MCPcopy
hub / github.com/KaTeX/KaTeX / getBuilt

Function getBuilt

test/helpers.ts:73–96  ·  view source on GitHub ↗
(expr: any, settings: any = new Settings())

Source from the content-addressed store, hash-verified

71 * @returns {Object}
72 */
73export 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.

Callers 1

katex-spec.tsFile · 0.90

Calls 1

rFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…