Programmatically converting/parsing LaTeX code to plain text

前端 未结 8 1330
梦毁少年i
梦毁少年i 2021-02-04 10:06

I have a couple of code projects in C++/Python in which LaTeX-format descriptions and labels are used to generate PDF documentation or graphs made using LaTeX+pstricks. However,

8条回答
  •  闹比i
    闹比i (楼主)
    2021-02-04 11:03

    A word of caution: It is much more difficult to write a complete parser for plain TeX than what you might think. The TeX-level (not LaTeX) \def command actually extends TeX's syntax. For example, \def\foo #1.{{\bf #1}} will expand \foo goo. into goo - Notice that the dot became a delimiter for the foo macro! Therefore, if you have to deal with any form of TeX, without restrictions on which packages may be used, it is not recommended to rely on simple parsing. You need TeX rendering. catdvi is what I use, although it is not perfect.

提交回复
热议问题