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

Function assertCharacterGroup

src/parseNode.ts:52–68  ·  view source on GitHub ↗
(
    group: ParseNode<"ordgroup">,
    errorMessage: string,
    allowSpaces?: boolean,
)

Source from the content-addressed store, hash-verified

50 * literal space counts as a character; `~` and `\ ` do not.
51 */
52export function assertCharacterGroup(
53 group: ParseNode<"ordgroup">,
54 errorMessage: string,
55 allowSpaces?: boolean,
56): string {
57 let text = "";
58 for (const node of group.body) {
59 if (node.type === "textord") {
60 text += node.text;
61 } else if (allowSpaces && node.type === "spacing" && node.text === " ") {
62 text += " ";
63 } else {
64 throw new ParseError(errorMessage, group);
65 }
66 }
67 return text;
68}

Callers 3

alignedHandlerFunction · 0.90
handlerFunction · 0.90
handlerFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected