Quick and dirty math rendering in Hakyll

Posted on May 14, 2020
Tags: Pandoc, Hakyll, LaTex

This solution is clearly not optimal for someone who want to do everything locally, but it’s an easy way to render LaTex equations.

Include this header and that’s it:

<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>

Now you can use the Latex commands inside the “$$” operator, let’s test it with a big equation:

$${\partial{\bf u}\over{\partial t}} + ({\bf u} \cdot \nabla) {\bf u}
= - {1\over\rho} \nabla p + \gamma\nabla^2{\bf u} + {1\over\rho}{\bf
F}$$

And we get:

$${\partial{\bf u}\over{\partial t}} + ({\bf u} \cdot \nabla) {\bf u} = - {1\over\rho} \nabla p + \gamma\nabla^2{\bf u} + {1\over\rho}{\bf F}$$

Edit: The rendering doesn’t work anymore, because I updated the “Content-Security-Policy” header to only serve content from this site. In the end I don’t think I will allow it, since I’m not a fan of JavaScript to say the least, and I know there are other ways to do this. I will update this when I have time.