To install this JPSWiki extension, you will need Admin rights; and have the Haddock Template activated.
Math Behavior is a JSPWiki javascript extension which allows to add math equations in
TeX, LaTeX or ASCIImath format.
Find below the installation instructions. See Math for how-to-use examples.
How to install the MathJax behavior#
Step 1: Create a JS file#
Create a javascript behavior file MathJax.js with the following code snippet and put it in <your-wiki-site>/scripts folder. This implementation automatically pulls the library from the MathJax distributed network service(//cdn.mathjax.org) so you don't need to install anything locally.
Wiki.once(".load-mathjax",function(a){window.MathJax={tex2jax:{inlineMath:[["$","$"],["\\(","\\)"]],displayMath:[["$$","$$"]]},asciimath2jax:{delimiters:[["`","`"]]}},"script".slick({src:"//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_SVG,Safe"}).inject(document.head)});
Step 2: Update JSP file#
Add following lines to <your-wiki-site>/templates/haddock/commonheader.jsp.
<!-- existing line --> <script async src="<wiki:Link format='url' jsp='scripts/haddock.js'/>"></script> <!-- add this line --> <script src="<wiki:Link format='url' jsp='scripts/MathJax.js'/>" ></script>
And do the same in <your-wiki-site>/templates/reader/ViewTemplate.js.
You are now ready to render Math formulae on your wiki-pages !
No need to restart your JSPWiki server.
See MathJax™ for more detailed documentation.
MathJax™ uses CSS with web fonts or SVG, instead of bitmap images or Flash, so equations scale with surrounding text at all zoom levels.