Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redundant </math> when there's a blank line before $$...$$ #36

Closed
yuanbug opened this issue Dec 4, 2021 · 1 comment
Closed

Redundant </math> when there's a blank line before $$...$$ #36

yuanbug opened this issue Dec 4, 2021 · 1 comment

Comments

@yuanbug
Copy link

yuanbug commented Dec 4, 2021

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>
@goessner
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants