mathjax / MathJax-node

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

The tex2jax Preprocessor doesn't work! #423

Open ystreibel opened 6 years ago

ystreibel commented 6 years ago

Hi, this is the configuration and the test that I try to do but doesn't work for me.

const mathjaxNode = require('mathjax-node');
mathjaxNode.config({MathJax: {tex2jax: {inlineMath: [ ['$','$'], ['\\(','\\)'] ],processEscapes: true}}});

mathjaxNode.typeset({
                                    math: ''$ d = a \left( \eta _0 \right) \Delta \eta $'',
                                    format: "inline-TeX",
                                    svg: true,
                                    html: true
                                }, (data) => {
                if (!data.errors) {
                    label.displayLabel = data.html;
                    label.image = {
                        data: 'data:image/svg+xml;base64,' + Buffer.from(data.svg).toString('base64'),
                        contentType: 'image/svg+xml'
                    };
                }

And the result is for svg : <span class="mjx-chtml"><span class="mjx-math" aria-label="$ \frac {2 G m }{r c ^2 } $"><span class="mjx-mrow" aria-hidden="true"><span class="mjx-texatom"><span class="mjx-mrow"><span class="mjx-mo"><span class="mjx-char MJXc-TeX-main-R" style="padding-top: 0.446em; padding-bottom: 0.372em;">$</span></span></span></span><span class="mjx-mfrac"><span class="mjx-box MJXc-stacked" style="width: 1.672em; padding: 0px 0.12em;"><span class="mjx-numerator" style="font-size: 70.7%; width: 2.364em; top: -1.433em;"><span class="mjx-mrow" style=""><span class="mjx-mn"><span class="mjx-char MJXc-TeX-main-R" style="padding-top: 0.372em; padding-bottom: 0.372em;">2</span></span><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.519em; padding-bottom: 0.298em;">G</span></span><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.225em; padding-bottom: 0.298em;">m</span></span></span></span><span class="mjx-denominator" style="font-size: 70.7%; width: 2.364em; bottom: -0.85em;"><span class="mjx-mrow" style=""><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.225em; padding-bottom: 0.298em;">r</span></span><span class="mjx-msubsup"><span class="mjx-base"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.225em; padding-bottom: 0.298em;">c</span></span></span><span class="mjx-sup" style="font-size: 83.3%; vertical-align: 0.347em; padding-left: 0px; padding-right: 0.06em;"><span class="mjx-mn" style=""><span class="mjx-char MJXc-TeX-main-R" style="padding-top: 0.372em; padding-bottom: 0.372em;">2</span></span></span></span></span></span><span style="border-bottom: 1.3px solid; top: -0.296em; width: 1.672em;" class="mjx-line"></span></span><span style="height: 1.615em; vertical-align: -0.601em;" class="mjx-vsize"></span></span><span class="mjx-texatom"><span class="mjx-mrow"><span class="mjx-mo"><span class="mjx-char MJXc-TeX-main-R" style="padding-top: 0.446em; padding-bottom: 0.372em;">$</span></span></span></span></span></span></span>

Delimiter $ is not remove after the typeset.

What can I do to remove delimiter? Could I need to contribute for this project?

pkra commented 6 years ago

Mathjax-node expects a single expression without delimiters. You will need to remove them yourself beforehand.

ystreibel commented 6 years ago

But what about the MathJax configuration ?

mathjaxNode.config({MathJax: {tex2jax: {inlineMath: [ ['$','$'], ['\\(','\\)'] ],processEscapes: true}}});

pkra commented 6 years ago

But what about the MathJax configuration ?

It is ignored.

ystreibel commented 6 years ago

Ok! So, could you add this in a feature request?

Maybe fix the readme.md that say:

MathJax: { } // standard MathJax configuration options, see https://docs.mathjax.org for more detail.

because the project doesn't support all the MathJax features.