phfaist / pylatexenc

Simple LaTeX parser providing latex-to-unicode and unicode-to-latex conversion
https://pylatexenc.readthedocs.io
MIT License
283 stars 35 forks source link

pylatexenc import latexpp NCArgsParser doesn't work #95

Open zhanghaiyu0511 opened 1 year ago

zhanghaiyu0511 commented 1 year ago

with open("data/tes.tex") as tex_file: latex = tex_file.read() l2t_context_db = latexwalker.get_default_latex_context_db()

l2t_context_db.set_unknown_macro_spec(MacroSpec("newcommand", NCArgsParser("newcommand"))) output = LatexNodes2Text().latex_to_text(latex, latex_context=l2t_context_db) print(output)

phfaist commented 1 year ago

Could you provide more context please? As far as I remember, the NCArgsParser from latexpp is not designed to be used outside of latexpp. It also needs to be rewritten because of some design issues.