diff --git a/README.md b/README.md index 757c3d4..8cd211a 100644 --- a/README.md +++ b/README.md @@ -835,6 +835,33 @@ Download the latest release from . Unpa The resulting path should be `static/katex`. Then set the `math` param to "true" and write some math to be typeset. +Wrap inline math in single "$": + +~~~~ +Lorem $E=mc^2$ ipsum +~~~~ + +and block math in double "$$": + +~~~~ +$$ +[ \int_0^1 \frac{dx}{e^x} = \frac{e-1}{e} ] +$$ +~~~~ + +Markdown rendering will in some instances mess with the math. To avoid this use the math shortcode for inline math: + +~~~~ +Lorem {{< math >}}E=mc^2{{< /math >}} ipsum +~~~~ + + and math codeblocks for block math: + +`~~~~ math` +`[ \int_0^1 \frac{dx}{e^x} = \frac{e-1}{e} ]` +`~~~~` + + ## Getting help diff --git a/layouts/_default/_markup/render-codeblock-math.html b/layouts/_default/_markup/render-codeblock-math.html new file mode 100644 index 0000000..6f33eca --- /dev/null +++ b/layouts/_default/_markup/render-codeblock-math.html @@ -0,0 +1,6 @@ +{{ .Page.Store.Set "math" true -}} + +$$ +{{ .Inner }} +$$ +

diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 8660939..2e4091c 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -10,7 +10,7 @@ {{ partial "meta_json_ld.html" . }} {{ partial "scripts.html" . }} {{ partialCached "tracking.html" . }} -{{ if $.Param "math" }}{{ partialCached "math.html" . }}{{ end -}} +{{ partialCached "math.html" . }} diff --git a/layouts/partials/math.html b/layouts/partials/math.html index 4039f1e..6c6c05e 100644 --- a/layouts/partials/math.html +++ b/layouts/partials/math.html @@ -1,5 +1,7 @@ +{{ if or ($.Param "math") (.Page.Store.Get "math") (.HasShortcode "math") -}} {{ $math := resources.Get "js/math.js" | minify | fingerprint -}} +{{ end -}} diff --git a/layouts/shortcodes/math.html b/layouts/shortcodes/math.html new file mode 100644 index 0000000..7ca55f7 --- /dev/null +++ b/layouts/shortcodes/math.html @@ -0,0 +1 @@ +${{ .Inner }}$