Skip to content

Commit 44f552c

Browse files
authored
feat(deps): move MathJax configuration to a separate file (cotes2020#1670)
Move `MathJax` configuration to file `assets/js/data/mathjax.js` will help add extensions.
1 parent 7d48d32 commit 44f552c

File tree

3 files changed

+35
-20
lines changed

3 files changed

+35
-20
lines changed

_includes/js-selector.html

+1-19
Original file line numberDiff line numberDiff line change
@@ -72,25 +72,7 @@
7272

7373
{% if page.math %}
7474
<!-- MathJax -->
75-
<script>
76-
/* see: <https://docs.mathjax.org/en/latest/options/input/tex.html#tex-options> */
77-
MathJax = {
78-
tex: {
79-
/* start/end delimiter pairs for in-line math */
80-
inlineMath: [
81-
['$', '$'],
82-
['\\(', '\\)']
83-
],
84-
/* start/end delimiter pairs for display math */
85-
displayMath: [
86-
['$$', '$$'],
87-
['\\[', '\\]']
88-
],
89-
/* equation numbering */
90-
tags: 'ams'
91-
}
92-
};
93-
</script>
75+
<script src="{{ '/assets/js/data/mathjax.js' | relative_url }}"></script>
9476
<script src="https://cdnjs.cloudflare.com/polyfill/v3/polyfill.min.js?features=es6"></script>
9577
<script id="MathJax-script" async src="{{ site.data.origin[type].mathjax.js | relative_url }}"></script>
9678
{% endif %}

_posts/2019-08-08-write-a-new-post.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,9 @@ comments: false
109109

110110
## Mathematics
111111

112-
For website performance reasons, the mathematical feature won't be loaded by default. But it can be enabled by:
112+
We use [**MathJax**][mathjax] to generate mathematics. For website performance reasons, the mathematical feature won't be loaded by default. But it can be enabled by:
113+
114+
[mathjax]: https://www.mathjax.org/
113115

114116
```yaml
115117
---
@@ -154,6 +156,12 @@ Can be referenced as \eqref{eq:label_name}.
154156
3. \$$ LaTeX_math_expression $$
155157
```
156158

159+
> Starting with `v7.0.0`, configuration options for **MathJax** have been moved to file `assets/js/data/mathjax.js`{: .filepath }, and you can change the options as needed, such as adding [extensions][mathjax-exts].
160+
> If you are building the site via `chirpy-starter`, copy that file from the gem installation directory (check with command `bundle info --path jekyll-theme-chirpy`) to the same directory in your repository.
161+
{: .prompt-tip }
162+
163+
[mathjax-exts]: https://docs.mathjax.org/en/latest/input/tex/extensions/index.html
164+
157165
## Mermaid
158166

159167
[**Mermaid**](https://github.com/mermaid-js/mermaid) is a great diagram generation tool. To enable it on your post, add the following to the YAML block:

assets/js/data/mathjax.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
layout: compress
3+
# WARNING: Don't use '//' to comment out code, use '{% comment %}' and '{% endcomment %}' instead.
4+
---
5+
6+
{%- comment -%}
7+
See: <https://docs.mathjax.org/en/latest/options/input/tex.html#tex-options>
8+
{%- endcomment -%}
9+
10+
MathJax = {
11+
tex: {
12+
{%- comment -%} start/end delimiter pairs for in-line math {%- endcomment -%}
13+
inlineMath: [
14+
['$', '$'],
15+
['\\(', '\\)']
16+
],
17+
{%- comment -%} start/end delimiter pairs for display math {%- endcomment -%}
18+
displayMath: [
19+
['$$', '$$'],
20+
['\\[', '\\]']
21+
],
22+
{%- comment -%} equation numbering {%- endcomment -%}
23+
tags: 'ams'
24+
}
25+
};

0 commit comments

Comments
 (0)