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

Function buildSvgSpan_

static/katex/katex.js:7271–7386  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7269var stretchy_svgSpan = function svgSpan(group, options) {
7270 // Create a span with inline SVG for the element.
7271 function buildSvgSpan_() {
7272 var viewBoxWidth = 400000; // default
7273
7274 var label = group.label.substr(1);
7275
7276 if (utils.contains(["widehat", "widecheck", "widetilde", "utilde"], label)) {
7277 // Each type in the `if` statement corresponds to one of the ParseNode
7278 // types below. This narrowing is required to access `grp.base`.
7279 var grp = group; // There are four SVG images available for each function.
7280 // Choose a taller image when there are more characters.
7281
7282 var numChars = groupLength(grp.base);
7283 var viewBoxHeight;
7284 var pathName;
7285
7286 var _height;
7287
7288 if (numChars > 5) {
7289 if (label === "widehat" || label === "widecheck") {
7290 viewBoxHeight = 420;
7291 viewBoxWidth = 2364;
7292 _height = 0.42;
7293 pathName = label + "4";
7294 } else {
7295 viewBoxHeight = 312;
7296 viewBoxWidth = 2340;
7297 _height = 0.34;
7298 pathName = "tilde4";
7299 }
7300 } else {
7301 var imgIndex = [1, 1, 2, 2, 3, 3][numChars];
7302
7303 if (label === "widehat" || label === "widecheck") {
7304 viewBoxWidth = [0, 1062, 2364, 2364, 2364][imgIndex];
7305 viewBoxHeight = [0, 239, 300, 360, 420][imgIndex];
7306 _height = [0, 0.24, 0.3, 0.3, 0.36, 0.42][imgIndex];
7307 pathName = label + imgIndex;
7308 } else {
7309 viewBoxWidth = [0, 600, 1033, 2339, 2340][imgIndex];
7310 viewBoxHeight = [0, 260, 286, 306, 312][imgIndex];
7311 _height = [0, 0.26, 0.286, 0.3, 0.306, 0.34][imgIndex];
7312 pathName = "tilde" + imgIndex;
7313 }
7314 }
7315
7316 var path = new domTree_PathNode(pathName);
7317 var svgNode = new SvgNode([path], {
7318 "width": "100%",
7319 "height": _height + "em",
7320 "viewBox": "0 0 " + viewBoxWidth + " " + viewBoxHeight,
7321 "preserveAspectRatio": "none"
7322 });
7323 return {
7324 span: buildCommon.makeSvgSpan([], [svgNode], options),
7325 minWidth: 0,
7326 height: _height
7327 };
7328 } else {

Callers 1

stretchy_svgSpanFunction · 0.70

Calls 1

groupLengthFunction · 0.70

Tested by

no test coverage detected