oxygenxml / blog

Oxygen XML Editor Blog Posts
4 stars 12 forks source link

Using MathML Equations with DITA #7

Open raducoravu opened 4 years ago

raducoravu commented 4 years ago

Converted from internal issue EXM-38364

Pasting an answer I gave some time ago:

Yes, embedded MathML works fine for me with DITA-OT 2.2.x. Please follow these steps:

To add DITA support for MathML:

Download jeuclid-core-3.1.9.jar, jeuclid-fop-3.1.9.jar and put them in DITA-OT/plugins/org.dita.pdf2.fop/fop/lib

Install dita community plugins:

Download the archive:

https://github.com/dita-community/dita13-dita-ot-1.x-support/releases/download/1.0.2/dita13-support-toolkit-plugins-1.0.2.zip

Unpack and copy 3 directories to DITA-OT/plugins/ (doctypes plugin is not needed since DITA-OT 2.2.0):

org.dita-community.common.xslt

org.dita-community.dita13.html

org.dita-community.dita13.pdf

Enable character entities by replacing “IGNORE” with “INCLUDE” on line 81:

DITA-OT/plugins/org.oasis-open.dita.v1_3/dtd/technicalContent/dtd/mathml/mathml3-ditadriver.dtd

<!ENTITY % mathml-charent.module "INCLUDE" >

Please also make sure to correctly embed MathML into your DITA files. I use "equation-figure" element to embed mathml. Here is an example:
<equation-figure>
<mathml>
<m:math xmlns:m="http://www.w3.org/1998/Math/MathML">
<m:mi>x</m:mi>
</m:math>
</mathml>
</equation-figure>

I need to create a formula with a square root symbol. How can this be accomplished in DITA 1.2?

Example using the non-existing element <square-root> to illustrate what I want to do:

dE<sub>ab</sub> = <square-root>(dL)<sup>2</sup>(da)<sup>2</sup>(db)<sup>2</sup></square-root>

Is there a DITA-OT plug-in (compatible with V1.7.1) that allows me to use such elements?

DITA 1.3 has support for embedding MathML content. But if that looks
right in the published HTML-based output depends on the web browser.
Referencing the MathJax Javascript libraries in the generated HTML
content helps:

http://blog.oxygenxml.com/2013/10/using-mathjax-to-properly-view-mathml.html

As possible other approached you can either refer to a binary image
containing the formula or somehow dynamically convert the mathml to a
binary image when the publishing is done. Or have the equation available
as an SVG image and refer to it. SVG recently started being supported
quite well by web browsers.

An easy workaround is to create your equation in an editor and insert it as graphic.

DITA for Publishers includes support for MathML that predates DITA 1.3 by many years—it’s now obsolete in the face of DITA 1.3’s support for MathML but it does work with DITA 1.2 as long as you can integrate the domains into your document types.

Otherwise using images or some custom-built version of the DITA 1.3 mathmlref will be your only options.

Go to MathML Cloud, insert your equation in mathml and process it. Copy the SVG out and use that SVG as an image in your document. You may have to add some fonts in your processing but that is an easy way to do one or a few equations and get them in highest quality format that work with both browsers and PDF renderers,
raducoravu commented 4 years ago

This topic in the Oxygen user's guide covers the HTML publishing: https://www.oxygenxml.com/doc/versions/21.1/ug-editor/topics/whr-mathml-support-x-2.html