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

Function buildHTML_buildExpression

static/katex/katex.js:6315–6389  ·  view source on GitHub ↗
(expression, options, isRealGroup, surrounding)

Source from the content-addressed store, hash-verified

6313 * consisting type of nodes that will be added to the left and right.
6314 */
6315var buildHTML_buildExpression = function buildExpression(expression, options, isRealGroup, surrounding) {
6316 if (surrounding === void 0) {
6317 surrounding = [null, null];
6318 }
6319
6320 // Parse expressions into `groups`.
6321 var groups = [];
6322
6323 for (var i = 0; i < expression.length; i++) {
6324 var output = buildHTML_buildGroup(expression[i], options);
6325
6326 if (output instanceof tree_DocumentFragment) {
6327 var children = output.children;
6328 groups.push.apply(groups, children);
6329 } else {
6330 groups.push(output);
6331 }
6332 } // If `expression` is a partial group, let the parent handle spacings
6333 // to avoid processing groups multiple times.
6334
6335
6336 if (!isRealGroup) {
6337 return groups;
6338 }
6339
6340 var glueOptions = options;
6341
6342 if (expression.length === 1) {
6343 var node = checkNodeType(expression[0], "sizing") || checkNodeType(expression[0], "styling");
6344
6345 if (!node) {// No match.
6346 } else if (node.type === "sizing") {
6347 glueOptions = options.havingSize(node.size);
6348 } else if (node.type === "styling") {
6349 glueOptions = options.havingStyle(buildHTML_styleMap[node.style]);
6350 }
6351 } // Dummy spans for determining spacings between surrounding atoms.
6352 // If `expression` has no atoms on the left or right, class "leftmost"
6353 // or "rightmost", respectively, is used to indicate it.
6354
6355
6356 var dummyPrev = buildHTML_makeSpan([surrounding[0] || "leftmost"], [], options);
6357 var dummyNext = buildHTML_makeSpan([surrounding[1] || "rightmost"], [], options); // TODO: These code assumes that a node's math class is the first element
6358 // of its `classes` array. A later cleanup should ensure this, for
6359 // instance by changing the signature of `makeSpan`.
6360 // Before determining what spaces to insert, perform bin cancellation.
6361 // Binary operators change to ordinary symbols in some contexts.
6362
6363 traverseNonSpaceNodes(groups, function (node, prev) {
6364 var prevType = prev.classes[0];
6365 var type = node.classes[0];
6366
6367 if (prevType === "mbin" && utils.contains(binRightCanceller, type)) {
6368 prev.classes[0] = "mord";
6369 } else if (type === "mbin" && utils.contains(binLeftCanceller, prevType)) {
6370 node.classes[0] = "mord";
6371 }
6372 }, {

Callers 6

buildHTMLFunction · 0.85
color_htmlBuilderFunction · 0.85
katex.jsFile · 0.85
mclass_htmlBuilderFunction · 0.85
op_htmlBuilderFunction · 0.85
sizingGroupFunction · 0.85

Calls 7

buildHTML_buildGroupFunction · 0.85
havingSizeMethod · 0.80
havingStyleMethod · 0.80
checkNodeTypeFunction · 0.70
traverseNonSpaceNodesFunction · 0.70
getTypeOfDomTreeFunction · 0.70
hasClassMethod · 0.45

Tested by

no test coverage detected