From 76562b46831110439416785d3dd38d1783317d08 Mon Sep 17 00:00:00 2001 From: Shohei Ueda <30958501+peaceiris@users.noreply.github.com> Date: Sat, 12 Dec 2020 18:58:54 +0900 Subject: [PATCH] feat: math shortcode (#246) --- README.md | 16 ++++++++++++- .../content/en/posts/{mathjax.md => math.md} | 24 +++++++++++++++++++ layouts/shortcodes/math.html | 3 +++ package.json | 2 +- 4 files changed, 43 insertions(+), 2 deletions(-) rename exampleSite/content/en/posts/{mathjax.md => math.md} (67%) create mode 100644 layouts/shortcodes/math.html diff --git a/README.md b/README.md index d6167dc33..008afc07c 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,6 @@ Hugo IRIS Theme - - [Overview](#overview) - [Features](#features) - [Roadmap](#roadmap) @@ -51,6 +50,7 @@ Hugo IRIS Theme - [repo](#repo) - [github-sponsors-list](#github-sponsors-list) - [table](#table) + - [math](#math) - [How to Update the Theme](#how-to-update-the-theme) - [Special Thanks](#special-thanks) - [Changelog](#changelog) @@ -339,6 +339,20 @@ Please follow the instruction as the same as the `repo` shortcode. |---|---| | ![Shortcode table mouse out](https://raw.githubusercontent.com/peaceiris/hugo-theme-iris/master/exampleSite/static/images/shortcode_table_1.jpg) | ![Shortcode table mouse over](https://raw.githubusercontent.com/peaceiris/hugo-theme-iris/master/exampleSite/static/images/shortcode_table_2.jpg) | +### math + +See also [the example page](https://hugothemeiris.peaceiris.app/posts/math/). + +When you use the ampersand sign `&`, you need to use the following math shortcode. + +```md +{{* math */>}} +\begin{vmatrix}a & b\\ +c & d +\end{vmatrix} +{{* /math */>}} +``` +
diff --git a/exampleSite/content/en/posts/mathjax.md b/exampleSite/content/en/posts/math.md similarity index 67% rename from exampleSite/content/en/posts/mathjax.md rename to exampleSite/content/en/posts/math.md index 0b8db765d..e20597551 100644 --- a/exampleSite/content/en/posts/mathjax.md +++ b/exampleSite/content/en/posts/math.md @@ -50,3 +50,27 @@ $$ $$ \sum_{i=0}^n i^2 = \frac{(n^2+n)(2n+1)}{6} $$ + + + +## Math Shortcode + +See also [this thread](https://discourse.gohugo.io/t/use-goldmark-mathjax-extension/25721). + +### Input + +```md +{{* math */>}} +\begin{vmatrix}a & b\\ +c & d +\end{vmatrix} +{{* /math */>}} +``` + +### Output + +{{< math >}} +\begin{vmatrix}a & b\\ +c & d +\end{vmatrix} +{{< /math >}} diff --git a/layouts/shortcodes/math.html b/layouts/shortcodes/math.html new file mode 100644 index 000000000..c2a7716fd --- /dev/null +++ b/layouts/shortcodes/math.html @@ -0,0 +1,3 @@ +$$ +{{ .Inner }} +$$ diff --git a/package.json b/package.json index 9fd35dc5d..74b25601a 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "npm test" ], "{README,CONTRIBUTING}.md": [ - "npx doctoc@1.4.0 --github" + "npx doctoc@2.0.0 --github" ] }, "repository": {