blefloch / latex-unravel

Watching TeX digest tokens
24 stars 1 forks source link

obtain unraveled TeX code #25

Open MareoRaft opened 7 years ago

MareoRaft commented 7 years ago

This is a question and perhaps a feature request.

Is there a nice way to obtain the unraveled TeX code (the FINAL step shown before the compiler exits)?

Basically, I have to move some math LaTeX code to MathJax, and since MathJax supports less features that LaTeX, the most unravelled code is what I'm after. A good solution would be a script that takes in the LaTeX code and outputs the unravelled code.

blefloch commented 6 years ago

Now there is partial support with \unravel_get:nnN { mute } { "some code" } \l_result_tl. However since I had not planned this feature from the start I almost certainly abused the fact that I only cared about the output as a string. Another thing to keep in mind is that unravel goes all the way down to primitives, which is often not what one wants when expanding a user's macro. For instance it would probably be better to turn $\newcommand{\ZZ}{\mathbb{Z}}\ZZ$ into $\mathbb{Z}$ rather than a low-level font selection command.