MCPcopy Create free account
hub / github.com/TruthHun/BookStack / expandMacro

Method expandMacro

static/katex/katex.mjs:14082–14100  ·  view source on GitHub ↗

* Fully expand the given macro name and return the resulting list of * tokens, or return `undefined` if no such macro is defined.

(name)

Source from the content-addressed store, hash-verified

14080
14081
14082 expandMacro(name) {
14083 if (!this.macros.get(name)) {
14084 return undefined;
14085 }
14086
14087 const output = [];
14088 const oldStackLength = this.stack.length;
14089 this.pushToken(new Token(name));
14090
14091 while (this.stack.length > oldStackLength) {
14092 const expanded = this.expandOnce(); // expandOnce returns Token if and only if it's fully expanded.
14093
14094 if (expanded instanceof Token) {
14095 output.push(this.stack.pop());
14096 }
14097 }
14098
14099 return output;
14100 }
14101 /**
14102 * Fully expand the given macro name and return the result as a string,
14103 * or return `undefined` if no such macro is defined.

Callers 3

expandMacroAsTextMethod · 0.95
katex.jsFile · 0.80
katex.min.jsFile · 0.80

Calls 3

pushTokenMethod · 0.95
expandOnceMethod · 0.95
getMethod · 0.45

Tested by

no test coverage detected