mirror of
https://github.com/xoofx/markdig.git
synced 2026-02-08 13:54:54 +00:00
Block problem when Math rendering (MathJax) #698
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @KaiDeMori on GitHub (Sep 4, 2024).
Good day! And thank you for this great libary. I have been using it for years now 🤗
At the moment, I am struggling to get math rendering to work.
The lines I seek to render are using the
\[mathgoeshere\]notation like this:If I simply put it in a HTML file with MathJax (see attached example) it works fine.
But when I try to use it in a markdig generated HTML page, it doesnt work. The
\in front of the[]s are missing and thev^2gets rendered as<sup>, which I guess must confuse MathJax.I can't use the $$ notation and all the
.mdfiles I have already use the square brackets blocks.I am normally using many extensions, but I removed all of them for now (for testing the math).
Without any extensions loaded, it works perfectly if I add an additional backslash in front of the block brackets
\\[texgoeshere\\]Although there seems to be ways to "fix" this, my question is how it is supposed to work. Like: What is the intended way of doing math?
I couldn't find real examples or a tutorial and would be happy to write some explanation for the docs, when I get it to work.
Of course it would be an honor to answer any questions, as I might not have been able to present the problem in best manner. Please forgive me.
I have read these other related topics:
#259
#307
and have read the pull request
#311
I thought the latter one should support my intended use-case 🤔
These are the extensions I usually load:
I don't mind switching to a different math-rendering library, if that's the cause. I am looking for the cleanest solution.
Please have a wonderful time everyone and thanks again for the amazing code!
math_trials.zip
@xoofx commented on GitHub (Sep 4, 2024):
Markdig does not support math without
$$and #311 still expects wrapping$$or$. The changes in this PR added escaped brackets in and out.Check this example on babelmark that is correctly using
$$and the Markdown implementation supporting Math are correctly handling it.While apart maruku-math, none are supporting without
$$(here)@KaiDeMori commented on GitHub (Sep 4, 2024):
Thank you so much for the answer! I know now what to do.
BTW, babelmarkIII is a fantastic site. I didn't know that one yet. Thx!
@KaiDeMori commented on GitHub (Sep 4, 2024):
Sorry, just want to understand something:
The example doesn't work for me and only shows a formula for maruku. Should it also work on other implementations? What could I be doing wrong?
@xoofx commented on GitHub (Sep 5, 2024):
In Markdig and most Markdown implementations, a math code block:
will generate the following HTML fragment:
It is then up to your final HTML page composition to integrate your Math JS library of choice to format these blocks correctly. Markdig today does not support rendering directly to e.g MathML
@KaiDeMori commented on GitHub (Sep 5, 2024):
I think I finally get it now. 🙈
Thanks for the patience and taking the time! 🙏
@JaneConan commented on GitHub (Mar 3, 2025):
So how can we show the right Math, just Replace("\[", "$
") and Replace("\\]", "$") ?It's not look right in the final HTML page🤔
@KaiDeMori commented on GitHub (Mar 24, 2025):
@JaneConan Not sure what you mean. I use the
$$notation now in combination with MathJAX (thetex-mml-chtmlversion).But the whole pipeline is of course a little more complicated (Prism et al. 😉 )
Maybe you should open a new issue and explain more there. I would be glad to help.