asciidoctor / asciidoctor-pdf

:page_with_curl: Asciidoctor PDF: A native PDF converter for AsciiDoc based on Asciidoctor and Prawn, written entirely in Ruby.
https://docs.asciidoctor.org/pdf-converter/latest/
MIT License
1.14k stars 501 forks source link

MathML embedded in AsciiDoc #2409

Closed franklinvp closed 1 year ago

franklinvp commented 1 year ago

MathML and LaTeX/AsciiMath don't express the same type of information. For that reason, it is not always easy to convert to AsciiiDoc a large project that contains equations in MathML, for example from DITA.

Could AsciiDoc allow embedding MathML directly, for example, in the STEM expression or other in a way that asciidoctor-pdf can then render properly?


One way in which the MathML can be embedded is to put it inside a passthrough block. For example,

A displayed
++++
<equation-figure>
<mathml>
<math xmlns="[http://www.w3.org/1998/Math/MathML"](http://www.w3.org/1998/Math/MathML%22) display="block">
  <msqrt>
    <mn>2</mn>
  </msqrt>
</math>
</mathml>
</equation-figure>
++++
equation

Conversion to HTML works fine. MathJax takes care of rendering the equation. However, asciidoctor-pdf gives ERROR: failed to parse formatted text. Trying asciidoctor-pdf -r asciidoctor-mathematical -o test.pdf test.adoc also gives the same error.

mojavelinux commented 1 year ago

I wonder whether this would actually be more appropriate for Asciidoctor Mathematical. Asciidoctor PDF has no way of processing MathML. And it already relies on a third party library to process LaTeX (Mathematical). If Asciidoctor Mathematical can't handle it, then it may be necessary to introduce another extension. So Asciidoctor PDF could integrate with something if it exists (or someone creates it), but it can't process MathML itself. Something has to convert MathML to an SVG (or similar).

franklinvp commented 1 year ago

I see. Should I close here and move it there?

mojavelinux commented 1 year ago

Before opening yet another issue, I would recommend inquiring about what it's actually going to take to get this to work. And the appropriate place to do that is the project chat at https://chat.asciidoctor.org. Generally, open source maintainers don't like issues being made for feature requests that haven't been researched or vetted as there's no clear path to implementing them (and thus no time to even consider it). It's best to first try to get some research done behind an idea (and to build support for it), then come forward with a concrete proposal. Again, that's what the project chat is there for.

mojavelinux commented 1 year ago

Given that all math is handled by an extension in Asciidoctor PDF, this would be as well. Therefore, I'm closing only to say this is not the place for it. It's possible it is suitable for Asciidoctor Mathematical, especially since it also handles AsciiMath (despite the name). But I would still determine which library is going to be used to convert from MathML to SVG before raising an issue there.