Skip to content

inline $$x$$ math matches 2 times and returns nested mathjax #2805

@rambip

Description

@rambip

Description

In Tex, the $$x$$ format is supposed to be used only on newlines.
But in practice, a lot of parsers support $$x$$ at the end of lines.

The arithmetex modules here made the choice of treating inline $$x$$ as $x$, but there is a bug.
The matches occurs 2 times and we end up with a nested mathjax output.

Minimal Reproduction

foo = "hello $$x$$"
md = markdown.Markdown(extensions=[ArithmatexExtension()])
out = md.convert(foo)
print(out)

Output is:

<p>hello <span class="arithmatex"><span class="MathJax_Preview"><span class="arithmatex"><span class="MathJax_Preview">x</span><script type="math/tex">x</script></span></span><script type="math/tex"><span class="arithmatex"><span class="MathJax_Preview">x</span><script type="math/tex">x</script></span></script></span></p>

It should be:

<p>hello <span class="arithmatex"><span class="MathJax_Preview">x</span><script type="math/tex">x</script></span></p>

Note: same behaviour with and without preview.

Version(s) & System Info

  • Operating System: Linux
  • Python Version: 3.14
  • Package Version: latest

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions