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

Method constructor

src/mathMLTree.ts:193–218  ·  view source on GitHub ↗

* Create a Space node with width given in CSS ems.

(width: number)

Source from the content-addressed store, hash-verified

191 * Create a Space node with width given in CSS ems.
192 */
193 constructor(width: number) {
194 this.width = width;
195 // See https://www.w3.org/TR/2000/WD-MathML2-20000328/chapter6.html
196 // for a table of space-like characters. We use Unicode
197 // representations instead of &LongNames; as it's not clear how to
198 // make the latter via document.createTextNode.
199 if (width >= 0.05555 && width <= 0.05556) {
200 this.character = "\u200a"; // &VeryThinSpace;
201 } else if (width >= 0.1666 && width <= 0.1667) {
202 this.character = "\u2009"; // &ThinSpace;
203 } else if (width >= 0.2222 && width <= 0.2223) {
204 this.character = "\u2005"; // &MediumSpace;
205 } else if (width >= 0.2777 && width <= 0.2778) {
206 this.character = "\u2005\u200a"; // &ThickSpace;
207 } else if (width >= -0.05556 && width <= -0.05555) {
208 this.character = "\u200a\u2063"; // &NegativeVeryThinSpace;
209 } else if (width >= -0.1667 && width <= -0.1666) {
210 this.character = "\u2009\u2063"; // &NegativeThinSpace;
211 } else if (width >= -0.2223 && width <= -0.2222) {
212 this.character = "\u205f\u2063"; // &NegativeMediumSpace;
213 } else if (width >= -0.2778 && width <= -0.2777) {
214 this.character = "\u2005\u2063"; // &NegativeThickSpace;
215 } else {
216 this.character = null;
217 }
218 }
219
220 /**
221 * Converts the math node into a MathML-namespaced DOM element.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected