Skip to content

Commit e627926

Browse files
authored
Merge pull request #606 from liangliangyy/dev
增加数学公式支持
2 parents f7afb1d + 6389a66 commit e627926

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
$(function () {
2+
MathJax.Hub.Config({
3+
showProcessingMessages: false, //关闭js加载过程信息
4+
messageStyle: "none", //不显示信息
5+
extensions: ["tex2jax.js"], jax: ["input/TeX", "output/HTML-CSS"], displayAlign: "left", tex2jax: {
6+
inlineMath: [["$", "$"]], //行内公式选择$
7+
displayMath: [["$$", "$$"]], //段内公式选择$$
8+
skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code', 'a'], //避开某些标签
9+
}, "HTML-CSS": {
10+
availableFonts: ["STIX", "TeX"], //可选字体
11+
showMathMenu: false //关闭右击菜单显示
12+
}
13+
});
14+
// 识别范围 => 文章内容、评论内容标签
15+
const contentId = document.getElementById("content");
16+
const commentId = document.getElementById("comments");
17+
MathJax.Hub.Queue(["Typeset", MathJax.Hub, contentId, commentId]);
18+
})
19+
20+
21+

templates/share_layout/base.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
<link rel='stylesheet preload' as="font" id='twentytwelve-fonts-css'
3030
href='{% static 'blog/fonts/fonts.css' %}'
3131
type='text/css' media='all'/>
32+
<link rel="dns-prefetch" href="//cdn.mathjax.org" />
3233
{% compress css %}
3334

3435
<link rel='stylesheet' id='twentytwelve-style-css' href='{% static 'blog/css/style.css' %}' type='text/css'
@@ -75,11 +76,13 @@ <h2 class="site-description">{{ SITE_DESCRIPTION }}</h2>
7576

7677
</body>
7778
<footer>
79+
<script src="//cdn.bootcss.com/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
7880
{% compress js %}
7981
<script type="text/javascript" src="{% static 'blog/js/jquery-3.6.0.min.js' %}"></script>
8082
<script type="text/javascript" src="{% static 'blog/js/nprogress.js' %}"></script>
8183
<script src="{% static 'blog/js/blog.js' %}" type="application/javascript"></script>
8284
<script src="{% static 'blog/js/navigation.js' %}" type="application/javascript"></script>
85+
<script src="{% static 'mathjax/js/mathjax-config.js' %}" type="application/javascript"></script>
8386
{% block compress_js %}
8487
{% endblock %}
8588
{% endcompress %}

0 commit comments

Comments
 (0)