使用 Github Pages 发布博文时,当我们的 markdown 文件出现数学公式时,Github Page 里的 Jekyll 虽然支持 markdown,但不能正常显示数学公式,可以借助 MathJax 帮助渲染,具体做法是添加以下代码到 markdown 文件的开头,这样发布的博文就可以正常显示了。

1
2
3
4
5
6
7
8
9
10
11
<head>
<script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {
skipTags: ['script', 'noscript', 'style', 'textarea', 'pre'],
inlineMath: [['$','$']]
}
});
</script>
</head>