feature: degree special handling

This commit is contained in:
Matthias Jung
2026-02-14 23:21:35 +01:00
parent a4bc65ddfe
commit 4a4f6aaa78
+11 -4
View File
@@ -71,7 +71,11 @@ document.addEventListener("DOMContentLoaded", function() {
const rawNum = numTok.reverse().map(t => t.text).join(""); const rawNum = numTok.reverse().map(t => t.text).join("");
const unit = unitTok.reverse().map(t => t.text).join(""); const unit = unitTok.reverse().map(t => t.text).join("");
const formattedNum = formatThousands(rawNum); const formattedNum = formatThousands(rawNum);
return formattedNum + "\\,\\mathrm{" + unit + "}"; if (unit.startsWith("\\degree")) {
return formattedNum + "\\mathrm{" + unit + "}";
} else {
return formattedNum + "\\,\\mathrm{" + unit + "}";
}
}, },
"\\qtyrange": (context) => { "\\qtyrange": (context) => {
const [aTok, bTok, unitTok] = context.consumeArgs(3); const [aTok, bTok, unitTok] = context.consumeArgs(3);
@@ -80,7 +84,11 @@ document.addEventListener("DOMContentLoaded", function() {
const unit = unitTok.reverse().map(t => t.text).join(""); const unit = unitTok.reverse().map(t => t.text).join("");
const aFmt = formatThousands(aRaw); const aFmt = formatThousands(aRaw);
const bFmt = formatThousands(bRaw); const bFmt = formatThousands(bRaw);
return aFmt + "\\,\\text{--}\\," + bFmt + "\\,\\mathrm{" + unit + "}"; if (unit.startsWith("\\degree")) {
return aFmt + "\\text{--}\\," + bFmt + "\\mathrm{" + unit + "}";
} else {
return aFmt + "\\,\\text{--}\\," + bFmt + "\\,\\mathrm{" + unit + "}";
}
}, },
"\\unit": "{\\mathrm{#1}}", "\\unit": "{\\mathrm{#1}}",
"\\squared": "{^{2}}", "\\squared": "{^{2}}",
@@ -129,8 +137,7 @@ document.addEventListener("DOMContentLoaded", function() {
"\\tesla": "\\text{T}", "\\tesla": "\\text{T}",
"\\bit": "\\text{b}", "\\bit": "\\text{b}",
"\\baud": "\\text{Bd}", "\\baud": "\\text{Bd}",
"\\degree": "^\\circ", "\\degreeCelsius": "\\,\\degree\\text{C}",
"\\degreeCelsius": "^\\circ\\text{C}",
}; };
renderMathInElement(document.body, { renderMathInElement(document.body, {