MCPcopy Create free account
hub / github.com/TruthHun/BookStack / htmlBuilder$2

Function htmlBuilder$2

static/katex/katex.mjs:8905–9003  ·  view source on GitHub ↗
(group, options)

Source from the content-addressed store, hash-verified

8903});
8904
8905const htmlBuilder$2 = (group, options) => {
8906 // \cancel, \bcancel, \xcancel, \sout, \fbox, \colorbox, \fcolorbox
8907 // Some groups can return document fragments. Handle those by wrapping
8908 // them in a span.
8909 const inner = buildCommon.wrapFragment(buildGroup(group.body, options), options);
8910 const label = group.label.substr(1);
8911 const scale = options.sizeMultiplier;
8912 let img;
8913 let imgShift = 0; // In the LaTeX cancel package, line geometry is slightly different
8914 // depending on whether the subject is wider than it is tall, or vice versa.
8915 // We don't know the width of a group, so as a proxy, we test if
8916 // the subject is a single character. This captures most of the
8917 // subjects that should get the "tall" treatment.
8918
8919 const isSingleChar = utils.isCharacterBox(group.body);
8920
8921 if (label === "sout") {
8922 img = buildCommon.makeSpan(["stretchy", "sout"]);
8923 img.height = options.fontMetrics().defaultRuleThickness / scale;
8924 imgShift = -0.5 * options.fontMetrics().xHeight;
8925 } else {
8926 // Add horizontal padding
8927 if (/cancel/.test(label)) {
8928 if (!isSingleChar) {
8929 inner.classes.push("cancel-pad");
8930 }
8931 } else {
8932 inner.classes.push("boxpad");
8933 } // Add vertical padding
8934
8935
8936 let vertPad = 0; // ref: LaTeX source2e: \fboxsep = 3pt; \fboxrule = .4pt
8937 // ref: cancel package: \advance\totalheight2\p@ % "+2"
8938
8939 if (/box/.test(label)) {
8940 vertPad = label === "colorbox" ? 0.3 : 0.34;
8941 } else {
8942 vertPad = isSingleChar ? 0.2 : 0;
8943 }
8944
8945 img = stretchy.encloseSpan(inner, label, vertPad, options);
8946 imgShift = inner.depth + vertPad;
8947
8948 if (group.backgroundColor) {
8949 img.style.backgroundColor = group.backgroundColor;
8950
8951 if (group.borderColor) {
8952 img.style.borderColor = group.borderColor;
8953 }
8954 }
8955 }
8956
8957 let vlist;
8958
8959 if (group.backgroundColor) {
8960 vlist = buildCommon.makeVList({
8961 positionType: "individualShift",
8962 children: [// Put the color background behind inner;

Callers

nothing calls this directly

Calls 2

buildGroupFunction · 0.85
fontMetricsMethod · 0.80

Tested by

no test coverage detected