michael-brade / LaTeX.js

JavaScript LaTeX to HTML5 translator
https://latex.js.org
MIT License
736 stars 58 forks source link

Dependency on svgdom #121

Closed ignacioxd closed 3 years ago

ignacioxd commented 3 years ago

I just discovered this project and it looks really promising!

Looking at the documentation for version 0.12.4, it seems like svgdom is required for latex.js to work as a library. This is not mentioned in the documentation explicitly, and in fact the claim on the front page is that "No external dependencies need to be loaded", but the two examples provided both require svgdom.

Is there a way to avoid the document is not defined error thrown when not using svgdom? Otherwise, if svgdom is indeed required, should it be included as a dependency?

I haven't tried using latex.js as a CLI tool, but if it can work in the CLI without svgdom it should be possible to get it to work as a library as well.

ignacioxd commented 3 years ago

On second thought, svgdom may be a dependency of just HtmlGenerator and not latex.js itself. Maybe these should be decoupled, perhaps including a default PlainTextGenerator instead.

michael-brade commented 3 years ago

Yes, when latex.js is used in the browser, no dependencies are required. However, if it is used outside of the browser environment, a DOM implementation becomes necessary, there is no way around it. The CLI also uses svgdom.