Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/varkai/hugo-theme-zozo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorimzeuk <imzeuk@gmail.com>2019-04-16 10:04:06 +0300
committerimzeuk <imzeuk@gmail.com>2019-04-16 10:04:06 +0300
commitcb991e36fd582bb1bcc8ee58621d2feaae409866 (patch)
treef1cd9cd5e7896d4081e5622a7a7355caec7c9ddf
parent009ecf34d8fd294986cc8898211a849c74d06021 (diff)
add MathJax
-rw-r--r--README.md6
-rw-r--r--exampleSite/config.toml8
-rw-r--r--exampleSite/content/posts/theme-preview.md28
-rw-r--r--layouts/partials/js.html4
-rw-r--r--layouts/partials/mathjax.html33
5 files changed, 77 insertions, 2 deletions
diff --git a/README.md b/README.md
index fe26f51..b55538e 100644
--- a/README.md
+++ b/README.md
@@ -45,6 +45,12 @@ $ git clone https://github.com/imzeuk/hugo-theme-zozo themes/zozo
关于页面就是这么实现的。
+## Math 公式
+
+本主题支持 MathJax 数学公式,默认为关闭状态,如需使用,需要在 [`config.toml`](./exampleSite/config.toml) 中进行设置。
+
+设置 `[params]` 下的 `mathjax = true` 来支持数学公式。
+
## Valine 评论
本主题提供了 Valine 评论系统,默认为关闭状态,如需使用,需要在 [`config.toml`](./exampleSite/config.toml) 中进行设置。
diff --git a/exampleSite/config.toml b/exampleSite/config.toml
index d94f8ac..779c0e0 100644
--- a/exampleSite/config.toml
+++ b/exampleSite/config.toml
@@ -11,6 +11,9 @@ enableEmoji = true
[author] # essential # 必需
name = "Zeuk"
+[blackfriday]
+ smartypants = false
+
[[menu.main]] # config your menu 配置菜单
name = "首页"
weight = 10
@@ -33,11 +36,14 @@ enableEmoji = true
url = "/about/"
[params]
- subTitle = "the site subtitle" # 网站二级标题
+ subTitle = "the site subtitle" # 网站二级标题
footerSlogan = "我的精神家园" # 网站页脚标语
keywords = ["Hugo", "theme","zozo"] # 网站关键字
description = "Hugo theme zozo example site." # 网站描述
+ # mathjax
+ mathjax = true # 是否使用mathjax(数学公式)
+
# Valine.
# You can get your appid and appkey from https://leancloud.cn
# more info please open https://valine.js.org
diff --git a/exampleSite/content/posts/theme-preview.md b/exampleSite/content/posts/theme-preview.md
index b5f4fb7..ff75f6e 100644
--- a/exampleSite/content/posts/theme-preview.md
+++ b/exampleSite/content/posts/theme-preview.md
@@ -141,7 +141,33 @@ function doIt() {
- Second item
- Third item
-# Emoji
+# Math
+
+```
+$$
+evidence\_{i}=\sum\_{j}W\_{ij}x\_{j}+b\_{i}
+$$
+
+$$
+AveP = \int_0^1 p(r) dr
+$$
+
+When $a \ne 0$, there are two solutions to \(ax^2 + bx + c = 0\) and they are
+$$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$
+```
+
+$$
+evidence\_{i}=\sum\_{j}W\_{ij}x\_{j}+b\_{i}
+$$
+
+$$
+AveP = \int_0^1 p(r) dr
+$$
+
+When $a \ne 0$, there are two solutions to \(ax^2 + bx + c = 0\) and they are
+$$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$
+
+#### Emoji
This is a test for emoji.
:smile:
diff --git a/layouts/partials/js.html b/layouts/partials/js.html
index 46225b5..283efdb 100644
--- a/layouts/partials/js.html
+++ b/layouts/partials/js.html
@@ -5,3 +5,7 @@
<script src="{{ "/js/fancybox.min.js" | relURL }}"></script>
<script>hljs.initHighlightingOnLoad()</script>
+
+{{ if .Site.Params.mathjax }}
+ {{ partial "mathjax.html" . }}
+{{ end }}
diff --git a/layouts/partials/mathjax.html b/layouts/partials/mathjax.html
new file mode 100644
index 0000000..a8c59ab
--- /dev/null
+++ b/layouts/partials/mathjax.html
@@ -0,0 +1,33 @@
+<script type="text/javascript" async src="https://cdn.bootcss.com/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
+MathJax.Hub.Config({
+ tex2jax: {
+ inlineMath: [['$','$'], ['\\(','\\)']],
+ displayMath: [['$$','$$'], ['\[\[','\]\]']],
+ processEscapes: true,
+ processEnvironments: true,
+ skipTags: ['script', 'noscript', 'style', 'textarea', 'pre'],
+ TeX: { equationNumbers: { autoNumber: "AMS" },
+ extensions: ["AMSmath.js", "AMSsymbols.js"] }
+ }
+});
+
+MathJax.Hub.Queue(function() {
+ // Fix <code> tags after MathJax finishes running. This is a
+ // hack to overcome a shortcoming of Markdown. Discussion at
+ // https://github.com/mojombo/jekyll/issues/199
+ var all = MathJax.Hub.getAllJax(), i;
+ for(i = 0; i < all.length; i += 1) {
+ all[i].SourceElement().parentNode.className += ' has-jax';
+ }
+});
+</script>
+
+<style>
+code.has-jax {
+ font: inherit;
+ font-size: 100%;
+ background: inherit;
+ border: inherit;
+ color: #515151;
+}
+</style> \ No newline at end of file