NanoMichael / MicroTeX

A dynamic, cross-platform, and embeddable LaTeX rendering library
MIT License
435 stars 74 forks source link

Added support for building wasm from meson #155

Closed sp1ritCS closed 1 year ago

sp1ritCS commented 1 year ago

For some reason, when using the meson built microtex-wasm.wasm it initially starts to throw a few microtex::ex_parse: Missing '['! and microtex::ex_parse: Missing '{'! when switching rendering mode that don't occur with cmake. But since wasm seems impossible to debug, I didn't look into it further.

Also replaced a mirror that seems to be only resolvable in mainland china with the normal npmjs registry, as npm just hangs otherwise and it'll fail eventually (also using http instead of https 😬 ).

sp1ritCS commented 1 year ago

Looking at the wasm build artifact, it seems that meson build is more busted than I thought it was. Def. not ready to merge yet.

sp1ritCS commented 1 year ago

Ok, I've got some form of debugging working and it seems string indexing is really broken.

in Parser::parse() the following string "-b\\pm\\sqrt{b^2-4ac}" with _pos being 10 sets ch to \ instead of the expected {.

Same for the string "T\\kern-.15em\\raisebox{-.4ex}{E}\\kern-.15em X" with _pos being 28 results in ch being \ instead of the expected {.

This is really wierd and I have no idea why this is.


I did some more side-by-side native v. wasm debugging and it turns out that the exceptions in wasm aren't checked if they are catched further up the stack. So Parser::getGroup throws ex_parse and it is immediately passed to javascript instead of being caught by Parser::getOptsArgs in the getOpts lambda.