Add math render codeblock and math shortcode.
This commit is contained in:
parent
91c01f30a0
commit
936892fe7b
5 changed files with 37 additions and 1 deletions
27
README.md
27
README.md
|
|
@ -835,6 +835,33 @@ Download the latest release from <https://github.com/KaTeX/KaTeX/releases>. 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
|
||||
|
||||
|
|
|
|||
6
layouts/_default/_markup/render-codeblock-math.html
Normal file
6
layouts/_default/_markup/render-codeblock-math.html
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{{ .Page.Store.Set "math" true -}}
|
||||
<p{{ with .Attributes.class }} class="{{ . }}"{{ end }}>
|
||||
$$
|
||||
{{ .Inner }}
|
||||
$$
|
||||
</p>
|
||||
|
|
@ -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" . }}
|
||||
</head>
|
||||
|
||||
<body class="{{ if .IsPage }}single-page{{ else }}list-page{{ end }}{{ if .IsHome }} front{{ end }}{{ with $.Param "bodyclass" }} {{ . }}{{ end }}">
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
{{ if or ($.Param "math") (.Page.Store.Get "math") (.HasShortcode "math") -}}
|
||||
<link rel="stylesheet" href="{{ "katex/katex.min.css" | relURL }}">
|
||||
<script defer src="{{ "katex/katex.min.js" | relURL }}"></script>
|
||||
<script defer src="{{ "katex/contrib/auto-render.min.js" | relURL }}"></script>
|
||||
{{ $math := resources.Get "js/math.js" | minify | fingerprint -}}
|
||||
<script defer src="{{ $math.RelPermalink }}"></script>
|
||||
{{ end -}}
|
||||
|
|
|
|||
1
layouts/shortcodes/math.html
Normal file
1
layouts/shortcodes/math.html
Normal file
|
|
@ -0,0 +1 @@
|
|||
${{ .Inner }}$
|
||||
Loading…
Reference in a new issue