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

Function buildMathML_buildExpression

static/katex/katex.js:6975–7015  ·  view source on GitHub ↗
(expression, options)

Source from the content-addressed store, hash-verified

6973 */
6974
6975var buildMathML_buildExpression = function buildExpression(expression, options) {
6976 var groups = [];
6977 var lastGroup;
6978
6979 for (var i = 0; i < expression.length; i++) {
6980 var group = buildMathML_buildGroup(expression[i], options);
6981
6982 if (group instanceof mathMLTree_MathNode && lastGroup instanceof mathMLTree_MathNode) {
6983 // Concatenate adjacent <mtext>s
6984 if (group.type === 'mtext' && lastGroup.type === 'mtext' && group.getAttribute('mathvariant') === lastGroup.getAttribute('mathvariant')) {
6985 var _lastGroup$children;
6986
6987 (_lastGroup$children = lastGroup.children).push.apply(_lastGroup$children, group.children);
6988
6989 continue; // Concatenate adjacent <mn>s
6990 } else if (group.type === 'mn' && lastGroup.type === 'mn') {
6991 var _lastGroup$children2;
6992
6993 (_lastGroup$children2 = lastGroup.children).push.apply(_lastGroup$children2, group.children);
6994
6995 continue; // Concatenate <mn>...</mn> followed by <mi>.</mi>
6996 } else if (group.type === 'mi' && group.children.length === 1 && lastGroup.type === 'mn') {
6997 var child = group.children[0];
6998
6999 if (child instanceof mathMLTree_TextNode && child.text === '.') {
7000 var _lastGroup$children3;
7001
7002 (_lastGroup$children3 = lastGroup.children).push.apply(_lastGroup$children3, group.children);
7003
7004 continue;
7005 }
7006 }
7007 }
7008
7009 groups.push(group);
7010 lastGroup = group;
7011 } // TODO(kevinb): combine \\not with mrels and mords
7012
7013
7014 return groups;
7015};
7016/**
7017 * Equivalent to buildExpression, but wraps the elements in an <mrow>
7018 * if there's more than one. Returns a single node instead of an array.

Callers 6

buildExpressionRowFunction · 0.85
buildMathMLFunction · 0.85
color_mathmlBuilderFunction · 0.85
katex.jsFile · 0.85
mclass_mathmlBuilderFunction · 0.85
op_mathmlBuilderFunction · 0.85

Calls 2

buildMathML_buildGroupFunction · 0.85
getAttributeMethod · 0.80

Tested by

no test coverage detected