emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@posteo.net>
To: alain.cochard@unistra.fr
Cc: emacs-orgmode@gnu.org
Subject: Re: Problems with LaTeX export for $x\text{foo $x$}$-like construts?
Date: Thu, 29 Dec 2022 11:52:44 +0000	[thread overview]
Message-ID: <875yduv33n.fsf@localhost> (raw)
In-Reply-To: <87wn6av84v.fsf@localhost>

Ihor Radchenko <yantar92@posteo.net> writes:

> Unfortunately, I do not see an easy solution without hitting parser
> performance. Our general approach is to avoid forward-parsing as much as
> possible with an exception to paired brackets (because Elisp allows
> parsing paired brackets fast using C-level code). However, AFAIK, there
> is no easy way to parse brackets that are not single symbols. "\(" is
> impossible to match using `scan-lists'.

One interesting idea to consider is using PEG (third-party ELPA package).
The above examples with paired parenthesis can be parsed using the
following PEG:

(with-peg-rules
    ((no-paren (not "\\(") (not "\\)") (any))
     (no-paren-expr (+ no-paren))
     (paren-expr "\\(" (* (or no-paren-expr paren-expr)) "\\)"))
  (peg-run (peg paren-expr)))

PEG is not built-in though, so we cannot use it in Org.

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


      parent reply	other threads:[~2022-12-29 11:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-28 13:57 Problems with LaTeX export for $x\text{foo $x$}$-like construts? Alain.Cochard
2022-12-29 10:04 ` Ihor Radchenko
2022-12-29 10:39   ` Alain.Cochard
2022-12-29 10:44     ` Ihor Radchenko
2022-12-29 11:52   ` Ihor Radchenko [this message]

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=875yduv33n.fsf@localhost \
    --to=yantar92@posteo.net \
    --cc=alain.cochard@unistra.fr \
    --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).