asciidoctor-mathematical icon indicating copy to clipboard operation
asciidoctor-mathematical copied to clipboard

Add support for mathml output, closes #110, #118

Open infinity0 opened this issue 2 years ago • 8 comments

Enable by setting mathematical-format = mathml, mathematical-inline = true

infinity0 avatar Oct 27 '22 12:10 infinity0

The second commit is optional; I mentioned some details in #110. It would also be easy to tweak this PR to instead use plurimath over latexmath. That is, we have 3 options:

  • use latexmath -- 1st commit
  • use python-docutils' latex2mathml -- 2nd commit
  • use plurimath, the successor of latexmath -- I have a local commit for this, but it's not possible to test it until plurimath/plurimath#84 is fixed
  • use pandoc(1) -- 3rd commit

infinity0 avatar Oct 28 '22 11:10 infinity0

One downside of docutil's latex2mathml is that "supports only a subset of LaTeX math syntax". For example, it doesn't support {align}. (To its credit, latexmath does appear to support this.)

After some experimentation, my impression is that pandoc(1) supports converting the most wide-ranging set of LaTeX math features to MathML. I've therefore added a 3rd commit to switch to using pandoc(1). So we have a total of 4 options to choose from; I've updated the above comment to reflect that.

infinity0 avatar Oct 28 '22 13:10 infinity0

MathML is due to be released and enabled by default in Chrome 109, so nudging again on this.

infinity0 avatar Nov 14 '22 16:11 infinity0

More info:

  • https://chromestatus.com/feature/5240822173794304
  • https://bugs.chromium.org/p/chromium/issues/detail?id=6606

Note, MathML already works on Firefox and Opera.

infinity0 avatar Nov 14 '22 16:11 infinity0

Hello, I tried using your patch, but could not get it to work with AsciiDoctor PDF. Ended up with inline HTML in PDF.

<div class="stemblock"> <span class="math display">$$\lim_{n \to
\infty}\frac{n}{\sqrt[n]{n!}} = {\large e}$$</span> </div>

Could you please provide a example?

mateibarbu19 avatar Mar 01 '23 19:03 mateibarbu19

I've not tested PDF. I'm just using asciidoctor -a stem -r asciidoctor-mathematical -a mathematical-format=mathml -a mathematical-inline=true.

Example source here: https://github.com/infinity0/mkwww/blob/master/example/src/test%20with%20spaces.adoc (raw) Example output here: https://infinity0.github.io/mkwww/test%20with%20spaces.html

infinity0 avatar Jun 29 '23 12:06 infinity0

This PR is about MathML support. How do you expect MathML support to work inside a PDF, @mateibarbu19 ?

infinity0 avatar Jun 29 '23 14:06 infinity0

This PR is about MathML support. How do you expect MathML support to work inside a PDF, @mateibarbu19 ?

Hey, thanks for your helpful example! I was thinking that there may be a way of rendering it with an external call (e.g., to Chromium to then print it), and then including those graphics inside the PDF should be no problem.

I see now that my assumption was foolish, and I understand now how to use your fork for an HTML output.

Thank you!

mateibarbu19 avatar Aug 03 '23 18:08 mateibarbu19