(expr: any, settings: any = new Settings())
| 71 | * @returns {Object} |
| 72 | */ |
| 73 | export function getBuilt(expr: any, settings: any = new Settings()): any { |
| 74 | expr = r(expr); // support tagging literals |
| 75 | let rootNode: any = katex.__renderToDomTree(expr, settings); |
| 76 | |
| 77 | if (rootNode.classes.includes('katex-error')) { |
| 78 | return rootNode; |
| 79 | } |
| 80 | |
| 81 | if (rootNode.classes.includes('katex-display')) { |
| 82 | rootNode = rootNode.children[0]; |
| 83 | } |
| 84 | |
| 85 | // grab the root node of the HTML rendering |
| 86 | // rootNode.children[0] is the MathML rendering |
| 87 | const builtHTML: any = rootNode.children[1]; |
| 88 | |
| 89 | // combine the non-strut children of all base spans |
| 90 | const children = []; |
| 91 | for (let i = 0; i < builtHTML.children.length; i++) { |
| 92 | children.push(...builtHTML.children[i].children.filter( |
| 93 | (node: {classes: string[]}) => !node.classes.includes("strut"))); |
| 94 | } |
| 95 | return children; |
| 96 | } |
| 97 | |
| 98 | /** |
| 99 | * Return the root node of the parse tree. |
no test coverage detected
searching dependent graphs…