Mathjax for equations rendering

Post here questions and problems related to editing and publishing DITA content.
gbv34
Posts: 38
Joined: Thu Jan 20, 2022 12:36 pm

Mathjax for equations rendering

Post by gbv34 »

Hello,
Eureka, I finally succeed in displaying equations in a project. However, they remain unstyled.
I can use mathjax to render them, but for that I have to insert in every HTML page a javascript call with this script:

Code: Select all

<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
Would you have any suggestion or plugin to use, knowing that I can't define a publishing parameter in Oxygen itself because my client will use the DITA-OT out of Oxygen.

Thanks a lot for your kind help.
Radu
Posts: 8010
Joined: Fri Jul 09, 2004 5:18 pm

Re: Mathjax for equations rendering

Post by Radu »

Hi,

Create somewhere on disk an XML file containing this:

Code: Select all

<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
If you publish to WebHelp responsive output, there is a transformation parameter named "webhelp.fragment.head" and for other HTML based outputs there is a parameter named "args.hdf" which need to point to the XML file containing the script.
https://www.oxygenxml.com/doc/versions/ ... bhelp.html

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
gbv34
Posts: 38
Joined: Thu Jan 20, 2022 12:36 pm

Re: Mathjax for equations rendering

Post by gbv34 »

Hello, Radu!
Thanks for your answer.

Unfortunately, I had two constraints:
- I must stick to an HTML scenario, meaning webhelp is not considered as a publishing scenario
- I can't use a parameter because the DITA-OT is externalized on a server.

A potential solution would consist in developing a plugin that automatically inserts a footer like described here: https://www.dita-ot.org/3.6/topics/html ... eader.html. However, my previous attempt remained unsuccessful and I didn't explore it further because we solved the problem of including the mathJax library, not with the js call, but only the relevant CSS in our style management system.

So far, this solution seems okayish. I wanted to share potential answers with the community.
Radu
Posts: 8010
Joined: Fri Jul 09, 2004 5:18 pm

Re: Mathjax for equations rendering

Post by Radu »

Hi,

I understand the situation, I do not quite understand how you made MathJax work only with CSS changes, changes which also need to be propagated to the publishing engine using parameters.
Also if at some point you create a DITA OT plugin which attempts to add a custom header and it does not work you can zip it, send it to us (support@oxygenxml.com) and I can try to take a look at it.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
chrispitude
Posts: 470
Joined: Thu May 02, 2019 2:32 pm

Re: Mathjax for equations rendering

Post by chrispitude »

Hi gbv34,

I am glad you have something that works!

I am not sure if this is interesting to you, but I posted an idea here:

post65647.html#p65647

that maybe Oxygen's publishing engine could support a generalized MathML-to-SVG conversion at transformation time, so that the end-user's reliance on MathJax would be removed. This could be useful for firewalled or embedded systems, or to speed up the loading of pages with many equations.
gbv34
Posts: 38
Joined: Thu Jan 20, 2022 12:36 pm

Re: Mathjax for equations rendering

Post by gbv34 »

Hi Chris,
Thanks for your answer and the complementary info.
For sure, converting the equations in svg and getting rid of mathJax call would be a good idea. I'll try to stay informed about this potential new feature. Meanwhile, thanks to Radu's help, I succeeded in creating a plugin that inserts a script in the header directly.
For people like me who are slowly getting acquainted with the creation of plugins, here it is attached
com.xxx.html5-javascript.zip
(4.69 KiB) Downloaded 35 times
Post Reply