| 153 | * This node represents a piece of text. |
| 154 | */ |
| 155 | export class TextNode implements MathDomNode { |
| 156 | text: string; |
| 157 | |
| 158 | constructor(text: string) { |
| 159 | this.text = text; |
| 160 | } |
| 161 | |
| 162 | /** |
| 163 | * Converts the text node into a DOM text node. |
| 164 | */ |
| 165 | toNode(): Node { |
| 166 | return document.createTextNode(this.text); |
| 167 | } |
| 168 | |
| 169 | /** |
| 170 | * Converts the text node into escaped HTML markup |
| 171 | * (representing the text itself). |
| 172 | */ |
| 173 | toMarkup(): string { |
| 174 | return escape(this.toText()); |
| 175 | } |
| 176 | |
| 177 | /** |
| 178 | * Converts the text node into a string |
| 179 | * (representing the text itself). |
| 180 | */ |
| 181 | toText(): string { |
| 182 | return this.text; |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | /** |
| 187 | * This node represents a space, but may render as <mspace.../> or as text, |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…