Skip to content

Commit

Permalink
Merge pull request liangliangyy#606 from liangliangyy/dev
Browse files Browse the repository at this point in the history
增加数学公式支持
  • Loading branch information
liangliangyy authored Sep 20, 2022
2 parents f7afb1d + 6389a66 commit e627926
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
21 changes: 21 additions & 0 deletions blog/static/mathjax/js/mathjax-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
$(function () {
MathJax.Hub.Config({
showProcessingMessages: false, //关闭js加载过程信息
messageStyle: "none", //不显示信息
extensions: ["tex2jax.js"], jax: ["input/TeX", "output/HTML-CSS"], displayAlign: "left", tex2jax: {
inlineMath: [["$", "$"]], //行内公式选择$
displayMath: [["$$", "$$"]], //段内公式选择$$
skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code', 'a'], //避开某些标签
}, "HTML-CSS": {
availableFonts: ["STIX", "TeX"], //可选字体
showMathMenu: false //关闭右击菜单显示
}
});
// 识别范围 => 文章内容、评论内容标签
const contentId = document.getElementById("content");
const commentId = document.getElementById("comments");
MathJax.Hub.Queue(["Typeset", MathJax.Hub, contentId, commentId]);
})



3 changes: 3 additions & 0 deletions templates/share_layout/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<link rel='stylesheet preload' as="font" id='twentytwelve-fonts-css'
href='{% static 'blog/fonts/fonts.css' %}'
type='text/css' media='all'/>
<link rel="dns-prefetch" href="//cdn.mathjax.org" />
{% compress css %}

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

</body>
<footer>
<script src="//cdn.bootcss.com/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
{% compress js %}
<script type="text/javascript" src="{% static 'blog/js/jquery-3.6.0.min.js' %}"></script>
<script type="text/javascript" src="{% static 'blog/js/nprogress.js' %}"></script>
<script src="{% static 'blog/js/blog.js' %}" type="application/javascript"></script>
<script src="{% static 'blog/js/navigation.js' %}" type="application/javascript"></script>
<script src="{% static 'mathjax/js/mathjax-config.js' %}" type="application/javascript"></script>
{% block compress_js %}
{% endblock %}
{% endcompress %}
Expand Down

0 comments on commit e627926

Please sign in to comment.