Closed yuanbug closed 2 years ago
I run this:
const tm = require('markdown-it-texmath'); const md = require('markdown-it')({html:true}) .use(tm, { engine: require('katex'), delimiters: 'dollars', katexOptions: { macros: {"\\RR": "\\mathbb{R}"} } }); const str = ` something $$ 1+1=2 $$ `; console.log(md.render(str));
Then I got this:
<p>something</p> <section> <eqn><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mn>1</mn><mo>+</mo><mn>1</mn><mo>=</mo><mn>2</mn></mrow><annotation encoding="application/x-tex"> 1+1=2 </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7278em;vertical-align:-0.0833em;"></span><span class="mord">1</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">1</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">2</span></span></span></span></span></eqn> </section> <!-- redundant --> </math>
But if I delete the blank line before $$...$$:
const str = ` something $$ 1+1=2 $$ `; console.log(md.render(str));
I got a correct result:
<p> <!-- "something" isn't wrapped by p tags in this case --> something <section> <eqn><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mn>1</mn><mo>+</mo><mn>1</mn><mo>=</mo><mn>2</mn></mrow><annotation encoding="application/x-tex"> 1+1=2 </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7278em;vertical-align:-0.0833em;"></span><span class="mord">1</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">1</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">2</span></span></span></span></span></eqn> </section> </p>
This is a good catch ... thanks for that.
This bug now should have gone with version 0.7.9 ... I hope, you can verify this.
thanks again.
-- sg
I run this:
Then I got this:
But if I delete the blank line before $$...$$:
I got a correct result: