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

Function parseTree

static/katex/katex.mjs:15917–15943  ·  view source on GitHub ↗
(toParse, settings)

Source from the content-addressed store, hash-verified

15915 * Parses an expression using a Parser, then returns the parsed result.
15916 */
15917const parseTree = function parseTree(toParse, settings) {
15918 if (!(typeof toParse === 'string' || toParse instanceof String)) {
15919 throw new TypeError('KaTeX can only parse string typed expression');
15920 }
15921
15922 const parser = new Parser(toParse, settings); // Blank out any \df@tag to avoid spurious "Duplicate \tag" errors
15923
15924 delete parser.gullet.macros.current["\\df@tag"];
15925 let tree = parser.parse(); // If the input used \tag, it will set the \df@tag macro to the tag.
15926 // In this case, we separately parse the tag and wrap the tree.
15927
15928 if (parser.gullet.macros.get("\\df@tag")) {
15929 if (!settings.displayMode) {
15930 throw new ParseError("\\tag works only in display equations");
15931 }
15932
15933 parser.gullet.feed("\\df@tag");
15934 tree = [{
15935 type: "tag",
15936 mode: "text",
15937 body: tree,
15938 tag: parser.parse()
15939 }];
15940 }
15941
15942 return tree;
15943};
15944
15945/* eslint no-console:0 */
15946

Callers 3

generateParseTreeFunction · 0.85
renderToDomTreeFunction · 0.85
renderToHTMLTreeFunction · 0.85

Calls 3

parseMethod · 0.95
feedMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected