emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problems with LaTeX export for $x\text{foo $x$}$-like construts?


From: Ihor Radchenko
Subject: Re: Problems with LaTeX export for $x\text{foo $x$}$-like construts?
Date: Thu, 29 Dec 2022 11:52:44 +0000

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>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]