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

github.com/wangchucheng/hugo-eureka.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWang Chucheng <me@wangchucheng.com>2021-03-27 20:06:07 +0300
committerWang Chucheng <me@wangchucheng.com>2021-03-27 20:06:07 +0300
commit4b0bb031102826fccf891a648f44713636f33dd0 (patch)
tree1b7b8575530d09fc632b7eb48ae0c298ea3c42b1
parent4be09f66c077d885dc3e3f64e55d662d95168c11 (diff)
fix: make KaTeX options case sensitive
-rw-r--r--exampleSite/config/_default/params.yaml2
-rw-r--r--layouts/partials/head.html12
2 files changed, 14 insertions, 0 deletions
diff --git a/exampleSite/config/_default/params.yaml b/exampleSite/config/_default/params.yaml
index ff3bd53..8828b6d 100644
--- a/exampleSite/config/_default/params.yaml
+++ b/exampleSite/config/_default/params.yaml
@@ -37,6 +37,8 @@ math:
# # Browse https://katex.org/docs/options.html to see the options available.
# # KaTeX's Auto-render ignores `displayMode` property of the options, so this property will not work.
# # You can list the key and value you want as below.
+ # # Because Hugo's config params are case-insensitive, you need to add `-` or `_` before the uppercase letters.
+ # # For example, `throwOnError` should be written as `throw-On-Error` or other acceptable formats.
# leqno:
comment:
diff --git a/layouts/partials/head.html b/layouts/partials/head.html
index 6df2990..24f81e9 100644
--- a/layouts/partials/head.html
+++ b/layouts/partials/head.html
@@ -99,6 +99,17 @@
{{- end }}
{{- end }}
+{{ define "partials/camelize" }}
+{{ $input := . }}
+{{ $regexp := "(-|_)([a-z])" }}
+{{ $matches := findRE $regexp $input }}
+{{ range $matches }}
+ {{ $input = $input | replaceRE . (upper .) }}
+{{ end }}
+{{ $input = $input | replaceRE "(-|_)" "" }}
+{{ return $input }}
+{{ end }}
+
{{- if and (eq .Site.Params.math.handler "katex") $enableMath }}
<link rel="stylesheet" href="{{ printf $assets.katex.css.url $assets.katex.version }}"
{{ with $assets.katex.css.sri }} integrity="{{ . }}" {{ end }} media="print"
@@ -118,6 +129,7 @@
],
{{- range $key, $value := .Site.Params.math.katex }}
{{- if and (ne $value nil) (ne $value "") }}
+ {{- $key = partial "partials/camelize" $key }}
{{- $key | safeJS -}}: {{- $value | safeJS }},
{{- end }}
{{- end }}