Convert MathJax in Obsedian to MathJax in Hugo

Hongtao Hao / 2022-05-11

In Obsedian, you just use:

But in Hugo, you need to use:

Note that if it’s this:

Then Obsedian and Hugo are the same.

So, how to convert MathJax in Obsedian to that in Hugo?

Use python.

import re 

f = open('', 'r')
txt =

txt = txt = re.sub(r' \$', ' `$', txt)
txt = re.sub(r'\$ ', '$` ', txt)
with open('', 'w') as f:

The output file of won’t be perfect. You still need to manually change something. But that’s much better than manually change all of the signs, especially if you have a lot of math expressions.

Last modified on 2022-05-18