MathML in HTML5

259 views
Skip to first unread message

Dita OT Beginner

unread,
Jun 25, 2018, 5:26:48 AM6/25/18
to DITA-OT Users
Hello,

I am trying to convert XML to HTML5 which kind of works. The problem is in generating MathML. Is this possible? if so, can someone please point me to a reference or documentation? I am very new to Dita OT.

I read the Dita OT documentation and I wrote a simple plugin to generate the HTML5 and I do get HTML5 but the parts where there is MathML look like this on the browser:

[/sectionstart/subsec1/subsec2/p/inlineequation/mml:math/mml:mrow {""}) 

Thank you :)

Radu Coravu

unread,
Jun 25, 2018, 6:30:03 AM6/25/18
to Dita OT Beginner, DITA-OT Users
Hi,

The DITA OT (even the most recent version, 3.1) does not have support for publishing embedded MathML content:

There are some DITA OT plugins developed by Eliot Kimber which can be installed separately from:


You would need from there only the "org.dita-community.dita13.html" and "org.dita-community.common.xslt" folders.
You would also need to specify in the HTML headers for all generated pages (there is a transformation parameter to add custom header content to all HTML documents) a reference to the MathJax javascript libraries, otherwise few browsers support rendering MathML by default:


Regards,
Radu

--
You received this message because you are subscribed to the Google Groups "DITA-OT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dita-ot-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dita OT Beginner

unread,
Jun 25, 2018, 7:36:18 AM6/25/18
to DITA-OT Users
Hi, 

I have put the "org.dita-community.dita13.html" and "org.dita-community.common.xslt" folders in the Dita OT plugins folder and I run the "dita --install" command but I am not sure what to do next. 

I am not sure which transtype I should use with the plugin (HTML)?

Some more documentation would really help. I can't see from the project documentation how I can run it: https://github.com/dita-community/dita13-dita-ot-1.x-support

Regards.





To unsubscribe from this group and stop receiving emails from it, send an email to dita-ot-user...@googlegroups.com.

Radu Coravu

unread,
Jun 25, 2018, 7:51:44 AM6/25/18
to Dita OT Beginner, DITA-OT Users
Hi,
The plugins apply to any HTML-based obtained output, so you can run directly DITA to XHTML, HTML5 or to your custom HTML transtype and they should properly process the embedded MathML content.
After publishing you can open a generated HTML document and look inside it, see if the MathML elements have been properly preserved.

Regards,
Radu

To unsubscribe from this group and stop receiving emails from it, send an email to dita-ot-users+unsubscribe@googlegroups.com.

Dita OT Beginner

unread,
Jun 26, 2018, 9:01:35 AM6/26/18
to DITA-OT Users

The MathML haven't been properly preserved. I actually just need to remove mml: from every MathML element and keep the rest of the elements as is.
I have two questions: 


Can Dita OT ignore an element that I would specify. For example: If I supply pure MathML, then Dita OT doesn't need to convert it, just hop over it and convert the rest of the xml file.

How can I remove or replace all elements that have <mml: with empty space in Dita OT during conversion to HTML5?

Radu Coravu

unread,
Jun 27, 2018, 1:24:31 AM6/27/18
to Dita OT Beginner, DITA-OT Users
Hi,

I realise I should have given you more detailed steps and also try first things on my side.
As penitence I will give the detailed set of steps below:

Let's start with a small example:

1) I have a DITA topic which has a small MathML equation in it:

<!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">
<topic id="sample">
    <title>My title</title>
    <body>
        <p><mathml>
            <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"
                display="block">
                <m:semantics>
                    <m:mrow>
                        <m:mrow>
                            <m:mi mathvariant="bold">a</m:mi>
                            <m:mo>=</m:mo>
                            <m:mfrac>
                                <m:mrow>
                                    <m:mi mathvariant="bold">F</m:mi>
                                </m:mrow>
                                <m:mi>m</m:mi>
                            </m:mfrac>
                        </m:mrow>
                    </m:mrow>
                </m:semantics>
            </m:math>
        </mathml></p>
    </body>
</topic>

I create a small DITA Map, add a topicref to the topic and then use DITA OT 3.1 to publish to HTML5.
I look at the equivalent produced "topic.html" and the MathML equation is not there at all:

    <div class="body">
        <p class="p"></p>
    </div>

 
2)  I download this folder plugin from there:


and the plugin folder "org.dita-community.dita13.html" from there:


So you should have two folders "org.dita-community.common.xslt " and "org.dita-community.dita13.html" each containing a plugin.xml and a bunch of folders and stylesheets.

Copy them to the "DITA-OT/plugins" folder. I'm using DITA OT 3.1 for testing this.

3) Edit the "org.dita-community.dita13.html/plugin.xml" and after the line which adds the XSLT customization for the XHTML output:

  <feature extension="dita.xsl.xhtml" value="xsl/dita13Vocab2Html.xsl" type="file"/>

add this line which also adds the same customization for HTML 5 output:

  <feature extension="dita.xsl.html5" value="xsl/dita13Vocab2Html.xsl" type="file"/>

I'm attaching a zip containing both plugins with the changes I suggested already made to the plugin.xml.

4) Run the DITA OT integrator, on Windows this would usually mean running in the DITA-OT folder the "bin/dita.bat - install"  command.


5) Publish again, the result "topic.html" should now contain:

<div class="body">
        <p class="p">
            <math xmlns="http://www.w3.org/1998/Math/MathML">
                <semantics>
                    <mrow>
                        <mrow>
                            <mi mathvariant="bold">a</mi>
                            <mo>=</mo>
                            <mfrac>
                                <mrow>
                                    <mi mathvariant="bold">F</mi>
                                </mrow>
                                <mi>m</mi>
                            </mfrac>
                        </mrow>
                    </mrow>
                </semantics>
            </math>
        </p>
    </div>

Regards,
Radu

To unsubscribe from this group and stop receiving emails from it, send an email to dita-ot-users+unsubscribe@googlegroups.com.
plugins.zip
Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
0 new messages