Thursday, October 31, 2013

Using MathJax to properly view MathML equations in the WebHelp output.

Share to Facebook Share to Twitter Email This Share on Google Plus Share on Tumblr
MathJax is a solution to properly view MathML equations embedded in HTML content in a variety of browsers:


http://www.mathjax.org/

Let's say you have Docbook or DITA content which has embedded MathML equations and you want to properly view the equations in the published WebHelp output.
Without  the help of the MathJax Javascript code, right now only Firefox can render the equations.

For my tests I created a new DITA topic starting from our "DITA Composite with MathML" new file template which contains an embedded MathML equation. Then I referenced this topic in a small DITA Map.

The PDF output created using Apache FOP properly displayed the MathML equation so you do not need any customization for it.

As for the HTML output in order to use MathJax I created a file called footer.html with the content:

<script type="text/javascript"
    src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>

Then I edited the DITA Map WebHelp transformation scenario and set the parameter args.hdf to point to the footer.html resource.

I transformed to WebHelp and the equation was properly rendered in the browsers I tested with (IE, Chrome and Firefox).


No comments:

Post a Comment