aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortdro <tdro@noreply.example.com>2025-01-25 00:00:00 +0000
committertdro <tdro@noreply.example.com>2025-01-25 00:00:00 +0000
commit9cf1123a46371b7d38a8e5883a38e344d214d2fa (patch)
tree3cbf251afe184448458654b28eab0717d2446925
parentd510e43a6cb362642fa231fdb62b29948ba5178f (diff)
downloadcanory-9cf1123a46371b7d38a8e5883a38e344d214d2fa.tar.gz
canory-9cf1123a46371b7d38a8e5883a38e344d214d2fa.tar.bz2
canory-9cf1123a46371b7d38a8e5883a38e344d214d2fa.zip
themes/default/layouts/_default/_markup: Support LaTeX render
Trust MathML render
-rw-r--r--assets/css/default.css2
-rw-r--r--themes/default/layouts/_default/_markup/render-codeblock-latex.html24
-rw-r--r--themes/default/layouts/_default/_markup/render-codeblock-mathml.html13
3 files changed, 34 insertions, 5 deletions
diff --git a/assets/css/default.css b/assets/css/default.css
index 2e5654a..32dde88 100644
--- a/assets/css/default.css
+++ b/assets/css/default.css
@@ -834,7 +834,7 @@ figure object {
img:hover,
video:hover,
figure a svg:hover,
-figure span:hover {
+figure span:hover:not(.katex) {
box-shadow: 0 0 14px #00000060;
box-shadow: 0 0 14px var(--shadow);
filter: brightness(90%);
diff --git a/themes/default/layouts/_default/_markup/render-codeblock-latex.html b/themes/default/layouts/_default/_markup/render-codeblock-latex.html
new file mode 100644
index 0000000..77430fe
--- /dev/null
+++ b/themes/default/layouts/_default/_markup/render-codeblock-latex.html
@@ -0,0 +1,24 @@
+{{- $caption := default "LaTeX Render" .Attributes.caption -}}
+{{- $ordinal := add .Ordinal 1 -}}
+{{- $hash := print (truncate 3 "" (sha256 .Inner)) (truncate 3 "" (sha256 .Page.RelPermalink)) "-" $ordinal -}}
+{{- $id := print "latex:" $hash | safeURL -}}
+{{- $latex := .Inner -}}
+{{- $math := transform.ToMath $latex -}}
+
+<math-ml>
+ <figure id="{{ $id }}">
+ <figure title="{{ $latex }}">
+ {{- with gt ($latex | len) 0 -}}
+ {{ $math }}
+ {{- else -}}
+ <math xmlns="http://www.w3.org/1998/Math/MathML">
+ <mrow>Empty LaTex Rendered</mrow>
+ </math>
+ {{- end -}}
+ </figure>
+ <figcaption>
+ <a href="#{{ $id }}">({{ $ordinal }})</a>
+ {{ $caption | markdownify }}
+ </figcaption>
+ </figure>
+</math-ml>
diff --git a/themes/default/layouts/_default/_markup/render-codeblock-mathml.html b/themes/default/layouts/_default/_markup/render-codeblock-mathml.html
index f6e5b61..ff6c4c5 100644
--- a/themes/default/layouts/_default/_markup/render-codeblock-mathml.html
+++ b/themes/default/layouts/_default/_markup/render-codeblock-mathml.html
@@ -1,13 +1,18 @@
{{- $caption := default "Math Render" .Attributes.caption -}}
{{- $ordinal := add .Ordinal 1 -}}
-{{- $hash := print (truncate 3 "" (sha256 .Inner)) (truncate 3 "" (sha256 .Page.RelPermalink)) "-" $ordinal -}}
-{{- $id := print "math:" $hash | safeURL -}}
+{{- $hash := print (truncate 3 "" (sha256 .Inner)) (truncate 3 "" (sha256 .Page.RelPermalink)) "-" $ordinal -}}
+{{- $id := print "math:" $hash | safeURL -}}
+{{- $math := .Inner -}}
<math-ml>
<figure id="{{ $id }}">
<figure>
- {{- with $math := .Inner -}}
- {{- $math | safeHTML -}}
+ {{- with gt ($math | len) 0 -}}
+ {{ $math | safeHTML }}
+ {{- else -}}
+ <math xmlns="http://www.w3.org/1998/Math/MathML">
+ <mrow>Empty MathML Rendered</mrow>
+ </math>
{{- end -}}
</figure>
<figcaption>