MCPcopy
hub / github.com/KaTeX/KaTeX / buildHTMLUnbreakable

Function buildHTMLUnbreakable

src/buildHTML.ts:299–314  ·  view source on GitHub ↗

* Combine an array of HTML DOM nodes (e.g., the output of `buildExpression`) * into an unbreakable HTML node of class .base, with proper struts to * guarantee correct vertical extent. `buildHTML` calls this repeatedly to * make up the entire expression as a sequence of unbreakable units.

(children: HtmlDomNode[], options: Options)

Source from the content-addressed store, hash-verified

297 * make up the entire expression as a sequence of unbreakable units.
298 */
299function buildHTMLUnbreakable(children: HtmlDomNode[], options: Options) {
300 // Compute height and depth of this chunk.
301 const body = makeSpan(["base"], children, options);
302
303 // Add strut, which ensures that the top of the HTML element falls at
304 // the height of the expression, and the bottom of the HTML element
305 // falls at the depth of the expression.
306 const strut = makeSpan(["strut"]);
307 strut.style.height = makeEm(body.height + body.depth);
308 if (body.depth) {
309 strut.style.verticalAlign = makeEm(-body.depth);
310 }
311 body.children.unshift(strut);
312
313 return body;
314}
315
316/**
317 * Take an entire parse tree, and build it into an appropriate set of HTML

Callers 1

buildHTMLFunction · 0.85

Calls 2

makeSpanFunction · 0.90
makeEmFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…