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

Function htmlBuilder$6

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

Source from the content-addressed store, hash-verified

10128});
10129
10130const htmlBuilder$6 = (group, options) => {
10131 // Fractions are handled in the TeXbook on pages 444-445, rules 15(a-e).
10132 // Figure out what style this fraction should be in based on the
10133 // function used
10134 let style = options.style;
10135
10136 if (group.size === "display") {
10137 style = Style$1.DISPLAY;
10138 } else if (group.size === "text" && style.size === Style$1.DISPLAY.size) {
10139 // We're in a \tfrac but incoming style is displaystyle, so:
10140 style = Style$1.TEXT;
10141 } else if (group.size === "script") {
10142 style = Style$1.SCRIPT;
10143 } else if (group.size === "scriptscript") {
10144 style = Style$1.SCRIPTSCRIPT;
10145 }
10146
10147 const nstyle = style.fracNum();
10148 const dstyle = style.fracDen();
10149 let newOptions;
10150 newOptions = options.havingStyle(nstyle);
10151 const numerm = buildGroup(group.numer, newOptions, options);
10152
10153 if (group.continued) {
10154 // \cfrac inserts a \strut into the numerator.
10155 // Get \strut dimensions from TeXbook page 353.
10156 const hStrut = 8.5 / options.fontMetrics().ptPerEm;
10157 const dStrut = 3.5 / options.fontMetrics().ptPerEm;
10158 numerm.height = numerm.height < hStrut ? hStrut : numerm.height;
10159 numerm.depth = numerm.depth < dStrut ? dStrut : numerm.depth;
10160 }
10161
10162 newOptions = options.havingStyle(dstyle);
10163 const denomm = buildGroup(group.denom, newOptions, options);
10164 let rule;
10165 let ruleWidth;
10166 let ruleSpacing;
10167
10168 if (group.hasBarLine) {
10169 if (group.barSize) {
10170 ruleWidth = calculateSize(group.barSize, options);
10171 rule = buildCommon.makeLineSpan("frac-line", options, ruleWidth);
10172 } else {
10173 rule = buildCommon.makeLineSpan("frac-line", options);
10174 }
10175
10176 ruleWidth = rule.height;
10177 ruleSpacing = rule.height;
10178 } else {
10179 rule = null;
10180 ruleWidth = 0;
10181 ruleSpacing = options.fontMetrics().defaultRuleThickness;
10182 } // Rule 15b
10183
10184
10185 let numShift;
10186 let clearance;
10187 let denomShift;

Callers

nothing calls this directly

Calls 8

buildGroupFunction · 0.85
calculateSizeFunction · 0.85
fracNumMethod · 0.80
fracDenMethod · 0.80
havingStyleMethod · 0.80
fontMetricsMethod · 0.80
sizingClassesMethod · 0.80
makeNullDelimiterFunction · 0.70

Tested by

no test coverage detected