goessner / markdown-it-texmath

Support TeX math equations with your Markdown documents.
MIT License
161 stars 29 forks source link

Can't render when latex is in <p> block #23

Closed Hydrostic closed 3 years ago

Hydrostic commented 4 years ago

When latex text is in <p> block, it doesn't try to render image But if i put it out of the <p>, it's OK image

AbhijeetKrishnan commented 3 years ago

This issue still persists. I tested and found that the issue is present with div but not with span blocks.

This is an issue because

MWE

Run below in Node.js REPL.

tm = require('markdown-it-texmath'),
    md = require('markdown-it')({html: true}).use(tm, { engine: require('katex'),
                                            delimiters:'dollars',
                                            katexOptions: { macros: {"\\RR": "\\mathbb{R}"} }
                                          });
md.render('<p>$1$</p>')

Expected Behaviour

'<p><eq><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>1</mn></mrow><annotation encoding="application/x-tex">1</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.64444em;vertical-align:0em;"></span><span class="mord">1</span></span></span></span></eq></p>\n'

Actual Behaviour

'<p>$1$</p>'
goessner commented 3 years ago

This behavior is markdown-it specific by intention.

So

<p>*italic*</p>

as well as

<p>
*italic*
</p>

won't render markdown inside of html elements. It will show

*italic*.

But inserting blank lines before and after a markdown block inside of html elements will render markdown properly

<p>

*italic*

</p>

resulting in italic.

So this is not an issue, but from markdown-it by design.