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

converted formula lost its delimiters #60

Open
redstoneleo opened this issue Jan 14, 2023 · 1 comment
Open

converted formula lost its delimiters #60

redstoneleo opened this issue Jan 14, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@redstoneleo
Copy link

redstoneleo commented Jan 14, 2023

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

@redstoneleo redstoneleo added the bug Something isn't working label Jan 14, 2023
@welcome
Copy link

welcome bot commented Jan 14, 2023

Thanks for opening your first issue here! Engagement like this is essential for open source projects! 🤗

If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.

If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).

Welcome to the EBP community! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant