A world-class math input for the web
at main 21 lines 766 B view raw
1import { TreeNode, h, t, VNode } from "@caret-js/core"; 2import { DecimalNode } from "./decimal"; 3import { MathExpressionTag } from "../tags/mathExpression"; 4import { CanBeAdjacentMultRightSideTag } from "../parselets/adjacentMultiplication"; 5 6export class PositiveNode extends TreeNode { 7 constructor(public child: TreeNode) { 8 super(); 9 this.addTag(new MathExpressionTag()).addTag( 10 new CanBeAdjacentMultRightSideTag(false), // Negative nodes cannot be on the right side of adjacent multiplication (that would just be subtraction) 11 ); 12 } 13 14 static from(child: TreeNode): PositiveNode | DecimalNode { 15 return new PositiveNode(child); 16 } 17 18 toDebugMathML(): VNode { 19 return h("mrow", {}, h("mo", {}, t("+")), this.child.toDebugMathML()); 20 } 21}