mathjax / MathJax-node

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

[SVG] max-width with unitless value #399

Closed pkra closed 6 years ago

pkra commented 6 years ago

The SVG output generates a max-width as an inline style (e.g. labeled expressions). However, the value is missing a unit and is thus invalid.

MathJax itself seems to give the max-width is given in px.

pkra commented 6 years ago

Minimal example:

var mjAPI = require("./lib/main.js");
mjAPI.typeset({
  math: "\\begin{equation} x \\tag{1} \\end{equation}",
  format: ("TeX"),
  svg: true
}, function (data) {
  if (!data.errors) {console.log(data.svg)}
});
// => <svg xmlns:xlink="http://www.w3.org/1999/xlink" width="100ex" height="2.843ex" style="vertical-align: -0.838ex; max-width: 600;" ...
dpvc commented 6 years ago

The problem is line 2175 in the SVG jax.js file. It should have + 'px' at the end.

pkra commented 6 years ago

Huh, weird; I tested it and didn't see this with MathJax itself. If browsers add the px themselves, jsdom might consider this a bug.

dpvc commented 6 years ago

In earlier versions of CSS, unit-less values meant px, and browsers probably still handle that for backward compatibility. The CSSStyleDeclaration implementation in jsdom is very buggy (as you will recall), and I don't think it is currently being actively maintained.

pkra commented 6 years ago

Thanks for clarifying, Davide.

pkra commented 6 years ago

This has been fixed upstream (but perhaps closing this should wait until https://github.com/mathjax/MathJax/issues/1972 is resolved).