mathjax / MathJax-node

MathJax for Node
Apache License 2.0
614 stars 97 forks source link

mathjax-node render html result incorrect #453

Closed NoTalk-ly closed 4 years ago

NoTalk-ly commented 4 years ago

I create a equation render service with mathjax-node, but i found some latex macro reder to html looks like incorrect:

mathjax-node render result image

mathjax browser version render result image

actually this equation should be the second one.

i created a gist to repetition: https://gist.github.com/NoTalk-ly/e205447a7f79b5a4b6ed871edaa016ac

I alse compared this 2 result, I found that if i copy the style that mathjax browser script created, the equation looks like ok, and if I add css: ok to mathjax-node ’s config method, and add the created style by mathjax-node, the problem resolved。

but actually, as a servicer, I just want replace equation with html string that mathjax-node parse result and need not to add any style tag to html document, so how can i do to fix this problem ?

I can not use mathjax3 because I found that auto line breaking feature have not support, so I can only use mathjax-node 2.

thank you so much to create mathjax for us to display equation in browser~

dpvc commented 4 years ago

As you have found out, mathjax-node's html output can not be used without the companying CSS. That is one reason that mathjax-node provides you the option of obtaining that CSS. Your service could provide a means of serving that CSS.

You ask that this not be needed, but while some of the CSS could be included in in-line style attributes, not all of it could be. In particular, the CSS that loads web fonts needs to be in an actual stylesheet in the page. So it is not technically possible to create completely stand-alone html output for MathJax's output. (Unless you encapsulated your result inside an <iframe> that included the CSS, or with a custom element that used a ShadowDOM or some such thing.)

The SVG output, however, is much more portable. While there is some CSS to support links within the SVG, and a few other minor details, the SVG output does not have the heavy dependency on CSS that the CommonHTML output does. You might find that using SVGs is a better alternative.

NoTalk-ly commented 4 years ago

@dpvc thank you. maybe I should use the SVG outpu mode in your opinion.