mathjax / MathJax-node

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

[CommonHTML] lost inline style #433

Closed pkra closed 1 year ago

pkra commented 5 years ago

Originally reported at https://github.com/pkra/mathjax-node-page/issues/74 but this seems a mathjax-node issues

E.g., \bbox[lightgrey,2pt]{\text{Some lightgrey text}} generates

<span class="mjx-chtml MJXc-display" style="text-align: left;"><span class="mjx-math" aria-label="\bbox[lightgrey,2pt]{\text{Some test that is helpful}}"><span class="mjx-mrow" aria-hidden="true"><span class="mjx-mstyle"><span class="mjx-mrow"><span class="mjx-mpadded"><span class="mjx-block" style="width: 0px; margin-top: -0.07em; padding: 0px 10.829em 0.419em 0px;"><span class="mjx-box" style="width: 0px; margin: -0.73em 0px -0.219em; position: relative; left: 0.2em;"><span class="mjx-mrow"><span class="mjx-mtext"><span class="mjx-char MJXc-TeX-main-R" style="padding-top: 0.446em; padding-bottom: 0.519em;">Some test that is helpful</span></span></span></span><span class="mjx-strut"></span></span></span></span></span></span></span></span>

but in the browser we get e.g.

<span id="MathJax-Element-11-Frame" class="mjx-chtml MathJax_CHTML" tabindex="0" style="font-size: 127%;"><span id="MJXc-Node-71" class="mjx-math"><span id="MJXc-Node-72" class="mjx-mrow"><span id="MJXc-Node-73" class="mjx-mstyle" style="background-color: lightgrey;"><span id="MJXc-Node-74" class="mjx-mrow"><span id="MJXc-Node-75" class="mjx-mpadded"><span class="mjx-block" style="width: 0px; margin-top: -0.07em; padding: 0px 8.848em 0.431em 0px;"><span class="mjx-box" style="width: 0px; margin: -0.73em 0px -0.231em; position: relative; left: 0.2em;"><span id="MJXc-Node-76" class="mjx-mrow"><span id="MJXc-Node-77" class="mjx-mtext"><span class="mjx-char MJXc-TeX-main-R" style="padding-top: 0.396em; padding-bottom: 0.544em;">Some lightgrey text</span></span></span></span><span class="mjx-strut"></span></span></span></span></span></span></span></span>

I.e., the mjx-mstyle node has lost its inline style.

dpvc commented 5 years ago

This turns out to be a jsdom issue (actually, a cssstyle issue). It looks like named colors were only added to cssstyle 16 days ago! Try updating your copy of cssstyle to version 1.2.1, and see if that takes care of it. Doing npm install didn't seem to update it for me, but removing the package-lock.json file and then npm install did, so I guess the package-lock file needs to be updated.

I tried to update jsdom to version 13 (we are at 11) but both 13 and 12 caused file load errors, and I didn't try to track that down. I will have to see if I can figure out why version 11 loads fine but not later versions of jsdom.

dpvc commented 5 years ago

OK, it turns out that the addition of version numbers to the js files is breaking jsdom's file loading for versions 12 and above. Adding

      MathJax.Ajax.fileRev = function () {return ''};

to the AuthorInit function in lib/main.js resolves the problem, in case you want to update to the current jsdom.

pkra commented 5 years ago

Thanks, @dpvc. I think the workaround should be sufficient for the user who reported the issue.

Upgrading jsdom to latest seems like a good idea though. I'll make a PR when I get the chance.

pkra commented 1 year ago

Cleaning up my old issues.