aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortdro <tdro@noreply.example.com>2023-10-17 18:54:19 -0400
committertdro <tdro@noreply.example.com>2023-10-17 18:54:19 -0400
commite55fd333c9d1afabf5a4818eaf925cf31f677975 (patch)
treeeaa48b023731e83f2aeb70e21fd9a154ad2ecb37
parentddcd558c253e2cc350f495fff734c9b5112082ee (diff)
downloadcanory-e55fd333c9d1afabf5a4818eaf925cf31f677975.tar.gz
canory-e55fd333c9d1afabf5a4818eaf925cf31f677975.tar.bz2
canory-e55fd333c9d1afabf5a4818eaf925cf31f677975.zip
themes/default/layouts/_default/_markup: Support MathML
-rw-r--r--assets/css/default.css48
-rw-r--r--themes/default/layouts/_default/_markup/render-codeblock-mathml.html18
2 files changed, 65 insertions, 1 deletions
diff --git a/assets/css/default.css b/assets/css/default.css
index fa78d32..9f8fc11 100644
--- a/assets/css/default.css
+++ b/assets/css/default.css
@@ -221,6 +221,11 @@ h3 {
margin: 0;
}
+math {
+ font-family: "CMU Serif", serif;
+ font-size: 110%;
+}
+
micro-card[id] article h1,
micro-card[id] article h2,
micro-card[id] article h3 {
@@ -1419,7 +1424,9 @@ micro-summary details[data-disclosure][open] ~ *:not(details):not(micro-tags) {
display: inherit;
}
-micro-summary details[data-disclosure][open] ~ *:not(details):not(micro-tags) {
+micro-summary
+ details[data-disclosure][open]
+ ~ *:not(details):not(micro-tags):not(math-ml) {
color: #444;
color: var(--fade);
}
@@ -2220,6 +2227,45 @@ link-card article a {
display: block;
}
+math-ml,
+math-ml math {
+ display: block math;
+}
+
+math-ml:not(:last-child) {
+ margin-bottom: 0.75rem;
+}
+
+math-ml figure[id] {
+ scroll-margin-top: 6rem;
+}
+
+math-ml figure[id] figure {
+ overflow-x: auto;
+ overflow-y: hidden;
+ margin: 0;
+}
+
+math-ml figure[id] a:first-child {
+ font-size: 85%;
+ margin: 0 0.25rem;
+ padding: 0.125rem 0.25rem;
+ text-decoration: none;
+ font-weight: 700;
+ outline: 1px solid;
+ border-radius: 0.25rem;
+ display: inline-block;
+ line-height: 100%;
+}
+
+math-ml figure[id]:target figure {
+ background-color: #ffe699;
+ background-color: var(--warning-background);
+ color: #000;
+ outline: 2px solid;
+ border-radius: 0.5rem;
+}
+
/* ----- Attributes ----- */
[tabindex="-1"]:focus {
diff --git a/themes/default/layouts/_default/_markup/render-codeblock-mathml.html b/themes/default/layouts/_default/_markup/render-codeblock-mathml.html
new file mode 100644
index 0000000..62ce0e8
--- /dev/null
+++ b/themes/default/layouts/_default/_markup/render-codeblock-mathml.html
@@ -0,0 +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 -}}
+
+<math-ml>
+ <figure id="{{ $id }}">
+ <figure>
+ {{- with $math := .Inner -}}
+ {{- $math | safeHTML -}}
+ {{- end -}}
+ </figure>
+ <figcaption>
+ <a href="#{{ $id }}">{{ $ordinal }}</a>
+ {{ $caption | markdownify }}
+ </figcaption>
+ </figure>
+</math-ml>