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

Function makeSymbol

static/katex/katex.mjs:5286–5321  ·  view source on GitHub ↗
(value, fontName, mode, options, classes)

Source from the content-addressed store, hash-verified

5284
5285
5286const makeSymbol = function makeSymbol(value, fontName, mode, options, classes) {
5287 const lookup = lookupSymbol(value, fontName, mode);
5288 const metrics = lookup.metrics;
5289 value = lookup.value;
5290 let symbolNode;
5291
5292 if (metrics) {
5293 let italic = metrics.italic;
5294
5295 if (mode === "text" || options && options.font === "mathit") {
5296 italic = 0;
5297 }
5298
5299 symbolNode = new SymbolNode(value, metrics.height, metrics.depth, italic, metrics.skew, metrics.width, classes);
5300 } else {
5301 // TODO(emily): Figure out a good way to only print this in development
5302 typeof console !== "undefined" && console.warn("No character metrics for '" + value + "' in style '" + fontName + "'");
5303 symbolNode = new SymbolNode(value, 0, 0, 0, 0, 0, classes);
5304 }
5305
5306 if (options) {
5307 symbolNode.maxFontSize = options.sizeMultiplier;
5308
5309 if (options.style.isTight()) {
5310 symbolNode.classes.push("mtight");
5311 }
5312
5313 const color = options.getColor();
5314
5315 if (color) {
5316 symbolNode.style.color = color;
5317 }
5318 }
5319
5320 return symbolNode;
5321};
5322/**
5323 * Makes a symbol in Main-Regular or AMS-Regular.
5324 * Used for rel, bin, open, close, inner, and punct.

Callers 2

mathsymFunction · 0.85
makeOrdFunction · 0.85

Calls 3

lookupSymbolFunction · 0.85
isTightMethod · 0.80
getColorMethod · 0.80

Tested by

no test coverage detected