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

github.com/ojroques/hugo-researcher.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Roques <olivier@oroques.dev>2020-09-23 12:14:59 +0300
committerOlivier Roques <olivier@oroques.dev>2020-09-23 12:14:59 +0300
commit5beceabfd6a64d55737b035520dc9f9ffaa5e95b (patch)
tree7506da68500429d4dab61f4067c53e256eb96103
parent597523d77f570a73f3116dac89542602117c12f9 (diff)
Add math shortcode
-rw-r--r--layouts/_default/baseof.html2
-rw-r--r--layouts/shortcodes/math.html8
2 files changed, 9 insertions, 1 deletions
diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html
index 86eee86..cb56faf 100644
--- a/layouts/_default/baseof.html
+++ b/layouts/_default/baseof.html
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
{{- partial "head.html" . -}}
- {{ if or .Params.math .Site.Params.math }}
+ {{ if or (.Params.math) (.Site.Params.math) }}
{{- partial "math.html" . -}}
{{ end }}
<body>
diff --git a/layouts/shortcodes/math.html b/layouts/shortcodes/math.html
new file mode 100644
index 0000000..a429888
--- /dev/null
+++ b/layouts/shortcodes/math.html
@@ -0,0 +1,8 @@
+{{ if or (hasPrefix .Inner "\n") (hasPrefix .Inner "<p>") }}
+ $$
+ {{ $inner := trim (.Inner | htmlUnescape) "$\n " }}
+ {{- replace $inner "\n" " " -}}
+ $$
+{{ else }}
+ ${{- trim (.Inner | htmlUnescape) "$\n " -}}$
+{{ end }}