MCPcopy Index your code
hub / github.com/TruthHun/BookStack / buildMathML_getVariant

Function buildMathML_getVariant

static/katex/katex.js:6913–6968  ·  view source on GitHub ↗
(group, options)

Source from the content-addressed store, hash-verified

6911 */
6912
6913var buildMathML_getVariant = function getVariant(group, options) {
6914 // Handle \text... font specifiers as best we can.
6915 // MathML has a limited list of allowable mathvariant specifiers; see
6916 // https://www.w3.org/TR/MathML3/chapter3.html#presm.commatt
6917 if (options.fontFamily === "texttt") {
6918 return "monospace";
6919 } else if (options.fontFamily === "textsf") {
6920 if (options.fontShape === "textit" && options.fontWeight === "textbf") {
6921 return "sans-serif-bold-italic";
6922 } else if (options.fontShape === "textit") {
6923 return "sans-serif-italic";
6924 } else if (options.fontWeight === "textbf") {
6925 return "bold-sans-serif";
6926 } else {
6927 return "sans-serif";
6928 }
6929 } else if (options.fontShape === "textit" && options.fontWeight === "textbf") {
6930 return "bold-italic";
6931 } else if (options.fontShape === "textit") {
6932 return "italic";
6933 } else if (options.fontWeight === "textbf") {
6934 return "bold";
6935 }
6936
6937 var font = options.font;
6938
6939 if (!font || font === "mathnormal") {
6940 return null;
6941 }
6942
6943 var mode = group.mode;
6944
6945 if (font === "mathit") {
6946 return "italic";
6947 } else if (font === "boldsymbol") {
6948 return "bold-italic";
6949 }
6950
6951 var text = group.text;
6952
6953 if (utils.contains(["\\imath", "\\jmath"], text)) {
6954 return null;
6955 }
6956
6957 if (src_symbols[mode][text] && src_symbols[mode][text].replace) {
6958 text = src_symbols[mode][text].replace;
6959 }
6960
6961 var fontName = buildCommon.fontMap[font].fontName;
6962
6963 if (getCharacterMetrics(text, fontName, mode)) {
6964 return buildCommon.fontMap[font].variant;
6965 }
6966
6967 return null;
6968};
6969/**
6970 * Takes a list of nodes, builds them, and returns a list of the generated

Callers 1

katex.jsFile · 0.85

Calls 1

getCharacterMetricsFunction · 0.70

Tested by

no test coverage detected