MCPcopy Create free account
hub / github.com/TruthHun/BookStack / buildExpression$1

Function buildExpression$1

static/katex/katex.mjs:6902–6933  ·  view source on GitHub ↗
(expression, options)

Source from the content-addressed store, hash-verified

6900 */
6901
6902const buildExpression$1 = function buildExpression(expression, options) {
6903 const groups = [];
6904 let lastGroup;
6905
6906 for (let i = 0; i < expression.length; i++) {
6907 const group = buildGroup$1(expression[i], options);
6908
6909 if (group instanceof MathNode && lastGroup instanceof MathNode) {
6910 // Concatenate adjacent <mtext>s
6911 if (group.type === 'mtext' && lastGroup.type === 'mtext' && group.getAttribute('mathvariant') === lastGroup.getAttribute('mathvariant')) {
6912 lastGroup.children.push(...group.children);
6913 continue; // Concatenate adjacent <mn>s
6914 } else if (group.type === 'mn' && lastGroup.type === 'mn') {
6915 lastGroup.children.push(...group.children);
6916 continue; // Concatenate <mn>...</mn> followed by <mi>.</mi>
6917 } else if (group.type === 'mi' && group.children.length === 1 && lastGroup.type === 'mn') {
6918 const child = group.children[0];
6919
6920 if (child instanceof TextNode && child.text === '.') {
6921 lastGroup.children.push(...group.children);
6922 continue;
6923 }
6924 }
6925 }
6926
6927 groups.push(group);
6928 lastGroup = group;
6929 } // TODO(kevinb): combine \\not with mrels and mords
6930
6931
6932 return groups;
6933};
6934/**
6935 * Equivalent to buildExpression, but wraps the elements in an <mrow>
6936 * if there's more than one. Returns a single node instead of an array.

Callers 7

buildExpressionRowFunction · 0.85
buildMathMLFunction · 0.85
mathmlBuilder$1Function · 0.85
katex.mjsFile · 0.85
mathmlBuilder$4Function · 0.85
mathmlBuilder$8Function · 0.85
mathmlBuilderFunction · 0.85

Calls 2

buildGroup$1Function · 0.85
getAttributeMethod · 0.80

Tested by

no test coverage detected