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

Function buildCommon_makeVList

static/katex/katex.js:5748–5842  ·  view source on GitHub ↗
(params, options)

Source from the content-addressed store, hash-verified

5746
5747
5748var buildCommon_makeVList = function makeVList(params, options) {
5749 var _getVListChildrenAndD = getVListChildrenAndDepth(params),
5750 children = _getVListChildrenAndD.children,
5751 depth = _getVListChildrenAndD.depth; // Create a strut that is taller than any list item. The strut is added to
5752 // each item, where it will determine the item's baseline. Since it has
5753 // `overflow:hidden`, the strut's top edge will sit on the item's line box's
5754 // top edge and the strut's bottom edge will sit on the item's baseline,
5755 // with no additional line-height spacing. This allows the item baseline to
5756 // be positioned precisely without worrying about font ascent and
5757 // line-height.
5758
5759
5760 var pstrutSize = 0;
5761
5762 for (var i = 0; i < children.length; i++) {
5763 var child = children[i];
5764
5765 if (child.type === "elem") {
5766 var elem = child.elem;
5767 pstrutSize = Math.max(pstrutSize, elem.maxFontSize, elem.height);
5768 }
5769 }
5770
5771 pstrutSize += 2;
5772 var pstrut = buildCommon_makeSpan(["pstrut"], []);
5773 pstrut.style.height = pstrutSize + "em"; // Create a new list of actual children at the correct offsets
5774
5775 var realChildren = [];
5776 var minPos = depth;
5777 var maxPos = depth;
5778 var currPos = depth;
5779
5780 for (var _i2 = 0; _i2 < children.length; _i2++) {
5781 var _child = children[_i2];
5782
5783 if (_child.type === "kern") {
5784 currPos += _child.size;
5785 } else {
5786 var _elem = _child.elem;
5787 var classes = _child.wrapperClasses || [];
5788 var style = _child.wrapperStyle || {};
5789 var childWrap = buildCommon_makeSpan(classes, [pstrut, _elem], undefined, style);
5790 childWrap.style.top = -pstrutSize - currPos - _elem.depth + "em";
5791
5792 if (_child.marginLeft) {
5793 childWrap.style.marginLeft = _child.marginLeft;
5794 }
5795
5796 if (_child.marginRight) {
5797 childWrap.style.marginRight = _child.marginRight;
5798 }
5799
5800 realChildren.push(childWrap);
5801 currPos += _elem.height + _elem.depth;
5802 }
5803
5804 minPos = Math.min(minPos, currPos);
5805 maxPos = Math.max(maxPos, currPos);

Callers

nothing calls this directly

Calls 2

buildCommon_makeSpanFunction · 0.85
getVListChildrenAndDepthFunction · 0.70

Tested by

no test coverage detected