-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
The MathJax class forces ltr direction on messages #627
Comments
As Davide said elsewhere these yellow messages are actually MathML merror elements and are then converted into SVG, HTML-CSS or MathML (according to the selected output mode). It's possible to use a direction: rtl CSS property on the MathML token elements, but that won't work on non-browser MathML rendering (i.e. MathPlayer here). MathML has a dir attribute that could be used for that purpose and should work in Firefox native MathML and (I guess) MathPlayer. MathML bidi is not implemented yet in MathJax and we need that for the SVG/HTML-CSS output modes. Actually, here only the dir attributes on the MathML token element is necessary. I guess we can use the dir attribute for the HTML-CSS element. For SVG, I suspect that would be a bit more complicated since we use <path> not <text> elements. Probably we can rely on the mtextInherit work, here. |
I've created an experimental bidi branch that just implements basic features for MathML bidi that are needed here. This should work in MathML and HTML-CSS output modes, not SVG yet. @amire80 Can you try http://devel.mathjax.org/testing/mathjax/MathJax-bidi/test/localization.html?locale=he and see if that gives better result? The default output mode is HTML-CSS, you may switch to the MathML in Firefox and see if that works too. Known issues:
|
It is not better. The parent <span>s of the error messages carry style="direction: ltr" which is applied to the error messages, so they are still wrong. How can I switch to MathML? |
... Although the MathJax class doesn't have direction: ltr any more. |
Use the MathJax menu: right click on any equation and choose Math Settings → Math Renderer → MathML |
(look at the "TeX" item of the test page, as the "MathML" one has probably issues) |
@amire80: Which span carries style="direction: ltr"? I see that the default is direction=ltr until we arrive at the span with class="mstyle", where it becomes rtl until the text node. Here is what I get in HTML-CSS output mode: I think I have fixed the remaining MathML messages. However two messages on the test page (the bold ones) are not generated by the normal code path and are just "faked", so they won't render correctly (however they will render correctly in the rare cases when they happen by the normal way). |
@amire80 I've tried something for the SVG output too. Can you please try again with the three output modes (HTML, SVG and MathML)? http://devel.mathjax.org/testing/mathjax/MathJax-bidi/test/localization.html?locale=he (be sure to clear the cache) |
=> Setting ready for review, just to get preliminary feedback. https://github.com/fred-wang/MathJax/compare/mathjax:develop...bidi The idea is to implement MathML bidi just for what is necessary for the merror messages. For the MathML output, it's just setting the correct dir attribute. For the SVG, I only considered the cases where <text> is used. For HTML, I just apply the css direction=rtl property on the span ; this is probably wrong in general but will work for the error messages and might help people wanting simple support like in #610 (if that hack is not wanted, I can remove that). I only considered dir on math/mstyle/tokens not mrow. |
The current version at http://devel.mathjax.org/testing/mathjax/MathJax-bidi/test/localization.html?locale=he looks good. Thanks! |
Great, thanks for the feedback :-) |
@fred-wang, I've taken a look at the code and have the following recommendations: Since you need to check the
after the Then, in the AsciiMath, MathML, and TeX input jax, you can use things like
rather than
Note also that your version forces In
can become
instead. The second error message can be treated similarly. Note that there is also a corresponding error in the I did some reading about the direction CSS, and (as the OP suggested), it might be better to use So I'd recommend changing
Note that this also only sets the value when it is actually needed (i.e., when it has been specified as something other than the default), whereas the current implementation alway adds the attribute to every token element, whether it is needed or not. Finally, because the token elements will inherit the value from |
The idea was to try to implement an experimental and rudimentary support for the "overall direction bidi" in the HTML output as asked in #610 instead of just the bidi for token elements that is needed here. It seems that might work for simple equations, but I suspect that in general this is incorrect and would need more careful work. However, since that was asked by @mohsen-ghaly, I thought adding this experimental hack would be useful for some people. That won't be problematic for the error messages, since there is essentially only one single merror element here. However as I said, I can remove that if you prefer. |
I think it would be best to wait with that until we can do it properly, rather than have people start using something that will likely change substantially in the future. I can see them doing things to get around the problems that will just get them into trouble later. Fixing the error messages is an important step, but the bidi control for the rest of the math probably should wait. |
Yes, that makes sense. I'll update the branch today. |
https://github.com/fred-wang/MathJax/compare/mathjax:develop...bidi => Ready For Review @dpvc could you please add a look again today, so that we can merge this and start the beta release process? |
I had added the
could be handled as
putting the => Ready for Release |
Oops, sorry I missed that change. I'll do it when I do the pull request. |
Thanks. I just noticed that putting the |
There are two occurrences in the HTML-CSS glyph.js and one in the SVG glyph.js. |
=> Merged |
This adds an extra comma causing a crash on old versions of IE. I've removed the comma from the beta branch, but this should be fixed on develop. |
As I look at http://devel.mathjax.org/testing/mathjax/MathJax-issue530/test/localization.html?locale=he , I see that all the error messages (yellow background, red text and border) are shown with direction: ltr in the CSS. User interface messages in right-to-left languages must have direction: rtl.
(W3C's best practices for bidirectional HTML suggest to use HTML dir="rtl" and not CSS direction: rtl. If this be fixed using the HTML dir, it is preferable, but that is secondary.)
The text was updated successfully, but these errors were encountered: