<commit_before>/**
 * This module deals with creating delimiters of various sizes. The TeXbook
 * discusses these routines on page 441-442, in the "Another subroutine sets box
 * x to a specified variable delimiter" paragraph.
 *
 * There are three main routines here. `makeSmallDelim` makes a delimiter in the
 * normal font, but in either text, script, or scriptscript style.
 * `makeLargeDelim` makes a delimiter in textstyle, but in one of the Size1,
 * Size2, Size3, or Size4 fonts. `makeStackedDelim` makes a delimiter out of
 * smaller pieces that are stacked on top of one another.
 *
 * The functions take a parameter `center`, which determines if the delimiter
 * should be centered around the axis.
 *
 * Then, there are three exposed functions. `sizedDelim` makes a delimiter in
 * one of the given sizes. This is used for things like `\bigl`.
 * `customSizedDelim` makes a delimiter with a given total height+depth. It is
 * called in places like `\sqrt`. `leftRightDelim` makes an appropriate
 * delimiter which surrounds an expression of a given height an depth. It is
 * used in `\left` and `\right`.
 * @summary   Handling of delimiters surrounds symbols.
 * @module delimiters
 * @private
 */

import Definitions from './definitions.js';
import Span from './span.js';
import Mathstyle from './mathstyle.js';
import FontMetrics from './fontMetrics.js';

const makeSymbol = Span.makeSymbol;
const makeStyleWrap = Span.makeStyleWrap;
const makeSpan = Span.makeSpan;
const makeVlist = Span.makeVlist;



/**
 * Makes a small delimiter. This is a delimiter that comes in the Main-Regular
 * font, but is restyled to either be in textstyle, scriptstyle, or
 * scriptscriptstyle.
 * @memberof module:delimiters
 * @private
 */
function makeSmallDelim(type, delim, style, center, context, classes) {
    const text = makeSymbol(Definitions.getFontName('math', delim),
        Definitions.getValue('math', delim));

    const span = makeStyleWrap(type, text, context.mathstyle, style, classes);

    if (center) {
        span.setTop((1 - context.mathstyle.sizeMultiplier / style.sizeMultiplier) *
            context.mathstyle.metrics.axisHeight);
    }
    span.setStyle('color', context.color);
    if (typeof context.opacity === 'number') span.setStyle('opacity', context.opacity);

    return span;
}

/**
 * Makes a large delimiter. This is a delimiter that comes in the Size1, Size2,
 * Size3, or Size4 fonts. It is always rendered in textstyle.
 * @memberof module:delimiters
 * @private
 */
function makeLargeDelim(type, delim, size, center, context, classes) {
    const inner = makeSymbol('Size' + size + '-Regular',
        Definitions.getValue('math', delim));

    const result = makeStyleWrap( type,
            makeSpan(inner, 'delimsizing size' + size),
            context.mathstyle, Mathstyle.TEXT, classes);

    if (center) {
        result.setTop((1 - context.mathstyle.sizeMultiplier) *
            context.mathstyle.metrics.axisHeight);
    }
    result.setStyle('color', context.color);
    if (typeof context.opacity === 'number') span.setStyle('opacity', context.opacity);

    return result;
}

/**
 * Make an inner span with the given offset and in the given font. This is used
 * in `makeStackedDelim` to make the stacking pieces for the delimiter.
 * @memberof module:delimiters
 * @private
 */
function makeInner(symbol, font) {
    let sizeClass = '';
    // Apply the correct CSS class to choose the right font.
    if (font === 'Size1-Regular') {
        sizeClass = ' delim-size1';<commit_msg>Fixed typo<commit_after>/**
 * This module deals with creating delimiters of various sizes. The TeXbook
 * discusses these routines on page 441-442, in the "Another subroutine sets box
 * x to a specified variable delimiter" paragraph.
 *
 * There are three main routines here. `makeSmallDelim` makes a delimiter in the
 * normal font, but in either text, script, or scriptscript style.
 * `makeLargeDelim` makes a delimiter in textstyle, but in one of the Size1,
 * Size2, Size3, or Size4 fonts. `makeStackedDelim` makes a delimiter out of
 * smaller pieces that are stacked on top of one another.
 *
 * The functions take a parameter `center`, which determines if the delimiter
 * should be centered around the axis.
 *
 * Then, there are three exposed functions. `sizedDelim` makes a delimiter in
 * one of the given sizes. This is used for things like `\bigl`.
 * `customSizedDelim` makes a delimiter with a given total height+depth. It is
 * called in places like `\sqrt`. `leftRightDelim` makes an appropriate
 * delimiter which surrounds an expression of a given height an depth. It is
 * used in `\left` and `\right`.
 * @summary   Handling of delimiters surrounds symbols.
 * @module delimiters
 * @private
 */

import Definitions from './definitions.js';
import Span from './span.js';
import Mathstyle from './mathstyle.js';
import FontMetrics from './fontMetrics.js';

const makeSymbol = Span.makeSymbol;
const makeStyleWrap = Span.makeStyleWrap;
const makeSpan = Span.makeSpan;
const makeVlist = Span.makeVlist;



/**
 * Makes a small delimiter. This is a delimiter that comes in the Main-Regular
 * font, but is restyled to either be in textstyle, scriptstyle, or
 * scriptscriptstyle.
 * @memberof module:delimiters
 * @private
 */
function makeSmallDelim(type, delim, style, center, context, classes) {
    const text = makeSymbol(Definitions.getFontName('math', delim),
        Definitions.getValue('math', delim));

    const span = makeStyleWrap(type, text, context.mathstyle, style, classes);

    if (center) {
        span.setTop((1 - context.mathstyle.sizeMultiplier / style.sizeMultiplier) *
            context.mathstyle.metrics.axisHeight);
    }
    span.setStyle('color', context.color);
    if (typeof context.opacity === 'number') span.setStyle('opacity', context.opacity);

    return span;
}

/**
 * Makes a large delimiter. This is a delimiter that comes in the Size1, Size2,
 * Size3, or Size4 fonts. It is always rendered in textstyle.
 * @memberof module:delimiters
 * @private
 */
function makeLargeDelim(type, delim, size, center, context, classes) {
    const inner = makeSymbol('Size' + size + '-Regular',
        Definitions.getValue('math', delim));

    const result = makeStyleWrap( type,
            makeSpan(inner, 'delimsizing size' + size),
            context.mathstyle, Mathstyle.TEXT, classes);

    if (center) {
        result.setTop((1 - context.mathstyle.sizeMultiplier) *
            context.mathstyle.metrics.axisHeight);
    }
    result.setStyle('color', context.color);
    if (typeof context.opacity === 'number') result.setStyle('opacity', context.opacity);

    return result;
}

/**
 * Make an inner span with the given offset and in the given font. This is used
 * in `makeStackedDelim` to make the stacking pieces for the delimiter.
 * @memberof module:delimiters
 * @private
 */
function makeInner(symbol, font) {
    let sizeClass = '';
    // Apply the correct CSS class to choose the right font.
    if (font === 'Size1-Regular') {
        sizeClass = ' delim-size1';
{'fraction_non_alphanumeric': 0.10346289752650177, 'fraction_numerical': 0.005088339222614841, 'mean_word_length': 3.673712021136063, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6502501', 'n_tokens_mistral': 2047, 'n_tokens_neox': 1986, 'n_words': 762}