I have many markdown files with lots of mathjax formulas. When rendering those files, the underscore character ‘_’ in math formulas are treated as italic mark. I have noticed the official document provided a solution, but it requires modify the markdown files, which will be a hard work since there are lots of formulas.

Is there any way to ignore underscore when rendering markdown?

# Is there any way to ignore underscore when rendering markdown?

I think I’ve found a perfect solution to insert math equations in a markdown file. Just using pandoc to convert all math equations to png files. It works fine.

Thanks for bringing this up @lianera . “Tutorials” isn’t always the most obvious place to look for this kind of information.

NB, the “Tutorials” section no longer exists in the new concept site.

Can’t the Markdown parser used by Hugo be made smarter about ignoring underscores inside math formulas? Or is it that it has no awareness of math formulas at all?

Yep, Blackfriday doesn’t understand math formulas.

This has remained unmerged for years: https://github.com/russross/blackfriday/pull/412.

My hope is that when Hugo upgrades to a more actively maintained Markdown parser ( https://github.com/gohugoio/hugo/issues/5963 ), such issues could probably resolved in a more timely manner.

Thanks for the reply! That’s unfortunate, and hope the situation improves soon. Meanwhile I discovered that in addition to underscores, also expressions like `\{`

and `\\`

need to be escaped inside math expressions, which makes it all quite inconvenient. Thanks for the glimmer of hope

You have just started; there’s a lot more!

(I am the maintainer of an Org mode -> Markdown Emacs package. It produces Markdown which is compatible with Blackfriday, without messing up the LaTeX equations; above is how I need to handle it there.)