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

Function buildCommon_makeOrd

static/katex/katex.js:5452–5525  ·  view source on GitHub ↗
(group, options, type)

Source from the content-addressed store, hash-verified

5450
5451
5452var buildCommon_makeOrd = function makeOrd(group, options, type) {
5453 var mode = group.mode;
5454 var text = group.text;
5455 var classes = ["mord"]; // Math mode or Old font (i.e. \rm)
5456
5457 var isFont = mode === "math" || mode === "text" && options.font;
5458 var fontOrFamily = isFont ? options.font : options.fontFamily;
5459
5460 if (text.charCodeAt(0) === 0xD835) {
5461 // surrogate pairs get special treatment
5462 var _wideCharacterFont = wide_character_wideCharacterFont(text, mode),
5463 wideFontName = _wideCharacterFont[0],
5464 wideFontClass = _wideCharacterFont[1];
5465
5466 return buildCommon_makeSymbol(text, wideFontName, mode, options, classes.concat(wideFontClass));
5467 } else if (fontOrFamily) {
5468 var fontName;
5469 var fontClasses;
5470
5471 if (fontOrFamily === "boldsymbol" || fontOrFamily === "mathnormal") {
5472 var fontData = fontOrFamily === "boldsymbol" ? boldsymbol(text, mode, options, classes) : buildCommon_mathnormal(text, mode, options, classes);
5473 fontName = fontData.fontName;
5474 fontClasses = [fontData.fontClass];
5475 } else if (utils.contains(mathitLetters, text)) {
5476 fontName = "Main-Italic";
5477 fontClasses = ["mathit"];
5478 } else if (isFont) {
5479 fontName = fontMap[fontOrFamily].fontName;
5480 fontClasses = [fontOrFamily];
5481 } else {
5482 fontName = retrieveTextFontName(fontOrFamily, options.fontWeight, options.fontShape);
5483 fontClasses = [fontOrFamily, options.fontWeight, options.fontShape];
5484 }
5485
5486 if (buildCommon_lookupSymbol(text, fontName, mode).metrics) {
5487 return buildCommon_makeSymbol(text, fontName, mode, options, classes.concat(fontClasses));
5488 } else if (ligatures.hasOwnProperty(text) && fontName.substr(0, 10) === "Typewriter") {
5489 // Deconstruct ligatures in monospace fonts (\texttt, \tt).
5490 var parts = [];
5491
5492 for (var i = 0; i < text.length; i++) {
5493 parts.push(buildCommon_makeSymbol(text[i], fontName, mode, options, classes.concat(fontClasses)));
5494 }
5495
5496 return buildCommon_makeFragment(parts);
5497 }
5498 } // Makes a symbol in the default font for mathords and textords.
5499
5500
5501 if (type === "mathord") {
5502 var fontLookup = buildCommon_mathdefault(text, mode, options, classes);
5503 return buildCommon_makeSymbol(text, fontLookup.fontName, mode, options, classes.concat([fontLookup.fontClass]));
5504 } else if (type === "textord") {
5505 var font = src_symbols[mode][text] && src_symbols[mode][text].font;
5506
5507 if (font === "ams") {
5508 var _fontName = retrieveTextFontName("amsrm", options.fontWeight, options.fontShape);
5509

Callers

nothing calls this directly

Calls 8

buildCommon_makeSymbolFunction · 0.85
buildCommon_mathnormalFunction · 0.85
buildCommon_lookupSymbolFunction · 0.85
buildCommon_makeFragmentFunction · 0.85
buildCommon_mathdefaultFunction · 0.85
boldsymbolFunction · 0.70
retrieveTextFontNameFunction · 0.70

Tested by

no test coverage detected