MCPcopy Create free account
hub / github.com/TruthHun/BookStack / getVariant

Function getVariant

static/katex/katex.mjs:6840–6895  ·  view source on GitHub ↗
(group, options)

Source from the content-addressed store, hash-verified

6838 */
6839
6840const getVariant = function getVariant(group, options) {
6841 // Handle \text... font specifiers as best we can.
6842 // MathML has a limited list of allowable mathvariant specifiers; see
6843 // https://www.w3.org/TR/MathML3/chapter3.html#presm.commatt
6844 if (options.fontFamily === "texttt") {
6845 return "monospace";
6846 } else if (options.fontFamily === "textsf") {
6847 if (options.fontShape === "textit" && options.fontWeight === "textbf") {
6848 return "sans-serif-bold-italic";
6849 } else if (options.fontShape === "textit") {
6850 return "sans-serif-italic";
6851 } else if (options.fontWeight === "textbf") {
6852 return "bold-sans-serif";
6853 } else {
6854 return "sans-serif";
6855 }
6856 } else if (options.fontShape === "textit" && options.fontWeight === "textbf") {
6857 return "bold-italic";
6858 } else if (options.fontShape === "textit") {
6859 return "italic";
6860 } else if (options.fontWeight === "textbf") {
6861 return "bold";
6862 }
6863
6864 const font = options.font;
6865
6866 if (!font || font === "mathnormal") {
6867 return null;
6868 }
6869
6870 const mode = group.mode;
6871
6872 if (font === "mathit") {
6873 return "italic";
6874 } else if (font === "boldsymbol") {
6875 return "bold-italic";
6876 }
6877
6878 let text = group.text;
6879
6880 if (utils.contains(["\\imath", "\\jmath"], text)) {
6881 return null;
6882 }
6883
6884 if (symbols[mode][text] && symbols[mode][text].replace) {
6885 text = symbols[mode][text].replace;
6886 }
6887
6888 const fontName = buildCommon.fontMap[font].fontName;
6889
6890 if (getCharacterMetrics(text, fontName, mode)) {
6891 return buildCommon.fontMap[font].variant;
6892 }
6893
6894 return null;
6895};
6896/**
6897 * Takes a list of nodes, builds them, and returns a list of the generated

Callers 1

mathmlBuilderFunction · 0.85

Calls 1

getCharacterMetricsFunction · 0.70

Tested by

no test coverage detected