-
Notifications
You must be signed in to change notification settings - Fork 5.5k
MathJax MML support #1565
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
MathJax MML support #1565
Conversation
|
For that matter, would it be useful to add a mathml mime type so kernels can send MathML directly, rather than going through Mathjax to create it? |
It's been an ISO standard since last year though only supported fully on Firefox. I'm on board with pushing for this standard. What JS libraries are available to render MathML? The only one I've found so far is MathJax. |
I think the answer to this is either MathJax or let the browser do it (Firefox only, I think). |
|
@takluyver Does this MathJax config depend on a MathML mime type or can we merge this and create a new issue regarding MathML mime type? |
|
I'm not exactly sure about this, but I think it's orthogonal to my suggestion - I think this is about Mathjax rendering latex-y maths to MathML, whereas I'm talking about the kernel publishing MathML directly. |
|
Can second that this is about MathJax configuration, namely MathJax being able to render MathML in addition to the currently configured TeX support. In Jupyter's current MathJax configuration, MathJax does not support MathML input at all. As @rgbkrk noted, kernels wanting to use MathML directly can only do this on Firefox. Most browsers (including Chrome, which had MathML support but killed it some time ago) do not support MathML directly (see the MathML column under https://en.wikipedia.org/wiki/Comparison_of_web_browsers#Web_technology_support) and thus need MathJax to convert MathML to something they can render (e.g. CSS and HTML). Even on Firefox, MathJax may add certain MathML features that Firefox's native MathML renderer does not support (see https://www.mathjax.org/mathjax-2-0-and-the-default-rendering-in-firefox/). So, in short, Jupyter kernels wanting to output MathML need the change proposed in this PR. |
|
OK, so this is about MathML input to MJ? I had misunderstood, then, I thought it was about MathML output. Presumably the idea is that kernels would produce MathML embedded in HTML output? Do you think it would be helpful to add a MathML output type (akin to SVG output, which we already allow)? |
|
Exactly, the kernel outputs MathML output as |
|
We output a dictionary of alternative formats, keyed by mime types (see display_data messages). As far as I know, we don't explicitly prevent sending any format in there, but the frontend only handles formats it recognises, and we don't currently recognise MathML. IPython also provides convenient mechanisms to display the formats Jupyter recognises. So what you're presumably doing at the moment is sending |
|
I've created #1670 for taht. |
|
Ok, to summarize: this PR simply updates MathJax config to accept MathML input in addition to TeX. Unless there are any objections, I'd like to merge this. @takluyver created #1670 to discuss adding a MathML mime type and handler so that MathJax can not only accept |
|
I'm certainly in favor. This doesn't have to change any mimetypes at this time and we can handle it later. |
|
Thanks @poke1024 for your contribution! |
|
@poke1024 Theoretically, we should be able to test this on master by pasting the following in a Markdown cell? <math>
<apply>
<plus/>
<apply>
<times/>
<ci>a</ci>
<apply>
<power/>
<ci>x</ci>
<cn>2</cn>
</apply>
</apply>
<apply>
<times/>
<ci>b</ci>
<ci>x</ci>
</apply>
<ci>c</ci>
</apply>
</math>It's not working for me. I've created a notebook to test: https://gist.github.com/gnestor/bbe456b13a0d1d8430d0caa8d8a8fd65 |
|
Using the example code from your notebook, changing I'm not sure what The other example above (using This is |
|
The |
|
@poke1024 Thanks, that worked for me. Regarding Content MathML, I added support for it and AsciiMath to MathJax in #1677. @takluyver Next I will add formatters and displayers for MathML and AsciiMathto to ipython. It think we need to consider whether the |
Allows kernels to provide math output as MathML (MML) in addition to TeX by changing the default MathJax configuration from
TeX-AMS_HTML-fulltoTeX-AMS-MML_HTMLorMML-full.This allows the MathML-bound https://github.com/mathics/IMathics kernel to render its math output properly.
Details of the new and old MathJax configurations are available at http://docs.mathjax.org/en/latest/config-files.html.
This is a follow-up of #1456.