[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Inline markup: How does org identify nested code/verbatim?
From: |
Ihor Radchenko |
Subject: |
Re: Inline markup: How does org identify nested code/verbatim? |
Date: |
Mon, 30 Jan 2023 14:56:14 +0000 |
<c.buhtz@posteo.jp> writes:
> The point is myself I'm able to identify code or verbatim with regex
> including three catch groups for the content before, between and
> after the inline markers.
>
> for verbatim: "(^|[ .,;:\-?!({\"'])=(.*?)=([ .,;:\-?!)}\"']|$)"
> for code: "(^|[ .,;:\-?!({\"'])~(.*?)~([ .,;:\-?!)}\"']|$)"
>
> But they don't work together. In the example above I need to use the
> verbatim regex first to make it right.
See https://orgmode.org/worg/org-syntax.html#Emphasis_Markers
Note that Org is not context-free. Within Org AST elements that can
contain objects, the first match "wins":
1. Org looks at a text and searches the first matching object regexp
2. Everything before the match is considered plain-text
3. Everything inside the match is considered the matched object and then
parsed recursively
4. go to (1)
--
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>