Skip to content

Commit ecfaeb2

Browse files
include mathjax
1 parent d040d33 commit ecfaeb2

File tree

5 files changed

+45
-6
lines changed

5 files changed

+45
-6
lines changed

assets/js/mathjax-config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
MathJax = {
2+
tex: {
3+
displayMath: [['\\[', '\\]'], ['$$', '$$']], // block
4+
inlineMath: [['\\(', '\\)']] // inline
5+
},
6+
chtml: {
7+
fontURL: '/webfonts/mathjax',
8+
}
9+
};

hugo.toml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,29 @@ theme = ["hugo-admonitions"]
6161
source = "node_modules/altcha/dist_external"
6262
target = "assets/js/altcha"
6363

64-
[markup.goldmark.renderer]
65-
unsafe = true
64+
[[module.mounts]]
65+
source = "node_modules/mathjax/es5"
66+
target = "assets/js/mathjax"
6667

67-
[markup.goldmark.parser.attribute]
68-
block = true
68+
[[module.mounts]]
69+
source = "node_modules/mathjax/es5/output/chtml/fonts/woff-v2"
70+
target = "static/webfonts/mathjax"
71+
72+
[markup]
73+
[markup.goldmark]
74+
[markup.goldmark.extensions]
75+
[markup.goldmark.extensions.passthrough]
76+
enable = true
77+
[markup.goldmark.extensions.passthrough.delimiters]
78+
block = [['\[', '\]'], ['$$', '$$']]
79+
inline = [['\(', '\)']]
80+
[markup.goldmark.renderer]
81+
unsafe = true
82+
[markup.goldmark.parser.attribute]
83+
block = true
6984

7085
[params]
86+
math = false # set to true in frontmatter if required
7187
[params.releases]
7288
[params.releases.exe]
7389
version = "1.17.0"

layouts/_default/baseof.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,5 +109,11 @@
109109
<script type="text/javascript" src="{{ $alpine.RelPermalink }}" integrity="{{ $alpine.Data.Integrity }}" defer></script>
110110
{{ $lazysizes := resources.Get "js/lazysizes/lazysizes.min.js" | fingerprint }}
111111
<script type="text/javascript" src="{{ $lazysizes.RelPermalink }}" integrity="{{ $lazysizes.Data.Integrity }}" async></script>
112+
{{ if .Param "math" }}
113+
{{ $mjconfig := resources.Get "js/mathjax-config.js" | fingerprint }}
114+
<script type="text/javascript" src="{{ $mjconfig.RelPermalink }}" integrity="{{ $mjconfig.Data.Integrity }}"></script>
115+
{{ $mathjax := resources.Get "js/mathjax/tex-chtml.js" | fingerprint }}
116+
<script type="text/javascript" src="{{ $mathjax.RelPermalink }}" integrity="{{ $mathjax.Data.Integrity }}"></script>
117+
{{ end }}
112118
</body>
113119
</html>

package-lock.json

Lines changed: 8 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"altcha": "^1.4.2",
2929
"jquery": "^3.7.1",
3030
"js-yaml": "^4.1.0",
31-
"lazysizes": "^5.3.2"
31+
"lazysizes": "^5.3.2",
32+
"mathjax": "^3.2.2"
3233
}
3334
}

0 commit comments

Comments
 (0)