mirror of
https://github.com/matrix-org/matrix-spec
synced 2026-02-15 02:23:42 +01:00
Use docsy's support for KaTeX
Rather than having our own implementation. Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
This commit is contained in:
parent
4bd7a9242c
commit
93835adcca
|
|
@ -166,3 +166,10 @@ sidebar_menu_compact = true
|
|||
mediaType = "text/markdown"
|
||||
isPlainText = true
|
||||
baseName = "checklist"
|
||||
|
||||
# Add font media types for downloading KaTeX fonts.
|
||||
[mediaTypes]
|
||||
[mediaTypes.'font/woff']
|
||||
suffixes = ['woff']
|
||||
[mediaTypes.'font/woff2']
|
||||
suffixes = ['woff2']
|
||||
|
|
|
|||
|
|
@ -5,15 +5,7 @@
|
|||
We use it to send the delimited passthrough element through KaTeX to render maths
|
||||
in the Olm / Megolm spec.
|
||||
|
||||
See: https://gohugo.io/functions/transform/tomath/#step-2
|
||||
See: https://www.docsy.dev/docs/content/diagrams-and-formulae/#add-passthrough-render-hook
|
||||
|
||||
*/ -}}
|
||||
{{- $opts := dict "output" "htmlAndMathml" "displayMode" (eq .Type "block") }}
|
||||
{{- with try (transform.ToMath .Inner $opts) }}
|
||||
{{- with .Err }}
|
||||
{{- errorf "Unable to render mathematical markup to HTML using the transform.ToMath function. The KaTeX display engine threw the following error: %s: see %s." . $.Position }}
|
||||
{{- else }}
|
||||
{{- .Value }}
|
||||
{{- $.Page.Store.Set "hasMath" true }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
{{ partial "scripts/math.html" . }}
|
||||
|
|
|
|||
|
|
@ -31,10 +31,6 @@
|
|||
class="no-js">
|
||||
<head>
|
||||
{{ partial "head.html" . }}
|
||||
{{ if .Page.Store.Get "hasMath" }}
|
||||
<link href="{{ relURL "css/katex.min.css" }}" rel="preload" as="style">
|
||||
<link href="{{ relURL "css/katex.min.css" }}" rel="stylesheet">
|
||||
{{ end }}
|
||||
</head>
|
||||
<body class="td-{{ .Kind }}{{ with .Page.Params.body_class }} {{ . }}{{ end }}">
|
||||
<header>
|
||||
|
|
|
|||
|
|
@ -1,41 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Download the KaTeX fonts and CSS, and copy them into `static`.
|
||||
set -e
|
||||
|
||||
root=$(dirname "$0")/..
|
||||
|
||||
# Check that the caller supplied a version.
|
||||
version=$1
|
||||
if [[ -z $1 || $1 = "-h" || $1 = "--help" ]]; then
|
||||
>&2 echo "Usage: download-katex-assets.sh VERSION (e.g. v0.16.23)"
|
||||
>&2 echo
|
||||
>&2 echo "Downloads KaTeX fonts and CSS from the specified release"
|
||||
>&2 echo "on GitHub and puts the files into static/."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create a temporary directory and register a handler to clean it up on exit.
|
||||
tmp_dir=$(mktemp -d)
|
||||
clean_up () {
|
||||
rm -rf "$tmp_dir"
|
||||
}
|
||||
trap clean_up EXIT
|
||||
|
||||
# Fetch the release archive.
|
||||
archive=$tmp_dir/katex.tar.gz
|
||||
url=https://github.com/KaTeX/KaTeX/releases/download/$version/katex.tar.gz
|
||||
echo "GET $url"
|
||||
curl -L --output "$archive" "$url"
|
||||
|
||||
# Unpack the archive.
|
||||
tar -xzvf "$archive" -C "$tmp_dir"
|
||||
|
||||
# Move the CSS file into place.
|
||||
install -vm644 "$tmp_dir/katex/katex.min.css" "$root/static/css/katex.min.css"
|
||||
|
||||
# Remove any existing fonts and move the new ones into place.
|
||||
rm -rvf "$root"/static/css/fonts/KaTeX*
|
||||
while IFS= read -r -d '' file; do
|
||||
install -vm644 "$file" "$root/static/css/fonts"
|
||||
done < <(find "$tmp_dir/katex/fonts" -maxdepth 1 -name "KaTeX*.woff2" -print0)
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1
static/css/katex.min.css
vendored
1
static/css/katex.min.css
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue