bartp5 / libtexprintf

Library providing printf-style formatted output routines with tex-like syntax support.
GNU General Public License v3.0
27 stars 2 forks source link

LaTeX token don't work correctly #22

Closed JannesAlthoff closed 1 year ago

JannesAlthoff commented 1 year ago

Stuff like \frac 1\alpha or \frac {1}\alpha, which is valid LaTeX math produce errors:

❯ utftex '\frac 1 \alpha'

ERROR: Too few mandatory arguments to command (1x)
❯ utftex '\frac{1}\alpha'
Error, string is not proper UTF-8 code
Error, string is not proper UTF-8 code
1
─
JannesAlthoff commented 1 year ago

And

❯ utftex '\frac  {1}{\alpha^2}'

ERROR: Too few mandatory arguments to command (1x)

spaces between command and arguments don't work, while being valid LaTeX syntax.

bartp5 commented 1 year ago

Hi, you found two bugs, I did not skip spaces between the command and its arguments, and I did not properly handle multi-byte UTF-8 arguments without brackets (a pre-processor replaces the '\alpha' with α before I parse the arguments). I pushed a fix to dev branch. Thanks