Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SVG via jsdom: error messages cause NaN's #2550

Closed
pkra opened this issue Oct 6, 2020 · 3 comments
Closed

SVG via jsdom: error messages cause NaN's #2550

pkra opened this issue Oct 6, 2020 · 3 comments
Labels
Accepted Issue has been reproduced by MathJax team Fixed Test Needed v3 v3.1
Milestone

Comments

@pkra
Copy link
Contributor

pkra commented Oct 6, 2020

E.g.,

/MathJax-demos-node$ node jsdom/tex2svg "\begin{pkra}x\end{pkra}"

creates

<mjx-container class="MathJax" jax="SVG" display="true"><svg style="vertical-align: -0.452ex;" xmlns="http://www.w3.org/2000/svg" width="NaNex" height="2.149ex" role="img" focusable="false" viewBox="0 -750 NaN 950" xmlns:xlink="http://www.w3.org/1999/xlink"><defs></defs><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><g data-mml-node="math"><g data-mml-node="merror" data-mjx-error="Unknown environment 'pkra'" title="Unknown environment 'pkra'"><rect data-background="true" width="NaN" height="950" y="-200"></rect><title>Unknown environment 'pkra'</title><g data-mml-node="mtext" style="font-family: serif"><text data-variant="-explicitFont" transform="matrix(1 0 0 -1 0 0)" font-size="884px">\begin{pkra}x\end{pkra} </text></g></g></g></g></svg></mjx-container>

With several NaNs leading to broken output.

@pkra
Copy link
Contributor Author

pkra commented Oct 7, 2020

The same issue happens for "unknown" characters.

@dpvc dpvc added Accepted Issue has been reproduced by MathJax team Investigate v3 labels Oct 8, 2020
@dpvc
Copy link
Member

dpvc commented Oct 8, 2020

Thanks, I'll look into it. The jsdom adaptor probably needs to override the functions for measuring the content, as jsdom doesn't set the properties needed for that.

@dpvc
Copy link
Member

dpvc commented Feb 24, 2021

I've made a PR that addresses the problem. Since jsdom doesn't handle measurements of elements, like a browser DOM, we need to fake the measurements heuristically, like in the liteDOM.

@dpvc dpvc removed their assignment Feb 24, 2021
dpvc added a commit to mathjax/MathJax-src that referenced this issue Mar 12, 2021
Handle measuring of elements as in liteDOM, since jsdom doesn't do measurements.  (mathjax/MathJax#2550)
@dpvc dpvc added Merged Merged into develop branch and removed Ready for Review labels Mar 12, 2021
@dpvc dpvc added Fixed v3.1 and removed Merged Merged into develop branch labels Apr 27, 2021
@dpvc dpvc closed this as completed Apr 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accepted Issue has been reproduced by MathJax team Fixed Test Needed v3 v3.1
Projects
None yet
Development

No branches or pull requests

2 participants