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

Function makeVList

static/katex/katex.mjs:5716–5810  ·  view source on GitHub ↗
(params, options)

Source from the content-addressed store, hash-verified

5714
5715
5716const makeVList = function makeVList(params, options) {
5717 const _getVListChildrenAndD = getVListChildrenAndDepth(params),
5718 children = _getVListChildrenAndD.children,
5719 depth = _getVListChildrenAndD.depth; // Create a strut that is taller than any list item. The strut is added to
5720 // each item, where it will determine the item's baseline. Since it has
5721 // `overflow:hidden`, the strut's top edge will sit on the item's line box's
5722 // top edge and the strut's bottom edge will sit on the item's baseline,
5723 // with no additional line-height spacing. This allows the item baseline to
5724 // be positioned precisely without worrying about font ascent and
5725 // line-height.
5726
5727
5728 let pstrutSize = 0;
5729
5730 for (let i = 0; i < children.length; i++) {
5731 const child = children[i];
5732
5733 if (child.type === "elem") {
5734 const elem = child.elem;
5735 pstrutSize = Math.max(pstrutSize, elem.maxFontSize, elem.height);
5736 }
5737 }
5738
5739 pstrutSize += 2;
5740 const pstrut = makeSpan(["pstrut"], []);
5741 pstrut.style.height = pstrutSize + "em"; // Create a new list of actual children at the correct offsets
5742
5743 const realChildren = [];
5744 let minPos = depth;
5745 let maxPos = depth;
5746 let currPos = depth;
5747
5748 for (let i = 0; i < children.length; i++) {
5749 const child = children[i];
5750
5751 if (child.type === "kern") {
5752 currPos += child.size;
5753 } else {
5754 const elem = child.elem;
5755 const classes = child.wrapperClasses || [];
5756 const style = child.wrapperStyle || {};
5757 const childWrap = makeSpan(classes, [pstrut, elem], undefined, style);
5758 childWrap.style.top = -pstrutSize - currPos - elem.depth + "em";
5759
5760 if (child.marginLeft) {
5761 childWrap.style.marginLeft = child.marginLeft;
5762 }
5763
5764 if (child.marginRight) {
5765 childWrap.style.marginRight = child.marginRight;
5766 }
5767
5768 realChildren.push(childWrap);
5769 currPos += elem.height + elem.depth;
5770 }
5771
5772 minPos = Math.min(minPos, currPos);
5773 maxPos = Math.max(maxPos, currPos);

Callers

nothing calls this directly

Calls 2

makeSpanFunction · 0.85
getVListChildrenAndDepthFunction · 0.70

Tested by

no test coverage detected