What do I need to do for Math equations? #234

Closed
opened 2026-01-29 14:31:00 +00:00 by claunia · 5 comments
Owner

Originally created by @bjthomson on GitHub (Oct 25, 2018).

Firstly, nice parser. Thank you. I'm struggling to get the Mathematics extension working, however.

I dont know Latex (I'm a markdown novice too), but I tried the test example,

$$
\begin{equation}
  \int_0^\infty \frac{x^3}{e^x-1}\,dx = \frac{\pi^4}{15}
  \label{eq:sample}
\end{equation}
$$

and it didn't show the integral symbol
I also tried the StackEdit samples:

The *Gamma function* satisfying $\Gamma(n) = (n-1)!\quad\forall n\in\mathbb N$ is via the Euler integral

$$
\Gamma(z) = \int_0^\infty t^{z-1}e^{-t}dt\,.
$$

StackEdit shows this:
mathquery
I saw that Markdown Monster used MarkDig, but that doesn't render the equation either.
mathquery3

StackEdit mentions KaTeX, but I cant see a reference to that in the source. Looking at the page source in StackEdit, there is a bunch of HTML markup referring to KaTeX, but in my small test page, all I see is a div of class math?

mathquery2

I guess I'm missing something.
TIA

Originally created by @bjthomson on GitHub (Oct 25, 2018). Firstly, nice parser. Thank you. I'm struggling to get the Mathematics extension working, however. I dont know Latex (I'm a markdown novice too), but I tried the test example, $$ \begin{equation} \int_0^\infty \frac{x^3}{e^x-1}\,dx = \frac{\pi^4}{15} \label{eq:sample} \end{equation} $$ and it didn't show the integral symbol I also tried the StackEdit samples: The *Gamma function* satisfying $\Gamma(n) = (n-1)!\quad\forall n\in\mathbb N$ is via the Euler integral $$ \Gamma(z) = \int_0^\infty t^{z-1}e^{-t}dt\,. $$ StackEdit shows this: ![mathquery](https://user-images.githubusercontent.com/22427749/47488354-1793ce00-d83c-11e8-89a3-974fa678bb66.PNG) I saw that Markdown Monster used MarkDig, but that doesn't render the equation either. ![mathquery3](https://user-images.githubusercontent.com/22427749/47489904-8a527880-d83f-11e8-8d0d-6c50a97b0a2f.PNG) StackEdit mentions KaTeX, but I cant see a reference to that in the source. Looking at the page source in StackEdit, there is a bunch of HTML markup referring to KaTeX, but in my small test page, all I see is a div of class math? ![mathquery2](https://user-images.githubusercontent.com/22427749/47489359-5dea2c80-d83e-11e8-9782-b44ec4464d13.PNG) I guess I'm missing something. TIA
claunia added the question label 2026-01-29 14:31:00 +00:00
Author
Owner

@xoofx commented on GitHub (Oct 29, 2018):

So as you checked, markdig only generate a proper class/tag to detect math blocks. but it won't provide the rendering infrastructure. You need to plug an existing javascript Math framework for this (like KaTeX) and plug it into your final rendering page. Markdig doesn't generate a HTML page, it just generates a fragment of it.

Using with Katex, it should be something like this to process it (haven't tried this, but it should not be far from a version working):

<script>
  window.onload = function() {
      var tex = document.getElementsByClassName("math");
      Array.prototype.forEach.call(tex, function(el) {
          katex.render(el.textContent, el);
      });
  };
</script>
@xoofx commented on GitHub (Oct 29, 2018): So as you checked, markdig only generate a proper class/tag to detect math blocks. but it won't provide the rendering infrastructure. You need to plug an existing javascript Math framework for this (like KaTeX) and plug it into your final rendering page. Markdig doesn't generate a HTML page, it just generates a fragment of it. Using with Katex, it should be something like this to process it (haven't tried this, but it should not be far from a version working): ``` <script> window.onload = function() { var tex = document.getElementsByClassName("math"); Array.prototype.forEach.call(tex, function(el) { katex.render(el.textContent, el); }); }; </script> ```
Author
Owner

@bjthomson commented on GitHub (Oct 29, 2018):

Ah I see, Thanks, i'll investigate.

@bjthomson commented on GitHub (Oct 29, 2018): Ah I see, Thanks, i'll investigate.
Author
Owner

@jonkas2211 commented on GitHub (Dec 20, 2018):

Hallo @xoofx,

shouldn't that be documented in the spec file?
For example something like:
Note that you have to use a rendering engine like

<script src='https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML' async></script>
@jonkas2211 commented on GitHub (Dec 20, 2018): Hallo @xoofx, shouldn't that be documented in the spec file? For example something like: Note that you have to use a rendering engine like ``` <script src='https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML' async></script> ```
Author
Owner

@xoofx commented on GitHub (Dec 21, 2018):

shouldn't that be documented in the spec file?

I would prefer this in a proper documentation page instead, but I haven't any spare time to bring documentation setup for markdig. I will leave this issue open until then.

@xoofx commented on GitHub (Dec 21, 2018): > shouldn't that be documented in the spec file? I would prefer this in a proper documentation page instead, but I haven't any spare time to bring documentation setup for markdig. I will leave this issue open until then.
Author
Owner

@xoofx commented on GitHub (Mar 12, 2019):

Likely fixed by #311

@xoofx commented on GitHub (Mar 12, 2019): Likely fixed by #311
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#234