mitya57 / python-markdown-math

Math extension for Python-Markdown
https://pypi.org/project/python-markdown-math/
BSD 3-Clause "New" or "Revised" License
120 stars 27 forks source link

Parsing clash with underscore emphasis #8

Closed c42f closed 8 years ago

c42f commented 8 years ago

Hi, thanks for this plugin, and thanks for going to the effort to release it on pypi, it really makes things easier.

I've been using it to write some technical documentation, and have found what seems to be a clash with underscore emphasis. I haven't had the time to get to the bottom of it yet, so I thought I'd report it here. Simple test case:

In [3]: import markdown
In [4]: md = markdown.Markdown(extensions=['math'])
In [5]: md.convert(r'${a}_{b}$ ${c}_{d}$')
Out[5]: u'<p>${a}<em>{b}$ ${c}</em>{d}$</p>'

Obviously the emphasis tags which have been inserted here across the boundaries of the math notation are bogus...

c42f commented 8 years ago

Uh oh, I think this is my fault, I'm missing enable_dollar_delimiter in the extension config. It just so happens that most math renders fine without this, with mathjax configured to parse $...$ notation.

For anyone else hitting the issue, the appropriate mkdocs configuration section looks like

markdown_extensions:
    - math:
        enable_dollar_delimiter: True
mitya57 commented 8 years ago

Right. I also suggest to disable the tex2jax extension of MathJax because it has some potential conflicts with this extension (i.e. it can try processing escaped delimiters that this extension did not handle).

c42f commented 8 years ago

Thanks!