Skip to content

converted formula lost its delimiters #60

Open
@redstoneleo

Description

@redstoneleo

Describe the bug

context
I used markdown_it to convert Markdown to html, but the converted formula lost its delimiters, which caused my mathjax cannot render the formula,

Code for conversion :

from markdown_it import MarkdownIt
from mdit_py_plugins.front_matter import front_matter_plugin
from mdit_py_plugins.footnote import footnote_plugin
from mdit_py_plugins.anchors import anchors_plugin
from mdit_py_plugins.texmath import  texmath_plugin
from mdit_py_plugins.dollarmath import  dollarmath_plugin
from mdit_py_plugins.amsmath import amsmath_plugin
from markdown_it.common import  utils

import html
md = (
    # MarkdownIt('gfm-like' ,{
    MarkdownIt('commonmark' ,{
        'breaks':True,
        'html':True
        })


    # .use(texmath_plugin, delimiters="dollars")
    .use(dollarmath_plugin)
    # .use(amsmath_plugin)
	.use(front_matter_plugin)
    .use(footnote_plugin)
    .use(anchors_plugin, permalink=True, max_level=4)
    
    .enable('table')
)
s4=r'''a rational number like $\begin{matrix}
L & \  = \{ x \mid x \in \mathbb{Q},x \leq 0\} \cup \left\{ x \mid x \in \mathbb{Q},x > 0,x^{2} < 2 \right\} \\
U & \  = \mathbb{Q} - L = \left\{ x \mid x \in \mathbb{Q},x > 0,x^{2} > 2 \right\} \\
\end{matrix}$ .
  2.  A fact between two Dedekind cuts(the density of $Q$ in $R$): For any pair of real numbers $\alpha$ and $\beta$, where $\alpha > \beta$, there can always be found a real, and even in particular a rational, number $r$ which lies between them, i.e. $\alpha > r > \beta$ (and, consequently, an infinite set of such rational numbers).
'''
html_text = md.render(s4)
print(html_text)

The demo with the result at https://jsbin.com/ronasug/edit?html,output

expectation
delimiters around formula.

bug
converted formula lost its delimiters, the bug is also confirmed at https://groups.google.com/g/mathjax-users/c/aL3aqfp8DzU/m/KZoomKKvBwAJ

... but it looks like it might be an old one, as it seems to be producing jsMath-style delimiters (...) rather than MathJax-style ones. JsMath was MathJax's predecessor, active from 2004 to 2008, and while MathJax v2 includes an extension that would parse jsMath delimiters, that is not available in version 3. There is an example showing how to look for MathJax v2 <script> tags that could be modified to look for jsMath-style tags instead, if you are proficient enough with javascript.

Reproduce the bug

see the above section

List your environment

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions