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

mfrac linethickness causes render issues #2381

Closed
andreeapescar opened this issue Mar 25, 2020 · 6 comments
Closed

mfrac linethickness causes render issues #2381

andreeapescar opened this issue Mar 25, 2020 · 6 comments
Labels
Accepted Issue has been reproduced by MathJax team Fixed Test Needed v3
Milestone

Comments

@andreeapescar
Copy link

andreeapescar commented Mar 25, 2020

When linethickness is set, the fractions don't render properly, the line height is wrong ( <math><mrow><mo>-</mo><mfrac linethickness="1"><mn>1</mn><mn>3</mn></mfrac></mrow></math>).

I tried to render in multiple ways:
image

And this how it renders:
image

The ones that have linethickness="1" set don't render properly.
(I observed that em is used to render that line.)

Is there any fix for this?
Thank you!

@dpvc
Copy link
Member

dpvc commented Mar 25, 2020

I'm moving this to the main MathJax issue tracker, so that it is listed with all the other issues.

@dpvc dpvc transferred this issue from mathjax/MathJax-src Mar 25, 2020
@dpvc
Copy link
Member

dpvc commented Mar 25, 2020

The display for linethickness="0" is also correct, as that means there should be no line, which is what you are seeing.

Note that line thickness is a length, and so should either have units or be a named length (like medium). Unitless lengths are deprecated, and are available only for backward compatibility. They are supposed to represent a multiple of the default length, and so in that sense, the result is incorrect, but it turns out that MathJax treats linethickness="1" as linethickness="1em" in this case. That needs to be fixed.

It is not clear what result you are looking for. If linethickness="1" is supposed to produce the normal line thickness, then you could use linethickness="medium". Otherwise, use an explicit unit to get the size you want.

It is possible to use a MathML pre-filter to convert unitless line thickness to multiples of .06em (the size of medium). How that is done differs between version 2 and version 3, so I would need to know which you are using in order to advise you further.

@dpvc
Copy link
Member

dpvc commented Mar 25, 2020

I've made a pull request to fix the unitless linethickness value in version 3.

@andreeapescar
Copy link
Author

andreeapescar commented Mar 25, 2020

Thank you for your quick response!

You are right, The display for linethickness="0" is also correct, I am sorry for that mistake, I will update the issue.

I thought linethickness="1" is supposed to produce the normal line thickness, without having to replace "1" with "medium".

What I need this for:
I get a string like: <math><mrow><mo>-</mo><mfrac linethickness="1"><mn>1</mn><mn>3</mn></mfrac></mrow></math> and I have to render it as html (which I do with dangerouslysetinnerhtml) without having to parse the string.

I am using mathjax-full "^3.0.0".

I assume that after your PR is merged, linethickness="1" will produce normal line thickness, right?

@dpvc
Copy link
Member

dpvc commented Mar 25, 2020

I thought linethickness="1" is supposed to produce the normal line thickness

It is, but that usage is discouraged by the MathML specification:

"A number without a unit is interpreted as a multiple of the reference value. This form is primarily for backward compatibility and should be avoided, prefering explicit units for clarity."

I assume that after your PR is merged, linethickness="1" will produce normal line thickness, right?

After it is merged, it will be in the develop branch. This will become part of v3.0.2 when develop is merged into master. At that point, the mathjax-full package will be updated, and you can use npm install to get the fixed version.

In the meantime you could use something like

mml = mml.replace(/ linethickness\s*=\s*"([1-9][0-9]*(?:\.[0-9]*)?)"/g, 
          function (match, n) {return ` linethickness="${parseFloat(n)*.06}"`})

in order to work around the problem for now.

@andreeapescar
Copy link
Author

Awesome. Thanks a lot for helping! 👍

dpvc added a commit to mathjax/MathJax-src that referenced this issue Apr 3, 2020
Make unitless linethickness be a multiple of the default size.  (mathjax/MathJax#2381)
@dpvc dpvc added Merged Merged into develop branch Fixed and removed Ready for Review labels Apr 3, 2020
@dpvc dpvc closed this as completed Apr 10, 2020
@dpvc dpvc removed the Merged Merged into develop branch label Sep 3, 2020
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
Projects
None yet
Development

No branches or pull requests

2 participants