MCPcopy Create free account
hub / github.com/TruthHun/BookStack / toNode

Method toNode

static/katex/katex.mjs:1209–1237  ·  view source on GitHub ↗

* Creates a text node or span from a symbol node. Note that a span is only * created if it is needed.

()

Source from the content-addressed store, hash-verified

1207
1208
1209 toNode() {
1210 const node = document.createTextNode(this.text);
1211 let span = null;
1212
1213 if (this.italic > 0) {
1214 span = document.createElement("span");
1215 span.style.marginRight = this.italic + "em";
1216 }
1217
1218 if (this.classes.length > 0) {
1219 span = span || document.createElement("span");
1220 span.className = createClass(this.classes);
1221 }
1222
1223 for (const style in this.style) {
1224 if (this.style.hasOwnProperty(style)) {
1225 span = span || document.createElement("span"); // $FlowFixMe Flow doesn't seem to understand span.style's type.
1226
1227 span.style[style] = this.style[style];
1228 }
1229 }
1230
1231 if (span) {
1232 span.appendChild(node);
1233 return span;
1234 } else {
1235 return node;
1236 }
1237 }
1238 /**
1239 * Creates markup for a symbol node.
1240 */

Callers

nothing calls this directly

Calls 1

createClassFunction · 0.70

Tested by

no test coverage detected