From abdb37c285876493e76c80658a02a772a66fef47 Mon Sep 17 00:00:00 2001 From: XudongX Date: Thu, 30 Apr 2020 19:54:06 +0800 Subject: [PATCH 1/2] supported mathjax --- README.md | 8 ++++++++ _config.yml | 5 +++++ layout/mathjax.ejs | 29 +++++++++++++++++++++++++++++ layout/post.ejs | 3 +++ 4 files changed, 45 insertions(+) create mode 100644 layout/mathjax.ejs diff --git a/README.md b/README.md index 73e4c0a2..609d044d 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/_config.yml b/_config.yml index 46782b77..8d9c1d79 100755 --- a/_config.yml +++ b/_config.yml @@ -129,3 +129,8 @@ copyright: enable: true # https://creativecommons.org/ license: '本文采用知识共享署名-非商业性使用 4.0 国际许可协议进行许可' + +# MathJax Support +mathjax: + enable: true + cdn: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.6/MathJax.js?config=TeX-AMS-MML_HTMLorMML \ No newline at end of file diff --git a/layout/mathjax.ejs b/layout/mathjax.ejs new file mode 100644 index 00000000..31e6267f --- /dev/null +++ b/layout/mathjax.ejs @@ -0,0 +1,29 @@ +<% if (theme.mathjax.enable){ %> + + + + + + + +<% } %> \ No newline at end of file diff --git a/layout/post.ejs b/layout/post.ejs index 60091a51..e5620bd6 100644 --- a/layout/post.ejs +++ b/layout/post.ejs @@ -1,4 +1,7 @@
+ <% if (page.mathjax == true){ %> + <%- partial('mathjax') %> + <% } %>
<%- page.content %>
From 953319f0e3331b20fb7b4dcaf78a72c8aecc27e6 Mon Sep 17 00:00:00 2001 From: XudongX Date: Thu, 30 Apr 2020 19:59:06 +0800 Subject: [PATCH 2/2] updated README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 609d044d..adf356ee 100644 --- a/README.md +++ b/README.md @@ -255,6 +255,8 @@ npm uninstall hexo-renderer-marked --save npm install hexo-renderer-kramed --save ``` +然后就可以配置每篇文章(即.md文件)的头部的`mathjax: true`字段来实现在本篇文章中启用LaTex公式支持。 + ## License MIT