From 4a4f6aaa78dfe763b112498f8ed1a7b8c881b382 Mon Sep 17 00:00:00 2001 From: Matthias Jung Date: Sat, 14 Feb 2026 23:21:35 +0100 Subject: [PATCH] feature: degree special handling --- assets/latex.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/assets/latex.js b/assets/latex.js index 702ffba..85fbb1c 100644 --- a/assets/latex.js +++ b/assets/latex.js @@ -71,7 +71,11 @@ document.addEventListener("DOMContentLoaded", function() { const rawNum = numTok.reverse().map(t => t.text).join(""); const unit = unitTok.reverse().map(t => t.text).join(""); const formattedNum = formatThousands(rawNum); - return formattedNum + "\\,\\mathrm{" + unit + "}"; + if (unit.startsWith("\\degree")) { + return formattedNum + "\\mathrm{" + unit + "}"; + } else { + return formattedNum + "\\,\\mathrm{" + unit + "}"; + } }, "\\qtyrange": (context) => { 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 aFmt = formatThousands(aRaw); 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}}", "\\squared": "{^{2}}", @@ -129,8 +137,7 @@ document.addEventListener("DOMContentLoaded", function() { "\\tesla": "\\text{T}", "\\bit": "\\text{b}", "\\baud": "\\text{Bd}", - "\\degree": "^\\circ", - "\\degreeCelsius": "^\\circ\\text{C}", + "\\degreeCelsius": "\\,\\degree\\text{C}", }; renderMathInElement(document.body, {