[luatex] Intermediate tree representation of the document

Kalrish Bäakjen kalrish.baakjen at gmail.com
Wed Nov 23 12:35:27 CET 2016

There is no way that I know of. \section & company are nothing special
for the TeX engine; they're just macros that the engine expands as any
other. There are some parsers out there, but they seem somewhat
fragile, due to the complexity of TeX.

>From the Lua side it is possible to access the nodes of the document,
but I don't know if that would serve your purpose.

If all you need is document parts (sections, paragraphs,...),
references and some text features (bold, italics,...), you could
perhaps write your documents in another language that you could (more
easily) parse from your Python script (e.g. Markdown). Then, to
typeset them, you could either translate them to TeX before running
the engine (possibly sharing the parsing logic with your Python
script) or read them at document generation time with Lua.

More information about the luatex mailing list