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

Function makeLeftRightDelim

static/katex/katex.mjs:8567–8587  ·  view source on GitHub ↗
(delim, height, depth, options, mode, classes)

Source from the content-addressed store, hash-verified

8565
8566
8567const makeLeftRightDelim = function makeLeftRightDelim(delim, height, depth, options, mode, classes) {
8568 // We always center \left/\right delimiters, so the axis is always shifted
8569 const axisHeight = options.fontMetrics().axisHeight * options.sizeMultiplier; // Taken from TeX source, tex.web, function make_left_right
8570
8571 const delimiterFactor = 901;
8572 const delimiterExtend = 5.0 / options.fontMetrics().ptPerEm;
8573 const maxDistFromAxis = Math.max(height - axisHeight, depth + axisHeight);
8574 const totalHeight = Math.max( // In real TeX, calculations are done using integral values which are
8575 // 65536 per pt, or 655360 per em. So, the division here truncates in
8576 // TeX but doesn't here, producing different results. If we wanted to
8577 // exactly match TeX's calculation, we could do
8578 // Math.floor(655360 * maxDistFromAxis / 500) *
8579 // delimiterFactor / 655360
8580 // (To see the difference, compare
8581 // x^{x^{\left(\rule{0.1em}{0.68em}\right)}}
8582 // in TeX and KaTeX)
8583 maxDistFromAxis / 500 * delimiterFactor, 2 * maxDistFromAxis - delimiterExtend); // Finally, we defer to `makeCustomSizedDelim` with our calculated total
8584 // height
8585
8586 return makeCustomSizedDelim(delim, totalHeight, true, options, mode, classes);
8587};
8588
8589var delimiter = {
8590 sqrtImage: makeSqrtImage,

Callers

nothing calls this directly

Calls 2

makeCustomSizedDelimFunction · 0.85
fontMetricsMethod · 0.80

Tested by

no test coverage detected