(expression, options)
| 6900 | */ |
| 6901 | |
| 6902 | const 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. |
no test coverage detected