aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2019-09-30 00:49:31 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2019-09-30 00:49:31 +0300
commit169837de5f9649ea41107030c148cd7f31615fb7 (patch)
tree42b22c79917e6ae5ef738ca452c7ff44eef3e6d0
parentREADME: remove the obsolete Windows notes (diff)
downloadblog-169837de5f9649ea41107030c148cd7f31615fb7.tar.gz
blog-169837de5f9649ea41107030c148cd7f31615fb7.zip
add MathJax support
-rw-r--r--README.md24
-rw-r--r--_config.yml1
-rw-r--r--_includes/common/header.html1
-rw-r--r--_includes/common/mathjax.html12
4 files changed, 38 insertions, 0 deletions
diff --git a/README.md b/README.md
index e57ab9f..67d35f2 100644
--- a/README.md
+++ b/README.md
@@ -60,6 +60,30 @@ One easy workaround is to `wget` the website and convert the links:
wget --convert-links --recursive http://localhost:4000/
+### Typesetting math
+
+[MathJax] can be used to typeset mathematics using LaTeX.
+To use MathJax, set `mathjax` to `true` in page's front matter.
+Then you can do things like this:
+
+```
+This is an inline formula: $$y = kx + b$$.
+This is a formula in a separate block:
+
+$$
+y = kx + b
+$$
+```
+
+MathJax version 3 is used, which is unsupported by Kramdown (which produces
+`<script type="math/tex; ..."` tags, suitable for MathJax 2.
+This is why `math_engine` is set to `null` in _config.yml, making Kramdown
+output block formulas wrapped in `$$` and inline formulas in `$` respectively.
+MathJax is additionally customized to recognize `$` as an inline formula
+delimiter in _includes/common/mathjax.html.
+
+[MathJax]: https://www.mathjax.org/
+
License
-------
diff --git a/_config.yml b/_config.yml
index 5dbb624..c6d3334 100644
--- a/_config.yml
+++ b/_config.yml
@@ -22,6 +22,7 @@ highlighter: rouge
markdown: kramdown
kramdown:
+ math_engine: null
syntax_highlighter_opts:
span:
disable: true
diff --git a/_includes/common/header.html b/_includes/common/header.html
index c21b442..a17ea71 100644
--- a/_includes/common/header.html
+++ b/_includes/common/header.html
@@ -19,6 +19,7 @@
{% endif %}
{% include common/ie_compat.html %}
+ {% include common/mathjax.html %}
</head>
<body>
<div class="top-level-footer-wrapper">
diff --git a/_includes/common/mathjax.html b/_includes/common/mathjax.html
new file mode 100644
index 0000000..1d59f37
--- /dev/null
+++ b/_includes/common/mathjax.html
@@ -0,0 +1,12 @@
+{% if page.mathjax %}
+ <script>
+// See the README for explanation:
+MathJax = {
+ tex: {
+ inlineMath: [['$', '$']]
+ }
+};
+ </script>
+ <script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
+ <script type="text/javascript" id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"></script>
+{% endif %}