mathjax / MathJax-node

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

[SVG output] margin-bottom lost #233

Closed pkra closed 8 years ago

pkra commented 8 years ago

Via https://phabricator.wikimedia.org/T135423; cc @physikerwelt.

It seems like margin-bottom is missing when generating output with mathjax-node.

E.g., $\underline{\mathbb{Z}}$ will get style="vertical-align: -0.52ex;" from mathjax-node but in a page would get vertical-align: -0.52ex; margin-bottom: -0.734ex;.

dpvc commented 8 years ago

It looks like the CSSStyleDeclaration (used by jsdom) handling of ex units isn't right, so the margin-bottom isn't being set. I'll have to look into it. It is part of the code I had supplied to them, but it used their routines for determining when a measurement is valid.

dpvc commented 8 years ago

Looks like their unit parser doesn't include ex. Argh! I'll have to see about patching that.

pkra commented 8 years ago

Thanks for looking into it, @dpvc.

dpvc commented 8 years ago

OK, I've included a patch in the issue233 branch. I still have to make a PR to the CSSStyleDeclaration site to fix the issue, but the patch should take care of it from our end for now.

dpvc commented 8 years ago

Note, the misalignment in the original complaint is due to the fact that method adjusts the placement (I haven't looked into how it does this), which may be necessary because it is a background image rather than a direct image element. It may be that the missing margin-bottom was causing their computations to go awry.

physikerwelt commented 8 years ago

@dpvc Thank you very much. The patch seems to work great. However, I have to admit that I do not understand how it works. Since quite a few lines were changed, I'm a afraid that it might break other things.

physikerwelt commented 8 years ago

OK. Ater having understood that https://github.com/mathjax/MathJax-node/commit/bd1d6c430dbd45d5e6db8e496bfc03619e411169#diff-c4f7e206b09703de4edb0800d5a5af15R386 really is a non trivial setter and the line below is a getter I can finally get an idea of the change.