emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Inconsistent text markup handling when double-nesting markers
@ 2023-10-09 23:02 Tom Alexander
  2023-10-10 12:07 ` Ihor Radchenko
  0 siblings, 1 reply; 9+ messages in thread
From: Tom Alexander @ 2023-10-09 23:02 UTC (permalink / raw)
  To: emacs-orgmode

I used the following test document:
```
__foo__

**foo**
```

I'd expect the two to behave the same but the first one parses as:
```
(paragraph
  "_"
  (subscript "foo")
  "__"
  )
```

Whereas the second parses as:
```
(paragraph
  (bold
    (bold
      "foo"
      )
    )
  )
```

This pattern happens in worg at [2]

Looking at the description for text markup in the syntax document[1], I don't see any reason the first wouldn't be parsed as an underline:

1. PRE: valid because it is the beginning of a line
2. MARKER: valid underscore
3. CONTENTS: valid. Series of objects from standard set includes both subscript and text markup, so regardless of how we parse the interior, its valid. Also cannot begin or end with whitespace but there is no whitespace in the CONTENTS.
4. MARKER: valid underscore
5. POST: Only valid if we extend the underline to the 2nd underscore so it ends at the end of the line. But the 2nd line shows us that having copies of the marker inside the CONTENTS is fine so I see two possible expected parses of the CONTENTS:
    4a. (underline "foo")
    4b. ((subscript "foo") (plain-text "_"))

I also ran the following test document to further prove that having copies of the marker inside the CONTENTS is fine:
```
*foo*bar*
```
which parses as (bold "foo*bar")

So the only way the top line would fail to parse as an underline is if it matched the first closing underscore as closing the underline, but that would be invalid because underscore is not a valid POST character and invalid copies of the closing marker are ignored as proven by both "**foo**" and "*foo*bar*".


[1] https://orgmode.org/worg/org-syntax.html#Emphasis_Markers
[2] https://git.sr.ht/~bzg/worg/tree/ba6cda890f200d428a5d68e819eef15b5306055f/org-contrib/babel/intro.org#L117

--
Tom Alexander
pgp: https://fizz.buzz/pgp.asc


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-10-12 12:04 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2023-10-11 14:40           ` Tom Alexander
2023-10-12 10:23           ` Max Nikulin
2023-10-12 12:04             ` Ihor Radchenko

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).