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

Function op_htmlBuilder

static/katex/katex.js:11253–11484  ·  view source on GitHub ↗
(grp, options)

Source from the content-addressed store, hash-verified

11251
11252// NOTE: Unlike most `htmlBuilder`s, this one handles not only "op", but also
11253var op_htmlBuilder = function htmlBuilder(grp, options) {
11254 // Operators are handled in the TeXbook pg. 443-444, rule 13(a).
11255 var supGroup;
11256 var subGroup;
11257 var hasLimits = false;
11258 var group;
11259 var supSub = checkNodeType(grp, "supsub");
11260
11261 if (supSub) {
11262 // If we have limits, supsub will pass us its group to handle. Pull
11263 // out the superscript and subscript and set the group to the op in
11264 // its base.
11265 supGroup = supSub.sup;
11266 subGroup = supSub.sub;
11267 group = assertNodeType(supSub.base, "op");
11268 hasLimits = true;
11269 } else {
11270 group = assertNodeType(grp, "op");
11271 }
11272
11273 var style = options.style; // Most operators have a large successor symbol, but these don't.
11274
11275 var noSuccessor = ["\\smallint"];
11276 var large = false;
11277
11278 if (style.size === src_Style.DISPLAY.size && group.symbol && !utils.contains(noSuccessor, group.name)) {
11279 // Most symbol operators get larger in displaystyle (rule 13)
11280 large = true;
11281 }
11282
11283 var base;
11284
11285 if (group.symbol) {
11286 // If this is a symbol, create the symbol.
11287 var fontName = large ? "Size2-Regular" : "Size1-Regular";
11288 var stash = "";
11289
11290 if (group.name === "\\oiint" || group.name === "\\oiiint") {
11291 // No font glyphs yet, so use a glyph w/o the oval.
11292 // TODO: When font glyphs are available, delete this code.
11293 stash = group.name.substr(1); // $FlowFixMe
11294
11295 group.name = stash === "oiint" ? "\\iint" : "\\iiint";
11296 }
11297
11298 base = buildCommon.makeSymbol(group.name, fontName, "math", options, ["mop", "op-symbol", large ? "large-op" : "small-op"]);
11299
11300 if (stash.length > 0) {
11301 // We're in \oiint or \oiiint. Overlay the oval.
11302 // TODO: When font glyphs are available, delete this code.
11303 var italic = base.italic;
11304 var oval = buildCommon.staticSvg(stash + "Size" + (large ? "2" : "1"), options);
11305 base = buildCommon.makeVList({
11306 positionType: "individualShift",
11307 children: [{
11308 type: "elem",
11309 elem: base,
11310 shift: 0

Callers

nothing calls this directly

Calls 8

buildHTML_buildGroupFunction · 0.85
fontMetricsMethod · 0.80
havingStyleMethod · 0.80
supMethod · 0.80
subMethod · 0.80
checkNodeTypeFunction · 0.70
assertNodeTypeFunction · 0.70

Tested by

no test coverage detected