Any plan to introduce the mathjax support natively?

I used to build my personal web site with PHP/MYSQL and HTML editing but found this Hugo project yesterday. It would really save my time to deal with so much web technical details only to have a working and easy-to-edit web site. Thank you Hugo developers!

However, after I have read through the Hugo document, one problem that prevents me using it is that it is lack of mathjax support. Yes, the Hugo document gives a solution but it is not perfect. I have a lot of document in Jupyter notebook markdown format, which supports mathjax natively (no need to put div, span, ` or _ for math expression). To use Hugo, I need to convert all these documents to a Hugo-accepted format. But that will ruin the markdown document for all other applications. Potentially, if Hugo is going to support mathjax natively soon, I need to convert all those documents back, which is a lot of pain.

I wonder if there is any plan to support mathjax natively by modifying markdown parser in Go. I have heard one idea to do that is convert those math expressions into some special tokens first and then run the markdown parser. After that, substitute those tokens back. In Python, there has been some efforts to solve that. For example, the following Python script will use the module markdown2 markdown2Mathjax to parse markdown with mathjax correctly.

import sys

from markdown2Mathjax import sanitizeInput, reconstructMath
from markdown2 import markdown

if (len(sys.argv)==1):
  print('no input specified')
  raise SystemExit

infile = sys.argv[1]

with open(infile, 'r') as f:
    mdfile = f.read()

tmp = sanitizeInput(mdfile)
mdtext = markdown(tmp[0])
finalOutput = reconstructMath(mdtext,tmp[1])

print finalOutput.encode('utf8')

Ideally, if Hugo can support only $, $$, \( \), \[ \] delimit, the problem will be solved. And with that, I can see that many more math/science people will convert to Hugo for their web/document management solution.

1 Like

No plans.

I guess it is this doc you refer to:

That page doesn’t mention one obvious workaround that also will work for inline Mathjax: Create a shortcode wrapper.

So shortcodes/mj.html:

{{ .Inner }}

Then just wrap it in

{{< mj >}}Math here{{< /mj >}}

But native support should be implemented in https://github.com/russross/blackfriday – so it might be worth to add an issue there.

mmark suport MathML. Change the file extension .md to .mmark and verify alternative rendering.

1 Like