MCPcopy
hub / github.com/KhronosGroup/Vulkan-Docs / parseTree

Function parseTree

katex/katex.js:18742–18770  ·  view source on GitHub ↗
(toParse, settings)

Source from the content-addressed store, hash-verified

18740 * Parses an expression using a Parser, then returns the parsed result.
18741 */
18742const parseTree = function (toParse, settings) {
18743 if (!(typeof toParse === 'string' || toParse instanceof String)) {
18744 throw new TypeError('KaTeX can only parse string typed expression');
18745 }
18746
18747 const parser = new Parser(toParse, settings); // Blank out any \df@tag to avoid spurious "Duplicate \tag" errors
18748
18749 delete parser.gullet.macros.current["\\df@tag"];
18750 let tree = parser.parse(); // Prevent a color definition from persisting between calls to katex.render().
18751
18752 delete parser.gullet.macros.current["\\current@color"];
18753 delete parser.gullet.macros.current["\\color"]; // If the input used \tag, it will set the \df@tag macro to the tag.
18754 // In this case, we separately parse the tag and wrap the tree.
18755
18756 if (parser.gullet.macros.get("\\df@tag")) {
18757 if (!settings.displayMode) {
18758 throw new src_ParseError("\\tag works only in display equations");
18759 }
18760
18761 tree = [{
18762 type: "tag",
18763 mode: "text",
18764 body: tree,
18765 tag: parser.subparse([new Token("\\df@tag")])
18766 }];
18767 }
18768
18769 return tree;
18770};
18771
18772/* harmony default export */ var src_parseTree = (parseTree);
18773;// CONCATENATED MODULE: ./katex.js

Callers

nothing calls this directly

Calls 3

parseMethod · 0.95
subparseMethod · 0.95
getMethod · 0.45

Tested by

no test coverage detected