I would like to manipulate a LaTeX document in a program, e.g. add/change used packages or their options and adding environments.
Instead of doing this purely on the text level, it would be great to know if there is some kind of abstract syntax tree that one can generate for LaTeX. I know that this probably not as easy as for "real" programming languages because the structure is less rigid. But maybe there is a representation that is more helpful than the pure text file.
\begin-\endpairs and\section,\subsectionetc. does the trick for most cases. – Marijn May 23 '22 at 10:49