Skip to content

Commit

Permalink
supported mathjax
Browse files Browse the repository at this point in the history
  • Loading branch information
vsxd committed Apr 30, 2020
1 parent dbc7f68 commit abdb37c
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,14 @@ about_intro_height: 50

首先备份 archer 下所有你自定义过的文件(包括 _config.yml 和 source 文件夹下添加的文件等),然后删除 archer,再重新安装,最后将备份的文件替换到原来的位置即可。

## 关于LaTeX支持

已经内置mathjax.js,但是需要替换默认的渲染引擎来支持解析LaTeX语法。
```bash
npm uninstall hexo-renderer-marked --save
npm install hexo-renderer-kramed --save
```

## License

MIT
5 changes: 5 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,8 @@ copyright:
enable: true
# https://creativecommons.org/
license: '本文采用<a rel="license" href="http://creativecommons.org/licenses/by-nc/4.0/">知识共享署名-非商业性使用 4.0 国际许可协议</a>进行许可'

# MathJax Support
mathjax:
enable: true
cdn: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.6/MathJax.js?config=TeX-AMS-MML_HTMLorMML
29 changes: 29 additions & 0 deletions layout/mathjax.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<% if (theme.mathjax.enable){ %>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {
inlineMath: [ ['$','$'], ["\\(","\\)"] ],
processEscapes: true
}
});
</script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {
skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
}
});
</script>
<script type="text/x-mathjax-config">
MathJax.Hub.Queue(function() {
var all = MathJax.Hub.getAllJax(), i;
for(i=0; i < all.length; i += 1) {
all[i].SourceElement().parentNode.className += ' has-jax';
}
});
</script>
<script type="text/javascript" src="<%- theme.mathjax.cdn %>"></script>
<% } %>
3 changes: 3 additions & 0 deletions layout/post.ejs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<main class="main post-page">
<% if (page.mathjax == true){ %>
<%- partial('mathjax') %>
<% } %>
<article class="article-entry">
<%- page.content %>
</article>
Expand Down

0 comments on commit abdb37c

Please sign in to comment.