Rudolf Adamkovič <rud...@adamkovic.org> writes: >> 1. <begin cell> \(<end cell><begin cell>x<end cell><begin cell>\) <end cell> >> 2. <begin cell> <begin latex>|x|<end latex> <end cell> >> >> Org parser chooses one. It has to choose some. >> Org parser also chooses a simpler interpretation that does not require >> backtracking. > > But (2) is a *much, much, much* better choice (for the user).
Maybe, but it is also much more complex in terms of parser. Backtracking will introduce non-linear complexity to the parser, degrading the performance significantly. It will also make Org syntax much, much harder in more complex cases - there will still be ambiguities when you have more than 2 interpretations: e.g. | \(|x|\) | \(|x|\) | this one has 3 possibilities: 1. <cell> \(</cell><cell>x... 2. <cell> <latex>|x|\) | \(|x|</latex> </cell> 3. <cell> <latex>|x|</latex> </cell><cell> <latex>|x|</latex> </cell> And there will be similar situations with even more possibilities. In fact, the number of ambiguous alternatives can blow up pretty quickly when the text is complex enough combination of literal and non-literal markups. In any case, the way Org parser works in this example is one of the most fundamental design decisions in the Org markup. We cannot change it at this point without breaking all the historical documents + third-party parsers. That's why I am talking about providing markup extension to address the issue rather than altering the existing parser fundamentals. -- Ihor Radchenko // yantar92, Org mode maintainer, 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>