Yes, but again, these uses are inside GitHub’s own markdown. Jekyll doesn’t necessarily supports this. And you can change that behavior if you want. For instance, in our template we added support for other fenced blocks, like echarts
.
Being clearer: when you build your site with Jekyll and upload to GitHub pages, you are not using GitHub’s markdown parser, you are using Jekyll’s. And all examples here point to someone trying to display math inside a GitHub markdown, like in a README.md
file, not inside a GitHub page that is displayed as your-page.github.io
. MathJax doesn’t handle itself the math
fenced block. It was something added by the GitHub team to their markdown parser. If you check MathJax documentation there’s nothing about math
fenced blocks.
Now, why this
displayMath: [['```math', '```']
doesn’t work? Because Jekyll build takes place before Javascript even has the chance to look at the code. So, by the time this fenced block:
```math
E = mc^2
```
gets to the Javascript, means Jekyll built the site, it gets like this:
<div class="code-display-wrapper">
<pre>
<code class="language-math">E = mc^2</code>
</pre>
</div>
Now, if you use
$$
E = mc^2
$$
it correctly converts to
Note: as stated in MathJax docs:
By default, the TeX processor uses the LaTeX math delimiters, which are \(...\)
for in-line math, and \[...\]
for displayed equations. It also recognizes the TeX delimiters $...$
for displayed equations, but it does not define $...$
as in-line math delimiters. That is because dollar signs appear too often in non-mathematical settings, which could cause some text to be treated as mathematics unexpectedly. For example, with single-dollar delimiters, “… the cost is $2.50 for the first one, and $2.00 for each additional one …” would cause the phrase “2.50 for the first one, and” to be treated as mathematics since it falls between dollar signs.
So, changing to $
delimiters might be a bad idea. You should use the default $$
.