emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@posteo.net>
To: Max Nikulin <manikulin@gmail.com>
Cc: Tom Alexander <tom@fizz.buzz>, emacs-orgmode@gnu.org
Subject: Re: Inconsistent text markup handling when double-nesting markers
Date: Wed, 11 Oct 2023 12:26:45 +0000	[thread overview]
Message-ID: <87ttqx73ay.fsf@localhost> (raw)
In-Reply-To: <d0071071-63e6-465f-bf8a-b76ccff8a992@gmail.com>

Max Nikulin <manikulin@gmail.com> writes:

>> No, **bold** it is not a bug. The parser is recursive with inner markup
>> not "seeing" its parent. So, we first parse the outer bold and then
>> continue parsing the contents separately, as *bold*.
>
> I just find the following rather confusing:
>
> (org-export-string-as "**bold**" 'html t)
> "<p>\n<b><b>bold</b></b></p>\n"
> (org-export-string-as "**inner* outer*" 'html t)
> "<p>\n<b>*inner</b> outer*</p>\n"
> (org-export-string-as "*outer *inner**" 'html t)
> "<p>\n<b>outer <b>inner</b></b></p>\n"
> (org-export-string-as "*begin *inner* end*" 'html t)
> "<p>\n<b>begin *inner</b> end*</p>\n"

Maybe. It is indeed one of the edge cases. But it is following the
parser logic, which is (1) first matching markup is parser; (2) parsing
recursive contents is isolated.

>> Be it another way, /*bold italic*/ would also not be allowed as
>> we demand bol, whitespace, -, (, {, ', or " before the markup:
>> https://orgmode.org/worg/org-syntax.html#Emphasis_Markers
>
> Certainly /*b*/ should work, but nested bold was a surprise for me. I 
> believed that nesting is strictly prohibited. The case of underscores is 
> even more tricky due to ambiguity of underline and subscript.

It is not strictly prohibited on purpose. It is just a consequence of
how the parser works that nesting <end> constructs is almost impossible,
except certain edge cases like **b**.

> P.S. Juan Manuel at certain moment discovered that pandoc allows nesting 
> for *b1 *b2* b3*.

Which is a bug in pandoc.

I think we discussed this topic a number of times in the past - our
markup is a compromise between simplicity for users and simplicity of
the parser. This works in many simple cases, but edge cases become
problematic.

Workarounds have been discussed as well. For example, creole markup and
generic inline markup constructs (your idea with direct AST and the idea
with inline special blocks).

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


  reply	other threads:[~2023-10-11 12:26 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-09 23:02 Inconsistent text markup handling when double-nesting markers Tom Alexander
2023-10-10 12:07 ` Ihor Radchenko
2023-10-11  2:23   ` Max Nikulin
2023-10-11  9:15     ` Ihor Radchenko
2023-10-11 12:16       ` Max Nikulin
2023-10-11 12:26         ` Ihor Radchenko [this message]
2023-10-11 14:40           ` Tom Alexander
2023-10-12 10:23           ` Max Nikulin
2023-10-12 12:04             ` Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ttqx73ay.fsf@localhost \
    --to=yantar92@posteo.net \
    --cc=emacs-orgmode@gnu.org \
    --cc=manikulin@gmail.com \
    --cc=tom@fizz.buzz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).