How to get KaTeX to render math using mmark?


#1

I’ve added the KaTeX links:

<script src="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.6.0/katex.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.6.0/contrib/auto-render.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.6.0/katex.min.css">

to my header partial and I am utilizing a .mmark file, but when I attempt using $$ a^2 + b^2 = c^2 $$ I get as output:

\( a^2 + b^2 = c^2 \)

Note that this DOES work with MathJax but I’d prefer to use KaTeX.

Any ideas how I can resolve?


#2

This really isn’t a Hugo question, but…

  1. Unless you have a good reason not to, you should probably upgrade to the latest version (0.8.3). It may have important bug fixes, maybe even fixing the problem you’re having.
  2. Are you calling renderMathInElement() somewhere? See the README for auto-render
  3. Are you seeing any errors on the console?

Obviously these are all just wild guesses; it’s hard to know what might be wrong without seeing your site.


#3

It was the renderMathInElement(). Thank you so much!


#4

I should add – I did actually think this was possibly a Hugo issue, and my experience with SSGs and Markdown are pretty limited. I wasn’t just randomly posting about KaTeX & mmark :slight_smile: