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

Class TextNode

src/mathMLTree.ts:151–180  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

149 * This node represents a piece of text.
150 */
151export class TextNode implements MathDomNode {
152 text: string;
153
154 constructor(text: string) {
155 this.text = text;
156 }
157
158 /**
159 * Converts the text node into a DOM text node.
160 */
161 toNode(): Node {
162 return document.createTextNode(this.text);
163 }
164
165 /**
166 * Converts the text node into escaped HTML markup
167 * (representing the text itself).
168 */
169 toMarkup(): string {
170 return escape(this.toText());
171 }
172
173 /**
174 * Converts the text node into a string
175 * (representing the text itself).
176 */
177 toText(): string {
178 return this.text;
179 }
180}
181
182/**
183 * This node represents a space, but may render as <mspace.../> or as text,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected