diff options
author | Chun-Hung Tseng <henrybear327@users.noreply.github.com> | 2018-01-15 22:22:14 +0800 |
---|---|---|
committer | olOwOlo <26087907+olOwOlo@users.noreply.github.com> | 2018-01-15 22:22:14 +0800 |
commit | 6f7bd1b933b2ed24569b90645510804b607ff428 (patch) | |
tree | 1460981256232f289f1f54f298c962fa268a9125 | |
parent | e1f5be88d365dfa31b88b552f331460d73f31ca7 (diff) |
feat: config mathjax to use $...$ for in-line math mode (#22)
* Update cdn mathjax version to 2.7.2
-rw-r--r-- | archetypes/default.md | 1 | ||||
-rw-r--r-- | exampleSite/config.toml | 1 | ||||
-rw-r--r-- | layouts/partials/scripts.html | 11 |
3 files changed, 9 insertions, 4 deletions
diff --git a/archetypes/default.md b/archetypes/default.md index dd9dc12..5a49b9e 100644 --- a/archetypes/default.md +++ b/archetypes/default.md @@ -18,6 +18,7 @@ autoCollapseToc: false contentCopyright: false reward: false mathjax: false +mathjaxEnableSingleDollar: false --- <!--more--> diff --git a/exampleSite/config.toml b/exampleSite/config.toml index e2ed85c..bfb229c 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -67,6 +67,7 @@ copyright = "" # default: author.name ↓ # 默认为下面配 fancybox = true # see https://github.com/fancyapps/fancybox # 是否启用fancybox(图片可点击) bootcdn = false # In china. @Deprecated: use [params.publicCDN] # 是否使用bootcdn(@Deprecated: 请使用[params.publicCDN]) mathjax = false # see https://www.mathjax.org/ # 是否使用mathjax(数学公式) + mathjaxEnableSingleDollar = false # 是否使用 $...$ 即可進行inline latex渲染 linkToMarkDown = false # if you config contentCopyright and hugo output .md files. # 是否在链接到markdown原始文件(如果你配置了下面的许可协议并允许hugo生成markdown文件) contentCopyright = '<a rel="license noopener" href="https://creativecommons.org/licenses/by-nc-nd/4.0/" target="_blank">CC BY-NC-ND 4.0</a>' diff --git a/layouts/partials/scripts.html b/layouts/partials/scripts.html index 1a284ee..2cfa68a 100644 --- a/layouts/partials/scripts.html +++ b/layouts/partials/scripts.html @@ -16,13 +16,16 @@ <script type="text/javascript" src="{{ "dist/even.min.js?v=2.7.2" | relURL }}"></script> {{- if and (or .Params.mathjax (and .Site.Params.mathjax (ne .Params.mathjax false))) (or .IsPage .IsHome) }} - <script type="text/javascript"> - window.MathJax = { + <script type="text/x-mathjax-config"> + MathJax.Hub.Config({ + {{ if or .Params.mathjaxEnableSingleDollar (and .Site.Params.mathjaxEnableSingleDollar (ne .Params.mathjaxEnableSingleDollar false)) -}} + tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}, + {{ end -}} showProcessingMessages: false, messageStyle: 'none' - }; + }); </script> - <script async src='https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-MML-AM_CHTML'></script> + <script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-MML-AM_CHTML"></script> {{- end }} <!-- Analytics --> |