phfaist / pylatexenc

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

parse issue with `\newcommand{\be}{\begin{equation}}` #86

Closed nschloe closed 2 years ago

nschloe commented 2 years ago

With

\newcommand{\be}{\begin{equation}}

pylatexenc doesn't recognize the \begin{equation} as a command, but expects a closing statement which doesn't come.

phfaist commented 2 years ago

This is an inherent limitation of how pylatexenc works. Pylatexenc is not a replacement for a full (La)TeX engine. Instead, it parses content in a markup-like fashion to build a node tree of a document.

In the upcoming version of pylatexenc, there will be support for better handling of commands with complicated argument structures, and there will be opportunities to better support commands such as \newcommand.

Closing as the core of the issue is already filed as #50.

nschloe commented 2 years ago

Thanks for going through all the issues.

I had at first thought I might be able to use pylatexenc, but because of things like this one here, I started implementing my own TeX engine. (A parser won't cut it, as you correctly point out.)

If not important for you, feel free to close the issues I opened.

harvetech commented 5 months ago

@nschloe did you complete your latex engine ? I am in the same boat but reinventing a latex engine seems too much to me.