Block problem when Math rendering (MathJax) #695

Open
opened 2026-01-29 14:43:09 +00:00 by claunia · 0 comments
Owner

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:

\[ \gamma = \frac{1}{\sqrt{1 - \frac{v^2}{c^2}}} \]

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 the v^2 gets rendered as <sup>, which I guess must confuse MathJax.

I can't use the $$ notation and all the .md files 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:

      var pipeline = new MarkdownPipelineBuilder()
         .UseAdvancedExtensions()
         .UseEmojiAndSmiley()
         .UseEmphasisExtras()
         .UseSmartyPants()
         .DisableHtml()
         .UseSoftlineBreakAsHardlineBreak()
         .Build();

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

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: ``` \[ \gamma = \frac{1}{\sqrt{1 - \frac{v^2}{c^2}}} \] ``` 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 the `v^2` gets rendered as `<sup>`, which I guess must confuse MathJax. I can't use the $$ notation and all the `.md` files 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: ``` var pipeline = new MarkdownPipelineBuilder() .UseAdvancedExtensions() .UseEmojiAndSmiley() .UseEmphasisExtras() .UseSmartyPants() .DisableHtml() .UseSoftlineBreakAsHardlineBreak() .Build(); ``` 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](https://github.com/user-attachments/files/16869736/math_trials.zip)
claunia added the question label 2026-01-29 14:43:09 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#695