A world-class math input for the web
1import { CaretNode, IsErrorNodeTag } from "../node";
2import { Token } from "../token";
3import { h, VNode } from "../vdom";
4
5export class UnparseableNode extends CaretNode {
6 constructor(public parsed: CaretNode | null, public unparsedTokens: Token[]) {
7 super();
8 this.addTag(new IsErrorNodeTag());
9 }
10
11 static from(
12 parsed: CaretNode | null,
13 unparsedTokens: Token[]
14 ): UnparseableNode {
15 return new UnparseableNode(parsed, unparsedTokens);
16 }
17
18 toDebugHTML(): string {
19 return '<div style="color:red;">Unparseable</div>';
20 }
21
22 toDebugMathML(): VNode {
23 return h(
24 "mrow",
25 {},
26 ...this.unparsedTokens.map((token) => token.renderToDebugMathML())
27 );
28 }
29}