MCPcopy Create free account
hub / github.com/KaTeX/KaTeX / handleSupSubscript

Method handleSupSubscript

src/Parser.ts:285–307  ·  view source on GitHub ↗

* Handle a subscript or superscript with nice errors.

(
        name: string,   // For error reporting.
    )

Source from the content-addressed store, hash-verified

283 * Handle a subscript or superscript with nice errors.
284 */
285 handleSupSubscript(
286 name: string, // For error reporting.
287 ): AnyParseNode {
288 const symbolToken = this.fetch();
289 const symbol = symbolToken.text;
290 this.consume();
291 this.consumeSpaces(); // ignore spaces before sup/subscript argument
292
293 // Skip over allowed internal nodes such as \relax
294 let group: AnyParseNode | null | undefined;
295 do {
296 group = this.parseGroup(name);
297 } while (group?.type === "internal");
298
299 if (!group) {
300 throw new ParseError(
301 "Expected group after '" + symbol + "'",
302 symbolToken
303 );
304 }
305
306 return group;
307 }
308
309 /**
310 * Converts the textual input of an unsupported command into a text node

Callers 1

parseAtomMethod · 0.95

Calls 4

fetchMethod · 0.95
consumeMethod · 0.95
consumeSpacesMethod · 0.95
parseGroupMethod · 0.95

Tested by

no test coverage detected