feature: degree special handling
This commit is contained in:
+11
-4
@@ -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, {
|
||||||
|
|||||||
Reference in New Issue
Block a user