Mmark adding delimiters to output (Hugo + mmark + Katex)

#1

Hi,

I’m currently learning Hugo and I started by converting a simple jekyll theme.

I wanted to enable TeX rendering using KaTeX and using the mmark processor. The katex script is included and I add this piece of script to run KaTeX over the math elements generated by mmark.

$("span[class='math']").replaceWith(
  function(){
    var tex = $(this).text();
    return "<span class=\"inline-equation\">" +
           katex.renderToString(tex) +
           "</span>";
});

with mmark, $$ E = mc^2 $$ is rendered to <span class='math'>\( E = mc^2)which is (if I'm informed correctly) not even proper MathJax syntax but rather MathJS?. Katex is also unable to render that inner HTML, because of the the delimiters(and)`.

Is there a way to configure how the math is rendered or does somebody know another a workaround? loads of the docs and blog posts around usign mmark + katex seem outdated…

Apparently KaTeX’s auto-renderer can render the math client side but I’d like to keep my theme efficient and only render what’s necessary.

0 Likes