From: <c.buhtz@posteo.jp>
To: emacs-orgmode@gnu.org
Subject: Inline markup: How does org identify nested code/verbatim?
Date: Sun, 29 Jan 2023 18:05:14 +0000 [thread overview]
Message-ID: <4P4fNv4F48z6tmQ@submission01.posteo.de> (raw)
Hi folks,
this is a question about org(mode) development itself.
It is magic to me how you do this. ;) And I would like to learn it
because I do write kind of an org parser in Python.
Here is a nested code-in-verbatim text.
This =is ~code~ in verbatim= text.
Exporting this to html (via org-html-export-as-html)
This <code>is ~code~ in verbatim</code> text.
Awsome! :D
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.
If I would use the code regex first it wouldn't work because it would
find the ~code~ but without knowing that it is surrounded by ~verbatim~.
I don't know what my users inputs to my software: verbatim in code or
code in verbatim. So I have to figure out which regex to use first.
How does org solve this problem? I don't need a full working solution
but just an idea.
One approach in my mind is to run both regex separate and then compare
the results "somehow":
Verbatim: ['This', ' ', 'is ~code~ in verbatim', ' ', 'text.']
Code : ['This =is', ' ', 'code', ' ', 'in verbatim= text.']
"Somehow"!
Another approach in my mind is to do something I would call nested
regex. Constructing a regex pattern looking for verbatim with code in
it. And the other way around of course.
next reply other threads:[~2023-01-29 18:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-29 18:05 c.buhtz [this message]
2023-01-29 18:20 ` Inline markup: How does org identify nested code/verbatim? c.buhtz
2023-01-30 2:29 ` Max Nikulin
2023-01-30 14:56 ` Ihor Radchenko
2023-01-30 23:36 ` Tom Gillespie
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=4P4fNv4F48z6tmQ@submission01.posteo.de \
--to=c.buhtz@posteo.jp \
--cc=emacs-orgmode@gnu.org \
/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).