diff --git a/calculussolver b/calculussolver index 761308d..84122ae 160000 --- a/calculussolver +++ b/calculussolver @@ -1 +1 @@ -Subproject commit 761308da06f829f67058971ab48c526a1cbb7190 +Subproject commit 84122aeea75cf30d378be20eab0caac6ab821b2f diff --git a/frontend b/frontend index 191e8cf..b905e85 160000 --- a/frontend +++ b/frontend @@ -1 +1 @@ -Subproject commit 191e8cf7e0c7bb848344555180e971a832c967c3 +Subproject commit b905e850ebb58927669a58dad14b566d4e2151e9 diff --git a/node_modules/.bin/katex b/node_modules/.bin/katex new file mode 100644 index 0000000..081bce5 --- /dev/null +++ b/node_modules/.bin/katex @@ -0,0 +1,16 @@ +#!/bin/sh +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") + +case `uname` in + *CYGWIN*|*MINGW*|*MSYS*) + if command -v cygpath > /dev/null 2>&1; then + basedir=`cygpath -w "$basedir"` + fi + ;; +esac + +if [ -x "$basedir/node" ]; then + exec "$basedir/node" "$basedir/../katex/cli.js" "$@" +else + exec node "$basedir/../katex/cli.js" "$@" +fi diff --git a/node_modules/.bin/katex.cmd b/node_modules/.bin/katex.cmd new file mode 100644 index 0000000..86d85c5 --- /dev/null +++ b/node_modules/.bin/katex.cmd @@ -0,0 +1,17 @@ +@ECHO off +GOTO start +:find_dp0 +SET dp0=%~dp0 +EXIT /b +:start +SETLOCAL +CALL :find_dp0 + +IF EXIST "%dp0%\node.exe" ( + SET "_prog=%dp0%\node.exe" +) ELSE ( + SET "_prog=node" + SET PATHEXT=%PATHEXT:;.JS;=;% +) + +endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\katex\cli.js" %* diff --git a/node_modules/.bin/katex.ps1 b/node_modules/.bin/katex.ps1 new file mode 100644 index 0000000..cabbb02 --- /dev/null +++ b/node_modules/.bin/katex.ps1 @@ -0,0 +1,28 @@ +#!/usr/bin/env pwsh +$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent + +$exe="" +if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) { + # Fix case when both the Windows and Linux builds of Node + # are installed in the same directory + $exe=".exe" +} +$ret=0 +if (Test-Path "$basedir/node$exe") { + # Support pipeline input + if ($MyInvocation.ExpectingInput) { + $input | & "$basedir/node$exe" "$basedir/../katex/cli.js" $args + } else { + & "$basedir/node$exe" "$basedir/../katex/cli.js" $args + } + $ret=$LASTEXITCODE +} else { + # Support pipeline input + if ($MyInvocation.ExpectingInput) { + $input | & "node$exe" "$basedir/../katex/cli.js" $args + } else { + & "node$exe" "$basedir/../katex/cli.js" $args + } + $ret=$LASTEXITCODE +} +exit $ret diff --git a/node_modules/.bin/loose-envify b/node_modules/.bin/loose-envify new file mode 100644 index 0000000..076f91b --- /dev/null +++ b/node_modules/.bin/loose-envify @@ -0,0 +1,16 @@ +#!/bin/sh +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") + +case `uname` in + *CYGWIN*|*MINGW*|*MSYS*) + if command -v cygpath > /dev/null 2>&1; then + basedir=`cygpath -w "$basedir"` + fi + ;; +esac + +if [ -x "$basedir/node" ]; then + exec "$basedir/node" "$basedir/../loose-envify/cli.js" "$@" +else + exec node "$basedir/../loose-envify/cli.js" "$@" +fi diff --git a/node_modules/.bin/loose-envify.cmd b/node_modules/.bin/loose-envify.cmd new file mode 100644 index 0000000..599576f --- /dev/null +++ b/node_modules/.bin/loose-envify.cmd @@ -0,0 +1,17 @@ +@ECHO off +GOTO start +:find_dp0 +SET dp0=%~dp0 +EXIT /b +:start +SETLOCAL +CALL :find_dp0 + +IF EXIST "%dp0%\node.exe" ( + SET "_prog=%dp0%\node.exe" +) ELSE ( + SET "_prog=node" + SET PATHEXT=%PATHEXT:;.JS;=;% +) + +endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\loose-envify\cli.js" %* diff --git a/node_modules/.bin/loose-envify.ps1 b/node_modules/.bin/loose-envify.ps1 new file mode 100644 index 0000000..eb866fc --- /dev/null +++ b/node_modules/.bin/loose-envify.ps1 @@ -0,0 +1,28 @@ +#!/usr/bin/env pwsh +$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent + +$exe="" +if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) { + # Fix case when both the Windows and Linux builds of Node + # are installed in the same directory + $exe=".exe" +} +$ret=0 +if (Test-Path "$basedir/node$exe") { + # Support pipeline input + if ($MyInvocation.ExpectingInput) { + $input | & "$basedir/node$exe" "$basedir/../loose-envify/cli.js" $args + } else { + & "$basedir/node$exe" "$basedir/../loose-envify/cli.js" $args + } + $ret=$LASTEXITCODE +} else { + # Support pipeline input + if ($MyInvocation.ExpectingInput) { + $input | & "node$exe" "$basedir/../loose-envify/cli.js" $args + } else { + & "node$exe" "$basedir/../loose-envify/cli.js" $args + } + $ret=$LASTEXITCODE +} +exit $ret diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json new file mode 100644 index 0000000..a146c28 --- /dev/null +++ b/node_modules/.package-lock.json @@ -0,0 +1,120 @@ +{ + "name": "CalculusRuntime", + "lockfileVersion": 3, + "requires": true, + "packages": { + "node_modules/commander": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-8.3.0.tgz", + "integrity": "sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww==", + "license": "MIT", + "engines": { + "node": ">= 12" + } + }, + "node_modules/js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "license": "MIT", + "peer": true + }, + "node_modules/katex": { + "version": "0.17.0", + "resolved": "https://registry.npmjs.org/katex/-/katex-0.17.0.tgz", + "integrity": "sha512-Vdw0ATsQ9V+LuegM/BTwQqV/6cTl5lbGcIrU+BCgLxyf6bo38ybOr372tuSIxir3CN720flu1meYR6XzNMwQnw==", + "funding": [ + "https://opencollective.com/katex", + "https://github.com/sponsors/katex" + ], + "license": "MIT", + "dependencies": { + "commander": "^8.3.0" + }, + "bin": { + "katex": "cli.js" + } + }, + "node_modules/loose-envify": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", + "license": "MIT", + "peer": true, + "dependencies": { + "js-tokens": "^3.0.0 || ^4.0.0" + }, + "bin": { + "loose-envify": "cli.js" + } + }, + "node_modules/object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/prop-types": { + "version": "15.8.1", + "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz", + "integrity": "sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==", + "license": "MIT", + "peer": true, + "dependencies": { + "loose-envify": "^1.4.0", + "object-assign": "^4.1.1", + "react-is": "^16.13.1" + } + }, + "node_modules/react": { + "version": "19.2.7", + "resolved": "https://registry.npmjs.org/react/-/react-19.2.7.tgz", + "integrity": "sha512-HNe9WslTbXmFK8o8cmwgAeJFSBvt1bPdHCVKtaaV+WlAN36mpT4hcRpwbf3fY56ar2oIXzsBpOAiIRHAdY0OlQ==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/react-is": { + "version": "16.13.1", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", + "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==", + "license": "MIT", + "peer": true + }, + "node_modules/react-katex": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/react-katex/-/react-katex-3.1.0.tgz", + "integrity": "sha512-At9uLOkC75gwn2N+ZXc5HD8TlATsB+3Hkp9OGs6uA8tM3dwZ3Wljn74Bk3JyHFPgSnesY/EMrIAB1WJwqZqejA==", + "license": "MIT", + "dependencies": { + "katex": "^0.16.0" + }, + "peerDependencies": { + "prop-types": "^15.8.1", + "react": ">=15.3.2 <20" + } + }, + "node_modules/react-katex/node_modules/katex": { + "version": "0.16.47", + "resolved": "https://registry.npmjs.org/katex/-/katex-0.16.47.tgz", + "integrity": "sha512-Eeo8Ys1doU1z+x8AZsPpQu+p/QcZBI5PeOo7QGQdy2x2m0MU/hYagBbGOmXwr5KVbEfVuWv9LpnQWeehogurjg==", + "funding": [ + "https://opencollective.com/katex", + "https://github.com/sponsors/katex" + ], + "license": "MIT", + "dependencies": { + "commander": "^8.3.0" + }, + "bin": { + "katex": "cli.js" + } + } + } +} diff --git a/node_modules/commander/LICENSE b/node_modules/commander/LICENSE new file mode 100644 index 0000000..10f997a --- /dev/null +++ b/node_modules/commander/LICENSE @@ -0,0 +1,22 @@ +(The MIT License) + +Copyright (c) 2011 TJ Holowaychuk + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/commander/Readme.md b/node_modules/commander/Readme.md new file mode 100644 index 0000000..9a2ab95 --- /dev/null +++ b/node_modules/commander/Readme.md @@ -0,0 +1,1015 @@ +# Commander.js + +[![Build Status](https://github.com/tj/commander.js/workflows/build/badge.svg)](https://github.com/tj/commander.js/actions?query=workflow%3A%22build%22) +[![NPM Version](http://img.shields.io/npm/v/commander.svg?style=flat)](https://www.npmjs.org/package/commander) +[![NPM Downloads](https://img.shields.io/npm/dm/commander.svg?style=flat)](https://npmcharts.com/compare/commander?minimal=true) +[![Install Size](https://packagephobia.now.sh/badge?p=commander)](https://packagephobia.now.sh/result?p=commander) + +The complete solution for [node.js](http://nodejs.org) command-line interfaces. + +Read this in other languages: English | [简体中文](./Readme_zh-CN.md) + +- [Commander.js](#commanderjs) + - [Installation](#installation) + - [Declaring _program_ variable](#declaring-program-variable) + - [Options](#options) + - [Common option types, boolean and value](#common-option-types-boolean-and-value) + - [Default option value](#default-option-value) + - [Other option types, negatable boolean and boolean|value](#other-option-types-negatable-boolean-and-booleanvalue) + - [Required option](#required-option) + - [Variadic option](#variadic-option) + - [Version option](#version-option) + - [More configuration](#more-configuration) + - [Custom option processing](#custom-option-processing) + - [Commands](#commands) + - [Command-arguments](#command-arguments) + - [More configuration](#more-configuration-1) + - [Custom argument processing](#custom-argument-processing) + - [Action handler](#action-handler) + - [Stand-alone executable (sub)commands](#stand-alone-executable-subcommands) + - [Life cycle hooks](#life-cycle-hooks) + - [Automated help](#automated-help) + - [Custom help](#custom-help) + - [Display help after errors](#display-help-after-errors) + - [Display help from code](#display-help-from-code) + - [.usage and .name](#usage-and-name) + - [.helpOption(flags, description)](#helpoptionflags-description) + - [.addHelpCommand()](#addhelpcommand) + - [More configuration](#more-configuration-2) + - [Custom event listeners](#custom-event-listeners) + - [Bits and pieces](#bits-and-pieces) + - [.parse() and .parseAsync()](#parse-and-parseasync) + - [Parsing Configuration](#parsing-configuration) + - [Legacy options as properties](#legacy-options-as-properties) + - [TypeScript](#typescript) + - [createCommand()](#createcommand) + - [Node options such as `--harmony`](#node-options-such-as---harmony) + - [Debugging stand-alone executable subcommands](#debugging-stand-alone-executable-subcommands) + - [Override exit and output handling](#override-exit-and-output-handling) + - [Additional documentation](#additional-documentation) + - [Examples](#examples) + - [Support](#support) + - [Commander for enterprise](#commander-for-enterprise) + +For information about terms used in this document see: [terminology](./docs/terminology.md) + +## Installation + +```bash +npm install commander +``` + +## Declaring _program_ variable + +Commander exports a global object which is convenient for quick programs. +This is used in the examples in this README for brevity. + +```js +const { program } = require('commander'); +program.version('0.0.1'); +``` + +For larger programs which may use commander in multiple ways, including unit testing, it is better to create a local Command object to use. + +```js +const { Command } = require('commander'); +const program = new Command(); +program.version('0.0.1'); +``` + +For named imports in ECMAScript modules, import from `commander/esm.mjs`. + +```js +// index.mjs +import { Command } from 'commander/esm.mjs'; +const program = new Command(); +``` + +And in TypeScript: + +```ts +// index.ts +import { Command } from 'commander'; +const program = new Command(); +``` + +## Options + +Options are defined with the `.option()` method, also serving as documentation for the options. Each option can have a short flag (single character) and a long name, separated by a comma or space or vertical bar ('|'). + +The parsed options can be accessed by calling `.opts()` on a `Command` object, and are passed to the action handler. +(You can also use `.getOptionValue()` and `.setOptionValue()` to work with a single option value, +and `.getOptionValueSource()` and `.setOptionValueWithSource()` when it matters where the option value came from.) + +Multi-word options such as "--template-engine" are camel-cased, becoming `program.opts().templateEngine` etc. + +Multiple short flags may optionally be combined in a single argument following the dash: boolean flags, followed by a single option taking a value (possibly followed by the value). +For example `-a -b -p 80` may be written as `-ab -p80` or even `-abp80`. + +You can use `--` to indicate the end of the options, and any remaining arguments will be used without being interpreted. + +By default options on the command line are not positional, and can be specified before or after other arguments. + +### Common option types, boolean and value + +The two most used option types are a boolean option, and an option which takes its value +from the following argument (declared with angle brackets like `--expect `). Both are `undefined` unless specified on command line. + +Example file: [options-common.js](./examples/options-common.js) + +```js +program + .option('-d, --debug', 'output extra debugging') + .option('-s, --small', 'small pizza size') + .option('-p, --pizza-type ', 'flavour of pizza'); + +program.parse(process.argv); + +const options = program.opts(); +if (options.debug) console.log(options); +console.log('pizza details:'); +if (options.small) console.log('- small pizza size'); +if (options.pizzaType) console.log(`- ${options.pizzaType}`); +``` + +```bash +$ pizza-options -p +error: option '-p, --pizza-type ' argument missing +$ pizza-options -d -s -p vegetarian +{ debug: true, small: true, pizzaType: 'vegetarian' } +pizza details: +- small pizza size +- vegetarian +$ pizza-options --pizza-type=cheese +pizza details: +- cheese +``` + +`program.parse(arguments)` processes the arguments, leaving any args not consumed by the program options in the `program.args` array. The parameter is optional and defaults to `process.argv`. + +### Default option value + +You can specify a default value for an option which takes a value. + +Example file: [options-defaults.js](./examples/options-defaults.js) + +```js +program + .option('-c, --cheese ', 'add the specified type of cheese', 'blue'); + +program.parse(); + +console.log(`cheese: ${program.opts().cheese}`); +``` + +```bash +$ pizza-options +cheese: blue +$ pizza-options --cheese stilton +cheese: stilton +``` + +### Other option types, negatable boolean and boolean|value + +You can define a boolean option long name with a leading `no-` to set the option value to false when used. +Defined alone this also makes the option true by default. + +If you define `--foo` first, adding `--no-foo` does not change the default value from what it would +otherwise be. You can specify a default boolean value for a boolean option and it can be overridden on command line. + +Example file: [options-negatable.js](./examples/options-negatable.js) + +```js +program + .option('--no-sauce', 'Remove sauce') + .option('--cheese ', 'cheese flavour', 'mozzarella') + .option('--no-cheese', 'plain with no cheese') + .parse(); + +const options = program.opts(); +const sauceStr = options.sauce ? 'sauce' : 'no sauce'; +const cheeseStr = (options.cheese === false) ? 'no cheese' : `${options.cheese} cheese`; +console.log(`You ordered a pizza with ${sauceStr} and ${cheeseStr}`); +``` + +```bash +$ pizza-options +You ordered a pizza with sauce and mozzarella cheese +$ pizza-options --sauce +error: unknown option '--sauce' +$ pizza-options --cheese=blue +You ordered a pizza with sauce and blue cheese +$ pizza-options --no-sauce --no-cheese +You ordered a pizza with no sauce and no cheese +``` + +You can specify an option which may be used as a boolean option but may optionally take an option-argument +(declared with square brackets like `--optional [value]`). + +Example file: [options-boolean-or-value.js](./examples/options-boolean-or-value.js) + +```js +program + .option('-c, --cheese [type]', 'Add cheese with optional type'); + +program.parse(process.argv); + +const options = program.opts(); +if (options.cheese === undefined) console.log('no cheese'); +else if (options.cheese === true) console.log('add cheese'); +else console.log(`add cheese type ${options.cheese}`); +``` + +```bash +$ pizza-options +no cheese +$ pizza-options --cheese +add cheese +$ pizza-options --cheese mozzarella +add cheese type mozzarella +``` + +For information about possible ambiguous cases, see [options taking varying arguments](./docs/options-taking-varying-arguments.md). + +### Required option + +You may specify a required (mandatory) option using `.requiredOption`. The option must have a value after parsing, usually specified on the command line, or perhaps from a default value (say from environment). The method is otherwise the same as `.option` in format, taking flags and description, and optional default value or custom processing. + +Example file: [options-required.js](./examples/options-required.js) + +```js +program + .requiredOption('-c, --cheese ', 'pizza must have cheese'); + +program.parse(); +``` + +```bash +$ pizza +error: required option '-c, --cheese ' not specified +``` + +### Variadic option + +You may make an option variadic by appending `...` to the value placeholder when declaring the option. On the command line you +can then specify multiple option-arguments, and the parsed option value will be an array. The extra arguments +are read until the first argument starting with a dash. The special argument `--` stops option processing entirely. If a value +is specified in the same argument as the option then no further values are read. + +Example file: [options-variadic.js](./examples/options-variadic.js) + +```js +program + .option('-n, --number ', 'specify numbers') + .option('-l, --letter [letters...]', 'specify letters'); + +program.parse(); + +console.log('Options: ', program.opts()); +console.log('Remaining arguments: ', program.args); +``` + +```bash +$ collect -n 1 2 3 --letter a b c +Options: { number: [ '1', '2', '3' ], letter: [ 'a', 'b', 'c' ] } +Remaining arguments: [] +$ collect --letter=A -n80 operand +Options: { number: [ '80' ], letter: [ 'A' ] } +Remaining arguments: [ 'operand' ] +$ collect --letter -n 1 -n 2 3 -- operand +Options: { number: [ '1', '2', '3' ], letter: true } +Remaining arguments: [ 'operand' ] +``` + +For information about possible ambiguous cases, see [options taking varying arguments](./docs/options-taking-varying-arguments.md). + +### Version option + +The optional `version` method adds handling for displaying the command version. The default option flags are `-V` and `--version`, and when present the command prints the version number and exits. + +```js +program.version('0.0.1'); +``` + +```bash +$ ./examples/pizza -V +0.0.1 +``` + +You may change the flags and description by passing additional parameters to the `version` method, using +the same syntax for flags as the `option` method. + +```js +program.version('0.0.1', '-v, --vers', 'output the current version'); +``` + +### More configuration + +You can add most options using the `.option()` method, but there are some additional features available +by constructing an `Option` explicitly for less common cases. + +Example files: [options-extra.js](./examples/options-extra.js), [options-env.js](./examples/options-env.js) + +```js +program + .addOption(new Option('-s, --secret').hideHelp()) + .addOption(new Option('-t, --timeout ', 'timeout in seconds').default(60, 'one minute')) + .addOption(new Option('-d, --drink ', 'drink size').choices(['small', 'medium', 'large'])) + .addOption(new Option('-p, --port ', 'port number').env('PORT')); +``` + +```bash +$ extra --help +Usage: help [options] + +Options: + -t, --timeout timeout in seconds (default: one minute) + -d, --drink drink cup size (choices: "small", "medium", "large") + -p, --port port number (env: PORT) + -h, --help display help for command + +$ extra --drink huge +error: option '-d, --drink ' argument 'huge' is invalid. Allowed choices are small, medium, large. + +$ PORT=80 extra +Options: { timeout: 60, port: '80' } +``` + +### Custom option processing + +You may specify a function to do custom processing of option-arguments. The callback function receives two parameters, +the user specified option-argument and the previous value for the option. It returns the new value for the option. + +This allows you to coerce the option-argument to the desired type, or accumulate values, or do entirely custom processing. + +You can optionally specify the default/starting value for the option after the function parameter. + +Example file: [options-custom-processing.js](./examples/options-custom-processing.js) + +```js +function myParseInt(value, dummyPrevious) { + // parseInt takes a string and a radix + const parsedValue = parseInt(value, 10); + if (isNaN(parsedValue)) { + throw new commander.InvalidArgumentError('Not a number.'); + } + return parsedValue; +} + +function increaseVerbosity(dummyValue, previous) { + return previous + 1; +} + +function collect(value, previous) { + return previous.concat([value]); +} + +function commaSeparatedList(value, dummyPrevious) { + return value.split(','); +} + +program + .option('-f, --float ', 'float argument', parseFloat) + .option('-i, --integer ', 'integer argument', myParseInt) + .option('-v, --verbose', 'verbosity that can be increased', increaseVerbosity, 0) + .option('-c, --collect ', 'repeatable value', collect, []) + .option('-l, --list ', 'comma separated list', commaSeparatedList) +; + +program.parse(); + +const options = program.opts(); +if (options.float !== undefined) console.log(`float: ${options.float}`); +if (options.integer !== undefined) console.log(`integer: ${options.integer}`); +if (options.verbose > 0) console.log(`verbosity: ${options.verbose}`); +if (options.collect.length > 0) console.log(options.collect); +if (options.list !== undefined) console.log(options.list); +``` + +```bash +$ custom -f 1e2 +float: 100 +$ custom --integer 2 +integer: 2 +$ custom -v -v -v +verbose: 3 +$ custom -c a -c b -c c +[ 'a', 'b', 'c' ] +$ custom --list x,y,z +[ 'x', 'y', 'z' ] +``` + +## Commands + +You can specify (sub)commands using `.command()` or `.addCommand()`. There are two ways these can be implemented: using an action handler attached to the command, or as a stand-alone executable file (described in more detail later). The subcommands may be nested ([example](./examples/nestedCommands.js)). + +In the first parameter to `.command()` you specify the command name. You may append the command-arguments after the command name, or specify them separately using `.argument()`. The arguments may be `` or `[optional]`, and the last argument may also be `variadic...`. + +You can use `.addCommand()` to add an already configured subcommand to the program. + +For example: + +```js +// Command implemented using action handler (description is supplied separately to `.command`) +// Returns new command for configuring. +program + .command('clone [destination]') + .description('clone a repository into a newly created directory') + .action((source, destination) => { + console.log('clone command called'); + }); + +// Command implemented using stand-alone executable file, indicated by adding description as second parameter to `.command`. +// Returns `this` for adding more commands. +program + .command('start ', 'start named service') + .command('stop [service]', 'stop named service, or all if no name supplied'); + +// Command prepared separately. +// Returns `this` for adding more commands. +program + .addCommand(build.makeBuildCommand()); +``` + +Configuration options can be passed with the call to `.command()` and `.addCommand()`. Specifying `hidden: true` will +remove the command from the generated help output. Specifying `isDefault: true` will run the subcommand if no other +subcommand is specified ([example](./examples/defaultCommand.js)). + +### Command-arguments + +For subcommands, you can specify the argument syntax in the call to `.command()` (as shown above). This +is the only method usable for subcommands implemented using a stand-alone executable, but for other subcommands +you can instead use the following method. + +To configure a command, you can use `.argument()` to specify each expected command-argument. +You supply the argument name and an optional description. The argument may be `` or `[optional]`. +You can specify a default value for an optional command-argument. + +Example file: [argument.js](./examples/argument.js) + +```js +program + .version('0.1.0') + .argument('', 'user to login') + .argument('[password]', 'password for user, if required', 'no password given') + .action((username, password) => { + console.log('username:', username); + console.log('password:', password); + }); +``` + + The last argument of a command can be variadic, and only the last argument. To make an argument variadic you + append `...` to the argument name. A variadic argument is passed to the action handler as an array. For example: + +```js +program + .version('0.1.0') + .command('rmdir') + .argument('') + .action(function (dirs) { + dirs.forEach((dir) => { + console.log('rmdir %s', dir); + }); + }); +``` + +There is a convenience method to add multiple arguments at once, but without descriptions: + +```js +program + .arguments(' '); +``` + +#### More configuration + +There are some additional features available by constructing an `Argument` explicitly for less common cases. + +Example file: [arguments-extra.js](./examples/arguments-extra.js) + +```js +program + .addArgument(new commander.Argument('', 'drink cup size').choices(['small', 'medium', 'large'])) + .addArgument(new commander.Argument('[timeout]', 'timeout in seconds').default(60, 'one minute')) +``` + +#### Custom argument processing + +You may specify a function to do custom processing of command-arguments (like for option-arguments). +The callback function receives two parameters, the user specified command-argument and the previous value for the argument. +It returns the new value for the argument. + +The processed argument values are passed to the action handler, and saved as `.processedArgs`. + +You can optionally specify the default/starting value for the argument after the function parameter. + +Example file: [arguments-custom-processing.js](./examples/arguments-custom-processing.js) + +```js +program + .command('add') + .argument('', 'integer argument', myParseInt) + .argument('[second]', 'integer argument', myParseInt, 1000) + .action((first, second) => { + console.log(`${first} + ${second} = ${first + second}`); + }) +; +``` + +### Action handler + +The action handler gets passed a parameter for each command-argument you declared, and two additional parameters +which are the parsed options and the command object itself. + +Example file: [thank.js](./examples/thank.js) + +```js +program + .argument('') + .option('-t, --title ', 'title to use before name') + .option('-d, --debug', 'display some debugging') + .action((name, options, command) => { + if (options.debug) { + console.error('Called %s with options %o', command.name(), options); + } + const title = options.title ? `${options.title} ` : ''; + console.log(`Thank-you ${title}${name}`); + }); +``` + +You may supply an `async` action handler, in which case you call `.parseAsync` rather than `.parse`. + +```js +async function run() { /* code goes here */ } + +async function main() { + program + .command('run') + .action(run); + await program.parseAsync(process.argv); +} +``` + +A command's options and arguments on the command line are validated when the command is used. Any unknown options or missing arguments will be reported as an error. You can suppress the unknown option checks with `.allowUnknownOption()`. By default it is not an error to +pass more arguments than declared, but you can make this an error with `.allowExcessArguments(false)`. + +### Stand-alone executable (sub)commands + +When `.command()` is invoked with a description argument, this tells Commander that you're going to use stand-alone executables for subcommands. +Commander will search the executables in the directory of the entry script (like `./examples/pm`) with the name `program-subcommand`, like `pm-install`, `pm-search`. +You can specify a custom name with the `executableFile` configuration option. + +You handle the options for an executable (sub)command in the executable, and don't declare them at the top-level. + +Example file: [pm](./examples/pm) + +```js +program + .version('0.1.0') + .command('install [name]', 'install one or more packages') + .command('search [query]', 'search with optional query') + .command('update', 'update installed packages', { executableFile: 'myUpdateSubCommand' }) + .command('list', 'list packages installed', { isDefault: true }); + +program.parse(process.argv); +``` + +If the program is designed to be installed globally, make sure the executables have proper modes, like `755`. + +### Life cycle hooks + +You can add callback hooks to a command for life cycle events. + +Example file: [hook.js](./examples/hook.js) + +```js +program + .option('-t, --trace', 'display trace statements for commands') + .hook('preAction', (thisCommand, actionCommand) => { + if (thisCommand.opts().trace) { + console.log(`About to call action handler for subcommand: ${actionCommand.name()}`); + console.log('arguments: %O', actionCommand.args); + console.log('options: %o', actionCommand.opts()); + } + }); +``` + +The callback hook can be `async`, in which case you call `.parseAsync` rather than `.parse`. You can add multiple hooks per event. + +The supported events are: + +- `preAction`: called before action handler for this command and its subcommands +- `postAction`: called after action handler for this command and its subcommands + +The hook is passed the command it was added to, and the command running the action handler. + +## Automated help + +The help information is auto-generated based on the information commander already knows about your program. The default +help option is `-h,--help`. + +Example file: [pizza](./examples/pizza) + +```bash +$ node ./examples/pizza --help +Usage: pizza [options] + +An application for pizza ordering + +Options: + -p, --peppers Add peppers + -c, --cheese Add the specified type of cheese (default: "marble") + -C, --no-cheese You do not want any cheese + -h, --help display help for command +``` + +A `help` command is added by default if your command has subcommands. It can be used alone, or with a subcommand name to show +further help for the subcommand. These are effectively the same if the `shell` program has implicit help: + +```bash +shell help +shell --help + +shell help spawn +shell spawn --help +``` + +### Custom help + +You can add extra text to be displayed along with the built-in help. + +Example file: [custom-help](./examples/custom-help) + +```js +program + .option('-f, --foo', 'enable some foo'); + +program.addHelpText('after', ` + +Example call: + $ custom-help --help`); +``` + +Yields the following help output: + +```Text +Usage: custom-help [options] + +Options: + -f, --foo enable some foo + -h, --help display help for command + +Example call: + $ custom-help --help +``` + +The positions in order displayed are: + +- `beforeAll`: add to the program for a global banner or header +- `before`: display extra information before built-in help +- `after`: display extra information after built-in help +- `afterAll`: add to the program for a global footer (epilog) + +The positions "beforeAll" and "afterAll" apply to the command and all its subcommands. + +The second parameter can be a string, or a function returning a string. The function is passed a context object for your convenience. The properties are: + +- error: a boolean for whether the help is being displayed due to a usage error +- command: the Command which is displaying the help + +### Display help after errors + +The default behaviour for usage errors is to just display a short error message. +You can change the behaviour to show the full help or a custom help message after an error. + +```js +program.showHelpAfterError(); +// or +program.showHelpAfterError('(add --help for additional information)'); +``` + +```sh +$ pizza --unknown +error: unknown option '--unknown' +(add --help for additional information) +``` + +You can also show suggestions after an error for an unknown command or option. + +```js +program.showSuggestionAfterError(); +``` + +```sh +$ pizza --hepl +error: unknown option '--hepl' +(Did you mean --help?) +``` + +### Display help from code + +`.help()`: display help information and exit immediately. You can optionally pass `{ error: true }` to display on stderr and exit with an error status. + +`.outputHelp()`: output help information without exiting. You can optionally pass `{ error: true }` to display on stderr. + +`.helpInformation()`: get the built-in command help information as a string for processing or displaying yourself. + +### .usage and .name + +These allow you to customise the usage description in the first line of the help. The name is otherwise +deduced from the (full) program arguments. Given: + +```js +program + .name("my-command") + .usage("[global options] command") +``` + +The help will start with: + +```Text +Usage: my-command [global options] command +``` + +### .helpOption(flags, description) + +By default every command has a help option. Override the default help flags and description. Pass false to disable the built-in help option. + +```js +program + .helpOption('-e, --HELP', 'read more information'); +``` + +### .addHelpCommand() + +A help command is added by default if your command has subcommands. You can explicitly turn on or off the implicit help command with `.addHelpCommand()` and `.addHelpCommand(false)`. + +You can both turn on and customise the help command by supplying the name and description: + +```js +program.addHelpCommand('assist [command]', 'show assistance'); +``` + +### More configuration + +The built-in help is formatted using the Help class. +You can configure the Help behaviour by modifying data properties and methods using `.configureHelp()`, or by subclassing using `.createHelp()` if you prefer. + +The data properties are: + +- `helpWidth`: specify the wrap width, useful for unit tests +- `sortSubcommands`: sort the subcommands alphabetically +- `sortOptions`: sort the options alphabetically + +There are methods getting the visible lists of arguments, options, and subcommands. There are methods for formatting the items in the lists, with each item having a _term_ and _description_. Take a look at `.formatHelp()` to see how they are used. + +Example file: [configure-help.js](./examples/configure-help.js) + +```js +program.configureHelp({ + sortSubcommands: true, + subcommandTerm: (cmd) => cmd.name() // Just show the name, instead of short usage. +}); +``` + +## Custom event listeners + +You can execute custom actions by listening to command and option events. + +```js +program.on('option:verbose', function () { + process.env.VERBOSE = this.opts().verbose; +}); +``` + +## Bits and pieces + +### .parse() and .parseAsync() + +The first argument to `.parse` is the array of strings to parse. You may omit the parameter to implicitly use `process.argv`. + +If the arguments follow different conventions than node you can pass a `from` option in the second parameter: + +- 'node': default, `argv[0]` is the application and `argv[1]` is the script being run, with user parameters after that +- 'electron': `argv[1]` varies depending on whether the electron application is packaged +- 'user': all of the arguments from the user + +For example: + +```js +program.parse(process.argv); // Explicit, node conventions +program.parse(); // Implicit, and auto-detect electron +program.parse(['-f', 'filename'], { from: 'user' }); +``` + +### Parsing Configuration + +If the default parsing does not suit your needs, there are some behaviours to support other usage patterns. + +By default program options are recognised before and after subcommands. To only look for program options before subcommands, use `.enablePositionalOptions()`. This lets you use +an option for a different purpose in subcommands. + +Example file: [positional-options.js](./examples/positional-options.js) + +With positional options, the `-b` is a program option in the first line and a subcommand option in the second line: + +```sh +program -b subcommand +program subcommand -b +``` + +By default options are recognised before and after command-arguments. To only process options that come +before the command-arguments, use `.passThroughOptions()`. This lets you pass the arguments and following options through to another program +without needing to use `--` to end the option processing. +To use pass through options in a subcommand, the program needs to enable positional options. + +Example file: [pass-through-options.js](./examples/pass-through-options.js) + +With pass through options, the `--port=80` is a program option in the first line and passed through as a command-argument in the second line: + +```sh +program --port=80 arg +program arg --port=80 +``` + +By default the option processing shows an error for an unknown option. To have an unknown option treated as an ordinary command-argument and continue looking for options, use `.allowUnknownOption()`. This lets you mix known and unknown options. + +By default the argument processing does not display an error for more command-arguments than expected. +To display an error for excess arguments, use`.allowExcessArguments(false)`. + +### Legacy options as properties + +Before Commander 7, the option values were stored as properties on the command. +This was convenient to code but the downside was possible clashes with +existing properties of `Command`. You can revert to the old behaviour to run unmodified legacy code by using `.storeOptionsAsProperties()`. + +```js +program + .storeOptionsAsProperties() + .option('-d, --debug') + .action((commandAndOptions) => { + if (commandAndOptions.debug) { + console.error(`Called ${commandAndOptions.name()}`); + } + }); +``` + +### TypeScript + +If you use `ts-node` and stand-alone executable subcommands written as `.ts` files, you need to call your program through node to get the subcommands called correctly. e.g. + +```bash +node -r ts-node/register pm.ts +``` + +### createCommand() + +This factory function creates a new command. It is exported and may be used instead of using `new`, like: + +```js +const { createCommand } = require('commander'); +const program = createCommand(); +``` + +`createCommand` is also a method of the Command object, and creates a new command rather than a subcommand. This gets used internally +when creating subcommands using `.command()`, and you may override it to +customise the new subcommand (example file [custom-command-class.js](./examples/custom-command-class.js)). + +### Node options such as `--harmony` + +You can enable `--harmony` option in two ways: + +- Use `#! /usr/bin/env node --harmony` in the subcommands scripts. (Note Windows does not support this pattern.) +- Use the `--harmony` option when call the command, like `node --harmony examples/pm publish`. The `--harmony` option will be preserved when spawning subcommand process. + +### Debugging stand-alone executable subcommands + +An executable subcommand is launched as a separate child process. + +If you are using the node inspector for [debugging](https://nodejs.org/en/docs/guides/debugging-getting-started/) executable subcommands using `node --inspect` et al, +the inspector port is incremented by 1 for the spawned subcommand. + +If you are using VSCode to debug executable subcommands you need to set the `"autoAttachChildProcesses": true` flag in your launch.json configuration. + +### Override exit and output handling + +By default Commander calls `process.exit` when it detects errors, or after displaying the help or version. You can override +this behaviour and optionally supply a callback. The default override throws a `CommanderError`. + +The override callback is passed a `CommanderError` with properties `exitCode` number, `code` string, and `message`. The default override behaviour is to throw the error, except for async handling of executable subcommand completion which carries on. The normal display of error messages or version or help +is not affected by the override which is called after the display. + +```js +program.exitOverride(); + +try { + program.parse(process.argv); +} catch (err) { + // custom processing... +} +``` + +By default Commander is configured for a command-line application and writes to stdout and stderr. +You can modify this behaviour for custom applications. In addition, you can modify the display of error messages. + +Example file: [configure-output.js](./examples/configure-output.js) + +```js +function errorColor(str) { + // Add ANSI escape codes to display text in red. + return `\x1b[31m${str}\x1b[0m`; +} + +program + .configureOutput({ + // Visibly override write routines as example! + writeOut: (str) => process.stdout.write(`[OUT] ${str}`), + writeErr: (str) => process.stdout.write(`[ERR] ${str}`), + // Highlight errors in color. + outputError: (str, write) => write(errorColor(str)) + }); +``` + +### Additional documentation + +There is more information available about: + +- [deprecated](./docs/deprecated.md) features still supported for backwards compatibility +- [options taking varying arguments](./docs/options-taking-varying-arguments.md) + +## Examples + +In a single command program, you might not need an action handler. + +Example file: [pizza](./examples/pizza) + +```js +const { program } = require('commander'); + +program + .description('An application for pizza ordering') + .option('-p, --peppers', 'Add peppers') + .option('-c, --cheese ', 'Add the specified type of cheese', 'marble') + .option('-C, --no-cheese', 'You do not want any cheese'); + +program.parse(); + +const options = program.opts(); +console.log('you ordered a pizza with:'); +if (options.peppers) console.log(' - peppers'); +const cheese = !options.cheese ? 'no' : options.cheese; +console.log(' - %s cheese', cheese); +``` + +In a multi-command program, you will have action handlers for each command (or stand-alone executables for the commands). + +Example file: [deploy](./examples/deploy) + +```js +const { Command } = require('commander'); +const program = new Command(); + +program + .version('0.0.1') + .option('-c, --config ', 'set config path', './deploy.conf'); + +program + .command('setup [env]') + .description('run setup commands for all envs') + .option('-s, --setup_mode ', 'Which setup mode to use', 'normal') + .action((env, options) => { + env = env || 'all'; + console.log('read config from %s', program.opts().config); + console.log('setup for %s env(s) with %s mode', env, options.setup_mode); + }); + +program + .command('exec + + + + + ... + +``` + +You can also [download KaTeX](https://github.com/KaTeX/KaTeX/releases) and host it yourself. + +For details on how to configure auto-render extension, refer to [the documentation](https://katex.org/docs/autorender.html). + +### API + +Call `katex.render` to render a TeX expression directly into a DOM element. +For example: + +```js +katex.render("c = \\pm\\sqrt{a^2 + b^2}", element, { + throwOnError: false +}); +``` + +Call `katex.renderToString` to generate an HTML string of the rendered math, +e.g., for server-side rendering. For example: + +```js +var html = katex.renderToString("c = \\pm\\sqrt{a^2 + b^2}", { + throwOnError: false +}); +// '...' +``` + +Make sure to include the CSS and font files in both cases. +If you are doing all rendering on the server, there is no need to include the +JavaScript on the client. + +The examples above use the `throwOnError: false` option, which renders invalid +inputs as the TeX source code in red (by default), with the error message as +hover text. For other available options, see the +[API documentation](https://katex.org/docs/api.html), +[options documentation](https://katex.org/docs/options.html), and +[handling errors documentation](https://katex.org/docs/error.html). + +## Demo and Documentation + +Learn more about using KaTeX [on the website](https://katex.org)! + +## Contributors + +### Code Contributors + +This project exists thanks to all the people who contribute code. If you'd like to help, see [our guide to contributing code](CONTRIBUTING.md). +Code contributors + +### Financial Contributors + +Become a financial contributor and help us sustain our community. + +#### Individuals + +Contribute on Open Collective + +#### Organizations + +Support this project with your organization. Your logo will show up here with a link to your website. + +Organization 1 +Organization 2 +Organization 3 +Organization 4 +Organization 5 + +## License + +KaTeX is licensed under the [MIT License](https://opensource.org/licenses/MIT). diff --git a/node_modules/katex/cli.js b/node_modules/katex/cli.js new file mode 100644 index 0000000..b9e7f95 --- /dev/null +++ b/node_modules/katex/cli.js @@ -0,0 +1,114 @@ +#!/usr/bin/env node +// Simple CLI for KaTeX. +// Reads TeX from stdin, outputs HTML to stdout. +// To run this from the repository, you must first build KaTeX by running +// `yarn` and `yarn build`. + +/* eslint no-console:0 */ + +let katex; +try { + katex = require("./"); +} catch (e) { + console.error( + "KaTeX could not import, likely because dist/katex.js is missing."); + console.error("Please run 'yarn' and 'yarn build' before running"); + console.error("cli.js from the KaTeX repository."); + console.error(); + throw e; +} +const {version} = require("./package.json"); +const fs = require("fs"); + +const {program} = require("commander"); +program.version(version); + +for (const prop in katex.SETTINGS_SCHEMA) { + if (katex.SETTINGS_SCHEMA.hasOwnProperty(prop)) { + const opt = katex.SETTINGS_SCHEMA[prop]; + if (opt.cli !== false) { + program.option(opt.cli || "--" + prop, opt.cliDescription || + opt.description, opt.cliProcessor, opt.cliDefault); + } + } +} +program.option("-f, --macro-file ", + "Read macro definitions, one per line, from the given file.") + .option("-i, --input ", "Read LaTeX input from the given file.") + .option("-o, --output ", "Write html output to the given file."); + +let options; + +function readMacros() { + if (options.macroFile) { + fs.readFile(options.macroFile, "utf-8", function(err, data) { + if (err) {throw err;} + splitMacros(data.toString().split('\n')); + }); + } else { + splitMacros([]); + } +} + +function splitMacros(macroStrings) { + // Override macros from macro file (if any) + // with macros from command line (if any) + macroStrings = macroStrings.concat(options.macro); + + const macros = {}; + + for (const m of macroStrings) { + const i = m.search(":"); + if (i !== -1) { + macros[m.substring(0, i).trim()] = m.substring(i + 1).trim(); + } + } + + options.macros = macros; + readInput(); +} + +function readInput() { + let input = ""; + + if (options.input) { + fs.readFile(options.input, "utf-8", function(err, data) { + if (err) {throw err;} + input = data.toString(); + writeOutput(input); + }); + } else { + process.stdin.on("data", function(chunk) { + input += chunk.toString(); + }); + + process.stdin.on("end", function() { + writeOutput(input); + }); + } +} + +function writeOutput(input) { + // --format specifies the KaTeX output + const outputFile = options.output; + options.output = options.format; + + const output = katex.renderToString(input, options) + "\n"; + + if (outputFile) { + fs.writeFile(outputFile, output, function(err) { + if (err) { + return console.log(err); + } + }); + } else { + console.log(output); + } +} + +if (require.main !== module) { + module.exports = program; +} else { + options = program.parse(process.argv).opts(); + readMacros(); +} diff --git a/node_modules/katex/contrib/auto-render/README.md b/node_modules/katex/contrib/auto-render/README.md new file mode 100644 index 0000000..ea793f1 --- /dev/null +++ b/node_modules/katex/contrib/auto-render/README.md @@ -0,0 +1,8 @@ +# Auto-render extension + +This is an extension to automatically render all of the math inside of text. It +searches all of the text nodes in a given element for the given delimiters, and +renders the math in place. + +See [Auto-render extension documentation](https://katex.org/docs/autorender.html) +for more information. diff --git a/node_modules/katex/contrib/auto-render/auto-render.ts b/node_modules/katex/contrib/auto-render/auto-render.ts new file mode 100644 index 0000000..d778201 --- /dev/null +++ b/node_modules/katex/contrib/auto-render/auto-render.ts @@ -0,0 +1,164 @@ +/* eslint no-console:0 */ + +import katex from "katex"; +import splitAtDelimiters from "./splitAtDelimiters"; +import type {DelimiterSpec} from "./splitAtDelimiters"; + +interface RenderMathInElementOptions { + delimiters?: DelimiterSpec[]; + preProcess?: (math: string) => string; + ignoredTags?: string[]; + ignoredClasses?: string[]; + errorCallback?: (msg: string, err: Error) => void; + displayMode?: boolean; + macros?: Record; +} + +interface RenderMathInElementOptionsCopy { + delimiters: DelimiterSpec[]; + preProcess?: (math: string) => string; + ignoredTags: Set; + ignoredClasses: string[]; + errorCallback: (msg: string, err: Error) => void; + displayMode?: boolean; + macros?: Record; +} + +/* Note: optionsCopy is mutated by this method. If it is ever exposed in the + * API, we should copy it before mutating. + */ +const renderMathInText = function( + text: string, + optionsCopy: RenderMathInElementOptionsCopy +) { + const data = splitAtDelimiters(text, optionsCopy.delimiters); + if (data.length === 1 && data[0].type === 'text') { + // There is no formula in the text. + // Let's return null which means there is no need to replace + // the current text node with a new one. + return null; + } + + const fragment = document.createDocumentFragment(); + + for (let i = 0; i < data.length; i++) { + if (data[i].type === "text") { + fragment.appendChild(document.createTextNode(data[i].data)); + } else { + const span = document.createElement("span"); + let math = data[i].data; + // Override any display mode defined in the settings with that + // defined by the text itself + optionsCopy.displayMode = data[i].display; + try { + if (optionsCopy.preProcess) { + math = optionsCopy.preProcess(math); + } + katex.render(math, span, optionsCopy); + } catch (e) { + if (!(e instanceof katex.ParseError)) { + throw e; + } + optionsCopy.errorCallback( + "KaTeX auto-render: Failed to parse `" + data[i].data + + "` with ", + e + ); + fragment.appendChild(document.createTextNode(data[i].rawData!)); + continue; + } + fragment.appendChild(span); + } + } + + return fragment; +}; + +const renderElem = function( + elem: HTMLElement, + optionsCopy: RenderMathInElementOptionsCopy +) { + for (let i = 0; i < elem.childNodes.length; i++) { + const childNode = elem.childNodes[i]; + if (childNode.nodeType === 3) { + // Text node + // Concatenate all sibling text nodes. + // Webkit browsers split very large text nodes into smaller ones, + // so the delimiters may be split across different nodes. + let textContentConcat = childNode.textContent ?? ""; + let sibling = childNode.nextSibling; + let nSiblings = 0; + while (sibling && (sibling.nodeType === Node.TEXT_NODE)) { + textContentConcat += sibling.textContent ?? ""; + sibling = sibling.nextSibling; + nSiblings++; + } + const frag = renderMathInText(textContentConcat, optionsCopy); + if (frag) { + // Remove extra text nodes + for (let j = 0; j < nSiblings; j++) { + childNode.nextSibling!.remove(); + } + i += frag.childNodes.length - 1; + elem.replaceChild(frag, childNode); + } else { + // If the concatenated text does not contain math + // the siblings will not either + i += nSiblings; + } + } else if (childNode.nodeType === 1) { + // Element node + const className = ' ' + (childNode as HTMLElement).className + ' '; + const shouldRender = !optionsCopy.ignoredTags.has( + childNode.nodeName.toLowerCase()) && + optionsCopy.ignoredClasses.every( + (x: string) => !className.includes(' ' + x + ' ')); + + if (shouldRender) { + renderElem(childNode as HTMLElement, optionsCopy); + } + } + // Otherwise, it's something else, and ignore it. + } +}; + +const renderMathInElement = function(elem: HTMLElement, options?: RenderMathInElementOptions) { + if (!elem) { + throw new Error("No element provided to render"); + } + + const optionsCopy: Partial = {}; + + Object.assign(optionsCopy, options); + + // default options + optionsCopy.delimiters = optionsCopy.delimiters || [ + {left: "$$", right: "$$", display: true}, + {left: "\\(", right: "\\)", display: false}, + // LaTeX uses $…$, but it ruins the display of normal `$` in text: + // {left: "$", right: "$", display: false}, + // $ must come after $$ + + // Render AMS environments even if outside $$…$$ delimiters. + {left: "\\begin{equation}", right: "\\end{equation}", display: true}, + {left: "\\begin{align}", right: "\\end{align}", display: true}, + {left: "\\begin{alignat}", right: "\\end{alignat}", display: true}, + {left: "\\begin{gather}", right: "\\end{gather}", display: true}, + {left: "\\begin{CD}", right: "\\end{CD}", display: true}, + + {left: "\\[", right: "\\]", display: true}, + ]; + optionsCopy.ignoredTags = new Set(options?.ignoredTags || [ + "script", "noscript", "style", "textarea", "pre", "code", "option", + ]); + optionsCopy.ignoredClasses = optionsCopy.ignoredClasses || []; + optionsCopy.errorCallback = optionsCopy.errorCallback || console.error; + + // Enable sharing of global macros defined via `\gdef` between different + // math elements within a single call to `renderMathInElement`. + optionsCopy.macros = optionsCopy.macros || {}; + + renderElem(elem, optionsCopy as RenderMathInElementOptionsCopy); +}; + +export default renderMathInElement; diff --git a/node_modules/katex/contrib/auto-render/index.html b/node_modules/katex/contrib/auto-render/index.html new file mode 100644 index 0000000..cf5c209 --- /dev/null +++ b/node_modules/katex/contrib/auto-render/index.html @@ -0,0 +1,57 @@ + + + + + + Auto-render test + + + + + +
+ This is some text $math \frac12$ other text $\unsupported$ + + Other node \[ \text{displaymath} \frac{1}{2} \] blah $$ \int_2^3 $$ + + and some more text \(and math\) blah. And $math with a + \$ sign$. +
+        Stuff in a $pre tag$
+      
+

An AMS environment without $$…$$ delimiters.

+

\begin{equation} \begin{split} a &=b+c\\ &=e+f \end{split} \end{equation}

+
+ + + diff --git a/node_modules/katex/contrib/auto-render/splitAtDelimiters.ts b/node_modules/katex/contrib/auto-render/splitAtDelimiters.ts new file mode 100644 index 0000000..57f469b --- /dev/null +++ b/node_modules/katex/contrib/auto-render/splitAtDelimiters.ts @@ -0,0 +1,99 @@ +/* eslint no-constant-condition:0 */ + +export interface DelimiterSpec { + left: string; + right: string; + display: boolean; +} + +export interface SplitAtDelimiterData { + type: "text" | "math"; + data: string; + rawData?: string; + display?: boolean; +} + +const findEndOfMath = function(delimiter: string, text: string, startIndex: number): number { + // Adapted from + // https://github.com/Khan/perseus/blob/master/src/perseus-markdown.jsx + let index = startIndex; + let braceLevel = 0; + + const delimLength = delimiter.length; + + while (index < text.length) { + const character = text[index]; + + if (braceLevel <= 0 && + text.slice(index, index + delimLength) === delimiter) { + return index; + } else if (character === "\\") { + index++; + } else if (character === "{") { + braceLevel++; + } else if (character === "}") { + braceLevel--; + } + + index++; + } + + return -1; +}; + +const escapeRegex = function(string: string): string { + return string.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&"); +}; + +const amsRegex = /^\\begin{/; + +const splitAtDelimiters = function(text: string, delimiters: DelimiterSpec[]): SplitAtDelimiterData[] { + let index; + const data: SplitAtDelimiterData[] = []; + + const regexLeft = new RegExp( + "(" + delimiters.map((x) => escapeRegex(x.left)).join("|") + ")" + ); + + while (true) { + index = text.search(regexLeft); + if (index === -1) { + break; + } + if (index > 0) { + data.push({ + type: "text", + data: text.slice(0, index), + }); + text = text.slice(index); // now text starts with delimiter + } + // ... so this always succeeds: + const i = delimiters.findIndex((delim) => text.startsWith(delim.left)); + index = findEndOfMath(delimiters[i].right, text, delimiters[i].left.length); + if (index === -1) { + break; + } + const rawData = text.slice(0, index + delimiters[i].right.length); + const math = amsRegex.test(rawData) + ? rawData + : text.slice(delimiters[i].left.length, index); + data.push({ + type: "math", + data: math, + rawData, + display: delimiters[i].display, + }); + text = text.slice(index + delimiters[i].right.length); + } + + if (text !== "") { + data.push({ + type: "text", + data: text, + }); + } + + return data; +}; + +export default splitAtDelimiters; diff --git a/node_modules/katex/contrib/auto-render/test/auto-render-spec.ts b/node_modules/katex/contrib/auto-render/test/auto-render-spec.ts new file mode 100644 index 0000000..4d2b58b --- /dev/null +++ b/node_modules/katex/contrib/auto-render/test/auto-render-spec.ts @@ -0,0 +1,371 @@ +/** + * @jest-environment jsdom + */ +import splitAtDelimiters from "../splitAtDelimiters"; +import renderMathInElement from "../auto-render"; +import type { + DelimiterSpec, + SplitAtDelimiterData, +} from "../splitAtDelimiters"; + +beforeEach(function() { + expect.extend({ + toSplitInto: function( + actual: string, + result: SplitAtDelimiterData[], + delimiters: DelimiterSpec[], + ) { + const message = { + pass: true, + message: () => "'" + actual + "' split correctly", + }; + + const split = + splitAtDelimiters(actual, delimiters); + + if (split.length !== result.length) { + message.pass = false; + message.message = () => "Different number of splits: " + + split.length + " vs. " + result.length + " (" + + JSON.stringify(split) + " vs. " + + JSON.stringify(result) + ")"; + return message; + } + + for (let i = 0; i < split.length; i++) { + const real = split[i]; + const correct = result[i]; + + let good = true; + let diff = ""; + + if (real.type !== correct.type) { + good = false; + diff = "type"; + } else if (real.data !== correct.data) { + good = false; + diff = "data"; + } else if (real.display !== correct.display) { + good = false; + diff = "display"; + } + + if (!good) { + message.pass = false; + message.message = () => "Difference at split " + + (i + 1) + ": " + JSON.stringify(real) + + " vs. " + JSON.stringify(correct) + + " (" + diff + " differs)"; + break; + } + } + + return message; + }, + }); +}); + +describe("A delimiter splitter", function() { + it("doesn't split when there are no delimiters", function() { + expect("hello").toSplitInto( + [ + {type: "text", data: "hello"}, + ], + [ + {left: "(", right: ")", display: false}, + ]); + }); + + it("doesn't create a math node with only one left delimiter", function() { + expect("hello ( world").toSplitInto( + [ + {type: "text", data: "hello "}, + {type: "text", data: "( world"}, + ], + [ + {left: "(", right: ")", display: false}, + ]); + }); + + it("doesn't split when there's only a right delimiter", function() { + expect("hello ) world").toSplitInto( + [ + {type: "text", data: "hello ) world"}, + ], + [ + {left: "(", right: ")", display: false}, + ]); + }); + + it("splits when there are both delimiters", function() { + expect("hello ( world ) boo").toSplitInto( + [ + {type: "text", data: "hello "}, + {type: "math", data: " world ", + rawData: "( world )", display: false}, + {type: "text", data: " boo"}, + ], + [ + {left: "(", right: ")", display: false}, + ]); + }); + + it("splits on multi-character delimiters", function() { + expect("hello [[ world ]] boo").toSplitInto( + [ + {type: "text", data: "hello "}, + {type: "math", data: " world ", + rawData: "[[ world ]]", display: false}, + {type: "text", data: " boo"}, + ], + [ + {left: "[[", right: "]]", display: false}, + ]); + expect("hello \\begin{equation} world \\end{equation} boo").toSplitInto( + [ + {type: "text", data: "hello "}, + {type: "math", data: "\\begin{equation} world \\end{equation}", + rawData: "\\begin{equation} world \\end{equation}", + display: false}, + {type: "text", data: " boo"}, + ], + [ + {left: "\\begin{equation}", right: "\\end{equation}", + display: false}, + ]); + }); + + it("splits multiple times", function() { + expect("hello ( world ) boo ( more ) stuff").toSplitInto( + [ + {type: "text", data: "hello "}, + {type: "math", data: " world ", + rawData: "( world )", display: false}, + {type: "text", data: " boo "}, + {type: "math", data: " more ", + rawData: "( more )", display: false}, + {type: "text", data: " stuff"}, + ], + [ + {left: "(", right: ")", display: false}, + ]); + }); + + it("leaves the ending when there's only a left delimiter", function() { + expect("hello ( world ) boo ( left").toSplitInto( + [ + {type: "text", data: "hello "}, + {type: "math", data: " world ", + rawData: "( world )", display: false}, + {type: "text", data: " boo "}, + {type: "text", data: "( left"}, + ], + [ + {left: "(", right: ")", display: false}, + ]); + }); + + it("doesn't split when close delimiters are in {}s", function() { + expect("hello ( world { ) } ) boo").toSplitInto( + [ + {type: "text", data: "hello "}, + {type: "math", data: " world { ) } ", + rawData: "( world { ) } )", display: false}, + {type: "text", data: " boo"}, + ], + [ + {left: "(", right: ")", display: false}, + ]); + + expect("hello ( world { { } ) } ) boo").toSplitInto( + [ + {type: "text", data: "hello "}, + {type: "math", data: " world { { } ) } ", + rawData: "( world { { } ) } )", display: false}, + {type: "text", data: " boo"}, + ], + [ + {left: "(", right: ")", display: false}, + ]); + }); + + it("correctly processes sequences of $..$", function() { + expect("$hello$$world$$boo$").toSplitInto( + [ + {type: "math", data: "hello", + rawData: "$hello$", display: false}, + {type: "math", data: "world", + rawData: "$world$", display: false}, + {type: "math", data: "boo", + rawData: "$boo$", display: false}, + ], + [ + {left: "$", right: "$", display: false}, + ]); + }); + + it("doesn't split at escaped delimiters", function() { + expect("hello ( world \\) ) boo").toSplitInto( + [ + {type: "text", data: "hello "}, + {type: "math", data: " world \\) ", + rawData: "( world \\) )", display: false}, + {type: "text", data: " boo"}, + ], + [ + {left: "(", right: ")", display: false}, + ]); + + /* TODO(emily): make this work maybe? + expect("hello \\( ( world ) boo").toSplitInto( + "(", ")", + [ + {type: "text", data: "hello \\( "}, + {type: "math", data: " world ", + rawData: "( world )", display: false}, + {type: "text", data: " boo"}, + ]); + */ + }); + + it("splits when the right and left delimiters are the same", function() { + expect("hello $ world $ boo").toSplitInto( + [ + {type: "text", data: "hello "}, + {type: "math", data: " world ", + rawData: "$ world $", display: false}, + {type: "text", data: " boo"}, + ], + [ + {left: "$", right: "$", display: false}, + ]); + }); + + it("ignores \\$", function() { + expect("$x = \\$5$").toSplitInto( + [ + {type: "math", data: "x = \\$5", + rawData: "$x = \\$5$", display: false}, + ], + [ + {left: "$", right: "$", display: false}, + ]); + }); + + it("remembers which delimiters are display-mode", function() { + const startData = "hello ( world ) boo"; + + expect(splitAtDelimiters(startData, + [{left:"(", right:")", display:true}])).toEqual( + [ + {type: "text", data: "hello "}, + {type: "math", data: " world ", + rawData: "( world )", display: true}, + {type: "text", data: " boo"}, + ]); + }); + + it("handles nested delimiters irrespective of order", function() { + expect(splitAtDelimiters("$\\fbox{\\(hi\\)}$", + [ + {left:"\\(", right:"\\)", display:false}, + {left:"$", right:"$", display:false}, + ])).toEqual( + [ + {type: "math", data: "\\fbox{\\(hi\\)}", + rawData: "$\\fbox{\\(hi\\)}$", display: false}, + ]); + expect(splitAtDelimiters("\\(\\fbox{$hi$}\\)", + [ + {left:"\\(", right:"\\)", display:false}, + {left:"$", right:"$", display:false}, + ])).toEqual( + [ + {type: "math", data: "\\fbox{$hi$}", + rawData: "\\(\\fbox{$hi$}\\)", display: false}, + ]); + }); + + it("handles a mix of $ and $$", function() { + expect(splitAtDelimiters("$hello$world$$boo$$", + [ + {left:"$$", right:"$$", display:true}, + {left:"$", right:"$", display:false}, + ])).toEqual( + [ + {type: "math", data: "hello", + rawData: "$hello$", display: false}, + {type: "text", data: "world"}, + {type: "math", data: "boo", + rawData: "$$boo$$", display: true}, + ]); + expect(splitAtDelimiters("$hello$$world$$$boo$$", + [ + {left:"$$", right:"$$", display:true}, + {left:"$", right:"$", display:false}, + ])).toEqual( + [ + {type: "math", data: "hello", + rawData: "$hello$", display: false}, + {type: "math", data: "world", + rawData: "$world$", display: false}, + {type: "math", data: "boo", + rawData: "$$boo$$", display: true}, + ]); + }); +}); + +describe("Pre-process callback", function() { + it("replace `-squared` with `^2 `", function() { + const el1 = document.createElement('div'); + el1.textContent = 'Circle equation: $x-squared + y-squared = r-squared$.'; + const el2 = document.createElement('div'); + el2.textContent = 'Circle equation: $x^2 + y^2 = r^2$.'; + const delimiters = [{left: "$", right: "$", display: false}]; + renderMathInElement(el1, { + delimiters, + preProcess: math => math.replace(/-squared/g, '^2'), + }); + renderMathInElement(el2, {delimiters}); + expect(el1.innerHTML).toEqual(el2.innerHTML); + }); +}); + +describe("Parse adjacent text nodes", function() { + it("parse adjacent text nodes with math", function() { + const textNodes = ['\\[', + 'x^2 + y^2 = r^2', + '\\]']; + const el = document.createElement('div'); + for (let i = 0; i < textNodes.length; i++) { + const txt = document.createTextNode(textNodes[i]); + el.appendChild(txt); + } + const el2 = document.createElement('div'); + const txt = document.createTextNode(textNodes.join('')); + el2.appendChild(txt); + const delimiters = [{left: "\\[", right: "\\]", display: true}]; + renderMathInElement(el, {delimiters}); + renderMathInElement(el2, {delimiters}); + expect(el).toStrictEqual(el2); + }); + + it("parse adjacent text nodes without math", function() { + const textNodes = ['Lorem ipsum dolor', + 'sit amet', + 'consectetur adipiscing elit']; + const el = document.createElement('div'); + for (let i = 0; i < textNodes.length; i++) { + const txt = document.createTextNode(textNodes[i]); + el.appendChild(txt); + } + const el2 = document.createElement('div'); + for (let i = 0; i < textNodes.length; i++) { + const txt = document.createTextNode(textNodes[i]); + el2.appendChild(txt); + } + const delimiters = [{left: "\\[", right: "\\]", display: true}]; + renderMathInElement(el, {delimiters}); + expect(el).toStrictEqual(el2); + }); +}); diff --git a/node_modules/katex/contrib/copy-tex/README.md b/node_modules/katex/contrib/copy-tex/README.md new file mode 100644 index 0000000..a81d97c --- /dev/null +++ b/node_modules/katex/contrib/copy-tex/README.md @@ -0,0 +1,39 @@ +# Copy-tex extension + +This extension modifies the copy/paste behavior in any browser supporting the +[Clipboard API](https://developer.mozilla.org/en-US/docs/Web/API/ClipboardEvent) +so that, when selecting and copying KaTeX-rendered elements, the text +content of the resulting clipboard renders KaTeX elements as their LaTeX source +surrounded by specified delimiters. (The HTML content of the resulting +clipboard remains the selected HTML content, as it normally would.) +The default delimiters are `$...$` for inline math and `$$...$$` for display +math, but you can easy switch them to e.g. `\(...\)` and `\[...\]` by +modifying `copyDelimiters` in [the source code](copy-tex.js). +Note that a selection containing part of a KaTeX formula gets extended to +include the entire KaTeX formula. + +## Usage + +This extension isn't part of KaTeX proper, so the script should be separately +included in the page. + +```html + +``` + +(Note that, as of KaTeX 0.16.0, there is no longer a corresponding CSS file.) + +See [index.html](index.html) for an example. +(To run this example from a clone of the repository, run `yarn start` +in the root KaTeX directory, and then visit +http://localhost:7936/contrib/copy-tex/index.html +with your web browser.) + +If you want to build your own custom copy handler based on this one, +copy the `copy-tex.js` into your codebase and replace the `require` +statement with `require('katex/contrib/copy-tex/katex2tex.js')`. + +ECMAScript module is also available: +```html + +``` diff --git a/node_modules/katex/contrib/copy-tex/copy-tex.ts b/node_modules/katex/contrib/copy-tex/copy-tex.ts new file mode 100644 index 0000000..526a2c8 --- /dev/null +++ b/node_modules/katex/contrib/copy-tex/copy-tex.ts @@ -0,0 +1,49 @@ +import katexReplaceWithTex from "./katex2tex"; + +// Return
element containing node, or null if not found. +function closestKatex(node: Node): Element | null | undefined { + // If node is a Text Node, for example, go up to containing Element, + // where we can apply the `closest` method. + const element: Element | null | undefined = + (node instanceof Element ? node : node.parentElement); + return element && element.closest('.katex'); +} + +// Global copy handler to modify behavior on/within .katex elements. +document.addEventListener('copy', function(event: ClipboardEvent) { + const selection = window.getSelection(); + if (!selection || selection.isCollapsed || !event.clipboardData) { + return; // default action OK if selection is empty or unchangeable + } + const clipboardData = event.clipboardData; + const range = selection.getRangeAt(0); + + // When start point is within a formula, expand to entire formula. + const startKatex = closestKatex(range.startContainer); + if (startKatex) { + range.setStartBefore(startKatex); + } + + // Similarly, when end point is within a formula, expand to entire formula. + const endKatex = closestKatex(range.endContainer); + if (endKatex) { + range.setEndAfter(endKatex); + } + + const fragment = range.cloneContents(); + if (!fragment.querySelector('.katex-mathml')) { + return; // default action OK if no .katex-mathml elements + } + + const htmlContents = Array.prototype.map.call(fragment.childNodes, + (el) => (el instanceof Text ? el.textContent : el.outerHTML) + ).join(''); + + // Preserve usual HTML copy/paste behavior. + clipboardData.setData('text/html', htmlContents); + // Rewrite plain-text version. + clipboardData.setData('text/plain', + katexReplaceWithTex(fragment).textContent); + // Prevent normal copy handling. + event.preventDefault(); +}); diff --git a/node_modules/katex/contrib/copy-tex/index.html b/node_modules/katex/contrib/copy-tex/index.html new file mode 100644 index 0000000..fa59d27 --- /dev/null +++ b/node_modules/katex/contrib/copy-tex/index.html @@ -0,0 +1,38 @@ + + + + + + Copy-tex test + + + + + + +

Copy-tex test

+

Try copy/pasting some of the text below!

+

+ Here is some \(\KaTeX\) math: $$ x^2+y^2=z^2 $$ + The variables are \(x\), \(y\), and \(z\), + which are all in \(\mathbb{R}^+\). + Q.E.D. +

+ + + diff --git a/node_modules/katex/contrib/copy-tex/katex2tex.ts b/node_modules/katex/contrib/copy-tex/katex2tex.ts new file mode 100644 index 0000000..588bed2 --- /dev/null +++ b/node_modules/katex/contrib/copy-tex/katex2tex.ts @@ -0,0 +1,60 @@ + +export interface CopyDelimiters { + inline: [string, string]; + display: [string, string]; +} + +// Set these to how you want inline and display math to be delimited. +export const defaultCopyDelimiters: CopyDelimiters = { + inline: ['$', '$'], // alternative: ['\(', '\)'] + display: ['$$', '$$'], // alternative: ['\[', '\]'] +}; + +// Replace .katex elements with their TeX source ( element). +// Modifies fragment in-place. Useful for writing your own 'copy' handler, +// as in copy-tex.js. +export function katexReplaceWithTex( + fragment: DocumentFragment, + copyDelimiters: CopyDelimiters = defaultCopyDelimiters +): DocumentFragment { + // Remove .katex-html blocks that are preceded by .katex-mathml blocks + // (which will get replaced below). + const katexHtml = fragment.querySelectorAll('.katex-mathml + .katex-html'); + for (let i = 0; i < katexHtml.length; i++) { + const element = katexHtml[i]; + if (element.remove) { + element.remove(); + } else if (element.parentNode) { + element.parentNode.removeChild(element); + } + } + // Replace .katex-mathml elements with their annotation (TeX source) + // descendant, with inline delimiters. + const katexMathml = fragment.querySelectorAll('.katex-mathml'); + for (let i = 0; i < katexMathml.length; i++) { + const element = katexMathml[i]; + const texSource = element.querySelector('annotation'); + if (texSource) { + if (element.replaceWith) { + element.replaceWith(texSource); + } else if (element.parentNode) { + element.parentNode.replaceChild(texSource, element); + } + texSource.innerHTML = copyDelimiters.inline[0] + + texSource.innerHTML + copyDelimiters.inline[1]; + } + } + // Switch display math to display delimiters. + const displays = fragment.querySelectorAll('.katex-display annotation'); + for (let i = 0; i < displays.length; i++) { + const element = displays[i]; + element.innerHTML = copyDelimiters.display[0] + + element.innerHTML.substr(copyDelimiters.inline[0].length, + element.innerHTML.length - copyDelimiters.inline[0].length + - copyDelimiters.inline[1].length) + + copyDelimiters.display[1]; + } + return fragment; +} + +export default katexReplaceWithTex; diff --git a/node_modules/katex/contrib/mathtex-script-type/README.md b/node_modules/katex/contrib/mathtex-script-type/README.md new file mode 100644 index 0000000..33c7871 --- /dev/null +++ b/node_modules/katex/contrib/mathtex-script-type/README.md @@ -0,0 +1,38 @@ +# `math/tex` Custom Script Type Extension + +This is an extension to automatically display code inside `script` tags with `type=math/tex` using KaTeX. +This script type is commonly used by MathJax, so this can be used to support compatibility with MathJax. + +### Usage + +This extension isn't part of KaTeX proper, so the script should be separately +included in the page, in addition to KaTeX. + +Load the extension by adding the following line to your HTML file. + +```html + +``` +You can download the script and use it locally, or from a local KaTeX installation instead. + +For example, in the following simple page, we first load KaTeX as usual. +Then, in the body, we use a `math/tex` script to typeset the equation `x+\sqrt{1-x^2}`. + + +```html + + + + + + + + + + + +``` + +ECMAScript module is also available: +```html + diff --git a/node_modules/katex/contrib/mathtex-script-type/mathtex-script-type.js b/node_modules/katex/contrib/mathtex-script-type/mathtex-script-type.js new file mode 100644 index 0000000..732db69 --- /dev/null +++ b/node_modules/katex/contrib/mathtex-script-type/mathtex-script-type.js @@ -0,0 +1,23 @@ +import katex from "katex"; + +let scripts = document.body.getElementsByTagName("script"); +scripts = Array.prototype.slice.call(scripts); +scripts.forEach(function(script) { + if (!script.type || !script.type.match(/math\/tex/i)) { + return -1; + } + const display = + (script.type.match(/mode\s*=\s*display(;|\s|\n|$)/) != null); + + const katexElement = document.createElement(display ? "div" : "span"); + katexElement.setAttribute("class", + display ? "equation" : "inline-equation"); + try { + katex.render(script.text, katexElement, {displayMode: display}); + } catch (err) { + // eslint-disable-next-line no-console + console.error(err); + katexElement.textContent = script.text; + } + script.parentNode.replaceChild(katexElement, script); +}); diff --git a/node_modules/katex/contrib/mhchem/README.md b/node_modules/katex/contrib/mhchem/README.md new file mode 100644 index 0000000..dcae768 --- /dev/null +++ b/node_modules/katex/contrib/mhchem/README.md @@ -0,0 +1,23 @@ +# mhchem extension + +This extension adds to KaTeX the `\ce` and `\pu` functions from the [mhchem](https://mhchem.github.io/MathJax-mhchem/) package. + +### Usage + +This extension isn't part of core KaTeX, so the script should be separately included. Write the following line into the HTML page's ``. Place it *after* the line that calls `katex.js`, and if you make use of the [auto-render](https://katex.org/docs/autorender.html) extension, place it *before* the line that calls `auto-render.js`. + +```html + +``` + +If you remove the `defer` attribute from this tag, then you must also remove the `defer` attribute from the ` + + + + + ... + +``` + +You can also [download KaTeX](https://github.com/KaTeX/KaTeX/releases) and host it yourself. + +For details on how to configure auto-render extension, refer to [the documentation](https://katex.org/docs/autorender.html). + +### API + +Call `katex.render` to render a TeX expression directly into a DOM element. +For example: + +```js +katex.render("c = \\pm\\sqrt{a^2 + b^2}", element, { + throwOnError: false +}); +``` + +Call `katex.renderToString` to generate an HTML string of the rendered math, +e.g., for server-side rendering. For example: + +```js +var html = katex.renderToString("c = \\pm\\sqrt{a^2 + b^2}", { + throwOnError: false +}); +// '...' +``` + +Make sure to include the CSS and font files in both cases. +If you are doing all rendering on the server, there is no need to include the +JavaScript on the client. + +The examples above use the `throwOnError: false` option, which renders invalid +inputs as the TeX source code in red (by default), with the error message as +hover text. For other available options, see the +[API documentation](https://katex.org/docs/api.html), +[options documentation](https://katex.org/docs/options.html), and +[handling errors documentation](https://katex.org/docs/error.html). + +## Demo and Documentation + +Learn more about using KaTeX [on the website](https://katex.org)! + +## Contributors + +### Code Contributors + +This project exists thanks to all the people who contribute code. If you'd like to help, see [our guide to contributing code](CONTRIBUTING.md). +Code contributors + +### Financial Contributors + +Become a financial contributor and help us sustain our community. + +#### Individuals + +Contribute on Open Collective + +#### Organizations + +Support this project with your organization. Your logo will show up here with a link to your website. + +Organization 1 +Organization 2 +Organization 3 +Organization 4 +Organization 5 + +## License + +KaTeX is licensed under the [MIT License](https://opensource.org/licenses/MIT). diff --git a/node_modules/katex/dist/contrib/auto-render.js b/node_modules/katex/dist/contrib/auto-render.js new file mode 100644 index 0000000..36cf9f7 --- /dev/null +++ b/node_modules/katex/dist/contrib/auto-render.js @@ -0,0 +1,305 @@ +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(require("katex")); + else if(typeof define === 'function' && define.amd) + define(["katex"], factory); + else if(typeof exports === 'object') + exports["renderMathInElement"] = factory(require("katex")); + else + root["renderMathInElement"] = factory(root["katex"]); +})((typeof self !== 'undefined' ? self : this), function(__WEBPACK_EXTERNAL_MODULE__757__) { +return /******/ (function() { // webpackBootstrap +/******/ "use strict"; +/******/ var __webpack_modules__ = ({ + +/***/ 757: +/***/ (function(module) { + +module.exports = __WEBPACK_EXTERNAL_MODULE__757__; + +/***/ }) + +/******/ }); +/************************************************************************/ +/******/ // The module cache +/******/ var __webpack_module_cache__ = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ // Check if module is in cache +/******/ var cachedModule = __webpack_module_cache__[moduleId]; +/******/ if (cachedModule !== undefined) { +/******/ return cachedModule.exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = __webpack_module_cache__[moduleId] = { +/******/ // no module.id needed +/******/ // no module.loaded needed +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/************************************************************************/ +/******/ /* webpack/runtime/compat get default export */ +/******/ !function() { +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function() { return module['default']; } : +/******/ function() { return module; }; +/******/ __webpack_require__.d(getter, { a: getter }); +/******/ return getter; +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/define property getters */ +/******/ !function() { +/******/ // define getter functions for harmony exports +/******/ __webpack_require__.d = function(exports, definition) { +/******/ for(var key in definition) { +/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { +/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); +/******/ } +/******/ } +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/hasOwnProperty shorthand */ +/******/ !function() { +/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } +/******/ }(); +/******/ +/************************************************************************/ +var __webpack_exports__ = {}; + +// EXPORTS +__webpack_require__.d(__webpack_exports__, { + "default": function() { return /* binding */ auto_render; } +}); + +// EXTERNAL MODULE: external "katex" +var external_katex_ = __webpack_require__(757); +var external_katex_default = /*#__PURE__*/__webpack_require__.n(external_katex_); +;// ./contrib/auto-render/splitAtDelimiters.ts +/* eslint no-constant-condition:0 */ + +const findEndOfMath = function (delimiter, text, startIndex) { + // Adapted from + // https://github.com/Khan/perseus/blob/master/src/perseus-markdown.jsx + let index = startIndex; + let braceLevel = 0; + const delimLength = delimiter.length; + while (index < text.length) { + const character = text[index]; + if (braceLevel <= 0 && text.slice(index, index + delimLength) === delimiter) { + return index; + } else if (character === "\\") { + index++; + } else if (character === "{") { + braceLevel++; + } else if (character === "}") { + braceLevel--; + } + index++; + } + return -1; +}; +const escapeRegex = function (string) { + return string.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&"); +}; +const amsRegex = /^\\begin{/; +const splitAtDelimiters = function (text, delimiters) { + let index; + const data = []; + const regexLeft = new RegExp("(" + delimiters.map(x => escapeRegex(x.left)).join("|") + ")"); + while (true) { + index = text.search(regexLeft); + if (index === -1) { + break; + } + if (index > 0) { + data.push({ + type: "text", + data: text.slice(0, index) + }); + text = text.slice(index); // now text starts with delimiter + } + // ... so this always succeeds: + const i = delimiters.findIndex(delim => text.startsWith(delim.left)); + index = findEndOfMath(delimiters[i].right, text, delimiters[i].left.length); + if (index === -1) { + break; + } + const rawData = text.slice(0, index + delimiters[i].right.length); + const math = amsRegex.test(rawData) ? rawData : text.slice(delimiters[i].left.length, index); + data.push({ + type: "math", + data: math, + rawData, + display: delimiters[i].display + }); + text = text.slice(index + delimiters[i].right.length); + } + if (text !== "") { + data.push({ + type: "text", + data: text + }); + } + return data; +}; +/* harmony default export */ var auto_render_splitAtDelimiters = (splitAtDelimiters); +;// ./contrib/auto-render/auto-render.ts +/* eslint no-console:0 */ + + + +/* Note: optionsCopy is mutated by this method. If it is ever exposed in the + * API, we should copy it before mutating. + */ +const renderMathInText = function (text, optionsCopy) { + const data = auto_render_splitAtDelimiters(text, optionsCopy.delimiters); + if (data.length === 1 && data[0].type === 'text') { + // There is no formula in the text. + // Let's return null which means there is no need to replace + // the current text node with a new one. + return null; + } + const fragment = document.createDocumentFragment(); + for (let i = 0; i < data.length; i++) { + if (data[i].type === "text") { + fragment.appendChild(document.createTextNode(data[i].data)); + } else { + const span = document.createElement("span"); + let math = data[i].data; + // Override any display mode defined in the settings with that + // defined by the text itself + optionsCopy.displayMode = data[i].display; + try { + if (optionsCopy.preProcess) { + math = optionsCopy.preProcess(math); + } + external_katex_default().render(math, span, optionsCopy); + } catch (e) { + if (!(e instanceof (external_katex_default()).ParseError)) { + throw e; + } + optionsCopy.errorCallback("KaTeX auto-render: Failed to parse `" + data[i].data + "` with ", e); + fragment.appendChild(document.createTextNode(data[i].rawData)); + continue; + } + fragment.appendChild(span); + } + } + return fragment; +}; +const renderElem = function (elem, optionsCopy) { + for (let i = 0; i < elem.childNodes.length; i++) { + const childNode = elem.childNodes[i]; + if (childNode.nodeType === 3) { + var _childNode$textConten; + // Text node + // Concatenate all sibling text nodes. + // Webkit browsers split very large text nodes into smaller ones, + // so the delimiters may be split across different nodes. + let textContentConcat = (_childNode$textConten = childNode.textContent) != null ? _childNode$textConten : ""; + let sibling = childNode.nextSibling; + let nSiblings = 0; + while (sibling && sibling.nodeType === Node.TEXT_NODE) { + var _sibling$textContent; + textContentConcat += (_sibling$textContent = sibling.textContent) != null ? _sibling$textContent : ""; + sibling = sibling.nextSibling; + nSiblings++; + } + const frag = renderMathInText(textContentConcat, optionsCopy); + if (frag) { + // Remove extra text nodes + for (let j = 0; j < nSiblings; j++) { + childNode.nextSibling.remove(); + } + i += frag.childNodes.length - 1; + elem.replaceChild(frag, childNode); + } else { + // If the concatenated text does not contain math + // the siblings will not either + i += nSiblings; + } + } else if (childNode.nodeType === 1) { + // Element node + const className = ' ' + childNode.className + ' '; + const shouldRender = !optionsCopy.ignoredTags.has(childNode.nodeName.toLowerCase()) && optionsCopy.ignoredClasses.every(x => !className.includes(' ' + x + ' ')); + if (shouldRender) { + renderElem(childNode, optionsCopy); + } + } + // Otherwise, it's something else, and ignore it. + } +}; +const renderMathInElement = function (elem, options) { + if (!elem) { + throw new Error("No element provided to render"); + } + const optionsCopy = {}; + Object.assign(optionsCopy, options); + + // default options + optionsCopy.delimiters = optionsCopy.delimiters || [{ + left: "$$", + right: "$$", + display: true + }, { + left: "\\(", + right: "\\)", + display: false + }, + // LaTeX uses $…$, but it ruins the display of normal `$` in text: + // {left: "$", right: "$", display: false}, + // $ must come after $$ + + // Render AMS environments even if outside $$…$$ delimiters. + { + left: "\\begin{equation}", + right: "\\end{equation}", + display: true + }, { + left: "\\begin{align}", + right: "\\end{align}", + display: true + }, { + left: "\\begin{alignat}", + right: "\\end{alignat}", + display: true + }, { + left: "\\begin{gather}", + right: "\\end{gather}", + display: true + }, { + left: "\\begin{CD}", + right: "\\end{CD}", + display: true + }, { + left: "\\[", + right: "\\]", + display: true + }]; + optionsCopy.ignoredTags = new Set((options == null ? void 0 : options.ignoredTags) || ["script", "noscript", "style", "textarea", "pre", "code", "option"]); + optionsCopy.ignoredClasses = optionsCopy.ignoredClasses || []; + optionsCopy.errorCallback = optionsCopy.errorCallback || console.error; + + // Enable sharing of global macros defined via `\gdef` between different + // math elements within a single call to `renderMathInElement`. + optionsCopy.macros = optionsCopy.macros || {}; + renderElem(elem, optionsCopy); +}; +/* harmony default export */ var auto_render = (renderMathInElement); +__webpack_exports__ = __webpack_exports__["default"]; +/******/ return __webpack_exports__; +/******/ })() +; +}); \ No newline at end of file diff --git a/node_modules/katex/dist/contrib/auto-render.min.js b/node_modules/katex/dist/contrib/auto-render.min.js new file mode 100644 index 0000000..0a1f35d --- /dev/null +++ b/node_modules/katex/dist/contrib/auto-render.min.js @@ -0,0 +1 @@ +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("katex")):"function"==typeof define&&define.amd?define(["katex"],t):"object"==typeof exports?exports.renderMathInElement=t(require("katex")):e.renderMathInElement=t(e.katex)}("undefined"!=typeof self?self:this,function(e){return function(){"use strict";var t={757:function(t){t.exports=e}},n={};function r(e){var o=n[e];if(void 0!==o)return o.exports;var i=n[e]={exports:{}};return t[e](i,i.exports,r),i.exports}r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,{a:t}),t},r.d=function(e,t){for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};var o={};r.d(o,{default:function(){return p}});var i=r(757),a=r.n(i);const l=function(e,t,n){let r=n,o=0;const i=e.length;for(;re.left.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")).join("|")+")");for(;n=e.search(o),-1!==n;){n>0&&(r.push({type:"text",data:e.slice(0,n)}),e=e.slice(n));const o=t.findIndex(t=>e.startsWith(t.left));if(n=l(t[o].right,e,t[o].left.length),-1===n)break;const i=e.slice(0,n+t[o].right.length),a=s.test(i)?i:e.slice(t[o].left.length,n);r.push({type:"math",data:a,rawData:i,display:t[o].display}),e=e.slice(n+t[o].right.length)}return""!==e&&r.push({type:"text",data:e}),r};const c=function(e,t){const n=d(e,t.delimiters);if(1===n.length&&"text"===n[0].type)return null;const r=document.createDocumentFragment();for(let e=0;e!e.includes(" "+t+" "))&&f(i,t)}}};var p=function(e,t){if(!e)throw new Error("No element provided to render");const n={};Object.assign(n,t),n.delimiters=n.delimiters||[{left:"$$",right:"$$",display:!0},{left:"\\(",right:"\\)",display:!1},{left:"\\begin{equation}",right:"\\end{equation}",display:!0},{left:"\\begin{align}",right:"\\end{align}",display:!0},{left:"\\begin{alignat}",right:"\\end{alignat}",display:!0},{left:"\\begin{gather}",right:"\\end{gather}",display:!0},{left:"\\begin{CD}",right:"\\end{CD}",display:!0},{left:"\\[",right:"\\]",display:!0}],n.ignoredTags=new Set((null==t?void 0:t.ignoredTags)||["script","noscript","style","textarea","pre","code","option"]),n.ignoredClasses=n.ignoredClasses||[],n.errorCallback=n.errorCallback||console.error,n.macros=n.macros||{},f(e,n)};return o=o.default}()}); \ No newline at end of file diff --git a/node_modules/katex/dist/contrib/auto-render.mjs b/node_modules/katex/dist/contrib/auto-render.mjs new file mode 100644 index 0000000..7bd38c6 --- /dev/null +++ b/node_modules/katex/dist/contrib/auto-render.mjs @@ -0,0 +1,210 @@ +import katex from '../katex.mjs'; + +/* eslint no-constant-condition:0 */ +var findEndOfMath = function findEndOfMath(delimiter, text, startIndex) { + // Adapted from + // https://github.com/Khan/perseus/blob/master/src/perseus-markdown.jsx + var index = startIndex; + var braceLevel = 0; + var delimLength = delimiter.length; + while (index < text.length) { + var character = text[index]; + if (braceLevel <= 0 && text.slice(index, index + delimLength) === delimiter) { + return index; + } else if (character === "\\") { + index++; + } else if (character === "{") { + braceLevel++; + } else if (character === "}") { + braceLevel--; + } + index++; + } + return -1; +}; +var escapeRegex = function escapeRegex(string) { + return string.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&"); +}; +var amsRegex = /^\\begin{/; +var splitAtDelimiters = function splitAtDelimiters(text, delimiters) { + var index; + var data = []; + var regexLeft = new RegExp("(" + delimiters.map(x => escapeRegex(x.left)).join("|") + ")"); + while (true) { + index = text.search(regexLeft); + if (index === -1) { + break; + } + if (index > 0) { + data.push({ + type: "text", + data: text.slice(0, index) + }); + text = text.slice(index); // now text starts with delimiter + } + // ... so this always succeeds: + var i = delimiters.findIndex(delim => text.startsWith(delim.left)); + index = findEndOfMath(delimiters[i].right, text, delimiters[i].left.length); + if (index === -1) { + break; + } + var rawData = text.slice(0, index + delimiters[i].right.length); + var math = amsRegex.test(rawData) ? rawData : text.slice(delimiters[i].left.length, index); + data.push({ + type: "math", + data: math, + rawData, + display: delimiters[i].display + }); + text = text.slice(index + delimiters[i].right.length); + } + if (text !== "") { + data.push({ + type: "text", + data: text + }); + } + return data; +}; + +/* eslint no-console:0 */ +/* Note: optionsCopy is mutated by this method. If it is ever exposed in the + * API, we should copy it before mutating. + */ +var renderMathInText = function renderMathInText(text, optionsCopy) { + var data = splitAtDelimiters(text, optionsCopy.delimiters); + if (data.length === 1 && data[0].type === 'text') { + // There is no formula in the text. + // Let's return null which means there is no need to replace + // the current text node with a new one. + return null; + } + var fragment = document.createDocumentFragment(); + for (var i = 0; i < data.length; i++) { + if (data[i].type === "text") { + fragment.appendChild(document.createTextNode(data[i].data)); + } else { + var span = document.createElement("span"); + var math = data[i].data; + // Override any display mode defined in the settings with that + // defined by the text itself + optionsCopy.displayMode = data[i].display; + try { + if (optionsCopy.preProcess) { + math = optionsCopy.preProcess(math); + } + katex.render(math, span, optionsCopy); + } catch (e) { + if (!(e instanceof katex.ParseError)) { + throw e; + } + optionsCopy.errorCallback("KaTeX auto-render: Failed to parse `" + data[i].data + "` with ", e); + fragment.appendChild(document.createTextNode(data[i].rawData)); + continue; + } + fragment.appendChild(span); + } + } + return fragment; +}; +var _renderElem = function renderElem(elem, optionsCopy) { + var _loop = function _loop(_i) { + var childNode = elem.childNodes[_i]; + if (childNode.nodeType === 3) { + var _childNode$textConten; + // Text node + // Concatenate all sibling text nodes. + // Webkit browsers split very large text nodes into smaller ones, + // so the delimiters may be split across different nodes. + var textContentConcat = (_childNode$textConten = childNode.textContent) != null ? _childNode$textConten : ""; + var sibling = childNode.nextSibling; + var nSiblings = 0; + while (sibling && sibling.nodeType === Node.TEXT_NODE) { + var _sibling$textContent; + textContentConcat += (_sibling$textContent = sibling.textContent) != null ? _sibling$textContent : ""; + sibling = sibling.nextSibling; + nSiblings++; + } + var frag = renderMathInText(textContentConcat, optionsCopy); + if (frag) { + // Remove extra text nodes + for (var j = 0; j < nSiblings; j++) { + childNode.nextSibling.remove(); + } + _i += frag.childNodes.length - 1; + elem.replaceChild(frag, childNode); + } else { + // If the concatenated text does not contain math + // the siblings will not either + _i += nSiblings; + } + } else if (childNode.nodeType === 1) { + // Element node + var className = ' ' + childNode.className + ' '; + var shouldRender = !optionsCopy.ignoredTags.has(childNode.nodeName.toLowerCase()) && optionsCopy.ignoredClasses.every(x => !className.includes(' ' + x + ' ')); + if (shouldRender) { + _renderElem(childNode, optionsCopy); + } + } + // Otherwise, it's something else, and ignore it. + i = _i; + }; + for (var i = 0; i < elem.childNodes.length; i++) { + _loop(i); + } +}; +var renderMathInElement = function renderMathInElement(elem, options) { + if (!elem) { + throw new Error("No element provided to render"); + } + var optionsCopy = {}; + Object.assign(optionsCopy, options); + // default options + optionsCopy.delimiters = optionsCopy.delimiters || [{ + left: "$$", + right: "$$", + display: true + }, { + left: "\\(", + right: "\\)", + display: false + }, + // LaTeX uses $…$, but it ruins the display of normal `$` in text: + // {left: "$", right: "$", display: false}, + // $ must come after $$ + // Render AMS environments even if outside $$…$$ delimiters. + { + left: "\\begin{equation}", + right: "\\end{equation}", + display: true + }, { + left: "\\begin{align}", + right: "\\end{align}", + display: true + }, { + left: "\\begin{alignat}", + right: "\\end{alignat}", + display: true + }, { + left: "\\begin{gather}", + right: "\\end{gather}", + display: true + }, { + left: "\\begin{CD}", + right: "\\end{CD}", + display: true + }, { + left: "\\[", + right: "\\]", + display: true + }]; + optionsCopy.ignoredTags = new Set((options == null ? void 0 : options.ignoredTags) || ["script", "noscript", "style", "textarea", "pre", "code", "option"]); + optionsCopy.ignoredClasses = optionsCopy.ignoredClasses || []; + optionsCopy.errorCallback = optionsCopy.errorCallback || console.error; + // Enable sharing of global macros defined via `\gdef` between different + // math elements within a single call to `renderMathInElement`. + optionsCopy.macros = optionsCopy.macros || {}; + _renderElem(elem, optionsCopy); +}; + +export { renderMathInElement as default }; diff --git a/node_modules/katex/dist/contrib/copy-tex.js b/node_modules/katex/dist/contrib/copy-tex.js new file mode 100644 index 0000000..cb9a871 --- /dev/null +++ b/node_modules/katex/dist/contrib/copy-tex.js @@ -0,0 +1,113 @@ +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(); + else if(typeof define === 'function' && define.amd) + define([], factory); + else { + var a = factory(); + for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i]; + } +})((typeof self !== 'undefined' ? self : this), function() { +return /******/ (function() { // webpackBootstrap +/******/ "use strict"; +var __webpack_exports__ = {}; + +;// ./contrib/copy-tex/katex2tex.ts +// Set these to how you want inline and display math to be delimited. +const defaultCopyDelimiters = { + inline: ['$', '$'], + // alternative: ['\(', '\)'] + display: ['$$', '$$'] // alternative: ['\[', '\]'] +}; + +// Replace .katex elements with their TeX source ( element). +// Modifies fragment in-place. Useful for writing your own 'copy' handler, +// as in copy-tex.js. +function katexReplaceWithTex(fragment, copyDelimiters) { + if (copyDelimiters === void 0) { + copyDelimiters = defaultCopyDelimiters; + } + // Remove .katex-html blocks that are preceded by .katex-mathml blocks + // (which will get replaced below). + const katexHtml = fragment.querySelectorAll('.katex-mathml + .katex-html'); + for (let i = 0; i < katexHtml.length; i++) { + const element = katexHtml[i]; + if (element.remove) { + element.remove(); + } else if (element.parentNode) { + element.parentNode.removeChild(element); + } + } + // Replace .katex-mathml elements with their annotation (TeX source) + // descendant, with inline delimiters. + const katexMathml = fragment.querySelectorAll('.katex-mathml'); + for (let i = 0; i < katexMathml.length; i++) { + const element = katexMathml[i]; + const texSource = element.querySelector('annotation'); + if (texSource) { + if (element.replaceWith) { + element.replaceWith(texSource); + } else if (element.parentNode) { + element.parentNode.replaceChild(texSource, element); + } + texSource.innerHTML = copyDelimiters.inline[0] + texSource.innerHTML + copyDelimiters.inline[1]; + } + } + // Switch display math to display delimiters. + const displays = fragment.querySelectorAll('.katex-display annotation'); + for (let i = 0; i < displays.length; i++) { + const element = displays[i]; + element.innerHTML = copyDelimiters.display[0] + element.innerHTML.substr(copyDelimiters.inline[0].length, element.innerHTML.length - copyDelimiters.inline[0].length - copyDelimiters.inline[1].length) + copyDelimiters.display[1]; + } + return fragment; +} +/* harmony default export */ var katex2tex = (katexReplaceWithTex); +;// ./contrib/copy-tex/copy-tex.ts + + +// Return
element containing node, or null if not found. +function closestKatex(node) { + // If node is a Text Node, for example, go up to containing Element, + // where we can apply the `closest` method. + const element = node instanceof Element ? node : node.parentElement; + return element && element.closest('.katex'); +} + +// Global copy handler to modify behavior on/within .katex elements. +document.addEventListener('copy', function (event) { + const selection = window.getSelection(); + if (!selection || selection.isCollapsed || !event.clipboardData) { + return; // default action OK if selection is empty or unchangeable + } + const clipboardData = event.clipboardData; + const range = selection.getRangeAt(0); + + // When start point is within a formula, expand to entire formula. + const startKatex = closestKatex(range.startContainer); + if (startKatex) { + range.setStartBefore(startKatex); + } + + // Similarly, when end point is within a formula, expand to entire formula. + const endKatex = closestKatex(range.endContainer); + if (endKatex) { + range.setEndAfter(endKatex); + } + const fragment = range.cloneContents(); + if (!fragment.querySelector('.katex-mathml')) { + return; // default action OK if no .katex-mathml elements + } + const htmlContents = Array.prototype.map.call(fragment.childNodes, el => el instanceof Text ? el.textContent : el.outerHTML).join(''); + + // Preserve usual HTML copy/paste behavior. + clipboardData.setData('text/html', htmlContents); + // Rewrite plain-text version. + clipboardData.setData('text/plain', katex2tex(fragment).textContent); + // Prevent normal copy handling. + event.preventDefault(); +}); +__webpack_exports__ = __webpack_exports__["default"]; +/******/ return __webpack_exports__; +/******/ })() +; +}); \ No newline at end of file diff --git a/node_modules/katex/dist/contrib/copy-tex.min.js b/node_modules/katex/dist/contrib/copy-tex.min.js new file mode 100644 index 0000000..88f9c30 --- /dev/null +++ b/node_modules/katex/dist/contrib/copy-tex.min.js @@ -0,0 +1 @@ +!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var o in n)("object"==typeof exports?exports:e)[o]=n[o]}}("undefined"!=typeof self?self:this,function(){return function(){"use strict";var e={};const t={inline:["$","$"],display:["$$","$$"]};var n=function(e,n){void 0===n&&(n=t);const o=e.querySelectorAll(".katex-mathml + .katex-html");for(let e=0;ee instanceof Text?e.textContent:e.outerHTML).join("");r.setData("text/html",c),r.setData("text/plain",n(s).textContent),e.preventDefault()}),e=e.default}()}); \ No newline at end of file diff --git a/node_modules/katex/dist/contrib/copy-tex.mjs b/node_modules/katex/dist/contrib/copy-tex.mjs new file mode 100644 index 0000000..ce9977e --- /dev/null +++ b/node_modules/katex/dist/contrib/copy-tex.mjs @@ -0,0 +1,85 @@ +// Set these to how you want inline and display math to be delimited. +var defaultCopyDelimiters = { + inline: ['$', '$'], + // alternative: ['\(', '\)'] + display: ['$$', '$$'] // alternative: ['\[', '\]'] +}; +// Replace .katex elements with their TeX source ( element). +// Modifies fragment in-place. Useful for writing your own 'copy' handler, +// as in copy-tex.js. +function katexReplaceWithTex(fragment, copyDelimiters) { + if (copyDelimiters === void 0) { + copyDelimiters = defaultCopyDelimiters; + } + // Remove .katex-html blocks that are preceded by .katex-mathml blocks + // (which will get replaced below). + var katexHtml = fragment.querySelectorAll('.katex-mathml + .katex-html'); + for (var i = 0; i < katexHtml.length; i++) { + var element = katexHtml[i]; + if (element.remove) { + element.remove(); + } else if (element.parentNode) { + element.parentNode.removeChild(element); + } + } + // Replace .katex-mathml elements with their annotation (TeX source) + // descendant, with inline delimiters. + var katexMathml = fragment.querySelectorAll('.katex-mathml'); + for (var _i = 0; _i < katexMathml.length; _i++) { + var _element = katexMathml[_i]; + var texSource = _element.querySelector('annotation'); + if (texSource) { + if (_element.replaceWith) { + _element.replaceWith(texSource); + } else if (_element.parentNode) { + _element.parentNode.replaceChild(texSource, _element); + } + texSource.innerHTML = copyDelimiters.inline[0] + texSource.innerHTML + copyDelimiters.inline[1]; + } + } + // Switch display math to display delimiters. + var displays = fragment.querySelectorAll('.katex-display annotation'); + for (var _i2 = 0; _i2 < displays.length; _i2++) { + var _element2 = displays[_i2]; + _element2.innerHTML = copyDelimiters.display[0] + _element2.innerHTML.substr(copyDelimiters.inline[0].length, _element2.innerHTML.length - copyDelimiters.inline[0].length - copyDelimiters.inline[1].length) + copyDelimiters.display[1]; + } + return fragment; +} + +// Return
element containing node, or null if not found. +function closestKatex(node) { + // If node is a Text Node, for example, go up to containing Element, + // where we can apply the `closest` method. + var element = node instanceof Element ? node : node.parentElement; + return element && element.closest('.katex'); +} +// Global copy handler to modify behavior on/within .katex elements. +document.addEventListener('copy', function (event) { + var selection = window.getSelection(); + if (!selection || selection.isCollapsed || !event.clipboardData) { + return; // default action OK if selection is empty or unchangeable + } + var clipboardData = event.clipboardData; + var range = selection.getRangeAt(0); + // When start point is within a formula, expand to entire formula. + var startKatex = closestKatex(range.startContainer); + if (startKatex) { + range.setStartBefore(startKatex); + } + // Similarly, when end point is within a formula, expand to entire formula. + var endKatex = closestKatex(range.endContainer); + if (endKatex) { + range.setEndAfter(endKatex); + } + var fragment = range.cloneContents(); + if (!fragment.querySelector('.katex-mathml')) { + return; // default action OK if no .katex-mathml elements + } + var htmlContents = Array.prototype.map.call(fragment.childNodes, el => el instanceof Text ? el.textContent : el.outerHTML).join(''); + // Preserve usual HTML copy/paste behavior. + clipboardData.setData('text/html', htmlContents); + // Rewrite plain-text version. + clipboardData.setData('text/plain', katexReplaceWithTex(fragment).textContent); + // Prevent normal copy handling. + event.preventDefault(); +}); diff --git a/node_modules/katex/dist/contrib/mathtex-script-type.js b/node_modules/katex/dist/contrib/mathtex-script-type.js new file mode 100644 index 0000000..196c17e --- /dev/null +++ b/node_modules/katex/dist/contrib/mathtex-script-type.js @@ -0,0 +1,107 @@ +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(require("katex")); + else if(typeof define === 'function' && define.amd) + define(["katex"], factory); + else { + var a = typeof exports === 'object' ? factory(require("katex")) : factory(root["katex"]); + for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i]; + } +})((typeof self !== 'undefined' ? self : this), function(__WEBPACK_EXTERNAL_MODULE__757__) { +return /******/ (function() { // webpackBootstrap +/******/ "use strict"; +/******/ var __webpack_modules__ = ({ + +/***/ 757: +/***/ (function(module) { + +module.exports = __WEBPACK_EXTERNAL_MODULE__757__; + +/***/ }) + +/******/ }); +/************************************************************************/ +/******/ // The module cache +/******/ var __webpack_module_cache__ = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ // Check if module is in cache +/******/ var cachedModule = __webpack_module_cache__[moduleId]; +/******/ if (cachedModule !== undefined) { +/******/ return cachedModule.exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = __webpack_module_cache__[moduleId] = { +/******/ // no module.id needed +/******/ // no module.loaded needed +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/************************************************************************/ +/******/ /* webpack/runtime/compat get default export */ +/******/ !function() { +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function() { return module['default']; } : +/******/ function() { return module; }; +/******/ __webpack_require__.d(getter, { a: getter }); +/******/ return getter; +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/define property getters */ +/******/ !function() { +/******/ // define getter functions for harmony exports +/******/ __webpack_require__.d = function(exports, definition) { +/******/ for(var key in definition) { +/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { +/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); +/******/ } +/******/ } +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/hasOwnProperty shorthand */ +/******/ !function() { +/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } +/******/ }(); +/******/ +/************************************************************************/ +var __webpack_exports__ = {}; +/* harmony import */ var katex__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(757); +/* harmony import */ var katex__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(katex__WEBPACK_IMPORTED_MODULE_0__); + +let scripts = document.body.getElementsByTagName("script"); +scripts = Array.prototype.slice.call(scripts); +scripts.forEach(function (script) { + if (!script.type || !script.type.match(/math\/tex/i)) { + return -1; + } + const display = script.type.match(/mode\s*=\s*display(;|\s|\n|$)/) != null; + const katexElement = document.createElement(display ? "div" : "span"); + katexElement.setAttribute("class", display ? "equation" : "inline-equation"); + try { + katex__WEBPACK_IMPORTED_MODULE_0___default().render(script.text, katexElement, { + displayMode: display + }); + } catch (err) { + // eslint-disable-next-line no-console + console.error(err); + katexElement.textContent = script.text; + } + script.parentNode.replaceChild(katexElement, script); +}); +__webpack_exports__ = __webpack_exports__["default"]; +/******/ return __webpack_exports__; +/******/ })() +; +}); \ No newline at end of file diff --git a/node_modules/katex/dist/contrib/mathtex-script-type.min.js b/node_modules/katex/dist/contrib/mathtex-script-type.min.js new file mode 100644 index 0000000..c605747 --- /dev/null +++ b/node_modules/katex/dist/contrib/mathtex-script-type.min.js @@ -0,0 +1 @@ +!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("katex"));else if("function"==typeof define&&define.amd)define(["katex"],t);else{var r="object"==typeof exports?t(require("katex")):t(e.katex);for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}("undefined"!=typeof self?self:this,function(e){return function(){"use strict";var t={757:function(t){t.exports=e}},r={};function n(e){var o=r[e];if(void 0!==o)return o.exports;var i=r[e]={exports:{}};return t[e](i,i.exports,n),i.exports}n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};var o={},i=n(757),a=n.n(i);let u=document.body.getElementsByTagName("script");return u=Array.prototype.slice.call(u),u.forEach(function(e){if(!e.type||!e.type.match(/math\/tex/i))return-1;const t=null!=e.type.match(/mode\s*=\s*display(;|\s|\n|$)/),r=document.createElement(t?"div":"span");r.setAttribute("class",t?"equation":"inline-equation");try{a().render(e.text,r,{displayMode:t})}catch(t){console.error(t),r.textContent=e.text}e.parentNode.replaceChild(r,e)}),o=o.default}()}); \ No newline at end of file diff --git a/node_modules/katex/dist/contrib/mathtex-script-type.mjs b/node_modules/katex/dist/contrib/mathtex-script-type.mjs new file mode 100644 index 0000000..b5f2b74 --- /dev/null +++ b/node_modules/katex/dist/contrib/mathtex-script-type.mjs @@ -0,0 +1,22 @@ +import katex from '../katex.mjs'; + +var scripts = document.body.getElementsByTagName("script"); +scripts = Array.prototype.slice.call(scripts); +scripts.forEach(function (script) { + if (!script.type || !script.type.match(/math\/tex/i)) { + return -1; + } + var display = script.type.match(/mode\s*=\s*display(;|\s|\n|$)/) != null; + var katexElement = document.createElement(display ? "div" : "span"); + katexElement.setAttribute("class", display ? "equation" : "inline-equation"); + try { + katex.render(script.text, katexElement, { + displayMode: display + }); + } catch (err) { + // eslint-disable-next-line no-console + console.error(err); + katexElement.textContent = script.text; + } + script.parentNode.replaceChild(katexElement, script); +}); diff --git a/node_modules/katex/dist/contrib/mhchem.js b/node_modules/katex/dist/contrib/mhchem.js new file mode 100644 index 0000000..0a974a8 --- /dev/null +++ b/node_modules/katex/dist/contrib/mhchem.js @@ -0,0 +1,2965 @@ +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(require("katex")); + else if(typeof define === 'function' && define.amd) + define(["katex"], factory); + else { + var a = typeof exports === 'object' ? factory(require("katex")) : factory(root["katex"]); + for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i]; + } +})((typeof self !== 'undefined' ? self : this), function(__WEBPACK_EXTERNAL_MODULE__757__) { +return /******/ (function() { // webpackBootstrap +/******/ "use strict"; +/******/ var __webpack_modules__ = ({ + +/***/ 757: +/***/ (function(module) { + +module.exports = __WEBPACK_EXTERNAL_MODULE__757__; + +/***/ }) + +/******/ }); +/************************************************************************/ +/******/ // The module cache +/******/ var __webpack_module_cache__ = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ // Check if module is in cache +/******/ var cachedModule = __webpack_module_cache__[moduleId]; +/******/ if (cachedModule !== undefined) { +/******/ return cachedModule.exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = __webpack_module_cache__[moduleId] = { +/******/ // no module.id needed +/******/ // no module.loaded needed +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/************************************************************************/ +/******/ /* webpack/runtime/compat get default export */ +/******/ !function() { +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function() { return module['default']; } : +/******/ function() { return module; }; +/******/ __webpack_require__.d(getter, { a: getter }); +/******/ return getter; +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/define property getters */ +/******/ !function() { +/******/ // define getter functions for harmony exports +/******/ __webpack_require__.d = function(exports, definition) { +/******/ for(var key in definition) { +/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { +/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); +/******/ } +/******/ } +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/hasOwnProperty shorthand */ +/******/ !function() { +/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } +/******/ }(); +/******/ +/************************************************************************/ +var __webpack_exports__ = {}; +/* harmony import */ var katex__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(757); +/* harmony import */ var katex__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(katex__WEBPACK_IMPORTED_MODULE_0__); +/* eslint-disable */ +/* -*- Mode: JavaScript; indent-tabs-mode:nil; js-indent-level: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ + +/************************************************************* + * + * KaTeX mhchem.js + * + * This file implements a KaTeX version of mhchem version 3.3.0. + * It is adapted from MathJax/extensions/TeX/mhchem.js + * It differs from the MathJax version as follows: + * 1. The interface is changed so that it can be called from KaTeX, not MathJax. + * 2. \rlap and \llap are replaced with \mathrlap and \mathllap. + * 3. Four lines of code are edited in order to use \raisebox instead of \raise. + * 4. The reaction arrow code is simplified. All reaction arrows are rendered + * using KaTeX extensible arrows instead of building non-extensible arrows. + * 5. \tripledash vertical alignment is slightly adjusted. + * + * This code, as other KaTeX code, is released under the MIT license. + * + * /************************************************************* + * + * MathJax/extensions/TeX/mhchem.js + * + * Implements the \ce command for handling chemical formulas + * from the mhchem LaTeX package. + * + * --------------------------------------------------------------------- + * + * Copyright (c) 2011-2015 The MathJax Consortium + * Copyright (c) 2015-2018 Martin Hensel + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// +// Coding Style +// - use '' for identifiers that can by minified/uglified +// - use "" for strings that need to stay untouched + +// version: "3.3.0" for MathJax and KaTeX + +// Add \ce, \pu, and \tripledash to the KaTeX macros. + +katex__WEBPACK_IMPORTED_MODULE_0___default().__defineMacro("\\ce", function (context) { + return chemParse(context.consumeArgs(1)[0], "ce"); +}); +katex__WEBPACK_IMPORTED_MODULE_0___default().__defineMacro("\\pu", function (context) { + return chemParse(context.consumeArgs(1)[0], "pu"); +}); + +// Needed for \bond for the ~ forms +// Raise by 2.56mu, not 2mu. We're raising a hyphen-minus, U+002D, not +// a mathematical minus, U+2212. So we need that extra 0.56. +katex__WEBPACK_IMPORTED_MODULE_0___default().__defineMacro("\\tripledash", "{\\vphantom{-}\\raisebox{2.56mu}{$\\mkern2mu" + "\\tiny\\text{-}\\mkern1mu\\text{-}\\mkern1mu\\text{-}\\mkern2mu$}}"); + + +// +// This is the main function for handing the \ce and \pu commands. +// It takes the argument to \ce or \pu and returns the corresponding TeX string. +// + +var chemParse = function (tokens, stateMachine) { + // Recreate the argument string from KaTeX's array of tokens. + var str = ""; + var expectedLoc = tokens.length && tokens[tokens.length - 1].loc.start; + for (var i = tokens.length - 1; i >= 0; i--) { + if (tokens[i].loc.start > expectedLoc) { + // context.consumeArgs has eaten a space. + str += " "; + expectedLoc = tokens[i].loc.start; + } + str += tokens[i].text; + expectedLoc += tokens[i].text.length; + } + var tex = texify.go(mhchemParser.go(str, stateMachine)); + return tex; +}; + +// +// Core parser for mhchem syntax (recursive) +// +/** @type {MhchemParser} */ +var mhchemParser = { + // + // Parses mchem \ce syntax + // + // Call like + // go("H2O"); + // + go: function (input, stateMachine) { + if (!input) { + return []; + } + if (stateMachine === undefined) { + stateMachine = 'ce'; + } + var state = '0'; + + // + // String buffers for parsing: + // + // buffer.a == amount + // buffer.o == element + // buffer.b == left-side superscript + // buffer.p == left-side subscript + // buffer.q == right-side subscript + // buffer.d == right-side superscript + // + // buffer.r == arrow + // buffer.rdt == arrow, script above, type + // buffer.rd == arrow, script above, content + // buffer.rqt == arrow, script below, type + // buffer.rq == arrow, script below, content + // + // buffer.text_ + // buffer.rm + // etc. + // + // buffer.parenthesisLevel == int, starting at 0 + // buffer.sb == bool, space before + // buffer.beginsWithBond == bool + // + // These letters are also used as state names. + // + // Other states: + // 0 == begin of main part (arrow/operator unlikely) + // 1 == next entity + // 2 == next entity (arrow/operator unlikely) + // 3 == next atom + // c == macro + // + /** @type {Buffer} */ + var buffer = {}; + buffer['parenthesisLevel'] = 0; + input = input.replace(/\n/g, " "); + input = input.replace(/[\u2212\u2013\u2014\u2010]/g, "-"); + input = input.replace(/[\u2026]/g, "..."); + + // + // Looks through mhchemParser.transitions, to execute a matching action + // (recursive) + // + var lastInput; + var watchdog = 10; + /** @type {ParserOutput[]} */ + var output = []; + while (true) { + if (lastInput !== input) { + watchdog = 10; + lastInput = input; + } else { + watchdog--; + } + // + // Find actions in transition table + // + var machine = mhchemParser.stateMachines[stateMachine]; + var t = machine.transitions[state] || machine.transitions['*']; + iterateTransitions: for (var i = 0; i < t.length; i++) { + var matches = mhchemParser.patterns.match_(t[i].pattern, input); + if (matches) { + // + // Execute actions + // + var task = t[i].task; + for (var iA = 0; iA < task.action_.length; iA++) { + var o; + // + // Find and execute action + // + if (machine.actions[task.action_[iA].type_]) { + o = machine.actions[task.action_[iA].type_](buffer, matches.match_, task.action_[iA].option); + } else if (mhchemParser.actions[task.action_[iA].type_]) { + o = mhchemParser.actions[task.action_[iA].type_](buffer, matches.match_, task.action_[iA].option); + } else { + throw ["MhchemBugA", "mhchem bug A. Please report. (" + task.action_[iA].type_ + ")"]; // Trying to use non-existing action + } + // + // Add output + // + mhchemParser.concatArray(output, o); + } + // + // Set next state, + // Shorten input, + // Continue with next character + // (= apply only one transition per position) + // + state = task.nextState || state; + if (input.length > 0) { + if (!task.revisit) { + input = matches.remainder; + } + if (!task.toContinue) { + break iterateTransitions; + } + } else { + return output; + } + } + } + // + // Prevent infinite loop + // + if (watchdog <= 0) { + throw ["MhchemBugU", "mhchem bug U. Please report."]; // Unexpected character + } + } + }, + concatArray: function (a, b) { + if (b) { + if (Array.isArray(b)) { + for (var iB = 0; iB < b.length; iB++) { + a.push(b[iB]); + } + } else { + a.push(b); + } + } + }, + patterns: { + // + // Matching patterns + // either regexps or function that return null or {match_:"a", remainder:"bc"} + // + patterns: { + // property names must not look like integers ("2") for correct property traversal order, later on + 'empty': /^$/, + 'else': /^./, + 'else2': /^./, + 'space': /^\s/, + 'space A': /^\s(?=[A-Z\\$])/, + 'space$': /^\s$/, + 'a-z': /^[a-z]/, + 'x': /^x/, + 'x$': /^x$/, + 'i$': /^i$/, + 'letters': /^(?:[a-zA-Z\u03B1-\u03C9\u0391-\u03A9?@]|(?:\\(?:alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega|Gamma|Delta|Theta|Lambda|Xi|Pi|Sigma|Upsilon|Phi|Psi|Omega)(?:\s+|\{\}|(?![a-zA-Z]))))+/, + '\\greek': /^\\(?:alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega|Gamma|Delta|Theta|Lambda|Xi|Pi|Sigma|Upsilon|Phi|Psi|Omega)(?:\s+|\{\}|(?![a-zA-Z]))/, + 'one lowercase latin letter $': /^(?:([a-z])(?:$|[^a-zA-Z]))$/, + '$one lowercase latin letter$ $': /^\$(?:([a-z])(?:$|[^a-zA-Z]))\$$/, + 'one lowercase greek letter $': /^(?:\$?[\u03B1-\u03C9]\$?|\$?\\(?:alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega)\s*\$?)(?:\s+|\{\}|(?![a-zA-Z]))$/, + 'digits': /^[0-9]+/, + '-9.,9': /^[+\-]?(?:[0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+))/, + '-9.,9 no missing 0': /^[+\-]?[0-9]+(?:[.,][0-9]+)?/, + '(-)(9.,9)(e)(99)': function (input) { + var m = input.match(/^(\+\-|\+\/\-|\+|\-|\\pm\s?)?([0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+))?(\((?:[0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+))\))?(?:([eE]|\s*(\*|x|\\times|\u00D7)\s*10\^)([+\-]?[0-9]+|\{[+\-]?[0-9]+\}))?/); + if (m && m[0]) { + return { + match_: m.splice(1), + remainder: input.substr(m[0].length) + }; + } + return null; + }, + '(-)(9)^(-9)': function (input) { + var m = input.match(/^(\+\-|\+\/\-|\+|\-|\\pm\s?)?([0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+)?)\^([+\-]?[0-9]+|\{[+\-]?[0-9]+\})/); + if (m && m[0]) { + return { + match_: m.splice(1), + remainder: input.substr(m[0].length) + }; + } + return null; + }, + 'state of aggregation $': function (input) { + // ... or crystal system + var a = mhchemParser.patterns.findObserveGroups(input, "", /^\([a-z]{1,3}(?=[\),])/, ")", ""); // (aq), (aq,$\infty$), (aq, sat) + if (a && a.remainder.match(/^($|[\s,;\)\]\}])/)) { + return a; + } // AND end of 'phrase' + var m = input.match(/^(?:\((?:\\ca\s?)?\$[amothc]\$\))/); // OR crystal system ($o$) (\ca$c$) + if (m) { + return { + match_: m[0], + remainder: input.substr(m[0].length) + }; + } + return null; + }, + '_{(state of aggregation)}$': /^_\{(\([a-z]{1,3}\))\}/, + '{[(': /^(?:\\\{|\[|\()/, + ')]}': /^(?:\)|\]|\\\})/, + ', ': /^[,;]\s*/, + ',': /^[,;]/, + '.': /^[.]/, + '. ': /^([.\u22C5\u00B7\u2022])\s*/, + '...': /^\.\.\.(?=$|[^.])/, + '* ': /^([*])\s*/, + '^{(...)}': function (input) { + return mhchemParser.patterns.findObserveGroups(input, "^{", "", "", "}"); + }, + '^($...$)': function (input) { + return mhchemParser.patterns.findObserveGroups(input, "^", "$", "$", ""); + }, + '^a': /^\^([0-9]+|[^\\_])/, + '^\\x{}{}': function (input) { + return mhchemParser.patterns.findObserveGroups(input, "^", /^\\[a-zA-Z]+\{/, "}", "", "", "{", "}", "", true); + }, + '^\\x{}': function (input) { + return mhchemParser.patterns.findObserveGroups(input, "^", /^\\[a-zA-Z]+\{/, "}", ""); + }, + '^\\x': /^\^(\\[a-zA-Z]+)\s*/, + '^(-1)': /^\^(-?\d+)/, + '\'': /^'/, + '_{(...)}': function (input) { + return mhchemParser.patterns.findObserveGroups(input, "_{", "", "", "}"); + }, + '_($...$)': function (input) { + return mhchemParser.patterns.findObserveGroups(input, "_", "$", "$", ""); + }, + '_9': /^_([+\-]?[0-9]+|[^\\])/, + '_\\x{}{}': function (input) { + return mhchemParser.patterns.findObserveGroups(input, "_", /^\\[a-zA-Z]+\{/, "}", "", "", "{", "}", "", true); + }, + '_\\x{}': function (input) { + return mhchemParser.patterns.findObserveGroups(input, "_", /^\\[a-zA-Z]+\{/, "}", ""); + }, + '_\\x': /^_(\\[a-zA-Z]+)\s*/, + '^_': /^(?:\^(?=_)|\_(?=\^)|[\^_]$)/, + '{}': /^\{\}/, + '{...}': function (input) { + return mhchemParser.patterns.findObserveGroups(input, "", "{", "}", ""); + }, + '{(...)}': function (input) { + return mhchemParser.patterns.findObserveGroups(input, "{", "", "", "}"); + }, + '$...$': function (input) { + return mhchemParser.patterns.findObserveGroups(input, "", "$", "$", ""); + }, + '${(...)}$': function (input) { + return mhchemParser.patterns.findObserveGroups(input, "${", "", "", "}$"); + }, + '$(...)$': function (input) { + return mhchemParser.patterns.findObserveGroups(input, "$", "", "", "$"); + }, + '=<>': /^[=<>]/, + '#': /^[#\u2261]/, + '+': /^\+/, + '-$': /^-(?=[\s_},;\]/]|$|\([a-z]+\))/, + // -space -, -; -] -/ -$ -state-of-aggregation + '-9': /^-(?=[0-9])/, + '- orbital overlap': /^-(?=(?:[spd]|sp)(?:$|[\s,;\)\]\}]))/, + '-': /^-/, + 'pm-operator': /^(?:\\pm|\$\\pm\$|\+-|\+\/-)/, + 'operator': /^(?:\+|(?:[\-=<>]|<<|>>|\\approx|\$\\approx\$)(?=\s|$|-?[0-9]))/, + 'arrowUpDown': /^(?:v|\(v\)|\^|\(\^\))(?=$|[\s,;\)\]\}])/, + '\\bond{(...)}': function (input) { + return mhchemParser.patterns.findObserveGroups(input, "\\bond{", "", "", "}"); + }, + '->': /^(?:<->|<-->|->|<-|<=>>|<<=>|<=>|[\u2192\u27F6\u21CC])/, + 'CMT': /^[CMT](?=\[)/, + '[(...)]': function (input) { + return mhchemParser.patterns.findObserveGroups(input, "[", "", "", "]"); + }, + '1st-level escape': /^(&|\\\\|\\hline)\s*/, + '\\,': /^(?:\\[,\ ;:])/, + // \\x - but output no space before + '\\x{}{}': function (input) { + return mhchemParser.patterns.findObserveGroups(input, "", /^\\[a-zA-Z]+\{/, "}", "", "", "{", "}", "", true); + }, + '\\x{}': function (input) { + return mhchemParser.patterns.findObserveGroups(input, "", /^\\[a-zA-Z]+\{/, "}", ""); + }, + '\\ca': /^\\ca(?:\s+|(?![a-zA-Z]))/, + '\\x': /^(?:\\[a-zA-Z]+\s*|\\[_&{}%])/, + 'orbital': /^(?:[0-9]{1,2}[spdfgh]|[0-9]{0,2}sp)(?=$|[^a-zA-Z])/, + // only those with numbers in front, because the others will be formatted correctly anyway + 'others': /^[\/~|]/, + '\\frac{(...)}': function (input) { + return mhchemParser.patterns.findObserveGroups(input, "\\frac{", "", "", "}", "{", "", "", "}"); + }, + '\\overset{(...)}': function (input) { + return mhchemParser.patterns.findObserveGroups(input, "\\overset{", "", "", "}", "{", "", "", "}"); + }, + '\\underset{(...)}': function (input) { + return mhchemParser.patterns.findObserveGroups(input, "\\underset{", "", "", "}", "{", "", "", "}"); + }, + '\\underbrace{(...)}': function (input) { + return mhchemParser.patterns.findObserveGroups(input, "\\underbrace{", "", "", "}_", "{", "", "", "}"); + }, + '\\color{(...)}0': function (input) { + return mhchemParser.patterns.findObserveGroups(input, "\\color{", "", "", "}"); + }, + '\\color{(...)}{(...)}1': function (input) { + return mhchemParser.patterns.findObserveGroups(input, "\\color{", "", "", "}", "{", "", "", "}"); + }, + '\\color(...){(...)}2': function (input) { + return mhchemParser.patterns.findObserveGroups(input, "\\color", "\\", "", /^(?=\{)/, "{", "", "", "}"); + }, + '\\ce{(...)}': function (input) { + return mhchemParser.patterns.findObserveGroups(input, "\\ce{", "", "", "}"); + }, + 'oxidation$': /^(?:[+-][IVX]+|\\pm\s*0|\$\\pm\$\s*0)$/, + 'd-oxidation$': /^(?:[+-]?\s?[IVX]+|\\pm\s*0|\$\\pm\$\s*0)$/, + // 0 could be oxidation or charge + 'roman numeral': /^[IVX]+/, + '1/2$': /^[+\-]?(?:[0-9]+|\$[a-z]\$|[a-z])\/[0-9]+(?:\$[a-z]\$|[a-z])?$/, + 'amount': function (input) { + var match; + // e.g. 2, 0.5, 1/2, -2, n/2, +; $a$ could be added later in parsing + match = input.match(/^(?:(?:(?:\([+\-]?[0-9]+\/[0-9]+\)|[+\-]?(?:[0-9]+|\$[a-z]\$|[a-z])\/[0-9]+|[+\-]?[0-9]+[.,][0-9]+|[+\-]?\.[0-9]+|[+\-]?[0-9]+)(?:[a-z](?=\s*[A-Z]))?)|[+\-]?[a-z](?=\s*[A-Z])|\+(?!\s))/); + if (match) { + return { + match_: match[0], + remainder: input.substr(match[0].length) + }; + } + var a = mhchemParser.patterns.findObserveGroups(input, "", "$", "$", ""); + if (a) { + // e.g. $2n-1$, $-$ + match = a.match_.match(/^\$(?:\(?[+\-]?(?:[0-9]*[a-z]?[+\-])?[0-9]*[a-z](?:[+\-][0-9]*[a-z]?)?\)?|\+|-)\$$/); + if (match) { + return { + match_: match[0], + remainder: input.substr(match[0].length) + }; + } + } + return null; + }, + 'amount2': function (input) { + return this['amount'](input); + }, + '(KV letters),': /^(?:[A-Z][a-z]{0,2}|i)(?=,)/, + 'formula$': function (input) { + if (input.match(/^\([a-z]+\)$/)) { + return null; + } // state of aggregation = no formula + var match = input.match(/^(?:[a-z]|(?:[0-9\ \+\-\,\.\(\)]+[a-z])+[0-9\ \+\-\,\.\(\)]*|(?:[a-z][0-9\ \+\-\,\.\(\)]+)+[a-z]?)$/); + if (match) { + return { + match_: match[0], + remainder: input.substr(match[0].length) + }; + } + return null; + }, + 'uprightEntities': /^(?:pH|pOH|pC|pK|iPr|iBu)(?=$|[^a-zA-Z])/, + '/': /^\s*(\/)\s*/, + '//': /^\s*(\/\/)\s*/, + '*': /^\s*[*.]\s*/ + }, + findObserveGroups: function (input, begExcl, begIncl, endIncl, endExcl, beg2Excl, beg2Incl, end2Incl, end2Excl, combine) { + /** @type {{(input: string, pattern: string | RegExp): string | string[] | null;}} */ + var _match = function (input, pattern) { + if (typeof pattern === "string") { + if (input.indexOf(pattern) !== 0) { + return null; + } + return pattern; + } else { + var match = input.match(pattern); + if (!match) { + return null; + } + return match[0]; + } + }; + /** @type {{(input: string, i: number, endChars: string | RegExp): {endMatchBegin: number, endMatchEnd: number} | null;}} */ + var _findObserveGroups = function (input, i, endChars) { + var braces = 0; + while (i < input.length) { + var a = input.charAt(i); + var match = _match(input.substr(i), endChars); + if (match !== null && braces === 0) { + return { + endMatchBegin: i, + endMatchEnd: i + match.length + }; + } else if (a === "{") { + braces++; + } else if (a === "}") { + if (braces === 0) { + throw ["ExtraCloseMissingOpen", "Extra close brace or missing open brace"]; + } else { + braces--; + } + } + i++; + } + if (braces > 0) { + return null; + } + return null; + }; + var match = _match(input, begExcl); + if (match === null) { + return null; + } + input = input.substr(match.length); + match = _match(input, begIncl); + if (match === null) { + return null; + } + var e = _findObserveGroups(input, match.length, endIncl || endExcl); + if (e === null) { + return null; + } + var match1 = input.substring(0, endIncl ? e.endMatchEnd : e.endMatchBegin); + if (!(beg2Excl || beg2Incl)) { + return { + match_: match1, + remainder: input.substr(e.endMatchEnd) + }; + } else { + var group2 = this.findObserveGroups(input.substr(e.endMatchEnd), beg2Excl, beg2Incl, end2Incl, end2Excl); + if (group2 === null) { + return null; + } + /** @type {string[]} */ + var matchRet = [match1, group2.match_]; + return { + match_: combine ? matchRet.join("") : matchRet, + remainder: group2.remainder + }; + } + }, + // + // Matching function + // e.g. match("a", input) will look for the regexp called "a" and see if it matches + // returns null or {match_:"a", remainder:"bc"} + // + match_: function (m, input) { + var pattern = mhchemParser.patterns.patterns[m]; + if (pattern === undefined) { + throw ["MhchemBugP", "mhchem bug P. Please report. (" + m + ")"]; // Trying to use non-existing pattern + } else if (typeof pattern === "function") { + return mhchemParser.patterns.patterns[m](input); // cannot use cached var pattern here, because some pattern functions need this===mhchemParser + } else { + // RegExp + var match = input.match(pattern); + if (match) { + var mm; + if (match[2]) { + mm = [match[1], match[2]]; + } else if (match[1]) { + mm = match[1]; + } else { + mm = match[0]; + } + return { + match_: mm, + remainder: input.substr(match[0].length) + }; + } + return null; + } + } + }, + // + // Generic state machine actions + // + actions: { + 'a=': function (buffer, m) { + buffer.a = (buffer.a || "") + m; + }, + 'b=': function (buffer, m) { + buffer.b = (buffer.b || "") + m; + }, + 'p=': function (buffer, m) { + buffer.p = (buffer.p || "") + m; + }, + 'o=': function (buffer, m) { + buffer.o = (buffer.o || "") + m; + }, + 'q=': function (buffer, m) { + buffer.q = (buffer.q || "") + m; + }, + 'd=': function (buffer, m) { + buffer.d = (buffer.d || "") + m; + }, + 'rm=': function (buffer, m) { + buffer.rm = (buffer.rm || "") + m; + }, + 'text=': function (buffer, m) { + buffer.text_ = (buffer.text_ || "") + m; + }, + 'insert': function (buffer, m, a) { + return { + type_: a + }; + }, + 'insert+p1': function (buffer, m, a) { + return { + type_: a, + p1: m + }; + }, + 'insert+p1+p2': function (buffer, m, a) { + return { + type_: a, + p1: m[0], + p2: m[1] + }; + }, + 'copy': function (buffer, m) { + return m; + }, + 'rm': function (buffer, m) { + return { + type_: 'rm', + p1: m || "" + }; + }, + 'text': function (buffer, m) { + return mhchemParser.go(m, 'text'); + }, + '{text}': function (buffer, m) { + var ret = ["{"]; + mhchemParser.concatArray(ret, mhchemParser.go(m, 'text')); + ret.push("}"); + return ret; + }, + 'tex-math': function (buffer, m) { + return mhchemParser.go(m, 'tex-math'); + }, + 'tex-math tight': function (buffer, m) { + return mhchemParser.go(m, 'tex-math tight'); + }, + 'bond': function (buffer, m, k) { + return { + type_: 'bond', + kind_: k || m + }; + }, + 'color0-output': function (buffer, m) { + return { + type_: 'color0', + color: m[0] + }; + }, + 'ce': function (buffer, m) { + return mhchemParser.go(m); + }, + '1/2': function (buffer, m) { + /** @type {ParserOutput[]} */ + var ret = []; + if (m.match(/^[+\-]/)) { + ret.push(m.substr(0, 1)); + m = m.substr(1); + } + var n = m.match(/^([0-9]+|\$[a-z]\$|[a-z])\/([0-9]+)(\$[a-z]\$|[a-z])?$/); + n[1] = n[1].replace(/\$/g, ""); + ret.push({ + type_: 'frac', + p1: n[1], + p2: n[2] + }); + if (n[3]) { + n[3] = n[3].replace(/\$/g, ""); + ret.push({ + type_: 'tex-math', + p1: n[3] + }); + } + return ret; + }, + '9,9': function (buffer, m) { + return mhchemParser.go(m, '9,9'); + } + }, + // + // createTransitions + // convert { 'letter': { 'state': { action_: 'output' } } } to { 'state' => [ { pattern: 'letter', task: { action_: [{type_: 'output'}] } } ] } + // with expansion of 'a|b' to 'a' and 'b' (at 2 places) + // + createTransitions: function (o) { + var pattern, state; + /** @type {string[]} */ + var stateArray; + var i; + // + // 1. Collect all states + // + /** @type {Transitions} */ + var transitions = {}; + for (pattern in o) { + for (state in o[pattern]) { + stateArray = state.split("|"); + o[pattern][state].stateArray = stateArray; + for (i = 0; i < stateArray.length; i++) { + transitions[stateArray[i]] = []; + } + } + } + // + // 2. Fill states + // + for (pattern in o) { + for (state in o[pattern]) { + stateArray = o[pattern][state].stateArray || []; + for (i = 0; i < stateArray.length; i++) { + // + // 2a. Normalize actions into array: 'text=' ==> [{type_:'text='}] + // (Note to myself: Resolving the function here would be problematic. It would need .bind (for *this*) and currying (for *option*).) + // + /** @type {any} */ + var p = o[pattern][state]; + if (p.action_) { + p.action_ = [].concat(p.action_); + for (var k = 0; k < p.action_.length; k++) { + if (typeof p.action_[k] === "string") { + p.action_[k] = { + type_: p.action_[k] + }; + } + } + } else { + p.action_ = []; + } + // + // 2.b Multi-insert + // + var patternArray = pattern.split("|"); + for (var j = 0; j < patternArray.length; j++) { + if (stateArray[i] === '*') { + // insert into all + for (var t in transitions) { + transitions[t].push({ + pattern: patternArray[j], + task: p + }); + } + } else { + transitions[stateArray[i]].push({ + pattern: patternArray[j], + task: p + }); + } + } + } + } + } + return transitions; + }, + stateMachines: {} +}; + +// +// Definition of state machines +// +mhchemParser.stateMachines = { + // + // \ce state machines + // + //#region ce + 'ce': { + // main parser + transitions: mhchemParser.createTransitions({ + 'empty': { + '*': { + action_: 'output' + } + }, + 'else': { + '0|1|2': { + action_: 'beginsWithBond=false', + revisit: true, + toContinue: true + } + }, + 'oxidation$': { + '0': { + action_: 'oxidation-output' + } + }, + 'CMT': { + 'r': { + action_: 'rdt=', + nextState: 'rt' + }, + 'rd': { + action_: 'rqt=', + nextState: 'rdt' + } + }, + 'arrowUpDown': { + '0|1|2|as': { + action_: ['sb=false', 'output', 'operator'], + nextState: '1' + } + }, + 'uprightEntities': { + '0|1|2': { + action_: ['o=', 'output'], + nextState: '1' + } + }, + 'orbital': { + '0|1|2|3': { + action_: 'o=', + nextState: 'o' + } + }, + '->': { + '0|1|2|3': { + action_: 'r=', + nextState: 'r' + }, + 'a|as': { + action_: ['output', 'r='], + nextState: 'r' + }, + '*': { + action_: ['output', 'r='], + nextState: 'r' + } + }, + '+': { + 'o': { + action_: 'd= kv', + nextState: 'd' + }, + 'd|D': { + action_: 'd=', + nextState: 'd' + }, + 'q': { + action_: 'd=', + nextState: 'qd' + }, + 'qd|qD': { + action_: 'd=', + nextState: 'qd' + }, + 'dq': { + action_: ['output', 'd='], + nextState: 'd' + }, + '3': { + action_: ['sb=false', 'output', 'operator'], + nextState: '0' + } + }, + 'amount': { + '0|2': { + action_: 'a=', + nextState: 'a' + } + }, + 'pm-operator': { + '0|1|2|a|as': { + action_: ['sb=false', 'output', { + type_: 'operator', + option: '\\pm' + }], + nextState: '0' + } + }, + 'operator': { + '0|1|2|a|as': { + action_: ['sb=false', 'output', 'operator'], + nextState: '0' + } + }, + '-$': { + 'o|q': { + action_: ['charge or bond', 'output'], + nextState: 'qd' + }, + 'd': { + action_: 'd=', + nextState: 'd' + }, + 'D': { + action_: ['output', { + type_: 'bond', + option: "-" + }], + nextState: '3' + }, + 'q': { + action_: 'd=', + nextState: 'qd' + }, + 'qd': { + action_: 'd=', + nextState: 'qd' + }, + 'qD|dq': { + action_: ['output', { + type_: 'bond', + option: "-" + }], + nextState: '3' + } + }, + '-9': { + '3|o': { + action_: ['output', { + type_: 'insert', + option: 'hyphen' + }], + nextState: '3' + } + }, + '- orbital overlap': { + 'o': { + action_: ['output', { + type_: 'insert', + option: 'hyphen' + }], + nextState: '2' + }, + 'd': { + action_: ['output', { + type_: 'insert', + option: 'hyphen' + }], + nextState: '2' + } + }, + '-': { + '0|1|2': { + action_: [{ + type_: 'output', + option: 1 + }, 'beginsWithBond=true', { + type_: 'bond', + option: "-" + }], + nextState: '3' + }, + '3': { + action_: { + type_: 'bond', + option: "-" + } + }, + 'a': { + action_: ['output', { + type_: 'insert', + option: 'hyphen' + }], + nextState: '2' + }, + 'as': { + action_: [{ + type_: 'output', + option: 2 + }, { + type_: 'bond', + option: "-" + }], + nextState: '3' + }, + 'b': { + action_: 'b=' + }, + 'o': { + action_: { + type_: '- after o/d', + option: false + }, + nextState: '2' + }, + 'q': { + action_: { + type_: '- after o/d', + option: false + }, + nextState: '2' + }, + 'd|qd|dq': { + action_: { + type_: '- after o/d', + option: true + }, + nextState: '2' + }, + 'D|qD|p': { + action_: ['output', { + type_: 'bond', + option: "-" + }], + nextState: '3' + } + }, + 'amount2': { + '1|3': { + action_: 'a=', + nextState: 'a' + } + }, + 'letters': { + '0|1|2|3|a|as|b|p|bp|o': { + action_: 'o=', + nextState: 'o' + }, + 'q|dq': { + action_: ['output', 'o='], + nextState: 'o' + }, + 'd|D|qd|qD': { + action_: 'o after d', + nextState: 'o' + } + }, + 'digits': { + 'o': { + action_: 'q=', + nextState: 'q' + }, + 'd|D': { + action_: 'q=', + nextState: 'dq' + }, + 'q': { + action_: ['output', 'o='], + nextState: 'o' + }, + 'a': { + action_: 'o=', + nextState: 'o' + } + }, + 'space A': { + 'b|p|bp': {} + }, + 'space': { + 'a': { + nextState: 'as' + }, + '0': { + action_: 'sb=false' + }, + '1|2': { + action_: 'sb=true' + }, + 'r|rt|rd|rdt|rdq': { + action_: 'output', + nextState: '0' + }, + '*': { + action_: ['output', 'sb=true'], + nextState: '1' + } + }, + '1st-level escape': { + '1|2': { + action_: ['output', { + type_: 'insert+p1', + option: '1st-level escape' + }] + }, + '*': { + action_: ['output', { + type_: 'insert+p1', + option: '1st-level escape' + }], + nextState: '0' + } + }, + '[(...)]': { + 'r|rt': { + action_: 'rd=', + nextState: 'rd' + }, + 'rd|rdt': { + action_: 'rq=', + nextState: 'rdq' + } + }, + '...': { + 'o|d|D|dq|qd|qD': { + action_: ['output', { + type_: 'bond', + option: "..." + }], + nextState: '3' + }, + '*': { + action_: [{ + type_: 'output', + option: 1 + }, { + type_: 'insert', + option: 'ellipsis' + }], + nextState: '1' + } + }, + '. |* ': { + '*': { + action_: ['output', { + type_: 'insert', + option: 'addition compound' + }], + nextState: '1' + } + }, + 'state of aggregation $': { + '*': { + action_: ['output', 'state of aggregation'], + nextState: '1' + } + }, + '{[(': { + 'a|as|o': { + action_: ['o=', 'output', 'parenthesisLevel++'], + nextState: '2' + }, + '0|1|2|3': { + action_: ['o=', 'output', 'parenthesisLevel++'], + nextState: '2' + }, + '*': { + action_: ['output', 'o=', 'output', 'parenthesisLevel++'], + nextState: '2' + } + }, + ')]}': { + '0|1|2|3|b|p|bp|o': { + action_: ['o=', 'parenthesisLevel--'], + nextState: 'o' + }, + 'a|as|d|D|q|qd|qD|dq': { + action_: ['output', 'o=', 'parenthesisLevel--'], + nextState: 'o' + } + }, + ', ': { + '*': { + action_: ['output', 'comma'], + nextState: '0' + } + }, + '^_': { + // ^ and _ without a sensible argument + '*': {} + }, + '^{(...)}|^($...$)': { + '0|1|2|as': { + action_: 'b=', + nextState: 'b' + }, + 'p': { + action_: 'b=', + nextState: 'bp' + }, + '3|o': { + action_: 'd= kv', + nextState: 'D' + }, + 'q': { + action_: 'd=', + nextState: 'qD' + }, + 'd|D|qd|qD|dq': { + action_: ['output', 'd='], + nextState: 'D' + } + }, + '^a|^\\x{}{}|^\\x{}|^\\x|\'': { + '0|1|2|as': { + action_: 'b=', + nextState: 'b' + }, + 'p': { + action_: 'b=', + nextState: 'bp' + }, + '3|o': { + action_: 'd= kv', + nextState: 'd' + }, + 'q': { + action_: 'd=', + nextState: 'qd' + }, + 'd|qd|D|qD': { + action_: 'd=' + }, + 'dq': { + action_: ['output', 'd='], + nextState: 'd' + } + }, + '_{(state of aggregation)}$': { + 'd|D|q|qd|qD|dq': { + action_: ['output', 'q='], + nextState: 'q' + } + }, + '_{(...)}|_($...$)|_9|_\\x{}{}|_\\x{}|_\\x': { + '0|1|2|as': { + action_: 'p=', + nextState: 'p' + }, + 'b': { + action_: 'p=', + nextState: 'bp' + }, + '3|o': { + action_: 'q=', + nextState: 'q' + }, + 'd|D': { + action_: 'q=', + nextState: 'dq' + }, + 'q|qd|qD|dq': { + action_: ['output', 'q='], + nextState: 'q' + } + }, + '=<>': { + '0|1|2|3|a|as|o|q|d|D|qd|qD|dq': { + action_: [{ + type_: 'output', + option: 2 + }, 'bond'], + nextState: '3' + } + }, + '#': { + '0|1|2|3|a|as|o': { + action_: [{ + type_: 'output', + option: 2 + }, { + type_: 'bond', + option: "#" + }], + nextState: '3' + } + }, + '{}': { + '*': { + action_: { + type_: 'output', + option: 1 + }, + nextState: '1' + } + }, + '{...}': { + '0|1|2|3|a|as|b|p|bp': { + action_: 'o=', + nextState: 'o' + }, + 'o|d|D|q|qd|qD|dq': { + action_: ['output', 'o='], + nextState: 'o' + } + }, + '$...$': { + 'a': { + action_: 'a=' + }, + // 2$n$ + '0|1|2|3|as|b|p|bp|o': { + action_: 'o=', + nextState: 'o' + }, + // not 'amount' + 'as|o': { + action_: 'o=' + }, + 'q|d|D|qd|qD|dq': { + action_: ['output', 'o='], + nextState: 'o' + } + }, + '\\bond{(...)}': { + '*': { + action_: [{ + type_: 'output', + option: 2 + }, 'bond'], + nextState: "3" + } + }, + '\\frac{(...)}': { + '*': { + action_: [{ + type_: 'output', + option: 1 + }, 'frac-output'], + nextState: '3' + } + }, + '\\overset{(...)}': { + '*': { + action_: [{ + type_: 'output', + option: 2 + }, 'overset-output'], + nextState: '3' + } + }, + '\\underset{(...)}': { + '*': { + action_: [{ + type_: 'output', + option: 2 + }, 'underset-output'], + nextState: '3' + } + }, + '\\underbrace{(...)}': { + '*': { + action_: [{ + type_: 'output', + option: 2 + }, 'underbrace-output'], + nextState: '3' + } + }, + '\\color{(...)}{(...)}1|\\color(...){(...)}2': { + '*': { + action_: [{ + type_: 'output', + option: 2 + }, 'color-output'], + nextState: '3' + } + }, + '\\color{(...)}0': { + '*': { + action_: [{ + type_: 'output', + option: 2 + }, 'color0-output'] + } + }, + '\\ce{(...)}': { + '*': { + action_: [{ + type_: 'output', + option: 2 + }, 'ce'], + nextState: '3' + } + }, + '\\,': { + '*': { + action_: [{ + type_: 'output', + option: 1 + }, 'copy'], + nextState: '1' + } + }, + '\\x{}{}|\\x{}|\\x': { + '0|1|2|3|a|as|b|p|bp|o|c0': { + action_: ['o=', 'output'], + nextState: '3' + }, + '*': { + action_: ['output', 'o=', 'output'], + nextState: '3' + } + }, + 'others': { + '*': { + action_: [{ + type_: 'output', + option: 1 + }, 'copy'], + nextState: '3' + } + }, + 'else2': { + 'a': { + action_: 'a to o', + nextState: 'o', + revisit: true + }, + 'as': { + action_: ['output', 'sb=true'], + nextState: '1', + revisit: true + }, + 'r|rt|rd|rdt|rdq': { + action_: ['output'], + nextState: '0', + revisit: true + }, + '*': { + action_: ['output', 'copy'], + nextState: '3' + } + } + }), + actions: { + 'o after d': function (buffer, m) { + var ret; + if ((buffer.d || "").match(/^[0-9]+$/)) { + var tmp = buffer.d; + buffer.d = undefined; + ret = this['output'](buffer); + buffer.b = tmp; + } else { + ret = this['output'](buffer); + } + mhchemParser.actions['o='](buffer, m); + return ret; + }, + 'd= kv': function (buffer, m) { + buffer.d = m; + buffer.dType = 'kv'; + }, + 'charge or bond': function (buffer, m) { + if (buffer['beginsWithBond']) { + /** @type {ParserOutput[]} */ + var ret = []; + mhchemParser.concatArray(ret, this['output'](buffer)); + mhchemParser.concatArray(ret, mhchemParser.actions['bond'](buffer, m, "-")); + return ret; + } else { + buffer.d = m; + } + }, + '- after o/d': function (buffer, m, isAfterD) { + var c1 = mhchemParser.patterns.match_('orbital', buffer.o || ""); + var c2 = mhchemParser.patterns.match_('one lowercase greek letter $', buffer.o || ""); + var c3 = mhchemParser.patterns.match_('one lowercase latin letter $', buffer.o || ""); + var c4 = mhchemParser.patterns.match_('$one lowercase latin letter$ $', buffer.o || ""); + var hyphenFollows = m === "-" && (c1 && c1.remainder === "" || c2 || c3 || c4); + if (hyphenFollows && !buffer.a && !buffer.b && !buffer.p && !buffer.d && !buffer.q && !c1 && c3) { + buffer.o = '$' + buffer.o + '$'; + } + /** @type {ParserOutput[]} */ + var ret = []; + if (hyphenFollows) { + mhchemParser.concatArray(ret, this['output'](buffer)); + ret.push({ + type_: 'hyphen' + }); + } else { + c1 = mhchemParser.patterns.match_('digits', buffer.d || ""); + if (isAfterD && c1 && c1.remainder === '') { + mhchemParser.concatArray(ret, mhchemParser.actions['d='](buffer, m)); + mhchemParser.concatArray(ret, this['output'](buffer)); + } else { + mhchemParser.concatArray(ret, this['output'](buffer)); + mhchemParser.concatArray(ret, mhchemParser.actions['bond'](buffer, m, "-")); + } + } + return ret; + }, + 'a to o': function (buffer) { + buffer.o = buffer.a; + buffer.a = undefined; + }, + 'sb=true': function (buffer) { + buffer.sb = true; + }, + 'sb=false': function (buffer) { + buffer.sb = false; + }, + 'beginsWithBond=true': function (buffer) { + buffer['beginsWithBond'] = true; + }, + 'beginsWithBond=false': function (buffer) { + buffer['beginsWithBond'] = false; + }, + 'parenthesisLevel++': function (buffer) { + buffer['parenthesisLevel']++; + }, + 'parenthesisLevel--': function (buffer) { + buffer['parenthesisLevel']--; + }, + 'state of aggregation': function (buffer, m) { + return { + type_: 'state of aggregation', + p1: mhchemParser.go(m, 'o') + }; + }, + 'comma': function (buffer, m) { + var a = m.replace(/\s*$/, ''); + var withSpace = a !== m; + if (withSpace && buffer['parenthesisLevel'] === 0) { + return { + type_: 'comma enumeration L', + p1: a + }; + } else { + return { + type_: 'comma enumeration M', + p1: a + }; + } + }, + 'output': function (buffer, m, entityFollows) { + // entityFollows: + // undefined = if we have nothing else to output, also ignore the just read space (buffer.sb) + // 1 = an entity follows, never omit the space if there was one just read before (can only apply to state 1) + // 2 = 1 + the entity can have an amount, so output a\, instead of converting it to o (can only apply to states a|as) + /** @type {ParserOutput | ParserOutput[]} */ + var ret; + if (!buffer.r) { + ret = []; + if (!buffer.a && !buffer.b && !buffer.p && !buffer.o && !buffer.q && !buffer.d && !entityFollows) { + //ret = []; + } else { + if (buffer.sb) { + ret.push({ + type_: 'entitySkip' + }); + } + if (!buffer.o && !buffer.q && !buffer.d && !buffer.b && !buffer.p && entityFollows !== 2) { + buffer.o = buffer.a; + buffer.a = undefined; + } else if (!buffer.o && !buffer.q && !buffer.d && (buffer.b || buffer.p)) { + buffer.o = buffer.a; + buffer.d = buffer.b; + buffer.q = buffer.p; + buffer.a = buffer.b = buffer.p = undefined; + } else { + if (buffer.o && buffer.dType === 'kv' && mhchemParser.patterns.match_('d-oxidation$', buffer.d || "")) { + buffer.dType = 'oxidation'; + } else if (buffer.o && buffer.dType === 'kv' && !buffer.q) { + buffer.dType = undefined; + } + } + ret.push({ + type_: 'chemfive', + a: mhchemParser.go(buffer.a, 'a'), + b: mhchemParser.go(buffer.b, 'bd'), + p: mhchemParser.go(buffer.p, 'pq'), + o: mhchemParser.go(buffer.o, 'o'), + q: mhchemParser.go(buffer.q, 'pq'), + d: mhchemParser.go(buffer.d, buffer.dType === 'oxidation' ? 'oxidation' : 'bd'), + dType: buffer.dType + }); + } + } else { + // r + /** @type {ParserOutput[]} */ + var rd; + if (buffer.rdt === 'M') { + rd = mhchemParser.go(buffer.rd, 'tex-math'); + } else if (buffer.rdt === 'T') { + rd = [{ + type_: 'text', + p1: buffer.rd || "" + }]; + } else { + rd = mhchemParser.go(buffer.rd); + } + /** @type {ParserOutput[]} */ + var rq; + if (buffer.rqt === 'M') { + rq = mhchemParser.go(buffer.rq, 'tex-math'); + } else if (buffer.rqt === 'T') { + rq = [{ + type_: 'text', + p1: buffer.rq || "" + }]; + } else { + rq = mhchemParser.go(buffer.rq); + } + ret = { + type_: 'arrow', + r: buffer.r, + rd: rd, + rq: rq + }; + } + for (var p in buffer) { + if (p !== 'parenthesisLevel' && p !== 'beginsWithBond') { + delete buffer[p]; + } + } + return ret; + }, + 'oxidation-output': function (buffer, m) { + var ret = ["{"]; + mhchemParser.concatArray(ret, mhchemParser.go(m, 'oxidation')); + ret.push("}"); + return ret; + }, + 'frac-output': function (buffer, m) { + return { + type_: 'frac-ce', + p1: mhchemParser.go(m[0]), + p2: mhchemParser.go(m[1]) + }; + }, + 'overset-output': function (buffer, m) { + return { + type_: 'overset', + p1: mhchemParser.go(m[0]), + p2: mhchemParser.go(m[1]) + }; + }, + 'underset-output': function (buffer, m) { + return { + type_: 'underset', + p1: mhchemParser.go(m[0]), + p2: mhchemParser.go(m[1]) + }; + }, + 'underbrace-output': function (buffer, m) { + return { + type_: 'underbrace', + p1: mhchemParser.go(m[0]), + p2: mhchemParser.go(m[1]) + }; + }, + 'color-output': function (buffer, m) { + return { + type_: 'color', + color1: m[0], + color2: mhchemParser.go(m[1]) + }; + }, + 'r=': function (buffer, m) { + buffer.r = m; + }, + 'rdt=': function (buffer, m) { + buffer.rdt = m; + }, + 'rd=': function (buffer, m) { + buffer.rd = m; + }, + 'rqt=': function (buffer, m) { + buffer.rqt = m; + }, + 'rq=': function (buffer, m) { + buffer.rq = m; + }, + 'operator': function (buffer, m, p1) { + return { + type_: 'operator', + kind_: p1 || m + }; + } + } + }, + 'a': { + transitions: mhchemParser.createTransitions({ + 'empty': { + '*': {} + }, + '1/2$': { + '0': { + action_: '1/2' + } + }, + 'else': { + '0': { + nextState: '1', + revisit: true + } + }, + '$(...)$': { + '*': { + action_: 'tex-math tight', + nextState: '1' + } + }, + ',': { + '*': { + action_: { + type_: 'insert', + option: 'commaDecimal' + } + } + }, + 'else2': { + '*': { + action_: 'copy' + } + } + }), + actions: {} + }, + 'o': { + transitions: mhchemParser.createTransitions({ + 'empty': { + '*': {} + }, + '1/2$': { + '0': { + action_: '1/2' + } + }, + 'else': { + '0': { + nextState: '1', + revisit: true + } + }, + 'letters': { + '*': { + action_: 'rm' + } + }, + '\\ca': { + '*': { + action_: { + type_: 'insert', + option: 'circa' + } + } + }, + '\\x{}{}|\\x{}|\\x': { + '*': { + action_: 'copy' + } + }, + '${(...)}$|$(...)$': { + '*': { + action_: 'tex-math' + } + }, + '{(...)}': { + '*': { + action_: '{text}' + } + }, + 'else2': { + '*': { + action_: 'copy' + } + } + }), + actions: {} + }, + 'text': { + transitions: mhchemParser.createTransitions({ + 'empty': { + '*': { + action_: 'output' + } + }, + '{...}': { + '*': { + action_: 'text=' + } + }, + '${(...)}$|$(...)$': { + '*': { + action_: 'tex-math' + } + }, + '\\greek': { + '*': { + action_: ['output', 'rm'] + } + }, + '\\,|\\x{}{}|\\x{}|\\x': { + '*': { + action_: ['output', 'copy'] + } + }, + 'else': { + '*': { + action_: 'text=' + } + } + }), + actions: { + 'output': function (buffer) { + if (buffer.text_) { + /** @type {ParserOutput} */ + var ret = { + type_: 'text', + p1: buffer.text_ + }; + for (var p in buffer) { + delete buffer[p]; + } + return ret; + } + } + } + }, + 'pq': { + transitions: mhchemParser.createTransitions({ + 'empty': { + '*': {} + }, + 'state of aggregation $': { + '*': { + action_: 'state of aggregation' + } + }, + 'i$': { + '0': { + nextState: '!f', + revisit: true + } + }, + '(KV letters),': { + '0': { + action_: 'rm', + nextState: '0' + } + }, + 'formula$': { + '0': { + nextState: 'f', + revisit: true + } + }, + '1/2$': { + '0': { + action_: '1/2' + } + }, + 'else': { + '0': { + nextState: '!f', + revisit: true + } + }, + '${(...)}$|$(...)$': { + '*': { + action_: 'tex-math' + } + }, + '{(...)}': { + '*': { + action_: 'text' + } + }, + 'a-z': { + 'f': { + action_: 'tex-math' + } + }, + 'letters': { + '*': { + action_: 'rm' + } + }, + '-9.,9': { + '*': { + action_: '9,9' + } + }, + ',': { + '*': { + action_: { + type_: 'insert+p1', + option: 'comma enumeration S' + } + } + }, + '\\color{(...)}{(...)}1|\\color(...){(...)}2': { + '*': { + action_: 'color-output' + } + }, + '\\color{(...)}0': { + '*': { + action_: 'color0-output' + } + }, + '\\ce{(...)}': { + '*': { + action_: 'ce' + } + }, + '\\,|\\x{}{}|\\x{}|\\x': { + '*': { + action_: 'copy' + } + }, + 'else2': { + '*': { + action_: 'copy' + } + } + }), + actions: { + 'state of aggregation': function (buffer, m) { + return { + type_: 'state of aggregation subscript', + p1: mhchemParser.go(m, 'o') + }; + }, + 'color-output': function (buffer, m) { + return { + type_: 'color', + color1: m[0], + color2: mhchemParser.go(m[1], 'pq') + }; + } + } + }, + 'bd': { + transitions: mhchemParser.createTransitions({ + 'empty': { + '*': {} + }, + 'x$': { + '0': { + nextState: '!f', + revisit: true + } + }, + 'formula$': { + '0': { + nextState: 'f', + revisit: true + } + }, + 'else': { + '0': { + nextState: '!f', + revisit: true + } + }, + '-9.,9 no missing 0': { + '*': { + action_: '9,9' + } + }, + '.': { + '*': { + action_: { + type_: 'insert', + option: 'electron dot' + } + } + }, + 'a-z': { + 'f': { + action_: 'tex-math' + } + }, + 'x': { + '*': { + action_: { + type_: 'insert', + option: 'KV x' + } + } + }, + 'letters': { + '*': { + action_: 'rm' + } + }, + '\'': { + '*': { + action_: { + type_: 'insert', + option: 'prime' + } + } + }, + '${(...)}$|$(...)$': { + '*': { + action_: 'tex-math' + } + }, + '{(...)}': { + '*': { + action_: 'text' + } + }, + '\\color{(...)}{(...)}1|\\color(...){(...)}2': { + '*': { + action_: 'color-output' + } + }, + '\\color{(...)}0': { + '*': { + action_: 'color0-output' + } + }, + '\\ce{(...)}': { + '*': { + action_: 'ce' + } + }, + '\\,|\\x{}{}|\\x{}|\\x': { + '*': { + action_: 'copy' + } + }, + 'else2': { + '*': { + action_: 'copy' + } + } + }), + actions: { + 'color-output': function (buffer, m) { + return { + type_: 'color', + color1: m[0], + color2: mhchemParser.go(m[1], 'bd') + }; + } + } + }, + 'oxidation': { + transitions: mhchemParser.createTransitions({ + 'empty': { + '*': {} + }, + 'roman numeral': { + '*': { + action_: 'roman-numeral' + } + }, + '${(...)}$|$(...)$': { + '*': { + action_: 'tex-math' + } + }, + 'else': { + '*': { + action_: 'copy' + } + } + }), + actions: { + 'roman-numeral': function (buffer, m) { + return { + type_: 'roman numeral', + p1: m || "" + }; + } + } + }, + 'tex-math': { + transitions: mhchemParser.createTransitions({ + 'empty': { + '*': { + action_: 'output' + } + }, + '\\ce{(...)}': { + '*': { + action_: ['output', 'ce'] + } + }, + '{...}|\\,|\\x{}{}|\\x{}|\\x': { + '*': { + action_: 'o=' + } + }, + 'else': { + '*': { + action_: 'o=' + } + } + }), + actions: { + 'output': function (buffer) { + if (buffer.o) { + /** @type {ParserOutput} */ + var ret = { + type_: 'tex-math', + p1: buffer.o + }; + for (var p in buffer) { + delete buffer[p]; + } + return ret; + } + } + } + }, + 'tex-math tight': { + transitions: mhchemParser.createTransitions({ + 'empty': { + '*': { + action_: 'output' + } + }, + '\\ce{(...)}': { + '*': { + action_: ['output', 'ce'] + } + }, + '{...}|\\,|\\x{}{}|\\x{}|\\x': { + '*': { + action_: 'o=' + } + }, + '-|+': { + '*': { + action_: 'tight operator' + } + }, + 'else': { + '*': { + action_: 'o=' + } + } + }), + actions: { + 'tight operator': function (buffer, m) { + buffer.o = (buffer.o || "") + "{" + m + "}"; + }, + 'output': function (buffer) { + if (buffer.o) { + /** @type {ParserOutput} */ + var ret = { + type_: 'tex-math', + p1: buffer.o + }; + for (var p in buffer) { + delete buffer[p]; + } + return ret; + } + } + } + }, + '9,9': { + transitions: mhchemParser.createTransitions({ + 'empty': { + '*': {} + }, + ',': { + '*': { + action_: 'comma' + } + }, + 'else': { + '*': { + action_: 'copy' + } + } + }), + actions: { + 'comma': function () { + return { + type_: 'commaDecimal' + }; + } + } + }, + //#endregion + // + // \pu state machines + // + //#region pu + 'pu': { + transitions: mhchemParser.createTransitions({ + 'empty': { + '*': { + action_: 'output' + } + }, + 'space$': { + '*': { + action_: ['output', 'space'] + } + }, + '{[(|)]}': { + '0|a': { + action_: 'copy' + } + }, + '(-)(9)^(-9)': { + '0': { + action_: 'number^', + nextState: 'a' + } + }, + '(-)(9.,9)(e)(99)': { + '0': { + action_: 'enumber', + nextState: 'a' + } + }, + 'space': { + '0|a': {} + }, + 'pm-operator': { + '0|a': { + action_: { + type_: 'operator', + option: '\\pm' + }, + nextState: '0' + } + }, + 'operator': { + '0|a': { + action_: 'copy', + nextState: '0' + } + }, + '//': { + 'd': { + action_: 'o=', + nextState: '/' + } + }, + '/': { + 'd': { + action_: 'o=', + nextState: '/' + } + }, + '{...}|else': { + '0|d': { + action_: 'd=', + nextState: 'd' + }, + 'a': { + action_: ['space', 'd='], + nextState: 'd' + }, + '/|q': { + action_: 'q=', + nextState: 'q' + } + } + }), + actions: { + 'enumber': function (buffer, m) { + /** @type {ParserOutput[]} */ + var ret = []; + if (m[0] === "+-" || m[0] === "+/-") { + ret.push("\\pm "); + } else if (m[0]) { + ret.push(m[0]); + } + if (m[1]) { + mhchemParser.concatArray(ret, mhchemParser.go(m[1], 'pu-9,9')); + if (m[2]) { + if (m[2].match(/[,.]/)) { + mhchemParser.concatArray(ret, mhchemParser.go(m[2], 'pu-9,9')); + } else { + ret.push(m[2]); + } + } + m[3] = m[4] || m[3]; + if (m[3]) { + m[3] = m[3].trim(); + if (m[3] === "e" || m[3].substr(0, 1) === "*") { + ret.push({ + type_: 'cdot' + }); + } else { + ret.push({ + type_: 'times' + }); + } + } + } + if (m[3]) { + ret.push("10^{" + m[5] + "}"); + } + return ret; + }, + 'number^': function (buffer, m) { + /** @type {ParserOutput[]} */ + var ret = []; + if (m[0] === "+-" || m[0] === "+/-") { + ret.push("\\pm "); + } else if (m[0]) { + ret.push(m[0]); + } + mhchemParser.concatArray(ret, mhchemParser.go(m[1], 'pu-9,9')); + ret.push("^{" + m[2] + "}"); + return ret; + }, + 'operator': function (buffer, m, p1) { + return { + type_: 'operator', + kind_: p1 || m + }; + }, + 'space': function () { + return { + type_: 'pu-space-1' + }; + }, + 'output': function (buffer) { + /** @type {ParserOutput | ParserOutput[]} */ + var ret; + var md = mhchemParser.patterns.match_('{(...)}', buffer.d || ""); + if (md && md.remainder === '') { + buffer.d = md.match_; + } + var mq = mhchemParser.patterns.match_('{(...)}', buffer.q || ""); + if (mq && mq.remainder === '') { + buffer.q = mq.match_; + } + if (buffer.d) { + buffer.d = buffer.d.replace(/\u00B0C|\^oC|\^{o}C/g, "{}^{\\circ}C"); + buffer.d = buffer.d.replace(/\u00B0F|\^oF|\^{o}F/g, "{}^{\\circ}F"); + } + if (buffer.q) { + // fraction + buffer.q = buffer.q.replace(/\u00B0C|\^oC|\^{o}C/g, "{}^{\\circ}C"); + buffer.q = buffer.q.replace(/\u00B0F|\^oF|\^{o}F/g, "{}^{\\circ}F"); + var b5 = { + d: mhchemParser.go(buffer.d, 'pu'), + q: mhchemParser.go(buffer.q, 'pu') + }; + if (buffer.o === '//') { + ret = { + type_: 'pu-frac', + p1: b5.d, + p2: b5.q + }; + } else { + ret = b5.d; + if (b5.d.length > 1 || b5.q.length > 1) { + ret.push({ + type_: ' / ' + }); + } else { + ret.push({ + type_: '/' + }); + } + mhchemParser.concatArray(ret, b5.q); + } + } else { + // no fraction + ret = mhchemParser.go(buffer.d, 'pu-2'); + } + for (var p in buffer) { + delete buffer[p]; + } + return ret; + } + } + }, + 'pu-2': { + transitions: mhchemParser.createTransitions({ + 'empty': { + '*': { + action_: 'output' + } + }, + '*': { + '*': { + action_: ['output', 'cdot'], + nextState: '0' + } + }, + '\\x': { + '*': { + action_: 'rm=' + } + }, + 'space': { + '*': { + action_: ['output', 'space'], + nextState: '0' + } + }, + '^{(...)}|^(-1)': { + '1': { + action_: '^(-1)' + } + }, + '-9.,9': { + '0': { + action_: 'rm=', + nextState: '0' + }, + '1': { + action_: '^(-1)', + nextState: '0' + } + }, + '{...}|else': { + '*': { + action_: 'rm=', + nextState: '1' + } + } + }), + actions: { + 'cdot': function () { + return { + type_: 'tight cdot' + }; + }, + '^(-1)': function (buffer, m) { + buffer.rm += "^{" + m + "}"; + }, + 'space': function () { + return { + type_: 'pu-space-2' + }; + }, + 'output': function (buffer) { + /** @type {ParserOutput | ParserOutput[]} */ + var ret = []; + if (buffer.rm) { + var mrm = mhchemParser.patterns.match_('{(...)}', buffer.rm || ""); + if (mrm && mrm.remainder === '') { + ret = mhchemParser.go(mrm.match_, 'pu'); + } else { + ret = { + type_: 'rm', + p1: buffer.rm + }; + } + } + for (var p in buffer) { + delete buffer[p]; + } + return ret; + } + } + }, + 'pu-9,9': { + transitions: mhchemParser.createTransitions({ + 'empty': { + '0': { + action_: 'output-0' + }, + 'o': { + action_: 'output-o' + } + }, + ',': { + '0': { + action_: ['output-0', 'comma'], + nextState: 'o' + } + }, + '.': { + '0': { + action_: ['output-0', 'copy'], + nextState: 'o' + } + }, + 'else': { + '*': { + action_: 'text=' + } + } + }), + actions: { + 'comma': function () { + return { + type_: 'commaDecimal' + }; + }, + 'output-0': function (buffer) { + /** @type {ParserOutput[]} */ + var ret = []; + buffer.text_ = buffer.text_ || ""; + if (buffer.text_.length > 4) { + var a = buffer.text_.length % 3; + if (a === 0) { + a = 3; + } + for (var i = buffer.text_.length - 3; i > 0; i -= 3) { + ret.push(buffer.text_.substr(i, 3)); + ret.push({ + type_: '1000 separator' + }); + } + ret.push(buffer.text_.substr(0, a)); + ret.reverse(); + } else { + ret.push(buffer.text_); + } + for (var p in buffer) { + delete buffer[p]; + } + return ret; + }, + 'output-o': function (buffer) { + /** @type {ParserOutput[]} */ + var ret = []; + buffer.text_ = buffer.text_ || ""; + if (buffer.text_.length > 4) { + var a = buffer.text_.length - 3; + for (var i = 0; i < a; i += 3) { + ret.push(buffer.text_.substr(i, 3)); + ret.push({ + type_: '1000 separator' + }); + } + ret.push(buffer.text_.substr(i)); + } else { + ret.push(buffer.text_); + } + for (var p in buffer) { + delete buffer[p]; + } + return ret; + } + } + } + //#endregion +}; + +// +// texify: Take MhchemParser output and convert it to TeX +// +/** @type {Texify} */ +var texify = { + go: function (input, isInner) { + // (recursive, max 4 levels) + if (!input) { + return ""; + } + var res = ""; + var cee = false; + for (var i = 0; i < input.length; i++) { + var inputi = input[i]; + if (typeof inputi === "string") { + res += inputi; + } else { + res += texify._go2(inputi); + if (inputi.type_ === '1st-level escape') { + cee = true; + } + } + } + if (!isInner && !cee && res) { + res = "{" + res + "}"; + } + return res; + }, + _goInner: function (input) { + if (!input) { + return input; + } + return texify.go(input, true); + }, + _go2: function (buf) { + /** @type {undefined | string} */ + var res; + switch (buf.type_) { + case 'chemfive': + res = ""; + var b5 = { + a: texify._goInner(buf.a), + b: texify._goInner(buf.b), + p: texify._goInner(buf.p), + o: texify._goInner(buf.o), + q: texify._goInner(buf.q), + d: texify._goInner(buf.d) + }; + // + // a + // + if (b5.a) { + if (b5.a.match(/^[+\-]/)) { + b5.a = "{" + b5.a + "}"; + } + res += b5.a + "\\,"; + } + // + // b and p + // + if (b5.b || b5.p) { + res += "{\\vphantom{X}}"; + res += "^{\\hphantom{" + (b5.b || "") + "}}_{\\hphantom{" + (b5.p || "") + "}}"; + res += "{\\vphantom{X}}"; + res += "^{\\smash[t]{\\vphantom{2}}\\mathllap{" + (b5.b || "") + "}}"; + res += "_{\\vphantom{2}\\mathllap{\\smash[t]{" + (b5.p || "") + "}}}"; + } + // + // o + // + if (b5.o) { + if (b5.o.match(/^[+\-]/)) { + b5.o = "{" + b5.o + "}"; + } + res += b5.o; + } + // + // q and d + // + if (buf.dType === 'kv') { + if (b5.d || b5.q) { + res += "{\\vphantom{X}}"; + } + if (b5.d) { + res += "^{" + b5.d + "}"; + } + if (b5.q) { + res += "_{\\smash[t]{" + b5.q + "}}"; + } + } else if (buf.dType === 'oxidation') { + if (b5.d) { + res += "{\\vphantom{X}}"; + res += "^{" + b5.d + "}"; + } + if (b5.q) { + res += "{\\vphantom{X}}"; + res += "_{\\smash[t]{" + b5.q + "}}"; + } + } else { + if (b5.q) { + res += "{\\vphantom{X}}"; + res += "_{\\smash[t]{" + b5.q + "}}"; + } + if (b5.d) { + res += "{\\vphantom{X}}"; + res += "^{" + b5.d + "}"; + } + } + break; + case 'rm': + res = "\\mathrm{" + buf.p1 + "}"; + break; + case 'text': + if (buf.p1.match(/[\^_]/)) { + buf.p1 = buf.p1.replace(" ", "~").replace("-", "\\text{-}"); + res = "\\mathrm{" + buf.p1 + "}"; + } else { + res = "\\text{" + buf.p1 + "}"; + } + break; + case 'roman numeral': + res = "\\mathrm{" + buf.p1 + "}"; + break; + case 'state of aggregation': + res = "\\mskip2mu " + texify._goInner(buf.p1); + break; + case 'state of aggregation subscript': + res = "\\mskip1mu " + texify._goInner(buf.p1); + break; + case 'bond': + res = texify._getBond(buf.kind_); + if (!res) { + throw ["MhchemErrorBond", "mhchem Error. Unknown bond type (" + buf.kind_ + ")"]; + } + break; + case 'frac': + var c = "\\frac{" + buf.p1 + "}{" + buf.p2 + "}"; + res = "\\mathchoice{\\textstyle" + c + "}{" + c + "}{" + c + "}{" + c + "}"; + break; + case 'pu-frac': + var d = "\\frac{" + texify._goInner(buf.p1) + "}{" + texify._goInner(buf.p2) + "}"; + res = "\\mathchoice{\\textstyle" + d + "}{" + d + "}{" + d + "}{" + d + "}"; + break; + case 'tex-math': + res = buf.p1 + " "; + break; + case 'frac-ce': + res = "\\frac{" + texify._goInner(buf.p1) + "}{" + texify._goInner(buf.p2) + "}"; + break; + case 'overset': + res = "\\overset{" + texify._goInner(buf.p1) + "}{" + texify._goInner(buf.p2) + "}"; + break; + case 'underset': + res = "\\underset{" + texify._goInner(buf.p1) + "}{" + texify._goInner(buf.p2) + "}"; + break; + case 'underbrace': + res = "\\underbrace{" + texify._goInner(buf.p1) + "}_{" + texify._goInner(buf.p2) + "}"; + break; + case 'color': + res = "{\\color{" + buf.color1 + "}{" + texify._goInner(buf.color2) + "}}"; + break; + case 'color0': + res = "\\color{" + buf.color + "}"; + break; + case 'arrow': + var b6 = { + rd: texify._goInner(buf.rd), + rq: texify._goInner(buf.rq) + }; + var arrow = "\\x" + texify._getArrow(buf.r); + if (b6.rq) { + arrow += "[{" + b6.rq + "}]"; + } + if (b6.rd) { + arrow += "{" + b6.rd + "}"; + } else { + arrow += "{}"; + } + res = arrow; + break; + case 'operator': + res = texify._getOperator(buf.kind_); + break; + case '1st-level escape': + res = buf.p1 + " "; // &, \\\\, \\hlin + break; + case 'space': + res = " "; + break; + case 'entitySkip': + res = "~"; + break; + case 'pu-space-1': + res = "~"; + break; + case 'pu-space-2': + res = "\\mkern3mu "; + break; + case '1000 separator': + res = "\\mkern2mu "; + break; + case 'commaDecimal': + res = "{,}"; + break; + case 'comma enumeration L': + res = "{" + buf.p1 + "}\\mkern6mu "; + break; + case 'comma enumeration M': + res = "{" + buf.p1 + "}\\mkern3mu "; + break; + case 'comma enumeration S': + res = "{" + buf.p1 + "}\\mkern1mu "; + break; + case 'hyphen': + res = "\\text{-}"; + break; + case 'addition compound': + res = "\\,{\\cdot}\\,"; + break; + case 'electron dot': + res = "\\mkern1mu \\bullet\\mkern1mu "; + break; + case 'KV x': + res = "{\\times}"; + break; + case 'prime': + res = "\\prime "; + break; + case 'cdot': + res = "\\cdot "; + break; + case 'tight cdot': + res = "\\mkern1mu{\\cdot}\\mkern1mu "; + break; + case 'times': + res = "\\times "; + break; + case 'circa': + res = "{\\sim}"; + break; + case '^': + res = "uparrow"; + break; + case 'v': + res = "downarrow"; + break; + case 'ellipsis': + res = "\\ldots "; + break; + case '/': + res = "/"; + break; + case ' / ': + res = "\\,/\\,"; + break; + default: + assertNever(buf); + throw ["MhchemBugT", "mhchem bug T. Please report."]; + // Missing texify rule or unknown MhchemParser output + } + assertString(res); + return res; + }, + _getArrow: function (a) { + switch (a) { + case "->": + return "rightarrow"; + case "\u2192": + return "rightarrow"; + case "\u27F6": + return "rightarrow"; + case "<-": + return "leftarrow"; + case "<->": + return "leftrightarrow"; + case "<-->": + return "rightleftarrows"; + case "<=>": + return "rightleftharpoons"; + case "\u21CC": + return "rightleftharpoons"; + case "<=>>": + return "rightequilibrium"; + case "<<=>": + return "leftequilibrium"; + default: + assertNever(a); + throw ["MhchemBugT", "mhchem bug T. Please report."]; + } + }, + _getBond: function (a) { + switch (a) { + case "-": + return "{-}"; + case "1": + return "{-}"; + case "=": + return "{=}"; + case "2": + return "{=}"; + case "#": + return "{\\equiv}"; + case "3": + return "{\\equiv}"; + case "~": + return "{\\tripledash}"; + case "~-": + return "{\\mathrlap{\\raisebox{-.1em}{$-$}}\\raisebox{.1em}{$\\tripledash$}}"; + case "~=": + return "{\\mathrlap{\\raisebox{-.2em}{$-$}}\\mathrlap{\\raisebox{.2em}{$\\tripledash$}}-}"; + case "~--": + return "{\\mathrlap{\\raisebox{-.2em}{$-$}}\\mathrlap{\\raisebox{.2em}{$\\tripledash$}}-}"; + case "-~-": + return "{\\mathrlap{\\raisebox{-.2em}{$-$}}\\mathrlap{\\raisebox{.2em}{$-$}}\\tripledash}"; + case "...": + return "{{\\cdot}{\\cdot}{\\cdot}}"; + case "....": + return "{{\\cdot}{\\cdot}{\\cdot}{\\cdot}}"; + case "->": + return "{\\rightarrow}"; + case "<-": + return "{\\leftarrow}"; + case "<": + return "{<}"; + case ">": + return "{>}"; + default: + assertNever(a); + throw ["MhchemBugT", "mhchem bug T. Please report."]; + } + }, + _getOperator: function (a) { + switch (a) { + case "+": + return " {}+{} "; + case "-": + return " {}-{} "; + case "=": + return " {}={} "; + case "<": + return " {}<{} "; + case ">": + return " {}>{} "; + case "<<": + return " {}\\ll{} "; + case ">>": + return " {}\\gg{} "; + case "\\pm": + return " {}\\pm{} "; + case "\\approx": + return " {}\\approx{} "; + case "$\\approx$": + return " {}\\approx{} "; + case "v": + return " \\downarrow{} "; + case "(v)": + return " \\downarrow{} "; + case "^": + return " \\uparrow{} "; + case "(^)": + return " \\uparrow{} "; + default: + assertNever(a); + throw ["MhchemBugT", "mhchem bug T. Please report."]; + } + } +}; + +// +// Helpers for code analysis +// Will show type error at calling position +// +/** @param {number} a */ +function assertNever(a) {} +/** @param {string} a */ +function assertString(a) {} +__webpack_exports__ = __webpack_exports__["default"]; +/******/ return __webpack_exports__; +/******/ })() +; +}); \ No newline at end of file diff --git a/node_modules/katex/dist/contrib/mhchem.min.js b/node_modules/katex/dist/contrib/mhchem.min.js new file mode 100644 index 0000000..2bb40b3 --- /dev/null +++ b/node_modules/katex/dist/contrib/mhchem.min.js @@ -0,0 +1 @@ +!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("katex"));else if("function"==typeof define&&define.amd)define(["katex"],e);else{var n="object"==typeof exports?e(require("katex")):e(t.katex);for(var o in n)("object"==typeof exports?exports:t)[o]=n[o]}}("undefined"!=typeof self?self:this,function(t){return function(){"use strict";var e={757:function(e){e.exports=t}},n={};function o(t){var a=n[t];if(void 0!==a)return a.exports;var r=n[t]={exports:{}};return e[t](r,r.exports,o),r.exports}o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,{a:e}),e},o.d=function(t,e){for(var n in e)o.o(e,n)&&!o.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)};var a={},r=o(757),i=o.n(r);i().__defineMacro("\\ce",function(t){return c(t.consumeArgs(1)[0],"ce")}),i().__defineMacro("\\pu",function(t){return c(t.consumeArgs(1)[0],"pu")}),i().__defineMacro("\\tripledash","{\\vphantom{-}\\raisebox{2.56mu}{$\\mkern2mu\\tiny\\text{-}\\mkern1mu\\text{-}\\mkern1mu\\text{-}\\mkern2mu$}}");var c=function(t,e){for(var n="",o=t.length&&t[t.length-1].loc.start,a=t.length-1;a>=0;a--)t[a].loc.start>o&&(n+=" ",o=t[a].loc.start),n+=t[a].text,o+=t[a].text.length;return p.go(u.go(n,e))},u={go:function(t,e){if(!t)return[];void 0===e&&(e="ce");var n,o="0",a={};a.parenthesisLevel=0,t=(t=(t=t.replace(/\n/g," ")).replace(/[\u2212\u2013\u2014\u2010]/g,"-")).replace(/[\u2026]/g,"...");for(var r=10,i=[];;){n!==t?(r=10,n=t):r--;var c=u.stateMachines[e],p=c.transitions[o]||c.transitions["*"];t:for(var s=0;s0))return i;if(d.revisit||(t=_.remainder),!d.toContinue)break t}}if(r<=0)throw["MhchemBugU","mhchem bug U. Please report."]}},concatArray:function(t,e){if(e)if(Array.isArray(e))for(var n=0;n":/^[=<>]/,"#":/^[#\u2261]/,"+":/^\+/,"-$":/^-(?=[\s_},;\]/]|$|\([a-z]+\))/,"-9":/^-(?=[0-9])/,"- orbital overlap":/^-(?=(?:[spd]|sp)(?:$|[\s,;\)\]\}]))/,"-":/^-/,"pm-operator":/^(?:\\pm|\$\\pm\$|\+-|\+\/-)/,operator:/^(?:\+|(?:[\-=<>]|<<|>>|\\approx|\$\\approx\$)(?=\s|$|-?[0-9]))/,arrowUpDown:/^(?:v|\(v\)|\^|\(\^\))(?=$|[\s,;\)\]\}])/,"\\bond{(...)}":function(t){return u.patterns.findObserveGroups(t,"\\bond{","","","}")},"->":/^(?:<->|<-->|->|<-|<=>>|<<=>|<=>|[\u2192\u27F6\u21CC])/,CMT:/^[CMT](?=\[)/,"[(...)]":function(t){return u.patterns.findObserveGroups(t,"[","","","]")},"1st-level escape":/^(&|\\\\|\\hline)\s*/,"\\,":/^(?:\\[,\ ;:])/,"\\x{}{}":function(t){return u.patterns.findObserveGroups(t,"",/^\\[a-zA-Z]+\{/,"}","","","{","}","",!0)},"\\x{}":function(t){return u.patterns.findObserveGroups(t,"",/^\\[a-zA-Z]+\{/,"}","")},"\\ca":/^\\ca(?:\s+|(?![a-zA-Z]))/,"\\x":/^(?:\\[a-zA-Z]+\s*|\\[_&{}%])/,orbital:/^(?:[0-9]{1,2}[spdfgh]|[0-9]{0,2}sp)(?=$|[^a-zA-Z])/,others:/^[\/~|]/,"\\frac{(...)}":function(t){return u.patterns.findObserveGroups(t,"\\frac{","","","}","{","","","}")},"\\overset{(...)}":function(t){return u.patterns.findObserveGroups(t,"\\overset{","","","}","{","","","}")},"\\underset{(...)}":function(t){return u.patterns.findObserveGroups(t,"\\underset{","","","}","{","","","}")},"\\underbrace{(...)}":function(t){return u.patterns.findObserveGroups(t,"\\underbrace{","","","}_","{","","","}")},"\\color{(...)}0":function(t){return u.patterns.findObserveGroups(t,"\\color{","","","}")},"\\color{(...)}{(...)}1":function(t){return u.patterns.findObserveGroups(t,"\\color{","","","}","{","","","}")},"\\color(...){(...)}2":function(t){return u.patterns.findObserveGroups(t,"\\color","\\","",/^(?=\{)/,"{","","","}")},"\\ce{(...)}":function(t){return u.patterns.findObserveGroups(t,"\\ce{","","","}")},oxidation$:/^(?:[+-][IVX]+|\\pm\s*0|\$\\pm\$\s*0)$/,"d-oxidation$":/^(?:[+-]?\s?[IVX]+|\\pm\s*0|\$\\pm\$\s*0)$/,"roman numeral":/^[IVX]+/,"1/2$":/^[+\-]?(?:[0-9]+|\$[a-z]\$|[a-z])\/[0-9]+(?:\$[a-z]\$|[a-z])?$/,amount:function(t){var e;if(e=t.match(/^(?:(?:(?:\([+\-]?[0-9]+\/[0-9]+\)|[+\-]?(?:[0-9]+|\$[a-z]\$|[a-z])\/[0-9]+|[+\-]?[0-9]+[.,][0-9]+|[+\-]?\.[0-9]+|[+\-]?[0-9]+)(?:[a-z](?=\s*[A-Z]))?)|[+\-]?[a-z](?=\s*[A-Z])|\+(?!\s))/))return{match_:e[0],remainder:t.substr(e[0].length)};var n=u.patterns.findObserveGroups(t,"","$","$","");return n&&(e=n.match_.match(/^\$(?:\(?[+\-]?(?:[0-9]*[a-z]?[+\-])?[0-9]*[a-z](?:[+\-][0-9]*[a-z]?)?\)?|\+|-)\$$/))?{match_:e[0],remainder:t.substr(e[0].length)}:null},amount2:function(t){return this.amount(t)},"(KV letters),":/^(?:[A-Z][a-z]{0,2}|i)(?=,)/,formula$:function(t){if(t.match(/^\([a-z]+\)$/))return null;var e=t.match(/^(?:[a-z]|(?:[0-9\ \+\-\,\.\(\)]+[a-z])+[0-9\ \+\-\,\.\(\)]*|(?:[a-z][0-9\ \+\-\,\.\(\)]+)+[a-z]?)$/);return e?{match_:e[0],remainder:t.substr(e[0].length)}:null},uprightEntities:/^(?:pH|pOH|pC|pK|iPr|iBu)(?=$|[^a-zA-Z])/,"/":/^\s*(\/)\s*/,"//":/^\s*(\/\/)\s*/,"*":/^\s*[*.]\s*/},findObserveGroups:function(t,e,n,o,a,r,i,c,u,p){var s=function(t,e){if("string"==typeof e)return 0!==t.indexOf(e)?null:e;var n=t.match(e);return n?n[0]:null},_=s(t,e);if(null===_)return null;if(t=t.substr(_.length),null===(_=s(t,n)))return null;var d=function(t,e,n){for(var o=0;e":{"0|1|2|3":{action_:"r=",nextState:"r"},"a|as":{action_:["output","r="],nextState:"r"},"*":{action_:["output","r="],nextState:"r"}},"+":{o:{action_:"d= kv",nextState:"d"},"d|D":{action_:"d=",nextState:"d"},q:{action_:"d=",nextState:"qd"},"qd|qD":{action_:"d=",nextState:"qd"},dq:{action_:["output","d="],nextState:"d"},3:{action_:["sb=false","output","operator"],nextState:"0"}},amount:{"0|2":{action_:"a=",nextState:"a"}},"pm-operator":{"0|1|2|a|as":{action_:["sb=false","output",{type_:"operator",option:"\\pm"}],nextState:"0"}},operator:{"0|1|2|a|as":{action_:["sb=false","output","operator"],nextState:"0"}},"-$":{"o|q":{action_:["charge or bond","output"],nextState:"qd"},d:{action_:"d=",nextState:"d"},D:{action_:["output",{type_:"bond",option:"-"}],nextState:"3"},q:{action_:"d=",nextState:"qd"},qd:{action_:"d=",nextState:"qd"},"qD|dq":{action_:["output",{type_:"bond",option:"-"}],nextState:"3"}},"-9":{"3|o":{action_:["output",{type_:"insert",option:"hyphen"}],nextState:"3"}},"- orbital overlap":{o:{action_:["output",{type_:"insert",option:"hyphen"}],nextState:"2"},d:{action_:["output",{type_:"insert",option:"hyphen"}],nextState:"2"}},"-":{"0|1|2":{action_:[{type_:"output",option:1},"beginsWithBond=true",{type_:"bond",option:"-"}],nextState:"3"},3:{action_:{type_:"bond",option:"-"}},a:{action_:["output",{type_:"insert",option:"hyphen"}],nextState:"2"},as:{action_:[{type_:"output",option:2},{type_:"bond",option:"-"}],nextState:"3"},b:{action_:"b="},o:{action_:{type_:"- after o/d",option:!1},nextState:"2"},q:{action_:{type_:"- after o/d",option:!1},nextState:"2"},"d|qd|dq":{action_:{type_:"- after o/d",option:!0},nextState:"2"},"D|qD|p":{action_:["output",{type_:"bond",option:"-"}],nextState:"3"}},amount2:{"1|3":{action_:"a=",nextState:"a"}},letters:{"0|1|2|3|a|as|b|p|bp|o":{action_:"o=",nextState:"o"},"q|dq":{action_:["output","o="],nextState:"o"},"d|D|qd|qD":{action_:"o after d",nextState:"o"}},digits:{o:{action_:"q=",nextState:"q"},"d|D":{action_:"q=",nextState:"dq"},q:{action_:["output","o="],nextState:"o"},a:{action_:"o=",nextState:"o"}},"space A":{"b|p|bp":{}},space:{a:{nextState:"as"},0:{action_:"sb=false"},"1|2":{action_:"sb=true"},"r|rt|rd|rdt|rdq":{action_:"output",nextState:"0"},"*":{action_:["output","sb=true"],nextState:"1"}},"1st-level escape":{"1|2":{action_:["output",{type_:"insert+p1",option:"1st-level escape"}]},"*":{action_:["output",{type_:"insert+p1",option:"1st-level escape"}],nextState:"0"}},"[(...)]":{"r|rt":{action_:"rd=",nextState:"rd"},"rd|rdt":{action_:"rq=",nextState:"rdq"}},"...":{"o|d|D|dq|qd|qD":{action_:["output",{type_:"bond",option:"..."}],nextState:"3"},"*":{action_:[{type_:"output",option:1},{type_:"insert",option:"ellipsis"}],nextState:"1"}},". |* ":{"*":{action_:["output",{type_:"insert",option:"addition compound"}],nextState:"1"}},"state of aggregation $":{"*":{action_:["output","state of aggregation"],nextState:"1"}},"{[(":{"a|as|o":{action_:["o=","output","parenthesisLevel++"],nextState:"2"},"0|1|2|3":{action_:["o=","output","parenthesisLevel++"],nextState:"2"},"*":{action_:["output","o=","output","parenthesisLevel++"],nextState:"2"}},")]}":{"0|1|2|3|b|p|bp|o":{action_:["o=","parenthesisLevel--"],nextState:"o"},"a|as|d|D|q|qd|qD|dq":{action_:["output","o=","parenthesisLevel--"],nextState:"o"}},", ":{"*":{action_:["output","comma"],nextState:"0"}},"^_":{"*":{}},"^{(...)}|^($...$)":{"0|1|2|as":{action_:"b=",nextState:"b"},p:{action_:"b=",nextState:"bp"},"3|o":{action_:"d= kv",nextState:"D"},q:{action_:"d=",nextState:"qD"},"d|D|qd|qD|dq":{action_:["output","d="],nextState:"D"}},"^a|^\\x{}{}|^\\x{}|^\\x|'":{"0|1|2|as":{action_:"b=",nextState:"b"},p:{action_:"b=",nextState:"bp"},"3|o":{action_:"d= kv",nextState:"d"},q:{action_:"d=",nextState:"qd"},"d|qd|D|qD":{action_:"d="},dq:{action_:["output","d="],nextState:"d"}},"_{(state of aggregation)}$":{"d|D|q|qd|qD|dq":{action_:["output","q="],nextState:"q"}},"_{(...)}|_($...$)|_9|_\\x{}{}|_\\x{}|_\\x":{"0|1|2|as":{action_:"p=",nextState:"p"},b:{action_:"p=",nextState:"bp"},"3|o":{action_:"q=",nextState:"q"},"d|D":{action_:"q=",nextState:"dq"},"q|qd|qD|dq":{action_:["output","q="],nextState:"q"}},"=<>":{"0|1|2|3|a|as|o|q|d|D|qd|qD|dq":{action_:[{type_:"output",option:2},"bond"],nextState:"3"}},"#":{"0|1|2|3|a|as|o":{action_:[{type_:"output",option:2},{type_:"bond",option:"#"}],nextState:"3"}},"{}":{"*":{action_:{type_:"output",option:1},nextState:"1"}},"{...}":{"0|1|2|3|a|as|b|p|bp":{action_:"o=",nextState:"o"},"o|d|D|q|qd|qD|dq":{action_:["output","o="],nextState:"o"}},"$...$":{a:{action_:"a="},"0|1|2|3|as|b|p|bp|o":{action_:"o=",nextState:"o"},"as|o":{action_:"o="},"q|d|D|qd|qD|dq":{action_:["output","o="],nextState:"o"}},"\\bond{(...)}":{"*":{action_:[{type_:"output",option:2},"bond"],nextState:"3"}},"\\frac{(...)}":{"*":{action_:[{type_:"output",option:1},"frac-output"],nextState:"3"}},"\\overset{(...)}":{"*":{action_:[{type_:"output",option:2},"overset-output"],nextState:"3"}},"\\underset{(...)}":{"*":{action_:[{type_:"output",option:2},"underset-output"],nextState:"3"}},"\\underbrace{(...)}":{"*":{action_:[{type_:"output",option:2},"underbrace-output"],nextState:"3"}},"\\color{(...)}{(...)}1|\\color(...){(...)}2":{"*":{action_:[{type_:"output",option:2},"color-output"],nextState:"3"}},"\\color{(...)}0":{"*":{action_:[{type_:"output",option:2},"color0-output"]}},"\\ce{(...)}":{"*":{action_:[{type_:"output",option:2},"ce"],nextState:"3"}},"\\,":{"*":{action_:[{type_:"output",option:1},"copy"],nextState:"1"}},"\\x{}{}|\\x{}|\\x":{"0|1|2|3|a|as|b|p|bp|o|c0":{action_:["o=","output"],nextState:"3"},"*":{action_:["output","o=","output"],nextState:"3"}},others:{"*":{action_:[{type_:"output",option:1},"copy"],nextState:"3"}},else2:{a:{action_:"a to o",nextState:"o",revisit:!0},as:{action_:["output","sb=true"],nextState:"1",revisit:!0},"r|rt|rd|rdt|rdq":{action_:["output"],nextState:"0",revisit:!0},"*":{action_:["output","copy"],nextState:"3"}}}),actions:{"o after d":function(t,e){var n;if((t.d||"").match(/^[0-9]+$/)){var o=t.d;t.d=void 0,n=this.output(t),t.b=o}else n=this.output(t);return u.actions["o="](t,e),n},"d= kv":function(t,e){t.d=e,t.dType="kv"},"charge or bond":function(t,e){if(t.beginsWithBond){var n=[];return u.concatArray(n,this.output(t)),u.concatArray(n,u.actions.bond(t,e,"-")),n}t.d=e},"- after o/d":function(t,e,n){var o=u.patterns.match_("orbital",t.o||""),a=u.patterns.match_("one lowercase greek letter $",t.o||""),r=u.patterns.match_("one lowercase latin letter $",t.o||""),i=u.patterns.match_("$one lowercase latin letter$ $",t.o||""),c="-"===e&&(o&&""===o.remainder||a||r||i);!c||t.a||t.b||t.p||t.d||t.q||o||!r||(t.o="$"+t.o+"$");var p=[];return c?(u.concatArray(p,this.output(t)),p.push({type_:"hyphen"})):(o=u.patterns.match_("digits",t.d||""),n&&o&&""===o.remainder?(u.concatArray(p,u.actions["d="](t,e)),u.concatArray(p,this.output(t))):(u.concatArray(p,this.output(t)),u.concatArray(p,u.actions.bond(t,e,"-")))),p},"a to o":function(t){t.o=t.a,t.a=void 0},"sb=true":function(t){t.sb=!0},"sb=false":function(t){t.sb=!1},"beginsWithBond=true":function(t){t.beginsWithBond=!0},"beginsWithBond=false":function(t){t.beginsWithBond=!1},"parenthesisLevel++":function(t){t.parenthesisLevel++},"parenthesisLevel--":function(t){t.parenthesisLevel--},"state of aggregation":function(t,e){return{type_:"state of aggregation",p1:u.go(e,"o")}},comma:function(t,e){var n=e.replace(/\s*$/,"");return n!==e&&0===t.parenthesisLevel?{type_:"comma enumeration L",p1:n}:{type_:"comma enumeration M",p1:n}},output:function(t,e,n){var o,a,r;t.r?(a="M"===t.rdt?u.go(t.rd,"tex-math"):"T"===t.rdt?[{type_:"text",p1:t.rd||""}]:u.go(t.rd),r="M"===t.rqt?u.go(t.rq,"tex-math"):"T"===t.rqt?[{type_:"text",p1:t.rq||""}]:u.go(t.rq),o={type_:"arrow",r:t.r,rd:a,rq:r}):(o=[],(t.a||t.b||t.p||t.o||t.q||t.d||n)&&(t.sb&&o.push({type_:"entitySkip"}),t.o||t.q||t.d||t.b||t.p||2===n?t.o||t.q||t.d||!t.b&&!t.p?t.o&&"kv"===t.dType&&u.patterns.match_("d-oxidation$",t.d||"")?t.dType="oxidation":t.o&&"kv"===t.dType&&!t.q&&(t.dType=void 0):(t.o=t.a,t.d=t.b,t.q=t.p,t.a=t.b=t.p=void 0):(t.o=t.a,t.a=void 0),o.push({type_:"chemfive",a:u.go(t.a,"a"),b:u.go(t.b,"bd"),p:u.go(t.p,"pq"),o:u.go(t.o,"o"),q:u.go(t.q,"pq"),d:u.go(t.d,"oxidation"===t.dType?"oxidation":"bd"),dType:t.dType})));for(var i in t)"parenthesisLevel"!==i&&"beginsWithBond"!==i&&delete t[i];return o},"oxidation-output":function(t,e){var n=["{"];return u.concatArray(n,u.go(e,"oxidation")),n.push("}"),n},"frac-output":function(t,e){return{type_:"frac-ce",p1:u.go(e[0]),p2:u.go(e[1])}},"overset-output":function(t,e){return{type_:"overset",p1:u.go(e[0]),p2:u.go(e[1])}},"underset-output":function(t,e){return{type_:"underset",p1:u.go(e[0]),p2:u.go(e[1])}},"underbrace-output":function(t,e){return{type_:"underbrace",p1:u.go(e[0]),p2:u.go(e[1])}},"color-output":function(t,e){return{type_:"color",color1:e[0],color2:u.go(e[1])}},"r=":function(t,e){t.r=e},"rdt=":function(t,e){t.rdt=e},"rd=":function(t,e){t.rd=e},"rqt=":function(t,e){t.rqt=e},"rq=":function(t,e){t.rq=e},operator:function(t,e,n){return{type_:"operator",kind_:n||e}}}},a:{transitions:u.createTransitions({empty:{"*":{}},"1/2$":{0:{action_:"1/2"}},else:{0:{nextState:"1",revisit:!0}},"$(...)$":{"*":{action_:"tex-math tight",nextState:"1"}},",":{"*":{action_:{type_:"insert",option:"commaDecimal"}}},else2:{"*":{action_:"copy"}}}),actions:{}},o:{transitions:u.createTransitions({empty:{"*":{}},"1/2$":{0:{action_:"1/2"}},else:{0:{nextState:"1",revisit:!0}},letters:{"*":{action_:"rm"}},"\\ca":{"*":{action_:{type_:"insert",option:"circa"}}},"\\x{}{}|\\x{}|\\x":{"*":{action_:"copy"}},"${(...)}$|$(...)$":{"*":{action_:"tex-math"}},"{(...)}":{"*":{action_:"{text}"}},else2:{"*":{action_:"copy"}}}),actions:{}},text:{transitions:u.createTransitions({empty:{"*":{action_:"output"}},"{...}":{"*":{action_:"text="}},"${(...)}$|$(...)$":{"*":{action_:"tex-math"}},"\\greek":{"*":{action_:["output","rm"]}},"\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:["output","copy"]}},else:{"*":{action_:"text="}}}),actions:{output:function(t){if(t.text_){var e={type_:"text",p1:t.text_};for(var n in t)delete t[n];return e}}}},pq:{transitions:u.createTransitions({empty:{"*":{}},"state of aggregation $":{"*":{action_:"state of aggregation"}},i$:{0:{nextState:"!f",revisit:!0}},"(KV letters),":{0:{action_:"rm",nextState:"0"}},formula$:{0:{nextState:"f",revisit:!0}},"1/2$":{0:{action_:"1/2"}},else:{0:{nextState:"!f",revisit:!0}},"${(...)}$|$(...)$":{"*":{action_:"tex-math"}},"{(...)}":{"*":{action_:"text"}},"a-z":{f:{action_:"tex-math"}},letters:{"*":{action_:"rm"}},"-9.,9":{"*":{action_:"9,9"}},",":{"*":{action_:{type_:"insert+p1",option:"comma enumeration S"}}},"\\color{(...)}{(...)}1|\\color(...){(...)}2":{"*":{action_:"color-output"}},"\\color{(...)}0":{"*":{action_:"color0-output"}},"\\ce{(...)}":{"*":{action_:"ce"}},"\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:"copy"}},else2:{"*":{action_:"copy"}}}),actions:{"state of aggregation":function(t,e){return{type_:"state of aggregation subscript",p1:u.go(e,"o")}},"color-output":function(t,e){return{type_:"color",color1:e[0],color2:u.go(e[1],"pq")}}}},bd:{transitions:u.createTransitions({empty:{"*":{}},x$:{0:{nextState:"!f",revisit:!0}},formula$:{0:{nextState:"f",revisit:!0}},else:{0:{nextState:"!f",revisit:!0}},"-9.,9 no missing 0":{"*":{action_:"9,9"}},".":{"*":{action_:{type_:"insert",option:"electron dot"}}},"a-z":{f:{action_:"tex-math"}},x:{"*":{action_:{type_:"insert",option:"KV x"}}},letters:{"*":{action_:"rm"}},"'":{"*":{action_:{type_:"insert",option:"prime"}}},"${(...)}$|$(...)$":{"*":{action_:"tex-math"}},"{(...)}":{"*":{action_:"text"}},"\\color{(...)}{(...)}1|\\color(...){(...)}2":{"*":{action_:"color-output"}},"\\color{(...)}0":{"*":{action_:"color0-output"}},"\\ce{(...)}":{"*":{action_:"ce"}},"\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:"copy"}},else2:{"*":{action_:"copy"}}}),actions:{"color-output":function(t,e){return{type_:"color",color1:e[0],color2:u.go(e[1],"bd")}}}},oxidation:{transitions:u.createTransitions({empty:{"*":{}},"roman numeral":{"*":{action_:"roman-numeral"}},"${(...)}$|$(...)$":{"*":{action_:"tex-math"}},else:{"*":{action_:"copy"}}}),actions:{"roman-numeral":function(t,e){return{type_:"roman numeral",p1:e||""}}}},"tex-math":{transitions:u.createTransitions({empty:{"*":{action_:"output"}},"\\ce{(...)}":{"*":{action_:["output","ce"]}},"{...}|\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:"o="}},else:{"*":{action_:"o="}}}),actions:{output:function(t){if(t.o){var e={type_:"tex-math",p1:t.o};for(var n in t)delete t[n];return e}}}},"tex-math tight":{transitions:u.createTransitions({empty:{"*":{action_:"output"}},"\\ce{(...)}":{"*":{action_:["output","ce"]}},"{...}|\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:"o="}},"-|+":{"*":{action_:"tight operator"}},else:{"*":{action_:"o="}}}),actions:{"tight operator":function(t,e){t.o=(t.o||"")+"{"+e+"}"},output:function(t){if(t.o){var e={type_:"tex-math",p1:t.o};for(var n in t)delete t[n];return e}}}},"9,9":{transitions:u.createTransitions({empty:{"*":{}},",":{"*":{action_:"comma"}},else:{"*":{action_:"copy"}}}),actions:{comma:function(){return{type_:"commaDecimal"}}}},pu:{transitions:u.createTransitions({empty:{"*":{action_:"output"}},space$:{"*":{action_:["output","space"]}},"{[(|)]}":{"0|a":{action_:"copy"}},"(-)(9)^(-9)":{0:{action_:"number^",nextState:"a"}},"(-)(9.,9)(e)(99)":{0:{action_:"enumber",nextState:"a"}},space:{"0|a":{}},"pm-operator":{"0|a":{action_:{type_:"operator",option:"\\pm"},nextState:"0"}},operator:{"0|a":{action_:"copy",nextState:"0"}},"//":{d:{action_:"o=",nextState:"/"}},"/":{d:{action_:"o=",nextState:"/"}},"{...}|else":{"0|d":{action_:"d=",nextState:"d"},a:{action_:["space","d="],nextState:"d"},"/|q":{action_:"q=",nextState:"q"}}}),actions:{enumber:function(t,e){var n=[];return"+-"===e[0]||"+/-"===e[0]?n.push("\\pm "):e[0]&&n.push(e[0]),e[1]&&(u.concatArray(n,u.go(e[1],"pu-9,9")),e[2]&&(e[2].match(/[,.]/)?u.concatArray(n,u.go(e[2],"pu-9,9")):n.push(e[2])),e[3]=e[4]||e[3],e[3]&&(e[3]=e[3].trim(),"e"===e[3]||"*"===e[3].substr(0,1)?n.push({type_:"cdot"}):n.push({type_:"times"}))),e[3]&&n.push("10^{"+e[5]+"}"),n},"number^":function(t,e){var n=[];return"+-"===e[0]||"+/-"===e[0]?n.push("\\pm "):e[0]&&n.push(e[0]),u.concatArray(n,u.go(e[1],"pu-9,9")),n.push("^{"+e[2]+"}"),n},operator:function(t,e,n){return{type_:"operator",kind_:n||e}},space:function(){return{type_:"pu-space-1"}},output:function(t){var e,n=u.patterns.match_("{(...)}",t.d||"");n&&""===n.remainder&&(t.d=n.match_);var o=u.patterns.match_("{(...)}",t.q||"");if(o&&""===o.remainder&&(t.q=o.match_),t.d&&(t.d=t.d.replace(/\u00B0C|\^oC|\^{o}C/g,"{}^{\\circ}C"),t.d=t.d.replace(/\u00B0F|\^oF|\^{o}F/g,"{}^{\\circ}F")),t.q){t.q=t.q.replace(/\u00B0C|\^oC|\^{o}C/g,"{}^{\\circ}C"),t.q=t.q.replace(/\u00B0F|\^oF|\^{o}F/g,"{}^{\\circ}F");var a={d:u.go(t.d,"pu"),q:u.go(t.q,"pu")};"//"===t.o?e={type_:"pu-frac",p1:a.d,p2:a.q}:(e=a.d,a.d.length>1||a.q.length>1?e.push({type_:" / "}):e.push({type_:"/"}),u.concatArray(e,a.q))}else e=u.go(t.d,"pu-2");for(var r in t)delete t[r];return e}}},"pu-2":{transitions:u.createTransitions({empty:{"*":{action_:"output"}},"*":{"*":{action_:["output","cdot"],nextState:"0"}},"\\x":{"*":{action_:"rm="}},space:{"*":{action_:["output","space"],nextState:"0"}},"^{(...)}|^(-1)":{1:{action_:"^(-1)"}},"-9.,9":{0:{action_:"rm=",nextState:"0"},1:{action_:"^(-1)",nextState:"0"}},"{...}|else":{"*":{action_:"rm=",nextState:"1"}}}),actions:{cdot:function(){return{type_:"tight cdot"}},"^(-1)":function(t,e){t.rm+="^{"+e+"}"},space:function(){return{type_:"pu-space-2"}},output:function(t){var e=[];if(t.rm){var n=u.patterns.match_("{(...)}",t.rm||"");e=n&&""===n.remainder?u.go(n.match_,"pu"):{type_:"rm",p1:t.rm}}for(var o in t)delete t[o];return e}}},"pu-9,9":{transitions:u.createTransitions({empty:{0:{action_:"output-0"},o:{action_:"output-o"}},",":{0:{action_:["output-0","comma"],nextState:"o"}},".":{0:{action_:["output-0","copy"],nextState:"o"}},else:{"*":{action_:"text="}}}),actions:{comma:function(){return{type_:"commaDecimal"}},"output-0":function(t){var e=[];if(t.text_=t.text_||"",t.text_.length>4){var n=t.text_.length%3;0===n&&(n=3);for(var o=t.text_.length-3;o>0;o-=3)e.push(t.text_.substr(o,3)),e.push({type_:"1000 separator"});e.push(t.text_.substr(0,n)),e.reverse()}else e.push(t.text_);for(var a in t)delete t[a];return e},"output-o":function(t){var e=[];if(t.text_=t.text_||"",t.text_.length>4){for(var n=t.text_.length-3,o=0;o":case"\u2192":case"\u27f6":return"rightarrow";case"<-":return"leftarrow";case"<->":return"leftrightarrow";case"<--\x3e":return"rightleftarrows";case"<=>":case"\u21cc":return"rightleftharpoons";case"<=>>":return"rightequilibrium";case"<<=>":return"leftequilibrium";default:throw["MhchemBugT","mhchem bug T. Please report."]}},_getBond:function(t){switch(t){case"-":case"1":return"{-}";case"=":case"2":return"{=}";case"#":case"3":return"{\\equiv}";case"~":return"{\\tripledash}";case"~-":return"{\\mathrlap{\\raisebox{-.1em}{$-$}}\\raisebox{.1em}{$\\tripledash$}}";case"~=":case"~--":return"{\\mathrlap{\\raisebox{-.2em}{$-$}}\\mathrlap{\\raisebox{.2em}{$\\tripledash$}}-}";case"-~-":return"{\\mathrlap{\\raisebox{-.2em}{$-$}}\\mathrlap{\\raisebox{.2em}{$-$}}\\tripledash}";case"...":return"{{\\cdot}{\\cdot}{\\cdot}}";case"....":return"{{\\cdot}{\\cdot}{\\cdot}{\\cdot}}";case"->":return"{\\rightarrow}";case"<-":return"{\\leftarrow}";case"<":return"{<}";case">":return"{>}";default:throw["MhchemBugT","mhchem bug T. Please report."]}},_getOperator:function(t){switch(t){case"+":return" {}+{} ";case"-":return" {}-{} ";case"=":return" {}={} ";case"<":return" {}<{} ";case">":return" {}>{} ";case"<<":return" {}\\ll{} ";case">>":return" {}\\gg{} ";case"\\pm":return" {}\\pm{} ";case"\\approx":case"$\\approx$":return" {}\\approx{} ";case"v":case"(v)":return" \\downarrow{} ";case"^":case"(^)":return" \\uparrow{} ";default:throw["MhchemBugT","mhchem bug T. Please report."]}}};return a=a.default}()}); \ No newline at end of file diff --git a/node_modules/katex/dist/contrib/mhchem.mjs b/node_modules/katex/dist/contrib/mhchem.mjs new file mode 100644 index 0000000..bbb61fc --- /dev/null +++ b/node_modules/katex/dist/contrib/mhchem.mjs @@ -0,0 +1,2864 @@ +import katex from '../katex.mjs'; + +/* eslint-disable */ +/* -*- Mode: JavaScript; indent-tabs-mode:nil; js-indent-level: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ + +/************************************************************* + * + * KaTeX mhchem.js + * + * This file implements a KaTeX version of mhchem version 3.3.0. + * It is adapted from MathJax/extensions/TeX/mhchem.js + * It differs from the MathJax version as follows: + * 1. The interface is changed so that it can be called from KaTeX, not MathJax. + * 2. \rlap and \llap are replaced with \mathrlap and \mathllap. + * 3. Four lines of code are edited in order to use \raisebox instead of \raise. + * 4. The reaction arrow code is simplified. All reaction arrows are rendered + * using KaTeX extensible arrows instead of building non-extensible arrows. + * 5. \tripledash vertical alignment is slightly adjusted. + * + * This code, as other KaTeX code, is released under the MIT license. + * + * /************************************************************* + * + * MathJax/extensions/TeX/mhchem.js + * + * Implements the \ce command for handling chemical formulas + * from the mhchem LaTeX package. + * + * --------------------------------------------------------------------- + * + * Copyright (c) 2011-2015 The MathJax Consortium + * Copyright (c) 2015-2018 Martin Hensel + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// +// Coding Style +// - use '' for identifiers that can by minified/uglified +// - use "" for strings that need to stay untouched + +// version: "3.3.0" for MathJax and KaTeX + +// Add \ce, \pu, and \tripledash to the KaTeX macros. + +katex.__defineMacro("\\ce", function (context) { + return chemParse(context.consumeArgs(1)[0], "ce"); +}); +katex.__defineMacro("\\pu", function (context) { + return chemParse(context.consumeArgs(1)[0], "pu"); +}); + +// Needed for \bond for the ~ forms +// Raise by 2.56mu, not 2mu. We're raising a hyphen-minus, U+002D, not +// a mathematical minus, U+2212. So we need that extra 0.56. +katex.__defineMacro("\\tripledash", "{\\vphantom{-}\\raisebox{2.56mu}{$\\mkern2mu" + "\\tiny\\text{-}\\mkern1mu\\text{-}\\mkern1mu\\text{-}\\mkern2mu$}}"); + +// +// This is the main function for handing the \ce and \pu commands. +// It takes the argument to \ce or \pu and returns the corresponding TeX string. +// + +var chemParse = function chemParse(tokens, stateMachine) { + // Recreate the argument string from KaTeX's array of tokens. + var str = ""; + var expectedLoc = tokens.length && tokens[tokens.length - 1].loc.start; + for (var i = tokens.length - 1; i >= 0; i--) { + if (tokens[i].loc.start > expectedLoc) { + // context.consumeArgs has eaten a space. + str += " "; + expectedLoc = tokens[i].loc.start; + } + str += tokens[i].text; + expectedLoc += tokens[i].text.length; + } + var tex = texify.go(mhchemParser.go(str, stateMachine)); + return tex; +}; + +// +// Core parser for mhchem syntax (recursive) +// +/** @type {MhchemParser} */ +var mhchemParser = { + // + // Parses mchem \ce syntax + // + // Call like + // go("H2O"); + // + go: function go(input, stateMachine) { + if (!input) { + return []; + } + if (stateMachine === undefined) { + stateMachine = 'ce'; + } + var state = '0'; + + // + // String buffers for parsing: + // + // buffer.a == amount + // buffer.o == element + // buffer.b == left-side superscript + // buffer.p == left-side subscript + // buffer.q == right-side subscript + // buffer.d == right-side superscript + // + // buffer.r == arrow + // buffer.rdt == arrow, script above, type + // buffer.rd == arrow, script above, content + // buffer.rqt == arrow, script below, type + // buffer.rq == arrow, script below, content + // + // buffer.text_ + // buffer.rm + // etc. + // + // buffer.parenthesisLevel == int, starting at 0 + // buffer.sb == bool, space before + // buffer.beginsWithBond == bool + // + // These letters are also used as state names. + // + // Other states: + // 0 == begin of main part (arrow/operator unlikely) + // 1 == next entity + // 2 == next entity (arrow/operator unlikely) + // 3 == next atom + // c == macro + // + /** @type {Buffer} */ + var buffer = {}; + buffer['parenthesisLevel'] = 0; + input = input.replace(/\n/g, " "); + input = input.replace(/[\u2212\u2013\u2014\u2010]/g, "-"); + input = input.replace(/[\u2026]/g, "..."); + + // + // Looks through mhchemParser.transitions, to execute a matching action + // (recursive) + // + var lastInput; + var watchdog = 10; + /** @type {ParserOutput[]} */ + var output = []; + while (true) { + if (lastInput !== input) { + watchdog = 10; + lastInput = input; + } else { + watchdog--; + } + // + // Find actions in transition table + // + var machine = mhchemParser.stateMachines[stateMachine]; + var t = machine.transitions[state] || machine.transitions['*']; + iterateTransitions: for (var i = 0; i < t.length; i++) { + var matches = mhchemParser.patterns.match_(t[i].pattern, input); + if (matches) { + // + // Execute actions + // + var task = t[i].task; + for (var iA = 0; iA < task.action_.length; iA++) { + var o; + // + // Find and execute action + // + if (machine.actions[task.action_[iA].type_]) { + o = machine.actions[task.action_[iA].type_](buffer, matches.match_, task.action_[iA].option); + } else if (mhchemParser.actions[task.action_[iA].type_]) { + o = mhchemParser.actions[task.action_[iA].type_](buffer, matches.match_, task.action_[iA].option); + } else { + throw ["MhchemBugA", "mhchem bug A. Please report. (" + task.action_[iA].type_ + ")"]; // Trying to use non-existing action + } + // + // Add output + // + mhchemParser.concatArray(output, o); + } + // + // Set next state, + // Shorten input, + // Continue with next character + // (= apply only one transition per position) + // + state = task.nextState || state; + if (input.length > 0) { + if (!task.revisit) { + input = matches.remainder; + } + if (!task.toContinue) { + break iterateTransitions; + } + } else { + return output; + } + } + } + // + // Prevent infinite loop + // + if (watchdog <= 0) { + throw ["MhchemBugU", "mhchem bug U. Please report."]; // Unexpected character + } + } + }, + concatArray: function concatArray(a, b) { + if (b) { + if (Array.isArray(b)) { + for (var iB = 0; iB < b.length; iB++) { + a.push(b[iB]); + } + } else { + a.push(b); + } + } + }, + patterns: { + // + // Matching patterns + // either regexps or function that return null or {match_:"a", remainder:"bc"} + // + patterns: { + // property names must not look like integers ("2") for correct property traversal order, later on + 'empty': /^$/, + 'else': /^./, + 'else2': /^./, + 'space': /^\s/, + 'space A': /^\s(?=[A-Z\\$])/, + 'space$': /^\s$/, + 'a-z': /^[a-z]/, + 'x': /^x/, + 'x$': /^x$/, + 'i$': /^i$/, + 'letters': /^(?:[a-zA-Z\u03B1-\u03C9\u0391-\u03A9?@]|(?:\\(?:alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega|Gamma|Delta|Theta|Lambda|Xi|Pi|Sigma|Upsilon|Phi|Psi|Omega)(?:\s+|\{\}|(?![a-zA-Z]))))+/, + '\\greek': /^\\(?:alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega|Gamma|Delta|Theta|Lambda|Xi|Pi|Sigma|Upsilon|Phi|Psi|Omega)(?:\s+|\{\}|(?![a-zA-Z]))/, + 'one lowercase latin letter $': /^(?:([a-z])(?:$|[^a-zA-Z]))$/, + '$one lowercase latin letter$ $': /^\$(?:([a-z])(?:$|[^a-zA-Z]))\$$/, + 'one lowercase greek letter $': /^(?:\$?[\u03B1-\u03C9]\$?|\$?\\(?:alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega)\s*\$?)(?:\s+|\{\}|(?![a-zA-Z]))$/, + 'digits': /^[0-9]+/, + '-9.,9': /^[+\-]?(?:[0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+))/, + '-9.,9 no missing 0': /^[+\-]?[0-9]+(?:[.,][0-9]+)?/, + '(-)(9.,9)(e)(99)': function e99(input) { + var m = input.match(/^(\+\-|\+\/\-|\+|\-|\\pm\s?)?([0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+))?(\((?:[0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+))\))?(?:([eE]|\s*(\*|x|\\times|\u00D7)\s*10\^)([+\-]?[0-9]+|\{[+\-]?[0-9]+\}))?/); + if (m && m[0]) { + return { + match_: m.splice(1), + remainder: input.substr(m[0].length) + }; + } + return null; + }, + '(-)(9)^(-9)': function _(input) { + var m = input.match(/^(\+\-|\+\/\-|\+|\-|\\pm\s?)?([0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+)?)\^([+\-]?[0-9]+|\{[+\-]?[0-9]+\})/); + if (m && m[0]) { + return { + match_: m.splice(1), + remainder: input.substr(m[0].length) + }; + } + return null; + }, + 'state of aggregation $': function state_of_aggregation_$(input) { + // ... or crystal system + var a = mhchemParser.patterns.findObserveGroups(input, "", /^\([a-z]{1,3}(?=[\),])/, ")", ""); // (aq), (aq,$\infty$), (aq, sat) + if (a && a.remainder.match(/^($|[\s,;\)\]\}])/)) { + return a; + } // AND end of 'phrase' + var m = input.match(/^(?:\((?:\\ca\s?)?\$[amothc]\$\))/); // OR crystal system ($o$) (\ca$c$) + if (m) { + return { + match_: m[0], + remainder: input.substr(m[0].length) + }; + } + return null; + }, + '_{(state of aggregation)}$': /^_\{(\([a-z]{1,3}\))\}/, + '{[(': /^(?:\\\{|\[|\()/, + ')]}': /^(?:\)|\]|\\\})/, + ', ': /^[,;]\s*/, + ',': /^[,;]/, + '.': /^[.]/, + '. ': /^([.\u22C5\u00B7\u2022])\s*/, + '...': /^\.\.\.(?=$|[^.])/, + '* ': /^([*])\s*/, + '^{(...)}': function _(input) { + return mhchemParser.patterns.findObserveGroups(input, "^{", "", "", "}"); + }, + '^($...$)': function $$(input) { + return mhchemParser.patterns.findObserveGroups(input, "^", "$", "$", ""); + }, + '^a': /^\^([0-9]+|[^\\_])/, + '^\\x{}{}': function x(input) { + return mhchemParser.patterns.findObserveGroups(input, "^", /^\\[a-zA-Z]+\{/, "}", "", "", "{", "}", "", true); + }, + '^\\x{}': function x(input) { + return mhchemParser.patterns.findObserveGroups(input, "^", /^\\[a-zA-Z]+\{/, "}", ""); + }, + '^\\x': /^\^(\\[a-zA-Z]+)\s*/, + '^(-1)': /^\^(-?\d+)/, + '\'': /^'/, + '_{(...)}': function _(input) { + return mhchemParser.patterns.findObserveGroups(input, "_{", "", "", "}"); + }, + '_($...$)': function _$$(input) { + return mhchemParser.patterns.findObserveGroups(input, "_", "$", "$", ""); + }, + '_9': /^_([+\-]?[0-9]+|[^\\])/, + '_\\x{}{}': function _X(input) { + return mhchemParser.patterns.findObserveGroups(input, "_", /^\\[a-zA-Z]+\{/, "}", "", "", "{", "}", "", true); + }, + '_\\x{}': function _X(input) { + return mhchemParser.patterns.findObserveGroups(input, "_", /^\\[a-zA-Z]+\{/, "}", ""); + }, + '_\\x': /^_(\\[a-zA-Z]+)\s*/, + '^_': /^(?:\^(?=_)|\_(?=\^)|[\^_]$)/, + '{}': /^\{\}/, + '{...}': function _(input) { + return mhchemParser.patterns.findObserveGroups(input, "", "{", "}", ""); + }, + '{(...)}': function _(input) { + return mhchemParser.patterns.findObserveGroups(input, "{", "", "", "}"); + }, + '$...$': function $$(input) { + return mhchemParser.patterns.findObserveGroups(input, "", "$", "$", ""); + }, + '${(...)}$': function $$(input) { + return mhchemParser.patterns.findObserveGroups(input, "${", "", "", "}$"); + }, + '$(...)$': function $$(input) { + return mhchemParser.patterns.findObserveGroups(input, "$", "", "", "$"); + }, + '=<>': /^[=<>]/, + '#': /^[#\u2261]/, + '+': /^\+/, + '-$': /^-(?=[\s_},;\]/]|$|\([a-z]+\))/, + // -space -, -; -] -/ -$ -state-of-aggregation + '-9': /^-(?=[0-9])/, + '- orbital overlap': /^-(?=(?:[spd]|sp)(?:$|[\s,;\)\]\}]))/, + '-': /^-/, + 'pm-operator': /^(?:\\pm|\$\\pm\$|\+-|\+\/-)/, + 'operator': /^(?:\+|(?:[\-=<>]|<<|>>|\\approx|\$\\approx\$)(?=\s|$|-?[0-9]))/, + 'arrowUpDown': /^(?:v|\(v\)|\^|\(\^\))(?=$|[\s,;\)\]\}])/, + '\\bond{(...)}': function bond(input) { + return mhchemParser.patterns.findObserveGroups(input, "\\bond{", "", "", "}"); + }, + '->': /^(?:<->|<-->|->|<-|<=>>|<<=>|<=>|[\u2192\u27F6\u21CC])/, + 'CMT': /^[CMT](?=\[)/, + '[(...)]': function _(input) { + return mhchemParser.patterns.findObserveGroups(input, "[", "", "", "]"); + }, + '1st-level escape': /^(&|\\\\|\\hline)\s*/, + '\\,': /^(?:\\[,\ ;:])/, + // \\x - but output no space before + '\\x{}{}': function x(input) { + return mhchemParser.patterns.findObserveGroups(input, "", /^\\[a-zA-Z]+\{/, "}", "", "", "{", "}", "", true); + }, + '\\x{}': function x(input) { + return mhchemParser.patterns.findObserveGroups(input, "", /^\\[a-zA-Z]+\{/, "}", ""); + }, + '\\ca': /^\\ca(?:\s+|(?![a-zA-Z]))/, + '\\x': /^(?:\\[a-zA-Z]+\s*|\\[_&{}%])/, + 'orbital': /^(?:[0-9]{1,2}[spdfgh]|[0-9]{0,2}sp)(?=$|[^a-zA-Z])/, + // only those with numbers in front, because the others will be formatted correctly anyway + 'others': /^[\/~|]/, + '\\frac{(...)}': function frac(input) { + return mhchemParser.patterns.findObserveGroups(input, "\\frac{", "", "", "}", "{", "", "", "}"); + }, + '\\overset{(...)}': function overset(input) { + return mhchemParser.patterns.findObserveGroups(input, "\\overset{", "", "", "}", "{", "", "", "}"); + }, + '\\underset{(...)}': function underset(input) { + return mhchemParser.patterns.findObserveGroups(input, "\\underset{", "", "", "}", "{", "", "", "}"); + }, + '\\underbrace{(...)}': function underbrace(input) { + return mhchemParser.patterns.findObserveGroups(input, "\\underbrace{", "", "", "}_", "{", "", "", "}"); + }, + '\\color{(...)}0': function color0(input) { + return mhchemParser.patterns.findObserveGroups(input, "\\color{", "", "", "}"); + }, + '\\color{(...)}{(...)}1': function color1(input) { + return mhchemParser.patterns.findObserveGroups(input, "\\color{", "", "", "}", "{", "", "", "}"); + }, + '\\color(...){(...)}2': function color2(input) { + return mhchemParser.patterns.findObserveGroups(input, "\\color", "\\", "", /^(?=\{)/, "{", "", "", "}"); + }, + '\\ce{(...)}': function ce(input) { + return mhchemParser.patterns.findObserveGroups(input, "\\ce{", "", "", "}"); + }, + 'oxidation$': /^(?:[+-][IVX]+|\\pm\s*0|\$\\pm\$\s*0)$/, + 'd-oxidation$': /^(?:[+-]?\s?[IVX]+|\\pm\s*0|\$\\pm\$\s*0)$/, + // 0 could be oxidation or charge + 'roman numeral': /^[IVX]+/, + '1/2$': /^[+\-]?(?:[0-9]+|\$[a-z]\$|[a-z])\/[0-9]+(?:\$[a-z]\$|[a-z])?$/, + 'amount': function amount(input) { + var match; + // e.g. 2, 0.5, 1/2, -2, n/2, +; $a$ could be added later in parsing + match = input.match(/^(?:(?:(?:\([+\-]?[0-9]+\/[0-9]+\)|[+\-]?(?:[0-9]+|\$[a-z]\$|[a-z])\/[0-9]+|[+\-]?[0-9]+[.,][0-9]+|[+\-]?\.[0-9]+|[+\-]?[0-9]+)(?:[a-z](?=\s*[A-Z]))?)|[+\-]?[a-z](?=\s*[A-Z])|\+(?!\s))/); + if (match) { + return { + match_: match[0], + remainder: input.substr(match[0].length) + }; + } + var a = mhchemParser.patterns.findObserveGroups(input, "", "$", "$", ""); + if (a) { + // e.g. $2n-1$, $-$ + match = a.match_.match(/^\$(?:\(?[+\-]?(?:[0-9]*[a-z]?[+\-])?[0-9]*[a-z](?:[+\-][0-9]*[a-z]?)?\)?|\+|-)\$$/); + if (match) { + return { + match_: match[0], + remainder: input.substr(match[0].length) + }; + } + } + return null; + }, + 'amount2': function amount2(input) { + return this['amount'](input); + }, + '(KV letters),': /^(?:[A-Z][a-z]{0,2}|i)(?=,)/, + 'formula$': function formula$(input) { + if (input.match(/^\([a-z]+\)$/)) { + return null; + } // state of aggregation = no formula + var match = input.match(/^(?:[a-z]|(?:[0-9\ \+\-\,\.\(\)]+[a-z])+[0-9\ \+\-\,\.\(\)]*|(?:[a-z][0-9\ \+\-\,\.\(\)]+)+[a-z]?)$/); + if (match) { + return { + match_: match[0], + remainder: input.substr(match[0].length) + }; + } + return null; + }, + 'uprightEntities': /^(?:pH|pOH|pC|pK|iPr|iBu)(?=$|[^a-zA-Z])/, + '/': /^\s*(\/)\s*/, + '//': /^\s*(\/\/)\s*/, + '*': /^\s*[*.]\s*/ + }, + findObserveGroups: function findObserveGroups(input, begExcl, begIncl, endIncl, endExcl, beg2Excl, beg2Incl, end2Incl, end2Excl, combine) { + /** @type {{(input: string, pattern: string | RegExp): string | string[] | null;}} */ + var _match = function _match(input, pattern) { + if (typeof pattern === "string") { + if (input.indexOf(pattern) !== 0) { + return null; + } + return pattern; + } else { + var match = input.match(pattern); + if (!match) { + return null; + } + return match[0]; + } + }; + /** @type {{(input: string, i: number, endChars: string | RegExp): {endMatchBegin: number, endMatchEnd: number} | null;}} */ + var _findObserveGroups = function _findObserveGroups(input, i, endChars) { + var braces = 0; + while (i < input.length) { + var a = input.charAt(i); + var match = _match(input.substr(i), endChars); + if (match !== null && braces === 0) { + return { + endMatchBegin: i, + endMatchEnd: i + match.length + }; + } else if (a === "{") { + braces++; + } else if (a === "}") { + if (braces === 0) { + throw ["ExtraCloseMissingOpen", "Extra close brace or missing open brace"]; + } else { + braces--; + } + } + i++; + } + if (braces > 0) { + return null; + } + return null; + }; + var match = _match(input, begExcl); + if (match === null) { + return null; + } + input = input.substr(match.length); + match = _match(input, begIncl); + if (match === null) { + return null; + } + var e = _findObserveGroups(input, match.length, endIncl || endExcl); + if (e === null) { + return null; + } + var match1 = input.substring(0, endIncl ? e.endMatchEnd : e.endMatchBegin); + if (!(beg2Excl || beg2Incl)) { + return { + match_: match1, + remainder: input.substr(e.endMatchEnd) + }; + } else { + var group2 = this.findObserveGroups(input.substr(e.endMatchEnd), beg2Excl, beg2Incl, end2Incl, end2Excl); + if (group2 === null) { + return null; + } + /** @type {string[]} */ + var matchRet = [match1, group2.match_]; + return { + match_: combine ? matchRet.join("") : matchRet, + remainder: group2.remainder + }; + } + }, + // + // Matching function + // e.g. match("a", input) will look for the regexp called "a" and see if it matches + // returns null or {match_:"a", remainder:"bc"} + // + match_: function match_(m, input) { + var pattern = mhchemParser.patterns.patterns[m]; + if (pattern === undefined) { + throw ["MhchemBugP", "mhchem bug P. Please report. (" + m + ")"]; // Trying to use non-existing pattern + } else if (typeof pattern === "function") { + return mhchemParser.patterns.patterns[m](input); // cannot use cached var pattern here, because some pattern functions need this===mhchemParser + } else { + // RegExp + var match = input.match(pattern); + if (match) { + var mm; + if (match[2]) { + mm = [match[1], match[2]]; + } else if (match[1]) { + mm = match[1]; + } else { + mm = match[0]; + } + return { + match_: mm, + remainder: input.substr(match[0].length) + }; + } + return null; + } + } + }, + // + // Generic state machine actions + // + actions: { + 'a=': function a(buffer, m) { + buffer.a = (buffer.a || "") + m; + }, + 'b=': function b(buffer, m) { + buffer.b = (buffer.b || "") + m; + }, + 'p=': function p(buffer, m) { + buffer.p = (buffer.p || "") + m; + }, + 'o=': function o(buffer, m) { + buffer.o = (buffer.o || "") + m; + }, + 'q=': function q(buffer, m) { + buffer.q = (buffer.q || "") + m; + }, + 'd=': function d(buffer, m) { + buffer.d = (buffer.d || "") + m; + }, + 'rm=': function rm(buffer, m) { + buffer.rm = (buffer.rm || "") + m; + }, + 'text=': function text(buffer, m) { + buffer.text_ = (buffer.text_ || "") + m; + }, + 'insert': function insert(buffer, m, a) { + return { + type_: a + }; + }, + 'insert+p1': function insertP1(buffer, m, a) { + return { + type_: a, + p1: m + }; + }, + 'insert+p1+p2': function insertP1P2(buffer, m, a) { + return { + type_: a, + p1: m[0], + p2: m[1] + }; + }, + 'copy': function copy(buffer, m) { + return m; + }, + 'rm': function rm(buffer, m) { + return { + type_: 'rm', + p1: m || "" + }; + }, + 'text': function text(buffer, m) { + return mhchemParser.go(m, 'text'); + }, + '{text}': function text(buffer, m) { + var ret = ["{"]; + mhchemParser.concatArray(ret, mhchemParser.go(m, 'text')); + ret.push("}"); + return ret; + }, + 'tex-math': function texMath(buffer, m) { + return mhchemParser.go(m, 'tex-math'); + }, + 'tex-math tight': function texMath_tight(buffer, m) { + return mhchemParser.go(m, 'tex-math tight'); + }, + 'bond': function bond(buffer, m, k) { + return { + type_: 'bond', + kind_: k || m + }; + }, + 'color0-output': function color0Output(buffer, m) { + return { + type_: 'color0', + color: m[0] + }; + }, + 'ce': function ce(buffer, m) { + return mhchemParser.go(m); + }, + '1/2': function _2(buffer, m) { + /** @type {ParserOutput[]} */ + var ret = []; + if (m.match(/^[+\-]/)) { + ret.push(m.substr(0, 1)); + m = m.substr(1); + } + var n = m.match(/^([0-9]+|\$[a-z]\$|[a-z])\/([0-9]+)(\$[a-z]\$|[a-z])?$/); + n[1] = n[1].replace(/\$/g, ""); + ret.push({ + type_: 'frac', + p1: n[1], + p2: n[2] + }); + if (n[3]) { + n[3] = n[3].replace(/\$/g, ""); + ret.push({ + type_: 'tex-math', + p1: n[3] + }); + } + return ret; + }, + '9,9': function _(buffer, m) { + return mhchemParser.go(m, '9,9'); + } + }, + // + // createTransitions + // convert { 'letter': { 'state': { action_: 'output' } } } to { 'state' => [ { pattern: 'letter', task: { action_: [{type_: 'output'}] } } ] } + // with expansion of 'a|b' to 'a' and 'b' (at 2 places) + // + createTransitions: function createTransitions(o) { + var pattern, state; + /** @type {string[]} */ + var stateArray; + var i; + // + // 1. Collect all states + // + /** @type {Transitions} */ + var transitions = {}; + for (pattern in o) { + for (state in o[pattern]) { + stateArray = state.split("|"); + o[pattern][state].stateArray = stateArray; + for (i = 0; i < stateArray.length; i++) { + transitions[stateArray[i]] = []; + } + } + } + // + // 2. Fill states + // + for (pattern in o) { + for (state in o[pattern]) { + stateArray = o[pattern][state].stateArray || []; + for (i = 0; i < stateArray.length; i++) { + // + // 2a. Normalize actions into array: 'text=' ==> [{type_:'text='}] + // (Note to myself: Resolving the function here would be problematic. It would need .bind (for *this*) and currying (for *option*).) + // + /** @type {any} */ + var p = o[pattern][state]; + if (p.action_) { + p.action_ = [].concat(p.action_); + for (var k = 0; k < p.action_.length; k++) { + if (typeof p.action_[k] === "string") { + p.action_[k] = { + type_: p.action_[k] + }; + } + } + } else { + p.action_ = []; + } + // + // 2.b Multi-insert + // + var patternArray = pattern.split("|"); + for (var j = 0; j < patternArray.length; j++) { + if (stateArray[i] === '*') { + // insert into all + for (var t in transitions) { + transitions[t].push({ + pattern: patternArray[j], + task: p + }); + } + } else { + transitions[stateArray[i]].push({ + pattern: patternArray[j], + task: p + }); + } + } + } + } + } + return transitions; + }, + stateMachines: {} +}; + +// +// Definition of state machines +// +mhchemParser.stateMachines = { + // + // \ce state machines + // + //#region ce + 'ce': { + // main parser + transitions: mhchemParser.createTransitions({ + 'empty': { + '*': { + action_: 'output' + } + }, + 'else': { + '0|1|2': { + action_: 'beginsWithBond=false', + revisit: true, + toContinue: true + } + }, + 'oxidation$': { + '0': { + action_: 'oxidation-output' + } + }, + 'CMT': { + 'r': { + action_: 'rdt=', + nextState: 'rt' + }, + 'rd': { + action_: 'rqt=', + nextState: 'rdt' + } + }, + 'arrowUpDown': { + '0|1|2|as': { + action_: ['sb=false', 'output', 'operator'], + nextState: '1' + } + }, + 'uprightEntities': { + '0|1|2': { + action_: ['o=', 'output'], + nextState: '1' + } + }, + 'orbital': { + '0|1|2|3': { + action_: 'o=', + nextState: 'o' + } + }, + '->': { + '0|1|2|3': { + action_: 'r=', + nextState: 'r' + }, + 'a|as': { + action_: ['output', 'r='], + nextState: 'r' + }, + '*': { + action_: ['output', 'r='], + nextState: 'r' + } + }, + '+': { + 'o': { + action_: 'd= kv', + nextState: 'd' + }, + 'd|D': { + action_: 'd=', + nextState: 'd' + }, + 'q': { + action_: 'd=', + nextState: 'qd' + }, + 'qd|qD': { + action_: 'd=', + nextState: 'qd' + }, + 'dq': { + action_: ['output', 'd='], + nextState: 'd' + }, + '3': { + action_: ['sb=false', 'output', 'operator'], + nextState: '0' + } + }, + 'amount': { + '0|2': { + action_: 'a=', + nextState: 'a' + } + }, + 'pm-operator': { + '0|1|2|a|as': { + action_: ['sb=false', 'output', { + type_: 'operator', + option: '\\pm' + }], + nextState: '0' + } + }, + 'operator': { + '0|1|2|a|as': { + action_: ['sb=false', 'output', 'operator'], + nextState: '0' + } + }, + '-$': { + 'o|q': { + action_: ['charge or bond', 'output'], + nextState: 'qd' + }, + 'd': { + action_: 'd=', + nextState: 'd' + }, + 'D': { + action_: ['output', { + type_: 'bond', + option: "-" + }], + nextState: '3' + }, + 'q': { + action_: 'd=', + nextState: 'qd' + }, + 'qd': { + action_: 'd=', + nextState: 'qd' + }, + 'qD|dq': { + action_: ['output', { + type_: 'bond', + option: "-" + }], + nextState: '3' + } + }, + '-9': { + '3|o': { + action_: ['output', { + type_: 'insert', + option: 'hyphen' + }], + nextState: '3' + } + }, + '- orbital overlap': { + 'o': { + action_: ['output', { + type_: 'insert', + option: 'hyphen' + }], + nextState: '2' + }, + 'd': { + action_: ['output', { + type_: 'insert', + option: 'hyphen' + }], + nextState: '2' + } + }, + '-': { + '0|1|2': { + action_: [{ + type_: 'output', + option: 1 + }, 'beginsWithBond=true', { + type_: 'bond', + option: "-" + }], + nextState: '3' + }, + '3': { + action_: { + type_: 'bond', + option: "-" + } + }, + 'a': { + action_: ['output', { + type_: 'insert', + option: 'hyphen' + }], + nextState: '2' + }, + 'as': { + action_: [{ + type_: 'output', + option: 2 + }, { + type_: 'bond', + option: "-" + }], + nextState: '3' + }, + 'b': { + action_: 'b=' + }, + 'o': { + action_: { + type_: '- after o/d', + option: false + }, + nextState: '2' + }, + 'q': { + action_: { + type_: '- after o/d', + option: false + }, + nextState: '2' + }, + 'd|qd|dq': { + action_: { + type_: '- after o/d', + option: true + }, + nextState: '2' + }, + 'D|qD|p': { + action_: ['output', { + type_: 'bond', + option: "-" + }], + nextState: '3' + } + }, + 'amount2': { + '1|3': { + action_: 'a=', + nextState: 'a' + } + }, + 'letters': { + '0|1|2|3|a|as|b|p|bp|o': { + action_: 'o=', + nextState: 'o' + }, + 'q|dq': { + action_: ['output', 'o='], + nextState: 'o' + }, + 'd|D|qd|qD': { + action_: 'o after d', + nextState: 'o' + } + }, + 'digits': { + 'o': { + action_: 'q=', + nextState: 'q' + }, + 'd|D': { + action_: 'q=', + nextState: 'dq' + }, + 'q': { + action_: ['output', 'o='], + nextState: 'o' + }, + 'a': { + action_: 'o=', + nextState: 'o' + } + }, + 'space A': { + 'b|p|bp': {} + }, + 'space': { + 'a': { + nextState: 'as' + }, + '0': { + action_: 'sb=false' + }, + '1|2': { + action_: 'sb=true' + }, + 'r|rt|rd|rdt|rdq': { + action_: 'output', + nextState: '0' + }, + '*': { + action_: ['output', 'sb=true'], + nextState: '1' + } + }, + '1st-level escape': { + '1|2': { + action_: ['output', { + type_: 'insert+p1', + option: '1st-level escape' + }] + }, + '*': { + action_: ['output', { + type_: 'insert+p1', + option: '1st-level escape' + }], + nextState: '0' + } + }, + '[(...)]': { + 'r|rt': { + action_: 'rd=', + nextState: 'rd' + }, + 'rd|rdt': { + action_: 'rq=', + nextState: 'rdq' + } + }, + '...': { + 'o|d|D|dq|qd|qD': { + action_: ['output', { + type_: 'bond', + option: "..." + }], + nextState: '3' + }, + '*': { + action_: [{ + type_: 'output', + option: 1 + }, { + type_: 'insert', + option: 'ellipsis' + }], + nextState: '1' + } + }, + '. |* ': { + '*': { + action_: ['output', { + type_: 'insert', + option: 'addition compound' + }], + nextState: '1' + } + }, + 'state of aggregation $': { + '*': { + action_: ['output', 'state of aggregation'], + nextState: '1' + } + }, + '{[(': { + 'a|as|o': { + action_: ['o=', 'output', 'parenthesisLevel++'], + nextState: '2' + }, + '0|1|2|3': { + action_: ['o=', 'output', 'parenthesisLevel++'], + nextState: '2' + }, + '*': { + action_: ['output', 'o=', 'output', 'parenthesisLevel++'], + nextState: '2' + } + }, + ')]}': { + '0|1|2|3|b|p|bp|o': { + action_: ['o=', 'parenthesisLevel--'], + nextState: 'o' + }, + 'a|as|d|D|q|qd|qD|dq': { + action_: ['output', 'o=', 'parenthesisLevel--'], + nextState: 'o' + } + }, + ', ': { + '*': { + action_: ['output', 'comma'], + nextState: '0' + } + }, + '^_': { + // ^ and _ without a sensible argument + '*': {} + }, + '^{(...)}|^($...$)': { + '0|1|2|as': { + action_: 'b=', + nextState: 'b' + }, + 'p': { + action_: 'b=', + nextState: 'bp' + }, + '3|o': { + action_: 'd= kv', + nextState: 'D' + }, + 'q': { + action_: 'd=', + nextState: 'qD' + }, + 'd|D|qd|qD|dq': { + action_: ['output', 'd='], + nextState: 'D' + } + }, + '^a|^\\x{}{}|^\\x{}|^\\x|\'': { + '0|1|2|as': { + action_: 'b=', + nextState: 'b' + }, + 'p': { + action_: 'b=', + nextState: 'bp' + }, + '3|o': { + action_: 'd= kv', + nextState: 'd' + }, + 'q': { + action_: 'd=', + nextState: 'qd' + }, + 'd|qd|D|qD': { + action_: 'd=' + }, + 'dq': { + action_: ['output', 'd='], + nextState: 'd' + } + }, + '_{(state of aggregation)}$': { + 'd|D|q|qd|qD|dq': { + action_: ['output', 'q='], + nextState: 'q' + } + }, + '_{(...)}|_($...$)|_9|_\\x{}{}|_\\x{}|_\\x': { + '0|1|2|as': { + action_: 'p=', + nextState: 'p' + }, + 'b': { + action_: 'p=', + nextState: 'bp' + }, + '3|o': { + action_: 'q=', + nextState: 'q' + }, + 'd|D': { + action_: 'q=', + nextState: 'dq' + }, + 'q|qd|qD|dq': { + action_: ['output', 'q='], + nextState: 'q' + } + }, + '=<>': { + '0|1|2|3|a|as|o|q|d|D|qd|qD|dq': { + action_: [{ + type_: 'output', + option: 2 + }, 'bond'], + nextState: '3' + } + }, + '#': { + '0|1|2|3|a|as|o': { + action_: [{ + type_: 'output', + option: 2 + }, { + type_: 'bond', + option: "#" + }], + nextState: '3' + } + }, + '{}': { + '*': { + action_: { + type_: 'output', + option: 1 + }, + nextState: '1' + } + }, + '{...}': { + '0|1|2|3|a|as|b|p|bp': { + action_: 'o=', + nextState: 'o' + }, + 'o|d|D|q|qd|qD|dq': { + action_: ['output', 'o='], + nextState: 'o' + } + }, + '$...$': { + 'a': { + action_: 'a=' + }, + // 2$n$ + '0|1|2|3|as|b|p|bp|o': { + action_: 'o=', + nextState: 'o' + }, + // not 'amount' + 'as|o': { + action_: 'o=' + }, + 'q|d|D|qd|qD|dq': { + action_: ['output', 'o='], + nextState: 'o' + } + }, + '\\bond{(...)}': { + '*': { + action_: [{ + type_: 'output', + option: 2 + }, 'bond'], + nextState: "3" + } + }, + '\\frac{(...)}': { + '*': { + action_: [{ + type_: 'output', + option: 1 + }, 'frac-output'], + nextState: '3' + } + }, + '\\overset{(...)}': { + '*': { + action_: [{ + type_: 'output', + option: 2 + }, 'overset-output'], + nextState: '3' + } + }, + '\\underset{(...)}': { + '*': { + action_: [{ + type_: 'output', + option: 2 + }, 'underset-output'], + nextState: '3' + } + }, + '\\underbrace{(...)}': { + '*': { + action_: [{ + type_: 'output', + option: 2 + }, 'underbrace-output'], + nextState: '3' + } + }, + '\\color{(...)}{(...)}1|\\color(...){(...)}2': { + '*': { + action_: [{ + type_: 'output', + option: 2 + }, 'color-output'], + nextState: '3' + } + }, + '\\color{(...)}0': { + '*': { + action_: [{ + type_: 'output', + option: 2 + }, 'color0-output'] + } + }, + '\\ce{(...)}': { + '*': { + action_: [{ + type_: 'output', + option: 2 + }, 'ce'], + nextState: '3' + } + }, + '\\,': { + '*': { + action_: [{ + type_: 'output', + option: 1 + }, 'copy'], + nextState: '1' + } + }, + '\\x{}{}|\\x{}|\\x': { + '0|1|2|3|a|as|b|p|bp|o|c0': { + action_: ['o=', 'output'], + nextState: '3' + }, + '*': { + action_: ['output', 'o=', 'output'], + nextState: '3' + } + }, + 'others': { + '*': { + action_: [{ + type_: 'output', + option: 1 + }, 'copy'], + nextState: '3' + } + }, + 'else2': { + 'a': { + action_: 'a to o', + nextState: 'o', + revisit: true + }, + 'as': { + action_: ['output', 'sb=true'], + nextState: '1', + revisit: true + }, + 'r|rt|rd|rdt|rdq': { + action_: ['output'], + nextState: '0', + revisit: true + }, + '*': { + action_: ['output', 'copy'], + nextState: '3' + } + } + }), + actions: { + 'o after d': function o_after_d(buffer, m) { + var ret; + if ((buffer.d || "").match(/^[0-9]+$/)) { + var tmp = buffer.d; + buffer.d = undefined; + ret = this['output'](buffer); + buffer.b = tmp; + } else { + ret = this['output'](buffer); + } + mhchemParser.actions['o='](buffer, m); + return ret; + }, + 'd= kv': function d_kv(buffer, m) { + buffer.d = m; + buffer.dType = 'kv'; + }, + 'charge or bond': function charge_or_bond(buffer, m) { + if (buffer['beginsWithBond']) { + /** @type {ParserOutput[]} */ + var ret = []; + mhchemParser.concatArray(ret, this['output'](buffer)); + mhchemParser.concatArray(ret, mhchemParser.actions['bond'](buffer, m, "-")); + return ret; + } else { + buffer.d = m; + } + }, + '- after o/d': function _after_o_d(buffer, m, isAfterD) { + var c1 = mhchemParser.patterns.match_('orbital', buffer.o || ""); + var c2 = mhchemParser.patterns.match_('one lowercase greek letter $', buffer.o || ""); + var c3 = mhchemParser.patterns.match_('one lowercase latin letter $', buffer.o || ""); + var c4 = mhchemParser.patterns.match_('$one lowercase latin letter$ $', buffer.o || ""); + var hyphenFollows = m === "-" && (c1 && c1.remainder === "" || c2 || c3 || c4); + if (hyphenFollows && !buffer.a && !buffer.b && !buffer.p && !buffer.d && !buffer.q && !c1 && c3) { + buffer.o = '$' + buffer.o + '$'; + } + /** @type {ParserOutput[]} */ + var ret = []; + if (hyphenFollows) { + mhchemParser.concatArray(ret, this['output'](buffer)); + ret.push({ + type_: 'hyphen' + }); + } else { + c1 = mhchemParser.patterns.match_('digits', buffer.d || ""); + if (isAfterD && c1 && c1.remainder === '') { + mhchemParser.concatArray(ret, mhchemParser.actions['d='](buffer, m)); + mhchemParser.concatArray(ret, this['output'](buffer)); + } else { + mhchemParser.concatArray(ret, this['output'](buffer)); + mhchemParser.concatArray(ret, mhchemParser.actions['bond'](buffer, m, "-")); + } + } + return ret; + }, + 'a to o': function a_to_o(buffer) { + buffer.o = buffer.a; + buffer.a = undefined; + }, + 'sb=true': function sbTrue(buffer) { + buffer.sb = true; + }, + 'sb=false': function sbFalse(buffer) { + buffer.sb = false; + }, + 'beginsWithBond=true': function beginsWithBondTrue(buffer) { + buffer['beginsWithBond'] = true; + }, + 'beginsWithBond=false': function beginsWithBondFalse(buffer) { + buffer['beginsWithBond'] = false; + }, + 'parenthesisLevel++': function parenthesisLevel(buffer) { + buffer['parenthesisLevel']++; + }, + 'parenthesisLevel--': function parenthesisLevel(buffer) { + buffer['parenthesisLevel']--; + }, + 'state of aggregation': function state_of_aggregation(buffer, m) { + return { + type_: 'state of aggregation', + p1: mhchemParser.go(m, 'o') + }; + }, + 'comma': function comma(buffer, m) { + var a = m.replace(/\s*$/, ''); + var withSpace = a !== m; + if (withSpace && buffer['parenthesisLevel'] === 0) { + return { + type_: 'comma enumeration L', + p1: a + }; + } else { + return { + type_: 'comma enumeration M', + p1: a + }; + } + }, + 'output': function output(buffer, m, entityFollows) { + // entityFollows: + // undefined = if we have nothing else to output, also ignore the just read space (buffer.sb) + // 1 = an entity follows, never omit the space if there was one just read before (can only apply to state 1) + // 2 = 1 + the entity can have an amount, so output a\, instead of converting it to o (can only apply to states a|as) + /** @type {ParserOutput | ParserOutput[]} */ + var ret; + if (!buffer.r) { + ret = []; + if (!buffer.a && !buffer.b && !buffer.p && !buffer.o && !buffer.q && !buffer.d && !entityFollows) ; else { + if (buffer.sb) { + ret.push({ + type_: 'entitySkip' + }); + } + if (!buffer.o && !buffer.q && !buffer.d && !buffer.b && !buffer.p && entityFollows !== 2) { + buffer.o = buffer.a; + buffer.a = undefined; + } else if (!buffer.o && !buffer.q && !buffer.d && (buffer.b || buffer.p)) { + buffer.o = buffer.a; + buffer.d = buffer.b; + buffer.q = buffer.p; + buffer.a = buffer.b = buffer.p = undefined; + } else { + if (buffer.o && buffer.dType === 'kv' && mhchemParser.patterns.match_('d-oxidation$', buffer.d || "")) { + buffer.dType = 'oxidation'; + } else if (buffer.o && buffer.dType === 'kv' && !buffer.q) { + buffer.dType = undefined; + } + } + ret.push({ + type_: 'chemfive', + a: mhchemParser.go(buffer.a, 'a'), + b: mhchemParser.go(buffer.b, 'bd'), + p: mhchemParser.go(buffer.p, 'pq'), + o: mhchemParser.go(buffer.o, 'o'), + q: mhchemParser.go(buffer.q, 'pq'), + d: mhchemParser.go(buffer.d, buffer.dType === 'oxidation' ? 'oxidation' : 'bd'), + dType: buffer.dType + }); + } + } else { + // r + /** @type {ParserOutput[]} */ + var rd; + if (buffer.rdt === 'M') { + rd = mhchemParser.go(buffer.rd, 'tex-math'); + } else if (buffer.rdt === 'T') { + rd = [{ + type_: 'text', + p1: buffer.rd || "" + }]; + } else { + rd = mhchemParser.go(buffer.rd); + } + /** @type {ParserOutput[]} */ + var rq; + if (buffer.rqt === 'M') { + rq = mhchemParser.go(buffer.rq, 'tex-math'); + } else if (buffer.rqt === 'T') { + rq = [{ + type_: 'text', + p1: buffer.rq || "" + }]; + } else { + rq = mhchemParser.go(buffer.rq); + } + ret = { + type_: 'arrow', + r: buffer.r, + rd: rd, + rq: rq + }; + } + for (var p in buffer) { + if (p !== 'parenthesisLevel' && p !== 'beginsWithBond') { + delete buffer[p]; + } + } + return ret; + }, + 'oxidation-output': function oxidationOutput(buffer, m) { + var ret = ["{"]; + mhchemParser.concatArray(ret, mhchemParser.go(m, 'oxidation')); + ret.push("}"); + return ret; + }, + 'frac-output': function fracOutput(buffer, m) { + return { + type_: 'frac-ce', + p1: mhchemParser.go(m[0]), + p2: mhchemParser.go(m[1]) + }; + }, + 'overset-output': function oversetOutput(buffer, m) { + return { + type_: 'overset', + p1: mhchemParser.go(m[0]), + p2: mhchemParser.go(m[1]) + }; + }, + 'underset-output': function undersetOutput(buffer, m) { + return { + type_: 'underset', + p1: mhchemParser.go(m[0]), + p2: mhchemParser.go(m[1]) + }; + }, + 'underbrace-output': function underbraceOutput(buffer, m) { + return { + type_: 'underbrace', + p1: mhchemParser.go(m[0]), + p2: mhchemParser.go(m[1]) + }; + }, + 'color-output': function colorOutput(buffer, m) { + return { + type_: 'color', + color1: m[0], + color2: mhchemParser.go(m[1]) + }; + }, + 'r=': function r(buffer, m) { + buffer.r = m; + }, + 'rdt=': function rdt(buffer, m) { + buffer.rdt = m; + }, + 'rd=': function rd(buffer, m) { + buffer.rd = m; + }, + 'rqt=': function rqt(buffer, m) { + buffer.rqt = m; + }, + 'rq=': function rq(buffer, m) { + buffer.rq = m; + }, + 'operator': function operator(buffer, m, p1) { + return { + type_: 'operator', + kind_: p1 || m + }; + } + } + }, + 'a': { + transitions: mhchemParser.createTransitions({ + 'empty': { + '*': {} + }, + '1/2$': { + '0': { + action_: '1/2' + } + }, + 'else': { + '0': { + nextState: '1', + revisit: true + } + }, + '$(...)$': { + '*': { + action_: 'tex-math tight', + nextState: '1' + } + }, + ',': { + '*': { + action_: { + type_: 'insert', + option: 'commaDecimal' + } + } + }, + 'else2': { + '*': { + action_: 'copy' + } + } + }), + actions: {} + }, + 'o': { + transitions: mhchemParser.createTransitions({ + 'empty': { + '*': {} + }, + '1/2$': { + '0': { + action_: '1/2' + } + }, + 'else': { + '0': { + nextState: '1', + revisit: true + } + }, + 'letters': { + '*': { + action_: 'rm' + } + }, + '\\ca': { + '*': { + action_: { + type_: 'insert', + option: 'circa' + } + } + }, + '\\x{}{}|\\x{}|\\x': { + '*': { + action_: 'copy' + } + }, + '${(...)}$|$(...)$': { + '*': { + action_: 'tex-math' + } + }, + '{(...)}': { + '*': { + action_: '{text}' + } + }, + 'else2': { + '*': { + action_: 'copy' + } + } + }), + actions: {} + }, + 'text': { + transitions: mhchemParser.createTransitions({ + 'empty': { + '*': { + action_: 'output' + } + }, + '{...}': { + '*': { + action_: 'text=' + } + }, + '${(...)}$|$(...)$': { + '*': { + action_: 'tex-math' + } + }, + '\\greek': { + '*': { + action_: ['output', 'rm'] + } + }, + '\\,|\\x{}{}|\\x{}|\\x': { + '*': { + action_: ['output', 'copy'] + } + }, + 'else': { + '*': { + action_: 'text=' + } + } + }), + actions: { + 'output': function output(buffer) { + if (buffer.text_) { + /** @type {ParserOutput} */ + var ret = { + type_: 'text', + p1: buffer.text_ + }; + for (var p in buffer) { + delete buffer[p]; + } + return ret; + } + } + } + }, + 'pq': { + transitions: mhchemParser.createTransitions({ + 'empty': { + '*': {} + }, + 'state of aggregation $': { + '*': { + action_: 'state of aggregation' + } + }, + 'i$': { + '0': { + nextState: '!f', + revisit: true + } + }, + '(KV letters),': { + '0': { + action_: 'rm', + nextState: '0' + } + }, + 'formula$': { + '0': { + nextState: 'f', + revisit: true + } + }, + '1/2$': { + '0': { + action_: '1/2' + } + }, + 'else': { + '0': { + nextState: '!f', + revisit: true + } + }, + '${(...)}$|$(...)$': { + '*': { + action_: 'tex-math' + } + }, + '{(...)}': { + '*': { + action_: 'text' + } + }, + 'a-z': { + 'f': { + action_: 'tex-math' + } + }, + 'letters': { + '*': { + action_: 'rm' + } + }, + '-9.,9': { + '*': { + action_: '9,9' + } + }, + ',': { + '*': { + action_: { + type_: 'insert+p1', + option: 'comma enumeration S' + } + } + }, + '\\color{(...)}{(...)}1|\\color(...){(...)}2': { + '*': { + action_: 'color-output' + } + }, + '\\color{(...)}0': { + '*': { + action_: 'color0-output' + } + }, + '\\ce{(...)}': { + '*': { + action_: 'ce' + } + }, + '\\,|\\x{}{}|\\x{}|\\x': { + '*': { + action_: 'copy' + } + }, + 'else2': { + '*': { + action_: 'copy' + } + } + }), + actions: { + 'state of aggregation': function state_of_aggregation(buffer, m) { + return { + type_: 'state of aggregation subscript', + p1: mhchemParser.go(m, 'o') + }; + }, + 'color-output': function colorOutput(buffer, m) { + return { + type_: 'color', + color1: m[0], + color2: mhchemParser.go(m[1], 'pq') + }; + } + } + }, + 'bd': { + transitions: mhchemParser.createTransitions({ + 'empty': { + '*': {} + }, + 'x$': { + '0': { + nextState: '!f', + revisit: true + } + }, + 'formula$': { + '0': { + nextState: 'f', + revisit: true + } + }, + 'else': { + '0': { + nextState: '!f', + revisit: true + } + }, + '-9.,9 no missing 0': { + '*': { + action_: '9,9' + } + }, + '.': { + '*': { + action_: { + type_: 'insert', + option: 'electron dot' + } + } + }, + 'a-z': { + 'f': { + action_: 'tex-math' + } + }, + 'x': { + '*': { + action_: { + type_: 'insert', + option: 'KV x' + } + } + }, + 'letters': { + '*': { + action_: 'rm' + } + }, + '\'': { + '*': { + action_: { + type_: 'insert', + option: 'prime' + } + } + }, + '${(...)}$|$(...)$': { + '*': { + action_: 'tex-math' + } + }, + '{(...)}': { + '*': { + action_: 'text' + } + }, + '\\color{(...)}{(...)}1|\\color(...){(...)}2': { + '*': { + action_: 'color-output' + } + }, + '\\color{(...)}0': { + '*': { + action_: 'color0-output' + } + }, + '\\ce{(...)}': { + '*': { + action_: 'ce' + } + }, + '\\,|\\x{}{}|\\x{}|\\x': { + '*': { + action_: 'copy' + } + }, + 'else2': { + '*': { + action_: 'copy' + } + } + }), + actions: { + 'color-output': function colorOutput(buffer, m) { + return { + type_: 'color', + color1: m[0], + color2: mhchemParser.go(m[1], 'bd') + }; + } + } + }, + 'oxidation': { + transitions: mhchemParser.createTransitions({ + 'empty': { + '*': {} + }, + 'roman numeral': { + '*': { + action_: 'roman-numeral' + } + }, + '${(...)}$|$(...)$': { + '*': { + action_: 'tex-math' + } + }, + 'else': { + '*': { + action_: 'copy' + } + } + }), + actions: { + 'roman-numeral': function romanNumeral(buffer, m) { + return { + type_: 'roman numeral', + p1: m || "" + }; + } + } + }, + 'tex-math': { + transitions: mhchemParser.createTransitions({ + 'empty': { + '*': { + action_: 'output' + } + }, + '\\ce{(...)}': { + '*': { + action_: ['output', 'ce'] + } + }, + '{...}|\\,|\\x{}{}|\\x{}|\\x': { + '*': { + action_: 'o=' + } + }, + 'else': { + '*': { + action_: 'o=' + } + } + }), + actions: { + 'output': function output(buffer) { + if (buffer.o) { + /** @type {ParserOutput} */ + var ret = { + type_: 'tex-math', + p1: buffer.o + }; + for (var p in buffer) { + delete buffer[p]; + } + return ret; + } + } + } + }, + 'tex-math tight': { + transitions: mhchemParser.createTransitions({ + 'empty': { + '*': { + action_: 'output' + } + }, + '\\ce{(...)}': { + '*': { + action_: ['output', 'ce'] + } + }, + '{...}|\\,|\\x{}{}|\\x{}|\\x': { + '*': { + action_: 'o=' + } + }, + '-|+': { + '*': { + action_: 'tight operator' + } + }, + 'else': { + '*': { + action_: 'o=' + } + } + }), + actions: { + 'tight operator': function tight_operator(buffer, m) { + buffer.o = (buffer.o || "") + "{" + m + "}"; + }, + 'output': function output(buffer) { + if (buffer.o) { + /** @type {ParserOutput} */ + var ret = { + type_: 'tex-math', + p1: buffer.o + }; + for (var p in buffer) { + delete buffer[p]; + } + return ret; + } + } + } + }, + '9,9': { + transitions: mhchemParser.createTransitions({ + 'empty': { + '*': {} + }, + ',': { + '*': { + action_: 'comma' + } + }, + 'else': { + '*': { + action_: 'copy' + } + } + }), + actions: { + 'comma': function comma() { + return { + type_: 'commaDecimal' + }; + } + } + }, + //#endregion + // + // \pu state machines + // + //#region pu + 'pu': { + transitions: mhchemParser.createTransitions({ + 'empty': { + '*': { + action_: 'output' + } + }, + 'space$': { + '*': { + action_: ['output', 'space'] + } + }, + '{[(|)]}': { + '0|a': { + action_: 'copy' + } + }, + '(-)(9)^(-9)': { + '0': { + action_: 'number^', + nextState: 'a' + } + }, + '(-)(9.,9)(e)(99)': { + '0': { + action_: 'enumber', + nextState: 'a' + } + }, + 'space': { + '0|a': {} + }, + 'pm-operator': { + '0|a': { + action_: { + type_: 'operator', + option: '\\pm' + }, + nextState: '0' + } + }, + 'operator': { + '0|a': { + action_: 'copy', + nextState: '0' + } + }, + '//': { + 'd': { + action_: 'o=', + nextState: '/' + } + }, + '/': { + 'd': { + action_: 'o=', + nextState: '/' + } + }, + '{...}|else': { + '0|d': { + action_: 'd=', + nextState: 'd' + }, + 'a': { + action_: ['space', 'd='], + nextState: 'd' + }, + '/|q': { + action_: 'q=', + nextState: 'q' + } + } + }), + actions: { + 'enumber': function enumber(buffer, m) { + /** @type {ParserOutput[]} */ + var ret = []; + if (m[0] === "+-" || m[0] === "+/-") { + ret.push("\\pm "); + } else if (m[0]) { + ret.push(m[0]); + } + if (m[1]) { + mhchemParser.concatArray(ret, mhchemParser.go(m[1], 'pu-9,9')); + if (m[2]) { + if (m[2].match(/[,.]/)) { + mhchemParser.concatArray(ret, mhchemParser.go(m[2], 'pu-9,9')); + } else { + ret.push(m[2]); + } + } + m[3] = m[4] || m[3]; + if (m[3]) { + m[3] = m[3].trim(); + if (m[3] === "e" || m[3].substr(0, 1) === "*") { + ret.push({ + type_: 'cdot' + }); + } else { + ret.push({ + type_: 'times' + }); + } + } + } + if (m[3]) { + ret.push("10^{" + m[5] + "}"); + } + return ret; + }, + 'number^': function number(buffer, m) { + /** @type {ParserOutput[]} */ + var ret = []; + if (m[0] === "+-" || m[0] === "+/-") { + ret.push("\\pm "); + } else if (m[0]) { + ret.push(m[0]); + } + mhchemParser.concatArray(ret, mhchemParser.go(m[1], 'pu-9,9')); + ret.push("^{" + m[2] + "}"); + return ret; + }, + 'operator': function operator(buffer, m, p1) { + return { + type_: 'operator', + kind_: p1 || m + }; + }, + 'space': function space() { + return { + type_: 'pu-space-1' + }; + }, + 'output': function output(buffer) { + /** @type {ParserOutput | ParserOutput[]} */ + var ret; + var md = mhchemParser.patterns.match_('{(...)}', buffer.d || ""); + if (md && md.remainder === '') { + buffer.d = md.match_; + } + var mq = mhchemParser.patterns.match_('{(...)}', buffer.q || ""); + if (mq && mq.remainder === '') { + buffer.q = mq.match_; + } + if (buffer.d) { + buffer.d = buffer.d.replace(/\u00B0C|\^oC|\^{o}C/g, "{}^{\\circ}C"); + buffer.d = buffer.d.replace(/\u00B0F|\^oF|\^{o}F/g, "{}^{\\circ}F"); + } + if (buffer.q) { + // fraction + buffer.q = buffer.q.replace(/\u00B0C|\^oC|\^{o}C/g, "{}^{\\circ}C"); + buffer.q = buffer.q.replace(/\u00B0F|\^oF|\^{o}F/g, "{}^{\\circ}F"); + var b5 = { + d: mhchemParser.go(buffer.d, 'pu'), + q: mhchemParser.go(buffer.q, 'pu') + }; + if (buffer.o === '//') { + ret = { + type_: 'pu-frac', + p1: b5.d, + p2: b5.q + }; + } else { + ret = b5.d; + if (b5.d.length > 1 || b5.q.length > 1) { + ret.push({ + type_: ' / ' + }); + } else { + ret.push({ + type_: '/' + }); + } + mhchemParser.concatArray(ret, b5.q); + } + } else { + // no fraction + ret = mhchemParser.go(buffer.d, 'pu-2'); + } + for (var p in buffer) { + delete buffer[p]; + } + return ret; + } + } + }, + 'pu-2': { + transitions: mhchemParser.createTransitions({ + 'empty': { + '*': { + action_: 'output' + } + }, + '*': { + '*': { + action_: ['output', 'cdot'], + nextState: '0' + } + }, + '\\x': { + '*': { + action_: 'rm=' + } + }, + 'space': { + '*': { + action_: ['output', 'space'], + nextState: '0' + } + }, + '^{(...)}|^(-1)': { + '1': { + action_: '^(-1)' + } + }, + '-9.,9': { + '0': { + action_: 'rm=', + nextState: '0' + }, + '1': { + action_: '^(-1)', + nextState: '0' + } + }, + '{...}|else': { + '*': { + action_: 'rm=', + nextState: '1' + } + } + }), + actions: { + 'cdot': function cdot() { + return { + type_: 'tight cdot' + }; + }, + '^(-1)': function _(buffer, m) { + buffer.rm += "^{" + m + "}"; + }, + 'space': function space() { + return { + type_: 'pu-space-2' + }; + }, + 'output': function output(buffer) { + /** @type {ParserOutput | ParserOutput[]} */ + var ret = []; + if (buffer.rm) { + var mrm = mhchemParser.patterns.match_('{(...)}', buffer.rm || ""); + if (mrm && mrm.remainder === '') { + ret = mhchemParser.go(mrm.match_, 'pu'); + } else { + ret = { + type_: 'rm', + p1: buffer.rm + }; + } + } + for (var p in buffer) { + delete buffer[p]; + } + return ret; + } + } + }, + 'pu-9,9': { + transitions: mhchemParser.createTransitions({ + 'empty': { + '0': { + action_: 'output-0' + }, + 'o': { + action_: 'output-o' + } + }, + ',': { + '0': { + action_: ['output-0', 'comma'], + nextState: 'o' + } + }, + '.': { + '0': { + action_: ['output-0', 'copy'], + nextState: 'o' + } + }, + 'else': { + '*': { + action_: 'text=' + } + } + }), + actions: { + 'comma': function comma() { + return { + type_: 'commaDecimal' + }; + }, + 'output-0': function output0(buffer) { + /** @type {ParserOutput[]} */ + var ret = []; + buffer.text_ = buffer.text_ || ""; + if (buffer.text_.length > 4) { + var a = buffer.text_.length % 3; + if (a === 0) { + a = 3; + } + for (var i = buffer.text_.length - 3; i > 0; i -= 3) { + ret.push(buffer.text_.substr(i, 3)); + ret.push({ + type_: '1000 separator' + }); + } + ret.push(buffer.text_.substr(0, a)); + ret.reverse(); + } else { + ret.push(buffer.text_); + } + for (var p in buffer) { + delete buffer[p]; + } + return ret; + }, + 'output-o': function outputO(buffer) { + /** @type {ParserOutput[]} */ + var ret = []; + buffer.text_ = buffer.text_ || ""; + if (buffer.text_.length > 4) { + var a = buffer.text_.length - 3; + for (var i = 0; i < a; i += 3) { + ret.push(buffer.text_.substr(i, 3)); + ret.push({ + type_: '1000 separator' + }); + } + ret.push(buffer.text_.substr(i)); + } else { + ret.push(buffer.text_); + } + for (var p in buffer) { + delete buffer[p]; + } + return ret; + } + } + } + //#endregion +}; + +// +// texify: Take MhchemParser output and convert it to TeX +// +/** @type {Texify} */ +var texify = { + go: function go(input, isInner) { + // (recursive, max 4 levels) + if (!input) { + return ""; + } + var res = ""; + var cee = false; + for (var i = 0; i < input.length; i++) { + var inputi = input[i]; + if (typeof inputi === "string") { + res += inputi; + } else { + res += texify._go2(inputi); + if (inputi.type_ === '1st-level escape') { + cee = true; + } + } + } + if (!isInner && !cee && res) { + res = "{" + res + "}"; + } + return res; + }, + _goInner: function _goInner(input) { + if (!input) { + return input; + } + return texify.go(input, true); + }, + _go2: function _go2(buf) { + /** @type {undefined | string} */ + var res; + switch (buf.type_) { + case 'chemfive': + res = ""; + var b5 = { + a: texify._goInner(buf.a), + b: texify._goInner(buf.b), + p: texify._goInner(buf.p), + o: texify._goInner(buf.o), + q: texify._goInner(buf.q), + d: texify._goInner(buf.d) + }; + // + // a + // + if (b5.a) { + if (b5.a.match(/^[+\-]/)) { + b5.a = "{" + b5.a + "}"; + } + res += b5.a + "\\,"; + } + // + // b and p + // + if (b5.b || b5.p) { + res += "{\\vphantom{X}}"; + res += "^{\\hphantom{" + (b5.b || "") + "}}_{\\hphantom{" + (b5.p || "") + "}}"; + res += "{\\vphantom{X}}"; + res += "^{\\smash[t]{\\vphantom{2}}\\mathllap{" + (b5.b || "") + "}}"; + res += "_{\\vphantom{2}\\mathllap{\\smash[t]{" + (b5.p || "") + "}}}"; + } + // + // o + // + if (b5.o) { + if (b5.o.match(/^[+\-]/)) { + b5.o = "{" + b5.o + "}"; + } + res += b5.o; + } + // + // q and d + // + if (buf.dType === 'kv') { + if (b5.d || b5.q) { + res += "{\\vphantom{X}}"; + } + if (b5.d) { + res += "^{" + b5.d + "}"; + } + if (b5.q) { + res += "_{\\smash[t]{" + b5.q + "}}"; + } + } else if (buf.dType === 'oxidation') { + if (b5.d) { + res += "{\\vphantom{X}}"; + res += "^{" + b5.d + "}"; + } + if (b5.q) { + res += "{\\vphantom{X}}"; + res += "_{\\smash[t]{" + b5.q + "}}"; + } + } else { + if (b5.q) { + res += "{\\vphantom{X}}"; + res += "_{\\smash[t]{" + b5.q + "}}"; + } + if (b5.d) { + res += "{\\vphantom{X}}"; + res += "^{" + b5.d + "}"; + } + } + break; + case 'rm': + res = "\\mathrm{" + buf.p1 + "}"; + break; + case 'text': + if (buf.p1.match(/[\^_]/)) { + buf.p1 = buf.p1.replace(" ", "~").replace("-", "\\text{-}"); + res = "\\mathrm{" + buf.p1 + "}"; + } else { + res = "\\text{" + buf.p1 + "}"; + } + break; + case 'roman numeral': + res = "\\mathrm{" + buf.p1 + "}"; + break; + case 'state of aggregation': + res = "\\mskip2mu " + texify._goInner(buf.p1); + break; + case 'state of aggregation subscript': + res = "\\mskip1mu " + texify._goInner(buf.p1); + break; + case 'bond': + res = texify._getBond(buf.kind_); + if (!res) { + throw ["MhchemErrorBond", "mhchem Error. Unknown bond type (" + buf.kind_ + ")"]; + } + break; + case 'frac': + var c = "\\frac{" + buf.p1 + "}{" + buf.p2 + "}"; + res = "\\mathchoice{\\textstyle" + c + "}{" + c + "}{" + c + "}{" + c + "}"; + break; + case 'pu-frac': + var d = "\\frac{" + texify._goInner(buf.p1) + "}{" + texify._goInner(buf.p2) + "}"; + res = "\\mathchoice{\\textstyle" + d + "}{" + d + "}{" + d + "}{" + d + "}"; + break; + case 'tex-math': + res = buf.p1 + " "; + break; + case 'frac-ce': + res = "\\frac{" + texify._goInner(buf.p1) + "}{" + texify._goInner(buf.p2) + "}"; + break; + case 'overset': + res = "\\overset{" + texify._goInner(buf.p1) + "}{" + texify._goInner(buf.p2) + "}"; + break; + case 'underset': + res = "\\underset{" + texify._goInner(buf.p1) + "}{" + texify._goInner(buf.p2) + "}"; + break; + case 'underbrace': + res = "\\underbrace{" + texify._goInner(buf.p1) + "}_{" + texify._goInner(buf.p2) + "}"; + break; + case 'color': + res = "{\\color{" + buf.color1 + "}{" + texify._goInner(buf.color2) + "}}"; + break; + case 'color0': + res = "\\color{" + buf.color + "}"; + break; + case 'arrow': + var b6 = { + rd: texify._goInner(buf.rd), + rq: texify._goInner(buf.rq) + }; + var arrow = "\\x" + texify._getArrow(buf.r); + if (b6.rq) { + arrow += "[{" + b6.rq + "}]"; + } + if (b6.rd) { + arrow += "{" + b6.rd + "}"; + } else { + arrow += "{}"; + } + res = arrow; + break; + case 'operator': + res = texify._getOperator(buf.kind_); + break; + case '1st-level escape': + res = buf.p1 + " "; // &, \\\\, \\hlin + break; + case 'space': + res = " "; + break; + case 'entitySkip': + res = "~"; + break; + case 'pu-space-1': + res = "~"; + break; + case 'pu-space-2': + res = "\\mkern3mu "; + break; + case '1000 separator': + res = "\\mkern2mu "; + break; + case 'commaDecimal': + res = "{,}"; + break; + case 'comma enumeration L': + res = "{" + buf.p1 + "}\\mkern6mu "; + break; + case 'comma enumeration M': + res = "{" + buf.p1 + "}\\mkern3mu "; + break; + case 'comma enumeration S': + res = "{" + buf.p1 + "}\\mkern1mu "; + break; + case 'hyphen': + res = "\\text{-}"; + break; + case 'addition compound': + res = "\\,{\\cdot}\\,"; + break; + case 'electron dot': + res = "\\mkern1mu \\bullet\\mkern1mu "; + break; + case 'KV x': + res = "{\\times}"; + break; + case 'prime': + res = "\\prime "; + break; + case 'cdot': + res = "\\cdot "; + break; + case 'tight cdot': + res = "\\mkern1mu{\\cdot}\\mkern1mu "; + break; + case 'times': + res = "\\times "; + break; + case 'circa': + res = "{\\sim}"; + break; + case '^': + res = "uparrow"; + break; + case 'v': + res = "downarrow"; + break; + case 'ellipsis': + res = "\\ldots "; + break; + case '/': + res = "/"; + break; + case ' / ': + res = "\\,/\\,"; + break; + default: + throw ["MhchemBugT", "mhchem bug T. Please report."]; + // Missing texify rule or unknown MhchemParser output + } + return res; + }, + _getArrow: function _getArrow(a) { + switch (a) { + case "->": + return "rightarrow"; + case "\u2192": + return "rightarrow"; + case "\u27F6": + return "rightarrow"; + case "<-": + return "leftarrow"; + case "<->": + return "leftrightarrow"; + case "<-->": + return "rightleftarrows"; + case "<=>": + return "rightleftharpoons"; + case "\u21CC": + return "rightleftharpoons"; + case "<=>>": + return "rightequilibrium"; + case "<<=>": + return "leftequilibrium"; + default: + throw ["MhchemBugT", "mhchem bug T. Please report."]; + } + }, + _getBond: function _getBond(a) { + switch (a) { + case "-": + return "{-}"; + case "1": + return "{-}"; + case "=": + return "{=}"; + case "2": + return "{=}"; + case "#": + return "{\\equiv}"; + case "3": + return "{\\equiv}"; + case "~": + return "{\\tripledash}"; + case "~-": + return "{\\mathrlap{\\raisebox{-.1em}{$-$}}\\raisebox{.1em}{$\\tripledash$}}"; + case "~=": + return "{\\mathrlap{\\raisebox{-.2em}{$-$}}\\mathrlap{\\raisebox{.2em}{$\\tripledash$}}-}"; + case "~--": + return "{\\mathrlap{\\raisebox{-.2em}{$-$}}\\mathrlap{\\raisebox{.2em}{$\\tripledash$}}-}"; + case "-~-": + return "{\\mathrlap{\\raisebox{-.2em}{$-$}}\\mathrlap{\\raisebox{.2em}{$-$}}\\tripledash}"; + case "...": + return "{{\\cdot}{\\cdot}{\\cdot}}"; + case "....": + return "{{\\cdot}{\\cdot}{\\cdot}{\\cdot}}"; + case "->": + return "{\\rightarrow}"; + case "<-": + return "{\\leftarrow}"; + case "<": + return "{<}"; + case ">": + return "{>}"; + default: + throw ["MhchemBugT", "mhchem bug T. Please report."]; + } + }, + _getOperator: function _getOperator(a) { + switch (a) { + case "+": + return " {}+{} "; + case "-": + return " {}-{} "; + case "=": + return " {}={} "; + case "<": + return " {}<{} "; + case ">": + return " {}>{} "; + case "<<": + return " {}\\ll{} "; + case ">>": + return " {}\\gg{} "; + case "\\pm": + return " {}\\pm{} "; + case "\\approx": + return " {}\\approx{} "; + case "$\\approx$": + return " {}\\approx{} "; + case "v": + return " \\downarrow{} "; + case "(v)": + return " \\downarrow{} "; + case "^": + return " \\uparrow{} "; + case "(^)": + return " \\uparrow{} "; + default: + throw ["MhchemBugT", "mhchem bug T. Please report."]; + } + } +}; diff --git a/node_modules/katex/dist/contrib/render-a11y-string.js b/node_modules/katex/dist/contrib/render-a11y-string.js new file mode 100644 index 0000000..55dbb28 --- /dev/null +++ b/node_modules/katex/dist/contrib/render-a11y-string.js @@ -0,0 +1,827 @@ +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(require("katex")); + else if(typeof define === 'function' && define.amd) + define(["katex"], factory); + else { + var a = typeof exports === 'object' ? factory(require("katex")) : factory(root["katex"]); + for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i]; + } +})((typeof self !== 'undefined' ? self : this), function(__WEBPACK_EXTERNAL_MODULE__757__) { +return /******/ (function() { // webpackBootstrap +/******/ "use strict"; +/******/ var __webpack_modules__ = ({ + +/***/ 757: +/***/ (function(module) { + +module.exports = __WEBPACK_EXTERNAL_MODULE__757__; + +/***/ }) + +/******/ }); +/************************************************************************/ +/******/ // The module cache +/******/ var __webpack_module_cache__ = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ // Check if module is in cache +/******/ var cachedModule = __webpack_module_cache__[moduleId]; +/******/ if (cachedModule !== undefined) { +/******/ return cachedModule.exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = __webpack_module_cache__[moduleId] = { +/******/ // no module.id needed +/******/ // no module.loaded needed +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/************************************************************************/ +/******/ /* webpack/runtime/compat get default export */ +/******/ !function() { +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function() { return module['default']; } : +/******/ function() { return module; }; +/******/ __webpack_require__.d(getter, { a: getter }); +/******/ return getter; +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/define property getters */ +/******/ !function() { +/******/ // define getter functions for harmony exports +/******/ __webpack_require__.d = function(exports, definition) { +/******/ for(var key in definition) { +/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { +/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); +/******/ } +/******/ } +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/hasOwnProperty shorthand */ +/******/ !function() { +/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } +/******/ }(); +/******/ +/************************************************************************/ +var __webpack_exports__ = {}; + +// EXPORTS +__webpack_require__.d(__webpack_exports__, { + "default": function() { return /* binding */ render_a11y_string; } +}); + +;// ./src/atoms.ts +/** + * Small module for atom-group constants and type guard. Kept separate from + * `symbols.ts` so that consumers (notably `contrib/render-a11y-string`) can + * pull in `isAtom` without dragging in the ~870-line symbol tables. + */ + +// Some of these have a "-token" suffix since these are also used as `ParseNode` +// types for raw text tokens, and we want to avoid conflicts with higher-level +// `ParseNode` types. These `ParseNode`s are constructed within `Parser` by +// looking up the `symbols` map. +const ATOMS = { + "bin": 1, + "close": 1, + "inner": 1, + "open": 1, + "punct": 1, + "rel": 1 +}; +const NON_ATOMS = { + "accent-token": 1, + "mathord": 1, + "op-token": 1, + "spacing": 1, + "textord": 1 +}; +function isAtom(value) { + return value in ATOMS; +} +// EXTERNAL MODULE: external "katex" +var external_katex_ = __webpack_require__(757); +var external_katex_default = /*#__PURE__*/__webpack_require__.n(external_katex_); +;// ./contrib/render-a11y-string/render-a11y-string.ts +/** + * renderA11yString returns a readable string. + * + * In some cases the string will have the proper semantic math + * meaning,: + * renderA11yString("\\frac{1}{2}"") + * -> "start fraction, 1, divided by, 2, end fraction" + * + * However, other cases do not: + * renderA11yString("f(x) = x^2") + * -> "f, left parenthesis, x, right parenthesis, equals, x, squared" + * + * The commas in the string aim to increase ease of understanding + * when read by a screenreader. + */ + + + +const stringMap = { + "(": "left parenthesis", + ")": "right parenthesis", + "[": "open bracket", + "]": "close bracket", + "\\{": "left brace", + "\\}": "right brace", + "\\lvert": "open vertical bar", + "\\rvert": "close vertical bar", + "|": "vertical bar", + "\\uparrow": "up arrow", + "\\Uparrow": "up arrow", + "\\downarrow": "down arrow", + "\\Downarrow": "down arrow", + "\\updownarrow": "up down arrow", + "\\leftarrow": "left arrow", + "\\Leftarrow": "left arrow", + "\\rightarrow": "right arrow", + "\\Rightarrow": "right arrow", + "\\langle": "open angle", + "\\rangle": "close angle", + "\\lfloor": "open floor", + "\\rfloor": "close floor", + "\\int": "integral", + "\\intop": "integral", + "\\lim": "limit", + "\\ln": "natural log", + "\\log": "log", + "\\sin": "sine", + "\\cos": "cosine", + "\\tan": "tangent", + "\\cot": "cotangent", + "\\sum": "sum", + "/": "slash", + ",": "comma", + ".": "point", + "-": "negative", + "+": "plus", + "~": "tilde", + ":": "colon", + "?": "question mark", + "'": "apostrophe", + "\\%": "percent", + " ": "space", + "\\ ": "space", + "\\$": "dollar sign", + "\\angle": "angle", + "\\degree": "degree", + "\\circ": "circle", + "\\vec": "vector", + "\\triangle": "triangle", + "\\pi": "pi", + "\\prime": "prime", + "\\infty": "infinity", + "\\alpha": "alpha", + "\\beta": "beta", + "\\gamma": "gamma", + "\\omega": "omega", + "\\theta": "theta", + "\\sigma": "sigma", + "\\lambda": "lambda", + "\\tau": "tau", + "\\Delta": "delta", + "\\delta": "delta", + "\\mu": "mu", + "\\rho": "rho", + "\\nabla": "del", + "\\ell": "ell", + "\\ldots": "dots", + // TODO: add entries for all accents + "\\hat": "hat", + "\\acute": "acute" +}; +const powerMap = { + "prime": "prime", + "degree": "degrees", + "circle": "degrees", + "2": "squared", + "3": "cubed" +}; +const openMap = { + "|": "open vertical bar", + ".": "" +}; +const closeMap = { + "|": "close vertical bar", + ".": "" +}; +const binMap = { + "+": "plus", + "-": "minus", + "\\pm": "plus minus", + "\\cdot": "dot", + "*": "times", + "/": "divided by", + "\\times": "times", + "\\div": "divided by", + "\\circ": "circle", + "\\bullet": "bullet" +}; +const relMap = { + "=": "equals", + "\\approx": "approximately equals", + "≠": "does not equal", + "\\geq": "is greater than or equal to", + "\\ge": "is greater than or equal to", + "\\leq": "is less than or equal to", + "\\le": "is less than or equal to", + ">": "is greater than", + "<": "is less than", + "\\leftarrow": "left arrow", + "\\Leftarrow": "left arrow", + "\\rightarrow": "right arrow", + "\\Rightarrow": "right arrow", + ":": "colon" +}; +const accentUnderMap = { + "\\underleftarrow": "left arrow", + "\\underrightarrow": "right arrow", + "\\underleftrightarrow": "left-right arrow", + "\\undergroup": "group", + "\\underlinesegment": "line segment", + "\\utilde": "tilde" +}; +const buildString = (str, type, a11yStrings) => { + if (!str) { + return; + } + let ret; + if (type === "open") { + ret = str in openMap ? openMap[str] : stringMap[str] || str; + } else if (type === "close") { + ret = str in closeMap ? closeMap[str] : stringMap[str] || str; + } else if (type === "bin") { + ret = binMap[str] || str; + } else if (type === "rel") { + ret = relMap[str] || str; + } else { + ret = stringMap[str] || str; + } + + // If the text to add is a number and there is already a string + // in the list and the last string is a number then we should + // combine them into a single number + const last = a11yStrings[a11yStrings.length - 1]; + if (/^\d+$/.test(ret) && a11yStrings.length > 0 && typeof last === "string" && /^\d+$/.test(last)) { + a11yStrings[a11yStrings.length - 1] += ret; + } else if (ret) { + a11yStrings.push(ret); + } +}; +const buildRegion = (a11yStrings, callback) => { + const regionStrings = []; + a11yStrings.push(regionStrings); + callback(regionStrings); +}; +const handleObject = (tree, a11yStrings, atomType) => { + // Everything else is assumed to be an object... + switch (tree.type) { + case "accent": + { + buildRegion(a11yStrings, a11yStrings => { + buildA11yStrings(tree.base, a11yStrings, atomType); + a11yStrings.push("with"); + buildString(tree.label, "normal", a11yStrings); + a11yStrings.push("on top"); + }); + break; + } + case "accentUnder": + { + buildRegion(a11yStrings, a11yStrings => { + buildA11yStrings(tree.base, a11yStrings, atomType); + a11yStrings.push("with"); + buildString(accentUnderMap[tree.label], "normal", a11yStrings); + a11yStrings.push("underneath"); + }); + break; + } + case "accent-token": + { + // Used internally by accent symbols. + break; + } + case "atom": + { + const { + text + } = tree; + switch (tree.family) { + case "bin": + { + buildString(text, "bin", a11yStrings); + break; + } + case "close": + { + buildString(text, "close", a11yStrings); + break; + } + // TODO(kevinb): figure out what should be done for inner + case "inner": + { + buildString(tree.text, "inner", a11yStrings); + break; + } + case "open": + { + buildString(text, "open", a11yStrings); + break; + } + case "punct": + { + buildString(text, "punct", a11yStrings); + break; + } + case "rel": + { + buildString(text, "rel", a11yStrings); + break; + } + default: + { + tree.family; + throw new Error("\"" + tree.family + "\" is not a valid atom type"); + } + } + break; + } + case "color": + { + const color = tree.color.replace(/katex-/, ""); + buildRegion(a11yStrings, regionStrings => { + regionStrings.push("start color " + color); + buildA11yStrings(tree.body, regionStrings, atomType); + regionStrings.push("end color " + color); + }); + break; + } + case "color-token": + { + // Used by \color, \colorbox, and \fcolorbox but not directly rendered. + // It's a leaf node and has no children so just break. + break; + } + case "delimsizing": + { + if (tree.delim && tree.delim !== ".") { + buildString(tree.delim, "normal", a11yStrings); + } + break; + } + case "genfrac": + { + buildRegion(a11yStrings, regionStrings => { + // genfrac can have unbalanced delimiters + const { + leftDelim, + rightDelim + } = tree; + + // NOTE: Not sure if this is a safe assumption + // hasBarLine true -> fraction, false -> binomial + if (tree.hasBarLine) { + regionStrings.push("start fraction"); + leftDelim && buildString(leftDelim, "open", regionStrings); + buildA11yStrings(tree.numer, regionStrings, atomType); + regionStrings.push("divided by"); + buildA11yStrings(tree.denom, regionStrings, atomType); + rightDelim && buildString(rightDelim, "close", regionStrings); + regionStrings.push("end fraction"); + } else { + regionStrings.push("start binomial"); + leftDelim && buildString(leftDelim, "open", regionStrings); + buildA11yStrings(tree.numer, regionStrings, atomType); + regionStrings.push("over"); + buildA11yStrings(tree.denom, regionStrings, atomType); + rightDelim && buildString(rightDelim, "close", regionStrings); + regionStrings.push("end binomial"); + } + }); + break; + } + case "hbox": + { + buildA11yStrings(tree.body, a11yStrings, atomType); + break; + } + case "kern": + { + // No op: we don't attempt to present kerning information + // to the screen reader. + break; + } + case "leftright": + { + buildRegion(a11yStrings, regionStrings => { + buildString(tree.left, "open", regionStrings); + buildA11yStrings(tree.body, regionStrings, atomType); + buildString(tree.right, "close", regionStrings); + }); + break; + } + case "leftright-right": + { + // TODO: double check that this is a no-op + break; + } + case "lap": + { + buildA11yStrings(tree.body, a11yStrings, atomType); + break; + } + case "mathord": + { + buildString(tree.text, "normal", a11yStrings); + break; + } + case "op": + { + const { + body, + name + } = tree; + if (body) { + buildA11yStrings(body, a11yStrings, atomType); + } else if (name) { + buildString(name, "normal", a11yStrings); + } + break; + } + case "op-token": + { + // Used internally by operator symbols. + buildString(tree.text, atomType, a11yStrings); + break; + } + case "ordgroup": + { + buildA11yStrings(tree.body, a11yStrings, atomType); + break; + } + case "overline": + { + buildRegion(a11yStrings, function (a11yStrings) { + a11yStrings.push("start overline"); + buildA11yStrings(tree.body, a11yStrings, atomType); + a11yStrings.push("end overline"); + }); + break; + } + case "pmb": + { + a11yStrings.push("bold"); + break; + } + case "phantom": + { + a11yStrings.push("empty space"); + break; + } + case "raisebox": + { + buildA11yStrings(tree.body, a11yStrings, atomType); + break; + } + case "rule": + { + a11yStrings.push("rectangle"); + break; + } + case "sizing": + { + buildA11yStrings(tree.body, a11yStrings, atomType); + break; + } + case "spacing": + { + a11yStrings.push("space"); + break; + } + case "styling": + { + // We ignore the styling and just pass through the contents + buildA11yStrings(tree.body, a11yStrings, atomType); + break; + } + case "sqrt": + { + buildRegion(a11yStrings, regionStrings => { + const { + body, + index + } = tree; + if (index) { + const indexString = flatten(buildA11yStrings(index, [], atomType)).join(","); + if (indexString === "3") { + regionStrings.push("cube root of"); + buildA11yStrings(body, regionStrings, atomType); + regionStrings.push("end cube root"); + return; + } + regionStrings.push("root"); + regionStrings.push("start index"); + buildA11yStrings(index, regionStrings, atomType); + regionStrings.push("end index"); + return; + } + regionStrings.push("square root of"); + buildA11yStrings(body, regionStrings, atomType); + regionStrings.push("end square root"); + }); + break; + } + case "supsub": + { + const { + base, + sub, + sup + } = tree; + let isLog = false; + if (base) { + buildA11yStrings(base, a11yStrings, atomType); + isLog = base.type === "op" && base.name === "\\log"; + } + if (sub) { + const regionName = isLog ? "base" : "subscript"; + buildRegion(a11yStrings, function (regionStrings) { + regionStrings.push("start " + regionName); + buildA11yStrings(sub, regionStrings, atomType); + regionStrings.push("end " + regionName); + }); + } + if (sup) { + buildRegion(a11yStrings, function (regionStrings) { + const supString = flatten(buildA11yStrings(sup, [], atomType)).join(","); + if (supString in powerMap) { + regionStrings.push(powerMap[supString]); + return; + } + regionStrings.push("start superscript"); + buildA11yStrings(sup, regionStrings, atomType); + regionStrings.push("end superscript"); + }); + } + break; + } + case "text": + { + // TODO: handle other fonts + if (tree.font === "\\textbf") { + buildRegion(a11yStrings, function (regionStrings) { + regionStrings.push("start bold text"); + buildA11yStrings(tree.body, regionStrings, atomType); + regionStrings.push("end bold text"); + }); + break; + } + buildRegion(a11yStrings, function (regionStrings) { + regionStrings.push("start text"); + buildA11yStrings(tree.body, regionStrings, atomType); + regionStrings.push("end text"); + }); + break; + } + case "textord": + { + buildString(tree.text, atomType, a11yStrings); + break; + } + case "smash": + { + buildA11yStrings(tree.body, a11yStrings, atomType); + break; + } + case "enclose": + { + // TODO: create a map for these. + // TODO: differentiate between a body with a single atom, e.g. + // "cancel a" instead of "start cancel, a, end cancel" + if (/cancel/.test(tree.label)) { + buildRegion(a11yStrings, function (regionStrings) { + regionStrings.push("start cancel"); + buildA11yStrings(tree.body, regionStrings, atomType); + regionStrings.push("end cancel"); + }); + break; + } else if (/box/.test(tree.label)) { + buildRegion(a11yStrings, function (regionStrings) { + regionStrings.push("start box"); + buildA11yStrings(tree.body, regionStrings, atomType); + regionStrings.push("end box"); + }); + break; + } else if (/sout/.test(tree.label)) { + buildRegion(a11yStrings, function (regionStrings) { + regionStrings.push("start strikeout"); + buildA11yStrings(tree.body, regionStrings, atomType); + regionStrings.push("end strikeout"); + }); + break; + } else if (/phase/.test(tree.label)) { + buildRegion(a11yStrings, function (regionStrings) { + regionStrings.push("start phase angle"); + buildA11yStrings(tree.body, regionStrings, atomType); + regionStrings.push("end phase angle"); + }); + break; + } + throw new Error("KaTeX-a11y: enclose node with " + tree.label + " not supported yet"); + } + case "vcenter": + { + buildA11yStrings(tree.body, a11yStrings, atomType); + break; + } + case "vphantom": + { + throw new Error("KaTeX-a11y: vphantom not implemented yet"); + } + case "operatorname": + { + buildA11yStrings(tree.body, a11yStrings, atomType); + break; + } + case "array": + { + throw new Error("KaTeX-a11y: array not implemented yet"); + } + case "raw": + { + throw new Error("KaTeX-a11y: raw not implemented yet"); + } + case "size": + { + // Although there are nodes of type "size" in the parse tree, they have + // no semantic meaning and should be ignored. + break; + } + case "url": + { + throw new Error("KaTeX-a11y: url not implemented yet"); + } + case "tag": + { + throw new Error("KaTeX-a11y: tag not implemented yet"); + } + case "verb": + { + buildString("start verbatim", "normal", a11yStrings); + buildString(tree.body, "normal", a11yStrings); + buildString("end verbatim", "normal", a11yStrings); + break; + } + case "environment": + { + throw new Error("KaTeX-a11y: environment not implemented yet"); + } + case "horizBrace": + { + buildString("start " + tree.label.slice(1), "normal", a11yStrings); + buildA11yStrings(tree.base, a11yStrings, atomType); + buildString("end " + tree.label.slice(1), "normal", a11yStrings); + break; + } + case "infix": + { + // All infix nodes are replace with other nodes. + break; + } + case "includegraphics": + { + throw new Error("KaTeX-a11y: includegraphics not implemented yet"); + } + case "font": + { + // TODO: callout the start/end of specific fonts + // TODO: map \BBb{N} to "the naturals" or something like that + buildA11yStrings(tree.body, a11yStrings, atomType); + break; + } + case "href": + { + throw new Error("KaTeX-a11y: href not implemented yet"); + } + case "cr": + { + // This is used by environments. + throw new Error("KaTeX-a11y: cr not implemented yet"); + } + case "underline": + { + buildRegion(a11yStrings, function (a11yStrings) { + a11yStrings.push("start underline"); + buildA11yStrings(tree.body, a11yStrings, atomType); + a11yStrings.push("end underline"); + }); + break; + } + case "xArrow": + { + throw new Error("KaTeX-a11y: xArrow not implemented yet"); + } + case "cdlabel": + { + throw new Error("KaTeX-a11y: cdlabel not implemented yet"); + } + case "cdlabelparent": + { + throw new Error("KaTeX-a11y: cdlabelparent not implemented yet"); + } + case "mclass": + { + // \neq and \ne are macros so we let "htmlmathml" render the mathmal + // side of things and extract the text from that. + // mclass values are prefixed with "m" (e.g. "mrel" -> "rel") + const atomType = tree.mclass.slice(1); + if (atomType === "normal" || isAtom(atomType)) { + buildA11yStrings(tree.body, a11yStrings, atomType); + } else { + throw new Error("Unexpected mclass atom type: \"" + atomType + "\""); + } + break; + } + case "mathchoice": + { + // TODO: track which style we're using, e.g. display, text, etc. + // default to text style if even that may not be the correct style + buildA11yStrings(tree.text, a11yStrings, atomType); + break; + } + case "htmlmathml": + { + buildA11yStrings(tree.mathml, a11yStrings, atomType); + break; + } + case "middle": + { + buildString(tree.delim, atomType, a11yStrings); + break; + } + case "internal": + { + // internal nodes are never included in the parse tree + break; + } + case "html": + { + buildA11yStrings(tree.body, a11yStrings, atomType); + break; + } + default: + throw new Error("KaTeX a11y un-recognized type: " + tree.type); + } +}; +const buildA11yStrings = function (tree, a11yStrings, atomType) { + if (a11yStrings === void 0) { + a11yStrings = []; + } + if (tree instanceof Array) { + for (let i = 0; i < tree.length; i++) { + buildA11yStrings(tree[i], a11yStrings, atomType); + } + } else { + handleObject(tree, a11yStrings, atomType); + } + return a11yStrings; +}; +const flatten = function (array) { + let result = []; + array.forEach(function (item) { + if (Array.isArray(item)) { + result = result.concat(flatten(item)); + } else { + result.push(item); + } + }); + return result; +}; +const renderA11yString = function (text, settings) { + const tree = external_katex_default().__parse(text, settings); + const a11yStrings = buildA11yStrings(tree, [], "normal"); + return flatten(a11yStrings).join(", "); +}; +/* harmony default export */ var render_a11y_string = (renderA11yString); +__webpack_exports__ = __webpack_exports__["default"]; +/******/ return __webpack_exports__; +/******/ })() +; +}); \ No newline at end of file diff --git a/node_modules/katex/dist/contrib/render-a11y-string.min.js b/node_modules/katex/dist/contrib/render-a11y-string.min.js new file mode 100644 index 0000000..abbb3d7 --- /dev/null +++ b/node_modules/katex/dist/contrib/render-a11y-string.min.js @@ -0,0 +1 @@ +!function(e,r){if("object"==typeof exports&&"object"==typeof module)module.exports=r(require("katex"));else if("function"==typeof define&&define.amd)define(["katex"],r);else{var t="object"==typeof exports?r(require("katex")):r(e.katex);for(var a in t)("object"==typeof exports?exports:e)[a]=t[a]}}("undefined"!=typeof self?self:this,function(e){return function(){"use strict";var r={757:function(r){r.exports=e}},t={};function a(e){var o=t[e];if(void 0!==o)return o.exports;var n=t[e]={exports:{}};return r[e](n,n.exports,a),n.exports}a.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(r,{a:r}),r},a.d=function(e,r){for(var t in r)a.o(r,t)&&!a.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},a.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)};var o={};a.d(o,{default:function(){return k}});const n={bin:1,close:1,inner:1,open:1,punct:1,rel:1};var s=a(757),l=a.n(s);const i={"(":"left parenthesis",")":"right parenthesis","[":"open bracket","]":"close bracket","\\{":"left brace","\\}":"right brace","\\lvert":"open vertical bar","\\rvert":"close vertical bar","|":"vertical bar","\\uparrow":"up arrow","\\Uparrow":"up arrow","\\downarrow":"down arrow","\\Downarrow":"down arrow","\\updownarrow":"up down arrow","\\leftarrow":"left arrow","\\Leftarrow":"left arrow","\\rightarrow":"right arrow","\\Rightarrow":"right arrow","\\langle":"open angle","\\rangle":"close angle","\\lfloor":"open floor","\\rfloor":"close floor","\\int":"integral","\\intop":"integral","\\lim":"limit","\\ln":"natural log","\\log":"log","\\sin":"sine","\\cos":"cosine","\\tan":"tangent","\\cot":"cotangent","\\sum":"sum","/":"slash",",":"comma",".":"point","-":"negative","+":"plus","~":"tilde",":":"colon","?":"question mark","'":"apostrophe","\\%":"percent"," ":"space","\\ ":"space","\\$":"dollar sign","\\angle":"angle","\\degree":"degree","\\circ":"circle","\\vec":"vector","\\triangle":"triangle","\\pi":"pi","\\prime":"prime","\\infty":"infinity","\\alpha":"alpha","\\beta":"beta","\\gamma":"gamma","\\omega":"omega","\\theta":"theta","\\sigma":"sigma","\\lambda":"lambda","\\tau":"tau","\\Delta":"delta","\\delta":"delta","\\mu":"mu","\\rho":"rho","\\nabla":"del","\\ell":"ell","\\ldots":"dots","\\hat":"hat","\\acute":"acute"},c={prime:"prime",degree:"degrees",circle:"degrees",2:"squared",3:"cubed"},u={"|":"open vertical bar",".":""},p={"|":"close vertical bar",".":""},d={"+":"plus","-":"minus","\\pm":"plus minus","\\cdot":"dot","*":"times","/":"divided by","\\times":"times","\\div":"divided by","\\circ":"circle","\\bullet":"bullet"},h={"=":"equals","\\approx":"approximately equals","\u2260":"does not equal","\\geq":"is greater than or equal to","\\ge":"is greater than or equal to","\\leq":"is less than or equal to","\\le":"is less than or equal to",">":"is greater than","<":"is less than","\\leftarrow":"left arrow","\\Leftarrow":"left arrow","\\rightarrow":"right arrow","\\Rightarrow":"right arrow",":":"colon"},b={"\\underleftarrow":"left arrow","\\underrightarrow":"right arrow","\\underleftrightarrow":"left-right arrow","\\undergroup":"group","\\underlinesegment":"line segment","\\utilde":"tilde"},m=(e,r,t)=>{if(!e)return;let a;a="open"===r?e in u?u[e]:i[e]||e:"close"===r?e in p?p[e]:i[e]||e:"bin"===r?d[e]||e:"rel"===r?h[e]||e:i[e]||e;const o=t[t.length-1];/^\d+$/.test(a)&&t.length>0&&"string"==typeof o&&/^\d+$/.test(o)?t[t.length-1]+=a:a&&t.push(a)},f=(e,r)=>{const t=[];e.push(t),r(t)},w=(e,r,t)=>{switch(e.type){case"accent":f(r,r=>{g(e.base,r,t),r.push("with"),m(e.label,"normal",r),r.push("on top")});break;case"accentUnder":f(r,r=>{g(e.base,r,t),r.push("with"),m(b[e.label],"normal",r),r.push("underneath")});break;case"accent-token":case"color-token":case"kern":case"leftright-right":case"size":case"infix":case"internal":break;case"atom":{const{text:t}=e;switch(e.family){case"bin":m(t,"bin",r);break;case"close":m(t,"close",r);break;case"inner":m(e.text,"inner",r);break;case"open":m(t,"open",r);break;case"punct":m(t,"punct",r);break;case"rel":m(t,"rel",r);break;default:throw e.family,new Error('"'+e.family+'" is not a valid atom type')}break}case"color":{const a=e.color.replace(/katex-/,"");f(r,r=>{r.push("start color "+a),g(e.body,r,t),r.push("end color "+a)});break}case"delimsizing":e.delim&&"."!==e.delim&&m(e.delim,"normal",r);break;case"genfrac":f(r,r=>{const{leftDelim:a,rightDelim:o}=e;e.hasBarLine?(r.push("start fraction"),a&&m(a,"open",r),g(e.numer,r,t),r.push("divided by"),g(e.denom,r,t),o&&m(o,"close",r),r.push("end fraction")):(r.push("start binomial"),a&&m(a,"open",r),g(e.numer,r,t),r.push("over"),g(e.denom,r,t),o&&m(o,"close",r),r.push("end binomial"))});break;case"hbox":case"lap":case"ordgroup":case"raisebox":case"sizing":case"styling":case"smash":case"vcenter":case"operatorname":case"font":case"html":g(e.body,r,t);break;case"leftright":f(r,r=>{m(e.left,"open",r),g(e.body,r,t),m(e.right,"close",r)});break;case"mathord":m(e.text,"normal",r);break;case"op":{const{body:a,name:o}=e;a?g(a,r,t):o&&m(o,"normal",r);break}case"op-token":case"textord":m(e.text,t,r);break;case"overline":f(r,function(r){r.push("start overline"),g(e.body,r,t),r.push("end overline")});break;case"pmb":r.push("bold");break;case"phantom":r.push("empty space");break;case"rule":r.push("rectangle");break;case"spacing":r.push("space");break;case"sqrt":f(r,r=>{const{body:a,index:o}=e;if(o){return"3"===y(g(o,[],t)).join(",")?(r.push("cube root of"),g(a,r,t),void r.push("end cube root")):(r.push("root"),r.push("start index"),g(o,r,t),void r.push("end index"))}r.push("square root of"),g(a,r,t),r.push("end square root")});break;case"supsub":{const{base:a,sub:o,sup:n}=e;let s=!1;if(a&&(g(a,r,t),s="op"===a.type&&"\\log"===a.name),o){const e=s?"base":"subscript";f(r,function(r){r.push("start "+e),g(o,r,t),r.push("end "+e)})}n&&f(r,function(e){const r=y(g(n,[],t)).join(",");r in c?e.push(c[r]):(e.push("start superscript"),g(n,e,t),e.push("end superscript"))});break}case"text":if("\\textbf"===e.font){f(r,function(r){r.push("start bold text"),g(e.body,r,t),r.push("end bold text")});break}f(r,function(r){r.push("start text"),g(e.body,r,t),r.push("end text")});break;case"enclose":if(/cancel/.test(e.label)){f(r,function(r){r.push("start cancel"),g(e.body,r,t),r.push("end cancel")});break}if(/box/.test(e.label)){f(r,function(r){r.push("start box"),g(e.body,r,t),r.push("end box")});break}if(/sout/.test(e.label)){f(r,function(r){r.push("start strikeout"),g(e.body,r,t),r.push("end strikeout")});break}if(/phase/.test(e.label)){f(r,function(r){r.push("start phase angle"),g(e.body,r,t),r.push("end phase angle")});break}throw new Error("KaTeX-a11y: enclose node with "+e.label+" not supported yet");case"vphantom":throw new Error("KaTeX-a11y: vphantom not implemented yet");case"array":throw new Error("KaTeX-a11y: array not implemented yet");case"raw":throw new Error("KaTeX-a11y: raw not implemented yet");case"url":throw new Error("KaTeX-a11y: url not implemented yet");case"tag":throw new Error("KaTeX-a11y: tag not implemented yet");case"verb":m("start verbatim","normal",r),m(e.body,"normal",r),m("end verbatim","normal",r);break;case"environment":throw new Error("KaTeX-a11y: environment not implemented yet");case"horizBrace":m("start "+e.label.slice(1),"normal",r),g(e.base,r,t),m("end "+e.label.slice(1),"normal",r);break;case"includegraphics":throw new Error("KaTeX-a11y: includegraphics not implemented yet");case"href":throw new Error("KaTeX-a11y: href not implemented yet");case"cr":throw new Error("KaTeX-a11y: cr not implemented yet");case"underline":f(r,function(r){r.push("start underline"),g(e.body,r,t),r.push("end underline")});break;case"xArrow":throw new Error("KaTeX-a11y: xArrow not implemented yet");case"cdlabel":throw new Error("KaTeX-a11y: cdlabel not implemented yet");case"cdlabelparent":throw new Error("KaTeX-a11y: cdlabelparent not implemented yet");case"mclass":{const t=e.mclass.slice(1);if("normal"!==t&&!(t in n))throw new Error('Unexpected mclass atom type: "'+t+'"');g(e.body,r,t);break}case"mathchoice":g(e.text,r,t);break;case"htmlmathml":g(e.mathml,r,t);break;case"middle":m(e.delim,t,r);break;default:throw new Error("KaTeX a11y un-recognized type: "+e.type)}},g=function(e,r,t){if(void 0===r&&(r=[]),e instanceof Array)for(let a=0;a "start fraction, 1, divided by, 2, end fraction" + * + * However, other cases do not: + * renderA11yString("f(x) = x^2") + * -> "f, left parenthesis, x, right parenthesis, equals, x, squared" + * + * The commas in the string aim to increase ease of understanding + * when read by a screenreader. + */ +var stringMap = { + "(": "left parenthesis", + ")": "right parenthesis", + "[": "open bracket", + "]": "close bracket", + "\\{": "left brace", + "\\}": "right brace", + "\\lvert": "open vertical bar", + "\\rvert": "close vertical bar", + "|": "vertical bar", + "\\uparrow": "up arrow", + "\\Uparrow": "up arrow", + "\\downarrow": "down arrow", + "\\Downarrow": "down arrow", + "\\updownarrow": "up down arrow", + "\\leftarrow": "left arrow", + "\\Leftarrow": "left arrow", + "\\rightarrow": "right arrow", + "\\Rightarrow": "right arrow", + "\\langle": "open angle", + "\\rangle": "close angle", + "\\lfloor": "open floor", + "\\rfloor": "close floor", + "\\int": "integral", + "\\intop": "integral", + "\\lim": "limit", + "\\ln": "natural log", + "\\log": "log", + "\\sin": "sine", + "\\cos": "cosine", + "\\tan": "tangent", + "\\cot": "cotangent", + "\\sum": "sum", + "/": "slash", + ",": "comma", + ".": "point", + "-": "negative", + "+": "plus", + "~": "tilde", + ":": "colon", + "?": "question mark", + "'": "apostrophe", + "\\%": "percent", + " ": "space", + "\\ ": "space", + "\\$": "dollar sign", + "\\angle": "angle", + "\\degree": "degree", + "\\circ": "circle", + "\\vec": "vector", + "\\triangle": "triangle", + "\\pi": "pi", + "\\prime": "prime", + "\\infty": "infinity", + "\\alpha": "alpha", + "\\beta": "beta", + "\\gamma": "gamma", + "\\omega": "omega", + "\\theta": "theta", + "\\sigma": "sigma", + "\\lambda": "lambda", + "\\tau": "tau", + "\\Delta": "delta", + "\\delta": "delta", + "\\mu": "mu", + "\\rho": "rho", + "\\nabla": "del", + "\\ell": "ell", + "\\ldots": "dots", + // TODO: add entries for all accents + "\\hat": "hat", + "\\acute": "acute" +}; +var powerMap = { + "prime": "prime", + "degree": "degrees", + "circle": "degrees", + "2": "squared", + "3": "cubed" +}; +var openMap = { + "|": "open vertical bar", + ".": "" +}; +var closeMap = { + "|": "close vertical bar", + ".": "" +}; +var binMap = { + "+": "plus", + "-": "minus", + "\\pm": "plus minus", + "\\cdot": "dot", + "*": "times", + "/": "divided by", + "\\times": "times", + "\\div": "divided by", + "\\circ": "circle", + "\\bullet": "bullet" +}; +var relMap = { + "=": "equals", + "\\approx": "approximately equals", + "≠": "does not equal", + "\\geq": "is greater than or equal to", + "\\ge": "is greater than or equal to", + "\\leq": "is less than or equal to", + "\\le": "is less than or equal to", + ">": "is greater than", + "<": "is less than", + "\\leftarrow": "left arrow", + "\\Leftarrow": "left arrow", + "\\rightarrow": "right arrow", + "\\Rightarrow": "right arrow", + ":": "colon" +}; +var accentUnderMap = { + "\\underleftarrow": "left arrow", + "\\underrightarrow": "right arrow", + "\\underleftrightarrow": "left-right arrow", + "\\undergroup": "group", + "\\underlinesegment": "line segment", + "\\utilde": "tilde" +}; +var buildString = (str, type, a11yStrings) => { + if (!str) { + return; + } + var ret; + if (type === "open") { + ret = str in openMap ? openMap[str] : stringMap[str] || str; + } else if (type === "close") { + ret = str in closeMap ? closeMap[str] : stringMap[str] || str; + } else if (type === "bin") { + ret = binMap[str] || str; + } else if (type === "rel") { + ret = relMap[str] || str; + } else { + ret = stringMap[str] || str; + } + // If the text to add is a number and there is already a string + // in the list and the last string is a number then we should + // combine them into a single number + var last = a11yStrings[a11yStrings.length - 1]; + if (/^\d+$/.test(ret) && a11yStrings.length > 0 && typeof last === "string" && /^\d+$/.test(last)) { + a11yStrings[a11yStrings.length - 1] += ret; + } else if (ret) { + a11yStrings.push(ret); + } +}; +var buildRegion = (a11yStrings, callback) => { + var regionStrings = []; + a11yStrings.push(regionStrings); + callback(regionStrings); +}; +var handleObject = (tree, a11yStrings, atomType) => { + // Everything else is assumed to be an object... + switch (tree.type) { + case "accent": + { + buildRegion(a11yStrings, a11yStrings => { + _buildA11yStrings(tree.base, a11yStrings, atomType); + a11yStrings.push("with"); + buildString(tree.label, "normal", a11yStrings); + a11yStrings.push("on top"); + }); + break; + } + case "accentUnder": + { + buildRegion(a11yStrings, a11yStrings => { + _buildA11yStrings(tree.base, a11yStrings, atomType); + a11yStrings.push("with"); + buildString(accentUnderMap[tree.label], "normal", a11yStrings); + a11yStrings.push("underneath"); + }); + break; + } + case "accent-token": + { + // Used internally by accent symbols. + break; + } + case "atom": + { + var { + text + } = tree; + switch (tree.family) { + case "bin": + { + buildString(text, "bin", a11yStrings); + break; + } + case "close": + { + buildString(text, "close", a11yStrings); + break; + } + // TODO(kevinb): figure out what should be done for inner + case "inner": + { + buildString(tree.text, "inner", a11yStrings); + break; + } + case "open": + { + buildString(text, "open", a11yStrings); + break; + } + case "punct": + { + buildString(text, "punct", a11yStrings); + break; + } + case "rel": + { + buildString(text, "rel", a11yStrings); + break; + } + default: + { + tree.family; + throw new Error("\"" + tree.family + "\" is not a valid atom type"); + } + } + break; + } + case "color": + { + var color = tree.color.replace(/katex-/, ""); + buildRegion(a11yStrings, regionStrings => { + regionStrings.push("start color " + color); + _buildA11yStrings(tree.body, regionStrings, atomType); + regionStrings.push("end color " + color); + }); + break; + } + case "color-token": + { + // Used by \color, \colorbox, and \fcolorbox but not directly rendered. + // It's a leaf node and has no children so just break. + break; + } + case "delimsizing": + { + if (tree.delim && tree.delim !== ".") { + buildString(tree.delim, "normal", a11yStrings); + } + break; + } + case "genfrac": + { + buildRegion(a11yStrings, regionStrings => { + // genfrac can have unbalanced delimiters + var { + leftDelim, + rightDelim + } = tree; + // NOTE: Not sure if this is a safe assumption + // hasBarLine true -> fraction, false -> binomial + if (tree.hasBarLine) { + regionStrings.push("start fraction"); + leftDelim && buildString(leftDelim, "open", regionStrings); + _buildA11yStrings(tree.numer, regionStrings, atomType); + regionStrings.push("divided by"); + _buildA11yStrings(tree.denom, regionStrings, atomType); + rightDelim && buildString(rightDelim, "close", regionStrings); + regionStrings.push("end fraction"); + } else { + regionStrings.push("start binomial"); + leftDelim && buildString(leftDelim, "open", regionStrings); + _buildA11yStrings(tree.numer, regionStrings, atomType); + regionStrings.push("over"); + _buildA11yStrings(tree.denom, regionStrings, atomType); + rightDelim && buildString(rightDelim, "close", regionStrings); + regionStrings.push("end binomial"); + } + }); + break; + } + case "hbox": + { + _buildA11yStrings(tree.body, a11yStrings, atomType); + break; + } + case "kern": + { + // No op: we don't attempt to present kerning information + // to the screen reader. + break; + } + case "leftright": + { + buildRegion(a11yStrings, regionStrings => { + buildString(tree.left, "open", regionStrings); + _buildA11yStrings(tree.body, regionStrings, atomType); + buildString(tree.right, "close", regionStrings); + }); + break; + } + case "leftright-right": + { + // TODO: double check that this is a no-op + break; + } + case "lap": + { + _buildA11yStrings(tree.body, a11yStrings, atomType); + break; + } + case "mathord": + { + buildString(tree.text, "normal", a11yStrings); + break; + } + case "op": + { + var { + body, + name + } = tree; + if (body) { + _buildA11yStrings(body, a11yStrings, atomType); + } else if (name) { + buildString(name, "normal", a11yStrings); + } + break; + } + case "op-token": + { + // Used internally by operator symbols. + buildString(tree.text, atomType, a11yStrings); + break; + } + case "ordgroup": + { + _buildA11yStrings(tree.body, a11yStrings, atomType); + break; + } + case "overline": + { + buildRegion(a11yStrings, function (a11yStrings) { + a11yStrings.push("start overline"); + _buildA11yStrings(tree.body, a11yStrings, atomType); + a11yStrings.push("end overline"); + }); + break; + } + case "pmb": + { + a11yStrings.push("bold"); + break; + } + case "phantom": + { + a11yStrings.push("empty space"); + break; + } + case "raisebox": + { + _buildA11yStrings(tree.body, a11yStrings, atomType); + break; + } + case "rule": + { + a11yStrings.push("rectangle"); + break; + } + case "sizing": + { + _buildA11yStrings(tree.body, a11yStrings, atomType); + break; + } + case "spacing": + { + a11yStrings.push("space"); + break; + } + case "styling": + { + // We ignore the styling and just pass through the contents + _buildA11yStrings(tree.body, a11yStrings, atomType); + break; + } + case "sqrt": + { + buildRegion(a11yStrings, regionStrings => { + var { + body, + index + } = tree; + if (index) { + var indexString = _flatten(_buildA11yStrings(index, [], atomType)).join(","); + if (indexString === "3") { + regionStrings.push("cube root of"); + _buildA11yStrings(body, regionStrings, atomType); + regionStrings.push("end cube root"); + return; + } + regionStrings.push("root"); + regionStrings.push("start index"); + _buildA11yStrings(index, regionStrings, atomType); + regionStrings.push("end index"); + return; + } + regionStrings.push("square root of"); + _buildA11yStrings(body, regionStrings, atomType); + regionStrings.push("end square root"); + }); + break; + } + case "supsub": + { + var { + base, + sub, + sup + } = tree; + var isLog = false; + if (base) { + _buildA11yStrings(base, a11yStrings, atomType); + isLog = base.type === "op" && base.name === "\\log"; + } + if (sub) { + var regionName = isLog ? "base" : "subscript"; + buildRegion(a11yStrings, function (regionStrings) { + regionStrings.push("start " + regionName); + _buildA11yStrings(sub, regionStrings, atomType); + regionStrings.push("end " + regionName); + }); + } + if (sup) { + buildRegion(a11yStrings, function (regionStrings) { + var supString = _flatten(_buildA11yStrings(sup, [], atomType)).join(","); + if (supString in powerMap) { + regionStrings.push(powerMap[supString]); + return; + } + regionStrings.push("start superscript"); + _buildA11yStrings(sup, regionStrings, atomType); + regionStrings.push("end superscript"); + }); + } + break; + } + case "text": + { + // TODO: handle other fonts + if (tree.font === "\\textbf") { + buildRegion(a11yStrings, function (regionStrings) { + regionStrings.push("start bold text"); + _buildA11yStrings(tree.body, regionStrings, atomType); + regionStrings.push("end bold text"); + }); + break; + } + buildRegion(a11yStrings, function (regionStrings) { + regionStrings.push("start text"); + _buildA11yStrings(tree.body, regionStrings, atomType); + regionStrings.push("end text"); + }); + break; + } + case "textord": + { + buildString(tree.text, atomType, a11yStrings); + break; + } + case "smash": + { + _buildA11yStrings(tree.body, a11yStrings, atomType); + break; + } + case "enclose": + { + // TODO: create a map for these. + // TODO: differentiate between a body with a single atom, e.g. + // "cancel a" instead of "start cancel, a, end cancel" + if (/cancel/.test(tree.label)) { + buildRegion(a11yStrings, function (regionStrings) { + regionStrings.push("start cancel"); + _buildA11yStrings(tree.body, regionStrings, atomType); + regionStrings.push("end cancel"); + }); + break; + } else if (/box/.test(tree.label)) { + buildRegion(a11yStrings, function (regionStrings) { + regionStrings.push("start box"); + _buildA11yStrings(tree.body, regionStrings, atomType); + regionStrings.push("end box"); + }); + break; + } else if (/sout/.test(tree.label)) { + buildRegion(a11yStrings, function (regionStrings) { + regionStrings.push("start strikeout"); + _buildA11yStrings(tree.body, regionStrings, atomType); + regionStrings.push("end strikeout"); + }); + break; + } else if (/phase/.test(tree.label)) { + buildRegion(a11yStrings, function (regionStrings) { + regionStrings.push("start phase angle"); + _buildA11yStrings(tree.body, regionStrings, atomType); + regionStrings.push("end phase angle"); + }); + break; + } + throw new Error("KaTeX-a11y: enclose node with " + tree.label + " not supported yet"); + } + case "vcenter": + { + _buildA11yStrings(tree.body, a11yStrings, atomType); + break; + } + case "vphantom": + { + throw new Error("KaTeX-a11y: vphantom not implemented yet"); + } + case "operatorname": + { + _buildA11yStrings(tree.body, a11yStrings, atomType); + break; + } + case "array": + { + throw new Error("KaTeX-a11y: array not implemented yet"); + } + case "raw": + { + throw new Error("KaTeX-a11y: raw not implemented yet"); + } + case "size": + { + // Although there are nodes of type "size" in the parse tree, they have + // no semantic meaning and should be ignored. + break; + } + case "url": + { + throw new Error("KaTeX-a11y: url not implemented yet"); + } + case "tag": + { + throw new Error("KaTeX-a11y: tag not implemented yet"); + } + case "verb": + { + buildString("start verbatim", "normal", a11yStrings); + buildString(tree.body, "normal", a11yStrings); + buildString("end verbatim", "normal", a11yStrings); + break; + } + case "environment": + { + throw new Error("KaTeX-a11y: environment not implemented yet"); + } + case "horizBrace": + { + buildString("start " + tree.label.slice(1), "normal", a11yStrings); + _buildA11yStrings(tree.base, a11yStrings, atomType); + buildString("end " + tree.label.slice(1), "normal", a11yStrings); + break; + } + case "infix": + { + // All infix nodes are replace with other nodes. + break; + } + case "includegraphics": + { + throw new Error("KaTeX-a11y: includegraphics not implemented yet"); + } + case "font": + { + // TODO: callout the start/end of specific fonts + // TODO: map \BBb{N} to "the naturals" or something like that + _buildA11yStrings(tree.body, a11yStrings, atomType); + break; + } + case "href": + { + throw new Error("KaTeX-a11y: href not implemented yet"); + } + case "cr": + { + // This is used by environments. + throw new Error("KaTeX-a11y: cr not implemented yet"); + } + case "underline": + { + buildRegion(a11yStrings, function (a11yStrings) { + a11yStrings.push("start underline"); + _buildA11yStrings(tree.body, a11yStrings, atomType); + a11yStrings.push("end underline"); + }); + break; + } + case "xArrow": + { + throw new Error("KaTeX-a11y: xArrow not implemented yet"); + } + case "cdlabel": + { + throw new Error("KaTeX-a11y: cdlabel not implemented yet"); + } + case "cdlabelparent": + { + throw new Error("KaTeX-a11y: cdlabelparent not implemented yet"); + } + case "mclass": + { + // \neq and \ne are macros so we let "htmlmathml" render the mathmal + // side of things and extract the text from that. + // mclass values are prefixed with "m" (e.g. "mrel" -> "rel") + var _atomType = tree.mclass.slice(1); + if (_atomType === "normal" || isAtom(_atomType)) { + _buildA11yStrings(tree.body, a11yStrings, _atomType); + } else { + throw new Error("Unexpected mclass atom type: \"" + _atomType + "\""); + } + break; + } + case "mathchoice": + { + // TODO: track which style we're using, e.g. display, text, etc. + // default to text style if even that may not be the correct style + _buildA11yStrings(tree.text, a11yStrings, atomType); + break; + } + case "htmlmathml": + { + _buildA11yStrings(tree.mathml, a11yStrings, atomType); + break; + } + case "middle": + { + buildString(tree.delim, atomType, a11yStrings); + break; + } + case "internal": + { + // internal nodes are never included in the parse tree + break; + } + case "html": + { + _buildA11yStrings(tree.body, a11yStrings, atomType); + break; + } + default: + throw new Error("KaTeX a11y un-recognized type: " + tree.type); + } +}; +var _buildA11yStrings = function buildA11yStrings(tree, a11yStrings, atomType) { + if (a11yStrings === void 0) { + a11yStrings = []; + } + if (tree instanceof Array) { + for (var i = 0; i < tree.length; i++) { + _buildA11yStrings(tree[i], a11yStrings, atomType); + } + } else { + handleObject(tree, a11yStrings, atomType); + } + return a11yStrings; +}; +var _flatten = function flatten(array) { + var result = []; + array.forEach(function (item) { + if (Array.isArray(item)) { + result = result.concat(_flatten(item)); + } else { + result.push(item); + } + }); + return result; +}; +var renderA11yString = function renderA11yString(text, settings) { + var tree = katex.__parse(text, settings); + var a11yStrings = _buildA11yStrings(tree, [], "normal"); + return _flatten(a11yStrings).join(", "); +}; + +export { renderA11yString as default }; diff --git a/node_modules/katex/dist/fonts/KaTeX_AMS-Regular.ttf b/node_modules/katex/dist/fonts/KaTeX_AMS-Regular.ttf new file mode 100644 index 0000000..c6f9a5e Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_AMS-Regular.ttf differ diff --git a/node_modules/katex/dist/fonts/KaTeX_AMS-Regular.woff b/node_modules/katex/dist/fonts/KaTeX_AMS-Regular.woff new file mode 100644 index 0000000..b804d7b Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_AMS-Regular.woff differ diff --git a/node_modules/katex/dist/fonts/KaTeX_AMS-Regular.woff2 b/node_modules/katex/dist/fonts/KaTeX_AMS-Regular.woff2 new file mode 100644 index 0000000..0acaaff Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_AMS-Regular.woff2 differ diff --git a/node_modules/katex/dist/fonts/KaTeX_Caligraphic-Bold.ttf b/node_modules/katex/dist/fonts/KaTeX_Caligraphic-Bold.ttf new file mode 100644 index 0000000..9ff4a5e Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_Caligraphic-Bold.ttf differ diff --git a/node_modules/katex/dist/fonts/KaTeX_Caligraphic-Bold.woff b/node_modules/katex/dist/fonts/KaTeX_Caligraphic-Bold.woff new file mode 100644 index 0000000..9759710 Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_Caligraphic-Bold.woff differ diff --git a/node_modules/katex/dist/fonts/KaTeX_Caligraphic-Bold.woff2 b/node_modules/katex/dist/fonts/KaTeX_Caligraphic-Bold.woff2 new file mode 100644 index 0000000..f390922 Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_Caligraphic-Bold.woff2 differ diff --git a/node_modules/katex/dist/fonts/KaTeX_Caligraphic-Regular.ttf b/node_modules/katex/dist/fonts/KaTeX_Caligraphic-Regular.ttf new file mode 100644 index 0000000..f522294 Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_Caligraphic-Regular.ttf differ diff --git a/node_modules/katex/dist/fonts/KaTeX_Caligraphic-Regular.woff b/node_modules/katex/dist/fonts/KaTeX_Caligraphic-Regular.woff new file mode 100644 index 0000000..9bdd534 Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_Caligraphic-Regular.woff differ diff --git a/node_modules/katex/dist/fonts/KaTeX_Caligraphic-Regular.woff2 b/node_modules/katex/dist/fonts/KaTeX_Caligraphic-Regular.woff2 new file mode 100644 index 0000000..75344a1 Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_Caligraphic-Regular.woff2 differ diff --git a/node_modules/katex/dist/fonts/KaTeX_Fraktur-Bold.ttf b/node_modules/katex/dist/fonts/KaTeX_Fraktur-Bold.ttf new file mode 100644 index 0000000..4e98259 Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_Fraktur-Bold.ttf differ diff --git a/node_modules/katex/dist/fonts/KaTeX_Fraktur-Bold.woff b/node_modules/katex/dist/fonts/KaTeX_Fraktur-Bold.woff new file mode 100644 index 0000000..e7730f6 Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_Fraktur-Bold.woff differ diff --git a/node_modules/katex/dist/fonts/KaTeX_Fraktur-Bold.woff2 b/node_modules/katex/dist/fonts/KaTeX_Fraktur-Bold.woff2 new file mode 100644 index 0000000..395f28b Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_Fraktur-Bold.woff2 differ diff --git a/node_modules/katex/dist/fonts/KaTeX_Fraktur-Regular.ttf b/node_modules/katex/dist/fonts/KaTeX_Fraktur-Regular.ttf new file mode 100644 index 0000000..b8461b2 Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_Fraktur-Regular.ttf differ diff --git a/node_modules/katex/dist/fonts/KaTeX_Fraktur-Regular.woff b/node_modules/katex/dist/fonts/KaTeX_Fraktur-Regular.woff new file mode 100644 index 0000000..acab069 Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_Fraktur-Regular.woff differ diff --git a/node_modules/katex/dist/fonts/KaTeX_Fraktur-Regular.woff2 b/node_modules/katex/dist/fonts/KaTeX_Fraktur-Regular.woff2 new file mode 100644 index 0000000..735f694 Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_Fraktur-Regular.woff2 differ diff --git a/node_modules/katex/dist/fonts/KaTeX_Main-Bold.ttf b/node_modules/katex/dist/fonts/KaTeX_Main-Bold.ttf new file mode 100644 index 0000000..4060e62 Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_Main-Bold.ttf differ diff --git a/node_modules/katex/dist/fonts/KaTeX_Main-Bold.woff b/node_modules/katex/dist/fonts/KaTeX_Main-Bold.woff new file mode 100644 index 0000000..f38136a Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_Main-Bold.woff differ diff --git a/node_modules/katex/dist/fonts/KaTeX_Main-Bold.woff2 b/node_modules/katex/dist/fonts/KaTeX_Main-Bold.woff2 new file mode 100644 index 0000000..ab2ad21 Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_Main-Bold.woff2 differ diff --git a/node_modules/katex/dist/fonts/KaTeX_Main-BoldItalic.ttf b/node_modules/katex/dist/fonts/KaTeX_Main-BoldItalic.ttf new file mode 100644 index 0000000..dc00797 Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_Main-BoldItalic.ttf differ diff --git a/node_modules/katex/dist/fonts/KaTeX_Main-BoldItalic.woff b/node_modules/katex/dist/fonts/KaTeX_Main-BoldItalic.woff new file mode 100644 index 0000000..67807b0 Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_Main-BoldItalic.woff differ diff --git a/node_modules/katex/dist/fonts/KaTeX_Main-BoldItalic.woff2 b/node_modules/katex/dist/fonts/KaTeX_Main-BoldItalic.woff2 new file mode 100644 index 0000000..5931794 Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_Main-BoldItalic.woff2 differ diff --git a/node_modules/katex/dist/fonts/KaTeX_Main-Italic.ttf b/node_modules/katex/dist/fonts/KaTeX_Main-Italic.ttf new file mode 100644 index 0000000..0e9b0f3 Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_Main-Italic.ttf differ diff --git a/node_modules/katex/dist/fonts/KaTeX_Main-Italic.woff b/node_modules/katex/dist/fonts/KaTeX_Main-Italic.woff new file mode 100644 index 0000000..6f43b59 Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_Main-Italic.woff differ diff --git a/node_modules/katex/dist/fonts/KaTeX_Main-Italic.woff2 b/node_modules/katex/dist/fonts/KaTeX_Main-Italic.woff2 new file mode 100644 index 0000000..b50920e Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_Main-Italic.woff2 differ diff --git a/node_modules/katex/dist/fonts/KaTeX_Main-Regular.ttf b/node_modules/katex/dist/fonts/KaTeX_Main-Regular.ttf new file mode 100644 index 0000000..dd45e1e Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_Main-Regular.ttf differ diff --git a/node_modules/katex/dist/fonts/KaTeX_Main-Regular.woff b/node_modules/katex/dist/fonts/KaTeX_Main-Regular.woff new file mode 100644 index 0000000..21f5812 Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_Main-Regular.woff differ diff --git a/node_modules/katex/dist/fonts/KaTeX_Main-Regular.woff2 b/node_modules/katex/dist/fonts/KaTeX_Main-Regular.woff2 new file mode 100644 index 0000000..eb24a7b Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_Main-Regular.woff2 differ diff --git a/node_modules/katex/dist/fonts/KaTeX_Math-BoldItalic.ttf b/node_modules/katex/dist/fonts/KaTeX_Math-BoldItalic.ttf new file mode 100644 index 0000000..728ce7a Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_Math-BoldItalic.ttf differ diff --git a/node_modules/katex/dist/fonts/KaTeX_Math-BoldItalic.woff b/node_modules/katex/dist/fonts/KaTeX_Math-BoldItalic.woff new file mode 100644 index 0000000..0ae390d Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_Math-BoldItalic.woff differ diff --git a/node_modules/katex/dist/fonts/KaTeX_Math-BoldItalic.woff2 b/node_modules/katex/dist/fonts/KaTeX_Math-BoldItalic.woff2 new file mode 100644 index 0000000..2965702 Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_Math-BoldItalic.woff2 differ diff --git a/node_modules/katex/dist/fonts/KaTeX_Math-Italic.ttf b/node_modules/katex/dist/fonts/KaTeX_Math-Italic.ttf new file mode 100644 index 0000000..70d559b Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_Math-Italic.ttf differ diff --git a/node_modules/katex/dist/fonts/KaTeX_Math-Italic.woff b/node_modules/katex/dist/fonts/KaTeX_Math-Italic.woff new file mode 100644 index 0000000..eb5159d Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_Math-Italic.woff differ diff --git a/node_modules/katex/dist/fonts/KaTeX_Math-Italic.woff2 b/node_modules/katex/dist/fonts/KaTeX_Math-Italic.woff2 new file mode 100644 index 0000000..215c143 Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_Math-Italic.woff2 differ diff --git a/node_modules/katex/dist/fonts/KaTeX_SansSerif-Bold.ttf b/node_modules/katex/dist/fonts/KaTeX_SansSerif-Bold.ttf new file mode 100644 index 0000000..2f65a8a Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_SansSerif-Bold.ttf differ diff --git a/node_modules/katex/dist/fonts/KaTeX_SansSerif-Bold.woff b/node_modules/katex/dist/fonts/KaTeX_SansSerif-Bold.woff new file mode 100644 index 0000000..8d47c02 Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_SansSerif-Bold.woff differ diff --git a/node_modules/katex/dist/fonts/KaTeX_SansSerif-Bold.woff2 b/node_modules/katex/dist/fonts/KaTeX_SansSerif-Bold.woff2 new file mode 100644 index 0000000..cfaa3bd Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_SansSerif-Bold.woff2 differ diff --git a/node_modules/katex/dist/fonts/KaTeX_SansSerif-Italic.ttf b/node_modules/katex/dist/fonts/KaTeX_SansSerif-Italic.ttf new file mode 100644 index 0000000..d5850df Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_SansSerif-Italic.ttf differ diff --git a/node_modules/katex/dist/fonts/KaTeX_SansSerif-Italic.woff b/node_modules/katex/dist/fonts/KaTeX_SansSerif-Italic.woff new file mode 100644 index 0000000..7e02df9 Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_SansSerif-Italic.woff differ diff --git a/node_modules/katex/dist/fonts/KaTeX_SansSerif-Italic.woff2 b/node_modules/katex/dist/fonts/KaTeX_SansSerif-Italic.woff2 new file mode 100644 index 0000000..349c06d Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_SansSerif-Italic.woff2 differ diff --git a/node_modules/katex/dist/fonts/KaTeX_SansSerif-Regular.ttf b/node_modules/katex/dist/fonts/KaTeX_SansSerif-Regular.ttf new file mode 100644 index 0000000..537279f Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_SansSerif-Regular.ttf differ diff --git a/node_modules/katex/dist/fonts/KaTeX_SansSerif-Regular.woff b/node_modules/katex/dist/fonts/KaTeX_SansSerif-Regular.woff new file mode 100644 index 0000000..31b8482 Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_SansSerif-Regular.woff differ diff --git a/node_modules/katex/dist/fonts/KaTeX_SansSerif-Regular.woff2 b/node_modules/katex/dist/fonts/KaTeX_SansSerif-Regular.woff2 new file mode 100644 index 0000000..a90eea8 Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_SansSerif-Regular.woff2 differ diff --git a/node_modules/katex/dist/fonts/KaTeX_Script-Regular.ttf b/node_modules/katex/dist/fonts/KaTeX_Script-Regular.ttf new file mode 100644 index 0000000..fd679bf Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_Script-Regular.ttf differ diff --git a/node_modules/katex/dist/fonts/KaTeX_Script-Regular.woff b/node_modules/katex/dist/fonts/KaTeX_Script-Regular.woff new file mode 100644 index 0000000..0e7da82 Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_Script-Regular.woff differ diff --git a/node_modules/katex/dist/fonts/KaTeX_Script-Regular.woff2 b/node_modules/katex/dist/fonts/KaTeX_Script-Regular.woff2 new file mode 100644 index 0000000..b3048fc Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_Script-Regular.woff2 differ diff --git a/node_modules/katex/dist/fonts/KaTeX_Size1-Regular.ttf b/node_modules/katex/dist/fonts/KaTeX_Size1-Regular.ttf new file mode 100644 index 0000000..871fd7d Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_Size1-Regular.ttf differ diff --git a/node_modules/katex/dist/fonts/KaTeX_Size1-Regular.woff b/node_modules/katex/dist/fonts/KaTeX_Size1-Regular.woff new file mode 100644 index 0000000..7f292d9 Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_Size1-Regular.woff differ diff --git a/node_modules/katex/dist/fonts/KaTeX_Size1-Regular.woff2 b/node_modules/katex/dist/fonts/KaTeX_Size1-Regular.woff2 new file mode 100644 index 0000000..c5a8462 Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_Size1-Regular.woff2 differ diff --git a/node_modules/katex/dist/fonts/KaTeX_Size2-Regular.ttf b/node_modules/katex/dist/fonts/KaTeX_Size2-Regular.ttf new file mode 100644 index 0000000..7a212ca Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_Size2-Regular.ttf differ diff --git a/node_modules/katex/dist/fonts/KaTeX_Size2-Regular.woff b/node_modules/katex/dist/fonts/KaTeX_Size2-Regular.woff new file mode 100644 index 0000000..d241d9b Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_Size2-Regular.woff differ diff --git a/node_modules/katex/dist/fonts/KaTeX_Size2-Regular.woff2 b/node_modules/katex/dist/fonts/KaTeX_Size2-Regular.woff2 new file mode 100644 index 0000000..e1bccfe Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_Size2-Regular.woff2 differ diff --git a/node_modules/katex/dist/fonts/KaTeX_Size3-Regular.ttf b/node_modules/katex/dist/fonts/KaTeX_Size3-Regular.ttf new file mode 100644 index 0000000..00bff34 Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_Size3-Regular.ttf differ diff --git a/node_modules/katex/dist/fonts/KaTeX_Size3-Regular.woff b/node_modules/katex/dist/fonts/KaTeX_Size3-Regular.woff new file mode 100644 index 0000000..e6e9b65 Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_Size3-Regular.woff differ diff --git a/node_modules/katex/dist/fonts/KaTeX_Size3-Regular.woff2 b/node_modules/katex/dist/fonts/KaTeX_Size3-Regular.woff2 new file mode 100644 index 0000000..249a286 Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_Size3-Regular.woff2 differ diff --git a/node_modules/katex/dist/fonts/KaTeX_Size4-Regular.ttf b/node_modules/katex/dist/fonts/KaTeX_Size4-Regular.ttf new file mode 100644 index 0000000..74f0892 Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_Size4-Regular.ttf differ diff --git a/node_modules/katex/dist/fonts/KaTeX_Size4-Regular.woff b/node_modules/katex/dist/fonts/KaTeX_Size4-Regular.woff new file mode 100644 index 0000000..e1ec545 Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_Size4-Regular.woff differ diff --git a/node_modules/katex/dist/fonts/KaTeX_Size4-Regular.woff2 b/node_modules/katex/dist/fonts/KaTeX_Size4-Regular.woff2 new file mode 100644 index 0000000..680c130 Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_Size4-Regular.woff2 differ diff --git a/node_modules/katex/dist/fonts/KaTeX_Typewriter-Regular.ttf b/node_modules/katex/dist/fonts/KaTeX_Typewriter-Regular.ttf new file mode 100644 index 0000000..c83252c Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_Typewriter-Regular.ttf differ diff --git a/node_modules/katex/dist/fonts/KaTeX_Typewriter-Regular.woff b/node_modules/katex/dist/fonts/KaTeX_Typewriter-Regular.woff new file mode 100644 index 0000000..2432419 Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_Typewriter-Regular.woff differ diff --git a/node_modules/katex/dist/fonts/KaTeX_Typewriter-Regular.woff2 b/node_modules/katex/dist/fonts/KaTeX_Typewriter-Regular.woff2 new file mode 100644 index 0000000..771f1af Binary files /dev/null and b/node_modules/katex/dist/fonts/KaTeX_Typewriter-Regular.woff2 differ diff --git a/node_modules/katex/dist/katex-swap.css b/node_modules/katex/dist/katex-swap.css new file mode 100644 index 0000000..40aec2d --- /dev/null +++ b/node_modules/katex/dist/katex-swap.css @@ -0,0 +1,1241 @@ +/* stylelint-disable font-family-no-missing-generic-family-keyword */ +@font-face { + font-family: "KaTeX_AMS"; + src: url(fonts/KaTeX_AMS-Regular.woff2) format("woff2"), url(fonts/KaTeX_AMS-Regular.woff) format("woff"), url(fonts/KaTeX_AMS-Regular.ttf) format("truetype"); + font-weight: normal; + font-style: normal; + font-display: swap; +} +@font-face { + font-family: "KaTeX_Caligraphic"; + src: url(fonts/KaTeX_Caligraphic-Bold.woff2) format("woff2"), url(fonts/KaTeX_Caligraphic-Bold.woff) format("woff"), url(fonts/KaTeX_Caligraphic-Bold.ttf) format("truetype"); + font-weight: bold; + font-style: normal; + font-display: swap; +} +@font-face { + font-family: "KaTeX_Caligraphic"; + src: url(fonts/KaTeX_Caligraphic-Regular.woff2) format("woff2"), url(fonts/KaTeX_Caligraphic-Regular.woff) format("woff"), url(fonts/KaTeX_Caligraphic-Regular.ttf) format("truetype"); + font-weight: normal; + font-style: normal; + font-display: swap; +} +@font-face { + font-family: "KaTeX_Fraktur"; + src: url(fonts/KaTeX_Fraktur-Bold.woff2) format("woff2"), url(fonts/KaTeX_Fraktur-Bold.woff) format("woff"), url(fonts/KaTeX_Fraktur-Bold.ttf) format("truetype"); + font-weight: bold; + font-style: normal; + font-display: swap; +} +@font-face { + font-family: "KaTeX_Fraktur"; + src: url(fonts/KaTeX_Fraktur-Regular.woff2) format("woff2"), url(fonts/KaTeX_Fraktur-Regular.woff) format("woff"), url(fonts/KaTeX_Fraktur-Regular.ttf) format("truetype"); + font-weight: normal; + font-style: normal; + font-display: swap; +} +@font-face { + font-family: "KaTeX_Main"; + src: url(fonts/KaTeX_Main-Bold.woff2) format("woff2"), url(fonts/KaTeX_Main-Bold.woff) format("woff"), url(fonts/KaTeX_Main-Bold.ttf) format("truetype"); + font-weight: bold; + font-style: normal; + font-display: swap; +} +@font-face { + font-family: "KaTeX_Main"; + src: url(fonts/KaTeX_Main-BoldItalic.woff2) format("woff2"), url(fonts/KaTeX_Main-BoldItalic.woff) format("woff"), url(fonts/KaTeX_Main-BoldItalic.ttf) format("truetype"); + font-weight: bold; + font-style: italic; + font-display: swap; +} +@font-face { + font-family: "KaTeX_Main"; + src: url(fonts/KaTeX_Main-Italic.woff2) format("woff2"), url(fonts/KaTeX_Main-Italic.woff) format("woff"), url(fonts/KaTeX_Main-Italic.ttf) format("truetype"); + font-weight: normal; + font-style: italic; + font-display: swap; +} +@font-face { + font-family: "KaTeX_Main"; + src: url(fonts/KaTeX_Main-Regular.woff2) format("woff2"), url(fonts/KaTeX_Main-Regular.woff) format("woff"), url(fonts/KaTeX_Main-Regular.ttf) format("truetype"); + font-weight: normal; + font-style: normal; + font-display: swap; +} +@font-face { + font-family: "KaTeX_Math"; + src: url(fonts/KaTeX_Math-BoldItalic.woff2) format("woff2"), url(fonts/KaTeX_Math-BoldItalic.woff) format("woff"), url(fonts/KaTeX_Math-BoldItalic.ttf) format("truetype"); + font-weight: bold; + font-style: italic; + font-display: swap; +} +@font-face { + font-family: "KaTeX_Math"; + src: url(fonts/KaTeX_Math-Italic.woff2) format("woff2"), url(fonts/KaTeX_Math-Italic.woff) format("woff"), url(fonts/KaTeX_Math-Italic.ttf) format("truetype"); + font-weight: normal; + font-style: italic; + font-display: swap; +} +@font-face { + font-family: "KaTeX_SansSerif"; + src: url(fonts/KaTeX_SansSerif-Bold.woff2) format("woff2"), url(fonts/KaTeX_SansSerif-Bold.woff) format("woff"), url(fonts/KaTeX_SansSerif-Bold.ttf) format("truetype"); + font-weight: bold; + font-style: normal; + font-display: swap; +} +@font-face { + font-family: "KaTeX_SansSerif"; + src: url(fonts/KaTeX_SansSerif-Italic.woff2) format("woff2"), url(fonts/KaTeX_SansSerif-Italic.woff) format("woff"), url(fonts/KaTeX_SansSerif-Italic.ttf) format("truetype"); + font-weight: normal; + font-style: italic; + font-display: swap; +} +@font-face { + font-family: "KaTeX_SansSerif"; + src: url(fonts/KaTeX_SansSerif-Regular.woff2) format("woff2"), url(fonts/KaTeX_SansSerif-Regular.woff) format("woff"), url(fonts/KaTeX_SansSerif-Regular.ttf) format("truetype"); + font-weight: normal; + font-style: normal; + font-display: swap; +} +@font-face { + font-family: "KaTeX_Script"; + src: url(fonts/KaTeX_Script-Regular.woff2) format("woff2"), url(fonts/KaTeX_Script-Regular.woff) format("woff"), url(fonts/KaTeX_Script-Regular.ttf) format("truetype"); + font-weight: normal; + font-style: normal; + font-display: swap; +} +@font-face { + font-family: "KaTeX_Size1"; + src: url(fonts/KaTeX_Size1-Regular.woff2) format("woff2"), url(fonts/KaTeX_Size1-Regular.woff) format("woff"), url(fonts/KaTeX_Size1-Regular.ttf) format("truetype"); + font-weight: normal; + font-style: normal; + font-display: swap; +} +@font-face { + font-family: "KaTeX_Size2"; + src: url(fonts/KaTeX_Size2-Regular.woff2) format("woff2"), url(fonts/KaTeX_Size2-Regular.woff) format("woff"), url(fonts/KaTeX_Size2-Regular.ttf) format("truetype"); + font-weight: normal; + font-style: normal; + font-display: swap; +} +@font-face { + font-family: "KaTeX_Size3"; + src: url(fonts/KaTeX_Size3-Regular.woff2) format("woff2"), url(fonts/KaTeX_Size3-Regular.woff) format("woff"), url(fonts/KaTeX_Size3-Regular.ttf) format("truetype"); + font-weight: normal; + font-style: normal; + font-display: swap; +} +@font-face { + font-family: "KaTeX_Size4"; + src: url(fonts/KaTeX_Size4-Regular.woff2) format("woff2"), url(fonts/KaTeX_Size4-Regular.woff) format("woff"), url(fonts/KaTeX_Size4-Regular.ttf) format("truetype"); + font-weight: normal; + font-style: normal; + font-display: swap; +} +@font-face { + font-family: "KaTeX_Typewriter"; + src: url(fonts/KaTeX_Typewriter-Regular.woff2) format("woff2"), url(fonts/KaTeX_Typewriter-Regular.woff) format("woff"), url(fonts/KaTeX_Typewriter-Regular.ttf) format("truetype"); + font-weight: normal; + font-style: normal; + font-display: swap; +} +/* stylelint-disable font-family-no-missing-generic-family-keyword */ +.katex { + font: normal 1.21em KaTeX_Main, Times New Roman, serif; + line-height: 1.2; + position: relative; + text-indent: 0; + text-rendering: auto; +} +.katex * { + -ms-high-contrast-adjust: none !important; +} +.katex * { + border-color: currentColor; +} +.katex .katex-version::after { + content: "0.17.0"; +} +.katex .katex-mathml { + /* Accessibility hack to only show to screen readers + Found at: http://a11yproject.com/posts/how-to-hide-content/ */ + position: absolute; + -webkit-clip-path: inset(50%); + clip-path: inset(50%); + padding: 0; + border: 0; + height: 1px; + width: 1px; + overflow: hidden; +} +.katex .katex-html { + /* \newline is an empty block at top level, between .base elements */ +} +.katex .katex-html > .newline { + display: block; +} +.katex .base { + position: relative; + display: inline-block; + white-space: nowrap; + width: -webkit-min-content; + width: -moz-min-content; + width: min-content; +} +.katex .strut { + display: inline-block; +} +.katex .textbf { + font-weight: bold; +} +.katex .textit { + font-style: italic; +} +.katex .textrm { + font-family: KaTeX_Main; +} +.katex .textsf { + font-family: KaTeX_SansSerif; +} +.katex .texttt { + font-family: KaTeX_Typewriter; +} +.katex .mathnormal { + font-family: KaTeX_Math; + font-style: italic; +} +.katex .mathit { + font-family: KaTeX_Main; + font-style: italic; +} +.katex .mathrm { + font-style: normal; +} +.katex .mathbf { + font-family: KaTeX_Main; + font-weight: bold; +} +.katex .boldsymbol { + font-family: KaTeX_Math; + font-weight: bold; + font-style: italic; +} +.katex .amsrm { + font-family: KaTeX_AMS; +} +.katex .mathbb, +.katex .textbb { + font-family: KaTeX_AMS; +} +.katex .mathcal { + font-family: KaTeX_Caligraphic; +} +.katex .mathfrak, +.katex .textfrak { + font-family: KaTeX_Fraktur; +} +.katex .mathboldfrak, +.katex .textboldfrak { + font-family: KaTeX_Fraktur; + font-weight: bold; +} +.katex .mathtt { + font-family: KaTeX_Typewriter; +} +.katex .mathscr, +.katex .textscr { + font-family: KaTeX_Script; +} +.katex .mathsf, +.katex .textsf { + font-family: KaTeX_SansSerif; +} +.katex .mathboldsf, +.katex .textboldsf { + font-family: KaTeX_SansSerif; + font-weight: bold; +} +.katex .mathsfit, +.katex .mathitsf, +.katex .textitsf { + font-family: KaTeX_SansSerif; + font-style: italic; +} +.katex .mainrm { + font-family: KaTeX_Main; + font-style: normal; +} +.katex .vlist-t { + display: inline-table; + table-layout: fixed; + border-collapse: collapse; +} +.katex .vlist-r { + display: table-row; +} +.katex .vlist { + display: table-cell; + vertical-align: bottom; + position: relative; +} +.katex .vlist > span { + display: block; + height: 0; + position: relative; +} +.katex .vlist > span > span { + display: inline-block; +} +.katex .vlist > span > .pstrut { + overflow: hidden; + width: 0; +} +.katex .vlist-t2 { + margin-right: -2px; +} +.katex .vlist-s { + display: table-cell; + vertical-align: bottom; + font-size: 1px; + width: 2px; + min-width: 2px; +} +.katex .vbox { + display: inline-flex; + flex-direction: column; + align-items: baseline; +} +.katex .hbox { + display: inline-flex; + flex-direction: row; + width: 100%; +} +.katex .thinbox { + display: inline-flex; + flex-direction: row; + width: 0; + max-width: 0; +} +.katex .msupsub { + text-align: left; +} +.katex .mfrac > span > span { + text-align: center; +} +.katex .mfrac .frac-line { + display: inline-block; + width: 100%; + border-bottom-style: solid; +} +.katex .mfrac .frac-line, +.katex .overline .overline-line, +.katex .underline .underline-line, +.katex .hline, +.katex .hdashline, +.katex .rule { + min-height: 1px; +} +.katex .mspace { + display: inline-block; +} +.katex .smash { + display: inline; + line-height: 0; +} +.katex .llap, +.katex .rlap, +.katex .clap { + width: 0; + position: relative; +} +.katex .llap > .inner, +.katex .rlap > .inner, +.katex .clap > .inner { + position: absolute; +} +.katex .llap > .fix, +.katex .rlap > .fix, +.katex .clap > .fix { + display: inline-block; +} +.katex .llap > .inner { + right: 0; +} +.katex .rlap > .inner, +.katex .clap > .inner { + left: 0; +} +.katex .clap > .inner > span { + margin-left: -50%; + margin-right: 50%; +} +.katex .rule { + display: inline-block; + border: solid 0; + position: relative; +} +.katex .overline .overline-line, +.katex .underline .underline-line, +.katex .hline { + display: inline-block; + width: 100%; + border-bottom-style: solid; +} +.katex .hdashline { + display: inline-block; + width: 100%; + border-bottom-style: dashed; +} +.katex .sqrt > .root { + /* These values are taken from the definition of `\r@@t`, + `\mkern 5mu` and `\mkern -10mu`. */ + /* stylelint-disable-next-line declaration-property-value-no-unknown */ + margin-left: 0.2777777778em; + /* stylelint-disable-next-line declaration-property-value-no-unknown */ + margin-right: -0.5555555556em; +} +.katex .sizing.reset-size1.size1, +.katex .fontsize-ensurer.reset-size1.size1 { + /* stylelint-disable-next-line */ + font-size: 1em; +} +.katex .sizing.reset-size1.size2, +.katex .fontsize-ensurer.reset-size1.size2 { + /* stylelint-disable-next-line */ + font-size: 1.2em; +} +.katex .sizing.reset-size1.size3, +.katex .fontsize-ensurer.reset-size1.size3 { + /* stylelint-disable-next-line */ + font-size: 1.4em; +} +.katex .sizing.reset-size1.size4, +.katex .fontsize-ensurer.reset-size1.size4 { + /* stylelint-disable-next-line */ + font-size: 1.6em; +} +.katex .sizing.reset-size1.size5, +.katex .fontsize-ensurer.reset-size1.size5 { + /* stylelint-disable-next-line */ + font-size: 1.8em; +} +.katex .sizing.reset-size1.size6, +.katex .fontsize-ensurer.reset-size1.size6 { + /* stylelint-disable-next-line */ + font-size: 2em; +} +.katex .sizing.reset-size1.size7, +.katex .fontsize-ensurer.reset-size1.size7 { + /* stylelint-disable-next-line */ + font-size: 2.4em; +} +.katex .sizing.reset-size1.size8, +.katex .fontsize-ensurer.reset-size1.size8 { + /* stylelint-disable-next-line */ + font-size: 2.88em; +} +.katex .sizing.reset-size1.size9, +.katex .fontsize-ensurer.reset-size1.size9 { + /* stylelint-disable-next-line */ + font-size: 3.456em; +} +.katex .sizing.reset-size1.size10, +.katex .fontsize-ensurer.reset-size1.size10 { + /* stylelint-disable-next-line */ + font-size: 4.148em; +} +.katex .sizing.reset-size1.size11, +.katex .fontsize-ensurer.reset-size1.size11 { + /* stylelint-disable-next-line */ + font-size: 4.976em; +} +.katex .sizing.reset-size2.size1, +.katex .fontsize-ensurer.reset-size2.size1 { + /* stylelint-disable-next-line */ + font-size: 0.8333333333em; +} +.katex .sizing.reset-size2.size2, +.katex .fontsize-ensurer.reset-size2.size2 { + /* stylelint-disable-next-line */ + font-size: 1em; +} +.katex .sizing.reset-size2.size3, +.katex .fontsize-ensurer.reset-size2.size3 { + /* stylelint-disable-next-line */ + font-size: 1.1666666667em; +} +.katex .sizing.reset-size2.size4, +.katex .fontsize-ensurer.reset-size2.size4 { + /* stylelint-disable-next-line */ + font-size: 1.3333333333em; +} +.katex .sizing.reset-size2.size5, +.katex .fontsize-ensurer.reset-size2.size5 { + /* stylelint-disable-next-line */ + font-size: 1.5em; +} +.katex .sizing.reset-size2.size6, +.katex .fontsize-ensurer.reset-size2.size6 { + /* stylelint-disable-next-line */ + font-size: 1.6666666667em; +} +.katex .sizing.reset-size2.size7, +.katex .fontsize-ensurer.reset-size2.size7 { + /* stylelint-disable-next-line */ + font-size: 2em; +} +.katex .sizing.reset-size2.size8, +.katex .fontsize-ensurer.reset-size2.size8 { + /* stylelint-disable-next-line */ + font-size: 2.4em; +} +.katex .sizing.reset-size2.size9, +.katex .fontsize-ensurer.reset-size2.size9 { + /* stylelint-disable-next-line */ + font-size: 2.88em; +} +.katex .sizing.reset-size2.size10, +.katex .fontsize-ensurer.reset-size2.size10 { + /* stylelint-disable-next-line */ + font-size: 3.4566666667em; +} +.katex .sizing.reset-size2.size11, +.katex .fontsize-ensurer.reset-size2.size11 { + /* stylelint-disable-next-line */ + font-size: 4.1466666667em; +} +.katex .sizing.reset-size3.size1, +.katex .fontsize-ensurer.reset-size3.size1 { + /* stylelint-disable-next-line */ + font-size: 0.7142857143em; +} +.katex .sizing.reset-size3.size2, +.katex .fontsize-ensurer.reset-size3.size2 { + /* stylelint-disable-next-line */ + font-size: 0.8571428571em; +} +.katex .sizing.reset-size3.size3, +.katex .fontsize-ensurer.reset-size3.size3 { + /* stylelint-disable-next-line */ + font-size: 1em; +} +.katex .sizing.reset-size3.size4, +.katex .fontsize-ensurer.reset-size3.size4 { + /* stylelint-disable-next-line */ + font-size: 1.1428571429em; +} +.katex .sizing.reset-size3.size5, +.katex .fontsize-ensurer.reset-size3.size5 { + /* stylelint-disable-next-line */ + font-size: 1.2857142857em; +} +.katex .sizing.reset-size3.size6, +.katex .fontsize-ensurer.reset-size3.size6 { + /* stylelint-disable-next-line */ + font-size: 1.4285714286em; +} +.katex .sizing.reset-size3.size7, +.katex .fontsize-ensurer.reset-size3.size7 { + /* stylelint-disable-next-line */ + font-size: 1.7142857143em; +} +.katex .sizing.reset-size3.size8, +.katex .fontsize-ensurer.reset-size3.size8 { + /* stylelint-disable-next-line */ + font-size: 2.0571428571em; +} +.katex .sizing.reset-size3.size9, +.katex .fontsize-ensurer.reset-size3.size9 { + /* stylelint-disable-next-line */ + font-size: 2.4685714286em; +} +.katex .sizing.reset-size3.size10, +.katex .fontsize-ensurer.reset-size3.size10 { + /* stylelint-disable-next-line */ + font-size: 2.9628571429em; +} +.katex .sizing.reset-size3.size11, +.katex .fontsize-ensurer.reset-size3.size11 { + /* stylelint-disable-next-line */ + font-size: 3.5542857143em; +} +.katex .sizing.reset-size4.size1, +.katex .fontsize-ensurer.reset-size4.size1 { + /* stylelint-disable-next-line */ + font-size: 0.625em; +} +.katex .sizing.reset-size4.size2, +.katex .fontsize-ensurer.reset-size4.size2 { + /* stylelint-disable-next-line */ + font-size: 0.75em; +} +.katex .sizing.reset-size4.size3, +.katex .fontsize-ensurer.reset-size4.size3 { + /* stylelint-disable-next-line */ + font-size: 0.875em; +} +.katex .sizing.reset-size4.size4, +.katex .fontsize-ensurer.reset-size4.size4 { + /* stylelint-disable-next-line */ + font-size: 1em; +} +.katex .sizing.reset-size4.size5, +.katex .fontsize-ensurer.reset-size4.size5 { + /* stylelint-disable-next-line */ + font-size: 1.125em; +} +.katex .sizing.reset-size4.size6, +.katex .fontsize-ensurer.reset-size4.size6 { + /* stylelint-disable-next-line */ + font-size: 1.25em; +} +.katex .sizing.reset-size4.size7, +.katex .fontsize-ensurer.reset-size4.size7 { + /* stylelint-disable-next-line */ + font-size: 1.5em; +} +.katex .sizing.reset-size4.size8, +.katex .fontsize-ensurer.reset-size4.size8 { + /* stylelint-disable-next-line */ + font-size: 1.8em; +} +.katex .sizing.reset-size4.size9, +.katex .fontsize-ensurer.reset-size4.size9 { + /* stylelint-disable-next-line */ + font-size: 2.16em; +} +.katex .sizing.reset-size4.size10, +.katex .fontsize-ensurer.reset-size4.size10 { + /* stylelint-disable-next-line */ + font-size: 2.5925em; +} +.katex .sizing.reset-size4.size11, +.katex .fontsize-ensurer.reset-size4.size11 { + /* stylelint-disable-next-line */ + font-size: 3.11em; +} +.katex .sizing.reset-size5.size1, +.katex .fontsize-ensurer.reset-size5.size1 { + /* stylelint-disable-next-line */ + font-size: 0.5555555556em; +} +.katex .sizing.reset-size5.size2, +.katex .fontsize-ensurer.reset-size5.size2 { + /* stylelint-disable-next-line */ + font-size: 0.6666666667em; +} +.katex .sizing.reset-size5.size3, +.katex .fontsize-ensurer.reset-size5.size3 { + /* stylelint-disable-next-line */ + font-size: 0.7777777778em; +} +.katex .sizing.reset-size5.size4, +.katex .fontsize-ensurer.reset-size5.size4 { + /* stylelint-disable-next-line */ + font-size: 0.8888888889em; +} +.katex .sizing.reset-size5.size5, +.katex .fontsize-ensurer.reset-size5.size5 { + /* stylelint-disable-next-line */ + font-size: 1em; +} +.katex .sizing.reset-size5.size6, +.katex .fontsize-ensurer.reset-size5.size6 { + /* stylelint-disable-next-line */ + font-size: 1.1111111111em; +} +.katex .sizing.reset-size5.size7, +.katex .fontsize-ensurer.reset-size5.size7 { + /* stylelint-disable-next-line */ + font-size: 1.3333333333em; +} +.katex .sizing.reset-size5.size8, +.katex .fontsize-ensurer.reset-size5.size8 { + /* stylelint-disable-next-line */ + font-size: 1.6em; +} +.katex .sizing.reset-size5.size9, +.katex .fontsize-ensurer.reset-size5.size9 { + /* stylelint-disable-next-line */ + font-size: 1.92em; +} +.katex .sizing.reset-size5.size10, +.katex .fontsize-ensurer.reset-size5.size10 { + /* stylelint-disable-next-line */ + font-size: 2.3044444444em; +} +.katex .sizing.reset-size5.size11, +.katex .fontsize-ensurer.reset-size5.size11 { + /* stylelint-disable-next-line */ + font-size: 2.7644444444em; +} +.katex .sizing.reset-size6.size1, +.katex .fontsize-ensurer.reset-size6.size1 { + /* stylelint-disable-next-line */ + font-size: 0.5em; +} +.katex .sizing.reset-size6.size2, +.katex .fontsize-ensurer.reset-size6.size2 { + /* stylelint-disable-next-line */ + font-size: 0.6em; +} +.katex .sizing.reset-size6.size3, +.katex .fontsize-ensurer.reset-size6.size3 { + /* stylelint-disable-next-line */ + font-size: 0.7em; +} +.katex .sizing.reset-size6.size4, +.katex .fontsize-ensurer.reset-size6.size4 { + /* stylelint-disable-next-line */ + font-size: 0.8em; +} +.katex .sizing.reset-size6.size5, +.katex .fontsize-ensurer.reset-size6.size5 { + /* stylelint-disable-next-line */ + font-size: 0.9em; +} +.katex .sizing.reset-size6.size6, +.katex .fontsize-ensurer.reset-size6.size6 { + /* stylelint-disable-next-line */ + font-size: 1em; +} +.katex .sizing.reset-size6.size7, +.katex .fontsize-ensurer.reset-size6.size7 { + /* stylelint-disable-next-line */ + font-size: 1.2em; +} +.katex .sizing.reset-size6.size8, +.katex .fontsize-ensurer.reset-size6.size8 { + /* stylelint-disable-next-line */ + font-size: 1.44em; +} +.katex .sizing.reset-size6.size9, +.katex .fontsize-ensurer.reset-size6.size9 { + /* stylelint-disable-next-line */ + font-size: 1.728em; +} +.katex .sizing.reset-size6.size10, +.katex .fontsize-ensurer.reset-size6.size10 { + /* stylelint-disable-next-line */ + font-size: 2.074em; +} +.katex .sizing.reset-size6.size11, +.katex .fontsize-ensurer.reset-size6.size11 { + /* stylelint-disable-next-line */ + font-size: 2.488em; +} +.katex .sizing.reset-size7.size1, +.katex .fontsize-ensurer.reset-size7.size1 { + /* stylelint-disable-next-line */ + font-size: 0.4166666667em; +} +.katex .sizing.reset-size7.size2, +.katex .fontsize-ensurer.reset-size7.size2 { + /* stylelint-disable-next-line */ + font-size: 0.5em; +} +.katex .sizing.reset-size7.size3, +.katex .fontsize-ensurer.reset-size7.size3 { + /* stylelint-disable-next-line */ + font-size: 0.5833333333em; +} +.katex .sizing.reset-size7.size4, +.katex .fontsize-ensurer.reset-size7.size4 { + /* stylelint-disable-next-line */ + font-size: 0.6666666667em; +} +.katex .sizing.reset-size7.size5, +.katex .fontsize-ensurer.reset-size7.size5 { + /* stylelint-disable-next-line */ + font-size: 0.75em; +} +.katex .sizing.reset-size7.size6, +.katex .fontsize-ensurer.reset-size7.size6 { + /* stylelint-disable-next-line */ + font-size: 0.8333333333em; +} +.katex .sizing.reset-size7.size7, +.katex .fontsize-ensurer.reset-size7.size7 { + /* stylelint-disable-next-line */ + font-size: 1em; +} +.katex .sizing.reset-size7.size8, +.katex .fontsize-ensurer.reset-size7.size8 { + /* stylelint-disable-next-line */ + font-size: 1.2em; +} +.katex .sizing.reset-size7.size9, +.katex .fontsize-ensurer.reset-size7.size9 { + /* stylelint-disable-next-line */ + font-size: 1.44em; +} +.katex .sizing.reset-size7.size10, +.katex .fontsize-ensurer.reset-size7.size10 { + /* stylelint-disable-next-line */ + font-size: 1.7283333333em; +} +.katex .sizing.reset-size7.size11, +.katex .fontsize-ensurer.reset-size7.size11 { + /* stylelint-disable-next-line */ + font-size: 2.0733333333em; +} +.katex .sizing.reset-size8.size1, +.katex .fontsize-ensurer.reset-size8.size1 { + /* stylelint-disable-next-line */ + font-size: 0.3472222222em; +} +.katex .sizing.reset-size8.size2, +.katex .fontsize-ensurer.reset-size8.size2 { + /* stylelint-disable-next-line */ + font-size: 0.4166666667em; +} +.katex .sizing.reset-size8.size3, +.katex .fontsize-ensurer.reset-size8.size3 { + /* stylelint-disable-next-line */ + font-size: 0.4861111111em; +} +.katex .sizing.reset-size8.size4, +.katex .fontsize-ensurer.reset-size8.size4 { + /* stylelint-disable-next-line */ + font-size: 0.5555555556em; +} +.katex .sizing.reset-size8.size5, +.katex .fontsize-ensurer.reset-size8.size5 { + /* stylelint-disable-next-line */ + font-size: 0.625em; +} +.katex .sizing.reset-size8.size6, +.katex .fontsize-ensurer.reset-size8.size6 { + /* stylelint-disable-next-line */ + font-size: 0.6944444444em; +} +.katex .sizing.reset-size8.size7, +.katex .fontsize-ensurer.reset-size8.size7 { + /* stylelint-disable-next-line */ + font-size: 0.8333333333em; +} +.katex .sizing.reset-size8.size8, +.katex .fontsize-ensurer.reset-size8.size8 { + /* stylelint-disable-next-line */ + font-size: 1em; +} +.katex .sizing.reset-size8.size9, +.katex .fontsize-ensurer.reset-size8.size9 { + /* stylelint-disable-next-line */ + font-size: 1.2em; +} +.katex .sizing.reset-size8.size10, +.katex .fontsize-ensurer.reset-size8.size10 { + /* stylelint-disable-next-line */ + font-size: 1.4402777778em; +} +.katex .sizing.reset-size8.size11, +.katex .fontsize-ensurer.reset-size8.size11 { + /* stylelint-disable-next-line */ + font-size: 1.7277777778em; +} +.katex .sizing.reset-size9.size1, +.katex .fontsize-ensurer.reset-size9.size1 { + /* stylelint-disable-next-line */ + font-size: 0.2893518519em; +} +.katex .sizing.reset-size9.size2, +.katex .fontsize-ensurer.reset-size9.size2 { + /* stylelint-disable-next-line */ + font-size: 0.3472222222em; +} +.katex .sizing.reset-size9.size3, +.katex .fontsize-ensurer.reset-size9.size3 { + /* stylelint-disable-next-line */ + font-size: 0.4050925926em; +} +.katex .sizing.reset-size9.size4, +.katex .fontsize-ensurer.reset-size9.size4 { + /* stylelint-disable-next-line */ + font-size: 0.462962963em; +} +.katex .sizing.reset-size9.size5, +.katex .fontsize-ensurer.reset-size9.size5 { + /* stylelint-disable-next-line */ + font-size: 0.5208333333em; +} +.katex .sizing.reset-size9.size6, +.katex .fontsize-ensurer.reset-size9.size6 { + /* stylelint-disable-next-line */ + font-size: 0.5787037037em; +} +.katex .sizing.reset-size9.size7, +.katex .fontsize-ensurer.reset-size9.size7 { + /* stylelint-disable-next-line */ + font-size: 0.6944444444em; +} +.katex .sizing.reset-size9.size8, +.katex .fontsize-ensurer.reset-size9.size8 { + /* stylelint-disable-next-line */ + font-size: 0.8333333333em; +} +.katex .sizing.reset-size9.size9, +.katex .fontsize-ensurer.reset-size9.size9 { + /* stylelint-disable-next-line */ + font-size: 1em; +} +.katex .sizing.reset-size9.size10, +.katex .fontsize-ensurer.reset-size9.size10 { + /* stylelint-disable-next-line */ + font-size: 1.2002314815em; +} +.katex .sizing.reset-size9.size11, +.katex .fontsize-ensurer.reset-size9.size11 { + /* stylelint-disable-next-line */ + font-size: 1.4398148148em; +} +.katex .sizing.reset-size10.size1, +.katex .fontsize-ensurer.reset-size10.size1 { + /* stylelint-disable-next-line */ + font-size: 0.2410800386em; +} +.katex .sizing.reset-size10.size2, +.katex .fontsize-ensurer.reset-size10.size2 { + /* stylelint-disable-next-line */ + font-size: 0.2892960463em; +} +.katex .sizing.reset-size10.size3, +.katex .fontsize-ensurer.reset-size10.size3 { + /* stylelint-disable-next-line */ + font-size: 0.337512054em; +} +.katex .sizing.reset-size10.size4, +.katex .fontsize-ensurer.reset-size10.size4 { + /* stylelint-disable-next-line */ + font-size: 0.3857280617em; +} +.katex .sizing.reset-size10.size5, +.katex .fontsize-ensurer.reset-size10.size5 { + /* stylelint-disable-next-line */ + font-size: 0.4339440694em; +} +.katex .sizing.reset-size10.size6, +.katex .fontsize-ensurer.reset-size10.size6 { + /* stylelint-disable-next-line */ + font-size: 0.4821600771em; +} +.katex .sizing.reset-size10.size7, +.katex .fontsize-ensurer.reset-size10.size7 { + /* stylelint-disable-next-line */ + font-size: 0.5785920926em; +} +.katex .sizing.reset-size10.size8, +.katex .fontsize-ensurer.reset-size10.size8 { + /* stylelint-disable-next-line */ + font-size: 0.6943105111em; +} +.katex .sizing.reset-size10.size9, +.katex .fontsize-ensurer.reset-size10.size9 { + /* stylelint-disable-next-line */ + font-size: 0.8331726133em; +} +.katex .sizing.reset-size10.size10, +.katex .fontsize-ensurer.reset-size10.size10 { + /* stylelint-disable-next-line */ + font-size: 1em; +} +.katex .sizing.reset-size10.size11, +.katex .fontsize-ensurer.reset-size10.size11 { + /* stylelint-disable-next-line */ + font-size: 1.1996142719em; +} +.katex .sizing.reset-size11.size1, +.katex .fontsize-ensurer.reset-size11.size1 { + /* stylelint-disable-next-line */ + font-size: 0.2009646302em; +} +.katex .sizing.reset-size11.size2, +.katex .fontsize-ensurer.reset-size11.size2 { + /* stylelint-disable-next-line */ + font-size: 0.2411575563em; +} +.katex .sizing.reset-size11.size3, +.katex .fontsize-ensurer.reset-size11.size3 { + /* stylelint-disable-next-line */ + font-size: 0.2813504823em; +} +.katex .sizing.reset-size11.size4, +.katex .fontsize-ensurer.reset-size11.size4 { + /* stylelint-disable-next-line */ + font-size: 0.3215434084em; +} +.katex .sizing.reset-size11.size5, +.katex .fontsize-ensurer.reset-size11.size5 { + /* stylelint-disable-next-line */ + font-size: 0.3617363344em; +} +.katex .sizing.reset-size11.size6, +.katex .fontsize-ensurer.reset-size11.size6 { + /* stylelint-disable-next-line */ + font-size: 0.4019292605em; +} +.katex .sizing.reset-size11.size7, +.katex .fontsize-ensurer.reset-size11.size7 { + /* stylelint-disable-next-line */ + font-size: 0.4823151125em; +} +.katex .sizing.reset-size11.size8, +.katex .fontsize-ensurer.reset-size11.size8 { + /* stylelint-disable-next-line */ + font-size: 0.578778135em; +} +.katex .sizing.reset-size11.size9, +.katex .fontsize-ensurer.reset-size11.size9 { + /* stylelint-disable-next-line */ + font-size: 0.6945337621em; +} +.katex .sizing.reset-size11.size10, +.katex .fontsize-ensurer.reset-size11.size10 { + /* stylelint-disable-next-line */ + font-size: 0.8336012862em; +} +.katex .sizing.reset-size11.size11, +.katex .fontsize-ensurer.reset-size11.size11 { + /* stylelint-disable-next-line */ + font-size: 1em; +} +.katex .delimsizing.size1 { + font-family: KaTeX_Size1; +} +.katex .delimsizing.size2 { + font-family: KaTeX_Size2; +} +.katex .delimsizing.size3 { + font-family: KaTeX_Size3; +} +.katex .delimsizing.size4 { + font-family: KaTeX_Size4; +} +.katex .delimsizing.mult .delim-size1 > span { + font-family: KaTeX_Size1; +} +.katex .delimsizing.mult .delim-size4 > span { + font-family: KaTeX_Size4; +} +.katex .nulldelimiter { + display: inline-block; + width: 0.12em; +} +.katex .delimcenter { + position: relative; +} +.katex .op-symbol { + position: relative; +} +.katex .op-symbol.small-op { + font-family: KaTeX_Size1; +} +.katex .op-symbol.large-op { + font-family: KaTeX_Size2; +} +.katex .op-limits > .vlist-t { + text-align: center; +} +.katex .accent > .vlist-t { + text-align: center; +} +.katex .accent .accent-body { + position: relative; +} +.katex .accent .accent-body:not(.accent-full) { + width: 0; +} +.katex .overlay { + display: block; +} +.katex .mtable .vertical-separator { + display: inline-block; + min-width: 1px; +} +.katex .mtable .arraycolsep { + display: inline-block; +} +.katex .mtable .col-align-c > .vlist-t { + text-align: center; +} +.katex .mtable .col-align-l > .vlist-t { + text-align: left; +} +.katex .mtable .col-align-r > .vlist-t { + text-align: right; +} +.katex .svg-align { + text-align: left; +} +.katex svg { + display: block; + position: absolute; + width: 100%; + height: inherit; + fill: currentColor; + stroke: currentColor; +} +.katex svg path { + stroke: none; +} +.katex svg { + fill-rule: nonzero; + fill-opacity: 1; + stroke-width: 1; + stroke-linecap: butt; + stroke-linejoin: miter; + stroke-miterlimit: 4; + stroke-dasharray: none; + stroke-dashoffset: 0; + stroke-opacity: 1; +} +.katex img { + border-style: none; + min-width: 0; + min-height: 0; + max-width: none; + max-height: none; +} +.katex .stretchy { + width: 100%; + display: block; + position: relative; + overflow: hidden; +} +.katex .stretchy::before, .katex .stretchy::after { + content: ""; +} +.katex .hide-tail { + width: 100%; + position: relative; + overflow: hidden; +} +.katex .halfarrow-left { + position: absolute; + left: 0; + width: 50.2%; + overflow: hidden; +} +.katex .halfarrow-right { + position: absolute; + right: 0; + width: 50.2%; + overflow: hidden; +} +.katex .brace-left { + position: absolute; + left: 0; + width: 25.1%; + overflow: hidden; +} +.katex .brace-center { + position: absolute; + left: 25%; + width: 50%; + overflow: hidden; +} +.katex .brace-right { + position: absolute; + right: 0; + width: 25.1%; + overflow: hidden; +} +.katex .x-arrow-pad { + padding: 0 0.5em; +} +.katex .cd-arrow-pad { + padding: 0 0.55556em 0 0.27778em; +} +.katex .x-arrow, +.katex .mover, +.katex .munder { + text-align: center; +} +.katex .boxpad { + padding: 0 0.3em; +} +.katex .fbox, +.katex .fcolorbox { + box-sizing: border-box; + border: 0.04em solid; +} +.katex .cancel-pad { + padding: 0 0.2em; +} +.katex .cancel-lap { + margin-left: -0.2em; + margin-right: -0.2em; +} +.katex .sout { + border-bottom-style: solid; + border-bottom-width: 0.08em; +} +.katex .angl { + box-sizing: border-box; + border-top: 0.049em solid; + border-right: 0.049em solid; + margin-right: 0.03889em; +} +.katex .anglpad { + padding: 0 0.03889em; +} +.katex .eqn-num::before { + counter-increment: katexEqnNo; + content: "(" counter(katexEqnNo) ")"; +} +.katex .mml-eqn-num::before { + counter-increment: mmlEqnNo; + content: "(" counter(mmlEqnNo) ")"; +} +.katex .mtr-glue { + width: 50%; +} +.katex .cd-vert-arrow { + display: inline-block; + position: relative; +} +.katex .cd-label-left { + display: inline-block; + position: absolute; + right: calc(50% + 0.3em); + text-align: left; +} +.katex .cd-label-right { + display: inline-block; + position: absolute; + left: calc(50% + 0.3em); + text-align: right; +} + +.katex-display { + display: block; + margin: 1em 0; + text-align: center; +} +.katex-display > .katex { + display: block; + text-align: center; + white-space: nowrap; +} +.katex-display > .katex > .katex-html { + display: block; + position: relative; +} +.katex-display > .katex > .katex-html > .tag { + position: absolute; + right: 0; +} + +.katex-display.leqno > .katex > .katex-html > .tag { + left: 0; + right: auto; +} + +.katex-display.fleqn > .katex { + text-align: left; + padding-left: 2em; +} + +body { + counter-reset: katexEqnNo mmlEqnNo; +} diff --git a/node_modules/katex/dist/katex-swap.min.css b/node_modules/katex/dist/katex-swap.min.css new file mode 100644 index 0000000..85578ad --- /dev/null +++ b/node_modules/katex/dist/katex-swap.min.css @@ -0,0 +1 @@ +@font-face{font-display:swap;font-family:KaTeX_AMS;font-style:normal;font-weight:400;src:url(fonts/KaTeX_AMS-Regular.woff2) format("woff2"),url(fonts/KaTeX_AMS-Regular.woff) format("woff"),url(fonts/KaTeX_AMS-Regular.ttf) format("truetype")}@font-face{font-display:swap;font-family:KaTeX_Caligraphic;font-style:normal;font-weight:700;src:url(fonts/KaTeX_Caligraphic-Bold.woff2) format("woff2"),url(fonts/KaTeX_Caligraphic-Bold.woff) format("woff"),url(fonts/KaTeX_Caligraphic-Bold.ttf) format("truetype")}@font-face{font-display:swap;font-family:KaTeX_Caligraphic;font-style:normal;font-weight:400;src:url(fonts/KaTeX_Caligraphic-Regular.woff2) format("woff2"),url(fonts/KaTeX_Caligraphic-Regular.woff) format("woff"),url(fonts/KaTeX_Caligraphic-Regular.ttf) format("truetype")}@font-face{font-display:swap;font-family:KaTeX_Fraktur;font-style:normal;font-weight:700;src:url(fonts/KaTeX_Fraktur-Bold.woff2) format("woff2"),url(fonts/KaTeX_Fraktur-Bold.woff) format("woff"),url(fonts/KaTeX_Fraktur-Bold.ttf) format("truetype")}@font-face{font-display:swap;font-family:KaTeX_Fraktur;font-style:normal;font-weight:400;src:url(fonts/KaTeX_Fraktur-Regular.woff2) format("woff2"),url(fonts/KaTeX_Fraktur-Regular.woff) format("woff"),url(fonts/KaTeX_Fraktur-Regular.ttf) format("truetype")}@font-face{font-display:swap;font-family:KaTeX_Main;font-style:normal;font-weight:700;src:url(fonts/KaTeX_Main-Bold.woff2) format("woff2"),url(fonts/KaTeX_Main-Bold.woff) format("woff"),url(fonts/KaTeX_Main-Bold.ttf) format("truetype")}@font-face{font-display:swap;font-family:KaTeX_Main;font-style:italic;font-weight:700;src:url(fonts/KaTeX_Main-BoldItalic.woff2) format("woff2"),url(fonts/KaTeX_Main-BoldItalic.woff) format("woff"),url(fonts/KaTeX_Main-BoldItalic.ttf) format("truetype")}@font-face{font-display:swap;font-family:KaTeX_Main;font-style:italic;font-weight:400;src:url(fonts/KaTeX_Main-Italic.woff2) format("woff2"),url(fonts/KaTeX_Main-Italic.woff) format("woff"),url(fonts/KaTeX_Main-Italic.ttf) format("truetype")}@font-face{font-display:swap;font-family:KaTeX_Main;font-style:normal;font-weight:400;src:url(fonts/KaTeX_Main-Regular.woff2) format("woff2"),url(fonts/KaTeX_Main-Regular.woff) format("woff"),url(fonts/KaTeX_Main-Regular.ttf) format("truetype")}@font-face{font-display:swap;font-family:KaTeX_Math;font-style:italic;font-weight:700;src:url(fonts/KaTeX_Math-BoldItalic.woff2) format("woff2"),url(fonts/KaTeX_Math-BoldItalic.woff) format("woff"),url(fonts/KaTeX_Math-BoldItalic.ttf) format("truetype")}@font-face{font-display:swap;font-family:KaTeX_Math;font-style:italic;font-weight:400;src:url(fonts/KaTeX_Math-Italic.woff2) format("woff2"),url(fonts/KaTeX_Math-Italic.woff) format("woff"),url(fonts/KaTeX_Math-Italic.ttf) format("truetype")}@font-face{font-display:swap;font-family:"KaTeX_SansSerif";font-style:normal;font-weight:700;src:url(fonts/KaTeX_SansSerif-Bold.woff2) format("woff2"),url(fonts/KaTeX_SansSerif-Bold.woff) format("woff"),url(fonts/KaTeX_SansSerif-Bold.ttf) format("truetype")}@font-face{font-display:swap;font-family:"KaTeX_SansSerif";font-style:italic;font-weight:400;src:url(fonts/KaTeX_SansSerif-Italic.woff2) format("woff2"),url(fonts/KaTeX_SansSerif-Italic.woff) format("woff"),url(fonts/KaTeX_SansSerif-Italic.ttf) format("truetype")}@font-face{font-display:swap;font-family:"KaTeX_SansSerif";font-style:normal;font-weight:400;src:url(fonts/KaTeX_SansSerif-Regular.woff2) format("woff2"),url(fonts/KaTeX_SansSerif-Regular.woff) format("woff"),url(fonts/KaTeX_SansSerif-Regular.ttf) format("truetype")}@font-face{font-display:swap;font-family:KaTeX_Script;font-style:normal;font-weight:400;src:url(fonts/KaTeX_Script-Regular.woff2) format("woff2"),url(fonts/KaTeX_Script-Regular.woff) format("woff"),url(fonts/KaTeX_Script-Regular.ttf) format("truetype")}@font-face{font-display:swap;font-family:KaTeX_Size1;font-style:normal;font-weight:400;src:url(fonts/KaTeX_Size1-Regular.woff2) format("woff2"),url(fonts/KaTeX_Size1-Regular.woff) format("woff"),url(fonts/KaTeX_Size1-Regular.ttf) format("truetype")}@font-face{font-display:swap;font-family:KaTeX_Size2;font-style:normal;font-weight:400;src:url(fonts/KaTeX_Size2-Regular.woff2) format("woff2"),url(fonts/KaTeX_Size2-Regular.woff) format("woff"),url(fonts/KaTeX_Size2-Regular.ttf) format("truetype")}@font-face{font-display:swap;font-family:KaTeX_Size3;font-style:normal;font-weight:400;src:url(fonts/KaTeX_Size3-Regular.woff2) format("woff2"),url(fonts/KaTeX_Size3-Regular.woff) format("woff"),url(fonts/KaTeX_Size3-Regular.ttf) format("truetype")}@font-face{font-display:swap;font-family:KaTeX_Size4;font-style:normal;font-weight:400;src:url(fonts/KaTeX_Size4-Regular.woff2) format("woff2"),url(fonts/KaTeX_Size4-Regular.woff) format("woff"),url(fonts/KaTeX_Size4-Regular.ttf) format("truetype")}@font-face{font-display:swap;font-family:KaTeX_Typewriter;font-style:normal;font-weight:400;src:url(fonts/KaTeX_Typewriter-Regular.woff2) format("woff2"),url(fonts/KaTeX_Typewriter-Regular.woff) format("woff"),url(fonts/KaTeX_Typewriter-Regular.ttf) format("truetype")}.katex{font:normal 1.21em KaTeX_Main,Times New Roman,serif;line-height:1.2;position:relative;text-indent:0;text-rendering:auto}.katex *{-ms-high-contrast-adjust:none!important;border-color:currentColor}.katex .katex-version:after{content:"0.17.0"}.katex .katex-mathml{border:0;-webkit-clip-path:inset(50%);clip-path:inset(50%);height:1px;overflow:hidden;padding:0;position:absolute;width:1px}.katex .katex-html>.newline{display:block}.katex .base{position:relative;white-space:nowrap;width:-webkit-min-content;width:-moz-min-content;width:min-content}.katex .base,.katex .strut{display:inline-block}.katex .textbf{font-weight:700}.katex .textit{font-style:italic}.katex .textrm{font-family:KaTeX_Main}.katex .textsf{font-family:KaTeX_SansSerif}.katex .texttt{font-family:KaTeX_Typewriter}.katex .mathnormal{font-family:KaTeX_Math;font-style:italic}.katex .mathit{font-family:KaTeX_Main;font-style:italic}.katex .mathrm{font-style:normal}.katex .mathbf{font-family:KaTeX_Main;font-weight:700}.katex .boldsymbol{font-family:KaTeX_Math;font-style:italic;font-weight:700}.katex .amsrm,.katex .mathbb,.katex .textbb{font-family:KaTeX_AMS}.katex .mathcal{font-family:KaTeX_Caligraphic}.katex .mathfrak,.katex .textfrak{font-family:KaTeX_Fraktur}.katex .mathboldfrak,.katex .textboldfrak{font-family:KaTeX_Fraktur;font-weight:700}.katex .mathtt{font-family:KaTeX_Typewriter}.katex .mathscr,.katex .textscr{font-family:KaTeX_Script}.katex .mathsf,.katex .textsf{font-family:KaTeX_SansSerif}.katex .mathboldsf,.katex .textboldsf{font-family:KaTeX_SansSerif;font-weight:700}.katex .mathitsf,.katex .mathsfit,.katex .textitsf{font-family:KaTeX_SansSerif;font-style:italic}.katex .mainrm{font-family:KaTeX_Main;font-style:normal}.katex .vlist-t{border-collapse:collapse;display:inline-table;table-layout:fixed}.katex .vlist-r{display:table-row}.katex .vlist{display:table-cell;position:relative;vertical-align:bottom}.katex .vlist>span{display:block;height:0;position:relative}.katex .vlist>span>span{display:inline-block}.katex .vlist>span>.pstrut{overflow:hidden;width:0}.katex .vlist-t2{margin-right:-2px}.katex .vlist-s{display:table-cell;font-size:1px;min-width:2px;vertical-align:bottom;width:2px}.katex .vbox{align-items:baseline;display:inline-flex;flex-direction:column}.katex .hbox{width:100%}.katex .hbox,.katex .thinbox{display:inline-flex;flex-direction:row}.katex .thinbox{max-width:0;width:0}.katex .msupsub{text-align:left}.katex .mfrac>span>span{text-align:center}.katex .mfrac .frac-line{border-bottom-style:solid;display:inline-block;width:100%}.katex .hdashline,.katex .hline,.katex .mfrac .frac-line,.katex .overline .overline-line,.katex .rule,.katex .underline .underline-line{min-height:1px}.katex .mspace{display:inline-block}.katex .smash{display:inline;line-height:0}.katex .clap,.katex .llap,.katex .rlap{position:relative;width:0}.katex .clap>.inner,.katex .llap>.inner,.katex .rlap>.inner{position:absolute}.katex .clap>.fix,.katex .llap>.fix,.katex .rlap>.fix{display:inline-block}.katex .llap>.inner{right:0}.katex .clap>.inner,.katex .rlap>.inner{left:0}.katex .clap>.inner>span{margin-left:-50%;margin-right:50%}.katex .rule{border:0 solid;display:inline-block;position:relative}.katex .hline,.katex .overline .overline-line,.katex .underline .underline-line{border-bottom-style:solid;display:inline-block;width:100%}.katex .hdashline{border-bottom-style:dashed;display:inline-block;width:100%}.katex .sqrt>.root{margin-left:.2777777778em;margin-right:-.5555555556em}.katex .fontsize-ensurer.reset-size1.size1,.katex .sizing.reset-size1.size1{font-size:1em}.katex .fontsize-ensurer.reset-size1.size2,.katex .sizing.reset-size1.size2{font-size:1.2em}.katex .fontsize-ensurer.reset-size1.size3,.katex .sizing.reset-size1.size3{font-size:1.4em}.katex .fontsize-ensurer.reset-size1.size4,.katex .sizing.reset-size1.size4{font-size:1.6em}.katex .fontsize-ensurer.reset-size1.size5,.katex .sizing.reset-size1.size5{font-size:1.8em}.katex .fontsize-ensurer.reset-size1.size6,.katex .sizing.reset-size1.size6{font-size:2em}.katex .fontsize-ensurer.reset-size1.size7,.katex .sizing.reset-size1.size7{font-size:2.4em}.katex .fontsize-ensurer.reset-size1.size8,.katex .sizing.reset-size1.size8{font-size:2.88em}.katex .fontsize-ensurer.reset-size1.size9,.katex .sizing.reset-size1.size9{font-size:3.456em}.katex .fontsize-ensurer.reset-size1.size10,.katex .sizing.reset-size1.size10{font-size:4.148em}.katex .fontsize-ensurer.reset-size1.size11,.katex .sizing.reset-size1.size11{font-size:4.976em}.katex .fontsize-ensurer.reset-size2.size1,.katex .sizing.reset-size2.size1{font-size:.8333333333em}.katex .fontsize-ensurer.reset-size2.size2,.katex .sizing.reset-size2.size2{font-size:1em}.katex .fontsize-ensurer.reset-size2.size3,.katex .sizing.reset-size2.size3{font-size:1.1666666667em}.katex .fontsize-ensurer.reset-size2.size4,.katex .sizing.reset-size2.size4{font-size:1.3333333333em}.katex .fontsize-ensurer.reset-size2.size5,.katex .sizing.reset-size2.size5{font-size:1.5em}.katex .fontsize-ensurer.reset-size2.size6,.katex .sizing.reset-size2.size6{font-size:1.6666666667em}.katex .fontsize-ensurer.reset-size2.size7,.katex .sizing.reset-size2.size7{font-size:2em}.katex .fontsize-ensurer.reset-size2.size8,.katex .sizing.reset-size2.size8{font-size:2.4em}.katex .fontsize-ensurer.reset-size2.size9,.katex .sizing.reset-size2.size9{font-size:2.88em}.katex .fontsize-ensurer.reset-size2.size10,.katex .sizing.reset-size2.size10{font-size:3.4566666667em}.katex .fontsize-ensurer.reset-size2.size11,.katex .sizing.reset-size2.size11{font-size:4.1466666667em}.katex .fontsize-ensurer.reset-size3.size1,.katex .sizing.reset-size3.size1{font-size:.7142857143em}.katex .fontsize-ensurer.reset-size3.size2,.katex .sizing.reset-size3.size2{font-size:.8571428571em}.katex .fontsize-ensurer.reset-size3.size3,.katex .sizing.reset-size3.size3{font-size:1em}.katex .fontsize-ensurer.reset-size3.size4,.katex .sizing.reset-size3.size4{font-size:1.1428571429em}.katex .fontsize-ensurer.reset-size3.size5,.katex .sizing.reset-size3.size5{font-size:1.2857142857em}.katex .fontsize-ensurer.reset-size3.size6,.katex .sizing.reset-size3.size6{font-size:1.4285714286em}.katex .fontsize-ensurer.reset-size3.size7,.katex .sizing.reset-size3.size7{font-size:1.7142857143em}.katex .fontsize-ensurer.reset-size3.size8,.katex .sizing.reset-size3.size8{font-size:2.0571428571em}.katex .fontsize-ensurer.reset-size3.size9,.katex .sizing.reset-size3.size9{font-size:2.4685714286em}.katex .fontsize-ensurer.reset-size3.size10,.katex .sizing.reset-size3.size10{font-size:2.9628571429em}.katex .fontsize-ensurer.reset-size3.size11,.katex .sizing.reset-size3.size11{font-size:3.5542857143em}.katex .fontsize-ensurer.reset-size4.size1,.katex .sizing.reset-size4.size1{font-size:.625em}.katex .fontsize-ensurer.reset-size4.size2,.katex .sizing.reset-size4.size2{font-size:.75em}.katex .fontsize-ensurer.reset-size4.size3,.katex .sizing.reset-size4.size3{font-size:.875em}.katex .fontsize-ensurer.reset-size4.size4,.katex .sizing.reset-size4.size4{font-size:1em}.katex .fontsize-ensurer.reset-size4.size5,.katex .sizing.reset-size4.size5{font-size:1.125em}.katex .fontsize-ensurer.reset-size4.size6,.katex .sizing.reset-size4.size6{font-size:1.25em}.katex .fontsize-ensurer.reset-size4.size7,.katex .sizing.reset-size4.size7{font-size:1.5em}.katex .fontsize-ensurer.reset-size4.size8,.katex .sizing.reset-size4.size8{font-size:1.8em}.katex .fontsize-ensurer.reset-size4.size9,.katex .sizing.reset-size4.size9{font-size:2.16em}.katex .fontsize-ensurer.reset-size4.size10,.katex .sizing.reset-size4.size10{font-size:2.5925em}.katex .fontsize-ensurer.reset-size4.size11,.katex .sizing.reset-size4.size11{font-size:3.11em}.katex .fontsize-ensurer.reset-size5.size1,.katex .sizing.reset-size5.size1{font-size:.5555555556em}.katex .fontsize-ensurer.reset-size5.size2,.katex .sizing.reset-size5.size2{font-size:.6666666667em}.katex .fontsize-ensurer.reset-size5.size3,.katex .sizing.reset-size5.size3{font-size:.7777777778em}.katex .fontsize-ensurer.reset-size5.size4,.katex .sizing.reset-size5.size4{font-size:.8888888889em}.katex .fontsize-ensurer.reset-size5.size5,.katex .sizing.reset-size5.size5{font-size:1em}.katex .fontsize-ensurer.reset-size5.size6,.katex .sizing.reset-size5.size6{font-size:1.1111111111em}.katex .fontsize-ensurer.reset-size5.size7,.katex .sizing.reset-size5.size7{font-size:1.3333333333em}.katex .fontsize-ensurer.reset-size5.size8,.katex .sizing.reset-size5.size8{font-size:1.6em}.katex .fontsize-ensurer.reset-size5.size9,.katex .sizing.reset-size5.size9{font-size:1.92em}.katex .fontsize-ensurer.reset-size5.size10,.katex .sizing.reset-size5.size10{font-size:2.3044444444em}.katex .fontsize-ensurer.reset-size5.size11,.katex .sizing.reset-size5.size11{font-size:2.7644444444em}.katex .fontsize-ensurer.reset-size6.size1,.katex .sizing.reset-size6.size1{font-size:.5em}.katex .fontsize-ensurer.reset-size6.size2,.katex .sizing.reset-size6.size2{font-size:.6em}.katex .fontsize-ensurer.reset-size6.size3,.katex .sizing.reset-size6.size3{font-size:.7em}.katex .fontsize-ensurer.reset-size6.size4,.katex .sizing.reset-size6.size4{font-size:.8em}.katex .fontsize-ensurer.reset-size6.size5,.katex .sizing.reset-size6.size5{font-size:.9em}.katex .fontsize-ensurer.reset-size6.size6,.katex .sizing.reset-size6.size6{font-size:1em}.katex .fontsize-ensurer.reset-size6.size7,.katex .sizing.reset-size6.size7{font-size:1.2em}.katex .fontsize-ensurer.reset-size6.size8,.katex .sizing.reset-size6.size8{font-size:1.44em}.katex .fontsize-ensurer.reset-size6.size9,.katex .sizing.reset-size6.size9{font-size:1.728em}.katex .fontsize-ensurer.reset-size6.size10,.katex .sizing.reset-size6.size10{font-size:2.074em}.katex .fontsize-ensurer.reset-size6.size11,.katex .sizing.reset-size6.size11{font-size:2.488em}.katex .fontsize-ensurer.reset-size7.size1,.katex .sizing.reset-size7.size1{font-size:.4166666667em}.katex .fontsize-ensurer.reset-size7.size2,.katex .sizing.reset-size7.size2{font-size:.5em}.katex .fontsize-ensurer.reset-size7.size3,.katex .sizing.reset-size7.size3{font-size:.5833333333em}.katex .fontsize-ensurer.reset-size7.size4,.katex .sizing.reset-size7.size4{font-size:.6666666667em}.katex .fontsize-ensurer.reset-size7.size5,.katex .sizing.reset-size7.size5{font-size:.75em}.katex .fontsize-ensurer.reset-size7.size6,.katex .sizing.reset-size7.size6{font-size:.8333333333em}.katex .fontsize-ensurer.reset-size7.size7,.katex .sizing.reset-size7.size7{font-size:1em}.katex .fontsize-ensurer.reset-size7.size8,.katex .sizing.reset-size7.size8{font-size:1.2em}.katex .fontsize-ensurer.reset-size7.size9,.katex .sizing.reset-size7.size9{font-size:1.44em}.katex .fontsize-ensurer.reset-size7.size10,.katex .sizing.reset-size7.size10{font-size:1.7283333333em}.katex .fontsize-ensurer.reset-size7.size11,.katex .sizing.reset-size7.size11{font-size:2.0733333333em}.katex .fontsize-ensurer.reset-size8.size1,.katex .sizing.reset-size8.size1{font-size:.3472222222em}.katex .fontsize-ensurer.reset-size8.size2,.katex .sizing.reset-size8.size2{font-size:.4166666667em}.katex .fontsize-ensurer.reset-size8.size3,.katex .sizing.reset-size8.size3{font-size:.4861111111em}.katex .fontsize-ensurer.reset-size8.size4,.katex .sizing.reset-size8.size4{font-size:.5555555556em}.katex .fontsize-ensurer.reset-size8.size5,.katex .sizing.reset-size8.size5{font-size:.625em}.katex .fontsize-ensurer.reset-size8.size6,.katex .sizing.reset-size8.size6{font-size:.6944444444em}.katex .fontsize-ensurer.reset-size8.size7,.katex .sizing.reset-size8.size7{font-size:.8333333333em}.katex .fontsize-ensurer.reset-size8.size8,.katex .sizing.reset-size8.size8{font-size:1em}.katex .fontsize-ensurer.reset-size8.size9,.katex .sizing.reset-size8.size9{font-size:1.2em}.katex .fontsize-ensurer.reset-size8.size10,.katex .sizing.reset-size8.size10{font-size:1.4402777778em}.katex .fontsize-ensurer.reset-size8.size11,.katex .sizing.reset-size8.size11{font-size:1.7277777778em}.katex .fontsize-ensurer.reset-size9.size1,.katex .sizing.reset-size9.size1{font-size:.2893518519em}.katex .fontsize-ensurer.reset-size9.size2,.katex .sizing.reset-size9.size2{font-size:.3472222222em}.katex .fontsize-ensurer.reset-size9.size3,.katex .sizing.reset-size9.size3{font-size:.4050925926em}.katex .fontsize-ensurer.reset-size9.size4,.katex .sizing.reset-size9.size4{font-size:.462962963em}.katex .fontsize-ensurer.reset-size9.size5,.katex .sizing.reset-size9.size5{font-size:.5208333333em}.katex .fontsize-ensurer.reset-size9.size6,.katex .sizing.reset-size9.size6{font-size:.5787037037em}.katex .fontsize-ensurer.reset-size9.size7,.katex .sizing.reset-size9.size7{font-size:.6944444444em}.katex .fontsize-ensurer.reset-size9.size8,.katex .sizing.reset-size9.size8{font-size:.8333333333em}.katex .fontsize-ensurer.reset-size9.size9,.katex .sizing.reset-size9.size9{font-size:1em}.katex .fontsize-ensurer.reset-size9.size10,.katex .sizing.reset-size9.size10{font-size:1.2002314815em}.katex .fontsize-ensurer.reset-size9.size11,.katex .sizing.reset-size9.size11{font-size:1.4398148148em}.katex .fontsize-ensurer.reset-size10.size1,.katex .sizing.reset-size10.size1{font-size:.2410800386em}.katex .fontsize-ensurer.reset-size10.size2,.katex .sizing.reset-size10.size2{font-size:.2892960463em}.katex .fontsize-ensurer.reset-size10.size3,.katex .sizing.reset-size10.size3{font-size:.337512054em}.katex .fontsize-ensurer.reset-size10.size4,.katex .sizing.reset-size10.size4{font-size:.3857280617em}.katex .fontsize-ensurer.reset-size10.size5,.katex .sizing.reset-size10.size5{font-size:.4339440694em}.katex .fontsize-ensurer.reset-size10.size6,.katex .sizing.reset-size10.size6{font-size:.4821600771em}.katex .fontsize-ensurer.reset-size10.size7,.katex .sizing.reset-size10.size7{font-size:.5785920926em}.katex .fontsize-ensurer.reset-size10.size8,.katex .sizing.reset-size10.size8{font-size:.6943105111em}.katex .fontsize-ensurer.reset-size10.size9,.katex .sizing.reset-size10.size9{font-size:.8331726133em}.katex .fontsize-ensurer.reset-size10.size10,.katex .sizing.reset-size10.size10{font-size:1em}.katex .fontsize-ensurer.reset-size10.size11,.katex .sizing.reset-size10.size11{font-size:1.1996142719em}.katex .fontsize-ensurer.reset-size11.size1,.katex .sizing.reset-size11.size1{font-size:.2009646302em}.katex .fontsize-ensurer.reset-size11.size2,.katex .sizing.reset-size11.size2{font-size:.2411575563em}.katex .fontsize-ensurer.reset-size11.size3,.katex .sizing.reset-size11.size3{font-size:.2813504823em}.katex .fontsize-ensurer.reset-size11.size4,.katex .sizing.reset-size11.size4{font-size:.3215434084em}.katex .fontsize-ensurer.reset-size11.size5,.katex .sizing.reset-size11.size5{font-size:.3617363344em}.katex .fontsize-ensurer.reset-size11.size6,.katex .sizing.reset-size11.size6{font-size:.4019292605em}.katex .fontsize-ensurer.reset-size11.size7,.katex .sizing.reset-size11.size7{font-size:.4823151125em}.katex .fontsize-ensurer.reset-size11.size8,.katex .sizing.reset-size11.size8{font-size:.578778135em}.katex .fontsize-ensurer.reset-size11.size9,.katex .sizing.reset-size11.size9{font-size:.6945337621em}.katex .fontsize-ensurer.reset-size11.size10,.katex .sizing.reset-size11.size10{font-size:.8336012862em}.katex .fontsize-ensurer.reset-size11.size11,.katex .sizing.reset-size11.size11{font-size:1em}.katex .delimsizing.size1{font-family:KaTeX_Size1}.katex .delimsizing.size2{font-family:KaTeX_Size2}.katex .delimsizing.size3{font-family:KaTeX_Size3}.katex .delimsizing.size4{font-family:KaTeX_Size4}.katex .delimsizing.mult .delim-size1>span{font-family:KaTeX_Size1}.katex .delimsizing.mult .delim-size4>span{font-family:KaTeX_Size4}.katex .nulldelimiter{display:inline-block;width:.12em}.katex .delimcenter,.katex .op-symbol{position:relative}.katex .op-symbol.small-op{font-family:KaTeX_Size1}.katex .op-symbol.large-op{font-family:KaTeX_Size2}.katex .accent>.vlist-t,.katex .op-limits>.vlist-t{text-align:center}.katex .accent .accent-body{position:relative}.katex .accent .accent-body:not(.accent-full){width:0}.katex .overlay{display:block}.katex .mtable .vertical-separator{display:inline-block;min-width:1px}.katex .mtable .arraycolsep{display:inline-block}.katex .mtable .col-align-c>.vlist-t{text-align:center}.katex .mtable .col-align-l>.vlist-t{text-align:left}.katex .mtable .col-align-r>.vlist-t{text-align:right}.katex .svg-align{text-align:left}.katex svg{fill:currentColor;stroke:currentColor;display:block;height:inherit;position:absolute;width:100%}.katex svg path{stroke:none}.katex svg{fill-rule:nonzero;fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1}.katex img{border-style:none;max-height:none;max-width:none;min-height:0;min-width:0}.katex .stretchy{display:block;overflow:hidden;position:relative;width:100%}.katex .stretchy:after,.katex .stretchy:before{content:""}.katex .hide-tail{overflow:hidden;position:relative;width:100%}.katex .halfarrow-left{left:0;overflow:hidden;position:absolute;width:50.2%}.katex .halfarrow-right{overflow:hidden;position:absolute;right:0;width:50.2%}.katex .brace-left{left:0;overflow:hidden;position:absolute;width:25.1%}.katex .brace-center{left:25%;overflow:hidden;position:absolute;width:50%}.katex .brace-right{overflow:hidden;position:absolute;right:0;width:25.1%}.katex .x-arrow-pad{padding:0 .5em}.katex .cd-arrow-pad{padding:0 .55556em 0 .27778em}.katex .mover,.katex .munder,.katex .x-arrow{text-align:center}.katex .boxpad{padding:0 .3em}.katex .fbox,.katex .fcolorbox{border:.04em solid;box-sizing:border-box}.katex .cancel-pad{padding:0 .2em}.katex .cancel-lap{margin-left:-.2em;margin-right:-.2em}.katex .sout{border-bottom-style:solid;border-bottom-width:.08em}.katex .angl{border-right:.049em solid;border-top:.049em solid;box-sizing:border-box;margin-right:.03889em}.katex .anglpad{padding:0 .03889em}.katex .eqn-num:before{content:"(" counter(katexEqnNo) ")";counter-increment:katexEqnNo}.katex .mml-eqn-num:before{content:"(" counter(mmlEqnNo) ")";counter-increment:mmlEqnNo}.katex .mtr-glue{width:50%}.katex .cd-vert-arrow{display:inline-block;position:relative}.katex .cd-label-left{display:inline-block;position:absolute;right:calc(50% + .3em);text-align:left}.katex .cd-label-right{display:inline-block;left:calc(50% + .3em);position:absolute;text-align:right}.katex-display{display:block;margin:1em 0;text-align:center}.katex-display>.katex{display:block;text-align:center;white-space:nowrap}.katex-display>.katex>.katex-html{display:block;position:relative}.katex-display>.katex>.katex-html>.tag{position:absolute;right:0}.katex-display.leqno>.katex>.katex-html>.tag{left:0;right:auto}.katex-display.fleqn>.katex{padding-left:2em;text-align:left}body{counter-reset:katexEqnNo mmlEqnNo} diff --git a/node_modules/katex/dist/katex.css b/node_modules/katex/dist/katex.css new file mode 100644 index 0000000..8961dfb --- /dev/null +++ b/node_modules/katex/dist/katex.css @@ -0,0 +1,1241 @@ +/* stylelint-disable font-family-no-missing-generic-family-keyword */ +@font-face { + font-family: "KaTeX_AMS"; + src: url(fonts/KaTeX_AMS-Regular.woff2) format("woff2"), url(fonts/KaTeX_AMS-Regular.woff) format("woff"), url(fonts/KaTeX_AMS-Regular.ttf) format("truetype"); + font-weight: normal; + font-style: normal; + font-display: block; +} +@font-face { + font-family: "KaTeX_Caligraphic"; + src: url(fonts/KaTeX_Caligraphic-Bold.woff2) format("woff2"), url(fonts/KaTeX_Caligraphic-Bold.woff) format("woff"), url(fonts/KaTeX_Caligraphic-Bold.ttf) format("truetype"); + font-weight: bold; + font-style: normal; + font-display: block; +} +@font-face { + font-family: "KaTeX_Caligraphic"; + src: url(fonts/KaTeX_Caligraphic-Regular.woff2) format("woff2"), url(fonts/KaTeX_Caligraphic-Regular.woff) format("woff"), url(fonts/KaTeX_Caligraphic-Regular.ttf) format("truetype"); + font-weight: normal; + font-style: normal; + font-display: block; +} +@font-face { + font-family: "KaTeX_Fraktur"; + src: url(fonts/KaTeX_Fraktur-Bold.woff2) format("woff2"), url(fonts/KaTeX_Fraktur-Bold.woff) format("woff"), url(fonts/KaTeX_Fraktur-Bold.ttf) format("truetype"); + font-weight: bold; + font-style: normal; + font-display: block; +} +@font-face { + font-family: "KaTeX_Fraktur"; + src: url(fonts/KaTeX_Fraktur-Regular.woff2) format("woff2"), url(fonts/KaTeX_Fraktur-Regular.woff) format("woff"), url(fonts/KaTeX_Fraktur-Regular.ttf) format("truetype"); + font-weight: normal; + font-style: normal; + font-display: block; +} +@font-face { + font-family: "KaTeX_Main"; + src: url(fonts/KaTeX_Main-Bold.woff2) format("woff2"), url(fonts/KaTeX_Main-Bold.woff) format("woff"), url(fonts/KaTeX_Main-Bold.ttf) format("truetype"); + font-weight: bold; + font-style: normal; + font-display: block; +} +@font-face { + font-family: "KaTeX_Main"; + src: url(fonts/KaTeX_Main-BoldItalic.woff2) format("woff2"), url(fonts/KaTeX_Main-BoldItalic.woff) format("woff"), url(fonts/KaTeX_Main-BoldItalic.ttf) format("truetype"); + font-weight: bold; + font-style: italic; + font-display: block; +} +@font-face { + font-family: "KaTeX_Main"; + src: url(fonts/KaTeX_Main-Italic.woff2) format("woff2"), url(fonts/KaTeX_Main-Italic.woff) format("woff"), url(fonts/KaTeX_Main-Italic.ttf) format("truetype"); + font-weight: normal; + font-style: italic; + font-display: block; +} +@font-face { + font-family: "KaTeX_Main"; + src: url(fonts/KaTeX_Main-Regular.woff2) format("woff2"), url(fonts/KaTeX_Main-Regular.woff) format("woff"), url(fonts/KaTeX_Main-Regular.ttf) format("truetype"); + font-weight: normal; + font-style: normal; + font-display: block; +} +@font-face { + font-family: "KaTeX_Math"; + src: url(fonts/KaTeX_Math-BoldItalic.woff2) format("woff2"), url(fonts/KaTeX_Math-BoldItalic.woff) format("woff"), url(fonts/KaTeX_Math-BoldItalic.ttf) format("truetype"); + font-weight: bold; + font-style: italic; + font-display: block; +} +@font-face { + font-family: "KaTeX_Math"; + src: url(fonts/KaTeX_Math-Italic.woff2) format("woff2"), url(fonts/KaTeX_Math-Italic.woff) format("woff"), url(fonts/KaTeX_Math-Italic.ttf) format("truetype"); + font-weight: normal; + font-style: italic; + font-display: block; +} +@font-face { + font-family: "KaTeX_SansSerif"; + src: url(fonts/KaTeX_SansSerif-Bold.woff2) format("woff2"), url(fonts/KaTeX_SansSerif-Bold.woff) format("woff"), url(fonts/KaTeX_SansSerif-Bold.ttf) format("truetype"); + font-weight: bold; + font-style: normal; + font-display: block; +} +@font-face { + font-family: "KaTeX_SansSerif"; + src: url(fonts/KaTeX_SansSerif-Italic.woff2) format("woff2"), url(fonts/KaTeX_SansSerif-Italic.woff) format("woff"), url(fonts/KaTeX_SansSerif-Italic.ttf) format("truetype"); + font-weight: normal; + font-style: italic; + font-display: block; +} +@font-face { + font-family: "KaTeX_SansSerif"; + src: url(fonts/KaTeX_SansSerif-Regular.woff2) format("woff2"), url(fonts/KaTeX_SansSerif-Regular.woff) format("woff"), url(fonts/KaTeX_SansSerif-Regular.ttf) format("truetype"); + font-weight: normal; + font-style: normal; + font-display: block; +} +@font-face { + font-family: "KaTeX_Script"; + src: url(fonts/KaTeX_Script-Regular.woff2) format("woff2"), url(fonts/KaTeX_Script-Regular.woff) format("woff"), url(fonts/KaTeX_Script-Regular.ttf) format("truetype"); + font-weight: normal; + font-style: normal; + font-display: block; +} +@font-face { + font-family: "KaTeX_Size1"; + src: url(fonts/KaTeX_Size1-Regular.woff2) format("woff2"), url(fonts/KaTeX_Size1-Regular.woff) format("woff"), url(fonts/KaTeX_Size1-Regular.ttf) format("truetype"); + font-weight: normal; + font-style: normal; + font-display: block; +} +@font-face { + font-family: "KaTeX_Size2"; + src: url(fonts/KaTeX_Size2-Regular.woff2) format("woff2"), url(fonts/KaTeX_Size2-Regular.woff) format("woff"), url(fonts/KaTeX_Size2-Regular.ttf) format("truetype"); + font-weight: normal; + font-style: normal; + font-display: block; +} +@font-face { + font-family: "KaTeX_Size3"; + src: url(fonts/KaTeX_Size3-Regular.woff2) format("woff2"), url(fonts/KaTeX_Size3-Regular.woff) format("woff"), url(fonts/KaTeX_Size3-Regular.ttf) format("truetype"); + font-weight: normal; + font-style: normal; + font-display: block; +} +@font-face { + font-family: "KaTeX_Size4"; + src: url(fonts/KaTeX_Size4-Regular.woff2) format("woff2"), url(fonts/KaTeX_Size4-Regular.woff) format("woff"), url(fonts/KaTeX_Size4-Regular.ttf) format("truetype"); + font-weight: normal; + font-style: normal; + font-display: block; +} +@font-face { + font-family: "KaTeX_Typewriter"; + src: url(fonts/KaTeX_Typewriter-Regular.woff2) format("woff2"), url(fonts/KaTeX_Typewriter-Regular.woff) format("woff"), url(fonts/KaTeX_Typewriter-Regular.ttf) format("truetype"); + font-weight: normal; + font-style: normal; + font-display: block; +} +/* stylelint-disable font-family-no-missing-generic-family-keyword */ +.katex { + font: normal 1.21em KaTeX_Main, Times New Roman, serif; + line-height: 1.2; + position: relative; + text-indent: 0; + text-rendering: auto; +} +.katex * { + -ms-high-contrast-adjust: none !important; +} +.katex * { + border-color: currentColor; +} +.katex .katex-version::after { + content: "0.17.0"; +} +.katex .katex-mathml { + /* Accessibility hack to only show to screen readers + Found at: http://a11yproject.com/posts/how-to-hide-content/ */ + position: absolute; + -webkit-clip-path: inset(50%); + clip-path: inset(50%); + padding: 0; + border: 0; + height: 1px; + width: 1px; + overflow: hidden; +} +.katex .katex-html { + /* \newline is an empty block at top level, between .base elements */ +} +.katex .katex-html > .newline { + display: block; +} +.katex .base { + position: relative; + display: inline-block; + white-space: nowrap; + width: -webkit-min-content; + width: -moz-min-content; + width: min-content; +} +.katex .strut { + display: inline-block; +} +.katex .textbf { + font-weight: bold; +} +.katex .textit { + font-style: italic; +} +.katex .textrm { + font-family: KaTeX_Main; +} +.katex .textsf { + font-family: KaTeX_SansSerif; +} +.katex .texttt { + font-family: KaTeX_Typewriter; +} +.katex .mathnormal { + font-family: KaTeX_Math; + font-style: italic; +} +.katex .mathit { + font-family: KaTeX_Main; + font-style: italic; +} +.katex .mathrm { + font-style: normal; +} +.katex .mathbf { + font-family: KaTeX_Main; + font-weight: bold; +} +.katex .boldsymbol { + font-family: KaTeX_Math; + font-weight: bold; + font-style: italic; +} +.katex .amsrm { + font-family: KaTeX_AMS; +} +.katex .mathbb, +.katex .textbb { + font-family: KaTeX_AMS; +} +.katex .mathcal { + font-family: KaTeX_Caligraphic; +} +.katex .mathfrak, +.katex .textfrak { + font-family: KaTeX_Fraktur; +} +.katex .mathboldfrak, +.katex .textboldfrak { + font-family: KaTeX_Fraktur; + font-weight: bold; +} +.katex .mathtt { + font-family: KaTeX_Typewriter; +} +.katex .mathscr, +.katex .textscr { + font-family: KaTeX_Script; +} +.katex .mathsf, +.katex .textsf { + font-family: KaTeX_SansSerif; +} +.katex .mathboldsf, +.katex .textboldsf { + font-family: KaTeX_SansSerif; + font-weight: bold; +} +.katex .mathsfit, +.katex .mathitsf, +.katex .textitsf { + font-family: KaTeX_SansSerif; + font-style: italic; +} +.katex .mainrm { + font-family: KaTeX_Main; + font-style: normal; +} +.katex .vlist-t { + display: inline-table; + table-layout: fixed; + border-collapse: collapse; +} +.katex .vlist-r { + display: table-row; +} +.katex .vlist { + display: table-cell; + vertical-align: bottom; + position: relative; +} +.katex .vlist > span { + display: block; + height: 0; + position: relative; +} +.katex .vlist > span > span { + display: inline-block; +} +.katex .vlist > span > .pstrut { + overflow: hidden; + width: 0; +} +.katex .vlist-t2 { + margin-right: -2px; +} +.katex .vlist-s { + display: table-cell; + vertical-align: bottom; + font-size: 1px; + width: 2px; + min-width: 2px; +} +.katex .vbox { + display: inline-flex; + flex-direction: column; + align-items: baseline; +} +.katex .hbox { + display: inline-flex; + flex-direction: row; + width: 100%; +} +.katex .thinbox { + display: inline-flex; + flex-direction: row; + width: 0; + max-width: 0; +} +.katex .msupsub { + text-align: left; +} +.katex .mfrac > span > span { + text-align: center; +} +.katex .mfrac .frac-line { + display: inline-block; + width: 100%; + border-bottom-style: solid; +} +.katex .mfrac .frac-line, +.katex .overline .overline-line, +.katex .underline .underline-line, +.katex .hline, +.katex .hdashline, +.katex .rule { + min-height: 1px; +} +.katex .mspace { + display: inline-block; +} +.katex .smash { + display: inline; + line-height: 0; +} +.katex .llap, +.katex .rlap, +.katex .clap { + width: 0; + position: relative; +} +.katex .llap > .inner, +.katex .rlap > .inner, +.katex .clap > .inner { + position: absolute; +} +.katex .llap > .fix, +.katex .rlap > .fix, +.katex .clap > .fix { + display: inline-block; +} +.katex .llap > .inner { + right: 0; +} +.katex .rlap > .inner, +.katex .clap > .inner { + left: 0; +} +.katex .clap > .inner > span { + margin-left: -50%; + margin-right: 50%; +} +.katex .rule { + display: inline-block; + border: solid 0; + position: relative; +} +.katex .overline .overline-line, +.katex .underline .underline-line, +.katex .hline { + display: inline-block; + width: 100%; + border-bottom-style: solid; +} +.katex .hdashline { + display: inline-block; + width: 100%; + border-bottom-style: dashed; +} +.katex .sqrt > .root { + /* These values are taken from the definition of `\r@@t`, + `\mkern 5mu` and `\mkern -10mu`. */ + /* stylelint-disable-next-line declaration-property-value-no-unknown */ + margin-left: 0.2777777778em; + /* stylelint-disable-next-line declaration-property-value-no-unknown */ + margin-right: -0.5555555556em; +} +.katex .sizing.reset-size1.size1, +.katex .fontsize-ensurer.reset-size1.size1 { + /* stylelint-disable-next-line */ + font-size: 1em; +} +.katex .sizing.reset-size1.size2, +.katex .fontsize-ensurer.reset-size1.size2 { + /* stylelint-disable-next-line */ + font-size: 1.2em; +} +.katex .sizing.reset-size1.size3, +.katex .fontsize-ensurer.reset-size1.size3 { + /* stylelint-disable-next-line */ + font-size: 1.4em; +} +.katex .sizing.reset-size1.size4, +.katex .fontsize-ensurer.reset-size1.size4 { + /* stylelint-disable-next-line */ + font-size: 1.6em; +} +.katex .sizing.reset-size1.size5, +.katex .fontsize-ensurer.reset-size1.size5 { + /* stylelint-disable-next-line */ + font-size: 1.8em; +} +.katex .sizing.reset-size1.size6, +.katex .fontsize-ensurer.reset-size1.size6 { + /* stylelint-disable-next-line */ + font-size: 2em; +} +.katex .sizing.reset-size1.size7, +.katex .fontsize-ensurer.reset-size1.size7 { + /* stylelint-disable-next-line */ + font-size: 2.4em; +} +.katex .sizing.reset-size1.size8, +.katex .fontsize-ensurer.reset-size1.size8 { + /* stylelint-disable-next-line */ + font-size: 2.88em; +} +.katex .sizing.reset-size1.size9, +.katex .fontsize-ensurer.reset-size1.size9 { + /* stylelint-disable-next-line */ + font-size: 3.456em; +} +.katex .sizing.reset-size1.size10, +.katex .fontsize-ensurer.reset-size1.size10 { + /* stylelint-disable-next-line */ + font-size: 4.148em; +} +.katex .sizing.reset-size1.size11, +.katex .fontsize-ensurer.reset-size1.size11 { + /* stylelint-disable-next-line */ + font-size: 4.976em; +} +.katex .sizing.reset-size2.size1, +.katex .fontsize-ensurer.reset-size2.size1 { + /* stylelint-disable-next-line */ + font-size: 0.8333333333em; +} +.katex .sizing.reset-size2.size2, +.katex .fontsize-ensurer.reset-size2.size2 { + /* stylelint-disable-next-line */ + font-size: 1em; +} +.katex .sizing.reset-size2.size3, +.katex .fontsize-ensurer.reset-size2.size3 { + /* stylelint-disable-next-line */ + font-size: 1.1666666667em; +} +.katex .sizing.reset-size2.size4, +.katex .fontsize-ensurer.reset-size2.size4 { + /* stylelint-disable-next-line */ + font-size: 1.3333333333em; +} +.katex .sizing.reset-size2.size5, +.katex .fontsize-ensurer.reset-size2.size5 { + /* stylelint-disable-next-line */ + font-size: 1.5em; +} +.katex .sizing.reset-size2.size6, +.katex .fontsize-ensurer.reset-size2.size6 { + /* stylelint-disable-next-line */ + font-size: 1.6666666667em; +} +.katex .sizing.reset-size2.size7, +.katex .fontsize-ensurer.reset-size2.size7 { + /* stylelint-disable-next-line */ + font-size: 2em; +} +.katex .sizing.reset-size2.size8, +.katex .fontsize-ensurer.reset-size2.size8 { + /* stylelint-disable-next-line */ + font-size: 2.4em; +} +.katex .sizing.reset-size2.size9, +.katex .fontsize-ensurer.reset-size2.size9 { + /* stylelint-disable-next-line */ + font-size: 2.88em; +} +.katex .sizing.reset-size2.size10, +.katex .fontsize-ensurer.reset-size2.size10 { + /* stylelint-disable-next-line */ + font-size: 3.4566666667em; +} +.katex .sizing.reset-size2.size11, +.katex .fontsize-ensurer.reset-size2.size11 { + /* stylelint-disable-next-line */ + font-size: 4.1466666667em; +} +.katex .sizing.reset-size3.size1, +.katex .fontsize-ensurer.reset-size3.size1 { + /* stylelint-disable-next-line */ + font-size: 0.7142857143em; +} +.katex .sizing.reset-size3.size2, +.katex .fontsize-ensurer.reset-size3.size2 { + /* stylelint-disable-next-line */ + font-size: 0.8571428571em; +} +.katex .sizing.reset-size3.size3, +.katex .fontsize-ensurer.reset-size3.size3 { + /* stylelint-disable-next-line */ + font-size: 1em; +} +.katex .sizing.reset-size3.size4, +.katex .fontsize-ensurer.reset-size3.size4 { + /* stylelint-disable-next-line */ + font-size: 1.1428571429em; +} +.katex .sizing.reset-size3.size5, +.katex .fontsize-ensurer.reset-size3.size5 { + /* stylelint-disable-next-line */ + font-size: 1.2857142857em; +} +.katex .sizing.reset-size3.size6, +.katex .fontsize-ensurer.reset-size3.size6 { + /* stylelint-disable-next-line */ + font-size: 1.4285714286em; +} +.katex .sizing.reset-size3.size7, +.katex .fontsize-ensurer.reset-size3.size7 { + /* stylelint-disable-next-line */ + font-size: 1.7142857143em; +} +.katex .sizing.reset-size3.size8, +.katex .fontsize-ensurer.reset-size3.size8 { + /* stylelint-disable-next-line */ + font-size: 2.0571428571em; +} +.katex .sizing.reset-size3.size9, +.katex .fontsize-ensurer.reset-size3.size9 { + /* stylelint-disable-next-line */ + font-size: 2.4685714286em; +} +.katex .sizing.reset-size3.size10, +.katex .fontsize-ensurer.reset-size3.size10 { + /* stylelint-disable-next-line */ + font-size: 2.9628571429em; +} +.katex .sizing.reset-size3.size11, +.katex .fontsize-ensurer.reset-size3.size11 { + /* stylelint-disable-next-line */ + font-size: 3.5542857143em; +} +.katex .sizing.reset-size4.size1, +.katex .fontsize-ensurer.reset-size4.size1 { + /* stylelint-disable-next-line */ + font-size: 0.625em; +} +.katex .sizing.reset-size4.size2, +.katex .fontsize-ensurer.reset-size4.size2 { + /* stylelint-disable-next-line */ + font-size: 0.75em; +} +.katex .sizing.reset-size4.size3, +.katex .fontsize-ensurer.reset-size4.size3 { + /* stylelint-disable-next-line */ + font-size: 0.875em; +} +.katex .sizing.reset-size4.size4, +.katex .fontsize-ensurer.reset-size4.size4 { + /* stylelint-disable-next-line */ + font-size: 1em; +} +.katex .sizing.reset-size4.size5, +.katex .fontsize-ensurer.reset-size4.size5 { + /* stylelint-disable-next-line */ + font-size: 1.125em; +} +.katex .sizing.reset-size4.size6, +.katex .fontsize-ensurer.reset-size4.size6 { + /* stylelint-disable-next-line */ + font-size: 1.25em; +} +.katex .sizing.reset-size4.size7, +.katex .fontsize-ensurer.reset-size4.size7 { + /* stylelint-disable-next-line */ + font-size: 1.5em; +} +.katex .sizing.reset-size4.size8, +.katex .fontsize-ensurer.reset-size4.size8 { + /* stylelint-disable-next-line */ + font-size: 1.8em; +} +.katex .sizing.reset-size4.size9, +.katex .fontsize-ensurer.reset-size4.size9 { + /* stylelint-disable-next-line */ + font-size: 2.16em; +} +.katex .sizing.reset-size4.size10, +.katex .fontsize-ensurer.reset-size4.size10 { + /* stylelint-disable-next-line */ + font-size: 2.5925em; +} +.katex .sizing.reset-size4.size11, +.katex .fontsize-ensurer.reset-size4.size11 { + /* stylelint-disable-next-line */ + font-size: 3.11em; +} +.katex .sizing.reset-size5.size1, +.katex .fontsize-ensurer.reset-size5.size1 { + /* stylelint-disable-next-line */ + font-size: 0.5555555556em; +} +.katex .sizing.reset-size5.size2, +.katex .fontsize-ensurer.reset-size5.size2 { + /* stylelint-disable-next-line */ + font-size: 0.6666666667em; +} +.katex .sizing.reset-size5.size3, +.katex .fontsize-ensurer.reset-size5.size3 { + /* stylelint-disable-next-line */ + font-size: 0.7777777778em; +} +.katex .sizing.reset-size5.size4, +.katex .fontsize-ensurer.reset-size5.size4 { + /* stylelint-disable-next-line */ + font-size: 0.8888888889em; +} +.katex .sizing.reset-size5.size5, +.katex .fontsize-ensurer.reset-size5.size5 { + /* stylelint-disable-next-line */ + font-size: 1em; +} +.katex .sizing.reset-size5.size6, +.katex .fontsize-ensurer.reset-size5.size6 { + /* stylelint-disable-next-line */ + font-size: 1.1111111111em; +} +.katex .sizing.reset-size5.size7, +.katex .fontsize-ensurer.reset-size5.size7 { + /* stylelint-disable-next-line */ + font-size: 1.3333333333em; +} +.katex .sizing.reset-size5.size8, +.katex .fontsize-ensurer.reset-size5.size8 { + /* stylelint-disable-next-line */ + font-size: 1.6em; +} +.katex .sizing.reset-size5.size9, +.katex .fontsize-ensurer.reset-size5.size9 { + /* stylelint-disable-next-line */ + font-size: 1.92em; +} +.katex .sizing.reset-size5.size10, +.katex .fontsize-ensurer.reset-size5.size10 { + /* stylelint-disable-next-line */ + font-size: 2.3044444444em; +} +.katex .sizing.reset-size5.size11, +.katex .fontsize-ensurer.reset-size5.size11 { + /* stylelint-disable-next-line */ + font-size: 2.7644444444em; +} +.katex .sizing.reset-size6.size1, +.katex .fontsize-ensurer.reset-size6.size1 { + /* stylelint-disable-next-line */ + font-size: 0.5em; +} +.katex .sizing.reset-size6.size2, +.katex .fontsize-ensurer.reset-size6.size2 { + /* stylelint-disable-next-line */ + font-size: 0.6em; +} +.katex .sizing.reset-size6.size3, +.katex .fontsize-ensurer.reset-size6.size3 { + /* stylelint-disable-next-line */ + font-size: 0.7em; +} +.katex .sizing.reset-size6.size4, +.katex .fontsize-ensurer.reset-size6.size4 { + /* stylelint-disable-next-line */ + font-size: 0.8em; +} +.katex .sizing.reset-size6.size5, +.katex .fontsize-ensurer.reset-size6.size5 { + /* stylelint-disable-next-line */ + font-size: 0.9em; +} +.katex .sizing.reset-size6.size6, +.katex .fontsize-ensurer.reset-size6.size6 { + /* stylelint-disable-next-line */ + font-size: 1em; +} +.katex .sizing.reset-size6.size7, +.katex .fontsize-ensurer.reset-size6.size7 { + /* stylelint-disable-next-line */ + font-size: 1.2em; +} +.katex .sizing.reset-size6.size8, +.katex .fontsize-ensurer.reset-size6.size8 { + /* stylelint-disable-next-line */ + font-size: 1.44em; +} +.katex .sizing.reset-size6.size9, +.katex .fontsize-ensurer.reset-size6.size9 { + /* stylelint-disable-next-line */ + font-size: 1.728em; +} +.katex .sizing.reset-size6.size10, +.katex .fontsize-ensurer.reset-size6.size10 { + /* stylelint-disable-next-line */ + font-size: 2.074em; +} +.katex .sizing.reset-size6.size11, +.katex .fontsize-ensurer.reset-size6.size11 { + /* stylelint-disable-next-line */ + font-size: 2.488em; +} +.katex .sizing.reset-size7.size1, +.katex .fontsize-ensurer.reset-size7.size1 { + /* stylelint-disable-next-line */ + font-size: 0.4166666667em; +} +.katex .sizing.reset-size7.size2, +.katex .fontsize-ensurer.reset-size7.size2 { + /* stylelint-disable-next-line */ + font-size: 0.5em; +} +.katex .sizing.reset-size7.size3, +.katex .fontsize-ensurer.reset-size7.size3 { + /* stylelint-disable-next-line */ + font-size: 0.5833333333em; +} +.katex .sizing.reset-size7.size4, +.katex .fontsize-ensurer.reset-size7.size4 { + /* stylelint-disable-next-line */ + font-size: 0.6666666667em; +} +.katex .sizing.reset-size7.size5, +.katex .fontsize-ensurer.reset-size7.size5 { + /* stylelint-disable-next-line */ + font-size: 0.75em; +} +.katex .sizing.reset-size7.size6, +.katex .fontsize-ensurer.reset-size7.size6 { + /* stylelint-disable-next-line */ + font-size: 0.8333333333em; +} +.katex .sizing.reset-size7.size7, +.katex .fontsize-ensurer.reset-size7.size7 { + /* stylelint-disable-next-line */ + font-size: 1em; +} +.katex .sizing.reset-size7.size8, +.katex .fontsize-ensurer.reset-size7.size8 { + /* stylelint-disable-next-line */ + font-size: 1.2em; +} +.katex .sizing.reset-size7.size9, +.katex .fontsize-ensurer.reset-size7.size9 { + /* stylelint-disable-next-line */ + font-size: 1.44em; +} +.katex .sizing.reset-size7.size10, +.katex .fontsize-ensurer.reset-size7.size10 { + /* stylelint-disable-next-line */ + font-size: 1.7283333333em; +} +.katex .sizing.reset-size7.size11, +.katex .fontsize-ensurer.reset-size7.size11 { + /* stylelint-disable-next-line */ + font-size: 2.0733333333em; +} +.katex .sizing.reset-size8.size1, +.katex .fontsize-ensurer.reset-size8.size1 { + /* stylelint-disable-next-line */ + font-size: 0.3472222222em; +} +.katex .sizing.reset-size8.size2, +.katex .fontsize-ensurer.reset-size8.size2 { + /* stylelint-disable-next-line */ + font-size: 0.4166666667em; +} +.katex .sizing.reset-size8.size3, +.katex .fontsize-ensurer.reset-size8.size3 { + /* stylelint-disable-next-line */ + font-size: 0.4861111111em; +} +.katex .sizing.reset-size8.size4, +.katex .fontsize-ensurer.reset-size8.size4 { + /* stylelint-disable-next-line */ + font-size: 0.5555555556em; +} +.katex .sizing.reset-size8.size5, +.katex .fontsize-ensurer.reset-size8.size5 { + /* stylelint-disable-next-line */ + font-size: 0.625em; +} +.katex .sizing.reset-size8.size6, +.katex .fontsize-ensurer.reset-size8.size6 { + /* stylelint-disable-next-line */ + font-size: 0.6944444444em; +} +.katex .sizing.reset-size8.size7, +.katex .fontsize-ensurer.reset-size8.size7 { + /* stylelint-disable-next-line */ + font-size: 0.8333333333em; +} +.katex .sizing.reset-size8.size8, +.katex .fontsize-ensurer.reset-size8.size8 { + /* stylelint-disable-next-line */ + font-size: 1em; +} +.katex .sizing.reset-size8.size9, +.katex .fontsize-ensurer.reset-size8.size9 { + /* stylelint-disable-next-line */ + font-size: 1.2em; +} +.katex .sizing.reset-size8.size10, +.katex .fontsize-ensurer.reset-size8.size10 { + /* stylelint-disable-next-line */ + font-size: 1.4402777778em; +} +.katex .sizing.reset-size8.size11, +.katex .fontsize-ensurer.reset-size8.size11 { + /* stylelint-disable-next-line */ + font-size: 1.7277777778em; +} +.katex .sizing.reset-size9.size1, +.katex .fontsize-ensurer.reset-size9.size1 { + /* stylelint-disable-next-line */ + font-size: 0.2893518519em; +} +.katex .sizing.reset-size9.size2, +.katex .fontsize-ensurer.reset-size9.size2 { + /* stylelint-disable-next-line */ + font-size: 0.3472222222em; +} +.katex .sizing.reset-size9.size3, +.katex .fontsize-ensurer.reset-size9.size3 { + /* stylelint-disable-next-line */ + font-size: 0.4050925926em; +} +.katex .sizing.reset-size9.size4, +.katex .fontsize-ensurer.reset-size9.size4 { + /* stylelint-disable-next-line */ + font-size: 0.462962963em; +} +.katex .sizing.reset-size9.size5, +.katex .fontsize-ensurer.reset-size9.size5 { + /* stylelint-disable-next-line */ + font-size: 0.5208333333em; +} +.katex .sizing.reset-size9.size6, +.katex .fontsize-ensurer.reset-size9.size6 { + /* stylelint-disable-next-line */ + font-size: 0.5787037037em; +} +.katex .sizing.reset-size9.size7, +.katex .fontsize-ensurer.reset-size9.size7 { + /* stylelint-disable-next-line */ + font-size: 0.6944444444em; +} +.katex .sizing.reset-size9.size8, +.katex .fontsize-ensurer.reset-size9.size8 { + /* stylelint-disable-next-line */ + font-size: 0.8333333333em; +} +.katex .sizing.reset-size9.size9, +.katex .fontsize-ensurer.reset-size9.size9 { + /* stylelint-disable-next-line */ + font-size: 1em; +} +.katex .sizing.reset-size9.size10, +.katex .fontsize-ensurer.reset-size9.size10 { + /* stylelint-disable-next-line */ + font-size: 1.2002314815em; +} +.katex .sizing.reset-size9.size11, +.katex .fontsize-ensurer.reset-size9.size11 { + /* stylelint-disable-next-line */ + font-size: 1.4398148148em; +} +.katex .sizing.reset-size10.size1, +.katex .fontsize-ensurer.reset-size10.size1 { + /* stylelint-disable-next-line */ + font-size: 0.2410800386em; +} +.katex .sizing.reset-size10.size2, +.katex .fontsize-ensurer.reset-size10.size2 { + /* stylelint-disable-next-line */ + font-size: 0.2892960463em; +} +.katex .sizing.reset-size10.size3, +.katex .fontsize-ensurer.reset-size10.size3 { + /* stylelint-disable-next-line */ + font-size: 0.337512054em; +} +.katex .sizing.reset-size10.size4, +.katex .fontsize-ensurer.reset-size10.size4 { + /* stylelint-disable-next-line */ + font-size: 0.3857280617em; +} +.katex .sizing.reset-size10.size5, +.katex .fontsize-ensurer.reset-size10.size5 { + /* stylelint-disable-next-line */ + font-size: 0.4339440694em; +} +.katex .sizing.reset-size10.size6, +.katex .fontsize-ensurer.reset-size10.size6 { + /* stylelint-disable-next-line */ + font-size: 0.4821600771em; +} +.katex .sizing.reset-size10.size7, +.katex .fontsize-ensurer.reset-size10.size7 { + /* stylelint-disable-next-line */ + font-size: 0.5785920926em; +} +.katex .sizing.reset-size10.size8, +.katex .fontsize-ensurer.reset-size10.size8 { + /* stylelint-disable-next-line */ + font-size: 0.6943105111em; +} +.katex .sizing.reset-size10.size9, +.katex .fontsize-ensurer.reset-size10.size9 { + /* stylelint-disable-next-line */ + font-size: 0.8331726133em; +} +.katex .sizing.reset-size10.size10, +.katex .fontsize-ensurer.reset-size10.size10 { + /* stylelint-disable-next-line */ + font-size: 1em; +} +.katex .sizing.reset-size10.size11, +.katex .fontsize-ensurer.reset-size10.size11 { + /* stylelint-disable-next-line */ + font-size: 1.1996142719em; +} +.katex .sizing.reset-size11.size1, +.katex .fontsize-ensurer.reset-size11.size1 { + /* stylelint-disable-next-line */ + font-size: 0.2009646302em; +} +.katex .sizing.reset-size11.size2, +.katex .fontsize-ensurer.reset-size11.size2 { + /* stylelint-disable-next-line */ + font-size: 0.2411575563em; +} +.katex .sizing.reset-size11.size3, +.katex .fontsize-ensurer.reset-size11.size3 { + /* stylelint-disable-next-line */ + font-size: 0.2813504823em; +} +.katex .sizing.reset-size11.size4, +.katex .fontsize-ensurer.reset-size11.size4 { + /* stylelint-disable-next-line */ + font-size: 0.3215434084em; +} +.katex .sizing.reset-size11.size5, +.katex .fontsize-ensurer.reset-size11.size5 { + /* stylelint-disable-next-line */ + font-size: 0.3617363344em; +} +.katex .sizing.reset-size11.size6, +.katex .fontsize-ensurer.reset-size11.size6 { + /* stylelint-disable-next-line */ + font-size: 0.4019292605em; +} +.katex .sizing.reset-size11.size7, +.katex .fontsize-ensurer.reset-size11.size7 { + /* stylelint-disable-next-line */ + font-size: 0.4823151125em; +} +.katex .sizing.reset-size11.size8, +.katex .fontsize-ensurer.reset-size11.size8 { + /* stylelint-disable-next-line */ + font-size: 0.578778135em; +} +.katex .sizing.reset-size11.size9, +.katex .fontsize-ensurer.reset-size11.size9 { + /* stylelint-disable-next-line */ + font-size: 0.6945337621em; +} +.katex .sizing.reset-size11.size10, +.katex .fontsize-ensurer.reset-size11.size10 { + /* stylelint-disable-next-line */ + font-size: 0.8336012862em; +} +.katex .sizing.reset-size11.size11, +.katex .fontsize-ensurer.reset-size11.size11 { + /* stylelint-disable-next-line */ + font-size: 1em; +} +.katex .delimsizing.size1 { + font-family: KaTeX_Size1; +} +.katex .delimsizing.size2 { + font-family: KaTeX_Size2; +} +.katex .delimsizing.size3 { + font-family: KaTeX_Size3; +} +.katex .delimsizing.size4 { + font-family: KaTeX_Size4; +} +.katex .delimsizing.mult .delim-size1 > span { + font-family: KaTeX_Size1; +} +.katex .delimsizing.mult .delim-size4 > span { + font-family: KaTeX_Size4; +} +.katex .nulldelimiter { + display: inline-block; + width: 0.12em; +} +.katex .delimcenter { + position: relative; +} +.katex .op-symbol { + position: relative; +} +.katex .op-symbol.small-op { + font-family: KaTeX_Size1; +} +.katex .op-symbol.large-op { + font-family: KaTeX_Size2; +} +.katex .op-limits > .vlist-t { + text-align: center; +} +.katex .accent > .vlist-t { + text-align: center; +} +.katex .accent .accent-body { + position: relative; +} +.katex .accent .accent-body:not(.accent-full) { + width: 0; +} +.katex .overlay { + display: block; +} +.katex .mtable .vertical-separator { + display: inline-block; + min-width: 1px; +} +.katex .mtable .arraycolsep { + display: inline-block; +} +.katex .mtable .col-align-c > .vlist-t { + text-align: center; +} +.katex .mtable .col-align-l > .vlist-t { + text-align: left; +} +.katex .mtable .col-align-r > .vlist-t { + text-align: right; +} +.katex .svg-align { + text-align: left; +} +.katex svg { + display: block; + position: absolute; + width: 100%; + height: inherit; + fill: currentColor; + stroke: currentColor; +} +.katex svg path { + stroke: none; +} +.katex svg { + fill-rule: nonzero; + fill-opacity: 1; + stroke-width: 1; + stroke-linecap: butt; + stroke-linejoin: miter; + stroke-miterlimit: 4; + stroke-dasharray: none; + stroke-dashoffset: 0; + stroke-opacity: 1; +} +.katex img { + border-style: none; + min-width: 0; + min-height: 0; + max-width: none; + max-height: none; +} +.katex .stretchy { + width: 100%; + display: block; + position: relative; + overflow: hidden; +} +.katex .stretchy::before, .katex .stretchy::after { + content: ""; +} +.katex .hide-tail { + width: 100%; + position: relative; + overflow: hidden; +} +.katex .halfarrow-left { + position: absolute; + left: 0; + width: 50.2%; + overflow: hidden; +} +.katex .halfarrow-right { + position: absolute; + right: 0; + width: 50.2%; + overflow: hidden; +} +.katex .brace-left { + position: absolute; + left: 0; + width: 25.1%; + overflow: hidden; +} +.katex .brace-center { + position: absolute; + left: 25%; + width: 50%; + overflow: hidden; +} +.katex .brace-right { + position: absolute; + right: 0; + width: 25.1%; + overflow: hidden; +} +.katex .x-arrow-pad { + padding: 0 0.5em; +} +.katex .cd-arrow-pad { + padding: 0 0.55556em 0 0.27778em; +} +.katex .x-arrow, +.katex .mover, +.katex .munder { + text-align: center; +} +.katex .boxpad { + padding: 0 0.3em; +} +.katex .fbox, +.katex .fcolorbox { + box-sizing: border-box; + border: 0.04em solid; +} +.katex .cancel-pad { + padding: 0 0.2em; +} +.katex .cancel-lap { + margin-left: -0.2em; + margin-right: -0.2em; +} +.katex .sout { + border-bottom-style: solid; + border-bottom-width: 0.08em; +} +.katex .angl { + box-sizing: border-box; + border-top: 0.049em solid; + border-right: 0.049em solid; + margin-right: 0.03889em; +} +.katex .anglpad { + padding: 0 0.03889em; +} +.katex .eqn-num::before { + counter-increment: katexEqnNo; + content: "(" counter(katexEqnNo) ")"; +} +.katex .mml-eqn-num::before { + counter-increment: mmlEqnNo; + content: "(" counter(mmlEqnNo) ")"; +} +.katex .mtr-glue { + width: 50%; +} +.katex .cd-vert-arrow { + display: inline-block; + position: relative; +} +.katex .cd-label-left { + display: inline-block; + position: absolute; + right: calc(50% + 0.3em); + text-align: left; +} +.katex .cd-label-right { + display: inline-block; + position: absolute; + left: calc(50% + 0.3em); + text-align: right; +} + +.katex-display { + display: block; + margin: 1em 0; + text-align: center; +} +.katex-display > .katex { + display: block; + text-align: center; + white-space: nowrap; +} +.katex-display > .katex > .katex-html { + display: block; + position: relative; +} +.katex-display > .katex > .katex-html > .tag { + position: absolute; + right: 0; +} + +.katex-display.leqno > .katex > .katex-html > .tag { + left: 0; + right: auto; +} + +.katex-display.fleqn > .katex { + text-align: left; + padding-left: 2em; +} + +body { + counter-reset: katexEqnNo mmlEqnNo; +} diff --git a/node_modules/katex/dist/katex.js b/node_modules/katex/dist/katex.js new file mode 100644 index 0000000..6e17a61 --- /dev/null +++ b/node_modules/katex/dist/katex.js @@ -0,0 +1,17831 @@ +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(); + else if(typeof define === 'function' && define.amd) + define([], factory); + else if(typeof exports === 'object') + exports["katex"] = factory(); + else + root["katex"] = factory(); +})((typeof self !== 'undefined' ? self : this), function() { +return /******/ (function() { // webpackBootstrap +/******/ "use strict"; +/******/ // The require scope +/******/ var __webpack_require__ = {}; +/******/ +/************************************************************************/ +/******/ /* webpack/runtime/define property getters */ +/******/ !function() { +/******/ // define getter functions for harmony exports +/******/ __webpack_require__.d = function(exports, definition) { +/******/ for(var key in definition) { +/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { +/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); +/******/ } +/******/ } +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/hasOwnProperty shorthand */ +/******/ !function() { +/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } +/******/ }(); +/******/ +/************************************************************************/ +var __webpack_exports__ = {}; + +// EXPORTS +__webpack_require__.d(__webpack_exports__, { + "default": function() { return /* binding */ katex_webpack; } +}); + +;// ./src/ParseError.ts +/** + * This is the ParseError class, which is the main error thrown by KaTeX + * functions when something has gone wrong. This is used to distinguish internal + * errors from errors in the expression that the user provided. + * + * If possible, a caller should provide a Token or ParseNode with information + * about where in the source string the problem occurred. + */ +class ParseError extends Error { + // The underlying error message without any context added. + + constructor(message, + // The error message + token) { + let error = "KaTeX parse error: " + message; + let start; + let end; + const loc = token && token.loc; + if (loc && loc.start <= loc.end) { + // If we have the input and a position, make the error a bit fancier + + // Get the input + const input = loc.lexer.input; + + // Prepend some information + start = loc.start; + end = loc.end; + if (start === input.length) { + error += " at end of input: "; + } else { + error += " at position " + (start + 1) + ": "; + } + + // Underline token in question using combining underscores + const underlined = input.slice(start, end).replace(/[^]/g, "$&\u0332"); + + // Extract some context from the input and add it to the error + let left; + if (start > 15) { + left = "…" + input.slice(start - 15, start); + } else { + left = input.slice(0, start); + } + let right; + if (end + 15 < input.length) { + right = input.slice(end, end + 15) + "…"; + } else { + right = input.slice(end); + } + error += left + underlined + right; + } + super(error); + this.name = "ParseError"; + this.position = void 0; + // Error start position based on passed-in Token or ParseNode. + this.length = void 0; + // Length of affected text based on passed-in Token or ParseNode. + this.rawMessage = void 0; + Object.setPrototypeOf(this, ParseError.prototype); + this.position = start; + if (start != null && end != null) { + this.length = end - start; + } + this.rawMessage = message; + } +} +/* harmony default export */ var src_ParseError = (ParseError); +;// ./src/utils.ts +/** + * This file contains a list of utility functions which are useful in other + * files. + */ + +// hyphenate and escape adapted from Facebook's React under Apache 2 license +const uppercase = /([A-Z])/g; +const hyphenate = str => str.replace(uppercase, "-$1").toLowerCase(); +const ESCAPE_LOOKUP = { + "&": "&", + ">": ">", + "<": "<", + "\"": """, + "'": "'" +}; +const ESCAPE_REGEX = /[&><"']/g; + +/** + * Escapes text to prevent scripting attacks. + */ +const utils_escape = text => String(text).replace(ESCAPE_REGEX, match => ESCAPE_LOOKUP[match]); + +/** + * Sometimes we want to pull out the innermost element of a group. In most + * cases, this will just be the group itself, but when ordgroups and colors have + * a single element, we want to pull that out. + */ +const getBaseElem = group => { + if (group.type === "ordgroup") { + if (group.body.length === 1) { + return getBaseElem(group.body[0]); + } else { + return group; + } + } else if (group.type === "color") { + if (group.body.length === 1) { + return getBaseElem(group.body[0]); + } else { + return group; + } + } else if (group.type === "font") { + return getBaseElem(group.body); + } else { + return group; + } +}; +const characterNodesTypes = new Set(["mathord", "textord", "atom"]); + +/** + * TeXbook algorithms often reference "character boxes", which are simply groups + * with a single character in them. To decide if something is a character box, + * we find its innermost group, and see if it is a single character. + */ +const isCharacterBox = group => characterNodesTypes.has(getBaseElem(group).type); + +/** + * Return the protocol of a URL, or "_relative" if the URL does not specify a + * protocol (and thus is relative), or `null` if URL has invalid protocol + * (so should be outright rejected). + */ +const protocolFromUrl = url => { + // Check for possible leading protocol. + // https://url.spec.whatwg.org/#url-parsing strips leading whitespace + // (U+20) or C0 control (U+00-U+1F) characters. + const protocol = /^[\x00-\x20]*([^\\/#?]*?)(:|�*58|�*3a|&colon)/i.exec(url); + if (!protocol) { + return "_relative"; + } + // Reject weird colons + if (protocol[2] !== ":") { + return null; + } + // Reject invalid characters in scheme according to + // https://datatracker.ietf.org/doc/html/rfc3986#section-3.1 + if (!/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(protocol[1])) { + return null; + } + // Lowercase the protocol + return protocol[1].toLowerCase(); +}; +;// ./src/Settings.ts +/* eslint no-console:0 */ +/** + * This is a module for storing settings passed into KaTeX. It correctly handles + * default settings. + */ + + + + +/** + * Union of all values that appear as schema defaults, cliDefaults, or + * cliProcessor return values. StrictFunction / TrustFunction are + * option-value types, not default/schema values, so they are excluded. + */ + +// TODO: automatically generate documentation +// TODO: check all properties on Settings exist +// TODO: check the type of a property on Settings matches +const SETTINGS_SCHEMA = { + displayMode: { + type: "boolean", + description: "Render math in display mode, which puts the math in " + "display style (so \\int and \\sum are large, for example), and " + "centers the math on the page on its own line.", + cli: "-d, --display-mode" + }, + output: { + type: { + enum: ["htmlAndMathml", "html", "mathml"] + }, + description: "Determines the markup language of the output.", + cli: "-F, --format " + }, + leqno: { + type: "boolean", + description: "Render display math in leqno style (left-justified tags)." + }, + fleqn: { + type: "boolean", + description: "Render display math flush left." + }, + throwOnError: { + type: "boolean", + default: true, + cli: "-t, --no-throw-on-error", + cliDescription: "Render errors (in the color given by --error-color) ins" + "tead of throwing a ParseError exception when encountering an error." + }, + errorColor: { + type: "string", + default: "#cc0000", + cli: "-c, --error-color ", + cliDescription: "A color string given in the format 'rgb' or 'rrggbb' " + "(no #). This option determines the color of errors rendered by the " + "-t option.", + cliProcessor: color => "#" + color + }, + macros: { + type: "object", + cli: "-m, --macro ", + cliDescription: "Define custom macro of the form '\\foo:expansion' (use " + "multiple -m arguments for multiple macros).", + cliDefault: [], + cliProcessor: (def, defs) => { + defs.push(def); + return defs; + } + }, + minRuleThickness: { + type: "number", + description: "Specifies a minimum thickness, in ems, for fraction lines," + " `\\sqrt` top lines, `{array}` vertical lines, `\\hline`, " + "`\\hdashline`, `\\underline`, `\\overline`, and the borders of " + "`\\fbox`, `\\boxed`, and `\\fcolorbox`.", + processor: t => Math.max(0, t), + cli: "--min-rule-thickness ", + cliProcessor: parseFloat + }, + colorIsTextColor: { + type: "boolean", + description: "Makes \\color behave like LaTeX's 2-argument \\textcolor, " + "instead of LaTeX's one-argument \\color mode change.", + cli: "-b, --color-is-text-color" + }, + strict: { + type: [{ + enum: ["warn", "ignore", "error"] + }, "boolean", "function"], + description: "Turn on strict / LaTeX faithfulness mode, which throws an " + "error if the input uses features that are not supported by LaTeX.", + cli: "-S, --strict", + cliDefault: false + }, + trust: { + type: ["boolean", "function"], + description: "Trust the input, enabling all HTML features such as \\url.", + cli: "-T, --trust" + }, + maxSize: { + type: "number", + default: Infinity, + description: "If non-zero, all user-specified sizes, e.g. in " + "\\rule{500em}{500em}, will be capped to maxSize ems. Otherwise, " + "elements and spaces can be arbitrarily large", + processor: s => Math.max(0, s), + cli: "-s, --max-size ", + cliProcessor: parseInt + }, + maxExpand: { + type: "number", + default: 1000, + description: "Limit the number of macro expansions to the specified " + "number, to prevent e.g. infinite macro loops. If set to Infinity, " + "the macro expander will try to fully expand as in LaTeX.", + processor: n => Math.max(0, n), + cli: "-e, --max-expand ", + cliProcessor: n => n === "Infinity" ? Infinity : parseInt(n) + }, + globalGroup: { + type: "boolean", + cli: false + } +}; +function getImplicitDefault(type) { + if (typeof type !== 'string') { + return type.enum[0]; + } + switch (type) { + case 'boolean': + return false; + case 'string': + return ''; + case 'number': + return 0; + case 'object': + return {}; + default: + throw new Error("Unexpected schema type; settings must declare an explicit default."); + } +} +function getDefaultValue(schema) { + if (schema.default !== undefined) { + return schema.default; + } + const type = Array.isArray(schema.type) ? schema.type[0] : schema.type; + return getImplicitDefault(type); +} +function applySetting(target, prop, options, schema) { + const optionValue = options[prop]; + target[prop] = optionValue !== undefined ? schema.processor ? schema.processor(optionValue) : optionValue : getDefaultValue(schema); +} + +/** + * The main Settings object + * + * The current options stored are: + * - displayMode: Whether the expression should be typeset as inline math + * (false, the default), meaning that the math starts in + * \textstyle and is placed in an inline-block); or as display + * math (true), meaning that the math starts in \displaystyle + * and is placed in a block with vertical margin. + */ +class Settings { + constructor(options) { + if (options === void 0) { + options = {}; + } + this.displayMode = void 0; + this.output = void 0; + this.leqno = void 0; + this.fleqn = void 0; + this.throwOnError = void 0; + this.errorColor = void 0; + this.macros = void 0; + this.minRuleThickness = void 0; + this.colorIsTextColor = void 0; + this.strict = void 0; + this.trust = void 0; + this.maxSize = void 0; + this.maxExpand = void 0; + this.globalGroup = void 0; + // allow null options + options = options || {}; + for (const prop of Object.keys(SETTINGS_SCHEMA)) { + const schema = SETTINGS_SCHEMA[prop]; + if (schema) { + // TODO: validate options + applySetting(this, prop, options, schema); + } + } + } + + /** + * Report nonstrict (non-LaTeX-compatible) input. + * Can safely not be called if `this.strict` is false in JavaScript. + */ + reportNonstrict(errorCode, errorMsg, token) { + let strict = this.strict; + if (typeof strict === "function") { + // Allow return value of strict function to be boolean or string + // (or null/undefined, meaning no further processing). + strict = strict(errorCode, errorMsg, token); + } + if (!strict || strict === "ignore") { + return; + } else if (strict === true || strict === "error") { + throw new src_ParseError("LaTeX-incompatible input and strict mode is set to 'error': " + (errorMsg + " [" + errorCode + "]"), token); + } else if (strict === "warn") { + typeof console !== "undefined" && console.warn("LaTeX-incompatible input and strict mode is set to 'warn': " + (errorMsg + " [" + errorCode + "]")); + } else { + // won't happen in type-safe code + typeof console !== "undefined" && console.warn("LaTeX-incompatible input and strict mode is set to " + ("unrecognized '" + strict + "': " + errorMsg + " [" + errorCode + "]")); + } + } + + /** + * Check whether to apply strict (LaTeX-adhering) behavior for unusual + * input (like `\\`). Unlike `nonstrict`, will not throw an error; + * instead, "error" translates to a return value of `true`, while "ignore" + * translates to a return value of `false`. May still print a warning: + * "warn" prints a warning and returns `false`. + * This is for the second category of `errorCode`s listed in the README. + */ + useStrictBehavior(errorCode, errorMsg, token) { + let strict = this.strict; + if (typeof strict === "function") { + // Allow return value of strict function to be boolean or string + // (or null/undefined, meaning no further processing). + // But catch any exceptions thrown by function, treating them + // like "error". + try { + strict = strict(errorCode, errorMsg, token); + } catch (error) { + strict = "error"; + } + } + if (!strict || strict === "ignore") { + return false; + } else if (strict === true || strict === "error") { + return true; + } else if (strict === "warn") { + typeof console !== "undefined" && console.warn("LaTeX-incompatible input and strict mode is set to 'warn': " + (errorMsg + " [" + errorCode + "]")); + return false; + } else { + // won't happen in type-safe code + typeof console !== "undefined" && console.warn("LaTeX-incompatible input and strict mode is set to " + ("unrecognized '" + strict + "': " + errorMsg + " [" + errorCode + "]")); + return false; + } + } + + /** + * Check whether to test potentially dangerous input, and return + * `true` (trusted) or `false` (untrusted). The sole argument `context` + * should be an object with `command` field specifying the relevant LaTeX + * command (as a string starting with `\`), and any other arguments, etc. + * If `context` has a `url` field, a `protocol` field will automatically + * get added by this function (changing the specified object). + */ + isTrusted(context) { + if ("url" in context && context.url && !context.protocol) { + const protocol = protocolFromUrl(context.url); + if (protocol == null) { + return false; + } + context.protocol = protocol; + } + const trust = typeof this.trust === "function" ? this.trust(context) : this.trust; + return Boolean(trust); + } +} +;// ./src/Style.ts +/** + * This file contains information and classes for the various kinds of styles + * used in TeX. It provides a generic `Style` class, which holds information + * about a specific style. It then provides instances of all the different kinds + * of styles possible, and provides functions to move between them and get + * information about them. + */ + +/** + * The main style class. Contains a unique id for the style, a size (which is + * the same for cramped and uncramped version of a style), and a cramped flag. + */ +class Style { + constructor(id, size, cramped) { + this.id = void 0; + this.size = void 0; + this.cramped = void 0; + this.id = id; + this.size = size; + this.cramped = cramped; + } + + /** + * Get the style of a superscript given a base in the current style. + */ + sup() { + return styles[sup[this.id]]; + } + + /** + * Get the style of a subscript given a base in the current style. + */ + sub() { + return styles[sub[this.id]]; + } + + /** + * Get the style of a fraction numerator given the fraction in the current + * style. + */ + fracNum() { + return styles[fracNum[this.id]]; + } + + /** + * Get the style of a fraction denominator given the fraction in the current + * style. + */ + fracDen() { + return styles[fracDen[this.id]]; + } + + /** + * Get the cramped version of a style (in particular, cramping a cramped style + * doesn't change the style). + */ + cramp() { + return styles[cramp[this.id]]; + } + + /** + * Get a text or display version of this style. + */ + text() { + return styles[Style_text[this.id]]; + } + + /** + * Return true if this style is tightly spaced (scriptstyle/scriptscriptstyle) + */ + isTight() { + return this.size >= 2; + } +} + +// Export an interface for type checking, but don't expose the implementation. +// This way, no more styles can be generated. + +// IDs of the different styles +const D = 0; +const Dc = 1; +const T = 2; +const Tc = 3; +const S = 4; +const Sc = 5; +const SS = 6; +const SSc = 7; + +// Instances of the different styles +const styles = [new Style(D, 0, false), new Style(Dc, 0, true), new Style(T, 1, false), new Style(Tc, 1, true), new Style(S, 2, false), new Style(Sc, 2, true), new Style(SS, 3, false), new Style(SSc, 3, true)]; + +// Lookup tables for switching from one style to another +const sup = [S, Sc, S, Sc, SS, SSc, SS, SSc]; +const sub = [Sc, Sc, Sc, Sc, SSc, SSc, SSc, SSc]; +const fracNum = [T, Tc, S, Sc, SS, SSc, SS, SSc]; +const fracDen = [Tc, Tc, Sc, Sc, SSc, SSc, SSc, SSc]; +const cramp = [Dc, Dc, Tc, Tc, Sc, Sc, SSc, SSc]; +const Style_text = [D, Dc, T, Tc, T, Tc, T, Tc]; + +// We only export some of the styles. +/* harmony default export */ var src_Style = ({ + DISPLAY: styles[D], + TEXT: styles[T], + SCRIPT: styles[S], + SCRIPTSCRIPT: styles[SS] +}); +;// ./src/unicodeScripts.ts +/* + * This file defines the Unicode scripts and script families that we + * support. To add new scripts or families, just add a new entry to the + * scriptData array below. Adding scripts to the scriptData array allows + * characters from that script to appear in \text{} environments. + */ + +/** + * Each script or script family has a name and an array of blocks. + * Each block is an array of two numbers which specify the start and + * end points (inclusive) of a block of Unicode codepoints. + */ + +/** + * Unicode block data for the families of scripts we support in \text{}. + * Scripts only need to appear here if they do not have font metrics. + */ +const scriptData = [{ + // Latin characters beyond the Latin-1 characters we have metrics for. + // Needed for Czech, Hungarian and Turkish text, for example. + name: 'latin', + blocks: [[0x0100, 0x024f], + // Latin Extended-A and Latin Extended-B + [0x0300, 0x036f] // Combining Diacritical marks + ] +}, { + // The Cyrillic script used by Russian and related languages. + // A Cyrillic subset used to be supported as explicitly defined + // symbols in symbols.js + name: 'cyrillic', + blocks: [[0x0400, 0x04ff]] +}, { + // Armenian + name: 'armenian', + blocks: [[0x0530, 0x058F]] +}, { + // The Brahmic scripts of South and Southeast Asia + // Devanagari (0900–097F) + // Bengali (0980–09FF) + // Gurmukhi (0A00–0A7F) + // Gujarati (0A80–0AFF) + // Oriya (0B00–0B7F) + // Tamil (0B80–0BFF) + // Telugu (0C00–0C7F) + // Kannada (0C80–0CFF) + // Malayalam (0D00–0D7F) + // Sinhala (0D80–0DFF) + // Thai (0E00–0E7F) + // Lao (0E80–0EFF) + // Tibetan (0F00–0FFF) + // Myanmar (1000–109F) + name: 'brahmic', + blocks: [[0x0900, 0x109F]] +}, { + name: 'georgian', + blocks: [[0x10A0, 0x10ff]] +}, { + // Chinese and Japanese. + // The "k" in cjk is for Korean, but we've separated Korean out + name: "cjk", + blocks: [[0x3000, 0x30FF], + // CJK symbols and punctuation, Hiragana, Katakana + [0x4E00, 0x9FAF], + // CJK ideograms + [0xFF00, 0xFF60] // Fullwidth punctuation + // TODO: add halfwidth Katakana and Romanji glyphs + ] +}, { + // Korean + name: 'hangul', + blocks: [[0xAC00, 0xD7AF]] +}]; + +/** + * Given a codepoint, return the name of the script or script family + * it is from, or null if it is not part of a known block + */ +function scriptFromCodepoint(codepoint) { + for (let i = 0; i < scriptData.length; i++) { + const script = scriptData[i]; + for (let i = 0; i < script.blocks.length; i++) { + const block = script.blocks[i]; + if (codepoint >= block[0] && codepoint <= block[1]) { + return script.name; + } + } + } + return null; +} + +/** + * A flattened version of all the supported blocks in a single array. + * This is an optimization to make supportedCodepoint() fast. + */ +const allBlocks = []; +scriptData.forEach(s => s.blocks.forEach(b => allBlocks.push(...b))); + +/** + * Given a codepoint, return true if it falls within one of the + * scripts or script families defined above and false otherwise. + * + * Micro benchmarks shows that this is faster than + * /[\u3000-\u30FF\u4E00-\u9FAF\uFF00-\uFF60\uAC00-\uD7AF\u0900-\u109F]/.test() + * in Firefox, Chrome and Node. + */ +function supportedCodepoint(codepoint) { + for (let i = 0; i < allBlocks.length; i += 2) { + if (codepoint >= allBlocks[i] && codepoint <= allBlocks[i + 1]) { + return true; + } + } + return false; +} +;// ./src/svgGeometry.ts +/** + * This file provides support to domTree.js and delimiter.js. + * It's a storehouse of path geometry for SVG images. + */ + +// In all paths below, the viewBox-to-em scale is 1000:1. + +// Second Brush Stroke +// Low resolution monitors struggle to display images in fine detail. +// So browsers apply anti-aliasing. A long straight arrow shaft therefore +// will sometimes appear as if it has a blurred edge. + +// To mitigate this, these SVG files contain a second "brush-stroke" on the +// arrow shafts. That is, a second long thin rectangular SVG path has been +// written directly on top of each arrow shaft. This reinforcement causes +// some of the screen pixels to display as black instead of the anti-aliased +// gray pixel that a single path would generate. So we get arrow shafts +// whose edges appear to be sharper. +const doubleBrushStroke = svgPath => svgPath + " " + svgPath; +const hLinePad = 80; // padding above a sqrt vinculum. Prevents image cropping. + +// The vinculum of a \sqrt can be made thicker by a KaTeX rendering option. +// Think of variable extraVinculum as two detours in the SVG path. +// The detour begins at the lower left of the area labeled extraVinculum below. +// The detour proceeds one extraVinculum distance up and slightly to the right, +// displacing the radiused corner between surd and vinculum. The radius is +// traversed as usual, then the detour resumes. It goes right, to the end of +// the very long vinculum, then down one extraVinculum distance, +// after which it resumes regular path geometry for the radical. +/* vinculum + / + /▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒←extraVinculum + / █████████████████████←0.04em (40 unit) std vinculum thickness + / / + / / + / /\ + / / surd +*/ + +const sqrtMain = function (extraVinculum, hLinePad) { + // sqrtMain path geometry is from glyph U221A in the font KaTeX Main + return "M95," + (622 + extraVinculum + hLinePad) + "\nc-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14\nc0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54\nc44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10\ns173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429\nc69,-144,104.5,-217.7,106.5,-221\nl" + extraVinculum / 2.075 + " -" + extraVinculum + "\nc5.3,-9.3,12,-14,20,-14\nH400000v" + (40 + extraVinculum) + "H845.2724\ns-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7\nc-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z\nM" + (834 + extraVinculum) + " " + hLinePad + "h400000v" + (40 + extraVinculum) + "h-400000z"; +}; +const sqrtSize1 = function (extraVinculum, hLinePad) { + // size1 is from glyph U221A in the font KaTeX_Size1-Regular + return "M263," + (601 + extraVinculum + hLinePad) + "c0.7,0,18,39.7,52,119\nc34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120\nc340,-704.7,510.7,-1060.3,512,-1067\nl" + extraVinculum / 2.084 + " -" + extraVinculum + "\nc4.7,-7.3,11,-11,19,-11\nH40000v" + (40 + extraVinculum) + "H1012.3\ns-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232\nc-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1\ns-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26\nc-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z\nM" + (1001 + extraVinculum) + " " + hLinePad + "h400000v" + (40 + extraVinculum) + "h-400000z"; +}; +const sqrtSize2 = function (extraVinculum, hLinePad) { + // size2 is from glyph U221A in the font KaTeX_Size2-Regular + return "M983 " + (10 + extraVinculum + hLinePad) + "\nl" + extraVinculum / 3.13 + " -" + extraVinculum + "\nc4,-6.7,10,-10,18,-10 H400000v" + (40 + extraVinculum) + "\nH1013.1s-83.4,268,-264.1,840c-180.7,572,-277,876.3,-289,913c-4.7,4.7,-12.7,7,-24,7\ns-12,0,-12,0c-1.3,-3.3,-3.7,-11.7,-7,-25c-35.3,-125.3,-106.7,-373.3,-214,-744\nc-10,12,-21,25,-33,39s-32,39,-32,39c-6,-5.3,-15,-14,-27,-26s25,-30,25,-30\nc26.7,-32.7,52,-63,76,-91s52,-60,52,-60s208,722,208,722\nc56,-175.3,126.3,-397.3,211,-666c84.7,-268.7,153.8,-488.2,207.5,-658.5\nc53.7,-170.3,84.5,-266.8,92.5,-289.5z\nM" + (1001 + extraVinculum) + " " + hLinePad + "h400000v" + (40 + extraVinculum) + "h-400000z"; +}; +const sqrtSize3 = function (extraVinculum, hLinePad) { + // size3 is from glyph U221A in the font KaTeX_Size3-Regular + return "M424," + (2398 + extraVinculum + hLinePad) + "\nc-1.3,-0.7,-38.5,-172,-111.5,-514c-73,-342,-109.8,-513.3,-110.5,-514\nc0,-2,-10.7,14.3,-32,49c-4.7,7.3,-9.8,15.7,-15.5,25c-5.7,9.3,-9.8,16,-12.5,20\ns-5,7,-5,7c-4,-3.3,-8.3,-7.7,-13,-13s-13,-13,-13,-13s76,-122,76,-122s77,-121,77,-121\ns209,968,209,968c0,-2,84.7,-361.7,254,-1079c169.3,-717.3,254.7,-1077.7,256,-1081\nl" + extraVinculum / 4.223 + " -" + extraVinculum + "c4,-6.7,10,-10,18,-10 H400000\nv" + (40 + extraVinculum) + "H1014.6\ns-87.3,378.7,-272.6,1166c-185.3,787.3,-279.3,1182.3,-282,1185\nc-2,6,-10,9,-24,9\nc-8,0,-12,-0.7,-12,-2z M" + (1001 + extraVinculum) + " " + hLinePad + "\nh400000v" + (40 + extraVinculum) + "h-400000z"; +}; +const sqrtSize4 = function (extraVinculum, hLinePad) { + // size4 is from glyph U221A in the font KaTeX_Size4-Regular + return "M473," + (2713 + extraVinculum + hLinePad) + "\nc339.3,-1799.3,509.3,-2700,510,-2702 l" + extraVinculum / 5.298 + " -" + extraVinculum + "\nc3.3,-7.3,9.3,-11,18,-11 H400000v" + (40 + extraVinculum) + "H1017.7\ns-90.5,478,-276.2,1466c-185.7,988,-279.5,1483,-281.5,1485c-2,6,-10,9,-24,9\nc-8,0,-12,-0.7,-12,-2c0,-1.3,-5.3,-32,-16,-92c-50.7,-293.3,-119.7,-693.3,-207,-1200\nc0,-1.3,-5.3,8.7,-16,30c-10.7,21.3,-21.3,42.7,-32,64s-16,33,-16,33s-26,-26,-26,-26\ns76,-153,76,-153s77,-151,77,-151c0.7,0.7,35.7,202,105,604c67.3,400.7,102,602.7,104,\n606zM" + (1001 + extraVinculum) + " " + hLinePad + "h400000v" + (40 + extraVinculum) + "H1017.7z"; +}; +const phasePath = function (y) { + const x = y / 2; // x coordinate at top of angle + return "M400000 " + y + " H0 L" + x + " 0 l65 45 L145 " + (y - 80) + " H400000z"; +}; +const sqrtTall = function (extraVinculum, hLinePad, viewBoxHeight) { + // sqrtTall is from glyph U23B7 in the font KaTeX_Size4-Regular + // One path edge has a variable length. It runs vertically from the vinculum + // to a point near (14 units) the bottom of the surd. The vinculum + // is normally 40 units thick. So the length of the line in question is: + const vertSegment = viewBoxHeight - 54 - hLinePad - extraVinculum; + return "M702 " + (extraVinculum + hLinePad) + "H400000" + (40 + extraVinculum) + "\nH742v" + vertSegment + "l-4 4-4 4c-.667.7 -2 1.5-4 2.5s-4.167 1.833-6.5 2.5-5.5 1-9.5 1\nh-12l-28-84c-16.667-52-96.667 -294.333-240-727l-212 -643 -85 170\nc-4-3.333-8.333-7.667-13 -13l-13-13l77-155 77-156c66 199.333 139 419.667\n219 661 l218 661zM702 " + hLinePad + "H400000v" + (40 + extraVinculum) + "H742z"; +}; +const sqrtPath = function (size, extraVinculum, viewBoxHeight) { + extraVinculum = 1000 * extraVinculum; // Convert from document ems to viewBox. + let path = ""; + switch (size) { + case "sqrtMain": + path = sqrtMain(extraVinculum, hLinePad); + break; + case "sqrtSize1": + path = sqrtSize1(extraVinculum, hLinePad); + break; + case "sqrtSize2": + path = sqrtSize2(extraVinculum, hLinePad); + break; + case "sqrtSize3": + path = sqrtSize3(extraVinculum, hLinePad); + break; + case "sqrtSize4": + path = sqrtSize4(extraVinculum, hLinePad); + break; + case "sqrtTall": + path = sqrtTall(extraVinculum, hLinePad, viewBoxHeight); + } + return path; +}; +const innerPath = function (name, height) { + // The inner part of stretchy tall delimiters + switch (name) { + case "\u239c": + return doubleBrushStroke("M291 0 H417 V" + height + " H291z"); + case "\u2223": + return doubleBrushStroke("M145 0 H188 V" + height + " H145z"); + case "\u2225": + return doubleBrushStroke("M145 0 H188 V" + height + " H145z") + doubleBrushStroke("M367 0 H410 V" + height + " H367z"); + case "\u239f": + return doubleBrushStroke("M457 0 H583 V" + height + " H457z"); + case "\u23a2": + return doubleBrushStroke("M319 0 H403 V" + height + " H319z"); + case "\u23a5": + return doubleBrushStroke("M263 0 H347 V" + height + " H263z"); + case "\u23aa": + return doubleBrushStroke("M384 0 H504 V" + height + " H384z"); + case "\u23d0": + return doubleBrushStroke("M312 0 H355 V" + height + " H312z"); + case "\u2016": + return doubleBrushStroke("M257 0 H300 V" + height + " H257z") + doubleBrushStroke("M478 0 H521 V" + height + " H478z"); + default: + return ""; + } +}; +const path = { + // The doubleleftarrow geometry is from glyph U+21D0 in the font KaTeX Main + doubleleftarrow: "M262 157\nl10-10c34-36 62.7-77 86-123 3.3-8 5-13.3 5-16 0-5.3-6.7-8-20-8-7.3\n 0-12.2.5-14.5 1.5-2.3 1-4.8 4.5-7.5 10.5-49.3 97.3-121.7 169.3-217 216-28\n 14-57.3 25-88 33-6.7 2-11 3.8-13 5.5-2 1.7-3 4.2-3 7.5s1 5.8 3 7.5\nc2 1.7 6.3 3.5 13 5.5 68 17.3 128.2 47.8 180.5 91.5 52.3 43.7 93.8 96.2 124.5\n 157.5 9.3 8 15.3 12.3 18 13h6c12-.7 18-4 18-10 0-2-1.7-7-5-15-23.3-46-52-87\n-86-123l-10-10h399738v-40H218c328 0 0 0 0 0l-10-8c-26.7-20-65.7-43-117-69 2.7\n-2 6-3.7 10-5 36.7-16 72.3-37.3 107-64l10-8h399782v-40z\nm8 0v40h399730v-40zm0 194v40h399730v-40z", + // doublerightarrow is from glyph U+21D2 in font KaTeX Main + doublerightarrow: "M399738 392l\n-10 10c-34 36-62.7 77-86 123-3.3 8-5 13.3-5 16 0 5.3 6.7 8 20 8 7.3 0 12.2-.5\n 14.5-1.5 2.3-1 4.8-4.5 7.5-10.5 49.3-97.3 121.7-169.3 217-216 28-14 57.3-25 88\n-33 6.7-2 11-3.8 13-5.5 2-1.7 3-4.2 3-7.5s-1-5.8-3-7.5c-2-1.7-6.3-3.5-13-5.5-68\n-17.3-128.2-47.8-180.5-91.5-52.3-43.7-93.8-96.2-124.5-157.5-9.3-8-15.3-12.3-18\n-13h-6c-12 .7-18 4-18 10 0 2 1.7 7 5 15 23.3 46 52 87 86 123l10 10H0v40h399782\nc-328 0 0 0 0 0l10 8c26.7 20 65.7 43 117 69-2.7 2-6 3.7-10 5-36.7 16-72.3 37.3\n-107 64l-10 8H0v40zM0 157v40h399730v-40zm0 194v40h399730v-40z", + // leftarrow is from glyph U+2190 in font KaTeX Main + leftarrow: "M400000 241H110l3-3c68.7-52.7 113.7-120\n 135-202 4-14.7 6-23 6-25 0-7.3-7-11-21-11-8 0-13.2.8-15.5 2.5-2.3 1.7-4.2 5.8\n-5.5 12.5-1.3 4.7-2.7 10.3-4 17-12 48.7-34.8 92-68.5 130S65.3 228.3 18 247\nc-10 4-16 7.7-18 11 0 8.7 6 14.3 18 17 47.3 18.7 87.8 47 121.5 85S196 441.3 208\n 490c.7 2 1.3 5 2 9s1.2 6.7 1.5 8c.3 1.3 1 3.3 2 6s2.2 4.5 3.5 5.5c1.3 1 3.3\n 1.8 6 2.5s6 1 10 1c14 0 21-3.7 21-11 0-2-2-10.3-6-25-20-79.3-65-146.7-135-202\n l-3-3h399890zM100 241v40h399900v-40z", + // overbrace is from glyphs U+23A9/23A8/23A7 in font KaTeX_Size4-Regular + leftbrace: "M6 548l-6-6v-35l6-11c56-104 135.3-181.3 238-232 57.3-28.7 117\n-45 179-50h399577v120H403c-43.3 7-81 15-113 26-100.7 33-179.7 91-237 174-2.7\n 5-6 9-10 13-.7 1-7.3 1-20 1H6z", + leftbraceunder: "M0 6l6-6h17c12.688 0 19.313.3 20 1 4 4 7.313 8.3 10 13\n 35.313 51.3 80.813 93.8 136.5 127.5 55.688 33.7 117.188 55.8 184.5 66.5.688\n 0 2 .3 4 1 18.688 2.7 76 4.3 172 5h399450v120H429l-6-1c-124.688-8-235-61.7\n-331-161C60.687 138.7 32.312 99.3 7 54L0 41V6z", + // overgroup is from the MnSymbol package (public domain) + leftgroup: "M400000 80\nH435C64 80 168.3 229.4 21 260c-5.9 1.2-18 0-18 0-2 0-3-1-3-3v-38C76 61 257 0\n 435 0h399565z", + leftgroupunder: "M400000 262\nH435C64 262 168.3 112.6 21 82c-5.9-1.2-18 0-18 0-2 0-3 1-3 3v38c76 158 257 219\n 435 219h399565z", + // Harpoons are from glyph U+21BD in font KaTeX Main + leftharpoon: "M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3\n-3.3 10.2-9.5 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5\n-18.3 3-21-1.3-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7\n-196 228-6.7 4.7-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40z", + leftharpoonplus: "M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3-3.3 10.2-9.5\n 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5-18.3 3-21-1.3\n-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7-196 228-6.7 4.7\n-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40zM0 435v40h400000v-40z\nm0 0v40h400000v-40z", + leftharpoondown: "M7 241c-4 4-6.333 8.667-7 14 0 5.333.667 9 2 11s5.333\n 5.333 12 10c90.667 54 156 130 196 228 3.333 10.667 6.333 16.333 9 17 2 .667 5\n 1 9 1h5c10.667 0 16.667-2 18-6 2-2.667 1-9.667-3-21-32-87.333-82.667-157.667\n-152-211l-3-3h399907v-40zM93 281 H400000 v-40L7 241z", + leftharpoondownplus: "M7 435c-4 4-6.3 8.7-7 14 0 5.3.7 9 2 11s5.3 5.3 12\n 10c90.7 54 156 130 196 228 3.3 10.7 6.3 16.3 9 17 2 .7 5 1 9 1h5c10.7 0 16.7\n-2 18-6 2-2.7 1-9.7-3-21-32-87.3-82.7-157.7-152-211l-3-3h399907v-40H7zm93 0\nv40h399900v-40zM0 241v40h399900v-40zm0 0v40h399900v-40z", + // hook is from glyph U+21A9 in font KaTeX Main + lefthook: "M400000 281 H103s-33-11.2-61-33.5S0 197.3 0 164s14.2-61.2 42.5\n-83.5C70.8 58.2 104 47 142 47 c16.7 0 25 6.7 25 20 0 12-8.7 18.7-26 20-40 3.3\n-68.7 15.7-86 37-10 12-15 25.3-15 40 0 22.7 9.8 40.7 29.5 54 19.7 13.3 43.5 21\n 71.5 23h399859zM103 281v-40h399897v40z", + leftlinesegment: doubleBrushStroke("M40 281 V428 H0 V94 H40 V241 H400000 v40z"), + leftbracketunder: doubleBrushStroke("M0 0 h120 V290 H399995 v120 H0z"), + leftbracketover: doubleBrushStroke("M0 440 h120 V150 H399995 v-120 H0z"), + leftmapsto: doubleBrushStroke("M40 281 V448H0V74H40V241H400000v40z"), + // tofrom is from glyph U+21C4 in font KaTeX AMS Regular + leftToFrom: "M0 147h400000v40H0zm0 214c68 40 115.7 95.7 143 167h22c15.3 0 23\n-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69-70-101l-7-8h399905v-40H95l7-8\nc28.7-32 52-65.7 70-101 10.7-23.3 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 265.3\n 68 321 0 361zm0-174v-40h399900v40zm100 154v40h399900v-40z", + longequal: doubleBrushStroke("M0 50 h400000 v40H0z m0 194h40000v40H0z"), + midbrace: "M200428 334\nc-100.7-8.3-195.3-44-280-108-55.3-42-101.7-93-139-153l-9-14c-2.7 4-5.7 8.7-9 14\n-53.3 86.7-123.7 153-211 199-66.7 36-137.3 56.3-212 62H0V214h199568c178.3-11.7\n 311.7-78.3 403-201 6-8 9.7-12 11-12 .7-.7 6.7-1 18-1s17.3.3 18 1c1.3 0 5 4 11\n 12 44.7 59.3 101.3 106.3 170 141s145.3 54.3 229 60h199572v120z", + midbraceunder: "M199572 214\nc100.7 8.3 195.3 44 280 108 55.3 42 101.7 93 139 153l9 14c2.7-4 5.7-8.7 9-14\n 53.3-86.7 123.7-153 211-199 66.7-36 137.3-56.3 212-62h199568v120H200432c-178.3\n 11.7-311.7 78.3-403 201-6 8-9.7 12-11 12-.7.7-6.7 1-18 1s-17.3-.3-18-1c-1.3 0\n-5-4-11-12-44.7-59.3-101.3-106.3-170-141s-145.3-54.3-229-60H0V214z", + oiintSize1: "M512.6 71.6c272.6 0 320.3 106.8 320.3 178.2 0 70.8-47.7 177.6\n-320.3 177.6S193.1 320.6 193.1 249.8c0-71.4 46.9-178.2 319.5-178.2z\nm368.1 178.2c0-86.4-60.9-215.4-368.1-215.4-306.4 0-367.3 129-367.3 215.4 0 85.8\n60.9 214.8 367.3 214.8 307.2 0 368.1-129 368.1-214.8z", + oiintSize2: "M757.8 100.1c384.7 0 451.1 137.6 451.1 230 0 91.3-66.4 228.8\n-451.1 228.8-386.3 0-452.7-137.5-452.7-228.8 0-92.4 66.4-230 452.7-230z\nm502.4 230c0-111.2-82.4-277.2-502.4-277.2s-504 166-504 277.2\nc0 110 84 276 504 276s502.4-166 502.4-276z", + oiiintSize1: "M681.4 71.6c408.9 0 480.5 106.8 480.5 178.2 0 70.8-71.6 177.6\n-480.5 177.6S202.1 320.6 202.1 249.8c0-71.4 70.5-178.2 479.3-178.2z\nm525.8 178.2c0-86.4-86.8-215.4-525.7-215.4-437.9 0-524.7 129-524.7 215.4 0\n85.8 86.8 214.8 524.7 214.8 438.9 0 525.7-129 525.7-214.8z", + oiiintSize2: "M1021.2 53c603.6 0 707.8 165.8 707.8 277.2 0 110-104.2 275.8\n-707.8 275.8-606 0-710.2-165.8-710.2-275.8C311 218.8 415.2 53 1021.2 53z\nm770.4 277.1c0-131.2-126.4-327.6-770.5-327.6S248.4 198.9 248.4 330.1\nc0 130 128.8 326.4 772.7 326.4s770.5-196.4 770.5-326.4z", + rightarrow: "M0 241v40h399891c-47.3 35.3-84 78-110 128\n-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20\n 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7\n 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85\n-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5\n-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67\n 151.7 139 205zm0 0v40h399900v-40z", + rightbrace: "M400000 542l\n-6 6h-17c-12.7 0-19.3-.3-20-1-4-4-7.3-8.3-10-13-35.3-51.3-80.8-93.8-136.5-127.5\ns-117.2-55.8-184.5-66.5c-.7 0-2-.3-4-1-18.7-2.7-76-4.3-172-5H0V214h399571l6 1\nc124.7 8 235 61.7 331 161 31.3 33.3 59.7 72.7 85 118l7 13v35z", + rightbraceunder: "M399994 0l6 6v35l-6 11c-56 104-135.3 181.3-238 232-57.3\n 28.7-117 45-179 50H-300V214h399897c43.3-7 81-15 113-26 100.7-33 179.7-91 237\n-174 2.7-5 6-9 10-13 .7-1 7.3-1 20-1h17z", + rightgroup: "M0 80h399565c371 0 266.7 149.4 414 180 5.9 1.2 18 0 18 0 2 0\n 3-1 3-3v-38c-76-158-257-219-435-219H0z", + rightgroupunder: "M0 262h399565c371 0 266.7-149.4 414-180 5.9-1.2 18 0 18\n 0 2 0 3 1 3 3v38c-76 158-257 219-435 219H0z", + rightharpoon: "M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3\n-3.7-15.3-11-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2\n-10.7 0-16.7 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58\n 69.2 92 94.5zm0 0v40h399900v-40z", + rightharpoonplus: "M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3-3.7-15.3-11\n-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2-10.7 0-16.7\n 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58 69.2 92 94.5z\nm0 0v40h399900v-40z m100 194v40h399900v-40zm0 0v40h399900v-40z", + rightharpoondown: "M399747 511c0 7.3 6.7 11 20 11 8 0 13-.8 15-2.5s4.7-6.8\n 8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3 8.5-5.8 9.5\n-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3-64.7 57-92 95\n-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 241v40h399900v-40z", + rightharpoondownplus: "M399747 705c0 7.3 6.7 11 20 11 8 0 13-.8\n 15-2.5s4.7-6.8 8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3\n 8.5-5.8 9.5-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3\n-64.7 57-92 95-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 435v40h399900v-40z\nm0-194v40h400000v-40zm0 0v40h400000v-40z", + righthook: "M399859 241c-764 0 0 0 0 0 40-3.3 68.7-15.7 86-37 10-12 15-25.3\n 15-40 0-22.7-9.8-40.7-29.5-54-19.7-13.3-43.5-21-71.5-23-17.3-1.3-26-8-26-20 0\n-13.3 8.7-20 26-20 38 0 71 11.2 99 33.5 0 0 7 5.6 21 16.7 14 11.2 21 33.5 21\n 66.8s-14 61.2-42 83.5c-28 22.3-61 33.5-99 33.5L0 241z M0 281v-40h399859v40z", + rightlinesegment: doubleBrushStroke("M399960 241 V94 h40 V428 h-40 V281 H0 v-40z"), + rightbracketunder: doubleBrushStroke("M399995 0 h-120 V290 H0 v120 H400000z"), + rightbracketover: doubleBrushStroke("M399995 440 h-120 V150 H0 v-120 H399995z"), + rightToFrom: "M400000 167c-70.7-42-118-97.7-142-167h-23c-15.3 0-23 .3-23\n 1 0 1.3 5.3 13.7 16 37 18 35.3 41.3 69 70 101l7 8H0v40h399905l-7 8c-28.7 32\n-52 65.7-70 101-10.7 23.3-16 35.7-16 37 0 .7 7.7 1 23 1h23c24-69.3 71.3-125 142\n-167z M100 147v40h399900v-40zM0 341v40h399900v-40z", + // twoheadleftarrow is from glyph U+219E in font KaTeX AMS Regular + twoheadleftarrow: "M0 167c68 40\n 115.7 95.7 143 167h22c15.3 0 23-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69\n-70-101l-7-8h125l9 7c50.7 39.3 85 86 103 140h46c0-4.7-6.3-18.7-19-42-18-35.3\n-40-67.3-66-96l-9-9h399716v-40H284l9-9c26-28.7 48-60.7 66-96 12.7-23.333 19\n-37.333 19-42h-46c-18 54-52.3 100.7-103 140l-9 7H95l7-8c28.7-32 52-65.7 70-101\n 10.7-23.333 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 71.3 68 127 0 167z", + twoheadrightarrow: "M400000 167\nc-68-40-115.7-95.7-143-167h-22c-15.3 0-23 .3-23 1 0 1.3 5.3 13.7 16 37 18 35.3\n 41.3 69 70 101l7 8h-125l-9-7c-50.7-39.3-85-86-103-140h-46c0 4.7 6.3 18.7 19 42\n 18 35.3 40 67.3 66 96l9 9H0v40h399716l-9 9c-26 28.7-48 60.7-66 96-12.7 23.333\n-19 37.333-19 42h46c18-54 52.3-100.7 103-140l9-7h125l-7 8c-28.7 32-52 65.7-70\n 101-10.7 23.333-16 35.7-16 37 0 .7 7.7 1 23 1h22c27.3-71.3 75-127 143-167z", + // tilde1 is a modified version of a glyph from the MnSymbol package + tilde1: "M200 55.538c-77 0-168 73.953-177 73.953-3 0-7\n-2.175-9-5.437L2 97c-1-2-2-4-2-6 0-4 2-7 5-9l20-12C116 12 171 0 207 0c86 0\n 114 68 191 68 78 0 168-68 177-68 4 0 7 2 9 5l12 19c1 2.175 2 4.35 2 6.525 0\n 4.35-2 7.613-5 9.788l-19 13.05c-92 63.077-116.937 75.308-183 76.128\n-68.267.847-113-73.952-191-73.952z", + // ditto tilde2, tilde3, & tilde4 + tilde2: "M344 55.266c-142 0-300.638 81.316-311.5 86.418\n-8.01 3.762-22.5 10.91-23.5 5.562L1 120c-1-2-1-3-1-4 0-5 3-9 8-10l18.4-9C160.9\n 31.9 283 0 358 0c148 0 188 122 331 122s314-97 326-97c4 0 8 2 10 7l7 21.114\nc1 2.14 1 3.21 1 4.28 0 5.347-3 9.626-7 10.696l-22.3 12.622C852.6 158.372 751\n 181.476 676 181.476c-149 0-189-126.21-332-126.21z", + tilde3: "M786 59C457 59 32 175.242 13 175.242c-6 0-10-3.457\n-11-10.37L.15 138c-1-7 3-12 10-13l19.2-6.4C378.4 40.7 634.3 0 804.3 0c337 0\n 411.8 157 746.8 157 328 0 754-112 773-112 5 0 10 3 11 9l1 14.075c1 8.066-.697\n 16.595-6.697 17.492l-21.052 7.31c-367.9 98.146-609.15 122.696-778.15 122.696\n -338 0-409-156.573-744-156.573z", + tilde4: "M786 58C457 58 32 177.487 13 177.487c-6 0-10-3.345\n-11-10.035L.15 143c-1-7 3-12 10-13l22-6.7C381.2 35 637.15 0 807.15 0c337 0 409\n 177 744 177 328 0 754-127 773-127 5 0 10 3 11 9l1 14.794c1 7.805-3 13.38-9\n 14.495l-20.7 5.574c-366.85 99.79-607.3 139.372-776.3 139.372-338 0-409\n -175.236-744-175.236z", + // vec is from glyph U+20D7 in font KaTeX Main + vec: "M377 20c0-5.333 1.833-10 5.5-14S391 0 397 0c4.667 0 8.667 1.667 12 5\n3.333 2.667 6.667 9 10 19 6.667 24.667 20.333 43.667 41 57 7.333 4.667 11\n10.667 11 18 0 6-1 10-3 12s-6.667 5-14 9c-28.667 14.667-53.667 35.667-75 63\n-1.333 1.333-3.167 3.5-5.5 6.5s-4 4.833-5 5.5c-1 .667-2.5 1.333-4.5 2s-4.333 1\n-7 1c-4.667 0-9.167-1.833-13.5-5.5S337 184 337 178c0-12.667 15.667-32.333 47-59\nH213l-171-1c-8.667-6-13-12.333-13-19 0-4.667 4.333-11.333 13-20h359\nc-16-25.333-24-45-24-59z", + // widehat1 is a modified version of a glyph from the MnSymbol package + widehat1: "M529 0h5l519 115c5 1 9 5 9 10 0 1-1 2-1 3l-4 22\nc-1 5-5 9-11 9h-2L532 67 19 159h-2c-5 0-9-4-11-9l-5-22c-1-6 2-12 8-13z", + // ditto widehat2, widehat3, & widehat4 + widehat2: "M1181 0h2l1171 176c6 0 10 5 10 11l-2 23c-1 6-5 10\n-11 10h-1L1182 67 15 220h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z", + widehat3: "M1181 0h2l1171 236c6 0 10 5 10 11l-2 23c-1 6-5 10\n-11 10h-1L1182 67 15 280h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z", + widehat4: "M1181 0h2l1171 296c6 0 10 5 10 11l-2 23c-1 6-5 10\n-11 10h-1L1182 67 15 340h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z", + // widecheck paths are all inverted versions of widehat + widecheck1: "M529,159h5l519,-115c5,-1,9,-5,9,-10c0,-1,-1,-2,-1,-3l-4,-22c-1,\n-5,-5,-9,-11,-9h-2l-512,92l-513,-92h-2c-5,0,-9,4,-11,9l-5,22c-1,6,2,12,8,13z", + widecheck2: "M1181,220h2l1171,-176c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,\n-11,-10h-1l-1168,153l-1167,-153h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z", + widecheck3: "M1181,280h2l1171,-236c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,\n-11,-10h-1l-1168,213l-1167,-213h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z", + widecheck4: "M1181,340h2l1171,-296c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,\n-11,-10h-1l-1168,273l-1167,-273h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z", + // The next ten paths support reaction arrows from the mhchem package. + + // Arrows for \ce{<-->} are offset from xAxis by 0.22ex, per mhchem in LaTeX + // baraboveleftarrow is mostly from glyph U+2190 in font KaTeX Main + baraboveleftarrow: "M400000 620h-399890l3 -3c68.7 -52.7 113.7 -120 135 -202\nc4 -14.7 6 -23 6 -25c0 -7.3 -7 -11 -21 -11c-8 0 -13.2 0.8 -15.5 2.5\nc-2.3 1.7 -4.2 5.8 -5.5 12.5c-1.3 4.7 -2.7 10.3 -4 17c-12 48.7 -34.8 92 -68.5 130\ns-74.2 66.3 -121.5 85c-10 4 -16 7.7 -18 11c0 8.7 6 14.3 18 17c47.3 18.7 87.8 47\n121.5 85s56.5 81.3 68.5 130c0.7 2 1.3 5 2 9s1.2 6.7 1.5 8c0.3 1.3 1 3.3 2 6\ns2.2 4.5 3.5 5.5c1.3 1 3.3 1.8 6 2.5s6 1 10 1c14 0 21 -3.7 21 -11\nc0 -2 -2 -10.3 -6 -25c-20 -79.3 -65 -146.7 -135 -202l-3 -3h399890z\nM100 620v40h399900v-40z M0 241v40h399900v-40zM0 241v40h399900v-40z", + // rightarrowabovebar is mostly from glyph U+2192, KaTeX Main + rightarrowabovebar: "M0 241v40h399891c-47.3 35.3-84 78-110 128-16.7 32\n-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20 11 8 0\n13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7 39\n-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85-40.5\n-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5\n-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67\n151.7 139 205zm96 379h399894v40H0zm0 0h399904v40H0z", + // The short left harpoon has 0.5em (i.e. 500 units) kern on the left end. + // Ref from mhchem.sty: \rlap{\raisebox{-.22ex}{$\kern0.5em + baraboveshortleftharpoon: "M507,435c-4,4,-6.3,8.7,-7,14c0,5.3,0.7,9,2,11\nc1.3,2,5.3,5.3,12,10c90.7,54,156,130,196,228c3.3,10.7,6.3,16.3,9,17\nc2,0.7,5,1,9,1c0,0,5,0,5,0c10.7,0,16.7,-2,18,-6c2,-2.7,1,-9.7,-3,-21\nc-32,-87.3,-82.7,-157.7,-152,-211c0,0,-3,-3,-3,-3l399351,0l0,-40\nc-398570,0,-399437,0,-399437,0z M593 435 v40 H399500 v-40z\nM0 281 v-40 H399908 v40z M0 281 v-40 H399908 v40z", + rightharpoonaboveshortbar: "M0,241 l0,40c399126,0,399993,0,399993,0\nc4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199,\n-231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6\nc-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z\nM0 241 v40 H399908 v-40z M0 475 v-40 H399500 v40z M0 475 v-40 H399500 v40z", + shortbaraboveleftharpoon: "M7,435c-4,4,-6.3,8.7,-7,14c0,5.3,0.7,9,2,11\nc1.3,2,5.3,5.3,12,10c90.7,54,156,130,196,228c3.3,10.7,6.3,16.3,9,17c2,0.7,5,1,9,\n1c0,0,5,0,5,0c10.7,0,16.7,-2,18,-6c2,-2.7,1,-9.7,-3,-21c-32,-87.3,-82.7,-157.7,\n-152,-211c0,0,-3,-3,-3,-3l399907,0l0,-40c-399126,0,-399993,0,-399993,0z\nM93 435 v40 H400000 v-40z M500 241 v40 H400000 v-40z M500 241 v40 H400000 v-40z", + shortrightharpoonabovebar: "M53,241l0,40c398570,0,399437,0,399437,0\nc4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199,\n-231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6\nc-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z\nM500 241 v40 H399408 v-40z M500 435 v40 H400000 v-40z" +}; +const tallDelim = function (label, midHeight) { + switch (label) { + case "lbrack": + return "M403 1759 V84 H666 V0 H319 V1759 v" + midHeight + " v1759 v84 h347 v-84\nH403z M403 1759 V0 H319 V1759 v" + midHeight + " v1759 v84 h84z"; + case "rbrack": + return "M347 1759 V0 H0 V84 H263 V1759 v" + midHeight + " v1759 H0 v84 H347z\nM347 1759 V0 H263 V1759 v" + midHeight + " v1759 h84z"; + case "vert": + return "M145 15 v585 v" + midHeight + " v585 c2.667,10,9.667,15,21,15\nc10,0,16.667,-5,20,-15 v-585 v" + -midHeight + " v-585 c-2.667,-10,-9.667,-15,-21,-15\nc-10,0,-16.667,5,-20,15z M188 15 H145 v585 v" + midHeight + " v585 h43z"; + case "doublevert": + return "M145 15 v585 v" + midHeight + " v585 c2.667,10,9.667,15,21,15\nc10,0,16.667,-5,20,-15 v-585 v" + -midHeight + " v-585 c-2.667,-10,-9.667,-15,-21,-15\nc-10,0,-16.667,5,-20,15z M188 15 H145 v585 v" + midHeight + " v585 h43z\nM367 15 v585 v" + midHeight + " v585 c2.667,10,9.667,15,21,15\nc10,0,16.667,-5,20,-15 v-585 v" + -midHeight + " v-585 c-2.667,-10,-9.667,-15,-21,-15\nc-10,0,-16.667,5,-20,15z M410 15 H367 v585 v" + midHeight + " v585 h43z"; + case "lfloor": + return "M319 602 V0 H403 V602 v" + midHeight + " v1715 h263 v84 H319z\nMM319 602 V0 H403 V602 v" + midHeight + " v1715 H319z"; + case "rfloor": + return "M319 602 V0 H403 V602 v" + midHeight + " v1799 H0 v-84 H319z\nMM319 602 V0 H403 V602 v" + midHeight + " v1715 H319z"; + case "lceil": + return "M403 1759 V84 H666 V0 H319 V1759 v" + midHeight + " v602 h84z\nM403 1759 V0 H319 V1759 v" + midHeight + " v602 h84z"; + case "rceil": + return "M347 1759 V0 H0 V84 H263 V1759 v" + midHeight + " v602 h84z\nM347 1759 V0 h-84 V1759 v" + midHeight + " v602 h84z"; + case "lparen": + return "M863,9c0,-2,-2,-5,-6,-9c0,0,-17,0,-17,0c-12.7,0,-19.3,0.3,-20,1\nc-5.3,5.3,-10.3,11,-15,17c-242.7,294.7,-395.3,682,-458,1162c-21.3,163.3,-33.3,349,\n-36,557 l0," + (midHeight + 84) + "c0.2,6,0,26,0,60c2,159.3,10,310.7,24,454c53.3,528,210,\n949.7,470,1265c4.7,6,9.7,11.7,15,17c0.7,0.7,7,1,19,1c0,0,18,0,18,0c4,-4,6,-7,6,-9\nc0,-2.7,-3.3,-8.7,-10,-18c-135.3,-192.7,-235.5,-414.3,-300.5,-665c-65,-250.7,-102.5,\n-544.7,-112.5,-882c-2,-104,-3,-167,-3,-189\nl0,-" + (midHeight + 92) + "c0,-162.7,5.7,-314,17,-454c20.7,-272,63.7,-513,129,-723c65.3,\n-210,155.3,-396.3,270,-559c6.7,-9.3,10,-15.3,10,-18z"; + case "rparen": + return "M76,0c-16.7,0,-25,3,-25,9c0,2,2,6.3,6,13c21.3,28.7,42.3,60.3,\n63,95c96.7,156.7,172.8,332.5,228.5,527.5c55.7,195,92.8,416.5,111.5,664.5\nc11.3,139.3,17,290.7,17,454c0,28,1.7,43,3.3,45l0," + (midHeight + 9) + "\nc-3,4,-3.3,16.7,-3.3,38c0,162,-5.7,313.7,-17,455c-18.7,248,-55.8,469.3,-111.5,664\nc-55.7,194.7,-131.8,370.3,-228.5,527c-20.7,34.7,-41.7,66.3,-63,95c-2,3.3,-4,7,-6,11\nc0,7.3,5.7,11,17,11c0,0,11,0,11,0c9.3,0,14.3,-0.3,15,-1c5.3,-5.3,10.3,-11,15,-17\nc242.7,-294.7,395.3,-681.7,458,-1161c21.3,-164.7,33.3,-350.7,36,-558\nl0,-" + (midHeight + 144) + "c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,\n-470,-1265c-4.7,-6,-9.7,-11.7,-15,-17c-0.7,-0.7,-6.7,-1,-18,-1z"; + default: + // We should not ever get here. + throw new Error("Unknown stretchy delimiter."); + } +}; +;// ./src/tree.ts +// To ensure that all nodes have compatible signatures for these methods. + +function isMathDomNode(node) { + return 'toText' in node; +} + +/** + * This node represents a document fragment, which contains elements, but when + * placed into the DOM doesn't have any representation itself. It only contains + * children and doesn't have any DOM node properties. + */ +class DocumentFragment { + // Never used; needed for satisfying interface. + + constructor(children) { + this.children = void 0; + this.classes = void 0; + this.height = void 0; + this.depth = void 0; + this.maxFontSize = void 0; + this.style = void 0; + this.children = children; + this.classes = []; + this.height = 0; + this.depth = 0; + this.maxFontSize = 0; + this.style = {}; + } + hasClass(className) { + return this.classes.includes(className); + } + + /** Convert the fragment into a node. */ + toNode() { + const frag = document.createDocumentFragment(); + for (let i = 0; i < this.children.length; i++) { + frag.appendChild(this.children[i].toNode()); + } + return frag; + } + + /** Convert the fragment into HTML markup. */ + toMarkup() { + let markup = ""; + + // Simply concatenate the markup for the children together. + for (let i = 0; i < this.children.length; i++) { + markup += this.children[i].toMarkup(); + } + return markup; + } + + /** + * Converts the math node into a string, similar to innerText. Applies to + * MathDomNode's only. + */ + toText() { + return this.children.map(child => { + if (isMathDomNode(child)) { + return child.toText(); + } + throw new Error("Expected MathDomNode with toText, got " + child.constructor.name); + }).join(""); + } +} +;// ./src/units.ts +/** + * This file does conversion between units. In particular, it provides + * calculateSize to convert other units into ems. + */ + + +// This table gives the number of TeX pts in one of each *absolute* TeX unit. +// Thus, multiplying a length by this number converts the length from units +// into pts. Dividing the result by ptPerEm gives the number of ems +// *assuming* a font size of ptPerEm (normal size, normal style). +const ptPerUnit = { + // https://en.wikibooks.org/wiki/LaTeX/Lengths and + // https://tex.stackexchange.com/a/8263 + "pt": 1, + // TeX point + "mm": 7227 / 2540, + // millimeter + "cm": 7227 / 254, + // centimeter + "in": 72.27, + // inch + "bp": 803 / 800, + // big (PostScript) points + "pc": 12, + // pica + "dd": 1238 / 1157, + // didot + "cc": 14856 / 1157, + // cicero (12 didot) + "nd": 685 / 642, + // new didot + "nc": 1370 / 107, + // new cicero (12 new didot) + "sp": 1 / 65536, + // scaled point (TeX's internal smallest unit) + // https://tex.stackexchange.com/a/41371 + "px": 803 / 800 // \pdfpxdimen defaults to 1 bp in pdfTeX and LuaTeX +}; + +// Dictionary of relative units, for fast validity testing. +const relativeUnit = { + "ex": true, + "em": true, + "mu": true +}; + +/** + * Determine whether the specified unit (either a string defining the unit + * or a "size" parse node containing a unit field) is valid. + */ +const validUnit = function (unit) { + if (typeof unit !== "string") { + unit = unit.unit; + } + return unit in ptPerUnit || unit in relativeUnit || unit === "ex"; +}; + +/* + * Convert a "size" parse node (with numeric "number" and string "unit" fields, + * as parsed by functions.js argType "size") into a CSS em value for the + * current style/scale. `options` gives the current options. + */ +const calculateSize = function (sizeValue, options) { + let scale; + if (sizeValue.unit in ptPerUnit) { + // Absolute units + scale = ptPerUnit[sizeValue.unit] // Convert unit to pt + / options.fontMetrics().ptPerEm // Convert pt to CSS em + / options.sizeMultiplier; // Unscale to make absolute units + } else if (sizeValue.unit === "mu") { + // `mu` units scale with scriptstyle/scriptscriptstyle. + scale = options.fontMetrics().cssEmPerMu; + } else { + // Other relative units always refer to the *textstyle* font + // in the current size. + let unitOptions; + if (options.style.isTight()) { + // isTight() means current style is script/scriptscript. + unitOptions = options.havingStyle(options.style.text()); + } else { + unitOptions = options; + } + // TODO: In TeX these units are relative to the quad of the current + // *text* font, e.g. cmr10. KaTeX instead uses values from the + // comparably-sized *Computer Modern symbol* font. At 10pt, these + // match. At 7pt and 5pt, they differ: cmr7=1.138894, cmsy7=1.170641; + // cmr5=1.361133, cmsy5=1.472241. Consider $\scriptsize a\kern1emb$. + // TeX \showlists shows a kern of 1.13889 * fontsize; + // KaTeX shows a kern of 1.171 * fontsize. + if (sizeValue.unit === "ex") { + scale = unitOptions.fontMetrics().xHeight; + } else if (sizeValue.unit === "em") { + scale = unitOptions.fontMetrics().quad; + } else { + throw new src_ParseError("Invalid unit: '" + sizeValue.unit + "'"); + } + if (unitOptions !== options) { + scale *= unitOptions.sizeMultiplier / options.sizeMultiplier; + } + } + return Math.min(sizeValue.number * scale, options.maxSize); +}; + +/** + * Round `n` to 4 decimal places, or to the nearest 1/10,000th em. See + * https://github.com/KaTeX/KaTeX/pull/2460. + */ +const makeEm = function (n) { + return +n.toFixed(4) + "em"; +}; +;// ./src/domTree.ts +/** + * These objects store the data about the DOM nodes we create, as well as some + * extra data. They can then be transformed into real DOM nodes with the + * `toNode` function or HTML markup using `toMarkup`. They are useful for both + * storing extra properties on the nodes, as well as providing a way to easily + * work with the DOM. + * + * Similar functions for working with MathML nodes exist in mathMLTree.js. + * + * TODO: refactor `span` and `anchor` into common superclass when + * target environments support class inheritance + */ + + + + + + +/** + * Create an HTML className based on a list of classes. In addition to joining + * with spaces, we also remove empty classes. + */ +const createClass = function (classes) { + return classes.filter(cls => cls).join(" "); +}; + +/** + * Serialize a CssStyle object into a semicolon-delimited inline-style string + * (hyphenating camelCase property names). Returns "" when no property is set. + */ +const cssStyleToString = function (style) { + let styles = ""; + for (const key of Object.keys(style)) { + const value = style[key]; + if (value !== undefined) { + styles += hyphenate(key) + ":" + value + ";"; + } + } + return styles; +}; +const initNode = function (classes, options, style) { + this.classes = classes || []; + this.attributes = {}; + this.height = 0; + this.depth = 0; + this.maxFontSize = 0; + this.style = style || {}; + if (options) { + if (options.style.isTight()) { + this.classes.push("mtight"); + } + const color = options.getColor(); + if (color) { + this.style.color = color; + } + } +}; + +/** + * Convert into an HTML node + */ +const toNode = function (tagName) { + const node = document.createElement(tagName); + + // Apply the class + node.className = createClass(this.classes); + + // Apply inline styles + Object.assign(node.style, this.style); + + // Apply attributes + for (const attr of Object.keys(this.attributes)) { + node.setAttribute(attr, this.attributes[attr]); + } + + // Append the children, also as HTML nodes + for (let i = 0; i < this.children.length; i++) { + node.appendChild(this.children[i].toNode()); + } + return node; +}; + +/** + * https://w3c.github.io/html-reference/syntax.html#syntax-attributes + * + * > Attribute Names must consist of one or more characters + * other than the space characters, U+0000 NULL, + * '"', "'", ">", "/", "=", the control characters, + * and any characters that are not defined by Unicode. + */ +const invalidAttributeNameRegex = /[\s"'>/=\x00-\x1f]/; + +/** + * Convert into an HTML markup string + */ +const toMarkup = function (tagName) { + let markup = "<" + tagName; + + // Add the class + if (this.classes.length) { + markup += " class=\"" + utils_escape(createClass(this.classes)) + "\""; + } + const styles = cssStyleToString(this.style); + if (styles) { + markup += " style=\"" + utils_escape(styles) + "\""; + } + + // Add the attributes + for (const attr of Object.keys(this.attributes)) { + if (invalidAttributeNameRegex.test(attr)) { + throw new src_ParseError("Invalid attribute name '" + attr + "'"); + } + markup += " " + attr + "=\"" + utils_escape(this.attributes[attr]) + "\""; + } + markup += ">"; + + // Add the markup of the children, also as markup + for (let i = 0; i < this.children.length; i++) { + markup += this.children[i].toMarkup(); + } + markup += ""; + return markup; +}; + +// Making the type below exact with all optional fields doesn't work due to +// - https://github.com/facebook/flow/issues/4582 +// - https://github.com/facebook/flow/issues/5688 +// However, since *all* fields are optional, $Shape<> works as suggested in 5688 +// above. +// This type does not include all CSS properties. Additional properties should +// be added as needed. + +// Span wrapping other DOM nodes. + +// Span wrapping an SVG node. + +/** + * This node represents a span node, with a className, a list of children, and + * an inline style. It also contains information about its height, depth, and + * maxFontSize. + * + * Represents two types with different uses: SvgSpan to wrap an SVG and DomSpan + * otherwise. This typesafety is important when HTML builders access a span's + * children. + */ +class Span { + constructor(classes, children, options, style) { + this.children = void 0; + this.attributes = void 0; + this.classes = void 0; + this.height = void 0; + this.depth = void 0; + this.width = void 0; + this.maxFontSize = void 0; + this.style = void 0; + /** + * Italic correction carried over from a SymbolNode when the symbol is + * wrapped in a vlist (e.g. \oiint / \oiiint). Read by supsub to adjust + * subscript positioning. Only set when nonzero; use `?? 0` at read sites. + */ + this.italic = void 0; + initNode.call(this, classes, options, style); + this.children = children || []; + } + + /** + * Sets an arbitrary attribute on the span. Warning: use this wisely. Not + * all browsers support attributes the same, and having too many custom + * attributes is probably bad. + */ + setAttribute(attribute, value) { + this.attributes[attribute] = value; + } + hasClass(className) { + return this.classes.includes(className); + } + toNode() { + return toNode.call(this, "span"); + } + toMarkup() { + return toMarkup.call(this, "span"); + } +} + +/** + * This node represents an anchor () element with a hyperlink. See `span` + * for further details. + */ +class Anchor { + constructor(href, classes, children, options) { + this.children = void 0; + this.attributes = void 0; + this.classes = void 0; + this.height = void 0; + this.depth = void 0; + this.maxFontSize = void 0; + this.style = void 0; + initNode.call(this, classes, options); + this.children = children || []; + this.setAttribute('href', href); + } + setAttribute(attribute, value) { + this.attributes[attribute] = value; + } + hasClass(className) { + return this.classes.includes(className); + } + toNode() { + return toNode.call(this, "a"); + } + toMarkup() { + return toMarkup.call(this, "a"); + } +} + +/** + * This node represents an image embed () element. + */ +class Img { + constructor(src, alt, style) { + this.src = void 0; + this.alt = void 0; + this.classes = void 0; + this.height = void 0; + this.depth = void 0; + this.maxFontSize = void 0; + this.style = void 0; + this.alt = alt; + this.src = src; + this.classes = ["mord"]; + this.height = 0; + this.depth = 0; + this.maxFontSize = 0; + this.style = style; + } + hasClass(className) { + return this.classes.includes(className); + } + toNode() { + const node = document.createElement("img"); + node.src = this.src; + node.alt = this.alt; + node.className = "mord"; + + // Apply inline styles + Object.assign(node.style, this.style); + return node; + } + toMarkup() { + let markup = "\"" 0) { + span = document.createElement("span"); + span.style.marginRight = makeEm(this.italic); + } + if (this.classes.length > 0) { + span = span || document.createElement("span"); + span.className = createClass(this.classes); + } + if (Object.keys(this.style).length > 0) { + span = span || document.createElement("span"); + Object.assign(span.style, this.style); + } + if (span) { + span.appendChild(node); + return span; + } else { + return node; + } + } + + /** + * Creates markup for a symbol node. + */ + toMarkup() { + // TODO(alpert): More duplication than I'd like from + // span.prototype.toMarkup and symbolNode.prototype.toNode... + let needsSpan = false; + let markup = " 0) { + styles += "margin-right:" + makeEm(this.italic) + ";"; + } + styles += cssStyleToString(this.style); + if (styles) { + needsSpan = true; + markup += " style=\"" + utils_escape(styles) + "\""; + } + const escaped = utils_escape(this.text); + if (needsSpan) { + markup += ">"; + markup += escaped; + markup += ""; + return markup; + } else { + return escaped; + } + } +} + +/** + * SVG nodes are used to render stretchy wide elements. + */ +class SvgNode { + constructor(children, attributes) { + this.children = void 0; + this.attributes = void 0; + this.children = children || []; + this.attributes = attributes || {}; + } + toNode() { + const svgNS = "http://www.w3.org/2000/svg"; + const node = document.createElementNS(svgNS, "svg"); + + // Apply attributes + for (const attr of Object.keys(this.attributes)) { + node.setAttribute(attr, this.attributes[attr]); + } + for (let i = 0; i < this.children.length; i++) { + node.appendChild(this.children[i].toNode()); + } + return node; + } + toMarkup() { + let markup = ""; + } else { + return ""; + } + } +} +class LineNode { + constructor(attributes) { + this.attributes = void 0; + this.attributes = attributes || {}; + } + toNode() { + const svgNS = "http://www.w3.org/2000/svg"; + const node = document.createElementNS(svgNS, "line"); + + // Apply attributes + for (const attr of Object.keys(this.attributes)) { + node.setAttribute(attr, this.attributes[attr]); + } + return node; + } + toMarkup() { + let markup = " but got " + String(group) + "."); + } +} + +/** + * Whether an HtmlDomNode has HtmlDomNode children. + * HtmlDomNode is a base type representing a union of + * SymbolNode, SvgSpan, DomSpan, Anchor, and documentFragment. + * In the last three cases, the children are HtmlDomNode[]. + */ +const hasHtmlDomChildren = node => node instanceof Span || node instanceof Anchor || node instanceof DocumentFragment; +;// ./src/fontMetricsData.js +// This file is GENERATED by buildMetrics.sh. DO NOT MODIFY. +/* harmony default export */ var fontMetricsData = ({ + "AMS-Regular": { + "32": [0, 0, 0, 0, 0.25], + "65": [0, 0.68889, 0, 0, 0.72222], + "66": [0, 0.68889, 0, 0, 0.66667], + "67": [0, 0.68889, 0, 0, 0.72222], + "68": [0, 0.68889, 0, 0, 0.72222], + "69": [0, 0.68889, 0, 0, 0.66667], + "70": [0, 0.68889, 0, 0, 0.61111], + "71": [0, 0.68889, 0, 0, 0.77778], + "72": [0, 0.68889, 0, 0, 0.77778], + "73": [0, 0.68889, 0, 0, 0.38889], + "74": [0.16667, 0.68889, 0, 0, 0.5], + "75": [0, 0.68889, 0, 0, 0.77778], + "76": [0, 0.68889, 0, 0, 0.66667], + "77": [0, 0.68889, 0, 0, 0.94445], + "78": [0, 0.68889, 0, 0, 0.72222], + "79": [0.16667, 0.68889, 0, 0, 0.77778], + "80": [0, 0.68889, 0, 0, 0.61111], + "81": [0.16667, 0.68889, 0, 0, 0.77778], + "82": [0, 0.68889, 0, 0, 0.72222], + "83": [0, 0.68889, 0, 0, 0.55556], + "84": [0, 0.68889, 0, 0, 0.66667], + "85": [0, 0.68889, 0, 0, 0.72222], + "86": [0, 0.68889, 0, 0, 0.72222], + "87": [0, 0.68889, 0, 0, 1.0], + "88": [0, 0.68889, 0, 0, 0.72222], + "89": [0, 0.68889, 0, 0, 0.72222], + "90": [0, 0.68889, 0, 0, 0.66667], + "107": [0, 0.68889, 0, 0, 0.55556], + "160": [0, 0, 0, 0, 0.25], + "165": [0, 0.675, 0.025, 0, 0.75], + "174": [0.15559, 0.69224, 0, 0, 0.94666], + "240": [0, 0.68889, 0, 0, 0.55556], + "295": [0, 0.68889, 0, 0, 0.54028], + "710": [0, 0.825, 0, 0, 2.33334], + "732": [0, 0.9, 0, 0, 2.33334], + "770": [0, 0.825, 0, 0, 2.33334], + "771": [0, 0.9, 0, 0, 2.33334], + "989": [0.08167, 0.58167, 0, 0, 0.77778], + "1008": [0, 0.43056, 0.04028, 0, 0.66667], + "8245": [0, 0.54986, 0, 0, 0.275], + "8463": [0, 0.68889, 0, 0, 0.54028], + "8487": [0, 0.68889, 0, 0, 0.72222], + "8498": [0, 0.68889, 0, 0, 0.55556], + "8502": [0, 0.68889, 0, 0, 0.66667], + "8503": [0, 0.68889, 0, 0, 0.44445], + "8504": [0, 0.68889, 0, 0, 0.66667], + "8513": [0, 0.68889, 0, 0, 0.63889], + "8592": [-0.03598, 0.46402, 0, 0, 0.5], + "8594": [-0.03598, 0.46402, 0, 0, 0.5], + "8602": [-0.13313, 0.36687, 0, 0, 1.0], + "8603": [-0.13313, 0.36687, 0, 0, 1.0], + "8606": [0.01354, 0.52239, 0, 0, 1.0], + "8608": [0.01354, 0.52239, 0, 0, 1.0], + "8610": [0.01354, 0.52239, 0, 0, 1.11111], + "8611": [0.01354, 0.52239, 0, 0, 1.11111], + "8619": [0, 0.54986, 0, 0, 1.0], + "8620": [0, 0.54986, 0, 0, 1.0], + "8621": [-0.13313, 0.37788, 0, 0, 1.38889], + "8622": [-0.13313, 0.36687, 0, 0, 1.0], + "8624": [0, 0.69224, 0, 0, 0.5], + "8625": [0, 0.69224, 0, 0, 0.5], + "8630": [0, 0.43056, 0, 0, 1.0], + "8631": [0, 0.43056, 0, 0, 1.0], + "8634": [0.08198, 0.58198, 0, 0, 0.77778], + "8635": [0.08198, 0.58198, 0, 0, 0.77778], + "8638": [0.19444, 0.69224, 0, 0, 0.41667], + "8639": [0.19444, 0.69224, 0, 0, 0.41667], + "8642": [0.19444, 0.69224, 0, 0, 0.41667], + "8643": [0.19444, 0.69224, 0, 0, 0.41667], + "8644": [0.1808, 0.675, 0, 0, 1.0], + "8646": [0.1808, 0.675, 0, 0, 1.0], + "8647": [0.1808, 0.675, 0, 0, 1.0], + "8648": [0.19444, 0.69224, 0, 0, 0.83334], + "8649": [0.1808, 0.675, 0, 0, 1.0], + "8650": [0.19444, 0.69224, 0, 0, 0.83334], + "8651": [0.01354, 0.52239, 0, 0, 1.0], + "8652": [0.01354, 0.52239, 0, 0, 1.0], + "8653": [-0.13313, 0.36687, 0, 0, 1.0], + "8654": [-0.13313, 0.36687, 0, 0, 1.0], + "8655": [-0.13313, 0.36687, 0, 0, 1.0], + "8666": [0.13667, 0.63667, 0, 0, 1.0], + "8667": [0.13667, 0.63667, 0, 0, 1.0], + "8669": [-0.13313, 0.37788, 0, 0, 1.0], + "8672": [-0.064, 0.437, 0, 0, 1.334], + "8674": [-0.064, 0.437, 0, 0, 1.334], + "8705": [0, 0.825, 0, 0, 0.5], + "8708": [0, 0.68889, 0, 0, 0.55556], + "8709": [0.08167, 0.58167, 0, 0, 0.77778], + "8717": [0, 0.43056, 0, 0, 0.42917], + "8722": [-0.03598, 0.46402, 0, 0, 0.5], + "8724": [0.08198, 0.69224, 0, 0, 0.77778], + "8726": [0.08167, 0.58167, 0, 0, 0.77778], + "8733": [0, 0.69224, 0, 0, 0.77778], + "8736": [0, 0.69224, 0, 0, 0.72222], + "8737": [0, 0.69224, 0, 0, 0.72222], + "8738": [0.03517, 0.52239, 0, 0, 0.72222], + "8739": [0.08167, 0.58167, 0, 0, 0.22222], + "8740": [0.25142, 0.74111, 0, 0, 0.27778], + "8741": [0.08167, 0.58167, 0, 0, 0.38889], + "8742": [0.25142, 0.74111, 0, 0, 0.5], + "8756": [0, 0.69224, 0, 0, 0.66667], + "8757": [0, 0.69224, 0, 0, 0.66667], + "8764": [-0.13313, 0.36687, 0, 0, 0.77778], + "8765": [-0.13313, 0.37788, 0, 0, 0.77778], + "8769": [-0.13313, 0.36687, 0, 0, 0.77778], + "8770": [-0.03625, 0.46375, 0, 0, 0.77778], + "8774": [0.30274, 0.79383, 0, 0, 0.77778], + "8776": [-0.01688, 0.48312, 0, 0, 0.77778], + "8778": [0.08167, 0.58167, 0, 0, 0.77778], + "8782": [0.06062, 0.54986, 0, 0, 0.77778], + "8783": [0.06062, 0.54986, 0, 0, 0.77778], + "8785": [0.08198, 0.58198, 0, 0, 0.77778], + "8786": [0.08198, 0.58198, 0, 0, 0.77778], + "8787": [0.08198, 0.58198, 0, 0, 0.77778], + "8790": [0, 0.69224, 0, 0, 0.77778], + "8791": [0.22958, 0.72958, 0, 0, 0.77778], + "8796": [0.08198, 0.91667, 0, 0, 0.77778], + "8806": [0.25583, 0.75583, 0, 0, 0.77778], + "8807": [0.25583, 0.75583, 0, 0, 0.77778], + "8808": [0.25142, 0.75726, 0, 0, 0.77778], + "8809": [0.25142, 0.75726, 0, 0, 0.77778], + "8812": [0.25583, 0.75583, 0, 0, 0.5], + "8814": [0.20576, 0.70576, 0, 0, 0.77778], + "8815": [0.20576, 0.70576, 0, 0, 0.77778], + "8816": [0.30274, 0.79383, 0, 0, 0.77778], + "8817": [0.30274, 0.79383, 0, 0, 0.77778], + "8818": [0.22958, 0.72958, 0, 0, 0.77778], + "8819": [0.22958, 0.72958, 0, 0, 0.77778], + "8822": [0.1808, 0.675, 0, 0, 0.77778], + "8823": [0.1808, 0.675, 0, 0, 0.77778], + "8828": [0.13667, 0.63667, 0, 0, 0.77778], + "8829": [0.13667, 0.63667, 0, 0, 0.77778], + "8830": [0.22958, 0.72958, 0, 0, 0.77778], + "8831": [0.22958, 0.72958, 0, 0, 0.77778], + "8832": [0.20576, 0.70576, 0, 0, 0.77778], + "8833": [0.20576, 0.70576, 0, 0, 0.77778], + "8840": [0.30274, 0.79383, 0, 0, 0.77778], + "8841": [0.30274, 0.79383, 0, 0, 0.77778], + "8842": [0.13597, 0.63597, 0, 0, 0.77778], + "8843": [0.13597, 0.63597, 0, 0, 0.77778], + "8847": [0.03517, 0.54986, 0, 0, 0.77778], + "8848": [0.03517, 0.54986, 0, 0, 0.77778], + "8858": [0.08198, 0.58198, 0, 0, 0.77778], + "8859": [0.08198, 0.58198, 0, 0, 0.77778], + "8861": [0.08198, 0.58198, 0, 0, 0.77778], + "8862": [0, 0.675, 0, 0, 0.77778], + "8863": [0, 0.675, 0, 0, 0.77778], + "8864": [0, 0.675, 0, 0, 0.77778], + "8865": [0, 0.675, 0, 0, 0.77778], + "8872": [0, 0.69224, 0, 0, 0.61111], + "8873": [0, 0.69224, 0, 0, 0.72222], + "8874": [0, 0.69224, 0, 0, 0.88889], + "8876": [0, 0.68889, 0, 0, 0.61111], + "8877": [0, 0.68889, 0, 0, 0.61111], + "8878": [0, 0.68889, 0, 0, 0.72222], + "8879": [0, 0.68889, 0, 0, 0.72222], + "8882": [0.03517, 0.54986, 0, 0, 0.77778], + "8883": [0.03517, 0.54986, 0, 0, 0.77778], + "8884": [0.13667, 0.63667, 0, 0, 0.77778], + "8885": [0.13667, 0.63667, 0, 0, 0.77778], + "8888": [0, 0.54986, 0, 0, 1.11111], + "8890": [0.19444, 0.43056, 0, 0, 0.55556], + "8891": [0.19444, 0.69224, 0, 0, 0.61111], + "8892": [0.19444, 0.69224, 0, 0, 0.61111], + "8901": [0, 0.54986, 0, 0, 0.27778], + "8903": [0.08167, 0.58167, 0, 0, 0.77778], + "8905": [0.08167, 0.58167, 0, 0, 0.77778], + "8906": [0.08167, 0.58167, 0, 0, 0.77778], + "8907": [0, 0.69224, 0, 0, 0.77778], + "8908": [0, 0.69224, 0, 0, 0.77778], + "8909": [-0.03598, 0.46402, 0, 0, 0.77778], + "8910": [0, 0.54986, 0, 0, 0.76042], + "8911": [0, 0.54986, 0, 0, 0.76042], + "8912": [0.03517, 0.54986, 0, 0, 0.77778], + "8913": [0.03517, 0.54986, 0, 0, 0.77778], + "8914": [0, 0.54986, 0, 0, 0.66667], + "8915": [0, 0.54986, 0, 0, 0.66667], + "8916": [0, 0.69224, 0, 0, 0.66667], + "8918": [0.0391, 0.5391, 0, 0, 0.77778], + "8919": [0.0391, 0.5391, 0, 0, 0.77778], + "8920": [0.03517, 0.54986, 0, 0, 1.33334], + "8921": [0.03517, 0.54986, 0, 0, 1.33334], + "8922": [0.38569, 0.88569, 0, 0, 0.77778], + "8923": [0.38569, 0.88569, 0, 0, 0.77778], + "8926": [0.13667, 0.63667, 0, 0, 0.77778], + "8927": [0.13667, 0.63667, 0, 0, 0.77778], + "8928": [0.30274, 0.79383, 0, 0, 0.77778], + "8929": [0.30274, 0.79383, 0, 0, 0.77778], + "8934": [0.23222, 0.74111, 0, 0, 0.77778], + "8935": [0.23222, 0.74111, 0, 0, 0.77778], + "8936": [0.23222, 0.74111, 0, 0, 0.77778], + "8937": [0.23222, 0.74111, 0, 0, 0.77778], + "8938": [0.20576, 0.70576, 0, 0, 0.77778], + "8939": [0.20576, 0.70576, 0, 0, 0.77778], + "8940": [0.30274, 0.79383, 0, 0, 0.77778], + "8941": [0.30274, 0.79383, 0, 0, 0.77778], + "8994": [0.19444, 0.69224, 0, 0, 0.77778], + "8995": [0.19444, 0.69224, 0, 0, 0.77778], + "9416": [0.15559, 0.69224, 0, 0, 0.90222], + "9484": [0, 0.69224, 0, 0, 0.5], + "9488": [0, 0.69224, 0, 0, 0.5], + "9492": [0, 0.37788, 0, 0, 0.5], + "9496": [0, 0.37788, 0, 0, 0.5], + "9585": [0.19444, 0.68889, 0, 0, 0.88889], + "9586": [0.19444, 0.74111, 0, 0, 0.88889], + "9632": [0, 0.675, 0, 0, 0.77778], + "9633": [0, 0.675, 0, 0, 0.77778], + "9650": [0, 0.54986, 0, 0, 0.72222], + "9651": [0, 0.54986, 0, 0, 0.72222], + "9654": [0.03517, 0.54986, 0, 0, 0.77778], + "9660": [0, 0.54986, 0, 0, 0.72222], + "9661": [0, 0.54986, 0, 0, 0.72222], + "9664": [0.03517, 0.54986, 0, 0, 0.77778], + "9674": [0.11111, 0.69224, 0, 0, 0.66667], + "9733": [0.19444, 0.69224, 0, 0, 0.94445], + "10003": [0, 0.69224, 0, 0, 0.83334], + "10016": [0, 0.69224, 0, 0, 0.83334], + "10731": [0.11111, 0.69224, 0, 0, 0.66667], + "10846": [0.19444, 0.75583, 0, 0, 0.61111], + "10877": [0.13667, 0.63667, 0, 0, 0.77778], + "10878": [0.13667, 0.63667, 0, 0, 0.77778], + "10885": [0.25583, 0.75583, 0, 0, 0.77778], + "10886": [0.25583, 0.75583, 0, 0, 0.77778], + "10887": [0.13597, 0.63597, 0, 0, 0.77778], + "10888": [0.13597, 0.63597, 0, 0, 0.77778], + "10889": [0.26167, 0.75726, 0, 0, 0.77778], + "10890": [0.26167, 0.75726, 0, 0, 0.77778], + "10891": [0.48256, 0.98256, 0, 0, 0.77778], + "10892": [0.48256, 0.98256, 0, 0, 0.77778], + "10901": [0.13667, 0.63667, 0, 0, 0.77778], + "10902": [0.13667, 0.63667, 0, 0, 0.77778], + "10933": [0.25142, 0.75726, 0, 0, 0.77778], + "10934": [0.25142, 0.75726, 0, 0, 0.77778], + "10935": [0.26167, 0.75726, 0, 0, 0.77778], + "10936": [0.26167, 0.75726, 0, 0, 0.77778], + "10937": [0.26167, 0.75726, 0, 0, 0.77778], + "10938": [0.26167, 0.75726, 0, 0, 0.77778], + "10949": [0.25583, 0.75583, 0, 0, 0.77778], + "10950": [0.25583, 0.75583, 0, 0, 0.77778], + "10955": [0.28481, 0.79383, 0, 0, 0.77778], + "10956": [0.28481, 0.79383, 0, 0, 0.77778], + "57350": [0.08167, 0.58167, 0, 0, 0.22222], + "57351": [0.08167, 0.58167, 0, 0, 0.38889], + "57352": [0.08167, 0.58167, 0, 0, 0.77778], + "57353": [0, 0.43056, 0.04028, 0, 0.66667], + "57356": [0.25142, 0.75726, 0, 0, 0.77778], + "57357": [0.25142, 0.75726, 0, 0, 0.77778], + "57358": [0.41951, 0.91951, 0, 0, 0.77778], + "57359": [0.30274, 0.79383, 0, 0, 0.77778], + "57360": [0.30274, 0.79383, 0, 0, 0.77778], + "57361": [0.41951, 0.91951, 0, 0, 0.77778], + "57366": [0.25142, 0.75726, 0, 0, 0.77778], + "57367": [0.25142, 0.75726, 0, 0, 0.77778], + "57368": [0.25142, 0.75726, 0, 0, 0.77778], + "57369": [0.25142, 0.75726, 0, 0, 0.77778], + "57370": [0.13597, 0.63597, 0, 0, 0.77778], + "57371": [0.13597, 0.63597, 0, 0, 0.77778] + }, + "Caligraphic-Regular": { + "32": [0, 0, 0, 0, 0.25], + "65": [0, 0.68333, 0, 0.19445, 0.79847], + "66": [0, 0.68333, 0.03041, 0.13889, 0.65681], + "67": [0, 0.68333, 0.05834, 0.13889, 0.52653], + "68": [0, 0.68333, 0.02778, 0.08334, 0.77139], + "69": [0, 0.68333, 0.08944, 0.11111, 0.52778], + "70": [0, 0.68333, 0.09931, 0.11111, 0.71875], + "71": [0.09722, 0.68333, 0.0593, 0.11111, 0.59487], + "72": [0, 0.68333, 0.00965, 0.11111, 0.84452], + "73": [0, 0.68333, 0.07382, 0, 0.54452], + "74": [0.09722, 0.68333, 0.18472, 0.16667, 0.67778], + "75": [0, 0.68333, 0.01445, 0.05556, 0.76195], + "76": [0, 0.68333, 0, 0.13889, 0.68972], + "77": [0, 0.68333, 0, 0.13889, 1.2009], + "78": [0, 0.68333, 0.14736, 0.08334, 0.82049], + "79": [0, 0.68333, 0.02778, 0.11111, 0.79611], + "80": [0, 0.68333, 0.08222, 0.08334, 0.69556], + "81": [0.09722, 0.68333, 0, 0.11111, 0.81667], + "82": [0, 0.68333, 0, 0.08334, 0.8475], + "83": [0, 0.68333, 0.075, 0.13889, 0.60556], + "84": [0, 0.68333, 0.25417, 0, 0.54464], + "85": [0, 0.68333, 0.09931, 0.08334, 0.62583], + "86": [0, 0.68333, 0.08222, 0, 0.61278], + "87": [0, 0.68333, 0.08222, 0.08334, 0.98778], + "88": [0, 0.68333, 0.14643, 0.13889, 0.7133], + "89": [0.09722, 0.68333, 0.08222, 0.08334, 0.66834], + "90": [0, 0.68333, 0.07944, 0.13889, 0.72473], + "160": [0, 0, 0, 0, 0.25] + }, + "Fraktur-Regular": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69141, 0, 0, 0.29574], + "34": [0, 0.69141, 0, 0, 0.21471], + "38": [0, 0.69141, 0, 0, 0.73786], + "39": [0, 0.69141, 0, 0, 0.21201], + "40": [0.24982, 0.74947, 0, 0, 0.38865], + "41": [0.24982, 0.74947, 0, 0, 0.38865], + "42": [0, 0.62119, 0, 0, 0.27764], + "43": [0.08319, 0.58283, 0, 0, 0.75623], + "44": [0, 0.10803, 0, 0, 0.27764], + "45": [0.08319, 0.58283, 0, 0, 0.75623], + "46": [0, 0.10803, 0, 0, 0.27764], + "47": [0.24982, 0.74947, 0, 0, 0.50181], + "48": [0, 0.47534, 0, 0, 0.50181], + "49": [0, 0.47534, 0, 0, 0.50181], + "50": [0, 0.47534, 0, 0, 0.50181], + "51": [0.18906, 0.47534, 0, 0, 0.50181], + "52": [0.18906, 0.47534, 0, 0, 0.50181], + "53": [0.18906, 0.47534, 0, 0, 0.50181], + "54": [0, 0.69141, 0, 0, 0.50181], + "55": [0.18906, 0.47534, 0, 0, 0.50181], + "56": [0, 0.69141, 0, 0, 0.50181], + "57": [0.18906, 0.47534, 0, 0, 0.50181], + "58": [0, 0.47534, 0, 0, 0.21606], + "59": [0.12604, 0.47534, 0, 0, 0.21606], + "61": [-0.13099, 0.36866, 0, 0, 0.75623], + "63": [0, 0.69141, 0, 0, 0.36245], + "65": [0, 0.69141, 0, 0, 0.7176], + "66": [0, 0.69141, 0, 0, 0.88397], + "67": [0, 0.69141, 0, 0, 0.61254], + "68": [0, 0.69141, 0, 0, 0.83158], + "69": [0, 0.69141, 0, 0, 0.66278], + "70": [0.12604, 0.69141, 0, 0, 0.61119], + "71": [0, 0.69141, 0, 0, 0.78539], + "72": [0.06302, 0.69141, 0, 0, 0.7203], + "73": [0, 0.69141, 0, 0, 0.55448], + "74": [0.12604, 0.69141, 0, 0, 0.55231], + "75": [0, 0.69141, 0, 0, 0.66845], + "76": [0, 0.69141, 0, 0, 0.66602], + "77": [0, 0.69141, 0, 0, 1.04953], + "78": [0, 0.69141, 0, 0, 0.83212], + "79": [0, 0.69141, 0, 0, 0.82699], + "80": [0.18906, 0.69141, 0, 0, 0.82753], + "81": [0.03781, 0.69141, 0, 0, 0.82699], + "82": [0, 0.69141, 0, 0, 0.82807], + "83": [0, 0.69141, 0, 0, 0.82861], + "84": [0, 0.69141, 0, 0, 0.66899], + "85": [0, 0.69141, 0, 0, 0.64576], + "86": [0, 0.69141, 0, 0, 0.83131], + "87": [0, 0.69141, 0, 0, 1.04602], + "88": [0, 0.69141, 0, 0, 0.71922], + "89": [0.18906, 0.69141, 0, 0, 0.83293], + "90": [0.12604, 0.69141, 0, 0, 0.60201], + "91": [0.24982, 0.74947, 0, 0, 0.27764], + "93": [0.24982, 0.74947, 0, 0, 0.27764], + "94": [0, 0.69141, 0, 0, 0.49965], + "97": [0, 0.47534, 0, 0, 0.50046], + "98": [0, 0.69141, 0, 0, 0.51315], + "99": [0, 0.47534, 0, 0, 0.38946], + "100": [0, 0.62119, 0, 0, 0.49857], + "101": [0, 0.47534, 0, 0, 0.40053], + "102": [0.18906, 0.69141, 0, 0, 0.32626], + "103": [0.18906, 0.47534, 0, 0, 0.5037], + "104": [0.18906, 0.69141, 0, 0, 0.52126], + "105": [0, 0.69141, 0, 0, 0.27899], + "106": [0, 0.69141, 0, 0, 0.28088], + "107": [0, 0.69141, 0, 0, 0.38946], + "108": [0, 0.69141, 0, 0, 0.27953], + "109": [0, 0.47534, 0, 0, 0.76676], + "110": [0, 0.47534, 0, 0, 0.52666], + "111": [0, 0.47534, 0, 0, 0.48885], + "112": [0.18906, 0.52396, 0, 0, 0.50046], + "113": [0.18906, 0.47534, 0, 0, 0.48912], + "114": [0, 0.47534, 0, 0, 0.38919], + "115": [0, 0.47534, 0, 0, 0.44266], + "116": [0, 0.62119, 0, 0, 0.33301], + "117": [0, 0.47534, 0, 0, 0.5172], + "118": [0, 0.52396, 0, 0, 0.5118], + "119": [0, 0.52396, 0, 0, 0.77351], + "120": [0.18906, 0.47534, 0, 0, 0.38865], + "121": [0.18906, 0.47534, 0, 0, 0.49884], + "122": [0.18906, 0.47534, 0, 0, 0.39054], + "160": [0, 0, 0, 0, 0.25], + "8216": [0, 0.69141, 0, 0, 0.21471], + "8217": [0, 0.69141, 0, 0, 0.21471], + "58112": [0, 0.62119, 0, 0, 0.49749], + "58113": [0, 0.62119, 0, 0, 0.4983], + "58114": [0.18906, 0.69141, 0, 0, 0.33328], + "58115": [0.18906, 0.69141, 0, 0, 0.32923], + "58116": [0.18906, 0.47534, 0, 0, 0.50343], + "58117": [0, 0.69141, 0, 0, 0.33301], + "58118": [0, 0.62119, 0, 0, 0.33409], + "58119": [0, 0.47534, 0, 0, 0.50073] + }, + "Main-Bold": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0, 0, 0.35], + "34": [0, 0.69444, 0, 0, 0.60278], + "35": [0.19444, 0.69444, 0, 0, 0.95833], + "36": [0.05556, 0.75, 0, 0, 0.575], + "37": [0.05556, 0.75, 0, 0, 0.95833], + "38": [0, 0.69444, 0, 0, 0.89444], + "39": [0, 0.69444, 0, 0, 0.31944], + "40": [0.25, 0.75, 0, 0, 0.44722], + "41": [0.25, 0.75, 0, 0, 0.44722], + "42": [0, 0.75, 0, 0, 0.575], + "43": [0.13333, 0.63333, 0, 0, 0.89444], + "44": [0.19444, 0.15556, 0, 0, 0.31944], + "45": [0, 0.44444, 0, 0, 0.38333], + "46": [0, 0.15556, 0, 0, 0.31944], + "47": [0.25, 0.75, 0, 0, 0.575], + "48": [0, 0.64444, 0, 0, 0.575], + "49": [0, 0.64444, 0, 0, 0.575], + "50": [0, 0.64444, 0, 0, 0.575], + "51": [0, 0.64444, 0, 0, 0.575], + "52": [0, 0.64444, 0, 0, 0.575], + "53": [0, 0.64444, 0, 0, 0.575], + "54": [0, 0.64444, 0, 0, 0.575], + "55": [0, 0.64444, 0, 0, 0.575], + "56": [0, 0.64444, 0, 0, 0.575], + "57": [0, 0.64444, 0, 0, 0.575], + "58": [0, 0.44444, 0, 0, 0.31944], + "59": [0.19444, 0.44444, 0, 0, 0.31944], + "60": [0.08556, 0.58556, 0, 0, 0.89444], + "61": [-0.10889, 0.39111, 0, 0, 0.89444], + "62": [0.08556, 0.58556, 0, 0, 0.89444], + "63": [0, 0.69444, 0, 0, 0.54305], + "64": [0, 0.69444, 0, 0, 0.89444], + "65": [0, 0.68611, 0, 0, 0.86944], + "66": [0, 0.68611, 0, 0, 0.81805], + "67": [0, 0.68611, 0, 0, 0.83055], + "68": [0, 0.68611, 0, 0, 0.88194], + "69": [0, 0.68611, 0, 0, 0.75555], + "70": [0, 0.68611, 0, 0, 0.72361], + "71": [0, 0.68611, 0, 0, 0.90416], + "72": [0, 0.68611, 0, 0, 0.9], + "73": [0, 0.68611, 0, 0, 0.43611], + "74": [0, 0.68611, 0, 0, 0.59444], + "75": [0, 0.68611, 0, 0, 0.90138], + "76": [0, 0.68611, 0, 0, 0.69166], + "77": [0, 0.68611, 0, 0, 1.09166], + "78": [0, 0.68611, 0, 0, 0.9], + "79": [0, 0.68611, 0, 0, 0.86388], + "80": [0, 0.68611, 0, 0, 0.78611], + "81": [0.19444, 0.68611, 0, 0, 0.86388], + "82": [0, 0.68611, 0, 0, 0.8625], + "83": [0, 0.68611, 0, 0, 0.63889], + "84": [0, 0.68611, 0, 0, 0.8], + "85": [0, 0.68611, 0, 0, 0.88472], + "86": [0, 0.68611, 0.01597, 0, 0.86944], + "87": [0, 0.68611, 0.01597, 0, 1.18888], + "88": [0, 0.68611, 0, 0, 0.86944], + "89": [0, 0.68611, 0.02875, 0, 0.86944], + "90": [0, 0.68611, 0, 0, 0.70277], + "91": [0.25, 0.75, 0, 0, 0.31944], + "92": [0.25, 0.75, 0, 0, 0.575], + "93": [0.25, 0.75, 0, 0, 0.31944], + "94": [0, 0.69444, 0, 0, 0.575], + "95": [0.31, 0.13444, 0.03194, 0, 0.575], + "97": [0, 0.44444, 0, 0, 0.55902], + "98": [0, 0.69444, 0, 0, 0.63889], + "99": [0, 0.44444, 0, 0, 0.51111], + "100": [0, 0.69444, 0, 0, 0.63889], + "101": [0, 0.44444, 0, 0, 0.52708], + "102": [0, 0.69444, 0.10903, 0, 0.35139], + "103": [0.19444, 0.44444, 0.01597, 0, 0.575], + "104": [0, 0.69444, 0, 0, 0.63889], + "105": [0, 0.69444, 0, 0, 0.31944], + "106": [0.19444, 0.69444, 0, 0, 0.35139], + "107": [0, 0.69444, 0, 0, 0.60694], + "108": [0, 0.69444, 0, 0, 0.31944], + "109": [0, 0.44444, 0, 0, 0.95833], + "110": [0, 0.44444, 0, 0, 0.63889], + "111": [0, 0.44444, 0, 0, 0.575], + "112": [0.19444, 0.44444, 0, 0, 0.63889], + "113": [0.19444, 0.44444, 0, 0, 0.60694], + "114": [0, 0.44444, 0, 0, 0.47361], + "115": [0, 0.44444, 0, 0, 0.45361], + "116": [0, 0.63492, 0, 0, 0.44722], + "117": [0, 0.44444, 0, 0, 0.63889], + "118": [0, 0.44444, 0.01597, 0, 0.60694], + "119": [0, 0.44444, 0.01597, 0, 0.83055], + "120": [0, 0.44444, 0, 0, 0.60694], + "121": [0.19444, 0.44444, 0.01597, 0, 0.60694], + "122": [0, 0.44444, 0, 0, 0.51111], + "123": [0.25, 0.75, 0, 0, 0.575], + "124": [0.25, 0.75, 0, 0, 0.31944], + "125": [0.25, 0.75, 0, 0, 0.575], + "126": [0.35, 0.34444, 0, 0, 0.575], + "160": [0, 0, 0, 0, 0.25], + "163": [0, 0.69444, 0, 0, 0.86853], + "168": [0, 0.69444, 0, 0, 0.575], + "172": [0, 0.44444, 0, 0, 0.76666], + "176": [0, 0.69444, 0, 0, 0.86944], + "177": [0.13333, 0.63333, 0, 0, 0.89444], + "184": [0.17014, 0, 0, 0, 0.51111], + "198": [0, 0.68611, 0, 0, 1.04166], + "215": [0.13333, 0.63333, 0, 0, 0.89444], + "216": [0.04861, 0.73472, 0, 0, 0.89444], + "223": [0, 0.69444, 0, 0, 0.59722], + "230": [0, 0.44444, 0, 0, 0.83055], + "247": [0.13333, 0.63333, 0, 0, 0.89444], + "248": [0.09722, 0.54167, 0, 0, 0.575], + "305": [0, 0.44444, 0, 0, 0.31944], + "338": [0, 0.68611, 0, 0, 1.16944], + "339": [0, 0.44444, 0, 0, 0.89444], + "567": [0.19444, 0.44444, 0, 0, 0.35139], + "710": [0, 0.69444, 0, 0, 0.575], + "711": [0, 0.63194, 0, 0, 0.575], + "713": [0, 0.59611, 0, 0, 0.575], + "714": [0, 0.69444, 0, 0, 0.575], + "715": [0, 0.69444, 0, 0, 0.575], + "728": [0, 0.69444, 0, 0, 0.575], + "729": [0, 0.69444, 0, 0, 0.31944], + "730": [0, 0.69444, 0, 0, 0.86944], + "732": [0, 0.69444, 0, 0, 0.575], + "733": [0, 0.69444, 0, 0, 0.575], + "915": [0, 0.68611, 0, 0, 0.69166], + "916": [0, 0.68611, 0, 0, 0.95833], + "920": [0, 0.68611, 0, 0, 0.89444], + "923": [0, 0.68611, 0, 0, 0.80555], + "926": [0, 0.68611, 0, 0, 0.76666], + "928": [0, 0.68611, 0, 0, 0.9], + "931": [0, 0.68611, 0, 0, 0.83055], + "933": [0, 0.68611, 0, 0, 0.89444], + "934": [0, 0.68611, 0, 0, 0.83055], + "936": [0, 0.68611, 0, 0, 0.89444], + "937": [0, 0.68611, 0, 0, 0.83055], + "8211": [0, 0.44444, 0.03194, 0, 0.575], + "8212": [0, 0.44444, 0.03194, 0, 1.14999], + "8216": [0, 0.69444, 0, 0, 0.31944], + "8217": [0, 0.69444, 0, 0, 0.31944], + "8220": [0, 0.69444, 0, 0, 0.60278], + "8221": [0, 0.69444, 0, 0, 0.60278], + "8224": [0.19444, 0.69444, 0, 0, 0.51111], + "8225": [0.19444, 0.69444, 0, 0, 0.51111], + "8242": [0, 0.55556, 0, 0, 0.34444], + "8407": [0, 0.72444, 0.15486, 0, 0.575], + "8463": [0, 0.69444, 0, 0, 0.66759], + "8465": [0, 0.69444, 0, 0, 0.83055], + "8467": [0, 0.69444, 0, 0, 0.47361], + "8472": [0.19444, 0.44444, 0, 0, 0.74027], + "8476": [0, 0.69444, 0, 0, 0.83055], + "8501": [0, 0.69444, 0, 0, 0.70277], + "8592": [-0.10889, 0.39111, 0, 0, 1.14999], + "8593": [0.19444, 0.69444, 0, 0, 0.575], + "8594": [-0.10889, 0.39111, 0, 0, 1.14999], + "8595": [0.19444, 0.69444, 0, 0, 0.575], + "8596": [-0.10889, 0.39111, 0, 0, 1.14999], + "8597": [0.25, 0.75, 0, 0, 0.575], + "8598": [0.19444, 0.69444, 0, 0, 1.14999], + "8599": [0.19444, 0.69444, 0, 0, 1.14999], + "8600": [0.19444, 0.69444, 0, 0, 1.14999], + "8601": [0.19444, 0.69444, 0, 0, 1.14999], + "8636": [-0.10889, 0.39111, 0, 0, 1.14999], + "8637": [-0.10889, 0.39111, 0, 0, 1.14999], + "8640": [-0.10889, 0.39111, 0, 0, 1.14999], + "8641": [-0.10889, 0.39111, 0, 0, 1.14999], + "8656": [-0.10889, 0.39111, 0, 0, 1.14999], + "8657": [0.19444, 0.69444, 0, 0, 0.70277], + "8658": [-0.10889, 0.39111, 0, 0, 1.14999], + "8659": [0.19444, 0.69444, 0, 0, 0.70277], + "8660": [-0.10889, 0.39111, 0, 0, 1.14999], + "8661": [0.25, 0.75, 0, 0, 0.70277], + "8704": [0, 0.69444, 0, 0, 0.63889], + "8706": [0, 0.69444, 0.06389, 0, 0.62847], + "8707": [0, 0.69444, 0, 0, 0.63889], + "8709": [0.05556, 0.75, 0, 0, 0.575], + "8711": [0, 0.68611, 0, 0, 0.95833], + "8712": [0.08556, 0.58556, 0, 0, 0.76666], + "8715": [0.08556, 0.58556, 0, 0, 0.76666], + "8722": [0.13333, 0.63333, 0, 0, 0.89444], + "8723": [0.13333, 0.63333, 0, 0, 0.89444], + "8725": [0.25, 0.75, 0, 0, 0.575], + "8726": [0.25, 0.75, 0, 0, 0.575], + "8727": [-0.02778, 0.47222, 0, 0, 0.575], + "8728": [-0.02639, 0.47361, 0, 0, 0.575], + "8729": [-0.02639, 0.47361, 0, 0, 0.575], + "8730": [0.18, 0.82, 0, 0, 0.95833], + "8733": [0, 0.44444, 0, 0, 0.89444], + "8734": [0, 0.44444, 0, 0, 1.14999], + "8736": [0, 0.69224, 0, 0, 0.72222], + "8739": [0.25, 0.75, 0, 0, 0.31944], + "8741": [0.25, 0.75, 0, 0, 0.575], + "8743": [0, 0.55556, 0, 0, 0.76666], + "8744": [0, 0.55556, 0, 0, 0.76666], + "8745": [0, 0.55556, 0, 0, 0.76666], + "8746": [0, 0.55556, 0, 0, 0.76666], + "8747": [0.19444, 0.69444, 0.12778, 0, 0.56875], + "8764": [-0.10889, 0.39111, 0, 0, 0.89444], + "8768": [0.19444, 0.69444, 0, 0, 0.31944], + "8771": [0.00222, 0.50222, 0, 0, 0.89444], + "8773": [0.027, 0.638, 0, 0, 0.894], + "8776": [0.02444, 0.52444, 0, 0, 0.89444], + "8781": [0.00222, 0.50222, 0, 0, 0.89444], + "8801": [0.00222, 0.50222, 0, 0, 0.89444], + "8804": [0.19667, 0.69667, 0, 0, 0.89444], + "8805": [0.19667, 0.69667, 0, 0, 0.89444], + "8810": [0.08556, 0.58556, 0, 0, 1.14999], + "8811": [0.08556, 0.58556, 0, 0, 1.14999], + "8826": [0.08556, 0.58556, 0, 0, 0.89444], + "8827": [0.08556, 0.58556, 0, 0, 0.89444], + "8834": [0.08556, 0.58556, 0, 0, 0.89444], + "8835": [0.08556, 0.58556, 0, 0, 0.89444], + "8838": [0.19667, 0.69667, 0, 0, 0.89444], + "8839": [0.19667, 0.69667, 0, 0, 0.89444], + "8846": [0, 0.55556, 0, 0, 0.76666], + "8849": [0.19667, 0.69667, 0, 0, 0.89444], + "8850": [0.19667, 0.69667, 0, 0, 0.89444], + "8851": [0, 0.55556, 0, 0, 0.76666], + "8852": [0, 0.55556, 0, 0, 0.76666], + "8853": [0.13333, 0.63333, 0, 0, 0.89444], + "8854": [0.13333, 0.63333, 0, 0, 0.89444], + "8855": [0.13333, 0.63333, 0, 0, 0.89444], + "8856": [0.13333, 0.63333, 0, 0, 0.89444], + "8857": [0.13333, 0.63333, 0, 0, 0.89444], + "8866": [0, 0.69444, 0, 0, 0.70277], + "8867": [0, 0.69444, 0, 0, 0.70277], + "8868": [0, 0.69444, 0, 0, 0.89444], + "8869": [0, 0.69444, 0, 0, 0.89444], + "8900": [-0.02639, 0.47361, 0, 0, 0.575], + "8901": [-0.02639, 0.47361, 0, 0, 0.31944], + "8902": [-0.02778, 0.47222, 0, 0, 0.575], + "8968": [0.25, 0.75, 0, 0, 0.51111], + "8969": [0.25, 0.75, 0, 0, 0.51111], + "8970": [0.25, 0.75, 0, 0, 0.51111], + "8971": [0.25, 0.75, 0, 0, 0.51111], + "8994": [-0.13889, 0.36111, 0, 0, 1.14999], + "8995": [-0.13889, 0.36111, 0, 0, 1.14999], + "9651": [0.19444, 0.69444, 0, 0, 1.02222], + "9657": [-0.02778, 0.47222, 0, 0, 0.575], + "9661": [0.19444, 0.69444, 0, 0, 1.02222], + "9667": [-0.02778, 0.47222, 0, 0, 0.575], + "9711": [0.19444, 0.69444, 0, 0, 1.14999], + "9824": [0.12963, 0.69444, 0, 0, 0.89444], + "9825": [0.12963, 0.69444, 0, 0, 0.89444], + "9826": [0.12963, 0.69444, 0, 0, 0.89444], + "9827": [0.12963, 0.69444, 0, 0, 0.89444], + "9837": [0, 0.75, 0, 0, 0.44722], + "9838": [0.19444, 0.69444, 0, 0, 0.44722], + "9839": [0.19444, 0.69444, 0, 0, 0.44722], + "10216": [0.25, 0.75, 0, 0, 0.44722], + "10217": [0.25, 0.75, 0, 0, 0.44722], + "10815": [0, 0.68611, 0, 0, 0.9], + "10927": [0.19667, 0.69667, 0, 0, 0.89444], + "10928": [0.19667, 0.69667, 0, 0, 0.89444], + "57376": [0.19444, 0.69444, 0, 0, 0] + }, + "Main-BoldItalic": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0.11417, 0, 0.38611], + "34": [0, 0.69444, 0.07939, 0, 0.62055], + "35": [0.19444, 0.69444, 0.06833, 0, 0.94444], + "37": [0.05556, 0.75, 0.12861, 0, 0.94444], + "38": [0, 0.69444, 0.08528, 0, 0.88555], + "39": [0, 0.69444, 0.12945, 0, 0.35555], + "40": [0.25, 0.75, 0.15806, 0, 0.47333], + "41": [0.25, 0.75, 0.03306, 0, 0.47333], + "42": [0, 0.75, 0.14333, 0, 0.59111], + "43": [0.10333, 0.60333, 0.03306, 0, 0.88555], + "44": [0.19444, 0.14722, 0, 0, 0.35555], + "45": [0, 0.44444, 0.02611, 0, 0.41444], + "46": [0, 0.14722, 0, 0, 0.35555], + "47": [0.25, 0.75, 0.15806, 0, 0.59111], + "48": [0, 0.64444, 0.13167, 0, 0.59111], + "49": [0, 0.64444, 0.13167, 0, 0.59111], + "50": [0, 0.64444, 0.13167, 0, 0.59111], + "51": [0, 0.64444, 0.13167, 0, 0.59111], + "52": [0.19444, 0.64444, 0.13167, 0, 0.59111], + "53": [0, 0.64444, 0.13167, 0, 0.59111], + "54": [0, 0.64444, 0.13167, 0, 0.59111], + "55": [0.19444, 0.64444, 0.13167, 0, 0.59111], + "56": [0, 0.64444, 0.13167, 0, 0.59111], + "57": [0, 0.64444, 0.13167, 0, 0.59111], + "58": [0, 0.44444, 0.06695, 0, 0.35555], + "59": [0.19444, 0.44444, 0.06695, 0, 0.35555], + "61": [-0.10889, 0.39111, 0.06833, 0, 0.88555], + "63": [0, 0.69444, 0.11472, 0, 0.59111], + "64": [0, 0.69444, 0.09208, 0, 0.88555], + "65": [0, 0.68611, 0, 0, 0.86555], + "66": [0, 0.68611, 0.0992, 0, 0.81666], + "67": [0, 0.68611, 0.14208, 0, 0.82666], + "68": [0, 0.68611, 0.09062, 0, 0.87555], + "69": [0, 0.68611, 0.11431, 0, 0.75666], + "70": [0, 0.68611, 0.12903, 0, 0.72722], + "71": [0, 0.68611, 0.07347, 0, 0.89527], + "72": [0, 0.68611, 0.17208, 0, 0.8961], + "73": [0, 0.68611, 0.15681, 0, 0.47166], + "74": [0, 0.68611, 0.145, 0, 0.61055], + "75": [0, 0.68611, 0.14208, 0, 0.89499], + "76": [0, 0.68611, 0, 0, 0.69777], + "77": [0, 0.68611, 0.17208, 0, 1.07277], + "78": [0, 0.68611, 0.17208, 0, 0.8961], + "79": [0, 0.68611, 0.09062, 0, 0.85499], + "80": [0, 0.68611, 0.0992, 0, 0.78721], + "81": [0.19444, 0.68611, 0.09062, 0, 0.85499], + "82": [0, 0.68611, 0.02559, 0, 0.85944], + "83": [0, 0.68611, 0.11264, 0, 0.64999], + "84": [0, 0.68611, 0.12903, 0, 0.7961], + "85": [0, 0.68611, 0.17208, 0, 0.88083], + "86": [0, 0.68611, 0.18625, 0, 0.86555], + "87": [0, 0.68611, 0.18625, 0, 1.15999], + "88": [0, 0.68611, 0.15681, 0, 0.86555], + "89": [0, 0.68611, 0.19803, 0, 0.86555], + "90": [0, 0.68611, 0.14208, 0, 0.70888], + "91": [0.25, 0.75, 0.1875, 0, 0.35611], + "93": [0.25, 0.75, 0.09972, 0, 0.35611], + "94": [0, 0.69444, 0.06709, 0, 0.59111], + "95": [0.31, 0.13444, 0.09811, 0, 0.59111], + "97": [0, 0.44444, 0.09426, 0, 0.59111], + "98": [0, 0.69444, 0.07861, 0, 0.53222], + "99": [0, 0.44444, 0.05222, 0, 0.53222], + "100": [0, 0.69444, 0.10861, 0, 0.59111], + "101": [0, 0.44444, 0.085, 0, 0.53222], + "102": [0.19444, 0.69444, 0.21778, 0, 0.4], + "103": [0.19444, 0.44444, 0.105, 0, 0.53222], + "104": [0, 0.69444, 0.09426, 0, 0.59111], + "105": [0, 0.69326, 0.11387, 0, 0.35555], + "106": [0.19444, 0.69326, 0.1672, 0, 0.35555], + "107": [0, 0.69444, 0.11111, 0, 0.53222], + "108": [0, 0.69444, 0.10861, 0, 0.29666], + "109": [0, 0.44444, 0.09426, 0, 0.94444], + "110": [0, 0.44444, 0.09426, 0, 0.64999], + "111": [0, 0.44444, 0.07861, 0, 0.59111], + "112": [0.19444, 0.44444, 0.07861, 0, 0.59111], + "113": [0.19444, 0.44444, 0.105, 0, 0.53222], + "114": [0, 0.44444, 0.11111, 0, 0.50167], + "115": [0, 0.44444, 0.08167, 0, 0.48694], + "116": [0, 0.63492, 0.09639, 0, 0.385], + "117": [0, 0.44444, 0.09426, 0, 0.62055], + "118": [0, 0.44444, 0.11111, 0, 0.53222], + "119": [0, 0.44444, 0.11111, 0, 0.76777], + "120": [0, 0.44444, 0.12583, 0, 0.56055], + "121": [0.19444, 0.44444, 0.105, 0, 0.56166], + "122": [0, 0.44444, 0.13889, 0, 0.49055], + "126": [0.35, 0.34444, 0.11472, 0, 0.59111], + "160": [0, 0, 0, 0, 0.25], + "168": [0, 0.69444, 0.11473, 0, 0.59111], + "176": [0, 0.69444, 0, 0, 0.94888], + "184": [0.17014, 0, 0, 0, 0.53222], + "198": [0, 0.68611, 0.11431, 0, 1.02277], + "216": [0.04861, 0.73472, 0.09062, 0, 0.88555], + "223": [0.19444, 0.69444, 0.09736, 0, 0.665], + "230": [0, 0.44444, 0.085, 0, 0.82666], + "248": [0.09722, 0.54167, 0.09458, 0, 0.59111], + "305": [0, 0.44444, 0.09426, 0, 0.35555], + "338": [0, 0.68611, 0.11431, 0, 1.14054], + "339": [0, 0.44444, 0.085, 0, 0.82666], + "567": [0.19444, 0.44444, 0.04611, 0, 0.385], + "710": [0, 0.69444, 0.06709, 0, 0.59111], + "711": [0, 0.63194, 0.08271, 0, 0.59111], + "713": [0, 0.59444, 0.10444, 0, 0.59111], + "714": [0, 0.69444, 0.08528, 0, 0.59111], + "715": [0, 0.69444, 0, 0, 0.59111], + "728": [0, 0.69444, 0.10333, 0, 0.59111], + "729": [0, 0.69444, 0.12945, 0, 0.35555], + "730": [0, 0.69444, 0, 0, 0.94888], + "732": [0, 0.69444, 0.11472, 0, 0.59111], + "733": [0, 0.69444, 0.11472, 0, 0.59111], + "915": [0, 0.68611, 0.12903, 0, 0.69777], + "916": [0, 0.68611, 0, 0, 0.94444], + "920": [0, 0.68611, 0.09062, 0, 0.88555], + "923": [0, 0.68611, 0, 0, 0.80666], + "926": [0, 0.68611, 0.15092, 0, 0.76777], + "928": [0, 0.68611, 0.17208, 0, 0.8961], + "931": [0, 0.68611, 0.11431, 0, 0.82666], + "933": [0, 0.68611, 0.10778, 0, 0.88555], + "934": [0, 0.68611, 0.05632, 0, 0.82666], + "936": [0, 0.68611, 0.10778, 0, 0.88555], + "937": [0, 0.68611, 0.0992, 0, 0.82666], + "8211": [0, 0.44444, 0.09811, 0, 0.59111], + "8212": [0, 0.44444, 0.09811, 0, 1.18221], + "8216": [0, 0.69444, 0.12945, 0, 0.35555], + "8217": [0, 0.69444, 0.12945, 0, 0.35555], + "8220": [0, 0.69444, 0.16772, 0, 0.62055], + "8221": [0, 0.69444, 0.07939, 0, 0.62055] + }, + "Main-Italic": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0.12417, 0, 0.30667], + "34": [0, 0.69444, 0.06961, 0, 0.51444], + "35": [0.19444, 0.69444, 0.06616, 0, 0.81777], + "37": [0.05556, 0.75, 0.13639, 0, 0.81777], + "38": [0, 0.69444, 0.09694, 0, 0.76666], + "39": [0, 0.69444, 0.12417, 0, 0.30667], + "40": [0.25, 0.75, 0.16194, 0, 0.40889], + "41": [0.25, 0.75, 0.03694, 0, 0.40889], + "42": [0, 0.75, 0.14917, 0, 0.51111], + "43": [0.05667, 0.56167, 0.03694, 0, 0.76666], + "44": [0.19444, 0.10556, 0, 0, 0.30667], + "45": [0, 0.43056, 0.02826, 0, 0.35778], + "46": [0, 0.10556, 0, 0, 0.30667], + "47": [0.25, 0.75, 0.16194, 0, 0.51111], + "48": [0, 0.64444, 0.13556, 0, 0.51111], + "49": [0, 0.64444, 0.13556, 0, 0.51111], + "50": [0, 0.64444, 0.13556, 0, 0.51111], + "51": [0, 0.64444, 0.13556, 0, 0.51111], + "52": [0.19444, 0.64444, 0.13556, 0, 0.51111], + "53": [0, 0.64444, 0.13556, 0, 0.51111], + "54": [0, 0.64444, 0.13556, 0, 0.51111], + "55": [0.19444, 0.64444, 0.13556, 0, 0.51111], + "56": [0, 0.64444, 0.13556, 0, 0.51111], + "57": [0, 0.64444, 0.13556, 0, 0.51111], + "58": [0, 0.43056, 0.0582, 0, 0.30667], + "59": [0.19444, 0.43056, 0.0582, 0, 0.30667], + "61": [-0.13313, 0.36687, 0.06616, 0, 0.76666], + "63": [0, 0.69444, 0.1225, 0, 0.51111], + "64": [0, 0.69444, 0.09597, 0, 0.76666], + "65": [0, 0.68333, 0, 0, 0.74333], + "66": [0, 0.68333, 0.10257, 0, 0.70389], + "67": [0, 0.68333, 0.14528, 0, 0.71555], + "68": [0, 0.68333, 0.09403, 0, 0.755], + "69": [0, 0.68333, 0.12028, 0, 0.67833], + "70": [0, 0.68333, 0.13305, 0, 0.65277], + "71": [0, 0.68333, 0.08722, 0, 0.77361], + "72": [0, 0.68333, 0.16389, 0, 0.74333], + "73": [0, 0.68333, 0.15806, 0, 0.38555], + "74": [0, 0.68333, 0.14028, 0, 0.525], + "75": [0, 0.68333, 0.14528, 0, 0.76888], + "76": [0, 0.68333, 0, 0, 0.62722], + "77": [0, 0.68333, 0.16389, 0, 0.89666], + "78": [0, 0.68333, 0.16389, 0, 0.74333], + "79": [0, 0.68333, 0.09403, 0, 0.76666], + "80": [0, 0.68333, 0.10257, 0, 0.67833], + "81": [0.19444, 0.68333, 0.09403, 0, 0.76666], + "82": [0, 0.68333, 0.03868, 0, 0.72944], + "83": [0, 0.68333, 0.11972, 0, 0.56222], + "84": [0, 0.68333, 0.13305, 0, 0.71555], + "85": [0, 0.68333, 0.16389, 0, 0.74333], + "86": [0, 0.68333, 0.18361, 0, 0.74333], + "87": [0, 0.68333, 0.18361, 0, 0.99888], + "88": [0, 0.68333, 0.15806, 0, 0.74333], + "89": [0, 0.68333, 0.19383, 0, 0.74333], + "90": [0, 0.68333, 0.14528, 0, 0.61333], + "91": [0.25, 0.75, 0.1875, 0, 0.30667], + "93": [0.25, 0.75, 0.10528, 0, 0.30667], + "94": [0, 0.69444, 0.06646, 0, 0.51111], + "95": [0.31, 0.12056, 0.09208, 0, 0.51111], + "97": [0, 0.43056, 0.07671, 0, 0.51111], + "98": [0, 0.69444, 0.06312, 0, 0.46], + "99": [0, 0.43056, 0.05653, 0, 0.46], + "100": [0, 0.69444, 0.10333, 0, 0.51111], + "101": [0, 0.43056, 0.07514, 0, 0.46], + "102": [0.19444, 0.69444, 0.21194, 0, 0.30667], + "103": [0.19444, 0.43056, 0.08847, 0, 0.46], + "104": [0, 0.69444, 0.07671, 0, 0.51111], + "105": [0, 0.65536, 0.1019, 0, 0.30667], + "106": [0.19444, 0.65536, 0.14467, 0, 0.30667], + "107": [0, 0.69444, 0.10764, 0, 0.46], + "108": [0, 0.69444, 0.10333, 0, 0.25555], + "109": [0, 0.43056, 0.07671, 0, 0.81777], + "110": [0, 0.43056, 0.07671, 0, 0.56222], + "111": [0, 0.43056, 0.06312, 0, 0.51111], + "112": [0.19444, 0.43056, 0.06312, 0, 0.51111], + "113": [0.19444, 0.43056, 0.08847, 0, 0.46], + "114": [0, 0.43056, 0.10764, 0, 0.42166], + "115": [0, 0.43056, 0.08208, 0, 0.40889], + "116": [0, 0.61508, 0.09486, 0, 0.33222], + "117": [0, 0.43056, 0.07671, 0, 0.53666], + "118": [0, 0.43056, 0.10764, 0, 0.46], + "119": [0, 0.43056, 0.10764, 0, 0.66444], + "120": [0, 0.43056, 0.12042, 0, 0.46389], + "121": [0.19444, 0.43056, 0.08847, 0, 0.48555], + "122": [0, 0.43056, 0.12292, 0, 0.40889], + "126": [0.35, 0.31786, 0.11585, 0, 0.51111], + "160": [0, 0, 0, 0, 0.25], + "168": [0, 0.66786, 0.10474, 0, 0.51111], + "176": [0, 0.69444, 0, 0, 0.83129], + "184": [0.17014, 0, 0, 0, 0.46], + "198": [0, 0.68333, 0.12028, 0, 0.88277], + "216": [0.04861, 0.73194, 0.09403, 0, 0.76666], + "223": [0.19444, 0.69444, 0.10514, 0, 0.53666], + "230": [0, 0.43056, 0.07514, 0, 0.71555], + "248": [0.09722, 0.52778, 0.09194, 0, 0.51111], + "338": [0, 0.68333, 0.12028, 0, 0.98499], + "339": [0, 0.43056, 0.07514, 0, 0.71555], + "710": [0, 0.69444, 0.06646, 0, 0.51111], + "711": [0, 0.62847, 0.08295, 0, 0.51111], + "713": [0, 0.56167, 0.10333, 0, 0.51111], + "714": [0, 0.69444, 0.09694, 0, 0.51111], + "715": [0, 0.69444, 0, 0, 0.51111], + "728": [0, 0.69444, 0.10806, 0, 0.51111], + "729": [0, 0.66786, 0.11752, 0, 0.30667], + "730": [0, 0.69444, 0, 0, 0.83129], + "732": [0, 0.66786, 0.11585, 0, 0.51111], + "733": [0, 0.69444, 0.1225, 0, 0.51111], + "915": [0, 0.68333, 0.13305, 0, 0.62722], + "916": [0, 0.68333, 0, 0, 0.81777], + "920": [0, 0.68333, 0.09403, 0, 0.76666], + "923": [0, 0.68333, 0, 0, 0.69222], + "926": [0, 0.68333, 0.15294, 0, 0.66444], + "928": [0, 0.68333, 0.16389, 0, 0.74333], + "931": [0, 0.68333, 0.12028, 0, 0.71555], + "933": [0, 0.68333, 0.11111, 0, 0.76666], + "934": [0, 0.68333, 0.05986, 0, 0.71555], + "936": [0, 0.68333, 0.11111, 0, 0.76666], + "937": [0, 0.68333, 0.10257, 0, 0.71555], + "8211": [0, 0.43056, 0.09208, 0, 0.51111], + "8212": [0, 0.43056, 0.09208, 0, 1.02222], + "8216": [0, 0.69444, 0.12417, 0, 0.30667], + "8217": [0, 0.69444, 0.12417, 0, 0.30667], + "8220": [0, 0.69444, 0.1685, 0, 0.51444], + "8221": [0, 0.69444, 0.06961, 0, 0.51444], + "8463": [0, 0.68889, 0, 0, 0.54028] + }, + "Main-Regular": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0, 0, 0.27778], + "34": [0, 0.69444, 0, 0, 0.5], + "35": [0.19444, 0.69444, 0, 0, 0.83334], + "36": [0.05556, 0.75, 0, 0, 0.5], + "37": [0.05556, 0.75, 0, 0, 0.83334], + "38": [0, 0.69444, 0, 0, 0.77778], + "39": [0, 0.69444, 0, 0, 0.27778], + "40": [0.25, 0.75, 0, 0, 0.38889], + "41": [0.25, 0.75, 0, 0, 0.38889], + "42": [0, 0.75, 0, 0, 0.5], + "43": [0.08333, 0.58333, 0, 0, 0.77778], + "44": [0.19444, 0.10556, 0, 0, 0.27778], + "45": [0, 0.43056, 0, 0, 0.33333], + "46": [0, 0.10556, 0, 0, 0.27778], + "47": [0.25, 0.75, 0, 0, 0.5], + "48": [0, 0.64444, 0, 0, 0.5], + "49": [0, 0.64444, 0, 0, 0.5], + "50": [0, 0.64444, 0, 0, 0.5], + "51": [0, 0.64444, 0, 0, 0.5], + "52": [0, 0.64444, 0, 0, 0.5], + "53": [0, 0.64444, 0, 0, 0.5], + "54": [0, 0.64444, 0, 0, 0.5], + "55": [0, 0.64444, 0, 0, 0.5], + "56": [0, 0.64444, 0, 0, 0.5], + "57": [0, 0.64444, 0, 0, 0.5], + "58": [0, 0.43056, 0, 0, 0.27778], + "59": [0.19444, 0.43056, 0, 0, 0.27778], + "60": [0.0391, 0.5391, 0, 0, 0.77778], + "61": [-0.13313, 0.36687, 0, 0, 0.77778], + "62": [0.0391, 0.5391, 0, 0, 0.77778], + "63": [0, 0.69444, 0, 0, 0.47222], + "64": [0, 0.69444, 0, 0, 0.77778], + "65": [0, 0.68333, 0, 0, 0.75], + "66": [0, 0.68333, 0, 0, 0.70834], + "67": [0, 0.68333, 0, 0, 0.72222], + "68": [0, 0.68333, 0, 0, 0.76389], + "69": [0, 0.68333, 0, 0, 0.68056], + "70": [0, 0.68333, 0, 0, 0.65278], + "71": [0, 0.68333, 0, 0, 0.78472], + "72": [0, 0.68333, 0, 0, 0.75], + "73": [0, 0.68333, 0, 0, 0.36111], + "74": [0, 0.68333, 0, 0, 0.51389], + "75": [0, 0.68333, 0, 0, 0.77778], + "76": [0, 0.68333, 0, 0, 0.625], + "77": [0, 0.68333, 0, 0, 0.91667], + "78": [0, 0.68333, 0, 0, 0.75], + "79": [0, 0.68333, 0, 0, 0.77778], + "80": [0, 0.68333, 0, 0, 0.68056], + "81": [0.19444, 0.68333, 0, 0, 0.77778], + "82": [0, 0.68333, 0, 0, 0.73611], + "83": [0, 0.68333, 0, 0, 0.55556], + "84": [0, 0.68333, 0, 0, 0.72222], + "85": [0, 0.68333, 0, 0, 0.75], + "86": [0, 0.68333, 0.01389, 0, 0.75], + "87": [0, 0.68333, 0.01389, 0, 1.02778], + "88": [0, 0.68333, 0, 0, 0.75], + "89": [0, 0.68333, 0.025, 0, 0.75], + "90": [0, 0.68333, 0, 0, 0.61111], + "91": [0.25, 0.75, 0, 0, 0.27778], + "92": [0.25, 0.75, 0, 0, 0.5], + "93": [0.25, 0.75, 0, 0, 0.27778], + "94": [0, 0.69444, 0, 0, 0.5], + "95": [0.31, 0.12056, 0.02778, 0, 0.5], + "97": [0, 0.43056, 0, 0, 0.5], + "98": [0, 0.69444, 0, 0, 0.55556], + "99": [0, 0.43056, 0, 0, 0.44445], + "100": [0, 0.69444, 0, 0, 0.55556], + "101": [0, 0.43056, 0, 0, 0.44445], + "102": [0, 0.69444, 0.07778, 0, 0.30556], + "103": [0.19444, 0.43056, 0.01389, 0, 0.5], + "104": [0, 0.69444, 0, 0, 0.55556], + "105": [0, 0.66786, 0, 0, 0.27778], + "106": [0.19444, 0.66786, 0, 0, 0.30556], + "107": [0, 0.69444, 0, 0, 0.52778], + "108": [0, 0.69444, 0, 0, 0.27778], + "109": [0, 0.43056, 0, 0, 0.83334], + "110": [0, 0.43056, 0, 0, 0.55556], + "111": [0, 0.43056, 0, 0, 0.5], + "112": [0.19444, 0.43056, 0, 0, 0.55556], + "113": [0.19444, 0.43056, 0, 0, 0.52778], + "114": [0, 0.43056, 0, 0, 0.39167], + "115": [0, 0.43056, 0, 0, 0.39445], + "116": [0, 0.61508, 0, 0, 0.38889], + "117": [0, 0.43056, 0, 0, 0.55556], + "118": [0, 0.43056, 0.01389, 0, 0.52778], + "119": [0, 0.43056, 0.01389, 0, 0.72222], + "120": [0, 0.43056, 0, 0, 0.52778], + "121": [0.19444, 0.43056, 0.01389, 0, 0.52778], + "122": [0, 0.43056, 0, 0, 0.44445], + "123": [0.25, 0.75, 0, 0, 0.5], + "124": [0.25, 0.75, 0, 0, 0.27778], + "125": [0.25, 0.75, 0, 0, 0.5], + "126": [0.35, 0.31786, 0, 0, 0.5], + "160": [0, 0, 0, 0, 0.25], + "163": [0, 0.69444, 0, 0, 0.76909], + "167": [0.19444, 0.69444, 0, 0, 0.44445], + "168": [0, 0.66786, 0, 0, 0.5], + "172": [0, 0.43056, 0, 0, 0.66667], + "176": [0, 0.69444, 0, 0, 0.75], + "177": [0.08333, 0.58333, 0, 0, 0.77778], + "182": [0.19444, 0.69444, 0, 0, 0.61111], + "184": [0.17014, 0, 0, 0, 0.44445], + "198": [0, 0.68333, 0, 0, 0.90278], + "215": [0.08333, 0.58333, 0, 0, 0.77778], + "216": [0.04861, 0.73194, 0, 0, 0.77778], + "223": [0, 0.69444, 0, 0, 0.5], + "230": [0, 0.43056, 0, 0, 0.72222], + "247": [0.08333, 0.58333, 0, 0, 0.77778], + "248": [0.09722, 0.52778, 0, 0, 0.5], + "305": [0, 0.43056, 0, 0, 0.27778], + "338": [0, 0.68333, 0, 0, 1.01389], + "339": [0, 0.43056, 0, 0, 0.77778], + "567": [0.19444, 0.43056, 0, 0, 0.30556], + "710": [0, 0.69444, 0, 0, 0.5], + "711": [0, 0.62847, 0, 0, 0.5], + "713": [0, 0.56778, 0, 0, 0.5], + "714": [0, 0.69444, 0, 0, 0.5], + "715": [0, 0.69444, 0, 0, 0.5], + "728": [0, 0.69444, 0, 0, 0.5], + "729": [0, 0.66786, 0, 0, 0.27778], + "730": [0, 0.69444, 0, 0, 0.75], + "732": [0, 0.66786, 0, 0, 0.5], + "733": [0, 0.69444, 0, 0, 0.5], + "915": [0, 0.68333, 0, 0, 0.625], + "916": [0, 0.68333, 0, 0, 0.83334], + "920": [0, 0.68333, 0, 0, 0.77778], + "923": [0, 0.68333, 0, 0, 0.69445], + "926": [0, 0.68333, 0, 0, 0.66667], + "928": [0, 0.68333, 0, 0, 0.75], + "931": [0, 0.68333, 0, 0, 0.72222], + "933": [0, 0.68333, 0, 0, 0.77778], + "934": [0, 0.68333, 0, 0, 0.72222], + "936": [0, 0.68333, 0, 0, 0.77778], + "937": [0, 0.68333, 0, 0, 0.72222], + "8211": [0, 0.43056, 0.02778, 0, 0.5], + "8212": [0, 0.43056, 0.02778, 0, 1.0], + "8216": [0, 0.69444, 0, 0, 0.27778], + "8217": [0, 0.69444, 0, 0, 0.27778], + "8220": [0, 0.69444, 0, 0, 0.5], + "8221": [0, 0.69444, 0, 0, 0.5], + "8224": [0.19444, 0.69444, 0, 0, 0.44445], + "8225": [0.19444, 0.69444, 0, 0, 0.44445], + "8230": [0, 0.123, 0, 0, 1.172], + "8242": [0, 0.55556, 0, 0, 0.275], + "8407": [0, 0.71444, 0.15382, 0, 0.5], + "8463": [0, 0.68889, 0, 0, 0.54028], + "8465": [0, 0.69444, 0, 0, 0.72222], + "8467": [0, 0.69444, 0, 0.11111, 0.41667], + "8472": [0.19444, 0.43056, 0, 0.11111, 0.63646], + "8476": [0, 0.69444, 0, 0, 0.72222], + "8501": [0, 0.69444, 0, 0, 0.61111], + "8592": [-0.13313, 0.36687, 0, 0, 1.0], + "8593": [0.19444, 0.69444, 0, 0, 0.5], + "8594": [-0.13313, 0.36687, 0, 0, 1.0], + "8595": [0.19444, 0.69444, 0, 0, 0.5], + "8596": [-0.13313, 0.36687, 0, 0, 1.0], + "8597": [0.25, 0.75, 0, 0, 0.5], + "8598": [0.19444, 0.69444, 0, 0, 1.0], + "8599": [0.19444, 0.69444, 0, 0, 1.0], + "8600": [0.19444, 0.69444, 0, 0, 1.0], + "8601": [0.19444, 0.69444, 0, 0, 1.0], + "8614": [0.011, 0.511, 0, 0, 1.0], + "8617": [0.011, 0.511, 0, 0, 1.126], + "8618": [0.011, 0.511, 0, 0, 1.126], + "8636": [-0.13313, 0.36687, 0, 0, 1.0], + "8637": [-0.13313, 0.36687, 0, 0, 1.0], + "8640": [-0.13313, 0.36687, 0, 0, 1.0], + "8641": [-0.13313, 0.36687, 0, 0, 1.0], + "8652": [0.011, 0.671, 0, 0, 1.0], + "8656": [-0.13313, 0.36687, 0, 0, 1.0], + "8657": [0.19444, 0.69444, 0, 0, 0.61111], + "8658": [-0.13313, 0.36687, 0, 0, 1.0], + "8659": [0.19444, 0.69444, 0, 0, 0.61111], + "8660": [-0.13313, 0.36687, 0, 0, 1.0], + "8661": [0.25, 0.75, 0, 0, 0.61111], + "8704": [0, 0.69444, 0, 0, 0.55556], + "8706": [0, 0.69444, 0.05556, 0.08334, 0.5309], + "8707": [0, 0.69444, 0, 0, 0.55556], + "8709": [0.05556, 0.75, 0, 0, 0.5], + "8711": [0, 0.68333, 0, 0, 0.83334], + "8712": [0.0391, 0.5391, 0, 0, 0.66667], + "8715": [0.0391, 0.5391, 0, 0, 0.66667], + "8722": [0.08333, 0.58333, 0, 0, 0.77778], + "8723": [0.08333, 0.58333, 0, 0, 0.77778], + "8725": [0.25, 0.75, 0, 0, 0.5], + "8726": [0.25, 0.75, 0, 0, 0.5], + "8727": [-0.03472, 0.46528, 0, 0, 0.5], + "8728": [-0.05555, 0.44445, 0, 0, 0.5], + "8729": [-0.05555, 0.44445, 0, 0, 0.5], + "8730": [0.2, 0.8, 0, 0, 0.83334], + "8733": [0, 0.43056, 0, 0, 0.77778], + "8734": [0, 0.43056, 0, 0, 1.0], + "8736": [0, 0.69224, 0, 0, 0.72222], + "8739": [0.25, 0.75, 0, 0, 0.27778], + "8741": [0.25, 0.75, 0, 0, 0.5], + "8743": [0, 0.55556, 0, 0, 0.66667], + "8744": [0, 0.55556, 0, 0, 0.66667], + "8745": [0, 0.55556, 0, 0, 0.66667], + "8746": [0, 0.55556, 0, 0, 0.66667], + "8747": [0.19444, 0.69444, 0.11111, 0, 0.41667], + "8764": [-0.13313, 0.36687, 0, 0, 0.77778], + "8768": [0.19444, 0.69444, 0, 0, 0.27778], + "8771": [-0.03625, 0.46375, 0, 0, 0.77778], + "8773": [-0.022, 0.589, 0, 0, 0.778], + "8776": [-0.01688, 0.48312, 0, 0, 0.77778], + "8781": [-0.03625, 0.46375, 0, 0, 0.77778], + "8784": [-0.133, 0.673, 0, 0, 0.778], + "8801": [-0.03625, 0.46375, 0, 0, 0.77778], + "8804": [0.13597, 0.63597, 0, 0, 0.77778], + "8805": [0.13597, 0.63597, 0, 0, 0.77778], + "8810": [0.0391, 0.5391, 0, 0, 1.0], + "8811": [0.0391, 0.5391, 0, 0, 1.0], + "8826": [0.0391, 0.5391, 0, 0, 0.77778], + "8827": [0.0391, 0.5391, 0, 0, 0.77778], + "8834": [0.0391, 0.5391, 0, 0, 0.77778], + "8835": [0.0391, 0.5391, 0, 0, 0.77778], + "8838": [0.13597, 0.63597, 0, 0, 0.77778], + "8839": [0.13597, 0.63597, 0, 0, 0.77778], + "8846": [0, 0.55556, 0, 0, 0.66667], + "8849": [0.13597, 0.63597, 0, 0, 0.77778], + "8850": [0.13597, 0.63597, 0, 0, 0.77778], + "8851": [0, 0.55556, 0, 0, 0.66667], + "8852": [0, 0.55556, 0, 0, 0.66667], + "8853": [0.08333, 0.58333, 0, 0, 0.77778], + "8854": [0.08333, 0.58333, 0, 0, 0.77778], + "8855": [0.08333, 0.58333, 0, 0, 0.77778], + "8856": [0.08333, 0.58333, 0, 0, 0.77778], + "8857": [0.08333, 0.58333, 0, 0, 0.77778], + "8866": [0, 0.69444, 0, 0, 0.61111], + "8867": [0, 0.69444, 0, 0, 0.61111], + "8868": [0, 0.69444, 0, 0, 0.77778], + "8869": [0, 0.69444, 0, 0, 0.77778], + "8872": [0.249, 0.75, 0, 0, 0.867], + "8900": [-0.05555, 0.44445, 0, 0, 0.5], + "8901": [-0.05555, 0.44445, 0, 0, 0.27778], + "8902": [-0.03472, 0.46528, 0, 0, 0.5], + "8904": [0.005, 0.505, 0, 0, 0.9], + "8942": [0.03, 0.903, 0, 0, 0.278], + "8943": [-0.19, 0.313, 0, 0, 1.172], + "8945": [-0.1, 0.823, 0, 0, 1.282], + "8968": [0.25, 0.75, 0, 0, 0.44445], + "8969": [0.25, 0.75, 0, 0, 0.44445], + "8970": [0.25, 0.75, 0, 0, 0.44445], + "8971": [0.25, 0.75, 0, 0, 0.44445], + "8994": [-0.14236, 0.35764, 0, 0, 1.0], + "8995": [-0.14236, 0.35764, 0, 0, 1.0], + "9136": [0.244, 0.744, 0, 0, 0.412], + "9137": [0.244, 0.745, 0, 0, 0.412], + "9651": [0.19444, 0.69444, 0, 0, 0.88889], + "9657": [-0.03472, 0.46528, 0, 0, 0.5], + "9661": [0.19444, 0.69444, 0, 0, 0.88889], + "9667": [-0.03472, 0.46528, 0, 0, 0.5], + "9711": [0.19444, 0.69444, 0, 0, 1.0], + "9824": [0.12963, 0.69444, 0, 0, 0.77778], + "9825": [0.12963, 0.69444, 0, 0, 0.77778], + "9826": [0.12963, 0.69444, 0, 0, 0.77778], + "9827": [0.12963, 0.69444, 0, 0, 0.77778], + "9837": [0, 0.75, 0, 0, 0.38889], + "9838": [0.19444, 0.69444, 0, 0, 0.38889], + "9839": [0.19444, 0.69444, 0, 0, 0.38889], + "10216": [0.25, 0.75, 0, 0, 0.38889], + "10217": [0.25, 0.75, 0, 0, 0.38889], + "10222": [0.244, 0.744, 0, 0, 0.412], + "10223": [0.244, 0.745, 0, 0, 0.412], + "10229": [0.011, 0.511, 0, 0, 1.609], + "10230": [0.011, 0.511, 0, 0, 1.638], + "10231": [0.011, 0.511, 0, 0, 1.859], + "10232": [0.024, 0.525, 0, 0, 1.609], + "10233": [0.024, 0.525, 0, 0, 1.638], + "10234": [0.024, 0.525, 0, 0, 1.858], + "10236": [0.011, 0.511, 0, 0, 1.638], + "10815": [0, 0.68333, 0, 0, 0.75], + "10927": [0.13597, 0.63597, 0, 0, 0.77778], + "10928": [0.13597, 0.63597, 0, 0, 0.77778], + "57376": [0.19444, 0.69444, 0, 0, 0] + }, + "Math-BoldItalic": { + "32": [0, 0, 0, 0, 0.25], + "48": [0, 0.44444, 0, 0, 0.575], + "49": [0, 0.44444, 0, 0, 0.575], + "50": [0, 0.44444, 0, 0, 0.575], + "51": [0.19444, 0.44444, 0, 0, 0.575], + "52": [0.19444, 0.44444, 0, 0, 0.575], + "53": [0.19444, 0.44444, 0, 0, 0.575], + "54": [0, 0.64444, 0, 0, 0.575], + "55": [0.19444, 0.44444, 0, 0, 0.575], + "56": [0, 0.64444, 0, 0, 0.575], + "57": [0.19444, 0.44444, 0, 0, 0.575], + "65": [0, 0.68611, 0, 0, 0.86944], + "66": [0, 0.68611, 0.04835, 0, 0.8664], + "67": [0, 0.68611, 0.06979, 0, 0.81694], + "68": [0, 0.68611, 0.03194, 0, 0.93812], + "69": [0, 0.68611, 0.05451, 0, 0.81007], + "70": [0, 0.68611, 0.15972, 0, 0.68889], + "71": [0, 0.68611, 0, 0, 0.88673], + "72": [0, 0.68611, 0.08229, 0, 0.98229], + "73": [0, 0.68611, 0.07778, 0, 0.51111], + "74": [0, 0.68611, 0.10069, 0, 0.63125], + "75": [0, 0.68611, 0.06979, 0, 0.97118], + "76": [0, 0.68611, 0, 0, 0.75555], + "77": [0, 0.68611, 0.11424, 0, 1.14201], + "78": [0, 0.68611, 0.11424, 0, 0.95034], + "79": [0, 0.68611, 0.03194, 0, 0.83666], + "80": [0, 0.68611, 0.15972, 0, 0.72309], + "81": [0.19444, 0.68611, 0, 0, 0.86861], + "82": [0, 0.68611, 0.00421, 0, 0.87235], + "83": [0, 0.68611, 0.05382, 0, 0.69271], + "84": [0, 0.68611, 0.15972, 0, 0.63663], + "85": [0, 0.68611, 0.11424, 0, 0.80027], + "86": [0, 0.68611, 0.25555, 0, 0.67778], + "87": [0, 0.68611, 0.15972, 0, 1.09305], + "88": [0, 0.68611, 0.07778, 0, 0.94722], + "89": [0, 0.68611, 0.25555, 0, 0.67458], + "90": [0, 0.68611, 0.06979, 0, 0.77257], + "97": [0, 0.44444, 0, 0, 0.63287], + "98": [0, 0.69444, 0, 0, 0.52083], + "99": [0, 0.44444, 0, 0, 0.51342], + "100": [0, 0.69444, 0, 0, 0.60972], + "101": [0, 0.44444, 0, 0, 0.55361], + "102": [0.19444, 0.69444, 0.11042, 0, 0.56806], + "103": [0.19444, 0.44444, 0.03704, 0, 0.5449], + "104": [0, 0.69444, 0, 0, 0.66759], + "105": [0, 0.69326, 0, 0, 0.4048], + "106": [0.19444, 0.69326, 0.0622, 0, 0.47083], + "107": [0, 0.69444, 0.01852, 0, 0.6037], + "108": [0, 0.69444, 0.0088, 0, 0.34815], + "109": [0, 0.44444, 0, 0, 1.0324], + "110": [0, 0.44444, 0, 0, 0.71296], + "111": [0, 0.44444, 0, 0, 0.58472], + "112": [0.19444, 0.44444, 0, 0, 0.60092], + "113": [0.19444, 0.44444, 0.03704, 0, 0.54213], + "114": [0, 0.44444, 0.03194, 0, 0.5287], + "115": [0, 0.44444, 0, 0, 0.53125], + "116": [0, 0.63492, 0, 0, 0.41528], + "117": [0, 0.44444, 0, 0, 0.68102], + "118": [0, 0.44444, 0.03704, 0, 0.56666], + "119": [0, 0.44444, 0.02778, 0, 0.83148], + "120": [0, 0.44444, 0, 0, 0.65903], + "121": [0.19444, 0.44444, 0.03704, 0, 0.59028], + "122": [0, 0.44444, 0.04213, 0, 0.55509], + "160": [0, 0, 0, 0, 0.25], + "915": [0, 0.68611, 0.15972, 0, 0.65694], + "916": [0, 0.68611, 0, 0, 0.95833], + "920": [0, 0.68611, 0.03194, 0, 0.86722], + "923": [0, 0.68611, 0, 0, 0.80555], + "926": [0, 0.68611, 0.07458, 0, 0.84125], + "928": [0, 0.68611, 0.08229, 0, 0.98229], + "931": [0, 0.68611, 0.05451, 0, 0.88507], + "933": [0, 0.68611, 0.15972, 0, 0.67083], + "934": [0, 0.68611, 0, 0, 0.76666], + "936": [0, 0.68611, 0.11653, 0, 0.71402], + "937": [0, 0.68611, 0.04835, 0, 0.8789], + "945": [0, 0.44444, 0, 0, 0.76064], + "946": [0.19444, 0.69444, 0.03403, 0, 0.65972], + "947": [0.19444, 0.44444, 0.06389, 0, 0.59003], + "948": [0, 0.69444, 0.03819, 0, 0.52222], + "949": [0, 0.44444, 0, 0, 0.52882], + "950": [0.19444, 0.69444, 0.06215, 0, 0.50833], + "951": [0.19444, 0.44444, 0.03704, 0, 0.6], + "952": [0, 0.69444, 0.03194, 0, 0.5618], + "953": [0, 0.44444, 0, 0, 0.41204], + "954": [0, 0.44444, 0, 0, 0.66759], + "955": [0, 0.69444, 0, 0, 0.67083], + "956": [0.19444, 0.44444, 0, 0, 0.70787], + "957": [0, 0.44444, 0.06898, 0, 0.57685], + "958": [0.19444, 0.69444, 0.03021, 0, 0.50833], + "959": [0, 0.44444, 0, 0, 0.58472], + "960": [0, 0.44444, 0.03704, 0, 0.68241], + "961": [0.19444, 0.44444, 0, 0, 0.6118], + "962": [0.09722, 0.44444, 0.07917, 0, 0.42361], + "963": [0, 0.44444, 0.03704, 0, 0.68588], + "964": [0, 0.44444, 0.13472, 0, 0.52083], + "965": [0, 0.44444, 0.03704, 0, 0.63055], + "966": [0.19444, 0.44444, 0, 0, 0.74722], + "967": [0.19444, 0.44444, 0, 0, 0.71805], + "968": [0.19444, 0.69444, 0.03704, 0, 0.75833], + "969": [0, 0.44444, 0.03704, 0, 0.71782], + "977": [0, 0.69444, 0, 0, 0.69155], + "981": [0.19444, 0.69444, 0, 0, 0.7125], + "982": [0, 0.44444, 0.03194, 0, 0.975], + "1009": [0.19444, 0.44444, 0, 0, 0.6118], + "1013": [0, 0.44444, 0, 0, 0.48333], + "57649": [0, 0.44444, 0, 0, 0.39352], + "57911": [0.19444, 0.44444, 0, 0, 0.43889] + }, + "Math-Italic": { + "32": [0, 0, 0, 0, 0.25], + "48": [0, 0.43056, 0, 0, 0.5], + "49": [0, 0.43056, 0, 0, 0.5], + "50": [0, 0.43056, 0, 0, 0.5], + "51": [0.19444, 0.43056, 0, 0, 0.5], + "52": [0.19444, 0.43056, 0, 0, 0.5], + "53": [0.19444, 0.43056, 0, 0, 0.5], + "54": [0, 0.64444, 0, 0, 0.5], + "55": [0.19444, 0.43056, 0, 0, 0.5], + "56": [0, 0.64444, 0, 0, 0.5], + "57": [0.19444, 0.43056, 0, 0, 0.5], + "65": [0, 0.68333, 0, 0.13889, 0.75], + "66": [0, 0.68333, 0.05017, 0.08334, 0.75851], + "67": [0, 0.68333, 0.07153, 0.08334, 0.71472], + "68": [0, 0.68333, 0.02778, 0.05556, 0.82792], + "69": [0, 0.68333, 0.05764, 0.08334, 0.7382], + "70": [0, 0.68333, 0.13889, 0.08334, 0.64306], + "71": [0, 0.68333, 0, 0.08334, 0.78625], + "72": [0, 0.68333, 0.08125, 0.05556, 0.83125], + "73": [0, 0.68333, 0.07847, 0.11111, 0.43958], + "74": [0, 0.68333, 0.09618, 0.16667, 0.55451], + "75": [0, 0.68333, 0.07153, 0.05556, 0.84931], + "76": [0, 0.68333, 0, 0.02778, 0.68056], + "77": [0, 0.68333, 0.10903, 0.08334, 0.97014], + "78": [0, 0.68333, 0.10903, 0.08334, 0.80347], + "79": [0, 0.68333, 0.02778, 0.08334, 0.76278], + "80": [0, 0.68333, 0.13889, 0.08334, 0.64201], + "81": [0.19444, 0.68333, 0, 0.08334, 0.79056], + "82": [0, 0.68333, 0.00773, 0.08334, 0.75929], + "83": [0, 0.68333, 0.05764, 0.08334, 0.6132], + "84": [0, 0.68333, 0.13889, 0.08334, 0.58438], + "85": [0, 0.68333, 0.10903, 0.02778, 0.68278], + "86": [0, 0.68333, 0.22222, 0, 0.58333], + "87": [0, 0.68333, 0.13889, 0, 0.94445], + "88": [0, 0.68333, 0.07847, 0.08334, 0.82847], + "89": [0, 0.68333, 0.22222, 0, 0.58056], + "90": [0, 0.68333, 0.07153, 0.08334, 0.68264], + "97": [0, 0.43056, 0, 0, 0.52859], + "98": [0, 0.69444, 0, 0, 0.42917], + "99": [0, 0.43056, 0, 0.05556, 0.43276], + "100": [0, 0.69444, 0, 0.16667, 0.52049], + "101": [0, 0.43056, 0, 0.05556, 0.46563], + "102": [0.19444, 0.69444, 0.10764, 0.16667, 0.48959], + "103": [0.19444, 0.43056, 0.03588, 0.02778, 0.47697], + "104": [0, 0.69444, 0, 0, 0.57616], + "105": [0, 0.65952, 0, 0, 0.34451], + "106": [0.19444, 0.65952, 0.05724, 0, 0.41181], + "107": [0, 0.69444, 0.03148, 0, 0.5206], + "108": [0, 0.69444, 0.01968, 0.08334, 0.29838], + "109": [0, 0.43056, 0, 0, 0.87801], + "110": [0, 0.43056, 0, 0, 0.60023], + "111": [0, 0.43056, 0, 0.05556, 0.48472], + "112": [0.19444, 0.43056, 0, 0.08334, 0.50313], + "113": [0.19444, 0.43056, 0.03588, 0.08334, 0.44641], + "114": [0, 0.43056, 0.02778, 0.05556, 0.45116], + "115": [0, 0.43056, 0, 0.05556, 0.46875], + "116": [0, 0.61508, 0, 0.08334, 0.36111], + "117": [0, 0.43056, 0, 0.02778, 0.57246], + "118": [0, 0.43056, 0.03588, 0.02778, 0.48472], + "119": [0, 0.43056, 0.02691, 0.08334, 0.71592], + "120": [0, 0.43056, 0, 0.02778, 0.57153], + "121": [0.19444, 0.43056, 0.03588, 0.05556, 0.49028], + "122": [0, 0.43056, 0.04398, 0.05556, 0.46505], + "160": [0, 0, 0, 0, 0.25], + "915": [0, 0.68333, 0.13889, 0.08334, 0.61528], + "916": [0, 0.68333, 0, 0.16667, 0.83334], + "920": [0, 0.68333, 0.02778, 0.08334, 0.76278], + "923": [0, 0.68333, 0, 0.16667, 0.69445], + "926": [0, 0.68333, 0.07569, 0.08334, 0.74236], + "928": [0, 0.68333, 0.08125, 0.05556, 0.83125], + "931": [0, 0.68333, 0.05764, 0.08334, 0.77986], + "933": [0, 0.68333, 0.13889, 0.05556, 0.58333], + "934": [0, 0.68333, 0, 0.08334, 0.66667], + "936": [0, 0.68333, 0.11, 0.05556, 0.61222], + "937": [0, 0.68333, 0.05017, 0.08334, 0.7724], + "945": [0, 0.43056, 0.0037, 0.02778, 0.6397], + "946": [0.19444, 0.69444, 0.05278, 0.08334, 0.56563], + "947": [0.19444, 0.43056, 0.05556, 0, 0.51773], + "948": [0, 0.69444, 0.03785, 0.05556, 0.44444], + "949": [0, 0.43056, 0, 0.08334, 0.46632], + "950": [0.19444, 0.69444, 0.07378, 0.08334, 0.4375], + "951": [0.19444, 0.43056, 0.03588, 0.05556, 0.49653], + "952": [0, 0.69444, 0.02778, 0.08334, 0.46944], + "953": [0, 0.43056, 0, 0.05556, 0.35394], + "954": [0, 0.43056, 0, 0, 0.57616], + "955": [0, 0.69444, 0, 0, 0.58334], + "956": [0.19444, 0.43056, 0, 0.02778, 0.60255], + "957": [0, 0.43056, 0.06366, 0.02778, 0.49398], + "958": [0.19444, 0.69444, 0.04601, 0.11111, 0.4375], + "959": [0, 0.43056, 0, 0.05556, 0.48472], + "960": [0, 0.43056, 0.03588, 0, 0.57003], + "961": [0.19444, 0.43056, 0, 0.08334, 0.51702], + "962": [0.09722, 0.43056, 0.07986, 0.08334, 0.36285], + "963": [0, 0.43056, 0.03588, 0, 0.57141], + "964": [0, 0.43056, 0.1132, 0.02778, 0.43715], + "965": [0, 0.43056, 0.03588, 0.02778, 0.54028], + "966": [0.19444, 0.43056, 0, 0.08334, 0.65417], + "967": [0.19444, 0.43056, 0, 0.05556, 0.62569], + "968": [0.19444, 0.69444, 0.03588, 0.11111, 0.65139], + "969": [0, 0.43056, 0.03588, 0, 0.62245], + "977": [0, 0.69444, 0, 0.08334, 0.59144], + "981": [0.19444, 0.69444, 0, 0.08334, 0.59583], + "982": [0, 0.43056, 0.02778, 0, 0.82813], + "1009": [0.19444, 0.43056, 0, 0.08334, 0.51702], + "1013": [0, 0.43056, 0, 0.05556, 0.4059], + "57649": [0, 0.43056, 0, 0.02778, 0.32246], + "57911": [0.19444, 0.43056, 0, 0.08334, 0.38403] + }, + "SansSerif-Bold": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0, 0, 0.36667], + "34": [0, 0.69444, 0, 0, 0.55834], + "35": [0.19444, 0.69444, 0, 0, 0.91667], + "36": [0.05556, 0.75, 0, 0, 0.55], + "37": [0.05556, 0.75, 0, 0, 1.02912], + "38": [0, 0.69444, 0, 0, 0.83056], + "39": [0, 0.69444, 0, 0, 0.30556], + "40": [0.25, 0.75, 0, 0, 0.42778], + "41": [0.25, 0.75, 0, 0, 0.42778], + "42": [0, 0.75, 0, 0, 0.55], + "43": [0.11667, 0.61667, 0, 0, 0.85556], + "44": [0.10556, 0.13056, 0, 0, 0.30556], + "45": [0, 0.45833, 0, 0, 0.36667], + "46": [0, 0.13056, 0, 0, 0.30556], + "47": [0.25, 0.75, 0, 0, 0.55], + "48": [0, 0.69444, 0, 0, 0.55], + "49": [0, 0.69444, 0, 0, 0.55], + "50": [0, 0.69444, 0, 0, 0.55], + "51": [0, 0.69444, 0, 0, 0.55], + "52": [0, 0.69444, 0, 0, 0.55], + "53": [0, 0.69444, 0, 0, 0.55], + "54": [0, 0.69444, 0, 0, 0.55], + "55": [0, 0.69444, 0, 0, 0.55], + "56": [0, 0.69444, 0, 0, 0.55], + "57": [0, 0.69444, 0, 0, 0.55], + "58": [0, 0.45833, 0, 0, 0.30556], + "59": [0.10556, 0.45833, 0, 0, 0.30556], + "61": [-0.09375, 0.40625, 0, 0, 0.85556], + "63": [0, 0.69444, 0, 0, 0.51945], + "64": [0, 0.69444, 0, 0, 0.73334], + "65": [0, 0.69444, 0, 0, 0.73334], + "66": [0, 0.69444, 0, 0, 0.73334], + "67": [0, 0.69444, 0, 0, 0.70278], + "68": [0, 0.69444, 0, 0, 0.79445], + "69": [0, 0.69444, 0, 0, 0.64167], + "70": [0, 0.69444, 0, 0, 0.61111], + "71": [0, 0.69444, 0, 0, 0.73334], + "72": [0, 0.69444, 0, 0, 0.79445], + "73": [0, 0.69444, 0, 0, 0.33056], + "74": [0, 0.69444, 0, 0, 0.51945], + "75": [0, 0.69444, 0, 0, 0.76389], + "76": [0, 0.69444, 0, 0, 0.58056], + "77": [0, 0.69444, 0, 0, 0.97778], + "78": [0, 0.69444, 0, 0, 0.79445], + "79": [0, 0.69444, 0, 0, 0.79445], + "80": [0, 0.69444, 0, 0, 0.70278], + "81": [0.10556, 0.69444, 0, 0, 0.79445], + "82": [0, 0.69444, 0, 0, 0.70278], + "83": [0, 0.69444, 0, 0, 0.61111], + "84": [0, 0.69444, 0, 0, 0.73334], + "85": [0, 0.69444, 0, 0, 0.76389], + "86": [0, 0.69444, 0.01528, 0, 0.73334], + "87": [0, 0.69444, 0.01528, 0, 1.03889], + "88": [0, 0.69444, 0, 0, 0.73334], + "89": [0, 0.69444, 0.0275, 0, 0.73334], + "90": [0, 0.69444, 0, 0, 0.67223], + "91": [0.25, 0.75, 0, 0, 0.34306], + "93": [0.25, 0.75, 0, 0, 0.34306], + "94": [0, 0.69444, 0, 0, 0.55], + "95": [0.35, 0.10833, 0.03056, 0, 0.55], + "97": [0, 0.45833, 0, 0, 0.525], + "98": [0, 0.69444, 0, 0, 0.56111], + "99": [0, 0.45833, 0, 0, 0.48889], + "100": [0, 0.69444, 0, 0, 0.56111], + "101": [0, 0.45833, 0, 0, 0.51111], + "102": [0, 0.69444, 0.07639, 0, 0.33611], + "103": [0.19444, 0.45833, 0.01528, 0, 0.55], + "104": [0, 0.69444, 0, 0, 0.56111], + "105": [0, 0.69444, 0, 0, 0.25556], + "106": [0.19444, 0.69444, 0, 0, 0.28611], + "107": [0, 0.69444, 0, 0, 0.53056], + "108": [0, 0.69444, 0, 0, 0.25556], + "109": [0, 0.45833, 0, 0, 0.86667], + "110": [0, 0.45833, 0, 0, 0.56111], + "111": [0, 0.45833, 0, 0, 0.55], + "112": [0.19444, 0.45833, 0, 0, 0.56111], + "113": [0.19444, 0.45833, 0, 0, 0.56111], + "114": [0, 0.45833, 0.01528, 0, 0.37222], + "115": [0, 0.45833, 0, 0, 0.42167], + "116": [0, 0.58929, 0, 0, 0.40417], + "117": [0, 0.45833, 0, 0, 0.56111], + "118": [0, 0.45833, 0.01528, 0, 0.5], + "119": [0, 0.45833, 0.01528, 0, 0.74445], + "120": [0, 0.45833, 0, 0, 0.5], + "121": [0.19444, 0.45833, 0.01528, 0, 0.5], + "122": [0, 0.45833, 0, 0, 0.47639], + "126": [0.35, 0.34444, 0, 0, 0.55], + "160": [0, 0, 0, 0, 0.25], + "168": [0, 0.69444, 0, 0, 0.55], + "176": [0, 0.69444, 0, 0, 0.73334], + "180": [0, 0.69444, 0, 0, 0.55], + "184": [0.17014, 0, 0, 0, 0.48889], + "305": [0, 0.45833, 0, 0, 0.25556], + "567": [0.19444, 0.45833, 0, 0, 0.28611], + "710": [0, 0.69444, 0, 0, 0.55], + "711": [0, 0.63542, 0, 0, 0.55], + "713": [0, 0.63778, 0, 0, 0.55], + "728": [0, 0.69444, 0, 0, 0.55], + "729": [0, 0.69444, 0, 0, 0.30556], + "730": [0, 0.69444, 0, 0, 0.73334], + "732": [0, 0.69444, 0, 0, 0.55], + "733": [0, 0.69444, 0, 0, 0.55], + "915": [0, 0.69444, 0, 0, 0.58056], + "916": [0, 0.69444, 0, 0, 0.91667], + "920": [0, 0.69444, 0, 0, 0.85556], + "923": [0, 0.69444, 0, 0, 0.67223], + "926": [0, 0.69444, 0, 0, 0.73334], + "928": [0, 0.69444, 0, 0, 0.79445], + "931": [0, 0.69444, 0, 0, 0.79445], + "933": [0, 0.69444, 0, 0, 0.85556], + "934": [0, 0.69444, 0, 0, 0.79445], + "936": [0, 0.69444, 0, 0, 0.85556], + "937": [0, 0.69444, 0, 0, 0.79445], + "8211": [0, 0.45833, 0.03056, 0, 0.55], + "8212": [0, 0.45833, 0.03056, 0, 1.10001], + "8216": [0, 0.69444, 0, 0, 0.30556], + "8217": [0, 0.69444, 0, 0, 0.30556], + "8220": [0, 0.69444, 0, 0, 0.55834], + "8221": [0, 0.69444, 0, 0, 0.55834] + }, + "SansSerif-Italic": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0.05733, 0, 0.31945], + "34": [0, 0.69444, 0.00316, 0, 0.5], + "35": [0.19444, 0.69444, 0.05087, 0, 0.83334], + "36": [0.05556, 0.75, 0.11156, 0, 0.5], + "37": [0.05556, 0.75, 0.03126, 0, 0.83334], + "38": [0, 0.69444, 0.03058, 0, 0.75834], + "39": [0, 0.69444, 0.07816, 0, 0.27778], + "40": [0.25, 0.75, 0.13164, 0, 0.38889], + "41": [0.25, 0.75, 0.02536, 0, 0.38889], + "42": [0, 0.75, 0.11775, 0, 0.5], + "43": [0.08333, 0.58333, 0.02536, 0, 0.77778], + "44": [0.125, 0.08333, 0, 0, 0.27778], + "45": [0, 0.44444, 0.01946, 0, 0.33333], + "46": [0, 0.08333, 0, 0, 0.27778], + "47": [0.25, 0.75, 0.13164, 0, 0.5], + "48": [0, 0.65556, 0.11156, 0, 0.5], + "49": [0, 0.65556, 0.11156, 0, 0.5], + "50": [0, 0.65556, 0.11156, 0, 0.5], + "51": [0, 0.65556, 0.11156, 0, 0.5], + "52": [0, 0.65556, 0.11156, 0, 0.5], + "53": [0, 0.65556, 0.11156, 0, 0.5], + "54": [0, 0.65556, 0.11156, 0, 0.5], + "55": [0, 0.65556, 0.11156, 0, 0.5], + "56": [0, 0.65556, 0.11156, 0, 0.5], + "57": [0, 0.65556, 0.11156, 0, 0.5], + "58": [0, 0.44444, 0.02502, 0, 0.27778], + "59": [0.125, 0.44444, 0.02502, 0, 0.27778], + "61": [-0.13, 0.37, 0.05087, 0, 0.77778], + "63": [0, 0.69444, 0.11809, 0, 0.47222], + "64": [0, 0.69444, 0.07555, 0, 0.66667], + "65": [0, 0.69444, 0, 0, 0.66667], + "66": [0, 0.69444, 0.08293, 0, 0.66667], + "67": [0, 0.69444, 0.11983, 0, 0.63889], + "68": [0, 0.69444, 0.07555, 0, 0.72223], + "69": [0, 0.69444, 0.11983, 0, 0.59722], + "70": [0, 0.69444, 0.13372, 0, 0.56945], + "71": [0, 0.69444, 0.11983, 0, 0.66667], + "72": [0, 0.69444, 0.08094, 0, 0.70834], + "73": [0, 0.69444, 0.13372, 0, 0.27778], + "74": [0, 0.69444, 0.08094, 0, 0.47222], + "75": [0, 0.69444, 0.11983, 0, 0.69445], + "76": [0, 0.69444, 0, 0, 0.54167], + "77": [0, 0.69444, 0.08094, 0, 0.875], + "78": [0, 0.69444, 0.08094, 0, 0.70834], + "79": [0, 0.69444, 0.07555, 0, 0.73611], + "80": [0, 0.69444, 0.08293, 0, 0.63889], + "81": [0.125, 0.69444, 0.07555, 0, 0.73611], + "82": [0, 0.69444, 0.08293, 0, 0.64584], + "83": [0, 0.69444, 0.09205, 0, 0.55556], + "84": [0, 0.69444, 0.13372, 0, 0.68056], + "85": [0, 0.69444, 0.08094, 0, 0.6875], + "86": [0, 0.69444, 0.1615, 0, 0.66667], + "87": [0, 0.69444, 0.1615, 0, 0.94445], + "88": [0, 0.69444, 0.13372, 0, 0.66667], + "89": [0, 0.69444, 0.17261, 0, 0.66667], + "90": [0, 0.69444, 0.11983, 0, 0.61111], + "91": [0.25, 0.75, 0.15942, 0, 0.28889], + "93": [0.25, 0.75, 0.08719, 0, 0.28889], + "94": [0, 0.69444, 0.0799, 0, 0.5], + "95": [0.35, 0.09444, 0.08616, 0, 0.5], + "97": [0, 0.44444, 0.00981, 0, 0.48056], + "98": [0, 0.69444, 0.03057, 0, 0.51667], + "99": [0, 0.44444, 0.08336, 0, 0.44445], + "100": [0, 0.69444, 0.09483, 0, 0.51667], + "101": [0, 0.44444, 0.06778, 0, 0.44445], + "102": [0, 0.69444, 0.21705, 0, 0.30556], + "103": [0.19444, 0.44444, 0.10836, 0, 0.5], + "104": [0, 0.69444, 0.01778, 0, 0.51667], + "105": [0, 0.67937, 0.09718, 0, 0.23889], + "106": [0.19444, 0.67937, 0.09162, 0, 0.26667], + "107": [0, 0.69444, 0.08336, 0, 0.48889], + "108": [0, 0.69444, 0.09483, 0, 0.23889], + "109": [0, 0.44444, 0.01778, 0, 0.79445], + "110": [0, 0.44444, 0.01778, 0, 0.51667], + "111": [0, 0.44444, 0.06613, 0, 0.5], + "112": [0.19444, 0.44444, 0.0389, 0, 0.51667], + "113": [0.19444, 0.44444, 0.04169, 0, 0.51667], + "114": [0, 0.44444, 0.10836, 0, 0.34167], + "115": [0, 0.44444, 0.0778, 0, 0.38333], + "116": [0, 0.57143, 0.07225, 0, 0.36111], + "117": [0, 0.44444, 0.04169, 0, 0.51667], + "118": [0, 0.44444, 0.10836, 0, 0.46111], + "119": [0, 0.44444, 0.10836, 0, 0.68334], + "120": [0, 0.44444, 0.09169, 0, 0.46111], + "121": [0.19444, 0.44444, 0.10836, 0, 0.46111], + "122": [0, 0.44444, 0.08752, 0, 0.43472], + "126": [0.35, 0.32659, 0.08826, 0, 0.5], + "160": [0, 0, 0, 0, 0.25], + "168": [0, 0.67937, 0.06385, 0, 0.5], + "176": [0, 0.69444, 0, 0, 0.73752], + "184": [0.17014, 0, 0, 0, 0.44445], + "305": [0, 0.44444, 0.04169, 0, 0.23889], + "567": [0.19444, 0.44444, 0.04169, 0, 0.26667], + "710": [0, 0.69444, 0.0799, 0, 0.5], + "711": [0, 0.63194, 0.08432, 0, 0.5], + "713": [0, 0.60889, 0.08776, 0, 0.5], + "714": [0, 0.69444, 0.09205, 0, 0.5], + "715": [0, 0.69444, 0, 0, 0.5], + "728": [0, 0.69444, 0.09483, 0, 0.5], + "729": [0, 0.67937, 0.07774, 0, 0.27778], + "730": [0, 0.69444, 0, 0, 0.73752], + "732": [0, 0.67659, 0.08826, 0, 0.5], + "733": [0, 0.69444, 0.09205, 0, 0.5], + "915": [0, 0.69444, 0.13372, 0, 0.54167], + "916": [0, 0.69444, 0, 0, 0.83334], + "920": [0, 0.69444, 0.07555, 0, 0.77778], + "923": [0, 0.69444, 0, 0, 0.61111], + "926": [0, 0.69444, 0.12816, 0, 0.66667], + "928": [0, 0.69444, 0.08094, 0, 0.70834], + "931": [0, 0.69444, 0.11983, 0, 0.72222], + "933": [0, 0.69444, 0.09031, 0, 0.77778], + "934": [0, 0.69444, 0.04603, 0, 0.72222], + "936": [0, 0.69444, 0.09031, 0, 0.77778], + "937": [0, 0.69444, 0.08293, 0, 0.72222], + "8211": [0, 0.44444, 0.08616, 0, 0.5], + "8212": [0, 0.44444, 0.08616, 0, 1.0], + "8216": [0, 0.69444, 0.07816, 0, 0.27778], + "8217": [0, 0.69444, 0.07816, 0, 0.27778], + "8220": [0, 0.69444, 0.14205, 0, 0.5], + "8221": [0, 0.69444, 0.00316, 0, 0.5] + }, + "SansSerif-Regular": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0, 0, 0.31945], + "34": [0, 0.69444, 0, 0, 0.5], + "35": [0.19444, 0.69444, 0, 0, 0.83334], + "36": [0.05556, 0.75, 0, 0, 0.5], + "37": [0.05556, 0.75, 0, 0, 0.83334], + "38": [0, 0.69444, 0, 0, 0.75834], + "39": [0, 0.69444, 0, 0, 0.27778], + "40": [0.25, 0.75, 0, 0, 0.38889], + "41": [0.25, 0.75, 0, 0, 0.38889], + "42": [0, 0.75, 0, 0, 0.5], + "43": [0.08333, 0.58333, 0, 0, 0.77778], + "44": [0.125, 0.08333, 0, 0, 0.27778], + "45": [0, 0.44444, 0, 0, 0.33333], + "46": [0, 0.08333, 0, 0, 0.27778], + "47": [0.25, 0.75, 0, 0, 0.5], + "48": [0, 0.65556, 0, 0, 0.5], + "49": [0, 0.65556, 0, 0, 0.5], + "50": [0, 0.65556, 0, 0, 0.5], + "51": [0, 0.65556, 0, 0, 0.5], + "52": [0, 0.65556, 0, 0, 0.5], + "53": [0, 0.65556, 0, 0, 0.5], + "54": [0, 0.65556, 0, 0, 0.5], + "55": [0, 0.65556, 0, 0, 0.5], + "56": [0, 0.65556, 0, 0, 0.5], + "57": [0, 0.65556, 0, 0, 0.5], + "58": [0, 0.44444, 0, 0, 0.27778], + "59": [0.125, 0.44444, 0, 0, 0.27778], + "61": [-0.13, 0.37, 0, 0, 0.77778], + "63": [0, 0.69444, 0, 0, 0.47222], + "64": [0, 0.69444, 0, 0, 0.66667], + "65": [0, 0.69444, 0, 0, 0.66667], + "66": [0, 0.69444, 0, 0, 0.66667], + "67": [0, 0.69444, 0, 0, 0.63889], + "68": [0, 0.69444, 0, 0, 0.72223], + "69": [0, 0.69444, 0, 0, 0.59722], + "70": [0, 0.69444, 0, 0, 0.56945], + "71": [0, 0.69444, 0, 0, 0.66667], + "72": [0, 0.69444, 0, 0, 0.70834], + "73": [0, 0.69444, 0, 0, 0.27778], + "74": [0, 0.69444, 0, 0, 0.47222], + "75": [0, 0.69444, 0, 0, 0.69445], + "76": [0, 0.69444, 0, 0, 0.54167], + "77": [0, 0.69444, 0, 0, 0.875], + "78": [0, 0.69444, 0, 0, 0.70834], + "79": [0, 0.69444, 0, 0, 0.73611], + "80": [0, 0.69444, 0, 0, 0.63889], + "81": [0.125, 0.69444, 0, 0, 0.73611], + "82": [0, 0.69444, 0, 0, 0.64584], + "83": [0, 0.69444, 0, 0, 0.55556], + "84": [0, 0.69444, 0, 0, 0.68056], + "85": [0, 0.69444, 0, 0, 0.6875], + "86": [0, 0.69444, 0.01389, 0, 0.66667], + "87": [0, 0.69444, 0.01389, 0, 0.94445], + "88": [0, 0.69444, 0, 0, 0.66667], + "89": [0, 0.69444, 0.025, 0, 0.66667], + "90": [0, 0.69444, 0, 0, 0.61111], + "91": [0.25, 0.75, 0, 0, 0.28889], + "93": [0.25, 0.75, 0, 0, 0.28889], + "94": [0, 0.69444, 0, 0, 0.5], + "95": [0.35, 0.09444, 0.02778, 0, 0.5], + "97": [0, 0.44444, 0, 0, 0.48056], + "98": [0, 0.69444, 0, 0, 0.51667], + "99": [0, 0.44444, 0, 0, 0.44445], + "100": [0, 0.69444, 0, 0, 0.51667], + "101": [0, 0.44444, 0, 0, 0.44445], + "102": [0, 0.69444, 0.06944, 0, 0.30556], + "103": [0.19444, 0.44444, 0.01389, 0, 0.5], + "104": [0, 0.69444, 0, 0, 0.51667], + "105": [0, 0.67937, 0, 0, 0.23889], + "106": [0.19444, 0.67937, 0, 0, 0.26667], + "107": [0, 0.69444, 0, 0, 0.48889], + "108": [0, 0.69444, 0, 0, 0.23889], + "109": [0, 0.44444, 0, 0, 0.79445], + "110": [0, 0.44444, 0, 0, 0.51667], + "111": [0, 0.44444, 0, 0, 0.5], + "112": [0.19444, 0.44444, 0, 0, 0.51667], + "113": [0.19444, 0.44444, 0, 0, 0.51667], + "114": [0, 0.44444, 0.01389, 0, 0.34167], + "115": [0, 0.44444, 0, 0, 0.38333], + "116": [0, 0.57143, 0, 0, 0.36111], + "117": [0, 0.44444, 0, 0, 0.51667], + "118": [0, 0.44444, 0.01389, 0, 0.46111], + "119": [0, 0.44444, 0.01389, 0, 0.68334], + "120": [0, 0.44444, 0, 0, 0.46111], + "121": [0.19444, 0.44444, 0.01389, 0, 0.46111], + "122": [0, 0.44444, 0, 0, 0.43472], + "126": [0.35, 0.32659, 0, 0, 0.5], + "160": [0, 0, 0, 0, 0.25], + "168": [0, 0.67937, 0, 0, 0.5], + "176": [0, 0.69444, 0, 0, 0.66667], + "184": [0.17014, 0, 0, 0, 0.44445], + "305": [0, 0.44444, 0, 0, 0.23889], + "567": [0.19444, 0.44444, 0, 0, 0.26667], + "710": [0, 0.69444, 0, 0, 0.5], + "711": [0, 0.63194, 0, 0, 0.5], + "713": [0, 0.60889, 0, 0, 0.5], + "714": [0, 0.69444, 0, 0, 0.5], + "715": [0, 0.69444, 0, 0, 0.5], + "728": [0, 0.69444, 0, 0, 0.5], + "729": [0, 0.67937, 0, 0, 0.27778], + "730": [0, 0.69444, 0, 0, 0.66667], + "732": [0, 0.67659, 0, 0, 0.5], + "733": [0, 0.69444, 0, 0, 0.5], + "915": [0, 0.69444, 0, 0, 0.54167], + "916": [0, 0.69444, 0, 0, 0.83334], + "920": [0, 0.69444, 0, 0, 0.77778], + "923": [0, 0.69444, 0, 0, 0.61111], + "926": [0, 0.69444, 0, 0, 0.66667], + "928": [0, 0.69444, 0, 0, 0.70834], + "931": [0, 0.69444, 0, 0, 0.72222], + "933": [0, 0.69444, 0, 0, 0.77778], + "934": [0, 0.69444, 0, 0, 0.72222], + "936": [0, 0.69444, 0, 0, 0.77778], + "937": [0, 0.69444, 0, 0, 0.72222], + "8211": [0, 0.44444, 0.02778, 0, 0.5], + "8212": [0, 0.44444, 0.02778, 0, 1.0], + "8216": [0, 0.69444, 0, 0, 0.27778], + "8217": [0, 0.69444, 0, 0, 0.27778], + "8220": [0, 0.69444, 0, 0, 0.5], + "8221": [0, 0.69444, 0, 0, 0.5] + }, + "Script-Regular": { + "32": [0, 0, 0, 0, 0.25], + "65": [0, 0.7, 0.22925, 0, 0.80253], + "66": [0, 0.7, 0.04087, 0, 0.90757], + "67": [0, 0.7, 0.1689, 0, 0.66619], + "68": [0, 0.7, 0.09371, 0, 0.77443], + "69": [0, 0.7, 0.18583, 0, 0.56162], + "70": [0, 0.7, 0.13634, 0, 0.89544], + "71": [0, 0.7, 0.17322, 0, 0.60961], + "72": [0, 0.7, 0.29694, 0, 0.96919], + "73": [0, 0.7, 0.19189, 0, 0.80907], + "74": [0.27778, 0.7, 0.19189, 0, 1.05159], + "75": [0, 0.7, 0.31259, 0, 0.91364], + "76": [0, 0.7, 0.19189, 0, 0.87373], + "77": [0, 0.7, 0.15981, 0, 1.08031], + "78": [0, 0.7, 0.3525, 0, 0.9015], + "79": [0, 0.7, 0.08078, 0, 0.73787], + "80": [0, 0.7, 0.08078, 0, 1.01262], + "81": [0, 0.7, 0.03305, 0, 0.88282], + "82": [0, 0.7, 0.06259, 0, 0.85], + "83": [0, 0.7, 0.19189, 0, 0.86767], + "84": [0, 0.7, 0.29087, 0, 0.74697], + "85": [0, 0.7, 0.25815, 0, 0.79996], + "86": [0, 0.7, 0.27523, 0, 0.62204], + "87": [0, 0.7, 0.27523, 0, 0.80532], + "88": [0, 0.7, 0.26006, 0, 0.94445], + "89": [0, 0.7, 0.2939, 0, 0.70961], + "90": [0, 0.7, 0.24037, 0, 0.8212], + "160": [0, 0, 0, 0, 0.25] + }, + "Size1-Regular": { + "32": [0, 0, 0, 0, 0.25], + "40": [0.35001, 0.85, 0, 0, 0.45834], + "41": [0.35001, 0.85, 0, 0, 0.45834], + "47": [0.35001, 0.85, 0, 0, 0.57778], + "91": [0.35001, 0.85, 0, 0, 0.41667], + "92": [0.35001, 0.85, 0, 0, 0.57778], + "93": [0.35001, 0.85, 0, 0, 0.41667], + "123": [0.35001, 0.85, 0, 0, 0.58334], + "125": [0.35001, 0.85, 0, 0, 0.58334], + "160": [0, 0, 0, 0, 0.25], + "710": [0, 0.72222, 0, 0, 0.55556], + "732": [0, 0.72222, 0, 0, 0.55556], + "770": [0, 0.72222, 0, 0, 0.55556], + "771": [0, 0.72222, 0, 0, 0.55556], + "8214": [-0.00099, 0.601, 0, 0, 0.77778], + "8593": [1e-05, 0.6, 0, 0, 0.66667], + "8595": [1e-05, 0.6, 0, 0, 0.66667], + "8657": [1e-05, 0.6, 0, 0, 0.77778], + "8659": [1e-05, 0.6, 0, 0, 0.77778], + "8719": [0.25001, 0.75, 0, 0, 0.94445], + "8720": [0.25001, 0.75, 0, 0, 0.94445], + "8721": [0.25001, 0.75, 0, 0, 1.05556], + "8730": [0.35001, 0.85, 0, 0, 1.0], + "8739": [-0.00599, 0.606, 0, 0, 0.33333], + "8741": [-0.00599, 0.606, 0, 0, 0.55556], + "8747": [0.30612, 0.805, 0.19445, 0, 0.47222], + "8748": [0.306, 0.805, 0.19445, 0, 0.47222], + "8749": [0.306, 0.805, 0.19445, 0, 0.47222], + "8750": [0.30612, 0.805, 0.19445, 0, 0.47222], + "8896": [0.25001, 0.75, 0, 0, 0.83334], + "8897": [0.25001, 0.75, 0, 0, 0.83334], + "8898": [0.25001, 0.75, 0, 0, 0.83334], + "8899": [0.25001, 0.75, 0, 0, 0.83334], + "8968": [0.35001, 0.85, 0, 0, 0.47222], + "8969": [0.35001, 0.85, 0, 0, 0.47222], + "8970": [0.35001, 0.85, 0, 0, 0.47222], + "8971": [0.35001, 0.85, 0, 0, 0.47222], + "9168": [-0.00099, 0.601, 0, 0, 0.66667], + "10216": [0.35001, 0.85, 0, 0, 0.47222], + "10217": [0.35001, 0.85, 0, 0, 0.47222], + "10752": [0.25001, 0.75, 0, 0, 1.11111], + "10753": [0.25001, 0.75, 0, 0, 1.11111], + "10754": [0.25001, 0.75, 0, 0, 1.11111], + "10756": [0.25001, 0.75, 0, 0, 0.83334], + "10758": [0.25001, 0.75, 0, 0, 0.83334] + }, + "Size2-Regular": { + "32": [0, 0, 0, 0, 0.25], + "40": [0.65002, 1.15, 0, 0, 0.59722], + "41": [0.65002, 1.15, 0, 0, 0.59722], + "47": [0.65002, 1.15, 0, 0, 0.81111], + "91": [0.65002, 1.15, 0, 0, 0.47222], + "92": [0.65002, 1.15, 0, 0, 0.81111], + "93": [0.65002, 1.15, 0, 0, 0.47222], + "123": [0.65002, 1.15, 0, 0, 0.66667], + "125": [0.65002, 1.15, 0, 0, 0.66667], + "160": [0, 0, 0, 0, 0.25], + "710": [0, 0.75, 0, 0, 1.0], + "732": [0, 0.75, 0, 0, 1.0], + "770": [0, 0.75, 0, 0, 1.0], + "771": [0, 0.75, 0, 0, 1.0], + "8719": [0.55001, 1.05, 0, 0, 1.27778], + "8720": [0.55001, 1.05, 0, 0, 1.27778], + "8721": [0.55001, 1.05, 0, 0, 1.44445], + "8730": [0.65002, 1.15, 0, 0, 1.0], + "8747": [0.86225, 1.36, 0.44445, 0, 0.55556], + "8748": [0.862, 1.36, 0.44445, 0, 0.55556], + "8749": [0.862, 1.36, 0.44445, 0, 0.55556], + "8750": [0.86225, 1.36, 0.44445, 0, 0.55556], + "8896": [0.55001, 1.05, 0, 0, 1.11111], + "8897": [0.55001, 1.05, 0, 0, 1.11111], + "8898": [0.55001, 1.05, 0, 0, 1.11111], + "8899": [0.55001, 1.05, 0, 0, 1.11111], + "8968": [0.65002, 1.15, 0, 0, 0.52778], + "8969": [0.65002, 1.15, 0, 0, 0.52778], + "8970": [0.65002, 1.15, 0, 0, 0.52778], + "8971": [0.65002, 1.15, 0, 0, 0.52778], + "10216": [0.65002, 1.15, 0, 0, 0.61111], + "10217": [0.65002, 1.15, 0, 0, 0.61111], + "10752": [0.55001, 1.05, 0, 0, 1.51112], + "10753": [0.55001, 1.05, 0, 0, 1.51112], + "10754": [0.55001, 1.05, 0, 0, 1.51112], + "10756": [0.55001, 1.05, 0, 0, 1.11111], + "10758": [0.55001, 1.05, 0, 0, 1.11111] + }, + "Size3-Regular": { + "32": [0, 0, 0, 0, 0.25], + "40": [0.95003, 1.45, 0, 0, 0.73611], + "41": [0.95003, 1.45, 0, 0, 0.73611], + "47": [0.95003, 1.45, 0, 0, 1.04445], + "91": [0.95003, 1.45, 0, 0, 0.52778], + "92": [0.95003, 1.45, 0, 0, 1.04445], + "93": [0.95003, 1.45, 0, 0, 0.52778], + "123": [0.95003, 1.45, 0, 0, 0.75], + "125": [0.95003, 1.45, 0, 0, 0.75], + "160": [0, 0, 0, 0, 0.25], + "710": [0, 0.75, 0, 0, 1.44445], + "732": [0, 0.75, 0, 0, 1.44445], + "770": [0, 0.75, 0, 0, 1.44445], + "771": [0, 0.75, 0, 0, 1.44445], + "8730": [0.95003, 1.45, 0, 0, 1.0], + "8968": [0.95003, 1.45, 0, 0, 0.58334], + "8969": [0.95003, 1.45, 0, 0, 0.58334], + "8970": [0.95003, 1.45, 0, 0, 0.58334], + "8971": [0.95003, 1.45, 0, 0, 0.58334], + "10216": [0.95003, 1.45, 0, 0, 0.75], + "10217": [0.95003, 1.45, 0, 0, 0.75] + }, + "Size4-Regular": { + "32": [0, 0, 0, 0, 0.25], + "40": [1.25003, 1.75, 0, 0, 0.79167], + "41": [1.25003, 1.75, 0, 0, 0.79167], + "47": [1.25003, 1.75, 0, 0, 1.27778], + "91": [1.25003, 1.75, 0, 0, 0.58334], + "92": [1.25003, 1.75, 0, 0, 1.27778], + "93": [1.25003, 1.75, 0, 0, 0.58334], + "123": [1.25003, 1.75, 0, 0, 0.80556], + "125": [1.25003, 1.75, 0, 0, 0.80556], + "160": [0, 0, 0, 0, 0.25], + "710": [0, 0.825, 0, 0, 1.8889], + "732": [0, 0.825, 0, 0, 1.8889], + "770": [0, 0.825, 0, 0, 1.8889], + "771": [0, 0.825, 0, 0, 1.8889], + "8730": [1.25003, 1.75, 0, 0, 1.0], + "8968": [1.25003, 1.75, 0, 0, 0.63889], + "8969": [1.25003, 1.75, 0, 0, 0.63889], + "8970": [1.25003, 1.75, 0, 0, 0.63889], + "8971": [1.25003, 1.75, 0, 0, 0.63889], + "9115": [0.64502, 1.155, 0, 0, 0.875], + "9116": [1e-05, 0.6, 0, 0, 0.875], + "9117": [0.64502, 1.155, 0, 0, 0.875], + "9118": [0.64502, 1.155, 0, 0, 0.875], + "9119": [1e-05, 0.6, 0, 0, 0.875], + "9120": [0.64502, 1.155, 0, 0, 0.875], + "9121": [0.64502, 1.155, 0, 0, 0.66667], + "9122": [-0.00099, 0.601, 0, 0, 0.66667], + "9123": [0.64502, 1.155, 0, 0, 0.66667], + "9124": [0.64502, 1.155, 0, 0, 0.66667], + "9125": [-0.00099, 0.601, 0, 0, 0.66667], + "9126": [0.64502, 1.155, 0, 0, 0.66667], + "9127": [1e-05, 0.9, 0, 0, 0.88889], + "9128": [0.65002, 1.15, 0, 0, 0.88889], + "9129": [0.90001, 0, 0, 0, 0.88889], + "9130": [0, 0.3, 0, 0, 0.88889], + "9131": [1e-05, 0.9, 0, 0, 0.88889], + "9132": [0.65002, 1.15, 0, 0, 0.88889], + "9133": [0.90001, 0, 0, 0, 0.88889], + "9143": [0.88502, 0.915, 0, 0, 1.05556], + "10216": [1.25003, 1.75, 0, 0, 0.80556], + "10217": [1.25003, 1.75, 0, 0, 0.80556], + "57344": [-0.00499, 0.605, 0, 0, 1.05556], + "57345": [-0.00499, 0.605, 0, 0, 1.05556], + "57680": [0, 0.12, 0, 0, 0.45], + "57681": [0, 0.12, 0, 0, 0.45], + "57682": [0, 0.12, 0, 0, 0.45], + "57683": [0, 0.12, 0, 0, 0.45] + }, + "Typewriter-Regular": { + "32": [0, 0, 0, 0, 0.525], + "33": [0, 0.61111, 0, 0, 0.525], + "34": [0, 0.61111, 0, 0, 0.525], + "35": [0, 0.61111, 0, 0, 0.525], + "36": [0.08333, 0.69444, 0, 0, 0.525], + "37": [0.08333, 0.69444, 0, 0, 0.525], + "38": [0, 0.61111, 0, 0, 0.525], + "39": [0, 0.61111, 0, 0, 0.525], + "40": [0.08333, 0.69444, 0, 0, 0.525], + "41": [0.08333, 0.69444, 0, 0, 0.525], + "42": [0, 0.52083, 0, 0, 0.525], + "43": [-0.08056, 0.53055, 0, 0, 0.525], + "44": [0.13889, 0.125, 0, 0, 0.525], + "45": [-0.08056, 0.53055, 0, 0, 0.525], + "46": [0, 0.125, 0, 0, 0.525], + "47": [0.08333, 0.69444, 0, 0, 0.525], + "48": [0, 0.61111, 0, 0, 0.525], + "49": [0, 0.61111, 0, 0, 0.525], + "50": [0, 0.61111, 0, 0, 0.525], + "51": [0, 0.61111, 0, 0, 0.525], + "52": [0, 0.61111, 0, 0, 0.525], + "53": [0, 0.61111, 0, 0, 0.525], + "54": [0, 0.61111, 0, 0, 0.525], + "55": [0, 0.61111, 0, 0, 0.525], + "56": [0, 0.61111, 0, 0, 0.525], + "57": [0, 0.61111, 0, 0, 0.525], + "58": [0, 0.43056, 0, 0, 0.525], + "59": [0.13889, 0.43056, 0, 0, 0.525], + "60": [-0.05556, 0.55556, 0, 0, 0.525], + "61": [-0.19549, 0.41562, 0, 0, 0.525], + "62": [-0.05556, 0.55556, 0, 0, 0.525], + "63": [0, 0.61111, 0, 0, 0.525], + "64": [0, 0.61111, 0, 0, 0.525], + "65": [0, 0.61111, 0, 0, 0.525], + "66": [0, 0.61111, 0, 0, 0.525], + "67": [0, 0.61111, 0, 0, 0.525], + "68": [0, 0.61111, 0, 0, 0.525], + "69": [0, 0.61111, 0, 0, 0.525], + "70": [0, 0.61111, 0, 0, 0.525], + "71": [0, 0.61111, 0, 0, 0.525], + "72": [0, 0.61111, 0, 0, 0.525], + "73": [0, 0.61111, 0, 0, 0.525], + "74": [0, 0.61111, 0, 0, 0.525], + "75": [0, 0.61111, 0, 0, 0.525], + "76": [0, 0.61111, 0, 0, 0.525], + "77": [0, 0.61111, 0, 0, 0.525], + "78": [0, 0.61111, 0, 0, 0.525], + "79": [0, 0.61111, 0, 0, 0.525], + "80": [0, 0.61111, 0, 0, 0.525], + "81": [0.13889, 0.61111, 0, 0, 0.525], + "82": [0, 0.61111, 0, 0, 0.525], + "83": [0, 0.61111, 0, 0, 0.525], + "84": [0, 0.61111, 0, 0, 0.525], + "85": [0, 0.61111, 0, 0, 0.525], + "86": [0, 0.61111, 0, 0, 0.525], + "87": [0, 0.61111, 0, 0, 0.525], + "88": [0, 0.61111, 0, 0, 0.525], + "89": [0, 0.61111, 0, 0, 0.525], + "90": [0, 0.61111, 0, 0, 0.525], + "91": [0.08333, 0.69444, 0, 0, 0.525], + "92": [0.08333, 0.69444, 0, 0, 0.525], + "93": [0.08333, 0.69444, 0, 0, 0.525], + "94": [0, 0.61111, 0, 0, 0.525], + "95": [0.09514, 0, 0, 0, 0.525], + "96": [0, 0.61111, 0, 0, 0.525], + "97": [0, 0.43056, 0, 0, 0.525], + "98": [0, 0.61111, 0, 0, 0.525], + "99": [0, 0.43056, 0, 0, 0.525], + "100": [0, 0.61111, 0, 0, 0.525], + "101": [0, 0.43056, 0, 0, 0.525], + "102": [0, 0.61111, 0, 0, 0.525], + "103": [0.22222, 0.43056, 0, 0, 0.525], + "104": [0, 0.61111, 0, 0, 0.525], + "105": [0, 0.61111, 0, 0, 0.525], + "106": [0.22222, 0.61111, 0, 0, 0.525], + "107": [0, 0.61111, 0, 0, 0.525], + "108": [0, 0.61111, 0, 0, 0.525], + "109": [0, 0.43056, 0, 0, 0.525], + "110": [0, 0.43056, 0, 0, 0.525], + "111": [0, 0.43056, 0, 0, 0.525], + "112": [0.22222, 0.43056, 0, 0, 0.525], + "113": [0.22222, 0.43056, 0, 0, 0.525], + "114": [0, 0.43056, 0, 0, 0.525], + "115": [0, 0.43056, 0, 0, 0.525], + "116": [0, 0.55358, 0, 0, 0.525], + "117": [0, 0.43056, 0, 0, 0.525], + "118": [0, 0.43056, 0, 0, 0.525], + "119": [0, 0.43056, 0, 0, 0.525], + "120": [0, 0.43056, 0, 0, 0.525], + "121": [0.22222, 0.43056, 0, 0, 0.525], + "122": [0, 0.43056, 0, 0, 0.525], + "123": [0.08333, 0.69444, 0, 0, 0.525], + "124": [0.08333, 0.69444, 0, 0, 0.525], + "125": [0.08333, 0.69444, 0, 0, 0.525], + "126": [0, 0.61111, 0, 0, 0.525], + "127": [0, 0.61111, 0, 0, 0.525], + "160": [0, 0, 0, 0, 0.525], + "176": [0, 0.61111, 0, 0, 0.525], + "184": [0.19445, 0, 0, 0, 0.525], + "305": [0, 0.43056, 0, 0, 0.525], + "567": [0.22222, 0.43056, 0, 0, 0.525], + "711": [0, 0.56597, 0, 0, 0.525], + "713": [0, 0.56555, 0, 0, 0.525], + "714": [0, 0.61111, 0, 0, 0.525], + "715": [0, 0.61111, 0, 0, 0.525], + "728": [0, 0.61111, 0, 0, 0.525], + "730": [0, 0.61111, 0, 0, 0.525], + "770": [0, 0.61111, 0, 0, 0.525], + "771": [0, 0.61111, 0, 0, 0.525], + "776": [0, 0.61111, 0, 0, 0.525], + "915": [0, 0.61111, 0, 0, 0.525], + "916": [0, 0.61111, 0, 0, 0.525], + "920": [0, 0.61111, 0, 0, 0.525], + "923": [0, 0.61111, 0, 0, 0.525], + "926": [0, 0.61111, 0, 0, 0.525], + "928": [0, 0.61111, 0, 0, 0.525], + "931": [0, 0.61111, 0, 0, 0.525], + "933": [0, 0.61111, 0, 0, 0.525], + "934": [0, 0.61111, 0, 0, 0.525], + "936": [0, 0.61111, 0, 0, 0.525], + "937": [0, 0.61111, 0, 0, 0.525], + "8216": [0, 0.61111, 0, 0, 0.525], + "8217": [0, 0.61111, 0, 0, 0.525], + "8242": [0, 0.61111, 0, 0, 0.525], + "9251": [0.11111, 0.21944, 0, 0, 0.525] + } +}); +;// ./src/fontMetrics.ts + +// This map contains a mapping from font name and character code to character +// metrics, including height, depth, italic correction, and skew (kern from the +// character to the corresponding \skewchar) +// This map is generated via `make metrics`. It should not be changed manually. + + +/** + * This file contains metrics regarding fonts and individual symbols. The sigma + * and xi variables, as well as the metricMap map contain data extracted from + * TeX, TeX font metrics, and the TTF files. These data are then exposed via the + * `metrics` variable and the getCharacterMetrics function. + */ + +// In TeX, there are actually three sets of dimensions, one for each of +// textstyle (size index 5 and higher: >=9pt), scriptstyle (size index 3 and 4: +// 7-8pt), and scriptscriptstyle (size index 1 and 2: 5-6pt). These are +// provided in the arrays below, in that order. +// +// The font metrics are stored in fonts cmsy10, cmsy7, and cmsy5 respectively. +// This was determined by running the following script: +// +// latex -interaction=nonstopmode \ +// '\documentclass{article}\usepackage{amsmath}\begin{document}' \ +// '$a$ \expandafter\show\the\textfont2' \ +// '\expandafter\show\the\scriptfont2' \ +// '\expandafter\show\the\scriptscriptfont2' \ +// '\stop' +// +// The metrics themselves were retrieved using the following commands: +// +// tftopl cmsy10 +// tftopl cmsy7 +// tftopl cmsy5 +// +// The output of each of these commands is quite lengthy. The only part we +// care about is the FONTDIMEN section. Each value is measured in EMs. +const sigmasAndXis = { + slant: [0.250, 0.250, 0.250], + // sigma1 + space: [0.000, 0.000, 0.000], + // sigma2 + stretch: [0.000, 0.000, 0.000], + // sigma3 + shrink: [0.000, 0.000, 0.000], + // sigma4 + xHeight: [0.431, 0.431, 0.431], + // sigma5 + quad: [1.000, 1.171, 1.472], + // sigma6 + extraSpace: [0.000, 0.000, 0.000], + // sigma7 + num1: [0.677, 0.732, 0.925], + // sigma8 + num2: [0.394, 0.384, 0.387], + // sigma9 + num3: [0.444, 0.471, 0.504], + // sigma10 + denom1: [0.686, 0.752, 1.025], + // sigma11 + denom2: [0.345, 0.344, 0.532], + // sigma12 + sup1: [0.413, 0.503, 0.504], + // sigma13 + sup2: [0.363, 0.431, 0.404], + // sigma14 + sup3: [0.289, 0.286, 0.294], + // sigma15 + sub1: [0.150, 0.143, 0.200], + // sigma16 + sub2: [0.247, 0.286, 0.400], + // sigma17 + supDrop: [0.386, 0.353, 0.494], + // sigma18 + subDrop: [0.050, 0.071, 0.100], + // sigma19 + delim1: [2.390, 1.700, 1.980], + // sigma20 + delim2: [1.010, 1.157, 1.420], + // sigma21 + axisHeight: [0.250, 0.250, 0.250], + // sigma22 + + // These font metrics are extracted from TeX by using tftopl on cmex10.tfm; + // they correspond to the font parameters of the extension fonts (family 3). + // See the TeXbook, page 441. In AMSTeX, the extension fonts scale; to + // match cmex7, we'd use cmex7.tfm values for script and scriptscript + // values. + defaultRuleThickness: [0.04, 0.049, 0.049], + // xi8; cmex7: 0.049 + bigOpSpacing1: [0.111, 0.111, 0.111], + // xi9 + bigOpSpacing2: [0.166, 0.166, 0.166], + // xi10 + bigOpSpacing3: [0.2, 0.2, 0.2], + // xi11 + bigOpSpacing4: [0.6, 0.611, 0.611], + // xi12; cmex7: 0.611 + bigOpSpacing5: [0.1, 0.143, 0.143], + // xi13; cmex7: 0.143 + + // The \sqrt rule width is taken from the height of the surd character. + // Since we use the same font at all sizes, this thickness doesn't scale. + sqrtRuleThickness: [0.04, 0.04, 0.04], + // This value determines how large a pt is, for metrics which are defined + // in terms of pts. + // This value is also used in katex.scss; if you change it make sure the + // values match. + ptPerEm: [10.0, 10.0, 10.0], + // The space between adjacent `|` columns in an array definition. From + // `\showthe\doublerulesep` in LaTeX. Equals 2.0 / ptPerEm. + doubleRuleSep: [0.2, 0.2, 0.2], + // The width of separator lines in {array} environments. From + // `\showthe\arrayrulewidth` in LaTeX. Equals 0.4 / ptPerEm. + arrayRuleWidth: [0.04, 0.04, 0.04], + // Two values from LaTeX source2e: + fboxsep: [0.3, 0.3, 0.3], + // 3 pt / ptPerEm + fboxrule: [0.04, 0.04, 0.04] // 0.4 pt / ptPerEm +}; + +// These are very rough approximations. We default to Times New Roman which +// should have Latin-1 and Cyrillic characters, but may not depending on the +// operating system. The metrics do not account for extra height from the +// accents. In the case of Cyrillic characters which have both ascenders and +// descenders we prefer approximations with ascenders, primarily to prevent +// the fraction bar or root line from intersecting the glyph. +// TODO(kevinb) allow union of multiple glyph metrics for better accuracy. +const extraCharacterMap = { + // Latin-1 + 'Å': 'A', + 'Ð': 'D', + 'Þ': 'o', + 'å': 'a', + 'ð': 'd', + 'þ': 'o', + // Cyrillic + 'А': 'A', + 'Б': 'B', + 'В': 'B', + 'Г': 'F', + 'Д': 'A', + 'Е': 'E', + 'Ж': 'K', + 'З': '3', + 'И': 'N', + 'Й': 'N', + 'К': 'K', + 'Л': 'N', + 'М': 'M', + 'Н': 'H', + 'О': 'O', + 'П': 'N', + 'Р': 'P', + 'С': 'C', + 'Т': 'T', + 'У': 'y', + 'Ф': 'O', + 'Х': 'X', + 'Ц': 'U', + 'Ч': 'h', + 'Ш': 'W', + 'Щ': 'W', + 'Ъ': 'B', + 'Ы': 'X', + 'Ь': 'B', + 'Э': '3', + 'Ю': 'X', + 'Я': 'R', + 'а': 'a', + 'б': 'b', + 'в': 'a', + 'г': 'r', + 'д': 'y', + 'е': 'e', + 'ж': 'm', + 'з': 'e', + 'и': 'n', + 'й': 'n', + 'к': 'n', + 'л': 'n', + 'м': 'm', + 'н': 'n', + 'о': 'o', + 'п': 'n', + 'р': 'p', + 'с': 'c', + 'т': 'o', + 'у': 'y', + 'ф': 'b', + 'х': 'x', + 'ц': 'n', + 'ч': 'n', + 'ш': 'w', + 'щ': 'w', + 'ъ': 'a', + 'ы': 'm', + 'ь': 'a', + 'э': 'e', + 'ю': 'm', + 'я': 'r' +}; + +/** + * This function adds new font metrics to default metricMap + * It can also override existing metrics + */ +function setFontMetrics(fontName, metrics) { + fontMetricsData[fontName] = metrics; +} + +/** + * This function is a convenience function for looking up information in the + * metricMap table. It takes a character as a string, and a font. + * + * Note: the `width` property may be undefined if fontMetricsData.js wasn't + * built using `Make extended_metrics`. + */ +function getCharacterMetrics(character, font, mode) { + if (!fontMetricsData[font]) { + throw new Error("Font metrics not found for font: " + font + "."); + } + let ch = character.charCodeAt(0); + let metrics = fontMetricsData[font][ch]; + if (!metrics && character[0] in extraCharacterMap) { + ch = extraCharacterMap[character[0]].charCodeAt(0); + metrics = fontMetricsData[font][ch]; + } + if (!metrics && mode === 'text') { + // We don't typically have font metrics for Asian scripts. + // But since we support them in text mode, we need to return + // some sort of metrics. + // So if the character is in a script we support but we + // don't have metrics for it, just use the metrics for + // the Latin capital letter M. This is close enough because + // we (currently) only care about the height of the glyph + // not its width. + if (supportedCodepoint(ch)) { + metrics = fontMetricsData[font][77]; // 77 is the charcode for 'M' + } + } + if (metrics) { + return { + depth: metrics[0], + height: metrics[1], + italic: metrics[2], + skew: metrics[3], + width: metrics[4] + }; + } +} +const fontMetricsBySizeIndex = {}; + +/** + * Get the font metrics for a given size. + */ +function getGlobalMetrics(size) { + let sizeIndex; + if (size >= 5) { + sizeIndex = 0; + } else if (size >= 3) { + sizeIndex = 1; + } else { + sizeIndex = 2; + } + if (!fontMetricsBySizeIndex[sizeIndex]) { + const metrics = fontMetricsBySizeIndex[sizeIndex] = { + cssEmPerMu: sigmasAndXis.quad[sizeIndex] / 18 + }; + for (const key in sigmasAndXis) { + if (sigmasAndXis.hasOwnProperty(key)) { + metrics[key] = sigmasAndXis[key][sizeIndex]; + } + } + } + return fontMetricsBySizeIndex[sizeIndex]; +} +;// ./src/symbols.ts +/** + * This file holds a list of all no-argument functions and single-character + * symbols (like 'a' or ';'). + * + * For each of the symbols, there are three properties they can have: + * - font (required): the font to be used for this symbol. Either "main" (the + normal font), or "ams" (the ams fonts). + * - group (required): the ParseNode group type the symbol should have (i.e. + "textord", "mathord", etc). + See https://github.com/KaTeX/KaTeX/wiki/Examining-TeX#group-types + * - replace: the character that this symbol or function should be + * replaced with (i.e. "\phi" has a replace value of "\u03d5", the phi + * character in the main font). + * + * The outermost map in the table indicates what mode the symbols should be + * accepted in (e.g. "math" or "text"). + */ + +// Some of these have a "-token" suffix since these are also used as `ParseNode` +// types for raw text tokens, and we want to avoid conflicts with higher-level +// `ParseNode` types. These `ParseNode`s are constructed within `Parser` by +// looking up the `symbols` map. + +const symbols = { + "math": {}, + "text": {} +}; +/* harmony default export */ var src_symbols = (symbols); + +/** `acceptUnicodeChar = true` is only applicable if `replace` is set. */ +function defineSymbol(mode, font, group, replace, name, acceptUnicodeChar) { + symbols[mode][name] = { + font, + group, + replace + }; + if (acceptUnicodeChar && replace) { + symbols[mode][replace] = symbols[mode][name]; + } +} + +// Some abbreviations for commonly used strings. +// This helps minify the code, and also spotting typos using jshint. + +// modes: +const math = "math"; +const symbols_text = "text"; + +// fonts: +const main = "main"; +const ams = "ams"; + +// groups: +const accent = "accent-token"; +const bin = "bin"; +const symbols_close = "close"; +const inner = "inner"; +const mathord = "mathord"; +const op = "op-token"; +const symbols_open = "open"; +const punct = "punct"; +const rel = "rel"; +const spacing = "spacing"; +const textord = "textord"; + +// Now comes the symbol table + +// Relation Symbols +defineSymbol(math, main, rel, "\u2261", "\\equiv", true); +defineSymbol(math, main, rel, "\u227a", "\\prec", true); +defineSymbol(math, main, rel, "\u227b", "\\succ", true); +defineSymbol(math, main, rel, "\u223c", "\\sim", true); +defineSymbol(math, main, rel, "\u22a5", "\\perp"); +defineSymbol(math, main, rel, "\u2aaf", "\\preceq", true); +defineSymbol(math, main, rel, "\u2ab0", "\\succeq", true); +defineSymbol(math, main, rel, "\u2243", "\\simeq", true); +defineSymbol(math, main, rel, "\u2223", "\\mid", true); +defineSymbol(math, main, rel, "\u226a", "\\ll", true); +defineSymbol(math, main, rel, "\u226b", "\\gg", true); +defineSymbol(math, main, rel, "\u224d", "\\asymp", true); +defineSymbol(math, main, rel, "\u2225", "\\parallel"); +defineSymbol(math, main, rel, "\u22c8", "\\bowtie", true); +defineSymbol(math, main, rel, "\u2323", "\\smile", true); +defineSymbol(math, main, rel, "\u2291", "\\sqsubseteq", true); +defineSymbol(math, main, rel, "\u2292", "\\sqsupseteq", true); +defineSymbol(math, main, rel, "\u2250", "\\doteq", true); +defineSymbol(math, main, rel, "\u2322", "\\frown", true); +defineSymbol(math, main, rel, "\u220b", "\\ni", true); +defineSymbol(math, main, rel, "\u221d", "\\propto", true); +defineSymbol(math, main, rel, "\u22a2", "\\vdash", true); +defineSymbol(math, main, rel, "\u22a3", "\\dashv", true); +defineSymbol(math, main, rel, "\u220b", "\\owns"); + +// Punctuation +defineSymbol(math, main, punct, "\u002e", "\\ldotp"); +defineSymbol(math, main, punct, "\u22c5", "\\cdotp"); +// The KaTeX fonts do not contain U+00B7. Use the centered dot glyph at U+22C5 +// in both modes, but keep math-mode punctuation spacing only in math mode. +defineSymbol(math, main, punct, "\u22c5", "\u00b7"); +defineSymbol(symbols_text, main, textord, "\u22c5", "\u00b7"); + +// Misc Symbols +defineSymbol(math, main, textord, "\u0023", "\\#"); +defineSymbol(symbols_text, main, textord, "\u0023", "\\#"); +defineSymbol(math, main, textord, "\u0026", "\\&"); +defineSymbol(symbols_text, main, textord, "\u0026", "\\&"); +defineSymbol(math, main, textord, "\u2135", "\\aleph", true); +defineSymbol(math, main, textord, "\u2200", "\\forall", true); +defineSymbol(math, main, textord, "\u210f", "\\hbar", true); +defineSymbol(math, main, textord, "\u2203", "\\exists", true); +defineSymbol(math, main, textord, "\u2207", "\\nabla", true); +defineSymbol(math, main, textord, "\u266d", "\\flat", true); +defineSymbol(math, main, textord, "\u2113", "\\ell", true); +defineSymbol(math, main, textord, "\u266e", "\\natural", true); +defineSymbol(math, main, textord, "\u2663", "\\clubsuit", true); +defineSymbol(math, main, textord, "\u2118", "\\wp", true); +defineSymbol(math, main, textord, "\u266f", "\\sharp", true); +defineSymbol(math, main, textord, "\u2662", "\\diamondsuit", true); +defineSymbol(math, main, textord, "\u211c", "\\Re", true); +defineSymbol(math, main, textord, "\u2661", "\\heartsuit", true); +defineSymbol(math, main, textord, "\u2111", "\\Im", true); +defineSymbol(math, main, textord, "\u2660", "\\spadesuit", true); +defineSymbol(math, main, textord, "\u00a7", "\\S", true); +defineSymbol(symbols_text, main, textord, "\u00a7", "\\S"); +defineSymbol(math, main, textord, "\u00b6", "\\P", true); +defineSymbol(symbols_text, main, textord, "\u00b6", "\\P"); + +// Math and Text +defineSymbol(math, main, textord, "\u2020", "\\dag"); +defineSymbol(symbols_text, main, textord, "\u2020", "\\dag"); +defineSymbol(symbols_text, main, textord, "\u2020", "\\textdagger"); +defineSymbol(math, main, textord, "\u2021", "\\ddag"); +defineSymbol(symbols_text, main, textord, "\u2021", "\\ddag"); +defineSymbol(symbols_text, main, textord, "\u2021", "\\textdaggerdbl"); + +// Large Delimiters +defineSymbol(math, main, symbols_close, "\u23b1", "\\rmoustache", true); +defineSymbol(math, main, symbols_open, "\u23b0", "\\lmoustache", true); +defineSymbol(math, main, symbols_close, "\u27ef", "\\rgroup", true); +defineSymbol(math, main, symbols_open, "\u27ee", "\\lgroup", true); + +// Binary Operators +defineSymbol(math, main, bin, "\u2213", "\\mp", true); +defineSymbol(math, main, bin, "\u2296", "\\ominus", true); +defineSymbol(math, main, bin, "\u228e", "\\uplus", true); +defineSymbol(math, main, bin, "\u2293", "\\sqcap", true); +defineSymbol(math, main, bin, "\u2217", "\\ast"); +defineSymbol(math, main, bin, "\u2294", "\\sqcup", true); +defineSymbol(math, main, bin, "\u25ef", "\\bigcirc", true); +defineSymbol(math, main, bin, "\u2219", "\\bullet", true); +defineSymbol(math, main, bin, "\u2021", "\\ddagger"); +defineSymbol(math, main, bin, "\u2240", "\\wr", true); +defineSymbol(math, main, bin, "\u2a3f", "\\amalg"); +defineSymbol(math, main, bin, "\u0026", "\\And"); // from amsmath + +// Arrow Symbols +defineSymbol(math, main, rel, "\u27f5", "\\longleftarrow", true); +defineSymbol(math, main, rel, "\u21d0", "\\Leftarrow", true); +defineSymbol(math, main, rel, "\u27f8", "\\Longleftarrow", true); +defineSymbol(math, main, rel, "\u27f6", "\\longrightarrow", true); +defineSymbol(math, main, rel, "\u21d2", "\\Rightarrow", true); +defineSymbol(math, main, rel, "\u27f9", "\\Longrightarrow", true); +defineSymbol(math, main, rel, "\u2194", "\\leftrightarrow", true); +defineSymbol(math, main, rel, "\u27f7", "\\longleftrightarrow", true); +defineSymbol(math, main, rel, "\u21d4", "\\Leftrightarrow", true); +defineSymbol(math, main, rel, "\u27fa", "\\Longleftrightarrow", true); +defineSymbol(math, main, rel, "\u21a6", "\\mapsto", true); +defineSymbol(math, main, rel, "\u27fc", "\\longmapsto", true); +defineSymbol(math, main, rel, "\u2197", "\\nearrow", true); +defineSymbol(math, main, rel, "\u21a9", "\\hookleftarrow", true); +defineSymbol(math, main, rel, "\u21aa", "\\hookrightarrow", true); +defineSymbol(math, main, rel, "\u2198", "\\searrow", true); +defineSymbol(math, main, rel, "\u21bc", "\\leftharpoonup", true); +defineSymbol(math, main, rel, "\u21c0", "\\rightharpoonup", true); +defineSymbol(math, main, rel, "\u2199", "\\swarrow", true); +defineSymbol(math, main, rel, "\u21bd", "\\leftharpoondown", true); +defineSymbol(math, main, rel, "\u21c1", "\\rightharpoondown", true); +defineSymbol(math, main, rel, "\u2196", "\\nwarrow", true); +defineSymbol(math, main, rel, "\u21cc", "\\rightleftharpoons", true); + +// AMS Negated Binary Relations +defineSymbol(math, ams, rel, "\u226e", "\\nless", true); +// Symbol names preceded by "@" each have a corresponding macro. +defineSymbol(math, ams, rel, "\ue010", "\\@nleqslant"); +defineSymbol(math, ams, rel, "\ue011", "\\@nleqq"); +defineSymbol(math, ams, rel, "\u2a87", "\\lneq", true); +defineSymbol(math, ams, rel, "\u2268", "\\lneqq", true); +defineSymbol(math, ams, rel, "\ue00c", "\\@lvertneqq"); +defineSymbol(math, ams, rel, "\u22e6", "\\lnsim", true); +defineSymbol(math, ams, rel, "\u2a89", "\\lnapprox", true); +defineSymbol(math, ams, rel, "\u2280", "\\nprec", true); +// unicode-math maps \u22e0 to \npreccurlyeq. We'll use the AMS synonym. +defineSymbol(math, ams, rel, "\u22e0", "\\npreceq", true); +defineSymbol(math, ams, rel, "\u22e8", "\\precnsim", true); +defineSymbol(math, ams, rel, "\u2ab9", "\\precnapprox", true); +defineSymbol(math, ams, rel, "\u2241", "\\nsim", true); +defineSymbol(math, ams, rel, "\ue006", "\\@nshortmid"); +defineSymbol(math, ams, rel, "\u2224", "\\nmid", true); +defineSymbol(math, ams, rel, "\u22ac", "\\nvdash", true); +defineSymbol(math, ams, rel, "\u22ad", "\\nvDash", true); +defineSymbol(math, ams, rel, "\u22ea", "\\ntriangleleft"); +defineSymbol(math, ams, rel, "\u22ec", "\\ntrianglelefteq", true); +defineSymbol(math, ams, rel, "\u228a", "\\subsetneq", true); +defineSymbol(math, ams, rel, "\ue01a", "\\@varsubsetneq"); +defineSymbol(math, ams, rel, "\u2acb", "\\subsetneqq", true); +defineSymbol(math, ams, rel, "\ue017", "\\@varsubsetneqq"); +defineSymbol(math, ams, rel, "\u226f", "\\ngtr", true); +defineSymbol(math, ams, rel, "\ue00f", "\\@ngeqslant"); +defineSymbol(math, ams, rel, "\ue00e", "\\@ngeqq"); +defineSymbol(math, ams, rel, "\u2a88", "\\gneq", true); +defineSymbol(math, ams, rel, "\u2269", "\\gneqq", true); +defineSymbol(math, ams, rel, "\ue00d", "\\@gvertneqq"); +defineSymbol(math, ams, rel, "\u22e7", "\\gnsim", true); +defineSymbol(math, ams, rel, "\u2a8a", "\\gnapprox", true); +defineSymbol(math, ams, rel, "\u2281", "\\nsucc", true); +// unicode-math maps \u22e1 to \nsucccurlyeq. We'll use the AMS synonym. +defineSymbol(math, ams, rel, "\u22e1", "\\nsucceq", true); +defineSymbol(math, ams, rel, "\u22e9", "\\succnsim", true); +defineSymbol(math, ams, rel, "\u2aba", "\\succnapprox", true); +// unicode-math maps \u2246 to \simneqq. We'll use the AMS synonym. +defineSymbol(math, ams, rel, "\u2246", "\\ncong", true); +defineSymbol(math, ams, rel, "\ue007", "\\@nshortparallel"); +defineSymbol(math, ams, rel, "\u2226", "\\nparallel", true); +defineSymbol(math, ams, rel, "\u22af", "\\nVDash", true); +defineSymbol(math, ams, rel, "\u22eb", "\\ntriangleright"); +defineSymbol(math, ams, rel, "\u22ed", "\\ntrianglerighteq", true); +defineSymbol(math, ams, rel, "\ue018", "\\@nsupseteqq"); +defineSymbol(math, ams, rel, "\u228b", "\\supsetneq", true); +defineSymbol(math, ams, rel, "\ue01b", "\\@varsupsetneq"); +defineSymbol(math, ams, rel, "\u2acc", "\\supsetneqq", true); +defineSymbol(math, ams, rel, "\ue019", "\\@varsupsetneqq"); +defineSymbol(math, ams, rel, "\u22ae", "\\nVdash", true); +defineSymbol(math, ams, rel, "\u2ab5", "\\precneqq", true); +defineSymbol(math, ams, rel, "\u2ab6", "\\succneqq", true); +defineSymbol(math, ams, rel, "\ue016", "\\@nsubseteqq"); +defineSymbol(math, ams, bin, "\u22b4", "\\unlhd"); +defineSymbol(math, ams, bin, "\u22b5", "\\unrhd"); + +// AMS Negated Arrows +defineSymbol(math, ams, rel, "\u219a", "\\nleftarrow", true); +defineSymbol(math, ams, rel, "\u219b", "\\nrightarrow", true); +defineSymbol(math, ams, rel, "\u21cd", "\\nLeftarrow", true); +defineSymbol(math, ams, rel, "\u21cf", "\\nRightarrow", true); +defineSymbol(math, ams, rel, "\u21ae", "\\nleftrightarrow", true); +defineSymbol(math, ams, rel, "\u21ce", "\\nLeftrightarrow", true); + +// AMS Misc +defineSymbol(math, ams, rel, "\u25b3", "\\vartriangle"); +defineSymbol(math, ams, textord, "\u210f", "\\hslash"); +defineSymbol(math, ams, textord, "\u25bd", "\\triangledown"); +defineSymbol(math, ams, textord, "\u25ca", "\\lozenge"); +defineSymbol(math, ams, textord, "\u24c8", "\\circledS"); +defineSymbol(math, ams, textord, "\u00ae", "\\circledR"); +defineSymbol(symbols_text, ams, textord, "\u00ae", "\\circledR"); +defineSymbol(math, ams, textord, "\u2221", "\\measuredangle", true); +defineSymbol(math, ams, textord, "\u2204", "\\nexists"); +defineSymbol(math, ams, textord, "\u2127", "\\mho"); +defineSymbol(math, ams, textord, "\u2132", "\\Finv", true); +defineSymbol(math, ams, textord, "\u2141", "\\Game", true); +defineSymbol(math, ams, textord, "\u2035", "\\backprime"); +defineSymbol(math, ams, textord, "\u25b2", "\\blacktriangle"); +defineSymbol(math, ams, textord, "\u25bc", "\\blacktriangledown"); +defineSymbol(math, ams, textord, "\u25a0", "\\blacksquare"); +defineSymbol(math, ams, textord, "\u29eb", "\\blacklozenge"); +defineSymbol(math, ams, textord, "\u2605", "\\bigstar"); +defineSymbol(math, ams, textord, "\u2222", "\\sphericalangle", true); +defineSymbol(math, ams, textord, "\u2201", "\\complement", true); +// unicode-math maps U+F0 to \matheth. We map to AMS function \eth +defineSymbol(math, ams, textord, "\u00f0", "\\eth", true); +defineSymbol(symbols_text, main, textord, "\u00f0", "\u00f0"); +defineSymbol(math, ams, textord, "\u2571", "\\diagup"); +defineSymbol(math, ams, textord, "\u2572", "\\diagdown"); +defineSymbol(math, ams, textord, "\u25a1", "\\square"); +defineSymbol(math, ams, textord, "\u25a1", "\\Box"); +defineSymbol(math, ams, textord, "\u25ca", "\\Diamond"); +// unicode-math maps U+A5 to \mathyen. We map to AMS function \yen +defineSymbol(math, ams, textord, "\u00a5", "\\yen", true); +defineSymbol(symbols_text, ams, textord, "\u00a5", "\\yen", true); +defineSymbol(math, ams, textord, "\u2713", "\\checkmark", true); +defineSymbol(symbols_text, ams, textord, "\u2713", "\\checkmark"); + +// AMS Hebrew +defineSymbol(math, ams, textord, "\u2136", "\\beth", true); +defineSymbol(math, ams, textord, "\u2138", "\\daleth", true); +defineSymbol(math, ams, textord, "\u2137", "\\gimel", true); + +// AMS Greek +defineSymbol(math, ams, textord, "\u03dd", "\\digamma", true); +defineSymbol(math, ams, textord, "\u03f0", "\\varkappa"); + +// AMS Delimiters +defineSymbol(math, ams, symbols_open, "\u250c", "\\@ulcorner", true); +defineSymbol(math, ams, symbols_close, "\u2510", "\\@urcorner", true); +defineSymbol(math, ams, symbols_open, "\u2514", "\\@llcorner", true); +defineSymbol(math, ams, symbols_close, "\u2518", "\\@lrcorner", true); + +// AMS Binary Relations +defineSymbol(math, ams, rel, "\u2266", "\\leqq", true); +defineSymbol(math, ams, rel, "\u2a7d", "\\leqslant", true); +defineSymbol(math, ams, rel, "\u2a95", "\\eqslantless", true); +defineSymbol(math, ams, rel, "\u2272", "\\lesssim", true); +defineSymbol(math, ams, rel, "\u2a85", "\\lessapprox", true); +defineSymbol(math, ams, rel, "\u224a", "\\approxeq", true); +defineSymbol(math, ams, bin, "\u22d6", "\\lessdot"); +defineSymbol(math, ams, rel, "\u22d8", "\\lll", true); +defineSymbol(math, ams, rel, "\u2276", "\\lessgtr", true); +defineSymbol(math, ams, rel, "\u22da", "\\lesseqgtr", true); +defineSymbol(math, ams, rel, "\u2a8b", "\\lesseqqgtr", true); +defineSymbol(math, ams, rel, "\u2251", "\\doteqdot"); +defineSymbol(math, ams, rel, "\u2253", "\\risingdotseq", true); +defineSymbol(math, ams, rel, "\u2252", "\\fallingdotseq", true); +defineSymbol(math, ams, rel, "\u223d", "\\backsim", true); +defineSymbol(math, ams, rel, "\u22cd", "\\backsimeq", true); +defineSymbol(math, ams, rel, "\u2ac5", "\\subseteqq", true); +defineSymbol(math, ams, rel, "\u22d0", "\\Subset", true); +defineSymbol(math, ams, rel, "\u228f", "\\sqsubset", true); +defineSymbol(math, ams, rel, "\u227c", "\\preccurlyeq", true); +defineSymbol(math, ams, rel, "\u22de", "\\curlyeqprec", true); +defineSymbol(math, ams, rel, "\u227e", "\\precsim", true); +defineSymbol(math, ams, rel, "\u2ab7", "\\precapprox", true); +defineSymbol(math, ams, rel, "\u22b2", "\\vartriangleleft"); +defineSymbol(math, ams, rel, "\u22b4", "\\trianglelefteq"); +defineSymbol(math, ams, rel, "\u22a8", "\\vDash", true); +defineSymbol(math, ams, rel, "\u22aa", "\\Vvdash", true); +defineSymbol(math, ams, rel, "\u2323", "\\smallsmile"); +defineSymbol(math, ams, rel, "\u2322", "\\smallfrown"); +defineSymbol(math, ams, rel, "\u224f", "\\bumpeq", true); +defineSymbol(math, ams, rel, "\u224e", "\\Bumpeq", true); +defineSymbol(math, ams, rel, "\u2267", "\\geqq", true); +defineSymbol(math, ams, rel, "\u2a7e", "\\geqslant", true); +defineSymbol(math, ams, rel, "\u2a96", "\\eqslantgtr", true); +defineSymbol(math, ams, rel, "\u2273", "\\gtrsim", true); +defineSymbol(math, ams, rel, "\u2a86", "\\gtrapprox", true); +defineSymbol(math, ams, bin, "\u22d7", "\\gtrdot"); +defineSymbol(math, ams, rel, "\u22d9", "\\ggg", true); +defineSymbol(math, ams, rel, "\u2277", "\\gtrless", true); +defineSymbol(math, ams, rel, "\u22db", "\\gtreqless", true); +defineSymbol(math, ams, rel, "\u2a8c", "\\gtreqqless", true); +defineSymbol(math, ams, rel, "\u2256", "\\eqcirc", true); +defineSymbol(math, ams, rel, "\u2257", "\\circeq", true); +defineSymbol(math, ams, rel, "\u225c", "\\triangleq", true); +defineSymbol(math, ams, rel, "\u223c", "\\thicksim"); +defineSymbol(math, ams, rel, "\u2248", "\\thickapprox"); +defineSymbol(math, ams, rel, "\u2ac6", "\\supseteqq", true); +defineSymbol(math, ams, rel, "\u22d1", "\\Supset", true); +defineSymbol(math, ams, rel, "\u2290", "\\sqsupset", true); +defineSymbol(math, ams, rel, "\u227d", "\\succcurlyeq", true); +defineSymbol(math, ams, rel, "\u22df", "\\curlyeqsucc", true); +defineSymbol(math, ams, rel, "\u227f", "\\succsim", true); +defineSymbol(math, ams, rel, "\u2ab8", "\\succapprox", true); +defineSymbol(math, ams, rel, "\u22b3", "\\vartriangleright"); +defineSymbol(math, ams, rel, "\u22b5", "\\trianglerighteq"); +defineSymbol(math, ams, rel, "\u22a9", "\\Vdash", true); +defineSymbol(math, ams, rel, "\u2223", "\\shortmid"); +defineSymbol(math, ams, rel, "\u2225", "\\shortparallel"); +defineSymbol(math, ams, rel, "\u226c", "\\between", true); +defineSymbol(math, ams, rel, "\u22d4", "\\pitchfork", true); +defineSymbol(math, ams, rel, "\u221d", "\\varpropto"); +defineSymbol(math, ams, rel, "\u25c0", "\\blacktriangleleft"); +// unicode-math says that \therefore is a mathord atom. +// We kept the amssymb atom type, which is rel. +defineSymbol(math, ams, rel, "\u2234", "\\therefore", true); +defineSymbol(math, ams, rel, "\u220d", "\\backepsilon"); +defineSymbol(math, ams, rel, "\u25b6", "\\blacktriangleright"); +// unicode-math says that \because is a mathord atom. +// We kept the amssymb atom type, which is rel. +defineSymbol(math, ams, rel, "\u2235", "\\because", true); +defineSymbol(math, ams, rel, "\u22d8", "\\llless"); +defineSymbol(math, ams, rel, "\u22d9", "\\gggtr"); +defineSymbol(math, ams, bin, "\u22b2", "\\lhd"); +defineSymbol(math, ams, bin, "\u22b3", "\\rhd"); +defineSymbol(math, ams, rel, "\u2242", "\\eqsim", true); +defineSymbol(math, main, rel, "\u22c8", "\\Join"); +defineSymbol(math, ams, rel, "\u2251", "\\Doteq", true); + +// AMS Binary Operators +defineSymbol(math, ams, bin, "\u2214", "\\dotplus", true); +defineSymbol(math, ams, bin, "\u2216", "\\smallsetminus"); +defineSymbol(math, ams, bin, "\u22d2", "\\Cap", true); +defineSymbol(math, ams, bin, "\u22d3", "\\Cup", true); +defineSymbol(math, ams, bin, "\u2a5e", "\\doublebarwedge", true); +defineSymbol(math, ams, bin, "\u229f", "\\boxminus", true); +defineSymbol(math, ams, bin, "\u229e", "\\boxplus", true); +defineSymbol(math, ams, bin, "\u22c7", "\\divideontimes", true); +defineSymbol(math, ams, bin, "\u22c9", "\\ltimes", true); +defineSymbol(math, ams, bin, "\u22ca", "\\rtimes", true); +defineSymbol(math, ams, bin, "\u22cb", "\\leftthreetimes", true); +defineSymbol(math, ams, bin, "\u22cc", "\\rightthreetimes", true); +defineSymbol(math, ams, bin, "\u22cf", "\\curlywedge", true); +defineSymbol(math, ams, bin, "\u22ce", "\\curlyvee", true); +defineSymbol(math, ams, bin, "\u229d", "\\circleddash", true); +defineSymbol(math, ams, bin, "\u229b", "\\circledast", true); +defineSymbol(math, ams, bin, "\u22c5", "\\centerdot"); +defineSymbol(math, ams, bin, "\u22ba", "\\intercal", true); +defineSymbol(math, ams, bin, "\u22d2", "\\doublecap"); +defineSymbol(math, ams, bin, "\u22d3", "\\doublecup"); +defineSymbol(math, ams, bin, "\u22a0", "\\boxtimes", true); + +// AMS Arrows +// Note: unicode-math maps \u21e2 to their own function \rightdasharrow. +// We'll map it to AMS function \dashrightarrow. It produces the same atom. +defineSymbol(math, ams, rel, "\u21e2", "\\dashrightarrow", true); +// unicode-math maps \u21e0 to \leftdasharrow. We'll use the AMS synonym. +defineSymbol(math, ams, rel, "\u21e0", "\\dashleftarrow", true); +defineSymbol(math, ams, rel, "\u21c7", "\\leftleftarrows", true); +defineSymbol(math, ams, rel, "\u21c6", "\\leftrightarrows", true); +defineSymbol(math, ams, rel, "\u21da", "\\Lleftarrow", true); +defineSymbol(math, ams, rel, "\u219e", "\\twoheadleftarrow", true); +defineSymbol(math, ams, rel, "\u21a2", "\\leftarrowtail", true); +defineSymbol(math, ams, rel, "\u21ab", "\\looparrowleft", true); +defineSymbol(math, ams, rel, "\u21cb", "\\leftrightharpoons", true); +defineSymbol(math, ams, rel, "\u21b6", "\\curvearrowleft", true); +// unicode-math maps \u21ba to \acwopencirclearrow. We'll use the AMS synonym. +defineSymbol(math, ams, rel, "\u21ba", "\\circlearrowleft", true); +defineSymbol(math, ams, rel, "\u21b0", "\\Lsh", true); +defineSymbol(math, ams, rel, "\u21c8", "\\upuparrows", true); +defineSymbol(math, ams, rel, "\u21bf", "\\upharpoonleft", true); +defineSymbol(math, ams, rel, "\u21c3", "\\downharpoonleft", true); +defineSymbol(math, main, rel, "\u22b6", "\\origof", true); // not in font +defineSymbol(math, main, rel, "\u22b7", "\\imageof", true); // not in font +defineSymbol(math, ams, rel, "\u22b8", "\\multimap", true); +defineSymbol(math, ams, rel, "\u21ad", "\\leftrightsquigarrow", true); +defineSymbol(math, ams, rel, "\u21c9", "\\rightrightarrows", true); +defineSymbol(math, ams, rel, "\u21c4", "\\rightleftarrows", true); +defineSymbol(math, ams, rel, "\u21a0", "\\twoheadrightarrow", true); +defineSymbol(math, ams, rel, "\u21a3", "\\rightarrowtail", true); +defineSymbol(math, ams, rel, "\u21ac", "\\looparrowright", true); +defineSymbol(math, ams, rel, "\u21b7", "\\curvearrowright", true); +// unicode-math maps \u21bb to \cwopencirclearrow. We'll use the AMS synonym. +defineSymbol(math, ams, rel, "\u21bb", "\\circlearrowright", true); +defineSymbol(math, ams, rel, "\u21b1", "\\Rsh", true); +defineSymbol(math, ams, rel, "\u21ca", "\\downdownarrows", true); +defineSymbol(math, ams, rel, "\u21be", "\\upharpoonright", true); +defineSymbol(math, ams, rel, "\u21c2", "\\downharpoonright", true); +defineSymbol(math, ams, rel, "\u21dd", "\\rightsquigarrow", true); +defineSymbol(math, ams, rel, "\u21dd", "\\leadsto"); +defineSymbol(math, ams, rel, "\u21db", "\\Rrightarrow", true); +defineSymbol(math, ams, rel, "\u21be", "\\restriction"); +defineSymbol(math, main, textord, "\u2018", "`"); +defineSymbol(math, main, textord, "$", "\\$"); +defineSymbol(symbols_text, main, textord, "$", "\\$"); +defineSymbol(symbols_text, main, textord, "$", "\\textdollar"); +defineSymbol(math, main, textord, "%", "\\%"); +defineSymbol(symbols_text, main, textord, "%", "\\%"); +defineSymbol(math, main, textord, "_", "\\_"); +defineSymbol(symbols_text, main, textord, "_", "\\_"); +defineSymbol(symbols_text, main, textord, "_", "\\textunderscore"); +defineSymbol(math, main, textord, "\u2220", "\\angle", true); +defineSymbol(math, main, textord, "\u221e", "\\infty", true); +defineSymbol(math, main, textord, "\u2032", "\\prime"); +defineSymbol(math, main, textord, "\u25b3", "\\triangle"); +defineSymbol(math, main, textord, "\u0393", "\\Gamma", true); +defineSymbol(math, main, textord, "\u0394", "\\Delta", true); +defineSymbol(math, main, textord, "\u0398", "\\Theta", true); +defineSymbol(math, main, textord, "\u039b", "\\Lambda", true); +defineSymbol(math, main, textord, "\u039e", "\\Xi", true); +defineSymbol(math, main, textord, "\u03a0", "\\Pi", true); +defineSymbol(math, main, textord, "\u03a3", "\\Sigma", true); +defineSymbol(math, main, textord, "\u03a5", "\\Upsilon", true); +defineSymbol(math, main, textord, "\u03a6", "\\Phi", true); +defineSymbol(math, main, textord, "\u03a8", "\\Psi", true); +defineSymbol(math, main, textord, "\u03a9", "\\Omega", true); +defineSymbol(math, main, textord, "A", "\u0391"); +defineSymbol(math, main, textord, "B", "\u0392"); +defineSymbol(math, main, textord, "E", "\u0395"); +defineSymbol(math, main, textord, "Z", "\u0396"); +defineSymbol(math, main, textord, "H", "\u0397"); +defineSymbol(math, main, textord, "I", "\u0399"); +defineSymbol(math, main, textord, "K", "\u039A"); +defineSymbol(math, main, textord, "M", "\u039C"); +defineSymbol(math, main, textord, "N", "\u039D"); +defineSymbol(math, main, textord, "O", "\u039F"); +defineSymbol(math, main, textord, "P", "\u03A1"); +defineSymbol(math, main, textord, "T", "\u03A4"); +defineSymbol(math, main, textord, "X", "\u03A7"); +defineSymbol(math, main, textord, "\u00ac", "\\neg", true); +defineSymbol(math, main, textord, "\u00ac", "\\lnot"); +defineSymbol(math, main, textord, "\u22a4", "\\top"); +defineSymbol(math, main, textord, "\u22a5", "\\bot"); +defineSymbol(math, main, textord, "\u2205", "\\emptyset"); +defineSymbol(math, ams, textord, "\u2205", "\\varnothing"); +defineSymbol(math, main, mathord, "\u03b1", "\\alpha", true); +defineSymbol(math, main, mathord, "\u03b2", "\\beta", true); +defineSymbol(math, main, mathord, "\u03b3", "\\gamma", true); +defineSymbol(math, main, mathord, "\u03b4", "\\delta", true); +defineSymbol(math, main, mathord, "\u03f5", "\\epsilon", true); +defineSymbol(math, main, mathord, "\u03b6", "\\zeta", true); +defineSymbol(math, main, mathord, "\u03b7", "\\eta", true); +defineSymbol(math, main, mathord, "\u03b8", "\\theta", true); +defineSymbol(math, main, mathord, "\u03b9", "\\iota", true); +defineSymbol(math, main, mathord, "\u03ba", "\\kappa", true); +defineSymbol(math, main, mathord, "\u03bb", "\\lambda", true); +defineSymbol(math, main, mathord, "\u03bc", "\\mu", true); +defineSymbol(math, main, mathord, "\u03bd", "\\nu", true); +defineSymbol(math, main, mathord, "\u03be", "\\xi", true); +defineSymbol(math, main, mathord, "\u03bf", "\\omicron", true); +defineSymbol(math, main, mathord, "\u03c0", "\\pi", true); +defineSymbol(math, main, mathord, "\u03c1", "\\rho", true); +defineSymbol(math, main, mathord, "\u03c3", "\\sigma", true); +defineSymbol(math, main, mathord, "\u03c4", "\\tau", true); +defineSymbol(math, main, mathord, "\u03c5", "\\upsilon", true); +defineSymbol(math, main, mathord, "\u03d5", "\\phi", true); +defineSymbol(math, main, mathord, "\u03c7", "\\chi", true); +defineSymbol(math, main, mathord, "\u03c8", "\\psi", true); +defineSymbol(math, main, mathord, "\u03c9", "\\omega", true); +defineSymbol(math, main, mathord, "\u03b5", "\\varepsilon", true); +defineSymbol(math, main, mathord, "\u03d1", "\\vartheta", true); +defineSymbol(math, main, mathord, "\u03d6", "\\varpi", true); +defineSymbol(math, main, mathord, "\u03f1", "\\varrho", true); +defineSymbol(math, main, mathord, "\u03c2", "\\varsigma", true); +defineSymbol(math, main, mathord, "\u03c6", "\\varphi", true); +defineSymbol(math, main, bin, "\u2217", "*", true); +defineSymbol(math, main, bin, "+", "+"); +defineSymbol(math, main, bin, "\u2212", "-", true); +defineSymbol(math, main, bin, "\u22c5", "\\cdot", true); +defineSymbol(math, main, bin, "\u2218", "\\circ", true); +defineSymbol(math, main, bin, "\u00f7", "\\div", true); +defineSymbol(math, main, bin, "\u00b1", "\\pm", true); +defineSymbol(math, main, bin, "\u00d7", "\\times", true); +defineSymbol(math, main, bin, "\u2229", "\\cap", true); +defineSymbol(math, main, bin, "\u222a", "\\cup", true); +defineSymbol(math, main, bin, "\u2216", "\\setminus", true); +defineSymbol(math, main, bin, "\u2227", "\\land"); +defineSymbol(math, main, bin, "\u2228", "\\lor"); +defineSymbol(math, main, bin, "\u2227", "\\wedge", true); +defineSymbol(math, main, bin, "\u2228", "\\vee", true); +defineSymbol(math, main, textord, "\u221a", "\\surd"); +defineSymbol(math, main, symbols_open, "\u27e8", "\\langle", true); +defineSymbol(math, main, symbols_open, "\u2223", "\\lvert"); +defineSymbol(math, main, symbols_open, "\u2225", "\\lVert"); +defineSymbol(math, main, symbols_close, "?", "?"); +defineSymbol(math, main, symbols_close, "!", "!"); +defineSymbol(math, main, symbols_close, "\u27e9", "\\rangle", true); +defineSymbol(math, main, symbols_close, "\u2223", "\\rvert"); +defineSymbol(math, main, symbols_close, "\u2225", "\\rVert"); +defineSymbol(math, main, rel, "=", "="); +defineSymbol(math, main, rel, ":", ":"); +defineSymbol(math, main, rel, "\u2248", "\\approx", true); +defineSymbol(math, main, rel, "\u2245", "\\cong", true); +defineSymbol(math, main, rel, "\u2265", "\\ge"); +defineSymbol(math, main, rel, "\u2265", "\\geq", true); +defineSymbol(math, main, rel, "\u2190", "\\gets"); +defineSymbol(math, main, rel, ">", "\\gt", true); +defineSymbol(math, main, rel, "\u2208", "\\in", true); +defineSymbol(math, main, rel, "\ue020", "\\@not"); +defineSymbol(math, main, rel, "\u2282", "\\subset", true); +defineSymbol(math, main, rel, "\u2283", "\\supset", true); +defineSymbol(math, main, rel, "\u2286", "\\subseteq", true); +defineSymbol(math, main, rel, "\u2287", "\\supseteq", true); +defineSymbol(math, ams, rel, "\u2288", "\\nsubseteq", true); +defineSymbol(math, ams, rel, "\u2289", "\\nsupseteq", true); +defineSymbol(math, main, rel, "\u22a8", "\\models"); +defineSymbol(math, main, rel, "\u2190", "\\leftarrow", true); +defineSymbol(math, main, rel, "\u2264", "\\le"); +defineSymbol(math, main, rel, "\u2264", "\\leq", true); +defineSymbol(math, main, rel, "<", "\\lt", true); +defineSymbol(math, main, rel, "\u2192", "\\rightarrow", true); +defineSymbol(math, main, rel, "\u2192", "\\to"); +defineSymbol(math, ams, rel, "\u2271", "\\ngeq", true); +defineSymbol(math, ams, rel, "\u2270", "\\nleq", true); +defineSymbol(math, main, spacing, "\u00a0", "\\ "); +defineSymbol(math, main, spacing, "\u00a0", "\\space"); +// Ref: LaTeX Source 2e: \DeclareRobustCommand{\nobreakspace}{% +defineSymbol(math, main, spacing, "\u00a0", "\\nobreakspace"); +defineSymbol(symbols_text, main, spacing, "\u00a0", "\\ "); +defineSymbol(symbols_text, main, spacing, "\u00a0", " "); +defineSymbol(symbols_text, main, spacing, "\u00a0", "\\space"); +defineSymbol(symbols_text, main, spacing, "\u00a0", "\\nobreakspace"); +defineSymbol(math, main, spacing, "", "\\nobreak"); +defineSymbol(math, main, spacing, "", "\\allowbreak"); +defineSymbol(math, main, punct, ",", ","); +defineSymbol(math, main, punct, ";", ";"); +defineSymbol(math, ams, bin, "\u22bc", "\\barwedge", true); +defineSymbol(math, ams, bin, "\u22bb", "\\veebar", true); +defineSymbol(math, main, bin, "\u2299", "\\odot", true); +defineSymbol(math, main, bin, "\u2295", "\\oplus", true); +defineSymbol(math, main, bin, "\u2297", "\\otimes", true); +defineSymbol(math, main, textord, "\u2202", "\\partial", true); +defineSymbol(math, main, bin, "\u2298", "\\oslash", true); +defineSymbol(math, ams, bin, "\u229a", "\\circledcirc", true); +defineSymbol(math, ams, bin, "\u22a1", "\\boxdot", true); +defineSymbol(math, main, bin, "\u25b3", "\\bigtriangleup"); +defineSymbol(math, main, bin, "\u25bd", "\\bigtriangledown"); +defineSymbol(math, main, bin, "\u2020", "\\dagger"); +defineSymbol(math, main, bin, "\u22c4", "\\diamond"); +defineSymbol(math, main, bin, "\u22c6", "\\star"); +defineSymbol(math, main, bin, "\u25c3", "\\triangleleft"); +defineSymbol(math, main, bin, "\u25b9", "\\triangleright"); +defineSymbol(math, main, symbols_open, "{", "\\{"); +defineSymbol(symbols_text, main, textord, "{", "\\{"); +defineSymbol(symbols_text, main, textord, "{", "\\textbraceleft"); +defineSymbol(math, main, symbols_close, "}", "\\}"); +defineSymbol(symbols_text, main, textord, "}", "\\}"); +defineSymbol(symbols_text, main, textord, "}", "\\textbraceright"); +defineSymbol(math, main, symbols_open, "{", "\\lbrace"); +defineSymbol(math, main, symbols_close, "}", "\\rbrace"); +defineSymbol(math, main, symbols_open, "[", "\\lbrack", true); +defineSymbol(symbols_text, main, textord, "[", "\\lbrack", true); +defineSymbol(math, main, symbols_close, "]", "\\rbrack", true); +defineSymbol(symbols_text, main, textord, "]", "\\rbrack", true); +defineSymbol(math, main, symbols_open, "(", "\\lparen", true); +defineSymbol(math, main, symbols_close, ")", "\\rparen", true); +defineSymbol(symbols_text, main, textord, "<", "\\textless", true); // in T1 fontenc +defineSymbol(symbols_text, main, textord, ">", "\\textgreater", true); // in T1 fontenc +defineSymbol(math, main, symbols_open, "\u230a", "\\lfloor", true); +defineSymbol(math, main, symbols_close, "\u230b", "\\rfloor", true); +defineSymbol(math, main, symbols_open, "\u2308", "\\lceil", true); +defineSymbol(math, main, symbols_close, "\u2309", "\\rceil", true); +defineSymbol(math, main, textord, "\\", "\\backslash"); +defineSymbol(math, main, textord, "\u2223", "|"); +defineSymbol(math, main, textord, "\u2223", "\\vert"); +defineSymbol(symbols_text, main, textord, "|", "\\textbar", true); // in T1 fontenc +defineSymbol(math, main, textord, "\u2225", "\\|"); +defineSymbol(math, main, textord, "\u2225", "\\Vert"); +defineSymbol(symbols_text, main, textord, "\u2225", "\\textbardbl"); +defineSymbol(symbols_text, main, textord, "~", "\\textasciitilde"); +defineSymbol(symbols_text, main, textord, "\\", "\\textbackslash"); +defineSymbol(symbols_text, main, textord, "^", "\\textasciicircum"); +defineSymbol(math, main, rel, "\u2191", "\\uparrow", true); +defineSymbol(math, main, rel, "\u21d1", "\\Uparrow", true); +defineSymbol(math, main, rel, "\u2193", "\\downarrow", true); +defineSymbol(math, main, rel, "\u21d3", "\\Downarrow", true); +defineSymbol(math, main, rel, "\u2195", "\\updownarrow", true); +defineSymbol(math, main, rel, "\u21d5", "\\Updownarrow", true); +defineSymbol(math, main, op, "\u2210", "\\coprod"); +defineSymbol(math, main, op, "\u22c1", "\\bigvee"); +defineSymbol(math, main, op, "\u22c0", "\\bigwedge"); +defineSymbol(math, main, op, "\u2a04", "\\biguplus"); +defineSymbol(math, main, op, "\u22c2", "\\bigcap"); +defineSymbol(math, main, op, "\u22c3", "\\bigcup"); +defineSymbol(math, main, op, "\u222b", "\\int"); +defineSymbol(math, main, op, "\u222b", "\\intop"); +defineSymbol(math, main, op, "\u222c", "\\iint"); +defineSymbol(math, main, op, "\u222d", "\\iiint"); +defineSymbol(math, main, op, "\u220f", "\\prod"); +defineSymbol(math, main, op, "\u2211", "\\sum"); +defineSymbol(math, main, op, "\u2a02", "\\bigotimes"); +defineSymbol(math, main, op, "\u2a01", "\\bigoplus"); +defineSymbol(math, main, op, "\u2a00", "\\bigodot"); +defineSymbol(math, main, op, "\u222e", "\\oint"); +defineSymbol(math, main, op, "\u222f", "\\oiint"); +defineSymbol(math, main, op, "\u2230", "\\oiiint"); +defineSymbol(math, main, op, "\u2a06", "\\bigsqcup"); +defineSymbol(math, main, op, "\u222b", "\\smallint"); +defineSymbol(symbols_text, main, inner, "\u2026", "\\textellipsis"); +defineSymbol(math, main, inner, "\u2026", "\\mathellipsis"); +defineSymbol(symbols_text, main, inner, "\u2026", "\\ldots", true); +defineSymbol(math, main, inner, "\u2026", "\\ldots", true); +defineSymbol(math, main, inner, "\u22ef", "\\@cdots", true); +defineSymbol(math, main, inner, "\u22f1", "\\ddots", true); +// \vdots is a macro that uses one of these two symbols (with made-up names): +defineSymbol(math, main, textord, "\u22ee", "\\varvdots"); +defineSymbol(symbols_text, main, textord, "\u22ee", "\\varvdots"); +defineSymbol(math, main, accent, "\u02ca", "\\acute"); +defineSymbol(math, main, accent, "\u02cb", "\\grave"); +defineSymbol(math, main, accent, "\u00a8", "\\ddot"); +defineSymbol(math, main, accent, "\u007e", "\\tilde"); +defineSymbol(math, main, accent, "\u02c9", "\\bar"); +defineSymbol(math, main, accent, "\u02d8", "\\breve"); +defineSymbol(math, main, accent, "\u02c7", "\\check"); +defineSymbol(math, main, accent, "\u005e", "\\hat"); +defineSymbol(math, main, accent, "\u20d7", "\\vec"); +defineSymbol(math, main, accent, "\u02d9", "\\dot"); +defineSymbol(math, main, accent, "\u02da", "\\mathring"); +// \imath and \jmath should be invariant to \mathrm, \mathbf, etc., so use PUA +defineSymbol(math, main, mathord, "\ue131", "\\@imath"); +defineSymbol(math, main, mathord, "\ue237", "\\@jmath"); +defineSymbol(math, main, textord, "\u0131", "\u0131"); +defineSymbol(math, main, textord, "\u0237", "\u0237"); +defineSymbol(symbols_text, main, textord, "\u0131", "\\i", true); +defineSymbol(symbols_text, main, textord, "\u0237", "\\j", true); +defineSymbol(symbols_text, main, textord, "\u00df", "\\ss", true); +defineSymbol(symbols_text, main, textord, "\u00e6", "\\ae", true); +defineSymbol(symbols_text, main, textord, "\u0153", "\\oe", true); +defineSymbol(symbols_text, main, textord, "\u00f8", "\\o", true); +defineSymbol(symbols_text, main, textord, "\u00c6", "\\AE", true); +defineSymbol(symbols_text, main, textord, "\u0152", "\\OE", true); +defineSymbol(symbols_text, main, textord, "\u00d8", "\\O", true); +defineSymbol(symbols_text, main, accent, "\u02ca", "\\'"); // acute +defineSymbol(symbols_text, main, accent, "\u02cb", "\\`"); // grave +defineSymbol(symbols_text, main, accent, "\u02c6", "\\^"); // circumflex +defineSymbol(symbols_text, main, accent, "\u02dc", "\\~"); // tilde +defineSymbol(symbols_text, main, accent, "\u02c9", "\\="); // macron +defineSymbol(symbols_text, main, accent, "\u02d8", "\\u"); // breve +defineSymbol(symbols_text, main, accent, "\u02d9", "\\."); // dot above +defineSymbol(symbols_text, main, accent, "\u00b8", "\\c"); // cedilla +defineSymbol(symbols_text, main, accent, "\u02da", "\\r"); // ring above +defineSymbol(symbols_text, main, accent, "\u02c7", "\\v"); // caron +defineSymbol(symbols_text, main, accent, "\u00a8", '\\"'); // diaeresis +defineSymbol(symbols_text, main, accent, "\u02dd", "\\H"); // double acute +defineSymbol(symbols_text, main, accent, "\u25ef", "\\textcircled"); // \bigcirc glyph + +// These ligatures are detected and created in Parser.js's `formLigatures`. +const ligatures = { + "--": true, + "---": true, + "``": true, + "''": true +}; +defineSymbol(symbols_text, main, textord, "\u2013", "--", true); +defineSymbol(symbols_text, main, textord, "\u2013", "\\textendash"); +defineSymbol(symbols_text, main, textord, "\u2014", "---", true); +defineSymbol(symbols_text, main, textord, "\u2014", "\\textemdash"); +defineSymbol(symbols_text, main, textord, "\u2018", "`", true); +defineSymbol(symbols_text, main, textord, "\u2018", "\\textquoteleft"); +defineSymbol(symbols_text, main, textord, "\u2019", "'", true); +defineSymbol(symbols_text, main, textord, "\u2019", "\\textquoteright"); +defineSymbol(symbols_text, main, textord, "\u201c", "``", true); +defineSymbol(symbols_text, main, textord, "\u201c", "\\textquotedblleft"); +defineSymbol(symbols_text, main, textord, "\u201d", "''", true); +defineSymbol(symbols_text, main, textord, "\u201d", "\\textquotedblright"); +// \degree from gensymb package +defineSymbol(math, main, textord, "\u00b0", "\\degree", true); +defineSymbol(symbols_text, main, textord, "\u00b0", "\\degree"); +// \textdegree from inputenc package +defineSymbol(symbols_text, main, textord, "\u00b0", "\\textdegree", true); +// TODO: In LaTeX, \pounds can generate a different character in text and math +// mode, but among our fonts, only Main-Regular defines this character "163". +defineSymbol(math, main, textord, "\u00a3", "\\pounds"); +defineSymbol(math, main, textord, "\u00a3", "\\mathsterling", true); +defineSymbol(symbols_text, main, textord, "\u00a3", "\\pounds"); +defineSymbol(symbols_text, main, textord, "\u00a3", "\\textsterling", true); +defineSymbol(math, ams, textord, "\u2720", "\\maltese"); +defineSymbol(symbols_text, ams, textord, "\u2720", "\\maltese"); + +// There are lots of symbols which are the same, so we add them in afterwards. +// All of these are textords in math mode +const mathTextSymbols = "0123456789/@.\""; +for (let i = 0; i < mathTextSymbols.length; i++) { + const ch = mathTextSymbols.charAt(i); + defineSymbol(math, main, textord, ch, ch); +} + +// All of these are textords in text mode +const textSymbols = "0123456789!@*()-=+\";:?/.,"; +for (let i = 0; i < textSymbols.length; i++) { + const ch = textSymbols.charAt(i); + defineSymbol(symbols_text, main, textord, ch, ch); +} + +// All of these are textords in text mode, and mathords in math mode +const letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; +for (let i = 0; i < letters.length; i++) { + const ch = letters.charAt(i); + defineSymbol(math, main, mathord, ch, ch); + defineSymbol(symbols_text, main, textord, ch, ch); +} + +// Blackboard bold and script letters in Unicode range +defineSymbol(math, ams, textord, "C", "\u2102"); // blackboard bold +defineSymbol(symbols_text, ams, textord, "C", "\u2102"); +defineSymbol(math, ams, textord, "H", "\u210D"); +defineSymbol(symbols_text, ams, textord, "H", "\u210D"); +defineSymbol(math, ams, textord, "N", "\u2115"); +defineSymbol(symbols_text, ams, textord, "N", "\u2115"); +defineSymbol(math, ams, textord, "P", "\u2119"); +defineSymbol(symbols_text, ams, textord, "P", "\u2119"); +defineSymbol(math, ams, textord, "Q", "\u211A"); +defineSymbol(symbols_text, ams, textord, "Q", "\u211A"); +defineSymbol(math, ams, textord, "R", "\u211D"); +defineSymbol(symbols_text, ams, textord, "R", "\u211D"); +defineSymbol(math, ams, textord, "Z", "\u2124"); +defineSymbol(symbols_text, ams, textord, "Z", "\u2124"); +defineSymbol(math, main, mathord, "h", "\u210E"); // italic h, Planck constant +defineSymbol(symbols_text, main, mathord, "h", "\u210E"); + +// The next loop loads wide (surrogate pair) characters. +// We support some letters in the Unicode range U+1D400 to U+1D7FF, +// Mathematical Alphanumeric Symbols. +// Some editors do not deal well with wide characters. So don't write the +// string into this file. Instead, create the string from the surrogate pair. +let wideChar; +for (let i = 0; i < letters.length; i++) { + const ch = letters.charAt(i); + + // The hex numbers in the next line are a surrogate pair. + // 0xD835 is the high surrogate for all letters in the range we support. + // 0xDC00 is the low surrogate for bold A. + wideChar = String.fromCharCode(0xD835, 0xDC00 + i); // A-Z a-z bold + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(symbols_text, main, textord, ch, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDC34 + i); // A-Z a-z italic + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(symbols_text, main, textord, ch, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDC68 + i); // A-Z a-z bold italic + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(symbols_text, main, textord, ch, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDD04 + i); // A-Z a-z Fraktur + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(symbols_text, main, textord, ch, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDD6C + i); // A-Z a-z bold Fraktur + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(symbols_text, main, textord, ch, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDDA0 + i); // A-Z a-z sans-serif + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(symbols_text, main, textord, ch, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDDD4 + i); // A-Z a-z sans bold + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(symbols_text, main, textord, ch, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDE08 + i); // A-Z a-z sans italic + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(symbols_text, main, textord, ch, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDE70 + i); // A-Z a-z monospace + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(symbols_text, main, textord, ch, wideChar); + if (i < 26) { + // KaTeX fonts have only capital letters for blackboard bold and script. + // See exception for k below. + wideChar = String.fromCharCode(0xD835, 0xDD38 + i); // A-Z double struck + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(symbols_text, main, textord, ch, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDC9C + i); // A-Z script + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(symbols_text, main, textord, ch, wideChar); + } + + // TODO: Add bold script when it is supported by a KaTeX font. +} +// "k" is the only double struck lower case letter in the KaTeX fonts. +wideChar = String.fromCharCode(0xD835, 0xDD5C); // k double struck +defineSymbol(math, main, mathord, "k", wideChar); +defineSymbol(symbols_text, main, textord, "k", wideChar); + +// Next, some wide character numerals +for (let i = 0; i < 10; i++) { + const ch = i.toString(); + wideChar = String.fromCharCode(0xD835, 0xDFCE + i); // 0-9 bold + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(symbols_text, main, textord, ch, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDFE2 + i); // 0-9 sans serif + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(symbols_text, main, textord, ch, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDFEC + i); // 0-9 bold sans + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(symbols_text, main, textord, ch, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDFF6 + i); // 0-9 monospace + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(symbols_text, main, textord, ch, wideChar); +} + +// We add these Latin-1 letters as symbols for backwards-compatibility, +// but they are not actually in the font, nor are they supported by the +// Unicode accent mechanism, so they fall back to Times font and look ugly. +// TODO(edemaine): Fix this. +const extraLatin = "\u00d0\u00de\u00fe"; +for (let i = 0; i < extraLatin.length; i++) { + const ch = extraLatin.charAt(i); + defineSymbol(math, main, mathord, ch, ch); + defineSymbol(symbols_text, main, textord, ch, ch); +} +;// ./src/wide-character.ts +/** + * This file provides support for Unicode range U+1D400 to U+1D7FF, + * Mathematical Alphanumeric Symbols. + * + * Function wideCharacterFont takes a wide character as input and returns + * the font information necessary to render it properly. + */ + + +const boldUpright = { + mathClass: "mathbf", + textClass: "textbf", + font: "Main-Bold" +}; +const italic = { + mathClass: "mathnormal", + textClass: "textit", + font: "Math-Italic" +}; +const boldItalic = { + mathClass: "boldsymbol", + textClass: "boldsymbol", + font: "Main-BoldItalic" +}; +const script = { + mathClass: "mathscr", + textClass: "textscr", + font: "Script-Regular" +}; +const noFont = { + mathClass: "", + textClass: "", + font: "" +}; +const fraktur = { + mathClass: "mathfrak", + textClass: "textfrak", + font: "Fraktur-Regular" +}; +const doubleStruck = { + mathClass: "mathbb", + textClass: "textbb", + font: "AMS-Regular" +}; +const boldFraktur = { + mathClass: "mathboldfrak", + textClass: "textboldfrak", + font: "Fraktur-Regular" +}; +const sansSerif = { + mathClass: "mathsf", + textClass: "textsf", + font: "SansSerif-Regular" +}; +const boldSansSerif = { + mathClass: "mathboldsf", + textClass: "textboldsf", + font: "SansSerif-Bold" +}; +const italicSansSerif = { + mathClass: "mathitsf", + textClass: "textitsf", + font: "SansSerif-Italic" +}; +const monospace = { + mathClass: "mathtt", + textClass: "texttt", + font: "Typewriter-Regular" +}; + +/** + * Data below is from https://www.unicode.org/charts/PDF/U1D400.pdf + * That document sorts characters into groups by font type, say bold or italic. + * + * In the arrays below, each object consists of three properties: + * * The CSS class of that group when in math mode. + * * The CSS class of that group when in text mode. + * * The font name, so that KaTeX can get font metrics. + */ + +const wideLatinLetterData = [boldUpright, boldUpright, +// A-Z, a-z +italic, italic, +// A-Z, a-z +boldItalic, boldItalic, +// A-Z, a-z +// Map fancy A-Z letters to script, not calligraphic. +// This aligns with unicode-math and math fonts (except Cambria Math). +script, noFont, +// A-Z script, a-z — no font +noFont, noFont, +// A-Z bold script, a-z bold script — no font +fraktur, fraktur, +// A-Z, a-z +doubleStruck, doubleStruck, +// A-Z double-struck, k double-struck +// Note that we are using a bold font, but font metrics for regular Fraktur. +boldFraktur, boldFraktur, +// A-Z, a-z +sansSerif, sansSerif, +// A-Z, a-z +boldSansSerif, boldSansSerif, +// A-Z, a-z +italicSansSerif, italicSansSerif, +// A-Z, a-z +noFont, noFont, +// A-Z bold italic sans, a-z bold italic sans - no font +monospace, monospace // A-Z, a-z +]; +const wideNumeralData = [boldUpright, +// 0-9 +noFont, +// 0-9 double-struck. No KaTeX font. +sansSerif, +// 0-9 +boldSansSerif, +// 0-9 +monospace // 0-9 +]; +const wideCharacterFont = wideChar => { + // IE doesn't support codePointAt(). So work with the surrogate pair. + const H = wideChar.charCodeAt(0); // high surrogate + const L = wideChar.charCodeAt(1); // low surrogate + const codePoint = (H - 0xD800) * 0x400 + (L - 0xDC00) + 0x10000; + if (0x1D400 <= codePoint && codePoint < 0x1D6A4) { + // wideLatinLetterData contains exactly 26 chars on each row. + // So we can calculate the relevant row. No traverse necessary. + const i = Math.floor((codePoint - 0x1D400) / 26); + return wideLatinLetterData[i]; + } else if (0x1D7CE <= codePoint && codePoint <= 0x1D7FF) { + // Numerals, ten per row. + const i = Math.floor((codePoint - 0x1D7CE) / 10); + return wideNumeralData[i]; + } else if (codePoint === 0x1D6A5 || codePoint === 0x1D6A6) { + // dotless i or j + return wideLatinLetterData[0]; + } else if (0x1D6A6 < codePoint && codePoint < 0x1D7CE) { + // Greek letters. Not supported, yet. + return noFont; + } else { + // We don't support any wide characters outside 1D400–1D7FF. + throw new src_ParseError("Unsupported character: " + wideChar); + } +}; +;// ./src/buildCommon.ts +/* eslint no-console:0 */ +/** + * This module contains general functions that can be used for building + * different kinds of domTree nodes in a consistent manner. + */ + + + + + + + +/** + * Looks up the given symbol in fontMetrics, after applying any symbol + * replacements defined in symbol.js + */ +const lookupSymbol = function (value, fontName, mode) { + // Replace the value with its replaced value from symbol.js + if (src_symbols[mode][value]) { + const replacement = src_symbols[mode][value].replace; + if (replacement) { + value = replacement; + } + } + return { + value, + metrics: getCharacterMetrics(value, fontName, mode) + }; +}; + +/** + * Makes a symbolNode after translation via the list of symbols in symbols.js. + * Correctly pulls out metrics for the character, and optionally takes a list of + * classes to be attached to the node. + * + * TODO: make argument order closer to makeSpan + * TODO: add a separate argument for math class (e.g. `mop`, `mbin`), which + * should if present come first in `classes`. + * TODO(#953): Make `options` mandatory and always pass it in. + */ +const makeSymbol = function (value, fontName, mode, options, classes) { + const lookup = lookupSymbol(value, fontName, mode); + const metrics = lookup.metrics; + value = lookup.value; + let symbolNode; + if (metrics) { + let italic = metrics.italic; + if (mode === "text" || options && options.font === "mathit") { + italic = 0; + } + symbolNode = new SymbolNode(value, metrics.height, metrics.depth, italic, metrics.skew, metrics.width, classes); + } else { + // TODO(emily): Figure out a good way to only print this in development + typeof console !== "undefined" && console.warn("No character metrics " + ("for '" + value + "' in style '" + fontName + "' and mode '" + mode + "'")); + symbolNode = new SymbolNode(value, 0, 0, 0, 0, 0, classes); + } + if (options) { + symbolNode.maxFontSize = options.sizeMultiplier; + if (options.style.isTight()) { + symbolNode.classes.push("mtight"); + } + const color = options.getColor(); + if (color) { + symbolNode.style.color = color; + } + } + return symbolNode; +}; + +/** + * Makes a symbol in Main-Regular or AMS-Regular. + * Used for rel, bin, open, close, inner, and punct. + */ +const mathsym = function (value, mode, options, classes) { + if (classes === void 0) { + classes = []; + } + // Decide what font to render the symbol in by its entry in the symbols + // table. + // Have a special case for when the value = \ because the \ is used as a + // textord in unsupported command errors but cannot be parsed as a regular + // text ordinal and is therefore not present as a symbol in the symbols + // table for text, as well as a special case for boldsymbol because it + // can be used for bold + and - + if (options.font === "boldsymbol" && lookupSymbol(value, "Main-Bold", mode).metrics) { + return makeSymbol(value, "Main-Bold", mode, options, classes.concat(["mathbf"])); + } else if (value === "\\" || src_symbols[mode][value].font === "main") { + return makeSymbol(value, "Main-Regular", mode, options, classes); + } else { + return makeSymbol(value, "AMS-Regular", mode, options, classes.concat(["amsrm"])); + } +}; + +/** + * Determines which of the two font names (Main-Bold and Math-BoldItalic) and + * corresponding style tags (mathbf or boldsymbol) to use for font "boldsymbol", + * depending on the symbol. Use this function instead of fontMap for font + * "boldsymbol". + */ +const boldSymbol = function (value, mode, type) { + if (type !== "textord" && lookupSymbol(value, "Math-BoldItalic", mode).metrics) { + return { + fontName: "Math-BoldItalic", + fontClass: "boldsymbol" + }; + } else { + // Some glyphs do not exist in Math-BoldItalic so we need to use + // Main-Bold instead. + return { + fontName: "Main-Bold", + fontClass: "mathbf" + }; + } +}; + +/** + * Makes either a mathord or textord in the correct font and color. + */ +const makeOrd = function (group, options) { + // Spacing nodes are rendered as textord. + const type = group.type === "mathord" ? "mathord" : "textord"; + const mode = group.mode; + const text = group.text; + const classes = ["mord"]; + const { + font, + fontFamily, + fontWeight, + fontShape + } = options; + + // Math mode or Old font (i.e. \rm) + const useFont = mode === "math" || mode === "text" && !!font; + const fontOrFamily = useFont ? font : fontFamily; + let wideFontName = ""; + let wideFontClass = ""; + if (text.charCodeAt(0) === 0xD835) { + const wideCharData = wideCharacterFont(text); + wideFontName = wideCharData.font; + wideFontClass = wideCharData[mode + "Class"]; + } + if (wideFontName) { + // surrogate pairs get special treatment + return makeSymbol(text, wideFontName, mode, options, classes.concat(wideFontClass)); + } else if (fontOrFamily) { + let fontName; + let fontClasses; + if (fontOrFamily === "boldsymbol") { + const fontData = boldSymbol(text, mode, type); + fontName = fontData.fontName; + fontClasses = [fontData.fontClass]; + } else if (useFont) { + fontName = fontMap[font].fontName; + fontClasses = [font]; + } else { + fontName = retrieveTextFontName(fontFamily, fontWeight, fontShape); + fontClasses = [fontFamily, fontWeight, fontShape]; + } + if (lookupSymbol(text, fontName, mode).metrics) { + return makeSymbol(text, fontName, mode, options, classes.concat(fontClasses)); + } else if (ligatures.hasOwnProperty(text) && fontName.slice(0, 10) === "Typewriter") { + // Deconstruct ligatures in monospace fonts (\texttt, \tt). + const parts = []; + for (let i = 0; i < text.length; i++) { + parts.push(makeSymbol(text[i], fontName, mode, options, classes.concat(fontClasses))); + } + return makeFragment(parts); + } + } + + // Makes a symbol in the default font for mathords and textords. + if (type === "mathord") { + return makeSymbol(text, "Math-Italic", mode, options, classes.concat(["mathnormal"])); + } else if (type === "textord") { + const font = src_symbols[mode][text] && src_symbols[mode][text].font; + if (font === "ams") { + const fontName = retrieveTextFontName("amsrm", fontWeight, fontShape); + return makeSymbol(text, fontName, mode, options, classes.concat("amsrm", fontWeight, fontShape)); + } else if (font === "main" || !font) { + const fontName = retrieveTextFontName("textrm", fontWeight, fontShape); + return makeSymbol(text, fontName, mode, options, classes.concat(fontWeight, fontShape)); + } else { + // fonts added by plugins + const fontName = retrieveTextFontName(font, fontWeight, fontShape); + // We add font name as a css class + return makeSymbol(text, fontName, mode, options, classes.concat(fontName, fontWeight, fontShape)); + } + } else { + throw new Error("unexpected type: " + type + " in makeOrd"); + } +}; + +/** + * Returns true if subsequent symbolNodes have the same classes, skew, maxFont, + * and styles. For mathnormal text, the left node must also have zero italic + * correction so we don't lose spacing between combined glyphs. + */ +const canCombine = (prev, next) => { + if (createClass(prev.classes) !== createClass(next.classes) || prev.skew !== next.skew || prev.maxFontSize !== next.maxFontSize || prev.italic !== 0 && prev.hasClass("mathnormal")) { + return false; + } + + // If prev and next both are just "mbin"s or "mord"s we don't combine them + // so that the proper spacing can be preserved. + if (prev.classes.length === 1) { + const cls = prev.classes[0]; + if (cls === "mbin" || cls === "mord") { + return false; + } + } + for (const key of Object.keys(prev.style)) { + if (prev.style[key] !== next.style[key]) { + return false; + } + } + for (const key of Object.keys(next.style)) { + if (prev.style[key] !== next.style[key]) { + return false; + } + } + return true; +}; + +/** + * Combine consecutive domTree.symbolNodes into a single symbolNode. + * Note: this function mutates the argument. + */ +const tryCombineChars = chars => { + for (let i = 0; i < chars.length - 1; i++) { + const prev = chars[i]; + const next = chars[i + 1]; + if (prev instanceof SymbolNode && next instanceof SymbolNode && canCombine(prev, next)) { + prev.text += next.text; + prev.height = Math.max(prev.height, next.height); + prev.depth = Math.max(prev.depth, next.depth); + // Use the last character's italic correction since we use + // it to add padding to the right of the span created from + // the combined characters. + prev.italic = next.italic; + chars.splice(i + 1, 1); + i--; + } + } + return chars; +}; + +/** + * Calculate the height, depth, and maxFontSize of an element based on its + * children. + */ +const sizeElementFromChildren = function (elem) { + let height = 0; + let depth = 0; + let maxFontSize = 0; + for (let i = 0; i < elem.children.length; i++) { + const child = elem.children[i]; + if (child.height > height) { + height = child.height; + } + if (child.depth > depth) { + depth = child.depth; + } + if (child.maxFontSize > maxFontSize) { + maxFontSize = child.maxFontSize; + } + } + elem.height = height; + elem.depth = depth; + elem.maxFontSize = maxFontSize; +}; + +/** + * Makes a span with the given list of classes, list of children, and options. + * + * TODO(#953): Ensure that `options` is always provided (currently some call + * sites don't pass it) and make the type below mandatory. + * TODO: add a separate argument for math class (e.g. `mop`, `mbin`), which + * should if present come first in `classes`. + */ +const makeSpan = function (classes, children, options, style) { + const span = new Span(classes, children, options, style); + sizeElementFromChildren(span); + return span; +}; + +// SVG one is simpler -- doesn't require height, depth, max-font setting. +// This is also a separate method for typesafety. +const makeSvgSpan = (classes, children, options, style) => new Span(classes, children, options, style); +const makeLineSpan = function (className, options, thickness) { + const line = makeSpan([className], [], options); + line.height = Math.max(thickness || options.fontMetrics().defaultRuleThickness, options.minRuleThickness); + line.style.borderBottomWidth = makeEm(line.height); + line.maxFontSize = 1.0; + return line; +}; + +/** + * Makes an anchor with the given href, list of classes, list of children, + * and options. + */ +const makeAnchor = function (href, classes, children, options) { + const anchor = new Anchor(href, classes, children, options); + sizeElementFromChildren(anchor); + return anchor; +}; + +/** + * Makes a document fragment with the given list of children. + */ +const makeFragment = function (children) { + const fragment = new DocumentFragment(children); + sizeElementFromChildren(fragment); + return fragment; +}; + +/** + * Wraps group in a span if it's a document fragment, allowing to apply classes + * and styles + */ +const wrapFragment = function (group, options) { + if (group instanceof DocumentFragment) { + return makeSpan([], [group], options); + } + return group; +}; + +// A list of child or kern nodes to be stacked on top of each other (i.e. the +// first element will be at the bottom, and the last at the top). + +// Computes the updated `children` list and the overall depth. +// +// This helper function for makeVList makes it easier to enforce type safety by +// allowing early exits (returns) in the logic. +const getVListChildrenAndDepth = function (params) { + if (params.positionType === "individualShift") { + const oldChildren = params.children; + const children = [oldChildren[0]]; + + // Add in kerns to the list of params.children to get each element to be + // shifted to the correct specified shift + const depth = -oldChildren[0].shift - oldChildren[0].elem.depth; + let currPos = depth; + for (let i = 1; i < oldChildren.length; i++) { + const diff = -oldChildren[i].shift - currPos - oldChildren[i].elem.depth; + const size = diff - (oldChildren[i - 1].elem.height + oldChildren[i - 1].elem.depth); + currPos = currPos + diff; + children.push({ + type: "kern", + size + }); + children.push(oldChildren[i]); + } + return { + children, + depth + }; + } + let depth; + if (params.positionType === "top") { + // We always start at the bottom, so calculate the bottom by adding up + // all the sizes + let bottom = params.positionData; + for (let i = 0; i < params.children.length; i++) { + const child = params.children[i]; + bottom -= child.type === "kern" ? child.size : child.elem.height + child.elem.depth; + } + depth = bottom; + } else if (params.positionType === "bottom") { + depth = -params.positionData; + } else { + const firstChild = params.children[0]; + if (firstChild.type !== "elem") { + throw new Error('First child must have type "elem".'); + } + if (params.positionType === "shift") { + depth = -firstChild.elem.depth - params.positionData; + } else if (params.positionType === "firstBaseline") { + depth = -firstChild.elem.depth; + } else { + throw new Error("Invalid positionType " + params.positionType + "."); + } + } + return { + children: params.children, + depth + }; +}; + +/** + * Makes a vertical list by stacking elements and kerns on top of each other. + * Allows for many different ways of specifying the positioning method. + * + * See VListParam documentation above. + */ +const makeVList = function (params, options) { + const { + children, + depth + } = getVListChildrenAndDepth(params); + + // Create a strut that is taller than any list item. The strut is added to + // each item, where it will determine the item's baseline. Since it has + // `overflow:hidden`, the strut's top edge will sit on the item's line box's + // top edge and the strut's bottom edge will sit on the item's baseline, + // with no additional line-height spacing. This allows the item baseline to + // be positioned precisely without worrying about font ascent and + // line-height. + let pstrutSize = 0; + for (let i = 0; i < children.length; i++) { + const child = children[i]; + if (child.type === "elem") { + const elem = child.elem; + pstrutSize = Math.max(pstrutSize, elem.maxFontSize, elem.height); + } + } + pstrutSize += 2; + const pstrut = makeSpan(["pstrut"], []); + pstrut.style.height = makeEm(pstrutSize); + + // Create a new list of actual children at the correct offsets + const realChildren = []; + let minPos = depth; + let maxPos = depth; + let currPos = depth; + for (let i = 0; i < children.length; i++) { + const child = children[i]; + if (child.type === "kern") { + currPos += child.size; + } else { + const elem = child.elem; + const classes = child.wrapperClasses || []; + const style = child.wrapperStyle || {}; + const childWrap = makeSpan(classes, [pstrut, elem], undefined, style); + childWrap.style.top = makeEm(-pstrutSize - currPos - elem.depth); + if (child.marginLeft) { + childWrap.style.marginLeft = child.marginLeft; + } + if (child.marginRight) { + childWrap.style.marginRight = child.marginRight; + } + realChildren.push(childWrap); + currPos += elem.height + elem.depth; + } + minPos = Math.min(minPos, currPos); + maxPos = Math.max(maxPos, currPos); + } + + // The vlist contents go in a table-cell with `vertical-align:bottom`. + // This cell's bottom edge will determine the containing table's baseline + // without overly expanding the containing line-box. + const vlist = makeSpan(["vlist"], realChildren); + vlist.style.height = makeEm(maxPos); + + // A second row is used if necessary to represent the vlist's depth. + let rows; + if (minPos < 0) { + // We will define depth in an empty span with display: table-cell. + // It should render with the height that we define. But Chrome, in + // contenteditable mode only, treats that span as if it contains some + // text content. And that min-height over-rides our desired height. + // So we put another empty span inside the depth strut span. + const emptySpan = makeSpan([], []); + const depthStrut = makeSpan(["vlist"], [emptySpan]); + depthStrut.style.height = makeEm(-minPos); + + // Safari wants the first row to have inline content; otherwise it + // puts the bottom of the *second* row on the baseline. + const topStrut = makeSpan(["vlist-s"], [new SymbolNode("\u200b")]); + rows = [makeSpan(["vlist-r"], [vlist, topStrut]), makeSpan(["vlist-r"], [depthStrut])]; + } else { + rows = [makeSpan(["vlist-r"], [vlist])]; + } + const vtable = makeSpan(["vlist-t"], rows); + if (rows.length === 2) { + vtable.classes.push("vlist-t2"); + } + vtable.height = maxPos; + vtable.depth = -minPos; + return vtable; +}; + +// Glue is a concept from TeX which is a flexible space between elements in +// either a vertical or horizontal list. In KaTeX, at least for now, it's +// static space between elements in a horizontal layout. +const makeGlue = (measurement, options) => { + // Make an empty span for the space + const rule = makeSpan(["mspace"], [], options); + const size = calculateSize(measurement, options); + rule.style.marginRight = makeEm(size); + return rule; +}; + +// Takes font options, and returns the appropriate fontLookup name +const retrieveTextFontName = (fontFamily, fontWeight, fontShape) => { + let baseFontName; + let fontStylesName; + switch (fontFamily) { + case "amsrm": + baseFontName = "AMS"; + break; + case "textrm": + baseFontName = "Main"; + break; + case "textsf": + baseFontName = "SansSerif"; + break; + case "texttt": + baseFontName = "Typewriter"; + break; + default: + baseFontName = fontFamily; + // use fonts added by a plugin + } + if (fontWeight === "textbf" && fontShape === "textit") { + fontStylesName = "BoldItalic"; + } else if (fontWeight === "textbf") { + fontStylesName = "Bold"; + } else if (fontShape === "textit") { + fontStylesName = "Italic"; + } else { + fontStylesName = "Regular"; + } + return baseFontName + "-" + fontStylesName; +}; + +/** + * Maps TeX font commands to objects containing: + * - variant: string used for "mathvariant" attribute in buildMathML.js + * - fontName: the "style" parameter to fontMetrics.getCharacterMetrics + */ +// A map between tex font commands an MathML mathvariant attribute values +const fontMap = { + // styles + "mathbf": { + variant: "bold", + fontName: "Main-Bold" + }, + "mathrm": { + variant: "normal", + fontName: "Main-Regular" + }, + "textit": { + variant: "italic", + fontName: "Main-Italic" + }, + "mathit": { + variant: "italic", + fontName: "Main-Italic" + }, + "mathnormal": { + variant: "italic", + fontName: "Math-Italic" + }, + "mathsfit": { + variant: "sans-serif-italic", + fontName: "SansSerif-Italic" + }, + // "boldsymbol" is missing because they require the use of multiple fonts: + // Math-BoldItalic and Main-Bold. This is handled by a special case in + // makeOrd which ends up calling boldsymbol. + + // families + "mathbb": { + variant: "double-struck", + fontName: "AMS-Regular" + }, + "mathcal": { + variant: "script", + fontName: "Caligraphic-Regular" + }, + "mathfrak": { + variant: "fraktur", + fontName: "Fraktur-Regular" + }, + "mathscr": { + variant: "script", + fontName: "Script-Regular" + }, + "mathsf": { + variant: "sans-serif", + fontName: "SansSerif-Regular" + }, + "mathtt": { + variant: "monospace", + fontName: "Typewriter-Regular" + } +}; +const svgData = { + // path, width, height + vec: ["vec", 0.471, 0.714], + // values from the font glyph + oiintSize1: ["oiintSize1", 0.957, 0.499], + // oval to overlay the integrand + oiintSize2: ["oiintSize2", 1.472, 0.659], + oiiintSize1: ["oiiintSize1", 1.304, 0.499], + oiiintSize2: ["oiiintSize2", 1.98, 0.659] +}; +const staticSvg = function (value, options) { + // Create a span with inline SVG for the element. + const [pathName, width, height] = svgData[value]; + const path = new PathNode(pathName); + const svgNode = new SvgNode([path], { + "width": makeEm(width), + "height": makeEm(height), + // Override CSS rule `.katex svg { width: 100% }` + "style": "width:" + makeEm(width), + "viewBox": "0 0 " + 1000 * width + " " + 1000 * height, + "preserveAspectRatio": "xMinYMin" + }); + const span = makeSvgSpan(["overlay"], [svgNode], options); + span.height = height; + span.style.height = makeEm(height); + span.style.width = makeEm(width); + return span; +}; +;// ./src/spacingData.ts +/** + * Describes spaces between different classes of atoms. + */ + +const thinspace = { + number: 3, + unit: "mu" +}; +const mediumspace = { + number: 4, + unit: "mu" +}; +const thickspace = { + number: 5, + unit: "mu" +}; + +// Making the type below exact with all optional fields doesn't work due to +// - https://github.com/facebook/flow/issues/4582 +// - https://github.com/facebook/flow/issues/5688 +// However, since *all* fields are optional, $Shape<> works as suggested in 5688 +// above. + +// Spacing relationships for display and text styles +const spacings = { + mord: { + mop: thinspace, + mbin: mediumspace, + mrel: thickspace, + minner: thinspace + }, + mop: { + mord: thinspace, + mop: thinspace, + mrel: thickspace, + minner: thinspace + }, + mbin: { + mord: mediumspace, + mop: mediumspace, + mopen: mediumspace, + minner: mediumspace + }, + mrel: { + mord: thickspace, + mop: thickspace, + mopen: thickspace, + minner: thickspace + }, + mopen: {}, + mclose: { + mop: thinspace, + mbin: mediumspace, + mrel: thickspace, + minner: thinspace + }, + mpunct: { + mord: thinspace, + mop: thinspace, + mrel: thickspace, + mopen: thinspace, + mclose: thinspace, + mpunct: thinspace, + minner: thinspace + }, + minner: { + mord: thinspace, + mop: thinspace, + mbin: mediumspace, + mrel: thickspace, + mopen: thinspace, + mpunct: thinspace, + minner: thinspace + } +}; + +// Spacing relationships for script and scriptscript styles +const tightSpacings = { + mord: { + mop: thinspace + }, + mop: { + mord: thinspace, + mop: thinspace + }, + mbin: {}, + mrel: {}, + mopen: {}, + mclose: { + mop: thinspace + }, + mpunct: {}, + minner: { + mop: thinspace + } +}; +;// ./src/defineFunction.ts +/** Context provided to function handlers for error messages. */ + +// Note: reverse the order of the return type union will cause a flow error. +// See https://github.com/facebook/flow/issues/3663. + +// More general version of `HtmlBuilder` for nodes (e.g. \sum, accent types) +// whose presence impacts super/subscripting. In this case, ParseNode<"supsub"> +// delegates its HTML building to the HtmlBuilder corresponding to these nodes. + +/** + * Parser-facing function spec. Optional properties should use the defaults + * documented below. + */ + +/** + * Builder fields consumed during registration. These are stored separately in + * `_htmlGroupBuilders` and `_mathmlGroupBuilders`, and are not used by Parser. + */ + +/** + * Full registration spec passed to `defineFunction`. It combines the + * parser-facing fields with optional builder fields and the names being + * registered. + */ + +/** + * All registered functions. + * `functions.js` just exports this same dictionary again and makes it public. + * `Parser.js` requires this dictionary. + */ +const _functions = {}; + +/** + * All HTML builders. Should be only used in the `define*` and the `build*ML` + * functions. + * + * Builders for different node types are stored side by side, but + * `HtmlBuilder` is contravariant in `T`, so there is no single type + * argument that makes storing/retrieving them typecheck. `any` is used + * as an existential-quantifier escape hatch. + */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any +const _htmlGroupBuilders = {}; + +/** + * All MathML builders. Should be only used in the `define*` and the `build*ML` + * functions. See `_htmlGroupBuilders` above for the rationale behind `any`. + */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any +const _mathmlGroupBuilders = {}; +function defineFunction(data) { + const { + type, + names, + htmlBuilder, + mathmlBuilder + } = data; + for (let i = 0; i < names.length; ++i) { + // To avoid destructuring and rebuilding an object, + // we store the entire FunctionDefSpec object, + // even though Parser only needs the FunctionSpec fields. + _functions[names[i]] = data; + } + if (type) { + if (htmlBuilder) { + _htmlGroupBuilders[type] = htmlBuilder; + } + if (mathmlBuilder) { + _mathmlGroupBuilders[type] = mathmlBuilder; + } + } +} + +/** + * Use this to register only the HTML and MathML builders for a function (e.g. + * if the function's ParseNode is generated in Parser.js rather than via a + * stand-alone handler provided to `defineFunction`). + */ +function defineFunctionBuilders(_ref) { + let { + type, + htmlBuilder, + mathmlBuilder + } = _ref; + if (htmlBuilder) { + _htmlGroupBuilders[type] = htmlBuilder; + } + if (mathmlBuilder) { + _mathmlGroupBuilders[type] = mathmlBuilder; + } +} +const normalizeArgument = function (arg) { + return arg.type === "ordgroup" && arg.body.length === 1 ? arg.body[0] : arg; +}; + +// Since the corresponding buildHTML/buildMathML function expects a +// list of elements, we normalize for different kinds of arguments +const ordargument = function (arg) { + return arg.type === "ordgroup" ? arg.body : [arg]; +}; +;// ./src/buildHTML.ts +/** + * This file does the main work of building a domTree structure from a parse + * tree. The entry point is the `buildHTML` function, which takes a parse tree. + * Then, the buildExpression, buildGroup, and various groupBuilders functions + * are called, to produce a final HTML tree. + */ + + + + + + + + + +// Binary atoms (first class `mbin`) change into ordinary atoms (`mord`) +// depending on their surroundings. See TeXbook pg. 442-446, Rules 5 and 6, +// and the text before Rule 19. +const binLeftCanceller = new Set(["leftmost", "mbin", "mopen", "mrel", "mop", "mpunct"]); +const binRightCanceller = new Set(["rightmost", "mrel", "mclose", "mpunct"]); +const styleMap = { + "display": src_Style.DISPLAY, + "text": src_Style.TEXT, + "script": src_Style.SCRIPT, + "scriptscript": src_Style.SCRIPTSCRIPT +}; +const DomEnum = { + mord: "mord", + mop: "mop", + mbin: "mbin", + mrel: "mrel", + mopen: "mopen", + mclose: "mclose", + mpunct: "mpunct", + minner: "minner" +}; +/** + * Take a list of nodes, build them in order, and return a list of the built + * nodes. documentFragments are flattened into their contents, so the + * returned list contains no fragments. `isRealGroup` is true if `expression` + * is a real group (no atoms will be added on either side), as opposed to + * a partial group (e.g. one created by \color). `surrounding` is an array + * consisting type of nodes that will be added to the left and right. + */ +const buildExpression = function (expression, options, isRealGroup, surrounding) { + if (surrounding === void 0) { + surrounding = [null, null]; + } + // Parse expressions into `groups`. + const groups = []; + for (let i = 0; i < expression.length; i++) { + const output = buildGroup(expression[i], options); + if (output instanceof DocumentFragment) { + const children = output.children; + groups.push(...children); + } else { + groups.push(output); + } + } + + // Combine consecutive domTree.symbolNodes into a single symbolNode. + tryCombineChars(groups); + + // If `expression` is a partial group, let the parent handle spacings + // to avoid processing groups multiple times. + if (!isRealGroup) { + return groups; + } + let glueOptions = options; + if (expression.length === 1) { + const node = expression[0]; + if (node.type === "sizing") { + glueOptions = options.havingSize(node.size); + } else if (node.type === "styling") { + glueOptions = options.havingStyle(styleMap[node.style]); + } + } + + // Dummy spans for determining spacings between surrounding atoms. + // If `expression` has no atoms on the left or right, class "leftmost" + // or "rightmost", respectively, is used to indicate it. + const dummyPrev = makeSpan([surrounding[0] || "leftmost"], [], options); + const dummyNext = makeSpan([surrounding[1] || "rightmost"], [], options); + + // TODO: These code assumes that a node's math class is the first element + // of its `classes` array. A later cleanup should ensure this, for + // instance by changing the signature of `makeSpan`. + + // Before determining what spaces to insert, perform bin cancellation. + // Binary operators change to ordinary symbols in some contexts. + const isRoot = isRealGroup === "root"; + traverseNonSpaceNodes(groups, (node, prev) => { + const prevType = prev.classes[0]; + const type = node.classes[0]; + if (prevType === "mbin" && binRightCanceller.has(type)) { + prev.classes[0] = "mord"; + } else if (type === "mbin" && binLeftCanceller.has(prevType)) { + node.classes[0] = "mord"; + } + }, { + node: dummyPrev + }, dummyNext, isRoot); + traverseNonSpaceNodes(groups, (node, prev) => { + var _tightSpacings$prevTy, _spacings$prevType; + const prevType = getTypeOfDomTree(prev); + const type = getTypeOfDomTree(node); + + // 'mtight' indicates that the node is script or scriptscript style. + const space = prevType && type ? node.hasClass("mtight") ? (_tightSpacings$prevTy = tightSpacings[prevType]) == null ? void 0 : _tightSpacings$prevTy[type] : (_spacings$prevType = spacings[prevType]) == null ? void 0 : _spacings$prevType[type] : null; + if (space) { + // Insert glue (spacing) after the `prev`. + return makeGlue(space, glueOptions); + } + }, { + node: dummyPrev + }, dummyNext, isRoot); + return groups; +}; + +// Depth-first traverse non-space `nodes`, calling `callback` with the current and +// previous node as arguments, optionally returning a node to insert after the +// previous node. `prev` is an object with the previous node and `insertAfter` +// function to insert after it. `next` is a node that will be added to the right. +// Used for bin cancellation and inserting spacings. +const traverseNonSpaceNodes = function (nodes, callback, prev, next, isRoot) { + if (next) { + // temporarily append the right node, if exists + nodes.push(next); + } + let i = 0; + for (; i < nodes.length; i++) { + const node = nodes[i]; + const partialGroup = checkPartialGroup(node); + if (partialGroup) { + // Recursive DFS + // TODO(ts): partialGroup.children is ReadonlyArray but this + // function mutates the array (insertAfter splices into it). + traverseNonSpaceNodes(partialGroup.children, callback, prev, null, isRoot); + continue; + } + + // Ignore explicit spaces (e.g., \;, \,) when determining what implicit + // spacing should go between atoms of different classes + const nonspace = !node.hasClass("mspace"); + if (nonspace) { + const result = callback(node, prev.node); + if (result) { + if (prev.insertAfter) { + prev.insertAfter(result); + } else { + // insert at front + nodes.unshift(result); + i++; + } + } + } + if (nonspace) { + prev.node = node; + } else if (isRoot && node.hasClass("newline")) { + prev.node = makeSpan(["leftmost"]); // treat like beginning of line + } + prev.insertAfter = (index => n => { + nodes.splice(index + 1, 0, n); + i++; + })(i); + } + if (next) { + nodes.pop(); + } +}; + +// Check if given node is a partial group, i.e., does not affect spacing around. +const checkPartialGroup = function (node) { + if (node instanceof DocumentFragment || node instanceof Anchor || node instanceof Span && node.hasClass("enclosing")) { + return node; + } + return null; +}; + +// Return the outermost node of a domTree. +const getOutermostNode = function (node, side) { + const partialGroup = checkPartialGroup(node); + if (partialGroup) { + const children = partialGroup.children; + if (children.length) { + if (side === "right") { + return getOutermostNode(children[children.length - 1], "right"); + } else if (side === "left") { + return getOutermostNode(children[0], "left"); + } + } + } + return node; +}; + +// Return math atom class (mclass) of a domTree. +// If `side` is given, it will get the type of the outermost node at given side. +const getTypeOfDomTree = function (node, side) { + if (!node) { + return null; + } + if (side) { + node = getOutermostNode(node, side); + } + // This makes a lot of assumptions as to where the type of atom + // appears. We should do a better job of enforcing this. + const className = node.classes[0]; + return DomEnum[className] || null; +}; +const makeNullDelimiter = function (options, classes) { + const moreClasses = ["nulldelimiter"].concat(options.baseSizingClasses()); + return makeSpan(classes.concat(moreClasses)); +}; + +/** + * buildGroup is the function that takes a group and calls the correct groupType + * function for it. It also handles the interaction of size and style changes + * between parents and children. + */ +const buildGroup = function (group, options, baseOptions) { + if (!group) { + return makeSpan(); + } + if (_htmlGroupBuilders[group.type]) { + // TODO(ts): groupBuilders is Record>; + // a type-safe registry would need a mapped type keyed by NodeType. + let groupNode = _htmlGroupBuilders[group.type](group, options); + + // If the size changed between the parent and the current group, account + // for that size difference. + if (baseOptions && options.size !== baseOptions.size) { + groupNode = makeSpan(options.sizingClasses(baseOptions), [groupNode], options); + const multiplier = options.sizeMultiplier / baseOptions.sizeMultiplier; + groupNode.height *= multiplier; + groupNode.depth *= multiplier; + } + return groupNode; + } else { + throw new src_ParseError("Got group of unknown type: '" + group.type + "'"); + } +}; + +/** + * Combine an array of HTML DOM nodes (e.g., the output of `buildExpression`) + * into an unbreakable HTML node of class .base, with proper struts to + * guarantee correct vertical extent. `buildHTML` calls this repeatedly to + * make up the entire expression as a sequence of unbreakable units. + */ +function buildHTMLUnbreakable(children, options) { + // Compute height and depth of this chunk. + const body = makeSpan(["base"], children, options); + + // Add strut, which ensures that the top of the HTML element falls at + // the height of the expression, and the bottom of the HTML element + // falls at the depth of the expression. + const strut = makeSpan(["strut"]); + strut.style.height = makeEm(body.height + body.depth); + if (body.depth) { + strut.style.verticalAlign = makeEm(-body.depth); + } + body.children.unshift(strut); + return body; +} + +/** + * Take an entire parse tree, and build it into an appropriate set of HTML + * nodes. + */ +function buildHTML(tree, options) { + // Strip off outer tag wrapper for processing below. + let tag = null; + if (tree.length === 1 && tree[0].type === "tag") { + tag = tree[0].tag; + tree = tree[0].body; + } + + // Build the expression contained in the tree + const expression = buildExpression(tree, options, "root"); + let eqnNum; + if (expression.length === 2 && expression[1].hasClass("tag")) { + // An environment with automatic equation numbers, e.g. {gather}. + eqnNum = expression.pop(); + } + const children = []; + + // Create one base node for each chunk between potential line breaks. + // The TeXBook [p.173] says "A formula will be broken only after a + // relation symbol like $=$ or $<$ or $\rightarrow$, or after a binary + // operation symbol like $+$ or $-$ or $\times$, where the relation or + // binary operation is on the ``outer level'' of the formula (i.e., not + // enclosed in {...} and not part of an \over construction)." + + let parts = []; + for (let i = 0; i < expression.length; i++) { + parts.push(expression[i]); + if (expression[i].hasClass("mbin") || expression[i].hasClass("mrel") || expression[i].hasClass("allowbreak")) { + // Put any post-operator glue on same line as operator. + // Watch for \nobreak along the way, and stop at \newline. + let nobreak = false; + while (i < expression.length - 1 && expression[i + 1].hasClass("mspace") && !expression[i + 1].hasClass("newline")) { + i++; + parts.push(expression[i]); + if (expression[i].hasClass("nobreak")) { + nobreak = true; + } + } + // Don't allow break if \nobreak among the post-operator glue. + if (!nobreak) { + children.push(buildHTMLUnbreakable(parts, options)); + parts = []; + } + } else if (expression[i].hasClass("newline")) { + // Write the line except the newline + parts.pop(); + if (parts.length > 0) { + children.push(buildHTMLUnbreakable(parts, options)); + parts = []; + } + // Put the newline at the top level + children.push(expression[i]); + } + } + if (parts.length > 0) { + children.push(buildHTMLUnbreakable(parts, options)); + } + + // Now, if there was a tag, build it too and append it as a final child. + let tagChild; + if (tag) { + tagChild = buildHTMLUnbreakable(buildExpression(tag, options, true), options); + tagChild.classes = ["tag"]; + children.push(tagChild); + } else if (eqnNum) { + children.push(eqnNum); + } + const htmlNode = makeSpan(["katex-html"], children); + htmlNode.setAttribute("aria-hidden", "true"); + + // Adjust the strut of the tag to be the maximum height of all children + // (the height of the enclosing htmlNode) for proper vertical alignment. + if (tagChild) { + const strut = tagChild.children[0]; + strut.style.height = makeEm(htmlNode.height + htmlNode.depth); + if (htmlNode.depth) { + strut.style.verticalAlign = makeEm(-htmlNode.depth); + } + } + return htmlNode; +} +;// ./src/mathMLTree.ts +/** + * These objects store data about MathML nodes. This is the MathML equivalent + * of the types in domTree.js. Since MathML handles its own rendering, and + * since we're mainly using MathML to improve accessibility, we don't manage + * any of the styling state that the plain DOM nodes do. + * + * The `toNode` and `toMarkup` functions work similarly to how they do in + * domTree.js, creating namespaced DOM nodes and HTML text markup respectively. + */ + + + + + + +/** + * MathML node types used in KaTeX. For a complete list of MathML nodes, see + * https://developer.mozilla.org/en-US/docs/Web/MathML/Element. + */ + +function newDocumentFragment(children) { + return new DocumentFragment(children); +} + +/** + * This node represents a general purpose MathML node of any type. The + * constructor requires the type of node to create (for example, `"mo"` or + * `"mspace"`, corresponding to `` and `` tags). + */ +class MathNode { + constructor(type, children, classes) { + this.type = void 0; + this.attributes = void 0; + this.children = void 0; + this.classes = void 0; + this.type = type; + this.attributes = {}; + this.children = children || []; + this.classes = classes || []; + } + + /** + * Sets an attribute on a MathML node. MathML depends on attributes to convey a + * semantic content, so this is used heavily. + */ + setAttribute(name, value) { + this.attributes[name] = value; + } + + /** + * Gets an attribute on a MathML node. + */ + getAttribute(name) { + return this.attributes[name]; + } + + /** + * Converts the math node into a MathML-namespaced DOM element. + */ + toNode() { + const node = document.createElementNS("http://www.w3.org/1998/Math/MathML", this.type); + for (const attr in this.attributes) { + if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) { + node.setAttribute(attr, this.attributes[attr]); + } + } + if (this.classes.length > 0) { + node.className = createClass(this.classes); + } + for (let i = 0; i < this.children.length; i++) { + // Combine multiple TextNodes into one TextNode, to prevent + // screen readers from reading each as a separate word [#3995] + if (this.children[i] instanceof TextNode && this.children[i + 1] instanceof TextNode) { + let text = this.children[i].toText() + this.children[++i].toText(); + while (this.children[i + 1] instanceof TextNode) { + text += this.children[++i].toText(); + } + node.appendChild(new TextNode(text).toNode()); + } else { + node.appendChild(this.children[i].toNode()); + } + } + return node; + } + + /** + * Converts the math node into an HTML markup string. + */ + toMarkup() { + let markup = "<" + this.type; + + // Add the attributes + for (const attr in this.attributes) { + if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) { + markup += " " + attr + "=\""; + markup += utils_escape(this.attributes[attr]); + markup += "\""; + } + } + if (this.classes.length > 0) { + markup += " class =\"" + utils_escape(createClass(this.classes)) + "\""; + } + markup += ">"; + for (let i = 0; i < this.children.length; i++) { + markup += this.children[i].toMarkup(); + } + markup += ""; + return markup; + } + + /** + * Converts the math node into a string, similar to innerText, but escaped. + */ + toText() { + return this.children.map(child => child.toText()).join(""); + } +} + +/** + * This node represents a piece of text. + */ +class TextNode { + constructor(text) { + this.text = void 0; + this.text = text; + } + + /** + * Converts the text node into a DOM text node. + */ + toNode() { + return document.createTextNode(this.text); + } + + /** + * Converts the text node into escaped HTML markup + * (representing the text itself). + */ + toMarkup() { + return utils_escape(this.toText()); + } + + /** + * Converts the text node into a string + * (representing the text itself). + */ + toText() { + return this.text; + } +} + +/** + * This node represents a space, but may render as or as text, + * depending on the width. + */ +class SpaceNode { + /** + * Create a Space node with width given in CSS ems. + */ + constructor(width) { + this.width = void 0; + this.character = void 0; + this.width = width; + // See https://www.w3.org/TR/2000/WD-MathML2-20000328/chapter6.html + // for a table of space-like characters. We use Unicode + // representations instead of &LongNames; as it's not clear how to + // make the latter via document.createTextNode. + if (width >= 0.05555 && width <= 0.05556) { + this.character = "\u200a"; //   + } else if (width >= 0.1666 && width <= 0.1667) { + this.character = "\u2009"; //   + } else if (width >= 0.2222 && width <= 0.2223) { + this.character = "\u2005"; //   + } else if (width >= 0.2777 && width <= 0.2778) { + this.character = "\u2005\u200a"; //    + } else if (width >= -0.05556 && width <= -0.05555) { + this.character = "\u200a\u2063"; // ​ + } else if (width >= -0.1667 && width <= -0.1666) { + this.character = "\u2009\u2063"; // ​ + } else if (width >= -0.2223 && width <= -0.2222) { + this.character = "\u205f\u2063"; // ​ + } else if (width >= -0.2778 && width <= -0.2777) { + this.character = "\u2005\u2063"; // ​ + } else { + this.character = null; + } + } + + /** + * Converts the math node into a MathML-namespaced DOM element. + */ + toNode() { + if (this.character) { + return document.createTextNode(this.character); + } else { + const node = document.createElementNS("http://www.w3.org/1998/Math/MathML", "mspace"); + node.setAttribute("width", makeEm(this.width)); + return node; + } + } + + /** + * Converts the math node into an HTML markup string. + */ + toMarkup() { + if (this.character) { + return "" + this.character + ""; + } else { + return ""; + } + } + + /** + * Converts the math node into a string, similar to innerText. + */ + toText() { + if (this.character) { + return this.character; + } else { + return " "; + } + } +} +;// ./src/buildMathML.ts +/** + * This file converts a parse tree into a corresponding MathML tree. The main + * entry point is the `buildMathML` function, which takes a parse tree from the + * parser. + */ + + + + + + + +const noVariantSymbols = new Set(["\\imath", "\\jmath"]); +const rowLikeTypes = new Set(["mrow", "mtable"]); + +/** + * Takes a symbol and converts it into a MathML text node after performing + * optional replacement from symbols.js. + */ +const makeText = function (text, mode, options) { + if (src_symbols[mode][text] && src_symbols[mode][text].replace && text.charCodeAt(0) !== 0xD835 && !(ligatures.hasOwnProperty(text) && options && (options.fontFamily && options.fontFamily.slice(4, 6) === "tt" || options.font && options.font.slice(4, 6) === "tt"))) { + text = src_symbols[mode][text].replace; + } + return new TextNode(text); +}; + +/** + * Wrap the given array of nodes in an node if needed, i.e., + * unless the array has length 1. Always returns a single node. + */ +const makeRow = function (body) { + if (body.length === 1) { + return body[0]; + } else { + return new MathNode("mrow", body); + } +}; +const mathFontVariants = { + mathit: "italic", + boldsymbol: group => group.type === "textord" ? "bold" : "bold-italic", + mathbf: "bold", + mathbb: "double-struck", + mathsfit: "sans-serif-italic", + mathfrak: "fraktur", + mathscr: "script", + mathcal: "script", + mathsf: "sans-serif", + mathtt: "monospace" +}; + +/** + * Returns the math variant as a string or null if none is required. + */ +const getVariant = (group, options) => { + // Handle \text... font specifiers as best we can. + // MathML has a limited list of allowable mathvariant specifiers; see + // https://www.w3.org/TR/MathML3/chapter3.html#presm.commatt + if (group.mode === "text") { + if (options.fontFamily === "texttt") { + return "monospace"; + } else if (options.fontFamily === "textsf") { + if (options.fontShape === "textit" && options.fontWeight === "textbf") { + return "sans-serif-bold-italic"; + } else if (options.fontShape === "textit") { + return "sans-serif-italic"; + } else if (options.fontWeight === "textbf") { + return "bold-sans-serif"; + } else { + return "sans-serif"; + } + } else if (options.fontShape === "textit" && options.fontWeight === "textbf") { + return "bold-italic"; + } else if (options.fontShape === "textit") { + return "italic"; + } else if (options.fontWeight === "textbf") { + return "bold"; + } + } + const font = options.font; + if (!font || font === "mathnormal") { + return null; + } + const mode = group.mode; + const mathVariant = mathFontVariants[font]; + if (mathVariant) { + return typeof mathVariant === "function" ? mathVariant(group) : mathVariant; + } + let text = group.text; + if (noVariantSymbols.has(text)) { + return null; + } + if (src_symbols[mode][text]) { + const replacement = src_symbols[mode][text].replace; + if (replacement) { + text = replacement; + } + } + const fontName = fontMap[font].fontName; + if (getCharacterMetrics(text, fontName, mode)) { + return fontMap[font].variant; + } + return null; +}; + +/** + * Check for . which is how a dot renders in MathML, + * or , + * which is how a braced comma {,} renders in MathML + */ +function isNumberPunctuation(group) { + if (!group) { + return false; + } + if (group.type === 'mi' && group.children.length === 1) { + const child = group.children[0]; + return child instanceof TextNode && child.text === '.'; + } else if (group.type === 'mo' && group.children.length === 1 && group.getAttribute('separator') === 'true' && group.getAttribute('lspace') === '0em' && group.getAttribute('rspace') === '0em') { + const child = group.children[0]; + return child instanceof TextNode && child.text === ','; + } else { + return false; + } +} + +/** + * Takes a list of nodes, builds them, and returns a list of the generated + * MathML nodes. Also combine consecutive outputs into a single + * tag. + */ +const buildMathML_buildExpression = function (expression, options, isOrdgroup) { + if (expression.length === 1) { + const group = buildMathML_buildGroup(expression[0], options); + if (isOrdgroup && group instanceof MathNode && group.type === "mo") { + // When TeX writers want to suppress spacing on an operator, + // they often put the operator by itself inside braces. + group.setAttribute("lspace", "0em"); + group.setAttribute("rspace", "0em"); + } + return [group]; + } + const groups = []; + let lastGroup; + for (let i = 0; i < expression.length; i++) { + const group = buildMathML_buildGroup(expression[i], options); + if (group instanceof MathNode && lastGroup instanceof MathNode) { + // Concatenate adjacent s + if (group.type === 'mtext' && lastGroup.type === 'mtext' && group.getAttribute('mathvariant') === lastGroup.getAttribute('mathvariant')) { + lastGroup.children.push(...group.children); + continue; + // Concatenate adjacent s + } else if (group.type === 'mn' && lastGroup.type === 'mn') { + lastGroup.children.push(...group.children); + continue; + // Concatenate ... followed by . + } else if (isNumberPunctuation(group) && lastGroup.type === 'mn') { + lastGroup.children.push(...group.children); + continue; + // Concatenate . followed by ... + } else if (group.type === 'mn' && isNumberPunctuation(lastGroup)) { + group.children = [...lastGroup.children, ...group.children]; + groups.pop(); + // Put preceding ... or . inside base of + // ...base......exponent... (or ) + } else if ((group.type === 'msup' || group.type === 'msub') && group.children.length >= 1 && (lastGroup.type === 'mn' || isNumberPunctuation(lastGroup))) { + const base = group.children[0]; + if (base instanceof MathNode && base.type === 'mn') { + base.children = [...lastGroup.children, ...base.children]; + groups.pop(); + } + // \not + } else if (lastGroup.type === 'mi' && lastGroup.children.length === 1) { + const lastChild = lastGroup.children[0]; + if (lastChild instanceof TextNode && lastChild.text === '\u0338' && (group.type === 'mo' || group.type === 'mi' || group.type === 'mn')) { + const child = group.children[0]; + if (child instanceof TextNode && child.text.length > 0) { + // Overlay with combining character long solidus + child.text = child.text.slice(0, 1) + "\u0338" + child.text.slice(1); + groups.pop(); + } + } + } + } + groups.push(group); + lastGroup = group; + } + return groups; +}; + +/** + * Equivalent to buildExpression, but wraps the elements in an + * if there's more than one. Returns a single node instead of an array. + */ +const buildExpressionRow = function (expression, options, isOrdgroup) { + return makeRow(buildMathML_buildExpression(expression, options, isOrdgroup)); +}; + +/** + * Takes a group from the parser and calls the appropriate groupBuilders function + * on it to produce a MathML node. + */ +const buildMathML_buildGroup = function (group, options) { + if (!group) { + return new MathNode("mrow"); + } + if (_mathmlGroupBuilders[group.type]) { + // TODO(ts): MathMLBuilder returns MathDomNode but all concrete + // builders return MathNode. Widening the return type here would + // require updating all callers that assume MathNode. + return _mathmlGroupBuilders[group.type](group, options); + } else { + throw new src_ParseError("Got group of unknown type: '" + group.type + "'"); + } +}; + +/** + * Takes a full parse tree and settings and builds a MathML representation of + * it. In particular, we put the elements from building the parse tree into a + * tag so we can also include that TeX source as an annotation. + * + * Note that we actually return a domTree element with a `` inside it so + * we can do appropriate styling. + */ +function buildMathML(tree, texExpression, options, isDisplayMode, forMathmlOnly) { + const expression = buildMathML_buildExpression(tree, options); + + // TODO: Make a pass thru the MathML similar to buildHTML.traverseNonSpaceNodes + // and add spacing nodes. This is necessary only adjacent to math operators + // like \sin or \lim or to subsup elements that contain math operators. + // MathML takes care of the other spacing issues. + + // Wrap up the expression in an mrow so it is presented in the semantics + // tag correctly, unless it's a single or . + let wrapper; + if (expression.length === 1 && expression[0] instanceof MathNode && rowLikeTypes.has(expression[0].type)) { + wrapper = expression[0]; + } else { + wrapper = new MathNode("mrow", expression); + } + + // Build a TeX annotation of the source + const annotation = new MathNode("annotation", [new TextNode(texExpression)]); + annotation.setAttribute("encoding", "application/x-tex"); + const semantics = new MathNode("semantics", [wrapper, annotation]); + const math = new MathNode("math", [semantics]); + math.setAttribute("xmlns", "http://www.w3.org/1998/Math/MathML"); + if (isDisplayMode) { + math.setAttribute("display", "block"); + } + + // You can't style nodes, so we wrap the node in a span. + // NOTE: The span class is not typed to have nodes as children, and + // we don't want to make the children type more generic since the children + // of span are expected to have more fields in `buildHtml` contexts. + // The MathNode implements VirtualNode (toNode/toMarkup) which is all that + // Span needs from its children for rendering. + // TODO(ts): Span's child type is HtmlDomNode, but MathNode only implements + // VirtualNode. The double-cast acknowledges this architectural limitation. + const wrapperClass = forMathmlOnly ? "katex" : "katex-mathml"; + return makeSpan([wrapperClass], [math]); +} +;// ./src/Options.ts +/** + * This file contains information about the options that the Parser carries + * around with it while parsing. Data is held in an `Options` object, and when + * recursing, a new `Options` object can be created with the `.with*` and + * `.reset` functions. + */ + + +const sizeStyleMap = [ +// Each element contains [textsize, scriptsize, scriptscriptsize]. +// The size mappings are taken from TeX with \normalsize=10pt. +[1, 1, 1], +// size1: [5, 5, 5] \tiny +[2, 1, 1], +// size2: [6, 5, 5] +[3, 1, 1], +// size3: [7, 5, 5] \scriptsize +[4, 2, 1], +// size4: [8, 6, 5] \footnotesize +[5, 2, 1], +// size5: [9, 6, 5] \small +[6, 3, 1], +// size6: [10, 7, 5] \normalsize +[7, 4, 2], +// size7: [12, 8, 6] \large +[8, 6, 3], +// size8: [14.4, 10, 7] \Large +[9, 7, 6], +// size9: [17.28, 12, 10] \LARGE +[10, 8, 7], +// size10: [20.74, 14.4, 12] \huge +[11, 10, 9] // size11: [24.88, 20.74, 17.28] \HUGE +]; +const sizeMultipliers = [ +// fontMetrics.js:getGlobalMetrics also uses size indexes, so if +// you change size indexes, change that function. +0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.2, 1.44, 1.728, 2.074, 2.488]; +const sizeAtStyle = function (size, style) { + return style.size < 2 ? size : sizeStyleMap[size - 1][style.size - 1]; +}; +/** + * This is the main options class. It contains the current style, size, color, + * and font. + * + * Options objects should not be modified. To create a new Options with + * different properties, call a `.having*` method. + */ +class Options { + constructor(data) { + this.style = void 0; + this.color = void 0; + this.size = void 0; + this.textSize = void 0; + this.phantom = void 0; + // A font family applies to a group of fonts (i.e. SansSerif), while a font + // represents a specific font (i.e. SansSerif Bold). + // See: https://tex.stackexchange.com/questions/22350/difference-between-textrm-and-mathrm + this.font = void 0; + this.fontFamily = void 0; + this.fontWeight = void 0; + this.fontShape = void 0; + this.sizeMultiplier = void 0; + this.maxSize = void 0; + this.minRuleThickness = void 0; + this._fontMetrics = void 0; + this.style = data.style; + this.color = data.color; + this.size = data.size || Options.BASESIZE; + this.textSize = data.textSize || this.size; + this.phantom = !!data.phantom; + this.font = data.font || ""; + this.fontFamily = data.fontFamily || ""; + this.fontWeight = data.fontWeight || ""; + this.fontShape = data.fontShape || ""; + this.sizeMultiplier = sizeMultipliers[this.size - 1]; + this.maxSize = data.maxSize; + this.minRuleThickness = data.minRuleThickness; + this._fontMetrics = undefined; + } + + /** + * Returns a new options object with the same properties as "this". Properties + * from "extension" will be copied to the new options object. + */ + extend(extension) { + const data = { + style: this.style, + size: this.size, + textSize: this.textSize, + color: this.color, + phantom: this.phantom, + font: this.font, + fontFamily: this.fontFamily, + fontWeight: this.fontWeight, + fontShape: this.fontShape, + maxSize: this.maxSize, + minRuleThickness: this.minRuleThickness + }; + Object.assign(data, extension); + return new Options(data); + } + + /** + * Return an options object with the given style. If `this.style === style`, + * returns `this`. + */ + havingStyle(style) { + if (this.style === style) { + return this; + } else { + return this.extend({ + style: style, + size: sizeAtStyle(this.textSize, style) + }); + } + } + + /** + * Return an options object with a cramped version of the current style. If + * the current style is cramped, returns `this`. + */ + havingCrampedStyle() { + return this.havingStyle(this.style.cramp()); + } + + /** + * Return an options object with the given size and in at least `\textstyle`. + * Returns `this` if appropriate. + */ + havingSize(size) { + if (this.size === size && this.textSize === size) { + return this; + } else { + return this.extend({ + style: this.style.text(), + size: size, + textSize: size, + sizeMultiplier: sizeMultipliers[size - 1] + }); + } + } + + /** + * Like `this.havingSize(BASESIZE).havingStyle(style)`. If `style` is omitted, + * changes to at least `\textstyle`. + */ + havingBaseStyle(style) { + style = style || this.style.text(); + const wantSize = sizeAtStyle(Options.BASESIZE, style); + if (this.size === wantSize && this.textSize === Options.BASESIZE && this.style === style) { + return this; + } else { + return this.extend({ + style: style, + size: wantSize + }); + } + } + + /** + * Remove the effect of sizing changes such as \Huge. + * Keep the effect of the current style, such as \scriptstyle. + */ + havingBaseSizing() { + let size; + switch (this.style.id) { + case 4: + case 5: + size = 3; // normalsize in scriptstyle + break; + case 6: + case 7: + size = 1; // normalsize in scriptscriptstyle + break; + default: + size = 6; + // normalsize in textstyle or displaystyle + } + return this.extend({ + style: this.style.text(), + size: size + }); + } + + /** + * Create a new options object with the given color. + */ + withColor(color) { + return this.extend({ + color: color + }); + } + + /** + * Create a new options object with "phantom" set to true. + */ + withPhantom() { + return this.extend({ + phantom: true + }); + } + + /** + * Creates a new options object with the given math font or old text font. + * @type {[type]} + */ + withFont(font) { + return this.extend({ + font + }); + } + + /** + * Create a new options objects with the given fontFamily. + */ + withTextFontFamily(fontFamily) { + return this.extend({ + fontFamily, + font: "" + }); + } + + /** + * Creates a new options object with the given font weight + */ + withTextFontWeight(fontWeight) { + return this.extend({ + fontWeight, + font: "" + }); + } + + /** + * Creates a new options object with the given font weight + */ + withTextFontShape(fontShape) { + return this.extend({ + fontShape, + font: "" + }); + } + + /** + * Return the CSS sizing classes required to switch from enclosing options + * `oldOptions` to `this`. Returns an array of classes. + */ + sizingClasses(oldOptions) { + if (oldOptions.size !== this.size) { + return ["sizing", "reset-size" + oldOptions.size, "size" + this.size]; + } else { + return []; + } + } + + /** + * Return the CSS sizing classes required to switch to the base size. Like + * `this.havingSize(BASESIZE).sizingClasses(this)`. + */ + baseSizingClasses() { + if (this.size !== Options.BASESIZE) { + return ["sizing", "reset-size" + this.size, "size" + Options.BASESIZE]; + } else { + return []; + } + } + + /** + * Return the font metrics for this size. + */ + fontMetrics() { + if (!this._fontMetrics) { + this._fontMetrics = getGlobalMetrics(this.size); + } + return this._fontMetrics; + } + + /** + * Gets the CSS color of the current options object + */ + getColor() { + if (this.phantom) { + return "transparent"; + } else { + return this.color; + } + } +} +/** + * The base size index. + */ +Options.BASESIZE = 6; +/* harmony default export */ var src_Options = (Options); +;// ./src/buildTree.ts + + + + + +const optionsFromSettings = function (settings) { + return new src_Options({ + style: settings.displayMode ? src_Style.DISPLAY : src_Style.TEXT, + maxSize: settings.maxSize, + minRuleThickness: settings.minRuleThickness + }); +}; +const displayWrap = function (node, settings) { + if (settings.displayMode) { + const classes = ["katex-display"]; + if (settings.leqno) { + classes.push("leqno"); + } + if (settings.fleqn) { + classes.push("fleqn"); + } + node = makeSpan(classes, [node]); + } + return node; +}; +const buildTree = function (tree, expression, settings) { + const options = optionsFromSettings(settings); + let katexNode; + if (settings.output === "mathml") { + return buildMathML(tree, expression, options, settings.displayMode, true); + } else if (settings.output === "html") { + const htmlNode = buildHTML(tree, options); + katexNode = makeSpan(["katex"], [htmlNode]); + } else { + const mathMLNode = buildMathML(tree, expression, options, settings.displayMode, false); + const htmlNode = buildHTML(tree, options); + katexNode = makeSpan(["katex"], [mathMLNode, htmlNode]); + } + return displayWrap(katexNode, settings); +}; +const buildHTMLTree = function (tree, expression, settings) { + const options = optionsFromSettings(settings); + const htmlNode = buildHTML(tree, options); + const katexNode = makeSpan(["katex"], [htmlNode]); + return displayWrap(katexNode, settings); +}; +/* harmony default export */ var src_buildTree = ((/* unused pure expression or super */ null && (buildTree))); +;// ./src/stretchy.ts +/** + * This file provides support to buildMathML.js and buildHTML.js + * for stretchy wide elements rendered from SVG files + * and other CSS trickery. + */ + + + + + +const stretchyCodePoint = { + widehat: "^", + widecheck: "ˇ", + widetilde: "~", + utilde: "~", + overleftarrow: "\u2190", + underleftarrow: "\u2190", + xleftarrow: "\u2190", + overrightarrow: "\u2192", + underrightarrow: "\u2192", + xrightarrow: "\u2192", + underbrace: "\u23df", + overbrace: "\u23de", + underbracket: "\u23b5", + overbracket: "\u23b4", + overgroup: "\u23e0", + undergroup: "\u23e1", + overleftrightarrow: "\u2194", + underleftrightarrow: "\u2194", + xleftrightarrow: "\u2194", + Overrightarrow: "\u21d2", + xRightarrow: "\u21d2", + overleftharpoon: "\u21bc", + xleftharpoonup: "\u21bc", + overrightharpoon: "\u21c0", + xrightharpoonup: "\u21c0", + xLeftarrow: "\u21d0", + xLeftrightarrow: "\u21d4", + xhookleftarrow: "\u21a9", + xhookrightarrow: "\u21aa", + xmapsto: "\u21a6", + xrightharpoondown: "\u21c1", + xleftharpoondown: "\u21bd", + xrightleftharpoons: "\u21cc", + xleftrightharpoons: "\u21cb", + xtwoheadleftarrow: "\u219e", + xtwoheadrightarrow: "\u21a0", + xlongequal: "=", + xtofrom: "\u21c4", + xrightleftarrows: "\u21c4", + xrightequilibrium: "\u21cc", + // Not a perfect match. + xleftequilibrium: "\u21cb", + // None better available. + "\\cdrightarrow": "\u2192", + "\\cdleftarrow": "\u2190", + "\\cdlongequal": "=" +}; +const stretchyMathML = function (label) { + const node = new MathNode("mo", [new TextNode(stretchyCodePoint[label.replace(/^\\/, '')])]); + node.setAttribute("stretchy", "true"); + return node; +}; + +// Many of the KaTeX SVG images have been adapted from glyphs in KaTeX fonts. +// Copyright (c) 2009-2010, Design Science, Inc. () +// Copyright (c) 2014-2017 Khan Academy () +// Licensed under the SIL Open Font License, Version 1.1. +// See \nhttp://scripts.sil.org/OFL + +// Very Long SVGs +// Many of the KaTeX stretchy wide elements use a long SVG image and an +// overflow: hidden tactic to achieve a stretchy image while avoiding +// distortion of arrowheads or brace corners. + +// The SVG typically contains a very long (400 em) arrow. + +// The SVG is in a container span that has overflow: hidden, so the span +// acts like a window that exposes only part of the SVG. + +// The SVG always has a longer, thinner aspect ratio than the container span. +// After the SVG fills 100% of the height of the container span, +// there is a long arrow shaft left over. That left-over shaft is not shown. +// Instead, it is sliced off because the span's CSS has overflow: hidden. + +// Thus, the reader sees an arrow that matches the subject matter width +// without distortion. + +// Some functions, such as \cancel, need to vary their aspect ratio. These +// functions do not get the overflow SVG treatment. + +// In the katexImagesData object just below, the dimensions all +// correspond to path geometry inside the relevant SVG. +// For example, \overrightarrow uses the same arrowhead as glyph U+2192 +// from the KaTeX Main font. The scaling factor is 1000. +// That is, inside the font, that arrowhead is 522 units tall, which +// corresponds to 0.522 em inside the document. + +const katexImagesData = { + // path(s), minWidth, height, align + overrightarrow: [["rightarrow"], 0.888, 522, "xMaxYMin"], + overleftarrow: [["leftarrow"], 0.888, 522, "xMinYMin"], + underrightarrow: [["rightarrow"], 0.888, 522, "xMaxYMin"], + underleftarrow: [["leftarrow"], 0.888, 522, "xMinYMin"], + xrightarrow: [["rightarrow"], 1.469, 522, "xMaxYMin"], + "\\cdrightarrow": [["rightarrow"], 3.0, 522, "xMaxYMin"], + // CD minwwidth2.5pc + xleftarrow: [["leftarrow"], 1.469, 522, "xMinYMin"], + "\\cdleftarrow": [["leftarrow"], 3.0, 522, "xMinYMin"], + Overrightarrow: [["doublerightarrow"], 0.888, 560, "xMaxYMin"], + xRightarrow: [["doublerightarrow"], 1.526, 560, "xMaxYMin"], + xLeftarrow: [["doubleleftarrow"], 1.526, 560, "xMinYMin"], + overleftharpoon: [["leftharpoon"], 0.888, 522, "xMinYMin"], + xleftharpoonup: [["leftharpoon"], 0.888, 522, "xMinYMin"], + xleftharpoondown: [["leftharpoondown"], 0.888, 522, "xMinYMin"], + overrightharpoon: [["rightharpoon"], 0.888, 522, "xMaxYMin"], + xrightharpoonup: [["rightharpoon"], 0.888, 522, "xMaxYMin"], + xrightharpoondown: [["rightharpoondown"], 0.888, 522, "xMaxYMin"], + xlongequal: [["longequal"], 0.888, 334, "xMinYMin"], + "\\cdlongequal": [["longequal"], 3.0, 334, "xMinYMin"], + xtwoheadleftarrow: [["twoheadleftarrow"], 0.888, 334, "xMinYMin"], + xtwoheadrightarrow: [["twoheadrightarrow"], 0.888, 334, "xMaxYMin"], + overleftrightarrow: [["leftarrow", "rightarrow"], 0.888, 522], + overbrace: [["leftbrace", "midbrace", "rightbrace"], 1.6, 548], + underbrace: [["leftbraceunder", "midbraceunder", "rightbraceunder"], 1.6, 548], + underleftrightarrow: [["leftarrow", "rightarrow"], 0.888, 522], + xleftrightarrow: [["leftarrow", "rightarrow"], 1.75, 522], + xLeftrightarrow: [["doubleleftarrow", "doublerightarrow"], 1.75, 560], + xrightleftharpoons: [["leftharpoondownplus", "rightharpoonplus"], 1.75, 716], + xleftrightharpoons: [["leftharpoonplus", "rightharpoondownplus"], 1.75, 716], + xhookleftarrow: [["leftarrow", "righthook"], 1.08, 522], + xhookrightarrow: [["lefthook", "rightarrow"], 1.08, 522], + overlinesegment: [["leftlinesegment", "rightlinesegment"], 0.888, 522], + underlinesegment: [["leftlinesegment", "rightlinesegment"], 0.888, 522], + overbracket: [["leftbracketover", "rightbracketover"], 1.6, 440], + underbracket: [["leftbracketunder", "rightbracketunder"], 1.6, 410], + overgroup: [["leftgroup", "rightgroup"], 0.888, 342], + undergroup: [["leftgroupunder", "rightgroupunder"], 0.888, 342], + xmapsto: [["leftmapsto", "rightarrow"], 1.5, 522], + xtofrom: [["leftToFrom", "rightToFrom"], 1.75, 528], + // The next three arrows are from the mhchem package. + // In mhchem.sty, min-length is 2.0em. But these arrows might appear in the + // document as \xrightarrow or \xrightleftharpoons. Those have + // min-length = 1.75em, so we set min-length on these next three to match. + xrightleftarrows: [["baraboveleftarrow", "rightarrowabovebar"], 1.75, 901], + xrightequilibrium: [["baraboveshortleftharpoon", "rightharpoonaboveshortbar"], 1.75, 716], + xleftequilibrium: [["shortbaraboveleftharpoon", "shortrightharpoonabovebar"], 1.75, 716] +}; +const wideAccentLabels = new Set(["widehat", "widecheck", "widetilde", "utilde"]); +const stretchySvg = function (group, options) { + // Create a span with inline SVG for the element. + function buildSvgSpan_() { + let viewBoxWidth = 400000; // default + const label = group.label.slice(1); + if (wideAccentLabels.has(label) && 'base' in group) { + // There are four SVG images available for each function. + // Choose a taller image when there are more characters. + const numChars = group.base.type === "ordgroup" ? group.base.body.length : 1; + let viewBoxHeight; + let pathName; + let height; + if (numChars > 5) { + if (label === "widehat" || label === "widecheck") { + viewBoxHeight = 420; + viewBoxWidth = 2364; + height = 0.42; + pathName = label + "4"; + } else { + viewBoxHeight = 312; + viewBoxWidth = 2340; + height = 0.34; + pathName = "tilde4"; + } + } else { + const imgIndex = [1, 1, 2, 2, 3, 3][numChars]; + if (label === "widehat" || label === "widecheck") { + viewBoxWidth = [0, 1062, 2364, 2364, 2364][imgIndex]; + viewBoxHeight = [0, 239, 300, 360, 420][imgIndex]; + height = [0, 0.24, 0.3, 0.3, 0.36, 0.42][imgIndex]; + pathName = label + imgIndex; + } else { + viewBoxWidth = [0, 600, 1033, 2339, 2340][imgIndex]; + viewBoxHeight = [0, 260, 286, 306, 312][imgIndex]; + height = [0, 0.26, 0.286, 0.3, 0.306, 0.34][imgIndex]; + pathName = "tilde" + imgIndex; + } + } + const path = new PathNode(pathName); + const svgNode = new SvgNode([path], { + "width": "100%", + "height": makeEm(height), + "viewBox": "0 0 " + viewBoxWidth + " " + viewBoxHeight, + "preserveAspectRatio": "none" + }); + return { + span: makeSvgSpan([], [svgNode], options), + minWidth: 0, + height + }; + } else { + const spans = []; + const data = katexImagesData[label]; + if (!data) { + throw new Error("No SVG data for \"" + label + "\"."); + } + const [paths, minWidth, viewBoxHeight] = data; + const height = viewBoxHeight / 1000; + const numSvgChildren = paths.length; + let widthClasses; + let aligns; + if (numSvgChildren === 1) { + if (data.length !== 4) { + throw new Error("Expected 4-tuple for single-path SVG data \"" + label + "\"."); + } + widthClasses = ["hide-tail"]; + aligns = [data[3]]; + } else if (numSvgChildren === 2) { + widthClasses = ["halfarrow-left", "halfarrow-right"]; + aligns = ["xMinYMin", "xMaxYMin"]; + } else if (numSvgChildren === 3) { + widthClasses = ["brace-left", "brace-center", "brace-right"]; + aligns = ["xMinYMin", "xMidYMin", "xMaxYMin"]; + } else { + throw new Error("Correct katexImagesData or update code here to support\n " + numSvgChildren + " children."); + } + for (let i = 0; i < numSvgChildren; i++) { + const path = new PathNode(paths[i]); + const svgNode = new SvgNode([path], { + "width": "400em", + "height": makeEm(height), + "viewBox": "0 0 " + viewBoxWidth + " " + viewBoxHeight, + "preserveAspectRatio": aligns[i] + " slice" + }); + const span = makeSvgSpan([widthClasses[i]], [svgNode], options); + if (numSvgChildren === 1) { + return { + span, + minWidth, + height + }; + } else { + span.style.height = makeEm(height); + spans.push(span); + } + } + return { + span: makeSpan(["stretchy"], spans, options), + minWidth, + height + }; + } + } // buildSvgSpan_() + const { + span, + minWidth, + height + } = buildSvgSpan_(); + + // Note that we are returning span.depth = 0. + // Any adjustments relative to the baseline must be done in buildHTML. + span.height = height; + span.style.height = makeEm(height); + if (minWidth > 0) { + span.style.minWidth = makeEm(minWidth); + } + return span; +}; +const stretchyEnclose = function (inner, label, topPad, bottomPad, options) { + // Return an image span for \cancel, \bcancel, \xcancel, \fbox, or \angl + let img; + const totalHeight = inner.height + inner.depth + topPad + bottomPad; + if (/fbox|color|angl/.test(label)) { + img = makeSpan(["stretchy", label], [], options); + if (label === "fbox") { + const color = options.color && options.getColor(); + if (color) { + img.style.borderColor = color; + } + } + } else { + // \cancel, \bcancel, or \xcancel + // Since \cancel's SVG is inline and it omits the viewBox attribute, + // its stroke-width will not vary with span area. + + const lines = []; + if (/^[bx]cancel$/.test(label)) { + lines.push(new LineNode({ + "x1": "0", + "y1": "0", + "x2": "100%", + "y2": "100%", + "stroke-width": "0.046em" + })); + } + if (/^x?cancel$/.test(label)) { + lines.push(new LineNode({ + "x1": "0", + "y1": "100%", + "x2": "100%", + "y2": "0", + "stroke-width": "0.046em" + })); + } + const svgNode = new SvgNode(lines, { + "width": "100%", + "height": makeEm(totalHeight) + }); + img = makeSvgSpan([], [svgNode], options); + } + img.height = totalHeight; + img.style.height = makeEm(totalHeight); + return img; +}; +;// ./src/atoms.ts +/** + * Small module for atom-group constants and type guard. Kept separate from + * `symbols.ts` so that consumers (notably `contrib/render-a11y-string`) can + * pull in `isAtom` without dragging in the ~870-line symbol tables. + */ + +// Some of these have a "-token" suffix since these are also used as `ParseNode` +// types for raw text tokens, and we want to avoid conflicts with higher-level +// `ParseNode` types. These `ParseNode`s are constructed within `Parser` by +// looking up the `symbols` map. +const ATOMS = { + "bin": 1, + "close": 1, + "inner": 1, + "open": 1, + "punct": 1, + "rel": 1 +}; +const NON_ATOMS = { + "accent-token": 1, + "mathord": 1, + "op-token": 1, + "spacing": 1, + "textord": 1 +}; +function isAtom(value) { + return value in ATOMS; +} +;// ./src/parseNode.ts + +/** + * Asserts that the node is of the given type and returns it with stricter + * typing. Throws if the node's type does not match. + */ +function assertNodeType(node, type) { + if (!node || node.type !== type) { + throw new Error("Expected node of type " + type + ", but got " + (node ? "node of type " + node.type : String(node))); + } + return node; +} + +/** + * Returns the node more strictly typed iff it is of the given type. Otherwise, + * returns null. + */ +function assertSymbolNodeType(node) { + const typedNode = checkSymbolNodeType(node); + if (!typedNode) { + throw new Error("Expected node of symbol group type, but got " + (node ? "node of type " + node.type : String(node))); + } + return typedNode; +} + +/** + * Returns the node more strictly typed if it is of the given type. Otherwise, + * returns null. + */ +function checkSymbolNodeType(node) { + if (node && (node.type === "atom" || NON_ATOMS.hasOwnProperty(node.type))) { + return node; + } + return null; +} +;// ./src/functions/accent.ts + + + + + + + + + + +const getBaseSymbol = group => { + if (group instanceof SymbolNode) { + return group; + } + if (hasHtmlDomChildren(group) && group.children.length === 1) { + return getBaseSymbol(group.children[0]); + } +}; + +// NOTE: Unlike most `htmlBuilder`s, this one handles not only "accent", but +// also "supsub" since an accent can affect super/subscripting. +const htmlBuilder = (grp, options) => { + // Accents are handled in the TeXbook pg. 443, rule 12. + let base; + let group; + let supSubGroup; + if (grp && grp.type === "supsub") { + // If our base is a character box, and we have superscripts and + // subscripts, the supsub will defer to us. In particular, we want + // to attach the superscripts and subscripts to the inner body (so + // that the position of the superscripts and subscripts won't be + // affected by the height of the accent). We accomplish this by + // sticking the base of the accent into the base of the supsub, and + // rendering that, while keeping track of where the accent is. + + // The real accent group is the base of the supsub group + group = assertNodeType(grp.base, "accent"); + // The character box is the base of the accent group + base = group.base; + // Stick the character box into the base of the supsub group + grp.base = base; + + // Rerender the supsub group with its new base, and store that + // result. + supSubGroup = assertSpan(buildGroup(grp, options)); + + // reset original base + grp.base = group; + } else { + group = assertNodeType(grp, "accent"); + base = group.base; + } + + // Build the base group + const body = buildGroup(base, options.havingCrampedStyle()); + + // Does the accent need to shift for the skew of a character? + const mustShift = group.isShifty && isCharacterBox(base); + + // Calculate the skew of the accent. This is based on the line "If the + // nucleus is not a single character, let s = 0; otherwise set s to the + // kern amount for the nucleus followed by the \skewchar of its font." + // Note that our skew metrics are just the kern between each character + // and the skewchar. + let skew = 0; + if (mustShift) { + var _getBaseSymbol$skew, _getBaseSymbol; + // Read the skew from the rendered base symbol. + // This preserves font metrics from font wrappers like \mathbb. + skew = (_getBaseSymbol$skew = (_getBaseSymbol = getBaseSymbol(body)) == null ? void 0 : _getBaseSymbol.skew) != null ? _getBaseSymbol$skew : 0; + } + const accentBelow = group.label === "\\c"; + + // calculate the amount of space between the body and the accent + let clearance = accentBelow ? body.height + body.depth : Math.min(body.height, options.fontMetrics().xHeight); + + // Build the accent + let accentBody; + if (!group.isStretchy) { + let accent; + let width; + if (group.label === "\\vec") { + // Before version 0.9, \vec used the combining font glyph U+20D7. + // But browsers, especially Safari, are not consistent in how they + // render combining characters when not preceded by a character. + // So now we use an SVG. + // If Safari reforms, we should consider reverting to the glyph. + accent = staticSvg("vec", options); + width = svgData.vec[1]; + } else { + accent = makeOrd({ + type: "textord", + mode: group.mode, + text: group.label + }, options); + accent = assertSymbolDomNode(accent); + // Remove the italic correction of the accent, because it only serves to + // shift the accent over to a place we don't want. + accent.italic = 0; + width = accent.width; + if (accentBelow) { + clearance += accent.depth; + } + } + accentBody = makeSpan(["accent-body"], [accent]); + + // "Full" accents expand the width of the resulting symbol to be + // at least the width of the accent, and overlap directly onto the + // character without any vertical offset. + const accentFull = group.label === "\\textcircled"; + if (accentFull) { + accentBody.classes.push('accent-full'); + clearance = body.height; + } + + // Shift the accent over by the skew. + let left = skew; + + // CSS defines `.katex .accent .accent-body:not(.accent-full) { width: 0 }` + // so that the accent doesn't contribute to the bounding box. + // We need to shift the character by its width (effectively half + // its width) to compensate. + if (!accentFull) { + left -= width / 2; + } + accentBody.style.left = makeEm(left); + + // \textcircled uses the \bigcirc glyph, so it needs some + // vertical adjustment to match LaTeX. + if (group.label === "\\textcircled") { + accentBody.style.top = ".2em"; + } + accentBody = makeVList({ + positionType: "firstBaseline", + children: [{ + type: "elem", + elem: body + }, { + type: "kern", + size: -clearance + }, { + type: "elem", + elem: accentBody + }] + }, options); + } else { + accentBody = stretchySvg(group, options); + accentBody = makeVList({ + positionType: "firstBaseline", + children: [{ + type: "elem", + elem: body + }, { + type: "elem", + elem: accentBody, + wrapperClasses: ["svg-align"], + wrapperStyle: skew > 0 ? { + width: "calc(100% - " + makeEm(2 * skew) + ")", + marginLeft: makeEm(2 * skew) + } : undefined + }] + }, options); + } + const accentWrap = makeSpan(["mord", "accent"], [accentBody], options); + if (supSubGroup) { + // Here, we replace the "base" child of the supsub with our newly + // generated accent. + supSubGroup.children[0] = accentWrap; + + // Since we don't rerun the height calculation after replacing the + // accent, we manually recalculate height. + supSubGroup.height = Math.max(accentWrap.height, supSubGroup.height); + + // Accents should always be ords, even when their innards are not. + supSubGroup.classes[0] = "mord"; + return supSubGroup; + } else { + return accentWrap; + } +}; +const mathmlBuilder = (group, options) => { + const accentNode = group.isStretchy ? stretchyMathML(group.label) : new MathNode("mo", [makeText(group.label, group.mode)]); + const node = new MathNode("mover", [buildMathML_buildGroup(group.base, options), accentNode]); + node.setAttribute("accent", "true"); + return node; +}; +const NON_STRETCHY_ACCENT_REGEX = new RegExp(["\\acute", "\\grave", "\\ddot", "\\tilde", "\\bar", "\\breve", "\\check", "\\hat", "\\vec", "\\dot", "\\mathring"].map(accent => "\\" + accent).join("|")); + +// Accents +defineFunction({ + type: "accent", + names: ["\\acute", "\\grave", "\\ddot", "\\tilde", "\\bar", "\\breve", "\\check", "\\hat", "\\vec", "\\dot", "\\mathring", "\\widecheck", "\\widehat", "\\widetilde", "\\overrightarrow", "\\overleftarrow", "\\Overrightarrow", "\\overleftrightarrow", "\\overgroup", "\\overlinesegment", "\\overleftharpoon", "\\overrightharpoon"], + numArgs: 1, + handler: (context, args) => { + const base = normalizeArgument(args[0]); + const isStretchy = !NON_STRETCHY_ACCENT_REGEX.test(context.funcName); + const isShifty = !isStretchy || context.funcName === "\\widehat" || context.funcName === "\\widetilde" || context.funcName === "\\widecheck"; + return { + type: "accent", + mode: context.parser.mode, + label: context.funcName, + isStretchy: isStretchy, + isShifty: isShifty, + base: base + }; + }, + htmlBuilder, + mathmlBuilder +}); + +// Text-mode accents +defineFunction({ + type: "accent", + names: ["\\'", "\\`", "\\^", "\\~", "\\=", "\\u", "\\.", '\\"', "\\c", "\\r", "\\H", "\\v", "\\textcircled"], + numArgs: 1, + allowedInText: true, + allowedInMath: true, + // unless in strict mode + argTypes: ["primitive"], + handler: (context, args) => { + const base = args[0]; + let mode = context.parser.mode; + if (mode === "math") { + context.parser.settings.reportNonstrict("mathVsTextAccents", "LaTeX's accent " + context.funcName + " works only in text mode"); + mode = "text"; + } + return { + type: "accent", + mode: mode, + label: context.funcName, + isStretchy: false, + isShifty: true, + base: base + }; + } +}); +;// ./src/functions/accentunder.ts +// Horizontal overlap functions + + + + + + +defineFunction({ + type: "accentUnder", + names: ["\\underleftarrow", "\\underrightarrow", "\\underleftrightarrow", "\\undergroup", "\\underlinesegment", "\\utilde"], + numArgs: 1, + handler: (_ref, args) => { + let { + parser, + funcName + } = _ref; + const base = args[0]; + return { + type: "accentUnder", + mode: parser.mode, + label: funcName, + base: base + }; + }, + htmlBuilder: (group, options) => { + // Treat under accents much like underlines. + const innerGroup = buildGroup(group.base, options); + const accentBody = stretchySvg(group, options); + const kern = group.label === "\\utilde" ? 0.12 : 0; + + // Generate the vlist, with the appropriate kerns + const vlist = makeVList({ + positionType: "top", + positionData: innerGroup.height, + children: [{ + type: "elem", + elem: accentBody, + wrapperClasses: ["svg-align"] + }, { + type: "kern", + size: kern + }, { + type: "elem", + elem: innerGroup + }] + }, options); + return makeSpan(["mord", "accentunder"], [vlist], options); + }, + mathmlBuilder: (group, options) => { + const accentNode = stretchyMathML(group.label); + const node = new MathNode("munder", [buildMathML_buildGroup(group.base, options), accentNode]); + node.setAttribute("accentunder", "true"); + return node; + } +}); +;// ./src/functions/arrow.ts + + + + + + +// Helper function +const paddedNode = group => { + const node = new MathNode("mpadded", group ? [group] : []); + node.setAttribute("width", "+0.6em"); + node.setAttribute("lspace", "0.3em"); + return node; +}; + +// Stretchy arrows with an optional argument +defineFunction({ + type: "xArrow", + names: ["\\xleftarrow", "\\xrightarrow", "\\xLeftarrow", "\\xRightarrow", "\\xleftrightarrow", "\\xLeftrightarrow", "\\xhookleftarrow", "\\xhookrightarrow", "\\xmapsto", "\\xrightharpoondown", "\\xrightharpoonup", "\\xleftharpoondown", "\\xleftharpoonup", "\\xrightleftharpoons", "\\xleftrightharpoons", "\\xlongequal", "\\xtwoheadrightarrow", "\\xtwoheadleftarrow", "\\xtofrom", + // The next 3 functions are here to support the mhchem extension. + // Direct use of these functions is discouraged and may break someday. + "\\xrightleftarrows", "\\xrightequilibrium", "\\xleftequilibrium", + // The next 3 functions are here only to support the {CD} environment. + "\\\\cdrightarrow", "\\\\cdleftarrow", "\\\\cdlongequal"], + numArgs: 1, + numOptionalArgs: 1, + handler(_ref, args, optArgs) { + let { + parser, + funcName + } = _ref; + return { + type: "xArrow", + mode: parser.mode, + label: funcName, + body: args[0], + below: optArgs[0] + }; + }, + htmlBuilder(group, options) { + const style = options.style; + + // Build the argument groups in the appropriate style. + // Ref: amsmath.dtx: \hbox{$\scriptstyle\mkern#3mu{#6}\mkern#4mu$}% + + // Some groups can return document fragments. Handle those by wrapping + // them in a span. + let newOptions = options.havingStyle(style.sup()); + const upperGroup = wrapFragment(buildGroup(group.body, newOptions, options), options); + const arrowPrefix = group.label.slice(0, 2) === "\\x" ? "x" : "cd"; + upperGroup.classes.push(arrowPrefix + "-arrow-pad"); + let lowerGroup; + if (group.below) { + // Build the lower group + newOptions = options.havingStyle(style.sub()); + lowerGroup = wrapFragment(buildGroup(group.below, newOptions, options), options); + lowerGroup.classes.push(arrowPrefix + "-arrow-pad"); + } + const arrowBody = stretchySvg(group, options); + + // Re shift: Note that stretchySvg returned arrowBody.depth = 0. + // The point we want on the math axis is at 0.5 * arrowBody.height. + const arrowShift = -options.fontMetrics().axisHeight + 0.5 * arrowBody.height; + // 2 mu kern. Ref: amsmath.dtx: #7\if0#2\else\mkern#2mu\fi + let upperShift = -options.fontMetrics().axisHeight - 0.5 * arrowBody.height - 0.111; // 0.111 em = 2 mu + if (upperGroup.depth > 0.25 || group.label === "\\xleftequilibrium") { + upperShift -= upperGroup.depth; // shift up if depth encroaches + } + + // Generate the vlist + let vlist; + if (lowerGroup) { + const lowerShift = -options.fontMetrics().axisHeight + lowerGroup.height + 0.5 * arrowBody.height + 0.111; + vlist = makeVList({ + positionType: "individualShift", + children: [{ + type: "elem", + elem: upperGroup, + shift: upperShift + }, { + type: "elem", + elem: arrowBody, + shift: arrowShift, + wrapperClasses: ["svg-align"] + }, { + type: "elem", + elem: lowerGroup, + shift: lowerShift + }] + }, options); + } else { + vlist = makeVList({ + positionType: "individualShift", + children: [{ + type: "elem", + elem: upperGroup, + shift: upperShift + }, { + type: "elem", + elem: arrowBody, + shift: arrowShift, + wrapperClasses: ["svg-align"] + }] + }, options); + } + return makeSpan(["mrel", "x-arrow"], [vlist], options); + }, + mathmlBuilder(group, options) { + const arrowNode = stretchyMathML(group.label); + arrowNode.setAttribute("minsize", group.label.charAt(0) === "x" ? "1.75em" : "3.0em"); + let node; + if (group.body) { + const upperNode = paddedNode(buildMathML_buildGroup(group.body, options)); + if (group.below) { + const lowerNode = paddedNode(buildMathML_buildGroup(group.below, options)); + node = new MathNode("munderover", [arrowNode, lowerNode, upperNode]); + } else { + node = new MathNode("mover", [arrowNode, upperNode]); + } + } else if (group.below) { + const lowerNode = paddedNode(buildMathML_buildGroup(group.below, options)); + node = new MathNode("munder", [arrowNode, lowerNode]); + } else { + // This should never happen. + // Parser.js throws an error if there is no argument. + node = paddedNode(); + node = new MathNode("mover", [arrowNode, node]); + } + return node; + } +}); +;// ./src/functions/mclass.ts + + + + + + +function mclass_htmlBuilder(group, options) { + const elements = buildExpression(group.body, options, true); + return makeSpan([group.mclass], elements, options); +} +function mclass_mathmlBuilder(group, options) { + let node; + const inner = buildMathML_buildExpression(group.body, options); + if (group.mclass === "minner") { + node = new MathNode("mpadded", inner); + } else if (group.mclass === "mord") { + if (group.isCharacterBox) { + node = inner[0]; + node.type = "mi"; + } else { + node = new MathNode("mi", inner); + } + } else { + if (group.isCharacterBox) { + node = inner[0]; + node.type = "mo"; + } else { + node = new MathNode("mo", inner); + } + + // Set spacing based on what is the most likely adjacent atom type. + // See TeXbook p170. + if (group.mclass === "mbin") { + node.attributes.lspace = "0.22em"; // medium space + node.attributes.rspace = "0.22em"; + } else if (group.mclass === "mpunct") { + node.attributes.lspace = "0em"; + node.attributes.rspace = "0.17em"; // thinspace + } else if (group.mclass === "mopen" || group.mclass === "mclose") { + node.attributes.lspace = "0em"; + node.attributes.rspace = "0em"; + } + // MathML default space is 5/18 em, so needs no action. + // Ref: https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mo + } + return node; +} + +// Math class commands except \mathop +defineFunction({ + type: "mclass", + names: ["\\mathord", "\\mathbin", "\\mathrel", "\\mathopen", "\\mathclose", "\\mathpunct", "\\mathinner"], + numArgs: 1, + primitive: true, + handler(_ref, args) { + let { + parser, + funcName + } = _ref; + const body = args[0]; + return { + type: "mclass", + mode: parser.mode, + mclass: "m" + funcName.slice(5), + body: ordargument(body), + isCharacterBox: isCharacterBox(body) + }; + }, + htmlBuilder: mclass_htmlBuilder, + mathmlBuilder: mclass_mathmlBuilder +}); +const binrelClass = arg => { + // \binrel@ spacing varies with (bin|rel|ord) of the atom in the argument. + // (by rendering separately and with {}s before and after, and measuring + // the change in spacing). We'll do roughly the same by detecting the + // atom type directly. + const atom = arg.type === "ordgroup" && arg.body.length ? arg.body[0] : arg; + if (atom.type === "atom" && (atom.family === "bin" || atom.family === "rel")) { + return "m" + atom.family; + } else { + return "mord"; + } +}; + +// \@binrel{x}{y} renders like y but as mbin/mrel/mord if x is mbin/mrel/mord. +// This is equivalent to \binrel@{x}\binrel@@{y} in AMSTeX. +defineFunction({ + type: "mclass", + names: ["\\@binrel"], + numArgs: 2, + handler(_ref2, args) { + let { + parser + } = _ref2; + return { + type: "mclass", + mode: parser.mode, + mclass: binrelClass(args[0]), + body: ordargument(args[1]), + isCharacterBox: isCharacterBox(args[1]) + }; + } +}); + +// Build a relation or stacked op by placing one symbol on top of another +defineFunction({ + type: "mclass", + names: ["\\stackrel", "\\overset", "\\underset"], + numArgs: 2, + handler(_ref3, args) { + let { + parser, + funcName + } = _ref3; + const baseArg = args[1]; + const shiftedArg = args[0]; + let mclass; + if (funcName !== "\\stackrel") { + // LaTeX applies \binrel spacing to \overset and \underset. + mclass = binrelClass(baseArg); + } else { + mclass = "mrel"; // for \stackrel + } + const baseOp = { + type: "op", + mode: baseArg.mode, + limits: true, + alwaysHandleSupSub: true, + parentIsSupSub: false, + symbol: false, + suppressBaseShift: funcName !== "\\stackrel", + body: ordargument(baseArg) + }; + const supsub = funcName === "\\underset" ? { + type: "supsub", + mode: shiftedArg.mode, + base: baseOp, + sub: shiftedArg + } : { + type: "supsub", + mode: shiftedArg.mode, + base: baseOp, + sup: shiftedArg + }; + return { + type: "mclass", + mode: parser.mode, + mclass, + body: [supsub], + isCharacterBox: isCharacterBox(supsub) + }; + } +}); +;// ./src/functions/pmb.ts + + + + + + +// \pmb is a simulation of bold font. +// The version of \pmb in ambsy.sty works by typesetting three copies +// with small offsets. We use CSS text-shadow. +// It's a hack. Not as good as a real bold font. Better than nothing. + +defineFunction({ + type: "pmb", + names: ["\\pmb"], + numArgs: 1, + allowedInText: true, + handler(_ref, args) { + let { + parser + } = _ref; + return { + type: "pmb", + mode: parser.mode, + mclass: binrelClass(args[0]), + body: ordargument(args[0]) + }; + }, + htmlBuilder(group, options) { + const elements = buildExpression(group.body, options, true); + const node = makeSpan([group.mclass], elements, options); + node.style.textShadow = "0.02em 0.01em 0.04px"; + return node; + }, + mathmlBuilder(group, style) { + const inner = buildMathML_buildExpression(group.body, style); + // Wrap with an element. + const node = new MathNode("mstyle", inner); + node.setAttribute("style", "text-shadow: 0.02em 0.01em 0.04px"); + return node; + } +}); +;// ./src/environments/cd.ts + + + + + + + + +const cdArrowFunctionName = { + ">": "\\\\cdrightarrow", + "<": "\\\\cdleftarrow", + "=": "\\\\cdlongequal", + "A": "\\uparrow", + "V": "\\downarrow", + "|": "\\Vert", + ".": "no arrow" +}; +const newCell = () => { + // Create an empty cell, to be filled below with parse nodes. + // The parseTree from this module must be constructed like the + // one created by parseArray(), so an empty CD cell must + // be a ParseNode<"styling">. And CD is always displaystyle. + return { + type: "styling", + body: [], + mode: "math", + style: "display", + resetFont: true + }; +}; +const isStartOfArrow = node => { + return node.type === "textord" && node.text === "@"; +}; +const isLabelEnd = (node, endChar) => { + return (node.type === "mathord" || node.type === "atom") && node.text === endChar; +}; +function cdArrow(arrowChar, labels, parser) { + // Return a parse tree of an arrow and its labels. + // This acts in a way similar to a macro expansion. + const funcName = cdArrowFunctionName[arrowChar]; + switch (funcName) { + case "\\\\cdrightarrow": + case "\\\\cdleftarrow": + return parser.callFunction(funcName, [labels[0]], [labels[1]]); + case "\\uparrow": + case "\\downarrow": + { + const leftLabel = parser.callFunction("\\\\cdleft", [labels[0]], []); + const bareArrow = { + type: "atom", + text: funcName, + mode: "math", + family: "rel" + }; + const sizedArrow = parser.callFunction("\\Big", [bareArrow], []); + const rightLabel = parser.callFunction("\\\\cdright", [labels[1]], []); + const arrowGroup = { + type: "ordgroup", + mode: "math", + body: [leftLabel, sizedArrow, rightLabel] + }; + return parser.callFunction("\\\\cdparent", [arrowGroup], []); + } + case "\\\\cdlongequal": + return parser.callFunction("\\\\cdlongequal", [], []); + case "\\Vert": + { + const arrow = { + type: "textord", + text: "\\Vert", + mode: "math" + }; + return parser.callFunction("\\Big", [arrow], []); + } + default: + return { + type: "textord", + text: " ", + mode: "math" + }; + } +} +function parseCD(parser) { + // Get the array's parse nodes with \\ temporarily mapped to \cr. + const parsedRows = []; + parser.gullet.beginGroup(); + parser.gullet.macros.set("\\cr", "\\\\\\relax"); + parser.gullet.beginGroup(); + while (true) { + // Get the parse nodes for the next row. + parsedRows.push(parser.parseExpression(false, "\\\\")); + parser.gullet.endGroup(); + parser.gullet.beginGroup(); + const next = parser.fetch().text; + if (next === "&" || next === "\\\\") { + parser.consume(); + } else if (next === "\\end") { + if (parsedRows[parsedRows.length - 1].length === 0) { + parsedRows.pop(); // final row ended in \\ + } + break; + } else { + throw new src_ParseError("Expected \\\\ or \\cr or \\end", parser.nextToken); + } + } + let row = []; + const body = [row]; + + // Loop thru the parse nodes. Collect them into cells and arrows. + for (let i = 0; i < parsedRows.length; i++) { + // Start a new row. + const rowNodes = parsedRows[i]; + // Create the first cell. + let cell = newCell(); + for (let j = 0; j < rowNodes.length; j++) { + if (!isStartOfArrow(rowNodes[j])) { + // If a parseNode is not an arrow, it goes into a cell. + cell.body.push(rowNodes[j]); + } else { + // Parse node j is an "@", the start of an arrow. + // Before starting on the arrow, push the cell into `row`. + row.push(cell); + + // Now collect parseNodes into an arrow. + // The character after "@" defines the arrow type. + j += 1; + const arrowChar = assertSymbolNodeType(rowNodes[j]).text; + + // Create two empty label nodes. We may or may not use them. + const labels = new Array(2); + labels[0] = { + type: "ordgroup", + mode: "math", + body: [] + }; + labels[1] = { + type: "ordgroup", + mode: "math", + body: [] + }; + + // Process the arrow. + if ("=|.".includes(arrowChar)) { + // Three "arrows", ``@=`, `@|`, and `@.`, do not take labels. + // Do nothing here. + } else if ("<>AV".includes(arrowChar)) { + // Four arrows, `@>>>`, `@<<<`, `@AAA`, and `@VVV`, each take + // two optional labels. E.g. the right-point arrow syntax is + // really: @>{optional label}>{optional label}> + // Collect parseNodes into labels. + for (let labelNum = 0; labelNum < 2; labelNum++) { + let inLabel = true; + for (let k = j + 1; k < rowNodes.length; k++) { + if (isLabelEnd(rowNodes[k], arrowChar)) { + inLabel = false; + j = k; + break; + } + if (isStartOfArrow(rowNodes[k])) { + throw new src_ParseError("Missing a " + arrowChar + " character to complete a CD arrow.", rowNodes[k]); + } + labels[labelNum].body.push(rowNodes[k]); + } + if (inLabel) { + // isLabelEnd never returned a true. + throw new src_ParseError("Missing a " + arrowChar + " character to complete a CD arrow.", rowNodes[j]); + } + } + } else { + throw new src_ParseError("Expected one of \"<>AV=|.\" after @", rowNodes[j]); + } + + // Now join the arrow to its labels. + const arrow = cdArrow(arrowChar, labels, parser); + + // Wrap the arrow in ParseNode<"styling">. + // This is done to match parseArray() behavior. + const wrappedArrow = { + type: "styling", + body: [arrow], + mode: "math", + style: "display", + // CD is always displaystyle. + resetFont: true + }; + row.push(wrappedArrow); + // In CD's syntax, cells are implicit. That is, everything that + // is not an arrow gets collected into a cell. So create an empty + // cell now. It will collect upcoming parseNodes. + cell = newCell(); + } + } + if (i % 2 === 0) { + // Even-numbered rows consist of: cell, arrow, cell, arrow, ... cell + // The last cell is not yet pushed into `row`, so: + row.push(cell); + } else { + // Odd-numbered rows consist of: vert arrow, empty cell, ... vert arrow + // Remove the empty cell that was placed at the beginning of `row`. + row.shift(); + } + row = []; + body.push(row); + } + + // End row group + parser.gullet.endGroup(); + // End array group defining \\ + parser.gullet.endGroup(); + + // define column separation. + const cols = new Array(body[0].length).fill({ + type: "align", + align: "c", + pregap: 0.25, + // CD package sets \enskip between columns. + postgap: 0.25 // So pre and post each get half an \enskip, i.e. 0.25em. + }); + return { + type: "array", + mode: "math", + body, + arraystretch: 1, + addJot: true, + rowGaps: [null], + cols, + colSeparationType: "CD", + hLinesBeforeRow: new Array(body.length + 1).fill([]) + }; +} + +// The functions below are not available for general use. +// They are here only for internal use by the {CD} environment in placing labels +// next to vertical arrows. + +// We don't need any such functions for horizontal arrows because we can reuse +// the functionality that already exists for extensible arrows. + +defineFunction({ + type: "cdlabel", + names: ["\\\\cdleft", "\\\\cdright"], + numArgs: 1, + handler(_ref, args) { + let { + parser, + funcName + } = _ref; + return { + type: "cdlabel", + mode: parser.mode, + side: funcName.slice(4), + label: args[0] + }; + }, + htmlBuilder(group, options) { + const newOptions = options.havingStyle(options.style.sup()); + const label = wrapFragment(buildGroup(group.label, newOptions, options), options); + label.classes.push("cd-label-" + group.side); + label.style.bottom = makeEm(0.8 - label.depth); + // Zero out label height & depth, so vertical align of arrow is set + // by the arrow height, not by the label. + label.height = 0; + label.depth = 0; + return label; + }, + mathmlBuilder(group, options) { + let label = new MathNode("mrow", [buildMathML_buildGroup(group.label, options)]); + label = new MathNode("mpadded", [label]); + label.setAttribute("width", "0"); + if (group.side === "left") { + label.setAttribute("lspace", "-1width"); + } + // We have to guess at vertical alignment. We know the arrow is 1.8em tall, + // But we don't know the height or depth of the label. + label.setAttribute("voffset", "0.7em"); + label = new MathNode("mstyle", [label]); + label.setAttribute("displaystyle", "false"); + label.setAttribute("scriptlevel", "1"); + return label; + } +}); +defineFunction({ + type: "cdlabelparent", + names: ["\\\\cdparent"], + numArgs: 1, + handler(_ref2, args) { + let { + parser + } = _ref2; + return { + type: "cdlabelparent", + mode: parser.mode, + fragment: args[0] + }; + }, + htmlBuilder(group, options) { + // Wrap the vertical arrow and its labels. + // The parent gets position: relative. The child gets position: absolute. + // So CSS can locate the label correctly. + const parent = wrapFragment(buildGroup(group.fragment, options), options); + parent.classes.push("cd-vert-arrow"); + return parent; + }, + mathmlBuilder(group, options) { + return new MathNode("mrow", [buildMathML_buildGroup(group.fragment, options)]); + } +}); +;// ./src/functions/char.ts + + + + +// \@char is an internal function that takes a grouped decimal argument like +// {123} and converts into symbol with code 123. It is used by the *macro* +// \char defined in macros.js. +defineFunction({ + type: "textord", + names: ["\\@char"], + numArgs: 1, + allowedInText: true, + handler(_ref, args) { + let { + parser + } = _ref; + const arg = assertNodeType(args[0], "ordgroup"); + const group = arg.body; + let number = ""; + for (let i = 0; i < group.length; i++) { + const node = assertNodeType(group[i], "textord"); + number += node.text; + } + let code = parseInt(number); + let text; + if (isNaN(code)) { + throw new src_ParseError("\\@char has non-numeric argument " + number); + // If we drop IE support, the following code could be replaced with + // text = String.fromCodePoint(code) + } else if (code < 0 || code >= 0x10ffff) { + throw new src_ParseError("\\@char with invalid code point " + number); + } else if (code <= 0xffff) { + text = String.fromCharCode(code); + } else { + // Astral code point; split into surrogate halves + code -= 0x10000; + text = String.fromCharCode((code >> 10) + 0xd800, (code & 0x3ff) + 0xdc00); + } + return { + type: "textord", + mode: parser.mode, + text: text + }; + } +}); +;// ./src/functions/color.ts + + + + + + +const color_htmlBuilder = (group, options) => { + const elements = buildExpression(group.body, options.withColor(group.color), false); + + // \color isn't supposed to affect the type of the elements it contains. + // To accomplish this, we wrap the results in a fragment, so the inner + // elements will be able to directly interact with their neighbors. For + // example, `\color{red}{2 +} 3` has the same spacing as `2 + 3` + return makeFragment(elements); +}; +const color_mathmlBuilder = (group, options) => { + const inner = buildMathML_buildExpression(group.body, options.withColor(group.color)); + const node = new MathNode("mstyle", inner); + node.setAttribute("mathcolor", group.color); + return node; +}; +defineFunction({ + type: "color", + names: ["\\textcolor"], + numArgs: 2, + allowedInText: true, + argTypes: ["color", "original"], + handler(_ref, args) { + let { + parser + } = _ref; + const color = assertNodeType(args[0], "color-token").color; + const body = args[1]; + return { + type: "color", + mode: parser.mode, + color, + body: ordargument(body) + }; + }, + htmlBuilder: color_htmlBuilder, + mathmlBuilder: color_mathmlBuilder +}); +defineFunction({ + type: "color", + names: ["\\color"], + numArgs: 1, + allowedInText: true, + argTypes: ["color"], + handler(_ref2, args) { + let { + parser, + breakOnTokenText + } = _ref2; + const color = assertNodeType(args[0], "color-token").color; + + // Set macro \current@color in current namespace to store the current + // color, mimicking the behavior of color.sty. + // This is currently used just to correctly color a \right + // that follows a \color command. + parser.gullet.macros.set("\\current@color", color); + + // Parse out the implicit body that should be colored. + const body = parser.parseExpression(true, breakOnTokenText); + return { + type: "color", + mode: parser.mode, + color, + body + }; + } +}); +;// ./src/functions/cr.ts +// Row breaks within tabular environments, and line breaks at top level + + + + + + + +// \DeclareRobustCommand\\{...\@xnewline} +defineFunction({ + type: "cr", + names: ["\\\\"], + numArgs: 0, + numOptionalArgs: 0, + allowedInText: true, + handler(_ref, args, optArgs) { + let { + parser + } = _ref; + const size = parser.gullet.future().text === "[" ? parser.parseSizeGroup(true) : null; + const newLine = !parser.settings.displayMode || !parser.settings.useStrictBehavior("newLineInDisplayMode", "In LaTeX, \\\\ or \\newline " + "does nothing in display mode"); + return { + type: "cr", + mode: parser.mode, + newLine, + size: size && assertNodeType(size, "size").value + }; + }, + // The following builders are called only at the top level, + // not within tabular/array environments. + + htmlBuilder(group, options) { + const span = makeSpan(["mspace"], [], options); + if (group.newLine) { + span.classes.push("newline"); + if (group.size) { + span.style.marginTop = makeEm(calculateSize(group.size, options)); + } + } + return span; + }, + mathmlBuilder(group, options) { + const node = new MathNode("mspace"); + if (group.newLine) { + node.setAttribute("linebreak", "newline"); + if (group.size) { + node.setAttribute("height", makeEm(calculateSize(group.size, options))); + } + } + return node; + } +}); +;// ./src/functions/def.ts + + + +const globalMap = { + "\\global": "\\global", + "\\long": "\\\\globallong", + "\\\\globallong": "\\\\globallong", + "\\def": "\\gdef", + "\\gdef": "\\gdef", + "\\edef": "\\xdef", + "\\xdef": "\\xdef", + "\\let": "\\\\globallet", + "\\futurelet": "\\\\globalfuture" +}; +const checkControlSequence = tok => { + const name = tok.text; + if (/^(?:[\\{}$&#^_]|EOF)$/.test(name)) { + throw new src_ParseError("Expected a control sequence", tok); + } + return name; +}; +const getRHS = parser => { + let tok = parser.gullet.popToken(); + if (tok.text === "=") { + // consume optional equals + tok = parser.gullet.popToken(); + if (tok.text === " ") { + // consume one optional space + tok = parser.gullet.popToken(); + } + } + return tok; +}; +const letCommand = (parser, name, tok, global) => { + let macro = parser.gullet.macros.get(tok.text); + if (macro == null) { + // don't expand it later even if a macro with the same name is defined + // e.g., \let\foo=\frac \def\frac{\relax} \frac12 + tok.noexpand = true; + macro = { + tokens: [tok], + numArgs: 0, + // reproduce the same behavior in expansion + unexpandable: !parser.gullet.isExpandable(tok.text) + }; + } + parser.gullet.macros.set(name, macro, global); +}; + +// -> | +// -> |\global +// -> | +// -> \global|\long|\outer +defineFunction({ + type: "internal", + names: ["\\global", "\\long", "\\\\globallong" // can’t be entered directly + ], + numArgs: 0, + allowedInText: true, + handler(_ref) { + let { + parser, + funcName + } = _ref; + parser.consumeSpaces(); + const token = parser.fetch(); + if (globalMap[token.text]) { + // KaTeX doesn't have \par, so ignore \long + if (funcName === "\\global" || funcName === "\\\\globallong") { + token.text = globalMap[token.text]; + } + return assertNodeType(parser.parseFunction(), "internal"); + } + throw new src_ParseError("Invalid token after macro prefix", token); + } +}); + +// Basic support for macro definitions: \def, \gdef, \edef, \xdef +// -> +// -> \def|\gdef|\edef|\xdef +// -> +defineFunction({ + type: "internal", + names: ["\\def", "\\gdef", "\\edef", "\\xdef"], + numArgs: 0, + allowedInText: true, + primitive: true, + handler(_ref2) { + let { + parser, + funcName + } = _ref2; + let tok = parser.gullet.popToken(); + const name = tok.text; + if (/^(?:[\\{}$&#^_]|EOF)$/.test(name)) { + throw new src_ParseError("Expected a control sequence", tok); + } + let numArgs = 0; + let insert; + const delimiters = [[]]; + // contains no braces + while (parser.gullet.future().text !== "{") { + tok = parser.gullet.popToken(); + if (tok.text === "#") { + // If the very last character of the is #, so that + // this # is immediately followed by {, TeX will behave as if the { + // had been inserted at the right end of both the parameter text + // and the replacement text. + if (parser.gullet.future().text === "{") { + insert = parser.gullet.future(); + delimiters[numArgs].push("{"); + break; + } + + // A parameter, the first appearance of # must be followed by 1, + // the next by 2, and so on; up to nine #’s are allowed + tok = parser.gullet.popToken(); + if (!/^[1-9]$/.test(tok.text)) { + throw new src_ParseError("Invalid argument number \"" + tok.text + "\""); + } + if (parseInt(tok.text) !== numArgs + 1) { + throw new src_ParseError("Argument number \"" + tok.text + "\" out of order"); + } + numArgs++; + delimiters.push([]); + } else if (tok.text === "EOF") { + throw new src_ParseError("Expected a macro definition"); + } else { + delimiters[numArgs].push(tok.text); + } + } + // replacement text, enclosed in '{' and '}' and properly nested + let { + tokens + } = parser.gullet.consumeArg(); + if (insert) { + tokens.unshift(insert); + } + if (funcName === "\\edef" || funcName === "\\xdef") { + tokens = parser.gullet.expandTokens(tokens); + tokens.reverse(); // to fit in with stack order + } + // Final arg is the expansion of the macro + parser.gullet.macros.set(name, { + tokens, + numArgs, + delimiters + }, funcName === globalMap[funcName]); + return { + type: "internal", + mode: parser.mode + }; + } +}); + +// -> +// -> \futurelet +// | \let +// -> |= +defineFunction({ + type: "internal", + names: ["\\let", "\\\\globallet" // can’t be entered directly + ], + numArgs: 0, + allowedInText: true, + primitive: true, + handler(_ref3) { + let { + parser, + funcName + } = _ref3; + const name = checkControlSequence(parser.gullet.popToken()); + parser.gullet.consumeSpaces(); + const tok = getRHS(parser); + letCommand(parser, name, tok, funcName === "\\\\globallet"); + return { + type: "internal", + mode: parser.mode + }; + } +}); + +// ref: https://www.tug.org/TUGboat/tb09-3/tb22bechtolsheim.pdf +defineFunction({ + type: "internal", + names: ["\\futurelet", "\\\\globalfuture" // can’t be entered directly + ], + numArgs: 0, + allowedInText: true, + primitive: true, + handler(_ref4) { + let { + parser, + funcName + } = _ref4; + const name = checkControlSequence(parser.gullet.popToken()); + const middle = parser.gullet.popToken(); + const tok = parser.gullet.popToken(); + letCommand(parser, name, tok, funcName === "\\\\globalfuture"); + parser.gullet.pushToken(tok); + parser.gullet.pushToken(middle); + return { + type: "internal", + mode: parser.mode + }; + } +}); +;// ./src/delimiter.ts +/** + * This file 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`. + */ + + + + + + + + + + +/** + * Get the metrics for a given symbol and font, after transformation (i.e. + * after following replacement from symbols.js) + */ +const getMetrics = function (symbol, font, mode) { + const replace = src_symbols.math[symbol] && src_symbols.math[symbol].replace; + const metrics = getCharacterMetrics(replace || symbol, font, mode); + if (!metrics) { + throw new Error("Unsupported symbol " + symbol + " and font size " + font + "."); + } + return metrics; +}; + +/** + * Puts a delimiter span in a given style, and adds appropriate height, depth, + * and maxFontSizes. + */ +const styleWrap = function (delim, toStyle, options, classes) { + const newOptions = options.havingBaseStyle(toStyle); + const span = makeSpan(classes.concat(newOptions.sizingClasses(options)), [delim], options); + const delimSizeMultiplier = newOptions.sizeMultiplier / options.sizeMultiplier; + span.height *= delimSizeMultiplier; + span.depth *= delimSizeMultiplier; + span.maxFontSize = newOptions.sizeMultiplier; + return span; +}; +const centerSpan = function (span, options, style) { + const newOptions = options.havingBaseStyle(style); + const shift = (1 - options.sizeMultiplier / newOptions.sizeMultiplier) * options.fontMetrics().axisHeight; + span.classes.push("delimcenter"); + span.style.top = makeEm(shift); + span.height -= shift; + span.depth += shift; +}; + +/** + * 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. + */ +const makeSmallDelim = function (delim, style, center, options, mode, classes) { + const text = makeSymbol(delim, "Main-Regular", mode, options); + const span = styleWrap(text, style, options, classes); + if (center) { + centerSpan(span, options, style); + } + return span; +}; + +/** + * Builds a symbol in the given font size (note size is an integer) + */ +const mathrmSize = function (value, size, mode, options) { + return makeSymbol(value, "Size" + size + "-Regular", mode, options); +}; + +/** + * Makes a large delimiter. This is a delimiter that comes in the Size1, Size2, + * Size3, or Size4 fonts. It is always rendered in textstyle. + */ +const makeLargeDelim = function (delim, size, center, options, mode, classes) { + const inner = mathrmSize(delim, size, mode, options); + const span = styleWrap(makeSpan(["delimsizing", "size" + size], [inner], options), src_Style.TEXT, options, classes); + if (center) { + centerSpan(span, options, src_Style.TEXT); + } + return span; +}; + +/** + * Make a span from a font glyph with the given offset and in the given font. + * This is used in makeStackedDelim to make the stacking pieces for the delimiter. + */ +const makeGlyphSpan = function (symbol, font, mode) { + let sizeClass; + // Apply the correct CSS class to choose the right font. + if (font === "Size1-Regular") { + sizeClass = "delim-size1"; + } else /* if (font === "Size4-Regular") */{ + sizeClass = "delim-size4"; + } + const corner = makeSpan(["delimsizinginner", sizeClass], [makeSpan([], [makeSymbol(symbol, font, mode)])]); + + // Since this will be passed into `makeVList` in the end, wrap the element + // in the appropriate tag that VList uses. + return { + type: "elem", + elem: corner + }; +}; +const makeInner = function (ch, height, options) { + // Create a span with inline SVG for the inner part of a tall stacked delimiter. + const width = fontMetricsData['Size4-Regular'][ch.charCodeAt(0)] ? fontMetricsData['Size4-Regular'][ch.charCodeAt(0)][4] : fontMetricsData['Size1-Regular'][ch.charCodeAt(0)][4]; + const path = new PathNode("inner", innerPath(ch, Math.round(1000 * height))); + const svgNode = new SvgNode([path], { + "width": makeEm(width), + "height": makeEm(height), + // Override CSS rule `.katex svg { width: 100% }` + "style": "width:" + makeEm(width), + "viewBox": "0 0 " + 1000 * width + " " + Math.round(1000 * height), + "preserveAspectRatio": "xMinYMin" + }); + const span = makeSvgSpan([], [svgNode], options); + span.height = height; + span.style.height = makeEm(height); + span.style.width = makeEm(width); + return { + type: "elem", + elem: span + }; +}; + +// Helpers for makeStackedDelim +const lapInEms = 0.008; +const lap = { + type: "kern", + size: -1 * lapInEms +}; +const verts = new Set(["|", "\\lvert", "\\rvert", "\\vert"]); +const doubleVerts = new Set(["\\|", "\\lVert", "\\rVert", "\\Vert"]); + +/** + * Make a stacked delimiter out of a given delimiter, with the total height at + * least `heightTotal`. This routine is mentioned on page 442 of the TeXbook. + */ +const makeStackedDelim = function (delim, heightTotal, center, options, mode, classes) { + // There are four parts, the top, an optional middle, a repeated part, and a + // bottom. + let top; + let middle; + let repeat; + let bottom; + let svgLabel = ""; + let viewBoxWidth = 0; + top = repeat = bottom = delim; + middle = null; + // Also keep track of what font the delimiters are in + let font = "Size1-Regular"; + + // We set the parts and font based on the symbol. Note that we use + // '\u23d0' instead of '|' and '\u2016' instead of '\\|' for the + // repeats of the arrows + if (delim === "\\uparrow") { + repeat = bottom = "\u23d0"; + } else if (delim === "\\Uparrow") { + repeat = bottom = "\u2016"; + } else if (delim === "\\downarrow") { + top = repeat = "\u23d0"; + } else if (delim === "\\Downarrow") { + top = repeat = "\u2016"; + } else if (delim === "\\updownarrow") { + top = "\\uparrow"; + repeat = "\u23d0"; + bottom = "\\downarrow"; + } else if (delim === "\\Updownarrow") { + top = "\\Uparrow"; + repeat = "\u2016"; + bottom = "\\Downarrow"; + } else if (verts.has(delim)) { + repeat = "\u2223"; + svgLabel = "vert"; + viewBoxWidth = 333; + } else if (doubleVerts.has(delim)) { + repeat = "\u2225"; + svgLabel = "doublevert"; + viewBoxWidth = 556; + } else if (delim === "[" || delim === "\\lbrack") { + top = "\u23a1"; + repeat = "\u23a2"; + bottom = "\u23a3"; + font = "Size4-Regular"; + svgLabel = "lbrack"; + viewBoxWidth = 667; + } else if (delim === "]" || delim === "\\rbrack") { + top = "\u23a4"; + repeat = "\u23a5"; + bottom = "\u23a6"; + font = "Size4-Regular"; + svgLabel = "rbrack"; + viewBoxWidth = 667; + } else if (delim === "\\lfloor" || delim === "\u230a") { + repeat = top = "\u23a2"; + bottom = "\u23a3"; + font = "Size4-Regular"; + svgLabel = "lfloor"; + viewBoxWidth = 667; + } else if (delim === "\\lceil" || delim === "\u2308") { + top = "\u23a1"; + repeat = bottom = "\u23a2"; + font = "Size4-Regular"; + svgLabel = "lceil"; + viewBoxWidth = 667; + } else if (delim === "\\rfloor" || delim === "\u230b") { + repeat = top = "\u23a5"; + bottom = "\u23a6"; + font = "Size4-Regular"; + svgLabel = "rfloor"; + viewBoxWidth = 667; + } else if (delim === "\\rceil" || delim === "\u2309") { + top = "\u23a4"; + repeat = bottom = "\u23a5"; + font = "Size4-Regular"; + svgLabel = "rceil"; + viewBoxWidth = 667; + } else if (delim === "(" || delim === "\\lparen") { + top = "\u239b"; + repeat = "\u239c"; + bottom = "\u239d"; + font = "Size4-Regular"; + svgLabel = "lparen"; + viewBoxWidth = 875; + } else if (delim === ")" || delim === "\\rparen") { + top = "\u239e"; + repeat = "\u239f"; + bottom = "\u23a0"; + font = "Size4-Regular"; + svgLabel = "rparen"; + viewBoxWidth = 875; + } else if (delim === "\\{" || delim === "\\lbrace") { + top = "\u23a7"; + middle = "\u23a8"; + bottom = "\u23a9"; + repeat = "\u23aa"; + font = "Size4-Regular"; + } else if (delim === "\\}" || delim === "\\rbrace") { + top = "\u23ab"; + middle = "\u23ac"; + bottom = "\u23ad"; + repeat = "\u23aa"; + font = "Size4-Regular"; + } else if (delim === "\\lgroup" || delim === "\u27ee") { + top = "\u23a7"; + bottom = "\u23a9"; + repeat = "\u23aa"; + font = "Size4-Regular"; + } else if (delim === "\\rgroup" || delim === "\u27ef") { + top = "\u23ab"; + bottom = "\u23ad"; + repeat = "\u23aa"; + font = "Size4-Regular"; + } else if (delim === "\\lmoustache" || delim === "\u23b0") { + top = "\u23a7"; + bottom = "\u23ad"; + repeat = "\u23aa"; + font = "Size4-Regular"; + } else if (delim === "\\rmoustache" || delim === "\u23b1") { + top = "\u23ab"; + bottom = "\u23a9"; + repeat = "\u23aa"; + font = "Size4-Regular"; + } + + // Get the metrics of the four sections + const topMetrics = getMetrics(top, font, mode); + const topHeightTotal = topMetrics.height + topMetrics.depth; + const repeatMetrics = getMetrics(repeat, font, mode); + const repeatHeightTotal = repeatMetrics.height + repeatMetrics.depth; + const bottomMetrics = getMetrics(bottom, font, mode); + const bottomHeightTotal = bottomMetrics.height + bottomMetrics.depth; + let middleHeightTotal = 0; + let middleFactor = 1; + if (middle !== null) { + const middleMetrics = getMetrics(middle, font, mode); + middleHeightTotal = middleMetrics.height + middleMetrics.depth; + middleFactor = 2; // repeat symmetrically above and below middle + } + + // Calculate the minimal height that the delimiter can have. + // It is at least the size of the top, bottom, and optional middle combined. + const minHeight = topHeightTotal + bottomHeightTotal + middleHeightTotal; + + // Compute the number of copies of the repeat symbol we will need + const repeatCount = Math.max(0, Math.ceil((heightTotal - minHeight) / (middleFactor * repeatHeightTotal))); + + // Compute the total height of the delimiter including all the symbols + const realHeightTotal = minHeight + repeatCount * middleFactor * repeatHeightTotal; + + // The center of the delimiter is placed at the center of the axis. Note + // that in this context, "center" means that the delimiter should be + // centered around the axis in the current style, while normally it is + // centered around the axis in textstyle. + let axisHeight = options.fontMetrics().axisHeight; + if (center) { + axisHeight *= options.sizeMultiplier; + } + // Calculate the depth + const depth = realHeightTotal / 2 - axisHeight; + + // Now, we start building the pieces that will go into the vlist + // Keep a list of the pieces of the stacked delimiter + const stack = []; + if (svgLabel.length > 0) { + // Instead of stacking glyphs, create a single SVG. + // This evades browser problems with imprecise positioning of spans. + const midHeight = realHeightTotal - topHeightTotal - bottomHeightTotal; + const viewBoxHeight = Math.round(realHeightTotal * 1000); + const pathStr = tallDelim(svgLabel, Math.round(midHeight * 1000)); + const path = new PathNode(svgLabel, pathStr); + const width = makeEm(viewBoxWidth / 1000); + const height = makeEm(viewBoxHeight / 1000); + const svg = new SvgNode([path], { + "width": width, + "height": height, + "viewBox": "0 0 " + viewBoxWidth + " " + viewBoxHeight + }); + const wrapper = makeSvgSpan([], [svg], options); + wrapper.height = viewBoxHeight / 1000; + wrapper.style.width = width; + wrapper.style.height = height; + stack.push({ + type: "elem", + elem: wrapper + }); + } else { + // Stack glyphs + // Start by adding the bottom symbol + stack.push(makeGlyphSpan(bottom, font, mode)); + stack.push(lap); // overlap + + if (middle === null) { + // The middle section will be an SVG. Make it an extra 0.016em tall. + // We'll overlap by 0.008em at top and bottom. + const innerHeight = realHeightTotal - topHeightTotal - bottomHeightTotal + 2 * lapInEms; + stack.push(makeInner(repeat, innerHeight, options)); + } else { + // When there is a middle bit, we need the middle part and two repeated + // sections + const innerHeight = (realHeightTotal - topHeightTotal - bottomHeightTotal - middleHeightTotal) / 2 + 2 * lapInEms; + stack.push(makeInner(repeat, innerHeight, options)); + // Now insert the middle of the brace. + stack.push(lap); + stack.push(makeGlyphSpan(middle, font, mode)); + stack.push(lap); + stack.push(makeInner(repeat, innerHeight, options)); + } + + // Add the top symbol + stack.push(lap); + stack.push(makeGlyphSpan(top, font, mode)); + } + + // Finally, build the vlist + const newOptions = options.havingBaseStyle(src_Style.TEXT); + const inner = makeVList({ + positionType: "bottom", + positionData: depth, + children: stack + }, newOptions); + return styleWrap(makeSpan(["delimsizing", "mult"], [inner], newOptions), src_Style.TEXT, options, classes); +}; + +// All surds have 0.08em padding above the vinculum inside the SVG. +// That keeps browser span height rounding error from pinching the line. +const vbPad = 80; // padding above the surd, measured inside the viewBox. +const emPad = 0.08; // padding, in ems, measured in the document. + +const sqrtSvg = function (sqrtName, height, viewBoxHeight, extraVinculum, options) { + const path = sqrtPath(sqrtName, extraVinculum, viewBoxHeight); + const pathNode = new PathNode(sqrtName, path); + const svg = new SvgNode([pathNode], { + // Note: 1000:1 ratio of viewBox to document em width. + "width": "400em", + "height": makeEm(height), + "viewBox": "0 0 400000 " + viewBoxHeight, + "preserveAspectRatio": "xMinYMin slice" + }); + return makeSvgSpan(["hide-tail"], [svg], options); +}; + +/** + * Make a sqrt image of the given height, + */ +const makeSqrtImage = function (height, options) { + // Define a newOptions that removes the effect of size changes such as \Huge. + // We don't pick different a height surd for \Huge. For it, we scale up. + const newOptions = options.havingBaseSizing(); + + // Pick the desired surd glyph from a sequence of surds. + const delim = traverseSequence("\\surd", height * newOptions.sizeMultiplier, stackLargeDelimiterSequence, newOptions); + let sizeMultiplier = newOptions.sizeMultiplier; // default + + // The standard sqrt SVGs each have a 0.04em thick vinculum. + // If Settings.minRuleThickness is larger than that, we add extraVinculum. + const extraVinculum = Math.max(0, options.minRuleThickness - options.fontMetrics().sqrtRuleThickness); + + // Create a span containing an SVG image of a sqrt symbol. + let span; + let spanHeight; + let texHeight; + let viewBoxHeight; + let advanceWidth; + + // We create viewBoxes with 80 units of "padding" above each surd. + // Then browser rounding error on the parent span height will not + // encroach on the ink of the vinculum. But that padding is not + // included in the TeX-like `height` used for calculation of + // vertical alignment. So texHeight = span.height < span.style.height. + + if (delim.type === "small") { + // Get an SVG that is derived from glyph U+221A in font KaTeX-Main. + // 1000 unit normal glyph height. + viewBoxHeight = 1000 + 1000 * extraVinculum + vbPad; + if (height < 1.0) { + sizeMultiplier = 1.0; // mimic a \textfont radical + } else if (height < 1.4) { + sizeMultiplier = 0.7; // mimic a \scriptfont radical + } + spanHeight = (1.0 + extraVinculum + emPad) / sizeMultiplier; + texHeight = (1.00 + extraVinculum) / sizeMultiplier; + span = sqrtSvg("sqrtMain", spanHeight, viewBoxHeight, extraVinculum, options); + span.style.minWidth = "0.853em"; + advanceWidth = 0.833 / sizeMultiplier; // from the font. + } else if (delim.type === "large") { + // These SVGs come from fonts: KaTeX_Size1, _Size2, etc. + viewBoxHeight = (1000 + vbPad) * sizeToMaxHeight[delim.size]; + texHeight = (sizeToMaxHeight[delim.size] + extraVinculum) / sizeMultiplier; + spanHeight = (sizeToMaxHeight[delim.size] + extraVinculum + emPad) / sizeMultiplier; + span = sqrtSvg("sqrtSize" + delim.size, spanHeight, viewBoxHeight, extraVinculum, options); + span.style.minWidth = "1.02em"; + advanceWidth = 1.0 / sizeMultiplier; // 1.0 from the font. + } else { + // Tall sqrt. In TeX, this would be stacked using multiple glyphs. + // We'll use a single SVG to accomplish the same thing. + spanHeight = height + extraVinculum + emPad; + texHeight = height + extraVinculum; + viewBoxHeight = Math.floor(1000 * height + extraVinculum) + vbPad; + span = sqrtSvg("sqrtTall", spanHeight, viewBoxHeight, extraVinculum, options); + span.style.minWidth = "0.742em"; + advanceWidth = 1.056; + } + span.height = texHeight; + span.style.height = makeEm(spanHeight); + return { + span, + advanceWidth, + // Calculate the actual line width. + // This actually should depend on the chosen font -- e.g. \boldmath + // should use the thicker surd symbols from e.g. KaTeX_Main-Bold, and + // have thicker rules. + ruleWidth: (options.fontMetrics().sqrtRuleThickness + extraVinculum) * sizeMultiplier + }; +}; + +// There are three kinds of delimiters, delimiters that stack when they become +// too large +const stackLargeDelimiters = new Set(["(", "\\lparen", ")", "\\rparen", "[", "\\lbrack", "]", "\\rbrack", "\\{", "\\lbrace", "\\}", "\\rbrace", "\\lfloor", "\\rfloor", "\u230a", "\u230b", "\\lceil", "\\rceil", "\u2308", "\u2309", "\\surd"]); + +// delimiters that always stack +const stackAlwaysDelimiters = new Set(["\\uparrow", "\\downarrow", "\\updownarrow", "\\Uparrow", "\\Downarrow", "\\Updownarrow", "|", "\\|", "\\vert", "\\Vert", "\\lvert", "\\rvert", "\\lVert", "\\rVert", "\\lgroup", "\\rgroup", "\u27ee", "\u27ef", "\\lmoustache", "\\rmoustache", "\u23b0", "\u23b1"]); + +// and delimiters that never stack +const stackNeverDelimiters = new Set(["<", ">", "\\langle", "\\rangle", "/", "\\backslash", "\\lt", "\\gt"]); + +// Metrics of the different sizes. Found by looking at TeX's output of +// $\bigl| // \Bigl| \biggl| \Biggl| \showlists$ +// Used to create stacked delimiters of appropriate sizes in makeSizedDelim. +const sizeToMaxHeight = [0, 1.2, 1.8, 2.4, 3.0]; + +/** + * Used to create a delimiter of a specific size, where `size` is 1, 2, 3, or 4. + */ +const makeSizedDelim = function (delim, size, options, mode, classes) { + // < and > turn into \langle and \rangle in delimiters + if (delim === "<" || delim === "\\lt" || delim === "\u27e8") { + delim = "\\langle"; + } else if (delim === ">" || delim === "\\gt" || delim === "\u27e9") { + delim = "\\rangle"; + } + + // Sized delimiters are never centered. + if (stackLargeDelimiters.has(delim) || stackNeverDelimiters.has(delim)) { + return makeLargeDelim(delim, size, false, options, mode, classes); + } else if (stackAlwaysDelimiters.has(delim)) { + return makeStackedDelim(delim, sizeToMaxHeight[size], false, options, mode, classes); + } else { + throw new src_ParseError("Illegal delimiter: '" + delim + "'"); + } +}; + +/** + * There are three different sequences of delimiter sizes that the delimiters + * follow depending on the kind of delimiter. This is used when creating custom + * sized delimiters to decide whether to create a small, large, or stacked + * delimiter. + * + * In real TeX, these sequences aren't explicitly defined, but are instead + * defined inside the font metrics. Since there are only three sequences that + * are possible for the delimiters that TeX defines, it is easier to just encode + * them explicitly here. + */ + +// Delimiters that never stack try small delimiters and large delimiters only +const stackNeverDelimiterSequence = [{ + type: "small", + style: src_Style.SCRIPTSCRIPT +}, { + type: "small", + style: src_Style.SCRIPT +}, { + type: "small", + style: src_Style.TEXT +}, { + type: "large", + size: 1 +}, { + type: "large", + size: 2 +}, { + type: "large", + size: 3 +}, { + type: "large", + size: 4 +}]; + +// Delimiters that always stack try the small delimiters first, then stack +const stackAlwaysDelimiterSequence = [{ + type: "small", + style: src_Style.SCRIPTSCRIPT +}, { + type: "small", + style: src_Style.SCRIPT +}, { + type: "small", + style: src_Style.TEXT +}, { + type: "stack" +}]; + +// Delimiters that stack when large try the small and then large delimiters, and +// stack afterwards +const stackLargeDelimiterSequence = [{ + type: "small", + style: src_Style.SCRIPTSCRIPT +}, { + type: "small", + style: src_Style.SCRIPT +}, { + type: "small", + style: src_Style.TEXT +}, { + type: "large", + size: 1 +}, { + type: "large", + size: 2 +}, { + type: "large", + size: 3 +}, { + type: "large", + size: 4 +}, { + type: "stack" +}]; + +/** + * Get the font used in a delimiter based on what kind of delimiter it is. + * TODO(#963) Use more specific font family return type once that is introduced. + */ +const delimTypeToFont = function (type) { + if (type.type === "small") { + return "Main-Regular"; + } else if (type.type === "large") { + return "Size" + type.size + "-Regular"; + } else if (type.type === "stack") { + return "Size4-Regular"; + } else { + const delimKind = type.type; + throw new Error("Add support for delim type '" + delimKind + "' here."); + } +}; + +/** + * Traverse a sequence of types of delimiters to decide what kind of delimiter + * should be used to create a delimiter of the given height+depth. + */ +const traverseSequence = function (delim, height, sequence, options) { + // Here, we choose the index we should start at in the sequences. In smaller + // sizes (which correspond to larger numbers in style.size) we start earlier + // in the sequence. Thus, scriptscript starts at index 3-3=0, script starts + // at index 3-2=1, text starts at 3-1=2, and display starts at min(2,3-0)=2 + const start = Math.min(2, 3 - options.style.size); + for (let i = start; i < sequence.length; i++) { + const delimType = sequence[i]; + if (delimType.type === "stack") { + // This is always the last delimiter, so we just break the loop now. + break; + } + const metrics = getMetrics(delim, delimTypeToFont(delimType), "math"); + let heightDepth = metrics.height + metrics.depth; + + // Small delimiters are scaled down versions of the same font, so we + // account for the style change size. + if (delimType.type === "small") { + const newOptions = options.havingBaseStyle(delimType.style); + heightDepth *= newOptions.sizeMultiplier; + } + + // Check if the delimiter at this size works for the given height. + if (heightDepth > height) { + return delimType; + } + } + + // If we reached the end of the sequence, return the last sequence element. + return sequence[sequence.length - 1]; +}; + +/** + * Make a delimiter of a given height+depth, with optional centering. Here, we + * traverse the sequences, and create a delimiter that the sequence tells us to. + */ +const makeCustomSizedDelim = function (delim, height, center, options, mode, classes) { + if (delim === "<" || delim === "\\lt" || delim === "\u27e8") { + delim = "\\langle"; + } else if (delim === ">" || delim === "\\gt" || delim === "\u27e9") { + delim = "\\rangle"; + } + + // Decide what sequence to use + let sequence; + if (stackNeverDelimiters.has(delim)) { + sequence = stackNeverDelimiterSequence; + } else if (stackLargeDelimiters.has(delim)) { + sequence = stackLargeDelimiterSequence; + } else { + sequence = stackAlwaysDelimiterSequence; + } + + // Look through the sequence + const delimType = traverseSequence(delim, height, sequence, options); + + // Get the delimiter from font glyphs. + // Depending on the sequence element we decided on, call the + // appropriate function. + if (delimType.type === "small") { + return makeSmallDelim(delim, delimType.style, center, options, mode, classes); + } else if (delimType.type === "large") { + return makeLargeDelim(delim, delimType.size, center, options, mode, classes); + } else /* if (delimType.type === "stack") */{ + return makeStackedDelim(delim, height, center, options, mode, classes); + } +}; + +/** + * Make a delimiter for use with `\left` and `\right`, given a height and depth + * of an expression that the delimiters surround. + */ +const makeLeftRightDelim = function (delim, height, depth, options, mode, classes) { + // We always center \left/\right delimiters, so the axis is always shifted + const axisHeight = options.fontMetrics().axisHeight * options.sizeMultiplier; + + // Taken from TeX source, tex.web, function make_left_right + const delimiterFactor = 901; + const delimiterExtend = 5.0 / options.fontMetrics().ptPerEm; + const maxDistFromAxis = Math.max(height - axisHeight, depth + axisHeight); + const totalHeight = Math.max( + // In real TeX, calculations are done using integral values which are + // 65536 per pt, or 655360 per em. So, the division here truncates in + // TeX but doesn't here, producing different results. If we wanted to + // exactly match TeX's calculation, we could do + // Math.floor(655360 * maxDistFromAxis / 500) * + // delimiterFactor / 655360 + // (To see the difference, compare + // x^{x^{\left(\rule{0.1em}{0.68em}\right)}} + // in TeX and KaTeX) + maxDistFromAxis / 500 * delimiterFactor, 2 * maxDistFromAxis - delimiterExtend); + + // Finally, we defer to `makeCustomSizedDelim` with our calculated total + // height + return makeCustomSizedDelim(delim, totalHeight, true, options, mode, classes); +}; +;// ./src/functions/delimsizing.ts + + + + + + + + + +// Extra data needed for the delimiter handler down below +const delimiterSizes = { + "\\bigl": { + mclass: "mopen", + size: 1 + }, + "\\Bigl": { + mclass: "mopen", + size: 2 + }, + "\\biggl": { + mclass: "mopen", + size: 3 + }, + "\\Biggl": { + mclass: "mopen", + size: 4 + }, + "\\bigr": { + mclass: "mclose", + size: 1 + }, + "\\Bigr": { + mclass: "mclose", + size: 2 + }, + "\\biggr": { + mclass: "mclose", + size: 3 + }, + "\\Biggr": { + mclass: "mclose", + size: 4 + }, + "\\bigm": { + mclass: "mrel", + size: 1 + }, + "\\Bigm": { + mclass: "mrel", + size: 2 + }, + "\\biggm": { + mclass: "mrel", + size: 3 + }, + "\\Biggm": { + mclass: "mrel", + size: 4 + }, + "\\big": { + mclass: "mord", + size: 1 + }, + "\\Big": { + mclass: "mord", + size: 2 + }, + "\\bigg": { + mclass: "mord", + size: 3 + }, + "\\Bigg": { + mclass: "mord", + size: 4 + } +}; +const delimiters = new Set(["(", "\\lparen", ")", "\\rparen", "[", "\\lbrack", "]", "\\rbrack", "\\{", "\\lbrace", "\\}", "\\rbrace", "\\lfloor", "\\rfloor", "\u230a", "\u230b", "\\lceil", "\\rceil", "\u2308", "\u2309", "<", ">", "\\langle", "\u27e8", "\\rangle", "\u27e9", "\\lt", "\\gt", "\\lvert", "\\rvert", "\\lVert", "\\rVert", "\\lgroup", "\\rgroup", "\u27ee", "\u27ef", "\\lmoustache", "\\rmoustache", "\u23b0", "\u23b1", "/", "\\backslash", "|", "\\vert", "\\|", "\\Vert", "\\uparrow", "\\Uparrow", "\\downarrow", "\\Downarrow", "\\updownarrow", "\\Updownarrow", "."]); + +/** + * An HtmlDomNode that carries an `isMiddle` property, used by the + * \middle command to communicate delimiter info to the \left/\right builder. + */ + +function isMiddleDelimNode(node) { + return 'isMiddle' in node; +} + +// Delimiter functions +function checkDelimiter(delim, context) { + const symDelim = checkSymbolNodeType(delim); + if (symDelim && delimiters.has(symDelim.text)) { + return symDelim; + } else if (symDelim) { + throw new src_ParseError("Invalid delimiter '" + symDelim.text + "' after '" + context.funcName + "'", delim); + } else { + throw new src_ParseError("Invalid delimiter type '" + delim.type + "'", delim); + } +} +defineFunction({ + type: "delimsizing", + names: ["\\bigl", "\\Bigl", "\\biggl", "\\Biggl", "\\bigr", "\\Bigr", "\\biggr", "\\Biggr", "\\bigm", "\\Bigm", "\\biggm", "\\Biggm", "\\big", "\\Big", "\\bigg", "\\Bigg"], + numArgs: 1, + argTypes: ["primitive"], + handler: (context, args) => { + const delim = checkDelimiter(args[0], context); + return { + type: "delimsizing", + mode: context.parser.mode, + size: delimiterSizes[context.funcName].size, + mclass: delimiterSizes[context.funcName].mclass, + delim: delim.text + }; + }, + htmlBuilder: (group, options) => { + if (group.delim === ".") { + // Empty delimiters still count as elements, even though they don't + // show anything. + return makeSpan([group.mclass]); + } + return makeSizedDelim(group.delim, group.size, options, group.mode, [group.mclass]); + }, + mathmlBuilder: group => { + const children = []; + if (group.delim !== ".") { + children.push(makeText(group.delim, group.mode)); + } + const node = new MathNode("mo", children); + if (group.mclass === "mopen" || group.mclass === "mclose") { + // Only some of the delimsizing functions act as fences, and they + // return "mopen" or "mclose" mclass. + node.setAttribute("fence", "true"); + } else { + // Explicitly disable fencing if it's not a fence, to override the + // defaults. + node.setAttribute("fence", "false"); + } + node.setAttribute("stretchy", "true"); + const size = makeEm(sizeToMaxHeight[group.size]); + node.setAttribute("minsize", size); + node.setAttribute("maxsize", size); + return node; + } +}); +function assertParsed(group) { + if (!group.body) { + throw new Error("Bug: The leftright ParseNode wasn't fully parsed."); + } +} +defineFunction({ + type: "leftright-right", + names: ["\\right"], + numArgs: 1, + primitive: true, + handler: (context, args) => { + // \left case below triggers parsing of \right in + // `const right = parser.parseFunction();` + // uses this return value. + const color = context.parser.gullet.macros.get("\\current@color"); + if (color && typeof color !== "string") { + throw new src_ParseError("\\current@color set to non-string in \\right"); + } + return { + type: "leftright-right", + mode: context.parser.mode, + delim: checkDelimiter(args[0], context).text, + color // undefined if not set via \color + }; + } +}); +defineFunction({ + type: "leftright", + names: ["\\left"], + numArgs: 1, + primitive: true, + handler: (context, args) => { + const delim = checkDelimiter(args[0], context); + const parser = context.parser; + // Parse out the implicit body + ++parser.leftrightDepth; + // parseExpression stops before '\\right' + const body = parser.parseExpression(false); + --parser.leftrightDepth; + // Check the next token + parser.expect("\\right", false); + const right = assertNodeType(parser.parseFunction(), "leftright-right"); + return { + type: "leftright", + mode: parser.mode, + body, + left: delim.text, + right: right.delim, + rightColor: right.color + }; + }, + htmlBuilder: (group, options) => { + assertParsed(group); + // Build the inner expression + const inner = buildExpression(group.body, options, true, ["mopen", "mclose"]); + let innerHeight = 0; + let innerDepth = 0; + let hadMiddle = false; + + // Calculate its height and depth + for (let i = 0; i < inner.length; i++) { + const node = inner[i]; + if (isMiddleDelimNode(node)) { + hadMiddle = true; + } else { + innerHeight = Math.max(inner[i].height, innerHeight); + innerDepth = Math.max(inner[i].depth, innerDepth); + } + } + + // The size of delimiters is the same, regardless of what style we are + // in. Thus, to correctly calculate the size of delimiter we need around + // a group, we scale down the inner size based on the size. + innerHeight *= options.sizeMultiplier; + innerDepth *= options.sizeMultiplier; + let leftDelim; + if (group.left === ".") { + // Empty delimiters in \left and \right make null delimiter spaces. + leftDelim = makeNullDelimiter(options, ["mopen"]); + } else { + // Otherwise, use leftRightDelim to generate the correct sized + // delimiter. + leftDelim = makeLeftRightDelim(group.left, innerHeight, innerDepth, options, group.mode, ["mopen"]); + } + // Add it to the beginning of the expression + inner.unshift(leftDelim); + + // Handle middle delimiters + if (hadMiddle) { + for (let i = 1; i < inner.length; i++) { + const middleDelim = inner[i]; + if (isMiddleDelimNode(middleDelim)) { + const isMiddle = middleDelim.isMiddle; + // Apply the options that were active when \middle was called + inner[i] = makeLeftRightDelim(isMiddle.delim, innerHeight, innerDepth, isMiddle.options, group.mode, []); + } + } + } + let rightDelim; + // Same for the right delimiter, but using color specified by \color + if (group.right === ".") { + rightDelim = makeNullDelimiter(options, ["mclose"]); + } else { + const colorOptions = group.rightColor ? options.withColor(group.rightColor) : options; + rightDelim = makeLeftRightDelim(group.right, innerHeight, innerDepth, colorOptions, group.mode, ["mclose"]); + } + // Add it to the end of the expression. + inner.push(rightDelim); + return makeSpan(["minner"], inner, options); + }, + mathmlBuilder: (group, options) => { + assertParsed(group); + const inner = buildMathML_buildExpression(group.body, options); + if (group.left !== ".") { + const leftNode = new MathNode("mo", [makeText(group.left, group.mode)]); + leftNode.setAttribute("fence", "true"); + inner.unshift(leftNode); + } + if (group.right !== ".") { + const rightNode = new MathNode("mo", [makeText(group.right, group.mode)]); + rightNode.setAttribute("fence", "true"); + if (group.rightColor) { + rightNode.setAttribute("mathcolor", group.rightColor); + } + inner.push(rightNode); + } + return makeRow(inner); + } +}); +defineFunction({ + type: "middle", + names: ["\\middle"], + numArgs: 1, + primitive: true, + handler: (context, args) => { + const delim = checkDelimiter(args[0], context); + if (!context.parser.leftrightDepth) { + throw new src_ParseError("\\middle without preceding \\left", delim); + } + return { + type: "middle", + mode: context.parser.mode, + delim: delim.text + }; + }, + htmlBuilder: (group, options) => { + let middleDelim; + if (group.delim === ".") { + middleDelim = makeNullDelimiter(options, []); + } else { + middleDelim = makeSizedDelim(group.delim, 1, options, group.mode, []); + + // Patch an ad-hoc property onto the node so the \left/\right + // builder can reconstruct appropriately sized middle delimiters. + // isMiddle is not part of HtmlDomNode; the read side uses + // isMiddleDelimNode() to check before accessing. + middleDelim.isMiddle = { + delim: group.delim, + options + }; + } + return middleDelim; + }, + mathmlBuilder: (group, options) => { + // A Firefox \middle will stretch a character vertically only if it + // is in the fence part of the operator dictionary at: + // https://www.w3.org/TR/MathML3/appendixc.html. + // So we need to avoid U+2223 and use plain "|" instead. + const textNode = group.delim === "\\vert" || group.delim === "|" ? makeText("|", "text") : makeText(group.delim, group.mode); + const middleNode = new MathNode("mo", [textNode]); + middleNode.setAttribute("fence", "true"); + // MathML gives 5/18em spacing to each element. + // \middle should get delimiter spacing instead. + middleNode.setAttribute("lspace", "0.05em"); + middleNode.setAttribute("rspace", "0.05em"); + return middleNode; + } +}); +;// ./src/functions/enclose.ts + + + + + + + + + + + +const enclose_htmlBuilder = (group, options) => { + // \cancel, \bcancel, \xcancel, \sout, \fbox, \colorbox, \fcolorbox, \phase + // Some groups can return document fragments. Handle those by wrapping + // them in a span. + const inner = wrapFragment(buildGroup(group.body, options), options); + const label = group.label.slice(1); + let scale = options.sizeMultiplier; + let img; + let imgShift; + + // In the LaTeX cancel package, line geometry is slightly different + // depending on whether the subject is wider than it is tall, or vice versa. + // We don't know the width of a group, so as a proxy, we test if + // the subject is a single character. This captures most of the + // subjects that should get the "tall" treatment. + const isSingleChar = isCharacterBox(group.body); + if (label === "sout") { + img = makeSpan(["stretchy", "sout"]); + img.height = options.fontMetrics().defaultRuleThickness / scale; + imgShift = -0.5 * options.fontMetrics().xHeight; + } else if (label === "phase") { + // Set a couple of dimensions from the steinmetz package. + const lineWeight = calculateSize({ + number: 0.6, + unit: "pt" + }, options); + const clearance = calculateSize({ + number: 0.35, + unit: "ex" + }, options); + + // Prevent size changes like \Huge from affecting line thickness + const newOptions = options.havingBaseSizing(); + scale = scale / newOptions.sizeMultiplier; + const angleHeight = inner.height + inner.depth + lineWeight + clearance; + // Reserve a left pad for the angle. + inner.style.paddingLeft = makeEm(angleHeight / 2 + lineWeight); + + // Create an SVG + const viewBoxHeight = Math.floor(1000 * angleHeight * scale); + const path = phasePath(viewBoxHeight); + const svgNode = new SvgNode([new PathNode("phase", path)], { + "width": "400em", + "height": makeEm(viewBoxHeight / 1000), + "viewBox": "0 0 400000 " + viewBoxHeight, + "preserveAspectRatio": "xMinYMin slice" + }); + // Wrap it in a span with overflow: hidden. + img = makeSvgSpan(["hide-tail"], [svgNode], options); + img.style.height = makeEm(angleHeight); + imgShift = inner.depth + lineWeight + clearance; + } else { + // Add horizontal padding + if (/cancel/.test(label)) { + if (!isSingleChar) { + inner.classes.push("cancel-pad"); + } + } else if (label === "angl") { + inner.classes.push("anglpad"); + } else { + inner.classes.push("boxpad"); + } + + // Add vertical padding + let topPad; + let bottomPad; + let ruleThickness = 0; + // ref: cancel package: \advance\totalheight2\p@ % "+2" + if (/box/.test(label)) { + ruleThickness = Math.max(options.fontMetrics().fboxrule, + // default + options.minRuleThickness // User override. + ); + topPad = options.fontMetrics().fboxsep + (label === "colorbox" ? 0 : ruleThickness); + bottomPad = topPad; + } else if (label === "angl") { + ruleThickness = Math.max(options.fontMetrics().defaultRuleThickness, options.minRuleThickness); + topPad = 4 * ruleThickness; // gap = 3 × line, plus the line itself. + bottomPad = Math.max(0, 0.25 - inner.depth); + } else { + topPad = isSingleChar ? 0.2 : 0; + bottomPad = topPad; + } + img = stretchyEnclose(inner, label, topPad, bottomPad, options); + if (/fbox|boxed|fcolorbox/.test(label)) { + img.style.borderStyle = "solid"; + img.style.borderWidth = makeEm(ruleThickness); + } else if (label === "angl" && ruleThickness !== 0.049) { + img.style.borderTopWidth = makeEm(ruleThickness); + img.style.borderRightWidth = makeEm(ruleThickness); + } + imgShift = inner.depth + bottomPad; + if (group.backgroundColor) { + img.style.backgroundColor = group.backgroundColor; + if (group.borderColor) { + img.style.borderColor = group.borderColor; + } + } + } + let vlist; + if (group.backgroundColor) { + vlist = makeVList({ + positionType: "individualShift", + children: [ + // Put the color background behind inner; + { + type: "elem", + elem: img, + shift: imgShift + }, { + type: "elem", + elem: inner, + shift: 0 + }] + }, options); + } else { + const classes = /cancel|phase/.test(label) ? ["svg-align"] : []; + vlist = makeVList({ + positionType: "individualShift", + children: [ + // Write the \cancel stroke on top of inner. + { + type: "elem", + elem: inner, + shift: 0 + }, { + type: "elem", + elem: img, + shift: imgShift, + wrapperClasses: classes + }] + }, options); + } + if (/cancel/.test(label)) { + // The cancel package documentation says that cancel lines add their height + // to the expression, but tests show that isn't how it actually works. + vlist.height = inner.height; + vlist.depth = inner.depth; + } + if (/cancel/.test(label) && !isSingleChar) { + // cancel does not create horiz space for its line extension. + return makeSpan(["mord", "cancel-lap"], [vlist], options); + } else { + return makeSpan(["mord"], [vlist], options); + } +}; +const enclose_mathmlBuilder = (group, options) => { + let fboxsep; + const node = new MathNode(group.label.includes("colorbox") ? "mpadded" : "menclose", [buildMathML_buildGroup(group.body, options)]); + switch (group.label) { + case "\\cancel": + node.setAttribute("notation", "updiagonalstrike"); + break; + case "\\bcancel": + node.setAttribute("notation", "downdiagonalstrike"); + break; + case "\\phase": + node.setAttribute("notation", "phasorangle"); + break; + case "\\sout": + node.setAttribute("notation", "horizontalstrike"); + break; + case "\\fbox": + node.setAttribute("notation", "box"); + break; + case "\\angl": + node.setAttribute("notation", "actuarial"); + break; + case "\\fcolorbox": + case "\\colorbox": + // doesn't have a good notation option. So use + // instead. Set some attributes that come included with . + fboxsep = options.fontMetrics().fboxsep * options.fontMetrics().ptPerEm; + node.setAttribute("width", "+" + 2 * fboxsep + "pt"); + node.setAttribute("height", "+" + 2 * fboxsep + "pt"); + node.setAttribute("lspace", fboxsep + "pt"); // + node.setAttribute("voffset", fboxsep + "pt"); + if (group.label === "\\fcolorbox") { + const thk = Math.max(options.fontMetrics().fboxrule, + // default + options.minRuleThickness // user override + ); + node.setAttribute("style", "border: " + makeEm(thk) + " solid " + group.borderColor); + } + break; + case "\\xcancel": + node.setAttribute("notation", "updiagonalstrike downdiagonalstrike"); + break; + } + if (group.backgroundColor) { + node.setAttribute("mathbackground", group.backgroundColor); + } + return node; +}; +defineFunction({ + type: "enclose", + names: ["\\colorbox"], + numArgs: 2, + allowedInText: true, + argTypes: ["color", "hbox"], + handler(_ref, args, optArgs) { + let { + parser, + funcName + } = _ref; + const color = assertNodeType(args[0], "color-token").color; + const body = args[1]; + return { + type: "enclose", + mode: parser.mode, + label: funcName, + backgroundColor: color, + body + }; + }, + htmlBuilder: enclose_htmlBuilder, + mathmlBuilder: enclose_mathmlBuilder +}); +defineFunction({ + type: "enclose", + names: ["\\fcolorbox"], + numArgs: 3, + allowedInText: true, + argTypes: ["color", "color", "hbox"], + handler(_ref2, args, optArgs) { + let { + parser, + funcName + } = _ref2; + const borderColor = assertNodeType(args[0], "color-token").color; + const backgroundColor = assertNodeType(args[1], "color-token").color; + const body = args[2]; + return { + type: "enclose", + mode: parser.mode, + label: funcName, + backgroundColor, + borderColor, + body + }; + } +}); +defineFunction({ + type: "enclose", + names: ["\\fbox"], + numArgs: 1, + argTypes: ["hbox"], + allowedInText: true, + handler(_ref3, args) { + let { + parser + } = _ref3; + return { + type: "enclose", + mode: parser.mode, + label: "\\fbox", + body: args[0] + }; + } +}); +defineFunction({ + type: "enclose", + names: ["\\cancel", "\\bcancel", "\\xcancel", "\\phase"], + numArgs: 1, + handler(_ref4, args) { + let { + parser, + funcName + } = _ref4; + const body = args[0]; + return { + type: "enclose", + mode: parser.mode, + label: funcName, + body + }; + } +}); +defineFunction({ + type: "enclose", + names: ["\\sout"], + numArgs: 1, + allowedInText: true, + handler(_ref5, args) { + let { + parser, + funcName + } = _ref5; + if (parser.mode === "math") { + parser.settings.reportNonstrict("mathVsSout", "LaTeX's \\sout works only in text mode"); + } + const body = args[0]; + return { + type: "enclose", + mode: parser.mode, + label: funcName, + body + }; + } +}); +defineFunction({ + type: "enclose", + names: ["\\angl"], + numArgs: 1, + argTypes: ["hbox"], + allowedInText: false, + handler(_ref6, args) { + let { + parser + } = _ref6; + return { + type: "enclose", + mode: parser.mode, + label: "\\angl", + body: args[0] + }; + } +}); +;// ./src/defineEnvironment.ts + + +/** + * The context contains the following properties: + * - mode: current parsing mode. + * - envName: the name of the environment, one of the listed names. + * - parser: the parser object. + */ + +/** + * - context: information and references provided by the parser + * - args: an array of arguments passed to \begin{name} + * - optArgs: an array of optional arguments passed to \begin{name} + */ + +/** + * - numArgs: (default 0) The number of arguments after the \begin{name} function. + * - argTypes: (optional) Just like for a function + * - allowedInText: (default false) Whether or not the environment is allowed + * inside text mode (not enforced yet). + * - numOptionalArgs: (default 0) Just like for a function + */ + +/** + * Final environment spec for use at parse time. + * This is almost identical to `EnvDefSpec`, except it + * 1. includes the function handler + * 2. requires all arguments except argType + * It is generated by `defineEnvironment()` below. + */ + +/** + * All registered environments. + * `environments.js` exports this same dictionary again and makes it public. + * `Parser.js` requires this dictionary via `environments.js`. + */ +const _environments = {}; +function defineEnvironment(_ref) { + let { + type, + names, + props, + handler, + htmlBuilder, + mathmlBuilder + } = _ref; + // Set default values of environments. + const data = { + type, + numArgs: props.numArgs || 0, + allowedInText: false, + numOptionalArgs: 0, + handler + }; + for (let i = 0; i < names.length; ++i) { + // TODO: The value type of _environments should be a type union of all + // possible `EnvSpec<>` possibilities instead of `EnvSpec<*>`, which is + // an existential type. + _environments[names[i]] = data; + } + if (htmlBuilder) { + _htmlGroupBuilders[type] = htmlBuilder; + } + if (mathmlBuilder) { + _mathmlGroupBuilders[type] = mathmlBuilder; + } +} +;// ./src/defineMacro.ts +/** + * Provides context to macros defined by functions. Implemented by + * MacroExpander. + */ + +/** Macro tokens (in reverse order). */ + +/** + * All registered global/built-in macros. + * `macros.js` exports this same dictionary again and makes it public. + * `Parser.js` requires this dictionary via `macros.js`. + */ +const _macros = {}; + +// This function might one day accept an additional argument and do more things. +function defineMacro(name, body) { + _macros[name] = body; +} +;// ./src/SourceLocation.ts +/** + * Lexing or parsing positional information for error reporting. + * This object is immutable. + */ +class SourceLocation { + // End offset, zero-based exclusive. + + constructor(lexer, start, end) { + // The + prefix indicates that these fields aren't writeable + this.lexer = void 0; + // Lexer holding the input string. + this.start = void 0; + // Start offset, zero-based inclusive. + this.end = void 0; + this.lexer = lexer; + this.start = start; + this.end = end; + } + + /** + * Merges two `SourceLocation`s from location providers, given they are + * provided in order of appearance. + * - Returns the first one's location if only the first is provided. + * - Returns a merged range of the first and the last if both are provided + * and their lexers match. + * - Otherwise, returns null. + */ + static range(first, second) { + if (!second) { + return first && first.loc; + } else if (!first || !first.loc || !second.loc || first.loc.lexer !== second.loc.lexer) { + return null; + } else { + return new SourceLocation(first.loc.lexer, first.loc.start, second.loc.end); + } + } +} +;// ./src/Token.ts + + +/** + * Interface required to break circular dependency between Token, Lexer, and + * ParseError. + */ + +/** + * The resulting token returned from `lex`. + * + * It consists of the token text plus some position information. + * The position information is essentially a range in an input string, + * but instead of referencing the bare input string, we refer to the lexer. + * That way it is possible to attach extra metadata to the input string, + * like for example a file name or similar. + * + * The position information is optional, so it is OK to construct synthetic + * tokens if appropriate. Not providing available position information may + * lead to degraded error reporting, though. + */ +class Token { + // used in \noexpand + + constructor(text, + // the text of this token + loc) { + this.text = void 0; + this.loc = void 0; + this.noexpand = void 0; + // don't expand the token + this.treatAsRelax = void 0; + this.text = text; + this.loc = loc; + } + + /** + * Given a pair of tokens (this and endToken), compute a `Token` encompassing + * the whole input range enclosed by these two. + */ + range(endToken, + // last token of the range, inclusive + text // the text of the newly constructed token + ) { + return new Token(text, SourceLocation.range(this, endToken)); + } +} +;// ./src/environments/array.ts + + + + + + + + + + + + + + + +// Data stored in the ParseNode associated with the environment. + +// Type to indicate column separation in MathML + +// Helper functions +function getHLines(parser) { + // Return an array. The array length = number of hlines. + // Each element in the array tells if the line is dashed. + const hlineInfo = []; + parser.consumeSpaces(); + let nxt = parser.fetch().text; + if (nxt === "\\relax") { + // \relax is an artifact of the \cr macro below + parser.consume(); + parser.consumeSpaces(); + nxt = parser.fetch().text; + } + while (nxt === "\\hline" || nxt === "\\hdashline") { + parser.consume(); + hlineInfo.push(nxt === "\\hdashline"); + parser.consumeSpaces(); + nxt = parser.fetch().text; + } + return hlineInfo; +} +const validateAmsEnvironmentContext = context => { + const settings = context.parser.settings; + if (!settings.displayMode) { + throw new src_ParseError("{" + context.envName + "} can be used only in" + " display mode."); + } +}; +const gatherEnvironments = new Set(["gather", "gather*"]); + +// autoTag (an argument to parseArray) can be one of three values: +// * undefined: Regular (not-top-level) array; no tags on each row +// * true: Automatic equation numbering, overridable by \tag +// * false: Tags allowed on each row, but no automatic numbering +// This function *doesn't* work with the "split" environment name. +function getAutoTag(name) { + if (!name.includes("ed")) { + return !name.includes("*"); + } + // return undefined; +} + +/** + * Parse the body of the environment, with rows delimited by \\ and + * columns delimited by &, and create a nested list in row-major order + * with one group per cell. If given an optional argument style + * ("text", "display", etc.), then each cell is cast into that style. + */ +function parseArray(parser, _ref, style) { + let { + hskipBeforeAndAfter, + addJot, + cols, + arraystretch, + colSeparationType, + autoTag, + singleRow, + emptySingleRow, + maxNumCols, + leqno + } = _ref; + parser.gullet.beginGroup(); + if (!singleRow) { + // \cr is equivalent to \\ without the optional size argument (see below) + // TODO: provide helpful error when \cr is used outside array environment + parser.gullet.macros.set("\\cr", "\\\\\\relax"); + } + + // Get current arraystretch if it's not set by the environment + if (!arraystretch) { + const stretch = parser.gullet.expandMacroAsText("\\arraystretch"); + if (stretch == null) { + // Default \arraystretch from lttab.dtx + arraystretch = 1; + } else { + arraystretch = parseFloat(stretch); + if (!arraystretch || arraystretch < 0) { + throw new src_ParseError("Invalid \\arraystretch: " + stretch); + } + } + } + + // Start group for first cell + parser.gullet.beginGroup(); + let row = []; + const body = [row]; + const rowGaps = []; + const hLinesBeforeRow = []; + const tags = autoTag != null ? [] : undefined; + + // amsmath uses \global\@eqnswtrue and \global\@eqnswfalse to represent + // whether this row should have an equation number. Simulate this with + // a \@eqnsw macro set to 1 or 0. + function beginRow() { + if (autoTag) { + parser.gullet.macros.set("\\@eqnsw", "1", true); + } + } + function endRow() { + if (tags) { + if (parser.gullet.macros.get("\\df@tag")) { + tags.push(parser.subparse([new Token("\\df@tag")])); + parser.gullet.macros.set("\\df@tag", undefined, true); + } else { + tags.push(Boolean(autoTag) && parser.gullet.macros.get("\\@eqnsw") === "1"); + } + } + } + beginRow(); + + // Test for \hline at the top of the array. + hLinesBeforeRow.push(getHLines(parser)); + while (true) { + // Parse each cell in its own group (namespace) + const cellBody = parser.parseExpression(false, singleRow ? "\\end" : "\\\\"); + parser.gullet.endGroup(); + parser.gullet.beginGroup(); + let cell = { + type: "ordgroup", + mode: parser.mode, + body: cellBody + }; + if (style) { + cell = { + type: "styling", + mode: parser.mode, + style, + resetFont: true, + body: [cell] + }; + } + row.push(cell); + const next = parser.fetch().text; + if (next === "&") { + if (maxNumCols && row.length === maxNumCols) { + if (singleRow || colSeparationType) { + // {equation} or {split} + throw new src_ParseError("Too many tab characters: &", parser.nextToken); + } else { + // {array} environment + parser.settings.reportNonstrict("textEnv", "Too few columns " + "specified in the {array} column argument."); + } + } + parser.consume(); + } else if (next === "\\end") { + endRow(); + // Arrays terminate newlines with `\crcr` which consumes a `\cr` if + // the last line is empty. However, AMS environments keep the + // empty row if it's the only one. + // NOTE: Currently, `cell` is the last item added into `row`. + if (row.length === 1 && cell.type === "styling" && cell.body.length === 1 && cell.body[0].type === "ordgroup" && cell.body[0].body.length === 0 && (body.length > 1 || !emptySingleRow)) { + body.pop(); + } + if (hLinesBeforeRow.length < body.length + 1) { + hLinesBeforeRow.push([]); + } + break; + } else if (next === "\\\\") { + parser.consume(); + let size; + // \def\Let@{\let\\\math@cr} + // \def\math@cr{...\math@cr@} + // \def\math@cr@{\new@ifnextchar[\math@cr@@{\math@cr@@[\z@]}} + // \def\math@cr@@[#1]{...\math@cr@@@...} + // \def\math@cr@@@{\cr} + if (parser.gullet.future().text !== " ") { + size = parser.parseSizeGroup(true); + } + rowGaps.push(size ? size.value : null); + endRow(); + + // check for \hline(s) following the row separator + hLinesBeforeRow.push(getHLines(parser)); + row = []; + body.push(row); + beginRow(); + } else { + throw new src_ParseError("Expected & or \\\\ or \\cr or \\end", parser.nextToken); + } + } + + // End cell group + parser.gullet.endGroup(); + // End array group defining \cr + parser.gullet.endGroup(); + return { + type: "array", + mode: parser.mode, + addJot, + arraystretch, + body, + cols, + rowGaps, + hskipBeforeAndAfter, + hLinesBeforeRow, + colSeparationType, + tags, + leqno + }; +} + +// Decides on a style for cells in an array according to whether the given +// environment name starts with the letter 'd'. +function dCellStyle(envName) { + if (envName.slice(0, 1) === "d") { + return "display"; + } else { + return "text"; + } +} +const array_htmlBuilder = function (group, options) { + let r; + let c; + const nr = group.body.length; + const hLinesBeforeRow = group.hLinesBeforeRow; + let nc = 0; + const body = new Array(nr); + const hlines = []; + const ruleThickness = Math.max( + // From LaTeX \showthe\arrayrulewidth. Equals 0.04 em. + options.fontMetrics().arrayRuleWidth, options.minRuleThickness // User override. + ); + + // Horizontal spacing + const pt = 1 / options.fontMetrics().ptPerEm; + let arraycolsep = 5 * pt; // default value, i.e. \arraycolsep in article.cls + if (group.colSeparationType && group.colSeparationType === "small") { + // We're in a {smallmatrix}. Default column space is \thickspace, + // i.e. 5/18em = 0.2778em, per amsmath.dtx for {smallmatrix}. + // But that needs adjustment because LaTeX applies \scriptstyle to the + // entire array, including the colspace, but this function applies + // \scriptstyle only inside each element. + const localMultiplier = options.havingStyle(src_Style.SCRIPT).sizeMultiplier; + arraycolsep = 0.2778 * (localMultiplier / options.sizeMultiplier); + } + + // Vertical spacing + const baselineskip = group.colSeparationType === "CD" ? calculateSize({ + number: 3, + unit: "ex" + }, options) : 12 * pt; // see size10.clo + // Default \jot from ltmath.dtx + // TODO(edemaine): allow overriding \jot via \setlength (#687) + const jot = 3 * pt; + const arrayskip = group.arraystretch * baselineskip; + const arstrutHeight = 0.7 * arrayskip; // \strutbox in ltfsstrc.dtx and + const arstrutDepth = 0.3 * arrayskip; // \@arstrutbox in lttab.dtx + + let totalHeight = 0; + + // Set a position for \hline(s) at the top of the array, if any. + function setHLinePos(hlinesInGap) { + for (let i = 0; i < hlinesInGap.length; ++i) { + if (i > 0) { + totalHeight += 0.25; + } + hlines.push({ + pos: totalHeight, + isDashed: hlinesInGap[i] + }); + } + } + setHLinePos(hLinesBeforeRow[0]); + for (r = 0; r < group.body.length; ++r) { + const inrow = group.body[r]; + let height = arstrutHeight; // \@array adds an \@arstrut + let depth = arstrutDepth; // to each tow (via the template) + + if (nc < inrow.length) { + nc = inrow.length; + } + const outrow = { + cells: new Array(inrow.length), + height: 0, + depth: 0, + pos: 0 + }; + for (c = 0; c < inrow.length; ++c) { + const elt = buildGroup(inrow[c], options); + if (depth < elt.depth) { + depth = elt.depth; + } + if (height < elt.height) { + height = elt.height; + } + outrow.cells[c] = elt; + } + const rowGap = group.rowGaps[r]; + let gap = 0; + if (rowGap) { + gap = calculateSize(rowGap, options); + if (gap > 0) { + // \@argarraycr + gap += arstrutDepth; + if (depth < gap) { + depth = gap; // \@xargarraycr + } + gap = 0; + } + } + // In AMS multiline environments such as aligned and gathered, rows + // correspond to lines that have additional \jot added between lines + // via \openup. + // We simulate this by adding \jot depth to each row except the last. + if (group.addJot && r < group.body.length - 1) { + depth += jot; + } + outrow.height = height; + outrow.depth = depth; + totalHeight += height; + outrow.pos = totalHeight; + totalHeight += depth + gap; // \@yargarraycr + body[r] = outrow; + + // Set a position for \hline(s), if any. + setHLinePos(hLinesBeforeRow[r + 1]); + } + const offset = totalHeight / 2 + options.fontMetrics().axisHeight; + const colDescriptions = group.cols || []; + const cols = []; + let colSep; + let colDescrNum; + const tagSpans = []; + if (group.tags && group.tags.some(tag => tag)) { + // An environment with manual tags and/or automatic equation numbers. + // Create node(s), the latter of which trigger CSS counter increment. + for (r = 0; r < nr; ++r) { + const rw = body[r]; + const shift = rw.pos - offset; + const tag = group.tags[r]; + let tagSpan; + if (tag === true) { + // automatic numbering + tagSpan = makeSpan(["eqn-num"], [], options); + } else if (tag === false) { + // \nonumber/\notag or starred environment + tagSpan = makeSpan([], [], options); + } else { + // manual \tag + tagSpan = makeSpan([], buildExpression(tag, options, true), options); + } + tagSpan.depth = rw.depth; + tagSpan.height = rw.height; + tagSpans.push({ + type: "elem", + elem: tagSpan, + shift + }); + } + } + for (c = 0, colDescrNum = 0; + // Continue while either there are more columns or more column + // descriptions, so trailing separators don't get lost. + c < nc || colDescrNum < colDescriptions.length; ++c, ++colDescrNum) { + var _colDescr3; + let colDescr = colDescriptions[colDescrNum]; + let firstSeparator = true; + while (((_colDescr = colDescr) == null ? void 0 : _colDescr.type) === "separator") { + var _colDescr; + // If there is more than one separator in a row, add a space + // between them. + if (!firstSeparator) { + colSep = makeSpan(["arraycolsep"], []); + colSep.style.width = makeEm(options.fontMetrics().doubleRuleSep); + cols.push(colSep); + } + if (colDescr.separator === "|" || colDescr.separator === ":") { + const lineType = colDescr.separator === "|" ? "solid" : "dashed"; + const separator = makeSpan(["vertical-separator"], [], options); + separator.style.height = makeEm(totalHeight); + separator.style.borderRightWidth = makeEm(ruleThickness); + separator.style.borderRightStyle = lineType; + separator.style.margin = "0 " + makeEm(-ruleThickness / 2); + const shift = totalHeight - offset; + if (shift) { + separator.style.verticalAlign = makeEm(-shift); + } + cols.push(separator); + } else { + throw new src_ParseError("Invalid separator type: " + colDescr.separator); + } + colDescrNum++; + colDescr = colDescriptions[colDescrNum]; + firstSeparator = false; + } + if (c >= nc) { + continue; + } + let sepwidth; + if (c > 0 || group.hskipBeforeAndAfter) { + var _colDescr$pregap, _colDescr2; + sepwidth = (_colDescr$pregap = (_colDescr2 = colDescr) == null ? void 0 : _colDescr2.pregap) != null ? _colDescr$pregap : arraycolsep; + if (sepwidth !== 0) { + colSep = makeSpan(["arraycolsep"], []); + colSep.style.width = makeEm(sepwidth); + cols.push(colSep); + } + } + const colElems = []; + for (r = 0; r < nr; ++r) { + const row = body[r]; + const elem = row.cells[c]; + if (!elem) { + continue; + } + const shift = row.pos - offset; + elem.depth = row.depth; + elem.height = row.height; + colElems.push({ + type: "elem", + elem: elem, + shift: shift + }); + } + const colVList = makeVList({ + positionType: "individualShift", + children: colElems + }, options); + const colSpan = makeSpan(["col-align-" + (((_colDescr3 = colDescr) == null ? void 0 : _colDescr3.align) || "c")], [colVList]); + cols.push(colSpan); + if (c < nc - 1 || group.hskipBeforeAndAfter) { + var _colDescr$postgap, _colDescr4; + sepwidth = (_colDescr$postgap = (_colDescr4 = colDescr) == null ? void 0 : _colDescr4.postgap) != null ? _colDescr$postgap : arraycolsep; + if (sepwidth !== 0) { + colSep = makeSpan(["arraycolsep"], []); + colSep.style.width = makeEm(sepwidth); + cols.push(colSep); + } + } + } + let tableBody = makeSpan(["mtable"], cols); + + // Add \hline(s), if any. + if (hlines.length > 0) { + const line = makeLineSpan("hline", options, ruleThickness); + const dashes = makeLineSpan("hdashline", options, ruleThickness); + const vListElems = [{ + type: "elem", + elem: tableBody, + shift: 0 + }]; + while (hlines.length > 0) { + const hline = hlines.pop(); + const lineShift = hline.pos - offset; + if (hline.isDashed) { + vListElems.push({ + type: "elem", + elem: dashes, + shift: lineShift + }); + } else { + vListElems.push({ + type: "elem", + elem: line, + shift: lineShift + }); + } + } + tableBody = makeVList({ + positionType: "individualShift", + children: vListElems + }, options); + } + if (tagSpans.length === 0) { + return makeSpan(["mord"], [tableBody], options); + } else { + const eqnNumCol = makeVList({ + positionType: "individualShift", + children: tagSpans + }, options); + const tagCol = makeSpan(["tag"], [eqnNumCol], options); + return makeFragment([tableBody, tagCol]); + } +}; +const alignMap = { + c: "center ", + l: "left ", + r: "right " +}; +const array_mathmlBuilder = function (group, options) { + const tbl = []; + const glue = new MathNode("mtd", [], ["mtr-glue"]); + const tag = new MathNode("mtd", [], ["mml-eqn-num"]); + for (let i = 0; i < group.body.length; i++) { + const rw = group.body[i]; + const row = []; + for (let j = 0; j < rw.length; j++) { + row.push(new MathNode("mtd", [buildMathML_buildGroup(rw[j], options)])); + } + if (group.tags && group.tags[i]) { + row.unshift(glue); + row.push(glue); + if (group.leqno) { + row.unshift(tag); + } else { + row.push(tag); + } + } + tbl.push(new MathNode("mtr", row)); + } + let table = new MathNode("mtable", tbl); + + // Set column alignment, row spacing, column spacing, and + // array lines by setting attributes on the table element. + + // Set the row spacing. In MathML, we specify a gap distance. + // We do not use rowGap[] because MathML automatically increases + // cell height with the height/depth of the element content. + + // LaTeX \arraystretch multiplies the row baseline-to-baseline distance. + // We simulate this by adding (arraystretch - 1)em to the gap. This + // does a reasonable job of adjusting arrays containing 1 em tall content. + + // The 0.16 and 0.09 values are found empirically. They produce an array + // similar to LaTeX and in which content does not interfere with \hlines. + const gap = group.arraystretch === 0.5 ? 0.1 // {smallmatrix}, {subarray} + : 0.16 + group.arraystretch - 1 + (group.addJot ? 0.09 : 0); + table.setAttribute("rowspacing", makeEm(gap)); + + // MathML table lines go only between cells. + // To place a line on an edge we'll use , if necessary. + let menclose = ""; + let align = ""; + if (group.cols && group.cols.length > 0) { + // Find column alignment, column spacing, and vertical lines. + const cols = group.cols; + let columnLines = ""; + let prevTypeWasAlign = false; + let iStart = 0; + let iEnd = cols.length; + if (cols[0].type === "separator") { + menclose += "top "; + iStart = 1; + } + if (cols[cols.length - 1].type === "separator") { + menclose += "bottom "; + iEnd -= 1; + } + for (let i = iStart; i < iEnd; i++) { + const col = cols[i]; + if (col.type === "align") { + align += alignMap[col.align]; + if (prevTypeWasAlign) { + columnLines += "none "; + } + prevTypeWasAlign = true; + } else if (col.type === "separator") { + // MathML accepts only single lines between cells. + // So we read only the first of consecutive separators. + if (prevTypeWasAlign) { + columnLines += col.separator === "|" ? "solid " : "dashed "; + prevTypeWasAlign = false; + } + } + } + table.setAttribute("columnalign", align.trim()); + if (/[sd]/.test(columnLines)) { + table.setAttribute("columnlines", columnLines.trim()); + } + } + + // Set column spacing. + if (group.colSeparationType === "align") { + const cols = group.cols || []; + let spacing = ""; + for (let i = 1; i < cols.length; i++) { + spacing += i % 2 ? "0em " : "1em "; + } + table.setAttribute("columnspacing", spacing.trim()); + } else if (group.colSeparationType === "alignat" || group.colSeparationType === "gather") { + table.setAttribute("columnspacing", "0em"); + } else if (group.colSeparationType === "small") { + table.setAttribute("columnspacing", "0.2778em"); + } else if (group.colSeparationType === "CD") { + table.setAttribute("columnspacing", "0.5em"); + } else { + table.setAttribute("columnspacing", "1em"); + } + + // Address \hline and \hdashline + let rowLines = ""; + const hlines = group.hLinesBeforeRow; + menclose += hlines[0].length > 0 ? "left " : ""; + menclose += hlines[hlines.length - 1].length > 0 ? "right " : ""; + for (let i = 1; i < hlines.length - 1; i++) { + rowLines += hlines[i].length === 0 ? "none " + // MathML accepts only a single line between rows. Read one element. + : hlines[i][0] ? "dashed " : "solid "; + } + if (/[sd]/.test(rowLines)) { + table.setAttribute("rowlines", rowLines.trim()); + } + if (menclose !== "") { + table = new MathNode("menclose", [table]); + table.setAttribute("notation", menclose.trim()); + } + if (group.arraystretch && group.arraystretch < 1) { + // A small array. Wrap in scriptstyle so row gap is not too large. + table = new MathNode("mstyle", [table]); + table.setAttribute("scriptlevel", "1"); + } + return table; +}; + +// Convenience function for align, align*, aligned, alignat, alignat*, alignedat. +const alignedHandler = function (context, args) { + if (!context.envName.includes("ed")) { + validateAmsEnvironmentContext(context); + } + const cols = []; + const isSplit = context.envName === "split"; + const res = parseArray(context.parser, { + cols, + addJot: true, + autoTag: isSplit ? undefined : getAutoTag(context.envName), + emptySingleRow: true, + colSeparationType: context.envName.includes("at") ? "alignat" : "align", + maxNumCols: isSplit ? 2 : undefined, + leqno: context.parser.settings.leqno + }, "display"); + + // Determining number of columns. + // 1. If the first argument is given, we use it as a number of columns, + // and makes sure that each row doesn't exceed that number. + // 2. Otherwise, just count number of columns = maximum number + // of cells in each row ("aligned" mode -- isAligned will be true). + // + // At the same time, prepend empty group {} at beginning of every second + // cell in each row (starting with second cell) so that operators become + // binary. This behavior is implemented in amsmath's \start@aligned. + let numMaths = 0; + let numCols = 0; + const emptyGroup = { + type: "ordgroup", + mode: context.mode, + body: [] + }; + if (args[0] && args[0].type === "ordgroup") { + let arg0 = ""; + for (let i = 0; i < args[0].body.length; i++) { + const textord = assertNodeType(args[0].body[i], "textord"); + arg0 += textord.text; + } + numMaths = Number(arg0); + numCols = numMaths * 2; + } + const isAligned = !numCols; + res.body.forEach(function (row) { + for (let i = 1; i < row.length; i += 2) { + // Modify ordgroup node within styling node + const styling = assertNodeType(row[i], "styling"); + const ordgroup = assertNodeType(styling.body[0], "ordgroup"); + ordgroup.body.unshift(emptyGroup); + } + if (!isAligned) { + // Case 1 + const curMaths = row.length / 2; + if (numMaths < curMaths) { + throw new src_ParseError("Too many math in a row: " + ("expected " + numMaths + ", but got " + curMaths), row[0]); + } + } else if (numCols < row.length) { + // Case 2 + numCols = row.length; + } + }); + + // Adjusting alignment. + // In aligned mode, we add one \qquad between columns; + // otherwise we add nothing. + for (let i = 0; i < numCols; ++i) { + let align = "r"; + let pregap = 0; + if (i % 2 === 1) { + align = "l"; + } else if (i > 0 && isAligned) { + // "aligned" mode. + pregap = 1; // add one \quad + } + cols[i] = { + type: "align", + align: align, + pregap: pregap, + postgap: 0 + }; + } + res.colSeparationType = isAligned ? "align" : "alignat"; + return res; +}; + +// Arrays are part of LaTeX, defined in lttab.dtx so its documentation +// is part of the source2e.pdf file of LaTeX2e source documentation. +// {darray} is an {array} environment where cells are set in \displaystyle, +// as defined in nccmath.sty. +defineEnvironment({ + type: "array", + names: ["array", "darray"], + props: { + numArgs: 1 + }, + handler(context, args) { + // Since no types are specified above, the two possibilities are + // - The argument is wrapped in {} or [], in which case Parser's + // parseGroup() returns an "ordgroup" wrapping some symbol node. + // - The argument is a bare symbol node. + const symNode = checkSymbolNodeType(args[0]); + const colalign = symNode ? [args[0]] : assertNodeType(args[0], "ordgroup").body; + const cols = colalign.map(function (nde) { + const node = assertSymbolNodeType(nde); + const ca = node.text; + if ("lcr".includes(ca)) { + return { + type: "align", + align: ca + }; + } else if (ca === "|") { + return { + type: "separator", + separator: "|" + }; + } else if (ca === ":") { + return { + type: "separator", + separator: ":" + }; + } + throw new src_ParseError("Unknown column alignment: " + ca, nde); + }); + const res = { + cols, + hskipBeforeAndAfter: true, + // \@preamble in lttab.dtx + maxNumCols: cols.length + }; + return parseArray(context.parser, res, dCellStyle(context.envName)); + }, + htmlBuilder: array_htmlBuilder, + mathmlBuilder: array_mathmlBuilder +}); + +// The matrix environments of amsmath builds on the array environment +// of LaTeX, which is discussed above. +// The mathtools package adds starred versions of the same environments. +// These have an optional argument to choose left|center|right justification. +defineEnvironment({ + type: "array", + names: ["matrix", "pmatrix", "bmatrix", "Bmatrix", "vmatrix", "Vmatrix", "matrix*", "pmatrix*", "bmatrix*", "Bmatrix*", "vmatrix*", "Vmatrix*"], + props: { + numArgs: 0 + }, + handler(context) { + const delimiters = { + "matrix": null, + "pmatrix": ["(", ")"], + "bmatrix": ["[", "]"], + "Bmatrix": ["\\{", "\\}"], + "vmatrix": ["|", "|"], + "Vmatrix": ["\\Vert", "\\Vert"] + }[context.envName.replace("*", "")]; + // \hskip -\arraycolsep in amsmath + let colAlign = "c"; + const payload = { + hskipBeforeAndAfter: false, + cols: [{ + type: "align", + align: colAlign + }] + }; + if (context.envName.charAt(context.envName.length - 1) === "*") { + // It's one of the mathtools starred functions. + // Parse the optional alignment argument. + const parser = context.parser; + parser.consumeSpaces(); + if (parser.fetch().text === "[") { + parser.consume(); + parser.consumeSpaces(); + colAlign = parser.fetch().text; + if (!"lcr".includes(colAlign)) { + throw new src_ParseError("Expected l or c or r", parser.nextToken); + } + parser.consume(); + parser.consumeSpaces(); + parser.expect("]"); + parser.consume(); + payload.cols = [{ + type: "align", + align: colAlign + }]; + } + } + const res = parseArray(context.parser, payload, dCellStyle(context.envName)); + // Populate cols with the correct number of column alignment specs. + const numCols = Math.max(0, ...res.body.map(row => row.length)); + res.cols = new Array(numCols).fill({ + type: "align", + align: colAlign + }); + return delimiters ? { + type: "leftright", + mode: context.mode, + body: [res], + left: delimiters[0], + right: delimiters[1], + rightColor: undefined // \right uninfluenced by \color in array + } : res; + }, + htmlBuilder: array_htmlBuilder, + mathmlBuilder: array_mathmlBuilder +}); +defineEnvironment({ + type: "array", + names: ["smallmatrix"], + props: { + numArgs: 0 + }, + handler(context) { + const payload = { + arraystretch: 0.5 + }; + const res = parseArray(context.parser, payload, "script"); + res.colSeparationType = "small"; + return res; + }, + htmlBuilder: array_htmlBuilder, + mathmlBuilder: array_mathmlBuilder +}); +defineEnvironment({ + type: "array", + names: ["subarray"], + props: { + numArgs: 1 + }, + handler(context, args) { + // Parsing of {subarray} is similar to {array} + const symNode = checkSymbolNodeType(args[0]); + const colalign = symNode ? [args[0]] : assertNodeType(args[0], "ordgroup").body; + const cols = colalign.map(function (nde) { + const node = assertSymbolNodeType(nde); + const ca = node.text; + // {subarray} only recognizes "l" & "c" + if ("lc".includes(ca)) { + return { + type: "align", + align: ca + }; + } + throw new src_ParseError("Unknown column alignment: " + ca, nde); + }); + if (cols.length > 1) { + throw new src_ParseError("{subarray} can contain only one column"); + } + const payload = { + cols, + hskipBeforeAndAfter: false, + arraystretch: 0.5 + }; + const res = parseArray(context.parser, payload, "script"); + if (res.body.length > 0 && res.body[0].length > 1) { + throw new src_ParseError("{subarray} can contain only one column"); + } + return res; + }, + htmlBuilder: array_htmlBuilder, + mathmlBuilder: array_mathmlBuilder +}); + +// A cases environment (in amsmath.sty) is almost equivalent to +// \def\arraystretch{1.2}% +// \left\{\begin{array}{@{}l@{\quad}l@{}} … \end{array}\right. +// {dcases} is a {cases} environment where cells are set in \displaystyle, +// as defined in mathtools.sty. +// {rcases} is another mathtools environment. It's brace is on the right side. +defineEnvironment({ + type: "array", + names: ["cases", "dcases", "rcases", "drcases"], + props: { + numArgs: 0 + }, + handler(context) { + const payload = { + arraystretch: 1.2, + cols: [{ + type: "align", + align: "l", + pregap: 0, + // TODO(kevinb) get the current style. + // For now we use the metrics for TEXT style which is what we were + // doing before. Before attempting to get the current style we + // should look at TeX's behavior especially for \over and matrices. + postgap: 1.0 /* 1em quad */ + }, { + type: "align", + align: "l", + pregap: 0, + postgap: 0 + }] + }; + const res = parseArray(context.parser, payload, dCellStyle(context.envName)); + return { + type: "leftright", + mode: context.mode, + body: [res], + left: context.envName.includes("r") ? "." : "\\{", + right: context.envName.includes("r") ? "\\}" : ".", + rightColor: undefined + }; + }, + htmlBuilder: array_htmlBuilder, + mathmlBuilder: array_mathmlBuilder +}); + +// In the align environment, one uses ampersands, &, to specify number of +// columns in each row, and to locate spacing between each column. +// align gets automatic numbering. align* and aligned do not. +// The alignedat environment can be used in math mode. +// Note that we assume \nomallineskiplimit to be zero, +// so that \strut@ is the same as \strut. +defineEnvironment({ + type: "array", + names: ["align", "align*", "aligned", "split"], + props: { + numArgs: 0 + }, + handler: alignedHandler, + htmlBuilder: array_htmlBuilder, + mathmlBuilder: array_mathmlBuilder +}); + +// A gathered environment is like an array environment with one centered +// column, but where rows are considered lines so get \jot line spacing +// and contents are set in \displaystyle. +defineEnvironment({ + type: "array", + names: ["gathered", "gather", "gather*"], + props: { + numArgs: 0 + }, + handler(context) { + if (gatherEnvironments.has(context.envName)) { + validateAmsEnvironmentContext(context); + } + const res = { + cols: [{ + type: "align", + align: "c" + }], + addJot: true, + colSeparationType: "gather", + autoTag: getAutoTag(context.envName), + emptySingleRow: true, + leqno: context.parser.settings.leqno + }; + return parseArray(context.parser, res, "display"); + }, + htmlBuilder: array_htmlBuilder, + mathmlBuilder: array_mathmlBuilder +}); + +// alignat environment is like an align environment, but one must explicitly +// specify maximum number of columns in each row, and can adjust spacing between +// each columns. +defineEnvironment({ + type: "array", + names: ["alignat", "alignat*", "alignedat"], + props: { + numArgs: 1 + }, + handler: alignedHandler, + htmlBuilder: array_htmlBuilder, + mathmlBuilder: array_mathmlBuilder +}); +defineEnvironment({ + type: "array", + names: ["equation", "equation*"], + props: { + numArgs: 0 + }, + handler(context) { + validateAmsEnvironmentContext(context); + const res = { + autoTag: getAutoTag(context.envName), + emptySingleRow: true, + singleRow: true, + maxNumCols: 1, + leqno: context.parser.settings.leqno + }; + return parseArray(context.parser, res, "display"); + }, + htmlBuilder: array_htmlBuilder, + mathmlBuilder: array_mathmlBuilder +}); +defineEnvironment({ + type: "array", + names: ["CD"], + props: { + numArgs: 0 + }, + handler(context) { + validateAmsEnvironmentContext(context); + return parseCD(context.parser); + }, + htmlBuilder: array_htmlBuilder, + mathmlBuilder: array_mathmlBuilder +}); +defineMacro("\\nonumber", "\\gdef\\@eqnsw{0}"); +defineMacro("\\notag", "\\nonumber"); + +// Catch \hline outside array environment +defineFunction({ + type: "text", + // Doesn't matter what this is. + names: ["\\hline", "\\hdashline"], + numArgs: 0, + allowedInText: true, + allowedInMath: true, + handler(context, args) { + throw new src_ParseError(context.funcName + " valid only within array environment"); + } +}); +;// ./src/environments.ts + +const environments = _environments; +/* harmony default export */ var src_environments = (environments); + +// All environment definitions should be imported below + +;// ./src/functions/environment.ts + + + + +// Environment delimiters. HTML/MathML rendering is defined in the corresponding +// defineEnvironment definitions. +defineFunction({ + type: "environment", + names: ["\\begin", "\\end"], + numArgs: 1, + argTypes: ["text"], + handler(_ref, args) { + let { + parser, + funcName + } = _ref; + const nameGroup = args[0]; + if (nameGroup.type !== "ordgroup") { + throw new src_ParseError("Invalid environment name", nameGroup); + } + let envName = ""; + for (let i = 0; i < nameGroup.body.length; ++i) { + envName += assertNodeType(nameGroup.body[i], "textord").text; + } + if (funcName === "\\begin") { + // begin...end is similar to left...right + if (!src_environments.hasOwnProperty(envName)) { + throw new src_ParseError("No such environment: " + envName, nameGroup); + } + // Build the environment object. Arguments and other information will + // be made available to the begin and end methods using properties. + const env = src_environments[envName]; + const { + args, + optArgs + } = parser.parseArguments("\\begin{" + envName + "}", env); + const context = { + mode: parser.mode, + envName, + parser + }; + const result = env.handler(context, args, optArgs); + parser.expect("\\end", false); + const endNameToken = parser.nextToken; + const end = assertNodeType(parser.parseFunction(), "environment"); + if (end.name !== envName) { + throw new src_ParseError("Mismatch: \\begin{" + envName + "} matched by \\end{" + end.name + "}", endNameToken); + } + // env.handler returns the specific node type (e.g. "array"), + // not "environment". This cast is unavoidable: defineFunction + // requires the handler to return ParseNode<"environment"> but + // \begin delegates to environment handlers with different types. + return result; + } + return { + type: "environment", + mode: parser.mode, + name: envName, + nameGroup + }; + } +}); +;// ./src/functions/font.ts +// TODO(kevinb): implement \\sl and \\sc + + + + + + +const font_htmlBuilder = (group, options) => { + const font = group.font; + const newOptions = options.withFont(font); + return buildGroup(group.body, newOptions); +}; +const font_mathmlBuilder = (group, options) => { + const font = group.font; + const newOptions = options.withFont(font); + return buildMathML_buildGroup(group.body, newOptions); +}; +const fontAliases = { + "\\Bbb": "\\mathbb", + "\\bold": "\\mathbf", + "\\frak": "\\mathfrak" +}; +defineFunction({ + type: "font", + names: [ + // styles, except \boldsymbol defined below + "\\mathrm", "\\mathit", "\\mathbf", "\\mathnormal", "\\mathsfit", + // families + "\\mathbb", "\\mathcal", "\\mathfrak", "\\mathscr", "\\mathsf", "\\mathtt", + // aliases, except \bm defined below + "\\Bbb", "\\bold", "\\frak"], + numArgs: 1, + allowedInArgument: true, + handler: (_ref, args) => { + let { + parser, + funcName + } = _ref; + const body = normalizeArgument(args[0]); + const func = funcName in fontAliases ? fontAliases[funcName] : funcName; + return { + type: "font", + mode: parser.mode, + font: func.slice(1), + body + }; + }, + htmlBuilder: font_htmlBuilder, + mathmlBuilder: font_mathmlBuilder +}); +defineFunction({ + type: "mclass", + names: ["\\boldsymbol", "\\bm"], + numArgs: 1, + handler: (_ref2, args) => { + let { + parser + } = _ref2; + const body = args[0]; + // amsbsy.sty's \boldsymbol uses \binrel spacing to inherit the + // argument's bin|rel|ord status + return { + type: "mclass", + mode: parser.mode, + mclass: binrelClass(body), + body: [{ + type: "font", + mode: parser.mode, + font: "boldsymbol", + body + }], + isCharacterBox: isCharacterBox(body) + }; + } +}); + +// Old font changing functions +defineFunction({ + type: "font", + names: ["\\rm", "\\sf", "\\tt", "\\bf", "\\it", "\\cal"], + numArgs: 0, + allowedInText: true, + handler: (_ref3, args) => { + let { + parser, + funcName, + breakOnTokenText + } = _ref3; + const { + mode + } = parser; + const body = parser.parseExpression(true, breakOnTokenText); + return { + type: "font", + mode: mode, + font: "math" + funcName.slice(1), + body: { + type: "ordgroup", + mode: parser.mode, + body + } + }; + } +}); +;// ./src/functions/genfrac.ts + + + + + + + + + +const genfrac_htmlBuilder = (group, options) => { + // Fractions are handled in the TeXbook on pages 444-445, rules 15(a-e). + const style = options.style; + const nstyle = style.fracNum(); + const dstyle = style.fracDen(); + let newOptions; + newOptions = options.havingStyle(nstyle); + const numerm = buildGroup(group.numer, newOptions, options); + if (group.continued) { + // \cfrac inserts a \strut into the numerator. + // Get \strut dimensions from TeXbook page 353. + const hStrut = 8.5 / options.fontMetrics().ptPerEm; + const dStrut = 3.5 / options.fontMetrics().ptPerEm; + numerm.height = numerm.height < hStrut ? hStrut : numerm.height; + numerm.depth = numerm.depth < dStrut ? dStrut : numerm.depth; + } + newOptions = options.havingStyle(dstyle); + const denomm = buildGroup(group.denom, newOptions, options); + let rule; + let ruleWidth; + let ruleSpacing; + if (group.hasBarLine) { + if (group.barSize) { + ruleWidth = calculateSize(group.barSize, options); + rule = makeLineSpan("frac-line", options, ruleWidth); + } else { + rule = makeLineSpan("frac-line", options); + } + ruleWidth = rule.height; + ruleSpacing = rule.height; + } else { + rule = null; + ruleWidth = 0; + ruleSpacing = options.fontMetrics().defaultRuleThickness; + } + + // Rule 15b + let numShift; + let clearance; + let denomShift; + if (style.size === src_Style.DISPLAY.size) { + numShift = options.fontMetrics().num1; + if (ruleWidth > 0) { + clearance = 3 * ruleSpacing; + } else { + clearance = 7 * ruleSpacing; + } + denomShift = options.fontMetrics().denom1; + } else { + if (ruleWidth > 0) { + numShift = options.fontMetrics().num2; + clearance = ruleSpacing; + } else { + numShift = options.fontMetrics().num3; + clearance = 3 * ruleSpacing; + } + denomShift = options.fontMetrics().denom2; + } + let frac; + if (!rule) { + // Rule 15c + const candidateClearance = numShift - numerm.depth - (denomm.height - denomShift); + if (candidateClearance < clearance) { + numShift += 0.5 * (clearance - candidateClearance); + denomShift += 0.5 * (clearance - candidateClearance); + } + frac = makeVList({ + positionType: "individualShift", + children: [{ + type: "elem", + elem: denomm, + shift: denomShift + }, { + type: "elem", + elem: numerm, + shift: -numShift + }] + }, options); + } else { + // Rule 15d + const axisHeight = options.fontMetrics().axisHeight; + if (numShift - numerm.depth - (axisHeight + 0.5 * ruleWidth) < clearance) { + numShift += clearance - (numShift - numerm.depth - (axisHeight + 0.5 * ruleWidth)); + } + if (axisHeight - 0.5 * ruleWidth - (denomm.height - denomShift) < clearance) { + denomShift += clearance - (axisHeight - 0.5 * ruleWidth - (denomm.height - denomShift)); + } + const midShift = -(axisHeight - 0.5 * ruleWidth); + frac = makeVList({ + positionType: "individualShift", + children: [{ + type: "elem", + elem: denomm, + shift: denomShift + }, { + type: "elem", + elem: rule, + shift: midShift + }, { + type: "elem", + elem: numerm, + shift: -numShift + }] + }, options); + } + + // Since we manually change the style sometimes (with \dfrac or \tfrac), + // account for the possible size change here. + newOptions = options.havingStyle(style); + frac.height *= newOptions.sizeMultiplier / options.sizeMultiplier; + frac.depth *= newOptions.sizeMultiplier / options.sizeMultiplier; + + // Rule 15e + let delimSize; + if (style.size === src_Style.DISPLAY.size) { + delimSize = options.fontMetrics().delim1; + } else if (style.size === src_Style.SCRIPTSCRIPT.size) { + delimSize = options.havingStyle(src_Style.SCRIPT).fontMetrics().delim2; + } else { + delimSize = options.fontMetrics().delim2; + } + let leftDelim; + let rightDelim; + if (group.leftDelim == null) { + leftDelim = makeNullDelimiter(options, ["mopen"]); + } else { + leftDelim = makeCustomSizedDelim(group.leftDelim, delimSize, true, options.havingStyle(style), group.mode, ["mopen"]); + } + if (group.continued) { + rightDelim = makeSpan([]); // zero width for \cfrac + } else if (group.rightDelim == null) { + rightDelim = makeNullDelimiter(options, ["mclose"]); + } else { + rightDelim = makeCustomSizedDelim(group.rightDelim, delimSize, true, options.havingStyle(style), group.mode, ["mclose"]); + } + return makeSpan(["mord"].concat(newOptions.sizingClasses(options)), [leftDelim, makeSpan(["mfrac"], [frac]), rightDelim], options); +}; +const genfrac_mathmlBuilder = (group, options) => { + const node = new MathNode("mfrac", [buildMathML_buildGroup(group.numer, options), buildMathML_buildGroup(group.denom, options)]); + if (!group.hasBarLine) { + node.setAttribute("linethickness", "0px"); + } else if (group.barSize) { + const ruleWidth = calculateSize(group.barSize, options); + node.setAttribute("linethickness", makeEm(ruleWidth)); + } + if (group.leftDelim != null || group.rightDelim != null) { + const withDelims = []; + if (group.leftDelim != null) { + const leftOp = new MathNode("mo", [new TextNode(group.leftDelim.replace("\\", ""))]); + leftOp.setAttribute("fence", "true"); + withDelims.push(leftOp); + } + withDelims.push(node); + if (group.rightDelim != null) { + const rightOp = new MathNode("mo", [new TextNode(group.rightDelim.replace("\\", ""))]); + rightOp.setAttribute("fence", "true"); + withDelims.push(rightOp); + } + return makeRow(withDelims); + } + return node; +}; +const wrapWithStyle = (frac, style) => { + if (!style) { + return frac; + } + const wrapper = { + type: "styling", + mode: frac.mode, + style, + body: [frac] + }; + + // @ts-ignore defineFunction handler needs to return ParseNode<"genfrac"> + return wrapper; +}; +defineFunction({ + type: "genfrac", + names: ["\\cfrac", "\\dfrac", "\\frac", "\\tfrac", "\\dbinom", "\\binom", "\\tbinom", "\\\\atopfrac", + // can’t be entered directly + "\\\\bracefrac", "\\\\brackfrac" // ditto + ], + numArgs: 2, + allowedInArgument: true, + handler: (_ref, args) => { + let { + parser, + funcName + } = _ref; + const numer = args[0]; + const denom = args[1]; + let hasBarLine; + let leftDelim = null; + let rightDelim = null; + switch (funcName) { + case "\\cfrac": + case "\\dfrac": + case "\\frac": + case "\\tfrac": + hasBarLine = true; + break; + case "\\\\atopfrac": + hasBarLine = false; + break; + case "\\dbinom": + case "\\binom": + case "\\tbinom": + hasBarLine = false; + leftDelim = "("; + rightDelim = ")"; + break; + case "\\\\bracefrac": + hasBarLine = false; + leftDelim = "\\{"; + rightDelim = "\\}"; + break; + case "\\\\brackfrac": + hasBarLine = false; + leftDelim = "["; + rightDelim = "]"; + break; + default: + throw new Error("Unrecognized genfrac command"); + } + const continued = funcName === "\\cfrac"; + let style = null; + if (continued || funcName.startsWith("\\d")) { + style = "display"; + } else if (funcName.startsWith("\\t")) { + style = "text"; + } + return wrapWithStyle({ + type: "genfrac", + mode: parser.mode, + numer, + denom, + continued, + hasBarLine, + leftDelim, + rightDelim, + barSize: null + }, style); + }, + htmlBuilder: genfrac_htmlBuilder, + mathmlBuilder: genfrac_mathmlBuilder +}); + +// Infix generalized fractions -- these are not rendered directly, but replaced +// immediately by one of the variants above. +defineFunction({ + type: "infix", + names: ["\\over", "\\choose", "\\atop", "\\brace", "\\brack"], + numArgs: 0, + infix: true, + handler(_ref2) { + let { + parser, + funcName, + token + } = _ref2; + let replaceWith; + switch (funcName) { + case "\\over": + replaceWith = "\\frac"; + break; + case "\\choose": + replaceWith = "\\binom"; + break; + case "\\atop": + replaceWith = "\\\\atopfrac"; + break; + case "\\brace": + replaceWith = "\\\\bracefrac"; + break; + case "\\brack": + replaceWith = "\\\\brackfrac"; + break; + default: + throw new Error("Unrecognized infix genfrac command"); + } + return { + type: "infix", + mode: parser.mode, + replaceWith, + token + }; + } +}); +const stylArray = ["display", "text", "script", "scriptscript"]; +const delimFromValue = function (delimString) { + let delim = null; + if (delimString.length > 0) { + delim = delimString; + delim = delim === "." ? null : delim; + } + return delim; +}; +defineFunction({ + type: "genfrac", + names: ["\\genfrac"], + numArgs: 6, + allowedInArgument: true, + argTypes: ["math", "math", "size", "text", "math", "math"], + handler(_ref3, args) { + let { + parser + } = _ref3; + const numer = args[4]; + const denom = args[5]; + + // Look into the parse nodes to get the desired delimiters. + const leftNode = normalizeArgument(args[0]); + const leftDelim = leftNode.type === "atom" && leftNode.family === "open" ? delimFromValue(leftNode.text) : null; + const rightNode = normalizeArgument(args[1]); + const rightDelim = rightNode.type === "atom" && rightNode.family === "close" ? delimFromValue(rightNode.text) : null; + const barNode = assertNodeType(args[2], "size"); + let hasBarLine; + let barSize = null; + if (barNode.isBlank) { + // \genfrac acts differently than \above. + // \genfrac treats an empty size group as a signal to use a + // standard bar size. \above would see size = 0 and omit the bar. + hasBarLine = true; + } else { + barSize = barNode.value; + hasBarLine = barSize.number > 0; + } + + // Find out if we want displaystyle, textstyle, etc. + let size = null; + let styl = args[3]; + if (styl.type === "ordgroup") { + if (styl.body.length > 0) { + const textOrd = assertNodeType(styl.body[0], "textord"); + size = stylArray[Number(textOrd.text)]; + } + } else { + styl = assertNodeType(styl, "textord"); + size = stylArray[Number(styl.text)]; + } + return wrapWithStyle({ + type: "genfrac", + mode: parser.mode, + numer, + denom, + continued: false, + hasBarLine, + barSize, + leftDelim, + rightDelim + }, size); + } +}); + +// \above is an infix fraction that also defines a fraction bar size. +defineFunction({ + type: "infix", + names: ["\\above"], + numArgs: 1, + argTypes: ["size"], + infix: true, + handler(_ref4, args) { + let { + parser, + funcName, + token + } = _ref4; + return { + type: "infix", + mode: parser.mode, + replaceWith: "\\\\abovefrac", + size: assertNodeType(args[0], "size").value, + token + }; + } +}); +defineFunction({ + type: "genfrac", + names: ["\\\\abovefrac"], + numArgs: 3, + argTypes: ["math", "size", "math"], + handler: (_ref5, args) => { + let { + parser, + funcName + } = _ref5; + const numer = args[0]; + const barSize = assertNodeType(args[1], "infix").size; + if (!barSize) { + throw new Error("\\\\abovefrac expected size, but got " + String(barSize)); + } + const denom = args[2]; + const hasBarLine = barSize.number > 0; + return { + type: "genfrac", + mode: parser.mode, + numer, + denom, + continued: false, + hasBarLine, + barSize, + leftDelim: null, + rightDelim: null + }; + } +}); +;// ./src/functions/horizBrace.ts + + + + + + + + +// NOTE: Unlike most `htmlBuilder`s, this one handles not only "horizBrace", but +// also "supsub" since an over/underbrace can affect super/subscripting. +const horizBrace_htmlBuilder = (grp, options) => { + const style = options.style; + + // Pull out the `ParseNode<"horizBrace">` if `grp` is a "supsub" node. + let supSubGroup; + let group; + if (grp.type === "supsub") { + // Ref: LaTeX source2e: }}}}\limits} + // i.e. LaTeX treats the brace similar to an op and passes it + // with \limits, so we need to assign supsub style. + supSubGroup = grp.sup ? buildGroup(grp.sup, options.havingStyle(style.sup()), options) : buildGroup(grp.sub, options.havingStyle(style.sub()), options); + group = assertNodeType(grp.base, "horizBrace"); + } else { + group = assertNodeType(grp, "horizBrace"); + } + + // Build the base group + const body = buildGroup(group.base, options.havingBaseStyle(src_Style.DISPLAY)); + + // Create the stretchy element + const braceBody = stretchySvg(group, options); + + // Generate the vlist, with the appropriate kerns ┏━━━━━━━━┓ + // This first vlist contains the content and the brace: equation + let vlist; + if (group.isOver) { + vlist = makeVList({ + positionType: "firstBaseline", + children: [{ + type: "elem", + elem: body + }, { + type: "kern", + size: 0.1 + }, { + type: "elem", + elem: braceBody, + wrapperClasses: ["svg-align"] + }] + }, options); + } else { + vlist = makeVList({ + positionType: "bottom", + positionData: body.depth + 0.1 + braceBody.height, + children: [{ + type: "elem", + elem: braceBody, + wrapperClasses: ["svg-align"] + }, { + type: "kern", + size: 0.1 + }, { + type: "elem", + elem: body + }] + }, options); + } + if (supSubGroup) { + // To write the supsub, wrap the first vlist in another vlist: + // They can't all go in the same vlist, because the note might be + // wider than the equation. We want the equation to control the + // brace width. + + // note long note long note + // ┏━━━━━━━━┓ or ┏━━━┓ not ┏━━━━━━━━━┓ + // equation eqn eqn + + const vSpan = makeSpan(["minner", group.isOver ? "mover" : "munder"], [vlist], options); + if (group.isOver) { + vlist = makeVList({ + positionType: "firstBaseline", + children: [{ + type: "elem", + elem: vSpan + }, { + type: "kern", + size: 0.2 + }, { + type: "elem", + elem: supSubGroup + }] + }, options); + } else { + vlist = makeVList({ + positionType: "bottom", + positionData: vSpan.depth + 0.2 + supSubGroup.height + supSubGroup.depth, + children: [{ + type: "elem", + elem: supSubGroup + }, { + type: "kern", + size: 0.2 + }, { + type: "elem", + elem: vSpan + }] + }, options); + } + } + return makeSpan(["minner", group.isOver ? "mover" : "munder"], [vlist], options); +}; +const horizBrace_mathmlBuilder = (group, options) => { + const accentNode = stretchyMathML(group.label); + return new MathNode(group.isOver ? "mover" : "munder", [buildMathML_buildGroup(group.base, options), accentNode]); +}; + +// Horizontal stretchy braces +defineFunction({ + type: "horizBrace", + names: ["\\overbrace", "\\underbrace", "\\overbracket", "\\underbracket"], + numArgs: 1, + handler(_ref, args) { + let { + parser, + funcName + } = _ref; + return { + type: "horizBrace", + mode: parser.mode, + label: funcName, + isOver: funcName.includes("\\over"), + base: args[0] + }; + }, + htmlBuilder: horizBrace_htmlBuilder, + mathmlBuilder: horizBrace_mathmlBuilder +}); +;// ./src/functions/href.ts + + + + + + +defineFunction({ + type: "href", + names: ["\\href"], + numArgs: 2, + argTypes: ["url", "original"], + allowedInText: true, + handler: (_ref, args) => { + let { + parser + } = _ref; + const body = args[1]; + const href = assertNodeType(args[0], "url").url; + if (!parser.settings.isTrusted({ + command: "\\href", + url: href + })) { + return parser.formatUnsupportedCmd("\\href"); + } + return { + type: "href", + mode: parser.mode, + href, + body: ordargument(body) + }; + }, + htmlBuilder: (group, options) => { + const elements = buildExpression(group.body, options, false); + return makeAnchor(group.href, [], elements, options); + }, + mathmlBuilder: (group, options) => { + let math = buildExpressionRow(group.body, options); + if (!(math instanceof MathNode)) { + math = new MathNode("mrow", [math]); + } + math.setAttribute("href", group.href); + return math; + } +}); +defineFunction({ + type: "href", + names: ["\\url"], + numArgs: 1, + argTypes: ["url"], + allowedInText: true, + handler: (_ref2, args) => { + let { + parser + } = _ref2; + const href = assertNodeType(args[0], "url").url; + if (!parser.settings.isTrusted({ + command: "\\url", + url: href + })) { + return parser.formatUnsupportedCmd("\\url"); + } + const chars = []; + for (let i = 0; i < href.length; i++) { + let c = href[i]; + if (c === "~") { + c = "\\textasciitilde"; + } + chars.push({ + type: "textord", + mode: "text", + text: c + }); + } + const body = { + type: "text", + mode: parser.mode, + font: "\\texttt", + body: chars + }; + return { + type: "href", + mode: parser.mode, + href, + body: ordargument(body) + }; + } +}); +;// ./src/functions/hbox.ts + + + + + + +// \hbox is provided for compatibility with LaTeX \vcenter. +// In LaTeX, \vcenter can act only on a box, as in +// \vcenter{\hbox{$\frac{a+b}{\dfrac{c}{d}}$}} +// This function by itself doesn't do anything but prevent a soft line break. + +defineFunction({ + type: "hbox", + names: ["\\hbox"], + numArgs: 1, + argTypes: ["text"], + allowedInText: true, + primitive: true, + handler(_ref, args) { + let { + parser + } = _ref; + return { + type: "hbox", + mode: parser.mode, + body: ordargument(args[0]) + }; + }, + htmlBuilder(group, options) { + const elements = buildExpression(group.body, options.withFont(''), false); + return makeFragment(elements); + }, + mathmlBuilder(group, options) { + return new MathNode("mrow", buildMathML_buildExpression(group.body, options.withFont(''))); + } +}); +;// ./src/functions/html.ts + + + + + + +defineFunction({ + type: "html", + names: ["\\htmlClass", "\\htmlId", "\\htmlStyle", "\\htmlData"], + numArgs: 2, + argTypes: ["raw", "original"], + allowedInText: true, + handler: (_ref, args) => { + let { + parser, + funcName, + token + } = _ref; + const value = assertNodeType(args[0], "raw").string; + const body = args[1]; + if (parser.settings.strict) { + parser.settings.reportNonstrict("htmlExtension", "HTML extension is disabled on strict mode"); + } + let trustContext; + const attributes = {}; + switch (funcName) { + case "\\htmlClass": + attributes.class = value; + trustContext = { + command: "\\htmlClass", + class: value + }; + break; + case "\\htmlId": + attributes.id = value; + trustContext = { + command: "\\htmlId", + id: value + }; + break; + case "\\htmlStyle": + attributes.style = value; + trustContext = { + command: "\\htmlStyle", + style: value + }; + break; + case "\\htmlData": + { + const data = value.split(","); + for (let i = 0; i < data.length; i++) { + const item = data[i]; + const firstEquals = item.indexOf("="); + if (firstEquals < 0) { + throw new src_ParseError("\\htmlData key/value '" + item + "'" + " missing equals sign"); + } + const key = item.slice(0, firstEquals); + const value = item.slice(firstEquals + 1); + attributes["data-" + key.trim()] = value; + } + trustContext = { + command: "\\htmlData", + attributes + }; + break; + } + default: + throw new Error("Unrecognized html command"); + } + if (!parser.settings.isTrusted(trustContext)) { + return parser.formatUnsupportedCmd(funcName); + } + return { + type: "html", + mode: parser.mode, + attributes, + body: ordargument(body) + }; + }, + htmlBuilder: (group, options) => { + const elements = buildExpression(group.body, options, false); + const classes = ["enclosing"]; + if (group.attributes.class) { + classes.push(...group.attributes.class.trim().split(/\s+/)); + } + const span = makeSpan(classes, elements, options); + for (const attr in group.attributes) { + if (attr !== "class" && group.attributes.hasOwnProperty(attr)) { + span.setAttribute(attr, group.attributes[attr]); + } + } + return span; + }, + mathmlBuilder: (group, options) => { + return buildExpressionRow(group.body, options); + } +}); +;// ./src/functions/htmlmathml.ts + + + + +defineFunction({ + type: "htmlmathml", + names: ["\\html@mathml"], + numArgs: 2, + allowedInArgument: true, + allowedInText: true, + handler: (_ref, args) => { + let { + parser + } = _ref; + return { + type: "htmlmathml", + mode: parser.mode, + html: ordargument(args[0]), + mathml: ordargument(args[1]) + }; + }, + htmlBuilder: (group, options) => { + const elements = buildExpression(group.html, options, false); + return makeFragment(elements); + }, + mathmlBuilder: (group, options) => { + return buildExpressionRow(group.mathml, options); + } +}); +;// ./src/functions/includegraphics.ts + + + + + + +const sizeData = function (str) { + if (/^[-+]? *(\d+(\.\d*)?|\.\d+)$/.test(str)) { + // str is a number with no unit specified. + // default unit is bp, per graphix package. + return { + number: +str, + unit: "bp" + }; + } else { + const match = /([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(str); + if (!match) { + throw new src_ParseError("Invalid size: '" + str + "' in \\includegraphics"); + } + const data = { + number: +(match[1] + match[2]), + // sign + magnitude, cast to number + unit: match[3] + }; + if (!validUnit(data)) { + throw new src_ParseError("Invalid unit: '" + data.unit + "' in \\includegraphics."); + } + return data; + } +}; +defineFunction({ + type: "includegraphics", + names: ["\\includegraphics"], + numArgs: 1, + numOptionalArgs: 1, + argTypes: ["raw", "url"], + allowedInText: false, + handler: (_ref, args, optArgs) => { + let { + parser + } = _ref; + let width = { + number: 0, + unit: "em" + }; + let height = { + number: 0.9, + unit: "em" + }; // sorta character sized. + let totalheight = { + number: 0, + unit: "em" + }; + let alt = ""; + if (optArgs[0]) { + const attributeStr = assertNodeType(optArgs[0], "raw").string; + + // Parser.js does not parse key/value pairs. We get a string. + const attributes = attributeStr.split(","); + for (let i = 0; i < attributes.length; i++) { + const keyVal = attributes[i].split("="); + if (keyVal.length === 2) { + const str = keyVal[1].trim(); + switch (keyVal[0].trim()) { + case "alt": + alt = str; + break; + case "width": + width = sizeData(str); + break; + case "height": + height = sizeData(str); + break; + case "totalheight": + totalheight = sizeData(str); + break; + default: + throw new src_ParseError("Invalid key: '" + keyVal[0] + "' in \\includegraphics."); + } + } + } + } + const src = assertNodeType(args[0], "url").url; + if (alt === "") { + // No alt given. Use the file name. Strip away the path. + alt = src; + alt = alt.replace(/^.*[\\/]/, ''); + alt = alt.substring(0, alt.lastIndexOf('.')); + } + if (!parser.settings.isTrusted({ + command: "\\includegraphics", + url: src + })) { + return parser.formatUnsupportedCmd("\\includegraphics"); + } + return { + type: "includegraphics", + mode: parser.mode, + alt: alt, + width: width, + height: height, + totalheight: totalheight, + src: src + }; + }, + htmlBuilder: (group, options) => { + const height = calculateSize(group.height, options); + let depth = 0; + if (group.totalheight.number > 0) { + depth = calculateSize(group.totalheight, options) - height; + } + let width = 0; + if (group.width.number > 0) { + width = calculateSize(group.width, options); + } + const style = { + height: makeEm(height + depth) + }; + if (width > 0) { + style.width = makeEm(width); + } + if (depth > 0) { + style.verticalAlign = makeEm(-depth); + } + const node = new Img(group.src, group.alt, style); + node.height = height; + node.depth = depth; + return node; + }, + mathmlBuilder: (group, options) => { + const node = new MathNode("mglyph", []); + node.setAttribute("alt", group.alt); + const height = calculateSize(group.height, options); + let depth = 0; + if (group.totalheight.number > 0) { + depth = calculateSize(group.totalheight, options) - height; + node.setAttribute("valign", makeEm(-depth)); + } + node.setAttribute("height", makeEm(height + depth)); + if (group.width.number > 0) { + const width = calculateSize(group.width, options); + node.setAttribute("width", makeEm(width)); + } + node.setAttribute("src", group.src); + return node; + } +}); +;// ./src/functions/kern.ts +// Horizontal spacing commands + + + + + + + +// TODO: \hskip and \mskip should support plus and minus in lengths + +defineFunction({ + type: "kern", + names: ["\\kern", "\\mkern", "\\hskip", "\\mskip"], + numArgs: 1, + argTypes: ["size"], + primitive: true, + allowedInText: true, + handler(_ref, args) { + let { + parser, + funcName + } = _ref; + const size = assertNodeType(args[0], "size"); + if (parser.settings.strict) { + const mathFunction = funcName[1] === 'm'; // \mkern, \mskip + const muUnit = size.value.unit === 'mu'; + if (mathFunction) { + if (!muUnit) { + parser.settings.reportNonstrict("mathVsTextUnits", "LaTeX's " + funcName + " supports only mu units, " + ("not " + size.value.unit + " units")); + } + if (parser.mode !== "math") { + parser.settings.reportNonstrict("mathVsTextUnits", "LaTeX's " + funcName + " works only in math mode"); + } + } else { + // !mathFunction + if (muUnit) { + parser.settings.reportNonstrict("mathVsTextUnits", "LaTeX's " + funcName + " doesn't support mu units"); + } + } + } + return { + type: "kern", + mode: parser.mode, + dimension: size.value + }; + }, + htmlBuilder(group, options) { + return makeGlue(group.dimension, options); + }, + mathmlBuilder(group, options) { + const dimension = calculateSize(group.dimension, options); + return new SpaceNode(dimension); + } +}); +;// ./src/functions/lap.ts +// Horizontal overlap functions + + + + + + +defineFunction({ + type: "lap", + names: ["\\mathllap", "\\mathrlap", "\\mathclap"], + numArgs: 1, + allowedInText: true, + handler: (_ref, args) => { + let { + parser, + funcName + } = _ref; + const body = args[0]; + return { + type: "lap", + mode: parser.mode, + alignment: funcName.slice(5), + body + }; + }, + htmlBuilder: (group, options) => { + // mathllap, mathrlap, mathclap + let inner; + if (group.alignment === "clap") { + // ref: https://www.math.lsu.edu/~aperlis/publications/mathclap/ + inner = makeSpan([], [buildGroup(group.body, options)]); + // wrap, since CSS will center a .clap > .inner > span + inner = makeSpan(["inner"], [inner], options); + } else { + inner = makeSpan(["inner"], [buildGroup(group.body, options)]); + } + const fix = makeSpan(["fix"], []); + let node = makeSpan([group.alignment], [inner, fix], options); + + // At this point, we have correctly set horizontal alignment of the + // two items involved in the lap. + // Next, use a strut to set the height of the HTML bounding box. + // Otherwise, a tall argument may be misplaced. + // This code resolved issue #1153 + const strut = makeSpan(["strut"]); + strut.style.height = makeEm(node.height + node.depth); + if (node.depth) { + strut.style.verticalAlign = makeEm(-node.depth); + } + node.children.unshift(strut); + + // Next, prevent vertical misplacement when next to something tall. + // This code resolves issue #1234 + node = makeSpan(["thinbox"], [node], options); + return makeSpan(["mord", "vbox"], [node], options); + }, + mathmlBuilder: (group, options) => { + // mathllap, mathrlap, mathclap + const node = new MathNode("mpadded", [buildMathML_buildGroup(group.body, options)]); + if (group.alignment !== "rlap") { + const offset = group.alignment === "llap" ? "-1" : "-0.5"; + node.setAttribute("lspace", offset + "width"); + } + node.setAttribute("width", "0px"); + return node; + } +}); +;// ./src/functions/math.ts + + + +// Switching from text mode back to math mode +defineFunction({ + type: "styling", + names: ["\\(", "$"], + numArgs: 0, + allowedInText: true, + allowedInMath: false, + handler(_ref, args) { + let { + funcName, + parser + } = _ref; + const outerMode = parser.mode; + parser.switchMode("math"); + const close = funcName === "\\(" ? "\\)" : "$"; + const body = parser.parseExpression(false, close); + parser.expect(close); + parser.switchMode(outerMode); + return { + type: "styling", + mode: parser.mode, + style: "text", + resetFont: true, + body + }; + } +}); + +// Check for extra closing math delimiters +defineFunction({ + type: "text", + // Doesn't matter what this is. + names: ["\\)", "\\]"], + numArgs: 0, + allowedInText: true, + allowedInMath: false, + handler(context, args) { + throw new src_ParseError("Mismatched " + context.funcName); + } +}); +;// ./src/functions/mathchoice.ts + + + + + +const chooseMathStyle = (group, options) => { + switch (options.style.size) { + case src_Style.DISPLAY.size: + return group.display; + case src_Style.TEXT.size: + return group.text; + case src_Style.SCRIPT.size: + return group.script; + case src_Style.SCRIPTSCRIPT.size: + return group.scriptscript; + default: + return group.text; + } +}; +defineFunction({ + type: "mathchoice", + names: ["\\mathchoice"], + numArgs: 4, + primitive: true, + handler: (_ref, args) => { + let { + parser + } = _ref; + return { + type: "mathchoice", + mode: parser.mode, + display: ordargument(args[0]), + text: ordargument(args[1]), + script: ordargument(args[2]), + scriptscript: ordargument(args[3]) + }; + }, + htmlBuilder: (group, options) => { + const body = chooseMathStyle(group, options); + const elements = buildExpression(body, options, false); + return makeFragment(elements); + }, + mathmlBuilder: (group, options) => { + const body = chooseMathStyle(group, options); + return buildExpressionRow(body, options); + } +}); +;// ./src/functions/utils/assembleSupSub.ts + + + + + +// For an operator with limits, assemble the base, sup, and sub into a span. + +const assembleSupSub = (base, supGroup, subGroup, options, style, slant, baseShift) => { + base = makeSpan([], [base]); + const subIsSingleCharacter = subGroup && isCharacterBox(subGroup); + let sub; + let sup; + // We manually have to handle the superscripts and subscripts. This, + // aside from the kern calculations, is copied from supsub. + if (supGroup) { + const elem = buildGroup(supGroup, options.havingStyle(style.sup()), options); + sup = { + elem, + kern: Math.max(options.fontMetrics().bigOpSpacing1, options.fontMetrics().bigOpSpacing3 - elem.depth) + }; + } + if (subGroup) { + const elem = buildGroup(subGroup, options.havingStyle(style.sub()), options); + sub = { + elem, + kern: Math.max(options.fontMetrics().bigOpSpacing2, options.fontMetrics().bigOpSpacing4 - elem.height) + }; + } + + // Build the final group as a vlist of the possible subscript, base, + // and possible superscript. + let finalGroup; + if (sup && sub) { + const bottom = options.fontMetrics().bigOpSpacing5 + sub.elem.height + sub.elem.depth + sub.kern + base.depth + baseShift; + finalGroup = makeVList({ + positionType: "bottom", + positionData: bottom, + children: [{ + type: "kern", + size: options.fontMetrics().bigOpSpacing5 + }, { + type: "elem", + elem: sub.elem, + marginLeft: makeEm(-slant) + }, { + type: "kern", + size: sub.kern + }, { + type: "elem", + elem: base + }, { + type: "kern", + size: sup.kern + }, { + type: "elem", + elem: sup.elem, + marginLeft: makeEm(slant) + }, { + type: "kern", + size: options.fontMetrics().bigOpSpacing5 + }] + }, options); + } else if (sub) { + const top = base.height - baseShift; + + // Shift the limits by the slant of the symbol. Note + // that we are supposed to shift the limits by 1/2 of the slant, + // but since we are centering the limits adding a full slant of + // margin will shift by 1/2 that. + finalGroup = makeVList({ + positionType: "top", + positionData: top, + children: [{ + type: "kern", + size: options.fontMetrics().bigOpSpacing5 + }, { + type: "elem", + elem: sub.elem, + marginLeft: makeEm(-slant) + }, { + type: "kern", + size: sub.kern + }, { + type: "elem", + elem: base + }] + }, options); + } else if (sup) { + const bottom = base.depth + baseShift; + finalGroup = makeVList({ + positionType: "bottom", + positionData: bottom, + children: [{ + type: "elem", + elem: base + }, { + type: "kern", + size: sup.kern + }, { + type: "elem", + elem: sup.elem, + marginLeft: makeEm(slant) + }, { + type: "kern", + size: options.fontMetrics().bigOpSpacing5 + }] + }, options); + } else { + // This case probably shouldn't occur (this would mean the + // supsub was sending us a group with no superscript or + // subscript) but be safe. + return base; + } + const parts = [finalGroup]; + if (sub && slant !== 0 && !subIsSingleCharacter) { + // A negative margin-left was applied to the lower limit. + // Avoid an overlap by placing a spacer on the left on the group. + const spacer = makeSpan(["mspace"], [], options); + spacer.style.marginRight = makeEm(slant); + parts.unshift(spacer); + } + return makeSpan(["mop", "op-limits"], parts, options); +}; +;// ./src/functions/op.ts +// Limits, symbols + + + + + + + + + + +// Most operators have a large successor symbol, but these don't. +const noSuccessor = new Set(["\\smallint"]); + +// NOTE: Unlike most `htmlBuilder`s, this one handles not only "op", but also +// "supsub" since some of them (like \int) can affect super/subscripting. +const op_htmlBuilder = (grp, options) => { + // Operators are handled in the TeXbook pg. 443-444, rule 13(a). + let supGroup; + let subGroup; + let hasLimits = false; + let group; + if (grp.type === "supsub") { + // If we have limits, supsub will pass us its group to handle. Pull + // out the superscript and subscript and set the group to the op in + // its base. + supGroup = grp.sup; + subGroup = grp.sub; + group = assertNodeType(grp.base, "op"); + hasLimits = true; + } else { + group = assertNodeType(grp, "op"); + } + const style = options.style; + let large = false; + if (style.size === src_Style.DISPLAY.size && group.symbol && !noSuccessor.has(group.name)) { + // Most symbol operators get larger in displaystyle (rule 13) + large = true; + } + let base; + // Italic correction from the symbol glyph, captured before the symbol + // may be wrapped in a vlist (for \oiint/\oiiint). Stays 0 for non-symbol ops. + let symbolItalic; + if (group.symbol) { + // If this is a symbol, create the symbol. + const fontName = large ? "Size2-Regular" : "Size1-Regular"; + let stash = ""; + if (group.name === "\\oiint" || group.name === "\\oiiint") { + // No font glyphs yet, so use a glyph w/o the oval. + // TODO: When font glyphs are available, delete this code. + stash = group.name.slice(1); + group.name = stash === "oiint" ? "\\iint" : "\\iiint"; + } + base = makeSymbol(group.name, fontName, "math", options, ["mop", "op-symbol", large ? "large-op" : "small-op"]); + symbolItalic = base.italic; + if (stash.length > 0) { + // We're in \oiint or \oiiint. Overlay the oval. + // TODO: When font glyphs are available, delete this code. + const oval = staticSvg(stash + "Size" + (large ? "2" : "1"), options); + base = makeVList({ + positionType: "individualShift", + children: [{ + type: "elem", + elem: base, + shift: 0 + }, { + type: "elem", + elem: oval, + shift: large ? 0.08 : 0 + }] + }, options); + group.name = "\\" + stash; + base.classes.unshift("mop"); + // Carry the italic correction from the original symbol to the + // vlist wrapper so supsub can use it for subscript positioning. + base.italic = symbolItalic; + } + } else if (group.body) { + // If this is a list, compose that list. + const inner = buildExpression(group.body, options, true); + if (inner.length === 1 && inner[0] instanceof SymbolNode) { + base = inner[0]; + base.classes[0] = "mop"; // replace old mclass + } else { + base = makeSpan(["mop"], inner, options); + } + } else { + // Otherwise, this is a text operator. Build the text from the + // operator's name. + const output = []; + for (let i = 1; i < group.name.length; i++) { + output.push(mathsym(group.name[i], group.mode, options)); + } + base = makeSpan(["mop"], output, options); + } + + // If content of op is a single symbol, shift it vertically. + let baseShift = 0; + let slant = 0; + if ((base instanceof SymbolNode || group.name === "\\oiint" || group.name === "\\oiiint") && !group.suppressBaseShift) { + var _base$italic; + // We suppress the shift of the base of \overset and \underset. Otherwise, + // shift the symbol so its center lies on the axis (rule 13). It + // appears that our fonts have the centers of the symbols already + // almost on the axis, so these numbers are very small. Note we + // don't actually apply this here, but instead it is used either in + // the vlist creation or separately when there are no limits. + baseShift = (base.height - base.depth) / 2 - options.fontMetrics().axisHeight; + + // The slant of the symbol is just its italic correction. + // SymbolNode carries .italic natively; Span (for \oiint/\oiiint) + // only has it set when nonzero, so default to 0. + slant = (_base$italic = base.italic) != null ? _base$italic : 0; + } + if (hasLimits) { + return assembleSupSub(base, supGroup, subGroup, options, style, slant, baseShift); + } else { + if (baseShift) { + base.style.position = "relative"; + base.style.top = makeEm(baseShift); + } + return base; + } +}; +const op_mathmlBuilder = (group, options) => { + let node; + if (group.symbol) { + // This is a symbol. Just add the symbol. + node = new MathNode("mo", [makeText(group.name, group.mode)]); + if (noSuccessor.has(group.name)) { + node.setAttribute("largeop", "false"); + } + } else if (group.body) { + // This is an operator with children. Add them. + node = new MathNode("mo", buildMathML_buildExpression(group.body, options)); + } else { + // This is a text operator. Add all the characters from the + // operator's name. + node = new MathNode("mi", [new TextNode(group.name.slice(1))]); + // Append an . + // ref: https://www.w3.org/TR/REC-MathML/chap3_2.html#sec3.2.4 + const operator = new MathNode("mo", [makeText("\u2061", "text")]); + if (group.parentIsSupSub) { + node = new MathNode("mrow", [node, operator]); + } else { + node = newDocumentFragment([node, operator]); + } + } + return node; +}; +const singleCharBigOps = { + "\u220F": "\\prod", + "\u2210": "\\coprod", + "\u2211": "\\sum", + "\u22c0": "\\bigwedge", + "\u22c1": "\\bigvee", + "\u22c2": "\\bigcap", + "\u22c3": "\\bigcup", + "\u2a00": "\\bigodot", + "\u2a01": "\\bigoplus", + "\u2a02": "\\bigotimes", + "\u2a04": "\\biguplus", + "\u2a06": "\\bigsqcup" +}; +defineFunction({ + type: "op", + names: ["\\coprod", "\\bigvee", "\\bigwedge", "\\biguplus", "\\bigcap", "\\bigcup", "\\intop", "\\prod", "\\sum", "\\bigotimes", "\\bigoplus", "\\bigodot", "\\bigsqcup", "\\smallint", "\u220F", "\u2210", "\u2211", "\u22c0", "\u22c1", "\u22c2", "\u22c3", "\u2a00", "\u2a01", "\u2a02", "\u2a04", "\u2a06"], + numArgs: 0, + handler: (_ref, args) => { + let { + parser, + funcName + } = _ref; + let fName = funcName; + if (fName.length === 1) { + fName = singleCharBigOps[fName]; + } + return { + type: "op", + mode: parser.mode, + limits: true, + parentIsSupSub: false, + symbol: true, + name: fName + }; + }, + htmlBuilder: op_htmlBuilder, + mathmlBuilder: op_mathmlBuilder +}); +defineFunction({ + type: "op", + names: ["\\mathop"], + numArgs: 1, + primitive: true, + handler: (_ref2, args) => { + let { + parser + } = _ref2; + const body = args[0]; + return { + type: "op", + mode: parser.mode, + limits: false, + parentIsSupSub: false, + symbol: false, + body: ordargument(body) + }; + } +}); + +// There are 2 flags for operators; whether they produce limits in +// displaystyle, and whether they are symbols and should grow in +// displaystyle. These four groups cover the four possible choices. +const singleCharIntegrals = { + "\u222b": "\\int", + "\u222c": "\\iint", + "\u222d": "\\iiint", + "\u222e": "\\oint", + "\u222f": "\\oiint", + "\u2230": "\\oiiint" +}; + +// No limits, not symbols +defineFunction({ + type: "op", + names: ["\\arcsin", "\\arccos", "\\arctan", "\\arctg", "\\arcctg", "\\arg", "\\ch", "\\cos", "\\cosec", "\\cosh", "\\cot", "\\cotg", "\\coth", "\\csc", "\\ctg", "\\cth", "\\deg", "\\dim", "\\exp", "\\hom", "\\ker", "\\lg", "\\ln", "\\log", "\\sec", "\\sin", "\\sinh", "\\sh", "\\tan", "\\tanh", "\\tg", "\\th"], + numArgs: 0, + handler(_ref3) { + let { + parser, + funcName + } = _ref3; + return { + type: "op", + mode: parser.mode, + limits: false, + parentIsSupSub: false, + symbol: false, + name: funcName + }; + } +}); + +// Limits, not symbols +defineFunction({ + type: "op", + names: ["\\det", "\\gcd", "\\inf", "\\lim", "\\max", "\\min", "\\Pr", "\\sup"], + numArgs: 0, + handler(_ref4) { + let { + parser, + funcName + } = _ref4; + return { + type: "op", + mode: parser.mode, + limits: true, + parentIsSupSub: false, + symbol: false, + name: funcName + }; + } +}); + +// No limits, symbols +defineFunction({ + type: "op", + names: ["\\int", "\\iint", "\\iiint", "\\oint", "\\oiint", "\\oiiint", "\u222b", "\u222c", "\u222d", "\u222e", "\u222f", "\u2230"], + numArgs: 0, + allowedInArgument: true, + handler(_ref5) { + let { + parser, + funcName + } = _ref5; + let fName = funcName; + if (fName.length === 1) { + fName = singleCharIntegrals[fName]; + } + return { + type: "op", + mode: parser.mode, + limits: false, + parentIsSupSub: false, + symbol: true, + name: fName + }; + } +}); +;// ./src/functions/operatorname.ts + + + + + + + + + +// NOTE: Unlike most `htmlBuilder`s, this one handles not only +// "operatorname", but also "supsub" since \operatorname* can +// affect super/subscripting. +const operatorname_htmlBuilder = (grp, options) => { + // Operators are handled in the TeXbook pg. 443-444, rule 13(a). + let supGroup; + let subGroup; + let hasLimits = false; + let group; + if (grp.type === "supsub") { + // If we have limits, supsub will pass us its group to handle. Pull + // out the superscript and subscript and set the group to the op in + // its base. + supGroup = grp.sup; + subGroup = grp.sub; + group = assertNodeType(grp.base, "operatorname"); + hasLimits = true; + } else { + group = assertNodeType(grp, "operatorname"); + } + let base; + if (group.body.length > 0) { + const body = group.body.map(child => { + const childText = "text" in child ? child.text : undefined; + if (typeof childText === "string") { + return { + type: "textord", + mode: child.mode, + text: childText + }; + } else { + return child; + } + }); + + // Consolidate function names into symbol characters. + const expression = buildExpression(body, options.withFont("mathrm"), true); + for (let i = 0; i < expression.length; i++) { + const child = expression[i]; + if (child instanceof SymbolNode) { + // Per amsopn package, + // change minus to hyphen and \ast to asterisk + child.text = child.text.replace(/\u2212/, "-").replace(/\u2217/, "*"); + } + } + base = makeSpan(["mop"], expression, options); + } else { + base = makeSpan(["mop"], [], options); + } + if (hasLimits) { + return assembleSupSub(base, supGroup, subGroup, options, options.style, 0, 0); + } else { + return base; + } +}; +const operatorname_mathmlBuilder = (group, options) => { + // The steps taken here are similar to the html version. + let expression = buildMathML_buildExpression(group.body, options.withFont("mathrm")); + + // Is expression a string or has it something like a fraction? + let isAllString = true; // default + for (let i = 0; i < expression.length; i++) { + const node = expression[i]; + if (node instanceof SpaceNode) { + // Do nothing + } else if (node instanceof MathNode) { + switch (node.type) { + case "mi": + case "mn": + case "mspace": + case "mtext": + break; + // Do nothing yet. + case "mo": + { + const child = node.children[0]; + if (node.children.length === 1 && child instanceof TextNode) { + child.text = child.text.replace(/\u2212/, "-").replace(/\u2217/, "*"); + } else { + isAllString = false; + } + break; + } + default: + isAllString = false; + } + } else { + isAllString = false; + } + } + if (isAllString) { + // Write a single TextNode instead of multiple nested tags. + const word = expression.map(node => node.toText()).join(""); + expression = [new TextNode(word)]; + } + const identifier = new MathNode("mi", expression); + identifier.setAttribute("mathvariant", "normal"); + + // \u2061 is the same as ⁡ + // ref: https://www.w3schools.com/charsets/ref_html_entities_a.asp + const operator = new MathNode("mo", [makeText("\u2061", "text")]); + if (group.parentIsSupSub) { + return new MathNode("mrow", [identifier, operator]); + } else { + return newDocumentFragment([identifier, operator]); + } +}; + +// \operatorname +// amsopn.dtx: \mathop{#1\kern\z@\operator@font#3}\newmcodes@ +defineFunction({ + type: "operatorname", + names: ["\\operatorname@", "\\operatornamewithlimits"], + numArgs: 1, + handler: (_ref, args) => { + let { + parser, + funcName + } = _ref; + const body = args[0]; + return { + type: "operatorname", + mode: parser.mode, + body: ordargument(body), + alwaysHandleSupSub: funcName === "\\operatornamewithlimits", + limits: false, + parentIsSupSub: false + }; + }, + htmlBuilder: operatorname_htmlBuilder, + mathmlBuilder: operatorname_mathmlBuilder +}); +defineMacro("\\operatorname", "\\@ifstar\\operatornamewithlimits\\operatorname@"); +;// ./src/functions/ordgroup.ts + + + + +defineFunctionBuilders({ + type: "ordgroup", + htmlBuilder(group, options) { + if (group.semisimple) { + return makeFragment(buildExpression(group.body, options, false)); + } + return makeSpan(["mord"], buildExpression(group.body, options, true), options); + }, + mathmlBuilder(group, options) { + return buildExpressionRow(group.body, options, true); + } +}); +;// ./src/functions/overline.ts + + + + + +defineFunction({ + type: "overline", + names: ["\\overline"], + numArgs: 1, + handler(_ref, args) { + let { + parser + } = _ref; + const body = args[0]; + return { + type: "overline", + mode: parser.mode, + body + }; + }, + htmlBuilder(group, options) { + // Overlines are handled in the TeXbook pg 443, Rule 9. + + // Build the inner group in the cramped style. + const innerGroup = buildGroup(group.body, options.havingCrampedStyle()); + + // Create the line above the body + const line = makeLineSpan("overline-line", options); + + // Generate the vlist, with the appropriate kerns + const defaultRuleThickness = options.fontMetrics().defaultRuleThickness; + const vlist = makeVList({ + positionType: "firstBaseline", + children: [{ + type: "elem", + elem: innerGroup + }, { + type: "kern", + size: 3 * defaultRuleThickness + }, { + type: "elem", + elem: line + }, { + type: "kern", + size: defaultRuleThickness + }] + }, options); + return makeSpan(["mord", "overline"], [vlist], options); + }, + mathmlBuilder(group, options) { + const operator = new MathNode("mo", [new TextNode("\u203e")]); + operator.setAttribute("stretchy", "true"); + const node = new MathNode("mover", [buildMathML_buildGroup(group.body, options), operator]); + node.setAttribute("accent", "true"); + return node; + } +}); +;// ./src/functions/phantom.ts + + + + + + +defineFunction({ + type: "phantom", + names: ["\\phantom"], + numArgs: 1, + allowedInText: true, + handler: (_ref, args) => { + let { + parser + } = _ref; + const body = args[0]; + return { + type: "phantom", + mode: parser.mode, + body: ordargument(body) + }; + }, + htmlBuilder: (group, options) => { + const elements = buildExpression(group.body, options.withPhantom(), false); + + // \phantom isn't supposed to affect the elements it contains. + // See "color" for more details. + return makeFragment(elements); + }, + mathmlBuilder: (group, options) => { + const inner = buildMathML_buildExpression(group.body, options); + return new MathNode("mphantom", inner); + } +}); +defineMacro("\\hphantom", "\\smash{\\phantom{#1}}"); +defineFunction({ + type: "vphantom", + names: ["\\vphantom"], + numArgs: 1, + allowedInText: true, + handler: (_ref2, args) => { + let { + parser + } = _ref2; + const body = args[0]; + return { + type: "vphantom", + mode: parser.mode, + body + }; + }, + htmlBuilder: (group, options) => { + const inner = makeSpan(["inner"], [buildGroup(group.body, options.withPhantom())]); + const fix = makeSpan(["fix"], []); + return makeSpan(["mord", "rlap"], [inner, fix], options); + }, + mathmlBuilder: (group, options) => { + const inner = buildMathML_buildExpression(ordargument(group.body), options); + const phantom = new MathNode("mphantom", inner); + const node = new MathNode("mpadded", [phantom]); + node.setAttribute("width", "0px"); + return node; + } +}); +;// ./src/functions/raisebox.ts + + + + + + + + +// Box manipulation +defineFunction({ + type: "raisebox", + names: ["\\raisebox"], + numArgs: 2, + argTypes: ["size", "hbox"], + allowedInText: true, + handler(_ref, args) { + let { + parser + } = _ref; + const amount = assertNodeType(args[0], "size").value; + const body = args[1]; + return { + type: "raisebox", + mode: parser.mode, + dy: amount, + body + }; + }, + htmlBuilder(group, options) { + const body = buildGroup(group.body, options); + const dy = calculateSize(group.dy, options); + return makeVList({ + positionType: "shift", + positionData: -dy, + children: [{ + type: "elem", + elem: body + }] + }, options); + }, + mathmlBuilder(group, options) { + const node = new MathNode("mpadded", [buildMathML_buildGroup(group.body, options)]); + const dy = group.dy.number + group.dy.unit; + node.setAttribute("voffset", dy); + return node; + } +}); +;// ./src/functions/relax.ts + +defineFunction({ + type: "internal", + names: ["\\relax"], + numArgs: 0, + allowedInText: true, + allowedInArgument: true, + handler(_ref) { + let { + parser + } = _ref; + return { + type: "internal", + mode: parser.mode + }; + } +}); +;// ./src/functions/rule.ts + + + + + +defineFunction({ + type: "rule", + names: ["\\rule"], + numArgs: 2, + numOptionalArgs: 1, + allowedInText: true, + allowedInMath: true, + argTypes: ["size", "size", "size"], + handler(_ref, args, optArgs) { + let { + parser + } = _ref; + const shift = optArgs[0]; + const width = assertNodeType(args[0], "size"); + const height = assertNodeType(args[1], "size"); + return { + type: "rule", + mode: parser.mode, + shift: shift && assertNodeType(shift, "size").value, + width: width.value, + height: height.value + }; + }, + htmlBuilder(group, options) { + // Make an empty span for the rule + const rule = makeSpan(["mord", "rule"], [], options); + + // Calculate the shift, width, and height of the rule, and account for units + const width = calculateSize(group.width, options); + const height = calculateSize(group.height, options); + const shift = group.shift ? calculateSize(group.shift, options) : 0; + + // Style the rule to the right size + rule.style.borderRightWidth = makeEm(width); + rule.style.borderTopWidth = makeEm(height); + rule.style.bottom = makeEm(shift); + + // Record the height and width + rule.width = width; + rule.height = height + shift; + rule.depth = -shift; + // Font size is the number large enough that the browser will + // reserve at least `absHeight` space above the baseline. + // The 1.125 factor was empirically determined + rule.maxFontSize = height * 1.125 * options.sizeMultiplier; + return rule; + }, + mathmlBuilder(group, options) { + const width = calculateSize(group.width, options); + const height = calculateSize(group.height, options); + const shift = group.shift ? calculateSize(group.shift, options) : 0; + const color = options.color && options.getColor() || "black"; + const rule = new MathNode("mspace"); + rule.setAttribute("mathbackground", color); + rule.setAttribute("width", makeEm(width)); + rule.setAttribute("height", makeEm(height)); + const wrapper = new MathNode("mpadded", [rule]); + if (shift >= 0) { + wrapper.setAttribute("height", makeEm(shift)); + } else { + wrapper.setAttribute("height", makeEm(shift)); + wrapper.setAttribute("depth", makeEm(-shift)); + } + wrapper.setAttribute("voffset", makeEm(shift)); + return wrapper; + } +}); +;// ./src/functions/sizing.ts + + + + + + +function sizingGroup(value, options, baseOptions) { + const inner = buildExpression(value, options, false); + const multiplier = options.sizeMultiplier / baseOptions.sizeMultiplier; + + // Add size-resetting classes to the inner list and set maxFontSize + // manually. Handle nested size changes. + for (let i = 0; i < inner.length; i++) { + const pos = inner[i].classes.indexOf("sizing"); + if (pos < 0) { + Array.prototype.push.apply(inner[i].classes, options.sizingClasses(baseOptions)); + } else if (inner[i].classes[pos + 1] === "reset-size" + options.size) { + // This is a nested size change: e.g., inner[i] is the "b" in + // `\Huge a \small b`. Override the old size (the `reset-` class) + // but not the new size. + inner[i].classes[pos + 1] = "reset-size" + baseOptions.size; + } + inner[i].height *= multiplier; + inner[i].depth *= multiplier; + } + return makeFragment(inner); +} +const sizeFuncs = ["\\tiny", "\\sixptsize", "\\scriptsize", "\\footnotesize", "\\small", "\\normalsize", "\\large", "\\Large", "\\LARGE", "\\huge", "\\Huge"]; +const sizing_htmlBuilder = (group, options) => { + // Handle sizing operators like \Huge. Real TeX doesn't actually allow + // these functions inside of math expressions, so we do some special + // handling. + const newOptions = options.havingSize(group.size); + return sizingGroup(group.body, newOptions, options); +}; +defineFunction({ + type: "sizing", + names: sizeFuncs, + numArgs: 0, + allowedInText: true, + handler: (_ref, args) => { + let { + breakOnTokenText, + funcName, + parser + } = _ref; + const body = parser.parseExpression(false, breakOnTokenText); + return { + type: "sizing", + mode: parser.mode, + // Figure out what size to use based on the list of functions above + size: sizeFuncs.indexOf(funcName) + 1, + body + }; + }, + htmlBuilder: sizing_htmlBuilder, + mathmlBuilder: (group, options) => { + const newOptions = options.havingSize(group.size); + const inner = buildMathML_buildExpression(group.body, newOptions); + const node = new MathNode("mstyle", inner); + + // TODO(emily): This doesn't produce the correct size for nested size + // changes, because we don't keep state of what style we're currently + // in, so we can't reset the size to normal before changing it. Now + // that we're passing an options parameter we should be able to fix + // this. + node.setAttribute("mathsize", makeEm(newOptions.sizeMultiplier)); + return node; + } +}); +;// ./src/functions/smash.ts +// smash, with optional [tb], as in AMS + + + + + + +defineFunction({ + type: "smash", + names: ["\\smash"], + numArgs: 1, + numOptionalArgs: 1, + allowedInText: true, + handler: (_ref, args, optArgs) => { + let { + parser + } = _ref; + let smashHeight = false; + let smashDepth = false; + const tbArg = optArgs[0] && assertNodeType(optArgs[0], "ordgroup"); + if (tbArg) { + // Optional [tb] argument is engaged. + // ref: amsmath: \renewcommand{\smash}[1][tb]{% + // def\mb@t{\ht}\def\mb@b{\dp}\def\mb@tb{\ht\z@\z@\dp}% + let letter; + for (let i = 0; i < tbArg.body.length; ++i) { + const node = tbArg.body[i]; + letter = assertSymbolNodeType(node).text; + if (letter === "t") { + smashHeight = true; + } else if (letter === "b") { + smashDepth = true; + } else { + smashHeight = false; + smashDepth = false; + break; + } + } + } else { + smashHeight = true; + smashDepth = true; + } + const body = args[0]; + return { + type: "smash", + mode: parser.mode, + body, + smashHeight, + smashDepth + }; + }, + htmlBuilder: (group, options) => { + const node = makeSpan([], [buildGroup(group.body, options)]); + if (!group.smashHeight && !group.smashDepth) { + return node; + } + if (group.smashHeight) { + node.height = 0; + } + if (group.smashDepth) { + node.depth = 0; + } + if (group.smashHeight && group.smashDepth) { + // Symmetric \smash can stay in inline layout. + return makeSpan(["mord", "smash"], [node], options); + } + + // In order to influence makeVList for asymmetric smashing, we have to + // reset the children. + if (node.children) { + for (let i = 0; i < node.children.length; i++) { + if (group.smashHeight) { + node.children[i].height = 0; + } + if (group.smashDepth) { + node.children[i].depth = 0; + } + } + } + + // At this point, we've reset the TeX-like height and depth values. + // But the span still has an HTML line height. + // makeVList applies "display: table-cell", which prevents the browser + // from acting on that line height. So we'll call makeVList now. + + const smashedNode = makeVList({ + positionType: "firstBaseline", + children: [{ + type: "elem", + elem: node + }] + }, options); + + // For spacing, TeX treats \smash as a math group (same spacing as ord). + return makeSpan(["mord"], [smashedNode], options); + }, + mathmlBuilder: (group, options) => { + const node = new MathNode("mpadded", [buildMathML_buildGroup(group.body, options)]); + if (group.smashHeight) { + node.setAttribute("height", "0px"); + } + if (group.smashDepth) { + node.setAttribute("depth", "0px"); + } + return node; + } +}); +;// ./src/functions/sqrt.ts + + + + + + + + +defineFunction({ + type: "sqrt", + names: ["\\sqrt"], + numArgs: 1, + numOptionalArgs: 1, + handler(_ref, args, optArgs) { + let { + parser + } = _ref; + const index = optArgs[0]; + const body = args[0]; + return { + type: "sqrt", + mode: parser.mode, + body, + index + }; + }, + htmlBuilder(group, options) { + // Square roots are handled in the TeXbook pg. 443, Rule 11. + + // First, we do the same steps as in overline to build the inner group + // and line + let inner = buildGroup(group.body, options.havingCrampedStyle()); + if (inner.height === 0) { + // Render a small surd. + inner.height = options.fontMetrics().xHeight; + } + + // Some groups can return document fragments. Handle those by wrapping + // them in a span. + inner = wrapFragment(inner, options); + + // Calculate the minimum size for the \surd delimiter + const metrics = options.fontMetrics(); + const theta = metrics.defaultRuleThickness; + let phi = theta; + if (options.style.id < src_Style.TEXT.id) { + phi = options.fontMetrics().xHeight; + } + + // Calculate the clearance between the body and line + let lineClearance = theta + phi / 4; + const minDelimiterHeight = inner.height + inner.depth + lineClearance + theta; + + // Create a sqrt SVG of the required minimum size + const { + span: img, + ruleWidth, + advanceWidth + } = makeSqrtImage(minDelimiterHeight, options); + const delimDepth = img.height - ruleWidth; + + // Adjust the clearance based on the delimiter size + if (delimDepth > inner.height + inner.depth + lineClearance) { + lineClearance = (lineClearance + delimDepth - inner.height - inner.depth) / 2; + } + + // Shift the sqrt image + const imgShift = img.height - inner.height - lineClearance - ruleWidth; + inner.style.paddingLeft = makeEm(advanceWidth); + + // Overlay the image and the argument. + const body = makeVList({ + positionType: "firstBaseline", + children: [{ + type: "elem", + elem: inner, + wrapperClasses: ["svg-align"] + }, { + type: "kern", + size: -(inner.height + imgShift) + }, { + type: "elem", + elem: img + }, { + type: "kern", + size: ruleWidth + }] + }, options); + if (!group.index) { + return makeSpan(["mord", "sqrt"], [body], options); + } else { + // Handle the optional root index + + // The index is always in scriptscript style + const newOptions = options.havingStyle(src_Style.SCRIPTSCRIPT); + const rootm = buildGroup(group.index, newOptions, options); + + // The amount the index is shifted by. This is taken from the TeX + // source, in the definition of `\r@@t`. + const toShift = 0.6 * (body.height - body.depth); + + // Build a VList with the superscript shifted up correctly + const rootVList = makeVList({ + positionType: "shift", + positionData: -toShift, + children: [{ + type: "elem", + elem: rootm + }] + }, options); + // Add a class surrounding it so we can add on the appropriate + // kerning + const rootVListWrap = makeSpan(["root"], [rootVList]); + return makeSpan(["mord", "sqrt"], [rootVListWrap, body], options); + } + }, + mathmlBuilder(group, options) { + const { + body, + index + } = group; + return index ? new MathNode("mroot", [buildMathML_buildGroup(body, options), buildMathML_buildGroup(index, options)]) : new MathNode("msqrt", [buildMathML_buildGroup(body, options)]); + } +}); +;// ./src/functions/styling.ts + + + + + +const styling_styleMap = { + "display": src_Style.DISPLAY, + "text": src_Style.TEXT, + "script": src_Style.SCRIPT, + "scriptscript": src_Style.SCRIPTSCRIPT +}; +function isStyleStr(s) { + return s in styling_styleMap; +} +defineFunction({ + type: "styling", + names: ["\\displaystyle", "\\textstyle", "\\scriptstyle", "\\scriptscriptstyle"], + numArgs: 0, + allowedInText: true, + primitive: true, + handler(_ref, args) { + let { + breakOnTokenText, + funcName, + parser + } = _ref; + // parse out the implicit body + const body = parser.parseExpression(true, breakOnTokenText); + + // TODO: Refactor to avoid duplicating styleMap in multiple places (e.g. + // here and in buildHTML and de-dupe the enumeration of all the styles). + const style = funcName.slice(1, funcName.length - 5); + if (!isStyleStr(style)) { + throw new Error("Unknown style: " + style); + } + return { + type: "styling", + mode: parser.mode, + // Figure out what style to use by pulling out the style from + // the function name + style, + body + }; + }, + htmlBuilder(group, options) { + // Style changes are handled in the TeXbook on pg. 442, Rule 3. + const newStyle = styling_styleMap[group.style]; + let newOptions = options.havingStyle(newStyle); + if (group.resetFont) { + newOptions = newOptions.withFont(''); + } + return sizingGroup(group.body, newOptions, options); + }, + mathmlBuilder(group, options) { + // Figure out what style we're changing to. + const newStyle = styling_styleMap[group.style]; + let newOptions = options.havingStyle(newStyle); + if (group.resetFont) { + newOptions = newOptions.withFont(''); + } + const inner = buildMathML_buildExpression(group.body, newOptions); + const node = new MathNode("mstyle", inner); + const styleAttributes = { + "display": ["0", "true"], + "text": ["0", "false"], + "script": ["1", "false"], + "scriptscript": ["2", "false"] + }; + const attr = styleAttributes[group.style]; + node.setAttribute("scriptlevel", attr[0]); + node.setAttribute("displaystyle", attr[1]); + return node; + } +}); +;// ./src/functions/supsub.ts + + + + + + + + + + + + + +/** + * Sometimes, groups perform special rules when they have superscripts or + * subscripts attached to them. This function lets the `supsub` group know that + * Sometimes, groups perform special rules when they have superscripts or + * its inner element should handle the superscripts and subscripts instead of + * handling them itself. + */ +const htmlBuilderDelegate = function (group, options +// eslint-disable-next-line @typescript-eslint/no-explicit-any +) { + const base = group.base; + if (!base) { + return null; + } else if (base.type === "op") { + // Operators handle supsubs differently when they have limits + // (e.g. `\displaystyle\sum_2^3`) + const delegate = base.limits && (options.style.size === src_Style.DISPLAY.size || base.alwaysHandleSupSub); + return delegate ? op_htmlBuilder : null; + } else if (base.type === "operatorname") { + const delegate = base.alwaysHandleSupSub && (options.style.size === src_Style.DISPLAY.size || base.limits); + return delegate ? operatorname_htmlBuilder : null; + } else if (base.type === "accent") { + return isCharacterBox(base.base) ? htmlBuilder : null; + } else if (base.type === "horizBrace") { + const isSup = !group.sub; + return isSup === base.isOver ? horizBrace_htmlBuilder : null; + } else { + return null; + } +}; + +// Super scripts and subscripts, whose precise placement can depend on other +// functions that precede them. +defineFunctionBuilders({ + type: "supsub", + htmlBuilder(group, options) { + // Superscript and subscripts are handled in the TeXbook on page + // 445-446, rules 18(a-f). + + // Here is where we defer to the inner group if it should handle + // superscripts and subscripts itself. + const builderDelegate = htmlBuilderDelegate(group, options); + if (builderDelegate) { + return builderDelegate(group, options); + } + const { + base: valueBase, + sup: valueSup, + sub: valueSub + } = group; + const base = buildGroup(valueBase, options); + let supm; + let subm; + const metrics = options.fontMetrics(); + + // Rule 18a + let supShift = 0; + let subShift = 0; + const isCharBox = valueBase && isCharacterBox(valueBase); + if (valueSup) { + const newOptions = options.havingStyle(options.style.sup()); + supm = buildGroup(valueSup, newOptions, options); + if (!isCharBox) { + supShift = base.height - newOptions.fontMetrics().supDrop * newOptions.sizeMultiplier / options.sizeMultiplier; + } + } + if (valueSub) { + const newOptions = options.havingStyle(options.style.sub()); + subm = buildGroup(valueSub, newOptions, options); + if (!isCharBox) { + subShift = base.depth + newOptions.fontMetrics().subDrop * newOptions.sizeMultiplier / options.sizeMultiplier; + } + } + + // Rule 18c + let minSupShift; + if (options.style === src_Style.DISPLAY) { + minSupShift = metrics.sup1; + } else if (options.style.cramped) { + minSupShift = metrics.sup3; + } else { + minSupShift = metrics.sup2; + } + + // scriptspace is a font-size-independent size, so scale it + // appropriately for use as the marginRight. + const multiplier = options.sizeMultiplier; + const marginRight = makeEm(0.5 / metrics.ptPerEm / multiplier); + let marginLeft = null; + if (subm) { + // Subscripts shouldn't be shifted by the base's italic correction. + // Account for that by shifting the subscript back the appropriate + // amount. Note we only do this when the base is a single symbol. + const isOiint = group.base && group.base.type === "op" && group.base.name && (group.base.name === "\\oiint" || group.base.name === "\\oiiint"); + if (base instanceof SymbolNode || isOiint) { + var _italic; + // SymbolNode has .italic natively; for \oiint/\oiiint the + // op builder stores .italic on the wrapping Span. + marginLeft = makeEm(-((_italic = base.italic) != null ? _italic : 0)); + } + } + let supsub; + if (supm && subm) { + supShift = Math.max(supShift, minSupShift, supm.depth + 0.25 * metrics.xHeight); + subShift = Math.max(subShift, metrics.sub2); + const ruleWidth = metrics.defaultRuleThickness; + + // Rule 18e + const maxWidth = 4 * ruleWidth; + if (supShift - supm.depth - (subm.height - subShift) < maxWidth) { + subShift = maxWidth - (supShift - supm.depth) + subm.height; + const psi = 0.8 * metrics.xHeight - (supShift - supm.depth); + if (psi > 0) { + supShift += psi; + subShift -= psi; + } + } + const vlistElem = [{ + type: "elem", + elem: subm, + shift: subShift, + marginRight, + marginLeft + }, { + type: "elem", + elem: supm, + shift: -supShift, + marginRight + }]; + supsub = makeVList({ + positionType: "individualShift", + children: vlistElem + }, options); + } else if (subm) { + // Rule 18b + subShift = Math.max(subShift, metrics.sub1, subm.height - 0.8 * metrics.xHeight); + const vlistElem = [{ + type: "elem", + elem: subm, + marginLeft, + marginRight + }]; + supsub = makeVList({ + positionType: "shift", + positionData: subShift, + children: vlistElem + }, options); + } else if (supm) { + // Rule 18c, d + supShift = Math.max(supShift, minSupShift, supm.depth + 0.25 * metrics.xHeight); + supsub = makeVList({ + positionType: "shift", + positionData: -supShift, + children: [{ + type: "elem", + elem: supm, + marginRight + }] + }, options); + } else { + throw new Error("supsub must have either sup or sub."); + } + + // Wrap the supsub vlist in a span.msupsub to reset text-align. + const mclass = getTypeOfDomTree(base, "right") || "mord"; + return makeSpan([mclass], [base, makeSpan(["msupsub"], [supsub])], options); + }, + mathmlBuilder(group, options) { + // Is the inner group a relevant horizontal brace? + let isBrace = false; + let isOver; + let isSup; + if (group.base && group.base.type === "horizBrace") { + isSup = !!group.sup; + if (isSup === group.base.isOver) { + isBrace = true; + isOver = group.base.isOver; + } + } + if (group.base && (group.base.type === "op" || group.base.type === "operatorname")) { + group.base.parentIsSupSub = true; + } + const children = [buildMathML_buildGroup(group.base, options)]; + if (group.sub) { + children.push(buildMathML_buildGroup(group.sub, options)); + } + if (group.sup) { + children.push(buildMathML_buildGroup(group.sup, options)); + } + let nodeType; + if (isBrace) { + nodeType = isOver ? "mover" : "munder"; + } else if (!group.sub) { + const base = group.base; + if (base && base.type === "op" && base.limits && (options.style === src_Style.DISPLAY || base.alwaysHandleSupSub)) { + nodeType = "mover"; + } else if (base && base.type === "operatorname" && base.alwaysHandleSupSub && (base.limits || options.style === src_Style.DISPLAY)) { + nodeType = "mover"; + } else { + nodeType = "msup"; + } + } else if (!group.sup) { + const base = group.base; + if (base && base.type === "op" && base.limits && (options.style === src_Style.DISPLAY || base.alwaysHandleSupSub)) { + nodeType = "munder"; + } else if (base && base.type === "operatorname" && base.alwaysHandleSupSub && (base.limits || options.style === src_Style.DISPLAY)) { + nodeType = "munder"; + } else { + nodeType = "msub"; + } + } else { + const base = group.base; + if (base && base.type === "op" && base.limits && options.style === src_Style.DISPLAY) { + nodeType = "munderover"; + } else if (base && base.type === "operatorname" && base.alwaysHandleSupSub && (options.style === src_Style.DISPLAY || base.limits)) { + nodeType = "munderover"; + } else { + nodeType = "msubsup"; + } + } + return new MathNode(nodeType, children); + } +}); +;// ./src/functions/symbolsOp.ts + + + + + +// Operator ParseNodes created in Parser.js from symbol Groups in src/symbols.js. + +defineFunctionBuilders({ + type: "atom", + htmlBuilder(group, options) { + return mathsym(group.text, group.mode, options, ["m" + group.family]); + }, + mathmlBuilder(group, options) { + const node = new MathNode("mo", [makeText(group.text, group.mode)]); + if (group.family === "bin") { + const variant = getVariant(group, options); + if (variant === "bold-italic") { + node.setAttribute("mathvariant", variant); + } + } else if (group.family === "punct") { + node.setAttribute("separator", "true"); + } else if (group.family === "open" || group.family === "close") { + // Delims built here should not stretch vertically. + // See delimsizing.js for stretchy delims. + node.setAttribute("stretchy", "false"); + } + return node; + } +}); +;// ./src/functions/symbolsOrd.ts + + + + +// "mathord" and "textord" ParseNodes created in Parser.js from symbol Groups in +// src/symbols.js. + +const defaultVariant = { + "mi": "italic", + "mn": "normal", + "mtext": "normal" +}; +defineFunctionBuilders({ + type: "mathord", + htmlBuilder(group, options) { + return makeOrd(group, options); + }, + mathmlBuilder(group, options) { + const node = new MathNode("mi", [makeText(group.text, group.mode, options)]); + const variant = getVariant(group, options) || "italic"; + if (variant !== defaultVariant[node.type]) { + node.setAttribute("mathvariant", variant); + } + return node; + } +}); +defineFunctionBuilders({ + type: "textord", + htmlBuilder(group, options) { + return makeOrd(group, options); + }, + mathmlBuilder(group, options) { + const text = makeText(group.text, group.mode, options); + const variant = getVariant(group, options) || "normal"; + let node; + if (group.mode === 'text') { + node = new MathNode("mtext", [text]); + } else if (/[0-9]/.test(group.text)) { + node = new MathNode("mn", [text]); + } else if (group.text === "\\prime") { + node = new MathNode("mo", [text]); + } else { + node = new MathNode("mi", [text]); + } + if (variant !== defaultVariant[node.type]) { + node.setAttribute("mathvariant", variant); + } + return node; + } +}); +;// ./src/functions/symbolsSpacing.ts + + + + + +// A map of CSS-based spacing functions to their CSS class. +const cssSpace = { + "\\nobreak": "nobreak", + "\\allowbreak": "allowbreak" +}; + +// A lookup table to determine whether a spacing function/symbol should be +// treated like a regular space character. If a symbol or command is a key +// in this table, then it should be a regular space character. Furthermore, +// the associated value may have a `className` specifying an extra CSS class +// to add to the created `span`. +const regularSpace = { + " ": {}, + "\\ ": {}, + "~": { + className: "nobreak" + }, + "\\space": {}, + "\\nobreakspace": { + className: "nobreak" + } +}; + +// ParseNode<"spacing"> created in Parser.js from the "spacing" symbol Groups in +// src/symbols.js. +defineFunctionBuilders({ + type: "spacing", + htmlBuilder(group, options) { + if (regularSpace.hasOwnProperty(group.text)) { + const className = regularSpace[group.text].className || ""; + // Spaces are generated by adding an actual space. Each of these + // things has an entry in the symbols table, so these will be turned + // into appropriate outputs. + if (group.mode === "text") { + const ord = makeOrd(group, options); + ord.classes.push(className); + return ord; + } else { + return makeSpan(["mspace", className], [mathsym(group.text, group.mode, options)], options); + } + } else if (cssSpace.hasOwnProperty(group.text)) { + // Spaces based on just a CSS class. + return makeSpan(["mspace", cssSpace[group.text]], [], options); + } else { + throw new src_ParseError("Unknown type of space \"" + group.text + "\""); + } + }, + mathmlBuilder(group, options) { + let node; + if (regularSpace.hasOwnProperty(group.text)) { + node = new MathNode("mtext", [new TextNode("\u00a0")]); + } else if (cssSpace.hasOwnProperty(group.text)) { + // CSS-based MathML spaces (\nobreak, \allowbreak) are ignored + return new MathNode("mspace"); + } else { + throw new src_ParseError("Unknown type of space \"" + group.text + "\""); + } + return node; + } +}); +;// ./src/functions/tag.ts + + + +const pad = () => { + const padNode = new MathNode("mtd", []); + padNode.setAttribute("width", "50%"); + return padNode; +}; +defineFunctionBuilders({ + type: "tag", + mathmlBuilder(group, options) { + const table = new MathNode("mtable", [new MathNode("mtr", [pad(), new MathNode("mtd", [buildExpressionRow(group.body, options)]), pad(), new MathNode("mtd", [buildExpressionRow(group.tag, options)])])]); + table.setAttribute("width", "100%"); + return table; + + // TODO: Left-aligned tags. + // Currently, the group and options passed here do not contain + // enough info to set tag alignment. `leqno` is in Settings but it is + // not passed to Options. On the HTML side, leqno is + // set by a CSS class applied in buildTree.js. That would have worked + // in MathML if browsers supported . Since they don't, we + // need to rewrite the way this function is called. + } +}); +;// ./src/functions/text.ts + + + + +// Non-mathy text, possibly in a font +const textFontFamilies = { + "\\text": undefined, + "\\textrm": "textrm", + "\\textsf": "textsf", + "\\texttt": "texttt", + "\\textnormal": "textrm" +}; +const textFontWeights = { + "\\textbf": "textbf", + "\\textmd": "textmd" +}; +const textFontShapes = { + "\\textit": "textit", + "\\textup": "textup" +}; +const optionsWithFont = (group, options) => { + const font = group.font; + // Checks if the argument is a font family or a font style. + if (!font) { + return options; + } else if (textFontFamilies[font]) { + return options.withTextFontFamily(textFontFamilies[font]); + } else if (textFontWeights[font]) { + return options.withTextFontWeight(textFontWeights[font]); + } else if (font === "\\emph") { + return options.fontShape === "textit" ? options.withTextFontShape("textup") : options.withTextFontShape("textit"); + } + return options.withTextFontShape(textFontShapes[font]); +}; +defineFunction({ + type: "text", + names: [ + // Font families + "\\text", "\\textrm", "\\textsf", "\\texttt", "\\textnormal", + // Font weights + "\\textbf", "\\textmd", + // Font Shapes + "\\textit", "\\textup", "\\emph"], + numArgs: 1, + argTypes: ["text"], + allowedInArgument: true, + allowedInText: true, + handler(_ref, args) { + let { + parser, + funcName + } = _ref; + const body = args[0]; + return { + type: "text", + mode: parser.mode, + body: ordargument(body), + font: funcName + }; + }, + htmlBuilder(group, options) { + const newOptions = optionsWithFont(group, options); + const inner = buildExpression(group.body, newOptions, true); + return makeSpan(["mord", "text"], inner, newOptions); + }, + mathmlBuilder(group, options) { + const newOptions = optionsWithFont(group, options); + return buildExpressionRow(group.body, newOptions); + } +}); +;// ./src/functions/underline.ts + + + + + +defineFunction({ + type: "underline", + names: ["\\underline"], + numArgs: 1, + allowedInText: true, + handler(_ref, args) { + let { + parser + } = _ref; + return { + type: "underline", + mode: parser.mode, + body: args[0] + }; + }, + htmlBuilder(group, options) { + // Underlines are handled in the TeXbook pg 443, Rule 10. + // Build the inner group. + const innerGroup = buildGroup(group.body, options); + + // Create the line to go below the body + const line = makeLineSpan("underline-line", options); + + // Generate the vlist, with the appropriate kerns + const defaultRuleThickness = options.fontMetrics().defaultRuleThickness; + const vlist = makeVList({ + positionType: "top", + positionData: innerGroup.height, + children: [{ + type: "kern", + size: defaultRuleThickness + }, { + type: "elem", + elem: line + }, { + type: "kern", + size: 3 * defaultRuleThickness + }, { + type: "elem", + elem: innerGroup + }] + }, options); + return makeSpan(["mord", "underline"], [vlist], options); + }, + mathmlBuilder(group, options) { + const operator = new MathNode("mo", [new TextNode("\u203e")]); + operator.setAttribute("stretchy", "true"); + const node = new MathNode("munder", [buildMathML_buildGroup(group.body, options), operator]); + node.setAttribute("accentunder", "true"); + return node; + } +}); +;// ./src/functions/vcenter.ts + + + + + + +// \vcenter: Vertically center the argument group on the math axis. + +defineFunction({ + type: "vcenter", + names: ["\\vcenter"], + numArgs: 1, + argTypes: ["original"], + // In LaTeX, \vcenter can act only on a box. + allowedInText: false, + handler(_ref, args) { + let { + parser + } = _ref; + return { + type: "vcenter", + mode: parser.mode, + body: args[0] + }; + }, + htmlBuilder(group, options) { + const body = buildGroup(group.body, options); + const axisHeight = options.fontMetrics().axisHeight; + const dy = 0.5 * (body.height - axisHeight - (body.depth + axisHeight)); + return makeVList({ + positionType: "shift", + positionData: dy, + children: [{ + type: "elem", + elem: body + }] + }, options); + }, + mathmlBuilder(group, options) { + // There is no way to do this in MathML. + // Write a class as a breadcrumb in case some post-processor wants + // to perform a vcenter adjustment. + // Wrap in mrow to ensure valid MathML when placed inside mo (e.g., \mathrel) + const mpadded = new MathNode("mpadded", [buildMathML_buildGroup(group.body, options)], ["vcenter"]); + return new MathNode("mrow", [mpadded]); + } +}); +;// ./src/functions/verb.ts + + + + +defineFunction({ + type: "verb", + names: ["\\verb"], + numArgs: 0, + allowedInText: true, + handler(context, args, optArgs) { + // \verb and \verb* are dealt with directly in Parser.js. + // If we end up here, it's because of a failure to match the two delimiters + // in the regex in Lexer.js. LaTeX raises the following error when \verb is + // terminated by end of line (or file). + throw new src_ParseError("\\verb ended by end of line instead of matching delimiter"); + }, + htmlBuilder(group, options) { + const text = makeVerb(group); + const body = []; + // \verb enters text mode and therefore is sized like \textstyle + const newOptions = options.havingStyle(options.style.text()); + for (let i = 0; i < text.length; i++) { + let c = text[i]; + if (c === '~') { + c = '\\textasciitilde'; + } + body.push(makeSymbol(c, "Typewriter-Regular", group.mode, newOptions, ["mord", "texttt"])); + } + return makeSpan(["mord", "text"].concat(newOptions.sizingClasses(options)), tryCombineChars(body), newOptions); + }, + mathmlBuilder(group, options) { + const text = new TextNode(makeVerb(group)); + const node = new MathNode("mtext", [text]); + node.setAttribute("mathvariant", "monospace"); + return node; + } +}); + +/** + * Converts verb group into body string. + * + * \verb* replaces each space with an open box \u2423 + * \verb replaces each space with a no-break space \xA0 + */ +const makeVerb = group => group.body.replace(/ /g, group.star ? '\u2423' : '\xA0'); +;// ./src/functions.ts +/** Include this to ensure that all functions are defined. */ + +const functions = _functions; +/* harmony default export */ var src_functions = (functions); + +// TODO(kevinb): have functions return an object and call defineFunction with +// that object in this file instead of relying on side-effects. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +;// ./src/Lexer.ts +/** + * The Lexer class handles tokenizing the input in various ways. Since our + * parser expects us to be able to backtrack, the lexer allows lexing from any + * given starting point. + * + * Its main exposed function is the `lex` function, which takes a position to + * lex from and a type of token to lex. It defers to the appropriate `_innerLex` + * function. + * + * The various `_innerLex` functions perform the actual lexing of different + * kinds. + */ + + + + +/* The following tokenRegex + * - matches typical whitespace (but not NBSP etc.) using its first group + * - does not match any control character \x00-\x1f except whitespace + * - does not match a bare backslash + * - matches any ASCII character except those just mentioned + * - does not match the BMP private use area \uE000-\uF8FF + * - does not match bare surrogate code units + * - matches any BMP character except for those just described + * - matches any valid Unicode surrogate pair + * - matches a backslash followed by one or more whitespace characters + * - matches a backslash followed by one or more letters then whitespace + * - matches a backslash followed by any BMP character + * Capturing groups: + * [1] regular whitespace + * [2] backslash followed by whitespace + * [3] anything else, which may include: + * [4] left character of \verb* + * [5] left character of \verb + * [6] backslash followed by word, excluding any trailing whitespace + * Just because the Lexer matches something doesn't mean it's valid input: + * If there is no matching function or symbol definition, the Parser will + * still reject the input. + */ +const spaceRegexString = "[ \r\n\t]"; +const controlWordRegexString = "\\\\[a-zA-Z@]+"; +const controlSymbolRegexString = "\\\\[^\uD800-\uDFFF]"; +const controlWordWhitespaceRegexString = "(" + controlWordRegexString + ")" + spaceRegexString + "*"; +const controlSpaceRegexString = "\\\\(\n|[ \r\t]+\n?)[ \r\t]*"; +const combiningDiacriticalMarkString = "[\u0300-\u036f]"; +const combiningDiacriticalMarksEndRegex = new RegExp(combiningDiacriticalMarkString + "+$"); +const tokenRegexString = "(" + spaceRegexString + "+)|" + (// whitespace +controlSpaceRegexString + "|") + +// \whitespace +"([!-\\[\\]-\u2027\u202A-\uD7FF\uF900-\uFFFF]" + (// single codepoint +combiningDiacriticalMarkString + "*") + +// ...plus accents +"|[\uD800-\uDBFF][\uDC00-\uDFFF]" + (// surrogate pair +combiningDiacriticalMarkString + "*") + +// ...plus accents +"|\\\\verb\\*([^]).*?\\4" + +// \verb* +"|\\\\verb([^*a-zA-Z]).*?\\5" + (// \verb unstarred +"|" + controlWordWhitespaceRegexString) + (// \macroName + spaces +"|" + controlSymbolRegexString + ")"); // \\, \', etc. + +/** Main Lexer class */ +class Lexer { + constructor(input, settings) { + this.input = void 0; + this.settings = void 0; + this.tokenRegex = void 0; + // Category codes. The lexer only supports comment characters (14) for now. + // MacroExpander additionally distinguishes active (13). + this.catcodes = void 0; + // Separate accents from characters + this.input = input; + this.settings = settings; + this.tokenRegex = new RegExp(tokenRegexString, 'g'); + this.catcodes = { + "%": 14, + // comment character + "~": 13 // active character + }; + } + setCatcode(char, code) { + this.catcodes[char] = code; + } + + /** + * This function lexes a single token. + */ + lex() { + const input = this.input; + const pos = this.tokenRegex.lastIndex; + if (pos === input.length) { + return new Token("EOF", new SourceLocation(this, pos, pos)); + } + const match = this.tokenRegex.exec(input); + if (match === null || match.index !== pos) { + throw new src_ParseError("Unexpected character: '" + input[pos] + "'", new Token(input[pos], new SourceLocation(this, pos, pos + 1))); + } + const text = match[6] || match[3] || (match[2] ? "\\ " : " "); + if (this.catcodes[text] === 14) { + // comment character + const nlIndex = input.indexOf('\n', this.tokenRegex.lastIndex); + if (nlIndex === -1) { + this.tokenRegex.lastIndex = input.length; // EOF + this.settings.reportNonstrict("commentAtEnd", "% comment has no terminating newline; LaTeX would " + "fail because of commenting the end of math mode (e.g. $)"); + } else { + this.tokenRegex.lastIndex = nlIndex + 1; + } + return this.lex(); + } + return new Token(text, new SourceLocation(this, pos, this.tokenRegex.lastIndex)); + } +} +;// ./src/Namespace.ts +/** + * A `Namespace` refers to a space of nameable things like macros or lengths, + * which can be `set` either globally or local to a nested group, using an + * undo stack similar to how TeX implements this functionality. + * Performance-wise, `get` and local `set` take constant time, while global + * `set` takes time proportional to the depth of group nesting. + */ + + +class Namespace { + /** + * Both arguments are optional. The first argument is an object of + * built-in mappings which never change. The second argument is an object + * of initial (global-level) mappings, which will constantly change + * according to any global/top-level `set`s done. + */ + constructor(builtins, globalMacros) { + if (builtins === void 0) { + builtins = {}; + } + if (globalMacros === void 0) { + globalMacros = {}; + } + this.current = void 0; + this.builtins = void 0; + this.undefStack = void 0; + this.current = globalMacros; + this.builtins = builtins; + this.undefStack = []; + } + + /** + * Start a new nested group, affecting future local `set`s. + */ + beginGroup() { + this.undefStack.push({}); + } + + /** + * End current nested group, restoring values before the group began. + */ + endGroup() { + if (this.undefStack.length === 0) { + throw new src_ParseError("Unbalanced namespace destruction: attempt " + "to pop global namespace; please report this as a bug"); + } + const undefs = this.undefStack.pop(); + for (const undef in undefs) { + if (undefs.hasOwnProperty(undef)) { + if (undefs[undef] == null) { + delete this.current[undef]; + } else { + this.current[undef] = undefs[undef]; + } + } + } + } + + /** + * Ends all currently nested groups (if any), restoring values before the + * groups began. Useful in case of an error in the middle of parsing. + */ + endGroups() { + while (this.undefStack.length > 0) { + this.endGroup(); + } + } + + /** + * Detect whether `name` has a definition. Equivalent to + * `get(name) != null`. + */ + has(name) { + return this.current.hasOwnProperty(name) || this.builtins.hasOwnProperty(name); + } + + /** + * Get the current value of a name, or `undefined` if there is no value. + * + * Note: Do not use `if (namespace.get(...))` to detect whether a macro + * is defined, as the definition may be the empty string which evaluates + * to `false` in JavaScript. Use `if (namespace.get(...) != null)` or + * `if (namespace.has(...))`. + */ + get(name) { + if (this.current.hasOwnProperty(name)) { + return this.current[name]; + } else { + return this.builtins[name]; + } + } + + /** + * Set the current value of a name, and optionally set it globally too. + * Local set() sets the current value and (when appropriate) adds an undo + * operation to the undo stack. Global set() may change the undo + * operation at every level, so takes time linear in their number. + * A value of undefined means to delete existing definitions. + */ + set(name, value, global) { + if (global === void 0) { + global = false; + } + if (global) { + // Global set is equivalent to setting in all groups. Simulate this + // by destroying any undos currently scheduled for this name, + // and adding an undo with the *new* value (in case it later gets + // locally reset within this environment). + for (let i = 0; i < this.undefStack.length; i++) { + delete this.undefStack[i][name]; + } + if (this.undefStack.length > 0) { + this.undefStack[this.undefStack.length - 1][name] = value; + } + } else { + // Undo this set at end of this group (possibly to `undefined`), + // unless an undo is already in place, in which case that older + // value is the correct one. + const top = this.undefStack[this.undefStack.length - 1]; + if (top && !top.hasOwnProperty(name)) { + top[name] = this.current[name]; + } + } + if (value == null) { + delete this.current[name]; + } else { + this.current[name] = value; + } + } +} +;// ./src/macros.ts +/** + * Predefined macros for KaTeX. + * This can be used to define some commands in terms of others. + */ + +// Export global macros object from defineMacro + +const macros = _macros; +/* harmony default export */ var src_macros = (macros); + + + + + +////////////////////////////////////////////////////////////////////// +// macro tools + +defineMacro("\\noexpand", function (context) { + // The expansion is the token itself; but that token is interpreted + // as if its meaning were ‘\relax’ if it is a control sequence that + // would ordinarily be expanded by TeX’s expansion rules. + const t = context.popToken(); + if (context.isExpandable(t.text)) { + t.noexpand = true; + t.treatAsRelax = true; + } + return { + tokens: [t], + numArgs: 0 + }; +}); +defineMacro("\\expandafter", function (context) { + // TeX first reads the token that comes immediately after \expandafter, + // without expanding it; let’s call this token t. Then TeX reads the + // token that comes after t (and possibly more tokens, if that token + // has an argument), replacing it by its expansion. Finally TeX puts + // t back in front of that expansion. + const t = context.popToken(); + context.expandOnce(true); // expand only an expandable token + return { + tokens: [t], + numArgs: 0 + }; +}); + +// LaTeX's \@firstoftwo{#1}{#2} expands to #1, skipping #2 +// TeX source: \long\def\@firstoftwo#1#2{#1} +defineMacro("\\@firstoftwo", function (context) { + const args = context.consumeArgs(2); + return { + tokens: args[0], + numArgs: 0 + }; +}); + +// LaTeX's \@secondoftwo{#1}{#2} expands to #2, skipping #1 +// TeX source: \long\def\@secondoftwo#1#2{#2} +defineMacro("\\@secondoftwo", function (context) { + const args = context.consumeArgs(2); + return { + tokens: args[1], + numArgs: 0 + }; +}); + +// LaTeX's \@ifnextchar{#1}{#2}{#3} looks ahead to the next (unexpanded) +// symbol that isn't a space, consuming any spaces but not consuming the +// first nonspace character. If that nonspace character matches #1, then +// the macro expands to #2; otherwise, it expands to #3. +defineMacro("\\@ifnextchar", function (context) { + const args = context.consumeArgs(3); // symbol, if, else + context.consumeSpaces(); + const nextToken = context.future(); + if (args[0].length === 1 && args[0][0].text === nextToken.text) { + return { + tokens: args[1], + numArgs: 0 + }; + } else { + return { + tokens: args[2], + numArgs: 0 + }; + } +}); + +// LaTeX's \@ifstar{#1}{#2} looks ahead to the next (unexpanded) symbol. +// If it is `*`, then it consumes the symbol, and the macro expands to #1; +// otherwise, the macro expands to #2 (without consuming the symbol). +// TeX source: \def\@ifstar#1{\@ifnextchar *{\@firstoftwo{#1}}} +defineMacro("\\@ifstar", "\\@ifnextchar *{\\@firstoftwo{#1}}"); + +// LaTeX's \TextOrMath{#1}{#2} expands to #1 in text mode, #2 in math mode +defineMacro("\\TextOrMath", function (context) { + const args = context.consumeArgs(2); + if (context.mode === 'text') { + return { + tokens: args[0], + numArgs: 0 + }; + } else { + return { + tokens: args[1], + numArgs: 0 + }; + } +}); + +// Lookup table for parsing numbers in base 8 through 16 +const digitToNumber = { + "0": 0, + "1": 1, + "2": 2, + "3": 3, + "4": 4, + "5": 5, + "6": 6, + "7": 7, + "8": 8, + "9": 9, + "a": 10, + "A": 10, + "b": 11, + "B": 11, + "c": 12, + "C": 12, + "d": 13, + "D": 13, + "e": 14, + "E": 14, + "f": 15, + "F": 15 +}; + +// TeX \char makes a literal character (catcode 12) using the following forms: +// (see The TeXBook, p. 43) +// \char123 -- decimal +// \char'123 -- octal +// \char"123 -- hex +// \char`x -- character that can be written (i.e. isn't active) +// \char`\x -- character that cannot be written (e.g. %) +// These all refer to characters from the font, so we turn them into special +// calls to a function \@char dealt with in the Parser. +defineMacro("\\char", function (context) { + let token = context.popToken(); + let base; + let number = 0; + if (token.text === "'") { + base = 8; + token = context.popToken(); + } else if (token.text === '"') { + base = 16; + token = context.popToken(); + } else if (token.text === "`") { + token = context.popToken(); + if (token.text[0] === "\\") { + number = token.text.charCodeAt(1); + } else if (token.text === "EOF") { + throw new src_ParseError("\\char` missing argument"); + } else { + number = token.text.charCodeAt(0); + } + } else { + base = 10; + } + if (base) { + // Parse a number in the given base, starting with first `token`. + number = digitToNumber[token.text]; + if (number == null || number >= base) { + throw new src_ParseError("Invalid base-" + base + " digit " + token.text); + } + let digit; + while ((digit = digitToNumber[context.future().text]) != null && digit < base) { + number *= base; + number += digit; + context.popToken(); + } + } + return "\\@char{" + number + "}"; +}); + +// \newcommand{\macro}[args]{definition} +// \renewcommand{\macro}[args]{definition} +// TODO: Optional arguments: \newcommand{\macro}[args][default]{definition} +const newcommand = (context, existsOK, nonexistsOK, skipIfExists) => { + let arg = context.consumeArg().tokens; + if (arg.length !== 1) { + throw new src_ParseError("\\newcommand's first argument must be a macro name"); + } + const name = arg[0].text; + const exists = context.isDefined(name); + if (exists && !existsOK) { + throw new src_ParseError("\\newcommand{" + name + "} attempting to redefine " + (name + "; use \\renewcommand")); + } + if (!exists && !nonexistsOK) { + throw new src_ParseError("\\renewcommand{" + name + "} when command " + name + " " + "does not yet exist; use \\newcommand"); + } + let numArgs = 0; + arg = context.consumeArg().tokens; + if (arg.length === 1 && arg[0].text === "[") { + let argText = ''; + let token = context.expandNextToken(); + while (token.text !== "]" && token.text !== "EOF") { + // TODO: Should properly expand arg, e.g., ignore {}s + argText += token.text; + token = context.expandNextToken(); + } + if (!argText.match(/^\s*[0-9]+\s*$/)) { + throw new src_ParseError("Invalid number of arguments: " + argText); + } + numArgs = parseInt(argText); + arg = context.consumeArg().tokens; + } + if (!(exists && skipIfExists)) { + // Final arg is the expansion of the macro + context.macros.set(name, { + tokens: arg, + numArgs + }); + } + return ''; +}; +defineMacro("\\newcommand", context => newcommand(context, false, true, false)); +defineMacro("\\renewcommand", context => newcommand(context, true, false, false)); +defineMacro("\\providecommand", context => newcommand(context, true, true, true)); + +// terminal (console) tools +defineMacro("\\message", context => { + const arg = context.consumeArgs(1)[0]; + // eslint-disable-next-line no-console + console.log(arg.reverse().map(token => token.text).join("")); + return ''; +}); +defineMacro("\\errmessage", context => { + const arg = context.consumeArgs(1)[0]; + // eslint-disable-next-line no-console + console.error(arg.reverse().map(token => token.text).join("")); + return ''; +}); +defineMacro("\\show", context => { + const tok = context.popToken(); + const name = tok.text; + // eslint-disable-next-line no-console + console.log(tok, context.macros.get(name), src_functions[name], src_symbols.math[name], src_symbols.text[name]); + return ''; +}); + +////////////////////////////////////////////////////////////////////// +// Grouping +// \let\bgroup={ \let\egroup=} +defineMacro("\\bgroup", "{"); +defineMacro("\\egroup", "}"); + +// Symbols from latex.ltx: +// \def~{\nobreakspace{}} +// \def\lq{`} +// \def\rq{'} +// \def \aa {\r a} +// \def \AA {\r A} +defineMacro("~", "\\nobreakspace"); +defineMacro("\\lq", "`"); +defineMacro("\\rq", "'"); +defineMacro("\\aa", "\\r a"); +defineMacro("\\AA", "\\r A"); + +// Copyright (C) and registered (R) symbols. Use raw symbol in MathML. +// \DeclareTextCommandDefault{\textcopyright}{\textcircled{c}} +// \DeclareTextCommandDefault{\textregistered}{\textcircled{% +// \check@mathfonts\fontsize\sf@size\z@\math@fontsfalse\selectfont R}} +// \DeclareRobustCommand{\copyright}{% +// \ifmmode{\nfss@text{\textcopyright}}\else\textcopyright\fi} +defineMacro("\\textcopyright", "\\html@mathml{\\textcircled{c}}{\\char`©}"); +defineMacro("\\copyright", "\\TextOrMath{\\textcopyright}{\\text{\\textcopyright}}"); +defineMacro("\\textregistered", "\\html@mathml{\\textcircled{\\scriptsize R}}{\\char`®}"); + +// Characters omitted from Unicode range 1D400–1D7FF +defineMacro("\u212C", "\\mathscr{B}"); // script +defineMacro("\u2130", "\\mathscr{E}"); +defineMacro("\u2131", "\\mathscr{F}"); +defineMacro("\u210B", "\\mathscr{H}"); +defineMacro("\u2110", "\\mathscr{I}"); +defineMacro("\u2112", "\\mathscr{L}"); +defineMacro("\u2133", "\\mathscr{M}"); +defineMacro("\u211B", "\\mathscr{R}"); +defineMacro("\u212D", "\\mathfrak{C}"); // Fraktur +defineMacro("\u210C", "\\mathfrak{H}"); +defineMacro("\u2128", "\\mathfrak{Z}"); + +// Define \Bbbk with a macro that works in both HTML and MathML. +defineMacro("\\Bbbk", "\\Bbb{k}"); + +// \llap and \rlap render their contents in text mode +defineMacro("\\llap", "\\mathllap{\\textrm{#1}}"); +defineMacro("\\rlap", "\\mathrlap{\\textrm{#1}}"); +defineMacro("\\clap", "\\mathclap{\\textrm{#1}}"); + +// \mathstrut from the TeXbook, p 360 +defineMacro("\\mathstrut", "\\vphantom{(}"); + +// \underbar from TeXbook p 353 +defineMacro("\\underbar", "\\underline{\\text{#1}}"); + +// \not is defined by base/fontmath.ltx via +// \DeclareMathSymbol{\not}{\mathrel}{symbols}{"36} +// It's thus treated like a \mathrel, but defined by a symbol that has zero +// width but extends to the right. We use \rlap to get that spacing. +// For MathML we write U+0338 here. buildMathML.js will then do the overlay. +defineMacro("\\not", "\\html@mathml{\\mathrel{\\mathrlap\\@not}\\nobreak}" + "{\\char\"338}"); + +// Negated symbols from base/fontmath.ltx: +// \def\neq{\not=} \let\ne=\neq +// \DeclareRobustCommand +// \notin{\mathrel{\m@th\mathpalette\c@ncel\in}} +// \def\c@ncel#1#2{\m@th\ooalign{$\hfil#1\mkern1mu/\hfil$\crcr$#1#2$}} +defineMacro("\\neq", "\\html@mathml{\\mathrel{\\not=}}{\\mathrel{\\char`≠}}"); +defineMacro("\\ne", "\\neq"); +defineMacro("\u2260", "\\neq"); +defineMacro("\\notin", "\\html@mathml{\\mathrel{{\\in}\\mathllap{/\\mskip1mu}}}" + "{\\mathrel{\\char`∉}}"); +defineMacro("\u2209", "\\notin"); + +// Unicode stacked relations +defineMacro("\u2258", "\\html@mathml{" + "\\mathrel{=\\kern{-1em}\\raisebox{0.4em}{$\\scriptsize\\frown$}}" + "}{\\mathrel{\\char`\u2258}}"); +defineMacro("\u2259", "\\html@mathml{\\stackrel{\\tiny\\wedge}{=}}{\\mathrel{\\char`\u2258}}"); +defineMacro("\u225A", "\\html@mathml{\\stackrel{\\tiny\\vee}{=}}{\\mathrel{\\char`\u225A}}"); +defineMacro("\u225B", "\\html@mathml{\\stackrel{\\scriptsize\\star}{=}}" + "{\\mathrel{\\char`\u225B}}"); +defineMacro("\u225D", "\\html@mathml{\\stackrel{\\tiny\\mathrm{def}}{=}}" + "{\\mathrel{\\char`\u225D}}"); +defineMacro("\u225E", "\\html@mathml{\\stackrel{\\tiny\\mathrm{m}}{=}}" + "{\\mathrel{\\char`\u225E}}"); +defineMacro("\u225F", "\\html@mathml{\\stackrel{\\tiny?}{=}}{\\mathrel{\\char`\u225F}}"); + +// Misc Unicode +defineMacro("\u27C2", "\\perp"); +defineMacro("\u203C", "\\mathclose{!\\mkern-0.8mu!}"); +defineMacro("\u220C", "\\notni"); +defineMacro("\u231C", "\\ulcorner"); +defineMacro("\u231D", "\\urcorner"); +defineMacro("\u231E", "\\llcorner"); +defineMacro("\u231F", "\\lrcorner"); +defineMacro("\u00A9", "\\copyright"); +defineMacro("\u00AE", "\\textregistered"); + +// The KaTeX fonts have corners at codepoints that don't match Unicode. +// For MathML purposes, use the Unicode code point. +defineMacro("\\ulcorner", "\\html@mathml{\\@ulcorner}{\\mathop{\\char\"231c}}"); +defineMacro("\\urcorner", "\\html@mathml{\\@urcorner}{\\mathop{\\char\"231d}}"); +defineMacro("\\llcorner", "\\html@mathml{\\@llcorner}{\\mathop{\\char\"231e}}"); +defineMacro("\\lrcorner", "\\html@mathml{\\@lrcorner}{\\mathop{\\char\"231f}}"); + +////////////////////////////////////////////////////////////////////// +// LaTeX_2ε + +// \vdots{\vbox{\baselineskip4\p@ \lineskiplimit\z@ +// \kern6\p@\hbox{.}\hbox{.}\hbox{.}}} +// We'll call \varvdots, which gets a glyph from symbols.js. +// The zero-width rule gets us an equivalent to the vertical 6pt kern. +defineMacro("\\vdots", "{\\varvdots\\rule{0pt}{15pt}}"); +defineMacro("\u22ee", "\\vdots"); + +////////////////////////////////////////////////////////////////////// +// amsmath.sty +// http://mirrors.concertpass.com/tex-archive/macros/latex/required/amsmath/amsmath.pdf + +// Italic Greek capital letters. AMS defines these with \DeclareMathSymbol, +// but they are equivalent to \mathit{\Letter}. +defineMacro("\\varGamma", "\\mathit{\\Gamma}"); +defineMacro("\\varDelta", "\\mathit{\\Delta}"); +defineMacro("\\varTheta", "\\mathit{\\Theta}"); +defineMacro("\\varLambda", "\\mathit{\\Lambda}"); +defineMacro("\\varXi", "\\mathit{\\Xi}"); +defineMacro("\\varPi", "\\mathit{\\Pi}"); +defineMacro("\\varSigma", "\\mathit{\\Sigma}"); +defineMacro("\\varUpsilon", "\\mathit{\\Upsilon}"); +defineMacro("\\varPhi", "\\mathit{\\Phi}"); +defineMacro("\\varPsi", "\\mathit{\\Psi}"); +defineMacro("\\varOmega", "\\mathit{\\Omega}"); + +//\newcommand{\substack}[1]{\subarray{c}#1\endsubarray} +defineMacro("\\substack", "\\begin{subarray}{c}#1\\end{subarray}"); + +// \renewcommand{\colon}{\nobreak\mskip2mu\mathpunct{}\nonscript +// \mkern-\thinmuskip{:}\mskip6muplus1mu\relax} +defineMacro("\\colon", "\\nobreak\\mskip2mu\\mathpunct{}" + "\\mathchoice{\\mkern-3mu}{\\mkern-3mu}{}{}{:}\\mskip6mu\\relax"); + +// \newcommand{\boxed}[1]{\fbox{\m@th$\displaystyle#1$}} +defineMacro("\\boxed", "\\fbox{$\\displaystyle{#1}$}"); + +// \def\iff{\DOTSB\;\Longleftrightarrow\;} +// \def\implies{\DOTSB\;\Longrightarrow\;} +// \def\impliedby{\DOTSB\;\Longleftarrow\;} +defineMacro("\\iff", "\\DOTSB\\;\\Longleftrightarrow\\;"); +defineMacro("\\implies", "\\DOTSB\\;\\Longrightarrow\\;"); +defineMacro("\\impliedby", "\\DOTSB\\;\\Longleftarrow\\;"); + +// \def\dddot#1{{\mathop{#1}\limits^{\vbox to-1.4\ex@{\kern-\tw@\ex@ +// \hbox{\normalfont ...}\vss}}}} +// We use \overset which avoids the vertical shift of \mathop. +defineMacro("\\dddot", "{\\overset{\\raisebox{-0.1ex}{\\normalsize ...}}{#1}}"); +defineMacro("\\ddddot", "{\\overset{\\raisebox{-0.1ex}{\\normalsize ....}}{#1}}"); + +// AMSMath's automatic \dots, based on \mdots@@ macro. +const dotsByToken = { + ',': '\\dotsc', + '\\not': '\\dotsb', + // \keybin@ checks for the following: + '+': '\\dotsb', + '=': '\\dotsb', + '<': '\\dotsb', + '>': '\\dotsb', + '-': '\\dotsb', + '*': '\\dotsb', + ':': '\\dotsb', + // Symbols whose definition starts with \DOTSB: + '\\DOTSB': '\\dotsb', + '\\coprod': '\\dotsb', + '\\bigvee': '\\dotsb', + '\\bigwedge': '\\dotsb', + '\\biguplus': '\\dotsb', + '\\bigcap': '\\dotsb', + '\\bigcup': '\\dotsb', + '\\prod': '\\dotsb', + '\\sum': '\\dotsb', + '\\bigotimes': '\\dotsb', + '\\bigoplus': '\\dotsb', + '\\bigodot': '\\dotsb', + '\\bigsqcup': '\\dotsb', + '\\And': '\\dotsb', + '\\longrightarrow': '\\dotsb', + '\\Longrightarrow': '\\dotsb', + '\\longleftarrow': '\\dotsb', + '\\Longleftarrow': '\\dotsb', + '\\longleftrightarrow': '\\dotsb', + '\\Longleftrightarrow': '\\dotsb', + '\\mapsto': '\\dotsb', + '\\longmapsto': '\\dotsb', + '\\hookrightarrow': '\\dotsb', + '\\doteq': '\\dotsb', + // Symbols whose definition starts with \mathbin: + '\\mathbin': '\\dotsb', + // Symbols whose definition starts with \mathrel: + '\\mathrel': '\\dotsb', + '\\relbar': '\\dotsb', + '\\Relbar': '\\dotsb', + '\\xrightarrow': '\\dotsb', + '\\xleftarrow': '\\dotsb', + // Symbols whose definition starts with \DOTSI: + '\\DOTSI': '\\dotsi', + '\\int': '\\dotsi', + '\\oint': '\\dotsi', + '\\iint': '\\dotsi', + '\\iiint': '\\dotsi', + '\\iiiint': '\\dotsi', + '\\idotsint': '\\dotsi', + // Symbols whose definition starts with \DOTSX: + '\\DOTSX': '\\dotsx' +}; +const dotsbGroups = new Set(['bin', 'rel']); +defineMacro("\\dots", function (context) { + // TODO: If used in text mode, should expand to \textellipsis. + // However, in KaTeX, \textellipsis and \ldots behave the same + // (in text mode), and it's unlikely we'd see any of the math commands + // that affect the behavior of \dots when in text mode. So fine for now + // (until we support \ifmmode ... \else ... \fi). + let thedots = '\\dotso'; + const next = context.expandAfterFuture().text; + if (next in dotsByToken) { + thedots = dotsByToken[next]; + } else if (next.slice(0, 4) === '\\not') { + thedots = '\\dotsb'; + } else if (next in src_symbols.math) { + if (dotsbGroups.has(src_symbols.math[next].group)) { + thedots = '\\dotsb'; + } + } + return thedots; +}); +const spaceAfterDots = { + // \rightdelim@ checks for the following: + ')': true, + ']': true, + '\\rbrack': true, + '\\}': true, + '\\rbrace': true, + '\\rangle': true, + '\\rceil': true, + '\\rfloor': true, + '\\rgroup': true, + '\\rmoustache': true, + '\\right': true, + '\\bigr': true, + '\\biggr': true, + '\\Bigr': true, + '\\Biggr': true, + // \extra@ also tests for the following: + '$': true, + // \extrap@ checks for the following: + ';': true, + '.': true, + ',': true +}; +defineMacro("\\dotso", function (context) { + const next = context.future().text; + if (next in spaceAfterDots) { + return "\\ldots\\,"; + } else { + return "\\ldots"; + } +}); +defineMacro("\\dotsc", function (context) { + const next = context.future().text; + // \dotsc uses \extra@ but not \extrap@, instead specially checking for + // ';' and '.', but doesn't check for ','. + if (next in spaceAfterDots && next !== ',') { + return "\\ldots\\,"; + } else { + return "\\ldots"; + } +}); +defineMacro("\\cdots", function (context) { + const next = context.future().text; + if (next in spaceAfterDots) { + return "\\@cdots\\,"; + } else { + return "\\@cdots"; + } +}); +defineMacro("\\dotsb", "\\cdots"); +defineMacro("\\dotsm", "\\cdots"); +defineMacro("\\dotsi", "\\!\\cdots"); +// amsmath doesn't actually define \dotsx, but \dots followed by a macro +// starting with \DOTSX implies \dotso, and then \extra@ detects this case +// and forces the added `\,`. +defineMacro("\\dotsx", "\\ldots\\,"); + +// \let\DOTSI\relax +// \let\DOTSB\relax +// \let\DOTSX\relax +defineMacro("\\DOTSI", "\\relax"); +defineMacro("\\DOTSB", "\\relax"); +defineMacro("\\DOTSX", "\\relax"); + +// Spacing, based on amsmath.sty's override of LaTeX defaults +// \DeclareRobustCommand{\tmspace}[3]{% +// \ifmmode\mskip#1#2\else\kern#1#3\fi\relax} +defineMacro("\\tmspace", "\\TextOrMath{\\kern#1#3}{\\mskip#1#2}\\relax"); +// \renewcommand{\,}{\tmspace+\thinmuskip{.1667em}} +// TODO: math mode should use \thinmuskip +defineMacro("\\,", "\\tmspace+{3mu}{.1667em}"); +// \let\thinspace\, +defineMacro("\\thinspace", "\\,"); +// \def\>{\mskip\medmuskip} +// \renewcommand{\:}{\tmspace+\medmuskip{.2222em}} +// TODO: \> and math mode of \: should use \medmuskip = 4mu plus 2mu minus 4mu +defineMacro("\\>", "\\mskip{4mu}"); +defineMacro("\\:", "\\tmspace+{4mu}{.2222em}"); +// \let\medspace\: +defineMacro("\\medspace", "\\:"); +// \renewcommand{\;}{\tmspace+\thickmuskip{.2777em}} +// TODO: math mode should use \thickmuskip = 5mu plus 5mu +defineMacro("\\;", "\\tmspace+{5mu}{.2777em}"); +// \let\thickspace\; +defineMacro("\\thickspace", "\\;"); +// \renewcommand{\!}{\tmspace-\thinmuskip{.1667em}} +// TODO: math mode should use \thinmuskip +defineMacro("\\!", "\\tmspace-{3mu}{.1667em}"); +// \let\negthinspace\! +defineMacro("\\negthinspace", "\\!"); +// \newcommand{\negmedspace}{\tmspace-\medmuskip{.2222em}} +// TODO: math mode should use \medmuskip +defineMacro("\\negmedspace", "\\tmspace-{4mu}{.2222em}"); +// \newcommand{\negthickspace}{\tmspace-\thickmuskip{.2777em}} +// TODO: math mode should use \thickmuskip +defineMacro("\\negthickspace", "\\tmspace-{5mu}{.277em}"); +// \def\enspace{\kern.5em } +defineMacro("\\enspace", "\\kern.5em "); +// \def\enskip{\hskip.5em\relax} +defineMacro("\\enskip", "\\hskip.5em\\relax"); +// \def\quad{\hskip1em\relax} +defineMacro("\\quad", "\\hskip1em\\relax"); +// \def\qquad{\hskip2em\relax} +defineMacro("\\qquad", "\\hskip2em\\relax"); + +// \tag@in@display form of \tag +defineMacro("\\tag", "\\@ifstar\\tag@literal\\tag@paren"); +defineMacro("\\tag@paren", "\\tag@literal{({#1})}"); +defineMacro("\\tag@literal", context => { + if (context.macros.get("\\df@tag")) { + throw new src_ParseError("Multiple \\tag"); + } + return "\\gdef\\df@tag{\\text{#1}}"; +}); + +// \renewcommand{\bmod}{\nonscript\mskip-\medmuskip\mkern5mu\mathbin +// {\operator@font mod}\penalty900 +// \mkern5mu\nonscript\mskip-\medmuskip} +// \newcommand{\pod}[1]{\allowbreak +// \if@display\mkern18mu\else\mkern8mu\fi(#1)} +// \renewcommand{\pmod}[1]{\pod{{\operator@font mod}\mkern6mu#1}} +// \newcommand{\mod}[1]{\allowbreak\if@display\mkern18mu +// \else\mkern12mu\fi{\operator@font mod}\,\,#1} +// TODO: math mode should use \medmuskip = 4mu plus 2mu minus 4mu +defineMacro("\\bmod", "\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}" + "\\mathbin{\\rm mod}" + "\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}"); +defineMacro("\\pod", "\\allowbreak" + "\\mathchoice{\\mkern18mu}{\\mkern8mu}{\\mkern8mu}{\\mkern8mu}(#1)"); +defineMacro("\\pmod", "\\pod{{\\rm mod}\\mkern6mu#1}"); +defineMacro("\\mod", "\\allowbreak" + "\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}" + "{\\rm mod}\\,\\,#1"); + +////////////////////////////////////////////////////////////////////// +// LaTeX source2e + +// \expandafter\let\expandafter\@normalcr +// \csname\expandafter\@gobble\string\\ \endcsname +// \DeclareRobustCommand\newline{\@normalcr\relax} +defineMacro("\\newline", "\\\\\\relax"); + +// \def\TeX{T\kern-.1667em\lower.5ex\hbox{E}\kern-.125emX\@} +// TODO: Doesn't normally work in math mode because \@ fails. KaTeX doesn't +// support \@ yet, so that's omitted, and we add \text so that the result +// doesn't look funny in math mode. +defineMacro("\\TeX", "\\textrm{\\html@mathml{" + "T\\kern-.1667em\\raisebox{-.5ex}{E}\\kern-.125emX" + "}{TeX}}"); + +// \DeclareRobustCommand{\LaTeX}{L\kern-.36em% +// {\sbox\z@ T% +// \vbox to\ht\z@{\hbox{\check@mathfonts +// \fontsize\sf@size\z@ +// \math@fontsfalse\selectfont +// A}% +// \vss}% +// }% +// \kern-.15em% +// \TeX} +// This code aligns the top of the A with the T (from the perspective of TeX's +// boxes, though visually the A appears to extend above slightly). +// We compute the corresponding \raisebox when A is rendered in \normalsize +// \scriptstyle, which has a scale factor of 0.7 (see Options.js). +const latexRaiseA = makeEm(fontMetricsData['Main-Regular']["T".charCodeAt(0)][1] - 0.7 * fontMetricsData['Main-Regular']["A".charCodeAt(0)][1]); +defineMacro("\\LaTeX", "\\textrm{\\html@mathml{" + ("L\\kern-.36em\\raisebox{" + latexRaiseA + "}{\\scriptstyle A}") + "\\kern-.15em\\TeX}{LaTeX}}"); + +// New KaTeX logo based on tweaking LaTeX logo +defineMacro("\\KaTeX", "\\textrm{\\html@mathml{" + ("K\\kern-.17em\\raisebox{" + latexRaiseA + "}{\\scriptstyle A}") + "\\kern-.15em\\TeX}{KaTeX}}"); + +// \DeclareRobustCommand\hspace{\@ifstar\@hspacer\@hspace} +// \def\@hspace#1{\hskip #1\relax} +// \def\@hspacer#1{\vrule \@width\z@\nobreak +// \hskip #1\hskip \z@skip} +defineMacro("\\hspace", "\\@ifstar\\@hspacer\\@hspace"); +defineMacro("\\@hspace", "\\hskip #1\\relax"); +defineMacro("\\@hspacer", "\\rule{0pt}{0pt}\\hskip #1\\relax"); + +////////////////////////////////////////////////////////////////////// +// mathtools.sty + +//\providecommand\ordinarycolon{:} +defineMacro("\\ordinarycolon", ":"); +//\def\vcentcolon{\mathrel{\mathop\ordinarycolon}} +//TODO(edemaine): Not yet centered. Fix via \raisebox or #726 +defineMacro("\\vcentcolon", "\\mathrel{\\mathop\\ordinarycolon}"); +// \providecommand*\dblcolon{\vcentcolon\mathrel{\mkern-.9mu}\vcentcolon} +defineMacro("\\dblcolon", "\\html@mathml{" + "\\mathrel{\\vcentcolon\\mathrel{\\mkern-.9mu}\\vcentcolon}}" + "{\\mathop{\\char\"2237}}"); +// \providecommand*\coloneqq{\vcentcolon\mathrel{\mkern-1.2mu}=} +defineMacro("\\coloneqq", "\\html@mathml{" + "\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}=}}" + "{\\mathop{\\char\"2254}}"); // ≔ +// \providecommand*\Coloneqq{\dblcolon\mathrel{\mkern-1.2mu}=} +defineMacro("\\Coloneqq", "\\html@mathml{" + "\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}=}}" + "{\\mathop{\\char\"2237\\char\"3d}}"); +// \providecommand*\coloneq{\vcentcolon\mathrel{\mkern-1.2mu}\mathrel{-}} +defineMacro("\\coloneq", "\\html@mathml{" + "\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}" + "{\\mathop{\\char\"3a\\char\"2212}}"); +// \providecommand*\Coloneq{\dblcolon\mathrel{\mkern-1.2mu}\mathrel{-}} +defineMacro("\\Coloneq", "\\html@mathml{" + "\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}" + "{\\mathop{\\char\"2237\\char\"2212}}"); +// \providecommand*\eqqcolon{=\mathrel{\mkern-1.2mu}\vcentcolon} +defineMacro("\\eqqcolon", "\\html@mathml{" + "\\mathrel{=\\mathrel{\\mkern-1.2mu}\\vcentcolon}}" + "{\\mathop{\\char\"2255}}"); // ≕ +// \providecommand*\Eqqcolon{=\mathrel{\mkern-1.2mu}\dblcolon} +defineMacro("\\Eqqcolon", "\\html@mathml{" + "\\mathrel{=\\mathrel{\\mkern-1.2mu}\\dblcolon}}" + "{\\mathop{\\char\"3d\\char\"2237}}"); +// \providecommand*\eqcolon{\mathrel{-}\mathrel{\mkern-1.2mu}\vcentcolon} +defineMacro("\\eqcolon", "\\html@mathml{" + "\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\vcentcolon}}" + "{\\mathop{\\char\"2239}}"); +// \providecommand*\Eqcolon{\mathrel{-}\mathrel{\mkern-1.2mu}\dblcolon} +defineMacro("\\Eqcolon", "\\html@mathml{" + "\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\dblcolon}}" + "{\\mathop{\\char\"2212\\char\"2237}}"); +// \providecommand*\colonapprox{\vcentcolon\mathrel{\mkern-1.2mu}\approx} +defineMacro("\\colonapprox", "\\html@mathml{" + "\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\approx}}" + "{\\mathop{\\char\"3a\\char\"2248}}"); +// \providecommand*\Colonapprox{\dblcolon\mathrel{\mkern-1.2mu}\approx} +defineMacro("\\Colonapprox", "\\html@mathml{" + "\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\approx}}" + "{\\mathop{\\char\"2237\\char\"2248}}"); +// \providecommand*\colonsim{\vcentcolon\mathrel{\mkern-1.2mu}\sim} +defineMacro("\\colonsim", "\\html@mathml{" + "\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\sim}}" + "{\\mathop{\\char\"3a\\char\"223c}}"); +// \providecommand*\Colonsim{\dblcolon\mathrel{\mkern-1.2mu}\sim} +defineMacro("\\Colonsim", "\\html@mathml{" + "\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\sim}}" + "{\\mathop{\\char\"2237\\char\"223c}}"); + +// Some Unicode characters are implemented with macros to mathtools functions. +defineMacro("\u2237", "\\dblcolon"); // :: +defineMacro("\u2239", "\\eqcolon"); // -: +defineMacro("\u2254", "\\coloneqq"); // := +defineMacro("\u2255", "\\eqqcolon"); // =: +defineMacro("\u2A74", "\\Coloneqq"); // ::= + +////////////////////////////////////////////////////////////////////// +// colonequals.sty + +// Alternate names for mathtools's macros: +defineMacro("\\ratio", "\\vcentcolon"); +defineMacro("\\coloncolon", "\\dblcolon"); +defineMacro("\\colonequals", "\\coloneqq"); +defineMacro("\\coloncolonequals", "\\Coloneqq"); +defineMacro("\\equalscolon", "\\eqqcolon"); +defineMacro("\\equalscoloncolon", "\\Eqqcolon"); +defineMacro("\\colonminus", "\\coloneq"); +defineMacro("\\coloncolonminus", "\\Coloneq"); +defineMacro("\\minuscolon", "\\eqcolon"); +defineMacro("\\minuscoloncolon", "\\Eqcolon"); +// \colonapprox name is same in mathtools and colonequals. +defineMacro("\\coloncolonapprox", "\\Colonapprox"); +// \colonsim name is same in mathtools and colonequals. +defineMacro("\\coloncolonsim", "\\Colonsim"); + +// Additional macros, implemented by analogy with mathtools definitions: +defineMacro("\\simcolon", "\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\vcentcolon}"); +defineMacro("\\simcoloncolon", "\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\dblcolon}"); +defineMacro("\\approxcolon", "\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\vcentcolon}"); +defineMacro("\\approxcoloncolon", "\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\dblcolon}"); + +// Present in newtxmath, pxfonts and txfonts +defineMacro("\\notni", "\\html@mathml{\\not\\ni}{\\mathrel{\\char`\u220C}}"); +defineMacro("\\limsup", "\\DOTSB\\operatorname*{lim\\,sup}"); +defineMacro("\\liminf", "\\DOTSB\\operatorname*{lim\\,inf}"); + +////////////////////////////////////////////////////////////////////// +// From amsopn.sty +defineMacro("\\injlim", "\\DOTSB\\operatorname*{inj\\,lim}"); +defineMacro("\\projlim", "\\DOTSB\\operatorname*{proj\\,lim}"); +defineMacro("\\varlimsup", "\\DOTSB\\operatorname*{\\overline{lim}}"); +defineMacro("\\varliminf", "\\DOTSB\\operatorname*{\\underline{lim}}"); +defineMacro("\\varinjlim", "\\DOTSB\\operatorname*{\\underrightarrow{lim}}"); +defineMacro("\\varprojlim", "\\DOTSB\\operatorname*{\\underleftarrow{lim}}"); + +////////////////////////////////////////////////////////////////////// +// MathML alternates for KaTeX glyphs in the Unicode private area +defineMacro("\\gvertneqq", "\\html@mathml{\\@gvertneqq}{\u2269}"); +defineMacro("\\lvertneqq", "\\html@mathml{\\@lvertneqq}{\u2268}"); +defineMacro("\\ngeqq", "\\html@mathml{\\@ngeqq}{\u2271}"); +defineMacro("\\ngeqslant", "\\html@mathml{\\@ngeqslant}{\u2271}"); +defineMacro("\\nleqq", "\\html@mathml{\\@nleqq}{\u2270}"); +defineMacro("\\nleqslant", "\\html@mathml{\\@nleqslant}{\u2270}"); +defineMacro("\\nshortmid", "\\html@mathml{\\@nshortmid}{∤}"); +defineMacro("\\nshortparallel", "\\html@mathml{\\@nshortparallel}{∦}"); +defineMacro("\\nsubseteqq", "\\html@mathml{\\@nsubseteqq}{\u2288}"); +defineMacro("\\nsupseteqq", "\\html@mathml{\\@nsupseteqq}{\u2289}"); +defineMacro("\\varsubsetneq", "\\html@mathml{\\@varsubsetneq}{⊊}"); +defineMacro("\\varsubsetneqq", "\\html@mathml{\\@varsubsetneqq}{⫋}"); +defineMacro("\\varsupsetneq", "\\html@mathml{\\@varsupsetneq}{⊋}"); +defineMacro("\\varsupsetneqq", "\\html@mathml{\\@varsupsetneqq}{⫌}"); +defineMacro("\\imath", "\\html@mathml{\\@imath}{\u0131}"); +defineMacro("\\jmath", "\\html@mathml{\\@jmath}{\u0237}"); + +////////////////////////////////////////////////////////////////////// +// stmaryrd and semantic + +// The stmaryrd and semantic packages render the next four items by calling a +// glyph. Those glyphs do not exist in the KaTeX fonts. Hence the macros. + +defineMacro("\\llbracket", "\\html@mathml{" + "\\mathopen{[\\mkern-3.2mu[}}" + "{\\mathopen{\\char`\u27e6}}"); +defineMacro("\\rrbracket", "\\html@mathml{" + "\\mathclose{]\\mkern-3.2mu]}}" + "{\\mathclose{\\char`\u27e7}}"); +defineMacro("\u27e6", "\\llbracket"); // blackboard bold [ +defineMacro("\u27e7", "\\rrbracket"); // blackboard bold ] + +defineMacro("\\lBrace", "\\html@mathml{" + "\\mathopen{\\{\\mkern-3.2mu[}}" + "{\\mathopen{\\char`\u2983}}"); +defineMacro("\\rBrace", "\\html@mathml{" + "\\mathclose{]\\mkern-3.2mu\\}}}" + "{\\mathclose{\\char`\u2984}}"); +defineMacro("\u2983", "\\lBrace"); // blackboard bold { +defineMacro("\u2984", "\\rBrace"); // blackboard bold } + +// TODO: Create variable sized versions of the last two items. I believe that +// will require new font glyphs. + +// The stmaryrd function `\minuso` provides a "Plimsoll" symbol that +// superimposes the characters \circ and \mathminus. Used in chemistry. +defineMacro("\\minuso", "\\mathbin{\\html@mathml{" + "{\\mathrlap{\\mathchoice{\\kern{0.145em}}{\\kern{0.145em}}" + "{\\kern{0.1015em}}{\\kern{0.0725em}}\\circ}{-}}}" + "{\\char`⦵}}"); +defineMacro("⦵", "\\minuso"); + +////////////////////////////////////////////////////////////////////// +// texvc.sty + +// The texvc package contains macros available in mediawiki pages. +// We omit the functions deprecated at +// https://en.wikipedia.org/wiki/Help:Displaying_a_formula#Deprecated_syntax + +// We also omit texvc's \O, which conflicts with \text{\O} + +defineMacro("\\darr", "\\downarrow"); +defineMacro("\\dArr", "\\Downarrow"); +defineMacro("\\Darr", "\\Downarrow"); +defineMacro("\\lang", "\\langle"); +defineMacro("\\rang", "\\rangle"); +defineMacro("\\uarr", "\\uparrow"); +defineMacro("\\uArr", "\\Uparrow"); +defineMacro("\\Uarr", "\\Uparrow"); +defineMacro("\\N", "\\mathbb{N}"); +defineMacro("\\R", "\\mathbb{R}"); +defineMacro("\\Z", "\\mathbb{Z}"); +defineMacro("\\alef", "\\aleph"); +defineMacro("\\alefsym", "\\aleph"); +defineMacro("\\Alpha", "\\mathrm{A}"); +defineMacro("\\Beta", "\\mathrm{B}"); +defineMacro("\\bull", "\\bullet"); +defineMacro("\\Chi", "\\mathrm{X}"); +defineMacro("\\clubs", "\\clubsuit"); +defineMacro("\\cnums", "\\mathbb{C}"); +defineMacro("\\Complex", "\\mathbb{C}"); +defineMacro("\\Dagger", "\\ddagger"); +defineMacro("\\diamonds", "\\diamondsuit"); +defineMacro("\\empty", "\\emptyset"); +defineMacro("\\Epsilon", "\\mathrm{E}"); +defineMacro("\\Eta", "\\mathrm{H}"); +defineMacro("\\exist", "\\exists"); +defineMacro("\\harr", "\\leftrightarrow"); +defineMacro("\\hArr", "\\Leftrightarrow"); +defineMacro("\\Harr", "\\Leftrightarrow"); +defineMacro("\\hearts", "\\heartsuit"); +defineMacro("\\image", "\\Im"); +defineMacro("\\infin", "\\infty"); +defineMacro("\\Iota", "\\mathrm{I}"); +defineMacro("\\isin", "\\in"); +defineMacro("\\Kappa", "\\mathrm{K}"); +defineMacro("\\larr", "\\leftarrow"); +defineMacro("\\lArr", "\\Leftarrow"); +defineMacro("\\Larr", "\\Leftarrow"); +defineMacro("\\lrarr", "\\leftrightarrow"); +defineMacro("\\lrArr", "\\Leftrightarrow"); +defineMacro("\\Lrarr", "\\Leftrightarrow"); +defineMacro("\\Mu", "\\mathrm{M}"); +defineMacro("\\natnums", "\\mathbb{N}"); +defineMacro("\\Nu", "\\mathrm{N}"); +defineMacro("\\Omicron", "\\mathrm{O}"); +defineMacro("\\plusmn", "\\pm"); +defineMacro("\\rarr", "\\rightarrow"); +defineMacro("\\rArr", "\\Rightarrow"); +defineMacro("\\Rarr", "\\Rightarrow"); +defineMacro("\\real", "\\Re"); +defineMacro("\\reals", "\\mathbb{R}"); +defineMacro("\\Reals", "\\mathbb{R}"); +defineMacro("\\Rho", "\\mathrm{P}"); +defineMacro("\\sdot", "\\cdot"); +defineMacro("\\sect", "\\S"); +defineMacro("\\spades", "\\spadesuit"); +defineMacro("\\sub", "\\subset"); +defineMacro("\\sube", "\\subseteq"); +defineMacro("\\supe", "\\supseteq"); +defineMacro("\\Tau", "\\mathrm{T}"); +defineMacro("\\thetasym", "\\vartheta"); +// TODO: defineMacro("\\varcoppa", "\\\mbox{\\coppa}"); +defineMacro("\\weierp", "\\wp"); +defineMacro("\\Zeta", "\\mathrm{Z}"); + +////////////////////////////////////////////////////////////////////// +// statmath.sty +// https://ctan.math.illinois.edu/macros/latex/contrib/statmath/statmath.pdf + +defineMacro("\\argmin", "\\DOTSB\\operatorname*{arg\\,min}"); +defineMacro("\\argmax", "\\DOTSB\\operatorname*{arg\\,max}"); +defineMacro("\\plim", "\\DOTSB\\mathop{\\operatorname{plim}}\\limits"); + +////////////////////////////////////////////////////////////////////// +// braket.sty +// http://ctan.math.washington.edu/tex-archive/macros/latex/contrib/braket/braket.pdf + +defineMacro("\\bra", "\\mathinner{\\langle{#1}|}"); +defineMacro("\\ket", "\\mathinner{|{#1}\\rangle}"); +defineMacro("\\braket", "\\mathinner{\\langle{#1}\\rangle}"); +defineMacro("\\Bra", "\\left\\langle#1\\right|"); +defineMacro("\\Ket", "\\left|#1\\right\\rangle"); +const braketHelper = one => context => { + const left = context.consumeArg().tokens; + const middle = context.consumeArg().tokens; + const middleDouble = context.consumeArg().tokens; + const right = context.consumeArg().tokens; + const oldMiddle = context.macros.get("|"); + const oldMiddleDouble = context.macros.get("\\|"); + context.macros.beginGroup(); + const midMacro = double => context => { + if (one) { + // Only modify the first instance of | or \| + context.macros.set("|", oldMiddle); + if (middleDouble.length) { + context.macros.set("\\|", oldMiddleDouble); + } + } + let doubled = double; + if (!double && middleDouble.length) { + // Mimic \@ifnextchar + const nextToken = context.future(); + if (nextToken.text === "|") { + context.popToken(); + doubled = true; + } + } + return { + tokens: doubled ? middleDouble : middle, + numArgs: 0 + }; + }; + context.macros.set("|", midMacro(false)); + if (middleDouble.length) { + context.macros.set("\\|", midMacro(true)); + } + const arg = context.consumeArg().tokens; + const expanded = context.expandTokens([...right, ...arg, ...left // reversed + ]); + context.macros.endGroup(); + return { + tokens: expanded.reverse(), + numArgs: 0 + }; +}; +defineMacro("\\bra@ket", braketHelper(false)); +defineMacro("\\bra@set", braketHelper(true)); +defineMacro("\\Braket", "\\bra@ket{\\left\\langle}" + "{\\,\\middle\\vert\\,}{\\,\\middle\\vert\\,}{\\right\\rangle}"); +defineMacro("\\Set", "\\bra@set{\\left\\{\\:}" + "{\\;\\middle\\vert\\;}{\\;\\middle\\Vert\\;}{\\:\\right\\}}"); +defineMacro("\\set", "\\bra@set{\\{\\,}{\\mid}{}{\\,\\}}"); +// has no support for special || or \| + +////////////////////////////////////////////////////////////////////// +// actuarialangle.dtx +defineMacro("\\angln", "{\\angl n}"); + +// Custom Khan Academy colors, should be moved to an optional package +defineMacro("\\blue", "\\textcolor{##6495ed}{#1}"); +defineMacro("\\orange", "\\textcolor{##ffa500}{#1}"); +defineMacro("\\pink", "\\textcolor{##ff00af}{#1}"); +defineMacro("\\red", "\\textcolor{##df0030}{#1}"); +defineMacro("\\green", "\\textcolor{##28ae7b}{#1}"); +defineMacro("\\gray", "\\textcolor{gray}{#1}"); +defineMacro("\\purple", "\\textcolor{##9d38bd}{#1}"); +defineMacro("\\blueA", "\\textcolor{##ccfaff}{#1}"); +defineMacro("\\blueB", "\\textcolor{##80f6ff}{#1}"); +defineMacro("\\blueC", "\\textcolor{##63d9ea}{#1}"); +defineMacro("\\blueD", "\\textcolor{##11accd}{#1}"); +defineMacro("\\blueE", "\\textcolor{##0c7f99}{#1}"); +defineMacro("\\tealA", "\\textcolor{##94fff5}{#1}"); +defineMacro("\\tealB", "\\textcolor{##26edd5}{#1}"); +defineMacro("\\tealC", "\\textcolor{##01d1c1}{#1}"); +defineMacro("\\tealD", "\\textcolor{##01a995}{#1}"); +defineMacro("\\tealE", "\\textcolor{##208170}{#1}"); +defineMacro("\\greenA", "\\textcolor{##b6ffb0}{#1}"); +defineMacro("\\greenB", "\\textcolor{##8af281}{#1}"); +defineMacro("\\greenC", "\\textcolor{##74cf70}{#1}"); +defineMacro("\\greenD", "\\textcolor{##1fab54}{#1}"); +defineMacro("\\greenE", "\\textcolor{##0d923f}{#1}"); +defineMacro("\\goldA", "\\textcolor{##ffd0a9}{#1}"); +defineMacro("\\goldB", "\\textcolor{##ffbb71}{#1}"); +defineMacro("\\goldC", "\\textcolor{##ff9c39}{#1}"); +defineMacro("\\goldD", "\\textcolor{##e07d10}{#1}"); +defineMacro("\\goldE", "\\textcolor{##a75a05}{#1}"); +defineMacro("\\redA", "\\textcolor{##fca9a9}{#1}"); +defineMacro("\\redB", "\\textcolor{##ff8482}{#1}"); +defineMacro("\\redC", "\\textcolor{##f9685d}{#1}"); +defineMacro("\\redD", "\\textcolor{##e84d39}{#1}"); +defineMacro("\\redE", "\\textcolor{##bc2612}{#1}"); +defineMacro("\\maroonA", "\\textcolor{##ffbde0}{#1}"); +defineMacro("\\maroonB", "\\textcolor{##ff92c6}{#1}"); +defineMacro("\\maroonC", "\\textcolor{##ed5fa6}{#1}"); +defineMacro("\\maroonD", "\\textcolor{##ca337c}{#1}"); +defineMacro("\\maroonE", "\\textcolor{##9e034e}{#1}"); +defineMacro("\\purpleA", "\\textcolor{##ddd7ff}{#1}"); +defineMacro("\\purpleB", "\\textcolor{##c6b9fc}{#1}"); +defineMacro("\\purpleC", "\\textcolor{##aa87ff}{#1}"); +defineMacro("\\purpleD", "\\textcolor{##7854ab}{#1}"); +defineMacro("\\purpleE", "\\textcolor{##543b78}{#1}"); +defineMacro("\\mintA", "\\textcolor{##f5f9e8}{#1}"); +defineMacro("\\mintB", "\\textcolor{##edf2df}{#1}"); +defineMacro("\\mintC", "\\textcolor{##e0e5cc}{#1}"); +defineMacro("\\grayA", "\\textcolor{##f6f7f7}{#1}"); +defineMacro("\\grayB", "\\textcolor{##f0f1f2}{#1}"); +defineMacro("\\grayC", "\\textcolor{##e3e5e6}{#1}"); +defineMacro("\\grayD", "\\textcolor{##d6d8da}{#1}"); +defineMacro("\\grayE", "\\textcolor{##babec2}{#1}"); +defineMacro("\\grayF", "\\textcolor{##888d93}{#1}"); +defineMacro("\\grayG", "\\textcolor{##626569}{#1}"); +defineMacro("\\grayH", "\\textcolor{##3b3e40}{#1}"); +defineMacro("\\grayI", "\\textcolor{##21242c}{#1}"); +defineMacro("\\kaBlue", "\\textcolor{##314453}{#1}"); +defineMacro("\\kaGreen", "\\textcolor{##71B307}{#1}"); +;// ./src/MacroExpander.ts +/** + * This file contains the “gullet” where macros are expanded + * until only non-macro tokens remain. + */ + + + + + + + + + +// List of commands that act like macros but aren't defined as a macro, +// function, or symbol. Used in `isDefined`. +const implicitCommands = { + "^": true, + // Parser.js + "_": true, + // Parser.js + "\\limits": true, + // Parser.js + "\\nolimits": true // Parser.js +}; +class MacroExpander { + constructor(input, settings, mode) { + this.settings = void 0; + this.expansionCount = void 0; + this.lexer = void 0; + this.macros = void 0; + this.stack = void 0; + this.mode = void 0; + this.settings = settings; + this.expansionCount = 0; + this.feed(input); + // Make new global namespace + this.macros = new Namespace(src_macros, settings.macros); + this.mode = mode; + this.stack = []; // contains tokens in REVERSE order + } + + /** + * Feed a new input string to the same MacroExpander + * (with existing macros etc.). + */ + feed(input) { + this.lexer = new Lexer(input, this.settings); + } + + /** + * Switches between "text" and "math" modes. + */ + switchMode(newMode) { + this.mode = newMode; + } + + /** + * Start a new group nesting within all namespaces. + */ + beginGroup() { + this.macros.beginGroup(); + } + + /** + * End current group nesting within all namespaces. + */ + endGroup() { + this.macros.endGroup(); + } + + /** + * Ends all currently nested groups (if any), restoring values before the + * groups began. Useful in case of an error in the middle of parsing. + */ + endGroups() { + this.macros.endGroups(); + } + + /** + * Returns the topmost token on the stack, without expanding it. + * Similar in behavior to TeX's `\futurelet`. + */ + future() { + if (this.stack.length === 0) { + this.pushToken(this.lexer.lex()); + } + return this.stack[this.stack.length - 1]; + } + + /** + * Remove and return the next unexpanded token. + */ + popToken() { + this.future(); // ensure non-empty stack + return this.stack.pop(); + } + + /** + * Add a given token to the token stack. In particular, this get be used + * to put back a token returned from one of the other methods. + */ + pushToken(token) { + this.stack.push(token); + } + + /** + * Append an array of tokens to the token stack. + */ + pushTokens(tokens) { + this.stack.push(...tokens); + } + + /** + * Find an macro argument without expanding tokens and append the array of + * tokens to the token stack. Uses Token as a container for the result. + */ + scanArgument(isOptional) { + let start; + let end; + let tokens; + if (isOptional) { + this.consumeSpaces(); // \@ifnextchar gobbles any space following it + if (this.future().text !== "[") { + return null; + } + start = this.popToken(); // don't include [ in tokens + ({ + tokens, + end + } = this.consumeArg(["]"])); + } else { + ({ + tokens, + start, + end + } = this.consumeArg()); + } + + // indicate the end of an argument + this.pushToken(new Token("EOF", end.loc)); + this.pushTokens(tokens); + return new Token("", SourceLocation.range(start, end)); + } + + /** + * Consume all following space tokens, without expansion. + */ + consumeSpaces() { + for (;;) { + const token = this.future(); + if (token.text === " ") { + this.stack.pop(); + } else { + break; + } + } + } + + /** + * Consume an argument from the token stream, and return the resulting array + * of tokens and start/end token. + */ + consumeArg(delims) { + // The argument for a delimited parameter is the shortest (possibly + // empty) sequence of tokens with properly nested {...} groups that is + // followed ... by this particular list of non-parameter tokens. + // The argument for an undelimited parameter is the next nonblank + // token, unless that token is ‘{’, when the argument will be the + // entire {...} group that follows. + const tokens = []; + const isDelimited = delims && delims.length > 0; + if (!isDelimited) { + // Ignore spaces between arguments. As the TeXbook says: + // "After you have said ‘\def\row#1#2{...}’, you are allowed to + // put spaces between the arguments (e.g., ‘\row x n’), because + // TeX doesn’t use single spaces as undelimited arguments." + this.consumeSpaces(); + } + const start = this.future(); + let tok; + let depth = 0; + let match = 0; + do { + tok = this.popToken(); + tokens.push(tok); + if (tok.text === "{") { + ++depth; + } else if (tok.text === "}") { + --depth; + if (depth === -1) { + throw new src_ParseError("Extra }", tok); + } + } else if (tok.text === "EOF") { + throw new src_ParseError("Unexpected end of input in a macro argument" + ", expected '" + (delims && isDelimited ? delims[match] : "}") + "'", tok); + } + if (delims && isDelimited) { + if ((depth === 0 || depth === 1 && delims[match] === "{") && tok.text === delims[match]) { + ++match; + if (match === delims.length) { + // don't include delims in tokens + tokens.splice(-match, match); + break; + } + } else { + match = 0; + } + } + } while (depth !== 0 || isDelimited); + // If the argument found ... has the form ‘{}’, + // ... the outermost braces enclosing the argument are removed + if (start.text === "{" && tokens[tokens.length - 1].text === "}") { + tokens.pop(); + tokens.shift(); + } + tokens.reverse(); // to fit in with stack order + return { + tokens, + start, + end: tok + }; + } + + /** + * Consume the specified number of (delimited) arguments from the token + * stream and return the resulting array of arguments. + */ + consumeArgs(numArgs, delimiters) { + if (delimiters) { + if (delimiters.length !== numArgs + 1) { + throw new src_ParseError("The length of delimiters doesn't match the number of args!"); + } + const delims = delimiters[0]; + for (let i = 0; i < delims.length; i++) { + const tok = this.popToken(); + if (delims[i] !== tok.text) { + throw new src_ParseError("Use of the macro doesn't match its definition", tok); + } + } + } + const args = []; + for (let i = 0; i < numArgs; i++) { + args.push(this.consumeArg(delimiters && delimiters[i + 1]).tokens); + } + return args; + } + + /** + * Increment `expansionCount` by the specified amount. + * Throw an error if it exceeds `maxExpand`. + */ + countExpansion(amount) { + this.expansionCount += amount; + if (this.expansionCount > this.settings.maxExpand) { + throw new src_ParseError("Too many expansions: infinite loop or " + "need to increase maxExpand setting"); + } + } + + /** + * Expand the next token only once if possible. + * + * If the token is expanded, the resulting tokens will be pushed onto + * the stack in reverse order, and the number of such tokens will be + * returned. This number might be zero or positive. + * + * If not, the return value is `false`, and the next token remains at the + * top of the stack. + * + * In either case, the next token will be on the top of the stack, + * or the stack will be empty (in case of empty expansion + * and no other tokens). + * + * Used to implement `expandAfterFuture` and `expandNextToken`. + * + * If expandableOnly, only expandable tokens are expanded and + * an undefined control sequence results in an error. + */ + expandOnce(expandableOnly) { + const topToken = this.popToken(); + const name = topToken.text; + const expansion = !topToken.noexpand ? this._getExpansion(name) : null; + if (expansion == null || expandableOnly && expansion.unexpandable) { + if (expandableOnly && expansion == null && name[0] === "\\" && !this.isDefined(name)) { + throw new src_ParseError("Undefined control sequence: " + name); + } + this.pushToken(topToken); + return false; + } + this.countExpansion(1); + let tokens = expansion.tokens; + const args = this.consumeArgs(expansion.numArgs, expansion.delimiters); + if (expansion.numArgs) { + // paste arguments in place of the placeholders + tokens = tokens.slice(); // make a shallow copy + for (let i = tokens.length - 1; i >= 0; --i) { + let tok = tokens[i]; + if (tok.text === "#") { + if (i === 0) { + throw new src_ParseError("Incomplete placeholder at end of macro body", tok); + } + tok = tokens[--i]; // next token on stack + if (tok.text === "#") { + // ## → # + tokens.splice(i + 1, 1); // drop first # + } else if (/^[1-9]$/.test(tok.text)) { + // replace the placeholder with the indicated argument + tokens.splice(i, 2, ...args[+tok.text - 1]); + } else { + throw new src_ParseError("Not a valid argument number", tok); + } + } + } + } + // Concatenate expansion onto top of stack. + this.pushTokens(tokens); + return tokens.length; + } + + /** + * Expand the next token only once (if possible), and return the resulting + * top token on the stack (without removing anything from the stack). + * Similar in behavior to TeX's `\expandafter\futurelet`. + * Equivalent to expandOnce() followed by future(). + */ + expandAfterFuture() { + this.expandOnce(); + return this.future(); + } + + /** + * Recursively expand first token, then return first non-expandable token. + */ + expandNextToken() { + for (;;) { + if (this.expandOnce() === false) { + // fully expanded + const token = this.stack.pop(); + // the token after \noexpand is interpreted as if its meaning + // were ‘\relax’ + if (token.treatAsRelax) { + token.text = "\\relax"; + } + return token; + } + } + } + + /** + * Fully expand the given macro name and return the resulting list of + * tokens, or return `undefined` if no such macro is defined. + */ + expandMacro(name) { + return this.macros.has(name) ? this.expandTokens([new Token(name)]) : undefined; + } + + /** + * Fully expand the given token stream and return the resulting list of + * tokens. Note that the input tokens are in reverse order, but the + * output tokens are in forward order. + */ + expandTokens(tokens) { + const output = []; + const oldStackLength = this.stack.length; + this.pushTokens(tokens); + while (this.stack.length > oldStackLength) { + // Expand only expandable tokens + if (this.expandOnce(true) === false) { + // fully expanded + const token = this.stack.pop(); + if (token.treatAsRelax) { + // the expansion of \noexpand is the token itself + token.noexpand = false; + token.treatAsRelax = false; + } + output.push(token); + } + } + // Count all of these tokens as additional expansions, to prevent + // exponential blowup from linearly many \edef's. + this.countExpansion(output.length); + return output; + } + + /** + * Fully expand the given macro name and return the result as a string, + * or return `undefined` if no such macro is defined. + */ + expandMacroAsText(name) { + const tokens = this.expandMacro(name); + if (tokens) { + return tokens.map(token => token.text).join(""); + } else { + return tokens; + } + } + + /** + * Returns the expanded macro as a reversed array of tokens and a macro + * argument count. Or returns `null` if no such macro. + */ + _getExpansion(name) { + const definition = this.macros.get(name); + if (definition == null) { + // mainly checking for undefined here + return definition; + } + // If a single character has an associated catcode other than 13 + // (active character), then don't expand it. + if (name.length === 1) { + const catcode = this.lexer.catcodes[name]; + if (catcode != null && catcode !== 13) { + return; + } + } + const expansion = typeof definition === "function" ? definition(this) : definition; + if (typeof expansion === "string") { + let numArgs = 0; + if (expansion.includes("#")) { + const stripped = expansion.replace(/##/g, ""); + while (stripped.includes("#" + (numArgs + 1))) { + ++numArgs; + } + } + const bodyLexer = new Lexer(expansion, this.settings); + const tokens = []; + let tok = bodyLexer.lex(); + while (tok.text !== "EOF") { + tokens.push(tok); + tok = bodyLexer.lex(); + } + tokens.reverse(); // to fit in with stack using push and pop + const expanded = { + tokens, + numArgs + }; + return expanded; + } + return expansion; + } + + /** + * Determine whether a command is currently "defined" (has some + * functionality), meaning that it's a macro (in the current group), + * a function, a symbol, or one of the special commands listed in + * `implicitCommands`. + */ + isDefined(name) { + return this.macros.has(name) || src_functions.hasOwnProperty(name) || src_symbols.math.hasOwnProperty(name) || src_symbols.text.hasOwnProperty(name) || implicitCommands.hasOwnProperty(name); + } + + /** + * Determine whether a command is expandable. + */ + isExpandable(name) { + const macro = this.macros.get(name); + return macro != null ? typeof macro === "string" || typeof macro === "function" || !macro.unexpandable : src_functions.hasOwnProperty(name) && !src_functions[name].primitive; + } +} +;// ./src/unicodeSupOrSub.ts +// Helpers for Parser.js handling of Unicode (sub|super)script characters. + +const unicodeSubRegEx = /^[₊₋₌₍₎₀₁₂₃₄₅₆₇₈₉ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓᵦᵧᵨᵩᵪ]/; +const uSubsAndSups = Object.freeze({ + '₊': '+', + '₋': '-', + '₌': '=', + '₍': '(', + '₎': ')', + '₀': '0', + '₁': '1', + '₂': '2', + '₃': '3', + '₄': '4', + '₅': '5', + '₆': '6', + '₇': '7', + '₈': '8', + '₉': '9', + '\u2090': 'a', + '\u2091': 'e', + '\u2095': 'h', + '\u1D62': 'i', + '\u2C7C': 'j', + '\u2096': 'k', + '\u2097': 'l', + '\u2098': 'm', + '\u2099': 'n', + '\u2092': 'o', + '\u209A': 'p', + '\u1D63': 'r', + '\u209B': 's', + '\u209C': 't', + '\u1D64': 'u', + '\u1D65': 'v', + '\u2093': 'x', + '\u1D66': 'β', + '\u1D67': 'γ', + '\u1D68': 'ρ', + '\u1D69': '\u03d5', + '\u1D6A': 'χ', + '⁺': '+', + '⁻': '-', + '⁼': '=', + '⁽': '(', + '⁾': ')', + '⁰': '0', + '¹': '1', + '²': '2', + '³': '3', + '⁴': '4', + '⁵': '5', + '⁶': '6', + '⁷': '7', + '⁸': '8', + '⁹': '9', + '\u1D2C': 'A', + '\u1D2E': 'B', + '\u1D30': 'D', + '\u1D31': 'E', + '\u1D33': 'G', + '\u1D34': 'H', + '\u1D35': 'I', + '\u1D36': 'J', + '\u1D37': 'K', + '\u1D38': 'L', + '\u1D39': 'M', + '\u1D3A': 'N', + '\u1D3C': 'O', + '\u1D3E': 'P', + '\u1D3F': 'R', + '\u1D40': 'T', + '\u1D41': 'U', + '\u2C7D': 'V', + '\u1D42': 'W', + '\u1D43': 'a', + '\u1D47': 'b', + '\u1D9C': 'c', + '\u1D48': 'd', + '\u1D49': 'e', + '\u1DA0': 'f', + '\u1D4D': 'g', + '\u02B0': 'h', + '\u2071': 'i', + '\u02B2': 'j', + '\u1D4F': 'k', + '\u02E1': 'l', + '\u1D50': 'm', + '\u207F': 'n', + '\u1D52': 'o', + '\u1D56': 'p', + '\u02B3': 'r', + '\u02E2': 's', + '\u1D57': 't', + '\u1D58': 'u', + '\u1D5B': 'v', + '\u02B7': 'w', + '\u02E3': 'x', + '\u02B8': 'y', + '\u1DBB': 'z', + '\u1D5D': 'β', + '\u1D5E': 'γ', + '\u1D5F': 'δ', + '\u1D60': '\u03d5', + '\u1D61': 'χ', + '\u1DBF': 'θ' +}); +;// ./src/Parser.ts +/* eslint no-constant-condition:0 */ + + + + + + + + + + + + +// Pre-evaluate both modules as unicodeSymbols require String.normalize() +const unicodeAccents = { + "́": { + "text": "\\'", + "math": "\\acute" + }, + "̀": { + "text": "\\`", + "math": "\\grave" + }, + "̈": { + "text": "\\\"", + "math": "\\ddot" + }, + "̃": { + "text": "\\~", + "math": "\\tilde" + }, + "̄": { + "text": "\\=", + "math": "\\bar" + }, + "̆": { + "text": "\\u", + "math": "\\breve" + }, + "̌": { + "text": "\\v", + "math": "\\check" + }, + "̂": { + "text": "\\^", + "math": "\\hat" + }, + "̇": { + "text": "\\.", + "math": "\\dot" + }, + "̊": { + "text": "\\r", + "math": "\\mathring" + }, + "̋": { + "text": "\\H" + }, + "̧": { + "text": "\\c" + } +}; +const unicodeSymbols = { + "á": "á", + "à": "à", + "ä": "ä", + "ǟ": "ǟ", + "ã": "ã", + "ā": "ā", + "ă": "ă", + "ắ": "ắ", + "ằ": "ằ", + "ẵ": "ẵ", + "ǎ": "ǎ", + "â": "â", + "ấ": "ấ", + "ầ": "ầ", + "ẫ": "ẫ", + "ȧ": "ȧ", + "ǡ": "ǡ", + "å": "å", + "ǻ": "ǻ", + "ḃ": "ḃ", + "ć": "ć", + "ḉ": "ḉ", + "č": "č", + "ĉ": "ĉ", + "ċ": "ċ", + "ç": "ç", + "ď": "ď", + "ḋ": "ḋ", + "ḑ": "ḑ", + "é": "é", + "è": "è", + "ë": "ë", + "ẽ": "ẽ", + "ē": "ē", + "ḗ": "ḗ", + "ḕ": "ḕ", + "ĕ": "ĕ", + "ḝ": "ḝ", + "ě": "ě", + "ê": "ê", + "ế": "ế", + "ề": "ề", + "ễ": "ễ", + "ė": "ė", + "ȩ": "ȩ", + "ḟ": "ḟ", + "ǵ": "ǵ", + "ḡ": "ḡ", + "ğ": "ğ", + "ǧ": "ǧ", + "ĝ": "ĝ", + "ġ": "ġ", + "ģ": "ģ", + "ḧ": "ḧ", + "ȟ": "ȟ", + "ĥ": "ĥ", + "ḣ": "ḣ", + "ḩ": "ḩ", + "í": "í", + "ì": "ì", + "ï": "ï", + "ḯ": "ḯ", + "ĩ": "ĩ", + "ī": "ī", + "ĭ": "ĭ", + "ǐ": "ǐ", + "î": "î", + "ǰ": "ǰ", + "ĵ": "ĵ", + "ḱ": "ḱ", + "ǩ": "ǩ", + "ķ": "ķ", + "ĺ": "ĺ", + "ľ": "ľ", + "ļ": "ļ", + "ḿ": "ḿ", + "ṁ": "ṁ", + "ń": "ń", + "ǹ": "ǹ", + "ñ": "ñ", + "ň": "ň", + "ṅ": "ṅ", + "ņ": "ņ", + "ó": "ó", + "ò": "ò", + "ö": "ö", + "ȫ": "ȫ", + "õ": "õ", + "ṍ": "ṍ", + "ṏ": "ṏ", + "ȭ": "ȭ", + "ō": "ō", + "ṓ": "ṓ", + "ṑ": "ṑ", + "ŏ": "ŏ", + "ǒ": "ǒ", + "ô": "ô", + "ố": "ố", + "ồ": "ồ", + "ỗ": "ỗ", + "ȯ": "ȯ", + "ȱ": "ȱ", + "ő": "ő", + "ṕ": "ṕ", + "ṗ": "ṗ", + "ŕ": "ŕ", + "ř": "ř", + "ṙ": "ṙ", + "ŗ": "ŗ", + "ś": "ś", + "ṥ": "ṥ", + "š": "š", + "ṧ": "ṧ", + "ŝ": "ŝ", + "ṡ": "ṡ", + "ş": "ş", + "ẗ": "ẗ", + "ť": "ť", + "ṫ": "ṫ", + "ţ": "ţ", + "ú": "ú", + "ù": "ù", + "ü": "ü", + "ǘ": "ǘ", + "ǜ": "ǜ", + "ǖ": "ǖ", + "ǚ": "ǚ", + "ũ": "ũ", + "ṹ": "ṹ", + "ū": "ū", + "ṻ": "ṻ", + "ŭ": "ŭ", + "ǔ": "ǔ", + "û": "û", + "ů": "ů", + "ű": "ű", + "ṽ": "ṽ", + "ẃ": "ẃ", + "ẁ": "ẁ", + "ẅ": "ẅ", + "ŵ": "ŵ", + "ẇ": "ẇ", + "ẘ": "ẘ", + "ẍ": "ẍ", + "ẋ": "ẋ", + "ý": "ý", + "ỳ": "ỳ", + "ÿ": "ÿ", + "ỹ": "ỹ", + "ȳ": "ȳ", + "ŷ": "ŷ", + "ẏ": "ẏ", + "ẙ": "ẙ", + "ź": "ź", + "ž": "ž", + "ẑ": "ẑ", + "ż": "ż", + "Á": "Á", + "À": "À", + "Ä": "Ä", + "Ǟ": "Ǟ", + "Ã": "Ã", + "Ā": "Ā", + "Ă": "Ă", + "Ắ": "Ắ", + "Ằ": "Ằ", + "Ẵ": "Ẵ", + "Ǎ": "Ǎ", + "Â": "Â", + "Ấ": "Ấ", + "Ầ": "Ầ", + "Ẫ": "Ẫ", + "Ȧ": "Ȧ", + "Ǡ": "Ǡ", + "Å": "Å", + "Ǻ": "Ǻ", + "Ḃ": "Ḃ", + "Ć": "Ć", + "Ḉ": "Ḉ", + "Č": "Č", + "Ĉ": "Ĉ", + "Ċ": "Ċ", + "Ç": "Ç", + "Ď": "Ď", + "Ḋ": "Ḋ", + "Ḑ": "Ḑ", + "É": "É", + "È": "È", + "Ë": "Ë", + "Ẽ": "Ẽ", + "Ē": "Ē", + "Ḗ": "Ḗ", + "Ḕ": "Ḕ", + "Ĕ": "Ĕ", + "Ḝ": "Ḝ", + "Ě": "Ě", + "Ê": "Ê", + "Ế": "Ế", + "Ề": "Ề", + "Ễ": "Ễ", + "Ė": "Ė", + "Ȩ": "Ȩ", + "Ḟ": "Ḟ", + "Ǵ": "Ǵ", + "Ḡ": "Ḡ", + "Ğ": "Ğ", + "Ǧ": "Ǧ", + "Ĝ": "Ĝ", + "Ġ": "Ġ", + "Ģ": "Ģ", + "Ḧ": "Ḧ", + "Ȟ": "Ȟ", + "Ĥ": "Ĥ", + "Ḣ": "Ḣ", + "Ḩ": "Ḩ", + "Í": "Í", + "Ì": "Ì", + "Ï": "Ï", + "Ḯ": "Ḯ", + "Ĩ": "Ĩ", + "Ī": "Ī", + "Ĭ": "Ĭ", + "Ǐ": "Ǐ", + "Î": "Î", + "İ": "İ", + "Ĵ": "Ĵ", + "Ḱ": "Ḱ", + "Ǩ": "Ǩ", + "Ķ": "Ķ", + "Ĺ": "Ĺ", + "Ľ": "Ľ", + "Ļ": "Ļ", + "Ḿ": "Ḿ", + "Ṁ": "Ṁ", + "Ń": "Ń", + "Ǹ": "Ǹ", + "Ñ": "Ñ", + "Ň": "Ň", + "Ṅ": "Ṅ", + "Ņ": "Ņ", + "Ó": "Ó", + "Ò": "Ò", + "Ö": "Ö", + "Ȫ": "Ȫ", + "Õ": "Õ", + "Ṍ": "Ṍ", + "Ṏ": "Ṏ", + "Ȭ": "Ȭ", + "Ō": "Ō", + "Ṓ": "Ṓ", + "Ṑ": "Ṑ", + "Ŏ": "Ŏ", + "Ǒ": "Ǒ", + "Ô": "Ô", + "Ố": "Ố", + "Ồ": "Ồ", + "Ỗ": "Ỗ", + "Ȯ": "Ȯ", + "Ȱ": "Ȱ", + "Ő": "Ő", + "Ṕ": "Ṕ", + "Ṗ": "Ṗ", + "Ŕ": "Ŕ", + "Ř": "Ř", + "Ṙ": "Ṙ", + "Ŗ": "Ŗ", + "Ś": "Ś", + "Ṥ": "Ṥ", + "Š": "Š", + "Ṧ": "Ṧ", + "Ŝ": "Ŝ", + "Ṡ": "Ṡ", + "Ş": "Ş", + "Ť": "Ť", + "Ṫ": "Ṫ", + "Ţ": "Ţ", + "Ú": "Ú", + "Ù": "Ù", + "Ü": "Ü", + "Ǘ": "Ǘ", + "Ǜ": "Ǜ", + "Ǖ": "Ǖ", + "Ǚ": "Ǚ", + "Ũ": "Ũ", + "Ṹ": "Ṹ", + "Ū": "Ū", + "Ṻ": "Ṻ", + "Ŭ": "Ŭ", + "Ǔ": "Ǔ", + "Û": "Û", + "Ů": "Ů", + "Ű": "Ű", + "Ṽ": "Ṽ", + "Ẃ": "Ẃ", + "Ẁ": "Ẁ", + "Ẅ": "Ẅ", + "Ŵ": "Ŵ", + "Ẇ": "Ẇ", + "Ẍ": "Ẍ", + "Ẋ": "Ẋ", + "Ý": "Ý", + "Ỳ": "Ỳ", + "Ÿ": "Ÿ", + "Ỹ": "Ỹ", + "Ȳ": "Ȳ", + "Ŷ": "Ŷ", + "Ẏ": "Ẏ", + "Ź": "Ź", + "Ž": "Ž", + "Ẑ": "Ẑ", + "Ż": "Ż", + "ά": "ά", + "ὰ": "ὰ", + "ᾱ": "ᾱ", + "ᾰ": "ᾰ", + "έ": "έ", + "ὲ": "ὲ", + "ή": "ή", + "ὴ": "ὴ", + "ί": "ί", + "ὶ": "ὶ", + "ϊ": "ϊ", + "ΐ": "ΐ", + "ῒ": "ῒ", + "ῑ": "ῑ", + "ῐ": "ῐ", + "ό": "ό", + "ὸ": "ὸ", + "ύ": "ύ", + "ὺ": "ὺ", + "ϋ": "ϋ", + "ΰ": "ΰ", + "ῢ": "ῢ", + "ῡ": "ῡ", + "ῠ": "ῠ", + "ώ": "ώ", + "ὼ": "ὼ", + "Ύ": "Ύ", + "Ὺ": "Ὺ", + "Ϋ": "Ϋ", + "Ῡ": "Ῡ", + "Ῠ": "Ῠ", + "Ώ": "Ώ", + "Ὼ": "Ὼ" +}; +/** + * This file contains the parser used to parse out a TeX expression from the + * input. Since TeX isn't context-free, standard parsers don't work particularly + * well. + * + * The strategy of this parser is as such: + * + * The main functions (the `.parse...` ones) take a position in the current + * parse string to parse tokens from. The lexer (found in Lexer.js, stored at + * this.gullet.lexer) also supports pulling out tokens at arbitrary places. When + * individual tokens are needed at a position, the lexer is called to pull out a + * token, which is then used. + * + * The parser has a property called "mode" indicating the mode that + * the parser is currently in. Currently it has to be one of "math" or + * "text", which denotes whether the current environment is a math-y + * one or a text-y one (e.g. inside \text). Currently, this serves to + * limit the functions which can be used in text mode. + * + * The main functions then return an object which contains the useful data that + * was parsed at its given point, and a new position at the end of the parsed + * data. The main functions can call each other and continue the parsing by + * using the returned position as a new starting point. + * + * There are also extra `.handle...` functions, which pull out some reused + * functionality into self-contained functions. + * + * The functions return ParseNodes. + */ + +class Parser { + constructor(input, settings) { + this.mode = void 0; + this.gullet = void 0; + this.settings = void 0; + this.leftrightDepth = void 0; + this.nextToken = void 0; + // Start in math mode + this.mode = "math"; + // Create a new macro expander (gullet) and (indirectly via that) also a + // new lexer (mouth) for this parser (stomach, in the language of TeX) + this.gullet = new MacroExpander(input, settings, this.mode); + // Store the settings for use in parsing + this.settings = settings; + // Count leftright depth (for \middle errors) + this.leftrightDepth = 0; + this.nextToken = null; + } + + /** + * Checks a result to make sure it has the right type, and throws an + * appropriate error otherwise. + */ + expect(text, consume) { + if (consume === void 0) { + consume = true; + } + if (this.fetch().text !== text) { + throw new src_ParseError("Expected '" + text + "', got '" + this.fetch().text + "'", this.fetch()); + } + if (consume) { + this.consume(); + } + } + + /** + * Discards the current lookahead token, considering it consumed. + */ + consume() { + this.nextToken = null; + } + + /** + * Return the current lookahead token, or if there isn't one (at the + * beginning, or if the previous lookahead token was consume()d), + * fetch the next token as the new lookahead token and return it. + */ + fetch() { + if (this.nextToken == null) { + this.nextToken = this.gullet.expandNextToken(); + } + return this.nextToken; + } + + /** + * Switches between "text" and "math" modes. + */ + switchMode(newMode) { + this.mode = newMode; + this.gullet.switchMode(newMode); + } + + /** + * Main parsing function, which parses an entire input. + */ + parse() { + if (!this.settings.globalGroup) { + // Create a group namespace for the math expression. + // (LaTeX creates a new group for every $...$, $$...$$, \[...\].) + this.gullet.beginGroup(); + } + + // Use old \color behavior (same as LaTeX's \textcolor) if requested. + // We do this within the group for the math expression, so it doesn't + // pollute settings.macros. + if (this.settings.colorIsTextColor) { + this.gullet.macros.set("\\color", "\\textcolor"); + } + try { + // Try to parse the input + const parse = this.parseExpression(false); + + // If we succeeded, make sure there's an EOF at the end + this.expect("EOF"); + + // End the group namespace for the expression + if (!this.settings.globalGroup) { + this.gullet.endGroup(); + } + return parse; + + // Close any leftover groups in case of a parse error. + } finally { + this.gullet.endGroups(); + } + } + + /** + * Fully parse a separate sequence of tokens as a separate job. + * Tokens should be specified in reverse order, as in a MacroDefinition. + */ + subparse(tokens) { + // Save the next token from the current job. + const oldToken = this.nextToken; + this.consume(); + + // Run the new job, terminating it with an excess '}' + this.gullet.pushToken(new Token("}")); + this.gullet.pushTokens(tokens); + const parse = this.parseExpression(false); + this.expect("}"); + + // Restore the next token from the current job. + this.nextToken = oldToken; + return parse; + } + /** + * Parses an "expression", which is a list of atoms. + * + * `breakOnInfix`: Should the parsing stop when we hit infix nodes? This + * happens when functions have higher precedence than infix + * nodes in implicit parses. + * + * `breakOnTokenText`: The text of the token that the expression should end + * with, or `null` if something else should end the + * expression. + */ + parseExpression(breakOnInfix, breakOnTokenText) { + const body = []; + // Keep adding atoms to the body until we can't parse any more atoms (either + // we reached the end, a }, or a \right) + while (true) { + // Ignore spaces in math mode + if (this.mode === "math") { + this.consumeSpaces(); + } + const lex = this.fetch(); + if (Parser.endOfExpression.has(lex.text)) { + break; + } + if (breakOnTokenText && lex.text === breakOnTokenText) { + break; + } + if (breakOnInfix && src_functions[lex.text] && src_functions[lex.text].infix) { + break; + } + const atom = this.parseAtom(breakOnTokenText); + if (!atom) { + break; + } else if (atom.type === "internal") { + // Internal nodes do not appear in parse tree + continue; + } + body.push(atom); + } + if (this.mode === "text") { + this.formLigatures(body); + } + return this.handleInfixNodes(body); + } + + /** + * Rewrites infix operators such as \over with corresponding commands such + * as \frac. + * + * There can only be one infix operator per group. If there's more than one + * then the expression is ambiguous. This can be resolved by adding {}. + */ + handleInfixNodes(body) { + let overIndex = -1; + let funcName; + for (let i = 0; i < body.length; i++) { + const node = body[i]; + if (node.type === "infix") { + if (overIndex !== -1) { + throw new src_ParseError("only one infix operator per group", node.token); + } + overIndex = i; + funcName = node.replaceWith; + } + } + if (overIndex !== -1 && funcName) { + let numerNode; + let denomNode; + const numerBody = body.slice(0, overIndex); + const denomBody = body.slice(overIndex + 1); + if (numerBody.length === 1 && numerBody[0].type === "ordgroup") { + numerNode = numerBody[0]; + } else { + numerNode = { + type: "ordgroup", + mode: this.mode, + body: numerBody + }; + } + if (denomBody.length === 1 && denomBody[0].type === "ordgroup") { + denomNode = denomBody[0]; + } else { + denomNode = { + type: "ordgroup", + mode: this.mode, + body: denomBody + }; + } + let node; + if (funcName === "\\\\abovefrac") { + node = this.callFunction(funcName, [numerNode, body[overIndex], denomNode], []); + } else { + node = this.callFunction(funcName, [numerNode, denomNode], []); + } + return [node]; + } else { + return body; + } + } + + /** + * Handle a subscript or superscript with nice errors. + */ + handleSupSubscript(name // For error reporting. + ) { + const symbolToken = this.fetch(); + const symbol = symbolToken.text; + this.consume(); + this.consumeSpaces(); // ignore spaces before sup/subscript argument + + // Skip over allowed internal nodes such as \relax + let group; + do { + var _group; + group = this.parseGroup(name); + } while (((_group = group) == null ? void 0 : _group.type) === "internal"); + if (!group) { + throw new src_ParseError("Expected group after '" + symbol + "'", symbolToken); + } + return group; + } + + /** + * Converts the textual input of an unsupported command into a text node + * contained within a color node whose color is determined by errorColor + */ + formatUnsupportedCmd(text) { + const textordArray = []; + for (let i = 0; i < text.length; i++) { + textordArray.push({ + type: "textord", + mode: "text", + text: text[i] + }); + } + const textNode = { + type: "text", + mode: this.mode, + body: textordArray + }; + const colorNode = { + type: "color", + mode: this.mode, + color: this.settings.errorColor, + body: [textNode] + }; + return colorNode; + } + + /** + * Parses a group with optional super/subscripts. + */ + parseAtom(breakOnTokenText) { + // The body of an atom is an implicit group, so that things like + // \left(x\right)^2 work correctly. + const base = this.parseGroup("atom", breakOnTokenText); + + // Internal nodes (e.g. \relax) cannot support super/subscripts. + // Instead, we will pick up super/subscripts with blank base next round. + if ((base == null ? void 0 : base.type) === "internal") { + return base; + } + + // In text mode, we don't have superscripts or subscripts + if (this.mode === "text") { + return base; + } + let superscript; + let subscript; + while (true) { + // Guaranteed in math mode, so eat any spaces first. + this.consumeSpaces(); + + // Lex the first token + const lex = this.fetch(); + if (lex.text === "\\limits" || lex.text === "\\nolimits") { + // We got a limit control + if (base && base.type === "op") { + base.limits = lex.text === "\\limits"; + base.alwaysHandleSupSub = true; + } else if (base && base.type === "operatorname") { + if (base.alwaysHandleSupSub) { + base.limits = lex.text === "\\limits"; + } + } else { + throw new src_ParseError("Limit controls must follow a math operator", lex); + } + this.consume(); + } else if (lex.text === "^") { + // We got a superscript start + if (superscript) { + throw new src_ParseError("Double superscript", lex); + } + superscript = this.handleSupSubscript("superscript"); + } else if (lex.text === "_") { + // We got a subscript start + if (subscript) { + throw new src_ParseError("Double subscript", lex); + } + subscript = this.handleSupSubscript("subscript"); + } else if (lex.text === "'") { + // We got a prime + if (superscript) { + throw new src_ParseError("Double superscript", lex); + } + const prime = { + type: "textord", + mode: this.mode, + text: "\\prime" + }; + + // Many primes can be grouped together, so we handle this here + const primes = [prime]; + this.consume(); + // Keep lexing tokens until we get something that's not a prime + while (this.fetch().text === "'") { + // For each one, add another prime to the list + primes.push(prime); + this.consume(); + } + // If there's a superscript following the primes, combine that + // superscript in with the primes. + if (this.fetch().text === "^") { + primes.push(this.handleSupSubscript("superscript")); + } + // Put everything into an ordgroup as the superscript + superscript = { + type: "ordgroup", + mode: this.mode, + body: primes + }; + } else if (uSubsAndSups[lex.text]) { + // A Unicode subscript or superscript character. + // We treat these similarly to the unicode-math package. + // So we render a string of Unicode (sub|super)scripts the + // same as a (sub|super)script of regular characters. + const isSub = unicodeSubRegEx.test(lex.text); + const subsupTokens = []; + subsupTokens.push(new Token(uSubsAndSups[lex.text])); + this.consume(); + // Continue fetching tokens to fill out the string. + while (true) { + const token = this.fetch().text; + if (!uSubsAndSups[token]) { + break; + } + if (unicodeSubRegEx.test(token) !== isSub) { + break; + } + subsupTokens.unshift(new Token(uSubsAndSups[token])); + this.consume(); + } + // Now create a (sub|super)script. + const body = this.subparse(subsupTokens); + if (isSub) { + subscript = { + type: "ordgroup", + mode: "math", + body + }; + } else { + superscript = { + type: "ordgroup", + mode: "math", + body + }; + } + } else { + // If it wasn't ^, _, or ', stop parsing super/subscripts + break; + } + } + + // Base must be set if superscript or subscript are set per logic above, + // but need to check here for type check to pass. + if (superscript && subscript) { + return { + type: "supsub", + mode: this.mode, + base, + sup: superscript, + sub: subscript + }; + } else if (superscript) { + return { + type: "supsub", + mode: this.mode, + base, + sup: superscript + }; + } else if (subscript) { + return { + type: "supsub", + mode: this.mode, + base, + sub: subscript + }; + } else { + // Otherwise return the original body + return base; + } + } + + /** + * Parses an entire function, including its base and all of its arguments. + */ + parseFunction(breakOnTokenText, name // For determining its context + ) { + const token = this.fetch(); + const func = token.text; + const funcData = src_functions[func]; + if (!funcData) { + return null; + } + this.consume(); // consume command token + + if (name && name !== "atom" && !funcData.allowedInArgument) { + throw new src_ParseError("Got function '" + func + "' with no arguments" + (name ? " as " + name : ""), token); + // Treat undefined allowedInText as false. + } else if (this.mode === "text" && !funcData.allowedInText) { + throw new src_ParseError("Can't use function '" + func + "' in text mode", token); + // Treat undefined allowedInMath as true. + } else if (this.mode === "math" && funcData.allowedInMath === false) { + throw new src_ParseError("Can't use function '" + func + "' in math mode", token); + } + const { + args, + optArgs + } = this.parseArguments(func, funcData); + return this.callFunction(func, args, optArgs, token, breakOnTokenText); + } + + /** + * Call a function handler with a suitable context and arguments. + */ + callFunction(name, args, optArgs, token, breakOnTokenText) { + const context = { + funcName: name, + parser: this, + token, + breakOnTokenText + }; + const func = src_functions[name]; + if (func && func.handler) { + return func.handler(context, args, optArgs); + } else { + throw new src_ParseError("No function handler for " + name); + } + } + + /** + * Parses the arguments of a function or environment + */ + parseArguments(func, + // Should look like "\name" or "\begin{name}". + funcData) { + var _funcData$numOptional; + const numOptionalArgs = (_funcData$numOptional = funcData.numOptionalArgs) != null ? _funcData$numOptional : 0; + const totalArgs = funcData.numArgs + numOptionalArgs; + if (totalArgs === 0) { + return { + args: [], + optArgs: [] + }; + } + const args = []; + const optArgs = []; + for (let i = 0; i < totalArgs; i++) { + var _funcData$argTypes; + let argType = (_funcData$argTypes = funcData.argTypes) == null ? void 0 : _funcData$argTypes[i]; + const isOptional = i < numOptionalArgs; + if ("primitive" in funcData && funcData.primitive && argType == null || + // \sqrt expands into primitive if optional argument doesn't exist + funcData.type === "sqrt" && i === 1 && optArgs[0] == null) { + argType = "primitive"; + } + const arg = this.parseGroupOfType("argument to '" + func + "'", argType, isOptional); + if (isOptional) { + optArgs.push(arg); + } else if (arg != null) { + args.push(arg); + } else { + // should be unreachable + throw new src_ParseError("Null argument, please report this as a bug"); + } + } + return { + args, + optArgs + }; + } + + /** + * Parses a group when the mode is changing. + */ + parseGroupOfType(name, type, optional) { + switch (type) { + case "color": + return this.parseColorGroup(optional); + case "size": + return this.parseSizeGroup(optional); + case "url": + return this.parseUrlGroup(optional); + case "math": + case "text": + return this.parseArgumentGroup(optional, type); + case "hbox": + { + // hbox argument type wraps the argument in the equivalent of + // \hbox, which is like \text but switching to \textstyle size + // and resetting math font. + const group = this.parseArgumentGroup(optional, "text"); + return group != null ? { + type: "styling", + mode: group.mode, + body: [group], + style: "text", + // simulate \textstyle + resetFont: true + } : null; + } + case "raw": + { + const token = this.parseStringGroup(optional); + return token != null ? { + type: "raw", + mode: "text", + string: token.text + } : null; + } + case "primitive": + { + if (optional) { + throw new src_ParseError("A primitive argument cannot be optional"); + } + const group = this.parseGroup(name); + if (group == null) { + throw new src_ParseError("Expected group as " + name, this.fetch()); + } + return group; + } + case "original": + case undefined: + return this.parseArgumentGroup(optional); + default: + throw new src_ParseError("Unknown group type as " + name, this.fetch()); + } + } + + /** + * Discard any space tokens, fetching the next non-space token. + */ + consumeSpaces() { + while (this.fetch().text === " ") { + this.consume(); + } + } + + /** + * Parses a group, essentially returning the string formed by the + * brace-enclosed tokens plus some position information. + */ + parseStringGroup(optional) { + const argToken = this.gullet.scanArgument(optional); + if (argToken == null) { + return null; + } + let str = ""; + let nextToken; + while ((nextToken = this.fetch()).text !== "EOF") { + str += nextToken.text; + this.consume(); + } + this.consume(); // consume the end of the argument + argToken.text = str; + return argToken; + } + + /** + * Parses a regex-delimited group: the largest sequence of tokens + * whose concatenated strings match `regex`. Returns the string + * formed by the tokens plus some position information. + */ + parseRegexGroup(regex, modeName // Used to describe the mode in error messages. + ) { + const firstToken = this.fetch(); + let lastToken = firstToken; + let str = ""; + let nextToken; + while ((nextToken = this.fetch()).text !== "EOF" && regex.test(str + nextToken.text)) { + lastToken = nextToken; + str += lastToken.text; + this.consume(); + } + if (str === "") { + throw new src_ParseError("Invalid " + modeName + ": '" + firstToken.text + "'", firstToken); + } + return firstToken.range(lastToken, str); + } + + /** + * Parses a color description. + */ + parseColorGroup(optional) { + const res = this.parseStringGroup(optional); + if (res == null) { + return null; + } + const match = /^(#[a-f0-9]{3,4}|#[a-f0-9]{6}|#[a-f0-9]{8}|[a-f0-9]{6}|[a-z]+)$/i.exec(res.text); + if (!match) { + throw new src_ParseError("Invalid color: '" + res.text + "'", res); + } + let color = match[0]; + if (/^[0-9a-f]{6}$/i.test(color)) { + // We allow a 6-digit HTML color spec without a leading "#". + // This follows the xcolor package's HTML color model. + // Predefined color names are all missed by this RegEx pattern. + color = "#" + color; + } + return { + type: "color-token", + mode: this.mode, + color + }; + } + + /** + * Parses a size specification, consisting of magnitude and unit. + */ + parseSizeGroup(optional) { + let res; + let isBlank = false; + // don't expand before parseStringGroup + this.gullet.consumeSpaces(); + if (!optional && this.gullet.future().text !== "{") { + res = this.parseRegexGroup(/^[-+]? *(?:$|\d+|\d+\.\d*|\.\d*) *[a-z]{0,2} *$/, "size"); + } else { + res = this.parseStringGroup(optional); + } + if (!res) { + return null; + } + if (!optional && res.text.length === 0) { + // Because we've tested for what is !optional, this block won't + // affect \kern, \hspace, etc. It will capture the mandatory arguments + // to \genfrac and \above. + res.text = "0pt"; // Enable \above{} + isBlank = true; // This is here specifically for \genfrac + } + const match = /([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(res.text); + if (!match) { + throw new src_ParseError("Invalid size: '" + res.text + "'", res); + } + const data = { + number: +(match[1] + match[2]), + // sign + magnitude, cast to number + unit: match[3] + }; + if (!validUnit(data)) { + throw new src_ParseError("Invalid unit: '" + data.unit + "'", res); + } + return { + type: "size", + mode: this.mode, + value: data, + isBlank + }; + } + + /** + * Parses an URL, checking escaped letters and allowed protocols, + * and setting the catcode of % as an active character (as in \hyperref). + */ + parseUrlGroup(optional) { + this.gullet.lexer.setCatcode("%", 13); // active character + this.gullet.lexer.setCatcode("~", 12); // other character + const res = this.parseStringGroup(optional); + this.gullet.lexer.setCatcode("%", 14); // comment character + this.gullet.lexer.setCatcode("~", 13); // active character + if (res == null) { + return null; + } + // hyperref package allows backslashes alone in href, but doesn't + // generate valid links in such cases; we interpret this as + // "undefined" behaviour, and keep them as-is. Some browser will + // replace backslashes with forward slashes. + const url = res.text.replace(/\\([#$%&~_^{}])/g, '$1'); + return { + type: "url", + mode: this.mode, + url + }; + } + + /** + * Parses an argument with the mode specified. + */ + parseArgumentGroup(optional, mode) { + const argToken = this.gullet.scanArgument(optional); + if (argToken == null) { + return null; + } + const outerMode = this.mode; + if (mode) { + // Switch to specified mode + this.switchMode(mode); + } + this.gullet.beginGroup(); + const expression = this.parseExpression(false, "EOF"); + // TODO: find an alternative way to denote the end + this.expect("EOF"); // expect the end of the argument + this.gullet.endGroup(); + const result = { + type: "ordgroup", + mode: this.mode, + loc: argToken.loc, + body: expression + }; + if (mode) { + // Switch mode back + this.switchMode(outerMode); + } + return result; + } + + /** + * Parses an ordinary group, which is either a single nucleus (like "x") + * or an expression in braces (like "{x+y}") or an implicit group, a group + * that starts at the current position, and ends right before a higher explicit + * group ends, or at EOF. + */ + parseGroup(name, + // For error reporting. + breakOnTokenText) { + const firstToken = this.fetch(); + const text = firstToken.text; + let result; + // Try to parse an open brace or \begingroup + if (text === "{" || text === "\\begingroup") { + this.consume(); + const groupEnd = text === "{" ? "}" : "\\endgroup"; + this.gullet.beginGroup(); + // If we get a brace, parse an expression + const expression = this.parseExpression(false, groupEnd); + const lastToken = this.fetch(); + this.expect(groupEnd); // Check that we got a matching closing brace + this.gullet.endGroup(); + result = { + type: "ordgroup", + mode: this.mode, + loc: SourceLocation.range(firstToken, lastToken), + body: expression, + // A group formed by \begingroup...\endgroup is a semi-simple group + // which doesn't affect spacing in math mode, i.e., is transparent. + // https://tex.stackexchange.com/questions/1930/when-should-one- + // use-begingroup-instead-of-bgroup + semisimple: text === "\\begingroup" || undefined + }; + } else { + // If there exists a function with this name, parse the function. + // Otherwise, just return a nucleus + result = this.parseFunction(breakOnTokenText, name) || this.parseSymbol(); + if (result == null && text[0] === "\\" && !implicitCommands.hasOwnProperty(text)) { + if (this.settings.throwOnError) { + throw new src_ParseError("Undefined control sequence: " + text, firstToken); + } + result = this.formatUnsupportedCmd(text); + this.consume(); + } + } + return result; + } + + /** + * Form ligature-like combinations of characters for text mode. + * This includes inputs like "--", "---", "``" and "''". + * The result will simply replace multiple textord nodes with a single + * character in each value by a single textord node having multiple + * characters in its value. The representation is still ASCII source. + * The group will be modified in place. + */ + formLigatures(group) { + let n = group.length - 1; + for (let i = 0; i < n; ++i) { + const a = group[i]; + if (a.type !== "textord") { + continue; + } + const v = a.text; + const next = group[i + 1]; + if (!next || next.type !== "textord") { + continue; + } + if (v === "-" && next.text === "-") { + const afterNext = group[i + 2]; + if (i + 1 < n && afterNext && afterNext.type === "textord" && afterNext.text === "-") { + group.splice(i, 3, { + type: "textord", + mode: "text", + loc: SourceLocation.range(a, afterNext), + text: "---" + }); + n -= 2; + } else { + group.splice(i, 2, { + type: "textord", + mode: "text", + loc: SourceLocation.range(a, next), + text: "--" + }); + n -= 1; + } + } + if ((v === "'" || v === "`") && next.text === v) { + group.splice(i, 2, { + type: "textord", + mode: "text", + loc: SourceLocation.range(a, next), + text: v + v + }); + n -= 1; + } + } + } + + /** + * Parse a single symbol out of the string. Here, we handle single character + * symbols and special functions like \verb. + */ + parseSymbol() { + const nucleus = this.fetch(); + let text = nucleus.text; + if (/^\\verb[^a-zA-Z]/.test(text)) { + this.consume(); + let arg = text.slice(5); + const star = arg.charAt(0) === "*"; + if (star) { + arg = arg.slice(1); + } + // Lexer's tokenRegex is constructed to always have matching + // first/last characters. + if (arg.length < 2 || arg.charAt(0) !== arg.slice(-1)) { + throw new src_ParseError("\\verb assertion failed --\n please report what input caused this bug"); + } + arg = arg.slice(1, -1); // remove first and last char + + return { + type: "verb", + mode: "text", + body: arg, + star + }; + } + // At this point, we should have a symbol, possibly with accents. + // First expand any accented base symbol according to unicodeSymbols. + if (unicodeSymbols.hasOwnProperty(text[0]) && !src_symbols[this.mode][text[0]]) { + // This behavior is not strict (XeTeX-compatible) in math mode. + if (this.settings.strict && this.mode === "math") { + this.settings.reportNonstrict("unicodeTextInMathMode", "Accented Unicode text character \"" + text[0] + "\" used in " + "math mode", nucleus); + } + text = unicodeSymbols[text[0]] + text.slice(1); + } + // Strip off any combining characters + const match = combiningDiacriticalMarksEndRegex.exec(text); + if (match) { + text = text.substring(0, match.index); + if (text === 'i') { + text = '\u0131'; // dotless i, in math and text mode + } else if (text === 'j') { + text = '\u0237'; // dotless j, in math and text mode + } + } + // Recognize base symbol + let symbol; + if (src_symbols[this.mode][text]) { + if (this.settings.strict && this.mode === 'math' && extraLatin.includes(text)) { + this.settings.reportNonstrict("unicodeTextInMathMode", "Latin-1/Unicode text character \"" + text[0] + "\" used in " + "math mode", nucleus); + } + const group = src_symbols[this.mode][text].group; + const loc = SourceLocation.range(nucleus); + let s; + if (isAtom(group)) { + s = { + type: "atom", + mode: this.mode, + family: group, + loc, + text + }; + } else { + s = { + type: group, + mode: this.mode, + loc, + text + }; + } + symbol = s; + } else if (text.charCodeAt(0) >= 0x80) { + // no symbol for e.g. ^ + if (this.settings.strict) { + if (!supportedCodepoint(text.charCodeAt(0))) { + this.settings.reportNonstrict("unknownSymbol", "Unrecognized Unicode character \"" + text[0] + "\"" + (" (" + text.charCodeAt(0) + ")"), nucleus); + } else if (this.mode === "math") { + this.settings.reportNonstrict("unicodeTextInMathMode", "Unicode text character \"" + text[0] + "\" used in math mode", nucleus); + } + } + // All nonmathematical Unicode characters are rendered as if they + // are in text mode (wrapped in \text) because that's what it + // takes to render them in LaTeX. Setting `mode: this.mode` is + // another natural choice (the user requested math mode), but + // this makes it more difficult for getCharacterMetrics() to + // distinguish Unicode characters without metrics and those for + // which we want to simulate the letter M. + symbol = { + type: "textord", + mode: "text", + loc: SourceLocation.range(nucleus), + text + }; + } else { + return null; // EOF, ^, _, {, }, etc. + } + this.consume(); + // Transform combining characters into accents + if (match) { + for (let i = 0; i < match[0].length; i++) { + const accent = match[0][i]; + if (!unicodeAccents[accent]) { + throw new src_ParseError("Unknown accent ' " + accent + "'", nucleus); + } + const command = unicodeAccents[accent][this.mode] || unicodeAccents[accent].text; + if (!command) { + throw new src_ParseError("Accent " + accent + " unsupported in " + this.mode + " mode", nucleus); + } + symbol = { + type: "accent", + mode: this.mode, + loc: SourceLocation.range(nucleus), + label: command, + isStretchy: false, + isShifty: true, + base: symbol + }; + } + } + return symbol; + } +} +Parser.endOfExpression = new Set(["}", "\\endgroup", "\\end", "\\right", "&"]); +;// ./src/parseTree.ts + + + +/** + * Parses an expression using a Parser, then returns the parsed result. + */ +const parseTree = function (toParse, settings) { + if (!(typeof toParse === 'string' || toParse instanceof String)) { + throw new TypeError('KaTeX can only parse string typed expression'); + } + const parser = new Parser(toParse, settings); + + // Blank out any \df@tag to avoid spurious "Duplicate \tag" errors + delete parser.gullet.macros.current["\\df@tag"]; + let tree = parser.parse(); + + // Prevent a color definition from persisting between calls to katex.render(). + delete parser.gullet.macros.current["\\current@color"]; + delete parser.gullet.macros.current["\\color"]; + + // If the input used \tag, it will set the \df@tag macro to the tag. + // In this case, we separately parse the tag and wrap the tree. + if (parser.gullet.macros.get("\\df@tag")) { + if (!settings.displayMode) { + throw new src_ParseError("\\tag works only in display equations"); + } + tree = [{ + type: "tag", + mode: "text", + body: tree, + tag: parser.subparse([new Token("\\df@tag")]) + }]; + } + return tree; +}; +/* harmony default export */ var src_parseTree = (parseTree); +;// ./katex.ts +/* eslint no-console:0 */ +/** + * This is the main entry point for KaTeX. Here, we expose functions for + * rendering expressions either to DOM nodes or to markup strings. + * + * We also expose the ParseError class to check if errors thrown from KaTeX are + * errors in the expression, or errors in javascript handling. + */ + + + + + + + + + + + +/** + * Parse and build an expression, and place that expression in the DOM node + * given. + */ +let render = function (expression, baseNode, options) { + baseNode.textContent = ""; + const node = renderToDomTree(expression, options).toNode(); + baseNode.appendChild(node); +}; + +// KaTeX's styles don't work properly in quirks mode. Print out an error, and +// disable rendering. +if (typeof document !== "undefined") { + if (document.compatMode !== "CSS1Compat") { + typeof console !== "undefined" && console.warn("Warning: KaTeX doesn't work in quirks mode. Make sure your " + "website has a suitable doctype."); + render = function () { + throw new src_ParseError("KaTeX doesn't work in quirks mode."); + }; + } +} + +/** + * Parse and build an expression, and return the markup for that. + */ +const renderToString = function (expression, options) { + const markup = renderToDomTree(expression, options).toMarkup(); + return markup; +}; + +/** + * Parse an expression and return the parse tree. + */ +const generateParseTree = function (expression, options) { + const settings = new Settings(options); + return src_parseTree(expression, settings); +}; + +/** + * If the given error is a KaTeX ParseError and options.throwOnError is false, + * renders the invalid LaTeX as a span with hover title giving the KaTeX + * error message. Otherwise, simply throws the error. + */ +const renderError = function (error, expression, options) { + if (options.throwOnError || !(error instanceof src_ParseError)) { + throw error; + } + const node = makeSpan(["katex-error"], [new SymbolNode(expression)]); + node.setAttribute("title", error.toString()); + node.setAttribute("style", "color:" + options.errorColor); + return node; +}; + +/** + * Generates and returns the katex build tree. This is used for advanced + * use cases (like rendering to custom output). + */ +const renderToDomTree = function (expression, options) { + const settings = new Settings(options); + try { + const tree = src_parseTree(expression, settings); + return buildTree(tree, expression, settings); + } catch (error) { + return renderError(error, expression, settings); + } +}; + +/** + * Generates and returns the katex build tree, with just HTML (no MathML). + * This is used for advanced use cases (like rendering to custom output). + */ +const renderToHTMLTree = function (expression, options) { + const settings = new Settings(options); + try { + const tree = src_parseTree(expression, settings); + return buildHTMLTree(tree, expression, settings); + } catch (error) { + return renderError(error, expression, settings); + } +}; +const version = "0.17.0"; +const __domTree = { + Span: Span, + Anchor: Anchor, + SymbolNode: SymbolNode, + SvgNode: SvgNode, + PathNode: PathNode, + LineNode: LineNode +}; + +// ESM exports + + +// CJS exports and ESM default export +/* harmony default export */ var katex = ({ + /** + * Current KaTeX version + */ + version, + /** + * Renders the given LaTeX into an HTML+MathML combination, and adds + * it as a child to the specified DOM node. + */ + render, + /** + * Renders the given LaTeX into an HTML+MathML combination string, + * for sending to the client. + */ + renderToString, + /** + * KaTeX error, usually during parsing. + */ + ParseError: src_ParseError, + /** + * The schema of Settings + */ + SETTINGS_SCHEMA: SETTINGS_SCHEMA, + /** + * Parses the given LaTeX into KaTeX's internal parse tree structure, + * without rendering to HTML or MathML. + * + * NOTE: This method is not currently recommended for public use. + * The internal tree representation is unstable and is very likely + * to change. Use at your own risk. + */ + __parse: generateParseTree, + /** + * Renders the given LaTeX into an HTML+MathML internal DOM tree + * representation, without flattening that representation to a string. + * + * NOTE: This method is not currently recommended for public use. + * The internal tree representation is unstable and is very likely + * to change. Use at your own risk. + */ + __renderToDomTree: renderToDomTree, + /** + * Renders the given LaTeX into an HTML internal DOM tree representation, + * without MathML and without flattening that representation to a string. + * + * NOTE: This method is not currently recommended for public use. + * The internal tree representation is unstable and is very likely + * to change. Use at your own risk. + */ + __renderToHTMLTree: renderToHTMLTree, + /** + * extends internal font metrics object with a new object + * each key in the new object represents a font name + */ + __setFontMetrics: setFontMetrics, + /** + * adds a new symbol to builtin symbols table + */ + __defineSymbol: defineSymbol, + /** + * adds a new function to builtin function list, + * which directly produce parse tree elements + * and have their own html/mathml builders + */ + __defineFunction: defineFunction, + /** + * adds a new macro to builtin macro list + */ + __defineMacro: defineMacro, + /** + * Expose the dom tree node types, which can be useful for type checking nodes. + * + * NOTE: These methods are not currently recommended for public use. + * The internal tree representation is unstable and is very likely + * to change. Use at your own risk. + */ + __domTree +}); +;// ./katex.webpack.js +/** + * This is the webpack entry point for KaTeX. As ECMAScript, flow[1] and jest[2] + * doesn't support CSS modules natively, a separate entry point is used and + * it is not flowtyped. + * + * [1] https://gist.github.com/lambdahands/d19e0da96285b749f0ef + * [2] https://facebook.github.io/jest/docs/en/webpack.html + */ + + +/* harmony default export */ var katex_webpack = (katex); +__webpack_exports__ = __webpack_exports__["default"]; +/******/ return __webpack_exports__; +/******/ })() +; +}); \ No newline at end of file diff --git a/node_modules/katex/dist/katex.min.css b/node_modules/katex/dist/katex.min.css new file mode 100644 index 0000000..71298b5 --- /dev/null +++ b/node_modules/katex/dist/katex.min.css @@ -0,0 +1 @@ +@font-face{font-display:block;font-family:KaTeX_AMS;font-style:normal;font-weight:400;src:url(fonts/KaTeX_AMS-Regular.woff2) format("woff2"),url(fonts/KaTeX_AMS-Regular.woff) format("woff"),url(fonts/KaTeX_AMS-Regular.ttf) format("truetype")}@font-face{font-display:block;font-family:KaTeX_Caligraphic;font-style:normal;font-weight:700;src:url(fonts/KaTeX_Caligraphic-Bold.woff2) format("woff2"),url(fonts/KaTeX_Caligraphic-Bold.woff) format("woff"),url(fonts/KaTeX_Caligraphic-Bold.ttf) format("truetype")}@font-face{font-display:block;font-family:KaTeX_Caligraphic;font-style:normal;font-weight:400;src:url(fonts/KaTeX_Caligraphic-Regular.woff2) format("woff2"),url(fonts/KaTeX_Caligraphic-Regular.woff) format("woff"),url(fonts/KaTeX_Caligraphic-Regular.ttf) format("truetype")}@font-face{font-display:block;font-family:KaTeX_Fraktur;font-style:normal;font-weight:700;src:url(fonts/KaTeX_Fraktur-Bold.woff2) format("woff2"),url(fonts/KaTeX_Fraktur-Bold.woff) format("woff"),url(fonts/KaTeX_Fraktur-Bold.ttf) format("truetype")}@font-face{font-display:block;font-family:KaTeX_Fraktur;font-style:normal;font-weight:400;src:url(fonts/KaTeX_Fraktur-Regular.woff2) format("woff2"),url(fonts/KaTeX_Fraktur-Regular.woff) format("woff"),url(fonts/KaTeX_Fraktur-Regular.ttf) format("truetype")}@font-face{font-display:block;font-family:KaTeX_Main;font-style:normal;font-weight:700;src:url(fonts/KaTeX_Main-Bold.woff2) format("woff2"),url(fonts/KaTeX_Main-Bold.woff) format("woff"),url(fonts/KaTeX_Main-Bold.ttf) format("truetype")}@font-face{font-display:block;font-family:KaTeX_Main;font-style:italic;font-weight:700;src:url(fonts/KaTeX_Main-BoldItalic.woff2) format("woff2"),url(fonts/KaTeX_Main-BoldItalic.woff) format("woff"),url(fonts/KaTeX_Main-BoldItalic.ttf) format("truetype")}@font-face{font-display:block;font-family:KaTeX_Main;font-style:italic;font-weight:400;src:url(fonts/KaTeX_Main-Italic.woff2) format("woff2"),url(fonts/KaTeX_Main-Italic.woff) format("woff"),url(fonts/KaTeX_Main-Italic.ttf) format("truetype")}@font-face{font-display:block;font-family:KaTeX_Main;font-style:normal;font-weight:400;src:url(fonts/KaTeX_Main-Regular.woff2) format("woff2"),url(fonts/KaTeX_Main-Regular.woff) format("woff"),url(fonts/KaTeX_Main-Regular.ttf) format("truetype")}@font-face{font-display:block;font-family:KaTeX_Math;font-style:italic;font-weight:700;src:url(fonts/KaTeX_Math-BoldItalic.woff2) format("woff2"),url(fonts/KaTeX_Math-BoldItalic.woff) format("woff"),url(fonts/KaTeX_Math-BoldItalic.ttf) format("truetype")}@font-face{font-display:block;font-family:KaTeX_Math;font-style:italic;font-weight:400;src:url(fonts/KaTeX_Math-Italic.woff2) format("woff2"),url(fonts/KaTeX_Math-Italic.woff) format("woff"),url(fonts/KaTeX_Math-Italic.ttf) format("truetype")}@font-face{font-display:block;font-family:"KaTeX_SansSerif";font-style:normal;font-weight:700;src:url(fonts/KaTeX_SansSerif-Bold.woff2) format("woff2"),url(fonts/KaTeX_SansSerif-Bold.woff) format("woff"),url(fonts/KaTeX_SansSerif-Bold.ttf) format("truetype")}@font-face{font-display:block;font-family:"KaTeX_SansSerif";font-style:italic;font-weight:400;src:url(fonts/KaTeX_SansSerif-Italic.woff2) format("woff2"),url(fonts/KaTeX_SansSerif-Italic.woff) format("woff"),url(fonts/KaTeX_SansSerif-Italic.ttf) format("truetype")}@font-face{font-display:block;font-family:"KaTeX_SansSerif";font-style:normal;font-weight:400;src:url(fonts/KaTeX_SansSerif-Regular.woff2) format("woff2"),url(fonts/KaTeX_SansSerif-Regular.woff) format("woff"),url(fonts/KaTeX_SansSerif-Regular.ttf) format("truetype")}@font-face{font-display:block;font-family:KaTeX_Script;font-style:normal;font-weight:400;src:url(fonts/KaTeX_Script-Regular.woff2) format("woff2"),url(fonts/KaTeX_Script-Regular.woff) format("woff"),url(fonts/KaTeX_Script-Regular.ttf) format("truetype")}@font-face{font-display:block;font-family:KaTeX_Size1;font-style:normal;font-weight:400;src:url(fonts/KaTeX_Size1-Regular.woff2) format("woff2"),url(fonts/KaTeX_Size1-Regular.woff) format("woff"),url(fonts/KaTeX_Size1-Regular.ttf) format("truetype")}@font-face{font-display:block;font-family:KaTeX_Size2;font-style:normal;font-weight:400;src:url(fonts/KaTeX_Size2-Regular.woff2) format("woff2"),url(fonts/KaTeX_Size2-Regular.woff) format("woff"),url(fonts/KaTeX_Size2-Regular.ttf) format("truetype")}@font-face{font-display:block;font-family:KaTeX_Size3;font-style:normal;font-weight:400;src:url(fonts/KaTeX_Size3-Regular.woff2) format("woff2"),url(fonts/KaTeX_Size3-Regular.woff) format("woff"),url(fonts/KaTeX_Size3-Regular.ttf) format("truetype")}@font-face{font-display:block;font-family:KaTeX_Size4;font-style:normal;font-weight:400;src:url(fonts/KaTeX_Size4-Regular.woff2) format("woff2"),url(fonts/KaTeX_Size4-Regular.woff) format("woff"),url(fonts/KaTeX_Size4-Regular.ttf) format("truetype")}@font-face{font-display:block;font-family:KaTeX_Typewriter;font-style:normal;font-weight:400;src:url(fonts/KaTeX_Typewriter-Regular.woff2) format("woff2"),url(fonts/KaTeX_Typewriter-Regular.woff) format("woff"),url(fonts/KaTeX_Typewriter-Regular.ttf) format("truetype")}.katex{font:normal 1.21em KaTeX_Main,Times New Roman,serif;line-height:1.2;position:relative;text-indent:0;text-rendering:auto}.katex *{-ms-high-contrast-adjust:none!important;border-color:currentColor}.katex .katex-version:after{content:"0.17.0"}.katex .katex-mathml{border:0;-webkit-clip-path:inset(50%);clip-path:inset(50%);height:1px;overflow:hidden;padding:0;position:absolute;width:1px}.katex .katex-html>.newline{display:block}.katex .base{position:relative;white-space:nowrap;width:-webkit-min-content;width:-moz-min-content;width:min-content}.katex .base,.katex .strut{display:inline-block}.katex .textbf{font-weight:700}.katex .textit{font-style:italic}.katex .textrm{font-family:KaTeX_Main}.katex .textsf{font-family:KaTeX_SansSerif}.katex .texttt{font-family:KaTeX_Typewriter}.katex .mathnormal{font-family:KaTeX_Math;font-style:italic}.katex .mathit{font-family:KaTeX_Main;font-style:italic}.katex .mathrm{font-style:normal}.katex .mathbf{font-family:KaTeX_Main;font-weight:700}.katex .boldsymbol{font-family:KaTeX_Math;font-style:italic;font-weight:700}.katex .amsrm,.katex .mathbb,.katex .textbb{font-family:KaTeX_AMS}.katex .mathcal{font-family:KaTeX_Caligraphic}.katex .mathfrak,.katex .textfrak{font-family:KaTeX_Fraktur}.katex .mathboldfrak,.katex .textboldfrak{font-family:KaTeX_Fraktur;font-weight:700}.katex .mathtt{font-family:KaTeX_Typewriter}.katex .mathscr,.katex .textscr{font-family:KaTeX_Script}.katex .mathsf,.katex .textsf{font-family:KaTeX_SansSerif}.katex .mathboldsf,.katex .textboldsf{font-family:KaTeX_SansSerif;font-weight:700}.katex .mathitsf,.katex .mathsfit,.katex .textitsf{font-family:KaTeX_SansSerif;font-style:italic}.katex .mainrm{font-family:KaTeX_Main;font-style:normal}.katex .vlist-t{border-collapse:collapse;display:inline-table;table-layout:fixed}.katex .vlist-r{display:table-row}.katex .vlist{display:table-cell;position:relative;vertical-align:bottom}.katex .vlist>span{display:block;height:0;position:relative}.katex .vlist>span>span{display:inline-block}.katex .vlist>span>.pstrut{overflow:hidden;width:0}.katex .vlist-t2{margin-right:-2px}.katex .vlist-s{display:table-cell;font-size:1px;min-width:2px;vertical-align:bottom;width:2px}.katex .vbox{align-items:baseline;display:inline-flex;flex-direction:column}.katex .hbox{width:100%}.katex .hbox,.katex .thinbox{display:inline-flex;flex-direction:row}.katex .thinbox{max-width:0;width:0}.katex .msupsub{text-align:left}.katex .mfrac>span>span{text-align:center}.katex .mfrac .frac-line{border-bottom-style:solid;display:inline-block;width:100%}.katex .hdashline,.katex .hline,.katex .mfrac .frac-line,.katex .overline .overline-line,.katex .rule,.katex .underline .underline-line{min-height:1px}.katex .mspace{display:inline-block}.katex .smash{display:inline;line-height:0}.katex .clap,.katex .llap,.katex .rlap{position:relative;width:0}.katex .clap>.inner,.katex .llap>.inner,.katex .rlap>.inner{position:absolute}.katex .clap>.fix,.katex .llap>.fix,.katex .rlap>.fix{display:inline-block}.katex .llap>.inner{right:0}.katex .clap>.inner,.katex .rlap>.inner{left:0}.katex .clap>.inner>span{margin-left:-50%;margin-right:50%}.katex .rule{border:0 solid;display:inline-block;position:relative}.katex .hline,.katex .overline .overline-line,.katex .underline .underline-line{border-bottom-style:solid;display:inline-block;width:100%}.katex .hdashline{border-bottom-style:dashed;display:inline-block;width:100%}.katex .sqrt>.root{margin-left:.2777777778em;margin-right:-.5555555556em}.katex .fontsize-ensurer.reset-size1.size1,.katex .sizing.reset-size1.size1{font-size:1em}.katex .fontsize-ensurer.reset-size1.size2,.katex .sizing.reset-size1.size2{font-size:1.2em}.katex .fontsize-ensurer.reset-size1.size3,.katex .sizing.reset-size1.size3{font-size:1.4em}.katex .fontsize-ensurer.reset-size1.size4,.katex .sizing.reset-size1.size4{font-size:1.6em}.katex .fontsize-ensurer.reset-size1.size5,.katex .sizing.reset-size1.size5{font-size:1.8em}.katex .fontsize-ensurer.reset-size1.size6,.katex .sizing.reset-size1.size6{font-size:2em}.katex .fontsize-ensurer.reset-size1.size7,.katex .sizing.reset-size1.size7{font-size:2.4em}.katex .fontsize-ensurer.reset-size1.size8,.katex .sizing.reset-size1.size8{font-size:2.88em}.katex .fontsize-ensurer.reset-size1.size9,.katex .sizing.reset-size1.size9{font-size:3.456em}.katex .fontsize-ensurer.reset-size1.size10,.katex .sizing.reset-size1.size10{font-size:4.148em}.katex .fontsize-ensurer.reset-size1.size11,.katex .sizing.reset-size1.size11{font-size:4.976em}.katex .fontsize-ensurer.reset-size2.size1,.katex .sizing.reset-size2.size1{font-size:.8333333333em}.katex .fontsize-ensurer.reset-size2.size2,.katex .sizing.reset-size2.size2{font-size:1em}.katex .fontsize-ensurer.reset-size2.size3,.katex .sizing.reset-size2.size3{font-size:1.1666666667em}.katex .fontsize-ensurer.reset-size2.size4,.katex .sizing.reset-size2.size4{font-size:1.3333333333em}.katex .fontsize-ensurer.reset-size2.size5,.katex .sizing.reset-size2.size5{font-size:1.5em}.katex .fontsize-ensurer.reset-size2.size6,.katex .sizing.reset-size2.size6{font-size:1.6666666667em}.katex .fontsize-ensurer.reset-size2.size7,.katex .sizing.reset-size2.size7{font-size:2em}.katex .fontsize-ensurer.reset-size2.size8,.katex .sizing.reset-size2.size8{font-size:2.4em}.katex .fontsize-ensurer.reset-size2.size9,.katex .sizing.reset-size2.size9{font-size:2.88em}.katex .fontsize-ensurer.reset-size2.size10,.katex .sizing.reset-size2.size10{font-size:3.4566666667em}.katex .fontsize-ensurer.reset-size2.size11,.katex .sizing.reset-size2.size11{font-size:4.1466666667em}.katex .fontsize-ensurer.reset-size3.size1,.katex .sizing.reset-size3.size1{font-size:.7142857143em}.katex .fontsize-ensurer.reset-size3.size2,.katex .sizing.reset-size3.size2{font-size:.8571428571em}.katex .fontsize-ensurer.reset-size3.size3,.katex .sizing.reset-size3.size3{font-size:1em}.katex .fontsize-ensurer.reset-size3.size4,.katex .sizing.reset-size3.size4{font-size:1.1428571429em}.katex .fontsize-ensurer.reset-size3.size5,.katex .sizing.reset-size3.size5{font-size:1.2857142857em}.katex .fontsize-ensurer.reset-size3.size6,.katex .sizing.reset-size3.size6{font-size:1.4285714286em}.katex .fontsize-ensurer.reset-size3.size7,.katex .sizing.reset-size3.size7{font-size:1.7142857143em}.katex .fontsize-ensurer.reset-size3.size8,.katex .sizing.reset-size3.size8{font-size:2.0571428571em}.katex .fontsize-ensurer.reset-size3.size9,.katex .sizing.reset-size3.size9{font-size:2.4685714286em}.katex .fontsize-ensurer.reset-size3.size10,.katex .sizing.reset-size3.size10{font-size:2.9628571429em}.katex .fontsize-ensurer.reset-size3.size11,.katex .sizing.reset-size3.size11{font-size:3.5542857143em}.katex .fontsize-ensurer.reset-size4.size1,.katex .sizing.reset-size4.size1{font-size:.625em}.katex .fontsize-ensurer.reset-size4.size2,.katex .sizing.reset-size4.size2{font-size:.75em}.katex .fontsize-ensurer.reset-size4.size3,.katex .sizing.reset-size4.size3{font-size:.875em}.katex .fontsize-ensurer.reset-size4.size4,.katex .sizing.reset-size4.size4{font-size:1em}.katex .fontsize-ensurer.reset-size4.size5,.katex .sizing.reset-size4.size5{font-size:1.125em}.katex .fontsize-ensurer.reset-size4.size6,.katex .sizing.reset-size4.size6{font-size:1.25em}.katex .fontsize-ensurer.reset-size4.size7,.katex .sizing.reset-size4.size7{font-size:1.5em}.katex .fontsize-ensurer.reset-size4.size8,.katex .sizing.reset-size4.size8{font-size:1.8em}.katex .fontsize-ensurer.reset-size4.size9,.katex .sizing.reset-size4.size9{font-size:2.16em}.katex .fontsize-ensurer.reset-size4.size10,.katex .sizing.reset-size4.size10{font-size:2.5925em}.katex .fontsize-ensurer.reset-size4.size11,.katex .sizing.reset-size4.size11{font-size:3.11em}.katex .fontsize-ensurer.reset-size5.size1,.katex .sizing.reset-size5.size1{font-size:.5555555556em}.katex .fontsize-ensurer.reset-size5.size2,.katex .sizing.reset-size5.size2{font-size:.6666666667em}.katex .fontsize-ensurer.reset-size5.size3,.katex .sizing.reset-size5.size3{font-size:.7777777778em}.katex .fontsize-ensurer.reset-size5.size4,.katex .sizing.reset-size5.size4{font-size:.8888888889em}.katex .fontsize-ensurer.reset-size5.size5,.katex .sizing.reset-size5.size5{font-size:1em}.katex .fontsize-ensurer.reset-size5.size6,.katex .sizing.reset-size5.size6{font-size:1.1111111111em}.katex .fontsize-ensurer.reset-size5.size7,.katex .sizing.reset-size5.size7{font-size:1.3333333333em}.katex .fontsize-ensurer.reset-size5.size8,.katex .sizing.reset-size5.size8{font-size:1.6em}.katex .fontsize-ensurer.reset-size5.size9,.katex .sizing.reset-size5.size9{font-size:1.92em}.katex .fontsize-ensurer.reset-size5.size10,.katex .sizing.reset-size5.size10{font-size:2.3044444444em}.katex .fontsize-ensurer.reset-size5.size11,.katex .sizing.reset-size5.size11{font-size:2.7644444444em}.katex .fontsize-ensurer.reset-size6.size1,.katex .sizing.reset-size6.size1{font-size:.5em}.katex .fontsize-ensurer.reset-size6.size2,.katex .sizing.reset-size6.size2{font-size:.6em}.katex .fontsize-ensurer.reset-size6.size3,.katex .sizing.reset-size6.size3{font-size:.7em}.katex .fontsize-ensurer.reset-size6.size4,.katex .sizing.reset-size6.size4{font-size:.8em}.katex .fontsize-ensurer.reset-size6.size5,.katex .sizing.reset-size6.size5{font-size:.9em}.katex .fontsize-ensurer.reset-size6.size6,.katex .sizing.reset-size6.size6{font-size:1em}.katex .fontsize-ensurer.reset-size6.size7,.katex .sizing.reset-size6.size7{font-size:1.2em}.katex .fontsize-ensurer.reset-size6.size8,.katex .sizing.reset-size6.size8{font-size:1.44em}.katex .fontsize-ensurer.reset-size6.size9,.katex .sizing.reset-size6.size9{font-size:1.728em}.katex .fontsize-ensurer.reset-size6.size10,.katex .sizing.reset-size6.size10{font-size:2.074em}.katex .fontsize-ensurer.reset-size6.size11,.katex .sizing.reset-size6.size11{font-size:2.488em}.katex .fontsize-ensurer.reset-size7.size1,.katex .sizing.reset-size7.size1{font-size:.4166666667em}.katex .fontsize-ensurer.reset-size7.size2,.katex .sizing.reset-size7.size2{font-size:.5em}.katex .fontsize-ensurer.reset-size7.size3,.katex .sizing.reset-size7.size3{font-size:.5833333333em}.katex .fontsize-ensurer.reset-size7.size4,.katex .sizing.reset-size7.size4{font-size:.6666666667em}.katex .fontsize-ensurer.reset-size7.size5,.katex .sizing.reset-size7.size5{font-size:.75em}.katex .fontsize-ensurer.reset-size7.size6,.katex .sizing.reset-size7.size6{font-size:.8333333333em}.katex .fontsize-ensurer.reset-size7.size7,.katex .sizing.reset-size7.size7{font-size:1em}.katex .fontsize-ensurer.reset-size7.size8,.katex .sizing.reset-size7.size8{font-size:1.2em}.katex .fontsize-ensurer.reset-size7.size9,.katex .sizing.reset-size7.size9{font-size:1.44em}.katex .fontsize-ensurer.reset-size7.size10,.katex .sizing.reset-size7.size10{font-size:1.7283333333em}.katex .fontsize-ensurer.reset-size7.size11,.katex .sizing.reset-size7.size11{font-size:2.0733333333em}.katex .fontsize-ensurer.reset-size8.size1,.katex .sizing.reset-size8.size1{font-size:.3472222222em}.katex .fontsize-ensurer.reset-size8.size2,.katex .sizing.reset-size8.size2{font-size:.4166666667em}.katex .fontsize-ensurer.reset-size8.size3,.katex .sizing.reset-size8.size3{font-size:.4861111111em}.katex .fontsize-ensurer.reset-size8.size4,.katex .sizing.reset-size8.size4{font-size:.5555555556em}.katex .fontsize-ensurer.reset-size8.size5,.katex .sizing.reset-size8.size5{font-size:.625em}.katex .fontsize-ensurer.reset-size8.size6,.katex .sizing.reset-size8.size6{font-size:.6944444444em}.katex .fontsize-ensurer.reset-size8.size7,.katex .sizing.reset-size8.size7{font-size:.8333333333em}.katex .fontsize-ensurer.reset-size8.size8,.katex .sizing.reset-size8.size8{font-size:1em}.katex .fontsize-ensurer.reset-size8.size9,.katex .sizing.reset-size8.size9{font-size:1.2em}.katex .fontsize-ensurer.reset-size8.size10,.katex .sizing.reset-size8.size10{font-size:1.4402777778em}.katex .fontsize-ensurer.reset-size8.size11,.katex .sizing.reset-size8.size11{font-size:1.7277777778em}.katex .fontsize-ensurer.reset-size9.size1,.katex .sizing.reset-size9.size1{font-size:.2893518519em}.katex .fontsize-ensurer.reset-size9.size2,.katex .sizing.reset-size9.size2{font-size:.3472222222em}.katex .fontsize-ensurer.reset-size9.size3,.katex .sizing.reset-size9.size3{font-size:.4050925926em}.katex .fontsize-ensurer.reset-size9.size4,.katex .sizing.reset-size9.size4{font-size:.462962963em}.katex .fontsize-ensurer.reset-size9.size5,.katex .sizing.reset-size9.size5{font-size:.5208333333em}.katex .fontsize-ensurer.reset-size9.size6,.katex .sizing.reset-size9.size6{font-size:.5787037037em}.katex .fontsize-ensurer.reset-size9.size7,.katex .sizing.reset-size9.size7{font-size:.6944444444em}.katex .fontsize-ensurer.reset-size9.size8,.katex .sizing.reset-size9.size8{font-size:.8333333333em}.katex .fontsize-ensurer.reset-size9.size9,.katex .sizing.reset-size9.size9{font-size:1em}.katex .fontsize-ensurer.reset-size9.size10,.katex .sizing.reset-size9.size10{font-size:1.2002314815em}.katex .fontsize-ensurer.reset-size9.size11,.katex .sizing.reset-size9.size11{font-size:1.4398148148em}.katex .fontsize-ensurer.reset-size10.size1,.katex .sizing.reset-size10.size1{font-size:.2410800386em}.katex .fontsize-ensurer.reset-size10.size2,.katex .sizing.reset-size10.size2{font-size:.2892960463em}.katex .fontsize-ensurer.reset-size10.size3,.katex .sizing.reset-size10.size3{font-size:.337512054em}.katex .fontsize-ensurer.reset-size10.size4,.katex .sizing.reset-size10.size4{font-size:.3857280617em}.katex .fontsize-ensurer.reset-size10.size5,.katex .sizing.reset-size10.size5{font-size:.4339440694em}.katex .fontsize-ensurer.reset-size10.size6,.katex .sizing.reset-size10.size6{font-size:.4821600771em}.katex .fontsize-ensurer.reset-size10.size7,.katex .sizing.reset-size10.size7{font-size:.5785920926em}.katex .fontsize-ensurer.reset-size10.size8,.katex .sizing.reset-size10.size8{font-size:.6943105111em}.katex .fontsize-ensurer.reset-size10.size9,.katex .sizing.reset-size10.size9{font-size:.8331726133em}.katex .fontsize-ensurer.reset-size10.size10,.katex .sizing.reset-size10.size10{font-size:1em}.katex .fontsize-ensurer.reset-size10.size11,.katex .sizing.reset-size10.size11{font-size:1.1996142719em}.katex .fontsize-ensurer.reset-size11.size1,.katex .sizing.reset-size11.size1{font-size:.2009646302em}.katex .fontsize-ensurer.reset-size11.size2,.katex .sizing.reset-size11.size2{font-size:.2411575563em}.katex .fontsize-ensurer.reset-size11.size3,.katex .sizing.reset-size11.size3{font-size:.2813504823em}.katex .fontsize-ensurer.reset-size11.size4,.katex .sizing.reset-size11.size4{font-size:.3215434084em}.katex .fontsize-ensurer.reset-size11.size5,.katex .sizing.reset-size11.size5{font-size:.3617363344em}.katex .fontsize-ensurer.reset-size11.size6,.katex .sizing.reset-size11.size6{font-size:.4019292605em}.katex .fontsize-ensurer.reset-size11.size7,.katex .sizing.reset-size11.size7{font-size:.4823151125em}.katex .fontsize-ensurer.reset-size11.size8,.katex .sizing.reset-size11.size8{font-size:.578778135em}.katex .fontsize-ensurer.reset-size11.size9,.katex .sizing.reset-size11.size9{font-size:.6945337621em}.katex .fontsize-ensurer.reset-size11.size10,.katex .sizing.reset-size11.size10{font-size:.8336012862em}.katex .fontsize-ensurer.reset-size11.size11,.katex .sizing.reset-size11.size11{font-size:1em}.katex .delimsizing.size1{font-family:KaTeX_Size1}.katex .delimsizing.size2{font-family:KaTeX_Size2}.katex .delimsizing.size3{font-family:KaTeX_Size3}.katex .delimsizing.size4{font-family:KaTeX_Size4}.katex .delimsizing.mult .delim-size1>span{font-family:KaTeX_Size1}.katex .delimsizing.mult .delim-size4>span{font-family:KaTeX_Size4}.katex .nulldelimiter{display:inline-block;width:.12em}.katex .delimcenter,.katex .op-symbol{position:relative}.katex .op-symbol.small-op{font-family:KaTeX_Size1}.katex .op-symbol.large-op{font-family:KaTeX_Size2}.katex .accent>.vlist-t,.katex .op-limits>.vlist-t{text-align:center}.katex .accent .accent-body{position:relative}.katex .accent .accent-body:not(.accent-full){width:0}.katex .overlay{display:block}.katex .mtable .vertical-separator{display:inline-block;min-width:1px}.katex .mtable .arraycolsep{display:inline-block}.katex .mtable .col-align-c>.vlist-t{text-align:center}.katex .mtable .col-align-l>.vlist-t{text-align:left}.katex .mtable .col-align-r>.vlist-t{text-align:right}.katex .svg-align{text-align:left}.katex svg{fill:currentColor;stroke:currentColor;display:block;height:inherit;position:absolute;width:100%}.katex svg path{stroke:none}.katex svg{fill-rule:nonzero;fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1}.katex img{border-style:none;max-height:none;max-width:none;min-height:0;min-width:0}.katex .stretchy{display:block;overflow:hidden;position:relative;width:100%}.katex .stretchy:after,.katex .stretchy:before{content:""}.katex .hide-tail{overflow:hidden;position:relative;width:100%}.katex .halfarrow-left{left:0;overflow:hidden;position:absolute;width:50.2%}.katex .halfarrow-right{overflow:hidden;position:absolute;right:0;width:50.2%}.katex .brace-left{left:0;overflow:hidden;position:absolute;width:25.1%}.katex .brace-center{left:25%;overflow:hidden;position:absolute;width:50%}.katex .brace-right{overflow:hidden;position:absolute;right:0;width:25.1%}.katex .x-arrow-pad{padding:0 .5em}.katex .cd-arrow-pad{padding:0 .55556em 0 .27778em}.katex .mover,.katex .munder,.katex .x-arrow{text-align:center}.katex .boxpad{padding:0 .3em}.katex .fbox,.katex .fcolorbox{border:.04em solid;box-sizing:border-box}.katex .cancel-pad{padding:0 .2em}.katex .cancel-lap{margin-left:-.2em;margin-right:-.2em}.katex .sout{border-bottom-style:solid;border-bottom-width:.08em}.katex .angl{border-right:.049em solid;border-top:.049em solid;box-sizing:border-box;margin-right:.03889em}.katex .anglpad{padding:0 .03889em}.katex .eqn-num:before{content:"(" counter(katexEqnNo) ")";counter-increment:katexEqnNo}.katex .mml-eqn-num:before{content:"(" counter(mmlEqnNo) ")";counter-increment:mmlEqnNo}.katex .mtr-glue{width:50%}.katex .cd-vert-arrow{display:inline-block;position:relative}.katex .cd-label-left{display:inline-block;position:absolute;right:calc(50% + .3em);text-align:left}.katex .cd-label-right{display:inline-block;left:calc(50% + .3em);position:absolute;text-align:right}.katex-display{display:block;margin:1em 0;text-align:center}.katex-display>.katex{display:block;text-align:center;white-space:nowrap}.katex-display>.katex>.katex-html{display:block;position:relative}.katex-display>.katex>.katex-html>.tag{position:absolute;right:0}.katex-display.leqno>.katex>.katex-html>.tag{left:0;right:auto}.katex-display.fleqn>.katex{padding-left:2em;text-align:left}body{counter-reset:katexEqnNo mmlEqnNo} diff --git a/node_modules/katex/dist/katex.min.js b/node_modules/katex/dist/katex.min.js new file mode 100644 index 0000000..91882b1 --- /dev/null +++ b/node_modules/katex/dist/katex.min.js @@ -0,0 +1 @@ +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.katex=t():e.katex=t()}("undefined"!=typeof self?self:this,function(){return function(){"use strict";var e={d:function(t,r){for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}},t={};e.d(t,{default:function(){return mo}});class r extends Error{constructor(e,t){let n,o,s="KaTeX parse error: "+e;const i=t&&t.loc;if(i&&i.start<=i.end){const e=i.lexer.input;n=i.start,o=i.end,n===e.length?s+=" at end of input: ":s+=" at position "+(n+1)+": ";const t=e.slice(n,o).replace(/[^]/g,"$&\u0332");let r,l;r=n>15?"\u2026"+e.slice(n-15,n):e.slice(0,n),l=o+15e.replace(o,"-$1").toLowerCase(),i={"&":"&",">":">","<":"<",'"':""","'":"'"},l=/[&><"']/g,a=e=>String(e).replace(l,e=>i[e]),c=e=>"ordgroup"===e.type||"color"===e.type?1===e.body.length?c(e.body[0]):e:"font"===e.type?c(e.body):e,h=new Set(["mathord","textord","atom"]),m=e=>h.has(c(e).type),u={displayMode:{type:"boolean",description:"Render math in display mode, which puts the math in display style (so \\int and \\sum are large, for example), and centers the math on the page on its own line.",cli:"-d, --display-mode"},output:{type:{enum:["htmlAndMathml","html","mathml"]},description:"Determines the markup language of the output.",cli:"-F, --format "},leqno:{type:"boolean",description:"Render display math in leqno style (left-justified tags)."},fleqn:{type:"boolean",description:"Render display math flush left."},throwOnError:{type:"boolean",default:!0,cli:"-t, --no-throw-on-error",cliDescription:"Render errors (in the color given by --error-color) instead of throwing a ParseError exception when encountering an error."},errorColor:{type:"string",default:"#cc0000",cli:"-c, --error-color ",cliDescription:"A color string given in the format 'rgb' or 'rrggbb' (no #). This option determines the color of errors rendered by the -t option.",cliProcessor:e=>"#"+e},macros:{type:"object",cli:"-m, --macro ",cliDescription:"Define custom macro of the form '\\foo:expansion' (use multiple -m arguments for multiple macros).",cliDefault:[],cliProcessor:(e,t)=>(t.push(e),t)},minRuleThickness:{type:"number",description:"Specifies a minimum thickness, in ems, for fraction lines, `\\sqrt` top lines, `{array}` vertical lines, `\\hline`, `\\hdashline`, `\\underline`, `\\overline`, and the borders of `\\fbox`, `\\boxed`, and `\\fcolorbox`.",processor:e=>Math.max(0,e),cli:"--min-rule-thickness ",cliProcessor:parseFloat},colorIsTextColor:{type:"boolean",description:"Makes \\color behave like LaTeX's 2-argument \\textcolor, instead of LaTeX's one-argument \\color mode change.",cli:"-b, --color-is-text-color"},strict:{type:[{enum:["warn","ignore","error"]},"boolean","function"],description:"Turn on strict / LaTeX faithfulness mode, which throws an error if the input uses features that are not supported by LaTeX.",cli:"-S, --strict",cliDefault:!1},trust:{type:["boolean","function"],description:"Trust the input, enabling all HTML features such as \\url.",cli:"-T, --trust"},maxSize:{type:"number",default:1/0,description:"If non-zero, all user-specified sizes, e.g. in \\rule{500em}{500em}, will be capped to maxSize ems. Otherwise, elements and spaces can be arbitrarily large",processor:e=>Math.max(0,e),cli:"-s, --max-size ",cliProcessor:parseInt},maxExpand:{type:"number",default:1e3,description:"Limit the number of macro expansions to the specified number, to prevent e.g. infinite macro loops. If set to Infinity, the macro expander will try to fully expand as in LaTeX.",processor:e=>Math.max(0,e),cli:"-e, --max-expand ",cliProcessor:e=>"Infinity"===e?1/0:parseInt(e)},globalGroup:{type:"boolean",cli:!1}};function p(e){if(void 0!==e.default)return e.default;return function(e){if("string"!=typeof e)return e.enum[0];switch(e){case"boolean":return!1;case"string":return"";case"number":return 0;case"object":return{};default:throw new Error("Unexpected schema type; settings must declare an explicit default.")}}(Array.isArray(e.type)?e.type[0]:e.type)}function d(e,t,r,n){const o=r[t];e[t]=void 0!==o?n.processor?n.processor(o):o:p(n)}class g{constructor(e){void 0===e&&(e={}),this.displayMode=void 0,this.output=void 0,this.leqno=void 0,this.fleqn=void 0,this.throwOnError=void 0,this.errorColor=void 0,this.macros=void 0,this.minRuleThickness=void 0,this.colorIsTextColor=void 0,this.strict=void 0,this.trust=void 0,this.maxSize=void 0,this.maxExpand=void 0,this.globalGroup=void 0,e=e||{};for(const t of Object.keys(u)){const r=u[t];r&&d(this,t,e,r)}}reportNonstrict(e,t,r){let o=this.strict;if("function"==typeof o&&(o=o(e,t,r)),o&&"ignore"!==o){if(!0===o||"error"===o)throw new n("LaTeX-incompatible input and strict mode is set to 'error': "+t+" ["+e+"]",r);"warn"===o?"undefined"!=typeof console&&console.warn("LaTeX-incompatible input and strict mode is set to 'warn': "+t+" ["+e+"]"):"undefined"!=typeof console&&console.warn("LaTeX-incompatible input and strict mode is set to unrecognized '"+o+"': "+t+" ["+e+"]")}}useStrictBehavior(e,t,r){let n=this.strict;if("function"==typeof n)try{n=n(e,t,r)}catch(e){n="error"}return!(!n||"ignore"===n)&&(!0===n||"error"===n||("warn"===n?("undefined"!=typeof console&&console.warn("LaTeX-incompatible input and strict mode is set to 'warn': "+t+" ["+e+"]"),!1):("undefined"!=typeof console&&console.warn("LaTeX-incompatible input and strict mode is set to unrecognized '"+n+"': "+t+" ["+e+"]"),!1)))}isTrusted(e){if("url"in e&&e.url&&!e.protocol){const t=(e=>{const t=/^[\x00-\x20]*([^\\/#?]*?)(:|�*58|�*3a|&colon)/i.exec(e);return t?":"!==t[2]?null:/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(t[1])?t[1].toLowerCase():null:"_relative"})(e.url);if(null==t)return!1;e.protocol=t}const t="function"==typeof this.trust?this.trust(e):this.trust;return Boolean(t)}}class f{constructor(e,t,r){this.id=void 0,this.size=void 0,this.cramped=void 0,this.id=e,this.size=t,this.cramped=r}sup(){return b[y[this.id]]}sub(){return b[x[this.id]]}fracNum(){return b[w[this.id]]}fracDen(){return b[v[this.id]]}cramp(){return b[k[this.id]]}text(){return b[z[this.id]]}isTight(){return this.size>=2}}const b=[new f(0,0,!1),new f(1,0,!0),new f(2,1,!1),new f(3,1,!0),new f(4,2,!1),new f(5,2,!0),new f(6,3,!1),new f(7,3,!0)],y=[4,5,4,5,6,7,6,7],x=[5,5,5,5,7,7,7,7],w=[2,3,4,5,6,7,6,7],v=[3,3,5,5,7,7,7,7],k=[1,1,3,3,5,5,7,7],z=[0,1,2,3,2,3,2,3];var S={DISPLAY:b[0],TEXT:b[2],SCRIPT:b[4],SCRIPTSCRIPT:b[6]};const M=[{name:"latin",blocks:[[256,591],[768,879]]},{name:"cyrillic",blocks:[[1024,1279]]},{name:"armenian",blocks:[[1328,1423]]},{name:"brahmic",blocks:[[2304,4255]]},{name:"georgian",blocks:[[4256,4351]]},{name:"cjk",blocks:[[12288,12543],[19968,40879],[65280,65376]]},{name:"hangul",blocks:[[44032,55215]]}];const A=[];function T(e){for(let t=0;t=A[t]&&e<=A[t+1])return!0;return!1}M.forEach(e=>e.blocks.forEach(e=>A.push(...e)));const C=e=>e+" "+e,B=80,q={doubleleftarrow:"M262 157\nl10-10c34-36 62.7-77 86-123 3.3-8 5-13.3 5-16 0-5.3-6.7-8-20-8-7.3\n 0-12.2.5-14.5 1.5-2.3 1-4.8 4.5-7.5 10.5-49.3 97.3-121.7 169.3-217 216-28\n 14-57.3 25-88 33-6.7 2-11 3.8-13 5.5-2 1.7-3 4.2-3 7.5s1 5.8 3 7.5\nc2 1.7 6.3 3.5 13 5.5 68 17.3 128.2 47.8 180.5 91.5 52.3 43.7 93.8 96.2 124.5\n 157.5 9.3 8 15.3 12.3 18 13h6c12-.7 18-4 18-10 0-2-1.7-7-5-15-23.3-46-52-87\n-86-123l-10-10h399738v-40H218c328 0 0 0 0 0l-10-8c-26.7-20-65.7-43-117-69 2.7\n-2 6-3.7 10-5 36.7-16 72.3-37.3 107-64l10-8h399782v-40z\nm8 0v40h399730v-40zm0 194v40h399730v-40z",doublerightarrow:"M399738 392l\n-10 10c-34 36-62.7 77-86 123-3.3 8-5 13.3-5 16 0 5.3 6.7 8 20 8 7.3 0 12.2-.5\n 14.5-1.5 2.3-1 4.8-4.5 7.5-10.5 49.3-97.3 121.7-169.3 217-216 28-14 57.3-25 88\n-33 6.7-2 11-3.8 13-5.5 2-1.7 3-4.2 3-7.5s-1-5.8-3-7.5c-2-1.7-6.3-3.5-13-5.5-68\n-17.3-128.2-47.8-180.5-91.5-52.3-43.7-93.8-96.2-124.5-157.5-9.3-8-15.3-12.3-18\n-13h-6c-12 .7-18 4-18 10 0 2 1.7 7 5 15 23.3 46 52 87 86 123l10 10H0v40h399782\nc-328 0 0 0 0 0l10 8c26.7 20 65.7 43 117 69-2.7 2-6 3.7-10 5-36.7 16-72.3 37.3\n-107 64l-10 8H0v40zM0 157v40h399730v-40zm0 194v40h399730v-40z",leftarrow:"M400000 241H110l3-3c68.7-52.7 113.7-120\n 135-202 4-14.7 6-23 6-25 0-7.3-7-11-21-11-8 0-13.2.8-15.5 2.5-2.3 1.7-4.2 5.8\n-5.5 12.5-1.3 4.7-2.7 10.3-4 17-12 48.7-34.8 92-68.5 130S65.3 228.3 18 247\nc-10 4-16 7.7-18 11 0 8.7 6 14.3 18 17 47.3 18.7 87.8 47 121.5 85S196 441.3 208\n 490c.7 2 1.3 5 2 9s1.2 6.7 1.5 8c.3 1.3 1 3.3 2 6s2.2 4.5 3.5 5.5c1.3 1 3.3\n 1.8 6 2.5s6 1 10 1c14 0 21-3.7 21-11 0-2-2-10.3-6-25-20-79.3-65-146.7-135-202\n l-3-3h399890zM100 241v40h399900v-40z",leftbrace:"M6 548l-6-6v-35l6-11c56-104 135.3-181.3 238-232 57.3-28.7 117\n-45 179-50h399577v120H403c-43.3 7-81 15-113 26-100.7 33-179.7 91-237 174-2.7\n 5-6 9-10 13-.7 1-7.3 1-20 1H6z",leftbraceunder:"M0 6l6-6h17c12.688 0 19.313.3 20 1 4 4 7.313 8.3 10 13\n 35.313 51.3 80.813 93.8 136.5 127.5 55.688 33.7 117.188 55.8 184.5 66.5.688\n 0 2 .3 4 1 18.688 2.7 76 4.3 172 5h399450v120H429l-6-1c-124.688-8-235-61.7\n-331-161C60.687 138.7 32.312 99.3 7 54L0 41V6z",leftgroup:"M400000 80\nH435C64 80 168.3 229.4 21 260c-5.9 1.2-18 0-18 0-2 0-3-1-3-3v-38C76 61 257 0\n 435 0h399565z",leftgroupunder:"M400000 262\nH435C64 262 168.3 112.6 21 82c-5.9-1.2-18 0-18 0-2 0-3 1-3 3v38c76 158 257 219\n 435 219h399565z",leftharpoon:"M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3\n-3.3 10.2-9.5 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5\n-18.3 3-21-1.3-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7\n-196 228-6.7 4.7-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40z",leftharpoonplus:"M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3-3.3 10.2-9.5\n 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5-18.3 3-21-1.3\n-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7-196 228-6.7 4.7\n-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40zM0 435v40h400000v-40z\nm0 0v40h400000v-40z",leftharpoondown:"M7 241c-4 4-6.333 8.667-7 14 0 5.333.667 9 2 11s5.333\n 5.333 12 10c90.667 54 156 130 196 228 3.333 10.667 6.333 16.333 9 17 2 .667 5\n 1 9 1h5c10.667 0 16.667-2 18-6 2-2.667 1-9.667-3-21-32-87.333-82.667-157.667\n-152-211l-3-3h399907v-40zM93 281 H400000 v-40L7 241z",leftharpoondownplus:"M7 435c-4 4-6.3 8.7-7 14 0 5.3.7 9 2 11s5.3 5.3 12\n 10c90.7 54 156 130 196 228 3.3 10.7 6.3 16.3 9 17 2 .7 5 1 9 1h5c10.7 0 16.7\n-2 18-6 2-2.7 1-9.7-3-21-32-87.3-82.7-157.7-152-211l-3-3h399907v-40H7zm93 0\nv40h399900v-40zM0 241v40h399900v-40zm0 0v40h399900v-40z",lefthook:"M400000 281 H103s-33-11.2-61-33.5S0 197.3 0 164s14.2-61.2 42.5\n-83.5C70.8 58.2 104 47 142 47 c16.7 0 25 6.7 25 20 0 12-8.7 18.7-26 20-40 3.3\n-68.7 15.7-86 37-10 12-15 25.3-15 40 0 22.7 9.8 40.7 29.5 54 19.7 13.3 43.5 21\n 71.5 23h399859zM103 281v-40h399897v40z",leftlinesegment:C("M40 281 V428 H0 V94 H40 V241 H400000 v40z"),leftbracketunder:C("M0 0 h120 V290 H399995 v120 H0z"),leftbracketover:C("M0 440 h120 V150 H399995 v-120 H0z"),leftmapsto:C("M40 281 V448H0V74H40V241H400000v40z"),leftToFrom:"M0 147h400000v40H0zm0 214c68 40 115.7 95.7 143 167h22c15.3 0 23\n-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69-70-101l-7-8h399905v-40H95l7-8\nc28.7-32 52-65.7 70-101 10.7-23.3 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 265.3\n 68 321 0 361zm0-174v-40h399900v40zm100 154v40h399900v-40z",longequal:C("M0 50 h400000 v40H0z m0 194h40000v40H0z"),midbrace:"M200428 334\nc-100.7-8.3-195.3-44-280-108-55.3-42-101.7-93-139-153l-9-14c-2.7 4-5.7 8.7-9 14\n-53.3 86.7-123.7 153-211 199-66.7 36-137.3 56.3-212 62H0V214h199568c178.3-11.7\n 311.7-78.3 403-201 6-8 9.7-12 11-12 .7-.7 6.7-1 18-1s17.3.3 18 1c1.3 0 5 4 11\n 12 44.7 59.3 101.3 106.3 170 141s145.3 54.3 229 60h199572v120z",midbraceunder:"M199572 214\nc100.7 8.3 195.3 44 280 108 55.3 42 101.7 93 139 153l9 14c2.7-4 5.7-8.7 9-14\n 53.3-86.7 123.7-153 211-199 66.7-36 137.3-56.3 212-62h199568v120H200432c-178.3\n 11.7-311.7 78.3-403 201-6 8-9.7 12-11 12-.7.7-6.7 1-18 1s-17.3-.3-18-1c-1.3 0\n-5-4-11-12-44.7-59.3-101.3-106.3-170-141s-145.3-54.3-229-60H0V214z",oiintSize1:"M512.6 71.6c272.6 0 320.3 106.8 320.3 178.2 0 70.8-47.7 177.6\n-320.3 177.6S193.1 320.6 193.1 249.8c0-71.4 46.9-178.2 319.5-178.2z\nm368.1 178.2c0-86.4-60.9-215.4-368.1-215.4-306.4 0-367.3 129-367.3 215.4 0 85.8\n60.9 214.8 367.3 214.8 307.2 0 368.1-129 368.1-214.8z",oiintSize2:"M757.8 100.1c384.7 0 451.1 137.6 451.1 230 0 91.3-66.4 228.8\n-451.1 228.8-386.3 0-452.7-137.5-452.7-228.8 0-92.4 66.4-230 452.7-230z\nm502.4 230c0-111.2-82.4-277.2-502.4-277.2s-504 166-504 277.2\nc0 110 84 276 504 276s502.4-166 502.4-276z",oiiintSize1:"M681.4 71.6c408.9 0 480.5 106.8 480.5 178.2 0 70.8-71.6 177.6\n-480.5 177.6S202.1 320.6 202.1 249.8c0-71.4 70.5-178.2 479.3-178.2z\nm525.8 178.2c0-86.4-86.8-215.4-525.7-215.4-437.9 0-524.7 129-524.7 215.4 0\n85.8 86.8 214.8 524.7 214.8 438.9 0 525.7-129 525.7-214.8z",oiiintSize2:"M1021.2 53c603.6 0 707.8 165.8 707.8 277.2 0 110-104.2 275.8\n-707.8 275.8-606 0-710.2-165.8-710.2-275.8C311 218.8 415.2 53 1021.2 53z\nm770.4 277.1c0-131.2-126.4-327.6-770.5-327.6S248.4 198.9 248.4 330.1\nc0 130 128.8 326.4 772.7 326.4s770.5-196.4 770.5-326.4z",rightarrow:"M0 241v40h399891c-47.3 35.3-84 78-110 128\n-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20\n 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7\n 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85\n-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5\n-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67\n 151.7 139 205zm0 0v40h399900v-40z",rightbrace:"M400000 542l\n-6 6h-17c-12.7 0-19.3-.3-20-1-4-4-7.3-8.3-10-13-35.3-51.3-80.8-93.8-136.5-127.5\ns-117.2-55.8-184.5-66.5c-.7 0-2-.3-4-1-18.7-2.7-76-4.3-172-5H0V214h399571l6 1\nc124.7 8 235 61.7 331 161 31.3 33.3 59.7 72.7 85 118l7 13v35z",rightbraceunder:"M399994 0l6 6v35l-6 11c-56 104-135.3 181.3-238 232-57.3\n 28.7-117 45-179 50H-300V214h399897c43.3-7 81-15 113-26 100.7-33 179.7-91 237\n-174 2.7-5 6-9 10-13 .7-1 7.3-1 20-1h17z",rightgroup:"M0 80h399565c371 0 266.7 149.4 414 180 5.9 1.2 18 0 18 0 2 0\n 3-1 3-3v-38c-76-158-257-219-435-219H0z",rightgroupunder:"M0 262h399565c371 0 266.7-149.4 414-180 5.9-1.2 18 0 18\n 0 2 0 3 1 3 3v38c-76 158-257 219-435 219H0z",rightharpoon:"M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3\n-3.7-15.3-11-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2\n-10.7 0-16.7 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58\n 69.2 92 94.5zm0 0v40h399900v-40z",rightharpoonplus:"M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3-3.7-15.3-11\n-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2-10.7 0-16.7\n 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58 69.2 92 94.5z\nm0 0v40h399900v-40z m100 194v40h399900v-40zm0 0v40h399900v-40z",rightharpoondown:"M399747 511c0 7.3 6.7 11 20 11 8 0 13-.8 15-2.5s4.7-6.8\n 8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3 8.5-5.8 9.5\n-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3-64.7 57-92 95\n-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 241v40h399900v-40z",rightharpoondownplus:"M399747 705c0 7.3 6.7 11 20 11 8 0 13-.8\n 15-2.5s4.7-6.8 8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3\n 8.5-5.8 9.5-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3\n-64.7 57-92 95-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 435v40h399900v-40z\nm0-194v40h400000v-40zm0 0v40h400000v-40z",righthook:"M399859 241c-764 0 0 0 0 0 40-3.3 68.7-15.7 86-37 10-12 15-25.3\n 15-40 0-22.7-9.8-40.7-29.5-54-19.7-13.3-43.5-21-71.5-23-17.3-1.3-26-8-26-20 0\n-13.3 8.7-20 26-20 38 0 71 11.2 99 33.5 0 0 7 5.6 21 16.7 14 11.2 21 33.5 21\n 66.8s-14 61.2-42 83.5c-28 22.3-61 33.5-99 33.5L0 241z M0 281v-40h399859v40z",rightlinesegment:C("M399960 241 V94 h40 V428 h-40 V281 H0 v-40z"),rightbracketunder:C("M399995 0 h-120 V290 H0 v120 H400000z"),rightbracketover:C("M399995 440 h-120 V150 H0 v-120 H399995z"),rightToFrom:"M400000 167c-70.7-42-118-97.7-142-167h-23c-15.3 0-23 .3-23\n 1 0 1.3 5.3 13.7 16 37 18 35.3 41.3 69 70 101l7 8H0v40h399905l-7 8c-28.7 32\n-52 65.7-70 101-10.7 23.3-16 35.7-16 37 0 .7 7.7 1 23 1h23c24-69.3 71.3-125 142\n-167z M100 147v40h399900v-40zM0 341v40h399900v-40z",twoheadleftarrow:"M0 167c68 40\n 115.7 95.7 143 167h22c15.3 0 23-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69\n-70-101l-7-8h125l9 7c50.7 39.3 85 86 103 140h46c0-4.7-6.3-18.7-19-42-18-35.3\n-40-67.3-66-96l-9-9h399716v-40H284l9-9c26-28.7 48-60.7 66-96 12.7-23.333 19\n-37.333 19-42h-46c-18 54-52.3 100.7-103 140l-9 7H95l7-8c28.7-32 52-65.7 70-101\n 10.7-23.333 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 71.3 68 127 0 167z",twoheadrightarrow:"M400000 167\nc-68-40-115.7-95.7-143-167h-22c-15.3 0-23 .3-23 1 0 1.3 5.3 13.7 16 37 18 35.3\n 41.3 69 70 101l7 8h-125l-9-7c-50.7-39.3-85-86-103-140h-46c0 4.7 6.3 18.7 19 42\n 18 35.3 40 67.3 66 96l9 9H0v40h399716l-9 9c-26 28.7-48 60.7-66 96-12.7 23.333\n-19 37.333-19 42h46c18-54 52.3-100.7 103-140l9-7h125l-7 8c-28.7 32-52 65.7-70\n 101-10.7 23.333-16 35.7-16 37 0 .7 7.7 1 23 1h22c27.3-71.3 75-127 143-167z",tilde1:"M200 55.538c-77 0-168 73.953-177 73.953-3 0-7\n-2.175-9-5.437L2 97c-1-2-2-4-2-6 0-4 2-7 5-9l20-12C116 12 171 0 207 0c86 0\n 114 68 191 68 78 0 168-68 177-68 4 0 7 2 9 5l12 19c1 2.175 2 4.35 2 6.525 0\n 4.35-2 7.613-5 9.788l-19 13.05c-92 63.077-116.937 75.308-183 76.128\n-68.267.847-113-73.952-191-73.952z",tilde2:"M344 55.266c-142 0-300.638 81.316-311.5 86.418\n-8.01 3.762-22.5 10.91-23.5 5.562L1 120c-1-2-1-3-1-4 0-5 3-9 8-10l18.4-9C160.9\n 31.9 283 0 358 0c148 0 188 122 331 122s314-97 326-97c4 0 8 2 10 7l7 21.114\nc1 2.14 1 3.21 1 4.28 0 5.347-3 9.626-7 10.696l-22.3 12.622C852.6 158.372 751\n 181.476 676 181.476c-149 0-189-126.21-332-126.21z",tilde3:"M786 59C457 59 32 175.242 13 175.242c-6 0-10-3.457\n-11-10.37L.15 138c-1-7 3-12 10-13l19.2-6.4C378.4 40.7 634.3 0 804.3 0c337 0\n 411.8 157 746.8 157 328 0 754-112 773-112 5 0 10 3 11 9l1 14.075c1 8.066-.697\n 16.595-6.697 17.492l-21.052 7.31c-367.9 98.146-609.15 122.696-778.15 122.696\n -338 0-409-156.573-744-156.573z",tilde4:"M786 58C457 58 32 177.487 13 177.487c-6 0-10-3.345\n-11-10.035L.15 143c-1-7 3-12 10-13l22-6.7C381.2 35 637.15 0 807.15 0c337 0 409\n 177 744 177 328 0 754-127 773-127 5 0 10 3 11 9l1 14.794c1 7.805-3 13.38-9\n 14.495l-20.7 5.574c-366.85 99.79-607.3 139.372-776.3 139.372-338 0-409\n -175.236-744-175.236z",vec:"M377 20c0-5.333 1.833-10 5.5-14S391 0 397 0c4.667 0 8.667 1.667 12 5\n3.333 2.667 6.667 9 10 19 6.667 24.667 20.333 43.667 41 57 7.333 4.667 11\n10.667 11 18 0 6-1 10-3 12s-6.667 5-14 9c-28.667 14.667-53.667 35.667-75 63\n-1.333 1.333-3.167 3.5-5.5 6.5s-4 4.833-5 5.5c-1 .667-2.5 1.333-4.5 2s-4.333 1\n-7 1c-4.667 0-9.167-1.833-13.5-5.5S337 184 337 178c0-12.667 15.667-32.333 47-59\nH213l-171-1c-8.667-6-13-12.333-13-19 0-4.667 4.333-11.333 13-20h359\nc-16-25.333-24-45-24-59z",widehat1:"M529 0h5l519 115c5 1 9 5 9 10 0 1-1 2-1 3l-4 22\nc-1 5-5 9-11 9h-2L532 67 19 159h-2c-5 0-9-4-11-9l-5-22c-1-6 2-12 8-13z",widehat2:"M1181 0h2l1171 176c6 0 10 5 10 11l-2 23c-1 6-5 10\n-11 10h-1L1182 67 15 220h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z",widehat3:"M1181 0h2l1171 236c6 0 10 5 10 11l-2 23c-1 6-5 10\n-11 10h-1L1182 67 15 280h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z",widehat4:"M1181 0h2l1171 296c6 0 10 5 10 11l-2 23c-1 6-5 10\n-11 10h-1L1182 67 15 340h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z",widecheck1:"M529,159h5l519,-115c5,-1,9,-5,9,-10c0,-1,-1,-2,-1,-3l-4,-22c-1,\n-5,-5,-9,-11,-9h-2l-512,92l-513,-92h-2c-5,0,-9,4,-11,9l-5,22c-1,6,2,12,8,13z",widecheck2:"M1181,220h2l1171,-176c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,\n-11,-10h-1l-1168,153l-1167,-153h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z",widecheck3:"M1181,280h2l1171,-236c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,\n-11,-10h-1l-1168,213l-1167,-213h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z",widecheck4:"M1181,340h2l1171,-296c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,\n-11,-10h-1l-1168,273l-1167,-273h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z",baraboveleftarrow:"M400000 620h-399890l3 -3c68.7 -52.7 113.7 -120 135 -202\nc4 -14.7 6 -23 6 -25c0 -7.3 -7 -11 -21 -11c-8 0 -13.2 0.8 -15.5 2.5\nc-2.3 1.7 -4.2 5.8 -5.5 12.5c-1.3 4.7 -2.7 10.3 -4 17c-12 48.7 -34.8 92 -68.5 130\ns-74.2 66.3 -121.5 85c-10 4 -16 7.7 -18 11c0 8.7 6 14.3 18 17c47.3 18.7 87.8 47\n121.5 85s56.5 81.3 68.5 130c0.7 2 1.3 5 2 9s1.2 6.7 1.5 8c0.3 1.3 1 3.3 2 6\ns2.2 4.5 3.5 5.5c1.3 1 3.3 1.8 6 2.5s6 1 10 1c14 0 21 -3.7 21 -11\nc0 -2 -2 -10.3 -6 -25c-20 -79.3 -65 -146.7 -135 -202l-3 -3h399890z\nM100 620v40h399900v-40z M0 241v40h399900v-40zM0 241v40h399900v-40z",rightarrowabovebar:"M0 241v40h399891c-47.3 35.3-84 78-110 128-16.7 32\n-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20 11 8 0\n13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7 39\n-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85-40.5\n-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5\n-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67\n151.7 139 205zm96 379h399894v40H0zm0 0h399904v40H0z",baraboveshortleftharpoon:"M507,435c-4,4,-6.3,8.7,-7,14c0,5.3,0.7,9,2,11\nc1.3,2,5.3,5.3,12,10c90.7,54,156,130,196,228c3.3,10.7,6.3,16.3,9,17\nc2,0.7,5,1,9,1c0,0,5,0,5,0c10.7,0,16.7,-2,18,-6c2,-2.7,1,-9.7,-3,-21\nc-32,-87.3,-82.7,-157.7,-152,-211c0,0,-3,-3,-3,-3l399351,0l0,-40\nc-398570,0,-399437,0,-399437,0z M593 435 v40 H399500 v-40z\nM0 281 v-40 H399908 v40z M0 281 v-40 H399908 v40z",rightharpoonaboveshortbar:"M0,241 l0,40c399126,0,399993,0,399993,0\nc4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199,\n-231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6\nc-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z\nM0 241 v40 H399908 v-40z M0 475 v-40 H399500 v40z M0 475 v-40 H399500 v40z",shortbaraboveleftharpoon:"M7,435c-4,4,-6.3,8.7,-7,14c0,5.3,0.7,9,2,11\nc1.3,2,5.3,5.3,12,10c90.7,54,156,130,196,228c3.3,10.7,6.3,16.3,9,17c2,0.7,5,1,9,\n1c0,0,5,0,5,0c10.7,0,16.7,-2,18,-6c2,-2.7,1,-9.7,-3,-21c-32,-87.3,-82.7,-157.7,\n-152,-211c0,0,-3,-3,-3,-3l399907,0l0,-40c-399126,0,-399993,0,-399993,0z\nM93 435 v40 H400000 v-40z M500 241 v40 H400000 v-40z M500 241 v40 H400000 v-40z",shortrightharpoonabovebar:"M53,241l0,40c398570,0,399437,0,399437,0\nc4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199,\n-231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6\nc-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z\nM500 241 v40 H399408 v-40z M500 435 v40 H400000 v-40z"};class I{constructor(e){this.children=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,this.children=e,this.classes=[],this.height=0,this.depth=0,this.maxFontSize=0,this.style={}}hasClass(e){return this.classes.includes(e)}toNode(){const e=document.createDocumentFragment();for(let t=0;t{if("toText"in e)return e.toText();throw new Error("Expected MathDomNode with toText, got "+e.constructor.name)}).join("")}}const R={pt:1,mm:7227/2540,cm:7227/254,in:72.27,bp:1.00375,pc:12,dd:1238/1157,cc:14856/1157,nd:685/642,nc:1370/107,sp:1/65536,px:1.00375},H={ex:!0,em:!0,mu:!0},E=function(e){return"string"!=typeof e&&(e=e.unit),e in R||e in H||"ex"===e},N=function(e,t){let r;if(e.unit in R)r=R[e.unit]/t.fontMetrics().ptPerEm/t.sizeMultiplier;else if("mu"===e.unit)r=t.fontMetrics().cssEmPerMu;else{let o;if(o=t.style.isTight()?t.havingStyle(t.style.text()):t,"ex"===e.unit)r=o.fontMetrics().xHeight;else{if("em"!==e.unit)throw new n("Invalid unit: '"+e.unit+"'");r=o.fontMetrics().quad}o!==t&&(r*=o.sizeMultiplier/t.sizeMultiplier)}return Math.min(e.number*r,t.maxSize)},O=function(e){return+e.toFixed(4)+"em"},D=function(e){return e.filter(e=>e).join(" ")},L=function(e){let t="";for(const r of Object.keys(e)){const n=e[r];void 0!==n&&(t+=s(r)+":"+n+";")}return t},P=function(e,t,r){if(this.classes=e||[],this.attributes={},this.height=0,this.depth=0,this.maxFontSize=0,this.style=r||{},t){t.style.isTight()&&this.classes.push("mtight");const e=t.getColor();e&&(this.style.color=e)}},F=function(e){const t=document.createElement(e);t.className=D(this.classes),Object.assign(t.style,this.style);for(const e of Object.keys(this.attributes))t.setAttribute(e,this.attributes[e]);for(let e=0;e/=\x00-\x1f]/,G=function(e){let t="<"+e;this.classes.length&&(t+=' class="'+a(D(this.classes))+'"');const r=L(this.style);r&&(t+=' style="'+a(r)+'"');for(const e of Object.keys(this.attributes)){if(V.test(e))throw new n("Invalid attribute name '"+e+"'");t+=" "+e+'="'+a(this.attributes[e])+'"'}t+=">";for(let e=0;e",t};class U{constructor(e,t,r,n){this.children=void 0,this.attributes=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.width=void 0,this.maxFontSize=void 0,this.style=void 0,this.italic=void 0,P.call(this,e,r,n),this.children=t||[]}setAttribute(e,t){this.attributes[e]=t}hasClass(e){return this.classes.includes(e)}toNode(){return F.call(this,"span")}toMarkup(){return G.call(this,"span")}}class X{constructor(e,t,r,n){this.children=void 0,this.attributes=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,P.call(this,t,n),this.children=r||[],this.setAttribute("href",e)}setAttribute(e,t){this.attributes[e]=t}hasClass(e){return this.classes.includes(e)}toNode(){return F.call(this,"a")}toMarkup(){return G.call(this,"a")}}class Y{constructor(e,t,r){this.src=void 0,this.alt=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,this.alt=t,this.src=e,this.classes=["mord"],this.height=0,this.depth=0,this.maxFontSize=0,this.style=r}hasClass(e){return this.classes.includes(e)}toNode(){const e=document.createElement("img");return e.src=this.src,e.alt=this.alt,e.className="mord",Object.assign(e.style,this.style),e}toMarkup(){let e=''+a(this.alt)+'=n[0]&&e<=n[1])return r.name}}return null}(this.text.charCodeAt(0));a&&this.classes.push(a+"_fallback"),/[\xee\xef\xed\xec]/.test(this.text)&&(this.text=j[this.text])}hasClass(e){return this.classes.includes(e)}toNode(){const e=document.createTextNode(this.text);let t=null;return this.italic>0&&(t=document.createElement("span"),t.style.marginRight=O(this.italic)),this.classes.length>0&&(t=t||document.createElement("span"),t.className=D(this.classes)),Object.keys(this.style).length>0&&(t=t||document.createElement("span"),Object.assign(t.style,this.style)),t?(t.appendChild(e),t):e}toMarkup(){let e=!1,t="0&&(r+="margin-right:"+O(this.italic)+";"),r+=L(this.style),r&&(e=!0,t+=' style="'+a(r)+'"');const n=a(this.text);return e?(t+=">",t+=n,t+="",t):n}}class _{constructor(e,t){this.children=void 0,this.attributes=void 0,this.children=e||[],this.attributes=t||{}}toNode(){const e=document.createElementNS("http://www.w3.org/2000/svg","svg");for(const t of Object.keys(this.attributes))e.setAttribute(t,this.attributes[t]);for(let t=0;t':''}}class Z{constructor(e){this.attributes=void 0,this.attributes=e||{}}toNode(){const e=document.createElementNS("http://www.w3.org/2000/svg","line");for(const t of Object.keys(this.attributes))e.setAttribute(t,this.attributes[t]);return e}toMarkup(){let e="","\\gt",!0),oe(se,le,be,"\u2208","\\in",!0),oe(se,le,be,"\ue020","\\@not"),oe(se,le,be,"\u2282","\\subset",!0),oe(se,le,be,"\u2283","\\supset",!0),oe(se,le,be,"\u2286","\\subseteq",!0),oe(se,le,be,"\u2287","\\supseteq",!0),oe(se,ae,be,"\u2288","\\nsubseteq",!0),oe(se,ae,be,"\u2289","\\nsupseteq",!0),oe(se,le,be,"\u22a8","\\models"),oe(se,le,be,"\u2190","\\leftarrow",!0),oe(se,le,be,"\u2264","\\le"),oe(se,le,be,"\u2264","\\leq",!0),oe(se,le,be,"<","\\lt",!0),oe(se,le,be,"\u2192","\\rightarrow",!0),oe(se,le,be,"\u2192","\\to"),oe(se,ae,be,"\u2271","\\ngeq",!0),oe(se,ae,be,"\u2270","\\nleq",!0),oe(se,le,ye,"\xa0","\\ "),oe(se,le,ye,"\xa0","\\space"),oe(se,le,ye,"\xa0","\\nobreakspace"),oe(ie,le,ye,"\xa0","\\ "),oe(ie,le,ye,"\xa0"," "),oe(ie,le,ye,"\xa0","\\space"),oe(ie,le,ye,"\xa0","\\nobreakspace"),oe(se,le,ye,"","\\nobreak"),oe(se,le,ye,"","\\allowbreak"),oe(se,le,fe,",",","),oe(se,le,fe,";",";"),oe(se,ae,he,"\u22bc","\\barwedge",!0),oe(se,ae,he,"\u22bb","\\veebar",!0),oe(se,le,he,"\u2299","\\odot",!0),oe(se,le,he,"\u2295","\\oplus",!0),oe(se,le,he,"\u2297","\\otimes",!0),oe(se,le,xe,"\u2202","\\partial",!0),oe(se,le,he,"\u2298","\\oslash",!0),oe(se,ae,he,"\u229a","\\circledcirc",!0),oe(se,ae,he,"\u22a1","\\boxdot",!0),oe(se,le,he,"\u25b3","\\bigtriangleup"),oe(se,le,he,"\u25bd","\\bigtriangledown"),oe(se,le,he,"\u2020","\\dagger"),oe(se,le,he,"\u22c4","\\diamond"),oe(se,le,he,"\u22c6","\\star"),oe(se,le,he,"\u25c3","\\triangleleft"),oe(se,le,he,"\u25b9","\\triangleright"),oe(se,le,ge,"{","\\{"),oe(ie,le,xe,"{","\\{"),oe(ie,le,xe,"{","\\textbraceleft"),oe(se,le,me,"}","\\}"),oe(ie,le,xe,"}","\\}"),oe(ie,le,xe,"}","\\textbraceright"),oe(se,le,ge,"{","\\lbrace"),oe(se,le,me,"}","\\rbrace"),oe(se,le,ge,"[","\\lbrack",!0),oe(ie,le,xe,"[","\\lbrack",!0),oe(se,le,me,"]","\\rbrack",!0),oe(ie,le,xe,"]","\\rbrack",!0),oe(se,le,ge,"(","\\lparen",!0),oe(se,le,me,")","\\rparen",!0),oe(ie,le,xe,"<","\\textless",!0),oe(ie,le,xe,">","\\textgreater",!0),oe(se,le,ge,"\u230a","\\lfloor",!0),oe(se,le,me,"\u230b","\\rfloor",!0),oe(se,le,ge,"\u2308","\\lceil",!0),oe(se,le,me,"\u2309","\\rceil",!0),oe(se,le,xe,"\\","\\backslash"),oe(se,le,xe,"\u2223","|"),oe(se,le,xe,"\u2223","\\vert"),oe(ie,le,xe,"|","\\textbar",!0),oe(se,le,xe,"\u2225","\\|"),oe(se,le,xe,"\u2225","\\Vert"),oe(ie,le,xe,"\u2225","\\textbardbl"),oe(ie,le,xe,"~","\\textasciitilde"),oe(ie,le,xe,"\\","\\textbackslash"),oe(ie,le,xe,"^","\\textasciicircum"),oe(se,le,be,"\u2191","\\uparrow",!0),oe(se,le,be,"\u21d1","\\Uparrow",!0),oe(se,le,be,"\u2193","\\downarrow",!0),oe(se,le,be,"\u21d3","\\Downarrow",!0),oe(se,le,be,"\u2195","\\updownarrow",!0),oe(se,le,be,"\u21d5","\\Updownarrow",!0),oe(se,le,de,"\u2210","\\coprod"),oe(se,le,de,"\u22c1","\\bigvee"),oe(se,le,de,"\u22c0","\\bigwedge"),oe(se,le,de,"\u2a04","\\biguplus"),oe(se,le,de,"\u22c2","\\bigcap"),oe(se,le,de,"\u22c3","\\bigcup"),oe(se,le,de,"\u222b","\\int"),oe(se,le,de,"\u222b","\\intop"),oe(se,le,de,"\u222c","\\iint"),oe(se,le,de,"\u222d","\\iiint"),oe(se,le,de,"\u220f","\\prod"),oe(se,le,de,"\u2211","\\sum"),oe(se,le,de,"\u2a02","\\bigotimes"),oe(se,le,de,"\u2a01","\\bigoplus"),oe(se,le,de,"\u2a00","\\bigodot"),oe(se,le,de,"\u222e","\\oint"),oe(se,le,de,"\u222f","\\oiint"),oe(se,le,de,"\u2230","\\oiiint"),oe(se,le,de,"\u2a06","\\bigsqcup"),oe(se,le,de,"\u222b","\\smallint"),oe(ie,le,ue,"\u2026","\\textellipsis"),oe(se,le,ue,"\u2026","\\mathellipsis"),oe(ie,le,ue,"\u2026","\\ldots",!0),oe(se,le,ue,"\u2026","\\ldots",!0),oe(se,le,ue,"\u22ef","\\@cdots",!0),oe(se,le,ue,"\u22f1","\\ddots",!0),oe(se,le,xe,"\u22ee","\\varvdots"),oe(ie,le,xe,"\u22ee","\\varvdots"),oe(se,le,ce,"\u02ca","\\acute"),oe(se,le,ce,"\u02cb","\\grave"),oe(se,le,ce,"\xa8","\\ddot"),oe(se,le,ce,"~","\\tilde"),oe(se,le,ce,"\u02c9","\\bar"),oe(se,le,ce,"\u02d8","\\breve"),oe(se,le,ce,"\u02c7","\\check"),oe(se,le,ce,"^","\\hat"),oe(se,le,ce,"\u20d7","\\vec"),oe(se,le,ce,"\u02d9","\\dot"),oe(se,le,ce,"\u02da","\\mathring"),oe(se,le,pe,"\ue131","\\@imath"),oe(se,le,pe,"\ue237","\\@jmath"),oe(se,le,xe,"\u0131","\u0131"),oe(se,le,xe,"\u0237","\u0237"),oe(ie,le,xe,"\u0131","\\i",!0),oe(ie,le,xe,"\u0237","\\j",!0),oe(ie,le,xe,"\xdf","\\ss",!0),oe(ie,le,xe,"\xe6","\\ae",!0),oe(ie,le,xe,"\u0153","\\oe",!0),oe(ie,le,xe,"\xf8","\\o",!0),oe(ie,le,xe,"\xc6","\\AE",!0),oe(ie,le,xe,"\u0152","\\OE",!0),oe(ie,le,xe,"\xd8","\\O",!0),oe(ie,le,ce,"\u02ca","\\'"),oe(ie,le,ce,"\u02cb","\\`"),oe(ie,le,ce,"\u02c6","\\^"),oe(ie,le,ce,"\u02dc","\\~"),oe(ie,le,ce,"\u02c9","\\="),oe(ie,le,ce,"\u02d8","\\u"),oe(ie,le,ce,"\u02d9","\\."),oe(ie,le,ce,"\xb8","\\c"),oe(ie,le,ce,"\u02da","\\r"),oe(ie,le,ce,"\u02c7","\\v"),oe(ie,le,ce,"\xa8",'\\"'),oe(ie,le,ce,"\u02dd","\\H"),oe(ie,le,ce,"\u25ef","\\textcircled");const we={"--":!0,"---":!0,"``":!0,"''":!0};oe(ie,le,xe,"\u2013","--",!0),oe(ie,le,xe,"\u2013","\\textendash"),oe(ie,le,xe,"\u2014","---",!0),oe(ie,le,xe,"\u2014","\\textemdash"),oe(ie,le,xe,"\u2018","`",!0),oe(ie,le,xe,"\u2018","\\textquoteleft"),oe(ie,le,xe,"\u2019","'",!0),oe(ie,le,xe,"\u2019","\\textquoteright"),oe(ie,le,xe,"\u201c","``",!0),oe(ie,le,xe,"\u201c","\\textquotedblleft"),oe(ie,le,xe,"\u201d","''",!0),oe(ie,le,xe,"\u201d","\\textquotedblright"),oe(se,le,xe,"\xb0","\\degree",!0),oe(ie,le,xe,"\xb0","\\degree"),oe(ie,le,xe,"\xb0","\\textdegree",!0),oe(se,le,xe,"\xa3","\\pounds"),oe(se,le,xe,"\xa3","\\mathsterling",!0),oe(ie,le,xe,"\xa3","\\pounds"),oe(ie,le,xe,"\xa3","\\textsterling",!0),oe(se,ae,xe,"\u2720","\\maltese"),oe(ie,ae,xe,"\u2720","\\maltese");const ve='0123456789/@."';for(let e=0;e<14;e++){const t=ve.charAt(e);oe(se,le,xe,t,t)}const ke='0123456789!@*()-=+";:?/.,';for(let e=0;e<25;e++){const t=ke.charAt(e);oe(ie,le,xe,t,t)}const ze="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";for(let e=0;e<52;e++){const t=ze.charAt(e);oe(se,le,pe,t,t),oe(ie,le,xe,t,t)}let Se;oe(se,ae,xe,"C","\u2102"),oe(ie,ae,xe,"C","\u2102"),oe(se,ae,xe,"H","\u210d"),oe(ie,ae,xe,"H","\u210d"),oe(se,ae,xe,"N","\u2115"),oe(ie,ae,xe,"N","\u2115"),oe(se,ae,xe,"P","\u2119"),oe(ie,ae,xe,"P","\u2119"),oe(se,ae,xe,"Q","\u211a"),oe(ie,ae,xe,"Q","\u211a"),oe(se,ae,xe,"R","\u211d"),oe(ie,ae,xe,"R","\u211d"),oe(se,ae,xe,"Z","\u2124"),oe(ie,ae,xe,"Z","\u2124"),oe(se,le,pe,"h","\u210e"),oe(ie,le,pe,"h","\u210e");for(let e=0;e<52;e++){const t=ze.charAt(e);Se=String.fromCharCode(55349,56320+e),oe(se,le,pe,t,Se),oe(ie,le,xe,t,Se),Se=String.fromCharCode(55349,56372+e),oe(se,le,pe,t,Se),oe(ie,le,xe,t,Se),Se=String.fromCharCode(55349,56424+e),oe(se,le,pe,t,Se),oe(ie,le,xe,t,Se),Se=String.fromCharCode(55349,56580+e),oe(se,le,pe,t,Se),oe(ie,le,xe,t,Se),Se=String.fromCharCode(55349,56684+e),oe(se,le,pe,t,Se),oe(ie,le,xe,t,Se),Se=String.fromCharCode(55349,56736+e),oe(se,le,pe,t,Se),oe(ie,le,xe,t,Se),Se=String.fromCharCode(55349,56788+e),oe(se,le,pe,t,Se),oe(ie,le,xe,t,Se),Se=String.fromCharCode(55349,56840+e),oe(se,le,pe,t,Se),oe(ie,le,xe,t,Se),Se=String.fromCharCode(55349,56944+e),oe(se,le,pe,t,Se),oe(ie,le,xe,t,Se),e<26&&(Se=String.fromCharCode(55349,56632+e),oe(se,le,pe,t,Se),oe(ie,le,xe,t,Se),Se=String.fromCharCode(55349,56476+e),oe(se,le,pe,t,Se),oe(ie,le,xe,t,Se))}Se=String.fromCharCode(55349,56668),oe(se,le,pe,"k",Se),oe(ie,le,xe,"k",Se);for(let e=0;e<10;e++){const t=e.toString();Se=String.fromCharCode(55349,57294+e),oe(se,le,pe,t,Se),oe(ie,le,xe,t,Se),Se=String.fromCharCode(55349,57314+e),oe(se,le,pe,t,Se),oe(ie,le,xe,t,Se),Se=String.fromCharCode(55349,57324+e),oe(se,le,pe,t,Se),oe(ie,le,xe,t,Se),Se=String.fromCharCode(55349,57334+e),oe(se,le,pe,t,Se),oe(ie,le,xe,t,Se)}const Me="\xd0\xde\xfe";for(let e=0;e<3;e++){const t=Me.charAt(e);oe(se,le,pe,t,t),oe(ie,le,xe,t,t)}const Ae={mathClass:"mathbf",textClass:"textbf",font:"Main-Bold"},Te={mathClass:"mathnormal",textClass:"textit",font:"Math-Italic"},Ce={mathClass:"boldsymbol",textClass:"boldsymbol",font:"Main-BoldItalic"},Be={mathClass:"",textClass:"",font:""},qe={mathClass:"mathfrak",textClass:"textfrak",font:"Fraktur-Regular"},Ie={mathClass:"mathbb",textClass:"textbb",font:"AMS-Regular"},Re={mathClass:"mathboldfrak",textClass:"textboldfrak",font:"Fraktur-Regular"},He={mathClass:"mathsf",textClass:"textsf",font:"SansSerif-Regular"},Ee={mathClass:"mathboldsf",textClass:"textboldsf",font:"SansSerif-Bold"},Ne={mathClass:"mathitsf",textClass:"textitsf",font:"SansSerif-Italic"},Oe={mathClass:"mathtt",textClass:"texttt",font:"Typewriter-Regular"},De=[Ae,Ae,Te,Te,Ce,Ce,{mathClass:"mathscr",textClass:"textscr",font:"Script-Regular"},Be,Be,Be,qe,qe,Ie,Ie,Re,Re,He,He,Ee,Ee,Ne,Ne,Be,Be,Oe,Oe],Le=[Ae,Be,He,Ee,Oe],Pe=function(e,t,r){if(ne[r][e]){const t=ne[r][e].replace;t&&(e=t)}return{value:e,metrics:ee(e,t,r)}},Fe=function(e,t,r,n,o){const s=Pe(e,t,r),i=s.metrics;let l;if(e=s.value,i){let t=i.italic;("text"===r||n&&"mathit"===n.font)&&(t=0),l=new W(e,i.height,i.depth,t,i.skew,i.width,o)}else"undefined"!=typeof console&&console.warn("No character metrics for '"+e+"' in style '"+t+"' and mode '"+r+"'"),l=new W(e,0,0,0,0,0,o);if(n){l.maxFontSize=n.sizeMultiplier,n.style.isTight()&&l.classes.push("mtight");const e=n.getColor();e&&(l.style.color=e)}return l},Ve=function(e,t,r,n){return void 0===n&&(n=[]),"boldsymbol"===r.font&&Pe(e,"Main-Bold",t).metrics?Fe(e,"Main-Bold",t,r,n.concat(["mathbf"])):"\\"===e||"main"===ne[t][e].font?Fe(e,"Main-Regular",t,r,n):Fe(e,"AMS-Regular",t,r,n.concat(["amsrm"]))},Ge=function(e,t){const r="mathord"===e.type?"mathord":"textord",o=e.mode,s=e.text,i=["mord"],{font:l,fontFamily:a,fontWeight:c,fontShape:h}=t,m="math"===o||"text"===o&&!!l,u=m?l:a;let p="",d="";if(55349===s.charCodeAt(0)){const e=(e=>{const t=1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320)+65536;if(119808<=t&&t<120484){const e=Math.floor((t-119808)/26);return De[e]}if(120782<=t&&t<=120831){const e=Math.floor((t-120782)/10);return Le[e]}if(120485===t||120486===t)return De[0];if(120486{if(D(e.classes)!==D(t.classes)||e.skew!==t.skew||e.maxFontSize!==t.maxFontSize||0!==e.italic&&e.hasClass("mathnormal"))return!1;if(1===e.classes.length){const t=e.classes[0];if("mbin"===t||"mord"===t)return!1}for(const r of Object.keys(e.style))if(e.style[r]!==t.style[r])return!1;for(const r of Object.keys(t.style))if(e.style[r]!==t.style[r])return!1;return!0},Xe=e=>{for(let t=0;tt&&(t=s.height),s.depth>r&&(r=s.depth),s.maxFontSize>n&&(n=s.maxFontSize)}e.height=t,e.depth=r,e.maxFontSize=n},je=function(e,t,r,n){const o=new U(e,t,r,n);return Ye(o),o},We=(e,t,r,n)=>new U(e,t,r,n),_e=function(e,t,r){const n=je([e],[],t);return n.height=Math.max(r||t.fontMetrics().defaultRuleThickness,t.minRuleThickness),n.style.borderBottomWidth=O(n.height),n.maxFontSize=1,n},$e=function(e){const t=new I(e);return Ye(t),t},Ze=function(e,t){return e instanceof I?je([],[e],t):e},Ke=function(e,t){const{children:r,depth:n}=function(e){if("individualShift"===e.positionType){const t=e.children,r=[t[0]],n=-t[0].shift-t[0].elem.depth;let o=n;for(let e=1;e{const r=je(["mspace"],[],t),n=N(e,t);return r.style.marginRight=O(n),r},Qe=(e,t,r)=>{let n,o;switch(e){case"amsrm":n="AMS";break;case"textrm":n="Main";break;case"textsf":n="SansSerif";break;case"texttt":n="Typewriter";break;default:n=e}return o="textbf"===t&&"textit"===r?"BoldItalic":"textbf"===t?"Bold":"textit"===r?"Italic":"Regular",n+"-"+o},et={mathbf:{variant:"bold",fontName:"Main-Bold"},mathrm:{variant:"normal",fontName:"Main-Regular"},textit:{variant:"italic",fontName:"Main-Italic"},mathit:{variant:"italic",fontName:"Main-Italic"},mathnormal:{variant:"italic",fontName:"Math-Italic"},mathsfit:{variant:"sans-serif-italic",fontName:"SansSerif-Italic"},mathbb:{variant:"double-struck",fontName:"AMS-Regular"},mathcal:{variant:"script",fontName:"Caligraphic-Regular"},mathfrak:{variant:"fraktur",fontName:"Fraktur-Regular"},mathscr:{variant:"script",fontName:"Script-Regular"},mathsf:{variant:"sans-serif",fontName:"SansSerif-Regular"},mathtt:{variant:"monospace",fontName:"Typewriter-Regular"}},tt={vec:["vec",.471,.714],oiintSize1:["oiintSize1",.957,.499],oiintSize2:["oiintSize2",1.472,.659],oiiintSize1:["oiiintSize1",1.304,.499],oiiintSize2:["oiiintSize2",1.98,.659]},rt=function(e,t){const[r,n,o]=tt[e],s=new $(r),i=new _([s],{width:O(n),height:O(o),style:"width:"+O(n),viewBox:"0 0 "+1e3*n+" "+1e3*o,preserveAspectRatio:"xMinYMin"}),l=We(["overlay"],[i],t);return l.height=o,l.style.height=O(o),l.style.width=O(n),l},nt={number:3,unit:"mu"},ot={number:4,unit:"mu"},st={number:5,unit:"mu"},it={mord:{mop:nt,mbin:ot,mrel:st,minner:nt},mop:{mord:nt,mop:nt,mrel:st,minner:nt},mbin:{mord:ot,mop:ot,mopen:ot,minner:ot},mrel:{mord:st,mop:st,mopen:st,minner:st},mopen:{},mclose:{mop:nt,mbin:ot,mrel:st,minner:nt},mpunct:{mord:nt,mop:nt,mrel:st,mopen:nt,mclose:nt,mpunct:nt,minner:nt},minner:{mord:nt,mop:nt,mbin:ot,mrel:st,mopen:nt,mpunct:nt,minner:nt}},lt={mord:{mop:nt},mop:{mord:nt,mop:nt},mbin:{},mrel:{},mopen:{},mclose:{mop:nt},mpunct:{},minner:{mop:nt}},at={},ct={},ht={};function mt(e){const{type:t,names:r,htmlBuilder:n,mathmlBuilder:o}=e;for(let t=0;t{const r=t.classes[0],n=e.classes[0];"mbin"===r&&ft.has(n)?t.classes[0]="mord":"mbin"===n&>.has(r)&&(e.classes[0]="mord")},{node:i},l,a),wt(o,(e,t)=>{var r,n;const o=zt(t),i=zt(e),l=o&&i?e.hasClass("mtight")?null==(r=lt[o])?void 0:r[i]:null==(n=it[o])?void 0:n[i]:null;if(l)return Je(l,s)},{node:i},l,a),o},wt=function(e,t,r,n,o){n&&e.push(n);let s=0;for(;sr=>{e.splice(t+1,0,r),s++})(s)}n&&e.pop()},vt=function(e){return e instanceof I||e instanceof X||e instanceof U&&e.hasClass("enclosing")?e:null},kt=function(e,t){const r=vt(e);if(r){const e=r.children;if(e.length){if("right"===t)return kt(e[e.length-1],"right");if("left"===t)return kt(e[0],"left")}}return e},zt=function(e,t){if(!e)return null;t&&(e=kt(e,t));const r=e.classes[0];return yt[r]||null},St=function(e,t){const r=["nulldelimiter"].concat(e.baseSizingClasses());return je(t.concat(r))},Mt=function(e,t,r){if(!e)return je();if(ct[e.type]){let n=ct[e.type](e,t);if(r&&t.size!==r.size){n=je(t.sizingClasses(r),[n],t);const e=t.sizeMultiplier/r.sizeMultiplier;n.height*=e,n.depth*=e}return n}throw new n("Got group of unknown type: '"+e.type+"'")};function At(e,t){const r=je(["base"],e,t),n=je(["strut"]);return n.style.height=O(r.height+r.depth),r.depth&&(n.style.verticalAlign=O(-r.depth)),r.children.unshift(n),r}function Tt(e,t){let r=null;1===e.length&&"tag"===e[0].type&&(r=e[0].tag,e=e[0].body);const n=xt(e,t,"root");let o;2===n.length&&n[1].hasClass("tag")&&(o=n.pop());const s=[];let i,l=[];for(let e=0;e0&&(s.push(At(l,t)),l=[]),s.push(n[e]));l.length>0&&s.push(At(l,t)),r?(i=At(xt(r,t,!0),t),i.classes=["tag"],s.push(i)):o&&s.push(o);const a=je(["katex-html"],s);if(a.setAttribute("aria-hidden","true"),i){const e=i.children[0];e.style.height=O(a.height+a.depth),a.depth&&(e.style.verticalAlign=O(-a.depth))}return a}function Ct(e){return new I(e)}class Bt{constructor(e,t,r){this.type=void 0,this.attributes=void 0,this.children=void 0,this.classes=void 0,this.type=e,this.attributes={},this.children=t||[],this.classes=r||[]}setAttribute(e,t){this.attributes[e]=t}getAttribute(e){return this.attributes[e]}toNode(){const e=document.createElementNS("http://www.w3.org/1998/Math/MathML",this.type);for(const t in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,t)&&e.setAttribute(t,this.attributes[t]);this.classes.length>0&&(e.className=D(this.classes));for(let t=0;t0&&(e+=' class ="'+a(D(this.classes))+'"'),e+=">";for(let t=0;t",e}toText(){return this.children.map(e=>e.toText()).join("")}}class qt{constructor(e){this.text=void 0,this.text=e}toNode(){return document.createTextNode(this.text)}toMarkup(){return a(this.toText())}toText(){return this.text}}class It{constructor(e){this.width=void 0,this.character=void 0,this.width=e,this.character=e>=.05555&&e<=.05556?"\u200a":e>=.1666&&e<=.1667?"\u2009":e>=.2222&&e<=.2223?"\u2005":e>=.2777&&e<=.2778?"\u2005\u200a":e>=-.05556&&e<=-.05555?"\u200a\u2063":e>=-.1667&&e<=-.1666?"\u2009\u2063":e>=-.2223&&e<=-.2222?"\u205f\u2063":e>=-.2778&&e<=-.2777?"\u2005\u2063":null}toNode(){if(this.character)return document.createTextNode(this.character);{const e=document.createElementNS("http://www.w3.org/1998/Math/MathML","mspace");return e.setAttribute("width",O(this.width)),e}}toMarkup(){return this.character?""+this.character+"":''}toText(){return this.character?this.character:" "}}const Rt=new Set(["\\imath","\\jmath"]),Ht=new Set(["mrow","mtable"]),Et=function(e,t,r){return!ne[t][e]||!ne[t][e].replace||55349===e.charCodeAt(0)||we.hasOwnProperty(e)&&r&&(r.fontFamily&&"tt"===r.fontFamily.slice(4,6)||r.font&&"tt"===r.font.slice(4,6))||(e=ne[t][e].replace),new qt(e)},Nt=function(e){return 1===e.length?e[0]:new Bt("mrow",e)},Ot={mathit:"italic",boldsymbol:e=>"textord"===e.type?"bold":"bold-italic",mathbf:"bold",mathbb:"double-struck",mathsfit:"sans-serif-italic",mathfrak:"fraktur",mathscr:"script",mathcal:"script",mathsf:"sans-serif",mathtt:"monospace"},Dt=(e,t)=>{if("text"===e.mode){if("texttt"===t.fontFamily)return"monospace";if("textsf"===t.fontFamily)return"textit"===t.fontShape&&"textbf"===t.fontWeight?"sans-serif-bold-italic":"textit"===t.fontShape?"sans-serif-italic":"textbf"===t.fontWeight?"bold-sans-serif":"sans-serif";if("textit"===t.fontShape&&"textbf"===t.fontWeight)return"bold-italic";if("textit"===t.fontShape)return"italic";if("textbf"===t.fontWeight)return"bold"}const r=t.font;if(!r||"mathnormal"===r)return null;const n=e.mode,o=Ot[r];if(o)return"function"==typeof o?o(e):o;let s=e.text;if(Rt.has(s))return null;if(ne[n][s]){const e=ne[n][s].replace;e&&(s=e)}return ee(s,et[r].fontName,n)?et[r].variant:null};function Lt(e){if(!e)return!1;if("mi"===e.type&&1===e.children.length){const t=e.children[0];return t instanceof qt&&"."===t.text}if("mo"===e.type&&1===e.children.length&&"true"===e.getAttribute("separator")&&"0em"===e.getAttribute("lspace")&&"0em"===e.getAttribute("rspace")){const t=e.children[0];return t instanceof qt&&","===t.text}return!1}const Pt=function(e,t,r){if(1===e.length){const n=Vt(e[0],t);return r&&n instanceof Bt&&"mo"===n.type&&(n.setAttribute("lspace","0em"),n.setAttribute("rspace","0em")),[n]}const n=[];let o;for(let r=0;r=1&&("mn"===o.type||Lt(o))){const e=s.children[0];e instanceof Bt&&"mn"===e.type&&(e.children=[...o.children,...e.children],n.pop())}else if("mi"===o.type&&1===o.children.length){const e=o.children[0];if(e instanceof qt&&"\u0338"===e.text&&("mo"===s.type||"mi"===s.type||"mn"===s.type)){const e=s.children[0];e instanceof qt&&e.text.length>0&&(e.text=e.text.slice(0,1)+"\u0338"+e.text.slice(1),n.pop())}}}n.push(s),o=s}return n},Ft=function(e,t,r){return Nt(Pt(e,t,r))},Vt=function(e,t){if(!e)return new Bt("mrow");if(ht[e.type])return ht[e.type](e,t);throw new n("Got group of unknown type: '"+e.type+"'")};function Gt(e,t,r,n,o){const s=Pt(e,r);let i;i=1===s.length&&s[0]instanceof Bt&&Ht.has(s[0].type)?s[0]:new Bt("mrow",s);const l=new Bt("annotation",[new qt(t)]);l.setAttribute("encoding","application/x-tex");const a=new Bt("semantics",[i,l]),c=new Bt("math",[a]);c.setAttribute("xmlns","http://www.w3.org/1998/Math/MathML"),n&&c.setAttribute("display","block");return je([o?"katex":"katex-mathml"],[c])}const Ut=[[1,1,1],[2,1,1],[3,1,1],[4,2,1],[5,2,1],[6,3,1],[7,4,2],[8,6,3],[9,7,6],[10,8,7],[11,10,9]],Xt=[.5,.6,.7,.8,.9,1,1.2,1.44,1.728,2.074,2.488],Yt=function(e,t){return t.size<2?e:Ut[e-1][t.size-1]};class jt{constructor(e){this.style=void 0,this.color=void 0,this.size=void 0,this.textSize=void 0,this.phantom=void 0,this.font=void 0,this.fontFamily=void 0,this.fontWeight=void 0,this.fontShape=void 0,this.sizeMultiplier=void 0,this.maxSize=void 0,this.minRuleThickness=void 0,this._fontMetrics=void 0,this.style=e.style,this.color=e.color,this.size=e.size||jt.BASESIZE,this.textSize=e.textSize||this.size,this.phantom=!!e.phantom,this.font=e.font||"",this.fontFamily=e.fontFamily||"",this.fontWeight=e.fontWeight||"",this.fontShape=e.fontShape||"",this.sizeMultiplier=Xt[this.size-1],this.maxSize=e.maxSize,this.minRuleThickness=e.minRuleThickness,this._fontMetrics=void 0}extend(e){const t={style:this.style,size:this.size,textSize:this.textSize,color:this.color,phantom:this.phantom,font:this.font,fontFamily:this.fontFamily,fontWeight:this.fontWeight,fontShape:this.fontShape,maxSize:this.maxSize,minRuleThickness:this.minRuleThickness};return Object.assign(t,e),new jt(t)}havingStyle(e){return this.style===e?this:this.extend({style:e,size:Yt(this.textSize,e)})}havingCrampedStyle(){return this.havingStyle(this.style.cramp())}havingSize(e){return this.size===e&&this.textSize===e?this:this.extend({style:this.style.text(),size:e,textSize:e,sizeMultiplier:Xt[e-1]})}havingBaseStyle(e){e=e||this.style.text();const t=Yt(jt.BASESIZE,e);return this.size===t&&this.textSize===jt.BASESIZE&&this.style===e?this:this.extend({style:e,size:t})}havingBaseSizing(){let e;switch(this.style.id){case 4:case 5:e=3;break;case 6:case 7:e=1;break;default:e=6}return this.extend({style:this.style.text(),size:e})}withColor(e){return this.extend({color:e})}withPhantom(){return this.extend({phantom:!0})}withFont(e){return this.extend({font:e})}withTextFontFamily(e){return this.extend({fontFamily:e,font:""})}withTextFontWeight(e){return this.extend({fontWeight:e,font:""})}withTextFontShape(e){return this.extend({fontShape:e,font:""})}sizingClasses(e){return e.size!==this.size?["sizing","reset-size"+e.size,"size"+this.size]:[]}baseSizingClasses(){return this.size!==jt.BASESIZE?["sizing","reset-size"+this.size,"size"+jt.BASESIZE]:[]}fontMetrics(){return this._fontMetrics||(this._fontMetrics=function(e){let t;if(t=e>=5?0:e>=3?1:2,!te[t]){const e=te[t]={cssEmPerMu:J.quad[t]/18};for(const r in J)J.hasOwnProperty(r)&&(e[r]=J[r][t])}return te[t]}(this.size)),this._fontMetrics}getColor(){return this.phantom?"transparent":this.color}}jt.BASESIZE=6;var Wt=jt;const _t=function(e){return new Wt({style:e.displayMode?S.DISPLAY:S.TEXT,maxSize:e.maxSize,minRuleThickness:e.minRuleThickness})},$t=function(e,t){if(t.displayMode){const r=["katex-display"];t.leqno&&r.push("leqno"),t.fleqn&&r.push("fleqn"),e=je(r,[e])}return e},Zt=function(e,t,r){const n=_t(r);let o;if("mathml"===r.output)return Gt(e,t,n,r.displayMode,!0);if("html"===r.output){const t=Tt(e,n);o=je(["katex"],[t])}else{const s=Gt(e,t,n,r.displayMode,!1),i=Tt(e,n);o=je(["katex"],[s,i])}return $t(o,r)};const Kt={widehat:"^",widecheck:"\u02c7",widetilde:"~",utilde:"~",overleftarrow:"\u2190",underleftarrow:"\u2190",xleftarrow:"\u2190",overrightarrow:"\u2192",underrightarrow:"\u2192",xrightarrow:"\u2192",underbrace:"\u23df",overbrace:"\u23de",underbracket:"\u23b5",overbracket:"\u23b4",overgroup:"\u23e0",undergroup:"\u23e1",overleftrightarrow:"\u2194",underleftrightarrow:"\u2194",xleftrightarrow:"\u2194",Overrightarrow:"\u21d2",xRightarrow:"\u21d2",overleftharpoon:"\u21bc",xleftharpoonup:"\u21bc",overrightharpoon:"\u21c0",xrightharpoonup:"\u21c0",xLeftarrow:"\u21d0",xLeftrightarrow:"\u21d4",xhookleftarrow:"\u21a9",xhookrightarrow:"\u21aa",xmapsto:"\u21a6",xrightharpoondown:"\u21c1",xleftharpoondown:"\u21bd",xrightleftharpoons:"\u21cc",xleftrightharpoons:"\u21cb",xtwoheadleftarrow:"\u219e",xtwoheadrightarrow:"\u21a0",xlongequal:"=",xtofrom:"\u21c4",xrightleftarrows:"\u21c4",xrightequilibrium:"\u21cc",xleftequilibrium:"\u21cb","\\cdrightarrow":"\u2192","\\cdleftarrow":"\u2190","\\cdlongequal":"="},Jt=function(e){const t=new Bt("mo",[new qt(Kt[e.replace(/^\\/,"")])]);return t.setAttribute("stretchy","true"),t},Qt={overrightarrow:[["rightarrow"],.888,522,"xMaxYMin"],overleftarrow:[["leftarrow"],.888,522,"xMinYMin"],underrightarrow:[["rightarrow"],.888,522,"xMaxYMin"],underleftarrow:[["leftarrow"],.888,522,"xMinYMin"],xrightarrow:[["rightarrow"],1.469,522,"xMaxYMin"],"\\cdrightarrow":[["rightarrow"],3,522,"xMaxYMin"],xleftarrow:[["leftarrow"],1.469,522,"xMinYMin"],"\\cdleftarrow":[["leftarrow"],3,522,"xMinYMin"],Overrightarrow:[["doublerightarrow"],.888,560,"xMaxYMin"],xRightarrow:[["doublerightarrow"],1.526,560,"xMaxYMin"],xLeftarrow:[["doubleleftarrow"],1.526,560,"xMinYMin"],overleftharpoon:[["leftharpoon"],.888,522,"xMinYMin"],xleftharpoonup:[["leftharpoon"],.888,522,"xMinYMin"],xleftharpoondown:[["leftharpoondown"],.888,522,"xMinYMin"],overrightharpoon:[["rightharpoon"],.888,522,"xMaxYMin"],xrightharpoonup:[["rightharpoon"],.888,522,"xMaxYMin"],xrightharpoondown:[["rightharpoondown"],.888,522,"xMaxYMin"],xlongequal:[["longequal"],.888,334,"xMinYMin"],"\\cdlongequal":[["longequal"],3,334,"xMinYMin"],xtwoheadleftarrow:[["twoheadleftarrow"],.888,334,"xMinYMin"],xtwoheadrightarrow:[["twoheadrightarrow"],.888,334,"xMaxYMin"],overleftrightarrow:[["leftarrow","rightarrow"],.888,522],overbrace:[["leftbrace","midbrace","rightbrace"],1.6,548],underbrace:[["leftbraceunder","midbraceunder","rightbraceunder"],1.6,548],underleftrightarrow:[["leftarrow","rightarrow"],.888,522],xleftrightarrow:[["leftarrow","rightarrow"],1.75,522],xLeftrightarrow:[["doubleleftarrow","doublerightarrow"],1.75,560],xrightleftharpoons:[["leftharpoondownplus","rightharpoonplus"],1.75,716],xleftrightharpoons:[["leftharpoonplus","rightharpoondownplus"],1.75,716],xhookleftarrow:[["leftarrow","righthook"],1.08,522],xhookrightarrow:[["lefthook","rightarrow"],1.08,522],overlinesegment:[["leftlinesegment","rightlinesegment"],.888,522],underlinesegment:[["leftlinesegment","rightlinesegment"],.888,522],overbracket:[["leftbracketover","rightbracketover"],1.6,440],underbracket:[["leftbracketunder","rightbracketunder"],1.6,410],overgroup:[["leftgroup","rightgroup"],.888,342],undergroup:[["leftgroupunder","rightgroupunder"],.888,342],xmapsto:[["leftmapsto","rightarrow"],1.5,522],xtofrom:[["leftToFrom","rightToFrom"],1.75,528],xrightleftarrows:[["baraboveleftarrow","rightarrowabovebar"],1.75,901],xrightequilibrium:[["baraboveshortleftharpoon","rightharpoonaboveshortbar"],1.75,716],xleftequilibrium:[["shortbaraboveleftharpoon","shortrightharpoonabovebar"],1.75,716]},er=new Set(["widehat","widecheck","widetilde","utilde"]),tr=function(e,t){const{span:r,minWidth:n,height:o}=function(){let r=4e5;const n=e.label.slice(1);if(er.has(n)&&"base"in e){const o="ordgroup"===e.base.type?e.base.body.length:1;let s,i,l;if(o>5)"widehat"===n||"widecheck"===n?(s=420,r=2364,l=.42,i=n+"4"):(s=312,r=2340,l=.34,i="tilde4");else{const e=[1,1,2,2,3,3][o];"widehat"===n||"widecheck"===n?(r=[0,1062,2364,2364,2364][e],s=[0,239,300,360,420][e],l=[0,.24,.3,.3,.36,.42][e],i=n+e):(r=[0,600,1033,2339,2340][e],s=[0,260,286,306,312][e],l=[0,.26,.286,.3,.306,.34][e],i="tilde"+e)}const a=new $(i),c=new _([a],{width:"100%",height:O(l),viewBox:"0 0 "+r+" "+s,preserveAspectRatio:"none"});return{span:We([],[c],t),minWidth:0,height:l}}{const e=[],o=Qt[n];if(!o)throw new Error('No SVG data for "'+n+'".');const[s,i,l]=o,a=l/1e3,c=s.length;let h,m;if(1===c){if(4!==o.length)throw new Error('Expected 4-tuple for single-path SVG data "'+n+'".');h=["hide-tail"],m=[o[3]]}else if(2===c)h=["halfarrow-left","halfarrow-right"],m=["xMinYMin","xMaxYMin"];else{if(3!==c)throw new Error("Correct katexImagesData or update code here to support\n "+c+" children.");h=["brace-left","brace-center","brace-right"],m=["xMinYMin","xMidYMin","xMaxYMin"]}for(let n=0;n0&&(r.style.minWidth=O(n)),r},rr={bin:1,close:1,inner:1,open:1,punct:1,rel:1},nr={"accent-token":1,mathord:1,"op-token":1,spacing:1,textord:1};function or(e,t){if(!e||e.type!==t)throw new Error("Expected node of type "+t+", but got "+(e?"node of type "+e.type:String(e)));return e}function sr(e){const t=ir(e);if(!t)throw new Error("Expected node of symbol group type, but got "+(e?"node of type "+e.type:String(e)));return t}function ir(e){return e&&("atom"===e.type||nr.hasOwnProperty(e.type))?e:null}const lr=e=>{return e instanceof W?e:((t=e)instanceof U||t instanceof X||t instanceof I)&&1===e.children.length?lr(e.children[0]):void 0;var t},ar=(e,t)=>{let r,n,o;e&&"supsub"===e.type?(n=or(e.base,"accent"),r=n.base,e.base=r,o=function(e){if(e instanceof U)return e;throw new Error("Expected span but got "+String(e)+".")}(Mt(e,t)),e.base=n):(n=or(e,"accent"),r=n.base);const s=Mt(r,t.havingCrampedStyle());let i=0;var l,a;n.isShifty&&m(r)&&(i=null!=(l=null==(a=lr(s))?void 0:a.skew)?l:0);const c="\\c"===n.label;let h,u=c?s.height+s.depth:Math.min(s.height,t.fontMetrics().xHeight);if(n.isStretchy)h=tr(n,t),h=Ke({positionType:"firstBaseline",children:[{type:"elem",elem:s},{type:"elem",elem:h,wrapperClasses:["svg-align"],wrapperStyle:i>0?{width:"calc(100% - "+O(2*i)+")",marginLeft:O(2*i)}:void 0}]});else{let e,r;"\\vec"===n.label?(e=rt("vec",t),r=tt.vec[1]):(e=Ge({type:"textord",mode:n.mode,text:n.label},t),e=function(e){if(e instanceof W)return e;throw new Error("Expected symbolNode but got "+String(e)+".")}(e),e.italic=0,r=e.width,c&&(u+=e.depth)),h=je(["accent-body"],[e]);const o="\\textcircled"===n.label;o&&(h.classes.push("accent-full"),u=s.height);let l=i;o||(l-=r/2),h.style.left=O(l),"\\textcircled"===n.label&&(h.style.top=".2em"),h=Ke({positionType:"firstBaseline",children:[{type:"elem",elem:s},{type:"kern",size:-u},{type:"elem",elem:h}]})}const p=je(["mord","accent"],[h],t);return o?(o.children[0]=p,o.height=Math.max(p.height,o.height),o.classes[0]="mord",o):p},cr=new RegExp(["\\acute","\\grave","\\ddot","\\tilde","\\bar","\\breve","\\check","\\hat","\\vec","\\dot","\\mathring"].map(e=>"\\"+e).join("|"));mt({type:"accent",names:["\\acute","\\grave","\\ddot","\\tilde","\\bar","\\breve","\\check","\\hat","\\vec","\\dot","\\mathring","\\widecheck","\\widehat","\\widetilde","\\overrightarrow","\\overleftarrow","\\Overrightarrow","\\overleftrightarrow","\\overgroup","\\overlinesegment","\\overleftharpoon","\\overrightharpoon"],numArgs:1,handler:(e,t)=>{const r=pt(t[0]),n=!cr.test(e.funcName),o=!n||"\\widehat"===e.funcName||"\\widetilde"===e.funcName||"\\widecheck"===e.funcName;return{type:"accent",mode:e.parser.mode,label:e.funcName,isStretchy:n,isShifty:o,base:r}},htmlBuilder:ar,mathmlBuilder:(e,t)=>{const r=e.isStretchy?Jt(e.label):new Bt("mo",[Et(e.label,e.mode)]),n=new Bt("mover",[Vt(e.base,t),r]);return n.setAttribute("accent","true"),n}}),mt({type:"accent",names:["\\'","\\`","\\^","\\~","\\=","\\u","\\.",'\\"',"\\c","\\r","\\H","\\v","\\textcircled"],numArgs:1,allowedInText:!0,allowedInMath:!0,argTypes:["primitive"],handler:(e,t)=>{const r=t[0];let n=e.parser.mode;return"math"===n&&(e.parser.settings.reportNonstrict("mathVsTextAccents","LaTeX's accent "+e.funcName+" works only in text mode"),n="text"),{type:"accent",mode:n,label:e.funcName,isStretchy:!1,isShifty:!0,base:r}}}),mt({type:"accentUnder",names:["\\underleftarrow","\\underrightarrow","\\underleftrightarrow","\\undergroup","\\underlinesegment","\\utilde"],numArgs:1,handler:(e,t)=>{let{parser:r,funcName:n}=e;const o=t[0];return{type:"accentUnder",mode:r.mode,label:n,base:o}},htmlBuilder:(e,t)=>{const r=Mt(e.base,t),n=tr(e,t),o="\\utilde"===e.label?.12:0,s=Ke({positionType:"top",positionData:r.height,children:[{type:"elem",elem:n,wrapperClasses:["svg-align"]},{type:"kern",size:o},{type:"elem",elem:r}]});return je(["mord","accentunder"],[s],t)},mathmlBuilder:(e,t)=>{const r=Jt(e.label),n=new Bt("munder",[Vt(e.base,t),r]);return n.setAttribute("accentunder","true"),n}});const hr=e=>{const t=new Bt("mpadded",e?[e]:[]);return t.setAttribute("width","+0.6em"),t.setAttribute("lspace","0.3em"),t};mt({type:"xArrow",names:["\\xleftarrow","\\xrightarrow","\\xLeftarrow","\\xRightarrow","\\xleftrightarrow","\\xLeftrightarrow","\\xhookleftarrow","\\xhookrightarrow","\\xmapsto","\\xrightharpoondown","\\xrightharpoonup","\\xleftharpoondown","\\xleftharpoonup","\\xrightleftharpoons","\\xleftrightharpoons","\\xlongequal","\\xtwoheadrightarrow","\\xtwoheadleftarrow","\\xtofrom","\\xrightleftarrows","\\xrightequilibrium","\\xleftequilibrium","\\\\cdrightarrow","\\\\cdleftarrow","\\\\cdlongequal"],numArgs:1,numOptionalArgs:1,handler(e,t,r){let{parser:n,funcName:o}=e;return{type:"xArrow",mode:n.mode,label:o,body:t[0],below:r[0]}},htmlBuilder(e,t){const r=t.style;let n=t.havingStyle(r.sup());const o=Ze(Mt(e.body,n,t),t),s="\\x"===e.label.slice(0,2)?"x":"cd";let i;o.classes.push(s+"-arrow-pad"),e.below&&(n=t.havingStyle(r.sub()),i=Ze(Mt(e.below,n,t),t),i.classes.push(s+"-arrow-pad"));const l=tr(e,t),a=-t.fontMetrics().axisHeight+.5*l.height;let c,h=-t.fontMetrics().axisHeight-.5*l.height-.111;if((o.depth>.25||"\\xleftequilibrium"===e.label)&&(h-=o.depth),i){const e=-t.fontMetrics().axisHeight+i.height+.5*l.height+.111;c=Ke({positionType:"individualShift",children:[{type:"elem",elem:o,shift:h},{type:"elem",elem:l,shift:a,wrapperClasses:["svg-align"]},{type:"elem",elem:i,shift:e}]})}else c=Ke({positionType:"individualShift",children:[{type:"elem",elem:o,shift:h},{type:"elem",elem:l,shift:a,wrapperClasses:["svg-align"]}]});return je(["mrel","x-arrow"],[c],t)},mathmlBuilder(e,t){const r=Jt(e.label);let n;if(r.setAttribute("minsize","x"===e.label.charAt(0)?"1.75em":"3.0em"),e.body){const o=hr(Vt(e.body,t));if(e.below){const s=hr(Vt(e.below,t));n=new Bt("munderover",[r,s,o])}else n=new Bt("mover",[r,o])}else if(e.below){const o=hr(Vt(e.below,t));n=new Bt("munder",[r,o])}else n=hr(),n=new Bt("mover",[r,n]);return n}}),mt({type:"mclass",names:["\\mathord","\\mathbin","\\mathrel","\\mathopen","\\mathclose","\\mathpunct","\\mathinner"],numArgs:1,primitive:!0,handler(e,t){let{parser:r,funcName:n}=e;const o=t[0];return{type:"mclass",mode:r.mode,mclass:"m"+n.slice(5),body:dt(o),isCharacterBox:m(o)}},htmlBuilder:function(e,t){const r=xt(e.body,t,!0);return je([e.mclass],r,t)},mathmlBuilder:function(e,t){let r;const n=Pt(e.body,t);return"minner"===e.mclass?r=new Bt("mpadded",n):"mord"===e.mclass?e.isCharacterBox?(r=n[0],r.type="mi"):r=new Bt("mi",n):(e.isCharacterBox?(r=n[0],r.type="mo"):r=new Bt("mo",n),"mbin"===e.mclass?(r.attributes.lspace="0.22em",r.attributes.rspace="0.22em"):"mpunct"===e.mclass?(r.attributes.lspace="0em",r.attributes.rspace="0.17em"):"mopen"!==e.mclass&&"mclose"!==e.mclass||(r.attributes.lspace="0em",r.attributes.rspace="0em")),r}});const mr=e=>{const t="ordgroup"===e.type&&e.body.length?e.body[0]:e;return"atom"!==t.type||"bin"!==t.family&&"rel"!==t.family?"mord":"m"+t.family};mt({type:"mclass",names:["\\@binrel"],numArgs:2,handler(e,t){let{parser:r}=e;return{type:"mclass",mode:r.mode,mclass:mr(t[0]),body:dt(t[1]),isCharacterBox:m(t[1])}}}),mt({type:"mclass",names:["\\stackrel","\\overset","\\underset"],numArgs:2,handler(e,t){let{parser:r,funcName:n}=e;const o=t[1],s=t[0];let i;i="\\stackrel"!==n?mr(o):"mrel";const l={type:"op",mode:o.mode,limits:!0,alwaysHandleSupSub:!0,parentIsSupSub:!1,symbol:!1,suppressBaseShift:"\\stackrel"!==n,body:dt(o)},a="\\underset"===n?{type:"supsub",mode:s.mode,base:l,sub:s}:{type:"supsub",mode:s.mode,base:l,sup:s};return{type:"mclass",mode:r.mode,mclass:i,body:[a],isCharacterBox:m(a)}}}),mt({type:"pmb",names:["\\pmb"],numArgs:1,allowedInText:!0,handler(e,t){let{parser:r}=e;return{type:"pmb",mode:r.mode,mclass:mr(t[0]),body:dt(t[0])}},htmlBuilder(e,t){const r=xt(e.body,t,!0),n=je([e.mclass],r,t);return n.style.textShadow="0.02em 0.01em 0.04px",n},mathmlBuilder(e,t){const r=Pt(e.body,t),n=new Bt("mstyle",r);return n.setAttribute("style","text-shadow: 0.02em 0.01em 0.04px"),n}});const ur={">":"\\\\cdrightarrow","<":"\\\\cdleftarrow","=":"\\\\cdlongequal",A:"\\uparrow",V:"\\downarrow","|":"\\Vert",".":"no arrow"},pr=()=>({type:"styling",body:[],mode:"math",style:"display",resetFont:!0}),dr=e=>"textord"===e.type&&"@"===e.text,gr=(e,t)=>("mathord"===e.type||"atom"===e.type)&&e.text===t;function fr(e,t,r){const n=ur[e];switch(n){case"\\\\cdrightarrow":case"\\\\cdleftarrow":return r.callFunction(n,[t[0]],[t[1]]);case"\\uparrow":case"\\downarrow":{const e={type:"atom",text:n,mode:"math",family:"rel"},o={type:"ordgroup",mode:"math",body:[r.callFunction("\\\\cdleft",[t[0]],[]),r.callFunction("\\Big",[e],[]),r.callFunction("\\\\cdright",[t[1]],[])]};return r.callFunction("\\\\cdparent",[o],[])}case"\\\\cdlongequal":return r.callFunction("\\\\cdlongequal",[],[]);case"\\Vert":{const e={type:"textord",text:"\\Vert",mode:"math"};return r.callFunction("\\Big",[e],[])}default:return{type:"textord",text:" ",mode:"math"}}}mt({type:"cdlabel",names:["\\\\cdleft","\\\\cdright"],numArgs:1,handler(e,t){let{parser:r,funcName:n}=e;return{type:"cdlabel",mode:r.mode,side:n.slice(4),label:t[0]}},htmlBuilder(e,t){const r=t.havingStyle(t.style.sup()),n=Ze(Mt(e.label,r,t),t);return n.classes.push("cd-label-"+e.side),n.style.bottom=O(.8-n.depth),n.height=0,n.depth=0,n},mathmlBuilder(e,t){let r=new Bt("mrow",[Vt(e.label,t)]);return r=new Bt("mpadded",[r]),r.setAttribute("width","0"),"left"===e.side&&r.setAttribute("lspace","-1width"),r.setAttribute("voffset","0.7em"),r=new Bt("mstyle",[r]),r.setAttribute("displaystyle","false"),r.setAttribute("scriptlevel","1"),r}}),mt({type:"cdlabelparent",names:["\\\\cdparent"],numArgs:1,handler(e,t){let{parser:r}=e;return{type:"cdlabelparent",mode:r.mode,fragment:t[0]}},htmlBuilder(e,t){const r=Ze(Mt(e.fragment,t),t);return r.classes.push("cd-vert-arrow"),r},mathmlBuilder(e,t){return new Bt("mrow",[Vt(e.fragment,t)])}}),mt({type:"textord",names:["\\@char"],numArgs:1,allowedInText:!0,handler(e,t){let{parser:r}=e;const o=or(t[0],"ordgroup").body;let s="";for(let e=0;e=1114111)throw new n("\\@char with invalid code point "+s);return l<=65535?i=String.fromCharCode(l):(l-=65536,i=String.fromCharCode(55296+(l>>10),56320+(1023&l))),{type:"textord",mode:r.mode,text:i}}});mt({type:"color",names:["\\textcolor"],numArgs:2,allowedInText:!0,argTypes:["color","original"],handler(e,t){let{parser:r}=e;const n=or(t[0],"color-token").color,o=t[1];return{type:"color",mode:r.mode,color:n,body:dt(o)}},htmlBuilder:(e,t)=>{const r=xt(e.body,t.withColor(e.color),!1);return $e(r)},mathmlBuilder:(e,t)=>{const r=Pt(e.body,t.withColor(e.color)),n=new Bt("mstyle",r);return n.setAttribute("mathcolor",e.color),n}}),mt({type:"color",names:["\\color"],numArgs:1,allowedInText:!0,argTypes:["color"],handler(e,t){let{parser:r,breakOnTokenText:n}=e;const o=or(t[0],"color-token").color;r.gullet.macros.set("\\current@color",o);const s=r.parseExpression(!0,n);return{type:"color",mode:r.mode,color:o,body:s}}}),mt({type:"cr",names:["\\\\"],numArgs:0,numOptionalArgs:0,allowedInText:!0,handler(e,t,r){let{parser:n}=e;const o="["===n.gullet.future().text?n.parseSizeGroup(!0):null,s=!n.settings.displayMode||!n.settings.useStrictBehavior("newLineInDisplayMode","In LaTeX, \\\\ or \\newline does nothing in display mode");return{type:"cr",mode:n.mode,newLine:s,size:o&&or(o,"size").value}},htmlBuilder(e,t){const r=je(["mspace"],[],t);return e.newLine&&(r.classes.push("newline"),e.size&&(r.style.marginTop=O(N(e.size,t)))),r},mathmlBuilder(e,t){const r=new Bt("mspace");return e.newLine&&(r.setAttribute("linebreak","newline"),e.size&&r.setAttribute("height",O(N(e.size,t)))),r}});const br={"\\global":"\\global","\\long":"\\\\globallong","\\\\globallong":"\\\\globallong","\\def":"\\gdef","\\gdef":"\\gdef","\\edef":"\\xdef","\\xdef":"\\xdef","\\let":"\\\\globallet","\\futurelet":"\\\\globalfuture"},yr=e=>{const t=e.text;if(/^(?:[\\{}$&#^_]|EOF)$/.test(t))throw new n("Expected a control sequence",e);return t},xr=(e,t,r,n)=>{let o=e.gullet.macros.get(r.text);null==o&&(r.noexpand=!0,o={tokens:[r],numArgs:0,unexpandable:!e.gullet.isExpandable(r.text)}),e.gullet.macros.set(t,o,n)};mt({type:"internal",names:["\\global","\\long","\\\\globallong"],numArgs:0,allowedInText:!0,handler(e){let{parser:t,funcName:r}=e;t.consumeSpaces();const o=t.fetch();if(br[o.text])return"\\global"!==r&&"\\\\globallong"!==r||(o.text=br[o.text]),or(t.parseFunction(),"internal");throw new n("Invalid token after macro prefix",o)}}),mt({type:"internal",names:["\\def","\\gdef","\\edef","\\xdef"],numArgs:0,allowedInText:!0,primitive:!0,handler(e){let{parser:t,funcName:r}=e,o=t.gullet.popToken();const s=o.text;if(/^(?:[\\{}$&#^_]|EOF)$/.test(s))throw new n("Expected a control sequence",o);let i,l=0;const a=[[]];for(;"{"!==t.gullet.future().text;)if(o=t.gullet.popToken(),"#"===o.text){if("{"===t.gullet.future().text){i=t.gullet.future(),a[l].push("{");break}if(o=t.gullet.popToken(),!/^[1-9]$/.test(o.text))throw new n('Invalid argument number "'+o.text+'"');if(parseInt(o.text)!==l+1)throw new n('Argument number "'+o.text+'" out of order');l++,a.push([])}else{if("EOF"===o.text)throw new n("Expected a macro definition");a[l].push(o.text)}let{tokens:c}=t.gullet.consumeArg();return i&&c.unshift(i),"\\edef"!==r&&"\\xdef"!==r||(c=t.gullet.expandTokens(c),c.reverse()),t.gullet.macros.set(s,{tokens:c,numArgs:l,delimiters:a},r===br[r]),{type:"internal",mode:t.mode}}}),mt({type:"internal",names:["\\let","\\\\globallet"],numArgs:0,allowedInText:!0,primitive:!0,handler(e){let{parser:t,funcName:r}=e;const n=yr(t.gullet.popToken());t.gullet.consumeSpaces();const o=(e=>{let t=e.gullet.popToken();return"="===t.text&&(t=e.gullet.popToken()," "===t.text&&(t=e.gullet.popToken())),t})(t);return xr(t,n,o,"\\\\globallet"===r),{type:"internal",mode:t.mode}}}),mt({type:"internal",names:["\\futurelet","\\\\globalfuture"],numArgs:0,allowedInText:!0,primitive:!0,handler(e){let{parser:t,funcName:r}=e;const n=yr(t.gullet.popToken()),o=t.gullet.popToken(),s=t.gullet.popToken();return xr(t,n,s,"\\\\globalfuture"===r),t.gullet.pushToken(s),t.gullet.pushToken(o),{type:"internal",mode:t.mode}}});const wr=function(e,t,r){const n=ee(ne.math[e]&&ne.math[e].replace||e,t,r);if(!n)throw new Error("Unsupported symbol "+e+" and font size "+t+".");return n},vr=function(e,t,r,n){const o=r.havingBaseStyle(t),s=je(n.concat(o.sizingClasses(r)),[e],r),i=o.sizeMultiplier/r.sizeMultiplier;return s.height*=i,s.depth*=i,s.maxFontSize=o.sizeMultiplier,s},kr=function(e,t,r){const n=t.havingBaseStyle(r),o=(1-t.sizeMultiplier/n.sizeMultiplier)*t.fontMetrics().axisHeight;e.classes.push("delimcenter"),e.style.top=O(o),e.height-=o,e.depth+=o},zr=function(e,t,r,n,o,s){const i=function(e,t,r,n){return Fe(e,"Size"+t+"-Regular",r,n)}(e,t,o,n),l=vr(je(["delimsizing","size"+t],[i],n),S.TEXT,n,s);return r&&kr(l,n,S.TEXT),l},Sr=function(e,t,r){let n;n="Size1-Regular"===t?"delim-size1":"delim-size4";return{type:"elem",elem:je(["delimsizinginner",n],[je([],[Fe(e,t,r)])])}},Mr=function(e,t,r){const n=K["Size4-Regular"][e.charCodeAt(0)]?K["Size4-Regular"][e.charCodeAt(0)][4]:K["Size1-Regular"][e.charCodeAt(0)][4],o=new $("inner",function(e,t){switch(e){case"\u239c":return C("M291 0 H417 V"+t+" H291z");case"\u2223":return C("M145 0 H188 V"+t+" H145z");case"\u2225":return C("M145 0 H188 V"+t+" H145z")+C("M367 0 H410 V"+t+" H367z");case"\u239f":return C("M457 0 H583 V"+t+" H457z");case"\u23a2":return C("M319 0 H403 V"+t+" H319z");case"\u23a5":return C("M263 0 H347 V"+t+" H263z");case"\u23aa":return C("M384 0 H504 V"+t+" H384z");case"\u23d0":return C("M312 0 H355 V"+t+" H312z");case"\u2016":return C("M257 0 H300 V"+t+" H257z")+C("M478 0 H521 V"+t+" H478z");default:return""}}(e,Math.round(1e3*t))),s=new _([o],{width:O(n),height:O(t),style:"width:"+O(n),viewBox:"0 0 "+1e3*n+" "+Math.round(1e3*t),preserveAspectRatio:"xMinYMin"}),i=We([],[s],r);return i.height=t,i.style.height=O(t),i.style.width=O(n),{type:"elem",elem:i}},Ar={type:"kern",size:-.008},Tr=new Set(["|","\\lvert","\\rvert","\\vert"]),Cr=new Set(["\\|","\\lVert","\\rVert","\\Vert"]),Br=function(e,t,r,n,o,s){let i,l,a,c,h="",m=0;i=a=c=e,l=null;let u="Size1-Regular";"\\uparrow"===e?a=c="\u23d0":"\\Uparrow"===e?a=c="\u2016":"\\downarrow"===e?i=a="\u23d0":"\\Downarrow"===e?i=a="\u2016":"\\updownarrow"===e?(i="\\uparrow",a="\u23d0",c="\\downarrow"):"\\Updownarrow"===e?(i="\\Uparrow",a="\u2016",c="\\Downarrow"):Tr.has(e)?(a="\u2223",h="vert",m=333):Cr.has(e)?(a="\u2225",h="doublevert",m=556):"["===e||"\\lbrack"===e?(i="\u23a1",a="\u23a2",c="\u23a3",u="Size4-Regular",h="lbrack",m=667):"]"===e||"\\rbrack"===e?(i="\u23a4",a="\u23a5",c="\u23a6",u="Size4-Regular",h="rbrack",m=667):"\\lfloor"===e||"\u230a"===e?(a=i="\u23a2",c="\u23a3",u="Size4-Regular",h="lfloor",m=667):"\\lceil"===e||"\u2308"===e?(i="\u23a1",a=c="\u23a2",u="Size4-Regular",h="lceil",m=667):"\\rfloor"===e||"\u230b"===e?(a=i="\u23a5",c="\u23a6",u="Size4-Regular",h="rfloor",m=667):"\\rceil"===e||"\u2309"===e?(i="\u23a4",a=c="\u23a5",u="Size4-Regular",h="rceil",m=667):"("===e||"\\lparen"===e?(i="\u239b",a="\u239c",c="\u239d",u="Size4-Regular",h="lparen",m=875):")"===e||"\\rparen"===e?(i="\u239e",a="\u239f",c="\u23a0",u="Size4-Regular",h="rparen",m=875):"\\{"===e||"\\lbrace"===e?(i="\u23a7",l="\u23a8",c="\u23a9",a="\u23aa",u="Size4-Regular"):"\\}"===e||"\\rbrace"===e?(i="\u23ab",l="\u23ac",c="\u23ad",a="\u23aa",u="Size4-Regular"):"\\lgroup"===e||"\u27ee"===e?(i="\u23a7",c="\u23a9",a="\u23aa",u="Size4-Regular"):"\\rgroup"===e||"\u27ef"===e?(i="\u23ab",c="\u23ad",a="\u23aa",u="Size4-Regular"):"\\lmoustache"===e||"\u23b0"===e?(i="\u23a7",c="\u23ad",a="\u23aa",u="Size4-Regular"):"\\rmoustache"!==e&&"\u23b1"!==e||(i="\u23ab",c="\u23a9",a="\u23aa",u="Size4-Regular");const p=wr(i,u,o),d=p.height+p.depth,g=wr(a,u,o),f=g.height+g.depth,b=wr(c,u,o),y=b.height+b.depth;let x=0,w=1;if(null!==l){const e=wr(l,u,o);x=e.height+e.depth,w=2}const v=d+y+x,k=v+Math.max(0,Math.ceil((t-v)/(w*f)))*w*f;let z=n.fontMetrics().axisHeight;r&&(z*=n.sizeMultiplier);const M=k/2-z,A=[];if(h.length>0){const e=k-d-y,t=Math.round(1e3*k),r=function(e,t){switch(e){case"lbrack":return"M403 1759 V84 H666 V0 H319 V1759 v"+t+" v1759 v84 h347 v-84\nH403z M403 1759 V0 H319 V1759 v"+t+" v1759 v84 h84z";case"rbrack":return"M347 1759 V0 H0 V84 H263 V1759 v"+t+" v1759 H0 v84 H347z\nM347 1759 V0 H263 V1759 v"+t+" v1759 h84z";case"vert":return"M145 15 v585 v"+t+" v585 c2.667,10,9.667,15,21,15\nc10,0,16.667,-5,20,-15 v-585 v"+-t+" v-585 c-2.667,-10,-9.667,-15,-21,-15\nc-10,0,-16.667,5,-20,15z M188 15 H145 v585 v"+t+" v585 h43z";case"doublevert":return"M145 15 v585 v"+t+" v585 c2.667,10,9.667,15,21,15\nc10,0,16.667,-5,20,-15 v-585 v"+-t+" v-585 c-2.667,-10,-9.667,-15,-21,-15\nc-10,0,-16.667,5,-20,15z M188 15 H145 v585 v"+t+" v585 h43z\nM367 15 v585 v"+t+" v585 c2.667,10,9.667,15,21,15\nc10,0,16.667,-5,20,-15 v-585 v"+-t+" v-585 c-2.667,-10,-9.667,-15,-21,-15\nc-10,0,-16.667,5,-20,15z M410 15 H367 v585 v"+t+" v585 h43z";case"lfloor":return"M319 602 V0 H403 V602 v"+t+" v1715 h263 v84 H319z\nMM319 602 V0 H403 V602 v"+t+" v1715 H319z";case"rfloor":return"M319 602 V0 H403 V602 v"+t+" v1799 H0 v-84 H319z\nMM319 602 V0 H403 V602 v"+t+" v1715 H319z";case"lceil":return"M403 1759 V84 H666 V0 H319 V1759 v"+t+" v602 h84z\nM403 1759 V0 H319 V1759 v"+t+" v602 h84z";case"rceil":return"M347 1759 V0 H0 V84 H263 V1759 v"+t+" v602 h84z\nM347 1759 V0 h-84 V1759 v"+t+" v602 h84z";case"lparen":return"M863,9c0,-2,-2,-5,-6,-9c0,0,-17,0,-17,0c-12.7,0,-19.3,0.3,-20,1\nc-5.3,5.3,-10.3,11,-15,17c-242.7,294.7,-395.3,682,-458,1162c-21.3,163.3,-33.3,349,\n-36,557 l0,"+(t+84)+"c0.2,6,0,26,0,60c2,159.3,10,310.7,24,454c53.3,528,210,\n949.7,470,1265c4.7,6,9.7,11.7,15,17c0.7,0.7,7,1,19,1c0,0,18,0,18,0c4,-4,6,-7,6,-9\nc0,-2.7,-3.3,-8.7,-10,-18c-135.3,-192.7,-235.5,-414.3,-300.5,-665c-65,-250.7,-102.5,\n-544.7,-112.5,-882c-2,-104,-3,-167,-3,-189\nl0,-"+(t+92)+"c0,-162.7,5.7,-314,17,-454c20.7,-272,63.7,-513,129,-723c65.3,\n-210,155.3,-396.3,270,-559c6.7,-9.3,10,-15.3,10,-18z";case"rparen":return"M76,0c-16.7,0,-25,3,-25,9c0,2,2,6.3,6,13c21.3,28.7,42.3,60.3,\n63,95c96.7,156.7,172.8,332.5,228.5,527.5c55.7,195,92.8,416.5,111.5,664.5\nc11.3,139.3,17,290.7,17,454c0,28,1.7,43,3.3,45l0,"+(t+9)+"\nc-3,4,-3.3,16.7,-3.3,38c0,162,-5.7,313.7,-17,455c-18.7,248,-55.8,469.3,-111.5,664\nc-55.7,194.7,-131.8,370.3,-228.5,527c-20.7,34.7,-41.7,66.3,-63,95c-2,3.3,-4,7,-6,11\nc0,7.3,5.7,11,17,11c0,0,11,0,11,0c9.3,0,14.3,-0.3,15,-1c5.3,-5.3,10.3,-11,15,-17\nc242.7,-294.7,395.3,-681.7,458,-1161c21.3,-164.7,33.3,-350.7,36,-558\nl0,-"+(t+144)+"c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,\n-470,-1265c-4.7,-6,-9.7,-11.7,-15,-17c-0.7,-0.7,-6.7,-1,-18,-1z";default:throw new Error("Unknown stretchy delimiter.")}}(h,Math.round(1e3*e)),o=new $(h,r),s=O(m/1e3),i=O(t/1e3),l=new _([o],{width:s,height:i,viewBox:"0 0 "+m+" "+t}),a=We([],[l],n);a.height=t/1e3,a.style.width=s,a.style.height=i,A.push({type:"elem",elem:a})}else{if(A.push(Sr(c,u,o)),A.push(Ar),null===l){const e=k-d-y+.016;A.push(Mr(a,e,n))}else{const e=(k-d-y-x)/2+.016;A.push(Mr(a,e,n)),A.push(Ar),A.push(Sr(l,u,o)),A.push(Ar),A.push(Mr(a,e,n))}A.push(Ar),A.push(Sr(i,u,o))}const T=n.havingBaseStyle(S.TEXT),C=Ke({positionType:"bottom",positionData:M,children:A});return vr(je(["delimsizing","mult"],[C],T),S.TEXT,n,s)},qr=.08,Ir=function(e,t,r,n,o){const s=function(e,t,r){t*=1e3;let n="";switch(e){case"sqrtMain":n=function(e,t){return"M95,"+(622+e+t)+"\nc-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14\nc0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54\nc44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10\ns173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429\nc69,-144,104.5,-217.7,106.5,-221\nl"+e/2.075+" -"+e+"\nc5.3,-9.3,12,-14,20,-14\nH400000v"+(40+e)+"H845.2724\ns-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7\nc-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z\nM"+(834+e)+" "+t+"h400000v"+(40+e)+"h-400000z"}(t,B);break;case"sqrtSize1":n=function(e,t){return"M263,"+(601+e+t)+"c0.7,0,18,39.7,52,119\nc34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120\nc340,-704.7,510.7,-1060.3,512,-1067\nl"+e/2.084+" -"+e+"\nc4.7,-7.3,11,-11,19,-11\nH40000v"+(40+e)+"H1012.3\ns-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232\nc-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1\ns-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26\nc-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z\nM"+(1001+e)+" "+t+"h400000v"+(40+e)+"h-400000z"}(t,B);break;case"sqrtSize2":n=function(e,t){return"M983 "+(10+e+t)+"\nl"+e/3.13+" -"+e+"\nc4,-6.7,10,-10,18,-10 H400000v"+(40+e)+"\nH1013.1s-83.4,268,-264.1,840c-180.7,572,-277,876.3,-289,913c-4.7,4.7,-12.7,7,-24,7\ns-12,0,-12,0c-1.3,-3.3,-3.7,-11.7,-7,-25c-35.3,-125.3,-106.7,-373.3,-214,-744\nc-10,12,-21,25,-33,39s-32,39,-32,39c-6,-5.3,-15,-14,-27,-26s25,-30,25,-30\nc26.7,-32.7,52,-63,76,-91s52,-60,52,-60s208,722,208,722\nc56,-175.3,126.3,-397.3,211,-666c84.7,-268.7,153.8,-488.2,207.5,-658.5\nc53.7,-170.3,84.5,-266.8,92.5,-289.5z\nM"+(1001+e)+" "+t+"h400000v"+(40+e)+"h-400000z"}(t,B);break;case"sqrtSize3":n=function(e,t){return"M424,"+(2398+e+t)+"\nc-1.3,-0.7,-38.5,-172,-111.5,-514c-73,-342,-109.8,-513.3,-110.5,-514\nc0,-2,-10.7,14.3,-32,49c-4.7,7.3,-9.8,15.7,-15.5,25c-5.7,9.3,-9.8,16,-12.5,20\ns-5,7,-5,7c-4,-3.3,-8.3,-7.7,-13,-13s-13,-13,-13,-13s76,-122,76,-122s77,-121,77,-121\ns209,968,209,968c0,-2,84.7,-361.7,254,-1079c169.3,-717.3,254.7,-1077.7,256,-1081\nl"+e/4.223+" -"+e+"c4,-6.7,10,-10,18,-10 H400000\nv"+(40+e)+"H1014.6\ns-87.3,378.7,-272.6,1166c-185.3,787.3,-279.3,1182.3,-282,1185\nc-2,6,-10,9,-24,9\nc-8,0,-12,-0.7,-12,-2z M"+(1001+e)+" "+t+"\nh400000v"+(40+e)+"h-400000z"}(t,B);break;case"sqrtSize4":n=function(e,t){return"M473,"+(2713+e+t)+"\nc339.3,-1799.3,509.3,-2700,510,-2702 l"+e/5.298+" -"+e+"\nc3.3,-7.3,9.3,-11,18,-11 H400000v"+(40+e)+"H1017.7\ns-90.5,478,-276.2,1466c-185.7,988,-279.5,1483,-281.5,1485c-2,6,-10,9,-24,9\nc-8,0,-12,-0.7,-12,-2c0,-1.3,-5.3,-32,-16,-92c-50.7,-293.3,-119.7,-693.3,-207,-1200\nc0,-1.3,-5.3,8.7,-16,30c-10.7,21.3,-21.3,42.7,-32,64s-16,33,-16,33s-26,-26,-26,-26\ns76,-153,76,-153s77,-151,77,-151c0.7,0.7,35.7,202,105,604c67.3,400.7,102,602.7,104,\n606zM"+(1001+e)+" "+t+"h400000v"+(40+e)+"H1017.7z"}(t,B);break;case"sqrtTall":n=function(e,t,r){return"M702 "+(e+t)+"H400000"+(40+e)+"\nH742v"+(r-54-t-e)+"l-4 4-4 4c-.667.7 -2 1.5-4 2.5s-4.167 1.833-6.5 2.5-5.5 1-9.5 1\nh-12l-28-84c-16.667-52-96.667 -294.333-240-727l-212 -643 -85 170\nc-4-3.333-8.333-7.667-13 -13l-13-13l77-155 77-156c66 199.333 139 419.667\n219 661 l218 661zM702 "+t+"H400000v"+(40+e)+"H742z"}(t,B,r)}return n}(e,n,r),i=new $(e,s),l=new _([i],{width:"400em",height:O(t),viewBox:"0 0 400000 "+r,preserveAspectRatio:"xMinYMin slice"});return We(["hide-tail"],[l],o)},Rr=new Set(["(","\\lparen",")","\\rparen","[","\\lbrack","]","\\rbrack","\\{","\\lbrace","\\}","\\rbrace","\\lfloor","\\rfloor","\u230a","\u230b","\\lceil","\\rceil","\u2308","\u2309","\\surd"]),Hr=new Set(["\\uparrow","\\downarrow","\\updownarrow","\\Uparrow","\\Downarrow","\\Updownarrow","|","\\|","\\vert","\\Vert","\\lvert","\\rvert","\\lVert","\\rVert","\\lgroup","\\rgroup","\u27ee","\u27ef","\\lmoustache","\\rmoustache","\u23b0","\u23b1"]),Er=new Set(["<",">","\\langle","\\rangle","/","\\backslash","\\lt","\\gt"]),Nr=[0,1.2,1.8,2.4,3],Or=function(e,t,r,o,s){if("<"===e||"\\lt"===e||"\u27e8"===e?e="\\langle":">"!==e&&"\\gt"!==e&&"\u27e9"!==e||(e="\\rangle"),Rr.has(e)||Er.has(e))return zr(e,t,!1,r,o,s);if(Hr.has(e))return Br(e,Nr[t],!1,r,o,s);throw new n("Illegal delimiter: '"+e+"'")},Dr=[{type:"small",style:S.SCRIPTSCRIPT},{type:"small",style:S.SCRIPT},{type:"small",style:S.TEXT},{type:"large",size:1},{type:"large",size:2},{type:"large",size:3},{type:"large",size:4}],Lr=[{type:"small",style:S.SCRIPTSCRIPT},{type:"small",style:S.SCRIPT},{type:"small",style:S.TEXT},{type:"stack"}],Pr=[{type:"small",style:S.SCRIPTSCRIPT},{type:"small",style:S.SCRIPT},{type:"small",style:S.TEXT},{type:"large",size:1},{type:"large",size:2},{type:"large",size:3},{type:"large",size:4},{type:"stack"}],Fr=function(e){if("small"===e.type)return"Main-Regular";if("large"===e.type)return"Size"+e.size+"-Regular";if("stack"===e.type)return"Size4-Regular";{const t=e.type;throw new Error("Add support for delim type '"+t+"' here.")}},Vr=function(e,t,r,n){for(let o=Math.min(2,3-n.style.size);ot)return s}return r[r.length-1]},Gr=function(e,t,r,n,o,s){let i;"<"===e||"\\lt"===e||"\u27e8"===e?e="\\langle":">"!==e&&"\\gt"!==e&&"\u27e9"!==e||(e="\\rangle"),i=Er.has(e)?Dr:Rr.has(e)?Pr:Lr;const l=Vr(e,t,i,n);return"small"===l.type?function(e,t,r,n,o,s){const i=Fe(e,"Main-Regular",o,n),l=vr(i,t,n,s);return r&&kr(l,n,t),l}(e,l.style,r,n,o,s):"large"===l.type?zr(e,l.size,r,n,o,s):Br(e,t,r,n,o,s)},Ur=function(e,t,r,n,o,s){const i=n.fontMetrics().axisHeight*n.sizeMultiplier,l=5/n.fontMetrics().ptPerEm,a=Math.max(t-i,r+i),c=Math.max(a/500*901,2*a-l);return Gr(e,c,!0,n,o,s)},Xr={"\\bigl":{mclass:"mopen",size:1},"\\Bigl":{mclass:"mopen",size:2},"\\biggl":{mclass:"mopen",size:3},"\\Biggl":{mclass:"mopen",size:4},"\\bigr":{mclass:"mclose",size:1},"\\Bigr":{mclass:"mclose",size:2},"\\biggr":{mclass:"mclose",size:3},"\\Biggr":{mclass:"mclose",size:4},"\\bigm":{mclass:"mrel",size:1},"\\Bigm":{mclass:"mrel",size:2},"\\biggm":{mclass:"mrel",size:3},"\\Biggm":{mclass:"mrel",size:4},"\\big":{mclass:"mord",size:1},"\\Big":{mclass:"mord",size:2},"\\bigg":{mclass:"mord",size:3},"\\Bigg":{mclass:"mord",size:4}},Yr=new Set(["(","\\lparen",")","\\rparen","[","\\lbrack","]","\\rbrack","\\{","\\lbrace","\\}","\\rbrace","\\lfloor","\\rfloor","\u230a","\u230b","\\lceil","\\rceil","\u2308","\u2309","<",">","\\langle","\u27e8","\\rangle","\u27e9","\\lt","\\gt","\\lvert","\\rvert","\\lVert","\\rVert","\\lgroup","\\rgroup","\u27ee","\u27ef","\\lmoustache","\\rmoustache","\u23b0","\u23b1","/","\\backslash","|","\\vert","\\|","\\Vert","\\uparrow","\\Uparrow","\\downarrow","\\Downarrow","\\updownarrow","\\Updownarrow","."]);function jr(e){return"isMiddle"in e}function Wr(e,t){const r=ir(e);if(r&&Yr.has(r.text))return r;throw new n(r?"Invalid delimiter '"+r.text+"' after '"+t.funcName+"'":"Invalid delimiter type '"+e.type+"'",e)}function _r(e){if(!e.body)throw new Error("Bug: The leftright ParseNode wasn't fully parsed.")}mt({type:"delimsizing",names:["\\bigl","\\Bigl","\\biggl","\\Biggl","\\bigr","\\Bigr","\\biggr","\\Biggr","\\bigm","\\Bigm","\\biggm","\\Biggm","\\big","\\Big","\\bigg","\\Bigg"],numArgs:1,argTypes:["primitive"],handler:(e,t)=>{const r=Wr(t[0],e);return{type:"delimsizing",mode:e.parser.mode,size:Xr[e.funcName].size,mclass:Xr[e.funcName].mclass,delim:r.text}},htmlBuilder:(e,t)=>"."===e.delim?je([e.mclass]):Or(e.delim,e.size,t,e.mode,[e.mclass]),mathmlBuilder:e=>{const t=[];"."!==e.delim&&t.push(Et(e.delim,e.mode));const r=new Bt("mo",t);"mopen"===e.mclass||"mclose"===e.mclass?r.setAttribute("fence","true"):r.setAttribute("fence","false"),r.setAttribute("stretchy","true");const n=O(Nr[e.size]);return r.setAttribute("minsize",n),r.setAttribute("maxsize",n),r}}),mt({type:"leftright-right",names:["\\right"],numArgs:1,primitive:!0,handler:(e,t)=>{const r=e.parser.gullet.macros.get("\\current@color");if(r&&"string"!=typeof r)throw new n("\\current@color set to non-string in \\right");return{type:"leftright-right",mode:e.parser.mode,delim:Wr(t[0],e).text,color:r}}}),mt({type:"leftright",names:["\\left"],numArgs:1,primitive:!0,handler:(e,t)=>{const r=Wr(t[0],e),n=e.parser;++n.leftrightDepth;const o=n.parseExpression(!1);--n.leftrightDepth,n.expect("\\right",!1);const s=or(n.parseFunction(),"leftright-right");return{type:"leftright",mode:n.mode,body:o,left:r.text,right:s.delim,rightColor:s.color}},htmlBuilder:(e,t)=>{_r(e);const r=xt(e.body,t,!0,["mopen","mclose"]);let n,o,s=0,i=0,l=!1;for(let e=0;e{_r(e);const r=Pt(e.body,t);if("."!==e.left){const t=new Bt("mo",[Et(e.left,e.mode)]);t.setAttribute("fence","true"),r.unshift(t)}if("."!==e.right){const t=new Bt("mo",[Et(e.right,e.mode)]);t.setAttribute("fence","true"),e.rightColor&&t.setAttribute("mathcolor",e.rightColor),r.push(t)}return Nt(r)}}),mt({type:"middle",names:["\\middle"],numArgs:1,primitive:!0,handler:(e,t)=>{const r=Wr(t[0],e);if(!e.parser.leftrightDepth)throw new n("\\middle without preceding \\left",r);return{type:"middle",mode:e.parser.mode,delim:r.text}},htmlBuilder:(e,t)=>{let r;return"."===e.delim?r=St(t,[]):(r=Or(e.delim,1,t,e.mode,[]),r.isMiddle={delim:e.delim,options:t}),r},mathmlBuilder:(e,t)=>{const r="\\vert"===e.delim||"|"===e.delim?Et("|","text"):Et(e.delim,e.mode),n=new Bt("mo",[r]);return n.setAttribute("fence","true"),n.setAttribute("lspace","0.05em"),n.setAttribute("rspace","0.05em"),n}});mt({type:"enclose",names:["\\colorbox"],numArgs:2,allowedInText:!0,argTypes:["color","hbox"],handler(e,t,r){let{parser:n,funcName:o}=e;const s=or(t[0],"color-token").color,i=t[1];return{type:"enclose",mode:n.mode,label:o,backgroundColor:s,body:i}},htmlBuilder:(e,t)=>{const r=Ze(Mt(e.body,t),t),n=e.label.slice(1);let o,s,i=t.sizeMultiplier;const l=m(e.body);if("sout"===n)o=je(["stretchy","sout"]),o.height=t.fontMetrics().defaultRuleThickness/i,s=-.5*t.fontMetrics().xHeight;else if("phase"===n){const e=N({number:.6,unit:"pt"},t),n=N({number:.35,unit:"ex"},t);i/=t.havingBaseSizing().sizeMultiplier;const l=r.height+r.depth+e+n;r.style.paddingLeft=O(l/2+e);const c=Math.floor(1e3*l*i),h="M400000 "+(a=c)+" H0 L"+a/2+" 0 l65 45 L145 "+(a-80)+" H400000z",m=new _([new $("phase",h)],{width:"400em",height:O(c/1e3),viewBox:"0 0 400000 "+c,preserveAspectRatio:"xMinYMin slice"});o=We(["hide-tail"],[m],t),o.style.height=O(l),s=r.depth+e+n}else{let i,a;/cancel/.test(n)?l||r.classes.push("cancel-pad"):"angl"===n?r.classes.push("anglpad"):r.classes.push("boxpad");let c=0;/box/.test(n)?(c=Math.max(t.fontMetrics().fboxrule,t.minRuleThickness),i=t.fontMetrics().fboxsep+("colorbox"===n?0:c),a=i):"angl"===n?(c=Math.max(t.fontMetrics().defaultRuleThickness,t.minRuleThickness),i=4*c,a=Math.max(0,.25-r.depth)):(i=l?.2:0,a=i),o=function(e,t,r,n,o){let s;const i=e.height+e.depth+r+n;if(/fbox|color|angl/.test(t)){if(s=je(["stretchy",t],[],o),"fbox"===t){const e=o.color&&o.getColor();e&&(s.style.borderColor=e)}}else{const e=[];/^[bx]cancel$/.test(t)&&e.push(new Z({x1:"0",y1:"0",x2:"100%",y2:"100%","stroke-width":"0.046em"})),/^x?cancel$/.test(t)&&e.push(new Z({x1:"0",y1:"100%",x2:"100%",y2:"0","stroke-width":"0.046em"}));const r=new _(e,{width:"100%",height:O(i)});s=We([],[r],o)}return s.height=i,s.style.height=O(i),s}(r,n,i,a,t),/fbox|boxed|fcolorbox/.test(n)?(o.style.borderStyle="solid",o.style.borderWidth=O(c)):"angl"===n&&.049!==c&&(o.style.borderTopWidth=O(c),o.style.borderRightWidth=O(c)),s=r.depth+a,e.backgroundColor&&(o.style.backgroundColor=e.backgroundColor,e.borderColor&&(o.style.borderColor=e.borderColor))}var a;let c;if(e.backgroundColor)c=Ke({positionType:"individualShift",children:[{type:"elem",elem:o,shift:s},{type:"elem",elem:r,shift:0}]});else{const e=/cancel|phase/.test(n)?["svg-align"]:[];c=Ke({positionType:"individualShift",children:[{type:"elem",elem:r,shift:0},{type:"elem",elem:o,shift:s,wrapperClasses:e}]})}return/cancel/.test(n)&&(c.height=r.height,c.depth=r.depth),/cancel/.test(n)&&!l?je(["mord","cancel-lap"],[c],t):je(["mord"],[c],t)},mathmlBuilder:(e,t)=>{let r;const n=new Bt(e.label.includes("colorbox")?"mpadded":"menclose",[Vt(e.body,t)]);switch(e.label){case"\\cancel":n.setAttribute("notation","updiagonalstrike");break;case"\\bcancel":n.setAttribute("notation","downdiagonalstrike");break;case"\\phase":n.setAttribute("notation","phasorangle");break;case"\\sout":n.setAttribute("notation","horizontalstrike");break;case"\\fbox":n.setAttribute("notation","box");break;case"\\angl":n.setAttribute("notation","actuarial");break;case"\\fcolorbox":case"\\colorbox":if(r=t.fontMetrics().fboxsep*t.fontMetrics().ptPerEm,n.setAttribute("width","+"+2*r+"pt"),n.setAttribute("height","+"+2*r+"pt"),n.setAttribute("lspace",r+"pt"),n.setAttribute("voffset",r+"pt"),"\\fcolorbox"===e.label){const r=Math.max(t.fontMetrics().fboxrule,t.minRuleThickness);n.setAttribute("style","border: "+O(r)+" solid "+e.borderColor)}break;case"\\xcancel":n.setAttribute("notation","updiagonalstrike downdiagonalstrike")}return e.backgroundColor&&n.setAttribute("mathbackground",e.backgroundColor),n}}),mt({type:"enclose",names:["\\fcolorbox"],numArgs:3,allowedInText:!0,argTypes:["color","color","hbox"],handler(e,t,r){let{parser:n,funcName:o}=e;const s=or(t[0],"color-token").color,i=or(t[1],"color-token").color,l=t[2];return{type:"enclose",mode:n.mode,label:o,backgroundColor:i,borderColor:s,body:l}}}),mt({type:"enclose",names:["\\fbox"],numArgs:1,argTypes:["hbox"],allowedInText:!0,handler(e,t){let{parser:r}=e;return{type:"enclose",mode:r.mode,label:"\\fbox",body:t[0]}}}),mt({type:"enclose",names:["\\cancel","\\bcancel","\\xcancel","\\phase"],numArgs:1,handler(e,t){let{parser:r,funcName:n}=e;const o=t[0];return{type:"enclose",mode:r.mode,label:n,body:o}}}),mt({type:"enclose",names:["\\sout"],numArgs:1,allowedInText:!0,handler(e,t){let{parser:r,funcName:n}=e;"math"===r.mode&&r.settings.reportNonstrict("mathVsSout","LaTeX's \\sout works only in text mode");const o=t[0];return{type:"enclose",mode:r.mode,label:n,body:o}}}),mt({type:"enclose",names:["\\angl"],numArgs:1,argTypes:["hbox"],allowedInText:!1,handler(e,t){let{parser:r}=e;return{type:"enclose",mode:r.mode,label:"\\angl",body:t[0]}}});const $r={};function Zr(e){let{type:t,names:r,props:n,handler:o,htmlBuilder:s,mathmlBuilder:i}=e;const l={type:t,numArgs:n.numArgs||0,allowedInText:!1,numOptionalArgs:0,handler:o};for(let e=0;e{if(!e.parser.settings.displayMode)throw new n("{"+e.envName+"} can be used only in display mode.")},nn=new Set(["gather","gather*"]);function on(e){if(!e.includes("ed"))return!e.includes("*")}function sn(e,t,r){let{hskipBeforeAndAfter:o,addJot:s,cols:i,arraystretch:l,colSeparationType:a,autoTag:c,singleRow:h,emptySingleRow:m,maxNumCols:u,leqno:p}=t;if(e.gullet.beginGroup(),h||e.gullet.macros.set("\\cr","\\\\\\relax"),!l){const t=e.gullet.expandMacroAsText("\\arraystretch");if(null==t)l=1;else if(l=parseFloat(t),!l||l<0)throw new n("Invalid \\arraystretch: "+t)}e.gullet.beginGroup();let d=[];const g=[d],f=[],b=[],y=null!=c?[]:void 0;function x(){c&&e.gullet.macros.set("\\@eqnsw","1",!0)}function w(){y&&(e.gullet.macros.get("\\df@tag")?(y.push(e.subparse([new en("\\df@tag")])),e.gullet.macros.set("\\df@tag",void 0,!0)):y.push(Boolean(c)&&"1"===e.gullet.macros.get("\\@eqnsw")))}for(x(),b.push(tn(e));;){const t=e.parseExpression(!1,h?"\\end":"\\\\");e.gullet.endGroup(),e.gullet.beginGroup();let o={type:"ordgroup",mode:e.mode,body:t};r&&(o={type:"styling",mode:e.mode,style:r,resetFont:!0,body:[o]}),d.push(o);const s=e.fetch().text;if("&"===s){if(u&&d.length===u){if(h||a)throw new n("Too many tab characters: &",e.nextToken);e.settings.reportNonstrict("textEnv","Too few columns specified in the {array} column argument.")}e.consume()}else{if("\\end"===s){w(),1===d.length&&"styling"===o.type&&1===o.body.length&&"ordgroup"===o.body[0].type&&0===o.body[0].body.length&&(g.length>1||!m)&&g.pop(),b.length0&&(y+=.25),c.push({pos:y,isDashed:e[t]})}for(x(i[0]),r=0;r0&&(u+=b,ce))for(r=0;r=l)continue;var B,q;if(o>0||e.hskipBeforeAndAfter)i=null!=(B=null==(q=c)?void 0:q.pregap)?B:u,0!==i&&(z=je(["arraycolsep"],[]),z.style.width=O(i),k.push(z));const p=[];for(r=0;r0){const e=_e("hline",t,h),r=_e("hdashline",t,h),n=[{type:"elem",elem:H,shift:0}];for(;c.length>0;){const t=c.pop(),o=t.pos-w;t.isDashed?n.push({type:"elem",elem:r,shift:o}):n.push({type:"elem",elem:e,shift:o})}H=Ke({positionType:"individualShift",children:n})}if(0===A.length)return je(["mord"],[H],t);{const e=Ke({positionType:"individualShift",children:A}),r=je(["tag"],[e],t);return $e([H,r])}},cn={c:"center ",l:"left ",r:"right "},hn=function(e,t){const r=[],n=new Bt("mtd",[],["mtr-glue"]),o=new Bt("mtd",[],["mml-eqn-num"]);for(let s=0;s0){const t=e.cols;let r="",n=!1,o=0,i=t.length;"separator"===t[0].type&&(l+="top ",o=1),"separator"===t[t.length-1].type&&(l+="bottom ",i-=1);for(let e=o;e0?"left ":"",l+=h[h.length-1].length>0?"right ":"";for(let e=1;e0&&c&&(n=1),r[e]={type:"align",align:t,pregap:n,postgap:0}}return s.colSeparationType=c?"align":"alignat",s};Zr({type:"array",names:["array","darray"],props:{numArgs:1},handler(e,t){const r=(ir(t[0])?[t[0]]:or(t[0],"ordgroup").body).map(function(e){const t=sr(e).text;if("lcr".includes(t))return{type:"align",align:t};if("|"===t)return{type:"separator",separator:"|"};if(":"===t)return{type:"separator",separator:":"};throw new n("Unknown column alignment: "+t,e)}),o={cols:r,hskipBeforeAndAfter:!0,maxNumCols:r.length};return sn(e.parser,o,ln(e.envName))},htmlBuilder:an,mathmlBuilder:hn}),Zr({type:"array",names:["matrix","pmatrix","bmatrix","Bmatrix","vmatrix","Vmatrix","matrix*","pmatrix*","bmatrix*","Bmatrix*","vmatrix*","Vmatrix*"],props:{numArgs:0},handler(e){const t={matrix:null,pmatrix:["(",")"],bmatrix:["[","]"],Bmatrix:["\\{","\\}"],vmatrix:["|","|"],Vmatrix:["\\Vert","\\Vert"]}[e.envName.replace("*","")];let r="c";const o={hskipBeforeAndAfter:!1,cols:[{type:"align",align:r}]};if("*"===e.envName.charAt(e.envName.length-1)){const t=e.parser;if(t.consumeSpaces(),"["===t.fetch().text){if(t.consume(),t.consumeSpaces(),r=t.fetch().text,!"lcr".includes(r))throw new n("Expected l or c or r",t.nextToken);t.consume(),t.consumeSpaces(),t.expect("]"),t.consume(),o.cols=[{type:"align",align:r}]}}const s=sn(e.parser,o,ln(e.envName)),i=Math.max(0,...s.body.map(e=>e.length));return s.cols=new Array(i).fill({type:"align",align:r}),t?{type:"leftright",mode:e.mode,body:[s],left:t[0],right:t[1],rightColor:void 0}:s},htmlBuilder:an,mathmlBuilder:hn}),Zr({type:"array",names:["smallmatrix"],props:{numArgs:0},handler(e){const t=sn(e.parser,{arraystretch:.5},"script");return t.colSeparationType="small",t},htmlBuilder:an,mathmlBuilder:hn}),Zr({type:"array",names:["subarray"],props:{numArgs:1},handler(e,t){const r=(ir(t[0])?[t[0]]:or(t[0],"ordgroup").body).map(function(e){const t=sr(e).text;if("lc".includes(t))return{type:"align",align:t};throw new n("Unknown column alignment: "+t,e)});if(r.length>1)throw new n("{subarray} can contain only one column");const o={cols:r,hskipBeforeAndAfter:!1,arraystretch:.5},s=sn(e.parser,o,"script");if(s.body.length>0&&s.body[0].length>1)throw new n("{subarray} can contain only one column");return s},htmlBuilder:an,mathmlBuilder:hn}),Zr({type:"array",names:["cases","dcases","rcases","drcases"],props:{numArgs:0},handler(e){const t=sn(e.parser,{arraystretch:1.2,cols:[{type:"align",align:"l",pregap:0,postgap:1},{type:"align",align:"l",pregap:0,postgap:0}]},ln(e.envName));return{type:"leftright",mode:e.mode,body:[t],left:e.envName.includes("r")?".":"\\{",right:e.envName.includes("r")?"\\}":".",rightColor:void 0}},htmlBuilder:an,mathmlBuilder:hn}),Zr({type:"array",names:["align","align*","aligned","split"],props:{numArgs:0},handler:mn,htmlBuilder:an,mathmlBuilder:hn}),Zr({type:"array",names:["gathered","gather","gather*"],props:{numArgs:0},handler(e){nn.has(e.envName)&&rn(e);const t={cols:[{type:"align",align:"c"}],addJot:!0,colSeparationType:"gather",autoTag:on(e.envName),emptySingleRow:!0,leqno:e.parser.settings.leqno};return sn(e.parser,t,"display")},htmlBuilder:an,mathmlBuilder:hn}),Zr({type:"array",names:["alignat","alignat*","alignedat"],props:{numArgs:1},handler:mn,htmlBuilder:an,mathmlBuilder:hn}),Zr({type:"array",names:["equation","equation*"],props:{numArgs:0},handler(e){rn(e);const t={autoTag:on(e.envName),emptySingleRow:!0,singleRow:!0,maxNumCols:1,leqno:e.parser.settings.leqno};return sn(e.parser,t,"display")},htmlBuilder:an,mathmlBuilder:hn}),Zr({type:"array",names:["CD"],props:{numArgs:0},handler(e){return rn(e),function(e){const t=[];for(e.gullet.beginGroup(),e.gullet.macros.set("\\cr","\\\\\\relax"),e.gullet.beginGroup();;){t.push(e.parseExpression(!1,"\\\\")),e.gullet.endGroup(),e.gullet.beginGroup();const r=e.fetch().text;if("&"!==r&&"\\\\"!==r){if("\\end"===r){0===t[t.length-1].length&&t.pop();break}throw new n("Expected \\\\ or \\cr or \\end",e.nextToken)}e.consume()}let r=[];const o=[r];for(let s=0;sAV".includes(o))throw new n('Expected one of "<>AV=|." after @',i[t]);for(let e=0;e<2;e++){let r=!0;for(let l=t+1;l{let{parser:r,funcName:n}=e;const o=pt(t[0]),s=n in pn?pn[n]:n;return{type:"font",mode:r.mode,font:s.slice(1),body:o}},htmlBuilder:(e,t)=>{const r=e.font,n=t.withFont(r);return Mt(e.body,n)},mathmlBuilder:(e,t)=>{const r=e.font,n=t.withFont(r);return Vt(e.body,n)}}),mt({type:"mclass",names:["\\boldsymbol","\\bm"],numArgs:1,handler:(e,t)=>{let{parser:r}=e;const n=t[0];return{type:"mclass",mode:r.mode,mclass:mr(n),body:[{type:"font",mode:r.mode,font:"boldsymbol",body:n}],isCharacterBox:m(n)}}}),mt({type:"font",names:["\\rm","\\sf","\\tt","\\bf","\\it","\\cal"],numArgs:0,allowedInText:!0,handler:(e,t)=>{let{parser:r,funcName:n,breakOnTokenText:o}=e;const{mode:s}=r,i=r.parseExpression(!0,o);return{type:"font",mode:s,font:"math"+n.slice(1),body:{type:"ordgroup",mode:r.mode,body:i}}}});const dn=(e,t)=>{if(!t)return e;return{type:"styling",mode:e.mode,style:t,body:[e]}};mt({type:"genfrac",names:["\\cfrac","\\dfrac","\\frac","\\tfrac","\\dbinom","\\binom","\\tbinom","\\\\atopfrac","\\\\bracefrac","\\\\brackfrac"],numArgs:2,allowedInArgument:!0,handler:(e,t)=>{let{parser:r,funcName:n}=e;const o=t[0],s=t[1];let i,l=null,a=null;switch(n){case"\\cfrac":case"\\dfrac":case"\\frac":case"\\tfrac":i=!0;break;case"\\\\atopfrac":i=!1;break;case"\\dbinom":case"\\binom":case"\\tbinom":i=!1,l="(",a=")";break;case"\\\\bracefrac":i=!1,l="\\{",a="\\}";break;case"\\\\brackfrac":i=!1,l="[",a="]";break;default:throw new Error("Unrecognized genfrac command")}const c="\\cfrac"===n;let h=null;return c||n.startsWith("\\d")?h="display":n.startsWith("\\t")&&(h="text"),dn({type:"genfrac",mode:r.mode,numer:o,denom:s,continued:c,hasBarLine:i,leftDelim:l,rightDelim:a,barSize:null},h)},htmlBuilder:(e,t)=>{const r=t.style,n=r.fracNum(),o=r.fracDen();let s;s=t.havingStyle(n);const i=Mt(e.numer,s,t);if(e.continued){const e=8.5/t.fontMetrics().ptPerEm,r=3.5/t.fontMetrics().ptPerEm;i.height=i.height0?3*h:7*h,p=t.fontMetrics().denom1):(c>0?(m=t.fontMetrics().num2,u=h):(m=t.fontMetrics().num3,u=3*h),p=t.fontMetrics().denom2),a){const e=t.fontMetrics().axisHeight;m-i.depth-(e+.5*c){const r=new Bt("mfrac",[Vt(e.numer,t),Vt(e.denom,t)]);if(e.hasBarLine){if(e.barSize){const n=N(e.barSize,t);r.setAttribute("linethickness",O(n))}}else r.setAttribute("linethickness","0px");if(null!=e.leftDelim||null!=e.rightDelim){const t=[];if(null!=e.leftDelim){const r=new Bt("mo",[new qt(e.leftDelim.replace("\\",""))]);r.setAttribute("fence","true"),t.push(r)}if(t.push(r),null!=e.rightDelim){const r=new Bt("mo",[new qt(e.rightDelim.replace("\\",""))]);r.setAttribute("fence","true"),t.push(r)}return Nt(t)}return r}}),mt({type:"infix",names:["\\over","\\choose","\\atop","\\brace","\\brack"],numArgs:0,infix:!0,handler(e){let t,{parser:r,funcName:n,token:o}=e;switch(n){case"\\over":t="\\frac";break;case"\\choose":t="\\binom";break;case"\\atop":t="\\\\atopfrac";break;case"\\brace":t="\\\\bracefrac";break;case"\\brack":t="\\\\brackfrac";break;default:throw new Error("Unrecognized infix genfrac command")}return{type:"infix",mode:r.mode,replaceWith:t,token:o}}});const gn=["display","text","script","scriptscript"],fn=function(e){let t=null;return e.length>0&&(t=e,t="."===t?null:t),t};mt({type:"genfrac",names:["\\genfrac"],numArgs:6,allowedInArgument:!0,argTypes:["math","math","size","text","math","math"],handler(e,t){let{parser:r}=e;const n=t[4],o=t[5],s=pt(t[0]),i="atom"===s.type&&"open"===s.family?fn(s.text):null,l=pt(t[1]),a="atom"===l.type&&"close"===l.family?fn(l.text):null,c=or(t[2],"size");let h,m=null;c.isBlank?h=!0:(m=c.value,h=m.number>0);let u=null,p=t[3];if("ordgroup"===p.type){if(p.body.length>0){const e=or(p.body[0],"textord");u=gn[Number(e.text)]}}else p=or(p,"textord"),u=gn[Number(p.text)];return dn({type:"genfrac",mode:r.mode,numer:n,denom:o,continued:!1,hasBarLine:h,barSize:m,leftDelim:i,rightDelim:a},u)}}),mt({type:"infix",names:["\\above"],numArgs:1,argTypes:["size"],infix:!0,handler(e,t){let{parser:r,funcName:n,token:o}=e;return{type:"infix",mode:r.mode,replaceWith:"\\\\abovefrac",size:or(t[0],"size").value,token:o}}}),mt({type:"genfrac",names:["\\\\abovefrac"],numArgs:3,argTypes:["math","size","math"],handler:(e,t)=>{let{parser:r,funcName:n}=e;const o=t[0],s=or(t[1],"infix").size;if(!s)throw new Error("\\\\abovefrac expected size, but got "+String(s));const i=t[2],l=s.number>0;return{type:"genfrac",mode:r.mode,numer:o,denom:i,continued:!1,hasBarLine:l,barSize:s,leftDelim:null,rightDelim:null}}});const bn=(e,t)=>{const r=t.style;let n,o;"supsub"===e.type?(n=e.sup?Mt(e.sup,t.havingStyle(r.sup()),t):Mt(e.sub,t.havingStyle(r.sub()),t),o=or(e.base,"horizBrace")):o=or(e,"horizBrace");const s=Mt(o.base,t.havingBaseStyle(S.DISPLAY)),i=tr(o,t);let l;if(l=o.isOver?Ke({positionType:"firstBaseline",children:[{type:"elem",elem:s},{type:"kern",size:.1},{type:"elem",elem:i,wrapperClasses:["svg-align"]}]}):Ke({positionType:"bottom",positionData:s.depth+.1+i.height,children:[{type:"elem",elem:i,wrapperClasses:["svg-align"]},{type:"kern",size:.1},{type:"elem",elem:s}]}),n){const e=je(["minner",o.isOver?"mover":"munder"],[l],t);l=o.isOver?Ke({positionType:"firstBaseline",children:[{type:"elem",elem:e},{type:"kern",size:.2},{type:"elem",elem:n}]}):Ke({positionType:"bottom",positionData:e.depth+.2+n.height+n.depth,children:[{type:"elem",elem:n},{type:"kern",size:.2},{type:"elem",elem:e}]})}return je(["minner",o.isOver?"mover":"munder"],[l],t)};mt({type:"horizBrace",names:["\\overbrace","\\underbrace","\\overbracket","\\underbracket"],numArgs:1,handler(e,t){let{parser:r,funcName:n}=e;return{type:"horizBrace",mode:r.mode,label:n,isOver:n.includes("\\over"),base:t[0]}},htmlBuilder:bn,mathmlBuilder:(e,t)=>{const r=Jt(e.label);return new Bt(e.isOver?"mover":"munder",[Vt(e.base,t),r])}}),mt({type:"href",names:["\\href"],numArgs:2,argTypes:["url","original"],allowedInText:!0,handler:(e,t)=>{let{parser:r}=e;const n=t[1],o=or(t[0],"url").url;return r.settings.isTrusted({command:"\\href",url:o})?{type:"href",mode:r.mode,href:o,body:dt(n)}:r.formatUnsupportedCmd("\\href")},htmlBuilder:(e,t)=>{const r=xt(e.body,t,!1);return function(e,t,r,n){const o=new X(e,t,r,n);return Ye(o),o}(e.href,[],r,t)},mathmlBuilder:(e,t)=>{let r=Ft(e.body,t);return r instanceof Bt||(r=new Bt("mrow",[r])),r.setAttribute("href",e.href),r}}),mt({type:"href",names:["\\url"],numArgs:1,argTypes:["url"],allowedInText:!0,handler:(e,t)=>{let{parser:r}=e;const n=or(t[0],"url").url;if(!r.settings.isTrusted({command:"\\url",url:n}))return r.formatUnsupportedCmd("\\url");const o=[];for(let e=0;e{let{parser:r,funcName:o,token:s}=e;const i=or(t[0],"raw").string,l=t[1];let a;r.settings.strict&&r.settings.reportNonstrict("htmlExtension","HTML extension is disabled on strict mode");const c={};switch(o){case"\\htmlClass":c.class=i,a={command:"\\htmlClass",class:i};break;case"\\htmlId":c.id=i,a={command:"\\htmlId",id:i};break;case"\\htmlStyle":c.style=i,a={command:"\\htmlStyle",style:i};break;case"\\htmlData":{const e=i.split(",");for(let t=0;t{const r=xt(e.body,t,!1),n=["enclosing"];e.attributes.class&&n.push(...e.attributes.class.trim().split(/\s+/));const o=je(n,r,t);for(const t in e.attributes)"class"!==t&&e.attributes.hasOwnProperty(t)&&o.setAttribute(t,e.attributes[t]);return o},mathmlBuilder:(e,t)=>Ft(e.body,t)}),mt({type:"htmlmathml",names:["\\html@mathml"],numArgs:2,allowedInArgument:!0,allowedInText:!0,handler:(e,t)=>{let{parser:r}=e;return{type:"htmlmathml",mode:r.mode,html:dt(t[0]),mathml:dt(t[1])}},htmlBuilder:(e,t)=>{const r=xt(e.html,t,!1);return $e(r)},mathmlBuilder:(e,t)=>Ft(e.mathml,t)});const yn=function(e){if(/^[-+]? *(\d+(\.\d*)?|\.\d+)$/.test(e))return{number:+e,unit:"bp"};{const t=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(e);if(!t)throw new n("Invalid size: '"+e+"' in \\includegraphics");const r={number:+(t[1]+t[2]),unit:t[3]};if(!E(r))throw new n("Invalid unit: '"+r.unit+"' in \\includegraphics.");return r}};mt({type:"includegraphics",names:["\\includegraphics"],numArgs:1,numOptionalArgs:1,argTypes:["raw","url"],allowedInText:!1,handler:(e,t,r)=>{let{parser:o}=e,s={number:0,unit:"em"},i={number:.9,unit:"em"},l={number:0,unit:"em"},a="";if(r[0]){const e=or(r[0],"raw").string.split(",");for(let t=0;t{const r=N(e.height,t);let n=0;e.totalheight.number>0&&(n=N(e.totalheight,t)-r);let o=0;e.width.number>0&&(o=N(e.width,t));const s={height:O(r+n)};o>0&&(s.width=O(o)),n>0&&(s.verticalAlign=O(-n));const i=new Y(e.src,e.alt,s);return i.height=r,i.depth=n,i},mathmlBuilder:(e,t)=>{const r=new Bt("mglyph",[]);r.setAttribute("alt",e.alt);const n=N(e.height,t);let o=0;if(e.totalheight.number>0&&(o=N(e.totalheight,t)-n,r.setAttribute("valign",O(-o))),r.setAttribute("height",O(n+o)),e.width.number>0){const n=N(e.width,t);r.setAttribute("width",O(n))}return r.setAttribute("src",e.src),r}}),mt({type:"kern",names:["\\kern","\\mkern","\\hskip","\\mskip"],numArgs:1,argTypes:["size"],primitive:!0,allowedInText:!0,handler(e,t){let{parser:r,funcName:n}=e;const o=or(t[0],"size");if(r.settings.strict){const e="m"===n[1],t="mu"===o.value.unit;e?(t||r.settings.reportNonstrict("mathVsTextUnits","LaTeX's "+n+" supports only mu units, not "+o.value.unit+" units"),"math"!==r.mode&&r.settings.reportNonstrict("mathVsTextUnits","LaTeX's "+n+" works only in math mode")):t&&r.settings.reportNonstrict("mathVsTextUnits","LaTeX's "+n+" doesn't support mu units")}return{type:"kern",mode:r.mode,dimension:o.value}},htmlBuilder(e,t){return Je(e.dimension,t)},mathmlBuilder(e,t){const r=N(e.dimension,t);return new It(r)}}),mt({type:"lap",names:["\\mathllap","\\mathrlap","\\mathclap"],numArgs:1,allowedInText:!0,handler:(e,t)=>{let{parser:r,funcName:n}=e;const o=t[0];return{type:"lap",mode:r.mode,alignment:n.slice(5),body:o}},htmlBuilder:(e,t)=>{let r;"clap"===e.alignment?(r=je([],[Mt(e.body,t)]),r=je(["inner"],[r],t)):r=je(["inner"],[Mt(e.body,t)]);const n=je(["fix"],[]);let o=je([e.alignment],[r,n],t);const s=je(["strut"]);return s.style.height=O(o.height+o.depth),o.depth&&(s.style.verticalAlign=O(-o.depth)),o.children.unshift(s),o=je(["thinbox"],[o],t),je(["mord","vbox"],[o],t)},mathmlBuilder:(e,t)=>{const r=new Bt("mpadded",[Vt(e.body,t)]);if("rlap"!==e.alignment){const t="llap"===e.alignment?"-1":"-0.5";r.setAttribute("lspace",t+"width")}return r.setAttribute("width","0px"),r}}),mt({type:"styling",names:["\\(","$"],numArgs:0,allowedInText:!0,allowedInMath:!1,handler(e,t){let{funcName:r,parser:n}=e;const o=n.mode;n.switchMode("math");const s="\\("===r?"\\)":"$",i=n.parseExpression(!1,s);return n.expect(s),n.switchMode(o),{type:"styling",mode:n.mode,style:"text",resetFont:!0,body:i}}}),mt({type:"text",names:["\\)","\\]"],numArgs:0,allowedInText:!0,allowedInMath:!1,handler(e,t){throw new n("Mismatched "+e.funcName)}});const xn=(e,t)=>{switch(t.style.size){case S.DISPLAY.size:return e.display;case S.TEXT.size:return e.text;case S.SCRIPT.size:return e.script;case S.SCRIPTSCRIPT.size:return e.scriptscript;default:return e.text}};mt({type:"mathchoice",names:["\\mathchoice"],numArgs:4,primitive:!0,handler:(e,t)=>{let{parser:r}=e;return{type:"mathchoice",mode:r.mode,display:dt(t[0]),text:dt(t[1]),script:dt(t[2]),scriptscript:dt(t[3])}},htmlBuilder:(e,t)=>{const r=xn(e,t),n=xt(r,t,!1);return $e(n)},mathmlBuilder:(e,t)=>{const r=xn(e,t);return Ft(r,t)}});const wn=(e,t,r,n,o,s,i)=>{e=je([],[e]);const l=r&&m(r);let a,c,h;if(t){const e=Mt(t,n.havingStyle(o.sup()),n);c={elem:e,kern:Math.max(n.fontMetrics().bigOpSpacing1,n.fontMetrics().bigOpSpacing3-e.depth)}}if(r){const e=Mt(r,n.havingStyle(o.sub()),n);a={elem:e,kern:Math.max(n.fontMetrics().bigOpSpacing2,n.fontMetrics().bigOpSpacing4-e.height)}}if(c&&a){const t=n.fontMetrics().bigOpSpacing5+a.elem.height+a.elem.depth+a.kern+e.depth+i;h=Ke({positionType:"bottom",positionData:t,children:[{type:"kern",size:n.fontMetrics().bigOpSpacing5},{type:"elem",elem:a.elem,marginLeft:O(-s)},{type:"kern",size:a.kern},{type:"elem",elem:e},{type:"kern",size:c.kern},{type:"elem",elem:c.elem,marginLeft:O(s)},{type:"kern",size:n.fontMetrics().bigOpSpacing5}]})}else if(a){const t=e.height-i;h=Ke({positionType:"top",positionData:t,children:[{type:"kern",size:n.fontMetrics().bigOpSpacing5},{type:"elem",elem:a.elem,marginLeft:O(-s)},{type:"kern",size:a.kern},{type:"elem",elem:e}]})}else{if(!c)return e;{const t=e.depth+i;h=Ke({positionType:"bottom",positionData:t,children:[{type:"elem",elem:e},{type:"kern",size:c.kern},{type:"elem",elem:c.elem,marginLeft:O(s)},{type:"kern",size:n.fontMetrics().bigOpSpacing5}]})}}const u=[h];if(a&&0!==s&&!l){const e=je(["mspace"],[],n);e.style.marginRight=O(s),u.unshift(e)}return je(["mop","op-limits"],u,n)},vn=new Set(["\\smallint"]),kn=(e,t)=>{let r,n,o,s=!1;"supsub"===e.type?(r=e.sup,n=e.sub,o=or(e.base,"op"),s=!0):o=or(e,"op");const i=t.style;let l,a,c=!1;if(i.size===S.DISPLAY.size&&o.symbol&&!vn.has(o.name)&&(c=!0),o.symbol){const e=c?"Size2-Regular":"Size1-Regular";let r="";if("\\oiint"!==o.name&&"\\oiiint"!==o.name||(r=o.name.slice(1),o.name="oiint"===r?"\\iint":"\\iiint"),l=Fe(o.name,e,"math",t,["mop","op-symbol",c?"large-op":"small-op"]),a=l.italic,r.length>0){const e=rt(r+"Size"+(c?"2":"1"),t);l=Ke({positionType:"individualShift",children:[{type:"elem",elem:l,shift:0},{type:"elem",elem:e,shift:c?.08:0}]}),o.name="\\"+r,l.classes.unshift("mop"),l.italic=a}}else if(o.body){const e=xt(o.body,t,!0);1===e.length&&e[0]instanceof W?(l=e[0],l.classes[0]="mop"):l=je(["mop"],e,t)}else{const e=[];for(let r=1;r{let{parser:r,funcName:n}=e,o=n;return 1===o.length&&(o=zn[o]),{type:"op",mode:r.mode,limits:!0,parentIsSupSub:!1,symbol:!0,name:o}},htmlBuilder:kn,mathmlBuilder:(e,t)=>{let r;if(e.symbol)r=new Bt("mo",[Et(e.name,e.mode)]),vn.has(e.name)&&r.setAttribute("largeop","false");else if(e.body)r=new Bt("mo",Pt(e.body,t));else{r=new Bt("mi",[new qt(e.name.slice(1))]);const t=new Bt("mo",[Et("\u2061","text")]);r=e.parentIsSupSub?new Bt("mrow",[r,t]):Ct([r,t])}return r}}),mt({type:"op",names:["\\mathop"],numArgs:1,primitive:!0,handler:(e,t)=>{let{parser:r}=e;const n=t[0];return{type:"op",mode:r.mode,limits:!1,parentIsSupSub:!1,symbol:!1,body:dt(n)}}});const Sn={"\u222b":"\\int","\u222c":"\\iint","\u222d":"\\iiint","\u222e":"\\oint","\u222f":"\\oiint","\u2230":"\\oiiint"};mt({type:"op",names:["\\arcsin","\\arccos","\\arctan","\\arctg","\\arcctg","\\arg","\\ch","\\cos","\\cosec","\\cosh","\\cot","\\cotg","\\coth","\\csc","\\ctg","\\cth","\\deg","\\dim","\\exp","\\hom","\\ker","\\lg","\\ln","\\log","\\sec","\\sin","\\sinh","\\sh","\\tan","\\tanh","\\tg","\\th"],numArgs:0,handler(e){let{parser:t,funcName:r}=e;return{type:"op",mode:t.mode,limits:!1,parentIsSupSub:!1,symbol:!1,name:r}}}),mt({type:"op",names:["\\det","\\gcd","\\inf","\\lim","\\max","\\min","\\Pr","\\sup"],numArgs:0,handler(e){let{parser:t,funcName:r}=e;return{type:"op",mode:t.mode,limits:!0,parentIsSupSub:!1,symbol:!1,name:r}}}),mt({type:"op",names:["\\int","\\iint","\\iiint","\\oint","\\oiint","\\oiiint","\u222b","\u222c","\u222d","\u222e","\u222f","\u2230"],numArgs:0,allowedInArgument:!0,handler(e){let{parser:t,funcName:r}=e,n=r;return 1===n.length&&(n=Sn[n]),{type:"op",mode:t.mode,limits:!1,parentIsSupSub:!1,symbol:!0,name:n}}});const Mn=(e,t)=>{let r,n,o,s,i=!1;if("supsub"===e.type?(r=e.sup,n=e.sub,o=or(e.base,"operatorname"),i=!0):o=or(e,"operatorname"),o.body.length>0){const e=o.body.map(e=>{const t="text"in e?e.text:void 0;return"string"==typeof t?{type:"textord",mode:e.mode,text:t}:e}),r=xt(e,t.withFont("mathrm"),!0);for(let e=0;e{let{parser:r,funcName:n}=e;const o=t[0];return{type:"operatorname",mode:r.mode,body:dt(o),alwaysHandleSupSub:"\\operatornamewithlimits"===n,limits:!1,parentIsSupSub:!1}},htmlBuilder:Mn,mathmlBuilder:(e,t)=>{let r=Pt(e.body,t.withFont("mathrm")),n=!0;for(let e=0;ee.toText()).join("");r=[new qt(e)]}const o=new Bt("mi",r);o.setAttribute("mathvariant","normal");const s=new Bt("mo",[Et("\u2061","text")]);return e.parentIsSupSub?new Bt("mrow",[o,s]):Ct([o,s])}}),Jr("\\operatorname","\\@ifstar\\operatornamewithlimits\\operatorname@"),ut({type:"ordgroup",htmlBuilder(e,t){return e.semisimple?$e(xt(e.body,t,!1)):je(["mord"],xt(e.body,t,!0),t)},mathmlBuilder(e,t){return Ft(e.body,t,!0)}}),mt({type:"overline",names:["\\overline"],numArgs:1,handler(e,t){let{parser:r}=e;const n=t[0];return{type:"overline",mode:r.mode,body:n}},htmlBuilder(e,t){const r=Mt(e.body,t.havingCrampedStyle()),n=_e("overline-line",t),o=t.fontMetrics().defaultRuleThickness,s=Ke({positionType:"firstBaseline",children:[{type:"elem",elem:r},{type:"kern",size:3*o},{type:"elem",elem:n},{type:"kern",size:o}]});return je(["mord","overline"],[s],t)},mathmlBuilder(e,t){const r=new Bt("mo",[new qt("\u203e")]);r.setAttribute("stretchy","true");const n=new Bt("mover",[Vt(e.body,t),r]);return n.setAttribute("accent","true"),n}}),mt({type:"phantom",names:["\\phantom"],numArgs:1,allowedInText:!0,handler:(e,t)=>{let{parser:r}=e;const n=t[0];return{type:"phantom",mode:r.mode,body:dt(n)}},htmlBuilder:(e,t)=>{const r=xt(e.body,t.withPhantom(),!1);return $e(r)},mathmlBuilder:(e,t)=>{const r=Pt(e.body,t);return new Bt("mphantom",r)}}),Jr("\\hphantom","\\smash{\\phantom{#1}}"),mt({type:"vphantom",names:["\\vphantom"],numArgs:1,allowedInText:!0,handler:(e,t)=>{let{parser:r}=e;const n=t[0];return{type:"vphantom",mode:r.mode,body:n}},htmlBuilder:(e,t)=>{const r=je(["inner"],[Mt(e.body,t.withPhantom())]),n=je(["fix"],[]);return je(["mord","rlap"],[r,n],t)},mathmlBuilder:(e,t)=>{const r=Pt(dt(e.body),t),n=new Bt("mphantom",r),o=new Bt("mpadded",[n]);return o.setAttribute("width","0px"),o}}),mt({type:"raisebox",names:["\\raisebox"],numArgs:2,argTypes:["size","hbox"],allowedInText:!0,handler(e,t){let{parser:r}=e;const n=or(t[0],"size").value,o=t[1];return{type:"raisebox",mode:r.mode,dy:n,body:o}},htmlBuilder(e,t){const r=Mt(e.body,t),n=N(e.dy,t);return Ke({positionType:"shift",positionData:-n,children:[{type:"elem",elem:r}]})},mathmlBuilder(e,t){const r=new Bt("mpadded",[Vt(e.body,t)]),n=e.dy.number+e.dy.unit;return r.setAttribute("voffset",n),r}}),mt({type:"internal",names:["\\relax"],numArgs:0,allowedInText:!0,allowedInArgument:!0,handler(e){let{parser:t}=e;return{type:"internal",mode:t.mode}}}),mt({type:"rule",names:["\\rule"],numArgs:2,numOptionalArgs:1,allowedInText:!0,allowedInMath:!0,argTypes:["size","size","size"],handler(e,t,r){let{parser:n}=e;const o=r[0],s=or(t[0],"size"),i=or(t[1],"size");return{type:"rule",mode:n.mode,shift:o&&or(o,"size").value,width:s.value,height:i.value}},htmlBuilder(e,t){const r=je(["mord","rule"],[],t),n=N(e.width,t),o=N(e.height,t),s=e.shift?N(e.shift,t):0;return r.style.borderRightWidth=O(n),r.style.borderTopWidth=O(o),r.style.bottom=O(s),r.width=n,r.height=o+s,r.depth=-s,r.maxFontSize=1.125*o*t.sizeMultiplier,r},mathmlBuilder(e,t){const r=N(e.width,t),n=N(e.height,t),o=e.shift?N(e.shift,t):0,s=t.color&&t.getColor()||"black",i=new Bt("mspace");i.setAttribute("mathbackground",s),i.setAttribute("width",O(r)),i.setAttribute("height",O(n));const l=new Bt("mpadded",[i]);return o>=0?l.setAttribute("height",O(o)):(l.setAttribute("height",O(o)),l.setAttribute("depth",O(-o))),l.setAttribute("voffset",O(o)),l}});const Tn=["\\tiny","\\sixptsize","\\scriptsize","\\footnotesize","\\small","\\normalsize","\\large","\\Large","\\LARGE","\\huge","\\Huge"];mt({type:"sizing",names:Tn,numArgs:0,allowedInText:!0,handler:(e,t)=>{let{breakOnTokenText:r,funcName:n,parser:o}=e;const s=o.parseExpression(!1,r);return{type:"sizing",mode:o.mode,size:Tn.indexOf(n)+1,body:s}},htmlBuilder:(e,t)=>{const r=t.havingSize(e.size);return An(e.body,r,t)},mathmlBuilder:(e,t)=>{const r=t.havingSize(e.size),n=Pt(e.body,r),o=new Bt("mstyle",n);return o.setAttribute("mathsize",O(r.sizeMultiplier)),o}}),mt({type:"smash",names:["\\smash"],numArgs:1,numOptionalArgs:1,allowedInText:!0,handler:(e,t,r)=>{let{parser:n}=e,o=!1,s=!1;const i=r[0]&&or(r[0],"ordgroup");if(i){let e;for(let t=0;t{const r=je([],[Mt(e.body,t)]);if(!e.smashHeight&&!e.smashDepth)return r;if(e.smashHeight&&(r.height=0),e.smashDepth&&(r.depth=0),e.smashHeight&&e.smashDepth)return je(["mord","smash"],[r],t);if(r.children)for(let t=0;t{const r=new Bt("mpadded",[Vt(e.body,t)]);return e.smashHeight&&r.setAttribute("height","0px"),e.smashDepth&&r.setAttribute("depth","0px"),r}}),mt({type:"sqrt",names:["\\sqrt"],numArgs:1,numOptionalArgs:1,handler(e,t,r){let{parser:n}=e;const o=r[0],s=t[0];return{type:"sqrt",mode:n.mode,body:s,index:o}},htmlBuilder(e,t){let r=Mt(e.body,t.havingCrampedStyle());0===r.height&&(r.height=t.fontMetrics().xHeight),r=Ze(r,t);const n=t.fontMetrics().defaultRuleThickness;let o=n;t.style.idr.height+r.depth+s&&(s=(s+h-r.height-r.depth)/2);const m=l.height-r.height-s-a;r.style.paddingLeft=O(c);const u=Ke({positionType:"firstBaseline",children:[{type:"elem",elem:r,wrapperClasses:["svg-align"]},{type:"kern",size:-(r.height+m)},{type:"elem",elem:l},{type:"kern",size:a}]});if(e.index){const r=t.havingStyle(S.SCRIPTSCRIPT),n=Mt(e.index,r,t),o=.6*(u.height-u.depth),s=Ke({positionType:"shift",positionData:-o,children:[{type:"elem",elem:n}]}),i=je(["root"],[s]);return je(["mord","sqrt"],[i,u],t)}return je(["mord","sqrt"],[u],t)},mathmlBuilder(e,t){const{body:r,index:n}=e;return n?new Bt("mroot",[Vt(r,t),Vt(n,t)]):new Bt("msqrt",[Vt(r,t)])}});const Cn={display:S.DISPLAY,text:S.TEXT,script:S.SCRIPT,scriptscript:S.SCRIPTSCRIPT};mt({type:"styling",names:["\\displaystyle","\\textstyle","\\scriptstyle","\\scriptscriptstyle"],numArgs:0,allowedInText:!0,primitive:!0,handler(e,t){let{breakOnTokenText:r,funcName:n,parser:o}=e;const s=o.parseExpression(!0,r),i=n.slice(1,n.length-5);if(!(i in Cn))throw new Error("Unknown style: "+i);return{type:"styling",mode:o.mode,style:i,body:s}},htmlBuilder(e,t){const r=Cn[e.style];let n=t.havingStyle(r);return e.resetFont&&(n=n.withFont("")),An(e.body,n,t)},mathmlBuilder(e,t){const r=Cn[e.style];let n=t.havingStyle(r);e.resetFont&&(n=n.withFont(""));const o=Pt(e.body,n),s=new Bt("mstyle",o),i={display:["0","true"],text:["0","false"],script:["1","false"],scriptscript:["2","false"]}[e.style];return s.setAttribute("scriptlevel",i[0]),s.setAttribute("displaystyle",i[1]),s}});ut({type:"supsub",htmlBuilder(e,t){const r=function(e,t){const r=e.base;if(r)return"op"===r.type?r.limits&&(t.style.size===S.DISPLAY.size||r.alwaysHandleSupSub)?kn:null:"operatorname"===r.type?r.alwaysHandleSupSub&&(t.style.size===S.DISPLAY.size||r.limits)?Mn:null:"accent"===r.type?m(r.base)?ar:null:"horizBrace"===r.type&&!e.sub===r.isOver?bn:null;return null}(e,t);if(r)return r(e,t);const{base:n,sup:o,sub:s}=e,i=Mt(n,t);let l,a;const c=t.fontMetrics();let h=0,u=0;const p=n&&m(n);if(o){const e=t.havingStyle(t.style.sup());l=Mt(o,e,t),p||(h=i.height-e.fontMetrics().supDrop*e.sizeMultiplier/t.sizeMultiplier)}if(s){const e=t.havingStyle(t.style.sub());a=Mt(s,e,t),p||(u=i.depth+e.fontMetrics().subDrop*e.sizeMultiplier/t.sizeMultiplier)}let d;d=t.style===S.DISPLAY?c.sup1:t.style.cramped?c.sup3:c.sup2;const g=t.sizeMultiplier,f=O(.5/c.ptPerEm/g);let b,y=null;if(a){const t=e.base&&"op"===e.base.type&&e.base.name&&("\\oiint"===e.base.name||"\\oiiint"===e.base.name);var x;if(i instanceof W||t)y=O(-(null!=(x=i.italic)?x:0))}if(l&&a){h=Math.max(h,d,l.depth+.25*c.xHeight),u=Math.max(u,c.sub2);const e=4*c.defaultRuleThickness;if(h-l.depth-(a.height-u)0&&(h+=t,u-=t)}b=Ke({positionType:"individualShift",children:[{type:"elem",elem:a,shift:u,marginRight:f,marginLeft:y},{type:"elem",elem:l,shift:-h,marginRight:f}]})}else if(a){u=Math.max(u,c.sub1,a.height-.8*c.xHeight);b=Ke({positionType:"shift",positionData:u,children:[{type:"elem",elem:a,marginLeft:y,marginRight:f}]})}else{if(!l)throw new Error("supsub must have either sup or sub.");h=Math.max(h,d,l.depth+.25*c.xHeight),b=Ke({positionType:"shift",positionData:-h,children:[{type:"elem",elem:l,marginRight:f}]})}const w=zt(i,"right")||"mord";return je([w],[i,je(["msupsub"],[b])],t)},mathmlBuilder(e,t){let r,n,o=!1;e.base&&"horizBrace"===e.base.type&&(n=!!e.sup,n===e.base.isOver&&(o=!0,r=e.base.isOver)),!e.base||"op"!==e.base.type&&"operatorname"!==e.base.type||(e.base.parentIsSupSub=!0);const s=[Vt(e.base,t)];let i;if(e.sub&&s.push(Vt(e.sub,t)),e.sup&&s.push(Vt(e.sup,t)),o)i=r?"mover":"munder";else if(e.sub)if(e.sup){const r=e.base;i=r&&"op"===r.type&&r.limits&&t.style===S.DISPLAY||r&&"operatorname"===r.type&&r.alwaysHandleSupSub&&(t.style===S.DISPLAY||r.limits)?"munderover":"msubsup"}else{const r=e.base;i=r&&"op"===r.type&&r.limits&&(t.style===S.DISPLAY||r.alwaysHandleSupSub)||r&&"operatorname"===r.type&&r.alwaysHandleSupSub&&(r.limits||t.style===S.DISPLAY)?"munder":"msub"}else{const r=e.base;i=r&&"op"===r.type&&r.limits&&(t.style===S.DISPLAY||r.alwaysHandleSupSub)||r&&"operatorname"===r.type&&r.alwaysHandleSupSub&&(r.limits||t.style===S.DISPLAY)?"mover":"msup"}return new Bt(i,s)}}),ut({type:"atom",htmlBuilder(e,t){return Ve(e.text,e.mode,t,["m"+e.family])},mathmlBuilder(e,t){const r=new Bt("mo",[Et(e.text,e.mode)]);if("bin"===e.family){const n=Dt(e,t);"bold-italic"===n&&r.setAttribute("mathvariant",n)}else"punct"===e.family?r.setAttribute("separator","true"):"open"!==e.family&&"close"!==e.family||r.setAttribute("stretchy","false");return r}});const Bn={mi:"italic",mn:"normal",mtext:"normal"};ut({type:"mathord",htmlBuilder(e,t){return Ge(e,t)},mathmlBuilder(e,t){const r=new Bt("mi",[Et(e.text,e.mode,t)]),n=Dt(e,t)||"italic";return n!==Bn[r.type]&&r.setAttribute("mathvariant",n),r}}),ut({type:"textord",htmlBuilder(e,t){return Ge(e,t)},mathmlBuilder(e,t){const r=Et(e.text,e.mode,t),n=Dt(e,t)||"normal";let o;return o="text"===e.mode?new Bt("mtext",[r]):/[0-9]/.test(e.text)?new Bt("mn",[r]):"\\prime"===e.text?new Bt("mo",[r]):new Bt("mi",[r]),n!==Bn[o.type]&&o.setAttribute("mathvariant",n),o}});const qn={"\\nobreak":"nobreak","\\allowbreak":"allowbreak"},In={" ":{},"\\ ":{},"~":{className:"nobreak"},"\\space":{},"\\nobreakspace":{className:"nobreak"}};ut({type:"spacing",htmlBuilder(e,t){if(In.hasOwnProperty(e.text)){const r=In[e.text].className||"";if("text"===e.mode){const n=Ge(e,t);return n.classes.push(r),n}return je(["mspace",r],[Ve(e.text,e.mode,t)],t)}if(qn.hasOwnProperty(e.text))return je(["mspace",qn[e.text]],[],t);throw new n('Unknown type of space "'+e.text+'"')},mathmlBuilder(e,t){let r;if(!In.hasOwnProperty(e.text)){if(qn.hasOwnProperty(e.text))return new Bt("mspace");throw new n('Unknown type of space "'+e.text+'"')}return r=new Bt("mtext",[new qt("\xa0")]),r}});const Rn=()=>{const e=new Bt("mtd",[]);return e.setAttribute("width","50%"),e};ut({type:"tag",mathmlBuilder(e,t){const r=new Bt("mtable",[new Bt("mtr",[Rn(),new Bt("mtd",[Ft(e.body,t)]),Rn(),new Bt("mtd",[Ft(e.tag,t)])])]);return r.setAttribute("width","100%"),r}});const Hn={"\\text":void 0,"\\textrm":"textrm","\\textsf":"textsf","\\texttt":"texttt","\\textnormal":"textrm"},En={"\\textbf":"textbf","\\textmd":"textmd"},Nn={"\\textit":"textit","\\textup":"textup"},On=(e,t)=>{const r=e.font;return r?Hn[r]?t.withTextFontFamily(Hn[r]):En[r]?t.withTextFontWeight(En[r]):"\\emph"===r?"textit"===t.fontShape?t.withTextFontShape("textup"):t.withTextFontShape("textit"):t.withTextFontShape(Nn[r]):t};mt({type:"text",names:["\\text","\\textrm","\\textsf","\\texttt","\\textnormal","\\textbf","\\textmd","\\textit","\\textup","\\emph"],numArgs:1,argTypes:["text"],allowedInArgument:!0,allowedInText:!0,handler(e,t){let{parser:r,funcName:n}=e;const o=t[0];return{type:"text",mode:r.mode,body:dt(o),font:n}},htmlBuilder(e,t){const r=On(e,t),n=xt(e.body,r,!0);return je(["mord","text"],n,r)},mathmlBuilder(e,t){const r=On(e,t);return Ft(e.body,r)}}),mt({type:"underline",names:["\\underline"],numArgs:1,allowedInText:!0,handler(e,t){let{parser:r}=e;return{type:"underline",mode:r.mode,body:t[0]}},htmlBuilder(e,t){const r=Mt(e.body,t),n=_e("underline-line",t),o=t.fontMetrics().defaultRuleThickness,s=Ke({positionType:"top",positionData:r.height,children:[{type:"kern",size:o},{type:"elem",elem:n},{type:"kern",size:3*o},{type:"elem",elem:r}]});return je(["mord","underline"],[s],t)},mathmlBuilder(e,t){const r=new Bt("mo",[new qt("\u203e")]);r.setAttribute("stretchy","true");const n=new Bt("munder",[Vt(e.body,t),r]);return n.setAttribute("accentunder","true"),n}}),mt({type:"vcenter",names:["\\vcenter"],numArgs:1,argTypes:["original"],allowedInText:!1,handler(e,t){let{parser:r}=e;return{type:"vcenter",mode:r.mode,body:t[0]}},htmlBuilder(e,t){const r=Mt(e.body,t),n=t.fontMetrics().axisHeight,o=.5*(r.height-n-(r.depth+n));return Ke({positionType:"shift",positionData:o,children:[{type:"elem",elem:r}]})},mathmlBuilder(e,t){const r=new Bt("mpadded",[Vt(e.body,t)],["vcenter"]);return new Bt("mrow",[r])}}),mt({type:"verb",names:["\\verb"],numArgs:0,allowedInText:!0,handler(e,t,r){throw new n("\\verb ended by end of line instead of matching delimiter")},htmlBuilder(e,t){const r=Dn(e),n=[],o=t.havingStyle(t.style.text());for(let t=0;te.body.replace(/ /g,e.star?"\u2423":"\xa0");var Ln=at;const Pn="[ \r\n\t]",Fn="(\\\\[a-zA-Z@]+)"+Pn+"*",Vn="[\u0300-\u036f]",Gn=new RegExp(Vn+"+$"),Un="("+Pn+"+)|\\\\(\n|[ \r\t]+\n?)[ \r\t]*|([!-\\[\\]-\u2027\u202a-\ud7ff\uf900-\uffff]"+Vn+"*|[\ud800-\udbff][\udc00-\udfff]"+Vn+"*|\\\\verb\\*([^]).*?\\4|\\\\verb([^*a-zA-Z]).*?\\5|"+Fn+"|\\\\[^\ud800-\udfff])";class Xn{constructor(e,t){this.input=void 0,this.settings=void 0,this.tokenRegex=void 0,this.catcodes=void 0,this.input=e,this.settings=t,this.tokenRegex=new RegExp(Un,"g"),this.catcodes={"%":14,"~":13}}setCatcode(e,t){this.catcodes[e]=t}lex(){const e=this.input,t=this.tokenRegex.lastIndex;if(t===e.length)return new en("EOF",new Qr(this,t,t));const r=this.tokenRegex.exec(e);if(null===r||r.index!==t)throw new n("Unexpected character: '"+e[t]+"'",new en(e[t],new Qr(this,t,t+1)));const o=r[6]||r[3]||(r[2]?"\\ ":" ");if(14===this.catcodes[o]){const t=e.indexOf("\n",this.tokenRegex.lastIndex);return-1===t?(this.tokenRegex.lastIndex=e.length,this.settings.reportNonstrict("commentAtEnd","% comment has no terminating newline; LaTeX would fail because of commenting the end of math mode (e.g. $)")):this.tokenRegex.lastIndex=t+1,this.lex()}return new en(o,new Qr(this,t,this.tokenRegex.lastIndex))}}class Yn{constructor(e,t){void 0===e&&(e={}),void 0===t&&(t={}),this.current=void 0,this.builtins=void 0,this.undefStack=void 0,this.current=t,this.builtins=e,this.undefStack=[]}beginGroup(){this.undefStack.push({})}endGroup(){if(0===this.undefStack.length)throw new n("Unbalanced namespace destruction: attempt to pop global namespace; please report this as a bug");const e=this.undefStack.pop();for(const t in e)e.hasOwnProperty(t)&&(null==e[t]?delete this.current[t]:this.current[t]=e[t])}endGroups(){for(;this.undefStack.length>0;)this.endGroup()}has(e){return this.current.hasOwnProperty(e)||this.builtins.hasOwnProperty(e)}get(e){return this.current.hasOwnProperty(e)?this.current[e]:this.builtins[e]}set(e,t,r){if(void 0===r&&(r=!1),r){for(let t=0;t0&&(this.undefStack[this.undefStack.length-1][e]=t)}else{const t=this.undefStack[this.undefStack.length-1];t&&!t.hasOwnProperty(e)&&(t[e]=this.current[e])}null==t?delete this.current[e]:this.current[e]=t}}var jn=Kr;Jr("\\noexpand",function(e){const t=e.popToken();return e.isExpandable(t.text)&&(t.noexpand=!0,t.treatAsRelax=!0),{tokens:[t],numArgs:0}}),Jr("\\expandafter",function(e){const t=e.popToken();return e.expandOnce(!0),{tokens:[t],numArgs:0}}),Jr("\\@firstoftwo",function(e){return{tokens:e.consumeArgs(2)[0],numArgs:0}}),Jr("\\@secondoftwo",function(e){return{tokens:e.consumeArgs(2)[1],numArgs:0}}),Jr("\\@ifnextchar",function(e){const t=e.consumeArgs(3);e.consumeSpaces();const r=e.future();return 1===t[0].length&&t[0][0].text===r.text?{tokens:t[1],numArgs:0}:{tokens:t[2],numArgs:0}}),Jr("\\@ifstar","\\@ifnextchar *{\\@firstoftwo{#1}}"),Jr("\\TextOrMath",function(e){const t=e.consumeArgs(2);return"text"===e.mode?{tokens:t[0],numArgs:0}:{tokens:t[1],numArgs:0}});const Wn={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,A:10,b:11,B:11,c:12,C:12,d:13,D:13,e:14,E:14,f:15,F:15};Jr("\\char",function(e){let t,r=e.popToken(),o=0;if("'"===r.text)t=8,r=e.popToken();else if('"'===r.text)t=16,r=e.popToken();else if("`"===r.text)if(r=e.popToken(),"\\"===r.text[0])o=r.text.charCodeAt(1);else{if("EOF"===r.text)throw new n("\\char` missing argument");o=r.text.charCodeAt(0)}else t=10;if(t){if(o=Wn[r.text],null==o||o>=t)throw new n("Invalid base-"+t+" digit "+r.text);let s;for(;null!=(s=Wn[e.future().text])&&s{let s=e.consumeArg().tokens;if(1!==s.length)throw new n("\\newcommand's first argument must be a macro name");const i=s[0].text,l=e.isDefined(i);if(l&&!t)throw new n("\\newcommand{"+i+"} attempting to redefine "+i+"; use \\renewcommand");if(!l&&!r)throw new n("\\renewcommand{"+i+"} when command "+i+" does not yet exist; use \\newcommand");let a=0;if(s=e.consumeArg().tokens,1===s.length&&"["===s[0].text){let t="",r=e.expandNextToken();for(;"]"!==r.text&&"EOF"!==r.text;)t+=r.text,r=e.expandNextToken();if(!t.match(/^\s*[0-9]+\s*$/))throw new n("Invalid number of arguments: "+t);a=parseInt(t),s=e.consumeArg().tokens}return l&&o||e.macros.set(i,{tokens:s,numArgs:a}),""};Jr("\\newcommand",e=>_n(e,!1,!0,!1)),Jr("\\renewcommand",e=>_n(e,!0,!1,!1)),Jr("\\providecommand",e=>_n(e,!0,!0,!0)),Jr("\\message",e=>{const t=e.consumeArgs(1)[0];return console.log(t.reverse().map(e=>e.text).join("")),""}),Jr("\\errmessage",e=>{const t=e.consumeArgs(1)[0];return console.error(t.reverse().map(e=>e.text).join("")),""}),Jr("\\show",e=>{const t=e.popToken(),r=t.text;return console.log(t,e.macros.get(r),Ln[r],ne.math[r],ne.text[r]),""}),Jr("\\bgroup","{"),Jr("\\egroup","}"),Jr("~","\\nobreakspace"),Jr("\\lq","`"),Jr("\\rq","'"),Jr("\\aa","\\r a"),Jr("\\AA","\\r A"),Jr("\\textcopyright","\\html@mathml{\\textcircled{c}}{\\char`\xa9}"),Jr("\\copyright","\\TextOrMath{\\textcopyright}{\\text{\\textcopyright}}"),Jr("\\textregistered","\\html@mathml{\\textcircled{\\scriptsize R}}{\\char`\xae}"),Jr("\u212c","\\mathscr{B}"),Jr("\u2130","\\mathscr{E}"),Jr("\u2131","\\mathscr{F}"),Jr("\u210b","\\mathscr{H}"),Jr("\u2110","\\mathscr{I}"),Jr("\u2112","\\mathscr{L}"),Jr("\u2133","\\mathscr{M}"),Jr("\u211b","\\mathscr{R}"),Jr("\u212d","\\mathfrak{C}"),Jr("\u210c","\\mathfrak{H}"),Jr("\u2128","\\mathfrak{Z}"),Jr("\\Bbbk","\\Bbb{k}"),Jr("\\llap","\\mathllap{\\textrm{#1}}"),Jr("\\rlap","\\mathrlap{\\textrm{#1}}"),Jr("\\clap","\\mathclap{\\textrm{#1}}"),Jr("\\mathstrut","\\vphantom{(}"),Jr("\\underbar","\\underline{\\text{#1}}"),Jr("\\not",'\\html@mathml{\\mathrel{\\mathrlap\\@not}\\nobreak}{\\char"338}'),Jr("\\neq","\\html@mathml{\\mathrel{\\not=}}{\\mathrel{\\char`\u2260}}"),Jr("\\ne","\\neq"),Jr("\u2260","\\neq"),Jr("\\notin","\\html@mathml{\\mathrel{{\\in}\\mathllap{/\\mskip1mu}}}{\\mathrel{\\char`\u2209}}"),Jr("\u2209","\\notin"),Jr("\u2258","\\html@mathml{\\mathrel{=\\kern{-1em}\\raisebox{0.4em}{$\\scriptsize\\frown$}}}{\\mathrel{\\char`\u2258}}"),Jr("\u2259","\\html@mathml{\\stackrel{\\tiny\\wedge}{=}}{\\mathrel{\\char`\u2258}}"),Jr("\u225a","\\html@mathml{\\stackrel{\\tiny\\vee}{=}}{\\mathrel{\\char`\u225a}}"),Jr("\u225b","\\html@mathml{\\stackrel{\\scriptsize\\star}{=}}{\\mathrel{\\char`\u225b}}"),Jr("\u225d","\\html@mathml{\\stackrel{\\tiny\\mathrm{def}}{=}}{\\mathrel{\\char`\u225d}}"),Jr("\u225e","\\html@mathml{\\stackrel{\\tiny\\mathrm{m}}{=}}{\\mathrel{\\char`\u225e}}"),Jr("\u225f","\\html@mathml{\\stackrel{\\tiny?}{=}}{\\mathrel{\\char`\u225f}}"),Jr("\u27c2","\\perp"),Jr("\u203c","\\mathclose{!\\mkern-0.8mu!}"),Jr("\u220c","\\notni"),Jr("\u231c","\\ulcorner"),Jr("\u231d","\\urcorner"),Jr("\u231e","\\llcorner"),Jr("\u231f","\\lrcorner"),Jr("\xa9","\\copyright"),Jr("\xae","\\textregistered"),Jr("\\ulcorner",'\\html@mathml{\\@ulcorner}{\\mathop{\\char"231c}}'),Jr("\\urcorner",'\\html@mathml{\\@urcorner}{\\mathop{\\char"231d}}'),Jr("\\llcorner",'\\html@mathml{\\@llcorner}{\\mathop{\\char"231e}}'),Jr("\\lrcorner",'\\html@mathml{\\@lrcorner}{\\mathop{\\char"231f}}'),Jr("\\vdots","{\\varvdots\\rule{0pt}{15pt}}"),Jr("\u22ee","\\vdots"),Jr("\\varGamma","\\mathit{\\Gamma}"),Jr("\\varDelta","\\mathit{\\Delta}"),Jr("\\varTheta","\\mathit{\\Theta}"),Jr("\\varLambda","\\mathit{\\Lambda}"),Jr("\\varXi","\\mathit{\\Xi}"),Jr("\\varPi","\\mathit{\\Pi}"),Jr("\\varSigma","\\mathit{\\Sigma}"),Jr("\\varUpsilon","\\mathit{\\Upsilon}"),Jr("\\varPhi","\\mathit{\\Phi}"),Jr("\\varPsi","\\mathit{\\Psi}"),Jr("\\varOmega","\\mathit{\\Omega}"),Jr("\\substack","\\begin{subarray}{c}#1\\end{subarray}"),Jr("\\colon","\\nobreak\\mskip2mu\\mathpunct{}\\mathchoice{\\mkern-3mu}{\\mkern-3mu}{}{}{:}\\mskip6mu\\relax"),Jr("\\boxed","\\fbox{$\\displaystyle{#1}$}"),Jr("\\iff","\\DOTSB\\;\\Longleftrightarrow\\;"),Jr("\\implies","\\DOTSB\\;\\Longrightarrow\\;"),Jr("\\impliedby","\\DOTSB\\;\\Longleftarrow\\;"),Jr("\\dddot","{\\overset{\\raisebox{-0.1ex}{\\normalsize ...}}{#1}}"),Jr("\\ddddot","{\\overset{\\raisebox{-0.1ex}{\\normalsize ....}}{#1}}");const $n={",":"\\dotsc","\\not":"\\dotsb","+":"\\dotsb","=":"\\dotsb","<":"\\dotsb",">":"\\dotsb","-":"\\dotsb","*":"\\dotsb",":":"\\dotsb","\\DOTSB":"\\dotsb","\\coprod":"\\dotsb","\\bigvee":"\\dotsb","\\bigwedge":"\\dotsb","\\biguplus":"\\dotsb","\\bigcap":"\\dotsb","\\bigcup":"\\dotsb","\\prod":"\\dotsb","\\sum":"\\dotsb","\\bigotimes":"\\dotsb","\\bigoplus":"\\dotsb","\\bigodot":"\\dotsb","\\bigsqcup":"\\dotsb","\\And":"\\dotsb","\\longrightarrow":"\\dotsb","\\Longrightarrow":"\\dotsb","\\longleftarrow":"\\dotsb","\\Longleftarrow":"\\dotsb","\\longleftrightarrow":"\\dotsb","\\Longleftrightarrow":"\\dotsb","\\mapsto":"\\dotsb","\\longmapsto":"\\dotsb","\\hookrightarrow":"\\dotsb","\\doteq":"\\dotsb","\\mathbin":"\\dotsb","\\mathrel":"\\dotsb","\\relbar":"\\dotsb","\\Relbar":"\\dotsb","\\xrightarrow":"\\dotsb","\\xleftarrow":"\\dotsb","\\DOTSI":"\\dotsi","\\int":"\\dotsi","\\oint":"\\dotsi","\\iint":"\\dotsi","\\iiint":"\\dotsi","\\iiiint":"\\dotsi","\\idotsint":"\\dotsi","\\DOTSX":"\\dotsx"},Zn=new Set(["bin","rel"]);Jr("\\dots",function(e){let t="\\dotso";const r=e.expandAfterFuture().text;return r in $n?t=$n[r]:("\\not"===r.slice(0,4)||r in ne.math&&Zn.has(ne.math[r].group))&&(t="\\dotsb"),t});const Kn={")":!0,"]":!0,"\\rbrack":!0,"\\}":!0,"\\rbrace":!0,"\\rangle":!0,"\\rceil":!0,"\\rfloor":!0,"\\rgroup":!0,"\\rmoustache":!0,"\\right":!0,"\\bigr":!0,"\\biggr":!0,"\\Bigr":!0,"\\Biggr":!0,$:!0,";":!0,".":!0,",":!0};Jr("\\dotso",function(e){return e.future().text in Kn?"\\ldots\\,":"\\ldots"}),Jr("\\dotsc",function(e){const t=e.future().text;return t in Kn&&","!==t?"\\ldots\\,":"\\ldots"}),Jr("\\cdots",function(e){return e.future().text in Kn?"\\@cdots\\,":"\\@cdots"}),Jr("\\dotsb","\\cdots"),Jr("\\dotsm","\\cdots"),Jr("\\dotsi","\\!\\cdots"),Jr("\\dotsx","\\ldots\\,"),Jr("\\DOTSI","\\relax"),Jr("\\DOTSB","\\relax"),Jr("\\DOTSX","\\relax"),Jr("\\tmspace","\\TextOrMath{\\kern#1#3}{\\mskip#1#2}\\relax"),Jr("\\,","\\tmspace+{3mu}{.1667em}"),Jr("\\thinspace","\\,"),Jr("\\>","\\mskip{4mu}"),Jr("\\:","\\tmspace+{4mu}{.2222em}"),Jr("\\medspace","\\:"),Jr("\\;","\\tmspace+{5mu}{.2777em}"),Jr("\\thickspace","\\;"),Jr("\\!","\\tmspace-{3mu}{.1667em}"),Jr("\\negthinspace","\\!"),Jr("\\negmedspace","\\tmspace-{4mu}{.2222em}"),Jr("\\negthickspace","\\tmspace-{5mu}{.277em}"),Jr("\\enspace","\\kern.5em "),Jr("\\enskip","\\hskip.5em\\relax"),Jr("\\quad","\\hskip1em\\relax"),Jr("\\qquad","\\hskip2em\\relax"),Jr("\\tag","\\@ifstar\\tag@literal\\tag@paren"),Jr("\\tag@paren","\\tag@literal{({#1})}"),Jr("\\tag@literal",e=>{if(e.macros.get("\\df@tag"))throw new n("Multiple \\tag");return"\\gdef\\df@tag{\\text{#1}}"}),Jr("\\bmod","\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}\\mathbin{\\rm mod}\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}"),Jr("\\pod","\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern8mu}{\\mkern8mu}{\\mkern8mu}(#1)"),Jr("\\pmod","\\pod{{\\rm mod}\\mkern6mu#1}"),Jr("\\mod","\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}{\\rm mod}\\,\\,#1"),Jr("\\newline","\\\\\\relax"),Jr("\\TeX","\\textrm{\\html@mathml{T\\kern-.1667em\\raisebox{-.5ex}{E}\\kern-.125emX}{TeX}}");const Jn=O(K["Main-Regular"]["T".charCodeAt(0)][1]-.7*K["Main-Regular"]["A".charCodeAt(0)][1]);Jr("\\LaTeX","\\textrm{\\html@mathml{L\\kern-.36em\\raisebox{"+Jn+"}{\\scriptstyle A}\\kern-.15em\\TeX}{LaTeX}}"),Jr("\\KaTeX","\\textrm{\\html@mathml{K\\kern-.17em\\raisebox{"+Jn+"}{\\scriptstyle A}\\kern-.15em\\TeX}{KaTeX}}"),Jr("\\hspace","\\@ifstar\\@hspacer\\@hspace"),Jr("\\@hspace","\\hskip #1\\relax"),Jr("\\@hspacer","\\rule{0pt}{0pt}\\hskip #1\\relax"),Jr("\\ordinarycolon",":"),Jr("\\vcentcolon","\\mathrel{\\mathop\\ordinarycolon}"),Jr("\\dblcolon",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-.9mu}\\vcentcolon}}{\\mathop{\\char"2237}}'),Jr("\\coloneqq",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}=}}{\\mathop{\\char"2254}}'),Jr("\\Coloneqq",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}=}}{\\mathop{\\char"2237\\char"3d}}'),Jr("\\coloneq",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}{\\mathop{\\char"3a\\char"2212}}'),Jr("\\Coloneq",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}{\\mathop{\\char"2237\\char"2212}}'),Jr("\\eqqcolon",'\\html@mathml{\\mathrel{=\\mathrel{\\mkern-1.2mu}\\vcentcolon}}{\\mathop{\\char"2255}}'),Jr("\\Eqqcolon",'\\html@mathml{\\mathrel{=\\mathrel{\\mkern-1.2mu}\\dblcolon}}{\\mathop{\\char"3d\\char"2237}}'),Jr("\\eqcolon",'\\html@mathml{\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\vcentcolon}}{\\mathop{\\char"2239}}'),Jr("\\Eqcolon",'\\html@mathml{\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\dblcolon}}{\\mathop{\\char"2212\\char"2237}}'),Jr("\\colonapprox",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\approx}}{\\mathop{\\char"3a\\char"2248}}'),Jr("\\Colonapprox",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\approx}}{\\mathop{\\char"2237\\char"2248}}'),Jr("\\colonsim",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\sim}}{\\mathop{\\char"3a\\char"223c}}'),Jr("\\Colonsim",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\sim}}{\\mathop{\\char"2237\\char"223c}}'),Jr("\u2237","\\dblcolon"),Jr("\u2239","\\eqcolon"),Jr("\u2254","\\coloneqq"),Jr("\u2255","\\eqqcolon"),Jr("\u2a74","\\Coloneqq"),Jr("\\ratio","\\vcentcolon"),Jr("\\coloncolon","\\dblcolon"),Jr("\\colonequals","\\coloneqq"),Jr("\\coloncolonequals","\\Coloneqq"),Jr("\\equalscolon","\\eqqcolon"),Jr("\\equalscoloncolon","\\Eqqcolon"),Jr("\\colonminus","\\coloneq"),Jr("\\coloncolonminus","\\Coloneq"),Jr("\\minuscolon","\\eqcolon"),Jr("\\minuscoloncolon","\\Eqcolon"),Jr("\\coloncolonapprox","\\Colonapprox"),Jr("\\coloncolonsim","\\Colonsim"),Jr("\\simcolon","\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\vcentcolon}"),Jr("\\simcoloncolon","\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\dblcolon}"),Jr("\\approxcolon","\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\vcentcolon}"),Jr("\\approxcoloncolon","\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\dblcolon}"),Jr("\\notni","\\html@mathml{\\not\\ni}{\\mathrel{\\char`\u220c}}"),Jr("\\limsup","\\DOTSB\\operatorname*{lim\\,sup}"),Jr("\\liminf","\\DOTSB\\operatorname*{lim\\,inf}"),Jr("\\injlim","\\DOTSB\\operatorname*{inj\\,lim}"),Jr("\\projlim","\\DOTSB\\operatorname*{proj\\,lim}"),Jr("\\varlimsup","\\DOTSB\\operatorname*{\\overline{lim}}"),Jr("\\varliminf","\\DOTSB\\operatorname*{\\underline{lim}}"),Jr("\\varinjlim","\\DOTSB\\operatorname*{\\underrightarrow{lim}}"),Jr("\\varprojlim","\\DOTSB\\operatorname*{\\underleftarrow{lim}}"),Jr("\\gvertneqq","\\html@mathml{\\@gvertneqq}{\u2269}"),Jr("\\lvertneqq","\\html@mathml{\\@lvertneqq}{\u2268}"),Jr("\\ngeqq","\\html@mathml{\\@ngeqq}{\u2271}"),Jr("\\ngeqslant","\\html@mathml{\\@ngeqslant}{\u2271}"),Jr("\\nleqq","\\html@mathml{\\@nleqq}{\u2270}"),Jr("\\nleqslant","\\html@mathml{\\@nleqslant}{\u2270}"),Jr("\\nshortmid","\\html@mathml{\\@nshortmid}{\u2224}"),Jr("\\nshortparallel","\\html@mathml{\\@nshortparallel}{\u2226}"),Jr("\\nsubseteqq","\\html@mathml{\\@nsubseteqq}{\u2288}"),Jr("\\nsupseteqq","\\html@mathml{\\@nsupseteqq}{\u2289}"),Jr("\\varsubsetneq","\\html@mathml{\\@varsubsetneq}{\u228a}"),Jr("\\varsubsetneqq","\\html@mathml{\\@varsubsetneqq}{\u2acb}"),Jr("\\varsupsetneq","\\html@mathml{\\@varsupsetneq}{\u228b}"),Jr("\\varsupsetneqq","\\html@mathml{\\@varsupsetneqq}{\u2acc}"),Jr("\\imath","\\html@mathml{\\@imath}{\u0131}"),Jr("\\jmath","\\html@mathml{\\@jmath}{\u0237}"),Jr("\\llbracket","\\html@mathml{\\mathopen{[\\mkern-3.2mu[}}{\\mathopen{\\char`\u27e6}}"),Jr("\\rrbracket","\\html@mathml{\\mathclose{]\\mkern-3.2mu]}}{\\mathclose{\\char`\u27e7}}"),Jr("\u27e6","\\llbracket"),Jr("\u27e7","\\rrbracket"),Jr("\\lBrace","\\html@mathml{\\mathopen{\\{\\mkern-3.2mu[}}{\\mathopen{\\char`\u2983}}"),Jr("\\rBrace","\\html@mathml{\\mathclose{]\\mkern-3.2mu\\}}}{\\mathclose{\\char`\u2984}}"),Jr("\u2983","\\lBrace"),Jr("\u2984","\\rBrace"),Jr("\\minuso","\\mathbin{\\html@mathml{{\\mathrlap{\\mathchoice{\\kern{0.145em}}{\\kern{0.145em}}{\\kern{0.1015em}}{\\kern{0.0725em}}\\circ}{-}}}{\\char`\u29b5}}"),Jr("\u29b5","\\minuso"),Jr("\\darr","\\downarrow"),Jr("\\dArr","\\Downarrow"),Jr("\\Darr","\\Downarrow"),Jr("\\lang","\\langle"),Jr("\\rang","\\rangle"),Jr("\\uarr","\\uparrow"),Jr("\\uArr","\\Uparrow"),Jr("\\Uarr","\\Uparrow"),Jr("\\N","\\mathbb{N}"),Jr("\\R","\\mathbb{R}"),Jr("\\Z","\\mathbb{Z}"),Jr("\\alef","\\aleph"),Jr("\\alefsym","\\aleph"),Jr("\\Alpha","\\mathrm{A}"),Jr("\\Beta","\\mathrm{B}"),Jr("\\bull","\\bullet"),Jr("\\Chi","\\mathrm{X}"),Jr("\\clubs","\\clubsuit"),Jr("\\cnums","\\mathbb{C}"),Jr("\\Complex","\\mathbb{C}"),Jr("\\Dagger","\\ddagger"),Jr("\\diamonds","\\diamondsuit"),Jr("\\empty","\\emptyset"),Jr("\\Epsilon","\\mathrm{E}"),Jr("\\Eta","\\mathrm{H}"),Jr("\\exist","\\exists"),Jr("\\harr","\\leftrightarrow"),Jr("\\hArr","\\Leftrightarrow"),Jr("\\Harr","\\Leftrightarrow"),Jr("\\hearts","\\heartsuit"),Jr("\\image","\\Im"),Jr("\\infin","\\infty"),Jr("\\Iota","\\mathrm{I}"),Jr("\\isin","\\in"),Jr("\\Kappa","\\mathrm{K}"),Jr("\\larr","\\leftarrow"),Jr("\\lArr","\\Leftarrow"),Jr("\\Larr","\\Leftarrow"),Jr("\\lrarr","\\leftrightarrow"),Jr("\\lrArr","\\Leftrightarrow"),Jr("\\Lrarr","\\Leftrightarrow"),Jr("\\Mu","\\mathrm{M}"),Jr("\\natnums","\\mathbb{N}"),Jr("\\Nu","\\mathrm{N}"),Jr("\\Omicron","\\mathrm{O}"),Jr("\\plusmn","\\pm"),Jr("\\rarr","\\rightarrow"),Jr("\\rArr","\\Rightarrow"),Jr("\\Rarr","\\Rightarrow"),Jr("\\real","\\Re"),Jr("\\reals","\\mathbb{R}"),Jr("\\Reals","\\mathbb{R}"),Jr("\\Rho","\\mathrm{P}"),Jr("\\sdot","\\cdot"),Jr("\\sect","\\S"),Jr("\\spades","\\spadesuit"),Jr("\\sub","\\subset"),Jr("\\sube","\\subseteq"),Jr("\\supe","\\supseteq"),Jr("\\Tau","\\mathrm{T}"),Jr("\\thetasym","\\vartheta"),Jr("\\weierp","\\wp"),Jr("\\Zeta","\\mathrm{Z}"),Jr("\\argmin","\\DOTSB\\operatorname*{arg\\,min}"),Jr("\\argmax","\\DOTSB\\operatorname*{arg\\,max}"),Jr("\\plim","\\DOTSB\\mathop{\\operatorname{plim}}\\limits"),Jr("\\bra","\\mathinner{\\langle{#1}|}"),Jr("\\ket","\\mathinner{|{#1}\\rangle}"),Jr("\\braket","\\mathinner{\\langle{#1}\\rangle}"),Jr("\\Bra","\\left\\langle#1\\right|"),Jr("\\Ket","\\left|#1\\right\\rangle");const Qn=e=>t=>{const r=t.consumeArg().tokens,n=t.consumeArg().tokens,o=t.consumeArg().tokens,s=t.consumeArg().tokens,i=t.macros.get("|"),l=t.macros.get("\\|");t.macros.beginGroup();const a=t=>r=>{e&&(r.macros.set("|",i),o.length&&r.macros.set("\\|",l));let s=t;if(!t&&o.length){"|"===r.future().text&&(r.popToken(),s=!0)}return{tokens:s?o:n,numArgs:0}};t.macros.set("|",a(!1)),o.length&&t.macros.set("\\|",a(!0));const c=t.consumeArg().tokens,h=t.expandTokens([...s,...c,...r]);return t.macros.endGroup(),{tokens:h.reverse(),numArgs:0}};Jr("\\bra@ket",Qn(!1)),Jr("\\bra@set",Qn(!0)),Jr("\\Braket","\\bra@ket{\\left\\langle}{\\,\\middle\\vert\\,}{\\,\\middle\\vert\\,}{\\right\\rangle}"),Jr("\\Set","\\bra@set{\\left\\{\\:}{\\;\\middle\\vert\\;}{\\;\\middle\\Vert\\;}{\\:\\right\\}}"),Jr("\\set","\\bra@set{\\{\\,}{\\mid}{}{\\,\\}}"),Jr("\\angln","{\\angl n}"),Jr("\\blue","\\textcolor{##6495ed}{#1}"),Jr("\\orange","\\textcolor{##ffa500}{#1}"),Jr("\\pink","\\textcolor{##ff00af}{#1}"),Jr("\\red","\\textcolor{##df0030}{#1}"),Jr("\\green","\\textcolor{##28ae7b}{#1}"),Jr("\\gray","\\textcolor{gray}{#1}"),Jr("\\purple","\\textcolor{##9d38bd}{#1}"),Jr("\\blueA","\\textcolor{##ccfaff}{#1}"),Jr("\\blueB","\\textcolor{##80f6ff}{#1}"),Jr("\\blueC","\\textcolor{##63d9ea}{#1}"),Jr("\\blueD","\\textcolor{##11accd}{#1}"),Jr("\\blueE","\\textcolor{##0c7f99}{#1}"),Jr("\\tealA","\\textcolor{##94fff5}{#1}"),Jr("\\tealB","\\textcolor{##26edd5}{#1}"),Jr("\\tealC","\\textcolor{##01d1c1}{#1}"),Jr("\\tealD","\\textcolor{##01a995}{#1}"),Jr("\\tealE","\\textcolor{##208170}{#1}"),Jr("\\greenA","\\textcolor{##b6ffb0}{#1}"),Jr("\\greenB","\\textcolor{##8af281}{#1}"),Jr("\\greenC","\\textcolor{##74cf70}{#1}"),Jr("\\greenD","\\textcolor{##1fab54}{#1}"),Jr("\\greenE","\\textcolor{##0d923f}{#1}"),Jr("\\goldA","\\textcolor{##ffd0a9}{#1}"),Jr("\\goldB","\\textcolor{##ffbb71}{#1}"),Jr("\\goldC","\\textcolor{##ff9c39}{#1}"),Jr("\\goldD","\\textcolor{##e07d10}{#1}"),Jr("\\goldE","\\textcolor{##a75a05}{#1}"),Jr("\\redA","\\textcolor{##fca9a9}{#1}"),Jr("\\redB","\\textcolor{##ff8482}{#1}"),Jr("\\redC","\\textcolor{##f9685d}{#1}"),Jr("\\redD","\\textcolor{##e84d39}{#1}"),Jr("\\redE","\\textcolor{##bc2612}{#1}"),Jr("\\maroonA","\\textcolor{##ffbde0}{#1}"),Jr("\\maroonB","\\textcolor{##ff92c6}{#1}"),Jr("\\maroonC","\\textcolor{##ed5fa6}{#1}"),Jr("\\maroonD","\\textcolor{##ca337c}{#1}"),Jr("\\maroonE","\\textcolor{##9e034e}{#1}"),Jr("\\purpleA","\\textcolor{##ddd7ff}{#1}"),Jr("\\purpleB","\\textcolor{##c6b9fc}{#1}"),Jr("\\purpleC","\\textcolor{##aa87ff}{#1}"),Jr("\\purpleD","\\textcolor{##7854ab}{#1}"),Jr("\\purpleE","\\textcolor{##543b78}{#1}"),Jr("\\mintA","\\textcolor{##f5f9e8}{#1}"),Jr("\\mintB","\\textcolor{##edf2df}{#1}"),Jr("\\mintC","\\textcolor{##e0e5cc}{#1}"),Jr("\\grayA","\\textcolor{##f6f7f7}{#1}"),Jr("\\grayB","\\textcolor{##f0f1f2}{#1}"),Jr("\\grayC","\\textcolor{##e3e5e6}{#1}"),Jr("\\grayD","\\textcolor{##d6d8da}{#1}"),Jr("\\grayE","\\textcolor{##babec2}{#1}"),Jr("\\grayF","\\textcolor{##888d93}{#1}"),Jr("\\grayG","\\textcolor{##626569}{#1}"),Jr("\\grayH","\\textcolor{##3b3e40}{#1}"),Jr("\\grayI","\\textcolor{##21242c}{#1}"),Jr("\\kaBlue","\\textcolor{##314453}{#1}"),Jr("\\kaGreen","\\textcolor{##71B307}{#1}");const eo={"^":!0,_:!0,"\\limits":!0,"\\nolimits":!0};class to{constructor(e,t,r){this.settings=void 0,this.expansionCount=void 0,this.lexer=void 0,this.macros=void 0,this.stack=void 0,this.mode=void 0,this.settings=t,this.expansionCount=0,this.feed(e),this.macros=new Yn(jn,t.macros),this.mode=r,this.stack=[]}feed(e){this.lexer=new Xn(e,this.settings)}switchMode(e){this.mode=e}beginGroup(){this.macros.beginGroup()}endGroup(){this.macros.endGroup()}endGroups(){this.macros.endGroups()}future(){return 0===this.stack.length&&this.pushToken(this.lexer.lex()),this.stack[this.stack.length-1]}popToken(){return this.future(),this.stack.pop()}pushToken(e){this.stack.push(e)}pushTokens(e){this.stack.push(...e)}scanArgument(e){let t,r,n;if(e){if(this.consumeSpaces(),"["!==this.future().text)return null;t=this.popToken(),({tokens:n,end:r}=this.consumeArg(["]"]))}else({tokens:n,start:t,end:r}=this.consumeArg());return this.pushToken(new en("EOF",r.loc)),this.pushTokens(n),new en("",Qr.range(t,r))}consumeSpaces(){for(;;){if(" "!==this.future().text)break;this.stack.pop()}}consumeArg(e){const t=[],r=e&&e.length>0;r||this.consumeSpaces();const o=this.future();let s,i=0,l=0;do{if(s=this.popToken(),t.push(s),"{"===s.text)++i;else if("}"===s.text){if(--i,-1===i)throw new n("Extra }",s)}else if("EOF"===s.text)throw new n("Unexpected end of input in a macro argument, expected '"+(e&&r?e[l]:"}")+"'",s);if(e&&r)if((0===i||1===i&&"{"===e[l])&&s.text===e[l]){if(++l,l===e.length){t.splice(-l,l);break}}else l=0}while(0!==i||r);return"{"===o.text&&"}"===t[t.length-1].text&&(t.pop(),t.shift()),t.reverse(),{tokens:t,start:o,end:s}}consumeArgs(e,t){if(t){if(t.length!==e+1)throw new n("The length of delimiters doesn't match the number of args!");const r=t[0];for(let e=0;ethis.settings.maxExpand)throw new n("Too many expansions: infinite loop or need to increase maxExpand setting")}expandOnce(e){const t=this.popToken(),r=t.text,o=t.noexpand?null:this._getExpansion(r);if(null==o||e&&o.unexpandable){if(e&&null==o&&"\\"===r[0]&&!this.isDefined(r))throw new n("Undefined control sequence: "+r);return this.pushToken(t),!1}this.countExpansion(1);let s=o.tokens;const i=this.consumeArgs(o.numArgs,o.delimiters);if(o.numArgs){s=s.slice();for(let e=s.length-1;e>=0;--e){let t=s[e];if("#"===t.text){if(0===e)throw new n("Incomplete placeholder at end of macro body",t);if(t=s[--e],"#"===t.text)s.splice(e+1,1);else{if(!/^[1-9]$/.test(t.text))throw new n("Not a valid argument number",t);s.splice(e,2,...i[+t.text-1])}}}}return this.pushTokens(s),s.length}expandAfterFuture(){return this.expandOnce(),this.future()}expandNextToken(){for(;;)if(!1===this.expandOnce()){const e=this.stack.pop();return e.treatAsRelax&&(e.text="\\relax"),e}}expandMacro(e){return this.macros.has(e)?this.expandTokens([new en(e)]):void 0}expandTokens(e){const t=[],r=this.stack.length;for(this.pushTokens(e);this.stack.length>r;)if(!1===this.expandOnce(!0)){const e=this.stack.pop();e.treatAsRelax&&(e.noexpand=!1,e.treatAsRelax=!1),t.push(e)}return this.countExpansion(t.length),t}expandMacroAsText(e){const t=this.expandMacro(e);return t?t.map(e=>e.text).join(""):t}_getExpansion(e){const t=this.macros.get(e);if(null==t)return t;if(1===e.length){const t=this.lexer.catcodes[e];if(null!=t&&13!==t)return}const r="function"==typeof t?t(this):t;if("string"==typeof r){let e=0;if(r.includes("#")){const t=r.replace(/##/g,"");for(;t.includes("#"+(e+1));)++e}const t=new Xn(r,this.settings),n=[];let o=t.lex();for(;"EOF"!==o.text;)n.push(o),o=t.lex();n.reverse();return{tokens:n,numArgs:e}}return r}isDefined(e){return this.macros.has(e)||Ln.hasOwnProperty(e)||ne.math.hasOwnProperty(e)||ne.text.hasOwnProperty(e)||eo.hasOwnProperty(e)}isExpandable(e){const t=this.macros.get(e);return null!=t?"string"==typeof t||"function"==typeof t||!t.unexpandable:Ln.hasOwnProperty(e)&&!Ln[e].primitive}}const ro=/^[\u208a\u208b\u208c\u208d\u208e\u2080\u2081\u2082\u2083\u2084\u2085\u2086\u2087\u2088\u2089\u2090\u2091\u2095\u1d62\u2c7c\u2096\u2097\u2098\u2099\u2092\u209a\u1d63\u209b\u209c\u1d64\u1d65\u2093\u1d66\u1d67\u1d68\u1d69\u1d6a]/,no=Object.freeze({"\u208a":"+","\u208b":"-","\u208c":"=","\u208d":"(","\u208e":")","\u2080":"0","\u2081":"1","\u2082":"2","\u2083":"3","\u2084":"4","\u2085":"5","\u2086":"6","\u2087":"7","\u2088":"8","\u2089":"9","\u2090":"a","\u2091":"e","\u2095":"h","\u1d62":"i","\u2c7c":"j","\u2096":"k","\u2097":"l","\u2098":"m","\u2099":"n","\u2092":"o","\u209a":"p","\u1d63":"r","\u209b":"s","\u209c":"t","\u1d64":"u","\u1d65":"v","\u2093":"x","\u1d66":"\u03b2","\u1d67":"\u03b3","\u1d68":"\u03c1","\u1d69":"\u03d5","\u1d6a":"\u03c7","\u207a":"+","\u207b":"-","\u207c":"=","\u207d":"(","\u207e":")","\u2070":"0","\xb9":"1","\xb2":"2","\xb3":"3","\u2074":"4","\u2075":"5","\u2076":"6","\u2077":"7","\u2078":"8","\u2079":"9","\u1d2c":"A","\u1d2e":"B","\u1d30":"D","\u1d31":"E","\u1d33":"G","\u1d34":"H","\u1d35":"I","\u1d36":"J","\u1d37":"K","\u1d38":"L","\u1d39":"M","\u1d3a":"N","\u1d3c":"O","\u1d3e":"P","\u1d3f":"R","\u1d40":"T","\u1d41":"U","\u2c7d":"V","\u1d42":"W","\u1d43":"a","\u1d47":"b","\u1d9c":"c","\u1d48":"d","\u1d49":"e","\u1da0":"f","\u1d4d":"g","\u02b0":"h","\u2071":"i","\u02b2":"j","\u1d4f":"k","\u02e1":"l","\u1d50":"m","\u207f":"n","\u1d52":"o","\u1d56":"p","\u02b3":"r","\u02e2":"s","\u1d57":"t","\u1d58":"u","\u1d5b":"v","\u02b7":"w","\u02e3":"x","\u02b8":"y","\u1dbb":"z","\u1d5d":"\u03b2","\u1d5e":"\u03b3","\u1d5f":"\u03b4","\u1d60":"\u03d5","\u1d61":"\u03c7","\u1dbf":"\u03b8"}),oo={"\u0301":{text:"\\'",math:"\\acute"},"\u0300":{text:"\\`",math:"\\grave"},"\u0308":{text:'\\"',math:"\\ddot"},"\u0303":{text:"\\~",math:"\\tilde"},"\u0304":{text:"\\=",math:"\\bar"},"\u0306":{text:"\\u",math:"\\breve"},"\u030c":{text:"\\v",math:"\\check"},"\u0302":{text:"\\^",math:"\\hat"},"\u0307":{text:"\\.",math:"\\dot"},"\u030a":{text:"\\r",math:"\\mathring"},"\u030b":{text:"\\H"},"\u0327":{text:"\\c"}},so={"\xe1":"a\u0301","\xe0":"a\u0300","\xe4":"a\u0308","\u01df":"a\u0308\u0304","\xe3":"a\u0303","\u0101":"a\u0304","\u0103":"a\u0306","\u1eaf":"a\u0306\u0301","\u1eb1":"a\u0306\u0300","\u1eb5":"a\u0306\u0303","\u01ce":"a\u030c","\xe2":"a\u0302","\u1ea5":"a\u0302\u0301","\u1ea7":"a\u0302\u0300","\u1eab":"a\u0302\u0303","\u0227":"a\u0307","\u01e1":"a\u0307\u0304","\xe5":"a\u030a","\u01fb":"a\u030a\u0301","\u1e03":"b\u0307","\u0107":"c\u0301","\u1e09":"c\u0327\u0301","\u010d":"c\u030c","\u0109":"c\u0302","\u010b":"c\u0307","\xe7":"c\u0327","\u010f":"d\u030c","\u1e0b":"d\u0307","\u1e11":"d\u0327","\xe9":"e\u0301","\xe8":"e\u0300","\xeb":"e\u0308","\u1ebd":"e\u0303","\u0113":"e\u0304","\u1e17":"e\u0304\u0301","\u1e15":"e\u0304\u0300","\u0115":"e\u0306","\u1e1d":"e\u0327\u0306","\u011b":"e\u030c","\xea":"e\u0302","\u1ebf":"e\u0302\u0301","\u1ec1":"e\u0302\u0300","\u1ec5":"e\u0302\u0303","\u0117":"e\u0307","\u0229":"e\u0327","\u1e1f":"f\u0307","\u01f5":"g\u0301","\u1e21":"g\u0304","\u011f":"g\u0306","\u01e7":"g\u030c","\u011d":"g\u0302","\u0121":"g\u0307","\u0123":"g\u0327","\u1e27":"h\u0308","\u021f":"h\u030c","\u0125":"h\u0302","\u1e23":"h\u0307","\u1e29":"h\u0327","\xed":"i\u0301","\xec":"i\u0300","\xef":"i\u0308","\u1e2f":"i\u0308\u0301","\u0129":"i\u0303","\u012b":"i\u0304","\u012d":"i\u0306","\u01d0":"i\u030c","\xee":"i\u0302","\u01f0":"j\u030c","\u0135":"j\u0302","\u1e31":"k\u0301","\u01e9":"k\u030c","\u0137":"k\u0327","\u013a":"l\u0301","\u013e":"l\u030c","\u013c":"l\u0327","\u1e3f":"m\u0301","\u1e41":"m\u0307","\u0144":"n\u0301","\u01f9":"n\u0300","\xf1":"n\u0303","\u0148":"n\u030c","\u1e45":"n\u0307","\u0146":"n\u0327","\xf3":"o\u0301","\xf2":"o\u0300","\xf6":"o\u0308","\u022b":"o\u0308\u0304","\xf5":"o\u0303","\u1e4d":"o\u0303\u0301","\u1e4f":"o\u0303\u0308","\u022d":"o\u0303\u0304","\u014d":"o\u0304","\u1e53":"o\u0304\u0301","\u1e51":"o\u0304\u0300","\u014f":"o\u0306","\u01d2":"o\u030c","\xf4":"o\u0302","\u1ed1":"o\u0302\u0301","\u1ed3":"o\u0302\u0300","\u1ed7":"o\u0302\u0303","\u022f":"o\u0307","\u0231":"o\u0307\u0304","\u0151":"o\u030b","\u1e55":"p\u0301","\u1e57":"p\u0307","\u0155":"r\u0301","\u0159":"r\u030c","\u1e59":"r\u0307","\u0157":"r\u0327","\u015b":"s\u0301","\u1e65":"s\u0301\u0307","\u0161":"s\u030c","\u1e67":"s\u030c\u0307","\u015d":"s\u0302","\u1e61":"s\u0307","\u015f":"s\u0327","\u1e97":"t\u0308","\u0165":"t\u030c","\u1e6b":"t\u0307","\u0163":"t\u0327","\xfa":"u\u0301","\xf9":"u\u0300","\xfc":"u\u0308","\u01d8":"u\u0308\u0301","\u01dc":"u\u0308\u0300","\u01d6":"u\u0308\u0304","\u01da":"u\u0308\u030c","\u0169":"u\u0303","\u1e79":"u\u0303\u0301","\u016b":"u\u0304","\u1e7b":"u\u0304\u0308","\u016d":"u\u0306","\u01d4":"u\u030c","\xfb":"u\u0302","\u016f":"u\u030a","\u0171":"u\u030b","\u1e7d":"v\u0303","\u1e83":"w\u0301","\u1e81":"w\u0300","\u1e85":"w\u0308","\u0175":"w\u0302","\u1e87":"w\u0307","\u1e98":"w\u030a","\u1e8d":"x\u0308","\u1e8b":"x\u0307","\xfd":"y\u0301","\u1ef3":"y\u0300","\xff":"y\u0308","\u1ef9":"y\u0303","\u0233":"y\u0304","\u0177":"y\u0302","\u1e8f":"y\u0307","\u1e99":"y\u030a","\u017a":"z\u0301","\u017e":"z\u030c","\u1e91":"z\u0302","\u017c":"z\u0307","\xc1":"A\u0301","\xc0":"A\u0300","\xc4":"A\u0308","\u01de":"A\u0308\u0304","\xc3":"A\u0303","\u0100":"A\u0304","\u0102":"A\u0306","\u1eae":"A\u0306\u0301","\u1eb0":"A\u0306\u0300","\u1eb4":"A\u0306\u0303","\u01cd":"A\u030c","\xc2":"A\u0302","\u1ea4":"A\u0302\u0301","\u1ea6":"A\u0302\u0300","\u1eaa":"A\u0302\u0303","\u0226":"A\u0307","\u01e0":"A\u0307\u0304","\xc5":"A\u030a","\u01fa":"A\u030a\u0301","\u1e02":"B\u0307","\u0106":"C\u0301","\u1e08":"C\u0327\u0301","\u010c":"C\u030c","\u0108":"C\u0302","\u010a":"C\u0307","\xc7":"C\u0327","\u010e":"D\u030c","\u1e0a":"D\u0307","\u1e10":"D\u0327","\xc9":"E\u0301","\xc8":"E\u0300","\xcb":"E\u0308","\u1ebc":"E\u0303","\u0112":"E\u0304","\u1e16":"E\u0304\u0301","\u1e14":"E\u0304\u0300","\u0114":"E\u0306","\u1e1c":"E\u0327\u0306","\u011a":"E\u030c","\xca":"E\u0302","\u1ebe":"E\u0302\u0301","\u1ec0":"E\u0302\u0300","\u1ec4":"E\u0302\u0303","\u0116":"E\u0307","\u0228":"E\u0327","\u1e1e":"F\u0307","\u01f4":"G\u0301","\u1e20":"G\u0304","\u011e":"G\u0306","\u01e6":"G\u030c","\u011c":"G\u0302","\u0120":"G\u0307","\u0122":"G\u0327","\u1e26":"H\u0308","\u021e":"H\u030c","\u0124":"H\u0302","\u1e22":"H\u0307","\u1e28":"H\u0327","\xcd":"I\u0301","\xcc":"I\u0300","\xcf":"I\u0308","\u1e2e":"I\u0308\u0301","\u0128":"I\u0303","\u012a":"I\u0304","\u012c":"I\u0306","\u01cf":"I\u030c","\xce":"I\u0302","\u0130":"I\u0307","\u0134":"J\u0302","\u1e30":"K\u0301","\u01e8":"K\u030c","\u0136":"K\u0327","\u0139":"L\u0301","\u013d":"L\u030c","\u013b":"L\u0327","\u1e3e":"M\u0301","\u1e40":"M\u0307","\u0143":"N\u0301","\u01f8":"N\u0300","\xd1":"N\u0303","\u0147":"N\u030c","\u1e44":"N\u0307","\u0145":"N\u0327","\xd3":"O\u0301","\xd2":"O\u0300","\xd6":"O\u0308","\u022a":"O\u0308\u0304","\xd5":"O\u0303","\u1e4c":"O\u0303\u0301","\u1e4e":"O\u0303\u0308","\u022c":"O\u0303\u0304","\u014c":"O\u0304","\u1e52":"O\u0304\u0301","\u1e50":"O\u0304\u0300","\u014e":"O\u0306","\u01d1":"O\u030c","\xd4":"O\u0302","\u1ed0":"O\u0302\u0301","\u1ed2":"O\u0302\u0300","\u1ed6":"O\u0302\u0303","\u022e":"O\u0307","\u0230":"O\u0307\u0304","\u0150":"O\u030b","\u1e54":"P\u0301","\u1e56":"P\u0307","\u0154":"R\u0301","\u0158":"R\u030c","\u1e58":"R\u0307","\u0156":"R\u0327","\u015a":"S\u0301","\u1e64":"S\u0301\u0307","\u0160":"S\u030c","\u1e66":"S\u030c\u0307","\u015c":"S\u0302","\u1e60":"S\u0307","\u015e":"S\u0327","\u0164":"T\u030c","\u1e6a":"T\u0307","\u0162":"T\u0327","\xda":"U\u0301","\xd9":"U\u0300","\xdc":"U\u0308","\u01d7":"U\u0308\u0301","\u01db":"U\u0308\u0300","\u01d5":"U\u0308\u0304","\u01d9":"U\u0308\u030c","\u0168":"U\u0303","\u1e78":"U\u0303\u0301","\u016a":"U\u0304","\u1e7a":"U\u0304\u0308","\u016c":"U\u0306","\u01d3":"U\u030c","\xdb":"U\u0302","\u016e":"U\u030a","\u0170":"U\u030b","\u1e7c":"V\u0303","\u1e82":"W\u0301","\u1e80":"W\u0300","\u1e84":"W\u0308","\u0174":"W\u0302","\u1e86":"W\u0307","\u1e8c":"X\u0308","\u1e8a":"X\u0307","\xdd":"Y\u0301","\u1ef2":"Y\u0300","\u0178":"Y\u0308","\u1ef8":"Y\u0303","\u0232":"Y\u0304","\u0176":"Y\u0302","\u1e8e":"Y\u0307","\u0179":"Z\u0301","\u017d":"Z\u030c","\u1e90":"Z\u0302","\u017b":"Z\u0307","\u03ac":"\u03b1\u0301","\u1f70":"\u03b1\u0300","\u1fb1":"\u03b1\u0304","\u1fb0":"\u03b1\u0306","\u03ad":"\u03b5\u0301","\u1f72":"\u03b5\u0300","\u03ae":"\u03b7\u0301","\u1f74":"\u03b7\u0300","\u03af":"\u03b9\u0301","\u1f76":"\u03b9\u0300","\u03ca":"\u03b9\u0308","\u0390":"\u03b9\u0308\u0301","\u1fd2":"\u03b9\u0308\u0300","\u1fd1":"\u03b9\u0304","\u1fd0":"\u03b9\u0306","\u03cc":"\u03bf\u0301","\u1f78":"\u03bf\u0300","\u03cd":"\u03c5\u0301","\u1f7a":"\u03c5\u0300","\u03cb":"\u03c5\u0308","\u03b0":"\u03c5\u0308\u0301","\u1fe2":"\u03c5\u0308\u0300","\u1fe1":"\u03c5\u0304","\u1fe0":"\u03c5\u0306","\u03ce":"\u03c9\u0301","\u1f7c":"\u03c9\u0300","\u038e":"\u03a5\u0301","\u1fea":"\u03a5\u0300","\u03ab":"\u03a5\u0308","\u1fe9":"\u03a5\u0304","\u1fe8":"\u03a5\u0306","\u038f":"\u03a9\u0301","\u1ffa":"\u03a9\u0300"};class io{constructor(e,t){this.mode=void 0,this.gullet=void 0,this.settings=void 0,this.leftrightDepth=void 0,this.nextToken=void 0,this.mode="math",this.gullet=new to(e,t,this.mode),this.settings=t,this.leftrightDepth=0,this.nextToken=null}expect(e,t){if(void 0===t&&(t=!0),this.fetch().text!==e)throw new n("Expected '"+e+"', got '"+this.fetch().text+"'",this.fetch());t&&this.consume()}consume(){this.nextToken=null}fetch(){return null==this.nextToken&&(this.nextToken=this.gullet.expandNextToken()),this.nextToken}switchMode(e){this.mode=e,this.gullet.switchMode(e)}parse(){this.settings.globalGroup||this.gullet.beginGroup(),this.settings.colorIsTextColor&&this.gullet.macros.set("\\color","\\textcolor");try{const e=this.parseExpression(!1);return this.expect("EOF"),this.settings.globalGroup||this.gullet.endGroup(),e}finally{this.gullet.endGroups()}}subparse(e){const t=this.nextToken;this.consume(),this.gullet.pushToken(new en("}")),this.gullet.pushTokens(e);const r=this.parseExpression(!1);return this.expect("}"),this.nextToken=t,r}parseExpression(e,t){const r=[];for(;;){"math"===this.mode&&this.consumeSpaces();const n=this.fetch();if(io.endOfExpression.has(n.text))break;if(t&&n.text===t)break;if(e&&Ln[n.text]&&Ln[n.text].infix)break;const o=this.parseAtom(t);if(!o)break;"internal"!==o.type&&r.push(o)}return"text"===this.mode&&this.formLigatures(r),this.handleInfixNodes(r)}handleInfixNodes(e){let t,r=-1;for(let o=0;o=128))return null;this.settings.strict&&(T(t.charCodeAt(0))?"math"===this.mode&&this.settings.reportNonstrict("unicodeTextInMathMode",'Unicode text character "'+t[0]+'" used in math mode',e):this.settings.reportNonstrict("unknownSymbol",'Unrecognized Unicode character "'+t[0]+'" ('+t.charCodeAt(0)+")",e)),o={type:"textord",mode:"text",loc:Qr.range(e),text:t}}if(this.consume(),r)for(let t=0;t 15) { + left = "…" + input.slice(start - 15, start); + } else { + left = input.slice(0, start); + } + var right; + if (end + 15 < input.length) { + right = input.slice(end, end + 15) + "…"; + } else { + right = input.slice(end); + } + error += left + underlined + right; + } + super(error); + this.name = "ParseError"; + this.position = void 0; + // Error start position based on passed-in Token or ParseNode. + this.length = void 0; + // Length of affected text based on passed-in Token or ParseNode. + this.rawMessage = void 0; + Object.setPrototypeOf(this, ParseError.prototype); + this.position = start; + if (start != null && end != null) { + this.length = end - start; + } + this.rawMessage = message; + } +} + +/** + * This file contains a list of utility functions which are useful in other + * files. + */ +// hyphenate and escape adapted from Facebook's React under Apache 2 license +var uppercase = /([A-Z])/g; +var hyphenate = str => str.replace(uppercase, "-$1").toLowerCase(); +var ESCAPE_LOOKUP = { + "&": "&", + ">": ">", + "<": "<", + "\"": """, + "'": "'" +}; +var ESCAPE_REGEX = /[&><"']/g; +/** + * Escapes text to prevent scripting attacks. + */ +var escape = text => String(text).replace(ESCAPE_REGEX, match => ESCAPE_LOOKUP[match]); +/** + * Sometimes we want to pull out the innermost element of a group. In most + * cases, this will just be the group itself, but when ordgroups and colors have + * a single element, we want to pull that out. + */ +var getBaseElem = group => { + if (group.type === "ordgroup") { + if (group.body.length === 1) { + return getBaseElem(group.body[0]); + } else { + return group; + } + } else if (group.type === "color") { + if (group.body.length === 1) { + return getBaseElem(group.body[0]); + } else { + return group; + } + } else if (group.type === "font") { + return getBaseElem(group.body); + } else { + return group; + } +}; +var characterNodesTypes = new Set(["mathord", "textord", "atom"]); +/** + * TeXbook algorithms often reference "character boxes", which are simply groups + * with a single character in them. To decide if something is a character box, + * we find its innermost group, and see if it is a single character. + */ +var isCharacterBox = group => characterNodesTypes.has(getBaseElem(group).type); +/** + * Return the protocol of a URL, or "_relative" if the URL does not specify a + * protocol (and thus is relative), or `null` if URL has invalid protocol + * (so should be outright rejected). + */ +var protocolFromUrl = url => { + // Check for possible leading protocol. + // https://url.spec.whatwg.org/#url-parsing strips leading whitespace + // (U+20) or C0 control (U+00-U+1F) characters. + var protocol = /^[\x00-\x20]*([^\\/#?]*?)(:|�*58|�*3a|&colon)/i.exec(url); + if (!protocol) { + return "_relative"; + } + // Reject weird colons + if (protocol[2] !== ":") { + return null; + } + // Reject invalid characters in scheme according to + // https://datatracker.ietf.org/doc/html/rfc3986#section-3.1 + if (!/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(protocol[1])) { + return null; + } + // Lowercase the protocol + return protocol[1].toLowerCase(); +}; + +/* eslint no-console:0 */ +// TODO: automatically generate documentation +// TODO: check all properties on Settings exist +// TODO: check the type of a property on Settings matches +var SETTINGS_SCHEMA = { + displayMode: { + type: "boolean", + description: "Render math in display mode, which puts the math in " + "display style (so \\int and \\sum are large, for example), and " + "centers the math on the page on its own line.", + cli: "-d, --display-mode" + }, + output: { + type: { + enum: ["htmlAndMathml", "html", "mathml"] + }, + description: "Determines the markup language of the output.", + cli: "-F, --format " + }, + leqno: { + type: "boolean", + description: "Render display math in leqno style (left-justified tags)." + }, + fleqn: { + type: "boolean", + description: "Render display math flush left." + }, + throwOnError: { + type: "boolean", + default: true, + cli: "-t, --no-throw-on-error", + cliDescription: "Render errors (in the color given by --error-color) ins" + "tead of throwing a ParseError exception when encountering an error." + }, + errorColor: { + type: "string", + default: "#cc0000", + cli: "-c, --error-color ", + cliDescription: "A color string given in the format 'rgb' or 'rrggbb' " + "(no #). This option determines the color of errors rendered by the " + "-t option.", + cliProcessor: color => "#" + color + }, + macros: { + type: "object", + cli: "-m, --macro ", + cliDescription: "Define custom macro of the form '\\foo:expansion' (use " + "multiple -m arguments for multiple macros).", + cliDefault: [], + cliProcessor: (def, defs) => { + defs.push(def); + return defs; + } + }, + minRuleThickness: { + type: "number", + description: "Specifies a minimum thickness, in ems, for fraction lines," + " `\\sqrt` top lines, `{array}` vertical lines, `\\hline`, " + "`\\hdashline`, `\\underline`, `\\overline`, and the borders of " + "`\\fbox`, `\\boxed`, and `\\fcolorbox`.", + processor: t => Math.max(0, t), + cli: "--min-rule-thickness ", + cliProcessor: parseFloat + }, + colorIsTextColor: { + type: "boolean", + description: "Makes \\color behave like LaTeX's 2-argument \\textcolor, " + "instead of LaTeX's one-argument \\color mode change.", + cli: "-b, --color-is-text-color" + }, + strict: { + type: [{ + enum: ["warn", "ignore", "error"] + }, "boolean", "function"], + description: "Turn on strict / LaTeX faithfulness mode, which throws an " + "error if the input uses features that are not supported by LaTeX.", + cli: "-S, --strict", + cliDefault: false + }, + trust: { + type: ["boolean", "function"], + description: "Trust the input, enabling all HTML features such as \\url.", + cli: "-T, --trust" + }, + maxSize: { + type: "number", + default: Infinity, + description: "If non-zero, all user-specified sizes, e.g. in " + "\\rule{500em}{500em}, will be capped to maxSize ems. Otherwise, " + "elements and spaces can be arbitrarily large", + processor: s => Math.max(0, s), + cli: "-s, --max-size ", + cliProcessor: parseInt + }, + maxExpand: { + type: "number", + default: 1000, + description: "Limit the number of macro expansions to the specified " + "number, to prevent e.g. infinite macro loops. If set to Infinity, " + "the macro expander will try to fully expand as in LaTeX.", + processor: n => Math.max(0, n), + cli: "-e, --max-expand ", + cliProcessor: n => n === "Infinity" ? Infinity : parseInt(n) + }, + globalGroup: { + type: "boolean", + cli: false + } +}; +function getImplicitDefault(type) { + if (typeof type !== 'string') { + return type.enum[0]; + } + switch (type) { + case 'boolean': + return false; + case 'string': + return ''; + case 'number': + return 0; + case 'object': + return {}; + default: + throw new Error("Unexpected schema type; settings must declare an explicit default."); + } +} +function getDefaultValue(schema) { + if (schema.default !== undefined) { + return schema.default; + } + var type = Array.isArray(schema.type) ? schema.type[0] : schema.type; + return getImplicitDefault(type); +} +function applySetting(target, prop, options, schema) { + var optionValue = options[prop]; + target[prop] = optionValue !== undefined ? schema.processor ? schema.processor(optionValue) : optionValue : getDefaultValue(schema); +} +/** + * The main Settings object + * + * The current options stored are: + * - displayMode: Whether the expression should be typeset as inline math + * (false, the default), meaning that the math starts in + * \textstyle and is placed in an inline-block); or as display + * math (true), meaning that the math starts in \displaystyle + * and is placed in a block with vertical margin. + */ +class Settings { + constructor(options) { + if (options === void 0) { + options = {}; + } + this.displayMode = void 0; + this.output = void 0; + this.leqno = void 0; + this.fleqn = void 0; + this.throwOnError = void 0; + this.errorColor = void 0; + this.macros = void 0; + this.minRuleThickness = void 0; + this.colorIsTextColor = void 0; + this.strict = void 0; + this.trust = void 0; + this.maxSize = void 0; + this.maxExpand = void 0; + this.globalGroup = void 0; + // allow null options + options = options || {}; + for (var prop of Object.keys(SETTINGS_SCHEMA)) { + var schema = SETTINGS_SCHEMA[prop]; + if (schema) { + // TODO: validate options + applySetting(this, prop, options, schema); + } + } + } + /** + * Report nonstrict (non-LaTeX-compatible) input. + * Can safely not be called if `this.strict` is false in JavaScript. + */ + reportNonstrict(errorCode, errorMsg, token) { + var strict = this.strict; + if (typeof strict === "function") { + // Allow return value of strict function to be boolean or string + // (or null/undefined, meaning no further processing). + strict = strict(errorCode, errorMsg, token); + } + if (!strict || strict === "ignore") { + return; + } else if (strict === true || strict === "error") { + throw new ParseError("LaTeX-incompatible input and strict mode is set to 'error': " + (errorMsg + " [" + errorCode + "]"), token); + } else if (strict === "warn") { + typeof console !== "undefined" && console.warn("LaTeX-incompatible input and strict mode is set to 'warn': " + (errorMsg + " [" + errorCode + "]")); + } else { + // won't happen in type-safe code + typeof console !== "undefined" && console.warn("LaTeX-incompatible input and strict mode is set to " + ("unrecognized '" + strict + "': " + errorMsg + " [" + errorCode + "]")); + } + } + /** + * Check whether to apply strict (LaTeX-adhering) behavior for unusual + * input (like `\\`). Unlike `nonstrict`, will not throw an error; + * instead, "error" translates to a return value of `true`, while "ignore" + * translates to a return value of `false`. May still print a warning: + * "warn" prints a warning and returns `false`. + * This is for the second category of `errorCode`s listed in the README. + */ + useStrictBehavior(errorCode, errorMsg, token) { + var strict = this.strict; + if (typeof strict === "function") { + // Allow return value of strict function to be boolean or string + // (or null/undefined, meaning no further processing). + // But catch any exceptions thrown by function, treating them + // like "error". + try { + strict = strict(errorCode, errorMsg, token); + } catch (error) { + strict = "error"; + } + } + if (!strict || strict === "ignore") { + return false; + } else if (strict === true || strict === "error") { + return true; + } else if (strict === "warn") { + typeof console !== "undefined" && console.warn("LaTeX-incompatible input and strict mode is set to 'warn': " + (errorMsg + " [" + errorCode + "]")); + return false; + } else { + // won't happen in type-safe code + typeof console !== "undefined" && console.warn("LaTeX-incompatible input and strict mode is set to " + ("unrecognized '" + strict + "': " + errorMsg + " [" + errorCode + "]")); + return false; + } + } + /** + * Check whether to test potentially dangerous input, and return + * `true` (trusted) or `false` (untrusted). The sole argument `context` + * should be an object with `command` field specifying the relevant LaTeX + * command (as a string starting with `\`), and any other arguments, etc. + * If `context` has a `url` field, a `protocol` field will automatically + * get added by this function (changing the specified object). + */ + isTrusted(context) { + if ("url" in context && context.url && !context.protocol) { + var protocol = protocolFromUrl(context.url); + if (protocol == null) { + return false; + } + context.protocol = protocol; + } + var trust = typeof this.trust === "function" ? this.trust(context) : this.trust; + return Boolean(trust); + } +} + +/** + * This file contains information and classes for the various kinds of styles + * used in TeX. It provides a generic `Style` class, which holds information + * about a specific style. It then provides instances of all the different kinds + * of styles possible, and provides functions to move between them and get + * information about them. + */ +/** + * The main style class. Contains a unique id for the style, a size (which is + * the same for cramped and uncramped version of a style), and a cramped flag. + */ +class Style { + constructor(id, size, cramped) { + this.id = void 0; + this.size = void 0; + this.cramped = void 0; + this.id = id; + this.size = size; + this.cramped = cramped; + } + /** + * Get the style of a superscript given a base in the current style. + */ + sup() { + return styles[sup[this.id]]; + } + /** + * Get the style of a subscript given a base in the current style. + */ + sub() { + return styles[sub[this.id]]; + } + /** + * Get the style of a fraction numerator given the fraction in the current + * style. + */ + fracNum() { + return styles[fracNum[this.id]]; + } + /** + * Get the style of a fraction denominator given the fraction in the current + * style. + */ + fracDen() { + return styles[fracDen[this.id]]; + } + /** + * Get the cramped version of a style (in particular, cramping a cramped style + * doesn't change the style). + */ + cramp() { + return styles[cramp[this.id]]; + } + /** + * Get a text or display version of this style. + */ + text() { + return styles[text$1[this.id]]; + } + /** + * Return true if this style is tightly spaced (scriptstyle/scriptscriptstyle) + */ + isTight() { + return this.size >= 2; + } +} +// IDs of the different styles +var D = 0; +var Dc = 1; +var T = 2; +var Tc = 3; +var S = 4; +var Sc = 5; +var SS = 6; +var SSc = 7; +// Instances of the different styles +var styles = [new Style(D, 0, false), new Style(Dc, 0, true), new Style(T, 1, false), new Style(Tc, 1, true), new Style(S, 2, false), new Style(Sc, 2, true), new Style(SS, 3, false), new Style(SSc, 3, true)]; +// Lookup tables for switching from one style to another +var sup = [S, Sc, S, Sc, SS, SSc, SS, SSc]; +var sub = [Sc, Sc, Sc, Sc, SSc, SSc, SSc, SSc]; +var fracNum = [T, Tc, S, Sc, SS, SSc, SS, SSc]; +var fracDen = [Tc, Tc, Sc, Sc, SSc, SSc, SSc, SSc]; +var cramp = [Dc, Dc, Tc, Tc, Sc, Sc, SSc, SSc]; +var text$1 = [D, Dc, T, Tc, T, Tc, T, Tc]; +// We only export some of the styles. +var Style$1 = { + DISPLAY: styles[D], + TEXT: styles[T], + SCRIPT: styles[S], + SCRIPTSCRIPT: styles[SS] +}; + +/* + * This file defines the Unicode scripts and script families that we + * support. To add new scripts or families, just add a new entry to the + * scriptData array below. Adding scripts to the scriptData array allows + * characters from that script to appear in \text{} environments. + */ +/** + * Unicode block data for the families of scripts we support in \text{}. + * Scripts only need to appear here if they do not have font metrics. + */ +var scriptData = [{ + // Latin characters beyond the Latin-1 characters we have metrics for. + // Needed for Czech, Hungarian and Turkish text, for example. + name: 'latin', + blocks: [[0x0100, 0x024f], + // Latin Extended-A and Latin Extended-B + [0x0300, 0x036f] // Combining Diacritical marks + ] +}, { + // The Cyrillic script used by Russian and related languages. + // A Cyrillic subset used to be supported as explicitly defined + // symbols in symbols.js + name: 'cyrillic', + blocks: [[0x0400, 0x04ff]] +}, { + // Armenian + name: 'armenian', + blocks: [[0x0530, 0x058F]] +}, { + // The Brahmic scripts of South and Southeast Asia + // Devanagari (0900–097F) + // Bengali (0980–09FF) + // Gurmukhi (0A00–0A7F) + // Gujarati (0A80–0AFF) + // Oriya (0B00–0B7F) + // Tamil (0B80–0BFF) + // Telugu (0C00–0C7F) + // Kannada (0C80–0CFF) + // Malayalam (0D00–0D7F) + // Sinhala (0D80–0DFF) + // Thai (0E00–0E7F) + // Lao (0E80–0EFF) + // Tibetan (0F00–0FFF) + // Myanmar (1000–109F) + name: 'brahmic', + blocks: [[0x0900, 0x109F]] +}, { + name: 'georgian', + blocks: [[0x10A0, 0x10ff]] +}, { + // Chinese and Japanese. + // The "k" in cjk is for Korean, but we've separated Korean out + name: "cjk", + blocks: [[0x3000, 0x30FF], + // CJK symbols and punctuation, Hiragana, Katakana + [0x4E00, 0x9FAF], + // CJK ideograms + [0xFF00, 0xFF60] // Fullwidth punctuation + // TODO: add halfwidth Katakana and Romanji glyphs + ] +}, { + // Korean + name: 'hangul', + blocks: [[0xAC00, 0xD7AF]] +}]; +/** + * Given a codepoint, return the name of the script or script family + * it is from, or null if it is not part of a known block + */ +function scriptFromCodepoint(codepoint) { + for (var i = 0; i < scriptData.length; i++) { + var script = scriptData[i]; + for (var _i = 0; _i < script.blocks.length; _i++) { + var block = script.blocks[_i]; + if (codepoint >= block[0] && codepoint <= block[1]) { + return script.name; + } + } + } + return null; +} +/** + * A flattened version of all the supported blocks in a single array. + * This is an optimization to make supportedCodepoint() fast. + */ +var allBlocks = []; +scriptData.forEach(s => s.blocks.forEach(b => allBlocks.push(...b))); +/** + * Given a codepoint, return true if it falls within one of the + * scripts or script families defined above and false otherwise. + * + * Micro benchmarks shows that this is faster than + * /[\u3000-\u30FF\u4E00-\u9FAF\uFF00-\uFF60\uAC00-\uD7AF\u0900-\u109F]/.test() + * in Firefox, Chrome and Node. + */ +function supportedCodepoint(codepoint) { + for (var i = 0; i < allBlocks.length; i += 2) { + if (codepoint >= allBlocks[i] && codepoint <= allBlocks[i + 1]) { + return true; + } + } + return false; +} + +/** + * This file provides support to domTree.js and delimiter.js. + * It's a storehouse of path geometry for SVG images. + */ +// In all paths below, the viewBox-to-em scale is 1000:1. +// Second Brush Stroke +// Low resolution monitors struggle to display images in fine detail. +// So browsers apply anti-aliasing. A long straight arrow shaft therefore +// will sometimes appear as if it has a blurred edge. +// To mitigate this, these SVG files contain a second "brush-stroke" on the +// arrow shafts. That is, a second long thin rectangular SVG path has been +// written directly on top of each arrow shaft. This reinforcement causes +// some of the screen pixels to display as black instead of the anti-aliased +// gray pixel that a single path would generate. So we get arrow shafts +// whose edges appear to be sharper. +var doubleBrushStroke = svgPath => svgPath + " " + svgPath; +var hLinePad = 80; // padding above a sqrt vinculum. Prevents image cropping. +// The vinculum of a \sqrt can be made thicker by a KaTeX rendering option. +// Think of variable extraVinculum as two detours in the SVG path. +// The detour begins at the lower left of the area labeled extraVinculum below. +// The detour proceeds one extraVinculum distance up and slightly to the right, +// displacing the radiused corner between surd and vinculum. The radius is +// traversed as usual, then the detour resumes. It goes right, to the end of +// the very long vinculum, then down one extraVinculum distance, +// after which it resumes regular path geometry for the radical. +/* vinculum + / + /▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒←extraVinculum + / █████████████████████←0.04em (40 unit) std vinculum thickness + / / + / / + / /\ + / / surd +*/ +var sqrtMain = function sqrtMain(extraVinculum, hLinePad) { + // sqrtMain path geometry is from glyph U221A in the font KaTeX Main + return "M95," + (622 + extraVinculum + hLinePad) + "\nc-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14\nc0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54\nc44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10\ns173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429\nc69,-144,104.5,-217.7,106.5,-221\nl" + extraVinculum / 2.075 + " -" + extraVinculum + "\nc5.3,-9.3,12,-14,20,-14\nH400000v" + (40 + extraVinculum) + "H845.2724\ns-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7\nc-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z\nM" + (834 + extraVinculum) + " " + hLinePad + "h400000v" + (40 + extraVinculum) + "h-400000z"; +}; +var sqrtSize1 = function sqrtSize1(extraVinculum, hLinePad) { + // size1 is from glyph U221A in the font KaTeX_Size1-Regular + return "M263," + (601 + extraVinculum + hLinePad) + "c0.7,0,18,39.7,52,119\nc34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120\nc340,-704.7,510.7,-1060.3,512,-1067\nl" + extraVinculum / 2.084 + " -" + extraVinculum + "\nc4.7,-7.3,11,-11,19,-11\nH40000v" + (40 + extraVinculum) + "H1012.3\ns-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232\nc-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1\ns-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26\nc-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z\nM" + (1001 + extraVinculum) + " " + hLinePad + "h400000v" + (40 + extraVinculum) + "h-400000z"; +}; +var sqrtSize2 = function sqrtSize2(extraVinculum, hLinePad) { + // size2 is from glyph U221A in the font KaTeX_Size2-Regular + return "M983 " + (10 + extraVinculum + hLinePad) + "\nl" + extraVinculum / 3.13 + " -" + extraVinculum + "\nc4,-6.7,10,-10,18,-10 H400000v" + (40 + extraVinculum) + "\nH1013.1s-83.4,268,-264.1,840c-180.7,572,-277,876.3,-289,913c-4.7,4.7,-12.7,7,-24,7\ns-12,0,-12,0c-1.3,-3.3,-3.7,-11.7,-7,-25c-35.3,-125.3,-106.7,-373.3,-214,-744\nc-10,12,-21,25,-33,39s-32,39,-32,39c-6,-5.3,-15,-14,-27,-26s25,-30,25,-30\nc26.7,-32.7,52,-63,76,-91s52,-60,52,-60s208,722,208,722\nc56,-175.3,126.3,-397.3,211,-666c84.7,-268.7,153.8,-488.2,207.5,-658.5\nc53.7,-170.3,84.5,-266.8,92.5,-289.5z\nM" + (1001 + extraVinculum) + " " + hLinePad + "h400000v" + (40 + extraVinculum) + "h-400000z"; +}; +var sqrtSize3 = function sqrtSize3(extraVinculum, hLinePad) { + // size3 is from glyph U221A in the font KaTeX_Size3-Regular + return "M424," + (2398 + extraVinculum + hLinePad) + "\nc-1.3,-0.7,-38.5,-172,-111.5,-514c-73,-342,-109.8,-513.3,-110.5,-514\nc0,-2,-10.7,14.3,-32,49c-4.7,7.3,-9.8,15.7,-15.5,25c-5.7,9.3,-9.8,16,-12.5,20\ns-5,7,-5,7c-4,-3.3,-8.3,-7.7,-13,-13s-13,-13,-13,-13s76,-122,76,-122s77,-121,77,-121\ns209,968,209,968c0,-2,84.7,-361.7,254,-1079c169.3,-717.3,254.7,-1077.7,256,-1081\nl" + extraVinculum / 4.223 + " -" + extraVinculum + "c4,-6.7,10,-10,18,-10 H400000\nv" + (40 + extraVinculum) + "H1014.6\ns-87.3,378.7,-272.6,1166c-185.3,787.3,-279.3,1182.3,-282,1185\nc-2,6,-10,9,-24,9\nc-8,0,-12,-0.7,-12,-2z M" + (1001 + extraVinculum) + " " + hLinePad + "\nh400000v" + (40 + extraVinculum) + "h-400000z"; +}; +var sqrtSize4 = function sqrtSize4(extraVinculum, hLinePad) { + // size4 is from glyph U221A in the font KaTeX_Size4-Regular + return "M473," + (2713 + extraVinculum + hLinePad) + "\nc339.3,-1799.3,509.3,-2700,510,-2702 l" + extraVinculum / 5.298 + " -" + extraVinculum + "\nc3.3,-7.3,9.3,-11,18,-11 H400000v" + (40 + extraVinculum) + "H1017.7\ns-90.5,478,-276.2,1466c-185.7,988,-279.5,1483,-281.5,1485c-2,6,-10,9,-24,9\nc-8,0,-12,-0.7,-12,-2c0,-1.3,-5.3,-32,-16,-92c-50.7,-293.3,-119.7,-693.3,-207,-1200\nc0,-1.3,-5.3,8.7,-16,30c-10.7,21.3,-21.3,42.7,-32,64s-16,33,-16,33s-26,-26,-26,-26\ns76,-153,76,-153s77,-151,77,-151c0.7,0.7,35.7,202,105,604c67.3,400.7,102,602.7,104,\n606zM" + (1001 + extraVinculum) + " " + hLinePad + "h400000v" + (40 + extraVinculum) + "H1017.7z"; +}; +var phasePath = function phasePath(y) { + var x = y / 2; // x coordinate at top of angle + return "M400000 " + y + " H0 L" + x + " 0 l65 45 L145 " + (y - 80) + " H400000z"; +}; +var sqrtTall = function sqrtTall(extraVinculum, hLinePad, viewBoxHeight) { + // sqrtTall is from glyph U23B7 in the font KaTeX_Size4-Regular + // One path edge has a variable length. It runs vertically from the vinculum + // to a point near (14 units) the bottom of the surd. The vinculum + // is normally 40 units thick. So the length of the line in question is: + var vertSegment = viewBoxHeight - 54 - hLinePad - extraVinculum; + return "M702 " + (extraVinculum + hLinePad) + "H400000" + (40 + extraVinculum) + "\nH742v" + vertSegment + "l-4 4-4 4c-.667.7 -2 1.5-4 2.5s-4.167 1.833-6.5 2.5-5.5 1-9.5 1\nh-12l-28-84c-16.667-52-96.667 -294.333-240-727l-212 -643 -85 170\nc-4-3.333-8.333-7.667-13 -13l-13-13l77-155 77-156c66 199.333 139 419.667\n219 661 l218 661zM702 " + hLinePad + "H400000v" + (40 + extraVinculum) + "H742z"; +}; +var sqrtPath = function sqrtPath(size, extraVinculum, viewBoxHeight) { + extraVinculum = 1000 * extraVinculum; // Convert from document ems to viewBox. + var path = ""; + switch (size) { + case "sqrtMain": + path = sqrtMain(extraVinculum, hLinePad); + break; + case "sqrtSize1": + path = sqrtSize1(extraVinculum, hLinePad); + break; + case "sqrtSize2": + path = sqrtSize2(extraVinculum, hLinePad); + break; + case "sqrtSize3": + path = sqrtSize3(extraVinculum, hLinePad); + break; + case "sqrtSize4": + path = sqrtSize4(extraVinculum, hLinePad); + break; + case "sqrtTall": + path = sqrtTall(extraVinculum, hLinePad, viewBoxHeight); + } + return path; +}; +var innerPath = function innerPath(name, height) { + // The inner part of stretchy tall delimiters + switch (name) { + case "\u239c": + return doubleBrushStroke("M291 0 H417 V" + height + " H291z"); + case "\u2223": + return doubleBrushStroke("M145 0 H188 V" + height + " H145z"); + case "\u2225": + return doubleBrushStroke("M145 0 H188 V" + height + " H145z") + doubleBrushStroke("M367 0 H410 V" + height + " H367z"); + case "\u239f": + return doubleBrushStroke("M457 0 H583 V" + height + " H457z"); + case "\u23a2": + return doubleBrushStroke("M319 0 H403 V" + height + " H319z"); + case "\u23a5": + return doubleBrushStroke("M263 0 H347 V" + height + " H263z"); + case "\u23aa": + return doubleBrushStroke("M384 0 H504 V" + height + " H384z"); + case "\u23d0": + return doubleBrushStroke("M312 0 H355 V" + height + " H312z"); + case "\u2016": + return doubleBrushStroke("M257 0 H300 V" + height + " H257z") + doubleBrushStroke("M478 0 H521 V" + height + " H478z"); + default: + return ""; + } +}; +var path = { + // The doubleleftarrow geometry is from glyph U+21D0 in the font KaTeX Main + doubleleftarrow: "M262 157\nl10-10c34-36 62.7-77 86-123 3.3-8 5-13.3 5-16 0-5.3-6.7-8-20-8-7.3\n 0-12.2.5-14.5 1.5-2.3 1-4.8 4.5-7.5 10.5-49.3 97.3-121.7 169.3-217 216-28\n 14-57.3 25-88 33-6.7 2-11 3.8-13 5.5-2 1.7-3 4.2-3 7.5s1 5.8 3 7.5\nc2 1.7 6.3 3.5 13 5.5 68 17.3 128.2 47.8 180.5 91.5 52.3 43.7 93.8 96.2 124.5\n 157.5 9.3 8 15.3 12.3 18 13h6c12-.7 18-4 18-10 0-2-1.7-7-5-15-23.3-46-52-87\n-86-123l-10-10h399738v-40H218c328 0 0 0 0 0l-10-8c-26.7-20-65.7-43-117-69 2.7\n-2 6-3.7 10-5 36.7-16 72.3-37.3 107-64l10-8h399782v-40z\nm8 0v40h399730v-40zm0 194v40h399730v-40z", + // doublerightarrow is from glyph U+21D2 in font KaTeX Main + doublerightarrow: "M399738 392l\n-10 10c-34 36-62.7 77-86 123-3.3 8-5 13.3-5 16 0 5.3 6.7 8 20 8 7.3 0 12.2-.5\n 14.5-1.5 2.3-1 4.8-4.5 7.5-10.5 49.3-97.3 121.7-169.3 217-216 28-14 57.3-25 88\n-33 6.7-2 11-3.8 13-5.5 2-1.7 3-4.2 3-7.5s-1-5.8-3-7.5c-2-1.7-6.3-3.5-13-5.5-68\n-17.3-128.2-47.8-180.5-91.5-52.3-43.7-93.8-96.2-124.5-157.5-9.3-8-15.3-12.3-18\n-13h-6c-12 .7-18 4-18 10 0 2 1.7 7 5 15 23.3 46 52 87 86 123l10 10H0v40h399782\nc-328 0 0 0 0 0l10 8c26.7 20 65.7 43 117 69-2.7 2-6 3.7-10 5-36.7 16-72.3 37.3\n-107 64l-10 8H0v40zM0 157v40h399730v-40zm0 194v40h399730v-40z", + // leftarrow is from glyph U+2190 in font KaTeX Main + leftarrow: "M400000 241H110l3-3c68.7-52.7 113.7-120\n 135-202 4-14.7 6-23 6-25 0-7.3-7-11-21-11-8 0-13.2.8-15.5 2.5-2.3 1.7-4.2 5.8\n-5.5 12.5-1.3 4.7-2.7 10.3-4 17-12 48.7-34.8 92-68.5 130S65.3 228.3 18 247\nc-10 4-16 7.7-18 11 0 8.7 6 14.3 18 17 47.3 18.7 87.8 47 121.5 85S196 441.3 208\n 490c.7 2 1.3 5 2 9s1.2 6.7 1.5 8c.3 1.3 1 3.3 2 6s2.2 4.5 3.5 5.5c1.3 1 3.3\n 1.8 6 2.5s6 1 10 1c14 0 21-3.7 21-11 0-2-2-10.3-6-25-20-79.3-65-146.7-135-202\n l-3-3h399890zM100 241v40h399900v-40z", + // overbrace is from glyphs U+23A9/23A8/23A7 in font KaTeX_Size4-Regular + leftbrace: "M6 548l-6-6v-35l6-11c56-104 135.3-181.3 238-232 57.3-28.7 117\n-45 179-50h399577v120H403c-43.3 7-81 15-113 26-100.7 33-179.7 91-237 174-2.7\n 5-6 9-10 13-.7 1-7.3 1-20 1H6z", + leftbraceunder: "M0 6l6-6h17c12.688 0 19.313.3 20 1 4 4 7.313 8.3 10 13\n 35.313 51.3 80.813 93.8 136.5 127.5 55.688 33.7 117.188 55.8 184.5 66.5.688\n 0 2 .3 4 1 18.688 2.7 76 4.3 172 5h399450v120H429l-6-1c-124.688-8-235-61.7\n-331-161C60.687 138.7 32.312 99.3 7 54L0 41V6z", + // overgroup is from the MnSymbol package (public domain) + leftgroup: "M400000 80\nH435C64 80 168.3 229.4 21 260c-5.9 1.2-18 0-18 0-2 0-3-1-3-3v-38C76 61 257 0\n 435 0h399565z", + leftgroupunder: "M400000 262\nH435C64 262 168.3 112.6 21 82c-5.9-1.2-18 0-18 0-2 0-3 1-3 3v38c76 158 257 219\n 435 219h399565z", + // Harpoons are from glyph U+21BD in font KaTeX Main + leftharpoon: "M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3\n-3.3 10.2-9.5 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5\n-18.3 3-21-1.3-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7\n-196 228-6.7 4.7-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40z", + leftharpoonplus: "M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3-3.3 10.2-9.5\n 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5-18.3 3-21-1.3\n-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7-196 228-6.7 4.7\n-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40zM0 435v40h400000v-40z\nm0 0v40h400000v-40z", + leftharpoondown: "M7 241c-4 4-6.333 8.667-7 14 0 5.333.667 9 2 11s5.333\n 5.333 12 10c90.667 54 156 130 196 228 3.333 10.667 6.333 16.333 9 17 2 .667 5\n 1 9 1h5c10.667 0 16.667-2 18-6 2-2.667 1-9.667-3-21-32-87.333-82.667-157.667\n-152-211l-3-3h399907v-40zM93 281 H400000 v-40L7 241z", + leftharpoondownplus: "M7 435c-4 4-6.3 8.7-7 14 0 5.3.7 9 2 11s5.3 5.3 12\n 10c90.7 54 156 130 196 228 3.3 10.7 6.3 16.3 9 17 2 .7 5 1 9 1h5c10.7 0 16.7\n-2 18-6 2-2.7 1-9.7-3-21-32-87.3-82.7-157.7-152-211l-3-3h399907v-40H7zm93 0\nv40h399900v-40zM0 241v40h399900v-40zm0 0v40h399900v-40z", + // hook is from glyph U+21A9 in font KaTeX Main + lefthook: "M400000 281 H103s-33-11.2-61-33.5S0 197.3 0 164s14.2-61.2 42.5\n-83.5C70.8 58.2 104 47 142 47 c16.7 0 25 6.7 25 20 0 12-8.7 18.7-26 20-40 3.3\n-68.7 15.7-86 37-10 12-15 25.3-15 40 0 22.7 9.8 40.7 29.5 54 19.7 13.3 43.5 21\n 71.5 23h399859zM103 281v-40h399897v40z", + leftlinesegment: doubleBrushStroke("M40 281 V428 H0 V94 H40 V241 H400000 v40z"), + leftbracketunder: doubleBrushStroke("M0 0 h120 V290 H399995 v120 H0z"), + leftbracketover: doubleBrushStroke("M0 440 h120 V150 H399995 v-120 H0z"), + leftmapsto: doubleBrushStroke("M40 281 V448H0V74H40V241H400000v40z"), + // tofrom is from glyph U+21C4 in font KaTeX AMS Regular + leftToFrom: "M0 147h400000v40H0zm0 214c68 40 115.7 95.7 143 167h22c15.3 0 23\n-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69-70-101l-7-8h399905v-40H95l7-8\nc28.7-32 52-65.7 70-101 10.7-23.3 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 265.3\n 68 321 0 361zm0-174v-40h399900v40zm100 154v40h399900v-40z", + longequal: doubleBrushStroke("M0 50 h400000 v40H0z m0 194h40000v40H0z"), + midbrace: "M200428 334\nc-100.7-8.3-195.3-44-280-108-55.3-42-101.7-93-139-153l-9-14c-2.7 4-5.7 8.7-9 14\n-53.3 86.7-123.7 153-211 199-66.7 36-137.3 56.3-212 62H0V214h199568c178.3-11.7\n 311.7-78.3 403-201 6-8 9.7-12 11-12 .7-.7 6.7-1 18-1s17.3.3 18 1c1.3 0 5 4 11\n 12 44.7 59.3 101.3 106.3 170 141s145.3 54.3 229 60h199572v120z", + midbraceunder: "M199572 214\nc100.7 8.3 195.3 44 280 108 55.3 42 101.7 93 139 153l9 14c2.7-4 5.7-8.7 9-14\n 53.3-86.7 123.7-153 211-199 66.7-36 137.3-56.3 212-62h199568v120H200432c-178.3\n 11.7-311.7 78.3-403 201-6 8-9.7 12-11 12-.7.7-6.7 1-18 1s-17.3-.3-18-1c-1.3 0\n-5-4-11-12-44.7-59.3-101.3-106.3-170-141s-145.3-54.3-229-60H0V214z", + oiintSize1: "M512.6 71.6c272.6 0 320.3 106.8 320.3 178.2 0 70.8-47.7 177.6\n-320.3 177.6S193.1 320.6 193.1 249.8c0-71.4 46.9-178.2 319.5-178.2z\nm368.1 178.2c0-86.4-60.9-215.4-368.1-215.4-306.4 0-367.3 129-367.3 215.4 0 85.8\n60.9 214.8 367.3 214.8 307.2 0 368.1-129 368.1-214.8z", + oiintSize2: "M757.8 100.1c384.7 0 451.1 137.6 451.1 230 0 91.3-66.4 228.8\n-451.1 228.8-386.3 0-452.7-137.5-452.7-228.8 0-92.4 66.4-230 452.7-230z\nm502.4 230c0-111.2-82.4-277.2-502.4-277.2s-504 166-504 277.2\nc0 110 84 276 504 276s502.4-166 502.4-276z", + oiiintSize1: "M681.4 71.6c408.9 0 480.5 106.8 480.5 178.2 0 70.8-71.6 177.6\n-480.5 177.6S202.1 320.6 202.1 249.8c0-71.4 70.5-178.2 479.3-178.2z\nm525.8 178.2c0-86.4-86.8-215.4-525.7-215.4-437.9 0-524.7 129-524.7 215.4 0\n85.8 86.8 214.8 524.7 214.8 438.9 0 525.7-129 525.7-214.8z", + oiiintSize2: "M1021.2 53c603.6 0 707.8 165.8 707.8 277.2 0 110-104.2 275.8\n-707.8 275.8-606 0-710.2-165.8-710.2-275.8C311 218.8 415.2 53 1021.2 53z\nm770.4 277.1c0-131.2-126.4-327.6-770.5-327.6S248.4 198.9 248.4 330.1\nc0 130 128.8 326.4 772.7 326.4s770.5-196.4 770.5-326.4z", + rightarrow: "M0 241v40h399891c-47.3 35.3-84 78-110 128\n-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20\n 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7\n 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85\n-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5\n-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67\n 151.7 139 205zm0 0v40h399900v-40z", + rightbrace: "M400000 542l\n-6 6h-17c-12.7 0-19.3-.3-20-1-4-4-7.3-8.3-10-13-35.3-51.3-80.8-93.8-136.5-127.5\ns-117.2-55.8-184.5-66.5c-.7 0-2-.3-4-1-18.7-2.7-76-4.3-172-5H0V214h399571l6 1\nc124.7 8 235 61.7 331 161 31.3 33.3 59.7 72.7 85 118l7 13v35z", + rightbraceunder: "M399994 0l6 6v35l-6 11c-56 104-135.3 181.3-238 232-57.3\n 28.7-117 45-179 50H-300V214h399897c43.3-7 81-15 113-26 100.7-33 179.7-91 237\n-174 2.7-5 6-9 10-13 .7-1 7.3-1 20-1h17z", + rightgroup: "M0 80h399565c371 0 266.7 149.4 414 180 5.9 1.2 18 0 18 0 2 0\n 3-1 3-3v-38c-76-158-257-219-435-219H0z", + rightgroupunder: "M0 262h399565c371 0 266.7-149.4 414-180 5.9-1.2 18 0 18\n 0 2 0 3 1 3 3v38c-76 158-257 219-435 219H0z", + rightharpoon: "M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3\n-3.7-15.3-11-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2\n-10.7 0-16.7 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58\n 69.2 92 94.5zm0 0v40h399900v-40z", + rightharpoonplus: "M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3-3.7-15.3-11\n-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2-10.7 0-16.7\n 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58 69.2 92 94.5z\nm0 0v40h399900v-40z m100 194v40h399900v-40zm0 0v40h399900v-40z", + rightharpoondown: "M399747 511c0 7.3 6.7 11 20 11 8 0 13-.8 15-2.5s4.7-6.8\n 8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3 8.5-5.8 9.5\n-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3-64.7 57-92 95\n-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 241v40h399900v-40z", + rightharpoondownplus: "M399747 705c0 7.3 6.7 11 20 11 8 0 13-.8\n 15-2.5s4.7-6.8 8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3\n 8.5-5.8 9.5-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3\n-64.7 57-92 95-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 435v40h399900v-40z\nm0-194v40h400000v-40zm0 0v40h400000v-40z", + righthook: "M399859 241c-764 0 0 0 0 0 40-3.3 68.7-15.7 86-37 10-12 15-25.3\n 15-40 0-22.7-9.8-40.7-29.5-54-19.7-13.3-43.5-21-71.5-23-17.3-1.3-26-8-26-20 0\n-13.3 8.7-20 26-20 38 0 71 11.2 99 33.5 0 0 7 5.6 21 16.7 14 11.2 21 33.5 21\n 66.8s-14 61.2-42 83.5c-28 22.3-61 33.5-99 33.5L0 241z M0 281v-40h399859v40z", + rightlinesegment: doubleBrushStroke("M399960 241 V94 h40 V428 h-40 V281 H0 v-40z"), + rightbracketunder: doubleBrushStroke("M399995 0 h-120 V290 H0 v120 H400000z"), + rightbracketover: doubleBrushStroke("M399995 440 h-120 V150 H0 v-120 H399995z"), + rightToFrom: "M400000 167c-70.7-42-118-97.7-142-167h-23c-15.3 0-23 .3-23\n 1 0 1.3 5.3 13.7 16 37 18 35.3 41.3 69 70 101l7 8H0v40h399905l-7 8c-28.7 32\n-52 65.7-70 101-10.7 23.3-16 35.7-16 37 0 .7 7.7 1 23 1h23c24-69.3 71.3-125 142\n-167z M100 147v40h399900v-40zM0 341v40h399900v-40z", + // twoheadleftarrow is from glyph U+219E in font KaTeX AMS Regular + twoheadleftarrow: "M0 167c68 40\n 115.7 95.7 143 167h22c15.3 0 23-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69\n-70-101l-7-8h125l9 7c50.7 39.3 85 86 103 140h46c0-4.7-6.3-18.7-19-42-18-35.3\n-40-67.3-66-96l-9-9h399716v-40H284l9-9c26-28.7 48-60.7 66-96 12.7-23.333 19\n-37.333 19-42h-46c-18 54-52.3 100.7-103 140l-9 7H95l7-8c28.7-32 52-65.7 70-101\n 10.7-23.333 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 71.3 68 127 0 167z", + twoheadrightarrow: "M400000 167\nc-68-40-115.7-95.7-143-167h-22c-15.3 0-23 .3-23 1 0 1.3 5.3 13.7 16 37 18 35.3\n 41.3 69 70 101l7 8h-125l-9-7c-50.7-39.3-85-86-103-140h-46c0 4.7 6.3 18.7 19 42\n 18 35.3 40 67.3 66 96l9 9H0v40h399716l-9 9c-26 28.7-48 60.7-66 96-12.7 23.333\n-19 37.333-19 42h46c18-54 52.3-100.7 103-140l9-7h125l-7 8c-28.7 32-52 65.7-70\n 101-10.7 23.333-16 35.7-16 37 0 .7 7.7 1 23 1h22c27.3-71.3 75-127 143-167z", + // tilde1 is a modified version of a glyph from the MnSymbol package + tilde1: "M200 55.538c-77 0-168 73.953-177 73.953-3 0-7\n-2.175-9-5.437L2 97c-1-2-2-4-2-6 0-4 2-7 5-9l20-12C116 12 171 0 207 0c86 0\n 114 68 191 68 78 0 168-68 177-68 4 0 7 2 9 5l12 19c1 2.175 2 4.35 2 6.525 0\n 4.35-2 7.613-5 9.788l-19 13.05c-92 63.077-116.937 75.308-183 76.128\n-68.267.847-113-73.952-191-73.952z", + // ditto tilde2, tilde3, & tilde4 + tilde2: "M344 55.266c-142 0-300.638 81.316-311.5 86.418\n-8.01 3.762-22.5 10.91-23.5 5.562L1 120c-1-2-1-3-1-4 0-5 3-9 8-10l18.4-9C160.9\n 31.9 283 0 358 0c148 0 188 122 331 122s314-97 326-97c4 0 8 2 10 7l7 21.114\nc1 2.14 1 3.21 1 4.28 0 5.347-3 9.626-7 10.696l-22.3 12.622C852.6 158.372 751\n 181.476 676 181.476c-149 0-189-126.21-332-126.21z", + tilde3: "M786 59C457 59 32 175.242 13 175.242c-6 0-10-3.457\n-11-10.37L.15 138c-1-7 3-12 10-13l19.2-6.4C378.4 40.7 634.3 0 804.3 0c337 0\n 411.8 157 746.8 157 328 0 754-112 773-112 5 0 10 3 11 9l1 14.075c1 8.066-.697\n 16.595-6.697 17.492l-21.052 7.31c-367.9 98.146-609.15 122.696-778.15 122.696\n -338 0-409-156.573-744-156.573z", + tilde4: "M786 58C457 58 32 177.487 13 177.487c-6 0-10-3.345\n-11-10.035L.15 143c-1-7 3-12 10-13l22-6.7C381.2 35 637.15 0 807.15 0c337 0 409\n 177 744 177 328 0 754-127 773-127 5 0 10 3 11 9l1 14.794c1 7.805-3 13.38-9\n 14.495l-20.7 5.574c-366.85 99.79-607.3 139.372-776.3 139.372-338 0-409\n -175.236-744-175.236z", + // vec is from glyph U+20D7 in font KaTeX Main + vec: "M377 20c0-5.333 1.833-10 5.5-14S391 0 397 0c4.667 0 8.667 1.667 12 5\n3.333 2.667 6.667 9 10 19 6.667 24.667 20.333 43.667 41 57 7.333 4.667 11\n10.667 11 18 0 6-1 10-3 12s-6.667 5-14 9c-28.667 14.667-53.667 35.667-75 63\n-1.333 1.333-3.167 3.5-5.5 6.5s-4 4.833-5 5.5c-1 .667-2.5 1.333-4.5 2s-4.333 1\n-7 1c-4.667 0-9.167-1.833-13.5-5.5S337 184 337 178c0-12.667 15.667-32.333 47-59\nH213l-171-1c-8.667-6-13-12.333-13-19 0-4.667 4.333-11.333 13-20h359\nc-16-25.333-24-45-24-59z", + // widehat1 is a modified version of a glyph from the MnSymbol package + widehat1: "M529 0h5l519 115c5 1 9 5 9 10 0 1-1 2-1 3l-4 22\nc-1 5-5 9-11 9h-2L532 67 19 159h-2c-5 0-9-4-11-9l-5-22c-1-6 2-12 8-13z", + // ditto widehat2, widehat3, & widehat4 + widehat2: "M1181 0h2l1171 176c6 0 10 5 10 11l-2 23c-1 6-5 10\n-11 10h-1L1182 67 15 220h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z", + widehat3: "M1181 0h2l1171 236c6 0 10 5 10 11l-2 23c-1 6-5 10\n-11 10h-1L1182 67 15 280h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z", + widehat4: "M1181 0h2l1171 296c6 0 10 5 10 11l-2 23c-1 6-5 10\n-11 10h-1L1182 67 15 340h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z", + // widecheck paths are all inverted versions of widehat + widecheck1: "M529,159h5l519,-115c5,-1,9,-5,9,-10c0,-1,-1,-2,-1,-3l-4,-22c-1,\n-5,-5,-9,-11,-9h-2l-512,92l-513,-92h-2c-5,0,-9,4,-11,9l-5,22c-1,6,2,12,8,13z", + widecheck2: "M1181,220h2l1171,-176c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,\n-11,-10h-1l-1168,153l-1167,-153h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z", + widecheck3: "M1181,280h2l1171,-236c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,\n-11,-10h-1l-1168,213l-1167,-213h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z", + widecheck4: "M1181,340h2l1171,-296c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,\n-11,-10h-1l-1168,273l-1167,-273h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z", + // The next ten paths support reaction arrows from the mhchem package. + // Arrows for \ce{<-->} are offset from xAxis by 0.22ex, per mhchem in LaTeX + // baraboveleftarrow is mostly from glyph U+2190 in font KaTeX Main + baraboveleftarrow: "M400000 620h-399890l3 -3c68.7 -52.7 113.7 -120 135 -202\nc4 -14.7 6 -23 6 -25c0 -7.3 -7 -11 -21 -11c-8 0 -13.2 0.8 -15.5 2.5\nc-2.3 1.7 -4.2 5.8 -5.5 12.5c-1.3 4.7 -2.7 10.3 -4 17c-12 48.7 -34.8 92 -68.5 130\ns-74.2 66.3 -121.5 85c-10 4 -16 7.7 -18 11c0 8.7 6 14.3 18 17c47.3 18.7 87.8 47\n121.5 85s56.5 81.3 68.5 130c0.7 2 1.3 5 2 9s1.2 6.7 1.5 8c0.3 1.3 1 3.3 2 6\ns2.2 4.5 3.5 5.5c1.3 1 3.3 1.8 6 2.5s6 1 10 1c14 0 21 -3.7 21 -11\nc0 -2 -2 -10.3 -6 -25c-20 -79.3 -65 -146.7 -135 -202l-3 -3h399890z\nM100 620v40h399900v-40z M0 241v40h399900v-40zM0 241v40h399900v-40z", + // rightarrowabovebar is mostly from glyph U+2192, KaTeX Main + rightarrowabovebar: "M0 241v40h399891c-47.3 35.3-84 78-110 128-16.7 32\n-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20 11 8 0\n13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7 39\n-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85-40.5\n-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5\n-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67\n151.7 139 205zm96 379h399894v40H0zm0 0h399904v40H0z", + // The short left harpoon has 0.5em (i.e. 500 units) kern on the left end. + // Ref from mhchem.sty: \rlap{\raisebox{-.22ex}{$\kern0.5em + baraboveshortleftharpoon: "M507,435c-4,4,-6.3,8.7,-7,14c0,5.3,0.7,9,2,11\nc1.3,2,5.3,5.3,12,10c90.7,54,156,130,196,228c3.3,10.7,6.3,16.3,9,17\nc2,0.7,5,1,9,1c0,0,5,0,5,0c10.7,0,16.7,-2,18,-6c2,-2.7,1,-9.7,-3,-21\nc-32,-87.3,-82.7,-157.7,-152,-211c0,0,-3,-3,-3,-3l399351,0l0,-40\nc-398570,0,-399437,0,-399437,0z M593 435 v40 H399500 v-40z\nM0 281 v-40 H399908 v40z M0 281 v-40 H399908 v40z", + rightharpoonaboveshortbar: "M0,241 l0,40c399126,0,399993,0,399993,0\nc4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199,\n-231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6\nc-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z\nM0 241 v40 H399908 v-40z M0 475 v-40 H399500 v40z M0 475 v-40 H399500 v40z", + shortbaraboveleftharpoon: "M7,435c-4,4,-6.3,8.7,-7,14c0,5.3,0.7,9,2,11\nc1.3,2,5.3,5.3,12,10c90.7,54,156,130,196,228c3.3,10.7,6.3,16.3,9,17c2,0.7,5,1,9,\n1c0,0,5,0,5,0c10.7,0,16.7,-2,18,-6c2,-2.7,1,-9.7,-3,-21c-32,-87.3,-82.7,-157.7,\n-152,-211c0,0,-3,-3,-3,-3l399907,0l0,-40c-399126,0,-399993,0,-399993,0z\nM93 435 v40 H400000 v-40z M500 241 v40 H400000 v-40z M500 241 v40 H400000 v-40z", + shortrightharpoonabovebar: "M53,241l0,40c398570,0,399437,0,399437,0\nc4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199,\n-231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6\nc-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z\nM500 241 v40 H399408 v-40z M500 435 v40 H400000 v-40z" +}; +var tallDelim = function tallDelim(label, midHeight) { + switch (label) { + case "lbrack": + return "M403 1759 V84 H666 V0 H319 V1759 v" + midHeight + " v1759 v84 h347 v-84\nH403z M403 1759 V0 H319 V1759 v" + midHeight + " v1759 v84 h84z"; + case "rbrack": + return "M347 1759 V0 H0 V84 H263 V1759 v" + midHeight + " v1759 H0 v84 H347z\nM347 1759 V0 H263 V1759 v" + midHeight + " v1759 h84z"; + case "vert": + return "M145 15 v585 v" + midHeight + " v585 c2.667,10,9.667,15,21,15\nc10,0,16.667,-5,20,-15 v-585 v" + -midHeight + " v-585 c-2.667,-10,-9.667,-15,-21,-15\nc-10,0,-16.667,5,-20,15z M188 15 H145 v585 v" + midHeight + " v585 h43z"; + case "doublevert": + return "M145 15 v585 v" + midHeight + " v585 c2.667,10,9.667,15,21,15\nc10,0,16.667,-5,20,-15 v-585 v" + -midHeight + " v-585 c-2.667,-10,-9.667,-15,-21,-15\nc-10,0,-16.667,5,-20,15z M188 15 H145 v585 v" + midHeight + " v585 h43z\nM367 15 v585 v" + midHeight + " v585 c2.667,10,9.667,15,21,15\nc10,0,16.667,-5,20,-15 v-585 v" + -midHeight + " v-585 c-2.667,-10,-9.667,-15,-21,-15\nc-10,0,-16.667,5,-20,15z M410 15 H367 v585 v" + midHeight + " v585 h43z"; + case "lfloor": + return "M319 602 V0 H403 V602 v" + midHeight + " v1715 h263 v84 H319z\nMM319 602 V0 H403 V602 v" + midHeight + " v1715 H319z"; + case "rfloor": + return "M319 602 V0 H403 V602 v" + midHeight + " v1799 H0 v-84 H319z\nMM319 602 V0 H403 V602 v" + midHeight + " v1715 H319z"; + case "lceil": + return "M403 1759 V84 H666 V0 H319 V1759 v" + midHeight + " v602 h84z\nM403 1759 V0 H319 V1759 v" + midHeight + " v602 h84z"; + case "rceil": + return "M347 1759 V0 H0 V84 H263 V1759 v" + midHeight + " v602 h84z\nM347 1759 V0 h-84 V1759 v" + midHeight + " v602 h84z"; + case "lparen": + return "M863,9c0,-2,-2,-5,-6,-9c0,0,-17,0,-17,0c-12.7,0,-19.3,0.3,-20,1\nc-5.3,5.3,-10.3,11,-15,17c-242.7,294.7,-395.3,682,-458,1162c-21.3,163.3,-33.3,349,\n-36,557 l0," + (midHeight + 84) + "c0.2,6,0,26,0,60c2,159.3,10,310.7,24,454c53.3,528,210,\n949.7,470,1265c4.7,6,9.7,11.7,15,17c0.7,0.7,7,1,19,1c0,0,18,0,18,0c4,-4,6,-7,6,-9\nc0,-2.7,-3.3,-8.7,-10,-18c-135.3,-192.7,-235.5,-414.3,-300.5,-665c-65,-250.7,-102.5,\n-544.7,-112.5,-882c-2,-104,-3,-167,-3,-189\nl0,-" + (midHeight + 92) + "c0,-162.7,5.7,-314,17,-454c20.7,-272,63.7,-513,129,-723c65.3,\n-210,155.3,-396.3,270,-559c6.7,-9.3,10,-15.3,10,-18z"; + case "rparen": + return "M76,0c-16.7,0,-25,3,-25,9c0,2,2,6.3,6,13c21.3,28.7,42.3,60.3,\n63,95c96.7,156.7,172.8,332.5,228.5,527.5c55.7,195,92.8,416.5,111.5,664.5\nc11.3,139.3,17,290.7,17,454c0,28,1.7,43,3.3,45l0," + (midHeight + 9) + "\nc-3,4,-3.3,16.7,-3.3,38c0,162,-5.7,313.7,-17,455c-18.7,248,-55.8,469.3,-111.5,664\nc-55.7,194.7,-131.8,370.3,-228.5,527c-20.7,34.7,-41.7,66.3,-63,95c-2,3.3,-4,7,-6,11\nc0,7.3,5.7,11,17,11c0,0,11,0,11,0c9.3,0,14.3,-0.3,15,-1c5.3,-5.3,10.3,-11,15,-17\nc242.7,-294.7,395.3,-681.7,458,-1161c21.3,-164.7,33.3,-350.7,36,-558\nl0,-" + (midHeight + 144) + "c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,\n-470,-1265c-4.7,-6,-9.7,-11.7,-15,-17c-0.7,-0.7,-6.7,-1,-18,-1z"; + default: + // We should not ever get here. + throw new Error("Unknown stretchy delimiter."); + } +}; + +function isMathDomNode(node) { + return 'toText' in node; +} +/** + * This node represents a document fragment, which contains elements, but when + * placed into the DOM doesn't have any representation itself. It only contains + * children and doesn't have any DOM node properties. + */ +class DocumentFragment { + // Never used; needed for satisfying interface. + constructor(children) { + this.children = void 0; + this.classes = void 0; + this.height = void 0; + this.depth = void 0; + this.maxFontSize = void 0; + this.style = void 0; + this.children = children; + this.classes = []; + this.height = 0; + this.depth = 0; + this.maxFontSize = 0; + this.style = {}; + } + hasClass(className) { + return this.classes.includes(className); + } + /** Convert the fragment into a node. */ + toNode() { + var frag = document.createDocumentFragment(); + for (var i = 0; i < this.children.length; i++) { + frag.appendChild(this.children[i].toNode()); + } + return frag; + } + /** Convert the fragment into HTML markup. */ + toMarkup() { + var markup = ""; + // Simply concatenate the markup for the children together. + for (var i = 0; i < this.children.length; i++) { + markup += this.children[i].toMarkup(); + } + return markup; + } + /** + * Converts the math node into a string, similar to innerText. Applies to + * MathDomNode's only. + */ + toText() { + return this.children.map(child => { + if (isMathDomNode(child)) { + return child.toText(); + } + throw new Error("Expected MathDomNode with toText, got " + child.constructor.name); + }).join(""); + } +} + +/** + * This file does conversion between units. In particular, it provides + * calculateSize to convert other units into ems. + */ +// This table gives the number of TeX pts in one of each *absolute* TeX unit. +// Thus, multiplying a length by this number converts the length from units +// into pts. Dividing the result by ptPerEm gives the number of ems +// *assuming* a font size of ptPerEm (normal size, normal style). +var ptPerUnit = { + // https://en.wikibooks.org/wiki/LaTeX/Lengths and + // https://tex.stackexchange.com/a/8263 + "pt": 1, + // TeX point + "mm": 7227 / 2540, + // millimeter + "cm": 7227 / 254, + // centimeter + "in": 72.27, + // inch + "bp": 803 / 800, + // big (PostScript) points + "pc": 12, + // pica + "dd": 1238 / 1157, + // didot + "cc": 14856 / 1157, + // cicero (12 didot) + "nd": 685 / 642, + // new didot + "nc": 1370 / 107, + // new cicero (12 new didot) + "sp": 1 / 65536, + // scaled point (TeX's internal smallest unit) + // https://tex.stackexchange.com/a/41371 + "px": 803 / 800 // \pdfpxdimen defaults to 1 bp in pdfTeX and LuaTeX +}; +// Dictionary of relative units, for fast validity testing. +var relativeUnit = { + "ex": true, + "em": true, + "mu": true +}; +/** + * Determine whether the specified unit (either a string defining the unit + * or a "size" parse node containing a unit field) is valid. + */ +var validUnit = function validUnit(unit) { + if (typeof unit !== "string") { + unit = unit.unit; + } + return unit in ptPerUnit || unit in relativeUnit || unit === "ex"; +}; +/* + * Convert a "size" parse node (with numeric "number" and string "unit" fields, + * as parsed by functions.js argType "size") into a CSS em value for the + * current style/scale. `options` gives the current options. + */ +var calculateSize = function calculateSize(sizeValue, options) { + var scale; + if (sizeValue.unit in ptPerUnit) { + // Absolute units + scale = ptPerUnit[sizeValue.unit] // Convert unit to pt + / options.fontMetrics().ptPerEm // Convert pt to CSS em + / options.sizeMultiplier; // Unscale to make absolute units + } else if (sizeValue.unit === "mu") { + // `mu` units scale with scriptstyle/scriptscriptstyle. + scale = options.fontMetrics().cssEmPerMu; + } else { + // Other relative units always refer to the *textstyle* font + // in the current size. + var unitOptions; + if (options.style.isTight()) { + // isTight() means current style is script/scriptscript. + unitOptions = options.havingStyle(options.style.text()); + } else { + unitOptions = options; + } + // TODO: In TeX these units are relative to the quad of the current + // *text* font, e.g. cmr10. KaTeX instead uses values from the + // comparably-sized *Computer Modern symbol* font. At 10pt, these + // match. At 7pt and 5pt, they differ: cmr7=1.138894, cmsy7=1.170641; + // cmr5=1.361133, cmsy5=1.472241. Consider $\scriptsize a\kern1emb$. + // TeX \showlists shows a kern of 1.13889 * fontsize; + // KaTeX shows a kern of 1.171 * fontsize. + if (sizeValue.unit === "ex") { + scale = unitOptions.fontMetrics().xHeight; + } else if (sizeValue.unit === "em") { + scale = unitOptions.fontMetrics().quad; + } else { + throw new ParseError("Invalid unit: '" + sizeValue.unit + "'"); + } + if (unitOptions !== options) { + scale *= unitOptions.sizeMultiplier / options.sizeMultiplier; + } + } + return Math.min(sizeValue.number * scale, options.maxSize); +}; +/** + * Round `n` to 4 decimal places, or to the nearest 1/10,000th em. See + * https://github.com/KaTeX/KaTeX/pull/2460. + */ +var makeEm = function makeEm(n) { + return +n.toFixed(4) + "em"; +}; + +/** + * These objects store the data about the DOM nodes we create, as well as some + * extra data. They can then be transformed into real DOM nodes with the + * `toNode` function or HTML markup using `toMarkup`. They are useful for both + * storing extra properties on the nodes, as well as providing a way to easily + * work with the DOM. + * + * Similar functions for working with MathML nodes exist in mathMLTree.js. + * + * TODO: refactor `span` and `anchor` into common superclass when + * target environments support class inheritance + */ +/** + * Create an HTML className based on a list of classes. In addition to joining + * with spaces, we also remove empty classes. + */ +var createClass = function createClass(classes) { + return classes.filter(cls => cls).join(" "); +}; +/** + * Serialize a CssStyle object into a semicolon-delimited inline-style string + * (hyphenating camelCase property names). Returns "" when no property is set. + */ +var cssStyleToString = function cssStyleToString(style) { + var styles = ""; + for (var key of Object.keys(style)) { + var value = style[key]; + if (value !== undefined) { + styles += hyphenate(key) + ":" + value + ";"; + } + } + return styles; +}; +var initNode = function initNode(classes, options, style) { + this.classes = classes || []; + this.attributes = {}; + this.height = 0; + this.depth = 0; + this.maxFontSize = 0; + this.style = style || {}; + if (options) { + if (options.style.isTight()) { + this.classes.push("mtight"); + } + var color = options.getColor(); + if (color) { + this.style.color = color; + } + } +}; +/** + * Convert into an HTML node + */ +var toNode = function toNode(tagName) { + var node = document.createElement(tagName); + // Apply the class + node.className = createClass(this.classes); + // Apply inline styles + Object.assign(node.style, this.style); + // Apply attributes + for (var attr of Object.keys(this.attributes)) { + node.setAttribute(attr, this.attributes[attr]); + } + // Append the children, also as HTML nodes + for (var i = 0; i < this.children.length; i++) { + node.appendChild(this.children[i].toNode()); + } + return node; +}; +/** + * https://w3c.github.io/html-reference/syntax.html#syntax-attributes + * + * > Attribute Names must consist of one or more characters + * other than the space characters, U+0000 NULL, + * '"', "'", ">", "/", "=", the control characters, + * and any characters that are not defined by Unicode. + */ +var invalidAttributeNameRegex = /[\s"'>/=\x00-\x1f]/; +/** + * Convert into an HTML markup string + */ +var toMarkup = function toMarkup(tagName) { + var markup = "<" + tagName; + // Add the class + if (this.classes.length) { + markup += " class=\"" + escape(createClass(this.classes)) + "\""; + } + var styles = cssStyleToString(this.style); + if (styles) { + markup += " style=\"" + escape(styles) + "\""; + } + // Add the attributes + for (var attr of Object.keys(this.attributes)) { + if (invalidAttributeNameRegex.test(attr)) { + throw new ParseError("Invalid attribute name '" + attr + "'"); + } + markup += " " + attr + "=\"" + escape(this.attributes[attr]) + "\""; + } + markup += ">"; + // Add the markup of the children, also as markup + for (var i = 0; i < this.children.length; i++) { + markup += this.children[i].toMarkup(); + } + markup += ""; + return markup; +}; +/** + * This node represents a span node, with a className, a list of children, and + * an inline style. It also contains information about its height, depth, and + * maxFontSize. + * + * Represents two types with different uses: SvgSpan to wrap an SVG and DomSpan + * otherwise. This typesafety is important when HTML builders access a span's + * children. + */ +class Span { + constructor(classes, children, options, style) { + this.children = void 0; + this.attributes = void 0; + this.classes = void 0; + this.height = void 0; + this.depth = void 0; + this.width = void 0; + this.maxFontSize = void 0; + this.style = void 0; + /** + * Italic correction carried over from a SymbolNode when the symbol is + * wrapped in a vlist (e.g. \oiint / \oiiint). Read by supsub to adjust + * subscript positioning. Only set when nonzero; use `?? 0` at read sites. + */ + this.italic = void 0; + initNode.call(this, classes, options, style); + this.children = children || []; + } + /** + * Sets an arbitrary attribute on the span. Warning: use this wisely. Not + * all browsers support attributes the same, and having too many custom + * attributes is probably bad. + */ + setAttribute(attribute, value) { + this.attributes[attribute] = value; + } + hasClass(className) { + return this.classes.includes(className); + } + toNode() { + return toNode.call(this, "span"); + } + toMarkup() { + return toMarkup.call(this, "span"); + } +} +/** + * This node represents an anchor () element with a hyperlink. See `span` + * for further details. + */ +class Anchor { + constructor(href, classes, children, options) { + this.children = void 0; + this.attributes = void 0; + this.classes = void 0; + this.height = void 0; + this.depth = void 0; + this.maxFontSize = void 0; + this.style = void 0; + initNode.call(this, classes, options); + this.children = children || []; + this.setAttribute('href', href); + } + setAttribute(attribute, value) { + this.attributes[attribute] = value; + } + hasClass(className) { + return this.classes.includes(className); + } + toNode() { + return toNode.call(this, "a"); + } + toMarkup() { + return toMarkup.call(this, "a"); + } +} +/** + * This node represents an image embed () element. + */ +class Img { + constructor(src, alt, style) { + this.src = void 0; + this.alt = void 0; + this.classes = void 0; + this.height = void 0; + this.depth = void 0; + this.maxFontSize = void 0; + this.style = void 0; + this.alt = alt; + this.src = src; + this.classes = ["mord"]; + this.height = 0; + this.depth = 0; + this.maxFontSize = 0; + this.style = style; + } + hasClass(className) { + return this.classes.includes(className); + } + toNode() { + var node = document.createElement("img"); + node.src = this.src; + node.alt = this.alt; + node.className = "mord"; + // Apply inline styles + Object.assign(node.style, this.style); + return node; + } + toMarkup() { + var markup = "\"" 0) { + span = document.createElement("span"); + span.style.marginRight = makeEm(this.italic); + } + if (this.classes.length > 0) { + span = span || document.createElement("span"); + span.className = createClass(this.classes); + } + if (Object.keys(this.style).length > 0) { + span = span || document.createElement("span"); + Object.assign(span.style, this.style); + } + if (span) { + span.appendChild(node); + return span; + } else { + return node; + } + } + /** + * Creates markup for a symbol node. + */ + toMarkup() { + // TODO(alpert): More duplication than I'd like from + // span.prototype.toMarkup and symbolNode.prototype.toNode... + var needsSpan = false; + var markup = " 0) { + styles += "margin-right:" + makeEm(this.italic) + ";"; + } + styles += cssStyleToString(this.style); + if (styles) { + needsSpan = true; + markup += " style=\"" + escape(styles) + "\""; + } + var escaped = escape(this.text); + if (needsSpan) { + markup += ">"; + markup += escaped; + markup += ""; + return markup; + } else { + return escaped; + } + } +} +/** + * SVG nodes are used to render stretchy wide elements. + */ +class SvgNode { + constructor(children, attributes) { + this.children = void 0; + this.attributes = void 0; + this.children = children || []; + this.attributes = attributes || {}; + } + toNode() { + var svgNS = "http://www.w3.org/2000/svg"; + var node = document.createElementNS(svgNS, "svg"); + // Apply attributes + for (var attr of Object.keys(this.attributes)) { + node.setAttribute(attr, this.attributes[attr]); + } + for (var i = 0; i < this.children.length; i++) { + node.appendChild(this.children[i].toNode()); + } + return node; + } + toMarkup() { + var markup = ""; + } else { + return ""; + } + } +} +class LineNode { + constructor(attributes) { + this.attributes = void 0; + this.attributes = attributes || {}; + } + toNode() { + var svgNS = "http://www.w3.org/2000/svg"; + var node = document.createElementNS(svgNS, "line"); + // Apply attributes + for (var attr of Object.keys(this.attributes)) { + node.setAttribute(attr, this.attributes[attr]); + } + return node; + } + toMarkup() { + var markup = " but got " + String(group) + "."); + } +} +/** + * Whether an HtmlDomNode has HtmlDomNode children. + * HtmlDomNode is a base type representing a union of + * SymbolNode, SvgSpan, DomSpan, Anchor, and documentFragment. + * In the last three cases, the children are HtmlDomNode[]. + */ +var hasHtmlDomChildren = node => node instanceof Span || node instanceof Anchor || node instanceof DocumentFragment; + +// This file is GENERATED by buildMetrics.sh. DO NOT MODIFY. +var fontMetricsData = { + "AMS-Regular": { + "32": [0, 0, 0, 0, 0.25], + "65": [0, 0.68889, 0, 0, 0.72222], + "66": [0, 0.68889, 0, 0, 0.66667], + "67": [0, 0.68889, 0, 0, 0.72222], + "68": [0, 0.68889, 0, 0, 0.72222], + "69": [0, 0.68889, 0, 0, 0.66667], + "70": [0, 0.68889, 0, 0, 0.61111], + "71": [0, 0.68889, 0, 0, 0.77778], + "72": [0, 0.68889, 0, 0, 0.77778], + "73": [0, 0.68889, 0, 0, 0.38889], + "74": [0.16667, 0.68889, 0, 0, 0.5], + "75": [0, 0.68889, 0, 0, 0.77778], + "76": [0, 0.68889, 0, 0, 0.66667], + "77": [0, 0.68889, 0, 0, 0.94445], + "78": [0, 0.68889, 0, 0, 0.72222], + "79": [0.16667, 0.68889, 0, 0, 0.77778], + "80": [0, 0.68889, 0, 0, 0.61111], + "81": [0.16667, 0.68889, 0, 0, 0.77778], + "82": [0, 0.68889, 0, 0, 0.72222], + "83": [0, 0.68889, 0, 0, 0.55556], + "84": [0, 0.68889, 0, 0, 0.66667], + "85": [0, 0.68889, 0, 0, 0.72222], + "86": [0, 0.68889, 0, 0, 0.72222], + "87": [0, 0.68889, 0, 0, 1.0], + "88": [0, 0.68889, 0, 0, 0.72222], + "89": [0, 0.68889, 0, 0, 0.72222], + "90": [0, 0.68889, 0, 0, 0.66667], + "107": [0, 0.68889, 0, 0, 0.55556], + "160": [0, 0, 0, 0, 0.25], + "165": [0, 0.675, 0.025, 0, 0.75], + "174": [0.15559, 0.69224, 0, 0, 0.94666], + "240": [0, 0.68889, 0, 0, 0.55556], + "295": [0, 0.68889, 0, 0, 0.54028], + "710": [0, 0.825, 0, 0, 2.33334], + "732": [0, 0.9, 0, 0, 2.33334], + "770": [0, 0.825, 0, 0, 2.33334], + "771": [0, 0.9, 0, 0, 2.33334], + "989": [0.08167, 0.58167, 0, 0, 0.77778], + "1008": [0, 0.43056, 0.04028, 0, 0.66667], + "8245": [0, 0.54986, 0, 0, 0.275], + "8463": [0, 0.68889, 0, 0, 0.54028], + "8487": [0, 0.68889, 0, 0, 0.72222], + "8498": [0, 0.68889, 0, 0, 0.55556], + "8502": [0, 0.68889, 0, 0, 0.66667], + "8503": [0, 0.68889, 0, 0, 0.44445], + "8504": [0, 0.68889, 0, 0, 0.66667], + "8513": [0, 0.68889, 0, 0, 0.63889], + "8592": [-0.03598, 0.46402, 0, 0, 0.5], + "8594": [-0.03598, 0.46402, 0, 0, 0.5], + "8602": [-0.13313, 0.36687, 0, 0, 1.0], + "8603": [-0.13313, 0.36687, 0, 0, 1.0], + "8606": [0.01354, 0.52239, 0, 0, 1.0], + "8608": [0.01354, 0.52239, 0, 0, 1.0], + "8610": [0.01354, 0.52239, 0, 0, 1.11111], + "8611": [0.01354, 0.52239, 0, 0, 1.11111], + "8619": [0, 0.54986, 0, 0, 1.0], + "8620": [0, 0.54986, 0, 0, 1.0], + "8621": [-0.13313, 0.37788, 0, 0, 1.38889], + "8622": [-0.13313, 0.36687, 0, 0, 1.0], + "8624": [0, 0.69224, 0, 0, 0.5], + "8625": [0, 0.69224, 0, 0, 0.5], + "8630": [0, 0.43056, 0, 0, 1.0], + "8631": [0, 0.43056, 0, 0, 1.0], + "8634": [0.08198, 0.58198, 0, 0, 0.77778], + "8635": [0.08198, 0.58198, 0, 0, 0.77778], + "8638": [0.19444, 0.69224, 0, 0, 0.41667], + "8639": [0.19444, 0.69224, 0, 0, 0.41667], + "8642": [0.19444, 0.69224, 0, 0, 0.41667], + "8643": [0.19444, 0.69224, 0, 0, 0.41667], + "8644": [0.1808, 0.675, 0, 0, 1.0], + "8646": [0.1808, 0.675, 0, 0, 1.0], + "8647": [0.1808, 0.675, 0, 0, 1.0], + "8648": [0.19444, 0.69224, 0, 0, 0.83334], + "8649": [0.1808, 0.675, 0, 0, 1.0], + "8650": [0.19444, 0.69224, 0, 0, 0.83334], + "8651": [0.01354, 0.52239, 0, 0, 1.0], + "8652": [0.01354, 0.52239, 0, 0, 1.0], + "8653": [-0.13313, 0.36687, 0, 0, 1.0], + "8654": [-0.13313, 0.36687, 0, 0, 1.0], + "8655": [-0.13313, 0.36687, 0, 0, 1.0], + "8666": [0.13667, 0.63667, 0, 0, 1.0], + "8667": [0.13667, 0.63667, 0, 0, 1.0], + "8669": [-0.13313, 0.37788, 0, 0, 1.0], + "8672": [-0.064, 0.437, 0, 0, 1.334], + "8674": [-0.064, 0.437, 0, 0, 1.334], + "8705": [0, 0.825, 0, 0, 0.5], + "8708": [0, 0.68889, 0, 0, 0.55556], + "8709": [0.08167, 0.58167, 0, 0, 0.77778], + "8717": [0, 0.43056, 0, 0, 0.42917], + "8722": [-0.03598, 0.46402, 0, 0, 0.5], + "8724": [0.08198, 0.69224, 0, 0, 0.77778], + "8726": [0.08167, 0.58167, 0, 0, 0.77778], + "8733": [0, 0.69224, 0, 0, 0.77778], + "8736": [0, 0.69224, 0, 0, 0.72222], + "8737": [0, 0.69224, 0, 0, 0.72222], + "8738": [0.03517, 0.52239, 0, 0, 0.72222], + "8739": [0.08167, 0.58167, 0, 0, 0.22222], + "8740": [0.25142, 0.74111, 0, 0, 0.27778], + "8741": [0.08167, 0.58167, 0, 0, 0.38889], + "8742": [0.25142, 0.74111, 0, 0, 0.5], + "8756": [0, 0.69224, 0, 0, 0.66667], + "8757": [0, 0.69224, 0, 0, 0.66667], + "8764": [-0.13313, 0.36687, 0, 0, 0.77778], + "8765": [-0.13313, 0.37788, 0, 0, 0.77778], + "8769": [-0.13313, 0.36687, 0, 0, 0.77778], + "8770": [-0.03625, 0.46375, 0, 0, 0.77778], + "8774": [0.30274, 0.79383, 0, 0, 0.77778], + "8776": [-0.01688, 0.48312, 0, 0, 0.77778], + "8778": [0.08167, 0.58167, 0, 0, 0.77778], + "8782": [0.06062, 0.54986, 0, 0, 0.77778], + "8783": [0.06062, 0.54986, 0, 0, 0.77778], + "8785": [0.08198, 0.58198, 0, 0, 0.77778], + "8786": [0.08198, 0.58198, 0, 0, 0.77778], + "8787": [0.08198, 0.58198, 0, 0, 0.77778], + "8790": [0, 0.69224, 0, 0, 0.77778], + "8791": [0.22958, 0.72958, 0, 0, 0.77778], + "8796": [0.08198, 0.91667, 0, 0, 0.77778], + "8806": [0.25583, 0.75583, 0, 0, 0.77778], + "8807": [0.25583, 0.75583, 0, 0, 0.77778], + "8808": [0.25142, 0.75726, 0, 0, 0.77778], + "8809": [0.25142, 0.75726, 0, 0, 0.77778], + "8812": [0.25583, 0.75583, 0, 0, 0.5], + "8814": [0.20576, 0.70576, 0, 0, 0.77778], + "8815": [0.20576, 0.70576, 0, 0, 0.77778], + "8816": [0.30274, 0.79383, 0, 0, 0.77778], + "8817": [0.30274, 0.79383, 0, 0, 0.77778], + "8818": [0.22958, 0.72958, 0, 0, 0.77778], + "8819": [0.22958, 0.72958, 0, 0, 0.77778], + "8822": [0.1808, 0.675, 0, 0, 0.77778], + "8823": [0.1808, 0.675, 0, 0, 0.77778], + "8828": [0.13667, 0.63667, 0, 0, 0.77778], + "8829": [0.13667, 0.63667, 0, 0, 0.77778], + "8830": [0.22958, 0.72958, 0, 0, 0.77778], + "8831": [0.22958, 0.72958, 0, 0, 0.77778], + "8832": [0.20576, 0.70576, 0, 0, 0.77778], + "8833": [0.20576, 0.70576, 0, 0, 0.77778], + "8840": [0.30274, 0.79383, 0, 0, 0.77778], + "8841": [0.30274, 0.79383, 0, 0, 0.77778], + "8842": [0.13597, 0.63597, 0, 0, 0.77778], + "8843": [0.13597, 0.63597, 0, 0, 0.77778], + "8847": [0.03517, 0.54986, 0, 0, 0.77778], + "8848": [0.03517, 0.54986, 0, 0, 0.77778], + "8858": [0.08198, 0.58198, 0, 0, 0.77778], + "8859": [0.08198, 0.58198, 0, 0, 0.77778], + "8861": [0.08198, 0.58198, 0, 0, 0.77778], + "8862": [0, 0.675, 0, 0, 0.77778], + "8863": [0, 0.675, 0, 0, 0.77778], + "8864": [0, 0.675, 0, 0, 0.77778], + "8865": [0, 0.675, 0, 0, 0.77778], + "8872": [0, 0.69224, 0, 0, 0.61111], + "8873": [0, 0.69224, 0, 0, 0.72222], + "8874": [0, 0.69224, 0, 0, 0.88889], + "8876": [0, 0.68889, 0, 0, 0.61111], + "8877": [0, 0.68889, 0, 0, 0.61111], + "8878": [0, 0.68889, 0, 0, 0.72222], + "8879": [0, 0.68889, 0, 0, 0.72222], + "8882": [0.03517, 0.54986, 0, 0, 0.77778], + "8883": [0.03517, 0.54986, 0, 0, 0.77778], + "8884": [0.13667, 0.63667, 0, 0, 0.77778], + "8885": [0.13667, 0.63667, 0, 0, 0.77778], + "8888": [0, 0.54986, 0, 0, 1.11111], + "8890": [0.19444, 0.43056, 0, 0, 0.55556], + "8891": [0.19444, 0.69224, 0, 0, 0.61111], + "8892": [0.19444, 0.69224, 0, 0, 0.61111], + "8901": [0, 0.54986, 0, 0, 0.27778], + "8903": [0.08167, 0.58167, 0, 0, 0.77778], + "8905": [0.08167, 0.58167, 0, 0, 0.77778], + "8906": [0.08167, 0.58167, 0, 0, 0.77778], + "8907": [0, 0.69224, 0, 0, 0.77778], + "8908": [0, 0.69224, 0, 0, 0.77778], + "8909": [-0.03598, 0.46402, 0, 0, 0.77778], + "8910": [0, 0.54986, 0, 0, 0.76042], + "8911": [0, 0.54986, 0, 0, 0.76042], + "8912": [0.03517, 0.54986, 0, 0, 0.77778], + "8913": [0.03517, 0.54986, 0, 0, 0.77778], + "8914": [0, 0.54986, 0, 0, 0.66667], + "8915": [0, 0.54986, 0, 0, 0.66667], + "8916": [0, 0.69224, 0, 0, 0.66667], + "8918": [0.0391, 0.5391, 0, 0, 0.77778], + "8919": [0.0391, 0.5391, 0, 0, 0.77778], + "8920": [0.03517, 0.54986, 0, 0, 1.33334], + "8921": [0.03517, 0.54986, 0, 0, 1.33334], + "8922": [0.38569, 0.88569, 0, 0, 0.77778], + "8923": [0.38569, 0.88569, 0, 0, 0.77778], + "8926": [0.13667, 0.63667, 0, 0, 0.77778], + "8927": [0.13667, 0.63667, 0, 0, 0.77778], + "8928": [0.30274, 0.79383, 0, 0, 0.77778], + "8929": [0.30274, 0.79383, 0, 0, 0.77778], + "8934": [0.23222, 0.74111, 0, 0, 0.77778], + "8935": [0.23222, 0.74111, 0, 0, 0.77778], + "8936": [0.23222, 0.74111, 0, 0, 0.77778], + "8937": [0.23222, 0.74111, 0, 0, 0.77778], + "8938": [0.20576, 0.70576, 0, 0, 0.77778], + "8939": [0.20576, 0.70576, 0, 0, 0.77778], + "8940": [0.30274, 0.79383, 0, 0, 0.77778], + "8941": [0.30274, 0.79383, 0, 0, 0.77778], + "8994": [0.19444, 0.69224, 0, 0, 0.77778], + "8995": [0.19444, 0.69224, 0, 0, 0.77778], + "9416": [0.15559, 0.69224, 0, 0, 0.90222], + "9484": [0, 0.69224, 0, 0, 0.5], + "9488": [0, 0.69224, 0, 0, 0.5], + "9492": [0, 0.37788, 0, 0, 0.5], + "9496": [0, 0.37788, 0, 0, 0.5], + "9585": [0.19444, 0.68889, 0, 0, 0.88889], + "9586": [0.19444, 0.74111, 0, 0, 0.88889], + "9632": [0, 0.675, 0, 0, 0.77778], + "9633": [0, 0.675, 0, 0, 0.77778], + "9650": [0, 0.54986, 0, 0, 0.72222], + "9651": [0, 0.54986, 0, 0, 0.72222], + "9654": [0.03517, 0.54986, 0, 0, 0.77778], + "9660": [0, 0.54986, 0, 0, 0.72222], + "9661": [0, 0.54986, 0, 0, 0.72222], + "9664": [0.03517, 0.54986, 0, 0, 0.77778], + "9674": [0.11111, 0.69224, 0, 0, 0.66667], + "9733": [0.19444, 0.69224, 0, 0, 0.94445], + "10003": [0, 0.69224, 0, 0, 0.83334], + "10016": [0, 0.69224, 0, 0, 0.83334], + "10731": [0.11111, 0.69224, 0, 0, 0.66667], + "10846": [0.19444, 0.75583, 0, 0, 0.61111], + "10877": [0.13667, 0.63667, 0, 0, 0.77778], + "10878": [0.13667, 0.63667, 0, 0, 0.77778], + "10885": [0.25583, 0.75583, 0, 0, 0.77778], + "10886": [0.25583, 0.75583, 0, 0, 0.77778], + "10887": [0.13597, 0.63597, 0, 0, 0.77778], + "10888": [0.13597, 0.63597, 0, 0, 0.77778], + "10889": [0.26167, 0.75726, 0, 0, 0.77778], + "10890": [0.26167, 0.75726, 0, 0, 0.77778], + "10891": [0.48256, 0.98256, 0, 0, 0.77778], + "10892": [0.48256, 0.98256, 0, 0, 0.77778], + "10901": [0.13667, 0.63667, 0, 0, 0.77778], + "10902": [0.13667, 0.63667, 0, 0, 0.77778], + "10933": [0.25142, 0.75726, 0, 0, 0.77778], + "10934": [0.25142, 0.75726, 0, 0, 0.77778], + "10935": [0.26167, 0.75726, 0, 0, 0.77778], + "10936": [0.26167, 0.75726, 0, 0, 0.77778], + "10937": [0.26167, 0.75726, 0, 0, 0.77778], + "10938": [0.26167, 0.75726, 0, 0, 0.77778], + "10949": [0.25583, 0.75583, 0, 0, 0.77778], + "10950": [0.25583, 0.75583, 0, 0, 0.77778], + "10955": [0.28481, 0.79383, 0, 0, 0.77778], + "10956": [0.28481, 0.79383, 0, 0, 0.77778], + "57350": [0.08167, 0.58167, 0, 0, 0.22222], + "57351": [0.08167, 0.58167, 0, 0, 0.38889], + "57352": [0.08167, 0.58167, 0, 0, 0.77778], + "57353": [0, 0.43056, 0.04028, 0, 0.66667], + "57356": [0.25142, 0.75726, 0, 0, 0.77778], + "57357": [0.25142, 0.75726, 0, 0, 0.77778], + "57358": [0.41951, 0.91951, 0, 0, 0.77778], + "57359": [0.30274, 0.79383, 0, 0, 0.77778], + "57360": [0.30274, 0.79383, 0, 0, 0.77778], + "57361": [0.41951, 0.91951, 0, 0, 0.77778], + "57366": [0.25142, 0.75726, 0, 0, 0.77778], + "57367": [0.25142, 0.75726, 0, 0, 0.77778], + "57368": [0.25142, 0.75726, 0, 0, 0.77778], + "57369": [0.25142, 0.75726, 0, 0, 0.77778], + "57370": [0.13597, 0.63597, 0, 0, 0.77778], + "57371": [0.13597, 0.63597, 0, 0, 0.77778] + }, + "Caligraphic-Regular": { + "32": [0, 0, 0, 0, 0.25], + "65": [0, 0.68333, 0, 0.19445, 0.79847], + "66": [0, 0.68333, 0.03041, 0.13889, 0.65681], + "67": [0, 0.68333, 0.05834, 0.13889, 0.52653], + "68": [0, 0.68333, 0.02778, 0.08334, 0.77139], + "69": [0, 0.68333, 0.08944, 0.11111, 0.52778], + "70": [0, 0.68333, 0.09931, 0.11111, 0.71875], + "71": [0.09722, 0.68333, 0.0593, 0.11111, 0.59487], + "72": [0, 0.68333, 0.00965, 0.11111, 0.84452], + "73": [0, 0.68333, 0.07382, 0, 0.54452], + "74": [0.09722, 0.68333, 0.18472, 0.16667, 0.67778], + "75": [0, 0.68333, 0.01445, 0.05556, 0.76195], + "76": [0, 0.68333, 0, 0.13889, 0.68972], + "77": [0, 0.68333, 0, 0.13889, 1.2009], + "78": [0, 0.68333, 0.14736, 0.08334, 0.82049], + "79": [0, 0.68333, 0.02778, 0.11111, 0.79611], + "80": [0, 0.68333, 0.08222, 0.08334, 0.69556], + "81": [0.09722, 0.68333, 0, 0.11111, 0.81667], + "82": [0, 0.68333, 0, 0.08334, 0.8475], + "83": [0, 0.68333, 0.075, 0.13889, 0.60556], + "84": [0, 0.68333, 0.25417, 0, 0.54464], + "85": [0, 0.68333, 0.09931, 0.08334, 0.62583], + "86": [0, 0.68333, 0.08222, 0, 0.61278], + "87": [0, 0.68333, 0.08222, 0.08334, 0.98778], + "88": [0, 0.68333, 0.14643, 0.13889, 0.7133], + "89": [0.09722, 0.68333, 0.08222, 0.08334, 0.66834], + "90": [0, 0.68333, 0.07944, 0.13889, 0.72473], + "160": [0, 0, 0, 0, 0.25] + }, + "Fraktur-Regular": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69141, 0, 0, 0.29574], + "34": [0, 0.69141, 0, 0, 0.21471], + "38": [0, 0.69141, 0, 0, 0.73786], + "39": [0, 0.69141, 0, 0, 0.21201], + "40": [0.24982, 0.74947, 0, 0, 0.38865], + "41": [0.24982, 0.74947, 0, 0, 0.38865], + "42": [0, 0.62119, 0, 0, 0.27764], + "43": [0.08319, 0.58283, 0, 0, 0.75623], + "44": [0, 0.10803, 0, 0, 0.27764], + "45": [0.08319, 0.58283, 0, 0, 0.75623], + "46": [0, 0.10803, 0, 0, 0.27764], + "47": [0.24982, 0.74947, 0, 0, 0.50181], + "48": [0, 0.47534, 0, 0, 0.50181], + "49": [0, 0.47534, 0, 0, 0.50181], + "50": [0, 0.47534, 0, 0, 0.50181], + "51": [0.18906, 0.47534, 0, 0, 0.50181], + "52": [0.18906, 0.47534, 0, 0, 0.50181], + "53": [0.18906, 0.47534, 0, 0, 0.50181], + "54": [0, 0.69141, 0, 0, 0.50181], + "55": [0.18906, 0.47534, 0, 0, 0.50181], + "56": [0, 0.69141, 0, 0, 0.50181], + "57": [0.18906, 0.47534, 0, 0, 0.50181], + "58": [0, 0.47534, 0, 0, 0.21606], + "59": [0.12604, 0.47534, 0, 0, 0.21606], + "61": [-0.13099, 0.36866, 0, 0, 0.75623], + "63": [0, 0.69141, 0, 0, 0.36245], + "65": [0, 0.69141, 0, 0, 0.7176], + "66": [0, 0.69141, 0, 0, 0.88397], + "67": [0, 0.69141, 0, 0, 0.61254], + "68": [0, 0.69141, 0, 0, 0.83158], + "69": [0, 0.69141, 0, 0, 0.66278], + "70": [0.12604, 0.69141, 0, 0, 0.61119], + "71": [0, 0.69141, 0, 0, 0.78539], + "72": [0.06302, 0.69141, 0, 0, 0.7203], + "73": [0, 0.69141, 0, 0, 0.55448], + "74": [0.12604, 0.69141, 0, 0, 0.55231], + "75": [0, 0.69141, 0, 0, 0.66845], + "76": [0, 0.69141, 0, 0, 0.66602], + "77": [0, 0.69141, 0, 0, 1.04953], + "78": [0, 0.69141, 0, 0, 0.83212], + "79": [0, 0.69141, 0, 0, 0.82699], + "80": [0.18906, 0.69141, 0, 0, 0.82753], + "81": [0.03781, 0.69141, 0, 0, 0.82699], + "82": [0, 0.69141, 0, 0, 0.82807], + "83": [0, 0.69141, 0, 0, 0.82861], + "84": [0, 0.69141, 0, 0, 0.66899], + "85": [0, 0.69141, 0, 0, 0.64576], + "86": [0, 0.69141, 0, 0, 0.83131], + "87": [0, 0.69141, 0, 0, 1.04602], + "88": [0, 0.69141, 0, 0, 0.71922], + "89": [0.18906, 0.69141, 0, 0, 0.83293], + "90": [0.12604, 0.69141, 0, 0, 0.60201], + "91": [0.24982, 0.74947, 0, 0, 0.27764], + "93": [0.24982, 0.74947, 0, 0, 0.27764], + "94": [0, 0.69141, 0, 0, 0.49965], + "97": [0, 0.47534, 0, 0, 0.50046], + "98": [0, 0.69141, 0, 0, 0.51315], + "99": [0, 0.47534, 0, 0, 0.38946], + "100": [0, 0.62119, 0, 0, 0.49857], + "101": [0, 0.47534, 0, 0, 0.40053], + "102": [0.18906, 0.69141, 0, 0, 0.32626], + "103": [0.18906, 0.47534, 0, 0, 0.5037], + "104": [0.18906, 0.69141, 0, 0, 0.52126], + "105": [0, 0.69141, 0, 0, 0.27899], + "106": [0, 0.69141, 0, 0, 0.28088], + "107": [0, 0.69141, 0, 0, 0.38946], + "108": [0, 0.69141, 0, 0, 0.27953], + "109": [0, 0.47534, 0, 0, 0.76676], + "110": [0, 0.47534, 0, 0, 0.52666], + "111": [0, 0.47534, 0, 0, 0.48885], + "112": [0.18906, 0.52396, 0, 0, 0.50046], + "113": [0.18906, 0.47534, 0, 0, 0.48912], + "114": [0, 0.47534, 0, 0, 0.38919], + "115": [0, 0.47534, 0, 0, 0.44266], + "116": [0, 0.62119, 0, 0, 0.33301], + "117": [0, 0.47534, 0, 0, 0.5172], + "118": [0, 0.52396, 0, 0, 0.5118], + "119": [0, 0.52396, 0, 0, 0.77351], + "120": [0.18906, 0.47534, 0, 0, 0.38865], + "121": [0.18906, 0.47534, 0, 0, 0.49884], + "122": [0.18906, 0.47534, 0, 0, 0.39054], + "160": [0, 0, 0, 0, 0.25], + "8216": [0, 0.69141, 0, 0, 0.21471], + "8217": [0, 0.69141, 0, 0, 0.21471], + "58112": [0, 0.62119, 0, 0, 0.49749], + "58113": [0, 0.62119, 0, 0, 0.4983], + "58114": [0.18906, 0.69141, 0, 0, 0.33328], + "58115": [0.18906, 0.69141, 0, 0, 0.32923], + "58116": [0.18906, 0.47534, 0, 0, 0.50343], + "58117": [0, 0.69141, 0, 0, 0.33301], + "58118": [0, 0.62119, 0, 0, 0.33409], + "58119": [0, 0.47534, 0, 0, 0.50073] + }, + "Main-Bold": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0, 0, 0.35], + "34": [0, 0.69444, 0, 0, 0.60278], + "35": [0.19444, 0.69444, 0, 0, 0.95833], + "36": [0.05556, 0.75, 0, 0, 0.575], + "37": [0.05556, 0.75, 0, 0, 0.95833], + "38": [0, 0.69444, 0, 0, 0.89444], + "39": [0, 0.69444, 0, 0, 0.31944], + "40": [0.25, 0.75, 0, 0, 0.44722], + "41": [0.25, 0.75, 0, 0, 0.44722], + "42": [0, 0.75, 0, 0, 0.575], + "43": [0.13333, 0.63333, 0, 0, 0.89444], + "44": [0.19444, 0.15556, 0, 0, 0.31944], + "45": [0, 0.44444, 0, 0, 0.38333], + "46": [0, 0.15556, 0, 0, 0.31944], + "47": [0.25, 0.75, 0, 0, 0.575], + "48": [0, 0.64444, 0, 0, 0.575], + "49": [0, 0.64444, 0, 0, 0.575], + "50": [0, 0.64444, 0, 0, 0.575], + "51": [0, 0.64444, 0, 0, 0.575], + "52": [0, 0.64444, 0, 0, 0.575], + "53": [0, 0.64444, 0, 0, 0.575], + "54": [0, 0.64444, 0, 0, 0.575], + "55": [0, 0.64444, 0, 0, 0.575], + "56": [0, 0.64444, 0, 0, 0.575], + "57": [0, 0.64444, 0, 0, 0.575], + "58": [0, 0.44444, 0, 0, 0.31944], + "59": [0.19444, 0.44444, 0, 0, 0.31944], + "60": [0.08556, 0.58556, 0, 0, 0.89444], + "61": [-0.10889, 0.39111, 0, 0, 0.89444], + "62": [0.08556, 0.58556, 0, 0, 0.89444], + "63": [0, 0.69444, 0, 0, 0.54305], + "64": [0, 0.69444, 0, 0, 0.89444], + "65": [0, 0.68611, 0, 0, 0.86944], + "66": [0, 0.68611, 0, 0, 0.81805], + "67": [0, 0.68611, 0, 0, 0.83055], + "68": [0, 0.68611, 0, 0, 0.88194], + "69": [0, 0.68611, 0, 0, 0.75555], + "70": [0, 0.68611, 0, 0, 0.72361], + "71": [0, 0.68611, 0, 0, 0.90416], + "72": [0, 0.68611, 0, 0, 0.9], + "73": [0, 0.68611, 0, 0, 0.43611], + "74": [0, 0.68611, 0, 0, 0.59444], + "75": [0, 0.68611, 0, 0, 0.90138], + "76": [0, 0.68611, 0, 0, 0.69166], + "77": [0, 0.68611, 0, 0, 1.09166], + "78": [0, 0.68611, 0, 0, 0.9], + "79": [0, 0.68611, 0, 0, 0.86388], + "80": [0, 0.68611, 0, 0, 0.78611], + "81": [0.19444, 0.68611, 0, 0, 0.86388], + "82": [0, 0.68611, 0, 0, 0.8625], + "83": [0, 0.68611, 0, 0, 0.63889], + "84": [0, 0.68611, 0, 0, 0.8], + "85": [0, 0.68611, 0, 0, 0.88472], + "86": [0, 0.68611, 0.01597, 0, 0.86944], + "87": [0, 0.68611, 0.01597, 0, 1.18888], + "88": [0, 0.68611, 0, 0, 0.86944], + "89": [0, 0.68611, 0.02875, 0, 0.86944], + "90": [0, 0.68611, 0, 0, 0.70277], + "91": [0.25, 0.75, 0, 0, 0.31944], + "92": [0.25, 0.75, 0, 0, 0.575], + "93": [0.25, 0.75, 0, 0, 0.31944], + "94": [0, 0.69444, 0, 0, 0.575], + "95": [0.31, 0.13444, 0.03194, 0, 0.575], + "97": [0, 0.44444, 0, 0, 0.55902], + "98": [0, 0.69444, 0, 0, 0.63889], + "99": [0, 0.44444, 0, 0, 0.51111], + "100": [0, 0.69444, 0, 0, 0.63889], + "101": [0, 0.44444, 0, 0, 0.52708], + "102": [0, 0.69444, 0.10903, 0, 0.35139], + "103": [0.19444, 0.44444, 0.01597, 0, 0.575], + "104": [0, 0.69444, 0, 0, 0.63889], + "105": [0, 0.69444, 0, 0, 0.31944], + "106": [0.19444, 0.69444, 0, 0, 0.35139], + "107": [0, 0.69444, 0, 0, 0.60694], + "108": [0, 0.69444, 0, 0, 0.31944], + "109": [0, 0.44444, 0, 0, 0.95833], + "110": [0, 0.44444, 0, 0, 0.63889], + "111": [0, 0.44444, 0, 0, 0.575], + "112": [0.19444, 0.44444, 0, 0, 0.63889], + "113": [0.19444, 0.44444, 0, 0, 0.60694], + "114": [0, 0.44444, 0, 0, 0.47361], + "115": [0, 0.44444, 0, 0, 0.45361], + "116": [0, 0.63492, 0, 0, 0.44722], + "117": [0, 0.44444, 0, 0, 0.63889], + "118": [0, 0.44444, 0.01597, 0, 0.60694], + "119": [0, 0.44444, 0.01597, 0, 0.83055], + "120": [0, 0.44444, 0, 0, 0.60694], + "121": [0.19444, 0.44444, 0.01597, 0, 0.60694], + "122": [0, 0.44444, 0, 0, 0.51111], + "123": [0.25, 0.75, 0, 0, 0.575], + "124": [0.25, 0.75, 0, 0, 0.31944], + "125": [0.25, 0.75, 0, 0, 0.575], + "126": [0.35, 0.34444, 0, 0, 0.575], + "160": [0, 0, 0, 0, 0.25], + "163": [0, 0.69444, 0, 0, 0.86853], + "168": [0, 0.69444, 0, 0, 0.575], + "172": [0, 0.44444, 0, 0, 0.76666], + "176": [0, 0.69444, 0, 0, 0.86944], + "177": [0.13333, 0.63333, 0, 0, 0.89444], + "184": [0.17014, 0, 0, 0, 0.51111], + "198": [0, 0.68611, 0, 0, 1.04166], + "215": [0.13333, 0.63333, 0, 0, 0.89444], + "216": [0.04861, 0.73472, 0, 0, 0.89444], + "223": [0, 0.69444, 0, 0, 0.59722], + "230": [0, 0.44444, 0, 0, 0.83055], + "247": [0.13333, 0.63333, 0, 0, 0.89444], + "248": [0.09722, 0.54167, 0, 0, 0.575], + "305": [0, 0.44444, 0, 0, 0.31944], + "338": [0, 0.68611, 0, 0, 1.16944], + "339": [0, 0.44444, 0, 0, 0.89444], + "567": [0.19444, 0.44444, 0, 0, 0.35139], + "710": [0, 0.69444, 0, 0, 0.575], + "711": [0, 0.63194, 0, 0, 0.575], + "713": [0, 0.59611, 0, 0, 0.575], + "714": [0, 0.69444, 0, 0, 0.575], + "715": [0, 0.69444, 0, 0, 0.575], + "728": [0, 0.69444, 0, 0, 0.575], + "729": [0, 0.69444, 0, 0, 0.31944], + "730": [0, 0.69444, 0, 0, 0.86944], + "732": [0, 0.69444, 0, 0, 0.575], + "733": [0, 0.69444, 0, 0, 0.575], + "915": [0, 0.68611, 0, 0, 0.69166], + "916": [0, 0.68611, 0, 0, 0.95833], + "920": [0, 0.68611, 0, 0, 0.89444], + "923": [0, 0.68611, 0, 0, 0.80555], + "926": [0, 0.68611, 0, 0, 0.76666], + "928": [0, 0.68611, 0, 0, 0.9], + "931": [0, 0.68611, 0, 0, 0.83055], + "933": [0, 0.68611, 0, 0, 0.89444], + "934": [0, 0.68611, 0, 0, 0.83055], + "936": [0, 0.68611, 0, 0, 0.89444], + "937": [0, 0.68611, 0, 0, 0.83055], + "8211": [0, 0.44444, 0.03194, 0, 0.575], + "8212": [0, 0.44444, 0.03194, 0, 1.14999], + "8216": [0, 0.69444, 0, 0, 0.31944], + "8217": [0, 0.69444, 0, 0, 0.31944], + "8220": [0, 0.69444, 0, 0, 0.60278], + "8221": [0, 0.69444, 0, 0, 0.60278], + "8224": [0.19444, 0.69444, 0, 0, 0.51111], + "8225": [0.19444, 0.69444, 0, 0, 0.51111], + "8242": [0, 0.55556, 0, 0, 0.34444], + "8407": [0, 0.72444, 0.15486, 0, 0.575], + "8463": [0, 0.69444, 0, 0, 0.66759], + "8465": [0, 0.69444, 0, 0, 0.83055], + "8467": [0, 0.69444, 0, 0, 0.47361], + "8472": [0.19444, 0.44444, 0, 0, 0.74027], + "8476": [0, 0.69444, 0, 0, 0.83055], + "8501": [0, 0.69444, 0, 0, 0.70277], + "8592": [-0.10889, 0.39111, 0, 0, 1.14999], + "8593": [0.19444, 0.69444, 0, 0, 0.575], + "8594": [-0.10889, 0.39111, 0, 0, 1.14999], + "8595": [0.19444, 0.69444, 0, 0, 0.575], + "8596": [-0.10889, 0.39111, 0, 0, 1.14999], + "8597": [0.25, 0.75, 0, 0, 0.575], + "8598": [0.19444, 0.69444, 0, 0, 1.14999], + "8599": [0.19444, 0.69444, 0, 0, 1.14999], + "8600": [0.19444, 0.69444, 0, 0, 1.14999], + "8601": [0.19444, 0.69444, 0, 0, 1.14999], + "8636": [-0.10889, 0.39111, 0, 0, 1.14999], + "8637": [-0.10889, 0.39111, 0, 0, 1.14999], + "8640": [-0.10889, 0.39111, 0, 0, 1.14999], + "8641": [-0.10889, 0.39111, 0, 0, 1.14999], + "8656": [-0.10889, 0.39111, 0, 0, 1.14999], + "8657": [0.19444, 0.69444, 0, 0, 0.70277], + "8658": [-0.10889, 0.39111, 0, 0, 1.14999], + "8659": [0.19444, 0.69444, 0, 0, 0.70277], + "8660": [-0.10889, 0.39111, 0, 0, 1.14999], + "8661": [0.25, 0.75, 0, 0, 0.70277], + "8704": [0, 0.69444, 0, 0, 0.63889], + "8706": [0, 0.69444, 0.06389, 0, 0.62847], + "8707": [0, 0.69444, 0, 0, 0.63889], + "8709": [0.05556, 0.75, 0, 0, 0.575], + "8711": [0, 0.68611, 0, 0, 0.95833], + "8712": [0.08556, 0.58556, 0, 0, 0.76666], + "8715": [0.08556, 0.58556, 0, 0, 0.76666], + "8722": [0.13333, 0.63333, 0, 0, 0.89444], + "8723": [0.13333, 0.63333, 0, 0, 0.89444], + "8725": [0.25, 0.75, 0, 0, 0.575], + "8726": [0.25, 0.75, 0, 0, 0.575], + "8727": [-0.02778, 0.47222, 0, 0, 0.575], + "8728": [-0.02639, 0.47361, 0, 0, 0.575], + "8729": [-0.02639, 0.47361, 0, 0, 0.575], + "8730": [0.18, 0.82, 0, 0, 0.95833], + "8733": [0, 0.44444, 0, 0, 0.89444], + "8734": [0, 0.44444, 0, 0, 1.14999], + "8736": [0, 0.69224, 0, 0, 0.72222], + "8739": [0.25, 0.75, 0, 0, 0.31944], + "8741": [0.25, 0.75, 0, 0, 0.575], + "8743": [0, 0.55556, 0, 0, 0.76666], + "8744": [0, 0.55556, 0, 0, 0.76666], + "8745": [0, 0.55556, 0, 0, 0.76666], + "8746": [0, 0.55556, 0, 0, 0.76666], + "8747": [0.19444, 0.69444, 0.12778, 0, 0.56875], + "8764": [-0.10889, 0.39111, 0, 0, 0.89444], + "8768": [0.19444, 0.69444, 0, 0, 0.31944], + "8771": [0.00222, 0.50222, 0, 0, 0.89444], + "8773": [0.027, 0.638, 0, 0, 0.894], + "8776": [0.02444, 0.52444, 0, 0, 0.89444], + "8781": [0.00222, 0.50222, 0, 0, 0.89444], + "8801": [0.00222, 0.50222, 0, 0, 0.89444], + "8804": [0.19667, 0.69667, 0, 0, 0.89444], + "8805": [0.19667, 0.69667, 0, 0, 0.89444], + "8810": [0.08556, 0.58556, 0, 0, 1.14999], + "8811": [0.08556, 0.58556, 0, 0, 1.14999], + "8826": [0.08556, 0.58556, 0, 0, 0.89444], + "8827": [0.08556, 0.58556, 0, 0, 0.89444], + "8834": [0.08556, 0.58556, 0, 0, 0.89444], + "8835": [0.08556, 0.58556, 0, 0, 0.89444], + "8838": [0.19667, 0.69667, 0, 0, 0.89444], + "8839": [0.19667, 0.69667, 0, 0, 0.89444], + "8846": [0, 0.55556, 0, 0, 0.76666], + "8849": [0.19667, 0.69667, 0, 0, 0.89444], + "8850": [0.19667, 0.69667, 0, 0, 0.89444], + "8851": [0, 0.55556, 0, 0, 0.76666], + "8852": [0, 0.55556, 0, 0, 0.76666], + "8853": [0.13333, 0.63333, 0, 0, 0.89444], + "8854": [0.13333, 0.63333, 0, 0, 0.89444], + "8855": [0.13333, 0.63333, 0, 0, 0.89444], + "8856": [0.13333, 0.63333, 0, 0, 0.89444], + "8857": [0.13333, 0.63333, 0, 0, 0.89444], + "8866": [0, 0.69444, 0, 0, 0.70277], + "8867": [0, 0.69444, 0, 0, 0.70277], + "8868": [0, 0.69444, 0, 0, 0.89444], + "8869": [0, 0.69444, 0, 0, 0.89444], + "8900": [-0.02639, 0.47361, 0, 0, 0.575], + "8901": [-0.02639, 0.47361, 0, 0, 0.31944], + "8902": [-0.02778, 0.47222, 0, 0, 0.575], + "8968": [0.25, 0.75, 0, 0, 0.51111], + "8969": [0.25, 0.75, 0, 0, 0.51111], + "8970": [0.25, 0.75, 0, 0, 0.51111], + "8971": [0.25, 0.75, 0, 0, 0.51111], + "8994": [-0.13889, 0.36111, 0, 0, 1.14999], + "8995": [-0.13889, 0.36111, 0, 0, 1.14999], + "9651": [0.19444, 0.69444, 0, 0, 1.02222], + "9657": [-0.02778, 0.47222, 0, 0, 0.575], + "9661": [0.19444, 0.69444, 0, 0, 1.02222], + "9667": [-0.02778, 0.47222, 0, 0, 0.575], + "9711": [0.19444, 0.69444, 0, 0, 1.14999], + "9824": [0.12963, 0.69444, 0, 0, 0.89444], + "9825": [0.12963, 0.69444, 0, 0, 0.89444], + "9826": [0.12963, 0.69444, 0, 0, 0.89444], + "9827": [0.12963, 0.69444, 0, 0, 0.89444], + "9837": [0, 0.75, 0, 0, 0.44722], + "9838": [0.19444, 0.69444, 0, 0, 0.44722], + "9839": [0.19444, 0.69444, 0, 0, 0.44722], + "10216": [0.25, 0.75, 0, 0, 0.44722], + "10217": [0.25, 0.75, 0, 0, 0.44722], + "10815": [0, 0.68611, 0, 0, 0.9], + "10927": [0.19667, 0.69667, 0, 0, 0.89444], + "10928": [0.19667, 0.69667, 0, 0, 0.89444], + "57376": [0.19444, 0.69444, 0, 0, 0] + }, + "Main-BoldItalic": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0.11417, 0, 0.38611], + "34": [0, 0.69444, 0.07939, 0, 0.62055], + "35": [0.19444, 0.69444, 0.06833, 0, 0.94444], + "37": [0.05556, 0.75, 0.12861, 0, 0.94444], + "38": [0, 0.69444, 0.08528, 0, 0.88555], + "39": [0, 0.69444, 0.12945, 0, 0.35555], + "40": [0.25, 0.75, 0.15806, 0, 0.47333], + "41": [0.25, 0.75, 0.03306, 0, 0.47333], + "42": [0, 0.75, 0.14333, 0, 0.59111], + "43": [0.10333, 0.60333, 0.03306, 0, 0.88555], + "44": [0.19444, 0.14722, 0, 0, 0.35555], + "45": [0, 0.44444, 0.02611, 0, 0.41444], + "46": [0, 0.14722, 0, 0, 0.35555], + "47": [0.25, 0.75, 0.15806, 0, 0.59111], + "48": [0, 0.64444, 0.13167, 0, 0.59111], + "49": [0, 0.64444, 0.13167, 0, 0.59111], + "50": [0, 0.64444, 0.13167, 0, 0.59111], + "51": [0, 0.64444, 0.13167, 0, 0.59111], + "52": [0.19444, 0.64444, 0.13167, 0, 0.59111], + "53": [0, 0.64444, 0.13167, 0, 0.59111], + "54": [0, 0.64444, 0.13167, 0, 0.59111], + "55": [0.19444, 0.64444, 0.13167, 0, 0.59111], + "56": [0, 0.64444, 0.13167, 0, 0.59111], + "57": [0, 0.64444, 0.13167, 0, 0.59111], + "58": [0, 0.44444, 0.06695, 0, 0.35555], + "59": [0.19444, 0.44444, 0.06695, 0, 0.35555], + "61": [-0.10889, 0.39111, 0.06833, 0, 0.88555], + "63": [0, 0.69444, 0.11472, 0, 0.59111], + "64": [0, 0.69444, 0.09208, 0, 0.88555], + "65": [0, 0.68611, 0, 0, 0.86555], + "66": [0, 0.68611, 0.0992, 0, 0.81666], + "67": [0, 0.68611, 0.14208, 0, 0.82666], + "68": [0, 0.68611, 0.09062, 0, 0.87555], + "69": [0, 0.68611, 0.11431, 0, 0.75666], + "70": [0, 0.68611, 0.12903, 0, 0.72722], + "71": [0, 0.68611, 0.07347, 0, 0.89527], + "72": [0, 0.68611, 0.17208, 0, 0.8961], + "73": [0, 0.68611, 0.15681, 0, 0.47166], + "74": [0, 0.68611, 0.145, 0, 0.61055], + "75": [0, 0.68611, 0.14208, 0, 0.89499], + "76": [0, 0.68611, 0, 0, 0.69777], + "77": [0, 0.68611, 0.17208, 0, 1.07277], + "78": [0, 0.68611, 0.17208, 0, 0.8961], + "79": [0, 0.68611, 0.09062, 0, 0.85499], + "80": [0, 0.68611, 0.0992, 0, 0.78721], + "81": [0.19444, 0.68611, 0.09062, 0, 0.85499], + "82": [0, 0.68611, 0.02559, 0, 0.85944], + "83": [0, 0.68611, 0.11264, 0, 0.64999], + "84": [0, 0.68611, 0.12903, 0, 0.7961], + "85": [0, 0.68611, 0.17208, 0, 0.88083], + "86": [0, 0.68611, 0.18625, 0, 0.86555], + "87": [0, 0.68611, 0.18625, 0, 1.15999], + "88": [0, 0.68611, 0.15681, 0, 0.86555], + "89": [0, 0.68611, 0.19803, 0, 0.86555], + "90": [0, 0.68611, 0.14208, 0, 0.70888], + "91": [0.25, 0.75, 0.1875, 0, 0.35611], + "93": [0.25, 0.75, 0.09972, 0, 0.35611], + "94": [0, 0.69444, 0.06709, 0, 0.59111], + "95": [0.31, 0.13444, 0.09811, 0, 0.59111], + "97": [0, 0.44444, 0.09426, 0, 0.59111], + "98": [0, 0.69444, 0.07861, 0, 0.53222], + "99": [0, 0.44444, 0.05222, 0, 0.53222], + "100": [0, 0.69444, 0.10861, 0, 0.59111], + "101": [0, 0.44444, 0.085, 0, 0.53222], + "102": [0.19444, 0.69444, 0.21778, 0, 0.4], + "103": [0.19444, 0.44444, 0.105, 0, 0.53222], + "104": [0, 0.69444, 0.09426, 0, 0.59111], + "105": [0, 0.69326, 0.11387, 0, 0.35555], + "106": [0.19444, 0.69326, 0.1672, 0, 0.35555], + "107": [0, 0.69444, 0.11111, 0, 0.53222], + "108": [0, 0.69444, 0.10861, 0, 0.29666], + "109": [0, 0.44444, 0.09426, 0, 0.94444], + "110": [0, 0.44444, 0.09426, 0, 0.64999], + "111": [0, 0.44444, 0.07861, 0, 0.59111], + "112": [0.19444, 0.44444, 0.07861, 0, 0.59111], + "113": [0.19444, 0.44444, 0.105, 0, 0.53222], + "114": [0, 0.44444, 0.11111, 0, 0.50167], + "115": [0, 0.44444, 0.08167, 0, 0.48694], + "116": [0, 0.63492, 0.09639, 0, 0.385], + "117": [0, 0.44444, 0.09426, 0, 0.62055], + "118": [0, 0.44444, 0.11111, 0, 0.53222], + "119": [0, 0.44444, 0.11111, 0, 0.76777], + "120": [0, 0.44444, 0.12583, 0, 0.56055], + "121": [0.19444, 0.44444, 0.105, 0, 0.56166], + "122": [0, 0.44444, 0.13889, 0, 0.49055], + "126": [0.35, 0.34444, 0.11472, 0, 0.59111], + "160": [0, 0, 0, 0, 0.25], + "168": [0, 0.69444, 0.11473, 0, 0.59111], + "176": [0, 0.69444, 0, 0, 0.94888], + "184": [0.17014, 0, 0, 0, 0.53222], + "198": [0, 0.68611, 0.11431, 0, 1.02277], + "216": [0.04861, 0.73472, 0.09062, 0, 0.88555], + "223": [0.19444, 0.69444, 0.09736, 0, 0.665], + "230": [0, 0.44444, 0.085, 0, 0.82666], + "248": [0.09722, 0.54167, 0.09458, 0, 0.59111], + "305": [0, 0.44444, 0.09426, 0, 0.35555], + "338": [0, 0.68611, 0.11431, 0, 1.14054], + "339": [0, 0.44444, 0.085, 0, 0.82666], + "567": [0.19444, 0.44444, 0.04611, 0, 0.385], + "710": [0, 0.69444, 0.06709, 0, 0.59111], + "711": [0, 0.63194, 0.08271, 0, 0.59111], + "713": [0, 0.59444, 0.10444, 0, 0.59111], + "714": [0, 0.69444, 0.08528, 0, 0.59111], + "715": [0, 0.69444, 0, 0, 0.59111], + "728": [0, 0.69444, 0.10333, 0, 0.59111], + "729": [0, 0.69444, 0.12945, 0, 0.35555], + "730": [0, 0.69444, 0, 0, 0.94888], + "732": [0, 0.69444, 0.11472, 0, 0.59111], + "733": [0, 0.69444, 0.11472, 0, 0.59111], + "915": [0, 0.68611, 0.12903, 0, 0.69777], + "916": [0, 0.68611, 0, 0, 0.94444], + "920": [0, 0.68611, 0.09062, 0, 0.88555], + "923": [0, 0.68611, 0, 0, 0.80666], + "926": [0, 0.68611, 0.15092, 0, 0.76777], + "928": [0, 0.68611, 0.17208, 0, 0.8961], + "931": [0, 0.68611, 0.11431, 0, 0.82666], + "933": [0, 0.68611, 0.10778, 0, 0.88555], + "934": [0, 0.68611, 0.05632, 0, 0.82666], + "936": [0, 0.68611, 0.10778, 0, 0.88555], + "937": [0, 0.68611, 0.0992, 0, 0.82666], + "8211": [0, 0.44444, 0.09811, 0, 0.59111], + "8212": [0, 0.44444, 0.09811, 0, 1.18221], + "8216": [0, 0.69444, 0.12945, 0, 0.35555], + "8217": [0, 0.69444, 0.12945, 0, 0.35555], + "8220": [0, 0.69444, 0.16772, 0, 0.62055], + "8221": [0, 0.69444, 0.07939, 0, 0.62055] + }, + "Main-Italic": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0.12417, 0, 0.30667], + "34": [0, 0.69444, 0.06961, 0, 0.51444], + "35": [0.19444, 0.69444, 0.06616, 0, 0.81777], + "37": [0.05556, 0.75, 0.13639, 0, 0.81777], + "38": [0, 0.69444, 0.09694, 0, 0.76666], + "39": [0, 0.69444, 0.12417, 0, 0.30667], + "40": [0.25, 0.75, 0.16194, 0, 0.40889], + "41": [0.25, 0.75, 0.03694, 0, 0.40889], + "42": [0, 0.75, 0.14917, 0, 0.51111], + "43": [0.05667, 0.56167, 0.03694, 0, 0.76666], + "44": [0.19444, 0.10556, 0, 0, 0.30667], + "45": [0, 0.43056, 0.02826, 0, 0.35778], + "46": [0, 0.10556, 0, 0, 0.30667], + "47": [0.25, 0.75, 0.16194, 0, 0.51111], + "48": [0, 0.64444, 0.13556, 0, 0.51111], + "49": [0, 0.64444, 0.13556, 0, 0.51111], + "50": [0, 0.64444, 0.13556, 0, 0.51111], + "51": [0, 0.64444, 0.13556, 0, 0.51111], + "52": [0.19444, 0.64444, 0.13556, 0, 0.51111], + "53": [0, 0.64444, 0.13556, 0, 0.51111], + "54": [0, 0.64444, 0.13556, 0, 0.51111], + "55": [0.19444, 0.64444, 0.13556, 0, 0.51111], + "56": [0, 0.64444, 0.13556, 0, 0.51111], + "57": [0, 0.64444, 0.13556, 0, 0.51111], + "58": [0, 0.43056, 0.0582, 0, 0.30667], + "59": [0.19444, 0.43056, 0.0582, 0, 0.30667], + "61": [-0.13313, 0.36687, 0.06616, 0, 0.76666], + "63": [0, 0.69444, 0.1225, 0, 0.51111], + "64": [0, 0.69444, 0.09597, 0, 0.76666], + "65": [0, 0.68333, 0, 0, 0.74333], + "66": [0, 0.68333, 0.10257, 0, 0.70389], + "67": [0, 0.68333, 0.14528, 0, 0.71555], + "68": [0, 0.68333, 0.09403, 0, 0.755], + "69": [0, 0.68333, 0.12028, 0, 0.67833], + "70": [0, 0.68333, 0.13305, 0, 0.65277], + "71": [0, 0.68333, 0.08722, 0, 0.77361], + "72": [0, 0.68333, 0.16389, 0, 0.74333], + "73": [0, 0.68333, 0.15806, 0, 0.38555], + "74": [0, 0.68333, 0.14028, 0, 0.525], + "75": [0, 0.68333, 0.14528, 0, 0.76888], + "76": [0, 0.68333, 0, 0, 0.62722], + "77": [0, 0.68333, 0.16389, 0, 0.89666], + "78": [0, 0.68333, 0.16389, 0, 0.74333], + "79": [0, 0.68333, 0.09403, 0, 0.76666], + "80": [0, 0.68333, 0.10257, 0, 0.67833], + "81": [0.19444, 0.68333, 0.09403, 0, 0.76666], + "82": [0, 0.68333, 0.03868, 0, 0.72944], + "83": [0, 0.68333, 0.11972, 0, 0.56222], + "84": [0, 0.68333, 0.13305, 0, 0.71555], + "85": [0, 0.68333, 0.16389, 0, 0.74333], + "86": [0, 0.68333, 0.18361, 0, 0.74333], + "87": [0, 0.68333, 0.18361, 0, 0.99888], + "88": [0, 0.68333, 0.15806, 0, 0.74333], + "89": [0, 0.68333, 0.19383, 0, 0.74333], + "90": [0, 0.68333, 0.14528, 0, 0.61333], + "91": [0.25, 0.75, 0.1875, 0, 0.30667], + "93": [0.25, 0.75, 0.10528, 0, 0.30667], + "94": [0, 0.69444, 0.06646, 0, 0.51111], + "95": [0.31, 0.12056, 0.09208, 0, 0.51111], + "97": [0, 0.43056, 0.07671, 0, 0.51111], + "98": [0, 0.69444, 0.06312, 0, 0.46], + "99": [0, 0.43056, 0.05653, 0, 0.46], + "100": [0, 0.69444, 0.10333, 0, 0.51111], + "101": [0, 0.43056, 0.07514, 0, 0.46], + "102": [0.19444, 0.69444, 0.21194, 0, 0.30667], + "103": [0.19444, 0.43056, 0.08847, 0, 0.46], + "104": [0, 0.69444, 0.07671, 0, 0.51111], + "105": [0, 0.65536, 0.1019, 0, 0.30667], + "106": [0.19444, 0.65536, 0.14467, 0, 0.30667], + "107": [0, 0.69444, 0.10764, 0, 0.46], + "108": [0, 0.69444, 0.10333, 0, 0.25555], + "109": [0, 0.43056, 0.07671, 0, 0.81777], + "110": [0, 0.43056, 0.07671, 0, 0.56222], + "111": [0, 0.43056, 0.06312, 0, 0.51111], + "112": [0.19444, 0.43056, 0.06312, 0, 0.51111], + "113": [0.19444, 0.43056, 0.08847, 0, 0.46], + "114": [0, 0.43056, 0.10764, 0, 0.42166], + "115": [0, 0.43056, 0.08208, 0, 0.40889], + "116": [0, 0.61508, 0.09486, 0, 0.33222], + "117": [0, 0.43056, 0.07671, 0, 0.53666], + "118": [0, 0.43056, 0.10764, 0, 0.46], + "119": [0, 0.43056, 0.10764, 0, 0.66444], + "120": [0, 0.43056, 0.12042, 0, 0.46389], + "121": [0.19444, 0.43056, 0.08847, 0, 0.48555], + "122": [0, 0.43056, 0.12292, 0, 0.40889], + "126": [0.35, 0.31786, 0.11585, 0, 0.51111], + "160": [0, 0, 0, 0, 0.25], + "168": [0, 0.66786, 0.10474, 0, 0.51111], + "176": [0, 0.69444, 0, 0, 0.83129], + "184": [0.17014, 0, 0, 0, 0.46], + "198": [0, 0.68333, 0.12028, 0, 0.88277], + "216": [0.04861, 0.73194, 0.09403, 0, 0.76666], + "223": [0.19444, 0.69444, 0.10514, 0, 0.53666], + "230": [0, 0.43056, 0.07514, 0, 0.71555], + "248": [0.09722, 0.52778, 0.09194, 0, 0.51111], + "338": [0, 0.68333, 0.12028, 0, 0.98499], + "339": [0, 0.43056, 0.07514, 0, 0.71555], + "710": [0, 0.69444, 0.06646, 0, 0.51111], + "711": [0, 0.62847, 0.08295, 0, 0.51111], + "713": [0, 0.56167, 0.10333, 0, 0.51111], + "714": [0, 0.69444, 0.09694, 0, 0.51111], + "715": [0, 0.69444, 0, 0, 0.51111], + "728": [0, 0.69444, 0.10806, 0, 0.51111], + "729": [0, 0.66786, 0.11752, 0, 0.30667], + "730": [0, 0.69444, 0, 0, 0.83129], + "732": [0, 0.66786, 0.11585, 0, 0.51111], + "733": [0, 0.69444, 0.1225, 0, 0.51111], + "915": [0, 0.68333, 0.13305, 0, 0.62722], + "916": [0, 0.68333, 0, 0, 0.81777], + "920": [0, 0.68333, 0.09403, 0, 0.76666], + "923": [0, 0.68333, 0, 0, 0.69222], + "926": [0, 0.68333, 0.15294, 0, 0.66444], + "928": [0, 0.68333, 0.16389, 0, 0.74333], + "931": [0, 0.68333, 0.12028, 0, 0.71555], + "933": [0, 0.68333, 0.11111, 0, 0.76666], + "934": [0, 0.68333, 0.05986, 0, 0.71555], + "936": [0, 0.68333, 0.11111, 0, 0.76666], + "937": [0, 0.68333, 0.10257, 0, 0.71555], + "8211": [0, 0.43056, 0.09208, 0, 0.51111], + "8212": [0, 0.43056, 0.09208, 0, 1.02222], + "8216": [0, 0.69444, 0.12417, 0, 0.30667], + "8217": [0, 0.69444, 0.12417, 0, 0.30667], + "8220": [0, 0.69444, 0.1685, 0, 0.51444], + "8221": [0, 0.69444, 0.06961, 0, 0.51444], + "8463": [0, 0.68889, 0, 0, 0.54028] + }, + "Main-Regular": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0, 0, 0.27778], + "34": [0, 0.69444, 0, 0, 0.5], + "35": [0.19444, 0.69444, 0, 0, 0.83334], + "36": [0.05556, 0.75, 0, 0, 0.5], + "37": [0.05556, 0.75, 0, 0, 0.83334], + "38": [0, 0.69444, 0, 0, 0.77778], + "39": [0, 0.69444, 0, 0, 0.27778], + "40": [0.25, 0.75, 0, 0, 0.38889], + "41": [0.25, 0.75, 0, 0, 0.38889], + "42": [0, 0.75, 0, 0, 0.5], + "43": [0.08333, 0.58333, 0, 0, 0.77778], + "44": [0.19444, 0.10556, 0, 0, 0.27778], + "45": [0, 0.43056, 0, 0, 0.33333], + "46": [0, 0.10556, 0, 0, 0.27778], + "47": [0.25, 0.75, 0, 0, 0.5], + "48": [0, 0.64444, 0, 0, 0.5], + "49": [0, 0.64444, 0, 0, 0.5], + "50": [0, 0.64444, 0, 0, 0.5], + "51": [0, 0.64444, 0, 0, 0.5], + "52": [0, 0.64444, 0, 0, 0.5], + "53": [0, 0.64444, 0, 0, 0.5], + "54": [0, 0.64444, 0, 0, 0.5], + "55": [0, 0.64444, 0, 0, 0.5], + "56": [0, 0.64444, 0, 0, 0.5], + "57": [0, 0.64444, 0, 0, 0.5], + "58": [0, 0.43056, 0, 0, 0.27778], + "59": [0.19444, 0.43056, 0, 0, 0.27778], + "60": [0.0391, 0.5391, 0, 0, 0.77778], + "61": [-0.13313, 0.36687, 0, 0, 0.77778], + "62": [0.0391, 0.5391, 0, 0, 0.77778], + "63": [0, 0.69444, 0, 0, 0.47222], + "64": [0, 0.69444, 0, 0, 0.77778], + "65": [0, 0.68333, 0, 0, 0.75], + "66": [0, 0.68333, 0, 0, 0.70834], + "67": [0, 0.68333, 0, 0, 0.72222], + "68": [0, 0.68333, 0, 0, 0.76389], + "69": [0, 0.68333, 0, 0, 0.68056], + "70": [0, 0.68333, 0, 0, 0.65278], + "71": [0, 0.68333, 0, 0, 0.78472], + "72": [0, 0.68333, 0, 0, 0.75], + "73": [0, 0.68333, 0, 0, 0.36111], + "74": [0, 0.68333, 0, 0, 0.51389], + "75": [0, 0.68333, 0, 0, 0.77778], + "76": [0, 0.68333, 0, 0, 0.625], + "77": [0, 0.68333, 0, 0, 0.91667], + "78": [0, 0.68333, 0, 0, 0.75], + "79": [0, 0.68333, 0, 0, 0.77778], + "80": [0, 0.68333, 0, 0, 0.68056], + "81": [0.19444, 0.68333, 0, 0, 0.77778], + "82": [0, 0.68333, 0, 0, 0.73611], + "83": [0, 0.68333, 0, 0, 0.55556], + "84": [0, 0.68333, 0, 0, 0.72222], + "85": [0, 0.68333, 0, 0, 0.75], + "86": [0, 0.68333, 0.01389, 0, 0.75], + "87": [0, 0.68333, 0.01389, 0, 1.02778], + "88": [0, 0.68333, 0, 0, 0.75], + "89": [0, 0.68333, 0.025, 0, 0.75], + "90": [0, 0.68333, 0, 0, 0.61111], + "91": [0.25, 0.75, 0, 0, 0.27778], + "92": [0.25, 0.75, 0, 0, 0.5], + "93": [0.25, 0.75, 0, 0, 0.27778], + "94": [0, 0.69444, 0, 0, 0.5], + "95": [0.31, 0.12056, 0.02778, 0, 0.5], + "97": [0, 0.43056, 0, 0, 0.5], + "98": [0, 0.69444, 0, 0, 0.55556], + "99": [0, 0.43056, 0, 0, 0.44445], + "100": [0, 0.69444, 0, 0, 0.55556], + "101": [0, 0.43056, 0, 0, 0.44445], + "102": [0, 0.69444, 0.07778, 0, 0.30556], + "103": [0.19444, 0.43056, 0.01389, 0, 0.5], + "104": [0, 0.69444, 0, 0, 0.55556], + "105": [0, 0.66786, 0, 0, 0.27778], + "106": [0.19444, 0.66786, 0, 0, 0.30556], + "107": [0, 0.69444, 0, 0, 0.52778], + "108": [0, 0.69444, 0, 0, 0.27778], + "109": [0, 0.43056, 0, 0, 0.83334], + "110": [0, 0.43056, 0, 0, 0.55556], + "111": [0, 0.43056, 0, 0, 0.5], + "112": [0.19444, 0.43056, 0, 0, 0.55556], + "113": [0.19444, 0.43056, 0, 0, 0.52778], + "114": [0, 0.43056, 0, 0, 0.39167], + "115": [0, 0.43056, 0, 0, 0.39445], + "116": [0, 0.61508, 0, 0, 0.38889], + "117": [0, 0.43056, 0, 0, 0.55556], + "118": [0, 0.43056, 0.01389, 0, 0.52778], + "119": [0, 0.43056, 0.01389, 0, 0.72222], + "120": [0, 0.43056, 0, 0, 0.52778], + "121": [0.19444, 0.43056, 0.01389, 0, 0.52778], + "122": [0, 0.43056, 0, 0, 0.44445], + "123": [0.25, 0.75, 0, 0, 0.5], + "124": [0.25, 0.75, 0, 0, 0.27778], + "125": [0.25, 0.75, 0, 0, 0.5], + "126": [0.35, 0.31786, 0, 0, 0.5], + "160": [0, 0, 0, 0, 0.25], + "163": [0, 0.69444, 0, 0, 0.76909], + "167": [0.19444, 0.69444, 0, 0, 0.44445], + "168": [0, 0.66786, 0, 0, 0.5], + "172": [0, 0.43056, 0, 0, 0.66667], + "176": [0, 0.69444, 0, 0, 0.75], + "177": [0.08333, 0.58333, 0, 0, 0.77778], + "182": [0.19444, 0.69444, 0, 0, 0.61111], + "184": [0.17014, 0, 0, 0, 0.44445], + "198": [0, 0.68333, 0, 0, 0.90278], + "215": [0.08333, 0.58333, 0, 0, 0.77778], + "216": [0.04861, 0.73194, 0, 0, 0.77778], + "223": [0, 0.69444, 0, 0, 0.5], + "230": [0, 0.43056, 0, 0, 0.72222], + "247": [0.08333, 0.58333, 0, 0, 0.77778], + "248": [0.09722, 0.52778, 0, 0, 0.5], + "305": [0, 0.43056, 0, 0, 0.27778], + "338": [0, 0.68333, 0, 0, 1.01389], + "339": [0, 0.43056, 0, 0, 0.77778], + "567": [0.19444, 0.43056, 0, 0, 0.30556], + "710": [0, 0.69444, 0, 0, 0.5], + "711": [0, 0.62847, 0, 0, 0.5], + "713": [0, 0.56778, 0, 0, 0.5], + "714": [0, 0.69444, 0, 0, 0.5], + "715": [0, 0.69444, 0, 0, 0.5], + "728": [0, 0.69444, 0, 0, 0.5], + "729": [0, 0.66786, 0, 0, 0.27778], + "730": [0, 0.69444, 0, 0, 0.75], + "732": [0, 0.66786, 0, 0, 0.5], + "733": [0, 0.69444, 0, 0, 0.5], + "915": [0, 0.68333, 0, 0, 0.625], + "916": [0, 0.68333, 0, 0, 0.83334], + "920": [0, 0.68333, 0, 0, 0.77778], + "923": [0, 0.68333, 0, 0, 0.69445], + "926": [0, 0.68333, 0, 0, 0.66667], + "928": [0, 0.68333, 0, 0, 0.75], + "931": [0, 0.68333, 0, 0, 0.72222], + "933": [0, 0.68333, 0, 0, 0.77778], + "934": [0, 0.68333, 0, 0, 0.72222], + "936": [0, 0.68333, 0, 0, 0.77778], + "937": [0, 0.68333, 0, 0, 0.72222], + "8211": [0, 0.43056, 0.02778, 0, 0.5], + "8212": [0, 0.43056, 0.02778, 0, 1.0], + "8216": [0, 0.69444, 0, 0, 0.27778], + "8217": [0, 0.69444, 0, 0, 0.27778], + "8220": [0, 0.69444, 0, 0, 0.5], + "8221": [0, 0.69444, 0, 0, 0.5], + "8224": [0.19444, 0.69444, 0, 0, 0.44445], + "8225": [0.19444, 0.69444, 0, 0, 0.44445], + "8230": [0, 0.123, 0, 0, 1.172], + "8242": [0, 0.55556, 0, 0, 0.275], + "8407": [0, 0.71444, 0.15382, 0, 0.5], + "8463": [0, 0.68889, 0, 0, 0.54028], + "8465": [0, 0.69444, 0, 0, 0.72222], + "8467": [0, 0.69444, 0, 0.11111, 0.41667], + "8472": [0.19444, 0.43056, 0, 0.11111, 0.63646], + "8476": [0, 0.69444, 0, 0, 0.72222], + "8501": [0, 0.69444, 0, 0, 0.61111], + "8592": [-0.13313, 0.36687, 0, 0, 1.0], + "8593": [0.19444, 0.69444, 0, 0, 0.5], + "8594": [-0.13313, 0.36687, 0, 0, 1.0], + "8595": [0.19444, 0.69444, 0, 0, 0.5], + "8596": [-0.13313, 0.36687, 0, 0, 1.0], + "8597": [0.25, 0.75, 0, 0, 0.5], + "8598": [0.19444, 0.69444, 0, 0, 1.0], + "8599": [0.19444, 0.69444, 0, 0, 1.0], + "8600": [0.19444, 0.69444, 0, 0, 1.0], + "8601": [0.19444, 0.69444, 0, 0, 1.0], + "8614": [0.011, 0.511, 0, 0, 1.0], + "8617": [0.011, 0.511, 0, 0, 1.126], + "8618": [0.011, 0.511, 0, 0, 1.126], + "8636": [-0.13313, 0.36687, 0, 0, 1.0], + "8637": [-0.13313, 0.36687, 0, 0, 1.0], + "8640": [-0.13313, 0.36687, 0, 0, 1.0], + "8641": [-0.13313, 0.36687, 0, 0, 1.0], + "8652": [0.011, 0.671, 0, 0, 1.0], + "8656": [-0.13313, 0.36687, 0, 0, 1.0], + "8657": [0.19444, 0.69444, 0, 0, 0.61111], + "8658": [-0.13313, 0.36687, 0, 0, 1.0], + "8659": [0.19444, 0.69444, 0, 0, 0.61111], + "8660": [-0.13313, 0.36687, 0, 0, 1.0], + "8661": [0.25, 0.75, 0, 0, 0.61111], + "8704": [0, 0.69444, 0, 0, 0.55556], + "8706": [0, 0.69444, 0.05556, 0.08334, 0.5309], + "8707": [0, 0.69444, 0, 0, 0.55556], + "8709": [0.05556, 0.75, 0, 0, 0.5], + "8711": [0, 0.68333, 0, 0, 0.83334], + "8712": [0.0391, 0.5391, 0, 0, 0.66667], + "8715": [0.0391, 0.5391, 0, 0, 0.66667], + "8722": [0.08333, 0.58333, 0, 0, 0.77778], + "8723": [0.08333, 0.58333, 0, 0, 0.77778], + "8725": [0.25, 0.75, 0, 0, 0.5], + "8726": [0.25, 0.75, 0, 0, 0.5], + "8727": [-0.03472, 0.46528, 0, 0, 0.5], + "8728": [-0.05555, 0.44445, 0, 0, 0.5], + "8729": [-0.05555, 0.44445, 0, 0, 0.5], + "8730": [0.2, 0.8, 0, 0, 0.83334], + "8733": [0, 0.43056, 0, 0, 0.77778], + "8734": [0, 0.43056, 0, 0, 1.0], + "8736": [0, 0.69224, 0, 0, 0.72222], + "8739": [0.25, 0.75, 0, 0, 0.27778], + "8741": [0.25, 0.75, 0, 0, 0.5], + "8743": [0, 0.55556, 0, 0, 0.66667], + "8744": [0, 0.55556, 0, 0, 0.66667], + "8745": [0, 0.55556, 0, 0, 0.66667], + "8746": [0, 0.55556, 0, 0, 0.66667], + "8747": [0.19444, 0.69444, 0.11111, 0, 0.41667], + "8764": [-0.13313, 0.36687, 0, 0, 0.77778], + "8768": [0.19444, 0.69444, 0, 0, 0.27778], + "8771": [-0.03625, 0.46375, 0, 0, 0.77778], + "8773": [-0.022, 0.589, 0, 0, 0.778], + "8776": [-0.01688, 0.48312, 0, 0, 0.77778], + "8781": [-0.03625, 0.46375, 0, 0, 0.77778], + "8784": [-0.133, 0.673, 0, 0, 0.778], + "8801": [-0.03625, 0.46375, 0, 0, 0.77778], + "8804": [0.13597, 0.63597, 0, 0, 0.77778], + "8805": [0.13597, 0.63597, 0, 0, 0.77778], + "8810": [0.0391, 0.5391, 0, 0, 1.0], + "8811": [0.0391, 0.5391, 0, 0, 1.0], + "8826": [0.0391, 0.5391, 0, 0, 0.77778], + "8827": [0.0391, 0.5391, 0, 0, 0.77778], + "8834": [0.0391, 0.5391, 0, 0, 0.77778], + "8835": [0.0391, 0.5391, 0, 0, 0.77778], + "8838": [0.13597, 0.63597, 0, 0, 0.77778], + "8839": [0.13597, 0.63597, 0, 0, 0.77778], + "8846": [0, 0.55556, 0, 0, 0.66667], + "8849": [0.13597, 0.63597, 0, 0, 0.77778], + "8850": [0.13597, 0.63597, 0, 0, 0.77778], + "8851": [0, 0.55556, 0, 0, 0.66667], + "8852": [0, 0.55556, 0, 0, 0.66667], + "8853": [0.08333, 0.58333, 0, 0, 0.77778], + "8854": [0.08333, 0.58333, 0, 0, 0.77778], + "8855": [0.08333, 0.58333, 0, 0, 0.77778], + "8856": [0.08333, 0.58333, 0, 0, 0.77778], + "8857": [0.08333, 0.58333, 0, 0, 0.77778], + "8866": [0, 0.69444, 0, 0, 0.61111], + "8867": [0, 0.69444, 0, 0, 0.61111], + "8868": [0, 0.69444, 0, 0, 0.77778], + "8869": [0, 0.69444, 0, 0, 0.77778], + "8872": [0.249, 0.75, 0, 0, 0.867], + "8900": [-0.05555, 0.44445, 0, 0, 0.5], + "8901": [-0.05555, 0.44445, 0, 0, 0.27778], + "8902": [-0.03472, 0.46528, 0, 0, 0.5], + "8904": [0.005, 0.505, 0, 0, 0.9], + "8942": [0.03, 0.903, 0, 0, 0.278], + "8943": [-0.19, 0.313, 0, 0, 1.172], + "8945": [-0.1, 0.823, 0, 0, 1.282], + "8968": [0.25, 0.75, 0, 0, 0.44445], + "8969": [0.25, 0.75, 0, 0, 0.44445], + "8970": [0.25, 0.75, 0, 0, 0.44445], + "8971": [0.25, 0.75, 0, 0, 0.44445], + "8994": [-0.14236, 0.35764, 0, 0, 1.0], + "8995": [-0.14236, 0.35764, 0, 0, 1.0], + "9136": [0.244, 0.744, 0, 0, 0.412], + "9137": [0.244, 0.745, 0, 0, 0.412], + "9651": [0.19444, 0.69444, 0, 0, 0.88889], + "9657": [-0.03472, 0.46528, 0, 0, 0.5], + "9661": [0.19444, 0.69444, 0, 0, 0.88889], + "9667": [-0.03472, 0.46528, 0, 0, 0.5], + "9711": [0.19444, 0.69444, 0, 0, 1.0], + "9824": [0.12963, 0.69444, 0, 0, 0.77778], + "9825": [0.12963, 0.69444, 0, 0, 0.77778], + "9826": [0.12963, 0.69444, 0, 0, 0.77778], + "9827": [0.12963, 0.69444, 0, 0, 0.77778], + "9837": [0, 0.75, 0, 0, 0.38889], + "9838": [0.19444, 0.69444, 0, 0, 0.38889], + "9839": [0.19444, 0.69444, 0, 0, 0.38889], + "10216": [0.25, 0.75, 0, 0, 0.38889], + "10217": [0.25, 0.75, 0, 0, 0.38889], + "10222": [0.244, 0.744, 0, 0, 0.412], + "10223": [0.244, 0.745, 0, 0, 0.412], + "10229": [0.011, 0.511, 0, 0, 1.609], + "10230": [0.011, 0.511, 0, 0, 1.638], + "10231": [0.011, 0.511, 0, 0, 1.859], + "10232": [0.024, 0.525, 0, 0, 1.609], + "10233": [0.024, 0.525, 0, 0, 1.638], + "10234": [0.024, 0.525, 0, 0, 1.858], + "10236": [0.011, 0.511, 0, 0, 1.638], + "10815": [0, 0.68333, 0, 0, 0.75], + "10927": [0.13597, 0.63597, 0, 0, 0.77778], + "10928": [0.13597, 0.63597, 0, 0, 0.77778], + "57376": [0.19444, 0.69444, 0, 0, 0] + }, + "Math-BoldItalic": { + "32": [0, 0, 0, 0, 0.25], + "48": [0, 0.44444, 0, 0, 0.575], + "49": [0, 0.44444, 0, 0, 0.575], + "50": [0, 0.44444, 0, 0, 0.575], + "51": [0.19444, 0.44444, 0, 0, 0.575], + "52": [0.19444, 0.44444, 0, 0, 0.575], + "53": [0.19444, 0.44444, 0, 0, 0.575], + "54": [0, 0.64444, 0, 0, 0.575], + "55": [0.19444, 0.44444, 0, 0, 0.575], + "56": [0, 0.64444, 0, 0, 0.575], + "57": [0.19444, 0.44444, 0, 0, 0.575], + "65": [0, 0.68611, 0, 0, 0.86944], + "66": [0, 0.68611, 0.04835, 0, 0.8664], + "67": [0, 0.68611, 0.06979, 0, 0.81694], + "68": [0, 0.68611, 0.03194, 0, 0.93812], + "69": [0, 0.68611, 0.05451, 0, 0.81007], + "70": [0, 0.68611, 0.15972, 0, 0.68889], + "71": [0, 0.68611, 0, 0, 0.88673], + "72": [0, 0.68611, 0.08229, 0, 0.98229], + "73": [0, 0.68611, 0.07778, 0, 0.51111], + "74": [0, 0.68611, 0.10069, 0, 0.63125], + "75": [0, 0.68611, 0.06979, 0, 0.97118], + "76": [0, 0.68611, 0, 0, 0.75555], + "77": [0, 0.68611, 0.11424, 0, 1.14201], + "78": [0, 0.68611, 0.11424, 0, 0.95034], + "79": [0, 0.68611, 0.03194, 0, 0.83666], + "80": [0, 0.68611, 0.15972, 0, 0.72309], + "81": [0.19444, 0.68611, 0, 0, 0.86861], + "82": [0, 0.68611, 0.00421, 0, 0.87235], + "83": [0, 0.68611, 0.05382, 0, 0.69271], + "84": [0, 0.68611, 0.15972, 0, 0.63663], + "85": [0, 0.68611, 0.11424, 0, 0.80027], + "86": [0, 0.68611, 0.25555, 0, 0.67778], + "87": [0, 0.68611, 0.15972, 0, 1.09305], + "88": [0, 0.68611, 0.07778, 0, 0.94722], + "89": [0, 0.68611, 0.25555, 0, 0.67458], + "90": [0, 0.68611, 0.06979, 0, 0.77257], + "97": [0, 0.44444, 0, 0, 0.63287], + "98": [0, 0.69444, 0, 0, 0.52083], + "99": [0, 0.44444, 0, 0, 0.51342], + "100": [0, 0.69444, 0, 0, 0.60972], + "101": [0, 0.44444, 0, 0, 0.55361], + "102": [0.19444, 0.69444, 0.11042, 0, 0.56806], + "103": [0.19444, 0.44444, 0.03704, 0, 0.5449], + "104": [0, 0.69444, 0, 0, 0.66759], + "105": [0, 0.69326, 0, 0, 0.4048], + "106": [0.19444, 0.69326, 0.0622, 0, 0.47083], + "107": [0, 0.69444, 0.01852, 0, 0.6037], + "108": [0, 0.69444, 0.0088, 0, 0.34815], + "109": [0, 0.44444, 0, 0, 1.0324], + "110": [0, 0.44444, 0, 0, 0.71296], + "111": [0, 0.44444, 0, 0, 0.58472], + "112": [0.19444, 0.44444, 0, 0, 0.60092], + "113": [0.19444, 0.44444, 0.03704, 0, 0.54213], + "114": [0, 0.44444, 0.03194, 0, 0.5287], + "115": [0, 0.44444, 0, 0, 0.53125], + "116": [0, 0.63492, 0, 0, 0.41528], + "117": [0, 0.44444, 0, 0, 0.68102], + "118": [0, 0.44444, 0.03704, 0, 0.56666], + "119": [0, 0.44444, 0.02778, 0, 0.83148], + "120": [0, 0.44444, 0, 0, 0.65903], + "121": [0.19444, 0.44444, 0.03704, 0, 0.59028], + "122": [0, 0.44444, 0.04213, 0, 0.55509], + "160": [0, 0, 0, 0, 0.25], + "915": [0, 0.68611, 0.15972, 0, 0.65694], + "916": [0, 0.68611, 0, 0, 0.95833], + "920": [0, 0.68611, 0.03194, 0, 0.86722], + "923": [0, 0.68611, 0, 0, 0.80555], + "926": [0, 0.68611, 0.07458, 0, 0.84125], + "928": [0, 0.68611, 0.08229, 0, 0.98229], + "931": [0, 0.68611, 0.05451, 0, 0.88507], + "933": [0, 0.68611, 0.15972, 0, 0.67083], + "934": [0, 0.68611, 0, 0, 0.76666], + "936": [0, 0.68611, 0.11653, 0, 0.71402], + "937": [0, 0.68611, 0.04835, 0, 0.8789], + "945": [0, 0.44444, 0, 0, 0.76064], + "946": [0.19444, 0.69444, 0.03403, 0, 0.65972], + "947": [0.19444, 0.44444, 0.06389, 0, 0.59003], + "948": [0, 0.69444, 0.03819, 0, 0.52222], + "949": [0, 0.44444, 0, 0, 0.52882], + "950": [0.19444, 0.69444, 0.06215, 0, 0.50833], + "951": [0.19444, 0.44444, 0.03704, 0, 0.6], + "952": [0, 0.69444, 0.03194, 0, 0.5618], + "953": [0, 0.44444, 0, 0, 0.41204], + "954": [0, 0.44444, 0, 0, 0.66759], + "955": [0, 0.69444, 0, 0, 0.67083], + "956": [0.19444, 0.44444, 0, 0, 0.70787], + "957": [0, 0.44444, 0.06898, 0, 0.57685], + "958": [0.19444, 0.69444, 0.03021, 0, 0.50833], + "959": [0, 0.44444, 0, 0, 0.58472], + "960": [0, 0.44444, 0.03704, 0, 0.68241], + "961": [0.19444, 0.44444, 0, 0, 0.6118], + "962": [0.09722, 0.44444, 0.07917, 0, 0.42361], + "963": [0, 0.44444, 0.03704, 0, 0.68588], + "964": [0, 0.44444, 0.13472, 0, 0.52083], + "965": [0, 0.44444, 0.03704, 0, 0.63055], + "966": [0.19444, 0.44444, 0, 0, 0.74722], + "967": [0.19444, 0.44444, 0, 0, 0.71805], + "968": [0.19444, 0.69444, 0.03704, 0, 0.75833], + "969": [0, 0.44444, 0.03704, 0, 0.71782], + "977": [0, 0.69444, 0, 0, 0.69155], + "981": [0.19444, 0.69444, 0, 0, 0.7125], + "982": [0, 0.44444, 0.03194, 0, 0.975], + "1009": [0.19444, 0.44444, 0, 0, 0.6118], + "1013": [0, 0.44444, 0, 0, 0.48333], + "57649": [0, 0.44444, 0, 0, 0.39352], + "57911": [0.19444, 0.44444, 0, 0, 0.43889] + }, + "Math-Italic": { + "32": [0, 0, 0, 0, 0.25], + "48": [0, 0.43056, 0, 0, 0.5], + "49": [0, 0.43056, 0, 0, 0.5], + "50": [0, 0.43056, 0, 0, 0.5], + "51": [0.19444, 0.43056, 0, 0, 0.5], + "52": [0.19444, 0.43056, 0, 0, 0.5], + "53": [0.19444, 0.43056, 0, 0, 0.5], + "54": [0, 0.64444, 0, 0, 0.5], + "55": [0.19444, 0.43056, 0, 0, 0.5], + "56": [0, 0.64444, 0, 0, 0.5], + "57": [0.19444, 0.43056, 0, 0, 0.5], + "65": [0, 0.68333, 0, 0.13889, 0.75], + "66": [0, 0.68333, 0.05017, 0.08334, 0.75851], + "67": [0, 0.68333, 0.07153, 0.08334, 0.71472], + "68": [0, 0.68333, 0.02778, 0.05556, 0.82792], + "69": [0, 0.68333, 0.05764, 0.08334, 0.7382], + "70": [0, 0.68333, 0.13889, 0.08334, 0.64306], + "71": [0, 0.68333, 0, 0.08334, 0.78625], + "72": [0, 0.68333, 0.08125, 0.05556, 0.83125], + "73": [0, 0.68333, 0.07847, 0.11111, 0.43958], + "74": [0, 0.68333, 0.09618, 0.16667, 0.55451], + "75": [0, 0.68333, 0.07153, 0.05556, 0.84931], + "76": [0, 0.68333, 0, 0.02778, 0.68056], + "77": [0, 0.68333, 0.10903, 0.08334, 0.97014], + "78": [0, 0.68333, 0.10903, 0.08334, 0.80347], + "79": [0, 0.68333, 0.02778, 0.08334, 0.76278], + "80": [0, 0.68333, 0.13889, 0.08334, 0.64201], + "81": [0.19444, 0.68333, 0, 0.08334, 0.79056], + "82": [0, 0.68333, 0.00773, 0.08334, 0.75929], + "83": [0, 0.68333, 0.05764, 0.08334, 0.6132], + "84": [0, 0.68333, 0.13889, 0.08334, 0.58438], + "85": [0, 0.68333, 0.10903, 0.02778, 0.68278], + "86": [0, 0.68333, 0.22222, 0, 0.58333], + "87": [0, 0.68333, 0.13889, 0, 0.94445], + "88": [0, 0.68333, 0.07847, 0.08334, 0.82847], + "89": [0, 0.68333, 0.22222, 0, 0.58056], + "90": [0, 0.68333, 0.07153, 0.08334, 0.68264], + "97": [0, 0.43056, 0, 0, 0.52859], + "98": [0, 0.69444, 0, 0, 0.42917], + "99": [0, 0.43056, 0, 0.05556, 0.43276], + "100": [0, 0.69444, 0, 0.16667, 0.52049], + "101": [0, 0.43056, 0, 0.05556, 0.46563], + "102": [0.19444, 0.69444, 0.10764, 0.16667, 0.48959], + "103": [0.19444, 0.43056, 0.03588, 0.02778, 0.47697], + "104": [0, 0.69444, 0, 0, 0.57616], + "105": [0, 0.65952, 0, 0, 0.34451], + "106": [0.19444, 0.65952, 0.05724, 0, 0.41181], + "107": [0, 0.69444, 0.03148, 0, 0.5206], + "108": [0, 0.69444, 0.01968, 0.08334, 0.29838], + "109": [0, 0.43056, 0, 0, 0.87801], + "110": [0, 0.43056, 0, 0, 0.60023], + "111": [0, 0.43056, 0, 0.05556, 0.48472], + "112": [0.19444, 0.43056, 0, 0.08334, 0.50313], + "113": [0.19444, 0.43056, 0.03588, 0.08334, 0.44641], + "114": [0, 0.43056, 0.02778, 0.05556, 0.45116], + "115": [0, 0.43056, 0, 0.05556, 0.46875], + "116": [0, 0.61508, 0, 0.08334, 0.36111], + "117": [0, 0.43056, 0, 0.02778, 0.57246], + "118": [0, 0.43056, 0.03588, 0.02778, 0.48472], + "119": [0, 0.43056, 0.02691, 0.08334, 0.71592], + "120": [0, 0.43056, 0, 0.02778, 0.57153], + "121": [0.19444, 0.43056, 0.03588, 0.05556, 0.49028], + "122": [0, 0.43056, 0.04398, 0.05556, 0.46505], + "160": [0, 0, 0, 0, 0.25], + "915": [0, 0.68333, 0.13889, 0.08334, 0.61528], + "916": [0, 0.68333, 0, 0.16667, 0.83334], + "920": [0, 0.68333, 0.02778, 0.08334, 0.76278], + "923": [0, 0.68333, 0, 0.16667, 0.69445], + "926": [0, 0.68333, 0.07569, 0.08334, 0.74236], + "928": [0, 0.68333, 0.08125, 0.05556, 0.83125], + "931": [0, 0.68333, 0.05764, 0.08334, 0.77986], + "933": [0, 0.68333, 0.13889, 0.05556, 0.58333], + "934": [0, 0.68333, 0, 0.08334, 0.66667], + "936": [0, 0.68333, 0.11, 0.05556, 0.61222], + "937": [0, 0.68333, 0.05017, 0.08334, 0.7724], + "945": [0, 0.43056, 0.0037, 0.02778, 0.6397], + "946": [0.19444, 0.69444, 0.05278, 0.08334, 0.56563], + "947": [0.19444, 0.43056, 0.05556, 0, 0.51773], + "948": [0, 0.69444, 0.03785, 0.05556, 0.44444], + "949": [0, 0.43056, 0, 0.08334, 0.46632], + "950": [0.19444, 0.69444, 0.07378, 0.08334, 0.4375], + "951": [0.19444, 0.43056, 0.03588, 0.05556, 0.49653], + "952": [0, 0.69444, 0.02778, 0.08334, 0.46944], + "953": [0, 0.43056, 0, 0.05556, 0.35394], + "954": [0, 0.43056, 0, 0, 0.57616], + "955": [0, 0.69444, 0, 0, 0.58334], + "956": [0.19444, 0.43056, 0, 0.02778, 0.60255], + "957": [0, 0.43056, 0.06366, 0.02778, 0.49398], + "958": [0.19444, 0.69444, 0.04601, 0.11111, 0.4375], + "959": [0, 0.43056, 0, 0.05556, 0.48472], + "960": [0, 0.43056, 0.03588, 0, 0.57003], + "961": [0.19444, 0.43056, 0, 0.08334, 0.51702], + "962": [0.09722, 0.43056, 0.07986, 0.08334, 0.36285], + "963": [0, 0.43056, 0.03588, 0, 0.57141], + "964": [0, 0.43056, 0.1132, 0.02778, 0.43715], + "965": [0, 0.43056, 0.03588, 0.02778, 0.54028], + "966": [0.19444, 0.43056, 0, 0.08334, 0.65417], + "967": [0.19444, 0.43056, 0, 0.05556, 0.62569], + "968": [0.19444, 0.69444, 0.03588, 0.11111, 0.65139], + "969": [0, 0.43056, 0.03588, 0, 0.62245], + "977": [0, 0.69444, 0, 0.08334, 0.59144], + "981": [0.19444, 0.69444, 0, 0.08334, 0.59583], + "982": [0, 0.43056, 0.02778, 0, 0.82813], + "1009": [0.19444, 0.43056, 0, 0.08334, 0.51702], + "1013": [0, 0.43056, 0, 0.05556, 0.4059], + "57649": [0, 0.43056, 0, 0.02778, 0.32246], + "57911": [0.19444, 0.43056, 0, 0.08334, 0.38403] + }, + "SansSerif-Bold": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0, 0, 0.36667], + "34": [0, 0.69444, 0, 0, 0.55834], + "35": [0.19444, 0.69444, 0, 0, 0.91667], + "36": [0.05556, 0.75, 0, 0, 0.55], + "37": [0.05556, 0.75, 0, 0, 1.02912], + "38": [0, 0.69444, 0, 0, 0.83056], + "39": [0, 0.69444, 0, 0, 0.30556], + "40": [0.25, 0.75, 0, 0, 0.42778], + "41": [0.25, 0.75, 0, 0, 0.42778], + "42": [0, 0.75, 0, 0, 0.55], + "43": [0.11667, 0.61667, 0, 0, 0.85556], + "44": [0.10556, 0.13056, 0, 0, 0.30556], + "45": [0, 0.45833, 0, 0, 0.36667], + "46": [0, 0.13056, 0, 0, 0.30556], + "47": [0.25, 0.75, 0, 0, 0.55], + "48": [0, 0.69444, 0, 0, 0.55], + "49": [0, 0.69444, 0, 0, 0.55], + "50": [0, 0.69444, 0, 0, 0.55], + "51": [0, 0.69444, 0, 0, 0.55], + "52": [0, 0.69444, 0, 0, 0.55], + "53": [0, 0.69444, 0, 0, 0.55], + "54": [0, 0.69444, 0, 0, 0.55], + "55": [0, 0.69444, 0, 0, 0.55], + "56": [0, 0.69444, 0, 0, 0.55], + "57": [0, 0.69444, 0, 0, 0.55], + "58": [0, 0.45833, 0, 0, 0.30556], + "59": [0.10556, 0.45833, 0, 0, 0.30556], + "61": [-0.09375, 0.40625, 0, 0, 0.85556], + "63": [0, 0.69444, 0, 0, 0.51945], + "64": [0, 0.69444, 0, 0, 0.73334], + "65": [0, 0.69444, 0, 0, 0.73334], + "66": [0, 0.69444, 0, 0, 0.73334], + "67": [0, 0.69444, 0, 0, 0.70278], + "68": [0, 0.69444, 0, 0, 0.79445], + "69": [0, 0.69444, 0, 0, 0.64167], + "70": [0, 0.69444, 0, 0, 0.61111], + "71": [0, 0.69444, 0, 0, 0.73334], + "72": [0, 0.69444, 0, 0, 0.79445], + "73": [0, 0.69444, 0, 0, 0.33056], + "74": [0, 0.69444, 0, 0, 0.51945], + "75": [0, 0.69444, 0, 0, 0.76389], + "76": [0, 0.69444, 0, 0, 0.58056], + "77": [0, 0.69444, 0, 0, 0.97778], + "78": [0, 0.69444, 0, 0, 0.79445], + "79": [0, 0.69444, 0, 0, 0.79445], + "80": [0, 0.69444, 0, 0, 0.70278], + "81": [0.10556, 0.69444, 0, 0, 0.79445], + "82": [0, 0.69444, 0, 0, 0.70278], + "83": [0, 0.69444, 0, 0, 0.61111], + "84": [0, 0.69444, 0, 0, 0.73334], + "85": [0, 0.69444, 0, 0, 0.76389], + "86": [0, 0.69444, 0.01528, 0, 0.73334], + "87": [0, 0.69444, 0.01528, 0, 1.03889], + "88": [0, 0.69444, 0, 0, 0.73334], + "89": [0, 0.69444, 0.0275, 0, 0.73334], + "90": [0, 0.69444, 0, 0, 0.67223], + "91": [0.25, 0.75, 0, 0, 0.34306], + "93": [0.25, 0.75, 0, 0, 0.34306], + "94": [0, 0.69444, 0, 0, 0.55], + "95": [0.35, 0.10833, 0.03056, 0, 0.55], + "97": [0, 0.45833, 0, 0, 0.525], + "98": [0, 0.69444, 0, 0, 0.56111], + "99": [0, 0.45833, 0, 0, 0.48889], + "100": [0, 0.69444, 0, 0, 0.56111], + "101": [0, 0.45833, 0, 0, 0.51111], + "102": [0, 0.69444, 0.07639, 0, 0.33611], + "103": [0.19444, 0.45833, 0.01528, 0, 0.55], + "104": [0, 0.69444, 0, 0, 0.56111], + "105": [0, 0.69444, 0, 0, 0.25556], + "106": [0.19444, 0.69444, 0, 0, 0.28611], + "107": [0, 0.69444, 0, 0, 0.53056], + "108": [0, 0.69444, 0, 0, 0.25556], + "109": [0, 0.45833, 0, 0, 0.86667], + "110": [0, 0.45833, 0, 0, 0.56111], + "111": [0, 0.45833, 0, 0, 0.55], + "112": [0.19444, 0.45833, 0, 0, 0.56111], + "113": [0.19444, 0.45833, 0, 0, 0.56111], + "114": [0, 0.45833, 0.01528, 0, 0.37222], + "115": [0, 0.45833, 0, 0, 0.42167], + "116": [0, 0.58929, 0, 0, 0.40417], + "117": [0, 0.45833, 0, 0, 0.56111], + "118": [0, 0.45833, 0.01528, 0, 0.5], + "119": [0, 0.45833, 0.01528, 0, 0.74445], + "120": [0, 0.45833, 0, 0, 0.5], + "121": [0.19444, 0.45833, 0.01528, 0, 0.5], + "122": [0, 0.45833, 0, 0, 0.47639], + "126": [0.35, 0.34444, 0, 0, 0.55], + "160": [0, 0, 0, 0, 0.25], + "168": [0, 0.69444, 0, 0, 0.55], + "176": [0, 0.69444, 0, 0, 0.73334], + "180": [0, 0.69444, 0, 0, 0.55], + "184": [0.17014, 0, 0, 0, 0.48889], + "305": [0, 0.45833, 0, 0, 0.25556], + "567": [0.19444, 0.45833, 0, 0, 0.28611], + "710": [0, 0.69444, 0, 0, 0.55], + "711": [0, 0.63542, 0, 0, 0.55], + "713": [0, 0.63778, 0, 0, 0.55], + "728": [0, 0.69444, 0, 0, 0.55], + "729": [0, 0.69444, 0, 0, 0.30556], + "730": [0, 0.69444, 0, 0, 0.73334], + "732": [0, 0.69444, 0, 0, 0.55], + "733": [0, 0.69444, 0, 0, 0.55], + "915": [0, 0.69444, 0, 0, 0.58056], + "916": [0, 0.69444, 0, 0, 0.91667], + "920": [0, 0.69444, 0, 0, 0.85556], + "923": [0, 0.69444, 0, 0, 0.67223], + "926": [0, 0.69444, 0, 0, 0.73334], + "928": [0, 0.69444, 0, 0, 0.79445], + "931": [0, 0.69444, 0, 0, 0.79445], + "933": [0, 0.69444, 0, 0, 0.85556], + "934": [0, 0.69444, 0, 0, 0.79445], + "936": [0, 0.69444, 0, 0, 0.85556], + "937": [0, 0.69444, 0, 0, 0.79445], + "8211": [0, 0.45833, 0.03056, 0, 0.55], + "8212": [0, 0.45833, 0.03056, 0, 1.10001], + "8216": [0, 0.69444, 0, 0, 0.30556], + "8217": [0, 0.69444, 0, 0, 0.30556], + "8220": [0, 0.69444, 0, 0, 0.55834], + "8221": [0, 0.69444, 0, 0, 0.55834] + }, + "SansSerif-Italic": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0.05733, 0, 0.31945], + "34": [0, 0.69444, 0.00316, 0, 0.5], + "35": [0.19444, 0.69444, 0.05087, 0, 0.83334], + "36": [0.05556, 0.75, 0.11156, 0, 0.5], + "37": [0.05556, 0.75, 0.03126, 0, 0.83334], + "38": [0, 0.69444, 0.03058, 0, 0.75834], + "39": [0, 0.69444, 0.07816, 0, 0.27778], + "40": [0.25, 0.75, 0.13164, 0, 0.38889], + "41": [0.25, 0.75, 0.02536, 0, 0.38889], + "42": [0, 0.75, 0.11775, 0, 0.5], + "43": [0.08333, 0.58333, 0.02536, 0, 0.77778], + "44": [0.125, 0.08333, 0, 0, 0.27778], + "45": [0, 0.44444, 0.01946, 0, 0.33333], + "46": [0, 0.08333, 0, 0, 0.27778], + "47": [0.25, 0.75, 0.13164, 0, 0.5], + "48": [0, 0.65556, 0.11156, 0, 0.5], + "49": [0, 0.65556, 0.11156, 0, 0.5], + "50": [0, 0.65556, 0.11156, 0, 0.5], + "51": [0, 0.65556, 0.11156, 0, 0.5], + "52": [0, 0.65556, 0.11156, 0, 0.5], + "53": [0, 0.65556, 0.11156, 0, 0.5], + "54": [0, 0.65556, 0.11156, 0, 0.5], + "55": [0, 0.65556, 0.11156, 0, 0.5], + "56": [0, 0.65556, 0.11156, 0, 0.5], + "57": [0, 0.65556, 0.11156, 0, 0.5], + "58": [0, 0.44444, 0.02502, 0, 0.27778], + "59": [0.125, 0.44444, 0.02502, 0, 0.27778], + "61": [-0.13, 0.37, 0.05087, 0, 0.77778], + "63": [0, 0.69444, 0.11809, 0, 0.47222], + "64": [0, 0.69444, 0.07555, 0, 0.66667], + "65": [0, 0.69444, 0, 0, 0.66667], + "66": [0, 0.69444, 0.08293, 0, 0.66667], + "67": [0, 0.69444, 0.11983, 0, 0.63889], + "68": [0, 0.69444, 0.07555, 0, 0.72223], + "69": [0, 0.69444, 0.11983, 0, 0.59722], + "70": [0, 0.69444, 0.13372, 0, 0.56945], + "71": [0, 0.69444, 0.11983, 0, 0.66667], + "72": [0, 0.69444, 0.08094, 0, 0.70834], + "73": [0, 0.69444, 0.13372, 0, 0.27778], + "74": [0, 0.69444, 0.08094, 0, 0.47222], + "75": [0, 0.69444, 0.11983, 0, 0.69445], + "76": [0, 0.69444, 0, 0, 0.54167], + "77": [0, 0.69444, 0.08094, 0, 0.875], + "78": [0, 0.69444, 0.08094, 0, 0.70834], + "79": [0, 0.69444, 0.07555, 0, 0.73611], + "80": [0, 0.69444, 0.08293, 0, 0.63889], + "81": [0.125, 0.69444, 0.07555, 0, 0.73611], + "82": [0, 0.69444, 0.08293, 0, 0.64584], + "83": [0, 0.69444, 0.09205, 0, 0.55556], + "84": [0, 0.69444, 0.13372, 0, 0.68056], + "85": [0, 0.69444, 0.08094, 0, 0.6875], + "86": [0, 0.69444, 0.1615, 0, 0.66667], + "87": [0, 0.69444, 0.1615, 0, 0.94445], + "88": [0, 0.69444, 0.13372, 0, 0.66667], + "89": [0, 0.69444, 0.17261, 0, 0.66667], + "90": [0, 0.69444, 0.11983, 0, 0.61111], + "91": [0.25, 0.75, 0.15942, 0, 0.28889], + "93": [0.25, 0.75, 0.08719, 0, 0.28889], + "94": [0, 0.69444, 0.0799, 0, 0.5], + "95": [0.35, 0.09444, 0.08616, 0, 0.5], + "97": [0, 0.44444, 0.00981, 0, 0.48056], + "98": [0, 0.69444, 0.03057, 0, 0.51667], + "99": [0, 0.44444, 0.08336, 0, 0.44445], + "100": [0, 0.69444, 0.09483, 0, 0.51667], + "101": [0, 0.44444, 0.06778, 0, 0.44445], + "102": [0, 0.69444, 0.21705, 0, 0.30556], + "103": [0.19444, 0.44444, 0.10836, 0, 0.5], + "104": [0, 0.69444, 0.01778, 0, 0.51667], + "105": [0, 0.67937, 0.09718, 0, 0.23889], + "106": [0.19444, 0.67937, 0.09162, 0, 0.26667], + "107": [0, 0.69444, 0.08336, 0, 0.48889], + "108": [0, 0.69444, 0.09483, 0, 0.23889], + "109": [0, 0.44444, 0.01778, 0, 0.79445], + "110": [0, 0.44444, 0.01778, 0, 0.51667], + "111": [0, 0.44444, 0.06613, 0, 0.5], + "112": [0.19444, 0.44444, 0.0389, 0, 0.51667], + "113": [0.19444, 0.44444, 0.04169, 0, 0.51667], + "114": [0, 0.44444, 0.10836, 0, 0.34167], + "115": [0, 0.44444, 0.0778, 0, 0.38333], + "116": [0, 0.57143, 0.07225, 0, 0.36111], + "117": [0, 0.44444, 0.04169, 0, 0.51667], + "118": [0, 0.44444, 0.10836, 0, 0.46111], + "119": [0, 0.44444, 0.10836, 0, 0.68334], + "120": [0, 0.44444, 0.09169, 0, 0.46111], + "121": [0.19444, 0.44444, 0.10836, 0, 0.46111], + "122": [0, 0.44444, 0.08752, 0, 0.43472], + "126": [0.35, 0.32659, 0.08826, 0, 0.5], + "160": [0, 0, 0, 0, 0.25], + "168": [0, 0.67937, 0.06385, 0, 0.5], + "176": [0, 0.69444, 0, 0, 0.73752], + "184": [0.17014, 0, 0, 0, 0.44445], + "305": [0, 0.44444, 0.04169, 0, 0.23889], + "567": [0.19444, 0.44444, 0.04169, 0, 0.26667], + "710": [0, 0.69444, 0.0799, 0, 0.5], + "711": [0, 0.63194, 0.08432, 0, 0.5], + "713": [0, 0.60889, 0.08776, 0, 0.5], + "714": [0, 0.69444, 0.09205, 0, 0.5], + "715": [0, 0.69444, 0, 0, 0.5], + "728": [0, 0.69444, 0.09483, 0, 0.5], + "729": [0, 0.67937, 0.07774, 0, 0.27778], + "730": [0, 0.69444, 0, 0, 0.73752], + "732": [0, 0.67659, 0.08826, 0, 0.5], + "733": [0, 0.69444, 0.09205, 0, 0.5], + "915": [0, 0.69444, 0.13372, 0, 0.54167], + "916": [0, 0.69444, 0, 0, 0.83334], + "920": [0, 0.69444, 0.07555, 0, 0.77778], + "923": [0, 0.69444, 0, 0, 0.61111], + "926": [0, 0.69444, 0.12816, 0, 0.66667], + "928": [0, 0.69444, 0.08094, 0, 0.70834], + "931": [0, 0.69444, 0.11983, 0, 0.72222], + "933": [0, 0.69444, 0.09031, 0, 0.77778], + "934": [0, 0.69444, 0.04603, 0, 0.72222], + "936": [0, 0.69444, 0.09031, 0, 0.77778], + "937": [0, 0.69444, 0.08293, 0, 0.72222], + "8211": [0, 0.44444, 0.08616, 0, 0.5], + "8212": [0, 0.44444, 0.08616, 0, 1.0], + "8216": [0, 0.69444, 0.07816, 0, 0.27778], + "8217": [0, 0.69444, 0.07816, 0, 0.27778], + "8220": [0, 0.69444, 0.14205, 0, 0.5], + "8221": [0, 0.69444, 0.00316, 0, 0.5] + }, + "SansSerif-Regular": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0, 0, 0.31945], + "34": [0, 0.69444, 0, 0, 0.5], + "35": [0.19444, 0.69444, 0, 0, 0.83334], + "36": [0.05556, 0.75, 0, 0, 0.5], + "37": [0.05556, 0.75, 0, 0, 0.83334], + "38": [0, 0.69444, 0, 0, 0.75834], + "39": [0, 0.69444, 0, 0, 0.27778], + "40": [0.25, 0.75, 0, 0, 0.38889], + "41": [0.25, 0.75, 0, 0, 0.38889], + "42": [0, 0.75, 0, 0, 0.5], + "43": [0.08333, 0.58333, 0, 0, 0.77778], + "44": [0.125, 0.08333, 0, 0, 0.27778], + "45": [0, 0.44444, 0, 0, 0.33333], + "46": [0, 0.08333, 0, 0, 0.27778], + "47": [0.25, 0.75, 0, 0, 0.5], + "48": [0, 0.65556, 0, 0, 0.5], + "49": [0, 0.65556, 0, 0, 0.5], + "50": [0, 0.65556, 0, 0, 0.5], + "51": [0, 0.65556, 0, 0, 0.5], + "52": [0, 0.65556, 0, 0, 0.5], + "53": [0, 0.65556, 0, 0, 0.5], + "54": [0, 0.65556, 0, 0, 0.5], + "55": [0, 0.65556, 0, 0, 0.5], + "56": [0, 0.65556, 0, 0, 0.5], + "57": [0, 0.65556, 0, 0, 0.5], + "58": [0, 0.44444, 0, 0, 0.27778], + "59": [0.125, 0.44444, 0, 0, 0.27778], + "61": [-0.13, 0.37, 0, 0, 0.77778], + "63": [0, 0.69444, 0, 0, 0.47222], + "64": [0, 0.69444, 0, 0, 0.66667], + "65": [0, 0.69444, 0, 0, 0.66667], + "66": [0, 0.69444, 0, 0, 0.66667], + "67": [0, 0.69444, 0, 0, 0.63889], + "68": [0, 0.69444, 0, 0, 0.72223], + "69": [0, 0.69444, 0, 0, 0.59722], + "70": [0, 0.69444, 0, 0, 0.56945], + "71": [0, 0.69444, 0, 0, 0.66667], + "72": [0, 0.69444, 0, 0, 0.70834], + "73": [0, 0.69444, 0, 0, 0.27778], + "74": [0, 0.69444, 0, 0, 0.47222], + "75": [0, 0.69444, 0, 0, 0.69445], + "76": [0, 0.69444, 0, 0, 0.54167], + "77": [0, 0.69444, 0, 0, 0.875], + "78": [0, 0.69444, 0, 0, 0.70834], + "79": [0, 0.69444, 0, 0, 0.73611], + "80": [0, 0.69444, 0, 0, 0.63889], + "81": [0.125, 0.69444, 0, 0, 0.73611], + "82": [0, 0.69444, 0, 0, 0.64584], + "83": [0, 0.69444, 0, 0, 0.55556], + "84": [0, 0.69444, 0, 0, 0.68056], + "85": [0, 0.69444, 0, 0, 0.6875], + "86": [0, 0.69444, 0.01389, 0, 0.66667], + "87": [0, 0.69444, 0.01389, 0, 0.94445], + "88": [0, 0.69444, 0, 0, 0.66667], + "89": [0, 0.69444, 0.025, 0, 0.66667], + "90": [0, 0.69444, 0, 0, 0.61111], + "91": [0.25, 0.75, 0, 0, 0.28889], + "93": [0.25, 0.75, 0, 0, 0.28889], + "94": [0, 0.69444, 0, 0, 0.5], + "95": [0.35, 0.09444, 0.02778, 0, 0.5], + "97": [0, 0.44444, 0, 0, 0.48056], + "98": [0, 0.69444, 0, 0, 0.51667], + "99": [0, 0.44444, 0, 0, 0.44445], + "100": [0, 0.69444, 0, 0, 0.51667], + "101": [0, 0.44444, 0, 0, 0.44445], + "102": [0, 0.69444, 0.06944, 0, 0.30556], + "103": [0.19444, 0.44444, 0.01389, 0, 0.5], + "104": [0, 0.69444, 0, 0, 0.51667], + "105": [0, 0.67937, 0, 0, 0.23889], + "106": [0.19444, 0.67937, 0, 0, 0.26667], + "107": [0, 0.69444, 0, 0, 0.48889], + "108": [0, 0.69444, 0, 0, 0.23889], + "109": [0, 0.44444, 0, 0, 0.79445], + "110": [0, 0.44444, 0, 0, 0.51667], + "111": [0, 0.44444, 0, 0, 0.5], + "112": [0.19444, 0.44444, 0, 0, 0.51667], + "113": [0.19444, 0.44444, 0, 0, 0.51667], + "114": [0, 0.44444, 0.01389, 0, 0.34167], + "115": [0, 0.44444, 0, 0, 0.38333], + "116": [0, 0.57143, 0, 0, 0.36111], + "117": [0, 0.44444, 0, 0, 0.51667], + "118": [0, 0.44444, 0.01389, 0, 0.46111], + "119": [0, 0.44444, 0.01389, 0, 0.68334], + "120": [0, 0.44444, 0, 0, 0.46111], + "121": [0.19444, 0.44444, 0.01389, 0, 0.46111], + "122": [0, 0.44444, 0, 0, 0.43472], + "126": [0.35, 0.32659, 0, 0, 0.5], + "160": [0, 0, 0, 0, 0.25], + "168": [0, 0.67937, 0, 0, 0.5], + "176": [0, 0.69444, 0, 0, 0.66667], + "184": [0.17014, 0, 0, 0, 0.44445], + "305": [0, 0.44444, 0, 0, 0.23889], + "567": [0.19444, 0.44444, 0, 0, 0.26667], + "710": [0, 0.69444, 0, 0, 0.5], + "711": [0, 0.63194, 0, 0, 0.5], + "713": [0, 0.60889, 0, 0, 0.5], + "714": [0, 0.69444, 0, 0, 0.5], + "715": [0, 0.69444, 0, 0, 0.5], + "728": [0, 0.69444, 0, 0, 0.5], + "729": [0, 0.67937, 0, 0, 0.27778], + "730": [0, 0.69444, 0, 0, 0.66667], + "732": [0, 0.67659, 0, 0, 0.5], + "733": [0, 0.69444, 0, 0, 0.5], + "915": [0, 0.69444, 0, 0, 0.54167], + "916": [0, 0.69444, 0, 0, 0.83334], + "920": [0, 0.69444, 0, 0, 0.77778], + "923": [0, 0.69444, 0, 0, 0.61111], + "926": [0, 0.69444, 0, 0, 0.66667], + "928": [0, 0.69444, 0, 0, 0.70834], + "931": [0, 0.69444, 0, 0, 0.72222], + "933": [0, 0.69444, 0, 0, 0.77778], + "934": [0, 0.69444, 0, 0, 0.72222], + "936": [0, 0.69444, 0, 0, 0.77778], + "937": [0, 0.69444, 0, 0, 0.72222], + "8211": [0, 0.44444, 0.02778, 0, 0.5], + "8212": [0, 0.44444, 0.02778, 0, 1.0], + "8216": [0, 0.69444, 0, 0, 0.27778], + "8217": [0, 0.69444, 0, 0, 0.27778], + "8220": [0, 0.69444, 0, 0, 0.5], + "8221": [0, 0.69444, 0, 0, 0.5] + }, + "Script-Regular": { + "32": [0, 0, 0, 0, 0.25], + "65": [0, 0.7, 0.22925, 0, 0.80253], + "66": [0, 0.7, 0.04087, 0, 0.90757], + "67": [0, 0.7, 0.1689, 0, 0.66619], + "68": [0, 0.7, 0.09371, 0, 0.77443], + "69": [0, 0.7, 0.18583, 0, 0.56162], + "70": [0, 0.7, 0.13634, 0, 0.89544], + "71": [0, 0.7, 0.17322, 0, 0.60961], + "72": [0, 0.7, 0.29694, 0, 0.96919], + "73": [0, 0.7, 0.19189, 0, 0.80907], + "74": [0.27778, 0.7, 0.19189, 0, 1.05159], + "75": [0, 0.7, 0.31259, 0, 0.91364], + "76": [0, 0.7, 0.19189, 0, 0.87373], + "77": [0, 0.7, 0.15981, 0, 1.08031], + "78": [0, 0.7, 0.3525, 0, 0.9015], + "79": [0, 0.7, 0.08078, 0, 0.73787], + "80": [0, 0.7, 0.08078, 0, 1.01262], + "81": [0, 0.7, 0.03305, 0, 0.88282], + "82": [0, 0.7, 0.06259, 0, 0.85], + "83": [0, 0.7, 0.19189, 0, 0.86767], + "84": [0, 0.7, 0.29087, 0, 0.74697], + "85": [0, 0.7, 0.25815, 0, 0.79996], + "86": [0, 0.7, 0.27523, 0, 0.62204], + "87": [0, 0.7, 0.27523, 0, 0.80532], + "88": [0, 0.7, 0.26006, 0, 0.94445], + "89": [0, 0.7, 0.2939, 0, 0.70961], + "90": [0, 0.7, 0.24037, 0, 0.8212], + "160": [0, 0, 0, 0, 0.25] + }, + "Size1-Regular": { + "32": [0, 0, 0, 0, 0.25], + "40": [0.35001, 0.85, 0, 0, 0.45834], + "41": [0.35001, 0.85, 0, 0, 0.45834], + "47": [0.35001, 0.85, 0, 0, 0.57778], + "91": [0.35001, 0.85, 0, 0, 0.41667], + "92": [0.35001, 0.85, 0, 0, 0.57778], + "93": [0.35001, 0.85, 0, 0, 0.41667], + "123": [0.35001, 0.85, 0, 0, 0.58334], + "125": [0.35001, 0.85, 0, 0, 0.58334], + "160": [0, 0, 0, 0, 0.25], + "710": [0, 0.72222, 0, 0, 0.55556], + "732": [0, 0.72222, 0, 0, 0.55556], + "770": [0, 0.72222, 0, 0, 0.55556], + "771": [0, 0.72222, 0, 0, 0.55556], + "8214": [-0.00099, 0.601, 0, 0, 0.77778], + "8593": [1e-05, 0.6, 0, 0, 0.66667], + "8595": [1e-05, 0.6, 0, 0, 0.66667], + "8657": [1e-05, 0.6, 0, 0, 0.77778], + "8659": [1e-05, 0.6, 0, 0, 0.77778], + "8719": [0.25001, 0.75, 0, 0, 0.94445], + "8720": [0.25001, 0.75, 0, 0, 0.94445], + "8721": [0.25001, 0.75, 0, 0, 1.05556], + "8730": [0.35001, 0.85, 0, 0, 1.0], + "8739": [-0.00599, 0.606, 0, 0, 0.33333], + "8741": [-0.00599, 0.606, 0, 0, 0.55556], + "8747": [0.30612, 0.805, 0.19445, 0, 0.47222], + "8748": [0.306, 0.805, 0.19445, 0, 0.47222], + "8749": [0.306, 0.805, 0.19445, 0, 0.47222], + "8750": [0.30612, 0.805, 0.19445, 0, 0.47222], + "8896": [0.25001, 0.75, 0, 0, 0.83334], + "8897": [0.25001, 0.75, 0, 0, 0.83334], + "8898": [0.25001, 0.75, 0, 0, 0.83334], + "8899": [0.25001, 0.75, 0, 0, 0.83334], + "8968": [0.35001, 0.85, 0, 0, 0.47222], + "8969": [0.35001, 0.85, 0, 0, 0.47222], + "8970": [0.35001, 0.85, 0, 0, 0.47222], + "8971": [0.35001, 0.85, 0, 0, 0.47222], + "9168": [-0.00099, 0.601, 0, 0, 0.66667], + "10216": [0.35001, 0.85, 0, 0, 0.47222], + "10217": [0.35001, 0.85, 0, 0, 0.47222], + "10752": [0.25001, 0.75, 0, 0, 1.11111], + "10753": [0.25001, 0.75, 0, 0, 1.11111], + "10754": [0.25001, 0.75, 0, 0, 1.11111], + "10756": [0.25001, 0.75, 0, 0, 0.83334], + "10758": [0.25001, 0.75, 0, 0, 0.83334] + }, + "Size2-Regular": { + "32": [0, 0, 0, 0, 0.25], + "40": [0.65002, 1.15, 0, 0, 0.59722], + "41": [0.65002, 1.15, 0, 0, 0.59722], + "47": [0.65002, 1.15, 0, 0, 0.81111], + "91": [0.65002, 1.15, 0, 0, 0.47222], + "92": [0.65002, 1.15, 0, 0, 0.81111], + "93": [0.65002, 1.15, 0, 0, 0.47222], + "123": [0.65002, 1.15, 0, 0, 0.66667], + "125": [0.65002, 1.15, 0, 0, 0.66667], + "160": [0, 0, 0, 0, 0.25], + "710": [0, 0.75, 0, 0, 1.0], + "732": [0, 0.75, 0, 0, 1.0], + "770": [0, 0.75, 0, 0, 1.0], + "771": [0, 0.75, 0, 0, 1.0], + "8719": [0.55001, 1.05, 0, 0, 1.27778], + "8720": [0.55001, 1.05, 0, 0, 1.27778], + "8721": [0.55001, 1.05, 0, 0, 1.44445], + "8730": [0.65002, 1.15, 0, 0, 1.0], + "8747": [0.86225, 1.36, 0.44445, 0, 0.55556], + "8748": [0.862, 1.36, 0.44445, 0, 0.55556], + "8749": [0.862, 1.36, 0.44445, 0, 0.55556], + "8750": [0.86225, 1.36, 0.44445, 0, 0.55556], + "8896": [0.55001, 1.05, 0, 0, 1.11111], + "8897": [0.55001, 1.05, 0, 0, 1.11111], + "8898": [0.55001, 1.05, 0, 0, 1.11111], + "8899": [0.55001, 1.05, 0, 0, 1.11111], + "8968": [0.65002, 1.15, 0, 0, 0.52778], + "8969": [0.65002, 1.15, 0, 0, 0.52778], + "8970": [0.65002, 1.15, 0, 0, 0.52778], + "8971": [0.65002, 1.15, 0, 0, 0.52778], + "10216": [0.65002, 1.15, 0, 0, 0.61111], + "10217": [0.65002, 1.15, 0, 0, 0.61111], + "10752": [0.55001, 1.05, 0, 0, 1.51112], + "10753": [0.55001, 1.05, 0, 0, 1.51112], + "10754": [0.55001, 1.05, 0, 0, 1.51112], + "10756": [0.55001, 1.05, 0, 0, 1.11111], + "10758": [0.55001, 1.05, 0, 0, 1.11111] + }, + "Size3-Regular": { + "32": [0, 0, 0, 0, 0.25], + "40": [0.95003, 1.45, 0, 0, 0.73611], + "41": [0.95003, 1.45, 0, 0, 0.73611], + "47": [0.95003, 1.45, 0, 0, 1.04445], + "91": [0.95003, 1.45, 0, 0, 0.52778], + "92": [0.95003, 1.45, 0, 0, 1.04445], + "93": [0.95003, 1.45, 0, 0, 0.52778], + "123": [0.95003, 1.45, 0, 0, 0.75], + "125": [0.95003, 1.45, 0, 0, 0.75], + "160": [0, 0, 0, 0, 0.25], + "710": [0, 0.75, 0, 0, 1.44445], + "732": [0, 0.75, 0, 0, 1.44445], + "770": [0, 0.75, 0, 0, 1.44445], + "771": [0, 0.75, 0, 0, 1.44445], + "8730": [0.95003, 1.45, 0, 0, 1.0], + "8968": [0.95003, 1.45, 0, 0, 0.58334], + "8969": [0.95003, 1.45, 0, 0, 0.58334], + "8970": [0.95003, 1.45, 0, 0, 0.58334], + "8971": [0.95003, 1.45, 0, 0, 0.58334], + "10216": [0.95003, 1.45, 0, 0, 0.75], + "10217": [0.95003, 1.45, 0, 0, 0.75] + }, + "Size4-Regular": { + "32": [0, 0, 0, 0, 0.25], + "40": [1.25003, 1.75, 0, 0, 0.79167], + "41": [1.25003, 1.75, 0, 0, 0.79167], + "47": [1.25003, 1.75, 0, 0, 1.27778], + "91": [1.25003, 1.75, 0, 0, 0.58334], + "92": [1.25003, 1.75, 0, 0, 1.27778], + "93": [1.25003, 1.75, 0, 0, 0.58334], + "123": [1.25003, 1.75, 0, 0, 0.80556], + "125": [1.25003, 1.75, 0, 0, 0.80556], + "160": [0, 0, 0, 0, 0.25], + "710": [0, 0.825, 0, 0, 1.8889], + "732": [0, 0.825, 0, 0, 1.8889], + "770": [0, 0.825, 0, 0, 1.8889], + "771": [0, 0.825, 0, 0, 1.8889], + "8730": [1.25003, 1.75, 0, 0, 1.0], + "8968": [1.25003, 1.75, 0, 0, 0.63889], + "8969": [1.25003, 1.75, 0, 0, 0.63889], + "8970": [1.25003, 1.75, 0, 0, 0.63889], + "8971": [1.25003, 1.75, 0, 0, 0.63889], + "9115": [0.64502, 1.155, 0, 0, 0.875], + "9116": [1e-05, 0.6, 0, 0, 0.875], + "9117": [0.64502, 1.155, 0, 0, 0.875], + "9118": [0.64502, 1.155, 0, 0, 0.875], + "9119": [1e-05, 0.6, 0, 0, 0.875], + "9120": [0.64502, 1.155, 0, 0, 0.875], + "9121": [0.64502, 1.155, 0, 0, 0.66667], + "9122": [-0.00099, 0.601, 0, 0, 0.66667], + "9123": [0.64502, 1.155, 0, 0, 0.66667], + "9124": [0.64502, 1.155, 0, 0, 0.66667], + "9125": [-0.00099, 0.601, 0, 0, 0.66667], + "9126": [0.64502, 1.155, 0, 0, 0.66667], + "9127": [1e-05, 0.9, 0, 0, 0.88889], + "9128": [0.65002, 1.15, 0, 0, 0.88889], + "9129": [0.90001, 0, 0, 0, 0.88889], + "9130": [0, 0.3, 0, 0, 0.88889], + "9131": [1e-05, 0.9, 0, 0, 0.88889], + "9132": [0.65002, 1.15, 0, 0, 0.88889], + "9133": [0.90001, 0, 0, 0, 0.88889], + "9143": [0.88502, 0.915, 0, 0, 1.05556], + "10216": [1.25003, 1.75, 0, 0, 0.80556], + "10217": [1.25003, 1.75, 0, 0, 0.80556], + "57344": [-0.00499, 0.605, 0, 0, 1.05556], + "57345": [-0.00499, 0.605, 0, 0, 1.05556], + "57680": [0, 0.12, 0, 0, 0.45], + "57681": [0, 0.12, 0, 0, 0.45], + "57682": [0, 0.12, 0, 0, 0.45], + "57683": [0, 0.12, 0, 0, 0.45] + }, + "Typewriter-Regular": { + "32": [0, 0, 0, 0, 0.525], + "33": [0, 0.61111, 0, 0, 0.525], + "34": [0, 0.61111, 0, 0, 0.525], + "35": [0, 0.61111, 0, 0, 0.525], + "36": [0.08333, 0.69444, 0, 0, 0.525], + "37": [0.08333, 0.69444, 0, 0, 0.525], + "38": [0, 0.61111, 0, 0, 0.525], + "39": [0, 0.61111, 0, 0, 0.525], + "40": [0.08333, 0.69444, 0, 0, 0.525], + "41": [0.08333, 0.69444, 0, 0, 0.525], + "42": [0, 0.52083, 0, 0, 0.525], + "43": [-0.08056, 0.53055, 0, 0, 0.525], + "44": [0.13889, 0.125, 0, 0, 0.525], + "45": [-0.08056, 0.53055, 0, 0, 0.525], + "46": [0, 0.125, 0, 0, 0.525], + "47": [0.08333, 0.69444, 0, 0, 0.525], + "48": [0, 0.61111, 0, 0, 0.525], + "49": [0, 0.61111, 0, 0, 0.525], + "50": [0, 0.61111, 0, 0, 0.525], + "51": [0, 0.61111, 0, 0, 0.525], + "52": [0, 0.61111, 0, 0, 0.525], + "53": [0, 0.61111, 0, 0, 0.525], + "54": [0, 0.61111, 0, 0, 0.525], + "55": [0, 0.61111, 0, 0, 0.525], + "56": [0, 0.61111, 0, 0, 0.525], + "57": [0, 0.61111, 0, 0, 0.525], + "58": [0, 0.43056, 0, 0, 0.525], + "59": [0.13889, 0.43056, 0, 0, 0.525], + "60": [-0.05556, 0.55556, 0, 0, 0.525], + "61": [-0.19549, 0.41562, 0, 0, 0.525], + "62": [-0.05556, 0.55556, 0, 0, 0.525], + "63": [0, 0.61111, 0, 0, 0.525], + "64": [0, 0.61111, 0, 0, 0.525], + "65": [0, 0.61111, 0, 0, 0.525], + "66": [0, 0.61111, 0, 0, 0.525], + "67": [0, 0.61111, 0, 0, 0.525], + "68": [0, 0.61111, 0, 0, 0.525], + "69": [0, 0.61111, 0, 0, 0.525], + "70": [0, 0.61111, 0, 0, 0.525], + "71": [0, 0.61111, 0, 0, 0.525], + "72": [0, 0.61111, 0, 0, 0.525], + "73": [0, 0.61111, 0, 0, 0.525], + "74": [0, 0.61111, 0, 0, 0.525], + "75": [0, 0.61111, 0, 0, 0.525], + "76": [0, 0.61111, 0, 0, 0.525], + "77": [0, 0.61111, 0, 0, 0.525], + "78": [0, 0.61111, 0, 0, 0.525], + "79": [0, 0.61111, 0, 0, 0.525], + "80": [0, 0.61111, 0, 0, 0.525], + "81": [0.13889, 0.61111, 0, 0, 0.525], + "82": [0, 0.61111, 0, 0, 0.525], + "83": [0, 0.61111, 0, 0, 0.525], + "84": [0, 0.61111, 0, 0, 0.525], + "85": [0, 0.61111, 0, 0, 0.525], + "86": [0, 0.61111, 0, 0, 0.525], + "87": [0, 0.61111, 0, 0, 0.525], + "88": [0, 0.61111, 0, 0, 0.525], + "89": [0, 0.61111, 0, 0, 0.525], + "90": [0, 0.61111, 0, 0, 0.525], + "91": [0.08333, 0.69444, 0, 0, 0.525], + "92": [0.08333, 0.69444, 0, 0, 0.525], + "93": [0.08333, 0.69444, 0, 0, 0.525], + "94": [0, 0.61111, 0, 0, 0.525], + "95": [0.09514, 0, 0, 0, 0.525], + "96": [0, 0.61111, 0, 0, 0.525], + "97": [0, 0.43056, 0, 0, 0.525], + "98": [0, 0.61111, 0, 0, 0.525], + "99": [0, 0.43056, 0, 0, 0.525], + "100": [0, 0.61111, 0, 0, 0.525], + "101": [0, 0.43056, 0, 0, 0.525], + "102": [0, 0.61111, 0, 0, 0.525], + "103": [0.22222, 0.43056, 0, 0, 0.525], + "104": [0, 0.61111, 0, 0, 0.525], + "105": [0, 0.61111, 0, 0, 0.525], + "106": [0.22222, 0.61111, 0, 0, 0.525], + "107": [0, 0.61111, 0, 0, 0.525], + "108": [0, 0.61111, 0, 0, 0.525], + "109": [0, 0.43056, 0, 0, 0.525], + "110": [0, 0.43056, 0, 0, 0.525], + "111": [0, 0.43056, 0, 0, 0.525], + "112": [0.22222, 0.43056, 0, 0, 0.525], + "113": [0.22222, 0.43056, 0, 0, 0.525], + "114": [0, 0.43056, 0, 0, 0.525], + "115": [0, 0.43056, 0, 0, 0.525], + "116": [0, 0.55358, 0, 0, 0.525], + "117": [0, 0.43056, 0, 0, 0.525], + "118": [0, 0.43056, 0, 0, 0.525], + "119": [0, 0.43056, 0, 0, 0.525], + "120": [0, 0.43056, 0, 0, 0.525], + "121": [0.22222, 0.43056, 0, 0, 0.525], + "122": [0, 0.43056, 0, 0, 0.525], + "123": [0.08333, 0.69444, 0, 0, 0.525], + "124": [0.08333, 0.69444, 0, 0, 0.525], + "125": [0.08333, 0.69444, 0, 0, 0.525], + "126": [0, 0.61111, 0, 0, 0.525], + "127": [0, 0.61111, 0, 0, 0.525], + "160": [0, 0, 0, 0, 0.525], + "176": [0, 0.61111, 0, 0, 0.525], + "184": [0.19445, 0, 0, 0, 0.525], + "305": [0, 0.43056, 0, 0, 0.525], + "567": [0.22222, 0.43056, 0, 0, 0.525], + "711": [0, 0.56597, 0, 0, 0.525], + "713": [0, 0.56555, 0, 0, 0.525], + "714": [0, 0.61111, 0, 0, 0.525], + "715": [0, 0.61111, 0, 0, 0.525], + "728": [0, 0.61111, 0, 0, 0.525], + "730": [0, 0.61111, 0, 0, 0.525], + "770": [0, 0.61111, 0, 0, 0.525], + "771": [0, 0.61111, 0, 0, 0.525], + "776": [0, 0.61111, 0, 0, 0.525], + "915": [0, 0.61111, 0, 0, 0.525], + "916": [0, 0.61111, 0, 0, 0.525], + "920": [0, 0.61111, 0, 0, 0.525], + "923": [0, 0.61111, 0, 0, 0.525], + "926": [0, 0.61111, 0, 0, 0.525], + "928": [0, 0.61111, 0, 0, 0.525], + "931": [0, 0.61111, 0, 0, 0.525], + "933": [0, 0.61111, 0, 0, 0.525], + "934": [0, 0.61111, 0, 0, 0.525], + "936": [0, 0.61111, 0, 0, 0.525], + "937": [0, 0.61111, 0, 0, 0.525], + "8216": [0, 0.61111, 0, 0, 0.525], + "8217": [0, 0.61111, 0, 0, 0.525], + "8242": [0, 0.61111, 0, 0, 0.525], + "9251": [0.11111, 0.21944, 0, 0, 0.525] + } +}; + +/** + * This file contains metrics regarding fonts and individual symbols. The sigma + * and xi variables, as well as the metricMap map contain data extracted from + * TeX, TeX font metrics, and the TTF files. These data are then exposed via the + * `metrics` variable and the getCharacterMetrics function. + */ +// In TeX, there are actually three sets of dimensions, one for each of +// textstyle (size index 5 and higher: >=9pt), scriptstyle (size index 3 and 4: +// 7-8pt), and scriptscriptstyle (size index 1 and 2: 5-6pt). These are +// provided in the arrays below, in that order. +// +// The font metrics are stored in fonts cmsy10, cmsy7, and cmsy5 respectively. +// This was determined by running the following script: +// +// latex -interaction=nonstopmode \ +// '\documentclass{article}\usepackage{amsmath}\begin{document}' \ +// '$a$ \expandafter\show\the\textfont2' \ +// '\expandafter\show\the\scriptfont2' \ +// '\expandafter\show\the\scriptscriptfont2' \ +// '\stop' +// +// The metrics themselves were retrieved using the following commands: +// +// tftopl cmsy10 +// tftopl cmsy7 +// tftopl cmsy5 +// +// The output of each of these commands is quite lengthy. The only part we +// care about is the FONTDIMEN section. Each value is measured in EMs. +var sigmasAndXis = { + slant: [0.250, 0.250, 0.250], + // sigma1 + space: [0.000, 0.000, 0.000], + // sigma2 + stretch: [0.000, 0.000, 0.000], + // sigma3 + shrink: [0.000, 0.000, 0.000], + // sigma4 + xHeight: [0.431, 0.431, 0.431], + // sigma5 + quad: [1.000, 1.171, 1.472], + // sigma6 + extraSpace: [0.000, 0.000, 0.000], + // sigma7 + num1: [0.677, 0.732, 0.925], + // sigma8 + num2: [0.394, 0.384, 0.387], + // sigma9 + num3: [0.444, 0.471, 0.504], + // sigma10 + denom1: [0.686, 0.752, 1.025], + // sigma11 + denom2: [0.345, 0.344, 0.532], + // sigma12 + sup1: [0.413, 0.503, 0.504], + // sigma13 + sup2: [0.363, 0.431, 0.404], + // sigma14 + sup3: [0.289, 0.286, 0.294], + // sigma15 + sub1: [0.150, 0.143, 0.200], + // sigma16 + sub2: [0.247, 0.286, 0.400], + // sigma17 + supDrop: [0.386, 0.353, 0.494], + // sigma18 + subDrop: [0.050, 0.071, 0.100], + // sigma19 + delim1: [2.390, 1.700, 1.980], + // sigma20 + delim2: [1.010, 1.157, 1.420], + // sigma21 + axisHeight: [0.250, 0.250, 0.250], + // sigma22 + // These font metrics are extracted from TeX by using tftopl on cmex10.tfm; + // they correspond to the font parameters of the extension fonts (family 3). + // See the TeXbook, page 441. In AMSTeX, the extension fonts scale; to + // match cmex7, we'd use cmex7.tfm values for script and scriptscript + // values. + defaultRuleThickness: [0.04, 0.049, 0.049], + // xi8; cmex7: 0.049 + bigOpSpacing1: [0.111, 0.111, 0.111], + // xi9 + bigOpSpacing2: [0.166, 0.166, 0.166], + // xi10 + bigOpSpacing3: [0.2, 0.2, 0.2], + // xi11 + bigOpSpacing4: [0.6, 0.611, 0.611], + // xi12; cmex7: 0.611 + bigOpSpacing5: [0.1, 0.143, 0.143], + // xi13; cmex7: 0.143 + // The \sqrt rule width is taken from the height of the surd character. + // Since we use the same font at all sizes, this thickness doesn't scale. + sqrtRuleThickness: [0.04, 0.04, 0.04], + // This value determines how large a pt is, for metrics which are defined + // in terms of pts. + // This value is also used in katex.scss; if you change it make sure the + // values match. + ptPerEm: [10.0, 10.0, 10.0], + // The space between adjacent `|` columns in an array definition. From + // `\showthe\doublerulesep` in LaTeX. Equals 2.0 / ptPerEm. + doubleRuleSep: [0.2, 0.2, 0.2], + // The width of separator lines in {array} environments. From + // `\showthe\arrayrulewidth` in LaTeX. Equals 0.4 / ptPerEm. + arrayRuleWidth: [0.04, 0.04, 0.04], + // Two values from LaTeX source2e: + fboxsep: [0.3, 0.3, 0.3], + // 3 pt / ptPerEm + fboxrule: [0.04, 0.04, 0.04] // 0.4 pt / ptPerEm +}; +// These are very rough approximations. We default to Times New Roman which +// should have Latin-1 and Cyrillic characters, but may not depending on the +// operating system. The metrics do not account for extra height from the +// accents. In the case of Cyrillic characters which have both ascenders and +// descenders we prefer approximations with ascenders, primarily to prevent +// the fraction bar or root line from intersecting the glyph. +// TODO(kevinb) allow union of multiple glyph metrics for better accuracy. +var extraCharacterMap = { + // Latin-1 + 'Å': 'A', + 'Ð': 'D', + 'Þ': 'o', + 'å': 'a', + 'ð': 'd', + 'þ': 'o', + // Cyrillic + 'А': 'A', + 'Б': 'B', + 'В': 'B', + 'Г': 'F', + 'Д': 'A', + 'Е': 'E', + 'Ж': 'K', + 'З': '3', + 'И': 'N', + 'Й': 'N', + 'К': 'K', + 'Л': 'N', + 'М': 'M', + 'Н': 'H', + 'О': 'O', + 'П': 'N', + 'Р': 'P', + 'С': 'C', + 'Т': 'T', + 'У': 'y', + 'Ф': 'O', + 'Х': 'X', + 'Ц': 'U', + 'Ч': 'h', + 'Ш': 'W', + 'Щ': 'W', + 'Ъ': 'B', + 'Ы': 'X', + 'Ь': 'B', + 'Э': '3', + 'Ю': 'X', + 'Я': 'R', + 'а': 'a', + 'б': 'b', + 'в': 'a', + 'г': 'r', + 'д': 'y', + 'е': 'e', + 'ж': 'm', + 'з': 'e', + 'и': 'n', + 'й': 'n', + 'к': 'n', + 'л': 'n', + 'м': 'm', + 'н': 'n', + 'о': 'o', + 'п': 'n', + 'р': 'p', + 'с': 'c', + 'т': 'o', + 'у': 'y', + 'ф': 'b', + 'х': 'x', + 'ц': 'n', + 'ч': 'n', + 'ш': 'w', + 'щ': 'w', + 'ъ': 'a', + 'ы': 'm', + 'ь': 'a', + 'э': 'e', + 'ю': 'm', + 'я': 'r' +}; +/** + * This function adds new font metrics to default metricMap + * It can also override existing metrics + */ +function setFontMetrics(fontName, metrics) { + fontMetricsData[fontName] = metrics; +} +/** + * This function is a convenience function for looking up information in the + * metricMap table. It takes a character as a string, and a font. + * + * Note: the `width` property may be undefined if fontMetricsData.js wasn't + * built using `Make extended_metrics`. + */ +function getCharacterMetrics(character, font, mode) { + if (!fontMetricsData[font]) { + throw new Error("Font metrics not found for font: " + font + "."); + } + var ch = character.charCodeAt(0); + var metrics = fontMetricsData[font][ch]; + if (!metrics && character[0] in extraCharacterMap) { + ch = extraCharacterMap[character[0]].charCodeAt(0); + metrics = fontMetricsData[font][ch]; + } + if (!metrics && mode === 'text') { + // We don't typically have font metrics for Asian scripts. + // But since we support them in text mode, we need to return + // some sort of metrics. + // So if the character is in a script we support but we + // don't have metrics for it, just use the metrics for + // the Latin capital letter M. This is close enough because + // we (currently) only care about the height of the glyph + // not its width. + if (supportedCodepoint(ch)) { + metrics = fontMetricsData[font][77]; // 77 is the charcode for 'M' + } + } + if (metrics) { + return { + depth: metrics[0], + height: metrics[1], + italic: metrics[2], + skew: metrics[3], + width: metrics[4] + }; + } +} +var fontMetricsBySizeIndex = {}; +/** + * Get the font metrics for a given size. + */ +function getGlobalMetrics(size) { + var sizeIndex; + if (size >= 5) { + sizeIndex = 0; + } else if (size >= 3) { + sizeIndex = 1; + } else { + sizeIndex = 2; + } + if (!fontMetricsBySizeIndex[sizeIndex]) { + var metrics = fontMetricsBySizeIndex[sizeIndex] = { + cssEmPerMu: sigmasAndXis.quad[sizeIndex] / 18 + }; + for (var key in sigmasAndXis) { + if (sigmasAndXis.hasOwnProperty(key)) { + metrics[key] = sigmasAndXis[key][sizeIndex]; + } + } + } + return fontMetricsBySizeIndex[sizeIndex]; +} + +/** + * This file holds a list of all no-argument functions and single-character + * symbols (like 'a' or ';'). + * + * For each of the symbols, there are three properties they can have: + * - font (required): the font to be used for this symbol. Either "main" (the + normal font), or "ams" (the ams fonts). + * - group (required): the ParseNode group type the symbol should have (i.e. + "textord", "mathord", etc). + See https://github.com/KaTeX/KaTeX/wiki/Examining-TeX#group-types + * - replace: the character that this symbol or function should be + * replaced with (i.e. "\phi" has a replace value of "\u03d5", the phi + * character in the main font). + * + * The outermost map in the table indicates what mode the symbols should be + * accepted in (e.g. "math" or "text"). + */ +var symbols = { + "math": {}, + "text": {} +}; +/** `acceptUnicodeChar = true` is only applicable if `replace` is set. */ +function defineSymbol(mode, font, group, replace, name, acceptUnicodeChar) { + symbols[mode][name] = { + font, + group, + replace + }; + if (acceptUnicodeChar && replace) { + symbols[mode][replace] = symbols[mode][name]; + } +} +// Some abbreviations for commonly used strings. +// This helps minify the code, and also spotting typos using jshint. +// modes: +var math = "math"; +var text = "text"; +// fonts: +var main = "main"; +var ams = "ams"; +// groups: +var accent = "accent-token"; +var bin = "bin"; +var close = "close"; +var inner = "inner"; +var mathord = "mathord"; +var op = "op-token"; +var open = "open"; +var punct = "punct"; +var rel = "rel"; +var spacing = "spacing"; +var textord = "textord"; +// Now comes the symbol table +// Relation Symbols +defineSymbol(math, main, rel, "\u2261", "\\equiv", true); +defineSymbol(math, main, rel, "\u227a", "\\prec", true); +defineSymbol(math, main, rel, "\u227b", "\\succ", true); +defineSymbol(math, main, rel, "\u223c", "\\sim", true); +defineSymbol(math, main, rel, "\u22a5", "\\perp"); +defineSymbol(math, main, rel, "\u2aaf", "\\preceq", true); +defineSymbol(math, main, rel, "\u2ab0", "\\succeq", true); +defineSymbol(math, main, rel, "\u2243", "\\simeq", true); +defineSymbol(math, main, rel, "\u2223", "\\mid", true); +defineSymbol(math, main, rel, "\u226a", "\\ll", true); +defineSymbol(math, main, rel, "\u226b", "\\gg", true); +defineSymbol(math, main, rel, "\u224d", "\\asymp", true); +defineSymbol(math, main, rel, "\u2225", "\\parallel"); +defineSymbol(math, main, rel, "\u22c8", "\\bowtie", true); +defineSymbol(math, main, rel, "\u2323", "\\smile", true); +defineSymbol(math, main, rel, "\u2291", "\\sqsubseteq", true); +defineSymbol(math, main, rel, "\u2292", "\\sqsupseteq", true); +defineSymbol(math, main, rel, "\u2250", "\\doteq", true); +defineSymbol(math, main, rel, "\u2322", "\\frown", true); +defineSymbol(math, main, rel, "\u220b", "\\ni", true); +defineSymbol(math, main, rel, "\u221d", "\\propto", true); +defineSymbol(math, main, rel, "\u22a2", "\\vdash", true); +defineSymbol(math, main, rel, "\u22a3", "\\dashv", true); +defineSymbol(math, main, rel, "\u220b", "\\owns"); +// Punctuation +defineSymbol(math, main, punct, "\u002e", "\\ldotp"); +defineSymbol(math, main, punct, "\u22c5", "\\cdotp"); +// The KaTeX fonts do not contain U+00B7. Use the centered dot glyph at U+22C5 +// in both modes, but keep math-mode punctuation spacing only in math mode. +defineSymbol(math, main, punct, "\u22c5", "\u00b7"); +defineSymbol(text, main, textord, "\u22c5", "\u00b7"); +// Misc Symbols +defineSymbol(math, main, textord, "\u0023", "\\#"); +defineSymbol(text, main, textord, "\u0023", "\\#"); +defineSymbol(math, main, textord, "\u0026", "\\&"); +defineSymbol(text, main, textord, "\u0026", "\\&"); +defineSymbol(math, main, textord, "\u2135", "\\aleph", true); +defineSymbol(math, main, textord, "\u2200", "\\forall", true); +defineSymbol(math, main, textord, "\u210f", "\\hbar", true); +defineSymbol(math, main, textord, "\u2203", "\\exists", true); +defineSymbol(math, main, textord, "\u2207", "\\nabla", true); +defineSymbol(math, main, textord, "\u266d", "\\flat", true); +defineSymbol(math, main, textord, "\u2113", "\\ell", true); +defineSymbol(math, main, textord, "\u266e", "\\natural", true); +defineSymbol(math, main, textord, "\u2663", "\\clubsuit", true); +defineSymbol(math, main, textord, "\u2118", "\\wp", true); +defineSymbol(math, main, textord, "\u266f", "\\sharp", true); +defineSymbol(math, main, textord, "\u2662", "\\diamondsuit", true); +defineSymbol(math, main, textord, "\u211c", "\\Re", true); +defineSymbol(math, main, textord, "\u2661", "\\heartsuit", true); +defineSymbol(math, main, textord, "\u2111", "\\Im", true); +defineSymbol(math, main, textord, "\u2660", "\\spadesuit", true); +defineSymbol(math, main, textord, "\u00a7", "\\S", true); +defineSymbol(text, main, textord, "\u00a7", "\\S"); +defineSymbol(math, main, textord, "\u00b6", "\\P", true); +defineSymbol(text, main, textord, "\u00b6", "\\P"); +// Math and Text +defineSymbol(math, main, textord, "\u2020", "\\dag"); +defineSymbol(text, main, textord, "\u2020", "\\dag"); +defineSymbol(text, main, textord, "\u2020", "\\textdagger"); +defineSymbol(math, main, textord, "\u2021", "\\ddag"); +defineSymbol(text, main, textord, "\u2021", "\\ddag"); +defineSymbol(text, main, textord, "\u2021", "\\textdaggerdbl"); +// Large Delimiters +defineSymbol(math, main, close, "\u23b1", "\\rmoustache", true); +defineSymbol(math, main, open, "\u23b0", "\\lmoustache", true); +defineSymbol(math, main, close, "\u27ef", "\\rgroup", true); +defineSymbol(math, main, open, "\u27ee", "\\lgroup", true); +// Binary Operators +defineSymbol(math, main, bin, "\u2213", "\\mp", true); +defineSymbol(math, main, bin, "\u2296", "\\ominus", true); +defineSymbol(math, main, bin, "\u228e", "\\uplus", true); +defineSymbol(math, main, bin, "\u2293", "\\sqcap", true); +defineSymbol(math, main, bin, "\u2217", "\\ast"); +defineSymbol(math, main, bin, "\u2294", "\\sqcup", true); +defineSymbol(math, main, bin, "\u25ef", "\\bigcirc", true); +defineSymbol(math, main, bin, "\u2219", "\\bullet", true); +defineSymbol(math, main, bin, "\u2021", "\\ddagger"); +defineSymbol(math, main, bin, "\u2240", "\\wr", true); +defineSymbol(math, main, bin, "\u2a3f", "\\amalg"); +defineSymbol(math, main, bin, "\u0026", "\\And"); // from amsmath +// Arrow Symbols +defineSymbol(math, main, rel, "\u27f5", "\\longleftarrow", true); +defineSymbol(math, main, rel, "\u21d0", "\\Leftarrow", true); +defineSymbol(math, main, rel, "\u27f8", "\\Longleftarrow", true); +defineSymbol(math, main, rel, "\u27f6", "\\longrightarrow", true); +defineSymbol(math, main, rel, "\u21d2", "\\Rightarrow", true); +defineSymbol(math, main, rel, "\u27f9", "\\Longrightarrow", true); +defineSymbol(math, main, rel, "\u2194", "\\leftrightarrow", true); +defineSymbol(math, main, rel, "\u27f7", "\\longleftrightarrow", true); +defineSymbol(math, main, rel, "\u21d4", "\\Leftrightarrow", true); +defineSymbol(math, main, rel, "\u27fa", "\\Longleftrightarrow", true); +defineSymbol(math, main, rel, "\u21a6", "\\mapsto", true); +defineSymbol(math, main, rel, "\u27fc", "\\longmapsto", true); +defineSymbol(math, main, rel, "\u2197", "\\nearrow", true); +defineSymbol(math, main, rel, "\u21a9", "\\hookleftarrow", true); +defineSymbol(math, main, rel, "\u21aa", "\\hookrightarrow", true); +defineSymbol(math, main, rel, "\u2198", "\\searrow", true); +defineSymbol(math, main, rel, "\u21bc", "\\leftharpoonup", true); +defineSymbol(math, main, rel, "\u21c0", "\\rightharpoonup", true); +defineSymbol(math, main, rel, "\u2199", "\\swarrow", true); +defineSymbol(math, main, rel, "\u21bd", "\\leftharpoondown", true); +defineSymbol(math, main, rel, "\u21c1", "\\rightharpoondown", true); +defineSymbol(math, main, rel, "\u2196", "\\nwarrow", true); +defineSymbol(math, main, rel, "\u21cc", "\\rightleftharpoons", true); +// AMS Negated Binary Relations +defineSymbol(math, ams, rel, "\u226e", "\\nless", true); +// Symbol names preceded by "@" each have a corresponding macro. +defineSymbol(math, ams, rel, "\ue010", "\\@nleqslant"); +defineSymbol(math, ams, rel, "\ue011", "\\@nleqq"); +defineSymbol(math, ams, rel, "\u2a87", "\\lneq", true); +defineSymbol(math, ams, rel, "\u2268", "\\lneqq", true); +defineSymbol(math, ams, rel, "\ue00c", "\\@lvertneqq"); +defineSymbol(math, ams, rel, "\u22e6", "\\lnsim", true); +defineSymbol(math, ams, rel, "\u2a89", "\\lnapprox", true); +defineSymbol(math, ams, rel, "\u2280", "\\nprec", true); +// unicode-math maps \u22e0 to \npreccurlyeq. We'll use the AMS synonym. +defineSymbol(math, ams, rel, "\u22e0", "\\npreceq", true); +defineSymbol(math, ams, rel, "\u22e8", "\\precnsim", true); +defineSymbol(math, ams, rel, "\u2ab9", "\\precnapprox", true); +defineSymbol(math, ams, rel, "\u2241", "\\nsim", true); +defineSymbol(math, ams, rel, "\ue006", "\\@nshortmid"); +defineSymbol(math, ams, rel, "\u2224", "\\nmid", true); +defineSymbol(math, ams, rel, "\u22ac", "\\nvdash", true); +defineSymbol(math, ams, rel, "\u22ad", "\\nvDash", true); +defineSymbol(math, ams, rel, "\u22ea", "\\ntriangleleft"); +defineSymbol(math, ams, rel, "\u22ec", "\\ntrianglelefteq", true); +defineSymbol(math, ams, rel, "\u228a", "\\subsetneq", true); +defineSymbol(math, ams, rel, "\ue01a", "\\@varsubsetneq"); +defineSymbol(math, ams, rel, "\u2acb", "\\subsetneqq", true); +defineSymbol(math, ams, rel, "\ue017", "\\@varsubsetneqq"); +defineSymbol(math, ams, rel, "\u226f", "\\ngtr", true); +defineSymbol(math, ams, rel, "\ue00f", "\\@ngeqslant"); +defineSymbol(math, ams, rel, "\ue00e", "\\@ngeqq"); +defineSymbol(math, ams, rel, "\u2a88", "\\gneq", true); +defineSymbol(math, ams, rel, "\u2269", "\\gneqq", true); +defineSymbol(math, ams, rel, "\ue00d", "\\@gvertneqq"); +defineSymbol(math, ams, rel, "\u22e7", "\\gnsim", true); +defineSymbol(math, ams, rel, "\u2a8a", "\\gnapprox", true); +defineSymbol(math, ams, rel, "\u2281", "\\nsucc", true); +// unicode-math maps \u22e1 to \nsucccurlyeq. We'll use the AMS synonym. +defineSymbol(math, ams, rel, "\u22e1", "\\nsucceq", true); +defineSymbol(math, ams, rel, "\u22e9", "\\succnsim", true); +defineSymbol(math, ams, rel, "\u2aba", "\\succnapprox", true); +// unicode-math maps \u2246 to \simneqq. We'll use the AMS synonym. +defineSymbol(math, ams, rel, "\u2246", "\\ncong", true); +defineSymbol(math, ams, rel, "\ue007", "\\@nshortparallel"); +defineSymbol(math, ams, rel, "\u2226", "\\nparallel", true); +defineSymbol(math, ams, rel, "\u22af", "\\nVDash", true); +defineSymbol(math, ams, rel, "\u22eb", "\\ntriangleright"); +defineSymbol(math, ams, rel, "\u22ed", "\\ntrianglerighteq", true); +defineSymbol(math, ams, rel, "\ue018", "\\@nsupseteqq"); +defineSymbol(math, ams, rel, "\u228b", "\\supsetneq", true); +defineSymbol(math, ams, rel, "\ue01b", "\\@varsupsetneq"); +defineSymbol(math, ams, rel, "\u2acc", "\\supsetneqq", true); +defineSymbol(math, ams, rel, "\ue019", "\\@varsupsetneqq"); +defineSymbol(math, ams, rel, "\u22ae", "\\nVdash", true); +defineSymbol(math, ams, rel, "\u2ab5", "\\precneqq", true); +defineSymbol(math, ams, rel, "\u2ab6", "\\succneqq", true); +defineSymbol(math, ams, rel, "\ue016", "\\@nsubseteqq"); +defineSymbol(math, ams, bin, "\u22b4", "\\unlhd"); +defineSymbol(math, ams, bin, "\u22b5", "\\unrhd"); +// AMS Negated Arrows +defineSymbol(math, ams, rel, "\u219a", "\\nleftarrow", true); +defineSymbol(math, ams, rel, "\u219b", "\\nrightarrow", true); +defineSymbol(math, ams, rel, "\u21cd", "\\nLeftarrow", true); +defineSymbol(math, ams, rel, "\u21cf", "\\nRightarrow", true); +defineSymbol(math, ams, rel, "\u21ae", "\\nleftrightarrow", true); +defineSymbol(math, ams, rel, "\u21ce", "\\nLeftrightarrow", true); +// AMS Misc +defineSymbol(math, ams, rel, "\u25b3", "\\vartriangle"); +defineSymbol(math, ams, textord, "\u210f", "\\hslash"); +defineSymbol(math, ams, textord, "\u25bd", "\\triangledown"); +defineSymbol(math, ams, textord, "\u25ca", "\\lozenge"); +defineSymbol(math, ams, textord, "\u24c8", "\\circledS"); +defineSymbol(math, ams, textord, "\u00ae", "\\circledR"); +defineSymbol(text, ams, textord, "\u00ae", "\\circledR"); +defineSymbol(math, ams, textord, "\u2221", "\\measuredangle", true); +defineSymbol(math, ams, textord, "\u2204", "\\nexists"); +defineSymbol(math, ams, textord, "\u2127", "\\mho"); +defineSymbol(math, ams, textord, "\u2132", "\\Finv", true); +defineSymbol(math, ams, textord, "\u2141", "\\Game", true); +defineSymbol(math, ams, textord, "\u2035", "\\backprime"); +defineSymbol(math, ams, textord, "\u25b2", "\\blacktriangle"); +defineSymbol(math, ams, textord, "\u25bc", "\\blacktriangledown"); +defineSymbol(math, ams, textord, "\u25a0", "\\blacksquare"); +defineSymbol(math, ams, textord, "\u29eb", "\\blacklozenge"); +defineSymbol(math, ams, textord, "\u2605", "\\bigstar"); +defineSymbol(math, ams, textord, "\u2222", "\\sphericalangle", true); +defineSymbol(math, ams, textord, "\u2201", "\\complement", true); +// unicode-math maps U+F0 to \matheth. We map to AMS function \eth +defineSymbol(math, ams, textord, "\u00f0", "\\eth", true); +defineSymbol(text, main, textord, "\u00f0", "\u00f0"); +defineSymbol(math, ams, textord, "\u2571", "\\diagup"); +defineSymbol(math, ams, textord, "\u2572", "\\diagdown"); +defineSymbol(math, ams, textord, "\u25a1", "\\square"); +defineSymbol(math, ams, textord, "\u25a1", "\\Box"); +defineSymbol(math, ams, textord, "\u25ca", "\\Diamond"); +// unicode-math maps U+A5 to \mathyen. We map to AMS function \yen +defineSymbol(math, ams, textord, "\u00a5", "\\yen", true); +defineSymbol(text, ams, textord, "\u00a5", "\\yen", true); +defineSymbol(math, ams, textord, "\u2713", "\\checkmark", true); +defineSymbol(text, ams, textord, "\u2713", "\\checkmark"); +// AMS Hebrew +defineSymbol(math, ams, textord, "\u2136", "\\beth", true); +defineSymbol(math, ams, textord, "\u2138", "\\daleth", true); +defineSymbol(math, ams, textord, "\u2137", "\\gimel", true); +// AMS Greek +defineSymbol(math, ams, textord, "\u03dd", "\\digamma", true); +defineSymbol(math, ams, textord, "\u03f0", "\\varkappa"); +// AMS Delimiters +defineSymbol(math, ams, open, "\u250c", "\\@ulcorner", true); +defineSymbol(math, ams, close, "\u2510", "\\@urcorner", true); +defineSymbol(math, ams, open, "\u2514", "\\@llcorner", true); +defineSymbol(math, ams, close, "\u2518", "\\@lrcorner", true); +// AMS Binary Relations +defineSymbol(math, ams, rel, "\u2266", "\\leqq", true); +defineSymbol(math, ams, rel, "\u2a7d", "\\leqslant", true); +defineSymbol(math, ams, rel, "\u2a95", "\\eqslantless", true); +defineSymbol(math, ams, rel, "\u2272", "\\lesssim", true); +defineSymbol(math, ams, rel, "\u2a85", "\\lessapprox", true); +defineSymbol(math, ams, rel, "\u224a", "\\approxeq", true); +defineSymbol(math, ams, bin, "\u22d6", "\\lessdot"); +defineSymbol(math, ams, rel, "\u22d8", "\\lll", true); +defineSymbol(math, ams, rel, "\u2276", "\\lessgtr", true); +defineSymbol(math, ams, rel, "\u22da", "\\lesseqgtr", true); +defineSymbol(math, ams, rel, "\u2a8b", "\\lesseqqgtr", true); +defineSymbol(math, ams, rel, "\u2251", "\\doteqdot"); +defineSymbol(math, ams, rel, "\u2253", "\\risingdotseq", true); +defineSymbol(math, ams, rel, "\u2252", "\\fallingdotseq", true); +defineSymbol(math, ams, rel, "\u223d", "\\backsim", true); +defineSymbol(math, ams, rel, "\u22cd", "\\backsimeq", true); +defineSymbol(math, ams, rel, "\u2ac5", "\\subseteqq", true); +defineSymbol(math, ams, rel, "\u22d0", "\\Subset", true); +defineSymbol(math, ams, rel, "\u228f", "\\sqsubset", true); +defineSymbol(math, ams, rel, "\u227c", "\\preccurlyeq", true); +defineSymbol(math, ams, rel, "\u22de", "\\curlyeqprec", true); +defineSymbol(math, ams, rel, "\u227e", "\\precsim", true); +defineSymbol(math, ams, rel, "\u2ab7", "\\precapprox", true); +defineSymbol(math, ams, rel, "\u22b2", "\\vartriangleleft"); +defineSymbol(math, ams, rel, "\u22b4", "\\trianglelefteq"); +defineSymbol(math, ams, rel, "\u22a8", "\\vDash", true); +defineSymbol(math, ams, rel, "\u22aa", "\\Vvdash", true); +defineSymbol(math, ams, rel, "\u2323", "\\smallsmile"); +defineSymbol(math, ams, rel, "\u2322", "\\smallfrown"); +defineSymbol(math, ams, rel, "\u224f", "\\bumpeq", true); +defineSymbol(math, ams, rel, "\u224e", "\\Bumpeq", true); +defineSymbol(math, ams, rel, "\u2267", "\\geqq", true); +defineSymbol(math, ams, rel, "\u2a7e", "\\geqslant", true); +defineSymbol(math, ams, rel, "\u2a96", "\\eqslantgtr", true); +defineSymbol(math, ams, rel, "\u2273", "\\gtrsim", true); +defineSymbol(math, ams, rel, "\u2a86", "\\gtrapprox", true); +defineSymbol(math, ams, bin, "\u22d7", "\\gtrdot"); +defineSymbol(math, ams, rel, "\u22d9", "\\ggg", true); +defineSymbol(math, ams, rel, "\u2277", "\\gtrless", true); +defineSymbol(math, ams, rel, "\u22db", "\\gtreqless", true); +defineSymbol(math, ams, rel, "\u2a8c", "\\gtreqqless", true); +defineSymbol(math, ams, rel, "\u2256", "\\eqcirc", true); +defineSymbol(math, ams, rel, "\u2257", "\\circeq", true); +defineSymbol(math, ams, rel, "\u225c", "\\triangleq", true); +defineSymbol(math, ams, rel, "\u223c", "\\thicksim"); +defineSymbol(math, ams, rel, "\u2248", "\\thickapprox"); +defineSymbol(math, ams, rel, "\u2ac6", "\\supseteqq", true); +defineSymbol(math, ams, rel, "\u22d1", "\\Supset", true); +defineSymbol(math, ams, rel, "\u2290", "\\sqsupset", true); +defineSymbol(math, ams, rel, "\u227d", "\\succcurlyeq", true); +defineSymbol(math, ams, rel, "\u22df", "\\curlyeqsucc", true); +defineSymbol(math, ams, rel, "\u227f", "\\succsim", true); +defineSymbol(math, ams, rel, "\u2ab8", "\\succapprox", true); +defineSymbol(math, ams, rel, "\u22b3", "\\vartriangleright"); +defineSymbol(math, ams, rel, "\u22b5", "\\trianglerighteq"); +defineSymbol(math, ams, rel, "\u22a9", "\\Vdash", true); +defineSymbol(math, ams, rel, "\u2223", "\\shortmid"); +defineSymbol(math, ams, rel, "\u2225", "\\shortparallel"); +defineSymbol(math, ams, rel, "\u226c", "\\between", true); +defineSymbol(math, ams, rel, "\u22d4", "\\pitchfork", true); +defineSymbol(math, ams, rel, "\u221d", "\\varpropto"); +defineSymbol(math, ams, rel, "\u25c0", "\\blacktriangleleft"); +// unicode-math says that \therefore is a mathord atom. +// We kept the amssymb atom type, which is rel. +defineSymbol(math, ams, rel, "\u2234", "\\therefore", true); +defineSymbol(math, ams, rel, "\u220d", "\\backepsilon"); +defineSymbol(math, ams, rel, "\u25b6", "\\blacktriangleright"); +// unicode-math says that \because is a mathord atom. +// We kept the amssymb atom type, which is rel. +defineSymbol(math, ams, rel, "\u2235", "\\because", true); +defineSymbol(math, ams, rel, "\u22d8", "\\llless"); +defineSymbol(math, ams, rel, "\u22d9", "\\gggtr"); +defineSymbol(math, ams, bin, "\u22b2", "\\lhd"); +defineSymbol(math, ams, bin, "\u22b3", "\\rhd"); +defineSymbol(math, ams, rel, "\u2242", "\\eqsim", true); +defineSymbol(math, main, rel, "\u22c8", "\\Join"); +defineSymbol(math, ams, rel, "\u2251", "\\Doteq", true); +// AMS Binary Operators +defineSymbol(math, ams, bin, "\u2214", "\\dotplus", true); +defineSymbol(math, ams, bin, "\u2216", "\\smallsetminus"); +defineSymbol(math, ams, bin, "\u22d2", "\\Cap", true); +defineSymbol(math, ams, bin, "\u22d3", "\\Cup", true); +defineSymbol(math, ams, bin, "\u2a5e", "\\doublebarwedge", true); +defineSymbol(math, ams, bin, "\u229f", "\\boxminus", true); +defineSymbol(math, ams, bin, "\u229e", "\\boxplus", true); +defineSymbol(math, ams, bin, "\u22c7", "\\divideontimes", true); +defineSymbol(math, ams, bin, "\u22c9", "\\ltimes", true); +defineSymbol(math, ams, bin, "\u22ca", "\\rtimes", true); +defineSymbol(math, ams, bin, "\u22cb", "\\leftthreetimes", true); +defineSymbol(math, ams, bin, "\u22cc", "\\rightthreetimes", true); +defineSymbol(math, ams, bin, "\u22cf", "\\curlywedge", true); +defineSymbol(math, ams, bin, "\u22ce", "\\curlyvee", true); +defineSymbol(math, ams, bin, "\u229d", "\\circleddash", true); +defineSymbol(math, ams, bin, "\u229b", "\\circledast", true); +defineSymbol(math, ams, bin, "\u22c5", "\\centerdot"); +defineSymbol(math, ams, bin, "\u22ba", "\\intercal", true); +defineSymbol(math, ams, bin, "\u22d2", "\\doublecap"); +defineSymbol(math, ams, bin, "\u22d3", "\\doublecup"); +defineSymbol(math, ams, bin, "\u22a0", "\\boxtimes", true); +// AMS Arrows +// Note: unicode-math maps \u21e2 to their own function \rightdasharrow. +// We'll map it to AMS function \dashrightarrow. It produces the same atom. +defineSymbol(math, ams, rel, "\u21e2", "\\dashrightarrow", true); +// unicode-math maps \u21e0 to \leftdasharrow. We'll use the AMS synonym. +defineSymbol(math, ams, rel, "\u21e0", "\\dashleftarrow", true); +defineSymbol(math, ams, rel, "\u21c7", "\\leftleftarrows", true); +defineSymbol(math, ams, rel, "\u21c6", "\\leftrightarrows", true); +defineSymbol(math, ams, rel, "\u21da", "\\Lleftarrow", true); +defineSymbol(math, ams, rel, "\u219e", "\\twoheadleftarrow", true); +defineSymbol(math, ams, rel, "\u21a2", "\\leftarrowtail", true); +defineSymbol(math, ams, rel, "\u21ab", "\\looparrowleft", true); +defineSymbol(math, ams, rel, "\u21cb", "\\leftrightharpoons", true); +defineSymbol(math, ams, rel, "\u21b6", "\\curvearrowleft", true); +// unicode-math maps \u21ba to \acwopencirclearrow. We'll use the AMS synonym. +defineSymbol(math, ams, rel, "\u21ba", "\\circlearrowleft", true); +defineSymbol(math, ams, rel, "\u21b0", "\\Lsh", true); +defineSymbol(math, ams, rel, "\u21c8", "\\upuparrows", true); +defineSymbol(math, ams, rel, "\u21bf", "\\upharpoonleft", true); +defineSymbol(math, ams, rel, "\u21c3", "\\downharpoonleft", true); +defineSymbol(math, main, rel, "\u22b6", "\\origof", true); // not in font +defineSymbol(math, main, rel, "\u22b7", "\\imageof", true); // not in font +defineSymbol(math, ams, rel, "\u22b8", "\\multimap", true); +defineSymbol(math, ams, rel, "\u21ad", "\\leftrightsquigarrow", true); +defineSymbol(math, ams, rel, "\u21c9", "\\rightrightarrows", true); +defineSymbol(math, ams, rel, "\u21c4", "\\rightleftarrows", true); +defineSymbol(math, ams, rel, "\u21a0", "\\twoheadrightarrow", true); +defineSymbol(math, ams, rel, "\u21a3", "\\rightarrowtail", true); +defineSymbol(math, ams, rel, "\u21ac", "\\looparrowright", true); +defineSymbol(math, ams, rel, "\u21b7", "\\curvearrowright", true); +// unicode-math maps \u21bb to \cwopencirclearrow. We'll use the AMS synonym. +defineSymbol(math, ams, rel, "\u21bb", "\\circlearrowright", true); +defineSymbol(math, ams, rel, "\u21b1", "\\Rsh", true); +defineSymbol(math, ams, rel, "\u21ca", "\\downdownarrows", true); +defineSymbol(math, ams, rel, "\u21be", "\\upharpoonright", true); +defineSymbol(math, ams, rel, "\u21c2", "\\downharpoonright", true); +defineSymbol(math, ams, rel, "\u21dd", "\\rightsquigarrow", true); +defineSymbol(math, ams, rel, "\u21dd", "\\leadsto"); +defineSymbol(math, ams, rel, "\u21db", "\\Rrightarrow", true); +defineSymbol(math, ams, rel, "\u21be", "\\restriction"); +defineSymbol(math, main, textord, "\u2018", "`"); +defineSymbol(math, main, textord, "$", "\\$"); +defineSymbol(text, main, textord, "$", "\\$"); +defineSymbol(text, main, textord, "$", "\\textdollar"); +defineSymbol(math, main, textord, "%", "\\%"); +defineSymbol(text, main, textord, "%", "\\%"); +defineSymbol(math, main, textord, "_", "\\_"); +defineSymbol(text, main, textord, "_", "\\_"); +defineSymbol(text, main, textord, "_", "\\textunderscore"); +defineSymbol(math, main, textord, "\u2220", "\\angle", true); +defineSymbol(math, main, textord, "\u221e", "\\infty", true); +defineSymbol(math, main, textord, "\u2032", "\\prime"); +defineSymbol(math, main, textord, "\u25b3", "\\triangle"); +defineSymbol(math, main, textord, "\u0393", "\\Gamma", true); +defineSymbol(math, main, textord, "\u0394", "\\Delta", true); +defineSymbol(math, main, textord, "\u0398", "\\Theta", true); +defineSymbol(math, main, textord, "\u039b", "\\Lambda", true); +defineSymbol(math, main, textord, "\u039e", "\\Xi", true); +defineSymbol(math, main, textord, "\u03a0", "\\Pi", true); +defineSymbol(math, main, textord, "\u03a3", "\\Sigma", true); +defineSymbol(math, main, textord, "\u03a5", "\\Upsilon", true); +defineSymbol(math, main, textord, "\u03a6", "\\Phi", true); +defineSymbol(math, main, textord, "\u03a8", "\\Psi", true); +defineSymbol(math, main, textord, "\u03a9", "\\Omega", true); +defineSymbol(math, main, textord, "A", "\u0391"); +defineSymbol(math, main, textord, "B", "\u0392"); +defineSymbol(math, main, textord, "E", "\u0395"); +defineSymbol(math, main, textord, "Z", "\u0396"); +defineSymbol(math, main, textord, "H", "\u0397"); +defineSymbol(math, main, textord, "I", "\u0399"); +defineSymbol(math, main, textord, "K", "\u039A"); +defineSymbol(math, main, textord, "M", "\u039C"); +defineSymbol(math, main, textord, "N", "\u039D"); +defineSymbol(math, main, textord, "O", "\u039F"); +defineSymbol(math, main, textord, "P", "\u03A1"); +defineSymbol(math, main, textord, "T", "\u03A4"); +defineSymbol(math, main, textord, "X", "\u03A7"); +defineSymbol(math, main, textord, "\u00ac", "\\neg", true); +defineSymbol(math, main, textord, "\u00ac", "\\lnot"); +defineSymbol(math, main, textord, "\u22a4", "\\top"); +defineSymbol(math, main, textord, "\u22a5", "\\bot"); +defineSymbol(math, main, textord, "\u2205", "\\emptyset"); +defineSymbol(math, ams, textord, "\u2205", "\\varnothing"); +defineSymbol(math, main, mathord, "\u03b1", "\\alpha", true); +defineSymbol(math, main, mathord, "\u03b2", "\\beta", true); +defineSymbol(math, main, mathord, "\u03b3", "\\gamma", true); +defineSymbol(math, main, mathord, "\u03b4", "\\delta", true); +defineSymbol(math, main, mathord, "\u03f5", "\\epsilon", true); +defineSymbol(math, main, mathord, "\u03b6", "\\zeta", true); +defineSymbol(math, main, mathord, "\u03b7", "\\eta", true); +defineSymbol(math, main, mathord, "\u03b8", "\\theta", true); +defineSymbol(math, main, mathord, "\u03b9", "\\iota", true); +defineSymbol(math, main, mathord, "\u03ba", "\\kappa", true); +defineSymbol(math, main, mathord, "\u03bb", "\\lambda", true); +defineSymbol(math, main, mathord, "\u03bc", "\\mu", true); +defineSymbol(math, main, mathord, "\u03bd", "\\nu", true); +defineSymbol(math, main, mathord, "\u03be", "\\xi", true); +defineSymbol(math, main, mathord, "\u03bf", "\\omicron", true); +defineSymbol(math, main, mathord, "\u03c0", "\\pi", true); +defineSymbol(math, main, mathord, "\u03c1", "\\rho", true); +defineSymbol(math, main, mathord, "\u03c3", "\\sigma", true); +defineSymbol(math, main, mathord, "\u03c4", "\\tau", true); +defineSymbol(math, main, mathord, "\u03c5", "\\upsilon", true); +defineSymbol(math, main, mathord, "\u03d5", "\\phi", true); +defineSymbol(math, main, mathord, "\u03c7", "\\chi", true); +defineSymbol(math, main, mathord, "\u03c8", "\\psi", true); +defineSymbol(math, main, mathord, "\u03c9", "\\omega", true); +defineSymbol(math, main, mathord, "\u03b5", "\\varepsilon", true); +defineSymbol(math, main, mathord, "\u03d1", "\\vartheta", true); +defineSymbol(math, main, mathord, "\u03d6", "\\varpi", true); +defineSymbol(math, main, mathord, "\u03f1", "\\varrho", true); +defineSymbol(math, main, mathord, "\u03c2", "\\varsigma", true); +defineSymbol(math, main, mathord, "\u03c6", "\\varphi", true); +defineSymbol(math, main, bin, "\u2217", "*", true); +defineSymbol(math, main, bin, "+", "+"); +defineSymbol(math, main, bin, "\u2212", "-", true); +defineSymbol(math, main, bin, "\u22c5", "\\cdot", true); +defineSymbol(math, main, bin, "\u2218", "\\circ", true); +defineSymbol(math, main, bin, "\u00f7", "\\div", true); +defineSymbol(math, main, bin, "\u00b1", "\\pm", true); +defineSymbol(math, main, bin, "\u00d7", "\\times", true); +defineSymbol(math, main, bin, "\u2229", "\\cap", true); +defineSymbol(math, main, bin, "\u222a", "\\cup", true); +defineSymbol(math, main, bin, "\u2216", "\\setminus", true); +defineSymbol(math, main, bin, "\u2227", "\\land"); +defineSymbol(math, main, bin, "\u2228", "\\lor"); +defineSymbol(math, main, bin, "\u2227", "\\wedge", true); +defineSymbol(math, main, bin, "\u2228", "\\vee", true); +defineSymbol(math, main, textord, "\u221a", "\\surd"); +defineSymbol(math, main, open, "\u27e8", "\\langle", true); +defineSymbol(math, main, open, "\u2223", "\\lvert"); +defineSymbol(math, main, open, "\u2225", "\\lVert"); +defineSymbol(math, main, close, "?", "?"); +defineSymbol(math, main, close, "!", "!"); +defineSymbol(math, main, close, "\u27e9", "\\rangle", true); +defineSymbol(math, main, close, "\u2223", "\\rvert"); +defineSymbol(math, main, close, "\u2225", "\\rVert"); +defineSymbol(math, main, rel, "=", "="); +defineSymbol(math, main, rel, ":", ":"); +defineSymbol(math, main, rel, "\u2248", "\\approx", true); +defineSymbol(math, main, rel, "\u2245", "\\cong", true); +defineSymbol(math, main, rel, "\u2265", "\\ge"); +defineSymbol(math, main, rel, "\u2265", "\\geq", true); +defineSymbol(math, main, rel, "\u2190", "\\gets"); +defineSymbol(math, main, rel, ">", "\\gt", true); +defineSymbol(math, main, rel, "\u2208", "\\in", true); +defineSymbol(math, main, rel, "\ue020", "\\@not"); +defineSymbol(math, main, rel, "\u2282", "\\subset", true); +defineSymbol(math, main, rel, "\u2283", "\\supset", true); +defineSymbol(math, main, rel, "\u2286", "\\subseteq", true); +defineSymbol(math, main, rel, "\u2287", "\\supseteq", true); +defineSymbol(math, ams, rel, "\u2288", "\\nsubseteq", true); +defineSymbol(math, ams, rel, "\u2289", "\\nsupseteq", true); +defineSymbol(math, main, rel, "\u22a8", "\\models"); +defineSymbol(math, main, rel, "\u2190", "\\leftarrow", true); +defineSymbol(math, main, rel, "\u2264", "\\le"); +defineSymbol(math, main, rel, "\u2264", "\\leq", true); +defineSymbol(math, main, rel, "<", "\\lt", true); +defineSymbol(math, main, rel, "\u2192", "\\rightarrow", true); +defineSymbol(math, main, rel, "\u2192", "\\to"); +defineSymbol(math, ams, rel, "\u2271", "\\ngeq", true); +defineSymbol(math, ams, rel, "\u2270", "\\nleq", true); +defineSymbol(math, main, spacing, "\u00a0", "\\ "); +defineSymbol(math, main, spacing, "\u00a0", "\\space"); +// Ref: LaTeX Source 2e: \DeclareRobustCommand{\nobreakspace}{% +defineSymbol(math, main, spacing, "\u00a0", "\\nobreakspace"); +defineSymbol(text, main, spacing, "\u00a0", "\\ "); +defineSymbol(text, main, spacing, "\u00a0", " "); +defineSymbol(text, main, spacing, "\u00a0", "\\space"); +defineSymbol(text, main, spacing, "\u00a0", "\\nobreakspace"); +defineSymbol(math, main, spacing, "", "\\nobreak"); +defineSymbol(math, main, spacing, "", "\\allowbreak"); +defineSymbol(math, main, punct, ",", ","); +defineSymbol(math, main, punct, ";", ";"); +defineSymbol(math, ams, bin, "\u22bc", "\\barwedge", true); +defineSymbol(math, ams, bin, "\u22bb", "\\veebar", true); +defineSymbol(math, main, bin, "\u2299", "\\odot", true); +defineSymbol(math, main, bin, "\u2295", "\\oplus", true); +defineSymbol(math, main, bin, "\u2297", "\\otimes", true); +defineSymbol(math, main, textord, "\u2202", "\\partial", true); +defineSymbol(math, main, bin, "\u2298", "\\oslash", true); +defineSymbol(math, ams, bin, "\u229a", "\\circledcirc", true); +defineSymbol(math, ams, bin, "\u22a1", "\\boxdot", true); +defineSymbol(math, main, bin, "\u25b3", "\\bigtriangleup"); +defineSymbol(math, main, bin, "\u25bd", "\\bigtriangledown"); +defineSymbol(math, main, bin, "\u2020", "\\dagger"); +defineSymbol(math, main, bin, "\u22c4", "\\diamond"); +defineSymbol(math, main, bin, "\u22c6", "\\star"); +defineSymbol(math, main, bin, "\u25c3", "\\triangleleft"); +defineSymbol(math, main, bin, "\u25b9", "\\triangleright"); +defineSymbol(math, main, open, "{", "\\{"); +defineSymbol(text, main, textord, "{", "\\{"); +defineSymbol(text, main, textord, "{", "\\textbraceleft"); +defineSymbol(math, main, close, "}", "\\}"); +defineSymbol(text, main, textord, "}", "\\}"); +defineSymbol(text, main, textord, "}", "\\textbraceright"); +defineSymbol(math, main, open, "{", "\\lbrace"); +defineSymbol(math, main, close, "}", "\\rbrace"); +defineSymbol(math, main, open, "[", "\\lbrack", true); +defineSymbol(text, main, textord, "[", "\\lbrack", true); +defineSymbol(math, main, close, "]", "\\rbrack", true); +defineSymbol(text, main, textord, "]", "\\rbrack", true); +defineSymbol(math, main, open, "(", "\\lparen", true); +defineSymbol(math, main, close, ")", "\\rparen", true); +defineSymbol(text, main, textord, "<", "\\textless", true); // in T1 fontenc +defineSymbol(text, main, textord, ">", "\\textgreater", true); // in T1 fontenc +defineSymbol(math, main, open, "\u230a", "\\lfloor", true); +defineSymbol(math, main, close, "\u230b", "\\rfloor", true); +defineSymbol(math, main, open, "\u2308", "\\lceil", true); +defineSymbol(math, main, close, "\u2309", "\\rceil", true); +defineSymbol(math, main, textord, "\\", "\\backslash"); +defineSymbol(math, main, textord, "\u2223", "|"); +defineSymbol(math, main, textord, "\u2223", "\\vert"); +defineSymbol(text, main, textord, "|", "\\textbar", true); // in T1 fontenc +defineSymbol(math, main, textord, "\u2225", "\\|"); +defineSymbol(math, main, textord, "\u2225", "\\Vert"); +defineSymbol(text, main, textord, "\u2225", "\\textbardbl"); +defineSymbol(text, main, textord, "~", "\\textasciitilde"); +defineSymbol(text, main, textord, "\\", "\\textbackslash"); +defineSymbol(text, main, textord, "^", "\\textasciicircum"); +defineSymbol(math, main, rel, "\u2191", "\\uparrow", true); +defineSymbol(math, main, rel, "\u21d1", "\\Uparrow", true); +defineSymbol(math, main, rel, "\u2193", "\\downarrow", true); +defineSymbol(math, main, rel, "\u21d3", "\\Downarrow", true); +defineSymbol(math, main, rel, "\u2195", "\\updownarrow", true); +defineSymbol(math, main, rel, "\u21d5", "\\Updownarrow", true); +defineSymbol(math, main, op, "\u2210", "\\coprod"); +defineSymbol(math, main, op, "\u22c1", "\\bigvee"); +defineSymbol(math, main, op, "\u22c0", "\\bigwedge"); +defineSymbol(math, main, op, "\u2a04", "\\biguplus"); +defineSymbol(math, main, op, "\u22c2", "\\bigcap"); +defineSymbol(math, main, op, "\u22c3", "\\bigcup"); +defineSymbol(math, main, op, "\u222b", "\\int"); +defineSymbol(math, main, op, "\u222b", "\\intop"); +defineSymbol(math, main, op, "\u222c", "\\iint"); +defineSymbol(math, main, op, "\u222d", "\\iiint"); +defineSymbol(math, main, op, "\u220f", "\\prod"); +defineSymbol(math, main, op, "\u2211", "\\sum"); +defineSymbol(math, main, op, "\u2a02", "\\bigotimes"); +defineSymbol(math, main, op, "\u2a01", "\\bigoplus"); +defineSymbol(math, main, op, "\u2a00", "\\bigodot"); +defineSymbol(math, main, op, "\u222e", "\\oint"); +defineSymbol(math, main, op, "\u222f", "\\oiint"); +defineSymbol(math, main, op, "\u2230", "\\oiiint"); +defineSymbol(math, main, op, "\u2a06", "\\bigsqcup"); +defineSymbol(math, main, op, "\u222b", "\\smallint"); +defineSymbol(text, main, inner, "\u2026", "\\textellipsis"); +defineSymbol(math, main, inner, "\u2026", "\\mathellipsis"); +defineSymbol(text, main, inner, "\u2026", "\\ldots", true); +defineSymbol(math, main, inner, "\u2026", "\\ldots", true); +defineSymbol(math, main, inner, "\u22ef", "\\@cdots", true); +defineSymbol(math, main, inner, "\u22f1", "\\ddots", true); +// \vdots is a macro that uses one of these two symbols (with made-up names): +defineSymbol(math, main, textord, "\u22ee", "\\varvdots"); +defineSymbol(text, main, textord, "\u22ee", "\\varvdots"); +defineSymbol(math, main, accent, "\u02ca", "\\acute"); +defineSymbol(math, main, accent, "\u02cb", "\\grave"); +defineSymbol(math, main, accent, "\u00a8", "\\ddot"); +defineSymbol(math, main, accent, "\u007e", "\\tilde"); +defineSymbol(math, main, accent, "\u02c9", "\\bar"); +defineSymbol(math, main, accent, "\u02d8", "\\breve"); +defineSymbol(math, main, accent, "\u02c7", "\\check"); +defineSymbol(math, main, accent, "\u005e", "\\hat"); +defineSymbol(math, main, accent, "\u20d7", "\\vec"); +defineSymbol(math, main, accent, "\u02d9", "\\dot"); +defineSymbol(math, main, accent, "\u02da", "\\mathring"); +// \imath and \jmath should be invariant to \mathrm, \mathbf, etc., so use PUA +defineSymbol(math, main, mathord, "\ue131", "\\@imath"); +defineSymbol(math, main, mathord, "\ue237", "\\@jmath"); +defineSymbol(math, main, textord, "\u0131", "\u0131"); +defineSymbol(math, main, textord, "\u0237", "\u0237"); +defineSymbol(text, main, textord, "\u0131", "\\i", true); +defineSymbol(text, main, textord, "\u0237", "\\j", true); +defineSymbol(text, main, textord, "\u00df", "\\ss", true); +defineSymbol(text, main, textord, "\u00e6", "\\ae", true); +defineSymbol(text, main, textord, "\u0153", "\\oe", true); +defineSymbol(text, main, textord, "\u00f8", "\\o", true); +defineSymbol(text, main, textord, "\u00c6", "\\AE", true); +defineSymbol(text, main, textord, "\u0152", "\\OE", true); +defineSymbol(text, main, textord, "\u00d8", "\\O", true); +defineSymbol(text, main, accent, "\u02ca", "\\'"); // acute +defineSymbol(text, main, accent, "\u02cb", "\\`"); // grave +defineSymbol(text, main, accent, "\u02c6", "\\^"); // circumflex +defineSymbol(text, main, accent, "\u02dc", "\\~"); // tilde +defineSymbol(text, main, accent, "\u02c9", "\\="); // macron +defineSymbol(text, main, accent, "\u02d8", "\\u"); // breve +defineSymbol(text, main, accent, "\u02d9", "\\."); // dot above +defineSymbol(text, main, accent, "\u00b8", "\\c"); // cedilla +defineSymbol(text, main, accent, "\u02da", "\\r"); // ring above +defineSymbol(text, main, accent, "\u02c7", "\\v"); // caron +defineSymbol(text, main, accent, "\u00a8", '\\"'); // diaeresis +defineSymbol(text, main, accent, "\u02dd", "\\H"); // double acute +defineSymbol(text, main, accent, "\u25ef", "\\textcircled"); // \bigcirc glyph +// These ligatures are detected and created in Parser.js's `formLigatures`. +var ligatures = { + "--": true, + "---": true, + "``": true, + "''": true +}; +defineSymbol(text, main, textord, "\u2013", "--", true); +defineSymbol(text, main, textord, "\u2013", "\\textendash"); +defineSymbol(text, main, textord, "\u2014", "---", true); +defineSymbol(text, main, textord, "\u2014", "\\textemdash"); +defineSymbol(text, main, textord, "\u2018", "`", true); +defineSymbol(text, main, textord, "\u2018", "\\textquoteleft"); +defineSymbol(text, main, textord, "\u2019", "'", true); +defineSymbol(text, main, textord, "\u2019", "\\textquoteright"); +defineSymbol(text, main, textord, "\u201c", "``", true); +defineSymbol(text, main, textord, "\u201c", "\\textquotedblleft"); +defineSymbol(text, main, textord, "\u201d", "''", true); +defineSymbol(text, main, textord, "\u201d", "\\textquotedblright"); +// \degree from gensymb package +defineSymbol(math, main, textord, "\u00b0", "\\degree", true); +defineSymbol(text, main, textord, "\u00b0", "\\degree"); +// \textdegree from inputenc package +defineSymbol(text, main, textord, "\u00b0", "\\textdegree", true); +// TODO: In LaTeX, \pounds can generate a different character in text and math +// mode, but among our fonts, only Main-Regular defines this character "163". +defineSymbol(math, main, textord, "\u00a3", "\\pounds"); +defineSymbol(math, main, textord, "\u00a3", "\\mathsterling", true); +defineSymbol(text, main, textord, "\u00a3", "\\pounds"); +defineSymbol(text, main, textord, "\u00a3", "\\textsterling", true); +defineSymbol(math, ams, textord, "\u2720", "\\maltese"); +defineSymbol(text, ams, textord, "\u2720", "\\maltese"); +// There are lots of symbols which are the same, so we add them in afterwards. +// All of these are textords in math mode +var mathTextSymbols = "0123456789/@.\""; +for (var i = 0; i < mathTextSymbols.length; i++) { + var ch = mathTextSymbols.charAt(i); + defineSymbol(math, main, textord, ch, ch); +} +// All of these are textords in text mode +var textSymbols = "0123456789!@*()-=+\";:?/.,"; +for (var _i = 0; _i < textSymbols.length; _i++) { + var _ch = textSymbols.charAt(_i); + defineSymbol(text, main, textord, _ch, _ch); +} +// All of these are textords in text mode, and mathords in math mode +var letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; +for (var _i2 = 0; _i2 < letters.length; _i2++) { + var _ch2 = letters.charAt(_i2); + defineSymbol(math, main, mathord, _ch2, _ch2); + defineSymbol(text, main, textord, _ch2, _ch2); +} +// Blackboard bold and script letters in Unicode range +defineSymbol(math, ams, textord, "C", "\u2102"); // blackboard bold +defineSymbol(text, ams, textord, "C", "\u2102"); +defineSymbol(math, ams, textord, "H", "\u210D"); +defineSymbol(text, ams, textord, "H", "\u210D"); +defineSymbol(math, ams, textord, "N", "\u2115"); +defineSymbol(text, ams, textord, "N", "\u2115"); +defineSymbol(math, ams, textord, "P", "\u2119"); +defineSymbol(text, ams, textord, "P", "\u2119"); +defineSymbol(math, ams, textord, "Q", "\u211A"); +defineSymbol(text, ams, textord, "Q", "\u211A"); +defineSymbol(math, ams, textord, "R", "\u211D"); +defineSymbol(text, ams, textord, "R", "\u211D"); +defineSymbol(math, ams, textord, "Z", "\u2124"); +defineSymbol(text, ams, textord, "Z", "\u2124"); +defineSymbol(math, main, mathord, "h", "\u210E"); // italic h, Planck constant +defineSymbol(text, main, mathord, "h", "\u210E"); +// The next loop loads wide (surrogate pair) characters. +// We support some letters in the Unicode range U+1D400 to U+1D7FF, +// Mathematical Alphanumeric Symbols. +// Some editors do not deal well with wide characters. So don't write the +// string into this file. Instead, create the string from the surrogate pair. +var wideChar; +for (var _i3 = 0; _i3 < letters.length; _i3++) { + var _ch3 = letters.charAt(_i3); + // The hex numbers in the next line are a surrogate pair. + // 0xD835 is the high surrogate for all letters in the range we support. + // 0xDC00 is the low surrogate for bold A. + wideChar = String.fromCharCode(0xD835, 0xDC00 + _i3); // A-Z a-z bold + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(text, main, textord, _ch3, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDC34 + _i3); // A-Z a-z italic + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(text, main, textord, _ch3, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDC68 + _i3); // A-Z a-z bold italic + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(text, main, textord, _ch3, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDD04 + _i3); // A-Z a-z Fraktur + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(text, main, textord, _ch3, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDD6C + _i3); // A-Z a-z bold Fraktur + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(text, main, textord, _ch3, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDDA0 + _i3); // A-Z a-z sans-serif + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(text, main, textord, _ch3, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDDD4 + _i3); // A-Z a-z sans bold + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(text, main, textord, _ch3, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDE08 + _i3); // A-Z a-z sans italic + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(text, main, textord, _ch3, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDE70 + _i3); // A-Z a-z monospace + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(text, main, textord, _ch3, wideChar); + if (_i3 < 26) { + // KaTeX fonts have only capital letters for blackboard bold and script. + // See exception for k below. + wideChar = String.fromCharCode(0xD835, 0xDD38 + _i3); // A-Z double struck + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(text, main, textord, _ch3, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDC9C + _i3); // A-Z script + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(text, main, textord, _ch3, wideChar); + } + // TODO: Add bold script when it is supported by a KaTeX font. +} +// "k" is the only double struck lower case letter in the KaTeX fonts. +wideChar = String.fromCharCode(0xD835, 0xDD5C); // k double struck +defineSymbol(math, main, mathord, "k", wideChar); +defineSymbol(text, main, textord, "k", wideChar); +// Next, some wide character numerals +for (var _i4 = 0; _i4 < 10; _i4++) { + var _ch4 = _i4.toString(); + wideChar = String.fromCharCode(0xD835, 0xDFCE + _i4); // 0-9 bold + defineSymbol(math, main, mathord, _ch4, wideChar); + defineSymbol(text, main, textord, _ch4, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDFE2 + _i4); // 0-9 sans serif + defineSymbol(math, main, mathord, _ch4, wideChar); + defineSymbol(text, main, textord, _ch4, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDFEC + _i4); // 0-9 bold sans + defineSymbol(math, main, mathord, _ch4, wideChar); + defineSymbol(text, main, textord, _ch4, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDFF6 + _i4); // 0-9 monospace + defineSymbol(math, main, mathord, _ch4, wideChar); + defineSymbol(text, main, textord, _ch4, wideChar); +} +// We add these Latin-1 letters as symbols for backwards-compatibility, +// but they are not actually in the font, nor are they supported by the +// Unicode accent mechanism, so they fall back to Times font and look ugly. +// TODO(edemaine): Fix this. +var extraLatin = "\u00d0\u00de\u00fe"; +for (var _i5 = 0; _i5 < extraLatin.length; _i5++) { + var _ch5 = extraLatin.charAt(_i5); + defineSymbol(math, main, mathord, _ch5, _ch5); + defineSymbol(text, main, textord, _ch5, _ch5); +} + +/** + * This file provides support for Unicode range U+1D400 to U+1D7FF, + * Mathematical Alphanumeric Symbols. + * + * Function wideCharacterFont takes a wide character as input and returns + * the font information necessary to render it properly. + */ +var boldUpright = { + mathClass: "mathbf", + textClass: "textbf", + font: "Main-Bold" +}; +var italic = { + mathClass: "mathnormal", + textClass: "textit", + font: "Math-Italic" +}; +var boldItalic = { + mathClass: "boldsymbol", + textClass: "boldsymbol", + font: "Main-BoldItalic" +}; +var script = { + mathClass: "mathscr", + textClass: "textscr", + font: "Script-Regular" +}; +var noFont = { + mathClass: "", + textClass: "", + font: "" +}; +var fraktur = { + mathClass: "mathfrak", + textClass: "textfrak", + font: "Fraktur-Regular" +}; +var doubleStruck = { + mathClass: "mathbb", + textClass: "textbb", + font: "AMS-Regular" +}; +var boldFraktur = { + mathClass: "mathboldfrak", + textClass: "textboldfrak", + font: "Fraktur-Regular" +}; +var sansSerif = { + mathClass: "mathsf", + textClass: "textsf", + font: "SansSerif-Regular" +}; +var boldSansSerif = { + mathClass: "mathboldsf", + textClass: "textboldsf", + font: "SansSerif-Bold" +}; +var italicSansSerif = { + mathClass: "mathitsf", + textClass: "textitsf", + font: "SansSerif-Italic" +}; +var monospace = { + mathClass: "mathtt", + textClass: "texttt", + font: "Typewriter-Regular" +}; +/** + * Data below is from https://www.unicode.org/charts/PDF/U1D400.pdf + * That document sorts characters into groups by font type, say bold or italic. + * + * In the arrays below, each object consists of three properties: + * * The CSS class of that group when in math mode. + * * The CSS class of that group when in text mode. + * * The font name, so that KaTeX can get font metrics. + */ +var wideLatinLetterData = [boldUpright, boldUpright, +// A-Z, a-z +italic, italic, +// A-Z, a-z +boldItalic, boldItalic, +// A-Z, a-z +// Map fancy A-Z letters to script, not calligraphic. +// This aligns with unicode-math and math fonts (except Cambria Math). +script, noFont, +// A-Z script, a-z — no font +noFont, noFont, +// A-Z bold script, a-z bold script — no font +fraktur, fraktur, +// A-Z, a-z +doubleStruck, doubleStruck, +// A-Z double-struck, k double-struck +// Note that we are using a bold font, but font metrics for regular Fraktur. +boldFraktur, boldFraktur, +// A-Z, a-z +sansSerif, sansSerif, +// A-Z, a-z +boldSansSerif, boldSansSerif, +// A-Z, a-z +italicSansSerif, italicSansSerif, +// A-Z, a-z +noFont, noFont, +// A-Z bold italic sans, a-z bold italic sans - no font +monospace, monospace // A-Z, a-z +]; +var wideNumeralData = [boldUpright, +// 0-9 +noFont, +// 0-9 double-struck. No KaTeX font. +sansSerif, +// 0-9 +boldSansSerif, +// 0-9 +monospace // 0-9 +]; +var wideCharacterFont = wideChar => { + // IE doesn't support codePointAt(). So work with the surrogate pair. + var H = wideChar.charCodeAt(0); // high surrogate + var L = wideChar.charCodeAt(1); // low surrogate + var codePoint = (H - 0xD800) * 0x400 + (L - 0xDC00) + 0x10000; + if (0x1D400 <= codePoint && codePoint < 0x1D6A4) { + // wideLatinLetterData contains exactly 26 chars on each row. + // So we can calculate the relevant row. No traverse necessary. + var i = Math.floor((codePoint - 0x1D400) / 26); + return wideLatinLetterData[i]; + } else if (0x1D7CE <= codePoint && codePoint <= 0x1D7FF) { + // Numerals, ten per row. + var _i = Math.floor((codePoint - 0x1D7CE) / 10); + return wideNumeralData[_i]; + } else if (codePoint === 0x1D6A5 || codePoint === 0x1D6A6) { + // dotless i or j + return wideLatinLetterData[0]; + } else if (0x1D6A6 < codePoint && codePoint < 0x1D7CE) { + // Greek letters. Not supported, yet. + return noFont; + } else { + // We don't support any wide characters outside 1D400–1D7FF. + throw new ParseError("Unsupported character: " + wideChar); + } +}; + +/* eslint no-console:0 */ +/** + * Looks up the given symbol in fontMetrics, after applying any symbol + * replacements defined in symbol.js + */ +var lookupSymbol = function lookupSymbol(value, fontName, mode) { + // Replace the value with its replaced value from symbol.js + if (symbols[mode][value]) { + var replacement = symbols[mode][value].replace; + if (replacement) { + value = replacement; + } + } + return { + value, + metrics: getCharacterMetrics(value, fontName, mode) + }; +}; +/** + * Makes a symbolNode after translation via the list of symbols in symbols.js. + * Correctly pulls out metrics for the character, and optionally takes a list of + * classes to be attached to the node. + * + * TODO: make argument order closer to makeSpan + * TODO: add a separate argument for math class (e.g. `mop`, `mbin`), which + * should if present come first in `classes`. + * TODO(#953): Make `options` mandatory and always pass it in. + */ +var makeSymbol = function makeSymbol(value, fontName, mode, options, classes) { + var lookup = lookupSymbol(value, fontName, mode); + var metrics = lookup.metrics; + value = lookup.value; + var symbolNode; + if (metrics) { + var italic = metrics.italic; + if (mode === "text" || options && options.font === "mathit") { + italic = 0; + } + symbolNode = new SymbolNode(value, metrics.height, metrics.depth, italic, metrics.skew, metrics.width, classes); + } else { + // TODO(emily): Figure out a good way to only print this in development + typeof console !== "undefined" && console.warn("No character metrics " + ("for '" + value + "' in style '" + fontName + "' and mode '" + mode + "'")); + symbolNode = new SymbolNode(value, 0, 0, 0, 0, 0, classes); + } + if (options) { + symbolNode.maxFontSize = options.sizeMultiplier; + if (options.style.isTight()) { + symbolNode.classes.push("mtight"); + } + var color = options.getColor(); + if (color) { + symbolNode.style.color = color; + } + } + return symbolNode; +}; +/** + * Makes a symbol in Main-Regular or AMS-Regular. + * Used for rel, bin, open, close, inner, and punct. + */ +var mathsym = function mathsym(value, mode, options, classes) { + if (classes === void 0) { + classes = []; + } + // Decide what font to render the symbol in by its entry in the symbols + // table. + // Have a special case for when the value = \ because the \ is used as a + // textord in unsupported command errors but cannot be parsed as a regular + // text ordinal and is therefore not present as a symbol in the symbols + // table for text, as well as a special case for boldsymbol because it + // can be used for bold + and - + if (options.font === "boldsymbol" && lookupSymbol(value, "Main-Bold", mode).metrics) { + return makeSymbol(value, "Main-Bold", mode, options, classes.concat(["mathbf"])); + } else if (value === "\\" || symbols[mode][value].font === "main") { + return makeSymbol(value, "Main-Regular", mode, options, classes); + } else { + return makeSymbol(value, "AMS-Regular", mode, options, classes.concat(["amsrm"])); + } +}; +/** + * Determines which of the two font names (Main-Bold and Math-BoldItalic) and + * corresponding style tags (mathbf or boldsymbol) to use for font "boldsymbol", + * depending on the symbol. Use this function instead of fontMap for font + * "boldsymbol". + */ +var boldSymbol = function boldSymbol(value, mode, type) { + if (type !== "textord" && lookupSymbol(value, "Math-BoldItalic", mode).metrics) { + return { + fontName: "Math-BoldItalic", + fontClass: "boldsymbol" + }; + } else { + // Some glyphs do not exist in Math-BoldItalic so we need to use + // Main-Bold instead. + return { + fontName: "Main-Bold", + fontClass: "mathbf" + }; + } +}; +/** + * Makes either a mathord or textord in the correct font and color. + */ +var makeOrd = function makeOrd(group, options) { + // Spacing nodes are rendered as textord. + var type = group.type === "mathord" ? "mathord" : "textord"; + var mode = group.mode; + var text = group.text; + var classes = ["mord"]; + var { + font, + fontFamily, + fontWeight, + fontShape + } = options; + // Math mode or Old font (i.e. \rm) + var useFont = mode === "math" || mode === "text" && !!font; + var fontOrFamily = useFont ? font : fontFamily; + var wideFontName = ""; + var wideFontClass = ""; + if (text.charCodeAt(0) === 0xD835) { + var wideCharData = wideCharacterFont(text); + wideFontName = wideCharData.font; + wideFontClass = wideCharData[mode + "Class"]; + } + if (wideFontName) { + // surrogate pairs get special treatment + return makeSymbol(text, wideFontName, mode, options, classes.concat(wideFontClass)); + } else if (fontOrFamily) { + var fontName; + var fontClasses; + if (fontOrFamily === "boldsymbol") { + var fontData = boldSymbol(text, mode, type); + fontName = fontData.fontName; + fontClasses = [fontData.fontClass]; + } else if (useFont) { + fontName = fontMap[font].fontName; + fontClasses = [font]; + } else { + fontName = retrieveTextFontName(fontFamily, fontWeight, fontShape); + fontClasses = [fontFamily, fontWeight, fontShape]; + } + if (lookupSymbol(text, fontName, mode).metrics) { + return makeSymbol(text, fontName, mode, options, classes.concat(fontClasses)); + } else if (ligatures.hasOwnProperty(text) && fontName.slice(0, 10) === "Typewriter") { + // Deconstruct ligatures in monospace fonts (\texttt, \tt). + var parts = []; + for (var i = 0; i < text.length; i++) { + parts.push(makeSymbol(text[i], fontName, mode, options, classes.concat(fontClasses))); + } + return makeFragment(parts); + } + } + // Makes a symbol in the default font for mathords and textords. + if (type === "mathord") { + return makeSymbol(text, "Math-Italic", mode, options, classes.concat(["mathnormal"])); + } else if (type === "textord") { + var _font = symbols[mode][text] && symbols[mode][text].font; + if (_font === "ams") { + var _fontName = retrieveTextFontName("amsrm", fontWeight, fontShape); + return makeSymbol(text, _fontName, mode, options, classes.concat("amsrm", fontWeight, fontShape)); + } else if (_font === "main" || !_font) { + var _fontName2 = retrieveTextFontName("textrm", fontWeight, fontShape); + return makeSymbol(text, _fontName2, mode, options, classes.concat(fontWeight, fontShape)); + } else { + // fonts added by plugins + var _fontName3 = retrieveTextFontName(_font, fontWeight, fontShape); + // We add font name as a css class + return makeSymbol(text, _fontName3, mode, options, classes.concat(_fontName3, fontWeight, fontShape)); + } + } else { + throw new Error("unexpected type: " + type + " in makeOrd"); + } +}; +/** + * Returns true if subsequent symbolNodes have the same classes, skew, maxFont, + * and styles. For mathnormal text, the left node must also have zero italic + * correction so we don't lose spacing between combined glyphs. + */ +var canCombine = (prev, next) => { + if (createClass(prev.classes) !== createClass(next.classes) || prev.skew !== next.skew || prev.maxFontSize !== next.maxFontSize || prev.italic !== 0 && prev.hasClass("mathnormal")) { + return false; + } + // If prev and next both are just "mbin"s or "mord"s we don't combine them + // so that the proper spacing can be preserved. + if (prev.classes.length === 1) { + var cls = prev.classes[0]; + if (cls === "mbin" || cls === "mord") { + return false; + } + } + for (var key of Object.keys(prev.style)) { + if (prev.style[key] !== next.style[key]) { + return false; + } + } + for (var _key of Object.keys(next.style)) { + if (prev.style[_key] !== next.style[_key]) { + return false; + } + } + return true; +}; +/** + * Combine consecutive domTree.symbolNodes into a single symbolNode. + * Note: this function mutates the argument. + */ +var tryCombineChars = chars => { + for (var i = 0; i < chars.length - 1; i++) { + var prev = chars[i]; + var next = chars[i + 1]; + if (prev instanceof SymbolNode && next instanceof SymbolNode && canCombine(prev, next)) { + prev.text += next.text; + prev.height = Math.max(prev.height, next.height); + prev.depth = Math.max(prev.depth, next.depth); + // Use the last character's italic correction since we use + // it to add padding to the right of the span created from + // the combined characters. + prev.italic = next.italic; + chars.splice(i + 1, 1); + i--; + } + } + return chars; +}; +/** + * Calculate the height, depth, and maxFontSize of an element based on its + * children. + */ +var sizeElementFromChildren = function sizeElementFromChildren(elem) { + var height = 0; + var depth = 0; + var maxFontSize = 0; + for (var i = 0; i < elem.children.length; i++) { + var child = elem.children[i]; + if (child.height > height) { + height = child.height; + } + if (child.depth > depth) { + depth = child.depth; + } + if (child.maxFontSize > maxFontSize) { + maxFontSize = child.maxFontSize; + } + } + elem.height = height; + elem.depth = depth; + elem.maxFontSize = maxFontSize; +}; +/** + * Makes a span with the given list of classes, list of children, and options. + * + * TODO(#953): Ensure that `options` is always provided (currently some call + * sites don't pass it) and make the type below mandatory. + * TODO: add a separate argument for math class (e.g. `mop`, `mbin`), which + * should if present come first in `classes`. + */ +var makeSpan = function makeSpan(classes, children, options, style) { + var span = new Span(classes, children, options, style); + sizeElementFromChildren(span); + return span; +}; +// SVG one is simpler -- doesn't require height, depth, max-font setting. +// This is also a separate method for typesafety. +var makeSvgSpan = (classes, children, options, style) => new Span(classes, children, options, style); +var makeLineSpan = function makeLineSpan(className, options, thickness) { + var line = makeSpan([className], [], options); + line.height = Math.max(thickness || options.fontMetrics().defaultRuleThickness, options.minRuleThickness); + line.style.borderBottomWidth = makeEm(line.height); + line.maxFontSize = 1.0; + return line; +}; +/** + * Makes an anchor with the given href, list of classes, list of children, + * and options. + */ +var makeAnchor = function makeAnchor(href, classes, children, options) { + var anchor = new Anchor(href, classes, children, options); + sizeElementFromChildren(anchor); + return anchor; +}; +/** + * Makes a document fragment with the given list of children. + */ +var makeFragment = function makeFragment(children) { + var fragment = new DocumentFragment(children); + sizeElementFromChildren(fragment); + return fragment; +}; +/** + * Wraps group in a span if it's a document fragment, allowing to apply classes + * and styles + */ +var wrapFragment = function wrapFragment(group, options) { + if (group instanceof DocumentFragment) { + return makeSpan([], [group], options); + } + return group; +}; +// Computes the updated `children` list and the overall depth. +// +// This helper function for makeVList makes it easier to enforce type safety by +// allowing early exits (returns) in the logic. +var getVListChildrenAndDepth = function getVListChildrenAndDepth(params) { + if (params.positionType === "individualShift") { + var oldChildren = params.children; + var children = [oldChildren[0]]; + // Add in kerns to the list of params.children to get each element to be + // shifted to the correct specified shift + var _depth = -oldChildren[0].shift - oldChildren[0].elem.depth; + var currPos = _depth; + for (var i = 1; i < oldChildren.length; i++) { + var diff = -oldChildren[i].shift - currPos - oldChildren[i].elem.depth; + var size = diff - (oldChildren[i - 1].elem.height + oldChildren[i - 1].elem.depth); + currPos = currPos + diff; + children.push({ + type: "kern", + size + }); + children.push(oldChildren[i]); + } + return { + children, + depth: _depth + }; + } + var depth; + if (params.positionType === "top") { + // We always start at the bottom, so calculate the bottom by adding up + // all the sizes + var bottom = params.positionData; + for (var _i = 0; _i < params.children.length; _i++) { + var child = params.children[_i]; + bottom -= child.type === "kern" ? child.size : child.elem.height + child.elem.depth; + } + depth = bottom; + } else if (params.positionType === "bottom") { + depth = -params.positionData; + } else { + var firstChild = params.children[0]; + if (firstChild.type !== "elem") { + throw new Error('First child must have type "elem".'); + } + if (params.positionType === "shift") { + depth = -firstChild.elem.depth - params.positionData; + } else if (params.positionType === "firstBaseline") { + depth = -firstChild.elem.depth; + } else { + throw new Error("Invalid positionType " + params.positionType + "."); + } + } + return { + children: params.children, + depth + }; +}; +/** + * Makes a vertical list by stacking elements and kerns on top of each other. + * Allows for many different ways of specifying the positioning method. + * + * See VListParam documentation above. + */ +var makeVList = function makeVList(params, options) { + var { + children, + depth + } = getVListChildrenAndDepth(params); + // Create a strut that is taller than any list item. The strut is added to + // each item, where it will determine the item's baseline. Since it has + // `overflow:hidden`, the strut's top edge will sit on the item's line box's + // top edge and the strut's bottom edge will sit on the item's baseline, + // with no additional line-height spacing. This allows the item baseline to + // be positioned precisely without worrying about font ascent and + // line-height. + var pstrutSize = 0; + for (var i = 0; i < children.length; i++) { + var child = children[i]; + if (child.type === "elem") { + var elem = child.elem; + pstrutSize = Math.max(pstrutSize, elem.maxFontSize, elem.height); + } + } + pstrutSize += 2; + var pstrut = makeSpan(["pstrut"], []); + pstrut.style.height = makeEm(pstrutSize); + // Create a new list of actual children at the correct offsets + var realChildren = []; + var minPos = depth; + var maxPos = depth; + var currPos = depth; + for (var _i2 = 0; _i2 < children.length; _i2++) { + var _child = children[_i2]; + if (_child.type === "kern") { + currPos += _child.size; + } else { + var _elem = _child.elem; + var classes = _child.wrapperClasses || []; + var style = _child.wrapperStyle || {}; + var childWrap = makeSpan(classes, [pstrut, _elem], undefined, style); + childWrap.style.top = makeEm(-pstrutSize - currPos - _elem.depth); + if (_child.marginLeft) { + childWrap.style.marginLeft = _child.marginLeft; + } + if (_child.marginRight) { + childWrap.style.marginRight = _child.marginRight; + } + realChildren.push(childWrap); + currPos += _elem.height + _elem.depth; + } + minPos = Math.min(minPos, currPos); + maxPos = Math.max(maxPos, currPos); + } + // The vlist contents go in a table-cell with `vertical-align:bottom`. + // This cell's bottom edge will determine the containing table's baseline + // without overly expanding the containing line-box. + var vlist = makeSpan(["vlist"], realChildren); + vlist.style.height = makeEm(maxPos); + // A second row is used if necessary to represent the vlist's depth. + var rows; + if (minPos < 0) { + // We will define depth in an empty span with display: table-cell. + // It should render with the height that we define. But Chrome, in + // contenteditable mode only, treats that span as if it contains some + // text content. And that min-height over-rides our desired height. + // So we put another empty span inside the depth strut span. + var emptySpan = makeSpan([], []); + var depthStrut = makeSpan(["vlist"], [emptySpan]); + depthStrut.style.height = makeEm(-minPos); + // Safari wants the first row to have inline content; otherwise it + // puts the bottom of the *second* row on the baseline. + var topStrut = makeSpan(["vlist-s"], [new SymbolNode("\u200b")]); + rows = [makeSpan(["vlist-r"], [vlist, topStrut]), makeSpan(["vlist-r"], [depthStrut])]; + } else { + rows = [makeSpan(["vlist-r"], [vlist])]; + } + var vtable = makeSpan(["vlist-t"], rows); + if (rows.length === 2) { + vtable.classes.push("vlist-t2"); + } + vtable.height = maxPos; + vtable.depth = -minPos; + return vtable; +}; +// Glue is a concept from TeX which is a flexible space between elements in +// either a vertical or horizontal list. In KaTeX, at least for now, it's +// static space between elements in a horizontal layout. +var makeGlue = (measurement, options) => { + // Make an empty span for the space + var rule = makeSpan(["mspace"], [], options); + var size = calculateSize(measurement, options); + rule.style.marginRight = makeEm(size); + return rule; +}; +// Takes font options, and returns the appropriate fontLookup name +var retrieveTextFontName = (fontFamily, fontWeight, fontShape) => { + var baseFontName; + var fontStylesName; + switch (fontFamily) { + case "amsrm": + baseFontName = "AMS"; + break; + case "textrm": + baseFontName = "Main"; + break; + case "textsf": + baseFontName = "SansSerif"; + break; + case "texttt": + baseFontName = "Typewriter"; + break; + default: + baseFontName = fontFamily; + // use fonts added by a plugin + } + if (fontWeight === "textbf" && fontShape === "textit") { + fontStylesName = "BoldItalic"; + } else if (fontWeight === "textbf") { + fontStylesName = "Bold"; + } else if (fontShape === "textit") { + fontStylesName = "Italic"; + } else { + fontStylesName = "Regular"; + } + return baseFontName + "-" + fontStylesName; +}; +/** + * Maps TeX font commands to objects containing: + * - variant: string used for "mathvariant" attribute in buildMathML.js + * - fontName: the "style" parameter to fontMetrics.getCharacterMetrics + */ +// A map between tex font commands an MathML mathvariant attribute values +var fontMap = { + // styles + "mathbf": { + variant: "bold", + fontName: "Main-Bold" + }, + "mathrm": { + variant: "normal", + fontName: "Main-Regular" + }, + "textit": { + variant: "italic", + fontName: "Main-Italic" + }, + "mathit": { + variant: "italic", + fontName: "Main-Italic" + }, + "mathnormal": { + variant: "italic", + fontName: "Math-Italic" + }, + "mathsfit": { + variant: "sans-serif-italic", + fontName: "SansSerif-Italic" + }, + // "boldsymbol" is missing because they require the use of multiple fonts: + // Math-BoldItalic and Main-Bold. This is handled by a special case in + // makeOrd which ends up calling boldsymbol. + // families + "mathbb": { + variant: "double-struck", + fontName: "AMS-Regular" + }, + "mathcal": { + variant: "script", + fontName: "Caligraphic-Regular" + }, + "mathfrak": { + variant: "fraktur", + fontName: "Fraktur-Regular" + }, + "mathscr": { + variant: "script", + fontName: "Script-Regular" + }, + "mathsf": { + variant: "sans-serif", + fontName: "SansSerif-Regular" + }, + "mathtt": { + variant: "monospace", + fontName: "Typewriter-Regular" + } +}; +var svgData = { + // path, width, height + vec: ["vec", 0.471, 0.714], + // values from the font glyph + oiintSize1: ["oiintSize1", 0.957, 0.499], + // oval to overlay the integrand + oiintSize2: ["oiintSize2", 1.472, 0.659], + oiiintSize1: ["oiiintSize1", 1.304, 0.499], + oiiintSize2: ["oiiintSize2", 1.98, 0.659] +}; +var staticSvg = function staticSvg(value, options) { + // Create a span with inline SVG for the element. + var [pathName, width, height] = svgData[value]; + var path = new PathNode(pathName); + var svgNode = new SvgNode([path], { + "width": makeEm(width), + "height": makeEm(height), + // Override CSS rule `.katex svg { width: 100% }` + "style": "width:" + makeEm(width), + "viewBox": "0 0 " + 1000 * width + " " + 1000 * height, + "preserveAspectRatio": "xMinYMin" + }); + var span = makeSvgSpan(["overlay"], [svgNode], options); + span.height = height; + span.style.height = makeEm(height); + span.style.width = makeEm(width); + return span; +}; + +/** + * Describes spaces between different classes of atoms. + */ +var thinspace = { + number: 3, + unit: "mu" +}; +var mediumspace = { + number: 4, + unit: "mu" +}; +var thickspace = { + number: 5, + unit: "mu" +}; +// Spacing relationships for display and text styles +var spacings = { + mord: { + mop: thinspace, + mbin: mediumspace, + mrel: thickspace, + minner: thinspace + }, + mop: { + mord: thinspace, + mop: thinspace, + mrel: thickspace, + minner: thinspace + }, + mbin: { + mord: mediumspace, + mop: mediumspace, + mopen: mediumspace, + minner: mediumspace + }, + mrel: { + mord: thickspace, + mop: thickspace, + mopen: thickspace, + minner: thickspace + }, + mopen: {}, + mclose: { + mop: thinspace, + mbin: mediumspace, + mrel: thickspace, + minner: thinspace + }, + mpunct: { + mord: thinspace, + mop: thinspace, + mrel: thickspace, + mopen: thinspace, + mclose: thinspace, + mpunct: thinspace, + minner: thinspace + }, + minner: { + mord: thinspace, + mop: thinspace, + mbin: mediumspace, + mrel: thickspace, + mopen: thinspace, + mpunct: thinspace, + minner: thinspace + } +}; +// Spacing relationships for script and scriptscript styles +var tightSpacings = { + mord: { + mop: thinspace + }, + mop: { + mord: thinspace, + mop: thinspace + }, + mbin: {}, + mrel: {}, + mopen: {}, + mclose: { + mop: thinspace + }, + mpunct: {}, + minner: { + mop: thinspace + } +}; + +/** + * All registered functions. + * `functions.js` just exports this same dictionary again and makes it public. + * `Parser.js` requires this dictionary. + */ +var _functions = {}; +/** + * All HTML builders. Should be only used in the `define*` and the `build*ML` + * functions. + * + * Builders for different node types are stored side by side, but + * `HtmlBuilder` is contravariant in `T`, so there is no single type + * argument that makes storing/retrieving them typecheck. `any` is used + * as an existential-quantifier escape hatch. + */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any +var _htmlGroupBuilders = {}; +/** + * All MathML builders. Should be only used in the `define*` and the `build*ML` + * functions. See `_htmlGroupBuilders` above for the rationale behind `any`. + */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any +var _mathmlGroupBuilders = {}; +function defineFunction(data) { + var { + type, + names, + htmlBuilder, + mathmlBuilder + } = data; + for (var i = 0; i < names.length; ++i) { + // To avoid destructuring and rebuilding an object, + // we store the entire FunctionDefSpec object, + // even though Parser only needs the FunctionSpec fields. + _functions[names[i]] = data; + } + if (type) { + if (htmlBuilder) { + _htmlGroupBuilders[type] = htmlBuilder; + } + if (mathmlBuilder) { + _mathmlGroupBuilders[type] = mathmlBuilder; + } + } +} +/** + * Use this to register only the HTML and MathML builders for a function (e.g. + * if the function's ParseNode is generated in Parser.js rather than via a + * stand-alone handler provided to `defineFunction`). + */ +function defineFunctionBuilders(_ref) { + var { + type, + htmlBuilder, + mathmlBuilder + } = _ref; + if (htmlBuilder) { + _htmlGroupBuilders[type] = htmlBuilder; + } + if (mathmlBuilder) { + _mathmlGroupBuilders[type] = mathmlBuilder; + } +} +var normalizeArgument = function normalizeArgument(arg) { + return arg.type === "ordgroup" && arg.body.length === 1 ? arg.body[0] : arg; +}; +// Since the corresponding buildHTML/buildMathML function expects a +// list of elements, we normalize for different kinds of arguments +var ordargument = function ordargument(arg) { + return arg.type === "ordgroup" ? arg.body : [arg]; +}; + +/** + * This file does the main work of building a domTree structure from a parse + * tree. The entry point is the `buildHTML` function, which takes a parse tree. + * Then, the buildExpression, buildGroup, and various groupBuilders functions + * are called, to produce a final HTML tree. + */ +// Binary atoms (first class `mbin`) change into ordinary atoms (`mord`) +// depending on their surroundings. See TeXbook pg. 442-446, Rules 5 and 6, +// and the text before Rule 19. +var binLeftCanceller = new Set(["leftmost", "mbin", "mopen", "mrel", "mop", "mpunct"]); +var binRightCanceller = new Set(["rightmost", "mrel", "mclose", "mpunct"]); +var styleMap$1 = { + "display": Style$1.DISPLAY, + "text": Style$1.TEXT, + "script": Style$1.SCRIPT, + "scriptscript": Style$1.SCRIPTSCRIPT +}; +var DomEnum = { + mord: "mord", + mop: "mop", + mbin: "mbin", + mrel: "mrel", + mopen: "mopen", + mclose: "mclose", + mpunct: "mpunct", + minner: "minner" +}; +/** + * Take a list of nodes, build them in order, and return a list of the built + * nodes. documentFragments are flattened into their contents, so the + * returned list contains no fragments. `isRealGroup` is true if `expression` + * is a real group (no atoms will be added on either side), as opposed to + * a partial group (e.g. one created by \color). `surrounding` is an array + * consisting type of nodes that will be added to the left and right. + */ +var buildExpression$1 = function buildExpression(expression, options, isRealGroup, surrounding) { + if (surrounding === void 0) { + surrounding = [null, null]; + } + // Parse expressions into `groups`. + var groups = []; + for (var i = 0; i < expression.length; i++) { + var output = buildGroup$1(expression[i], options); + if (output instanceof DocumentFragment) { + var children = output.children; + groups.push(...children); + } else { + groups.push(output); + } + } + // Combine consecutive domTree.symbolNodes into a single symbolNode. + tryCombineChars(groups); + // If `expression` is a partial group, let the parent handle spacings + // to avoid processing groups multiple times. + if (!isRealGroup) { + return groups; + } + var glueOptions = options; + if (expression.length === 1) { + var node = expression[0]; + if (node.type === "sizing") { + glueOptions = options.havingSize(node.size); + } else if (node.type === "styling") { + glueOptions = options.havingStyle(styleMap$1[node.style]); + } + } + // Dummy spans for determining spacings between surrounding atoms. + // If `expression` has no atoms on the left or right, class "leftmost" + // or "rightmost", respectively, is used to indicate it. + var dummyPrev = makeSpan([surrounding[0] || "leftmost"], [], options); + var dummyNext = makeSpan([surrounding[1] || "rightmost"], [], options); + // TODO: These code assumes that a node's math class is the first element + // of its `classes` array. A later cleanup should ensure this, for + // instance by changing the signature of `makeSpan`. + // Before determining what spaces to insert, perform bin cancellation. + // Binary operators change to ordinary symbols in some contexts. + var isRoot = isRealGroup === "root"; + _traverseNonSpaceNodes(groups, (node, prev) => { + var prevType = prev.classes[0]; + var type = node.classes[0]; + if (prevType === "mbin" && binRightCanceller.has(type)) { + prev.classes[0] = "mord"; + } else if (type === "mbin" && binLeftCanceller.has(prevType)) { + node.classes[0] = "mord"; + } + }, { + node: dummyPrev + }, dummyNext, isRoot); + _traverseNonSpaceNodes(groups, (node, prev) => { + var _tightSpacings$prevTy, _spacings$prevType; + var prevType = getTypeOfDomTree(prev); + var type = getTypeOfDomTree(node); + // 'mtight' indicates that the node is script or scriptscript style. + var space = prevType && type ? node.hasClass("mtight") ? (_tightSpacings$prevTy = tightSpacings[prevType]) == null ? void 0 : _tightSpacings$prevTy[type] : (_spacings$prevType = spacings[prevType]) == null ? void 0 : _spacings$prevType[type] : null; + if (space) { + // Insert glue (spacing) after the `prev`. + return makeGlue(space, glueOptions); + } + }, { + node: dummyPrev + }, dummyNext, isRoot); + return groups; +}; +// Depth-first traverse non-space `nodes`, calling `callback` with the current and +// previous node as arguments, optionally returning a node to insert after the +// previous node. `prev` is an object with the previous node and `insertAfter` +// function to insert after it. `next` is a node that will be added to the right. +// Used for bin cancellation and inserting spacings. +var _traverseNonSpaceNodes = function traverseNonSpaceNodes(nodes, callback, prev, next, isRoot) { + if (next) { + // temporarily append the right node, if exists + nodes.push(next); + } + var i = 0; + for (; i < nodes.length; i++) { + var node = nodes[i]; + var partialGroup = checkPartialGroup(node); + if (partialGroup) { + // Recursive DFS + // TODO(ts): partialGroup.children is ReadonlyArray but this + // function mutates the array (insertAfter splices into it). + _traverseNonSpaceNodes(partialGroup.children, callback, prev, null, isRoot); + continue; + } + // Ignore explicit spaces (e.g., \;, \,) when determining what implicit + // spacing should go between atoms of different classes + var nonspace = !node.hasClass("mspace"); + if (nonspace) { + var result = callback(node, prev.node); + if (result) { + if (prev.insertAfter) { + prev.insertAfter(result); + } else { + // insert at front + nodes.unshift(result); + i++; + } + } + } + if (nonspace) { + prev.node = node; + } else if (isRoot && node.hasClass("newline")) { + prev.node = makeSpan(["leftmost"]); // treat like beginning of line + } + prev.insertAfter = (index => n => { + nodes.splice(index + 1, 0, n); + i++; + })(i); + } + if (next) { + nodes.pop(); + } +}; +// Check if given node is a partial group, i.e., does not affect spacing around. +var checkPartialGroup = function checkPartialGroup(node) { + if (node instanceof DocumentFragment || node instanceof Anchor || node instanceof Span && node.hasClass("enclosing")) { + return node; + } + return null; +}; +// Return the outermost node of a domTree. +var _getOutermostNode = function getOutermostNode(node, side) { + var partialGroup = checkPartialGroup(node); + if (partialGroup) { + var children = partialGroup.children; + if (children.length) { + if (side === "right") { + return _getOutermostNode(children[children.length - 1], "right"); + } else if (side === "left") { + return _getOutermostNode(children[0], "left"); + } + } + } + return node; +}; +// Return math atom class (mclass) of a domTree. +// If `side` is given, it will get the type of the outermost node at given side. +var getTypeOfDomTree = function getTypeOfDomTree(node, side) { + if (!node) { + return null; + } + if (side) { + node = _getOutermostNode(node, side); + } + // This makes a lot of assumptions as to where the type of atom + // appears. We should do a better job of enforcing this. + var className = node.classes[0]; + return DomEnum[className] || null; +}; +var makeNullDelimiter = function makeNullDelimiter(options, classes) { + var moreClasses = ["nulldelimiter"].concat(options.baseSizingClasses()); + return makeSpan(classes.concat(moreClasses)); +}; +/** + * buildGroup is the function that takes a group and calls the correct groupType + * function for it. It also handles the interaction of size and style changes + * between parents and children. + */ +var buildGroup$1 = function buildGroup(group, options, baseOptions) { + if (!group) { + return makeSpan(); + } + if (_htmlGroupBuilders[group.type]) { + // TODO(ts): groupBuilders is Record>; + // a type-safe registry would need a mapped type keyed by NodeType. + var groupNode = _htmlGroupBuilders[group.type](group, options); + // If the size changed between the parent and the current group, account + // for that size difference. + if (baseOptions && options.size !== baseOptions.size) { + groupNode = makeSpan(options.sizingClasses(baseOptions), [groupNode], options); + var multiplier = options.sizeMultiplier / baseOptions.sizeMultiplier; + groupNode.height *= multiplier; + groupNode.depth *= multiplier; + } + return groupNode; + } else { + throw new ParseError("Got group of unknown type: '" + group.type + "'"); + } +}; +/** + * Combine an array of HTML DOM nodes (e.g., the output of `buildExpression`) + * into an unbreakable HTML node of class .base, with proper struts to + * guarantee correct vertical extent. `buildHTML` calls this repeatedly to + * make up the entire expression as a sequence of unbreakable units. + */ +function buildHTMLUnbreakable(children, options) { + // Compute height and depth of this chunk. + var body = makeSpan(["base"], children, options); + // Add strut, which ensures that the top of the HTML element falls at + // the height of the expression, and the bottom of the HTML element + // falls at the depth of the expression. + var strut = makeSpan(["strut"]); + strut.style.height = makeEm(body.height + body.depth); + if (body.depth) { + strut.style.verticalAlign = makeEm(-body.depth); + } + body.children.unshift(strut); + return body; +} +/** + * Take an entire parse tree, and build it into an appropriate set of HTML + * nodes. + */ +function buildHTML(tree, options) { + // Strip off outer tag wrapper for processing below. + var tag = null; + if (tree.length === 1 && tree[0].type === "tag") { + tag = tree[0].tag; + tree = tree[0].body; + } + // Build the expression contained in the tree + var expression = buildExpression$1(tree, options, "root"); + var eqnNum; + if (expression.length === 2 && expression[1].hasClass("tag")) { + // An environment with automatic equation numbers, e.g. {gather}. + eqnNum = expression.pop(); + } + var children = []; + // Create one base node for each chunk between potential line breaks. + // The TeXBook [p.173] says "A formula will be broken only after a + // relation symbol like $=$ or $<$ or $\rightarrow$, or after a binary + // operation symbol like $+$ or $-$ or $\times$, where the relation or + // binary operation is on the ``outer level'' of the formula (i.e., not + // enclosed in {...} and not part of an \over construction)." + var parts = []; + for (var i = 0; i < expression.length; i++) { + parts.push(expression[i]); + if (expression[i].hasClass("mbin") || expression[i].hasClass("mrel") || expression[i].hasClass("allowbreak")) { + // Put any post-operator glue on same line as operator. + // Watch for \nobreak along the way, and stop at \newline. + var nobreak = false; + while (i < expression.length - 1 && expression[i + 1].hasClass("mspace") && !expression[i + 1].hasClass("newline")) { + i++; + parts.push(expression[i]); + if (expression[i].hasClass("nobreak")) { + nobreak = true; + } + } + // Don't allow break if \nobreak among the post-operator glue. + if (!nobreak) { + children.push(buildHTMLUnbreakable(parts, options)); + parts = []; + } + } else if (expression[i].hasClass("newline")) { + // Write the line except the newline + parts.pop(); + if (parts.length > 0) { + children.push(buildHTMLUnbreakable(parts, options)); + parts = []; + } + // Put the newline at the top level + children.push(expression[i]); + } + } + if (parts.length > 0) { + children.push(buildHTMLUnbreakable(parts, options)); + } + // Now, if there was a tag, build it too and append it as a final child. + var tagChild; + if (tag) { + tagChild = buildHTMLUnbreakable(buildExpression$1(tag, options, true), options); + tagChild.classes = ["tag"]; + children.push(tagChild); + } else if (eqnNum) { + children.push(eqnNum); + } + var htmlNode = makeSpan(["katex-html"], children); + htmlNode.setAttribute("aria-hidden", "true"); + // Adjust the strut of the tag to be the maximum height of all children + // (the height of the enclosing htmlNode) for proper vertical alignment. + if (tagChild) { + var strut = tagChild.children[0]; + strut.style.height = makeEm(htmlNode.height + htmlNode.depth); + if (htmlNode.depth) { + strut.style.verticalAlign = makeEm(-htmlNode.depth); + } + } + return htmlNode; +} + +/** + * These objects store data about MathML nodes. This is the MathML equivalent + * of the types in domTree.js. Since MathML handles its own rendering, and + * since we're mainly using MathML to improve accessibility, we don't manage + * any of the styling state that the plain DOM nodes do. + * + * The `toNode` and `toMarkup` functions work similarly to how they do in + * domTree.js, creating namespaced DOM nodes and HTML text markup respectively. + */ +function newDocumentFragment(children) { + return new DocumentFragment(children); +} +/** + * This node represents a general purpose MathML node of any type. The + * constructor requires the type of node to create (for example, `"mo"` or + * `"mspace"`, corresponding to `` and `` tags). + */ +class MathNode { + constructor(type, children, classes) { + this.type = void 0; + this.attributes = void 0; + this.children = void 0; + this.classes = void 0; + this.type = type; + this.attributes = {}; + this.children = children || []; + this.classes = classes || []; + } + /** + * Sets an attribute on a MathML node. MathML depends on attributes to convey a + * semantic content, so this is used heavily. + */ + setAttribute(name, value) { + this.attributes[name] = value; + } + /** + * Gets an attribute on a MathML node. + */ + getAttribute(name) { + return this.attributes[name]; + } + /** + * Converts the math node into a MathML-namespaced DOM element. + */ + toNode() { + var node = document.createElementNS("http://www.w3.org/1998/Math/MathML", this.type); + for (var attr in this.attributes) { + if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) { + node.setAttribute(attr, this.attributes[attr]); + } + } + if (this.classes.length > 0) { + node.className = createClass(this.classes); + } + for (var i = 0; i < this.children.length; i++) { + // Combine multiple TextNodes into one TextNode, to prevent + // screen readers from reading each as a separate word [#3995] + if (this.children[i] instanceof TextNode && this.children[i + 1] instanceof TextNode) { + var text = this.children[i].toText() + this.children[++i].toText(); + while (this.children[i + 1] instanceof TextNode) { + text += this.children[++i].toText(); + } + node.appendChild(new TextNode(text).toNode()); + } else { + node.appendChild(this.children[i].toNode()); + } + } + return node; + } + /** + * Converts the math node into an HTML markup string. + */ + toMarkup() { + var markup = "<" + this.type; + // Add the attributes + for (var attr in this.attributes) { + if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) { + markup += " " + attr + "=\""; + markup += escape(this.attributes[attr]); + markup += "\""; + } + } + if (this.classes.length > 0) { + markup += " class =\"" + escape(createClass(this.classes)) + "\""; + } + markup += ">"; + for (var i = 0; i < this.children.length; i++) { + markup += this.children[i].toMarkup(); + } + markup += ""; + return markup; + } + /** + * Converts the math node into a string, similar to innerText, but escaped. + */ + toText() { + return this.children.map(child => child.toText()).join(""); + } +} +/** + * This node represents a piece of text. + */ +class TextNode { + constructor(text) { + this.text = void 0; + this.text = text; + } + /** + * Converts the text node into a DOM text node. + */ + toNode() { + return document.createTextNode(this.text); + } + /** + * Converts the text node into escaped HTML markup + * (representing the text itself). + */ + toMarkup() { + return escape(this.toText()); + } + /** + * Converts the text node into a string + * (representing the text itself). + */ + toText() { + return this.text; + } +} +/** + * This node represents a space, but may render as or as text, + * depending on the width. + */ +class SpaceNode { + /** + * Create a Space node with width given in CSS ems. + */ + constructor(width) { + this.width = void 0; + this.character = void 0; + this.width = width; + // See https://www.w3.org/TR/2000/WD-MathML2-20000328/chapter6.html + // for a table of space-like characters. We use Unicode + // representations instead of &LongNames; as it's not clear how to + // make the latter via document.createTextNode. + if (width >= 0.05555 && width <= 0.05556) { + this.character = "\u200a"; //   + } else if (width >= 0.1666 && width <= 0.1667) { + this.character = "\u2009"; //   + } else if (width >= 0.2222 && width <= 0.2223) { + this.character = "\u2005"; //   + } else if (width >= 0.2777 && width <= 0.2778) { + this.character = "\u2005\u200a"; //    + } else if (width >= -0.05556 && width <= -0.05555) { + this.character = "\u200a\u2063"; // ​ + } else if (width >= -0.1667 && width <= -0.1666) { + this.character = "\u2009\u2063"; // ​ + } else if (width >= -0.2223 && width <= -0.2222) { + this.character = "\u205f\u2063"; // ​ + } else if (width >= -0.2778 && width <= -0.2777) { + this.character = "\u2005\u2063"; // ​ + } else { + this.character = null; + } + } + /** + * Converts the math node into a MathML-namespaced DOM element. + */ + toNode() { + if (this.character) { + return document.createTextNode(this.character); + } else { + var node = document.createElementNS("http://www.w3.org/1998/Math/MathML", "mspace"); + node.setAttribute("width", makeEm(this.width)); + return node; + } + } + /** + * Converts the math node into an HTML markup string. + */ + toMarkup() { + if (this.character) { + return "" + this.character + ""; + } else { + return ""; + } + } + /** + * Converts the math node into a string, similar to innerText. + */ + toText() { + if (this.character) { + return this.character; + } else { + return " "; + } + } +} + +/** + * This file converts a parse tree into a corresponding MathML tree. The main + * entry point is the `buildMathML` function, which takes a parse tree from the + * parser. + */ +var noVariantSymbols = new Set(["\\imath", "\\jmath"]); +var rowLikeTypes = new Set(["mrow", "mtable"]); +/** + * Takes a symbol and converts it into a MathML text node after performing + * optional replacement from symbols.js. + */ +var makeText = function makeText(text, mode, options) { + if (symbols[mode][text] && symbols[mode][text].replace && text.charCodeAt(0) !== 0xD835 && !(ligatures.hasOwnProperty(text) && options && (options.fontFamily && options.fontFamily.slice(4, 6) === "tt" || options.font && options.font.slice(4, 6) === "tt"))) { + text = symbols[mode][text].replace; + } + return new TextNode(text); +}; +/** + * Wrap the given array of nodes in an node if needed, i.e., + * unless the array has length 1. Always returns a single node. + */ +var makeRow = function makeRow(body) { + if (body.length === 1) { + return body[0]; + } else { + return new MathNode("mrow", body); + } +}; +var mathFontVariants = { + mathit: "italic", + boldsymbol: group => group.type === "textord" ? "bold" : "bold-italic", + mathbf: "bold", + mathbb: "double-struck", + mathsfit: "sans-serif-italic", + mathfrak: "fraktur", + mathscr: "script", + mathcal: "script", + mathsf: "sans-serif", + mathtt: "monospace" +}; +/** + * Returns the math variant as a string or null if none is required. + */ +var getVariant = (group, options) => { + // Handle \text... font specifiers as best we can. + // MathML has a limited list of allowable mathvariant specifiers; see + // https://www.w3.org/TR/MathML3/chapter3.html#presm.commatt + if (group.mode === "text") { + if (options.fontFamily === "texttt") { + return "monospace"; + } else if (options.fontFamily === "textsf") { + if (options.fontShape === "textit" && options.fontWeight === "textbf") { + return "sans-serif-bold-italic"; + } else if (options.fontShape === "textit") { + return "sans-serif-italic"; + } else if (options.fontWeight === "textbf") { + return "bold-sans-serif"; + } else { + return "sans-serif"; + } + } else if (options.fontShape === "textit" && options.fontWeight === "textbf") { + return "bold-italic"; + } else if (options.fontShape === "textit") { + return "italic"; + } else if (options.fontWeight === "textbf") { + return "bold"; + } + } + var font = options.font; + if (!font || font === "mathnormal") { + return null; + } + var mode = group.mode; + var mathVariant = mathFontVariants[font]; + if (mathVariant) { + return typeof mathVariant === "function" ? mathVariant(group) : mathVariant; + } + var text = group.text; + if (noVariantSymbols.has(text)) { + return null; + } + if (symbols[mode][text]) { + var replacement = symbols[mode][text].replace; + if (replacement) { + text = replacement; + } + } + var fontName = fontMap[font].fontName; + if (getCharacterMetrics(text, fontName, mode)) { + return fontMap[font].variant; + } + return null; +}; +/** + * Check for . which is how a dot renders in MathML, + * or , + * which is how a braced comma {,} renders in MathML + */ +function isNumberPunctuation(group) { + if (!group) { + return false; + } + if (group.type === 'mi' && group.children.length === 1) { + var child = group.children[0]; + return child instanceof TextNode && child.text === '.'; + } else if (group.type === 'mo' && group.children.length === 1 && group.getAttribute('separator') === 'true' && group.getAttribute('lspace') === '0em' && group.getAttribute('rspace') === '0em') { + var _child = group.children[0]; + return _child instanceof TextNode && _child.text === ','; + } else { + return false; + } +} +/** + * Takes a list of nodes, builds them, and returns a list of the generated + * MathML nodes. Also combine consecutive outputs into a single + * tag. + */ +var buildExpression = function buildExpression(expression, options, isOrdgroup) { + if (expression.length === 1) { + var group = buildGroup(expression[0], options); + if (isOrdgroup && group instanceof MathNode && group.type === "mo") { + // When TeX writers want to suppress spacing on an operator, + // they often put the operator by itself inside braces. + group.setAttribute("lspace", "0em"); + group.setAttribute("rspace", "0em"); + } + return [group]; + } + var groups = []; + var lastGroup; + for (var i = 0; i < expression.length; i++) { + var _group = buildGroup(expression[i], options); + if (_group instanceof MathNode && lastGroup instanceof MathNode) { + // Concatenate adjacent s + if (_group.type === 'mtext' && lastGroup.type === 'mtext' && _group.getAttribute('mathvariant') === lastGroup.getAttribute('mathvariant')) { + lastGroup.children.push(..._group.children); + continue; + // Concatenate adjacent s + } else if (_group.type === 'mn' && lastGroup.type === 'mn') { + lastGroup.children.push(..._group.children); + continue; + // Concatenate ... followed by . + } else if (isNumberPunctuation(_group) && lastGroup.type === 'mn') { + lastGroup.children.push(..._group.children); + continue; + // Concatenate . followed by ... + } else if (_group.type === 'mn' && isNumberPunctuation(lastGroup)) { + _group.children = [...lastGroup.children, ..._group.children]; + groups.pop(); + // Put preceding ... or . inside base of + // ...base......exponent... (or ) + } else if ((_group.type === 'msup' || _group.type === 'msub') && _group.children.length >= 1 && (lastGroup.type === 'mn' || isNumberPunctuation(lastGroup))) { + var base = _group.children[0]; + if (base instanceof MathNode && base.type === 'mn') { + base.children = [...lastGroup.children, ...base.children]; + groups.pop(); + } + // \not + } else if (lastGroup.type === 'mi' && lastGroup.children.length === 1) { + var lastChild = lastGroup.children[0]; + if (lastChild instanceof TextNode && lastChild.text === '\u0338' && (_group.type === 'mo' || _group.type === 'mi' || _group.type === 'mn')) { + var child = _group.children[0]; + if (child instanceof TextNode && child.text.length > 0) { + // Overlay with combining character long solidus + child.text = child.text.slice(0, 1) + "\u0338" + child.text.slice(1); + groups.pop(); + } + } + } + } + groups.push(_group); + lastGroup = _group; + } + return groups; +}; +/** + * Equivalent to buildExpression, but wraps the elements in an + * if there's more than one. Returns a single node instead of an array. + */ +var buildExpressionRow = function buildExpressionRow(expression, options, isOrdgroup) { + return makeRow(buildExpression(expression, options, isOrdgroup)); +}; +/** + * Takes a group from the parser and calls the appropriate groupBuilders function + * on it to produce a MathML node. + */ +var buildGroup = function buildGroup(group, options) { + if (!group) { + return new MathNode("mrow"); + } + if (_mathmlGroupBuilders[group.type]) { + // TODO(ts): MathMLBuilder returns MathDomNode but all concrete + // builders return MathNode. Widening the return type here would + // require updating all callers that assume MathNode. + return _mathmlGroupBuilders[group.type](group, options); + } else { + throw new ParseError("Got group of unknown type: '" + group.type + "'"); + } +}; +/** + * Takes a full parse tree and settings and builds a MathML representation of + * it. In particular, we put the elements from building the parse tree into a + * tag so we can also include that TeX source as an annotation. + * + * Note that we actually return a domTree element with a `` inside it so + * we can do appropriate styling. + */ +function buildMathML(tree, texExpression, options, isDisplayMode, forMathmlOnly) { + var expression = buildExpression(tree, options); + // TODO: Make a pass thru the MathML similar to buildHTML.traverseNonSpaceNodes + // and add spacing nodes. This is necessary only adjacent to math operators + // like \sin or \lim or to subsup elements that contain math operators. + // MathML takes care of the other spacing issues. + // Wrap up the expression in an mrow so it is presented in the semantics + // tag correctly, unless it's a single or . + var wrapper; + if (expression.length === 1 && expression[0] instanceof MathNode && rowLikeTypes.has(expression[0].type)) { + wrapper = expression[0]; + } else { + wrapper = new MathNode("mrow", expression); + } + // Build a TeX annotation of the source + var annotation = new MathNode("annotation", [new TextNode(texExpression)]); + annotation.setAttribute("encoding", "application/x-tex"); + var semantics = new MathNode("semantics", [wrapper, annotation]); + var math = new MathNode("math", [semantics]); + math.setAttribute("xmlns", "http://www.w3.org/1998/Math/MathML"); + if (isDisplayMode) { + math.setAttribute("display", "block"); + } + // You can't style nodes, so we wrap the node in a span. + // NOTE: The span class is not typed to have nodes as children, and + // we don't want to make the children type more generic since the children + // of span are expected to have more fields in `buildHtml` contexts. + // The MathNode implements VirtualNode (toNode/toMarkup) which is all that + // Span needs from its children for rendering. + // TODO(ts): Span's child type is HtmlDomNode, but MathNode only implements + // VirtualNode. The double-cast acknowledges this architectural limitation. + var wrapperClass = forMathmlOnly ? "katex" : "katex-mathml"; + return makeSpan([wrapperClass], [math]); +} + +/** + * This file contains information about the options that the Parser carries + * around with it while parsing. Data is held in an `Options` object, and when + * recursing, a new `Options` object can be created with the `.with*` and + * `.reset` functions. + */ +var sizeStyleMap = [ +// Each element contains [textsize, scriptsize, scriptscriptsize]. +// The size mappings are taken from TeX with \normalsize=10pt. +[1, 1, 1], +// size1: [5, 5, 5] \tiny +[2, 1, 1], +// size2: [6, 5, 5] +[3, 1, 1], +// size3: [7, 5, 5] \scriptsize +[4, 2, 1], +// size4: [8, 6, 5] \footnotesize +[5, 2, 1], +// size5: [9, 6, 5] \small +[6, 3, 1], +// size6: [10, 7, 5] \normalsize +[7, 4, 2], +// size7: [12, 8, 6] \large +[8, 6, 3], +// size8: [14.4, 10, 7] \Large +[9, 7, 6], +// size9: [17.28, 12, 10] \LARGE +[10, 8, 7], +// size10: [20.74, 14.4, 12] \huge +[11, 10, 9] // size11: [24.88, 20.74, 17.28] \HUGE +]; +var sizeMultipliers = [ +// fontMetrics.js:getGlobalMetrics also uses size indexes, so if +// you change size indexes, change that function. +0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.2, 1.44, 1.728, 2.074, 2.488]; +var sizeAtStyle = function sizeAtStyle(size, style) { + return style.size < 2 ? size : sizeStyleMap[size - 1][style.size - 1]; +}; +/** + * This is the main options class. It contains the current style, size, color, + * and font. + * + * Options objects should not be modified. To create a new Options with + * different properties, call a `.having*` method. + */ +class Options { + constructor(data) { + this.style = void 0; + this.color = void 0; + this.size = void 0; + this.textSize = void 0; + this.phantom = void 0; + // A font family applies to a group of fonts (i.e. SansSerif), while a font + // represents a specific font (i.e. SansSerif Bold). + // See: https://tex.stackexchange.com/questions/22350/difference-between-textrm-and-mathrm + this.font = void 0; + this.fontFamily = void 0; + this.fontWeight = void 0; + this.fontShape = void 0; + this.sizeMultiplier = void 0; + this.maxSize = void 0; + this.minRuleThickness = void 0; + this._fontMetrics = void 0; + this.style = data.style; + this.color = data.color; + this.size = data.size || Options.BASESIZE; + this.textSize = data.textSize || this.size; + this.phantom = !!data.phantom; + this.font = data.font || ""; + this.fontFamily = data.fontFamily || ""; + this.fontWeight = data.fontWeight || ""; + this.fontShape = data.fontShape || ""; + this.sizeMultiplier = sizeMultipliers[this.size - 1]; + this.maxSize = data.maxSize; + this.minRuleThickness = data.minRuleThickness; + this._fontMetrics = undefined; + } + /** + * Returns a new options object with the same properties as "this". Properties + * from "extension" will be copied to the new options object. + */ + extend(extension) { + var data = { + style: this.style, + size: this.size, + textSize: this.textSize, + color: this.color, + phantom: this.phantom, + font: this.font, + fontFamily: this.fontFamily, + fontWeight: this.fontWeight, + fontShape: this.fontShape, + maxSize: this.maxSize, + minRuleThickness: this.minRuleThickness + }; + Object.assign(data, extension); + return new Options(data); + } + /** + * Return an options object with the given style. If `this.style === style`, + * returns `this`. + */ + havingStyle(style) { + if (this.style === style) { + return this; + } else { + return this.extend({ + style: style, + size: sizeAtStyle(this.textSize, style) + }); + } + } + /** + * Return an options object with a cramped version of the current style. If + * the current style is cramped, returns `this`. + */ + havingCrampedStyle() { + return this.havingStyle(this.style.cramp()); + } + /** + * Return an options object with the given size and in at least `\textstyle`. + * Returns `this` if appropriate. + */ + havingSize(size) { + if (this.size === size && this.textSize === size) { + return this; + } else { + return this.extend({ + style: this.style.text(), + size: size, + textSize: size, + sizeMultiplier: sizeMultipliers[size - 1] + }); + } + } + /** + * Like `this.havingSize(BASESIZE).havingStyle(style)`. If `style` is omitted, + * changes to at least `\textstyle`. + */ + havingBaseStyle(style) { + style = style || this.style.text(); + var wantSize = sizeAtStyle(Options.BASESIZE, style); + if (this.size === wantSize && this.textSize === Options.BASESIZE && this.style === style) { + return this; + } else { + return this.extend({ + style: style, + size: wantSize + }); + } + } + /** + * Remove the effect of sizing changes such as \Huge. + * Keep the effect of the current style, such as \scriptstyle. + */ + havingBaseSizing() { + var size; + switch (this.style.id) { + case 4: + case 5: + size = 3; // normalsize in scriptstyle + break; + case 6: + case 7: + size = 1; // normalsize in scriptscriptstyle + break; + default: + size = 6; + // normalsize in textstyle or displaystyle + } + return this.extend({ + style: this.style.text(), + size: size + }); + } + /** + * Create a new options object with the given color. + */ + withColor(color) { + return this.extend({ + color: color + }); + } + /** + * Create a new options object with "phantom" set to true. + */ + withPhantom() { + return this.extend({ + phantom: true + }); + } + /** + * Creates a new options object with the given math font or old text font. + * @type {[type]} + */ + withFont(font) { + return this.extend({ + font + }); + } + /** + * Create a new options objects with the given fontFamily. + */ + withTextFontFamily(fontFamily) { + return this.extend({ + fontFamily, + font: "" + }); + } + /** + * Creates a new options object with the given font weight + */ + withTextFontWeight(fontWeight) { + return this.extend({ + fontWeight, + font: "" + }); + } + /** + * Creates a new options object with the given font weight + */ + withTextFontShape(fontShape) { + return this.extend({ + fontShape, + font: "" + }); + } + /** + * Return the CSS sizing classes required to switch from enclosing options + * `oldOptions` to `this`. Returns an array of classes. + */ + sizingClasses(oldOptions) { + if (oldOptions.size !== this.size) { + return ["sizing", "reset-size" + oldOptions.size, "size" + this.size]; + } else { + return []; + } + } + /** + * Return the CSS sizing classes required to switch to the base size. Like + * `this.havingSize(BASESIZE).sizingClasses(this)`. + */ + baseSizingClasses() { + if (this.size !== Options.BASESIZE) { + return ["sizing", "reset-size" + this.size, "size" + Options.BASESIZE]; + } else { + return []; + } + } + /** + * Return the font metrics for this size. + */ + fontMetrics() { + if (!this._fontMetrics) { + this._fontMetrics = getGlobalMetrics(this.size); + } + return this._fontMetrics; + } + /** + * Gets the CSS color of the current options object + */ + getColor() { + if (this.phantom) { + return "transparent"; + } else { + return this.color; + } + } +} +/** + * The base size index. + */ +Options.BASESIZE = 6; + +var optionsFromSettings = function optionsFromSettings(settings) { + return new Options({ + style: settings.displayMode ? Style$1.DISPLAY : Style$1.TEXT, + maxSize: settings.maxSize, + minRuleThickness: settings.minRuleThickness + }); +}; +var displayWrap = function displayWrap(node, settings) { + if (settings.displayMode) { + var classes = ["katex-display"]; + if (settings.leqno) { + classes.push("leqno"); + } + if (settings.fleqn) { + classes.push("fleqn"); + } + node = makeSpan(classes, [node]); + } + return node; +}; +var buildTree = function buildTree(tree, expression, settings) { + var options = optionsFromSettings(settings); + var katexNode; + if (settings.output === "mathml") { + return buildMathML(tree, expression, options, settings.displayMode, true); + } else if (settings.output === "html") { + var htmlNode = buildHTML(tree, options); + katexNode = makeSpan(["katex"], [htmlNode]); + } else { + var mathMLNode = buildMathML(tree, expression, options, settings.displayMode, false); + var _htmlNode = buildHTML(tree, options); + katexNode = makeSpan(["katex"], [mathMLNode, _htmlNode]); + } + return displayWrap(katexNode, settings); +}; +var buildHTMLTree = function buildHTMLTree(tree, expression, settings) { + var options = optionsFromSettings(settings); + var htmlNode = buildHTML(tree, options); + var katexNode = makeSpan(["katex"], [htmlNode]); + return displayWrap(katexNode, settings); +}; + +/** + * This file provides support to buildMathML.js and buildHTML.js + * for stretchy wide elements rendered from SVG files + * and other CSS trickery. + */ +var stretchyCodePoint = { + widehat: "^", + widecheck: "ˇ", + widetilde: "~", + utilde: "~", + overleftarrow: "\u2190", + underleftarrow: "\u2190", + xleftarrow: "\u2190", + overrightarrow: "\u2192", + underrightarrow: "\u2192", + xrightarrow: "\u2192", + underbrace: "\u23df", + overbrace: "\u23de", + underbracket: "\u23b5", + overbracket: "\u23b4", + overgroup: "\u23e0", + undergroup: "\u23e1", + overleftrightarrow: "\u2194", + underleftrightarrow: "\u2194", + xleftrightarrow: "\u2194", + Overrightarrow: "\u21d2", + xRightarrow: "\u21d2", + overleftharpoon: "\u21bc", + xleftharpoonup: "\u21bc", + overrightharpoon: "\u21c0", + xrightharpoonup: "\u21c0", + xLeftarrow: "\u21d0", + xLeftrightarrow: "\u21d4", + xhookleftarrow: "\u21a9", + xhookrightarrow: "\u21aa", + xmapsto: "\u21a6", + xrightharpoondown: "\u21c1", + xleftharpoondown: "\u21bd", + xrightleftharpoons: "\u21cc", + xleftrightharpoons: "\u21cb", + xtwoheadleftarrow: "\u219e", + xtwoheadrightarrow: "\u21a0", + xlongequal: "=", + xtofrom: "\u21c4", + xrightleftarrows: "\u21c4", + xrightequilibrium: "\u21cc", + // Not a perfect match. + xleftequilibrium: "\u21cb", + // None better available. + "\\cdrightarrow": "\u2192", + "\\cdleftarrow": "\u2190", + "\\cdlongequal": "=" +}; +var stretchyMathML = function stretchyMathML(label) { + var node = new MathNode("mo", [new TextNode(stretchyCodePoint[label.replace(/^\\/, '')])]); + node.setAttribute("stretchy", "true"); + return node; +}; +var katexImagesData = { + // path(s), minWidth, height, align + overrightarrow: [["rightarrow"], 0.888, 522, "xMaxYMin"], + overleftarrow: [["leftarrow"], 0.888, 522, "xMinYMin"], + underrightarrow: [["rightarrow"], 0.888, 522, "xMaxYMin"], + underleftarrow: [["leftarrow"], 0.888, 522, "xMinYMin"], + xrightarrow: [["rightarrow"], 1.469, 522, "xMaxYMin"], + "\\cdrightarrow": [["rightarrow"], 3.0, 522, "xMaxYMin"], + // CD minwwidth2.5pc + xleftarrow: [["leftarrow"], 1.469, 522, "xMinYMin"], + "\\cdleftarrow": [["leftarrow"], 3.0, 522, "xMinYMin"], + Overrightarrow: [["doublerightarrow"], 0.888, 560, "xMaxYMin"], + xRightarrow: [["doublerightarrow"], 1.526, 560, "xMaxYMin"], + xLeftarrow: [["doubleleftarrow"], 1.526, 560, "xMinYMin"], + overleftharpoon: [["leftharpoon"], 0.888, 522, "xMinYMin"], + xleftharpoonup: [["leftharpoon"], 0.888, 522, "xMinYMin"], + xleftharpoondown: [["leftharpoondown"], 0.888, 522, "xMinYMin"], + overrightharpoon: [["rightharpoon"], 0.888, 522, "xMaxYMin"], + xrightharpoonup: [["rightharpoon"], 0.888, 522, "xMaxYMin"], + xrightharpoondown: [["rightharpoondown"], 0.888, 522, "xMaxYMin"], + xlongequal: [["longequal"], 0.888, 334, "xMinYMin"], + "\\cdlongequal": [["longequal"], 3.0, 334, "xMinYMin"], + xtwoheadleftarrow: [["twoheadleftarrow"], 0.888, 334, "xMinYMin"], + xtwoheadrightarrow: [["twoheadrightarrow"], 0.888, 334, "xMaxYMin"], + overleftrightarrow: [["leftarrow", "rightarrow"], 0.888, 522], + overbrace: [["leftbrace", "midbrace", "rightbrace"], 1.6, 548], + underbrace: [["leftbraceunder", "midbraceunder", "rightbraceunder"], 1.6, 548], + underleftrightarrow: [["leftarrow", "rightarrow"], 0.888, 522], + xleftrightarrow: [["leftarrow", "rightarrow"], 1.75, 522], + xLeftrightarrow: [["doubleleftarrow", "doublerightarrow"], 1.75, 560], + xrightleftharpoons: [["leftharpoondownplus", "rightharpoonplus"], 1.75, 716], + xleftrightharpoons: [["leftharpoonplus", "rightharpoondownplus"], 1.75, 716], + xhookleftarrow: [["leftarrow", "righthook"], 1.08, 522], + xhookrightarrow: [["lefthook", "rightarrow"], 1.08, 522], + overlinesegment: [["leftlinesegment", "rightlinesegment"], 0.888, 522], + underlinesegment: [["leftlinesegment", "rightlinesegment"], 0.888, 522], + overbracket: [["leftbracketover", "rightbracketover"], 1.6, 440], + underbracket: [["leftbracketunder", "rightbracketunder"], 1.6, 410], + overgroup: [["leftgroup", "rightgroup"], 0.888, 342], + undergroup: [["leftgroupunder", "rightgroupunder"], 0.888, 342], + xmapsto: [["leftmapsto", "rightarrow"], 1.5, 522], + xtofrom: [["leftToFrom", "rightToFrom"], 1.75, 528], + // The next three arrows are from the mhchem package. + // In mhchem.sty, min-length is 2.0em. But these arrows might appear in the + // document as \xrightarrow or \xrightleftharpoons. Those have + // min-length = 1.75em, so we set min-length on these next three to match. + xrightleftarrows: [["baraboveleftarrow", "rightarrowabovebar"], 1.75, 901], + xrightequilibrium: [["baraboveshortleftharpoon", "rightharpoonaboveshortbar"], 1.75, 716], + xleftequilibrium: [["shortbaraboveleftharpoon", "shortrightharpoonabovebar"], 1.75, 716] +}; +var wideAccentLabels = new Set(["widehat", "widecheck", "widetilde", "utilde"]); +var stretchySvg = function stretchySvg(group, options) { + // Create a span with inline SVG for the element. + function buildSvgSpan_() { + var viewBoxWidth = 400000; // default + var label = group.label.slice(1); + if (wideAccentLabels.has(label) && 'base' in group) { + // There are four SVG images available for each function. + // Choose a taller image when there are more characters. + var numChars = group.base.type === "ordgroup" ? group.base.body.length : 1; + var viewBoxHeight; + var pathName; + var _height; + if (numChars > 5) { + if (label === "widehat" || label === "widecheck") { + viewBoxHeight = 420; + viewBoxWidth = 2364; + _height = 0.42; + pathName = label + "4"; + } else { + viewBoxHeight = 312; + viewBoxWidth = 2340; + _height = 0.34; + pathName = "tilde4"; + } + } else { + var imgIndex = [1, 1, 2, 2, 3, 3][numChars]; + if (label === "widehat" || label === "widecheck") { + viewBoxWidth = [0, 1062, 2364, 2364, 2364][imgIndex]; + viewBoxHeight = [0, 239, 300, 360, 420][imgIndex]; + _height = [0, 0.24, 0.3, 0.3, 0.36, 0.42][imgIndex]; + pathName = label + imgIndex; + } else { + viewBoxWidth = [0, 600, 1033, 2339, 2340][imgIndex]; + viewBoxHeight = [0, 260, 286, 306, 312][imgIndex]; + _height = [0, 0.26, 0.286, 0.3, 0.306, 0.34][imgIndex]; + pathName = "tilde" + imgIndex; + } + } + var path = new PathNode(pathName); + var svgNode = new SvgNode([path], { + "width": "100%", + "height": makeEm(_height), + "viewBox": "0 0 " + viewBoxWidth + " " + viewBoxHeight, + "preserveAspectRatio": "none" + }); + return { + span: makeSvgSpan([], [svgNode], options), + minWidth: 0, + height: _height + }; + } else { + var spans = []; + var data = katexImagesData[label]; + if (!data) { + throw new Error("No SVG data for \"" + label + "\"."); + } + var [paths, _minWidth, _viewBoxHeight] = data; + var _height2 = _viewBoxHeight / 1000; + var numSvgChildren = paths.length; + var widthClasses; + var aligns; + if (numSvgChildren === 1) { + if (data.length !== 4) { + throw new Error("Expected 4-tuple for single-path SVG data \"" + label + "\"."); + } + widthClasses = ["hide-tail"]; + aligns = [data[3]]; + } else if (numSvgChildren === 2) { + widthClasses = ["halfarrow-left", "halfarrow-right"]; + aligns = ["xMinYMin", "xMaxYMin"]; + } else if (numSvgChildren === 3) { + widthClasses = ["brace-left", "brace-center", "brace-right"]; + aligns = ["xMinYMin", "xMidYMin", "xMaxYMin"]; + } else { + throw new Error("Correct katexImagesData or update code here to support\n " + numSvgChildren + " children."); + } + for (var i = 0; i < numSvgChildren; i++) { + var _path = new PathNode(paths[i]); + var _svgNode = new SvgNode([_path], { + "width": "400em", + "height": makeEm(_height2), + "viewBox": "0 0 " + viewBoxWidth + " " + _viewBoxHeight, + "preserveAspectRatio": aligns[i] + " slice" + }); + var _span = makeSvgSpan([widthClasses[i]], [_svgNode], options); + if (numSvgChildren === 1) { + return { + span: _span, + minWidth: _minWidth, + height: _height2 + }; + } else { + _span.style.height = makeEm(_height2); + spans.push(_span); + } + } + return { + span: makeSpan(["stretchy"], spans, options), + minWidth: _minWidth, + height: _height2 + }; + } + } // buildSvgSpan_() + var { + span, + minWidth, + height + } = buildSvgSpan_(); + // Note that we are returning span.depth = 0. + // Any adjustments relative to the baseline must be done in buildHTML. + span.height = height; + span.style.height = makeEm(height); + if (minWidth > 0) { + span.style.minWidth = makeEm(minWidth); + } + return span; +}; +var stretchyEnclose = function stretchyEnclose(inner, label, topPad, bottomPad, options) { + // Return an image span for \cancel, \bcancel, \xcancel, \fbox, or \angl + var img; + var totalHeight = inner.height + inner.depth + topPad + bottomPad; + if (/fbox|color|angl/.test(label)) { + img = makeSpan(["stretchy", label], [], options); + if (label === "fbox") { + var color = options.color && options.getColor(); + if (color) { + img.style.borderColor = color; + } + } + } else { + // \cancel, \bcancel, or \xcancel + // Since \cancel's SVG is inline and it omits the viewBox attribute, + // its stroke-width will not vary with span area. + var lines = []; + if (/^[bx]cancel$/.test(label)) { + lines.push(new LineNode({ + "x1": "0", + "y1": "0", + "x2": "100%", + "y2": "100%", + "stroke-width": "0.046em" + })); + } + if (/^x?cancel$/.test(label)) { + lines.push(new LineNode({ + "x1": "0", + "y1": "100%", + "x2": "100%", + "y2": "0", + "stroke-width": "0.046em" + })); + } + var svgNode = new SvgNode(lines, { + "width": "100%", + "height": makeEm(totalHeight) + }); + img = makeSvgSpan([], [svgNode], options); + } + img.height = totalHeight; + img.style.height = makeEm(totalHeight); + return img; +}; + +/** + * Small module for atom-group constants and type guard. Kept separate from + * `symbols.ts` so that consumers (notably `contrib/render-a11y-string`) can + * pull in `isAtom` without dragging in the ~870-line symbol tables. + */ +// Some of these have a "-token" suffix since these are also used as `ParseNode` +// types for raw text tokens, and we want to avoid conflicts with higher-level +// `ParseNode` types. These `ParseNode`s are constructed within `Parser` by +// looking up the `symbols` map. +var ATOMS = { + "bin": 1, + "close": 1, + "inner": 1, + "open": 1, + "punct": 1, + "rel": 1 +}; +var NON_ATOMS = { + "accent-token": 1, + "mathord": 1, + "op-token": 1, + "spacing": 1, + "textord": 1 +}; +function isAtom(value) { + return value in ATOMS; +} + +/** + * Asserts that the node is of the given type and returns it with stricter + * typing. Throws if the node's type does not match. + */ +function assertNodeType(node, type) { + if (!node || node.type !== type) { + throw new Error("Expected node of type " + type + ", but got " + (node ? "node of type " + node.type : String(node))); + } + return node; +} +/** + * Returns the node more strictly typed iff it is of the given type. Otherwise, + * returns null. + */ +function assertSymbolNodeType(node) { + var typedNode = checkSymbolNodeType(node); + if (!typedNode) { + throw new Error("Expected node of symbol group type, but got " + (node ? "node of type " + node.type : String(node))); + } + return typedNode; +} +/** + * Returns the node more strictly typed if it is of the given type. Otherwise, + * returns null. + */ +function checkSymbolNodeType(node) { + if (node && (node.type === "atom" || NON_ATOMS.hasOwnProperty(node.type))) { + return node; + } + return null; +} + +var getBaseSymbol = group => { + if (group instanceof SymbolNode) { + return group; + } + if (hasHtmlDomChildren(group) && group.children.length === 1) { + return getBaseSymbol(group.children[0]); + } +}; +// NOTE: Unlike most `htmlBuilder`s, this one handles not only "accent", but +// also "supsub" since an accent can affect super/subscripting. +var htmlBuilder$a = (grp, options) => { + // Accents are handled in the TeXbook pg. 443, rule 12. + var base; + var group; + var supSubGroup; + if (grp && grp.type === "supsub") { + // If our base is a character box, and we have superscripts and + // subscripts, the supsub will defer to us. In particular, we want + // to attach the superscripts and subscripts to the inner body (so + // that the position of the superscripts and subscripts won't be + // affected by the height of the accent). We accomplish this by + // sticking the base of the accent into the base of the supsub, and + // rendering that, while keeping track of where the accent is. + // The real accent group is the base of the supsub group + group = assertNodeType(grp.base, "accent"); + // The character box is the base of the accent group + base = group.base; + // Stick the character box into the base of the supsub group + grp.base = base; + // Rerender the supsub group with its new base, and store that + // result. + supSubGroup = assertSpan(buildGroup$1(grp, options)); + // reset original base + grp.base = group; + } else { + group = assertNodeType(grp, "accent"); + base = group.base; + } + // Build the base group + var body = buildGroup$1(base, options.havingCrampedStyle()); + // Does the accent need to shift for the skew of a character? + var mustShift = group.isShifty && isCharacterBox(base); + // Calculate the skew of the accent. This is based on the line "If the + // nucleus is not a single character, let s = 0; otherwise set s to the + // kern amount for the nucleus followed by the \skewchar of its font." + // Note that our skew metrics are just the kern between each character + // and the skewchar. + var skew = 0; + if (mustShift) { + var _getBaseSymbol$skew, _getBaseSymbol; + // Read the skew from the rendered base symbol. + // This preserves font metrics from font wrappers like \mathbb. + skew = (_getBaseSymbol$skew = (_getBaseSymbol = getBaseSymbol(body)) == null ? void 0 : _getBaseSymbol.skew) != null ? _getBaseSymbol$skew : 0; + } + var accentBelow = group.label === "\\c"; + // calculate the amount of space between the body and the accent + var clearance = accentBelow ? body.height + body.depth : Math.min(body.height, options.fontMetrics().xHeight); + // Build the accent + var accentBody; + if (!group.isStretchy) { + var accent; + var width; + if (group.label === "\\vec") { + // Before version 0.9, \vec used the combining font glyph U+20D7. + // But browsers, especially Safari, are not consistent in how they + // render combining characters when not preceded by a character. + // So now we use an SVG. + // If Safari reforms, we should consider reverting to the glyph. + accent = staticSvg("vec", options); + width = svgData.vec[1]; + } else { + accent = makeOrd({ + type: "textord", + mode: group.mode, + text: group.label + }, options); + accent = assertSymbolDomNode(accent); + // Remove the italic correction of the accent, because it only serves to + // shift the accent over to a place we don't want. + accent.italic = 0; + width = accent.width; + if (accentBelow) { + clearance += accent.depth; + } + } + accentBody = makeSpan(["accent-body"], [accent]); + // "Full" accents expand the width of the resulting symbol to be + // at least the width of the accent, and overlap directly onto the + // character without any vertical offset. + var accentFull = group.label === "\\textcircled"; + if (accentFull) { + accentBody.classes.push('accent-full'); + clearance = body.height; + } + // Shift the accent over by the skew. + var left = skew; + // CSS defines `.katex .accent .accent-body:not(.accent-full) { width: 0 }` + // so that the accent doesn't contribute to the bounding box. + // We need to shift the character by its width (effectively half + // its width) to compensate. + if (!accentFull) { + left -= width / 2; + } + accentBody.style.left = makeEm(left); + // \textcircled uses the \bigcirc glyph, so it needs some + // vertical adjustment to match LaTeX. + if (group.label === "\\textcircled") { + accentBody.style.top = ".2em"; + } + accentBody = makeVList({ + positionType: "firstBaseline", + children: [{ + type: "elem", + elem: body + }, { + type: "kern", + size: -clearance + }, { + type: "elem", + elem: accentBody + }] + }); + } else { + accentBody = stretchySvg(group, options); + accentBody = makeVList({ + positionType: "firstBaseline", + children: [{ + type: "elem", + elem: body + }, { + type: "elem", + elem: accentBody, + wrapperClasses: ["svg-align"], + wrapperStyle: skew > 0 ? { + width: "calc(100% - " + makeEm(2 * skew) + ")", + marginLeft: makeEm(2 * skew) + } : undefined + }] + }); + } + var accentWrap = makeSpan(["mord", "accent"], [accentBody], options); + if (supSubGroup) { + // Here, we replace the "base" child of the supsub with our newly + // generated accent. + supSubGroup.children[0] = accentWrap; + // Since we don't rerun the height calculation after replacing the + // accent, we manually recalculate height. + supSubGroup.height = Math.max(accentWrap.height, supSubGroup.height); + // Accents should always be ords, even when their innards are not. + supSubGroup.classes[0] = "mord"; + return supSubGroup; + } else { + return accentWrap; + } +}; +var mathmlBuilder$9 = (group, options) => { + var accentNode = group.isStretchy ? stretchyMathML(group.label) : new MathNode("mo", [makeText(group.label, group.mode)]); + var node = new MathNode("mover", [buildGroup(group.base, options), accentNode]); + node.setAttribute("accent", "true"); + return node; +}; +var NON_STRETCHY_ACCENT_REGEX = new RegExp(["\\acute", "\\grave", "\\ddot", "\\tilde", "\\bar", "\\breve", "\\check", "\\hat", "\\vec", "\\dot", "\\mathring"].map(accent => "\\" + accent).join("|")); +// Accents +defineFunction({ + type: "accent", + names: ["\\acute", "\\grave", "\\ddot", "\\tilde", "\\bar", "\\breve", "\\check", "\\hat", "\\vec", "\\dot", "\\mathring", "\\widecheck", "\\widehat", "\\widetilde", "\\overrightarrow", "\\overleftarrow", "\\Overrightarrow", "\\overleftrightarrow", "\\overgroup", "\\overlinesegment", "\\overleftharpoon", "\\overrightharpoon"], + numArgs: 1, + handler: (context, args) => { + var base = normalizeArgument(args[0]); + var isStretchy = !NON_STRETCHY_ACCENT_REGEX.test(context.funcName); + var isShifty = !isStretchy || context.funcName === "\\widehat" || context.funcName === "\\widetilde" || context.funcName === "\\widecheck"; + return { + type: "accent", + mode: context.parser.mode, + label: context.funcName, + isStretchy: isStretchy, + isShifty: isShifty, + base: base + }; + }, + htmlBuilder: htmlBuilder$a, + mathmlBuilder: mathmlBuilder$9 +}); +// Text-mode accents +defineFunction({ + type: "accent", + names: ["\\'", "\\`", "\\^", "\\~", "\\=", "\\u", "\\.", '\\"', "\\c", "\\r", "\\H", "\\v", "\\textcircled"], + numArgs: 1, + allowedInText: true, + allowedInMath: true, + // unless in strict mode + argTypes: ["primitive"], + handler: (context, args) => { + var base = args[0]; + var mode = context.parser.mode; + if (mode === "math") { + context.parser.settings.reportNonstrict("mathVsTextAccents", "LaTeX's accent " + context.funcName + " works only in text mode"); + mode = "text"; + } + return { + type: "accent", + mode: mode, + label: context.funcName, + isStretchy: false, + isShifty: true, + base: base + }; + } +}); + +// Horizontal overlap functions +defineFunction({ + type: "accentUnder", + names: ["\\underleftarrow", "\\underrightarrow", "\\underleftrightarrow", "\\undergroup", "\\underlinesegment", "\\utilde"], + numArgs: 1, + handler: (_ref, args) => { + var { + parser, + funcName + } = _ref; + var base = args[0]; + return { + type: "accentUnder", + mode: parser.mode, + label: funcName, + base: base + }; + }, + htmlBuilder: (group, options) => { + // Treat under accents much like underlines. + var innerGroup = buildGroup$1(group.base, options); + var accentBody = stretchySvg(group, options); + var kern = group.label === "\\utilde" ? 0.12 : 0; + // Generate the vlist, with the appropriate kerns + var vlist = makeVList({ + positionType: "top", + positionData: innerGroup.height, + children: [{ + type: "elem", + elem: accentBody, + wrapperClasses: ["svg-align"] + }, { + type: "kern", + size: kern + }, { + type: "elem", + elem: innerGroup + }] + }); + return makeSpan(["mord", "accentunder"], [vlist], options); + }, + mathmlBuilder: (group, options) => { + var accentNode = stretchyMathML(group.label); + var node = new MathNode("munder", [buildGroup(group.base, options), accentNode]); + node.setAttribute("accentunder", "true"); + return node; + } +}); + +// Helper function +var paddedNode = group => { + var node = new MathNode("mpadded", group ? [group] : []); + node.setAttribute("width", "+0.6em"); + node.setAttribute("lspace", "0.3em"); + return node; +}; +// Stretchy arrows with an optional argument +defineFunction({ + type: "xArrow", + names: ["\\xleftarrow", "\\xrightarrow", "\\xLeftarrow", "\\xRightarrow", "\\xleftrightarrow", "\\xLeftrightarrow", "\\xhookleftarrow", "\\xhookrightarrow", "\\xmapsto", "\\xrightharpoondown", "\\xrightharpoonup", "\\xleftharpoondown", "\\xleftharpoonup", "\\xrightleftharpoons", "\\xleftrightharpoons", "\\xlongequal", "\\xtwoheadrightarrow", "\\xtwoheadleftarrow", "\\xtofrom", + // The next 3 functions are here to support the mhchem extension. + // Direct use of these functions is discouraged and may break someday. + "\\xrightleftarrows", "\\xrightequilibrium", "\\xleftequilibrium", + // The next 3 functions are here only to support the {CD} environment. + "\\\\cdrightarrow", "\\\\cdleftarrow", "\\\\cdlongequal"], + numArgs: 1, + numOptionalArgs: 1, + handler(_ref, args, optArgs) { + var { + parser, + funcName + } = _ref; + return { + type: "xArrow", + mode: parser.mode, + label: funcName, + body: args[0], + below: optArgs[0] + }; + }, + htmlBuilder(group, options) { + var style = options.style; + // Build the argument groups in the appropriate style. + // Ref: amsmath.dtx: \hbox{$\scriptstyle\mkern#3mu{#6}\mkern#4mu$}% + // Some groups can return document fragments. Handle those by wrapping + // them in a span. + var newOptions = options.havingStyle(style.sup()); + var upperGroup = wrapFragment(buildGroup$1(group.body, newOptions, options), options); + var arrowPrefix = group.label.slice(0, 2) === "\\x" ? "x" : "cd"; + upperGroup.classes.push(arrowPrefix + "-arrow-pad"); + var lowerGroup; + if (group.below) { + // Build the lower group + newOptions = options.havingStyle(style.sub()); + lowerGroup = wrapFragment(buildGroup$1(group.below, newOptions, options), options); + lowerGroup.classes.push(arrowPrefix + "-arrow-pad"); + } + var arrowBody = stretchySvg(group, options); + // Re shift: Note that stretchySvg returned arrowBody.depth = 0. + // The point we want on the math axis is at 0.5 * arrowBody.height. + var arrowShift = -options.fontMetrics().axisHeight + 0.5 * arrowBody.height; + // 2 mu kern. Ref: amsmath.dtx: #7\if0#2\else\mkern#2mu\fi + var upperShift = -options.fontMetrics().axisHeight - 0.5 * arrowBody.height - 0.111; // 0.111 em = 2 mu + if (upperGroup.depth > 0.25 || group.label === "\\xleftequilibrium") { + upperShift -= upperGroup.depth; // shift up if depth encroaches + } + // Generate the vlist + var vlist; + if (lowerGroup) { + var lowerShift = -options.fontMetrics().axisHeight + lowerGroup.height + 0.5 * arrowBody.height + 0.111; + vlist = makeVList({ + positionType: "individualShift", + children: [{ + type: "elem", + elem: upperGroup, + shift: upperShift + }, { + type: "elem", + elem: arrowBody, + shift: arrowShift, + wrapperClasses: ["svg-align"] + }, { + type: "elem", + elem: lowerGroup, + shift: lowerShift + }] + }); + } else { + vlist = makeVList({ + positionType: "individualShift", + children: [{ + type: "elem", + elem: upperGroup, + shift: upperShift + }, { + type: "elem", + elem: arrowBody, + shift: arrowShift, + wrapperClasses: ["svg-align"] + }] + }); + } + return makeSpan(["mrel", "x-arrow"], [vlist], options); + }, + mathmlBuilder(group, options) { + var arrowNode = stretchyMathML(group.label); + arrowNode.setAttribute("minsize", group.label.charAt(0) === "x" ? "1.75em" : "3.0em"); + var node; + if (group.body) { + var upperNode = paddedNode(buildGroup(group.body, options)); + if (group.below) { + var lowerNode = paddedNode(buildGroup(group.below, options)); + node = new MathNode("munderover", [arrowNode, lowerNode, upperNode]); + } else { + node = new MathNode("mover", [arrowNode, upperNode]); + } + } else if (group.below) { + var _lowerNode = paddedNode(buildGroup(group.below, options)); + node = new MathNode("munder", [arrowNode, _lowerNode]); + } else { + // This should never happen. + // Parser.js throws an error if there is no argument. + node = paddedNode(); + node = new MathNode("mover", [arrowNode, node]); + } + return node; + } +}); + +function htmlBuilder$9(group, options) { + var elements = buildExpression$1(group.body, options, true); + return makeSpan([group.mclass], elements, options); +} +function mathmlBuilder$8(group, options) { + var node; + var inner = buildExpression(group.body, options); + if (group.mclass === "minner") { + node = new MathNode("mpadded", inner); + } else if (group.mclass === "mord") { + if (group.isCharacterBox) { + node = inner[0]; + node.type = "mi"; + } else { + node = new MathNode("mi", inner); + } + } else { + if (group.isCharacterBox) { + node = inner[0]; + node.type = "mo"; + } else { + node = new MathNode("mo", inner); + } + // Set spacing based on what is the most likely adjacent atom type. + // See TeXbook p170. + if (group.mclass === "mbin") { + node.attributes.lspace = "0.22em"; // medium space + node.attributes.rspace = "0.22em"; + } else if (group.mclass === "mpunct") { + node.attributes.lspace = "0em"; + node.attributes.rspace = "0.17em"; // thinspace + } else if (group.mclass === "mopen" || group.mclass === "mclose") { + node.attributes.lspace = "0em"; + node.attributes.rspace = "0em"; + } + // MathML default space is 5/18 em, so needs no action. + // Ref: https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mo + } + return node; +} +// Math class commands except \mathop +defineFunction({ + type: "mclass", + names: ["\\mathord", "\\mathbin", "\\mathrel", "\\mathopen", "\\mathclose", "\\mathpunct", "\\mathinner"], + numArgs: 1, + primitive: true, + handler(_ref, args) { + var { + parser, + funcName + } = _ref; + var body = args[0]; + return { + type: "mclass", + mode: parser.mode, + mclass: "m" + funcName.slice(5), + body: ordargument(body), + isCharacterBox: isCharacterBox(body) + }; + }, + htmlBuilder: htmlBuilder$9, + mathmlBuilder: mathmlBuilder$8 +}); +var binrelClass = arg => { + // \binrel@ spacing varies with (bin|rel|ord) of the atom in the argument. + // (by rendering separately and with {}s before and after, and measuring + // the change in spacing). We'll do roughly the same by detecting the + // atom type directly. + var atom = arg.type === "ordgroup" && arg.body.length ? arg.body[0] : arg; + if (atom.type === "atom" && (atom.family === "bin" || atom.family === "rel")) { + return "m" + atom.family; + } else { + return "mord"; + } +}; +// \@binrel{x}{y} renders like y but as mbin/mrel/mord if x is mbin/mrel/mord. +// This is equivalent to \binrel@{x}\binrel@@{y} in AMSTeX. +defineFunction({ + type: "mclass", + names: ["\\@binrel"], + numArgs: 2, + handler(_ref2, args) { + var { + parser + } = _ref2; + return { + type: "mclass", + mode: parser.mode, + mclass: binrelClass(args[0]), + body: ordargument(args[1]), + isCharacterBox: isCharacterBox(args[1]) + }; + } +}); +// Build a relation or stacked op by placing one symbol on top of another +defineFunction({ + type: "mclass", + names: ["\\stackrel", "\\overset", "\\underset"], + numArgs: 2, + handler(_ref3, args) { + var { + parser, + funcName + } = _ref3; + var baseArg = args[1]; + var shiftedArg = args[0]; + var mclass; + if (funcName !== "\\stackrel") { + // LaTeX applies \binrel spacing to \overset and \underset. + mclass = binrelClass(baseArg); + } else { + mclass = "mrel"; // for \stackrel + } + var baseOp = { + type: "op", + mode: baseArg.mode, + limits: true, + alwaysHandleSupSub: true, + parentIsSupSub: false, + symbol: false, + suppressBaseShift: funcName !== "\\stackrel", + body: ordargument(baseArg) + }; + var supsub = funcName === "\\underset" ? { + type: "supsub", + mode: shiftedArg.mode, + base: baseOp, + sub: shiftedArg + } : { + type: "supsub", + mode: shiftedArg.mode, + base: baseOp, + sup: shiftedArg + }; + return { + type: "mclass", + mode: parser.mode, + mclass, + body: [supsub], + isCharacterBox: isCharacterBox(supsub) + }; + } +}); + +// \pmb is a simulation of bold font. +// The version of \pmb in ambsy.sty works by typesetting three copies +// with small offsets. We use CSS text-shadow. +// It's a hack. Not as good as a real bold font. Better than nothing. +defineFunction({ + type: "pmb", + names: ["\\pmb"], + numArgs: 1, + allowedInText: true, + handler(_ref, args) { + var { + parser + } = _ref; + return { + type: "pmb", + mode: parser.mode, + mclass: binrelClass(args[0]), + body: ordargument(args[0]) + }; + }, + htmlBuilder(group, options) { + var elements = buildExpression$1(group.body, options, true); + var node = makeSpan([group.mclass], elements, options); + node.style.textShadow = "0.02em 0.01em 0.04px"; + return node; + }, + mathmlBuilder(group, style) { + var inner = buildExpression(group.body, style); + // Wrap with an element. + var node = new MathNode("mstyle", inner); + node.setAttribute("style", "text-shadow: 0.02em 0.01em 0.04px"); + return node; + } +}); + +var cdArrowFunctionName = { + ">": "\\\\cdrightarrow", + "<": "\\\\cdleftarrow", + "=": "\\\\cdlongequal", + "A": "\\uparrow", + "V": "\\downarrow", + "|": "\\Vert", + ".": "no arrow" +}; +var newCell = () => { + // Create an empty cell, to be filled below with parse nodes. + // The parseTree from this module must be constructed like the + // one created by parseArray(), so an empty CD cell must + // be a ParseNode<"styling">. And CD is always displaystyle. + return { + type: "styling", + body: [], + mode: "math", + style: "display", + resetFont: true + }; +}; +var isStartOfArrow = node => { + return node.type === "textord" && node.text === "@"; +}; +var isLabelEnd = (node, endChar) => { + return (node.type === "mathord" || node.type === "atom") && node.text === endChar; +}; +function cdArrow(arrowChar, labels, parser) { + // Return a parse tree of an arrow and its labels. + // This acts in a way similar to a macro expansion. + var funcName = cdArrowFunctionName[arrowChar]; + switch (funcName) { + case "\\\\cdrightarrow": + case "\\\\cdleftarrow": + return parser.callFunction(funcName, [labels[0]], [labels[1]]); + case "\\uparrow": + case "\\downarrow": + { + var leftLabel = parser.callFunction("\\\\cdleft", [labels[0]], []); + var bareArrow = { + type: "atom", + text: funcName, + mode: "math", + family: "rel" + }; + var sizedArrow = parser.callFunction("\\Big", [bareArrow], []); + var rightLabel = parser.callFunction("\\\\cdright", [labels[1]], []); + var arrowGroup = { + type: "ordgroup", + mode: "math", + body: [leftLabel, sizedArrow, rightLabel] + }; + return parser.callFunction("\\\\cdparent", [arrowGroup], []); + } + case "\\\\cdlongequal": + return parser.callFunction("\\\\cdlongequal", [], []); + case "\\Vert": + { + var arrow = { + type: "textord", + text: "\\Vert", + mode: "math" + }; + return parser.callFunction("\\Big", [arrow], []); + } + default: + return { + type: "textord", + text: " ", + mode: "math" + }; + } +} +function parseCD(parser) { + // Get the array's parse nodes with \\ temporarily mapped to \cr. + var parsedRows = []; + parser.gullet.beginGroup(); + parser.gullet.macros.set("\\cr", "\\\\\\relax"); + parser.gullet.beginGroup(); + while (true) { + // Get the parse nodes for the next row. + parsedRows.push(parser.parseExpression(false, "\\\\")); + parser.gullet.endGroup(); + parser.gullet.beginGroup(); + var next = parser.fetch().text; + if (next === "&" || next === "\\\\") { + parser.consume(); + } else if (next === "\\end") { + if (parsedRows[parsedRows.length - 1].length === 0) { + parsedRows.pop(); // final row ended in \\ + } + break; + } else { + throw new ParseError("Expected \\\\ or \\cr or \\end", parser.nextToken); + } + } + var row = []; + var body = [row]; + // Loop thru the parse nodes. Collect them into cells and arrows. + for (var i = 0; i < parsedRows.length; i++) { + // Start a new row. + var rowNodes = parsedRows[i]; + // Create the first cell. + var cell = newCell(); + for (var j = 0; j < rowNodes.length; j++) { + if (!isStartOfArrow(rowNodes[j])) { + // If a parseNode is not an arrow, it goes into a cell. + cell.body.push(rowNodes[j]); + } else { + // Parse node j is an "@", the start of an arrow. + // Before starting on the arrow, push the cell into `row`. + row.push(cell); + // Now collect parseNodes into an arrow. + // The character after "@" defines the arrow type. + j += 1; + var arrowChar = assertSymbolNodeType(rowNodes[j]).text; + // Create two empty label nodes. We may or may not use them. + var labels = new Array(2); + labels[0] = { + type: "ordgroup", + mode: "math", + body: [] + }; + labels[1] = { + type: "ordgroup", + mode: "math", + body: [] + }; + // Process the arrow. + if ("=|.".includes(arrowChar)) ; else if ("<>AV".includes(arrowChar)) { + // Four arrows, `@>>>`, `@<<<`, `@AAA`, and `@VVV`, each take + // two optional labels. E.g. the right-point arrow syntax is + // really: @>{optional label}>{optional label}> + // Collect parseNodes into labels. + for (var labelNum = 0; labelNum < 2; labelNum++) { + var inLabel = true; + for (var k = j + 1; k < rowNodes.length; k++) { + if (isLabelEnd(rowNodes[k], arrowChar)) { + inLabel = false; + j = k; + break; + } + if (isStartOfArrow(rowNodes[k])) { + throw new ParseError("Missing a " + arrowChar + " character to complete a CD arrow.", rowNodes[k]); + } + labels[labelNum].body.push(rowNodes[k]); + } + if (inLabel) { + // isLabelEnd never returned a true. + throw new ParseError("Missing a " + arrowChar + " character to complete a CD arrow.", rowNodes[j]); + } + } + } else { + throw new ParseError("Expected one of \"<>AV=|.\" after @", rowNodes[j]); + } + // Now join the arrow to its labels. + var arrow = cdArrow(arrowChar, labels, parser); + // Wrap the arrow in ParseNode<"styling">. + // This is done to match parseArray() behavior. + var wrappedArrow = { + type: "styling", + body: [arrow], + mode: "math", + style: "display", + // CD is always displaystyle. + resetFont: true + }; + row.push(wrappedArrow); + // In CD's syntax, cells are implicit. That is, everything that + // is not an arrow gets collected into a cell. So create an empty + // cell now. It will collect upcoming parseNodes. + cell = newCell(); + } + } + if (i % 2 === 0) { + // Even-numbered rows consist of: cell, arrow, cell, arrow, ... cell + // The last cell is not yet pushed into `row`, so: + row.push(cell); + } else { + // Odd-numbered rows consist of: vert arrow, empty cell, ... vert arrow + // Remove the empty cell that was placed at the beginning of `row`. + row.shift(); + } + row = []; + body.push(row); + } + // End row group + parser.gullet.endGroup(); + // End array group defining \\ + parser.gullet.endGroup(); + // define column separation. + var cols = new Array(body[0].length).fill({ + type: "align", + align: "c", + pregap: 0.25, + // CD package sets \enskip between columns. + postgap: 0.25 // So pre and post each get half an \enskip, i.e. 0.25em. + }); + return { + type: "array", + mode: "math", + body, + arraystretch: 1, + addJot: true, + rowGaps: [null], + cols, + colSeparationType: "CD", + hLinesBeforeRow: new Array(body.length + 1).fill([]) + }; +} +// The functions below are not available for general use. +// They are here only for internal use by the {CD} environment in placing labels +// next to vertical arrows. +// We don't need any such functions for horizontal arrows because we can reuse +// the functionality that already exists for extensible arrows. +defineFunction({ + type: "cdlabel", + names: ["\\\\cdleft", "\\\\cdright"], + numArgs: 1, + handler(_ref, args) { + var { + parser, + funcName + } = _ref; + return { + type: "cdlabel", + mode: parser.mode, + side: funcName.slice(4), + label: args[0] + }; + }, + htmlBuilder(group, options) { + var newOptions = options.havingStyle(options.style.sup()); + var label = wrapFragment(buildGroup$1(group.label, newOptions, options), options); + label.classes.push("cd-label-" + group.side); + label.style.bottom = makeEm(0.8 - label.depth); + // Zero out label height & depth, so vertical align of arrow is set + // by the arrow height, not by the label. + label.height = 0; + label.depth = 0; + return label; + }, + mathmlBuilder(group, options) { + var label = new MathNode("mrow", [buildGroup(group.label, options)]); + label = new MathNode("mpadded", [label]); + label.setAttribute("width", "0"); + if (group.side === "left") { + label.setAttribute("lspace", "-1width"); + } + // We have to guess at vertical alignment. We know the arrow is 1.8em tall, + // But we don't know the height or depth of the label. + label.setAttribute("voffset", "0.7em"); + label = new MathNode("mstyle", [label]); + label.setAttribute("displaystyle", "false"); + label.setAttribute("scriptlevel", "1"); + return label; + } +}); +defineFunction({ + type: "cdlabelparent", + names: ["\\\\cdparent"], + numArgs: 1, + handler(_ref2, args) { + var { + parser + } = _ref2; + return { + type: "cdlabelparent", + mode: parser.mode, + fragment: args[0] + }; + }, + htmlBuilder(group, options) { + // Wrap the vertical arrow and its labels. + // The parent gets position: relative. The child gets position: absolute. + // So CSS can locate the label correctly. + var parent = wrapFragment(buildGroup$1(group.fragment, options), options); + parent.classes.push("cd-vert-arrow"); + return parent; + }, + mathmlBuilder(group, options) { + return new MathNode("mrow", [buildGroup(group.fragment, options)]); + } +}); + +// \@char is an internal function that takes a grouped decimal argument like +// {123} and converts into symbol with code 123. It is used by the *macro* +// \char defined in macros.js. +defineFunction({ + type: "textord", + names: ["\\@char"], + numArgs: 1, + allowedInText: true, + handler(_ref, args) { + var { + parser + } = _ref; + var arg = assertNodeType(args[0], "ordgroup"); + var group = arg.body; + var number = ""; + for (var i = 0; i < group.length; i++) { + var node = assertNodeType(group[i], "textord"); + number += node.text; + } + var code = parseInt(number); + var text; + if (isNaN(code)) { + throw new ParseError("\\@char has non-numeric argument " + number); + // If we drop IE support, the following code could be replaced with + // text = String.fromCodePoint(code) + } else if (code < 0 || code >= 0x10ffff) { + throw new ParseError("\\@char with invalid code point " + number); + } else if (code <= 0xffff) { + text = String.fromCharCode(code); + } else { + // Astral code point; split into surrogate halves + code -= 0x10000; + text = String.fromCharCode((code >> 10) + 0xd800, (code & 0x3ff) + 0xdc00); + } + return { + type: "textord", + mode: parser.mode, + text: text + }; + } +}); + +var htmlBuilder$8 = (group, options) => { + var elements = buildExpression$1(group.body, options.withColor(group.color), false); + // \color isn't supposed to affect the type of the elements it contains. + // To accomplish this, we wrap the results in a fragment, so the inner + // elements will be able to directly interact with their neighbors. For + // example, `\color{red}{2 +} 3` has the same spacing as `2 + 3` + return makeFragment(elements); +}; +var mathmlBuilder$7 = (group, options) => { + var inner = buildExpression(group.body, options.withColor(group.color)); + var node = new MathNode("mstyle", inner); + node.setAttribute("mathcolor", group.color); + return node; +}; +defineFunction({ + type: "color", + names: ["\\textcolor"], + numArgs: 2, + allowedInText: true, + argTypes: ["color", "original"], + handler(_ref, args) { + var { + parser + } = _ref; + var color = assertNodeType(args[0], "color-token").color; + var body = args[1]; + return { + type: "color", + mode: parser.mode, + color, + body: ordargument(body) + }; + }, + htmlBuilder: htmlBuilder$8, + mathmlBuilder: mathmlBuilder$7 +}); +defineFunction({ + type: "color", + names: ["\\color"], + numArgs: 1, + allowedInText: true, + argTypes: ["color"], + handler(_ref2, args) { + var { + parser, + breakOnTokenText + } = _ref2; + var color = assertNodeType(args[0], "color-token").color; + // Set macro \current@color in current namespace to store the current + // color, mimicking the behavior of color.sty. + // This is currently used just to correctly color a \right + // that follows a \color command. + parser.gullet.macros.set("\\current@color", color); + // Parse out the implicit body that should be colored. + var body = parser.parseExpression(true, breakOnTokenText); + return { + type: "color", + mode: parser.mode, + color, + body + }; + } +}); + +// Row breaks within tabular environments, and line breaks at top level +// \DeclareRobustCommand\\{...\@xnewline} +defineFunction({ + type: "cr", + names: ["\\\\"], + numArgs: 0, + numOptionalArgs: 0, + allowedInText: true, + handler(_ref, args, optArgs) { + var { + parser + } = _ref; + var size = parser.gullet.future().text === "[" ? parser.parseSizeGroup(true) : null; + var newLine = !parser.settings.displayMode || !parser.settings.useStrictBehavior("newLineInDisplayMode", "In LaTeX, \\\\ or \\newline " + "does nothing in display mode"); + return { + type: "cr", + mode: parser.mode, + newLine, + size: size && assertNodeType(size, "size").value + }; + }, + // The following builders are called only at the top level, + // not within tabular/array environments. + htmlBuilder(group, options) { + var span = makeSpan(["mspace"], [], options); + if (group.newLine) { + span.classes.push("newline"); + if (group.size) { + span.style.marginTop = makeEm(calculateSize(group.size, options)); + } + } + return span; + }, + mathmlBuilder(group, options) { + var node = new MathNode("mspace"); + if (group.newLine) { + node.setAttribute("linebreak", "newline"); + if (group.size) { + node.setAttribute("height", makeEm(calculateSize(group.size, options))); + } + } + return node; + } +}); + +var globalMap = { + "\\global": "\\global", + "\\long": "\\\\globallong", + "\\\\globallong": "\\\\globallong", + "\\def": "\\gdef", + "\\gdef": "\\gdef", + "\\edef": "\\xdef", + "\\xdef": "\\xdef", + "\\let": "\\\\globallet", + "\\futurelet": "\\\\globalfuture" +}; +var checkControlSequence = tok => { + var name = tok.text; + if (/^(?:[\\{}$&#^_]|EOF)$/.test(name)) { + throw new ParseError("Expected a control sequence", tok); + } + return name; +}; +var getRHS = parser => { + var tok = parser.gullet.popToken(); + if (tok.text === "=") { + // consume optional equals + tok = parser.gullet.popToken(); + if (tok.text === " ") { + // consume one optional space + tok = parser.gullet.popToken(); + } + } + return tok; +}; +var letCommand = (parser, name, tok, global) => { + var macro = parser.gullet.macros.get(tok.text); + if (macro == null) { + // don't expand it later even if a macro with the same name is defined + // e.g., \let\foo=\frac \def\frac{\relax} \frac12 + tok.noexpand = true; + macro = { + tokens: [tok], + numArgs: 0, + // reproduce the same behavior in expansion + unexpandable: !parser.gullet.isExpandable(tok.text) + }; + } + parser.gullet.macros.set(name, macro, global); +}; +// -> | +// -> |\global +// -> | +// -> \global|\long|\outer +defineFunction({ + type: "internal", + names: ["\\global", "\\long", "\\\\globallong" // can’t be entered directly + ], + numArgs: 0, + allowedInText: true, + handler(_ref) { + var { + parser, + funcName + } = _ref; + parser.consumeSpaces(); + var token = parser.fetch(); + if (globalMap[token.text]) { + // KaTeX doesn't have \par, so ignore \long + if (funcName === "\\global" || funcName === "\\\\globallong") { + token.text = globalMap[token.text]; + } + return assertNodeType(parser.parseFunction(), "internal"); + } + throw new ParseError("Invalid token after macro prefix", token); + } +}); +// Basic support for macro definitions: \def, \gdef, \edef, \xdef +// -> +// -> \def|\gdef|\edef|\xdef +// -> +defineFunction({ + type: "internal", + names: ["\\def", "\\gdef", "\\edef", "\\xdef"], + numArgs: 0, + allowedInText: true, + primitive: true, + handler(_ref2) { + var { + parser, + funcName + } = _ref2; + var tok = parser.gullet.popToken(); + var name = tok.text; + if (/^(?:[\\{}$&#^_]|EOF)$/.test(name)) { + throw new ParseError("Expected a control sequence", tok); + } + var numArgs = 0; + var insert; + var delimiters = [[]]; + // contains no braces + while (parser.gullet.future().text !== "{") { + tok = parser.gullet.popToken(); + if (tok.text === "#") { + // If the very last character of the is #, so that + // this # is immediately followed by {, TeX will behave as if the { + // had been inserted at the right end of both the parameter text + // and the replacement text. + if (parser.gullet.future().text === "{") { + insert = parser.gullet.future(); + delimiters[numArgs].push("{"); + break; + } + // A parameter, the first appearance of # must be followed by 1, + // the next by 2, and so on; up to nine #’s are allowed + tok = parser.gullet.popToken(); + if (!/^[1-9]$/.test(tok.text)) { + throw new ParseError("Invalid argument number \"" + tok.text + "\""); + } + if (parseInt(tok.text) !== numArgs + 1) { + throw new ParseError("Argument number \"" + tok.text + "\" out of order"); + } + numArgs++; + delimiters.push([]); + } else if (tok.text === "EOF") { + throw new ParseError("Expected a macro definition"); + } else { + delimiters[numArgs].push(tok.text); + } + } + // replacement text, enclosed in '{' and '}' and properly nested + var { + tokens + } = parser.gullet.consumeArg(); + if (insert) { + tokens.unshift(insert); + } + if (funcName === "\\edef" || funcName === "\\xdef") { + tokens = parser.gullet.expandTokens(tokens); + tokens.reverse(); // to fit in with stack order + } + // Final arg is the expansion of the macro + parser.gullet.macros.set(name, { + tokens, + numArgs, + delimiters + }, funcName === globalMap[funcName]); + return { + type: "internal", + mode: parser.mode + }; + } +}); +// -> +// -> \futurelet +// | \let +// -> |= +defineFunction({ + type: "internal", + names: ["\\let", "\\\\globallet" // can’t be entered directly + ], + numArgs: 0, + allowedInText: true, + primitive: true, + handler(_ref3) { + var { + parser, + funcName + } = _ref3; + var name = checkControlSequence(parser.gullet.popToken()); + parser.gullet.consumeSpaces(); + var tok = getRHS(parser); + letCommand(parser, name, tok, funcName === "\\\\globallet"); + return { + type: "internal", + mode: parser.mode + }; + } +}); +// ref: https://www.tug.org/TUGboat/tb09-3/tb22bechtolsheim.pdf +defineFunction({ + type: "internal", + names: ["\\futurelet", "\\\\globalfuture" // can’t be entered directly + ], + numArgs: 0, + allowedInText: true, + primitive: true, + handler(_ref4) { + var { + parser, + funcName + } = _ref4; + var name = checkControlSequence(parser.gullet.popToken()); + var middle = parser.gullet.popToken(); + var tok = parser.gullet.popToken(); + letCommand(parser, name, tok, funcName === "\\\\globalfuture"); + parser.gullet.pushToken(tok); + parser.gullet.pushToken(middle); + return { + type: "internal", + mode: parser.mode + }; + } +}); + +/** + * This file 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`. + */ +/** + * Get the metrics for a given symbol and font, after transformation (i.e. + * after following replacement from symbols.js) + */ +var getMetrics = function getMetrics(symbol, font, mode) { + var replace = symbols.math[symbol] && symbols.math[symbol].replace; + var metrics = getCharacterMetrics(replace || symbol, font, mode); + if (!metrics) { + throw new Error("Unsupported symbol " + symbol + " and font size " + font + "."); + } + return metrics; +}; +/** + * Puts a delimiter span in a given style, and adds appropriate height, depth, + * and maxFontSizes. + */ +var styleWrap = function styleWrap(delim, toStyle, options, classes) { + var newOptions = options.havingBaseStyle(toStyle); + var span = makeSpan(classes.concat(newOptions.sizingClasses(options)), [delim], options); + var delimSizeMultiplier = newOptions.sizeMultiplier / options.sizeMultiplier; + span.height *= delimSizeMultiplier; + span.depth *= delimSizeMultiplier; + span.maxFontSize = newOptions.sizeMultiplier; + return span; +}; +var centerSpan = function centerSpan(span, options, style) { + var newOptions = options.havingBaseStyle(style); + var shift = (1 - options.sizeMultiplier / newOptions.sizeMultiplier) * options.fontMetrics().axisHeight; + span.classes.push("delimcenter"); + span.style.top = makeEm(shift); + span.height -= shift; + span.depth += shift; +}; +/** + * 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. + */ +var makeSmallDelim = function makeSmallDelim(delim, style, center, options, mode, classes) { + var text = makeSymbol(delim, "Main-Regular", mode, options); + var span = styleWrap(text, style, options, classes); + if (center) { + centerSpan(span, options, style); + } + return span; +}; +/** + * Builds a symbol in the given font size (note size is an integer) + */ +var mathrmSize = function mathrmSize(value, size, mode, options) { + return makeSymbol(value, "Size" + size + "-Regular", mode, options); +}; +/** + * Makes a large delimiter. This is a delimiter that comes in the Size1, Size2, + * Size3, or Size4 fonts. It is always rendered in textstyle. + */ +var makeLargeDelim = function makeLargeDelim(delim, size, center, options, mode, classes) { + var inner = mathrmSize(delim, size, mode, options); + var span = styleWrap(makeSpan(["delimsizing", "size" + size], [inner], options), Style$1.TEXT, options, classes); + if (center) { + centerSpan(span, options, Style$1.TEXT); + } + return span; +}; +/** + * Make a span from a font glyph with the given offset and in the given font. + * This is used in makeStackedDelim to make the stacking pieces for the delimiter. + */ +var makeGlyphSpan = function makeGlyphSpan(symbol, font, mode) { + var sizeClass; + // Apply the correct CSS class to choose the right font. + if (font === "Size1-Regular") { + sizeClass = "delim-size1"; + } else /* if (font === "Size4-Regular") */{ + sizeClass = "delim-size4"; + } + var corner = makeSpan(["delimsizinginner", sizeClass], [makeSpan([], [makeSymbol(symbol, font, mode)])]); + // Since this will be passed into `makeVList` in the end, wrap the element + // in the appropriate tag that VList uses. + return { + type: "elem", + elem: corner + }; +}; +var makeInner = function makeInner(ch, height, options) { + // Create a span with inline SVG for the inner part of a tall stacked delimiter. + var width = fontMetricsData['Size4-Regular'][ch.charCodeAt(0)] ? fontMetricsData['Size4-Regular'][ch.charCodeAt(0)][4] : fontMetricsData['Size1-Regular'][ch.charCodeAt(0)][4]; + var path = new PathNode("inner", innerPath(ch, Math.round(1000 * height))); + var svgNode = new SvgNode([path], { + "width": makeEm(width), + "height": makeEm(height), + // Override CSS rule `.katex svg { width: 100% }` + "style": "width:" + makeEm(width), + "viewBox": "0 0 " + 1000 * width + " " + Math.round(1000 * height), + "preserveAspectRatio": "xMinYMin" + }); + var span = makeSvgSpan([], [svgNode], options); + span.height = height; + span.style.height = makeEm(height); + span.style.width = makeEm(width); + return { + type: "elem", + elem: span + }; +}; +// Helpers for makeStackedDelim +var lapInEms = 0.008; +var lap = { + type: "kern", + size: -1 * lapInEms +}; +var verts = new Set(["|", "\\lvert", "\\rvert", "\\vert"]); +var doubleVerts = new Set(["\\|", "\\lVert", "\\rVert", "\\Vert"]); +/** + * Make a stacked delimiter out of a given delimiter, with the total height at + * least `heightTotal`. This routine is mentioned on page 442 of the TeXbook. + */ +var makeStackedDelim = function makeStackedDelim(delim, heightTotal, center, options, mode, classes) { + // There are four parts, the top, an optional middle, a repeated part, and a + // bottom. + var top; + var middle; + var repeat; + var bottom; + var svgLabel = ""; + var viewBoxWidth = 0; + top = repeat = bottom = delim; + middle = null; + // Also keep track of what font the delimiters are in + var font = "Size1-Regular"; + // We set the parts and font based on the symbol. Note that we use + // '\u23d0' instead of '|' and '\u2016' instead of '\\|' for the + // repeats of the arrows + if (delim === "\\uparrow") { + repeat = bottom = "\u23d0"; + } else if (delim === "\\Uparrow") { + repeat = bottom = "\u2016"; + } else if (delim === "\\downarrow") { + top = repeat = "\u23d0"; + } else if (delim === "\\Downarrow") { + top = repeat = "\u2016"; + } else if (delim === "\\updownarrow") { + top = "\\uparrow"; + repeat = "\u23d0"; + bottom = "\\downarrow"; + } else if (delim === "\\Updownarrow") { + top = "\\Uparrow"; + repeat = "\u2016"; + bottom = "\\Downarrow"; + } else if (verts.has(delim)) { + repeat = "\u2223"; + svgLabel = "vert"; + viewBoxWidth = 333; + } else if (doubleVerts.has(delim)) { + repeat = "\u2225"; + svgLabel = "doublevert"; + viewBoxWidth = 556; + } else if (delim === "[" || delim === "\\lbrack") { + top = "\u23a1"; + repeat = "\u23a2"; + bottom = "\u23a3"; + font = "Size4-Regular"; + svgLabel = "lbrack"; + viewBoxWidth = 667; + } else if (delim === "]" || delim === "\\rbrack") { + top = "\u23a4"; + repeat = "\u23a5"; + bottom = "\u23a6"; + font = "Size4-Regular"; + svgLabel = "rbrack"; + viewBoxWidth = 667; + } else if (delim === "\\lfloor" || delim === "\u230a") { + repeat = top = "\u23a2"; + bottom = "\u23a3"; + font = "Size4-Regular"; + svgLabel = "lfloor"; + viewBoxWidth = 667; + } else if (delim === "\\lceil" || delim === "\u2308") { + top = "\u23a1"; + repeat = bottom = "\u23a2"; + font = "Size4-Regular"; + svgLabel = "lceil"; + viewBoxWidth = 667; + } else if (delim === "\\rfloor" || delim === "\u230b") { + repeat = top = "\u23a5"; + bottom = "\u23a6"; + font = "Size4-Regular"; + svgLabel = "rfloor"; + viewBoxWidth = 667; + } else if (delim === "\\rceil" || delim === "\u2309") { + top = "\u23a4"; + repeat = bottom = "\u23a5"; + font = "Size4-Regular"; + svgLabel = "rceil"; + viewBoxWidth = 667; + } else if (delim === "(" || delim === "\\lparen") { + top = "\u239b"; + repeat = "\u239c"; + bottom = "\u239d"; + font = "Size4-Regular"; + svgLabel = "lparen"; + viewBoxWidth = 875; + } else if (delim === ")" || delim === "\\rparen") { + top = "\u239e"; + repeat = "\u239f"; + bottom = "\u23a0"; + font = "Size4-Regular"; + svgLabel = "rparen"; + viewBoxWidth = 875; + } else if (delim === "\\{" || delim === "\\lbrace") { + top = "\u23a7"; + middle = "\u23a8"; + bottom = "\u23a9"; + repeat = "\u23aa"; + font = "Size4-Regular"; + } else if (delim === "\\}" || delim === "\\rbrace") { + top = "\u23ab"; + middle = "\u23ac"; + bottom = "\u23ad"; + repeat = "\u23aa"; + font = "Size4-Regular"; + } else if (delim === "\\lgroup" || delim === "\u27ee") { + top = "\u23a7"; + bottom = "\u23a9"; + repeat = "\u23aa"; + font = "Size4-Regular"; + } else if (delim === "\\rgroup" || delim === "\u27ef") { + top = "\u23ab"; + bottom = "\u23ad"; + repeat = "\u23aa"; + font = "Size4-Regular"; + } else if (delim === "\\lmoustache" || delim === "\u23b0") { + top = "\u23a7"; + bottom = "\u23ad"; + repeat = "\u23aa"; + font = "Size4-Regular"; + } else if (delim === "\\rmoustache" || delim === "\u23b1") { + top = "\u23ab"; + bottom = "\u23a9"; + repeat = "\u23aa"; + font = "Size4-Regular"; + } + // Get the metrics of the four sections + var topMetrics = getMetrics(top, font, mode); + var topHeightTotal = topMetrics.height + topMetrics.depth; + var repeatMetrics = getMetrics(repeat, font, mode); + var repeatHeightTotal = repeatMetrics.height + repeatMetrics.depth; + var bottomMetrics = getMetrics(bottom, font, mode); + var bottomHeightTotal = bottomMetrics.height + bottomMetrics.depth; + var middleHeightTotal = 0; + var middleFactor = 1; + if (middle !== null) { + var middleMetrics = getMetrics(middle, font, mode); + middleHeightTotal = middleMetrics.height + middleMetrics.depth; + middleFactor = 2; // repeat symmetrically above and below middle + } + // Calculate the minimal height that the delimiter can have. + // It is at least the size of the top, bottom, and optional middle combined. + var minHeight = topHeightTotal + bottomHeightTotal + middleHeightTotal; + // Compute the number of copies of the repeat symbol we will need + var repeatCount = Math.max(0, Math.ceil((heightTotal - minHeight) / (middleFactor * repeatHeightTotal))); + // Compute the total height of the delimiter including all the symbols + var realHeightTotal = minHeight + repeatCount * middleFactor * repeatHeightTotal; + // The center of the delimiter is placed at the center of the axis. Note + // that in this context, "center" means that the delimiter should be + // centered around the axis in the current style, while normally it is + // centered around the axis in textstyle. + var axisHeight = options.fontMetrics().axisHeight; + if (center) { + axisHeight *= options.sizeMultiplier; + } + // Calculate the depth + var depth = realHeightTotal / 2 - axisHeight; + // Now, we start building the pieces that will go into the vlist + // Keep a list of the pieces of the stacked delimiter + var stack = []; + if (svgLabel.length > 0) { + // Instead of stacking glyphs, create a single SVG. + // This evades browser problems with imprecise positioning of spans. + var midHeight = realHeightTotal - topHeightTotal - bottomHeightTotal; + var viewBoxHeight = Math.round(realHeightTotal * 1000); + var pathStr = tallDelim(svgLabel, Math.round(midHeight * 1000)); + var path = new PathNode(svgLabel, pathStr); + var width = makeEm(viewBoxWidth / 1000); + var height = makeEm(viewBoxHeight / 1000); + var svg = new SvgNode([path], { + "width": width, + "height": height, + "viewBox": "0 0 " + viewBoxWidth + " " + viewBoxHeight + }); + var wrapper = makeSvgSpan([], [svg], options); + wrapper.height = viewBoxHeight / 1000; + wrapper.style.width = width; + wrapper.style.height = height; + stack.push({ + type: "elem", + elem: wrapper + }); + } else { + // Stack glyphs + // Start by adding the bottom symbol + stack.push(makeGlyphSpan(bottom, font, mode)); + stack.push(lap); // overlap + if (middle === null) { + // The middle section will be an SVG. Make it an extra 0.016em tall. + // We'll overlap by 0.008em at top and bottom. + var innerHeight = realHeightTotal - topHeightTotal - bottomHeightTotal + 2 * lapInEms; + stack.push(makeInner(repeat, innerHeight, options)); + } else { + // When there is a middle bit, we need the middle part and two repeated + // sections + var _innerHeight = (realHeightTotal - topHeightTotal - bottomHeightTotal - middleHeightTotal) / 2 + 2 * lapInEms; + stack.push(makeInner(repeat, _innerHeight, options)); + // Now insert the middle of the brace. + stack.push(lap); + stack.push(makeGlyphSpan(middle, font, mode)); + stack.push(lap); + stack.push(makeInner(repeat, _innerHeight, options)); + } + // Add the top symbol + stack.push(lap); + stack.push(makeGlyphSpan(top, font, mode)); + } + // Finally, build the vlist + var newOptions = options.havingBaseStyle(Style$1.TEXT); + var inner = makeVList({ + positionType: "bottom", + positionData: depth, + children: stack + }); + return styleWrap(makeSpan(["delimsizing", "mult"], [inner], newOptions), Style$1.TEXT, options, classes); +}; +// All surds have 0.08em padding above the vinculum inside the SVG. +// That keeps browser span height rounding error from pinching the line. +var vbPad = 80; // padding above the surd, measured inside the viewBox. +var emPad = 0.08; // padding, in ems, measured in the document. +var sqrtSvg = function sqrtSvg(sqrtName, height, viewBoxHeight, extraVinculum, options) { + var path = sqrtPath(sqrtName, extraVinculum, viewBoxHeight); + var pathNode = new PathNode(sqrtName, path); + var svg = new SvgNode([pathNode], { + // Note: 1000:1 ratio of viewBox to document em width. + "width": "400em", + "height": makeEm(height), + "viewBox": "0 0 400000 " + viewBoxHeight, + "preserveAspectRatio": "xMinYMin slice" + }); + return makeSvgSpan(["hide-tail"], [svg], options); +}; +/** + * Make a sqrt image of the given height, + */ +var makeSqrtImage = function makeSqrtImage(height, options) { + // Define a newOptions that removes the effect of size changes such as \Huge. + // We don't pick different a height surd for \Huge. For it, we scale up. + var newOptions = options.havingBaseSizing(); + // Pick the desired surd glyph from a sequence of surds. + var delim = traverseSequence("\\surd", height * newOptions.sizeMultiplier, stackLargeDelimiterSequence, newOptions); + var sizeMultiplier = newOptions.sizeMultiplier; // default + // The standard sqrt SVGs each have a 0.04em thick vinculum. + // If Settings.minRuleThickness is larger than that, we add extraVinculum. + var extraVinculum = Math.max(0, options.minRuleThickness - options.fontMetrics().sqrtRuleThickness); + // Create a span containing an SVG image of a sqrt symbol. + var span; + var spanHeight; + var texHeight; + var viewBoxHeight; + var advanceWidth; + // We create viewBoxes with 80 units of "padding" above each surd. + // Then browser rounding error on the parent span height will not + // encroach on the ink of the vinculum. But that padding is not + // included in the TeX-like `height` used for calculation of + // vertical alignment. So texHeight = span.height < span.style.height. + if (delim.type === "small") { + // Get an SVG that is derived from glyph U+221A in font KaTeX-Main. + // 1000 unit normal glyph height. + viewBoxHeight = 1000 + 1000 * extraVinculum + vbPad; + if (height < 1.0) { + sizeMultiplier = 1.0; // mimic a \textfont radical + } else if (height < 1.4) { + sizeMultiplier = 0.7; // mimic a \scriptfont radical + } + spanHeight = (1.0 + extraVinculum + emPad) / sizeMultiplier; + texHeight = (1.00 + extraVinculum) / sizeMultiplier; + span = sqrtSvg("sqrtMain", spanHeight, viewBoxHeight, extraVinculum, options); + span.style.minWidth = "0.853em"; + advanceWidth = 0.833 / sizeMultiplier; // from the font. + } else if (delim.type === "large") { + // These SVGs come from fonts: KaTeX_Size1, _Size2, etc. + viewBoxHeight = (1000 + vbPad) * sizeToMaxHeight[delim.size]; + texHeight = (sizeToMaxHeight[delim.size] + extraVinculum) / sizeMultiplier; + spanHeight = (sizeToMaxHeight[delim.size] + extraVinculum + emPad) / sizeMultiplier; + span = sqrtSvg("sqrtSize" + delim.size, spanHeight, viewBoxHeight, extraVinculum, options); + span.style.minWidth = "1.02em"; + advanceWidth = 1.0 / sizeMultiplier; // 1.0 from the font. + } else { + // Tall sqrt. In TeX, this would be stacked using multiple glyphs. + // We'll use a single SVG to accomplish the same thing. + spanHeight = height + extraVinculum + emPad; + texHeight = height + extraVinculum; + viewBoxHeight = Math.floor(1000 * height + extraVinculum) + vbPad; + span = sqrtSvg("sqrtTall", spanHeight, viewBoxHeight, extraVinculum, options); + span.style.minWidth = "0.742em"; + advanceWidth = 1.056; + } + span.height = texHeight; + span.style.height = makeEm(spanHeight); + return { + span, + advanceWidth, + // Calculate the actual line width. + // This actually should depend on the chosen font -- e.g. \boldmath + // should use the thicker surd symbols from e.g. KaTeX_Main-Bold, and + // have thicker rules. + ruleWidth: (options.fontMetrics().sqrtRuleThickness + extraVinculum) * sizeMultiplier + }; +}; +// There are three kinds of delimiters, delimiters that stack when they become +// too large +var stackLargeDelimiters = new Set(["(", "\\lparen", ")", "\\rparen", "[", "\\lbrack", "]", "\\rbrack", "\\{", "\\lbrace", "\\}", "\\rbrace", "\\lfloor", "\\rfloor", "\u230a", "\u230b", "\\lceil", "\\rceil", "\u2308", "\u2309", "\\surd"]); +// delimiters that always stack +var stackAlwaysDelimiters = new Set(["\\uparrow", "\\downarrow", "\\updownarrow", "\\Uparrow", "\\Downarrow", "\\Updownarrow", "|", "\\|", "\\vert", "\\Vert", "\\lvert", "\\rvert", "\\lVert", "\\rVert", "\\lgroup", "\\rgroup", "\u27ee", "\u27ef", "\\lmoustache", "\\rmoustache", "\u23b0", "\u23b1"]); +// and delimiters that never stack +var stackNeverDelimiters = new Set(["<", ">", "\\langle", "\\rangle", "/", "\\backslash", "\\lt", "\\gt"]); +// Metrics of the different sizes. Found by looking at TeX's output of +// $\bigl| // \Bigl| \biggl| \Biggl| \showlists$ +// Used to create stacked delimiters of appropriate sizes in makeSizedDelim. +var sizeToMaxHeight = [0, 1.2, 1.8, 2.4, 3.0]; +/** + * Used to create a delimiter of a specific size, where `size` is 1, 2, 3, or 4. + */ +var makeSizedDelim = function makeSizedDelim(delim, size, options, mode, classes) { + // < and > turn into \langle and \rangle in delimiters + if (delim === "<" || delim === "\\lt" || delim === "\u27e8") { + delim = "\\langle"; + } else if (delim === ">" || delim === "\\gt" || delim === "\u27e9") { + delim = "\\rangle"; + } + // Sized delimiters are never centered. + if (stackLargeDelimiters.has(delim) || stackNeverDelimiters.has(delim)) { + return makeLargeDelim(delim, size, false, options, mode, classes); + } else if (stackAlwaysDelimiters.has(delim)) { + return makeStackedDelim(delim, sizeToMaxHeight[size], false, options, mode, classes); + } else { + throw new ParseError("Illegal delimiter: '" + delim + "'"); + } +}; +// Delimiters that never stack try small delimiters and large delimiters only +var stackNeverDelimiterSequence = [{ + type: "small", + style: Style$1.SCRIPTSCRIPT +}, { + type: "small", + style: Style$1.SCRIPT +}, { + type: "small", + style: Style$1.TEXT +}, { + type: "large", + size: 1 +}, { + type: "large", + size: 2 +}, { + type: "large", + size: 3 +}, { + type: "large", + size: 4 +}]; +// Delimiters that always stack try the small delimiters first, then stack +var stackAlwaysDelimiterSequence = [{ + type: "small", + style: Style$1.SCRIPTSCRIPT +}, { + type: "small", + style: Style$1.SCRIPT +}, { + type: "small", + style: Style$1.TEXT +}, { + type: "stack" +}]; +// Delimiters that stack when large try the small and then large delimiters, and +// stack afterwards +var stackLargeDelimiterSequence = [{ + type: "small", + style: Style$1.SCRIPTSCRIPT +}, { + type: "small", + style: Style$1.SCRIPT +}, { + type: "small", + style: Style$1.TEXT +}, { + type: "large", + size: 1 +}, { + type: "large", + size: 2 +}, { + type: "large", + size: 3 +}, { + type: "large", + size: 4 +}, { + type: "stack" +}]; +/** + * Get the font used in a delimiter based on what kind of delimiter it is. + * TODO(#963) Use more specific font family return type once that is introduced. + */ +var delimTypeToFont = function delimTypeToFont(type) { + if (type.type === "small") { + return "Main-Regular"; + } else if (type.type === "large") { + return "Size" + type.size + "-Regular"; + } else if (type.type === "stack") { + return "Size4-Regular"; + } else { + var delimKind = type.type; + throw new Error("Add support for delim type '" + delimKind + "' here."); + } +}; +/** + * Traverse a sequence of types of delimiters to decide what kind of delimiter + * should be used to create a delimiter of the given height+depth. + */ +var traverseSequence = function traverseSequence(delim, height, sequence, options) { + // Here, we choose the index we should start at in the sequences. In smaller + // sizes (which correspond to larger numbers in style.size) we start earlier + // in the sequence. Thus, scriptscript starts at index 3-3=0, script starts + // at index 3-2=1, text starts at 3-1=2, and display starts at min(2,3-0)=2 + var start = Math.min(2, 3 - options.style.size); + for (var i = start; i < sequence.length; i++) { + var delimType = sequence[i]; + if (delimType.type === "stack") { + // This is always the last delimiter, so we just break the loop now. + break; + } + var metrics = getMetrics(delim, delimTypeToFont(delimType), "math"); + var heightDepth = metrics.height + metrics.depth; + // Small delimiters are scaled down versions of the same font, so we + // account for the style change size. + if (delimType.type === "small") { + var newOptions = options.havingBaseStyle(delimType.style); + heightDepth *= newOptions.sizeMultiplier; + } + // Check if the delimiter at this size works for the given height. + if (heightDepth > height) { + return delimType; + } + } + // If we reached the end of the sequence, return the last sequence element. + return sequence[sequence.length - 1]; +}; +/** + * Make a delimiter of a given height+depth, with optional centering. Here, we + * traverse the sequences, and create a delimiter that the sequence tells us to. + */ +var makeCustomSizedDelim = function makeCustomSizedDelim(delim, height, center, options, mode, classes) { + if (delim === "<" || delim === "\\lt" || delim === "\u27e8") { + delim = "\\langle"; + } else if (delim === ">" || delim === "\\gt" || delim === "\u27e9") { + delim = "\\rangle"; + } + // Decide what sequence to use + var sequence; + if (stackNeverDelimiters.has(delim)) { + sequence = stackNeverDelimiterSequence; + } else if (stackLargeDelimiters.has(delim)) { + sequence = stackLargeDelimiterSequence; + } else { + sequence = stackAlwaysDelimiterSequence; + } + // Look through the sequence + var delimType = traverseSequence(delim, height, sequence, options); + // Get the delimiter from font glyphs. + // Depending on the sequence element we decided on, call the + // appropriate function. + if (delimType.type === "small") { + return makeSmallDelim(delim, delimType.style, center, options, mode, classes); + } else if (delimType.type === "large") { + return makeLargeDelim(delim, delimType.size, center, options, mode, classes); + } else /* if (delimType.type === "stack") */{ + return makeStackedDelim(delim, height, center, options, mode, classes); + } +}; +/** + * Make a delimiter for use with `\left` and `\right`, given a height and depth + * of an expression that the delimiters surround. + */ +var makeLeftRightDelim = function makeLeftRightDelim(delim, height, depth, options, mode, classes) { + // We always center \left/\right delimiters, so the axis is always shifted + var axisHeight = options.fontMetrics().axisHeight * options.sizeMultiplier; + // Taken from TeX source, tex.web, function make_left_right + var delimiterFactor = 901; + var delimiterExtend = 5.0 / options.fontMetrics().ptPerEm; + var maxDistFromAxis = Math.max(height - axisHeight, depth + axisHeight); + var totalHeight = Math.max( + // In real TeX, calculations are done using integral values which are + // 65536 per pt, or 655360 per em. So, the division here truncates in + // TeX but doesn't here, producing different results. If we wanted to + // exactly match TeX's calculation, we could do + // Math.floor(655360 * maxDistFromAxis / 500) * + // delimiterFactor / 655360 + // (To see the difference, compare + // x^{x^{\left(\rule{0.1em}{0.68em}\right)}} + // in TeX and KaTeX) + maxDistFromAxis / 500 * delimiterFactor, 2 * maxDistFromAxis - delimiterExtend); + // Finally, we defer to `makeCustomSizedDelim` with our calculated total + // height + return makeCustomSizedDelim(delim, totalHeight, true, options, mode, classes); +}; + +// Extra data needed for the delimiter handler down below +var delimiterSizes = { + "\\bigl": { + mclass: "mopen", + size: 1 + }, + "\\Bigl": { + mclass: "mopen", + size: 2 + }, + "\\biggl": { + mclass: "mopen", + size: 3 + }, + "\\Biggl": { + mclass: "mopen", + size: 4 + }, + "\\bigr": { + mclass: "mclose", + size: 1 + }, + "\\Bigr": { + mclass: "mclose", + size: 2 + }, + "\\biggr": { + mclass: "mclose", + size: 3 + }, + "\\Biggr": { + mclass: "mclose", + size: 4 + }, + "\\bigm": { + mclass: "mrel", + size: 1 + }, + "\\Bigm": { + mclass: "mrel", + size: 2 + }, + "\\biggm": { + mclass: "mrel", + size: 3 + }, + "\\Biggm": { + mclass: "mrel", + size: 4 + }, + "\\big": { + mclass: "mord", + size: 1 + }, + "\\Big": { + mclass: "mord", + size: 2 + }, + "\\bigg": { + mclass: "mord", + size: 3 + }, + "\\Bigg": { + mclass: "mord", + size: 4 + } +}; +var delimiters = new Set(["(", "\\lparen", ")", "\\rparen", "[", "\\lbrack", "]", "\\rbrack", "\\{", "\\lbrace", "\\}", "\\rbrace", "\\lfloor", "\\rfloor", "\u230a", "\u230b", "\\lceil", "\\rceil", "\u2308", "\u2309", "<", ">", "\\langle", "\u27e8", "\\rangle", "\u27e9", "\\lt", "\\gt", "\\lvert", "\\rvert", "\\lVert", "\\rVert", "\\lgroup", "\\rgroup", "\u27ee", "\u27ef", "\\lmoustache", "\\rmoustache", "\u23b0", "\u23b1", "/", "\\backslash", "|", "\\vert", "\\|", "\\Vert", "\\uparrow", "\\Uparrow", "\\downarrow", "\\Downarrow", "\\updownarrow", "\\Updownarrow", "."]); +function isMiddleDelimNode(node) { + return 'isMiddle' in node; +} +// Delimiter functions +function checkDelimiter(delim, context) { + var symDelim = checkSymbolNodeType(delim); + if (symDelim && delimiters.has(symDelim.text)) { + return symDelim; + } else if (symDelim) { + throw new ParseError("Invalid delimiter '" + symDelim.text + "' after '" + context.funcName + "'", delim); + } else { + throw new ParseError("Invalid delimiter type '" + delim.type + "'", delim); + } +} +defineFunction({ + type: "delimsizing", + names: ["\\bigl", "\\Bigl", "\\biggl", "\\Biggl", "\\bigr", "\\Bigr", "\\biggr", "\\Biggr", "\\bigm", "\\Bigm", "\\biggm", "\\Biggm", "\\big", "\\Big", "\\bigg", "\\Bigg"], + numArgs: 1, + argTypes: ["primitive"], + handler: (context, args) => { + var delim = checkDelimiter(args[0], context); + return { + type: "delimsizing", + mode: context.parser.mode, + size: delimiterSizes[context.funcName].size, + mclass: delimiterSizes[context.funcName].mclass, + delim: delim.text + }; + }, + htmlBuilder: (group, options) => { + if (group.delim === ".") { + // Empty delimiters still count as elements, even though they don't + // show anything. + return makeSpan([group.mclass]); + } + return makeSizedDelim(group.delim, group.size, options, group.mode, [group.mclass]); + }, + mathmlBuilder: group => { + var children = []; + if (group.delim !== ".") { + children.push(makeText(group.delim, group.mode)); + } + var node = new MathNode("mo", children); + if (group.mclass === "mopen" || group.mclass === "mclose") { + // Only some of the delimsizing functions act as fences, and they + // return "mopen" or "mclose" mclass. + node.setAttribute("fence", "true"); + } else { + // Explicitly disable fencing if it's not a fence, to override the + // defaults. + node.setAttribute("fence", "false"); + } + node.setAttribute("stretchy", "true"); + var size = makeEm(sizeToMaxHeight[group.size]); + node.setAttribute("minsize", size); + node.setAttribute("maxsize", size); + return node; + } +}); +function assertParsed(group) { + if (!group.body) { + throw new Error("Bug: The leftright ParseNode wasn't fully parsed."); + } +} +defineFunction({ + type: "leftright-right", + names: ["\\right"], + numArgs: 1, + primitive: true, + handler: (context, args) => { + // \left case below triggers parsing of \right in + // `const right = parser.parseFunction();` + // uses this return value. + var color = context.parser.gullet.macros.get("\\current@color"); + if (color && typeof color !== "string") { + throw new ParseError("\\current@color set to non-string in \\right"); + } + return { + type: "leftright-right", + mode: context.parser.mode, + delim: checkDelimiter(args[0], context).text, + color // undefined if not set via \color + }; + } +}); +defineFunction({ + type: "leftright", + names: ["\\left"], + numArgs: 1, + primitive: true, + handler: (context, args) => { + var delim = checkDelimiter(args[0], context); + var parser = context.parser; + // Parse out the implicit body + ++parser.leftrightDepth; + // parseExpression stops before '\\right' + var body = parser.parseExpression(false); + --parser.leftrightDepth; + // Check the next token + parser.expect("\\right", false); + var right = assertNodeType(parser.parseFunction(), "leftright-right"); + return { + type: "leftright", + mode: parser.mode, + body, + left: delim.text, + right: right.delim, + rightColor: right.color + }; + }, + htmlBuilder: (group, options) => { + assertParsed(group); + // Build the inner expression + var inner = buildExpression$1(group.body, options, true, ["mopen", "mclose"]); + var innerHeight = 0; + var innerDepth = 0; + var hadMiddle = false; + // Calculate its height and depth + for (var i = 0; i < inner.length; i++) { + var node = inner[i]; + if (isMiddleDelimNode(node)) { + hadMiddle = true; + } else { + innerHeight = Math.max(inner[i].height, innerHeight); + innerDepth = Math.max(inner[i].depth, innerDepth); + } + } + // The size of delimiters is the same, regardless of what style we are + // in. Thus, to correctly calculate the size of delimiter we need around + // a group, we scale down the inner size based on the size. + innerHeight *= options.sizeMultiplier; + innerDepth *= options.sizeMultiplier; + var leftDelim; + if (group.left === ".") { + // Empty delimiters in \left and \right make null delimiter spaces. + leftDelim = makeNullDelimiter(options, ["mopen"]); + } else { + // Otherwise, use leftRightDelim to generate the correct sized + // delimiter. + leftDelim = makeLeftRightDelim(group.left, innerHeight, innerDepth, options, group.mode, ["mopen"]); + } + // Add it to the beginning of the expression + inner.unshift(leftDelim); + // Handle middle delimiters + if (hadMiddle) { + for (var _i = 1; _i < inner.length; _i++) { + var middleDelim = inner[_i]; + if (isMiddleDelimNode(middleDelim)) { + var isMiddle = middleDelim.isMiddle; + // Apply the options that were active when \middle was called + inner[_i] = makeLeftRightDelim(isMiddle.delim, innerHeight, innerDepth, isMiddle.options, group.mode, []); + } + } + } + var rightDelim; + // Same for the right delimiter, but using color specified by \color + if (group.right === ".") { + rightDelim = makeNullDelimiter(options, ["mclose"]); + } else { + var colorOptions = group.rightColor ? options.withColor(group.rightColor) : options; + rightDelim = makeLeftRightDelim(group.right, innerHeight, innerDepth, colorOptions, group.mode, ["mclose"]); + } + // Add it to the end of the expression. + inner.push(rightDelim); + return makeSpan(["minner"], inner, options); + }, + mathmlBuilder: (group, options) => { + assertParsed(group); + var inner = buildExpression(group.body, options); + if (group.left !== ".") { + var leftNode = new MathNode("mo", [makeText(group.left, group.mode)]); + leftNode.setAttribute("fence", "true"); + inner.unshift(leftNode); + } + if (group.right !== ".") { + var rightNode = new MathNode("mo", [makeText(group.right, group.mode)]); + rightNode.setAttribute("fence", "true"); + if (group.rightColor) { + rightNode.setAttribute("mathcolor", group.rightColor); + } + inner.push(rightNode); + } + return makeRow(inner); + } +}); +defineFunction({ + type: "middle", + names: ["\\middle"], + numArgs: 1, + primitive: true, + handler: (context, args) => { + var delim = checkDelimiter(args[0], context); + if (!context.parser.leftrightDepth) { + throw new ParseError("\\middle without preceding \\left", delim); + } + return { + type: "middle", + mode: context.parser.mode, + delim: delim.text + }; + }, + htmlBuilder: (group, options) => { + var middleDelim; + if (group.delim === ".") { + middleDelim = makeNullDelimiter(options, []); + } else { + middleDelim = makeSizedDelim(group.delim, 1, options, group.mode, []); + // Patch an ad-hoc property onto the node so the \left/\right + // builder can reconstruct appropriately sized middle delimiters. + // isMiddle is not part of HtmlDomNode; the read side uses + // isMiddleDelimNode() to check before accessing. + middleDelim.isMiddle = { + delim: group.delim, + options + }; + } + return middleDelim; + }, + mathmlBuilder: (group, options) => { + // A Firefox \middle will stretch a character vertically only if it + // is in the fence part of the operator dictionary at: + // https://www.w3.org/TR/MathML3/appendixc.html. + // So we need to avoid U+2223 and use plain "|" instead. + var textNode = group.delim === "\\vert" || group.delim === "|" ? makeText("|", "text") : makeText(group.delim, group.mode); + var middleNode = new MathNode("mo", [textNode]); + middleNode.setAttribute("fence", "true"); + // MathML gives 5/18em spacing to each element. + // \middle should get delimiter spacing instead. + middleNode.setAttribute("lspace", "0.05em"); + middleNode.setAttribute("rspace", "0.05em"); + return middleNode; + } +}); + +var htmlBuilder$7 = (group, options) => { + // \cancel, \bcancel, \xcancel, \sout, \fbox, \colorbox, \fcolorbox, \phase + // Some groups can return document fragments. Handle those by wrapping + // them in a span. + var inner = wrapFragment(buildGroup$1(group.body, options), options); + var label = group.label.slice(1); + var scale = options.sizeMultiplier; + var img; + var imgShift; + // In the LaTeX cancel package, line geometry is slightly different + // depending on whether the subject is wider than it is tall, or vice versa. + // We don't know the width of a group, so as a proxy, we test if + // the subject is a single character. This captures most of the + // subjects that should get the "tall" treatment. + var isSingleChar = isCharacterBox(group.body); + if (label === "sout") { + img = makeSpan(["stretchy", "sout"]); + img.height = options.fontMetrics().defaultRuleThickness / scale; + imgShift = -0.5 * options.fontMetrics().xHeight; + } else if (label === "phase") { + // Set a couple of dimensions from the steinmetz package. + var lineWeight = calculateSize({ + number: 0.6, + unit: "pt" + }, options); + var clearance = calculateSize({ + number: 0.35, + unit: "ex" + }, options); + // Prevent size changes like \Huge from affecting line thickness + var newOptions = options.havingBaseSizing(); + scale = scale / newOptions.sizeMultiplier; + var angleHeight = inner.height + inner.depth + lineWeight + clearance; + // Reserve a left pad for the angle. + inner.style.paddingLeft = makeEm(angleHeight / 2 + lineWeight); + // Create an SVG + var viewBoxHeight = Math.floor(1000 * angleHeight * scale); + var path = phasePath(viewBoxHeight); + var svgNode = new SvgNode([new PathNode("phase", path)], { + "width": "400em", + "height": makeEm(viewBoxHeight / 1000), + "viewBox": "0 0 400000 " + viewBoxHeight, + "preserveAspectRatio": "xMinYMin slice" + }); + // Wrap it in a span with overflow: hidden. + img = makeSvgSpan(["hide-tail"], [svgNode], options); + img.style.height = makeEm(angleHeight); + imgShift = inner.depth + lineWeight + clearance; + } else { + // Add horizontal padding + if (/cancel/.test(label)) { + if (!isSingleChar) { + inner.classes.push("cancel-pad"); + } + } else if (label === "angl") { + inner.classes.push("anglpad"); + } else { + inner.classes.push("boxpad"); + } + // Add vertical padding + var topPad; + var bottomPad; + var ruleThickness = 0; + // ref: cancel package: \advance\totalheight2\p@ % "+2" + if (/box/.test(label)) { + ruleThickness = Math.max(options.fontMetrics().fboxrule, + // default + options.minRuleThickness); + topPad = options.fontMetrics().fboxsep + (label === "colorbox" ? 0 : ruleThickness); + bottomPad = topPad; + } else if (label === "angl") { + ruleThickness = Math.max(options.fontMetrics().defaultRuleThickness, options.minRuleThickness); + topPad = 4 * ruleThickness; // gap = 3 × line, plus the line itself. + bottomPad = Math.max(0, 0.25 - inner.depth); + } else { + topPad = isSingleChar ? 0.2 : 0; + bottomPad = topPad; + } + img = stretchyEnclose(inner, label, topPad, bottomPad, options); + if (/fbox|boxed|fcolorbox/.test(label)) { + img.style.borderStyle = "solid"; + img.style.borderWidth = makeEm(ruleThickness); + } else if (label === "angl" && ruleThickness !== 0.049) { + img.style.borderTopWidth = makeEm(ruleThickness); + img.style.borderRightWidth = makeEm(ruleThickness); + } + imgShift = inner.depth + bottomPad; + if (group.backgroundColor) { + img.style.backgroundColor = group.backgroundColor; + if (group.borderColor) { + img.style.borderColor = group.borderColor; + } + } + } + var vlist; + if (group.backgroundColor) { + vlist = makeVList({ + positionType: "individualShift", + children: [ + // Put the color background behind inner; + { + type: "elem", + elem: img, + shift: imgShift + }, { + type: "elem", + elem: inner, + shift: 0 + }] + }); + } else { + var classes = /cancel|phase/.test(label) ? ["svg-align"] : []; + vlist = makeVList({ + positionType: "individualShift", + children: [ + // Write the \cancel stroke on top of inner. + { + type: "elem", + elem: inner, + shift: 0 + }, { + type: "elem", + elem: img, + shift: imgShift, + wrapperClasses: classes + }] + }); + } + if (/cancel/.test(label)) { + // The cancel package documentation says that cancel lines add their height + // to the expression, but tests show that isn't how it actually works. + vlist.height = inner.height; + vlist.depth = inner.depth; + } + if (/cancel/.test(label) && !isSingleChar) { + // cancel does not create horiz space for its line extension. + return makeSpan(["mord", "cancel-lap"], [vlist], options); + } else { + return makeSpan(["mord"], [vlist], options); + } +}; +var mathmlBuilder$6 = (group, options) => { + var fboxsep; + var node = new MathNode(group.label.includes("colorbox") ? "mpadded" : "menclose", [buildGroup(group.body, options)]); + switch (group.label) { + case "\\cancel": + node.setAttribute("notation", "updiagonalstrike"); + break; + case "\\bcancel": + node.setAttribute("notation", "downdiagonalstrike"); + break; + case "\\phase": + node.setAttribute("notation", "phasorangle"); + break; + case "\\sout": + node.setAttribute("notation", "horizontalstrike"); + break; + case "\\fbox": + node.setAttribute("notation", "box"); + break; + case "\\angl": + node.setAttribute("notation", "actuarial"); + break; + case "\\fcolorbox": + case "\\colorbox": + // doesn't have a good notation option. So use + // instead. Set some attributes that come included with . + fboxsep = options.fontMetrics().fboxsep * options.fontMetrics().ptPerEm; + node.setAttribute("width", "+" + 2 * fboxsep + "pt"); + node.setAttribute("height", "+" + 2 * fboxsep + "pt"); + node.setAttribute("lspace", fboxsep + "pt"); // + node.setAttribute("voffset", fboxsep + "pt"); + if (group.label === "\\fcolorbox") { + var thk = Math.max(options.fontMetrics().fboxrule, + // default + options.minRuleThickness); + node.setAttribute("style", "border: " + makeEm(thk) + " solid " + group.borderColor); + } + break; + case "\\xcancel": + node.setAttribute("notation", "updiagonalstrike downdiagonalstrike"); + break; + } + if (group.backgroundColor) { + node.setAttribute("mathbackground", group.backgroundColor); + } + return node; +}; +defineFunction({ + type: "enclose", + names: ["\\colorbox"], + numArgs: 2, + allowedInText: true, + argTypes: ["color", "hbox"], + handler(_ref, args, optArgs) { + var { + parser, + funcName + } = _ref; + var color = assertNodeType(args[0], "color-token").color; + var body = args[1]; + return { + type: "enclose", + mode: parser.mode, + label: funcName, + backgroundColor: color, + body + }; + }, + htmlBuilder: htmlBuilder$7, + mathmlBuilder: mathmlBuilder$6 +}); +defineFunction({ + type: "enclose", + names: ["\\fcolorbox"], + numArgs: 3, + allowedInText: true, + argTypes: ["color", "color", "hbox"], + handler(_ref2, args, optArgs) { + var { + parser, + funcName + } = _ref2; + var borderColor = assertNodeType(args[0], "color-token").color; + var backgroundColor = assertNodeType(args[1], "color-token").color; + var body = args[2]; + return { + type: "enclose", + mode: parser.mode, + label: funcName, + backgroundColor, + borderColor, + body + }; + } +}); +defineFunction({ + type: "enclose", + names: ["\\fbox"], + numArgs: 1, + argTypes: ["hbox"], + allowedInText: true, + handler(_ref3, args) { + var { + parser + } = _ref3; + return { + type: "enclose", + mode: parser.mode, + label: "\\fbox", + body: args[0] + }; + } +}); +defineFunction({ + type: "enclose", + names: ["\\cancel", "\\bcancel", "\\xcancel", "\\phase"], + numArgs: 1, + handler(_ref4, args) { + var { + parser, + funcName + } = _ref4; + var body = args[0]; + return { + type: "enclose", + mode: parser.mode, + label: funcName, + body + }; + } +}); +defineFunction({ + type: "enclose", + names: ["\\sout"], + numArgs: 1, + allowedInText: true, + handler(_ref5, args) { + var { + parser, + funcName + } = _ref5; + if (parser.mode === "math") { + parser.settings.reportNonstrict("mathVsSout", "LaTeX's \\sout works only in text mode"); + } + var body = args[0]; + return { + type: "enclose", + mode: parser.mode, + label: funcName, + body + }; + } +}); +defineFunction({ + type: "enclose", + names: ["\\angl"], + numArgs: 1, + argTypes: ["hbox"], + allowedInText: false, + handler(_ref6, args) { + var { + parser + } = _ref6; + return { + type: "enclose", + mode: parser.mode, + label: "\\angl", + body: args[0] + }; + } +}); + +/** + * All registered environments. + * `environments.js` exports this same dictionary again and makes it public. + * `Parser.js` requires this dictionary via `environments.js`. + */ +var _environments = {}; +function defineEnvironment(_ref) { + var { + type, + names, + props, + handler, + htmlBuilder, + mathmlBuilder + } = _ref; + // Set default values of environments. + var data = { + type, + numArgs: props.numArgs || 0, + allowedInText: false, + numOptionalArgs: 0, + handler + }; + for (var i = 0; i < names.length; ++i) { + // TODO: The value type of _environments should be a type union of all + // possible `EnvSpec<>` possibilities instead of `EnvSpec<*>`, which is + // an existential type. + _environments[names[i]] = data; + } + if (htmlBuilder) { + _htmlGroupBuilders[type] = htmlBuilder; + } + if (mathmlBuilder) { + _mathmlGroupBuilders[type] = mathmlBuilder; + } +} + +/** + * All registered global/built-in macros. + * `macros.js` exports this same dictionary again and makes it public. + * `Parser.js` requires this dictionary via `macros.js`. + */ +var _macros = {}; +// This function might one day accept an additional argument and do more things. +function defineMacro(name, body) { + _macros[name] = body; +} + +/** + * Lexing or parsing positional information for error reporting. + * This object is immutable. + */ +class SourceLocation { + // End offset, zero-based exclusive. + constructor(lexer, start, end) { + // The + prefix indicates that these fields aren't writeable + this.lexer = void 0; + // Lexer holding the input string. + this.start = void 0; + // Start offset, zero-based inclusive. + this.end = void 0; + this.lexer = lexer; + this.start = start; + this.end = end; + } + /** + * Merges two `SourceLocation`s from location providers, given they are + * provided in order of appearance. + * - Returns the first one's location if only the first is provided. + * - Returns a merged range of the first and the last if both are provided + * and their lexers match. + * - Otherwise, returns null. + */ + static range(first, second) { + if (!second) { + return first && first.loc; + } else if (!first || !first.loc || !second.loc || first.loc.lexer !== second.loc.lexer) { + return null; + } else { + return new SourceLocation(first.loc.lexer, first.loc.start, second.loc.end); + } + } +} + +/** + * The resulting token returned from `lex`. + * + * It consists of the token text plus some position information. + * The position information is essentially a range in an input string, + * but instead of referencing the bare input string, we refer to the lexer. + * That way it is possible to attach extra metadata to the input string, + * like for example a file name or similar. + * + * The position information is optional, so it is OK to construct synthetic + * tokens if appropriate. Not providing available position information may + * lead to degraded error reporting, though. + */ +class Token { + // used in \noexpand + constructor(text, + // the text of this token + loc) { + this.text = void 0; + this.loc = void 0; + this.noexpand = void 0; + // don't expand the token + this.treatAsRelax = void 0; + this.text = text; + this.loc = loc; + } + /** + * Given a pair of tokens (this and endToken), compute a `Token` encompassing + * the whole input range enclosed by these two. + */ + range(endToken, + // last token of the range, inclusive + text) { + return new Token(text, SourceLocation.range(this, endToken)); + } +} + +// Helper functions +function getHLines(parser) { + // Return an array. The array length = number of hlines. + // Each element in the array tells if the line is dashed. + var hlineInfo = []; + parser.consumeSpaces(); + var nxt = parser.fetch().text; + if (nxt === "\\relax") { + // \relax is an artifact of the \cr macro below + parser.consume(); + parser.consumeSpaces(); + nxt = parser.fetch().text; + } + while (nxt === "\\hline" || nxt === "\\hdashline") { + parser.consume(); + hlineInfo.push(nxt === "\\hdashline"); + parser.consumeSpaces(); + nxt = parser.fetch().text; + } + return hlineInfo; +} +var validateAmsEnvironmentContext = context => { + var settings = context.parser.settings; + if (!settings.displayMode) { + throw new ParseError("{" + context.envName + "} can be used only in" + " display mode."); + } +}; +var gatherEnvironments = new Set(["gather", "gather*"]); +// autoTag (an argument to parseArray) can be one of three values: +// * undefined: Regular (not-top-level) array; no tags on each row +// * true: Automatic equation numbering, overridable by \tag +// * false: Tags allowed on each row, but no automatic numbering +// This function *doesn't* work with the "split" environment name. +function getAutoTag(name) { + if (!name.includes("ed")) { + return !name.includes("*"); + } + // return undefined; +} +/** + * Parse the body of the environment, with rows delimited by \\ and + * columns delimited by &, and create a nested list in row-major order + * with one group per cell. If given an optional argument style + * ("text", "display", etc.), then each cell is cast into that style. + */ +function parseArray(parser, _ref, style) { + var { + hskipBeforeAndAfter, + addJot, + cols, + arraystretch, + colSeparationType, + autoTag, + singleRow, + emptySingleRow, + maxNumCols, + leqno + } = _ref; + parser.gullet.beginGroup(); + if (!singleRow) { + // \cr is equivalent to \\ without the optional size argument (see below) + // TODO: provide helpful error when \cr is used outside array environment + parser.gullet.macros.set("\\cr", "\\\\\\relax"); + } + // Get current arraystretch if it's not set by the environment + if (!arraystretch) { + var stretch = parser.gullet.expandMacroAsText("\\arraystretch"); + if (stretch == null) { + // Default \arraystretch from lttab.dtx + arraystretch = 1; + } else { + arraystretch = parseFloat(stretch); + if (!arraystretch || arraystretch < 0) { + throw new ParseError("Invalid \\arraystretch: " + stretch); + } + } + } + // Start group for first cell + parser.gullet.beginGroup(); + var row = []; + var body = [row]; + var rowGaps = []; + var hLinesBeforeRow = []; + var tags = autoTag != null ? [] : undefined; + // amsmath uses \global\@eqnswtrue and \global\@eqnswfalse to represent + // whether this row should have an equation number. Simulate this with + // a \@eqnsw macro set to 1 or 0. + function beginRow() { + if (autoTag) { + parser.gullet.macros.set("\\@eqnsw", "1", true); + } + } + function endRow() { + if (tags) { + if (parser.gullet.macros.get("\\df@tag")) { + tags.push(parser.subparse([new Token("\\df@tag")])); + parser.gullet.macros.set("\\df@tag", undefined, true); + } else { + tags.push(Boolean(autoTag) && parser.gullet.macros.get("\\@eqnsw") === "1"); + } + } + } + beginRow(); + // Test for \hline at the top of the array. + hLinesBeforeRow.push(getHLines(parser)); + while (true) { + // Parse each cell in its own group (namespace) + var cellBody = parser.parseExpression(false, singleRow ? "\\end" : "\\\\"); + parser.gullet.endGroup(); + parser.gullet.beginGroup(); + var cell = { + type: "ordgroup", + mode: parser.mode, + body: cellBody + }; + if (style) { + cell = { + type: "styling", + mode: parser.mode, + style, + resetFont: true, + body: [cell] + }; + } + row.push(cell); + var next = parser.fetch().text; + if (next === "&") { + if (maxNumCols && row.length === maxNumCols) { + if (singleRow || colSeparationType) { + // {equation} or {split} + throw new ParseError("Too many tab characters: &", parser.nextToken); + } else { + // {array} environment + parser.settings.reportNonstrict("textEnv", "Too few columns " + "specified in the {array} column argument."); + } + } + parser.consume(); + } else if (next === "\\end") { + endRow(); + // Arrays terminate newlines with `\crcr` which consumes a `\cr` if + // the last line is empty. However, AMS environments keep the + // empty row if it's the only one. + // NOTE: Currently, `cell` is the last item added into `row`. + if (row.length === 1 && cell.type === "styling" && cell.body.length === 1 && cell.body[0].type === "ordgroup" && cell.body[0].body.length === 0 && (body.length > 1 || !emptySingleRow)) { + body.pop(); + } + if (hLinesBeforeRow.length < body.length + 1) { + hLinesBeforeRow.push([]); + } + break; + } else if (next === "\\\\") { + parser.consume(); + var size = void 0; + // \def\Let@{\let\\\math@cr} + // \def\math@cr{...\math@cr@} + // \def\math@cr@{\new@ifnextchar[\math@cr@@{\math@cr@@[\z@]}} + // \def\math@cr@@[#1]{...\math@cr@@@...} + // \def\math@cr@@@{\cr} + if (parser.gullet.future().text !== " ") { + size = parser.parseSizeGroup(true); + } + rowGaps.push(size ? size.value : null); + endRow(); + // check for \hline(s) following the row separator + hLinesBeforeRow.push(getHLines(parser)); + row = []; + body.push(row); + beginRow(); + } else { + throw new ParseError("Expected & or \\\\ or \\cr or \\end", parser.nextToken); + } + } + // End cell group + parser.gullet.endGroup(); + // End array group defining \cr + parser.gullet.endGroup(); + return { + type: "array", + mode: parser.mode, + addJot, + arraystretch, + body, + cols, + rowGaps, + hskipBeforeAndAfter, + hLinesBeforeRow, + colSeparationType, + tags, + leqno + }; +} +// Decides on a style for cells in an array according to whether the given +// environment name starts with the letter 'd'. +function dCellStyle(envName) { + if (envName.slice(0, 1) === "d") { + return "display"; + } else { + return "text"; + } +} +var htmlBuilder$6 = function htmlBuilder(group, options) { + var r; + var c; + var nr = group.body.length; + var hLinesBeforeRow = group.hLinesBeforeRow; + var nc = 0; + var body = new Array(nr); + var hlines = []; + var ruleThickness = Math.max( + // From LaTeX \showthe\arrayrulewidth. Equals 0.04 em. + options.fontMetrics().arrayRuleWidth, options.minRuleThickness); + // Horizontal spacing + var pt = 1 / options.fontMetrics().ptPerEm; + var arraycolsep = 5 * pt; // default value, i.e. \arraycolsep in article.cls + if (group.colSeparationType && group.colSeparationType === "small") { + // We're in a {smallmatrix}. Default column space is \thickspace, + // i.e. 5/18em = 0.2778em, per amsmath.dtx for {smallmatrix}. + // But that needs adjustment because LaTeX applies \scriptstyle to the + // entire array, including the colspace, but this function applies + // \scriptstyle only inside each element. + var localMultiplier = options.havingStyle(Style$1.SCRIPT).sizeMultiplier; + arraycolsep = 0.2778 * (localMultiplier / options.sizeMultiplier); + } + // Vertical spacing + var baselineskip = group.colSeparationType === "CD" ? calculateSize({ + number: 3, + unit: "ex" + }, options) : 12 * pt; // see size10.clo + // Default \jot from ltmath.dtx + // TODO(edemaine): allow overriding \jot via \setlength (#687) + var jot = 3 * pt; + var arrayskip = group.arraystretch * baselineskip; + var arstrutHeight = 0.7 * arrayskip; // \strutbox in ltfsstrc.dtx and + var arstrutDepth = 0.3 * arrayskip; // \@arstrutbox in lttab.dtx + var totalHeight = 0; + // Set a position for \hline(s) at the top of the array, if any. + function setHLinePos(hlinesInGap) { + for (var i = 0; i < hlinesInGap.length; ++i) { + if (i > 0) { + totalHeight += 0.25; + } + hlines.push({ + pos: totalHeight, + isDashed: hlinesInGap[i] + }); + } + } + setHLinePos(hLinesBeforeRow[0]); + for (r = 0; r < group.body.length; ++r) { + var inrow = group.body[r]; + var height = arstrutHeight; // \@array adds an \@arstrut + var depth = arstrutDepth; // to each tow (via the template) + if (nc < inrow.length) { + nc = inrow.length; + } + var outrow = { + cells: new Array(inrow.length), + height: 0, + depth: 0, + pos: 0 + }; + for (c = 0; c < inrow.length; ++c) { + var elt = buildGroup$1(inrow[c], options); + if (depth < elt.depth) { + depth = elt.depth; + } + if (height < elt.height) { + height = elt.height; + } + outrow.cells[c] = elt; + } + var rowGap = group.rowGaps[r]; + var gap = 0; + if (rowGap) { + gap = calculateSize(rowGap, options); + if (gap > 0) { + // \@argarraycr + gap += arstrutDepth; + if (depth < gap) { + depth = gap; // \@xargarraycr + } + gap = 0; + } + } + // In AMS multiline environments such as aligned and gathered, rows + // correspond to lines that have additional \jot added between lines + // via \openup. + // We simulate this by adding \jot depth to each row except the last. + if (group.addJot && r < group.body.length - 1) { + depth += jot; + } + outrow.height = height; + outrow.depth = depth; + totalHeight += height; + outrow.pos = totalHeight; + totalHeight += depth + gap; // \@yargarraycr + body[r] = outrow; + // Set a position for \hline(s), if any. + setHLinePos(hLinesBeforeRow[r + 1]); + } + var offset = totalHeight / 2 + options.fontMetrics().axisHeight; + var colDescriptions = group.cols || []; + var cols = []; + var colSep; + var colDescrNum; + var tagSpans = []; + if (group.tags && group.tags.some(tag => tag)) { + // An environment with manual tags and/or automatic equation numbers. + // Create node(s), the latter of which trigger CSS counter increment. + for (r = 0; r < nr; ++r) { + var rw = body[r]; + var shift = rw.pos - offset; + var tag = group.tags[r]; + var tagSpan = void 0; + if (tag === true) { + // automatic numbering + tagSpan = makeSpan(["eqn-num"], [], options); + } else if (tag === false) { + // \nonumber/\notag or starred environment + tagSpan = makeSpan([], [], options); + } else { + // manual \tag + tagSpan = makeSpan([], buildExpression$1(tag, options, true), options); + } + tagSpan.depth = rw.depth; + tagSpan.height = rw.height; + tagSpans.push({ + type: "elem", + elem: tagSpan, + shift + }); + } + } + for (c = 0, colDescrNum = 0; + // Continue while either there are more columns or more column + // descriptions, so trailing separators don't get lost. + c < nc || colDescrNum < colDescriptions.length; ++c, ++colDescrNum) { + var _colDescr3; + var colDescr = colDescriptions[colDescrNum]; + var firstSeparator = true; + while (((_colDescr = colDescr) == null ? void 0 : _colDescr.type) === "separator") { + var _colDescr; + // If there is more than one separator in a row, add a space + // between them. + if (!firstSeparator) { + colSep = makeSpan(["arraycolsep"], []); + colSep.style.width = makeEm(options.fontMetrics().doubleRuleSep); + cols.push(colSep); + } + if (colDescr.separator === "|" || colDescr.separator === ":") { + var lineType = colDescr.separator === "|" ? "solid" : "dashed"; + var separator = makeSpan(["vertical-separator"], [], options); + separator.style.height = makeEm(totalHeight); + separator.style.borderRightWidth = makeEm(ruleThickness); + separator.style.borderRightStyle = lineType; + separator.style.margin = "0 " + makeEm(-ruleThickness / 2); + var _shift = totalHeight - offset; + if (_shift) { + separator.style.verticalAlign = makeEm(-_shift); + } + cols.push(separator); + } else { + throw new ParseError("Invalid separator type: " + colDescr.separator); + } + colDescrNum++; + colDescr = colDescriptions[colDescrNum]; + firstSeparator = false; + } + if (c >= nc) { + continue; + } + var sepwidth = void 0; + if (c > 0 || group.hskipBeforeAndAfter) { + var _colDescr$pregap, _colDescr2; + sepwidth = (_colDescr$pregap = (_colDescr2 = colDescr) == null ? void 0 : _colDescr2.pregap) != null ? _colDescr$pregap : arraycolsep; + if (sepwidth !== 0) { + colSep = makeSpan(["arraycolsep"], []); + colSep.style.width = makeEm(sepwidth); + cols.push(colSep); + } + } + var colElems = []; + for (r = 0; r < nr; ++r) { + var row = body[r]; + var elem = row.cells[c]; + if (!elem) { + continue; + } + var _shift2 = row.pos - offset; + elem.depth = row.depth; + elem.height = row.height; + colElems.push({ + type: "elem", + elem: elem, + shift: _shift2 + }); + } + var colVList = makeVList({ + positionType: "individualShift", + children: colElems + }); + var colSpan = makeSpan(["col-align-" + (((_colDescr3 = colDescr) == null ? void 0 : _colDescr3.align) || "c")], [colVList]); + cols.push(colSpan); + if (c < nc - 1 || group.hskipBeforeAndAfter) { + var _colDescr$postgap, _colDescr4; + sepwidth = (_colDescr$postgap = (_colDescr4 = colDescr) == null ? void 0 : _colDescr4.postgap) != null ? _colDescr$postgap : arraycolsep; + if (sepwidth !== 0) { + colSep = makeSpan(["arraycolsep"], []); + colSep.style.width = makeEm(sepwidth); + cols.push(colSep); + } + } + } + var tableBody = makeSpan(["mtable"], cols); + // Add \hline(s), if any. + if (hlines.length > 0) { + var line = makeLineSpan("hline", options, ruleThickness); + var dashes = makeLineSpan("hdashline", options, ruleThickness); + var vListElems = [{ + type: "elem", + elem: tableBody, + shift: 0 + }]; + while (hlines.length > 0) { + var hline = hlines.pop(); + var lineShift = hline.pos - offset; + if (hline.isDashed) { + vListElems.push({ + type: "elem", + elem: dashes, + shift: lineShift + }); + } else { + vListElems.push({ + type: "elem", + elem: line, + shift: lineShift + }); + } + } + tableBody = makeVList({ + positionType: "individualShift", + children: vListElems + }); + } + if (tagSpans.length === 0) { + return makeSpan(["mord"], [tableBody], options); + } else { + var eqnNumCol = makeVList({ + positionType: "individualShift", + children: tagSpans + }); + var tagCol = makeSpan(["tag"], [eqnNumCol], options); + return makeFragment([tableBody, tagCol]); + } +}; +var alignMap = { + c: "center ", + l: "left ", + r: "right " +}; +var mathmlBuilder$5 = function mathmlBuilder(group, options) { + var tbl = []; + var glue = new MathNode("mtd", [], ["mtr-glue"]); + var tag = new MathNode("mtd", [], ["mml-eqn-num"]); + for (var i = 0; i < group.body.length; i++) { + var rw = group.body[i]; + var row = []; + for (var j = 0; j < rw.length; j++) { + row.push(new MathNode("mtd", [buildGroup(rw[j], options)])); + } + if (group.tags && group.tags[i]) { + row.unshift(glue); + row.push(glue); + if (group.leqno) { + row.unshift(tag); + } else { + row.push(tag); + } + } + tbl.push(new MathNode("mtr", row)); + } + var table = new MathNode("mtable", tbl); + // Set column alignment, row spacing, column spacing, and + // array lines by setting attributes on the table element. + // Set the row spacing. In MathML, we specify a gap distance. + // We do not use rowGap[] because MathML automatically increases + // cell height with the height/depth of the element content. + // LaTeX \arraystretch multiplies the row baseline-to-baseline distance. + // We simulate this by adding (arraystretch - 1)em to the gap. This + // does a reasonable job of adjusting arrays containing 1 em tall content. + // The 0.16 and 0.09 values are found empirically. They produce an array + // similar to LaTeX and in which content does not interfere with \hlines. + var gap = group.arraystretch === 0.5 ? 0.1 // {smallmatrix}, {subarray} + : 0.16 + group.arraystretch - 1 + (group.addJot ? 0.09 : 0); + table.setAttribute("rowspacing", makeEm(gap)); + // MathML table lines go only between cells. + // To place a line on an edge we'll use , if necessary. + var menclose = ""; + var align = ""; + if (group.cols && group.cols.length > 0) { + // Find column alignment, column spacing, and vertical lines. + var cols = group.cols; + var columnLines = ""; + var prevTypeWasAlign = false; + var iStart = 0; + var iEnd = cols.length; + if (cols[0].type === "separator") { + menclose += "top "; + iStart = 1; + } + if (cols[cols.length - 1].type === "separator") { + menclose += "bottom "; + iEnd -= 1; + } + for (var _i = iStart; _i < iEnd; _i++) { + var col = cols[_i]; + if (col.type === "align") { + align += alignMap[col.align]; + if (prevTypeWasAlign) { + columnLines += "none "; + } + prevTypeWasAlign = true; + } else if (col.type === "separator") { + // MathML accepts only single lines between cells. + // So we read only the first of consecutive separators. + if (prevTypeWasAlign) { + columnLines += col.separator === "|" ? "solid " : "dashed "; + prevTypeWasAlign = false; + } + } + } + table.setAttribute("columnalign", align.trim()); + if (/[sd]/.test(columnLines)) { + table.setAttribute("columnlines", columnLines.trim()); + } + } + // Set column spacing. + if (group.colSeparationType === "align") { + var _cols = group.cols || []; + var spacing = ""; + for (var _i2 = 1; _i2 < _cols.length; _i2++) { + spacing += _i2 % 2 ? "0em " : "1em "; + } + table.setAttribute("columnspacing", spacing.trim()); + } else if (group.colSeparationType === "alignat" || group.colSeparationType === "gather") { + table.setAttribute("columnspacing", "0em"); + } else if (group.colSeparationType === "small") { + table.setAttribute("columnspacing", "0.2778em"); + } else if (group.colSeparationType === "CD") { + table.setAttribute("columnspacing", "0.5em"); + } else { + table.setAttribute("columnspacing", "1em"); + } + // Address \hline and \hdashline + var rowLines = ""; + var hlines = group.hLinesBeforeRow; + menclose += hlines[0].length > 0 ? "left " : ""; + menclose += hlines[hlines.length - 1].length > 0 ? "right " : ""; + for (var _i3 = 1; _i3 < hlines.length - 1; _i3++) { + rowLines += hlines[_i3].length === 0 ? "none " + // MathML accepts only a single line between rows. Read one element. + : hlines[_i3][0] ? "dashed " : "solid "; + } + if (/[sd]/.test(rowLines)) { + table.setAttribute("rowlines", rowLines.trim()); + } + if (menclose !== "") { + table = new MathNode("menclose", [table]); + table.setAttribute("notation", menclose.trim()); + } + if (group.arraystretch && group.arraystretch < 1) { + // A small array. Wrap in scriptstyle so row gap is not too large. + table = new MathNode("mstyle", [table]); + table.setAttribute("scriptlevel", "1"); + } + return table; +}; +// Convenience function for align, align*, aligned, alignat, alignat*, alignedat. +var alignedHandler = function alignedHandler(context, args) { + if (!context.envName.includes("ed")) { + validateAmsEnvironmentContext(context); + } + var cols = []; + var isSplit = context.envName === "split"; + var res = parseArray(context.parser, { + cols, + addJot: true, + autoTag: isSplit ? undefined : getAutoTag(context.envName), + emptySingleRow: true, + colSeparationType: context.envName.includes("at") ? "alignat" : "align", + maxNumCols: isSplit ? 2 : undefined, + leqno: context.parser.settings.leqno + }, "display"); + // Determining number of columns. + // 1. If the first argument is given, we use it as a number of columns, + // and makes sure that each row doesn't exceed that number. + // 2. Otherwise, just count number of columns = maximum number + // of cells in each row ("aligned" mode -- isAligned will be true). + // + // At the same time, prepend empty group {} at beginning of every second + // cell in each row (starting with second cell) so that operators become + // binary. This behavior is implemented in amsmath's \start@aligned. + var numMaths = 0; + var numCols = 0; + var emptyGroup = { + type: "ordgroup", + mode: context.mode, + body: [] + }; + if (args[0] && args[0].type === "ordgroup") { + var arg0 = ""; + for (var i = 0; i < args[0].body.length; i++) { + var textord = assertNodeType(args[0].body[i], "textord"); + arg0 += textord.text; + } + numMaths = Number(arg0); + numCols = numMaths * 2; + } + var isAligned = !numCols; + res.body.forEach(function (row) { + for (var _i4 = 1; _i4 < row.length; _i4 += 2) { + // Modify ordgroup node within styling node + var styling = assertNodeType(row[_i4], "styling"); + var ordgroup = assertNodeType(styling.body[0], "ordgroup"); + ordgroup.body.unshift(emptyGroup); + } + if (!isAligned) { + // Case 1 + var curMaths = row.length / 2; + if (numMaths < curMaths) { + throw new ParseError("Too many math in a row: " + ("expected " + numMaths + ", but got " + curMaths), row[0]); + } + } else if (numCols < row.length) { + // Case 2 + numCols = row.length; + } + }); + // Adjusting alignment. + // In aligned mode, we add one \qquad between columns; + // otherwise we add nothing. + for (var _i5 = 0; _i5 < numCols; ++_i5) { + var align = "r"; + var pregap = 0; + if (_i5 % 2 === 1) { + align = "l"; + } else if (_i5 > 0 && isAligned) { + // "aligned" mode. + pregap = 1; // add one \quad + } + cols[_i5] = { + type: "align", + align: align, + pregap: pregap, + postgap: 0 + }; + } + res.colSeparationType = isAligned ? "align" : "alignat"; + return res; +}; +// Arrays are part of LaTeX, defined in lttab.dtx so its documentation +// is part of the source2e.pdf file of LaTeX2e source documentation. +// {darray} is an {array} environment where cells are set in \displaystyle, +// as defined in nccmath.sty. +defineEnvironment({ + type: "array", + names: ["array", "darray"], + props: { + numArgs: 1 + }, + handler(context, args) { + // Since no types are specified above, the two possibilities are + // - The argument is wrapped in {} or [], in which case Parser's + // parseGroup() returns an "ordgroup" wrapping some symbol node. + // - The argument is a bare symbol node. + var symNode = checkSymbolNodeType(args[0]); + var colalign = symNode ? [args[0]] : assertNodeType(args[0], "ordgroup").body; + var cols = colalign.map(function (nde) { + var node = assertSymbolNodeType(nde); + var ca = node.text; + if ("lcr".includes(ca)) { + return { + type: "align", + align: ca + }; + } else if (ca === "|") { + return { + type: "separator", + separator: "|" + }; + } else if (ca === ":") { + return { + type: "separator", + separator: ":" + }; + } + throw new ParseError("Unknown column alignment: " + ca, nde); + }); + var res = { + cols, + hskipBeforeAndAfter: true, + // \@preamble in lttab.dtx + maxNumCols: cols.length + }; + return parseArray(context.parser, res, dCellStyle(context.envName)); + }, + htmlBuilder: htmlBuilder$6, + mathmlBuilder: mathmlBuilder$5 +}); +// The matrix environments of amsmath builds on the array environment +// of LaTeX, which is discussed above. +// The mathtools package adds starred versions of the same environments. +// These have an optional argument to choose left|center|right justification. +defineEnvironment({ + type: "array", + names: ["matrix", "pmatrix", "bmatrix", "Bmatrix", "vmatrix", "Vmatrix", "matrix*", "pmatrix*", "bmatrix*", "Bmatrix*", "vmatrix*", "Vmatrix*"], + props: { + numArgs: 0 + }, + handler(context) { + var delimiters = { + "matrix": null, + "pmatrix": ["(", ")"], + "bmatrix": ["[", "]"], + "Bmatrix": ["\\{", "\\}"], + "vmatrix": ["|", "|"], + "Vmatrix": ["\\Vert", "\\Vert"] + }[context.envName.replace("*", "")]; + // \hskip -\arraycolsep in amsmath + var colAlign = "c"; + var payload = { + hskipBeforeAndAfter: false, + cols: [{ + type: "align", + align: colAlign + }] + }; + if (context.envName.charAt(context.envName.length - 1) === "*") { + // It's one of the mathtools starred functions. + // Parse the optional alignment argument. + var parser = context.parser; + parser.consumeSpaces(); + if (parser.fetch().text === "[") { + parser.consume(); + parser.consumeSpaces(); + colAlign = parser.fetch().text; + if (!"lcr".includes(colAlign)) { + throw new ParseError("Expected l or c or r", parser.nextToken); + } + parser.consume(); + parser.consumeSpaces(); + parser.expect("]"); + parser.consume(); + payload.cols = [{ + type: "align", + align: colAlign + }]; + } + } + var res = parseArray(context.parser, payload, dCellStyle(context.envName)); + // Populate cols with the correct number of column alignment specs. + var numCols = Math.max(0, ...res.body.map(row => row.length)); + res.cols = new Array(numCols).fill({ + type: "align", + align: colAlign + }); + return delimiters ? { + type: "leftright", + mode: context.mode, + body: [res], + left: delimiters[0], + right: delimiters[1], + rightColor: undefined // \right uninfluenced by \color in array + } : res; + }, + htmlBuilder: htmlBuilder$6, + mathmlBuilder: mathmlBuilder$5 +}); +defineEnvironment({ + type: "array", + names: ["smallmatrix"], + props: { + numArgs: 0 + }, + handler(context) { + var payload = { + arraystretch: 0.5 + }; + var res = parseArray(context.parser, payload, "script"); + res.colSeparationType = "small"; + return res; + }, + htmlBuilder: htmlBuilder$6, + mathmlBuilder: mathmlBuilder$5 +}); +defineEnvironment({ + type: "array", + names: ["subarray"], + props: { + numArgs: 1 + }, + handler(context, args) { + // Parsing of {subarray} is similar to {array} + var symNode = checkSymbolNodeType(args[0]); + var colalign = symNode ? [args[0]] : assertNodeType(args[0], "ordgroup").body; + var cols = colalign.map(function (nde) { + var node = assertSymbolNodeType(nde); + var ca = node.text; + // {subarray} only recognizes "l" & "c" + if ("lc".includes(ca)) { + return { + type: "align", + align: ca + }; + } + throw new ParseError("Unknown column alignment: " + ca, nde); + }); + if (cols.length > 1) { + throw new ParseError("{subarray} can contain only one column"); + } + var payload = { + cols, + hskipBeforeAndAfter: false, + arraystretch: 0.5 + }; + var res = parseArray(context.parser, payload, "script"); + if (res.body.length > 0 && res.body[0].length > 1) { + throw new ParseError("{subarray} can contain only one column"); + } + return res; + }, + htmlBuilder: htmlBuilder$6, + mathmlBuilder: mathmlBuilder$5 +}); +// A cases environment (in amsmath.sty) is almost equivalent to +// \def\arraystretch{1.2}% +// \left\{\begin{array}{@{}l@{\quad}l@{}} … \end{array}\right. +// {dcases} is a {cases} environment where cells are set in \displaystyle, +// as defined in mathtools.sty. +// {rcases} is another mathtools environment. It's brace is on the right side. +defineEnvironment({ + type: "array", + names: ["cases", "dcases", "rcases", "drcases"], + props: { + numArgs: 0 + }, + handler(context) { + var payload = { + arraystretch: 1.2, + cols: [{ + type: "align", + align: "l", + pregap: 0, + // TODO(kevinb) get the current style. + // For now we use the metrics for TEXT style which is what we were + // doing before. Before attempting to get the current style we + // should look at TeX's behavior especially for \over and matrices. + postgap: 1.0 /* 1em quad */ + }, { + type: "align", + align: "l", + pregap: 0, + postgap: 0 + }] + }; + var res = parseArray(context.parser, payload, dCellStyle(context.envName)); + return { + type: "leftright", + mode: context.mode, + body: [res], + left: context.envName.includes("r") ? "." : "\\{", + right: context.envName.includes("r") ? "\\}" : ".", + rightColor: undefined + }; + }, + htmlBuilder: htmlBuilder$6, + mathmlBuilder: mathmlBuilder$5 +}); +// In the align environment, one uses ampersands, &, to specify number of +// columns in each row, and to locate spacing between each column. +// align gets automatic numbering. align* and aligned do not. +// The alignedat environment can be used in math mode. +// Note that we assume \nomallineskiplimit to be zero, +// so that \strut@ is the same as \strut. +defineEnvironment({ + type: "array", + names: ["align", "align*", "aligned", "split"], + props: { + numArgs: 0 + }, + handler: alignedHandler, + htmlBuilder: htmlBuilder$6, + mathmlBuilder: mathmlBuilder$5 +}); +// A gathered environment is like an array environment with one centered +// column, but where rows are considered lines so get \jot line spacing +// and contents are set in \displaystyle. +defineEnvironment({ + type: "array", + names: ["gathered", "gather", "gather*"], + props: { + numArgs: 0 + }, + handler(context) { + if (gatherEnvironments.has(context.envName)) { + validateAmsEnvironmentContext(context); + } + var res = { + cols: [{ + type: "align", + align: "c" + }], + addJot: true, + colSeparationType: "gather", + autoTag: getAutoTag(context.envName), + emptySingleRow: true, + leqno: context.parser.settings.leqno + }; + return parseArray(context.parser, res, "display"); + }, + htmlBuilder: htmlBuilder$6, + mathmlBuilder: mathmlBuilder$5 +}); +// alignat environment is like an align environment, but one must explicitly +// specify maximum number of columns in each row, and can adjust spacing between +// each columns. +defineEnvironment({ + type: "array", + names: ["alignat", "alignat*", "alignedat"], + props: { + numArgs: 1 + }, + handler: alignedHandler, + htmlBuilder: htmlBuilder$6, + mathmlBuilder: mathmlBuilder$5 +}); +defineEnvironment({ + type: "array", + names: ["equation", "equation*"], + props: { + numArgs: 0 + }, + handler(context) { + validateAmsEnvironmentContext(context); + var res = { + autoTag: getAutoTag(context.envName), + emptySingleRow: true, + singleRow: true, + maxNumCols: 1, + leqno: context.parser.settings.leqno + }; + return parseArray(context.parser, res, "display"); + }, + htmlBuilder: htmlBuilder$6, + mathmlBuilder: mathmlBuilder$5 +}); +defineEnvironment({ + type: "array", + names: ["CD"], + props: { + numArgs: 0 + }, + handler(context) { + validateAmsEnvironmentContext(context); + return parseCD(context.parser); + }, + htmlBuilder: htmlBuilder$6, + mathmlBuilder: mathmlBuilder$5 +}); +defineMacro("\\nonumber", "\\gdef\\@eqnsw{0}"); +defineMacro("\\notag", "\\nonumber"); +// Catch \hline outside array environment +defineFunction({ + type: "text", + // Doesn't matter what this is. + names: ["\\hline", "\\hdashline"], + numArgs: 0, + allowedInText: true, + allowedInMath: true, + handler(context, args) { + throw new ParseError(context.funcName + " valid only within array environment"); + } +}); + +var environments = _environments; + +// Environment delimiters. HTML/MathML rendering is defined in the corresponding +// defineEnvironment definitions. +defineFunction({ + type: "environment", + names: ["\\begin", "\\end"], + numArgs: 1, + argTypes: ["text"], + handler(_ref, args) { + var { + parser, + funcName + } = _ref; + var nameGroup = args[0]; + if (nameGroup.type !== "ordgroup") { + throw new ParseError("Invalid environment name", nameGroup); + } + var envName = ""; + for (var i = 0; i < nameGroup.body.length; ++i) { + envName += assertNodeType(nameGroup.body[i], "textord").text; + } + if (funcName === "\\begin") { + // begin...end is similar to left...right + if (!environments.hasOwnProperty(envName)) { + throw new ParseError("No such environment: " + envName, nameGroup); + } + // Build the environment object. Arguments and other information will + // be made available to the begin and end methods using properties. + var env = environments[envName]; + var { + args: _args, + optArgs + } = parser.parseArguments("\\begin{" + envName + "}", env); + var context = { + mode: parser.mode, + envName, + parser + }; + var result = env.handler(context, _args, optArgs); + parser.expect("\\end", false); + var endNameToken = parser.nextToken; + var end = assertNodeType(parser.parseFunction(), "environment"); + if (end.name !== envName) { + throw new ParseError("Mismatch: \\begin{" + envName + "} matched by \\end{" + end.name + "}", endNameToken); + } + // env.handler returns the specific node type (e.g. "array"), + // not "environment". This cast is unavoidable: defineFunction + // requires the handler to return ParseNode<"environment"> but + // \begin delegates to environment handlers with different types. + return result; + } + return { + type: "environment", + mode: parser.mode, + name: envName, + nameGroup + }; + } +}); + +// TODO(kevinb): implement \\sl and \\sc +var htmlBuilder$5 = (group, options) => { + var font = group.font; + var newOptions = options.withFont(font); + return buildGroup$1(group.body, newOptions); +}; +var mathmlBuilder$4 = (group, options) => { + var font = group.font; + var newOptions = options.withFont(font); + return buildGroup(group.body, newOptions); +}; +var fontAliases = { + "\\Bbb": "\\mathbb", + "\\bold": "\\mathbf", + "\\frak": "\\mathfrak" +}; +defineFunction({ + type: "font", + names: [ + // styles, except \boldsymbol defined below + "\\mathrm", "\\mathit", "\\mathbf", "\\mathnormal", "\\mathsfit", + // families + "\\mathbb", "\\mathcal", "\\mathfrak", "\\mathscr", "\\mathsf", "\\mathtt", + // aliases, except \bm defined below + "\\Bbb", "\\bold", "\\frak"], + numArgs: 1, + allowedInArgument: true, + handler: (_ref, args) => { + var { + parser, + funcName + } = _ref; + var body = normalizeArgument(args[0]); + var func = funcName in fontAliases ? fontAliases[funcName] : funcName; + return { + type: "font", + mode: parser.mode, + font: func.slice(1), + body + }; + }, + htmlBuilder: htmlBuilder$5, + mathmlBuilder: mathmlBuilder$4 +}); +defineFunction({ + type: "mclass", + names: ["\\boldsymbol", "\\bm"], + numArgs: 1, + handler: (_ref2, args) => { + var { + parser + } = _ref2; + var body = args[0]; + // amsbsy.sty's \boldsymbol uses \binrel spacing to inherit the + // argument's bin|rel|ord status + return { + type: "mclass", + mode: parser.mode, + mclass: binrelClass(body), + body: [{ + type: "font", + mode: parser.mode, + font: "boldsymbol", + body + }], + isCharacterBox: isCharacterBox(body) + }; + } +}); +// Old font changing functions +defineFunction({ + type: "font", + names: ["\\rm", "\\sf", "\\tt", "\\bf", "\\it", "\\cal"], + numArgs: 0, + allowedInText: true, + handler: (_ref3, args) => { + var { + parser, + funcName, + breakOnTokenText + } = _ref3; + var { + mode + } = parser; + var body = parser.parseExpression(true, breakOnTokenText); + return { + type: "font", + mode: mode, + font: "math" + funcName.slice(1), + body: { + type: "ordgroup", + mode: parser.mode, + body + } + }; + } +}); + +var htmlBuilder$4 = (group, options) => { + // Fractions are handled in the TeXbook on pages 444-445, rules 15(a-e). + var style = options.style; + var nstyle = style.fracNum(); + var dstyle = style.fracDen(); + var newOptions; + newOptions = options.havingStyle(nstyle); + var numerm = buildGroup$1(group.numer, newOptions, options); + if (group.continued) { + // \cfrac inserts a \strut into the numerator. + // Get \strut dimensions from TeXbook page 353. + var hStrut = 8.5 / options.fontMetrics().ptPerEm; + var dStrut = 3.5 / options.fontMetrics().ptPerEm; + numerm.height = numerm.height < hStrut ? hStrut : numerm.height; + numerm.depth = numerm.depth < dStrut ? dStrut : numerm.depth; + } + newOptions = options.havingStyle(dstyle); + var denomm = buildGroup$1(group.denom, newOptions, options); + var rule; + var ruleWidth; + var ruleSpacing; + if (group.hasBarLine) { + if (group.barSize) { + ruleWidth = calculateSize(group.barSize, options); + rule = makeLineSpan("frac-line", options, ruleWidth); + } else { + rule = makeLineSpan("frac-line", options); + } + ruleWidth = rule.height; + ruleSpacing = rule.height; + } else { + rule = null; + ruleWidth = 0; + ruleSpacing = options.fontMetrics().defaultRuleThickness; + } + // Rule 15b + var numShift; + var clearance; + var denomShift; + if (style.size === Style$1.DISPLAY.size) { + numShift = options.fontMetrics().num1; + if (ruleWidth > 0) { + clearance = 3 * ruleSpacing; + } else { + clearance = 7 * ruleSpacing; + } + denomShift = options.fontMetrics().denom1; + } else { + if (ruleWidth > 0) { + numShift = options.fontMetrics().num2; + clearance = ruleSpacing; + } else { + numShift = options.fontMetrics().num3; + clearance = 3 * ruleSpacing; + } + denomShift = options.fontMetrics().denom2; + } + var frac; + if (!rule) { + // Rule 15c + var candidateClearance = numShift - numerm.depth - (denomm.height - denomShift); + if (candidateClearance < clearance) { + numShift += 0.5 * (clearance - candidateClearance); + denomShift += 0.5 * (clearance - candidateClearance); + } + frac = makeVList({ + positionType: "individualShift", + children: [{ + type: "elem", + elem: denomm, + shift: denomShift + }, { + type: "elem", + elem: numerm, + shift: -numShift + }] + }); + } else { + // Rule 15d + var axisHeight = options.fontMetrics().axisHeight; + if (numShift - numerm.depth - (axisHeight + 0.5 * ruleWidth) < clearance) { + numShift += clearance - (numShift - numerm.depth - (axisHeight + 0.5 * ruleWidth)); + } + if (axisHeight - 0.5 * ruleWidth - (denomm.height - denomShift) < clearance) { + denomShift += clearance - (axisHeight - 0.5 * ruleWidth - (denomm.height - denomShift)); + } + var midShift = -(axisHeight - 0.5 * ruleWidth); + frac = makeVList({ + positionType: "individualShift", + children: [{ + type: "elem", + elem: denomm, + shift: denomShift + }, { + type: "elem", + elem: rule, + shift: midShift + }, { + type: "elem", + elem: numerm, + shift: -numShift + }] + }); + } + // Since we manually change the style sometimes (with \dfrac or \tfrac), + // account for the possible size change here. + newOptions = options.havingStyle(style); + frac.height *= newOptions.sizeMultiplier / options.sizeMultiplier; + frac.depth *= newOptions.sizeMultiplier / options.sizeMultiplier; + // Rule 15e + var delimSize; + if (style.size === Style$1.DISPLAY.size) { + delimSize = options.fontMetrics().delim1; + } else if (style.size === Style$1.SCRIPTSCRIPT.size) { + delimSize = options.havingStyle(Style$1.SCRIPT).fontMetrics().delim2; + } else { + delimSize = options.fontMetrics().delim2; + } + var leftDelim; + var rightDelim; + if (group.leftDelim == null) { + leftDelim = makeNullDelimiter(options, ["mopen"]); + } else { + leftDelim = makeCustomSizedDelim(group.leftDelim, delimSize, true, options.havingStyle(style), group.mode, ["mopen"]); + } + if (group.continued) { + rightDelim = makeSpan([]); // zero width for \cfrac + } else if (group.rightDelim == null) { + rightDelim = makeNullDelimiter(options, ["mclose"]); + } else { + rightDelim = makeCustomSizedDelim(group.rightDelim, delimSize, true, options.havingStyle(style), group.mode, ["mclose"]); + } + return makeSpan(["mord"].concat(newOptions.sizingClasses(options)), [leftDelim, makeSpan(["mfrac"], [frac]), rightDelim], options); +}; +var mathmlBuilder$3 = (group, options) => { + var node = new MathNode("mfrac", [buildGroup(group.numer, options), buildGroup(group.denom, options)]); + if (!group.hasBarLine) { + node.setAttribute("linethickness", "0px"); + } else if (group.barSize) { + var ruleWidth = calculateSize(group.barSize, options); + node.setAttribute("linethickness", makeEm(ruleWidth)); + } + if (group.leftDelim != null || group.rightDelim != null) { + var withDelims = []; + if (group.leftDelim != null) { + var leftOp = new MathNode("mo", [new TextNode(group.leftDelim.replace("\\", ""))]); + leftOp.setAttribute("fence", "true"); + withDelims.push(leftOp); + } + withDelims.push(node); + if (group.rightDelim != null) { + var rightOp = new MathNode("mo", [new TextNode(group.rightDelim.replace("\\", ""))]); + rightOp.setAttribute("fence", "true"); + withDelims.push(rightOp); + } + return makeRow(withDelims); + } + return node; +}; +var wrapWithStyle = (frac, style) => { + if (!style) { + return frac; + } + var wrapper = { + type: "styling", + mode: frac.mode, + style, + body: [frac] + }; + // @ts-ignore defineFunction handler needs to return ParseNode<"genfrac"> + return wrapper; +}; +defineFunction({ + type: "genfrac", + names: ["\\cfrac", "\\dfrac", "\\frac", "\\tfrac", "\\dbinom", "\\binom", "\\tbinom", "\\\\atopfrac", + // can’t be entered directly + "\\\\bracefrac", "\\\\brackfrac" // ditto + ], + numArgs: 2, + allowedInArgument: true, + handler: (_ref, args) => { + var { + parser, + funcName + } = _ref; + var numer = args[0]; + var denom = args[1]; + var hasBarLine; + var leftDelim = null; + var rightDelim = null; + switch (funcName) { + case "\\cfrac": + case "\\dfrac": + case "\\frac": + case "\\tfrac": + hasBarLine = true; + break; + case "\\\\atopfrac": + hasBarLine = false; + break; + case "\\dbinom": + case "\\binom": + case "\\tbinom": + hasBarLine = false; + leftDelim = "("; + rightDelim = ")"; + break; + case "\\\\bracefrac": + hasBarLine = false; + leftDelim = "\\{"; + rightDelim = "\\}"; + break; + case "\\\\brackfrac": + hasBarLine = false; + leftDelim = "["; + rightDelim = "]"; + break; + default: + throw new Error("Unrecognized genfrac command"); + } + var continued = funcName === "\\cfrac"; + var style = null; + if (continued || funcName.startsWith("\\d")) { + style = "display"; + } else if (funcName.startsWith("\\t")) { + style = "text"; + } + return wrapWithStyle({ + type: "genfrac", + mode: parser.mode, + numer, + denom, + continued, + hasBarLine, + leftDelim, + rightDelim, + barSize: null + }, style); + }, + htmlBuilder: htmlBuilder$4, + mathmlBuilder: mathmlBuilder$3 +}); +// Infix generalized fractions -- these are not rendered directly, but replaced +// immediately by one of the variants above. +defineFunction({ + type: "infix", + names: ["\\over", "\\choose", "\\atop", "\\brace", "\\brack"], + numArgs: 0, + infix: true, + handler(_ref2) { + var { + parser, + funcName, + token + } = _ref2; + var replaceWith; + switch (funcName) { + case "\\over": + replaceWith = "\\frac"; + break; + case "\\choose": + replaceWith = "\\binom"; + break; + case "\\atop": + replaceWith = "\\\\atopfrac"; + break; + case "\\brace": + replaceWith = "\\\\bracefrac"; + break; + case "\\brack": + replaceWith = "\\\\brackfrac"; + break; + default: + throw new Error("Unrecognized infix genfrac command"); + } + return { + type: "infix", + mode: parser.mode, + replaceWith, + token + }; + } +}); +var stylArray = ["display", "text", "script", "scriptscript"]; +var delimFromValue = function delimFromValue(delimString) { + var delim = null; + if (delimString.length > 0) { + delim = delimString; + delim = delim === "." ? null : delim; + } + return delim; +}; +defineFunction({ + type: "genfrac", + names: ["\\genfrac"], + numArgs: 6, + allowedInArgument: true, + argTypes: ["math", "math", "size", "text", "math", "math"], + handler(_ref3, args) { + var { + parser + } = _ref3; + var numer = args[4]; + var denom = args[5]; + // Look into the parse nodes to get the desired delimiters. + var leftNode = normalizeArgument(args[0]); + var leftDelim = leftNode.type === "atom" && leftNode.family === "open" ? delimFromValue(leftNode.text) : null; + var rightNode = normalizeArgument(args[1]); + var rightDelim = rightNode.type === "atom" && rightNode.family === "close" ? delimFromValue(rightNode.text) : null; + var barNode = assertNodeType(args[2], "size"); + var hasBarLine; + var barSize = null; + if (barNode.isBlank) { + // \genfrac acts differently than \above. + // \genfrac treats an empty size group as a signal to use a + // standard bar size. \above would see size = 0 and omit the bar. + hasBarLine = true; + } else { + barSize = barNode.value; + hasBarLine = barSize.number > 0; + } + // Find out if we want displaystyle, textstyle, etc. + var size = null; + var styl = args[3]; + if (styl.type === "ordgroup") { + if (styl.body.length > 0) { + var textOrd = assertNodeType(styl.body[0], "textord"); + size = stylArray[Number(textOrd.text)]; + } + } else { + styl = assertNodeType(styl, "textord"); + size = stylArray[Number(styl.text)]; + } + return wrapWithStyle({ + type: "genfrac", + mode: parser.mode, + numer, + denom, + continued: false, + hasBarLine, + barSize, + leftDelim, + rightDelim + }, size); + } +}); +// \above is an infix fraction that also defines a fraction bar size. +defineFunction({ + type: "infix", + names: ["\\above"], + numArgs: 1, + argTypes: ["size"], + infix: true, + handler(_ref4, args) { + var { + parser, + funcName, + token + } = _ref4; + return { + type: "infix", + mode: parser.mode, + replaceWith: "\\\\abovefrac", + size: assertNodeType(args[0], "size").value, + token + }; + } +}); +defineFunction({ + type: "genfrac", + names: ["\\\\abovefrac"], + numArgs: 3, + argTypes: ["math", "size", "math"], + handler: (_ref5, args) => { + var { + parser, + funcName + } = _ref5; + var numer = args[0]; + var barSize = assertNodeType(args[1], "infix").size; + if (!barSize) { + throw new Error("\\\\abovefrac expected size, but got " + String(barSize)); + } + var denom = args[2]; + var hasBarLine = barSize.number > 0; + return { + type: "genfrac", + mode: parser.mode, + numer, + denom, + continued: false, + hasBarLine, + barSize, + leftDelim: null, + rightDelim: null + }; + } +}); + +// NOTE: Unlike most `htmlBuilder`s, this one handles not only "horizBrace", but +// also "supsub" since an over/underbrace can affect super/subscripting. +var htmlBuilder$3 = (grp, options) => { + var style = options.style; + // Pull out the `ParseNode<"horizBrace">` if `grp` is a "supsub" node. + var supSubGroup; + var group; + if (grp.type === "supsub") { + // Ref: LaTeX source2e: }}}}\limits} + // i.e. LaTeX treats the brace similar to an op and passes it + // with \limits, so we need to assign supsub style. + supSubGroup = grp.sup ? buildGroup$1(grp.sup, options.havingStyle(style.sup()), options) : buildGroup$1(grp.sub, options.havingStyle(style.sub()), options); + group = assertNodeType(grp.base, "horizBrace"); + } else { + group = assertNodeType(grp, "horizBrace"); + } + // Build the base group + var body = buildGroup$1(group.base, options.havingBaseStyle(Style$1.DISPLAY)); + // Create the stretchy element + var braceBody = stretchySvg(group, options); + // Generate the vlist, with the appropriate kerns ┏━━━━━━━━┓ + // This first vlist contains the content and the brace: equation + var vlist; + if (group.isOver) { + vlist = makeVList({ + positionType: "firstBaseline", + children: [{ + type: "elem", + elem: body + }, { + type: "kern", + size: 0.1 + }, { + type: "elem", + elem: braceBody, + wrapperClasses: ["svg-align"] + }] + }); + } else { + vlist = makeVList({ + positionType: "bottom", + positionData: body.depth + 0.1 + braceBody.height, + children: [{ + type: "elem", + elem: braceBody, + wrapperClasses: ["svg-align"] + }, { + type: "kern", + size: 0.1 + }, { + type: "elem", + elem: body + }] + }); + } + if (supSubGroup) { + // To write the supsub, wrap the first vlist in another vlist: + // They can't all go in the same vlist, because the note might be + // wider than the equation. We want the equation to control the + // brace width. + // note long note long note + // ┏━━━━━━━━┓ or ┏━━━┓ not ┏━━━━━━━━━┓ + // equation eqn eqn + var vSpan = makeSpan(["minner", group.isOver ? "mover" : "munder"], [vlist], options); + if (group.isOver) { + vlist = makeVList({ + positionType: "firstBaseline", + children: [{ + type: "elem", + elem: vSpan + }, { + type: "kern", + size: 0.2 + }, { + type: "elem", + elem: supSubGroup + }] + }); + } else { + vlist = makeVList({ + positionType: "bottom", + positionData: vSpan.depth + 0.2 + supSubGroup.height + supSubGroup.depth, + children: [{ + type: "elem", + elem: supSubGroup + }, { + type: "kern", + size: 0.2 + }, { + type: "elem", + elem: vSpan + }] + }); + } + } + return makeSpan(["minner", group.isOver ? "mover" : "munder"], [vlist], options); +}; +var mathmlBuilder$2 = (group, options) => { + var accentNode = stretchyMathML(group.label); + return new MathNode(group.isOver ? "mover" : "munder", [buildGroup(group.base, options), accentNode]); +}; +// Horizontal stretchy braces +defineFunction({ + type: "horizBrace", + names: ["\\overbrace", "\\underbrace", "\\overbracket", "\\underbracket"], + numArgs: 1, + handler(_ref, args) { + var { + parser, + funcName + } = _ref; + return { + type: "horizBrace", + mode: parser.mode, + label: funcName, + isOver: funcName.includes("\\over"), + base: args[0] + }; + }, + htmlBuilder: htmlBuilder$3, + mathmlBuilder: mathmlBuilder$2 +}); + +defineFunction({ + type: "href", + names: ["\\href"], + numArgs: 2, + argTypes: ["url", "original"], + allowedInText: true, + handler: (_ref, args) => { + var { + parser + } = _ref; + var body = args[1]; + var href = assertNodeType(args[0], "url").url; + if (!parser.settings.isTrusted({ + command: "\\href", + url: href + })) { + return parser.formatUnsupportedCmd("\\href"); + } + return { + type: "href", + mode: parser.mode, + href, + body: ordargument(body) + }; + }, + htmlBuilder: (group, options) => { + var elements = buildExpression$1(group.body, options, false); + return makeAnchor(group.href, [], elements, options); + }, + mathmlBuilder: (group, options) => { + var math = buildExpressionRow(group.body, options); + if (!(math instanceof MathNode)) { + math = new MathNode("mrow", [math]); + } + math.setAttribute("href", group.href); + return math; + } +}); +defineFunction({ + type: "href", + names: ["\\url"], + numArgs: 1, + argTypes: ["url"], + allowedInText: true, + handler: (_ref2, args) => { + var { + parser + } = _ref2; + var href = assertNodeType(args[0], "url").url; + if (!parser.settings.isTrusted({ + command: "\\url", + url: href + })) { + return parser.formatUnsupportedCmd("\\url"); + } + var chars = []; + for (var i = 0; i < href.length; i++) { + var c = href[i]; + if (c === "~") { + c = "\\textasciitilde"; + } + chars.push({ + type: "textord", + mode: "text", + text: c + }); + } + var body = { + type: "text", + mode: parser.mode, + font: "\\texttt", + body: chars + }; + return { + type: "href", + mode: parser.mode, + href, + body: ordargument(body) + }; + } +}); + +// \hbox is provided for compatibility with LaTeX \vcenter. +// In LaTeX, \vcenter can act only on a box, as in +// \vcenter{\hbox{$\frac{a+b}{\dfrac{c}{d}}$}} +// This function by itself doesn't do anything but prevent a soft line break. +defineFunction({ + type: "hbox", + names: ["\\hbox"], + numArgs: 1, + argTypes: ["text"], + allowedInText: true, + primitive: true, + handler(_ref, args) { + var { + parser + } = _ref; + return { + type: "hbox", + mode: parser.mode, + body: ordargument(args[0]) + }; + }, + htmlBuilder(group, options) { + var elements = buildExpression$1(group.body, options.withFont(''), false); + return makeFragment(elements); + }, + mathmlBuilder(group, options) { + return new MathNode("mrow", buildExpression(group.body, options.withFont(''))); + } +}); + +defineFunction({ + type: "html", + names: ["\\htmlClass", "\\htmlId", "\\htmlStyle", "\\htmlData"], + numArgs: 2, + argTypes: ["raw", "original"], + allowedInText: true, + handler: (_ref, args) => { + var { + parser, + funcName, + token + } = _ref; + var value = assertNodeType(args[0], "raw").string; + var body = args[1]; + if (parser.settings.strict) { + parser.settings.reportNonstrict("htmlExtension", "HTML extension is disabled on strict mode"); + } + var trustContext; + var attributes = {}; + switch (funcName) { + case "\\htmlClass": + attributes.class = value; + trustContext = { + command: "\\htmlClass", + class: value + }; + break; + case "\\htmlId": + attributes.id = value; + trustContext = { + command: "\\htmlId", + id: value + }; + break; + case "\\htmlStyle": + attributes.style = value; + trustContext = { + command: "\\htmlStyle", + style: value + }; + break; + case "\\htmlData": + { + var data = value.split(","); + for (var i = 0; i < data.length; i++) { + var item = data[i]; + var firstEquals = item.indexOf("="); + if (firstEquals < 0) { + throw new ParseError("\\htmlData key/value '" + item + "'" + " missing equals sign"); + } + var key = item.slice(0, firstEquals); + var _value = item.slice(firstEquals + 1); + attributes["data-" + key.trim()] = _value; + } + trustContext = { + command: "\\htmlData", + attributes + }; + break; + } + default: + throw new Error("Unrecognized html command"); + } + if (!parser.settings.isTrusted(trustContext)) { + return parser.formatUnsupportedCmd(funcName); + } + return { + type: "html", + mode: parser.mode, + attributes, + body: ordargument(body) + }; + }, + htmlBuilder: (group, options) => { + var elements = buildExpression$1(group.body, options, false); + var classes = ["enclosing"]; + if (group.attributes.class) { + classes.push(...group.attributes.class.trim().split(/\s+/)); + } + var span = makeSpan(classes, elements, options); + for (var attr in group.attributes) { + if (attr !== "class" && group.attributes.hasOwnProperty(attr)) { + span.setAttribute(attr, group.attributes[attr]); + } + } + return span; + }, + mathmlBuilder: (group, options) => { + return buildExpressionRow(group.body, options); + } +}); + +defineFunction({ + type: "htmlmathml", + names: ["\\html@mathml"], + numArgs: 2, + allowedInArgument: true, + allowedInText: true, + handler: (_ref, args) => { + var { + parser + } = _ref; + return { + type: "htmlmathml", + mode: parser.mode, + html: ordargument(args[0]), + mathml: ordargument(args[1]) + }; + }, + htmlBuilder: (group, options) => { + var elements = buildExpression$1(group.html, options, false); + return makeFragment(elements); + }, + mathmlBuilder: (group, options) => { + return buildExpressionRow(group.mathml, options); + } +}); + +var sizeData = function sizeData(str) { + if (/^[-+]? *(\d+(\.\d*)?|\.\d+)$/.test(str)) { + // str is a number with no unit specified. + // default unit is bp, per graphix package. + return { + number: +str, + unit: "bp" + }; + } else { + var match = /([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(str); + if (!match) { + throw new ParseError("Invalid size: '" + str + "' in \\includegraphics"); + } + var data = { + number: +(match[1] + match[2]), + // sign + magnitude, cast to number + unit: match[3] + }; + if (!validUnit(data)) { + throw new ParseError("Invalid unit: '" + data.unit + "' in \\includegraphics."); + } + return data; + } +}; +defineFunction({ + type: "includegraphics", + names: ["\\includegraphics"], + numArgs: 1, + numOptionalArgs: 1, + argTypes: ["raw", "url"], + allowedInText: false, + handler: (_ref, args, optArgs) => { + var { + parser + } = _ref; + var width = { + number: 0, + unit: "em" + }; + var height = { + number: 0.9, + unit: "em" + }; // sorta character sized. + var totalheight = { + number: 0, + unit: "em" + }; + var alt = ""; + if (optArgs[0]) { + var attributeStr = assertNodeType(optArgs[0], "raw").string; + // Parser.js does not parse key/value pairs. We get a string. + var attributes = attributeStr.split(","); + for (var i = 0; i < attributes.length; i++) { + var keyVal = attributes[i].split("="); + if (keyVal.length === 2) { + var str = keyVal[1].trim(); + switch (keyVal[0].trim()) { + case "alt": + alt = str; + break; + case "width": + width = sizeData(str); + break; + case "height": + height = sizeData(str); + break; + case "totalheight": + totalheight = sizeData(str); + break; + default: + throw new ParseError("Invalid key: '" + keyVal[0] + "' in \\includegraphics."); + } + } + } + } + var src = assertNodeType(args[0], "url").url; + if (alt === "") { + // No alt given. Use the file name. Strip away the path. + alt = src; + alt = alt.replace(/^.*[\\/]/, ''); + alt = alt.substring(0, alt.lastIndexOf('.')); + } + if (!parser.settings.isTrusted({ + command: "\\includegraphics", + url: src + })) { + return parser.formatUnsupportedCmd("\\includegraphics"); + } + return { + type: "includegraphics", + mode: parser.mode, + alt: alt, + width: width, + height: height, + totalheight: totalheight, + src: src + }; + }, + htmlBuilder: (group, options) => { + var height = calculateSize(group.height, options); + var depth = 0; + if (group.totalheight.number > 0) { + depth = calculateSize(group.totalheight, options) - height; + } + var width = 0; + if (group.width.number > 0) { + width = calculateSize(group.width, options); + } + var style = { + height: makeEm(height + depth) + }; + if (width > 0) { + style.width = makeEm(width); + } + if (depth > 0) { + style.verticalAlign = makeEm(-depth); + } + var node = new Img(group.src, group.alt, style); + node.height = height; + node.depth = depth; + return node; + }, + mathmlBuilder: (group, options) => { + var node = new MathNode("mglyph", []); + node.setAttribute("alt", group.alt); + var height = calculateSize(group.height, options); + var depth = 0; + if (group.totalheight.number > 0) { + depth = calculateSize(group.totalheight, options) - height; + node.setAttribute("valign", makeEm(-depth)); + } + node.setAttribute("height", makeEm(height + depth)); + if (group.width.number > 0) { + var width = calculateSize(group.width, options); + node.setAttribute("width", makeEm(width)); + } + node.setAttribute("src", group.src); + return node; + } +}); + +// Horizontal spacing commands +// TODO: \hskip and \mskip should support plus and minus in lengths +defineFunction({ + type: "kern", + names: ["\\kern", "\\mkern", "\\hskip", "\\mskip"], + numArgs: 1, + argTypes: ["size"], + primitive: true, + allowedInText: true, + handler(_ref, args) { + var { + parser, + funcName + } = _ref; + var size = assertNodeType(args[0], "size"); + if (parser.settings.strict) { + var mathFunction = funcName[1] === 'm'; // \mkern, \mskip + var muUnit = size.value.unit === 'mu'; + if (mathFunction) { + if (!muUnit) { + parser.settings.reportNonstrict("mathVsTextUnits", "LaTeX's " + funcName + " supports only mu units, " + ("not " + size.value.unit + " units")); + } + if (parser.mode !== "math") { + parser.settings.reportNonstrict("mathVsTextUnits", "LaTeX's " + funcName + " works only in math mode"); + } + } else { + // !mathFunction + if (muUnit) { + parser.settings.reportNonstrict("mathVsTextUnits", "LaTeX's " + funcName + " doesn't support mu units"); + } + } + } + return { + type: "kern", + mode: parser.mode, + dimension: size.value + }; + }, + htmlBuilder(group, options) { + return makeGlue(group.dimension, options); + }, + mathmlBuilder(group, options) { + var dimension = calculateSize(group.dimension, options); + return new SpaceNode(dimension); + } +}); + +// Horizontal overlap functions +defineFunction({ + type: "lap", + names: ["\\mathllap", "\\mathrlap", "\\mathclap"], + numArgs: 1, + allowedInText: true, + handler: (_ref, args) => { + var { + parser, + funcName + } = _ref; + var body = args[0]; + return { + type: "lap", + mode: parser.mode, + alignment: funcName.slice(5), + body + }; + }, + htmlBuilder: (group, options) => { + // mathllap, mathrlap, mathclap + var inner; + if (group.alignment === "clap") { + // ref: https://www.math.lsu.edu/~aperlis/publications/mathclap/ + inner = makeSpan([], [buildGroup$1(group.body, options)]); + // wrap, since CSS will center a .clap > .inner > span + inner = makeSpan(["inner"], [inner], options); + } else { + inner = makeSpan(["inner"], [buildGroup$1(group.body, options)]); + } + var fix = makeSpan(["fix"], []); + var node = makeSpan([group.alignment], [inner, fix], options); + // At this point, we have correctly set horizontal alignment of the + // two items involved in the lap. + // Next, use a strut to set the height of the HTML bounding box. + // Otherwise, a tall argument may be misplaced. + // This code resolved issue #1153 + var strut = makeSpan(["strut"]); + strut.style.height = makeEm(node.height + node.depth); + if (node.depth) { + strut.style.verticalAlign = makeEm(-node.depth); + } + node.children.unshift(strut); + // Next, prevent vertical misplacement when next to something tall. + // This code resolves issue #1234 + node = makeSpan(["thinbox"], [node], options); + return makeSpan(["mord", "vbox"], [node], options); + }, + mathmlBuilder: (group, options) => { + // mathllap, mathrlap, mathclap + var node = new MathNode("mpadded", [buildGroup(group.body, options)]); + if (group.alignment !== "rlap") { + var offset = group.alignment === "llap" ? "-1" : "-0.5"; + node.setAttribute("lspace", offset + "width"); + } + node.setAttribute("width", "0px"); + return node; + } +}); + +// Switching from text mode back to math mode +defineFunction({ + type: "styling", + names: ["\\(", "$"], + numArgs: 0, + allowedInText: true, + allowedInMath: false, + handler(_ref, args) { + var { + funcName, + parser + } = _ref; + var outerMode = parser.mode; + parser.switchMode("math"); + var close = funcName === "\\(" ? "\\)" : "$"; + var body = parser.parseExpression(false, close); + parser.expect(close); + parser.switchMode(outerMode); + return { + type: "styling", + mode: parser.mode, + style: "text", + resetFont: true, + body + }; + } +}); +// Check for extra closing math delimiters +defineFunction({ + type: "text", + // Doesn't matter what this is. + names: ["\\)", "\\]"], + numArgs: 0, + allowedInText: true, + allowedInMath: false, + handler(context, args) { + throw new ParseError("Mismatched " + context.funcName); + } +}); + +var chooseMathStyle = (group, options) => { + switch (options.style.size) { + case Style$1.DISPLAY.size: + return group.display; + case Style$1.TEXT.size: + return group.text; + case Style$1.SCRIPT.size: + return group.script; + case Style$1.SCRIPTSCRIPT.size: + return group.scriptscript; + default: + return group.text; + } +}; +defineFunction({ + type: "mathchoice", + names: ["\\mathchoice"], + numArgs: 4, + primitive: true, + handler: (_ref, args) => { + var { + parser + } = _ref; + return { + type: "mathchoice", + mode: parser.mode, + display: ordargument(args[0]), + text: ordargument(args[1]), + script: ordargument(args[2]), + scriptscript: ordargument(args[3]) + }; + }, + htmlBuilder: (group, options) => { + var body = chooseMathStyle(group, options); + var elements = buildExpression$1(body, options, false); + return makeFragment(elements); + }, + mathmlBuilder: (group, options) => { + var body = chooseMathStyle(group, options); + return buildExpressionRow(body, options); + } +}); + +// For an operator with limits, assemble the base, sup, and sub into a span. +var assembleSupSub = (base, supGroup, subGroup, options, style, slant, baseShift) => { + base = makeSpan([], [base]); + var subIsSingleCharacter = subGroup && isCharacterBox(subGroup); + var sub; + var sup; + // We manually have to handle the superscripts and subscripts. This, + // aside from the kern calculations, is copied from supsub. + if (supGroup) { + var elem = buildGroup$1(supGroup, options.havingStyle(style.sup()), options); + sup = { + elem, + kern: Math.max(options.fontMetrics().bigOpSpacing1, options.fontMetrics().bigOpSpacing3 - elem.depth) + }; + } + if (subGroup) { + var _elem = buildGroup$1(subGroup, options.havingStyle(style.sub()), options); + sub = { + elem: _elem, + kern: Math.max(options.fontMetrics().bigOpSpacing2, options.fontMetrics().bigOpSpacing4 - _elem.height) + }; + } + // Build the final group as a vlist of the possible subscript, base, + // and possible superscript. + var finalGroup; + if (sup && sub) { + var bottom = options.fontMetrics().bigOpSpacing5 + sub.elem.height + sub.elem.depth + sub.kern + base.depth + baseShift; + finalGroup = makeVList({ + positionType: "bottom", + positionData: bottom, + children: [{ + type: "kern", + size: options.fontMetrics().bigOpSpacing5 + }, { + type: "elem", + elem: sub.elem, + marginLeft: makeEm(-slant) + }, { + type: "kern", + size: sub.kern + }, { + type: "elem", + elem: base + }, { + type: "kern", + size: sup.kern + }, { + type: "elem", + elem: sup.elem, + marginLeft: makeEm(slant) + }, { + type: "kern", + size: options.fontMetrics().bigOpSpacing5 + }] + }); + } else if (sub) { + var top = base.height - baseShift; + // Shift the limits by the slant of the symbol. Note + // that we are supposed to shift the limits by 1/2 of the slant, + // but since we are centering the limits adding a full slant of + // margin will shift by 1/2 that. + finalGroup = makeVList({ + positionType: "top", + positionData: top, + children: [{ + type: "kern", + size: options.fontMetrics().bigOpSpacing5 + }, { + type: "elem", + elem: sub.elem, + marginLeft: makeEm(-slant) + }, { + type: "kern", + size: sub.kern + }, { + type: "elem", + elem: base + }] + }); + } else if (sup) { + var _bottom = base.depth + baseShift; + finalGroup = makeVList({ + positionType: "bottom", + positionData: _bottom, + children: [{ + type: "elem", + elem: base + }, { + type: "kern", + size: sup.kern + }, { + type: "elem", + elem: sup.elem, + marginLeft: makeEm(slant) + }, { + type: "kern", + size: options.fontMetrics().bigOpSpacing5 + }] + }); + } else { + // This case probably shouldn't occur (this would mean the + // supsub was sending us a group with no superscript or + // subscript) but be safe. + return base; + } + var parts = [finalGroup]; + if (sub && slant !== 0 && !subIsSingleCharacter) { + // A negative margin-left was applied to the lower limit. + // Avoid an overlap by placing a spacer on the left on the group. + var spacer = makeSpan(["mspace"], [], options); + spacer.style.marginRight = makeEm(slant); + parts.unshift(spacer); + } + return makeSpan(["mop", "op-limits"], parts, options); +}; + +// Limits, symbols +// Most operators have a large successor symbol, but these don't. +var noSuccessor = new Set(["\\smallint"]); +// NOTE: Unlike most `htmlBuilder`s, this one handles not only "op", but also +// "supsub" since some of them (like \int) can affect super/subscripting. +var htmlBuilder$2 = (grp, options) => { + // Operators are handled in the TeXbook pg. 443-444, rule 13(a). + var supGroup; + var subGroup; + var hasLimits = false; + var group; + if (grp.type === "supsub") { + // If we have limits, supsub will pass us its group to handle. Pull + // out the superscript and subscript and set the group to the op in + // its base. + supGroup = grp.sup; + subGroup = grp.sub; + group = assertNodeType(grp.base, "op"); + hasLimits = true; + } else { + group = assertNodeType(grp, "op"); + } + var style = options.style; + var large = false; + if (style.size === Style$1.DISPLAY.size && group.symbol && !noSuccessor.has(group.name)) { + // Most symbol operators get larger in displaystyle (rule 13) + large = true; + } + var base; + // Italic correction from the symbol glyph, captured before the symbol + // may be wrapped in a vlist (for \oiint/\oiiint). Stays 0 for non-symbol ops. + var symbolItalic; + if (group.symbol) { + // If this is a symbol, create the symbol. + var fontName = large ? "Size2-Regular" : "Size1-Regular"; + var stash = ""; + if (group.name === "\\oiint" || group.name === "\\oiiint") { + // No font glyphs yet, so use a glyph w/o the oval. + // TODO: When font glyphs are available, delete this code. + stash = group.name.slice(1); + group.name = stash === "oiint" ? "\\iint" : "\\iiint"; + } + base = makeSymbol(group.name, fontName, "math", options, ["mop", "op-symbol", large ? "large-op" : "small-op"]); + symbolItalic = base.italic; + if (stash.length > 0) { + // We're in \oiint or \oiiint. Overlay the oval. + // TODO: When font glyphs are available, delete this code. + var oval = staticSvg(stash + "Size" + (large ? "2" : "1"), options); + base = makeVList({ + positionType: "individualShift", + children: [{ + type: "elem", + elem: base, + shift: 0 + }, { + type: "elem", + elem: oval, + shift: large ? 0.08 : 0 + }] + }); + group.name = "\\" + stash; + base.classes.unshift("mop"); + // Carry the italic correction from the original symbol to the + // vlist wrapper so supsub can use it for subscript positioning. + base.italic = symbolItalic; + } + } else if (group.body) { + // If this is a list, compose that list. + var inner = buildExpression$1(group.body, options, true); + if (inner.length === 1 && inner[0] instanceof SymbolNode) { + base = inner[0]; + base.classes[0] = "mop"; // replace old mclass + } else { + base = makeSpan(["mop"], inner, options); + } + } else { + // Otherwise, this is a text operator. Build the text from the + // operator's name. + var output = []; + for (var i = 1; i < group.name.length; i++) { + output.push(mathsym(group.name[i], group.mode, options)); + } + base = makeSpan(["mop"], output, options); + } + // If content of op is a single symbol, shift it vertically. + var baseShift = 0; + var slant = 0; + if ((base instanceof SymbolNode || group.name === "\\oiint" || group.name === "\\oiiint") && !group.suppressBaseShift) { + var _base$italic; + // We suppress the shift of the base of \overset and \underset. Otherwise, + // shift the symbol so its center lies on the axis (rule 13). It + // appears that our fonts have the centers of the symbols already + // almost on the axis, so these numbers are very small. Note we + // don't actually apply this here, but instead it is used either in + // the vlist creation or separately when there are no limits. + baseShift = (base.height - base.depth) / 2 - options.fontMetrics().axisHeight; + // The slant of the symbol is just its italic correction. + // SymbolNode carries .italic natively; Span (for \oiint/\oiiint) + // only has it set when nonzero, so default to 0. + slant = (_base$italic = base.italic) != null ? _base$italic : 0; + } + if (hasLimits) { + return assembleSupSub(base, supGroup, subGroup, options, style, slant, baseShift); + } else { + if (baseShift) { + base.style.position = "relative"; + base.style.top = makeEm(baseShift); + } + return base; + } +}; +var mathmlBuilder$1 = (group, options) => { + var node; + if (group.symbol) { + // This is a symbol. Just add the symbol. + node = new MathNode("mo", [makeText(group.name, group.mode)]); + if (noSuccessor.has(group.name)) { + node.setAttribute("largeop", "false"); + } + } else if (group.body) { + // This is an operator with children. Add them. + node = new MathNode("mo", buildExpression(group.body, options)); + } else { + // This is a text operator. Add all the characters from the + // operator's name. + node = new MathNode("mi", [new TextNode(group.name.slice(1))]); + // Append an . + // ref: https://www.w3.org/TR/REC-MathML/chap3_2.html#sec3.2.4 + var operator = new MathNode("mo", [makeText("\u2061", "text")]); + if (group.parentIsSupSub) { + node = new MathNode("mrow", [node, operator]); + } else { + node = newDocumentFragment([node, operator]); + } + } + return node; +}; +var singleCharBigOps = { + "\u220F": "\\prod", + "\u2210": "\\coprod", + "\u2211": "\\sum", + "\u22c0": "\\bigwedge", + "\u22c1": "\\bigvee", + "\u22c2": "\\bigcap", + "\u22c3": "\\bigcup", + "\u2a00": "\\bigodot", + "\u2a01": "\\bigoplus", + "\u2a02": "\\bigotimes", + "\u2a04": "\\biguplus", + "\u2a06": "\\bigsqcup" +}; +defineFunction({ + type: "op", + names: ["\\coprod", "\\bigvee", "\\bigwedge", "\\biguplus", "\\bigcap", "\\bigcup", "\\intop", "\\prod", "\\sum", "\\bigotimes", "\\bigoplus", "\\bigodot", "\\bigsqcup", "\\smallint", "\u220F", "\u2210", "\u2211", "\u22c0", "\u22c1", "\u22c2", "\u22c3", "\u2a00", "\u2a01", "\u2a02", "\u2a04", "\u2a06"], + numArgs: 0, + handler: (_ref, args) => { + var { + parser, + funcName + } = _ref; + var fName = funcName; + if (fName.length === 1) { + fName = singleCharBigOps[fName]; + } + return { + type: "op", + mode: parser.mode, + limits: true, + parentIsSupSub: false, + symbol: true, + name: fName + }; + }, + htmlBuilder: htmlBuilder$2, + mathmlBuilder: mathmlBuilder$1 +}); +defineFunction({ + type: "op", + names: ["\\mathop"], + numArgs: 1, + primitive: true, + handler: (_ref2, args) => { + var { + parser + } = _ref2; + var body = args[0]; + return { + type: "op", + mode: parser.mode, + limits: false, + parentIsSupSub: false, + symbol: false, + body: ordargument(body) + }; + } +}); +// There are 2 flags for operators; whether they produce limits in +// displaystyle, and whether they are symbols and should grow in +// displaystyle. These four groups cover the four possible choices. +var singleCharIntegrals = { + "\u222b": "\\int", + "\u222c": "\\iint", + "\u222d": "\\iiint", + "\u222e": "\\oint", + "\u222f": "\\oiint", + "\u2230": "\\oiiint" +}; +// No limits, not symbols +defineFunction({ + type: "op", + names: ["\\arcsin", "\\arccos", "\\arctan", "\\arctg", "\\arcctg", "\\arg", "\\ch", "\\cos", "\\cosec", "\\cosh", "\\cot", "\\cotg", "\\coth", "\\csc", "\\ctg", "\\cth", "\\deg", "\\dim", "\\exp", "\\hom", "\\ker", "\\lg", "\\ln", "\\log", "\\sec", "\\sin", "\\sinh", "\\sh", "\\tan", "\\tanh", "\\tg", "\\th"], + numArgs: 0, + handler(_ref3) { + var { + parser, + funcName + } = _ref3; + return { + type: "op", + mode: parser.mode, + limits: false, + parentIsSupSub: false, + symbol: false, + name: funcName + }; + } +}); +// Limits, not symbols +defineFunction({ + type: "op", + names: ["\\det", "\\gcd", "\\inf", "\\lim", "\\max", "\\min", "\\Pr", "\\sup"], + numArgs: 0, + handler(_ref4) { + var { + parser, + funcName + } = _ref4; + return { + type: "op", + mode: parser.mode, + limits: true, + parentIsSupSub: false, + symbol: false, + name: funcName + }; + } +}); +// No limits, symbols +defineFunction({ + type: "op", + names: ["\\int", "\\iint", "\\iiint", "\\oint", "\\oiint", "\\oiiint", "\u222b", "\u222c", "\u222d", "\u222e", "\u222f", "\u2230"], + numArgs: 0, + allowedInArgument: true, + handler(_ref5) { + var { + parser, + funcName + } = _ref5; + var fName = funcName; + if (fName.length === 1) { + fName = singleCharIntegrals[fName]; + } + return { + type: "op", + mode: parser.mode, + limits: false, + parentIsSupSub: false, + symbol: true, + name: fName + }; + } +}); + +// NOTE: Unlike most `htmlBuilder`s, this one handles not only +// "operatorname", but also "supsub" since \operatorname* can +// affect super/subscripting. +var htmlBuilder$1 = (grp, options) => { + // Operators are handled in the TeXbook pg. 443-444, rule 13(a). + var supGroup; + var subGroup; + var hasLimits = false; + var group; + if (grp.type === "supsub") { + // If we have limits, supsub will pass us its group to handle. Pull + // out the superscript and subscript and set the group to the op in + // its base. + supGroup = grp.sup; + subGroup = grp.sub; + group = assertNodeType(grp.base, "operatorname"); + hasLimits = true; + } else { + group = assertNodeType(grp, "operatorname"); + } + var base; + if (group.body.length > 0) { + var body = group.body.map(child => { + var childText = "text" in child ? child.text : undefined; + if (typeof childText === "string") { + return { + type: "textord", + mode: child.mode, + text: childText + }; + } else { + return child; + } + }); + // Consolidate function names into symbol characters. + var expression = buildExpression$1(body, options.withFont("mathrm"), true); + for (var i = 0; i < expression.length; i++) { + var child = expression[i]; + if (child instanceof SymbolNode) { + // Per amsopn package, + // change minus to hyphen and \ast to asterisk + child.text = child.text.replace(/\u2212/, "-").replace(/\u2217/, "*"); + } + } + base = makeSpan(["mop"], expression, options); + } else { + base = makeSpan(["mop"], [], options); + } + if (hasLimits) { + return assembleSupSub(base, supGroup, subGroup, options, options.style, 0, 0); + } else { + return base; + } +}; +var mathmlBuilder = (group, options) => { + // The steps taken here are similar to the html version. + var expression = buildExpression(group.body, options.withFont("mathrm")); + // Is expression a string or has it something like a fraction? + var isAllString = true; // default + for (var i = 0; i < expression.length; i++) { + var node = expression[i]; + if (node instanceof SpaceNode) ; else if (node instanceof MathNode) { + switch (node.type) { + case "mi": + case "mn": + case "mspace": + case "mtext": + break; + // Do nothing yet. + case "mo": + { + var child = node.children[0]; + if (node.children.length === 1 && child instanceof TextNode) { + child.text = child.text.replace(/\u2212/, "-").replace(/\u2217/, "*"); + } else { + isAllString = false; + } + break; + } + default: + isAllString = false; + } + } else { + isAllString = false; + } + } + if (isAllString) { + // Write a single TextNode instead of multiple nested tags. + var word = expression.map(node => node.toText()).join(""); + expression = [new TextNode(word)]; + } + var identifier = new MathNode("mi", expression); + identifier.setAttribute("mathvariant", "normal"); + // \u2061 is the same as ⁡ + // ref: https://www.w3schools.com/charsets/ref_html_entities_a.asp + var operator = new MathNode("mo", [makeText("\u2061", "text")]); + if (group.parentIsSupSub) { + return new MathNode("mrow", [identifier, operator]); + } else { + return newDocumentFragment([identifier, operator]); + } +}; +// \operatorname +// amsopn.dtx: \mathop{#1\kern\z@\operator@font#3}\newmcodes@ +defineFunction({ + type: "operatorname", + names: ["\\operatorname@", "\\operatornamewithlimits"], + numArgs: 1, + handler: (_ref, args) => { + var { + parser, + funcName + } = _ref; + var body = args[0]; + return { + type: "operatorname", + mode: parser.mode, + body: ordargument(body), + alwaysHandleSupSub: funcName === "\\operatornamewithlimits", + limits: false, + parentIsSupSub: false + }; + }, + htmlBuilder: htmlBuilder$1, + mathmlBuilder +}); +defineMacro("\\operatorname", "\\@ifstar\\operatornamewithlimits\\operatorname@"); + +defineFunctionBuilders({ + type: "ordgroup", + htmlBuilder(group, options) { + if (group.semisimple) { + return makeFragment(buildExpression$1(group.body, options, false)); + } + return makeSpan(["mord"], buildExpression$1(group.body, options, true), options); + }, + mathmlBuilder(group, options) { + return buildExpressionRow(group.body, options, true); + } +}); + +defineFunction({ + type: "overline", + names: ["\\overline"], + numArgs: 1, + handler(_ref, args) { + var { + parser + } = _ref; + var body = args[0]; + return { + type: "overline", + mode: parser.mode, + body + }; + }, + htmlBuilder(group, options) { + // Overlines are handled in the TeXbook pg 443, Rule 9. + // Build the inner group in the cramped style. + var innerGroup = buildGroup$1(group.body, options.havingCrampedStyle()); + // Create the line above the body + var line = makeLineSpan("overline-line", options); + // Generate the vlist, with the appropriate kerns + var defaultRuleThickness = options.fontMetrics().defaultRuleThickness; + var vlist = makeVList({ + positionType: "firstBaseline", + children: [{ + type: "elem", + elem: innerGroup + }, { + type: "kern", + size: 3 * defaultRuleThickness + }, { + type: "elem", + elem: line + }, { + type: "kern", + size: defaultRuleThickness + }] + }); + return makeSpan(["mord", "overline"], [vlist], options); + }, + mathmlBuilder(group, options) { + var operator = new MathNode("mo", [new TextNode("\u203e")]); + operator.setAttribute("stretchy", "true"); + var node = new MathNode("mover", [buildGroup(group.body, options), operator]); + node.setAttribute("accent", "true"); + return node; + } +}); + +defineFunction({ + type: "phantom", + names: ["\\phantom"], + numArgs: 1, + allowedInText: true, + handler: (_ref, args) => { + var { + parser + } = _ref; + var body = args[0]; + return { + type: "phantom", + mode: parser.mode, + body: ordargument(body) + }; + }, + htmlBuilder: (group, options) => { + var elements = buildExpression$1(group.body, options.withPhantom(), false); + // \phantom isn't supposed to affect the elements it contains. + // See "color" for more details. + return makeFragment(elements); + }, + mathmlBuilder: (group, options) => { + var inner = buildExpression(group.body, options); + return new MathNode("mphantom", inner); + } +}); +defineMacro("\\hphantom", "\\smash{\\phantom{#1}}"); +defineFunction({ + type: "vphantom", + names: ["\\vphantom"], + numArgs: 1, + allowedInText: true, + handler: (_ref2, args) => { + var { + parser + } = _ref2; + var body = args[0]; + return { + type: "vphantom", + mode: parser.mode, + body + }; + }, + htmlBuilder: (group, options) => { + var inner = makeSpan(["inner"], [buildGroup$1(group.body, options.withPhantom())]); + var fix = makeSpan(["fix"], []); + return makeSpan(["mord", "rlap"], [inner, fix], options); + }, + mathmlBuilder: (group, options) => { + var inner = buildExpression(ordargument(group.body), options); + var phantom = new MathNode("mphantom", inner); + var node = new MathNode("mpadded", [phantom]); + node.setAttribute("width", "0px"); + return node; + } +}); + +// Box manipulation +defineFunction({ + type: "raisebox", + names: ["\\raisebox"], + numArgs: 2, + argTypes: ["size", "hbox"], + allowedInText: true, + handler(_ref, args) { + var { + parser + } = _ref; + var amount = assertNodeType(args[0], "size").value; + var body = args[1]; + return { + type: "raisebox", + mode: parser.mode, + dy: amount, + body + }; + }, + htmlBuilder(group, options) { + var body = buildGroup$1(group.body, options); + var dy = calculateSize(group.dy, options); + return makeVList({ + positionType: "shift", + positionData: -dy, + children: [{ + type: "elem", + elem: body + }] + }); + }, + mathmlBuilder(group, options) { + var node = new MathNode("mpadded", [buildGroup(group.body, options)]); + var dy = group.dy.number + group.dy.unit; + node.setAttribute("voffset", dy); + return node; + } +}); + +defineFunction({ + type: "internal", + names: ["\\relax"], + numArgs: 0, + allowedInText: true, + allowedInArgument: true, + handler(_ref) { + var { + parser + } = _ref; + return { + type: "internal", + mode: parser.mode + }; + } +}); + +defineFunction({ + type: "rule", + names: ["\\rule"], + numArgs: 2, + numOptionalArgs: 1, + allowedInText: true, + allowedInMath: true, + argTypes: ["size", "size", "size"], + handler(_ref, args, optArgs) { + var { + parser + } = _ref; + var shift = optArgs[0]; + var width = assertNodeType(args[0], "size"); + var height = assertNodeType(args[1], "size"); + return { + type: "rule", + mode: parser.mode, + shift: shift && assertNodeType(shift, "size").value, + width: width.value, + height: height.value + }; + }, + htmlBuilder(group, options) { + // Make an empty span for the rule + var rule = makeSpan(["mord", "rule"], [], options); + // Calculate the shift, width, and height of the rule, and account for units + var width = calculateSize(group.width, options); + var height = calculateSize(group.height, options); + var shift = group.shift ? calculateSize(group.shift, options) : 0; + // Style the rule to the right size + rule.style.borderRightWidth = makeEm(width); + rule.style.borderTopWidth = makeEm(height); + rule.style.bottom = makeEm(shift); + // Record the height and width + rule.width = width; + rule.height = height + shift; + rule.depth = -shift; + // Font size is the number large enough that the browser will + // reserve at least `absHeight` space above the baseline. + // The 1.125 factor was empirically determined + rule.maxFontSize = height * 1.125 * options.sizeMultiplier; + return rule; + }, + mathmlBuilder(group, options) { + var width = calculateSize(group.width, options); + var height = calculateSize(group.height, options); + var shift = group.shift ? calculateSize(group.shift, options) : 0; + var color = options.color && options.getColor() || "black"; + var rule = new MathNode("mspace"); + rule.setAttribute("mathbackground", color); + rule.setAttribute("width", makeEm(width)); + rule.setAttribute("height", makeEm(height)); + var wrapper = new MathNode("mpadded", [rule]); + if (shift >= 0) { + wrapper.setAttribute("height", makeEm(shift)); + } else { + wrapper.setAttribute("height", makeEm(shift)); + wrapper.setAttribute("depth", makeEm(-shift)); + } + wrapper.setAttribute("voffset", makeEm(shift)); + return wrapper; + } +}); + +function sizingGroup(value, options, baseOptions) { + var inner = buildExpression$1(value, options, false); + var multiplier = options.sizeMultiplier / baseOptions.sizeMultiplier; + // Add size-resetting classes to the inner list and set maxFontSize + // manually. Handle nested size changes. + for (var i = 0; i < inner.length; i++) { + var pos = inner[i].classes.indexOf("sizing"); + if (pos < 0) { + Array.prototype.push.apply(inner[i].classes, options.sizingClasses(baseOptions)); + } else if (inner[i].classes[pos + 1] === "reset-size" + options.size) { + // This is a nested size change: e.g., inner[i] is the "b" in + // `\Huge a \small b`. Override the old size (the `reset-` class) + // but not the new size. + inner[i].classes[pos + 1] = "reset-size" + baseOptions.size; + } + inner[i].height *= multiplier; + inner[i].depth *= multiplier; + } + return makeFragment(inner); +} +var sizeFuncs = ["\\tiny", "\\sixptsize", "\\scriptsize", "\\footnotesize", "\\small", "\\normalsize", "\\large", "\\Large", "\\LARGE", "\\huge", "\\Huge"]; +var htmlBuilder = (group, options) => { + // Handle sizing operators like \Huge. Real TeX doesn't actually allow + // these functions inside of math expressions, so we do some special + // handling. + var newOptions = options.havingSize(group.size); + return sizingGroup(group.body, newOptions, options); +}; +defineFunction({ + type: "sizing", + names: sizeFuncs, + numArgs: 0, + allowedInText: true, + handler: (_ref, args) => { + var { + breakOnTokenText, + funcName, + parser + } = _ref; + var body = parser.parseExpression(false, breakOnTokenText); + return { + type: "sizing", + mode: parser.mode, + // Figure out what size to use based on the list of functions above + size: sizeFuncs.indexOf(funcName) + 1, + body + }; + }, + htmlBuilder, + mathmlBuilder: (group, options) => { + var newOptions = options.havingSize(group.size); + var inner = buildExpression(group.body, newOptions); + var node = new MathNode("mstyle", inner); + // TODO(emily): This doesn't produce the correct size for nested size + // changes, because we don't keep state of what style we're currently + // in, so we can't reset the size to normal before changing it. Now + // that we're passing an options parameter we should be able to fix + // this. + node.setAttribute("mathsize", makeEm(newOptions.sizeMultiplier)); + return node; + } +}); + +// smash, with optional [tb], as in AMS +defineFunction({ + type: "smash", + names: ["\\smash"], + numArgs: 1, + numOptionalArgs: 1, + allowedInText: true, + handler: (_ref, args, optArgs) => { + var { + parser + } = _ref; + var smashHeight = false; + var smashDepth = false; + var tbArg = optArgs[0] && assertNodeType(optArgs[0], "ordgroup"); + if (tbArg) { + // Optional [tb] argument is engaged. + // ref: amsmath: \renewcommand{\smash}[1][tb]{% + // def\mb@t{\ht}\def\mb@b{\dp}\def\mb@tb{\ht\z@\z@\dp}% + var letter; + for (var i = 0; i < tbArg.body.length; ++i) { + var node = tbArg.body[i]; + letter = assertSymbolNodeType(node).text; + if (letter === "t") { + smashHeight = true; + } else if (letter === "b") { + smashDepth = true; + } else { + smashHeight = false; + smashDepth = false; + break; + } + } + } else { + smashHeight = true; + smashDepth = true; + } + var body = args[0]; + return { + type: "smash", + mode: parser.mode, + body, + smashHeight, + smashDepth + }; + }, + htmlBuilder: (group, options) => { + var node = makeSpan([], [buildGroup$1(group.body, options)]); + if (!group.smashHeight && !group.smashDepth) { + return node; + } + if (group.smashHeight) { + node.height = 0; + } + if (group.smashDepth) { + node.depth = 0; + } + if (group.smashHeight && group.smashDepth) { + // Symmetric \smash can stay in inline layout. + return makeSpan(["mord", "smash"], [node], options); + } + // In order to influence makeVList for asymmetric smashing, we have to + // reset the children. + if (node.children) { + for (var i = 0; i < node.children.length; i++) { + if (group.smashHeight) { + node.children[i].height = 0; + } + if (group.smashDepth) { + node.children[i].depth = 0; + } + } + } + // At this point, we've reset the TeX-like height and depth values. + // But the span still has an HTML line height. + // makeVList applies "display: table-cell", which prevents the browser + // from acting on that line height. So we'll call makeVList now. + var smashedNode = makeVList({ + positionType: "firstBaseline", + children: [{ + type: "elem", + elem: node + }] + }); + // For spacing, TeX treats \smash as a math group (same spacing as ord). + return makeSpan(["mord"], [smashedNode], options); + }, + mathmlBuilder: (group, options) => { + var node = new MathNode("mpadded", [buildGroup(group.body, options)]); + if (group.smashHeight) { + node.setAttribute("height", "0px"); + } + if (group.smashDepth) { + node.setAttribute("depth", "0px"); + } + return node; + } +}); + +defineFunction({ + type: "sqrt", + names: ["\\sqrt"], + numArgs: 1, + numOptionalArgs: 1, + handler(_ref, args, optArgs) { + var { + parser + } = _ref; + var index = optArgs[0]; + var body = args[0]; + return { + type: "sqrt", + mode: parser.mode, + body, + index + }; + }, + htmlBuilder(group, options) { + // Square roots are handled in the TeXbook pg. 443, Rule 11. + // First, we do the same steps as in overline to build the inner group + // and line + var inner = buildGroup$1(group.body, options.havingCrampedStyle()); + if (inner.height === 0) { + // Render a small surd. + inner.height = options.fontMetrics().xHeight; + } + // Some groups can return document fragments. Handle those by wrapping + // them in a span. + inner = wrapFragment(inner, options); + // Calculate the minimum size for the \surd delimiter + var metrics = options.fontMetrics(); + var theta = metrics.defaultRuleThickness; + var phi = theta; + if (options.style.id < Style$1.TEXT.id) { + phi = options.fontMetrics().xHeight; + } + // Calculate the clearance between the body and line + var lineClearance = theta + phi / 4; + var minDelimiterHeight = inner.height + inner.depth + lineClearance + theta; + // Create a sqrt SVG of the required minimum size + var { + span: img, + ruleWidth, + advanceWidth + } = makeSqrtImage(minDelimiterHeight, options); + var delimDepth = img.height - ruleWidth; + // Adjust the clearance based on the delimiter size + if (delimDepth > inner.height + inner.depth + lineClearance) { + lineClearance = (lineClearance + delimDepth - inner.height - inner.depth) / 2; + } + // Shift the sqrt image + var imgShift = img.height - inner.height - lineClearance - ruleWidth; + inner.style.paddingLeft = makeEm(advanceWidth); + // Overlay the image and the argument. + var body = makeVList({ + positionType: "firstBaseline", + children: [{ + type: "elem", + elem: inner, + wrapperClasses: ["svg-align"] + }, { + type: "kern", + size: -(inner.height + imgShift) + }, { + type: "elem", + elem: img + }, { + type: "kern", + size: ruleWidth + }] + }); + if (!group.index) { + return makeSpan(["mord", "sqrt"], [body], options); + } else { + // Handle the optional root index + // The index is always in scriptscript style + var newOptions = options.havingStyle(Style$1.SCRIPTSCRIPT); + var rootm = buildGroup$1(group.index, newOptions, options); + // The amount the index is shifted by. This is taken from the TeX + // source, in the definition of `\r@@t`. + var toShift = 0.6 * (body.height - body.depth); + // Build a VList with the superscript shifted up correctly + var rootVList = makeVList({ + positionType: "shift", + positionData: -toShift, + children: [{ + type: "elem", + elem: rootm + }] + }); + // Add a class surrounding it so we can add on the appropriate + // kerning + var rootVListWrap = makeSpan(["root"], [rootVList]); + return makeSpan(["mord", "sqrt"], [rootVListWrap, body], options); + } + }, + mathmlBuilder(group, options) { + var { + body, + index + } = group; + return index ? new MathNode("mroot", [buildGroup(body, options), buildGroup(index, options)]) : new MathNode("msqrt", [buildGroup(body, options)]); + } +}); + +var styleMap = { + "display": Style$1.DISPLAY, + "text": Style$1.TEXT, + "script": Style$1.SCRIPT, + "scriptscript": Style$1.SCRIPTSCRIPT +}; +function isStyleStr(s) { + return s in styleMap; +} +defineFunction({ + type: "styling", + names: ["\\displaystyle", "\\textstyle", "\\scriptstyle", "\\scriptscriptstyle"], + numArgs: 0, + allowedInText: true, + primitive: true, + handler(_ref, args) { + var { + breakOnTokenText, + funcName, + parser + } = _ref; + // parse out the implicit body + var body = parser.parseExpression(true, breakOnTokenText); + // TODO: Refactor to avoid duplicating styleMap in multiple places (e.g. + // here and in buildHTML and de-dupe the enumeration of all the styles). + var style = funcName.slice(1, funcName.length - 5); + if (!isStyleStr(style)) { + throw new Error("Unknown style: " + style); + } + return { + type: "styling", + mode: parser.mode, + // Figure out what style to use by pulling out the style from + // the function name + style, + body + }; + }, + htmlBuilder(group, options) { + // Style changes are handled in the TeXbook on pg. 442, Rule 3. + var newStyle = styleMap[group.style]; + var newOptions = options.havingStyle(newStyle); + if (group.resetFont) { + newOptions = newOptions.withFont(''); + } + return sizingGroup(group.body, newOptions, options); + }, + mathmlBuilder(group, options) { + // Figure out what style we're changing to. + var newStyle = styleMap[group.style]; + var newOptions = options.havingStyle(newStyle); + if (group.resetFont) { + newOptions = newOptions.withFont(''); + } + var inner = buildExpression(group.body, newOptions); + var node = new MathNode("mstyle", inner); + var styleAttributes = { + "display": ["0", "true"], + "text": ["0", "false"], + "script": ["1", "false"], + "scriptscript": ["2", "false"] + }; + var attr = styleAttributes[group.style]; + node.setAttribute("scriptlevel", attr[0]); + node.setAttribute("displaystyle", attr[1]); + return node; + } +}); + +/** + * Sometimes, groups perform special rules when they have superscripts or + * subscripts attached to them. This function lets the `supsub` group know that + * Sometimes, groups perform special rules when they have superscripts or + * its inner element should handle the superscripts and subscripts instead of + * handling them itself. + */ +var htmlBuilderDelegate = function htmlBuilderDelegate(group, options) { + var base = group.base; + if (!base) { + return null; + } else if (base.type === "op") { + // Operators handle supsubs differently when they have limits + // (e.g. `\displaystyle\sum_2^3`) + var delegate = base.limits && (options.style.size === Style$1.DISPLAY.size || base.alwaysHandleSupSub); + return delegate ? htmlBuilder$2 : null; + } else if (base.type === "operatorname") { + var _delegate = base.alwaysHandleSupSub && (options.style.size === Style$1.DISPLAY.size || base.limits); + return _delegate ? htmlBuilder$1 : null; + } else if (base.type === "accent") { + return isCharacterBox(base.base) ? htmlBuilder$a : null; + } else if (base.type === "horizBrace") { + var isSup = !group.sub; + return isSup === base.isOver ? htmlBuilder$3 : null; + } else { + return null; + } +}; +// Super scripts and subscripts, whose precise placement can depend on other +// functions that precede them. +defineFunctionBuilders({ + type: "supsub", + htmlBuilder(group, options) { + // Superscript and subscripts are handled in the TeXbook on page + // 445-446, rules 18(a-f). + // Here is where we defer to the inner group if it should handle + // superscripts and subscripts itself. + var builderDelegate = htmlBuilderDelegate(group, options); + if (builderDelegate) { + return builderDelegate(group, options); + } + var { + base: valueBase, + sup: valueSup, + sub: valueSub + } = group; + var base = buildGroup$1(valueBase, options); + var supm; + var subm; + var metrics = options.fontMetrics(); + // Rule 18a + var supShift = 0; + var subShift = 0; + var isCharBox = valueBase && isCharacterBox(valueBase); + if (valueSup) { + var newOptions = options.havingStyle(options.style.sup()); + supm = buildGroup$1(valueSup, newOptions, options); + if (!isCharBox) { + supShift = base.height - newOptions.fontMetrics().supDrop * newOptions.sizeMultiplier / options.sizeMultiplier; + } + } + if (valueSub) { + var _newOptions = options.havingStyle(options.style.sub()); + subm = buildGroup$1(valueSub, _newOptions, options); + if (!isCharBox) { + subShift = base.depth + _newOptions.fontMetrics().subDrop * _newOptions.sizeMultiplier / options.sizeMultiplier; + } + } + // Rule 18c + var minSupShift; + if (options.style === Style$1.DISPLAY) { + minSupShift = metrics.sup1; + } else if (options.style.cramped) { + minSupShift = metrics.sup3; + } else { + minSupShift = metrics.sup2; + } + // scriptspace is a font-size-independent size, so scale it + // appropriately for use as the marginRight. + var multiplier = options.sizeMultiplier; + var marginRight = makeEm(0.5 / metrics.ptPerEm / multiplier); + var marginLeft = null; + if (subm) { + // Subscripts shouldn't be shifted by the base's italic correction. + // Account for that by shifting the subscript back the appropriate + // amount. Note we only do this when the base is a single symbol. + var isOiint = group.base && group.base.type === "op" && group.base.name && (group.base.name === "\\oiint" || group.base.name === "\\oiiint"); + if (base instanceof SymbolNode || isOiint) { + var _base$italic; + // SymbolNode has .italic natively; for \oiint/\oiiint the + // op builder stores .italic on the wrapping Span. + marginLeft = makeEm(-((_base$italic = base.italic) != null ? _base$italic : 0)); + } + } + var supsub; + if (supm && subm) { + supShift = Math.max(supShift, minSupShift, supm.depth + 0.25 * metrics.xHeight); + subShift = Math.max(subShift, metrics.sub2); + var ruleWidth = metrics.defaultRuleThickness; + // Rule 18e + var maxWidth = 4 * ruleWidth; + if (supShift - supm.depth - (subm.height - subShift) < maxWidth) { + subShift = maxWidth - (supShift - supm.depth) + subm.height; + var psi = 0.8 * metrics.xHeight - (supShift - supm.depth); + if (psi > 0) { + supShift += psi; + subShift -= psi; + } + } + var vlistElem = [{ + type: "elem", + elem: subm, + shift: subShift, + marginRight, + marginLeft + }, { + type: "elem", + elem: supm, + shift: -supShift, + marginRight + }]; + supsub = makeVList({ + positionType: "individualShift", + children: vlistElem + }); + } else if (subm) { + // Rule 18b + subShift = Math.max(subShift, metrics.sub1, subm.height - 0.8 * metrics.xHeight); + var _vlistElem = [{ + type: "elem", + elem: subm, + marginLeft, + marginRight + }]; + supsub = makeVList({ + positionType: "shift", + positionData: subShift, + children: _vlistElem + }); + } else if (supm) { + // Rule 18c, d + supShift = Math.max(supShift, minSupShift, supm.depth + 0.25 * metrics.xHeight); + supsub = makeVList({ + positionType: "shift", + positionData: -supShift, + children: [{ + type: "elem", + elem: supm, + marginRight + }] + }); + } else { + throw new Error("supsub must have either sup or sub."); + } + // Wrap the supsub vlist in a span.msupsub to reset text-align. + var mclass = getTypeOfDomTree(base, "right") || "mord"; + return makeSpan([mclass], [base, makeSpan(["msupsub"], [supsub])], options); + }, + mathmlBuilder(group, options) { + // Is the inner group a relevant horizontal brace? + var isBrace = false; + var isOver; + var isSup; + if (group.base && group.base.type === "horizBrace") { + isSup = !!group.sup; + if (isSup === group.base.isOver) { + isBrace = true; + isOver = group.base.isOver; + } + } + if (group.base && (group.base.type === "op" || group.base.type === "operatorname")) { + group.base.parentIsSupSub = true; + } + var children = [buildGroup(group.base, options)]; + if (group.sub) { + children.push(buildGroup(group.sub, options)); + } + if (group.sup) { + children.push(buildGroup(group.sup, options)); + } + var nodeType; + if (isBrace) { + nodeType = isOver ? "mover" : "munder"; + } else if (!group.sub) { + var base = group.base; + if (base && base.type === "op" && base.limits && (options.style === Style$1.DISPLAY || base.alwaysHandleSupSub)) { + nodeType = "mover"; + } else if (base && base.type === "operatorname" && base.alwaysHandleSupSub && (base.limits || options.style === Style$1.DISPLAY)) { + nodeType = "mover"; + } else { + nodeType = "msup"; + } + } else if (!group.sup) { + var _base = group.base; + if (_base && _base.type === "op" && _base.limits && (options.style === Style$1.DISPLAY || _base.alwaysHandleSupSub)) { + nodeType = "munder"; + } else if (_base && _base.type === "operatorname" && _base.alwaysHandleSupSub && (_base.limits || options.style === Style$1.DISPLAY)) { + nodeType = "munder"; + } else { + nodeType = "msub"; + } + } else { + var _base2 = group.base; + if (_base2 && _base2.type === "op" && _base2.limits && options.style === Style$1.DISPLAY) { + nodeType = "munderover"; + } else if (_base2 && _base2.type === "operatorname" && _base2.alwaysHandleSupSub && (options.style === Style$1.DISPLAY || _base2.limits)) { + nodeType = "munderover"; + } else { + nodeType = "msubsup"; + } + } + return new MathNode(nodeType, children); + } +}); + +// Operator ParseNodes created in Parser.js from symbol Groups in src/symbols.js. +defineFunctionBuilders({ + type: "atom", + htmlBuilder(group, options) { + return mathsym(group.text, group.mode, options, ["m" + group.family]); + }, + mathmlBuilder(group, options) { + var node = new MathNode("mo", [makeText(group.text, group.mode)]); + if (group.family === "bin") { + var variant = getVariant(group, options); + if (variant === "bold-italic") { + node.setAttribute("mathvariant", variant); + } + } else if (group.family === "punct") { + node.setAttribute("separator", "true"); + } else if (group.family === "open" || group.family === "close") { + // Delims built here should not stretch vertically. + // See delimsizing.js for stretchy delims. + node.setAttribute("stretchy", "false"); + } + return node; + } +}); + +// "mathord" and "textord" ParseNodes created in Parser.js from symbol Groups in +// src/symbols.js. +var defaultVariant = { + "mi": "italic", + "mn": "normal", + "mtext": "normal" +}; +defineFunctionBuilders({ + type: "mathord", + htmlBuilder(group, options) { + return makeOrd(group, options); + }, + mathmlBuilder(group, options) { + var node = new MathNode("mi", [makeText(group.text, group.mode, options)]); + var variant = getVariant(group, options) || "italic"; + if (variant !== defaultVariant[node.type]) { + node.setAttribute("mathvariant", variant); + } + return node; + } +}); +defineFunctionBuilders({ + type: "textord", + htmlBuilder(group, options) { + return makeOrd(group, options); + }, + mathmlBuilder(group, options) { + var text = makeText(group.text, group.mode, options); + var variant = getVariant(group, options) || "normal"; + var node; + if (group.mode === 'text') { + node = new MathNode("mtext", [text]); + } else if (/[0-9]/.test(group.text)) { + node = new MathNode("mn", [text]); + } else if (group.text === "\\prime") { + node = new MathNode("mo", [text]); + } else { + node = new MathNode("mi", [text]); + } + if (variant !== defaultVariant[node.type]) { + node.setAttribute("mathvariant", variant); + } + return node; + } +}); + +// A map of CSS-based spacing functions to their CSS class. +var cssSpace = { + "\\nobreak": "nobreak", + "\\allowbreak": "allowbreak" +}; +// A lookup table to determine whether a spacing function/symbol should be +// treated like a regular space character. If a symbol or command is a key +// in this table, then it should be a regular space character. Furthermore, +// the associated value may have a `className` specifying an extra CSS class +// to add to the created `span`. +var regularSpace = { + " ": {}, + "\\ ": {}, + "~": { + className: "nobreak" + }, + "\\space": {}, + "\\nobreakspace": { + className: "nobreak" + } +}; +// ParseNode<"spacing"> created in Parser.js from the "spacing" symbol Groups in +// src/symbols.js. +defineFunctionBuilders({ + type: "spacing", + htmlBuilder(group, options) { + if (regularSpace.hasOwnProperty(group.text)) { + var className = regularSpace[group.text].className || ""; + // Spaces are generated by adding an actual space. Each of these + // things has an entry in the symbols table, so these will be turned + // into appropriate outputs. + if (group.mode === "text") { + var ord = makeOrd(group, options); + ord.classes.push(className); + return ord; + } else { + return makeSpan(["mspace", className], [mathsym(group.text, group.mode, options)], options); + } + } else if (cssSpace.hasOwnProperty(group.text)) { + // Spaces based on just a CSS class. + return makeSpan(["mspace", cssSpace[group.text]], [], options); + } else { + throw new ParseError("Unknown type of space \"" + group.text + "\""); + } + }, + mathmlBuilder(group, options) { + var node; + if (regularSpace.hasOwnProperty(group.text)) { + node = new MathNode("mtext", [new TextNode("\u00a0")]); + } else if (cssSpace.hasOwnProperty(group.text)) { + // CSS-based MathML spaces (\nobreak, \allowbreak) are ignored + return new MathNode("mspace"); + } else { + throw new ParseError("Unknown type of space \"" + group.text + "\""); + } + return node; + } +}); + +var pad = () => { + var padNode = new MathNode("mtd", []); + padNode.setAttribute("width", "50%"); + return padNode; +}; +defineFunctionBuilders({ + type: "tag", + mathmlBuilder(group, options) { + var table = new MathNode("mtable", [new MathNode("mtr", [pad(), new MathNode("mtd", [buildExpressionRow(group.body, options)]), pad(), new MathNode("mtd", [buildExpressionRow(group.tag, options)])])]); + table.setAttribute("width", "100%"); + return table; + // TODO: Left-aligned tags. + // Currently, the group and options passed here do not contain + // enough info to set tag alignment. `leqno` is in Settings but it is + // not passed to Options. On the HTML side, leqno is + // set by a CSS class applied in buildTree.js. That would have worked + // in MathML if browsers supported . Since they don't, we + // need to rewrite the way this function is called. + } +}); + +// Non-mathy text, possibly in a font +var textFontFamilies = { + "\\text": undefined, + "\\textrm": "textrm", + "\\textsf": "textsf", + "\\texttt": "texttt", + "\\textnormal": "textrm" +}; +var textFontWeights = { + "\\textbf": "textbf", + "\\textmd": "textmd" +}; +var textFontShapes = { + "\\textit": "textit", + "\\textup": "textup" +}; +var optionsWithFont = (group, options) => { + var font = group.font; + // Checks if the argument is a font family or a font style. + if (!font) { + return options; + } else if (textFontFamilies[font]) { + return options.withTextFontFamily(textFontFamilies[font]); + } else if (textFontWeights[font]) { + return options.withTextFontWeight(textFontWeights[font]); + } else if (font === "\\emph") { + return options.fontShape === "textit" ? options.withTextFontShape("textup") : options.withTextFontShape("textit"); + } + return options.withTextFontShape(textFontShapes[font]); +}; +defineFunction({ + type: "text", + names: [ + // Font families + "\\text", "\\textrm", "\\textsf", "\\texttt", "\\textnormal", + // Font weights + "\\textbf", "\\textmd", + // Font Shapes + "\\textit", "\\textup", "\\emph"], + numArgs: 1, + argTypes: ["text"], + allowedInArgument: true, + allowedInText: true, + handler(_ref, args) { + var { + parser, + funcName + } = _ref; + var body = args[0]; + return { + type: "text", + mode: parser.mode, + body: ordargument(body), + font: funcName + }; + }, + htmlBuilder(group, options) { + var newOptions = optionsWithFont(group, options); + var inner = buildExpression$1(group.body, newOptions, true); + return makeSpan(["mord", "text"], inner, newOptions); + }, + mathmlBuilder(group, options) { + var newOptions = optionsWithFont(group, options); + return buildExpressionRow(group.body, newOptions); + } +}); + +defineFunction({ + type: "underline", + names: ["\\underline"], + numArgs: 1, + allowedInText: true, + handler(_ref, args) { + var { + parser + } = _ref; + return { + type: "underline", + mode: parser.mode, + body: args[0] + }; + }, + htmlBuilder(group, options) { + // Underlines are handled in the TeXbook pg 443, Rule 10. + // Build the inner group. + var innerGroup = buildGroup$1(group.body, options); + // Create the line to go below the body + var line = makeLineSpan("underline-line", options); + // Generate the vlist, with the appropriate kerns + var defaultRuleThickness = options.fontMetrics().defaultRuleThickness; + var vlist = makeVList({ + positionType: "top", + positionData: innerGroup.height, + children: [{ + type: "kern", + size: defaultRuleThickness + }, { + type: "elem", + elem: line + }, { + type: "kern", + size: 3 * defaultRuleThickness + }, { + type: "elem", + elem: innerGroup + }] + }); + return makeSpan(["mord", "underline"], [vlist], options); + }, + mathmlBuilder(group, options) { + var operator = new MathNode("mo", [new TextNode("\u203e")]); + operator.setAttribute("stretchy", "true"); + var node = new MathNode("munder", [buildGroup(group.body, options), operator]); + node.setAttribute("accentunder", "true"); + return node; + } +}); + +// \vcenter: Vertically center the argument group on the math axis. +defineFunction({ + type: "vcenter", + names: ["\\vcenter"], + numArgs: 1, + argTypes: ["original"], + // In LaTeX, \vcenter can act only on a box. + allowedInText: false, + handler(_ref, args) { + var { + parser + } = _ref; + return { + type: "vcenter", + mode: parser.mode, + body: args[0] + }; + }, + htmlBuilder(group, options) { + var body = buildGroup$1(group.body, options); + var axisHeight = options.fontMetrics().axisHeight; + var dy = 0.5 * (body.height - axisHeight - (body.depth + axisHeight)); + return makeVList({ + positionType: "shift", + positionData: dy, + children: [{ + type: "elem", + elem: body + }] + }); + }, + mathmlBuilder(group, options) { + // There is no way to do this in MathML. + // Write a class as a breadcrumb in case some post-processor wants + // to perform a vcenter adjustment. + // Wrap in mrow to ensure valid MathML when placed inside mo (e.g., \mathrel) + var mpadded = new MathNode("mpadded", [buildGroup(group.body, options)], ["vcenter"]); + return new MathNode("mrow", [mpadded]); + } +}); + +defineFunction({ + type: "verb", + names: ["\\verb"], + numArgs: 0, + allowedInText: true, + handler(context, args, optArgs) { + // \verb and \verb* are dealt with directly in Parser.js. + // If we end up here, it's because of a failure to match the two delimiters + // in the regex in Lexer.js. LaTeX raises the following error when \verb is + // terminated by end of line (or file). + throw new ParseError("\\verb ended by end of line instead of matching delimiter"); + }, + htmlBuilder(group, options) { + var text = makeVerb(group); + var body = []; + // \verb enters text mode and therefore is sized like \textstyle + var newOptions = options.havingStyle(options.style.text()); + for (var i = 0; i < text.length; i++) { + var c = text[i]; + if (c === '~') { + c = '\\textasciitilde'; + } + body.push(makeSymbol(c, "Typewriter-Regular", group.mode, newOptions, ["mord", "texttt"])); + } + return makeSpan(["mord", "text"].concat(newOptions.sizingClasses(options)), tryCombineChars(body), newOptions); + }, + mathmlBuilder(group, options) { + var text = new TextNode(makeVerb(group)); + var node = new MathNode("mtext", [text]); + node.setAttribute("mathvariant", "monospace"); + return node; + } +}); +/** + * Converts verb group into body string. + * + * \verb* replaces each space with an open box \u2423 + * \verb replaces each space with a no-break space \xA0 + */ +var makeVerb = group => group.body.replace(/ /g, group.star ? '\u2423' : '\xA0'); + +/** Include this to ensure that all functions are defined. */ +var functions = _functions; + +/** + * The Lexer class handles tokenizing the input in various ways. Since our + * parser expects us to be able to backtrack, the lexer allows lexing from any + * given starting point. + * + * Its main exposed function is the `lex` function, which takes a position to + * lex from and a type of token to lex. It defers to the appropriate `_innerLex` + * function. + * + * The various `_innerLex` functions perform the actual lexing of different + * kinds. + */ +/* The following tokenRegex + * - matches typical whitespace (but not NBSP etc.) using its first group + * - does not match any control character \x00-\x1f except whitespace + * - does not match a bare backslash + * - matches any ASCII character except those just mentioned + * - does not match the BMP private use area \uE000-\uF8FF + * - does not match bare surrogate code units + * - matches any BMP character except for those just described + * - matches any valid Unicode surrogate pair + * - matches a backslash followed by one or more whitespace characters + * - matches a backslash followed by one or more letters then whitespace + * - matches a backslash followed by any BMP character + * Capturing groups: + * [1] regular whitespace + * [2] backslash followed by whitespace + * [3] anything else, which may include: + * [4] left character of \verb* + * [5] left character of \verb + * [6] backslash followed by word, excluding any trailing whitespace + * Just because the Lexer matches something doesn't mean it's valid input: + * If there is no matching function or symbol definition, the Parser will + * still reject the input. + */ +var spaceRegexString = "[ \r\n\t]"; +var controlWordRegexString = "\\\\[a-zA-Z@]+"; +var controlSymbolRegexString = "\\\\[^\uD800-\uDFFF]"; +var controlWordWhitespaceRegexString = "(" + controlWordRegexString + ")" + spaceRegexString + "*"; +var controlSpaceRegexString = "\\\\(\n|[ \r\t]+\n?)[ \r\t]*"; +var combiningDiacriticalMarkString = "[\u0300-\u036f]"; +var combiningDiacriticalMarksEndRegex = new RegExp(combiningDiacriticalMarkString + "+$"); +var tokenRegexString = "(" + spaceRegexString + "+)|" + (// whitespace +controlSpaceRegexString + "|") + +// \whitespace +"([!-\\[\\]-\u2027\u202A-\uD7FF\uF900-\uFFFF]" + (// single codepoint +combiningDiacriticalMarkString + "*") + +// ...plus accents +"|[\uD800-\uDBFF][\uDC00-\uDFFF]" + (// surrogate pair +combiningDiacriticalMarkString + "*") + +// ...plus accents +"|\\\\verb\\*([^]).*?\\4" + +// \verb* +"|\\\\verb([^*a-zA-Z]).*?\\5" + (// \verb unstarred +"|" + controlWordWhitespaceRegexString) + (// \macroName + spaces +"|" + controlSymbolRegexString + ")"); // \\, \', etc. +/** Main Lexer class */ +class Lexer { + constructor(input, settings) { + this.input = void 0; + this.settings = void 0; + this.tokenRegex = void 0; + // Category codes. The lexer only supports comment characters (14) for now. + // MacroExpander additionally distinguishes active (13). + this.catcodes = void 0; + // Separate accents from characters + this.input = input; + this.settings = settings; + this.tokenRegex = new RegExp(tokenRegexString, 'g'); + this.catcodes = { + "%": 14, + // comment character + "~": 13 // active character + }; + } + setCatcode(char, code) { + this.catcodes[char] = code; + } + /** + * This function lexes a single token. + */ + lex() { + var input = this.input; + var pos = this.tokenRegex.lastIndex; + if (pos === input.length) { + return new Token("EOF", new SourceLocation(this, pos, pos)); + } + var match = this.tokenRegex.exec(input); + if (match === null || match.index !== pos) { + throw new ParseError("Unexpected character: '" + input[pos] + "'", new Token(input[pos], new SourceLocation(this, pos, pos + 1))); + } + var text = match[6] || match[3] || (match[2] ? "\\ " : " "); + if (this.catcodes[text] === 14) { + // comment character + var nlIndex = input.indexOf('\n', this.tokenRegex.lastIndex); + if (nlIndex === -1) { + this.tokenRegex.lastIndex = input.length; // EOF + this.settings.reportNonstrict("commentAtEnd", "% comment has no terminating newline; LaTeX would " + "fail because of commenting the end of math mode (e.g. $)"); + } else { + this.tokenRegex.lastIndex = nlIndex + 1; + } + return this.lex(); + } + return new Token(text, new SourceLocation(this, pos, this.tokenRegex.lastIndex)); + } +} + +/** + * A `Namespace` refers to a space of nameable things like macros or lengths, + * which can be `set` either globally or local to a nested group, using an + * undo stack similar to how TeX implements this functionality. + * Performance-wise, `get` and local `set` take constant time, while global + * `set` takes time proportional to the depth of group nesting. + */ +class Namespace { + /** + * Both arguments are optional. The first argument is an object of + * built-in mappings which never change. The second argument is an object + * of initial (global-level) mappings, which will constantly change + * according to any global/top-level `set`s done. + */ + constructor(builtins, globalMacros) { + if (builtins === void 0) { + builtins = {}; + } + if (globalMacros === void 0) { + globalMacros = {}; + } + this.current = void 0; + this.builtins = void 0; + this.undefStack = void 0; + this.current = globalMacros; + this.builtins = builtins; + this.undefStack = []; + } + /** + * Start a new nested group, affecting future local `set`s. + */ + beginGroup() { + this.undefStack.push({}); + } + /** + * End current nested group, restoring values before the group began. + */ + endGroup() { + if (this.undefStack.length === 0) { + throw new ParseError("Unbalanced namespace destruction: attempt " + "to pop global namespace; please report this as a bug"); + } + var undefs = this.undefStack.pop(); + for (var undef in undefs) { + if (undefs.hasOwnProperty(undef)) { + if (undefs[undef] == null) { + delete this.current[undef]; + } else { + this.current[undef] = undefs[undef]; + } + } + } + } + /** + * Ends all currently nested groups (if any), restoring values before the + * groups began. Useful in case of an error in the middle of parsing. + */ + endGroups() { + while (this.undefStack.length > 0) { + this.endGroup(); + } + } + /** + * Detect whether `name` has a definition. Equivalent to + * `get(name) != null`. + */ + has(name) { + return this.current.hasOwnProperty(name) || this.builtins.hasOwnProperty(name); + } + /** + * Get the current value of a name, or `undefined` if there is no value. + * + * Note: Do not use `if (namespace.get(...))` to detect whether a macro + * is defined, as the definition may be the empty string which evaluates + * to `false` in JavaScript. Use `if (namespace.get(...) != null)` or + * `if (namespace.has(...))`. + */ + get(name) { + if (this.current.hasOwnProperty(name)) { + return this.current[name]; + } else { + return this.builtins[name]; + } + } + /** + * Set the current value of a name, and optionally set it globally too. + * Local set() sets the current value and (when appropriate) adds an undo + * operation to the undo stack. Global set() may change the undo + * operation at every level, so takes time linear in their number. + * A value of undefined means to delete existing definitions. + */ + set(name, value, global) { + if (global === void 0) { + global = false; + } + if (global) { + // Global set is equivalent to setting in all groups. Simulate this + // by destroying any undos currently scheduled for this name, + // and adding an undo with the *new* value (in case it later gets + // locally reset within this environment). + for (var i = 0; i < this.undefStack.length; i++) { + delete this.undefStack[i][name]; + } + if (this.undefStack.length > 0) { + this.undefStack[this.undefStack.length - 1][name] = value; + } + } else { + // Undo this set at end of this group (possibly to `undefined`), + // unless an undo is already in place, in which case that older + // value is the correct one. + var top = this.undefStack[this.undefStack.length - 1]; + if (top && !top.hasOwnProperty(name)) { + top[name] = this.current[name]; + } + } + if (value == null) { + delete this.current[name]; + } else { + this.current[name] = value; + } + } +} + +/** + * Predefined macros for KaTeX. + * This can be used to define some commands in terms of others. + */ +var macros = _macros; +////////////////////////////////////////////////////////////////////// +// macro tools +defineMacro("\\noexpand", function (context) { + // The expansion is the token itself; but that token is interpreted + // as if its meaning were ‘\relax’ if it is a control sequence that + // would ordinarily be expanded by TeX’s expansion rules. + var t = context.popToken(); + if (context.isExpandable(t.text)) { + t.noexpand = true; + t.treatAsRelax = true; + } + return { + tokens: [t], + numArgs: 0 + }; +}); +defineMacro("\\expandafter", function (context) { + // TeX first reads the token that comes immediately after \expandafter, + // without expanding it; let’s call this token t. Then TeX reads the + // token that comes after t (and possibly more tokens, if that token + // has an argument), replacing it by its expansion. Finally TeX puts + // t back in front of that expansion. + var t = context.popToken(); + context.expandOnce(true); // expand only an expandable token + return { + tokens: [t], + numArgs: 0 + }; +}); +// LaTeX's \@firstoftwo{#1}{#2} expands to #1, skipping #2 +// TeX source: \long\def\@firstoftwo#1#2{#1} +defineMacro("\\@firstoftwo", function (context) { + var args = context.consumeArgs(2); + return { + tokens: args[0], + numArgs: 0 + }; +}); +// LaTeX's \@secondoftwo{#1}{#2} expands to #2, skipping #1 +// TeX source: \long\def\@secondoftwo#1#2{#2} +defineMacro("\\@secondoftwo", function (context) { + var args = context.consumeArgs(2); + return { + tokens: args[1], + numArgs: 0 + }; +}); +// LaTeX's \@ifnextchar{#1}{#2}{#3} looks ahead to the next (unexpanded) +// symbol that isn't a space, consuming any spaces but not consuming the +// first nonspace character. If that nonspace character matches #1, then +// the macro expands to #2; otherwise, it expands to #3. +defineMacro("\\@ifnextchar", function (context) { + var args = context.consumeArgs(3); // symbol, if, else + context.consumeSpaces(); + var nextToken = context.future(); + if (args[0].length === 1 && args[0][0].text === nextToken.text) { + return { + tokens: args[1], + numArgs: 0 + }; + } else { + return { + tokens: args[2], + numArgs: 0 + }; + } +}); +// LaTeX's \@ifstar{#1}{#2} looks ahead to the next (unexpanded) symbol. +// If it is `*`, then it consumes the symbol, and the macro expands to #1; +// otherwise, the macro expands to #2 (without consuming the symbol). +// TeX source: \def\@ifstar#1{\@ifnextchar *{\@firstoftwo{#1}}} +defineMacro("\\@ifstar", "\\@ifnextchar *{\\@firstoftwo{#1}}"); +// LaTeX's \TextOrMath{#1}{#2} expands to #1 in text mode, #2 in math mode +defineMacro("\\TextOrMath", function (context) { + var args = context.consumeArgs(2); + if (context.mode === 'text') { + return { + tokens: args[0], + numArgs: 0 + }; + } else { + return { + tokens: args[1], + numArgs: 0 + }; + } +}); +// Lookup table for parsing numbers in base 8 through 16 +var digitToNumber = { + "0": 0, + "1": 1, + "2": 2, + "3": 3, + "4": 4, + "5": 5, + "6": 6, + "7": 7, + "8": 8, + "9": 9, + "a": 10, + "A": 10, + "b": 11, + "B": 11, + "c": 12, + "C": 12, + "d": 13, + "D": 13, + "e": 14, + "E": 14, + "f": 15, + "F": 15 +}; +// TeX \char makes a literal character (catcode 12) using the following forms: +// (see The TeXBook, p. 43) +// \char123 -- decimal +// \char'123 -- octal +// \char"123 -- hex +// \char`x -- character that can be written (i.e. isn't active) +// \char`\x -- character that cannot be written (e.g. %) +// These all refer to characters from the font, so we turn them into special +// calls to a function \@char dealt with in the Parser. +defineMacro("\\char", function (context) { + var token = context.popToken(); + var base; + var number = 0; + if (token.text === "'") { + base = 8; + token = context.popToken(); + } else if (token.text === '"') { + base = 16; + token = context.popToken(); + } else if (token.text === "`") { + token = context.popToken(); + if (token.text[0] === "\\") { + number = token.text.charCodeAt(1); + } else if (token.text === "EOF") { + throw new ParseError("\\char` missing argument"); + } else { + number = token.text.charCodeAt(0); + } + } else { + base = 10; + } + if (base) { + // Parse a number in the given base, starting with first `token`. + number = digitToNumber[token.text]; + if (number == null || number >= base) { + throw new ParseError("Invalid base-" + base + " digit " + token.text); + } + var digit; + while ((digit = digitToNumber[context.future().text]) != null && digit < base) { + number *= base; + number += digit; + context.popToken(); + } + } + return "\\@char{" + number + "}"; +}); +// \newcommand{\macro}[args]{definition} +// \renewcommand{\macro}[args]{definition} +// TODO: Optional arguments: \newcommand{\macro}[args][default]{definition} +var newcommand = (context, existsOK, nonexistsOK, skipIfExists) => { + var arg = context.consumeArg().tokens; + if (arg.length !== 1) { + throw new ParseError("\\newcommand's first argument must be a macro name"); + } + var name = arg[0].text; + var exists = context.isDefined(name); + if (exists && !existsOK) { + throw new ParseError("\\newcommand{" + name + "} attempting to redefine " + (name + "; use \\renewcommand")); + } + if (!exists && !nonexistsOK) { + throw new ParseError("\\renewcommand{" + name + "} when command " + name + " " + "does not yet exist; use \\newcommand"); + } + var numArgs = 0; + arg = context.consumeArg().tokens; + if (arg.length === 1 && arg[0].text === "[") { + var argText = ''; + var token = context.expandNextToken(); + while (token.text !== "]" && token.text !== "EOF") { + // TODO: Should properly expand arg, e.g., ignore {}s + argText += token.text; + token = context.expandNextToken(); + } + if (!argText.match(/^\s*[0-9]+\s*$/)) { + throw new ParseError("Invalid number of arguments: " + argText); + } + numArgs = parseInt(argText); + arg = context.consumeArg().tokens; + } + if (!(exists && skipIfExists)) { + // Final arg is the expansion of the macro + context.macros.set(name, { + tokens: arg, + numArgs + }); + } + return ''; +}; +defineMacro("\\newcommand", context => newcommand(context, false, true, false)); +defineMacro("\\renewcommand", context => newcommand(context, true, false, false)); +defineMacro("\\providecommand", context => newcommand(context, true, true, true)); +// terminal (console) tools +defineMacro("\\message", context => { + var arg = context.consumeArgs(1)[0]; + // eslint-disable-next-line no-console + console.log(arg.reverse().map(token => token.text).join("")); + return ''; +}); +defineMacro("\\errmessage", context => { + var arg = context.consumeArgs(1)[0]; + // eslint-disable-next-line no-console + console.error(arg.reverse().map(token => token.text).join("")); + return ''; +}); +defineMacro("\\show", context => { + var tok = context.popToken(); + var name = tok.text; + // eslint-disable-next-line no-console + console.log(tok, context.macros.get(name), functions[name], symbols.math[name], symbols.text[name]); + return ''; +}); +////////////////////////////////////////////////////////////////////// +// Grouping +// \let\bgroup={ \let\egroup=} +defineMacro("\\bgroup", "{"); +defineMacro("\\egroup", "}"); +// Symbols from latex.ltx: +// \def~{\nobreakspace{}} +// \def\lq{`} +// \def\rq{'} +// \def \aa {\r a} +// \def \AA {\r A} +defineMacro("~", "\\nobreakspace"); +defineMacro("\\lq", "`"); +defineMacro("\\rq", "'"); +defineMacro("\\aa", "\\r a"); +defineMacro("\\AA", "\\r A"); +// Copyright (C) and registered (R) symbols. Use raw symbol in MathML. +// \DeclareTextCommandDefault{\textcopyright}{\textcircled{c}} +// \DeclareTextCommandDefault{\textregistered}{\textcircled{% +// \check@mathfonts\fontsize\sf@size\z@\math@fontsfalse\selectfont R}} +// \DeclareRobustCommand{\copyright}{% +// \ifmmode{\nfss@text{\textcopyright}}\else\textcopyright\fi} +defineMacro("\\textcopyright", "\\html@mathml{\\textcircled{c}}{\\char`©}"); +defineMacro("\\copyright", "\\TextOrMath{\\textcopyright}{\\text{\\textcopyright}}"); +defineMacro("\\textregistered", "\\html@mathml{\\textcircled{\\scriptsize R}}{\\char`®}"); +// Characters omitted from Unicode range 1D400–1D7FF +defineMacro("\u212C", "\\mathscr{B}"); // script +defineMacro("\u2130", "\\mathscr{E}"); +defineMacro("\u2131", "\\mathscr{F}"); +defineMacro("\u210B", "\\mathscr{H}"); +defineMacro("\u2110", "\\mathscr{I}"); +defineMacro("\u2112", "\\mathscr{L}"); +defineMacro("\u2133", "\\mathscr{M}"); +defineMacro("\u211B", "\\mathscr{R}"); +defineMacro("\u212D", "\\mathfrak{C}"); // Fraktur +defineMacro("\u210C", "\\mathfrak{H}"); +defineMacro("\u2128", "\\mathfrak{Z}"); +// Define \Bbbk with a macro that works in both HTML and MathML. +defineMacro("\\Bbbk", "\\Bbb{k}"); +// \llap and \rlap render their contents in text mode +defineMacro("\\llap", "\\mathllap{\\textrm{#1}}"); +defineMacro("\\rlap", "\\mathrlap{\\textrm{#1}}"); +defineMacro("\\clap", "\\mathclap{\\textrm{#1}}"); +// \mathstrut from the TeXbook, p 360 +defineMacro("\\mathstrut", "\\vphantom{(}"); +// \underbar from TeXbook p 353 +defineMacro("\\underbar", "\\underline{\\text{#1}}"); +// \not is defined by base/fontmath.ltx via +// \DeclareMathSymbol{\not}{\mathrel}{symbols}{"36} +// It's thus treated like a \mathrel, but defined by a symbol that has zero +// width but extends to the right. We use \rlap to get that spacing. +// For MathML we write U+0338 here. buildMathML.js will then do the overlay. +defineMacro("\\not", "\\html@mathml{\\mathrel{\\mathrlap\\@not}\\nobreak}" + "{\\char\"338}"); +// Negated symbols from base/fontmath.ltx: +// \def\neq{\not=} \let\ne=\neq +// \DeclareRobustCommand +// \notin{\mathrel{\m@th\mathpalette\c@ncel\in}} +// \def\c@ncel#1#2{\m@th\ooalign{$\hfil#1\mkern1mu/\hfil$\crcr$#1#2$}} +defineMacro("\\neq", "\\html@mathml{\\mathrel{\\not=}}{\\mathrel{\\char`≠}}"); +defineMacro("\\ne", "\\neq"); +defineMacro("\u2260", "\\neq"); +defineMacro("\\notin", "\\html@mathml{\\mathrel{{\\in}\\mathllap{/\\mskip1mu}}}" + "{\\mathrel{\\char`∉}}"); +defineMacro("\u2209", "\\notin"); +// Unicode stacked relations +defineMacro("\u2258", "\\html@mathml{" + "\\mathrel{=\\kern{-1em}\\raisebox{0.4em}{$\\scriptsize\\frown$}}" + "}{\\mathrel{\\char`\u2258}}"); +defineMacro("\u2259", "\\html@mathml{\\stackrel{\\tiny\\wedge}{=}}{\\mathrel{\\char`\u2258}}"); +defineMacro("\u225A", "\\html@mathml{\\stackrel{\\tiny\\vee}{=}}{\\mathrel{\\char`\u225A}}"); +defineMacro("\u225B", "\\html@mathml{\\stackrel{\\scriptsize\\star}{=}}" + "{\\mathrel{\\char`\u225B}}"); +defineMacro("\u225D", "\\html@mathml{\\stackrel{\\tiny\\mathrm{def}}{=}}" + "{\\mathrel{\\char`\u225D}}"); +defineMacro("\u225E", "\\html@mathml{\\stackrel{\\tiny\\mathrm{m}}{=}}" + "{\\mathrel{\\char`\u225E}}"); +defineMacro("\u225F", "\\html@mathml{\\stackrel{\\tiny?}{=}}{\\mathrel{\\char`\u225F}}"); +// Misc Unicode +defineMacro("\u27C2", "\\perp"); +defineMacro("\u203C", "\\mathclose{!\\mkern-0.8mu!}"); +defineMacro("\u220C", "\\notni"); +defineMacro("\u231C", "\\ulcorner"); +defineMacro("\u231D", "\\urcorner"); +defineMacro("\u231E", "\\llcorner"); +defineMacro("\u231F", "\\lrcorner"); +defineMacro("\u00A9", "\\copyright"); +defineMacro("\u00AE", "\\textregistered"); +// The KaTeX fonts have corners at codepoints that don't match Unicode. +// For MathML purposes, use the Unicode code point. +defineMacro("\\ulcorner", "\\html@mathml{\\@ulcorner}{\\mathop{\\char\"231c}}"); +defineMacro("\\urcorner", "\\html@mathml{\\@urcorner}{\\mathop{\\char\"231d}}"); +defineMacro("\\llcorner", "\\html@mathml{\\@llcorner}{\\mathop{\\char\"231e}}"); +defineMacro("\\lrcorner", "\\html@mathml{\\@lrcorner}{\\mathop{\\char\"231f}}"); +////////////////////////////////////////////////////////////////////// +// LaTeX_2ε +// \vdots{\vbox{\baselineskip4\p@ \lineskiplimit\z@ +// \kern6\p@\hbox{.}\hbox{.}\hbox{.}}} +// We'll call \varvdots, which gets a glyph from symbols.js. +// The zero-width rule gets us an equivalent to the vertical 6pt kern. +defineMacro("\\vdots", "{\\varvdots\\rule{0pt}{15pt}}"); +defineMacro("\u22ee", "\\vdots"); +////////////////////////////////////////////////////////////////////// +// amsmath.sty +// http://mirrors.concertpass.com/tex-archive/macros/latex/required/amsmath/amsmath.pdf +// Italic Greek capital letters. AMS defines these with \DeclareMathSymbol, +// but they are equivalent to \mathit{\Letter}. +defineMacro("\\varGamma", "\\mathit{\\Gamma}"); +defineMacro("\\varDelta", "\\mathit{\\Delta}"); +defineMacro("\\varTheta", "\\mathit{\\Theta}"); +defineMacro("\\varLambda", "\\mathit{\\Lambda}"); +defineMacro("\\varXi", "\\mathit{\\Xi}"); +defineMacro("\\varPi", "\\mathit{\\Pi}"); +defineMacro("\\varSigma", "\\mathit{\\Sigma}"); +defineMacro("\\varUpsilon", "\\mathit{\\Upsilon}"); +defineMacro("\\varPhi", "\\mathit{\\Phi}"); +defineMacro("\\varPsi", "\\mathit{\\Psi}"); +defineMacro("\\varOmega", "\\mathit{\\Omega}"); +//\newcommand{\substack}[1]{\subarray{c}#1\endsubarray} +defineMacro("\\substack", "\\begin{subarray}{c}#1\\end{subarray}"); +// \renewcommand{\colon}{\nobreak\mskip2mu\mathpunct{}\nonscript +// \mkern-\thinmuskip{:}\mskip6muplus1mu\relax} +defineMacro("\\colon", "\\nobreak\\mskip2mu\\mathpunct{}" + "\\mathchoice{\\mkern-3mu}{\\mkern-3mu}{}{}{:}\\mskip6mu\\relax"); +// \newcommand{\boxed}[1]{\fbox{\m@th$\displaystyle#1$}} +defineMacro("\\boxed", "\\fbox{$\\displaystyle{#1}$}"); +// \def\iff{\DOTSB\;\Longleftrightarrow\;} +// \def\implies{\DOTSB\;\Longrightarrow\;} +// \def\impliedby{\DOTSB\;\Longleftarrow\;} +defineMacro("\\iff", "\\DOTSB\\;\\Longleftrightarrow\\;"); +defineMacro("\\implies", "\\DOTSB\\;\\Longrightarrow\\;"); +defineMacro("\\impliedby", "\\DOTSB\\;\\Longleftarrow\\;"); +// \def\dddot#1{{\mathop{#1}\limits^{\vbox to-1.4\ex@{\kern-\tw@\ex@ +// \hbox{\normalfont ...}\vss}}}} +// We use \overset which avoids the vertical shift of \mathop. +defineMacro("\\dddot", "{\\overset{\\raisebox{-0.1ex}{\\normalsize ...}}{#1}}"); +defineMacro("\\ddddot", "{\\overset{\\raisebox{-0.1ex}{\\normalsize ....}}{#1}}"); +// AMSMath's automatic \dots, based on \mdots@@ macro. +var dotsByToken = { + ',': '\\dotsc', + '\\not': '\\dotsb', + // \keybin@ checks for the following: + '+': '\\dotsb', + '=': '\\dotsb', + '<': '\\dotsb', + '>': '\\dotsb', + '-': '\\dotsb', + '*': '\\dotsb', + ':': '\\dotsb', + // Symbols whose definition starts with \DOTSB: + '\\DOTSB': '\\dotsb', + '\\coprod': '\\dotsb', + '\\bigvee': '\\dotsb', + '\\bigwedge': '\\dotsb', + '\\biguplus': '\\dotsb', + '\\bigcap': '\\dotsb', + '\\bigcup': '\\dotsb', + '\\prod': '\\dotsb', + '\\sum': '\\dotsb', + '\\bigotimes': '\\dotsb', + '\\bigoplus': '\\dotsb', + '\\bigodot': '\\dotsb', + '\\bigsqcup': '\\dotsb', + '\\And': '\\dotsb', + '\\longrightarrow': '\\dotsb', + '\\Longrightarrow': '\\dotsb', + '\\longleftarrow': '\\dotsb', + '\\Longleftarrow': '\\dotsb', + '\\longleftrightarrow': '\\dotsb', + '\\Longleftrightarrow': '\\dotsb', + '\\mapsto': '\\dotsb', + '\\longmapsto': '\\dotsb', + '\\hookrightarrow': '\\dotsb', + '\\doteq': '\\dotsb', + // Symbols whose definition starts with \mathbin: + '\\mathbin': '\\dotsb', + // Symbols whose definition starts with \mathrel: + '\\mathrel': '\\dotsb', + '\\relbar': '\\dotsb', + '\\Relbar': '\\dotsb', + '\\xrightarrow': '\\dotsb', + '\\xleftarrow': '\\dotsb', + // Symbols whose definition starts with \DOTSI: + '\\DOTSI': '\\dotsi', + '\\int': '\\dotsi', + '\\oint': '\\dotsi', + '\\iint': '\\dotsi', + '\\iiint': '\\dotsi', + '\\iiiint': '\\dotsi', + '\\idotsint': '\\dotsi', + // Symbols whose definition starts with \DOTSX: + '\\DOTSX': '\\dotsx' +}; +var dotsbGroups = new Set(['bin', 'rel']); +defineMacro("\\dots", function (context) { + // TODO: If used in text mode, should expand to \textellipsis. + // However, in KaTeX, \textellipsis and \ldots behave the same + // (in text mode), and it's unlikely we'd see any of the math commands + // that affect the behavior of \dots when in text mode. So fine for now + // (until we support \ifmmode ... \else ... \fi). + var thedots = '\\dotso'; + var next = context.expandAfterFuture().text; + if (next in dotsByToken) { + thedots = dotsByToken[next]; + } else if (next.slice(0, 4) === '\\not') { + thedots = '\\dotsb'; + } else if (next in symbols.math) { + if (dotsbGroups.has(symbols.math[next].group)) { + thedots = '\\dotsb'; + } + } + return thedots; +}); +var spaceAfterDots = { + // \rightdelim@ checks for the following: + ')': true, + ']': true, + '\\rbrack': true, + '\\}': true, + '\\rbrace': true, + '\\rangle': true, + '\\rceil': true, + '\\rfloor': true, + '\\rgroup': true, + '\\rmoustache': true, + '\\right': true, + '\\bigr': true, + '\\biggr': true, + '\\Bigr': true, + '\\Biggr': true, + // \extra@ also tests for the following: + '$': true, + // \extrap@ checks for the following: + ';': true, + '.': true, + ',': true +}; +defineMacro("\\dotso", function (context) { + var next = context.future().text; + if (next in spaceAfterDots) { + return "\\ldots\\,"; + } else { + return "\\ldots"; + } +}); +defineMacro("\\dotsc", function (context) { + var next = context.future().text; + // \dotsc uses \extra@ but not \extrap@, instead specially checking for + // ';' and '.', but doesn't check for ','. + if (next in spaceAfterDots && next !== ',') { + return "\\ldots\\,"; + } else { + return "\\ldots"; + } +}); +defineMacro("\\cdots", function (context) { + var next = context.future().text; + if (next in spaceAfterDots) { + return "\\@cdots\\,"; + } else { + return "\\@cdots"; + } +}); +defineMacro("\\dotsb", "\\cdots"); +defineMacro("\\dotsm", "\\cdots"); +defineMacro("\\dotsi", "\\!\\cdots"); +// amsmath doesn't actually define \dotsx, but \dots followed by a macro +// starting with \DOTSX implies \dotso, and then \extra@ detects this case +// and forces the added `\,`. +defineMacro("\\dotsx", "\\ldots\\,"); +// \let\DOTSI\relax +// \let\DOTSB\relax +// \let\DOTSX\relax +defineMacro("\\DOTSI", "\\relax"); +defineMacro("\\DOTSB", "\\relax"); +defineMacro("\\DOTSX", "\\relax"); +// Spacing, based on amsmath.sty's override of LaTeX defaults +// \DeclareRobustCommand{\tmspace}[3]{% +// \ifmmode\mskip#1#2\else\kern#1#3\fi\relax} +defineMacro("\\tmspace", "\\TextOrMath{\\kern#1#3}{\\mskip#1#2}\\relax"); +// \renewcommand{\,}{\tmspace+\thinmuskip{.1667em}} +// TODO: math mode should use \thinmuskip +defineMacro("\\,", "\\tmspace+{3mu}{.1667em}"); +// \let\thinspace\, +defineMacro("\\thinspace", "\\,"); +// \def\>{\mskip\medmuskip} +// \renewcommand{\:}{\tmspace+\medmuskip{.2222em}} +// TODO: \> and math mode of \: should use \medmuskip = 4mu plus 2mu minus 4mu +defineMacro("\\>", "\\mskip{4mu}"); +defineMacro("\\:", "\\tmspace+{4mu}{.2222em}"); +// \let\medspace\: +defineMacro("\\medspace", "\\:"); +// \renewcommand{\;}{\tmspace+\thickmuskip{.2777em}} +// TODO: math mode should use \thickmuskip = 5mu plus 5mu +defineMacro("\\;", "\\tmspace+{5mu}{.2777em}"); +// \let\thickspace\; +defineMacro("\\thickspace", "\\;"); +// \renewcommand{\!}{\tmspace-\thinmuskip{.1667em}} +// TODO: math mode should use \thinmuskip +defineMacro("\\!", "\\tmspace-{3mu}{.1667em}"); +// \let\negthinspace\! +defineMacro("\\negthinspace", "\\!"); +// \newcommand{\negmedspace}{\tmspace-\medmuskip{.2222em}} +// TODO: math mode should use \medmuskip +defineMacro("\\negmedspace", "\\tmspace-{4mu}{.2222em}"); +// \newcommand{\negthickspace}{\tmspace-\thickmuskip{.2777em}} +// TODO: math mode should use \thickmuskip +defineMacro("\\negthickspace", "\\tmspace-{5mu}{.277em}"); +// \def\enspace{\kern.5em } +defineMacro("\\enspace", "\\kern.5em "); +// \def\enskip{\hskip.5em\relax} +defineMacro("\\enskip", "\\hskip.5em\\relax"); +// \def\quad{\hskip1em\relax} +defineMacro("\\quad", "\\hskip1em\\relax"); +// \def\qquad{\hskip2em\relax} +defineMacro("\\qquad", "\\hskip2em\\relax"); +// \tag@in@display form of \tag +defineMacro("\\tag", "\\@ifstar\\tag@literal\\tag@paren"); +defineMacro("\\tag@paren", "\\tag@literal{({#1})}"); +defineMacro("\\tag@literal", context => { + if (context.macros.get("\\df@tag")) { + throw new ParseError("Multiple \\tag"); + } + return "\\gdef\\df@tag{\\text{#1}}"; +}); +// \renewcommand{\bmod}{\nonscript\mskip-\medmuskip\mkern5mu\mathbin +// {\operator@font mod}\penalty900 +// \mkern5mu\nonscript\mskip-\medmuskip} +// \newcommand{\pod}[1]{\allowbreak +// \if@display\mkern18mu\else\mkern8mu\fi(#1)} +// \renewcommand{\pmod}[1]{\pod{{\operator@font mod}\mkern6mu#1}} +// \newcommand{\mod}[1]{\allowbreak\if@display\mkern18mu +// \else\mkern12mu\fi{\operator@font mod}\,\,#1} +// TODO: math mode should use \medmuskip = 4mu plus 2mu minus 4mu +defineMacro("\\bmod", "\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}" + "\\mathbin{\\rm mod}" + "\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}"); +defineMacro("\\pod", "\\allowbreak" + "\\mathchoice{\\mkern18mu}{\\mkern8mu}{\\mkern8mu}{\\mkern8mu}(#1)"); +defineMacro("\\pmod", "\\pod{{\\rm mod}\\mkern6mu#1}"); +defineMacro("\\mod", "\\allowbreak" + "\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}" + "{\\rm mod}\\,\\,#1"); +////////////////////////////////////////////////////////////////////// +// LaTeX source2e +// \expandafter\let\expandafter\@normalcr +// \csname\expandafter\@gobble\string\\ \endcsname +// \DeclareRobustCommand\newline{\@normalcr\relax} +defineMacro("\\newline", "\\\\\\relax"); +// \def\TeX{T\kern-.1667em\lower.5ex\hbox{E}\kern-.125emX\@} +// TODO: Doesn't normally work in math mode because \@ fails. KaTeX doesn't +// support \@ yet, so that's omitted, and we add \text so that the result +// doesn't look funny in math mode. +defineMacro("\\TeX", "\\textrm{\\html@mathml{" + "T\\kern-.1667em\\raisebox{-.5ex}{E}\\kern-.125emX" + "}{TeX}}"); +// \DeclareRobustCommand{\LaTeX}{L\kern-.36em% +// {\sbox\z@ T% +// \vbox to\ht\z@{\hbox{\check@mathfonts +// \fontsize\sf@size\z@ +// \math@fontsfalse\selectfont +// A}% +// \vss}% +// }% +// \kern-.15em% +// \TeX} +// This code aligns the top of the A with the T (from the perspective of TeX's +// boxes, though visually the A appears to extend above slightly). +// We compute the corresponding \raisebox when A is rendered in \normalsize +// \scriptstyle, which has a scale factor of 0.7 (see Options.js). +var latexRaiseA = makeEm(fontMetricsData['Main-Regular']["T".charCodeAt(0)][1] - 0.7 * fontMetricsData['Main-Regular']["A".charCodeAt(0)][1]); +defineMacro("\\LaTeX", "\\textrm{\\html@mathml{" + ("L\\kern-.36em\\raisebox{" + latexRaiseA + "}{\\scriptstyle A}") + "\\kern-.15em\\TeX}{LaTeX}}"); +// New KaTeX logo based on tweaking LaTeX logo +defineMacro("\\KaTeX", "\\textrm{\\html@mathml{" + ("K\\kern-.17em\\raisebox{" + latexRaiseA + "}{\\scriptstyle A}") + "\\kern-.15em\\TeX}{KaTeX}}"); +// \DeclareRobustCommand\hspace{\@ifstar\@hspacer\@hspace} +// \def\@hspace#1{\hskip #1\relax} +// \def\@hspacer#1{\vrule \@width\z@\nobreak +// \hskip #1\hskip \z@skip} +defineMacro("\\hspace", "\\@ifstar\\@hspacer\\@hspace"); +defineMacro("\\@hspace", "\\hskip #1\\relax"); +defineMacro("\\@hspacer", "\\rule{0pt}{0pt}\\hskip #1\\relax"); +////////////////////////////////////////////////////////////////////// +// mathtools.sty +//\providecommand\ordinarycolon{:} +defineMacro("\\ordinarycolon", ":"); +//\def\vcentcolon{\mathrel{\mathop\ordinarycolon}} +//TODO(edemaine): Not yet centered. Fix via \raisebox or #726 +defineMacro("\\vcentcolon", "\\mathrel{\\mathop\\ordinarycolon}"); +// \providecommand*\dblcolon{\vcentcolon\mathrel{\mkern-.9mu}\vcentcolon} +defineMacro("\\dblcolon", "\\html@mathml{" + "\\mathrel{\\vcentcolon\\mathrel{\\mkern-.9mu}\\vcentcolon}}" + "{\\mathop{\\char\"2237}}"); +// \providecommand*\coloneqq{\vcentcolon\mathrel{\mkern-1.2mu}=} +defineMacro("\\coloneqq", "\\html@mathml{" + "\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}=}}" + "{\\mathop{\\char\"2254}}"); // ≔ +// \providecommand*\Coloneqq{\dblcolon\mathrel{\mkern-1.2mu}=} +defineMacro("\\Coloneqq", "\\html@mathml{" + "\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}=}}" + "{\\mathop{\\char\"2237\\char\"3d}}"); +// \providecommand*\coloneq{\vcentcolon\mathrel{\mkern-1.2mu}\mathrel{-}} +defineMacro("\\coloneq", "\\html@mathml{" + "\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}" + "{\\mathop{\\char\"3a\\char\"2212}}"); +// \providecommand*\Coloneq{\dblcolon\mathrel{\mkern-1.2mu}\mathrel{-}} +defineMacro("\\Coloneq", "\\html@mathml{" + "\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}" + "{\\mathop{\\char\"2237\\char\"2212}}"); +// \providecommand*\eqqcolon{=\mathrel{\mkern-1.2mu}\vcentcolon} +defineMacro("\\eqqcolon", "\\html@mathml{" + "\\mathrel{=\\mathrel{\\mkern-1.2mu}\\vcentcolon}}" + "{\\mathop{\\char\"2255}}"); // ≕ +// \providecommand*\Eqqcolon{=\mathrel{\mkern-1.2mu}\dblcolon} +defineMacro("\\Eqqcolon", "\\html@mathml{" + "\\mathrel{=\\mathrel{\\mkern-1.2mu}\\dblcolon}}" + "{\\mathop{\\char\"3d\\char\"2237}}"); +// \providecommand*\eqcolon{\mathrel{-}\mathrel{\mkern-1.2mu}\vcentcolon} +defineMacro("\\eqcolon", "\\html@mathml{" + "\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\vcentcolon}}" + "{\\mathop{\\char\"2239}}"); +// \providecommand*\Eqcolon{\mathrel{-}\mathrel{\mkern-1.2mu}\dblcolon} +defineMacro("\\Eqcolon", "\\html@mathml{" + "\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\dblcolon}}" + "{\\mathop{\\char\"2212\\char\"2237}}"); +// \providecommand*\colonapprox{\vcentcolon\mathrel{\mkern-1.2mu}\approx} +defineMacro("\\colonapprox", "\\html@mathml{" + "\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\approx}}" + "{\\mathop{\\char\"3a\\char\"2248}}"); +// \providecommand*\Colonapprox{\dblcolon\mathrel{\mkern-1.2mu}\approx} +defineMacro("\\Colonapprox", "\\html@mathml{" + "\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\approx}}" + "{\\mathop{\\char\"2237\\char\"2248}}"); +// \providecommand*\colonsim{\vcentcolon\mathrel{\mkern-1.2mu}\sim} +defineMacro("\\colonsim", "\\html@mathml{" + "\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\sim}}" + "{\\mathop{\\char\"3a\\char\"223c}}"); +// \providecommand*\Colonsim{\dblcolon\mathrel{\mkern-1.2mu}\sim} +defineMacro("\\Colonsim", "\\html@mathml{" + "\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\sim}}" + "{\\mathop{\\char\"2237\\char\"223c}}"); +// Some Unicode characters are implemented with macros to mathtools functions. +defineMacro("\u2237", "\\dblcolon"); // :: +defineMacro("\u2239", "\\eqcolon"); // -: +defineMacro("\u2254", "\\coloneqq"); // := +defineMacro("\u2255", "\\eqqcolon"); // =: +defineMacro("\u2A74", "\\Coloneqq"); // ::= +////////////////////////////////////////////////////////////////////// +// colonequals.sty +// Alternate names for mathtools's macros: +defineMacro("\\ratio", "\\vcentcolon"); +defineMacro("\\coloncolon", "\\dblcolon"); +defineMacro("\\colonequals", "\\coloneqq"); +defineMacro("\\coloncolonequals", "\\Coloneqq"); +defineMacro("\\equalscolon", "\\eqqcolon"); +defineMacro("\\equalscoloncolon", "\\Eqqcolon"); +defineMacro("\\colonminus", "\\coloneq"); +defineMacro("\\coloncolonminus", "\\Coloneq"); +defineMacro("\\minuscolon", "\\eqcolon"); +defineMacro("\\minuscoloncolon", "\\Eqcolon"); +// \colonapprox name is same in mathtools and colonequals. +defineMacro("\\coloncolonapprox", "\\Colonapprox"); +// \colonsim name is same in mathtools and colonequals. +defineMacro("\\coloncolonsim", "\\Colonsim"); +// Additional macros, implemented by analogy with mathtools definitions: +defineMacro("\\simcolon", "\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\vcentcolon}"); +defineMacro("\\simcoloncolon", "\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\dblcolon}"); +defineMacro("\\approxcolon", "\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\vcentcolon}"); +defineMacro("\\approxcoloncolon", "\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\dblcolon}"); +// Present in newtxmath, pxfonts and txfonts +defineMacro("\\notni", "\\html@mathml{\\not\\ni}{\\mathrel{\\char`\u220C}}"); +defineMacro("\\limsup", "\\DOTSB\\operatorname*{lim\\,sup}"); +defineMacro("\\liminf", "\\DOTSB\\operatorname*{lim\\,inf}"); +////////////////////////////////////////////////////////////////////// +// From amsopn.sty +defineMacro("\\injlim", "\\DOTSB\\operatorname*{inj\\,lim}"); +defineMacro("\\projlim", "\\DOTSB\\operatorname*{proj\\,lim}"); +defineMacro("\\varlimsup", "\\DOTSB\\operatorname*{\\overline{lim}}"); +defineMacro("\\varliminf", "\\DOTSB\\operatorname*{\\underline{lim}}"); +defineMacro("\\varinjlim", "\\DOTSB\\operatorname*{\\underrightarrow{lim}}"); +defineMacro("\\varprojlim", "\\DOTSB\\operatorname*{\\underleftarrow{lim}}"); +////////////////////////////////////////////////////////////////////// +// MathML alternates for KaTeX glyphs in the Unicode private area +defineMacro("\\gvertneqq", "\\html@mathml{\\@gvertneqq}{\u2269}"); +defineMacro("\\lvertneqq", "\\html@mathml{\\@lvertneqq}{\u2268}"); +defineMacro("\\ngeqq", "\\html@mathml{\\@ngeqq}{\u2271}"); +defineMacro("\\ngeqslant", "\\html@mathml{\\@ngeqslant}{\u2271}"); +defineMacro("\\nleqq", "\\html@mathml{\\@nleqq}{\u2270}"); +defineMacro("\\nleqslant", "\\html@mathml{\\@nleqslant}{\u2270}"); +defineMacro("\\nshortmid", "\\html@mathml{\\@nshortmid}{∤}"); +defineMacro("\\nshortparallel", "\\html@mathml{\\@nshortparallel}{∦}"); +defineMacro("\\nsubseteqq", "\\html@mathml{\\@nsubseteqq}{\u2288}"); +defineMacro("\\nsupseteqq", "\\html@mathml{\\@nsupseteqq}{\u2289}"); +defineMacro("\\varsubsetneq", "\\html@mathml{\\@varsubsetneq}{⊊}"); +defineMacro("\\varsubsetneqq", "\\html@mathml{\\@varsubsetneqq}{⫋}"); +defineMacro("\\varsupsetneq", "\\html@mathml{\\@varsupsetneq}{⊋}"); +defineMacro("\\varsupsetneqq", "\\html@mathml{\\@varsupsetneqq}{⫌}"); +defineMacro("\\imath", "\\html@mathml{\\@imath}{\u0131}"); +defineMacro("\\jmath", "\\html@mathml{\\@jmath}{\u0237}"); +////////////////////////////////////////////////////////////////////// +// stmaryrd and semantic +// The stmaryrd and semantic packages render the next four items by calling a +// glyph. Those glyphs do not exist in the KaTeX fonts. Hence the macros. +defineMacro("\\llbracket", "\\html@mathml{" + "\\mathopen{[\\mkern-3.2mu[}}" + "{\\mathopen{\\char`\u27e6}}"); +defineMacro("\\rrbracket", "\\html@mathml{" + "\\mathclose{]\\mkern-3.2mu]}}" + "{\\mathclose{\\char`\u27e7}}"); +defineMacro("\u27e6", "\\llbracket"); // blackboard bold [ +defineMacro("\u27e7", "\\rrbracket"); // blackboard bold ] +defineMacro("\\lBrace", "\\html@mathml{" + "\\mathopen{\\{\\mkern-3.2mu[}}" + "{\\mathopen{\\char`\u2983}}"); +defineMacro("\\rBrace", "\\html@mathml{" + "\\mathclose{]\\mkern-3.2mu\\}}}" + "{\\mathclose{\\char`\u2984}}"); +defineMacro("\u2983", "\\lBrace"); // blackboard bold { +defineMacro("\u2984", "\\rBrace"); // blackboard bold } +// TODO: Create variable sized versions of the last two items. I believe that +// will require new font glyphs. +// The stmaryrd function `\minuso` provides a "Plimsoll" symbol that +// superimposes the characters \circ and \mathminus. Used in chemistry. +defineMacro("\\minuso", "\\mathbin{\\html@mathml{" + "{\\mathrlap{\\mathchoice{\\kern{0.145em}}{\\kern{0.145em}}" + "{\\kern{0.1015em}}{\\kern{0.0725em}}\\circ}{-}}}" + "{\\char`⦵}}"); +defineMacro("⦵", "\\minuso"); +////////////////////////////////////////////////////////////////////// +// texvc.sty +// The texvc package contains macros available in mediawiki pages. +// We omit the functions deprecated at +// https://en.wikipedia.org/wiki/Help:Displaying_a_formula#Deprecated_syntax +// We also omit texvc's \O, which conflicts with \text{\O} +defineMacro("\\darr", "\\downarrow"); +defineMacro("\\dArr", "\\Downarrow"); +defineMacro("\\Darr", "\\Downarrow"); +defineMacro("\\lang", "\\langle"); +defineMacro("\\rang", "\\rangle"); +defineMacro("\\uarr", "\\uparrow"); +defineMacro("\\uArr", "\\Uparrow"); +defineMacro("\\Uarr", "\\Uparrow"); +defineMacro("\\N", "\\mathbb{N}"); +defineMacro("\\R", "\\mathbb{R}"); +defineMacro("\\Z", "\\mathbb{Z}"); +defineMacro("\\alef", "\\aleph"); +defineMacro("\\alefsym", "\\aleph"); +defineMacro("\\Alpha", "\\mathrm{A}"); +defineMacro("\\Beta", "\\mathrm{B}"); +defineMacro("\\bull", "\\bullet"); +defineMacro("\\Chi", "\\mathrm{X}"); +defineMacro("\\clubs", "\\clubsuit"); +defineMacro("\\cnums", "\\mathbb{C}"); +defineMacro("\\Complex", "\\mathbb{C}"); +defineMacro("\\Dagger", "\\ddagger"); +defineMacro("\\diamonds", "\\diamondsuit"); +defineMacro("\\empty", "\\emptyset"); +defineMacro("\\Epsilon", "\\mathrm{E}"); +defineMacro("\\Eta", "\\mathrm{H}"); +defineMacro("\\exist", "\\exists"); +defineMacro("\\harr", "\\leftrightarrow"); +defineMacro("\\hArr", "\\Leftrightarrow"); +defineMacro("\\Harr", "\\Leftrightarrow"); +defineMacro("\\hearts", "\\heartsuit"); +defineMacro("\\image", "\\Im"); +defineMacro("\\infin", "\\infty"); +defineMacro("\\Iota", "\\mathrm{I}"); +defineMacro("\\isin", "\\in"); +defineMacro("\\Kappa", "\\mathrm{K}"); +defineMacro("\\larr", "\\leftarrow"); +defineMacro("\\lArr", "\\Leftarrow"); +defineMacro("\\Larr", "\\Leftarrow"); +defineMacro("\\lrarr", "\\leftrightarrow"); +defineMacro("\\lrArr", "\\Leftrightarrow"); +defineMacro("\\Lrarr", "\\Leftrightarrow"); +defineMacro("\\Mu", "\\mathrm{M}"); +defineMacro("\\natnums", "\\mathbb{N}"); +defineMacro("\\Nu", "\\mathrm{N}"); +defineMacro("\\Omicron", "\\mathrm{O}"); +defineMacro("\\plusmn", "\\pm"); +defineMacro("\\rarr", "\\rightarrow"); +defineMacro("\\rArr", "\\Rightarrow"); +defineMacro("\\Rarr", "\\Rightarrow"); +defineMacro("\\real", "\\Re"); +defineMacro("\\reals", "\\mathbb{R}"); +defineMacro("\\Reals", "\\mathbb{R}"); +defineMacro("\\Rho", "\\mathrm{P}"); +defineMacro("\\sdot", "\\cdot"); +defineMacro("\\sect", "\\S"); +defineMacro("\\spades", "\\spadesuit"); +defineMacro("\\sub", "\\subset"); +defineMacro("\\sube", "\\subseteq"); +defineMacro("\\supe", "\\supseteq"); +defineMacro("\\Tau", "\\mathrm{T}"); +defineMacro("\\thetasym", "\\vartheta"); +// TODO: defineMacro("\\varcoppa", "\\\mbox{\\coppa}"); +defineMacro("\\weierp", "\\wp"); +defineMacro("\\Zeta", "\\mathrm{Z}"); +////////////////////////////////////////////////////////////////////// +// statmath.sty +// https://ctan.math.illinois.edu/macros/latex/contrib/statmath/statmath.pdf +defineMacro("\\argmin", "\\DOTSB\\operatorname*{arg\\,min}"); +defineMacro("\\argmax", "\\DOTSB\\operatorname*{arg\\,max}"); +defineMacro("\\plim", "\\DOTSB\\mathop{\\operatorname{plim}}\\limits"); +////////////////////////////////////////////////////////////////////// +// braket.sty +// http://ctan.math.washington.edu/tex-archive/macros/latex/contrib/braket/braket.pdf +defineMacro("\\bra", "\\mathinner{\\langle{#1}|}"); +defineMacro("\\ket", "\\mathinner{|{#1}\\rangle}"); +defineMacro("\\braket", "\\mathinner{\\langle{#1}\\rangle}"); +defineMacro("\\Bra", "\\left\\langle#1\\right|"); +defineMacro("\\Ket", "\\left|#1\\right\\rangle"); +var braketHelper = one => context => { + var left = context.consumeArg().tokens; + var middle = context.consumeArg().tokens; + var middleDouble = context.consumeArg().tokens; + var right = context.consumeArg().tokens; + var oldMiddle = context.macros.get("|"); + var oldMiddleDouble = context.macros.get("\\|"); + context.macros.beginGroup(); + var midMacro = double => context => { + if (one) { + // Only modify the first instance of | or \| + context.macros.set("|", oldMiddle); + if (middleDouble.length) { + context.macros.set("\\|", oldMiddleDouble); + } + } + var doubled = double; + if (!double && middleDouble.length) { + // Mimic \@ifnextchar + var nextToken = context.future(); + if (nextToken.text === "|") { + context.popToken(); + doubled = true; + } + } + return { + tokens: doubled ? middleDouble : middle, + numArgs: 0 + }; + }; + context.macros.set("|", midMacro(false)); + if (middleDouble.length) { + context.macros.set("\\|", midMacro(true)); + } + var arg = context.consumeArg().tokens; + var expanded = context.expandTokens([...right, ...arg, ...left // reversed + ]); + context.macros.endGroup(); + return { + tokens: expanded.reverse(), + numArgs: 0 + }; +}; +defineMacro("\\bra@ket", braketHelper(false)); +defineMacro("\\bra@set", braketHelper(true)); +defineMacro("\\Braket", "\\bra@ket{\\left\\langle}" + "{\\,\\middle\\vert\\,}{\\,\\middle\\vert\\,}{\\right\\rangle}"); +defineMacro("\\Set", "\\bra@set{\\left\\{\\:}" + "{\\;\\middle\\vert\\;}{\\;\\middle\\Vert\\;}{\\:\\right\\}}"); +defineMacro("\\set", "\\bra@set{\\{\\,}{\\mid}{}{\\,\\}}"); +// has no support for special || or \| +////////////////////////////////////////////////////////////////////// +// actuarialangle.dtx +defineMacro("\\angln", "{\\angl n}"); +// Custom Khan Academy colors, should be moved to an optional package +defineMacro("\\blue", "\\textcolor{##6495ed}{#1}"); +defineMacro("\\orange", "\\textcolor{##ffa500}{#1}"); +defineMacro("\\pink", "\\textcolor{##ff00af}{#1}"); +defineMacro("\\red", "\\textcolor{##df0030}{#1}"); +defineMacro("\\green", "\\textcolor{##28ae7b}{#1}"); +defineMacro("\\gray", "\\textcolor{gray}{#1}"); +defineMacro("\\purple", "\\textcolor{##9d38bd}{#1}"); +defineMacro("\\blueA", "\\textcolor{##ccfaff}{#1}"); +defineMacro("\\blueB", "\\textcolor{##80f6ff}{#1}"); +defineMacro("\\blueC", "\\textcolor{##63d9ea}{#1}"); +defineMacro("\\blueD", "\\textcolor{##11accd}{#1}"); +defineMacro("\\blueE", "\\textcolor{##0c7f99}{#1}"); +defineMacro("\\tealA", "\\textcolor{##94fff5}{#1}"); +defineMacro("\\tealB", "\\textcolor{##26edd5}{#1}"); +defineMacro("\\tealC", "\\textcolor{##01d1c1}{#1}"); +defineMacro("\\tealD", "\\textcolor{##01a995}{#1}"); +defineMacro("\\tealE", "\\textcolor{##208170}{#1}"); +defineMacro("\\greenA", "\\textcolor{##b6ffb0}{#1}"); +defineMacro("\\greenB", "\\textcolor{##8af281}{#1}"); +defineMacro("\\greenC", "\\textcolor{##74cf70}{#1}"); +defineMacro("\\greenD", "\\textcolor{##1fab54}{#1}"); +defineMacro("\\greenE", "\\textcolor{##0d923f}{#1}"); +defineMacro("\\goldA", "\\textcolor{##ffd0a9}{#1}"); +defineMacro("\\goldB", "\\textcolor{##ffbb71}{#1}"); +defineMacro("\\goldC", "\\textcolor{##ff9c39}{#1}"); +defineMacro("\\goldD", "\\textcolor{##e07d10}{#1}"); +defineMacro("\\goldE", "\\textcolor{##a75a05}{#1}"); +defineMacro("\\redA", "\\textcolor{##fca9a9}{#1}"); +defineMacro("\\redB", "\\textcolor{##ff8482}{#1}"); +defineMacro("\\redC", "\\textcolor{##f9685d}{#1}"); +defineMacro("\\redD", "\\textcolor{##e84d39}{#1}"); +defineMacro("\\redE", "\\textcolor{##bc2612}{#1}"); +defineMacro("\\maroonA", "\\textcolor{##ffbde0}{#1}"); +defineMacro("\\maroonB", "\\textcolor{##ff92c6}{#1}"); +defineMacro("\\maroonC", "\\textcolor{##ed5fa6}{#1}"); +defineMacro("\\maroonD", "\\textcolor{##ca337c}{#1}"); +defineMacro("\\maroonE", "\\textcolor{##9e034e}{#1}"); +defineMacro("\\purpleA", "\\textcolor{##ddd7ff}{#1}"); +defineMacro("\\purpleB", "\\textcolor{##c6b9fc}{#1}"); +defineMacro("\\purpleC", "\\textcolor{##aa87ff}{#1}"); +defineMacro("\\purpleD", "\\textcolor{##7854ab}{#1}"); +defineMacro("\\purpleE", "\\textcolor{##543b78}{#1}"); +defineMacro("\\mintA", "\\textcolor{##f5f9e8}{#1}"); +defineMacro("\\mintB", "\\textcolor{##edf2df}{#1}"); +defineMacro("\\mintC", "\\textcolor{##e0e5cc}{#1}"); +defineMacro("\\grayA", "\\textcolor{##f6f7f7}{#1}"); +defineMacro("\\grayB", "\\textcolor{##f0f1f2}{#1}"); +defineMacro("\\grayC", "\\textcolor{##e3e5e6}{#1}"); +defineMacro("\\grayD", "\\textcolor{##d6d8da}{#1}"); +defineMacro("\\grayE", "\\textcolor{##babec2}{#1}"); +defineMacro("\\grayF", "\\textcolor{##888d93}{#1}"); +defineMacro("\\grayG", "\\textcolor{##626569}{#1}"); +defineMacro("\\grayH", "\\textcolor{##3b3e40}{#1}"); +defineMacro("\\grayI", "\\textcolor{##21242c}{#1}"); +defineMacro("\\kaBlue", "\\textcolor{##314453}{#1}"); +defineMacro("\\kaGreen", "\\textcolor{##71B307}{#1}"); + +/** + * This file contains the “gullet” where macros are expanded + * until only non-macro tokens remain. + */ +// List of commands that act like macros but aren't defined as a macro, +// function, or symbol. Used in `isDefined`. +var implicitCommands = { + "^": true, + // Parser.js + "_": true, + // Parser.js + "\\limits": true, + // Parser.js + "\\nolimits": true // Parser.js +}; +class MacroExpander { + constructor(input, settings, mode) { + this.settings = void 0; + this.expansionCount = void 0; + this.lexer = void 0; + this.macros = void 0; + this.stack = void 0; + this.mode = void 0; + this.settings = settings; + this.expansionCount = 0; + this.feed(input); + // Make new global namespace + this.macros = new Namespace(macros, settings.macros); + this.mode = mode; + this.stack = []; // contains tokens in REVERSE order + } + /** + * Feed a new input string to the same MacroExpander + * (with existing macros etc.). + */ + feed(input) { + this.lexer = new Lexer(input, this.settings); + } + /** + * Switches between "text" and "math" modes. + */ + switchMode(newMode) { + this.mode = newMode; + } + /** + * Start a new group nesting within all namespaces. + */ + beginGroup() { + this.macros.beginGroup(); + } + /** + * End current group nesting within all namespaces. + */ + endGroup() { + this.macros.endGroup(); + } + /** + * Ends all currently nested groups (if any), restoring values before the + * groups began. Useful in case of an error in the middle of parsing. + */ + endGroups() { + this.macros.endGroups(); + } + /** + * Returns the topmost token on the stack, without expanding it. + * Similar in behavior to TeX's `\futurelet`. + */ + future() { + if (this.stack.length === 0) { + this.pushToken(this.lexer.lex()); + } + return this.stack[this.stack.length - 1]; + } + /** + * Remove and return the next unexpanded token. + */ + popToken() { + this.future(); // ensure non-empty stack + return this.stack.pop(); + } + /** + * Add a given token to the token stack. In particular, this get be used + * to put back a token returned from one of the other methods. + */ + pushToken(token) { + this.stack.push(token); + } + /** + * Append an array of tokens to the token stack. + */ + pushTokens(tokens) { + this.stack.push(...tokens); + } + /** + * Find an macro argument without expanding tokens and append the array of + * tokens to the token stack. Uses Token as a container for the result. + */ + scanArgument(isOptional) { + var start; + var end; + var tokens; + if (isOptional) { + this.consumeSpaces(); // \@ifnextchar gobbles any space following it + if (this.future().text !== "[") { + return null; + } + start = this.popToken(); // don't include [ in tokens + ({ + tokens, + end + } = this.consumeArg(["]"])); + } else { + ({ + tokens, + start, + end + } = this.consumeArg()); + } + // indicate the end of an argument + this.pushToken(new Token("EOF", end.loc)); + this.pushTokens(tokens); + return new Token("", SourceLocation.range(start, end)); + } + /** + * Consume all following space tokens, without expansion. + */ + consumeSpaces() { + for (;;) { + var token = this.future(); + if (token.text === " ") { + this.stack.pop(); + } else { + break; + } + } + } + /** + * Consume an argument from the token stream, and return the resulting array + * of tokens and start/end token. + */ + consumeArg(delims) { + // The argument for a delimited parameter is the shortest (possibly + // empty) sequence of tokens with properly nested {...} groups that is + // followed ... by this particular list of non-parameter tokens. + // The argument for an undelimited parameter is the next nonblank + // token, unless that token is ‘{’, when the argument will be the + // entire {...} group that follows. + var tokens = []; + var isDelimited = delims && delims.length > 0; + if (!isDelimited) { + // Ignore spaces between arguments. As the TeXbook says: + // "After you have said ‘\def\row#1#2{...}’, you are allowed to + // put spaces between the arguments (e.g., ‘\row x n’), because + // TeX doesn’t use single spaces as undelimited arguments." + this.consumeSpaces(); + } + var start = this.future(); + var tok; + var depth = 0; + var match = 0; + do { + tok = this.popToken(); + tokens.push(tok); + if (tok.text === "{") { + ++depth; + } else if (tok.text === "}") { + --depth; + if (depth === -1) { + throw new ParseError("Extra }", tok); + } + } else if (tok.text === "EOF") { + throw new ParseError("Unexpected end of input in a macro argument" + ", expected '" + (delims && isDelimited ? delims[match] : "}") + "'", tok); + } + if (delims && isDelimited) { + if ((depth === 0 || depth === 1 && delims[match] === "{") && tok.text === delims[match]) { + ++match; + if (match === delims.length) { + // don't include delims in tokens + tokens.splice(-match, match); + break; + } + } else { + match = 0; + } + } + } while (depth !== 0 || isDelimited); + // If the argument found ... has the form ‘{}’, + // ... the outermost braces enclosing the argument are removed + if (start.text === "{" && tokens[tokens.length - 1].text === "}") { + tokens.pop(); + tokens.shift(); + } + tokens.reverse(); // to fit in with stack order + return { + tokens, + start, + end: tok + }; + } + /** + * Consume the specified number of (delimited) arguments from the token + * stream and return the resulting array of arguments. + */ + consumeArgs(numArgs, delimiters) { + if (delimiters) { + if (delimiters.length !== numArgs + 1) { + throw new ParseError("The length of delimiters doesn't match the number of args!"); + } + var delims = delimiters[0]; + for (var i = 0; i < delims.length; i++) { + var tok = this.popToken(); + if (delims[i] !== tok.text) { + throw new ParseError("Use of the macro doesn't match its definition", tok); + } + } + } + var args = []; + for (var _i = 0; _i < numArgs; _i++) { + args.push(this.consumeArg(delimiters && delimiters[_i + 1]).tokens); + } + return args; + } + /** + * Increment `expansionCount` by the specified amount. + * Throw an error if it exceeds `maxExpand`. + */ + countExpansion(amount) { + this.expansionCount += amount; + if (this.expansionCount > this.settings.maxExpand) { + throw new ParseError("Too many expansions: infinite loop or " + "need to increase maxExpand setting"); + } + } + /** + * Expand the next token only once if possible. + * + * If the token is expanded, the resulting tokens will be pushed onto + * the stack in reverse order, and the number of such tokens will be + * returned. This number might be zero or positive. + * + * If not, the return value is `false`, and the next token remains at the + * top of the stack. + * + * In either case, the next token will be on the top of the stack, + * or the stack will be empty (in case of empty expansion + * and no other tokens). + * + * Used to implement `expandAfterFuture` and `expandNextToken`. + * + * If expandableOnly, only expandable tokens are expanded and + * an undefined control sequence results in an error. + */ + expandOnce(expandableOnly) { + var topToken = this.popToken(); + var name = topToken.text; + var expansion = !topToken.noexpand ? this._getExpansion(name) : null; + if (expansion == null || expandableOnly && expansion.unexpandable) { + if (expandableOnly && expansion == null && name[0] === "\\" && !this.isDefined(name)) { + throw new ParseError("Undefined control sequence: " + name); + } + this.pushToken(topToken); + return false; + } + this.countExpansion(1); + var tokens = expansion.tokens; + var args = this.consumeArgs(expansion.numArgs, expansion.delimiters); + if (expansion.numArgs) { + // paste arguments in place of the placeholders + tokens = tokens.slice(); // make a shallow copy + for (var i = tokens.length - 1; i >= 0; --i) { + var tok = tokens[i]; + if (tok.text === "#") { + if (i === 0) { + throw new ParseError("Incomplete placeholder at end of macro body", tok); + } + tok = tokens[--i]; // next token on stack + if (tok.text === "#") { + // ## → # + tokens.splice(i + 1, 1); // drop first # + } else if (/^[1-9]$/.test(tok.text)) { + // replace the placeholder with the indicated argument + tokens.splice(i, 2, ...args[+tok.text - 1]); + } else { + throw new ParseError("Not a valid argument number", tok); + } + } + } + } + // Concatenate expansion onto top of stack. + this.pushTokens(tokens); + return tokens.length; + } + /** + * Expand the next token only once (if possible), and return the resulting + * top token on the stack (without removing anything from the stack). + * Similar in behavior to TeX's `\expandafter\futurelet`. + * Equivalent to expandOnce() followed by future(). + */ + expandAfterFuture() { + this.expandOnce(); + return this.future(); + } + /** + * Recursively expand first token, then return first non-expandable token. + */ + expandNextToken() { + for (;;) { + if (this.expandOnce() === false) { + // fully expanded + var token = this.stack.pop(); + // the token after \noexpand is interpreted as if its meaning + // were ‘\relax’ + if (token.treatAsRelax) { + token.text = "\\relax"; + } + return token; + } + } + } + /** + * Fully expand the given macro name and return the resulting list of + * tokens, or return `undefined` if no such macro is defined. + */ + expandMacro(name) { + return this.macros.has(name) ? this.expandTokens([new Token(name)]) : undefined; + } + /** + * Fully expand the given token stream and return the resulting list of + * tokens. Note that the input tokens are in reverse order, but the + * output tokens are in forward order. + */ + expandTokens(tokens) { + var output = []; + var oldStackLength = this.stack.length; + this.pushTokens(tokens); + while (this.stack.length > oldStackLength) { + // Expand only expandable tokens + if (this.expandOnce(true) === false) { + // fully expanded + var token = this.stack.pop(); + if (token.treatAsRelax) { + // the expansion of \noexpand is the token itself + token.noexpand = false; + token.treatAsRelax = false; + } + output.push(token); + } + } + // Count all of these tokens as additional expansions, to prevent + // exponential blowup from linearly many \edef's. + this.countExpansion(output.length); + return output; + } + /** + * Fully expand the given macro name and return the result as a string, + * or return `undefined` if no such macro is defined. + */ + expandMacroAsText(name) { + var tokens = this.expandMacro(name); + if (tokens) { + return tokens.map(token => token.text).join(""); + } else { + return tokens; + } + } + /** + * Returns the expanded macro as a reversed array of tokens and a macro + * argument count. Or returns `null` if no such macro. + */ + _getExpansion(name) { + var definition = this.macros.get(name); + if (definition == null) { + // mainly checking for undefined here + return definition; + } + // If a single character has an associated catcode other than 13 + // (active character), then don't expand it. + if (name.length === 1) { + var catcode = this.lexer.catcodes[name]; + if (catcode != null && catcode !== 13) { + return; + } + } + var expansion = typeof definition === "function" ? definition(this) : definition; + if (typeof expansion === "string") { + var numArgs = 0; + if (expansion.includes("#")) { + var stripped = expansion.replace(/##/g, ""); + while (stripped.includes("#" + (numArgs + 1))) { + ++numArgs; + } + } + var bodyLexer = new Lexer(expansion, this.settings); + var tokens = []; + var tok = bodyLexer.lex(); + while (tok.text !== "EOF") { + tokens.push(tok); + tok = bodyLexer.lex(); + } + tokens.reverse(); // to fit in with stack using push and pop + var expanded = { + tokens, + numArgs + }; + return expanded; + } + return expansion; + } + /** + * Determine whether a command is currently "defined" (has some + * functionality), meaning that it's a macro (in the current group), + * a function, a symbol, or one of the special commands listed in + * `implicitCommands`. + */ + isDefined(name) { + return this.macros.has(name) || functions.hasOwnProperty(name) || symbols.math.hasOwnProperty(name) || symbols.text.hasOwnProperty(name) || implicitCommands.hasOwnProperty(name); + } + /** + * Determine whether a command is expandable. + */ + isExpandable(name) { + var macro = this.macros.get(name); + return macro != null ? typeof macro === "string" || typeof macro === "function" || !macro.unexpandable : functions.hasOwnProperty(name) && !functions[name].primitive; + } +} + +// Helpers for Parser.js handling of Unicode (sub|super)script characters. +var unicodeSubRegEx = /^[₊₋₌₍₎₀₁₂₃₄₅₆₇₈₉ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓᵦᵧᵨᵩᵪ]/; +var uSubsAndSups = Object.freeze({ + '₊': '+', + '₋': '-', + '₌': '=', + '₍': '(', + '₎': ')', + '₀': '0', + '₁': '1', + '₂': '2', + '₃': '3', + '₄': '4', + '₅': '5', + '₆': '6', + '₇': '7', + '₈': '8', + '₉': '9', + '\u2090': 'a', + '\u2091': 'e', + '\u2095': 'h', + '\u1D62': 'i', + '\u2C7C': 'j', + '\u2096': 'k', + '\u2097': 'l', + '\u2098': 'm', + '\u2099': 'n', + '\u2092': 'o', + '\u209A': 'p', + '\u1D63': 'r', + '\u209B': 's', + '\u209C': 't', + '\u1D64': 'u', + '\u1D65': 'v', + '\u2093': 'x', + '\u1D66': 'β', + '\u1D67': 'γ', + '\u1D68': 'ρ', + '\u1D69': '\u03d5', + '\u1D6A': 'χ', + '⁺': '+', + '⁻': '-', + '⁼': '=', + '⁽': '(', + '⁾': ')', + '⁰': '0', + '¹': '1', + '²': '2', + '³': '3', + '⁴': '4', + '⁵': '5', + '⁶': '6', + '⁷': '7', + '⁸': '8', + '⁹': '9', + '\u1D2C': 'A', + '\u1D2E': 'B', + '\u1D30': 'D', + '\u1D31': 'E', + '\u1D33': 'G', + '\u1D34': 'H', + '\u1D35': 'I', + '\u1D36': 'J', + '\u1D37': 'K', + '\u1D38': 'L', + '\u1D39': 'M', + '\u1D3A': 'N', + '\u1D3C': 'O', + '\u1D3E': 'P', + '\u1D3F': 'R', + '\u1D40': 'T', + '\u1D41': 'U', + '\u2C7D': 'V', + '\u1D42': 'W', + '\u1D43': 'a', + '\u1D47': 'b', + '\u1D9C': 'c', + '\u1D48': 'd', + '\u1D49': 'e', + '\u1DA0': 'f', + '\u1D4D': 'g', + '\u02B0': 'h', + '\u2071': 'i', + '\u02B2': 'j', + '\u1D4F': 'k', + '\u02E1': 'l', + '\u1D50': 'm', + '\u207F': 'n', + '\u1D52': 'o', + '\u1D56': 'p', + '\u02B3': 'r', + '\u02E2': 's', + '\u1D57': 't', + '\u1D58': 'u', + '\u1D5B': 'v', + '\u02B7': 'w', + '\u02E3': 'x', + '\u02B8': 'y', + '\u1DBB': 'z', + '\u1D5D': 'β', + '\u1D5E': 'γ', + '\u1D5F': 'δ', + '\u1D60': '\u03d5', + '\u1D61': 'χ', + '\u1DBF': 'θ' +}); + +/* eslint no-constant-condition:0 */ +// Pre-evaluate both modules as unicodeSymbols require String.normalize() +var unicodeAccents = { + "́": { + "text": "\\'", + "math": "\\acute" + }, + "̀": { + "text": "\\`", + "math": "\\grave" + }, + "̈": { + "text": "\\\"", + "math": "\\ddot" + }, + "̃": { + "text": "\\~", + "math": "\\tilde" + }, + "̄": { + "text": "\\=", + "math": "\\bar" + }, + "̆": { + "text": "\\u", + "math": "\\breve" + }, + "̌": { + "text": "\\v", + "math": "\\check" + }, + "̂": { + "text": "\\^", + "math": "\\hat" + }, + "̇": { + "text": "\\.", + "math": "\\dot" + }, + "̊": { + "text": "\\r", + "math": "\\mathring" + }, + "̋": { + "text": "\\H" + }, + "̧": { + "text": "\\c" + } +}; +var unicodeSymbols = { + "á": "á", + "à": "à", + "ä": "ä", + "ǟ": "ǟ", + "ã": "ã", + "ā": "ā", + "ă": "ă", + "ắ": "ắ", + "ằ": "ằ", + "ẵ": "ẵ", + "ǎ": "ǎ", + "â": "â", + "ấ": "ấ", + "ầ": "ầ", + "ẫ": "ẫ", + "ȧ": "ȧ", + "ǡ": "ǡ", + "å": "å", + "ǻ": "ǻ", + "ḃ": "ḃ", + "ć": "ć", + "ḉ": "ḉ", + "č": "č", + "ĉ": "ĉ", + "ċ": "ċ", + "ç": "ç", + "ď": "ď", + "ḋ": "ḋ", + "ḑ": "ḑ", + "é": "é", + "è": "è", + "ë": "ë", + "ẽ": "ẽ", + "ē": "ē", + "ḗ": "ḗ", + "ḕ": "ḕ", + "ĕ": "ĕ", + "ḝ": "ḝ", + "ě": "ě", + "ê": "ê", + "ế": "ế", + "ề": "ề", + "ễ": "ễ", + "ė": "ė", + "ȩ": "ȩ", + "ḟ": "ḟ", + "ǵ": "ǵ", + "ḡ": "ḡ", + "ğ": "ğ", + "ǧ": "ǧ", + "ĝ": "ĝ", + "ġ": "ġ", + "ģ": "ģ", + "ḧ": "ḧ", + "ȟ": "ȟ", + "ĥ": "ĥ", + "ḣ": "ḣ", + "ḩ": "ḩ", + "í": "í", + "ì": "ì", + "ï": "ï", + "ḯ": "ḯ", + "ĩ": "ĩ", + "ī": "ī", + "ĭ": "ĭ", + "ǐ": "ǐ", + "î": "î", + "ǰ": "ǰ", + "ĵ": "ĵ", + "ḱ": "ḱ", + "ǩ": "ǩ", + "ķ": "ķ", + "ĺ": "ĺ", + "ľ": "ľ", + "ļ": "ļ", + "ḿ": "ḿ", + "ṁ": "ṁ", + "ń": "ń", + "ǹ": "ǹ", + "ñ": "ñ", + "ň": "ň", + "ṅ": "ṅ", + "ņ": "ņ", + "ó": "ó", + "ò": "ò", + "ö": "ö", + "ȫ": "ȫ", + "õ": "õ", + "ṍ": "ṍ", + "ṏ": "ṏ", + "ȭ": "ȭ", + "ō": "ō", + "ṓ": "ṓ", + "ṑ": "ṑ", + "ŏ": "ŏ", + "ǒ": "ǒ", + "ô": "ô", + "ố": "ố", + "ồ": "ồ", + "ỗ": "ỗ", + "ȯ": "ȯ", + "ȱ": "ȱ", + "ő": "ő", + "ṕ": "ṕ", + "ṗ": "ṗ", + "ŕ": "ŕ", + "ř": "ř", + "ṙ": "ṙ", + "ŗ": "ŗ", + "ś": "ś", + "ṥ": "ṥ", + "š": "š", + "ṧ": "ṧ", + "ŝ": "ŝ", + "ṡ": "ṡ", + "ş": "ş", + "ẗ": "ẗ", + "ť": "ť", + "ṫ": "ṫ", + "ţ": "ţ", + "ú": "ú", + "ù": "ù", + "ü": "ü", + "ǘ": "ǘ", + "ǜ": "ǜ", + "ǖ": "ǖ", + "ǚ": "ǚ", + "ũ": "ũ", + "ṹ": "ṹ", + "ū": "ū", + "ṻ": "ṻ", + "ŭ": "ŭ", + "ǔ": "ǔ", + "û": "û", + "ů": "ů", + "ű": "ű", + "ṽ": "ṽ", + "ẃ": "ẃ", + "ẁ": "ẁ", + "ẅ": "ẅ", + "ŵ": "ŵ", + "ẇ": "ẇ", + "ẘ": "ẘ", + "ẍ": "ẍ", + "ẋ": "ẋ", + "ý": "ý", + "ỳ": "ỳ", + "ÿ": "ÿ", + "ỹ": "ỹ", + "ȳ": "ȳ", + "ŷ": "ŷ", + "ẏ": "ẏ", + "ẙ": "ẙ", + "ź": "ź", + "ž": "ž", + "ẑ": "ẑ", + "ż": "ż", + "Á": "Á", + "À": "À", + "Ä": "Ä", + "Ǟ": "Ǟ", + "Ã": "Ã", + "Ā": "Ā", + "Ă": "Ă", + "Ắ": "Ắ", + "Ằ": "Ằ", + "Ẵ": "Ẵ", + "Ǎ": "Ǎ", + "Â": "Â", + "Ấ": "Ấ", + "Ầ": "Ầ", + "Ẫ": "Ẫ", + "Ȧ": "Ȧ", + "Ǡ": "Ǡ", + "Å": "Å", + "Ǻ": "Ǻ", + "Ḃ": "Ḃ", + "Ć": "Ć", + "Ḉ": "Ḉ", + "Č": "Č", + "Ĉ": "Ĉ", + "Ċ": "Ċ", + "Ç": "Ç", + "Ď": "Ď", + "Ḋ": "Ḋ", + "Ḑ": "Ḑ", + "É": "É", + "È": "È", + "Ë": "Ë", + "Ẽ": "Ẽ", + "Ē": "Ē", + "Ḗ": "Ḗ", + "Ḕ": "Ḕ", + "Ĕ": "Ĕ", + "Ḝ": "Ḝ", + "Ě": "Ě", + "Ê": "Ê", + "Ế": "Ế", + "Ề": "Ề", + "Ễ": "Ễ", + "Ė": "Ė", + "Ȩ": "Ȩ", + "Ḟ": "Ḟ", + "Ǵ": "Ǵ", + "Ḡ": "Ḡ", + "Ğ": "Ğ", + "Ǧ": "Ǧ", + "Ĝ": "Ĝ", + "Ġ": "Ġ", + "Ģ": "Ģ", + "Ḧ": "Ḧ", + "Ȟ": "Ȟ", + "Ĥ": "Ĥ", + "Ḣ": "Ḣ", + "Ḩ": "Ḩ", + "Í": "Í", + "Ì": "Ì", + "Ï": "Ï", + "Ḯ": "Ḯ", + "Ĩ": "Ĩ", + "Ī": "Ī", + "Ĭ": "Ĭ", + "Ǐ": "Ǐ", + "Î": "Î", + "İ": "İ", + "Ĵ": "Ĵ", + "Ḱ": "Ḱ", + "Ǩ": "Ǩ", + "Ķ": "Ķ", + "Ĺ": "Ĺ", + "Ľ": "Ľ", + "Ļ": "Ļ", + "Ḿ": "Ḿ", + "Ṁ": "Ṁ", + "Ń": "Ń", + "Ǹ": "Ǹ", + "Ñ": "Ñ", + "Ň": "Ň", + "Ṅ": "Ṅ", + "Ņ": "Ņ", + "Ó": "Ó", + "Ò": "Ò", + "Ö": "Ö", + "Ȫ": "Ȫ", + "Õ": "Õ", + "Ṍ": "Ṍ", + "Ṏ": "Ṏ", + "Ȭ": "Ȭ", + "Ō": "Ō", + "Ṓ": "Ṓ", + "Ṑ": "Ṑ", + "Ŏ": "Ŏ", + "Ǒ": "Ǒ", + "Ô": "Ô", + "Ố": "Ố", + "Ồ": "Ồ", + "Ỗ": "Ỗ", + "Ȯ": "Ȯ", + "Ȱ": "Ȱ", + "Ő": "Ő", + "Ṕ": "Ṕ", + "Ṗ": "Ṗ", + "Ŕ": "Ŕ", + "Ř": "Ř", + "Ṙ": "Ṙ", + "Ŗ": "Ŗ", + "Ś": "Ś", + "Ṥ": "Ṥ", + "Š": "Š", + "Ṧ": "Ṧ", + "Ŝ": "Ŝ", + "Ṡ": "Ṡ", + "Ş": "Ş", + "Ť": "Ť", + "Ṫ": "Ṫ", + "Ţ": "Ţ", + "Ú": "Ú", + "Ù": "Ù", + "Ü": "Ü", + "Ǘ": "Ǘ", + "Ǜ": "Ǜ", + "Ǖ": "Ǖ", + "Ǚ": "Ǚ", + "Ũ": "Ũ", + "Ṹ": "Ṹ", + "Ū": "Ū", + "Ṻ": "Ṻ", + "Ŭ": "Ŭ", + "Ǔ": "Ǔ", + "Û": "Û", + "Ů": "Ů", + "Ű": "Ű", + "Ṽ": "Ṽ", + "Ẃ": "Ẃ", + "Ẁ": "Ẁ", + "Ẅ": "Ẅ", + "Ŵ": "Ŵ", + "Ẇ": "Ẇ", + "Ẍ": "Ẍ", + "Ẋ": "Ẋ", + "Ý": "Ý", + "Ỳ": "Ỳ", + "Ÿ": "Ÿ", + "Ỹ": "Ỹ", + "Ȳ": "Ȳ", + "Ŷ": "Ŷ", + "Ẏ": "Ẏ", + "Ź": "Ź", + "Ž": "Ž", + "Ẑ": "Ẑ", + "Ż": "Ż", + "ά": "ά", + "ὰ": "ὰ", + "ᾱ": "ᾱ", + "ᾰ": "ᾰ", + "έ": "έ", + "ὲ": "ὲ", + "ή": "ή", + "ὴ": "ὴ", + "ί": "ί", + "ὶ": "ὶ", + "ϊ": "ϊ", + "ΐ": "ΐ", + "ῒ": "ῒ", + "ῑ": "ῑ", + "ῐ": "ῐ", + "ό": "ό", + "ὸ": "ὸ", + "ύ": "ύ", + "ὺ": "ὺ", + "ϋ": "ϋ", + "ΰ": "ΰ", + "ῢ": "ῢ", + "ῡ": "ῡ", + "ῠ": "ῠ", + "ώ": "ώ", + "ὼ": "ὼ", + "Ύ": "Ύ", + "Ὺ": "Ὺ", + "Ϋ": "Ϋ", + "Ῡ": "Ῡ", + "Ῠ": "Ῠ", + "Ώ": "Ώ", + "Ὼ": "Ὼ" +}; +/** + * This file contains the parser used to parse out a TeX expression from the + * input. Since TeX isn't context-free, standard parsers don't work particularly + * well. + * + * The strategy of this parser is as such: + * + * The main functions (the `.parse...` ones) take a position in the current + * parse string to parse tokens from. The lexer (found in Lexer.js, stored at + * this.gullet.lexer) also supports pulling out tokens at arbitrary places. When + * individual tokens are needed at a position, the lexer is called to pull out a + * token, which is then used. + * + * The parser has a property called "mode" indicating the mode that + * the parser is currently in. Currently it has to be one of "math" or + * "text", which denotes whether the current environment is a math-y + * one or a text-y one (e.g. inside \text). Currently, this serves to + * limit the functions which can be used in text mode. + * + * The main functions then return an object which contains the useful data that + * was parsed at its given point, and a new position at the end of the parsed + * data. The main functions can call each other and continue the parsing by + * using the returned position as a new starting point. + * + * There are also extra `.handle...` functions, which pull out some reused + * functionality into self-contained functions. + * + * The functions return ParseNodes. + */ +class Parser { + constructor(input, settings) { + this.mode = void 0; + this.gullet = void 0; + this.settings = void 0; + this.leftrightDepth = void 0; + this.nextToken = void 0; + // Start in math mode + this.mode = "math"; + // Create a new macro expander (gullet) and (indirectly via that) also a + // new lexer (mouth) for this parser (stomach, in the language of TeX) + this.gullet = new MacroExpander(input, settings, this.mode); + // Store the settings for use in parsing + this.settings = settings; + // Count leftright depth (for \middle errors) + this.leftrightDepth = 0; + this.nextToken = null; + } + /** + * Checks a result to make sure it has the right type, and throws an + * appropriate error otherwise. + */ + expect(text, consume) { + if (consume === void 0) { + consume = true; + } + if (this.fetch().text !== text) { + throw new ParseError("Expected '" + text + "', got '" + this.fetch().text + "'", this.fetch()); + } + if (consume) { + this.consume(); + } + } + /** + * Discards the current lookahead token, considering it consumed. + */ + consume() { + this.nextToken = null; + } + /** + * Return the current lookahead token, or if there isn't one (at the + * beginning, or if the previous lookahead token was consume()d), + * fetch the next token as the new lookahead token and return it. + */ + fetch() { + if (this.nextToken == null) { + this.nextToken = this.gullet.expandNextToken(); + } + return this.nextToken; + } + /** + * Switches between "text" and "math" modes. + */ + switchMode(newMode) { + this.mode = newMode; + this.gullet.switchMode(newMode); + } + /** + * Main parsing function, which parses an entire input. + */ + parse() { + if (!this.settings.globalGroup) { + // Create a group namespace for the math expression. + // (LaTeX creates a new group for every $...$, $$...$$, \[...\].) + this.gullet.beginGroup(); + } + // Use old \color behavior (same as LaTeX's \textcolor) if requested. + // We do this within the group for the math expression, so it doesn't + // pollute settings.macros. + if (this.settings.colorIsTextColor) { + this.gullet.macros.set("\\color", "\\textcolor"); + } + try { + // Try to parse the input + var parse = this.parseExpression(false); + // If we succeeded, make sure there's an EOF at the end + this.expect("EOF"); + // End the group namespace for the expression + if (!this.settings.globalGroup) { + this.gullet.endGroup(); + } + return parse; + // Close any leftover groups in case of a parse error. + } finally { + this.gullet.endGroups(); + } + } + /** + * Fully parse a separate sequence of tokens as a separate job. + * Tokens should be specified in reverse order, as in a MacroDefinition. + */ + subparse(tokens) { + // Save the next token from the current job. + var oldToken = this.nextToken; + this.consume(); + // Run the new job, terminating it with an excess '}' + this.gullet.pushToken(new Token("}")); + this.gullet.pushTokens(tokens); + var parse = this.parseExpression(false); + this.expect("}"); + // Restore the next token from the current job. + this.nextToken = oldToken; + return parse; + } + /** + * Parses an "expression", which is a list of atoms. + * + * `breakOnInfix`: Should the parsing stop when we hit infix nodes? This + * happens when functions have higher precedence than infix + * nodes in implicit parses. + * + * `breakOnTokenText`: The text of the token that the expression should end + * with, or `null` if something else should end the + * expression. + */ + parseExpression(breakOnInfix, breakOnTokenText) { + var body = []; + // Keep adding atoms to the body until we can't parse any more atoms (either + // we reached the end, a }, or a \right) + while (true) { + // Ignore spaces in math mode + if (this.mode === "math") { + this.consumeSpaces(); + } + var lex = this.fetch(); + if (Parser.endOfExpression.has(lex.text)) { + break; + } + if (breakOnTokenText && lex.text === breakOnTokenText) { + break; + } + if (breakOnInfix && functions[lex.text] && functions[lex.text].infix) { + break; + } + var atom = this.parseAtom(breakOnTokenText); + if (!atom) { + break; + } else if (atom.type === "internal") { + // Internal nodes do not appear in parse tree + continue; + } + body.push(atom); + } + if (this.mode === "text") { + this.formLigatures(body); + } + return this.handleInfixNodes(body); + } + /** + * Rewrites infix operators such as \over with corresponding commands such + * as \frac. + * + * There can only be one infix operator per group. If there's more than one + * then the expression is ambiguous. This can be resolved by adding {}. + */ + handleInfixNodes(body) { + var overIndex = -1; + var funcName; + for (var i = 0; i < body.length; i++) { + var node = body[i]; + if (node.type === "infix") { + if (overIndex !== -1) { + throw new ParseError("only one infix operator per group", node.token); + } + overIndex = i; + funcName = node.replaceWith; + } + } + if (overIndex !== -1 && funcName) { + var numerNode; + var denomNode; + var numerBody = body.slice(0, overIndex); + var denomBody = body.slice(overIndex + 1); + if (numerBody.length === 1 && numerBody[0].type === "ordgroup") { + numerNode = numerBody[0]; + } else { + numerNode = { + type: "ordgroup", + mode: this.mode, + body: numerBody + }; + } + if (denomBody.length === 1 && denomBody[0].type === "ordgroup") { + denomNode = denomBody[0]; + } else { + denomNode = { + type: "ordgroup", + mode: this.mode, + body: denomBody + }; + } + var _node; + if (funcName === "\\\\abovefrac") { + _node = this.callFunction(funcName, [numerNode, body[overIndex], denomNode], []); + } else { + _node = this.callFunction(funcName, [numerNode, denomNode], []); + } + return [_node]; + } else { + return body; + } + } + /** + * Handle a subscript or superscript with nice errors. + */ + handleSupSubscript(name) { + var symbolToken = this.fetch(); + var symbol = symbolToken.text; + this.consume(); + this.consumeSpaces(); // ignore spaces before sup/subscript argument + // Skip over allowed internal nodes such as \relax + var group; + do { + var _group; + group = this.parseGroup(name); + } while (((_group = group) == null ? void 0 : _group.type) === "internal"); + if (!group) { + throw new ParseError("Expected group after '" + symbol + "'", symbolToken); + } + return group; + } + /** + * Converts the textual input of an unsupported command into a text node + * contained within a color node whose color is determined by errorColor + */ + formatUnsupportedCmd(text) { + var textordArray = []; + for (var i = 0; i < text.length; i++) { + textordArray.push({ + type: "textord", + mode: "text", + text: text[i] + }); + } + var textNode = { + type: "text", + mode: this.mode, + body: textordArray + }; + var colorNode = { + type: "color", + mode: this.mode, + color: this.settings.errorColor, + body: [textNode] + }; + return colorNode; + } + /** + * Parses a group with optional super/subscripts. + */ + parseAtom(breakOnTokenText) { + // The body of an atom is an implicit group, so that things like + // \left(x\right)^2 work correctly. + var base = this.parseGroup("atom", breakOnTokenText); + // Internal nodes (e.g. \relax) cannot support super/subscripts. + // Instead, we will pick up super/subscripts with blank base next round. + if ((base == null ? void 0 : base.type) === "internal") { + return base; + } + // In text mode, we don't have superscripts or subscripts + if (this.mode === "text") { + return base; + } + var superscript; + var subscript; + while (true) { + // Guaranteed in math mode, so eat any spaces first. + this.consumeSpaces(); + // Lex the first token + var lex = this.fetch(); + if (lex.text === "\\limits" || lex.text === "\\nolimits") { + // We got a limit control + if (base && base.type === "op") { + base.limits = lex.text === "\\limits"; + base.alwaysHandleSupSub = true; + } else if (base && base.type === "operatorname") { + if (base.alwaysHandleSupSub) { + base.limits = lex.text === "\\limits"; + } + } else { + throw new ParseError("Limit controls must follow a math operator", lex); + } + this.consume(); + } else if (lex.text === "^") { + // We got a superscript start + if (superscript) { + throw new ParseError("Double superscript", lex); + } + superscript = this.handleSupSubscript("superscript"); + } else if (lex.text === "_") { + // We got a subscript start + if (subscript) { + throw new ParseError("Double subscript", lex); + } + subscript = this.handleSupSubscript("subscript"); + } else if (lex.text === "'") { + // We got a prime + if (superscript) { + throw new ParseError("Double superscript", lex); + } + var prime = { + type: "textord", + mode: this.mode, + text: "\\prime" + }; + // Many primes can be grouped together, so we handle this here + var primes = [prime]; + this.consume(); + // Keep lexing tokens until we get something that's not a prime + while (this.fetch().text === "'") { + // For each one, add another prime to the list + primes.push(prime); + this.consume(); + } + // If there's a superscript following the primes, combine that + // superscript in with the primes. + if (this.fetch().text === "^") { + primes.push(this.handleSupSubscript("superscript")); + } + // Put everything into an ordgroup as the superscript + superscript = { + type: "ordgroup", + mode: this.mode, + body: primes + }; + } else if (uSubsAndSups[lex.text]) { + // A Unicode subscript or superscript character. + // We treat these similarly to the unicode-math package. + // So we render a string of Unicode (sub|super)scripts the + // same as a (sub|super)script of regular characters. + var isSub = unicodeSubRegEx.test(lex.text); + var subsupTokens = []; + subsupTokens.push(new Token(uSubsAndSups[lex.text])); + this.consume(); + // Continue fetching tokens to fill out the string. + while (true) { + var token = this.fetch().text; + if (!uSubsAndSups[token]) { + break; + } + if (unicodeSubRegEx.test(token) !== isSub) { + break; + } + subsupTokens.unshift(new Token(uSubsAndSups[token])); + this.consume(); + } + // Now create a (sub|super)script. + var body = this.subparse(subsupTokens); + if (isSub) { + subscript = { + type: "ordgroup", + mode: "math", + body + }; + } else { + superscript = { + type: "ordgroup", + mode: "math", + body + }; + } + } else { + // If it wasn't ^, _, or ', stop parsing super/subscripts + break; + } + } + // Base must be set if superscript or subscript are set per logic above, + // but need to check here for type check to pass. + if (superscript && subscript) { + return { + type: "supsub", + mode: this.mode, + base, + sup: superscript, + sub: subscript + }; + } else if (superscript) { + return { + type: "supsub", + mode: this.mode, + base, + sup: superscript + }; + } else if (subscript) { + return { + type: "supsub", + mode: this.mode, + base, + sub: subscript + }; + } else { + // Otherwise return the original body + return base; + } + } + /** + * Parses an entire function, including its base and all of its arguments. + */ + parseFunction(breakOnTokenText, name) { + var token = this.fetch(); + var func = token.text; + var funcData = functions[func]; + if (!funcData) { + return null; + } + this.consume(); // consume command token + if (name && name !== "atom" && !funcData.allowedInArgument) { + throw new ParseError("Got function '" + func + "' with no arguments" + (name ? " as " + name : ""), token); + // Treat undefined allowedInText as false. + } else if (this.mode === "text" && !funcData.allowedInText) { + throw new ParseError("Can't use function '" + func + "' in text mode", token); + // Treat undefined allowedInMath as true. + } else if (this.mode === "math" && funcData.allowedInMath === false) { + throw new ParseError("Can't use function '" + func + "' in math mode", token); + } + var { + args, + optArgs + } = this.parseArguments(func, funcData); + return this.callFunction(func, args, optArgs, token, breakOnTokenText); + } + /** + * Call a function handler with a suitable context and arguments. + */ + callFunction(name, args, optArgs, token, breakOnTokenText) { + var context = { + funcName: name, + parser: this, + token, + breakOnTokenText + }; + var func = functions[name]; + if (func && func.handler) { + return func.handler(context, args, optArgs); + } else { + throw new ParseError("No function handler for " + name); + } + } + /** + * Parses the arguments of a function or environment + */ + parseArguments(func, + // Should look like "\name" or "\begin{name}". + funcData) { + var _funcData$numOptional; + var numOptionalArgs = (_funcData$numOptional = funcData.numOptionalArgs) != null ? _funcData$numOptional : 0; + var totalArgs = funcData.numArgs + numOptionalArgs; + if (totalArgs === 0) { + return { + args: [], + optArgs: [] + }; + } + var args = []; + var optArgs = []; + for (var i = 0; i < totalArgs; i++) { + var _funcData$argTypes; + var argType = (_funcData$argTypes = funcData.argTypes) == null ? void 0 : _funcData$argTypes[i]; + var isOptional = i < numOptionalArgs; + if ("primitive" in funcData && funcData.primitive && argType == null || + // \sqrt expands into primitive if optional argument doesn't exist + funcData.type === "sqrt" && i === 1 && optArgs[0] == null) { + argType = "primitive"; + } + var arg = this.parseGroupOfType("argument to '" + func + "'", argType, isOptional); + if (isOptional) { + optArgs.push(arg); + } else if (arg != null) { + args.push(arg); + } else { + // should be unreachable + throw new ParseError("Null argument, please report this as a bug"); + } + } + return { + args, + optArgs + }; + } + /** + * Parses a group when the mode is changing. + */ + parseGroupOfType(name, type, optional) { + switch (type) { + case "color": + return this.parseColorGroup(optional); + case "size": + return this.parseSizeGroup(optional); + case "url": + return this.parseUrlGroup(optional); + case "math": + case "text": + return this.parseArgumentGroup(optional, type); + case "hbox": + { + // hbox argument type wraps the argument in the equivalent of + // \hbox, which is like \text but switching to \textstyle size + // and resetting math font. + var group = this.parseArgumentGroup(optional, "text"); + return group != null ? { + type: "styling", + mode: group.mode, + body: [group], + style: "text", + // simulate \textstyle + resetFont: true + } : null; + } + case "raw": + { + var token = this.parseStringGroup(optional); + return token != null ? { + type: "raw", + mode: "text", + string: token.text + } : null; + } + case "primitive": + { + if (optional) { + throw new ParseError("A primitive argument cannot be optional"); + } + var _group2 = this.parseGroup(name); + if (_group2 == null) { + throw new ParseError("Expected group as " + name, this.fetch()); + } + return _group2; + } + case "original": + case undefined: + return this.parseArgumentGroup(optional); + default: + throw new ParseError("Unknown group type as " + name, this.fetch()); + } + } + /** + * Discard any space tokens, fetching the next non-space token. + */ + consumeSpaces() { + while (this.fetch().text === " ") { + this.consume(); + } + } + /** + * Parses a group, essentially returning the string formed by the + * brace-enclosed tokens plus some position information. + */ + parseStringGroup(optional) { + var argToken = this.gullet.scanArgument(optional); + if (argToken == null) { + return null; + } + var str = ""; + var nextToken; + while ((nextToken = this.fetch()).text !== "EOF") { + str += nextToken.text; + this.consume(); + } + this.consume(); // consume the end of the argument + argToken.text = str; + return argToken; + } + /** + * Parses a regex-delimited group: the largest sequence of tokens + * whose concatenated strings match `regex`. Returns the string + * formed by the tokens plus some position information. + */ + parseRegexGroup(regex, modeName) { + var firstToken = this.fetch(); + var lastToken = firstToken; + var str = ""; + var nextToken; + while ((nextToken = this.fetch()).text !== "EOF" && regex.test(str + nextToken.text)) { + lastToken = nextToken; + str += lastToken.text; + this.consume(); + } + if (str === "") { + throw new ParseError("Invalid " + modeName + ": '" + firstToken.text + "'", firstToken); + } + return firstToken.range(lastToken, str); + } + /** + * Parses a color description. + */ + parseColorGroup(optional) { + var res = this.parseStringGroup(optional); + if (res == null) { + return null; + } + var match = /^(#[a-f0-9]{3,4}|#[a-f0-9]{6}|#[a-f0-9]{8}|[a-f0-9]{6}|[a-z]+)$/i.exec(res.text); + if (!match) { + throw new ParseError("Invalid color: '" + res.text + "'", res); + } + var color = match[0]; + if (/^[0-9a-f]{6}$/i.test(color)) { + // We allow a 6-digit HTML color spec without a leading "#". + // This follows the xcolor package's HTML color model. + // Predefined color names are all missed by this RegEx pattern. + color = "#" + color; + } + return { + type: "color-token", + mode: this.mode, + color + }; + } + /** + * Parses a size specification, consisting of magnitude and unit. + */ + parseSizeGroup(optional) { + var res; + var isBlank = false; + // don't expand before parseStringGroup + this.gullet.consumeSpaces(); + if (!optional && this.gullet.future().text !== "{") { + res = this.parseRegexGroup(/^[-+]? *(?:$|\d+|\d+\.\d*|\.\d*) *[a-z]{0,2} *$/, "size"); + } else { + res = this.parseStringGroup(optional); + } + if (!res) { + return null; + } + if (!optional && res.text.length === 0) { + // Because we've tested for what is !optional, this block won't + // affect \kern, \hspace, etc. It will capture the mandatory arguments + // to \genfrac and \above. + res.text = "0pt"; // Enable \above{} + isBlank = true; // This is here specifically for \genfrac + } + var match = /([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(res.text); + if (!match) { + throw new ParseError("Invalid size: '" + res.text + "'", res); + } + var data = { + number: +(match[1] + match[2]), + // sign + magnitude, cast to number + unit: match[3] + }; + if (!validUnit(data)) { + throw new ParseError("Invalid unit: '" + data.unit + "'", res); + } + return { + type: "size", + mode: this.mode, + value: data, + isBlank + }; + } + /** + * Parses an URL, checking escaped letters and allowed protocols, + * and setting the catcode of % as an active character (as in \hyperref). + */ + parseUrlGroup(optional) { + this.gullet.lexer.setCatcode("%", 13); // active character + this.gullet.lexer.setCatcode("~", 12); // other character + var res = this.parseStringGroup(optional); + this.gullet.lexer.setCatcode("%", 14); // comment character + this.gullet.lexer.setCatcode("~", 13); // active character + if (res == null) { + return null; + } + // hyperref package allows backslashes alone in href, but doesn't + // generate valid links in such cases; we interpret this as + // "undefined" behaviour, and keep them as-is. Some browser will + // replace backslashes with forward slashes. + var url = res.text.replace(/\\([#$%&~_^{}])/g, '$1'); + return { + type: "url", + mode: this.mode, + url + }; + } + /** + * Parses an argument with the mode specified. + */ + parseArgumentGroup(optional, mode) { + var argToken = this.gullet.scanArgument(optional); + if (argToken == null) { + return null; + } + var outerMode = this.mode; + if (mode) { + // Switch to specified mode + this.switchMode(mode); + } + this.gullet.beginGroup(); + var expression = this.parseExpression(false, "EOF"); + // TODO: find an alternative way to denote the end + this.expect("EOF"); // expect the end of the argument + this.gullet.endGroup(); + var result = { + type: "ordgroup", + mode: this.mode, + loc: argToken.loc, + body: expression + }; + if (mode) { + // Switch mode back + this.switchMode(outerMode); + } + return result; + } + /** + * Parses an ordinary group, which is either a single nucleus (like "x") + * or an expression in braces (like "{x+y}") or an implicit group, a group + * that starts at the current position, and ends right before a higher explicit + * group ends, or at EOF. + */ + parseGroup(name, + // For error reporting. + breakOnTokenText) { + var firstToken = this.fetch(); + var text = firstToken.text; + var result; + // Try to parse an open brace or \begingroup + if (text === "{" || text === "\\begingroup") { + this.consume(); + var groupEnd = text === "{" ? "}" : "\\endgroup"; + this.gullet.beginGroup(); + // If we get a brace, parse an expression + var expression = this.parseExpression(false, groupEnd); + var lastToken = this.fetch(); + this.expect(groupEnd); // Check that we got a matching closing brace + this.gullet.endGroup(); + result = { + type: "ordgroup", + mode: this.mode, + loc: SourceLocation.range(firstToken, lastToken), + body: expression, + // A group formed by \begingroup...\endgroup is a semi-simple group + // which doesn't affect spacing in math mode, i.e., is transparent. + // https://tex.stackexchange.com/questions/1930/when-should-one- + // use-begingroup-instead-of-bgroup + semisimple: text === "\\begingroup" || undefined + }; + } else { + // If there exists a function with this name, parse the function. + // Otherwise, just return a nucleus + result = this.parseFunction(breakOnTokenText, name) || this.parseSymbol(); + if (result == null && text[0] === "\\" && !implicitCommands.hasOwnProperty(text)) { + if (this.settings.throwOnError) { + throw new ParseError("Undefined control sequence: " + text, firstToken); + } + result = this.formatUnsupportedCmd(text); + this.consume(); + } + } + return result; + } + /** + * Form ligature-like combinations of characters for text mode. + * This includes inputs like "--", "---", "``" and "''". + * The result will simply replace multiple textord nodes with a single + * character in each value by a single textord node having multiple + * characters in its value. The representation is still ASCII source. + * The group will be modified in place. + */ + formLigatures(group) { + var n = group.length - 1; + for (var i = 0; i < n; ++i) { + var a = group[i]; + if (a.type !== "textord") { + continue; + } + var v = a.text; + var next = group[i + 1]; + if (!next || next.type !== "textord") { + continue; + } + if (v === "-" && next.text === "-") { + var afterNext = group[i + 2]; + if (i + 1 < n && afterNext && afterNext.type === "textord" && afterNext.text === "-") { + group.splice(i, 3, { + type: "textord", + mode: "text", + loc: SourceLocation.range(a, afterNext), + text: "---" + }); + n -= 2; + } else { + group.splice(i, 2, { + type: "textord", + mode: "text", + loc: SourceLocation.range(a, next), + text: "--" + }); + n -= 1; + } + } + if ((v === "'" || v === "`") && next.text === v) { + group.splice(i, 2, { + type: "textord", + mode: "text", + loc: SourceLocation.range(a, next), + text: v + v + }); + n -= 1; + } + } + } + /** + * Parse a single symbol out of the string. Here, we handle single character + * symbols and special functions like \verb. + */ + parseSymbol() { + var nucleus = this.fetch(); + var text = nucleus.text; + if (/^\\verb[^a-zA-Z]/.test(text)) { + this.consume(); + var arg = text.slice(5); + var star = arg.charAt(0) === "*"; + if (star) { + arg = arg.slice(1); + } + // Lexer's tokenRegex is constructed to always have matching + // first/last characters. + if (arg.length < 2 || arg.charAt(0) !== arg.slice(-1)) { + throw new ParseError("\\verb assertion failed --\n please report what input caused this bug"); + } + arg = arg.slice(1, -1); // remove first and last char + return { + type: "verb", + mode: "text", + body: arg, + star + }; + } + // At this point, we should have a symbol, possibly with accents. + // First expand any accented base symbol according to unicodeSymbols. + if (unicodeSymbols.hasOwnProperty(text[0]) && !symbols[this.mode][text[0]]) { + // This behavior is not strict (XeTeX-compatible) in math mode. + if (this.settings.strict && this.mode === "math") { + this.settings.reportNonstrict("unicodeTextInMathMode", "Accented Unicode text character \"" + text[0] + "\" used in " + "math mode", nucleus); + } + text = unicodeSymbols[text[0]] + text.slice(1); + } + // Strip off any combining characters + var match = combiningDiacriticalMarksEndRegex.exec(text); + if (match) { + text = text.substring(0, match.index); + if (text === 'i') { + text = '\u0131'; // dotless i, in math and text mode + } else if (text === 'j') { + text = '\u0237'; // dotless j, in math and text mode + } + } + // Recognize base symbol + var symbol; + if (symbols[this.mode][text]) { + if (this.settings.strict && this.mode === 'math' && extraLatin.includes(text)) { + this.settings.reportNonstrict("unicodeTextInMathMode", "Latin-1/Unicode text character \"" + text[0] + "\" used in " + "math mode", nucleus); + } + var group = symbols[this.mode][text].group; + var loc = SourceLocation.range(nucleus); + var s; + if (isAtom(group)) { + s = { + type: "atom", + mode: this.mode, + family: group, + loc, + text + }; + } else { + s = { + type: group, + mode: this.mode, + loc, + text + }; + } + symbol = s; + } else if (text.charCodeAt(0) >= 0x80) { + // no symbol for e.g. ^ + if (this.settings.strict) { + if (!supportedCodepoint(text.charCodeAt(0))) { + this.settings.reportNonstrict("unknownSymbol", "Unrecognized Unicode character \"" + text[0] + "\"" + (" (" + text.charCodeAt(0) + ")"), nucleus); + } else if (this.mode === "math") { + this.settings.reportNonstrict("unicodeTextInMathMode", "Unicode text character \"" + text[0] + "\" used in math mode", nucleus); + } + } + // All nonmathematical Unicode characters are rendered as if they + // are in text mode (wrapped in \text) because that's what it + // takes to render them in LaTeX. Setting `mode: this.mode` is + // another natural choice (the user requested math mode), but + // this makes it more difficult for getCharacterMetrics() to + // distinguish Unicode characters without metrics and those for + // which we want to simulate the letter M. + symbol = { + type: "textord", + mode: "text", + loc: SourceLocation.range(nucleus), + text + }; + } else { + return null; // EOF, ^, _, {, }, etc. + } + this.consume(); + // Transform combining characters into accents + if (match) { + for (var i = 0; i < match[0].length; i++) { + var accent = match[0][i]; + if (!unicodeAccents[accent]) { + throw new ParseError("Unknown accent ' " + accent + "'", nucleus); + } + var command = unicodeAccents[accent][this.mode] || unicodeAccents[accent].text; + if (!command) { + throw new ParseError("Accent " + accent + " unsupported in " + this.mode + " mode", nucleus); + } + symbol = { + type: "accent", + mode: this.mode, + loc: SourceLocation.range(nucleus), + label: command, + isStretchy: false, + isShifty: true, + base: symbol + }; + } + } + return symbol; + } +} +Parser.endOfExpression = new Set(["}", "\\endgroup", "\\end", "\\right", "&"]); + +/** + * Parses an expression using a Parser, then returns the parsed result. + */ +var parseTree = function parseTree(toParse, settings) { + if (!(typeof toParse === 'string' || toParse instanceof String)) { + throw new TypeError('KaTeX can only parse string typed expression'); + } + var parser = new Parser(toParse, settings); + // Blank out any \df@tag to avoid spurious "Duplicate \tag" errors + delete parser.gullet.macros.current["\\df@tag"]; + var tree = parser.parse(); + // Prevent a color definition from persisting between calls to katex.render(). + delete parser.gullet.macros.current["\\current@color"]; + delete parser.gullet.macros.current["\\color"]; + // If the input used \tag, it will set the \df@tag macro to the tag. + // In this case, we separately parse the tag and wrap the tree. + if (parser.gullet.macros.get("\\df@tag")) { + if (!settings.displayMode) { + throw new ParseError("\\tag works only in display equations"); + } + tree = [{ + type: "tag", + mode: "text", + body: tree, + tag: parser.subparse([new Token("\\df@tag")]) + }]; + } + return tree; +}; + +/* eslint no-console:0 */ +/** + * Parse and build an expression, and place that expression in the DOM node + * given. + */ +var render = function render(expression, baseNode, options) { + baseNode.textContent = ""; + var node = renderToDomTree(expression, options).toNode(); + baseNode.appendChild(node); +}; +// KaTeX's styles don't work properly in quirks mode. Print out an error, and +// disable rendering. +if (typeof document !== "undefined") { + if (document.compatMode !== "CSS1Compat") { + typeof console !== "undefined" && console.warn("Warning: KaTeX doesn't work in quirks mode. Make sure your " + "website has a suitable doctype."); + render = function render() { + throw new ParseError("KaTeX doesn't work in quirks mode."); + }; + } +} +/** + * Parse and build an expression, and return the markup for that. + */ +var renderToString = function renderToString(expression, options) { + var markup = renderToDomTree(expression, options).toMarkup(); + return markup; +}; +/** + * Parse an expression and return the parse tree. + */ +var generateParseTree = function generateParseTree(expression, options) { + var settings = new Settings(options); + return parseTree(expression, settings); +}; +/** + * If the given error is a KaTeX ParseError and options.throwOnError is false, + * renders the invalid LaTeX as a span with hover title giving the KaTeX + * error message. Otherwise, simply throws the error. + */ +var renderError = function renderError(error, expression, options) { + if (options.throwOnError || !(error instanceof ParseError)) { + throw error; + } + var node = makeSpan(["katex-error"], [new SymbolNode(expression)]); + node.setAttribute("title", error.toString()); + node.setAttribute("style", "color:" + options.errorColor); + return node; +}; +/** + * Generates and returns the katex build tree. This is used for advanced + * use cases (like rendering to custom output). + */ +var renderToDomTree = function renderToDomTree(expression, options) { + var settings = new Settings(options); + try { + var tree = parseTree(expression, settings); + return buildTree(tree, expression, settings); + } catch (error) { + return renderError(error, expression, settings); + } +}; +/** + * Generates and returns the katex build tree, with just HTML (no MathML). + * This is used for advanced use cases (like rendering to custom output). + */ +var renderToHTMLTree = function renderToHTMLTree(expression, options) { + var settings = new Settings(options); + try { + var tree = parseTree(expression, settings); + return buildHTMLTree(tree, expression, settings); + } catch (error) { + return renderError(error, expression, settings); + } +}; +var version = "0.17.0"; +var __domTree = { + Span, + Anchor, + SymbolNode, + SvgNode, + PathNode, + LineNode +}; +// CJS exports and ESM default export +var katex = { + /** + * Current KaTeX version + */ + version, + /** + * Renders the given LaTeX into an HTML+MathML combination, and adds + * it as a child to the specified DOM node. + */ + render, + /** + * Renders the given LaTeX into an HTML+MathML combination string, + * for sending to the client. + */ + renderToString, + /** + * KaTeX error, usually during parsing. + */ + ParseError, + /** + * The schema of Settings + */ + SETTINGS_SCHEMA, + /** + * Parses the given LaTeX into KaTeX's internal parse tree structure, + * without rendering to HTML or MathML. + * + * NOTE: This method is not currently recommended for public use. + * The internal tree representation is unstable and is very likely + * to change. Use at your own risk. + */ + __parse: generateParseTree, + /** + * Renders the given LaTeX into an HTML+MathML internal DOM tree + * representation, without flattening that representation to a string. + * + * NOTE: This method is not currently recommended for public use. + * The internal tree representation is unstable and is very likely + * to change. Use at your own risk. + */ + __renderToDomTree: renderToDomTree, + /** + * Renders the given LaTeX into an HTML internal DOM tree representation, + * without MathML and without flattening that representation to a string. + * + * NOTE: This method is not currently recommended for public use. + * The internal tree representation is unstable and is very likely + * to change. Use at your own risk. + */ + __renderToHTMLTree: renderToHTMLTree, + /** + * extends internal font metrics object with a new object + * each key in the new object represents a font name + */ + __setFontMetrics: setFontMetrics, + /** + * adds a new symbol to builtin symbols table + */ + __defineSymbol: defineSymbol, + /** + * adds a new function to builtin function list, + * which directly produce parse tree elements + * and have their own html/mathml builders + */ + __defineFunction: defineFunction, + /** + * adds a new macro to builtin macro list + */ + __defineMacro: defineMacro, + /** + * Expose the dom tree node types, which can be useful for type checking nodes. + * + * NOTE: These methods are not currently recommended for public use. + * The internal tree representation is unstable and is very likely + * to change. Use at your own risk. + */ + __domTree +}; + +export { ParseError, SETTINGS_SCHEMA, defineFunction as __defineFunction, defineMacro as __defineMacro, defineSymbol as __defineSymbol, __domTree, generateParseTree as __parse, renderToDomTree as __renderToDomTree, renderToHTMLTree as __renderToHTMLTree, setFontMetrics as __setFontMetrics, katex as default, render, renderToString, version }; diff --git a/node_modules/katex/katex.ts b/node_modules/katex/katex.ts new file mode 100644 index 0000000..743134e --- /dev/null +++ b/node_modules/katex/katex.ts @@ -0,0 +1,250 @@ +/* eslint no-console:0 */ +/** + * This is the main entry point for KaTeX. Here, we expose functions for + * rendering expressions either to DOM nodes or to markup strings. + * + * We also expose the ParseError class to check if errors thrown from KaTeX are + * errors in the expression, or errors in javascript handling. + */ + +import ParseError from "./src/ParseError"; +import Settings, {SETTINGS_SCHEMA} from "./src/Settings"; + +import {buildTree, buildHTMLTree} from "./src/buildTree"; +import parseTree from "./src/parseTree"; +import {makeSpan} from "./src/buildCommon"; +import { + Span, + Anchor, + SymbolNode, + SvgNode, + PathNode, + LineNode, +} from "./src/domTree"; + +import type {SettingsOptions} from "./src/Settings"; +import type {AnyParseNode} from "./src/types/nodes"; +import type {DomSpan} from "./src/domTree"; + +import {defineSymbol} from './src/symbols'; +import defineFunction from './src/defineFunction'; +import defineMacro from './src/defineMacro'; +import {setFontMetrics} from './src/fontMetrics'; + +declare let __VERSION__: string; + +/** + * Parse and build an expression, and place that expression in the DOM node + * given. + */ +let render: ( + expression: string, + baseNode: Node, + options: SettingsOptions, +) => void = function( + expression: string, + baseNode: Node, + options: SettingsOptions, +) { + baseNode.textContent = ""; + const node = renderToDomTree(expression, options).toNode(); + baseNode.appendChild(node); +}; + +// KaTeX's styles don't work properly in quirks mode. Print out an error, and +// disable rendering. +if (typeof document !== "undefined") { + if (document.compatMode !== "CSS1Compat") { + typeof console !== "undefined" && console.warn( + "Warning: KaTeX doesn't work in quirks mode. Make sure your " + + "website has a suitable doctype."); + + render = function() { + throw new ParseError("KaTeX doesn't work in quirks mode."); + }; + } +} + +/** + * Parse and build an expression, and return the markup for that. + */ +const renderToString = function( + expression: string, + options: SettingsOptions, +): string { + const markup = renderToDomTree(expression, options).toMarkup(); + return markup; +}; + +/** + * Parse an expression and return the parse tree. + */ +const generateParseTree = function( + expression: string, + options?: SettingsOptions, +): AnyParseNode[] { + const settings = new Settings(options); + return parseTree(expression, settings); +}; + +/** + * If the given error is a KaTeX ParseError and options.throwOnError is false, + * renders the invalid LaTeX as a span with hover title giving the KaTeX + * error message. Otherwise, simply throws the error. + */ +const renderError = function( + error: unknown, + expression: string, + options: Settings, +) { + if (options.throwOnError || !(error instanceof ParseError)) { + throw error; + } + const node = makeSpan(["katex-error"], + [new SymbolNode(expression)]); + node.setAttribute("title", error.toString()); + node.setAttribute("style", `color:${options.errorColor}`); + return node; +}; + +/** + * Generates and returns the katex build tree. This is used for advanced + * use cases (like rendering to custom output). + */ +const renderToDomTree = function( + expression: string, + options: SettingsOptions, +): DomSpan { + const settings = new Settings(options); + try { + const tree = parseTree(expression, settings); + return buildTree(tree, expression, settings); + } catch (error) { + return renderError(error, expression, settings); + } +}; + +/** + * Generates and returns the katex build tree, with just HTML (no MathML). + * This is used for advanced use cases (like rendering to custom output). + */ +const renderToHTMLTree = function( + expression: string, + options: SettingsOptions, +): DomSpan { + const settings = new Settings(options); + try { + const tree = parseTree(expression, settings); + return buildHTMLTree(tree, expression, settings); + } catch (error) { + return renderError(error, expression, settings); + } +}; + +const version = __VERSION__; + +const __domTree = { + Span, + Anchor, + SymbolNode, + SvgNode, + PathNode, + LineNode, +}; + +// ESM exports +export { + version, + render, + renderToString, + ParseError, + SETTINGS_SCHEMA, + generateParseTree as __parse, + renderToDomTree as __renderToDomTree, + renderToHTMLTree as __renderToHTMLTree, + setFontMetrics as __setFontMetrics, + defineSymbol as __defineSymbol, + defineFunction as __defineFunction, + defineMacro as __defineMacro, + __domTree, +}; + +// CJS exports and ESM default export +export default { + /** + * Current KaTeX version + */ + version, + /** + * Renders the given LaTeX into an HTML+MathML combination, and adds + * it as a child to the specified DOM node. + */ + render, + /** + * Renders the given LaTeX into an HTML+MathML combination string, + * for sending to the client. + */ + renderToString, + /** + * KaTeX error, usually during parsing. + */ + ParseError, + /** + * The schema of Settings + */ + SETTINGS_SCHEMA, + /** + * Parses the given LaTeX into KaTeX's internal parse tree structure, + * without rendering to HTML or MathML. + * + * NOTE: This method is not currently recommended for public use. + * The internal tree representation is unstable and is very likely + * to change. Use at your own risk. + */ + __parse: generateParseTree, + /** + * Renders the given LaTeX into an HTML+MathML internal DOM tree + * representation, without flattening that representation to a string. + * + * NOTE: This method is not currently recommended for public use. + * The internal tree representation is unstable and is very likely + * to change. Use at your own risk. + */ + __renderToDomTree: renderToDomTree, + /** + * Renders the given LaTeX into an HTML internal DOM tree representation, + * without MathML and without flattening that representation to a string. + * + * NOTE: This method is not currently recommended for public use. + * The internal tree representation is unstable and is very likely + * to change. Use at your own risk. + */ + __renderToHTMLTree: renderToHTMLTree, + /** + * extends internal font metrics object with a new object + * each key in the new object represents a font name + */ + __setFontMetrics: setFontMetrics, + /** + * adds a new symbol to builtin symbols table + */ + __defineSymbol: defineSymbol, + /** + * adds a new function to builtin function list, + * which directly produce parse tree elements + * and have their own html/mathml builders + */ + __defineFunction: defineFunction, + /** + * adds a new macro to builtin macro list + */ + __defineMacro: defineMacro, + /** + * Expose the dom tree node types, which can be useful for type checking nodes. + * + * NOTE: These methods are not currently recommended for public use. + * The internal tree representation is unstable and is very likely + * to change. Use at your own risk. + */ + __domTree, +}; diff --git a/node_modules/katex/package.json b/node_modules/katex/package.json new file mode 100644 index 0000000..c79d7c7 --- /dev/null +++ b/node_modules/katex/package.json @@ -0,0 +1,198 @@ +{ + "name": "katex", + "version": "0.17.0", + "description": "Fast math typesetting for the web.", + "main": "dist/katex.js", + "types": "types/katex.d.ts", + "exports": { + ".": { + "require": { + "types": "./types/katex.d.ts", + "default": "./dist/katex.js" + }, + "import": { + "types": "./types/katex.d.ts", + "default": "./dist/katex.mjs" + } + }, + "./contrib/auto-render": { + "require": "./dist/contrib/auto-render.js", + "import": "./dist/contrib/auto-render.mjs" + }, + "./contrib/mhchem": { + "require": "./dist/contrib/mhchem.js", + "import": "./dist/contrib/mhchem.mjs" + }, + "./contrib/copy-tex": { + "require": "./dist/contrib/copy-tex.js", + "import": "./dist/contrib/copy-tex.mjs" + }, + "./contrib/mathtex-script-type": { + "require": "./dist/contrib/mathtex-script-type.js", + "import": "./dist/contrib/mathtex-script-type.mjs" + }, + "./contrib/render-a11y-string": { + "require": "./dist/contrib/render-a11y-string.js", + "import": "./dist/contrib/render-a11y-string.mjs" + }, + "./*": "./*" + }, + "homepage": "https://katex.org", + "repository": { + "type": "git", + "url": "https://github.com/KaTeX/KaTeX.git" + }, + "funding": [ + "https://opencollective.com/katex", + "https://github.com/sponsors/katex" + ], + "files": [ + "katex.ts", + "cli.js", + "src/", + "contrib/", + "dist/", + "types/" + ], + "license": "MIT", + "packageManager": "yarn@4.1.1", + "devDependencies": { + "@babel/core": "^7.29.0", + "@babel/plugin-proposal-class-properties": "^7.18.6", + "@babel/plugin-transform-react-jsx": "^7.28.6", + "@babel/plugin-transform-runtime": "^7.29.0", + "@babel/preset-env": "^7.29.0", + "@babel/preset-react": "^7.28.5", + "@babel/preset-typescript": "^7.28.5", + "@babel/register": "^7.28.6", + "@babel/runtime": "^7.28.6", + "@eslint/eslintrc": "^3.3.5", + "@eslint/js": "^10.0.1", + "@rollup/plugin-babel": "^5.3.1", + "@rollup/plugin-commonjs": "^28.0.9", + "@rollup/plugin-typescript": "^12.3.0", + "@semantic-release/changelog": "^6.0.1", + "@semantic-release/git": "^10.0.1", + "@stylistic/stylelint-plugin": "^5.1.0", + "@typescript-eslint/eslint-plugin": "^8.59.1", + "@typescript-eslint/parser": "^8.59.1", + "babel-jest": "^30.2.0", + "babel-loader": "^8.2.5", + "babel-plugin-istanbul": "^6.1.1", + "babel-plugin-preval": "^5.1.0", + "babel-plugin-version-inline": "^1.0.0", + "benchmark": "^2.1.4", + "browserslist": "^4.21.3", + "caniuse-lite": "^1.0.30001384", + "css-loader": "^6.7.1", + "cssnano": "^5.1.13", + "eslint": "^10.0.3", + "eslint-plugin-actions": "^2.0.0", + "eslint-plugin-react": "^7.37.5", + "fs-extra": "^10.1.0", + "globals": "^17.6.0", + "got": "^11.8.5", + "husky": "^4.3.8", + "istanbul-lib-coverage": "^3.2.0", + "istanbul-lib-report": "^3.0.0", + "istanbul-reports": "^3.1.5", + "jest": "^30.2.0", + "jest-diff": "^30.2.0", + "jest-environment-jsdom": "^30.2.0", + "jest-matcher-utils": "^30.2.0", + "jest-message-util": "^30.2.0", + "jest-serializer-html": "^7.1.0", + "js-yaml": "^4.1.0", + "json-stable-stringify": "^1.0.1", + "jspngopt": "^0.2.0", + "mini-css-extract-plugin": "^2.6.1", + "mkdirp": "^1.0.4", + "p-retry": "^4.6.2", + "pako": "^2.0.4", + "postcss": "^8.4.16", + "postcss-loader": "^7.0.1", + "postcss-preset-env": "^7.8.0", + "postcss-scss": "^4.0.9", + "rimraf": "^3.0.2", + "rollup": "^2.79.2", + "sass": "^1.94.2", + "sass-loader": "^16.0.6", + "selenium-webdriver": "^4.4.0", + "semantic-release": "^19.0.5", + "sri-toolbox": "^0.2.0", + "style-loader": "^3.3.1", + "stylelint": "^17.9.1", + "stylelint-config-standard": "^40.0.0", + "stylelint-scss": "^7.0.0", + "terser-webpack-plugin": "^5.3.6", + "tslib": "^2.8.1", + "typescript": "^5.9.3", + "webpack": "^5.74.0", + "webpack-bundle-analyzer": "^5.0.0", + "webpack-cli": "^5.0.0", + "webpack-dev-server": "^5.0.0", + "webpack-remove-empty-scripts": "^1.0.4" + }, + "bin": "cli.js", + "scripts": { + "test": "yarn test:lint && yarn test:ts && yarn test:jest", + "test:lint": "yarn test:lint:js && yarn test:lint:css", + "test:lint:js": "eslint .", + "test:lint:css": "stylelint src/styles/katex.scss static/main.css website/static/**/*.css", + "test:jest": "jest", + "test:jest:watch": "jest --watch", + "test:jest:update": "jest --updateSnapshot", + "test:jest:coverage": "jest --coverage", + "test:screenshots": "yarn test:screenshots:update --verify", + "test:screenshots:update": "dockers/screenshotter/screenshotter.sh", + "test:perf": "NODE_ENV=test node -e \"require('@babel/register')({extensions:['.js','.ts']}); require('./test/perf-test.ts')\"", + "test:ts": "tsc --noEmit", + "test:build": "node test/verify-build.js", + "clean": "rm -rf dist/ node_modules/", + "clean-install": "yarn clean && yarn", + "start": "webpack serve --config webpack.dev.js", + "analyze": "webpack --config webpack.analyze.js", + "build": "rimraf dist/ && mkdirp dist && cp README.md dist && rollup -c --failAfterWarnings && webpack && node update-sri.js package dist/README.md", + "build:fonts": "dockers/fonts/buildFonts.sh", + "build:metrics": "dockers/fonts/buildMetrics.sh", + "watch": "yarn build --watch", + "postversion": "yarn dist && node update-sri.js package README.md contrib/*/README.md docs/*.md website/pages/index.html", + "semantic-release": "semantic-release", + "dist": "yarn build && yarn dist:zip", + "dist:zip": "rimraf katex/ katex.tar.gz katex.zip && cp -R dist katex && tar czf katex.tar.gz katex && zip -rq katex.zip katex && rimraf katex/" + }, + "dependencies": { + "commander": "^8.3.0" + }, + "husky": { + "hooks": { + "pre-commit": "yarn test:lint" + } + }, + "jest": { + "collectCoverageFrom": [ + "src/**/*.{js,ts}", + "contrib/**/*.{js,ts}", + "!src/unicodeSymbols.{js,ts}", + "!contrib/mhchem/**" + ], + "setupFilesAfterEnv": [ + "/test/setup.ts" + ], + "snapshotSerializers": [ + "jest-serializer-html" + ], + "testMatch": [ + "**/test/*-spec.ts" + ], + "testEnvironmentOptions": { + "url": "http://localhost/" + }, + "transform": { + "^.+\\.(js|ts)$": "babel-jest" + }, + "moduleNameMapper": { + "^katex$": "/katex.ts" + } + } +} diff --git a/node_modules/katex/src/Lexer.ts b/node_modules/katex/src/Lexer.ts new file mode 100644 index 0000000..ad3ac38 --- /dev/null +++ b/node_modules/katex/src/Lexer.ts @@ -0,0 +1,121 @@ +/** + * The Lexer class handles tokenizing the input in various ways. Since our + * parser expects us to be able to backtrack, the lexer allows lexing from any + * given starting point. + * + * Its main exposed function is the `lex` function, which takes a position to + * lex from and a type of token to lex. It defers to the appropriate `_innerLex` + * function. + * + * The various `_innerLex` functions perform the actual lexing of different + * kinds. + */ + +import ParseError from "./ParseError"; +import SourceLocation from "./SourceLocation"; +import {Token} from "./Token"; + +import type {LexerInterface} from "./Token"; +import type Settings from "./Settings"; + +/* The following tokenRegex + * - matches typical whitespace (but not NBSP etc.) using its first group + * - does not match any control character \x00-\x1f except whitespace + * - does not match a bare backslash + * - matches any ASCII character except those just mentioned + * - does not match the BMP private use area \uE000-\uF8FF + * - does not match bare surrogate code units + * - matches any BMP character except for those just described + * - matches any valid Unicode surrogate pair + * - matches a backslash followed by one or more whitespace characters + * - matches a backslash followed by one or more letters then whitespace + * - matches a backslash followed by any BMP character + * Capturing groups: + * [1] regular whitespace + * [2] backslash followed by whitespace + * [3] anything else, which may include: + * [4] left character of \verb* + * [5] left character of \verb + * [6] backslash followed by word, excluding any trailing whitespace + * Just because the Lexer matches something doesn't mean it's valid input: + * If there is no matching function or symbol definition, the Parser will + * still reject the input. + */ +const spaceRegexString = "[ \r\n\t]"; +const controlWordRegexString = "\\\\[a-zA-Z@]+"; +const controlSymbolRegexString = "\\\\[^\uD800-\uDFFF]"; +const controlWordWhitespaceRegexString = + `(${controlWordRegexString})${spaceRegexString}*`; +const controlSpaceRegexString = "\\\\(\n|[ \r\t]+\n?)[ \r\t]*"; +const combiningDiacriticalMarkString = "[\u0300-\u036f]"; +export const combiningDiacriticalMarksEndRegex: RegExp = + new RegExp(`${combiningDiacriticalMarkString}+$`); +const tokenRegexString = `(${spaceRegexString}+)|` + // whitespace + `${controlSpaceRegexString}|` + // \whitespace + "([!-\\[\\]-\u2027\u202A-\uD7FF\uF900-\uFFFF]" + // single codepoint + `${combiningDiacriticalMarkString}*` + // ...plus accents + "|[\uD800-\uDBFF][\uDC00-\uDFFF]" + // surrogate pair + `${combiningDiacriticalMarkString}*` + // ...plus accents + "|\\\\verb\\*([^]).*?\\4" + // \verb* + "|\\\\verb([^*a-zA-Z]).*?\\5" + // \verb unstarred + `|${controlWordWhitespaceRegexString}` + // \macroName + spaces + `|${controlSymbolRegexString})`; // \\, \', etc. + +/** Main Lexer class */ +export default class Lexer implements LexerInterface { + input: string; + settings: Settings; + tokenRegex: RegExp; + // Category codes. The lexer only supports comment characters (14) for now. + // MacroExpander additionally distinguishes active (13). + catcodes: Record; + + constructor(input: string, settings: Settings) { + // Separate accents from characters + this.input = input; + this.settings = settings; + this.tokenRegex = new RegExp(tokenRegexString, 'g'); + this.catcodes = { + "%": 14, // comment character + "~": 13, // active character + }; + } + + setCatcode(char: string, code: number) { + this.catcodes[char] = code; + } + + /** + * This function lexes a single token. + */ + lex(): Token { + const input = this.input; + const pos = this.tokenRegex.lastIndex; + if (pos === input.length) { + return new Token("EOF", new SourceLocation(this, pos, pos)); + } + const match = this.tokenRegex.exec(input); + if (match === null || match.index !== pos) { + throw new ParseError( + `Unexpected character: '${input[pos]}'`, + new Token(input[pos], new SourceLocation(this, pos, pos + 1))); + } + const text = match[6] || match[3] || (match[2] ? "\\ " : " "); + + if (this.catcodes[text] === 14) { // comment character + const nlIndex = input.indexOf('\n', this.tokenRegex.lastIndex); + if (nlIndex === -1) { + this.tokenRegex.lastIndex = input.length; // EOF + this.settings.reportNonstrict("commentAtEnd", + "% comment has no terminating newline; LaTeX would " + + "fail because of commenting the end of math mode (e.g. $)"); + } else { + this.tokenRegex.lastIndex = nlIndex + 1; + } + return this.lex(); + } + + return new Token(text, new SourceLocation(this, pos, + this.tokenRegex.lastIndex)); + } +} diff --git a/node_modules/katex/src/MacroExpander.ts b/node_modules/katex/src/MacroExpander.ts new file mode 100644 index 0000000..309a512 --- /dev/null +++ b/node_modules/katex/src/MacroExpander.ts @@ -0,0 +1,467 @@ +/** + * This file contains the “gullet” where macros are expanded + * until only non-macro tokens remain. + */ + +import functions from "./functions"; +import symbols from "./symbols"; +import Lexer from "./Lexer"; +import {Token} from "./Token"; +import type {Mode} from "./types"; +import ParseError from "./ParseError"; +import SourceLocation from "./SourceLocation"; +import Namespace from "./Namespace"; +import macros from "./macros"; + +import type {MacroContextInterface, MacroDefinition, MacroExpansion, MacroArg} + from "./defineMacro"; +import type Settings from "./Settings"; + +// List of commands that act like macros but aren't defined as a macro, +// function, or symbol. Used in `isDefined`. +export const implicitCommands = { + "^": true, // Parser.js + "_": true, // Parser.js + "\\limits": true, // Parser.js + "\\nolimits": true, // Parser.js +}; + +export default class MacroExpander implements MacroContextInterface { + settings: Settings; + expansionCount: number; + lexer!: Lexer; + macros: Namespace; + stack: Token[]; + mode: Mode; + + constructor(input: string, settings: Settings, mode: Mode) { + this.settings = settings; + this.expansionCount = 0; + this.feed(input); + // Make new global namespace + this.macros = new Namespace(macros, settings.macros); + this.mode = mode; + this.stack = []; // contains tokens in REVERSE order + } + + /** + * Feed a new input string to the same MacroExpander + * (with existing macros etc.). + */ + feed(input: string) { + this.lexer = new Lexer(input, this.settings); + } + + /** + * Switches between "text" and "math" modes. + */ + switchMode(newMode: Mode) { + this.mode = newMode; + } + + /** + * Start a new group nesting within all namespaces. + */ + beginGroup() { + this.macros.beginGroup(); + } + + /** + * End current group nesting within all namespaces. + */ + endGroup() { + this.macros.endGroup(); + } + + /** + * Ends all currently nested groups (if any), restoring values before the + * groups began. Useful in case of an error in the middle of parsing. + */ + endGroups() { + this.macros.endGroups(); + } + + /** + * Returns the topmost token on the stack, without expanding it. + * Similar in behavior to TeX's `\futurelet`. + */ + future(): Token { + if (this.stack.length === 0) { + this.pushToken(this.lexer.lex()); + } + return this.stack[this.stack.length - 1]; + } + + /** + * Remove and return the next unexpanded token. + */ + popToken(): Token { + this.future(); // ensure non-empty stack + return this.stack.pop()!; + } + + /** + * Add a given token to the token stack. In particular, this get be used + * to put back a token returned from one of the other methods. + */ + pushToken(token: Token) { + this.stack.push(token); + } + + /** + * Append an array of tokens to the token stack. + */ + pushTokens(tokens: Token[]) { + this.stack.push(...tokens); + } + + /** + * Find an macro argument without expanding tokens and append the array of + * tokens to the token stack. Uses Token as a container for the result. + */ + scanArgument(isOptional: boolean): Token | null { + let start; + let end; + let tokens; + if (isOptional) { + this.consumeSpaces(); // \@ifnextchar gobbles any space following it + if (this.future().text !== "[") { + return null; + } + start = this.popToken(); // don't include [ in tokens + ({tokens, end} = this.consumeArg(["]"])); + } else { + ({tokens, start, end} = this.consumeArg()); + } + + // indicate the end of an argument + this.pushToken(new Token("EOF", end.loc)); + + this.pushTokens(tokens); + return new Token("", SourceLocation.range(start, end)); + } + + /** + * Consume all following space tokens, without expansion. + */ + consumeSpaces() { + for (;;) { + const token = this.future(); + if (token.text === " ") { + this.stack.pop(); + } else { + break; + } + } + } + + /** + * Consume an argument from the token stream, and return the resulting array + * of tokens and start/end token. + */ + consumeArg(delims?: string[] | null | undefined): MacroArg { + // The argument for a delimited parameter is the shortest (possibly + // empty) sequence of tokens with properly nested {...} groups that is + // followed ... by this particular list of non-parameter tokens. + // The argument for an undelimited parameter is the next nonblank + // token, unless that token is ‘{’, when the argument will be the + // entire {...} group that follows. + const tokens: Token[] = []; + const isDelimited = delims && delims.length > 0; + if (!isDelimited) { + // Ignore spaces between arguments. As the TeXbook says: + // "After you have said ‘\def\row#1#2{...}’, you are allowed to + // put spaces between the arguments (e.g., ‘\row x n’), because + // TeX doesn’t use single spaces as undelimited arguments." + this.consumeSpaces(); + } + const start = this.future(); + let tok; + let depth = 0; + let match = 0; + do { + tok = this.popToken(); + tokens.push(tok); + if (tok.text === "{") { + ++depth; + } else if (tok.text === "}") { + --depth; + if (depth === -1) { + throw new ParseError("Extra }", tok); + } + } else if (tok.text === "EOF") { + throw new ParseError("Unexpected end of input in a macro argument" + + ", expected '" + (delims && isDelimited ? delims[match] : "}") + + "'", tok); + } + if (delims && isDelimited) { + if ((depth === 0 || (depth === 1 && delims[match] === "{")) && + tok.text === delims[match]) { + ++match; + if (match === delims.length) { + // don't include delims in tokens + tokens.splice(-match, match); + break; + } + } else { + match = 0; + } + } + } while (depth !== 0 || isDelimited); + // If the argument found ... has the form ‘{}’, + // ... the outermost braces enclosing the argument are removed + if (start.text === "{" && tokens[tokens.length - 1].text === "}") { + tokens.pop(); + tokens.shift(); + } + tokens.reverse(); // to fit in with stack order + return {tokens, start, end: tok}; + } + + /** + * Consume the specified number of (delimited) arguments from the token + * stream and return the resulting array of arguments. + */ + consumeArgs(numArgs: number, delimiters?: string[][]): Token[][] { + if (delimiters) { + if (delimiters.length !== numArgs + 1) { + throw new ParseError( + "The length of delimiters doesn't match the number of args!"); + } + const delims = delimiters[0]; + for (let i = 0; i < delims.length; i++) { + const tok = this.popToken(); + if (delims[i] !== tok.text) { + throw new ParseError( + "Use of the macro doesn't match its definition", tok); + } + } + } + + const args: Token[][] = []; + for (let i = 0; i < numArgs; i++) { + args.push(this.consumeArg(delimiters && delimiters[i + 1]).tokens); + } + return args; + } + + /** + * Increment `expansionCount` by the specified amount. + * Throw an error if it exceeds `maxExpand`. + */ + countExpansion(amount: number): void { + this.expansionCount += amount; + if (this.expansionCount > this.settings.maxExpand) { + throw new ParseError("Too many expansions: infinite loop or " + + "need to increase maxExpand setting"); + } + } + + /** + * Expand the next token only once if possible. + * + * If the token is expanded, the resulting tokens will be pushed onto + * the stack in reverse order, and the number of such tokens will be + * returned. This number might be zero or positive. + * + * If not, the return value is `false`, and the next token remains at the + * top of the stack. + * + * In either case, the next token will be on the top of the stack, + * or the stack will be empty (in case of empty expansion + * and no other tokens). + * + * Used to implement `expandAfterFuture` and `expandNextToken`. + * + * If expandableOnly, only expandable tokens are expanded and + * an undefined control sequence results in an error. + */ + expandOnce(expandableOnly?: boolean): number | boolean { + const topToken = this.popToken(); + const name = topToken.text; + const expansion = !topToken.noexpand ? this._getExpansion(name) : null; + if (expansion == null || (expandableOnly && expansion.unexpandable)) { + if (expandableOnly && expansion == null && + name[0] === "\\" && !this.isDefined(name)) { + throw new ParseError("Undefined control sequence: " + name); + } + this.pushToken(topToken); + return false; + } + this.countExpansion(1); + let tokens = expansion.tokens; + const args = this.consumeArgs(expansion.numArgs, expansion.delimiters); + if (expansion.numArgs) { + // paste arguments in place of the placeholders + tokens = tokens.slice(); // make a shallow copy + for (let i = tokens.length - 1; i >= 0; --i) { + let tok = tokens[i]; + if (tok.text === "#") { + if (i === 0) { + throw new ParseError( + "Incomplete placeholder at end of macro body", + tok); + } + tok = tokens[--i]; // next token on stack + if (tok.text === "#") { // ## → # + tokens.splice(i + 1, 1); // drop first # + } else if (/^[1-9]$/.test(tok.text)) { + // replace the placeholder with the indicated argument + tokens.splice(i, 2, ...args[+tok.text - 1]); + } else { + throw new ParseError( + "Not a valid argument number", + tok); + } + } + } + } + // Concatenate expansion onto top of stack. + this.pushTokens(tokens); + return tokens.length; + } + + /** + * Expand the next token only once (if possible), and return the resulting + * top token on the stack (without removing anything from the stack). + * Similar in behavior to TeX's `\expandafter\futurelet`. + * Equivalent to expandOnce() followed by future(). + */ + expandAfterFuture(): Token { + this.expandOnce(); + return this.future(); + } + + /** + * Recursively expand first token, then return first non-expandable token. + */ + expandNextToken(): Token { + for (;;) { + if (this.expandOnce() === false) { // fully expanded + const token = this.stack.pop()!; + // the token after \noexpand is interpreted as if its meaning + // were ‘\relax’ + if (token.treatAsRelax) { + token.text = "\\relax"; + } + return token; + } + } + } + + /** + * Fully expand the given macro name and return the resulting list of + * tokens, or return `undefined` if no such macro is defined. + */ + expandMacro(name: string): Token[] | undefined { + return this.macros.has(name) + ? this.expandTokens([new Token(name)]) : undefined; + } + + /** + * Fully expand the given token stream and return the resulting list of + * tokens. Note that the input tokens are in reverse order, but the + * output tokens are in forward order. + */ + expandTokens(tokens: Token[]): Token[] { + const output: Token[] = []; + const oldStackLength = this.stack.length; + this.pushTokens(tokens); + while (this.stack.length > oldStackLength) { + // Expand only expandable tokens + if (this.expandOnce(true) === false) { // fully expanded + const token = this.stack.pop()!; + if (token.treatAsRelax) { + // the expansion of \noexpand is the token itself + token.noexpand = false; + token.treatAsRelax = false; + } + output.push(token); + } + } + // Count all of these tokens as additional expansions, to prevent + // exponential blowup from linearly many \edef's. + this.countExpansion(output.length); + return output; + } + + /** + * Fully expand the given macro name and return the result as a string, + * or return `undefined` if no such macro is defined. + */ + expandMacroAsText(name: string): string | undefined { + const tokens = this.expandMacro(name); + if (tokens) { + return tokens.map((token) => token.text).join(""); + } else { + return tokens; + } + } + + /** + * Returns the expanded macro as a reversed array of tokens and a macro + * argument count. Or returns `null` if no such macro. + */ + _getExpansion(name: string): MacroExpansion | null | undefined { + const definition = this.macros.get(name); + + if (definition == null) { // mainly checking for undefined here + return definition; + } + // If a single character has an associated catcode other than 13 + // (active character), then don't expand it. + if (name.length === 1) { + const catcode = this.lexer.catcodes[name]; + if (catcode != null && catcode !== 13) { + return; + } + } + const expansion = + typeof definition === "function" ? definition(this) : definition; + if (typeof expansion === "string") { + let numArgs = 0; + if (expansion.includes("#")) { + const stripped = expansion.replace(/##/g, ""); + while (stripped.includes("#" + (numArgs + 1))) { + ++numArgs; + } + } + const bodyLexer = new Lexer(expansion, this.settings); + const tokens = []; + let tok = bodyLexer.lex(); + while (tok.text !== "EOF") { + tokens.push(tok); + tok = bodyLexer.lex(); + } + tokens.reverse(); // to fit in with stack using push and pop + const expanded = {tokens, numArgs}; + return expanded; + } + + return expansion; + } + + /** + * Determine whether a command is currently "defined" (has some + * functionality), meaning that it's a macro (in the current group), + * a function, a symbol, or one of the special commands listed in + * `implicitCommands`. + */ + isDefined(name: string): boolean { + return this.macros.has(name) || + functions.hasOwnProperty(name) || + symbols.math.hasOwnProperty(name) || + symbols.text.hasOwnProperty(name) || + implicitCommands.hasOwnProperty(name); + } + + /** + * Determine whether a command is expandable. + */ + isExpandable(name: string): boolean { + const macro = this.macros.get(name); + return macro != null ? typeof macro === "string" + || typeof macro === "function" || !macro.unexpandable + : functions.hasOwnProperty(name) && !functions[name].primitive; + } +} diff --git a/node_modules/katex/src/Namespace.ts b/node_modules/katex/src/Namespace.ts new file mode 100644 index 0000000..4d5d9f0 --- /dev/null +++ b/node_modules/katex/src/Namespace.ts @@ -0,0 +1,127 @@ + +/** + * A `Namespace` refers to a space of nameable things like macros or lengths, + * which can be `set` either globally or local to a nested group, using an + * undo stack similar to how TeX implements this functionality. + * Performance-wise, `get` and local `set` take constant time, while global + * `set` takes time proportional to the depth of group nesting. + */ + +import ParseError from "./ParseError"; +export type Mapping = Record; + +export default class Namespace { + current: Mapping; + builtins: Mapping; + undefStack: Mapping[]; + + /** + * Both arguments are optional. The first argument is an object of + * built-in mappings which never change. The second argument is an object + * of initial (global-level) mappings, which will constantly change + * according to any global/top-level `set`s done. + */ + constructor(builtins: Mapping = {}, + globalMacros: Mapping = {}) { + this.current = globalMacros; + this.builtins = builtins; + this.undefStack = []; + } + + /** + * Start a new nested group, affecting future local `set`s. + */ + beginGroup() { + this.undefStack.push({}); + } + + /** + * End current nested group, restoring values before the group began. + */ + endGroup() { + if (this.undefStack.length === 0) { + throw new ParseError("Unbalanced namespace destruction: attempt " + + "to pop global namespace; please report this as a bug"); + } + const undefs = this.undefStack.pop(); + for (const undef in undefs) { + if (undefs.hasOwnProperty(undef)) { + if (undefs[undef] == null) { + delete this.current[undef]; + } else { + this.current[undef] = undefs[undef]; + } + } + } + } + + /** + * Ends all currently nested groups (if any), restoring values before the + * groups began. Useful in case of an error in the middle of parsing. + */ + endGroups() { + while (this.undefStack.length > 0) { + this.endGroup(); + } + } + + /** + * Detect whether `name` has a definition. Equivalent to + * `get(name) != null`. + */ + has(name: string): boolean { + return this.current.hasOwnProperty(name) || + this.builtins.hasOwnProperty(name); + } + + /** + * Get the current value of a name, or `undefined` if there is no value. + * + * Note: Do not use `if (namespace.get(...))` to detect whether a macro + * is defined, as the definition may be the empty string which evaluates + * to `false` in JavaScript. Use `if (namespace.get(...) != null)` or + * `if (namespace.has(...))`. + */ + get(name: string): Value | undefined { + if (this.current.hasOwnProperty(name)) { + return this.current[name]; + } else { + return this.builtins[name]; + } + } + + /** + * Set the current value of a name, and optionally set it globally too. + * Local set() sets the current value and (when appropriate) adds an undo + * operation to the undo stack. Global set() may change the undo + * operation at every level, so takes time linear in their number. + * A value of undefined means to delete existing definitions. + */ + set(name: string, value: Value | null | undefined, global: boolean = false) { + if (global) { + // Global set is equivalent to setting in all groups. Simulate this + // by destroying any undos currently scheduled for this name, + // and adding an undo with the *new* value (in case it later gets + // locally reset within this environment). + for (let i = 0; i < this.undefStack.length; i++) { + delete this.undefStack[i][name]; + } + if (this.undefStack.length > 0) { + this.undefStack[this.undefStack.length - 1][name] = value; + } + } else { + // Undo this set at end of this group (possibly to `undefined`), + // unless an undo is already in place, in which case that older + // value is the correct one. + const top = this.undefStack[this.undefStack.length - 1]; + if (top && !top.hasOwnProperty(name)) { + top[name] = this.current[name]; + } + } + if (value == null) { + delete this.current[name]; + } else { + this.current[name] = value; + } + } +} diff --git a/node_modules/katex/src/Options.ts b/node_modules/katex/src/Options.ts new file mode 100644 index 0000000..5a54af8 --- /dev/null +++ b/node_modules/katex/src/Options.ts @@ -0,0 +1,315 @@ +/** + * This file contains information about the options that the Parser carries + * around with it while parsing. Data is held in an `Options` object, and when + * recursing, a new `Options` object can be created with the `.with*` and + * `.reset` functions. + */ + +import {getGlobalMetrics} from "./fontMetrics"; +import type {StyleInterface} from "./Style"; +import type {FontMetrics, MathFont, TextFont, FontWeight, FontShape} from "./types/fonts"; + +const sizeStyleMap = [ + // Each element contains [textsize, scriptsize, scriptscriptsize]. + // The size mappings are taken from TeX with \normalsize=10pt. + [1, 1, 1], // size1: [5, 5, 5] \tiny + [2, 1, 1], // size2: [6, 5, 5] + [3, 1, 1], // size3: [7, 5, 5] \scriptsize + [4, 2, 1], // size4: [8, 6, 5] \footnotesize + [5, 2, 1], // size5: [9, 6, 5] \small + [6, 3, 1], // size6: [10, 7, 5] \normalsize + [7, 4, 2], // size7: [12, 8, 6] \large + [8, 6, 3], // size8: [14.4, 10, 7] \Large + [9, 7, 6], // size9: [17.28, 12, 10] \LARGE + [10, 8, 7], // size10: [20.74, 14.4, 12] \huge + [11, 10, 9], // size11: [24.88, 20.74, 17.28] \HUGE +]; + +const sizeMultipliers = [ + // fontMetrics.js:getGlobalMetrics also uses size indexes, so if + // you change size indexes, change that function. + 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.2, 1.44, 1.728, 2.074, 2.488, +]; + +const sizeAtStyle = function(size: number, style: StyleInterface): number { + return style.size < 2 ? size : sizeStyleMap[size - 1][style.size - 1]; +}; + +export type OptionsData = { + style: StyleInterface; + color?: string | undefined; + size?: number; + textSize?: number; + phantom?: boolean; + font?: MathFont; + fontFamily?: TextFont; + fontWeight?: FontWeight; + fontShape?: FontShape; + sizeMultiplier?: number; + maxSize: number; + minRuleThickness: number; +}; + +/** + * This is the main options class. It contains the current style, size, color, + * and font. + * + * Options objects should not be modified. To create a new Options with + * different properties, call a `.having*` method. + */ +class Options { + style: StyleInterface; + color: string | undefined; + size: number; + textSize: number; + phantom: boolean; + // A font family applies to a group of fonts (i.e. SansSerif), while a font + // represents a specific font (i.e. SansSerif Bold). + // See: https://tex.stackexchange.com/questions/22350/difference-between-textrm-and-mathrm + font: MathFont; + fontFamily: TextFont; + fontWeight: FontWeight; + fontShape: FontShape; + sizeMultiplier: number; + maxSize: number; + minRuleThickness: number; + _fontMetrics: FontMetrics | undefined; + + /** + * The base size index. + */ + static BASESIZE: number = 6; + + constructor(data: OptionsData) { + this.style = data.style; + this.color = data.color; + this.size = data.size || Options.BASESIZE; + this.textSize = data.textSize || this.size; + this.phantom = !!data.phantom; + this.font = data.font || ""; + this.fontFamily = data.fontFamily || ""; + this.fontWeight = data.fontWeight || ""; + this.fontShape = data.fontShape || ""; + this.sizeMultiplier = sizeMultipliers[this.size - 1]; + this.maxSize = data.maxSize; + this.minRuleThickness = data.minRuleThickness; + this._fontMetrics = undefined; + } + + /** + * Returns a new options object with the same properties as "this". Properties + * from "extension" will be copied to the new options object. + */ + extend(extension: Partial): Options { + const data: OptionsData = { + style: this.style, + size: this.size, + textSize: this.textSize, + color: this.color, + phantom: this.phantom, + font: this.font, + fontFamily: this.fontFamily, + fontWeight: this.fontWeight, + fontShape: this.fontShape, + maxSize: this.maxSize, + minRuleThickness: this.minRuleThickness, + }; + + Object.assign(data, extension); + + return new Options(data); + } + + /** + * Return an options object with the given style. If `this.style === style`, + * returns `this`. + */ + havingStyle(style: StyleInterface): Options { + if (this.style === style) { + return this; + } else { + return this.extend({ + style: style, + size: sizeAtStyle(this.textSize, style), + }); + } + } + + /** + * Return an options object with a cramped version of the current style. If + * the current style is cramped, returns `this`. + */ + havingCrampedStyle(): Options { + return this.havingStyle(this.style.cramp()); + } + + /** + * Return an options object with the given size and in at least `\textstyle`. + * Returns `this` if appropriate. + */ + havingSize(size: number): Options { + if (this.size === size && this.textSize === size) { + return this; + } else { + return this.extend({ + style: this.style.text(), + size: size, + textSize: size, + sizeMultiplier: sizeMultipliers[size - 1], + }); + } + } + + /** + * Like `this.havingSize(BASESIZE).havingStyle(style)`. If `style` is omitted, + * changes to at least `\textstyle`. + */ + havingBaseStyle(style: StyleInterface): Options { + style = style || this.style.text(); + const wantSize = sizeAtStyle(Options.BASESIZE, style); + if ( + this.size === wantSize && + this.textSize === Options.BASESIZE && + this.style === style + ) { + return this; + } else { + return this.extend({ + style: style, + size: wantSize, + }); + } + } + + /** + * Remove the effect of sizing changes such as \Huge. + * Keep the effect of the current style, such as \scriptstyle. + */ + havingBaseSizing(): Options { + let size; + switch (this.style.id) { + case 4: + case 5: + size = 3; // normalsize in scriptstyle + break; + case 6: + case 7: + size = 1; // normalsize in scriptscriptstyle + break; + default: + size = 6; // normalsize in textstyle or displaystyle + } + return this.extend({ + style: this.style.text(), + size: size, + }); + } + + /** + * Create a new options object with the given color. + */ + withColor(color: string): Options { + return this.extend({ + color: color, + }); + } + + /** + * Create a new options object with "phantom" set to true. + */ + withPhantom(): Options { + return this.extend({ + phantom: true, + }); + } + + /** + * Creates a new options object with the given math font or old text font. + * @type {[type]} + */ + withFont(font: MathFont): Options { + return this.extend({font}); + } + + /** + * Create a new options objects with the given fontFamily. + */ + withTextFontFamily(fontFamily: TextFont): Options { + return this.extend({fontFamily, font: ""}); + } + + /** + * Creates a new options object with the given font weight + */ + withTextFontWeight(fontWeight: FontWeight): Options { + return this.extend({ + fontWeight, + font: "", + }); + } + + /** + * Creates a new options object with the given font weight + */ + withTextFontShape(fontShape: FontShape): Options { + return this.extend({ + fontShape, + font: "", + }); + } + + /** + * Return the CSS sizing classes required to switch from enclosing options + * `oldOptions` to `this`. Returns an array of classes. + */ + sizingClasses(oldOptions: Options): Array { + if (oldOptions.size !== this.size) { + return [ + "sizing", + "reset-size" + oldOptions.size, + "size" + this.size, + ]; + } else { + return []; + } + } + + /** + * Return the CSS sizing classes required to switch to the base size. Like + * `this.havingSize(BASESIZE).sizingClasses(this)`. + */ + baseSizingClasses(): Array { + if (this.size !== Options.BASESIZE) { + return [ + "sizing", + "reset-size" + this.size, + "size" + Options.BASESIZE, + ]; + } else { + return []; + } + } + + /** + * Return the font metrics for this size. + */ + fontMetrics(): FontMetrics { + if (!this._fontMetrics) { + this._fontMetrics = getGlobalMetrics(this.size); + } + return this._fontMetrics; + } + + /** + * Gets the CSS color of the current options object + */ + getColor(): string | undefined { + if (this.phantom) { + return "transparent"; + } else { + return this.color; + } + } +} + +export default Options; diff --git a/node_modules/katex/src/ParseError.ts b/node_modules/katex/src/ParseError.ts new file mode 100644 index 0000000..3b6ef5b --- /dev/null +++ b/node_modules/katex/src/ParseError.ts @@ -0,0 +1,76 @@ +import {Token} from "./Token"; + +import type {AnyParseNode} from "./types/nodes"; + +/** + * This is the ParseError class, which is the main error thrown by KaTeX + * functions when something has gone wrong. This is used to distinguish internal + * errors from errors in the expression that the user provided. + * + * If possible, a caller should provide a Token or ParseNode with information + * about where in the source string the problem occurred. + */ +class ParseError extends Error { + override name = "ParseError" as const; + position: number | undefined; + // Error start position based on passed-in Token or ParseNode. + length: number | undefined; + // Length of affected text based on passed-in Token or ParseNode. + rawMessage: string; + // The underlying error message without any context added. + + constructor( + message: string, // The error message + token?: Token | null | undefined | AnyParseNode, + ) { + let error = "KaTeX parse error: " + message; + let start; + let end; + + const loc = token && token.loc; + if (loc && loc.start <= loc.end) { + // If we have the input and a position, make the error a bit fancier + + // Get the input + const input = loc.lexer.input; + + // Prepend some information + start = loc.start; + end = loc.end; + if (start === input.length) { + error += " at end of input: "; + } else { + error += " at position " + (start + 1) + ": "; + } + + // Underline token in question using combining underscores + const underlined = input.slice(start, end).replace(/[^]/g, "$&\u0332"); + + // Extract some context from the input and add it to the error + let left; + if (start > 15) { + left = "…" + input.slice(start - 15, start); + } else { + left = input.slice(0, start); + } + let right; + if (end + 15 < input.length) { + right = input.slice(end, end + 15) + "…"; + } else { + right = input.slice(end); + } + error += left + underlined + right; + + } + + super(error); + Object.setPrototypeOf(this, ParseError.prototype); + this.position = start; + if (start != null && end != null) { + this.length = end - start; + } + this.rawMessage = message; + } +} + +export default ParseError; diff --git a/node_modules/katex/src/Parser.ts b/node_modules/katex/src/Parser.ts new file mode 100644 index 0000000..08ad48d --- /dev/null +++ b/node_modules/katex/src/Parser.ts @@ -0,0 +1,1047 @@ +/* eslint no-constant-condition:0 */ +import functions from "./functions"; +import MacroExpander, {implicitCommands} from "./MacroExpander"; +import symbols, {extraLatin} from "./symbols"; +import type {Group} from "./atoms"; +import {isAtom} from "./atoms"; +import {validUnit} from "./units"; +import {supportedCodepoint} from "./unicodeScripts"; +import ParseError from "./ParseError"; +import {combiningDiacriticalMarksEndRegex} from "./Lexer"; +import Settings from "./Settings"; +import SourceLocation from "./SourceLocation"; +import {unicodeSubRegEx, uSubsAndSups} from "./unicodeSupOrSub"; +import {Token} from "./Token"; + +// Pre-evaluate both modules as unicodeSymbols require String.normalize() +import unicodeAccents from /*preval*/ "./unicodeAccents"; +import unicodeSymbols from /*preval*/ "./unicodeSymbols"; + +import type {ArgType, BreakToken, Mode} from "./types"; +import type {AnyParseNode, NodeType, ParseNode, SymbolParseNode, UnsupportedCmdParseNode} from "./types/nodes"; +import type {FunctionContext, FunctionSpec} from "./defineFunction"; +import type {EnvSpec} from "./defineEnvironment"; + +/** + * This file contains the parser used to parse out a TeX expression from the + * input. Since TeX isn't context-free, standard parsers don't work particularly + * well. + * + * The strategy of this parser is as such: + * + * The main functions (the `.parse...` ones) take a position in the current + * parse string to parse tokens from. The lexer (found in Lexer.js, stored at + * this.gullet.lexer) also supports pulling out tokens at arbitrary places. When + * individual tokens are needed at a position, the lexer is called to pull out a + * token, which is then used. + * + * The parser has a property called "mode" indicating the mode that + * the parser is currently in. Currently it has to be one of "math" or + * "text", which denotes whether the current environment is a math-y + * one or a text-y one (e.g. inside \text). Currently, this serves to + * limit the functions which can be used in text mode. + * + * The main functions then return an object which contains the useful data that + * was parsed at its given point, and a new position at the end of the parsed + * data. The main functions can call each other and continue the parsing by + * using the returned position as a new starting point. + * + * There are also extra `.handle...` functions, which pull out some reused + * functionality into self-contained functions. + * + * The functions return ParseNodes. + */ + +export default class Parser { + mode: Mode; + gullet: MacroExpander; + settings: Settings; + leftrightDepth: number; + nextToken: Token | null; + + constructor(input: string, settings: Settings) { + // Start in math mode + this.mode = "math"; + // Create a new macro expander (gullet) and (indirectly via that) also a + // new lexer (mouth) for this parser (stomach, in the language of TeX) + this.gullet = new MacroExpander(input, settings, this.mode); + // Store the settings for use in parsing + this.settings = settings; + // Count leftright depth (for \middle errors) + this.leftrightDepth = 0; + this.nextToken = null; + } + + /** + * Checks a result to make sure it has the right type, and throws an + * appropriate error otherwise. + */ + expect(text: string, consume = true) { + if (this.fetch().text !== text) { + throw new ParseError( + `Expected '${text}', got '${this.fetch().text}'`, this.fetch() + ); + } + if (consume) { + this.consume(); + } + } + + /** + * Discards the current lookahead token, considering it consumed. + */ + consume() { + this.nextToken = null; + } + + /** + * Return the current lookahead token, or if there isn't one (at the + * beginning, or if the previous lookahead token was consume()d), + * fetch the next token as the new lookahead token and return it. + */ + fetch(): Token { + if (this.nextToken == null) { + this.nextToken = this.gullet.expandNextToken(); + } + return this.nextToken; + } + + /** + * Switches between "text" and "math" modes. + */ + switchMode(newMode: Mode) { + this.mode = newMode; + this.gullet.switchMode(newMode); + } + + /** + * Main parsing function, which parses an entire input. + */ + parse(): AnyParseNode[] { + if (!this.settings.globalGroup) { + // Create a group namespace for the math expression. + // (LaTeX creates a new group for every $...$, $$...$$, \[...\].) + this.gullet.beginGroup(); + } + + // Use old \color behavior (same as LaTeX's \textcolor) if requested. + // We do this within the group for the math expression, so it doesn't + // pollute settings.macros. + if (this.settings.colorIsTextColor) { + this.gullet.macros.set("\\color", "\\textcolor"); + } + + try { + // Try to parse the input + const parse = this.parseExpression(false); + + // If we succeeded, make sure there's an EOF at the end + this.expect("EOF"); + + // End the group namespace for the expression + if (!this.settings.globalGroup) { + this.gullet.endGroup(); + } + + return parse; + + // Close any leftover groups in case of a parse error. + } finally { + this.gullet.endGroups(); + } + } + + /** + * Fully parse a separate sequence of tokens as a separate job. + * Tokens should be specified in reverse order, as in a MacroDefinition. + */ + subparse(tokens: Token[]): AnyParseNode[] { + // Save the next token from the current job. + const oldToken = this.nextToken; + this.consume(); + + // Run the new job, terminating it with an excess '}' + this.gullet.pushToken(new Token("}")); + this.gullet.pushTokens(tokens); + const parse = this.parseExpression(false); + this.expect("}"); + + // Restore the next token from the current job. + this.nextToken = oldToken; + + return parse; + } + + static endOfExpression: Set = + new Set(["}", "\\endgroup", "\\end", "\\right", "&"]); + + /** + * Parses an "expression", which is a list of atoms. + * + * `breakOnInfix`: Should the parsing stop when we hit infix nodes? This + * happens when functions have higher precedence than infix + * nodes in implicit parses. + * + * `breakOnTokenText`: The text of the token that the expression should end + * with, or `null` if something else should end the + * expression. + */ + parseExpression( + breakOnInfix: boolean, + breakOnTokenText?: BreakToken, + ): AnyParseNode[] { + const body = []; + // Keep adding atoms to the body until we can't parse any more atoms (either + // we reached the end, a }, or a \right) + while (true) { + // Ignore spaces in math mode + if (this.mode === "math") { + this.consumeSpaces(); + } + const lex = this.fetch(); + if (Parser.endOfExpression.has(lex.text)) { + break; + } + if (breakOnTokenText && lex.text === breakOnTokenText) { + break; + } + if (breakOnInfix && functions[lex.text] && functions[lex.text].infix) { + break; + } + const atom = this.parseAtom(breakOnTokenText); + if (!atom) { + break; + } else if (atom.type === "internal") { + // Internal nodes do not appear in parse tree + continue; + } + body.push(atom); + } + if (this.mode === "text") { + this.formLigatures(body); + } + return this.handleInfixNodes(body); + } + + /** + * Rewrites infix operators such as \over with corresponding commands such + * as \frac. + * + * There can only be one infix operator per group. If there's more than one + * then the expression is ambiguous. This can be resolved by adding {}. + */ + handleInfixNodes(body: AnyParseNode[]): AnyParseNode[] { + let overIndex = -1; + let funcName; + + for (let i = 0; i < body.length; i++) { + const node = body[i]; + if (node.type === "infix") { + if (overIndex !== -1) { + throw new ParseError( + "only one infix operator per group", + node.token); + } + overIndex = i; + funcName = node.replaceWith; + } + } + + if (overIndex !== -1 && funcName) { + let numerNode: AnyParseNode; + let denomNode: AnyParseNode; + + const numerBody = body.slice(0, overIndex); + const denomBody = body.slice(overIndex + 1); + + if (numerBody.length === 1 && numerBody[0].type === "ordgroup") { + numerNode = numerBody[0]; + } else { + numerNode = {type: "ordgroup", mode: this.mode, body: numerBody}; + } + + if (denomBody.length === 1 && denomBody[0].type === "ordgroup") { + denomNode = denomBody[0]; + } else { + denomNode = {type: "ordgroup", mode: this.mode, body: denomBody}; + } + + let node; + if (funcName === "\\\\abovefrac") { + node = this.callFunction(funcName, + [numerNode, body[overIndex], denomNode], []); + } else { + node = this.callFunction(funcName, [numerNode, denomNode], []); + } + return [node]; + } else { + return body; + } + } + + /** + * Handle a subscript or superscript with nice errors. + */ + handleSupSubscript( + name: string, // For error reporting. + ): AnyParseNode { + const symbolToken = this.fetch(); + const symbol = symbolToken.text; + this.consume(); + this.consumeSpaces(); // ignore spaces before sup/subscript argument + + // Skip over allowed internal nodes such as \relax + let group: AnyParseNode | null | undefined; + do { + group = this.parseGroup(name); + } while (group?.type === "internal"); + + if (!group) { + throw new ParseError( + "Expected group after '" + symbol + "'", + symbolToken + ); + } + + return group; + } + + /** + * Converts the textual input of an unsupported command into a text node + * contained within a color node whose color is determined by errorColor + */ + formatUnsupportedCmd(text: string): UnsupportedCmdParseNode { + const textordArray: ParseNode<"textord">[] = []; + + for (let i = 0; i < text.length; i++) { + textordArray.push({type: "textord", mode: "text", text: text[i]}); + } + + const textNode: ParseNode<"text"> = { + type: "text", + mode: this.mode, + body: textordArray, + }; + const colorNode: ParseNode<"color"> = { + type: "color", + mode: this.mode, + color: this.settings.errorColor, + body: [textNode], + }; + + return colorNode; + } + + /** + * Parses a group with optional super/subscripts. + */ + parseAtom(breakOnTokenText?: BreakToken): AnyParseNode | null { + // The body of an atom is an implicit group, so that things like + // \left(x\right)^2 work correctly. + const base = this.parseGroup("atom", breakOnTokenText); + + // Internal nodes (e.g. \relax) cannot support super/subscripts. + // Instead, we will pick up super/subscripts with blank base next round. + if (base?.type === "internal") { + return base; + } + + // In text mode, we don't have superscripts or subscripts + if (this.mode === "text") { + return base; + } + + let superscript: AnyParseNode | undefined; + let subscript: AnyParseNode | undefined; + while (true) { + // Guaranteed in math mode, so eat any spaces first. + this.consumeSpaces(); + + // Lex the first token + const lex = this.fetch(); + + if (lex.text === "\\limits" || lex.text === "\\nolimits") { + // We got a limit control + if (base && base.type === "op") { + base.limits = lex.text === "\\limits"; + base.alwaysHandleSupSub = true; + } else if (base && base.type === "operatorname") { + if (base.alwaysHandleSupSub) { + base.limits = lex.text === "\\limits"; + } + } else { + throw new ParseError( + "Limit controls must follow a math operator", + lex); + } + this.consume(); + } else if (lex.text === "^") { + // We got a superscript start + if (superscript) { + throw new ParseError("Double superscript", lex); + } + superscript = this.handleSupSubscript("superscript"); + } else if (lex.text === "_") { + // We got a subscript start + if (subscript) { + throw new ParseError("Double subscript", lex); + } + subscript = this.handleSupSubscript("subscript"); + } else if (lex.text === "'") { + // We got a prime + if (superscript) { + throw new ParseError("Double superscript", lex); + } + + const prime: ParseNode<"textord"> = {type: "textord", mode: this.mode, text: "\\prime"}; + + // Many primes can be grouped together, so we handle this here + const primes: AnyParseNode[] = [prime]; + this.consume(); + // Keep lexing tokens until we get something that's not a prime + while (this.fetch().text === "'") { + // For each one, add another prime to the list + primes.push(prime); + this.consume(); + } + // If there's a superscript following the primes, combine that + // superscript in with the primes. + if (this.fetch().text === "^") { + primes.push(this.handleSupSubscript("superscript")); + } + // Put everything into an ordgroup as the superscript + superscript = {type: "ordgroup", mode: this.mode, body: primes}; + } else if (uSubsAndSups[lex.text]) { + // A Unicode subscript or superscript character. + // We treat these similarly to the unicode-math package. + // So we render a string of Unicode (sub|super)scripts the + // same as a (sub|super)script of regular characters. + const isSub = unicodeSubRegEx.test(lex.text); + const subsupTokens = []; + subsupTokens.push(new Token(uSubsAndSups[lex.text])); + this.consume(); + // Continue fetching tokens to fill out the string. + while (true) { + const token = this.fetch().text; + if (!(uSubsAndSups[token])) { break; } + if (unicodeSubRegEx.test(token) !== isSub) { break; } + subsupTokens.unshift(new Token(uSubsAndSups[token])); + this.consume(); + } + // Now create a (sub|super)script. + const body = this.subparse(subsupTokens); + if (isSub) { + subscript = {type: "ordgroup", mode: "math", body}; + } else { + superscript = {type: "ordgroup", mode: "math", body}; + } + } else { + // If it wasn't ^, _, or ', stop parsing super/subscripts + break; + } + } + + // Base must be set if superscript or subscript are set per logic above, + // but need to check here for type check to pass. + if (superscript && subscript) { + return {type: "supsub", mode: this.mode, base, sup: superscript, sub: subscript}; + } else if (superscript) { + return {type: "supsub", mode: this.mode, base, sup: superscript}; + } else if (subscript) { + return {type: "supsub", mode: this.mode, base, sub: subscript}; + } else { + // Otherwise return the original body + return base; + } + } + + /** + * Parses an entire function, including its base and all of its arguments. + */ + parseFunction( + breakOnTokenText?: BreakToken, + name?: string, // For determining its context + ): AnyParseNode | null { + const token = this.fetch(); + const func = token.text; + const funcData = functions[func]; + if (!funcData) { + return null; + } + this.consume(); // consume command token + + if (name && name !== "atom" && !funcData.allowedInArgument) { + throw new ParseError( + "Got function '" + func + "' with no arguments" + + (name ? " as " + name : ""), token); + // Treat undefined allowedInText as false. + } else if (this.mode === "text" && !funcData.allowedInText) { + throw new ParseError( + "Can't use function '" + func + "' in text mode", token); + // Treat undefined allowedInMath as true. + } else if (this.mode === "math" && funcData.allowedInMath === false) { + throw new ParseError( + "Can't use function '" + func + "' in math mode", token); + } + + const {args, optArgs} = this.parseArguments(func, funcData); + return this.callFunction(func, args, optArgs, token, breakOnTokenText); + } + + /** + * Call a function handler with a suitable context and arguments. + */ + callFunction( + name: string, + args: AnyParseNode[], + optArgs: (AnyParseNode | null)[], + token?: Token, + breakOnTokenText?: BreakToken, + ): AnyParseNode { + const context: FunctionContext = { + funcName: name, + parser: this, + token, + breakOnTokenText, + }; + const func = functions[name]; + if (func && func.handler) { + return func.handler(context, args, optArgs); + } else { + throw new ParseError(`No function handler for ${name}`); + } + } + + /** + * Parses the arguments of a function or environment + */ + parseArguments( + func: string, // Should look like "\name" or "\begin{name}". + funcData: FunctionSpec | EnvSpec, + ): { + args: AnyParseNode[]; + optArgs: (AnyParseNode | null)[]; + } { + const numOptionalArgs = funcData.numOptionalArgs ?? 0; + const totalArgs = funcData.numArgs + numOptionalArgs; + if (totalArgs === 0) { + return {args: [], optArgs: []}; + } + + const args: AnyParseNode[] = []; + const optArgs: (AnyParseNode | null)[] = []; + + for (let i = 0; i < totalArgs; i++) { + let argType = funcData.argTypes?.[i]; + const isOptional = i < numOptionalArgs; + + if (("primitive" in funcData && funcData.primitive && argType == null) || + // \sqrt expands into primitive if optional argument doesn't exist + (funcData.type === "sqrt" && i === 1 && optArgs[0] == null) + ) { + argType = "primitive"; + } + + const arg = this.parseGroupOfType(`argument to '${func}'`, + argType, isOptional); + if (isOptional) { + optArgs.push(arg); + } else if (arg != null) { + args.push(arg); + } else { // should be unreachable + throw new ParseError("Null argument, please report this as a bug"); + } + } + + return {args, optArgs}; + } + + /** + * Parses a group when the mode is changing. + */ + parseGroupOfType( + name: string, + type: ArgType | undefined, + optional: boolean, + ): AnyParseNode | null { + switch (type) { + case "color": + return this.parseColorGroup(optional); + case "size": + return this.parseSizeGroup(optional); + case "url": + return this.parseUrlGroup(optional); + case "math": + case "text": + return this.parseArgumentGroup(optional, type); + case "hbox": { + // hbox argument type wraps the argument in the equivalent of + // \hbox, which is like \text but switching to \textstyle size + // and resetting math font. + const group = this.parseArgumentGroup(optional, "text"); + return group != null ? { + type: "styling", + mode: group.mode, + body: [group], + style: "text", // simulate \textstyle + resetFont: true, + } : null; + } + case "raw": { + const token = this.parseStringGroup(optional); + return token != null ? { + type: "raw", + mode: "text", + string: token.text, + } : null; + } + case "primitive": { + if (optional) { + throw new ParseError("A primitive argument cannot be optional"); + } + const group = this.parseGroup(name); + if (group == null) { + throw new ParseError("Expected group as " + name, this.fetch()); + } + return group; + } + case "original": + case undefined: + return this.parseArgumentGroup(optional); + default: + throw new ParseError( + "Unknown group type as " + name, this.fetch()); + } + } + + /** + * Discard any space tokens, fetching the next non-space token. + */ + consumeSpaces() { + while (this.fetch().text === " ") { + this.consume(); + } + } + + /** + * Parses a group, essentially returning the string formed by the + * brace-enclosed tokens plus some position information. + */ + parseStringGroup( + optional: boolean, + ): Token | null { + const argToken = this.gullet.scanArgument(optional); + if (argToken == null) { + return null; + } + let str = ""; + let nextToken: Token; + while ((nextToken = this.fetch()).text !== "EOF") { + str += nextToken.text; + this.consume(); + } + this.consume(); // consume the end of the argument + argToken.text = str; + return argToken; + } + + /** + * Parses a regex-delimited group: the largest sequence of tokens + * whose concatenated strings match `regex`. Returns the string + * formed by the tokens plus some position information. + */ + parseRegexGroup( + regex: RegExp, + modeName: string, // Used to describe the mode in error messages. + ): Token { + const firstToken = this.fetch(); + let lastToken = firstToken; + let str = ""; + let nextToken: Token; + while ((nextToken = this.fetch()).text !== "EOF" && + regex.test(str + nextToken.text)) { + lastToken = nextToken; + str += lastToken.text; + this.consume(); + } + if (str === "") { + throw new ParseError( + "Invalid " + modeName + ": '" + firstToken.text + "'", + firstToken); + } + return firstToken.range(lastToken, str); + } + + /** + * Parses a color description. + */ + parseColorGroup(optional: boolean): ParseNode<"color-token"> | null { + const res = this.parseStringGroup(optional); + if (res == null) { + return null; + } + const match = ( + /^(#[a-f0-9]{3,4}|#[a-f0-9]{6}|#[a-f0-9]{8}|[a-f0-9]{6}|[a-z]+)$/i + ).exec(res.text); + if (!match) { + throw new ParseError("Invalid color: '" + res.text + "'", res); + } + let color = match[0]; + if (/^[0-9a-f]{6}$/i.test(color)) { + // We allow a 6-digit HTML color spec without a leading "#". + // This follows the xcolor package's HTML color model. + // Predefined color names are all missed by this RegEx pattern. + color = "#" + color; + } + + return { + type: "color-token", + mode: this.mode, + color, + }; + } + + /** + * Parses a size specification, consisting of magnitude and unit. + */ + parseSizeGroup(optional: boolean): ParseNode<"size"> | null { + let res: Token | null; + let isBlank = false; + // don't expand before parseStringGroup + this.gullet.consumeSpaces(); + if (!optional && this.gullet.future().text !== "{") { + res = this.parseRegexGroup( + /^[-+]? *(?:$|\d+|\d+\.\d*|\.\d*) *[a-z]{0,2} *$/, "size"); + } else { + res = this.parseStringGroup(optional); + } + if (!res) { + return null; + } + if (!optional && res.text.length === 0) { + // Because we've tested for what is !optional, this block won't + // affect \kern, \hspace, etc. It will capture the mandatory arguments + // to \genfrac and \above. + res.text = "0pt"; // Enable \above{} + isBlank = true; // This is here specifically for \genfrac + } + const match = (/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/).exec(res.text); + if (!match) { + throw new ParseError("Invalid size: '" + res.text + "'", res); + } + const data = { + number: +(match[1] + match[2]), // sign + magnitude, cast to number + unit: match[3], + }; + if (!validUnit(data)) { + throw new ParseError("Invalid unit: '" + data.unit + "'", res); + } + + return { + type: "size", + mode: this.mode, + value: data, + isBlank, + }; + } + + /** + * Parses an URL, checking escaped letters and allowed protocols, + * and setting the catcode of % as an active character (as in \hyperref). + */ + parseUrlGroup(optional: boolean): ParseNode<"url"> | null { + this.gullet.lexer.setCatcode("%", 13); // active character + this.gullet.lexer.setCatcode("~", 12); // other character + const res = this.parseStringGroup(optional); + this.gullet.lexer.setCatcode("%", 14); // comment character + this.gullet.lexer.setCatcode("~", 13); // active character + if (res == null) { + return null; + } + // hyperref package allows backslashes alone in href, but doesn't + // generate valid links in such cases; we interpret this as + // "undefined" behaviour, and keep them as-is. Some browser will + // replace backslashes with forward slashes. + const url = res.text.replace(/\\([#$%&~_^{}])/g, '$1'); + return { + type: "url", + mode: this.mode, + url, + }; + } + + /** + * Parses an argument with the mode specified. + */ + parseArgumentGroup(optional: boolean, mode?: Mode): ParseNode<"ordgroup"> | null { + const argToken = this.gullet.scanArgument(optional); + if (argToken == null) { + return null; + } + const outerMode = this.mode; + if (mode) { // Switch to specified mode + this.switchMode(mode); + } + + this.gullet.beginGroup(); + const expression = this.parseExpression(false, "EOF"); + // TODO: find an alternative way to denote the end + this.expect("EOF"); // expect the end of the argument + this.gullet.endGroup(); + const result: ParseNode<"ordgroup"> = { + type: "ordgroup", + mode: this.mode, + loc: argToken.loc, + body: expression, + }; + + if (mode) { // Switch mode back + this.switchMode(outerMode); + } + return result; + } + + /** + * Parses an ordinary group, which is either a single nucleus (like "x") + * or an expression in braces (like "{x+y}") or an implicit group, a group + * that starts at the current position, and ends right before a higher explicit + * group ends, or at EOF. + */ + parseGroup( + name: string, // For error reporting. + breakOnTokenText?: BreakToken, + ): AnyParseNode | null { + const firstToken = this.fetch(); + const text = firstToken.text; + + let result; + // Try to parse an open brace or \begingroup + if (text === "{" || text === "\\begingroup") { + this.consume(); + const groupEnd = text === "{" ? "}" : "\\endgroup"; + + this.gullet.beginGroup(); + // If we get a brace, parse an expression + const expression = this.parseExpression(false, groupEnd); + const lastToken = this.fetch(); + this.expect(groupEnd); // Check that we got a matching closing brace + this.gullet.endGroup(); + result = { + type: "ordgroup", + mode: this.mode, + loc: SourceLocation.range(firstToken, lastToken), + body: expression, + // A group formed by \begingroup...\endgroup is a semi-simple group + // which doesn't affect spacing in math mode, i.e., is transparent. + // https://tex.stackexchange.com/questions/1930/when-should-one- + // use-begingroup-instead-of-bgroup + semisimple: text === "\\begingroup" || undefined, + } as const satisfies ParseNode<"ordgroup">; + } else { + // If there exists a function with this name, parse the function. + // Otherwise, just return a nucleus + result = this.parseFunction(breakOnTokenText, name) || + this.parseSymbol(); + if (result == null && text[0] === "\\" && + !implicitCommands.hasOwnProperty(text)) { + if (this.settings.throwOnError) { + throw new ParseError( + "Undefined control sequence: " + text, firstToken); + } + result = this.formatUnsupportedCmd(text); + this.consume(); + } + } + return result; + } + + /** + * Form ligature-like combinations of characters for text mode. + * This includes inputs like "--", "---", "``" and "''". + * The result will simply replace multiple textord nodes with a single + * character in each value by a single textord node having multiple + * characters in its value. The representation is still ASCII source. + * The group will be modified in place. + */ + formLigatures(group: AnyParseNode[]) { + let n = group.length - 1; + for (let i = 0; i < n; ++i) { + const a = group[i]; + if (a.type !== "textord") { + continue; + } + const v = a.text; + const next = group[i + 1]; + if (!next || next.type !== "textord") { + continue; + } + if (v === "-" && next.text === "-") { + const afterNext = group[i + 2]; + if (i + 1 < n && afterNext && afterNext.type === "textord" && afterNext.text === "-") { + group.splice(i, 3, { + type: "textord", + mode: "text", + loc: SourceLocation.range(a, afterNext), + text: "---", + }); + n -= 2; + } else { + group.splice(i, 2, { + type: "textord", + mode: "text", + loc: SourceLocation.range(a, next), + text: "--", + }); + n -= 1; + } + } + if ((v === "'" || v === "`") && next.text === v) { + group.splice(i, 2, { + type: "textord", + mode: "text", + loc: SourceLocation.range(a, next), + text: v + v, + }); + n -= 1; + } + } + } + + /** + * Parse a single symbol out of the string. Here, we handle single character + * symbols and special functions like \verb. + */ + parseSymbol(): AnyParseNode | null { + const nucleus = this.fetch(); + let text = nucleus.text; + + if (/^\\verb[^a-zA-Z]/.test(text)) { + this.consume(); + let arg = text.slice(5); + const star = (arg.charAt(0) === "*"); + if (star) { + arg = arg.slice(1); + } + // Lexer's tokenRegex is constructed to always have matching + // first/last characters. + if (arg.length < 2 || arg.charAt(0) !== arg.slice(-1)) { + throw new ParseError(`\\verb assertion failed -- + please report what input caused this bug`); + } + arg = arg.slice(1, -1); // remove first and last char + + return { + type: "verb", + mode: "text", + body: arg, + star, + }; + } + // At this point, we should have a symbol, possibly with accents. + // First expand any accented base symbol according to unicodeSymbols. + if (unicodeSymbols.hasOwnProperty(text[0]) && + !symbols[this.mode][text[0]]) { + // This behavior is not strict (XeTeX-compatible) in math mode. + if (this.settings.strict && this.mode === "math") { + this.settings.reportNonstrict("unicodeTextInMathMode", + `Accented Unicode text character "${text[0]}" used in ` + + `math mode`, nucleus); + } + text = unicodeSymbols[text[0]] + text.slice(1); + } + // Strip off any combining characters + const match = combiningDiacriticalMarksEndRegex.exec(text); + if (match) { + text = text.substring(0, match.index); + if (text === 'i') { + text = '\u0131'; // dotless i, in math and text mode + } else if (text === 'j') { + text = '\u0237'; // dotless j, in math and text mode + } + } + // Recognize base symbol + let symbol: AnyParseNode; + if (symbols[this.mode][text]) { + if (this.settings.strict && this.mode === 'math' && + extraLatin.includes(text)) { + this.settings.reportNonstrict("unicodeTextInMathMode", + `Latin-1/Unicode text character "${text[0]}" used in ` + + `math mode`, nucleus); + } + const group: Group = symbols[this.mode][text].group; + const loc = SourceLocation.range(nucleus); + let s: SymbolParseNode; + if (isAtom(group)) { + s = { + type: "atom", + mode: this.mode, + family: group, + loc, + text, + }; + } else { + s = { + type: group, + mode: this.mode, + loc, + text, + }; + } + symbol = s; + } else if (text.charCodeAt(0) >= 0x80) { // no symbol for e.g. ^ + if (this.settings.strict) { + if (!supportedCodepoint(text.charCodeAt(0))) { + this.settings.reportNonstrict("unknownSymbol", + `Unrecognized Unicode character "${text[0]}"` + + ` (${text.charCodeAt(0)})`, nucleus); + } else if (this.mode === "math") { + this.settings.reportNonstrict("unicodeTextInMathMode", + `Unicode text character "${text[0]}" used in math mode`, + nucleus); + } + } + // All nonmathematical Unicode characters are rendered as if they + // are in text mode (wrapped in \text) because that's what it + // takes to render them in LaTeX. Setting `mode: this.mode` is + // another natural choice (the user requested math mode), but + // this makes it more difficult for getCharacterMetrics() to + // distinguish Unicode characters without metrics and those for + // which we want to simulate the letter M. + symbol = { + type: "textord", + mode: "text", + loc: SourceLocation.range(nucleus), + text, + }; + } else { + return null; // EOF, ^, _, {, }, etc. + } + this.consume(); + // Transform combining characters into accents + if (match) { + for (let i = 0; i < match[0].length; i++) { + const accent: string = match[0][i]; + if (!unicodeAccents[accent]) { + throw new ParseError(`Unknown accent ' ${accent}'`, nucleus); + } + const command = unicodeAccents[accent][this.mode] || + unicodeAccents[accent].text; + if (!command) { + throw new ParseError( + `Accent ${accent} unsupported in ${this.mode} mode`, + nucleus); + } + symbol = { + type: "accent", + mode: this.mode, + loc: SourceLocation.range(nucleus), + label: command, + isStretchy: false, + isShifty: true, + base: symbol, + }; + } + } + return symbol; + } +} diff --git a/node_modules/katex/src/Settings.ts b/node_modules/katex/src/Settings.ts new file mode 100644 index 0000000..da3c505 --- /dev/null +++ b/node_modules/katex/src/Settings.ts @@ -0,0 +1,477 @@ +/* eslint no-console:0 */ +/** + * This is a module for storing settings passed into KaTeX. It correctly handles + * default settings. + */ + +import {protocolFromUrl} from "./utils"; +import ParseError from "./ParseError"; +import {Token} from "./Token"; + +import type {AnyParseNode} from "./types/nodes"; +import type {MacroMap} from "./defineMacro"; + +export type StrictFunction = + (errorCode: string, errorMsg: string, token?: Token | AnyParseNode) => + (boolean | string) | null | undefined; + +export type TrustContextTypes = { + "\\href": { + command: "\\href"; + url: string; + protocol?: string; + }; + "\\includegraphics": { + command: "\\includegraphics"; + url: string; + protocol?: string; + }; + "\\url": { + command: "\\url"; + url: string; + protocol?: string; + }; + "\\htmlClass": { + command: "\\htmlClass"; + class: string; + }; + "\\htmlId": { + command: "\\htmlId"; + id: string; + }; + "\\htmlStyle": { + command: "\\htmlStyle"; + style: string; + }; + "\\htmlData": { + command: "\\htmlData"; + attributes: Record; + }; +}; +export type AnyTrustContext = TrustContextTypes[keyof TrustContextTypes]; +export type TrustFunction = (context: AnyTrustContext) => boolean | null | undefined; +export type SettingsOptions = Partial; + +type EnumType = { + enum: T[]; +}; + +type Type = "boolean" | "string" | "number" | "object" | "function" | EnumType; +/** + * Union of all values that appear as schema defaults, cliDefaults, or + * cliProcessor return values. StrictFunction / TrustFunction are + * option-value types, not default/schema values, so they are excluded. + */ +type SettingsValue = boolean | string | number | MacroMap | string[]; +type DefaultValue = Exclude; + +type SchemaMetadata = { + /** + * The description. + */ + description?: string; + /** + * The function to process the option. + */ + processor?: (value: Settings[K]) => Settings[K]; + /** + * The command line argument. See Commander.js docs for more information. + * If not specified, the name prefixed with -- will be used. Set false not + * to add to the CLI. + */ + cli?: string | false; + /** + * The default value for the CLI. + */ + cliDefault?: SettingsValue; + /** + * The description for the CLI. If not specified, the description for the + * option will be used. + */ + cliDescription?: string; + /** + * The custom argument processor for the CLI. See Commander.js docs for + * more information. Signature varies per setting (e.g. parseFloat, + * or (def, defs) => defs.push(def) for macros). + */ + cliProcessor?: (...args: any[]) => SettingsValue; +}; + +type BooleanSchema = SchemaMetadata & { + /** + * Allowed type(s) of the value. + */ + type: "boolean"; + /** + * The default value. If not specified, false will be used. + */ + default?: Extract; +}; + +type StringSchema = SchemaMetadata & { + /** + * Allowed type(s) of the value. + */ + type: "string"; + /** + * The default value. If not specified, an empty string will be used. + */ + default?: Extract; +}; + +type NumberSchema = SchemaMetadata & { + /** + * Allowed type(s) of the value. + */ + type: "number"; + /** + * The default value. If not specified, 0 will be used. + */ + default?: Extract; +}; + +type ObjectSchema = SchemaMetadata & { + /** + * Allowed type(s) of the value. + */ + type: "object"; + /** + * The default value. If not specified, an empty object will be used. + */ + default?: Extract; +}; + +type FunctionSchema = SchemaMetadata & { + /** + * Allowed type(s) of the value. + */ + type: "function"; + /** + * Settings do not currently use function-valued defaults. + */ + default?: never; +}; + +type EnumSchema = SchemaMetadata & { + /** + * Allowed type(s) of the value. + */ + type: EnumType>; + /** + * The default value. If not specified, the first enum value will be used. + */ + default?: Extract; +}; + +type SingleTypeSchema = + | BooleanSchema + | StringSchema + | NumberSchema + | ObjectSchema + | FunctionSchema + | EnumSchema; + +type MultiTypeSchema = SchemaMetadata & { + /** + * Allowed type(s) of the value. + */ + type: [SingleTypeSchema["type"], ...Array["type"]>]; + /** + * The default value. If not specified, the first allowed type determines + * the default value. + */ + default?: Extract; +}; + +type SchemaEntry = + | SingleTypeSchema + | MultiTypeSchema; + +type Schema = { + [key in keyof SettingsOptions]?: SchemaEntry; +}; + +// TODO: automatically generate documentation +// TODO: check all properties on Settings exist +// TODO: check the type of a property on Settings matches +export const SETTINGS_SCHEMA: Schema = { + displayMode: { + type: "boolean", + description: "Render math in display mode, which puts the math in " + + "display style (so \\int and \\sum are large, for example), and " + + "centers the math on the page on its own line.", + cli: "-d, --display-mode", + }, + output: { + type: {enum: ["htmlAndMathml", "html", "mathml"]}, + description: "Determines the markup language of the output.", + cli: "-F, --format ", + }, + leqno: { + type: "boolean", + description: "Render display math in leqno style (left-justified tags).", + }, + fleqn: { + type: "boolean", + description: "Render display math flush left.", + }, + throwOnError: { + type: "boolean", + default: true, + cli: "-t, --no-throw-on-error", + cliDescription: "Render errors (in the color given by --error-color) ins" + + "tead of throwing a ParseError exception when encountering an error.", + }, + errorColor: { + type: "string", + default: "#cc0000", + cli: "-c, --error-color ", + cliDescription: "A color string given in the format 'rgb' or 'rrggbb' " + + "(no #). This option determines the color of errors rendered by the " + + "-t option.", + cliProcessor: (color) => "#" + color, + }, + macros: { + type: "object", + cli: "-m, --macro ", + cliDescription: "Define custom macro of the form '\\foo:expansion' (use " + + "multiple -m arguments for multiple macros).", + cliDefault: [], + cliProcessor: (def, defs) => { + defs.push(def); + return defs; + }, + }, + minRuleThickness: { + type: "number", + description: "Specifies a minimum thickness, in ems, for fraction lines," + + " `\\sqrt` top lines, `{array}` vertical lines, `\\hline`, " + + "`\\hdashline`, `\\underline`, `\\overline`, and the borders of " + + "`\\fbox`, `\\boxed`, and `\\fcolorbox`.", + processor: (t) => Math.max(0, t), + cli: "--min-rule-thickness ", + cliProcessor: parseFloat, + }, + colorIsTextColor: { + type: "boolean", + description: "Makes \\color behave like LaTeX's 2-argument \\textcolor, " + + "instead of LaTeX's one-argument \\color mode change.", + cli: "-b, --color-is-text-color", + }, + strict: { + type: [{enum: ["warn", "ignore", "error"]}, "boolean", "function"], + description: "Turn on strict / LaTeX faithfulness mode, which throws an " + + "error if the input uses features that are not supported by LaTeX.", + cli: "-S, --strict", + cliDefault: false, + }, + trust: { + type: ["boolean", "function"], + description: "Trust the input, enabling all HTML features such as \\url.", + cli: "-T, --trust", + }, + maxSize: { + type: "number", + default: Infinity, + description: "If non-zero, all user-specified sizes, e.g. in " + + "\\rule{500em}{500em}, will be capped to maxSize ems. Otherwise, " + + "elements and spaces can be arbitrarily large", + processor: (s) => Math.max(0, s), + cli: "-s, --max-size ", + cliProcessor: parseInt, + }, + maxExpand: { + type: "number", + default: 1000, + description: "Limit the number of macro expansions to the specified " + + "number, to prevent e.g. infinite macro loops. If set to Infinity, " + + "the macro expander will try to fully expand as in LaTeX.", + processor: (n) => Math.max(0, n), + cli: "-e, --max-expand ", + cliProcessor: (n) => (n === "Infinity" ? Infinity : parseInt(n)), + }, + globalGroup: { + type: "boolean", + cli: false, + }, +}; + +function getImplicitDefault(type: "boolean"): boolean; +function getImplicitDefault(type: "string"): string; +function getImplicitDefault(type: "number"): number; +function getImplicitDefault(type: "object"): MacroMap; +function getImplicitDefault(type: "function"): never; +function getImplicitDefault(type: EnumType): T; +function getImplicitDefault(type: Type): DefaultValue; +function getImplicitDefault(type: Type): DefaultValue { + if (typeof type !== 'string') { + return type.enum[0]; + } + switch (type) { + case 'boolean': + return false; + case 'string': + return ''; + case 'number': + return 0; + case 'object': + return {}; + default: + throw new Error( + "Unexpected schema type; settings must declare an explicit default."); + } +} + +function getDefaultValue( + schema: SchemaEntry, +): Settings[K]; +function getDefaultValue(schema: SchemaEntry): DefaultValue { + if (schema.default !== undefined) { + return schema.default; + } + const type = Array.isArray(schema.type) ? schema.type[0] : schema.type; + return getImplicitDefault(type); +} + +function applySetting( + target: Settings, + prop: K, + options: SettingsOptions, + schema: SchemaEntry, +) { + const optionValue = options[prop]; + target[prop] = optionValue !== undefined + ? (schema.processor + ? schema.processor(optionValue) + : optionValue) + : getDefaultValue(schema); +} + +/** + * The main Settings object + * + * The current options stored are: + * - displayMode: Whether the expression should be typeset as inline math + * (false, the default), meaning that the math starts in + * \textstyle and is placed in an inline-block); or as display + * math (true), meaning that the math starts in \displaystyle + * and is placed in a block with vertical margin. + */ +export default class Settings { + displayMode!: boolean; + output!: "html" | "mathml" | "htmlAndMathml"; + leqno!: boolean; + fleqn!: boolean; + throwOnError!: boolean; + errorColor!: string; + macros!: MacroMap; + minRuleThickness!: number; + colorIsTextColor!: boolean; + strict!: boolean | "ignore" | "warn" | "error" | StrictFunction; + trust!: boolean | TrustFunction; + maxSize!: number; + maxExpand!: number; + globalGroup!: boolean; + + constructor(options: SettingsOptions = {}) { + // allow null options + options = options || {}; + for (const prop of Object.keys(SETTINGS_SCHEMA) as Array) { + const schema = SETTINGS_SCHEMA[prop] as SchemaEntry | undefined; + if (schema) { + // TODO: validate options + applySetting(this, prop, options, schema); + } + } + } + + /** + * Report nonstrict (non-LaTeX-compatible) input. + * Can safely not be called if `this.strict` is false in JavaScript. + */ + reportNonstrict(errorCode: string, errorMsg: string, + token?: Token | AnyParseNode) { + let strict: Settings["strict"] | ReturnType = this.strict; + if (typeof strict === "function") { + // Allow return value of strict function to be boolean or string + // (or null/undefined, meaning no further processing). + strict = strict(errorCode, errorMsg, token); + } + if (!strict || strict === "ignore") { + return; + } else if (strict === true || strict === "error") { + throw new ParseError( + "LaTeX-incompatible input and strict mode is set to 'error': " + + `${errorMsg} [${errorCode}]`, token); + } else if (strict === "warn") { + typeof console !== "undefined" && console.warn( + "LaTeX-incompatible input and strict mode is set to 'warn': " + + `${errorMsg} [${errorCode}]`); + } else { // won't happen in type-safe code + typeof console !== "undefined" && console.warn( + "LaTeX-incompatible input and strict mode is set to " + + `unrecognized '${strict}': ${errorMsg} [${errorCode}]`); + } + } + + /** + * Check whether to apply strict (LaTeX-adhering) behavior for unusual + * input (like `\\`). Unlike `nonstrict`, will not throw an error; + * instead, "error" translates to a return value of `true`, while "ignore" + * translates to a return value of `false`. May still print a warning: + * "warn" prints a warning and returns `false`. + * This is for the second category of `errorCode`s listed in the README. + */ + useStrictBehavior(errorCode: string, errorMsg: string, + token?: Token | AnyParseNode): boolean { + let strict: Settings["strict"] | ReturnType = this.strict; + if (typeof strict === "function") { + // Allow return value of strict function to be boolean or string + // (or null/undefined, meaning no further processing). + // But catch any exceptions thrown by function, treating them + // like "error". + try { + strict = strict(errorCode, errorMsg, token); + } catch (error) { + strict = "error"; + } + } + if (!strict || strict === "ignore") { + return false; + } else if (strict === true || strict === "error") { + return true; + } else if (strict === "warn") { + typeof console !== "undefined" && console.warn( + "LaTeX-incompatible input and strict mode is set to 'warn': " + + `${errorMsg} [${errorCode}]`); + return false; + } else { // won't happen in type-safe code + typeof console !== "undefined" && console.warn( + "LaTeX-incompatible input and strict mode is set to " + + `unrecognized '${strict}': ${errorMsg} [${errorCode}]`); + return false; + } + } + + /** + * Check whether to test potentially dangerous input, and return + * `true` (trusted) or `false` (untrusted). The sole argument `context` + * should be an object with `command` field specifying the relevant LaTeX + * command (as a string starting with `\`), and any other arguments, etc. + * If `context` has a `url` field, a `protocol` field will automatically + * get added by this function (changing the specified object). + */ + isTrusted(context: AnyTrustContext): boolean { + if ("url" in context && context.url && !context.protocol) { + const protocol = protocolFromUrl(context.url); + if (protocol == null) { + return false; + } + context.protocol = protocol; + } + const trust = typeof this.trust === "function" + ? this.trust(context) + : this.trust; + return Boolean(trust); + } +} diff --git a/node_modules/katex/src/SourceLocation.ts b/node_modules/katex/src/SourceLocation.ts new file mode 100644 index 0000000..0cda454 --- /dev/null +++ b/node_modules/katex/src/SourceLocation.ts @@ -0,0 +1,41 @@ +import type {LexerInterface} from "./Token"; + +/** + * Lexing or parsing positional information for error reporting. + * This object is immutable. + */ +export default class SourceLocation { + // The + prefix indicates that these fields aren't writeable + readonly lexer: LexerInterface; // Lexer holding the input string. + readonly start: number; // Start offset, zero-based inclusive. + readonly end: number; // End offset, zero-based exclusive. + + constructor(lexer: LexerInterface, start: number, end: number) { + this.lexer = lexer; + this.start = start; + this.end = end; + } + + /** + * Merges two `SourceLocation`s from location providers, given they are + * provided in order of appearance. + * - Returns the first one's location if only the first is provided. + * - Returns a merged range of the first and the last if both are provided + * and their lexers match. + * - Otherwise, returns null. + */ + static range( + first: {loc?: SourceLocation | null}, + second?: {loc?: SourceLocation | null}, + ): SourceLocation | null | undefined { + if (!second) { + return first && first.loc; + } else if (!first || !first.loc || !second.loc || + first.loc.lexer !== second.loc.lexer) { + return null; + } else { + return new SourceLocation( + first.loc.lexer, first.loc.start, second.loc.end); + } + } +} diff --git a/node_modules/katex/src/Style.ts b/node_modules/katex/src/Style.ts new file mode 100644 index 0000000..4926258 --- /dev/null +++ b/node_modules/katex/src/Style.ts @@ -0,0 +1,129 @@ +/** + * This file contains information and classes for the various kinds of styles + * used in TeX. It provides a generic `Style` class, which holds information + * about a specific style. It then provides instances of all the different kinds + * of styles possible, and provides functions to move between them and get + * information about them. + */ + +/** + * The main style class. Contains a unique id for the style, a size (which is + * the same for cramped and uncramped version of a style), and a cramped flag. + */ +class Style implements StyleInterface { + id: number; + size: number; + cramped: boolean; + + constructor(id: number, size: number, cramped: boolean) { + this.id = id; + this.size = size; + this.cramped = cramped; + } + + /** + * Get the style of a superscript given a base in the current style. + */ + sup(): Style { + return styles[sup[this.id]]; + } + + /** + * Get the style of a subscript given a base in the current style. + */ + sub(): Style { + return styles[sub[this.id]]; + } + + /** + * Get the style of a fraction numerator given the fraction in the current + * style. + */ + fracNum(): Style { + return styles[fracNum[this.id]]; + } + + /** + * Get the style of a fraction denominator given the fraction in the current + * style. + */ + fracDen(): Style { + return styles[fracDen[this.id]]; + } + + /** + * Get the cramped version of a style (in particular, cramping a cramped style + * doesn't change the style). + */ + cramp(): Style { + return styles[cramp[this.id]]; + } + + /** + * Get a text or display version of this style. + */ + text(): Style { + return styles[text[this.id]]; + } + + /** + * Return true if this style is tightly spaced (scriptstyle/scriptscriptstyle) + */ + isTight(): boolean { + return this.size >= 2; + } +} + +// Export an interface for type checking, but don't expose the implementation. +// This way, no more styles can be generated. +export interface StyleInterface { + id: number; + size: number; + cramped: boolean; + + sup(): StyleInterface; + sub(): StyleInterface; + fracNum(): StyleInterface; + fracDen(): StyleInterface; + cramp(): StyleInterface; + text(): StyleInterface; + isTight(): boolean; +} + +// IDs of the different styles +const D = 0; +const Dc = 1; +const T = 2; +const Tc = 3; +const S = 4; +const Sc = 5; +const SS = 6; +const SSc = 7; + +// Instances of the different styles +const styles = [ + new Style(D, 0, false), + new Style(Dc, 0, true), + new Style(T, 1, false), + new Style(Tc, 1, true), + new Style(S, 2, false), + new Style(Sc, 2, true), + new Style(SS, 3, false), + new Style(SSc, 3, true), +]; + +// Lookup tables for switching from one style to another +const sup = [S, Sc, S, Sc, SS, SSc, SS, SSc]; +const sub = [Sc, Sc, Sc, Sc, SSc, SSc, SSc, SSc]; +const fracNum = [T, Tc, S, Sc, SS, SSc, SS, SSc]; +const fracDen = [Tc, Tc, Sc, Sc, SSc, SSc, SSc, SSc]; +const cramp = [Dc, Dc, Tc, Tc, Sc, Sc, SSc, SSc]; +const text = [D, Dc, T, Tc, T, Tc, T, Tc]; + +// We only export some of the styles. +export default { + DISPLAY: (styles[D] as Style), + TEXT: (styles[T] as Style), + SCRIPT: (styles[S] as Style), + SCRIPTSCRIPT: (styles[SS] as Style), +}; diff --git a/node_modules/katex/src/Token.ts b/node_modules/katex/src/Token.ts new file mode 100644 index 0000000..78cee4f --- /dev/null +++ b/node_modules/katex/src/Token.ts @@ -0,0 +1,49 @@ +import SourceLocation from "./SourceLocation"; + +/** + * Interface required to break circular dependency between Token, Lexer, and + * ParseError. + */ +export interface LexerInterface { + input: string; + tokenRegex: RegExp; +} + +/** + * The resulting token returned from `lex`. + * + * It consists of the token text plus some position information. + * The position information is essentially a range in an input string, + * but instead of referencing the bare input string, we refer to the lexer. + * That way it is possible to attach extra metadata to the input string, + * like for example a file name or similar. + * + * The position information is optional, so it is OK to construct synthetic + * tokens if appropriate. Not providing available position information may + * lead to degraded error reporting, though. + */ +export class Token { + text: string; + loc: SourceLocation | null | undefined; + noexpand: boolean | null | undefined; // don't expand the token + treatAsRelax: boolean | null | undefined; // used in \noexpand + + constructor( + text: string, // the text of this token + loc?: SourceLocation | null | undefined, + ) { + this.text = text; + this.loc = loc; + } + + /** + * Given a pair of tokens (this and endToken), compute a `Token` encompassing + * the whole input range enclosed by these two. + */ + range( + endToken: Token, // last token of the range, inclusive + text: string, // the text of the newly constructed token + ): Token { + return new Token(text, SourceLocation.range(this, endToken)); + } +} diff --git a/node_modules/katex/src/atoms.ts b/node_modules/katex/src/atoms.ts new file mode 100644 index 0000000..b7fa920 --- /dev/null +++ b/node_modules/katex/src/atoms.ts @@ -0,0 +1,33 @@ +/** + * Small module for atom-group constants and type guard. Kept separate from + * `symbols.ts` so that consumers (notably `contrib/render-a11y-string`) can + * pull in `isAtom` without dragging in the ~870-line symbol tables. + */ + +// Some of these have a "-token" suffix since these are also used as `ParseNode` +// types for raw text tokens, and we want to avoid conflicts with higher-level +// `ParseNode` types. These `ParseNode`s are constructed within `Parser` by +// looking up the `symbols` map. +export const ATOMS = { + "bin": 1, + "close": 1, + "inner": 1, + "open": 1, + "punct": 1, + "rel": 1, +}; +export const NON_ATOMS = { + "accent-token": 1, + "mathord": 1, + "op-token": 1, + "spacing": 1, + "textord": 1, +}; + +export type Atom = keyof typeof ATOMS; +export type NonAtom = keyof typeof NON_ATOMS; +export type Group = Atom | NonAtom; + +export function isAtom(value: string): value is Atom { + return value in ATOMS; +} diff --git a/node_modules/katex/src/buildCommon.ts b/node_modules/katex/src/buildCommon.ts new file mode 100644 index 0000000..8e3e1e3 --- /dev/null +++ b/node_modules/katex/src/buildCommon.ts @@ -0,0 +1,783 @@ +/* eslint no-console:0 */ +/** + * This module contains general functions that can be used for building + * different kinds of domTree nodes in a consistent manner. + */ + +import {SymbolNode, Anchor, Span, PathNode, SvgNode, createClass} from "./domTree"; +import {getCharacterMetrics} from "./fontMetrics"; +import symbols, {ligatures} from "./symbols"; +import {wideCharacterFont} from "./wide-character"; +import {calculateSize, makeEm} from "./units"; +import {DocumentFragment} from "./tree"; + +import type Options from "./Options"; +import type {Measurement, Mode} from "./types"; +import type {ParseNode} from "./types/nodes"; +import type {documentFragment as HtmlDocumentFragment} from "./domTree"; +import type {HtmlDomNode, DomSpan, SvgSpan, CssStyle} from "./domTree"; +import type { + CharacterMetrics, + FontName, + FontShape, + FontVariant, + FontWeight, + TextFont, +} from "./types/fonts"; + +/** + * Looks up the given symbol in fontMetrics, after applying any symbol + * replacements defined in symbol.js + */ +const lookupSymbol = function( + value: string, + fontName: FontName, + mode: Mode, +): { + value: string; + metrics: CharacterMetrics | null | undefined; +} { + // Replace the value with its replaced value from symbol.js + if (symbols[mode][value]) { + const replacement = symbols[mode][value].replace; + if (replacement) { + value = replacement; + } + } + + return { + value, + metrics: getCharacterMetrics(value, fontName, mode), + }; +}; + +/** + * Makes a symbolNode after translation via the list of symbols in symbols.js. + * Correctly pulls out metrics for the character, and optionally takes a list of + * classes to be attached to the node. + * + * TODO: make argument order closer to makeSpan + * TODO: add a separate argument for math class (e.g. `mop`, `mbin`), which + * should if present come first in `classes`. + * TODO(#953): Make `options` mandatory and always pass it in. + */ +export const makeSymbol = function( + value: string, + fontName: FontName, + mode: Mode, + options?: Options, + classes?: string[], +): SymbolNode { + const lookup = lookupSymbol(value, fontName, mode); + const metrics = lookup.metrics; + value = lookup.value; + + let symbolNode; + if (metrics) { + let italic = metrics.italic; + if (mode === "text" || (options && options.font === "mathit")) { + italic = 0; + } + symbolNode = new SymbolNode( + value, metrics.height, metrics.depth, italic, metrics.skew, + metrics.width, classes); + } else { + // TODO(emily): Figure out a good way to only print this in development + typeof console !== "undefined" && console.warn("No character metrics " + + `for '${value}' in style '${fontName}' and mode '${mode}'`); + symbolNode = new SymbolNode(value, 0, 0, 0, 0, 0, classes); + } + + if (options) { + symbolNode.maxFontSize = options.sizeMultiplier; + if (options.style.isTight()) { + symbolNode.classes.push("mtight"); + } + const color = options.getColor(); + if (color) { + symbolNode.style.color = color; + } + } + + return symbolNode; +}; + +/** + * Makes a symbol in Main-Regular or AMS-Regular. + * Used for rel, bin, open, close, inner, and punct. + */ +export const mathsym = function( + value: string, + mode: Mode, + options: Options, + classes: string[] = [], +): SymbolNode { + // Decide what font to render the symbol in by its entry in the symbols + // table. + // Have a special case for when the value = \ because the \ is used as a + // textord in unsupported command errors but cannot be parsed as a regular + // text ordinal and is therefore not present as a symbol in the symbols + // table for text, as well as a special case for boldsymbol because it + // can be used for bold + and - + if (options.font === "boldsymbol" && + lookupSymbol(value, "Main-Bold", mode).metrics) { + return makeSymbol(value, "Main-Bold", mode, options, + classes.concat(["mathbf"])); + } else if (value === "\\" || symbols[mode][value].font === "main") { + return makeSymbol(value, "Main-Regular", mode, options, classes); + } else { + return makeSymbol( + value, "AMS-Regular", mode, options, classes.concat(["amsrm"])); + } +}; + +/** + * Determines which of the two font names (Main-Bold and Math-BoldItalic) and + * corresponding style tags (mathbf or boldsymbol) to use for font "boldsymbol", + * depending on the symbol. Use this function instead of fontMap for font + * "boldsymbol". + */ +const boldSymbol = function( + value: string, + mode: Mode, + type: "mathord" | "textord", +): { + fontName: "Math-BoldItalic" | "Main-Bold"; + fontClass: "boldsymbol" | "mathbf"; +} { + if ( + type !== "textord" && + lookupSymbol(value, "Math-BoldItalic", mode).metrics + ) { + return { + fontName: "Math-BoldItalic", + fontClass: "boldsymbol", + }; + } else { + // Some glyphs do not exist in Math-BoldItalic so we need to use + // Main-Bold instead. + return { + fontName: "Main-Bold", + fontClass: "mathbf", + }; + } +}; + +/** + * Makes either a mathord or textord in the correct font and color. + */ +export const makeOrd = function( + group: ParseNode<"spacing"> | ParseNode<"mathord"> | ParseNode<"textord">, + options: Options, +): HtmlDocumentFragment | SymbolNode { + // Spacing nodes are rendered as textord. + const type: "mathord" | "textord" = group.type === "mathord" ? "mathord" : "textord"; + const mode = group.mode; + const text = group.text; + const classes = ["mord"]; + const {font, fontFamily, fontWeight, fontShape} = options; + + // Math mode or Old font (i.e. \rm) + const useFont = mode === "math" || (mode === "text" && !!font); + const fontOrFamily = useFont ? font : fontFamily; + let wideFontName: FontName | "" = ""; + let wideFontClass = ""; + if (text.charCodeAt(0) === 0xD835) { + const wideCharData = wideCharacterFont(text); + wideFontName = wideCharData.font; + wideFontClass = wideCharData[`${mode}Class`]; + } + if (wideFontName) { + // surrogate pairs get special treatment + return makeSymbol(text, wideFontName, mode, options, classes.concat(wideFontClass)); + } else if (fontOrFamily) { + let fontName; + let fontClasses; + if (fontOrFamily === "boldsymbol") { + const fontData = boldSymbol(text, mode, type); + fontName = fontData.fontName; + fontClasses = [fontData.fontClass]; + } else if (useFont) { + fontName = fontMap[font].fontName; + fontClasses = [font]; + } else { + fontName = retrieveTextFontName( + fontFamily, + fontWeight, + fontShape, + ); + fontClasses = [fontFamily, fontWeight, fontShape]; + } + + if (lookupSymbol(text, fontName, mode).metrics) { + return makeSymbol(text, fontName, mode, options, + classes.concat(fontClasses)); + } else if (ligatures.hasOwnProperty(text) && + fontName.slice(0, 10) === "Typewriter") { + // Deconstruct ligatures in monospace fonts (\texttt, \tt). + const parts = []; + for (let i = 0; i < text.length; i++) { + parts.push(makeSymbol(text[i], fontName, mode, options, + classes.concat(fontClasses))); + } + return makeFragment(parts); + } + } + + // Makes a symbol in the default font for mathords and textords. + if (type === "mathord") { + return makeSymbol(text, "Math-Italic", mode, options, + classes.concat(["mathnormal"])); + } else if (type === "textord") { + const font = symbols[mode][text] && symbols[mode][text].font; + if (font === "ams") { + const fontName = retrieveTextFontName("amsrm", fontWeight, fontShape); + return makeSymbol( + text, fontName, mode, options, + classes.concat("amsrm", fontWeight, fontShape)); + } else if (font === "main" || !font) { + const fontName = retrieveTextFontName("textrm", fontWeight, fontShape); + return makeSymbol( + text, fontName, mode, options, + classes.concat(fontWeight, fontShape)); + } else { // fonts added by plugins + const fontName = retrieveTextFontName(font, fontWeight, fontShape); + // We add font name as a css class + return makeSymbol( + text, fontName, mode, options, + classes.concat(fontName, fontWeight, fontShape)); + } + } else { + throw new Error("unexpected type: " + type + " in makeOrd"); + } +}; + +/** + * Returns true if subsequent symbolNodes have the same classes, skew, maxFont, + * and styles. For mathnormal text, the left node must also have zero italic + * correction so we don't lose spacing between combined glyphs. + */ +const canCombine = (prev: SymbolNode, next: SymbolNode) => { + if (createClass(prev.classes) !== createClass(next.classes) + || prev.skew !== next.skew + || prev.maxFontSize !== next.maxFontSize + || (prev.italic !== 0 && prev.hasClass("mathnormal"))) { + return false; + } + + // If prev and next both are just "mbin"s or "mord"s we don't combine them + // so that the proper spacing can be preserved. + if (prev.classes.length === 1) { + const cls = prev.classes[0]; + if (cls === "mbin" || cls === "mord") { + return false; + } + } + + for (const key of Object.keys(prev.style) as Array) { + if (prev.style[key] !== next.style[key]) { + return false; + } + } + + for (const key of Object.keys(next.style) as Array) { + if (prev.style[key] !== next.style[key]) { + return false; + } + } + + return true; +}; + +/** + * Combine consecutive domTree.symbolNodes into a single symbolNode. + * Note: this function mutates the argument. + */ +export const tryCombineChars = (chars: HtmlDomNode[]): HtmlDomNode[] => { + for (let i = 0; i < chars.length - 1; i++) { + const prev = chars[i]; + const next = chars[i + 1]; + if (prev instanceof SymbolNode + && next instanceof SymbolNode + && canCombine(prev, next)) { + + prev.text += next.text; + prev.height = Math.max(prev.height, next.height); + prev.depth = Math.max(prev.depth, next.depth); + // Use the last character's italic correction since we use + // it to add padding to the right of the span created from + // the combined characters. + prev.italic = next.italic; + chars.splice(i + 1, 1); + i--; + } + } + return chars; +}; + +/** + * Calculate the height, depth, and maxFontSize of an element based on its + * children. + */ +const sizeElementFromChildren = function( + elem: DomSpan | Anchor | HtmlDocumentFragment, +) { + let height = 0; + let depth = 0; + let maxFontSize = 0; + + for (let i = 0; i < elem.children.length; i++) { + const child = elem.children[i]; + if (child.height > height) { + height = child.height; + } + if (child.depth > depth) { + depth = child.depth; + } + if (child.maxFontSize > maxFontSize) { + maxFontSize = child.maxFontSize; + } + } + + elem.height = height; + elem.depth = depth; + elem.maxFontSize = maxFontSize; +}; + +/** + * Makes a span with the given list of classes, list of children, and options. + * + * TODO(#953): Ensure that `options` is always provided (currently some call + * sites don't pass it) and make the type below mandatory. + * TODO: add a separate argument for math class (e.g. `mop`, `mbin`), which + * should if present come first in `classes`. + */ +export const makeSpan = function( + classes?: string[], + children?: HtmlDomNode[], + options?: Options, + style?: CssStyle, +): DomSpan { + const span = new Span(classes, children, options, style); + + sizeElementFromChildren(span); + + return span; +}; + +// SVG one is simpler -- doesn't require height, depth, max-font setting. +// This is also a separate method for typesafety. +export const makeSvgSpan = ( + classes?: string[], + children?: SvgNode[], + options?: Options, + style?: CssStyle, +): SvgSpan => new Span(classes, children, options, style); + +export const makeLineSpan = function( + className: string, + options: Options, + thickness?: number, +): DomSpan { + const line = makeSpan([className], [], options); + line.height = Math.max( + thickness || options.fontMetrics().defaultRuleThickness, + options.minRuleThickness, + ); + line.style.borderBottomWidth = makeEm(line.height); + line.maxFontSize = 1.0; + return line; +}; + +/** + * Makes an anchor with the given href, list of classes, list of children, + * and options. + */ +export const makeAnchor = function( + href: string, + classes: string[], + children: HtmlDomNode[], + options: Options, +): Anchor { + const anchor = new Anchor(href, classes, children, options); + + sizeElementFromChildren(anchor); + + return anchor; +}; + +/** + * Makes a document fragment with the given list of children. + */ +export const makeFragment = function( + children: HtmlDomNode[], +): HtmlDocumentFragment { + const fragment = new DocumentFragment(children); + + sizeElementFromChildren(fragment); + + return fragment; +}; + +/** + * Wraps group in a span if it's a document fragment, allowing to apply classes + * and styles + */ +export const wrapFragment = function( + group: HtmlDomNode, + options: Options, +): HtmlDomNode { + if (group instanceof DocumentFragment) { + return makeSpan([], [group], options); + } + return group; +}; + +export type VListElem = { + type: "elem"; + elem: HtmlDomNode; + marginLeft?: string | null | undefined; + marginRight?: string; + wrapperClasses?: string[]; + wrapperStyle?: CssStyle; +}; +type VListElemAndShift = { + type: "elem"; + elem: HtmlDomNode; + shift: number; + marginLeft?: string | null | undefined; + marginRight?: string; + wrapperClasses?: string[]; + wrapperStyle?: CssStyle; +}; +type VListKern = { + type: "kern"; + size: number; +}; + +// A list of child or kern nodes to be stacked on top of each other (i.e. the +// first element will be at the bottom, and the last at the top). +type VListChild = VListElem | VListKern; +type VListParam = { + // Each child contains how much it should be shifted downward. + positionType: "individualShift"; + children: VListElemAndShift[]; +} | { + // "top": The positionData specifies the topmost point of the vlist (note this + // is expected to be a height, so positive values move up). + // "bottom": The positionData specifies the bottommost point of the vlist (note + // this is expected to be a depth, so positive values move down). + // "shift": The vlist will be positioned such that its baseline is positionData + // away from the baseline of the first child which MUST be an + // "elem". Positive values move downwards. + positionType: "top" | "bottom" | "shift"; + positionData: number; + children: VListChild[]; +} | { + // The vlist is positioned so that its baseline is aligned with the baseline + // of the first child which MUST be an "elem". This is equivalent to "shift" + // with positionData=0. + positionType: "firstBaseline"; + children: VListChild[]; +}; + +// Computes the updated `children` list and the overall depth. +// +// This helper function for makeVList makes it easier to enforce type safety by +// allowing early exits (returns) in the logic. +const getVListChildrenAndDepth = function(params: VListParam): { + children: (VListChild | VListElemAndShift)[] | VListChild[]; + depth: number; +} { + if (params.positionType === "individualShift") { + const oldChildren = params.children; + const children: (VListChild | VListElemAndShift)[] = [oldChildren[0]]; + + // Add in kerns to the list of params.children to get each element to be + // shifted to the correct specified shift + const depth = -oldChildren[0].shift - oldChildren[0].elem.depth; + let currPos = depth; + for (let i = 1; i < oldChildren.length; i++) { + const diff = -oldChildren[i].shift - currPos - + oldChildren[i].elem.depth; + const size = diff - + (oldChildren[i - 1].elem.height + + oldChildren[i - 1].elem.depth); + + currPos = currPos + diff; + children.push({type: "kern", size}); + children.push(oldChildren[i]); + } + + return {children, depth}; + } + + let depth; + if (params.positionType === "top") { + // We always start at the bottom, so calculate the bottom by adding up + // all the sizes + let bottom = params.positionData; + for (let i = 0; i < params.children.length; i++) { + const child = params.children[i]; + bottom -= child.type === "kern" + ? child.size + : child.elem.height + child.elem.depth; + } + depth = bottom; + } else if (params.positionType === "bottom") { + depth = -params.positionData; + } else { + const firstChild = params.children[0]; + if (firstChild.type !== "elem") { + throw new Error('First child must have type "elem".'); + } + if (params.positionType === "shift") { + depth = -firstChild.elem.depth - params.positionData; + } else if (params.positionType === "firstBaseline") { + depth = -firstChild.elem.depth; + } else { + throw new Error(`Invalid positionType ${params.positionType}.`); + } + } + + return {children: params.children, depth}; +}; + +/** + * Makes a vertical list by stacking elements and kerns on top of each other. + * Allows for many different ways of specifying the positioning method. + * + * See VListParam documentation above. + */ +export const makeVList = function(params: VListParam, options: Options): DomSpan { + const {children, depth} = getVListChildrenAndDepth(params); + + // Create a strut that is taller than any list item. The strut is added to + // each item, where it will determine the item's baseline. Since it has + // `overflow:hidden`, the strut's top edge will sit on the item's line box's + // top edge and the strut's bottom edge will sit on the item's baseline, + // with no additional line-height spacing. This allows the item baseline to + // be positioned precisely without worrying about font ascent and + // line-height. + let pstrutSize = 0; + for (let i = 0; i < children.length; i++) { + const child = children[i]; + if (child.type === "elem") { + const elem = child.elem; + pstrutSize = Math.max(pstrutSize, elem.maxFontSize, elem.height); + } + } + pstrutSize += 2; + const pstrut = makeSpan(["pstrut"], []); + pstrut.style.height = makeEm(pstrutSize); + + // Create a new list of actual children at the correct offsets + const realChildren = []; + let minPos = depth; + let maxPos = depth; + let currPos = depth; + for (let i = 0; i < children.length; i++) { + const child = children[i]; + if (child.type === "kern") { + currPos += child.size; + } else { + const elem = child.elem; + const classes = child.wrapperClasses || []; + const style = child.wrapperStyle || {}; + + const childWrap = makeSpan(classes, [pstrut, elem], undefined, style); + childWrap.style.top = makeEm(-pstrutSize - currPos - elem.depth); + if (child.marginLeft) { + childWrap.style.marginLeft = child.marginLeft; + } + if (child.marginRight) { + childWrap.style.marginRight = child.marginRight; + } + + realChildren.push(childWrap); + currPos += elem.height + elem.depth; + } + minPos = Math.min(minPos, currPos); + maxPos = Math.max(maxPos, currPos); + } + + // The vlist contents go in a table-cell with `vertical-align:bottom`. + // This cell's bottom edge will determine the containing table's baseline + // without overly expanding the containing line-box. + const vlist = makeSpan(["vlist"], realChildren); + vlist.style.height = makeEm(maxPos); + + // A second row is used if necessary to represent the vlist's depth. + let rows; + if (minPos < 0) { + // We will define depth in an empty span with display: table-cell. + // It should render with the height that we define. But Chrome, in + // contenteditable mode only, treats that span as if it contains some + // text content. And that min-height over-rides our desired height. + // So we put another empty span inside the depth strut span. + const emptySpan = makeSpan([], []); + const depthStrut = makeSpan(["vlist"], [emptySpan]); + depthStrut.style.height = makeEm(-minPos); + + // Safari wants the first row to have inline content; otherwise it + // puts the bottom of the *second* row on the baseline. + const topStrut = makeSpan(["vlist-s"], [new SymbolNode("\u200b")]); + + rows = [makeSpan(["vlist-r"], [vlist, topStrut]), + makeSpan(["vlist-r"], [depthStrut])]; + } else { + rows = [makeSpan(["vlist-r"], [vlist])]; + } + + const vtable = makeSpan(["vlist-t"], rows); + if (rows.length === 2) { + vtable.classes.push("vlist-t2"); + } + vtable.height = maxPos; + vtable.depth = -minPos; + return vtable; +}; + +// Glue is a concept from TeX which is a flexible space between elements in +// either a vertical or horizontal list. In KaTeX, at least for now, it's +// static space between elements in a horizontal layout. +export const makeGlue = (measurement: Measurement, options: Options): DomSpan => { + // Make an empty span for the space + const rule = makeSpan(["mspace"], [], options); + const size = calculateSize(measurement, options); + rule.style.marginRight = makeEm(size); + return rule; +}; + +// Takes font options, and returns the appropriate fontLookup name +const retrieveTextFontName = ( + fontFamily: TextFont, + fontWeight: FontWeight, + fontShape: FontShape, +): FontName => { + let baseFontName: "AMS" | "Main" | "SansSerif" | "Typewriter" | TextFont; + let fontStylesName: "BoldItalic" | "Bold" | "Italic" | "Regular"; + + switch (fontFamily) { + case "amsrm": + baseFontName = "AMS"; + break; + case "textrm": + baseFontName = "Main"; + break; + case "textsf": + baseFontName = "SansSerif"; + break; + case "texttt": + baseFontName = "Typewriter"; + break; + default: + baseFontName = fontFamily; // use fonts added by a plugin + } + + if (fontWeight === "textbf" && fontShape === "textit") { + fontStylesName = "BoldItalic"; + } else if (fontWeight === "textbf") { + fontStylesName = "Bold"; + } else if (fontShape === "textit") { + fontStylesName = "Italic"; + } else { + fontStylesName = "Regular"; + } + + return `${baseFontName}-${fontStylesName}` as FontName; +}; + +/** + * Maps TeX font commands to objects containing: + * - variant: string used for "mathvariant" attribute in buildMathML.js + * - fontName: the "style" parameter to fontMetrics.getCharacterMetrics + */ +// A map between tex font commands an MathML mathvariant attribute values +export const fontMap: Record = { + // styles + "mathbf": { + variant: "bold", + fontName: "Main-Bold", + }, + "mathrm": { + variant: "normal", + fontName: "Main-Regular", + }, + "textit": { + variant: "italic", + fontName: "Main-Italic", + }, + "mathit": { + variant: "italic", + fontName: "Main-Italic", + }, + "mathnormal": { + variant: "italic", + fontName: "Math-Italic", + }, + "mathsfit": { + variant: "sans-serif-italic", + fontName: "SansSerif-Italic", + }, + // "boldsymbol" is missing because they require the use of multiple fonts: + // Math-BoldItalic and Main-Bold. This is handled by a special case in + // makeOrd which ends up calling boldsymbol. + + // families + "mathbb": { + variant: "double-struck", + fontName: "AMS-Regular", + }, + "mathcal": { + variant: "script", + fontName: "Caligraphic-Regular", + }, + "mathfrak": { + variant: "fraktur", + fontName: "Fraktur-Regular", + }, + "mathscr": { + variant: "script", + fontName: "Script-Regular", + }, + "mathsf": { + variant: "sans-serif", + fontName: "SansSerif-Regular", + }, + "mathtt": { + variant: "monospace", + fontName: "Typewriter-Regular", + }, +}; + +export const svgData: Record = { + // path, width, height + vec: ["vec", 0.471, 0.714], // values from the font glyph + oiintSize1: ["oiintSize1", 0.957, 0.499], // oval to overlay the integrand + oiintSize2: ["oiintSize2", 1.472, 0.659], + oiiintSize1: ["oiiintSize1", 1.304, 0.499], + oiiintSize2: ["oiiintSize2", 1.98, 0.659], +}; + +export const staticSvg = function(value: string, options: Options): SvgSpan { + // Create a span with inline SVG for the element. + const [pathName, width, height] = svgData[value]; + const path = new PathNode(pathName); + const svgNode = new SvgNode([path], { + "width": makeEm(width), + "height": makeEm(height), + // Override CSS rule `.katex svg { width: 100% }` + "style": "width:" + makeEm(width), + "viewBox": "0 0 " + 1000 * width + " " + 1000 * height, + "preserveAspectRatio": "xMinYMin", + }); + const span = makeSvgSpan(["overlay"], [svgNode], options); + span.height = height; + span.style.height = makeEm(height); + span.style.width = makeEm(width); + return span; +}; diff --git a/node_modules/katex/src/buildHTML.ts b/node_modules/katex/src/buildHTML.ts new file mode 100644 index 0000000..aba7a26 --- /dev/null +++ b/node_modules/katex/src/buildHTML.ts @@ -0,0 +1,411 @@ +/** + * This file does the main work of building a domTree structure from a parse + * tree. The entry point is the `buildHTML` function, which takes a parse tree. + * Then, the buildExpression, buildGroup, and various groupBuilders functions + * are called, to produce a final HTML tree. + */ + +import ParseError from "./ParseError"; +import Style from "./Style"; +import {makeGlue, makeSpan, tryCombineChars} from "./buildCommon"; +import type {DomSpan, HtmlDomNode} from "./domTree"; +import {Anchor, Span} from "./domTree"; +import {makeEm} from "./units"; +import {spacings, tightSpacings} from "./spacingData"; +import {_htmlGroupBuilders as groupBuilders} from "./defineFunction"; +import {DocumentFragment} from "./tree"; + +import type Options from "./Options"; +import type {AnyParseNode} from "./types/nodes"; +import type {Side} from "./types"; + +// Binary atoms (first class `mbin`) change into ordinary atoms (`mord`) +// depending on their surroundings. See TeXbook pg. 442-446, Rules 5 and 6, +// and the text before Rule 19. +const binLeftCanceller = new Set([ + "leftmost", "mbin", "mopen", "mrel", "mop", "mpunct", +]); +const binRightCanceller = new Set([ + "rightmost", "mrel", "mclose", "mpunct", +]); + +const styleMap = { + "display": Style.DISPLAY, + "text": Style.TEXT, + "script": Style.SCRIPT, + "scriptscript": Style.SCRIPTSCRIPT, +}; + +const DomEnum = { + mord: "mord", + mop: "mop", + mbin: "mbin", + mrel: "mrel", + mopen: "mopen", + mclose: "mclose", + mpunct: "mpunct", + minner: "minner", +}; +type DomType = keyof typeof DomEnum; + +/** + * Take a list of nodes, build them in order, and return a list of the built + * nodes. documentFragments are flattened into their contents, so the + * returned list contains no fragments. `isRealGroup` is true if `expression` + * is a real group (no atoms will be added on either side), as opposed to + * a partial group (e.g. one created by \color). `surrounding` is an array + * consisting type of nodes that will be added to the left and right. + */ +export const buildExpression = function( + expression: AnyParseNode[], + options: Options, + isRealGroup: boolean | "root", + surrounding: [DomType | null | undefined, DomType | null | undefined] = [null, null], +): HtmlDomNode[] { + // Parse expressions into `groups`. + const groups: HtmlDomNode[] = []; + for (let i = 0; i < expression.length; i++) { + const output = buildGroup(expression[i], options); + if (output instanceof DocumentFragment) { + const children: ReadonlyArray = output.children; + groups.push(...children); + } else { + groups.push(output); + } + } + + // Combine consecutive domTree.symbolNodes into a single symbolNode. + tryCombineChars(groups); + + // If `expression` is a partial group, let the parent handle spacings + // to avoid processing groups multiple times. + if (!isRealGroup) { + return groups; + } + + let glueOptions = options; + if (expression.length === 1) { + const node = expression[0]; + if (node.type === "sizing") { + glueOptions = options.havingSize(node.size); + } else if (node.type === "styling") { + glueOptions = options.havingStyle(styleMap[node.style]); + } + } + + // Dummy spans for determining spacings between surrounding atoms. + // If `expression` has no atoms on the left or right, class "leftmost" + // or "rightmost", respectively, is used to indicate it. + const dummyPrev = makeSpan([surrounding[0] || "leftmost"], [], options); + const dummyNext = makeSpan([surrounding[1] || "rightmost"], [], options); + + // TODO: These code assumes that a node's math class is the first element + // of its `classes` array. A later cleanup should ensure this, for + // instance by changing the signature of `makeSpan`. + + // Before determining what spaces to insert, perform bin cancellation. + // Binary operators change to ordinary symbols in some contexts. + const isRoot = (isRealGroup === "root"); + traverseNonSpaceNodes(groups, (node, prev): void => { + const prevType = prev.classes[0]; + const type = node.classes[0]; + if (prevType === "mbin" && binRightCanceller.has(type)) { + prev.classes[0] = "mord"; + } else if (type === "mbin" && binLeftCanceller.has(prevType)) { + node.classes[0] = "mord"; + } + }, {node: dummyPrev}, dummyNext, isRoot); + + traverseNonSpaceNodes(groups, (node, prev): HtmlDomNode | undefined => { + const prevType = getTypeOfDomTree(prev); + const type = getTypeOfDomTree(node); + + // 'mtight' indicates that the node is script or scriptscript style. + const space = prevType && type ? (node.hasClass("mtight") + ? tightSpacings[prevType]?.[type] + : spacings[prevType]?.[type]) : null; + + if (space) { // Insert glue (spacing) after the `prev`. + return makeGlue(space, glueOptions); + } + }, {node: dummyPrev}, dummyNext, isRoot); + + return groups; +}; + +// Depth-first traverse non-space `nodes`, calling `callback` with the current and +// previous node as arguments, optionally returning a node to insert after the +// previous node. `prev` is an object with the previous node and `insertAfter` +// function to insert after it. `next` is a node that will be added to the right. +// Used for bin cancellation and inserting spacings. +const traverseNonSpaceNodes = function( + nodes: HtmlDomNode[], + callback: (arg0: HtmlDomNode, arg1: HtmlDomNode) => + HtmlDomNode | null | void, + prev: { + node: HtmlDomNode, + insertAfter?: (arg0: HtmlDomNode) => void, + }, + next: HtmlDomNode | null | undefined, + isRoot: boolean, +) { + if (next) { // temporarily append the right node, if exists + nodes.push(next); + } + let i = 0; + for (; i < nodes.length; i++) { + const node = nodes[i]; + const partialGroup = checkPartialGroup(node); + + if (partialGroup) { // Recursive DFS + // TODO(ts): partialGroup.children is ReadonlyArray but this + // function mutates the array (insertAfter splices into it). + traverseNonSpaceNodes(partialGroup.children as HtmlDomNode[], + callback, prev, null, isRoot); + continue; + } + + // Ignore explicit spaces (e.g., \;, \,) when determining what implicit + // spacing should go between atoms of different classes + const nonspace = !node.hasClass("mspace"); + if (nonspace) { + const result = callback(node, prev.node); + if (result) { + if (prev.insertAfter) { + prev.insertAfter(result); + } else { // insert at front + nodes.unshift(result); + i++; + } + } + } + + if (nonspace) { + prev.node = node; + } else if (isRoot && node.hasClass("newline")) { + prev.node = makeSpan(["leftmost"]); // treat like beginning of line + } + prev.insertAfter = (index => n => { + nodes.splice(index + 1, 0, n); + i++; + })(i); + } + + if (next) { + nodes.pop(); + } +}; + +// Check if given node is a partial group, i.e., does not affect spacing around. +const checkPartialGroup = function( + node: HtmlDomNode, +): DocumentFragment | Anchor | DomSpan | null | undefined { + if (node instanceof DocumentFragment || node instanceof Anchor + || (node instanceof Span && node.hasClass("enclosing"))) { + return node; + } + return null; +}; + +// Return the outermost node of a domTree. +const getOutermostNode = function( + node: HtmlDomNode, + side: Side, +): HtmlDomNode { + const partialGroup = checkPartialGroup(node); + if (partialGroup) { + const children = partialGroup.children; + if (children.length) { + if (side === "right") { + return getOutermostNode(children[children.length - 1], "right"); + } else if (side === "left") { + return getOutermostNode(children[0], "left"); + } + } + } + return node; +}; + +// Return math atom class (mclass) of a domTree. +// If `side` is given, it will get the type of the outermost node at given side. +export const getTypeOfDomTree = function( + node: HtmlDomNode | null | undefined, + side?: Side | null | undefined, +): DomType | null | undefined { + if (!node) { + return null; + } + if (side) { + node = getOutermostNode(node, side); + } + // This makes a lot of assumptions as to where the type of atom + // appears. We should do a better job of enforcing this. + const className = node.classes[0] as keyof typeof DomEnum; + return (DomEnum[className] as DomType | undefined) || null; +}; +export const makeNullDelimiter = function( + options: Options, + classes: string[], +): DomSpan { + const moreClasses = ["nulldelimiter"].concat(options.baseSizingClasses()); + return makeSpan(classes.concat(moreClasses)); +}; + +/** + * buildGroup is the function that takes a group and calls the correct groupType + * function for it. It also handles the interaction of size and style changes + * between parents and children. + */ +export const buildGroup = function( + group: AnyParseNode | null | undefined, + options: Options, + baseOptions?: Options, +): HtmlDomNode { + if (!group) { + return makeSpan(); + } + + if (groupBuilders[group.type]) { + // TODO(ts): groupBuilders is Record>; + // a type-safe registry would need a mapped type keyed by NodeType. + let groupNode: HtmlDomNode = groupBuilders[group.type](group, options); + + // If the size changed between the parent and the current group, account + // for that size difference. + if (baseOptions && options.size !== baseOptions.size) { + groupNode = makeSpan(options.sizingClasses(baseOptions), + [groupNode], options); + + const multiplier = + options.sizeMultiplier / baseOptions.sizeMultiplier; + + groupNode.height *= multiplier; + groupNode.depth *= multiplier; + } + + return groupNode; + } else { + throw new ParseError( + "Got group of unknown type: '" + group.type + "'"); + } +}; + +/** + * Combine an array of HTML DOM nodes (e.g., the output of `buildExpression`) + * into an unbreakable HTML node of class .base, with proper struts to + * guarantee correct vertical extent. `buildHTML` calls this repeatedly to + * make up the entire expression as a sequence of unbreakable units. + */ +function buildHTMLUnbreakable(children: HtmlDomNode[], options: Options) { + // Compute height and depth of this chunk. + const body = makeSpan(["base"], children, options); + + // Add strut, which ensures that the top of the HTML element falls at + // the height of the expression, and the bottom of the HTML element + // falls at the depth of the expression. + const strut = makeSpan(["strut"]); + strut.style.height = makeEm(body.height + body.depth); + if (body.depth) { + strut.style.verticalAlign = makeEm(-body.depth); + } + body.children.unshift(strut); + + return body; +} + +/** + * Take an entire parse tree, and build it into an appropriate set of HTML + * nodes. + */ +export default function buildHTML(tree: AnyParseNode[], options: Options): DomSpan { + // Strip off outer tag wrapper for processing below. + let tag = null; + if (tree.length === 1 && tree[0].type === "tag") { + tag = tree[0].tag; + tree = tree[0].body; + } + + // Build the expression contained in the tree + const expression = buildExpression(tree, options, "root"); + + let eqnNum; + if (expression.length === 2 && expression[1].hasClass("tag")) { + // An environment with automatic equation numbers, e.g. {gather}. + eqnNum = expression.pop(); + } + + const children = []; + + // Create one base node for each chunk between potential line breaks. + // The TeXBook [p.173] says "A formula will be broken only after a + // relation symbol like $=$ or $<$ or $\rightarrow$, or after a binary + // operation symbol like $+$ or $-$ or $\times$, where the relation or + // binary operation is on the ``outer level'' of the formula (i.e., not + // enclosed in {...} and not part of an \over construction)." + + let parts = []; + for (let i = 0; i < expression.length; i++) { + parts.push(expression[i]); + if (expression[i].hasClass("mbin") || + expression[i].hasClass("mrel") || + expression[i].hasClass("allowbreak")) { + // Put any post-operator glue on same line as operator. + // Watch for \nobreak along the way, and stop at \newline. + let nobreak = false; + while (i < expression.length - 1 && + expression[i + 1].hasClass("mspace") && + !expression[i + 1].hasClass("newline")) { + i++; + parts.push(expression[i]); + if (expression[i].hasClass("nobreak")) { + nobreak = true; + } + } + // Don't allow break if \nobreak among the post-operator glue. + if (!nobreak) { + children.push(buildHTMLUnbreakable(parts, options)); + parts = []; + } + } else if (expression[i].hasClass("newline")) { + // Write the line except the newline + parts.pop(); + if (parts.length > 0) { + children.push(buildHTMLUnbreakable(parts, options)); + parts = []; + } + // Put the newline at the top level + children.push(expression[i]); + } + } + if (parts.length > 0) { + children.push(buildHTMLUnbreakable(parts, options)); + } + + // Now, if there was a tag, build it too and append it as a final child. + let tagChild; + if (tag) { + tagChild = buildHTMLUnbreakable( + buildExpression(tag, options, true), + options, + ); + tagChild.classes = ["tag"]; + children.push(tagChild); + } else if (eqnNum) { + children.push(eqnNum); + } + + const htmlNode = makeSpan(["katex-html"], children); + htmlNode.setAttribute("aria-hidden", "true"); + + // Adjust the strut of the tag to be the maximum height of all children + // (the height of the enclosing htmlNode) for proper vertical alignment. + if (tagChild) { + const strut = tagChild.children[0]; + strut.style.height = makeEm(htmlNode.height + htmlNode.depth); + if (htmlNode.depth) { + strut.style.verticalAlign = makeEm(-htmlNode.depth); + } + } + + return htmlNode; +} diff --git a/node_modules/katex/src/buildMathML.ts b/node_modules/katex/src/buildMathML.ts new file mode 100644 index 0000000..8668dfa --- /dev/null +++ b/node_modules/katex/src/buildMathML.ts @@ -0,0 +1,332 @@ +/** + * This file converts a parse tree into a corresponding MathML tree. The main + * entry point is the `buildMathML` function, which takes a parse tree from the + * parser. + */ + +import {fontMap, makeSpan} from "./buildCommon"; +import {getCharacterMetrics} from "./fontMetrics"; +import ParseError from "./ParseError"; +import symbols, {ligatures} from "./symbols"; +import {_mathmlGroupBuilders as groupBuilders} from "./defineFunction"; +import {MathNode, TextNode} from "./mathMLTree"; + +import type Options from "./Options"; +import type {DomSpan, HtmlDomNode} from "./domTree"; +import type {MathDomNode} from "./mathMLTree"; +import type {Mode} from "./types"; +import type {FontVariant, MathFont} from "./types/fonts"; +import type {AnyParseNode, SymbolParseNode} from "./types/nodes"; + +const noVariantSymbols = new Set(["\\imath", "\\jmath"]); +const rowLikeTypes = new Set(["mrow", "mtable"]); + +/** + * Takes a symbol and converts it into a MathML text node after performing + * optional replacement from symbols.js. + */ +export const makeText = function( + text: string, + mode: Mode, + options?: Options, +): TextNode { + if (symbols[mode][text] && symbols[mode][text].replace && + text.charCodeAt(0) !== 0xD835 && + !(ligatures.hasOwnProperty(text) && options && + ((options.fontFamily && options.fontFamily.slice(4, 6) === "tt") || + (options.font && options.font.slice(4, 6) === "tt")))) { + text = symbols[mode][text].replace!; + } + + return new TextNode(text); +}; + +/** + * Wrap the given array of nodes in an node if needed, i.e., + * unless the array has length 1. Always returns a single node. + */ +export const makeRow = function(body: MathDomNode[]): MathDomNode { + if (body.length === 1) { + return body[0]; + } else { + return new MathNode("mrow", body); + } +}; + +const mathFontVariants: Partial< + Record FontVariant)> +> = { + mathit: "italic", + boldsymbol: (group) => (group.type === "textord" ? "bold" : "bold-italic"), + mathbf: "bold", + mathbb: "double-struck", + mathsfit: "sans-serif-italic", + mathfrak: "fraktur", + mathscr: "script", + mathcal: "script", + mathsf: "sans-serif", + mathtt: "monospace", +}; + +/** + * Returns the math variant as a string or null if none is required. + */ +export const getVariant = ( + group: SymbolParseNode, + options: Options, +): FontVariant | null | undefined => { + // Handle \text... font specifiers as best we can. + // MathML has a limited list of allowable mathvariant specifiers; see + // https://www.w3.org/TR/MathML3/chapter3.html#presm.commatt + if (group.mode === "text") { + if (options.fontFamily === "texttt") { + return "monospace"; + } else if (options.fontFamily === "textsf") { + if (options.fontShape === "textit" && + options.fontWeight === "textbf") { + return "sans-serif-bold-italic"; + } else if (options.fontShape === "textit") { + return "sans-serif-italic"; + } else if (options.fontWeight === "textbf") { + return "bold-sans-serif"; + } else { + return "sans-serif"; + } + } else if (options.fontShape === "textit" && + options.fontWeight === "textbf") { + return "bold-italic"; + } else if (options.fontShape === "textit") { + return "italic"; + } else if (options.fontWeight === "textbf") { + return "bold"; + } + } + + const font = options.font; + if (!font || font === "mathnormal") { + return null; + } + + const mode = group.mode; + const mathVariant = mathFontVariants[font]; + + if (mathVariant) { + return typeof mathVariant === "function" + ? mathVariant(group) + : mathVariant; + } + + let text = group.text; + if (noVariantSymbols.has(text)) { + return null; + } + + if (symbols[mode][text]) { + const replacement = symbols[mode][text].replace; + if (replacement) { + text = replacement; + } + } + + const fontName = fontMap[font].fontName; + if (getCharacterMetrics(text, fontName, mode)) { + return fontMap[font].variant; + } + + return null; +}; + +/** + * Check for . which is how a dot renders in MathML, + * or , + * which is how a braced comma {,} renders in MathML + */ +function isNumberPunctuation(group: MathNode | null | undefined): boolean { + if (!group) { + return false; + } + if (group.type === 'mi' && group.children.length === 1) { + const child = group.children[0]; + return child instanceof TextNode && child.text === '.'; + } else if (group.type === 'mo' && group.children.length === 1 && + group.getAttribute('separator') === 'true' && + group.getAttribute('lspace') === '0em' && + group.getAttribute('rspace') === '0em' + ) { + const child = group.children[0]; + return child instanceof TextNode && child.text === ','; + } else { + return false; + } +} + +/** + * Takes a list of nodes, builds them, and returns a list of the generated + * MathML nodes. Also combine consecutive outputs into a single + * tag. + */ +export const buildExpression = function( + expression: AnyParseNode[], + options: Options, + isOrdgroup?: boolean, +): MathNode[] { + if (expression.length === 1) { + const group = buildGroup(expression[0], options); + if (isOrdgroup && group instanceof MathNode && group.type === "mo") { + // When TeX writers want to suppress spacing on an operator, + // they often put the operator by itself inside braces. + group.setAttribute("lspace", "0em"); + group.setAttribute("rspace", "0em"); + } + return [group]; + } + + const groups = []; + let lastGroup; + for (let i = 0; i < expression.length; i++) { + const group = buildGroup(expression[i], options); + if (group instanceof MathNode && lastGroup instanceof MathNode) { + // Concatenate adjacent s + if (group.type === 'mtext' && lastGroup.type === 'mtext' + && group.getAttribute('mathvariant') === + lastGroup.getAttribute('mathvariant')) { + lastGroup.children.push(...group.children); + continue; + // Concatenate adjacent s + } else if (group.type === 'mn' && lastGroup.type === 'mn') { + lastGroup.children.push(...group.children); + continue; + // Concatenate ... followed by . + } else if (isNumberPunctuation(group) && lastGroup.type === 'mn') { + lastGroup.children.push(...group.children); + continue; + // Concatenate . followed by ... + } else if (group.type === 'mn' && isNumberPunctuation(lastGroup)) { + group.children = [...lastGroup.children, ...group.children]; + groups.pop(); + // Put preceding ... or . inside base of + // ...base......exponent... (or ) + } else if ((group.type === 'msup' || group.type === 'msub') && + group.children.length >= 1 && + (lastGroup.type === 'mn' || isNumberPunctuation(lastGroup)) + ) { + const base = group.children[0]; + if (base instanceof MathNode && base.type === 'mn') { + base.children = [...lastGroup.children, ...base.children]; + groups.pop(); + } + // \not + } else if (lastGroup.type === 'mi' && lastGroup.children.length === 1) { + const lastChild = lastGroup.children[0]; + if (lastChild instanceof TextNode && lastChild.text === '\u0338' && + (group.type === 'mo' || group.type === 'mi' || + group.type === 'mn')) { + const child = group.children[0]; + if (child instanceof TextNode && child.text.length > 0) { + // Overlay with combining character long solidus + child.text = child.text.slice(0, 1) + "\u0338" + + child.text.slice(1); + groups.pop(); + } + } + } + } + groups.push(group); + lastGroup = group; + } + return groups; +}; + +/** + * Equivalent to buildExpression, but wraps the elements in an + * if there's more than one. Returns a single node instead of an array. + */ +export const buildExpressionRow = function( + expression: AnyParseNode[], + options: Options, + isOrdgroup?: boolean, +): MathDomNode { + return makeRow(buildExpression(expression, options, isOrdgroup)); +}; + +/** + * Takes a group from the parser and calls the appropriate groupBuilders function + * on it to produce a MathML node. + */ +export const buildGroup = function( + group: AnyParseNode | null | undefined, + options: Options, +): MathNode { + if (!group) { + return new MathNode("mrow"); + } + + if (groupBuilders[group.type]) { + // TODO(ts): MathMLBuilder returns MathDomNode but all concrete + // builders return MathNode. Widening the return type here would + // require updating all callers that assume MathNode. + return groupBuilders[group.type](group, options) as MathNode; + } else { + throw new ParseError( + "Got group of unknown type: '" + group.type + "'"); + } +}; + +/** + * Takes a full parse tree and settings and builds a MathML representation of + * it. In particular, we put the elements from building the parse tree into a + * tag so we can also include that TeX source as an annotation. + * + * Note that we actually return a domTree element with a `` inside it so + * we can do appropriate styling. + */ +export default function buildMathML( + tree: AnyParseNode[], + texExpression: string, + options: Options, + isDisplayMode: boolean, + forMathmlOnly: boolean, +): DomSpan { + const expression = buildExpression(tree, options); + + // TODO: Make a pass thru the MathML similar to buildHTML.traverseNonSpaceNodes + // and add spacing nodes. This is necessary only adjacent to math operators + // like \sin or \lim or to subsup elements that contain math operators. + // MathML takes care of the other spacing issues. + + // Wrap up the expression in an mrow so it is presented in the semantics + // tag correctly, unless it's a single or . + let wrapper; + if (expression.length === 1 && expression[0] instanceof MathNode && + rowLikeTypes.has(expression[0].type)) { + wrapper = expression[0]; + } else { + wrapper = new MathNode("mrow", expression); + } + + // Build a TeX annotation of the source + const annotation = new MathNode( + "annotation", [new TextNode(texExpression)]); + + annotation.setAttribute("encoding", "application/x-tex"); + + const semantics = new MathNode( + "semantics", [wrapper, annotation]); + + const math = new MathNode("math", [semantics]); + math.setAttribute("xmlns", "http://www.w3.org/1998/Math/MathML"); + if (isDisplayMode) { + math.setAttribute("display", "block"); + } + + // You can't style nodes, so we wrap the node in a span. + // NOTE: The span class is not typed to have nodes as children, and + // we don't want to make the children type more generic since the children + // of span are expected to have more fields in `buildHtml` contexts. + // The MathNode implements VirtualNode (toNode/toMarkup) which is all that + // Span needs from its children for rendering. + // TODO(ts): Span's child type is HtmlDomNode, but MathNode only implements + // VirtualNode. The double-cast acknowledges this architectural limitation. + const wrapperClass = forMathmlOnly ? "katex" : "katex-mathml"; + return makeSpan([wrapperClass], [math as unknown as HtmlDomNode]); +} diff --git a/node_modules/katex/src/buildTree.ts b/node_modules/katex/src/buildTree.ts new file mode 100644 index 0000000..41e81f0 --- /dev/null +++ b/node_modules/katex/src/buildTree.ts @@ -0,0 +1,66 @@ +import buildHTML from "./buildHTML"; +import buildMathML from "./buildMathML"; +import {makeSpan} from "./buildCommon"; +import Options from "./Options"; +import Settings from "./Settings"; +import Style from "./Style"; + +import type {AnyParseNode} from "./types/nodes"; +import type {DomSpan} from "./domTree"; + +const optionsFromSettings = function(settings: Settings) { + return new Options({ + style: (settings.displayMode ? Style.DISPLAY : Style.TEXT), + maxSize: settings.maxSize, + minRuleThickness: settings.minRuleThickness, + }); +}; + +const displayWrap = function(node: DomSpan, settings: Settings): DomSpan { + if (settings.displayMode) { + const classes = ["katex-display"]; + if (settings.leqno) { + classes.push("leqno"); + } + if (settings.fleqn) { + classes.push("fleqn"); + } + node = makeSpan(classes, [node]); + } + return node; +}; + +export const buildTree = function( + tree: AnyParseNode[], + expression: string, + settings: Settings, +): DomSpan { + const options = optionsFromSettings(settings); + let katexNode; + if (settings.output === "mathml") { + return buildMathML(tree, expression, options, settings.displayMode, true); + } else if (settings.output === "html") { + const htmlNode = buildHTML(tree, options); + katexNode = makeSpan(["katex"], [htmlNode]); + } else { + const mathMLNode = buildMathML(tree, expression, options, + settings.displayMode, false); + const htmlNode = buildHTML(tree, options); + katexNode = makeSpan(["katex"], [mathMLNode, htmlNode]); + } + + return displayWrap(katexNode, settings); +}; + +export const buildHTMLTree = function( + tree: AnyParseNode[], + expression: string, + settings: Settings, +): DomSpan { + const options = optionsFromSettings(settings); + const htmlNode = buildHTML(tree, options); + const katexNode = makeSpan(["katex"], [htmlNode]); + return displayWrap(katexNode, settings); +}; + +export default buildTree; diff --git a/node_modules/katex/src/defineEnvironment.ts b/node_modules/katex/src/defineEnvironment.ts new file mode 100644 index 0000000..6fffec9 --- /dev/null +++ b/node_modules/katex/src/defineEnvironment.ts @@ -0,0 +1,115 @@ +import {_htmlGroupBuilders, _mathmlGroupBuilders} from "./defineFunction"; + +import type Parser from "./Parser"; +import type {AnyParseNode, NodeType} from "./types/nodes"; +import type {ArgType, Mode} from "./types"; +import type {HtmlBuilder, MathMLBuilder} from "./defineFunction"; + +/** + * The context contains the following properties: + * - mode: current parsing mode. + * - envName: the name of the environment, one of the listed names. + * - parser: the parser object. + */ +type EnvContext = { + mode: Mode; + envName: string; + parser: Parser; +}; + +/** + * - context: information and references provided by the parser + * - args: an array of arguments passed to \begin{name} + * - optArgs: an array of optional arguments passed to \begin{name} + */ +type EnvHandler = ( + context: EnvContext, + args: AnyParseNode[], + optArgs: (AnyParseNode | null | undefined)[], +) => AnyParseNode; + +/** + * - numArgs: (default 0) The number of arguments after the \begin{name} function. + * - argTypes: (optional) Just like for a function + * - allowedInText: (default false) Whether or not the environment is allowed + * inside text mode (not enforced yet). + * - numOptionalArgs: (default 0) Just like for a function + */ +type EnvProps = { + numArgs: number; +}; + +/** + * Final environment spec for use at parse time. + * This is almost identical to `EnvDefSpec`, except it + * 1. includes the function handler + * 2. requires all arguments except argType + * It is generated by `defineEnvironment()` below. + */ +export type EnvSpec = { + type: NODETYPE; + // Need to use the type to avoid error. See NOTES below. + numArgs: number; + argTypes?: ArgType[]; + allowedInText: boolean; + numOptionalArgs: number; + handler: EnvHandler; +}; + +/** + * All registered environments. + * `environments.js` exports this same dictionary again and makes it public. + * `Parser.js` requires this dictionary via `environments.js`. + */ +export const _environments: Record> = {}; + +type EnvDefSpec = { + // Unique string to differentiate parse nodes. + type: NODETYPE; + + // List of functions which use the give handler, htmlBuilder, + // and mathmlBuilder. + names: Array; + + // Properties that control how the environments are parsed. + props: EnvProps; + handler: EnvHandler; + + // This function returns an object representing the DOM structure to be + // created when rendering the defined LaTeX function. + htmlBuilder: HtmlBuilder; + + // This function returns an object representing the MathML structure to be + // created when rendering the defined LaTeX function. + mathmlBuilder: MathMLBuilder; +}; + +export default function defineEnvironment({ + type, + names, + props, + handler, + htmlBuilder, + mathmlBuilder, +}: EnvDefSpec) { + // Set default values of environments. + const data = { + type, + numArgs: props.numArgs || 0, + allowedInText: false, + numOptionalArgs: 0, + handler, + }; + for (let i = 0; i < names.length; ++i) { + // TODO: The value type of _environments should be a type union of all + // possible `EnvSpec<>` possibilities instead of `EnvSpec<*>`, which is + // an existential type. + _environments[names[i]] = data; + } + if (htmlBuilder) { + _htmlGroupBuilders[type] = htmlBuilder; + } + if (mathmlBuilder) { + _mathmlGroupBuilders[type] = mathmlBuilder; + } +} diff --git a/node_modules/katex/src/defineFunction.ts b/node_modules/katex/src/defineFunction.ts new file mode 100644 index 0000000..8c780fe --- /dev/null +++ b/node_modules/katex/src/defineFunction.ts @@ -0,0 +1,220 @@ +import type Parser from "./Parser"; +import type Options from "./Options"; +import type {ArgType, BreakToken} from "./types"; +import type {AnyParseNode, NodeType, ParseNode, UnsupportedCmdParseNode} from "./types/nodes"; +import type {HtmlDomNode} from "./domTree"; +import type {Token} from "./Token"; +import type {MathDomNode} from "./mathMLTree"; + +/** Context provided to function handlers for error messages. */ +export type FunctionContext = { + funcName: FUNCNAME; + parser: Parser; + token?: Token; + breakOnTokenText?: BreakToken; +}; + +export type FunctionHandler< + NODETYPE extends NodeType, + FUNCNAME extends string = string, +> = ( + context: FunctionContext, + args: AnyParseNode[], + optArgs: (AnyParseNode | null)[], +) => UnsupportedCmdParseNode | ParseNode; +// Note: reverse the order of the return type union will cause a flow error. +// See https://github.com/facebook/flow/issues/3663. + +export type HtmlBuilder = + (group: ParseNode, options: Options) => HtmlDomNode; +export type MathMLBuilder = + (group: ParseNode, options: Options) => MathDomNode; + +// More general version of `HtmlBuilder` for nodes (e.g. \sum, accent types) +// whose presence impacts super/subscripting. In this case, ParseNode<"supsub"> +// delegates its HTML building to the HtmlBuilder corresponding to these nodes. +export type HtmlBuilderSupSub = + (group: ParseNode<"supsub"> | ParseNode, options: Options) => HtmlDomNode; + +/** + * Parser-facing function spec. Optional properties should use the defaults + * documented below. + */ +export type FunctionSpec< + NODETYPE extends NodeType, + FUNCNAME extends string = string, +> = { + /** + * Unique string to differentiate parse nodes. + * Also determines the type of the value returned by `handler`. + */ + type: NODETYPE; + + /** The number of arguments the function takes. */ + numArgs: number; + + /** + * An array corresponding to each argument of the function, giving the + * type of argument that should be parsed. Its length should be equal + * to `numOptionalArgs + numArgs`, and types for optional arguments + * should appear before types for mandatory arguments. + */ + argTypes?: ArgType[]; + + /** + * Whether it expands to a single token or a braced group of tokens. + * If it's grouped, it can be used as an argument to primitive commands, + * such as \sqrt (without the optional argument) and super/subscript. + * (default false) + */ + allowedInArgument?: boolean; + + /** + * Whether or not the function is allowed inside text mode + * (default false) + */ + allowedInText?: boolean; + + /** + * Whether or not the function is allowed inside math mode + * (default true) + */ + allowedInMath?: boolean; + + /** + * The number of optional arguments the function should parse. If the + * optional arguments aren't found, `null` will be passed to the handler in + * their place. + * (default 0) + */ + numOptionalArgs?: number; + + /** Must be true if the function is an infix operator. */ + infix?: boolean; + + /** Whether or not the function is a TeX primitive. */ + primitive?: boolean; + + /** + * The handler is called to handle these functions and their arguments and + * returns a `ParseNode`. It must be specified unless it's handled directly + * in the parser. + */ + handler: FunctionHandler | null | undefined; +}; + +/** + * Builder fields consumed during registration. These are stored separately in + * `_htmlGroupBuilders` and `_mathmlGroupBuilders`, and are not used by Parser. + */ +export type FunctionBuilders = { + /** + * This function returns an object representing the DOM structure to be + * created when rendering the defined LaTeX function. + * This should not modify the `ParseNode`. + */ + htmlBuilder?: HtmlBuilder; + + /** + * This function returns an object representing the MathML structure to be + * created when rendering the defined LaTeX function. + * This should not modify the `ParseNode`. + */ + mathmlBuilder?: MathMLBuilder; +}; + +/** + * Full registration spec passed to `defineFunction`. It combines the + * parser-facing fields with optional builder fields and the names being + * registered. + */ +type FunctionDefSpec< + NODETYPE extends NodeType, + NAMES extends readonly string[], +> = + FunctionSpec & FunctionBuilders & { + /** + * The first argument to defineFunction is a single name or a list of names. + * All functions named in such a list will share a single implementation. + */ + names: NAMES; + }; + +/** + * All registered functions. + * `functions.js` just exports this same dictionary again and makes it public. + * `Parser.js` requires this dictionary. + */ +export const _functions: Record> = {}; + +/** + * All HTML builders. Should be only used in the `define*` and the `build*ML` + * functions. + * + * Builders for different node types are stored side by side, but + * `HtmlBuilder` is contravariant in `T`, so there is no single type + * argument that makes storing/retrieving them typecheck. `any` is used + * as an existential-quantifier escape hatch. + */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any +export const _htmlGroupBuilders: Record> = {}; + +/** + * All MathML builders. Should be only used in the `define*` and the `build*ML` + * functions. See `_htmlGroupBuilders` above for the rationale behind `any`. + */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any +export const _mathmlGroupBuilders: Record> = {}; + +export default function defineFunction< + NODETYPE extends NodeType, + const NAMES extends readonly string[], +>( + data: FunctionDefSpec, +) { + const {type, names, htmlBuilder, mathmlBuilder} = data; + for (let i = 0; i < names.length; ++i) { + // To avoid destructuring and rebuilding an object, + // we store the entire FunctionDefSpec object, + // even though Parser only needs the FunctionSpec fields. + _functions[names[i]] = data; + } + if (type) { + if (htmlBuilder) { + _htmlGroupBuilders[type] = htmlBuilder; + } + if (mathmlBuilder) { + _mathmlGroupBuilders[type] = mathmlBuilder; + } + } +} + +/** + * Use this to register only the HTML and MathML builders for a function (e.g. + * if the function's ParseNode is generated in Parser.js rather than via a + * stand-alone handler provided to `defineFunction`). + */ +export function defineFunctionBuilders({ + type, htmlBuilder, mathmlBuilder, +}: { + type: NODETYPE; + htmlBuilder?: HtmlBuilder; + mathmlBuilder: MathMLBuilder; +}) { + if (htmlBuilder) { + _htmlGroupBuilders[type] = htmlBuilder; + } + if (mathmlBuilder) { + _mathmlGroupBuilders[type] = mathmlBuilder; + } +} + +export const normalizeArgument = function(arg: AnyParseNode): AnyParseNode { + return arg.type === "ordgroup" && arg.body.length === 1 ? arg.body[0] : arg; +}; + +// Since the corresponding buildHTML/buildMathML function expects a +// list of elements, we normalize for different kinds of arguments +export const ordargument = function(arg: AnyParseNode): AnyParseNode[] { + return arg.type === "ordgroup" ? arg.body : [arg]; +}; diff --git a/node_modules/katex/src/defineMacro.ts b/node_modules/katex/src/defineMacro.ts new file mode 100644 index 0000000..aee9bf2 --- /dev/null +++ b/node_modules/katex/src/defineMacro.ts @@ -0,0 +1,124 @@ + +import {Token} from "./Token"; +import type Namespace from "./Namespace"; +import type {Mode} from "./types"; + +/** + * Provides context to macros defined by functions. Implemented by + * MacroExpander. + */ +export interface MacroContextInterface { + mode: Mode; + + /** + * Object mapping macros to their expansions. + */ + macros: Namespace; + + /** + * Returns the topmost token on the stack, without expanding it. + * Similar in behavior to TeX's `\futurelet`. + */ + future(): Token; + + /** + * Remove and return the next unexpanded token. + */ + popToken(): Token; + + /** + * Consume all following space tokens, without expansion. + */ + consumeSpaces(): void; + + /** + * Expand the next token only once if possible. + */ + expandOnce(expandableOnly?: boolean): number | boolean; + + /** + * Expand the next token only once (if possible), and return the resulting + * top token on the stack (without removing anything from the stack). + * Similar in behavior to TeX's `\expandafter\futurelet`. + */ + expandAfterFuture(): Token; + + /** + * Recursively expand first token, then return first non-expandable token. + */ + expandNextToken(): Token; + + /** + * Fully expand the given macro name and return the resulting list of + * tokens, or return `undefined` if no such macro is defined. + */ + expandMacro(name: string): Token[] | undefined; + + /** + * Fully expand the given macro name and return the result as a string, + * or return `undefined` if no such macro is defined. + */ + expandMacroAsText(name: string): string | undefined; + + /** + * Fully expand the given token stream and return the resulting list of + * tokens. Note that the input tokens are in reverse order, but the + * output tokens are in forward order. + */ + expandTokens(tokens: Token[]): Token[]; + + /** + * Consume an argument from the token stream, and return the resulting array + * of tokens and start/end token. + */ + consumeArg(delims?: string[] | null | undefined): MacroArg; + + /** + * Consume the specified number of arguments from the token stream, + * and return the resulting array of arguments. + */ + consumeArgs(numArgs: number): Token[][]; + + /** + * Determine whether a command is currently "defined" (has some + * functionality), meaning that it's a macro (in the current group), + * a function, a symbol, or one of the special commands listed in + * `implicitCommands`. + */ + isDefined(name: string): boolean; + + /** + * Determine whether a command is expandable. + */ + isExpandable(name: string): boolean; +} + +export type MacroArg = { + tokens: Token[]; + start: Token; + end: Token; +}; + +/** Macro tokens (in reverse order). */ +export type MacroExpansion = { + tokens: Token[]; + numArgs: number; + delimiters?: string[][]; + unexpandable?: boolean; // used in \let +}; + +export type MacroDefinition = string | MacroExpansion | + ((arg0: MacroContextInterface) => string | MacroExpansion); +export type MacroMap = Record; + +/** + * All registered global/built-in macros. + * `macros.js` exports this same dictionary again and makes it public. + * `Parser.js` requires this dictionary via `macros.js`. + */ +export const _macros: MacroMap = {}; + +// This function might one day accept an additional argument and do more things. +export default function defineMacro(name: string, body: MacroDefinition) { + _macros[name] = body; +} diff --git a/node_modules/katex/src/delimiter.ts b/node_modules/katex/src/delimiter.ts new file mode 100644 index 0000000..b808799 --- /dev/null +++ b/node_modules/katex/src/delimiter.ts @@ -0,0 +1,832 @@ +/** + * This file 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`. + */ + +import ParseError from "./ParseError"; +import Style from "./Style"; + +import {PathNode, SvgNode, SymbolNode} from "./domTree"; +import {sqrtPath, innerPath, tallDelim} from "./svgGeometry"; +import {makeSpan, makeSymbol, makeSvgSpan, makeVList} from "./buildCommon"; +import {getCharacterMetrics} from "./fontMetrics"; +import symbols from "./symbols"; +import {makeEm} from "./units"; +import fontMetricsData from "./fontMetricsData"; + +import type Options from "./Options"; +import type {HtmlDomNode, DomSpan, SvgSpan} from "./domTree"; +import type {DelimiterSize, Mode} from "./types"; +import type {StyleInterface} from "./Style"; +import type {VListElem} from "./buildCommon"; +import type {CharacterMetrics, FontName} from "./types/fonts"; + +type StackedDelimiterFont = "Size1-Regular" | "Size4-Regular"; + +/** + * Get the metrics for a given symbol and font, after transformation (i.e. + * after following replacement from symbols.js) + */ +const getMetrics = function( + symbol: string, + font: string, + mode: Mode, +): CharacterMetrics { + const replace = symbols.math[symbol] && symbols.math[symbol].replace; + const metrics = + getCharacterMetrics(replace || symbol, font, mode); + if (!metrics) { + throw new Error(`Unsupported symbol ${symbol} and font size ${font}.`); + } + return metrics; +}; + +/** + * Puts a delimiter span in a given style, and adds appropriate height, depth, + * and maxFontSizes. + */ +const styleWrap = function( + delim: HtmlDomNode, + toStyle: StyleInterface, + options: Options, + classes: string[], +): DomSpan { + const newOptions = options.havingBaseStyle(toStyle); + + const span = makeSpan( + classes.concat(newOptions.sizingClasses(options)), + [delim], options); + + const delimSizeMultiplier = + newOptions.sizeMultiplier / options.sizeMultiplier; + span.height *= delimSizeMultiplier; + span.depth *= delimSizeMultiplier; + span.maxFontSize = newOptions.sizeMultiplier; + + return span; +}; + +const centerSpan = function( + span: DomSpan, + options: Options, + style: StyleInterface, +) { + const newOptions = options.havingBaseStyle(style); + const shift = + (1 - options.sizeMultiplier / newOptions.sizeMultiplier) * + options.fontMetrics().axisHeight; + + span.classes.push("delimcenter"); + span.style.top = makeEm(shift); + span.height -= shift; + span.depth += shift; +}; + +/** + * 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. + */ +const makeSmallDelim = function( + delim: string, + style: StyleInterface, + center: boolean, + options: Options, + mode: Mode, + classes: string[], +): DomSpan { + const text = makeSymbol(delim, "Main-Regular", mode, options); + const span = styleWrap(text, style, options, classes); + if (center) { + centerSpan(span, options, style); + } + return span; +}; + +/** + * Builds a symbol in the given font size (note size is an integer) + */ +const mathrmSize = function( + value: string, + size: DelimiterSize, + mode: Mode, + options: Options, +): SymbolNode { + return makeSymbol(value, `Size${size}-Regular`, mode, options); +}; + +/** + * Makes a large delimiter. This is a delimiter that comes in the Size1, Size2, + * Size3, or Size4 fonts. It is always rendered in textstyle. + */ +const makeLargeDelim = function(delim: string, + size: DelimiterSize, + center: boolean, + options: Options, + mode: Mode, + classes: string[], +): DomSpan { + const inner = mathrmSize(delim, size, mode, options); + const span = styleWrap( + makeSpan(["delimsizing", "size" + size], [inner], options), + Style.TEXT, options, classes); + if (center) { + centerSpan(span, options, Style.TEXT); + } + return span; +}; + +/** + * Make a span from a font glyph with the given offset and in the given font. + * This is used in makeStackedDelim to make the stacking pieces for the delimiter. + */ +const makeGlyphSpan = function( + symbol: string, + font: StackedDelimiterFont, + mode: Mode, +): VListElem { + let sizeClass; + // Apply the correct CSS class to choose the right font. + if (font === "Size1-Regular") { + sizeClass = "delim-size1"; + } else /* if (font === "Size4-Regular") */ { + sizeClass = "delim-size4"; + } + + const corner = makeSpan( + ["delimsizinginner", sizeClass], + [makeSpan([], [makeSymbol(symbol, font, mode)])]); + + // Since this will be passed into `makeVList` in the end, wrap the element + // in the appropriate tag that VList uses. + return {type: "elem", elem: corner}; +}; + +const makeInner = function( + ch: string, + height: number, + options: Options +): VListElem { + // Create a span with inline SVG for the inner part of a tall stacked delimiter. + const width = fontMetricsData['Size4-Regular'][ch.charCodeAt(0)] + ? fontMetricsData['Size4-Regular'][ch.charCodeAt(0)][4] + : fontMetricsData['Size1-Regular'][ch.charCodeAt(0)][4]; + const path = new PathNode("inner", innerPath(ch, Math.round(1000 * height))); + const svgNode = new SvgNode([path], { + "width": makeEm(width), + "height": makeEm(height), + // Override CSS rule `.katex svg { width: 100% }` + "style": "width:" + makeEm(width), + "viewBox": "0 0 " + 1000 * width + " " + Math.round(1000 * height), + "preserveAspectRatio": "xMinYMin", + }); + const span = makeSvgSpan([], [svgNode], options); + span.height = height; + span.style.height = makeEm(height); + span.style.width = makeEm(width); + return {type: "elem", elem: span}; +}; + +// Helpers for makeStackedDelim +const lapInEms = 0.008; +const lap: {type: "kern"; size: number} = {type: "kern", size: -1 * lapInEms}; +const verts = new Set(["|", "\\lvert", "\\rvert", "\\vert"]); +const doubleVerts = new Set(["\\|", "\\lVert", "\\rVert", "\\Vert"]); + +/** + * Make a stacked delimiter out of a given delimiter, with the total height at + * least `heightTotal`. This routine is mentioned on page 442 of the TeXbook. + */ +const makeStackedDelim = function( + delim: string, + heightTotal: number, + center: boolean, + options: Options, + mode: Mode, + classes: string[], +): DomSpan { + // There are four parts, the top, an optional middle, a repeated part, and a + // bottom. + let top; + let middle; + let repeat; + let bottom; + let svgLabel = ""; + let viewBoxWidth = 0; + top = repeat = bottom = delim; + middle = null; + // Also keep track of what font the delimiters are in + let font: StackedDelimiterFont = "Size1-Regular"; + + // We set the parts and font based on the symbol. Note that we use + // '\u23d0' instead of '|' and '\u2016' instead of '\\|' for the + // repeats of the arrows + if (delim === "\\uparrow") { + repeat = bottom = "\u23d0"; + } else if (delim === "\\Uparrow") { + repeat = bottom = "\u2016"; + } else if (delim === "\\downarrow") { + top = repeat = "\u23d0"; + } else if (delim === "\\Downarrow") { + top = repeat = "\u2016"; + } else if (delim === "\\updownarrow") { + top = "\\uparrow"; + repeat = "\u23d0"; + bottom = "\\downarrow"; + } else if (delim === "\\Updownarrow") { + top = "\\Uparrow"; + repeat = "\u2016"; + bottom = "\\Downarrow"; + } else if (verts.has(delim)) { + repeat = "\u2223"; + svgLabel = "vert"; + viewBoxWidth = 333; + } else if (doubleVerts.has(delim)) { + repeat = "\u2225"; + svgLabel = "doublevert"; + viewBoxWidth = 556; + } else if (delim === "[" || delim === "\\lbrack") { + top = "\u23a1"; + repeat = "\u23a2"; + bottom = "\u23a3"; + font = "Size4-Regular"; + svgLabel = "lbrack"; + viewBoxWidth = 667; + } else if (delim === "]" || delim === "\\rbrack") { + top = "\u23a4"; + repeat = "\u23a5"; + bottom = "\u23a6"; + font = "Size4-Regular"; + svgLabel = "rbrack"; + viewBoxWidth = 667; + } else if (delim === "\\lfloor" || delim === "\u230a") { + repeat = top = "\u23a2"; + bottom = "\u23a3"; + font = "Size4-Regular"; + svgLabel = "lfloor"; + viewBoxWidth = 667; + } else if (delim === "\\lceil" || delim === "\u2308") { + top = "\u23a1"; + repeat = bottom = "\u23a2"; + font = "Size4-Regular"; + svgLabel = "lceil"; + viewBoxWidth = 667; + } else if (delim === "\\rfloor" || delim === "\u230b") { + repeat = top = "\u23a5"; + bottom = "\u23a6"; + font = "Size4-Regular"; + svgLabel = "rfloor"; + viewBoxWidth = 667; + } else if (delim === "\\rceil" || delim === "\u2309") { + top = "\u23a4"; + repeat = bottom = "\u23a5"; + font = "Size4-Regular"; + svgLabel = "rceil"; + viewBoxWidth = 667; + } else if (delim === "(" || delim === "\\lparen") { + top = "\u239b"; + repeat = "\u239c"; + bottom = "\u239d"; + font = "Size4-Regular"; + svgLabel = "lparen"; + viewBoxWidth = 875; + } else if (delim === ")" || delim === "\\rparen") { + top = "\u239e"; + repeat = "\u239f"; + bottom = "\u23a0"; + font = "Size4-Regular"; + svgLabel = "rparen"; + viewBoxWidth = 875; + } else if (delim === "\\{" || delim === "\\lbrace") { + top = "\u23a7"; + middle = "\u23a8"; + bottom = "\u23a9"; + repeat = "\u23aa"; + font = "Size4-Regular"; + } else if (delim === "\\}" || delim === "\\rbrace") { + top = "\u23ab"; + middle = "\u23ac"; + bottom = "\u23ad"; + repeat = "\u23aa"; + font = "Size4-Regular"; + } else if (delim === "\\lgroup" || delim === "\u27ee") { + top = "\u23a7"; + bottom = "\u23a9"; + repeat = "\u23aa"; + font = "Size4-Regular"; + } else if (delim === "\\rgroup" || delim === "\u27ef") { + top = "\u23ab"; + bottom = "\u23ad"; + repeat = "\u23aa"; + font = "Size4-Regular"; + } else if (delim === "\\lmoustache" || delim === "\u23b0") { + top = "\u23a7"; + bottom = "\u23ad"; + repeat = "\u23aa"; + font = "Size4-Regular"; + } else if (delim === "\\rmoustache" || delim === "\u23b1") { + top = "\u23ab"; + bottom = "\u23a9"; + repeat = "\u23aa"; + font = "Size4-Regular"; + } + + // Get the metrics of the four sections + const topMetrics = getMetrics(top, font, mode); + const topHeightTotal = topMetrics.height + topMetrics.depth; + const repeatMetrics = getMetrics(repeat, font, mode); + const repeatHeightTotal = repeatMetrics.height + repeatMetrics.depth; + const bottomMetrics = getMetrics(bottom, font, mode); + const bottomHeightTotal = bottomMetrics.height + bottomMetrics.depth; + let middleHeightTotal = 0; + let middleFactor = 1; + if (middle !== null) { + const middleMetrics = getMetrics(middle, font, mode); + middleHeightTotal = middleMetrics.height + middleMetrics.depth; + middleFactor = 2; // repeat symmetrically above and below middle + } + + // Calculate the minimal height that the delimiter can have. + // It is at least the size of the top, bottom, and optional middle combined. + const minHeight = topHeightTotal + bottomHeightTotal + middleHeightTotal; + + // Compute the number of copies of the repeat symbol we will need + const repeatCount = Math.max(0, Math.ceil( + (heightTotal - minHeight) / (middleFactor * repeatHeightTotal))); + + // Compute the total height of the delimiter including all the symbols + const realHeightTotal = + minHeight + repeatCount * middleFactor * repeatHeightTotal; + + // The center of the delimiter is placed at the center of the axis. Note + // that in this context, "center" means that the delimiter should be + // centered around the axis in the current style, while normally it is + // centered around the axis in textstyle. + let axisHeight = options.fontMetrics().axisHeight; + if (center) { + axisHeight *= options.sizeMultiplier; + } + // Calculate the depth + const depth = realHeightTotal / 2 - axisHeight; + + // Now, we start building the pieces that will go into the vlist + // Keep a list of the pieces of the stacked delimiter + const stack: Array = []; + + if (svgLabel.length > 0) { + // Instead of stacking glyphs, create a single SVG. + // This evades browser problems with imprecise positioning of spans. + const midHeight = realHeightTotal - topHeightTotal - bottomHeightTotal; + const viewBoxHeight = Math.round(realHeightTotal * 1000); + const pathStr = tallDelim(svgLabel, Math.round(midHeight * 1000)); + const path = new PathNode(svgLabel, pathStr); + const width = makeEm(viewBoxWidth / 1000); + const height = makeEm(viewBoxHeight / 1000); + const svg = new SvgNode([path], { + "width": width, + "height": height, + "viewBox": `0 0 ${viewBoxWidth} ${viewBoxHeight}`, + }); + const wrapper = makeSvgSpan([], [svg], options); + wrapper.height = viewBoxHeight / 1000; + wrapper.style.width = width; + wrapper.style.height = height; + stack.push({type: "elem", elem: wrapper}); + } else { + // Stack glyphs + // Start by adding the bottom symbol + stack.push(makeGlyphSpan(bottom, font, mode)); + stack.push(lap); // overlap + + if (middle === null) { + // The middle section will be an SVG. Make it an extra 0.016em tall. + // We'll overlap by 0.008em at top and bottom. + const innerHeight = realHeightTotal - topHeightTotal - bottomHeightTotal + + 2 * lapInEms; + stack.push(makeInner(repeat, innerHeight, options)); + } else { + // When there is a middle bit, we need the middle part and two repeated + // sections + const innerHeight = (realHeightTotal - topHeightTotal - + bottomHeightTotal - middleHeightTotal) / 2 + 2 * lapInEms; + stack.push(makeInner(repeat, innerHeight, options)); + // Now insert the middle of the brace. + stack.push(lap); + stack.push(makeGlyphSpan(middle, font, mode)); + stack.push(lap); + stack.push(makeInner(repeat, innerHeight, options)); + } + + // Add the top symbol + stack.push(lap); + stack.push(makeGlyphSpan(top, font, mode)); + } + + // Finally, build the vlist + const newOptions = options.havingBaseStyle(Style.TEXT); + const inner = makeVList({ + positionType: "bottom", + positionData: depth, + children: stack, + }, newOptions); + + return styleWrap( + makeSpan(["delimsizing", "mult"], [inner], newOptions), + Style.TEXT, options, classes); +}; + +// All surds have 0.08em padding above the vinculum inside the SVG. +// That keeps browser span height rounding error from pinching the line. +const vbPad = 80; // padding above the surd, measured inside the viewBox. +const emPad = 0.08; // padding, in ems, measured in the document. + +const sqrtSvg = function( + sqrtName: string, + height: number, + viewBoxHeight: number, + extraVinculum: number, + options: Options, +): SvgSpan { + const path = sqrtPath(sqrtName, extraVinculum, viewBoxHeight); + const pathNode = new PathNode(sqrtName, path); + + const svg = new SvgNode([pathNode], { + // Note: 1000:1 ratio of viewBox to document em width. + "width": "400em", + "height": makeEm(height), + "viewBox": "0 0 400000 " + viewBoxHeight, + "preserveAspectRatio": "xMinYMin slice", + }); + + return makeSvgSpan(["hide-tail"], [svg], options); +}; + +/** + * Make a sqrt image of the given height, + */ +export const makeSqrtImage = function( + height: number, + options: Options, +): { + span: SvgSpan, + ruleWidth: number, + advanceWidth: number, +} { + // Define a newOptions that removes the effect of size changes such as \Huge. + // We don't pick different a height surd for \Huge. For it, we scale up. + const newOptions = options.havingBaseSizing(); + + // Pick the desired surd glyph from a sequence of surds. + const delim = traverseSequence("\\surd", height * newOptions.sizeMultiplier, + stackLargeDelimiterSequence, newOptions); + + let sizeMultiplier = newOptions.sizeMultiplier; // default + + // The standard sqrt SVGs each have a 0.04em thick vinculum. + // If Settings.minRuleThickness is larger than that, we add extraVinculum. + const extraVinculum = Math.max(0, + options.minRuleThickness - options.fontMetrics().sqrtRuleThickness); + + // Create a span containing an SVG image of a sqrt symbol. + let span; + let spanHeight; + let texHeight; + let viewBoxHeight; + let advanceWidth; + + // We create viewBoxes with 80 units of "padding" above each surd. + // Then browser rounding error on the parent span height will not + // encroach on the ink of the vinculum. But that padding is not + // included in the TeX-like `height` used for calculation of + // vertical alignment. So texHeight = span.height < span.style.height. + + if (delim.type === "small") { + // Get an SVG that is derived from glyph U+221A in font KaTeX-Main. + // 1000 unit normal glyph height. + viewBoxHeight = 1000 + 1000 * extraVinculum + vbPad; + if (height < 1.0) { + sizeMultiplier = 1.0; // mimic a \textfont radical + } else if (height < 1.4) { + sizeMultiplier = 0.7; // mimic a \scriptfont radical + } + spanHeight = (1.0 + extraVinculum + emPad) / sizeMultiplier; + texHeight = (1.00 + extraVinculum) / sizeMultiplier; + span = sqrtSvg("sqrtMain", spanHeight, viewBoxHeight, extraVinculum, + options); + span.style.minWidth = "0.853em"; + advanceWidth = 0.833 / sizeMultiplier; // from the font. + + } else if (delim.type === "large") { + // These SVGs come from fonts: KaTeX_Size1, _Size2, etc. + viewBoxHeight = (1000 + vbPad) * sizeToMaxHeight[delim.size]; + texHeight = (sizeToMaxHeight[delim.size] + extraVinculum) / sizeMultiplier; + spanHeight = (sizeToMaxHeight[delim.size] + extraVinculum + emPad) + / sizeMultiplier; + span = sqrtSvg("sqrtSize" + delim.size, spanHeight, viewBoxHeight, + extraVinculum, options); + span.style.minWidth = "1.02em"; + advanceWidth = 1.0 / sizeMultiplier; // 1.0 from the font. + + } else { + // Tall sqrt. In TeX, this would be stacked using multiple glyphs. + // We'll use a single SVG to accomplish the same thing. + spanHeight = height + extraVinculum + emPad; + texHeight = height + extraVinculum; + viewBoxHeight = Math.floor(1000 * height + extraVinculum) + vbPad; + span = sqrtSvg("sqrtTall", spanHeight, viewBoxHeight, extraVinculum, + options); + span.style.minWidth = "0.742em"; + advanceWidth = 1.056; + } + + span.height = texHeight; + span.style.height = makeEm(spanHeight); + + return { + span, + advanceWidth, + // Calculate the actual line width. + // This actually should depend on the chosen font -- e.g. \boldmath + // should use the thicker surd symbols from e.g. KaTeX_Main-Bold, and + // have thicker rules. + ruleWidth: (options.fontMetrics().sqrtRuleThickness + extraVinculum) + * sizeMultiplier, + }; +}; + +// There are three kinds of delimiters, delimiters that stack when they become +// too large +const stackLargeDelimiters = new Set([ + "(", "\\lparen", ")", "\\rparen", + "[", "\\lbrack", "]", "\\rbrack", + "\\{", "\\lbrace", "\\}", "\\rbrace", + "\\lfloor", "\\rfloor", "\u230a", "\u230b", + "\\lceil", "\\rceil", "\u2308", "\u2309", + "\\surd", +]); + +// delimiters that always stack +const stackAlwaysDelimiters = new Set([ + "\\uparrow", "\\downarrow", "\\updownarrow", + "\\Uparrow", "\\Downarrow", "\\Updownarrow", + "|", "\\|", "\\vert", "\\Vert", + "\\lvert", "\\rvert", "\\lVert", "\\rVert", + "\\lgroup", "\\rgroup", "\u27ee", "\u27ef", + "\\lmoustache", "\\rmoustache", "\u23b0", "\u23b1", +]); + +// and delimiters that never stack +const stackNeverDelimiters = new Set([ + "<", ">", "\\langle", "\\rangle", "/", "\\backslash", "\\lt", "\\gt", +]); + +// Metrics of the different sizes. Found by looking at TeX's output of +// $\bigl| // \Bigl| \biggl| \Biggl| \showlists$ +// Used to create stacked delimiters of appropriate sizes in makeSizedDelim. +export const sizeToMaxHeight = [0, 1.2, 1.8, 2.4, 3.0]; + +/** + * Used to create a delimiter of a specific size, where `size` is 1, 2, 3, or 4. + */ +export const makeSizedDelim = function( + delim: string, + size: DelimiterSize, + options: Options, + mode: Mode, + classes: string[], +): DomSpan { + // < and > turn into \langle and \rangle in delimiters + if (delim === "<" || delim === "\\lt" || delim === "\u27e8") { + delim = "\\langle"; + } else if (delim === ">" || delim === "\\gt" || delim === "\u27e9") { + delim = "\\rangle"; + } + + // Sized delimiters are never centered. + if (stackLargeDelimiters.has(delim) || stackNeverDelimiters.has(delim)) { + return makeLargeDelim(delim, size, false, options, mode, classes); + } else if (stackAlwaysDelimiters.has(delim)) { + return makeStackedDelim( + delim, + sizeToMaxHeight[size], + false, + options, + mode, + classes, + ); + } else { + throw new ParseError("Illegal delimiter: '" + delim + "'"); + } +}; + +/** + * There are three different sequences of delimiter sizes that the delimiters + * follow depending on the kind of delimiter. This is used when creating custom + * sized delimiters to decide whether to create a small, large, or stacked + * delimiter. + * + * In real TeX, these sequences aren't explicitly defined, but are instead + * defined inside the font metrics. Since there are only three sequences that + * are possible for the delimiters that TeX defines, it is easier to just encode + * them explicitly here. + */ + +type Delimiter = + {type: "small", style: StyleInterface} | + {type: "large", size: 1 | 2 | 3 | 4} | + {type: "stack"}; + +// Delimiters that never stack try small delimiters and large delimiters only +const stackNeverDelimiterSequence: Delimiter[] = [ + {type: "small", style: Style.SCRIPTSCRIPT}, + {type: "small", style: Style.SCRIPT}, + {type: "small", style: Style.TEXT}, + {type: "large", size: 1}, + {type: "large", size: 2}, + {type: "large", size: 3}, + {type: "large", size: 4}, +]; + +// Delimiters that always stack try the small delimiters first, then stack +const stackAlwaysDelimiterSequence: Delimiter[] = [ + {type: "small", style: Style.SCRIPTSCRIPT}, + {type: "small", style: Style.SCRIPT}, + {type: "small", style: Style.TEXT}, + {type: "stack"}, +]; + +// Delimiters that stack when large try the small and then large delimiters, and +// stack afterwards +const stackLargeDelimiterSequence: Delimiter[] = [ + {type: "small", style: Style.SCRIPTSCRIPT}, + {type: "small", style: Style.SCRIPT}, + {type: "small", style: Style.TEXT}, + {type: "large", size: 1}, + {type: "large", size: 2}, + {type: "large", size: 3}, + {type: "large", size: 4}, + {type: "stack"}, +]; + +/** + * Get the font used in a delimiter based on what kind of delimiter it is. + * TODO(#963) Use more specific font family return type once that is introduced. + */ +const delimTypeToFont = function(type: Delimiter): string { + if (type.type === "small") { + return "Main-Regular"; + } else if (type.type === "large") { + return "Size" + type.size + "-Regular"; + } else if (type.type === "stack") { + return "Size4-Regular"; + } else { + const delimKind = (type as Delimiter).type; + throw new Error(`Add support for delim type '${delimKind}' here.`); + } +}; + +/** + * Traverse a sequence of types of delimiters to decide what kind of delimiter + * should be used to create a delimiter of the given height+depth. + */ +const traverseSequence = function( + delim: string, + height: number, + sequence: Delimiter[], + options: Options, +): Delimiter { + // Here, we choose the index we should start at in the sequences. In smaller + // sizes (which correspond to larger numbers in style.size) we start earlier + // in the sequence. Thus, scriptscript starts at index 3-3=0, script starts + // at index 3-2=1, text starts at 3-1=2, and display starts at min(2,3-0)=2 + const start = Math.min(2, 3 - options.style.size); + for (let i = start; i < sequence.length; i++) { + const delimType = sequence[i]; + if (delimType.type === "stack") { + // This is always the last delimiter, so we just break the loop now. + break; + } + + const metrics = getMetrics(delim, delimTypeToFont(delimType), "math"); + let heightDepth = metrics.height + metrics.depth; + + // Small delimiters are scaled down versions of the same font, so we + // account for the style change size. + if (delimType.type === "small") { + const newOptions = options.havingBaseStyle(delimType.style); + heightDepth *= newOptions.sizeMultiplier; + } + + // Check if the delimiter at this size works for the given height. + if (heightDepth > height) { + return delimType; + } + } + + // If we reached the end of the sequence, return the last sequence element. + return sequence[sequence.length - 1]; +}; + +/** + * Make a delimiter of a given height+depth, with optional centering. Here, we + * traverse the sequences, and create a delimiter that the sequence tells us to. + */ +export const makeCustomSizedDelim = function( + delim: string, + height: number, + center: boolean, + options: Options, + mode: Mode, + classes: string[], +): DomSpan { + if (delim === "<" || delim === "\\lt" || delim === "\u27e8") { + delim = "\\langle"; + } else if (delim === ">" || delim === "\\gt" || delim === "\u27e9") { + delim = "\\rangle"; + } + + // Decide what sequence to use + let sequence: Delimiter[]; + if (stackNeverDelimiters.has(delim)) { + sequence = stackNeverDelimiterSequence; + } else if (stackLargeDelimiters.has(delim)) { + sequence = stackLargeDelimiterSequence; + } else { + sequence = stackAlwaysDelimiterSequence; + } + + // Look through the sequence + const delimType = traverseSequence(delim, height, sequence, options); + + // Get the delimiter from font glyphs. + // Depending on the sequence element we decided on, call the + // appropriate function. + if (delimType.type === "small") { + return makeSmallDelim(delim, delimType.style, center, options, + mode, classes); + } else if (delimType.type === "large") { + return makeLargeDelim(delim, delimType.size, center, options, mode, + classes); + } else /* if (delimType.type === "stack") */ { + return makeStackedDelim(delim, height, center, options, mode, + classes); + } +}; + +/** + * Make a delimiter for use with `\left` and `\right`, given a height and depth + * of an expression that the delimiters surround. + */ +export const makeLeftRightDelim = function( + delim: string, + height: number, + depth: number, + options: Options, + mode: Mode, + classes: string[], +): DomSpan { + // We always center \left/\right delimiters, so the axis is always shifted + const axisHeight = + options.fontMetrics().axisHeight * options.sizeMultiplier; + + // Taken from TeX source, tex.web, function make_left_right + const delimiterFactor = 901; + const delimiterExtend = 5.0 / options.fontMetrics().ptPerEm; + + const maxDistFromAxis = Math.max( + height - axisHeight, depth + axisHeight); + + const totalHeight = Math.max( + // In real TeX, calculations are done using integral values which are + // 65536 per pt, or 655360 per em. So, the division here truncates in + // TeX but doesn't here, producing different results. If we wanted to + // exactly match TeX's calculation, we could do + // Math.floor(655360 * maxDistFromAxis / 500) * + // delimiterFactor / 655360 + // (To see the difference, compare + // x^{x^{\left(\rule{0.1em}{0.68em}\right)}} + // in TeX and KaTeX) + maxDistFromAxis / 500 * delimiterFactor, + 2 * maxDistFromAxis - delimiterExtend); + + // Finally, we defer to `makeCustomSizedDelim` with our calculated total + // height + return makeCustomSizedDelim(delim, totalHeight, true, options, mode, classes); +}; diff --git a/node_modules/katex/src/domTree.ts b/node_modules/katex/src/domTree.ts new file mode 100644 index 0000000..50d79df --- /dev/null +++ b/node_modules/katex/src/domTree.ts @@ -0,0 +1,641 @@ +/** + * These objects store the data about the DOM nodes we create, as well as some + * extra data. They can then be transformed into real DOM nodes with the + * `toNode` function or HTML markup using `toMarkup`. They are useful for both + * storing extra properties on the nodes, as well as providing a way to easily + * work with the DOM. + * + * Similar functions for working with MathML nodes exist in mathMLTree.js. + * + * TODO: refactor `span` and `anchor` into common superclass when + * target environments support class inheritance + */ +import {scriptFromCodepoint} from "./unicodeScripts"; +import {escape, hyphenate} from "./utils"; +import {path} from "./svgGeometry"; +import type Options from "./Options"; +import {DocumentFragment} from "./tree"; +import {makeEm} from "./units"; +import ParseError from "./ParseError"; + +import type {VirtualNode} from "./tree"; + +/** + * Create an HTML className based on a list of classes. In addition to joining + * with spaces, we also remove empty classes. + */ +export const createClass = function(classes: string[]): string { + return classes.filter(cls => cls).join(" "); +}; + +/** + * Serialize a CssStyle object into a semicolon-delimited inline-style string + * (hyphenating camelCase property names). Returns "" when no property is set. + */ +const cssStyleToString = function(style: CssStyle): string { + let styles = ""; + for (const key of Object.keys(style) as Array) { + const value = style[key]; + if (value !== undefined) { + styles += `${hyphenate(key)}:${value};`; + } + } + return styles; +}; + +type InitNodeData = { + classes: string[]; + attributes: Record; + height: number; + depth: number; + maxFontSize: number; + style: CssStyle; +}; + +type HtmlNodeData = InitNodeData & { + children: VirtualNode[]; +}; + +const initNode = function( + this: InitNodeData, + classes?: string[], + options?: Options, + style?: CssStyle, +) { + this.classes = classes || []; + this.attributes = {}; + this.height = 0; + this.depth = 0; + this.maxFontSize = 0; + this.style = style || {}; + if (options) { + if (options.style.isTight()) { + this.classes.push("mtight"); + } + const color = options.getColor(); + if (color) { + this.style.color = color; + } + } +}; + +/** + * Convert into an HTML node + */ +const toNode = function(this: HtmlNodeData, tagName: string): HTMLElement { + const node = document.createElement(tagName); + + // Apply the class + node.className = createClass(this.classes); + + // Apply inline styles + Object.assign(node.style, this.style); + + // Apply attributes + for (const attr of Object.keys(this.attributes)) { + node.setAttribute(attr, this.attributes[attr]); + } + + // Append the children, also as HTML nodes + for (let i = 0; i < this.children.length; i++) { + node.appendChild(this.children[i].toNode()); + } + + return node; +}; + +/** + * https://w3c.github.io/html-reference/syntax.html#syntax-attributes + * + * > Attribute Names must consist of one or more characters + * other than the space characters, U+0000 NULL, + * '"', "'", ">", "/", "=", the control characters, + * and any characters that are not defined by Unicode. + */ +const invalidAttributeNameRegex = /[\s"'>/=\x00-\x1f]/; + +/** + * Convert into an HTML markup string + */ +const toMarkup = function(this: HtmlNodeData, tagName: string): string { + let markup = `<${tagName}`; + + // Add the class + if (this.classes.length) { + markup += ` class="${escape(createClass(this.classes))}"`; + } + + const styles = cssStyleToString(this.style); + if (styles) { + markup += ` style="${escape(styles)}"`; + } + + // Add the attributes + for (const attr of Object.keys(this.attributes)) { + if (invalidAttributeNameRegex.test(attr)) { + throw new ParseError(`Invalid attribute name '${attr}'`); + } + markup += ` ${attr}="${escape(this.attributes[attr])}"`; + } + + markup += ">"; + + // Add the markup of the children, also as markup + for (let i = 0; i < this.children.length; i++) { + markup += this.children[i].toMarkup(); + } + + markup += ``; + + return markup; +}; + +// Making the type below exact with all optional fields doesn't work due to +// - https://github.com/facebook/flow/issues/4582 +// - https://github.com/facebook/flow/issues/5688 +// However, since *all* fields are optional, $Shape<> works as suggested in 5688 +// above. +// This type does not include all CSS properties. Additional properties should +// be added as needed. +export type CssStyle = Partial<{ + backgroundColor: string; + borderBottomWidth: string; + borderColor: string; + borderRightStyle: string; + borderRightWidth: string; + borderTopWidth: string; + borderStyle: string; + borderWidth: string; + bottom: string; + color: string; + height: string; + left: string; + margin: string; + marginLeft: string; + marginRight: string; + marginTop: string; + minWidth: string; + paddingLeft: string; + position: string; + textShadow: string; + top: string; + width: string; + verticalAlign: string; +}> & {}; + +export interface HtmlDomNode extends VirtualNode { + classes: string[]; + height: number; + depth: number; + maxFontSize: number; + style: CssStyle; + hasClass(className: string): boolean; +} + +// Span wrapping other DOM nodes. +export type DomSpan = Span; +// Span wrapping an SVG node. +export type SvgSpan = Span; + +export type SvgChildNode = PathNode | LineNode; +export type documentFragment = DocumentFragment; + +/** + * This node represents a span node, with a className, a list of children, and + * an inline style. It also contains information about its height, depth, and + * maxFontSize. + * + * Represents two types with different uses: SvgSpan to wrap an SVG and DomSpan + * otherwise. This typesafety is important when HTML builders access a span's + * children. + */ +export class Span implements HtmlDomNode { + children: ChildType[]; + attributes!: Record; + classes!: string[]; + height!: number; + depth!: number; + width: number | null | undefined; + maxFontSize!: number; + style!: CssStyle; + /** + * Italic correction carried over from a SymbolNode when the symbol is + * wrapped in a vlist (e.g. \oiint / \oiiint). Read by supsub to adjust + * subscript positioning. Only set when nonzero; use `?? 0` at read sites. + */ + italic?: number; + + constructor( + classes?: string[], + children?: ChildType[], + options?: Options, + style?: CssStyle, + ) { + initNode.call(this, classes, options, style); + this.children = children || []; + } + + /** + * Sets an arbitrary attribute on the span. Warning: use this wisely. Not + * all browsers support attributes the same, and having too many custom + * attributes is probably bad. + */ + setAttribute(attribute: string, value: string) { + this.attributes[attribute] = value; + } + + hasClass(className: string): boolean { + return this.classes.includes(className); + } + + toNode(): HTMLElement { + return toNode.call(this, "span"); + } + + toMarkup(): string { + return toMarkup.call(this, "span"); + } +} + +/** + * This node represents an anchor () element with a hyperlink. See `span` + * for further details. + */ +export class Anchor implements HtmlDomNode { + children: HtmlDomNode[]; + attributes!: Record; + classes!: string[]; + height!: number; + depth!: number; + maxFontSize!: number; + style!: CssStyle; + + constructor( + href: string, + classes: string[], + children: HtmlDomNode[], + options: Options, + ) { + initNode.call(this, classes, options); + this.children = children || []; + this.setAttribute('href', href); + } + + setAttribute(attribute: string, value: string) { + this.attributes[attribute] = value; + } + + hasClass(className: string): boolean { + return this.classes.includes(className); + } + + toNode(): HTMLElement { + return toNode.call(this, "a"); + } + + toMarkup(): string { + return toMarkup.call(this, "a"); + } +} + +/** + * This node represents an image embed () element. + */ +export class Img implements VirtualNode { + src: string; + alt: string; + classes: string[]; + height: number; + depth: number; + maxFontSize: number; + style: CssStyle; + + constructor( + src: string, + alt: string, + style: CssStyle, + ) { + this.alt = alt; + this.src = src; + this.classes = ["mord"]; + this.height = 0; + this.depth = 0; + this.maxFontSize = 0; + this.style = style; + } + + hasClass(className: string): boolean { + return this.classes.includes(className); + } + + toNode(): Node { + const node = document.createElement("img"); + node.src = this.src; + node.alt = this.alt; + node.className = "mord"; + + // Apply inline styles + Object.assign(node.style, this.style); + + return node; + } + + toMarkup(): string { + let markup = `${escape(this.alt)} = { + 'î': '\u0131\u0302', + 'ï': '\u0131\u0308', + 'í': '\u0131\u0301', + // 'ī': '\u0131\u0304', // enable when we add Extended Latin + 'ì': '\u0131\u0300', +}; + +/** + * A symbol node contains information about a single symbol. It either renders + * to a single text node, or a span with a single text node in it, depending on + * whether it has CSS classes, styles, or needs italic correction. + */ +export class SymbolNode implements HtmlDomNode { + text: string; + height: number; + depth: number; + italic: number; + skew: number; + width: number; + maxFontSize: number; + classes: string[]; + style: CssStyle; + + constructor( + text: string, + height?: number, + depth?: number, + italic?: number, + skew?: number, + width?: number, + classes?: string[], + style?: CssStyle, + ) { + this.text = text; + this.height = height || 0; + this.depth = depth || 0; + this.italic = italic || 0; + this.skew = skew || 0; + this.width = width || 0; + this.classes = classes || []; + this.style = style || {}; + this.maxFontSize = 0; + + // Mark text from non-Latin scripts with specific classes so that we + // can specify which fonts to use. This allows us to render these + // characters with a serif font in situations where the browser would + // either default to a sans serif or render a placeholder character. + // We use CSS class names like cjk_fallback, hangul_fallback and + // brahmic_fallback. See ./unicodeScripts.js for the set of possible + // script names + const script = scriptFromCodepoint(this.text.charCodeAt(0)); + if (script) { + this.classes.push(script + "_fallback"); + } + + if (/[îïíì]/.test(this.text)) { // add ī when we add Extended Latin + this.text = iCombinations[this.text]; + } + } + + hasClass(className: string): boolean { + return this.classes.includes(className); + } + + /** + * Creates a text node or span from a symbol node. Note that a span is only + * created if it is needed. + */ + toNode(): Node { + const node = document.createTextNode(this.text); + let span = null; + + if (this.italic > 0) { + span = document.createElement("span"); + span.style.marginRight = makeEm(this.italic); + } + + if (this.classes.length > 0) { + span = span || document.createElement("span"); + span.className = createClass(this.classes); + } + + if (Object.keys(this.style).length > 0) { + span = span || document.createElement("span"); + Object.assign(span.style, this.style); + } + + if (span) { + span.appendChild(node); + return span; + } else { + return node; + } + } + + /** + * Creates markup for a symbol node. + */ + toMarkup(): string { + // TODO(alpert): More duplication than I'd like from + // span.prototype.toMarkup and symbolNode.prototype.toNode... + let needsSpan = false; + + let markup = " 0) { + styles += `margin-right:${makeEm(this.italic)};`; + } + styles += cssStyleToString(this.style); + + if (styles) { + needsSpan = true; + markup += " style=\"" + escape(styles) + "\""; + } + + const escaped = escape(this.text); + if (needsSpan) { + markup += ">"; + markup += escaped; + markup += ""; + return markup; + } else { + return escaped; + } + } +} + +/** + * SVG nodes are used to render stretchy wide elements. + */ +export class SvgNode implements VirtualNode { + children: SvgChildNode[]; + attributes: Record; + + constructor( + children?: SvgChildNode[], + attributes?: Record, + ) { + this.children = children || []; + this.attributes = attributes || {}; + } + + toNode(): Node { + const svgNS = "http://www.w3.org/2000/svg"; + const node = document.createElementNS(svgNS, "svg"); + + // Apply attributes + for (const attr of Object.keys(this.attributes)) { + node.setAttribute(attr, this.attributes[attr]); + } + + for (let i = 0; i < this.children.length; i++) { + node.appendChild(this.children[i].toNode()); + } + return node; + } + + toMarkup(): string { + let markup = ``; + } else { + return ``; + } + } +} + +export class LineNode implements VirtualNode { + attributes: Record; + + constructor( + attributes?: Record, + ) { + this.attributes = attributes || {}; + } + + toNode(): Node { + const svgNS = "http://www.w3.org/2000/svg"; + const node = document.createElementNS(svgNS, "line"); + + // Apply attributes + for (const attr of Object.keys(this.attributes)) { + node.setAttribute(attr, this.attributes[attr]); + } + + return node; + } + + toMarkup(): string { + let markup = " { + if (group instanceof Span) { + return group; + } else { + throw new Error(`Expected span but got ${String(group)}.`); + } +} + +/** + * Whether an HtmlDomNode has HtmlDomNode children. + * HtmlDomNode is a base type representing a union of + * SymbolNode, SvgSpan, DomSpan, Anchor, and documentFragment. + * In the last three cases, the children are HtmlDomNode[]. + */ +export const hasHtmlDomChildren = ( + node: HtmlDomNode, +): node is DomSpan | Anchor | documentFragment => + node instanceof Span || + node instanceof Anchor || + node instanceof DocumentFragment; diff --git a/node_modules/katex/src/environments.ts b/node_modules/katex/src/environments.ts new file mode 100644 index 0000000..fb26eec --- /dev/null +++ b/node_modules/katex/src/environments.ts @@ -0,0 +1,8 @@ +import {_environments} from "./defineEnvironment"; + +const environments = _environments; + +export default environments; + +// All environment definitions should be imported below +import "./environments/array"; diff --git a/node_modules/katex/src/environments/array.ts b/node_modules/katex/src/environments/array.ts new file mode 100644 index 0000000..778718d --- /dev/null +++ b/node_modules/katex/src/environments/array.ts @@ -0,0 +1,1132 @@ +import {makeFragment, makeLineSpan, makeSpan, makeVList} from "../buildCommon"; +import Style from "../Style"; +import defineEnvironment from "../defineEnvironment"; +import {parseCD} from "./cd"; +import defineFunction from "../defineFunction"; +import defineMacro from "../defineMacro"; +import {MathNode} from "../mathMLTree"; +import ParseError from "../ParseError"; +import {assertNodeType, assertSymbolNodeType} from "../parseNode"; +import {checkSymbolNodeType} from "../parseNode"; +import {Token} from "../Token"; +import {calculateSize, makeEm} from "../units"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; + +import type Parser from "../Parser"; +import type {StyleStr, Mode} from "../types"; +import type {AnyParseNode, ParseNode} from "../types/nodes"; +import type {HtmlBuilder, MathMLBuilder} from "../defineFunction"; +import type {HtmlDomNode} from "../domTree"; + +type EnvContextLike = { + parser: Parser; + envName: string; + mode: Mode; +}; + +// Data stored in the ParseNode associated with the environment. +export type AlignSpec = {type: "separator", separator: string} | { + type: "align"; + align: string; + pregap?: number; + postgap?: number; +}; + +// Type to indicate column separation in MathML +export type ColSeparationType = "align" | "alignat" | "gather" | "small" | "CD"; + +// Helper functions +function getHLines(parser: Parser): boolean[] { + // Return an array. The array length = number of hlines. + // Each element in the array tells if the line is dashed. + const hlineInfo = []; + parser.consumeSpaces(); + let nxt = parser.fetch().text; + if (nxt === "\\relax") { // \relax is an artifact of the \cr macro below + parser.consume(); + parser.consumeSpaces(); + nxt = parser.fetch().text; + } + while (nxt === "\\hline" || nxt === "\\hdashline") { + parser.consume(); + hlineInfo.push(nxt === "\\hdashline"); + parser.consumeSpaces(); + nxt = parser.fetch().text; + } + return hlineInfo; +} + +const validateAmsEnvironmentContext = (context: EnvContextLike) => { + const settings = context.parser.settings; + if (!settings.displayMode) { + throw new ParseError(`{${context.envName}} can be used only in` + + ` display mode.`); + } +}; + +const gatherEnvironments = new Set(["gather", "gather*"]); + +// autoTag (an argument to parseArray) can be one of three values: +// * undefined: Regular (not-top-level) array; no tags on each row +// * true: Automatic equation numbering, overridable by \tag +// * false: Tags allowed on each row, but no automatic numbering +// This function *doesn't* work with the "split" environment name. +function getAutoTag(name: string): boolean | null | undefined { + if (!name.includes("ed")) { + return !name.includes("*"); + } + // return undefined; +} + +/** + * Parse the body of the environment, with rows delimited by \\ and + * columns delimited by &, and create a nested list in row-major order + * with one group per cell. If given an optional argument style + * ("text", "display", etc.), then each cell is cast into that style. + */ +function parseArray( + parser: Parser, + { + hskipBeforeAndAfter, + addJot, + cols, + arraystretch, + colSeparationType, + autoTag, + singleRow, + emptySingleRow, + maxNumCols, + leqno, + }: { + hskipBeforeAndAfter?: boolean; + addJot?: boolean; + cols?: AlignSpec[]; + arraystretch?: number; + colSeparationType?: ColSeparationType; + autoTag?: boolean | null | undefined; + singleRow?: boolean; + emptySingleRow?: boolean; + maxNumCols?: number; + leqno?: boolean; + }, + style: StyleStr, +): ParseNode<"array"> { + parser.gullet.beginGroup(); + if (!singleRow) { + // \cr is equivalent to \\ without the optional size argument (see below) + // TODO: provide helpful error when \cr is used outside array environment + parser.gullet.macros.set("\\cr", "\\\\\\relax"); + } + + // Get current arraystretch if it's not set by the environment + if (!arraystretch) { + const stretch = parser.gullet.expandMacroAsText("\\arraystretch"); + if (stretch == null) { + // Default \arraystretch from lttab.dtx + arraystretch = 1; + } else { + arraystretch = parseFloat(stretch); + if (!arraystretch || arraystretch < 0) { + throw new ParseError(`Invalid \\arraystretch: ${stretch}`); + } + } + } + + // Start group for first cell + parser.gullet.beginGroup(); + + let row: AnyParseNode[] = []; + const body: AnyParseNode[][] = [row]; + const rowGaps = []; + const hLinesBeforeRow = []; + const tags: Array | undefined = + (autoTag != null ? [] : undefined); + + // amsmath uses \global\@eqnswtrue and \global\@eqnswfalse to represent + // whether this row should have an equation number. Simulate this with + // a \@eqnsw macro set to 1 or 0. + function beginRow() { + if (autoTag) { + parser.gullet.macros.set("\\@eqnsw", "1", true); + } + } + function endRow() { + if (tags) { + if (parser.gullet.macros.get("\\df@tag")) { + tags.push(parser.subparse([new Token("\\df@tag")])); + parser.gullet.macros.set("\\df@tag", undefined, true); + } else { + tags.push(Boolean(autoTag) && + parser.gullet.macros.get("\\@eqnsw") === "1"); + } + } + } + beginRow(); + + // Test for \hline at the top of the array. + hLinesBeforeRow.push(getHLines(parser)); + + while (true) { + // Parse each cell in its own group (namespace) + const cellBody = parser.parseExpression(false, singleRow ? "\\end" : "\\\\"); + parser.gullet.endGroup(); + parser.gullet.beginGroup(); + let cell: AnyParseNode = { + type: "ordgroup", + mode: parser.mode, + body: cellBody, + }; + if (style) { + cell = { + type: "styling", + mode: parser.mode, + style, + resetFont: true, + body: [cell], + }; + } + row.push(cell); + const next = parser.fetch().text; + if (next === "&") { + if (maxNumCols && row.length === maxNumCols) { + if (singleRow || colSeparationType) { + // {equation} or {split} + throw new ParseError("Too many tab characters: &", + parser.nextToken); + } else { + // {array} environment + parser.settings.reportNonstrict("textEnv", "Too few columns " + + "specified in the {array} column argument."); + } + } + parser.consume(); + } else if (next === "\\end") { + endRow(); + // Arrays terminate newlines with `\crcr` which consumes a `\cr` if + // the last line is empty. However, AMS environments keep the + // empty row if it's the only one. + // NOTE: Currently, `cell` is the last item added into `row`. + if (row.length === 1 && cell.type === "styling" && + cell.body.length === 1 && cell.body[0].type === "ordgroup" && + cell.body[0].body.length === 0 && + (body.length > 1 || !emptySingleRow)) { + body.pop(); + } + if (hLinesBeforeRow.length < body.length + 1) { + hLinesBeforeRow.push([]); + } + break; + } else if (next === "\\\\") { + parser.consume(); + let size; + // \def\Let@{\let\\\math@cr} + // \def\math@cr{...\math@cr@} + // \def\math@cr@{\new@ifnextchar[\math@cr@@{\math@cr@@[\z@]}} + // \def\math@cr@@[#1]{...\math@cr@@@...} + // \def\math@cr@@@{\cr} + if (parser.gullet.future().text !== " ") { + size = parser.parseSizeGroup(true); + } + rowGaps.push(size ? size.value : null); + endRow(); + + // check for \hline(s) following the row separator + hLinesBeforeRow.push(getHLines(parser)); + + row = []; + body.push(row); + beginRow(); + } else { + throw new ParseError("Expected & or \\\\ or \\cr or \\end", + parser.nextToken); + } + } + + // End cell group + parser.gullet.endGroup(); + // End array group defining \cr + parser.gullet.endGroup(); + + return { + type: "array", + mode: parser.mode, + addJot, + arraystretch, + body, + cols, + rowGaps, + hskipBeforeAndAfter, + hLinesBeforeRow, + colSeparationType, + tags, + leqno, + }; +} + +// Decides on a style for cells in an array according to whether the given +// environment name starts with the letter 'd'. +function dCellStyle(envName: string): StyleStr { + if (envName.slice(0, 1) === "d") { + return "display"; + } else { + return "text"; + } +} + +type Outrow = { + cells: HtmlDomNode[]; + height: number; + depth: number; + pos: number; +}; + +const htmlBuilder: HtmlBuilder<"array"> = function(group, options) { + let r; + let c; + const nr = group.body.length; + const hLinesBeforeRow = group.hLinesBeforeRow; + let nc = 0; + const body: Outrow[] = new Array(nr); + const hlines: Array<{pos: number; isDashed: boolean}> = []; + const ruleThickness = Math.max( + // From LaTeX \showthe\arrayrulewidth. Equals 0.04 em. + options.fontMetrics().arrayRuleWidth, + options.minRuleThickness, // User override. + ); + + // Horizontal spacing + const pt = 1 / options.fontMetrics().ptPerEm; + let arraycolsep = 5 * pt; // default value, i.e. \arraycolsep in article.cls + if (group.colSeparationType && group.colSeparationType === "small") { + // We're in a {smallmatrix}. Default column space is \thickspace, + // i.e. 5/18em = 0.2778em, per amsmath.dtx for {smallmatrix}. + // But that needs adjustment because LaTeX applies \scriptstyle to the + // entire array, including the colspace, but this function applies + // \scriptstyle only inside each element. + const localMultiplier = options.havingStyle(Style.SCRIPT).sizeMultiplier; + arraycolsep = 0.2778 * (localMultiplier / options.sizeMultiplier); + } + + // Vertical spacing + const baselineskip = group.colSeparationType === "CD" + ? calculateSize({number: 3, unit: "ex"}, options) + : 12 * pt; // see size10.clo + // Default \jot from ltmath.dtx + // TODO(edemaine): allow overriding \jot via \setlength (#687) + const jot = 3 * pt; + const arrayskip = group.arraystretch * baselineskip; + const arstrutHeight = 0.7 * arrayskip; // \strutbox in ltfsstrc.dtx and + const arstrutDepth = 0.3 * arrayskip; // \@arstrutbox in lttab.dtx + + let totalHeight = 0; + + // Set a position for \hline(s) at the top of the array, if any. + function setHLinePos(hlinesInGap: boolean[]) { + for (let i = 0; i < hlinesInGap.length; ++i) { + if (i > 0) { + totalHeight += 0.25; + } + hlines.push({pos: totalHeight, isDashed: hlinesInGap[i]}); + } + } + setHLinePos(hLinesBeforeRow[0]); + + for (r = 0; r < group.body.length; ++r) { + const inrow = group.body[r]; + let height = arstrutHeight; // \@array adds an \@arstrut + let depth = arstrutDepth; // to each tow (via the template) + + if (nc < inrow.length) { + nc = inrow.length; + } + + const outrow: Outrow = { + cells: new Array(inrow.length), + height: 0, + depth: 0, + pos: 0, + }; + for (c = 0; c < inrow.length; ++c) { + const elt = html.buildGroup(inrow[c], options); + if (depth < elt.depth) { + depth = elt.depth; + } + if (height < elt.height) { + height = elt.height; + } + outrow.cells[c] = elt; + } + + const rowGap = group.rowGaps[r]; + let gap = 0; + if (rowGap) { + gap = calculateSize(rowGap, options); + if (gap > 0) { // \@argarraycr + gap += arstrutDepth; + if (depth < gap) { + depth = gap; // \@xargarraycr + } + gap = 0; + } + } + // In AMS multiline environments such as aligned and gathered, rows + // correspond to lines that have additional \jot added between lines + // via \openup. + // We simulate this by adding \jot depth to each row except the last. + if (group.addJot && r < group.body.length - 1) { + depth += jot; + } + + outrow.height = height; + outrow.depth = depth; + totalHeight += height; + outrow.pos = totalHeight; + totalHeight += depth + gap; // \@yargarraycr + body[r] = outrow; + + // Set a position for \hline(s), if any. + setHLinePos(hLinesBeforeRow[r + 1]); + } + + const offset = totalHeight / 2 + options.fontMetrics().axisHeight; + const colDescriptions = group.cols || []; + const cols: HtmlDomNode[] = []; + let colSep; + let colDescrNum; + const tagSpans: Array<{ + type: "elem"; + elem: HtmlDomNode; + shift: number; + }> = []; + + if (group.tags && group.tags.some(tag => tag)) { + // An environment with manual tags and/or automatic equation numbers. + // Create node(s), the latter of which trigger CSS counter increment. + for (r = 0; r < nr; ++r) { + const rw = body[r]; + const shift = rw.pos - offset; + const tag = group.tags[r]; + let tagSpan; + if (tag === true) { // automatic numbering + tagSpan = makeSpan(["eqn-num"], [], options); + } else if (tag === false) { + // \nonumber/\notag or starred environment + tagSpan = makeSpan([], [], options); + } else { // manual \tag + tagSpan = makeSpan([], + html.buildExpression(tag, options, true), options); + } + tagSpan.depth = rw.depth; + tagSpan.height = rw.height; + tagSpans.push({type: "elem", elem: tagSpan, shift}); + } + } + + for (c = 0, colDescrNum = 0; + // Continue while either there are more columns or more column + // descriptions, so trailing separators don't get lost. + c < nc || colDescrNum < colDescriptions.length; + ++c, ++colDescrNum) { + let colDescr: AlignSpec | undefined = colDescriptions[colDescrNum]; + + let firstSeparator = true; + while (colDescr?.type === "separator") { + // If there is more than one separator in a row, add a space + // between them. + if (!firstSeparator) { + colSep = makeSpan(["arraycolsep"], []); + colSep.style.width = + makeEm(options.fontMetrics().doubleRuleSep); + cols.push(colSep); + } + + if (colDescr.separator === "|" || colDescr.separator === ":") { + const lineType = colDescr.separator === "|" ? "solid" : "dashed"; + const separator = makeSpan(["vertical-separator"], [], options); + separator.style.height = makeEm(totalHeight); + separator.style.borderRightWidth = makeEm(ruleThickness); + separator.style.borderRightStyle = lineType; + separator.style.margin = `0 ${makeEm(-ruleThickness / 2)}`; + const shift = totalHeight - offset; + if (shift) { + separator.style.verticalAlign = makeEm(-shift); + } + + cols.push(separator); + } else { + throw new ParseError( + "Invalid separator type: " + colDescr.separator); + } + + colDescrNum++; + colDescr = colDescriptions[colDescrNum]; + firstSeparator = false; + } + + if (c >= nc) { + continue; + } + + let sepwidth; + if (c > 0 || group.hskipBeforeAndAfter) { + sepwidth = colDescr?.pregap ?? arraycolsep; + if (sepwidth !== 0) { + colSep = makeSpan(["arraycolsep"], []); + colSep.style.width = makeEm(sepwidth); + cols.push(colSep); + } + } + + const colElems: Array<{ + type: "elem"; + elem: HtmlDomNode; + shift: number; + }> = []; + for (r = 0; r < nr; ++r) { + const row = body[r]; + const elem = row.cells[c]; + if (!elem) { + continue; + } + const shift = row.pos - offset; + elem.depth = row.depth; + elem.height = row.height; + colElems.push({type: "elem", elem: elem, shift: shift}); + } + + const colVList = makeVList({ + positionType: "individualShift", + children: colElems, + }, options); + const colSpan = makeSpan( + ["col-align-" + (colDescr?.align || "c")], + [colVList], + ); + cols.push(colSpan); + + if (c < nc - 1 || group.hskipBeforeAndAfter) { + sepwidth = colDescr?.postgap ?? arraycolsep; + if (sepwidth !== 0) { + colSep = makeSpan(["arraycolsep"], []); + colSep.style.width = makeEm(sepwidth); + cols.push(colSep); + } + } + } + + let tableBody: HtmlDomNode = makeSpan(["mtable"], cols); + + // Add \hline(s), if any. + if (hlines.length > 0) { + const line = makeLineSpan("hline", options, ruleThickness); + const dashes = makeLineSpan("hdashline", options, ruleThickness); + const vListElems = [{type: "elem" as const, elem: tableBody, shift: 0}]; + while (hlines.length > 0) { + const hline = hlines.pop()!; + const lineShift = hline.pos - offset; + if (hline.isDashed) { + vListElems.push({type: "elem" as const, elem: dashes, shift: lineShift}); + } else { + vListElems.push({type: "elem" as const, elem: line, shift: lineShift}); + } + } + + tableBody = makeVList({ + positionType: "individualShift", + children: vListElems, + }, options); + } + + if (tagSpans.length === 0) { + return makeSpan(["mord"], [tableBody], options); + } else { + const eqnNumCol = makeVList({ + positionType: "individualShift", + children: tagSpans, + }, options); + const tagCol = makeSpan(["tag"], [eqnNumCol], options); + return makeFragment([tableBody, tagCol]); + } +}; + +const alignMap: Record = { + c: "center ", + l: "left ", + r: "right ", +}; + +const mathmlBuilder: MathMLBuilder<"array"> = function(group, options) { + const tbl = []; + const glue = new MathNode("mtd", [], ["mtr-glue"]); + const tag = new MathNode("mtd", [], ["mml-eqn-num"]); + for (let i = 0; i < group.body.length; i++) { + const rw = group.body[i]; + const row = []; + for (let j = 0; j < rw.length; j++) { + row.push(new MathNode("mtd", + [mml.buildGroup(rw[j], options)])); + } + if (group.tags && group.tags[i]) { + row.unshift(glue); + row.push(glue); + if (group.leqno) { + row.unshift(tag); + } else { + row.push(tag); + } + } + tbl.push(new MathNode("mtr", row)); + } + let table = new MathNode("mtable", tbl); + + // Set column alignment, row spacing, column spacing, and + // array lines by setting attributes on the table element. + + // Set the row spacing. In MathML, we specify a gap distance. + // We do not use rowGap[] because MathML automatically increases + // cell height with the height/depth of the element content. + + // LaTeX \arraystretch multiplies the row baseline-to-baseline distance. + // We simulate this by adding (arraystretch - 1)em to the gap. This + // does a reasonable job of adjusting arrays containing 1 em tall content. + + // The 0.16 and 0.09 values are found empirically. They produce an array + // similar to LaTeX and in which content does not interfere with \hlines. + const gap = (group.arraystretch === 0.5) + ? 0.1 // {smallmatrix}, {subarray} + : 0.16 + group.arraystretch - 1 + (group.addJot ? 0.09 : 0); + table.setAttribute("rowspacing", makeEm(gap)); + + // MathML table lines go only between cells. + // To place a line on an edge we'll use , if necessary. + let menclose = ""; + let align = ""; + + if (group.cols && group.cols.length > 0) { + // Find column alignment, column spacing, and vertical lines. + const cols = group.cols; + let columnLines = ""; + let prevTypeWasAlign = false; + let iStart = 0; + let iEnd = cols.length; + + if (cols[0].type === "separator") { + menclose += "top "; + iStart = 1; + } + if (cols[cols.length - 1].type === "separator") { + menclose += "bottom "; + iEnd -= 1; + } + + for (let i = iStart; i < iEnd; i++) { + const col = cols[i]; + if (col.type === "align") { + align += alignMap[col.align]; + + if (prevTypeWasAlign) { + columnLines += "none "; + } + prevTypeWasAlign = true; + } else if (col.type === "separator") { + // MathML accepts only single lines between cells. + // So we read only the first of consecutive separators. + if (prevTypeWasAlign) { + columnLines += col.separator === "|" ? "solid " : "dashed "; + prevTypeWasAlign = false; + } + } + } + + table.setAttribute("columnalign", align.trim()); + + if (/[sd]/.test(columnLines)) { + table.setAttribute("columnlines", columnLines.trim()); + } + } + + // Set column spacing. + if (group.colSeparationType === "align") { + const cols = group.cols || []; + let spacing = ""; + for (let i = 1; i < cols.length; i++) { + spacing += i % 2 ? "0em " : "1em "; + } + table.setAttribute("columnspacing", spacing.trim()); + } else if (group.colSeparationType === "alignat" || + group.colSeparationType === "gather") { + table.setAttribute("columnspacing", "0em"); + } else if (group.colSeparationType === "small") { + table.setAttribute("columnspacing", "0.2778em"); + } else if (group.colSeparationType === "CD") { + table.setAttribute("columnspacing", "0.5em"); + } else { + table.setAttribute("columnspacing", "1em"); + } + + // Address \hline and \hdashline + let rowLines = ""; + const hlines = group.hLinesBeforeRow; + + menclose += hlines[0].length > 0 ? "left " : ""; + menclose += hlines[hlines.length - 1].length > 0 ? "right " : ""; + + for (let i = 1; i < hlines.length - 1; i++) { + rowLines += (hlines[i].length === 0) + ? "none " + // MathML accepts only a single line between rows. Read one element. + : hlines[i][0] ? "dashed " : "solid "; + } + if (/[sd]/.test(rowLines)) { + table.setAttribute("rowlines", rowLines.trim()); + } + + if (menclose !== "") { + table = new MathNode("menclose", [table]); + table.setAttribute("notation", menclose.trim()); + } + + if (group.arraystretch && group.arraystretch < 1) { + // A small array. Wrap in scriptstyle so row gap is not too large. + table = new MathNode("mstyle", [table]); + table.setAttribute("scriptlevel", "1"); + } + + return table; +}; + +// Convenience function for align, align*, aligned, alignat, alignat*, alignedat. +const alignedHandler = function(context: EnvContextLike, args: AnyParseNode[]) { + if (!context.envName.includes("ed")) { + validateAmsEnvironmentContext(context); + } + const cols: AlignSpec[] = []; + const isSplit = context.envName === "split"; + const res = parseArray(context.parser, + { + cols, + addJot: true, + autoTag: isSplit ? undefined : getAutoTag(context.envName), + emptySingleRow: true, + colSeparationType: context.envName.includes("at") ? "alignat" : "align", + maxNumCols: isSplit ? 2 : undefined, + leqno: context.parser.settings.leqno, + }, + "display" + ); + + // Determining number of columns. + // 1. If the first argument is given, we use it as a number of columns, + // and makes sure that each row doesn't exceed that number. + // 2. Otherwise, just count number of columns = maximum number + // of cells in each row ("aligned" mode -- isAligned will be true). + // + // At the same time, prepend empty group {} at beginning of every second + // cell in each row (starting with second cell) so that operators become + // binary. This behavior is implemented in amsmath's \start@aligned. + let numMaths = 0; + let numCols = 0; + const emptyGroup: ParseNode<"ordgroup"> = { + type: "ordgroup", + mode: context.mode, + body: [], + }; + if (args[0] && args[0].type === "ordgroup") { + let arg0 = ""; + for (let i = 0; i < args[0].body.length; i++) { + const textord = assertNodeType(args[0].body[i], "textord"); + arg0 += textord.text; + } + numMaths = Number(arg0); + numCols = numMaths * 2; + } + const isAligned = !numCols; + res.body.forEach(function(row) { + for (let i = 1; i < row.length; i += 2) { + // Modify ordgroup node within styling node + const styling = assertNodeType(row[i], "styling"); + const ordgroup = assertNodeType(styling.body[0], "ordgroup"); + ordgroup.body.unshift(emptyGroup); + } + if (!isAligned) { // Case 1 + const curMaths = row.length / 2; + if (numMaths < curMaths) { + throw new ParseError( + "Too many math in a row: " + + `expected ${numMaths}, but got ${curMaths}`, + row[0]); + } + } else if (numCols < row.length) { // Case 2 + numCols = row.length; + } + }); + + // Adjusting alignment. + // In aligned mode, we add one \qquad between columns; + // otherwise we add nothing. + for (let i = 0; i < numCols; ++i) { + let align = "r"; + let pregap = 0; + if (i % 2 === 1) { + align = "l"; + } else if (i > 0 && isAligned) { // "aligned" mode. + pregap = 1; // add one \quad + } + cols[i] = { + type: "align", + align: align, + pregap: pregap, + postgap: 0, + }; + } + res.colSeparationType = isAligned ? "align" : "alignat"; + return res; +}; + +// Arrays are part of LaTeX, defined in lttab.dtx so its documentation +// is part of the source2e.pdf file of LaTeX2e source documentation. +// {darray} is an {array} environment where cells are set in \displaystyle, +// as defined in nccmath.sty. +defineEnvironment({ + type: "array", + names: ["array", "darray"], + props: { + numArgs: 1, + }, + handler(context, args) { + // Since no types are specified above, the two possibilities are + // - The argument is wrapped in {} or [], in which case Parser's + // parseGroup() returns an "ordgroup" wrapping some symbol node. + // - The argument is a bare symbol node. + const symNode = checkSymbolNodeType(args[0]); + const colalign: AnyParseNode[] = + symNode ? [args[0]] : assertNodeType(args[0], "ordgroup").body; + const cols: AlignSpec[] = colalign.map(function(nde) { + const node = assertSymbolNodeType(nde); + const ca = node.text; + if ("lcr".includes(ca)) { + return { + type: "align", + align: ca, + }; + } else if (ca === "|") { + return { + type: "separator", + separator: "|", + }; + } else if (ca === ":") { + return { + type: "separator", + separator: ":", + }; + } + throw new ParseError("Unknown column alignment: " + ca, nde); + }); + const res: Parameters[1] = { + cols, + hskipBeforeAndAfter: true, // \@preamble in lttab.dtx + maxNumCols: cols.length, + }; + return parseArray(context.parser, res, dCellStyle(context.envName)); + }, + htmlBuilder, + mathmlBuilder, +}); + +// The matrix environments of amsmath builds on the array environment +// of LaTeX, which is discussed above. +// The mathtools package adds starred versions of the same environments. +// These have an optional argument to choose left|center|right justification. +defineEnvironment({ + type: "array", + names: [ + "matrix", + "pmatrix", + "bmatrix", + "Bmatrix", + "vmatrix", + "Vmatrix", + "matrix*", + "pmatrix*", + "bmatrix*", + "Bmatrix*", + "vmatrix*", + "Vmatrix*", + ], + props: { + numArgs: 0, + }, + handler(context) { + const delimiters = { + "matrix": null, + "pmatrix": ["(", ")"], + "bmatrix": ["[", "]"], + "Bmatrix": ["\\{", "\\}"], + "vmatrix": ["|", "|"], + "Vmatrix": ["\\Vert", "\\Vert"], + }[context.envName.replace("*", "")]; + // \hskip -\arraycolsep in amsmath + let colAlign = "c"; + const payload: Parameters[1] = { + hskipBeforeAndAfter: false, + cols: [{type: "align", align: colAlign}], + }; + if (context.envName.charAt(context.envName.length - 1) === "*") { + // It's one of the mathtools starred functions. + // Parse the optional alignment argument. + const parser = context.parser; + parser.consumeSpaces(); + if (parser.fetch().text === "[") { + parser.consume(); + parser.consumeSpaces(); + colAlign = parser.fetch().text; + if (!"lcr".includes(colAlign)) { + throw new ParseError("Expected l or c or r", parser.nextToken); + } + parser.consume(); + parser.consumeSpaces(); + parser.expect("]"); + parser.consume(); + payload.cols = [{type: "align", align: colAlign}]; + } + } + const res = parseArray(context.parser, payload, dCellStyle(context.envName)); + // Populate cols with the correct number of column alignment specs. + const numCols = Math.max(0, ...res.body.map(row => row.length)); + res.cols = new Array(numCols).fill( + {type: "align", align: colAlign} + ); + return delimiters ? { + type: "leftright", + mode: context.mode, + body: [res], + left: delimiters[0], + right: delimiters[1], + rightColor: undefined, // \right uninfluenced by \color in array + } : res; + }, + htmlBuilder, + mathmlBuilder, +}); + +defineEnvironment({ + type: "array", + names: ["smallmatrix"], + props: { + numArgs: 0, + }, + handler(context) { + const payload: Parameters[1] = {arraystretch: 0.5}; + const res = parseArray(context.parser, payload, "script"); + res.colSeparationType = "small"; + return res; + }, + htmlBuilder, + mathmlBuilder, +}); + +defineEnvironment({ + type: "array", + names: ["subarray"], + props: { + numArgs: 1, + }, + handler(context, args) { + // Parsing of {subarray} is similar to {array} + const symNode = checkSymbolNodeType(args[0]); + const colalign: AnyParseNode[] = + symNode ? [args[0]] : assertNodeType(args[0], "ordgroup").body; + const cols: AlignSpec[] = colalign.map(function(nde) { + const node = assertSymbolNodeType(nde); + const ca = node.text; + // {subarray} only recognizes "l" & "c" + if ("lc".includes(ca)) { + return { + type: "align", + align: ca, + }; + } + throw new ParseError("Unknown column alignment: " + ca, nde); + }); + if (cols.length > 1) { + throw new ParseError("{subarray} can contain only one column"); + } + const payload: Parameters[1] = { + cols, + hskipBeforeAndAfter: false, + arraystretch: 0.5, + }; + const res = parseArray(context.parser, payload, "script"); + if (res.body.length > 0 && res.body[0].length > 1) { + throw new ParseError("{subarray} can contain only one column"); + } + return res; + }, + htmlBuilder, + mathmlBuilder, +}); + +// A cases environment (in amsmath.sty) is almost equivalent to +// \def\arraystretch{1.2}% +// \left\{\begin{array}{@{}l@{\quad}l@{}} … \end{array}\right. +// {dcases} is a {cases} environment where cells are set in \displaystyle, +// as defined in mathtools.sty. +// {rcases} is another mathtools environment. It's brace is on the right side. +defineEnvironment({ + type: "array", + names: [ + "cases", + "dcases", + "rcases", + "drcases", + ], + props: { + numArgs: 0, + }, + handler(context) { + const payload: Parameters[1] = { + arraystretch: 1.2, + cols: [{ + type: "align", + align: "l", + pregap: 0, + // TODO(kevinb) get the current style. + // For now we use the metrics for TEXT style which is what we were + // doing before. Before attempting to get the current style we + // should look at TeX's behavior especially for \over and matrices. + postgap: 1.0, /* 1em quad */ + }, { + type: "align", + align: "l", + pregap: 0, + postgap: 0, + }], + }; + const res = parseArray(context.parser, payload, dCellStyle(context.envName)); + return { + type: "leftright", + mode: context.mode, + body: [res], + left: context.envName.includes("r") ? "." : "\\{", + right: context.envName.includes("r") ? "\\}" : ".", + rightColor: undefined, + }; + }, + htmlBuilder, + mathmlBuilder, +}); + +// In the align environment, one uses ampersands, &, to specify number of +// columns in each row, and to locate spacing between each column. +// align gets automatic numbering. align* and aligned do not. +// The alignedat environment can be used in math mode. +// Note that we assume \nomallineskiplimit to be zero, +// so that \strut@ is the same as \strut. +defineEnvironment({ + type: "array", + names: ["align", "align*", "aligned", "split"], + props: { + numArgs: 0, + }, + handler: alignedHandler, + htmlBuilder, + mathmlBuilder, +}); + +// A gathered environment is like an array environment with one centered +// column, but where rows are considered lines so get \jot line spacing +// and contents are set in \displaystyle. +defineEnvironment({ + type: "array", + names: ["gathered", "gather", "gather*"], + props: { + numArgs: 0, + }, + handler(context) { + if (gatherEnvironments.has(context.envName)) { + validateAmsEnvironmentContext(context); + } + const res: Parameters[1] = { + cols: [{ + type: "align", + align: "c", + }], + addJot: true, + colSeparationType: "gather", + autoTag: getAutoTag(context.envName), + emptySingleRow: true, + leqno: context.parser.settings.leqno, + }; + return parseArray(context.parser, res, "display"); + }, + htmlBuilder, + mathmlBuilder, +}); + +// alignat environment is like an align environment, but one must explicitly +// specify maximum number of columns in each row, and can adjust spacing between +// each columns. +defineEnvironment({ + type: "array", + names: ["alignat", "alignat*", "alignedat"], + props: { + numArgs: 1, + }, + handler: alignedHandler, + htmlBuilder, + mathmlBuilder, +}); + +defineEnvironment({ + type: "array", + names: ["equation", "equation*"], + props: { + numArgs: 0, + }, + handler(context) { + validateAmsEnvironmentContext(context); + const res: Parameters[1] = { + autoTag: getAutoTag(context.envName), + emptySingleRow: true, + singleRow: true, + maxNumCols: 1, + leqno: context.parser.settings.leqno, + }; + return parseArray(context.parser, res, "display"); + }, + htmlBuilder, + mathmlBuilder, +}); + +defineEnvironment({ + type: "array", + names: ["CD"], + props: { + numArgs: 0, + }, + handler(context) { + validateAmsEnvironmentContext(context); + return parseCD(context.parser); + }, + htmlBuilder, + mathmlBuilder, +}); + +defineMacro("\\nonumber", "\\gdef\\@eqnsw{0}"); +defineMacro("\\notag", "\\nonumber"); + +// Catch \hline outside array environment +defineFunction({ + type: "text", // Doesn't matter what this is. + names: ["\\hline", "\\hdashline"], + numArgs: 0, + allowedInText: true, + allowedInMath: true, + + handler(context, args) { + throw new ParseError( + `${context.funcName} valid only within array environment`); + }, +}); diff --git a/node_modules/katex/src/environments/cd.ts b/node_modules/katex/src/environments/cd.ts new file mode 100644 index 0000000..ef9452c --- /dev/null +++ b/node_modules/katex/src/environments/cd.ts @@ -0,0 +1,318 @@ +import {wrapFragment} from "../buildCommon"; +import defineFunction from "../defineFunction"; +import {MathNode} from "../mathMLTree"; +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; +import {assertSymbolNodeType} from "../parseNode"; +import ParseError from "../ParseError"; +import {makeEm} from "../units"; + +import type Parser from "../Parser"; +import type {AnyParseNode, ParseNode} from "../types/nodes"; +import type {Slice4} from "../types"; + +const cdArrowFunctionName: Record = { + ">": "\\\\cdrightarrow", + "<": "\\\\cdleftarrow", + "=": "\\\\cdlongequal", + "A": "\\uparrow", + "V": "\\downarrow", + "|": "\\Vert", + ".": "no arrow", +}; + +const newCell = (): ParseNode<"styling"> => { + // Create an empty cell, to be filled below with parse nodes. + // The parseTree from this module must be constructed like the + // one created by parseArray(), so an empty CD cell must + // be a ParseNode<"styling">. And CD is always displaystyle. + return { + type: "styling", + body: [], + mode: "math", + style: "display", + resetFont: true, + }; +}; + +const isStartOfArrow = (node: AnyParseNode) => { + return (node.type === "textord" && node.text === "@"); +}; + +const isLabelEnd = (node: AnyParseNode, endChar: string): boolean => { + return ((node.type === "mathord" || node.type === "atom") && + node.text === endChar); +}; + +function cdArrow( + arrowChar: string, + labels: ParseNode<"ordgroup">[], + parser: Parser +): AnyParseNode { + // Return a parse tree of an arrow and its labels. + // This acts in a way similar to a macro expansion. + const funcName = cdArrowFunctionName[arrowChar]; + switch (funcName) { + case "\\\\cdrightarrow": + case "\\\\cdleftarrow": + return parser.callFunction( + funcName, [labels[0]], [labels[1]] + ); + case "\\uparrow": + case "\\downarrow": { + const leftLabel = parser.callFunction( + "\\\\cdleft", [labels[0]], [] + ); + const bareArrow: ParseNode<"atom"> = { + type: "atom", + text: funcName, + mode: "math", + family: "rel", + }; + const sizedArrow = parser.callFunction("\\Big", [bareArrow], []); + const rightLabel = parser.callFunction( + "\\\\cdright", [labels[1]], [] + ); + const arrowGroup: ParseNode<"ordgroup"> = { + type: "ordgroup", + mode: "math", + body: [leftLabel, sizedArrow, rightLabel], + }; + return parser.callFunction("\\\\cdparent", [arrowGroup], []); + } + case "\\\\cdlongequal": + return parser.callFunction("\\\\cdlongequal", [], []); + case "\\Vert": { + const arrow: ParseNode<"textord"> = {type: "textord", text: "\\Vert", mode: "math"}; + return parser.callFunction("\\Big", [arrow], []); + } + default: + return {type: "textord", text: " ", mode: "math"}; + } +} + +export function parseCD(parser: Parser): ParseNode<"array"> { + // Get the array's parse nodes with \\ temporarily mapped to \cr. + const parsedRows: AnyParseNode[][] = []; + parser.gullet.beginGroup(); + parser.gullet.macros.set("\\cr", "\\\\\\relax"); + parser.gullet.beginGroup(); + while (true) { + // Get the parse nodes for the next row. + parsedRows.push(parser.parseExpression(false, "\\\\")); + parser.gullet.endGroup(); + parser.gullet.beginGroup(); + const next = parser.fetch().text; + if (next === "&" || next === "\\\\") { + parser.consume(); + } else if (next === "\\end") { + if (parsedRows[parsedRows.length - 1].length === 0) { + parsedRows.pop(); // final row ended in \\ + } + break; + } else { + throw new ParseError("Expected \\\\ or \\cr or \\end", + parser.nextToken); + } + } + + let row: ParseNode<"styling">[] = []; + const body: ParseNode<"styling">[][] = [row]; + + // Loop thru the parse nodes. Collect them into cells and arrows. + for (let i = 0; i < parsedRows.length; i++) { + // Start a new row. + const rowNodes = parsedRows[i]; + // Create the first cell. + let cell = newCell(); + + for (let j = 0; j < rowNodes.length; j++) { + if (!isStartOfArrow(rowNodes[j])) { + // If a parseNode is not an arrow, it goes into a cell. + cell.body.push(rowNodes[j]); + } else { + // Parse node j is an "@", the start of an arrow. + // Before starting on the arrow, push the cell into `row`. + row.push(cell); + + // Now collect parseNodes into an arrow. + // The character after "@" defines the arrow type. + j += 1; + const arrowChar = assertSymbolNodeType(rowNodes[j]).text; + + // Create two empty label nodes. We may or may not use them. + const labels: ParseNode<"ordgroup">[] = new Array(2); + labels[0] = {type: "ordgroup", mode: "math", body: []}; + labels[1] = {type: "ordgroup", mode: "math", body: []}; + + // Process the arrow. + if ("=|.".includes(arrowChar)) { + // Three "arrows", ``@=`, `@|`, and `@.`, do not take labels. + // Do nothing here. + } else if ("<>AV".includes(arrowChar)) { + // Four arrows, `@>>>`, `@<<<`, `@AAA`, and `@VVV`, each take + // two optional labels. E.g. the right-point arrow syntax is + // really: @>{optional label}>{optional label}> + // Collect parseNodes into labels. + for (let labelNum = 0; labelNum < 2; labelNum++) { + let inLabel = true; + for (let k = j + 1; k < rowNodes.length; k++) { + if (isLabelEnd(rowNodes[k], arrowChar)) { + inLabel = false; + j = k; + break; + } + if (isStartOfArrow(rowNodes[k])) { + throw new ParseError("Missing a " + arrowChar + + " character to complete a CD arrow.", rowNodes[k]); + } + + labels[labelNum].body.push(rowNodes[k]); + } + if (inLabel) { + // isLabelEnd never returned a true. + throw new ParseError("Missing a " + arrowChar + + " character to complete a CD arrow.", rowNodes[j]); + } + } + } else { + throw new ParseError(`Expected one of "<>AV=|." after @`, + rowNodes[j]); + } + + // Now join the arrow to its labels. + const arrow: AnyParseNode = cdArrow(arrowChar, labels, parser); + + // Wrap the arrow in ParseNode<"styling">. + // This is done to match parseArray() behavior. + const wrappedArrow: ParseNode<"styling"> = { + type: "styling", + body: [arrow], + mode: "math", + style: "display", // CD is always displaystyle. + resetFont: true, + }; + row.push(wrappedArrow); + // In CD's syntax, cells are implicit. That is, everything that + // is not an arrow gets collected into a cell. So create an empty + // cell now. It will collect upcoming parseNodes. + cell = newCell(); + } + } + if (i % 2 === 0) { + // Even-numbered rows consist of: cell, arrow, cell, arrow, ... cell + // The last cell is not yet pushed into `row`, so: + row.push(cell); + } else { + // Odd-numbered rows consist of: vert arrow, empty cell, ... vert arrow + // Remove the empty cell that was placed at the beginning of `row`. + row.shift(); + } + row = []; + body.push(row); + } + + // End row group + parser.gullet.endGroup(); + // End array group defining \\ + parser.gullet.endGroup(); + + // define column separation. + const cols = new Array(body[0].length).fill({ + type: "align", + align: "c", + pregap: 0.25, // CD package sets \enskip between columns. + postgap: 0.25, // So pre and post each get half an \enskip, i.e. 0.25em. + }); + + return { + type: "array", + mode: "math", + body, + arraystretch: 1, + addJot: true, + rowGaps: [null], + cols, + colSeparationType: "CD", + hLinesBeforeRow: new Array(body.length + 1).fill([]), + }; +} + +// The functions below are not available for general use. +// They are here only for internal use by the {CD} environment in placing labels +// next to vertical arrows. + +// We don't need any such functions for horizontal arrows because we can reuse +// the functionality that already exists for extensible arrows. + +defineFunction({ + type: "cdlabel", + names: ["\\\\cdleft", "\\\\cdright"], + numArgs: 1, + handler({parser, funcName}, args) { + return { + type: "cdlabel", + mode: parser.mode, + side: funcName.slice(4) as Slice4, + label: args[0], + }; + }, + + htmlBuilder(group, options) { + const newOptions = options.havingStyle(options.style.sup()); + const label = wrapFragment( + html.buildGroup(group.label, newOptions, options), options); + label.classes.push("cd-label-" + group.side); + label.style.bottom = makeEm(0.8 - label.depth); + // Zero out label height & depth, so vertical align of arrow is set + // by the arrow height, not by the label. + label.height = 0; + label.depth = 0; + return label; + }, + mathmlBuilder(group, options) { + let label = new MathNode("mrow", + [mml.buildGroup(group.label, options)]); + label = new MathNode("mpadded", [label]); + label.setAttribute("width", "0"); + if (group.side === "left") { + label.setAttribute("lspace", "-1width"); + } + // We have to guess at vertical alignment. We know the arrow is 1.8em tall, + // But we don't know the height or depth of the label. + label.setAttribute("voffset", "0.7em"); + label = new MathNode("mstyle", [label]); + label.setAttribute("displaystyle", "false"); + label.setAttribute("scriptlevel", "1"); + return label; + }, +}); + +defineFunction({ + type: "cdlabelparent", + names: ["\\\\cdparent"], + numArgs: 1, + + handler({parser}, args) { + return { + type: "cdlabelparent", + mode: parser.mode, + fragment: args[0], + }; + }, + + htmlBuilder(group, options) { + // Wrap the vertical arrow and its labels. + // The parent gets position: relative. The child gets position: absolute. + // So CSS can locate the label correctly. + const parent = wrapFragment( + html.buildGroup(group.fragment, options), options + ); + parent.classes.push("cd-vert-arrow"); + return parent; + }, + mathmlBuilder(group, options) { + return new MathNode("mrow", + [mml.buildGroup(group.fragment, options)]); + }, +}); diff --git a/node_modules/katex/src/fontMetrics.ts b/node_modules/katex/src/fontMetrics.ts new file mode 100644 index 0000000..acd75c2 --- /dev/null +++ b/node_modules/katex/src/fontMetrics.ts @@ -0,0 +1,267 @@ +import {supportedCodepoint} from "./unicodeScripts"; + +import type {Mode} from "./types"; +import type {CharacterMetrics, CharacterMetricsTuple, FontMetrics} from "./types/fonts"; +// This map contains a mapping from font name and character code to character +// metrics, including height, depth, italic correction, and skew (kern from the +// character to the corresponding \skewchar) +// This map is generated via `make metrics`. It should not be changed manually. +import metricMap from "./fontMetricsData"; + +/** + * This file contains metrics regarding fonts and individual symbols. The sigma + * and xi variables, as well as the metricMap map contain data extracted from + * TeX, TeX font metrics, and the TTF files. These data are then exposed via the + * `metrics` variable and the getCharacterMetrics function. + */ + +// In TeX, there are actually three sets of dimensions, one for each of +// textstyle (size index 5 and higher: >=9pt), scriptstyle (size index 3 and 4: +// 7-8pt), and scriptscriptstyle (size index 1 and 2: 5-6pt). These are +// provided in the arrays below, in that order. +// +// The font metrics are stored in fonts cmsy10, cmsy7, and cmsy5 respectively. +// This was determined by running the following script: +// +// latex -interaction=nonstopmode \ +// '\documentclass{article}\usepackage{amsmath}\begin{document}' \ +// '$a$ \expandafter\show\the\textfont2' \ +// '\expandafter\show\the\scriptfont2' \ +// '\expandafter\show\the\scriptscriptfont2' \ +// '\stop' +// +// The metrics themselves were retrieved using the following commands: +// +// tftopl cmsy10 +// tftopl cmsy7 +// tftopl cmsy5 +// +// The output of each of these commands is quite lengthy. The only part we +// care about is the FONTDIMEN section. Each value is measured in EMs. +const sigmasAndXis: Record = { + slant: [0.250, 0.250, 0.250], // sigma1 + space: [0.000, 0.000, 0.000], // sigma2 + stretch: [0.000, 0.000, 0.000], // sigma3 + shrink: [0.000, 0.000, 0.000], // sigma4 + xHeight: [0.431, 0.431, 0.431], // sigma5 + quad: [1.000, 1.171, 1.472], // sigma6 + extraSpace: [0.000, 0.000, 0.000], // sigma7 + num1: [0.677, 0.732, 0.925], // sigma8 + num2: [0.394, 0.384, 0.387], // sigma9 + num3: [0.444, 0.471, 0.504], // sigma10 + denom1: [0.686, 0.752, 1.025], // sigma11 + denom2: [0.345, 0.344, 0.532], // sigma12 + sup1: [0.413, 0.503, 0.504], // sigma13 + sup2: [0.363, 0.431, 0.404], // sigma14 + sup3: [0.289, 0.286, 0.294], // sigma15 + sub1: [0.150, 0.143, 0.200], // sigma16 + sub2: [0.247, 0.286, 0.400], // sigma17 + supDrop: [0.386, 0.353, 0.494], // sigma18 + subDrop: [0.050, 0.071, 0.100], // sigma19 + delim1: [2.390, 1.700, 1.980], // sigma20 + delim2: [1.010, 1.157, 1.420], // sigma21 + axisHeight: [0.250, 0.250, 0.250], // sigma22 + + // These font metrics are extracted from TeX by using tftopl on cmex10.tfm; + // they correspond to the font parameters of the extension fonts (family 3). + // See the TeXbook, page 441. In AMSTeX, the extension fonts scale; to + // match cmex7, we'd use cmex7.tfm values for script and scriptscript + // values. + defaultRuleThickness: [0.04, 0.049, 0.049], // xi8; cmex7: 0.049 + bigOpSpacing1: [0.111, 0.111, 0.111], // xi9 + bigOpSpacing2: [0.166, 0.166, 0.166], // xi10 + bigOpSpacing3: [0.2, 0.2, 0.2], // xi11 + bigOpSpacing4: [0.6, 0.611, 0.611], // xi12; cmex7: 0.611 + bigOpSpacing5: [0.1, 0.143, 0.143], // xi13; cmex7: 0.143 + + // The \sqrt rule width is taken from the height of the surd character. + // Since we use the same font at all sizes, this thickness doesn't scale. + sqrtRuleThickness: [0.04, 0.04, 0.04], + + // This value determines how large a pt is, for metrics which are defined + // in terms of pts. + // This value is also used in katex.scss; if you change it make sure the + // values match. + ptPerEm: [10.0, 10.0, 10.0], + + // The space between adjacent `|` columns in an array definition. From + // `\showthe\doublerulesep` in LaTeX. Equals 2.0 / ptPerEm. + doubleRuleSep: [0.2, 0.2, 0.2], + + // The width of separator lines in {array} environments. From + // `\showthe\arrayrulewidth` in LaTeX. Equals 0.4 / ptPerEm. + arrayRuleWidth: [0.04, 0.04, 0.04], + + // Two values from LaTeX source2e: + fboxsep: [0.3, 0.3, 0.3], // 3 pt / ptPerEm + fboxrule: [0.04, 0.04, 0.04], // 0.4 pt / ptPerEm +}; + +// These are very rough approximations. We default to Times New Roman which +// should have Latin-1 and Cyrillic characters, but may not depending on the +// operating system. The metrics do not account for extra height from the +// accents. In the case of Cyrillic characters which have both ascenders and +// descenders we prefer approximations with ascenders, primarily to prevent +// the fraction bar or root line from intersecting the glyph. +// TODO(kevinb) allow union of multiple glyph metrics for better accuracy. +const extraCharacterMap: Record = { + // Latin-1 + 'Å': 'A', + 'Ð': 'D', + 'Þ': 'o', + 'å': 'a', + 'ð': 'd', + 'þ': 'o', + + // Cyrillic + 'А': 'A', + 'Б': 'B', + 'В': 'B', + 'Г': 'F', + 'Д': 'A', + 'Е': 'E', + 'Ж': 'K', + 'З': '3', + 'И': 'N', + 'Й': 'N', + 'К': 'K', + 'Л': 'N', + 'М': 'M', + 'Н': 'H', + 'О': 'O', + 'П': 'N', + 'Р': 'P', + 'С': 'C', + 'Т': 'T', + 'У': 'y', + 'Ф': 'O', + 'Х': 'X', + 'Ц': 'U', + 'Ч': 'h', + 'Ш': 'W', + 'Щ': 'W', + 'Ъ': 'B', + 'Ы': 'X', + 'Ь': 'B', + 'Э': '3', + 'Ю': 'X', + 'Я': 'R', + 'а': 'a', + 'б': 'b', + 'в': 'a', + 'г': 'r', + 'д': 'y', + 'е': 'e', + 'ж': 'm', + 'з': 'e', + 'и': 'n', + 'й': 'n', + 'к': 'n', + 'л': 'n', + 'м': 'm', + 'н': 'n', + 'о': 'o', + 'п': 'n', + 'р': 'p', + 'с': 'c', + 'т': 'o', + 'у': 'y', + 'ф': 'b', + 'х': 'x', + 'ц': 'n', + 'ч': 'n', + 'ш': 'w', + 'щ': 'w', + 'ъ': 'a', + 'ы': 'm', + 'ь': 'a', + 'э': 'e', + 'ю': 'm', + 'я': 'r', +}; + +/** + * This function adds new font metrics to default metricMap + * It can also override existing metrics + */ +export function setFontMetrics( + fontName: string, + metrics: {[key: string]: CharacterMetricsTuple} +) { + metricMap[fontName] = metrics; +} + +/** + * This function is a convenience function for looking up information in the + * metricMap table. It takes a character as a string, and a font. + * + * Note: the `width` property may be undefined if fontMetricsData.js wasn't + * built using `Make extended_metrics`. + */ +export function getCharacterMetrics( + character: string, + font: string, + mode: Mode, +): CharacterMetrics | null | undefined { + if (!metricMap[font]) { + throw new Error(`Font metrics not found for font: ${font}.`); + } + let ch = character.charCodeAt(0); + let metrics = metricMap[font][ch]; + if (!metrics && character[0] in extraCharacterMap) { + ch = extraCharacterMap[character[0]].charCodeAt(0); + metrics = metricMap[font][ch]; + } + + if (!metrics && mode === 'text') { + // We don't typically have font metrics for Asian scripts. + // But since we support them in text mode, we need to return + // some sort of metrics. + // So if the character is in a script we support but we + // don't have metrics for it, just use the metrics for + // the Latin capital letter M. This is close enough because + // we (currently) only care about the height of the glyph + // not its width. + if (supportedCodepoint(ch)) { + metrics = metricMap[font][77]; // 77 is the charcode for 'M' + } + } + + if (metrics) { + return { + depth: metrics[0], + height: metrics[1], + italic: metrics[2], + skew: metrics[3], + width: metrics[4], + }; + } +} + +type FontSizeIndex = 0 | 1 | 2; +const fontMetricsBySizeIndex: Partial> = {}; + +/** + * Get the font metrics for a given size. + */ +export function getGlobalMetrics(size: number): FontMetrics { + let sizeIndex: FontSizeIndex; + if (size >= 5) { + sizeIndex = 0; + } else if (size >= 3) { + sizeIndex = 1; + } else { + sizeIndex = 2; + } + if (!fontMetricsBySizeIndex[sizeIndex]) { + const metrics: FontMetrics = fontMetricsBySizeIndex[sizeIndex] = { + cssEmPerMu: sigmasAndXis.quad[sizeIndex] / 18, + }; + for (const key in sigmasAndXis) { + if (sigmasAndXis.hasOwnProperty(key)) { + metrics[key] = sigmasAndXis[key][sizeIndex]; + } + } + } + return fontMetricsBySizeIndex[sizeIndex]!; +} diff --git a/node_modules/katex/src/fontMetricsData.d.ts b/node_modules/katex/src/fontMetricsData.d.ts new file mode 100644 index 0000000..aa7dc66 --- /dev/null +++ b/node_modules/katex/src/fontMetricsData.d.ts @@ -0,0 +1,8 @@ +import type {CharacterMetricsTuple, FontName} from "./types/fonts"; + +type FontMetrics = Record; + +declare const fontMetricsData: Record & + Record; + +export default fontMetricsData; diff --git a/node_modules/katex/src/fontMetricsData.js b/node_modules/katex/src/fontMetricsData.js new file mode 100644 index 0000000..2557245 --- /dev/null +++ b/node_modules/katex/src/fontMetricsData.js @@ -0,0 +1,2077 @@ +// This file is GENERATED by buildMetrics.sh. DO NOT MODIFY. +export default { + "AMS-Regular": { + "32": [0, 0, 0, 0, 0.25], + "65": [0, 0.68889, 0, 0, 0.72222], + "66": [0, 0.68889, 0, 0, 0.66667], + "67": [0, 0.68889, 0, 0, 0.72222], + "68": [0, 0.68889, 0, 0, 0.72222], + "69": [0, 0.68889, 0, 0, 0.66667], + "70": [0, 0.68889, 0, 0, 0.61111], + "71": [0, 0.68889, 0, 0, 0.77778], + "72": [0, 0.68889, 0, 0, 0.77778], + "73": [0, 0.68889, 0, 0, 0.38889], + "74": [0.16667, 0.68889, 0, 0, 0.5], + "75": [0, 0.68889, 0, 0, 0.77778], + "76": [0, 0.68889, 0, 0, 0.66667], + "77": [0, 0.68889, 0, 0, 0.94445], + "78": [0, 0.68889, 0, 0, 0.72222], + "79": [0.16667, 0.68889, 0, 0, 0.77778], + "80": [0, 0.68889, 0, 0, 0.61111], + "81": [0.16667, 0.68889, 0, 0, 0.77778], + "82": [0, 0.68889, 0, 0, 0.72222], + "83": [0, 0.68889, 0, 0, 0.55556], + "84": [0, 0.68889, 0, 0, 0.66667], + "85": [0, 0.68889, 0, 0, 0.72222], + "86": [0, 0.68889, 0, 0, 0.72222], + "87": [0, 0.68889, 0, 0, 1.0], + "88": [0, 0.68889, 0, 0, 0.72222], + "89": [0, 0.68889, 0, 0, 0.72222], + "90": [0, 0.68889, 0, 0, 0.66667], + "107": [0, 0.68889, 0, 0, 0.55556], + "160": [0, 0, 0, 0, 0.25], + "165": [0, 0.675, 0.025, 0, 0.75], + "174": [0.15559, 0.69224, 0, 0, 0.94666], + "240": [0, 0.68889, 0, 0, 0.55556], + "295": [0, 0.68889, 0, 0, 0.54028], + "710": [0, 0.825, 0, 0, 2.33334], + "732": [0, 0.9, 0, 0, 2.33334], + "770": [0, 0.825, 0, 0, 2.33334], + "771": [0, 0.9, 0, 0, 2.33334], + "989": [0.08167, 0.58167, 0, 0, 0.77778], + "1008": [0, 0.43056, 0.04028, 0, 0.66667], + "8245": [0, 0.54986, 0, 0, 0.275], + "8463": [0, 0.68889, 0, 0, 0.54028], + "8487": [0, 0.68889, 0, 0, 0.72222], + "8498": [0, 0.68889, 0, 0, 0.55556], + "8502": [0, 0.68889, 0, 0, 0.66667], + "8503": [0, 0.68889, 0, 0, 0.44445], + "8504": [0, 0.68889, 0, 0, 0.66667], + "8513": [0, 0.68889, 0, 0, 0.63889], + "8592": [-0.03598, 0.46402, 0, 0, 0.5], + "8594": [-0.03598, 0.46402, 0, 0, 0.5], + "8602": [-0.13313, 0.36687, 0, 0, 1.0], + "8603": [-0.13313, 0.36687, 0, 0, 1.0], + "8606": [0.01354, 0.52239, 0, 0, 1.0], + "8608": [0.01354, 0.52239, 0, 0, 1.0], + "8610": [0.01354, 0.52239, 0, 0, 1.11111], + "8611": [0.01354, 0.52239, 0, 0, 1.11111], + "8619": [0, 0.54986, 0, 0, 1.0], + "8620": [0, 0.54986, 0, 0, 1.0], + "8621": [-0.13313, 0.37788, 0, 0, 1.38889], + "8622": [-0.13313, 0.36687, 0, 0, 1.0], + "8624": [0, 0.69224, 0, 0, 0.5], + "8625": [0, 0.69224, 0, 0, 0.5], + "8630": [0, 0.43056, 0, 0, 1.0], + "8631": [0, 0.43056, 0, 0, 1.0], + "8634": [0.08198, 0.58198, 0, 0, 0.77778], + "8635": [0.08198, 0.58198, 0, 0, 0.77778], + "8638": [0.19444, 0.69224, 0, 0, 0.41667], + "8639": [0.19444, 0.69224, 0, 0, 0.41667], + "8642": [0.19444, 0.69224, 0, 0, 0.41667], + "8643": [0.19444, 0.69224, 0, 0, 0.41667], + "8644": [0.1808, 0.675, 0, 0, 1.0], + "8646": [0.1808, 0.675, 0, 0, 1.0], + "8647": [0.1808, 0.675, 0, 0, 1.0], + "8648": [0.19444, 0.69224, 0, 0, 0.83334], + "8649": [0.1808, 0.675, 0, 0, 1.0], + "8650": [0.19444, 0.69224, 0, 0, 0.83334], + "8651": [0.01354, 0.52239, 0, 0, 1.0], + "8652": [0.01354, 0.52239, 0, 0, 1.0], + "8653": [-0.13313, 0.36687, 0, 0, 1.0], + "8654": [-0.13313, 0.36687, 0, 0, 1.0], + "8655": [-0.13313, 0.36687, 0, 0, 1.0], + "8666": [0.13667, 0.63667, 0, 0, 1.0], + "8667": [0.13667, 0.63667, 0, 0, 1.0], + "8669": [-0.13313, 0.37788, 0, 0, 1.0], + "8672": [-0.064, 0.437, 0, 0, 1.334], + "8674": [-0.064, 0.437, 0, 0, 1.334], + "8705": [0, 0.825, 0, 0, 0.5], + "8708": [0, 0.68889, 0, 0, 0.55556], + "8709": [0.08167, 0.58167, 0, 0, 0.77778], + "8717": [0, 0.43056, 0, 0, 0.42917], + "8722": [-0.03598, 0.46402, 0, 0, 0.5], + "8724": [0.08198, 0.69224, 0, 0, 0.77778], + "8726": [0.08167, 0.58167, 0, 0, 0.77778], + "8733": [0, 0.69224, 0, 0, 0.77778], + "8736": [0, 0.69224, 0, 0, 0.72222], + "8737": [0, 0.69224, 0, 0, 0.72222], + "8738": [0.03517, 0.52239, 0, 0, 0.72222], + "8739": [0.08167, 0.58167, 0, 0, 0.22222], + "8740": [0.25142, 0.74111, 0, 0, 0.27778], + "8741": [0.08167, 0.58167, 0, 0, 0.38889], + "8742": [0.25142, 0.74111, 0, 0, 0.5], + "8756": [0, 0.69224, 0, 0, 0.66667], + "8757": [0, 0.69224, 0, 0, 0.66667], + "8764": [-0.13313, 0.36687, 0, 0, 0.77778], + "8765": [-0.13313, 0.37788, 0, 0, 0.77778], + "8769": [-0.13313, 0.36687, 0, 0, 0.77778], + "8770": [-0.03625, 0.46375, 0, 0, 0.77778], + "8774": [0.30274, 0.79383, 0, 0, 0.77778], + "8776": [-0.01688, 0.48312, 0, 0, 0.77778], + "8778": [0.08167, 0.58167, 0, 0, 0.77778], + "8782": [0.06062, 0.54986, 0, 0, 0.77778], + "8783": [0.06062, 0.54986, 0, 0, 0.77778], + "8785": [0.08198, 0.58198, 0, 0, 0.77778], + "8786": [0.08198, 0.58198, 0, 0, 0.77778], + "8787": [0.08198, 0.58198, 0, 0, 0.77778], + "8790": [0, 0.69224, 0, 0, 0.77778], + "8791": [0.22958, 0.72958, 0, 0, 0.77778], + "8796": [0.08198, 0.91667, 0, 0, 0.77778], + "8806": [0.25583, 0.75583, 0, 0, 0.77778], + "8807": [0.25583, 0.75583, 0, 0, 0.77778], + "8808": [0.25142, 0.75726, 0, 0, 0.77778], + "8809": [0.25142, 0.75726, 0, 0, 0.77778], + "8812": [0.25583, 0.75583, 0, 0, 0.5], + "8814": [0.20576, 0.70576, 0, 0, 0.77778], + "8815": [0.20576, 0.70576, 0, 0, 0.77778], + "8816": [0.30274, 0.79383, 0, 0, 0.77778], + "8817": [0.30274, 0.79383, 0, 0, 0.77778], + "8818": [0.22958, 0.72958, 0, 0, 0.77778], + "8819": [0.22958, 0.72958, 0, 0, 0.77778], + "8822": [0.1808, 0.675, 0, 0, 0.77778], + "8823": [0.1808, 0.675, 0, 0, 0.77778], + "8828": [0.13667, 0.63667, 0, 0, 0.77778], + "8829": [0.13667, 0.63667, 0, 0, 0.77778], + "8830": [0.22958, 0.72958, 0, 0, 0.77778], + "8831": [0.22958, 0.72958, 0, 0, 0.77778], + "8832": [0.20576, 0.70576, 0, 0, 0.77778], + "8833": [0.20576, 0.70576, 0, 0, 0.77778], + "8840": [0.30274, 0.79383, 0, 0, 0.77778], + "8841": [0.30274, 0.79383, 0, 0, 0.77778], + "8842": [0.13597, 0.63597, 0, 0, 0.77778], + "8843": [0.13597, 0.63597, 0, 0, 0.77778], + "8847": [0.03517, 0.54986, 0, 0, 0.77778], + "8848": [0.03517, 0.54986, 0, 0, 0.77778], + "8858": [0.08198, 0.58198, 0, 0, 0.77778], + "8859": [0.08198, 0.58198, 0, 0, 0.77778], + "8861": [0.08198, 0.58198, 0, 0, 0.77778], + "8862": [0, 0.675, 0, 0, 0.77778], + "8863": [0, 0.675, 0, 0, 0.77778], + "8864": [0, 0.675, 0, 0, 0.77778], + "8865": [0, 0.675, 0, 0, 0.77778], + "8872": [0, 0.69224, 0, 0, 0.61111], + "8873": [0, 0.69224, 0, 0, 0.72222], + "8874": [0, 0.69224, 0, 0, 0.88889], + "8876": [0, 0.68889, 0, 0, 0.61111], + "8877": [0, 0.68889, 0, 0, 0.61111], + "8878": [0, 0.68889, 0, 0, 0.72222], + "8879": [0, 0.68889, 0, 0, 0.72222], + "8882": [0.03517, 0.54986, 0, 0, 0.77778], + "8883": [0.03517, 0.54986, 0, 0, 0.77778], + "8884": [0.13667, 0.63667, 0, 0, 0.77778], + "8885": [0.13667, 0.63667, 0, 0, 0.77778], + "8888": [0, 0.54986, 0, 0, 1.11111], + "8890": [0.19444, 0.43056, 0, 0, 0.55556], + "8891": [0.19444, 0.69224, 0, 0, 0.61111], + "8892": [0.19444, 0.69224, 0, 0, 0.61111], + "8901": [0, 0.54986, 0, 0, 0.27778], + "8903": [0.08167, 0.58167, 0, 0, 0.77778], + "8905": [0.08167, 0.58167, 0, 0, 0.77778], + "8906": [0.08167, 0.58167, 0, 0, 0.77778], + "8907": [0, 0.69224, 0, 0, 0.77778], + "8908": [0, 0.69224, 0, 0, 0.77778], + "8909": [-0.03598, 0.46402, 0, 0, 0.77778], + "8910": [0, 0.54986, 0, 0, 0.76042], + "8911": [0, 0.54986, 0, 0, 0.76042], + "8912": [0.03517, 0.54986, 0, 0, 0.77778], + "8913": [0.03517, 0.54986, 0, 0, 0.77778], + "8914": [0, 0.54986, 0, 0, 0.66667], + "8915": [0, 0.54986, 0, 0, 0.66667], + "8916": [0, 0.69224, 0, 0, 0.66667], + "8918": [0.0391, 0.5391, 0, 0, 0.77778], + "8919": [0.0391, 0.5391, 0, 0, 0.77778], + "8920": [0.03517, 0.54986, 0, 0, 1.33334], + "8921": [0.03517, 0.54986, 0, 0, 1.33334], + "8922": [0.38569, 0.88569, 0, 0, 0.77778], + "8923": [0.38569, 0.88569, 0, 0, 0.77778], + "8926": [0.13667, 0.63667, 0, 0, 0.77778], + "8927": [0.13667, 0.63667, 0, 0, 0.77778], + "8928": [0.30274, 0.79383, 0, 0, 0.77778], + "8929": [0.30274, 0.79383, 0, 0, 0.77778], + "8934": [0.23222, 0.74111, 0, 0, 0.77778], + "8935": [0.23222, 0.74111, 0, 0, 0.77778], + "8936": [0.23222, 0.74111, 0, 0, 0.77778], + "8937": [0.23222, 0.74111, 0, 0, 0.77778], + "8938": [0.20576, 0.70576, 0, 0, 0.77778], + "8939": [0.20576, 0.70576, 0, 0, 0.77778], + "8940": [0.30274, 0.79383, 0, 0, 0.77778], + "8941": [0.30274, 0.79383, 0, 0, 0.77778], + "8994": [0.19444, 0.69224, 0, 0, 0.77778], + "8995": [0.19444, 0.69224, 0, 0, 0.77778], + "9416": [0.15559, 0.69224, 0, 0, 0.90222], + "9484": [0, 0.69224, 0, 0, 0.5], + "9488": [0, 0.69224, 0, 0, 0.5], + "9492": [0, 0.37788, 0, 0, 0.5], + "9496": [0, 0.37788, 0, 0, 0.5], + "9585": [0.19444, 0.68889, 0, 0, 0.88889], + "9586": [0.19444, 0.74111, 0, 0, 0.88889], + "9632": [0, 0.675, 0, 0, 0.77778], + "9633": [0, 0.675, 0, 0, 0.77778], + "9650": [0, 0.54986, 0, 0, 0.72222], + "9651": [0, 0.54986, 0, 0, 0.72222], + "9654": [0.03517, 0.54986, 0, 0, 0.77778], + "9660": [0, 0.54986, 0, 0, 0.72222], + "9661": [0, 0.54986, 0, 0, 0.72222], + "9664": [0.03517, 0.54986, 0, 0, 0.77778], + "9674": [0.11111, 0.69224, 0, 0, 0.66667], + "9733": [0.19444, 0.69224, 0, 0, 0.94445], + "10003": [0, 0.69224, 0, 0, 0.83334], + "10016": [0, 0.69224, 0, 0, 0.83334], + "10731": [0.11111, 0.69224, 0, 0, 0.66667], + "10846": [0.19444, 0.75583, 0, 0, 0.61111], + "10877": [0.13667, 0.63667, 0, 0, 0.77778], + "10878": [0.13667, 0.63667, 0, 0, 0.77778], + "10885": [0.25583, 0.75583, 0, 0, 0.77778], + "10886": [0.25583, 0.75583, 0, 0, 0.77778], + "10887": [0.13597, 0.63597, 0, 0, 0.77778], + "10888": [0.13597, 0.63597, 0, 0, 0.77778], + "10889": [0.26167, 0.75726, 0, 0, 0.77778], + "10890": [0.26167, 0.75726, 0, 0, 0.77778], + "10891": [0.48256, 0.98256, 0, 0, 0.77778], + "10892": [0.48256, 0.98256, 0, 0, 0.77778], + "10901": [0.13667, 0.63667, 0, 0, 0.77778], + "10902": [0.13667, 0.63667, 0, 0, 0.77778], + "10933": [0.25142, 0.75726, 0, 0, 0.77778], + "10934": [0.25142, 0.75726, 0, 0, 0.77778], + "10935": [0.26167, 0.75726, 0, 0, 0.77778], + "10936": [0.26167, 0.75726, 0, 0, 0.77778], + "10937": [0.26167, 0.75726, 0, 0, 0.77778], + "10938": [0.26167, 0.75726, 0, 0, 0.77778], + "10949": [0.25583, 0.75583, 0, 0, 0.77778], + "10950": [0.25583, 0.75583, 0, 0, 0.77778], + "10955": [0.28481, 0.79383, 0, 0, 0.77778], + "10956": [0.28481, 0.79383, 0, 0, 0.77778], + "57350": [0.08167, 0.58167, 0, 0, 0.22222], + "57351": [0.08167, 0.58167, 0, 0, 0.38889], + "57352": [0.08167, 0.58167, 0, 0, 0.77778], + "57353": [0, 0.43056, 0.04028, 0, 0.66667], + "57356": [0.25142, 0.75726, 0, 0, 0.77778], + "57357": [0.25142, 0.75726, 0, 0, 0.77778], + "57358": [0.41951, 0.91951, 0, 0, 0.77778], + "57359": [0.30274, 0.79383, 0, 0, 0.77778], + "57360": [0.30274, 0.79383, 0, 0, 0.77778], + "57361": [0.41951, 0.91951, 0, 0, 0.77778], + "57366": [0.25142, 0.75726, 0, 0, 0.77778], + "57367": [0.25142, 0.75726, 0, 0, 0.77778], + "57368": [0.25142, 0.75726, 0, 0, 0.77778], + "57369": [0.25142, 0.75726, 0, 0, 0.77778], + "57370": [0.13597, 0.63597, 0, 0, 0.77778], + "57371": [0.13597, 0.63597, 0, 0, 0.77778], + }, + "Caligraphic-Regular": { + "32": [0, 0, 0, 0, 0.25], + "65": [0, 0.68333, 0, 0.19445, 0.79847], + "66": [0, 0.68333, 0.03041, 0.13889, 0.65681], + "67": [0, 0.68333, 0.05834, 0.13889, 0.52653], + "68": [0, 0.68333, 0.02778, 0.08334, 0.77139], + "69": [0, 0.68333, 0.08944, 0.11111, 0.52778], + "70": [0, 0.68333, 0.09931, 0.11111, 0.71875], + "71": [0.09722, 0.68333, 0.0593, 0.11111, 0.59487], + "72": [0, 0.68333, 0.00965, 0.11111, 0.84452], + "73": [0, 0.68333, 0.07382, 0, 0.54452], + "74": [0.09722, 0.68333, 0.18472, 0.16667, 0.67778], + "75": [0, 0.68333, 0.01445, 0.05556, 0.76195], + "76": [0, 0.68333, 0, 0.13889, 0.68972], + "77": [0, 0.68333, 0, 0.13889, 1.2009], + "78": [0, 0.68333, 0.14736, 0.08334, 0.82049], + "79": [0, 0.68333, 0.02778, 0.11111, 0.79611], + "80": [0, 0.68333, 0.08222, 0.08334, 0.69556], + "81": [0.09722, 0.68333, 0, 0.11111, 0.81667], + "82": [0, 0.68333, 0, 0.08334, 0.8475], + "83": [0, 0.68333, 0.075, 0.13889, 0.60556], + "84": [0, 0.68333, 0.25417, 0, 0.54464], + "85": [0, 0.68333, 0.09931, 0.08334, 0.62583], + "86": [0, 0.68333, 0.08222, 0, 0.61278], + "87": [0, 0.68333, 0.08222, 0.08334, 0.98778], + "88": [0, 0.68333, 0.14643, 0.13889, 0.7133], + "89": [0.09722, 0.68333, 0.08222, 0.08334, 0.66834], + "90": [0, 0.68333, 0.07944, 0.13889, 0.72473], + "160": [0, 0, 0, 0, 0.25], + }, + "Fraktur-Regular": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69141, 0, 0, 0.29574], + "34": [0, 0.69141, 0, 0, 0.21471], + "38": [0, 0.69141, 0, 0, 0.73786], + "39": [0, 0.69141, 0, 0, 0.21201], + "40": [0.24982, 0.74947, 0, 0, 0.38865], + "41": [0.24982, 0.74947, 0, 0, 0.38865], + "42": [0, 0.62119, 0, 0, 0.27764], + "43": [0.08319, 0.58283, 0, 0, 0.75623], + "44": [0, 0.10803, 0, 0, 0.27764], + "45": [0.08319, 0.58283, 0, 0, 0.75623], + "46": [0, 0.10803, 0, 0, 0.27764], + "47": [0.24982, 0.74947, 0, 0, 0.50181], + "48": [0, 0.47534, 0, 0, 0.50181], + "49": [0, 0.47534, 0, 0, 0.50181], + "50": [0, 0.47534, 0, 0, 0.50181], + "51": [0.18906, 0.47534, 0, 0, 0.50181], + "52": [0.18906, 0.47534, 0, 0, 0.50181], + "53": [0.18906, 0.47534, 0, 0, 0.50181], + "54": [0, 0.69141, 0, 0, 0.50181], + "55": [0.18906, 0.47534, 0, 0, 0.50181], + "56": [0, 0.69141, 0, 0, 0.50181], + "57": [0.18906, 0.47534, 0, 0, 0.50181], + "58": [0, 0.47534, 0, 0, 0.21606], + "59": [0.12604, 0.47534, 0, 0, 0.21606], + "61": [-0.13099, 0.36866, 0, 0, 0.75623], + "63": [0, 0.69141, 0, 0, 0.36245], + "65": [0, 0.69141, 0, 0, 0.7176], + "66": [0, 0.69141, 0, 0, 0.88397], + "67": [0, 0.69141, 0, 0, 0.61254], + "68": [0, 0.69141, 0, 0, 0.83158], + "69": [0, 0.69141, 0, 0, 0.66278], + "70": [0.12604, 0.69141, 0, 0, 0.61119], + "71": [0, 0.69141, 0, 0, 0.78539], + "72": [0.06302, 0.69141, 0, 0, 0.7203], + "73": [0, 0.69141, 0, 0, 0.55448], + "74": [0.12604, 0.69141, 0, 0, 0.55231], + "75": [0, 0.69141, 0, 0, 0.66845], + "76": [0, 0.69141, 0, 0, 0.66602], + "77": [0, 0.69141, 0, 0, 1.04953], + "78": [0, 0.69141, 0, 0, 0.83212], + "79": [0, 0.69141, 0, 0, 0.82699], + "80": [0.18906, 0.69141, 0, 0, 0.82753], + "81": [0.03781, 0.69141, 0, 0, 0.82699], + "82": [0, 0.69141, 0, 0, 0.82807], + "83": [0, 0.69141, 0, 0, 0.82861], + "84": [0, 0.69141, 0, 0, 0.66899], + "85": [0, 0.69141, 0, 0, 0.64576], + "86": [0, 0.69141, 0, 0, 0.83131], + "87": [0, 0.69141, 0, 0, 1.04602], + "88": [0, 0.69141, 0, 0, 0.71922], + "89": [0.18906, 0.69141, 0, 0, 0.83293], + "90": [0.12604, 0.69141, 0, 0, 0.60201], + "91": [0.24982, 0.74947, 0, 0, 0.27764], + "93": [0.24982, 0.74947, 0, 0, 0.27764], + "94": [0, 0.69141, 0, 0, 0.49965], + "97": [0, 0.47534, 0, 0, 0.50046], + "98": [0, 0.69141, 0, 0, 0.51315], + "99": [0, 0.47534, 0, 0, 0.38946], + "100": [0, 0.62119, 0, 0, 0.49857], + "101": [0, 0.47534, 0, 0, 0.40053], + "102": [0.18906, 0.69141, 0, 0, 0.32626], + "103": [0.18906, 0.47534, 0, 0, 0.5037], + "104": [0.18906, 0.69141, 0, 0, 0.52126], + "105": [0, 0.69141, 0, 0, 0.27899], + "106": [0, 0.69141, 0, 0, 0.28088], + "107": [0, 0.69141, 0, 0, 0.38946], + "108": [0, 0.69141, 0, 0, 0.27953], + "109": [0, 0.47534, 0, 0, 0.76676], + "110": [0, 0.47534, 0, 0, 0.52666], + "111": [0, 0.47534, 0, 0, 0.48885], + "112": [0.18906, 0.52396, 0, 0, 0.50046], + "113": [0.18906, 0.47534, 0, 0, 0.48912], + "114": [0, 0.47534, 0, 0, 0.38919], + "115": [0, 0.47534, 0, 0, 0.44266], + "116": [0, 0.62119, 0, 0, 0.33301], + "117": [0, 0.47534, 0, 0, 0.5172], + "118": [0, 0.52396, 0, 0, 0.5118], + "119": [0, 0.52396, 0, 0, 0.77351], + "120": [0.18906, 0.47534, 0, 0, 0.38865], + "121": [0.18906, 0.47534, 0, 0, 0.49884], + "122": [0.18906, 0.47534, 0, 0, 0.39054], + "160": [0, 0, 0, 0, 0.25], + "8216": [0, 0.69141, 0, 0, 0.21471], + "8217": [0, 0.69141, 0, 0, 0.21471], + "58112": [0, 0.62119, 0, 0, 0.49749], + "58113": [0, 0.62119, 0, 0, 0.4983], + "58114": [0.18906, 0.69141, 0, 0, 0.33328], + "58115": [0.18906, 0.69141, 0, 0, 0.32923], + "58116": [0.18906, 0.47534, 0, 0, 0.50343], + "58117": [0, 0.69141, 0, 0, 0.33301], + "58118": [0, 0.62119, 0, 0, 0.33409], + "58119": [0, 0.47534, 0, 0, 0.50073], + }, + "Main-Bold": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0, 0, 0.35], + "34": [0, 0.69444, 0, 0, 0.60278], + "35": [0.19444, 0.69444, 0, 0, 0.95833], + "36": [0.05556, 0.75, 0, 0, 0.575], + "37": [0.05556, 0.75, 0, 0, 0.95833], + "38": [0, 0.69444, 0, 0, 0.89444], + "39": [0, 0.69444, 0, 0, 0.31944], + "40": [0.25, 0.75, 0, 0, 0.44722], + "41": [0.25, 0.75, 0, 0, 0.44722], + "42": [0, 0.75, 0, 0, 0.575], + "43": [0.13333, 0.63333, 0, 0, 0.89444], + "44": [0.19444, 0.15556, 0, 0, 0.31944], + "45": [0, 0.44444, 0, 0, 0.38333], + "46": [0, 0.15556, 0, 0, 0.31944], + "47": [0.25, 0.75, 0, 0, 0.575], + "48": [0, 0.64444, 0, 0, 0.575], + "49": [0, 0.64444, 0, 0, 0.575], + "50": [0, 0.64444, 0, 0, 0.575], + "51": [0, 0.64444, 0, 0, 0.575], + "52": [0, 0.64444, 0, 0, 0.575], + "53": [0, 0.64444, 0, 0, 0.575], + "54": [0, 0.64444, 0, 0, 0.575], + "55": [0, 0.64444, 0, 0, 0.575], + "56": [0, 0.64444, 0, 0, 0.575], + "57": [0, 0.64444, 0, 0, 0.575], + "58": [0, 0.44444, 0, 0, 0.31944], + "59": [0.19444, 0.44444, 0, 0, 0.31944], + "60": [0.08556, 0.58556, 0, 0, 0.89444], + "61": [-0.10889, 0.39111, 0, 0, 0.89444], + "62": [0.08556, 0.58556, 0, 0, 0.89444], + "63": [0, 0.69444, 0, 0, 0.54305], + "64": [0, 0.69444, 0, 0, 0.89444], + "65": [0, 0.68611, 0, 0, 0.86944], + "66": [0, 0.68611, 0, 0, 0.81805], + "67": [0, 0.68611, 0, 0, 0.83055], + "68": [0, 0.68611, 0, 0, 0.88194], + "69": [0, 0.68611, 0, 0, 0.75555], + "70": [0, 0.68611, 0, 0, 0.72361], + "71": [0, 0.68611, 0, 0, 0.90416], + "72": [0, 0.68611, 0, 0, 0.9], + "73": [0, 0.68611, 0, 0, 0.43611], + "74": [0, 0.68611, 0, 0, 0.59444], + "75": [0, 0.68611, 0, 0, 0.90138], + "76": [0, 0.68611, 0, 0, 0.69166], + "77": [0, 0.68611, 0, 0, 1.09166], + "78": [0, 0.68611, 0, 0, 0.9], + "79": [0, 0.68611, 0, 0, 0.86388], + "80": [0, 0.68611, 0, 0, 0.78611], + "81": [0.19444, 0.68611, 0, 0, 0.86388], + "82": [0, 0.68611, 0, 0, 0.8625], + "83": [0, 0.68611, 0, 0, 0.63889], + "84": [0, 0.68611, 0, 0, 0.8], + "85": [0, 0.68611, 0, 0, 0.88472], + "86": [0, 0.68611, 0.01597, 0, 0.86944], + "87": [0, 0.68611, 0.01597, 0, 1.18888], + "88": [0, 0.68611, 0, 0, 0.86944], + "89": [0, 0.68611, 0.02875, 0, 0.86944], + "90": [0, 0.68611, 0, 0, 0.70277], + "91": [0.25, 0.75, 0, 0, 0.31944], + "92": [0.25, 0.75, 0, 0, 0.575], + "93": [0.25, 0.75, 0, 0, 0.31944], + "94": [0, 0.69444, 0, 0, 0.575], + "95": [0.31, 0.13444, 0.03194, 0, 0.575], + "97": [0, 0.44444, 0, 0, 0.55902], + "98": [0, 0.69444, 0, 0, 0.63889], + "99": [0, 0.44444, 0, 0, 0.51111], + "100": [0, 0.69444, 0, 0, 0.63889], + "101": [0, 0.44444, 0, 0, 0.52708], + "102": [0, 0.69444, 0.10903, 0, 0.35139], + "103": [0.19444, 0.44444, 0.01597, 0, 0.575], + "104": [0, 0.69444, 0, 0, 0.63889], + "105": [0, 0.69444, 0, 0, 0.31944], + "106": [0.19444, 0.69444, 0, 0, 0.35139], + "107": [0, 0.69444, 0, 0, 0.60694], + "108": [0, 0.69444, 0, 0, 0.31944], + "109": [0, 0.44444, 0, 0, 0.95833], + "110": [0, 0.44444, 0, 0, 0.63889], + "111": [0, 0.44444, 0, 0, 0.575], + "112": [0.19444, 0.44444, 0, 0, 0.63889], + "113": [0.19444, 0.44444, 0, 0, 0.60694], + "114": [0, 0.44444, 0, 0, 0.47361], + "115": [0, 0.44444, 0, 0, 0.45361], + "116": [0, 0.63492, 0, 0, 0.44722], + "117": [0, 0.44444, 0, 0, 0.63889], + "118": [0, 0.44444, 0.01597, 0, 0.60694], + "119": [0, 0.44444, 0.01597, 0, 0.83055], + "120": [0, 0.44444, 0, 0, 0.60694], + "121": [0.19444, 0.44444, 0.01597, 0, 0.60694], + "122": [0, 0.44444, 0, 0, 0.51111], + "123": [0.25, 0.75, 0, 0, 0.575], + "124": [0.25, 0.75, 0, 0, 0.31944], + "125": [0.25, 0.75, 0, 0, 0.575], + "126": [0.35, 0.34444, 0, 0, 0.575], + "160": [0, 0, 0, 0, 0.25], + "163": [0, 0.69444, 0, 0, 0.86853], + "168": [0, 0.69444, 0, 0, 0.575], + "172": [0, 0.44444, 0, 0, 0.76666], + "176": [0, 0.69444, 0, 0, 0.86944], + "177": [0.13333, 0.63333, 0, 0, 0.89444], + "184": [0.17014, 0, 0, 0, 0.51111], + "198": [0, 0.68611, 0, 0, 1.04166], + "215": [0.13333, 0.63333, 0, 0, 0.89444], + "216": [0.04861, 0.73472, 0, 0, 0.89444], + "223": [0, 0.69444, 0, 0, 0.59722], + "230": [0, 0.44444, 0, 0, 0.83055], + "247": [0.13333, 0.63333, 0, 0, 0.89444], + "248": [0.09722, 0.54167, 0, 0, 0.575], + "305": [0, 0.44444, 0, 0, 0.31944], + "338": [0, 0.68611, 0, 0, 1.16944], + "339": [0, 0.44444, 0, 0, 0.89444], + "567": [0.19444, 0.44444, 0, 0, 0.35139], + "710": [0, 0.69444, 0, 0, 0.575], + "711": [0, 0.63194, 0, 0, 0.575], + "713": [0, 0.59611, 0, 0, 0.575], + "714": [0, 0.69444, 0, 0, 0.575], + "715": [0, 0.69444, 0, 0, 0.575], + "728": [0, 0.69444, 0, 0, 0.575], + "729": [0, 0.69444, 0, 0, 0.31944], + "730": [0, 0.69444, 0, 0, 0.86944], + "732": [0, 0.69444, 0, 0, 0.575], + "733": [0, 0.69444, 0, 0, 0.575], + "915": [0, 0.68611, 0, 0, 0.69166], + "916": [0, 0.68611, 0, 0, 0.95833], + "920": [0, 0.68611, 0, 0, 0.89444], + "923": [0, 0.68611, 0, 0, 0.80555], + "926": [0, 0.68611, 0, 0, 0.76666], + "928": [0, 0.68611, 0, 0, 0.9], + "931": [0, 0.68611, 0, 0, 0.83055], + "933": [0, 0.68611, 0, 0, 0.89444], + "934": [0, 0.68611, 0, 0, 0.83055], + "936": [0, 0.68611, 0, 0, 0.89444], + "937": [0, 0.68611, 0, 0, 0.83055], + "8211": [0, 0.44444, 0.03194, 0, 0.575], + "8212": [0, 0.44444, 0.03194, 0, 1.14999], + "8216": [0, 0.69444, 0, 0, 0.31944], + "8217": [0, 0.69444, 0, 0, 0.31944], + "8220": [0, 0.69444, 0, 0, 0.60278], + "8221": [0, 0.69444, 0, 0, 0.60278], + "8224": [0.19444, 0.69444, 0, 0, 0.51111], + "8225": [0.19444, 0.69444, 0, 0, 0.51111], + "8242": [0, 0.55556, 0, 0, 0.34444], + "8407": [0, 0.72444, 0.15486, 0, 0.575], + "8463": [0, 0.69444, 0, 0, 0.66759], + "8465": [0, 0.69444, 0, 0, 0.83055], + "8467": [0, 0.69444, 0, 0, 0.47361], + "8472": [0.19444, 0.44444, 0, 0, 0.74027], + "8476": [0, 0.69444, 0, 0, 0.83055], + "8501": [0, 0.69444, 0, 0, 0.70277], + "8592": [-0.10889, 0.39111, 0, 0, 1.14999], + "8593": [0.19444, 0.69444, 0, 0, 0.575], + "8594": [-0.10889, 0.39111, 0, 0, 1.14999], + "8595": [0.19444, 0.69444, 0, 0, 0.575], + "8596": [-0.10889, 0.39111, 0, 0, 1.14999], + "8597": [0.25, 0.75, 0, 0, 0.575], + "8598": [0.19444, 0.69444, 0, 0, 1.14999], + "8599": [0.19444, 0.69444, 0, 0, 1.14999], + "8600": [0.19444, 0.69444, 0, 0, 1.14999], + "8601": [0.19444, 0.69444, 0, 0, 1.14999], + "8636": [-0.10889, 0.39111, 0, 0, 1.14999], + "8637": [-0.10889, 0.39111, 0, 0, 1.14999], + "8640": [-0.10889, 0.39111, 0, 0, 1.14999], + "8641": [-0.10889, 0.39111, 0, 0, 1.14999], + "8656": [-0.10889, 0.39111, 0, 0, 1.14999], + "8657": [0.19444, 0.69444, 0, 0, 0.70277], + "8658": [-0.10889, 0.39111, 0, 0, 1.14999], + "8659": [0.19444, 0.69444, 0, 0, 0.70277], + "8660": [-0.10889, 0.39111, 0, 0, 1.14999], + "8661": [0.25, 0.75, 0, 0, 0.70277], + "8704": [0, 0.69444, 0, 0, 0.63889], + "8706": [0, 0.69444, 0.06389, 0, 0.62847], + "8707": [0, 0.69444, 0, 0, 0.63889], + "8709": [0.05556, 0.75, 0, 0, 0.575], + "8711": [0, 0.68611, 0, 0, 0.95833], + "8712": [0.08556, 0.58556, 0, 0, 0.76666], + "8715": [0.08556, 0.58556, 0, 0, 0.76666], + "8722": [0.13333, 0.63333, 0, 0, 0.89444], + "8723": [0.13333, 0.63333, 0, 0, 0.89444], + "8725": [0.25, 0.75, 0, 0, 0.575], + "8726": [0.25, 0.75, 0, 0, 0.575], + "8727": [-0.02778, 0.47222, 0, 0, 0.575], + "8728": [-0.02639, 0.47361, 0, 0, 0.575], + "8729": [-0.02639, 0.47361, 0, 0, 0.575], + "8730": [0.18, 0.82, 0, 0, 0.95833], + "8733": [0, 0.44444, 0, 0, 0.89444], + "8734": [0, 0.44444, 0, 0, 1.14999], + "8736": [0, 0.69224, 0, 0, 0.72222], + "8739": [0.25, 0.75, 0, 0, 0.31944], + "8741": [0.25, 0.75, 0, 0, 0.575], + "8743": [0, 0.55556, 0, 0, 0.76666], + "8744": [0, 0.55556, 0, 0, 0.76666], + "8745": [0, 0.55556, 0, 0, 0.76666], + "8746": [0, 0.55556, 0, 0, 0.76666], + "8747": [0.19444, 0.69444, 0.12778, 0, 0.56875], + "8764": [-0.10889, 0.39111, 0, 0, 0.89444], + "8768": [0.19444, 0.69444, 0, 0, 0.31944], + "8771": [0.00222, 0.50222, 0, 0, 0.89444], + "8773": [0.027, 0.638, 0, 0, 0.894], + "8776": [0.02444, 0.52444, 0, 0, 0.89444], + "8781": [0.00222, 0.50222, 0, 0, 0.89444], + "8801": [0.00222, 0.50222, 0, 0, 0.89444], + "8804": [0.19667, 0.69667, 0, 0, 0.89444], + "8805": [0.19667, 0.69667, 0, 0, 0.89444], + "8810": [0.08556, 0.58556, 0, 0, 1.14999], + "8811": [0.08556, 0.58556, 0, 0, 1.14999], + "8826": [0.08556, 0.58556, 0, 0, 0.89444], + "8827": [0.08556, 0.58556, 0, 0, 0.89444], + "8834": [0.08556, 0.58556, 0, 0, 0.89444], + "8835": [0.08556, 0.58556, 0, 0, 0.89444], + "8838": [0.19667, 0.69667, 0, 0, 0.89444], + "8839": [0.19667, 0.69667, 0, 0, 0.89444], + "8846": [0, 0.55556, 0, 0, 0.76666], + "8849": [0.19667, 0.69667, 0, 0, 0.89444], + "8850": [0.19667, 0.69667, 0, 0, 0.89444], + "8851": [0, 0.55556, 0, 0, 0.76666], + "8852": [0, 0.55556, 0, 0, 0.76666], + "8853": [0.13333, 0.63333, 0, 0, 0.89444], + "8854": [0.13333, 0.63333, 0, 0, 0.89444], + "8855": [0.13333, 0.63333, 0, 0, 0.89444], + "8856": [0.13333, 0.63333, 0, 0, 0.89444], + "8857": [0.13333, 0.63333, 0, 0, 0.89444], + "8866": [0, 0.69444, 0, 0, 0.70277], + "8867": [0, 0.69444, 0, 0, 0.70277], + "8868": [0, 0.69444, 0, 0, 0.89444], + "8869": [0, 0.69444, 0, 0, 0.89444], + "8900": [-0.02639, 0.47361, 0, 0, 0.575], + "8901": [-0.02639, 0.47361, 0, 0, 0.31944], + "8902": [-0.02778, 0.47222, 0, 0, 0.575], + "8968": [0.25, 0.75, 0, 0, 0.51111], + "8969": [0.25, 0.75, 0, 0, 0.51111], + "8970": [0.25, 0.75, 0, 0, 0.51111], + "8971": [0.25, 0.75, 0, 0, 0.51111], + "8994": [-0.13889, 0.36111, 0, 0, 1.14999], + "8995": [-0.13889, 0.36111, 0, 0, 1.14999], + "9651": [0.19444, 0.69444, 0, 0, 1.02222], + "9657": [-0.02778, 0.47222, 0, 0, 0.575], + "9661": [0.19444, 0.69444, 0, 0, 1.02222], + "9667": [-0.02778, 0.47222, 0, 0, 0.575], + "9711": [0.19444, 0.69444, 0, 0, 1.14999], + "9824": [0.12963, 0.69444, 0, 0, 0.89444], + "9825": [0.12963, 0.69444, 0, 0, 0.89444], + "9826": [0.12963, 0.69444, 0, 0, 0.89444], + "9827": [0.12963, 0.69444, 0, 0, 0.89444], + "9837": [0, 0.75, 0, 0, 0.44722], + "9838": [0.19444, 0.69444, 0, 0, 0.44722], + "9839": [0.19444, 0.69444, 0, 0, 0.44722], + "10216": [0.25, 0.75, 0, 0, 0.44722], + "10217": [0.25, 0.75, 0, 0, 0.44722], + "10815": [0, 0.68611, 0, 0, 0.9], + "10927": [0.19667, 0.69667, 0, 0, 0.89444], + "10928": [0.19667, 0.69667, 0, 0, 0.89444], + "57376": [0.19444, 0.69444, 0, 0, 0], + }, + "Main-BoldItalic": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0.11417, 0, 0.38611], + "34": [0, 0.69444, 0.07939, 0, 0.62055], + "35": [0.19444, 0.69444, 0.06833, 0, 0.94444], + "37": [0.05556, 0.75, 0.12861, 0, 0.94444], + "38": [0, 0.69444, 0.08528, 0, 0.88555], + "39": [0, 0.69444, 0.12945, 0, 0.35555], + "40": [0.25, 0.75, 0.15806, 0, 0.47333], + "41": [0.25, 0.75, 0.03306, 0, 0.47333], + "42": [0, 0.75, 0.14333, 0, 0.59111], + "43": [0.10333, 0.60333, 0.03306, 0, 0.88555], + "44": [0.19444, 0.14722, 0, 0, 0.35555], + "45": [0, 0.44444, 0.02611, 0, 0.41444], + "46": [0, 0.14722, 0, 0, 0.35555], + "47": [0.25, 0.75, 0.15806, 0, 0.59111], + "48": [0, 0.64444, 0.13167, 0, 0.59111], + "49": [0, 0.64444, 0.13167, 0, 0.59111], + "50": [0, 0.64444, 0.13167, 0, 0.59111], + "51": [0, 0.64444, 0.13167, 0, 0.59111], + "52": [0.19444, 0.64444, 0.13167, 0, 0.59111], + "53": [0, 0.64444, 0.13167, 0, 0.59111], + "54": [0, 0.64444, 0.13167, 0, 0.59111], + "55": [0.19444, 0.64444, 0.13167, 0, 0.59111], + "56": [0, 0.64444, 0.13167, 0, 0.59111], + "57": [0, 0.64444, 0.13167, 0, 0.59111], + "58": [0, 0.44444, 0.06695, 0, 0.35555], + "59": [0.19444, 0.44444, 0.06695, 0, 0.35555], + "61": [-0.10889, 0.39111, 0.06833, 0, 0.88555], + "63": [0, 0.69444, 0.11472, 0, 0.59111], + "64": [0, 0.69444, 0.09208, 0, 0.88555], + "65": [0, 0.68611, 0, 0, 0.86555], + "66": [0, 0.68611, 0.0992, 0, 0.81666], + "67": [0, 0.68611, 0.14208, 0, 0.82666], + "68": [0, 0.68611, 0.09062, 0, 0.87555], + "69": [0, 0.68611, 0.11431, 0, 0.75666], + "70": [0, 0.68611, 0.12903, 0, 0.72722], + "71": [0, 0.68611, 0.07347, 0, 0.89527], + "72": [0, 0.68611, 0.17208, 0, 0.8961], + "73": [0, 0.68611, 0.15681, 0, 0.47166], + "74": [0, 0.68611, 0.145, 0, 0.61055], + "75": [0, 0.68611, 0.14208, 0, 0.89499], + "76": [0, 0.68611, 0, 0, 0.69777], + "77": [0, 0.68611, 0.17208, 0, 1.07277], + "78": [0, 0.68611, 0.17208, 0, 0.8961], + "79": [0, 0.68611, 0.09062, 0, 0.85499], + "80": [0, 0.68611, 0.0992, 0, 0.78721], + "81": [0.19444, 0.68611, 0.09062, 0, 0.85499], + "82": [0, 0.68611, 0.02559, 0, 0.85944], + "83": [0, 0.68611, 0.11264, 0, 0.64999], + "84": [0, 0.68611, 0.12903, 0, 0.7961], + "85": [0, 0.68611, 0.17208, 0, 0.88083], + "86": [0, 0.68611, 0.18625, 0, 0.86555], + "87": [0, 0.68611, 0.18625, 0, 1.15999], + "88": [0, 0.68611, 0.15681, 0, 0.86555], + "89": [0, 0.68611, 0.19803, 0, 0.86555], + "90": [0, 0.68611, 0.14208, 0, 0.70888], + "91": [0.25, 0.75, 0.1875, 0, 0.35611], + "93": [0.25, 0.75, 0.09972, 0, 0.35611], + "94": [0, 0.69444, 0.06709, 0, 0.59111], + "95": [0.31, 0.13444, 0.09811, 0, 0.59111], + "97": [0, 0.44444, 0.09426, 0, 0.59111], + "98": [0, 0.69444, 0.07861, 0, 0.53222], + "99": [0, 0.44444, 0.05222, 0, 0.53222], + "100": [0, 0.69444, 0.10861, 0, 0.59111], + "101": [0, 0.44444, 0.085, 0, 0.53222], + "102": [0.19444, 0.69444, 0.21778, 0, 0.4], + "103": [0.19444, 0.44444, 0.105, 0, 0.53222], + "104": [0, 0.69444, 0.09426, 0, 0.59111], + "105": [0, 0.69326, 0.11387, 0, 0.35555], + "106": [0.19444, 0.69326, 0.1672, 0, 0.35555], + "107": [0, 0.69444, 0.11111, 0, 0.53222], + "108": [0, 0.69444, 0.10861, 0, 0.29666], + "109": [0, 0.44444, 0.09426, 0, 0.94444], + "110": [0, 0.44444, 0.09426, 0, 0.64999], + "111": [0, 0.44444, 0.07861, 0, 0.59111], + "112": [0.19444, 0.44444, 0.07861, 0, 0.59111], + "113": [0.19444, 0.44444, 0.105, 0, 0.53222], + "114": [0, 0.44444, 0.11111, 0, 0.50167], + "115": [0, 0.44444, 0.08167, 0, 0.48694], + "116": [0, 0.63492, 0.09639, 0, 0.385], + "117": [0, 0.44444, 0.09426, 0, 0.62055], + "118": [0, 0.44444, 0.11111, 0, 0.53222], + "119": [0, 0.44444, 0.11111, 0, 0.76777], + "120": [0, 0.44444, 0.12583, 0, 0.56055], + "121": [0.19444, 0.44444, 0.105, 0, 0.56166], + "122": [0, 0.44444, 0.13889, 0, 0.49055], + "126": [0.35, 0.34444, 0.11472, 0, 0.59111], + "160": [0, 0, 0, 0, 0.25], + "168": [0, 0.69444, 0.11473, 0, 0.59111], + "176": [0, 0.69444, 0, 0, 0.94888], + "184": [0.17014, 0, 0, 0, 0.53222], + "198": [0, 0.68611, 0.11431, 0, 1.02277], + "216": [0.04861, 0.73472, 0.09062, 0, 0.88555], + "223": [0.19444, 0.69444, 0.09736, 0, 0.665], + "230": [0, 0.44444, 0.085, 0, 0.82666], + "248": [0.09722, 0.54167, 0.09458, 0, 0.59111], + "305": [0, 0.44444, 0.09426, 0, 0.35555], + "338": [0, 0.68611, 0.11431, 0, 1.14054], + "339": [0, 0.44444, 0.085, 0, 0.82666], + "567": [0.19444, 0.44444, 0.04611, 0, 0.385], + "710": [0, 0.69444, 0.06709, 0, 0.59111], + "711": [0, 0.63194, 0.08271, 0, 0.59111], + "713": [0, 0.59444, 0.10444, 0, 0.59111], + "714": [0, 0.69444, 0.08528, 0, 0.59111], + "715": [0, 0.69444, 0, 0, 0.59111], + "728": [0, 0.69444, 0.10333, 0, 0.59111], + "729": [0, 0.69444, 0.12945, 0, 0.35555], + "730": [0, 0.69444, 0, 0, 0.94888], + "732": [0, 0.69444, 0.11472, 0, 0.59111], + "733": [0, 0.69444, 0.11472, 0, 0.59111], + "915": [0, 0.68611, 0.12903, 0, 0.69777], + "916": [0, 0.68611, 0, 0, 0.94444], + "920": [0, 0.68611, 0.09062, 0, 0.88555], + "923": [0, 0.68611, 0, 0, 0.80666], + "926": [0, 0.68611, 0.15092, 0, 0.76777], + "928": [0, 0.68611, 0.17208, 0, 0.8961], + "931": [0, 0.68611, 0.11431, 0, 0.82666], + "933": [0, 0.68611, 0.10778, 0, 0.88555], + "934": [0, 0.68611, 0.05632, 0, 0.82666], + "936": [0, 0.68611, 0.10778, 0, 0.88555], + "937": [0, 0.68611, 0.0992, 0, 0.82666], + "8211": [0, 0.44444, 0.09811, 0, 0.59111], + "8212": [0, 0.44444, 0.09811, 0, 1.18221], + "8216": [0, 0.69444, 0.12945, 0, 0.35555], + "8217": [0, 0.69444, 0.12945, 0, 0.35555], + "8220": [0, 0.69444, 0.16772, 0, 0.62055], + "8221": [0, 0.69444, 0.07939, 0, 0.62055], + }, + "Main-Italic": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0.12417, 0, 0.30667], + "34": [0, 0.69444, 0.06961, 0, 0.51444], + "35": [0.19444, 0.69444, 0.06616, 0, 0.81777], + "37": [0.05556, 0.75, 0.13639, 0, 0.81777], + "38": [0, 0.69444, 0.09694, 0, 0.76666], + "39": [0, 0.69444, 0.12417, 0, 0.30667], + "40": [0.25, 0.75, 0.16194, 0, 0.40889], + "41": [0.25, 0.75, 0.03694, 0, 0.40889], + "42": [0, 0.75, 0.14917, 0, 0.51111], + "43": [0.05667, 0.56167, 0.03694, 0, 0.76666], + "44": [0.19444, 0.10556, 0, 0, 0.30667], + "45": [0, 0.43056, 0.02826, 0, 0.35778], + "46": [0, 0.10556, 0, 0, 0.30667], + "47": [0.25, 0.75, 0.16194, 0, 0.51111], + "48": [0, 0.64444, 0.13556, 0, 0.51111], + "49": [0, 0.64444, 0.13556, 0, 0.51111], + "50": [0, 0.64444, 0.13556, 0, 0.51111], + "51": [0, 0.64444, 0.13556, 0, 0.51111], + "52": [0.19444, 0.64444, 0.13556, 0, 0.51111], + "53": [0, 0.64444, 0.13556, 0, 0.51111], + "54": [0, 0.64444, 0.13556, 0, 0.51111], + "55": [0.19444, 0.64444, 0.13556, 0, 0.51111], + "56": [0, 0.64444, 0.13556, 0, 0.51111], + "57": [0, 0.64444, 0.13556, 0, 0.51111], + "58": [0, 0.43056, 0.0582, 0, 0.30667], + "59": [0.19444, 0.43056, 0.0582, 0, 0.30667], + "61": [-0.13313, 0.36687, 0.06616, 0, 0.76666], + "63": [0, 0.69444, 0.1225, 0, 0.51111], + "64": [0, 0.69444, 0.09597, 0, 0.76666], + "65": [0, 0.68333, 0, 0, 0.74333], + "66": [0, 0.68333, 0.10257, 0, 0.70389], + "67": [0, 0.68333, 0.14528, 0, 0.71555], + "68": [0, 0.68333, 0.09403, 0, 0.755], + "69": [0, 0.68333, 0.12028, 0, 0.67833], + "70": [0, 0.68333, 0.13305, 0, 0.65277], + "71": [0, 0.68333, 0.08722, 0, 0.77361], + "72": [0, 0.68333, 0.16389, 0, 0.74333], + "73": [0, 0.68333, 0.15806, 0, 0.38555], + "74": [0, 0.68333, 0.14028, 0, 0.525], + "75": [0, 0.68333, 0.14528, 0, 0.76888], + "76": [0, 0.68333, 0, 0, 0.62722], + "77": [0, 0.68333, 0.16389, 0, 0.89666], + "78": [0, 0.68333, 0.16389, 0, 0.74333], + "79": [0, 0.68333, 0.09403, 0, 0.76666], + "80": [0, 0.68333, 0.10257, 0, 0.67833], + "81": [0.19444, 0.68333, 0.09403, 0, 0.76666], + "82": [0, 0.68333, 0.03868, 0, 0.72944], + "83": [0, 0.68333, 0.11972, 0, 0.56222], + "84": [0, 0.68333, 0.13305, 0, 0.71555], + "85": [0, 0.68333, 0.16389, 0, 0.74333], + "86": [0, 0.68333, 0.18361, 0, 0.74333], + "87": [0, 0.68333, 0.18361, 0, 0.99888], + "88": [0, 0.68333, 0.15806, 0, 0.74333], + "89": [0, 0.68333, 0.19383, 0, 0.74333], + "90": [0, 0.68333, 0.14528, 0, 0.61333], + "91": [0.25, 0.75, 0.1875, 0, 0.30667], + "93": [0.25, 0.75, 0.10528, 0, 0.30667], + "94": [0, 0.69444, 0.06646, 0, 0.51111], + "95": [0.31, 0.12056, 0.09208, 0, 0.51111], + "97": [0, 0.43056, 0.07671, 0, 0.51111], + "98": [0, 0.69444, 0.06312, 0, 0.46], + "99": [0, 0.43056, 0.05653, 0, 0.46], + "100": [0, 0.69444, 0.10333, 0, 0.51111], + "101": [0, 0.43056, 0.07514, 0, 0.46], + "102": [0.19444, 0.69444, 0.21194, 0, 0.30667], + "103": [0.19444, 0.43056, 0.08847, 0, 0.46], + "104": [0, 0.69444, 0.07671, 0, 0.51111], + "105": [0, 0.65536, 0.1019, 0, 0.30667], + "106": [0.19444, 0.65536, 0.14467, 0, 0.30667], + "107": [0, 0.69444, 0.10764, 0, 0.46], + "108": [0, 0.69444, 0.10333, 0, 0.25555], + "109": [0, 0.43056, 0.07671, 0, 0.81777], + "110": [0, 0.43056, 0.07671, 0, 0.56222], + "111": [0, 0.43056, 0.06312, 0, 0.51111], + "112": [0.19444, 0.43056, 0.06312, 0, 0.51111], + "113": [0.19444, 0.43056, 0.08847, 0, 0.46], + "114": [0, 0.43056, 0.10764, 0, 0.42166], + "115": [0, 0.43056, 0.08208, 0, 0.40889], + "116": [0, 0.61508, 0.09486, 0, 0.33222], + "117": [0, 0.43056, 0.07671, 0, 0.53666], + "118": [0, 0.43056, 0.10764, 0, 0.46], + "119": [0, 0.43056, 0.10764, 0, 0.66444], + "120": [0, 0.43056, 0.12042, 0, 0.46389], + "121": [0.19444, 0.43056, 0.08847, 0, 0.48555], + "122": [0, 0.43056, 0.12292, 0, 0.40889], + "126": [0.35, 0.31786, 0.11585, 0, 0.51111], + "160": [0, 0, 0, 0, 0.25], + "168": [0, 0.66786, 0.10474, 0, 0.51111], + "176": [0, 0.69444, 0, 0, 0.83129], + "184": [0.17014, 0, 0, 0, 0.46], + "198": [0, 0.68333, 0.12028, 0, 0.88277], + "216": [0.04861, 0.73194, 0.09403, 0, 0.76666], + "223": [0.19444, 0.69444, 0.10514, 0, 0.53666], + "230": [0, 0.43056, 0.07514, 0, 0.71555], + "248": [0.09722, 0.52778, 0.09194, 0, 0.51111], + "338": [0, 0.68333, 0.12028, 0, 0.98499], + "339": [0, 0.43056, 0.07514, 0, 0.71555], + "710": [0, 0.69444, 0.06646, 0, 0.51111], + "711": [0, 0.62847, 0.08295, 0, 0.51111], + "713": [0, 0.56167, 0.10333, 0, 0.51111], + "714": [0, 0.69444, 0.09694, 0, 0.51111], + "715": [0, 0.69444, 0, 0, 0.51111], + "728": [0, 0.69444, 0.10806, 0, 0.51111], + "729": [0, 0.66786, 0.11752, 0, 0.30667], + "730": [0, 0.69444, 0, 0, 0.83129], + "732": [0, 0.66786, 0.11585, 0, 0.51111], + "733": [0, 0.69444, 0.1225, 0, 0.51111], + "915": [0, 0.68333, 0.13305, 0, 0.62722], + "916": [0, 0.68333, 0, 0, 0.81777], + "920": [0, 0.68333, 0.09403, 0, 0.76666], + "923": [0, 0.68333, 0, 0, 0.69222], + "926": [0, 0.68333, 0.15294, 0, 0.66444], + "928": [0, 0.68333, 0.16389, 0, 0.74333], + "931": [0, 0.68333, 0.12028, 0, 0.71555], + "933": [0, 0.68333, 0.11111, 0, 0.76666], + "934": [0, 0.68333, 0.05986, 0, 0.71555], + "936": [0, 0.68333, 0.11111, 0, 0.76666], + "937": [0, 0.68333, 0.10257, 0, 0.71555], + "8211": [0, 0.43056, 0.09208, 0, 0.51111], + "8212": [0, 0.43056, 0.09208, 0, 1.02222], + "8216": [0, 0.69444, 0.12417, 0, 0.30667], + "8217": [0, 0.69444, 0.12417, 0, 0.30667], + "8220": [0, 0.69444, 0.1685, 0, 0.51444], + "8221": [0, 0.69444, 0.06961, 0, 0.51444], + "8463": [0, 0.68889, 0, 0, 0.54028], + }, + "Main-Regular": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0, 0, 0.27778], + "34": [0, 0.69444, 0, 0, 0.5], + "35": [0.19444, 0.69444, 0, 0, 0.83334], + "36": [0.05556, 0.75, 0, 0, 0.5], + "37": [0.05556, 0.75, 0, 0, 0.83334], + "38": [0, 0.69444, 0, 0, 0.77778], + "39": [0, 0.69444, 0, 0, 0.27778], + "40": [0.25, 0.75, 0, 0, 0.38889], + "41": [0.25, 0.75, 0, 0, 0.38889], + "42": [0, 0.75, 0, 0, 0.5], + "43": [0.08333, 0.58333, 0, 0, 0.77778], + "44": [0.19444, 0.10556, 0, 0, 0.27778], + "45": [0, 0.43056, 0, 0, 0.33333], + "46": [0, 0.10556, 0, 0, 0.27778], + "47": [0.25, 0.75, 0, 0, 0.5], + "48": [0, 0.64444, 0, 0, 0.5], + "49": [0, 0.64444, 0, 0, 0.5], + "50": [0, 0.64444, 0, 0, 0.5], + "51": [0, 0.64444, 0, 0, 0.5], + "52": [0, 0.64444, 0, 0, 0.5], + "53": [0, 0.64444, 0, 0, 0.5], + "54": [0, 0.64444, 0, 0, 0.5], + "55": [0, 0.64444, 0, 0, 0.5], + "56": [0, 0.64444, 0, 0, 0.5], + "57": [0, 0.64444, 0, 0, 0.5], + "58": [0, 0.43056, 0, 0, 0.27778], + "59": [0.19444, 0.43056, 0, 0, 0.27778], + "60": [0.0391, 0.5391, 0, 0, 0.77778], + "61": [-0.13313, 0.36687, 0, 0, 0.77778], + "62": [0.0391, 0.5391, 0, 0, 0.77778], + "63": [0, 0.69444, 0, 0, 0.47222], + "64": [0, 0.69444, 0, 0, 0.77778], + "65": [0, 0.68333, 0, 0, 0.75], + "66": [0, 0.68333, 0, 0, 0.70834], + "67": [0, 0.68333, 0, 0, 0.72222], + "68": [0, 0.68333, 0, 0, 0.76389], + "69": [0, 0.68333, 0, 0, 0.68056], + "70": [0, 0.68333, 0, 0, 0.65278], + "71": [0, 0.68333, 0, 0, 0.78472], + "72": [0, 0.68333, 0, 0, 0.75], + "73": [0, 0.68333, 0, 0, 0.36111], + "74": [0, 0.68333, 0, 0, 0.51389], + "75": [0, 0.68333, 0, 0, 0.77778], + "76": [0, 0.68333, 0, 0, 0.625], + "77": [0, 0.68333, 0, 0, 0.91667], + "78": [0, 0.68333, 0, 0, 0.75], + "79": [0, 0.68333, 0, 0, 0.77778], + "80": [0, 0.68333, 0, 0, 0.68056], + "81": [0.19444, 0.68333, 0, 0, 0.77778], + "82": [0, 0.68333, 0, 0, 0.73611], + "83": [0, 0.68333, 0, 0, 0.55556], + "84": [0, 0.68333, 0, 0, 0.72222], + "85": [0, 0.68333, 0, 0, 0.75], + "86": [0, 0.68333, 0.01389, 0, 0.75], + "87": [0, 0.68333, 0.01389, 0, 1.02778], + "88": [0, 0.68333, 0, 0, 0.75], + "89": [0, 0.68333, 0.025, 0, 0.75], + "90": [0, 0.68333, 0, 0, 0.61111], + "91": [0.25, 0.75, 0, 0, 0.27778], + "92": [0.25, 0.75, 0, 0, 0.5], + "93": [0.25, 0.75, 0, 0, 0.27778], + "94": [0, 0.69444, 0, 0, 0.5], + "95": [0.31, 0.12056, 0.02778, 0, 0.5], + "97": [0, 0.43056, 0, 0, 0.5], + "98": [0, 0.69444, 0, 0, 0.55556], + "99": [0, 0.43056, 0, 0, 0.44445], + "100": [0, 0.69444, 0, 0, 0.55556], + "101": [0, 0.43056, 0, 0, 0.44445], + "102": [0, 0.69444, 0.07778, 0, 0.30556], + "103": [0.19444, 0.43056, 0.01389, 0, 0.5], + "104": [0, 0.69444, 0, 0, 0.55556], + "105": [0, 0.66786, 0, 0, 0.27778], + "106": [0.19444, 0.66786, 0, 0, 0.30556], + "107": [0, 0.69444, 0, 0, 0.52778], + "108": [0, 0.69444, 0, 0, 0.27778], + "109": [0, 0.43056, 0, 0, 0.83334], + "110": [0, 0.43056, 0, 0, 0.55556], + "111": [0, 0.43056, 0, 0, 0.5], + "112": [0.19444, 0.43056, 0, 0, 0.55556], + "113": [0.19444, 0.43056, 0, 0, 0.52778], + "114": [0, 0.43056, 0, 0, 0.39167], + "115": [0, 0.43056, 0, 0, 0.39445], + "116": [0, 0.61508, 0, 0, 0.38889], + "117": [0, 0.43056, 0, 0, 0.55556], + "118": [0, 0.43056, 0.01389, 0, 0.52778], + "119": [0, 0.43056, 0.01389, 0, 0.72222], + "120": [0, 0.43056, 0, 0, 0.52778], + "121": [0.19444, 0.43056, 0.01389, 0, 0.52778], + "122": [0, 0.43056, 0, 0, 0.44445], + "123": [0.25, 0.75, 0, 0, 0.5], + "124": [0.25, 0.75, 0, 0, 0.27778], + "125": [0.25, 0.75, 0, 0, 0.5], + "126": [0.35, 0.31786, 0, 0, 0.5], + "160": [0, 0, 0, 0, 0.25], + "163": [0, 0.69444, 0, 0, 0.76909], + "167": [0.19444, 0.69444, 0, 0, 0.44445], + "168": [0, 0.66786, 0, 0, 0.5], + "172": [0, 0.43056, 0, 0, 0.66667], + "176": [0, 0.69444, 0, 0, 0.75], + "177": [0.08333, 0.58333, 0, 0, 0.77778], + "182": [0.19444, 0.69444, 0, 0, 0.61111], + "184": [0.17014, 0, 0, 0, 0.44445], + "198": [0, 0.68333, 0, 0, 0.90278], + "215": [0.08333, 0.58333, 0, 0, 0.77778], + "216": [0.04861, 0.73194, 0, 0, 0.77778], + "223": [0, 0.69444, 0, 0, 0.5], + "230": [0, 0.43056, 0, 0, 0.72222], + "247": [0.08333, 0.58333, 0, 0, 0.77778], + "248": [0.09722, 0.52778, 0, 0, 0.5], + "305": [0, 0.43056, 0, 0, 0.27778], + "338": [0, 0.68333, 0, 0, 1.01389], + "339": [0, 0.43056, 0, 0, 0.77778], + "567": [0.19444, 0.43056, 0, 0, 0.30556], + "710": [0, 0.69444, 0, 0, 0.5], + "711": [0, 0.62847, 0, 0, 0.5], + "713": [0, 0.56778, 0, 0, 0.5], + "714": [0, 0.69444, 0, 0, 0.5], + "715": [0, 0.69444, 0, 0, 0.5], + "728": [0, 0.69444, 0, 0, 0.5], + "729": [0, 0.66786, 0, 0, 0.27778], + "730": [0, 0.69444, 0, 0, 0.75], + "732": [0, 0.66786, 0, 0, 0.5], + "733": [0, 0.69444, 0, 0, 0.5], + "915": [0, 0.68333, 0, 0, 0.625], + "916": [0, 0.68333, 0, 0, 0.83334], + "920": [0, 0.68333, 0, 0, 0.77778], + "923": [0, 0.68333, 0, 0, 0.69445], + "926": [0, 0.68333, 0, 0, 0.66667], + "928": [0, 0.68333, 0, 0, 0.75], + "931": [0, 0.68333, 0, 0, 0.72222], + "933": [0, 0.68333, 0, 0, 0.77778], + "934": [0, 0.68333, 0, 0, 0.72222], + "936": [0, 0.68333, 0, 0, 0.77778], + "937": [0, 0.68333, 0, 0, 0.72222], + "8211": [0, 0.43056, 0.02778, 0, 0.5], + "8212": [0, 0.43056, 0.02778, 0, 1.0], + "8216": [0, 0.69444, 0, 0, 0.27778], + "8217": [0, 0.69444, 0, 0, 0.27778], + "8220": [0, 0.69444, 0, 0, 0.5], + "8221": [0, 0.69444, 0, 0, 0.5], + "8224": [0.19444, 0.69444, 0, 0, 0.44445], + "8225": [0.19444, 0.69444, 0, 0, 0.44445], + "8230": [0, 0.123, 0, 0, 1.172], + "8242": [0, 0.55556, 0, 0, 0.275], + "8407": [0, 0.71444, 0.15382, 0, 0.5], + "8463": [0, 0.68889, 0, 0, 0.54028], + "8465": [0, 0.69444, 0, 0, 0.72222], + "8467": [0, 0.69444, 0, 0.11111, 0.41667], + "8472": [0.19444, 0.43056, 0, 0.11111, 0.63646], + "8476": [0, 0.69444, 0, 0, 0.72222], + "8501": [0, 0.69444, 0, 0, 0.61111], + "8592": [-0.13313, 0.36687, 0, 0, 1.0], + "8593": [0.19444, 0.69444, 0, 0, 0.5], + "8594": [-0.13313, 0.36687, 0, 0, 1.0], + "8595": [0.19444, 0.69444, 0, 0, 0.5], + "8596": [-0.13313, 0.36687, 0, 0, 1.0], + "8597": [0.25, 0.75, 0, 0, 0.5], + "8598": [0.19444, 0.69444, 0, 0, 1.0], + "8599": [0.19444, 0.69444, 0, 0, 1.0], + "8600": [0.19444, 0.69444, 0, 0, 1.0], + "8601": [0.19444, 0.69444, 0, 0, 1.0], + "8614": [0.011, 0.511, 0, 0, 1.0], + "8617": [0.011, 0.511, 0, 0, 1.126], + "8618": [0.011, 0.511, 0, 0, 1.126], + "8636": [-0.13313, 0.36687, 0, 0, 1.0], + "8637": [-0.13313, 0.36687, 0, 0, 1.0], + "8640": [-0.13313, 0.36687, 0, 0, 1.0], + "8641": [-0.13313, 0.36687, 0, 0, 1.0], + "8652": [0.011, 0.671, 0, 0, 1.0], + "8656": [-0.13313, 0.36687, 0, 0, 1.0], + "8657": [0.19444, 0.69444, 0, 0, 0.61111], + "8658": [-0.13313, 0.36687, 0, 0, 1.0], + "8659": [0.19444, 0.69444, 0, 0, 0.61111], + "8660": [-0.13313, 0.36687, 0, 0, 1.0], + "8661": [0.25, 0.75, 0, 0, 0.61111], + "8704": [0, 0.69444, 0, 0, 0.55556], + "8706": [0, 0.69444, 0.05556, 0.08334, 0.5309], + "8707": [0, 0.69444, 0, 0, 0.55556], + "8709": [0.05556, 0.75, 0, 0, 0.5], + "8711": [0, 0.68333, 0, 0, 0.83334], + "8712": [0.0391, 0.5391, 0, 0, 0.66667], + "8715": [0.0391, 0.5391, 0, 0, 0.66667], + "8722": [0.08333, 0.58333, 0, 0, 0.77778], + "8723": [0.08333, 0.58333, 0, 0, 0.77778], + "8725": [0.25, 0.75, 0, 0, 0.5], + "8726": [0.25, 0.75, 0, 0, 0.5], + "8727": [-0.03472, 0.46528, 0, 0, 0.5], + "8728": [-0.05555, 0.44445, 0, 0, 0.5], + "8729": [-0.05555, 0.44445, 0, 0, 0.5], + "8730": [0.2, 0.8, 0, 0, 0.83334], + "8733": [0, 0.43056, 0, 0, 0.77778], + "8734": [0, 0.43056, 0, 0, 1.0], + "8736": [0, 0.69224, 0, 0, 0.72222], + "8739": [0.25, 0.75, 0, 0, 0.27778], + "8741": [0.25, 0.75, 0, 0, 0.5], + "8743": [0, 0.55556, 0, 0, 0.66667], + "8744": [0, 0.55556, 0, 0, 0.66667], + "8745": [0, 0.55556, 0, 0, 0.66667], + "8746": [0, 0.55556, 0, 0, 0.66667], + "8747": [0.19444, 0.69444, 0.11111, 0, 0.41667], + "8764": [-0.13313, 0.36687, 0, 0, 0.77778], + "8768": [0.19444, 0.69444, 0, 0, 0.27778], + "8771": [-0.03625, 0.46375, 0, 0, 0.77778], + "8773": [-0.022, 0.589, 0, 0, 0.778], + "8776": [-0.01688, 0.48312, 0, 0, 0.77778], + "8781": [-0.03625, 0.46375, 0, 0, 0.77778], + "8784": [-0.133, 0.673, 0, 0, 0.778], + "8801": [-0.03625, 0.46375, 0, 0, 0.77778], + "8804": [0.13597, 0.63597, 0, 0, 0.77778], + "8805": [0.13597, 0.63597, 0, 0, 0.77778], + "8810": [0.0391, 0.5391, 0, 0, 1.0], + "8811": [0.0391, 0.5391, 0, 0, 1.0], + "8826": [0.0391, 0.5391, 0, 0, 0.77778], + "8827": [0.0391, 0.5391, 0, 0, 0.77778], + "8834": [0.0391, 0.5391, 0, 0, 0.77778], + "8835": [0.0391, 0.5391, 0, 0, 0.77778], + "8838": [0.13597, 0.63597, 0, 0, 0.77778], + "8839": [0.13597, 0.63597, 0, 0, 0.77778], + "8846": [0, 0.55556, 0, 0, 0.66667], + "8849": [0.13597, 0.63597, 0, 0, 0.77778], + "8850": [0.13597, 0.63597, 0, 0, 0.77778], + "8851": [0, 0.55556, 0, 0, 0.66667], + "8852": [0, 0.55556, 0, 0, 0.66667], + "8853": [0.08333, 0.58333, 0, 0, 0.77778], + "8854": [0.08333, 0.58333, 0, 0, 0.77778], + "8855": [0.08333, 0.58333, 0, 0, 0.77778], + "8856": [0.08333, 0.58333, 0, 0, 0.77778], + "8857": [0.08333, 0.58333, 0, 0, 0.77778], + "8866": [0, 0.69444, 0, 0, 0.61111], + "8867": [0, 0.69444, 0, 0, 0.61111], + "8868": [0, 0.69444, 0, 0, 0.77778], + "8869": [0, 0.69444, 0, 0, 0.77778], + "8872": [0.249, 0.75, 0, 0, 0.867], + "8900": [-0.05555, 0.44445, 0, 0, 0.5], + "8901": [-0.05555, 0.44445, 0, 0, 0.27778], + "8902": [-0.03472, 0.46528, 0, 0, 0.5], + "8904": [0.005, 0.505, 0, 0, 0.9], + "8942": [0.03, 0.903, 0, 0, 0.278], + "8943": [-0.19, 0.313, 0, 0, 1.172], + "8945": [-0.1, 0.823, 0, 0, 1.282], + "8968": [0.25, 0.75, 0, 0, 0.44445], + "8969": [0.25, 0.75, 0, 0, 0.44445], + "8970": [0.25, 0.75, 0, 0, 0.44445], + "8971": [0.25, 0.75, 0, 0, 0.44445], + "8994": [-0.14236, 0.35764, 0, 0, 1.0], + "8995": [-0.14236, 0.35764, 0, 0, 1.0], + "9136": [0.244, 0.744, 0, 0, 0.412], + "9137": [0.244, 0.745, 0, 0, 0.412], + "9651": [0.19444, 0.69444, 0, 0, 0.88889], + "9657": [-0.03472, 0.46528, 0, 0, 0.5], + "9661": [0.19444, 0.69444, 0, 0, 0.88889], + "9667": [-0.03472, 0.46528, 0, 0, 0.5], + "9711": [0.19444, 0.69444, 0, 0, 1.0], + "9824": [0.12963, 0.69444, 0, 0, 0.77778], + "9825": [0.12963, 0.69444, 0, 0, 0.77778], + "9826": [0.12963, 0.69444, 0, 0, 0.77778], + "9827": [0.12963, 0.69444, 0, 0, 0.77778], + "9837": [0, 0.75, 0, 0, 0.38889], + "9838": [0.19444, 0.69444, 0, 0, 0.38889], + "9839": [0.19444, 0.69444, 0, 0, 0.38889], + "10216": [0.25, 0.75, 0, 0, 0.38889], + "10217": [0.25, 0.75, 0, 0, 0.38889], + "10222": [0.244, 0.744, 0, 0, 0.412], + "10223": [0.244, 0.745, 0, 0, 0.412], + "10229": [0.011, 0.511, 0, 0, 1.609], + "10230": [0.011, 0.511, 0, 0, 1.638], + "10231": [0.011, 0.511, 0, 0, 1.859], + "10232": [0.024, 0.525, 0, 0, 1.609], + "10233": [0.024, 0.525, 0, 0, 1.638], + "10234": [0.024, 0.525, 0, 0, 1.858], + "10236": [0.011, 0.511, 0, 0, 1.638], + "10815": [0, 0.68333, 0, 0, 0.75], + "10927": [0.13597, 0.63597, 0, 0, 0.77778], + "10928": [0.13597, 0.63597, 0, 0, 0.77778], + "57376": [0.19444, 0.69444, 0, 0, 0], + }, + "Math-BoldItalic": { + "32": [0, 0, 0, 0, 0.25], + "48": [0, 0.44444, 0, 0, 0.575], + "49": [0, 0.44444, 0, 0, 0.575], + "50": [0, 0.44444, 0, 0, 0.575], + "51": [0.19444, 0.44444, 0, 0, 0.575], + "52": [0.19444, 0.44444, 0, 0, 0.575], + "53": [0.19444, 0.44444, 0, 0, 0.575], + "54": [0, 0.64444, 0, 0, 0.575], + "55": [0.19444, 0.44444, 0, 0, 0.575], + "56": [0, 0.64444, 0, 0, 0.575], + "57": [0.19444, 0.44444, 0, 0, 0.575], + "65": [0, 0.68611, 0, 0, 0.86944], + "66": [0, 0.68611, 0.04835, 0, 0.8664], + "67": [0, 0.68611, 0.06979, 0, 0.81694], + "68": [0, 0.68611, 0.03194, 0, 0.93812], + "69": [0, 0.68611, 0.05451, 0, 0.81007], + "70": [0, 0.68611, 0.15972, 0, 0.68889], + "71": [0, 0.68611, 0, 0, 0.88673], + "72": [0, 0.68611, 0.08229, 0, 0.98229], + "73": [0, 0.68611, 0.07778, 0, 0.51111], + "74": [0, 0.68611, 0.10069, 0, 0.63125], + "75": [0, 0.68611, 0.06979, 0, 0.97118], + "76": [0, 0.68611, 0, 0, 0.75555], + "77": [0, 0.68611, 0.11424, 0, 1.14201], + "78": [0, 0.68611, 0.11424, 0, 0.95034], + "79": [0, 0.68611, 0.03194, 0, 0.83666], + "80": [0, 0.68611, 0.15972, 0, 0.72309], + "81": [0.19444, 0.68611, 0, 0, 0.86861], + "82": [0, 0.68611, 0.00421, 0, 0.87235], + "83": [0, 0.68611, 0.05382, 0, 0.69271], + "84": [0, 0.68611, 0.15972, 0, 0.63663], + "85": [0, 0.68611, 0.11424, 0, 0.80027], + "86": [0, 0.68611, 0.25555, 0, 0.67778], + "87": [0, 0.68611, 0.15972, 0, 1.09305], + "88": [0, 0.68611, 0.07778, 0, 0.94722], + "89": [0, 0.68611, 0.25555, 0, 0.67458], + "90": [0, 0.68611, 0.06979, 0, 0.77257], + "97": [0, 0.44444, 0, 0, 0.63287], + "98": [0, 0.69444, 0, 0, 0.52083], + "99": [0, 0.44444, 0, 0, 0.51342], + "100": [0, 0.69444, 0, 0, 0.60972], + "101": [0, 0.44444, 0, 0, 0.55361], + "102": [0.19444, 0.69444, 0.11042, 0, 0.56806], + "103": [0.19444, 0.44444, 0.03704, 0, 0.5449], + "104": [0, 0.69444, 0, 0, 0.66759], + "105": [0, 0.69326, 0, 0, 0.4048], + "106": [0.19444, 0.69326, 0.0622, 0, 0.47083], + "107": [0, 0.69444, 0.01852, 0, 0.6037], + "108": [0, 0.69444, 0.0088, 0, 0.34815], + "109": [0, 0.44444, 0, 0, 1.0324], + "110": [0, 0.44444, 0, 0, 0.71296], + "111": [0, 0.44444, 0, 0, 0.58472], + "112": [0.19444, 0.44444, 0, 0, 0.60092], + "113": [0.19444, 0.44444, 0.03704, 0, 0.54213], + "114": [0, 0.44444, 0.03194, 0, 0.5287], + "115": [0, 0.44444, 0, 0, 0.53125], + "116": [0, 0.63492, 0, 0, 0.41528], + "117": [0, 0.44444, 0, 0, 0.68102], + "118": [0, 0.44444, 0.03704, 0, 0.56666], + "119": [0, 0.44444, 0.02778, 0, 0.83148], + "120": [0, 0.44444, 0, 0, 0.65903], + "121": [0.19444, 0.44444, 0.03704, 0, 0.59028], + "122": [0, 0.44444, 0.04213, 0, 0.55509], + "160": [0, 0, 0, 0, 0.25], + "915": [0, 0.68611, 0.15972, 0, 0.65694], + "916": [0, 0.68611, 0, 0, 0.95833], + "920": [0, 0.68611, 0.03194, 0, 0.86722], + "923": [0, 0.68611, 0, 0, 0.80555], + "926": [0, 0.68611, 0.07458, 0, 0.84125], + "928": [0, 0.68611, 0.08229, 0, 0.98229], + "931": [0, 0.68611, 0.05451, 0, 0.88507], + "933": [0, 0.68611, 0.15972, 0, 0.67083], + "934": [0, 0.68611, 0, 0, 0.76666], + "936": [0, 0.68611, 0.11653, 0, 0.71402], + "937": [0, 0.68611, 0.04835, 0, 0.8789], + "945": [0, 0.44444, 0, 0, 0.76064], + "946": [0.19444, 0.69444, 0.03403, 0, 0.65972], + "947": [0.19444, 0.44444, 0.06389, 0, 0.59003], + "948": [0, 0.69444, 0.03819, 0, 0.52222], + "949": [0, 0.44444, 0, 0, 0.52882], + "950": [0.19444, 0.69444, 0.06215, 0, 0.50833], + "951": [0.19444, 0.44444, 0.03704, 0, 0.6], + "952": [0, 0.69444, 0.03194, 0, 0.5618], + "953": [0, 0.44444, 0, 0, 0.41204], + "954": [0, 0.44444, 0, 0, 0.66759], + "955": [0, 0.69444, 0, 0, 0.67083], + "956": [0.19444, 0.44444, 0, 0, 0.70787], + "957": [0, 0.44444, 0.06898, 0, 0.57685], + "958": [0.19444, 0.69444, 0.03021, 0, 0.50833], + "959": [0, 0.44444, 0, 0, 0.58472], + "960": [0, 0.44444, 0.03704, 0, 0.68241], + "961": [0.19444, 0.44444, 0, 0, 0.6118], + "962": [0.09722, 0.44444, 0.07917, 0, 0.42361], + "963": [0, 0.44444, 0.03704, 0, 0.68588], + "964": [0, 0.44444, 0.13472, 0, 0.52083], + "965": [0, 0.44444, 0.03704, 0, 0.63055], + "966": [0.19444, 0.44444, 0, 0, 0.74722], + "967": [0.19444, 0.44444, 0, 0, 0.71805], + "968": [0.19444, 0.69444, 0.03704, 0, 0.75833], + "969": [0, 0.44444, 0.03704, 0, 0.71782], + "977": [0, 0.69444, 0, 0, 0.69155], + "981": [0.19444, 0.69444, 0, 0, 0.7125], + "982": [0, 0.44444, 0.03194, 0, 0.975], + "1009": [0.19444, 0.44444, 0, 0, 0.6118], + "1013": [0, 0.44444, 0, 0, 0.48333], + "57649": [0, 0.44444, 0, 0, 0.39352], + "57911": [0.19444, 0.44444, 0, 0, 0.43889], + }, + "Math-Italic": { + "32": [0, 0, 0, 0, 0.25], + "48": [0, 0.43056, 0, 0, 0.5], + "49": [0, 0.43056, 0, 0, 0.5], + "50": [0, 0.43056, 0, 0, 0.5], + "51": [0.19444, 0.43056, 0, 0, 0.5], + "52": [0.19444, 0.43056, 0, 0, 0.5], + "53": [0.19444, 0.43056, 0, 0, 0.5], + "54": [0, 0.64444, 0, 0, 0.5], + "55": [0.19444, 0.43056, 0, 0, 0.5], + "56": [0, 0.64444, 0, 0, 0.5], + "57": [0.19444, 0.43056, 0, 0, 0.5], + "65": [0, 0.68333, 0, 0.13889, 0.75], + "66": [0, 0.68333, 0.05017, 0.08334, 0.75851], + "67": [0, 0.68333, 0.07153, 0.08334, 0.71472], + "68": [0, 0.68333, 0.02778, 0.05556, 0.82792], + "69": [0, 0.68333, 0.05764, 0.08334, 0.7382], + "70": [0, 0.68333, 0.13889, 0.08334, 0.64306], + "71": [0, 0.68333, 0, 0.08334, 0.78625], + "72": [0, 0.68333, 0.08125, 0.05556, 0.83125], + "73": [0, 0.68333, 0.07847, 0.11111, 0.43958], + "74": [0, 0.68333, 0.09618, 0.16667, 0.55451], + "75": [0, 0.68333, 0.07153, 0.05556, 0.84931], + "76": [0, 0.68333, 0, 0.02778, 0.68056], + "77": [0, 0.68333, 0.10903, 0.08334, 0.97014], + "78": [0, 0.68333, 0.10903, 0.08334, 0.80347], + "79": [0, 0.68333, 0.02778, 0.08334, 0.76278], + "80": [0, 0.68333, 0.13889, 0.08334, 0.64201], + "81": [0.19444, 0.68333, 0, 0.08334, 0.79056], + "82": [0, 0.68333, 0.00773, 0.08334, 0.75929], + "83": [0, 0.68333, 0.05764, 0.08334, 0.6132], + "84": [0, 0.68333, 0.13889, 0.08334, 0.58438], + "85": [0, 0.68333, 0.10903, 0.02778, 0.68278], + "86": [0, 0.68333, 0.22222, 0, 0.58333], + "87": [0, 0.68333, 0.13889, 0, 0.94445], + "88": [0, 0.68333, 0.07847, 0.08334, 0.82847], + "89": [0, 0.68333, 0.22222, 0, 0.58056], + "90": [0, 0.68333, 0.07153, 0.08334, 0.68264], + "97": [0, 0.43056, 0, 0, 0.52859], + "98": [0, 0.69444, 0, 0, 0.42917], + "99": [0, 0.43056, 0, 0.05556, 0.43276], + "100": [0, 0.69444, 0, 0.16667, 0.52049], + "101": [0, 0.43056, 0, 0.05556, 0.46563], + "102": [0.19444, 0.69444, 0.10764, 0.16667, 0.48959], + "103": [0.19444, 0.43056, 0.03588, 0.02778, 0.47697], + "104": [0, 0.69444, 0, 0, 0.57616], + "105": [0, 0.65952, 0, 0, 0.34451], + "106": [0.19444, 0.65952, 0.05724, 0, 0.41181], + "107": [0, 0.69444, 0.03148, 0, 0.5206], + "108": [0, 0.69444, 0.01968, 0.08334, 0.29838], + "109": [0, 0.43056, 0, 0, 0.87801], + "110": [0, 0.43056, 0, 0, 0.60023], + "111": [0, 0.43056, 0, 0.05556, 0.48472], + "112": [0.19444, 0.43056, 0, 0.08334, 0.50313], + "113": [0.19444, 0.43056, 0.03588, 0.08334, 0.44641], + "114": [0, 0.43056, 0.02778, 0.05556, 0.45116], + "115": [0, 0.43056, 0, 0.05556, 0.46875], + "116": [0, 0.61508, 0, 0.08334, 0.36111], + "117": [0, 0.43056, 0, 0.02778, 0.57246], + "118": [0, 0.43056, 0.03588, 0.02778, 0.48472], + "119": [0, 0.43056, 0.02691, 0.08334, 0.71592], + "120": [0, 0.43056, 0, 0.02778, 0.57153], + "121": [0.19444, 0.43056, 0.03588, 0.05556, 0.49028], + "122": [0, 0.43056, 0.04398, 0.05556, 0.46505], + "160": [0, 0, 0, 0, 0.25], + "915": [0, 0.68333, 0.13889, 0.08334, 0.61528], + "916": [0, 0.68333, 0, 0.16667, 0.83334], + "920": [0, 0.68333, 0.02778, 0.08334, 0.76278], + "923": [0, 0.68333, 0, 0.16667, 0.69445], + "926": [0, 0.68333, 0.07569, 0.08334, 0.74236], + "928": [0, 0.68333, 0.08125, 0.05556, 0.83125], + "931": [0, 0.68333, 0.05764, 0.08334, 0.77986], + "933": [0, 0.68333, 0.13889, 0.05556, 0.58333], + "934": [0, 0.68333, 0, 0.08334, 0.66667], + "936": [0, 0.68333, 0.11, 0.05556, 0.61222], + "937": [0, 0.68333, 0.05017, 0.08334, 0.7724], + "945": [0, 0.43056, 0.0037, 0.02778, 0.6397], + "946": [0.19444, 0.69444, 0.05278, 0.08334, 0.56563], + "947": [0.19444, 0.43056, 0.05556, 0, 0.51773], + "948": [0, 0.69444, 0.03785, 0.05556, 0.44444], + "949": [0, 0.43056, 0, 0.08334, 0.46632], + "950": [0.19444, 0.69444, 0.07378, 0.08334, 0.4375], + "951": [0.19444, 0.43056, 0.03588, 0.05556, 0.49653], + "952": [0, 0.69444, 0.02778, 0.08334, 0.46944], + "953": [0, 0.43056, 0, 0.05556, 0.35394], + "954": [0, 0.43056, 0, 0, 0.57616], + "955": [0, 0.69444, 0, 0, 0.58334], + "956": [0.19444, 0.43056, 0, 0.02778, 0.60255], + "957": [0, 0.43056, 0.06366, 0.02778, 0.49398], + "958": [0.19444, 0.69444, 0.04601, 0.11111, 0.4375], + "959": [0, 0.43056, 0, 0.05556, 0.48472], + "960": [0, 0.43056, 0.03588, 0, 0.57003], + "961": [0.19444, 0.43056, 0, 0.08334, 0.51702], + "962": [0.09722, 0.43056, 0.07986, 0.08334, 0.36285], + "963": [0, 0.43056, 0.03588, 0, 0.57141], + "964": [0, 0.43056, 0.1132, 0.02778, 0.43715], + "965": [0, 0.43056, 0.03588, 0.02778, 0.54028], + "966": [0.19444, 0.43056, 0, 0.08334, 0.65417], + "967": [0.19444, 0.43056, 0, 0.05556, 0.62569], + "968": [0.19444, 0.69444, 0.03588, 0.11111, 0.65139], + "969": [0, 0.43056, 0.03588, 0, 0.62245], + "977": [0, 0.69444, 0, 0.08334, 0.59144], + "981": [0.19444, 0.69444, 0, 0.08334, 0.59583], + "982": [0, 0.43056, 0.02778, 0, 0.82813], + "1009": [0.19444, 0.43056, 0, 0.08334, 0.51702], + "1013": [0, 0.43056, 0, 0.05556, 0.4059], + "57649": [0, 0.43056, 0, 0.02778, 0.32246], + "57911": [0.19444, 0.43056, 0, 0.08334, 0.38403], + }, + "SansSerif-Bold": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0, 0, 0.36667], + "34": [0, 0.69444, 0, 0, 0.55834], + "35": [0.19444, 0.69444, 0, 0, 0.91667], + "36": [0.05556, 0.75, 0, 0, 0.55], + "37": [0.05556, 0.75, 0, 0, 1.02912], + "38": [0, 0.69444, 0, 0, 0.83056], + "39": [0, 0.69444, 0, 0, 0.30556], + "40": [0.25, 0.75, 0, 0, 0.42778], + "41": [0.25, 0.75, 0, 0, 0.42778], + "42": [0, 0.75, 0, 0, 0.55], + "43": [0.11667, 0.61667, 0, 0, 0.85556], + "44": [0.10556, 0.13056, 0, 0, 0.30556], + "45": [0, 0.45833, 0, 0, 0.36667], + "46": [0, 0.13056, 0, 0, 0.30556], + "47": [0.25, 0.75, 0, 0, 0.55], + "48": [0, 0.69444, 0, 0, 0.55], + "49": [0, 0.69444, 0, 0, 0.55], + "50": [0, 0.69444, 0, 0, 0.55], + "51": [0, 0.69444, 0, 0, 0.55], + "52": [0, 0.69444, 0, 0, 0.55], + "53": [0, 0.69444, 0, 0, 0.55], + "54": [0, 0.69444, 0, 0, 0.55], + "55": [0, 0.69444, 0, 0, 0.55], + "56": [0, 0.69444, 0, 0, 0.55], + "57": [0, 0.69444, 0, 0, 0.55], + "58": [0, 0.45833, 0, 0, 0.30556], + "59": [0.10556, 0.45833, 0, 0, 0.30556], + "61": [-0.09375, 0.40625, 0, 0, 0.85556], + "63": [0, 0.69444, 0, 0, 0.51945], + "64": [0, 0.69444, 0, 0, 0.73334], + "65": [0, 0.69444, 0, 0, 0.73334], + "66": [0, 0.69444, 0, 0, 0.73334], + "67": [0, 0.69444, 0, 0, 0.70278], + "68": [0, 0.69444, 0, 0, 0.79445], + "69": [0, 0.69444, 0, 0, 0.64167], + "70": [0, 0.69444, 0, 0, 0.61111], + "71": [0, 0.69444, 0, 0, 0.73334], + "72": [0, 0.69444, 0, 0, 0.79445], + "73": [0, 0.69444, 0, 0, 0.33056], + "74": [0, 0.69444, 0, 0, 0.51945], + "75": [0, 0.69444, 0, 0, 0.76389], + "76": [0, 0.69444, 0, 0, 0.58056], + "77": [0, 0.69444, 0, 0, 0.97778], + "78": [0, 0.69444, 0, 0, 0.79445], + "79": [0, 0.69444, 0, 0, 0.79445], + "80": [0, 0.69444, 0, 0, 0.70278], + "81": [0.10556, 0.69444, 0, 0, 0.79445], + "82": [0, 0.69444, 0, 0, 0.70278], + "83": [0, 0.69444, 0, 0, 0.61111], + "84": [0, 0.69444, 0, 0, 0.73334], + "85": [0, 0.69444, 0, 0, 0.76389], + "86": [0, 0.69444, 0.01528, 0, 0.73334], + "87": [0, 0.69444, 0.01528, 0, 1.03889], + "88": [0, 0.69444, 0, 0, 0.73334], + "89": [0, 0.69444, 0.0275, 0, 0.73334], + "90": [0, 0.69444, 0, 0, 0.67223], + "91": [0.25, 0.75, 0, 0, 0.34306], + "93": [0.25, 0.75, 0, 0, 0.34306], + "94": [0, 0.69444, 0, 0, 0.55], + "95": [0.35, 0.10833, 0.03056, 0, 0.55], + "97": [0, 0.45833, 0, 0, 0.525], + "98": [0, 0.69444, 0, 0, 0.56111], + "99": [0, 0.45833, 0, 0, 0.48889], + "100": [0, 0.69444, 0, 0, 0.56111], + "101": [0, 0.45833, 0, 0, 0.51111], + "102": [0, 0.69444, 0.07639, 0, 0.33611], + "103": [0.19444, 0.45833, 0.01528, 0, 0.55], + "104": [0, 0.69444, 0, 0, 0.56111], + "105": [0, 0.69444, 0, 0, 0.25556], + "106": [0.19444, 0.69444, 0, 0, 0.28611], + "107": [0, 0.69444, 0, 0, 0.53056], + "108": [0, 0.69444, 0, 0, 0.25556], + "109": [0, 0.45833, 0, 0, 0.86667], + "110": [0, 0.45833, 0, 0, 0.56111], + "111": [0, 0.45833, 0, 0, 0.55], + "112": [0.19444, 0.45833, 0, 0, 0.56111], + "113": [0.19444, 0.45833, 0, 0, 0.56111], + "114": [0, 0.45833, 0.01528, 0, 0.37222], + "115": [0, 0.45833, 0, 0, 0.42167], + "116": [0, 0.58929, 0, 0, 0.40417], + "117": [0, 0.45833, 0, 0, 0.56111], + "118": [0, 0.45833, 0.01528, 0, 0.5], + "119": [0, 0.45833, 0.01528, 0, 0.74445], + "120": [0, 0.45833, 0, 0, 0.5], + "121": [0.19444, 0.45833, 0.01528, 0, 0.5], + "122": [0, 0.45833, 0, 0, 0.47639], + "126": [0.35, 0.34444, 0, 0, 0.55], + "160": [0, 0, 0, 0, 0.25], + "168": [0, 0.69444, 0, 0, 0.55], + "176": [0, 0.69444, 0, 0, 0.73334], + "180": [0, 0.69444, 0, 0, 0.55], + "184": [0.17014, 0, 0, 0, 0.48889], + "305": [0, 0.45833, 0, 0, 0.25556], + "567": [0.19444, 0.45833, 0, 0, 0.28611], + "710": [0, 0.69444, 0, 0, 0.55], + "711": [0, 0.63542, 0, 0, 0.55], + "713": [0, 0.63778, 0, 0, 0.55], + "728": [0, 0.69444, 0, 0, 0.55], + "729": [0, 0.69444, 0, 0, 0.30556], + "730": [0, 0.69444, 0, 0, 0.73334], + "732": [0, 0.69444, 0, 0, 0.55], + "733": [0, 0.69444, 0, 0, 0.55], + "915": [0, 0.69444, 0, 0, 0.58056], + "916": [0, 0.69444, 0, 0, 0.91667], + "920": [0, 0.69444, 0, 0, 0.85556], + "923": [0, 0.69444, 0, 0, 0.67223], + "926": [0, 0.69444, 0, 0, 0.73334], + "928": [0, 0.69444, 0, 0, 0.79445], + "931": [0, 0.69444, 0, 0, 0.79445], + "933": [0, 0.69444, 0, 0, 0.85556], + "934": [0, 0.69444, 0, 0, 0.79445], + "936": [0, 0.69444, 0, 0, 0.85556], + "937": [0, 0.69444, 0, 0, 0.79445], + "8211": [0, 0.45833, 0.03056, 0, 0.55], + "8212": [0, 0.45833, 0.03056, 0, 1.10001], + "8216": [0, 0.69444, 0, 0, 0.30556], + "8217": [0, 0.69444, 0, 0, 0.30556], + "8220": [0, 0.69444, 0, 0, 0.55834], + "8221": [0, 0.69444, 0, 0, 0.55834], + }, + "SansSerif-Italic": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0.05733, 0, 0.31945], + "34": [0, 0.69444, 0.00316, 0, 0.5], + "35": [0.19444, 0.69444, 0.05087, 0, 0.83334], + "36": [0.05556, 0.75, 0.11156, 0, 0.5], + "37": [0.05556, 0.75, 0.03126, 0, 0.83334], + "38": [0, 0.69444, 0.03058, 0, 0.75834], + "39": [0, 0.69444, 0.07816, 0, 0.27778], + "40": [0.25, 0.75, 0.13164, 0, 0.38889], + "41": [0.25, 0.75, 0.02536, 0, 0.38889], + "42": [0, 0.75, 0.11775, 0, 0.5], + "43": [0.08333, 0.58333, 0.02536, 0, 0.77778], + "44": [0.125, 0.08333, 0, 0, 0.27778], + "45": [0, 0.44444, 0.01946, 0, 0.33333], + "46": [0, 0.08333, 0, 0, 0.27778], + "47": [0.25, 0.75, 0.13164, 0, 0.5], + "48": [0, 0.65556, 0.11156, 0, 0.5], + "49": [0, 0.65556, 0.11156, 0, 0.5], + "50": [0, 0.65556, 0.11156, 0, 0.5], + "51": [0, 0.65556, 0.11156, 0, 0.5], + "52": [0, 0.65556, 0.11156, 0, 0.5], + "53": [0, 0.65556, 0.11156, 0, 0.5], + "54": [0, 0.65556, 0.11156, 0, 0.5], + "55": [0, 0.65556, 0.11156, 0, 0.5], + "56": [0, 0.65556, 0.11156, 0, 0.5], + "57": [0, 0.65556, 0.11156, 0, 0.5], + "58": [0, 0.44444, 0.02502, 0, 0.27778], + "59": [0.125, 0.44444, 0.02502, 0, 0.27778], + "61": [-0.13, 0.37, 0.05087, 0, 0.77778], + "63": [0, 0.69444, 0.11809, 0, 0.47222], + "64": [0, 0.69444, 0.07555, 0, 0.66667], + "65": [0, 0.69444, 0, 0, 0.66667], + "66": [0, 0.69444, 0.08293, 0, 0.66667], + "67": [0, 0.69444, 0.11983, 0, 0.63889], + "68": [0, 0.69444, 0.07555, 0, 0.72223], + "69": [0, 0.69444, 0.11983, 0, 0.59722], + "70": [0, 0.69444, 0.13372, 0, 0.56945], + "71": [0, 0.69444, 0.11983, 0, 0.66667], + "72": [0, 0.69444, 0.08094, 0, 0.70834], + "73": [0, 0.69444, 0.13372, 0, 0.27778], + "74": [0, 0.69444, 0.08094, 0, 0.47222], + "75": [0, 0.69444, 0.11983, 0, 0.69445], + "76": [0, 0.69444, 0, 0, 0.54167], + "77": [0, 0.69444, 0.08094, 0, 0.875], + "78": [0, 0.69444, 0.08094, 0, 0.70834], + "79": [0, 0.69444, 0.07555, 0, 0.73611], + "80": [0, 0.69444, 0.08293, 0, 0.63889], + "81": [0.125, 0.69444, 0.07555, 0, 0.73611], + "82": [0, 0.69444, 0.08293, 0, 0.64584], + "83": [0, 0.69444, 0.09205, 0, 0.55556], + "84": [0, 0.69444, 0.13372, 0, 0.68056], + "85": [0, 0.69444, 0.08094, 0, 0.6875], + "86": [0, 0.69444, 0.1615, 0, 0.66667], + "87": [0, 0.69444, 0.1615, 0, 0.94445], + "88": [0, 0.69444, 0.13372, 0, 0.66667], + "89": [0, 0.69444, 0.17261, 0, 0.66667], + "90": [0, 0.69444, 0.11983, 0, 0.61111], + "91": [0.25, 0.75, 0.15942, 0, 0.28889], + "93": [0.25, 0.75, 0.08719, 0, 0.28889], + "94": [0, 0.69444, 0.0799, 0, 0.5], + "95": [0.35, 0.09444, 0.08616, 0, 0.5], + "97": [0, 0.44444, 0.00981, 0, 0.48056], + "98": [0, 0.69444, 0.03057, 0, 0.51667], + "99": [0, 0.44444, 0.08336, 0, 0.44445], + "100": [0, 0.69444, 0.09483, 0, 0.51667], + "101": [0, 0.44444, 0.06778, 0, 0.44445], + "102": [0, 0.69444, 0.21705, 0, 0.30556], + "103": [0.19444, 0.44444, 0.10836, 0, 0.5], + "104": [0, 0.69444, 0.01778, 0, 0.51667], + "105": [0, 0.67937, 0.09718, 0, 0.23889], + "106": [0.19444, 0.67937, 0.09162, 0, 0.26667], + "107": [0, 0.69444, 0.08336, 0, 0.48889], + "108": [0, 0.69444, 0.09483, 0, 0.23889], + "109": [0, 0.44444, 0.01778, 0, 0.79445], + "110": [0, 0.44444, 0.01778, 0, 0.51667], + "111": [0, 0.44444, 0.06613, 0, 0.5], + "112": [0.19444, 0.44444, 0.0389, 0, 0.51667], + "113": [0.19444, 0.44444, 0.04169, 0, 0.51667], + "114": [0, 0.44444, 0.10836, 0, 0.34167], + "115": [0, 0.44444, 0.0778, 0, 0.38333], + "116": [0, 0.57143, 0.07225, 0, 0.36111], + "117": [0, 0.44444, 0.04169, 0, 0.51667], + "118": [0, 0.44444, 0.10836, 0, 0.46111], + "119": [0, 0.44444, 0.10836, 0, 0.68334], + "120": [0, 0.44444, 0.09169, 0, 0.46111], + "121": [0.19444, 0.44444, 0.10836, 0, 0.46111], + "122": [0, 0.44444, 0.08752, 0, 0.43472], + "126": [0.35, 0.32659, 0.08826, 0, 0.5], + "160": [0, 0, 0, 0, 0.25], + "168": [0, 0.67937, 0.06385, 0, 0.5], + "176": [0, 0.69444, 0, 0, 0.73752], + "184": [0.17014, 0, 0, 0, 0.44445], + "305": [0, 0.44444, 0.04169, 0, 0.23889], + "567": [0.19444, 0.44444, 0.04169, 0, 0.26667], + "710": [0, 0.69444, 0.0799, 0, 0.5], + "711": [0, 0.63194, 0.08432, 0, 0.5], + "713": [0, 0.60889, 0.08776, 0, 0.5], + "714": [0, 0.69444, 0.09205, 0, 0.5], + "715": [0, 0.69444, 0, 0, 0.5], + "728": [0, 0.69444, 0.09483, 0, 0.5], + "729": [0, 0.67937, 0.07774, 0, 0.27778], + "730": [0, 0.69444, 0, 0, 0.73752], + "732": [0, 0.67659, 0.08826, 0, 0.5], + "733": [0, 0.69444, 0.09205, 0, 0.5], + "915": [0, 0.69444, 0.13372, 0, 0.54167], + "916": [0, 0.69444, 0, 0, 0.83334], + "920": [0, 0.69444, 0.07555, 0, 0.77778], + "923": [0, 0.69444, 0, 0, 0.61111], + "926": [0, 0.69444, 0.12816, 0, 0.66667], + "928": [0, 0.69444, 0.08094, 0, 0.70834], + "931": [0, 0.69444, 0.11983, 0, 0.72222], + "933": [0, 0.69444, 0.09031, 0, 0.77778], + "934": [0, 0.69444, 0.04603, 0, 0.72222], + "936": [0, 0.69444, 0.09031, 0, 0.77778], + "937": [0, 0.69444, 0.08293, 0, 0.72222], + "8211": [0, 0.44444, 0.08616, 0, 0.5], + "8212": [0, 0.44444, 0.08616, 0, 1.0], + "8216": [0, 0.69444, 0.07816, 0, 0.27778], + "8217": [0, 0.69444, 0.07816, 0, 0.27778], + "8220": [0, 0.69444, 0.14205, 0, 0.5], + "8221": [0, 0.69444, 0.00316, 0, 0.5], + }, + "SansSerif-Regular": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0, 0, 0.31945], + "34": [0, 0.69444, 0, 0, 0.5], + "35": [0.19444, 0.69444, 0, 0, 0.83334], + "36": [0.05556, 0.75, 0, 0, 0.5], + "37": [0.05556, 0.75, 0, 0, 0.83334], + "38": [0, 0.69444, 0, 0, 0.75834], + "39": [0, 0.69444, 0, 0, 0.27778], + "40": [0.25, 0.75, 0, 0, 0.38889], + "41": [0.25, 0.75, 0, 0, 0.38889], + "42": [0, 0.75, 0, 0, 0.5], + "43": [0.08333, 0.58333, 0, 0, 0.77778], + "44": [0.125, 0.08333, 0, 0, 0.27778], + "45": [0, 0.44444, 0, 0, 0.33333], + "46": [0, 0.08333, 0, 0, 0.27778], + "47": [0.25, 0.75, 0, 0, 0.5], + "48": [0, 0.65556, 0, 0, 0.5], + "49": [0, 0.65556, 0, 0, 0.5], + "50": [0, 0.65556, 0, 0, 0.5], + "51": [0, 0.65556, 0, 0, 0.5], + "52": [0, 0.65556, 0, 0, 0.5], + "53": [0, 0.65556, 0, 0, 0.5], + "54": [0, 0.65556, 0, 0, 0.5], + "55": [0, 0.65556, 0, 0, 0.5], + "56": [0, 0.65556, 0, 0, 0.5], + "57": [0, 0.65556, 0, 0, 0.5], + "58": [0, 0.44444, 0, 0, 0.27778], + "59": [0.125, 0.44444, 0, 0, 0.27778], + "61": [-0.13, 0.37, 0, 0, 0.77778], + "63": [0, 0.69444, 0, 0, 0.47222], + "64": [0, 0.69444, 0, 0, 0.66667], + "65": [0, 0.69444, 0, 0, 0.66667], + "66": [0, 0.69444, 0, 0, 0.66667], + "67": [0, 0.69444, 0, 0, 0.63889], + "68": [0, 0.69444, 0, 0, 0.72223], + "69": [0, 0.69444, 0, 0, 0.59722], + "70": [0, 0.69444, 0, 0, 0.56945], + "71": [0, 0.69444, 0, 0, 0.66667], + "72": [0, 0.69444, 0, 0, 0.70834], + "73": [0, 0.69444, 0, 0, 0.27778], + "74": [0, 0.69444, 0, 0, 0.47222], + "75": [0, 0.69444, 0, 0, 0.69445], + "76": [0, 0.69444, 0, 0, 0.54167], + "77": [0, 0.69444, 0, 0, 0.875], + "78": [0, 0.69444, 0, 0, 0.70834], + "79": [0, 0.69444, 0, 0, 0.73611], + "80": [0, 0.69444, 0, 0, 0.63889], + "81": [0.125, 0.69444, 0, 0, 0.73611], + "82": [0, 0.69444, 0, 0, 0.64584], + "83": [0, 0.69444, 0, 0, 0.55556], + "84": [0, 0.69444, 0, 0, 0.68056], + "85": [0, 0.69444, 0, 0, 0.6875], + "86": [0, 0.69444, 0.01389, 0, 0.66667], + "87": [0, 0.69444, 0.01389, 0, 0.94445], + "88": [0, 0.69444, 0, 0, 0.66667], + "89": [0, 0.69444, 0.025, 0, 0.66667], + "90": [0, 0.69444, 0, 0, 0.61111], + "91": [0.25, 0.75, 0, 0, 0.28889], + "93": [0.25, 0.75, 0, 0, 0.28889], + "94": [0, 0.69444, 0, 0, 0.5], + "95": [0.35, 0.09444, 0.02778, 0, 0.5], + "97": [0, 0.44444, 0, 0, 0.48056], + "98": [0, 0.69444, 0, 0, 0.51667], + "99": [0, 0.44444, 0, 0, 0.44445], + "100": [0, 0.69444, 0, 0, 0.51667], + "101": [0, 0.44444, 0, 0, 0.44445], + "102": [0, 0.69444, 0.06944, 0, 0.30556], + "103": [0.19444, 0.44444, 0.01389, 0, 0.5], + "104": [0, 0.69444, 0, 0, 0.51667], + "105": [0, 0.67937, 0, 0, 0.23889], + "106": [0.19444, 0.67937, 0, 0, 0.26667], + "107": [0, 0.69444, 0, 0, 0.48889], + "108": [0, 0.69444, 0, 0, 0.23889], + "109": [0, 0.44444, 0, 0, 0.79445], + "110": [0, 0.44444, 0, 0, 0.51667], + "111": [0, 0.44444, 0, 0, 0.5], + "112": [0.19444, 0.44444, 0, 0, 0.51667], + "113": [0.19444, 0.44444, 0, 0, 0.51667], + "114": [0, 0.44444, 0.01389, 0, 0.34167], + "115": [0, 0.44444, 0, 0, 0.38333], + "116": [0, 0.57143, 0, 0, 0.36111], + "117": [0, 0.44444, 0, 0, 0.51667], + "118": [0, 0.44444, 0.01389, 0, 0.46111], + "119": [0, 0.44444, 0.01389, 0, 0.68334], + "120": [0, 0.44444, 0, 0, 0.46111], + "121": [0.19444, 0.44444, 0.01389, 0, 0.46111], + "122": [0, 0.44444, 0, 0, 0.43472], + "126": [0.35, 0.32659, 0, 0, 0.5], + "160": [0, 0, 0, 0, 0.25], + "168": [0, 0.67937, 0, 0, 0.5], + "176": [0, 0.69444, 0, 0, 0.66667], + "184": [0.17014, 0, 0, 0, 0.44445], + "305": [0, 0.44444, 0, 0, 0.23889], + "567": [0.19444, 0.44444, 0, 0, 0.26667], + "710": [0, 0.69444, 0, 0, 0.5], + "711": [0, 0.63194, 0, 0, 0.5], + "713": [0, 0.60889, 0, 0, 0.5], + "714": [0, 0.69444, 0, 0, 0.5], + "715": [0, 0.69444, 0, 0, 0.5], + "728": [0, 0.69444, 0, 0, 0.5], + "729": [0, 0.67937, 0, 0, 0.27778], + "730": [0, 0.69444, 0, 0, 0.66667], + "732": [0, 0.67659, 0, 0, 0.5], + "733": [0, 0.69444, 0, 0, 0.5], + "915": [0, 0.69444, 0, 0, 0.54167], + "916": [0, 0.69444, 0, 0, 0.83334], + "920": [0, 0.69444, 0, 0, 0.77778], + "923": [0, 0.69444, 0, 0, 0.61111], + "926": [0, 0.69444, 0, 0, 0.66667], + "928": [0, 0.69444, 0, 0, 0.70834], + "931": [0, 0.69444, 0, 0, 0.72222], + "933": [0, 0.69444, 0, 0, 0.77778], + "934": [0, 0.69444, 0, 0, 0.72222], + "936": [0, 0.69444, 0, 0, 0.77778], + "937": [0, 0.69444, 0, 0, 0.72222], + "8211": [0, 0.44444, 0.02778, 0, 0.5], + "8212": [0, 0.44444, 0.02778, 0, 1.0], + "8216": [0, 0.69444, 0, 0, 0.27778], + "8217": [0, 0.69444, 0, 0, 0.27778], + "8220": [0, 0.69444, 0, 0, 0.5], + "8221": [0, 0.69444, 0, 0, 0.5], + }, + "Script-Regular": { + "32": [0, 0, 0, 0, 0.25], + "65": [0, 0.7, 0.22925, 0, 0.80253], + "66": [0, 0.7, 0.04087, 0, 0.90757], + "67": [0, 0.7, 0.1689, 0, 0.66619], + "68": [0, 0.7, 0.09371, 0, 0.77443], + "69": [0, 0.7, 0.18583, 0, 0.56162], + "70": [0, 0.7, 0.13634, 0, 0.89544], + "71": [0, 0.7, 0.17322, 0, 0.60961], + "72": [0, 0.7, 0.29694, 0, 0.96919], + "73": [0, 0.7, 0.19189, 0, 0.80907], + "74": [0.27778, 0.7, 0.19189, 0, 1.05159], + "75": [0, 0.7, 0.31259, 0, 0.91364], + "76": [0, 0.7, 0.19189, 0, 0.87373], + "77": [0, 0.7, 0.15981, 0, 1.08031], + "78": [0, 0.7, 0.3525, 0, 0.9015], + "79": [0, 0.7, 0.08078, 0, 0.73787], + "80": [0, 0.7, 0.08078, 0, 1.01262], + "81": [0, 0.7, 0.03305, 0, 0.88282], + "82": [0, 0.7, 0.06259, 0, 0.85], + "83": [0, 0.7, 0.19189, 0, 0.86767], + "84": [0, 0.7, 0.29087, 0, 0.74697], + "85": [0, 0.7, 0.25815, 0, 0.79996], + "86": [0, 0.7, 0.27523, 0, 0.62204], + "87": [0, 0.7, 0.27523, 0, 0.80532], + "88": [0, 0.7, 0.26006, 0, 0.94445], + "89": [0, 0.7, 0.2939, 0, 0.70961], + "90": [0, 0.7, 0.24037, 0, 0.8212], + "160": [0, 0, 0, 0, 0.25], + }, + "Size1-Regular": { + "32": [0, 0, 0, 0, 0.25], + "40": [0.35001, 0.85, 0, 0, 0.45834], + "41": [0.35001, 0.85, 0, 0, 0.45834], + "47": [0.35001, 0.85, 0, 0, 0.57778], + "91": [0.35001, 0.85, 0, 0, 0.41667], + "92": [0.35001, 0.85, 0, 0, 0.57778], + "93": [0.35001, 0.85, 0, 0, 0.41667], + "123": [0.35001, 0.85, 0, 0, 0.58334], + "125": [0.35001, 0.85, 0, 0, 0.58334], + "160": [0, 0, 0, 0, 0.25], + "710": [0, 0.72222, 0, 0, 0.55556], + "732": [0, 0.72222, 0, 0, 0.55556], + "770": [0, 0.72222, 0, 0, 0.55556], + "771": [0, 0.72222, 0, 0, 0.55556], + "8214": [-0.00099, 0.601, 0, 0, 0.77778], + "8593": [1e-05, 0.6, 0, 0, 0.66667], + "8595": [1e-05, 0.6, 0, 0, 0.66667], + "8657": [1e-05, 0.6, 0, 0, 0.77778], + "8659": [1e-05, 0.6, 0, 0, 0.77778], + "8719": [0.25001, 0.75, 0, 0, 0.94445], + "8720": [0.25001, 0.75, 0, 0, 0.94445], + "8721": [0.25001, 0.75, 0, 0, 1.05556], + "8730": [0.35001, 0.85, 0, 0, 1.0], + "8739": [-0.00599, 0.606, 0, 0, 0.33333], + "8741": [-0.00599, 0.606, 0, 0, 0.55556], + "8747": [0.30612, 0.805, 0.19445, 0, 0.47222], + "8748": [0.306, 0.805, 0.19445, 0, 0.47222], + "8749": [0.306, 0.805, 0.19445, 0, 0.47222], + "8750": [0.30612, 0.805, 0.19445, 0, 0.47222], + "8896": [0.25001, 0.75, 0, 0, 0.83334], + "8897": [0.25001, 0.75, 0, 0, 0.83334], + "8898": [0.25001, 0.75, 0, 0, 0.83334], + "8899": [0.25001, 0.75, 0, 0, 0.83334], + "8968": [0.35001, 0.85, 0, 0, 0.47222], + "8969": [0.35001, 0.85, 0, 0, 0.47222], + "8970": [0.35001, 0.85, 0, 0, 0.47222], + "8971": [0.35001, 0.85, 0, 0, 0.47222], + "9168": [-0.00099, 0.601, 0, 0, 0.66667], + "10216": [0.35001, 0.85, 0, 0, 0.47222], + "10217": [0.35001, 0.85, 0, 0, 0.47222], + "10752": [0.25001, 0.75, 0, 0, 1.11111], + "10753": [0.25001, 0.75, 0, 0, 1.11111], + "10754": [0.25001, 0.75, 0, 0, 1.11111], + "10756": [0.25001, 0.75, 0, 0, 0.83334], + "10758": [0.25001, 0.75, 0, 0, 0.83334], + }, + "Size2-Regular": { + "32": [0, 0, 0, 0, 0.25], + "40": [0.65002, 1.15, 0, 0, 0.59722], + "41": [0.65002, 1.15, 0, 0, 0.59722], + "47": [0.65002, 1.15, 0, 0, 0.81111], + "91": [0.65002, 1.15, 0, 0, 0.47222], + "92": [0.65002, 1.15, 0, 0, 0.81111], + "93": [0.65002, 1.15, 0, 0, 0.47222], + "123": [0.65002, 1.15, 0, 0, 0.66667], + "125": [0.65002, 1.15, 0, 0, 0.66667], + "160": [0, 0, 0, 0, 0.25], + "710": [0, 0.75, 0, 0, 1.0], + "732": [0, 0.75, 0, 0, 1.0], + "770": [0, 0.75, 0, 0, 1.0], + "771": [0, 0.75, 0, 0, 1.0], + "8719": [0.55001, 1.05, 0, 0, 1.27778], + "8720": [0.55001, 1.05, 0, 0, 1.27778], + "8721": [0.55001, 1.05, 0, 0, 1.44445], + "8730": [0.65002, 1.15, 0, 0, 1.0], + "8747": [0.86225, 1.36, 0.44445, 0, 0.55556], + "8748": [0.862, 1.36, 0.44445, 0, 0.55556], + "8749": [0.862, 1.36, 0.44445, 0, 0.55556], + "8750": [0.86225, 1.36, 0.44445, 0, 0.55556], + "8896": [0.55001, 1.05, 0, 0, 1.11111], + "8897": [0.55001, 1.05, 0, 0, 1.11111], + "8898": [0.55001, 1.05, 0, 0, 1.11111], + "8899": [0.55001, 1.05, 0, 0, 1.11111], + "8968": [0.65002, 1.15, 0, 0, 0.52778], + "8969": [0.65002, 1.15, 0, 0, 0.52778], + "8970": [0.65002, 1.15, 0, 0, 0.52778], + "8971": [0.65002, 1.15, 0, 0, 0.52778], + "10216": [0.65002, 1.15, 0, 0, 0.61111], + "10217": [0.65002, 1.15, 0, 0, 0.61111], + "10752": [0.55001, 1.05, 0, 0, 1.51112], + "10753": [0.55001, 1.05, 0, 0, 1.51112], + "10754": [0.55001, 1.05, 0, 0, 1.51112], + "10756": [0.55001, 1.05, 0, 0, 1.11111], + "10758": [0.55001, 1.05, 0, 0, 1.11111], + }, + "Size3-Regular": { + "32": [0, 0, 0, 0, 0.25], + "40": [0.95003, 1.45, 0, 0, 0.73611], + "41": [0.95003, 1.45, 0, 0, 0.73611], + "47": [0.95003, 1.45, 0, 0, 1.04445], + "91": [0.95003, 1.45, 0, 0, 0.52778], + "92": [0.95003, 1.45, 0, 0, 1.04445], + "93": [0.95003, 1.45, 0, 0, 0.52778], + "123": [0.95003, 1.45, 0, 0, 0.75], + "125": [0.95003, 1.45, 0, 0, 0.75], + "160": [0, 0, 0, 0, 0.25], + "710": [0, 0.75, 0, 0, 1.44445], + "732": [0, 0.75, 0, 0, 1.44445], + "770": [0, 0.75, 0, 0, 1.44445], + "771": [0, 0.75, 0, 0, 1.44445], + "8730": [0.95003, 1.45, 0, 0, 1.0], + "8968": [0.95003, 1.45, 0, 0, 0.58334], + "8969": [0.95003, 1.45, 0, 0, 0.58334], + "8970": [0.95003, 1.45, 0, 0, 0.58334], + "8971": [0.95003, 1.45, 0, 0, 0.58334], + "10216": [0.95003, 1.45, 0, 0, 0.75], + "10217": [0.95003, 1.45, 0, 0, 0.75], + }, + "Size4-Regular": { + "32": [0, 0, 0, 0, 0.25], + "40": [1.25003, 1.75, 0, 0, 0.79167], + "41": [1.25003, 1.75, 0, 0, 0.79167], + "47": [1.25003, 1.75, 0, 0, 1.27778], + "91": [1.25003, 1.75, 0, 0, 0.58334], + "92": [1.25003, 1.75, 0, 0, 1.27778], + "93": [1.25003, 1.75, 0, 0, 0.58334], + "123": [1.25003, 1.75, 0, 0, 0.80556], + "125": [1.25003, 1.75, 0, 0, 0.80556], + "160": [0, 0, 0, 0, 0.25], + "710": [0, 0.825, 0, 0, 1.8889], + "732": [0, 0.825, 0, 0, 1.8889], + "770": [0, 0.825, 0, 0, 1.8889], + "771": [0, 0.825, 0, 0, 1.8889], + "8730": [1.25003, 1.75, 0, 0, 1.0], + "8968": [1.25003, 1.75, 0, 0, 0.63889], + "8969": [1.25003, 1.75, 0, 0, 0.63889], + "8970": [1.25003, 1.75, 0, 0, 0.63889], + "8971": [1.25003, 1.75, 0, 0, 0.63889], + "9115": [0.64502, 1.155, 0, 0, 0.875], + "9116": [1e-05, 0.6, 0, 0, 0.875], + "9117": [0.64502, 1.155, 0, 0, 0.875], + "9118": [0.64502, 1.155, 0, 0, 0.875], + "9119": [1e-05, 0.6, 0, 0, 0.875], + "9120": [0.64502, 1.155, 0, 0, 0.875], + "9121": [0.64502, 1.155, 0, 0, 0.66667], + "9122": [-0.00099, 0.601, 0, 0, 0.66667], + "9123": [0.64502, 1.155, 0, 0, 0.66667], + "9124": [0.64502, 1.155, 0, 0, 0.66667], + "9125": [-0.00099, 0.601, 0, 0, 0.66667], + "9126": [0.64502, 1.155, 0, 0, 0.66667], + "9127": [1e-05, 0.9, 0, 0, 0.88889], + "9128": [0.65002, 1.15, 0, 0, 0.88889], + "9129": [0.90001, 0, 0, 0, 0.88889], + "9130": [0, 0.3, 0, 0, 0.88889], + "9131": [1e-05, 0.9, 0, 0, 0.88889], + "9132": [0.65002, 1.15, 0, 0, 0.88889], + "9133": [0.90001, 0, 0, 0, 0.88889], + "9143": [0.88502, 0.915, 0, 0, 1.05556], + "10216": [1.25003, 1.75, 0, 0, 0.80556], + "10217": [1.25003, 1.75, 0, 0, 0.80556], + "57344": [-0.00499, 0.605, 0, 0, 1.05556], + "57345": [-0.00499, 0.605, 0, 0, 1.05556], + "57680": [0, 0.12, 0, 0, 0.45], + "57681": [0, 0.12, 0, 0, 0.45], + "57682": [0, 0.12, 0, 0, 0.45], + "57683": [0, 0.12, 0, 0, 0.45], + }, + "Typewriter-Regular": { + "32": [0, 0, 0, 0, 0.525], + "33": [0, 0.61111, 0, 0, 0.525], + "34": [0, 0.61111, 0, 0, 0.525], + "35": [0, 0.61111, 0, 0, 0.525], + "36": [0.08333, 0.69444, 0, 0, 0.525], + "37": [0.08333, 0.69444, 0, 0, 0.525], + "38": [0, 0.61111, 0, 0, 0.525], + "39": [0, 0.61111, 0, 0, 0.525], + "40": [0.08333, 0.69444, 0, 0, 0.525], + "41": [0.08333, 0.69444, 0, 0, 0.525], + "42": [0, 0.52083, 0, 0, 0.525], + "43": [-0.08056, 0.53055, 0, 0, 0.525], + "44": [0.13889, 0.125, 0, 0, 0.525], + "45": [-0.08056, 0.53055, 0, 0, 0.525], + "46": [0, 0.125, 0, 0, 0.525], + "47": [0.08333, 0.69444, 0, 0, 0.525], + "48": [0, 0.61111, 0, 0, 0.525], + "49": [0, 0.61111, 0, 0, 0.525], + "50": [0, 0.61111, 0, 0, 0.525], + "51": [0, 0.61111, 0, 0, 0.525], + "52": [0, 0.61111, 0, 0, 0.525], + "53": [0, 0.61111, 0, 0, 0.525], + "54": [0, 0.61111, 0, 0, 0.525], + "55": [0, 0.61111, 0, 0, 0.525], + "56": [0, 0.61111, 0, 0, 0.525], + "57": [0, 0.61111, 0, 0, 0.525], + "58": [0, 0.43056, 0, 0, 0.525], + "59": [0.13889, 0.43056, 0, 0, 0.525], + "60": [-0.05556, 0.55556, 0, 0, 0.525], + "61": [-0.19549, 0.41562, 0, 0, 0.525], + "62": [-0.05556, 0.55556, 0, 0, 0.525], + "63": [0, 0.61111, 0, 0, 0.525], + "64": [0, 0.61111, 0, 0, 0.525], + "65": [0, 0.61111, 0, 0, 0.525], + "66": [0, 0.61111, 0, 0, 0.525], + "67": [0, 0.61111, 0, 0, 0.525], + "68": [0, 0.61111, 0, 0, 0.525], + "69": [0, 0.61111, 0, 0, 0.525], + "70": [0, 0.61111, 0, 0, 0.525], + "71": [0, 0.61111, 0, 0, 0.525], + "72": [0, 0.61111, 0, 0, 0.525], + "73": [0, 0.61111, 0, 0, 0.525], + "74": [0, 0.61111, 0, 0, 0.525], + "75": [0, 0.61111, 0, 0, 0.525], + "76": [0, 0.61111, 0, 0, 0.525], + "77": [0, 0.61111, 0, 0, 0.525], + "78": [0, 0.61111, 0, 0, 0.525], + "79": [0, 0.61111, 0, 0, 0.525], + "80": [0, 0.61111, 0, 0, 0.525], + "81": [0.13889, 0.61111, 0, 0, 0.525], + "82": [0, 0.61111, 0, 0, 0.525], + "83": [0, 0.61111, 0, 0, 0.525], + "84": [0, 0.61111, 0, 0, 0.525], + "85": [0, 0.61111, 0, 0, 0.525], + "86": [0, 0.61111, 0, 0, 0.525], + "87": [0, 0.61111, 0, 0, 0.525], + "88": [0, 0.61111, 0, 0, 0.525], + "89": [0, 0.61111, 0, 0, 0.525], + "90": [0, 0.61111, 0, 0, 0.525], + "91": [0.08333, 0.69444, 0, 0, 0.525], + "92": [0.08333, 0.69444, 0, 0, 0.525], + "93": [0.08333, 0.69444, 0, 0, 0.525], + "94": [0, 0.61111, 0, 0, 0.525], + "95": [0.09514, 0, 0, 0, 0.525], + "96": [0, 0.61111, 0, 0, 0.525], + "97": [0, 0.43056, 0, 0, 0.525], + "98": [0, 0.61111, 0, 0, 0.525], + "99": [0, 0.43056, 0, 0, 0.525], + "100": [0, 0.61111, 0, 0, 0.525], + "101": [0, 0.43056, 0, 0, 0.525], + "102": [0, 0.61111, 0, 0, 0.525], + "103": [0.22222, 0.43056, 0, 0, 0.525], + "104": [0, 0.61111, 0, 0, 0.525], + "105": [0, 0.61111, 0, 0, 0.525], + "106": [0.22222, 0.61111, 0, 0, 0.525], + "107": [0, 0.61111, 0, 0, 0.525], + "108": [0, 0.61111, 0, 0, 0.525], + "109": [0, 0.43056, 0, 0, 0.525], + "110": [0, 0.43056, 0, 0, 0.525], + "111": [0, 0.43056, 0, 0, 0.525], + "112": [0.22222, 0.43056, 0, 0, 0.525], + "113": [0.22222, 0.43056, 0, 0, 0.525], + "114": [0, 0.43056, 0, 0, 0.525], + "115": [0, 0.43056, 0, 0, 0.525], + "116": [0, 0.55358, 0, 0, 0.525], + "117": [0, 0.43056, 0, 0, 0.525], + "118": [0, 0.43056, 0, 0, 0.525], + "119": [0, 0.43056, 0, 0, 0.525], + "120": [0, 0.43056, 0, 0, 0.525], + "121": [0.22222, 0.43056, 0, 0, 0.525], + "122": [0, 0.43056, 0, 0, 0.525], + "123": [0.08333, 0.69444, 0, 0, 0.525], + "124": [0.08333, 0.69444, 0, 0, 0.525], + "125": [0.08333, 0.69444, 0, 0, 0.525], + "126": [0, 0.61111, 0, 0, 0.525], + "127": [0, 0.61111, 0, 0, 0.525], + "160": [0, 0, 0, 0, 0.525], + "176": [0, 0.61111, 0, 0, 0.525], + "184": [0.19445, 0, 0, 0, 0.525], + "305": [0, 0.43056, 0, 0, 0.525], + "567": [0.22222, 0.43056, 0, 0, 0.525], + "711": [0, 0.56597, 0, 0, 0.525], + "713": [0, 0.56555, 0, 0, 0.525], + "714": [0, 0.61111, 0, 0, 0.525], + "715": [0, 0.61111, 0, 0, 0.525], + "728": [0, 0.61111, 0, 0, 0.525], + "730": [0, 0.61111, 0, 0, 0.525], + "770": [0, 0.61111, 0, 0, 0.525], + "771": [0, 0.61111, 0, 0, 0.525], + "776": [0, 0.61111, 0, 0, 0.525], + "915": [0, 0.61111, 0, 0, 0.525], + "916": [0, 0.61111, 0, 0, 0.525], + "920": [0, 0.61111, 0, 0, 0.525], + "923": [0, 0.61111, 0, 0, 0.525], + "926": [0, 0.61111, 0, 0, 0.525], + "928": [0, 0.61111, 0, 0, 0.525], + "931": [0, 0.61111, 0, 0, 0.525], + "933": [0, 0.61111, 0, 0, 0.525], + "934": [0, 0.61111, 0, 0, 0.525], + "936": [0, 0.61111, 0, 0, 0.525], + "937": [0, 0.61111, 0, 0, 0.525], + "8216": [0, 0.61111, 0, 0, 0.525], + "8217": [0, 0.61111, 0, 0, 0.525], + "8242": [0, 0.61111, 0, 0, 0.525], + "9251": [0.11111, 0.21944, 0, 0, 0.525], + }, +}; diff --git a/node_modules/katex/src/fonts/Makefile b/node_modules/katex/src/fonts/Makefile new file mode 100644 index 0000000..83c22db --- /dev/null +++ b/node_modules/katex/src/fonts/Makefile @@ -0,0 +1,139 @@ +#!gmake +# +# Version: Apache License 2.0 +# +# Copyright (c) 2013 MathJax Project +# Copyright (c) 2013 The MathJax Consortium +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +CUSTOM=custom.cfg + +-include $(CUSTOM) + +MFTRACE_MODIFIED=lib/mftrace-modified + +all: config fonts + +$(CUSTOM): + @cp default.cfg $(CUSTOM); + +$(CUSTOM).pl: $(CUSTOM) + @echo "Creating Perl config file..." + @cp $(CUSTOM) $(CUSTOM).pl + @echo >> $(CUSTOM).pl # ensure that the config file ends by a new line + @echo "MFTRACE_PATH=`$(WHICH) $(MFTRACE)`" >> $(CUSTOM).pl + @$(SED) -i "s|^\([A-Z_0-9]*\)=\(.*\)|$$\1='\2';|" $(CUSTOM).pl + @echo "1;" >> $(CUSTOM).pl + +.PHONY: config +config: $(CUSTOM).pl + +blacker: $(MFTRACE_MODIFIED) +$(MFTRACE_MODIFIED): + $(PERL) -I. makeBlacker 15 # values between 10 and 30 seem best + +pfa: $(MFTRACE_MODIFIED) + @echo "cmr10" + $(PYTHON) $(MFTRACE_MODIFIED) --magnification 1000 --simplify cmr10 + + @echo "cmmi10" + $(PYTHON) $(MFTRACE_MODIFIED) --magnification 1000 --encoding $(TETEXENCODING)/aae443f0.enc --simplify cmmi10 + + @echo "cmsy10" + $(PYTHON) $(MFTRACE_MODIFIED) --magnification 1000 --encoding $(TETEXENCODING)/10037936.enc --simplify cmsy10 + + @echo "cmex10" + $(PYTHON) $(MFTRACE_MODIFIED) --magnification 1000 --simplify cmex10 + + @echo "cmbx10" + $(PYTHON) $(MFTRACE_MODIFIED) --magnification 1000 --simplify cmbx10 + + @echo "cmbxti10" + $(PYTHON) $(MFTRACE_MODIFIED) --magnification 1000 --simplify cmbxti10 + + @echo "cmti10" + $(PYTHON) $(MFTRACE_MODIFIED) --magnification 1000 --simplify cmti10 + + @echo "msam10" + $(PYTHON) $(MFTRACE_MODIFIED) --magnification 1000 --simplify --encoding $(TETEXENCODING)/10037936.enc msam10 + + @echo "msbm10" + $(PYTHON) $(MFTRACE_MODIFIED) --magnification 1000 --simplify --encoding $(TETEXENCODING)/10037936.enc msbm10 + + @echo "cmmib10" + $(PYTHON) $(MFTRACE_MODIFIED) --magnification 1000 --encoding $(TETEXENCODING)/aae443f0.enc --simplify cmmib10 + + @echo "cmbsy10" + $(PYTHON) $(MFTRACE_MODIFIED) --magnification 1000 --encoding $(TETEXENCODING)/10037936.enc --simplify cmbsy10 + + @echo "cmtt10" + $(PYTHON) $(MFTRACE_MODIFIED) --magnification 1000 --simplify cmtt10 + + @echo "cmss10" + $(PYTHON) $(MFTRACE_MODIFIED) --magnification 1000 --simplify cmss10 + @echo "cmssi10" + $(PYTHON) $(MFTRACE_MODIFIED) --magnification 1000 --simplify cmssi10 + @echo "cmssbx10" + $(PYTHON) $(MFTRACE_MODIFIED) --magnification 1000 --simplify cmssbx10 + + @echo "eufm10" + cp "`$(KPSEWHICH) eufm10.pfb`" eufm10.pfb + @echo "eufb10" + cp "`$(KPSEWHICH) eufb10.pfb`" eufb10.pfb + + # echo "eusm10" + # $(PYTHON) $(MFTRACE_MODIFIED) --magnification 1000 --simplify eusm10 + # echo "eusb10" + # $(PYTHON) $(MFTRACE_MODIFIED) --magnification 1000 --simplify eusb10 + + @echo "rsfs10" + $(PYTHON) $(MFTRACE_MODIFIED) --magnification 1000 --simplify --encoding $(BASEENCODING)/tex256.enc rsfs10 + + mkdir -p pfa + rm -f pfa/* + mv *.pfa pfa + mv *.pfb pfa + +ff: pfa + mkdir -p ff otf + rm -f ff/* otf/* + $(PERL) -I. makeFF + +.PHONY: fonts +fonts: ff + mkdir -p ttf woff woff2 + rm -f ttf/* woff/* woff2/* + + @for file in `ls ff/*.ff | $(SED) 's|ff/\(.*\)\.ff|\1|'`; do \ + echo ""; \ + echo $$file; \ + $(FONTFORGE) -lang=ff -script ff/$$file.ff; \ + \ + echo "Hinting $$file"; \ + if echo "$$file" | $(GREP) -q -e "Size[1-4]" -e "Typewriter"; then \ + $(TTFAUTOHINT) -f none -S --windows-compatibility --symbol ttf/$$file.ttf ttf/$$file.ttf.hinted; \ + else \ + $(TTFAUTOHINT) -f none -S --windows-compatibility ttf/$$file.ttf ttf/$$file.ttf.hinted; \ + fi; \ + mv ttf/$$file.ttf.hinted ttf/$$file.ttf; \ + \ + echo "Generating $$file..."; \ + $(PYTHON) generate_fonts.py ttf/$$file.ttf; \ + done + +clean: + rm -f $(CUSTOM).pl + rm -f $(MFTRACE_MODIFIED) lib/blacker.mf + rm -rf pfa ff otf ttf woff woff2 diff --git a/node_modules/katex/src/fonts/default.cfg b/node_modules/katex/src/fonts/default.cfg new file mode 100644 index 0000000..2c39c31 --- /dev/null +++ b/node_modules/katex/src/fonts/default.cfg @@ -0,0 +1,20 @@ +# Note: paths should be absolute, unless they point to programs in your $PATH. + +##### Standard programs ##### +GREP=grep +PERL=perl +PYTHON=python3 +SED=sed +WHICH=which +KPSEWHICH=kpsewhich + +##### Font tools ##### +# Most of the tools below are standard and should be available from your package manager. +FONTFORGE=fontforge +MFTRACE=mftrace +TTX=ttx +TTFAUTOHINT=ttfautohint + +##### TeXLive Encoding +TETEXENCODING=/usr/share/texlive/texmf-texlive/fonts/enc/dvips/tetex/ +BASEENCODING=/usr/share/texlive/texmf-texlive/fonts/enc/dvips/base/ diff --git a/node_modules/katex/src/fonts/generate_fonts.py b/node_modules/katex/src/fonts/generate_fonts.py new file mode 100644 index 0000000..d606b82 --- /dev/null +++ b/node_modules/katex/src/fonts/generate_fonts.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python3 + +import sys +import os +import json + +from fontTools.ttLib import TTFont, sfnt +from fontTools.misc.timeTools import timestampNow +sfnt.USE_ZOPFLI = True + +if len(sys.argv) < 2: + print("Usage: %s " % sys.argv[0]) + sys.exit(1) + +font_file = sys.argv[1] +font_name = os.path.splitext(os.path.basename(font_file))[0] + + +font = TTFont(font_file, recalcBBoxes=False, recalcTimestamp=False) + +# fix timestamp to the epoch +font['head'].created = 0 +font['head'].modified = 0 + +# remove fontforge timestamps +if 'FFTM' in font: + del font['FFTM'] + +# remove redundant GDEF table +if 'GDEF' in font: + del font['GDEF'] + +# remove Macintosh table +# https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6cmap.html +font['name'].names = [record for record in font['name'].names if record.platformID != 1] +font['cmap'].tables = [table for table in font['cmap'].tables if table.platformID != 1] + +# fix OS/2 and hhea metrics +glyf = font['glyf'] +ascent = int(max(glyf[c].yMax for c in font.getGlyphOrder() if hasattr(glyf[c], "yMax"))) +descent = -int(min(glyf[c].yMin for c in font.getGlyphOrder() if hasattr(glyf[c], "yMin"))) + +font['OS/2'].usWinAscent = ascent +font['OS/2'].usWinDescent = descent + +font['hhea'].ascent = ascent +font['hhea'].descent = -descent + +# save TTF +font.save(font_file, reorderTables=None) + +# save WOFF +font.flavor = 'woff' +font.save(os.path.join('woff', font_name + '.woff'), reorderTables=None) + +# save WOFF2 +font.flavor = 'woff2' +font.save(os.path.join('woff2', font_name + '.woff2'), reorderTables=None) diff --git a/node_modules/katex/src/fonts/lib/Extra.otf b/node_modules/katex/src/fonts/lib/Extra.otf new file mode 100644 index 0000000..e1c84f8 Binary files /dev/null and b/node_modules/katex/src/fonts/lib/Extra.otf differ diff --git a/node_modules/katex/src/fonts/lib/Space.ttx b/node_modules/katex/src/fonts/lib/Space.ttx new file mode 100644 index 0000000..cfed4af --- /dev/null +++ b/node_modules/katex/src/fonts/lib/Space.ttx @@ -0,0 +1,234 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Copyright (c) 2009-2010 Design Science, Inc. +Copyright (c) 2014-2018 Khan Academy + + + *NAME* + + + *WEIGHT_S* + + + FontForge 2.0 : *NAME*-*WEIGHT* + + + *NAME*-*WEIGHT* + + + Version 1.1 + + + *NAME*-*WEIGHT* + + + Copyright (c) 2009-2010, Design Science, Inc. (<www.mathjax.org>) +Copyright (c) 2014-2018 Khan Academy (<www.khanacademy.org>), +with Reserved Font Name *NAME*. + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license available with a FAQ at: +http://scripts.sil.org/OFL + + + http://scripts.sil.org/OFL + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 50 433 50 hstem + 50 50 50 50 vstem + 50 hmoveto + 150 533 -150 hlineto + 50 -483 rmoveto + 433 50 -433 vlineto + endchar + + + endchar + + + endchar + + + + + + + + + + + + + + + + diff --git a/node_modules/katex/src/fonts/makeBlacker b/node_modules/katex/src/fonts/makeBlacker new file mode 100644 index 0000000..69b0737 --- /dev/null +++ b/node_modules/katex/src/fonts/makeBlacker @@ -0,0 +1,49 @@ +#! /usr/bin/perl + +# Creates the metafont file needed for darker copies of the TeX fonts, +# and modifies mftrace to use it. +# +# Usage: ./makeBlacker blackness + +require "custom.cfg.pl"; + +$blacker = shift; +unless ($blacker) { + print stderr "Usage: ./makeBlacker blackness\n"; + exit; +} + +sub editMftrace { + my $oldMFTRACE = $MFTRACE_PATH; + $MFTRACE = "./lib/mftrace-modified"; + print "Editing mftrace\n"; + open(MFT,$oldMFTRACE) || die "Can't read '$oldMFTRACE': $!\n"; + my $MFT = join("",); + close(MFT); + $MFT =~ s!r"mf '\\mode:=(?:[^;]*)(; [^"]*)"!r"""mf '\\smode:="lib/blacker.mf"$1"""!; + open(MFT,">$MFTRACE") || die "Can't write '$MFTRACE': $!\n"; + print MFT $MFT; + close(MFT); + chmod 0755, $MFTRACE; +} + +sub makeBlackerMF { + my $blacker = shift; + print "Using blacker = $blacker\n"; + open(BLACKER,">lib/blacker.mf") || die "Can't write 'lib/blacker.mf': $!\n"; + print BLACKER << " END"; + proofing:=0; + fontmaking:=1; + tracingtitles:=0; + pixels_per_inch:=1200; + blacker:=$blacker; + fillin:=0; + o_correction:=1; + END + close(BLACKER); +} + +editMftrace(); +makeBlackerMF($blacker); + +1; diff --git a/node_modules/katex/src/fonts/makeFF b/node_modules/katex/src/fonts/makeFF new file mode 100644 index 0000000..606d5fd --- /dev/null +++ b/node_modules/katex/src/fonts/makeFF @@ -0,0 +1,2005 @@ +#! /usr/bin/perl + +# Creates the FontForge files needed to create the +# KaTeX fonts from the TeX source files, constructing some +# glyphs from two or more parts, when needed. +# +# Usage: ./makeFF + +require "custom.cfg.pl"; + +######################################################################### + +$map{cmr10} = { + "Main-Regular" => [ + [0,1] => 0x393, # \Gamma, \Delta + 2 => 0x398, # \Theta + 3 => 0x39B, # \Lambda + 4 => 0x39E, # \Xi + 5 => 0x3A0, # \Pi + 6 => 0x3A3, # \Sigma + [7,8] => 0x3A5, # \Upsilon, \Phi + [9,0xA] => 0x3A8, # \Psi, \Omega + + 0x10 => 0x131, # \i + 0x11 => 0x237, # \j + 0x12 => 0x2CB, # \grave + 0x13 => 0x2CA, # \acute + 0x14 => 0x2C7, # \check + 0x15 => 0x2D8, # \breve + 0x16 => 0x2C9, # \bar + 0x17 => [0xB0,-125,0], # \degree + 0x17 => 0x02DA, # \r, ring above + 0x18 => 0xB8, # \c, cedilla + + [0x21,0x2F] => 0x21, # !, ", #, $, %, &, ', (, ), *, +, comma, -, ., / + 0x22 => 0x201D, # " + 0x27 => 0x2019, # ' + [0x30,0x39] => 0x30, # 0-9 + [0x3A,0x3B] => 0x3A, # :, ; + 0x3D => 0x3D, # = + [0x3F,0x40] => 0x3F, # ?, @ + [0x41,0x5A] => 0x41, # A-Z + 0x5B => 0x5B, # [ + 0x5C => 0x201C, # `` + [0x5D,0x5E] => 0x5D, # ], ^ + 0x5E => 0x2C6, # \hat + 0x5F => 0x2D9, # \dot + 0x60 => 0x2018, # ` + [0x61,0x7A] => 0x61, # a-z + [0x7B,0x7C] => 0x2013, # \endash, \emdash + 0x7B => [0x5F,0,-310], # underline + 0x7D => 0x2DD, # double acute + 0x7E => [0x7E,0,-350], # ~ + 0x7E => 0x2DC, # \tilde + 0x7F => 0xA8, # \ddot + 0x19 => 0xDF, # sharp S + 0x1A => 0xE6, # ae ligature + 0x1B => 0x153, # oe ligature + 0x1C => 0xF8, # o with slash + 0x1D => 0xC6, # AE ligature + 0x1E => 0x152, # OE ligature + 0x1F => 0xD8, # O with slash + ], +}; + +$map{cmmi10} = { + "Math-Italic" => [ + [0,1] => 0x393, # \Gamma, \Delta + 2 => 0x398, # \Theta + 3 => 0x39B, # \Lambda + 4 => 0x39E, # \Xi + 5 => 0x3A0, # \Pi + 6 => 0x3A3, # \Sigma + [7,8] => 0x3A5, # \Upsilon, \Phi + [9,0xA] => 0x3A8, # \Psi, \Omega + + [0xB,0xE] => 0x3B1, # \alpha, \beta, \gamma, \delta + 0xF => 0x3F5, # \elpsilon + [0x10,0x18] => 0x3B6, # \zeta, \eta, \theta, \iota, \kappa, \lambda, \mu, \nu, \xi + [0x19,0x1A] => 0x3C0, # \pi, \rho + [0x1B,0x1D] => 0x3C3, # \sigma, \tau, \upsilon + 0x1E => 0x3D5, # \phi + [0x1F,0x21] => 0x3C7, # \chi, \psi, \omega + 0x22 => 0x3B5, # \varepsilon + 0x23 => 0x3D1, # \vartheta + 0x24 => 0x3D6, # \varpi + 0x25 => 0x3F1, # \varrho + 0x26 => 0x3C2, # \varsigma + 0x27 => 0x3C6, # \varphi + + [0x41,0x5A] => 0x41, # A-Z + [0x61,0x7A] => 0x61, # a - z + [0x30,0x39] => 0x30, # Oldstyle 0-9 + + 0x6F => 0x3BF, # omicron + 0x7B => 0xE131, # \imath (These differ from \i and \j, so use PUA character) + 0x7C => 0xE237, # \jmath + ], + + "Main-Regular" => [ + 0x28 => 0x21BC, # \leftharpoonup + 0x29 => 0x21BD, # \leftharpoondown + 0x2A => 0x21C0, # \rightharpoonup + 0x2B => 0x21C1, # \rightharpoondown + + 0x2E => 0x25B9, # \triangleright + 0x2F => 0x25C3, # \triangleleft + + 0x3A => 0x2E, # . + 0x3B => 0x2C, # , + 0x3C => 0x3C, # < + 0x3D => 0x2215, # / + 0x3E => 0x3E, # > + 0x3F => 0x22C6, # \star + 0x40 => 0x2202, # \partial + + [0x5B,0x5D] => 0x266D, # \flat, \natural, \sharp + 0x5E => 0x2323, # \smile + 0x5F => 0x2322, # \frown + 0x60 => 0x2113, # \ell + + 0x7D => 0x2118, # \wp + 0x7E => [0x20D7,-653,0],# \vec + ], +}; + +$map{cmsy10} = { + "Main-Regular" => [ + [0,1] => 0x2212, # - + 1 => 0x22C5, # \cdot + 2 => 0xD7, # \times + 3 => 0x2217, # \ast + 4 => 0xF7, # \div + 5 => 0x22C4, # \diamond + 6 => 0xB1, # \pm + 7 => 0x2213, # \mp + [8,0xC] => 0x2295, # \oplus, \ominus, \otimes, \oslash, \odot + 0xD => 0x25EF, # \bigcirc + [0xE,0xF] => 0x2218, # \circ, \bullet + + 0x10 => 0x224D, # \asymp + 0x11 => 0x2261, # \equiv + [0x12,0x13] => 0x2286, # \subseteq, \supseteq + [0x14,0x15] => 0x2264, # \leq, \geq + [0x16,0x17] => 0x2AAF, # \preceq, \succeq + 0x18 => 0x223C, # \sim + 0x19 => 0x2248, # \approx + [0x1A,0x1B] => 0x2282, # \subset, \supset + [0x1C,0x1D] => 0x226A, # \ll, \gg + [0x1E,0x1F] => 0x227A, # \prec, \succ + + 0x20 => 0x2190, # \leftarrow + 0x21 => 0x2192, # \rightarrow + 0x22 => 0x2191, # \uparrow + 0x23 => 0x2193, # \downarrow + 0x24 => 0x2194, # \leftrightarrow + 0x25 => 0x2197, # \nearrow + 0x26 => 0x2198, # \searrow + 0x27 => 0x2243, # \simeq + + 0x28 => 0x21D0, # \Leftarrow + 0x29 => 0x21D2, # \Rightarrow + 0x2A => 0x21D1, # \Uparrow + 0x2B => 0x21D3, # \Downarrow + 0x2C => 0x21D4, # \Leftrightarrow + 0x2D => 0x2196, # \nwarrow + 0x2E => 0x2199, # \swarrow + 0x2F => 0x221D, # \propto + + 0x30 => 0x2032, # \prime + 0x31 => 0x221E, # \infty + 0x32 => 0x2208, # \in + 0x33 => 0x220B, # \ni + 0x34 => 0x25B3, # \bigtriangleup and \triangle + 0x35 => 0x25BD, # \bigtriangledown + 0x36 => 0xE020, # \not (U+0338 COMBINING LONG SOLIDUS OVERLAY would + # be most natural, but we don't use a negative + # leading space, so use PUA character) + + 0x38 => 0x2200, # \forall + 0x39 => 0x2203, # \exists + 0x3A => 0xAC, # \neg + 0x3B => 0x2205, # \emptyset + 0x3C => 0x211C, # \Re + 0x3D => 0x2111, # \Im + 0x3E => 0x22A4, # \top + 0x3F => 0x22A5, # \bot + + 0x40 => 0x2135, # \aleph + + 0x5B => 0x222A, # \cup + 0x5C => 0x2229, # \cap + 0x5D => 0x228E, # \uplus + [0x5E,0x5F] => 0x2227, # \wedge, \vee + + [0x60,0x61] => 0x22A2, # \vdash, \dashv + [0x62,0x63] => 0x230A, # \lfloor, \rfloor + [0x64,0x65] => 0x2308, # \lceil, \rceil + 0x66 => 0x7B, # { + 0x67 => 0x7D, # } + [0x68,0x69] => 0x27E8, # \langle, \rangle + 0x6A => 0x7C, # | + 0x6A => 0x2223, # \vert + 0x6B => 0x2225, # \Vert + 0x6C => 0x2195, # \updownarrow + 0x6D => 0x21D5, # \Updownarrow + 0x6E => 0x5C, # \backslash + 0x6E => 0x2216, # \setminus + 0x6F => 0x2240, # \wr + + 0x70 => [0x221A,0,760], # \surd ### adjust position so font doesn't have a large depth + 0x71 => 0x2A3F, # \amalg + 0x72 => 0x2207, # \nabla + 0x73 => 0x222B, # \int + 0x74 => 0x2294, # \sqcup + 0x75 => 0x2293, # \sqcap + [0x76,0x77] => 0x2291, # \sqsubseteq, \sqsupseteq + 0x78 => 0xA7, # \S + [0x79,0x7A] => 0x2020, # \dagger, \ddagger + 0x7B => 0xB6, # \P + 0x7C => 0x2663, # \clubsuit + 0x7D => 0x2662, # \diamondsuit + 0x7E => 0x2661, # \heartsuit + 0x7F => 0x2660, # \spadesuit + ], + + "Caligraphic" => [ + [0x41,0x5A] => 0x41, # A-Z + ], +}; + +$map{cmex10} = { + "Size1" => [ + 0 => [0x28,0,810], # ( + 1 => [0x29,0,810], # ) + 2 => [0x5B,0,810], # [ + 3 => [0x5D,0,810], # ] + 4 => [0x230A,0,810], # \lfloor + 5 => [0x230B,0,810], # \rfloor + 6 => [0x2308,0,810], # \lceil + 7 => [0x2309,0,810], # \rceil + 8 => [0x7B,0,810], # { + 9 => [0x7D,0,810], # } + 0xA => [0x27E8,0,810], # \langle + 0xB => [0x27E9,0,810], # \rangle + 0xC => [0x2223,0,606], # \vert + 0xD => [0x2225,0,606], # \Vert + 0xE => [0x2F,0,810], # / + 0xF => [0x5C,0,810], # \ + + 0x46 => [0x2A06,0,750], # \bigsqcup + 0x48 => [0x222E,0,805], # \oint + 0x4A => [0x2A00,0,750], # \bigodot + 0x4C => [0x2A01,0,750], # \bigoplus + 0x4E => [0x2A02,0,750], # \bigotimes + + 0x50 => [0x2211,0,750], # \sum + 0x51 => [0x220F,0,750], # \prod + 0x52 => [0x222B,0,805], # \int + 0x53 => [0x22C3,0,750], # \bigcup + 0x54 => [0x22C2,0,750], # \bigcap + 0x55 => [0x2A04,0,750], # \biguplus + 0x56 => [0x22C0,0,750], # \bigwedge + 0x57 => [0x22C1,0,750], # \bigvee + + 0x60 => [0x2210,0,750], # \coprod + 0x62 => 0x2C6, # \widehat + 0x62 => [0x302,-556,0], # \widehat (combining) + 0x65 => 0x2DC, # \widetilde + 0x65 => [0x303,-556,0], # \widetilde (combining) + + 0x70 => [0x221A,0,810], # surd + 0x3F => [0x23D0,0,601], # arrow extension + 0x77 => [0x2016,0,601], # Arrow extension (non-standard) + 0x78 => [0x2191,0,600], # uparrow top + 0x79 => [0x2193,0,600], # downarrow bottom + 0x7E => [0x21D1,0,600], # Uparrow top + 0x7F => [0x21D3,0,600], # Downarrow bottom + ], + + "Size2" => [ + 0x10 => [0x28,0,1110], # ( + 0x11 => [0x29,0,1110], # ) + 0x2E => [0x2F,0,1110], # / + 0x2F => [0x5C,0,1110], # \ + 0x44 => [0x27E8,0,1110],# \langle + 0x45 => [0x27E9,0,1110],# \rangle + + 0x47 => [0x2A06,0,950], # \bigsqcup + 0x49 => [0x222E,0,1360],# \oint + 0x4B => [0x2A00,0,950], # \bigodot + 0x4D => [0x2A01,0,950], # \bigoplus + 0x4F => [0x2A02,0,950], # \bigotimes + + 0x58 => [0x2211,0,950], # \sum + 0x59 => [0x220F,0,950], # \prod + 0x5A => [0x222B,0,1360],# \int + 0x5B => [0x22C3,0,950], # \bigcup + 0x5C => [0x22C2,0,950], # \bigcap + 0x5D => [0x2A04,0,950], # \biguplus + 0x5E => [0x22C0,0,950], # \bigwedge + 0x5F => [0x22C1,0,950], # \bigvee + 0x61 => [0x2210,0,950], # \coprod + + 0x63 => 0x2C6, # \widehat + 0x63 => [0x302,-1000,0],# \widehat (combining) + 0x66 => 0x2DC, # \widetilde + 0x66 => [0x303,-1000,0],# \widetilde (combining) + + 0x68 => [0x5B,0,1110], # [ + 0x69 => [0x5D,0,1110], # ] + 0x6A => [0x230A,0,1110],# \lfloor + 0x6B => [0x230B,0,1110],# \rfloor + 0x6C => [0x2308,0,1110],# \lceil + 0x6D => [0x2309,0,1110],# \rceil + 0x6E => [0x7B,0,1110], # { + 0x6F => [0x7D,0,1110], # } + 0x71 => [0x221A,0,1110],# surd + ], + + "Size3" => [ + 0x12 => [0x28,0,1410], # ( + 0x13 => [0x29,0,1410], # ) + 0x14 => [0x5B,0,1410], # [ + 0x15 => [0x5D,0,1410], # ] + 0x16 => [0x230A,0,1410],# \lfloor + 0x17 => [0x230B,0,1410],# \rfloor + 0x18 => [0x2308,0,1410],# \lceil + 0x19 => [0x2309,0,1410],# \rceil + 0x1A => [0x7B,0,1410], # { + 0x1B => [0x7D,0,1410], # } + 0x1C => [0x27E8,0,1410],# \langle + 0x1D => [0x27E9,0,1410],# \rangle + 0x1E => [0x2F,0,1410], # / + 0x1F => [0x5C,0,1410], # \ + 0x64 => 0x2C6, # \widehat + 0x64 => [0x302,-1444,0],# \widehat (combining) + 0x67 => 0x2DC, # \widetilde + 0x67 => [0x303,-1444,0],# \widetilde (combining) + 0x72 => [0x221A,0,1410],# surd + ], + + "Size4" => [ + 0x20 => [0x28,0,1710], # ( + 0x21 => [0x29,0,1710], # ) + 0x22 => [0x5B,0,1710], # [ + 0x23 => [0x5D,0,1710], # ] + 0x24 => [0x230A,0,1710],# \lfloor + 0x25 => [0x230B,0,1710],# \rfloor + 0x26 => [0x2308,0,1710],# \lceil + 0x27 => [0x2309,0,1710],# \rceil + 0x28 => [0x7B,0,1710], # { + 0x29 => [0x7D,0,1710], # } + 0x2A => [0x27E8,0,1710],# \langle + 0x2B => [0x27E9,0,1710],# \rangle + 0x2C => [0x2F,0,1710], # / + 0x2D => [0x5C,0,1710], # \ + 0x73 => [0x221A,0,1710],# surd + + 0x30 => [0x239B,0,1115],# left paren upper hook + 0x31 => [0x239E,0,1115],# right paren upper hook + 0x32 => [0x23A1,0,1115],# left square bracket upper corner + 0x33 => [0x23A4,0,1115],# right square bracket upper corner + 0x34 => [0x23A3,0,1115],# left square bracket lower corner + 0x35 => [0x23A6,0,1115],# right square bracket lower hook + 0x36 => [0x23A2,0,601], # left square bracket extension + 0x37 => [0x23A5,0,601], # right square bracket extension + 0x38 => [0x23A7,0,900], # left curly brace upper hook + 0x39 => [0x23AB,0,900], # right curly brace upper hook + 0x3A => 0x23A9, # left curly brace lower hook + 0x3B => 0x23AD, # right curly brace lower hook + 0x3C => [0x23A8,0,1150],# left curly brace middle + 0x3D => [0x23AC,0,1150],# right curly brace middle + 0x3E => [0x23AA,0,300], # curly brace extension + + 0x40 => [0x239D,0,1115],# left paren lower hook + 0x41 => [0x23A0,0,1115],# right paren lower hook + 0x42 => [0x239C,0,600], # left paren extension + 0x43 => [0x239F,0,600], # right paren extension + + 0x74 => [0x23B7,0,915], # radical bottom + 0x75 => [0xE000,0,605], # radical extension (PUA) + 0x76 => [0xE001,0,565], # radical top (PUA) + [0x7A,0x7D] => 0xE150, # \braceld, \bracerd, \bracelu, \braceru (PUA) + ], + + "Main-Regular" => [ + 0x38 => [0x23B0,0,900], # left curly brace upper hook, for lgroup, lmoustache + 0x39 => [0x23B1,0,900], # right curly brace upper hook, for rgroup, rmoustache + 0x3A => 0x23A9, # left curly brace lower hook, for lgroup, rmoustache + 0x3B => 0x23AD, # right curly brace lower hook, for rgroup, lmoustache + ], +}; + +$map{cmti10} = { + "Main-Italic" => [ + [0,1] => 0x393, # \Gamma, \Delta + 2 => 0x398, # \Theta + 3 => 0x39B, # \Lambda + 4 => 0x39E, # \Xi + 5 => 0x3A0, # \Pi + 6 => 0x3A3, # \Sigma + [7,8] => 0x3A5, # \Upsilon, \Phi + [9,0xA] => 0x3A8, # \Psi, \Omega + + 0x10 => 0x131, # \i + 0x11 => 0x237, # \j + 0x12 => 0x2CB, # \grave + 0x13 => 0x2CA, # \acute + 0x14 => 0x2C7, # \check + 0x15 => 0x2D8, # \breve + 0x16 => 0x2C9, # \bar + 0x17 => [0xB0,-160,0], # \degree + 0x17 => 0x02DA, # \r, ring above + 0x18 => 0xB8, # \c, cedilla + + [0x21,0x23] => 0x21, # !, ", #, + 0x22 => 0x201D, # " + [0x25,0x2F] => 0x25, # %, &, ', (, ), *, +, comma, -, ., / + 0x27 => 0x2019, # ' + [0x30,0x39] => 0x30, # 0-9 + [0x3A,0x3B] => 0x3A, # :, ; + 0x3D => 0x3D, # = + [0x3F,0x40] => 0x3F, # ?, @ + [0x41,0x5A] => 0x41, # A-Z + 0x5B => 0x5B, # [ + 0x5C => 0x201C, # `` + [0x5D,0x5E] => 0x5D, # ], ^ + 0x5E => 0x2C6, # \hat + 0x5F => 0x2D9, # \dot + 0x60 => 0x2018, # ` + [0x61,0x7A] => 0x61, # a-z + [0x7B,0x7C] => 0x2013, # \endash, \emdash + 0x7B => [0x5F,0,-310], # underline + 0x7D => 0x2DD, # double acute + 0x7E => [0x7E,0,-350], # ~ + 0x7E => 0x2DC, # \tilde + 0x7F => 0xA8, # \ddot + 0x19 => 0xDF, # sharp S + 0x1A => 0xE6, # ae ligature + 0x1B => 0x153, # oe ligature + 0x1C => 0xF8, # o with slash + 0x1D => 0xC6, # AE ligature + 0x1E => 0x152, # OE ligature + 0x1F => 0xD8, # O with slash + ], + + "Main-Regular" => [ + 0x24 => 0xA3, # pound sign + ], +}; + +$map{cmbx10} = { + "Main-Bold" => [ + [0,1] => 0x393, # \Gamma, \Delta + 2 => 0x398, # \Theta + 3 => 0x39B, # \Lambda + 4 => 0x39E, # \Xi + 5 => 0x3A0, # \Pi + 6 => 0x3A3, # \Sigma + [7,8] => 0x3A5, # \Upsilon, \Phi + [9,0xA] => 0x3A8, # \Psi, \Omega + + 0x10 => 0x131, # \i + 0x11 => 0x237, # \j + 0x12 => 0x2CB, # \grave + 0x13 => 0x2CA, # \acute + 0x14 => 0x2C7, # \check + 0x15 => 0x2D8, # \breve + 0x16 => 0x2C9, # \bar + 0x17 => [0xB0,-147,0], # \degree + 0x17 => 0x02DA, # \r, ring above + 0x18 => 0xB8, # \c, cedilla + + [0x21,0x2F] => 0x21, # !, ", #, $, %, &, ', (, ), *, +, comma, -, ., / + 0x22 => 0x201D, # " + 0x27 => 0x2019, # ' + [0x30,0x39] => 0x30, # 0-9 + [0x3A,0x3B] => 0x3A, # :, ; + 0x3D => 0x3D, # = + [0x3F,0x40] => 0x3F, # ?, @ + [0x41,0x5A] => 0x41, # A-Z + 0x5B => 0x5B, # [ + 0x5C => 0x201C, # `` + [0x5D,0x5E] => 0x5D, # ], ^ + 0x5E => 0x2C6, # \hat + 0x5F => 0x2D9, # \dot + 0x60 => 0x2018, # ` + [0x61,0x7A] => 0x61, # a-z + [0x7B,0x7C] => 0x2013, # \endash, \emdash + 0x7B => [0x5F,0,-310], # underline + 0x7D => 0x2DD, # double acute + 0x7E => [0x7E,0,-350], # ~ + 0x7E => 0x2DC, # \tilde + 0x7F => 0xA8, # \ddot + 0x19 => 0xDF, # sharp S + 0x1A => 0xE6, # ae ligature + 0x1B => 0x153, # oe ligature + 0x1C => 0xF8, # o with slash + 0x1D => 0xC6, # AE ligature + 0x1E => 0x152, # OE ligature + 0x1F => 0xD8, # O with slash + ], +}; + +$map{cmbxti10} = { + "Main-BoldItalic" => [ + [0,1] => 0x393, # \Gamma, \Delta + 2 => 0x398, # \Theta + 3 => 0x39B, # \Lambda + 4 => 0x39E, # \Xi + 5 => 0x3A0, # \Pi + 6 => 0x3A3, # \Sigma + [7,8] => 0x3A5, # \Upsilon, \Phi + [9,0xA] => 0x3A8, # \Psi, \Omega + + 0x10 => 0x131, # \i + 0x11 => 0x237, # \j + 0x12 => 0x2CB, # \grave + 0x13 => 0x2CA, # \acute + 0x14 => 0x2C7, # \check + 0x15 => 0x2D8, # \breve + 0x16 => 0x2C9, # \bar + 0x17 => [0xB0,-160,0], # \degree + 0x17 => 0x02DA, # \r, ring above + 0x18 => 0xB8, # \c, cedilla + + [0x21,0x23] => 0x21, # !, ", #, + 0x22 => 0x201D, # " + [0x25,0x2F] => 0x25, # %, &, ', (, ), *, +, comma, -, ., / + 0x27 => 0x2019, # ' + [0x30,0x39] => 0x30, # 0-9 + [0x3A,0x3B] => 0x3A, # :, ; + 0x3D => 0x3D, # = + [0x3F,0x40] => 0x3F, # ?, @ + [0x41,0x5A] => 0x41, # A-Z + 0x5B => 0x5B, # [ + 0x5C => 0x201C, # `` + [0x5D,0x5E] => 0x5D, # ], ^ + 0x5E => 0x2C6, # \hat + 0x5F => 0x2D9, # \dot + 0x60 => 0x2018, # ` + [0x61,0x7A] => 0x61, # a-z + [0x7B,0x7C] => 0x2013, # \endash, \emdash + 0x7B => [0x5F,0,-310], # underline + 0x7D => 0x2DD, # double acute + 0x7E => [0x7E,0,-350], # ~ + 0x7E => 0x2DC, # \tilde + 0x7F => 0xA8, # \ddot + 0x19 => 0xDF, # sharp S + 0x1A => 0xE6, # ae ligature + 0x1B => 0x153, # oe ligature + 0x1C => 0xF8, # o with slash + 0x1D => 0xC6, # AE ligature + 0x1E => 0x152, # OE ligature + 0x1F => 0xD8, # O with slash + ], + + "Main-Bold" => [ + 0x24 => 0xA3, # pound sign + ], +}; + +$map{cmmib10} = { + "Math-BoldItalic" => [ + [0,1] => 0x393, # \Gamma, \Delta + 2 => 0x398, # \Theta + 3 => 0x39B, # \Lambda + 4 => 0x39E, # \Xi + 5 => 0x3A0, # \Pi + 6 => 0x3A3, # \Sigma + [7,8] => 0x3A5, # \Upsilon, \Phi + [9,0xA] => 0x3A8, # \Psi, \Omega + + [0xB,0xE] => 0x3B1, # \alpha, \beta, \gamma, \delta + 0xF => 0x3F5, # \elpsilon + [0x10,0x18] => 0x3B6, # \zeta, \eta, \theta, \iota, \kappa, \lambda, \mu, \nu, \xi + [0x19,0x1A] => 0x3C0, # \pi, \rho + [0x1B,0x1D] => 0x3C3, # \sigma, \tau, \upsilon + 0x1E => 0x3D5, # \phi + [0x1F,0x21] => 0x3C7, # \chi, \psi, \omega + 0x22 => 0x3B5, # \varepsilon + 0x23 => 0x3D1, # \vartheta + 0x24 => 0x3D6, # \varpi + 0x25 => 0x3F1, # \varrho + 0x26 => 0x3C2, # \varsigma + 0x27 => 0x3C6, # \varphi + + [0x30,0x39] => 0x30, # Oldstyle 0-9 + [0x41,0x5A] => 0x41, # A-Z + [0x61,0x7A] => 0x61, # a - z + + 0x6F => 0x3BF, # omicron + 0x7B => 0xE131, # \imath (PUA) + 0x7C => 0xE237, # \jmath (PUA) + ], + + "Main-Bold" => [ + 0x28 => 0x21BC, # \leftharpoonup + 0x29 => 0x21BD, # \leftharpoondown + 0x2A => 0x21C0, # \rightharpoonup + 0x2B => 0x21C1, # \rightharpoondown + + 0x2E => 0x25B9, # \triangleright + 0x2F => 0x25C3, # \triangleleft + + 0x3A => 0x2E, # . + 0x3B => 0x2C, # , + 0x3C => 0x3C, # < + 0x3D => 0x2215, # / + 0x3E => 0x3E, # > + 0x3F => 0x22C6, # \star + 0x40 => 0x2202, # \partial + + [0x5B,0x5D] => 0x266D, # \flat, \natural, \sharp + 0x5E => 0x2323, # \smile + 0x5F => 0x2322, # \frown + 0x60 => 0x2113, # \ell + 0x68 => 0x210F, # \hbar (bar added below) + + 0x7D => 0x2118, # \wp + 0x7E => [0x20D7,-729,0],# \vec + ], +}; + +$map{cmbsy10} = { + "Main-Bold" => [ + [0,1] => 0x2212, # - + 1 => 0x22C5, # \cdot + 2 => 0xD7, # \times + 3 => 0x2217, # \ast + 4 => 0xF7, # \div + 5 => 0x22C4, # \diamond + 6 => 0xB1, # \pm + 7 => 0x2213, # \mp + [8,0xC] => 0x2295, # \oplus, \ominus, \otimes, \oslash, \odot + 0xD => 0x25EF, # \bigcirc + [0xE,0xF] => 0x2218, # \circ, \bullet + + 0x10 => 0x224D, # \asymp + 0x11 => 0x2261, # \equiv + [0x12,0x13] => 0x2286, # \subseteq, \supseteq + [0x14,0x15] => 0x2264, # \leq, \geq + [0x16,0x17] => 0x2AAF, # \preceq, \succeq + 0x18 => 0x223C, # \sim + 0x19 => 0x2248, # \approx + [0x1A,0x1B] => 0x2282, # \subset, \supset + [0x1C,0x1D] => 0x226A, # \ll, \gg + [0x1E,0x1F] => 0x227A, # \prec, \succ + + 0x20 => 0x2190, # \leftarrow + 0x21 => 0x2192, # \rightarrow + 0x22 => 0x2191, # \uparrow + 0x23 => 0x2193, # \downarrow + 0x24 => 0x2194, # \leftrightarrow + 0x25 => 0x2197, # \nearrow + 0x26 => 0x2198, # \searrow + 0x27 => 0x2243, # \simeq + + 0x28 => 0x21D0, # \Leftarrow + 0x29 => 0x21D2, # \Rightarrow + 0x2A => 0x21D1, # \Uparrow + 0x2B => 0x21D3, # \Downarrow + 0x2C => 0x21D4, # \Leftrightarrow + 0x2D => 0x2196, # \nwarrow + 0x2E => 0x2199, # \swarrow + 0x2F => 0x221D, # \propto + + 0x30 => 0x2032, # \prime + 0x31 => 0x221E, # \infty + 0x32 => 0x2208, # \in + 0x33 => 0x220B, # \ni + 0x34 => 0x25B3, # \bigtriangleup and \triangle + 0x35 => 0x25BD, # \bigtriangledown + 0x36 => 0xE020, # \not + + 0x38 => 0x2200, # \forall + 0x39 => 0x2203, # \exists + 0x3A => 0xAC, # \neg + 0x3B => 0x2205, # \emptyset + 0x3C => 0x211C, # \Re + 0x3D => 0x2111, # \Im + 0x3E => 0x22A4, # \top + 0x3F => 0x22A5, # \bot + + 0x40 => 0x2135, # \aleph + + 0x5B => 0x222A, # \cup + 0x5C => 0x2229, # \cap + 0x5D => 0x228E, # \uplus + [0x5E,0x5F] => 0x2227, # \wedge, \vee + + [0x60,0x61] => 0x22A2, # \vdash, \dashv + [0x62,0x63] => 0x230A, # \lfloor, \rfloor + [0x64,0x65] => 0x2308, # \lceil, \rceil + 0x66 => 0x7B, # { + 0x67 => 0x7D, # } + [0x68,0x69] => 0x27E8, # \langle, \rangle + 0x6A => 0x7C, # | + 0x6A => 0x2223, # \vert + 0x6B => 0x2225, # \Vert + 0x6C => 0x2195, # \updownarrow + 0x6D => 0x21D5, # \Updownarrow + 0x6E => 0x5C, # \backslash + 0x6E => 0x2216, # \setminus + 0x6F => 0x2240, # \wr + + 0x70 => [0x221A,0,760], # \surd ### adjust position so font doesn't have a large depth + 0x71 => 0x2A3F, # \amalg + 0x72 => 0x2207, # \nabla + 0x73 => 0x222B, # \int + 0x74 => 0x2294, # \sqcup + 0x75 => 0x2293, # \sqcap + [0x76,0x77] => 0x2291, # \sqsubseteq, \sqsupseteq + + [0x79,0x7A] => 0x2020, # \dagger, \ddagger + + 0x7C => 0x2663, # \clubsuit + 0x7D => 0x2662, # \diamondsuit + 0x7E => 0x2661, # \heartsuit + 0x7F => 0x2660, # \spadesuit + ], + + "Caligraphic-Bold" => [ + [0x41,0x5A] => 0x41, # A-Z + ], +}; + +$map{msam10} = { + "Main-Regular" => [ + 0x5C => 0x2220, # \angle + ], + + "Main-Bold" => [ + 0x5C => 0x2220, # \angle (emboldened below) + ], + + "AMS" => [ + 0x00 => 0x22A1, # \boxdot + 0x01 => 0x229E, # \boxplus + 0x02 => 0x22A0, # \boxtimes + 0x03 => 0x25A1, # \square + 0x04 => 0x25A0, # \blacksquare + 0x05 => 0x22C5, # \centerdot + 0x06 => 0x25CA, # \lozenge + 0x07 => 0x29EB, # \blacklozenge + 0x08 => 0x21BB, # \circlearrowright + 0x09 => 0x21BA, # \circlearrowleft + 0x0A => 0x21CC, # \rightleftharpoons + 0x0B => 0x21CB, # \leftrightharpoons + 0x0C => 0x229F, # \boxminus + 0x0D => 0x22A9, # \Vdash + 0x0E => 0x22AA, # \Vvdash + 0x0F => 0x22A8, # \vDash + 0x10 => 0x21A0, # \twoheadrightarrow + 0x11 => 0x219E, # \twoheadleftarrow + 0x12 => 0x21C7, # \leftleftarrows + 0x13 => 0x21C9, # \rightrightarrows + 0x14 => 0x21C8, # \upuparrows + 0x15 => 0x21CA, # \downdownarrows + 0x16 => 0x21BE, # \upharpoonright + 0x17 => 0x21C2, # \downharpoonright + 0x18 => 0x21BF, # \upharpoonleft + 0x19 => 0x21C3, # \downharpoonleft + 0x1A => 0x21A3, # \rightarrowtail + 0x1B => 0x21A2, # \leftarrowtail + 0x1C => 0x21C6, # \leftrightarrows + 0x1D => 0x21C4, # \rightleftarrows + 0x1E => 0x21B0, # \Lsh + 0x1F => 0x21B1, # \Rsh + 0x20 => 0x21DD, # \rightsquigarrow + 0x21 => 0x21AD, # \leftrightsquigarrow + 0x22 => 0x21AB, # \looparrowleft + 0x23 => 0x21AC, # \looparrowright + 0x24 => 0x2257, # \circeq + 0x25 => 0x227F, # \succsim + 0x26 => 0x2273, # \gtrsim + 0x27 => 0x2A86, # \gtrapprox + 0x28 => 0x22B8, # \multimap + 0x29 => 0x2234, # \therefore + 0x2A => 0x2235, # \because + 0x2B => 0x2251, # \doteqdot + 0x2C => 0x225C, # \triangleq + 0x2D => 0x227E, # \precsim + 0x2E => 0x2272, # \lesssim + 0x2F => 0x2A85, # \lessapprox + 0x30 => 0x2A95, # \eqslantless + 0x31 => 0x2A96, # \eqslantgtr + 0x32 => 0x22DE, # \curlyeqprec + 0x33 => 0x22DF, # \curlyeqsucc + 0x34 => 0x227C, # \preccurlyeq + 0x35 => 0x2266, # \leqq + 0x36 => 0x2A7D, # \leqslant + 0x37 => 0x2276, # \lessgtr + 0x38 => 0x2035, # \backprime + 0x39 => 0x2212, # dahsed arrow extension + 0x3A => 0x2253, # \risingdotseq + 0x3B => 0x2252, # \fallingdotseq + 0x3C => 0x227D, # \succcurlyeq + 0x3D => 0x2267, # \geqq + 0x3E => 0x2A7E, # \geqslant + 0x3F => 0x2277, # \gtrless + 0x40 => 0x228F, # \sqsubset + 0x41 => 0x2290, # \sqsupset + 0x42 => 0x22B3, # \vartriangleright + 0x43 => 0x22B2, # \vartriangleleft + 0x44 => 0x22B5, # \trianglerighteq + 0x45 => 0x22B4, # \trianglelefteq + 0x46 => 0x2605, # \bigstar + 0x47 => 0x226C, # \between + 0x48 => 0x25BC, # \blacktriangledown + 0x49 => 0x25B6, # \blacktriangleright + 0x4A => 0x25C0, # \blacktriangleleft + 0x4B => 0x2192, # rightarrow + 0x4C => 0x2190, # leftarrow + 0x4D => 0x25B3, # \vartriangle + 0x4E => 0x25B2, # \blacktriangle + 0x4F => 0x25BD, # \triangledown + 0x50 => 0x2256, # \eqcirc + 0x51 => 0x22DA, # \lesseqgtr + 0x52 => 0x22DB, # \gtreqless + 0x53 => 0x2A8B, # \lesseqqgtr + 0x54 => 0x2A8C, # \gtreqqless + 0x55 => 0x00A5, # yen + 0x56 => 0x21DB, # \Rrightarrow + 0x57 => 0x21DA, # \Lleftarrow + 0x58 => 0x2713, # checkmark + 0x59 => 0x22BB, # \veebar + 0x5A => 0x22BC, # \barwedge + 0x5B => 0x2A5E, # \doublebarwedge + 0x5C => 0x2220, # \angle + 0x5D => 0x2221, # \measuredangle + 0x5E => 0x2222, # \sphericalangle + 0x5F => 0x221D, # \varpropto + 0x60 => 0x2323, # \smallsmile + 0x61 => 0x2322, # \smallfrown + 0x62 => 0x22D0, # \Subset + 0x63 => 0x22D1, # \Supset + 0x64 => 0x22D3, # \Cup + 0x65 => 0x22D2, # \Cap + 0x66 => 0x22CF, # \curlywedge + 0x67 => 0x22CE, # \curlyvee + 0x68 => 0x22CB, # \leftthreetimes + 0x69 => 0x22CC, # \rightthreetimes + 0x6A => 0x2AC5, # \subseteqq + 0x6B => 0x2AC6, # \supseteqq + 0x6C => 0x224F, # \bumpeq + 0x6D => 0x224E, # \Bumpeq + 0x6E => 0x22D8, # \lll + 0x6F => 0x22D9, # \ggg + 0x70 => 0x250C, # \ulcorner + 0x71 => 0x2510, # \urcorner + 0x72 => 0x00AE, # registered sign + 0x73 => 0x24C8, # \circledS + 0x74 => 0x22D4, # \pitchfork + 0x75 => 0x2214, # \dotplus + 0x76 => 0x223D, # \backsim + 0x77 => 0x22CD, # \backsimeq + 0x78 => 0x2514, # \llcorner + 0x79 => 0x2518, # \lrcorner + 0x7A => 0x2720, # maltese cross + 0x7B => 0x2201, # \complement + 0x7C => 0x22BA, # \intercal + 0x7D => 0x229A, # \circledcirc + 0x7E => 0x229B, # \circledast + 0x7F => 0x229D, # \circleddash + ], +}; + +$map{msbm10} = { + "Size4" => [ + 0x5B => 0x2C6, # \widehat + 0x5B => [0x302,-1889,0],# \widehat (combining) + 0x5D => 0x2DC, # \widetilde + 0x5D => [0x303,-1889,0],# \widetilde (combining) + ], + + "Main-Regular" => [ + 0x7E => 0x210F, # \hbar + ], + + "Main-Italic" => [ + 0x7D => 0x210F, # \hbar (with slant) + ], + + "AMS" => [ + 0x00 => 0xE00C, # \lvertneqq + 0x01 => 0xE00D, # \gvertneqq + 0x02 => 0x2270, # \nleq + 0x03 => 0x2271, # \ngeq + 0x04 => 0x226E, # \nless + 0x05 => 0x226F, # \ngtr + 0x06 => 0x2280, # \nprec + 0x07 => 0x2281, # \nsucc + 0x08 => 0x2268, # \lneqq + 0x09 => 0x2269, # \gneqq + 0x0A => 0xE010, # \nleqslant + 0x0B => 0xE00F, # \ngeqslant + 0x0C => 0x2A87, # \lneq + 0x0D => 0x2A88, # \gneq + 0x0E => 0x22E0, # \npreceq + 0x0F => 0x22E1, # \nsucceq + 0x10 => 0x22E8, # \precnsim + 0x11 => 0x22E9, # \succnsim + 0x12 => 0x22E6, # \lnsim + 0x13 => 0x22E7, # \gnsim + 0x14 => 0xE011, # \nleqq + 0x15 => 0xE00E, # \ngeqq + 0x16 => 0x2AB5, # \precneqq + 0x17 => 0x2AB6, # \succneqq + 0x18 => 0x2AB9, # \precnapprox + 0x19 => 0x2ABA, # \succnapprox + 0x1A => 0x2A89, # \lnapprox + 0x1B => 0x2A8A, # \gnapprox + 0x1C => 0x2241, # \nsim + 0x1D => 0x2246, # \ncong + 0x1E => 0x2571, # \diagup + 0x1F => 0x2572, # \diagdown + 0x20 => 0xE01A, # \varsubsetneq + 0x21 => 0xE01B, # \varsupsetneq + 0x22 => 0xE016, # \nsubseteqq + 0x23 => 0xE018, # \nsupseteqq + 0x24 => 0x2ACB, # \subsetneqq + 0x25 => 0x2ACC, # \supsetneqq + 0x26 => 0xE017, # \varsubsetneqq + 0x27 => 0xE019, # \varsupsetneqq + 0x28 => 0x228A, # \subsetneq + 0x29 => 0x228B, # \supsetneq + 0x2A => 0x2288, # \nsubseteq + 0x2B => 0x2289, # \nsupseteq + 0x2C => 0x2226, # \nparallel + 0x2D => 0x2224, # \nmid + 0x2E => 0xE006, # \nshortmid + 0x2F => 0xE007, # \nshortparallel + 0x30 => 0x22AC, # \nvdash + 0x31 => 0x22AE, # \nVdash + 0x32 => 0x22AD, # \nvDash + 0x33 => 0x22AF, # \nVDash + 0x34 => 0x22ED, # \ntrianglerighteq + 0x35 => 0x22EC, # \ntrianglelefteq + 0x36 => 0x22EA, # \ntriangleleft + 0x37 => 0x22EB, # \ntriangleright + 0x38 => 0x219A, # \nleftarrow + 0x39 => 0x219B, # \nrightarrow + 0x3A => 0x21CD, # \nLeftarrow + 0x3B => 0x21CF, # \nRightarrow + 0x3C => 0x21CE, # \nLeftrightarrow + 0x3D => 0x21AE, # \nleftrightarrow + 0x3E => 0x22C7, # \divideontimes + 0x3F => 0x2205, # \varnothing + 0x40 => 0x2204, # \nexists + + [0x41,0x5A] => 0x41, # A-Z + 0x5C => 0x2C6, # \widehat + 0x5C => [0x302,-2333,0],# \widehat (combining) + 0x5E => 0x2DC, # \widetilde + 0x5E => [0x303,-2333,0],# \widetilde (combining) + + 0x60 => 0x2132, # \Finv + 0x61 => 0x2141, # \Game + 0x66 => 0x2127, # \mho + 0x67 => 0x00F0, # \eth + 0x68 => 0x2242, # minus-tilde + 0x69 => 0x2136, # \beth + 0x6A => 0x2137, # \gimel + 0x6B => 0x2138, # \daleth + 0x6C => 0x22D6, # \lessdot + 0x6D => 0x22D7, # \gtrdot + 0x6E => 0x22C9, # \ltimes + 0x6F => 0x22CA, # \rtimes + 0x70 => 0x2223, # \shortmid + 0x71 => 0x2225, # \shortparallel + 0x72 => 0x2216, # \smallsetminus + 0x73 => 0x223C, # \thicksim + 0x74 => 0x2248, # \thickapprox + 0x75 => 0x224A, # \approxeq + 0x76 => 0x2AB8, # \succapprox + 0x77 => 0x2AB7, # \precapprox + 0x78 => 0x21B6, # \curvearrowleft + 0x79 => 0x21B7, # \curvearrowright + 0x7A => 0x03DD, # \digamma + 0x7B => 0x03F0, # \varkappa + 0x7A => 0xE008, # \digamma (non-standard, for IE) + 0x7B => 0xE009, # \varkappa (non-standard, for IE) + 0x7C => 0x006B, # \Bbbk + 0x7D => 0x210F, # \hslash + 0x7E => 0x0127, # \hbar + 0x7F => 0x220D, # \backepsilon + ], +}; + +$map{cmss10} = { + "SansSerif-Regular" => [ + [0,1] => 0x393, # \Gamma, \Delta + 2 => 0x398, # \Theta + 3 => 0x39B, # \Lambda + 4 => 0x39E, # \Xi + 5 => 0x3A0, # \Pi + 6 => 0x3A3, # \Sigma + [7,8] => 0x3A5, # \Upsilon, \Phi + [9,0xA] => 0x3A8, # \Psi, \Omega + + 0x10 => 0x131, # \i + 0x11 => 0x237, # \j + 0x12 => 0x2CB, # \grave + 0x13 => 0x2CA, # \acute + 0x14 => 0x2C7, # \check + 0x15 => 0x2D8, # \breve + 0x16 => 0x2C9, # \bar + 0x17 => [0xB0,-142,0], # \degree + 0x17 => 0x02DA, # \r, ring above + 0x18 => 0xB8, # \c, cedilla + + [0x21,0x2F] => 0x21, # !, ", #, $, %, &, ', (, ), *, +, comma, -, ., / + 0x22 => 0x201D, # " + 0x27 => 0x2019, # ' + [0x30,0x39] => 0x30, # 0-9 + [0x3A,0x3B] => 0x3A, # :, ; + 0x3D => 0x3D, # = + [0x3F,0x40] => 0x3F, # ?, @ + [0x41,0x5A] => 0x41, # A-Z + 0x5B => 0x5B, # [ + 0x5C => 0x201C, # `` + [0x5D,0x5E] => 0x5D, # ], ^ + 0x5E => 0x2C6, # \hat + 0x5F => 0x2D9, # \dot + 0x60 => 0x2018, # ` + [0x61,0x7A] => 0x61, # a-z + [0x7B,0x7C] => 0x2013, # \endash, \emdash + 0x7B => [0x5F,0,-350], # underline + 0x7D => 0x2DD, # double acute + 0x7E => [0x7E,0,-350], # ~ + 0x7E => 0x2DC, # \tilde + 0x7F => 0xA8, # \ddot + ], +}; + +$map{cmssi10} = { + "SansSerif-Italic" => [ + [0,1] => 0x393, # \Gamma, \Delta + 2 => 0x398, # \Theta + 3 => 0x39B, # \Lambda + 4 => 0x39E, # \Xi + 5 => 0x3A0, # \Pi + 6 => 0x3A3, # \Sigma + [7,8] => 0x3A5, # \Upsilon, \Phi + [9,0xA] => 0x3A8, # \Psi, \Omega + + 0x10 => 0x131, # \i + 0x11 => 0x237, # \j + 0x12 => 0x2CB, # \grave + 0x13 => 0x2CA, # \acute + 0x14 => 0x2C7, # \check + 0x15 => 0x2D8, # \breve + 0x16 => 0x2C9, # \bar + 0x17 => [0xB0,-113,0], # \degree + 0x17 => 0x02DA, # \r, ring above + 0x18 => 0xB8, # \c, cedilla + + [0x21,0x2F] => 0x21, # !, ", #, $, %, &, ', (, ), *, +, comma, -, ., / + 0x22 => 0x201D, # " + 0x27 => 0x2019, # ' + [0x30,0x39] => 0x30, # 0-9 + [0x3A,0x3B] => 0x3A, # :, ; + 0x3D => 0x3D, # = + [0x3F,0x40] => 0x3F, # ?, @ + [0x41,0x5A] => 0x41, # A-Z + 0x5B => 0x5B, # [ + 0x5C => 0x201C, # `` + [0x5D,0x5E] => 0x5D, # ], ^ + 0x5E => 0x2C6, # \hat + 0x5F => 0x2D9, # \dot + 0x60 => 0x2018, # ` + [0x61,0x7A] => 0x61, # a-z + [0x7B,0x7C] => 0x2013, # \endash, \emdash + 0x7B => [0x5F,0,-350], # underline + 0x7D => 0x2DD, # double acute + 0x7E => [0x7E,0,-350], # ~ + 0x7E => 0x2DC, # \tilde + 0x7F => 0xA8, # \ddot + ], +}; + +$map{cmssbx10} = { + "SansSerif-Bold" => [ + [0,1] => 0x393, # \Gamma, \Delta + 2 => 0x398, # \Theta + 3 => 0x39B, # \Lambda + 4 => 0x39E, # \Xi + 5 => 0x3A0, # \Pi + 6 => 0x3A3, # \Sigma + [7,8] => 0x3A5, # \Upsilon, \Phi + [9,0xA] => 0x3A8, # \Psi, \Omega + + 0x10 => 0x131, # \i + 0x11 => 0x237, # \j + 0x13 => 0xB4, # \acute + 0x14 => 0x2C7, # \check + 0x15 => 0x2D8, # \breve + 0x16 => 0x2C9, # \bar + 0x17 => [0xB0,-58,0], # \degree + 0x17 => 0x02DA, # \r, ring above + 0x18 => 0xB8, # \c, cedilla + + [0x21,0x2F] => 0x21, # !, ", #, $, %, &, ', (, ), *, +, comma, -, ., / + 0x22 => 0x201D, # " + 0x27 => 0x2019, # ' + [0x30,0x39] => 0x30, # 0-9 + [0x3A,0x3B] => 0x3A, # :, ; + 0x3D => 0x3D, # = + [0x3F,0x40] => 0x3F, # ?, @ + [0x41,0x5A] => 0x41, # A-Z + 0x5B => 0x5B, # [ + 0x5C => 0x201C, # `` + [0x5D,0x5E] => 0x5D, # ], ^ + 0x5E => 0x2C6, # \hat + 0x5F => 0x2D9, # \dot + 0x60 => 0x2018, # ` + [0x61,0x7A] => 0x61, # a-z + [0x7B,0x7C] => 0x2013, # \endash, \emdash + 0x7B => [0x5F,0,-350], # underline + 0x7D => 0x2DD, # double acute + 0x7E => [0x7E,0,-350], # ~ + 0x7E => 0x2DC, # \tilde + 0x7F => 0xA8, # \ddot + ], +}; + +$map{eufm10} = { + "Fraktur-Regular" => [ + [0,7] => 0xE300, # variants + 0x12 => 0x2018, # left quote + 0x13 => 0x2019, # right quote + 0x21 => 0x21, # ! + [0x26,0x2F] => 0x26, # &, ', (, ), *, +, comma, -, ., / + [0x30,0x39] => 0x30, # 0-9 + [0x3A,0x3B] => 0x3A, # :, ; + 0x3D => 0x3D, # = + 0x3F => 0x3F, # ? + [0x41,0x5A] => 0x41, # A-Z + 0x5B => 0x5B, # [ + [0x5D,0x5E] => 0x5D, # ], ^ + [0x61,0x7A] => 0x61, # a-z + 0x7D => 0x22, # " + ], +}; + +$map{eufb10} = { + "Fraktur-Bold" => [ + [1,5] => 0xE301, # variants + [8,9] => 0xE308, # variants + 0x12 => 0x2018, # left quote + 0x13 => 0x2019, # right quote + 0x21 => 0x21, # ! + [0x26,0x2F] => 0x26, # &, ', (, ), *, +, comma, -, ., / + [0x30,0x39] => 0x30, # 0-9 + [0x3A,0x3B] => 0x3A, # :, ; + 0x3D => 0x3D, # = + 0x3F => 0x3F, # ? + [0x41,0x5A] => 0x41, # A-Z + 0x5B => 0x5B, # [ + [0x5D,0x5E] => 0x5D, # ], ^ + [0x61,0x7A] => 0x61, # a-z + 0x7D => 0x22, # " + ], +}; + +$map{rsfs10} = { + "Script-Regular" => [ + [0x41,0x5A] => 0x41, # A-Z + ] +}; + +#$map{eusm10} = { +# "Script-Regular" => [ +# 0x3C => 0x211C, # \Re +# 0x3D => 0x2111, # \Im +# 0x40 => 0x2135, # \aleph +# [0x41,0x5A] => 0x41, # A-Z +# 0x66 => 0x7B, # { +# 0x67 => 0x7D, # } +# 0x78 => 0xA7, # \S +# ], +#}; + +#$map{eusb10} = { +# "Script-Bold" => [ +# 0x3C => 0x211C, # \Re +# 0x3D => 0x2111, # \Im +# 0x40 => 0x2135, # \aleph +# [0x41,0x5A] => 0x41, # A-Z +# 0x66 => 0x7B, # { +# 0x67 => 0x7D, # } +# 0x78 => 0xA7, # \S +# ], +#}; + +$map{cmtt10} = { + "Typewriter" => [ + [0,1] => 0x393, # \Gamma, \Delta + 2 => 0x398, # \Theta + 3 => 0x39B, # \Lambda + 4 => 0x39E, # \Xi + 5 => 0x3A0, # \Pi + 6 => 0x3A3, # \Sigma + [7,8] => 0x3A5, # \Upsilon, \Phi + [9,0xA] => 0x3A8, # \Psi, \Omega + 0xD => 0x2032, # ' + + 0x10 => 0x131, # \i + 0x11 => 0x237, # \j + 0x12 => 0x2CB, # \grave + 0x13 => 0x2CA, # \acute + 0x14 => 0x2C7, # \check + 0x15 => 0x2D8, # \breve + 0x16 => 0x2C9, # \bar + 0x17 => 0xB0, # \degree + 0x17 => 0x02DA, # \r, ring above + 0x18 => 0xB8, # \c, cedilla + 0x20 => 0x2423, # graphic representation of space + + [0x21,0x7F] => 0x21, + + 0x60 => 0x2018, # left quote + 0x27 => 0x2019, # right quote + 0x5E => 0x2C6, # \hat + 0x5F => 0x2D9, # \dot + 0x7D => 0x2DD, # double acute + 0x7E => [0x7E,0,-350], # ~ + 0x7E => 0x2DC, # \tilde + 0x7F => 0xA8, # \ddot + ] +}; + +######################################################################### + +$extra{'Main-Regular'} = { + cdots => [ + 'Select(0u22C5)','Copy()', + 'Select(0u22EF)','Paste()', + 'PasteWithOffset(447,0)', + 'PasteWithOffset(894,0)', + 'SetRBearing(894,1)', + ], + + ldots => [ + 'Select(0u2E)','Copy()', + 'Select(0u2026)','Paste()', + 'PasteWithOffset(447,0)', + 'PasteWithOffset(894,0)', + 'SetRBearing(894,1)', + ], + + vdots => [ + 'Select(0u2E)','Copy()', + 'Select(0u22EE)','Clear()', + 'PasteWithOffset(0,-30)', + 'PasteWithOffset(0,380)', + 'PasteWithOffset(0,780)', + 'SetRBearing(-722,1)', + ], + + ddots => [ + 'Select(0u2E)','Copy()', + 'Select(0u22F1)','Clear()', + 'PasteWithOffset(55,700)', + 'PasteWithOffset(502,400)', + 'PasteWithOffset(949,100)', + 'SetRBearing(282,1)', + ], + + spaceEn => [ + 'Select(0u2002)', + 'SetRBearing(500)', + ], + + spaceEm => [ + 'Select(0u2003)', + 'SetRBearing(999)', + ], + + space3 => [ + 'Select(0u2004)', + 'SetRBearing(333)', + ], + + space4 => [ + 'Select(0u2005)', + 'SetRBearing(250)', + ], + + space6 => [ + 'Select(0u2006)', + 'SetRBearing(167)', + ], + + thinspace => [ + 'Select(0u2009)', + 'SetRBearing(167)', + ], + + hairspace => [ + 'Select(0u200A)', + 'SetRBearing(83)', + ], + + cong => [ + 'Select(0u223C)','Copy()', + 'Select(0u2245)','Clear()', + 'PasteWithOffset(0,222)', + 'Select(0u3D)','Copy()', + 'Select(0u2245)', + 'PasteWithOffset(0,-111)', + 'SetWidth(778)', + ], + + bowtie => [ + 'Select(0u25B9)','Copy()', + 'Select(0u22C8)','Paste()', + 'Select(0u25C3)','Copy()', + 'Select(0u22C8)', + 'PasteWithOffset(400,0)', + 'SetRBearing(400,1)', + 'RemoveOverlap()', + ], + + models => [ + 'Select(0u2223)','Copy()', + 'Select(0u22A8)','Paste()', + 'Select(0u3D)','Copy()', + 'Select(0u22A8)', + 'PasteWithOffset(89,0)', + 'SetRBearing(589,1)', + 'RemoveOverlap()', + ], + + doteq => [ + 'Select(0u3D)','Copy()', + 'Select(0u2250)','Paste()', + 'Select(0u2E)','Copy()', + 'Select(0u2250)', + 'PasteWithOffset(251,550)', + ], + + not => [ + 'Select(0uE020)', + 'SetRBearing(778,1)', + ], + + #notin => [ + # 'Select(0u2208)','Copy()', + # 'Select(0u2209)','Paste()', + # 'Select(0u338)','Copy()', + # 'Select(0u2209)', + # 'PasteWithOffset(-55,0)', + # 'RemoveOverlap()', + #], + + #noteq => [ + # 'Select(0u3D)','Copy()', + # 'Select(0u2260)','Paste()', + # 'Select(0u338)','Copy()', + # 'Select(0u2260)', + # 'PasteWithOffset(0,0)', + # 'RemoveOverlap()', + #], + + longleftarrow => [ + 'Select(0u2190)','Copy()', + 'Select(0u27F5)','Paste()', + 'Select(0u2212)','Copy()', + 'Select(0u27F5)', + 'PasteWithOffset(831,0)', + 'SetRBearing(609,1)', + 'RemoveOverlap()','Simplify()', + ], + + Longleftarrow => [ + 'Select(0u21D0)','Copy()', + 'Select(0u27F8)','Paste()', + 'Select(0u3D)','Copy()', + 'Select(0u27F8)', + 'PasteWithOffset(831,0)', + 'SetRBearing(609,1)', + 'RemoveOverlap()','Simplify()', + ], + + longrightarrow => [ + 'Select(0u2212)','Copy()', + 'Select(0u27F6)','Paste()', + 'Select(0u2192)','Copy()', + 'Select(0u27F6)', + 'PasteWithOffset(609,0)', + 'SetRBearing(860,1)', + 'RemoveOverlap()','Simplify()', + ], + + Longrightarrow => [ + 'Select(0u3D)','Copy()', + 'Select(0u27F9)','Paste()', + 'Select(0u21D2)','Copy()', + 'Select(0u27F9)', + 'PasteWithOffset(638,0)', + 'SetRBearing(860,1)', + 'RemoveOverlap()','Simplify()', + ], + + leftrightarrow => [ + 'Select(0u2190)','Copy()', + 'Select(0u27F7)','Paste()', + 'Select(0u2192)','Copy()', + 'Select(0u27F7)', + 'PasteWithOffset(859,0)', + 'SetRBearing(859,1)', + 'RemoveOverlap()','Simplify()', + ], + + Leftrightarrow => [ + 'Select(0u21D0)','Copy()', + 'Select(0u27FA)','Paste()', + 'Select(0u21D2)','Copy()', + 'Select(0u27FA)', + 'PasteWithOffset(858,0)', + 'SetRBearing(858,1)', + 'RemoveOverlap()','Simplify()', + ], + + mapsto => [ + 'Select(0u2192)','Copy()', + 'Select(0u21A6)','Paste()', + 'Generate("otf/KaTeX_Main-Regular.otf")', + 'Open("pfa/cmsy10.pfa")', + 'Select(0x37)','Copy()', + 'Open("otf/KaTeX_Main-Regular.otf")', + 'Select(0u21A6)', + 'PasteWithOffset(0,0)', + 'RemoveOverlap()','Simplify()', + ], + + xlongmapsto => [ + 'Select(0u27F6)','Copy()', + 'Select(0u27FC)','Paste()', + 'Generate("otf/KaTeX_Main-Regular.otf")', + 'Open("pfa/cmsy10.pfa")', + 'Select(0x37)','Copy()', + 'Open("otf/KaTeX_Main-Regular.otf")', + 'Select(0u27FC)', + 'PasteWithOffset(0,0)', + 'RemoveOverlap()','Simplify()', + ], + + hookleftarrow => [ + 'Select(0u2190)','Copy()', + 'Select(0u21A9)','Paste()', + 'Generate("otf/KaTeX_Main-Regular.otf")', + 'Open("pfa/cmmi10.pfa")', + 'Select(0x2D)','Copy()', + 'Open("otf/KaTeX_Main-Regular.otf")', + 'Select(0u21A9)', + 'PasteWithOffset(848,0)', + 'SetRBearing(126,1)', + 'RemoveOverlap()','Simplify()', + ], + + hookrightarrow => [ + 'Generate("otf/KaTeX_Main-Regular.otf")', + 'Open("pfa/cmmi10.pfa")', + 'Select(0x2C)','Copy()', + 'Open("otf/KaTeX_Main-Regular.otf")', + 'Select(0u21AA)','Paste()', + 'Select(0u2192)','Copy()', + 'Select(0u21AA)', + 'PasteWithOffset(126,0)', + 'SetRBearing(848,1)', + 'RemoveOverlap()','Simplify()', + ], + + rightleftharpoons => [ + 'Select(0u21BD)','Copy()', + 'Select(0u21CC)','Paste()', + 'Select(0u21C0)','Copy()', + 'Select(0u21CC)', + 'PasteWithOffset(0,160)', + 'RemoveOverlap()','Simplify()', + ], + + lgroup => [ + 'Select(0u23B0)','Copy()', + 'Select(0u27EE)','Paste()', + 'Select(0u23A9)','Copy()', + 'Select(0u27EE)', + 'PasteWithOffset(0,0)', + 'Scale(55,0,0)','RoundToInt()','Move(-38,250)', + 'RemoveOverlap()','Simplify()', + 'SetRBearing(-38,1)', + ], + + rgroup => [ + 'Select(0u23B1)','Copy()', + 'Select(0u27EF)','Paste()', + 'Select(0u23AD)','Copy()', + 'Select(0u27EF)', + 'PasteWithOffset(1,0)', + 'Scale(55,0,0)','RoundToInt()','Move(-38,250)', + 'RemoveOverlap()','Simplify()', + 'SetRBearing(-38,1)', + ], + + lmoustache => [ + 'Select(0u23AD)','Copy()', + 'Select(0u23B0)', + 'PasteWithOffset(0,0)', + 'Scale(55,0,0)','RoundToInt()','Move(-38,250)', + 'RemoveOverlap()','Simplify()', + 'SetRBearing(-38,1)', + ], + + rmoustache => [ + 'Select(0u23A9)','Copy()', + 'Select(0u23B1)', + 'PasteWithOffset(0,0)', + 'Scale(55,0,0)','RoundToInt()','Move(-38,250)', + 'RemoveOverlap()','Simplify()', + 'SetRBearing(-38,1)', + ], + + diacriticals => [ + 'Select(0uB0)', 'SetRBearing(-125,1)', # \degree + 'Select(0u20D7)','SetRBearing(153,1)', # \vec + ], + +}; + +$extra{'Main-Bold'} = { + cdots => [ + 'Select(0u22C5)','Copy()', + 'Select(0u22EF)','Paste()', + 'PasteWithOffset(488,0)', + 'PasteWithOffset(976,0)', + 'SetRBearing(976,1)', + ], + + ldots => [ + 'Select(0u2E)','Copy()', + 'Select(0u2026)','Paste()', + 'PasteWithOffset(488,0)', + 'PasteWithOffset(976,0)', + 'SetRBearing(976,1)', + ], + + vdots => [ + 'Select(0u2E)','Copy()', + 'Select(0u22EE)','Clear()', + 'PasteWithOffset(0,-30)', + 'PasteWithOffset(0,380)', + 'PasteWithOffset(0,780)', + 'SetRBearing(-681,1)', + ], + + ddots => [ + 'Select(0u2E)','Copy()', + 'Select(0u22F1)','Clear()', + 'PasteWithOffset(55,700)', + 'PasteWithOffset(502,400)', + 'PasteWithOffset(949,100)', + 'SetRBearing(323,1)', + ], + + spaceEn => [ + 'Select(0u2002)', + 'SetRBearing(500)', + ], + + spaceEm => [ + 'Select(0u2003)', + 'SetRBearing(999)', + ], + + space3 => [ + 'Select(0u2004)', + 'SetRBearing(333)', + ], + + space4 => [ + 'Select(0u2005)', + 'SetRBearing(250)', + ], + + space6 => [ + 'Select(0u2006)', + 'SetRBearing(167)', + ], + + thinspace => [ + 'Select(0u2009)', + 'SetRBearing(167)', + ], + + hairspace => [ + 'Select(0u200A)', + 'SetRBearing(83)', + ], + + cong => [ + 'Select(0u223C)','Copy()', + 'Select(0u2245)','Clear()', + 'PasteWithOffset(0,247)', + 'Select(0u3D)','Copy()', + 'Select(0u2245)', + 'PasteWithOffset(0,-136)', + 'SetWidth(894)', + ], + + bowtie => [ + 'Select(0u25B9)','Copy()', + 'Select(0u22C8)','Paste()', + 'Select(0u25C3)','Copy()', + 'Select(0u22C8)', + 'PasteWithOffset(425,0)', + 'SetRBearing(425,1)', + 'RemoveOverlap()', + ], + + models => [ + 'Select(0u2223)','Copy()', + 'Select(0u22A8)','Paste()', + 'Select(0u3D)','Copy()', + 'Select(0u22A8)', + 'PasteWithOffset(89,0)', + 'SetRBearing(655,1)', + 'RemoveOverlap()', + ], + + doteq => [ + 'Select(0u3D)','Copy()', + 'Select(0u2250)','Paste()', + 'Select(0u2E)','Copy()', + 'Select(0u2250)', + 'PasteWithOffset(288,550)', + ], + + not => [ + 'Select(0uE020)', + 'SetRBearing(894,1)', + ], + +# notin => [ +# 'Select(0u2208)','Copy()', +# 'Select(0u2209)','Paste()', +# 'Select(0u338)','Copy()', +# 'Select(0u2209)', +# 'PasteWithOffset(-63,0)', +# 'PasteWithOffset(831,0)', +# 'RemoveOverlap()', +# ], + +# noteq => [ +# 'Select(0u3D)','Copy()', +# 'Select(0u2260)','Paste()', +# 'Select(0u338)','Copy()', +# 'Select(0u2260)', +# 'PasteWithOffset(0,0)', +# 'PasteWithOffset(894,0)', +# 'RemoveOverlap()', +# ], + + longleftarrow => [ + 'Select(0u2190)','Copy()', + 'Select(0u27F5)','Paste()', + 'Select(0u2212)','Copy()', + 'Select(0u27F5)', + 'PasteWithOffset(944,0)', + 'SetRBearing(655,1)', + 'RemoveOverlap()','Simplify()', + ], + + Longleftarrow => [ + 'Select(0u21D0)','Copy()', + 'Select(0u27F8)','Paste()', + 'Select(0u3D)','Copy()', + 'Select(0u27F8)', + 'PasteWithOffset(975,0)', + 'SetRBearing(718,1)', + 'RemoveOverlap()','Simplify()', + ], + + longrightarrow => [ + 'Select(0u2212)','Copy()', + 'Select(0u27F6)','Paste()', + 'Select(0u2192)','Copy()', + 'Select(0u27F6)', + 'PasteWithOffset(688,0)', + 'SetRBearing(939,1)', + 'RemoveOverlap()','Simplify()', + ], + + Longrightarrow => [ + 'Select(0u3D)','Copy()', + 'Select(0u27F9)','Paste()', + 'Select(0u21D2)','Copy()', + 'Select(0u27F9)', + 'PasteWithOffset(720,0)', + 'SetRBearing(976,1)', + 'RemoveOverlap()','Simplify()', + ], + + leftrightarrow => [ + 'Select(0u2190)','Copy()', + 'Select(0u27F7)','Paste()', + 'Select(0u2192)','Copy()', + 'Select(0u27F7)', + 'PasteWithOffset(976,0)', + 'SetRBearing(976,1)', + 'RemoveOverlap()','Simplify()', + ], + + Leftrightarrow => [ + 'Select(0u21D0)','Copy()', + 'Select(0u27FA)','Paste()', + 'Select(0u21D2)','Copy()', + 'Select(0u27FA)', + 'PasteWithOffset(976,0)', + 'SetRBearing(976,1)', + 'RemoveOverlap()','Simplify()', + ], + + mapsto => [ + 'Select(0u2192)','Copy()', + 'Select(0u21A6)','Paste()', + 'Generate("otf/KaTeX_Main-Bold.otf")', + 'Open("pfa/cmbsy10.pfa")', + 'Select(0x37)','Copy()', + 'Open("otf/KaTeX_Main-Bold.otf")', + 'Select(0u21A6)', + 'PasteWithOffset(0,0)', + 'RemoveOverlap()','Simplify()', + ], + + xlongmapsto => [ + 'Select(0u27F6)','Copy()', + 'Select(0u27FC)','Paste()', + 'Generate("otf/KaTeX_Main-Bold.otf")', + 'Open("pfa/cmbsy10.pfa")', + 'Select(0x37)','Copy()', + 'Open("otf/KaTeX_Main-Bold.otf")', + 'Select(0u27FC)', + 'PasteWithOffset(0,0)', + 'RemoveOverlap()','Simplify()', + ], + + hookleftarrow => [ + 'Select(0u2190)','Copy()', + 'Select(0u21A9)','Paste()', + 'Generate("otf/KaTeX_Main-Bold.otf")', + 'Open("pfa/cmmib10.pfa")', + 'Select(0x2D)','Copy()', + 'Open("otf/KaTeX_Main-Bold.otf")', + 'Select(0u21A9)', + 'PasteWithOffset(965,0)', + 'SetRBearing(132,1)', + 'RemoveOverlap()','Simplify()', + ], + + hookrightarrow => [ + 'Generate("otf/KaTeX_Main-Bold.otf")', + 'Open("pfa/cmmib10.pfa")', + 'Select(0x2C)','Copy()', + 'Open("otf/KaTeX_Main-Bold.otf")', + 'Select(0u21AA)','Paste()', + 'Select(0u2192)','Copy()', + 'Select(0u21AA)', + 'PasteWithOffset(132,0)', + 'SetRBearing(963,1)', + 'RemoveOverlap()','Simplify()', + ], + + rightleftharpoons => [ + 'Select(0u21BD)','Copy()', + 'Select(0u21CC)','Paste()', + 'Select(0u21C0)','Copy()', + 'Select(0u21CC)', + 'PasteWithOffset(0,200)', + 'RemoveOverlap()','Simplify()', + ], + + hbar => [ + 'Select(0u2C9)','Copy()', + 'Select(0u210F)','PasteWithOffset(0,0)', + 'RemoveOverlap()','Simplify()', + ], + + angle => [ + 'Select(0u2220)','Copy()', + 'PasteWithOffset(0,10)', + 'PasteWithOffset(0,20)', + 'RemoveOverlap()','Simplify()', + 'PasteWithOffset(10,0)', + 'RemoveOverlap()','Simplify()', + ], + + diacriticals => [ + 'Select(0uB0)', 'SetRBearing(-147,1)', # \degree + 'Select(0u20D7)','SetRBearing(154,1)', # \vec + ], +}; + +$extra{'Main-Italic'} = { + diacriticals => [ + 'Select(0uB0)', 'SetRBearing(-160,1)', # \degree + ], +}; + +$extra{'Size1'} = { + iint => [ + 'Select(0u222B)', 'Copy()', + 'Select(0u222C)', 'Paste()', + 'PasteWithOffset(347,0)', + 'SetRBearing(347,1)', + ], + + iiint => [ + 'Select(0u222B)', 'Copy()', + 'Select(0u222D)', 'Paste()', + 'PasteWithOffset(347,0)', + 'PasteWithOffset(694,0)', + 'SetRBearing(694,1)', + ], +}; + +$extra{'Size2'} = { + iint => [ + 'Select(0u222B)', 'Copy()', + 'Select(0u222C)', 'Paste()', + 'PasteWithOffset(528,0)', + 'SetRBearing(528,1)', + ], + + iiint => [ + 'Select(0u222B)', 'Copy()', + 'Select(0u222D)', 'Paste()', + 'PasteWithOffset(528,0)', + 'PasteWithOffset(1036,0)', + 'SetRBearing(1036,1)', + ], +}; + +$extra{'Size4'} = { + braceext => [ + 'Open("lib/Extra.otf")', + 'Select(0u5F)','Copy()', + 'Open("otf/KaTeX_Size4-Regular.otf")', + 'Select(0uE154)','Paste()', + ], +}; + +$extra{"AMS"} = { + dashleftarrow => [ + 'Select(0u2190)', 'Copy()', + 'Select(0u21E0)', 'Paste()', + 'Select(0u2212)','Copy()', + 'Select(0u21E0)', + 'PasteWithOffset(417,0)', + 'PasteWithOffset(834,0)', + 'SetRBearing(834,1)', + ], + + dashrightarrow => [ + 'Select(0u2212)', 'Copy()', + 'Select(0u21E2)', 'Paste()', + 'PasteWithOffset(417,0)', + 'Select(0u2192)','Copy()', + 'Select(0u21E2)','PasteWithOffset(834,0)', + 'SetRBearing(834,1)', + ], +}; + +$extra{'Typewriter'} = { + space => [ + 'Select(0u20)','Clear()', + 'SetRBearing(525)', + ], + + spaceNB => [ + 'Select(0uA0)','Clear()', + 'SetRBearing(525)', + ], +}; + +$extra{"SansSerif-Regular"} = { + diacriticals => [ + 'Select(0uB0)', 'SetRBearing(-142,1)', # \degree + ], +}; + +$extra{"SansSerif-Italic"} = { + diacriticals => [ + 'Select(0uB0)', 'SetRBearing(-113,1)', # \degree + ], +}; + +$extra{"SansSerif-Bold"} = { + diacriticals => [ + 'Select(0uB0)', 'SetRBearing(-58,1)', # \degree + ], +}; + +######################################################################### + +foreach $cmfont (sort (keys %map)) { + print "Reading $cmfont...\n"; + foreach $mjfont (keys %{$map{$cmfont}}) { + $fontname = "KaTeX_$mjfont"; + $style = $fontname; $style =~ s/.*?(-|$)//; $style = "Regular" unless $style; + $normal = "Normal"; $normal = "Bold" if style =~ m/Bold/; + $family = $fontname; $family =~ s/-.*//; + $fontname = "$family-$style"; + $STYLE = $style; $STYLE = "Bold Italic" if $STYLE eq "BoldItalic"; + $otf = "otf/$fontname.otf"; + unless (defined($script{$mjfont})) { + open(SPACE,"lib/Space.ttx"); $lines = join("",); close(SPACE); + $lines =~ s/\*NAME\*/$family/g; $lines =~ s/\*WEIGHT\*/$style/g; + $lines =~ s/\*WEIGHT_S\*/$STYLE/g; $lines =~ s/\*NORMAL\*/$normal/g; + if ($style eq "Regular") {$lines =~ s/\* WEIGHT\*//g} else {$lines =~ s/\* WEIGHT\*/ $STYLE/g} + open(SPACE,">Space.ttx"); print SPACE $lines; close(SPACE); + `$TTX -f Space.ttx; mv Space.otf '$otf'`; unlink("Space.ttx"); + $script{$mjfont} = [ + 'Open("'.$otf.'")', + 'SetPanose([0,0,'.($style eq 'Bold' ? '8' : '0').',0,0,0,0,0,0,0])', + 'SetOS2Value("Weight",'.($style =~ m/Bold/ ? 700 : 400).')', + 'SetGasp(8,2,16,1,65535,3)', + 'Reencode("unicode")', + 'Generate("'.$otf.'")', + ]; + } + $script = $script{$mjfont}; + @remap = @{$map{$cmfont}{$mjfont}}; + while (defined($item = shift(@remap))) { + $remap = shift(@remap); + if ($cmfont =~ /^eu/) { + push(@$script,'Open("pfa/'.$cmfont.'.pfb")'); + } else { + push(@$script,'Open("pfa/'.$cmfont.'.pfa")'); + } + if (ref($item) eq "ARRAY") { + push(@$script,'Select('.sprintf("%d,%d",@$item).')'); + } else { + push(@$script,'Select('.$item.')'); + } + push(@$script,"Copy()",'Open("'.$otf.'")'); + if (ref($item) eq "ARRAY") { + push(@$script, + 'Select('.sprintf("0u%04x,0u%04x",$remap,$remap+($item->[1]-$item->[0])).')', + 'Paste()', + ); + } elsif (ref($remap) eq "ARRAY") { + push(@$script, + 'Select('.sprintf("0u%04x",$remap->[0]).')', + 'Paste()', + 'Move('.$remap->[1].','.$remap->[2].')', + ); + } else { + push(@$script,'Select('.sprintf("0u%04x",$remap).')','Paste()'); + } + push(@$script,'Generate("'.$otf.'")'); + } + } +} +print "\n"; + + +# +# Add extra characters by hand +# +foreach $font (keys %extra) { + foreach $char (sort(keys %{$extra{$font}})) { + push(@{$script{$font}},join(";\n",@{$extra{$font}{$char}}),""); + } +} + +# Cleanup temporary glyphs +push(@{$script{'Main-Regular'}}, + 'Select(0u23A9)', + 'Clear()', + 'Select(0u23AD)', + 'Clear()', +); + +# +# Write all scripts +# +foreach $font (sort keys %script) { + $family = $font; $family .= "-Regular" unless $family =~ m/-/; + print "KaTeX_$font\n"; + open(SCRIPT,">","ff/KaTeX_$family.ff"); + print SCRIPT join(";\n",@{$script{$font}},"", + 'SelectAll()','RoundToInt()', + 'Simplify()','AddExtrema()','Simplify()', + 'ClearHints()','AutoHint()','RoundToInt()', + 'Generate("otf/KaTeX_'.$family.'.otf")', + 'SelectAll()','AutoInstr()', + 'Generate("ttf/KaTeX_'.$family.'.ttf")'),"\n"; + close(SCRIPT); +} + +1; diff --git a/node_modules/katex/src/fonts/xbbold.mf b/node_modules/katex/src/fonts/xbbold.mf new file mode 100644 index 0000000..64a6683 --- /dev/null +++ b/node_modules/katex/src/fonts/xbbold.mf @@ -0,0 +1,182 @@ +%% filename: xbbold.mf +%% version: 2.2 +%% date: 1995/01/04 +%% +%% (katex-fonts) The line 69 is modified to prevent overflow +%% +%% American Mathematical Society +%% Technical Support +%% Publications Technical Group +%% 201 Charles Street +%% Providence, RI 02904 +%% USA +%% tel: (401) 455-4080 +%% (800) 321-4267 (USA and Canada only) +%% fax: (401) 331-3842 +%% email: tech-support@ams.org +%% +%% Copyright 1995, 2009 American Mathematical Society. +%% +%% This Font Software is licensed under the SIL Open Font License, +%% Version 1.1. This license is in the accompanying file OFL.txt, and +%% is also available with a FAQ at: http://scripts.sil.org/OFL. +%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% Changes of minimal parameters in outlined characters for version 2.1 +% done by Stefan Lindner, 18-April-1991 + +input xbbase; +%%mode_setup; %called by amsyb.mf; two calls confuse Metafont. NGB 15-OCT-1991 + +%%%%designsize:= font_size; % was 10pt#; +width#:= designsize; % was 10pt#; +unit#:= width#/18; +u#:= width#/54; +smallu#:= width#/162; +ascender#:= 37/3*unit#; +cap#:= 37/3*unit#; +number#:= 36/3*unit#; +xheight#:= 25/3*unit#; +descender#:= 12/4*unit#; +define_whole_vertical_pixels + (width,unit,u,smallu,ascender,cap,number,xheight,descender); +wpix(1.90u) (linethickness); +wpix(0.65u) (Sover_bot); +wpix(1.00u) (Aapex,Napex,Vapex,Wapex,Cover,Gover,Oover,Sover_top,Uover); +wpix(9.00u) (Uthin_bracket); +wpix(8.00u) (Kthin_diag_bracket,Xthin_diag_bracket,Ythin_diag_bracket); +wpix(7.00u) (k_thin_diag); +wpix(6.00u) (c_thin_stem_bracket); +wpix(5.00u) (c_thick_stem_bracket,c_inner_bracket,lc_thick_stem_bracket); +wpix(4.00u) (c_round_bracket); +adjpix(1.35u) (serif_thickness); +adjpix(1.30u) (Emid_tip,inbeak); +adjpix(1.50u) (Atip,Btopthin,Bmidthin,Ebot_tip,Ltip,Mapex, + Ntip,Ttip,Vtip,Wtip,Ztip,outbeak); +adjpix(1.65u) (Bbotthin,Gbotthin,Stopthin); +adjpix(1.75u) (Dtopthin,Ebotarm,Lthin,Tthin); +adjpix(1.80u) (Abar,Ctopthin,Dbotthin,Gtopthin,Jbotthin,Pmidarm,Sbotthin); +adjpix(1.90u) (Emidarm,Etoparm,Othin,Pthin,Rthin,Ydiag,Zthin); +adjpix(2.00u) (kthin,Mthin_diag,Wleftthin); +adjpix(2.10u) (Ctip); +adjpix(2.25u) (Athin,Kthin,Mthin_vert,Nthin,Uthin,Vthin,Wrightthin,Xthin); +adjpix(2.50u) (Hbar); +adjpix(2.60u) (Cbotthin); + + +%%%% Begin of changes for version 2.1 +%(katex-fonts) Originally was pixels_per_inch*designsize < 1500: +if pixels_per_inch < 1500/designsize: + if pixels_per_inch*designsize < 1000: + if pixels_per_inch*designsize < 800: + if pixels_per_inch*designsize < 700: + minadjpix(0)(8.80u) (stem); + minadjpix(0)(6.80u) (kdiag); + minadjpix(0)(7.40u) (kstem); + minadjpix(0)(7.80u) (Jbulb,Mdiag); + minadjpix(0)(8.20u) (Kdiag); + minadjpix(0)(8.30u) (Gstem,Mstem); + minadjpix(0)(8.60u) (Lstem,Ustem,Ythick_diag); + minadjpix(0)(8.50u) (Bstem,Estem,Fstem,Ndiag,Rdiag,Xdiag,Zdiag); + minadjpix(0)(8.90u) (Btopcurve); + minadjpix(1)(9.30u) (Bbotcurve,Pcurve,Rcurve); + minadjpix(1)(9.50u) (Ccurve,Dcurve,Gcurve,Ocurve); + else: + minadjpix(1)(8.80u) (stem); + minadjpix(1)(6.80u) (kdiag); + minadjpix(1)(7.40u) (kstem); + minadjpix(1)(7.80u) (Jbulb,Mdiag); + minadjpix(1)(8.20u) (Kdiag); + minadjpix(1)(8.30u) (Gstem,Mstem); + minadjpix(1)(8.60u) (Lstem,Ustem,Ythick_diag); + minadjpix(1)(8.50u) (Bstem,Estem,Fstem,Ndiag,Rdiag,Xdiag,Zdiag); + minadjpix(1)(8.90u) (Btopcurve); + minadjpix(2)(9.30u) (Bbotcurve,Pcurve,Rcurve); + minadjpix(2)(9.50u) (Ccurve,Dcurve,Gcurve,Ocurve); + fi + else: + adjpix(3.0u) (Mapex); + minadjpix(1)(8.80u) (stem); + minadjpix(2)(6.80u) (kdiag); + minadjpix(2)(7.40u) (kstem); + minadjpix(2)(7.80u) (Jbulb); + minadjpix(1)(6.00u) (Mdiag); + minadjpix(2)(8.20u) (Kdiag); + minadjpix(2)(8.30u) (Gstem) + minadjpix(2)(8.30u) (Mstem); + minadjpix(2)(8.60u) (Lstem,Ustem,Ythick_diag); + minadjpix(2)(8.50u) (Bstem,Ndiag,Rdiag,Xdiag,Zdiag); + minadjpix(1)(8.50u) (Estem, Fstem); + minadjpix(2)(8.90u) (Btopcurve); + minadjpix(3)(9.30u) (Bbotcurve,Pcurve,Rcurve); + minadjpix(3)(9.50u) (Ccurve,Dcurve,Gcurve,Ocurve); + fi + else: + adjpix(3.0u) (Mapex); + minadjpix(2)(8.80u) (stem); + minadjpix(3)(6.80u) (kdiag); + minadjpix(3)(7.40u) (kstem); + minadjpix(3)(7.80u) (Jbulb); + minadjpix(1)(5.00u) (Mdiag); + minadjpix(3)(8.20u) (Kdiag); + minadjpix(3)(8.30u) (Gstem); + minadjpix(2)(8.30u) (Mstem); + minadjpix(3)(8.60u) (Lstem,Ustem,Ythick_diag); + minadjpix(3)(8.50u) (Estem,Fstem,Ndiag,Rdiag,Xdiag,Zdiag); + minadjpix(2)(8.50u) (Bstem); + minadjpix(3)(8.90u) (Btopcurve); + minadjpix(3)(9.30u) (Bbotcurve,Pcurve,Rcurve); + minadjpix(3)(9.50u) (Ccurve,Dcurve,Gcurve,Ocurve) + fi +else: + minadjpix(4)(8.80u) (stem); + minadjpix(4)(6.80u) (kdiag); + minadjpix(4)(7.40u) (kstem); + minadjpix(4)(7.80u) (Jbulb,Mdiag); + minadjpix(4)(8.20u) (Kdiag); + minadjpix(4)(8.30u) (Gstem,Mstem); + minadjpix(4)(8.60u) (Lstem,Ustem,Ythick_diag); + minadjpix(4)(8.50u) (Bstem,Estem,Fstem,Ndiag,Rdiag,Xdiag,Zdiag); + minadjpix(4)(8.90u) (Btopcurve); + minadjpix(5)(9.30u) (Bbotcurve,Pcurve,Rcurve); + minadjpix(5)(9.50u) (Ccurve,Dcurve,Gcurve,Ocurve) +fi; +%%%% end of changes for version 2.1 + +boolean lowres; lowres:=width<50; +highres_lowres(pullin) (.85)(1); % Emidarm +highres_lowres(pulleven) (1)(1.3); % Etoparm,Tarms,Zarms +highres_lowres(pullout) (1.1)(1); % Ebotarm,Lbotarm +highres_lowres(bracket0) (.0)(0); % Ntopleft +highres_lowres(bracket3) (.3)(0); % Nthinstems +highres_lowres(bracket01) (.0)(.1); % Uthin +highres_lowres(bracket32) (.3)(.2); % Vstems +highres_lowres(bracket4) (.4)(0); % P-all,R-all,I-all,F-all +highres_lowres(bracket42) (.4)(.2); % Xdiag + +bool(ctrls):=false; +entasis:=inlimit(0)(0,1); +serif_constant_amt:=0pt; +join_radius:=1; +bool(softpath):=true; + +c_thick_stem_bracket:=min(.5cap-eps,c_thick_stem_bracket); +rulepen:=pensquare scaled 1; +extra_beginchar:=extra_beginchar&"save t,p,ref; path p[],p[]',p[]'',ref[];"; +extra_beginchar:=extra_beginchar&"pickup pencircle scaled linethickness;"; + +for x:="R": + wanted[byte x]:=true; endfor % test these characters + let iff=always_iff; % tests all chars in the file + +font_normal_space .3width#; % TeX fontdimen 2 normal word space +font_normal_stretch .15width#; % TeX fontdimen 3 interword stretch +font_normal_shrink .1width#; % TeX fontdimen 4 interword shrink +font_x_height xheight#; % Tex fontdinem 5 for accents +font_quad width#; % TeX fontdimen 6 quad width +font_extra_space .1width#; % TeX fontdimen 7 extra space(period) + + +input xbcaps +bye % changed from "end" 26 Aug 93; bnb diff --git a/node_modules/katex/src/functions.ts b/node_modules/katex/src/functions.ts new file mode 100644 index 0000000..bb0a155 --- /dev/null +++ b/node_modules/katex/src/functions.ts @@ -0,0 +1,54 @@ +/** Include this to ensure that all functions are defined. */ +import {_functions} from "./defineFunction"; + +const functions = _functions; +export default functions; + +// TODO(kevinb): have functions return an object and call defineFunction with +// that object in this file instead of relying on side-effects. +import "./functions/accent"; +import "./functions/accentunder"; +import "./functions/arrow"; +import "./functions/pmb"; +import "./environments/cd"; +import "./functions/char"; +import "./functions/color"; +import "./functions/cr"; +import "./functions/def"; +import "./functions/delimsizing"; +import "./functions/enclose"; +import "./functions/environment"; +import "./functions/font"; +import "./functions/genfrac"; +import "./functions/horizBrace"; +import "./functions/href"; +import "./functions/hbox"; +import "./functions/html"; +import "./functions/htmlmathml"; +import "./functions/includegraphics"; +import "./functions/kern"; +import "./functions/lap"; +import "./functions/math"; +import "./functions/mathchoice"; +import "./functions/mclass"; +import "./functions/op"; +import "./functions/operatorname"; +import "./functions/ordgroup"; +import "./functions/overline"; +import "./functions/phantom"; +import "./functions/raisebox"; +import "./functions/relax"; +import "./functions/rule"; +import "./functions/sizing"; +import "./functions/smash"; +import "./functions/sqrt"; +import "./functions/styling"; +import "./functions/supsub"; +import "./functions/symbolsOp"; +import "./functions/symbolsOrd"; +import "./functions/symbolsSpacing"; +import "./functions/tag"; +import "./functions/text"; +import "./functions/underline"; +import "./functions/vcenter"; +import "./functions/verb"; diff --git a/node_modules/katex/src/functions/accent.ts b/node_modules/katex/src/functions/accent.ts new file mode 100644 index 0000000..e393e19 --- /dev/null +++ b/node_modules/katex/src/functions/accent.ts @@ -0,0 +1,282 @@ +import defineFunction, {normalizeArgument} from "../defineFunction"; +import {makeOrd, makeSpan, makeVList, staticSvg, svgData} from "../buildCommon"; +import {isCharacterBox} from "../utils"; +import {MathNode} from "../mathMLTree"; +import {stretchyMathML, stretchySvg} from "../stretchy"; +import {assertNodeType} from "../parseNode"; +import {assertSpan, assertSymbolDomNode, hasHtmlDomChildren, SymbolNode} from "../domTree"; +import {makeEm} from "../units"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; + +import type {HtmlBuilderSupSub, MathMLBuilder} from "../defineFunction"; +import type {HtmlDomNode} from "../domTree"; +import type {AnyParseNode, ParseNode} from "../types/nodes"; + +const getBaseSymbol = (group: HtmlDomNode): SymbolNode | undefined => { + if (group instanceof SymbolNode) { + return group; + } + if (hasHtmlDomChildren(group) && group.children.length === 1) { + return getBaseSymbol(group.children[0]); + } +}; + +// NOTE: Unlike most `htmlBuilder`s, this one handles not only "accent", but +// also "supsub" since an accent can affect super/subscripting. +export const htmlBuilder: HtmlBuilderSupSub<"accent"> = (grp, options) => { + // Accents are handled in the TeXbook pg. 443, rule 12. + let base: AnyParseNode; + let group: ParseNode<"accent">; + + let supSubGroup; + if (grp && grp.type === "supsub") { + // If our base is a character box, and we have superscripts and + // subscripts, the supsub will defer to us. In particular, we want + // to attach the superscripts and subscripts to the inner body (so + // that the position of the superscripts and subscripts won't be + // affected by the height of the accent). We accomplish this by + // sticking the base of the accent into the base of the supsub, and + // rendering that, while keeping track of where the accent is. + + // The real accent group is the base of the supsub group + group = assertNodeType(grp.base, "accent"); + // The character box is the base of the accent group + base = group.base; + // Stick the character box into the base of the supsub group + grp.base = base; + + // Rerender the supsub group with its new base, and store that + // result. + supSubGroup = assertSpan(html.buildGroup(grp, options)); + + // reset original base + grp.base = group; + } else { + group = assertNodeType(grp, "accent"); + base = group.base; + } + + // Build the base group + const body = html.buildGroup(base, options.havingCrampedStyle()); + + // Does the accent need to shift for the skew of a character? + const mustShift = group.isShifty && isCharacterBox(base); + + // Calculate the skew of the accent. This is based on the line "If the + // nucleus is not a single character, let s = 0; otherwise set s to the + // kern amount for the nucleus followed by the \skewchar of its font." + // Note that our skew metrics are just the kern between each character + // and the skewchar. + let skew = 0; + if (mustShift) { + // Read the skew from the rendered base symbol. + // This preserves font metrics from font wrappers like \mathbb. + skew = getBaseSymbol(body)?.skew ?? 0; + } + + const accentBelow = group.label === "\\c"; + + // calculate the amount of space between the body and the accent + let clearance = accentBelow + ? body.height + body.depth + : Math.min( + body.height, + options.fontMetrics().xHeight); + + // Build the accent + let accentBody; + if (!group.isStretchy) { + let accent; + let width: number; + if (group.label === "\\vec") { + // Before version 0.9, \vec used the combining font glyph U+20D7. + // But browsers, especially Safari, are not consistent in how they + // render combining characters when not preceded by a character. + // So now we use an SVG. + // If Safari reforms, we should consider reverting to the glyph. + accent = staticSvg("vec", options); + width = svgData.vec[1]; + } else { + accent = makeOrd({type: "textord", mode: group.mode, text: group.label}, + options); + accent = assertSymbolDomNode(accent); + // Remove the italic correction of the accent, because it only serves to + // shift the accent over to a place we don't want. + accent.italic = 0; + width = accent.width; + if (accentBelow) { + clearance += accent.depth; + } + } + + accentBody = makeSpan(["accent-body"], [accent]); + + // "Full" accents expand the width of the resulting symbol to be + // at least the width of the accent, and overlap directly onto the + // character without any vertical offset. + const accentFull = (group.label === "\\textcircled"); + if (accentFull) { + accentBody.classes.push('accent-full'); + clearance = body.height; + } + + // Shift the accent over by the skew. + let left = skew; + + // CSS defines `.katex .accent .accent-body:not(.accent-full) { width: 0 }` + // so that the accent doesn't contribute to the bounding box. + // We need to shift the character by its width (effectively half + // its width) to compensate. + if (!accentFull) { + left -= width / 2; + } + + accentBody.style.left = makeEm(left); + + // \textcircled uses the \bigcirc glyph, so it needs some + // vertical adjustment to match LaTeX. + if (group.label === "\\textcircled") { + accentBody.style.top = ".2em"; + } + + accentBody = makeVList({ + positionType: "firstBaseline", + children: [ + {type: "elem", elem: body}, + {type: "kern", size: -clearance}, + {type: "elem", elem: accentBody}, + ], + }, options); + + } else { + accentBody = stretchySvg(group, options); + + accentBody = makeVList({ + positionType: "firstBaseline", + children: [ + {type: "elem", elem: body}, + { + type: "elem", + elem: accentBody, + wrapperClasses: ["svg-align"], + wrapperStyle: skew > 0 + ? { + width: `calc(100% - ${makeEm(2 * skew)})`, + marginLeft: makeEm(2 * skew), + } + : undefined, + }, + ], + }, options); + } + + const accentWrap = + makeSpan(["mord", "accent"], [accentBody], options); + + if (supSubGroup) { + // Here, we replace the "base" child of the supsub with our newly + // generated accent. + supSubGroup.children[0] = accentWrap; + + // Since we don't rerun the height calculation after replacing the + // accent, we manually recalculate height. + supSubGroup.height = Math.max(accentWrap.height, supSubGroup.height); + + // Accents should always be ords, even when their innards are not. + supSubGroup.classes[0] = "mord"; + + return supSubGroup; + } else { + return accentWrap; + } +}; + +const mathmlBuilder: MathMLBuilder<"accent"> = (group, options) => { + const accentNode = + group.isStretchy ? + stretchyMathML(group.label) : + new MathNode("mo", [mml.makeText(group.label, group.mode)]); + + const node = new MathNode( + "mover", + [mml.buildGroup(group.base, options), accentNode]); + + node.setAttribute("accent", "true"); + + return node; +}; + +const NON_STRETCHY_ACCENT_REGEX = new RegExp([ + "\\acute", "\\grave", "\\ddot", "\\tilde", "\\bar", "\\breve", + "\\check", "\\hat", "\\vec", "\\dot", "\\mathring", +].map(accent => `\\${accent}`).join("|")); + +// Accents +defineFunction({ + type: "accent", + names: [ + "\\acute", "\\grave", "\\ddot", "\\tilde", "\\bar", "\\breve", + "\\check", "\\hat", "\\vec", "\\dot", "\\mathring", "\\widecheck", + "\\widehat", "\\widetilde", "\\overrightarrow", "\\overleftarrow", + "\\Overrightarrow", "\\overleftrightarrow", "\\overgroup", + "\\overlinesegment", "\\overleftharpoon", "\\overrightharpoon", + ], + numArgs: 1, + + handler: (context, args) => { + const base = normalizeArgument(args[0]); + + const isStretchy = !NON_STRETCHY_ACCENT_REGEX.test(context.funcName); + const isShifty = !isStretchy || + context.funcName === "\\widehat" || + context.funcName === "\\widetilde" || + context.funcName === "\\widecheck"; + + return { + type: "accent", + mode: context.parser.mode, + label: context.funcName, + isStretchy: isStretchy, + isShifty: isShifty, + base: base, + }; + }, + + htmlBuilder, + mathmlBuilder, +}); + +// Text-mode accents +defineFunction({ + type: "accent", + names: [ + "\\'", "\\`", "\\^", "\\~", "\\=", "\\u", "\\.", '\\"', + "\\c", "\\r", "\\H", "\\v", "\\textcircled", + ], + numArgs: 1, + allowedInText: true, + allowedInMath: true, // unless in strict mode + argTypes: ["primitive"], + + handler: (context, args) => { + const base = args[0]; + let mode = context.parser.mode; + + if (mode === "math") { + context.parser.settings.reportNonstrict("mathVsTextAccents", + `LaTeX's accent ${context.funcName} works only in text mode`); + mode = "text"; + } + + return { + type: "accent", + mode: mode, + label: context.funcName, + isStretchy: false, + isShifty: true, + base: base, + }; + }, +}); diff --git a/node_modules/katex/src/functions/accentunder.ts b/node_modules/katex/src/functions/accentunder.ts new file mode 100644 index 0000000..eae6c71 --- /dev/null +++ b/node_modules/katex/src/functions/accentunder.ts @@ -0,0 +1,59 @@ +// Horizontal overlap functions +import defineFunction from "../defineFunction"; +import {makeSpan, makeVList} from "../buildCommon"; +import {MathNode} from "../mathMLTree"; +import {stretchyMathML, stretchySvg} from "../stretchy"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; + +import type {ParseNode} from "../types/nodes"; + +defineFunction({ + type: "accentUnder", + names: [ + "\\underleftarrow", "\\underrightarrow", "\\underleftrightarrow", + "\\undergroup", "\\underlinesegment", "\\utilde", + ], + numArgs: 1, + + handler: ({parser, funcName}, args) => { + const base = args[0]; + return { + type: "accentUnder", + mode: parser.mode, + label: funcName, + base: base, + }; + }, + + htmlBuilder: (group: ParseNode<"accentUnder">, options) => { + // Treat under accents much like underlines. + const innerGroup = html.buildGroup(group.base, options); + + const accentBody = stretchySvg(group, options); + const kern = group.label === "\\utilde" ? 0.12 : 0; + + // Generate the vlist, with the appropriate kerns + const vlist = makeVList({ + positionType: "top", + positionData: innerGroup.height, + children: [ + {type: "elem", elem: accentBody, wrapperClasses: ["svg-align"]}, + {type: "kern", size: kern}, + {type: "elem", elem: innerGroup}, + ], + }, options); + + return makeSpan(["mord", "accentunder"], [vlist], options); + }, + mathmlBuilder: (group, options) => { + const accentNode = stretchyMathML(group.label); + const node = new MathNode( + "munder", + [mml.buildGroup(group.base, options), accentNode] + ); + node.setAttribute("accentunder", "true"); + return node; + }, +}); diff --git a/node_modules/katex/src/functions/arrow.ts b/node_modules/katex/src/functions/arrow.ts new file mode 100644 index 0000000..c63a623 --- /dev/null +++ b/node_modules/katex/src/functions/arrow.ts @@ -0,0 +1,141 @@ +import defineFunction from "../defineFunction"; +import {makeSpan, makeVList, wrapFragment} from "../buildCommon"; +import {MathNode} from "../mathMLTree"; +import {stretchyMathML, stretchySvg} from "../stretchy"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; + +import type {ParseNode} from "../types/nodes"; +import type {MathDomNode} from "../mathMLTree"; + +// Helper function +const paddedNode = (group?: MathDomNode | null | undefined) => { + const node = new MathNode("mpadded", group ? [group] : []); + node.setAttribute("width", "+0.6em"); + node.setAttribute("lspace", "0.3em"); + return node; +}; + +// Stretchy arrows with an optional argument +defineFunction({ + type: "xArrow", + names: [ + "\\xleftarrow", "\\xrightarrow", "\\xLeftarrow", "\\xRightarrow", + "\\xleftrightarrow", "\\xLeftrightarrow", "\\xhookleftarrow", + "\\xhookrightarrow", "\\xmapsto", "\\xrightharpoondown", + "\\xrightharpoonup", "\\xleftharpoondown", "\\xleftharpoonup", + "\\xrightleftharpoons", "\\xleftrightharpoons", "\\xlongequal", + "\\xtwoheadrightarrow", "\\xtwoheadleftarrow", "\\xtofrom", + // The next 3 functions are here to support the mhchem extension. + // Direct use of these functions is discouraged and may break someday. + "\\xrightleftarrows", "\\xrightequilibrium", "\\xleftequilibrium", + // The next 3 functions are here only to support the {CD} environment. + "\\\\cdrightarrow", "\\\\cdleftarrow", "\\\\cdlongequal", + ], + numArgs: 1, + numOptionalArgs: 1, + + handler({parser, funcName}, args, optArgs) { + return { + type: "xArrow", + mode: parser.mode, + label: funcName, + body: args[0], + below: optArgs[0], + }; + }, + + htmlBuilder(group: ParseNode<"xArrow">, options) { + const style = options.style; + + // Build the argument groups in the appropriate style. + // Ref: amsmath.dtx: \hbox{$\scriptstyle\mkern#3mu{#6}\mkern#4mu$}% + + // Some groups can return document fragments. Handle those by wrapping + // them in a span. + let newOptions = options.havingStyle(style.sup()); + const upperGroup = wrapFragment( + html.buildGroup(group.body, newOptions, options), options); + const arrowPrefix = group.label.slice(0, 2) === "\\x" ? "x" : "cd"; + upperGroup.classes.push(arrowPrefix + "-arrow-pad"); + + let lowerGroup; + if (group.below) { + // Build the lower group + newOptions = options.havingStyle(style.sub()); + lowerGroup = wrapFragment( + html.buildGroup(group.below, newOptions, options), options); + lowerGroup.classes.push(arrowPrefix + "-arrow-pad"); + } + + const arrowBody = stretchySvg(group, options); + + // Re shift: Note that stretchySvg returned arrowBody.depth = 0. + // The point we want on the math axis is at 0.5 * arrowBody.height. + const arrowShift = -options.fontMetrics().axisHeight + + 0.5 * arrowBody.height; + // 2 mu kern. Ref: amsmath.dtx: #7\if0#2\else\mkern#2mu\fi + let upperShift = -options.fontMetrics().axisHeight + - 0.5 * arrowBody.height - 0.111; // 0.111 em = 2 mu + if (upperGroup.depth > 0.25 || group.label === "\\xleftequilibrium") { + upperShift -= upperGroup.depth; // shift up if depth encroaches + } + + // Generate the vlist + let vlist; + if (lowerGroup) { + const lowerShift = -options.fontMetrics().axisHeight + + lowerGroup.height + 0.5 * arrowBody.height + + 0.111; + vlist = makeVList({ + positionType: "individualShift", + children: [ + {type: "elem", elem: upperGroup, shift: upperShift}, + {type: "elem", elem: arrowBody, shift: arrowShift, + wrapperClasses: ["svg-align"]}, + {type: "elem", elem: lowerGroup, shift: lowerShift}, + ], + }, options); + } else { + vlist = makeVList({ + positionType: "individualShift", + children: [ + {type: "elem", elem: upperGroup, shift: upperShift}, + {type: "elem", elem: arrowBody, shift: arrowShift, + wrapperClasses: ["svg-align"]}, + ], + }, options); + } + + return makeSpan(["mrel", "x-arrow"], [vlist], options); + }, + mathmlBuilder(group, options) { + const arrowNode = stretchyMathML(group.label); + arrowNode.setAttribute( + "minsize", group.label.charAt(0) === "x" ? "1.75em" : "3.0em" + ); + let node; + + if (group.body) { + const upperNode = paddedNode(mml.buildGroup(group.body, options)); + if (group.below) { + const lowerNode = paddedNode(mml.buildGroup(group.below, options)); + node = new MathNode( + "munderover", [arrowNode, lowerNode, upperNode] + ); + } else { + node = new MathNode("mover", [arrowNode, upperNode]); + } + } else if (group.below) { + const lowerNode = paddedNode(mml.buildGroup(group.below, options)); + node = new MathNode("munder", [arrowNode, lowerNode]); + } else { + // This should never happen. + // Parser.js throws an error if there is no argument. + node = paddedNode(); + node = new MathNode("mover", [arrowNode, node]); + } + return node; + }, +}); diff --git a/node_modules/katex/src/functions/char.ts b/node_modules/katex/src/functions/char.ts new file mode 100644 index 0000000..34697f5 --- /dev/null +++ b/node_modules/katex/src/functions/char.ts @@ -0,0 +1,43 @@ +import defineFunction from "../defineFunction"; +import ParseError from "../ParseError"; +import {assertNodeType} from "../parseNode"; + +// \@char is an internal function that takes a grouped decimal argument like +// {123} and converts into symbol with code 123. It is used by the *macro* +// \char defined in macros.js. +defineFunction({ + type: "textord", + names: ["\\@char"], + numArgs: 1, + allowedInText: true, + + handler({parser}, args) { + const arg = assertNodeType(args[0], "ordgroup"); + const group = arg.body; + let number = ""; + for (let i = 0; i < group.length; i++) { + const node = assertNodeType(group[i], "textord"); + number += node.text; + } + let code = parseInt(number); + let text; + if (isNaN(code)) { + throw new ParseError(`\\@char has non-numeric argument ${number}`); + // If we drop IE support, the following code could be replaced with + // text = String.fromCodePoint(code) + } else if (code < 0 || code >= 0x10ffff) { + throw new ParseError(`\\@char with invalid code point ${number}`); + } else if (code <= 0xffff) { + text = String.fromCharCode(code); + } else { // Astral code point; split into surrogate halves + code -= 0x10000; + text = String.fromCharCode((code >> 10) + 0xd800, + (code & 0x3ff) + 0xdc00); + } + return { + type: "textord", + mode: parser.mode, + text: text, + }; + }, +}); diff --git a/node_modules/katex/src/functions/color.ts b/node_modules/katex/src/functions/color.ts new file mode 100644 index 0000000..90096fc --- /dev/null +++ b/node_modules/katex/src/functions/color.ts @@ -0,0 +1,84 @@ +import defineFunction, {ordargument} from "../defineFunction"; +import {makeFragment} from "../buildCommon"; +import {MathNode} from "../mathMLTree"; +import {assertNodeType} from "../parseNode"; +import type {AnyParseNode} from "../types/nodes"; +import type {HtmlBuilder, MathMLBuilder} from "../defineFunction"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; + +const htmlBuilder: HtmlBuilder<"color"> = (group, options) => { + const elements = html.buildExpression( + group.body, + options.withColor(group.color), + false + ); + + // \color isn't supposed to affect the type of the elements it contains. + // To accomplish this, we wrap the results in a fragment, so the inner + // elements will be able to directly interact with their neighbors. For + // example, `\color{red}{2 +} 3` has the same spacing as `2 + 3` + return makeFragment(elements); +}; + +const mathmlBuilder: MathMLBuilder<"color"> = (group, options) => { + const inner = mml.buildExpression(group.body, + options.withColor(group.color)); + + const node = new MathNode("mstyle", inner); + + node.setAttribute("mathcolor", group.color); + + return node; +}; + +defineFunction({ + type: "color", + names: ["\\textcolor"], + numArgs: 2, + allowedInText: true, + argTypes: ["color", "original"], + + handler({parser}, args) { + const color = assertNodeType(args[0], "color-token").color; + const body = args[1]; + return { + type: "color", + mode: parser.mode, + color, + body: (ordargument(body) as AnyParseNode[]), + }; + }, + + htmlBuilder, + mathmlBuilder, +}); + +defineFunction({ + type: "color", + names: ["\\color"], + numArgs: 1, + allowedInText: true, + argTypes: ["color"], + + handler({parser, breakOnTokenText}, args) { + const color = assertNodeType(args[0], "color-token").color; + + // Set macro \current@color in current namespace to store the current + // color, mimicking the behavior of color.sty. + // This is currently used just to correctly color a \right + // that follows a \color command. + parser.gullet.macros.set("\\current@color", color); + + // Parse out the implicit body that should be colored. + const body: AnyParseNode[] = parser.parseExpression(true, breakOnTokenText); + + return { + type: "color", + mode: parser.mode, + color, + body, + }; + }, +}); diff --git a/node_modules/katex/src/functions/cr.ts b/node_modules/katex/src/functions/cr.ts new file mode 100644 index 0000000..bf79b20 --- /dev/null +++ b/node_modules/katex/src/functions/cr.ts @@ -0,0 +1,58 @@ +// Row breaks within tabular environments, and line breaks at top level + +import defineFunction from "../defineFunction"; +import {makeSpan} from "../buildCommon"; +import {MathNode} from "../mathMLTree"; +import {calculateSize, makeEm} from "../units"; +import {assertNodeType} from "../parseNode"; + +// \DeclareRobustCommand\\{...\@xnewline} +defineFunction({ + type: "cr", + names: ["\\\\"], + numArgs: 0, + numOptionalArgs: 0, + allowedInText: true, + + handler({parser}, args, optArgs) { + const size = parser.gullet.future().text === "[" ? + parser.parseSizeGroup(true) : null; + const newLine = !parser.settings.displayMode || + !parser.settings.useStrictBehavior( + "newLineInDisplayMode", "In LaTeX, \\\\ or \\newline " + + "does nothing in display mode"); + return { + type: "cr", + mode: parser.mode, + newLine, + size: size && assertNodeType(size, "size").value, + }; + }, + + // The following builders are called only at the top level, + // not within tabular/array environments. + + htmlBuilder(group, options) { + const span = makeSpan(["mspace"], [], options); + if (group.newLine) { + span.classes.push("newline"); + if (group.size) { + span.style.marginTop = + makeEm(calculateSize(group.size, options)); + } + } + return span; + }, + + mathmlBuilder(group, options) { + const node = new MathNode("mspace"); + if (group.newLine) { + node.setAttribute("linebreak", "newline"); + if (group.size) { + node.setAttribute("height", + makeEm(calculateSize(group.size, options))); + } + } + return node; + }, +}); diff --git a/node_modules/katex/src/functions/def.ts b/node_modules/katex/src/functions/def.ts new file mode 100644 index 0000000..54c1f6a --- /dev/null +++ b/node_modules/katex/src/functions/def.ts @@ -0,0 +1,208 @@ +import defineFunction from "../defineFunction"; +import ParseError from "../ParseError"; +import {assertNodeType} from "../parseNode"; +import {Token} from "../Token"; + +import type Parser from "../Parser"; + +const globalMap: Record = { + "\\global": "\\global", + "\\long": "\\\\globallong", + "\\\\globallong": "\\\\globallong", + "\\def": "\\gdef", + "\\gdef": "\\gdef", + "\\edef": "\\xdef", + "\\xdef": "\\xdef", + "\\let": "\\\\globallet", + "\\futurelet": "\\\\globalfuture", +}; + +const checkControlSequence = (tok: Token): string => { + const name = tok.text; + if (/^(?:[\\{}$&#^_]|EOF)$/.test(name)) { + throw new ParseError("Expected a control sequence", tok); + } + return name; +}; + +const getRHS = (parser: Parser): Token => { + let tok = parser.gullet.popToken(); + if (tok.text === "=") { // consume optional equals + tok = parser.gullet.popToken(); + if (tok.text === " ") { // consume one optional space + tok = parser.gullet.popToken(); + } + } + return tok; +}; + +const letCommand = (parser: Parser, name: string, tok: Token, global: boolean) => { + let macro = parser.gullet.macros.get(tok.text); + if (macro == null) { + // don't expand it later even if a macro with the same name is defined + // e.g., \let\foo=\frac \def\frac{\relax} \frac12 + tok.noexpand = true; + macro = { + tokens: [tok], + numArgs: 0, + // reproduce the same behavior in expansion + unexpandable: !parser.gullet.isExpandable(tok.text), + }; + } + parser.gullet.macros.set(name, macro, global); +}; + +// -> | +// -> |\global +// -> | +// -> \global|\long|\outer +defineFunction({ + type: "internal", + names: [ + "\\global", "\\long", + "\\\\globallong", // can’t be entered directly + ], + numArgs: 0, + allowedInText: true, + + handler({parser, funcName}) { + parser.consumeSpaces(); + const token = parser.fetch(); + if (globalMap[token.text]) { + // KaTeX doesn't have \par, so ignore \long + if (funcName === "\\global" || funcName === "\\\\globallong") { + token.text = globalMap[token.text]; + } + return assertNodeType(parser.parseFunction(), "internal"); + } + throw new ParseError(`Invalid token after macro prefix`, token); + }, +}); + +// Basic support for macro definitions: \def, \gdef, \edef, \xdef +// -> +// -> \def|\gdef|\edef|\xdef +// -> +defineFunction({ + type: "internal", + names: ["\\def", "\\gdef", "\\edef", "\\xdef"], + numArgs: 0, + allowedInText: true, + primitive: true, + + handler({parser, funcName}) { + let tok = parser.gullet.popToken(); + const name = tok.text; + if (/^(?:[\\{}$&#^_]|EOF)$/.test(name)) { + throw new ParseError("Expected a control sequence", tok); + } + + let numArgs = 0; + let insert: Token | undefined; + const delimiters: string[][] = [[]]; + // contains no braces + while (parser.gullet.future().text !== "{") { + tok = parser.gullet.popToken(); + if (tok.text === "#") { + // If the very last character of the is #, so that + // this # is immediately followed by {, TeX will behave as if the { + // had been inserted at the right end of both the parameter text + // and the replacement text. + if (parser.gullet.future().text === "{") { + insert = parser.gullet.future(); + delimiters[numArgs].push("{"); + break; + } + + // A parameter, the first appearance of # must be followed by 1, + // the next by 2, and so on; up to nine #’s are allowed + tok = parser.gullet.popToken(); + if (!(/^[1-9]$/.test(tok.text))) { + throw new ParseError(`Invalid argument number "${tok.text}"`); + } + if (parseInt(tok.text) !== numArgs + 1) { + throw new ParseError( + `Argument number "${tok.text}" out of order`); + } + numArgs++; + delimiters.push([]); + } else if (tok.text === "EOF") { + throw new ParseError("Expected a macro definition"); + } else { + delimiters[numArgs].push(tok.text); + } + } + // replacement text, enclosed in '{' and '}' and properly nested + let {tokens} = parser.gullet.consumeArg(); + if (insert) { + tokens.unshift(insert); + } + + if (funcName === "\\edef" || funcName === "\\xdef") { + tokens = parser.gullet.expandTokens(tokens); + tokens.reverse(); // to fit in with stack order + } + // Final arg is the expansion of the macro + parser.gullet.macros.set(name, { + tokens, + numArgs, + delimiters, + }, funcName === globalMap[funcName]); + + return { + type: "internal", + mode: parser.mode, + }; + }, +}); + +// -> +// -> \futurelet +// | \let +// -> |= +defineFunction({ + type: "internal", + names: [ + "\\let", + "\\\\globallet", // can’t be entered directly + ], + numArgs: 0, + allowedInText: true, + primitive: true, + + handler({parser, funcName}) { + const name = checkControlSequence(parser.gullet.popToken()); + parser.gullet.consumeSpaces(); + const tok = getRHS(parser); + letCommand(parser, name, tok, funcName === "\\\\globallet"); + return { + type: "internal", + mode: parser.mode, + }; + }, +}); + +// ref: https://www.tug.org/TUGboat/tb09-3/tb22bechtolsheim.pdf +defineFunction({ + type: "internal", + names: [ + "\\futurelet", + "\\\\globalfuture", // can’t be entered directly + ], + numArgs: 0, + allowedInText: true, + primitive: true, + + handler({parser, funcName}) { + const name = checkControlSequence(parser.gullet.popToken()); + const middle = parser.gullet.popToken(); + const tok = parser.gullet.popToken(); + letCommand(parser, name, tok, funcName === "\\\\globalfuture"); + parser.gullet.pushToken(tok); + parser.gullet.pushToken(middle); + return { + type: "internal", + mode: parser.mode, + }; + }, +}); diff --git a/node_modules/katex/src/functions/delimsizing.ts b/node_modules/katex/src/functions/delimsizing.ts new file mode 100644 index 0000000..d516d66 --- /dev/null +++ b/node_modules/katex/src/functions/delimsizing.ts @@ -0,0 +1,366 @@ +import {makeSpan} from "../buildCommon"; +import defineFunction from "../defineFunction"; +import {makeLeftRightDelim, makeSizedDelim, sizeToMaxHeight} from "../delimiter"; +import {MathNode} from "../mathMLTree"; +import ParseError from "../ParseError"; +import {assertNodeType, checkSymbolNodeType} from "../parseNode"; +import {makeEm} from "../units"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; + +import type Options from "../Options"; +import type {FunctionContext} from "../defineFunction"; +import type {HtmlDomNode} from "../domTree"; +import type {DelimiterSize, MathClass} from "../types"; +import type {AnyParseNode, ParseNode, SymbolParseNode} from "../types/nodes"; + +// Extra data needed for the delimiter handler down below +const delimiterSizes = { + "\\bigl" : {mclass: "mopen", size: 1}, + "\\Bigl" : {mclass: "mopen", size: 2}, + "\\biggl": {mclass: "mopen", size: 3}, + "\\Biggl": {mclass: "mopen", size: 4}, + "\\bigr" : {mclass: "mclose", size: 1}, + "\\Bigr" : {mclass: "mclose", size: 2}, + "\\biggr": {mclass: "mclose", size: 3}, + "\\Biggr": {mclass: "mclose", size: 4}, + "\\bigm" : {mclass: "mrel", size: 1}, + "\\Bigm" : {mclass: "mrel", size: 2}, + "\\biggm": {mclass: "mrel", size: 3}, + "\\Biggm": {mclass: "mrel", size: 4}, + "\\big" : {mclass: "mord", size: 1}, + "\\Big" : {mclass: "mord", size: 2}, + "\\bigg" : {mclass: "mord", size: 3}, + "\\Bigg" : {mclass: "mord", size: 4}, +} as const satisfies Record; + +const delimiters = new Set([ + "(", "\\lparen", ")", "\\rparen", + "[", "\\lbrack", "]", "\\rbrack", + "\\{", "\\lbrace", "\\}", "\\rbrace", + "\\lfloor", "\\rfloor", "\u230a", "\u230b", + "\\lceil", "\\rceil", "\u2308", "\u2309", + "<", ">", "\\langle", "\u27e8", "\\rangle", "\u27e9", "\\lt", "\\gt", + "\\lvert", "\\rvert", "\\lVert", "\\rVert", + "\\lgroup", "\\rgroup", "\u27ee", "\u27ef", + "\\lmoustache", "\\rmoustache", "\u23b0", "\u23b1", + "/", "\\backslash", + "|", "\\vert", "\\|", "\\Vert", + "\\uparrow", "\\Uparrow", + "\\downarrow", "\\Downarrow", + "\\updownarrow", "\\Updownarrow", + ".", +]); + +type IsMiddle = {delim: string, options: Options}; + +/** + * An HtmlDomNode that carries an `isMiddle` property, used by the + * \middle command to communicate delimiter info to the \left/\right builder. + */ +type MiddleDelimNode = HtmlDomNode & {isMiddle: IsMiddle}; + +function isMiddleDelimNode(node: HtmlDomNode): node is MiddleDelimNode { + return 'isMiddle' in node; +} + +// Delimiter functions +function checkDelimiter( + delim: AnyParseNode, + context: FunctionContext, +): SymbolParseNode { + const symDelim = checkSymbolNodeType(delim); + if (symDelim && delimiters.has(symDelim.text)) { + return symDelim; + } else if (symDelim) { + throw new ParseError( + `Invalid delimiter '${symDelim.text}' after '${context.funcName}'`, + delim); + } else { + throw new ParseError(`Invalid delimiter type '${delim.type}'`, delim); + } +} + +defineFunction({ + type: "delimsizing", + names: [ + "\\bigl", "\\Bigl", "\\biggl", "\\Biggl", + "\\bigr", "\\Bigr", "\\biggr", "\\Biggr", + "\\bigm", "\\Bigm", "\\biggm", "\\Biggm", + "\\big", "\\Big", "\\bigg", "\\Bigg", + ], + numArgs: 1, + argTypes: ["primitive"], + + handler: (context, args) => { + const delim = checkDelimiter(args[0], context); + + return { + type: "delimsizing", + mode: context.parser.mode, + size: delimiterSizes[context.funcName].size, + mclass: delimiterSizes[context.funcName].mclass, + delim: delim.text, + }; + }, + + htmlBuilder: (group, options) => { + if (group.delim === ".") { + // Empty delimiters still count as elements, even though they don't + // show anything. + return makeSpan([group.mclass]); + } + + return makeSizedDelim( + group.delim, group.size, options, group.mode, [group.mclass]); + }, + mathmlBuilder: (group) => { + const children = []; + + if (group.delim !== ".") { + children.push(mml.makeText(group.delim, group.mode)); + } + + const node = new MathNode("mo", children); + + if (group.mclass === "mopen" || + group.mclass === "mclose") { + // Only some of the delimsizing functions act as fences, and they + // return "mopen" or "mclose" mclass. + node.setAttribute("fence", "true"); + } else { + // Explicitly disable fencing if it's not a fence, to override the + // defaults. + node.setAttribute("fence", "false"); + } + + node.setAttribute("stretchy", "true"); + const size = makeEm(sizeToMaxHeight[group.size]); + node.setAttribute("minsize", size); + node.setAttribute("maxsize", size); + + return node; + }, +}); + + +function assertParsed(group: ParseNode<"leftright">) { + if (!group.body) { + throw new Error("Bug: The leftright ParseNode wasn't fully parsed."); + } +} + + +defineFunction({ + type: "leftright-right", + names: ["\\right"], + numArgs: 1, + primitive: true, + + handler: (context, args) => { + // \left case below triggers parsing of \right in + // `const right = parser.parseFunction();` + // uses this return value. + const color = context.parser.gullet.macros.get("\\current@color"); + if (color && typeof color !== "string") { + throw new ParseError( + "\\current@color set to non-string in \\right"); + } + return { + type: "leftright-right", + mode: context.parser.mode, + delim: checkDelimiter(args[0], context).text, + color, // undefined if not set via \color + }; + }, +}); + + +defineFunction({ + type: "leftright", + names: ["\\left"], + numArgs: 1, + primitive: true, + + handler: (context, args) => { + const delim = checkDelimiter(args[0], context); + + const parser = context.parser; + // Parse out the implicit body + ++parser.leftrightDepth; + // parseExpression stops before '\\right' + const body = parser.parseExpression(false); + --parser.leftrightDepth; + // Check the next token + parser.expect("\\right", false); + const right = assertNodeType(parser.parseFunction(), "leftright-right"); + return { + type: "leftright", + mode: parser.mode, + body, + left: delim.text, + right: right.delim, + rightColor: right.color, + }; + }, + + htmlBuilder: (group, options) => { + assertParsed(group); + // Build the inner expression + const inner = html.buildExpression(group.body, options, true, + ["mopen", "mclose"]); + + let innerHeight = 0; + let innerDepth = 0; + let hadMiddle = false; + + // Calculate its height and depth + for (let i = 0; i < inner.length; i++) { + const node = inner[i]; + if (isMiddleDelimNode(node)) { + hadMiddle = true; + } else { + innerHeight = Math.max(inner[i].height, innerHeight); + innerDepth = Math.max(inner[i].depth, innerDepth); + } + } + + // The size of delimiters is the same, regardless of what style we are + // in. Thus, to correctly calculate the size of delimiter we need around + // a group, we scale down the inner size based on the size. + innerHeight *= options.sizeMultiplier; + innerDepth *= options.sizeMultiplier; + + let leftDelim; + if (group.left === ".") { + // Empty delimiters in \left and \right make null delimiter spaces. + leftDelim = html.makeNullDelimiter(options, ["mopen"]); + } else { + // Otherwise, use leftRightDelim to generate the correct sized + // delimiter. + leftDelim = makeLeftRightDelim( + group.left, innerHeight, innerDepth, options, + group.mode, ["mopen"]); + } + // Add it to the beginning of the expression + inner.unshift(leftDelim); + + // Handle middle delimiters + if (hadMiddle) { + for (let i = 1; i < inner.length; i++) { + const middleDelim = inner[i]; + if (isMiddleDelimNode(middleDelim)) { + const isMiddle = middleDelim.isMiddle; + // Apply the options that were active when \middle was called + inner[i] = makeLeftRightDelim( + isMiddle.delim, innerHeight, innerDepth, + isMiddle.options, group.mode, []); + } + } + } + + let rightDelim; + // Same for the right delimiter, but using color specified by \color + if (group.right === ".") { + rightDelim = html.makeNullDelimiter(options, ["mclose"]); + } else { + const colorOptions = group.rightColor ? + options.withColor(group.rightColor) : options; + rightDelim = makeLeftRightDelim( + group.right, innerHeight, innerDepth, colorOptions, + group.mode, ["mclose"]); + } + // Add it to the end of the expression. + inner.push(rightDelim); + + return makeSpan(["minner"], inner, options); + }, + mathmlBuilder: (group, options) => { + assertParsed(group); + const inner = mml.buildExpression(group.body, options); + + if (group.left !== ".") { + const leftNode = new MathNode( + "mo", [mml.makeText(group.left, group.mode)]); + + leftNode.setAttribute("fence", "true"); + + inner.unshift(leftNode); + } + + if (group.right !== ".") { + const rightNode = new MathNode( + "mo", [mml.makeText(group.right, group.mode)]); + + rightNode.setAttribute("fence", "true"); + + if (group.rightColor) { + rightNode.setAttribute("mathcolor", group.rightColor); + } + + inner.push(rightNode); + } + + return mml.makeRow(inner); + }, +}); + +defineFunction({ + type: "middle", + names: ["\\middle"], + numArgs: 1, + primitive: true, + + handler: (context, args) => { + const delim = checkDelimiter(args[0], context); + if (!context.parser.leftrightDepth) { + throw new ParseError("\\middle without preceding \\left", delim); + } + + return { + type: "middle", + mode: context.parser.mode, + delim: delim.text, + }; + }, + + htmlBuilder: (group, options) => { + let middleDelim; + if (group.delim === ".") { + middleDelim = html.makeNullDelimiter(options, []); + } else { + middleDelim = makeSizedDelim( + group.delim, 1, options, + group.mode, []); + + // Patch an ad-hoc property onto the node so the \left/\right + // builder can reconstruct appropriately sized middle delimiters. + // isMiddle is not part of HtmlDomNode; the read side uses + // isMiddleDelimNode() to check before accessing. + (middleDelim as unknown as MiddleDelimNode).isMiddle = { + delim: group.delim, options, + }; + } + return middleDelim; + }, + mathmlBuilder: (group, options) => { + // A Firefox \middle will stretch a character vertically only if it + // is in the fence part of the operator dictionary at: + // https://www.w3.org/TR/MathML3/appendixc.html. + // So we need to avoid U+2223 and use plain "|" instead. + const textNode = (group.delim === "\\vert" || group.delim === "|") + ? mml.makeText("|", "text") + : mml.makeText(group.delim, group.mode); + const middleNode = new MathNode("mo", [textNode]); + middleNode.setAttribute("fence", "true"); + // MathML gives 5/18em spacing to each element. + // \middle should get delimiter spacing instead. + middleNode.setAttribute("lspace", "0.05em"); + middleNode.setAttribute("rspace", "0.05em"); + return middleNode; + }, +}); diff --git a/node_modules/katex/src/functions/enclose.ts b/node_modules/katex/src/functions/enclose.ts new file mode 100644 index 0000000..e208ab3 --- /dev/null +++ b/node_modules/katex/src/functions/enclose.ts @@ -0,0 +1,334 @@ +import defineFunction from "../defineFunction"; +import {makeSpan, makeSvgSpan, makeVList, wrapFragment} from "../buildCommon"; +import {isCharacterBox} from "../utils"; +import {MathNode} from "../mathMLTree"; +import {stretchyEnclose} from "../stretchy"; +import {phasePath} from "../svgGeometry"; +import {PathNode, SvgNode} from "../domTree"; +import {calculateSize, makeEm} from "../units"; +import {assertNodeType} from "../parseNode"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; +import type {HtmlBuilder, MathMLBuilder} from "../defineFunction"; + +const htmlBuilder: HtmlBuilder<"enclose"> = (group, options) => { + // \cancel, \bcancel, \xcancel, \sout, \fbox, \colorbox, \fcolorbox, \phase + // Some groups can return document fragments. Handle those by wrapping + // them in a span. + const inner = wrapFragment( + html.buildGroup(group.body, options), options); + + const label = group.label.slice(1); + let scale = options.sizeMultiplier; + let img; + let imgShift; + + // In the LaTeX cancel package, line geometry is slightly different + // depending on whether the subject is wider than it is tall, or vice versa. + // We don't know the width of a group, so as a proxy, we test if + // the subject is a single character. This captures most of the + // subjects that should get the "tall" treatment. + const isSingleChar = isCharacterBox(group.body); + + if (label === "sout") { + img = makeSpan(["stretchy", "sout"]); + img.height = options.fontMetrics().defaultRuleThickness / scale; + imgShift = -0.5 * options.fontMetrics().xHeight; + + } else if (label === "phase") { + // Set a couple of dimensions from the steinmetz package. + const lineWeight = calculateSize({number: 0.6, unit: "pt"}, options); + const clearance = calculateSize({number: 0.35, unit: "ex"}, options); + + // Prevent size changes like \Huge from affecting line thickness + const newOptions = options.havingBaseSizing(); + scale = scale / newOptions.sizeMultiplier; + + const angleHeight = inner.height + inner.depth + lineWeight + clearance; + // Reserve a left pad for the angle. + inner.style.paddingLeft = makeEm(angleHeight / 2 + lineWeight); + + // Create an SVG + const viewBoxHeight = Math.floor(1000 * angleHeight * scale); + const path = phasePath(viewBoxHeight); + const svgNode = new SvgNode([new PathNode("phase", path)], { + "width": "400em", + "height": makeEm(viewBoxHeight / 1000), + "viewBox": `0 0 400000 ${viewBoxHeight}`, + "preserveAspectRatio": "xMinYMin slice", + }); + // Wrap it in a span with overflow: hidden. + img = makeSvgSpan(["hide-tail"], [svgNode], options); + img.style.height = makeEm(angleHeight); + imgShift = inner.depth + lineWeight + clearance; + + } else { + // Add horizontal padding + if (/cancel/.test(label)) { + if (!isSingleChar) { + inner.classes.push("cancel-pad"); + } + } else if (label === "angl") { + inner.classes.push("anglpad"); + } else { + inner.classes.push("boxpad"); + } + + // Add vertical padding + let topPad; + let bottomPad; + let ruleThickness = 0; + // ref: cancel package: \advance\totalheight2\p@ % "+2" + if (/box/.test(label)) { + ruleThickness = Math.max( + options.fontMetrics().fboxrule, // default + options.minRuleThickness, // User override. + ); + topPad = options.fontMetrics().fboxsep + + (label === "colorbox" ? 0 : ruleThickness); + bottomPad = topPad; + } else if (label === "angl") { + ruleThickness = Math.max( + options.fontMetrics().defaultRuleThickness, + options.minRuleThickness + ); + topPad = 4 * ruleThickness; // gap = 3 × line, plus the line itself. + bottomPad = Math.max(0, 0.25 - inner.depth); + } else { + topPad = isSingleChar ? 0.2 : 0; + bottomPad = topPad; + } + + img = stretchyEnclose(inner, label, topPad, bottomPad, options); + if (/fbox|boxed|fcolorbox/.test(label)) { + img.style.borderStyle = "solid"; + img.style.borderWidth = makeEm(ruleThickness); + } else if (label === "angl" && ruleThickness !== 0.049) { + img.style.borderTopWidth = makeEm(ruleThickness); + img.style.borderRightWidth = makeEm(ruleThickness); + } + imgShift = inner.depth + bottomPad; + + if (group.backgroundColor) { + img.style.backgroundColor = group.backgroundColor; + if (group.borderColor) { + img.style.borderColor = group.borderColor; + } + } + } + + let vlist; + if (group.backgroundColor) { + vlist = makeVList({ + positionType: "individualShift", + children: [ + // Put the color background behind inner; + {type: "elem", elem: img, shift: imgShift}, + {type: "elem", elem: inner, shift: 0}, + ], + }, options); + } else { + const classes = /cancel|phase/.test(label) ? ["svg-align"] : []; + vlist = makeVList({ + positionType: "individualShift", + children: [ + // Write the \cancel stroke on top of inner. + { + type: "elem", + elem: inner, + shift: 0, + }, + { + type: "elem", + elem: img, + shift: imgShift, + wrapperClasses: classes, + }, + ], + }, options); + } + + if (/cancel/.test(label)) { + // The cancel package documentation says that cancel lines add their height + // to the expression, but tests show that isn't how it actually works. + vlist.height = inner.height; + vlist.depth = inner.depth; + } + + if (/cancel/.test(label) && !isSingleChar) { + // cancel does not create horiz space for its line extension. + return makeSpan(["mord", "cancel-lap"], [vlist], options); + } else { + return makeSpan(["mord"], [vlist], options); + } +}; + +const mathmlBuilder: MathMLBuilder<"enclose"> = (group, options) => { + let fboxsep; + const node = new MathNode( + group.label.includes("colorbox") ? "mpadded" : "menclose", + [mml.buildGroup(group.body, options)] + ); + switch (group.label) { + case "\\cancel": + node.setAttribute("notation", "updiagonalstrike"); + break; + case "\\bcancel": + node.setAttribute("notation", "downdiagonalstrike"); + break; + case "\\phase": + node.setAttribute("notation", "phasorangle"); + break; + case "\\sout": + node.setAttribute("notation", "horizontalstrike"); + break; + case "\\fbox": + node.setAttribute("notation", "box"); + break; + case "\\angl": + node.setAttribute("notation", "actuarial"); + break; + case "\\fcolorbox": + case "\\colorbox": + // doesn't have a good notation option. So use + // instead. Set some attributes that come included with . + fboxsep = options.fontMetrics().fboxsep * + options.fontMetrics().ptPerEm; + node.setAttribute("width", `+${2 * fboxsep}pt`); + node.setAttribute("height", `+${2 * fboxsep}pt`); + node.setAttribute("lspace", `${fboxsep}pt`); // + node.setAttribute("voffset", `${fboxsep}pt`); + if (group.label === "\\fcolorbox") { + const thk = Math.max( + options.fontMetrics().fboxrule, // default + options.minRuleThickness, // user override + ); + node.setAttribute("style", `border: ${makeEm(thk)} solid ${group.borderColor}`); + } + break; + case "\\xcancel": + node.setAttribute("notation", "updiagonalstrike downdiagonalstrike"); + break; + } + if (group.backgroundColor) { + node.setAttribute("mathbackground", group.backgroundColor); + } + return node; +}; + +defineFunction({ + type: "enclose", + names: ["\\colorbox"], + numArgs: 2, + allowedInText: true, + argTypes: ["color", "hbox"], + + handler({parser, funcName}, args, optArgs) { + const color = assertNodeType(args[0], "color-token").color; + const body = args[1]; + return { + type: "enclose", + mode: parser.mode, + label: funcName, + backgroundColor: color, + body, + }; + }, + + htmlBuilder, + mathmlBuilder, +}); + +defineFunction({ + type: "enclose", + names: ["\\fcolorbox"], + numArgs: 3, + allowedInText: true, + argTypes: ["color", "color", "hbox"], + + handler({parser, funcName}, args, optArgs) { + const borderColor = assertNodeType(args[0], "color-token").color; + const backgroundColor = assertNodeType(args[1], "color-token").color; + const body = args[2]; + return { + type: "enclose", + mode: parser.mode, + label: funcName, + backgroundColor, + borderColor, + body, + }; + }, +}); + +defineFunction({ + type: "enclose", + names: ["\\fbox"], + numArgs: 1, + argTypes: ["hbox"], + allowedInText: true, + + handler({parser}, args) { + return { + type: "enclose", + mode: parser.mode, + label: "\\fbox", + body: args[0], + }; + }, +}); + +defineFunction({ + type: "enclose", + names: ["\\cancel", "\\bcancel", "\\xcancel", "\\phase"], + numArgs: 1, + + handler({parser, funcName}, args) { + const body = args[0]; + return { + type: "enclose", + mode: parser.mode, + label: funcName, + body, + }; + }, +}); + +defineFunction({ + type: "enclose", + names: ["\\sout"], + numArgs: 1, + allowedInText: true, + + handler({parser, funcName}, args) { + if (parser.mode === "math") { + parser.settings.reportNonstrict("mathVsSout", + `LaTeX's \\sout works only in text mode`); + } + const body = args[0]; + return { + type: "enclose", + mode: parser.mode, + label: funcName, + body, + }; + }, +}); + +defineFunction({ + type: "enclose", + names: ["\\angl"], + numArgs: 1, + argTypes: ["hbox"], + allowedInText: false, + + handler({parser}, args) { + return { + type: "enclose", + mode: parser.mode, + label: "\\angl", + body: args[0], + }; + }, +}); diff --git a/node_modules/katex/src/functions/environment.ts b/node_modules/katex/src/functions/environment.ts new file mode 100644 index 0000000..fd69a95 --- /dev/null +++ b/node_modules/katex/src/functions/environment.ts @@ -0,0 +1,65 @@ +import defineFunction from "../defineFunction"; +import ParseError from "../ParseError"; +import {assertNodeType} from "../parseNode"; +import environments from "../environments"; + +import type {ParseNode} from "../types/nodes"; + +// Environment delimiters. HTML/MathML rendering is defined in the corresponding +// defineEnvironment definitions. +defineFunction({ + type: "environment", + names: ["\\begin", "\\end"], + numArgs: 1, + argTypes: ["text"], + + handler({parser, funcName}, args) { + const nameGroup = args[0]; + if (nameGroup.type !== "ordgroup") { + throw new ParseError("Invalid environment name", nameGroup); + } + let envName = ""; + for (let i = 0; i < nameGroup.body.length; ++i) { + envName += assertNodeType(nameGroup.body[i], "textord").text; + } + + if (funcName === "\\begin") { + // begin...end is similar to left...right + if (!environments.hasOwnProperty(envName)) { + throw new ParseError( + "No such environment: " + envName, nameGroup); + } + // Build the environment object. Arguments and other information will + // be made available to the begin and end methods using properties. + const env = environments[envName]; + const {args, optArgs} = + parser.parseArguments("\\begin{" + envName + "}", env); + const context = { + mode: parser.mode, + envName, + parser, + }; + const result = env.handler(context, args, optArgs); + parser.expect("\\end", false); + const endNameToken = parser.nextToken; + const end = assertNodeType(parser.parseFunction(), "environment"); + if (end.name !== envName) { + throw new ParseError( + `Mismatch: \\begin{${envName}} matched by \\end{${end.name}}`, + endNameToken); + } + // env.handler returns the specific node type (e.g. "array"), + // not "environment". This cast is unavoidable: defineFunction + // requires the handler to return ParseNode<"environment"> but + // \begin delegates to environment handlers with different types. + return result as unknown as ParseNode<"environment">; + } + + return { + type: "environment", + mode: parser.mode, + name: envName, + nameGroup, + }; + }, +}); diff --git a/node_modules/katex/src/functions/font.ts b/node_modules/katex/src/functions/font.ts new file mode 100644 index 0000000..49949b0 --- /dev/null +++ b/node_modules/katex/src/functions/font.ts @@ -0,0 +1,112 @@ +// TODO(kevinb): implement \\sl and \\sc + +import {binrelClass} from "./mclass"; +import defineFunction, {normalizeArgument} from "../defineFunction"; +import {isCharacterBox} from "../utils"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; + +import type Options from "../Options"; +import type {ParseNode} from "../types/nodes"; +import type {Slice1} from "../types"; + +const htmlBuilder = (group: ParseNode<"font">, options: Options) => { + const font = group.font; + const newOptions = options.withFont(font); + return html.buildGroup(group.body, newOptions); +}; + +const mathmlBuilder = (group: ParseNode<"font">, options: Options) => { + const font = group.font; + const newOptions = options.withFont(font); + return mml.buildGroup(group.body, newOptions); +}; + +const fontAliases = { + "\\Bbb": "\\mathbb", + "\\bold": "\\mathbf", + "\\frak": "\\mathfrak", +} as const; + +defineFunction({ + type: "font", + names: [ + // styles, except \boldsymbol defined below + "\\mathrm", "\\mathit", "\\mathbf", "\\mathnormal", "\\mathsfit", + + // families + "\\mathbb", "\\mathcal", "\\mathfrak", "\\mathscr", "\\mathsf", + "\\mathtt", + + // aliases, except \bm defined below + "\\Bbb", "\\bold", "\\frak", + ], + numArgs: 1, + allowedInArgument: true, + + handler: ({parser, funcName}, args) => { + const body = normalizeArgument(args[0]); + const func = funcName in fontAliases + ? fontAliases[funcName as keyof typeof fontAliases] + : funcName as Exclude; + return { + type: "font", + mode: parser.mode, + font: func.slice(1) as Slice1, + body, + }; + }, + + htmlBuilder, + mathmlBuilder, +}); + +defineFunction({ + type: "mclass", + names: ["\\boldsymbol", "\\bm"], + numArgs: 1, + + handler: ({parser}, args) => { + const body = args[0]; + // amsbsy.sty's \boldsymbol uses \binrel spacing to inherit the + // argument's bin|rel|ord status + return { + type: "mclass", + mode: parser.mode, + mclass: binrelClass(body), + body: [ + { + type: "font", + mode: parser.mode, + font: "boldsymbol", + body, + }, + ], + isCharacterBox: isCharacterBox(body), + }; + }, +}); + +// Old font changing functions +defineFunction({ + type: "font", + names: ["\\rm", "\\sf", "\\tt", "\\bf", "\\it", "\\cal"], + numArgs: 0, + allowedInText: true, + handler: ({parser, funcName, breakOnTokenText}, args) => { + const {mode} = parser; + const body = parser.parseExpression(true, breakOnTokenText); + + return { + type: "font", + mode: mode, + font: `math${funcName.slice(1) as Slice1}` as const, + body: { + type: "ordgroup", + mode: parser.mode, + body, + }, + }; + }, +}); diff --git a/node_modules/katex/src/functions/genfrac.ts b/node_modules/katex/src/functions/genfrac.ts new file mode 100644 index 0000000..f619713 --- /dev/null +++ b/node_modules/katex/src/functions/genfrac.ts @@ -0,0 +1,466 @@ +import defineFunction, {normalizeArgument} from "../defineFunction"; +import {makeLineSpan, makeSpan, makeVList} from "../buildCommon"; +import {makeCustomSizedDelim} from "../delimiter"; +import {MathNode, TextNode} from "../mathMLTree"; +import type {ParseNode} from "../types/nodes"; +import Style from "../Style"; +import {assertNodeType} from "../parseNode"; +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; +import {calculateSize, makeEm} from "../units"; +import type {StyleStr} from "../types"; +import type {HtmlBuilder, MathMLBuilder} from "../defineFunction"; + +const htmlBuilder: HtmlBuilder<"genfrac"> = (group, options) => { + // Fractions are handled in the TeXbook on pages 444-445, rules 15(a-e). + const style = options.style; + + const nstyle = style.fracNum(); + const dstyle = style.fracDen(); + let newOptions; + + newOptions = options.havingStyle(nstyle); + const numerm = html.buildGroup(group.numer, newOptions, options); + + if (group.continued) { + // \cfrac inserts a \strut into the numerator. + // Get \strut dimensions from TeXbook page 353. + const hStrut = 8.5 / options.fontMetrics().ptPerEm; + const dStrut = 3.5 / options.fontMetrics().ptPerEm; + numerm.height = numerm.height < hStrut ? hStrut : numerm.height; + numerm.depth = numerm.depth < dStrut ? dStrut : numerm.depth; + } + + newOptions = options.havingStyle(dstyle); + const denomm = html.buildGroup(group.denom, newOptions, options); + + let rule; + let ruleWidth; + let ruleSpacing; + if (group.hasBarLine) { + if (group.barSize) { + ruleWidth = calculateSize(group.barSize, options); + rule = makeLineSpan("frac-line", options, ruleWidth); + } else { + rule = makeLineSpan("frac-line", options); + } + ruleWidth = rule.height; + ruleSpacing = rule.height; + } else { + rule = null; + ruleWidth = 0; + ruleSpacing = options.fontMetrics().defaultRuleThickness; + } + + // Rule 15b + let numShift; + let clearance; + let denomShift; + if (style.size === Style.DISPLAY.size) { + numShift = options.fontMetrics().num1; + if (ruleWidth > 0) { + clearance = 3 * ruleSpacing; + } else { + clearance = 7 * ruleSpacing; + } + denomShift = options.fontMetrics().denom1; + } else { + if (ruleWidth > 0) { + numShift = options.fontMetrics().num2; + clearance = ruleSpacing; + } else { + numShift = options.fontMetrics().num3; + clearance = 3 * ruleSpacing; + } + denomShift = options.fontMetrics().denom2; + } + + let frac; + if (!rule) { + // Rule 15c + const candidateClearance = + (numShift - numerm.depth) - (denomm.height - denomShift); + if (candidateClearance < clearance) { + numShift += 0.5 * (clearance - candidateClearance); + denomShift += 0.5 * (clearance - candidateClearance); + } + + frac = makeVList({ + positionType: "individualShift", + children: [ + {type: "elem", elem: denomm, shift: denomShift}, + {type: "elem", elem: numerm, shift: -numShift}, + ], + }, options); + } else { + // Rule 15d + const axisHeight = options.fontMetrics().axisHeight; + + if ((numShift - numerm.depth) - (axisHeight + 0.5 * ruleWidth) < + clearance) { + numShift += + clearance - ((numShift - numerm.depth) - + (axisHeight + 0.5 * ruleWidth)); + } + + if ((axisHeight - 0.5 * ruleWidth) - (denomm.height - denomShift) < + clearance) { + denomShift += + clearance - ((axisHeight - 0.5 * ruleWidth) - + (denomm.height - denomShift)); + } + + const midShift = -(axisHeight - 0.5 * ruleWidth); + + frac = makeVList({ + positionType: "individualShift", + children: [ + {type: "elem", elem: denomm, shift: denomShift}, + {type: "elem", elem: rule, shift: midShift}, + {type: "elem", elem: numerm, shift: -numShift}, + ], + }, options); + } + + // Since we manually change the style sometimes (with \dfrac or \tfrac), + // account for the possible size change here. + newOptions = options.havingStyle(style); + frac.height *= newOptions.sizeMultiplier / options.sizeMultiplier; + frac.depth *= newOptions.sizeMultiplier / options.sizeMultiplier; + + // Rule 15e + let delimSize; + if (style.size === Style.DISPLAY.size) { + delimSize = options.fontMetrics().delim1; + } else if (style.size === Style.SCRIPTSCRIPT.size) { + delimSize = options.havingStyle(Style.SCRIPT).fontMetrics().delim2; + } else { + delimSize = options.fontMetrics().delim2; + } + + let leftDelim; + let rightDelim; + if (group.leftDelim == null) { + leftDelim = html.makeNullDelimiter(options, ["mopen"]); + } else { + leftDelim = makeCustomSizedDelim( + group.leftDelim, delimSize, true, + options.havingStyle(style), group.mode, ["mopen"]); + } + + if (group.continued) { + rightDelim = makeSpan([]); // zero width for \cfrac + } else if (group.rightDelim == null) { + rightDelim = html.makeNullDelimiter(options, ["mclose"]); + } else { + rightDelim = makeCustomSizedDelim( + group.rightDelim, delimSize, true, + options.havingStyle(style), group.mode, ["mclose"]); + } + + return makeSpan( + ["mord"].concat(newOptions.sizingClasses(options)), + [leftDelim, makeSpan(["mfrac"], [frac]), rightDelim], + options); +}; + +const mathmlBuilder: MathMLBuilder<"genfrac"> = (group, options) => { + const node = new MathNode( + "mfrac", + [ + mml.buildGroup(group.numer, options), + mml.buildGroup(group.denom, options), + ]); + + if (!group.hasBarLine) { + node.setAttribute("linethickness", "0px"); + } else if (group.barSize) { + const ruleWidth = calculateSize(group.barSize, options); + node.setAttribute("linethickness", makeEm(ruleWidth)); + } + + if (group.leftDelim != null || group.rightDelim != null) { + const withDelims = []; + + if (group.leftDelim != null) { + const leftOp = new MathNode( + "mo", + [new TextNode(group.leftDelim.replace("\\", ""))] + ); + + leftOp.setAttribute("fence", "true"); + + withDelims.push(leftOp); + } + + withDelims.push(node); + + if (group.rightDelim != null) { + const rightOp = new MathNode( + "mo", + [new TextNode(group.rightDelim.replace("\\", ""))] + ); + + rightOp.setAttribute("fence", "true"); + + withDelims.push(rightOp); + } + + return mml.makeRow(withDelims); + } + + return node; +}; + +const wrapWithStyle = ( + frac: ParseNode<"genfrac">, + style?: StyleStr | null, +): ParseNode<"genfrac"> => { + if (!style) { + return frac; + } + + const wrapper: ParseNode<"styling"> = { + type: "styling", + mode: frac.mode, + style, + body: [frac], + }; + + // @ts-ignore defineFunction handler needs to return ParseNode<"genfrac"> + return wrapper; +}; + +defineFunction({ + type: "genfrac", + names: [ + "\\cfrac", "\\dfrac", "\\frac", "\\tfrac", + "\\dbinom", "\\binom", "\\tbinom", + "\\\\atopfrac", // can’t be entered directly + "\\\\bracefrac", "\\\\brackfrac", // ditto + ], + numArgs: 2, + allowedInArgument: true, + + handler: ({parser, funcName}, args) => { + const numer = args[0]; + const denom = args[1]; + let hasBarLine: boolean; + let leftDelim: string | null = null; + let rightDelim: string | null = null; + + switch (funcName) { + case "\\cfrac": + case "\\dfrac": + case "\\frac": + case "\\tfrac": + hasBarLine = true; + break; + case "\\\\atopfrac": + hasBarLine = false; + break; + case "\\dbinom": + case "\\binom": + case "\\tbinom": + hasBarLine = false; + leftDelim = "("; + rightDelim = ")"; + break; + case "\\\\bracefrac": + hasBarLine = false; + leftDelim = "\\{"; + rightDelim = "\\}"; + break; + case "\\\\brackfrac": + hasBarLine = false; + leftDelim = "["; + rightDelim = "]"; + break; + default: + throw new Error("Unrecognized genfrac command"); + } + + const continued = funcName === "\\cfrac"; + let style = null; + if (continued || funcName.startsWith("\\d")) { + style = "display" as StyleStr; + } else if (funcName.startsWith("\\t")) { + style = "text" as StyleStr; + } + + return wrapWithStyle({ + type: "genfrac", + mode: parser.mode, + numer, + denom, + continued, + hasBarLine, + leftDelim, + rightDelim, + barSize: null, + }, style); + }, + + + htmlBuilder, + mathmlBuilder, +}); + +// Infix generalized fractions -- these are not rendered directly, but replaced +// immediately by one of the variants above. +defineFunction({ + type: "infix", + names: ["\\over", "\\choose", "\\atop", "\\brace", "\\brack"], + numArgs: 0, + infix: true, + + handler({parser, funcName, token}) { + let replaceWith; + switch (funcName) { + case "\\over": + replaceWith = "\\frac"; + break; + case "\\choose": + replaceWith = "\\binom"; + break; + case "\\atop": + replaceWith = "\\\\atopfrac"; + break; + case "\\brace": + replaceWith = "\\\\bracefrac"; + break; + case "\\brack": + replaceWith = "\\\\brackfrac"; + break; + default: + throw new Error("Unrecognized infix genfrac command"); + } + return { + type: "infix", + mode: parser.mode, + replaceWith, + token, + }; + }, +}); + +const stylArray: StyleStr[] = ["display", "text", "script", "scriptscript"]; + +const delimFromValue = function(delimString: string): string | null { + let delim = null; + if (delimString.length > 0) { + delim = delimString; + delim = delim === "." ? null : delim; + } + return delim; +}; + +defineFunction({ + type: "genfrac", + names: ["\\genfrac"], + numArgs: 6, + allowedInArgument: true, + argTypes: ["math", "math", "size", "text", "math", "math"], + + handler({parser}, args) { + const numer = args[4]; + const denom = args[5]; + + // Look into the parse nodes to get the desired delimiters. + const leftNode = normalizeArgument(args[0]); + const leftDelim = leftNode.type === "atom" && leftNode.family === "open" + ? delimFromValue(leftNode.text) : null; + const rightNode = normalizeArgument(args[1]); + const rightDelim = rightNode.type === "atom" && rightNode.family === "close" + ? delimFromValue(rightNode.text) : null; + + const barNode = assertNodeType(args[2], "size"); + let hasBarLine: boolean; + let barSize = null; + if (barNode.isBlank) { + // \genfrac acts differently than \above. + // \genfrac treats an empty size group as a signal to use a + // standard bar size. \above would see size = 0 and omit the bar. + hasBarLine = true; + } else { + barSize = barNode.value; + hasBarLine = barSize.number > 0; + } + + // Find out if we want displaystyle, textstyle, etc. + let size = null; + let styl = args[3]; + if (styl.type === "ordgroup") { + if (styl.body.length > 0) { + const textOrd = assertNodeType(styl.body[0], "textord"); + size = stylArray[Number(textOrd.text)] as StyleStr; + } + } else { + styl = assertNodeType(styl, "textord"); + size = stylArray[Number(styl.text)] as StyleStr; + } + + return wrapWithStyle({ + type: "genfrac", + mode: parser.mode, + numer, + denom, + continued: false, + hasBarLine, + barSize, + leftDelim, + rightDelim, + }, size); + }, +}); + +// \above is an infix fraction that also defines a fraction bar size. +defineFunction({ + type: "infix", + names: ["\\above"], + numArgs: 1, + argTypes: ["size"], + infix: true, + + handler({parser, funcName, token}, args) { + return { + type: "infix", + mode: parser.mode, + replaceWith: "\\\\abovefrac", + size: assertNodeType(args[0], "size").value, + token, + }; + }, +}); + +defineFunction({ + type: "genfrac", + names: ["\\\\abovefrac"], + numArgs: 3, + argTypes: ["math", "size", "math"], + + handler: ({parser, funcName}, args) => { + const numer = args[0]; + const barSize = assertNodeType(args[1], "infix").size; + + if (!barSize) { + throw new Error( + `\\\\abovefrac expected size, but got ${String(barSize)}`); + } + + const denom = args[2]; + + const hasBarLine = barSize.number > 0; + return { + type: "genfrac", + mode: parser.mode, + numer, + denom, + continued: false, + hasBarLine, + barSize, + leftDelim: null, + rightDelim: null, + }; + }, +}); diff --git a/node_modules/katex/src/functions/hbox.ts b/node_modules/katex/src/functions/hbox.ts new file mode 100644 index 0000000..460d719 --- /dev/null +++ b/node_modules/katex/src/functions/hbox.ts @@ -0,0 +1,38 @@ +import defineFunction, {ordargument} from "../defineFunction"; +import {makeFragment} from "../buildCommon"; +import {MathNode} from "../mathMLTree"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; + +// \hbox is provided for compatibility with LaTeX \vcenter. +// In LaTeX, \vcenter can act only on a box, as in +// \vcenter{\hbox{$\frac{a+b}{\dfrac{c}{d}}$}} +// This function by itself doesn't do anything but prevent a soft line break. + +defineFunction({ + type: "hbox", + names: ["\\hbox"], + numArgs: 1, + argTypes: ["text"], + allowedInText: true, + primitive: true, + + handler({parser}, args) { + return { + type: "hbox", + mode: parser.mode, + body: ordargument(args[0]), + }; + }, + + htmlBuilder(group, options) { + const elements = html.buildExpression(group.body, options.withFont(''), false); + return makeFragment(elements); + }, + mathmlBuilder(group, options) { + return new MathNode( + "mrow", mml.buildExpression(group.body, options.withFont('')) + ); + }, +}); diff --git a/node_modules/katex/src/functions/horizBrace.ts b/node_modules/katex/src/functions/horizBrace.ts new file mode 100644 index 0000000..fe3842b --- /dev/null +++ b/node_modules/katex/src/functions/horizBrace.ts @@ -0,0 +1,134 @@ +import defineFunction from "../defineFunction"; +import {makeSpan, makeVList} from "../buildCommon"; +import {MathNode} from "../mathMLTree"; +import {stretchyMathML, stretchySvg} from "../stretchy"; +import Style from "../Style"; +import {assertNodeType} from "../parseNode"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; + +import type {HtmlBuilderSupSub, MathMLBuilder} from "../defineFunction"; +import type {ParseNode} from "../types/nodes"; + +// NOTE: Unlike most `htmlBuilder`s, this one handles not only "horizBrace", but +// also "supsub" since an over/underbrace can affect super/subscripting. +export const htmlBuilder: HtmlBuilderSupSub<"horizBrace"> = (grp, options) => { + const style = options.style; + + // Pull out the `ParseNode<"horizBrace">` if `grp` is a "supsub" node. + let supSubGroup; + let group: ParseNode<"horizBrace">; + if (grp.type === "supsub") { + // Ref: LaTeX source2e: }}}}\limits} + // i.e. LaTeX treats the brace similar to an op and passes it + // with \limits, so we need to assign supsub style. + supSubGroup = grp.sup ? + html.buildGroup(grp.sup, options.havingStyle(style.sup()), options) : + html.buildGroup(grp.sub, options.havingStyle(style.sub()), options); + group = assertNodeType(grp.base, "horizBrace"); + } else { + group = assertNodeType(grp, "horizBrace"); + } + + // Build the base group + const body = html.buildGroup( + group.base, options.havingBaseStyle(Style.DISPLAY)); + + // Create the stretchy element + const braceBody = stretchySvg(group, options); + + // Generate the vlist, with the appropriate kerns ┏━━━━━━━━┓ + // This first vlist contains the content and the brace: equation + let vlist; + if (group.isOver) { + vlist = makeVList({ + positionType: "firstBaseline", + children: [ + {type: "elem", elem: body}, + {type: "kern", size: 0.1}, + {type: "elem", elem: braceBody, + wrapperClasses: ["svg-align"]}, + ], + }, options); + } else { + vlist = makeVList({ + positionType: "bottom", + positionData: body.depth + 0.1 + braceBody.height, + children: [ + {type: "elem", elem: braceBody, + wrapperClasses: ["svg-align"]}, + {type: "kern", size: 0.1}, + {type: "elem", elem: body}, + ], + }, options); + } + + if (supSubGroup) { + // To write the supsub, wrap the first vlist in another vlist: + // They can't all go in the same vlist, because the note might be + // wider than the equation. We want the equation to control the + // brace width. + + // note long note long note + // ┏━━━━━━━━┓ or ┏━━━┓ not ┏━━━━━━━━━┓ + // equation eqn eqn + + const vSpan = makeSpan( + ["minner", (group.isOver ? "mover" : "munder")], + [vlist], options); + + if (group.isOver) { + vlist = makeVList({ + positionType: "firstBaseline", + children: [ + {type: "elem", elem: vSpan}, + {type: "kern", size: 0.2}, + {type: "elem", elem: supSubGroup}, + ], + }, options); + } else { + vlist = makeVList({ + positionType: "bottom", + positionData: vSpan.depth + 0.2 + supSubGroup.height + + supSubGroup.depth, + children: [ + {type: "elem", elem: supSubGroup}, + {type: "kern", size: 0.2}, + {type: "elem", elem: vSpan}, + ], + }, options); + } + } + + return makeSpan( + ["minner", (group.isOver ? "mover" : "munder")], [vlist], options); +}; + +const mathmlBuilder: MathMLBuilder<"horizBrace"> = (group, options) => { + const accentNode = stretchyMathML(group.label); + return new MathNode( + (group.isOver ? "mover" : "munder"), + [mml.buildGroup(group.base, options), accentNode] + ); +}; + +// Horizontal stretchy braces +defineFunction({ + type: "horizBrace", + names: ["\\overbrace", "\\underbrace", "\\overbracket", "\\underbracket"], + numArgs: 1, + + handler({parser, funcName}, args) { + return { + type: "horizBrace", + mode: parser.mode, + label: funcName, + isOver: funcName.includes("\\over"), + base: args[0], + }; + }, + + htmlBuilder, + mathmlBuilder, +}); diff --git a/node_modules/katex/src/functions/href.ts b/node_modules/katex/src/functions/href.ts new file mode 100644 index 0000000..d1dbc73 --- /dev/null +++ b/node_modules/katex/src/functions/href.ts @@ -0,0 +1,92 @@ +import defineFunction, {ordargument} from "../defineFunction"; +import {makeAnchor} from "../buildCommon"; +import {assertNodeType} from "../parseNode"; +import {MathNode} from "../mathMLTree"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; +import type {ParseNode} from "../types/nodes"; + +defineFunction({ + type: "href", + names: ["\\href"], + numArgs: 2, + argTypes: ["url", "original"], + allowedInText: true, + + handler: ({parser}, args) => { + const body = args[1]; + const href = assertNodeType(args[0], "url").url; + + if (!parser.settings.isTrusted({ + command: "\\href", + url: href, + })) { + return parser.formatUnsupportedCmd("\\href"); + } + + return { + type: "href", + mode: parser.mode, + href, + body: ordargument(body), + }; + }, + + htmlBuilder: (group, options) => { + const elements = html.buildExpression(group.body, options, false); + return makeAnchor(group.href, [], elements, options); + }, + mathmlBuilder: (group, options) => { + let math = mml.buildExpressionRow(group.body, options); + if (!(math instanceof MathNode)) { + math = new MathNode("mrow", [math]); + } + (math as MathNode).setAttribute("href", group.href); + return math; + }, +}); + +defineFunction({ + type: "href", + names: ["\\url"], + numArgs: 1, + argTypes: ["url"], + allowedInText: true, + + handler: ({parser}, args) => { + const href = assertNodeType(args[0], "url").url; + + if (!parser.settings.isTrusted({ + command: "\\url", + url: href, + })) { + return parser.formatUnsupportedCmd("\\url"); + } + + const chars: ParseNode<"textord">[] = []; + for (let i = 0; i < href.length; i++) { + let c = href[i]; + if (c === "~") { + c = "\\textasciitilde"; + } + chars.push({ + type: "textord", + mode: "text", + text: c, + }); + } + const body: ParseNode<"text"> = { + type: "text", + mode: parser.mode, + font: "\\texttt", + body: chars, + }; + return { + type: "href", + mode: parser.mode, + href, + body: ordargument(body), + }; + }, +}); diff --git a/node_modules/katex/src/functions/html.ts b/node_modules/katex/src/functions/html.ts new file mode 100644 index 0000000..2ad9238 --- /dev/null +++ b/node_modules/katex/src/functions/html.ts @@ -0,0 +1,105 @@ +import defineFunction, {ordargument} from "../defineFunction"; +import {makeSpan} from "../buildCommon"; +import {assertNodeType} from "../parseNode"; +import ParseError from "../ParseError"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; +import type {AnyTrustContext} from "../Settings"; + +defineFunction({ + type: "html", + names: ["\\htmlClass", "\\htmlId", "\\htmlStyle", "\\htmlData"], + numArgs: 2, + argTypes: ["raw", "original"], + allowedInText: true, + + handler: ({parser, funcName, token}, args) => { + const value = assertNodeType(args[0], "raw").string; + const body = args[1]; + + if (parser.settings.strict) { + parser.settings.reportNonstrict("htmlExtension", + "HTML extension is disabled on strict mode"); + } + + let trustContext: AnyTrustContext; + const attributes: Record = {}; + + switch (funcName) { + case "\\htmlClass": + attributes.class = value; + trustContext = { + command: "\\htmlClass", + class: value, + }; + break; + case "\\htmlId": + attributes.id = value; + trustContext = { + command: "\\htmlId", + id: value, + }; + break; + case "\\htmlStyle": + attributes.style = value; + trustContext = { + command: "\\htmlStyle", + style: value, + }; + break; + case "\\htmlData": { + const data = value.split(","); + for (let i = 0; i < data.length; i++) { + const item = data[i]; + const firstEquals = item.indexOf("="); + if (firstEquals < 0) { + throw new ParseError(`\\htmlData key/value '${item}'` + + ` missing equals sign`); + } + const key = item.slice(0, firstEquals); + const value = item.slice(firstEquals + 1); + attributes["data-" + key.trim()] = value; + } + + trustContext = { + command: "\\htmlData", + attributes, + }; + break; + } + default: + throw new Error("Unrecognized html command"); + } + + if (!parser.settings.isTrusted(trustContext)) { + return parser.formatUnsupportedCmd(funcName); + } + return { + type: "html", + mode: parser.mode, + attributes, + body: ordargument(body), + }; + }, + + htmlBuilder: (group, options) => { + const elements = html.buildExpression(group.body, options, false); + + const classes = ["enclosing"]; + if (group.attributes.class) { + classes.push(...group.attributes.class.trim().split(/\s+/)); + } + + const span = makeSpan(classes, elements, options); + for (const attr in group.attributes) { + if (attr !== "class" && group.attributes.hasOwnProperty(attr)) { + span.setAttribute(attr, group.attributes[attr]); + } + } + return span; + }, + mathmlBuilder: (group, options) => { + return mml.buildExpressionRow(group.body, options); + }, +}); diff --git a/node_modules/katex/src/functions/htmlmathml.ts b/node_modules/katex/src/functions/htmlmathml.ts new file mode 100644 index 0000000..6ed94f3 --- /dev/null +++ b/node_modules/katex/src/functions/htmlmathml.ts @@ -0,0 +1,34 @@ +import defineFunction, {ordargument} from "../defineFunction"; +import {makeFragment} from "../buildCommon"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; + +defineFunction({ + type: "htmlmathml", + names: ["\\html@mathml"], + numArgs: 2, + allowedInArgument: true, + allowedInText: true, + + handler: ({parser}, args) => { + return { + type: "htmlmathml", + mode: parser.mode, + html: ordargument(args[0]), + mathml: ordargument(args[1]), + }; + }, + + htmlBuilder: (group, options) => { + const elements = html.buildExpression( + group.html, + options, + false + ); + return makeFragment(elements); + }, + mathmlBuilder: (group, options) => { + return mml.buildExpressionRow(group.mathml, options); + }, +}); diff --git a/node_modules/katex/src/functions/includegraphics.ts b/node_modules/katex/src/functions/includegraphics.ts new file mode 100644 index 0000000..514a9ee --- /dev/null +++ b/node_modules/katex/src/functions/includegraphics.ts @@ -0,0 +1,150 @@ +import defineFunction from "../defineFunction"; +import {calculateSize, validUnit, makeEm} from "../units"; +import ParseError from "../ParseError"; +import {Img} from "../domTree"; +import {MathNode} from "../mathMLTree"; +import {assertNodeType} from "../parseNode"; +import type {CssStyle} from "../domTree"; +import type {Measurement} from "../types"; + +const sizeData = function(str: string): Measurement { + if (/^[-+]? *(\d+(\.\d*)?|\.\d+)$/.test(str)) { + // str is a number with no unit specified. + // default unit is bp, per graphix package. + return {number: +str, unit: "bp"}; + } else { + const match = (/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/).exec(str); + if (!match) { + throw new ParseError("Invalid size: '" + str + + "' in \\includegraphics"); + } + const data = { + number: +(match[1] + match[2]), // sign + magnitude, cast to number + unit: match[3], + }; + if (!validUnit(data)) { + throw new ParseError("Invalid unit: '" + data.unit + + "' in \\includegraphics."); + } + return data; + } +}; + +defineFunction({ + type: "includegraphics", + names: ["\\includegraphics"], + numArgs: 1, + numOptionalArgs: 1, + argTypes: ["raw", "url"], + allowedInText: false, + + handler: ({parser}, args, optArgs) => { + let width = {number: 0, unit: "em"}; + let height = {number: 0.9, unit: "em"}; // sorta character sized. + let totalheight = {number: 0, unit: "em"}; + let alt = ""; + + if (optArgs[0]) { + const attributeStr = assertNodeType(optArgs[0], "raw").string; + + // Parser.js does not parse key/value pairs. We get a string. + const attributes = attributeStr.split(","); + for (let i = 0; i < attributes.length; i++) { + const keyVal = attributes[i].split("="); + if (keyVal.length === 2) { + const str = keyVal[1].trim(); + switch (keyVal[0].trim()) { + case "alt": + alt = str; + break; + case "width": + width = sizeData(str); + break; + case "height": + height = sizeData(str); + break; + case "totalheight": + totalheight = sizeData(str); + break; + default: + throw new ParseError("Invalid key: '" + keyVal[0] + + "' in \\includegraphics."); + } + } + } + } + + const src = assertNodeType(args[0], "url").url; + + if (alt === "") { + // No alt given. Use the file name. Strip away the path. + alt = src; + alt = alt.replace(/^.*[\\/]/, ''); + alt = alt.substring(0, alt.lastIndexOf('.')); + } + + if (!parser.settings.isTrusted({ + command: "\\includegraphics", + url: src, + })) { + return parser.formatUnsupportedCmd("\\includegraphics"); + } + + return { + type: "includegraphics", + mode: parser.mode, + alt: alt, + width: width, + height: height, + totalheight: totalheight, + src: src, + }; + }, + + htmlBuilder: (group, options) => { + const height = calculateSize(group.height, options); + let depth = 0; + + if (group.totalheight.number > 0) { + depth = calculateSize(group.totalheight, options) - height; + } + + let width = 0; + if (group.width.number > 0) { + width = calculateSize(group.width, options); + } + + const style: CssStyle = {height: makeEm(height + depth)}; + if (width > 0) { + style.width = makeEm(width); + } + if (depth > 0) { + style.verticalAlign = makeEm(-depth); + } + + const node = new Img(group.src, group.alt, style); + node.height = height; + node.depth = depth; + + return node; + }, + mathmlBuilder: (group, options) => { + const node = new MathNode("mglyph", []); + node.setAttribute("alt", group.alt); + + const height = calculateSize(group.height, options); + let depth = 0; + if (group.totalheight.number > 0) { + depth = calculateSize(group.totalheight, options) - height; + node.setAttribute("valign", makeEm(-depth)); + } + node.setAttribute("height", makeEm(height + depth)); + + if (group.width.number > 0) { + const width = calculateSize(group.width, options); + node.setAttribute("width", makeEm(width)); + } + node.setAttribute("src", group.src); + return node; + }, +}); diff --git a/node_modules/katex/src/functions/kern.ts b/node_modules/katex/src/functions/kern.ts new file mode 100644 index 0000000..ca0e7fc --- /dev/null +++ b/node_modules/katex/src/functions/kern.ts @@ -0,0 +1,55 @@ +// Horizontal spacing commands + +import defineFunction from "../defineFunction"; +import {makeGlue} from "../buildCommon"; +import {SpaceNode} from "../mathMLTree"; +import {calculateSize} from "../units"; +import {assertNodeType} from "../parseNode"; + +// TODO: \hskip and \mskip should support plus and minus in lengths + +defineFunction({ + type: "kern", + names: ["\\kern", "\\mkern", "\\hskip", "\\mskip"], + numArgs: 1, + argTypes: ["size"], + primitive: true, + allowedInText: true, + + handler({parser, funcName}, args) { + const size = assertNodeType(args[0], "size"); + if (parser.settings.strict) { + const mathFunction = (funcName[1] === 'm'); // \mkern, \mskip + const muUnit = (size.value.unit === 'mu'); + if (mathFunction) { + if (!muUnit) { + parser.settings.reportNonstrict("mathVsTextUnits", + `LaTeX's ${funcName} supports only mu units, ` + + `not ${size.value.unit} units`); + } + if (parser.mode !== "math") { + parser.settings.reportNonstrict("mathVsTextUnits", + `LaTeX's ${funcName} works only in math mode`); + } + } else { // !mathFunction + if (muUnit) { + parser.settings.reportNonstrict("mathVsTextUnits", + `LaTeX's ${funcName} doesn't support mu units`); + } + } + } + return { + type: "kern", + mode: parser.mode, + dimension: size.value, + }; + }, + + htmlBuilder(group, options) { + return makeGlue(group.dimension, options); + }, + mathmlBuilder(group, options) { + const dimension = calculateSize(group.dimension, options); + return new SpaceNode(dimension); + }, +}); diff --git a/node_modules/katex/src/functions/lap.ts b/node_modules/katex/src/functions/lap.ts new file mode 100644 index 0000000..0d363ee --- /dev/null +++ b/node_modules/katex/src/functions/lap.ts @@ -0,0 +1,73 @@ +// Horizontal overlap functions +import defineFunction from "../defineFunction"; +import {makeSpan} from "../buildCommon"; +import {MathNode} from "../mathMLTree"; +import {makeEm} from "../units"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; + +defineFunction({ + type: "lap", + names: ["\\mathllap", "\\mathrlap", "\\mathclap"], + numArgs: 1, + allowedInText: true, + + handler: ({parser, funcName}, args) => { + const body = args[0]; + return { + type: "lap", + mode: parser.mode, + alignment: funcName.slice(5), + body, + }; + }, + + htmlBuilder: (group, options) => { + // mathllap, mathrlap, mathclap + let inner; + if (group.alignment === "clap") { + // ref: https://www.math.lsu.edu/~aperlis/publications/mathclap/ + inner = makeSpan( + [], [html.buildGroup(group.body, options)]); + // wrap, since CSS will center a .clap > .inner > span + inner = makeSpan(["inner"], [inner], options); + } else { + inner = makeSpan( + ["inner"], [html.buildGroup(group.body, options)]); + } + const fix = makeSpan(["fix"], []); + let node = makeSpan( + [group.alignment], [inner, fix], options); + + // At this point, we have correctly set horizontal alignment of the + // two items involved in the lap. + // Next, use a strut to set the height of the HTML bounding box. + // Otherwise, a tall argument may be misplaced. + // This code resolved issue #1153 + const strut = makeSpan(["strut"]); + strut.style.height = makeEm(node.height + node.depth); + if (node.depth) { + strut.style.verticalAlign = makeEm(-node.depth); + } + node.children.unshift(strut); + + // Next, prevent vertical misplacement when next to something tall. + // This code resolves issue #1234 + node = makeSpan(["thinbox"], [node], options); + return makeSpan(["mord", "vbox"], [node], options); + }, + mathmlBuilder: (group, options) => { + // mathllap, mathrlap, mathclap + const node = new MathNode( + "mpadded", [mml.buildGroup(group.body, options)]); + + if (group.alignment !== "rlap") { + const offset = (group.alignment === "llap" ? "-1" : "-0.5"); + node.setAttribute("lspace", offset + "width"); + } + node.setAttribute("width", "0px"); + + return node; + }, +}); diff --git a/node_modules/katex/src/functions/math.ts b/node_modules/katex/src/functions/math.ts new file mode 100644 index 0000000..85b9696 --- /dev/null +++ b/node_modules/katex/src/functions/math.ts @@ -0,0 +1,40 @@ +import defineFunction from "../defineFunction"; +import ParseError from "../ParseError"; + +// Switching from text mode back to math mode +defineFunction({ + type: "styling", + names: ["\\(", "$"], + numArgs: 0, + allowedInText: true, + allowedInMath: false, + + handler({funcName, parser}, args) { + const outerMode = parser.mode; + parser.switchMode("math"); + const close = (funcName === "\\(" ? "\\)" : "$"); + const body = parser.parseExpression(false, close); + parser.expect(close); + parser.switchMode(outerMode); + return { + type: "styling", + mode: parser.mode, + style: "text", + resetFont: true, + body, + }; + }, +}); + +// Check for extra closing math delimiters +defineFunction({ + type: "text", // Doesn't matter what this is. + names: ["\\)", "\\]"], + numArgs: 0, + allowedInText: true, + allowedInMath: false, + + handler(context, args) { + throw new ParseError(`Mismatched ${context.funcName}`); + }, +}); diff --git a/node_modules/katex/src/functions/mathchoice.ts b/node_modules/katex/src/functions/mathchoice.ts new file mode 100644 index 0000000..15b46c6 --- /dev/null +++ b/node_modules/katex/src/functions/mathchoice.ts @@ -0,0 +1,51 @@ +import defineFunction, {ordargument} from "../defineFunction"; +import {makeFragment} from "../buildCommon"; +import Style from "../Style"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; + +import type Options from "../Options"; +import type {ParseNode} from "../types/nodes"; + +const chooseMathStyle = (group: ParseNode<"mathchoice">, options: Options) => { + switch (options.style.size) { + case Style.DISPLAY.size: return group.display; + case Style.TEXT.size: return group.text; + case Style.SCRIPT.size: return group.script; + case Style.SCRIPTSCRIPT.size: return group.scriptscript; + default: return group.text; + } +}; + +defineFunction({ + type: "mathchoice", + names: ["\\mathchoice"], + numArgs: 4, + primitive: true, + + handler: ({parser}, args) => { + return { + type: "mathchoice", + mode: parser.mode, + display: ordargument(args[0]), + text: ordargument(args[1]), + script: ordargument(args[2]), + scriptscript: ordargument(args[3]), + }; + }, + + htmlBuilder: (group, options) => { + const body = chooseMathStyle(group, options); + const elements = html.buildExpression( + body, + options, + false + ); + return makeFragment(elements); + }, + mathmlBuilder: (group, options) => { + const body = chooseMathStyle(group, options); + return mml.buildExpressionRow(body, options); + }, +}); diff --git a/node_modules/katex/src/functions/mclass.ts b/node_modules/katex/src/functions/mclass.ts new file mode 100644 index 0000000..4c5f3a8 --- /dev/null +++ b/node_modules/katex/src/functions/mclass.ts @@ -0,0 +1,153 @@ +import defineFunction, {ordargument} from "../defineFunction"; +import {makeSpan} from "../buildCommon"; +import {isCharacterBox} from "../utils"; +import {MathNode} from "../mathMLTree"; +import type {AnyParseNode, ParseNode} from "../types/nodes"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; + +import type Options from "../Options"; +import type {MathClass, Slice5} from "../types"; + +function htmlBuilder(group: ParseNode<"mclass">, options: Options) { + const elements = html.buildExpression(group.body, options, true); + return makeSpan([group.mclass], elements, options); +} + +function mathmlBuilder(group: ParseNode<"mclass">, options: Options) { + let node: MathNode; + const inner = mml.buildExpression(group.body, options); + + if (group.mclass === "minner") { + node = new MathNode("mpadded", inner); + } else if (group.mclass === "mord") { + if (group.isCharacterBox) { + node = inner[0]; + node.type = "mi"; + } else { + node = new MathNode("mi", inner); + } + } else { + if (group.isCharacterBox) { + node = inner[0]; + node.type = "mo"; + } else { + node = new MathNode("mo", inner); + } + + // Set spacing based on what is the most likely adjacent atom type. + // See TeXbook p170. + if (group.mclass === "mbin") { + node.attributes.lspace = "0.22em"; // medium space + node.attributes.rspace = "0.22em"; + } else if (group.mclass === "mpunct") { + node.attributes.lspace = "0em"; + node.attributes.rspace = "0.17em"; // thinspace + } else if (group.mclass === "mopen" || group.mclass === "mclose") { + node.attributes.lspace = "0em"; + node.attributes.rspace = "0em"; + } + // MathML default space is 5/18 em, so needs no action. + // Ref: https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mo + } + return node; +} + +// Math class commands except \mathop +defineFunction({ + type: "mclass", + names: [ + "\\mathord", "\\mathbin", "\\mathrel", "\\mathopen", + "\\mathclose", "\\mathpunct", "\\mathinner", + ], + numArgs: 1, + primitive: true, + handler({parser, funcName}, args) { + const body = args[0]; + return { + type: "mclass", + mode: parser.mode, + mclass: `m${funcName.slice(5) as Slice5}`, + body: ordargument(body), + isCharacterBox: isCharacterBox(body), + }; + }, + + htmlBuilder, + mathmlBuilder, +}); + +export const binrelClass = (arg: AnyParseNode): MathClass => { + // \binrel@ spacing varies with (bin|rel|ord) of the atom in the argument. + // (by rendering separately and with {}s before and after, and measuring + // the change in spacing). We'll do roughly the same by detecting the + // atom type directly. + const atom = (arg.type === "ordgroup" && arg.body.length ? arg.body[0] : arg); + if (atom.type === "atom" && (atom.family === "bin" || atom.family === "rel")) { + return `m${atom.family}`; + } else { + return "mord"; + } +}; + +// \@binrel{x}{y} renders like y but as mbin/mrel/mord if x is mbin/mrel/mord. +// This is equivalent to \binrel@{x}\binrel@@{y} in AMSTeX. +defineFunction({ + type: "mclass", + names: ["\\@binrel"], + numArgs: 2, + + handler({parser}, args) { + return { + type: "mclass", + mode: parser.mode, + mclass: binrelClass(args[0]), + body: ordargument(args[1]), + isCharacterBox: isCharacterBox(args[1]), + }; + }, +}); + +// Build a relation or stacked op by placing one symbol on top of another +defineFunction({ + type: "mclass", + names: ["\\stackrel", "\\overset", "\\underset"], + numArgs: 2, + + handler({parser, funcName}, args) { + const baseArg = args[1]; + const shiftedArg = args[0]; + + let mclass: MathClass; + if (funcName !== "\\stackrel") { + // LaTeX applies \binrel spacing to \overset and \underset. + mclass = binrelClass(baseArg); + } else { + mclass = "mrel"; // for \stackrel + } + + const baseOp: ParseNode<"op"> = { + type: "op", + mode: baseArg.mode, + limits: true, + alwaysHandleSupSub: true, + parentIsSupSub: false, + symbol: false, + suppressBaseShift: funcName !== "\\stackrel", + body: ordargument(baseArg), + }; + + const supsub: ParseNode<"supsub"> = funcName === "\\underset" + ? {type: "supsub", mode: shiftedArg.mode, base: baseOp, sub: shiftedArg} + : {type: "supsub", mode: shiftedArg.mode, base: baseOp, sup: shiftedArg}; + + return { + type: "mclass", + mode: parser.mode, + mclass, + body: [supsub], + isCharacterBox: isCharacterBox(supsub), + }; + }, +}); diff --git a/node_modules/katex/src/functions/op.ts b/node_modules/katex/src/functions/op.ts new file mode 100644 index 0000000..aef66b9 --- /dev/null +++ b/node_modules/katex/src/functions/op.ts @@ -0,0 +1,323 @@ +// Limits, symbols +import defineFunction, {ordargument} from "../defineFunction"; +import {mathsym, makeSpan, makeSymbol, makeVList, staticSvg} from "../buildCommon"; +import {SymbolNode} from "../domTree"; +import {MathNode, newDocumentFragment, TextNode} from "../mathMLTree"; +import Style from "../Style"; +import {assembleSupSub} from "./utils/assembleSupSub"; +import {assertNodeType} from "../parseNode"; +import {makeEm} from "../units"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; + +import type {HtmlBuilderSupSub, MathMLBuilder} from "../defineFunction"; +import type {ParseNode} from "../types/nodes"; + +// Most operators have a large successor symbol, but these don't. +const noSuccessor = new Set([ + "\\smallint", +]); + +// NOTE: Unlike most `htmlBuilder`s, this one handles not only "op", but also +// "supsub" since some of them (like \int) can affect super/subscripting. +export const htmlBuilder: HtmlBuilderSupSub<"op"> = (grp, options) => { + // Operators are handled in the TeXbook pg. 443-444, rule 13(a). + let supGroup; + let subGroup; + let hasLimits = false; + let group: ParseNode<"op">; + if (grp.type === "supsub") { + // If we have limits, supsub will pass us its group to handle. Pull + // out the superscript and subscript and set the group to the op in + // its base. + supGroup = grp.sup; + subGroup = grp.sub; + group = assertNodeType(grp.base, "op"); + hasLimits = true; + } else { + group = assertNodeType(grp, "op"); + } + + const style = options.style; + + let large = false; + if (style.size === Style.DISPLAY.size && + group.symbol && + !noSuccessor.has(group.name)) { + + // Most symbol operators get larger in displaystyle (rule 13) + large = true; + } + + let base; + // Italic correction from the symbol glyph, captured before the symbol + // may be wrapped in a vlist (for \oiint/\oiiint). Stays 0 for non-symbol ops. + let symbolItalic; + if (group.symbol) { + // If this is a symbol, create the symbol. + const fontName = large ? "Size2-Regular" : "Size1-Regular"; + + let stash = ""; + if (group.name === "\\oiint" || group.name === "\\oiiint") { + // No font glyphs yet, so use a glyph w/o the oval. + // TODO: When font glyphs are available, delete this code. + stash = group.name.slice(1); + group.name = stash === "oiint" ? "\\iint" : "\\iiint"; + } + + base = makeSymbol( + group.name, fontName, "math", options, + ["mop", "op-symbol", large ? "large-op" : "small-op"]); + symbolItalic = base.italic; + + if (stash.length > 0) { + // We're in \oiint or \oiiint. Overlay the oval. + // TODO: When font glyphs are available, delete this code. + const oval = staticSvg(stash + "Size" + + (large ? "2" : "1"), options); + base = makeVList({ + positionType: "individualShift", + children: [ + {type: "elem", elem: base, shift: 0}, + {type: "elem", elem: oval, shift: large ? 0.08 : 0}, + ], + }, options); + group.name = "\\" + stash; + base.classes.unshift("mop"); + // Carry the italic correction from the original symbol to the + // vlist wrapper so supsub can use it for subscript positioning. + base.italic = symbolItalic; + } + } else if (group.body) { + // If this is a list, compose that list. + const inner = html.buildExpression(group.body, options, true); + if (inner.length === 1 && inner[0] instanceof SymbolNode) { + base = inner[0]; + base.classes[0] = "mop"; // replace old mclass + } else { + base = makeSpan(["mop"], inner, options); + } + } else { + // Otherwise, this is a text operator. Build the text from the + // operator's name. + const output = []; + for (let i = 1; i < group.name!.length; i++) { + output.push(mathsym(group.name![i], group.mode, options)); + } + base = makeSpan(["mop"], output, options); + } + + // If content of op is a single symbol, shift it vertically. + let baseShift = 0; + let slant = 0; + if ((base instanceof SymbolNode + || group.name === "\\oiint" || group.name === "\\oiiint") + && !group.suppressBaseShift) { + // We suppress the shift of the base of \overset and \underset. Otherwise, + // shift the symbol so its center lies on the axis (rule 13). It + // appears that our fonts have the centers of the symbols already + // almost on the axis, so these numbers are very small. Note we + // don't actually apply this here, but instead it is used either in + // the vlist creation or separately when there are no limits. + baseShift = (base.height - base.depth) / 2 - + options.fontMetrics().axisHeight; + + // The slant of the symbol is just its italic correction. + // SymbolNode carries .italic natively; Span (for \oiint/\oiiint) + // only has it set when nonzero, so default to 0. + slant = base.italic ?? 0; + } + + if (hasLimits) { + return assembleSupSub(base, supGroup, subGroup, options, + style, slant, baseShift); + + } else { + if (baseShift) { + base.style.position = "relative"; + base.style.top = makeEm(baseShift); + } + + return base; + } +}; + +const mathmlBuilder: MathMLBuilder<"op"> = (group, options) => { + let node; + + if (group.symbol) { + // This is a symbol. Just add the symbol. + node = new MathNode( + "mo", [mml.makeText(group.name, group.mode)]); + if (noSuccessor.has(group.name)) { + node.setAttribute("largeop", "false"); + } + } else if (group.body) { + // This is an operator with children. Add them. + node = new MathNode( + "mo", mml.buildExpression(group.body, options)); + } else { + // This is a text operator. Add all the characters from the + // operator's name. + node = new MathNode( + "mi", [new TextNode(group.name!.slice(1))]); + // Append an . + // ref: https://www.w3.org/TR/REC-MathML/chap3_2.html#sec3.2.4 + const operator = new MathNode("mo", + [mml.makeText("\u2061", "text")]); + if (group.parentIsSupSub) { + node = new MathNode("mrow", [node, operator]); + } else { + node = newDocumentFragment([node, operator]); + } + } + + return node; +}; + +const singleCharBigOps: Record = { + "\u220F": "\\prod", + "\u2210": "\\coprod", + "\u2211": "\\sum", + "\u22c0": "\\bigwedge", + "\u22c1": "\\bigvee", + "\u22c2": "\\bigcap", + "\u22c3": "\\bigcup", + "\u2a00": "\\bigodot", + "\u2a01": "\\bigoplus", + "\u2a02": "\\bigotimes", + "\u2a04": "\\biguplus", + "\u2a06": "\\bigsqcup", +}; + +defineFunction({ + type: "op", + names: [ + "\\coprod", "\\bigvee", "\\bigwedge", "\\biguplus", "\\bigcap", + "\\bigcup", "\\intop", "\\prod", "\\sum", "\\bigotimes", + "\\bigoplus", "\\bigodot", "\\bigsqcup", "\\smallint", "\u220F", + "\u2210", "\u2211", "\u22c0", "\u22c1", "\u22c2", "\u22c3", "\u2a00", + "\u2a01", "\u2a02", "\u2a04", "\u2a06", + ], + numArgs: 0, + + handler: ({parser, funcName}, args) => { + let fName: string = funcName; + if (fName.length === 1) { + fName = singleCharBigOps[fName]; + } + return { + type: "op", + mode: parser.mode, + limits: true, + parentIsSupSub: false, + symbol: true, + name: fName, + }; + }, + + htmlBuilder, + mathmlBuilder, +}); + +defineFunction({ + type: "op", + names: ["\\mathop"], + numArgs: 1, + primitive: true, + + handler: ({parser}, args) => { + const body = args[0]; + return { + type: "op", + mode: parser.mode, + limits: false, + parentIsSupSub: false, + symbol: false, + body: ordargument(body), + }; + }, +}); + +// There are 2 flags for operators; whether they produce limits in +// displaystyle, and whether they are symbols and should grow in +// displaystyle. These four groups cover the four possible choices. +const singleCharIntegrals: Record = { + "\u222b": "\\int", + "\u222c": "\\iint", + "\u222d": "\\iiint", + "\u222e": "\\oint", + "\u222f": "\\oiint", + "\u2230": "\\oiiint", +}; + +// No limits, not symbols +defineFunction({ + type: "op", + names: [ + "\\arcsin", "\\arccos", "\\arctan", "\\arctg", "\\arcctg", + "\\arg", "\\ch", "\\cos", "\\cosec", "\\cosh", "\\cot", "\\cotg", + "\\coth", "\\csc", "\\ctg", "\\cth", "\\deg", "\\dim", "\\exp", + "\\hom", "\\ker", "\\lg", "\\ln", "\\log", "\\sec", "\\sin", + "\\sinh", "\\sh", "\\tan", "\\tanh", "\\tg", "\\th", + ], + numArgs: 0, + + handler({parser, funcName}) { + return { + type: "op", + mode: parser.mode, + limits: false, + parentIsSupSub: false, + symbol: false, + name: funcName, + }; + }, +}); + +// Limits, not symbols +defineFunction({ + type: "op", + names: [ + "\\det", "\\gcd", "\\inf", "\\lim", "\\max", "\\min", "\\Pr", "\\sup", + ], + numArgs: 0, + + handler({parser, funcName}) { + return { + type: "op", + mode: parser.mode, + limits: true, + parentIsSupSub: false, + symbol: false, + name: funcName, + }; + }, +}); + +// No limits, symbols +defineFunction({ + type: "op", + names: [ + "\\int", "\\iint", "\\iiint", "\\oint", "\\oiint", "\\oiiint", + "\u222b", "\u222c", "\u222d", "\u222e", "\u222f", "\u2230", + ], + numArgs: 0, + allowedInArgument: true, + + handler({parser, funcName}) { + let fName: string = funcName; + if (fName.length === 1) { + fName = singleCharIntegrals[fName]; + } + return { + type: "op", + mode: parser.mode, + limits: false, + parentIsSupSub: false, + symbol: true, + name: fName, + }; + }, +}); diff --git a/node_modules/katex/src/functions/operatorname.ts b/node_modules/katex/src/functions/operatorname.ts new file mode 100644 index 0000000..bf84b66 --- /dev/null +++ b/node_modules/katex/src/functions/operatorname.ts @@ -0,0 +1,161 @@ +import defineFunction, {ordargument} from "../defineFunction"; +import defineMacro from "../defineMacro"; +import {makeSpan} from "../buildCommon"; +import {MathNode, newDocumentFragment, SpaceNode, TextNode} from "../mathMLTree"; +import {SymbolNode} from "../domTree"; +import {assembleSupSub} from "./utils/assembleSupSub"; +import {assertNodeType} from "../parseNode"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; + +import type {HtmlBuilderSupSub, MathMLBuilder} from "../defineFunction"; +import type {AnyParseNode, ParseNode} from "../types/nodes"; + +// NOTE: Unlike most `htmlBuilder`s, this one handles not only +// "operatorname", but also "supsub" since \operatorname* can +// affect super/subscripting. +export const htmlBuilder: HtmlBuilderSupSub<"operatorname"> = (grp, options) => { + // Operators are handled in the TeXbook pg. 443-444, rule 13(a). + let supGroup; + let subGroup; + let hasLimits = false; + let group: ParseNode<"operatorname">; + if (grp.type === "supsub") { + // If we have limits, supsub will pass us its group to handle. Pull + // out the superscript and subscript and set the group to the op in + // its base. + supGroup = grp.sup; + subGroup = grp.sub; + group = assertNodeType(grp.base, "operatorname"); + hasLimits = true; + } else { + group = assertNodeType(grp, "operatorname"); + } + + let base; + if (group.body.length > 0) { + const body = group.body.map((child): AnyParseNode => { + const childText = "text" in child ? child.text : undefined; + if (typeof childText === "string") { + return { + type: "textord", + mode: child.mode, + text: childText, + }; + } else { + return child; + } + }); + + // Consolidate function names into symbol characters. + const expression = html.buildExpression( + body, options.withFont("mathrm"), true); + + for (let i = 0; i < expression.length; i++) { + const child = expression[i]; + if (child instanceof SymbolNode) { + // Per amsopn package, + // change minus to hyphen and \ast to asterisk + child.text = child.text.replace(/\u2212/, "-") + .replace(/\u2217/, "*"); + } + } + base = makeSpan(["mop"], expression, options); + } else { + base = makeSpan(["mop"], [], options); + } + + if (hasLimits) { + return assembleSupSub(base, supGroup, subGroup, options, + options.style, 0, 0); + + } else { + return base; + } +}; + +const mathmlBuilder: MathMLBuilder<"operatorname"> = (group, options) => { + // The steps taken here are similar to the html version. + let expression: Array = mml.buildExpression( + group.body, options.withFont("mathrm")); + + // Is expression a string or has it something like a fraction? + let isAllString = true; // default + for (let i = 0; i < expression.length; i++) { + const node = expression[i]; + if (node instanceof SpaceNode) { + // Do nothing + } else if (node instanceof MathNode) { + switch (node.type) { + case "mi": + case "mn": + case "mspace": + case "mtext": + break; // Do nothing yet. + case "mo": { + const child = node.children[0]; + if (node.children.length === 1 && + child instanceof TextNode) { + child.text = + child.text.replace(/\u2212/, "-") + .replace(/\u2217/, "*"); + } else { + isAllString = false; + } + break; + } + default: + isAllString = false; + } + } else { + isAllString = false; + } + } + + if (isAllString) { + // Write a single TextNode instead of multiple nested tags. + const word = expression.map(node => node.toText()).join(""); + expression = [new TextNode(word)]; + } + + const identifier = new MathNode("mi", expression); + identifier.setAttribute("mathvariant", "normal"); + + // \u2061 is the same as ⁡ + // ref: https://www.w3schools.com/charsets/ref_html_entities_a.asp + const operator = new MathNode("mo", + [mml.makeText("\u2061", "text")]); + + if (group.parentIsSupSub) { + return new MathNode("mrow", [identifier, operator]); + } else { + return newDocumentFragment([identifier, operator]); + } +}; + +// \operatorname +// amsopn.dtx: \mathop{#1\kern\z@\operator@font#3}\newmcodes@ +defineFunction({ + type: "operatorname", + names: ["\\operatorname@", "\\operatornamewithlimits"], + numArgs: 1, + + handler: ({parser, funcName}, args) => { + const body = args[0]; + return { + type: "operatorname", + mode: parser.mode, + body: ordargument(body), + alwaysHandleSupSub: (funcName === "\\operatornamewithlimits"), + limits: false, + parentIsSupSub: false, + }; + }, + + htmlBuilder, + mathmlBuilder, +}); + +defineMacro("\\operatorname", + "\\@ifstar\\operatornamewithlimits\\operatorname@"); diff --git a/node_modules/katex/src/functions/ordgroup.ts b/node_modules/katex/src/functions/ordgroup.ts new file mode 100644 index 0000000..adf828a --- /dev/null +++ b/node_modules/katex/src/functions/ordgroup.ts @@ -0,0 +1,20 @@ +import {defineFunctionBuilders} from "../defineFunction"; +import {makeFragment, makeSpan} from "../buildCommon"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; + +defineFunctionBuilders({ + type: "ordgroup", + htmlBuilder(group, options) { + if (group.semisimple) { + return makeFragment( + html.buildExpression(group.body, options, false)); + } + return makeSpan( + ["mord"], html.buildExpression(group.body, options, true), options); + }, + mathmlBuilder(group, options) { + return mml.buildExpressionRow(group.body, options, true); + }, +}); diff --git a/node_modules/katex/src/functions/overline.ts b/node_modules/katex/src/functions/overline.ts new file mode 100644 index 0000000..c7e2a33 --- /dev/null +++ b/node_modules/katex/src/functions/overline.ts @@ -0,0 +1,58 @@ +import defineFunction from "../defineFunction"; +import {makeLineSpan, makeSpan, makeVList} from "../buildCommon"; +import {MathNode, TextNode} from "../mathMLTree"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; + +defineFunction({ + type: "overline", + names: ["\\overline"], + numArgs: 1, + + handler({parser}, args) { + const body = args[0]; + return { + type: "overline", + mode: parser.mode, + body, + }; + }, + + htmlBuilder(group, options) { + // Overlines are handled in the TeXbook pg 443, Rule 9. + + // Build the inner group in the cramped style. + const innerGroup = html.buildGroup(group.body, + options.havingCrampedStyle()); + + // Create the line above the body + const line = makeLineSpan("overline-line", options); + + // Generate the vlist, with the appropriate kerns + const defaultRuleThickness = options.fontMetrics().defaultRuleThickness; + const vlist = makeVList({ + positionType: "firstBaseline", + children: [ + {type: "elem", elem: innerGroup}, + {type: "kern", size: 3 * defaultRuleThickness}, + {type: "elem", elem: line}, + {type: "kern", size: defaultRuleThickness}, + ], + }, options); + + return makeSpan(["mord", "overline"], [vlist], options); + }, + mathmlBuilder(group, options) { + const operator = new MathNode( + "mo", [new TextNode("\u203e")]); + operator.setAttribute("stretchy", "true"); + + const node = new MathNode( + "mover", + [mml.buildGroup(group.body, options), operator]); + node.setAttribute("accent", "true"); + + return node; + }, +}); diff --git a/node_modules/katex/src/functions/phantom.ts b/node_modules/katex/src/functions/phantom.ts new file mode 100644 index 0000000..575f33d --- /dev/null +++ b/node_modules/katex/src/functions/phantom.ts @@ -0,0 +1,73 @@ +import defineFunction, {ordargument} from "../defineFunction"; +import defineMacro from "../defineMacro"; +import {makeFragment, makeSpan} from "../buildCommon"; +import {MathNode} from "../mathMLTree"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; + +defineFunction({ + type: "phantom", + names: ["\\phantom"], + numArgs: 1, + allowedInText: true, + + handler: ({parser}, args) => { + const body = args[0]; + return { + type: "phantom", + mode: parser.mode, + body: ordargument(body), + }; + }, + + htmlBuilder: (group, options) => { + const elements = html.buildExpression( + group.body, + options.withPhantom(), + false + ); + + // \phantom isn't supposed to affect the elements it contains. + // See "color" for more details. + return makeFragment(elements); + }, + mathmlBuilder: (group, options) => { + const inner = mml.buildExpression(group.body, options); + return new MathNode("mphantom", inner); + }, +}); + +defineMacro("\\hphantom", "\\smash{\\phantom{#1}}"); + +defineFunction({ + type: "vphantom", + names: ["\\vphantom"], + numArgs: 1, + allowedInText: true, + + handler: ({parser}, args) => { + const body = args[0]; + return { + type: "vphantom", + mode: parser.mode, + body, + }; + }, + + htmlBuilder: (group, options) => { + const inner = makeSpan( + ["inner"], + [html.buildGroup(group.body, options.withPhantom())]); + const fix = makeSpan(["fix"], []); + return makeSpan( + ["mord", "rlap"], [inner, fix], options); + }, + mathmlBuilder: (group, options) => { + const inner = mml.buildExpression(ordargument(group.body), options); + const phantom = new MathNode("mphantom", inner); + const node = new MathNode("mpadded", [phantom]); + node.setAttribute("width", "0px"); + return node; + }, +}); diff --git a/node_modules/katex/src/functions/pmb.ts b/node_modules/katex/src/functions/pmb.ts new file mode 100644 index 0000000..8a65b4c --- /dev/null +++ b/node_modules/katex/src/functions/pmb.ts @@ -0,0 +1,43 @@ +import defineFunction, {ordargument} from "../defineFunction"; +import {makeSpan} from "../buildCommon"; +import {MathNode} from "../mathMLTree"; +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; +import {binrelClass} from "./mclass"; + +import type {ParseNode} from "../types/nodes"; + +// \pmb is a simulation of bold font. +// The version of \pmb in ambsy.sty works by typesetting three copies +// with small offsets. We use CSS text-shadow. +// It's a hack. Not as good as a real bold font. Better than nothing. + +defineFunction({ + type: "pmb", + names: ["\\pmb"], + numArgs: 1, + allowedInText: true, + + handler({parser}, args) { + return { + type: "pmb", + mode: parser.mode, + mclass: binrelClass(args[0]), + body: ordargument(args[0]), + }; + }, + + htmlBuilder(group: ParseNode<"pmb">, options) { + const elements = html.buildExpression(group.body, options, true); + const node = makeSpan([group.mclass], elements, options); + node.style.textShadow = "0.02em 0.01em 0.04px"; + return node; + }, + mathmlBuilder(group: ParseNode<"pmb">, style) { + const inner = mml.buildExpression(group.body, style); + // Wrap with an element. + const node = new MathNode("mstyle", inner); + node.setAttribute("style", "text-shadow: 0.02em 0.01em 0.04px"); + return node; + }, +}); diff --git a/node_modules/katex/src/functions/raisebox.ts b/node_modules/katex/src/functions/raisebox.ts new file mode 100644 index 0000000..9add1d5 --- /dev/null +++ b/node_modules/katex/src/functions/raisebox.ts @@ -0,0 +1,45 @@ +import defineFunction from "../defineFunction"; +import {makeVList} from "../buildCommon"; +import {MathNode} from "../mathMLTree"; +import {assertNodeType} from "../parseNode"; +import {calculateSize} from "../units"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; + +// Box manipulation +defineFunction({ + type: "raisebox", + names: ["\\raisebox"], + numArgs: 2, + argTypes: ["size", "hbox"], + allowedInText: true, + + handler({parser}, args) { + const amount = assertNodeType(args[0], "size").value; + const body = args[1]; + return { + type: "raisebox", + mode: parser.mode, + dy: amount, + body, + }; + }, + + htmlBuilder(group, options) { + const body = html.buildGroup(group.body, options); + const dy = calculateSize(group.dy, options); + return makeVList({ + positionType: "shift", + positionData: -dy, + children: [{type: "elem", elem: body}], + }, options); + }, + mathmlBuilder(group, options) { + const node = new MathNode( + "mpadded", [mml.buildGroup(group.body, options)]); + const dy = group.dy.number + group.dy.unit; + node.setAttribute("voffset", dy); + return node; + }, +}); diff --git a/node_modules/katex/src/functions/relax.ts b/node_modules/katex/src/functions/relax.ts new file mode 100644 index 0000000..2b4395d --- /dev/null +++ b/node_modules/katex/src/functions/relax.ts @@ -0,0 +1,16 @@ +import defineFunction from "../defineFunction"; + +defineFunction({ + type: "internal", + names: ["\\relax"], + numArgs: 0, + allowedInText: true, + allowedInArgument: true, + + handler({parser}) { + return { + type: "internal", + mode: parser.mode, + }; + }, +}); diff --git a/node_modules/katex/src/functions/rule.ts b/node_modules/katex/src/functions/rule.ts new file mode 100644 index 0000000..29d4a00 --- /dev/null +++ b/node_modules/katex/src/functions/rule.ts @@ -0,0 +1,76 @@ +import {makeSpan} from "../buildCommon"; +import defineFunction from "../defineFunction"; +import {MathNode} from "../mathMLTree"; +import {assertNodeType} from "../parseNode"; +import {calculateSize, makeEm} from "../units"; + +defineFunction({ + type: "rule", + names: ["\\rule"], + numArgs: 2, + numOptionalArgs: 1, + allowedInText: true, + allowedInMath: true, + argTypes: ["size", "size", "size"], + + handler({parser}, args, optArgs) { + const shift = optArgs[0]; + const width = assertNodeType(args[0], "size"); + const height = assertNodeType(args[1], "size"); + return { + type: "rule", + mode: parser.mode, + shift: shift && assertNodeType(shift, "size").value, + width: width.value, + height: height.value, + }; + }, + + htmlBuilder(group, options) { + // Make an empty span for the rule + const rule = makeSpan(["mord", "rule"], [], options); + + // Calculate the shift, width, and height of the rule, and account for units + const width = calculateSize(group.width, options); + const height = calculateSize(group.height, options); + const shift = (group.shift) ? calculateSize(group.shift, options) : 0; + + // Style the rule to the right size + rule.style.borderRightWidth = makeEm(width); + rule.style.borderTopWidth = makeEm(height); + rule.style.bottom = makeEm(shift); + + // Record the height and width + rule.width = width; + rule.height = height + shift; + rule.depth = -shift; + // Font size is the number large enough that the browser will + // reserve at least `absHeight` space above the baseline. + // The 1.125 factor was empirically determined + rule.maxFontSize = height * 1.125 * options.sizeMultiplier; + + return rule; + }, + mathmlBuilder(group, options) { + const width = calculateSize(group.width, options); + const height = calculateSize(group.height, options); + const shift = (group.shift) ? calculateSize(group.shift, options) : 0; + const color = options.color && options.getColor() || "black"; + + const rule = new MathNode("mspace"); + rule.setAttribute("mathbackground", color); + rule.setAttribute("width", makeEm(width)); + rule.setAttribute("height", makeEm(height)); + + const wrapper = new MathNode("mpadded", [rule]); + if (shift >= 0) { + wrapper.setAttribute("height", makeEm(shift)); + } else { + wrapper.setAttribute("height", makeEm(shift)); + wrapper.setAttribute("depth", makeEm(-shift)); + } + wrapper.setAttribute("voffset", makeEm(shift)); + + return wrapper; + }, +}); diff --git a/node_modules/katex/src/functions/sizing.ts b/node_modules/katex/src/functions/sizing.ts new file mode 100644 index 0000000..a995698 --- /dev/null +++ b/node_modules/katex/src/functions/sizing.ts @@ -0,0 +1,90 @@ +import {makeFragment} from "../buildCommon"; +import defineFunction from "../defineFunction"; +import {MathNode} from "../mathMLTree"; +import {makeEm} from "../units"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; + +import type Options from "../Options"; +import type {AnyParseNode} from "../types/nodes"; +import type {HtmlBuilder} from "../defineFunction"; +import type {documentFragment as HtmlDocumentFragment} from "../domTree"; + +export function sizingGroup( + value: AnyParseNode[], + options: Options, + baseOptions: Options, +): HtmlDocumentFragment { + const inner = html.buildExpression(value, options, false); + const multiplier = options.sizeMultiplier / baseOptions.sizeMultiplier; + + // Add size-resetting classes to the inner list and set maxFontSize + // manually. Handle nested size changes. + for (let i = 0; i < inner.length; i++) { + const pos = inner[i].classes.indexOf("sizing"); + if (pos < 0) { + Array.prototype.push.apply(inner[i].classes, + options.sizingClasses(baseOptions)); + } else if (inner[i].classes[pos + 1] === "reset-size" + options.size) { + // This is a nested size change: e.g., inner[i] is the "b" in + // `\Huge a \small b`. Override the old size (the `reset-` class) + // but not the new size. + inner[i].classes[pos + 1] = "reset-size" + baseOptions.size; + } + + inner[i].height *= multiplier; + inner[i].depth *= multiplier; + } + + return makeFragment(inner); +} + +const sizeFuncs = [ + "\\tiny", "\\sixptsize", "\\scriptsize", "\\footnotesize", "\\small", + "\\normalsize", "\\large", "\\Large", "\\LARGE", "\\huge", "\\Huge", +] as const; + +export const htmlBuilder: HtmlBuilder<"sizing"> = (group, options) => { + // Handle sizing operators like \Huge. Real TeX doesn't actually allow + // these functions inside of math expressions, so we do some special + // handling. + const newOptions = options.havingSize(group.size); + return sizingGroup(group.body, newOptions, options); +}; + +defineFunction({ + type: "sizing", + names: sizeFuncs, + numArgs: 0, + allowedInText: true, + + handler: ({breakOnTokenText, funcName, parser}, args) => { + const body = parser.parseExpression(false, breakOnTokenText); + + return { + type: "sizing", + mode: parser.mode, + // Figure out what size to use based on the list of functions above + size: sizeFuncs.indexOf(funcName) + 1, + body, + }; + }, + + htmlBuilder, + mathmlBuilder: (group, options) => { + const newOptions = options.havingSize(group.size); + const inner = mml.buildExpression(group.body, newOptions); + + const node = new MathNode("mstyle", inner); + + // TODO(emily): This doesn't produce the correct size for nested size + // changes, because we don't keep state of what style we're currently + // in, so we can't reset the size to normal before changing it. Now + // that we're passing an options parameter we should be able to fix + // this. + node.setAttribute("mathsize", makeEm(newOptions.sizeMultiplier)); + + return node; + }, +}); diff --git a/node_modules/katex/src/functions/smash.ts b/node_modules/katex/src/functions/smash.ts new file mode 100644 index 0000000..ef98fb9 --- /dev/null +++ b/node_modules/katex/src/functions/smash.ts @@ -0,0 +1,115 @@ +// smash, with optional [tb], as in AMS +import defineFunction from "../defineFunction"; +import {makeSpan, makeVList} from "../buildCommon"; +import {MathNode} from "../mathMLTree"; +import {assertNodeType, assertSymbolNodeType} from "../parseNode"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; + +defineFunction({ + type: "smash", + names: ["\\smash"], + numArgs: 1, + numOptionalArgs: 1, + allowedInText: true, + + handler: ({parser}, args, optArgs) => { + let smashHeight = false; + let smashDepth = false; + const tbArg = optArgs[0] && assertNodeType(optArgs[0], "ordgroup"); + if (tbArg) { + // Optional [tb] argument is engaged. + // ref: amsmath: \renewcommand{\smash}[1][tb]{% + // def\mb@t{\ht}\def\mb@b{\dp}\def\mb@tb{\ht\z@\z@\dp}% + let letter; + for (let i = 0; i < tbArg.body.length; ++i) { + const node = tbArg.body[i]; + letter = assertSymbolNodeType(node).text; + if (letter === "t") { + smashHeight = true; + } else if (letter === "b") { + smashDepth = true; + } else { + smashHeight = false; + smashDepth = false; + break; + } + } + } else { + smashHeight = true; + smashDepth = true; + } + + const body = args[0]; + return { + type: "smash", + mode: parser.mode, + body, + smashHeight, + smashDepth, + }; + }, + + htmlBuilder: (group, options) => { + const node = makeSpan( + [], [html.buildGroup(group.body, options)]); + + if (!group.smashHeight && !group.smashDepth) { + return node; + } + + if (group.smashHeight) { + node.height = 0; + } + + if (group.smashDepth) { + node.depth = 0; + } + + if (group.smashHeight && group.smashDepth) { + // Symmetric \smash can stay in inline layout. + return makeSpan(["mord", "smash"], [node], options); + } + + // In order to influence makeVList for asymmetric smashing, we have to + // reset the children. + if (node.children) { + for (let i = 0; i < node.children.length; i++) { + if (group.smashHeight) { + node.children[i].height = 0; + } + if (group.smashDepth) { + node.children[i].depth = 0; + } + } + } + + // At this point, we've reset the TeX-like height and depth values. + // But the span still has an HTML line height. + // makeVList applies "display: table-cell", which prevents the browser + // from acting on that line height. So we'll call makeVList now. + + const smashedNode = makeVList({ + positionType: "firstBaseline", + children: [{type: "elem", elem: node}], + }, options); + + // For spacing, TeX treats \smash as a math group (same spacing as ord). + return makeSpan(["mord"], [smashedNode], options); + }, + mathmlBuilder: (group, options) => { + const node = new MathNode( + "mpadded", [mml.buildGroup(group.body, options)]); + + if (group.smashHeight) { + node.setAttribute("height", "0px"); + } + + if (group.smashDepth) { + node.setAttribute("depth", "0px"); + } + + return node; + }, +}); diff --git a/node_modules/katex/src/functions/sqrt.ts b/node_modules/katex/src/functions/sqrt.ts new file mode 100644 index 0000000..642e245 --- /dev/null +++ b/node_modules/katex/src/functions/sqrt.ts @@ -0,0 +1,124 @@ +import defineFunction from "../defineFunction"; +import {makeSpan, makeVList, wrapFragment} from "../buildCommon"; +import {MathNode} from "../mathMLTree"; +import {makeSqrtImage} from "../delimiter"; +import Style from "../Style"; +import {makeEm} from "../units"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; + +defineFunction({ + type: "sqrt", + names: ["\\sqrt"], + numArgs: 1, + numOptionalArgs: 1, + + handler({parser}, args, optArgs) { + const index = optArgs[0]; + const body = args[0]; + return { + type: "sqrt", + mode: parser.mode, + body, + index, + }; + }, + + htmlBuilder(group, options) { + // Square roots are handled in the TeXbook pg. 443, Rule 11. + + // First, we do the same steps as in overline to build the inner group + // and line + let inner = html.buildGroup(group.body, options.havingCrampedStyle()); + if (inner.height === 0) { + // Render a small surd. + inner.height = options.fontMetrics().xHeight; + } + + // Some groups can return document fragments. Handle those by wrapping + // them in a span. + inner = wrapFragment(inner, options); + + // Calculate the minimum size for the \surd delimiter + const metrics = options.fontMetrics(); + const theta = metrics.defaultRuleThickness; + + let phi = theta; + if (options.style.id < Style.TEXT.id) { + phi = options.fontMetrics().xHeight; + } + + // Calculate the clearance between the body and line + let lineClearance = theta + phi / 4; + + const minDelimiterHeight = (inner.height + inner.depth + + lineClearance + theta); + + // Create a sqrt SVG of the required minimum size + const {span: img, ruleWidth, advanceWidth} = + makeSqrtImage(minDelimiterHeight, options); + + const delimDepth = img.height - ruleWidth; + + // Adjust the clearance based on the delimiter size + if (delimDepth > inner.height + inner.depth + lineClearance) { + lineClearance = + (lineClearance + delimDepth - inner.height - inner.depth) / 2; + } + + // Shift the sqrt image + const imgShift = img.height - inner.height - lineClearance - ruleWidth; + + inner.style.paddingLeft = makeEm(advanceWidth); + + // Overlay the image and the argument. + const body = makeVList({ + positionType: "firstBaseline", + children: [ + {type: "elem", elem: inner, wrapperClasses: ["svg-align"]}, + {type: "kern", size: -(inner.height + imgShift)}, + {type: "elem", elem: img}, + {type: "kern", size: ruleWidth}, + ], + }, options); + + if (!group.index) { + return makeSpan(["mord", "sqrt"], [body], options); + } else { + // Handle the optional root index + + // The index is always in scriptscript style + const newOptions = options.havingStyle(Style.SCRIPTSCRIPT); + const rootm = html.buildGroup(group.index, newOptions, options); + + // The amount the index is shifted by. This is taken from the TeX + // source, in the definition of `\r@@t`. + const toShift = 0.6 * (body.height - body.depth); + + // Build a VList with the superscript shifted up correctly + const rootVList = makeVList({ + positionType: "shift", + positionData: -toShift, + children: [{type: "elem", elem: rootm}], + }, options); + // Add a class surrounding it so we can add on the appropriate + // kerning + const rootVListWrap = makeSpan(["root"], [rootVList]); + + return makeSpan(["mord", "sqrt"], + [rootVListWrap, body], options); + } + }, + mathmlBuilder(group, options) { + const {body, index} = group; + return index ? + new MathNode( + "mroot", [ + mml.buildGroup(body, options), + mml.buildGroup(index, options), + ]) : + new MathNode( + "msqrt", [mml.buildGroup(body, options)]); + }, +}); diff --git a/node_modules/katex/src/functions/styling.ts b/node_modules/katex/src/functions/styling.ts new file mode 100644 index 0000000..858e582 --- /dev/null +++ b/node_modules/katex/src/functions/styling.ts @@ -0,0 +1,85 @@ +import defineFunction from "../defineFunction"; +import {MathNode} from "../mathMLTree"; +import Style from "../Style"; +import {sizingGroup} from "./sizing"; + +import * as mml from "../buildMathML"; +import type {StyleStr} from "../types"; + +const styleMap: Record = { + "display": Style.DISPLAY, + "text": Style.TEXT, + "script": Style.SCRIPT, + "scriptscript": Style.SCRIPTSCRIPT, +}; + +function isStyleStr(s: string): s is StyleStr { + return s in styleMap; +} + +defineFunction({ + type: "styling", + names: [ + "\\displaystyle", "\\textstyle", "\\scriptstyle", + "\\scriptscriptstyle", + ], + numArgs: 0, + allowedInText: true, + primitive: true, + + handler({breakOnTokenText, funcName, parser}, args) { + // parse out the implicit body + const body = parser.parseExpression(true, breakOnTokenText); + + // TODO: Refactor to avoid duplicating styleMap in multiple places (e.g. + // here and in buildHTML and de-dupe the enumeration of all the styles). + const style = funcName.slice(1, funcName.length - 5); + if (!isStyleStr(style)) { + throw new Error(`Unknown style: ${style}`); + } + return { + type: "styling", + mode: parser.mode, + // Figure out what style to use by pulling out the style from + // the function name + style, + body, + }; + }, + + htmlBuilder(group, options) { + // Style changes are handled in the TeXbook on pg. 442, Rule 3. + const newStyle = styleMap[group.style]; + let newOptions = options.havingStyle(newStyle); + if (group.resetFont) { + newOptions = newOptions.withFont(''); + } + return sizingGroup(group.body, newOptions, options); + }, + mathmlBuilder(group, options) { + // Figure out what style we're changing to. + const newStyle = styleMap[group.style]; + let newOptions = options.havingStyle(newStyle); + if (group.resetFont) { + newOptions = newOptions.withFont(''); + } + + const inner = mml.buildExpression(group.body, newOptions); + + const node = new MathNode("mstyle", inner); + + const styleAttributes = { + "display": ["0", "true"], + "text": ["0", "false"], + "script": ["1", "false"], + "scriptscript": ["2", "false"], + }; + + const attr = styleAttributes[group.style]; + + node.setAttribute("scriptlevel", attr[0]); + node.setAttribute("displaystyle", attr[1]); + + return node; + }, +}); diff --git a/node_modules/katex/src/functions/supsub.ts b/node_modules/katex/src/functions/supsub.ts new file mode 100644 index 0000000..cd8930d --- /dev/null +++ b/node_modules/katex/src/functions/supsub.ts @@ -0,0 +1,268 @@ +import {defineFunctionBuilders} from "../defineFunction"; +import {makeSpan, makeVList} from "../buildCommon"; +import {Span, SymbolNode, type HtmlDomNode} from "../domTree"; +import {isCharacterBox} from "../utils"; +import {MathNode} from "../mathMLTree"; +import {makeEm} from "../units"; +import Style from "../Style"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; +import * as accent from "./accent"; +import * as horizBrace from "./horizBrace"; +import * as op from "./op"; +import * as operatorname from "./operatorname"; + +import type Options from "../Options"; +import type {ParseNode} from "../types/nodes"; +import type {HtmlBuilder} from "../defineFunction"; +import type {MathNodeType} from "../mathMLTree"; + +/** + * Sometimes, groups perform special rules when they have superscripts or + * subscripts attached to them. This function lets the `supsub` group know that + * Sometimes, groups perform special rules when they have superscripts or + * its inner element should handle the superscripts and subscripts instead of + * handling them itself. + */ +const htmlBuilderDelegate = function( + group: ParseNode<"supsub">, + options: Options, +// eslint-disable-next-line @typescript-eslint/no-explicit-any +): HtmlBuilder | null | undefined { + const base = group.base; + if (!base) { + return null; + } else if (base.type === "op") { + // Operators handle supsubs differently when they have limits + // (e.g. `\displaystyle\sum_2^3`) + const delegate = base.limits && + (options.style.size === Style.DISPLAY.size || + base.alwaysHandleSupSub); + return delegate ? op.htmlBuilder : null; + } else if (base.type === "operatorname") { + const delegate = base.alwaysHandleSupSub && + (options.style.size === Style.DISPLAY.size || base.limits); + return delegate ? operatorname.htmlBuilder : null; + } else if (base.type === "accent") { + return isCharacterBox(base.base) ? accent.htmlBuilder : null; + } else if (base.type === "horizBrace") { + const isSup = !group.sub; + return isSup === base.isOver ? horizBrace.htmlBuilder : null; + } else { + return null; + } +}; + +// Super scripts and subscripts, whose precise placement can depend on other +// functions that precede them. +defineFunctionBuilders({ + type: "supsub", + htmlBuilder(group, options) { + // Superscript and subscripts are handled in the TeXbook on page + // 445-446, rules 18(a-f). + + // Here is where we defer to the inner group if it should handle + // superscripts and subscripts itself. + const builderDelegate = htmlBuilderDelegate(group, options); + if (builderDelegate) { + return builderDelegate(group, options); + } + + const {base: valueBase, sup: valueSup, sub: valueSub} = group; + const base = html.buildGroup(valueBase, options); + let supm; + let subm; + + const metrics = options.fontMetrics(); + + // Rule 18a + let supShift = 0; + let subShift = 0; + + const isCharBox = valueBase && isCharacterBox(valueBase); + if (valueSup) { + const newOptions = options.havingStyle(options.style.sup()); + supm = html.buildGroup(valueSup, newOptions, options); + if (!isCharBox) { + supShift = base.height - newOptions.fontMetrics().supDrop + * newOptions.sizeMultiplier / options.sizeMultiplier; + } + } + + if (valueSub) { + const newOptions = options.havingStyle(options.style.sub()); + subm = html.buildGroup(valueSub, newOptions, options); + if (!isCharBox) { + subShift = base.depth + newOptions.fontMetrics().subDrop + * newOptions.sizeMultiplier / options.sizeMultiplier; + } + } + + // Rule 18c + let minSupShift; + if (options.style === Style.DISPLAY) { + minSupShift = metrics.sup1; + } else if (options.style.cramped) { + minSupShift = metrics.sup3; + } else { + minSupShift = metrics.sup2; + } + + // scriptspace is a font-size-independent size, so scale it + // appropriately for use as the marginRight. + const multiplier = options.sizeMultiplier; + const marginRight = makeEm((0.5 / metrics.ptPerEm) / multiplier); + + let marginLeft = null; + if (subm) { + // Subscripts shouldn't be shifted by the base's italic correction. + // Account for that by shifting the subscript back the appropriate + // amount. Note we only do this when the base is a single symbol. + const isOiint = + group.base && group.base.type === "op" && group.base.name && + (group.base.name === "\\oiint" || group.base.name === "\\oiiint"); + if (base instanceof SymbolNode || isOiint) { + // SymbolNode has .italic natively; for \oiint/\oiiint the + // op builder stores .italic on the wrapping Span. + marginLeft = makeEm( + -((base as SymbolNode | Span).italic ?? 0)); + } + } + + let supsub; + if (supm && subm) { + supShift = Math.max( + supShift, minSupShift, supm.depth + 0.25 * metrics.xHeight); + subShift = Math.max(subShift, metrics.sub2); + + const ruleWidth = metrics.defaultRuleThickness; + + // Rule 18e + const maxWidth = 4 * ruleWidth; + if ((supShift - supm.depth) - (subm.height - subShift) < maxWidth) { + subShift = maxWidth - (supShift - supm.depth) + subm.height; + const psi = 0.8 * metrics.xHeight - (supShift - supm.depth); + if (psi > 0) { + supShift += psi; + subShift -= psi; + } + } + + const vlistElem = [ + {type: "elem" as const, elem: subm, shift: subShift, marginRight, + marginLeft}, + {type: "elem" as const, elem: supm, shift: -supShift, marginRight}, + ]; + + supsub = makeVList({ + positionType: "individualShift", + children: vlistElem, + }, options); + } else if (subm) { + // Rule 18b + subShift = Math.max( + subShift, metrics.sub1, + subm.height - 0.8 * metrics.xHeight); + + const vlistElem = + [{type: "elem" as const, elem: subm, marginLeft, marginRight}]; + + supsub = makeVList({ + positionType: "shift", + positionData: subShift, + children: vlistElem, + }, options); + } else if (supm) { + // Rule 18c, d + supShift = Math.max(supShift, minSupShift, + supm.depth + 0.25 * metrics.xHeight); + + supsub = makeVList({ + positionType: "shift", + positionData: -supShift, + children: [{type: "elem" as const, elem: supm, marginRight}], + }, options); + } else { + throw new Error("supsub must have either sup or sub."); + } + + // Wrap the supsub vlist in a span.msupsub to reset text-align. + const mclass = html.getTypeOfDomTree(base, "right") || "mord"; + return makeSpan([mclass], + [base, makeSpan(["msupsub"], [supsub])], + options); + }, + mathmlBuilder(group, options) { + // Is the inner group a relevant horizontal brace? + let isBrace = false; + let isOver; + let isSup; + + if (group.base && group.base.type === "horizBrace") { + isSup = !!group.sup; + if (isSup === group.base.isOver) { + isBrace = true; + isOver = group.base.isOver; + } + } + + if (group.base && + (group.base.type === "op" || group.base.type === "operatorname")) { + group.base.parentIsSupSub = true; + } + + const children = [mml.buildGroup(group.base, options)]; + + if (group.sub) { + children.push(mml.buildGroup(group.sub, options)); + } + + if (group.sup) { + children.push(mml.buildGroup(group.sup, options)); + } + + let nodeType: MathNodeType; + if (isBrace) { + nodeType = (isOver ? "mover" : "munder"); + } else if (!group.sub) { + const base = group.base; + if (base && base.type === "op" && base.limits && + (options.style === Style.DISPLAY || base.alwaysHandleSupSub)) { + nodeType = "mover"; + } else if (base && base.type === "operatorname" && + base.alwaysHandleSupSub && + (base.limits || options.style === Style.DISPLAY)) { + nodeType = "mover"; + } else { + nodeType = "msup"; + } + } else if (!group.sup) { + const base = group.base; + if (base && base.type === "op" && base.limits && + (options.style === Style.DISPLAY || base.alwaysHandleSupSub)) { + nodeType = "munder"; + } else if (base && base.type === "operatorname" && + base.alwaysHandleSupSub && + (base.limits || options.style === Style.DISPLAY)) { + nodeType = "munder"; + } else { + nodeType = "msub"; + } + } else { + const base = group.base; + if (base && base.type === "op" && base.limits && + options.style === Style.DISPLAY) { + nodeType = "munderover"; + } else if (base && base.type === "operatorname" && + base.alwaysHandleSupSub && + (options.style === Style.DISPLAY || base.limits)) { + nodeType = "munderover"; + } else { + nodeType = "msubsup"; + } + } + + return new MathNode(nodeType, children); + }, +}); diff --git a/node_modules/katex/src/functions/symbolsOp.ts b/node_modules/katex/src/functions/symbolsOp.ts new file mode 100644 index 0000000..b0c5086 --- /dev/null +++ b/node_modules/katex/src/functions/symbolsOp.ts @@ -0,0 +1,32 @@ +import {defineFunctionBuilders} from "../defineFunction"; +import {mathsym} from "../buildCommon"; +import {MathNode} from "../mathMLTree"; + +import * as mml from "../buildMathML"; + +// Operator ParseNodes created in Parser.js from symbol Groups in src/symbols.js. + +defineFunctionBuilders({ + type: "atom", + htmlBuilder(group, options) { + return mathsym( + group.text, group.mode, options, ["m" + group.family]); + }, + mathmlBuilder(group, options) { + const node = new MathNode( + "mo", [mml.makeText(group.text, group.mode)]); + if (group.family === "bin") { + const variant = mml.getVariant(group, options); + if (variant === "bold-italic") { + node.setAttribute("mathvariant", variant); + } + } else if (group.family === "punct") { + node.setAttribute("separator", "true"); + } else if (group.family === "open" || group.family === "close") { + // Delims built here should not stretch vertically. + // See delimsizing.js for stretchy delims. + node.setAttribute("stretchy", "false"); + } + return node; + }, +}); diff --git a/node_modules/katex/src/functions/symbolsOrd.ts b/node_modules/katex/src/functions/symbolsOrd.ts new file mode 100644 index 0000000..a2cec4a --- /dev/null +++ b/node_modules/katex/src/functions/symbolsOrd.ts @@ -0,0 +1,61 @@ +import {defineFunctionBuilders} from "../defineFunction"; +import {makeOrd} from "../buildCommon"; +import {MathNode} from "../mathMLTree"; + +import * as mml from "../buildMathML"; + +import type {ParseNode} from "../types/nodes"; + +// "mathord" and "textord" ParseNodes created in Parser.js from symbol Groups in +// src/symbols.js. + +const defaultVariant: Record = { + "mi": "italic", + "mn": "normal", + "mtext": "normal", +}; + +defineFunctionBuilders({ + type: "mathord", + htmlBuilder(group, options) { + return makeOrd(group, options); + }, + mathmlBuilder(group: ParseNode<"mathord">, options) { + const node = new MathNode( + "mi", + [mml.makeText(group.text, group.mode, options)]); + + const variant = mml.getVariant(group, options) || "italic"; + if (variant !== defaultVariant[node.type]) { + node.setAttribute("mathvariant", variant); + } + return node; + }, +}); + +defineFunctionBuilders({ + type: "textord", + htmlBuilder(group, options) { + return makeOrd(group, options); + }, + mathmlBuilder(group: ParseNode<"textord">, options) { + const text = mml.makeText(group.text, group.mode, options); + const variant = mml.getVariant(group, options) || "normal"; + + let node; + if (group.mode === 'text') { + node = new MathNode("mtext", [text]); + } else if (/[0-9]/.test(group.text)) { + node = new MathNode("mn", [text]); + } else if (group.text === "\\prime") { + node = new MathNode("mo", [text]); + } else { + node = new MathNode("mi", [text]); + } + if (variant !== defaultVariant[node.type]) { + node.setAttribute("mathvariant", variant); + } + + return node; + }, +}); diff --git a/node_modules/katex/src/functions/symbolsSpacing.ts b/node_modules/katex/src/functions/symbolsSpacing.ts new file mode 100644 index 0000000..6515c2f --- /dev/null +++ b/node_modules/katex/src/functions/symbolsSpacing.ts @@ -0,0 +1,72 @@ +import {defineFunctionBuilders} from "../defineFunction"; +import {mathsym, makeOrd, makeSpan} from "../buildCommon"; +import {MathNode, TextNode} from "../mathMLTree"; +import ParseError from "../ParseError"; + +// A map of CSS-based spacing functions to their CSS class. +const cssSpace: Record = { + "\\nobreak": "nobreak", + "\\allowbreak": "allowbreak", +}; + +// A lookup table to determine whether a spacing function/symbol should be +// treated like a regular space character. If a symbol or command is a key +// in this table, then it should be a regular space character. Furthermore, +// the associated value may have a `className` specifying an extra CSS class +// to add to the created `span`. +const regularSpace: Record = { + " ": {}, + "\\ ": {}, + "~": { + className: "nobreak", + }, + "\\space": {}, + "\\nobreakspace": { + className: "nobreak", + }, +}; + +// ParseNode<"spacing"> created in Parser.js from the "spacing" symbol Groups in +// src/symbols.js. +defineFunctionBuilders({ + type: "spacing", + htmlBuilder(group, options) { + if (regularSpace.hasOwnProperty(group.text)) { + const className = regularSpace[group.text].className || ""; + // Spaces are generated by adding an actual space. Each of these + // things has an entry in the symbols table, so these will be turned + // into appropriate outputs. + if (group.mode === "text") { + const ord = makeOrd(group, options); + ord.classes.push(className); + return ord; + } else { + return makeSpan(["mspace", className], + [mathsym(group.text, group.mode, options)], + options); + } + } else if (cssSpace.hasOwnProperty(group.text)) { + // Spaces based on just a CSS class. + return makeSpan( + ["mspace", cssSpace[group.text]], + [], options); + } else { + throw new ParseError(`Unknown type of space "${group.text}"`); + } + }, + mathmlBuilder(group, options) { + let node; + + if (regularSpace.hasOwnProperty(group.text)) { + node = new MathNode( + "mtext", [new TextNode("\u00a0")]); + } else if (cssSpace.hasOwnProperty(group.text)) { + // CSS-based MathML spaces (\nobreak, \allowbreak) are ignored + return new MathNode("mspace"); + } else { + throw new ParseError(`Unknown type of space "${group.text}"`); + } + + return node; + }, +}); diff --git a/node_modules/katex/src/functions/tag.ts b/node_modules/katex/src/functions/tag.ts new file mode 100644 index 0000000..9803a82 --- /dev/null +++ b/node_modules/katex/src/functions/tag.ts @@ -0,0 +1,38 @@ +import {defineFunctionBuilders} from "../defineFunction"; +import {MathNode} from "../mathMLTree"; + +import * as mml from "../buildMathML"; + +const pad = () => { + const padNode = new MathNode("mtd", []); + padNode.setAttribute("width", "50%"); + return padNode; +}; + +defineFunctionBuilders({ + type: "tag", + mathmlBuilder(group, options) { + const table = new MathNode("mtable", [ + new MathNode("mtr", [ + pad(), + new MathNode("mtd", [ + mml.buildExpressionRow(group.body, options), + ]), + pad(), + new MathNode("mtd", [ + mml.buildExpressionRow(group.tag, options), + ]), + ]), + ]); + table.setAttribute("width", "100%"); + return table; + + // TODO: Left-aligned tags. + // Currently, the group and options passed here do not contain + // enough info to set tag alignment. `leqno` is in Settings but it is + // not passed to Options. On the HTML side, leqno is + // set by a CSS class applied in buildTree.js. That would have worked + // in MathML if browsers supported . Since they don't, we + // need to rewrite the way this function is called. + }, +}); diff --git a/node_modules/katex/src/functions/text.ts b/node_modules/katex/src/functions/text.ts new file mode 100644 index 0000000..1e438b2 --- /dev/null +++ b/node_modules/katex/src/functions/text.ts @@ -0,0 +1,81 @@ +import defineFunction, {ordargument} from "../defineFunction"; +import type {TextFont} from "../types/fonts"; +import {makeSpan} from "../buildCommon"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; +import type Options from "../Options"; +import type {ParseNode} from "../types/nodes"; + +// Non-mathy text, possibly in a font +const textFontFamilies: Record = { + "\\text": undefined, + "\\textrm": "textrm", + "\\textsf": "textsf", + "\\texttt": "texttt", + "\\textnormal": "textrm", +}; + +const textFontWeights: Record = { + "\\textbf": "textbf", + "\\textmd": "textmd", +}; + +const textFontShapes: Record = { + "\\textit": "textit", + "\\textup": "textup", +}; + +const optionsWithFont = (group: ParseNode<"text">, options: Options): Options => { + const font = group.font; + // Checks if the argument is a font family or a font style. + if (!font) { + return options; + } else if (textFontFamilies[font]) { + return options.withTextFontFamily(textFontFamilies[font]); + } else if (textFontWeights[font]) { + return options.withTextFontWeight(textFontWeights[font]); + } else if (font === "\\emph") { + return options.fontShape === "textit" ? + options.withTextFontShape("textup") : + options.withTextFontShape("textit"); + } + + return options.withTextFontShape(textFontShapes[font] as "textit" | "textup"); +}; + +defineFunction({ + type: "text", + names: [ + // Font families + "\\text", "\\textrm", "\\textsf", "\\texttt", "\\textnormal", + // Font weights + "\\textbf", "\\textmd", + // Font Shapes + "\\textit", "\\textup", "\\emph", + ], + numArgs: 1, + argTypes: ["text"], + allowedInArgument: true, + allowedInText: true, + + handler({parser, funcName}, args) { + const body = args[0]; + return { + type: "text", + mode: parser.mode, + body: ordargument(body), + font: funcName, + }; + }, + + htmlBuilder(group, options) { + const newOptions = optionsWithFont(group, options); + const inner = html.buildExpression(group.body, newOptions, true); + return makeSpan(["mord", "text"], inner, newOptions); + }, + mathmlBuilder(group, options) { + const newOptions = optionsWithFont(group, options); + return mml.buildExpressionRow(group.body, newOptions); + }, +}); diff --git a/node_modules/katex/src/functions/underline.ts b/node_modules/katex/src/functions/underline.ts new file mode 100644 index 0000000..cc6ffde --- /dev/null +++ b/node_modules/katex/src/functions/underline.ts @@ -0,0 +1,57 @@ +import defineFunction from "../defineFunction"; +import {makeLineSpan, makeSpan, makeVList} from "../buildCommon"; +import {MathNode, TextNode} from "../mathMLTree"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; + +defineFunction({ + type: "underline", + names: ["\\underline"], + numArgs: 1, + allowedInText: true, + + handler({parser}, args) { + return { + type: "underline", + mode: parser.mode, + body: args[0], + }; + }, + + htmlBuilder(group, options) { + // Underlines are handled in the TeXbook pg 443, Rule 10. + // Build the inner group. + const innerGroup = html.buildGroup(group.body, options); + + // Create the line to go below the body + const line = makeLineSpan("underline-line", options); + + // Generate the vlist, with the appropriate kerns + const defaultRuleThickness = options.fontMetrics().defaultRuleThickness; + const vlist = makeVList({ + positionType: "top", + positionData: innerGroup.height, + children: [ + {type: "kern", size: defaultRuleThickness}, + {type: "elem", elem: line}, + {type: "kern", size: 3 * defaultRuleThickness}, + {type: "elem", elem: innerGroup}, + ], + }, options); + + return makeSpan(["mord", "underline"], [vlist], options); + }, + mathmlBuilder(group, options) { + const operator = new MathNode( + "mo", [new TextNode("\u203e")]); + operator.setAttribute("stretchy", "true"); + + const node = new MathNode( + "munder", + [mml.buildGroup(group.body, options), operator]); + node.setAttribute("accentunder", "true"); + + return node; + }, +}); diff --git a/node_modules/katex/src/functions/utils/assembleSupSub.ts b/node_modules/katex/src/functions/utils/assembleSupSub.ts new file mode 100644 index 0000000..e928772 --- /dev/null +++ b/node_modules/katex/src/functions/utils/assembleSupSub.ts @@ -0,0 +1,119 @@ +import {makeSpan, makeVList} from "../../buildCommon"; +import * as html from "../../buildHTML"; +import {isCharacterBox} from "../../utils"; +import type {StyleInterface} from "../../Style"; +import type Options from "../../Options"; +import type {DomSpan, SymbolNode} from "../../domTree"; +import type {AnyParseNode} from "../../types/nodes"; +import {makeEm} from "../../units"; + +// For an operator with limits, assemble the base, sup, and sub into a span. + +export const assembleSupSub = ( + base: DomSpan | SymbolNode, + supGroup: AnyParseNode | null | undefined, + subGroup: AnyParseNode | null | undefined, + options: Options, + style: StyleInterface, + slant: number, + baseShift: number, +): DomSpan => { + base = makeSpan([], [base]); + const subIsSingleCharacter = subGroup && isCharacterBox(subGroup); + let sub; + let sup; + // We manually have to handle the superscripts and subscripts. This, + // aside from the kern calculations, is copied from supsub. + if (supGroup) { + const elem = html.buildGroup( + supGroup, options.havingStyle(style.sup()), options); + + sup = { + elem, + kern: Math.max( + options.fontMetrics().bigOpSpacing1, + options.fontMetrics().bigOpSpacing3 - elem.depth), + }; + } + + if (subGroup) { + const elem = html.buildGroup( + subGroup, options.havingStyle(style.sub()), options); + + sub = { + elem, + kern: Math.max( + options.fontMetrics().bigOpSpacing2, + options.fontMetrics().bigOpSpacing4 - elem.height), + }; + } + + // Build the final group as a vlist of the possible subscript, base, + // and possible superscript. + let finalGroup; + if (sup && sub) { + const bottom = options.fontMetrics().bigOpSpacing5 + + sub.elem.height + sub.elem.depth + + sub.kern + + base.depth + baseShift; + + finalGroup = makeVList({ + positionType: "bottom", + positionData: bottom, + children: [ + {type: "kern", size: options.fontMetrics().bigOpSpacing5}, + {type: "elem", elem: sub.elem, marginLeft: makeEm(-slant)}, + {type: "kern", size: sub.kern}, + {type: "elem", elem: base}, + {type: "kern", size: sup.kern}, + {type: "elem", elem: sup.elem, marginLeft: makeEm(slant)}, + {type: "kern", size: options.fontMetrics().bigOpSpacing5}, + ], + }, options); + } else if (sub) { + const top = base.height - baseShift; + + // Shift the limits by the slant of the symbol. Note + // that we are supposed to shift the limits by 1/2 of the slant, + // but since we are centering the limits adding a full slant of + // margin will shift by 1/2 that. + finalGroup = makeVList({ + positionType: "top", + positionData: top, + children: [ + {type: "kern", size: options.fontMetrics().bigOpSpacing5}, + {type: "elem", elem: sub.elem, marginLeft: makeEm(-slant)}, + {type: "kern", size: sub.kern}, + {type: "elem", elem: base}, + ], + }, options); + } else if (sup) { + const bottom = base.depth + baseShift; + + finalGroup = makeVList({ + positionType: "bottom", + positionData: bottom, + children: [ + {type: "elem", elem: base}, + {type: "kern", size: sup.kern}, + {type: "elem", elem: sup.elem, marginLeft: makeEm(slant)}, + {type: "kern", size: options.fontMetrics().bigOpSpacing5}, + ], + }, options); + } else { + // This case probably shouldn't occur (this would mean the + // supsub was sending us a group with no superscript or + // subscript) but be safe. + return base; + } + + const parts = [finalGroup]; + if (sub && slant !== 0 && !subIsSingleCharacter) { + // A negative margin-left was applied to the lower limit. + // Avoid an overlap by placing a spacer on the left on the group. + const spacer = makeSpan(["mspace"], [], options); + spacer.style.marginRight = makeEm(slant); + parts.unshift(spacer); + } + return makeSpan(["mop", "op-limits"], parts, options); +}; diff --git a/node_modules/katex/src/functions/vcenter.ts b/node_modules/katex/src/functions/vcenter.ts new file mode 100644 index 0000000..cf1cbc8 --- /dev/null +++ b/node_modules/katex/src/functions/vcenter.ts @@ -0,0 +1,44 @@ +import defineFunction from "../defineFunction"; +import {makeVList} from "../buildCommon"; +import {MathNode} from "../mathMLTree"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; + +// \vcenter: Vertically center the argument group on the math axis. + +defineFunction({ + type: "vcenter", + names: ["\\vcenter"], + numArgs: 1, + argTypes: ["original"], // In LaTeX, \vcenter can act only on a box. + allowedInText: false, + + handler({parser}, args) { + return { + type: "vcenter", + mode: parser.mode, + body: args[0], + }; + }, + + htmlBuilder(group, options) { + const body = html.buildGroup(group.body, options); + const axisHeight = options.fontMetrics().axisHeight; + const dy = 0.5 * ((body.height - axisHeight) - (body.depth + axisHeight)); + return makeVList({ + positionType: "shift", + positionData: dy, + children: [{type: "elem", elem: body}], + }, options); + }, + mathmlBuilder(group, options) { + // There is no way to do this in MathML. + // Write a class as a breadcrumb in case some post-processor wants + // to perform a vcenter adjustment. + // Wrap in mrow to ensure valid MathML when placed inside mo (e.g., \mathrel) + const mpadded = new MathNode( + "mpadded", [mml.buildGroup(group.body, options)], ["vcenter"]); + return new MathNode("mrow", [mpadded]); + }, +}); diff --git a/node_modules/katex/src/functions/verb.ts b/node_modules/katex/src/functions/verb.ts new file mode 100644 index 0000000..d31eaa4 --- /dev/null +++ b/node_modules/katex/src/functions/verb.ts @@ -0,0 +1,57 @@ +import defineFunction from "../defineFunction"; +import {makeSpan, makeSymbol, tryCombineChars} from "../buildCommon"; +import {MathNode, TextNode} from "../mathMLTree"; +import ParseError from "../ParseError"; + +import type {ParseNode} from "../types/nodes"; + +defineFunction({ + type: "verb", + names: ["\\verb"], + numArgs: 0, + allowedInText: true, + + handler(context, args, optArgs) { + // \verb and \verb* are dealt with directly in Parser.js. + // If we end up here, it's because of a failure to match the two delimiters + // in the regex in Lexer.js. LaTeX raises the following error when \verb is + // terminated by end of line (or file). + throw new ParseError( + "\\verb ended by end of line instead of matching delimiter"); + }, + + htmlBuilder(group, options) { + const text = makeVerb(group); + const body = []; + // \verb enters text mode and therefore is sized like \textstyle + const newOptions = options.havingStyle(options.style.text()); + for (let i = 0; i < text.length; i++) { + let c = text[i]; + if (c === '~') { + c = '\\textasciitilde'; + } + body.push(makeSymbol(c, "Typewriter-Regular", + group.mode, newOptions, ["mord", "texttt"])); + } + return makeSpan( + ["mord", "text"].concat(newOptions.sizingClasses(options)), + tryCombineChars(body), + newOptions, + ); + }, + mathmlBuilder(group, options) { + const text = new TextNode(makeVerb(group)); + const node = new MathNode("mtext", [text]); + node.setAttribute("mathvariant", "monospace"); + return node; + }, +}); + +/** + * Converts verb group into body string. + * + * \verb* replaces each space with an open box \u2423 + * \verb replaces each space with a no-break space \xA0 + */ +const makeVerb = (group: ParseNode<"verb">): string => + group.body.replace(/ /g, group.star ? '\u2423' : '\xA0'); diff --git a/node_modules/katex/src/macros.ts b/node_modules/katex/src/macros.ts new file mode 100644 index 0000000..f714f9e --- /dev/null +++ b/node_modules/katex/src/macros.ts @@ -0,0 +1,1032 @@ +/** + * Predefined macros for KaTeX. + * This can be used to define some commands in terms of others. + */ + +// Export global macros object from defineMacro +import defineMacro, {_macros} from "./defineMacro"; +const macros = _macros; +export default macros; + +import fontMetricsData from "./fontMetricsData"; +import functions from "./functions"; +import symbols from "./symbols"; +import {makeEm} from "./units"; +import ParseError from "./ParseError"; + +import type {MacroContextInterface} from "./defineMacro"; + +////////////////////////////////////////////////////////////////////// +// macro tools + +defineMacro("\\noexpand", function(context) { + // The expansion is the token itself; but that token is interpreted + // as if its meaning were ‘\relax’ if it is a control sequence that + // would ordinarily be expanded by TeX’s expansion rules. + const t = context.popToken(); + if (context.isExpandable(t.text)) { + t.noexpand = true; + t.treatAsRelax = true; + } + return {tokens: [t], numArgs: 0}; +}); + +defineMacro("\\expandafter", function(context) { + // TeX first reads the token that comes immediately after \expandafter, + // without expanding it; let’s call this token t. Then TeX reads the + // token that comes after t (and possibly more tokens, if that token + // has an argument), replacing it by its expansion. Finally TeX puts + // t back in front of that expansion. + const t = context.popToken(); + context.expandOnce(true); // expand only an expandable token + return {tokens: [t], numArgs: 0}; +}); + +// LaTeX's \@firstoftwo{#1}{#2} expands to #1, skipping #2 +// TeX source: \long\def\@firstoftwo#1#2{#1} +defineMacro("\\@firstoftwo", function(context) { + const args = context.consumeArgs(2); + return {tokens: args[0], numArgs: 0}; +}); + +// LaTeX's \@secondoftwo{#1}{#2} expands to #2, skipping #1 +// TeX source: \long\def\@secondoftwo#1#2{#2} +defineMacro("\\@secondoftwo", function(context) { + const args = context.consumeArgs(2); + return {tokens: args[1], numArgs: 0}; +}); + +// LaTeX's \@ifnextchar{#1}{#2}{#3} looks ahead to the next (unexpanded) +// symbol that isn't a space, consuming any spaces but not consuming the +// first nonspace character. If that nonspace character matches #1, then +// the macro expands to #2; otherwise, it expands to #3. +defineMacro("\\@ifnextchar", function(context) { + const args = context.consumeArgs(3); // symbol, if, else + context.consumeSpaces(); + const nextToken = context.future(); + if (args[0].length === 1 && args[0][0].text === nextToken.text) { + return {tokens: args[1], numArgs: 0}; + } else { + return {tokens: args[2], numArgs: 0}; + } +}); + +// LaTeX's \@ifstar{#1}{#2} looks ahead to the next (unexpanded) symbol. +// If it is `*`, then it consumes the symbol, and the macro expands to #1; +// otherwise, the macro expands to #2 (without consuming the symbol). +// TeX source: \def\@ifstar#1{\@ifnextchar *{\@firstoftwo{#1}}} +defineMacro("\\@ifstar", "\\@ifnextchar *{\\@firstoftwo{#1}}"); + +// LaTeX's \TextOrMath{#1}{#2} expands to #1 in text mode, #2 in math mode +defineMacro("\\TextOrMath", function(context) { + const args = context.consumeArgs(2); + if (context.mode === 'text') { + return {tokens: args[0], numArgs: 0}; + } else { + return {tokens: args[1], numArgs: 0}; + } +}); + +// Lookup table for parsing numbers in base 8 through 16 +const digitToNumber: Record = { + "0": 0, "1": 1, "2": 2, "3": 3, "4": 4, "5": 5, "6": 6, "7": 7, "8": 8, + "9": 9, "a": 10, "A": 10, "b": 11, "B": 11, "c": 12, "C": 12, + "d": 13, "D": 13, "e": 14, "E": 14, "f": 15, "F": 15, +}; + +// TeX \char makes a literal character (catcode 12) using the following forms: +// (see The TeXBook, p. 43) +// \char123 -- decimal +// \char'123 -- octal +// \char"123 -- hex +// \char`x -- character that can be written (i.e. isn't active) +// \char`\x -- character that cannot be written (e.g. %) +// These all refer to characters from the font, so we turn them into special +// calls to a function \@char dealt with in the Parser. +defineMacro("\\char", function(context) { + let token = context.popToken(); + let base; + let number = 0; + if (token.text === "'") { + base = 8; + token = context.popToken(); + } else if (token.text === '"') { + base = 16; + token = context.popToken(); + } else if (token.text === "`") { + token = context.popToken(); + if (token.text[0] === "\\") { + number = token.text.charCodeAt(1); + } else if (token.text === "EOF") { + throw new ParseError("\\char` missing argument"); + } else { + number = token.text.charCodeAt(0); + } + } else { + base = 10; + } + if (base) { + // Parse a number in the given base, starting with first `token`. + number = digitToNumber[token.text]; + if (number == null || number >= base) { + throw new ParseError(`Invalid base-${base} digit ${token.text}`); + } + let digit; + while ((digit = digitToNumber[context.future().text]) != null && + digit < base) { + number *= base; + number += digit; + context.popToken(); + } + } + return `\\@char{${number}}`; +}); + +// \newcommand{\macro}[args]{definition} +// \renewcommand{\macro}[args]{definition} +// TODO: Optional arguments: \newcommand{\macro}[args][default]{definition} +const newcommand = ( + context: MacroContextInterface, + existsOK: boolean, + nonexistsOK: boolean, + skipIfExists: boolean, +) => { + let arg = context.consumeArg().tokens; + if (arg.length !== 1) { + throw new ParseError( + "\\newcommand's first argument must be a macro name"); + } + const name = arg[0].text; + + const exists = context.isDefined(name); + if (exists && !existsOK) { + throw new ParseError(`\\newcommand{${name}} attempting to redefine ` + + `${name}; use \\renewcommand`); + } + if (!exists && !nonexistsOK) { + throw new ParseError(`\\renewcommand{${name}} when command ${name} ` + + `does not yet exist; use \\newcommand`); + } + + let numArgs = 0; + arg = context.consumeArg().tokens; + if (arg.length === 1 && arg[0].text === "[") { + let argText = ''; + let token = context.expandNextToken(); + while (token.text !== "]" && token.text !== "EOF") { + // TODO: Should properly expand arg, e.g., ignore {}s + argText += token.text; + token = context.expandNextToken(); + } + if (!argText.match(/^\s*[0-9]+\s*$/)) { + throw new ParseError(`Invalid number of arguments: ${argText}`); + } + numArgs = parseInt(argText); + arg = context.consumeArg().tokens; + } + + if (!(exists && skipIfExists)) { + // Final arg is the expansion of the macro + context.macros.set(name, { + tokens: arg, + numArgs, + }); + } + return ''; +}; +defineMacro("\\newcommand", + (context) => newcommand(context, false, true, false)); +defineMacro("\\renewcommand", + (context) => newcommand(context, true, false, false)); +defineMacro("\\providecommand", + (context) => newcommand(context, true, true, true)); + +// terminal (console) tools +defineMacro("\\message", (context) => { + const arg = context.consumeArgs(1)[0]; + // eslint-disable-next-line no-console + console.log(arg.reverse().map(token => token.text).join("")); + return ''; +}); +defineMacro("\\errmessage", (context) => { + const arg = context.consumeArgs(1)[0]; + // eslint-disable-next-line no-console + console.error(arg.reverse().map(token => token.text).join("")); + return ''; +}); +defineMacro("\\show", (context) => { + const tok = context.popToken(); + const name = tok.text; + // eslint-disable-next-line no-console + console.log(tok, context.macros.get(name), functions[name], + symbols.math[name], symbols.text[name]); + return ''; +}); + +////////////////////////////////////////////////////////////////////// +// Grouping +// \let\bgroup={ \let\egroup=} +defineMacro("\\bgroup", "{"); +defineMacro("\\egroup", "}"); + +// Symbols from latex.ltx: +// \def~{\nobreakspace{}} +// \def\lq{`} +// \def\rq{'} +// \def \aa {\r a} +// \def \AA {\r A} +defineMacro("~", "\\nobreakspace"); +defineMacro("\\lq", "`"); +defineMacro("\\rq", "'"); +defineMacro("\\aa", "\\r a"); +defineMacro("\\AA", "\\r A"); + +// Copyright (C) and registered (R) symbols. Use raw symbol in MathML. +// \DeclareTextCommandDefault{\textcopyright}{\textcircled{c}} +// \DeclareTextCommandDefault{\textregistered}{\textcircled{% +// \check@mathfonts\fontsize\sf@size\z@\math@fontsfalse\selectfont R}} +// \DeclareRobustCommand{\copyright}{% +// \ifmmode{\nfss@text{\textcopyright}}\else\textcopyright\fi} +defineMacro("\\textcopyright", "\\html@mathml{\\textcircled{c}}{\\char`©}"); +defineMacro("\\copyright", + "\\TextOrMath{\\textcopyright}{\\text{\\textcopyright}}"); +defineMacro("\\textregistered", + "\\html@mathml{\\textcircled{\\scriptsize R}}{\\char`®}"); + +// Characters omitted from Unicode range 1D400–1D7FF +defineMacro("\u212C", "\\mathscr{B}"); // script +defineMacro("\u2130", "\\mathscr{E}"); +defineMacro("\u2131", "\\mathscr{F}"); +defineMacro("\u210B", "\\mathscr{H}"); +defineMacro("\u2110", "\\mathscr{I}"); +defineMacro("\u2112", "\\mathscr{L}"); +defineMacro("\u2133", "\\mathscr{M}"); +defineMacro("\u211B", "\\mathscr{R}"); +defineMacro("\u212D", "\\mathfrak{C}"); // Fraktur +defineMacro("\u210C", "\\mathfrak{H}"); +defineMacro("\u2128", "\\mathfrak{Z}"); + +// Define \Bbbk with a macro that works in both HTML and MathML. +defineMacro("\\Bbbk", "\\Bbb{k}"); + +// \llap and \rlap render their contents in text mode +defineMacro("\\llap", "\\mathllap{\\textrm{#1}}"); +defineMacro("\\rlap", "\\mathrlap{\\textrm{#1}}"); +defineMacro("\\clap", "\\mathclap{\\textrm{#1}}"); + +// \mathstrut from the TeXbook, p 360 +defineMacro("\\mathstrut", "\\vphantom{(}"); + +// \underbar from TeXbook p 353 +defineMacro("\\underbar", "\\underline{\\text{#1}}"); + +// \not is defined by base/fontmath.ltx via +// \DeclareMathSymbol{\not}{\mathrel}{symbols}{"36} +// It's thus treated like a \mathrel, but defined by a symbol that has zero +// width but extends to the right. We use \rlap to get that spacing. +// For MathML we write U+0338 here. buildMathML.js will then do the overlay. +defineMacro("\\not", "\\html@mathml{\\mathrel{\\mathrlap\\@not}\\nobreak}" + + "{\\char\"338}"); + +// Negated symbols from base/fontmath.ltx: +// \def\neq{\not=} \let\ne=\neq +// \DeclareRobustCommand +// \notin{\mathrel{\m@th\mathpalette\c@ncel\in}} +// \def\c@ncel#1#2{\m@th\ooalign{$\hfil#1\mkern1mu/\hfil$\crcr$#1#2$}} +defineMacro("\\neq", "\\html@mathml{\\mathrel{\\not=}}{\\mathrel{\\char`≠}}"); +defineMacro("\\ne", "\\neq"); +defineMacro("\u2260", "\\neq"); +defineMacro("\\notin", "\\html@mathml{\\mathrel{{\\in}\\mathllap{/\\mskip1mu}}}" + + "{\\mathrel{\\char`∉}}"); +defineMacro("\u2209", "\\notin"); + +// Unicode stacked relations +defineMacro("\u2258", "\\html@mathml{" + + "\\mathrel{=\\kern{-1em}\\raisebox{0.4em}{$\\scriptsize\\frown$}}" + + "}{\\mathrel{\\char`\u2258}}"); +defineMacro("\u2259", + "\\html@mathml{\\stackrel{\\tiny\\wedge}{=}}{\\mathrel{\\char`\u2258}}"); +defineMacro("\u225A", + "\\html@mathml{\\stackrel{\\tiny\\vee}{=}}{\\mathrel{\\char`\u225A}}"); +defineMacro("\u225B", + "\\html@mathml{\\stackrel{\\scriptsize\\star}{=}}" + + "{\\mathrel{\\char`\u225B}}"); +defineMacro("\u225D", + "\\html@mathml{\\stackrel{\\tiny\\mathrm{def}}{=}}" + + "{\\mathrel{\\char`\u225D}}"); +defineMacro("\u225E", + "\\html@mathml{\\stackrel{\\tiny\\mathrm{m}}{=}}" + + "{\\mathrel{\\char`\u225E}}"); +defineMacro("\u225F", + "\\html@mathml{\\stackrel{\\tiny?}{=}}{\\mathrel{\\char`\u225F}}"); + +// Misc Unicode +defineMacro("\u27C2", "\\perp"); +defineMacro("\u203C", "\\mathclose{!\\mkern-0.8mu!}"); +defineMacro("\u220C", "\\notni"); +defineMacro("\u231C", "\\ulcorner"); +defineMacro("\u231D", "\\urcorner"); +defineMacro("\u231E", "\\llcorner"); +defineMacro("\u231F", "\\lrcorner"); +defineMacro("\u00A9", "\\copyright"); +defineMacro("\u00AE", "\\textregistered"); + +// The KaTeX fonts have corners at codepoints that don't match Unicode. +// For MathML purposes, use the Unicode code point. +defineMacro("\\ulcorner", "\\html@mathml{\\@ulcorner}{\\mathop{\\char\"231c}}"); +defineMacro("\\urcorner", "\\html@mathml{\\@urcorner}{\\mathop{\\char\"231d}}"); +defineMacro("\\llcorner", "\\html@mathml{\\@llcorner}{\\mathop{\\char\"231e}}"); +defineMacro("\\lrcorner", "\\html@mathml{\\@lrcorner}{\\mathop{\\char\"231f}}"); + +////////////////////////////////////////////////////////////////////// +// LaTeX_2ε + +// \vdots{\vbox{\baselineskip4\p@ \lineskiplimit\z@ +// \kern6\p@\hbox{.}\hbox{.}\hbox{.}}} +// We'll call \varvdots, which gets a glyph from symbols.js. +// The zero-width rule gets us an equivalent to the vertical 6pt kern. +defineMacro("\\vdots", "{\\varvdots\\rule{0pt}{15pt}}"); +defineMacro("\u22ee", "\\vdots"); + +////////////////////////////////////////////////////////////////////// +// amsmath.sty +// http://mirrors.concertpass.com/tex-archive/macros/latex/required/amsmath/amsmath.pdf + +// Italic Greek capital letters. AMS defines these with \DeclareMathSymbol, +// but they are equivalent to \mathit{\Letter}. +defineMacro("\\varGamma", "\\mathit{\\Gamma}"); +defineMacro("\\varDelta", "\\mathit{\\Delta}"); +defineMacro("\\varTheta", "\\mathit{\\Theta}"); +defineMacro("\\varLambda", "\\mathit{\\Lambda}"); +defineMacro("\\varXi", "\\mathit{\\Xi}"); +defineMacro("\\varPi", "\\mathit{\\Pi}"); +defineMacro("\\varSigma", "\\mathit{\\Sigma}"); +defineMacro("\\varUpsilon", "\\mathit{\\Upsilon}"); +defineMacro("\\varPhi", "\\mathit{\\Phi}"); +defineMacro("\\varPsi", "\\mathit{\\Psi}"); +defineMacro("\\varOmega", "\\mathit{\\Omega}"); + +//\newcommand{\substack}[1]{\subarray{c}#1\endsubarray} +defineMacro("\\substack", "\\begin{subarray}{c}#1\\end{subarray}"); + +// \renewcommand{\colon}{\nobreak\mskip2mu\mathpunct{}\nonscript +// \mkern-\thinmuskip{:}\mskip6muplus1mu\relax} +defineMacro("\\colon", "\\nobreak\\mskip2mu\\mathpunct{}" + + "\\mathchoice{\\mkern-3mu}{\\mkern-3mu}{}{}{:}\\mskip6mu\\relax"); + +// \newcommand{\boxed}[1]{\fbox{\m@th$\displaystyle#1$}} +defineMacro("\\boxed", "\\fbox{$\\displaystyle{#1}$}"); + +// \def\iff{\DOTSB\;\Longleftrightarrow\;} +// \def\implies{\DOTSB\;\Longrightarrow\;} +// \def\impliedby{\DOTSB\;\Longleftarrow\;} +defineMacro("\\iff", "\\DOTSB\\;\\Longleftrightarrow\\;"); +defineMacro("\\implies", "\\DOTSB\\;\\Longrightarrow\\;"); +defineMacro("\\impliedby", "\\DOTSB\\;\\Longleftarrow\\;"); + +// \def\dddot#1{{\mathop{#1}\limits^{\vbox to-1.4\ex@{\kern-\tw@\ex@ +// \hbox{\normalfont ...}\vss}}}} +// We use \overset which avoids the vertical shift of \mathop. +defineMacro("\\dddot", "{\\overset{\\raisebox{-0.1ex}{\\normalsize ...}}{#1}}"); +defineMacro("\\ddddot", "{\\overset{\\raisebox{-0.1ex}{\\normalsize ....}}{#1}}"); + +// AMSMath's automatic \dots, based on \mdots@@ macro. +const dotsByToken: Record = { + ',': '\\dotsc', + '\\not': '\\dotsb', + // \keybin@ checks for the following: + '+': '\\dotsb', + '=': '\\dotsb', + '<': '\\dotsb', + '>': '\\dotsb', + '-': '\\dotsb', + '*': '\\dotsb', + ':': '\\dotsb', + // Symbols whose definition starts with \DOTSB: + '\\DOTSB': '\\dotsb', + '\\coprod': '\\dotsb', + '\\bigvee': '\\dotsb', + '\\bigwedge': '\\dotsb', + '\\biguplus': '\\dotsb', + '\\bigcap': '\\dotsb', + '\\bigcup': '\\dotsb', + '\\prod': '\\dotsb', + '\\sum': '\\dotsb', + '\\bigotimes': '\\dotsb', + '\\bigoplus': '\\dotsb', + '\\bigodot': '\\dotsb', + '\\bigsqcup': '\\dotsb', + '\\And': '\\dotsb', + '\\longrightarrow': '\\dotsb', + '\\Longrightarrow': '\\dotsb', + '\\longleftarrow': '\\dotsb', + '\\Longleftarrow': '\\dotsb', + '\\longleftrightarrow': '\\dotsb', + '\\Longleftrightarrow': '\\dotsb', + '\\mapsto': '\\dotsb', + '\\longmapsto': '\\dotsb', + '\\hookrightarrow': '\\dotsb', + '\\doteq': '\\dotsb', + // Symbols whose definition starts with \mathbin: + '\\mathbin': '\\dotsb', + // Symbols whose definition starts with \mathrel: + '\\mathrel': '\\dotsb', + '\\relbar': '\\dotsb', + '\\Relbar': '\\dotsb', + '\\xrightarrow': '\\dotsb', + '\\xleftarrow': '\\dotsb', + // Symbols whose definition starts with \DOTSI: + '\\DOTSI': '\\dotsi', + '\\int': '\\dotsi', + '\\oint': '\\dotsi', + '\\iint': '\\dotsi', + '\\iiint': '\\dotsi', + '\\iiiint': '\\dotsi', + '\\idotsint': '\\dotsi', + // Symbols whose definition starts with \DOTSX: + '\\DOTSX': '\\dotsx', +}; + +const dotsbGroups = new Set(['bin', 'rel']); + +defineMacro("\\dots", function(context) { + // TODO: If used in text mode, should expand to \textellipsis. + // However, in KaTeX, \textellipsis and \ldots behave the same + // (in text mode), and it's unlikely we'd see any of the math commands + // that affect the behavior of \dots when in text mode. So fine for now + // (until we support \ifmmode ... \else ... \fi). + let thedots = '\\dotso'; + const next = context.expandAfterFuture().text; + if (next in dotsByToken) { + thedots = dotsByToken[next]; + } else if (next.slice(0, 4) === '\\not') { + thedots = '\\dotsb'; + } else if (next in symbols.math) { + if (dotsbGroups.has(symbols.math[next].group)) { + thedots = '\\dotsb'; + } + } + return thedots; +}); + +const spaceAfterDots = { + // \rightdelim@ checks for the following: + ')': true, + ']': true, + '\\rbrack': true, + '\\}': true, + '\\rbrace': true, + '\\rangle': true, + '\\rceil': true, + '\\rfloor': true, + '\\rgroup': true, + '\\rmoustache': true, + '\\right': true, + '\\bigr': true, + '\\biggr': true, + '\\Bigr': true, + '\\Biggr': true, + // \extra@ also tests for the following: + '$': true, + // \extrap@ checks for the following: + ';': true, + '.': true, + ',': true, +}; + +defineMacro("\\dotso", function(context) { + const next = context.future().text; + if (next in spaceAfterDots) { + return "\\ldots\\,"; + } else { + return "\\ldots"; + } +}); + +defineMacro("\\dotsc", function(context) { + const next = context.future().text; + // \dotsc uses \extra@ but not \extrap@, instead specially checking for + // ';' and '.', but doesn't check for ','. + if (next in spaceAfterDots && next !== ',') { + return "\\ldots\\,"; + } else { + return "\\ldots"; + } +}); + +defineMacro("\\cdots", function(context) { + const next = context.future().text; + if (next in spaceAfterDots) { + return "\\@cdots\\,"; + } else { + return "\\@cdots"; + } +}); + +defineMacro("\\dotsb", "\\cdots"); +defineMacro("\\dotsm", "\\cdots"); +defineMacro("\\dotsi", "\\!\\cdots"); +// amsmath doesn't actually define \dotsx, but \dots followed by a macro +// starting with \DOTSX implies \dotso, and then \extra@ detects this case +// and forces the added `\,`. +defineMacro("\\dotsx", "\\ldots\\,"); + +// \let\DOTSI\relax +// \let\DOTSB\relax +// \let\DOTSX\relax +defineMacro("\\DOTSI", "\\relax"); +defineMacro("\\DOTSB", "\\relax"); +defineMacro("\\DOTSX", "\\relax"); + +// Spacing, based on amsmath.sty's override of LaTeX defaults +// \DeclareRobustCommand{\tmspace}[3]{% +// \ifmmode\mskip#1#2\else\kern#1#3\fi\relax} +defineMacro("\\tmspace", "\\TextOrMath{\\kern#1#3}{\\mskip#1#2}\\relax"); +// \renewcommand{\,}{\tmspace+\thinmuskip{.1667em}} +// TODO: math mode should use \thinmuskip +defineMacro("\\,", "\\tmspace+{3mu}{.1667em}"); +// \let\thinspace\, +defineMacro("\\thinspace", "\\,"); +// \def\>{\mskip\medmuskip} +// \renewcommand{\:}{\tmspace+\medmuskip{.2222em}} +// TODO: \> and math mode of \: should use \medmuskip = 4mu plus 2mu minus 4mu +defineMacro("\\>", "\\mskip{4mu}"); +defineMacro("\\:", "\\tmspace+{4mu}{.2222em}"); +// \let\medspace\: +defineMacro("\\medspace", "\\:"); +// \renewcommand{\;}{\tmspace+\thickmuskip{.2777em}} +// TODO: math mode should use \thickmuskip = 5mu plus 5mu +defineMacro("\\;", "\\tmspace+{5mu}{.2777em}"); +// \let\thickspace\; +defineMacro("\\thickspace", "\\;"); +// \renewcommand{\!}{\tmspace-\thinmuskip{.1667em}} +// TODO: math mode should use \thinmuskip +defineMacro("\\!", "\\tmspace-{3mu}{.1667em}"); +// \let\negthinspace\! +defineMacro("\\negthinspace", "\\!"); +// \newcommand{\negmedspace}{\tmspace-\medmuskip{.2222em}} +// TODO: math mode should use \medmuskip +defineMacro("\\negmedspace", "\\tmspace-{4mu}{.2222em}"); +// \newcommand{\negthickspace}{\tmspace-\thickmuskip{.2777em}} +// TODO: math mode should use \thickmuskip +defineMacro("\\negthickspace", "\\tmspace-{5mu}{.277em}"); +// \def\enspace{\kern.5em } +defineMacro("\\enspace", "\\kern.5em "); +// \def\enskip{\hskip.5em\relax} +defineMacro("\\enskip", "\\hskip.5em\\relax"); +// \def\quad{\hskip1em\relax} +defineMacro("\\quad", "\\hskip1em\\relax"); +// \def\qquad{\hskip2em\relax} +defineMacro("\\qquad", "\\hskip2em\\relax"); + +// \tag@in@display form of \tag +defineMacro("\\tag", "\\@ifstar\\tag@literal\\tag@paren"); +defineMacro("\\tag@paren", "\\tag@literal{({#1})}"); +defineMacro("\\tag@literal", (context) => { + if (context.macros.get("\\df@tag")) { + throw new ParseError("Multiple \\tag"); + } + return "\\gdef\\df@tag{\\text{#1}}"; +}); + +// \renewcommand{\bmod}{\nonscript\mskip-\medmuskip\mkern5mu\mathbin +// {\operator@font mod}\penalty900 +// \mkern5mu\nonscript\mskip-\medmuskip} +// \newcommand{\pod}[1]{\allowbreak +// \if@display\mkern18mu\else\mkern8mu\fi(#1)} +// \renewcommand{\pmod}[1]{\pod{{\operator@font mod}\mkern6mu#1}} +// \newcommand{\mod}[1]{\allowbreak\if@display\mkern18mu +// \else\mkern12mu\fi{\operator@font mod}\,\,#1} +// TODO: math mode should use \medmuskip = 4mu plus 2mu minus 4mu +defineMacro("\\bmod", + "\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}" + + "\\mathbin{\\rm mod}" + + "\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}"); +defineMacro("\\pod", "\\allowbreak" + + "\\mathchoice{\\mkern18mu}{\\mkern8mu}{\\mkern8mu}{\\mkern8mu}(#1)"); +defineMacro("\\pmod", "\\pod{{\\rm mod}\\mkern6mu#1}"); +defineMacro("\\mod", "\\allowbreak" + + "\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}" + + "{\\rm mod}\\,\\,#1"); + +////////////////////////////////////////////////////////////////////// +// LaTeX source2e + +// \expandafter\let\expandafter\@normalcr +// \csname\expandafter\@gobble\string\\ \endcsname +// \DeclareRobustCommand\newline{\@normalcr\relax} +defineMacro("\\newline", "\\\\\\relax"); + +// \def\TeX{T\kern-.1667em\lower.5ex\hbox{E}\kern-.125emX\@} +// TODO: Doesn't normally work in math mode because \@ fails. KaTeX doesn't +// support \@ yet, so that's omitted, and we add \text so that the result +// doesn't look funny in math mode. +defineMacro("\\TeX", "\\textrm{\\html@mathml{" + + "T\\kern-.1667em\\raisebox{-.5ex}{E}\\kern-.125emX" + + "}{TeX}}"); + +// \DeclareRobustCommand{\LaTeX}{L\kern-.36em% +// {\sbox\z@ T% +// \vbox to\ht\z@{\hbox{\check@mathfonts +// \fontsize\sf@size\z@ +// \math@fontsfalse\selectfont +// A}% +// \vss}% +// }% +// \kern-.15em% +// \TeX} +// This code aligns the top of the A with the T (from the perspective of TeX's +// boxes, though visually the A appears to extend above slightly). +// We compute the corresponding \raisebox when A is rendered in \normalsize +// \scriptstyle, which has a scale factor of 0.7 (see Options.js). +const latexRaiseA = makeEm(fontMetricsData['Main-Regular']["T".charCodeAt(0)][1] - + 0.7 * fontMetricsData['Main-Regular']["A".charCodeAt(0)][1]); +defineMacro("\\LaTeX", "\\textrm{\\html@mathml{" + + `L\\kern-.36em\\raisebox{${latexRaiseA}}{\\scriptstyle A}` + + "\\kern-.15em\\TeX}{LaTeX}}"); + +// New KaTeX logo based on tweaking LaTeX logo +defineMacro("\\KaTeX", "\\textrm{\\html@mathml{" + + `K\\kern-.17em\\raisebox{${latexRaiseA}}{\\scriptstyle A}` + + "\\kern-.15em\\TeX}{KaTeX}}"); + +// \DeclareRobustCommand\hspace{\@ifstar\@hspacer\@hspace} +// \def\@hspace#1{\hskip #1\relax} +// \def\@hspacer#1{\vrule \@width\z@\nobreak +// \hskip #1\hskip \z@skip} +defineMacro("\\hspace", "\\@ifstar\\@hspacer\\@hspace"); +defineMacro("\\@hspace", "\\hskip #1\\relax"); +defineMacro("\\@hspacer", "\\rule{0pt}{0pt}\\hskip #1\\relax"); + +////////////////////////////////////////////////////////////////////// +// mathtools.sty + +//\providecommand\ordinarycolon{:} +defineMacro("\\ordinarycolon", ":"); +//\def\vcentcolon{\mathrel{\mathop\ordinarycolon}} +//TODO(edemaine): Not yet centered. Fix via \raisebox or #726 +defineMacro("\\vcentcolon", "\\mathrel{\\mathop\\ordinarycolon}"); +// \providecommand*\dblcolon{\vcentcolon\mathrel{\mkern-.9mu}\vcentcolon} +defineMacro("\\dblcolon", "\\html@mathml{" + + "\\mathrel{\\vcentcolon\\mathrel{\\mkern-.9mu}\\vcentcolon}}" + + "{\\mathop{\\char\"2237}}"); +// \providecommand*\coloneqq{\vcentcolon\mathrel{\mkern-1.2mu}=} +defineMacro("\\coloneqq", "\\html@mathml{" + + "\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}=}}" + + "{\\mathop{\\char\"2254}}"); // ≔ +// \providecommand*\Coloneqq{\dblcolon\mathrel{\mkern-1.2mu}=} +defineMacro("\\Coloneqq", "\\html@mathml{" + + "\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}=}}" + + "{\\mathop{\\char\"2237\\char\"3d}}"); +// \providecommand*\coloneq{\vcentcolon\mathrel{\mkern-1.2mu}\mathrel{-}} +defineMacro("\\coloneq", "\\html@mathml{" + + "\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}" + + "{\\mathop{\\char\"3a\\char\"2212}}"); +// \providecommand*\Coloneq{\dblcolon\mathrel{\mkern-1.2mu}\mathrel{-}} +defineMacro("\\Coloneq", "\\html@mathml{" + + "\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}" + + "{\\mathop{\\char\"2237\\char\"2212}}"); +// \providecommand*\eqqcolon{=\mathrel{\mkern-1.2mu}\vcentcolon} +defineMacro("\\eqqcolon", "\\html@mathml{" + + "\\mathrel{=\\mathrel{\\mkern-1.2mu}\\vcentcolon}}" + + "{\\mathop{\\char\"2255}}"); // ≕ +// \providecommand*\Eqqcolon{=\mathrel{\mkern-1.2mu}\dblcolon} +defineMacro("\\Eqqcolon", "\\html@mathml{" + + "\\mathrel{=\\mathrel{\\mkern-1.2mu}\\dblcolon}}" + + "{\\mathop{\\char\"3d\\char\"2237}}"); +// \providecommand*\eqcolon{\mathrel{-}\mathrel{\mkern-1.2mu}\vcentcolon} +defineMacro("\\eqcolon", "\\html@mathml{" + + "\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\vcentcolon}}" + + "{\\mathop{\\char\"2239}}"); +// \providecommand*\Eqcolon{\mathrel{-}\mathrel{\mkern-1.2mu}\dblcolon} +defineMacro("\\Eqcolon", "\\html@mathml{" + + "\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\dblcolon}}" + + "{\\mathop{\\char\"2212\\char\"2237}}"); +// \providecommand*\colonapprox{\vcentcolon\mathrel{\mkern-1.2mu}\approx} +defineMacro("\\colonapprox", "\\html@mathml{" + + "\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\approx}}" + + "{\\mathop{\\char\"3a\\char\"2248}}"); +// \providecommand*\Colonapprox{\dblcolon\mathrel{\mkern-1.2mu}\approx} +defineMacro("\\Colonapprox", "\\html@mathml{" + + "\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\approx}}" + + "{\\mathop{\\char\"2237\\char\"2248}}"); +// \providecommand*\colonsim{\vcentcolon\mathrel{\mkern-1.2mu}\sim} +defineMacro("\\colonsim", "\\html@mathml{" + + "\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\sim}}" + + "{\\mathop{\\char\"3a\\char\"223c}}"); +// \providecommand*\Colonsim{\dblcolon\mathrel{\mkern-1.2mu}\sim} +defineMacro("\\Colonsim", "\\html@mathml{" + + "\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\sim}}" + + "{\\mathop{\\char\"2237\\char\"223c}}"); + +// Some Unicode characters are implemented with macros to mathtools functions. +defineMacro("\u2237", "\\dblcolon"); // :: +defineMacro("\u2239", "\\eqcolon"); // -: +defineMacro("\u2254", "\\coloneqq"); // := +defineMacro("\u2255", "\\eqqcolon"); // =: +defineMacro("\u2A74", "\\Coloneqq"); // ::= + +////////////////////////////////////////////////////////////////////// +// colonequals.sty + +// Alternate names for mathtools's macros: +defineMacro("\\ratio", "\\vcentcolon"); +defineMacro("\\coloncolon", "\\dblcolon"); +defineMacro("\\colonequals", "\\coloneqq"); +defineMacro("\\coloncolonequals", "\\Coloneqq"); +defineMacro("\\equalscolon", "\\eqqcolon"); +defineMacro("\\equalscoloncolon", "\\Eqqcolon"); +defineMacro("\\colonminus", "\\coloneq"); +defineMacro("\\coloncolonminus", "\\Coloneq"); +defineMacro("\\minuscolon", "\\eqcolon"); +defineMacro("\\minuscoloncolon", "\\Eqcolon"); +// \colonapprox name is same in mathtools and colonequals. +defineMacro("\\coloncolonapprox", "\\Colonapprox"); +// \colonsim name is same in mathtools and colonequals. +defineMacro("\\coloncolonsim", "\\Colonsim"); + +// Additional macros, implemented by analogy with mathtools definitions: +defineMacro("\\simcolon", + "\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\vcentcolon}"); +defineMacro("\\simcoloncolon", + "\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\dblcolon}"); +defineMacro("\\approxcolon", + "\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\vcentcolon}"); +defineMacro("\\approxcoloncolon", + "\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\dblcolon}"); + +// Present in newtxmath, pxfonts and txfonts +defineMacro("\\notni", "\\html@mathml{\\not\\ni}{\\mathrel{\\char`\u220C}}"); +defineMacro("\\limsup", "\\DOTSB\\operatorname*{lim\\,sup}"); +defineMacro("\\liminf", "\\DOTSB\\operatorname*{lim\\,inf}"); + +////////////////////////////////////////////////////////////////////// +// From amsopn.sty +defineMacro("\\injlim", "\\DOTSB\\operatorname*{inj\\,lim}"); +defineMacro("\\projlim", "\\DOTSB\\operatorname*{proj\\,lim}"); +defineMacro("\\varlimsup", "\\DOTSB\\operatorname*{\\overline{lim}}"); +defineMacro("\\varliminf", "\\DOTSB\\operatorname*{\\underline{lim}}"); +defineMacro("\\varinjlim", "\\DOTSB\\operatorname*{\\underrightarrow{lim}}"); +defineMacro("\\varprojlim", "\\DOTSB\\operatorname*{\\underleftarrow{lim}}"); + +////////////////////////////////////////////////////////////////////// +// MathML alternates for KaTeX glyphs in the Unicode private area +defineMacro("\\gvertneqq", "\\html@mathml{\\@gvertneqq}{\u2269}"); +defineMacro("\\lvertneqq", "\\html@mathml{\\@lvertneqq}{\u2268}"); +defineMacro("\\ngeqq", "\\html@mathml{\\@ngeqq}{\u2271}"); +defineMacro("\\ngeqslant", "\\html@mathml{\\@ngeqslant}{\u2271}"); +defineMacro("\\nleqq", "\\html@mathml{\\@nleqq}{\u2270}"); +defineMacro("\\nleqslant", "\\html@mathml{\\@nleqslant}{\u2270}"); +defineMacro("\\nshortmid", "\\html@mathml{\\@nshortmid}{∤}"); +defineMacro("\\nshortparallel", "\\html@mathml{\\@nshortparallel}{∦}"); +defineMacro("\\nsubseteqq", "\\html@mathml{\\@nsubseteqq}{\u2288}"); +defineMacro("\\nsupseteqq", "\\html@mathml{\\@nsupseteqq}{\u2289}"); +defineMacro("\\varsubsetneq", "\\html@mathml{\\@varsubsetneq}{⊊}"); +defineMacro("\\varsubsetneqq", "\\html@mathml{\\@varsubsetneqq}{⫋}"); +defineMacro("\\varsupsetneq", "\\html@mathml{\\@varsupsetneq}{⊋}"); +defineMacro("\\varsupsetneqq", "\\html@mathml{\\@varsupsetneqq}{⫌}"); +defineMacro("\\imath", "\\html@mathml{\\@imath}{\u0131}"); +defineMacro("\\jmath", "\\html@mathml{\\@jmath}{\u0237}"); + +////////////////////////////////////////////////////////////////////// +// stmaryrd and semantic + +// The stmaryrd and semantic packages render the next four items by calling a +// glyph. Those glyphs do not exist in the KaTeX fonts. Hence the macros. + +defineMacro("\\llbracket", "\\html@mathml{" + + "\\mathopen{[\\mkern-3.2mu[}}" + + "{\\mathopen{\\char`\u27e6}}"); +defineMacro("\\rrbracket", "\\html@mathml{" + + "\\mathclose{]\\mkern-3.2mu]}}" + + "{\\mathclose{\\char`\u27e7}}"); + +defineMacro("\u27e6", "\\llbracket"); // blackboard bold [ +defineMacro("\u27e7", "\\rrbracket"); // blackboard bold ] + +defineMacro("\\lBrace", "\\html@mathml{" + + "\\mathopen{\\{\\mkern-3.2mu[}}" + + "{\\mathopen{\\char`\u2983}}"); +defineMacro("\\rBrace", "\\html@mathml{" + + "\\mathclose{]\\mkern-3.2mu\\}}}" + + "{\\mathclose{\\char`\u2984}}"); + +defineMacro("\u2983", "\\lBrace"); // blackboard bold { +defineMacro("\u2984", "\\rBrace"); // blackboard bold } + +// TODO: Create variable sized versions of the last two items. I believe that +// will require new font glyphs. + +// The stmaryrd function `\minuso` provides a "Plimsoll" symbol that +// superimposes the characters \circ and \mathminus. Used in chemistry. +defineMacro("\\minuso", "\\mathbin{\\html@mathml{" + + "{\\mathrlap{\\mathchoice{\\kern{0.145em}}{\\kern{0.145em}}" + + "{\\kern{0.1015em}}{\\kern{0.0725em}}\\circ}{-}}}" + + "{\\char`⦵}}"); +defineMacro("⦵", "\\minuso"); + +////////////////////////////////////////////////////////////////////// +// texvc.sty + +// The texvc package contains macros available in mediawiki pages. +// We omit the functions deprecated at +// https://en.wikipedia.org/wiki/Help:Displaying_a_formula#Deprecated_syntax + +// We also omit texvc's \O, which conflicts with \text{\O} + +defineMacro("\\darr", "\\downarrow"); +defineMacro("\\dArr", "\\Downarrow"); +defineMacro("\\Darr", "\\Downarrow"); +defineMacro("\\lang", "\\langle"); +defineMacro("\\rang", "\\rangle"); +defineMacro("\\uarr", "\\uparrow"); +defineMacro("\\uArr", "\\Uparrow"); +defineMacro("\\Uarr", "\\Uparrow"); +defineMacro("\\N", "\\mathbb{N}"); +defineMacro("\\R", "\\mathbb{R}"); +defineMacro("\\Z", "\\mathbb{Z}"); +defineMacro("\\alef", "\\aleph"); +defineMacro("\\alefsym", "\\aleph"); +defineMacro("\\Alpha", "\\mathrm{A}"); +defineMacro("\\Beta", "\\mathrm{B}"); +defineMacro("\\bull", "\\bullet"); +defineMacro("\\Chi", "\\mathrm{X}"); +defineMacro("\\clubs", "\\clubsuit"); +defineMacro("\\cnums", "\\mathbb{C}"); +defineMacro("\\Complex", "\\mathbb{C}"); +defineMacro("\\Dagger", "\\ddagger"); +defineMacro("\\diamonds", "\\diamondsuit"); +defineMacro("\\empty", "\\emptyset"); +defineMacro("\\Epsilon", "\\mathrm{E}"); +defineMacro("\\Eta", "\\mathrm{H}"); +defineMacro("\\exist", "\\exists"); +defineMacro("\\harr", "\\leftrightarrow"); +defineMacro("\\hArr", "\\Leftrightarrow"); +defineMacro("\\Harr", "\\Leftrightarrow"); +defineMacro("\\hearts", "\\heartsuit"); +defineMacro("\\image", "\\Im"); +defineMacro("\\infin", "\\infty"); +defineMacro("\\Iota", "\\mathrm{I}"); +defineMacro("\\isin", "\\in"); +defineMacro("\\Kappa", "\\mathrm{K}"); +defineMacro("\\larr", "\\leftarrow"); +defineMacro("\\lArr", "\\Leftarrow"); +defineMacro("\\Larr", "\\Leftarrow"); +defineMacro("\\lrarr", "\\leftrightarrow"); +defineMacro("\\lrArr", "\\Leftrightarrow"); +defineMacro("\\Lrarr", "\\Leftrightarrow"); +defineMacro("\\Mu", "\\mathrm{M}"); +defineMacro("\\natnums", "\\mathbb{N}"); +defineMacro("\\Nu", "\\mathrm{N}"); +defineMacro("\\Omicron", "\\mathrm{O}"); +defineMacro("\\plusmn", "\\pm"); +defineMacro("\\rarr", "\\rightarrow"); +defineMacro("\\rArr", "\\Rightarrow"); +defineMacro("\\Rarr", "\\Rightarrow"); +defineMacro("\\real", "\\Re"); +defineMacro("\\reals", "\\mathbb{R}"); +defineMacro("\\Reals", "\\mathbb{R}"); +defineMacro("\\Rho", "\\mathrm{P}"); +defineMacro("\\sdot", "\\cdot"); +defineMacro("\\sect", "\\S"); +defineMacro("\\spades", "\\spadesuit"); +defineMacro("\\sub", "\\subset"); +defineMacro("\\sube", "\\subseteq"); +defineMacro("\\supe", "\\supseteq"); +defineMacro("\\Tau", "\\mathrm{T}"); +defineMacro("\\thetasym", "\\vartheta"); +// TODO: defineMacro("\\varcoppa", "\\\mbox{\\coppa}"); +defineMacro("\\weierp", "\\wp"); +defineMacro("\\Zeta", "\\mathrm{Z}"); + +////////////////////////////////////////////////////////////////////// +// statmath.sty +// https://ctan.math.illinois.edu/macros/latex/contrib/statmath/statmath.pdf + +defineMacro("\\argmin", "\\DOTSB\\operatorname*{arg\\,min}"); +defineMacro("\\argmax", "\\DOTSB\\operatorname*{arg\\,max}"); +defineMacro("\\plim", "\\DOTSB\\mathop{\\operatorname{plim}}\\limits"); + +////////////////////////////////////////////////////////////////////// +// braket.sty +// http://ctan.math.washington.edu/tex-archive/macros/latex/contrib/braket/braket.pdf + +defineMacro("\\bra", "\\mathinner{\\langle{#1}|}"); +defineMacro("\\ket", "\\mathinner{|{#1}\\rangle}"); +defineMacro("\\braket", "\\mathinner{\\langle{#1}\\rangle}"); +defineMacro("\\Bra", "\\left\\langle#1\\right|"); +defineMacro("\\Ket", "\\left|#1\\right\\rangle"); +const braketHelper = (one: boolean) => (context: MacroContextInterface) => { + const left = context.consumeArg().tokens; + const middle = context.consumeArg().tokens; + const middleDouble = context.consumeArg().tokens; + const right = context.consumeArg().tokens; + const oldMiddle = context.macros.get("|"); + const oldMiddleDouble = context.macros.get("\\|"); + context.macros.beginGroup(); + const midMacro = (double: boolean) => (context: MacroContextInterface) => { + if (one) { + // Only modify the first instance of | or \| + context.macros.set("|", oldMiddle); + if (middleDouble.length) { + context.macros.set("\\|", oldMiddleDouble); + } + } + let doubled = double; + if (!double && middleDouble.length) { + // Mimic \@ifnextchar + const nextToken = context.future(); + if (nextToken.text === "|") { + context.popToken(); + doubled = true; + } + } + return { + tokens: doubled ? middleDouble : middle, + numArgs: 0, + }; + }; + context.macros.set("|", midMacro(false)); + if (middleDouble.length) { + context.macros.set("\\|", midMacro(true)); + } + const arg = context.consumeArg().tokens; + const expanded = context.expandTokens([ + ...right, ...arg, ...left, // reversed + ]); + context.macros.endGroup(); + return { + tokens: expanded.reverse(), + numArgs: 0, + }; +}; +defineMacro("\\bra@ket", braketHelper(false)); +defineMacro("\\bra@set", braketHelper(true)); +defineMacro("\\Braket", "\\bra@ket{\\left\\langle}" + + "{\\,\\middle\\vert\\,}{\\,\\middle\\vert\\,}{\\right\\rangle}"); +defineMacro("\\Set", "\\bra@set{\\left\\{\\:}" + + "{\\;\\middle\\vert\\;}{\\;\\middle\\Vert\\;}{\\:\\right\\}}"); +defineMacro("\\set", "\\bra@set{\\{\\,}{\\mid}{}{\\,\\}}"); + // has no support for special || or \| + +////////////////////////////////////////////////////////////////////// +// actuarialangle.dtx +defineMacro("\\angln", "{\\angl n}"); + +// Custom Khan Academy colors, should be moved to an optional package +defineMacro("\\blue", "\\textcolor{##6495ed}{#1}"); +defineMacro("\\orange", "\\textcolor{##ffa500}{#1}"); +defineMacro("\\pink", "\\textcolor{##ff00af}{#1}"); +defineMacro("\\red", "\\textcolor{##df0030}{#1}"); +defineMacro("\\green", "\\textcolor{##28ae7b}{#1}"); +defineMacro("\\gray", "\\textcolor{gray}{#1}"); +defineMacro("\\purple", "\\textcolor{##9d38bd}{#1}"); +defineMacro("\\blueA", "\\textcolor{##ccfaff}{#1}"); +defineMacro("\\blueB", "\\textcolor{##80f6ff}{#1}"); +defineMacro("\\blueC", "\\textcolor{##63d9ea}{#1}"); +defineMacro("\\blueD", "\\textcolor{##11accd}{#1}"); +defineMacro("\\blueE", "\\textcolor{##0c7f99}{#1}"); +defineMacro("\\tealA", "\\textcolor{##94fff5}{#1}"); +defineMacro("\\tealB", "\\textcolor{##26edd5}{#1}"); +defineMacro("\\tealC", "\\textcolor{##01d1c1}{#1}"); +defineMacro("\\tealD", "\\textcolor{##01a995}{#1}"); +defineMacro("\\tealE", "\\textcolor{##208170}{#1}"); +defineMacro("\\greenA", "\\textcolor{##b6ffb0}{#1}"); +defineMacro("\\greenB", "\\textcolor{##8af281}{#1}"); +defineMacro("\\greenC", "\\textcolor{##74cf70}{#1}"); +defineMacro("\\greenD", "\\textcolor{##1fab54}{#1}"); +defineMacro("\\greenE", "\\textcolor{##0d923f}{#1}"); +defineMacro("\\goldA", "\\textcolor{##ffd0a9}{#1}"); +defineMacro("\\goldB", "\\textcolor{##ffbb71}{#1}"); +defineMacro("\\goldC", "\\textcolor{##ff9c39}{#1}"); +defineMacro("\\goldD", "\\textcolor{##e07d10}{#1}"); +defineMacro("\\goldE", "\\textcolor{##a75a05}{#1}"); +defineMacro("\\redA", "\\textcolor{##fca9a9}{#1}"); +defineMacro("\\redB", "\\textcolor{##ff8482}{#1}"); +defineMacro("\\redC", "\\textcolor{##f9685d}{#1}"); +defineMacro("\\redD", "\\textcolor{##e84d39}{#1}"); +defineMacro("\\redE", "\\textcolor{##bc2612}{#1}"); +defineMacro("\\maroonA", "\\textcolor{##ffbde0}{#1}"); +defineMacro("\\maroonB", "\\textcolor{##ff92c6}{#1}"); +defineMacro("\\maroonC", "\\textcolor{##ed5fa6}{#1}"); +defineMacro("\\maroonD", "\\textcolor{##ca337c}{#1}"); +defineMacro("\\maroonE", "\\textcolor{##9e034e}{#1}"); +defineMacro("\\purpleA", "\\textcolor{##ddd7ff}{#1}"); +defineMacro("\\purpleB", "\\textcolor{##c6b9fc}{#1}"); +defineMacro("\\purpleC", "\\textcolor{##aa87ff}{#1}"); +defineMacro("\\purpleD", "\\textcolor{##7854ab}{#1}"); +defineMacro("\\purpleE", "\\textcolor{##543b78}{#1}"); +defineMacro("\\mintA", "\\textcolor{##f5f9e8}{#1}"); +defineMacro("\\mintB", "\\textcolor{##edf2df}{#1}"); +defineMacro("\\mintC", "\\textcolor{##e0e5cc}{#1}"); +defineMacro("\\grayA", "\\textcolor{##f6f7f7}{#1}"); +defineMacro("\\grayB", "\\textcolor{##f0f1f2}{#1}"); +defineMacro("\\grayC", "\\textcolor{##e3e5e6}{#1}"); +defineMacro("\\grayD", "\\textcolor{##d6d8da}{#1}"); +defineMacro("\\grayE", "\\textcolor{##babec2}{#1}"); +defineMacro("\\grayF", "\\textcolor{##888d93}{#1}"); +defineMacro("\\grayG", "\\textcolor{##626569}{#1}"); +defineMacro("\\grayH", "\\textcolor{##3b3e40}{#1}"); +defineMacro("\\grayI", "\\textcolor{##21242c}{#1}"); +defineMacro("\\kaBlue", "\\textcolor{##314453}{#1}"); +defineMacro("\\kaGreen", "\\textcolor{##71B307}{#1}"); diff --git a/node_modules/katex/src/mathMLTree.ts b/node_modules/katex/src/mathMLTree.ts new file mode 100644 index 0000000..4bb925f --- /dev/null +++ b/node_modules/katex/src/mathMLTree.ts @@ -0,0 +1,259 @@ +/** + * These objects store data about MathML nodes. This is the MathML equivalent + * of the types in domTree.js. Since MathML handles its own rendering, and + * since we're mainly using MathML to improve accessibility, we don't manage + * any of the styling state that the plain DOM nodes do. + * + * The `toNode` and `toMarkup` functions work similarly to how they do in + * domTree.js, creating namespaced DOM nodes and HTML text markup respectively. + */ + +import {escape} from "./utils"; +import {DocumentFragment} from "./tree"; +import {createClass} from "./domTree"; +import {makeEm} from "./units"; + +import type {VirtualNode} from "./tree"; + +/** + * MathML node types used in KaTeX. For a complete list of MathML nodes, see + * https://developer.mozilla.org/en-US/docs/Web/MathML/Element. + */ +export type MathNodeType = + "math" | "annotation" | "semantics" | + "mtext" | "mn" | "mo" | "mi" | "mspace" | + "mover" | "munder" | "munderover" | "msup" | "msub" | "msubsup" | + "mfrac" | "mroot" | "msqrt" | + "mtable" | "mtr" | "mtd" | "mlabeledtr" | + "mrow" | "menclose" | + "mstyle" | "mpadded" | "mphantom" | "mglyph"; + +export interface MathDomNode extends VirtualNode { + toText(): string; +} + +export type documentFragment = DocumentFragment; +export function newDocumentFragment( + children: ReadonlyArray +): documentFragment { + return new DocumentFragment(children); +} + +/** + * This node represents a general purpose MathML node of any type. The + * constructor requires the type of node to create (for example, `"mo"` or + * `"mspace"`, corresponding to `` and `` tags). + */ +export class MathNode implements MathDomNode { + type: MathNodeType; + attributes: Record; + children: MathDomNode[]; + classes: string[]; + + constructor( + type: MathNodeType, + children?: MathDomNode[], + classes?: string[] + ) { + this.type = type; + this.attributes = {}; + this.children = children || []; + this.classes = classes || []; + } + + /** + * Sets an attribute on a MathML node. MathML depends on attributes to convey a + * semantic content, so this is used heavily. + */ + setAttribute(name: string, value: string) { + this.attributes[name] = value; + } + + /** + * Gets an attribute on a MathML node. + */ + getAttribute(name: string): string { + return this.attributes[name]; + } + + /** + * Converts the math node into a MathML-namespaced DOM element. + */ + toNode(): Node { + const node = document.createElementNS( + "http://www.w3.org/1998/Math/MathML", this.type); + + for (const attr in this.attributes) { + if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) { + node.setAttribute(attr, this.attributes[attr]); + } + } + + if (this.classes.length > 0) { + node.className = createClass(this.classes); + } + + for (let i = 0; i < this.children.length; i++) { + // Combine multiple TextNodes into one TextNode, to prevent + // screen readers from reading each as a separate word [#3995] + if (this.children[i] instanceof TextNode && + this.children[i + 1] instanceof TextNode) { + let text = this.children[i].toText() + this.children[++i].toText(); + while (this.children[i + 1] instanceof TextNode) { + text += this.children[++i].toText(); + } + node.appendChild(new TextNode(text).toNode()); + } else { + node.appendChild(this.children[i].toNode()); + } + } + + return node; + } + + /** + * Converts the math node into an HTML markup string. + */ + toMarkup(): string { + let markup = "<" + this.type; + + // Add the attributes + for (const attr in this.attributes) { + if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) { + markup += " " + attr + "=\""; + markup += escape(this.attributes[attr]); + markup += "\""; + } + } + + if (this.classes.length > 0) { + markup += ` class ="${escape(createClass(this.classes))}"`; + } + + markup += ">"; + + for (let i = 0; i < this.children.length; i++) { + markup += this.children[i].toMarkup(); + } + + markup += ""; + + return markup; + } + + /** + * Converts the math node into a string, similar to innerText, but escaped. + */ + toText(): string { + return this.children.map(child => child.toText()).join(""); + } +} + +/** + * This node represents a piece of text. + */ +export class TextNode implements MathDomNode { + text: string; + + constructor(text: string) { + this.text = text; + } + + /** + * Converts the text node into a DOM text node. + */ + toNode(): Node { + return document.createTextNode(this.text); + } + + /** + * Converts the text node into escaped HTML markup + * (representing the text itself). + */ + toMarkup(): string { + return escape(this.toText()); + } + + /** + * Converts the text node into a string + * (representing the text itself). + */ + toText(): string { + return this.text; + } +} + +/** + * This node represents a space, but may render as or as text, + * depending on the width. + */ +export class SpaceNode implements MathDomNode { + width: number; + character: string | null | undefined; + + /** + * Create a Space node with width given in CSS ems. + */ + constructor(width: number) { + this.width = width; + // See https://www.w3.org/TR/2000/WD-MathML2-20000328/chapter6.html + // for a table of space-like characters. We use Unicode + // representations instead of &LongNames; as it's not clear how to + // make the latter via document.createTextNode. + if (width >= 0.05555 && width <= 0.05556) { + this.character = "\u200a"; //   + } else if (width >= 0.1666 && width <= 0.1667) { + this.character = "\u2009"; //   + } else if (width >= 0.2222 && width <= 0.2223) { + this.character = "\u2005"; //   + } else if (width >= 0.2777 && width <= 0.2778) { + this.character = "\u2005\u200a"; //    + } else if (width >= -0.05556 && width <= -0.05555) { + this.character = "\u200a\u2063"; // ​ + } else if (width >= -0.1667 && width <= -0.1666) { + this.character = "\u2009\u2063"; // ​ + } else if (width >= -0.2223 && width <= -0.2222) { + this.character = "\u205f\u2063"; // ​ + } else if (width >= -0.2778 && width <= -0.2777) { + this.character = "\u2005\u2063"; // ​ + } else { + this.character = null; + } + } + + /** + * Converts the math node into a MathML-namespaced DOM element. + */ + toNode(): Node { + if (this.character) { + return document.createTextNode(this.character); + } else { + const node = document.createElementNS( + "http://www.w3.org/1998/Math/MathML", "mspace"); + node.setAttribute("width", makeEm(this.width)); + return node; + } + } + + /** + * Converts the math node into an HTML markup string. + */ + toMarkup(): string { + if (this.character) { + return `${this.character}`; + } else { + return ``; + } + } + + /** + * Converts the math node into a string, similar to innerText. + */ + toText(): string { + if (this.character) { + return this.character; + } else { + return " "; + } + } +} diff --git a/node_modules/katex/src/metrics/README.md b/node_modules/katex/src/metrics/README.md new file mode 100644 index 0000000..c340e72 --- /dev/null +++ b/node_modules/katex/src/metrics/README.md @@ -0,0 +1,23 @@ +### How to generate new metrics +------------------------------- + +There are several requirements for generating the metrics used by KaTeX. + +- You need to have an installation of TeX which supports kpathsea. You can check + this by running `tex --version`, and seeing if it has a line that looks like + > kpathsea version 6.2.0 + +- You need the Perl module `JSON`. You can install this either from CPAN + (e.g. using the `cpan` command line tool: `cpan install JSON`) + or with your package manager. + +- You need the Python module `fonttools`. You can install this either from PyPI + (using `easy_install` or `pip`: `pip install fonttools`) + or with your package manager. + +Once you have these things, run the following command from the root directory: + + sh ./dockers/fonts/buildMetrics.sh + +which should generate new metrics and place them into `fontMetricsData.json`. +You're done! diff --git a/node_modules/katex/src/metrics/extract_tfms.py b/node_modules/katex/src/metrics/extract_tfms.py new file mode 100644 index 0000000..70297dc --- /dev/null +++ b/node_modules/katex/src/metrics/extract_tfms.py @@ -0,0 +1,114 @@ +#!/usr/bin/env python3 + +import collections +import json +import parse_tfm +import subprocess +import sys + + +def find_font_path(font_name): + try: + font_path = subprocess.check_output(['kpsewhich', font_name]) + except OSError: + raise RuntimeError("Couldn't find kpsewhich program, make sure you" + + " have TeX installed") + except subprocess.CalledProcessError: + raise RuntimeError("Couldn't find font metrics: '%s'" % font_name) + return font_path.strip() + + +def main(): + mapping = json.load(sys.stdin) + + fonts = [ + 'cmbsy10.tfm', + 'cmbx10.tfm', + 'cmbxti10.tfm', + 'cmex10.tfm', + 'cmmi10.tfm', + 'cmmib10.tfm', + 'cmr10.tfm', + 'cmsy10.tfm', + 'cmti10.tfm', + 'msam10.tfm', + 'msbm10.tfm', + 'eufm10.tfm', + 'cmtt10.tfm', + 'rsfs10.tfm', + 'cmss10.tfm', + 'cmssbx10.tfm', + 'cmssi10.tfm', + ] + + # Extracted by running `\font\a=` and then `\showthe\skewchar\a` in + # TeX, where `` is the name of the font listed here. The skewchar + # will be printed out in the output. If it outputs `-1`, that means there + # is no skewchar, so we use `None` here. + font_skewchar = { + 'cmbsy10': None, + 'cmbx10': None, + 'cmbxti10': None, + 'cmex10': None, + 'cmmi10': 127, + 'cmmib10': None, + 'cmr10': None, + 'cmsy10': 48, + 'cmti10': None, + 'msam10': None, + 'msbm10': None, + 'eufm10': None, + 'cmtt10': None, + 'rsfs10': None, + 'cmss10': None, + 'cmssbx10': None, + 'cmssi10': None, + } + + font_name_to_tfm = {} + + for font_name in fonts: + font_basename = font_name.split('.')[0] + font_path = find_font_path(font_name) + font_name_to_tfm[font_basename] = parse_tfm.read_tfm_file(font_path) + + families = collections.defaultdict(dict) + + for family, chars in mapping.items(): + for char, char_data in chars.items(): + char_num = int(char) + + font = char_data['font'] + tex_char_num = int(char_data['char']) + yshift = float(char_data['yshift']) + + if family == "Script-Regular": + tfm_char = font_name_to_tfm[font].get_char_metrics(tex_char_num, + fix_rsfs=True) + else: + tfm_char = font_name_to_tfm[font].get_char_metrics(tex_char_num) + + height = round(tfm_char.height + yshift / 1000.0, 5) + depth = round(tfm_char.depth - yshift / 1000.0, 5) + italic = round(tfm_char.italic_correction, 5) + width = round(tfm_char.width, 5) + + skewkern = 0.0 + if (font_skewchar[font] and + font_skewchar[font] in tfm_char.kern_table): + skewkern = round( + tfm_char.kern_table[font_skewchar[font]], 5) + + families[family][char_num] = { + 'height': height, + 'depth': depth, + 'italic': italic, + 'skew': skewkern, + 'width': width + } + + sys.stdout.write( + json.dumps(families, separators=(',', ':'), sort_keys=True)) + +if __name__ == '__main__': + main() diff --git a/node_modules/katex/src/metrics/extract_ttfs.py b/node_modules/katex/src/metrics/extract_ttfs.py new file mode 100644 index 0000000..29f9225 --- /dev/null +++ b/node_modules/katex/src/metrics/extract_ttfs.py @@ -0,0 +1,122 @@ +#!/usr/bin/env python3 + +from fontTools.ttLib import TTFont +import sys +import json + +# map of characters to extract +metrics_to_extract = { + # Font name + "AMS-Regular": { + u"\u21e2": None, # \dashrightarrow + u"\u21e0": None, # \dashleftarrow + }, + "Main-Regular": { + # Skew and italic metrics can't be easily parsed from the TTF. Instead, + # we map each character to a "base character", which is a character + # from the same font with correct italic and skew metrics. A character + # maps to None if it doesn't have a base. + + #u"\u2209": None, # \notin + #u"\u2260": None, # \neq + u"\u2245": None, # \cong + u"\u2026": None, # \ldots + u"\u22ef": None, # \cdots + u"\u22f1": None, # \ddots + u"\u22ee": None, # \vdots + u"\u22ee": None, # \vdots + u"\u22a8": None, # \models + u"\u22c8": None, # \bowtie + u"\u2250": None, # \doteq + u"\u23b0": None, # \lmoustache + u"\u23b1": None, # \rmoustache + u"\u27ee": None, # \lgroup + u"\u27ef": None, # \rgroup + u"\u27f5": None, # \longleftarrow + u"\u27f8": None, # \Longleftarrow + u"\u27f6": None, # \longrightarrow + u"\u27f9": None, # \Longrightarrow + u"\u27f7": None, # \longleftrightarrow + u"\u27fa": None, # \Longleftrightarrow + u"\u21a6": None, # \mapsto + u"\u27fc": None, # \longmapsto + u"\u21a9": None, # \hookleftarrow + u"\u21aa": None, # \hookrightarrow + u"\u21cc": None, # \rightleftharpoons + }, + "Main-Bold": { + u"\u2245": None, # \cong + }, + "Size1-Regular": { + u"\u222c": u"\u222b", # \iint, based on \int + u"\u222d": u"\u222b", # \iiint, based on \int + }, + "Size2-Regular": { + u"\u222c": u"\u222b", # \iint, based on \int + u"\u222d": u"\u222b", # \iiint, based on \int + }, +} + + +def main(): + start_json = json.load(sys.stdin) + + for font in start_json: + fontInfo = TTFont("../../fonts/KaTeX_" + font + ".ttf") + glyf = fontInfo["glyf"] + widths = fontInfo.getGlyphSet() + unitsPerEm = float(fontInfo["head"].unitsPerEm) + + # We keep ALL Unicode cmaps, not just fontInfo["cmap"].getcmap(3, 1). + # This is playing it extra safe, since it reports inconsistencies. + # Platform 0 is Unicode, platform 3 is Windows. For platform 3, + # encoding 1 is UCS-2 and encoding 10 is UCS-4. + cmap = [t.cmap for t in fontInfo["cmap"].tables + if (t.platformID == 0) + or (t.platformID == 3 and t.platEncID in (1, 10))] + + chars = metrics_to_extract.get(font, {}) + chars[u"\u0020"] = None # space + chars[u"\u00a0"] = None # nbsp + + for char, base_char in chars.items(): + code = ord(char) + names = set(t.get(code) for t in cmap) + if not names: + sys.stderr.write( + "Codepoint {} of font {} maps to no name\n" + .format(code, font)) + continue + if len(names) != 1: + sys.stderr.write( + "Codepoint {} of font {} maps to multiple names: {}\n" + .format(code, font, ", ".join(sorted(names)))) + continue + name = names.pop() + + height = depth = italic = skew = width = 0 + glyph = glyf[name] + if glyph.numberOfContours: + height = glyph.yMax / unitsPerEm + depth = -glyph.yMin / unitsPerEm + width = widths[name].width / unitsPerEm + if base_char: + base_char_str = str(ord(base_char)) + base_metrics = start_json[font][base_char_str] + italic = base_metrics["italic"] + skew = base_metrics["skew"] + width = base_metrics["width"] + + start_json[font][str(code)] = { + "height": height, + "depth": depth, + "italic": italic, + "skew": skew, + "width": width + } + + sys.stdout.write( + json.dumps(start_json, separators=(',', ':'), sort_keys=True)) + +if __name__ == "__main__": + main() diff --git a/node_modules/katex/src/metrics/format_json.py b/node_modules/katex/src/metrics/format_json.py new file mode 100644 index 0000000..0918d4d --- /dev/null +++ b/node_modules/katex/src/metrics/format_json.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python3 + +import sys +import json + +props = ['depth', 'height', 'italic', 'skew'] + +if len(sys.argv) > 1: + if sys.argv[1] == '--width': + props.append('width') + +data = json.load(sys.stdin) +sys.stdout.write( + "// This file is GENERATED by buildMetrics.sh. DO NOT MODIFY.\n") +sep = "export default {\n " +for font in sorted(data): + sys.stdout.write(sep + json.dumps(font)) + sep = ": {\n " + for glyph in sorted(data[font], key=int): + sys.stdout.write(sep + json.dumps(glyph) + ": ") + + values = [value if value != 0.0 else 0 for value in + [data[font][glyph][key] for key in props]] + + sys.stdout.write(json.dumps(values)) + sep = ",\n " + sep = ",\n },\n " +sys.stdout.write(",\n },\n};\n") diff --git a/node_modules/katex/src/metrics/mapping.pl b/node_modules/katex/src/metrics/mapping.pl new file mode 100644 index 0000000..dabc7ce --- /dev/null +++ b/node_modules/katex/src/metrics/mapping.pl @@ -0,0 +1,1224 @@ +#! /usr/bin/perl + +# Adapted from the MathJax-dev repository file /fonts/OTF/TeX/makeFF under the +# Apache 2 license + +# We use this file to recover the mapping from TeX fonts to KaTeX fonts, to +# accurately extract the metrics from the corresponding .tfm (TeX font metric) +# files + +use JSON; + +$map{cmr10} = { + "Main-Regular" => [ + [0,1] => 0x393, # \Gamma, \Delta + 2 => 0x398, # \Theta + 3 => 0x39B, # \Lambda + 4 => 0x39E, # \Xi + 5 => 0x3A0, # \Pi + 6 => 0x3A3, # \Sigma + [7,8] => 0x3A5, # \Upsilon, \Phi + [9,0xA] => 0x3A8, # \Psi, \Omega + + 0x10 => 0x131, # \i + 0x11 => 0x237, # \j + 0x12 => 0x2CB, # \grave + 0x13 => 0x2CA, # \acute + 0x14 => 0x2C7, # \check + 0x15 => 0x2D8, # \breve + 0x16 => 0x2C9, # \bar + 0x17 => [0xB0,-125,0], # \degree + 0x17 => 0x02DA, # \r, ring above + 0x18 => 0xB8, # \c, cedilla + + [0x21,0x2F] => 0x21, # !, ", #, $, %, &, ', (, ), *, +, comma, -, ., / + 0x22 => 0x201D, # " + 0x27 => 0x2019, # ' + [0x30,0x39] => 0x30, # 0-9 + [0x3A,0x3B] => 0x3A, # :, ; + 0x3D => 0x3D, # = + [0x3F,0x40] => 0x3F, # ?, @ + [0x41,0x5A] => 0x41, # A-Z + 0x5B => 0x5B, # [ + 0x5C => 0x201C, # `` + [0x5D,0x5E] => 0x5D, # ], ^ + 0x5E => 0x2C6, # \hat + 0x5F => 0x2D9, # \dot + 0x60 => 0x2018, # ` + [0x61,0x7A] => 0x61, # a-z + [0x7B,0x7C] => 0x2013, # \endash, \emdash + 0x7B => [0x5F,0,-310], # underline + 0x7D => 0x2DD, # double acute + 0x7E => [0x7E,0,-350], # ~ + 0x7E => 0x2DC, # \tilde + 0x7F => 0xA8, # \ddot + 0x19 => 0xDF, # sharp S + 0x1A => 0xE6, # ae ligature + 0x1B => 0x153, # oe ligature + 0x1C => 0xF8, # o with slash + 0x1D => 0xC6, # AE ligature + 0x1E => 0x152, # OE ligature + 0x1F => 0xD8, # O with slash + ], +}; + +$map{cmmi10} = { + "Math-Italic" => [ + [0,1] => 0x393, # \Gamma, \Delta + 2 => 0x398, # \Theta + 3 => 0x39B, # \Lambda + 4 => 0x39E, # \Xi + 5 => 0x3A0, # \Pi + 6 => 0x3A3, # \Sigma + [7,8] => 0x3A5, # \Upsilon, \Phi + [9,0xA] => 0x3A8, # \Psi, \Omega + + [0xB,0xE] => 0x3B1, # \alpha, \beta, \gamma, \delta + 0xF => 0x3F5, # \elpsilon + [0x10,0x18] => 0x3B6, # \zeta, \eta, \theta, \iota, \kappa, \lambda, \mu, \nu, \xi + [0x19,0x1A] => 0x3C0, # \pi, \rho + [0x1B,0x1D] => 0x3C3, # \sigma, \tau, \upsilon + 0x1E => 0x3D5, # \phi + [0x1F,0x21] => 0x3C7, # \chi, \psi, \omega + 0x22 => 0x3B5, # \varepsilon + 0x23 => 0x3D1, # \vartheta + 0x24 => 0x3D6, # \varpi + 0x25 => 0x3F1, # \varrho + 0x26 => 0x3C2, # \varsigma + 0x27 => 0x3C6, # \varphi + + [0x30,0x39] => 0x30, # Oldstyle 0-9 + [0x41,0x5A] => 0x41, # A-Z + [0x61,0x7A] => 0x61, # a - z + + 0x6F => 0x3BF, # omicron + 0x7B => 0xE131, # \imath (PUA) + 0x7C => 0xE237, # \jmath (PUA) + ], + + "Main-Regular" => [ + 0x28 => 0x21BC, # \leftharpoonup + 0x29 => 0x21BD, # \leftharpoondown + 0x2A => 0x21C0, # \rightharpoonup + 0x2B => 0x21C1, # \rightharpoondown + + 0x2E => 0x25B9, # \triangleright + 0x2F => 0x25C3, # \triangleleft + + 0x3C => 0x3C, # < + 0x3D => 0x2215, # / + 0x3E => 0x3E, # > + 0x3F => 0x22C6, # \star + 0x40 => 0x2202, # \partial + + [0x5B,0x5D] => 0x266D, # \flat, \natural, \sharp + 0x5E => 0x2323, # \smile + 0x5F => 0x2322, # \frown + 0x60 => 0x2113, # \ell + + 0x7D => 0x2118, # \wp + 0x7E => [0x20D7,-653,0],# \vec + ], +}; + +$map{cmsy10} = { + "Main-Regular" => [ + 0 => 0x2212, # - + 1 => 0x22C5, # \cdot + 2 => 0xD7, # \times + 3 => 0x2217, # \ast + 4 => 0xF7, # \div + 5 => 0x22C4, # \diamond + 6 => 0xB1, # \pm + 7 => 0x2213, # \mp + [8,0xC] => 0x2295, # \oplus, \ominus, \otimes, \oslash, \odot + 0xD => 0x25EF, # \bigcirc + [0xE,0xF] => 0x2218, # \circ, \bullet + + 0x10 => 0x224D, # \asymp + 0x11 => 0x2261, # \equiv + [0x12,0x13] => 0x2286, # \subseteq, \supseteq + [0x14,0x15] => 0x2264, # \leq, \geq + [0x16,0x17] => 0x2AAF, # \preceq, \succeq + 0x18 => 0x223C, # \sim + 0x19 => 0x2248, # \approx + [0x1A,0x1B] => 0x2282, # \subset, \supset + [0x1C,0x1D] => 0x226A, # \ll, \gg + [0x1E,0x1F] => 0x227A, # \prec, \succ + + 0x20 => 0x2190, # \leftarrow + 0x21 => 0x2192, # \rightarrow + 0x22 => 0x2191, # \uparrow + 0x23 => 0x2193, # \downarrow + 0x24 => 0x2194, # \leftrightarrow + 0x25 => 0x2197, # \nearrow + 0x26 => 0x2198, # \searrow + 0x27 => 0x2243, # \simeq + + 0x28 => 0x21D0, # \Leftarrow + 0x29 => 0x21D2, # \Rightarrow + 0x2A => 0x21D1, # \Uparrow + 0x2B => 0x21D3, # \Downarrow + 0x2C => 0x21D4, # \Leftrightarrow + 0x2D => 0x2196, # \nwarrow + 0x2E => 0x2199, # \swarrow + 0x2F => 0x221D, # \propto + + 0x30 => 0x2032, # \prime + 0x31 => 0x221E, # \infty + 0x32 => 0x2208, # \in + 0x33 => 0x220B, # \ni + 0x34 => 0x25B3, # \bigtriangleup and \triangle + 0x35 => 0x25BD, # \bigtriangledown + 0x36 => 0xE020, # \not + + 0x38 => 0x2200, # \forall + 0x39 => 0x2203, # \exists + 0x3A => 0xAC, # \neg + 0x3B => 0x2205, # \emptyset + 0x3C => 0x211C, # \Re + 0x3D => 0x2111, # \Im + 0x3E => 0x22A4, # \top + 0x3F => 0x22A5, # \bot + + 0x40 => 0x2135, # \aleph + + 0x5B => 0x222A, # \cup + 0x5C => 0x2229, # \cap + 0x5D => 0x228E, # \uplus + [0x5E,0x5F] => 0x2227, # \wedge, \vee + + [0x60,0x61] => 0x22A2, # \vdash, \dashv + [0x62,0x63] => 0x230A, # \lfloor, \rfloor + [0x64,0x65] => 0x2308, # \lceil, \rceil + 0x66 => 0x7B, # { + 0x67 => 0x7D, # } + [0x68,0x69] => 0x27E8, # \langle, \rangle + 0x6A => 0x7C, # | + 0x6A => 0x2223, # \vert + 0x6B => 0x2225, # \Vert + 0x6C => 0x2195, # \updownarrow + 0x6D => 0x21D5, # \Updownarrow + 0x6E => 0x5C, # \backslash + 0x6E => 0x2216, # \setminus + 0x6F => 0x2240, # \wr + + 0x70 => [0x221A,0,760], # \surd ### adjust position so font doesn't have a large depth + 0x71 => 0x2A3F, # \amalg + 0x72 => 0x2207, # \nabla + 0x73 => 0x222B, # \int + 0x74 => 0x2294, # \sqcup + 0x75 => 0x2293, # \sqcap + [0x76,0x77] => 0x2291, # \sqsubseteq, \sqsupseteq + 0x78 => 0xA7, # \S + [0x79,0x7A] => 0x2020, # \dagger, \ddagger + 0x7B => 0xB6, # \P + 0x7C => 0x2663, # \clubsuit + 0x7D => 0x2662, # \diamondsuit + 0x7E => 0x2661, # \heartsuit + 0x7F => 0x2660, # \spadesuit + ], + + "Caligraphic-Regular" => [ + [0x41,0x5A] => 0x41, # A-Z + ], +}; + +$map{cmex10} = { + "Size1" => [ + 0 => [0x28,0,810], # ( + 1 => [0x29,0,810], # ) + 2 => [0x5B,0,810], # [ + 3 => [0x5D,0,810], # ] + 4 => [0x230A,0,810], # \lfloor + 5 => [0x230B,0,810], # \rfloor + 6 => [0x2308,0,810], # \lceil + 7 => [0x2309,0,810], # \rceil + 8 => [0x7B,0,810], # { + 9 => [0x7D,0,810], # } + 0xA => [0x27E8,0,810], # \langle + 0xB => [0x27E9,0,810], # \rangle + 0xC => [0x2223,0,606], # \vert + 0xD => [0x2225,0,606], # \Vert + 0xE => [0x2F,0,810], # / + 0xF => [0x5C,0,810], # \ + + 0x46 => [0x2A06,0,750], # \bigsqcup + 0x48 => [0x222E,0,805], # \oint + 0x4A => [0x2A00,0,750], # \bigodot + 0x4C => [0x2A01,0,750], # \bigoplus + 0x4E => [0x2A02,0,750], # \bigotimes + + 0x50 => [0x2211,0,750], # \sum + 0x51 => [0x220F,0,750], # \prod + 0x52 => [0x222B,0,805], # \int + 0x53 => [0x22C3,0,750], # \bigcup + 0x54 => [0x22C2,0,750], # \bigcap + 0x55 => [0x2A04,0,750], # \biguplus + 0x56 => [0x22C0,0,750], # \bigwedge + 0x57 => [0x22C1,0,750], # \bigvee + + 0x60 => [0x2210,0,750], # \coprod + 0x62 => 0x2C6, # \widehat + 0x62 => [0x302,-556,0], # \widehat (combining) + 0x65 => 0x2DC, # \widetilde + 0x65 => [0x303,-556,0], # \widetilde (combining) + + 0x70 => [0x221A,0,810], # surd + 0x3F => [0x23D0,0,601], # arrow extension + 0x77 => [0x2016,0,601], # Arrow extension (non-standard) + 0x78 => [0x2191,0,600], # uparrow top + 0x79 => [0x2193,0,600], # downarrow bottom + 0x7E => [0x21D1,0,600], # Uparrow top + 0x7F => [0x21D3,0,600], # Downarrow bottom + ], + + "Size2" => [ + 0x10 => [0x28,0,1110], # ( + 0x11 => [0x29,0,1110], # ) + 0x2E => [0x2F,0,1110], # / + 0x2F => [0x5C,0,1110], # \ + 0x44 => [0x27E8,0,1110],# \langle + 0x45 => [0x27E9,0,1110],# \rangle + + 0x47 => [0x2A06,0,950], # \bigsqcup + 0x49 => [0x222E,0,1360],# \oint + 0x4B => [0x2A00,0,950], # \bigodot + 0x4D => [0x2A01,0,950], # \bigoplus + 0x4F => [0x2A02,0,950], # \bigotimes + + 0x58 => [0x2211,0,950], # \sum + 0x59 => [0x220F,0,950], # \prod + 0x5A => [0x222B,0,1360],# \int + 0x5B => [0x22C3,0,950], # \bigcup + 0x5C => [0x22C2,0,950], # \bigcap + 0x5D => [0x2A04,0,950], # \biguplus + 0x5E => [0x22C0,0,950], # \bigwedge + 0x5F => [0x22C1,0,950], # \bigvee + 0x61 => [0x2210,0,950], # \coprod + + 0x63 => 0x2C6, # \widehat + 0x63 => [0x302,-1000,0],# \widehat (combining) + 0x66 => 0x2DC, # \widetilde + 0x66 => [0x303,-1000,0],# \widetilde (combining) + + 0x68 => [0x5B,0,1110], # [ + 0x69 => [0x5D,0,1110], # ] + 0x6A => [0x230A,0,1110],# \lfloor + 0x6B => [0x230B,0,1110],# \rfloor + 0x6C => [0x2308,0,1110],# \lceil + 0x6D => [0x2309,0,1110],# \rceil + 0x6E => [0x7B,0,1110], # { + 0x6F => [0x7D,0,1110], # } + 0x71 => [0x221A,0,1110],# surd + ], + + "Size3" => [ + 0x12 => [0x28,0,1410], # ( + 0x13 => [0x29,0,1410], # ) + 0x14 => [0x5B,0,1410], # [ + 0x15 => [0x5D,0,1410], # ] + 0x16 => [0x230A,0,1410],# \lfloor + 0x17 => [0x230B,0,1410],# \rfloor + 0x18 => [0x2308,0,1410],# \lceil + 0x19 => [0x2309,0,1410],# \rceil + 0x1A => [0x7B,0,1410], # { + 0x1B => [0x7D,0,1410], # } + 0x1C => [0x27E8,0,1410],# \langle + 0x1D => [0x27E9,0,1410],# \rangle + 0x1E => [0x2F,0,1410], # / + 0x1F => [0x5C,0,1410], # \ + 0x64 => 0x2C6, # \widehat + 0x64 => [0x302,-1444,0],# \widehat (combining) + 0x67 => 0x2DC, # \widetilde + 0x67 => [0x303,-1444,0],# \widetilde (combining) + 0x72 => [0x221A,0,1410],# surd + ], + + "Size4" => [ + 0x20 => [0x28,0,1710], # ( + 0x21 => [0x29,0,1710], # ) + 0x22 => [0x5B,0,1710], # [ + 0x23 => [0x5D,0,1710], # ] + 0x24 => [0x230A,0,1710],# \lfloor + 0x25 => [0x230B,0,1710],# \rfloor + 0x26 => [0x2308,0,1710],# \lceil + 0x27 => [0x2309,0,1710],# \rceil + 0x28 => [0x7B,0,1710], # { + 0x29 => [0x7D,0,1710], # } + 0x2A => [0x27E8,0,1710],# \langle + 0x2B => [0x27E9,0,1710],# \rangle + 0x2C => [0x2F,0,1710], # / + 0x2D => [0x5C,0,1710], # \ + 0x73 => [0x221A,0,1710],# surd + + 0x30 => [0x239B,0,1115],# left paren upper hook + 0x31 => [0x239E,0,1115],# right paren upper hook + 0x32 => [0x23A1,0,1115],# left square bracket upper corner + 0x33 => [0x23A4,0,1115],# right square bracket upper corner + 0x34 => [0x23A3,0,1115],# left square bracket lower corner + 0x35 => [0x23A6,0,1115],# right square bracket lower hook + 0x36 => [0x23A2,0,601], # left square bracket extension + 0x37 => [0x23A5,0,601], # right square bracket extension + 0x38 => [0x23A7,0,900], # left curly brace upper hook + 0x39 => [0x23AB,0,900], # right curly brace upper hook + 0x3A => 0x23A9, # left curly brace lower hook + 0x3B => 0x23AD, # right curly brace lower hook + 0x3C => [0x23A8,0,1150],# left curly brace middle + 0x3D => [0x23AC,0,1150],# right curly brace middle + 0x3E => [0x23AA,0,300], # curly brace extension + + 0x40 => [0x239D,0,1115],# left paren lower hook + 0x41 => [0x23A0,0,1115],# right paren lower hook + 0x42 => [0x239C,0,600], # left paren extension + 0x43 => [0x239F,0,600], # right paren extension + + 0x74 => [0x23B7,0,915], # radical bottom + 0x75 => [0xE000,0,605], # radical extension (PUA) + 0x76 => [0xE001,0,565], # radical top (PUA) + [0x7A,0x7D] => 0xE150, # \braceld, \bracerd, \bracelu, \braceru (PUA) + ], +}; + +$map{cmti10} = { + "Main-Italic" => [ + [0,1] => 0x393, # \Gamma, \Delta + 2 => 0x398, # \Theta + 3 => 0x39B, # \Lambda + 4 => 0x39E, # \Xi + 5 => 0x3A0, # \Pi + 6 => 0x3A3, # \Sigma + [7,8] => 0x3A5, # \Upsilon, \Phi + [9,0xA] => 0x3A8, # \Psi, \Omega + + 0x12 => 0x2CB, # \grave + 0x13 => 0x2CA, # \acute + 0x14 => 0x2C7, # \check + 0x15 => 0x2D8, # \breve + 0x16 => 0x2C9, # \bar + 0x17 => [0xB0,-160,0], # \degree + 0x17 => 0x02DA, # \r, ring above + 0x18 => 0xB8, # \c, cedilla + + [0x21,0x23] => 0x21, # !, ", #, + 0x22 => 0x201D, # " + [0x25,0x2F] => 0x25, # %, &, ', (, ), *, +, comma, -, ., / + 0x27 => 0x2019, # ' + [0x30,0x39] => 0x30, # 0-9 + [0x3A,0x3B] => 0x3A, # :, ; + 0x3D => 0x3D, # = + [0x3F,0x40] => 0x3F, # ?, @ + [0x41,0x5A] => 0x41, # A-Z + 0x5B => 0x5B, # [ + 0x5C => 0x201C, # `` + [0x5D,0x5E] => 0x5D, # ], ^ + 0x5E => 0x2C6, # \hat + 0x5F => 0x2D9, # \dot + 0x60 => 0x2018, # ` + [0x61,0x7A] => 0x61, # a-z + [0x7B,0x7C] => 0x2013, # \endash, \emdash + 0x7B => [0x5F,0,-310], # underline + 0x7D => 0x2DD, # double acute + 0x7E => [0x7E,0,-350], # ~ + 0x7E => 0x2DC, # \tilde + 0x7F => 0xA8, # \ddot + 0x19 => 0xDF, # sharp S + 0x1A => 0xE6, # ae ligature + 0x1B => 0x153, # oe ligature + 0x1C => 0xF8, # o with slash + 0x1D => 0xC6, # AE ligature + 0x1E => 0x152, # OE ligature + 0x1F => 0xD8, # O with slash + ], + + "Main-Regular" => [ + 0x24 => 0xA3, # pound sign + ], +}; + +$map{cmbx10} = { + "Main-Bold" => [ + [0,1] => 0x393, # \Gamma, \Delta + 2 => 0x398, # \Theta + 3 => 0x39B, # \Lambda + 4 => 0x39E, # \Xi + 5 => 0x3A0, # \Pi + 6 => 0x3A3, # \Sigma + [7,8] => 0x3A5, # \Upsilon, \Phi + [9,0xA] => 0x3A8, # \Psi, \Omega + + 0x10 => 0x131, # \i + 0x11 => 0x237, # \j + 0x12 => 0x2CB, # \grave + 0x13 => 0x2CA, # \acute + 0x14 => 0x2C7, # \check + 0x15 => 0x2D8, # \breve + 0x16 => 0x2C9, # \bar + 0x17 => [0xB0,-147,0], # \degree + 0x17 => 0x02DA, # \r, ring above + 0x18 => 0xB8, # \c, cedilla + + [0x21,0x2F] => 0x21, # !, ", #, $, %, &, ', (, ), *, +, comma, -, ., / + 0x22 => 0x201D, # " + 0x27 => 0x2019, # ' + [0x30,0x39] => 0x30, # 0-9 + [0x3A,0x3B] => 0x3A, # :, ; + 0x3D => 0x3D, # = + [0x3F,0x40] => 0x3F, # ?, @ + [0x41,0x5A] => 0x41, # A-Z + 0x5B => 0x5B, # [ + 0x5C => 0x201C, # `` + [0x5D,0x5E] => 0x5D, # ], ^ + 0x5E => 0x2C6, # \hat + 0x5F => 0x2D9, # \dot + 0x60 => 0x2018, # ` + [0x61,0x7A] => 0x61, # a-z + [0x7B,0x7C] => 0x2013, # \endash, \emdash + 0x7B => [0x5F,0,-310], # underline + 0x7D => 0x2DD, # double acute + 0x7E => [0x7E,0,-350], # ~ + 0x7E => 0x2DC, # \tilde + 0x7F => 0xA8, # \ddot + 0x19 => 0xDF, # sharp S + 0x1A => 0xE6, # ae ligature + 0x1B => 0x153, # oe ligature + 0x1C => 0xF8, # o with slash + 0x1D => 0xC6, # AE ligature + 0x1E => 0x152, # OE ligature + 0x1F => 0xD8, # O with slash + ], +}; + +$map{cmbxti10} = { + "Main-BoldItalic" => [ + [0,1] => 0x393, # \Gamma, \Delta + 2 => 0x398, # \Theta + 3 => 0x39B, # \Lambda + 4 => 0x39E, # \Xi + 5 => 0x3A0, # \Pi + 6 => 0x3A3, # \Sigma + [7,8] => 0x3A5, # \Upsilon, \Phi + [9,0xA] => 0x3A8, # \Psi, \Omega + + 0x10 => 0x131, # \i + 0x11 => 0x237, # \j + 0x12 => 0x2CB, # \grave + 0x13 => 0x2CA, # \acute + 0x14 => 0x2C7, # \check + 0x15 => 0x2D8, # \breve + 0x16 => 0x2C9, # \bar + 0x17 => [0xB0,-160,0], # \degree + 0x17 => 0x02DA, # \r, ring above + 0x18 => 0xB8, # \c, cedilla + + [0x21,0x23] => 0x21, # !, ", #, + 0x22 => 0x201D, # " + [0x25,0x2F] => 0x25, # %, &, ', (, ), *, +, comma, -, ., / + 0x27 => 0x2019, # ' + [0x30,0x39] => 0x30, # 0-9 + [0x3A,0x3B] => 0x3A, # :, ; + 0x3D => 0x3D, # = + [0x3F,0x40] => 0x3F, # ?, @ + [0x41,0x5A] => 0x41, # A-Z + 0x5B => 0x5B, # [ + 0x5C => 0x201C, # `` + [0x5D,0x5E] => 0x5D, # ], ^ + 0x5E => 0x2C6, # \hat + 0x5F => 0x2D9, # \dot + 0x60 => 0x2018, # ` + [0x61,0x7A] => 0x61, # a-z + [0x7B,0x7C] => 0x2013, # \endash, \emdash + 0x7B => [0x5F,0,-310], # underline + 0x7D => 0x2DD, # double acute + 0x7E => [0x7E,0,-350], # ~ + 0x7E => 0x2DC, # \tilde + 0x7F => 0xA8, # \ddot + 0x19 => 0xDF, # sharp S + 0x1A => 0xE6, # ae ligature + 0x1B => 0x153, # oe ligature + 0x1C => 0xF8, # o with slash + 0x1D => 0xC6, # AE ligature + 0x1E => 0x152, # OE ligature + 0x1F => 0xD8, # O with slash + ], + + "Main-Bold" => [ + 0x24 => 0xA3, # pound sign + ], +}; + +$map{cmmib10} = { + "Math-BoldItalic" => [ + [0,1] => 0x393, # \Gamma, \Delta + 2 => 0x398, # \Theta + 3 => 0x39B, # \Lambda + 4 => 0x39E, # \Xi + 5 => 0x3A0, # \Pi + 6 => 0x3A3, # \Sigma + [7,8] => 0x3A5, # \Upsilon, \Phi + [9,0xA] => 0x3A8, # \Psi, \Omega + + [0xB,0xE] => 0x3B1, # \alpha, \beta, \gamma, \delta + 0xF => 0x3F5, # \elpsilon + [0x10,0x18] => 0x3B6, # \zeta, \eta, \theta, \iota, \kappa, \lambda, \mu, \nu, \xi + [0x19,0x1A] => 0x3C0, # \pi, \rho + [0x1B,0x1D] => 0x3C3, # \sigma, \tau, \upsilon + 0x1E => 0x3D5, # \phi + [0x1F,0x21] => 0x3C7, # \chi, \psi, \omega + 0x22 => 0x3B5, # \varepsilon + 0x23 => 0x3D1, # \vartheta + 0x24 => 0x3D6, # \varpi + 0x25 => 0x3F1, # \varrho + 0x26 => 0x3C2, # \varsigma + 0x27 => 0x3C6, # \varphi + + [0x41,0x5A] => 0x41, # A-Z + [0x61,0x7A] => 0x61, # a - z + [0x30,0x39] => 0x30, # Oldstyle 0-9 + + 0x6F => 0x3BF, # omicron + 0x7B => 0xE131, # \imath (PUA) + 0x7C => 0xE237, # \jmath (PUA) + ], + + "Main-Bold" => [ + 0x28 => 0x21BC, # \leftharpoonup + 0x29 => 0x21BD, # \leftharpoondown + 0x2A => 0x21C0, # \rightharpoonup + 0x2B => 0x21C1, # \rightharpoondown + + 0x2E => 0x25B9, # \triangleright + 0x2F => 0x25C3, # \triangleleft + + 0x3C => 0x3C, # < + 0x3D => 0x2215, # / + 0x3E => 0x3E, # > + 0x3F => 0x22C6, # \star + 0x40 => 0x2202, # \partial + + [0x5B,0x5D] => 0x266D, # \flat, \natural, \sharp + 0x5E => 0x2323, # \smile + 0x5F => 0x2322, # \frown + 0x60 => 0x2113, # \ell + 0x68 => 0x210F, # \hbar (bar added below) + + 0x7D => 0x2118, # \wp + 0x7E => [0x20D7,-729,0],# \vec + ], +}; + +$map{cmbsy10} = { + "Main-Bold" => [ + 0 => 0x2212, # - + 1 => 0x22C5, # \cdot + 2 => 0xD7, # \times + 3 => 0x2217, # \ast + 4 => 0xF7, # \div + 5 => 0x22C4, # \diamond + 6 => 0xB1, # \pm + 7 => 0x2213, # \mp + [8,0xC] => 0x2295, # \oplus, \ominus, \otimes, \oslash, \odot + 0xD => 0x25EF, # \bigcirc + [0xE,0xF] => 0x2218, # \circ, \bullet + + 0x10 => 0x224D, # \asymp + 0x11 => 0x2261, # \equiv + [0x12,0x13] => 0x2286, # \subseteq, \supseteq + [0x14,0x15] => 0x2264, # \leq, \geq + [0x16,0x17] => 0x2AAF, # \preceq, \succeq + 0x18 => 0x223C, # \sim + 0x19 => 0x2248, # \approx + [0x1A,0x1B] => 0x2282, # \subset, \supset + [0x1C,0x1D] => 0x226A, # \ll, \gg + [0x1E,0x1F] => 0x227A, # \prec, \succ + + 0x20 => 0x2190, # \leftarrow + 0x21 => 0x2192, # \rightarrow + 0x22 => 0x2191, # \uparrow + 0x23 => 0x2193, # \downarrow + 0x24 => 0x2194, # \leftrightarrow + 0x25 => 0x2197, # \nearrow + 0x26 => 0x2198, # \searrow + 0x27 => 0x2243, # \simeq + + 0x28 => 0x21D0, # \Leftarrow + 0x29 => 0x21D2, # \Rightarrow + 0x2A => 0x21D1, # \Uparrow + 0x2B => 0x21D3, # \Downarrow + 0x2C => 0x21D4, # \Leftrightarrow + 0x2D => 0x2196, # \nwarrow + 0x2E => 0x2199, # \swarrow + 0x2F => 0x221D, # \propto + + 0x30 => 0x2032, # \prime + 0x31 => 0x221E, # \infty + 0x32 => 0x2208, # \in + 0x33 => 0x220B, # \ni + 0x34 => 0x25B3, # \bigtriangleup and \triangle + 0x35 => 0x25BD, # \bigtriangledown + 0x36 => 0xE020, # \not + + 0x38 => 0x2200, # \forall + 0x39 => 0x2203, # \exists + 0x3A => 0xAC, # \neg + 0x3B => 0x2205, # \emptyset + 0x3C => 0x211C, # \Re + 0x3D => 0x2111, # \Im + 0x3E => 0x22A4, # \top + 0x3F => 0x22A5, # \bot + + 0x40 => 0x2135, # \aleph + + 0x5B => 0x222A, # \cup + 0x5C => 0x2229, # \cap + 0x5D => 0x228E, # \uplus + [0x5E,0x5F] => 0x2227, # \wedge, \vee + + [0x60,0x61] => 0x22A2, # \vdash, \dashv + [0x62,0x63] => 0x230A, # \lfloor, \rfloor + [0x64,0x65] => 0x2308, # \lceil, \rceil + 0x66 => 0x7B, # { + 0x67 => 0x7D, # } + [0x68,0x69] => 0x27E8, # \langle, \rangle + 0x6A => 0x7C, # | + 0x6A => 0x2223, # \vert + 0x6B => 0x2225, # \Vert + 0x6C => 0x2195, # \updownarrow + 0x6D => 0x21D5, # \Updownarrow + 0x6E => 0x5C, # \backslash + 0x6E => 0x2216, # \setminus + 0x6F => 0x2240, # \wr + + 0x70 => [0x221A,0,760], # \surd ### adjust position so font doesn't have a large depth + 0x71 => 0x2A3F, # \amalg + 0x72 => 0x2207, # \nabla + 0x73 => 0x222B, # \int + 0x74 => 0x2294, # \sqcup + 0x75 => 0x2293, # \sqcap + [0x76,0x77] => 0x2291, # \sqsubseteq, \sqsupseteq + + [0x79,0x7A] => 0x2020, # \dagger, \ddagger + + 0x7C => 0x2663, # \clubsuit + 0x7D => 0x2662, # \diamondsuit + 0x7E => 0x2661, # \heartsuit + 0x7F => 0x2660, # \spadesuit + ], +}; + +$map{msam10} = { + "Main-Regular" => [ + 0x5C => 0x2220, # \angle + ], + + "Main-Bold" => [ + 0x5C => 0x2220, # \angle (emboldened below) + ], + + "AMS" => [ + 0x00 => 0x22A1, # \boxdot + 0x01 => 0x229E, # \boxplus + 0x02 => 0x22A0, # \boxtimes + 0x03 => 0x25A1, # \square + 0x04 => 0x25A0, # \blacksquare + 0x05 => 0x22C5, # \centerdot + 0x06 => 0x25CA, # \lozenge + 0x07 => 0x29EB, # \blacklozenge + 0x08 => 0x21BB, # \circlearrowright + 0x09 => 0x21BA, # \circlearrowleft + 0x0A => 0x21CC, # \rightleftharpoons + 0x0B => 0x21CB, # \leftrightharpoons + 0x0C => 0x229F, # \boxminus + 0x0D => 0x22A9, # \Vdash + 0x0E => 0x22AA, # \Vvdash + 0x0F => 0x22A8, # \vDash + 0x10 => 0x21A0, # \twoheadrightarrow + 0x11 => 0x219E, # \twoheadleftarrow + 0x12 => 0x21C7, # \leftleftarrows + 0x13 => 0x21C9, # \rightrightarrows + 0x14 => 0x21C8, # \upuparrows + 0x15 => 0x21CA, # \downdownarrows + 0x16 => 0x21BE, # \upharpoonright + 0x17 => 0x21C2, # \downharpoonright + 0x18 => 0x21BF, # \upharpoonleft + 0x19 => 0x21C3, # \downharpoonleft + 0x1A => 0x21A3, # \rightarrowtail + 0x1B => 0x21A2, # \leftarrowtail + 0x1C => 0x21C6, # \leftrightarrows + 0x1D => 0x21C4, # \rightleftarrows + 0x1E => 0x21B0, # \Lsh + 0x1F => 0x21B1, # \Rsh + 0x20 => 0x21DD, # \rightsquigarrow + 0x21 => 0x21AD, # \leftrightsquigarrow + 0x22 => 0x21AB, # \looparrowleft + 0x23 => 0x21AC, # \looparrowright + 0x24 => 0x2257, # \circeq + 0x25 => 0x227F, # \succsim + 0x26 => 0x2273, # \gtrsim + 0x27 => 0x2A86, # \gtrapprox + 0x28 => 0x22B8, # \multimap + 0x29 => 0x2234, # \therefore + 0x2A => 0x2235, # \because + 0x2B => 0x2251, # \doteqdot + 0x2C => 0x225C, # \triangleq + 0x2D => 0x227E, # \precsim + 0x2E => 0x2272, # \lesssim + 0x2F => 0x2A85, # \lessapprox + 0x30 => 0x2A95, # \eqslantless + 0x31 => 0x2A96, # \eqslantgtr + 0x32 => 0x22DE, # \curlyeqprec + 0x33 => 0x22DF, # \curlyeqsucc + 0x34 => 0x227C, # \preccurlyeq + 0x35 => 0x2266, # \leqq + 0x36 => 0x2A7D, # \leqslant + 0x37 => 0x2276, # \lessgtr + 0x38 => 0x2035, # \backprime + 0x39 => 0x2212, # dahsed arrow extension + 0x3A => 0x2253, # \risingdotseq + 0x3B => 0x2252, # \fallingdotseq + 0x3C => 0x227D, # \succcurlyeq + 0x3D => 0x2267, # \geqq + 0x3E => 0x2A7E, # \geqslant + 0x3F => 0x2277, # \gtrless + 0x40 => 0x228F, # \sqsubset + 0x41 => 0x2290, # \sqsupset + 0x42 => 0x22B3, # \vartriangleright + 0x43 => 0x22B2, # \vartriangleleft + 0x44 => 0x22B5, # \trianglerighteq + 0x45 => 0x22B4, # \trianglelefteq + 0x46 => 0x2605, # \bigstar + 0x47 => 0x226C, # \between + 0x48 => 0x25BC, # \blacktriangledown + 0x49 => 0x25B6, # \blacktriangleright + 0x4A => 0x25C0, # \blacktriangleleft + 0x4B => 0x2192, # rightarrow + 0x4C => 0x2190, # leftarrow + 0x4D => 0x25B3, # \vartriangle + 0x4E => 0x25B2, # \blacktriangle + 0x4F => 0x25BD, # \triangledown + 0x50 => 0x2256, # \eqcirc + 0x51 => 0x22DA, # \lesseqgtr + 0x52 => 0x22DB, # \gtreqless + 0x53 => 0x2A8B, # \lesseqqgtr + 0x54 => 0x2A8C, # \gtreqqless + 0x55 => 0x00A5, # yen + 0x56 => 0x21DB, # \Rrightarrow + 0x57 => 0x21DA, # \Lleftarrow + 0x58 => 0x2713, # checkmark + 0x59 => 0x22BB, # \veebar + 0x5A => 0x22BC, # \barwedge + 0x5B => 0x2A5E, # \doublebarwedge + 0x5C => 0x2220, # \angle + 0x5D => 0x2221, # \measuredangle + 0x5E => 0x2222, # \sphericalangle + 0x5F => 0x221D, # \varpropto + 0x60 => 0x2323, # \smallsmile + 0x61 => 0x2322, # \smallfrown + 0x62 => 0x22D0, # \Subset + 0x63 => 0x22D1, # \Supset + 0x64 => 0x22D3, # \Cup + 0x65 => 0x22D2, # \Cap + 0x66 => 0x22CF, # \curlywedge + 0x67 => 0x22CE, # \curlyvee + 0x68 => 0x22CB, # \leftthreetimes + 0x69 => 0x22CC, # \rightthreetimes + 0x6A => 0x2AC5, # \subseteqq + 0x6B => 0x2AC6, # \supseteqq + 0x6C => 0x224F, # \bumpeq + 0x6D => 0x224E, # \Bumpeq + 0x6E => 0x22D8, # \lll + 0x6F => 0x22D9, # \ggg + 0x70 => 0x250C, # \ulcorner + 0x71 => 0x2510, # \urcorner + 0x72 => 0x00AE, # registered sign + 0x73 => 0x24C8, # \circledS + 0x74 => 0x22D4, # \pitchfork + 0x75 => 0x2214, # \dotplus + 0x76 => 0x223D, # \backsim + 0x77 => 0x22CD, # \backsimeq + 0x78 => 0x2514, # \llcorner + 0x79 => 0x2518, # \lrcorner + 0x7A => 0x2720, # maltese cross + 0x7B => 0x2201, # \complement + 0x7C => 0x22BA, # \intercal + 0x7D => 0x229A, # \circledcirc + 0x7E => 0x229B, # \circledast + 0x7F => 0x229D, # \circleddash + ], +}; + +$map{msbm10} = { + "Size4" => [ + 0x5B => 0x2C6, # \widehat + 0x5B => [0x302,-1889,0],# \widehat (combining) + 0x5D => 0x2DC, # \widetilde + 0x5D => [0x303,-1889,0],# \widetilde (combining) + ], + + "Main-Regular" => [ + 0x7E => 0x210F, # \hbar + ], + + "Main-Italic" => [ + 0x7D => 0x210F, # \hbar (with slant) + ], + + "AMS" => [ + 0x00 => 0xE00C, # \lvertneqq + 0x01 => 0xE00D, # \gvertneqq + 0x02 => 0x2270, # \nleq + 0x03 => 0x2271, # \ngeq + 0x04 => 0x226E, # \nless + 0x05 => 0x226F, # \ngtr + 0x06 => 0x2280, # \nprec + 0x07 => 0x2281, # \nsucc + 0x08 => 0x2268, # \lneqq + 0x09 => 0x2269, # \gneqq + 0x0A => 0xE010, # \nleqslant + 0x0B => 0xE00F, # \ngeqslant + 0x0C => 0x2A87, # \lneq + 0x0D => 0x2A88, # \gneq + 0x0E => 0x22E0, # \npreceq + 0x0F => 0x22E1, # \nsucceq + 0x10 => 0x22E8, # \precnsim + 0x11 => 0x22E9, # \succnsim + 0x12 => 0x22E6, # \lnsim + 0x13 => 0x22E7, # \gnsim + 0x14 => 0xE011, # \nleqq + 0x15 => 0xE00E, # \ngeqq + 0x16 => 0x2AB5, # \precneqq + 0x17 => 0x2AB6, # \succneqq + 0x18 => 0x2AB9, # \precnapprox + 0x19 => 0x2ABA, # \succnapprox + 0x1A => 0x2A89, # \lnapprox + 0x1B => 0x2A8A, # \gnapprox + 0x1C => 0x2241, # \nsim + 0x1D => 0x2246, # \ncong + 0x1E => 0x2571, # \diagup + 0x1F => 0x2572, # \diagdown + 0x20 => 0xE01A, # \varsubsetneq + 0x21 => 0xE01B, # \varsupsetneq + 0x22 => 0xE016, # \nsubseteqq + 0x23 => 0xE018, # \nsupseteqq + 0x24 => 0x2ACB, # \subsetneqq + 0x25 => 0x2ACC, # \supsetneqq + 0x26 => 0xE017, # \varsubsetneqq + 0x27 => 0xE019, # \varsupsetneqq + 0x28 => 0x228A, # \subsetneq + 0x29 => 0x228B, # \supsetneq + 0x2A => 0x2288, # \nsubseteq + 0x2B => 0x2289, # \nsupseteq + 0x2C => 0x2226, # \nparallel + 0x2D => 0x2224, # \nmid + 0x2E => 0xE006, # \nshortmid + 0x2F => 0xE007, # \nshortparallel + 0x30 => 0x22AC, # \nvdash + 0x31 => 0x22AE, # \nVdash + 0x32 => 0x22AD, # \nvDash + 0x33 => 0x22AF, # \nVDash + 0x34 => 0x22ED, # \ntrianglerighteq + 0x35 => 0x22EC, # \ntrianglelefteq + 0x36 => 0x22EA, # \ntriangleleft + 0x37 => 0x22EB, # \ntriangleright + 0x38 => 0x219A, # \nleftarrow + 0x39 => 0x219B, # \nrightarrow + 0x3A => 0x21CD, # \nLeftarrow + 0x3B => 0x21CF, # \nRightarrow + 0x3C => 0x21CE, # \nLeftrightarrow + 0x3D => 0x21AE, # \nleftrightarrow + 0x3E => 0x22C7, # \divideontimes + 0x3F => 0x2205, # \varnothing + 0x40 => 0x2204, # \nexists + + [0x41,0x5A] => 0x41, # A-Z + 0x5C => 0x2C6, # \widehat + 0x5C => [0x302,-2333,0],# \widehat (combining) + 0x5E => 0x2DC, # \widetilde + 0x5E => [0x303,-2333,0],# \widetilde (combining) + + 0x60 => 0x2132, # \Finv + 0x61 => 0x2141, # \Game + 0x66 => 0x2127, # \mho + 0x67 => 0x00F0, # \eth + 0x68 => 0x2242, # minus-tilde + 0x69 => 0x2136, # \beth + 0x6A => 0x2137, # \gimel + 0x6B => 0x2138, # \daleth + 0x6C => 0x22D6, # \lessdot + 0x6D => 0x22D7, # \gtrdot + 0x6E => 0x22C9, # \ltimes + 0x6F => 0x22CA, # \rtimes + 0x70 => 0x2223, # \shortmid + 0x71 => 0x2225, # \shortparallel + 0x72 => 0x2216, # \smallsetminus + 0x73 => 0x223C, # \thicksim + 0x74 => 0x2248, # \thickapprox + 0x75 => 0x224A, # \approxeq + 0x76 => 0x2AB8, # \succapprox + 0x77 => 0x2AB7, # \precapprox + 0x78 => 0x21B6, # \curvearrowleft + 0x79 => 0x21B7, # \curvearrowright + 0x7A => 0x03DD, # \digamma + 0x7B => 0x03F0, # \varkappa + 0x7A => 0xE008, # \digamma (non-standard, for IE) + 0x7B => 0xE009, # \varkappa (non-standard, for IE) + 0x7C => 0x006B, # \Bbbk + 0x7D => 0x210F, # \hslash + 0x7E => 0x0127, # \hbar + 0x7F => 0x220D, # \backepsilon + ], +}; + +$map{eufm10} = { + "Fraktur-Regular" => [ + [0,7] => 0xE300, # variants + 0x12 => 0x2018, # left quote + 0x13 => 0x2019, # right quote + 0x21 => 0x21, # ! + [0x26,0x2F] => 0x26, # &, ', (, ), *, +, comma, -, ., / + [0x30,0x39] => 0x30, # 0-9 + [0x3A,0x3B] => 0x3A, # :, ; + 0x3D => 0x3D, # = + 0x3F => 0x3F, # ? + [0x41,0x5A] => 0x41, # A-Z + 0x5B => 0x5B, # [ + [0x5D,0x5E] => 0x5D, # ], ^ + [0x61,0x7A] => 0x61, # a-z + 0x7D => 0x22, # " + ], +}; + +$map{cmtt10} = { + "Typewriter-Regular" => [ + [0,1] => 0x393, # \Gamma, \Delta + 2 => 0x398, # \Theta + 3 => 0x39B, # \Lambda + 4 => 0x39E, # \Xi + 5 => 0x3A0, # \Pi + 6 => 0x3A3, # \Sigma + [7,8] => 0x3A5, # \Upsilon, \Phi + [9,0xA] => 0x3A8, # \Psi, \Omega + 0xD => 0x2032, # ' + + 0x10 => 0x131, # \i + 0x11 => 0x237, # \j + 0x12 => 0x2CB, # \grave + 0x13 => 0x2CA, # \acute + 0x14 => 0x2C7, # \check + 0x15 => 0x2D8, # \breve + 0x16 => 0x2C9, # \bar + 0x17 => 0xB0, # \degree + 0x17 => 0x02DA, # \r, ring above + 0x18 => 0xB8, # \c, cedilla + 0x20 => 0x2423, # graphic representation of space + + [0x21,0x7F] => 0x21, + + 0x27 => 0x2018, # left quote + 0x60 => 0x2019, # right quote + 0x5E => [0x302,-525,0], # \hat (combining) + 0x7E => [0x303,-525,0], # \tilde (combining) + 0x7F => [0x308,-525,0], # \ddot (combining) + ], +}; + +$map{rsfs10} = { + "Script-Regular" => [ + [0x41,0x5A] => 0x41, # A-Z + ], +}; + +$map{cmssbx10} = { + "SansSerif-Bold" => [ + [0,1] => 0x393, # \Gamma, \Delta + 2 => 0x398, # \Theta + 3 => 0x39B, # \Lambda + 4 => 0x39E, # \Xi + 5 => 0x3A0, # \Pi + 6 => 0x3A3, # \Sigma + [7,8] => 0x3A5, # \Upsilon, \Phi + [9,0xA] => 0x3A8, # \Psi, \Omega + + 0x10 => 0x131, # \i + 0x11 => 0x237, # \j + 0x13 => 0xB4, # \acute + 0x14 => 0x2C7, # \check + 0x15 => 0x2D8, # \breve + 0x16 => 0x2C9, # \bar + 0x17 => [0xB0,-58,0], # \degree + 0x17 => 0x02DA, # \r, ring above + 0x18 => 0xB8, # \c, cedilla + + [0x21,0x2F] => 0x21, # !, ", #, $, %, &, ', (, ), *, +, comma, -, ., / + 0x22 => 0x201D, # " + 0x27 => 0x2019, # ' + [0x30,0x39] => 0x30, # 0-9 + [0x3A,0x3B] => 0x3A, # :, ; + 0x3D => 0x3D, # = + [0x3F,0x40] => 0x3F, # ?, @ + [0x41,0x5A] => 0x41, # A-Z + 0x5B => 0x5B, # [ + 0x5C => 0x201C, # `` + [0x5D,0x5E] => 0x5D, # ], ^ + 0x5E => 0x2C6, # \hat + 0x5F => 0x2D9, # \dot + 0x60 => 0x2018, # ` + [0x61,0x7A] => 0x61, # a-z + [0x7B,0x7C] => 0x2013, # \endash, \emdash + 0x7B => [0x5F,0,-350], # underline + 0x7D => 0x2DD, # double acute + 0x7E => [0x7E,0,-350], # ~ + 0x7E => 0x2DC, # \tilde + 0x7F => 0xA8, # \ddot + ], +}; + +$map{cmss10} = { + "SansSerif-Regular" => [ + [0,1] => 0x393, # \Gamma, \Delta + 2 => 0x398, # \Theta + 3 => 0x39B, # \Lambda + 4 => 0x39E, # \Xi + 5 => 0x3A0, # \Pi + 6 => 0x3A3, # \Sigma + [7,8] => 0x3A5, # \Upsilon, \Phi + [9,0xA] => 0x3A8, # \Psi, \Omega + + 0x10 => 0x131, # \i + 0x11 => 0x237, # \j + 0x12 => 0x2CB, # \grave + 0x13 => 0x2CA, # \acute + 0x14 => 0x2C7, # \check + 0x15 => 0x2D8, # \breve + 0x16 => 0x2C9, # \bar + 0x17 => [0xB0,-142,0], # \degree + 0x17 => 0x02DA, # \r, ring above + 0x18 => 0xB8, # \c, cedilla + + [0x21,0x2F] => 0x21, # !, ", #, $, %, &, ', (, ), *, +, comma, -, ., / + 0x22 => 0x201D, # " + 0x27 => 0x2019, # ' + [0x30,0x39] => 0x30, # 0-9 + [0x3A,0x3B] => 0x3A, # :, ; + 0x3D => 0x3D, # = + [0x3F,0x40] => 0x3F, # ?, @ + [0x41,0x5A] => 0x41, # A-Z + 0x5B => 0x5B, # [ + 0x5C => 0x201C, # `` + [0x5D,0x5E] => 0x5D, # ], ^ + 0x5E => 0x2C6, # \hat + 0x5F => 0x2D9, # \dot + 0x60 => 0x2018, # ` + [0x61,0x7A] => 0x61, # a-z + [0x7B,0x7C] => 0x2013, # \endash, \emdash + 0x7B => [0x5F,0,-350], # underline + 0x7D => 0x2DD, # double acute + 0x7E => [0x7E,0,-350], # ~ + 0x7E => 0x2DC, # \tilde + 0x7F => 0xA8, # \ddot + ], +}; + +$map{cmssi10} = { + "SansSerif-Italic" => [ + [0,1] => 0x393, # \Gamma, \Delta + 2 => 0x398, # \Theta + 3 => 0x39B, # \Lambda + 4 => 0x39E, # \Xi + 5 => 0x3A0, # \Pi + 6 => 0x3A3, # \Sigma + [7,8] => 0x3A5, # \Upsilon, \Phi + [9,0xA] => 0x3A8, # \Psi, \Omega + + 0x10 => 0x131, # \i + 0x11 => 0x237, # \j + 0x12 => 0x2CB, # \grave + 0x13 => 0x2CA, # \acute + 0x14 => 0x2C7, # \check + 0x15 => 0x2D8, # \breve + 0x16 => 0x2C9, # \bar + 0x17 => [0xB0,-113,0], # \degree + 0x17 => 0x02DA, # \r, ring above + 0x18 => 0xB8, # \c, cedilla + + [0x21,0x2F] => 0x21, # !, ", #, $, %, &, ', (, ), *, +, comma, -, ., / + 0x22 => 0x201D, # " + 0x27 => 0x2019, # ' + [0x30,0x39] => 0x30, # 0-9 + [0x3A,0x3B] => 0x3A, # :, ; + 0x3D => 0x3D, # = + [0x3F,0x40] => 0x3F, # ?, @ + [0x41,0x5A] => 0x41, # A-Z + 0x5B => 0x5B, # [ + 0x5C => 0x201C, # `` + [0x5D,0x5E] => 0x5D, # ], ^ + 0x5E => 0x2C6, # \hat + 0x5F => 0x2D9, # \dot + 0x60 => 0x2018, # ` + [0x61,0x7A] => 0x61, # a-z + [0x7B,0x7C] => 0x2013, # \endash, \emdash + 0x7B => [0x5F,0,-350], # underline + 0x7D => 0x2DD, # double acute + 0x7E => [0x7E,0,-350], # ~ + 0x7E => 0x2DC, # \tilde + 0x7F => 0xA8, # \ddot + ], +}; + +foreach $cmfont (keys %map) { + foreach $mjfont (keys %{$map{$cmfont}}) { + $style = $mjfont; $style =~ s/.*?(-|$)//; $style = "Regular" unless $style; + $family = $mjfont; $family =~ s/-.*//; + $fontname = "$family-$style"; + @{$reverse{$fontname}{$cmfont}} = @{$map{$cmfont}{$mjfont}}; + } +} + +my %output; + +sub add_to_output { + my ($mjfont,$cmfont,$from,$to) = @_; + + my $xshift = 0, $yshift = 0; + + if (ref($to) eq "ARRAY") { + $xshift = $to->[1]; + $yshift = $to->[2]; + $to = $to->[0]; + } + + $data = { + "font" => $cmfont, + "char" => $from, + "xshift" => $xshift, + "yshift" => $yshift + }; + + if (defined($output{$mjfont}{$to})) { + print STDERR "Duplicate mapping $to for $mjfont: " . + $output{$mjfont}{$to}{font} . ":" . + $output{$mjfont}{$to}{char} . " vs. $cmfont:$from\n"; + die "Duplicate mapping!"; # disable this line to see all of them + } + $output{$mjfont}{$to} = $data; +} + +foreach $mjfont (keys %reverse) { + foreach $cmfont (keys %{$reverse{$mjfont}}) { + @remap = @{$reverse{$mjfont}{$cmfont}}; + while (defined($item = shift(@remap))) { + $remap = shift(@remap); + + if (ref($item) eq "ARRAY") { + foreach $from ($item->[0]...$item->[1]) { + $to = $from - $item->[0] + $remap; + add_to_output($mjfont, $cmfont, $from, $to); + } + } else { + add_to_output($mjfont, $cmfont, $item, $remap); + } + } + } +} + +print(encode_json(\%output)); diff --git a/node_modules/katex/src/metrics/parse_tfm.py b/node_modules/katex/src/metrics/parse_tfm.py new file mode 100644 index 0000000..56f2db0 --- /dev/null +++ b/node_modules/katex/src/metrics/parse_tfm.py @@ -0,0 +1,211 @@ +class CharInfoWord(object): + def __init__(self, word): + b1, b2, b3, b4 = (word >> 24, + (word & 0xff0000) >> 16, + (word & 0xff00) >> 8, + word & 0xff) + + self.width_index = b1 + self.height_index = b2 >> 4 + self.depth_index = b2 & 0x0f + self.italic_index = (b3 & 0b11111100) >> 2 + self.tag = b3 & 0b11 + self.remainder = b4 + + def has_ligkern(self): + return self.tag == 1 + + def ligkern_start(self): + return self.remainder + + +class LigKernProgram(object): + def __init__(self, program): + self.program = program + + def execute(self, start, next_char): + curr_instruction = start + while True: + instruction = self.program[curr_instruction] + (skip, inst_next_char, op, remainder) = instruction + + if inst_next_char == next_char: + if op < 128: + # Don't worry about ligatures for now, we only need kerns + return None + else: + return 256 * (op - 128) + remainder + elif skip >= 128: + return None + else: + curr_instruction += 1 + skip + + +class TfmCharMetrics(object): + def __init__(self, width, height, depth, italic, kern_table): + self.width = width + self.height = height + self.depth = depth + self.italic_correction = italic + self.kern_table = kern_table + + +class TfmFile(object): + def __init__(self, start_char, end_char, char_info, width_table, + height_table, depth_table, italic_table, ligkern_table, + kern_table): + self.start_char = start_char + self.end_char = end_char + self.char_info = char_info + self.width_table = width_table + self.height_table = height_table + self.depth_table = depth_table + self.italic_table = italic_table + self.ligkern_program = LigKernProgram(ligkern_table) + self.kern_table = kern_table + + def get_char_metrics(self, char_num, fix_rsfs=False): + """Return glyph metrics for a unicode code point. + + Arguments: + char_num: a unicode code point + fix_rsfs: adjust for rsfs10.tfm's different indexing system + """ + if char_num < self.start_char or char_num > self.end_char: + raise RuntimeError("Invalid character number") + + if fix_rsfs: + # all of the char_nums contained start from zero in rsfs10.tfm + info = self.char_info[char_num - self.start_char] + else: + info = self.char_info[char_num + self.start_char] + + char_kern_table = {} + if info.has_ligkern(): + for char in range(self.start_char, self.end_char + 1): + kern = self.ligkern_program.execute(info.ligkern_start(), char) + if kern: + char_kern_table[char] = self.kern_table[kern] + + return TfmCharMetrics( + self.width_table[info.width_index], + self.height_table[info.height_index], + self.depth_table[info.depth_index], + self.italic_table[info.italic_index], + char_kern_table) + + +class TfmReader(object): + def __init__(self, f): + self.f = f + + def read_byte(self): + return ord(self.f.read(1)) + + def read_halfword(self): + b1 = self.read_byte() + b2 = self.read_byte() + return (b1 << 8) | b2 + + def read_word(self): + b1 = self.read_byte() + b2 = self.read_byte() + b3 = self.read_byte() + b4 = self.read_byte() + return (b1 << 24) | (b2 << 16) | (b3 << 8) | b4 + + def read_fixword(self): + word = self.read_word() + + neg = False + if word & 0x80000000: + neg = True + word = (-word & 0xffffffff) + + return (-1 if neg else 1) * word / float(1 << 20) + + def read_bcpl(self, length): + str_length = self.read_byte() + data = self.f.read(length - 1) + return data[:str_length] + + +def read_tfm_file(file_name): + with open(file_name, 'rb') as f: + reader = TfmReader(f) + + # file_size + reader.read_halfword() + header_size = reader.read_halfword() + + start_char = reader.read_halfword() + end_char = reader.read_halfword() + + width_table_size = reader.read_halfword() + height_table_size = reader.read_halfword() + depth_table_size = reader.read_halfword() + italic_table_size = reader.read_halfword() + + ligkern_table_size = reader.read_halfword() + kern_table_size = reader.read_halfword() + + # extensible_table_size + reader.read_halfword() + # parameter_table_size + reader.read_halfword() + + # checksum + reader.read_word() + # design_size + reader.read_fixword() + + if header_size > 2: + # coding_scheme + reader.read_bcpl(40) + + if header_size > 12: + # font_family + reader.read_bcpl(20) + + for i in range(header_size - 17): + reader.read_word() + + char_info = [] + for i in range(start_char, end_char + 1): + char_info.append(CharInfoWord(reader.read_word())) + + width_table = [] + for i in range(width_table_size): + width_table.append(reader.read_fixword()) + + height_table = [] + for i in range(height_table_size): + height_table.append(reader.read_fixword()) + + depth_table = [] + for i in range(depth_table_size): + depth_table.append(reader.read_fixword()) + + italic_table = [] + for i in range(italic_table_size): + italic_table.append(reader.read_fixword()) + + ligkern_table = [] + for i in range(ligkern_table_size): + skip = reader.read_byte() + next_char = reader.read_byte() + op = reader.read_byte() + remainder = reader.read_byte() + + ligkern_table.append((skip, next_char, op, remainder)) + + kern_table = [] + for i in range(kern_table_size): + kern_table.append(reader.read_fixword()) + + # There is more information, like the ligkern, kern, extensible, and + # param table, but we don't need these for now + + return TfmFile(start_char, end_char, char_info, width_table, + height_table, depth_table, italic_table, + ligkern_table, kern_table) diff --git a/node_modules/katex/src/parseNode.ts b/node_modules/katex/src/parseNode.ts new file mode 100644 index 0000000..31ff98f --- /dev/null +++ b/node_modules/katex/src/parseNode.ts @@ -0,0 +1,44 @@ +import {NON_ATOMS} from "./atoms"; +import type {AnyParseNode, NodeType, ParseNode, SymbolParseNode} from "./types/nodes"; + +/** + * Asserts that the node is of the given type and returns it with stricter + * typing. Throws if the node's type does not match. + */ +export function assertNodeType( + node: AnyParseNode | null | undefined, + type: NODETYPE, +): ParseNode { + if (!node || node.type !== type) { + throw new Error( + `Expected node of type ${type}, but got ` + + (node ? `node of type ${node.type}` : String(node))); + } + + return node as ParseNode; +} + +/** + * Returns the node more strictly typed iff it is of the given type. Otherwise, + * returns null. + */ +export function assertSymbolNodeType(node: AnyParseNode | null | undefined): SymbolParseNode { + const typedNode = checkSymbolNodeType(node); + if (!typedNode) { + throw new Error( + `Expected node of symbol group type, but got ` + + (node ? `node of type ${node.type}` : String(node))); + } + return typedNode; +} + +/** + * Returns the node more strictly typed if it is of the given type. Otherwise, + * returns null. + */ +export function checkSymbolNodeType(node: AnyParseNode | null | undefined): SymbolParseNode | null | undefined { + if (node && (node.type === "atom" || NON_ATOMS.hasOwnProperty(node.type))) { + return node as SymbolParseNode; + } + return null; +} diff --git a/node_modules/katex/src/parseTree.ts b/node_modules/katex/src/parseTree.ts new file mode 100644 index 0000000..63dde9a --- /dev/null +++ b/node_modules/katex/src/parseTree.ts @@ -0,0 +1,46 @@ +import Parser from "./Parser"; +import ParseError from "./ParseError"; +import {Token} from "./Token"; + +import type Settings from "./Settings"; +import type {AnyParseNode} from "./types/nodes"; + +/** + * Parses an expression using a Parser, then returns the parsed result. + */ +const parseTree = function( + toParse: string | InstanceType, + settings: Settings, +): AnyParseNode[] { + if (!(typeof toParse === 'string' || toParse instanceof String)) { + throw new TypeError('KaTeX can only parse string typed expression'); + } + const parser = new Parser(toParse as string, settings); + + // Blank out any \df@tag to avoid spurious "Duplicate \tag" errors + delete parser.gullet.macros.current["\\df@tag"]; + + let tree = parser.parse(); + + // Prevent a color definition from persisting between calls to katex.render(). + delete parser.gullet.macros.current["\\current@color"]; + delete parser.gullet.macros.current["\\color"]; + + // If the input used \tag, it will set the \df@tag macro to the tag. + // In this case, we separately parse the tag and wrap the tree. + if (parser.gullet.macros.get("\\df@tag")) { + if (!settings.displayMode) { + throw new ParseError("\\tag works only in display equations"); + } + tree = [{ + type: "tag", + mode: "text", + body: tree, + tag: parser.subparse([new Token("\\df@tag")]), + }]; + } + + return tree; +}; + +export default parseTree; diff --git a/node_modules/katex/src/spacingData.ts b/node_modules/katex/src/spacingData.ts new file mode 100644 index 0000000..e43423d --- /dev/null +++ b/node_modules/katex/src/spacingData.ts @@ -0,0 +1,108 @@ +/** + * Describes spaces between different classes of atoms. + */ + +import type {Measurement} from "./types"; + +const thinspace: Measurement = { + number: 3, + unit: "mu", +}; +const mediumspace: Measurement = { + number: 4, + unit: "mu", +}; +const thickspace: Measurement = { + number: 5, + unit: "mu", +}; + +// Making the type below exact with all optional fields doesn't work due to +// - https://github.com/facebook/flow/issues/4582 +// - https://github.com/facebook/flow/issues/5688 +// However, since *all* fields are optional, $Shape<> works as suggested in 5688 +// above. +export type Spacings = Partial<{ + mord: Measurement; + mop: Measurement; + mbin: Measurement; + mrel: Measurement; + mopen: Measurement; + mclose: Measurement; + mpunct: Measurement; + minner: Measurement; +}> & {}; + +// Spacing relationships for display and text styles +export const spacings: {[key in keyof Spacings]?: Spacings} = { + mord: { + mop: thinspace, + mbin: mediumspace, + mrel: thickspace, + minner: thinspace, + }, + mop: { + mord: thinspace, + mop: thinspace, + mrel: thickspace, + minner: thinspace, + }, + mbin: { + mord: mediumspace, + mop: mediumspace, + mopen: mediumspace, + minner: mediumspace, + }, + mrel: { + mord: thickspace, + mop: thickspace, + mopen: thickspace, + minner: thickspace, + }, + mopen: {}, + mclose: { + mop: thinspace, + mbin: mediumspace, + mrel: thickspace, + minner: thinspace, + }, + mpunct: { + mord: thinspace, + mop: thinspace, + mrel: thickspace, + mopen: thinspace, + mclose: thinspace, + mpunct: thinspace, + minner: thinspace, + }, + minner: { + mord: thinspace, + mop: thinspace, + mbin: mediumspace, + mrel: thickspace, + mopen: thinspace, + mpunct: thinspace, + minner: thinspace, + }, +}; + +// Spacing relationships for script and scriptscript styles +export const tightSpacings: {[key in keyof Spacings]?: Spacings} = { + mord: { + mop: thinspace, + }, + mop: { + mord: thinspace, + mop: thinspace, + }, + mbin: {}, + mrel: {}, + mopen: {}, + mclose: { + mop: thinspace, + }, + mpunct: {}, + minner: { + mop: thinspace, + }, +}; diff --git a/node_modules/katex/src/stretchy.ts b/node_modules/katex/src/stretchy.ts new file mode 100644 index 0000000..8d060a3 --- /dev/null +++ b/node_modules/katex/src/stretchy.ts @@ -0,0 +1,358 @@ +/** + * This file provides support to buildMathML.js and buildHTML.js + * for stretchy wide elements rendered from SVG files + * and other CSS trickery. + */ + +import {LineNode, PathNode, SvgNode} from "./domTree"; +import {makeSpan, makeSvgSpan} from "./buildCommon"; +import {MathNode, TextNode} from "./mathMLTree"; +import {makeEm} from "./units"; + +import type Options from "./Options"; +import type {ParseNode} from "./types/nodes"; +import type {DomSpan, HtmlDomNode, SvgSpan} from "./domTree"; + +const stretchyCodePoint: Record = { + widehat: "^", + widecheck: "ˇ", + widetilde: "~", + utilde: "~", + overleftarrow: "\u2190", + underleftarrow: "\u2190", + xleftarrow: "\u2190", + overrightarrow: "\u2192", + underrightarrow: "\u2192", + xrightarrow: "\u2192", + underbrace: "\u23df", + overbrace: "\u23de", + underbracket: "\u23b5", + overbracket: "\u23b4", + overgroup: "\u23e0", + undergroup: "\u23e1", + overleftrightarrow: "\u2194", + underleftrightarrow: "\u2194", + xleftrightarrow: "\u2194", + Overrightarrow: "\u21d2", + xRightarrow: "\u21d2", + overleftharpoon: "\u21bc", + xleftharpoonup: "\u21bc", + overrightharpoon: "\u21c0", + xrightharpoonup: "\u21c0", + xLeftarrow: "\u21d0", + xLeftrightarrow: "\u21d4", + xhookleftarrow: "\u21a9", + xhookrightarrow: "\u21aa", + xmapsto: "\u21a6", + xrightharpoondown: "\u21c1", + xleftharpoondown: "\u21bd", + xrightleftharpoons: "\u21cc", + xleftrightharpoons: "\u21cb", + xtwoheadleftarrow: "\u219e", + xtwoheadrightarrow: "\u21a0", + xlongequal: "=", + xtofrom: "\u21c4", + xrightleftarrows: "\u21c4", + xrightequilibrium: "\u21cc", // Not a perfect match. + xleftequilibrium: "\u21cb", // None better available. + "\\cdrightarrow": "\u2192", + "\\cdleftarrow": "\u2190", + "\\cdlongequal": "=", +}; + +export const stretchyMathML = function(label: string): MathNode { + const node = new MathNode( + "mo", + [new TextNode(stretchyCodePoint[label.replace(/^\\/, '')])], + ); + node.setAttribute("stretchy", "true"); + return node; +}; + +// Many of the KaTeX SVG images have been adapted from glyphs in KaTeX fonts. +// Copyright (c) 2009-2010, Design Science, Inc. () +// Copyright (c) 2014-2017 Khan Academy () +// Licensed under the SIL Open Font License, Version 1.1. +// See \nhttp://scripts.sil.org/OFL + +// Very Long SVGs +// Many of the KaTeX stretchy wide elements use a long SVG image and an +// overflow: hidden tactic to achieve a stretchy image while avoiding +// distortion of arrowheads or brace corners. + +// The SVG typically contains a very long (400 em) arrow. + +// The SVG is in a container span that has overflow: hidden, so the span +// acts like a window that exposes only part of the SVG. + +// The SVG always has a longer, thinner aspect ratio than the container span. +// After the SVG fills 100% of the height of the container span, +// there is a long arrow shaft left over. That left-over shaft is not shown. +// Instead, it is sliced off because the span's CSS has overflow: hidden. + +// Thus, the reader sees an arrow that matches the subject matter width +// without distortion. + +// Some functions, such as \cancel, need to vary their aspect ratio. These +// functions do not get the overflow SVG treatment. + +// In the katexImagesData object just below, the dimensions all +// correspond to path geometry inside the relevant SVG. +// For example, \overrightarrow uses the same arrowhead as glyph U+2192 +// from the KaTeX Main font. The scaling factor is 1000. +// That is, inside the font, that arrowhead is 522 units tall, which +// corresponds to 0.522 em inside the document. + +type SvgData = [string[], number, number, string?]; + +const katexImagesData: {[key: string]: SvgData} = { + // path(s), minWidth, height, align + overrightarrow: [["rightarrow"], 0.888, 522, "xMaxYMin"], + overleftarrow: [["leftarrow"], 0.888, 522, "xMinYMin"], + underrightarrow: [["rightarrow"], 0.888, 522, "xMaxYMin"], + underleftarrow: [["leftarrow"], 0.888, 522, "xMinYMin"], + xrightarrow: [["rightarrow"], 1.469, 522, "xMaxYMin"], + "\\cdrightarrow": [["rightarrow"], 3.0, 522, "xMaxYMin"], // CD minwwidth2.5pc + xleftarrow: [["leftarrow"], 1.469, 522, "xMinYMin"], + "\\cdleftarrow": [["leftarrow"], 3.0, 522, "xMinYMin"], + Overrightarrow: [["doublerightarrow"], 0.888, 560, "xMaxYMin"], + xRightarrow: [["doublerightarrow"], 1.526, 560, "xMaxYMin"], + xLeftarrow: [["doubleleftarrow"], 1.526, 560, "xMinYMin"], + overleftharpoon: [["leftharpoon"], 0.888, 522, "xMinYMin"], + xleftharpoonup: [["leftharpoon"], 0.888, 522, "xMinYMin"], + xleftharpoondown: [["leftharpoondown"], 0.888, 522, "xMinYMin"], + overrightharpoon: [["rightharpoon"], 0.888, 522, "xMaxYMin"], + xrightharpoonup: [["rightharpoon"], 0.888, 522, "xMaxYMin"], + xrightharpoondown: [["rightharpoondown"], 0.888, 522, "xMaxYMin"], + xlongequal: [["longequal"], 0.888, 334, "xMinYMin"], + "\\cdlongequal": [["longequal"], 3.0, 334, "xMinYMin"], + xtwoheadleftarrow: [["twoheadleftarrow"], 0.888, 334, "xMinYMin"], + xtwoheadrightarrow: [["twoheadrightarrow"], 0.888, 334, "xMaxYMin"], + + overleftrightarrow: [["leftarrow", "rightarrow"], 0.888, 522], + overbrace: [["leftbrace", "midbrace", "rightbrace"], 1.6, 548], + underbrace: [["leftbraceunder", "midbraceunder", "rightbraceunder"], + 1.6, 548], + underleftrightarrow: [["leftarrow", "rightarrow"], 0.888, 522], + xleftrightarrow: [["leftarrow", "rightarrow"], 1.75, 522], + xLeftrightarrow: [["doubleleftarrow", "doublerightarrow"], 1.75, 560], + xrightleftharpoons: [["leftharpoondownplus", "rightharpoonplus"], 1.75, 716], + xleftrightharpoons: [["leftharpoonplus", "rightharpoondownplus"], + 1.75, 716], + xhookleftarrow: [["leftarrow", "righthook"], 1.08, 522], + xhookrightarrow: [["lefthook", "rightarrow"], 1.08, 522], + overlinesegment: [["leftlinesegment", "rightlinesegment"], 0.888, 522], + underlinesegment: [["leftlinesegment", "rightlinesegment"], 0.888, 522], + overbracket: [["leftbracketover", "rightbracketover"], 1.6, 440], + underbracket: [["leftbracketunder", "rightbracketunder"], 1.6, 410], + overgroup: [["leftgroup", "rightgroup"], 0.888, 342], + undergroup: [["leftgroupunder", "rightgroupunder"], 0.888, 342], + xmapsto: [["leftmapsto", "rightarrow"], 1.5, 522], + xtofrom: [["leftToFrom", "rightToFrom"], 1.75, 528], + + // The next three arrows are from the mhchem package. + // In mhchem.sty, min-length is 2.0em. But these arrows might appear in the + // document as \xrightarrow or \xrightleftharpoons. Those have + // min-length = 1.75em, so we set min-length on these next three to match. + xrightleftarrows: [["baraboveleftarrow", "rightarrowabovebar"], 1.75, 901], + xrightequilibrium: [["baraboveshortleftharpoon", + "rightharpoonaboveshortbar"], 1.75, 716], + xleftequilibrium: [["shortbaraboveleftharpoon", + "shortrightharpoonabovebar"], 1.75, 716], +}; + +const wideAccentLabels = + new Set(["widehat", "widecheck", "widetilde", "utilde"]); + +export const stretchySvg = function( + group: ParseNode<"accent"> | ParseNode<"accentUnder"> | ParseNode<"xArrow"> + | ParseNode<"horizBrace">, + options: Options, +): DomSpan | SvgSpan { + // Create a span with inline SVG for the element. + function buildSvgSpan_(): { + span: DomSpan | SvgSpan, + minWidth: number, + height: number, + } { + let viewBoxWidth = 400000; // default + const label = group.label.slice(1); + if (wideAccentLabels.has(label) && 'base' in group) { + // There are four SVG images available for each function. + // Choose a taller image when there are more characters. + const numChars = group.base.type === "ordgroup" ? + group.base.body.length : 1; + let viewBoxHeight; + let pathName; + let height; + + if (numChars > 5) { + if (label === "widehat" || label === "widecheck") { + viewBoxHeight = 420; + viewBoxWidth = 2364; + height = 0.42; + pathName = label + "4"; + } else { + viewBoxHeight = 312; + viewBoxWidth = 2340; + height = 0.34; + pathName = "tilde4"; + } + } else { + const imgIndex = [1, 1, 2, 2, 3, 3][numChars]; + if (label === "widehat" || label === "widecheck") { + viewBoxWidth = [0, 1062, 2364, 2364, 2364][imgIndex]; + viewBoxHeight = [0, 239, 300, 360, 420][imgIndex]; + height = [0, 0.24, 0.3, 0.3, 0.36, 0.42][imgIndex]; + pathName = label + imgIndex; + } else { + viewBoxWidth = [0, 600, 1033, 2339, 2340][imgIndex]; + viewBoxHeight = [0, 260, 286, 306, 312][imgIndex]; + height = [0, 0.26, 0.286, 0.3, 0.306, 0.34][imgIndex]; + pathName = "tilde" + imgIndex; + } + } + const path = new PathNode(pathName); + const svgNode = new SvgNode([path], { + "width": "100%", + "height": makeEm(height), + "viewBox": `0 0 ${viewBoxWidth} ${viewBoxHeight}`, + "preserveAspectRatio": "none", + }); + return { + span: makeSvgSpan([], [svgNode], options), + minWidth: 0, + height, + }; + } else { + const spans = []; + + const data = katexImagesData[label]; + if (!data) { + throw new Error(`No SVG data for "${label}".`); + } + const [paths, minWidth, viewBoxHeight] = data; + const height = viewBoxHeight / 1000; + + const numSvgChildren = paths.length; + let widthClasses; + let aligns; + if (numSvgChildren === 1) { + if (data.length !== 4) { + throw new Error( + `Expected 4-tuple for single-path SVG data "${label}".`); + } + widthClasses = ["hide-tail"]; + aligns = [data[3]]; + } else if (numSvgChildren === 2) { + widthClasses = ["halfarrow-left", "halfarrow-right"]; + aligns = ["xMinYMin", "xMaxYMin"]; + } else if (numSvgChildren === 3) { + widthClasses = ["brace-left", "brace-center", "brace-right"]; + aligns = ["xMinYMin", "xMidYMin", "xMaxYMin"]; + } else { + throw new Error( + `Correct katexImagesData or update code here to support + ${numSvgChildren} children.`); + } + + for (let i = 0; i < numSvgChildren; i++) { + const path = new PathNode(paths[i]); + + const svgNode = new SvgNode([path], { + "width": "400em", + "height": makeEm(height), + "viewBox": `0 0 ${viewBoxWidth} ${viewBoxHeight}`, + "preserveAspectRatio": aligns[i] + " slice", + }); + + const span = makeSvgSpan( + [widthClasses[i]], [svgNode], options); + if (numSvgChildren === 1) { + return {span, minWidth, height}; + } else { + span.style.height = makeEm(height); + spans.push(span); + } + } + + return { + span: makeSpan(["stretchy"], spans, options), + minWidth, + height, + }; + } + } // buildSvgSpan_() + const {span, minWidth, height} = buildSvgSpan_(); + + // Note that we are returning span.depth = 0. + // Any adjustments relative to the baseline must be done in buildHTML. + span.height = height; + span.style.height = makeEm(height); + if (minWidth > 0) { + span.style.minWidth = makeEm(minWidth); + } + + return span; +}; + +export const stretchyEnclose = function( + inner: HtmlDomNode, + label: string, + topPad: number, + bottomPad: number, + options: Options, +): DomSpan | SvgSpan { + // Return an image span for \cancel, \bcancel, \xcancel, \fbox, or \angl + let img; + const totalHeight = inner.height + inner.depth + topPad + bottomPad; + + if (/fbox|color|angl/.test(label)) { + img = makeSpan(["stretchy", label], [], options); + + if (label === "fbox") { + const color = options.color && options.getColor(); + if (color) { + img.style.borderColor = color; + } + } + + } else { + // \cancel, \bcancel, or \xcancel + // Since \cancel's SVG is inline and it omits the viewBox attribute, + // its stroke-width will not vary with span area. + + const lines = []; + if (/^[bx]cancel$/.test(label)) { + lines.push(new LineNode({ + "x1": "0", + "y1": "0", + "x2": "100%", + "y2": "100%", + "stroke-width": "0.046em", + })); + } + + if (/^x?cancel$/.test(label)) { + lines.push(new LineNode({ + "x1": "0", + "y1": "100%", + "x2": "100%", + "y2": "0", + "stroke-width": "0.046em", + })); + } + + const svgNode = new SvgNode(lines, { + "width": "100%", + "height": makeEm(totalHeight), + }); + + img = makeSvgSpan([], [svgNode], options); + } + + img.height = totalHeight; + img.style.height = makeEm(totalHeight); + + return img; +}; diff --git a/node_modules/katex/src/styles/fonts.scss b/node_modules/katex/src/styles/fonts.scss new file mode 100644 index 0000000..430da86 --- /dev/null +++ b/node_modules/katex/src/styles/fonts.scss @@ -0,0 +1,75 @@ +@use "sass:list"; + +$font-folder: "../../fonts" !default; +$use-woff2: true !default; +$use-woff: true !default; +$use-ttf: true !default; +$font-display: block !default; + +@function generate-src($family, $family-suffix) { + $src: null; + @if $use-woff2 { + $src: list.append($src, url('#{$font-folder}/KaTeX_#{$family}-#{$family-suffix}.woff2') format('woff2'), comma); + } + @if $use-woff { + $src: list.append($src, url('#{$font-folder}/KaTeX_#{$family}-#{$family-suffix}.woff') format('woff'), comma); + } + @if $use-ttf { + $src: list.append($src, url('#{$font-folder}/KaTeX_#{$family}-#{$family-suffix}.ttf') format('truetype'), comma); + } + + @return $src; +} + +@function generate-suffix($weight, $style) { + $suffix: null; + + @if $weight == normal and $style == normal { + $suffix: 'Regular'; + } + @if $weight == normal and $style == italic { + $suffix: 'Italic'; + } + @if $weight == bold and $style == normal { + $suffix: 'Bold'; + } + @if $weight == bold and $style == italic { + $suffix: 'BoldItalic'; + } + + @return $suffix; +} + +@mixin font-face($family, $weight, $style) { + $suffix: generate-suffix($weight, $style); + $src: generate-src($family, $suffix); + + @font-face { + font-family: 'KaTeX_#{$family}'; + src: $src; + font-weight: $weight; + font-style: $style; + font-display: $font-display; + } +} + +@include font-face('AMS', normal, normal); +@include font-face('Caligraphic', bold, normal); +@include font-face('Caligraphic', normal, normal); +@include font-face('Fraktur', bold, normal); +@include font-face('Fraktur', normal, normal); +@include font-face('Main', bold, normal); +@include font-face('Main', bold, italic); +@include font-face('Main', normal, italic); +@include font-face('Main', normal, normal); +@include font-face('Math', bold, italic); +@include font-face('Math', normal, italic); +@include font-face('SansSerif', bold, normal); +@include font-face('SansSerif', normal, italic); +@include font-face('SansSerif', normal, normal); +@include font-face('Script', normal, normal); +@include font-face('Size1', normal, normal); +@include font-face('Size2', normal, normal); +@include font-face('Size3', normal, normal); +@include font-face('Size4', normal, normal); +@include font-face('Typewriter', normal, normal); diff --git a/node_modules/katex/src/styles/katex-swap.scss b/node_modules/katex/src/styles/katex-swap.scss new file mode 100644 index 0000000..ac46cb0 --- /dev/null +++ b/node_modules/katex/src/styles/katex-swap.scss @@ -0,0 +1,4 @@ +@use 'katex' with ( + $font-display: swap, + $version: $version, +); diff --git a/node_modules/katex/src/styles/katex.scss b/node_modules/katex/src/styles/katex.scss new file mode 100644 index 0000000..f3223f9 --- /dev/null +++ b/node_modules/katex/src/styles/katex.scss @@ -0,0 +1,683 @@ +/* stylelint-disable font-family-no-missing-generic-family-keyword */ +@use "sass:list"; +@use "sass:math"; + +@forward "fonts.scss" with ( + $font-folder: "../../fonts" !default, + $use-woff2: true !default, + $use-woff: true !default, + $use-ttf: true !default, + $font-display: block !default +); + +@use "fonts.scss"; + +// The mu unit is defined as 1/18 em +$mu: calc(1em / 18); + +// The version is dynamically set from package.json via webpack.common.js +$version: "" !default; + +// CSS margin property for math in display mode +$display-margin: 1em 0 !default; + +.katex { + font: normal 1.21em KaTeX_Main, Times New Roman, serif; + line-height: 1.2; + position: relative; + + // Protect elements inside .katex from inheriting text-indent. + text-indent: 0; + + // Prevent a rendering bug that misplaces \vec in Chrome. + text-rendering: auto; + + * { + // Prevent background resetting on elements in Windows's high-contrast + // mode, while still allowing background/foreground setting on root .katex + -ms-high-contrast-adjust: none !important; + + // Insulate fraction bars and rules from CSS that sets border-color. + border-color: currentColor; + } + + .katex-version::after { + content: $version; + } + + .katex-mathml { + /* Accessibility hack to only show to screen readers + Found at: http://a11yproject.com/posts/how-to-hide-content/ */ + position: absolute; + clip-path: inset(50%); + padding: 0; + border: 0; + height: 1px; + width: 1px; + overflow: hidden; + } + + .katex-html { + /* \newline is an empty block at top level, between .base elements */ + > .newline { + display: block; + } + } + + .base { + position: relative; + display: inline-block; + white-space: nowrap; + + // Fix width of containers of negative spaces, working around Chrome bug. + width: min-content; + } + + .strut { + display: inline-block; + } + + // Text font weights + .textbf { + font-weight: bold; + } + + // Text font shapes. + .textit { + font-style: italic; + } + + // Text font families. + .textrm { + font-family: KaTeX_Main; + } + + .textsf { + font-family: KaTeX_SansSerif; + } + + .texttt { + font-family: KaTeX_Typewriter; + } + + // Math fonts. + .mathnormal { + font-family: KaTeX_Math; + font-style: italic; + } + + .mathit { + font-family: KaTeX_Main; + font-style: italic; + } + + .mathrm { + font-style: normal; + } + + .mathbf { + font-family: KaTeX_Main; + font-weight: bold; + } + + .boldsymbol { + font-family: KaTeX_Math; + font-weight: bold; + font-style: italic; + } + + .amsrm { + font-family: KaTeX_AMS; + } + + .mathbb, + .textbb { + font-family: KaTeX_AMS; + } + + .mathcal { + font-family: KaTeX_Caligraphic; + } + + .mathfrak, + .textfrak { + font-family: KaTeX_Fraktur; + } + + .mathboldfrak, + .textboldfrak { + font-family: KaTeX_Fraktur; + font-weight: bold; + } + + .mathtt { + font-family: KaTeX_Typewriter; + } + + .mathscr, + .textscr { + font-family: KaTeX_Script; + } + + .mathsf, + .textsf { + font-family: KaTeX_SansSerif; + } + + .mathboldsf, + .textboldsf { + font-family: KaTeX_SansSerif; + font-weight: bold; + } + + .mathsfit, + .mathitsf, + .textitsf { + font-family: KaTeX_SansSerif; + font-style: italic; + } + + .mainrm { + font-family: KaTeX_Main; + font-style: normal; + } + + // This value is also used in fontMetrics.js, if you change it make sure the + // values match. + $ptperem: 10; + $nulldelimiterspace: calc(1.2em / $ptperem); + + $muspace: 0.055556em; // 1mu + $thinspace: 0.16667em; // 3mu + $mediumspace: 0.22222em; // 4mu + $thickspace: 0.27778em; // 5mu + + .vlist-t { + display: inline-table; + table-layout: fixed; + border-collapse: collapse; + } + + .vlist-r { + display: table-row; + } + + .vlist { + display: table-cell; + vertical-align: bottom; + position: relative; + + > span { + display: block; + height: 0; + position: relative; + + > span { + display: inline-block; + } + + > .pstrut { + overflow: hidden; + width: 0; + } + } + } + + .vlist-t2 { + margin-right: -2px; + } + + .vlist-s { + // This cell solves Safari rendering problems. It has text content, so + // its baseline is used for the table. A very small font avoids line-box + // issues; absolute units prevent user font-size overrides from breaking + // rendering. Safari refuses to make the box zero-width, so we give it + // a known width and compensate with negative right margin on the + // inline-table. To prevent the "width: min-content" Chrome workaround + // from shrinking this box, we also set min-width. + display: table-cell; + vertical-align: bottom; + font-size: 1px; + width: 2px; + min-width: 2px; + } + + .vbox { + display: inline-flex; + flex-direction: column; + align-items: baseline; + } + + .hbox { + display: inline-flex; + flex-direction: row; + width: 100%; + } + + .thinbox { + display: inline-flex; + flex-direction: row; + width: 0; + max-width: 0; // necessary for Safari + } + + .msupsub { + text-align: left; + } + + .mfrac { + > span > span { + text-align: center; + } + + .frac-line { + display: inline-block; + width: 100%; + border-bottom-style: solid; + } + } + + // Prevent Chrome from disappearing frac-lines, rules, etc. + .mfrac .frac-line, + .overline .overline-line, + .underline .underline-line, + .hline, + .hdashline, + .rule { + min-height: 1px; + } + + .mspace { + display: inline-block; + } + + .smash { + display: inline; + line-height: 0; + } + + .llap, + .rlap, + .clap { + width: 0; + position: relative; + + > .inner { + position: absolute; + } + + > .fix { + display: inline-block; + } + } + + .llap > .inner { + right: 0; + } + + .rlap > .inner, + .clap > .inner { + left: 0; + } + + .clap > .inner > span { + margin-left: -50%; + margin-right: 50%; + } + + .rule { + display: inline-block; + border: solid 0; + position: relative; + } + + .overline .overline-line, + .underline .underline-line, + .hline { + display: inline-block; + width: 100%; + border-bottom-style: solid; + } + + .hdashline { + display: inline-block; + width: 100%; + border-bottom-style: dashed; + } + + .sqrt { + > .root { + /* These values are taken from the definition of `\r@@t`, + `\mkern 5mu` and `\mkern -10mu`. */ + /* stylelint-disable-next-line declaration-property-value-no-unknown */ + margin-left: calc(5*$mu); + /* stylelint-disable-next-line declaration-property-value-no-unknown */ + margin-right: calc(-10*$mu); + } + } + + .sizing, + .fontsize-ensurer { + $sizes: 0.5, 0.6, 0.7, 0.8, 0.9, 1, 1.2, 1.44, 1.728, 2.074, 2.488; + + @for $from from 1 through list.length($sizes) { + @for $to from 1 through list.length($sizes) { + &.reset-size#{$from}.size#{$to} { + /* stylelint-disable-next-line */ + font-size: calc(math.div(list.nth($sizes, $to), list.nth($sizes, $from)) * 1em); + } + } + } + } + + .delimsizing { + &.size1 { font-family: KaTeX_Size1; } + &.size2 { font-family: KaTeX_Size2; } + &.size3 { font-family: KaTeX_Size3; } + &.size4 { font-family: KaTeX_Size4; } + + &.mult { + .delim-size1 > span { + font-family: KaTeX_Size1; + } + + .delim-size4 > span { + font-family: KaTeX_Size4; + } + } + } + + .nulldelimiter { + display: inline-block; + width: $nulldelimiterspace; + } + + .delimcenter { + position: relative; + } + + .op-symbol { + position: relative; + + &.small-op { + font-family: KaTeX_Size1; + } + + &.large-op { + font-family: KaTeX_Size2; + } + } + + .op-limits { + > .vlist-t { + text-align: center; + } + } + + .accent { + > .vlist-t { + text-align: center; + } + + .accent-body { + position: relative; // so that 'left' can shift the accent + } + + // Accents that are not of the accent-full class have zero width + // (do not contribute to the width of the final symbol). + .accent-body:not(.accent-full) { + width: 0; + } + } + + .overlay { + display: block; + } + + .mtable { + .vertical-separator { + display: inline-block; + // margin and border-right are set in JavaScript + min-width: 1px; // Prevent Chrome from omitting a line. + } + + .arraycolsep { + display: inline-block; + } + + .col-align-c > .vlist-t { + text-align: center; + } + + .col-align-l > .vlist-t { + text-align: left; + } + + .col-align-r > .vlist-t { + text-align: right; + } + } + + .svg-align { + text-align: left; + } + + svg { + display: block; + position: absolute; // absolute relative to parent + width: 100%; + height: inherit; + + // We want to inherit colors from our environment + fill: currentColor; + stroke: currentColor; + + // But path elements should not have an outline by default + // that would make them bigger than we expect. + path { + stroke: none; + } + + // And we don't want to inherit any other style properties + // that could affect SVG rendering without affecting font + // rendering. So we reset these properties to their default + // values for every element. + // See https://www.w3.org/TR/SVG/painting.html + fill-rule: nonzero; + fill-opacity: 1; + stroke-width: 1; + stroke-linecap: butt; + stroke-linejoin: miter; + stroke-miterlimit: 4; + stroke-dasharray: none; + stroke-dashoffset: 0; + stroke-opacity: 1; + } + + img { + border-style: none; + min-width: 0; + min-height: 0; + max-width: none; + max-height: none; + } + + // Define CSS for image whose width will match its span width. + .stretchy { + width: 100%; + display: block; + position: relative; + overflow: hidden; + + &::before, + &::after { + content: ""; + } + } + + // Hide the long tail of a stretchy SVG. + .hide-tail { + width: 100%; // necessary only to get IE to work properly + position: relative; // ditto + overflow: hidden; // This line applies to all browsers. + } + + .halfarrow-left { + position: absolute; + left: 0; + width: 50.2%; + overflow: hidden; + } + + .halfarrow-right { + position: absolute; + right: 0; + width: 50.2%; + overflow: hidden; + } + + .brace-left { + position: absolute; + left: 0; + width: 25.1%; + overflow: hidden; + } + + .brace-center { + position: absolute; + left: 25%; + width: 50%; + overflow: hidden; + } + + .brace-right { + position: absolute; + right: 0; + width: 25.1%; + overflow: hidden; + } + + // Lengthen the extensible arrows via padding. + .x-arrow-pad { + padding: 0 0.5em; + } + + .cd-arrow-pad { + padding: 0 0.55556em 0 0.27778em; // \;{#1}\;\; + } + + .x-arrow, + .mover, + .munder { + text-align: center; + } + + .boxpad { + padding: 0 0.3em; // \fboxsep = 3pt + } + + .fbox, + .fcolorbox { + box-sizing: border-box; + border: 0.04em solid; // \fboxrule = 0.4pt + } + + .cancel-pad { + padding: 0 0.2em; // ref: cancel package \advance\dimen@ 2\p@ % "+2" + } + + .cancel-lap { + margin-left: -0.2em; // \cancel does not affect horizontal spacing. + margin-right: -0.2em; // Apply negative margin to correct for 0.2em padding + } // inside the \cancel group. + + .sout { + border-bottom-style: solid; + border-bottom-width: 0.08em; + } + + .angl { + // from package actuarialangle, which is always used in a subscript. + box-sizing: border-box; + border-top: 0.049em solid; // defaultRuleThickness in scriptstyle + border-right: 0.049em solid; // ditto + margin-right: 0.03889em; // 1 mu + } + + .anglpad { + padding: 0 0.03889em; // pad 1mu left and right (in scriptstyle) + } + + .eqn-num::before { + counter-increment: katexEqnNo; + content: "(" counter(katexEqnNo) ")"; + } + + .mml-eqn-num::before { + counter-increment: mmlEqnNo; + content: "(" counter(mmlEqnNo) ")"; + } + + .mtr-glue { + width: 50%; + } + + .cd-vert-arrow { + display: inline-block; + position: relative; + } + + .cd-label-left { + display: inline-block; + position: absolute; + right: calc(50% + 0.3em); + text-align: left; + } + + .cd-label-right { + display: inline-block; + position: absolute; + left: calc(50% + 0.3em); + text-align: right; + } +} + +.katex-display { + display: block; + margin: $display-margin; + text-align: center; + + > .katex { + display: block; + text-align: center; + white-space: nowrap; + + > .katex-html { + display: block; + position: relative; + + > .tag { + position: absolute; + right: 0; + } + } + } +} + +// Left-justified tags (default is right-justified) +.katex-display.leqno > .katex > .katex-html > .tag { + left: 0; + right: auto; +} + +// Flush-left display math +.katex-display.fleqn > .katex { + text-align: left; + padding-left: 2em; +} + +// Automatic equation numbers for some environments. +// Use parallel counters for HTML and MathML. +body { + counter-reset: katexEqnNo mmlEqnNo; +} diff --git a/node_modules/katex/src/svgGeometry.ts b/node_modules/katex/src/svgGeometry.ts new file mode 100644 index 0000000..0765eef --- /dev/null +++ b/node_modules/katex/src/svgGeometry.ts @@ -0,0 +1,561 @@ +/** + * This file provides support to domTree.js and delimiter.js. + * It's a storehouse of path geometry for SVG images. + */ + +// In all paths below, the viewBox-to-em scale is 1000:1. + +// Second Brush Stroke +// Low resolution monitors struggle to display images in fine detail. +// So browsers apply anti-aliasing. A long straight arrow shaft therefore +// will sometimes appear as if it has a blurred edge. + +// To mitigate this, these SVG files contain a second "brush-stroke" on the +// arrow shafts. That is, a second long thin rectangular SVG path has been +// written directly on top of each arrow shaft. This reinforcement causes +// some of the screen pixels to display as black instead of the anti-aliased +// gray pixel that a single path would generate. So we get arrow shafts +// whose edges appear to be sharper. +const doubleBrushStroke = (svgPath: string): string => `${svgPath} ${svgPath}`; + +const hLinePad = 80; // padding above a sqrt vinculum. Prevents image cropping. + +// The vinculum of a \sqrt can be made thicker by a KaTeX rendering option. +// Think of variable extraVinculum as two detours in the SVG path. +// The detour begins at the lower left of the area labeled extraVinculum below. +// The detour proceeds one extraVinculum distance up and slightly to the right, +// displacing the radiused corner between surd and vinculum. The radius is +// traversed as usual, then the detour resumes. It goes right, to the end of +// the very long vinculum, then down one extraVinculum distance, +// after which it resumes regular path geometry for the radical. +/* vinculum + / + /▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒←extraVinculum + / █████████████████████←0.04em (40 unit) std vinculum thickness + / / + / / + / /\ + / / surd +*/ + +const sqrtMain = function(extraVinculum: number, hLinePad: number): string { + // sqrtMain path geometry is from glyph U221A in the font KaTeX Main + return `M95,${622 + extraVinculum + hLinePad} +c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14 +c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54 +c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10 +s173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429 +c69,-144,104.5,-217.7,106.5,-221 +l${extraVinculum / 2.075} -${extraVinculum} +c5.3,-9.3,12,-14,20,-14 +H400000v${40 + extraVinculum}H845.2724 +s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7 +c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z +M${834 + extraVinculum} ${hLinePad}h400000v${40 + extraVinculum}h-400000z`; +}; + +const sqrtSize1 = function(extraVinculum: number, hLinePad: number): string { + // size1 is from glyph U221A in the font KaTeX_Size1-Regular + return `M263,${601 + extraVinculum + hLinePad}c0.7,0,18,39.7,52,119 +c34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120 +c340,-704.7,510.7,-1060.3,512,-1067 +l${extraVinculum / 2.084} -${extraVinculum} +c4.7,-7.3,11,-11,19,-11 +H40000v${40 + extraVinculum}H1012.3 +s-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232 +c-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1 +s-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26 +c-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z +M${1001 + extraVinculum} ${hLinePad}h400000v${40 + extraVinculum}h-400000z`; +}; + +const sqrtSize2 = function(extraVinculum: number, hLinePad: number): string { + // size2 is from glyph U221A in the font KaTeX_Size2-Regular + return `M983 ${10 + extraVinculum + hLinePad} +l${extraVinculum / 3.13} -${extraVinculum} +c4,-6.7,10,-10,18,-10 H400000v${40 + extraVinculum} +H1013.1s-83.4,268,-264.1,840c-180.7,572,-277,876.3,-289,913c-4.7,4.7,-12.7,7,-24,7 +s-12,0,-12,0c-1.3,-3.3,-3.7,-11.7,-7,-25c-35.3,-125.3,-106.7,-373.3,-214,-744 +c-10,12,-21,25,-33,39s-32,39,-32,39c-6,-5.3,-15,-14,-27,-26s25,-30,25,-30 +c26.7,-32.7,52,-63,76,-91s52,-60,52,-60s208,722,208,722 +c56,-175.3,126.3,-397.3,211,-666c84.7,-268.7,153.8,-488.2,207.5,-658.5 +c53.7,-170.3,84.5,-266.8,92.5,-289.5z +M${1001 + extraVinculum} ${hLinePad}h400000v${40 + extraVinculum}h-400000z`; +}; + +const sqrtSize3 = function(extraVinculum: number, hLinePad: number): string { + // size3 is from glyph U221A in the font KaTeX_Size3-Regular + return `M424,${2398 + extraVinculum + hLinePad} +c-1.3,-0.7,-38.5,-172,-111.5,-514c-73,-342,-109.8,-513.3,-110.5,-514 +c0,-2,-10.7,14.3,-32,49c-4.7,7.3,-9.8,15.7,-15.5,25c-5.7,9.3,-9.8,16,-12.5,20 +s-5,7,-5,7c-4,-3.3,-8.3,-7.7,-13,-13s-13,-13,-13,-13s76,-122,76,-122s77,-121,77,-121 +s209,968,209,968c0,-2,84.7,-361.7,254,-1079c169.3,-717.3,254.7,-1077.7,256,-1081 +l${extraVinculum / 4.223} -${extraVinculum}c4,-6.7,10,-10,18,-10 H400000 +v${40 + extraVinculum}H1014.6 +s-87.3,378.7,-272.6,1166c-185.3,787.3,-279.3,1182.3,-282,1185 +c-2,6,-10,9,-24,9 +c-8,0,-12,-0.7,-12,-2z M${1001 + extraVinculum} ${hLinePad} +h400000v${40 + extraVinculum}h-400000z`; +}; + +const sqrtSize4 = function(extraVinculum: number, hLinePad: number): string { + // size4 is from glyph U221A in the font KaTeX_Size4-Regular + return `M473,${2713 + extraVinculum + hLinePad} +c339.3,-1799.3,509.3,-2700,510,-2702 l${extraVinculum / 5.298} -${extraVinculum} +c3.3,-7.3,9.3,-11,18,-11 H400000v${40 + extraVinculum}H1017.7 +s-90.5,478,-276.2,1466c-185.7,988,-279.5,1483,-281.5,1485c-2,6,-10,9,-24,9 +c-8,0,-12,-0.7,-12,-2c0,-1.3,-5.3,-32,-16,-92c-50.7,-293.3,-119.7,-693.3,-207,-1200 +c0,-1.3,-5.3,8.7,-16,30c-10.7,21.3,-21.3,42.7,-32,64s-16,33,-16,33s-26,-26,-26,-26 +s76,-153,76,-153s77,-151,77,-151c0.7,0.7,35.7,202,105,604c67.3,400.7,102,602.7,104, +606zM${1001 + extraVinculum} ${hLinePad}h400000v${40 + extraVinculum}H1017.7z`; +}; + +export const phasePath = function(y: number): string { + const x = y / 2; // x coordinate at top of angle + return `M400000 ${y} H0 L${x} 0 l65 45 L145 ${y - 80} H400000z`; +}; + +const sqrtTall = function( + extraVinculum: number, + hLinePad: number, + viewBoxHeight: number +): string { + // sqrtTall is from glyph U23B7 in the font KaTeX_Size4-Regular + // One path edge has a variable length. It runs vertically from the vinculum + // to a point near (14 units) the bottom of the surd. The vinculum + // is normally 40 units thick. So the length of the line in question is: + const vertSegment = viewBoxHeight - 54 - hLinePad - extraVinculum; + + return `M702 ${extraVinculum + hLinePad}H400000${40 + extraVinculum} +H742v${vertSegment}l-4 4-4 4c-.667.7 -2 1.5-4 2.5s-4.167 1.833-6.5 2.5-5.5 1-9.5 1 +h-12l-28-84c-16.667-52-96.667 -294.333-240-727l-212 -643 -85 170 +c-4-3.333-8.333-7.667-13 -13l-13-13l77-155 77-156c66 199.333 139 419.667 +219 661 l218 661zM702 ${hLinePad}H400000v${40 + extraVinculum}H742z`; +}; + +export const sqrtPath = function( + size: string, + extraVinculum: number, + viewBoxHeight: number +): string { + extraVinculum = 1000 * extraVinculum; // Convert from document ems to viewBox. + let path = ""; + + switch (size) { + case "sqrtMain": + path = sqrtMain(extraVinculum, hLinePad); + break; + case "sqrtSize1": + path = sqrtSize1(extraVinculum, hLinePad); + break; + case "sqrtSize2": + path = sqrtSize2(extraVinculum, hLinePad); + break; + case "sqrtSize3": + path = sqrtSize3(extraVinculum, hLinePad); + break; + case "sqrtSize4": + path = sqrtSize4(extraVinculum, hLinePad); + break; + case "sqrtTall": + path = sqrtTall(extraVinculum, hLinePad, viewBoxHeight); + } + return path; +}; + +export const innerPath = function(name: string, height: number): string { + // The inner part of stretchy tall delimiters + switch (name) { + case "\u239c": + return doubleBrushStroke(`M291 0 H417 V${height} H291z`); + case "\u2223": + return doubleBrushStroke(`M145 0 H188 V${height} H145z`); + case "\u2225": + return doubleBrushStroke(`M145 0 H188 V${height} H145z`) + + doubleBrushStroke(`M367 0 H410 V${height} H367z`); + case "\u239f": + return doubleBrushStroke(`M457 0 H583 V${height} H457z`); + case "\u23a2": + return doubleBrushStroke(`M319 0 H403 V${height} H319z`); + case "\u23a5": + return doubleBrushStroke(`M263 0 H347 V${height} H263z`); + case "\u23aa": + return doubleBrushStroke(`M384 0 H504 V${height} H384z`); + case "\u23d0": + return doubleBrushStroke(`M312 0 H355 V${height} H312z`); + case "\u2016": + return doubleBrushStroke(`M257 0 H300 V${height} H257z`) + + doubleBrushStroke(`M478 0 H521 V${height} H478z`); + default: + return ""; + } +}; + +export const path: Record = { + // The doubleleftarrow geometry is from glyph U+21D0 in the font KaTeX Main + doubleleftarrow: `M262 157 +l10-10c34-36 62.7-77 86-123 3.3-8 5-13.3 5-16 0-5.3-6.7-8-20-8-7.3 + 0-12.2.5-14.5 1.5-2.3 1-4.8 4.5-7.5 10.5-49.3 97.3-121.7 169.3-217 216-28 + 14-57.3 25-88 33-6.7 2-11 3.8-13 5.5-2 1.7-3 4.2-3 7.5s1 5.8 3 7.5 +c2 1.7 6.3 3.5 13 5.5 68 17.3 128.2 47.8 180.5 91.5 52.3 43.7 93.8 96.2 124.5 + 157.5 9.3 8 15.3 12.3 18 13h6c12-.7 18-4 18-10 0-2-1.7-7-5-15-23.3-46-52-87 +-86-123l-10-10h399738v-40H218c328 0 0 0 0 0l-10-8c-26.7-20-65.7-43-117-69 2.7 +-2 6-3.7 10-5 36.7-16 72.3-37.3 107-64l10-8h399782v-40z +m8 0v40h399730v-40zm0 194v40h399730v-40z`, + + // doublerightarrow is from glyph U+21D2 in font KaTeX Main + doublerightarrow: `M399738 392l +-10 10c-34 36-62.7 77-86 123-3.3 8-5 13.3-5 16 0 5.3 6.7 8 20 8 7.3 0 12.2-.5 + 14.5-1.5 2.3-1 4.8-4.5 7.5-10.5 49.3-97.3 121.7-169.3 217-216 28-14 57.3-25 88 +-33 6.7-2 11-3.8 13-5.5 2-1.7 3-4.2 3-7.5s-1-5.8-3-7.5c-2-1.7-6.3-3.5-13-5.5-68 +-17.3-128.2-47.8-180.5-91.5-52.3-43.7-93.8-96.2-124.5-157.5-9.3-8-15.3-12.3-18 +-13h-6c-12 .7-18 4-18 10 0 2 1.7 7 5 15 23.3 46 52 87 86 123l10 10H0v40h399782 +c-328 0 0 0 0 0l10 8c26.7 20 65.7 43 117 69-2.7 2-6 3.7-10 5-36.7 16-72.3 37.3 +-107 64l-10 8H0v40zM0 157v40h399730v-40zm0 194v40h399730v-40z`, + + // leftarrow is from glyph U+2190 in font KaTeX Main + leftarrow: `M400000 241H110l3-3c68.7-52.7 113.7-120 + 135-202 4-14.7 6-23 6-25 0-7.3-7-11-21-11-8 0-13.2.8-15.5 2.5-2.3 1.7-4.2 5.8 +-5.5 12.5-1.3 4.7-2.7 10.3-4 17-12 48.7-34.8 92-68.5 130S65.3 228.3 18 247 +c-10 4-16 7.7-18 11 0 8.7 6 14.3 18 17 47.3 18.7 87.8 47 121.5 85S196 441.3 208 + 490c.7 2 1.3 5 2 9s1.2 6.7 1.5 8c.3 1.3 1 3.3 2 6s2.2 4.5 3.5 5.5c1.3 1 3.3 + 1.8 6 2.5s6 1 10 1c14 0 21-3.7 21-11 0-2-2-10.3-6-25-20-79.3-65-146.7-135-202 + l-3-3h399890zM100 241v40h399900v-40z`, + + // overbrace is from glyphs U+23A9/23A8/23A7 in font KaTeX_Size4-Regular + leftbrace: `M6 548l-6-6v-35l6-11c56-104 135.3-181.3 238-232 57.3-28.7 117 +-45 179-50h399577v120H403c-43.3 7-81 15-113 26-100.7 33-179.7 91-237 174-2.7 + 5-6 9-10 13-.7 1-7.3 1-20 1H6z`, + + leftbraceunder: `M0 6l6-6h17c12.688 0 19.313.3 20 1 4 4 7.313 8.3 10 13 + 35.313 51.3 80.813 93.8 136.5 127.5 55.688 33.7 117.188 55.8 184.5 66.5.688 + 0 2 .3 4 1 18.688 2.7 76 4.3 172 5h399450v120H429l-6-1c-124.688-8-235-61.7 +-331-161C60.687 138.7 32.312 99.3 7 54L0 41V6z`, + + // overgroup is from the MnSymbol package (public domain) + leftgroup: `M400000 80 +H435C64 80 168.3 229.4 21 260c-5.9 1.2-18 0-18 0-2 0-3-1-3-3v-38C76 61 257 0 + 435 0h399565z`, + + leftgroupunder: `M400000 262 +H435C64 262 168.3 112.6 21 82c-5.9-1.2-18 0-18 0-2 0-3 1-3 3v38c76 158 257 219 + 435 219h399565z`, + + // Harpoons are from glyph U+21BD in font KaTeX Main + leftharpoon: `M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3 +-3.3 10.2-9.5 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5 +-18.3 3-21-1.3-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7 +-196 228-6.7 4.7-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40z`, + + leftharpoonplus: `M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3-3.3 10.2-9.5 + 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5-18.3 3-21-1.3 +-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7-196 228-6.7 4.7 +-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40zM0 435v40h400000v-40z +m0 0v40h400000v-40z`, + + leftharpoondown: `M7 241c-4 4-6.333 8.667-7 14 0 5.333.667 9 2 11s5.333 + 5.333 12 10c90.667 54 156 130 196 228 3.333 10.667 6.333 16.333 9 17 2 .667 5 + 1 9 1h5c10.667 0 16.667-2 18-6 2-2.667 1-9.667-3-21-32-87.333-82.667-157.667 +-152-211l-3-3h399907v-40zM93 281 H400000 v-40L7 241z`, + + leftharpoondownplus: `M7 435c-4 4-6.3 8.7-7 14 0 5.3.7 9 2 11s5.3 5.3 12 + 10c90.7 54 156 130 196 228 3.3 10.7 6.3 16.3 9 17 2 .7 5 1 9 1h5c10.7 0 16.7 +-2 18-6 2-2.7 1-9.7-3-21-32-87.3-82.7-157.7-152-211l-3-3h399907v-40H7zm93 0 +v40h399900v-40zM0 241v40h399900v-40zm0 0v40h399900v-40z`, + + // hook is from glyph U+21A9 in font KaTeX Main + lefthook: `M400000 281 H103s-33-11.2-61-33.5S0 197.3 0 164s14.2-61.2 42.5 +-83.5C70.8 58.2 104 47 142 47 c16.7 0 25 6.7 25 20 0 12-8.7 18.7-26 20-40 3.3 +-68.7 15.7-86 37-10 12-15 25.3-15 40 0 22.7 9.8 40.7 29.5 54 19.7 13.3 43.5 21 + 71.5 23h399859zM103 281v-40h399897v40z`, + + leftlinesegment: doubleBrushStroke(`M40 281 V428 H0 V94 H40 V241 H400000 v40z`), + + leftbracketunder: doubleBrushStroke(`M0 0 h120 V290 H399995 v120 H0z`), + + leftbracketover: doubleBrushStroke(`M0 440 h120 V150 H399995 v-120 H0z`), + + leftmapsto: doubleBrushStroke(`M40 281 V448H0V74H40V241H400000v40z`), + + // tofrom is from glyph U+21C4 in font KaTeX AMS Regular + leftToFrom: `M0 147h400000v40H0zm0 214c68 40 115.7 95.7 143 167h22c15.3 0 23 +-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69-70-101l-7-8h399905v-40H95l7-8 +c28.7-32 52-65.7 70-101 10.7-23.3 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 265.3 + 68 321 0 361zm0-174v-40h399900v40zm100 154v40h399900v-40z`, + + longequal: doubleBrushStroke(`M0 50 h400000 v40H0z m0 194h40000v40H0z`), + + midbrace: `M200428 334 +c-100.7-8.3-195.3-44-280-108-55.3-42-101.7-93-139-153l-9-14c-2.7 4-5.7 8.7-9 14 +-53.3 86.7-123.7 153-211 199-66.7 36-137.3 56.3-212 62H0V214h199568c178.3-11.7 + 311.7-78.3 403-201 6-8 9.7-12 11-12 .7-.7 6.7-1 18-1s17.3.3 18 1c1.3 0 5 4 11 + 12 44.7 59.3 101.3 106.3 170 141s145.3 54.3 229 60h199572v120z`, + + midbraceunder: `M199572 214 +c100.7 8.3 195.3 44 280 108 55.3 42 101.7 93 139 153l9 14c2.7-4 5.7-8.7 9-14 + 53.3-86.7 123.7-153 211-199 66.7-36 137.3-56.3 212-62h199568v120H200432c-178.3 + 11.7-311.7 78.3-403 201-6 8-9.7 12-11 12-.7.7-6.7 1-18 1s-17.3-.3-18-1c-1.3 0 +-5-4-11-12-44.7-59.3-101.3-106.3-170-141s-145.3-54.3-229-60H0V214z`, + + oiintSize1: `M512.6 71.6c272.6 0 320.3 106.8 320.3 178.2 0 70.8-47.7 177.6 +-320.3 177.6S193.1 320.6 193.1 249.8c0-71.4 46.9-178.2 319.5-178.2z +m368.1 178.2c0-86.4-60.9-215.4-368.1-215.4-306.4 0-367.3 129-367.3 215.4 0 85.8 +60.9 214.8 367.3 214.8 307.2 0 368.1-129 368.1-214.8z`, + + oiintSize2: `M757.8 100.1c384.7 0 451.1 137.6 451.1 230 0 91.3-66.4 228.8 +-451.1 228.8-386.3 0-452.7-137.5-452.7-228.8 0-92.4 66.4-230 452.7-230z +m502.4 230c0-111.2-82.4-277.2-502.4-277.2s-504 166-504 277.2 +c0 110 84 276 504 276s502.4-166 502.4-276z`, + + oiiintSize1: `M681.4 71.6c408.9 0 480.5 106.8 480.5 178.2 0 70.8-71.6 177.6 +-480.5 177.6S202.1 320.6 202.1 249.8c0-71.4 70.5-178.2 479.3-178.2z +m525.8 178.2c0-86.4-86.8-215.4-525.7-215.4-437.9 0-524.7 129-524.7 215.4 0 +85.8 86.8 214.8 524.7 214.8 438.9 0 525.7-129 525.7-214.8z`, + + oiiintSize2: `M1021.2 53c603.6 0 707.8 165.8 707.8 277.2 0 110-104.2 275.8 +-707.8 275.8-606 0-710.2-165.8-710.2-275.8C311 218.8 415.2 53 1021.2 53z +m770.4 277.1c0-131.2-126.4-327.6-770.5-327.6S248.4 198.9 248.4 330.1 +c0 130 128.8 326.4 772.7 326.4s770.5-196.4 770.5-326.4z`, + + rightarrow: `M0 241v40h399891c-47.3 35.3-84 78-110 128 +-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20 + 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7 + 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85 +-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5 +-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67 + 151.7 139 205zm0 0v40h399900v-40z`, + + rightbrace: `M400000 542l +-6 6h-17c-12.7 0-19.3-.3-20-1-4-4-7.3-8.3-10-13-35.3-51.3-80.8-93.8-136.5-127.5 +s-117.2-55.8-184.5-66.5c-.7 0-2-.3-4-1-18.7-2.7-76-4.3-172-5H0V214h399571l6 1 +c124.7 8 235 61.7 331 161 31.3 33.3 59.7 72.7 85 118l7 13v35z`, + + rightbraceunder: `M399994 0l6 6v35l-6 11c-56 104-135.3 181.3-238 232-57.3 + 28.7-117 45-179 50H-300V214h399897c43.3-7 81-15 113-26 100.7-33 179.7-91 237 +-174 2.7-5 6-9 10-13 .7-1 7.3-1 20-1h17z`, + + rightgroup: `M0 80h399565c371 0 266.7 149.4 414 180 5.9 1.2 18 0 18 0 2 0 + 3-1 3-3v-38c-76-158-257-219-435-219H0z`, + + rightgroupunder: `M0 262h399565c371 0 266.7-149.4 414-180 5.9-1.2 18 0 18 + 0 2 0 3 1 3 3v38c-76 158-257 219-435 219H0z`, + + rightharpoon: `M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3 +-3.7-15.3-11-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2 +-10.7 0-16.7 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58 + 69.2 92 94.5zm0 0v40h399900v-40z`, + + rightharpoonplus: `M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3-3.7-15.3-11 +-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2-10.7 0-16.7 + 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58 69.2 92 94.5z +m0 0v40h399900v-40z m100 194v40h399900v-40zm0 0v40h399900v-40z`, + + rightharpoondown: `M399747 511c0 7.3 6.7 11 20 11 8 0 13-.8 15-2.5s4.7-6.8 + 8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3 8.5-5.8 9.5 +-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3-64.7 57-92 95 +-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 241v40h399900v-40z`, + + rightharpoondownplus: `M399747 705c0 7.3 6.7 11 20 11 8 0 13-.8 + 15-2.5s4.7-6.8 8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3 + 8.5-5.8 9.5-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3 +-64.7 57-92 95-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 435v40h399900v-40z +m0-194v40h400000v-40zm0 0v40h400000v-40z`, + + righthook: `M399859 241c-764 0 0 0 0 0 40-3.3 68.7-15.7 86-37 10-12 15-25.3 + 15-40 0-22.7-9.8-40.7-29.5-54-19.7-13.3-43.5-21-71.5-23-17.3-1.3-26-8-26-20 0 +-13.3 8.7-20 26-20 38 0 71 11.2 99 33.5 0 0 7 5.6 21 16.7 14 11.2 21 33.5 21 + 66.8s-14 61.2-42 83.5c-28 22.3-61 33.5-99 33.5L0 241z M0 281v-40h399859v40z`, + + rightlinesegment: doubleBrushStroke(`M399960 241 V94 h40 V428 h-40 V281 H0 v-40z`), + + rightbracketunder: doubleBrushStroke(`M399995 0 h-120 V290 H0 v120 H400000z`), + + rightbracketover: doubleBrushStroke(`M399995 440 h-120 V150 H0 v-120 H399995z`), + + rightToFrom: `M400000 167c-70.7-42-118-97.7-142-167h-23c-15.3 0-23 .3-23 + 1 0 1.3 5.3 13.7 16 37 18 35.3 41.3 69 70 101l7 8H0v40h399905l-7 8c-28.7 32 +-52 65.7-70 101-10.7 23.3-16 35.7-16 37 0 .7 7.7 1 23 1h23c24-69.3 71.3-125 142 +-167z M100 147v40h399900v-40zM0 341v40h399900v-40z`, + + // twoheadleftarrow is from glyph U+219E in font KaTeX AMS Regular + twoheadleftarrow: `M0 167c68 40 + 115.7 95.7 143 167h22c15.3 0 23-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69 +-70-101l-7-8h125l9 7c50.7 39.3 85 86 103 140h46c0-4.7-6.3-18.7-19-42-18-35.3 +-40-67.3-66-96l-9-9h399716v-40H284l9-9c26-28.7 48-60.7 66-96 12.7-23.333 19 +-37.333 19-42h-46c-18 54-52.3 100.7-103 140l-9 7H95l7-8c28.7-32 52-65.7 70-101 + 10.7-23.333 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 71.3 68 127 0 167z`, + + twoheadrightarrow: `M400000 167 +c-68-40-115.7-95.7-143-167h-22c-15.3 0-23 .3-23 1 0 1.3 5.3 13.7 16 37 18 35.3 + 41.3 69 70 101l7 8h-125l-9-7c-50.7-39.3-85-86-103-140h-46c0 4.7 6.3 18.7 19 42 + 18 35.3 40 67.3 66 96l9 9H0v40h399716l-9 9c-26 28.7-48 60.7-66 96-12.7 23.333 +-19 37.333-19 42h46c18-54 52.3-100.7 103-140l9-7h125l-7 8c-28.7 32-52 65.7-70 + 101-10.7 23.333-16 35.7-16 37 0 .7 7.7 1 23 1h22c27.3-71.3 75-127 143-167z`, + + // tilde1 is a modified version of a glyph from the MnSymbol package + tilde1: `M200 55.538c-77 0-168 73.953-177 73.953-3 0-7 +-2.175-9-5.437L2 97c-1-2-2-4-2-6 0-4 2-7 5-9l20-12C116 12 171 0 207 0c86 0 + 114 68 191 68 78 0 168-68 177-68 4 0 7 2 9 5l12 19c1 2.175 2 4.35 2 6.525 0 + 4.35-2 7.613-5 9.788l-19 13.05c-92 63.077-116.937 75.308-183 76.128 +-68.267.847-113-73.952-191-73.952z`, + + // ditto tilde2, tilde3, & tilde4 + tilde2: `M344 55.266c-142 0-300.638 81.316-311.5 86.418 +-8.01 3.762-22.5 10.91-23.5 5.562L1 120c-1-2-1-3-1-4 0-5 3-9 8-10l18.4-9C160.9 + 31.9 283 0 358 0c148 0 188 122 331 122s314-97 326-97c4 0 8 2 10 7l7 21.114 +c1 2.14 1 3.21 1 4.28 0 5.347-3 9.626-7 10.696l-22.3 12.622C852.6 158.372 751 + 181.476 676 181.476c-149 0-189-126.21-332-126.21z`, + + tilde3: `M786 59C457 59 32 175.242 13 175.242c-6 0-10-3.457 +-11-10.37L.15 138c-1-7 3-12 10-13l19.2-6.4C378.4 40.7 634.3 0 804.3 0c337 0 + 411.8 157 746.8 157 328 0 754-112 773-112 5 0 10 3 11 9l1 14.075c1 8.066-.697 + 16.595-6.697 17.492l-21.052 7.31c-367.9 98.146-609.15 122.696-778.15 122.696 + -338 0-409-156.573-744-156.573z`, + + tilde4: `M786 58C457 58 32 177.487 13 177.487c-6 0-10-3.345 +-11-10.035L.15 143c-1-7 3-12 10-13l22-6.7C381.2 35 637.15 0 807.15 0c337 0 409 + 177 744 177 328 0 754-127 773-127 5 0 10 3 11 9l1 14.794c1 7.805-3 13.38-9 + 14.495l-20.7 5.574c-366.85 99.79-607.3 139.372-776.3 139.372-338 0-409 + -175.236-744-175.236z`, + + // vec is from glyph U+20D7 in font KaTeX Main + vec: `M377 20c0-5.333 1.833-10 5.5-14S391 0 397 0c4.667 0 8.667 1.667 12 5 +3.333 2.667 6.667 9 10 19 6.667 24.667 20.333 43.667 41 57 7.333 4.667 11 +10.667 11 18 0 6-1 10-3 12s-6.667 5-14 9c-28.667 14.667-53.667 35.667-75 63 +-1.333 1.333-3.167 3.5-5.5 6.5s-4 4.833-5 5.5c-1 .667-2.5 1.333-4.5 2s-4.333 1 +-7 1c-4.667 0-9.167-1.833-13.5-5.5S337 184 337 178c0-12.667 15.667-32.333 47-59 +H213l-171-1c-8.667-6-13-12.333-13-19 0-4.667 4.333-11.333 13-20h359 +c-16-25.333-24-45-24-59z`, + + // widehat1 is a modified version of a glyph from the MnSymbol package + widehat1: `M529 0h5l519 115c5 1 9 5 9 10 0 1-1 2-1 3l-4 22 +c-1 5-5 9-11 9h-2L532 67 19 159h-2c-5 0-9-4-11-9l-5-22c-1-6 2-12 8-13z`, + + // ditto widehat2, widehat3, & widehat4 + widehat2: `M1181 0h2l1171 176c6 0 10 5 10 11l-2 23c-1 6-5 10 +-11 10h-1L1182 67 15 220h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z`, + + widehat3: `M1181 0h2l1171 236c6 0 10 5 10 11l-2 23c-1 6-5 10 +-11 10h-1L1182 67 15 280h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z`, + + widehat4: `M1181 0h2l1171 296c6 0 10 5 10 11l-2 23c-1 6-5 10 +-11 10h-1L1182 67 15 340h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z`, + + // widecheck paths are all inverted versions of widehat + widecheck1: `M529,159h5l519,-115c5,-1,9,-5,9,-10c0,-1,-1,-2,-1,-3l-4,-22c-1, +-5,-5,-9,-11,-9h-2l-512,92l-513,-92h-2c-5,0,-9,4,-11,9l-5,22c-1,6,2,12,8,13z`, + + widecheck2: `M1181,220h2l1171,-176c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10, +-11,-10h-1l-1168,153l-1167,-153h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z`, + + widecheck3: `M1181,280h2l1171,-236c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10, +-11,-10h-1l-1168,213l-1167,-213h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z`, + + widecheck4: `M1181,340h2l1171,-296c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10, +-11,-10h-1l-1168,273l-1167,-273h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z`, + + // The next ten paths support reaction arrows from the mhchem package. + + // Arrows for \ce{<-->} are offset from xAxis by 0.22ex, per mhchem in LaTeX + // baraboveleftarrow is mostly from glyph U+2190 in font KaTeX Main + baraboveleftarrow: `M400000 620h-399890l3 -3c68.7 -52.7 113.7 -120 135 -202 +c4 -14.7 6 -23 6 -25c0 -7.3 -7 -11 -21 -11c-8 0 -13.2 0.8 -15.5 2.5 +c-2.3 1.7 -4.2 5.8 -5.5 12.5c-1.3 4.7 -2.7 10.3 -4 17c-12 48.7 -34.8 92 -68.5 130 +s-74.2 66.3 -121.5 85c-10 4 -16 7.7 -18 11c0 8.7 6 14.3 18 17c47.3 18.7 87.8 47 +121.5 85s56.5 81.3 68.5 130c0.7 2 1.3 5 2 9s1.2 6.7 1.5 8c0.3 1.3 1 3.3 2 6 +s2.2 4.5 3.5 5.5c1.3 1 3.3 1.8 6 2.5s6 1 10 1c14 0 21 -3.7 21 -11 +c0 -2 -2 -10.3 -6 -25c-20 -79.3 -65 -146.7 -135 -202l-3 -3h399890z +M100 620v40h399900v-40z M0 241v40h399900v-40zM0 241v40h399900v-40z`, + + // rightarrowabovebar is mostly from glyph U+2192, KaTeX Main + rightarrowabovebar: `M0 241v40h399891c-47.3 35.3-84 78-110 128-16.7 32 +-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20 11 8 0 +13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7 39 +-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85-40.5 +-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5 +-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67 +151.7 139 205zm96 379h399894v40H0zm0 0h399904v40H0z`, + + // The short left harpoon has 0.5em (i.e. 500 units) kern on the left end. + // Ref from mhchem.sty: \rlap{\raisebox{-.22ex}{$\kern0.5em + baraboveshortleftharpoon: `M507,435c-4,4,-6.3,8.7,-7,14c0,5.3,0.7,9,2,11 +c1.3,2,5.3,5.3,12,10c90.7,54,156,130,196,228c3.3,10.7,6.3,16.3,9,17 +c2,0.7,5,1,9,1c0,0,5,0,5,0c10.7,0,16.7,-2,18,-6c2,-2.7,1,-9.7,-3,-21 +c-32,-87.3,-82.7,-157.7,-152,-211c0,0,-3,-3,-3,-3l399351,0l0,-40 +c-398570,0,-399437,0,-399437,0z M593 435 v40 H399500 v-40z +M0 281 v-40 H399908 v40z M0 281 v-40 H399908 v40z`, + + rightharpoonaboveshortbar: `M0,241 l0,40c399126,0,399993,0,399993,0 +c4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199, +-231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6 +c-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z +M0 241 v40 H399908 v-40z M0 475 v-40 H399500 v40z M0 475 v-40 H399500 v40z`, + + shortbaraboveleftharpoon: `M7,435c-4,4,-6.3,8.7,-7,14c0,5.3,0.7,9,2,11 +c1.3,2,5.3,5.3,12,10c90.7,54,156,130,196,228c3.3,10.7,6.3,16.3,9,17c2,0.7,5,1,9, +1c0,0,5,0,5,0c10.7,0,16.7,-2,18,-6c2,-2.7,1,-9.7,-3,-21c-32,-87.3,-82.7,-157.7, +-152,-211c0,0,-3,-3,-3,-3l399907,0l0,-40c-399126,0,-399993,0,-399993,0z +M93 435 v40 H400000 v-40z M500 241 v40 H400000 v-40z M500 241 v40 H400000 v-40z`, + + shortrightharpoonabovebar: `M53,241l0,40c398570,0,399437,0,399437,0 +c4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199, +-231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6 +c-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z +M500 241 v40 H399408 v-40z M500 435 v40 H400000 v-40z`, +}; + +export const tallDelim = function(label: string, midHeight: number): string { + switch (label) { + case "lbrack": + return `M403 1759 V84 H666 V0 H319 V1759 v${midHeight} v1759 v84 h347 v-84 +H403z M403 1759 V0 H319 V1759 v${midHeight} v1759 v84 h84z`; + case "rbrack": + return `M347 1759 V0 H0 V84 H263 V1759 v${midHeight} v1759 H0 v84 H347z +M347 1759 V0 H263 V1759 v${midHeight} v1759 h84z`; + case "vert": + return `M145 15 v585 v${midHeight} v585 c2.667,10,9.667,15,21,15 +c10,0,16.667,-5,20,-15 v-585 v${-midHeight} v-585 c-2.667,-10,-9.667,-15,-21,-15 +c-10,0,-16.667,5,-20,15z M188 15 H145 v585 v${midHeight} v585 h43z`; + case "doublevert": + return `M145 15 v585 v${midHeight} v585 c2.667,10,9.667,15,21,15 +c10,0,16.667,-5,20,-15 v-585 v${-midHeight} v-585 c-2.667,-10,-9.667,-15,-21,-15 +c-10,0,-16.667,5,-20,15z M188 15 H145 v585 v${midHeight} v585 h43z +M367 15 v585 v${midHeight} v585 c2.667,10,9.667,15,21,15 +c10,0,16.667,-5,20,-15 v-585 v${-midHeight} v-585 c-2.667,-10,-9.667,-15,-21,-15 +c-10,0,-16.667,5,-20,15z M410 15 H367 v585 v${midHeight} v585 h43z`; + case "lfloor": + return `M319 602 V0 H403 V602 v${midHeight} v1715 h263 v84 H319z +MM319 602 V0 H403 V602 v${midHeight} v1715 H319z`; + case "rfloor": + return `M319 602 V0 H403 V602 v${midHeight} v1799 H0 v-84 H319z +MM319 602 V0 H403 V602 v${midHeight} v1715 H319z`; + case "lceil": + return `M403 1759 V84 H666 V0 H319 V1759 v${midHeight} v602 h84z +M403 1759 V0 H319 V1759 v${midHeight} v602 h84z`; + case "rceil": + return `M347 1759 V0 H0 V84 H263 V1759 v${midHeight} v602 h84z +M347 1759 V0 h-84 V1759 v${midHeight} v602 h84z`; + case "lparen": + return `M863,9c0,-2,-2,-5,-6,-9c0,0,-17,0,-17,0c-12.7,0,-19.3,0.3,-20,1 +c-5.3,5.3,-10.3,11,-15,17c-242.7,294.7,-395.3,682,-458,1162c-21.3,163.3,-33.3,349, +-36,557 l0,${midHeight + 84}c0.2,6,0,26,0,60c2,159.3,10,310.7,24,454c53.3,528,210, +949.7,470,1265c4.7,6,9.7,11.7,15,17c0.7,0.7,7,1,19,1c0,0,18,0,18,0c4,-4,6,-7,6,-9 +c0,-2.7,-3.3,-8.7,-10,-18c-135.3,-192.7,-235.5,-414.3,-300.5,-665c-65,-250.7,-102.5, +-544.7,-112.5,-882c-2,-104,-3,-167,-3,-189 +l0,-${midHeight + 92}c0,-162.7,5.7,-314,17,-454c20.7,-272,63.7,-513,129,-723c65.3, +-210,155.3,-396.3,270,-559c6.7,-9.3,10,-15.3,10,-18z`; + case "rparen": + return `M76,0c-16.7,0,-25,3,-25,9c0,2,2,6.3,6,13c21.3,28.7,42.3,60.3, +63,95c96.7,156.7,172.8,332.5,228.5,527.5c55.7,195,92.8,416.5,111.5,664.5 +c11.3,139.3,17,290.7,17,454c0,28,1.7,43,3.3,45l0,${midHeight + 9} +c-3,4,-3.3,16.7,-3.3,38c0,162,-5.7,313.7,-17,455c-18.7,248,-55.8,469.3,-111.5,664 +c-55.7,194.7,-131.8,370.3,-228.5,527c-20.7,34.7,-41.7,66.3,-63,95c-2,3.3,-4,7,-6,11 +c0,7.3,5.7,11,17,11c0,0,11,0,11,0c9.3,0,14.3,-0.3,15,-1c5.3,-5.3,10.3,-11,15,-17 +c242.7,-294.7,395.3,-681.7,458,-1161c21.3,-164.7,33.3,-350.7,36,-558 +l0,-${midHeight + 144}c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7, +-470,-1265c-4.7,-6,-9.7,-11.7,-15,-17c-0.7,-0.7,-6.7,-1,-18,-1z`; + default: + // We should not ever get here. + throw new Error("Unknown stretchy delimiter."); + } +}; diff --git a/node_modules/katex/src/symbols.ts b/node_modules/katex/src/symbols.ts new file mode 100644 index 0000000..d6a02c2 --- /dev/null +++ b/node_modules/katex/src/symbols.ts @@ -0,0 +1,879 @@ +/** + * This file holds a list of all no-argument functions and single-character + * symbols (like 'a' or ';'). + * + * For each of the symbols, there are three properties they can have: + * - font (required): the font to be used for this symbol. Either "main" (the + normal font), or "ams" (the ams fonts). + * - group (required): the ParseNode group type the symbol should have (i.e. + "textord", "mathord", etc). + See https://github.com/KaTeX/KaTeX/wiki/Examining-TeX#group-types + * - replace: the character that this symbol or function should be + * replaced with (i.e. "\phi" has a replace value of "\u03d5", the phi + * character in the main font). + * + * The outermost map in the table indicates what mode the symbols should be + * accepted in (e.g. "math" or "text"). + */ + +import type {Group} from "./atoms"; +import type {Mode} from "./types"; +import type {SymbolFont} from "./types/fonts"; + +// Some of these have a "-token" suffix since these are also used as `ParseNode` +// types for raw text tokens, and we want to avoid conflicts with higher-level +// `ParseNode` types. These `ParseNode`s are constructed within `Parser` by +// looking up the `symbols` map. + +type CharInfoMap = Record< + string, + {font: SymbolFont; group: Group; replace: string | null | undefined} +>; + +const symbols: Record = { + "math": {}, + "text": {}, +}; +export default symbols; + +/** `acceptUnicodeChar = true` is only applicable if `replace` is set. */ +export function defineSymbol( + mode: Mode, + font: SymbolFont, + group: Group, + replace: string, + name: string, + acceptUnicodeChar?: boolean, +) { + symbols[mode][name] = {font, group, replace}; + + if (acceptUnicodeChar && replace) { + symbols[mode][replace] = symbols[mode][name]; + } +} + +// Some abbreviations for commonly used strings. +// This helps minify the code, and also spotting typos using jshint. + +// modes: +const math = "math"; +const text = "text"; + +// fonts: +const main = "main"; +const ams = "ams"; + +// groups: +const accent = "accent-token"; +const bin = "bin"; +const close = "close"; +const inner = "inner"; +const mathord = "mathord"; +const op = "op-token"; +const open = "open"; +const punct = "punct"; +const rel = "rel"; +const spacing = "spacing"; +const textord = "textord"; + +// Now comes the symbol table + +// Relation Symbols +defineSymbol(math, main, rel, "\u2261", "\\equiv", true); +defineSymbol(math, main, rel, "\u227a", "\\prec", true); +defineSymbol(math, main, rel, "\u227b", "\\succ", true); +defineSymbol(math, main, rel, "\u223c", "\\sim", true); +defineSymbol(math, main, rel, "\u22a5", "\\perp"); +defineSymbol(math, main, rel, "\u2aaf", "\\preceq", true); +defineSymbol(math, main, rel, "\u2ab0", "\\succeq", true); +defineSymbol(math, main, rel, "\u2243", "\\simeq", true); +defineSymbol(math, main, rel, "\u2223", "\\mid", true); +defineSymbol(math, main, rel, "\u226a", "\\ll", true); +defineSymbol(math, main, rel, "\u226b", "\\gg", true); +defineSymbol(math, main, rel, "\u224d", "\\asymp", true); +defineSymbol(math, main, rel, "\u2225", "\\parallel"); +defineSymbol(math, main, rel, "\u22c8", "\\bowtie", true); +defineSymbol(math, main, rel, "\u2323", "\\smile", true); +defineSymbol(math, main, rel, "\u2291", "\\sqsubseteq", true); +defineSymbol(math, main, rel, "\u2292", "\\sqsupseteq", true); +defineSymbol(math, main, rel, "\u2250", "\\doteq", true); +defineSymbol(math, main, rel, "\u2322", "\\frown", true); +defineSymbol(math, main, rel, "\u220b", "\\ni", true); +defineSymbol(math, main, rel, "\u221d", "\\propto", true); +defineSymbol(math, main, rel, "\u22a2", "\\vdash", true); +defineSymbol(math, main, rel, "\u22a3", "\\dashv", true); +defineSymbol(math, main, rel, "\u220b", "\\owns"); + +// Punctuation +defineSymbol(math, main, punct, "\u002e", "\\ldotp"); +defineSymbol(math, main, punct, "\u22c5", "\\cdotp"); +// The KaTeX fonts do not contain U+00B7. Use the centered dot glyph at U+22C5 +// in both modes, but keep math-mode punctuation spacing only in math mode. +defineSymbol(math, main, punct, "\u22c5", "\u00b7"); +defineSymbol(text, main, textord, "\u22c5", "\u00b7"); + +// Misc Symbols +defineSymbol(math, main, textord, "\u0023", "\\#"); +defineSymbol(text, main, textord, "\u0023", "\\#"); +defineSymbol(math, main, textord, "\u0026", "\\&"); +defineSymbol(text, main, textord, "\u0026", "\\&"); +defineSymbol(math, main, textord, "\u2135", "\\aleph", true); +defineSymbol(math, main, textord, "\u2200", "\\forall", true); +defineSymbol(math, main, textord, "\u210f", "\\hbar", true); +defineSymbol(math, main, textord, "\u2203", "\\exists", true); +defineSymbol(math, main, textord, "\u2207", "\\nabla", true); +defineSymbol(math, main, textord, "\u266d", "\\flat", true); +defineSymbol(math, main, textord, "\u2113", "\\ell", true); +defineSymbol(math, main, textord, "\u266e", "\\natural", true); +defineSymbol(math, main, textord, "\u2663", "\\clubsuit", true); +defineSymbol(math, main, textord, "\u2118", "\\wp", true); +defineSymbol(math, main, textord, "\u266f", "\\sharp", true); +defineSymbol(math, main, textord, "\u2662", "\\diamondsuit", true); +defineSymbol(math, main, textord, "\u211c", "\\Re", true); +defineSymbol(math, main, textord, "\u2661", "\\heartsuit", true); +defineSymbol(math, main, textord, "\u2111", "\\Im", true); +defineSymbol(math, main, textord, "\u2660", "\\spadesuit", true); +defineSymbol(math, main, textord, "\u00a7", "\\S", true); +defineSymbol(text, main, textord, "\u00a7", "\\S"); +defineSymbol(math, main, textord, "\u00b6", "\\P", true); +defineSymbol(text, main, textord, "\u00b6", "\\P"); + +// Math and Text +defineSymbol(math, main, textord, "\u2020", "\\dag"); +defineSymbol(text, main, textord, "\u2020", "\\dag"); +defineSymbol(text, main, textord, "\u2020", "\\textdagger"); +defineSymbol(math, main, textord, "\u2021", "\\ddag"); +defineSymbol(text, main, textord, "\u2021", "\\ddag"); +defineSymbol(text, main, textord, "\u2021", "\\textdaggerdbl"); + +// Large Delimiters +defineSymbol(math, main, close, "\u23b1", "\\rmoustache", true); +defineSymbol(math, main, open, "\u23b0", "\\lmoustache", true); +defineSymbol(math, main, close, "\u27ef", "\\rgroup", true); +defineSymbol(math, main, open, "\u27ee", "\\lgroup", true); + +// Binary Operators +defineSymbol(math, main, bin, "\u2213", "\\mp", true); +defineSymbol(math, main, bin, "\u2296", "\\ominus", true); +defineSymbol(math, main, bin, "\u228e", "\\uplus", true); +defineSymbol(math, main, bin, "\u2293", "\\sqcap", true); +defineSymbol(math, main, bin, "\u2217", "\\ast"); +defineSymbol(math, main, bin, "\u2294", "\\sqcup", true); +defineSymbol(math, main, bin, "\u25ef", "\\bigcirc", true); +defineSymbol(math, main, bin, "\u2219", "\\bullet", true); +defineSymbol(math, main, bin, "\u2021", "\\ddagger"); +defineSymbol(math, main, bin, "\u2240", "\\wr", true); +defineSymbol(math, main, bin, "\u2a3f", "\\amalg"); +defineSymbol(math, main, bin, "\u0026", "\\And"); // from amsmath + +// Arrow Symbols +defineSymbol(math, main, rel, "\u27f5", "\\longleftarrow", true); +defineSymbol(math, main, rel, "\u21d0", "\\Leftarrow", true); +defineSymbol(math, main, rel, "\u27f8", "\\Longleftarrow", true); +defineSymbol(math, main, rel, "\u27f6", "\\longrightarrow", true); +defineSymbol(math, main, rel, "\u21d2", "\\Rightarrow", true); +defineSymbol(math, main, rel, "\u27f9", "\\Longrightarrow", true); +defineSymbol(math, main, rel, "\u2194", "\\leftrightarrow", true); +defineSymbol(math, main, rel, "\u27f7", "\\longleftrightarrow", true); +defineSymbol(math, main, rel, "\u21d4", "\\Leftrightarrow", true); +defineSymbol(math, main, rel, "\u27fa", "\\Longleftrightarrow", true); +defineSymbol(math, main, rel, "\u21a6", "\\mapsto", true); +defineSymbol(math, main, rel, "\u27fc", "\\longmapsto", true); +defineSymbol(math, main, rel, "\u2197", "\\nearrow", true); +defineSymbol(math, main, rel, "\u21a9", "\\hookleftarrow", true); +defineSymbol(math, main, rel, "\u21aa", "\\hookrightarrow", true); +defineSymbol(math, main, rel, "\u2198", "\\searrow", true); +defineSymbol(math, main, rel, "\u21bc", "\\leftharpoonup", true); +defineSymbol(math, main, rel, "\u21c0", "\\rightharpoonup", true); +defineSymbol(math, main, rel, "\u2199", "\\swarrow", true); +defineSymbol(math, main, rel, "\u21bd", "\\leftharpoondown", true); +defineSymbol(math, main, rel, "\u21c1", "\\rightharpoondown", true); +defineSymbol(math, main, rel, "\u2196", "\\nwarrow", true); +defineSymbol(math, main, rel, "\u21cc", "\\rightleftharpoons", true); + +// AMS Negated Binary Relations +defineSymbol(math, ams, rel, "\u226e", "\\nless", true); +// Symbol names preceded by "@" each have a corresponding macro. +defineSymbol(math, ams, rel, "\ue010", "\\@nleqslant"); +defineSymbol(math, ams, rel, "\ue011", "\\@nleqq"); +defineSymbol(math, ams, rel, "\u2a87", "\\lneq", true); +defineSymbol(math, ams, rel, "\u2268", "\\lneqq", true); +defineSymbol(math, ams, rel, "\ue00c", "\\@lvertneqq"); +defineSymbol(math, ams, rel, "\u22e6", "\\lnsim", true); +defineSymbol(math, ams, rel, "\u2a89", "\\lnapprox", true); +defineSymbol(math, ams, rel, "\u2280", "\\nprec", true); +// unicode-math maps \u22e0 to \npreccurlyeq. We'll use the AMS synonym. +defineSymbol(math, ams, rel, "\u22e0", "\\npreceq", true); +defineSymbol(math, ams, rel, "\u22e8", "\\precnsim", true); +defineSymbol(math, ams, rel, "\u2ab9", "\\precnapprox", true); +defineSymbol(math, ams, rel, "\u2241", "\\nsim", true); +defineSymbol(math, ams, rel, "\ue006", "\\@nshortmid"); +defineSymbol(math, ams, rel, "\u2224", "\\nmid", true); +defineSymbol(math, ams, rel, "\u22ac", "\\nvdash", true); +defineSymbol(math, ams, rel, "\u22ad", "\\nvDash", true); +defineSymbol(math, ams, rel, "\u22ea", "\\ntriangleleft"); +defineSymbol(math, ams, rel, "\u22ec", "\\ntrianglelefteq", true); +defineSymbol(math, ams, rel, "\u228a", "\\subsetneq", true); +defineSymbol(math, ams, rel, "\ue01a", "\\@varsubsetneq"); +defineSymbol(math, ams, rel, "\u2acb", "\\subsetneqq", true); +defineSymbol(math, ams, rel, "\ue017", "\\@varsubsetneqq"); +defineSymbol(math, ams, rel, "\u226f", "\\ngtr", true); +defineSymbol(math, ams, rel, "\ue00f", "\\@ngeqslant"); +defineSymbol(math, ams, rel, "\ue00e", "\\@ngeqq"); +defineSymbol(math, ams, rel, "\u2a88", "\\gneq", true); +defineSymbol(math, ams, rel, "\u2269", "\\gneqq", true); +defineSymbol(math, ams, rel, "\ue00d", "\\@gvertneqq"); +defineSymbol(math, ams, rel, "\u22e7", "\\gnsim", true); +defineSymbol(math, ams, rel, "\u2a8a", "\\gnapprox", true); +defineSymbol(math, ams, rel, "\u2281", "\\nsucc", true); +// unicode-math maps \u22e1 to \nsucccurlyeq. We'll use the AMS synonym. +defineSymbol(math, ams, rel, "\u22e1", "\\nsucceq", true); +defineSymbol(math, ams, rel, "\u22e9", "\\succnsim", true); +defineSymbol(math, ams, rel, "\u2aba", "\\succnapprox", true); +// unicode-math maps \u2246 to \simneqq. We'll use the AMS synonym. +defineSymbol(math, ams, rel, "\u2246", "\\ncong", true); +defineSymbol(math, ams, rel, "\ue007", "\\@nshortparallel"); +defineSymbol(math, ams, rel, "\u2226", "\\nparallel", true); +defineSymbol(math, ams, rel, "\u22af", "\\nVDash", true); +defineSymbol(math, ams, rel, "\u22eb", "\\ntriangleright"); +defineSymbol(math, ams, rel, "\u22ed", "\\ntrianglerighteq", true); +defineSymbol(math, ams, rel, "\ue018", "\\@nsupseteqq"); +defineSymbol(math, ams, rel, "\u228b", "\\supsetneq", true); +defineSymbol(math, ams, rel, "\ue01b", "\\@varsupsetneq"); +defineSymbol(math, ams, rel, "\u2acc", "\\supsetneqq", true); +defineSymbol(math, ams, rel, "\ue019", "\\@varsupsetneqq"); +defineSymbol(math, ams, rel, "\u22ae", "\\nVdash", true); +defineSymbol(math, ams, rel, "\u2ab5", "\\precneqq", true); +defineSymbol(math, ams, rel, "\u2ab6", "\\succneqq", true); +defineSymbol(math, ams, rel, "\ue016", "\\@nsubseteqq"); +defineSymbol(math, ams, bin, "\u22b4", "\\unlhd"); +defineSymbol(math, ams, bin, "\u22b5", "\\unrhd"); + +// AMS Negated Arrows +defineSymbol(math, ams, rel, "\u219a", "\\nleftarrow", true); +defineSymbol(math, ams, rel, "\u219b", "\\nrightarrow", true); +defineSymbol(math, ams, rel, "\u21cd", "\\nLeftarrow", true); +defineSymbol(math, ams, rel, "\u21cf", "\\nRightarrow", true); +defineSymbol(math, ams, rel, "\u21ae", "\\nleftrightarrow", true); +defineSymbol(math, ams, rel, "\u21ce", "\\nLeftrightarrow", true); + +// AMS Misc +defineSymbol(math, ams, rel, "\u25b3", "\\vartriangle"); +defineSymbol(math, ams, textord, "\u210f", "\\hslash"); +defineSymbol(math, ams, textord, "\u25bd", "\\triangledown"); +defineSymbol(math, ams, textord, "\u25ca", "\\lozenge"); +defineSymbol(math, ams, textord, "\u24c8", "\\circledS"); +defineSymbol(math, ams, textord, "\u00ae", "\\circledR"); +defineSymbol(text, ams, textord, "\u00ae", "\\circledR"); +defineSymbol(math, ams, textord, "\u2221", "\\measuredangle", true); +defineSymbol(math, ams, textord, "\u2204", "\\nexists"); +defineSymbol(math, ams, textord, "\u2127", "\\mho"); +defineSymbol(math, ams, textord, "\u2132", "\\Finv", true); +defineSymbol(math, ams, textord, "\u2141", "\\Game", true); +defineSymbol(math, ams, textord, "\u2035", "\\backprime"); +defineSymbol(math, ams, textord, "\u25b2", "\\blacktriangle"); +defineSymbol(math, ams, textord, "\u25bc", "\\blacktriangledown"); +defineSymbol(math, ams, textord, "\u25a0", "\\blacksquare"); +defineSymbol(math, ams, textord, "\u29eb", "\\blacklozenge"); +defineSymbol(math, ams, textord, "\u2605", "\\bigstar"); +defineSymbol(math, ams, textord, "\u2222", "\\sphericalangle", true); +defineSymbol(math, ams, textord, "\u2201", "\\complement", true); +// unicode-math maps U+F0 to \matheth. We map to AMS function \eth +defineSymbol(math, ams, textord, "\u00f0", "\\eth", true); +defineSymbol(text, main, textord, "\u00f0", "\u00f0"); +defineSymbol(math, ams, textord, "\u2571", "\\diagup"); +defineSymbol(math, ams, textord, "\u2572", "\\diagdown"); +defineSymbol(math, ams, textord, "\u25a1", "\\square"); +defineSymbol(math, ams, textord, "\u25a1", "\\Box"); +defineSymbol(math, ams, textord, "\u25ca", "\\Diamond"); +// unicode-math maps U+A5 to \mathyen. We map to AMS function \yen +defineSymbol(math, ams, textord, "\u00a5", "\\yen", true); +defineSymbol(text, ams, textord, "\u00a5", "\\yen", true); +defineSymbol(math, ams, textord, "\u2713", "\\checkmark", true); +defineSymbol(text, ams, textord, "\u2713", "\\checkmark"); + +// AMS Hebrew +defineSymbol(math, ams, textord, "\u2136", "\\beth", true); +defineSymbol(math, ams, textord, "\u2138", "\\daleth", true); +defineSymbol(math, ams, textord, "\u2137", "\\gimel", true); + +// AMS Greek +defineSymbol(math, ams, textord, "\u03dd", "\\digamma", true); +defineSymbol(math, ams, textord, "\u03f0", "\\varkappa"); + +// AMS Delimiters +defineSymbol(math, ams, open, "\u250c", "\\@ulcorner", true); +defineSymbol(math, ams, close, "\u2510", "\\@urcorner", true); +defineSymbol(math, ams, open, "\u2514", "\\@llcorner", true); +defineSymbol(math, ams, close, "\u2518", "\\@lrcorner", true); + +// AMS Binary Relations +defineSymbol(math, ams, rel, "\u2266", "\\leqq", true); +defineSymbol(math, ams, rel, "\u2a7d", "\\leqslant", true); +defineSymbol(math, ams, rel, "\u2a95", "\\eqslantless", true); +defineSymbol(math, ams, rel, "\u2272", "\\lesssim", true); +defineSymbol(math, ams, rel, "\u2a85", "\\lessapprox", true); +defineSymbol(math, ams, rel, "\u224a", "\\approxeq", true); +defineSymbol(math, ams, bin, "\u22d6", "\\lessdot"); +defineSymbol(math, ams, rel, "\u22d8", "\\lll", true); +defineSymbol(math, ams, rel, "\u2276", "\\lessgtr", true); +defineSymbol(math, ams, rel, "\u22da", "\\lesseqgtr", true); +defineSymbol(math, ams, rel, "\u2a8b", "\\lesseqqgtr", true); +defineSymbol(math, ams, rel, "\u2251", "\\doteqdot"); +defineSymbol(math, ams, rel, "\u2253", "\\risingdotseq", true); +defineSymbol(math, ams, rel, "\u2252", "\\fallingdotseq", true); +defineSymbol(math, ams, rel, "\u223d", "\\backsim", true); +defineSymbol(math, ams, rel, "\u22cd", "\\backsimeq", true); +defineSymbol(math, ams, rel, "\u2ac5", "\\subseteqq", true); +defineSymbol(math, ams, rel, "\u22d0", "\\Subset", true); +defineSymbol(math, ams, rel, "\u228f", "\\sqsubset", true); +defineSymbol(math, ams, rel, "\u227c", "\\preccurlyeq", true); +defineSymbol(math, ams, rel, "\u22de", "\\curlyeqprec", true); +defineSymbol(math, ams, rel, "\u227e", "\\precsim", true); +defineSymbol(math, ams, rel, "\u2ab7", "\\precapprox", true); +defineSymbol(math, ams, rel, "\u22b2", "\\vartriangleleft"); +defineSymbol(math, ams, rel, "\u22b4", "\\trianglelefteq"); +defineSymbol(math, ams, rel, "\u22a8", "\\vDash", true); +defineSymbol(math, ams, rel, "\u22aa", "\\Vvdash", true); +defineSymbol(math, ams, rel, "\u2323", "\\smallsmile"); +defineSymbol(math, ams, rel, "\u2322", "\\smallfrown"); +defineSymbol(math, ams, rel, "\u224f", "\\bumpeq", true); +defineSymbol(math, ams, rel, "\u224e", "\\Bumpeq", true); +defineSymbol(math, ams, rel, "\u2267", "\\geqq", true); +defineSymbol(math, ams, rel, "\u2a7e", "\\geqslant", true); +defineSymbol(math, ams, rel, "\u2a96", "\\eqslantgtr", true); +defineSymbol(math, ams, rel, "\u2273", "\\gtrsim", true); +defineSymbol(math, ams, rel, "\u2a86", "\\gtrapprox", true); +defineSymbol(math, ams, bin, "\u22d7", "\\gtrdot"); +defineSymbol(math, ams, rel, "\u22d9", "\\ggg", true); +defineSymbol(math, ams, rel, "\u2277", "\\gtrless", true); +defineSymbol(math, ams, rel, "\u22db", "\\gtreqless", true); +defineSymbol(math, ams, rel, "\u2a8c", "\\gtreqqless", true); +defineSymbol(math, ams, rel, "\u2256", "\\eqcirc", true); +defineSymbol(math, ams, rel, "\u2257", "\\circeq", true); +defineSymbol(math, ams, rel, "\u225c", "\\triangleq", true); +defineSymbol(math, ams, rel, "\u223c", "\\thicksim"); +defineSymbol(math, ams, rel, "\u2248", "\\thickapprox"); +defineSymbol(math, ams, rel, "\u2ac6", "\\supseteqq", true); +defineSymbol(math, ams, rel, "\u22d1", "\\Supset", true); +defineSymbol(math, ams, rel, "\u2290", "\\sqsupset", true); +defineSymbol(math, ams, rel, "\u227d", "\\succcurlyeq", true); +defineSymbol(math, ams, rel, "\u22df", "\\curlyeqsucc", true); +defineSymbol(math, ams, rel, "\u227f", "\\succsim", true); +defineSymbol(math, ams, rel, "\u2ab8", "\\succapprox", true); +defineSymbol(math, ams, rel, "\u22b3", "\\vartriangleright"); +defineSymbol(math, ams, rel, "\u22b5", "\\trianglerighteq"); +defineSymbol(math, ams, rel, "\u22a9", "\\Vdash", true); +defineSymbol(math, ams, rel, "\u2223", "\\shortmid"); +defineSymbol(math, ams, rel, "\u2225", "\\shortparallel"); +defineSymbol(math, ams, rel, "\u226c", "\\between", true); +defineSymbol(math, ams, rel, "\u22d4", "\\pitchfork", true); +defineSymbol(math, ams, rel, "\u221d", "\\varpropto"); +defineSymbol(math, ams, rel, "\u25c0", "\\blacktriangleleft"); +// unicode-math says that \therefore is a mathord atom. +// We kept the amssymb atom type, which is rel. +defineSymbol(math, ams, rel, "\u2234", "\\therefore", true); +defineSymbol(math, ams, rel, "\u220d", "\\backepsilon"); +defineSymbol(math, ams, rel, "\u25b6", "\\blacktriangleright"); +// unicode-math says that \because is a mathord atom. +// We kept the amssymb atom type, which is rel. +defineSymbol(math, ams, rel, "\u2235", "\\because", true); +defineSymbol(math, ams, rel, "\u22d8", "\\llless"); +defineSymbol(math, ams, rel, "\u22d9", "\\gggtr"); +defineSymbol(math, ams, bin, "\u22b2", "\\lhd"); +defineSymbol(math, ams, bin, "\u22b3", "\\rhd"); +defineSymbol(math, ams, rel, "\u2242", "\\eqsim", true); +defineSymbol(math, main, rel, "\u22c8", "\\Join"); +defineSymbol(math, ams, rel, "\u2251", "\\Doteq", true); + +// AMS Binary Operators +defineSymbol(math, ams, bin, "\u2214", "\\dotplus", true); +defineSymbol(math, ams, bin, "\u2216", "\\smallsetminus"); +defineSymbol(math, ams, bin, "\u22d2", "\\Cap", true); +defineSymbol(math, ams, bin, "\u22d3", "\\Cup", true); +defineSymbol(math, ams, bin, "\u2a5e", "\\doublebarwedge", true); +defineSymbol(math, ams, bin, "\u229f", "\\boxminus", true); +defineSymbol(math, ams, bin, "\u229e", "\\boxplus", true); +defineSymbol(math, ams, bin, "\u22c7", "\\divideontimes", true); +defineSymbol(math, ams, bin, "\u22c9", "\\ltimes", true); +defineSymbol(math, ams, bin, "\u22ca", "\\rtimes", true); +defineSymbol(math, ams, bin, "\u22cb", "\\leftthreetimes", true); +defineSymbol(math, ams, bin, "\u22cc", "\\rightthreetimes", true); +defineSymbol(math, ams, bin, "\u22cf", "\\curlywedge", true); +defineSymbol(math, ams, bin, "\u22ce", "\\curlyvee", true); +defineSymbol(math, ams, bin, "\u229d", "\\circleddash", true); +defineSymbol(math, ams, bin, "\u229b", "\\circledast", true); +defineSymbol(math, ams, bin, "\u22c5", "\\centerdot"); +defineSymbol(math, ams, bin, "\u22ba", "\\intercal", true); +defineSymbol(math, ams, bin, "\u22d2", "\\doublecap"); +defineSymbol(math, ams, bin, "\u22d3", "\\doublecup"); +defineSymbol(math, ams, bin, "\u22a0", "\\boxtimes", true); + +// AMS Arrows +// Note: unicode-math maps \u21e2 to their own function \rightdasharrow. +// We'll map it to AMS function \dashrightarrow. It produces the same atom. +defineSymbol(math, ams, rel, "\u21e2", "\\dashrightarrow", true); +// unicode-math maps \u21e0 to \leftdasharrow. We'll use the AMS synonym. +defineSymbol(math, ams, rel, "\u21e0", "\\dashleftarrow", true); +defineSymbol(math, ams, rel, "\u21c7", "\\leftleftarrows", true); +defineSymbol(math, ams, rel, "\u21c6", "\\leftrightarrows", true); +defineSymbol(math, ams, rel, "\u21da", "\\Lleftarrow", true); +defineSymbol(math, ams, rel, "\u219e", "\\twoheadleftarrow", true); +defineSymbol(math, ams, rel, "\u21a2", "\\leftarrowtail", true); +defineSymbol(math, ams, rel, "\u21ab", "\\looparrowleft", true); +defineSymbol(math, ams, rel, "\u21cb", "\\leftrightharpoons", true); +defineSymbol(math, ams, rel, "\u21b6", "\\curvearrowleft", true); +// unicode-math maps \u21ba to \acwopencirclearrow. We'll use the AMS synonym. +defineSymbol(math, ams, rel, "\u21ba", "\\circlearrowleft", true); +defineSymbol(math, ams, rel, "\u21b0", "\\Lsh", true); +defineSymbol(math, ams, rel, "\u21c8", "\\upuparrows", true); +defineSymbol(math, ams, rel, "\u21bf", "\\upharpoonleft", true); +defineSymbol(math, ams, rel, "\u21c3", "\\downharpoonleft", true); +defineSymbol(math, main, rel, "\u22b6", "\\origof", true); // not in font +defineSymbol(math, main, rel, "\u22b7", "\\imageof", true); // not in font +defineSymbol(math, ams, rel, "\u22b8", "\\multimap", true); +defineSymbol(math, ams, rel, "\u21ad", "\\leftrightsquigarrow", true); +defineSymbol(math, ams, rel, "\u21c9", "\\rightrightarrows", true); +defineSymbol(math, ams, rel, "\u21c4", "\\rightleftarrows", true); +defineSymbol(math, ams, rel, "\u21a0", "\\twoheadrightarrow", true); +defineSymbol(math, ams, rel, "\u21a3", "\\rightarrowtail", true); +defineSymbol(math, ams, rel, "\u21ac", "\\looparrowright", true); +defineSymbol(math, ams, rel, "\u21b7", "\\curvearrowright", true); +// unicode-math maps \u21bb to \cwopencirclearrow. We'll use the AMS synonym. +defineSymbol(math, ams, rel, "\u21bb", "\\circlearrowright", true); +defineSymbol(math, ams, rel, "\u21b1", "\\Rsh", true); +defineSymbol(math, ams, rel, "\u21ca", "\\downdownarrows", true); +defineSymbol(math, ams, rel, "\u21be", "\\upharpoonright", true); +defineSymbol(math, ams, rel, "\u21c2", "\\downharpoonright", true); +defineSymbol(math, ams, rel, "\u21dd", "\\rightsquigarrow", true); +defineSymbol(math, ams, rel, "\u21dd", "\\leadsto"); +defineSymbol(math, ams, rel, "\u21db", "\\Rrightarrow", true); +defineSymbol(math, ams, rel, "\u21be", "\\restriction"); + +defineSymbol(math, main, textord, "\u2018", "`"); +defineSymbol(math, main, textord, "$", "\\$"); +defineSymbol(text, main, textord, "$", "\\$"); +defineSymbol(text, main, textord, "$", "\\textdollar"); +defineSymbol(math, main, textord, "%", "\\%"); +defineSymbol(text, main, textord, "%", "\\%"); +defineSymbol(math, main, textord, "_", "\\_"); +defineSymbol(text, main, textord, "_", "\\_"); +defineSymbol(text, main, textord, "_", "\\textunderscore"); +defineSymbol(math, main, textord, "\u2220", "\\angle", true); +defineSymbol(math, main, textord, "\u221e", "\\infty", true); +defineSymbol(math, main, textord, "\u2032", "\\prime"); +defineSymbol(math, main, textord, "\u25b3", "\\triangle"); +defineSymbol(math, main, textord, "\u0393", "\\Gamma", true); +defineSymbol(math, main, textord, "\u0394", "\\Delta", true); +defineSymbol(math, main, textord, "\u0398", "\\Theta", true); +defineSymbol(math, main, textord, "\u039b", "\\Lambda", true); +defineSymbol(math, main, textord, "\u039e", "\\Xi", true); +defineSymbol(math, main, textord, "\u03a0", "\\Pi", true); +defineSymbol(math, main, textord, "\u03a3", "\\Sigma", true); +defineSymbol(math, main, textord, "\u03a5", "\\Upsilon", true); +defineSymbol(math, main, textord, "\u03a6", "\\Phi", true); +defineSymbol(math, main, textord, "\u03a8", "\\Psi", true); +defineSymbol(math, main, textord, "\u03a9", "\\Omega", true); +defineSymbol(math, main, textord, "A", "\u0391"); +defineSymbol(math, main, textord, "B", "\u0392"); +defineSymbol(math, main, textord, "E", "\u0395"); +defineSymbol(math, main, textord, "Z", "\u0396"); +defineSymbol(math, main, textord, "H", "\u0397"); +defineSymbol(math, main, textord, "I", "\u0399"); +defineSymbol(math, main, textord, "K", "\u039A"); +defineSymbol(math, main, textord, "M", "\u039C"); +defineSymbol(math, main, textord, "N", "\u039D"); +defineSymbol(math, main, textord, "O", "\u039F"); +defineSymbol(math, main, textord, "P", "\u03A1"); +defineSymbol(math, main, textord, "T", "\u03A4"); +defineSymbol(math, main, textord, "X", "\u03A7"); +defineSymbol(math, main, textord, "\u00ac", "\\neg", true); +defineSymbol(math, main, textord, "\u00ac", "\\lnot"); +defineSymbol(math, main, textord, "\u22a4", "\\top"); +defineSymbol(math, main, textord, "\u22a5", "\\bot"); +defineSymbol(math, main, textord, "\u2205", "\\emptyset"); +defineSymbol(math, ams, textord, "\u2205", "\\varnothing"); +defineSymbol(math, main, mathord, "\u03b1", "\\alpha", true); +defineSymbol(math, main, mathord, "\u03b2", "\\beta", true); +defineSymbol(math, main, mathord, "\u03b3", "\\gamma", true); +defineSymbol(math, main, mathord, "\u03b4", "\\delta", true); +defineSymbol(math, main, mathord, "\u03f5", "\\epsilon", true); +defineSymbol(math, main, mathord, "\u03b6", "\\zeta", true); +defineSymbol(math, main, mathord, "\u03b7", "\\eta", true); +defineSymbol(math, main, mathord, "\u03b8", "\\theta", true); +defineSymbol(math, main, mathord, "\u03b9", "\\iota", true); +defineSymbol(math, main, mathord, "\u03ba", "\\kappa", true); +defineSymbol(math, main, mathord, "\u03bb", "\\lambda", true); +defineSymbol(math, main, mathord, "\u03bc", "\\mu", true); +defineSymbol(math, main, mathord, "\u03bd", "\\nu", true); +defineSymbol(math, main, mathord, "\u03be", "\\xi", true); +defineSymbol(math, main, mathord, "\u03bf", "\\omicron", true); +defineSymbol(math, main, mathord, "\u03c0", "\\pi", true); +defineSymbol(math, main, mathord, "\u03c1", "\\rho", true); +defineSymbol(math, main, mathord, "\u03c3", "\\sigma", true); +defineSymbol(math, main, mathord, "\u03c4", "\\tau", true); +defineSymbol(math, main, mathord, "\u03c5", "\\upsilon", true); +defineSymbol(math, main, mathord, "\u03d5", "\\phi", true); +defineSymbol(math, main, mathord, "\u03c7", "\\chi", true); +defineSymbol(math, main, mathord, "\u03c8", "\\psi", true); +defineSymbol(math, main, mathord, "\u03c9", "\\omega", true); +defineSymbol(math, main, mathord, "\u03b5", "\\varepsilon", true); +defineSymbol(math, main, mathord, "\u03d1", "\\vartheta", true); +defineSymbol(math, main, mathord, "\u03d6", "\\varpi", true); +defineSymbol(math, main, mathord, "\u03f1", "\\varrho", true); +defineSymbol(math, main, mathord, "\u03c2", "\\varsigma", true); +defineSymbol(math, main, mathord, "\u03c6", "\\varphi", true); +defineSymbol(math, main, bin, "\u2217", "*", true); +defineSymbol(math, main, bin, "+", "+"); +defineSymbol(math, main, bin, "\u2212", "-", true); +defineSymbol(math, main, bin, "\u22c5", "\\cdot", true); +defineSymbol(math, main, bin, "\u2218", "\\circ", true); +defineSymbol(math, main, bin, "\u00f7", "\\div", true); +defineSymbol(math, main, bin, "\u00b1", "\\pm", true); +defineSymbol(math, main, bin, "\u00d7", "\\times", true); +defineSymbol(math, main, bin, "\u2229", "\\cap", true); +defineSymbol(math, main, bin, "\u222a", "\\cup", true); +defineSymbol(math, main, bin, "\u2216", "\\setminus", true); +defineSymbol(math, main, bin, "\u2227", "\\land"); +defineSymbol(math, main, bin, "\u2228", "\\lor"); +defineSymbol(math, main, bin, "\u2227", "\\wedge", true); +defineSymbol(math, main, bin, "\u2228", "\\vee", true); +defineSymbol(math, main, textord, "\u221a", "\\surd"); +defineSymbol(math, main, open, "\u27e8", "\\langle", true); +defineSymbol(math, main, open, "\u2223", "\\lvert"); +defineSymbol(math, main, open, "\u2225", "\\lVert"); +defineSymbol(math, main, close, "?", "?"); +defineSymbol(math, main, close, "!", "!"); +defineSymbol(math, main, close, "\u27e9", "\\rangle", true); +defineSymbol(math, main, close, "\u2223", "\\rvert"); +defineSymbol(math, main, close, "\u2225", "\\rVert"); +defineSymbol(math, main, rel, "=", "="); +defineSymbol(math, main, rel, ":", ":"); +defineSymbol(math, main, rel, "\u2248", "\\approx", true); +defineSymbol(math, main, rel, "\u2245", "\\cong", true); +defineSymbol(math, main, rel, "\u2265", "\\ge"); +defineSymbol(math, main, rel, "\u2265", "\\geq", true); +defineSymbol(math, main, rel, "\u2190", "\\gets"); +defineSymbol(math, main, rel, ">", "\\gt", true); +defineSymbol(math, main, rel, "\u2208", "\\in", true); +defineSymbol(math, main, rel, "\ue020", "\\@not"); +defineSymbol(math, main, rel, "\u2282", "\\subset", true); +defineSymbol(math, main, rel, "\u2283", "\\supset", true); +defineSymbol(math, main, rel, "\u2286", "\\subseteq", true); +defineSymbol(math, main, rel, "\u2287", "\\supseteq", true); +defineSymbol(math, ams, rel, "\u2288", "\\nsubseteq", true); +defineSymbol(math, ams, rel, "\u2289", "\\nsupseteq", true); +defineSymbol(math, main, rel, "\u22a8", "\\models"); +defineSymbol(math, main, rel, "\u2190", "\\leftarrow", true); +defineSymbol(math, main, rel, "\u2264", "\\le"); +defineSymbol(math, main, rel, "\u2264", "\\leq", true); +defineSymbol(math, main, rel, "<", "\\lt", true); +defineSymbol(math, main, rel, "\u2192", "\\rightarrow", true); +defineSymbol(math, main, rel, "\u2192", "\\to"); +defineSymbol(math, ams, rel, "\u2271", "\\ngeq", true); +defineSymbol(math, ams, rel, "\u2270", "\\nleq", true); +defineSymbol(math, main, spacing, "\u00a0", "\\ "); +defineSymbol(math, main, spacing, "\u00a0", "\\space"); +// Ref: LaTeX Source 2e: \DeclareRobustCommand{\nobreakspace}{% +defineSymbol(math, main, spacing, "\u00a0", "\\nobreakspace"); +defineSymbol(text, main, spacing, "\u00a0", "\\ "); +defineSymbol(text, main, spacing, "\u00a0", " "); +defineSymbol(text, main, spacing, "\u00a0", "\\space"); +defineSymbol(text, main, spacing, "\u00a0", "\\nobreakspace"); +defineSymbol(math, main, spacing, "", "\\nobreak"); +defineSymbol(math, main, spacing, "", "\\allowbreak"); +defineSymbol(math, main, punct, ",", ","); +defineSymbol(math, main, punct, ";", ";"); +defineSymbol(math, ams, bin, "\u22bc", "\\barwedge", true); +defineSymbol(math, ams, bin, "\u22bb", "\\veebar", true); +defineSymbol(math, main, bin, "\u2299", "\\odot", true); +defineSymbol(math, main, bin, "\u2295", "\\oplus", true); +defineSymbol(math, main, bin, "\u2297", "\\otimes", true); +defineSymbol(math, main, textord, "\u2202", "\\partial", true); +defineSymbol(math, main, bin, "\u2298", "\\oslash", true); +defineSymbol(math, ams, bin, "\u229a", "\\circledcirc", true); +defineSymbol(math, ams, bin, "\u22a1", "\\boxdot", true); +defineSymbol(math, main, bin, "\u25b3", "\\bigtriangleup"); +defineSymbol(math, main, bin, "\u25bd", "\\bigtriangledown"); +defineSymbol(math, main, bin, "\u2020", "\\dagger"); +defineSymbol(math, main, bin, "\u22c4", "\\diamond"); +defineSymbol(math, main, bin, "\u22c6", "\\star"); +defineSymbol(math, main, bin, "\u25c3", "\\triangleleft"); +defineSymbol(math, main, bin, "\u25b9", "\\triangleright"); +defineSymbol(math, main, open, "{", "\\{"); +defineSymbol(text, main, textord, "{", "\\{"); +defineSymbol(text, main, textord, "{", "\\textbraceleft"); +defineSymbol(math, main, close, "}", "\\}"); +defineSymbol(text, main, textord, "}", "\\}"); +defineSymbol(text, main, textord, "}", "\\textbraceright"); +defineSymbol(math, main, open, "{", "\\lbrace"); +defineSymbol(math, main, close, "}", "\\rbrace"); +defineSymbol(math, main, open, "[", "\\lbrack", true); +defineSymbol(text, main, textord, "[", "\\lbrack", true); +defineSymbol(math, main, close, "]", "\\rbrack", true); +defineSymbol(text, main, textord, "]", "\\rbrack", true); +defineSymbol(math, main, open, "(", "\\lparen", true); +defineSymbol(math, main, close, ")", "\\rparen", true); +defineSymbol(text, main, textord, "<", "\\textless", true); // in T1 fontenc +defineSymbol(text, main, textord, ">", "\\textgreater", true); // in T1 fontenc +defineSymbol(math, main, open, "\u230a", "\\lfloor", true); +defineSymbol(math, main, close, "\u230b", "\\rfloor", true); +defineSymbol(math, main, open, "\u2308", "\\lceil", true); +defineSymbol(math, main, close, "\u2309", "\\rceil", true); +defineSymbol(math, main, textord, "\\", "\\backslash"); +defineSymbol(math, main, textord, "\u2223", "|"); +defineSymbol(math, main, textord, "\u2223", "\\vert"); +defineSymbol(text, main, textord, "|", "\\textbar", true); // in T1 fontenc +defineSymbol(math, main, textord, "\u2225", "\\|"); +defineSymbol(math, main, textord, "\u2225", "\\Vert"); +defineSymbol(text, main, textord, "\u2225", "\\textbardbl"); +defineSymbol(text, main, textord, "~", "\\textasciitilde"); +defineSymbol(text, main, textord, "\\", "\\textbackslash"); +defineSymbol(text, main, textord, "^", "\\textasciicircum"); +defineSymbol(math, main, rel, "\u2191", "\\uparrow", true); +defineSymbol(math, main, rel, "\u21d1", "\\Uparrow", true); +defineSymbol(math, main, rel, "\u2193", "\\downarrow", true); +defineSymbol(math, main, rel, "\u21d3", "\\Downarrow", true); +defineSymbol(math, main, rel, "\u2195", "\\updownarrow", true); +defineSymbol(math, main, rel, "\u21d5", "\\Updownarrow", true); +defineSymbol(math, main, op, "\u2210", "\\coprod"); +defineSymbol(math, main, op, "\u22c1", "\\bigvee"); +defineSymbol(math, main, op, "\u22c0", "\\bigwedge"); +defineSymbol(math, main, op, "\u2a04", "\\biguplus"); +defineSymbol(math, main, op, "\u22c2", "\\bigcap"); +defineSymbol(math, main, op, "\u22c3", "\\bigcup"); +defineSymbol(math, main, op, "\u222b", "\\int"); +defineSymbol(math, main, op, "\u222b", "\\intop"); +defineSymbol(math, main, op, "\u222c", "\\iint"); +defineSymbol(math, main, op, "\u222d", "\\iiint"); +defineSymbol(math, main, op, "\u220f", "\\prod"); +defineSymbol(math, main, op, "\u2211", "\\sum"); +defineSymbol(math, main, op, "\u2a02", "\\bigotimes"); +defineSymbol(math, main, op, "\u2a01", "\\bigoplus"); +defineSymbol(math, main, op, "\u2a00", "\\bigodot"); +defineSymbol(math, main, op, "\u222e", "\\oint"); +defineSymbol(math, main, op, "\u222f", "\\oiint"); +defineSymbol(math, main, op, "\u2230", "\\oiiint"); +defineSymbol(math, main, op, "\u2a06", "\\bigsqcup"); +defineSymbol(math, main, op, "\u222b", "\\smallint"); +defineSymbol(text, main, inner, "\u2026", "\\textellipsis"); +defineSymbol(math, main, inner, "\u2026", "\\mathellipsis"); +defineSymbol(text, main, inner, "\u2026", "\\ldots", true); +defineSymbol(math, main, inner, "\u2026", "\\ldots", true); +defineSymbol(math, main, inner, "\u22ef", "\\@cdots", true); +defineSymbol(math, main, inner, "\u22f1", "\\ddots", true); +// \vdots is a macro that uses one of these two symbols (with made-up names): +defineSymbol(math, main, textord, "\u22ee", "\\varvdots"); +defineSymbol(text, main, textord, "\u22ee", "\\varvdots"); +defineSymbol(math, main, accent, "\u02ca", "\\acute"); +defineSymbol(math, main, accent, "\u02cb", "\\grave"); +defineSymbol(math, main, accent, "\u00a8", "\\ddot"); +defineSymbol(math, main, accent, "\u007e", "\\tilde"); +defineSymbol(math, main, accent, "\u02c9", "\\bar"); +defineSymbol(math, main, accent, "\u02d8", "\\breve"); +defineSymbol(math, main, accent, "\u02c7", "\\check"); +defineSymbol(math, main, accent, "\u005e", "\\hat"); +defineSymbol(math, main, accent, "\u20d7", "\\vec"); +defineSymbol(math, main, accent, "\u02d9", "\\dot"); +defineSymbol(math, main, accent, "\u02da", "\\mathring"); +// \imath and \jmath should be invariant to \mathrm, \mathbf, etc., so use PUA +defineSymbol(math, main, mathord, "\ue131", "\\@imath"); +defineSymbol(math, main, mathord, "\ue237", "\\@jmath"); +defineSymbol(math, main, textord, "\u0131", "\u0131"); +defineSymbol(math, main, textord, "\u0237", "\u0237"); +defineSymbol(text, main, textord, "\u0131", "\\i", true); +defineSymbol(text, main, textord, "\u0237", "\\j", true); +defineSymbol(text, main, textord, "\u00df", "\\ss", true); +defineSymbol(text, main, textord, "\u00e6", "\\ae", true); +defineSymbol(text, main, textord, "\u0153", "\\oe", true); +defineSymbol(text, main, textord, "\u00f8", "\\o", true); +defineSymbol(text, main, textord, "\u00c6", "\\AE", true); +defineSymbol(text, main, textord, "\u0152", "\\OE", true); +defineSymbol(text, main, textord, "\u00d8", "\\O", true); +defineSymbol(text, main, accent, "\u02ca", "\\'"); // acute +defineSymbol(text, main, accent, "\u02cb", "\\`"); // grave +defineSymbol(text, main, accent, "\u02c6", "\\^"); // circumflex +defineSymbol(text, main, accent, "\u02dc", "\\~"); // tilde +defineSymbol(text, main, accent, "\u02c9", "\\="); // macron +defineSymbol(text, main, accent, "\u02d8", "\\u"); // breve +defineSymbol(text, main, accent, "\u02d9", "\\."); // dot above +defineSymbol(text, main, accent, "\u00b8", "\\c"); // cedilla +defineSymbol(text, main, accent, "\u02da", "\\r"); // ring above +defineSymbol(text, main, accent, "\u02c7", "\\v"); // caron +defineSymbol(text, main, accent, "\u00a8", '\\"'); // diaeresis +defineSymbol(text, main, accent, "\u02dd", "\\H"); // double acute +defineSymbol(text, main, accent, "\u25ef", "\\textcircled"); // \bigcirc glyph + +// These ligatures are detected and created in Parser.js's `formLigatures`. +export const ligatures = { + "--": true, + "---": true, + "``": true, + "''": true, +}; + +defineSymbol(text, main, textord, "\u2013", "--", true); +defineSymbol(text, main, textord, "\u2013", "\\textendash"); +defineSymbol(text, main, textord, "\u2014", "---", true); +defineSymbol(text, main, textord, "\u2014", "\\textemdash"); +defineSymbol(text, main, textord, "\u2018", "`", true); +defineSymbol(text, main, textord, "\u2018", "\\textquoteleft"); +defineSymbol(text, main, textord, "\u2019", "'", true); +defineSymbol(text, main, textord, "\u2019", "\\textquoteright"); +defineSymbol(text, main, textord, "\u201c", "``", true); +defineSymbol(text, main, textord, "\u201c", "\\textquotedblleft"); +defineSymbol(text, main, textord, "\u201d", "''", true); +defineSymbol(text, main, textord, "\u201d", "\\textquotedblright"); +// \degree from gensymb package +defineSymbol(math, main, textord, "\u00b0", "\\degree", true); +defineSymbol(text, main, textord, "\u00b0", "\\degree"); +// \textdegree from inputenc package +defineSymbol(text, main, textord, "\u00b0", "\\textdegree", true); +// TODO: In LaTeX, \pounds can generate a different character in text and math +// mode, but among our fonts, only Main-Regular defines this character "163". +defineSymbol(math, main, textord, "\u00a3", "\\pounds"); +defineSymbol(math, main, textord, "\u00a3", "\\mathsterling", true); +defineSymbol(text, main, textord, "\u00a3", "\\pounds"); +defineSymbol(text, main, textord, "\u00a3", "\\textsterling", true); +defineSymbol(math, ams, textord, "\u2720", "\\maltese"); +defineSymbol(text, ams, textord, "\u2720", "\\maltese"); + +// There are lots of symbols which are the same, so we add them in afterwards. +// All of these are textords in math mode +const mathTextSymbols = "0123456789/@.\""; +for (let i = 0; i < mathTextSymbols.length; i++) { + const ch = mathTextSymbols.charAt(i); + defineSymbol(math, main, textord, ch, ch); +} + +// All of these are textords in text mode +const textSymbols = "0123456789!@*()-=+\";:?/.,"; +for (let i = 0; i < textSymbols.length; i++) { + const ch = textSymbols.charAt(i); + defineSymbol(text, main, textord, ch, ch); +} + +// All of these are textords in text mode, and mathords in math mode +const letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; +for (let i = 0; i < letters.length; i++) { + const ch = letters.charAt(i); + defineSymbol(math, main, mathord, ch, ch); + defineSymbol(text, main, textord, ch, ch); +} + +// Blackboard bold and script letters in Unicode range +defineSymbol(math, ams, textord, "C", "\u2102"); // blackboard bold +defineSymbol(text, ams, textord, "C", "\u2102"); +defineSymbol(math, ams, textord, "H", "\u210D"); +defineSymbol(text, ams, textord, "H", "\u210D"); +defineSymbol(math, ams, textord, "N", "\u2115"); +defineSymbol(text, ams, textord, "N", "\u2115"); +defineSymbol(math, ams, textord, "P", "\u2119"); +defineSymbol(text, ams, textord, "P", "\u2119"); +defineSymbol(math, ams, textord, "Q", "\u211A"); +defineSymbol(text, ams, textord, "Q", "\u211A"); +defineSymbol(math, ams, textord, "R", "\u211D"); +defineSymbol(text, ams, textord, "R", "\u211D"); +defineSymbol(math, ams, textord, "Z", "\u2124"); +defineSymbol(text, ams, textord, "Z", "\u2124"); +defineSymbol(math, main, mathord, "h", "\u210E"); // italic h, Planck constant +defineSymbol(text, main, mathord, "h", "\u210E"); + +// The next loop loads wide (surrogate pair) characters. +// We support some letters in the Unicode range U+1D400 to U+1D7FF, +// Mathematical Alphanumeric Symbols. +// Some editors do not deal well with wide characters. So don't write the +// string into this file. Instead, create the string from the surrogate pair. +let wideChar; +for (let i = 0; i < letters.length; i++) { + const ch = letters.charAt(i); + + // The hex numbers in the next line are a surrogate pair. + // 0xD835 is the high surrogate for all letters in the range we support. + // 0xDC00 is the low surrogate for bold A. + wideChar = String.fromCharCode(0xD835, 0xDC00 + i); // A-Z a-z bold + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(text, main, textord, ch, wideChar); + + wideChar = String.fromCharCode(0xD835, 0xDC34 + i); // A-Z a-z italic + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(text, main, textord, ch, wideChar); + + wideChar = String.fromCharCode(0xD835, 0xDC68 + i); // A-Z a-z bold italic + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(text, main, textord, ch, wideChar); + + wideChar = String.fromCharCode(0xD835, 0xDD04 + i); // A-Z a-z Fraktur + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(text, main, textord, ch, wideChar); + + wideChar = String.fromCharCode(0xD835, 0xDD6C + i); // A-Z a-z bold Fraktur + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(text, main, textord, ch, wideChar); + + wideChar = String.fromCharCode(0xD835, 0xDDA0 + i); // A-Z a-z sans-serif + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(text, main, textord, ch, wideChar); + + wideChar = String.fromCharCode(0xD835, 0xDDD4 + i); // A-Z a-z sans bold + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(text, main, textord, ch, wideChar); + + wideChar = String.fromCharCode(0xD835, 0xDE08 + i); // A-Z a-z sans italic + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(text, main, textord, ch, wideChar); + + wideChar = String.fromCharCode(0xD835, 0xDE70 + i); // A-Z a-z monospace + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(text, main, textord, ch, wideChar); + + if (i < 26) { + // KaTeX fonts have only capital letters for blackboard bold and script. + // See exception for k below. + wideChar = String.fromCharCode(0xD835, 0xDD38 + i); // A-Z double struck + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(text, main, textord, ch, wideChar); + + wideChar = String.fromCharCode(0xD835, 0xDC9C + i); // A-Z script + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(text, main, textord, ch, wideChar); + } + + // TODO: Add bold script when it is supported by a KaTeX font. +} +// "k" is the only double struck lower case letter in the KaTeX fonts. +wideChar = String.fromCharCode(0xD835, 0xDD5C); // k double struck +defineSymbol(math, main, mathord, "k", wideChar); +defineSymbol(text, main, textord, "k", wideChar); + +// Next, some wide character numerals +for (let i = 0; i < 10; i++) { + const ch = i.toString(); + + wideChar = String.fromCharCode(0xD835, 0xDFCE + i); // 0-9 bold + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(text, main, textord, ch, wideChar); + + wideChar = String.fromCharCode(0xD835, 0xDFE2 + i); // 0-9 sans serif + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(text, main, textord, ch, wideChar); + + wideChar = String.fromCharCode(0xD835, 0xDFEC + i); // 0-9 bold sans + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(text, main, textord, ch, wideChar); + + wideChar = String.fromCharCode(0xD835, 0xDFF6 + i); // 0-9 monospace + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(text, main, textord, ch, wideChar); +} + +// We add these Latin-1 letters as symbols for backwards-compatibility, +// but they are not actually in the font, nor are they supported by the +// Unicode accent mechanism, so they fall back to Times font and look ugly. +// TODO(edemaine): Fix this. +export const extraLatin = "\u00d0\u00de\u00fe"; +for (let i = 0; i < extraLatin.length; i++) { + const ch = extraLatin.charAt(i); + defineSymbol(math, main, mathord, ch, ch); + defineSymbol(text, main, textord, ch, ch); +} diff --git a/node_modules/katex/src/tree.ts b/node_modules/katex/src/tree.ts new file mode 100644 index 0000000..8e5dbee --- /dev/null +++ b/node_modules/katex/src/tree.ts @@ -0,0 +1,79 @@ +import type {CssStyle, HtmlDomNode} from "./domTree"; +import type {MathDomNode} from "./mathMLTree"; + + +// To ensure that all nodes have compatible signatures for these methods. +export interface VirtualNode { + toNode(): Node; + toMarkup(): string; +} + +function isMathDomNode(node: VirtualNode): node is MathDomNode { + return 'toText' in node; +} + + +/** + * This node represents a document fragment, which contains elements, but when + * placed into the DOM doesn't have any representation itself. It only contains + * children and doesn't have any DOM node properties. + */ +export class DocumentFragment + implements HtmlDomNode, MathDomNode { + children: ReadonlyArray; + classes: string[]; + height: number; + depth: number; + maxFontSize: number; + style: CssStyle; // Never used; needed for satisfying interface. + + constructor(children: ReadonlyArray) { + this.children = children; + this.classes = []; + this.height = 0; + this.depth = 0; + this.maxFontSize = 0; + this.style = {}; + } + + hasClass(className: string): boolean { + return this.classes.includes(className); + } + + /** Convert the fragment into a node. */ + toNode(): Node { + const frag = document.createDocumentFragment(); + + for (let i = 0; i < this.children.length; i++) { + frag.appendChild(this.children[i].toNode()); + } + + return frag; + } + + /** Convert the fragment into HTML markup. */ + toMarkup(): string { + let markup = ""; + + // Simply concatenate the markup for the children together. + for (let i = 0; i < this.children.length; i++) { + markup += this.children[i].toMarkup(); + } + + return markup; + } + + /** + * Converts the math node into a string, similar to innerText. Applies to + * MathDomNode's only. + */ + toText(): string { + return this.children.map((child: ChildType): string => { + if (isMathDomNode(child)) { + return child.toText(); + } + throw new Error( + `Expected MathDomNode with toText, got ${child.constructor.name}`); + }).join(""); + } +} diff --git a/node_modules/katex/src/types/fonts.ts b/node_modules/katex/src/types/fonts.ts new file mode 100644 index 0000000..e4c0872 --- /dev/null +++ b/node_modules/katex/src/types/fonts.ts @@ -0,0 +1,73 @@ +// Math font variants. +export type FontVariant = + | "bold" + | "bold-italic" + | "bold-sans-serif" + | "double-struck" + | "fraktur" + | "italic" + | "monospace" + | "normal" + | "sans-serif" + | "sans-serif-bold-italic" + | "sans-serif-italic" + | "script"; + +export type FontName = + | "AMS-Regular" + | "Caligraphic-Regular" + | "Fraktur-Regular" + | "Main-Bold" + | "Main-BoldItalic" + | "Main-Italic" + | "Main-Regular" + | "Math-BoldItalic" + | "Math-Italic" + | "SansSerif-Regular" + | "SansSerif-Bold" + | "SansSerif-Italic" + | "Script-Regular" + | "Size1-Regular" + | "Size2-Regular" + | "Size3-Regular" + | "Size4-Regular" + | "Typewriter-Regular"; + +//[depth, height, italic, skew, width] +export type CharacterMetricsTuple = [depth: number, height: number, italic: number, skew: number, width: number]; + +export type CharacterMetrics = { + depth: number; + height: number; + italic: number; + skew: number; + width: number; +}; + +export type FontMetrics = { + cssEmPerMu: number; + [key: string]: number; +}; + +export type SymbolFont = "main" | "ams"; + +export type MathFont = + | "" + | "mathrm" + | "mathit" + | "mathbf" + | "mathnormal" + | "mathsfit" + | "mathbb" + | "mathcal" + | "mathfrak" + | "mathscr" + | "mathsf" + | "mathtt" + | "boldsymbol"; + +export type TextFont = "textrm" | "textsf" | "texttt" | "amsrm" | ""; + +// In these types, "" (empty string) means "no change". +export type FontWeight = "textbf" | "textmd" | ""; +export type FontShape = "textit" | "textup" | ""; diff --git a/node_modules/katex/src/types/index.ts b/node_modules/katex/src/types/index.ts new file mode 100644 index 0000000..bde98d1 --- /dev/null +++ b/node_modules/katex/src/types/index.ts @@ -0,0 +1,41 @@ +export type Mode = "math" | "text"; + +// LaTeX argument type. +// - "size": A size-like thing, such as "1em" or "5ex" +// - "color": An html color, like "#abc" or "blue" +// - "url": An url string, in which "\" will be ignored +// - if it precedes [#$%&~_^\{}] +// - "raw": A string, allowing single character, percent sign, +// and nested braces +// - "original": The same type as the environment that the +// function being parsed is in (e.g. used for the +// bodies of functions like \textcolor where the +// first argument is special and the second +// argument is parsed normally) +// - Mode: Node group parsed in given mode. +export type ArgType = "color" | "size" | "url" | "raw" | "original" | "hbox" | + "primitive" | Mode; + +// LaTeX display style. +export type StyleStr = "text" | "display" | "script" | "scriptscript"; + +// Allowable token text for "break" arguments in parser. +export type BreakToken = "]" | "}" | "\\endgroup" | "$" | "\\)" | "\\\\" | "\\end" | + "EOF"; + +export type DelimiterSize = 1 | 2 | 3 | 4; + +export type Slice1 = + S extends `${string}${infer Rest}` ? Rest : ""; + +export type Slice4 = + S extends `${string}${string}${string}${string}${infer Rest}` ? Rest : ""; + +export type Slice5 = + S extends `${string}${string}${string}${string}${string}${infer Rest}` ? Rest : ""; + +export type Measurement = {number: number, unit: string}; + +export type MathClass = "mord" | "mop" | "mbin" | "mrel" | "mopen" | "mclose" | "mpunct" | "minner"; + +export type Side = "left" | "right"; diff --git a/node_modules/katex/src/types/nodes.ts b/node_modules/katex/src/types/nodes.ts new file mode 100644 index 0000000..33ac364 --- /dev/null +++ b/node_modules/katex/src/types/nodes.ts @@ -0,0 +1,456 @@ +import type SourceLocation from "../SourceLocation"; +import type {DelimiterSize, MathClass, Measurement, Mode, Side, StyleStr} from "./index"; +import type {AlignSpec, ColSeparationType} from "../environments/array"; +import type {Atom} from "../atoms"; +import type {MathFont} from "./fonts"; +import type {Token} from "../Token"; + +// ParseNode from `Parser.formatUnsupportedCmd` +export type UnsupportedCmdParseNode = ColorNode; + +export type NodeType = AnyParseNode["type"]; + +export type ParseNode = ParseNodeMap[T]; + +export type AnyParseNode = + | ArrayNode + | CommutativeDiagramLabelNode + | CommutativeDiagramLabelParentNode + | ColorNode + | ColorTokenNode + | OperatorNode + | OrdinaryGroupNode + | RawNode + | SizeNode + | StylingNode + | SupSubNode + | TagNode + | TextNode + | UrlNode + | VerbatimNode + | AtomNode + | MathOrdinaryNode + | TextOrdinaryNode + | SpacingNode + | AccentTokenNode + | OperatorTokenNode + | AccentNode + | AccentUnderNode + | CarriageReturnNode + | DelimiterSizingNode + | EncloseNode + | EnvironmentNode + | FontNode + | GeneralizedFractionNode + | HorizontalBoxNode + | HorizontalBraceNode + | HrefNode + | HtmlNode + | HtmlMathmlNode + | IncludeGraphicsNode + | InfixNode + | InternalNode + | KernNode + | LapNode + | LeftRightNode + | ClosingDelimiterNode + | MathChoiceNode + | MiddleNode + | MathClassNode + | OperatorNameNode + | OverlineNode + | UnderlineNode + | PhantomNode + | VerticalPhantomNode + | PoorMansBoldNode + | RaiseBoxNode + | RuleNode + | SizingNode + | SmashNode + | SqrtNode + | VerticalCenterNode + | ExtensibleArrowNode; + +// ParseNode's corresponding to Symbol `Group`s in symbols.js. +export type SymbolParseNode = + ParseNode<"atom"> | + ParseNode<"accent-token"> | + ParseNode<"mathord"> | + ParseNode<"op-token"> | + ParseNode<"spacing"> | + ParseNode<"textord">; + +type ParseNodeMap = { + [K in NodeType]: Extract; +}; + +type BaseNode = { + mode: Mode; + loc?: SourceLocation | null; +}; + +type ArrayNode = BaseNode & { + type: "array"; + colSeparationType?: ColSeparationType; + hskipBeforeAndAfter?: boolean; + addJot?: boolean; + cols?: AlignSpec[]; + arraystretch: number; + body: AnyParseNode[][]; + // List of rows in the (2D) array. + rowGaps: (Measurement | null)[]; + hLinesBeforeRow: boolean[][]; + // Whether each row should be automatically numbered, or an explicit tag + tags?: (boolean | AnyParseNode[])[]; + leqno?: boolean; +}; + +type CommutativeDiagramLabelNode = BaseNode & { + type: "cdlabel"; + side: Side; + label: AnyParseNode; +}; + +type CommutativeDiagramLabelParentNode = BaseNode & { + type: "cdlabelparent"; + fragment: AnyParseNode; +} + +type ColorNode = BaseNode & { + type: "color"; + color: string; + body: AnyParseNode[]; +} + +type ColorTokenNode = BaseNode & { + type: "color-token"; + color: string; +} + +type OperatorNodeBase = BaseNode & { + type: "op"; + limits: boolean; + alwaysHandleSupSub?: boolean; + suppressBaseShift?: boolean; + parentIsSupSub: boolean; +} + +type OperatorNode = + | OperatorNodeBase & {symbol: true; name: string; body?: never;} + | OperatorNodeBase & {symbol: false; body: AnyParseNode[]; name?: never;} + | OperatorNodeBase & {symbol: false; name: string; body?: never;}; + +type OrdinaryGroupNode = BaseNode & { + type: "ordgroup"; + body: AnyParseNode[]; + semisimple?: boolean; +} + +type RawNode = BaseNode & { + type: "raw"; + string: string; +} + +type SizeNode = BaseNode & { + type: "size"; + value: Measurement; + isBlank: boolean; +} + +type StylingNode = BaseNode & { + type: "styling"; + style: StyleStr; + resetFont?: boolean; + body: AnyParseNode[]; +} + +type SupSubNode = BaseNode & { + type: "supsub"; + base: AnyParseNode | null; +} & ( + | {sup: AnyParseNode; sub?: AnyParseNode;} + | {sup?: AnyParseNode; sub: AnyParseNode;} + ); + +type TagNode = BaseNode & { + type: "tag"; + body: AnyParseNode[]; + tag: AnyParseNode[]; +} + +type TextNode = BaseNode & { + type: "text"; + body: AnyParseNode[]; + font?: string; +} + +type UrlNode = BaseNode & { + type: "url"; + url: string; +} + +type VerbatimNode = BaseNode & { + type: "verb"; + body: string; + star: boolean; +} + +type SymbolNode = BaseNode & { + text: string; +} + +type AtomNode = SymbolNode & { + type: "atom"; + family: Atom; +} + +type MathOrdinaryNode = SymbolNode & { + type: "mathord"; +} + +type TextOrdinaryNode = SymbolNode & { + type: "textord"; +} + +type SpacingNode = SymbolNode & { + type: "spacing"; +} + +type AccentTokenNode = SymbolNode & { + type: "accent-token"; +} + +type OperatorTokenNode = SymbolNode & { + type: "op-token"; +} + +type AccentBaseNode = BaseNode & { + label: string; + isStretchy?: boolean; + isShifty?: boolean; + base: AnyParseNode; +} + +type AccentNode = AccentBaseNode & { + type: "accent"; +} + +type AccentUnderNode = AccentBaseNode & { + type: "accentUnder"; +} + +type CarriageReturnNode = BaseNode & { + type: "cr"; + newLine: boolean; + size: Measurement | null; +} + +type DelimiterSizingNode = BaseNode & { + type: "delimsizing"; + size: DelimiterSize; + mclass: "mopen" | "mclose" | "mrel" | "mord"; + delim: string; +} + +type EncloseNode = BaseNode & { + type: "enclose"; + body: AnyParseNode; + label: string; + backgroundColor?: string; + borderColor?: string; +} + +type EnvironmentNode = BaseNode & { + type: "environment"; + name: string; + nameGroup: AnyParseNode; +} + +type FontNode = BaseNode & { + type: "font"; + font: Exclude; + body: AnyParseNode; +} + +type GeneralizedFractionNode = BaseNode & { + type: "genfrac"; + continued: boolean; + numer: AnyParseNode; + denom: AnyParseNode; + hasBarLine: boolean; + leftDelim: string | null; + rightDelim: string | null; + barSize: Measurement | null; +} + +type HorizontalBoxNode = BaseNode & { + type: "hbox"; + body: AnyParseNode[]; +} + +type HorizontalBraceNode = BaseNode & { + type: "horizBrace"; + label: string; + isOver: boolean; + base: AnyParseNode; +} + +type HrefNode = BaseNode & { + type: "href"; + href: string; + body: AnyParseNode[]; +} + +type HtmlNode = BaseNode & { + type: "html"; + attributes: Record; + body: AnyParseNode[]; +} + +type HtmlMathmlNode = BaseNode & { + type: "htmlmathml"; + html: AnyParseNode[]; + mathml: AnyParseNode[]; +} + +type IncludeGraphicsNode = BaseNode & { + type: "includegraphics"; + alt: string; + width: Measurement; + height: Measurement; + totalheight: Measurement; + src: string; +} + +type InfixNode = BaseNode & { + type: "infix"; + replaceWith: string; + size?: Measurement; + token?: Token; +} + +type InternalNode = BaseNode & { + type: "internal"; +} + +type KernNode = BaseNode & { + type: "kern"; + dimension: Measurement; +} + +type LapNode = BaseNode & { + type: "lap"; + alignment: string; + body: AnyParseNode; +} +type LeftRightNode = BaseNode & { + type: "leftright"; + body: AnyParseNode[]; + left: string; + right: string; + rightColor?: string; +} + +type ClosingDelimiterNode = BaseNode & { + type: "leftright-right"; + delim: string; + color?: string; +} + +type MathChoiceNode = BaseNode & { + type: "mathchoice"; + display: AnyParseNode[]; + text: AnyParseNode[]; + script: AnyParseNode[]; + scriptscript: AnyParseNode[]; +} + +type MiddleNode = BaseNode & { + type: "middle"; + delim: string; +} + +type MathClassNode = BaseNode & { + type: "mclass"; + mclass: MathClass; + body: AnyParseNode[]; + isCharacterBox: boolean; +} + +type OperatorNameNode = BaseNode & { + type: "operatorname"; + body: AnyParseNode[]; + alwaysHandleSupSub: boolean; + limits: boolean; + parentIsSupSub: boolean; +} + +type OverlineNode = BaseNode & { + type: "overline"; + body: AnyParseNode; +} + +type UnderlineNode = BaseNode & { + type: "underline"; + body: AnyParseNode; +} + +type PhantomNode = BaseNode & { + type: "phantom"; + body: AnyParseNode[]; +} + +type VerticalPhantomNode = BaseNode & { + type: "vphantom"; + body: AnyParseNode; +} + +type PoorMansBoldNode = BaseNode & { + type: "pmb"; + mclass: MathClass; + body: AnyParseNode[]; +} + +type RaiseBoxNode = BaseNode & { + type: "raisebox"; + dy: Measurement; + body: AnyParseNode; +} + +type RuleNode = BaseNode & { + type: "rule"; + shift: Measurement | null | undefined; + width: Measurement; + height: Measurement; +} + +type SizingNode = BaseNode & { + type: "sizing"; + size: number; + body: AnyParseNode[]; +} + +type SmashNode = BaseNode & { + type: "smash"; + body: AnyParseNode; + smashHeight: boolean; + smashDepth: boolean; +} + +type SqrtNode = BaseNode & { + type: "sqrt"; + body: AnyParseNode; + index: AnyParseNode | null; +} + +type VerticalCenterNode = BaseNode & { + type: "vcenter"; + body: AnyParseNode; +} + +type ExtensibleArrowNode = BaseNode & { + type: "xArrow"; + label: string; + body: AnyParseNode; + below: AnyParseNode | null; +} diff --git a/node_modules/katex/src/unicodeAccents.js b/node_modules/katex/src/unicodeAccents.js new file mode 100644 index 0000000..3acd07e --- /dev/null +++ b/node_modules/katex/src/unicodeAccents.js @@ -0,0 +1,21 @@ +// Mapping of Unicode accent characters to their LaTeX equivalent in text and +// math mode (when they exist). +// This exports a CommonJS module, allowing to be required in unicodeSymbols +// without transpiling. +/** @type {Record} */ +const unicodeAccents = { + '\u0301': {text: "\\'", math: '\\acute'}, + '\u0300': {text: '\\`', math: '\\grave'}, + '\u0308': {text: '\\"', math: '\\ddot'}, + '\u0303': {text: '\\~', math: '\\tilde'}, + '\u0304': {text: '\\=', math: '\\bar'}, + '\u0306': {text: '\\u', math: '\\breve'}, + '\u030c': {text: '\\v', math: '\\check'}, + '\u0302': {text: '\\^', math: '\\hat'}, + '\u0307': {text: '\\.', math: '\\dot'}, + '\u030a': {text: '\\r', math: '\\mathring'}, + '\u030b': {text: '\\H'}, + '\u0327': {text: '\\c'}, +}; + +module.exports = unicodeAccents; diff --git a/node_modules/katex/src/unicodeScripts.ts b/node_modules/katex/src/unicodeScripts.ts new file mode 100644 index 0000000..316f4d0 --- /dev/null +++ b/node_modules/katex/src/unicodeScripts.ts @@ -0,0 +1,124 @@ +/* + * This file defines the Unicode scripts and script families that we + * support. To add new scripts or families, just add a new entry to the + * scriptData array below. Adding scripts to the scriptData array allows + * characters from that script to appear in \text{} environments. + */ + +/** + * Each script or script family has a name and an array of blocks. + * Each block is an array of two numbers which specify the start and + * end points (inclusive) of a block of Unicode codepoints. + */ +type Script = { + name: string; + blocks: Array>; +}; + +/** + * Unicode block data for the families of scripts we support in \text{}. + * Scripts only need to appear here if they do not have font metrics. + */ +const scriptData: Array + + + +``` + +* [**cdnjs**](https://cdnjs.com/libraries/prop-types) +```html + + + + + +``` + +To load a specific version of `prop-types` replace `15.6.0` with the version number. + +## Usage + +PropTypes was originally exposed as part of the React core module, and is +commonly used with React components. +Here is an example of using PropTypes with a React component, which also +documents the different validators provided: + +```js +import React from 'react'; +import PropTypes from 'prop-types'; + +class MyComponent extends React.Component { + render() { + // ... do things with the props + } +} + +MyComponent.propTypes = { + // You can declare that a prop is a specific JS primitive. By default, these + // are all optional. + optionalArray: PropTypes.array, + optionalBigInt: PropTypes.bigint, + optionalBool: PropTypes.bool, + optionalFunc: PropTypes.func, + optionalNumber: PropTypes.number, + optionalObject: PropTypes.object, + optionalString: PropTypes.string, + optionalSymbol: PropTypes.symbol, + + // Anything that can be rendered: numbers, strings, elements or an array + // (or fragment) containing these types. + // see https://reactjs.org/docs/rendering-elements.html for more info + optionalNode: PropTypes.node, + + // A React element (ie. ). + optionalElement: PropTypes.element, + + // A React element type (eg. MyComponent). + // a function, string, or "element-like" object (eg. React.Fragment, Suspense, etc.) + // see https://github.com/facebook/react/blob/HEAD/packages/shared/isValidElementType.js + optionalElementType: PropTypes.elementType, + + // You can also declare that a prop is an instance of a class. This uses + // JS's instanceof operator. + optionalMessage: PropTypes.instanceOf(Message), + + // You can ensure that your prop is limited to specific values by treating + // it as an enum. + optionalEnum: PropTypes.oneOf(['News', 'Photos']), + + // An object that could be one of many types + optionalUnion: PropTypes.oneOfType([ + PropTypes.string, + PropTypes.number, + PropTypes.instanceOf(Message) + ]), + + // An array of a certain type + optionalArrayOf: PropTypes.arrayOf(PropTypes.number), + + // An object with property values of a certain type + optionalObjectOf: PropTypes.objectOf(PropTypes.number), + + // You can chain any of the above with `isRequired` to make sure a warning + // is shown if the prop isn't provided. + + // An object taking on a particular shape + optionalObjectWithShape: PropTypes.shape({ + optionalProperty: PropTypes.string, + requiredProperty: PropTypes.number.isRequired + }), + + // An object with warnings on extra properties + optionalObjectWithStrictShape: PropTypes.exact({ + optionalProperty: PropTypes.string, + requiredProperty: PropTypes.number.isRequired + }), + + requiredFunc: PropTypes.func.isRequired, + + // A value of any data type + requiredAny: PropTypes.any.isRequired, + + // You can also specify a custom validator. It should return an Error + // object if the validation fails. Don't `console.warn` or throw, as this + // won't work inside `oneOfType`. + customProp: function(props, propName, componentName) { + if (!/matchme/.test(props[propName])) { + return new Error( + 'Invalid prop `' + propName + '` supplied to' + + ' `' + componentName + '`. Validation failed.' + ); + } + }, + + // You can also supply a custom validator to `arrayOf` and `objectOf`. + // It should return an Error object if the validation fails. The validator + // will be called for each key in the array or object. The first two + // arguments of the validator are the array or object itself, and the + // current item's key. + customArrayProp: PropTypes.arrayOf(function(propValue, key, componentName, location, propFullName) { + if (!/matchme/.test(propValue[key])) { + return new Error( + 'Invalid prop `' + propFullName + '` supplied to' + + ' `' + componentName + '`. Validation failed.' + ); + } + }) +}; +``` + +Refer to the [React documentation](https://facebook.github.io/react/docs/typechecking-with-proptypes.html) for more information. + +## Migrating from React.PropTypes + +Check out [Migrating from React.PropTypes](https://facebook.github.io/react/blog/2017/04/07/react-v15.5.0.html#migrating-from-react.proptypes) for details on how to migrate to `prop-types` from `React.PropTypes`. + +Note that this blog posts **mentions a codemod script that performs the conversion automatically**. + +There are also important notes below. + +## How to Depend on This Package? + +For apps, we recommend putting it in `dependencies` with a caret range. +For example: + +```js + "dependencies": { + "prop-types": "^15.5.7" + } +``` + +For libraries, we *also* recommend leaving it in `dependencies`: + +```js + "dependencies": { + "prop-types": "^15.5.7" + }, + "peerDependencies": { + "react": "^15.5.0" + } +``` + +**Note:** there are known issues in versions before 15.5.7 so we recommend using it as the minimal version. + +Make sure that the version range uses a caret (`^`) and thus is broad enough for npm to efficiently deduplicate packages. + +For UMD bundles of your components, make sure you **don’t** include `PropTypes` in the build. Usually this is done by marking it as an external (the specifics depend on your bundler), just like you do with React. + +## Compatibility + +### React 0.14 + +This package is compatible with **React 0.14.9**. Compared to 0.14.8 (which was released in March of 2016), there are no other changes in 0.14.9, so it should be a painless upgrade. + +```shell +# ATTENTION: Only run this if you still use React 0.14! +npm install --save react@^0.14.9 react-dom@^0.14.9 +``` + +### React 15+ + +This package is compatible with **React 15.3.0** and higher. + +``` +npm install --save react@^15.3.0 react-dom@^15.3.0 +``` + +### What happens on other React versions? + +It outputs warnings with the message below even though the developer doesn’t do anything wrong. Unfortunately there is no solution for this other than updating React to either 15.3.0 or higher, or 0.14.9 if you’re using React 0.14. + +## Difference from `React.PropTypes`: Don’t Call Validator Functions + +First of all, **which version of React are you using**? You might be seeing this message because a component library has updated to use `prop-types` package, but your version of React is incompatible with it. See the [above section](#compatibility) for more details. + +Are you using either React 0.14.9 or a version higher than React 15.3.0? Read on. + +When you migrate components to use the standalone `prop-types`, **all validator functions will start throwing an error if you call them directly**. This makes sure that nobody relies on them in production code, and it is safe to strip their implementations to optimize the bundle size. + +Code like this is still fine: + +```js +MyComponent.propTypes = { + myProp: PropTypes.bool +}; +``` + +However, code like this will not work with the `prop-types` package: + +```js +// Will not work with `prop-types` package! +var errorOrNull = PropTypes.bool(42, 'myProp', 'MyComponent', 'prop'); +``` + +It will throw an error: + +``` +Calling PropTypes validators directly is not supported by the `prop-types` package. +Use PropTypes.checkPropTypes() to call them. +``` + +(If you see **a warning** rather than an error with this message, please check the [above section about compatibility](#compatibility).) + +This is new behavior, and you will only encounter it when you migrate from `React.PropTypes` to the `prop-types` package. For the vast majority of components, this doesn’t matter, and if you didn’t see [this warning](https://facebook.github.io/react/warnings/dont-call-proptypes.html) in your components, your code is safe to migrate. This is not a breaking change in React because you are only opting into this change for a component by explicitly changing your imports to use `prop-types`. If you temporarily need the old behavior, you can keep using `React.PropTypes` until React 16. + +**If you absolutely need to trigger the validation manually**, call `PropTypes.checkPropTypes()`. Unlike the validators themselves, this function is safe to call in production, as it will be replaced by an empty function: + +```js +// Works with standalone PropTypes +PropTypes.checkPropTypes(MyComponent.propTypes, props, 'prop', 'MyComponent'); +``` +See below for more info. + +**If you DO want to use validation in production**, you can choose to use the **development version** by importing/requiring `prop-types/prop-types` instead of `prop-types`. + +**You might also see this error** if you’re calling a `PropTypes` validator from your own custom `PropTypes` validator. In this case, the fix is to make sure that you are passing *all* of the arguments to the inner function. There is a more in-depth explanation of how to fix it [on this page](https://facebook.github.io/react/warnings/dont-call-proptypes.html#fixing-the-false-positive-in-third-party-proptypes). Alternatively, you can temporarily keep using `React.PropTypes` until React 16, as it would still only warn in this case. + +If you use a bundler like Browserify or Webpack, don’t forget to [follow these instructions](https://reactjs.org/docs/optimizing-performance.html#use-the-production-build) to correctly bundle your application in development or production mode. Otherwise you’ll ship unnecessary code to your users. + +## PropTypes.checkPropTypes + +React will automatically check the propTypes you set on the component, but if +you are using PropTypes without React then you may want to manually call +`PropTypes.checkPropTypes`, like so: + +```js +const myPropTypes = { + name: PropTypes.string, + age: PropTypes.number, + // ... define your prop validations +}; + +const props = { + name: 'hello', // is valid + age: 'world', // not valid +}; + +// Let's say your component is called 'MyComponent' + +// Works with standalone PropTypes +PropTypes.checkPropTypes(myPropTypes, props, 'prop', 'MyComponent'); +// This will warn as follows: +// Warning: Failed prop type: Invalid prop `age` of type `string` supplied to +// `MyComponent`, expected `number`. +``` + +## PropTypes.resetWarningCache() + +`PropTypes.checkPropTypes(...)` only `console.error`s a given message once. To reset the error warning cache in tests, call `PropTypes.resetWarningCache()` + +### License + +prop-types is [MIT licensed](./LICENSE). diff --git a/node_modules/prop-types/checkPropTypes.js b/node_modules/prop-types/checkPropTypes.js new file mode 100644 index 0000000..481f2cf --- /dev/null +++ b/node_modules/prop-types/checkPropTypes.js @@ -0,0 +1,103 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +'use strict'; + +var printWarning = function() {}; + +if (process.env.NODE_ENV !== 'production') { + var ReactPropTypesSecret = require('./lib/ReactPropTypesSecret'); + var loggedTypeFailures = {}; + var has = require('./lib/has'); + + printWarning = function(text) { + var message = 'Warning: ' + text; + if (typeof console !== 'undefined') { + console.error(message); + } + try { + // --- Welcome to debugging React --- + // This error was thrown as a convenience so that you can use this stack + // to find the callsite that caused this warning to fire. + throw new Error(message); + } catch (x) { /**/ } + }; +} + +/** + * Assert that the values match with the type specs. + * Error messages are memorized and will only be shown once. + * + * @param {object} typeSpecs Map of name to a ReactPropType + * @param {object} values Runtime values that need to be type-checked + * @param {string} location e.g. "prop", "context", "child context" + * @param {string} componentName Name of the component for error messages. + * @param {?Function} getStack Returns the component stack. + * @private + */ +function checkPropTypes(typeSpecs, values, location, componentName, getStack) { + if (process.env.NODE_ENV !== 'production') { + for (var typeSpecName in typeSpecs) { + if (has(typeSpecs, typeSpecName)) { + var error; + // Prop type validation may throw. In case they do, we don't want to + // fail the render phase where it didn't fail before. So we log it. + // After these have been cleaned up, we'll let them throw. + try { + // This is intentionally an invariant that gets caught. It's the same + // behavior as without this statement except with a better message. + if (typeof typeSpecs[typeSpecName] !== 'function') { + var err = Error( + (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + + 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.' + ); + err.name = 'Invariant Violation'; + throw err; + } + error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret); + } catch (ex) { + error = ex; + } + if (error && !(error instanceof Error)) { + printWarning( + (componentName || 'React class') + ': type specification of ' + + location + ' `' + typeSpecName + '` is invalid; the type checker ' + + 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' + + 'You may have forgotten to pass an argument to the type checker ' + + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + + 'shape all require an argument).' + ); + } + if (error instanceof Error && !(error.message in loggedTypeFailures)) { + // Only monitor this failure once because there tends to be a lot of the + // same error. + loggedTypeFailures[error.message] = true; + + var stack = getStack ? getStack() : ''; + + printWarning( + 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '') + ); + } + } + } + } +} + +/** + * Resets warning cache when testing. + * + * @private + */ +checkPropTypes.resetWarningCache = function() { + if (process.env.NODE_ENV !== 'production') { + loggedTypeFailures = {}; + } +} + +module.exports = checkPropTypes; diff --git a/node_modules/prop-types/factory.js b/node_modules/prop-types/factory.js new file mode 100644 index 0000000..abdf8e6 --- /dev/null +++ b/node_modules/prop-types/factory.js @@ -0,0 +1,19 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +'use strict'; + +// React 15.5 references this module, and assumes PropTypes are still callable in production. +// Therefore we re-export development-only version with all the PropTypes checks here. +// However if one is migrating to the `prop-types` npm library, they will go through the +// `index.js` entry point, and it will branch depending on the environment. +var factory = require('./factoryWithTypeCheckers'); +module.exports = function(isValidElement) { + // It is still allowed in 15.5. + var throwOnDirectAccess = false; + return factory(isValidElement, throwOnDirectAccess); +}; diff --git a/node_modules/prop-types/factoryWithThrowingShims.js b/node_modules/prop-types/factoryWithThrowingShims.js new file mode 100644 index 0000000..ac88267 --- /dev/null +++ b/node_modules/prop-types/factoryWithThrowingShims.js @@ -0,0 +1,65 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +'use strict'; + +var ReactPropTypesSecret = require('./lib/ReactPropTypesSecret'); + +function emptyFunction() {} +function emptyFunctionWithReset() {} +emptyFunctionWithReset.resetWarningCache = emptyFunction; + +module.exports = function() { + function shim(props, propName, componentName, location, propFullName, secret) { + if (secret === ReactPropTypesSecret) { + // It is still safe when called from React. + return; + } + var err = new Error( + 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' + + 'Use PropTypes.checkPropTypes() to call them. ' + + 'Read more at http://fb.me/use-check-prop-types' + ); + err.name = 'Invariant Violation'; + throw err; + }; + shim.isRequired = shim; + function getShim() { + return shim; + }; + // Important! + // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`. + var ReactPropTypes = { + array: shim, + bigint: shim, + bool: shim, + func: shim, + number: shim, + object: shim, + string: shim, + symbol: shim, + + any: shim, + arrayOf: getShim, + element: shim, + elementType: shim, + instanceOf: getShim, + node: shim, + objectOf: getShim, + oneOf: getShim, + oneOfType: getShim, + shape: getShim, + exact: getShim, + + checkPropTypes: emptyFunctionWithReset, + resetWarningCache: emptyFunction + }; + + ReactPropTypes.PropTypes = ReactPropTypes; + + return ReactPropTypes; +}; diff --git a/node_modules/prop-types/factoryWithTypeCheckers.js b/node_modules/prop-types/factoryWithTypeCheckers.js new file mode 100644 index 0000000..a88068e --- /dev/null +++ b/node_modules/prop-types/factoryWithTypeCheckers.js @@ -0,0 +1,610 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +'use strict'; + +var ReactIs = require('react-is'); +var assign = require('object-assign'); + +var ReactPropTypesSecret = require('./lib/ReactPropTypesSecret'); +var has = require('./lib/has'); +var checkPropTypes = require('./checkPropTypes'); + +var printWarning = function() {}; + +if (process.env.NODE_ENV !== 'production') { + printWarning = function(text) { + var message = 'Warning: ' + text; + if (typeof console !== 'undefined') { + console.error(message); + } + try { + // --- Welcome to debugging React --- + // This error was thrown as a convenience so that you can use this stack + // to find the callsite that caused this warning to fire. + throw new Error(message); + } catch (x) {} + }; +} + +function emptyFunctionThatReturnsNull() { + return null; +} + +module.exports = function(isValidElement, throwOnDirectAccess) { + /* global Symbol */ + var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; + var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec. + + /** + * Returns the iterator method function contained on the iterable object. + * + * Be sure to invoke the function with the iterable as context: + * + * var iteratorFn = getIteratorFn(myIterable); + * if (iteratorFn) { + * var iterator = iteratorFn.call(myIterable); + * ... + * } + * + * @param {?object} maybeIterable + * @return {?function} + */ + function getIteratorFn(maybeIterable) { + var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]); + if (typeof iteratorFn === 'function') { + return iteratorFn; + } + } + + /** + * Collection of methods that allow declaration and validation of props that are + * supplied to React components. Example usage: + * + * var Props = require('ReactPropTypes'); + * var MyArticle = React.createClass({ + * propTypes: { + * // An optional string prop named "description". + * description: Props.string, + * + * // A required enum prop named "category". + * category: Props.oneOf(['News','Photos']).isRequired, + * + * // A prop named "dialog" that requires an instance of Dialog. + * dialog: Props.instanceOf(Dialog).isRequired + * }, + * render: function() { ... } + * }); + * + * A more formal specification of how these methods are used: + * + * type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...) + * decl := ReactPropTypes.{type}(.isRequired)? + * + * Each and every declaration produces a function with the same signature. This + * allows the creation of custom validation functions. For example: + * + * var MyLink = React.createClass({ + * propTypes: { + * // An optional string or URI prop named "href". + * href: function(props, propName, componentName) { + * var propValue = props[propName]; + * if (propValue != null && typeof propValue !== 'string' && + * !(propValue instanceof URI)) { + * return new Error( + * 'Expected a string or an URI for ' + propName + ' in ' + + * componentName + * ); + * } + * } + * }, + * render: function() {...} + * }); + * + * @internal + */ + + var ANONYMOUS = '<>'; + + // Important! + // Keep this list in sync with production version in `./factoryWithThrowingShims.js`. + var ReactPropTypes = { + array: createPrimitiveTypeChecker('array'), + bigint: createPrimitiveTypeChecker('bigint'), + bool: createPrimitiveTypeChecker('boolean'), + func: createPrimitiveTypeChecker('function'), + number: createPrimitiveTypeChecker('number'), + object: createPrimitiveTypeChecker('object'), + string: createPrimitiveTypeChecker('string'), + symbol: createPrimitiveTypeChecker('symbol'), + + any: createAnyTypeChecker(), + arrayOf: createArrayOfTypeChecker, + element: createElementTypeChecker(), + elementType: createElementTypeTypeChecker(), + instanceOf: createInstanceTypeChecker, + node: createNodeChecker(), + objectOf: createObjectOfTypeChecker, + oneOf: createEnumTypeChecker, + oneOfType: createUnionTypeChecker, + shape: createShapeTypeChecker, + exact: createStrictShapeTypeChecker, + }; + + /** + * inlined Object.is polyfill to avoid requiring consumers ship their own + * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is + */ + /*eslint-disable no-self-compare*/ + function is(x, y) { + // SameValue algorithm + if (x === y) { + // Steps 1-5, 7-10 + // Steps 6.b-6.e: +0 != -0 + return x !== 0 || 1 / x === 1 / y; + } else { + // Step 6.a: NaN == NaN + return x !== x && y !== y; + } + } + /*eslint-enable no-self-compare*/ + + /** + * We use an Error-like object for backward compatibility as people may call + * PropTypes directly and inspect their output. However, we don't use real + * Errors anymore. We don't inspect their stack anyway, and creating them + * is prohibitively expensive if they are created too often, such as what + * happens in oneOfType() for any type before the one that matched. + */ + function PropTypeError(message, data) { + this.message = message; + this.data = data && typeof data === 'object' ? data: {}; + this.stack = ''; + } + // Make `instanceof Error` still work for returned errors. + PropTypeError.prototype = Error.prototype; + + function createChainableTypeChecker(validate) { + if (process.env.NODE_ENV !== 'production') { + var manualPropTypeCallCache = {}; + var manualPropTypeWarningCount = 0; + } + function checkType(isRequired, props, propName, componentName, location, propFullName, secret) { + componentName = componentName || ANONYMOUS; + propFullName = propFullName || propName; + + if (secret !== ReactPropTypesSecret) { + if (throwOnDirectAccess) { + // New behavior only for users of `prop-types` package + var err = new Error( + 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' + + 'Use `PropTypes.checkPropTypes()` to call them. ' + + 'Read more at http://fb.me/use-check-prop-types' + ); + err.name = 'Invariant Violation'; + throw err; + } else if (process.env.NODE_ENV !== 'production' && typeof console !== 'undefined') { + // Old behavior for people using React.PropTypes + var cacheKey = componentName + ':' + propName; + if ( + !manualPropTypeCallCache[cacheKey] && + // Avoid spamming the console because they are often not actionable except for lib authors + manualPropTypeWarningCount < 3 + ) { + printWarning( + 'You are manually calling a React.PropTypes validation ' + + 'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' + + 'and will throw in the standalone `prop-types` package. ' + + 'You may be seeing this warning due to a third-party PropTypes ' + + 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.' + ); + manualPropTypeCallCache[cacheKey] = true; + manualPropTypeWarningCount++; + } + } + } + if (props[propName] == null) { + if (isRequired) { + if (props[propName] === null) { + return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.')); + } + return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.')); + } + return null; + } else { + return validate(props, propName, componentName, location, propFullName); + } + } + + var chainedCheckType = checkType.bind(null, false); + chainedCheckType.isRequired = checkType.bind(null, true); + + return chainedCheckType; + } + + function createPrimitiveTypeChecker(expectedType) { + function validate(props, propName, componentName, location, propFullName, secret) { + var propValue = props[propName]; + var propType = getPropType(propValue); + if (propType !== expectedType) { + // `propValue` being instance of, say, date/regexp, pass the 'object' + // check, but we can offer a more precise error message here rather than + // 'of type `object`'. + var preciseType = getPreciseType(propValue); + + return new PropTypeError( + 'Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'), + {expectedType: expectedType} + ); + } + return null; + } + return createChainableTypeChecker(validate); + } + + function createAnyTypeChecker() { + return createChainableTypeChecker(emptyFunctionThatReturnsNull); + } + + function createArrayOfTypeChecker(typeChecker) { + function validate(props, propName, componentName, location, propFullName) { + if (typeof typeChecker !== 'function') { + return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.'); + } + var propValue = props[propName]; + if (!Array.isArray(propValue)) { + var propType = getPropType(propValue); + return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.')); + } + for (var i = 0; i < propValue.length; i++) { + var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret); + if (error instanceof Error) { + return error; + } + } + return null; + } + return createChainableTypeChecker(validate); + } + + function createElementTypeChecker() { + function validate(props, propName, componentName, location, propFullName) { + var propValue = props[propName]; + if (!isValidElement(propValue)) { + var propType = getPropType(propValue); + return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.')); + } + return null; + } + return createChainableTypeChecker(validate); + } + + function createElementTypeTypeChecker() { + function validate(props, propName, componentName, location, propFullName) { + var propValue = props[propName]; + if (!ReactIs.isValidElementType(propValue)) { + var propType = getPropType(propValue); + return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement type.')); + } + return null; + } + return createChainableTypeChecker(validate); + } + + function createInstanceTypeChecker(expectedClass) { + function validate(props, propName, componentName, location, propFullName) { + if (!(props[propName] instanceof expectedClass)) { + var expectedClassName = expectedClass.name || ANONYMOUS; + var actualClassName = getClassName(props[propName]); + return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.')); + } + return null; + } + return createChainableTypeChecker(validate); + } + + function createEnumTypeChecker(expectedValues) { + if (!Array.isArray(expectedValues)) { + if (process.env.NODE_ENV !== 'production') { + if (arguments.length > 1) { + printWarning( + 'Invalid arguments supplied to oneOf, expected an array, got ' + arguments.length + ' arguments. ' + + 'A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).' + ); + } else { + printWarning('Invalid argument supplied to oneOf, expected an array.'); + } + } + return emptyFunctionThatReturnsNull; + } + + function validate(props, propName, componentName, location, propFullName) { + var propValue = props[propName]; + for (var i = 0; i < expectedValues.length; i++) { + if (is(propValue, expectedValues[i])) { + return null; + } + } + + var valuesString = JSON.stringify(expectedValues, function replacer(key, value) { + var type = getPreciseType(value); + if (type === 'symbol') { + return String(value); + } + return value; + }); + return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + String(propValue) + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.')); + } + return createChainableTypeChecker(validate); + } + + function createObjectOfTypeChecker(typeChecker) { + function validate(props, propName, componentName, location, propFullName) { + if (typeof typeChecker !== 'function') { + return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.'); + } + var propValue = props[propName]; + var propType = getPropType(propValue); + if (propType !== 'object') { + return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.')); + } + for (var key in propValue) { + if (has(propValue, key)) { + var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret); + if (error instanceof Error) { + return error; + } + } + } + return null; + } + return createChainableTypeChecker(validate); + } + + function createUnionTypeChecker(arrayOfTypeCheckers) { + if (!Array.isArray(arrayOfTypeCheckers)) { + process.env.NODE_ENV !== 'production' ? printWarning('Invalid argument supplied to oneOfType, expected an instance of array.') : void 0; + return emptyFunctionThatReturnsNull; + } + + for (var i = 0; i < arrayOfTypeCheckers.length; i++) { + var checker = arrayOfTypeCheckers[i]; + if (typeof checker !== 'function') { + printWarning( + 'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' + + 'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.' + ); + return emptyFunctionThatReturnsNull; + } + } + + function validate(props, propName, componentName, location, propFullName) { + var expectedTypes = []; + for (var i = 0; i < arrayOfTypeCheckers.length; i++) { + var checker = arrayOfTypeCheckers[i]; + var checkerResult = checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret); + if (checkerResult == null) { + return null; + } + if (checkerResult.data && has(checkerResult.data, 'expectedType')) { + expectedTypes.push(checkerResult.data.expectedType); + } + } + var expectedTypesMessage = (expectedTypes.length > 0) ? ', expected one of type [' + expectedTypes.join(', ') + ']': ''; + return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`' + expectedTypesMessage + '.')); + } + return createChainableTypeChecker(validate); + } + + function createNodeChecker() { + function validate(props, propName, componentName, location, propFullName) { + if (!isNode(props[propName])) { + return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.')); + } + return null; + } + return createChainableTypeChecker(validate); + } + + function invalidValidatorError(componentName, location, propFullName, key, type) { + return new PropTypeError( + (componentName || 'React class') + ': ' + location + ' type `' + propFullName + '.' + key + '` is invalid; ' + + 'it must be a function, usually from the `prop-types` package, but received `' + type + '`.' + ); + } + + function createShapeTypeChecker(shapeTypes) { + function validate(props, propName, componentName, location, propFullName) { + var propValue = props[propName]; + var propType = getPropType(propValue); + if (propType !== 'object') { + return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.')); + } + for (var key in shapeTypes) { + var checker = shapeTypes[key]; + if (typeof checker !== 'function') { + return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker)); + } + var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret); + if (error) { + return error; + } + } + return null; + } + return createChainableTypeChecker(validate); + } + + function createStrictShapeTypeChecker(shapeTypes) { + function validate(props, propName, componentName, location, propFullName) { + var propValue = props[propName]; + var propType = getPropType(propValue); + if (propType !== 'object') { + return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.')); + } + // We need to check all keys in case some are required but missing from props. + var allKeys = assign({}, props[propName], shapeTypes); + for (var key in allKeys) { + var checker = shapeTypes[key]; + if (has(shapeTypes, key) && typeof checker !== 'function') { + return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker)); + } + if (!checker) { + return new PropTypeError( + 'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' + + '\nBad object: ' + JSON.stringify(props[propName], null, ' ') + + '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ') + ); + } + var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret); + if (error) { + return error; + } + } + return null; + } + + return createChainableTypeChecker(validate); + } + + function isNode(propValue) { + switch (typeof propValue) { + case 'number': + case 'string': + case 'undefined': + return true; + case 'boolean': + return !propValue; + case 'object': + if (Array.isArray(propValue)) { + return propValue.every(isNode); + } + if (propValue === null || isValidElement(propValue)) { + return true; + } + + var iteratorFn = getIteratorFn(propValue); + if (iteratorFn) { + var iterator = iteratorFn.call(propValue); + var step; + if (iteratorFn !== propValue.entries) { + while (!(step = iterator.next()).done) { + if (!isNode(step.value)) { + return false; + } + } + } else { + // Iterator will provide entry [k,v] tuples rather than values. + while (!(step = iterator.next()).done) { + var entry = step.value; + if (entry) { + if (!isNode(entry[1])) { + return false; + } + } + } + } + } else { + return false; + } + + return true; + default: + return false; + } + } + + function isSymbol(propType, propValue) { + // Native Symbol. + if (propType === 'symbol') { + return true; + } + + // falsy value can't be a Symbol + if (!propValue) { + return false; + } + + // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol' + if (propValue['@@toStringTag'] === 'Symbol') { + return true; + } + + // Fallback for non-spec compliant Symbols which are polyfilled. + if (typeof Symbol === 'function' && propValue instanceof Symbol) { + return true; + } + + return false; + } + + // Equivalent of `typeof` but with special handling for array and regexp. + function getPropType(propValue) { + var propType = typeof propValue; + if (Array.isArray(propValue)) { + return 'array'; + } + if (propValue instanceof RegExp) { + // Old webkits (at least until Android 4.0) return 'function' rather than + // 'object' for typeof a RegExp. We'll normalize this here so that /bla/ + // passes PropTypes.object. + return 'object'; + } + if (isSymbol(propType, propValue)) { + return 'symbol'; + } + return propType; + } + + // This handles more types than `getPropType`. Only used for error messages. + // See `createPrimitiveTypeChecker`. + function getPreciseType(propValue) { + if (typeof propValue === 'undefined' || propValue === null) { + return '' + propValue; + } + var propType = getPropType(propValue); + if (propType === 'object') { + if (propValue instanceof Date) { + return 'date'; + } else if (propValue instanceof RegExp) { + return 'regexp'; + } + } + return propType; + } + + // Returns a string that is postfixed to a warning about an invalid type. + // For example, "undefined" or "of type array" + function getPostfixForTypeWarning(value) { + var type = getPreciseType(value); + switch (type) { + case 'array': + case 'object': + return 'an ' + type; + case 'boolean': + case 'date': + case 'regexp': + return 'a ' + type; + default: + return type; + } + } + + // Returns class name of the object, if any. + function getClassName(propValue) { + if (!propValue.constructor || !propValue.constructor.name) { + return ANONYMOUS; + } + return propValue.constructor.name; + } + + ReactPropTypes.checkPropTypes = checkPropTypes; + ReactPropTypes.resetWarningCache = checkPropTypes.resetWarningCache; + ReactPropTypes.PropTypes = ReactPropTypes; + + return ReactPropTypes; +}; diff --git a/node_modules/prop-types/index.js b/node_modules/prop-types/index.js new file mode 100644 index 0000000..e9ef51d --- /dev/null +++ b/node_modules/prop-types/index.js @@ -0,0 +1,19 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +if (process.env.NODE_ENV !== 'production') { + var ReactIs = require('react-is'); + + // By explicitly using `prop-types` you are opting into new development behavior. + // http://fb.me/prop-types-in-prod + var throwOnDirectAccess = true; + module.exports = require('./factoryWithTypeCheckers')(ReactIs.isElement, throwOnDirectAccess); +} else { + // By explicitly using `prop-types` you are opting into new production behavior. + // http://fb.me/prop-types-in-prod + module.exports = require('./factoryWithThrowingShims')(); +} diff --git a/node_modules/prop-types/lib/ReactPropTypesSecret.js b/node_modules/prop-types/lib/ReactPropTypesSecret.js new file mode 100644 index 0000000..f54525e --- /dev/null +++ b/node_modules/prop-types/lib/ReactPropTypesSecret.js @@ -0,0 +1,12 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +'use strict'; + +var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'; + +module.exports = ReactPropTypesSecret; diff --git a/node_modules/prop-types/lib/has.js b/node_modules/prop-types/lib/has.js new file mode 100644 index 0000000..007bae3 --- /dev/null +++ b/node_modules/prop-types/lib/has.js @@ -0,0 +1 @@ +module.exports = Function.call.bind(Object.prototype.hasOwnProperty); diff --git a/node_modules/prop-types/package.json b/node_modules/prop-types/package.json new file mode 100644 index 0000000..63daf70 --- /dev/null +++ b/node_modules/prop-types/package.json @@ -0,0 +1,60 @@ +{ + "name": "prop-types", + "version": "15.8.1", + "description": "Runtime type checking for React props and similar objects.", + "sideEffects": false, + "main": "index.js", + "license": "MIT", + "files": [ + "LICENSE", + "README.md", + "checkPropTypes.js", + "factory.js", + "factoryWithThrowingShims.js", + "factoryWithTypeCheckers.js", + "index.js", + "prop-types.js", + "prop-types.min.js", + "lib" + ], + "repository": "facebook/prop-types", + "keywords": [ + "react" + ], + "bugs": { + "url": "https://github.com/facebook/prop-types/issues" + }, + "homepage": "https://facebook.github.io/react/", + "dependencies": { + "loose-envify": "^1.4.0", + "object-assign": "^4.1.1", + "react-is": "^16.13.1" + }, + "scripts": { + "pretest": "npm run lint", + "lint": "eslint .", + "test": "npm run tests-only", + "tests-only": "jest", + "umd": "NODE_ENV=development browserify index.js -t loose-envify --standalone PropTypes -o prop-types.js", + "umd-min": "NODE_ENV=production browserify index.js -t loose-envify -t uglifyify --standalone PropTypes -p bundle-collapser/plugin -o | uglifyjs --compress unused,dead_code -o prop-types.min.js", + "build": "yarn umd && yarn umd-min", + "prepublish": "not-in-publish || yarn build" + }, + "devDependencies": { + "babel-jest": "^19.0.0", + "babel-preset-react": "^6.24.1", + "browserify": "^16.5.0", + "bundle-collapser": "^1.4.0", + "eslint": "^8.6.0", + "in-publish": "^2.0.1", + "jest": "^19.0.2", + "react": "^15.7.0", + "uglifyify": "^5.0.2", + "uglifyjs": "^2.4.11" + }, + "browserify": { + "transform": [ + "loose-envify" + ] + } +} diff --git a/node_modules/prop-types/prop-types.js b/node_modules/prop-types/prop-types.js new file mode 100644 index 0000000..a5a15dd --- /dev/null +++ b/node_modules/prop-types/prop-types.js @@ -0,0 +1,1315 @@ +(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.PropTypes = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i 1) { + printWarning( + 'Invalid arguments supplied to oneOf, expected an array, got ' + arguments.length + ' arguments. ' + + 'A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).' + ); + } else { + printWarning('Invalid argument supplied to oneOf, expected an array.'); + } + } + return emptyFunctionThatReturnsNull; + } + + function validate(props, propName, componentName, location, propFullName) { + var propValue = props[propName]; + for (var i = 0; i < expectedValues.length; i++) { + if (is(propValue, expectedValues[i])) { + return null; + } + } + + var valuesString = JSON.stringify(expectedValues, function replacer(key, value) { + var type = getPreciseType(value); + if (type === 'symbol') { + return String(value); + } + return value; + }); + return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + String(propValue) + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.')); + } + return createChainableTypeChecker(validate); + } + + function createObjectOfTypeChecker(typeChecker) { + function validate(props, propName, componentName, location, propFullName) { + if (typeof typeChecker !== 'function') { + return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.'); + } + var propValue = props[propName]; + var propType = getPropType(propValue); + if (propType !== 'object') { + return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.')); + } + for (var key in propValue) { + if (has(propValue, key)) { + var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret); + if (error instanceof Error) { + return error; + } + } + } + return null; + } + return createChainableTypeChecker(validate); + } + + function createUnionTypeChecker(arrayOfTypeCheckers) { + if (!Array.isArray(arrayOfTypeCheckers)) { + "development" !== 'production' ? printWarning('Invalid argument supplied to oneOfType, expected an instance of array.') : void 0; + return emptyFunctionThatReturnsNull; + } + + for (var i = 0; i < arrayOfTypeCheckers.length; i++) { + var checker = arrayOfTypeCheckers[i]; + if (typeof checker !== 'function') { + printWarning( + 'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' + + 'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.' + ); + return emptyFunctionThatReturnsNull; + } + } + + function validate(props, propName, componentName, location, propFullName) { + var expectedTypes = []; + for (var i = 0; i < arrayOfTypeCheckers.length; i++) { + var checker = arrayOfTypeCheckers[i]; + var checkerResult = checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret); + if (checkerResult == null) { + return null; + } + if (checkerResult.data.hasOwnProperty('expectedType')) { + expectedTypes.push(checkerResult.data.expectedType); + } + } + var expectedTypesMessage = (expectedTypes.length > 0) ? ', expected one of type [' + expectedTypes.join(', ') + ']': ''; + return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`' + expectedTypesMessage + '.')); + } + return createChainableTypeChecker(validate); + } + + function createNodeChecker() { + function validate(props, propName, componentName, location, propFullName) { + if (!isNode(props[propName])) { + return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.')); + } + return null; + } + return createChainableTypeChecker(validate); + } + + function invalidValidatorError(componentName, location, propFullName, key, type) { + return new PropTypeError( + (componentName || 'React class') + ': ' + location + ' type `' + propFullName + '.' + key + '` is invalid; ' + + 'it must be a function, usually from the `prop-types` package, but received `' + type + '`.' + ); + } + + function createShapeTypeChecker(shapeTypes) { + function validate(props, propName, componentName, location, propFullName) { + var propValue = props[propName]; + var propType = getPropType(propValue); + if (propType !== 'object') { + return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.')); + } + for (var key in shapeTypes) { + var checker = shapeTypes[key]; + if (typeof checker !== 'function') { + return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker)); + } + var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret); + if (error) { + return error; + } + } + return null; + } + return createChainableTypeChecker(validate); + } + + function createStrictShapeTypeChecker(shapeTypes) { + function validate(props, propName, componentName, location, propFullName) { + var propValue = props[propName]; + var propType = getPropType(propValue); + if (propType !== 'object') { + return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.')); + } + // We need to check all keys in case some are required but missing from props. + var allKeys = assign({}, props[propName], shapeTypes); + for (var key in allKeys) { + var checker = shapeTypes[key]; + if (has(shapeTypes, key) && typeof checker !== 'function') { + return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker)); + } + if (!checker) { + return new PropTypeError( + 'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' + + '\nBad object: ' + JSON.stringify(props[propName], null, ' ') + + '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ') + ); + } + var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret); + if (error) { + return error; + } + } + return null; + } + + return createChainableTypeChecker(validate); + } + + function isNode(propValue) { + switch (typeof propValue) { + case 'number': + case 'string': + case 'undefined': + return true; + case 'boolean': + return !propValue; + case 'object': + if (Array.isArray(propValue)) { + return propValue.every(isNode); + } + if (propValue === null || isValidElement(propValue)) { + return true; + } + + var iteratorFn = getIteratorFn(propValue); + if (iteratorFn) { + var iterator = iteratorFn.call(propValue); + var step; + if (iteratorFn !== propValue.entries) { + while (!(step = iterator.next()).done) { + if (!isNode(step.value)) { + return false; + } + } + } else { + // Iterator will provide entry [k,v] tuples rather than values. + while (!(step = iterator.next()).done) { + var entry = step.value; + if (entry) { + if (!isNode(entry[1])) { + return false; + } + } + } + } + } else { + return false; + } + + return true; + default: + return false; + } + } + + function isSymbol(propType, propValue) { + // Native Symbol. + if (propType === 'symbol') { + return true; + } + + // falsy value can't be a Symbol + if (!propValue) { + return false; + } + + // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol' + if (propValue['@@toStringTag'] === 'Symbol') { + return true; + } + + // Fallback for non-spec compliant Symbols which are polyfilled. + if (typeof Symbol === 'function' && propValue instanceof Symbol) { + return true; + } + + return false; + } + + // Equivalent of `typeof` but with special handling for array and regexp. + function getPropType(propValue) { + var propType = typeof propValue; + if (Array.isArray(propValue)) { + return 'array'; + } + if (propValue instanceof RegExp) { + // Old webkits (at least until Android 4.0) return 'function' rather than + // 'object' for typeof a RegExp. We'll normalize this here so that /bla/ + // passes PropTypes.object. + return 'object'; + } + if (isSymbol(propType, propValue)) { + return 'symbol'; + } + return propType; + } + + // This handles more types than `getPropType`. Only used for error messages. + // See `createPrimitiveTypeChecker`. + function getPreciseType(propValue) { + if (typeof propValue === 'undefined' || propValue === null) { + return '' + propValue; + } + var propType = getPropType(propValue); + if (propType === 'object') { + if (propValue instanceof Date) { + return 'date'; + } else if (propValue instanceof RegExp) { + return 'regexp'; + } + } + return propType; + } + + // Returns a string that is postfixed to a warning about an invalid type. + // For example, "undefined" or "of type array" + function getPostfixForTypeWarning(value) { + var type = getPreciseType(value); + switch (type) { + case 'array': + case 'object': + return 'an ' + type; + case 'boolean': + case 'date': + case 'regexp': + return 'a ' + type; + default: + return type; + } + } + + // Returns class name of the object, if any. + function getClassName(propValue) { + if (!propValue.constructor || !propValue.constructor.name) { + return ANONYMOUS; + } + return propValue.constructor.name; + } + + ReactPropTypes.checkPropTypes = checkPropTypes; + ReactPropTypes.resetWarningCache = checkPropTypes.resetWarningCache; + ReactPropTypes.PropTypes = ReactPropTypes; + + return ReactPropTypes; +}; + +},{"./checkPropTypes":1,"./lib/ReactPropTypesSecret":5,"./lib/has":6,"object-assign":7,"react-is":11}],4:[function(require,module,exports){ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +if ("development" !== 'production') { + var ReactIs = require('react-is'); + + // By explicitly using `prop-types` you are opting into new development behavior. + // http://fb.me/prop-types-in-prod + var throwOnDirectAccess = true; + module.exports = require('./factoryWithTypeCheckers')(ReactIs.isElement, throwOnDirectAccess); +} else { + // By explicitly using `prop-types` you are opting into new production behavior. + // http://fb.me/prop-types-in-prod + module.exports = require('./factoryWithThrowingShims')(); +} + +},{"./factoryWithThrowingShims":2,"./factoryWithTypeCheckers":3,"react-is":11}],5:[function(require,module,exports){ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +'use strict'; + +var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'; + +module.exports = ReactPropTypesSecret; + +},{}],6:[function(require,module,exports){ +module.exports = Function.call.bind(Object.prototype.hasOwnProperty); + +},{}],7:[function(require,module,exports){ +/* +object-assign +(c) Sindre Sorhus +@license MIT +*/ + +'use strict'; +/* eslint-disable no-unused-vars */ +var getOwnPropertySymbols = Object.getOwnPropertySymbols; +var hasOwnProperty = Object.prototype.hasOwnProperty; +var propIsEnumerable = Object.prototype.propertyIsEnumerable; + +function toObject(val) { + if (val === null || val === undefined) { + throw new TypeError('Object.assign cannot be called with null or undefined'); + } + + return Object(val); +} + +function shouldUseNative() { + try { + if (!Object.assign) { + return false; + } + + // Detect buggy property enumeration order in older V8 versions. + + // https://bugs.chromium.org/p/v8/issues/detail?id=4118 + var test1 = new String('abc'); // eslint-disable-line no-new-wrappers + test1[5] = 'de'; + if (Object.getOwnPropertyNames(test1)[0] === '5') { + return false; + } + + // https://bugs.chromium.org/p/v8/issues/detail?id=3056 + var test2 = {}; + for (var i = 0; i < 10; i++) { + test2['_' + String.fromCharCode(i)] = i; + } + var order2 = Object.getOwnPropertyNames(test2).map(function (n) { + return test2[n]; + }); + if (order2.join('') !== '0123456789') { + return false; + } + + // https://bugs.chromium.org/p/v8/issues/detail?id=3056 + var test3 = {}; + 'abcdefghijklmnopqrst'.split('').forEach(function (letter) { + test3[letter] = letter; + }); + if (Object.keys(Object.assign({}, test3)).join('') !== + 'abcdefghijklmnopqrst') { + return false; + } + + return true; + } catch (err) { + // We don't expect any of the above to throw, but better to be safe. + return false; + } +} + +module.exports = shouldUseNative() ? Object.assign : function (target, source) { + var from; + var to = toObject(target); + var symbols; + + for (var s = 1; s < arguments.length; s++) { + from = Object(arguments[s]); + + for (var key in from) { + if (hasOwnProperty.call(from, key)) { + to[key] = from[key]; + } + } + + if (getOwnPropertySymbols) { + symbols = getOwnPropertySymbols(from); + for (var i = 0; i < symbols.length; i++) { + if (propIsEnumerable.call(from, symbols[i])) { + to[symbols[i]] = from[symbols[i]]; + } + } + } + } + + return to; +}; + +},{}],8:[function(require,module,exports){ +// shim for using process in browser +var process = module.exports = {}; + +// cached from whatever global is present so that test runners that stub it +// don't break things. But we need to wrap it in a try catch in case it is +// wrapped in strict mode code which doesn't define any globals. It's inside a +// function because try/catches deoptimize in certain engines. + +var cachedSetTimeout; +var cachedClearTimeout; + +function defaultSetTimout() { + throw new Error('setTimeout has not been defined'); +} +function defaultClearTimeout () { + throw new Error('clearTimeout has not been defined'); +} +(function () { + try { + if (typeof setTimeout === 'function') { + cachedSetTimeout = setTimeout; + } else { + cachedSetTimeout = defaultSetTimout; + } + } catch (e) { + cachedSetTimeout = defaultSetTimout; + } + try { + if (typeof clearTimeout === 'function') { + cachedClearTimeout = clearTimeout; + } else { + cachedClearTimeout = defaultClearTimeout; + } + } catch (e) { + cachedClearTimeout = defaultClearTimeout; + } +} ()) +function runTimeout(fun) { + if (cachedSetTimeout === setTimeout) { + //normal enviroments in sane situations + return setTimeout(fun, 0); + } + // if setTimeout wasn't available but was latter defined + if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { + cachedSetTimeout = setTimeout; + return setTimeout(fun, 0); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedSetTimeout(fun, 0); + } catch(e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedSetTimeout.call(null, fun, 0); + } catch(e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error + return cachedSetTimeout.call(this, fun, 0); + } + } + + +} +function runClearTimeout(marker) { + if (cachedClearTimeout === clearTimeout) { + //normal enviroments in sane situations + return clearTimeout(marker); + } + // if clearTimeout wasn't available but was latter defined + if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { + cachedClearTimeout = clearTimeout; + return clearTimeout(marker); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedClearTimeout(marker); + } catch (e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedClearTimeout.call(null, marker); + } catch (e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. + // Some versions of I.E. have different rules for clearTimeout vs setTimeout + return cachedClearTimeout.call(this, marker); + } + } + + + +} +var queue = []; +var draining = false; +var currentQueue; +var queueIndex = -1; + +function cleanUpNextTick() { + if (!draining || !currentQueue) { + return; + } + draining = false; + if (currentQueue.length) { + queue = currentQueue.concat(queue); + } else { + queueIndex = -1; + } + if (queue.length) { + drainQueue(); + } +} + +function drainQueue() { + if (draining) { + return; + } + var timeout = runTimeout(cleanUpNextTick); + draining = true; + + var len = queue.length; + while(len) { + currentQueue = queue; + queue = []; + while (++queueIndex < len) { + if (currentQueue) { + currentQueue[queueIndex].run(); + } + } + queueIndex = -1; + len = queue.length; + } + currentQueue = null; + draining = false; + runClearTimeout(timeout); +} + +process.nextTick = function (fun) { + var args = new Array(arguments.length - 1); + if (arguments.length > 1) { + for (var i = 1; i < arguments.length; i++) { + args[i - 1] = arguments[i]; + } + } + queue.push(new Item(fun, args)); + if (queue.length === 1 && !draining) { + runTimeout(drainQueue); + } +}; + +// v8 likes predictible objects +function Item(fun, array) { + this.fun = fun; + this.array = array; +} +Item.prototype.run = function () { + this.fun.apply(null, this.array); +}; +process.title = 'browser'; +process.browser = true; +process.env = {}; +process.argv = []; +process.version = ''; // empty string to avoid regexp issues +process.versions = {}; + +function noop() {} + +process.on = noop; +process.addListener = noop; +process.once = noop; +process.off = noop; +process.removeListener = noop; +process.removeAllListeners = noop; +process.emit = noop; +process.prependListener = noop; +process.prependOnceListener = noop; + +process.listeners = function (name) { return [] } + +process.binding = function (name) { + throw new Error('process.binding is not supported'); +}; + +process.cwd = function () { return '/' }; +process.chdir = function (dir) { + throw new Error('process.chdir is not supported'); +}; +process.umask = function() { return 0; }; + +},{}],9:[function(require,module,exports){ +(function (process){(function (){ +/** @license React v16.13.1 + * react-is.development.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +'use strict'; + + + +if (process.env.NODE_ENV !== "production") { + (function() { +'use strict'; + +// The Symbol used to tag the ReactElement-like types. If there is no native Symbol +// nor polyfill, then a plain number is used for performance. +var hasSymbol = typeof Symbol === 'function' && Symbol.for; +var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7; +var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca; +var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb; +var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc; +var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2; +var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd; +var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary +// (unstable) APIs that have been removed. Can we remove the symbols? + +var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf; +var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf; +var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0; +var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1; +var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8; +var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3; +var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4; +var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for('react.block') : 0xead9; +var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5; +var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6; +var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7; + +function isValidElementType(type) { + return typeof type === 'string' || typeof type === 'function' || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill. + type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE || type.$$typeof === REACT_BLOCK_TYPE); +} + +function typeOf(object) { + if (typeof object === 'object' && object !== null) { + var $$typeof = object.$$typeof; + + switch ($$typeof) { + case REACT_ELEMENT_TYPE: + var type = object.type; + + switch (type) { + case REACT_ASYNC_MODE_TYPE: + case REACT_CONCURRENT_MODE_TYPE: + case REACT_FRAGMENT_TYPE: + case REACT_PROFILER_TYPE: + case REACT_STRICT_MODE_TYPE: + case REACT_SUSPENSE_TYPE: + return type; + + default: + var $$typeofType = type && type.$$typeof; + + switch ($$typeofType) { + case REACT_CONTEXT_TYPE: + case REACT_FORWARD_REF_TYPE: + case REACT_LAZY_TYPE: + case REACT_MEMO_TYPE: + case REACT_PROVIDER_TYPE: + return $$typeofType; + + default: + return $$typeof; + } + + } + + case REACT_PORTAL_TYPE: + return $$typeof; + } + } + + return undefined; +} // AsyncMode is deprecated along with isAsyncMode + +var AsyncMode = REACT_ASYNC_MODE_TYPE; +var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE; +var ContextConsumer = REACT_CONTEXT_TYPE; +var ContextProvider = REACT_PROVIDER_TYPE; +var Element = REACT_ELEMENT_TYPE; +var ForwardRef = REACT_FORWARD_REF_TYPE; +var Fragment = REACT_FRAGMENT_TYPE; +var Lazy = REACT_LAZY_TYPE; +var Memo = REACT_MEMO_TYPE; +var Portal = REACT_PORTAL_TYPE; +var Profiler = REACT_PROFILER_TYPE; +var StrictMode = REACT_STRICT_MODE_TYPE; +var Suspense = REACT_SUSPENSE_TYPE; +var hasWarnedAboutDeprecatedIsAsyncMode = false; // AsyncMode should be deprecated + +function isAsyncMode(object) { + { + if (!hasWarnedAboutDeprecatedIsAsyncMode) { + hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint + + console['warn']('The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.'); + } + } + + return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE; +} +function isConcurrentMode(object) { + return typeOf(object) === REACT_CONCURRENT_MODE_TYPE; +} +function isContextConsumer(object) { + return typeOf(object) === REACT_CONTEXT_TYPE; +} +function isContextProvider(object) { + return typeOf(object) === REACT_PROVIDER_TYPE; +} +function isElement(object) { + return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE; +} +function isForwardRef(object) { + return typeOf(object) === REACT_FORWARD_REF_TYPE; +} +function isFragment(object) { + return typeOf(object) === REACT_FRAGMENT_TYPE; +} +function isLazy(object) { + return typeOf(object) === REACT_LAZY_TYPE; +} +function isMemo(object) { + return typeOf(object) === REACT_MEMO_TYPE; +} +function isPortal(object) { + return typeOf(object) === REACT_PORTAL_TYPE; +} +function isProfiler(object) { + return typeOf(object) === REACT_PROFILER_TYPE; +} +function isStrictMode(object) { + return typeOf(object) === REACT_STRICT_MODE_TYPE; +} +function isSuspense(object) { + return typeOf(object) === REACT_SUSPENSE_TYPE; +} + +exports.AsyncMode = AsyncMode; +exports.ConcurrentMode = ConcurrentMode; +exports.ContextConsumer = ContextConsumer; +exports.ContextProvider = ContextProvider; +exports.Element = Element; +exports.ForwardRef = ForwardRef; +exports.Fragment = Fragment; +exports.Lazy = Lazy; +exports.Memo = Memo; +exports.Portal = Portal; +exports.Profiler = Profiler; +exports.StrictMode = StrictMode; +exports.Suspense = Suspense; +exports.isAsyncMode = isAsyncMode; +exports.isConcurrentMode = isConcurrentMode; +exports.isContextConsumer = isContextConsumer; +exports.isContextProvider = isContextProvider; +exports.isElement = isElement; +exports.isForwardRef = isForwardRef; +exports.isFragment = isFragment; +exports.isLazy = isLazy; +exports.isMemo = isMemo; +exports.isPortal = isPortal; +exports.isProfiler = isProfiler; +exports.isStrictMode = isStrictMode; +exports.isSuspense = isSuspense; +exports.isValidElementType = isValidElementType; +exports.typeOf = typeOf; + })(); +} + +}).call(this)}).call(this,require('_process')) +},{"_process":8}],10:[function(require,module,exports){ +/** @license React v16.13.1 + * react-is.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +'use strict';var b="function"===typeof Symbol&&Symbol.for,c=b?Symbol.for("react.element"):60103,d=b?Symbol.for("react.portal"):60106,e=b?Symbol.for("react.fragment"):60107,f=b?Symbol.for("react.strict_mode"):60108,g=b?Symbol.for("react.profiler"):60114,h=b?Symbol.for("react.provider"):60109,k=b?Symbol.for("react.context"):60110,l=b?Symbol.for("react.async_mode"):60111,m=b?Symbol.for("react.concurrent_mode"):60111,n=b?Symbol.for("react.forward_ref"):60112,p=b?Symbol.for("react.suspense"):60113,q=b? +Symbol.for("react.suspense_list"):60120,r=b?Symbol.for("react.memo"):60115,t=b?Symbol.for("react.lazy"):60116,v=b?Symbol.for("react.block"):60121,w=b?Symbol.for("react.fundamental"):60117,x=b?Symbol.for("react.responder"):60118,y=b?Symbol.for("react.scope"):60119; +function z(a){if("object"===typeof a&&null!==a){var u=a.$$typeof;switch(u){case c:switch(a=a.type,a){case l:case m:case e:case g:case f:case p:return a;default:switch(a=a&&a.$$typeof,a){case k:case n:case t:case r:case h:return a;default:return u}}case d:return u}}}function A(a){return z(a)===m}exports.AsyncMode=l;exports.ConcurrentMode=m;exports.ContextConsumer=k;exports.ContextProvider=h;exports.Element=c;exports.ForwardRef=n;exports.Fragment=e;exports.Lazy=t;exports.Memo=r;exports.Portal=d; +exports.Profiler=g;exports.StrictMode=f;exports.Suspense=p;exports.isAsyncMode=function(a){return A(a)||z(a)===l};exports.isConcurrentMode=A;exports.isContextConsumer=function(a){return z(a)===k};exports.isContextProvider=function(a){return z(a)===h};exports.isElement=function(a){return"object"===typeof a&&null!==a&&a.$$typeof===c};exports.isForwardRef=function(a){return z(a)===n};exports.isFragment=function(a){return z(a)===e};exports.isLazy=function(a){return z(a)===t}; +exports.isMemo=function(a){return z(a)===r};exports.isPortal=function(a){return z(a)===d};exports.isProfiler=function(a){return z(a)===g};exports.isStrictMode=function(a){return z(a)===f};exports.isSuspense=function(a){return z(a)===p}; +exports.isValidElementType=function(a){return"string"===typeof a||"function"===typeof a||a===e||a===m||a===g||a===f||a===p||a===q||"object"===typeof a&&null!==a&&(a.$$typeof===t||a.$$typeof===r||a.$$typeof===h||a.$$typeof===k||a.$$typeof===n||a.$$typeof===w||a.$$typeof===x||a.$$typeof===y||a.$$typeof===v)};exports.typeOf=z; + +},{}],11:[function(require,module,exports){ +(function (process){(function (){ +'use strict'; + +if (process.env.NODE_ENV === 'production') { + module.exports = require('./cjs/react-is.production.min.js'); +} else { + module.exports = require('./cjs/react-is.development.js'); +} + +}).call(this)}).call(this,require('_process')) +},{"./cjs/react-is.development.js":9,"./cjs/react-is.production.min.js":10,"_process":8}]},{},[4])(4) +}); diff --git a/node_modules/prop-types/prop-types.min.js b/node_modules/prop-types/prop-types.min.js new file mode 100644 index 0000000..7a746e1 --- /dev/null +++ b/node_modules/prop-types/prop-types.min.js @@ -0,0 +1 @@ +!function(f){"object"==typeof exports&&"undefined"!=typeof module?module.exports=f():"function"==typeof define&&define.amd?define([],f):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).PropTypes=f()}(function(){return function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var p="function"==typeof require&&require;if(!f&&p)return p(i,!0);if(u)return u(i,!0);throw(p=new Error("Cannot find module '"+i+"'")).code="MODULE_NOT_FOUND",p}p=n[i]={exports:{}},e[i][0].call(p.exports,function(r){return o(e[i][1][r]||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i React.createElement("div"); + +const ForwardRefComponent = React.forwardRef((props, ref) => + React.createElement(Component, { forwardedRef: ref, ...props }) +); + +const Context = React.createContext(false); + +ReactIs.isValidElementType("div"); // true +ReactIs.isValidElementType(ClassComponent); // true +ReactIs.isValidElementType(FunctionComponent); // true +ReactIs.isValidElementType(ForwardRefComponent); // true +ReactIs.isValidElementType(Context.Provider); // true +ReactIs.isValidElementType(Context.Consumer); // true +ReactIs.isValidElementType(React.createFactory("div")); // true +``` + +### Determining an Element's Type + +#### Context + +```js +import React from "react"; +import * as ReactIs from 'react-is'; + +const ThemeContext = React.createContext("blue"); + +ReactIs.isContextConsumer(); // true +ReactIs.isContextProvider(); // true +ReactIs.typeOf() === ReactIs.ContextProvider; // true +ReactIs.typeOf() === ReactIs.ContextConsumer; // true +``` + +#### Element + +```js +import React from "react"; +import * as ReactIs from 'react-is'; + +ReactIs.isElement(
); // true +ReactIs.typeOf(
) === ReactIs.Element; // true +``` + +#### Fragment + +```js +import React from "react"; +import * as ReactIs from 'react-is'; + +ReactIs.isFragment(<>); // true +ReactIs.typeOf(<>) === ReactIs.Fragment; // true +``` + +#### Portal + +```js +import React from "react"; +import ReactDOM from "react-dom"; +import * as ReactIs from 'react-is'; + +const div = document.createElement("div"); +const portal = ReactDOM.createPortal(
, div); + +ReactIs.isPortal(portal); // true +ReactIs.typeOf(portal) === ReactIs.Portal; // true +``` + +#### StrictMode + +```js +import React from "react"; +import * as ReactIs from 'react-is'; + +ReactIs.isStrictMode(); // true +ReactIs.typeOf() === ReactIs.StrictMode; // true +``` diff --git a/node_modules/react-is/build-info.json b/node_modules/react-is/build-info.json new file mode 100644 index 0000000..4094da6 --- /dev/null +++ b/node_modules/react-is/build-info.json @@ -0,0 +1,8 @@ +{ + "branch": "pull/18344", + "buildNumber": "106499", + "checksum": "7fe5a2e", + "commit": "da834083c", + "environment": "ci", + "reactVersion": "16.12.0-da834083c" +} diff --git a/node_modules/react-is/cjs/react-is.development.js b/node_modules/react-is/cjs/react-is.development.js new file mode 100644 index 0000000..8a80b76 --- /dev/null +++ b/node_modules/react-is/cjs/react-is.development.js @@ -0,0 +1,181 @@ +/** @license React v16.13.1 + * react-is.development.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +'use strict'; + + + +if (process.env.NODE_ENV !== "production") { + (function() { +'use strict'; + +// The Symbol used to tag the ReactElement-like types. If there is no native Symbol +// nor polyfill, then a plain number is used for performance. +var hasSymbol = typeof Symbol === 'function' && Symbol.for; +var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7; +var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca; +var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb; +var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc; +var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2; +var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd; +var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary +// (unstable) APIs that have been removed. Can we remove the symbols? + +var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf; +var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf; +var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0; +var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1; +var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8; +var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3; +var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4; +var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for('react.block') : 0xead9; +var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5; +var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6; +var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7; + +function isValidElementType(type) { + return typeof type === 'string' || typeof type === 'function' || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill. + type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE || type.$$typeof === REACT_BLOCK_TYPE); +} + +function typeOf(object) { + if (typeof object === 'object' && object !== null) { + var $$typeof = object.$$typeof; + + switch ($$typeof) { + case REACT_ELEMENT_TYPE: + var type = object.type; + + switch (type) { + case REACT_ASYNC_MODE_TYPE: + case REACT_CONCURRENT_MODE_TYPE: + case REACT_FRAGMENT_TYPE: + case REACT_PROFILER_TYPE: + case REACT_STRICT_MODE_TYPE: + case REACT_SUSPENSE_TYPE: + return type; + + default: + var $$typeofType = type && type.$$typeof; + + switch ($$typeofType) { + case REACT_CONTEXT_TYPE: + case REACT_FORWARD_REF_TYPE: + case REACT_LAZY_TYPE: + case REACT_MEMO_TYPE: + case REACT_PROVIDER_TYPE: + return $$typeofType; + + default: + return $$typeof; + } + + } + + case REACT_PORTAL_TYPE: + return $$typeof; + } + } + + return undefined; +} // AsyncMode is deprecated along with isAsyncMode + +var AsyncMode = REACT_ASYNC_MODE_TYPE; +var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE; +var ContextConsumer = REACT_CONTEXT_TYPE; +var ContextProvider = REACT_PROVIDER_TYPE; +var Element = REACT_ELEMENT_TYPE; +var ForwardRef = REACT_FORWARD_REF_TYPE; +var Fragment = REACT_FRAGMENT_TYPE; +var Lazy = REACT_LAZY_TYPE; +var Memo = REACT_MEMO_TYPE; +var Portal = REACT_PORTAL_TYPE; +var Profiler = REACT_PROFILER_TYPE; +var StrictMode = REACT_STRICT_MODE_TYPE; +var Suspense = REACT_SUSPENSE_TYPE; +var hasWarnedAboutDeprecatedIsAsyncMode = false; // AsyncMode should be deprecated + +function isAsyncMode(object) { + { + if (!hasWarnedAboutDeprecatedIsAsyncMode) { + hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint + + console['warn']('The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.'); + } + } + + return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE; +} +function isConcurrentMode(object) { + return typeOf(object) === REACT_CONCURRENT_MODE_TYPE; +} +function isContextConsumer(object) { + return typeOf(object) === REACT_CONTEXT_TYPE; +} +function isContextProvider(object) { + return typeOf(object) === REACT_PROVIDER_TYPE; +} +function isElement(object) { + return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE; +} +function isForwardRef(object) { + return typeOf(object) === REACT_FORWARD_REF_TYPE; +} +function isFragment(object) { + return typeOf(object) === REACT_FRAGMENT_TYPE; +} +function isLazy(object) { + return typeOf(object) === REACT_LAZY_TYPE; +} +function isMemo(object) { + return typeOf(object) === REACT_MEMO_TYPE; +} +function isPortal(object) { + return typeOf(object) === REACT_PORTAL_TYPE; +} +function isProfiler(object) { + return typeOf(object) === REACT_PROFILER_TYPE; +} +function isStrictMode(object) { + return typeOf(object) === REACT_STRICT_MODE_TYPE; +} +function isSuspense(object) { + return typeOf(object) === REACT_SUSPENSE_TYPE; +} + +exports.AsyncMode = AsyncMode; +exports.ConcurrentMode = ConcurrentMode; +exports.ContextConsumer = ContextConsumer; +exports.ContextProvider = ContextProvider; +exports.Element = Element; +exports.ForwardRef = ForwardRef; +exports.Fragment = Fragment; +exports.Lazy = Lazy; +exports.Memo = Memo; +exports.Portal = Portal; +exports.Profiler = Profiler; +exports.StrictMode = StrictMode; +exports.Suspense = Suspense; +exports.isAsyncMode = isAsyncMode; +exports.isConcurrentMode = isConcurrentMode; +exports.isContextConsumer = isContextConsumer; +exports.isContextProvider = isContextProvider; +exports.isElement = isElement; +exports.isForwardRef = isForwardRef; +exports.isFragment = isFragment; +exports.isLazy = isLazy; +exports.isMemo = isMemo; +exports.isPortal = isPortal; +exports.isProfiler = isProfiler; +exports.isStrictMode = isStrictMode; +exports.isSuspense = isSuspense; +exports.isValidElementType = isValidElementType; +exports.typeOf = typeOf; + })(); +} diff --git a/node_modules/react-is/cjs/react-is.production.min.js b/node_modules/react-is/cjs/react-is.production.min.js new file mode 100644 index 0000000..3e83c7a --- /dev/null +++ b/node_modules/react-is/cjs/react-is.production.min.js @@ -0,0 +1,15 @@ +/** @license React v16.13.1 + * react-is.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +'use strict';var b="function"===typeof Symbol&&Symbol.for,c=b?Symbol.for("react.element"):60103,d=b?Symbol.for("react.portal"):60106,e=b?Symbol.for("react.fragment"):60107,f=b?Symbol.for("react.strict_mode"):60108,g=b?Symbol.for("react.profiler"):60114,h=b?Symbol.for("react.provider"):60109,k=b?Symbol.for("react.context"):60110,l=b?Symbol.for("react.async_mode"):60111,m=b?Symbol.for("react.concurrent_mode"):60111,n=b?Symbol.for("react.forward_ref"):60112,p=b?Symbol.for("react.suspense"):60113,q=b? +Symbol.for("react.suspense_list"):60120,r=b?Symbol.for("react.memo"):60115,t=b?Symbol.for("react.lazy"):60116,v=b?Symbol.for("react.block"):60121,w=b?Symbol.for("react.fundamental"):60117,x=b?Symbol.for("react.responder"):60118,y=b?Symbol.for("react.scope"):60119; +function z(a){if("object"===typeof a&&null!==a){var u=a.$$typeof;switch(u){case c:switch(a=a.type,a){case l:case m:case e:case g:case f:case p:return a;default:switch(a=a&&a.$$typeof,a){case k:case n:case t:case r:case h:return a;default:return u}}case d:return u}}}function A(a){return z(a)===m}exports.AsyncMode=l;exports.ConcurrentMode=m;exports.ContextConsumer=k;exports.ContextProvider=h;exports.Element=c;exports.ForwardRef=n;exports.Fragment=e;exports.Lazy=t;exports.Memo=r;exports.Portal=d; +exports.Profiler=g;exports.StrictMode=f;exports.Suspense=p;exports.isAsyncMode=function(a){return A(a)||z(a)===l};exports.isConcurrentMode=A;exports.isContextConsumer=function(a){return z(a)===k};exports.isContextProvider=function(a){return z(a)===h};exports.isElement=function(a){return"object"===typeof a&&null!==a&&a.$$typeof===c};exports.isForwardRef=function(a){return z(a)===n};exports.isFragment=function(a){return z(a)===e};exports.isLazy=function(a){return z(a)===t}; +exports.isMemo=function(a){return z(a)===r};exports.isPortal=function(a){return z(a)===d};exports.isProfiler=function(a){return z(a)===g};exports.isStrictMode=function(a){return z(a)===f};exports.isSuspense=function(a){return z(a)===p}; +exports.isValidElementType=function(a){return"string"===typeof a||"function"===typeof a||a===e||a===m||a===g||a===f||a===p||a===q||"object"===typeof a&&null!==a&&(a.$$typeof===t||a.$$typeof===r||a.$$typeof===h||a.$$typeof===k||a.$$typeof===n||a.$$typeof===w||a.$$typeof===x||a.$$typeof===y||a.$$typeof===v)};exports.typeOf=z; diff --git a/node_modules/react-is/index.js b/node_modules/react-is/index.js new file mode 100644 index 0000000..3ae098d --- /dev/null +++ b/node_modules/react-is/index.js @@ -0,0 +1,7 @@ +'use strict'; + +if (process.env.NODE_ENV === 'production') { + module.exports = require('./cjs/react-is.production.min.js'); +} else { + module.exports = require('./cjs/react-is.development.js'); +} diff --git a/node_modules/react-is/package.json b/node_modules/react-is/package.json new file mode 100644 index 0000000..5f32de2 --- /dev/null +++ b/node_modules/react-is/package.json @@ -0,0 +1,27 @@ +{ + "name": "react-is", + "version": "16.13.1", + "description": "Brand checking of React Elements.", + "main": "index.js", + "repository": { + "type": "git", + "url": "https://github.com/facebook/react.git", + "directory": "packages/react-is" + }, + "keywords": [ + "react" + ], + "license": "MIT", + "bugs": { + "url": "https://github.com/facebook/react/issues" + }, + "homepage": "https://reactjs.org/", + "files": [ + "LICENSE", + "README.md", + "build-info.json", + "index.js", + "cjs/", + "umd/" + ] +} diff --git a/node_modules/react-is/umd/react-is.development.js b/node_modules/react-is/umd/react-is.development.js new file mode 100644 index 0000000..a6bc018 --- /dev/null +++ b/node_modules/react-is/umd/react-is.development.js @@ -0,0 +1,181 @@ +/** @license React v16.13.1 + * react-is.development.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +'use strict'; + +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : + typeof define === 'function' && define.amd ? define(['exports'], factory) : + (global = global || self, factory(global.ReactIs = {})); +}(this, (function (exports) { 'use strict'; + + // The Symbol used to tag the ReactElement-like types. If there is no native Symbol + // nor polyfill, then a plain number is used for performance. + var hasSymbol = typeof Symbol === 'function' && Symbol.for; + var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7; + var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca; + var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb; + var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc; + var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2; + var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd; + var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary + // (unstable) APIs that have been removed. Can we remove the symbols? + + var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf; + var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf; + var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0; + var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1; + var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8; + var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3; + var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4; + var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for('react.block') : 0xead9; + var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5; + var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6; + var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7; + + function isValidElementType(type) { + return typeof type === 'string' || typeof type === 'function' || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill. + type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE || type.$$typeof === REACT_BLOCK_TYPE); + } + + function typeOf(object) { + if (typeof object === 'object' && object !== null) { + var $$typeof = object.$$typeof; + + switch ($$typeof) { + case REACT_ELEMENT_TYPE: + var type = object.type; + + switch (type) { + case REACT_ASYNC_MODE_TYPE: + case REACT_CONCURRENT_MODE_TYPE: + case REACT_FRAGMENT_TYPE: + case REACT_PROFILER_TYPE: + case REACT_STRICT_MODE_TYPE: + case REACT_SUSPENSE_TYPE: + return type; + + default: + var $$typeofType = type && type.$$typeof; + + switch ($$typeofType) { + case REACT_CONTEXT_TYPE: + case REACT_FORWARD_REF_TYPE: + case REACT_LAZY_TYPE: + case REACT_MEMO_TYPE: + case REACT_PROVIDER_TYPE: + return $$typeofType; + + default: + return $$typeof; + } + + } + + case REACT_PORTAL_TYPE: + return $$typeof; + } + } + + return undefined; + } // AsyncMode is deprecated along with isAsyncMode + + var AsyncMode = REACT_ASYNC_MODE_TYPE; + var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE; + var ContextConsumer = REACT_CONTEXT_TYPE; + var ContextProvider = REACT_PROVIDER_TYPE; + var Element = REACT_ELEMENT_TYPE; + var ForwardRef = REACT_FORWARD_REF_TYPE; + var Fragment = REACT_FRAGMENT_TYPE; + var Lazy = REACT_LAZY_TYPE; + var Memo = REACT_MEMO_TYPE; + var Portal = REACT_PORTAL_TYPE; + var Profiler = REACT_PROFILER_TYPE; + var StrictMode = REACT_STRICT_MODE_TYPE; + var Suspense = REACT_SUSPENSE_TYPE; + var hasWarnedAboutDeprecatedIsAsyncMode = false; // AsyncMode should be deprecated + + function isAsyncMode(object) { + { + if (!hasWarnedAboutDeprecatedIsAsyncMode) { + hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint + + console['warn']('The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.'); + } + } + + return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE; + } + function isConcurrentMode(object) { + return typeOf(object) === REACT_CONCURRENT_MODE_TYPE; + } + function isContextConsumer(object) { + return typeOf(object) === REACT_CONTEXT_TYPE; + } + function isContextProvider(object) { + return typeOf(object) === REACT_PROVIDER_TYPE; + } + function isElement(object) { + return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE; + } + function isForwardRef(object) { + return typeOf(object) === REACT_FORWARD_REF_TYPE; + } + function isFragment(object) { + return typeOf(object) === REACT_FRAGMENT_TYPE; + } + function isLazy(object) { + return typeOf(object) === REACT_LAZY_TYPE; + } + function isMemo(object) { + return typeOf(object) === REACT_MEMO_TYPE; + } + function isPortal(object) { + return typeOf(object) === REACT_PORTAL_TYPE; + } + function isProfiler(object) { + return typeOf(object) === REACT_PROFILER_TYPE; + } + function isStrictMode(object) { + return typeOf(object) === REACT_STRICT_MODE_TYPE; + } + function isSuspense(object) { + return typeOf(object) === REACT_SUSPENSE_TYPE; + } + + exports.AsyncMode = AsyncMode; + exports.ConcurrentMode = ConcurrentMode; + exports.ContextConsumer = ContextConsumer; + exports.ContextProvider = ContextProvider; + exports.Element = Element; + exports.ForwardRef = ForwardRef; + exports.Fragment = Fragment; + exports.Lazy = Lazy; + exports.Memo = Memo; + exports.Portal = Portal; + exports.Profiler = Profiler; + exports.StrictMode = StrictMode; + exports.Suspense = Suspense; + exports.isAsyncMode = isAsyncMode; + exports.isConcurrentMode = isConcurrentMode; + exports.isContextConsumer = isContextConsumer; + exports.isContextProvider = isContextProvider; + exports.isElement = isElement; + exports.isForwardRef = isForwardRef; + exports.isFragment = isFragment; + exports.isLazy = isLazy; + exports.isMemo = isMemo; + exports.isPortal = isPortal; + exports.isProfiler = isProfiler; + exports.isStrictMode = isStrictMode; + exports.isSuspense = isSuspense; + exports.isValidElementType = isValidElementType; + exports.typeOf = typeOf; + +}))); diff --git a/node_modules/react-is/umd/react-is.production.min.js b/node_modules/react-is/umd/react-is.production.min.js new file mode 100644 index 0000000..62fe6b2 --- /dev/null +++ b/node_modules/react-is/umd/react-is.production.min.js @@ -0,0 +1,13 @@ +/** @license React v16.13.1 + * react-is.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +'use strict';(function(b,d){"object"===typeof exports&&"undefined"!==typeof module?d(exports):"function"===typeof define&&define.amd?define(["exports"],d):(b=b||self,d(b.ReactIs={}))})(this,function(b){function d(a){if("object"===typeof a&&null!==a){var b=a.$$typeof;switch(b){case r:switch(a=a.type,a){case t:case e:case f:case g:case h:case k:return a;default:switch(a=a&&a.$$typeof,a){case l:case m:case n:case p:case q:return a;default:return b}}case u:return b}}}function v(a){return d(a)===e}var c= +"function"===typeof Symbol&&Symbol.for,r=c?Symbol.for("react.element"):60103,u=c?Symbol.for("react.portal"):60106,f=c?Symbol.for("react.fragment"):60107,h=c?Symbol.for("react.strict_mode"):60108,g=c?Symbol.for("react.profiler"):60114,q=c?Symbol.for("react.provider"):60109,l=c?Symbol.for("react.context"):60110,t=c?Symbol.for("react.async_mode"):60111,e=c?Symbol.for("react.concurrent_mode"):60111,m=c?Symbol.for("react.forward_ref"):60112,k=c?Symbol.for("react.suspense"):60113,w=c?Symbol.for("react.suspense_list"): +60120,p=c?Symbol.for("react.memo"):60115,n=c?Symbol.for("react.lazy"):60116,x=c?Symbol.for("react.block"):60121,y=c?Symbol.for("react.fundamental"):60117,z=c?Symbol.for("react.responder"):60118,A=c?Symbol.for("react.scope"):60119;b.AsyncMode=t;b.ConcurrentMode=e;b.ContextConsumer=l;b.ContextProvider=q;b.Element=r;b.ForwardRef=m;b.Fragment=f;b.Lazy=n;b.Memo=p;b.Portal=u;b.Profiler=g;b.StrictMode=h;b.Suspense=k;b.isAsyncMode=function(a){return v(a)||d(a)===t};b.isConcurrentMode=v;b.isContextConsumer= +function(a){return d(a)===l};b.isContextProvider=function(a){return d(a)===q};b.isElement=function(a){return"object"===typeof a&&null!==a&&a.$$typeof===r};b.isForwardRef=function(a){return d(a)===m};b.isFragment=function(a){return d(a)===f};b.isLazy=function(a){return d(a)===n};b.isMemo=function(a){return d(a)===p};b.isPortal=function(a){return d(a)===u};b.isProfiler=function(a){return d(a)===g};b.isStrictMode=function(a){return d(a)===h};b.isSuspense=function(a){return d(a)===k};b.isValidElementType= +function(a){return"string"===typeof a||"function"===typeof a||a===f||a===e||a===g||a===h||a===k||a===w||"object"===typeof a&&null!==a&&(a.$$typeof===n||a.$$typeof===p||a.$$typeof===q||a.$$typeof===l||a.$$typeof===m||a.$$typeof===y||a.$$typeof===z||a.$$typeof===A||a.$$typeof===x)};b.typeOf=d}); diff --git a/node_modules/react-katex/.babelrc b/node_modules/react-katex/.babelrc new file mode 100644 index 0000000..1cc2c90 --- /dev/null +++ b/node_modules/react-katex/.babelrc @@ -0,0 +1,4 @@ +{ + // this file exists only because of ESlint + "presets": ["@babel/preset-react"] +} diff --git a/node_modules/react-katex/.eslintrc b/node_modules/react-katex/.eslintrc new file mode 100644 index 0000000..e4fb997 --- /dev/null +++ b/node_modules/react-katex/.eslintrc @@ -0,0 +1,26 @@ +{ + "parser": "@babel/eslint-parser", + "env": { + "es6": true, + "mocha": true + }, + "extends": ["prettier", "eslint:recommended", "plugin:react/all"], + "plugins": ["react"], + "rules": { + "comma-spacing": ["error", { "before": false, "after": true }], + "indent": ["error", 2], + "linebreak-style": ["error", "unix"], + "quotes": ["error", "single"], + "semi": ["error", "always"], + "react/display-name": 0, + "react/jsx-indent": [2, 2], + "react/jsx-indent-props": [2, 2], + "react/no-danger": 0, + "react/no-unused-prop-types": 0, + "react/require-default-props": 0, + "react/function-component-definition": [2, { "namedComponents": "arrow-function" }], + "react/no-multi-comp": 0, + "react/jsx-sort-props": 0, + "react/jsx-max-props-per-line": 0 + } +} diff --git a/node_modules/react-katex/.swcrc b/node_modules/react-katex/.swcrc new file mode 100644 index 0000000..9c14d8e --- /dev/null +++ b/node_modules/react-katex/.swcrc @@ -0,0 +1,17 @@ +{ + "jsc": { + "parser": { + "syntax": "ecmascript", + "jsx": true, + "preserveAllComments": true + }, + "target": "es2015", + "loose": false + }, + "module": { + "type": "umd" + }, + "minify": false, + "isModule": true, + "sourceMaps": "inline" +} diff --git a/node_modules/react-katex/README.md b/node_modules/react-katex/README.md new file mode 100644 index 0000000..93b6278 --- /dev/null +++ b/node_modules/react-katex/README.md @@ -0,0 +1,151 @@ +# react-katex + +[![Build Status](https://travis-ci.org/talyssonoc/react-katex.svg?branch=master)](https://travis-ci.org/talyssonoc/react-katex) [![Code Climate](https://codeclimate.com/github/talyssonoc/react-katex/badges/gpa.svg)](https://codeclimate.com/github/talyssonoc/react-katex) [![Coverage Status](https://coveralls.io/repos/github/talyssonoc/react-katex/badge.svg?branch=master)](https://coveralls.io/github/talyssonoc/react-katex?branch=master) + +> Display math expressions with [KaTeX](https://khan.github.io/KaTeX/) and React + +## Installation + +```sh + $ npm install react-katex + # or + $ yarn add react-katex +``` + +## Usage + +```jsx +import 'katex/dist/katex.min.css'; +import { InlineMath, BlockMath } from 'react-katex'; +``` + +### InlineMath + +Display math in the middle of the text. + +```jsx + var InlineMath = ReactKaTeX.InlineMath; + + ReactDOM.render(, + document.getElementById('math')); + + // or + + ReactDOM.render(\int_0^\infty x^2 dx, + document.getElementById('math')); +``` + +It will be rendered like this: + +![Inline math](docs/inline.png) + +### BlockMath + +Display math in a separated block, with larger font and symbols. + +```jsx + var BlockMath = ReactKaTeX.BlockMath; + + ReactDOM.render(, + document.getElementById('math')); + + // or + + ReactDOM.render(\int_0^\infty x^2 dx, + document.getElementById('math')); +``` + +It will be rendered like this: + +![Block math](docs/block.png) + + +**Note:**
+Don't forget to import KaTeX CSS file. +```jsx +import 'katex/dist/katex.min.css'; +``` + +### Error handling + +#### Default error message + +By default the error rendering is handled by KaTeX. You can optionally pass `errorColor` (defaults to `#cc0000`) as a prop: + +```jsx +var BlockMath = ReactKaTeX.BlockMath; + +ReactDOM.render( + , document.getElementById('math')); +``` + +This will be rendered like so: + +![KaTeX error](docs/error.png) + +#### Custom error message + +It's possible to handle parse errors using the prop `renderError`. This prop must be a function that receives the error object and returns what should be rendered when parsing fails: + +```jsx +var BlockMath = ReactKaTeX.BlockMath; + +ReactDOM.render( + { + return Fail: {error.name} + }} + />, + document.getElementById('math')); + +// The code above will render 'Fail: ParseError' because it's the value returned from `renderError`. +``` + +This will render `Fail: ParseError`: + +![renderError](docs/rendererror.png) + +### Escaping expressions + +In addition to using the `math` property, you can also quote as a child allowing the use of `{ }` in your expression. + +```jsx +ReactDOM.render({"\\frac{\\text{m}}{\\text{s}^2}"}, + document.getElementById('math')); +``` + +Or Multiline + +```jsx +ReactDOM.render({`\\frac{\\text{m}} +{\\text{s}^2}`}, + document.getElementById('math')); +``` + +However, it can be annoying to escape backslashes. This can be circumvented with the `String.raw` tag on a template literal when using ES6. + +```jsx +ReactDOM.render({String.raw`\frac{\text{m}}{\text{s}^2}`}, + document.getElementById('math')); +``` + +Backticks must be escaped with a backslash but would be passed to KaTeX as \\\`. A tag can be created to replace \\\` with \` + +```jsx +const latex = (...a) => String.raw(...a).replace("\\`","`") +ReactDOM.render({latex`\``}, + document.getElementById('math')); +``` + +You can even do variable substitution + +```jsx +const top = "m"; +const bottom = "s"; +ReactDOM.render({String.raw`\frac{\text{${top}}}{\text{${bottom}}^2}`}, + document.getElementById('math')); +``` diff --git a/node_modules/react-katex/coverage/clover.xml b/node_modules/react-katex/coverage/clover.xml new file mode 100644 index 0000000..ec37d10 --- /dev/null +++ b/node_modules/react-katex/coverage/clover.xml @@ -0,0 +1,111 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/node_modules/react-katex/coverage/coverage-final.json b/node_modules/react-katex/coverage/coverage-final.json new file mode 100644 index 0000000..361581d --- /dev/null +++ b/node_modules/react-katex/coverage/coverage-final.json @@ -0,0 +1,3 @@ +{"/Users/talyssonoc/Development/react-katex/packages/react-katex/src/index.jsx": {"path":"/Users/talyssonoc/Development/react-katex/packages/react-katex/src/index.jsx","statementMap":{"0":{"start":{"line":90,"column":13},"end":{"line":90,"column":22}},"1":{"start":{"line":91,"column":13},"end":{"line":91,"column":23}},"2":{"start":{"line":1,"column":31},"end":{"line":1,"column":null}},"3":{"start":{"line":2,"column":22},"end":{"line":2,"column":null}},"4":{"start":{"line":3,"column":18},"end":{"line":3,"column":null}},"5":{"start":{"line":30,"column":28},"end":{"line":72,"column":1}},"6":{"start":{"line":36,"column":24},"end":{"line":62,"column":3}},"7":{"start":{"line":37,"column":20},"end":{"line":37,"column":36}},"8":{"start":{"line":39,"column":28},"end":{"line":55,"column":42}},"9":{"start":{"line":40,"column":6},"end":{"line":54,"column":null}},"10":{"start":{"line":41,"column":21},"end":{"line":45,"column":10}},"11":{"start":{"line":47,"column":8},"end":{"line":47,"column":42}},"12":{"start":{"line":49,"column":8},"end":{"line":51,"column":null}},"13":{"start":{"line":50,"column":10},"end":{"line":50,"column":27}},"14":{"start":{"line":53,"column":8},"end":{"line":53,"column":20}},"15":{"start":{"line":57,"column":4},"end":{"line":59,"column":null}},"16":{"start":{"line":58,"column":6},"end":{"line":58,"column":88}},"17":{"start":{"line":61,"column":4},"end":{"line":61,"column":37}},"18":{"start":{"line":64,"column":2},"end":{"line":69,"column":4}},"19":{"start":{"line":71,"column":2},"end":{"line":71,"column":23}},"20":{"start":{"line":74,"column":39},"end":{"line":76,"column":1}},"21":{"start":{"line":78,"column":26},"end":{"line":80,"column":1}},"22":{"start":{"line":79,"column":2},"end":{"line":79,"column":86}},"23":{"start":{"line":82,"column":0},"end":{"line":82,"column":61}},"24":{"start":{"line":84,"column":27},"end":{"line":86,"column":1}},"25":{"start":{"line":85,"column":2},"end":{"line":85,"column":87}},"26":{"start":{"line":88,"column":0},"end":{"line":88,"column":62}},"27":{"start":{"line":90,"column":25},"end":{"line":90,"column":86}},"28":{"start":{"line":91,"column":26},"end":{"line":91,"column":89}}},"fnMap":{"0":{"name":"(anonymous_1)","decl":{"start":{"line":90,"column":22},"end":{"line":90,"column":25}},"loc":{"start":{"line":90,"column":13},"end":{"line":90,"column":22}}},"1":{"name":"(anonymous_2)","decl":{"start":{"line":91,"column":23},"end":{"line":91,"column":26}},"loc":{"start":{"line":91,"column":13},"end":{"line":91,"column":23}}},"2":{"name":"(anonymous_7)","decl":{"start":{"line":30,"column":28},"end":{"line":30,"column":29}},"loc":{"start":{"line":30,"column":60},"end":{"line":72,"column":1}}},"3":{"name":"(anonymous_8)","decl":{"start":{"line":36,"column":24},"end":{"line":36,"column":25}},"loc":{"start":{"line":36,"column":73},"end":{"line":62,"column":3}}},"4":{"name":"(anonymous_9)","decl":{"start":{"line":39,"column":36},"end":{"line":39,"column":42}},"loc":{"start":{"line":39,"column":42},"end":{"line":55,"column":7}}},"5":{"name":"(anonymous_10)","decl":{"start":{"line":78,"column":26},"end":{"line":78,"column":27}},"loc":{"start":{"line":78,"column":40},"end":{"line":80,"column":1}}},"6":{"name":"(anonymous_11)","decl":{"start":{"line":84,"column":27},"end":{"line":84,"column":28}},"loc":{"start":{"line":84,"column":41},"end":{"line":86,"column":1}}}},"branchMap":{"0":{"loc":{"start":{"line":37,"column":20},"end":{"line":37,"column":36}},"type":"cond-expr","locations":[{"start":{"line":37,"column":20},"end":{"line":37,"column":24}},{"start":{"line":37,"column":28},"end":{"line":37,"column":36}}]},"1":{"loc":{"start":{"line":37,"column":20},"end":{"line":37,"column":28}},"type":"binary-expr","locations":[{"start":{"line":37,"column":20},"end":{"line":37,"column":28}},{"start":{"line":37,"column":20},"end":{"line":37,"column":28}}]},"2":{"loc":{"start":{"line":49,"column":8},"end":{"line":51,"column":null}},"type":"if","locations":[{"start":{"line":49,"column":8},"end":{"line":51,"column":null}}]},"3":{"loc":{"start":{"line":49,"column":12},"end":{"line":49,"column":75}},"type":"binary-expr","locations":[{"start":{"line":49,"column":12},"end":{"line":49,"column":45}},{"start":{"line":49,"column":49},"end":{"line":49,"column":75}}]},"4":{"loc":{"start":{"line":57,"column":4},"end":{"line":59,"column":null}},"type":"if","locations":[{"start":{"line":57,"column":4},"end":{"line":59,"column":null}}]},"5":{"loc":{"start":{"line":58,"column":13},"end":{"line":58,"column":88}},"type":"cond-expr","locations":[{"start":{"line":58,"column":27},"end":{"line":58,"column":45}},{"start":{"line":58,"column":48},"end":{"line":58,"column":88}}]}},"s":{"0":1,"1":1,"2":2,"3":2,"4":2,"5":2,"6":4,"7":32,"8":32,"9":32,"10":32,"11":22,"12":10,"13":10,"14":0,"15":32,"16":10,"17":22,"18":4,"19":4,"20":2,"21":2,"22":12,"23":2,"24":2,"25":12,"26":2,"27":2,"28":2},"f":{"0":1,"1":1,"2":4,"3":32,"4":32,"5":12,"6":12},"b":{"0":[26,6],"1":[32,32],"2":[10],"3":[10,2],"4":[10],"5":[8,2]}} +,"/Users/talyssonoc/Development/react-katex/packages/react-katex/tests/sharedExamples.js": {"path":"/Users/talyssonoc/Development/react-katex/packages/react-katex/tests/sharedExamples.js","statementMap":{"0":{"start":{"line":6,"column":0},"end":{"line":6,"column":15}},"1":{"start":{"line":1,"column":7},"end":{"line":1,"column":null}},"2":{"start":{"line":2,"column":31},"end":{"line":2,"column":null}},"3":{"start":{"line":3,"column":18},"end":{"line":3,"column":null}},"4":{"start":{"line":4,"column":18},"end":{"line":4,"column":null}},"5":{"start":{"line":6,"column":15},"end":{"line":124,"column":2}},"6":{"start":{"line":7,"column":21},"end":{"line":7,"column":38}},"7":{"start":{"line":8,"column":26},"end":{"line":8,"column":50}},"8":{"start":{"line":9,"column":32},"end":{"line":9,"column":40}},"9":{"start":{"line":10,"column":28},"end":{"line":10,"column":37}},"10":{"start":{"line":11,"column":22},"end":{"line":11,"column":109}},"11":{"start":{"line":11,"column":33},"end":{"line":11,"column":109}},"12":{"start":{"line":13,"column":31},"end":{"line":13,"column":70}},"13":{"start":{"line":13,"column":37},"end":{"line":13,"column":70}},"14":{"start":{"line":15,"column":37},"end":{"line":16,"column":72}},"15":{"start":{"line":16,"column":4},"end":{"line":16,"column":72}},"16":{"start":{"line":18,"column":26},"end":{"line":18,"column":92}},"17":{"start":{"line":18,"column":39},"end":{"line":18,"column":92}},"18":{"start":{"line":20,"column":33},"end":{"line":20,"column":109}},"19":{"start":{"line":20,"column":46},"end":{"line":20,"column":109}},"20":{"start":{"line":22,"column":2},"end":{"line":36,"column":5}},"21":{"start":{"line":23,"column":4},"end":{"line":27,"column":7}},"22":{"start":{"line":24,"column":6},"end":{"line":24,"column":46}},"23":{"start":{"line":26,"column":6},"end":{"line":26,"column":41}},"24":{"start":{"line":29,"column":4},"end":{"line":35,"column":7}},"25":{"start":{"line":30,"column":27},"end":{"line":30,"column":66}},"26":{"start":{"line":32,"column":6},"end":{"line":32,"column":53}},"27":{"start":{"line":34,"column":6},"end":{"line":34,"column":63}},"28":{"start":{"line":38,"column":2},"end":{"line":52,"column":5}},"29":{"start":{"line":39,"column":4},"end":{"line":43,"column":7}},"30":{"start":{"line":40,"column":6},"end":{"line":40,"column":55}},"31":{"start":{"line":42,"column":6},"end":{"line":42,"column":46}},"32":{"start":{"line":45,"column":4},"end":{"line":51,"column":7}},"33":{"start":{"line":46,"column":27},"end":{"line":46,"column":75}},"34":{"start":{"line":48,"column":6},"end":{"line":48,"column":52}},"35":{"start":{"line":50,"column":6},"end":{"line":50,"column":41}},"36":{"start":{"line":54,"column":2},"end":{"line":123,"column":5}},"37":{"start":{"line":55,"column":4},"end":{"line":61,"column":7}},"38":{"start":{"line":56,"column":27},"end":{"line":56,"column":103}},"39":{"start":{"line":58,"column":6},"end":{"line":58,"column":79}},"40":{"start":{"line":60,"column":6},"end":{"line":60,"column":46}},"41":{"start":{"line":63,"column":4},"end":{"line":69,"column":7}},"42":{"start":{"line":64,"column":38},"end":{"line":64,"column":108}},"43":{"start":{"line":66,"column":6},"end":{"line":66,"column":85}},"44":{"start":{"line":68,"column":6},"end":{"line":68,"column":113}},"45":{"start":{"line":71,"column":4},"end":{"line":106,"column":7}},"46":{"start":{"line":72,"column":6},"end":{"line":76,"column":9}},"47":{"start":{"line":73,"column":8},"end":{"line":73,"column":59}},"48":{"start":{"line":75,"column":8},"end":{"line":75,"column":77}},"49":{"start":{"line":78,"column":6},"end":{"line":84,"column":9}},"50":{"start":{"line":79,"column":8},"end":{"line":83,"column":11}},"51":{"start":{"line":80,"column":10},"end":{"line":80,"column":81}},"52":{"start":{"line":82,"column":10},"end":{"line":82,"column":76}},"53":{"start":{"line":86,"column":6},"end":{"line":97,"column":9}},"54":{"start":{"line":87,"column":8},"end":{"line":90,"column":11}},"55":{"start":{"line":89,"column":10},"end":{"line":89,"column":70}},"56":{"start":{"line":89,"column":64},"end":{"line":89,"column":68}},"57":{"start":{"line":92,"column":8},"end":{"line":96,"column":11}},"58":{"start":{"line":93,"column":10},"end":{"line":93,"column":55}},"59":{"start":{"line":95,"column":10},"end":{"line":95,"column":74}},"60":{"start":{"line":99,"column":6},"end":{"line":105,"column":9}},"61":{"start":{"line":100,"column":8},"end":{"line":104,"column":11}},"62":{"start":{"line":101,"column":10},"end":{"line":101,"column":57}},"63":{"start":{"line":103,"column":10},"end":{"line":103,"column":97}},"64":{"start":{"line":108,"column":4},"end":{"line":122,"column":7}},"65":{"start":{"line":109,"column":6},"end":{"line":113,"column":9}},"66":{"start":{"line":110,"column":30},"end":{"line":110,"column":106}},"67":{"start":{"line":112,"column":8},"end":{"line":112,"column":115}},"68":{"start":{"line":115,"column":6},"end":{"line":121,"column":9}},"69":{"start":{"line":116,"column":8},"end":{"line":120,"column":11}},"70":{"start":{"line":117,"column":32},"end":{"line":117,"column":104}},"71":{"start":{"line":119,"column":10},"end":{"line":119,"column":117}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":6,"column":0},"end":{"line":6,"column":15}},"loc":{"start":{"line":6,"column":0},"end":{"line":6,"column":15}}},"1":{"name":"(anonymous_2)","decl":{"start":{"line":6,"column":15},"end":{"line":6,"column":16}},"loc":{"start":{"line":6,"column":47},"end":{"line":124,"column":2}}},"2":{"name":"(anonymous_3)","decl":{"start":{"line":11,"column":22},"end":{"line":11,"column":23}},"loc":{"start":{"line":11,"column":33},"end":{"line":11,"column":109}}},"3":{"name":"(anonymous_4)","decl":{"start":{"line":13,"column":31},"end":{"line":13,"column":37}},"loc":{"start":{"line":13,"column":37},"end":{"line":13,"column":70}}},"4":{"name":"(anonymous_5)","decl":{"start":{"line":15,"column":37},"end":{"line":15,"column":38}},"loc":{"start":{"line":16,"column":4},"end":{"line":16,"column":72}}},"5":{"name":"(anonymous_6)","decl":{"start":{"line":18,"column":26},"end":{"line":18,"column":27}},"loc":{"start":{"line":18,"column":39},"end":{"line":18,"column":92}}},"6":{"name":"(anonymous_7)","decl":{"start":{"line":20,"column":33},"end":{"line":20,"column":34}},"loc":{"start":{"line":20,"column":46},"end":{"line":20,"column":109}}},"7":{"name":"(anonymous_8)","decl":{"start":{"line":22,"column":48},"end":{"line":22,"column":54}},"loc":{"start":{"line":22,"column":54},"end":{"line":36,"column":4}}},"8":{"name":"(anonymous_9)","decl":{"start":{"line":23,"column":28},"end":{"line":23,"column":34}},"loc":{"start":{"line":23,"column":34},"end":{"line":27,"column":6}}},"9":{"name":"(anonymous_10)","decl":{"start":{"line":29,"column":42},"end":{"line":29,"column":48}},"loc":{"start":{"line":29,"column":48},"end":{"line":35,"column":6}}},"10":{"name":"(anonymous_11)","decl":{"start":{"line":38,"column":48},"end":{"line":38,"column":54}},"loc":{"start":{"line":38,"column":54},"end":{"line":52,"column":4}}},"11":{"name":"(anonymous_12)","decl":{"start":{"line":39,"column":28},"end":{"line":39,"column":34}},"loc":{"start":{"line":39,"column":34},"end":{"line":43,"column":6}}},"12":{"name":"(anonymous_13)","decl":{"start":{"line":45,"column":42},"end":{"line":45,"column":48}},"loc":{"start":{"line":45,"column":48},"end":{"line":51,"column":6}}},"13":{"name":"(anonymous_14)","decl":{"start":{"line":54,"column":29},"end":{"line":54,"column":35}},"loc":{"start":{"line":54,"column":35},"end":{"line":123,"column":4}}},"14":{"name":"(anonymous_15)","decl":{"start":{"line":55,"column":61},"end":{"line":55,"column":67}},"loc":{"start":{"line":55,"column":67},"end":{"line":61,"column":6}}},"15":{"name":"(anonymous_16)","decl":{"start":{"line":63,"column":61},"end":{"line":63,"column":67}},"loc":{"start":{"line":63,"column":67},"end":{"line":69,"column":6}}},"16":{"name":"(anonymous_17)","decl":{"start":{"line":71,"column":49},"end":{"line":71,"column":55}},"loc":{"start":{"line":71,"column":55},"end":{"line":106,"column":6}}},"17":{"name":"(anonymous_18)","decl":{"start":{"line":72,"column":81},"end":{"line":72,"column":87}},"loc":{"start":{"line":72,"column":87},"end":{"line":76,"column":8}}},"18":{"name":"(anonymous_19)","decl":{"start":{"line":78,"column":50},"end":{"line":78,"column":56}},"loc":{"start":{"line":78,"column":56},"end":{"line":84,"column":8}}},"19":{"name":"(anonymous_20)","decl":{"start":{"line":79,"column":82},"end":{"line":79,"column":88}},"loc":{"start":{"line":79,"column":88},"end":{"line":83,"column":10}}},"20":{"name":"(anonymous_21)","decl":{"start":{"line":86,"column":63},"end":{"line":86,"column":69}},"loc":{"start":{"line":86,"column":69},"end":{"line":97,"column":8}}},"21":{"name":"(anonymous_22)","decl":{"start":{"line":87,"column":19},"end":{"line":87,"column":25}},"loc":{"start":{"line":87,"column":25},"end":{"line":90,"column":10}}},"22":{"name":"(anonymous_23)","decl":{"start":{"line":89,"column":58},"end":{"line":89,"column":64}},"loc":{"start":{"line":89,"column":64},"end":{"line":89,"column":68}}},"23":{"name":"(anonymous_24)","decl":{"start":{"line":92,"column":36},"end":{"line":92,"column":42}},"loc":{"start":{"line":92,"column":42},"end":{"line":96,"column":10}}},"24":{"name":"(anonymous_25)","decl":{"start":{"line":99,"column":69},"end":{"line":99,"column":75}},"loc":{"start":{"line":99,"column":75},"end":{"line":105,"column":8}}},"25":{"name":"(anonymous_26)","decl":{"start":{"line":100,"column":36},"end":{"line":100,"column":42}},"loc":{"start":{"line":100,"column":42},"end":{"line":104,"column":10}}},"26":{"name":"(anonymous_27)","decl":{"start":{"line":108,"column":48},"end":{"line":108,"column":54}},"loc":{"start":{"line":108,"column":54},"end":{"line":122,"column":6}}},"27":{"name":"(anonymous_28)","decl":{"start":{"line":109,"column":63},"end":{"line":109,"column":69}},"loc":{"start":{"line":109,"column":69},"end":{"line":113,"column":8}}},"28":{"name":"(anonymous_29)","decl":{"start":{"line":115,"column":69},"end":{"line":115,"column":75}},"loc":{"start":{"line":115,"column":75},"end":{"line":121,"column":8}}},"29":{"name":"(anonymous_30)","decl":{"start":{"line":116,"column":40},"end":{"line":116,"column":46}},"loc":{"start":{"line":116,"column":46},"end":{"line":120,"column":10}}}},"branchMap":{},"s":{"0":2,"1":2,"2":2,"3":2,"4":2,"5":2,"6":2,"7":2,"8":2,"9":2,"10":2,"11":8,"12":2,"13":18,"14":2,"15":6,"16":2,"17":14,"18":2,"19":10,"20":2,"21":2,"22":2,"23":2,"24":2,"25":2,"26":2,"27":2,"28":2,"29":2,"30":2,"31":2,"32":2,"33":2,"34":2,"35":2,"36":2,"37":2,"38":2,"39":2,"40":2,"41":2,"42":2,"43":2,"44":2,"45":2,"46":2,"47":2,"48":2,"49":2,"50":2,"51":2,"52":2,"53":2,"54":2,"55":2,"56":2,"57":2,"58":2,"59":2,"60":2,"61":2,"62":2,"63":2,"64":2,"65":2,"66":2,"67":2,"68":2,"69":2,"70":2,"71":2},"f":{"0":2,"1":2,"2":8,"3":18,"4":6,"5":14,"6":10,"7":2,"8":2,"9":2,"10":2,"11":2,"12":2,"13":2,"14":2,"15":2,"16":2,"17":2,"18":2,"19":2,"20":2,"21":2,"22":2,"23":2,"24":2,"25":2,"26":2,"27":2,"28":2,"29":2},"b":{}} +} diff --git a/node_modules/react-katex/coverage/lcov-report/base.css b/node_modules/react-katex/coverage/lcov-report/base.css new file mode 100644 index 0000000..f418035 --- /dev/null +++ b/node_modules/react-katex/coverage/lcov-report/base.css @@ -0,0 +1,224 @@ +body, html { + margin:0; padding: 0; + height: 100%; +} +body { + font-family: Helvetica Neue, Helvetica, Arial; + font-size: 14px; + color:#333; +} +.small { font-size: 12px; } +*, *:after, *:before { + -webkit-box-sizing:border-box; + -moz-box-sizing:border-box; + box-sizing:border-box; + } +h1 { font-size: 20px; margin: 0;} +h2 { font-size: 14px; } +pre { + font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace; + margin: 0; + padding: 0; + -moz-tab-size: 2; + -o-tab-size: 2; + tab-size: 2; +} +a { color:#0074D9; text-decoration:none; } +a:hover { text-decoration:underline; } +.strong { font-weight: bold; } +.space-top1 { padding: 10px 0 0 0; } +.pad2y { padding: 20px 0; } +.pad1y { padding: 10px 0; } +.pad2x { padding: 0 20px; } +.pad2 { padding: 20px; } +.pad1 { padding: 10px; } +.space-left2 { padding-left:55px; } +.space-right2 { padding-right:20px; } +.center { text-align:center; } +.clearfix { display:block; } +.clearfix:after { + content:''; + display:block; + height:0; + clear:both; + visibility:hidden; + } +.fl { float: left; } +@media only screen and (max-width:640px) { + .col3 { width:100%; max-width:100%; } + .hide-mobile { display:none!important; } +} + +.quiet { + color: #7f7f7f; + color: rgba(0,0,0,0.5); +} +.quiet a { opacity: 0.7; } + +.fraction { + font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; + font-size: 10px; + color: #555; + background: #E8E8E8; + padding: 4px 5px; + border-radius: 3px; + vertical-align: middle; +} + +div.path a:link, div.path a:visited { color: #333; } +table.coverage { + border-collapse: collapse; + margin: 10px 0 0 0; + padding: 0; +} + +table.coverage td { + margin: 0; + padding: 0; + vertical-align: top; +} +table.coverage td.line-count { + text-align: right; + padding: 0 5px 0 20px; +} +table.coverage td.line-coverage { + text-align: right; + padding-right: 10px; + min-width:20px; +} + +table.coverage td span.cline-any { + display: inline-block; + padding: 0 5px; + width: 100%; +} +.missing-if-branch { + display: inline-block; + margin-right: 5px; + border-radius: 3px; + position: relative; + padding: 0 4px; + background: #333; + color: yellow; +} + +.skip-if-branch { + display: none; + margin-right: 10px; + position: relative; + padding: 0 4px; + background: #ccc; + color: white; +} +.missing-if-branch .typ, .skip-if-branch .typ { + color: inherit !important; +} +.coverage-summary { + border-collapse: collapse; + width: 100%; +} +.coverage-summary tr { border-bottom: 1px solid #bbb; } +.keyline-all { border: 1px solid #ddd; } +.coverage-summary td, .coverage-summary th { padding: 10px; } +.coverage-summary tbody { border: 1px solid #bbb; } +.coverage-summary td { border-right: 1px solid #bbb; } +.coverage-summary td:last-child { border-right: none; } +.coverage-summary th { + text-align: left; + font-weight: normal; + white-space: nowrap; +} +.coverage-summary th.file { border-right: none !important; } +.coverage-summary th.pct { } +.coverage-summary th.pic, +.coverage-summary th.abs, +.coverage-summary td.pct, +.coverage-summary td.abs { text-align: right; } +.coverage-summary td.file { white-space: nowrap; } +.coverage-summary td.pic { min-width: 120px !important; } +.coverage-summary tfoot td { } + +.coverage-summary .sorter { + height: 10px; + width: 7px; + display: inline-block; + margin-left: 0.5em; + background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent; +} +.coverage-summary .sorted .sorter { + background-position: 0 -20px; +} +.coverage-summary .sorted-desc .sorter { + background-position: 0 -10px; +} +.status-line { height: 10px; } +/* yellow */ +.cbranch-no { background: yellow !important; color: #111; } +/* dark red */ +.red.solid, .status-line.low, .low .cover-fill { background:#C21F39 } +.low .chart { border:1px solid #C21F39 } +.highlighted, +.highlighted .cstat-no, .highlighted .fstat-no, .highlighted .cbranch-no{ + background: #C21F39 !important; +} +/* medium red */ +.cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE } +/* light red */ +.low, .cline-no { background:#FCE1E5 } +/* light green */ +.high, .cline-yes { background:rgb(230,245,208) } +/* medium green */ +.cstat-yes { background:rgb(161,215,106) } +/* dark green */ +.status-line.high, .high .cover-fill { background:rgb(77,146,33) } +.high .chart { border:1px solid rgb(77,146,33) } +/* dark yellow (gold) */ +.status-line.medium, .medium .cover-fill { background: #f9cd0b; } +.medium .chart { border:1px solid #f9cd0b; } +/* light yellow */ +.medium { background: #fff4c2; } + +.cstat-skip { background: #ddd; color: #111; } +.fstat-skip { background: #ddd; color: #111 !important; } +.cbranch-skip { background: #ddd !important; color: #111; } + +span.cline-neutral { background: #eaeaea; } + +.coverage-summary td.empty { + opacity: .5; + padding-top: 4px; + padding-bottom: 4px; + line-height: 1; + color: #888; +} + +.cover-fill, .cover-empty { + display:inline-block; + height: 12px; +} +.chart { + line-height: 0; +} +.cover-empty { + background: white; +} +.cover-full { + border-right: none !important; +} +pre.prettyprint { + border: none !important; + padding: 0 !important; + margin: 0 !important; +} +.com { color: #999 !important; } +.ignore-none { color: #999; font-weight: normal; } + +.wrapper { + min-height: 100%; + height: auto !important; + height: 100%; + margin: 0 auto -48px; +} +.footer, .push { + height: 48px; +} diff --git a/node_modules/react-katex/coverage/lcov-report/block-navigation.js b/node_modules/react-katex/coverage/lcov-report/block-navigation.js new file mode 100644 index 0000000..cc12130 --- /dev/null +++ b/node_modules/react-katex/coverage/lcov-report/block-navigation.js @@ -0,0 +1,87 @@ +/* eslint-disable */ +var jumpToCode = (function init() { + // Classes of code we would like to highlight in the file view + var missingCoverageClasses = ['.cbranch-no', '.cstat-no', '.fstat-no']; + + // Elements to highlight in the file listing view + var fileListingElements = ['td.pct.low']; + + // We don't want to select elements that are direct descendants of another match + var notSelector = ':not(' + missingCoverageClasses.join('):not(') + ') > '; // becomes `:not(a):not(b) > ` + + // Selecter that finds elements on the page to which we can jump + var selector = + fileListingElements.join(', ') + + ', ' + + notSelector + + missingCoverageClasses.join(', ' + notSelector); // becomes `:not(a):not(b) > a, :not(a):not(b) > b` + + // The NodeList of matching elements + var missingCoverageElements = document.querySelectorAll(selector); + + var currentIndex; + + function toggleClass(index) { + missingCoverageElements + .item(currentIndex) + .classList.remove('highlighted'); + missingCoverageElements.item(index).classList.add('highlighted'); + } + + function makeCurrent(index) { + toggleClass(index); + currentIndex = index; + missingCoverageElements.item(index).scrollIntoView({ + behavior: 'smooth', + block: 'center', + inline: 'center' + }); + } + + function goToPrevious() { + var nextIndex = 0; + if (typeof currentIndex !== 'number' || currentIndex === 0) { + nextIndex = missingCoverageElements.length - 1; + } else if (missingCoverageElements.length > 1) { + nextIndex = currentIndex - 1; + } + + makeCurrent(nextIndex); + } + + function goToNext() { + var nextIndex = 0; + + if ( + typeof currentIndex === 'number' && + currentIndex < missingCoverageElements.length - 1 + ) { + nextIndex = currentIndex + 1; + } + + makeCurrent(nextIndex); + } + + return function jump(event) { + if ( + document.getElementById('fileSearch') === document.activeElement && + document.activeElement != null + ) { + // if we're currently focused on the search input, we don't want to navigate + return; + } + + switch (event.which) { + case 78: // n + case 74: // j + goToNext(); + break; + case 66: // b + case 75: // k + case 80: // p + goToPrevious(); + break; + } + }; +})(); +window.addEventListener('keydown', jumpToCode); diff --git a/node_modules/react-katex/coverage/lcov-report/favicon.png b/node_modules/react-katex/coverage/lcov-report/favicon.png new file mode 100644 index 0000000..c1525b8 Binary files /dev/null and b/node_modules/react-katex/coverage/lcov-report/favicon.png differ diff --git a/node_modules/react-katex/coverage/lcov-report/index.html b/node_modules/react-katex/coverage/lcov-report/index.html new file mode 100644 index 0000000..6452fa8 --- /dev/null +++ b/node_modules/react-katex/coverage/lcov-report/index.html @@ -0,0 +1,131 @@ + + + + + + Code coverage report for All files + + + + + + + + + +
+
+

All files

+
+ +
+ 99% + Statements + 100/101 +
+ + +
+ 100% + Branches + 10/10 +
+ + +
+ 100% + Functions + 37/37 +
+ + +
+ 98.92% + Lines + 92/93 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
src +
+
96.55%28/29100%10/10100%7/796.29%26/27
tests +
+
100%72/72100%0/0100%30/30100%66/66
+
+
+
+ + + + + + + + \ No newline at end of file diff --git a/node_modules/react-katex/coverage/lcov-report/prettify.css b/node_modules/react-katex/coverage/lcov-report/prettify.css new file mode 100644 index 0000000..b317a7c --- /dev/null +++ b/node_modules/react-katex/coverage/lcov-report/prettify.css @@ -0,0 +1 @@ +.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee} diff --git a/node_modules/react-katex/coverage/lcov-report/prettify.js b/node_modules/react-katex/coverage/lcov-report/prettify.js new file mode 100644 index 0000000..b322523 --- /dev/null +++ b/node_modules/react-katex/coverage/lcov-report/prettify.js @@ -0,0 +1,2 @@ +/* eslint-disable */ +window.PR_SHOULD_USE_CONTINUATION=true;(function(){var h=["break,continue,do,else,for,if,return,while"];var u=[h,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"];var p=[u,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"];var l=[p,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"];var x=[p,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"];var R=[x,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"];var r="all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes";var w=[p,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"];var s="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END";var I=[h,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"];var f=[h,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"];var H=[h,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"];var A=[l,R,w,s+I,f,H];var e=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/;var C="str";var z="kwd";var j="com";var O="typ";var G="lit";var L="pun";var F="pln";var m="tag";var E="dec";var J="src";var P="atn";var n="atv";var N="nocode";var M="(?:^^\\.?|[+-]|\\!|\\!=|\\!==|\\#|\\%|\\%=|&|&&|&&=|&=|\\(|\\*|\\*=|\\+=|\\,|\\-=|\\->|\\/|\\/=|:|::|\\;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\@|\\[|\\^|\\^=|\\^\\^|\\^\\^=|\\{|\\||\\|=|\\|\\||\\|\\|=|\\~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function k(Z){var ad=0;var S=false;var ac=false;for(var V=0,U=Z.length;V122)){if(!(al<65||ag>90)){af.push([Math.max(65,ag)|32,Math.min(al,90)|32])}if(!(al<97||ag>122)){af.push([Math.max(97,ag)&~32,Math.min(al,122)&~32])}}}}af.sort(function(av,au){return(av[0]-au[0])||(au[1]-av[1])});var ai=[];var ap=[NaN,NaN];for(var ar=0;arat[0]){if(at[1]+1>at[0]){an.push("-")}an.push(T(at[1]))}}an.push("]");return an.join("")}function W(al){var aj=al.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g"));var ah=aj.length;var an=[];for(var ak=0,am=0;ak=2&&ai==="["){aj[ak]=X(ag)}else{if(ai!=="\\"){aj[ak]=ag.replace(/[a-zA-Z]/g,function(ao){var ap=ao.charCodeAt(0);return"["+String.fromCharCode(ap&~32,ap|32)+"]"})}}}}return aj.join("")}var aa=[];for(var V=0,U=Z.length;V=0;){S[ac.charAt(ae)]=Y}}var af=Y[1];var aa=""+af;if(!ag.hasOwnProperty(aa)){ah.push(af);ag[aa]=null}}ah.push(/[\0-\uffff]/);V=k(ah)})();var X=T.length;var W=function(ah){var Z=ah.sourceCode,Y=ah.basePos;var ad=[Y,F];var af=0;var an=Z.match(V)||[];var aj={};for(var ae=0,aq=an.length;ae=5&&"lang-"===ap.substring(0,5);if(am&&!(ai&&typeof ai[1]==="string")){am=false;ap=J}if(!am){aj[ag]=ap}}var ab=af;af+=ag.length;if(!am){ad.push(Y+ab,ap)}else{var al=ai[1];var ak=ag.indexOf(al);var ac=ak+al.length;if(ai[2]){ac=ag.length-ai[2].length;ak=ac-al.length}var ar=ap.substring(5);B(Y+ab,ag.substring(0,ak),W,ad);B(Y+ab+ak,al,q(ar,al),ad);B(Y+ab+ac,ag.substring(ac),W,ad)}}ah.decorations=ad};return W}function i(T){var W=[],S=[];if(T.tripleQuotedStrings){W.push([C,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,"'\""])}else{if(T.multiLineStrings){W.push([C,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"])}else{W.push([C,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"])}}if(T.verbatimStrings){S.push([C,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null])}var Y=T.hashComments;if(Y){if(T.cStyleComments){if(Y>1){W.push([j,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"])}else{W.push([j,/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"])}S.push([C,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,null])}else{W.push([j,/^#[^\r\n]*/,null,"#"])}}if(T.cStyleComments){S.push([j,/^\/\/[^\r\n]*/,null]);S.push([j,/^\/\*[\s\S]*?(?:\*\/|$)/,null])}if(T.regexLiterals){var X=("/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+/");S.push(["lang-regex",new RegExp("^"+M+"("+X+")")])}var V=T.types;if(V){S.push([O,V])}var U=(""+T.keywords).replace(/^ | $/g,"");if(U.length){S.push([z,new RegExp("^(?:"+U.replace(/[\s,]+/g,"|")+")\\b"),null])}W.push([F,/^\s+/,null," \r\n\t\xA0"]);S.push([G,/^@[a-z_$][a-z_$@0-9]*/i,null],[O,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[F,/^[a-z_$][a-z_$@0-9]*/i,null],[G,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[F,/^\\[\s\S]?/,null],[L,/^.[^\s\w\.$@\'\"\`\/\#\\]*/,null]);return g(W,S)}var K=i({keywords:A,hashComments:true,cStyleComments:true,multiLineStrings:true,regexLiterals:true});function Q(V,ag){var U=/(?:^|\s)nocode(?:\s|$)/;var ab=/\r\n?|\n/;var ac=V.ownerDocument;var S;if(V.currentStyle){S=V.currentStyle.whiteSpace}else{if(window.getComputedStyle){S=ac.defaultView.getComputedStyle(V,null).getPropertyValue("white-space")}}var Z=S&&"pre"===S.substring(0,3);var af=ac.createElement("LI");while(V.firstChild){af.appendChild(V.firstChild)}var W=[af];function ae(al){switch(al.nodeType){case 1:if(U.test(al.className)){break}if("BR"===al.nodeName){ad(al);if(al.parentNode){al.parentNode.removeChild(al)}}else{for(var an=al.firstChild;an;an=an.nextSibling){ae(an)}}break;case 3:case 4:if(Z){var am=al.nodeValue;var aj=am.match(ab);if(aj){var ai=am.substring(0,aj.index);al.nodeValue=ai;var ah=am.substring(aj.index+aj[0].length);if(ah){var ak=al.parentNode;ak.insertBefore(ac.createTextNode(ah),al.nextSibling)}ad(al);if(!ai){al.parentNode.removeChild(al)}}}break}}function ad(ak){while(!ak.nextSibling){ak=ak.parentNode;if(!ak){return}}function ai(al,ar){var aq=ar?al.cloneNode(false):al;var ao=al.parentNode;if(ao){var ap=ai(ao,1);var an=al.nextSibling;ap.appendChild(aq);for(var am=an;am;am=an){an=am.nextSibling;ap.appendChild(am)}}return aq}var ah=ai(ak.nextSibling,0);for(var aj;(aj=ah.parentNode)&&aj.nodeType===1;){ah=aj}W.push(ah)}for(var Y=0;Y=S){ah+=2}if(V>=ap){Z+=2}}}var t={};function c(U,V){for(var S=V.length;--S>=0;){var T=V[S];if(!t.hasOwnProperty(T)){t[T]=U}else{if(window.console){console.warn("cannot override language handler %s",T)}}}}function q(T,S){if(!(T&&t.hasOwnProperty(T))){T=/^\s*]*(?:>|$)/],[j,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[L,/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]);c(g([[F,/^[\s]+/,null," \t\r\n"],[n,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[[m,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[P,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[L,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]);c(g([],[[n,/^[\s\S]+/]]),["uq.val"]);c(i({keywords:l,hashComments:true,cStyleComments:true,types:e}),["c","cc","cpp","cxx","cyc","m"]);c(i({keywords:"null,true,false"}),["json"]);c(i({keywords:R,hashComments:true,cStyleComments:true,verbatimStrings:true,types:e}),["cs"]);c(i({keywords:x,cStyleComments:true}),["java"]);c(i({keywords:H,hashComments:true,multiLineStrings:true}),["bsh","csh","sh"]);c(i({keywords:I,hashComments:true,multiLineStrings:true,tripleQuotedStrings:true}),["cv","py"]);c(i({keywords:s,hashComments:true,multiLineStrings:true,regexLiterals:true}),["perl","pl","pm"]);c(i({keywords:f,hashComments:true,multiLineStrings:true,regexLiterals:true}),["rb"]);c(i({keywords:w,cStyleComments:true,regexLiterals:true}),["js"]);c(i({keywords:r,hashComments:3,cStyleComments:true,multilineStrings:true,tripleQuotedStrings:true,regexLiterals:true}),["coffee"]);c(g([],[[C,/^[\s\S]+/]]),["regex"]);function d(V){var U=V.langExtension;try{var S=a(V.sourceNode);var T=S.sourceCode;V.sourceCode=T;V.spans=S.spans;V.basePos=0;q(U,T)(V);D(V)}catch(W){if("console" in window){console.log(W&&W.stack?W.stack:W)}}}function y(W,V,U){var S=document.createElement("PRE");S.innerHTML=W;if(U){Q(S,U)}var T={langExtension:V,numberLines:U,sourceNode:S};d(T);return S.innerHTML}function b(ad){function Y(af){return document.getElementsByTagName(af)}var ac=[Y("pre"),Y("code"),Y("xmp")];var T=[];for(var aa=0;aa=0){var ah=ai.match(ab);var am;if(!ah&&(am=o(aj))&&"CODE"===am.tagName){ah=am.className.match(ab)}if(ah){ah=ah[1]}var al=false;for(var ak=aj.parentNode;ak;ak=ak.parentNode){if((ak.tagName==="pre"||ak.tagName==="code"||ak.tagName==="xmp")&&ak.className&&ak.className.indexOf("prettyprint")>=0){al=true;break}}if(!al){var af=aj.className.match(/\blinenums\b(?::(\d+))?/);af=af?af[1]&&af[1].length?+af[1]:true:false;if(af){Q(aj,af)}S={langExtension:ah,sourceNode:aj,numberLines:af};d(S)}}}if(X]*(?:>|$)/],[PR.PR_COMMENT,/^<\!--[\s\S]*?(?:-\->|$)/],[PR.PR_PUNCTUATION,/^(?:<[%?]|[%?]>)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-handlebars",/^]*type\s*=\s*['"]?text\/x-handlebars-template['"]?\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i],[PR.PR_DECLARATION,/^{{[#^>/]?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{&?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{{>?\s*[\w.][^}]*}}}/],[PR.PR_COMMENT,/^{{![^}]*}}/]]),["handlebars","hbs"]);PR.registerLangHandler(PR.createSimpleLexer([[PR.PR_PLAIN,/^[ \t\r\n\f]+/,null," \t\r\n\f"]],[[PR.PR_STRING,/^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/,null],[PR.PR_STRING,/^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/,null],["lang-css-str",/^url\(([^\)\"\']*)\)/i],[PR.PR_KEYWORD,/^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i],[PR.PR_COMMENT,/^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//],[PR.PR_COMMENT,/^(?:)/],[PR.PR_LITERAL,/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],[PR.PR_LITERAL,/^#(?:[0-9a-f]{3}){1,2}/i],[PR.PR_PLAIN,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i],[PR.PR_PUNCTUATION,/^[^\s\w\'\"]+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_KEYWORD,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_STRING,/^[^\)\"\']+/]]),["css-str"]); diff --git a/node_modules/react-katex/coverage/lcov-report/sort-arrow-sprite.png b/node_modules/react-katex/coverage/lcov-report/sort-arrow-sprite.png new file mode 100644 index 0000000..6ed6831 Binary files /dev/null and b/node_modules/react-katex/coverage/lcov-report/sort-arrow-sprite.png differ diff --git a/node_modules/react-katex/coverage/lcov-report/sorter.js b/node_modules/react-katex/coverage/lcov-report/sorter.js new file mode 100644 index 0000000..2bb296a --- /dev/null +++ b/node_modules/react-katex/coverage/lcov-report/sorter.js @@ -0,0 +1,196 @@ +/* eslint-disable */ +var addSorting = (function() { + 'use strict'; + var cols, + currentSort = { + index: 0, + desc: false + }; + + // returns the summary table element + function getTable() { + return document.querySelector('.coverage-summary'); + } + // returns the thead element of the summary table + function getTableHeader() { + return getTable().querySelector('thead tr'); + } + // returns the tbody element of the summary table + function getTableBody() { + return getTable().querySelector('tbody'); + } + // returns the th element for nth column + function getNthColumn(n) { + return getTableHeader().querySelectorAll('th')[n]; + } + + function onFilterInput() { + const searchValue = document.getElementById('fileSearch').value; + const rows = document.getElementsByTagName('tbody')[0].children; + for (let i = 0; i < rows.length; i++) { + const row = rows[i]; + if ( + row.textContent + .toLowerCase() + .includes(searchValue.toLowerCase()) + ) { + row.style.display = ''; + } else { + row.style.display = 'none'; + } + } + } + + // loads the search box + function addSearchBox() { + var template = document.getElementById('filterTemplate'); + var templateClone = template.content.cloneNode(true); + templateClone.getElementById('fileSearch').oninput = onFilterInput; + template.parentElement.appendChild(templateClone); + } + + // loads all columns + function loadColumns() { + var colNodes = getTableHeader().querySelectorAll('th'), + colNode, + cols = [], + col, + i; + + for (i = 0; i < colNodes.length; i += 1) { + colNode = colNodes[i]; + col = { + key: colNode.getAttribute('data-col'), + sortable: !colNode.getAttribute('data-nosort'), + type: colNode.getAttribute('data-type') || 'string' + }; + cols.push(col); + if (col.sortable) { + col.defaultDescSort = col.type === 'number'; + colNode.innerHTML = + colNode.innerHTML + ''; + } + } + return cols; + } + // attaches a data attribute to every tr element with an object + // of data values keyed by column name + function loadRowData(tableRow) { + var tableCols = tableRow.querySelectorAll('td'), + colNode, + col, + data = {}, + i, + val; + for (i = 0; i < tableCols.length; i += 1) { + colNode = tableCols[i]; + col = cols[i]; + val = colNode.getAttribute('data-value'); + if (col.type === 'number') { + val = Number(val); + } + data[col.key] = val; + } + return data; + } + // loads all row data + function loadData() { + var rows = getTableBody().querySelectorAll('tr'), + i; + + for (i = 0; i < rows.length; i += 1) { + rows[i].data = loadRowData(rows[i]); + } + } + // sorts the table using the data for the ith column + function sortByIndex(index, desc) { + var key = cols[index].key, + sorter = function(a, b) { + a = a.data[key]; + b = b.data[key]; + return a < b ? -1 : a > b ? 1 : 0; + }, + finalSorter = sorter, + tableBody = document.querySelector('.coverage-summary tbody'), + rowNodes = tableBody.querySelectorAll('tr'), + rows = [], + i; + + if (desc) { + finalSorter = function(a, b) { + return -1 * sorter(a, b); + }; + } + + for (i = 0; i < rowNodes.length; i += 1) { + rows.push(rowNodes[i]); + tableBody.removeChild(rowNodes[i]); + } + + rows.sort(finalSorter); + + for (i = 0; i < rows.length; i += 1) { + tableBody.appendChild(rows[i]); + } + } + // removes sort indicators for current column being sorted + function removeSortIndicators() { + var col = getNthColumn(currentSort.index), + cls = col.className; + + cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, ''); + col.className = cls; + } + // adds sort indicators for current column being sorted + function addSortIndicators() { + getNthColumn(currentSort.index).className += currentSort.desc + ? ' sorted-desc' + : ' sorted'; + } + // adds event listeners for all sorter widgets + function enableUI() { + var i, + el, + ithSorter = function ithSorter(i) { + var col = cols[i]; + + return function() { + var desc = col.defaultDescSort; + + if (currentSort.index === i) { + desc = !currentSort.desc; + } + sortByIndex(i, desc); + removeSortIndicators(); + currentSort.index = i; + currentSort.desc = desc; + addSortIndicators(); + }; + }; + for (i = 0; i < cols.length; i += 1) { + if (cols[i].sortable) { + // add the click event handler on the th so users + // dont have to click on those tiny arrows + el = getNthColumn(i).querySelector('.sorter').parentElement; + if (el.addEventListener) { + el.addEventListener('click', ithSorter(i)); + } else { + el.attachEvent('onclick', ithSorter(i)); + } + } + } + } + // adds sorting functionality to the UI + return function() { + if (!getTable()) { + return; + } + cols = loadColumns(); + loadData(); + addSearchBox(); + addSortIndicators(); + enableUI(); + }; +})(); + +window.addEventListener('load', addSorting); diff --git a/node_modules/react-katex/coverage/lcov-report/src/index.html b/node_modules/react-katex/coverage/lcov-report/src/index.html new file mode 100644 index 0000000..b42e258 --- /dev/null +++ b/node_modules/react-katex/coverage/lcov-report/src/index.html @@ -0,0 +1,116 @@ + + + + + + Code coverage report for src + + + + + + + + + +
+
+

All files src

+
+ +
+ 96.55% + Statements + 28/29 +
+ + +
+ 100% + Branches + 10/10 +
+ + +
+ 100% + Functions + 7/7 +
+ + +
+ 96.29% + Lines + 26/27 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
index.jsx +
+
96.55%28/29100%10/10100%7/796.29%26/27
+
+
+
+ + + + + + + + \ No newline at end of file diff --git a/node_modules/react-katex/coverage/lcov-report/src/index.jsx.html b/node_modules/react-katex/coverage/lcov-report/src/index.jsx.html new file mode 100644 index 0000000..26d4094 --- /dev/null +++ b/node_modules/react-katex/coverage/lcov-report/src/index.jsx.html @@ -0,0 +1,358 @@ + + + + + + Code coverage report for src/index.jsx + + + + + + + + + +
+
+

All files / src index.jsx

+
+ +
+ 96.55% + Statements + 28/29 +
+ + +
+ 100% + Branches + 10/10 +
+ + +
+ 100% + Functions + 7/7 +
+ + +
+ 96.29% + Lines + 26/27 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +922x +2x +2x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +2x +  +  +  +  +  +4x +32x +  +32x +32x +32x +  +  +  +  +  +22x +  +10x +10x +  +  +  +  +  +  +32x +10x +  +  +22x +  +  +4x +  +  +  +  +  +  +4x +  +  +2x +  +  +  +2x +12x +  +  +2x +  +2x +12x +  +  +2x +  +2x +2x + 
import React, { useMemo } from 'react';
+import PropTypes from 'prop-types';
+import KaTeX from 'katex';
+ 
+/**
+ * @typedef {import("react").ReactNode} ReactNode
+ *
+ *
+ * @callback ErrorRenderer
+ * @param {Error} error
+ * @returns {ReactNode}
+ *
+ *
+ * @typedef {object} MathComponentPropsWithMath
+ * @property {string} math
+ * @property {ReactNode=} children
+ * @property {string=} errorColor
+ * @property {ErrorRenderer=} renderError
+ *
+ *
+ * @typedef {object} MathComponentPropsWithChildren
+ * @property {string=} math
+ * @property {ReactNode} children
+ * @property {string=} errorColor
+ * @property {ErrorRenderer=} renderError
+ *
+ * @typedef {MathComponentPropsWithMath | MathComponentPropsWithChildren} MathComponentProps
+ */
+ 
+const createMathComponent = (Component, { displayMode }) => {
+  /**
+   *
+   * @param {MathComponentProps} props
+   * @returns {ReactNode}
+   */
+  const MathComponent = ({ children, errorColor, math, renderError }) => {
+    const formula = math ?? children;
+ 
+    const { html, error } = useMemo(() => {
+      try {
+        const html = KaTeX.renderToString(formula, {
+          displayMode,
+          errorColor,
+          throwOnError: !!renderError,
+        });
+ 
+        return { html, error: undefined };
+      } catch (error) {
+        if (error instanceof KaTeX.ParseError || error instanceof TypeError) {
+          return { error };
+        }
+ 
+        throw error;
+      }
+    }, [formula, errorColor, renderError]);
+ 
+    if (error) {
+      return renderError ? renderError(error) : <Component html={`${error.message}`} />;
+    }
+ 
+    return <Component html={html} />;
+  };
+ 
+  MathComponent.propTypes = {
+    children: PropTypes.string,
+    errorColor: PropTypes.string,
+    math: PropTypes.string,
+    renderError: PropTypes.func,
+  };
+ 
+  return MathComponent;
+};
+ 
+const InternalPathComponentPropTypes = {
+  html: PropTypes.string.isRequired,
+};
+ 
+const InternalBlockMath = ({ html }) => {
+  return <div data-testid="react-katex" dangerouslySetInnerHTML={{ __html: html }} />;
+};
+ 
+InternalBlockMath.propTypes = InternalPathComponentPropTypes;
+ 
+const InternalInlineMath = ({ html }) => {
+  return <span data-testid="react-katex" dangerouslySetInnerHTML={{ __html: html }} />;
+};
+ 
+InternalInlineMath.propTypes = InternalPathComponentPropTypes;
+ 
+export const BlockMath = createMathComponent(InternalBlockMath, { displayMode: true });
+export const InlineMath = createMathComponent(InternalInlineMath, { displayMode: false });
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/node_modules/react-katex/coverage/lcov-report/tests/index.html b/node_modules/react-katex/coverage/lcov-report/tests/index.html new file mode 100644 index 0000000..bb2c2ed --- /dev/null +++ b/node_modules/react-katex/coverage/lcov-report/tests/index.html @@ -0,0 +1,116 @@ + + + + + + Code coverage report for tests + + + + + + + + + +
+
+

All files tests

+
+ +
+ 100% + Statements + 72/72 +
+ + +
+ 100% + Branches + 0/0 +
+ + +
+ 100% + Functions + 30/30 +
+ + +
+ 100% + Lines + 66/66 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
sharedExamples.js +
+
100%72/72100%0/0100%30/30100%66/66
+
+
+
+ + + + + + + + \ No newline at end of file diff --git a/node_modules/react-katex/coverage/lcov-report/tests/sharedExamples.js.html b/node_modules/react-katex/coverage/lcov-report/tests/sharedExamples.js.html new file mode 100644 index 0000000..ba8b630 --- /dev/null +++ b/node_modules/react-katex/coverage/lcov-report/tests/sharedExamples.js.html @@ -0,0 +1,457 @@ + + + + + + Code coverage report for tests/sharedExamples.js + + + + + + + + + +
+
+

All files / tests sharedExamples.js

+
+ +
+ 100% + Statements + 72/72 +
+ + +
+ 100% + Branches + 0/0 +
+ + +
+ 100% + Functions + 30/30 +
+ + +
+ 100% + Lines + 66/66 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +1252x +2x +2x +2x +  +2x +2x +2x +2x +2x +8x +  +18x +  +2x +6x +  +14x +  +10x +  +2x +2x +2x +  +2x +  +  +2x +2x +  +2x +  +2x +  +  +  +2x +2x +2x +  +2x +  +  +2x +2x +  +2x +  +2x +  +  +  +2x +2x +2x +  +2x +  +2x +  +  +2x +2x +  +2x +  +2x +  +  +2x +2x +2x +  +2x +  +  +2x +2x +2x +  +2x +  +  +  +2x +2x +  +2x +  +  +2x +2x +  +2x +  +  +  +2x +2x +2x +  +2x +  +  +  +  +2x +2x +2x +  +2x +  +  +2x +2x +2x +  +2x +  +  +  +  +  + 
import '@testing-library/jest-dom';
+import { render, screen } from '@testing-library/react';
+import React from 'react';
+import KaTeX from 'katex';
+ 
+export default (Component, { displayMode }) => {
+  const sumFormula = '\\sum_0^\\infty';
+  const integralFormula = '\\int_{-infty}^\\infty';
+  const invalidCommandFormula = '\\inta';
+  const incompleteFormula = '\\sum_{';
+  const renderError = (error) => <span className="error">{`${error.name}: Cannot render this formula`}</span>;
+ 
+  const getReactKatexElement = () => screen.getByTestId('react-katex');
+ 
+  const expectToContainCustomError = (container, customError) =>
+    expect(container.querySelector('.error')).toContainHTML(customError);
+ 
+  const expectToContain = (content) => expect(getReactKatexElement()).toContainHTML(content);
+ 
+  const expectToContainFormula = (formula) => expectToContain(KaTeX.renderToString(formula, { displayMode }));
+ 
+  describe('when passing the formula as props', () => {
+    it('renders correctly', () => {
+      render(<Component math={sumFormula} />);
+ 
+      expectToContainFormula(sumFormula);
+    });
+ 
+    it('updates after props are updated', () => {
+      const { rerender } = render(<Component math={sumFormula} />);
+ 
+      rerender(<Component math={integralFormula} />);
+ 
+      expectToContainFormula(integralFormula, { displayMode });
+    });
+  });
+ 
+  describe('when passing the formula as child', () => {
+    it('renders correctly', () => {
+      render(<Component>{integralFormula}</Component>);
+ 
+      expectToContainFormula(integralFormula);
+    });
+ 
+    it('updates after props are updated', () => {
+      const { rerender } = render(<Component>{integralFormula}</Component>);
+ 
+      rerender(<Component>{sumFormula}</Component>);
+ 
+      expectToContainFormula(sumFormula);
+    });
+  });
+ 
+  describe('error handling', () => {
+    it('updates when passing from invalid to valid formula', () => {
+      const { rerender } = render(<Component math={invalidCommandFormula} renderError={renderError} />);
+ 
+      rerender(<Component math={integralFormula} renderError={renderError} />);
+ 
+      expectToContainFormula(integralFormula);
+    });
+ 
+    it('updates when passing from valid to invalid formula', () => {
+      const { rerender, container } = render(<Component math={integralFormula} renderError={renderError} />);
+ 
+      rerender(<Component math={invalidCommandFormula} renderError={renderError} />);
+ 
+      expectToContainCustomError(container, '<span class="error">ParseError: Cannot render this formula</span>');
+    });
+ 
+    describe('when using default error handler', () => {
+      it('renders the formula with the wrong part highlighted in default color', () => {
+        render(<Component math={invalidCommandFormula} />);
+ 
+        expect(getReactKatexElement().innerHTML).toContain('color:#cc0000;');
+      });
+ 
+      describe('when passing custom error color', () => {
+        it('renders the formula with the wrong part highlighted in custom color', () => {
+          render(<Component errorColor={'blue'} math={invalidCommandFormula} />);
+ 
+          expect(getReactKatexElement().innerHTML).toContain('color:blue;');
+        });
+      });
+ 
+      describe('when error is caused by an invalid prop type', () => {
+        beforeEach(() => {
+          // disable console.error doen by prop-types
+          jest.spyOn(console, 'error').mockImplementation(() => null);
+        });
+ 
+        it('renders error message', () => {
+          render(<Component displayMode math={123} />);
+ 
+          expectToContain('KaTeX can only parse string typed expression');
+        });
+      });
+ 
+      describe('when error is caused while parsing math expression', () => {
+        it('renders error message', () => {
+          render(<Component math={incompleteFormula} />);
+ 
+          expectToContain("KaTeX parse error: Expected '}', got 'EOF' at end of input: \\sum_{");
+        });
+      });
+    });
+ 
+    describe('when using custom error handler', () => {
+      it('renders the returned value from `renderError` prop', () => {
+        const { container } = render(<Component math={invalidCommandFormula} renderError={renderError} />);
+ 
+        expectToContainCustomError(container, '<span class="error">ParseError: Cannot render this formula</span>');
+      });
+ 
+      describe('when error is caused while parsing math expression', () => {
+        it('still uses custom handler', () => {
+          const { container } = render(<Component math={incompleteFormula} renderError={renderError} />);
+ 
+          expectToContainCustomError(container, '<span class="error">ParseError: Cannot render this formula</span>');
+        });
+      });
+    });
+  });
+};
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/node_modules/react-katex/coverage/lcov.info b/node_modules/react-katex/coverage/lcov.info new file mode 100644 index 0000000..1712b3e --- /dev/null +++ b/node_modules/react-katex/coverage/lcov.info @@ -0,0 +1,195 @@ +TN: +SF:src/index.jsx +FN:90,(anonymous_1) +FN:91,(anonymous_2) +FN:30,(anonymous_7) +FN:36,(anonymous_8) +FN:39,(anonymous_9) +FN:78,(anonymous_10) +FN:84,(anonymous_11) +FNF:7 +FNH:7 +FNDA:1,(anonymous_1) +FNDA:1,(anonymous_2) +FNDA:4,(anonymous_7) +FNDA:32,(anonymous_8) +FNDA:32,(anonymous_9) +FNDA:12,(anonymous_10) +FNDA:12,(anonymous_11) +DA:1,2 +DA:2,2 +DA:3,2 +DA:30,2 +DA:36,4 +DA:37,32 +DA:39,32 +DA:40,32 +DA:41,32 +DA:47,22 +DA:49,10 +DA:50,10 +DA:53,0 +DA:57,32 +DA:58,10 +DA:61,22 +DA:64,4 +DA:71,4 +DA:74,2 +DA:78,2 +DA:79,12 +DA:82,2 +DA:84,2 +DA:85,12 +DA:88,2 +DA:90,2 +DA:91,2 +LF:27 +LH:26 +BRDA:37,0,0,26 +BRDA:37,0,1,6 +BRDA:37,1,0,32 +BRDA:37,1,1,32 +BRDA:49,2,0,10 +BRDA:49,3,0,10 +BRDA:49,3,1,2 +BRDA:57,4,0,10 +BRDA:58,5,0,8 +BRDA:58,5,1,2 +BRF:10 +BRH:10 +end_of_record +TN: +SF:tests/sharedExamples.js +FN:6,(anonymous_0) +FN:6,(anonymous_2) +FN:11,(anonymous_3) +FN:13,(anonymous_4) +FN:15,(anonymous_5) +FN:18,(anonymous_6) +FN:20,(anonymous_7) +FN:22,(anonymous_8) +FN:23,(anonymous_9) +FN:29,(anonymous_10) +FN:38,(anonymous_11) +FN:39,(anonymous_12) +FN:45,(anonymous_13) +FN:54,(anonymous_14) +FN:55,(anonymous_15) +FN:63,(anonymous_16) +FN:71,(anonymous_17) +FN:72,(anonymous_18) +FN:78,(anonymous_19) +FN:79,(anonymous_20) +FN:86,(anonymous_21) +FN:87,(anonymous_22) +FN:89,(anonymous_23) +FN:92,(anonymous_24) +FN:99,(anonymous_25) +FN:100,(anonymous_26) +FN:108,(anonymous_27) +FN:109,(anonymous_28) +FN:115,(anonymous_29) +FN:116,(anonymous_30) +FNF:30 +FNH:30 +FNDA:2,(anonymous_0) +FNDA:2,(anonymous_2) +FNDA:8,(anonymous_3) +FNDA:18,(anonymous_4) +FNDA:6,(anonymous_5) +FNDA:14,(anonymous_6) +FNDA:10,(anonymous_7) +FNDA:2,(anonymous_8) +FNDA:2,(anonymous_9) +FNDA:2,(anonymous_10) +FNDA:2,(anonymous_11) +FNDA:2,(anonymous_12) +FNDA:2,(anonymous_13) +FNDA:2,(anonymous_14) +FNDA:2,(anonymous_15) +FNDA:2,(anonymous_16) +FNDA:2,(anonymous_17) +FNDA:2,(anonymous_18) +FNDA:2,(anonymous_19) +FNDA:2,(anonymous_20) +FNDA:2,(anonymous_21) +FNDA:2,(anonymous_22) +FNDA:2,(anonymous_23) +FNDA:2,(anonymous_24) +FNDA:2,(anonymous_25) +FNDA:2,(anonymous_26) +FNDA:2,(anonymous_27) +FNDA:2,(anonymous_28) +FNDA:2,(anonymous_29) +FNDA:2,(anonymous_30) +DA:1,2 +DA:2,2 +DA:3,2 +DA:4,2 +DA:6,2 +DA:7,2 +DA:8,2 +DA:9,2 +DA:10,2 +DA:11,8 +DA:13,18 +DA:15,2 +DA:16,6 +DA:18,14 +DA:20,10 +DA:22,2 +DA:23,2 +DA:24,2 +DA:26,2 +DA:29,2 +DA:30,2 +DA:32,2 +DA:34,2 +DA:38,2 +DA:39,2 +DA:40,2 +DA:42,2 +DA:45,2 +DA:46,2 +DA:48,2 +DA:50,2 +DA:54,2 +DA:55,2 +DA:56,2 +DA:58,2 +DA:60,2 +DA:63,2 +DA:64,2 +DA:66,2 +DA:68,2 +DA:71,2 +DA:72,2 +DA:73,2 +DA:75,2 +DA:78,2 +DA:79,2 +DA:80,2 +DA:82,2 +DA:86,2 +DA:87,2 +DA:89,2 +DA:92,2 +DA:93,2 +DA:95,2 +DA:99,2 +DA:100,2 +DA:101,2 +DA:103,2 +DA:108,2 +DA:109,2 +DA:110,2 +DA:112,2 +DA:115,2 +DA:116,2 +DA:117,2 +DA:119,2 +LF:66 +LH:66 +BRF:0 +BRH:0 +end_of_record diff --git a/node_modules/react-katex/dist/react-katex.d.ts/fonts/OpenSans-Bold-webfont.eot b/node_modules/react-katex/dist/react-katex.d.ts/fonts/OpenSans-Bold-webfont.eot new file mode 100644 index 0000000..5d20d91 Binary files /dev/null and b/node_modules/react-katex/dist/react-katex.d.ts/fonts/OpenSans-Bold-webfont.eot differ diff --git a/node_modules/react-katex/dist/react-katex.d.ts/fonts/OpenSans-Bold-webfont.svg b/node_modules/react-katex/dist/react-katex.d.ts/fonts/OpenSans-Bold-webfont.svg new file mode 100644 index 0000000..3ed7be4 --- /dev/null +++ b/node_modules/react-katex/dist/react-katex.d.ts/fonts/OpenSans-Bold-webfont.svg @@ -0,0 +1,1830 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/node_modules/react-katex/dist/react-katex.d.ts/fonts/OpenSans-Bold-webfont.woff b/node_modules/react-katex/dist/react-katex.d.ts/fonts/OpenSans-Bold-webfont.woff new file mode 100644 index 0000000..1205787 Binary files /dev/null and b/node_modules/react-katex/dist/react-katex.d.ts/fonts/OpenSans-Bold-webfont.woff differ diff --git a/node_modules/react-katex/dist/react-katex.d.ts/fonts/OpenSans-BoldItalic-webfont.eot b/node_modules/react-katex/dist/react-katex.d.ts/fonts/OpenSans-BoldItalic-webfont.eot new file mode 100644 index 0000000..1f639a1 Binary files /dev/null and b/node_modules/react-katex/dist/react-katex.d.ts/fonts/OpenSans-BoldItalic-webfont.eot differ diff --git a/node_modules/react-katex/dist/react-katex.d.ts/fonts/OpenSans-BoldItalic-webfont.svg b/node_modules/react-katex/dist/react-katex.d.ts/fonts/OpenSans-BoldItalic-webfont.svg new file mode 100644 index 0000000..6a2607b --- /dev/null +++ b/node_modules/react-katex/dist/react-katex.d.ts/fonts/OpenSans-BoldItalic-webfont.svg @@ -0,0 +1,1830 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/node_modules/react-katex/dist/react-katex.d.ts/fonts/OpenSans-BoldItalic-webfont.woff b/node_modules/react-katex/dist/react-katex.d.ts/fonts/OpenSans-BoldItalic-webfont.woff new file mode 100644 index 0000000..ed760c0 Binary files /dev/null and b/node_modules/react-katex/dist/react-katex.d.ts/fonts/OpenSans-BoldItalic-webfont.woff differ diff --git a/node_modules/react-katex/dist/react-katex.d.ts/fonts/OpenSans-Italic-webfont.eot b/node_modules/react-katex/dist/react-katex.d.ts/fonts/OpenSans-Italic-webfont.eot new file mode 100644 index 0000000..0c8a0ae Binary files /dev/null and b/node_modules/react-katex/dist/react-katex.d.ts/fonts/OpenSans-Italic-webfont.eot differ diff --git a/node_modules/react-katex/dist/react-katex.d.ts/fonts/OpenSans-Italic-webfont.svg b/node_modules/react-katex/dist/react-katex.d.ts/fonts/OpenSans-Italic-webfont.svg new file mode 100644 index 0000000..e1075dc --- /dev/null +++ b/node_modules/react-katex/dist/react-katex.d.ts/fonts/OpenSans-Italic-webfont.svg @@ -0,0 +1,1830 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/node_modules/react-katex/dist/react-katex.d.ts/fonts/OpenSans-Italic-webfont.woff b/node_modules/react-katex/dist/react-katex.d.ts/fonts/OpenSans-Italic-webfont.woff new file mode 100644 index 0000000..ff652e6 Binary files /dev/null and b/node_modules/react-katex/dist/react-katex.d.ts/fonts/OpenSans-Italic-webfont.woff differ diff --git a/node_modules/react-katex/dist/react-katex.d.ts/fonts/OpenSans-Light-webfont.eot b/node_modules/react-katex/dist/react-katex.d.ts/fonts/OpenSans-Light-webfont.eot new file mode 100644 index 0000000..1486840 Binary files /dev/null and b/node_modules/react-katex/dist/react-katex.d.ts/fonts/OpenSans-Light-webfont.eot differ diff --git a/node_modules/react-katex/dist/react-katex.d.ts/fonts/OpenSans-Light-webfont.svg b/node_modules/react-katex/dist/react-katex.d.ts/fonts/OpenSans-Light-webfont.svg new file mode 100644 index 0000000..11a472c --- /dev/null +++ b/node_modules/react-katex/dist/react-katex.d.ts/fonts/OpenSans-Light-webfont.svg @@ -0,0 +1,1831 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/node_modules/react-katex/dist/react-katex.d.ts/fonts/OpenSans-Light-webfont.woff b/node_modules/react-katex/dist/react-katex.d.ts/fonts/OpenSans-Light-webfont.woff new file mode 100644 index 0000000..e786074 Binary files /dev/null and b/node_modules/react-katex/dist/react-katex.d.ts/fonts/OpenSans-Light-webfont.woff differ diff --git a/node_modules/react-katex/dist/react-katex.d.ts/fonts/OpenSans-LightItalic-webfont.eot b/node_modules/react-katex/dist/react-katex.d.ts/fonts/OpenSans-LightItalic-webfont.eot new file mode 100644 index 0000000..8f44592 Binary files /dev/null and b/node_modules/react-katex/dist/react-katex.d.ts/fonts/OpenSans-LightItalic-webfont.eot differ diff --git a/node_modules/react-katex/dist/react-katex.d.ts/fonts/OpenSans-LightItalic-webfont.svg b/node_modules/react-katex/dist/react-katex.d.ts/fonts/OpenSans-LightItalic-webfont.svg new file mode 100644 index 0000000..431d7e3 --- /dev/null +++ b/node_modules/react-katex/dist/react-katex.d.ts/fonts/OpenSans-LightItalic-webfont.svg @@ -0,0 +1,1835 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/node_modules/react-katex/dist/react-katex.d.ts/fonts/OpenSans-LightItalic-webfont.woff b/node_modules/react-katex/dist/react-katex.d.ts/fonts/OpenSans-LightItalic-webfont.woff new file mode 100644 index 0000000..43e8b9e Binary files /dev/null and b/node_modules/react-katex/dist/react-katex.d.ts/fonts/OpenSans-LightItalic-webfont.woff differ diff --git a/node_modules/react-katex/dist/react-katex.d.ts/fonts/OpenSans-Regular-webfont.eot b/node_modules/react-katex/dist/react-katex.d.ts/fonts/OpenSans-Regular-webfont.eot new file mode 100644 index 0000000..6bbc3cf Binary files /dev/null and b/node_modules/react-katex/dist/react-katex.d.ts/fonts/OpenSans-Regular-webfont.eot differ diff --git a/node_modules/react-katex/dist/react-katex.d.ts/fonts/OpenSans-Regular-webfont.svg b/node_modules/react-katex/dist/react-katex.d.ts/fonts/OpenSans-Regular-webfont.svg new file mode 100644 index 0000000..25a3952 --- /dev/null +++ b/node_modules/react-katex/dist/react-katex.d.ts/fonts/OpenSans-Regular-webfont.svg @@ -0,0 +1,1831 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/node_modules/react-katex/dist/react-katex.d.ts/fonts/OpenSans-Regular-webfont.woff b/node_modules/react-katex/dist/react-katex.d.ts/fonts/OpenSans-Regular-webfont.woff new file mode 100644 index 0000000..e231183 Binary files /dev/null and b/node_modules/react-katex/dist/react-katex.d.ts/fonts/OpenSans-Regular-webfont.woff differ diff --git a/node_modules/react-katex/dist/react-katex.d.ts/global.html b/node_modules/react-katex/dist/react-katex.d.ts/global.html new file mode 100644 index 0000000..f2fa519 --- /dev/null +++ b/node_modules/react-katex/dist/react-katex.d.ts/global.html @@ -0,0 +1,555 @@ + + + + + JSDoc: Global + + + + + + + + + + +
+ +

Global

+ + + + + + +
+ +
+ +

+ + +
+ +
+
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + +

Type Definitions

+ + + + + + + +

MathComponentProps(error) → {ReactNode}

+ + + + + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
error + + +Error + + + +
+ + + + + + +
Properties:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
math + + +string + + + + + + + +
children + + +ReactNode + + + + + + <optional>
+ + + +
errorColor + + +string + + + + + + <optional>
+ + + +
renderError + + +ErrorRenderer + + + + + + <optional>
+ + + +
math + + +string + + + + + + <optional>
+ + + +
children + + +ReactNode + + + + + + + +
errorColor + + +string + + + + + + <optional>
+ + + +
renderError + + +ErrorRenderer + + + + + + <optional>
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + +
Returns:
+ + + + +
+
+ Type +
+
+ +ReactNode + + +
+
+ + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.6.11 on Wed Aug 10 2022 20:21:11 GMT-0300 (Brasilia Standard Time) +
+ + + + + \ No newline at end of file diff --git a/node_modules/react-katex/dist/react-katex.d.ts/index.html b/node_modules/react-katex/dist/react-katex.d.ts/index.html new file mode 100644 index 0000000..2790f5d --- /dev/null +++ b/node_modules/react-katex/dist/react-katex.d.ts/index.html @@ -0,0 +1,65 @@ + + + + + JSDoc: Home + + + + + + + + + + +
+ +

Home

+ + + + + + + + +

+ + + + + + + + + + + + + + + + + + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.6.11 on Wed Aug 10 2022 20:21:11 GMT-0300 (Brasilia Standard Time) +
+ + + + + \ No newline at end of file diff --git a/node_modules/react-katex/dist/react-katex.d.ts/index.jsx.html b/node_modules/react-katex/dist/react-katex.d.ts/index.jsx.html new file mode 100644 index 0000000..086eb55 --- /dev/null +++ b/node_modules/react-katex/dist/react-katex.d.ts/index.jsx.html @@ -0,0 +1,142 @@ + + + + + JSDoc: Source: index.jsx + + + + + + + + + + +
+ +

Source: index.jsx

+ + + + + + +
+
+
import React, { useMemo } from 'react';
+import PropTypes from 'prop-types';
+import KaTeX from 'katex';
+
+/**
+ * @typedef {import("react").ReactNode} ReactNode
+ *
+ *
+ * @callback ErrorRenderer
+ * @param {Error} error
+ * @returns {ReactNode}
+ *
+ *
+ * @typedef {object} MathComponentPropsWithMath
+ * @property {string} math
+ * @property {ReactNode=} children
+ * @property {string=} errorColor
+ * @property {ErrorRenderer=} renderError
+ *
+ *
+ * @typedef {object} MathComponentPropsWithChildren
+ * @property {string=} math
+ * @property {ReactNode} children
+ * @property {string=} errorColor
+ * @property {ErrorRenderer=} renderError
+ *
+ * @typedef {MathComponentPropsWithMath | MathComponentPropsWithChildren} MathComponentProps
+ */
+
+const createMathComponent = (Component, { displayMode }) => {
+  /**
+   *
+   * @param {MathComponentProps} props
+   * @returns {ReactNode}
+   */
+  const MathComponent = ({ children, errorColor, math, renderError }) => {
+    const formula = math ?? children;
+
+    const { html, error } = useMemo(() => {
+      try {
+        const html = KaTeX.renderToString(formula, {
+          displayMode,
+          errorColor,
+          throwOnError: !!renderError,
+        });
+
+        return { html, error: undefined };
+      } catch (error) {
+        if (error instanceof KaTeX.ParseError || error instanceof TypeError) {
+          return { error };
+        }
+
+        throw error;
+      }
+    }, [formula, errorColor, renderError]);
+
+    if (error) {
+      return renderError ? renderError(error) : <Component html={`${error.message}`} />;
+    }
+
+    return <Component html={html} />;
+  };
+
+  MathComponent.propTypes = {
+    children: PropTypes.string,
+    errorColor: PropTypes.string,
+    math: PropTypes.string,
+    renderError: PropTypes.func,
+  };
+
+  return MathComponent;
+};
+
+const InternalPathComponentPropTypes = {
+  html: PropTypes.string.isRequired,
+};
+
+const InternalBlockMath = ({ html }) => {
+  return <div data-testid="react-katex" dangerouslySetInnerHTML={{ __html: html }} />;
+};
+
+InternalBlockMath.propTypes = InternalPathComponentPropTypes;
+
+const InternalInlineMath = ({ html }) => {
+  return <span data-testid="react-katex" dangerouslySetInnerHTML={{ __html: html }} />;
+};
+
+InternalInlineMath.propTypes = InternalPathComponentPropTypes;
+
+export const BlockMath = createMathComponent(InternalBlockMath, { displayMode: true });
+export const InlineMath = createMathComponent(InternalInlineMath, { displayMode: false });
+
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.6.11 on Wed Aug 10 2022 20:21:11 GMT-0300 (Brasilia Standard Time) +
+ + + + + diff --git a/node_modules/react-katex/dist/react-katex.d.ts/scripts/linenumber.js b/node_modules/react-katex/dist/react-katex.d.ts/scripts/linenumber.js new file mode 100644 index 0000000..4354785 --- /dev/null +++ b/node_modules/react-katex/dist/react-katex.d.ts/scripts/linenumber.js @@ -0,0 +1,25 @@ +/*global document */ +(() => { + const source = document.getElementsByClassName('prettyprint source linenums'); + let i = 0; + let lineNumber = 0; + let lineId; + let lines; + let totalLines; + let anchorHash; + + if (source && source[0]) { + anchorHash = document.location.hash.substring(1); + lines = source[0].getElementsByTagName('li'); + totalLines = lines.length; + + for (; i < totalLines; i++) { + lineNumber++; + lineId = `line${lineNumber}`; + lines[i].id = lineId; + if (lineId === anchorHash) { + lines[i].className += ' selected'; + } + } + } +})(); diff --git a/node_modules/react-katex/dist/react-katex.d.ts/scripts/prettify/Apache-License-2.0.txt b/node_modules/react-katex/dist/react-katex.d.ts/scripts/prettify/Apache-License-2.0.txt new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/node_modules/react-katex/dist/react-katex.d.ts/scripts/prettify/Apache-License-2.0.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/node_modules/react-katex/dist/react-katex.d.ts/scripts/prettify/lang-css.js b/node_modules/react-katex/dist/react-katex.d.ts/scripts/prettify/lang-css.js new file mode 100644 index 0000000..041e1f5 --- /dev/null +++ b/node_modules/react-katex/dist/react-katex.d.ts/scripts/prettify/lang-css.js @@ -0,0 +1,2 @@ +PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\f\r ]+/,null," \t\r\n "]],[["str",/^"(?:[^\n\f\r"\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*"/,null],["str",/^'(?:[^\n\f\r'\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*'/,null],["lang-css-str",/^url\(([^"')]*)\)/i],["kwd",/^(?:url|rgb|!important|@import|@page|@media|@charset|inherit)(?=[^\w-]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*)\s*:/i],["com",/^\/\*[^*]*\*+(?:[^*/][^*]*\*+)*\//],["com", +/^(?:<\!--|--\>)/],["lit",/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],["lit",/^#[\da-f]{3,6}/i],["pln",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i],["pun",/^[^\s\w"']+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[["kwd",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[["str",/^[^"')]+/]]),["css-str"]); diff --git a/node_modules/react-katex/dist/react-katex.d.ts/scripts/prettify/prettify.js b/node_modules/react-katex/dist/react-katex.d.ts/scripts/prettify/prettify.js new file mode 100644 index 0000000..eef5ad7 --- /dev/null +++ b/node_modules/react-katex/dist/react-katex.d.ts/scripts/prettify/prettify.js @@ -0,0 +1,28 @@ +var q=null;window.PR_SHOULD_USE_CONTINUATION=!0; +(function(){function L(a){function m(a){var f=a.charCodeAt(0);if(f!==92)return f;var b=a.charAt(1);return(f=r[b])?f:"0"<=b&&b<="7"?parseInt(a.substring(1),8):b==="u"||b==="x"?parseInt(a.substring(2),16):a.charCodeAt(1)}function e(a){if(a<32)return(a<16?"\\x0":"\\x")+a.toString(16);a=String.fromCharCode(a);if(a==="\\"||a==="-"||a==="["||a==="]")a="\\"+a;return a}function h(a){for(var f=a.substring(1,a.length-1).match(/\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\[0-3][0-7]{0,2}|\\[0-7]{1,2}|\\[\S\s]|[^\\]/g),a= +[],b=[],o=f[0]==="^",c=o?1:0,i=f.length;c122||(d<65||j>90||b.push([Math.max(65,j)|32,Math.min(d,90)|32]),d<97||j>122||b.push([Math.max(97,j)&-33,Math.min(d,122)&-33]))}}b.sort(function(a,f){return a[0]-f[0]||f[1]-a[1]});f=[];j=[NaN,NaN];for(c=0;ci[0]&&(i[1]+1>i[0]&&b.push("-"),b.push(e(i[1])));b.push("]");return b.join("")}function y(a){for(var f=a.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),b=f.length,d=[],c=0,i=0;c=2&&a==="["?f[c]=h(j):a!=="\\"&&(f[c]=j.replace(/[A-Za-z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return f.join("")}for(var t=0,s=!1,l=!1,p=0,d=a.length;p=5&&"lang-"===b.substring(0,5))&&!(o&&typeof o[1]==="string"))c=!1,b="src";c||(r[f]=b)}i=d;d+=f.length;if(c){c=o[1];var j=f.indexOf(c),k=j+c.length;o[2]&&(k=f.length-o[2].length,j=k-c.length);b=b.substring(5);B(l+i,f.substring(0,j),e,p);B(l+i+j,c,C(b,c),p);B(l+i+k,f.substring(k),e,p)}else p.push(l+i,b)}a.e=p}var h={},y;(function(){for(var e=a.concat(m), +l=[],p={},d=0,g=e.length;d=0;)h[n.charAt(k)]=r;r=r[1];n=""+r;p.hasOwnProperty(n)||(l.push(r),p[n]=q)}l.push(/[\S\s]/);y=L(l)})();var t=m.length;return e}function u(a){var m=[],e=[];a.tripleQuotedStrings?m.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/,q,"'\""]):a.multiLineStrings?m.push(["str",/^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/, +q,"'\"`"]):m.push(["str",/^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,q,"\"'"]);a.verbatimStrings&&e.push(["str",/^@"(?:[^"]|"")*(?:"|$)/,q]);var h=a.hashComments;h&&(a.cStyleComments?(h>1?m.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,q,"#"]):m.push(["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\n\r]*)/,q,"#"]),e.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,q])):m.push(["com",/^#[^\n\r]*/, +q,"#"]));a.cStyleComments&&(e.push(["com",/^\/\/[^\n\r]*/,q]),e.push(["com",/^\/\*[\S\s]*?(?:\*\/|$)/,q]));a.regexLiterals&&e.push(["lang-regex",/^(?:^^\.?|[!+-]|!=|!==|#|%|%=|&|&&|&&=|&=|\(|\*|\*=|\+=|,|-=|->|\/|\/=|:|::|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|[?@[^]|\^=|\^\^|\^\^=|{|\||\|=|\|\||\|\|=|~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\s*(\/(?=[^*/])(?:[^/[\\]|\\[\S\s]|\[(?:[^\\\]]|\\[\S\s])*(?:]|$))+\/)/]);(h=a.types)&&e.push(["typ",h]);a=(""+a.keywords).replace(/^ | $/g, +"");a.length&&e.push(["kwd",RegExp("^(?:"+a.replace(/[\s,]+/g,"|")+")\\b"),q]);m.push(["pln",/^\s+/,q," \r\n\t\xa0"]);e.push(["lit",/^@[$_a-z][\w$@]*/i,q],["typ",/^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,q],["pln",/^[$_a-z][\w$@]*/i,q],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,q,"0123456789"],["pln",/^\\[\S\s]?/,q],["pun",/^.[^\s\w"-$'./@\\`]*/,q]);return x(m,e)}function D(a,m){function e(a){switch(a.nodeType){case 1:if(k.test(a.className))break;if("BR"===a.nodeName)h(a), +a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)e(a);break;case 3:case 4:if(p){var b=a.nodeValue,d=b.match(t);if(d){var c=b.substring(0,d.index);a.nodeValue=c;(b=b.substring(d.index+d[0].length))&&a.parentNode.insertBefore(s.createTextNode(b),a.nextSibling);h(a);c||a.parentNode.removeChild(a)}}}}function h(a){function b(a,d){var e=d?a.cloneNode(!1):a,f=a.parentNode;if(f){var f=b(f,1),g=a.nextSibling;f.appendChild(e);for(var h=g;h;h=g)g=h.nextSibling,f.appendChild(h)}return e} +for(;!a.nextSibling;)if(a=a.parentNode,!a)return;for(var a=b(a.nextSibling,0),e;(e=a.parentNode)&&e.nodeType===1;)a=e;d.push(a)}var k=/(?:^|\s)nocode(?:\s|$)/,t=/\r\n?|\n/,s=a.ownerDocument,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=s.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);for(l=s.createElement("LI");a.firstChild;)l.appendChild(a.firstChild);for(var d=[l],g=0;g=0;){var h=m[e];A.hasOwnProperty(h)?window.console&&console.warn("cannot override language handler %s",h):A[h]=a}}function C(a,m){if(!a||!A.hasOwnProperty(a))a=/^\s*=o&&(h+=2);e>=c&&(a+=2)}}catch(w){"console"in window&&console.log(w&&w.stack?w.stack:w)}}var v=["break,continue,do,else,for,if,return,while"],w=[[v,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"], +"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],F=[w,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],G=[w,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"], +H=[G,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"],w=[w,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"],I=[v,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"], +J=[v,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],v=[v,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],K=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/,N=/\S/,O=u({keywords:[F,H,w,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END"+ +I,J,v],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),A={};k(O,["default-code"]);k(x([],[["pln",/^[^]*(?:>|$)/],["com",/^<\!--[\S\s]*?(?:--\>|$)/],["lang-",/^<\?([\S\s]+?)(?:\?>|$)/],["lang-",/^<%([\S\s]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\S\s]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\S\s]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\S\s]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]), +["default-markup","htm","html","mxml","xhtml","xml","xsl"]);k(x([["pln",/^\s+/,q," \t\r\n"],["atv",/^(?:"[^"]*"?|'[^']*'?)/,q,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w-.:]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^\s"'>]*(?:[^\s"'/>]|\/(?=\s)))/],["pun",/^[/<->]+/],["lang-js",/^on\w+\s*=\s*"([^"]+)"/i],["lang-js",/^on\w+\s*=\s*'([^']+)'/i],["lang-js",/^on\w+\s*=\s*([^\s"'>]+)/i],["lang-css",/^style\s*=\s*"([^"]+)"/i],["lang-css",/^style\s*=\s*'([^']+)'/i],["lang-css", +/^style\s*=\s*([^\s"'>]+)/i]]),["in.tag"]);k(x([],[["atv",/^[\S\s]+/]]),["uq.val"]);k(u({keywords:F,hashComments:!0,cStyleComments:!0,types:K}),["c","cc","cpp","cxx","cyc","m"]);k(u({keywords:"null,true,false"}),["json"]);k(u({keywords:H,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:K}),["cs"]);k(u({keywords:G,cStyleComments:!0}),["java"]);k(u({keywords:v,hashComments:!0,multiLineStrings:!0}),["bsh","csh","sh"]);k(u({keywords:I,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}), +["cv","py"]);k(u({keywords:"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["perl","pl","pm"]);k(u({keywords:J,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb"]);k(u({keywords:w,cStyleComments:!0,regexLiterals:!0}),["js"]);k(u({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes", +hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]);k(x([],[["str",/^[\S\s]+/]]),["regex"]);window.prettyPrintOne=function(a,m,e){var h=document.createElement("PRE");h.innerHTML=a;e&&D(h,e);E({g:m,i:e,h:h});return h.innerHTML};window.prettyPrint=function(a){function m(){for(var e=window.PR_SHOULD_USE_CONTINUATION?l.now()+250:Infinity;p=0){var k=k.match(g),f,b;if(b= +!k){b=n;for(var o=void 0,c=b.firstChild;c;c=c.nextSibling)var i=c.nodeType,o=i===1?o?b:c:i===3?N.test(c.nodeValue)?b:o:o;b=(f=o===b?void 0:o)&&"CODE"===f.tagName}b&&(k=f.className.match(g));k&&(k=k[1]);b=!1;for(o=n.parentNode;o;o=o.parentNode)if((o.tagName==="pre"||o.tagName==="code"||o.tagName==="xmp")&&o.className&&o.className.indexOf("prettyprint")>=0){b=!0;break}b||((b=(b=n.className.match(/\blinenums\b(?::(\d+))?/))?b[1]&&b[1].length?+b[1]:!0:!1)&&D(n,b),d={g:k,h:n,i:b},E(d))}}p th:last-child { border-right: 1px solid #ddd; } + +.ancestors, .attribs { color: #999; } +.ancestors a, .attribs a +{ + color: #999 !important; + text-decoration: none; +} + +.clear +{ + clear: both; +} + +.important +{ + font-weight: bold; + color: #950B02; +} + +.yes-def { + text-indent: -1000px; +} + +.type-signature { + color: #aaa; +} + +.name, .signature { + font-family: Consolas, Monaco, 'Andale Mono', monospace; +} + +.details { margin-top: 14px; border-left: 2px solid #DDD; } +.details dt { width: 120px; float: left; padding-left: 10px; padding-top: 6px; } +.details dd { margin-left: 70px; } +.details ul { margin: 0; } +.details ul { list-style-type: none; } +.details li { margin-left: 30px; padding-top: 6px; } +.details pre.prettyprint { margin: 0 } +.details .object-value { padding-top: 0; } + +.description { + margin-bottom: 1em; + margin-top: 1em; +} + +.code-caption +{ + font-style: italic; + font-size: 107%; + margin: 0; +} + +.source +{ + border: 1px solid #ddd; + width: 80%; + overflow: auto; +} + +.prettyprint.source { + width: inherit; +} + +.source code +{ + font-size: 100%; + line-height: 18px; + display: block; + padding: 4px 12px; + margin: 0; + background-color: #fff; + color: #4D4E53; +} + +.prettyprint code span.line +{ + display: inline-block; +} + +.prettyprint.linenums +{ + padding-left: 70px; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +.prettyprint.linenums ol +{ + padding-left: 0; +} + +.prettyprint.linenums li +{ + border-left: 3px #ddd solid; +} + +.prettyprint.linenums li.selected, +.prettyprint.linenums li.selected * +{ + background-color: lightyellow; +} + +.prettyprint.linenums li * +{ + -webkit-user-select: text; + -moz-user-select: text; + -ms-user-select: text; + user-select: text; +} + +.params .name, .props .name, .name code { + color: #4D4E53; + font-family: Consolas, Monaco, 'Andale Mono', monospace; + font-size: 100%; +} + +.params td.description > p:first-child, +.props td.description > p:first-child +{ + margin-top: 0; + padding-top: 0; +} + +.params td.description > p:last-child, +.props td.description > p:last-child +{ + margin-bottom: 0; + padding-bottom: 0; +} + +.disabled { + color: #454545; +} diff --git a/node_modules/react-katex/dist/react-katex.d.ts/styles/prettify-jsdoc.css b/node_modules/react-katex/dist/react-katex.d.ts/styles/prettify-jsdoc.css new file mode 100644 index 0000000..5a2526e --- /dev/null +++ b/node_modules/react-katex/dist/react-katex.d.ts/styles/prettify-jsdoc.css @@ -0,0 +1,111 @@ +/* JSDoc prettify.js theme */ + +/* plain text */ +.pln { + color: #000000; + font-weight: normal; + font-style: normal; +} + +/* string content */ +.str { + color: #006400; + font-weight: normal; + font-style: normal; +} + +/* a keyword */ +.kwd { + color: #000000; + font-weight: bold; + font-style: normal; +} + +/* a comment */ +.com { + font-weight: normal; + font-style: italic; +} + +/* a type name */ +.typ { + color: #000000; + font-weight: normal; + font-style: normal; +} + +/* a literal value */ +.lit { + color: #006400; + font-weight: normal; + font-style: normal; +} + +/* punctuation */ +.pun { + color: #000000; + font-weight: bold; + font-style: normal; +} + +/* lisp open bracket */ +.opn { + color: #000000; + font-weight: bold; + font-style: normal; +} + +/* lisp close bracket */ +.clo { + color: #000000; + font-weight: bold; + font-style: normal; +} + +/* a markup tag name */ +.tag { + color: #006400; + font-weight: normal; + font-style: normal; +} + +/* a markup attribute name */ +.atn { + color: #006400; + font-weight: normal; + font-style: normal; +} + +/* a markup attribute value */ +.atv { + color: #006400; + font-weight: normal; + font-style: normal; +} + +/* a declaration */ +.dec { + color: #000000; + font-weight: bold; + font-style: normal; +} + +/* a variable name */ +.var { + color: #000000; + font-weight: normal; + font-style: normal; +} + +/* a function name */ +.fun { + color: #000000; + font-weight: bold; + font-style: normal; +} + +/* Specify class=linenums on a pre to get line numbering */ +ol.linenums { + margin-top: 0; + margin-bottom: 0; +} diff --git a/node_modules/react-katex/dist/react-katex.d.ts/styles/prettify-tomorrow.css b/node_modules/react-katex/dist/react-katex.d.ts/styles/prettify-tomorrow.css new file mode 100644 index 0000000..b6f92a7 --- /dev/null +++ b/node_modules/react-katex/dist/react-katex.d.ts/styles/prettify-tomorrow.css @@ -0,0 +1,132 @@ +/* Tomorrow Theme */ +/* Original theme - https://github.com/chriskempson/tomorrow-theme */ +/* Pretty printing styles. Used with prettify.js. */ +/* SPAN elements with the classes below are added by prettyprint. */ +/* plain text */ +.pln { + color: #4d4d4c; } + +@media screen { + /* string content */ + .str { + color: #718c00; } + + /* a keyword */ + .kwd { + color: #8959a8; } + + /* a comment */ + .com { + color: #8e908c; } + + /* a type name */ + .typ { + color: #4271ae; } + + /* a literal value */ + .lit { + color: #f5871f; } + + /* punctuation */ + .pun { + color: #4d4d4c; } + + /* lisp open bracket */ + .opn { + color: #4d4d4c; } + + /* lisp close bracket */ + .clo { + color: #4d4d4c; } + + /* a markup tag name */ + .tag { + color: #c82829; } + + /* a markup attribute name */ + .atn { + color: #f5871f; } + + /* a markup attribute value */ + .atv { + color: #3e999f; } + + /* a declaration */ + .dec { + color: #f5871f; } + + /* a variable name */ + .var { + color: #c82829; } + + /* a function name */ + .fun { + color: #4271ae; } } +/* Use higher contrast and text-weight for printable form. */ +@media print, projection { + .str { + color: #060; } + + .kwd { + color: #006; + font-weight: bold; } + + .com { + color: #600; + font-style: italic; } + + .typ { + color: #404; + font-weight: bold; } + + .lit { + color: #044; } + + .pun, .opn, .clo { + color: #440; } + + .tag { + color: #006; + font-weight: bold; } + + .atn { + color: #404; } + + .atv { + color: #060; } } +/* Style */ +/* +pre.prettyprint { + background: white; + font-family: Consolas, Monaco, 'Andale Mono', monospace; + font-size: 12px; + line-height: 1.5; + border: 1px solid #ccc; + padding: 10px; } +*/ + +/* Specify class=linenums on a pre to get line numbering */ +ol.linenums { + margin-top: 0; + margin-bottom: 0; } + +/* IE indents via margin-left */ +li.L0, +li.L1, +li.L2, +li.L3, +li.L4, +li.L5, +li.L6, +li.L7, +li.L8, +li.L9 { + /* */ } + +/* Alternate shading for lines */ +li.L1, +li.L3, +li.L5, +li.L7, +li.L9 { + /* */ } diff --git a/node_modules/react-katex/dist/react-katex.js b/node_modules/react-katex/dist/react-katex.js new file mode 100644 index 0000000..0c99b0f --- /dev/null +++ b/node_modules/react-katex/dist/react-katex.js @@ -0,0 +1,174 @@ +(function(global, factory) { + if (typeof module === "object" && typeof module.exports === "object") factory(exports, require("react"), require("prop-types"), require("katex")); + else if (typeof define === "function" && define.amd) define([ + "exports", + "react", + "prop-types", + "katex" + ], factory); + else if (global = typeof globalThis !== "undefined" ? globalThis : global || self) factory(global.index = {}, global.react, global.propTypes, global.katex); +})(this, function(exports, _react, _propTypes, _katex) { + "use strict"; + Object.defineProperty(exports, "__esModule", { + value: true + }); + function _export(target, all) { + for(var name in all)Object.defineProperty(target, name, { + enumerable: true, + get: all[name] + }); + } + _export(exports, { + BlockMath: ()=>BlockMath, + InlineMath: ()=>InlineMath + }); + _react = /*#__PURE__*/ _interopRequireWildcard(_react); + _propTypes = /*#__PURE__*/ _interopRequireDefault(_propTypes); + _katex = /*#__PURE__*/ _interopRequireDefault(_katex); + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; + } + function _getRequireWildcardCache(nodeInterop) { + if (typeof WeakMap !== "function") return null; + var cacheBabelInterop = new WeakMap(); + var cacheNodeInterop = new WeakMap(); + return (_getRequireWildcardCache = function(nodeInterop) { + return nodeInterop ? cacheNodeInterop : cacheBabelInterop; + })(nodeInterop); + } + function _interopRequireWildcard(obj, nodeInterop) { + if (!nodeInterop && obj && obj.__esModule) { + return obj; + } + if (obj === null || typeof obj !== "object" && typeof obj !== "function") { + return { + default: obj + }; + } + var cache = _getRequireWildcardCache(nodeInterop); + if (cache && cache.has(obj)) { + return cache.get(obj); + } + var newObj = {}; + var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; + for(var key in obj){ + if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { + var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; + if (desc && (desc.get || desc.set)) { + Object.defineProperty(newObj, key, desc); + } else { + newObj[key] = obj[key]; + } + } + } + newObj.default = obj; + if (cache) { + cache.set(obj, newObj); + } + return newObj; + } + /** + * @typedef {import("react").ReactNode} ReactNode + * + * + * @callback ErrorRenderer + * @param {Error} error + * @returns {ReactNode} + * + * + * @typedef {object} MathComponentPropsWithMath + * @property {string} math + * @property {ReactNode=} children + * @property {string=} errorColor + * @property {ErrorRenderer=} renderError + * + * + * @typedef {object} MathComponentPropsWithChildren + * @property {string=} math + * @property {ReactNode} children + * @property {string=} errorColor + * @property {ErrorRenderer=} renderError + * + * @typedef {MathComponentPropsWithMath | MathComponentPropsWithChildren} MathComponentProps + */ const createMathComponent = (Component, { displayMode })=>{ + /** + * + * @param {MathComponentProps} props + * @returns {ReactNode} + */ const MathComponent = ({ children , errorColor , math , renderError })=>{ + const formula = math !== null && math !== void 0 ? math : children; + const { html , error } = (0, _react.useMemo)(()=>{ + try { + const html = _katex.default.renderToString(formula, { + displayMode, + errorColor, + throwOnError: !!renderError + }); + return { + html, + error: undefined + }; + } catch (error) { + if (error instanceof _katex.default.ParseError || error instanceof TypeError) { + return { + error + }; + } + throw error; + } + }, [ + formula, + errorColor, + renderError + ]); + if (error) { + return renderError ? renderError(error) : /*#__PURE__*/ _react.default.createElement(Component, { + html: `${error.message}` + }); + } + return /*#__PURE__*/ _react.default.createElement(Component, { + html: html + }); + }; + MathComponent.propTypes = { + children: _propTypes.default.string, + errorColor: _propTypes.default.string, + math: _propTypes.default.string, + renderError: _propTypes.default.func + }; + return MathComponent; + }; + const InternalPathComponentPropTypes = { + html: _propTypes.default.string.isRequired + }; + const InternalBlockMath = ({ html })=>{ + return /*#__PURE__*/ _react.default.createElement("div", { + "data-testid": "react-katex", + dangerouslySetInnerHTML: { + __html: html + } + }); + }; + InternalBlockMath.propTypes = InternalPathComponentPropTypes; + const InternalInlineMath = ({ html })=>{ + return /*#__PURE__*/ _react.default.createElement("span", { + "data-testid": "react-katex", + dangerouslySetInnerHTML: { + __html: html + } + }); + }; + InternalInlineMath.propTypes = InternalPathComponentPropTypes; + const BlockMath = createMathComponent(InternalBlockMath, { + displayMode: true + }); + const InlineMath = createMathComponent(InternalInlineMath, { + displayMode: false + }); +}); + +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC5qc3giXSwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IFJlYWN0LCB7IHVzZU1lbW8gfSBmcm9tICdyZWFjdCc7XG5pbXBvcnQgUHJvcFR5cGVzIGZyb20gJ3Byb3AtdHlwZXMnO1xuaW1wb3J0IEthVGVYIGZyb20gJ2thdGV4JztcblxuLyoqXG4gKiBAdHlwZWRlZiB7aW1wb3J0KFwicmVhY3RcIikuUmVhY3ROb2RlfSBSZWFjdE5vZGVcbiAqXG4gKlxuICogQGNhbGxiYWNrIEVycm9yUmVuZGVyZXJcbiAqIEBwYXJhbSB7RXJyb3J9IGVycm9yXG4gKiBAcmV0dXJucyB7UmVhY3ROb2RlfVxuICpcbiAqXG4gKiBAdHlwZWRlZiB7b2JqZWN0fSBNYXRoQ29tcG9uZW50UHJvcHNXaXRoTWF0aFxuICogQHByb3BlcnR5IHtzdHJpbmd9IG1hdGhcbiAqIEBwcm9wZXJ0eSB7UmVhY3ROb2RlPX0gY2hpbGRyZW5cbiAqIEBwcm9wZXJ0eSB7c3RyaW5nPX0gZXJyb3JDb2xvclxuICogQHByb3BlcnR5IHtFcnJvclJlbmRlcmVyPX0gcmVuZGVyRXJyb3JcbiAqXG4gKlxuICogQHR5cGVkZWYge29iamVjdH0gTWF0aENvbXBvbmVudFByb3BzV2l0aENoaWxkcmVuXG4gKiBAcHJvcGVydHkge3N0cmluZz19IG1hdGhcbiAqIEBwcm9wZXJ0eSB7UmVhY3ROb2RlfSBjaGlsZHJlblxuICogQHByb3BlcnR5IHtzdHJpbmc9fSBlcnJvckNvbG9yXG4gKiBAcHJvcGVydHkge0Vycm9yUmVuZGVyZXI9fSByZW5kZXJFcnJvclxuICpcbiAqIEB0eXBlZGVmIHtNYXRoQ29tcG9uZW50UHJvcHNXaXRoTWF0aCB8IE1hdGhDb21wb25lbnRQcm9wc1dpdGhDaGlsZHJlbn0gTWF0aENvbXBvbmVudFByb3BzXG4gKi9cblxuY29uc3QgY3JlYXRlTWF0aENvbXBvbmVudCA9IChDb21wb25lbnQsIHsgZGlzcGxheU1vZGUgfSkgPT4ge1xuICAvKipcbiAgICpcbiAgICogQHBhcmFtIHtNYXRoQ29tcG9uZW50UHJvcHN9IHByb3BzXG4gICAqIEByZXR1cm5zIHtSZWFjdE5vZGV9XG4gICAqL1xuICBjb25zdCBNYXRoQ29tcG9uZW50ID0gKHsgY2hpbGRyZW4sIGVycm9yQ29sb3IsIG1hdGgsIHJlbmRlckVycm9yIH0pID0+IHtcbiAgICBjb25zdCBmb3JtdWxhID0gbWF0aCA/PyBjaGlsZHJlbjtcblxuICAgIGNvbnN0IHsgaHRtbCwgZXJyb3IgfSA9IHVzZU1lbW8oKCkgPT4ge1xuICAgICAgdHJ5IHtcbiAgICAgICAgY29uc3QgaHRtbCA9IEthVGVYLnJlbmRlclRvU3RyaW5nKGZvcm11bGEsIHtcbiAgICAgICAgICBkaXNwbGF5TW9kZSxcbiAgICAgICAgICBlcnJvckNvbG9yLFxuICAgICAgICAgIHRocm93T25FcnJvcjogISFyZW5kZXJFcnJvcixcbiAgICAgICAgfSk7XG5cbiAgICAgICAgcmV0dXJuIHsgaHRtbCwgZXJyb3I6IHVuZGVmaW5lZCB9O1xuICAgICAgfSBjYXRjaCAoZXJyb3IpIHtcbiAgICAgICAgaWYgKGVycm9yIGluc3RhbmNlb2YgS2FUZVguUGFyc2VFcnJvciB8fCBlcnJvciBpbnN0YW5jZW9mIFR5cGVFcnJvcikge1xuICAgICAgICAgIHJldHVybiB7IGVycm9yIH07XG4gICAgICAgIH1cblxuICAgICAgICB0aHJvdyBlcnJvcjtcbiAgICAgIH1cbiAgICB9LCBbZm9ybXVsYSwgZXJyb3JDb2xvciwgcmVuZGVyRXJyb3JdKTtcblxuICAgIGlmIChlcnJvcikge1xuICAgICAgcmV0dXJuIHJlbmRlckVycm9yID8gcmVuZGVyRXJyb3IoZXJyb3IpIDogPENvbXBvbmVudCBodG1sPXtgJHtlcnJvci5tZXNzYWdlfWB9IC8+O1xuICAgIH1cblxuICAgIHJldHVybiA8Q29tcG9uZW50IGh0bWw9e2h0bWx9IC8+O1xuICB9O1xuXG4gIE1hdGhDb21wb25lbnQucHJvcFR5cGVzID0ge1xuICAgIGNoaWxkcmVuOiBQcm9wVHlwZXMuc3RyaW5nLFxuICAgIGVycm9yQ29sb3I6IFByb3BUeXBlcy5zdHJpbmcsXG4gICAgbWF0aDogUHJvcFR5cGVzLnN0cmluZyxcbiAgICByZW5kZXJFcnJvcjogUHJvcFR5cGVzLmZ1bmMsXG4gIH07XG5cbiAgcmV0dXJuIE1hdGhDb21wb25lbnQ7XG59O1xuXG5jb25zdCBJbnRlcm5hbFBhdGhDb21wb25lbnRQcm9wVHlwZXMgPSB7XG4gIGh0bWw6IFByb3BUeXBlcy5zdHJpbmcuaXNSZXF1aXJlZCxcbn07XG5cbmNvbnN0IEludGVybmFsQmxvY2tNYXRoID0gKHsgaHRtbCB9KSA9PiB7XG4gIHJldHVybiA8ZGl2IGRhdGEtdGVzdGlkPVwicmVhY3Qta2F0ZXhcIiBkYW5nZXJvdXNseVNldElubmVySFRNTD17eyBfX2h0bWw6IGh0bWwgfX0gLz47XG59O1xuXG5JbnRlcm5hbEJsb2NrTWF0aC5wcm9wVHlwZXMgPSBJbnRlcm5hbFBhdGhDb21wb25lbnRQcm9wVHlwZXM7XG5cbmNvbnN0IEludGVybmFsSW5saW5lTWF0aCA9ICh7IGh0bWwgfSkgPT4ge1xuICByZXR1cm4gPHNwYW4gZGF0YS10ZXN0aWQ9XCJyZWFjdC1rYXRleFwiIGRhbmdlcm91c2x5U2V0SW5uZXJIVE1MPXt7IF9faHRtbDogaHRtbCB9fSAvPjtcbn07XG5cbkludGVybmFsSW5saW5lTWF0aC5wcm9wVHlwZXMgPSBJbnRlcm5hbFBhdGhDb21wb25lbnRQcm9wVHlwZXM7XG5cbmV4cG9ydCBjb25zdCBCbG9ja01hdGggPSBjcmVhdGVNYXRoQ29tcG9uZW50KEludGVybmFsQmxvY2tNYXRoLCB7IGRpc3BsYXlNb2RlOiB0cnVlIH0pO1xuZXhwb3J0IGNvbnN0IElubGluZU1hdGggPSBjcmVhdGVNYXRoQ29tcG9uZW50KEludGVybmFsSW5saW5lTWF0aCwgeyBkaXNwbGF5TW9kZTogZmFsc2UgfSk7XG4iXSwibmFtZXMiOlsiQmxvY2tNYXRoIiwiSW5saW5lTWF0aCIsImNyZWF0ZU1hdGhDb21wb25lbnQiLCJDb21wb25lbnQiLCJkaXNwbGF5TW9kZSIsIk1hdGhDb21wb25lbnQiLCJjaGlsZHJlbiIsImVycm9yQ29sb3IiLCJtYXRoIiwicmVuZGVyRXJyb3IiLCJmb3JtdWxhIiwiaHRtbCIsImVycm9yIiwidXNlTWVtbyIsIkthVGVYIiwicmVuZGVyVG9TdHJpbmciLCJ0aHJvd09uRXJyb3IiLCJ1bmRlZmluZWQiLCJQYXJzZUVycm9yIiwiVHlwZUVycm9yIiwibWVzc2FnZSIsInByb3BUeXBlcyIsIlByb3BUeXBlcyIsInN0cmluZyIsImZ1bmMiLCJJbnRlcm5hbFBhdGhDb21wb25lbnRQcm9wVHlwZXMiLCJpc1JlcXVpcmVkIiwiSW50ZXJuYWxCbG9ja01hdGgiLCJkaXYiLCJkYXRhLXRlc3RpZCIsImRhbmdlcm91c2x5U2V0SW5uZXJIVE1MIiwiX19odG1sIiwiSW50ZXJuYWxJbmxpbmVNYXRoIiwic3BhbiJdLCJtYXBwaW5ncyI6IkFBQUE7bUdBQStCLE9BQU8sV0FDaEIsWUFBWSxXQUNoQixPQUFPOzs7UUFGTSxPQUFPO1FBQ2hCLFlBQVk7UUFDaEIsT0FBTzs7Ozs7Ozs7Ozs7Ozs7O1FBdUZaQSxTQUFTLE1BQVRBLFNBQVM7UUFDVEMsVUFBVSxNQUFWQSxVQUFVOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0lBdEZ2Qjs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Q0F1QkMsR0FFRCxNQUFNQyxtQkFBbUIsR0FBRyxDQUFDQyxTQUFTLEVBQUUsRUFBRUMsV0FBVyxDQUFBLEVBQUUsR0FBSztRQUMxRDs7OztHQUlDLEdBQ0QsTUFBTUMsYUFBYSxHQUFHLENBQUMsRUFBRUMsUUFBUSxDQUFBLEVBQUVDLFVBQVUsQ0FBQSxFQUFFQyxJQUFJLENBQUEsRUFBRUMsV0FBVyxDQUFBLEVBQUUsR0FBSztZQUNyRSxNQUFNQyxPQUFPLEdBQUdGLElBQUksYUFBSkEsSUFBSSxjQUFKQSxJQUFJLEdBQUlGLFFBQVEsQUFBQztZQUVqQyxNQUFNLEVBQUVLLElBQUksQ0FBQSxFQUFFQyxLQUFLLENBQUEsRUFBRSxHQUFHQyxJQUFBQSxNQUFPLFFBQUEsRUFBQyxJQUFNO2dCQUNwQyxJQUFJO29CQUNGLE1BQU1GLElBQUksR0FBR0csTUFBSyxRQUFBLENBQUNDLGNBQWMsQ0FBQ0wsT0FBTyxFQUFFO3dCQUN6Q04sV0FBVzt3QkFDWEcsVUFBVTt3QkFDVlMsWUFBWSxFQUFFLENBQUMsQ0FBQ1AsV0FBVztxQkFDNUIsQ0FBQyxBQUFDO29CQUVILE9BQU87d0JBQUVFLElBQUk7d0JBQUVDLEtBQUssRUFBRUssU0FBUztxQkFBRSxDQUFDO2lCQUNuQyxDQUFDLE9BQU9MLEtBQUssRUFBRTtvQkFDZCxJQUFJQSxLQUFLLFlBQVlFLE1BQUssUUFBQSxDQUFDSSxVQUFVLElBQUlOLEtBQUssWUFBWU8sU0FBUyxFQUFFO3dCQUNuRSxPQUFPOzRCQUFFUCxLQUFLO3lCQUFFLENBQUM7cUJBQ2xCO29CQUVELE1BQU1BLEtBQUssQ0FBQztpQkFDYjthQUNGLEVBQUU7Z0JBQUNGLE9BQU87Z0JBQUVILFVBQVU7Z0JBQUVFLFdBQVc7YUFBQyxDQUFDLEFBQUM7WUFFdkMsSUFBSUcsS0FBSyxFQUFFO2dCQUNULE9BQU9ILFdBQVcsR0FBR0EsV0FBVyxDQUFDRyxLQUFLLENBQUMsaUJBQUcsNkJBQUNULFNBQVM7b0JBQUNRLElBQUksRUFBRSxDQUFDLEVBQUVDLEtBQUssQ0FBQ1EsT0FBTyxDQUFDLENBQUM7a0JBQUksQ0FBQzthQUNuRjtZQUVELHFCQUFPLDZCQUFDakIsU0FBUztnQkFBQ1EsSUFBSSxFQUFFQSxJQUFJO2NBQUksQ0FBQztTQUNsQyxBQUFDO1FBRUZOLGFBQWEsQ0FBQ2dCLFNBQVMsR0FBRztZQUN4QmYsUUFBUSxFQUFFZ0IsVUFBUyxRQUFBLENBQUNDLE1BQU07WUFDMUJoQixVQUFVLEVBQUVlLFVBQVMsUUFBQSxDQUFDQyxNQUFNO1lBQzVCZixJQUFJLEVBQUVjLFVBQVMsUUFBQSxDQUFDQyxNQUFNO1lBQ3RCZCxXQUFXLEVBQUVhLFVBQVMsUUFBQSxDQUFDRSxJQUFJO1NBQzVCLENBQUM7UUFFRixPQUFPbkIsYUFBYSxDQUFDO0tBQ3RCLEFBQUM7SUFFRixNQUFNb0IsOEJBQThCLEdBQUc7UUFDckNkLElBQUksRUFBRVcsVUFBUyxRQUFBLENBQUNDLE1BQU0sQ0FBQ0csVUFBVTtLQUNsQyxBQUFDO0lBRUYsTUFBTUMsaUJBQWlCLEdBQUcsQ0FBQyxFQUFFaEIsSUFBSSxDQUFBLEVBQUUsR0FBSztRQUN0QyxxQkFBTyw2QkFBQ2lCLEtBQUc7WUFBQ0MsYUFBVyxFQUFDLGFBQWE7WUFBQ0MsdUJBQXVCLEVBQUU7Z0JBQUVDLE1BQU0sRUFBRXBCLElBQUk7YUFBRTtVQUFJLENBQUM7S0FDckYsQUFBQztJQUVGZ0IsaUJBQWlCLENBQUNOLFNBQVMsR0FBR0ksOEJBQThCLENBQUM7SUFFN0QsTUFBTU8sa0JBQWtCLEdBQUcsQ0FBQyxFQUFFckIsSUFBSSxDQUFBLEVBQUUsR0FBSztRQUN2QyxxQkFBTyw2QkFBQ3NCLE1BQUk7WUFBQ0osYUFBVyxFQUFDLGFBQWE7WUFBQ0MsdUJBQXVCLEVBQUU7Z0JBQUVDLE1BQU0sRUFBRXBCLElBQUk7YUFBRTtVQUFJLENBQUM7S0FDdEYsQUFBQztJQUVGcUIsa0JBQWtCLENBQUNYLFNBQVMsR0FBR0ksOEJBQThCLENBQUM7SUFFdkQsTUFBTXpCLFNBQVMsR0FBR0UsbUJBQW1CLENBQUN5QixpQkFBaUIsRUFBRTtRQUFFdkIsV0FBVyxFQUFFLElBQUk7S0FBRSxDQUFDLEFBQUM7SUFDaEYsTUFBTUgsVUFBVSxHQUFHQyxtQkFBbUIsQ0FBQzhCLGtCQUFrQixFQUFFO1FBQUU1QixXQUFXLEVBQUUsS0FBSztLQUFFLENBQUMsQUFBQyJ9 + +//# sourceMappingURL=react-katex.js.map \ No newline at end of file diff --git a/node_modules/react-katex/dist/react-katex.js.map b/node_modules/react-katex/dist/react-katex.js.map new file mode 100644 index 0000000..93aa36c --- /dev/null +++ b/node_modules/react-katex/dist/react-katex.js.map @@ -0,0 +1 @@ +{"version":3,"sources":[],"names":[],"mappings":"","file":"react-katex.js"} \ No newline at end of file diff --git a/node_modules/react-katex/docs/block.png b/node_modules/react-katex/docs/block.png new file mode 100644 index 0000000..0545910 Binary files /dev/null and b/node_modules/react-katex/docs/block.png differ diff --git a/node_modules/react-katex/docs/error.png b/node_modules/react-katex/docs/error.png new file mode 100644 index 0000000..27af628 Binary files /dev/null and b/node_modules/react-katex/docs/error.png differ diff --git a/node_modules/react-katex/docs/inline.png b/node_modules/react-katex/docs/inline.png new file mode 100644 index 0000000..795e547 Binary files /dev/null and b/node_modules/react-katex/docs/inline.png differ diff --git a/node_modules/react-katex/docs/rendererror.png b/node_modules/react-katex/docs/rendererror.png new file mode 100644 index 0000000..7b18c24 Binary files /dev/null and b/node_modules/react-katex/docs/rendererror.png differ diff --git a/node_modules/react-katex/jest.config.js b/node_modules/react-katex/jest.config.js new file mode 100644 index 0000000..3a35168 --- /dev/null +++ b/node_modules/react-katex/jest.config.js @@ -0,0 +1,196 @@ +/* + * For a detailed explanation regarding each configuration property, visit: + * https://jestjs.io/docs/configuration + */ + +module.exports = { + // All imported modules in your tests should be mocked automatically + // automock: false, + + // Stop running tests after `n` failures + // bail: 0, + + // The directory where Jest should store its cached dependency information + // cacheDirectory: "/tmp/jest_rs", + + // Automatically clear mock calls, instances and results before every test + // clearMocks: false, + + // Indicates whether the coverage information should be collected while executing the test + collectCoverage: true, + + // An array of glob patterns indicating a set of files for which coverage information should be collected + // collectCoverageFrom: undefined, + + // The directory where Jest should output its coverage files + coverageDirectory: 'coverage', + + // An array of regexp pattern strings used to skip coverage collection + // coveragePathIgnorePatterns: [ + // "/node_modules/" + // ], + + // Indicates which provider should be used to instrument code for coverage + // coverageProvider: "babel", + + // A list of reporter names that Jest uses when writing coverage reports + // coverageReporters: [ + // "json", + // "text", + // "lcov", + // "clover" + // ], + + // An object that configures minimum threshold enforcement for coverage results + // coverageThreshold: undefined, + + // A path to a custom dependency extractor + // dependencyExtractor: undefined, + + // Make calling deprecated APIs throw helpful error messages + // errorOnDeprecated: false, + + // Force coverage collection from ignored files using an array of glob patterns + // forceCoverageMatch: [], + + // A path to a module which exports an async function that is triggered once before all test suites + // globalSetup: undefined, + + // A path to a module which exports an async function that is triggered once after all test suites + // globalTeardown: undefined, + + // A set of global variables that need to be available in all test environments + // globals: {}, + + // The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers. + // maxWorkers: "50%", + + // An array of directory names to be searched recursively up from the requiring module's location + // moduleDirectories: [ + // "node_modules" + // ], + + // An array of file extensions your modules use + // moduleFileExtensions: [ + // "js", + // "jsx", + // "ts", + // "tsx", + // "json", + // "node" + // ], + + // A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module + // moduleNameMapper: {}, + + // An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader + // modulePathIgnorePatterns: [], + + // Activates notifications for test results + // notify: false, + + // An enum that specifies notification mode. Requires { notify: true } + // notifyMode: "failure-change", + + // A preset that is used as a base for Jest's configuration + // preset: undefined, + + // Run tests from one or more projects + // projects: undefined, + + // Use this configuration option to add custom reporters to Jest + // reporters: undefined, + + // Automatically reset mock state before every test + resetMocks: false, + + // Reset the module registry before running each individual test + // resetModules: false, + + // A path to a custom resolver + // resolver: undefined, + + // Automatically restore mock state and implementation before every test + // restoreMocks: false, + + // The root directory that Jest should scan for tests and modules within + // rootDir: undefined, + + // A list of paths to directories that Jest should use to search for files in + // roots: [ + // "" + // ], + + // Allows you to use a custom runner instead of Jest's default test runner + // runner: "jest-runner", + + // The paths to modules that run some code to configure or set up the testing environment before each test + // setupFiles: [], + + // A list of paths to modules that run some code to configure or set up the testing framework before each test + // setupFilesAfterEnv: [], + + // The number of seconds after which a test is considered as slow and reported as such in the results. + // slowTestThreshold: 5, + + // A list of paths to snapshot serializer modules Jest should use for snapshot testing + // snapshotSerializers: [], + + // The test environment that will be used for testing + testEnvironment: 'jsdom', + + // Options that will be passed to the testEnvironment + // testEnvironmentOptions: {}, + + // Adds a location field to test results + // testLocationInResults: false, + + // The glob patterns Jest uses to detect test files + // testMatch: [ + // "**/__tests__/**/*.[jt]s?(x)", + // "**/?(*.)+(spec|test).[tj]s?(x)" + // ], + + // An array of regexp pattern strings that are matched against all test paths, matched tests are skipped + // testPathIgnorePatterns: [ + // "/node_modules/" + // ], + + // The regexp pattern or array of patterns that Jest uses to detect test files + // testRegex: [], + + // This option allows the use of a custom results processor + // testResultsProcessor: undefined, + + // This option allows use of a custom test runner + // testRunner: "jest-circus/runner", + + // This option sets the URL for the jsdom environment. It is reflected in properties such as location.href + // testURL: "http://localhost", + + // Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout" + // timers: "real", + + // A map from regular expressions to paths to transformers + transform: { + '^.+\\.(t|j)sx?$': ['@swc/jest'], + }, + + // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation + // transformIgnorePatterns: [ + // "/node_modules/", + // "\\.pnp\\.[^\\/]+$" + // ], + + // An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them + // unmockedModulePathPatterns: undefined, + + // Indicates whether each individual test should be reported during the run + // verbose: undefined, + + // An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode + // watchPathIgnorePatterns: [], + + // Whether to use watchman for file crawling + // watchman: true, +}; diff --git a/node_modules/react-katex/node_modules/.bin/katex b/node_modules/react-katex/node_modules/.bin/katex new file mode 100644 index 0000000..081bce5 --- /dev/null +++ b/node_modules/react-katex/node_modules/.bin/katex @@ -0,0 +1,16 @@ +#!/bin/sh +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") + +case `uname` in + *CYGWIN*|*MINGW*|*MSYS*) + if command -v cygpath > /dev/null 2>&1; then + basedir=`cygpath -w "$basedir"` + fi + ;; +esac + +if [ -x "$basedir/node" ]; then + exec "$basedir/node" "$basedir/../katex/cli.js" "$@" +else + exec node "$basedir/../katex/cli.js" "$@" +fi diff --git a/node_modules/react-katex/node_modules/.bin/katex.cmd b/node_modules/react-katex/node_modules/.bin/katex.cmd new file mode 100644 index 0000000..86d85c5 --- /dev/null +++ b/node_modules/react-katex/node_modules/.bin/katex.cmd @@ -0,0 +1,17 @@ +@ECHO off +GOTO start +:find_dp0 +SET dp0=%~dp0 +EXIT /b +:start +SETLOCAL +CALL :find_dp0 + +IF EXIST "%dp0%\node.exe" ( + SET "_prog=%dp0%\node.exe" +) ELSE ( + SET "_prog=node" + SET PATHEXT=%PATHEXT:;.JS;=;% +) + +endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\katex\cli.js" %* diff --git a/node_modules/react-katex/node_modules/.bin/katex.ps1 b/node_modules/react-katex/node_modules/.bin/katex.ps1 new file mode 100644 index 0000000..cabbb02 --- /dev/null +++ b/node_modules/react-katex/node_modules/.bin/katex.ps1 @@ -0,0 +1,28 @@ +#!/usr/bin/env pwsh +$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent + +$exe="" +if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) { + # Fix case when both the Windows and Linux builds of Node + # are installed in the same directory + $exe=".exe" +} +$ret=0 +if (Test-Path "$basedir/node$exe") { + # Support pipeline input + if ($MyInvocation.ExpectingInput) { + $input | & "$basedir/node$exe" "$basedir/../katex/cli.js" $args + } else { + & "$basedir/node$exe" "$basedir/../katex/cli.js" $args + } + $ret=$LASTEXITCODE +} else { + # Support pipeline input + if ($MyInvocation.ExpectingInput) { + $input | & "node$exe" "$basedir/../katex/cli.js" $args + } else { + & "node$exe" "$basedir/../katex/cli.js" $args + } + $ret=$LASTEXITCODE +} +exit $ret diff --git a/node_modules/react-katex/node_modules/katex/LICENSE b/node_modules/react-katex/node_modules/katex/LICENSE new file mode 100644 index 0000000..37c6433 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2013-2020 Khan Academy and other contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/react-katex/node_modules/katex/README.md b/node_modules/react-katex/node_modules/katex/README.md new file mode 100644 index 0000000..8d07a37 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/README.md @@ -0,0 +1,125 @@ +

+ + + KaTeX + +

+ +[![npm](https://img.shields.io/npm/v/katex.svg)](https://www.npmjs.com/package/katex) +[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) +[![CI](https://github.com/KaTeX/KaTeX/workflows/CI/badge.svg?branch=main&event=push)](https://github.com/KaTeX/KaTeX/actions?query=workflow%3ACI) +[![codecov](https://codecov.io/gh/KaTeX/KaTeX/branch/main/graph/badge.svg)](https://codecov.io/gh/KaTeX/KaTeX) +[![Discussions](https://img.shields.io/badge/Discussions-join-brightgreen)](https://github.com/KaTeX/KaTeX/discussions) +[![jsDelivr](https://data.jsdelivr.com/v1/package/npm/katex/badge?style=rounded)](https://www.jsdelivr.com/package/npm/katex) +![katex.min.js size](https://img.badgesize.io/https://unpkg.com/katex/dist/katex.min.js?compression=gzip) +[![Gitpod ready-to-code](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/KaTeX/KaTeX) +[![Financial Contributors on Open Collective](https://opencollective.com/katex/all/badge.svg?label=financial+contributors)](https://opencollective.com/katex) + +KaTeX is a fast, easy-to-use JavaScript library for TeX math rendering on the web. + + * **Fast:** KaTeX renders its math synchronously and doesn't need to reflow the page. See how it compares to a competitor in [this speed test](https://www.intmath.com/cg5/katex-mathjax-comparison.php). + * **Print quality:** KaTeX's layout is based on Donald Knuth's TeX, the gold standard for math typesetting. + * **Self contained:** KaTeX has no dependencies and can easily be bundled with your website resources. + * **Server side rendering:** KaTeX produces the same output regardless of browser or environment, so you can pre-render expressions using Node.js and send them as plain HTML. + +KaTeX is compatible with all major browsers, including Chrome, Safari, Firefox, Opera, and Edge. + +KaTeX supports much (but not all) of LaTeX and many LaTeX packages. See the [list of supported functions](https://katex.org/docs/supported.html). + +Try out KaTeX [on the demo page](https://katex.org/#demo)! + +## Getting started + +### Starter template + +```html + + + + + + + + + + + + + ... + +``` + +You can also [download KaTeX](https://github.com/KaTeX/KaTeX/releases) and host it yourself. + +For details on how to configure auto-render extension, refer to [the documentation](https://katex.org/docs/autorender.html). + +### API + +Call `katex.render` to render a TeX expression directly into a DOM element. +For example: + +```js +katex.render("c = \\pm\\sqrt{a^2 + b^2}", element, { + throwOnError: false +}); +``` + +Call `katex.renderToString` to generate an HTML string of the rendered math, +e.g., for server-side rendering. For example: + +```js +var html = katex.renderToString("c = \\pm\\sqrt{a^2 + b^2}", { + throwOnError: false +}); +// '...' +``` + +Make sure to include the CSS and font files in both cases. +If you are doing all rendering on the server, there is no need to include the +JavaScript on the client. + +The examples above use the `throwOnError: false` option, which renders invalid +inputs as the TeX source code in red (by default), with the error message as +hover text. For other available options, see the +[API documentation](https://katex.org/docs/api.html), +[options documentation](https://katex.org/docs/options.html), and +[handling errors documentation](https://katex.org/docs/error.html). + +## Demo and Documentation + +Learn more about using KaTeX [on the website](https://katex.org)! + +## Contributors + +### Code Contributors + +This project exists thanks to all the people who contribute code. If you'd like to help, see [our guide to contributing code](CONTRIBUTING.md). +Code contributors + +### Financial Contributors + +Become a financial contributor and help us sustain our community. + +#### Individuals + +Contribute on Open Collective + +#### Organizations + +Support this project with your organization. Your logo will show up here with a link to your website. + +Organization 1 +Organization 2 +Organization 3 +Organization 4 +Organization 5 +Organization 6 +Organization 7 +Organization 8 +Organization 9 +Organization 10 + +## License + +KaTeX is licensed under the [MIT License](https://opensource.org/licenses/MIT). diff --git a/node_modules/react-katex/node_modules/katex/cli.js b/node_modules/react-katex/node_modules/katex/cli.js new file mode 100644 index 0000000..b9e7f95 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/cli.js @@ -0,0 +1,114 @@ +#!/usr/bin/env node +// Simple CLI for KaTeX. +// Reads TeX from stdin, outputs HTML to stdout. +// To run this from the repository, you must first build KaTeX by running +// `yarn` and `yarn build`. + +/* eslint no-console:0 */ + +let katex; +try { + katex = require("./"); +} catch (e) { + console.error( + "KaTeX could not import, likely because dist/katex.js is missing."); + console.error("Please run 'yarn' and 'yarn build' before running"); + console.error("cli.js from the KaTeX repository."); + console.error(); + throw e; +} +const {version} = require("./package.json"); +const fs = require("fs"); + +const {program} = require("commander"); +program.version(version); + +for (const prop in katex.SETTINGS_SCHEMA) { + if (katex.SETTINGS_SCHEMA.hasOwnProperty(prop)) { + const opt = katex.SETTINGS_SCHEMA[prop]; + if (opt.cli !== false) { + program.option(opt.cli || "--" + prop, opt.cliDescription || + opt.description, opt.cliProcessor, opt.cliDefault); + } + } +} +program.option("-f, --macro-file ", + "Read macro definitions, one per line, from the given file.") + .option("-i, --input ", "Read LaTeX input from the given file.") + .option("-o, --output ", "Write html output to the given file."); + +let options; + +function readMacros() { + if (options.macroFile) { + fs.readFile(options.macroFile, "utf-8", function(err, data) { + if (err) {throw err;} + splitMacros(data.toString().split('\n')); + }); + } else { + splitMacros([]); + } +} + +function splitMacros(macroStrings) { + // Override macros from macro file (if any) + // with macros from command line (if any) + macroStrings = macroStrings.concat(options.macro); + + const macros = {}; + + for (const m of macroStrings) { + const i = m.search(":"); + if (i !== -1) { + macros[m.substring(0, i).trim()] = m.substring(i + 1).trim(); + } + } + + options.macros = macros; + readInput(); +} + +function readInput() { + let input = ""; + + if (options.input) { + fs.readFile(options.input, "utf-8", function(err, data) { + if (err) {throw err;} + input = data.toString(); + writeOutput(input); + }); + } else { + process.stdin.on("data", function(chunk) { + input += chunk.toString(); + }); + + process.stdin.on("end", function() { + writeOutput(input); + }); + } +} + +function writeOutput(input) { + // --format specifies the KaTeX output + const outputFile = options.output; + options.output = options.format; + + const output = katex.renderToString(input, options) + "\n"; + + if (outputFile) { + fs.writeFile(outputFile, output, function(err) { + if (err) { + return console.log(err); + } + }); + } else { + console.log(output); + } +} + +if (require.main !== module) { + module.exports = program; +} else { + options = program.parse(process.argv).opts(); + readMacros(); +} diff --git a/node_modules/react-katex/node_modules/katex/contrib/auto-render/README.md b/node_modules/react-katex/node_modules/katex/contrib/auto-render/README.md new file mode 100644 index 0000000..ea793f1 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/contrib/auto-render/README.md @@ -0,0 +1,8 @@ +# Auto-render extension + +This is an extension to automatically render all of the math inside of text. It +searches all of the text nodes in a given element for the given delimiters, and +renders the math in place. + +See [Auto-render extension documentation](https://katex.org/docs/autorender.html) +for more information. diff --git a/node_modules/react-katex/node_modules/katex/contrib/auto-render/auto-render.ts b/node_modules/react-katex/node_modules/katex/contrib/auto-render/auto-render.ts new file mode 100644 index 0000000..d778201 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/contrib/auto-render/auto-render.ts @@ -0,0 +1,164 @@ +/* eslint no-console:0 */ + +import katex from "katex"; +import splitAtDelimiters from "./splitAtDelimiters"; +import type {DelimiterSpec} from "./splitAtDelimiters"; + +interface RenderMathInElementOptions { + delimiters?: DelimiterSpec[]; + preProcess?: (math: string) => string; + ignoredTags?: string[]; + ignoredClasses?: string[]; + errorCallback?: (msg: string, err: Error) => void; + displayMode?: boolean; + macros?: Record; +} + +interface RenderMathInElementOptionsCopy { + delimiters: DelimiterSpec[]; + preProcess?: (math: string) => string; + ignoredTags: Set; + ignoredClasses: string[]; + errorCallback: (msg: string, err: Error) => void; + displayMode?: boolean; + macros?: Record; +} + +/* Note: optionsCopy is mutated by this method. If it is ever exposed in the + * API, we should copy it before mutating. + */ +const renderMathInText = function( + text: string, + optionsCopy: RenderMathInElementOptionsCopy +) { + const data = splitAtDelimiters(text, optionsCopy.delimiters); + if (data.length === 1 && data[0].type === 'text') { + // There is no formula in the text. + // Let's return null which means there is no need to replace + // the current text node with a new one. + return null; + } + + const fragment = document.createDocumentFragment(); + + for (let i = 0; i < data.length; i++) { + if (data[i].type === "text") { + fragment.appendChild(document.createTextNode(data[i].data)); + } else { + const span = document.createElement("span"); + let math = data[i].data; + // Override any display mode defined in the settings with that + // defined by the text itself + optionsCopy.displayMode = data[i].display; + try { + if (optionsCopy.preProcess) { + math = optionsCopy.preProcess(math); + } + katex.render(math, span, optionsCopy); + } catch (e) { + if (!(e instanceof katex.ParseError)) { + throw e; + } + optionsCopy.errorCallback( + "KaTeX auto-render: Failed to parse `" + data[i].data + + "` with ", + e + ); + fragment.appendChild(document.createTextNode(data[i].rawData!)); + continue; + } + fragment.appendChild(span); + } + } + + return fragment; +}; + +const renderElem = function( + elem: HTMLElement, + optionsCopy: RenderMathInElementOptionsCopy +) { + for (let i = 0; i < elem.childNodes.length; i++) { + const childNode = elem.childNodes[i]; + if (childNode.nodeType === 3) { + // Text node + // Concatenate all sibling text nodes. + // Webkit browsers split very large text nodes into smaller ones, + // so the delimiters may be split across different nodes. + let textContentConcat = childNode.textContent ?? ""; + let sibling = childNode.nextSibling; + let nSiblings = 0; + while (sibling && (sibling.nodeType === Node.TEXT_NODE)) { + textContentConcat += sibling.textContent ?? ""; + sibling = sibling.nextSibling; + nSiblings++; + } + const frag = renderMathInText(textContentConcat, optionsCopy); + if (frag) { + // Remove extra text nodes + for (let j = 0; j < nSiblings; j++) { + childNode.nextSibling!.remove(); + } + i += frag.childNodes.length - 1; + elem.replaceChild(frag, childNode); + } else { + // If the concatenated text does not contain math + // the siblings will not either + i += nSiblings; + } + } else if (childNode.nodeType === 1) { + // Element node + const className = ' ' + (childNode as HTMLElement).className + ' '; + const shouldRender = !optionsCopy.ignoredTags.has( + childNode.nodeName.toLowerCase()) && + optionsCopy.ignoredClasses.every( + (x: string) => !className.includes(' ' + x + ' ')); + + if (shouldRender) { + renderElem(childNode as HTMLElement, optionsCopy); + } + } + // Otherwise, it's something else, and ignore it. + } +}; + +const renderMathInElement = function(elem: HTMLElement, options?: RenderMathInElementOptions) { + if (!elem) { + throw new Error("No element provided to render"); + } + + const optionsCopy: Partial = {}; + + Object.assign(optionsCopy, options); + + // default options + optionsCopy.delimiters = optionsCopy.delimiters || [ + {left: "$$", right: "$$", display: true}, + {left: "\\(", right: "\\)", display: false}, + // LaTeX uses $…$, but it ruins the display of normal `$` in text: + // {left: "$", right: "$", display: false}, + // $ must come after $$ + + // Render AMS environments even if outside $$…$$ delimiters. + {left: "\\begin{equation}", right: "\\end{equation}", display: true}, + {left: "\\begin{align}", right: "\\end{align}", display: true}, + {left: "\\begin{alignat}", right: "\\end{alignat}", display: true}, + {left: "\\begin{gather}", right: "\\end{gather}", display: true}, + {left: "\\begin{CD}", right: "\\end{CD}", display: true}, + + {left: "\\[", right: "\\]", display: true}, + ]; + optionsCopy.ignoredTags = new Set(options?.ignoredTags || [ + "script", "noscript", "style", "textarea", "pre", "code", "option", + ]); + optionsCopy.ignoredClasses = optionsCopy.ignoredClasses || []; + optionsCopy.errorCallback = optionsCopy.errorCallback || console.error; + + // Enable sharing of global macros defined via `\gdef` between different + // math elements within a single call to `renderMathInElement`. + optionsCopy.macros = optionsCopy.macros || {}; + + renderElem(elem, optionsCopy as RenderMathInElementOptionsCopy); +}; + +export default renderMathInElement; diff --git a/node_modules/react-katex/node_modules/katex/contrib/auto-render/index.html b/node_modules/react-katex/node_modules/katex/contrib/auto-render/index.html new file mode 100644 index 0000000..cf5c209 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/contrib/auto-render/index.html @@ -0,0 +1,57 @@ + + + + + + Auto-render test + + + + + +
+ This is some text $math \frac12$ other text $\unsupported$ + + Other node \[ \text{displaymath} \frac{1}{2} \] blah $$ \int_2^3 $$ + + and some more text \(and math\) blah. And $math with a + \$ sign$. +
+        Stuff in a $pre tag$
+      
+

An AMS environment without $$…$$ delimiters.

+

\begin{equation} \begin{split} a &=b+c\\ &=e+f \end{split} \end{equation}

+
+ + + diff --git a/node_modules/react-katex/node_modules/katex/contrib/auto-render/splitAtDelimiters.ts b/node_modules/react-katex/node_modules/katex/contrib/auto-render/splitAtDelimiters.ts new file mode 100644 index 0000000..57f469b --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/contrib/auto-render/splitAtDelimiters.ts @@ -0,0 +1,99 @@ +/* eslint no-constant-condition:0 */ + +export interface DelimiterSpec { + left: string; + right: string; + display: boolean; +} + +export interface SplitAtDelimiterData { + type: "text" | "math"; + data: string; + rawData?: string; + display?: boolean; +} + +const findEndOfMath = function(delimiter: string, text: string, startIndex: number): number { + // Adapted from + // https://github.com/Khan/perseus/blob/master/src/perseus-markdown.jsx + let index = startIndex; + let braceLevel = 0; + + const delimLength = delimiter.length; + + while (index < text.length) { + const character = text[index]; + + if (braceLevel <= 0 && + text.slice(index, index + delimLength) === delimiter) { + return index; + } else if (character === "\\") { + index++; + } else if (character === "{") { + braceLevel++; + } else if (character === "}") { + braceLevel--; + } + + index++; + } + + return -1; +}; + +const escapeRegex = function(string: string): string { + return string.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&"); +}; + +const amsRegex = /^\\begin{/; + +const splitAtDelimiters = function(text: string, delimiters: DelimiterSpec[]): SplitAtDelimiterData[] { + let index; + const data: SplitAtDelimiterData[] = []; + + const regexLeft = new RegExp( + "(" + delimiters.map((x) => escapeRegex(x.left)).join("|") + ")" + ); + + while (true) { + index = text.search(regexLeft); + if (index === -1) { + break; + } + if (index > 0) { + data.push({ + type: "text", + data: text.slice(0, index), + }); + text = text.slice(index); // now text starts with delimiter + } + // ... so this always succeeds: + const i = delimiters.findIndex((delim) => text.startsWith(delim.left)); + index = findEndOfMath(delimiters[i].right, text, delimiters[i].left.length); + if (index === -1) { + break; + } + const rawData = text.slice(0, index + delimiters[i].right.length); + const math = amsRegex.test(rawData) + ? rawData + : text.slice(delimiters[i].left.length, index); + data.push({ + type: "math", + data: math, + rawData, + display: delimiters[i].display, + }); + text = text.slice(index + delimiters[i].right.length); + } + + if (text !== "") { + data.push({ + type: "text", + data: text, + }); + } + + return data; +}; + +export default splitAtDelimiters; diff --git a/node_modules/react-katex/node_modules/katex/contrib/auto-render/test/auto-render-spec.ts b/node_modules/react-katex/node_modules/katex/contrib/auto-render/test/auto-render-spec.ts new file mode 100644 index 0000000..4d2b58b --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/contrib/auto-render/test/auto-render-spec.ts @@ -0,0 +1,371 @@ +/** + * @jest-environment jsdom + */ +import splitAtDelimiters from "../splitAtDelimiters"; +import renderMathInElement from "../auto-render"; +import type { + DelimiterSpec, + SplitAtDelimiterData, +} from "../splitAtDelimiters"; + +beforeEach(function() { + expect.extend({ + toSplitInto: function( + actual: string, + result: SplitAtDelimiterData[], + delimiters: DelimiterSpec[], + ) { + const message = { + pass: true, + message: () => "'" + actual + "' split correctly", + }; + + const split = + splitAtDelimiters(actual, delimiters); + + if (split.length !== result.length) { + message.pass = false; + message.message = () => "Different number of splits: " + + split.length + " vs. " + result.length + " (" + + JSON.stringify(split) + " vs. " + + JSON.stringify(result) + ")"; + return message; + } + + for (let i = 0; i < split.length; i++) { + const real = split[i]; + const correct = result[i]; + + let good = true; + let diff = ""; + + if (real.type !== correct.type) { + good = false; + diff = "type"; + } else if (real.data !== correct.data) { + good = false; + diff = "data"; + } else if (real.display !== correct.display) { + good = false; + diff = "display"; + } + + if (!good) { + message.pass = false; + message.message = () => "Difference at split " + + (i + 1) + ": " + JSON.stringify(real) + + " vs. " + JSON.stringify(correct) + + " (" + diff + " differs)"; + break; + } + } + + return message; + }, + }); +}); + +describe("A delimiter splitter", function() { + it("doesn't split when there are no delimiters", function() { + expect("hello").toSplitInto( + [ + {type: "text", data: "hello"}, + ], + [ + {left: "(", right: ")", display: false}, + ]); + }); + + it("doesn't create a math node with only one left delimiter", function() { + expect("hello ( world").toSplitInto( + [ + {type: "text", data: "hello "}, + {type: "text", data: "( world"}, + ], + [ + {left: "(", right: ")", display: false}, + ]); + }); + + it("doesn't split when there's only a right delimiter", function() { + expect("hello ) world").toSplitInto( + [ + {type: "text", data: "hello ) world"}, + ], + [ + {left: "(", right: ")", display: false}, + ]); + }); + + it("splits when there are both delimiters", function() { + expect("hello ( world ) boo").toSplitInto( + [ + {type: "text", data: "hello "}, + {type: "math", data: " world ", + rawData: "( world )", display: false}, + {type: "text", data: " boo"}, + ], + [ + {left: "(", right: ")", display: false}, + ]); + }); + + it("splits on multi-character delimiters", function() { + expect("hello [[ world ]] boo").toSplitInto( + [ + {type: "text", data: "hello "}, + {type: "math", data: " world ", + rawData: "[[ world ]]", display: false}, + {type: "text", data: " boo"}, + ], + [ + {left: "[[", right: "]]", display: false}, + ]); + expect("hello \\begin{equation} world \\end{equation} boo").toSplitInto( + [ + {type: "text", data: "hello "}, + {type: "math", data: "\\begin{equation} world \\end{equation}", + rawData: "\\begin{equation} world \\end{equation}", + display: false}, + {type: "text", data: " boo"}, + ], + [ + {left: "\\begin{equation}", right: "\\end{equation}", + display: false}, + ]); + }); + + it("splits multiple times", function() { + expect("hello ( world ) boo ( more ) stuff").toSplitInto( + [ + {type: "text", data: "hello "}, + {type: "math", data: " world ", + rawData: "( world )", display: false}, + {type: "text", data: " boo "}, + {type: "math", data: " more ", + rawData: "( more )", display: false}, + {type: "text", data: " stuff"}, + ], + [ + {left: "(", right: ")", display: false}, + ]); + }); + + it("leaves the ending when there's only a left delimiter", function() { + expect("hello ( world ) boo ( left").toSplitInto( + [ + {type: "text", data: "hello "}, + {type: "math", data: " world ", + rawData: "( world )", display: false}, + {type: "text", data: " boo "}, + {type: "text", data: "( left"}, + ], + [ + {left: "(", right: ")", display: false}, + ]); + }); + + it("doesn't split when close delimiters are in {}s", function() { + expect("hello ( world { ) } ) boo").toSplitInto( + [ + {type: "text", data: "hello "}, + {type: "math", data: " world { ) } ", + rawData: "( world { ) } )", display: false}, + {type: "text", data: " boo"}, + ], + [ + {left: "(", right: ")", display: false}, + ]); + + expect("hello ( world { { } ) } ) boo").toSplitInto( + [ + {type: "text", data: "hello "}, + {type: "math", data: " world { { } ) } ", + rawData: "( world { { } ) } )", display: false}, + {type: "text", data: " boo"}, + ], + [ + {left: "(", right: ")", display: false}, + ]); + }); + + it("correctly processes sequences of $..$", function() { + expect("$hello$$world$$boo$").toSplitInto( + [ + {type: "math", data: "hello", + rawData: "$hello$", display: false}, + {type: "math", data: "world", + rawData: "$world$", display: false}, + {type: "math", data: "boo", + rawData: "$boo$", display: false}, + ], + [ + {left: "$", right: "$", display: false}, + ]); + }); + + it("doesn't split at escaped delimiters", function() { + expect("hello ( world \\) ) boo").toSplitInto( + [ + {type: "text", data: "hello "}, + {type: "math", data: " world \\) ", + rawData: "( world \\) )", display: false}, + {type: "text", data: " boo"}, + ], + [ + {left: "(", right: ")", display: false}, + ]); + + /* TODO(emily): make this work maybe? + expect("hello \\( ( world ) boo").toSplitInto( + "(", ")", + [ + {type: "text", data: "hello \\( "}, + {type: "math", data: " world ", + rawData: "( world )", display: false}, + {type: "text", data: " boo"}, + ]); + */ + }); + + it("splits when the right and left delimiters are the same", function() { + expect("hello $ world $ boo").toSplitInto( + [ + {type: "text", data: "hello "}, + {type: "math", data: " world ", + rawData: "$ world $", display: false}, + {type: "text", data: " boo"}, + ], + [ + {left: "$", right: "$", display: false}, + ]); + }); + + it("ignores \\$", function() { + expect("$x = \\$5$").toSplitInto( + [ + {type: "math", data: "x = \\$5", + rawData: "$x = \\$5$", display: false}, + ], + [ + {left: "$", right: "$", display: false}, + ]); + }); + + it("remembers which delimiters are display-mode", function() { + const startData = "hello ( world ) boo"; + + expect(splitAtDelimiters(startData, + [{left:"(", right:")", display:true}])).toEqual( + [ + {type: "text", data: "hello "}, + {type: "math", data: " world ", + rawData: "( world )", display: true}, + {type: "text", data: " boo"}, + ]); + }); + + it("handles nested delimiters irrespective of order", function() { + expect(splitAtDelimiters("$\\fbox{\\(hi\\)}$", + [ + {left:"\\(", right:"\\)", display:false}, + {left:"$", right:"$", display:false}, + ])).toEqual( + [ + {type: "math", data: "\\fbox{\\(hi\\)}", + rawData: "$\\fbox{\\(hi\\)}$", display: false}, + ]); + expect(splitAtDelimiters("\\(\\fbox{$hi$}\\)", + [ + {left:"\\(", right:"\\)", display:false}, + {left:"$", right:"$", display:false}, + ])).toEqual( + [ + {type: "math", data: "\\fbox{$hi$}", + rawData: "\\(\\fbox{$hi$}\\)", display: false}, + ]); + }); + + it("handles a mix of $ and $$", function() { + expect(splitAtDelimiters("$hello$world$$boo$$", + [ + {left:"$$", right:"$$", display:true}, + {left:"$", right:"$", display:false}, + ])).toEqual( + [ + {type: "math", data: "hello", + rawData: "$hello$", display: false}, + {type: "text", data: "world"}, + {type: "math", data: "boo", + rawData: "$$boo$$", display: true}, + ]); + expect(splitAtDelimiters("$hello$$world$$$boo$$", + [ + {left:"$$", right:"$$", display:true}, + {left:"$", right:"$", display:false}, + ])).toEqual( + [ + {type: "math", data: "hello", + rawData: "$hello$", display: false}, + {type: "math", data: "world", + rawData: "$world$", display: false}, + {type: "math", data: "boo", + rawData: "$$boo$$", display: true}, + ]); + }); +}); + +describe("Pre-process callback", function() { + it("replace `-squared` with `^2 `", function() { + const el1 = document.createElement('div'); + el1.textContent = 'Circle equation: $x-squared + y-squared = r-squared$.'; + const el2 = document.createElement('div'); + el2.textContent = 'Circle equation: $x^2 + y^2 = r^2$.'; + const delimiters = [{left: "$", right: "$", display: false}]; + renderMathInElement(el1, { + delimiters, + preProcess: math => math.replace(/-squared/g, '^2'), + }); + renderMathInElement(el2, {delimiters}); + expect(el1.innerHTML).toEqual(el2.innerHTML); + }); +}); + +describe("Parse adjacent text nodes", function() { + it("parse adjacent text nodes with math", function() { + const textNodes = ['\\[', + 'x^2 + y^2 = r^2', + '\\]']; + const el = document.createElement('div'); + for (let i = 0; i < textNodes.length; i++) { + const txt = document.createTextNode(textNodes[i]); + el.appendChild(txt); + } + const el2 = document.createElement('div'); + const txt = document.createTextNode(textNodes.join('')); + el2.appendChild(txt); + const delimiters = [{left: "\\[", right: "\\]", display: true}]; + renderMathInElement(el, {delimiters}); + renderMathInElement(el2, {delimiters}); + expect(el).toStrictEqual(el2); + }); + + it("parse adjacent text nodes without math", function() { + const textNodes = ['Lorem ipsum dolor', + 'sit amet', + 'consectetur adipiscing elit']; + const el = document.createElement('div'); + for (let i = 0; i < textNodes.length; i++) { + const txt = document.createTextNode(textNodes[i]); + el.appendChild(txt); + } + const el2 = document.createElement('div'); + for (let i = 0; i < textNodes.length; i++) { + const txt = document.createTextNode(textNodes[i]); + el2.appendChild(txt); + } + const delimiters = [{left: "\\[", right: "\\]", display: true}]; + renderMathInElement(el, {delimiters}); + expect(el).toStrictEqual(el2); + }); +}); diff --git a/node_modules/react-katex/node_modules/katex/contrib/copy-tex/README.md b/node_modules/react-katex/node_modules/katex/contrib/copy-tex/README.md new file mode 100644 index 0000000..0b4bf1a --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/contrib/copy-tex/README.md @@ -0,0 +1,39 @@ +# Copy-tex extension + +This extension modifies the copy/paste behavior in any browser supporting the +[Clipboard API](https://developer.mozilla.org/en-US/docs/Web/API/ClipboardEvent) +so that, when selecting and copying KaTeX-rendered elements, the text +content of the resulting clipboard renders KaTeX elements as their LaTeX source +surrounded by specified delimiters. (The HTML content of the resulting +clipboard remains the selected HTML content, as it normally would.) +The default delimiters are `$...$` for inline math and `$$...$$` for display +math, but you can easy switch them to e.g. `\(...\)` and `\[...\]` by +modifying `copyDelimiters` in [the source code](copy-tex.js). +Note that a selection containing part of a KaTeX formula gets extended to +include the entire KaTeX formula. + +## Usage + +This extension isn't part of KaTeX proper, so the script should be separately +included in the page. + +```html + +``` + +(Note that, as of KaTeX 0.16.0, there is no longer a corresponding CSS file.) + +See [index.html](index.html) for an example. +(To run this example from a clone of the repository, run `yarn start` +in the root KaTeX directory, and then visit +http://localhost:7936/contrib/copy-tex/index.html +with your web browser.) + +If you want to build your own custom copy handler based on this one, +copy the `copy-tex.js` into your codebase and replace the `require` +statement with `require('katex/contrib/copy-tex/katex2tex.js')`. + +ECMAScript module is also available: +```html + +``` diff --git a/node_modules/react-katex/node_modules/katex/contrib/copy-tex/copy-tex.ts b/node_modules/react-katex/node_modules/katex/contrib/copy-tex/copy-tex.ts new file mode 100644 index 0000000..526a2c8 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/contrib/copy-tex/copy-tex.ts @@ -0,0 +1,49 @@ +import katexReplaceWithTex from "./katex2tex"; + +// Return
element containing node, or null if not found. +function closestKatex(node: Node): Element | null | undefined { + // If node is a Text Node, for example, go up to containing Element, + // where we can apply the `closest` method. + const element: Element | null | undefined = + (node instanceof Element ? node : node.parentElement); + return element && element.closest('.katex'); +} + +// Global copy handler to modify behavior on/within .katex elements. +document.addEventListener('copy', function(event: ClipboardEvent) { + const selection = window.getSelection(); + if (!selection || selection.isCollapsed || !event.clipboardData) { + return; // default action OK if selection is empty or unchangeable + } + const clipboardData = event.clipboardData; + const range = selection.getRangeAt(0); + + // When start point is within a formula, expand to entire formula. + const startKatex = closestKatex(range.startContainer); + if (startKatex) { + range.setStartBefore(startKatex); + } + + // Similarly, when end point is within a formula, expand to entire formula. + const endKatex = closestKatex(range.endContainer); + if (endKatex) { + range.setEndAfter(endKatex); + } + + const fragment = range.cloneContents(); + if (!fragment.querySelector('.katex-mathml')) { + return; // default action OK if no .katex-mathml elements + } + + const htmlContents = Array.prototype.map.call(fragment.childNodes, + (el) => (el instanceof Text ? el.textContent : el.outerHTML) + ).join(''); + + // Preserve usual HTML copy/paste behavior. + clipboardData.setData('text/html', htmlContents); + // Rewrite plain-text version. + clipboardData.setData('text/plain', + katexReplaceWithTex(fragment).textContent); + // Prevent normal copy handling. + event.preventDefault(); +}); diff --git a/node_modules/react-katex/node_modules/katex/contrib/copy-tex/index.html b/node_modules/react-katex/node_modules/katex/contrib/copy-tex/index.html new file mode 100644 index 0000000..fa59d27 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/contrib/copy-tex/index.html @@ -0,0 +1,38 @@ + + + + + + Copy-tex test + + + + + + +

Copy-tex test

+

Try copy/pasting some of the text below!

+

+ Here is some \(\KaTeX\) math: $$ x^2+y^2=z^2 $$ + The variables are \(x\), \(y\), and \(z\), + which are all in \(\mathbb{R}^+\). + Q.E.D. +

+ + + diff --git a/node_modules/react-katex/node_modules/katex/contrib/copy-tex/katex2tex.ts b/node_modules/react-katex/node_modules/katex/contrib/copy-tex/katex2tex.ts new file mode 100644 index 0000000..588bed2 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/contrib/copy-tex/katex2tex.ts @@ -0,0 +1,60 @@ + +export interface CopyDelimiters { + inline: [string, string]; + display: [string, string]; +} + +// Set these to how you want inline and display math to be delimited. +export const defaultCopyDelimiters: CopyDelimiters = { + inline: ['$', '$'], // alternative: ['\(', '\)'] + display: ['$$', '$$'], // alternative: ['\[', '\]'] +}; + +// Replace .katex elements with their TeX source ( element). +// Modifies fragment in-place. Useful for writing your own 'copy' handler, +// as in copy-tex.js. +export function katexReplaceWithTex( + fragment: DocumentFragment, + copyDelimiters: CopyDelimiters = defaultCopyDelimiters +): DocumentFragment { + // Remove .katex-html blocks that are preceded by .katex-mathml blocks + // (which will get replaced below). + const katexHtml = fragment.querySelectorAll('.katex-mathml + .katex-html'); + for (let i = 0; i < katexHtml.length; i++) { + const element = katexHtml[i]; + if (element.remove) { + element.remove(); + } else if (element.parentNode) { + element.parentNode.removeChild(element); + } + } + // Replace .katex-mathml elements with their annotation (TeX source) + // descendant, with inline delimiters. + const katexMathml = fragment.querySelectorAll('.katex-mathml'); + for (let i = 0; i < katexMathml.length; i++) { + const element = katexMathml[i]; + const texSource = element.querySelector('annotation'); + if (texSource) { + if (element.replaceWith) { + element.replaceWith(texSource); + } else if (element.parentNode) { + element.parentNode.replaceChild(texSource, element); + } + texSource.innerHTML = copyDelimiters.inline[0] + + texSource.innerHTML + copyDelimiters.inline[1]; + } + } + // Switch display math to display delimiters. + const displays = fragment.querySelectorAll('.katex-display annotation'); + for (let i = 0; i < displays.length; i++) { + const element = displays[i]; + element.innerHTML = copyDelimiters.display[0] + + element.innerHTML.substr(copyDelimiters.inline[0].length, + element.innerHTML.length - copyDelimiters.inline[0].length + - copyDelimiters.inline[1].length) + + copyDelimiters.display[1]; + } + return fragment; +} + +export default katexReplaceWithTex; diff --git a/node_modules/react-katex/node_modules/katex/contrib/mathtex-script-type/README.md b/node_modules/react-katex/node_modules/katex/contrib/mathtex-script-type/README.md new file mode 100644 index 0000000..aa38f5f --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/contrib/mathtex-script-type/README.md @@ -0,0 +1,38 @@ +# `math/tex` Custom Script Type Extension + +This is an extension to automatically display code inside `script` tags with `type=math/tex` using KaTeX. +This script type is commonly used by MathJax, so this can be used to support compatibility with MathJax. + +### Usage + +This extension isn't part of KaTeX proper, so the script should be separately +included in the page, in addition to KaTeX. + +Load the extension by adding the following line to your HTML file. + +```html + +``` +You can download the script and use it locally, or from a local KaTeX installation instead. + +For example, in the following simple page, we first load KaTeX as usual. +Then, in the body, we use a `math/tex` script to typeset the equation `x+\sqrt{1-x^2}`. + + +```html + + + + + + + + + + + +``` + +ECMAScript module is also available: +```html + diff --git a/node_modules/react-katex/node_modules/katex/contrib/mathtex-script-type/mathtex-script-type.js b/node_modules/react-katex/node_modules/katex/contrib/mathtex-script-type/mathtex-script-type.js new file mode 100644 index 0000000..732db69 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/contrib/mathtex-script-type/mathtex-script-type.js @@ -0,0 +1,23 @@ +import katex from "katex"; + +let scripts = document.body.getElementsByTagName("script"); +scripts = Array.prototype.slice.call(scripts); +scripts.forEach(function(script) { + if (!script.type || !script.type.match(/math\/tex/i)) { + return -1; + } + const display = + (script.type.match(/mode\s*=\s*display(;|\s|\n|$)/) != null); + + const katexElement = document.createElement(display ? "div" : "span"); + katexElement.setAttribute("class", + display ? "equation" : "inline-equation"); + try { + katex.render(script.text, katexElement, {displayMode: display}); + } catch (err) { + // eslint-disable-next-line no-console + console.error(err); + katexElement.textContent = script.text; + } + script.parentNode.replaceChild(katexElement, script); +}); diff --git a/node_modules/react-katex/node_modules/katex/contrib/mhchem/README.md b/node_modules/react-katex/node_modules/katex/contrib/mhchem/README.md new file mode 100644 index 0000000..fba80f0 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/contrib/mhchem/README.md @@ -0,0 +1,23 @@ +# mhchem extension + +This extension adds to KaTeX the `\ce` and `\pu` functions from the [mhchem](https://mhchem.github.io/MathJax-mhchem/) package. + +### Usage + +This extension isn't part of core KaTeX, so the script should be separately included. Write the following line into the HTML page's ``. Place it *after* the line that calls `katex.js`, and if you make use of the [auto-render](https://katex.org/docs/autorender.html) extension, place it *before* the line that calls `auto-render.js`. + +```html + +``` + +If you remove the `defer` attribute from this tag, then you must also remove the `defer` attribute from the ` + + + + + ... + +``` + +You can also [download KaTeX](https://github.com/KaTeX/KaTeX/releases) and host it yourself. + +For details on how to configure auto-render extension, refer to [the documentation](https://katex.org/docs/autorender.html). + +### API + +Call `katex.render` to render a TeX expression directly into a DOM element. +For example: + +```js +katex.render("c = \\pm\\sqrt{a^2 + b^2}", element, { + throwOnError: false +}); +``` + +Call `katex.renderToString` to generate an HTML string of the rendered math, +e.g., for server-side rendering. For example: + +```js +var html = katex.renderToString("c = \\pm\\sqrt{a^2 + b^2}", { + throwOnError: false +}); +// '...' +``` + +Make sure to include the CSS and font files in both cases. +If you are doing all rendering on the server, there is no need to include the +JavaScript on the client. + +The examples above use the `throwOnError: false` option, which renders invalid +inputs as the TeX source code in red (by default), with the error message as +hover text. For other available options, see the +[API documentation](https://katex.org/docs/api.html), +[options documentation](https://katex.org/docs/options.html), and +[handling errors documentation](https://katex.org/docs/error.html). + +## Demo and Documentation + +Learn more about using KaTeX [on the website](https://katex.org)! + +## Contributors + +### Code Contributors + +This project exists thanks to all the people who contribute code. If you'd like to help, see [our guide to contributing code](CONTRIBUTING.md). +Code contributors + +### Financial Contributors + +Become a financial contributor and help us sustain our community. + +#### Individuals + +Contribute on Open Collective + +#### Organizations + +Support this project with your organization. Your logo will show up here with a link to your website. + +Organization 1 +Organization 2 +Organization 3 +Organization 4 +Organization 5 +Organization 6 +Organization 7 +Organization 8 +Organization 9 +Organization 10 + +## License + +KaTeX is licensed under the [MIT License](https://opensource.org/licenses/MIT). diff --git a/node_modules/react-katex/node_modules/katex/dist/contrib/auto-render.js b/node_modules/react-katex/node_modules/katex/dist/contrib/auto-render.js new file mode 100644 index 0000000..36cf9f7 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/dist/contrib/auto-render.js @@ -0,0 +1,305 @@ +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(require("katex")); + else if(typeof define === 'function' && define.amd) + define(["katex"], factory); + else if(typeof exports === 'object') + exports["renderMathInElement"] = factory(require("katex")); + else + root["renderMathInElement"] = factory(root["katex"]); +})((typeof self !== 'undefined' ? self : this), function(__WEBPACK_EXTERNAL_MODULE__757__) { +return /******/ (function() { // webpackBootstrap +/******/ "use strict"; +/******/ var __webpack_modules__ = ({ + +/***/ 757: +/***/ (function(module) { + +module.exports = __WEBPACK_EXTERNAL_MODULE__757__; + +/***/ }) + +/******/ }); +/************************************************************************/ +/******/ // The module cache +/******/ var __webpack_module_cache__ = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ // Check if module is in cache +/******/ var cachedModule = __webpack_module_cache__[moduleId]; +/******/ if (cachedModule !== undefined) { +/******/ return cachedModule.exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = __webpack_module_cache__[moduleId] = { +/******/ // no module.id needed +/******/ // no module.loaded needed +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/************************************************************************/ +/******/ /* webpack/runtime/compat get default export */ +/******/ !function() { +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function() { return module['default']; } : +/******/ function() { return module; }; +/******/ __webpack_require__.d(getter, { a: getter }); +/******/ return getter; +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/define property getters */ +/******/ !function() { +/******/ // define getter functions for harmony exports +/******/ __webpack_require__.d = function(exports, definition) { +/******/ for(var key in definition) { +/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { +/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); +/******/ } +/******/ } +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/hasOwnProperty shorthand */ +/******/ !function() { +/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } +/******/ }(); +/******/ +/************************************************************************/ +var __webpack_exports__ = {}; + +// EXPORTS +__webpack_require__.d(__webpack_exports__, { + "default": function() { return /* binding */ auto_render; } +}); + +// EXTERNAL MODULE: external "katex" +var external_katex_ = __webpack_require__(757); +var external_katex_default = /*#__PURE__*/__webpack_require__.n(external_katex_); +;// ./contrib/auto-render/splitAtDelimiters.ts +/* eslint no-constant-condition:0 */ + +const findEndOfMath = function (delimiter, text, startIndex) { + // Adapted from + // https://github.com/Khan/perseus/blob/master/src/perseus-markdown.jsx + let index = startIndex; + let braceLevel = 0; + const delimLength = delimiter.length; + while (index < text.length) { + const character = text[index]; + if (braceLevel <= 0 && text.slice(index, index + delimLength) === delimiter) { + return index; + } else if (character === "\\") { + index++; + } else if (character === "{") { + braceLevel++; + } else if (character === "}") { + braceLevel--; + } + index++; + } + return -1; +}; +const escapeRegex = function (string) { + return string.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&"); +}; +const amsRegex = /^\\begin{/; +const splitAtDelimiters = function (text, delimiters) { + let index; + const data = []; + const regexLeft = new RegExp("(" + delimiters.map(x => escapeRegex(x.left)).join("|") + ")"); + while (true) { + index = text.search(regexLeft); + if (index === -1) { + break; + } + if (index > 0) { + data.push({ + type: "text", + data: text.slice(0, index) + }); + text = text.slice(index); // now text starts with delimiter + } + // ... so this always succeeds: + const i = delimiters.findIndex(delim => text.startsWith(delim.left)); + index = findEndOfMath(delimiters[i].right, text, delimiters[i].left.length); + if (index === -1) { + break; + } + const rawData = text.slice(0, index + delimiters[i].right.length); + const math = amsRegex.test(rawData) ? rawData : text.slice(delimiters[i].left.length, index); + data.push({ + type: "math", + data: math, + rawData, + display: delimiters[i].display + }); + text = text.slice(index + delimiters[i].right.length); + } + if (text !== "") { + data.push({ + type: "text", + data: text + }); + } + return data; +}; +/* harmony default export */ var auto_render_splitAtDelimiters = (splitAtDelimiters); +;// ./contrib/auto-render/auto-render.ts +/* eslint no-console:0 */ + + + +/* Note: optionsCopy is mutated by this method. If it is ever exposed in the + * API, we should copy it before mutating. + */ +const renderMathInText = function (text, optionsCopy) { + const data = auto_render_splitAtDelimiters(text, optionsCopy.delimiters); + if (data.length === 1 && data[0].type === 'text') { + // There is no formula in the text. + // Let's return null which means there is no need to replace + // the current text node with a new one. + return null; + } + const fragment = document.createDocumentFragment(); + for (let i = 0; i < data.length; i++) { + if (data[i].type === "text") { + fragment.appendChild(document.createTextNode(data[i].data)); + } else { + const span = document.createElement("span"); + let math = data[i].data; + // Override any display mode defined in the settings with that + // defined by the text itself + optionsCopy.displayMode = data[i].display; + try { + if (optionsCopy.preProcess) { + math = optionsCopy.preProcess(math); + } + external_katex_default().render(math, span, optionsCopy); + } catch (e) { + if (!(e instanceof (external_katex_default()).ParseError)) { + throw e; + } + optionsCopy.errorCallback("KaTeX auto-render: Failed to parse `" + data[i].data + "` with ", e); + fragment.appendChild(document.createTextNode(data[i].rawData)); + continue; + } + fragment.appendChild(span); + } + } + return fragment; +}; +const renderElem = function (elem, optionsCopy) { + for (let i = 0; i < elem.childNodes.length; i++) { + const childNode = elem.childNodes[i]; + if (childNode.nodeType === 3) { + var _childNode$textConten; + // Text node + // Concatenate all sibling text nodes. + // Webkit browsers split very large text nodes into smaller ones, + // so the delimiters may be split across different nodes. + let textContentConcat = (_childNode$textConten = childNode.textContent) != null ? _childNode$textConten : ""; + let sibling = childNode.nextSibling; + let nSiblings = 0; + while (sibling && sibling.nodeType === Node.TEXT_NODE) { + var _sibling$textContent; + textContentConcat += (_sibling$textContent = sibling.textContent) != null ? _sibling$textContent : ""; + sibling = sibling.nextSibling; + nSiblings++; + } + const frag = renderMathInText(textContentConcat, optionsCopy); + if (frag) { + // Remove extra text nodes + for (let j = 0; j < nSiblings; j++) { + childNode.nextSibling.remove(); + } + i += frag.childNodes.length - 1; + elem.replaceChild(frag, childNode); + } else { + // If the concatenated text does not contain math + // the siblings will not either + i += nSiblings; + } + } else if (childNode.nodeType === 1) { + // Element node + const className = ' ' + childNode.className + ' '; + const shouldRender = !optionsCopy.ignoredTags.has(childNode.nodeName.toLowerCase()) && optionsCopy.ignoredClasses.every(x => !className.includes(' ' + x + ' ')); + if (shouldRender) { + renderElem(childNode, optionsCopy); + } + } + // Otherwise, it's something else, and ignore it. + } +}; +const renderMathInElement = function (elem, options) { + if (!elem) { + throw new Error("No element provided to render"); + } + const optionsCopy = {}; + Object.assign(optionsCopy, options); + + // default options + optionsCopy.delimiters = optionsCopy.delimiters || [{ + left: "$$", + right: "$$", + display: true + }, { + left: "\\(", + right: "\\)", + display: false + }, + // LaTeX uses $…$, but it ruins the display of normal `$` in text: + // {left: "$", right: "$", display: false}, + // $ must come after $$ + + // Render AMS environments even if outside $$…$$ delimiters. + { + left: "\\begin{equation}", + right: "\\end{equation}", + display: true + }, { + left: "\\begin{align}", + right: "\\end{align}", + display: true + }, { + left: "\\begin{alignat}", + right: "\\end{alignat}", + display: true + }, { + left: "\\begin{gather}", + right: "\\end{gather}", + display: true + }, { + left: "\\begin{CD}", + right: "\\end{CD}", + display: true + }, { + left: "\\[", + right: "\\]", + display: true + }]; + optionsCopy.ignoredTags = new Set((options == null ? void 0 : options.ignoredTags) || ["script", "noscript", "style", "textarea", "pre", "code", "option"]); + optionsCopy.ignoredClasses = optionsCopy.ignoredClasses || []; + optionsCopy.errorCallback = optionsCopy.errorCallback || console.error; + + // Enable sharing of global macros defined via `\gdef` between different + // math elements within a single call to `renderMathInElement`. + optionsCopy.macros = optionsCopy.macros || {}; + renderElem(elem, optionsCopy); +}; +/* harmony default export */ var auto_render = (renderMathInElement); +__webpack_exports__ = __webpack_exports__["default"]; +/******/ return __webpack_exports__; +/******/ })() +; +}); \ No newline at end of file diff --git a/node_modules/react-katex/node_modules/katex/dist/contrib/auto-render.min.js b/node_modules/react-katex/node_modules/katex/dist/contrib/auto-render.min.js new file mode 100644 index 0000000..0a1f35d --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/dist/contrib/auto-render.min.js @@ -0,0 +1 @@ +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("katex")):"function"==typeof define&&define.amd?define(["katex"],t):"object"==typeof exports?exports.renderMathInElement=t(require("katex")):e.renderMathInElement=t(e.katex)}("undefined"!=typeof self?self:this,function(e){return function(){"use strict";var t={757:function(t){t.exports=e}},n={};function r(e){var o=n[e];if(void 0!==o)return o.exports;var i=n[e]={exports:{}};return t[e](i,i.exports,r),i.exports}r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,{a:t}),t},r.d=function(e,t){for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};var o={};r.d(o,{default:function(){return p}});var i=r(757),a=r.n(i);const l=function(e,t,n){let r=n,o=0;const i=e.length;for(;re.left.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")).join("|")+")");for(;n=e.search(o),-1!==n;){n>0&&(r.push({type:"text",data:e.slice(0,n)}),e=e.slice(n));const o=t.findIndex(t=>e.startsWith(t.left));if(n=l(t[o].right,e,t[o].left.length),-1===n)break;const i=e.slice(0,n+t[o].right.length),a=s.test(i)?i:e.slice(t[o].left.length,n);r.push({type:"math",data:a,rawData:i,display:t[o].display}),e=e.slice(n+t[o].right.length)}return""!==e&&r.push({type:"text",data:e}),r};const c=function(e,t){const n=d(e,t.delimiters);if(1===n.length&&"text"===n[0].type)return null;const r=document.createDocumentFragment();for(let e=0;e!e.includes(" "+t+" "))&&f(i,t)}}};var p=function(e,t){if(!e)throw new Error("No element provided to render");const n={};Object.assign(n,t),n.delimiters=n.delimiters||[{left:"$$",right:"$$",display:!0},{left:"\\(",right:"\\)",display:!1},{left:"\\begin{equation}",right:"\\end{equation}",display:!0},{left:"\\begin{align}",right:"\\end{align}",display:!0},{left:"\\begin{alignat}",right:"\\end{alignat}",display:!0},{left:"\\begin{gather}",right:"\\end{gather}",display:!0},{left:"\\begin{CD}",right:"\\end{CD}",display:!0},{left:"\\[",right:"\\]",display:!0}],n.ignoredTags=new Set((null==t?void 0:t.ignoredTags)||["script","noscript","style","textarea","pre","code","option"]),n.ignoredClasses=n.ignoredClasses||[],n.errorCallback=n.errorCallback||console.error,n.macros=n.macros||{},f(e,n)};return o=o.default}()}); \ No newline at end of file diff --git a/node_modules/react-katex/node_modules/katex/dist/contrib/auto-render.mjs b/node_modules/react-katex/node_modules/katex/dist/contrib/auto-render.mjs new file mode 100644 index 0000000..7bd38c6 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/dist/contrib/auto-render.mjs @@ -0,0 +1,210 @@ +import katex from '../katex.mjs'; + +/* eslint no-constant-condition:0 */ +var findEndOfMath = function findEndOfMath(delimiter, text, startIndex) { + // Adapted from + // https://github.com/Khan/perseus/blob/master/src/perseus-markdown.jsx + var index = startIndex; + var braceLevel = 0; + var delimLength = delimiter.length; + while (index < text.length) { + var character = text[index]; + if (braceLevel <= 0 && text.slice(index, index + delimLength) === delimiter) { + return index; + } else if (character === "\\") { + index++; + } else if (character === "{") { + braceLevel++; + } else if (character === "}") { + braceLevel--; + } + index++; + } + return -1; +}; +var escapeRegex = function escapeRegex(string) { + return string.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&"); +}; +var amsRegex = /^\\begin{/; +var splitAtDelimiters = function splitAtDelimiters(text, delimiters) { + var index; + var data = []; + var regexLeft = new RegExp("(" + delimiters.map(x => escapeRegex(x.left)).join("|") + ")"); + while (true) { + index = text.search(regexLeft); + if (index === -1) { + break; + } + if (index > 0) { + data.push({ + type: "text", + data: text.slice(0, index) + }); + text = text.slice(index); // now text starts with delimiter + } + // ... so this always succeeds: + var i = delimiters.findIndex(delim => text.startsWith(delim.left)); + index = findEndOfMath(delimiters[i].right, text, delimiters[i].left.length); + if (index === -1) { + break; + } + var rawData = text.slice(0, index + delimiters[i].right.length); + var math = amsRegex.test(rawData) ? rawData : text.slice(delimiters[i].left.length, index); + data.push({ + type: "math", + data: math, + rawData, + display: delimiters[i].display + }); + text = text.slice(index + delimiters[i].right.length); + } + if (text !== "") { + data.push({ + type: "text", + data: text + }); + } + return data; +}; + +/* eslint no-console:0 */ +/* Note: optionsCopy is mutated by this method. If it is ever exposed in the + * API, we should copy it before mutating. + */ +var renderMathInText = function renderMathInText(text, optionsCopy) { + var data = splitAtDelimiters(text, optionsCopy.delimiters); + if (data.length === 1 && data[0].type === 'text') { + // There is no formula in the text. + // Let's return null which means there is no need to replace + // the current text node with a new one. + return null; + } + var fragment = document.createDocumentFragment(); + for (var i = 0; i < data.length; i++) { + if (data[i].type === "text") { + fragment.appendChild(document.createTextNode(data[i].data)); + } else { + var span = document.createElement("span"); + var math = data[i].data; + // Override any display mode defined in the settings with that + // defined by the text itself + optionsCopy.displayMode = data[i].display; + try { + if (optionsCopy.preProcess) { + math = optionsCopy.preProcess(math); + } + katex.render(math, span, optionsCopy); + } catch (e) { + if (!(e instanceof katex.ParseError)) { + throw e; + } + optionsCopy.errorCallback("KaTeX auto-render: Failed to parse `" + data[i].data + "` with ", e); + fragment.appendChild(document.createTextNode(data[i].rawData)); + continue; + } + fragment.appendChild(span); + } + } + return fragment; +}; +var _renderElem = function renderElem(elem, optionsCopy) { + var _loop = function _loop(_i) { + var childNode = elem.childNodes[_i]; + if (childNode.nodeType === 3) { + var _childNode$textConten; + // Text node + // Concatenate all sibling text nodes. + // Webkit browsers split very large text nodes into smaller ones, + // so the delimiters may be split across different nodes. + var textContentConcat = (_childNode$textConten = childNode.textContent) != null ? _childNode$textConten : ""; + var sibling = childNode.nextSibling; + var nSiblings = 0; + while (sibling && sibling.nodeType === Node.TEXT_NODE) { + var _sibling$textContent; + textContentConcat += (_sibling$textContent = sibling.textContent) != null ? _sibling$textContent : ""; + sibling = sibling.nextSibling; + nSiblings++; + } + var frag = renderMathInText(textContentConcat, optionsCopy); + if (frag) { + // Remove extra text nodes + for (var j = 0; j < nSiblings; j++) { + childNode.nextSibling.remove(); + } + _i += frag.childNodes.length - 1; + elem.replaceChild(frag, childNode); + } else { + // If the concatenated text does not contain math + // the siblings will not either + _i += nSiblings; + } + } else if (childNode.nodeType === 1) { + // Element node + var className = ' ' + childNode.className + ' '; + var shouldRender = !optionsCopy.ignoredTags.has(childNode.nodeName.toLowerCase()) && optionsCopy.ignoredClasses.every(x => !className.includes(' ' + x + ' ')); + if (shouldRender) { + _renderElem(childNode, optionsCopy); + } + } + // Otherwise, it's something else, and ignore it. + i = _i; + }; + for (var i = 0; i < elem.childNodes.length; i++) { + _loop(i); + } +}; +var renderMathInElement = function renderMathInElement(elem, options) { + if (!elem) { + throw new Error("No element provided to render"); + } + var optionsCopy = {}; + Object.assign(optionsCopy, options); + // default options + optionsCopy.delimiters = optionsCopy.delimiters || [{ + left: "$$", + right: "$$", + display: true + }, { + left: "\\(", + right: "\\)", + display: false + }, + // LaTeX uses $…$, but it ruins the display of normal `$` in text: + // {left: "$", right: "$", display: false}, + // $ must come after $$ + // Render AMS environments even if outside $$…$$ delimiters. + { + left: "\\begin{equation}", + right: "\\end{equation}", + display: true + }, { + left: "\\begin{align}", + right: "\\end{align}", + display: true + }, { + left: "\\begin{alignat}", + right: "\\end{alignat}", + display: true + }, { + left: "\\begin{gather}", + right: "\\end{gather}", + display: true + }, { + left: "\\begin{CD}", + right: "\\end{CD}", + display: true + }, { + left: "\\[", + right: "\\]", + display: true + }]; + optionsCopy.ignoredTags = new Set((options == null ? void 0 : options.ignoredTags) || ["script", "noscript", "style", "textarea", "pre", "code", "option"]); + optionsCopy.ignoredClasses = optionsCopy.ignoredClasses || []; + optionsCopy.errorCallback = optionsCopy.errorCallback || console.error; + // Enable sharing of global macros defined via `\gdef` between different + // math elements within a single call to `renderMathInElement`. + optionsCopy.macros = optionsCopy.macros || {}; + _renderElem(elem, optionsCopy); +}; + +export { renderMathInElement as default }; diff --git a/node_modules/react-katex/node_modules/katex/dist/contrib/copy-tex.js b/node_modules/react-katex/node_modules/katex/dist/contrib/copy-tex.js new file mode 100644 index 0000000..cb9a871 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/dist/contrib/copy-tex.js @@ -0,0 +1,113 @@ +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(); + else if(typeof define === 'function' && define.amd) + define([], factory); + else { + var a = factory(); + for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i]; + } +})((typeof self !== 'undefined' ? self : this), function() { +return /******/ (function() { // webpackBootstrap +/******/ "use strict"; +var __webpack_exports__ = {}; + +;// ./contrib/copy-tex/katex2tex.ts +// Set these to how you want inline and display math to be delimited. +const defaultCopyDelimiters = { + inline: ['$', '$'], + // alternative: ['\(', '\)'] + display: ['$$', '$$'] // alternative: ['\[', '\]'] +}; + +// Replace .katex elements with their TeX source ( element). +// Modifies fragment in-place. Useful for writing your own 'copy' handler, +// as in copy-tex.js. +function katexReplaceWithTex(fragment, copyDelimiters) { + if (copyDelimiters === void 0) { + copyDelimiters = defaultCopyDelimiters; + } + // Remove .katex-html blocks that are preceded by .katex-mathml blocks + // (which will get replaced below). + const katexHtml = fragment.querySelectorAll('.katex-mathml + .katex-html'); + for (let i = 0; i < katexHtml.length; i++) { + const element = katexHtml[i]; + if (element.remove) { + element.remove(); + } else if (element.parentNode) { + element.parentNode.removeChild(element); + } + } + // Replace .katex-mathml elements with their annotation (TeX source) + // descendant, with inline delimiters. + const katexMathml = fragment.querySelectorAll('.katex-mathml'); + for (let i = 0; i < katexMathml.length; i++) { + const element = katexMathml[i]; + const texSource = element.querySelector('annotation'); + if (texSource) { + if (element.replaceWith) { + element.replaceWith(texSource); + } else if (element.parentNode) { + element.parentNode.replaceChild(texSource, element); + } + texSource.innerHTML = copyDelimiters.inline[0] + texSource.innerHTML + copyDelimiters.inline[1]; + } + } + // Switch display math to display delimiters. + const displays = fragment.querySelectorAll('.katex-display annotation'); + for (let i = 0; i < displays.length; i++) { + const element = displays[i]; + element.innerHTML = copyDelimiters.display[0] + element.innerHTML.substr(copyDelimiters.inline[0].length, element.innerHTML.length - copyDelimiters.inline[0].length - copyDelimiters.inline[1].length) + copyDelimiters.display[1]; + } + return fragment; +} +/* harmony default export */ var katex2tex = (katexReplaceWithTex); +;// ./contrib/copy-tex/copy-tex.ts + + +// Return
element containing node, or null if not found. +function closestKatex(node) { + // If node is a Text Node, for example, go up to containing Element, + // where we can apply the `closest` method. + const element = node instanceof Element ? node : node.parentElement; + return element && element.closest('.katex'); +} + +// Global copy handler to modify behavior on/within .katex elements. +document.addEventListener('copy', function (event) { + const selection = window.getSelection(); + if (!selection || selection.isCollapsed || !event.clipboardData) { + return; // default action OK if selection is empty or unchangeable + } + const clipboardData = event.clipboardData; + const range = selection.getRangeAt(0); + + // When start point is within a formula, expand to entire formula. + const startKatex = closestKatex(range.startContainer); + if (startKatex) { + range.setStartBefore(startKatex); + } + + // Similarly, when end point is within a formula, expand to entire formula. + const endKatex = closestKatex(range.endContainer); + if (endKatex) { + range.setEndAfter(endKatex); + } + const fragment = range.cloneContents(); + if (!fragment.querySelector('.katex-mathml')) { + return; // default action OK if no .katex-mathml elements + } + const htmlContents = Array.prototype.map.call(fragment.childNodes, el => el instanceof Text ? el.textContent : el.outerHTML).join(''); + + // Preserve usual HTML copy/paste behavior. + clipboardData.setData('text/html', htmlContents); + // Rewrite plain-text version. + clipboardData.setData('text/plain', katex2tex(fragment).textContent); + // Prevent normal copy handling. + event.preventDefault(); +}); +__webpack_exports__ = __webpack_exports__["default"]; +/******/ return __webpack_exports__; +/******/ })() +; +}); \ No newline at end of file diff --git a/node_modules/react-katex/node_modules/katex/dist/contrib/copy-tex.min.js b/node_modules/react-katex/node_modules/katex/dist/contrib/copy-tex.min.js new file mode 100644 index 0000000..88f9c30 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/dist/contrib/copy-tex.min.js @@ -0,0 +1 @@ +!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var o in n)("object"==typeof exports?exports:e)[o]=n[o]}}("undefined"!=typeof self?self:this,function(){return function(){"use strict";var e={};const t={inline:["$","$"],display:["$$","$$"]};var n=function(e,n){void 0===n&&(n=t);const o=e.querySelectorAll(".katex-mathml + .katex-html");for(let e=0;ee instanceof Text?e.textContent:e.outerHTML).join("");r.setData("text/html",c),r.setData("text/plain",n(s).textContent),e.preventDefault()}),e=e.default}()}); \ No newline at end of file diff --git a/node_modules/react-katex/node_modules/katex/dist/contrib/copy-tex.mjs b/node_modules/react-katex/node_modules/katex/dist/contrib/copy-tex.mjs new file mode 100644 index 0000000..ce9977e --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/dist/contrib/copy-tex.mjs @@ -0,0 +1,85 @@ +// Set these to how you want inline and display math to be delimited. +var defaultCopyDelimiters = { + inline: ['$', '$'], + // alternative: ['\(', '\)'] + display: ['$$', '$$'] // alternative: ['\[', '\]'] +}; +// Replace .katex elements with their TeX source ( element). +// Modifies fragment in-place. Useful for writing your own 'copy' handler, +// as in copy-tex.js. +function katexReplaceWithTex(fragment, copyDelimiters) { + if (copyDelimiters === void 0) { + copyDelimiters = defaultCopyDelimiters; + } + // Remove .katex-html blocks that are preceded by .katex-mathml blocks + // (which will get replaced below). + var katexHtml = fragment.querySelectorAll('.katex-mathml + .katex-html'); + for (var i = 0; i < katexHtml.length; i++) { + var element = katexHtml[i]; + if (element.remove) { + element.remove(); + } else if (element.parentNode) { + element.parentNode.removeChild(element); + } + } + // Replace .katex-mathml elements with their annotation (TeX source) + // descendant, with inline delimiters. + var katexMathml = fragment.querySelectorAll('.katex-mathml'); + for (var _i = 0; _i < katexMathml.length; _i++) { + var _element = katexMathml[_i]; + var texSource = _element.querySelector('annotation'); + if (texSource) { + if (_element.replaceWith) { + _element.replaceWith(texSource); + } else if (_element.parentNode) { + _element.parentNode.replaceChild(texSource, _element); + } + texSource.innerHTML = copyDelimiters.inline[0] + texSource.innerHTML + copyDelimiters.inline[1]; + } + } + // Switch display math to display delimiters. + var displays = fragment.querySelectorAll('.katex-display annotation'); + for (var _i2 = 0; _i2 < displays.length; _i2++) { + var _element2 = displays[_i2]; + _element2.innerHTML = copyDelimiters.display[0] + _element2.innerHTML.substr(copyDelimiters.inline[0].length, _element2.innerHTML.length - copyDelimiters.inline[0].length - copyDelimiters.inline[1].length) + copyDelimiters.display[1]; + } + return fragment; +} + +// Return
element containing node, or null if not found. +function closestKatex(node) { + // If node is a Text Node, for example, go up to containing Element, + // where we can apply the `closest` method. + var element = node instanceof Element ? node : node.parentElement; + return element && element.closest('.katex'); +} +// Global copy handler to modify behavior on/within .katex elements. +document.addEventListener('copy', function (event) { + var selection = window.getSelection(); + if (!selection || selection.isCollapsed || !event.clipboardData) { + return; // default action OK if selection is empty or unchangeable + } + var clipboardData = event.clipboardData; + var range = selection.getRangeAt(0); + // When start point is within a formula, expand to entire formula. + var startKatex = closestKatex(range.startContainer); + if (startKatex) { + range.setStartBefore(startKatex); + } + // Similarly, when end point is within a formula, expand to entire formula. + var endKatex = closestKatex(range.endContainer); + if (endKatex) { + range.setEndAfter(endKatex); + } + var fragment = range.cloneContents(); + if (!fragment.querySelector('.katex-mathml')) { + return; // default action OK if no .katex-mathml elements + } + var htmlContents = Array.prototype.map.call(fragment.childNodes, el => el instanceof Text ? el.textContent : el.outerHTML).join(''); + // Preserve usual HTML copy/paste behavior. + clipboardData.setData('text/html', htmlContents); + // Rewrite plain-text version. + clipboardData.setData('text/plain', katexReplaceWithTex(fragment).textContent); + // Prevent normal copy handling. + event.preventDefault(); +}); diff --git a/node_modules/react-katex/node_modules/katex/dist/contrib/mathtex-script-type.js b/node_modules/react-katex/node_modules/katex/dist/contrib/mathtex-script-type.js new file mode 100644 index 0000000..196c17e --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/dist/contrib/mathtex-script-type.js @@ -0,0 +1,107 @@ +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(require("katex")); + else if(typeof define === 'function' && define.amd) + define(["katex"], factory); + else { + var a = typeof exports === 'object' ? factory(require("katex")) : factory(root["katex"]); + for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i]; + } +})((typeof self !== 'undefined' ? self : this), function(__WEBPACK_EXTERNAL_MODULE__757__) { +return /******/ (function() { // webpackBootstrap +/******/ "use strict"; +/******/ var __webpack_modules__ = ({ + +/***/ 757: +/***/ (function(module) { + +module.exports = __WEBPACK_EXTERNAL_MODULE__757__; + +/***/ }) + +/******/ }); +/************************************************************************/ +/******/ // The module cache +/******/ var __webpack_module_cache__ = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ // Check if module is in cache +/******/ var cachedModule = __webpack_module_cache__[moduleId]; +/******/ if (cachedModule !== undefined) { +/******/ return cachedModule.exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = __webpack_module_cache__[moduleId] = { +/******/ // no module.id needed +/******/ // no module.loaded needed +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/************************************************************************/ +/******/ /* webpack/runtime/compat get default export */ +/******/ !function() { +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function() { return module['default']; } : +/******/ function() { return module; }; +/******/ __webpack_require__.d(getter, { a: getter }); +/******/ return getter; +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/define property getters */ +/******/ !function() { +/******/ // define getter functions for harmony exports +/******/ __webpack_require__.d = function(exports, definition) { +/******/ for(var key in definition) { +/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { +/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); +/******/ } +/******/ } +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/hasOwnProperty shorthand */ +/******/ !function() { +/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } +/******/ }(); +/******/ +/************************************************************************/ +var __webpack_exports__ = {}; +/* harmony import */ var katex__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(757); +/* harmony import */ var katex__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(katex__WEBPACK_IMPORTED_MODULE_0__); + +let scripts = document.body.getElementsByTagName("script"); +scripts = Array.prototype.slice.call(scripts); +scripts.forEach(function (script) { + if (!script.type || !script.type.match(/math\/tex/i)) { + return -1; + } + const display = script.type.match(/mode\s*=\s*display(;|\s|\n|$)/) != null; + const katexElement = document.createElement(display ? "div" : "span"); + katexElement.setAttribute("class", display ? "equation" : "inline-equation"); + try { + katex__WEBPACK_IMPORTED_MODULE_0___default().render(script.text, katexElement, { + displayMode: display + }); + } catch (err) { + // eslint-disable-next-line no-console + console.error(err); + katexElement.textContent = script.text; + } + script.parentNode.replaceChild(katexElement, script); +}); +__webpack_exports__ = __webpack_exports__["default"]; +/******/ return __webpack_exports__; +/******/ })() +; +}); \ No newline at end of file diff --git a/node_modules/react-katex/node_modules/katex/dist/contrib/mathtex-script-type.min.js b/node_modules/react-katex/node_modules/katex/dist/contrib/mathtex-script-type.min.js new file mode 100644 index 0000000..c605747 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/dist/contrib/mathtex-script-type.min.js @@ -0,0 +1 @@ +!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("katex"));else if("function"==typeof define&&define.amd)define(["katex"],t);else{var r="object"==typeof exports?t(require("katex")):t(e.katex);for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}("undefined"!=typeof self?self:this,function(e){return function(){"use strict";var t={757:function(t){t.exports=e}},r={};function n(e){var o=r[e];if(void 0!==o)return o.exports;var i=r[e]={exports:{}};return t[e](i,i.exports,n),i.exports}n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};var o={},i=n(757),a=n.n(i);let u=document.body.getElementsByTagName("script");return u=Array.prototype.slice.call(u),u.forEach(function(e){if(!e.type||!e.type.match(/math\/tex/i))return-1;const t=null!=e.type.match(/mode\s*=\s*display(;|\s|\n|$)/),r=document.createElement(t?"div":"span");r.setAttribute("class",t?"equation":"inline-equation");try{a().render(e.text,r,{displayMode:t})}catch(t){console.error(t),r.textContent=e.text}e.parentNode.replaceChild(r,e)}),o=o.default}()}); \ No newline at end of file diff --git a/node_modules/react-katex/node_modules/katex/dist/contrib/mathtex-script-type.mjs b/node_modules/react-katex/node_modules/katex/dist/contrib/mathtex-script-type.mjs new file mode 100644 index 0000000..b5f2b74 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/dist/contrib/mathtex-script-type.mjs @@ -0,0 +1,22 @@ +import katex from '../katex.mjs'; + +var scripts = document.body.getElementsByTagName("script"); +scripts = Array.prototype.slice.call(scripts); +scripts.forEach(function (script) { + if (!script.type || !script.type.match(/math\/tex/i)) { + return -1; + } + var display = script.type.match(/mode\s*=\s*display(;|\s|\n|$)/) != null; + var katexElement = document.createElement(display ? "div" : "span"); + katexElement.setAttribute("class", display ? "equation" : "inline-equation"); + try { + katex.render(script.text, katexElement, { + displayMode: display + }); + } catch (err) { + // eslint-disable-next-line no-console + console.error(err); + katexElement.textContent = script.text; + } + script.parentNode.replaceChild(katexElement, script); +}); diff --git a/node_modules/react-katex/node_modules/katex/dist/contrib/mhchem.js b/node_modules/react-katex/node_modules/katex/dist/contrib/mhchem.js new file mode 100644 index 0000000..0a974a8 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/dist/contrib/mhchem.js @@ -0,0 +1,2965 @@ +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(require("katex")); + else if(typeof define === 'function' && define.amd) + define(["katex"], factory); + else { + var a = typeof exports === 'object' ? factory(require("katex")) : factory(root["katex"]); + for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i]; + } +})((typeof self !== 'undefined' ? self : this), function(__WEBPACK_EXTERNAL_MODULE__757__) { +return /******/ (function() { // webpackBootstrap +/******/ "use strict"; +/******/ var __webpack_modules__ = ({ + +/***/ 757: +/***/ (function(module) { + +module.exports = __WEBPACK_EXTERNAL_MODULE__757__; + +/***/ }) + +/******/ }); +/************************************************************************/ +/******/ // The module cache +/******/ var __webpack_module_cache__ = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ // Check if module is in cache +/******/ var cachedModule = __webpack_module_cache__[moduleId]; +/******/ if (cachedModule !== undefined) { +/******/ return cachedModule.exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = __webpack_module_cache__[moduleId] = { +/******/ // no module.id needed +/******/ // no module.loaded needed +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/************************************************************************/ +/******/ /* webpack/runtime/compat get default export */ +/******/ !function() { +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function() { return module['default']; } : +/******/ function() { return module; }; +/******/ __webpack_require__.d(getter, { a: getter }); +/******/ return getter; +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/define property getters */ +/******/ !function() { +/******/ // define getter functions for harmony exports +/******/ __webpack_require__.d = function(exports, definition) { +/******/ for(var key in definition) { +/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { +/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); +/******/ } +/******/ } +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/hasOwnProperty shorthand */ +/******/ !function() { +/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } +/******/ }(); +/******/ +/************************************************************************/ +var __webpack_exports__ = {}; +/* harmony import */ var katex__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(757); +/* harmony import */ var katex__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(katex__WEBPACK_IMPORTED_MODULE_0__); +/* eslint-disable */ +/* -*- Mode: JavaScript; indent-tabs-mode:nil; js-indent-level: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ + +/************************************************************* + * + * KaTeX mhchem.js + * + * This file implements a KaTeX version of mhchem version 3.3.0. + * It is adapted from MathJax/extensions/TeX/mhchem.js + * It differs from the MathJax version as follows: + * 1. The interface is changed so that it can be called from KaTeX, not MathJax. + * 2. \rlap and \llap are replaced with \mathrlap and \mathllap. + * 3. Four lines of code are edited in order to use \raisebox instead of \raise. + * 4. The reaction arrow code is simplified. All reaction arrows are rendered + * using KaTeX extensible arrows instead of building non-extensible arrows. + * 5. \tripledash vertical alignment is slightly adjusted. + * + * This code, as other KaTeX code, is released under the MIT license. + * + * /************************************************************* + * + * MathJax/extensions/TeX/mhchem.js + * + * Implements the \ce command for handling chemical formulas + * from the mhchem LaTeX package. + * + * --------------------------------------------------------------------- + * + * Copyright (c) 2011-2015 The MathJax Consortium + * Copyright (c) 2015-2018 Martin Hensel + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// +// Coding Style +// - use '' for identifiers that can by minified/uglified +// - use "" for strings that need to stay untouched + +// version: "3.3.0" for MathJax and KaTeX + +// Add \ce, \pu, and \tripledash to the KaTeX macros. + +katex__WEBPACK_IMPORTED_MODULE_0___default().__defineMacro("\\ce", function (context) { + return chemParse(context.consumeArgs(1)[0], "ce"); +}); +katex__WEBPACK_IMPORTED_MODULE_0___default().__defineMacro("\\pu", function (context) { + return chemParse(context.consumeArgs(1)[0], "pu"); +}); + +// Needed for \bond for the ~ forms +// Raise by 2.56mu, not 2mu. We're raising a hyphen-minus, U+002D, not +// a mathematical minus, U+2212. So we need that extra 0.56. +katex__WEBPACK_IMPORTED_MODULE_0___default().__defineMacro("\\tripledash", "{\\vphantom{-}\\raisebox{2.56mu}{$\\mkern2mu" + "\\tiny\\text{-}\\mkern1mu\\text{-}\\mkern1mu\\text{-}\\mkern2mu$}}"); + + +// +// This is the main function for handing the \ce and \pu commands. +// It takes the argument to \ce or \pu and returns the corresponding TeX string. +// + +var chemParse = function (tokens, stateMachine) { + // Recreate the argument string from KaTeX's array of tokens. + var str = ""; + var expectedLoc = tokens.length && tokens[tokens.length - 1].loc.start; + for (var i = tokens.length - 1; i >= 0; i--) { + if (tokens[i].loc.start > expectedLoc) { + // context.consumeArgs has eaten a space. + str += " "; + expectedLoc = tokens[i].loc.start; + } + str += tokens[i].text; + expectedLoc += tokens[i].text.length; + } + var tex = texify.go(mhchemParser.go(str, stateMachine)); + return tex; +}; + +// +// Core parser for mhchem syntax (recursive) +// +/** @type {MhchemParser} */ +var mhchemParser = { + // + // Parses mchem \ce syntax + // + // Call like + // go("H2O"); + // + go: function (input, stateMachine) { + if (!input) { + return []; + } + if (stateMachine === undefined) { + stateMachine = 'ce'; + } + var state = '0'; + + // + // String buffers for parsing: + // + // buffer.a == amount + // buffer.o == element + // buffer.b == left-side superscript + // buffer.p == left-side subscript + // buffer.q == right-side subscript + // buffer.d == right-side superscript + // + // buffer.r == arrow + // buffer.rdt == arrow, script above, type + // buffer.rd == arrow, script above, content + // buffer.rqt == arrow, script below, type + // buffer.rq == arrow, script below, content + // + // buffer.text_ + // buffer.rm + // etc. + // + // buffer.parenthesisLevel == int, starting at 0 + // buffer.sb == bool, space before + // buffer.beginsWithBond == bool + // + // These letters are also used as state names. + // + // Other states: + // 0 == begin of main part (arrow/operator unlikely) + // 1 == next entity + // 2 == next entity (arrow/operator unlikely) + // 3 == next atom + // c == macro + // + /** @type {Buffer} */ + var buffer = {}; + buffer['parenthesisLevel'] = 0; + input = input.replace(/\n/g, " "); + input = input.replace(/[\u2212\u2013\u2014\u2010]/g, "-"); + input = input.replace(/[\u2026]/g, "..."); + + // + // Looks through mhchemParser.transitions, to execute a matching action + // (recursive) + // + var lastInput; + var watchdog = 10; + /** @type {ParserOutput[]} */ + var output = []; + while (true) { + if (lastInput !== input) { + watchdog = 10; + lastInput = input; + } else { + watchdog--; + } + // + // Find actions in transition table + // + var machine = mhchemParser.stateMachines[stateMachine]; + var t = machine.transitions[state] || machine.transitions['*']; + iterateTransitions: for (var i = 0; i < t.length; i++) { + var matches = mhchemParser.patterns.match_(t[i].pattern, input); + if (matches) { + // + // Execute actions + // + var task = t[i].task; + for (var iA = 0; iA < task.action_.length; iA++) { + var o; + // + // Find and execute action + // + if (machine.actions[task.action_[iA].type_]) { + o = machine.actions[task.action_[iA].type_](buffer, matches.match_, task.action_[iA].option); + } else if (mhchemParser.actions[task.action_[iA].type_]) { + o = mhchemParser.actions[task.action_[iA].type_](buffer, matches.match_, task.action_[iA].option); + } else { + throw ["MhchemBugA", "mhchem bug A. Please report. (" + task.action_[iA].type_ + ")"]; // Trying to use non-existing action + } + // + // Add output + // + mhchemParser.concatArray(output, o); + } + // + // Set next state, + // Shorten input, + // Continue with next character + // (= apply only one transition per position) + // + state = task.nextState || state; + if (input.length > 0) { + if (!task.revisit) { + input = matches.remainder; + } + if (!task.toContinue) { + break iterateTransitions; + } + } else { + return output; + } + } + } + // + // Prevent infinite loop + // + if (watchdog <= 0) { + throw ["MhchemBugU", "mhchem bug U. Please report."]; // Unexpected character + } + } + }, + concatArray: function (a, b) { + if (b) { + if (Array.isArray(b)) { + for (var iB = 0; iB < b.length; iB++) { + a.push(b[iB]); + } + } else { + a.push(b); + } + } + }, + patterns: { + // + // Matching patterns + // either regexps or function that return null or {match_:"a", remainder:"bc"} + // + patterns: { + // property names must not look like integers ("2") for correct property traversal order, later on + 'empty': /^$/, + 'else': /^./, + 'else2': /^./, + 'space': /^\s/, + 'space A': /^\s(?=[A-Z\\$])/, + 'space$': /^\s$/, + 'a-z': /^[a-z]/, + 'x': /^x/, + 'x$': /^x$/, + 'i$': /^i$/, + 'letters': /^(?:[a-zA-Z\u03B1-\u03C9\u0391-\u03A9?@]|(?:\\(?:alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega|Gamma|Delta|Theta|Lambda|Xi|Pi|Sigma|Upsilon|Phi|Psi|Omega)(?:\s+|\{\}|(?![a-zA-Z]))))+/, + '\\greek': /^\\(?:alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega|Gamma|Delta|Theta|Lambda|Xi|Pi|Sigma|Upsilon|Phi|Psi|Omega)(?:\s+|\{\}|(?![a-zA-Z]))/, + 'one lowercase latin letter $': /^(?:([a-z])(?:$|[^a-zA-Z]))$/, + '$one lowercase latin letter$ $': /^\$(?:([a-z])(?:$|[^a-zA-Z]))\$$/, + 'one lowercase greek letter $': /^(?:\$?[\u03B1-\u03C9]\$?|\$?\\(?:alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega)\s*\$?)(?:\s+|\{\}|(?![a-zA-Z]))$/, + 'digits': /^[0-9]+/, + '-9.,9': /^[+\-]?(?:[0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+))/, + '-9.,9 no missing 0': /^[+\-]?[0-9]+(?:[.,][0-9]+)?/, + '(-)(9.,9)(e)(99)': function (input) { + var m = input.match(/^(\+\-|\+\/\-|\+|\-|\\pm\s?)?([0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+))?(\((?:[0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+))\))?(?:([eE]|\s*(\*|x|\\times|\u00D7)\s*10\^)([+\-]?[0-9]+|\{[+\-]?[0-9]+\}))?/); + if (m && m[0]) { + return { + match_: m.splice(1), + remainder: input.substr(m[0].length) + }; + } + return null; + }, + '(-)(9)^(-9)': function (input) { + var m = input.match(/^(\+\-|\+\/\-|\+|\-|\\pm\s?)?([0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+)?)\^([+\-]?[0-9]+|\{[+\-]?[0-9]+\})/); + if (m && m[0]) { + return { + match_: m.splice(1), + remainder: input.substr(m[0].length) + }; + } + return null; + }, + 'state of aggregation $': function (input) { + // ... or crystal system + var a = mhchemParser.patterns.findObserveGroups(input, "", /^\([a-z]{1,3}(?=[\),])/, ")", ""); // (aq), (aq,$\infty$), (aq, sat) + if (a && a.remainder.match(/^($|[\s,;\)\]\}])/)) { + return a; + } // AND end of 'phrase' + var m = input.match(/^(?:\((?:\\ca\s?)?\$[amothc]\$\))/); // OR crystal system ($o$) (\ca$c$) + if (m) { + return { + match_: m[0], + remainder: input.substr(m[0].length) + }; + } + return null; + }, + '_{(state of aggregation)}$': /^_\{(\([a-z]{1,3}\))\}/, + '{[(': /^(?:\\\{|\[|\()/, + ')]}': /^(?:\)|\]|\\\})/, + ', ': /^[,;]\s*/, + ',': /^[,;]/, + '.': /^[.]/, + '. ': /^([.\u22C5\u00B7\u2022])\s*/, + '...': /^\.\.\.(?=$|[^.])/, + '* ': /^([*])\s*/, + '^{(...)}': function (input) { + return mhchemParser.patterns.findObserveGroups(input, "^{", "", "", "}"); + }, + '^($...$)': function (input) { + return mhchemParser.patterns.findObserveGroups(input, "^", "$", "$", ""); + }, + '^a': /^\^([0-9]+|[^\\_])/, + '^\\x{}{}': function (input) { + return mhchemParser.patterns.findObserveGroups(input, "^", /^\\[a-zA-Z]+\{/, "}", "", "", "{", "}", "", true); + }, + '^\\x{}': function (input) { + return mhchemParser.patterns.findObserveGroups(input, "^", /^\\[a-zA-Z]+\{/, "}", ""); + }, + '^\\x': /^\^(\\[a-zA-Z]+)\s*/, + '^(-1)': /^\^(-?\d+)/, + '\'': /^'/, + '_{(...)}': function (input) { + return mhchemParser.patterns.findObserveGroups(input, "_{", "", "", "}"); + }, + '_($...$)': function (input) { + return mhchemParser.patterns.findObserveGroups(input, "_", "$", "$", ""); + }, + '_9': /^_([+\-]?[0-9]+|[^\\])/, + '_\\x{}{}': function (input) { + return mhchemParser.patterns.findObserveGroups(input, "_", /^\\[a-zA-Z]+\{/, "}", "", "", "{", "}", "", true); + }, + '_\\x{}': function (input) { + return mhchemParser.patterns.findObserveGroups(input, "_", /^\\[a-zA-Z]+\{/, "}", ""); + }, + '_\\x': /^_(\\[a-zA-Z]+)\s*/, + '^_': /^(?:\^(?=_)|\_(?=\^)|[\^_]$)/, + '{}': /^\{\}/, + '{...}': function (input) { + return mhchemParser.patterns.findObserveGroups(input, "", "{", "}", ""); + }, + '{(...)}': function (input) { + return mhchemParser.patterns.findObserveGroups(input, "{", "", "", "}"); + }, + '$...$': function (input) { + return mhchemParser.patterns.findObserveGroups(input, "", "$", "$", ""); + }, + '${(...)}$': function (input) { + return mhchemParser.patterns.findObserveGroups(input, "${", "", "", "}$"); + }, + '$(...)$': function (input) { + return mhchemParser.patterns.findObserveGroups(input, "$", "", "", "$"); + }, + '=<>': /^[=<>]/, + '#': /^[#\u2261]/, + '+': /^\+/, + '-$': /^-(?=[\s_},;\]/]|$|\([a-z]+\))/, + // -space -, -; -] -/ -$ -state-of-aggregation + '-9': /^-(?=[0-9])/, + '- orbital overlap': /^-(?=(?:[spd]|sp)(?:$|[\s,;\)\]\}]))/, + '-': /^-/, + 'pm-operator': /^(?:\\pm|\$\\pm\$|\+-|\+\/-)/, + 'operator': /^(?:\+|(?:[\-=<>]|<<|>>|\\approx|\$\\approx\$)(?=\s|$|-?[0-9]))/, + 'arrowUpDown': /^(?:v|\(v\)|\^|\(\^\))(?=$|[\s,;\)\]\}])/, + '\\bond{(...)}': function (input) { + return mhchemParser.patterns.findObserveGroups(input, "\\bond{", "", "", "}"); + }, + '->': /^(?:<->|<-->|->|<-|<=>>|<<=>|<=>|[\u2192\u27F6\u21CC])/, + 'CMT': /^[CMT](?=\[)/, + '[(...)]': function (input) { + return mhchemParser.patterns.findObserveGroups(input, "[", "", "", "]"); + }, + '1st-level escape': /^(&|\\\\|\\hline)\s*/, + '\\,': /^(?:\\[,\ ;:])/, + // \\x - but output no space before + '\\x{}{}': function (input) { + return mhchemParser.patterns.findObserveGroups(input, "", /^\\[a-zA-Z]+\{/, "}", "", "", "{", "}", "", true); + }, + '\\x{}': function (input) { + return mhchemParser.patterns.findObserveGroups(input, "", /^\\[a-zA-Z]+\{/, "}", ""); + }, + '\\ca': /^\\ca(?:\s+|(?![a-zA-Z]))/, + '\\x': /^(?:\\[a-zA-Z]+\s*|\\[_&{}%])/, + 'orbital': /^(?:[0-9]{1,2}[spdfgh]|[0-9]{0,2}sp)(?=$|[^a-zA-Z])/, + // only those with numbers in front, because the others will be formatted correctly anyway + 'others': /^[\/~|]/, + '\\frac{(...)}': function (input) { + return mhchemParser.patterns.findObserveGroups(input, "\\frac{", "", "", "}", "{", "", "", "}"); + }, + '\\overset{(...)}': function (input) { + return mhchemParser.patterns.findObserveGroups(input, "\\overset{", "", "", "}", "{", "", "", "}"); + }, + '\\underset{(...)}': function (input) { + return mhchemParser.patterns.findObserveGroups(input, "\\underset{", "", "", "}", "{", "", "", "}"); + }, + '\\underbrace{(...)}': function (input) { + return mhchemParser.patterns.findObserveGroups(input, "\\underbrace{", "", "", "}_", "{", "", "", "}"); + }, + '\\color{(...)}0': function (input) { + return mhchemParser.patterns.findObserveGroups(input, "\\color{", "", "", "}"); + }, + '\\color{(...)}{(...)}1': function (input) { + return mhchemParser.patterns.findObserveGroups(input, "\\color{", "", "", "}", "{", "", "", "}"); + }, + '\\color(...){(...)}2': function (input) { + return mhchemParser.patterns.findObserveGroups(input, "\\color", "\\", "", /^(?=\{)/, "{", "", "", "}"); + }, + '\\ce{(...)}': function (input) { + return mhchemParser.patterns.findObserveGroups(input, "\\ce{", "", "", "}"); + }, + 'oxidation$': /^(?:[+-][IVX]+|\\pm\s*0|\$\\pm\$\s*0)$/, + 'd-oxidation$': /^(?:[+-]?\s?[IVX]+|\\pm\s*0|\$\\pm\$\s*0)$/, + // 0 could be oxidation or charge + 'roman numeral': /^[IVX]+/, + '1/2$': /^[+\-]?(?:[0-9]+|\$[a-z]\$|[a-z])\/[0-9]+(?:\$[a-z]\$|[a-z])?$/, + 'amount': function (input) { + var match; + // e.g. 2, 0.5, 1/2, -2, n/2, +; $a$ could be added later in parsing + match = input.match(/^(?:(?:(?:\([+\-]?[0-9]+\/[0-9]+\)|[+\-]?(?:[0-9]+|\$[a-z]\$|[a-z])\/[0-9]+|[+\-]?[0-9]+[.,][0-9]+|[+\-]?\.[0-9]+|[+\-]?[0-9]+)(?:[a-z](?=\s*[A-Z]))?)|[+\-]?[a-z](?=\s*[A-Z])|\+(?!\s))/); + if (match) { + return { + match_: match[0], + remainder: input.substr(match[0].length) + }; + } + var a = mhchemParser.patterns.findObserveGroups(input, "", "$", "$", ""); + if (a) { + // e.g. $2n-1$, $-$ + match = a.match_.match(/^\$(?:\(?[+\-]?(?:[0-9]*[a-z]?[+\-])?[0-9]*[a-z](?:[+\-][0-9]*[a-z]?)?\)?|\+|-)\$$/); + if (match) { + return { + match_: match[0], + remainder: input.substr(match[0].length) + }; + } + } + return null; + }, + 'amount2': function (input) { + return this['amount'](input); + }, + '(KV letters),': /^(?:[A-Z][a-z]{0,2}|i)(?=,)/, + 'formula$': function (input) { + if (input.match(/^\([a-z]+\)$/)) { + return null; + } // state of aggregation = no formula + var match = input.match(/^(?:[a-z]|(?:[0-9\ \+\-\,\.\(\)]+[a-z])+[0-9\ \+\-\,\.\(\)]*|(?:[a-z][0-9\ \+\-\,\.\(\)]+)+[a-z]?)$/); + if (match) { + return { + match_: match[0], + remainder: input.substr(match[0].length) + }; + } + return null; + }, + 'uprightEntities': /^(?:pH|pOH|pC|pK|iPr|iBu)(?=$|[^a-zA-Z])/, + '/': /^\s*(\/)\s*/, + '//': /^\s*(\/\/)\s*/, + '*': /^\s*[*.]\s*/ + }, + findObserveGroups: function (input, begExcl, begIncl, endIncl, endExcl, beg2Excl, beg2Incl, end2Incl, end2Excl, combine) { + /** @type {{(input: string, pattern: string | RegExp): string | string[] | null;}} */ + var _match = function (input, pattern) { + if (typeof pattern === "string") { + if (input.indexOf(pattern) !== 0) { + return null; + } + return pattern; + } else { + var match = input.match(pattern); + if (!match) { + return null; + } + return match[0]; + } + }; + /** @type {{(input: string, i: number, endChars: string | RegExp): {endMatchBegin: number, endMatchEnd: number} | null;}} */ + var _findObserveGroups = function (input, i, endChars) { + var braces = 0; + while (i < input.length) { + var a = input.charAt(i); + var match = _match(input.substr(i), endChars); + if (match !== null && braces === 0) { + return { + endMatchBegin: i, + endMatchEnd: i + match.length + }; + } else if (a === "{") { + braces++; + } else if (a === "}") { + if (braces === 0) { + throw ["ExtraCloseMissingOpen", "Extra close brace or missing open brace"]; + } else { + braces--; + } + } + i++; + } + if (braces > 0) { + return null; + } + return null; + }; + var match = _match(input, begExcl); + if (match === null) { + return null; + } + input = input.substr(match.length); + match = _match(input, begIncl); + if (match === null) { + return null; + } + var e = _findObserveGroups(input, match.length, endIncl || endExcl); + if (e === null) { + return null; + } + var match1 = input.substring(0, endIncl ? e.endMatchEnd : e.endMatchBegin); + if (!(beg2Excl || beg2Incl)) { + return { + match_: match1, + remainder: input.substr(e.endMatchEnd) + }; + } else { + var group2 = this.findObserveGroups(input.substr(e.endMatchEnd), beg2Excl, beg2Incl, end2Incl, end2Excl); + if (group2 === null) { + return null; + } + /** @type {string[]} */ + var matchRet = [match1, group2.match_]; + return { + match_: combine ? matchRet.join("") : matchRet, + remainder: group2.remainder + }; + } + }, + // + // Matching function + // e.g. match("a", input) will look for the regexp called "a" and see if it matches + // returns null or {match_:"a", remainder:"bc"} + // + match_: function (m, input) { + var pattern = mhchemParser.patterns.patterns[m]; + if (pattern === undefined) { + throw ["MhchemBugP", "mhchem bug P. Please report. (" + m + ")"]; // Trying to use non-existing pattern + } else if (typeof pattern === "function") { + return mhchemParser.patterns.patterns[m](input); // cannot use cached var pattern here, because some pattern functions need this===mhchemParser + } else { + // RegExp + var match = input.match(pattern); + if (match) { + var mm; + if (match[2]) { + mm = [match[1], match[2]]; + } else if (match[1]) { + mm = match[1]; + } else { + mm = match[0]; + } + return { + match_: mm, + remainder: input.substr(match[0].length) + }; + } + return null; + } + } + }, + // + // Generic state machine actions + // + actions: { + 'a=': function (buffer, m) { + buffer.a = (buffer.a || "") + m; + }, + 'b=': function (buffer, m) { + buffer.b = (buffer.b || "") + m; + }, + 'p=': function (buffer, m) { + buffer.p = (buffer.p || "") + m; + }, + 'o=': function (buffer, m) { + buffer.o = (buffer.o || "") + m; + }, + 'q=': function (buffer, m) { + buffer.q = (buffer.q || "") + m; + }, + 'd=': function (buffer, m) { + buffer.d = (buffer.d || "") + m; + }, + 'rm=': function (buffer, m) { + buffer.rm = (buffer.rm || "") + m; + }, + 'text=': function (buffer, m) { + buffer.text_ = (buffer.text_ || "") + m; + }, + 'insert': function (buffer, m, a) { + return { + type_: a + }; + }, + 'insert+p1': function (buffer, m, a) { + return { + type_: a, + p1: m + }; + }, + 'insert+p1+p2': function (buffer, m, a) { + return { + type_: a, + p1: m[0], + p2: m[1] + }; + }, + 'copy': function (buffer, m) { + return m; + }, + 'rm': function (buffer, m) { + return { + type_: 'rm', + p1: m || "" + }; + }, + 'text': function (buffer, m) { + return mhchemParser.go(m, 'text'); + }, + '{text}': function (buffer, m) { + var ret = ["{"]; + mhchemParser.concatArray(ret, mhchemParser.go(m, 'text')); + ret.push("}"); + return ret; + }, + 'tex-math': function (buffer, m) { + return mhchemParser.go(m, 'tex-math'); + }, + 'tex-math tight': function (buffer, m) { + return mhchemParser.go(m, 'tex-math tight'); + }, + 'bond': function (buffer, m, k) { + return { + type_: 'bond', + kind_: k || m + }; + }, + 'color0-output': function (buffer, m) { + return { + type_: 'color0', + color: m[0] + }; + }, + 'ce': function (buffer, m) { + return mhchemParser.go(m); + }, + '1/2': function (buffer, m) { + /** @type {ParserOutput[]} */ + var ret = []; + if (m.match(/^[+\-]/)) { + ret.push(m.substr(0, 1)); + m = m.substr(1); + } + var n = m.match(/^([0-9]+|\$[a-z]\$|[a-z])\/([0-9]+)(\$[a-z]\$|[a-z])?$/); + n[1] = n[1].replace(/\$/g, ""); + ret.push({ + type_: 'frac', + p1: n[1], + p2: n[2] + }); + if (n[3]) { + n[3] = n[3].replace(/\$/g, ""); + ret.push({ + type_: 'tex-math', + p1: n[3] + }); + } + return ret; + }, + '9,9': function (buffer, m) { + return mhchemParser.go(m, '9,9'); + } + }, + // + // createTransitions + // convert { 'letter': { 'state': { action_: 'output' } } } to { 'state' => [ { pattern: 'letter', task: { action_: [{type_: 'output'}] } } ] } + // with expansion of 'a|b' to 'a' and 'b' (at 2 places) + // + createTransitions: function (o) { + var pattern, state; + /** @type {string[]} */ + var stateArray; + var i; + // + // 1. Collect all states + // + /** @type {Transitions} */ + var transitions = {}; + for (pattern in o) { + for (state in o[pattern]) { + stateArray = state.split("|"); + o[pattern][state].stateArray = stateArray; + for (i = 0; i < stateArray.length; i++) { + transitions[stateArray[i]] = []; + } + } + } + // + // 2. Fill states + // + for (pattern in o) { + for (state in o[pattern]) { + stateArray = o[pattern][state].stateArray || []; + for (i = 0; i < stateArray.length; i++) { + // + // 2a. Normalize actions into array: 'text=' ==> [{type_:'text='}] + // (Note to myself: Resolving the function here would be problematic. It would need .bind (for *this*) and currying (for *option*).) + // + /** @type {any} */ + var p = o[pattern][state]; + if (p.action_) { + p.action_ = [].concat(p.action_); + for (var k = 0; k < p.action_.length; k++) { + if (typeof p.action_[k] === "string") { + p.action_[k] = { + type_: p.action_[k] + }; + } + } + } else { + p.action_ = []; + } + // + // 2.b Multi-insert + // + var patternArray = pattern.split("|"); + for (var j = 0; j < patternArray.length; j++) { + if (stateArray[i] === '*') { + // insert into all + for (var t in transitions) { + transitions[t].push({ + pattern: patternArray[j], + task: p + }); + } + } else { + transitions[stateArray[i]].push({ + pattern: patternArray[j], + task: p + }); + } + } + } + } + } + return transitions; + }, + stateMachines: {} +}; + +// +// Definition of state machines +// +mhchemParser.stateMachines = { + // + // \ce state machines + // + //#region ce + 'ce': { + // main parser + transitions: mhchemParser.createTransitions({ + 'empty': { + '*': { + action_: 'output' + } + }, + 'else': { + '0|1|2': { + action_: 'beginsWithBond=false', + revisit: true, + toContinue: true + } + }, + 'oxidation$': { + '0': { + action_: 'oxidation-output' + } + }, + 'CMT': { + 'r': { + action_: 'rdt=', + nextState: 'rt' + }, + 'rd': { + action_: 'rqt=', + nextState: 'rdt' + } + }, + 'arrowUpDown': { + '0|1|2|as': { + action_: ['sb=false', 'output', 'operator'], + nextState: '1' + } + }, + 'uprightEntities': { + '0|1|2': { + action_: ['o=', 'output'], + nextState: '1' + } + }, + 'orbital': { + '0|1|2|3': { + action_: 'o=', + nextState: 'o' + } + }, + '->': { + '0|1|2|3': { + action_: 'r=', + nextState: 'r' + }, + 'a|as': { + action_: ['output', 'r='], + nextState: 'r' + }, + '*': { + action_: ['output', 'r='], + nextState: 'r' + } + }, + '+': { + 'o': { + action_: 'd= kv', + nextState: 'd' + }, + 'd|D': { + action_: 'd=', + nextState: 'd' + }, + 'q': { + action_: 'd=', + nextState: 'qd' + }, + 'qd|qD': { + action_: 'd=', + nextState: 'qd' + }, + 'dq': { + action_: ['output', 'd='], + nextState: 'd' + }, + '3': { + action_: ['sb=false', 'output', 'operator'], + nextState: '0' + } + }, + 'amount': { + '0|2': { + action_: 'a=', + nextState: 'a' + } + }, + 'pm-operator': { + '0|1|2|a|as': { + action_: ['sb=false', 'output', { + type_: 'operator', + option: '\\pm' + }], + nextState: '0' + } + }, + 'operator': { + '0|1|2|a|as': { + action_: ['sb=false', 'output', 'operator'], + nextState: '0' + } + }, + '-$': { + 'o|q': { + action_: ['charge or bond', 'output'], + nextState: 'qd' + }, + 'd': { + action_: 'd=', + nextState: 'd' + }, + 'D': { + action_: ['output', { + type_: 'bond', + option: "-" + }], + nextState: '3' + }, + 'q': { + action_: 'd=', + nextState: 'qd' + }, + 'qd': { + action_: 'd=', + nextState: 'qd' + }, + 'qD|dq': { + action_: ['output', { + type_: 'bond', + option: "-" + }], + nextState: '3' + } + }, + '-9': { + '3|o': { + action_: ['output', { + type_: 'insert', + option: 'hyphen' + }], + nextState: '3' + } + }, + '- orbital overlap': { + 'o': { + action_: ['output', { + type_: 'insert', + option: 'hyphen' + }], + nextState: '2' + }, + 'd': { + action_: ['output', { + type_: 'insert', + option: 'hyphen' + }], + nextState: '2' + } + }, + '-': { + '0|1|2': { + action_: [{ + type_: 'output', + option: 1 + }, 'beginsWithBond=true', { + type_: 'bond', + option: "-" + }], + nextState: '3' + }, + '3': { + action_: { + type_: 'bond', + option: "-" + } + }, + 'a': { + action_: ['output', { + type_: 'insert', + option: 'hyphen' + }], + nextState: '2' + }, + 'as': { + action_: [{ + type_: 'output', + option: 2 + }, { + type_: 'bond', + option: "-" + }], + nextState: '3' + }, + 'b': { + action_: 'b=' + }, + 'o': { + action_: { + type_: '- after o/d', + option: false + }, + nextState: '2' + }, + 'q': { + action_: { + type_: '- after o/d', + option: false + }, + nextState: '2' + }, + 'd|qd|dq': { + action_: { + type_: '- after o/d', + option: true + }, + nextState: '2' + }, + 'D|qD|p': { + action_: ['output', { + type_: 'bond', + option: "-" + }], + nextState: '3' + } + }, + 'amount2': { + '1|3': { + action_: 'a=', + nextState: 'a' + } + }, + 'letters': { + '0|1|2|3|a|as|b|p|bp|o': { + action_: 'o=', + nextState: 'o' + }, + 'q|dq': { + action_: ['output', 'o='], + nextState: 'o' + }, + 'd|D|qd|qD': { + action_: 'o after d', + nextState: 'o' + } + }, + 'digits': { + 'o': { + action_: 'q=', + nextState: 'q' + }, + 'd|D': { + action_: 'q=', + nextState: 'dq' + }, + 'q': { + action_: ['output', 'o='], + nextState: 'o' + }, + 'a': { + action_: 'o=', + nextState: 'o' + } + }, + 'space A': { + 'b|p|bp': {} + }, + 'space': { + 'a': { + nextState: 'as' + }, + '0': { + action_: 'sb=false' + }, + '1|2': { + action_: 'sb=true' + }, + 'r|rt|rd|rdt|rdq': { + action_: 'output', + nextState: '0' + }, + '*': { + action_: ['output', 'sb=true'], + nextState: '1' + } + }, + '1st-level escape': { + '1|2': { + action_: ['output', { + type_: 'insert+p1', + option: '1st-level escape' + }] + }, + '*': { + action_: ['output', { + type_: 'insert+p1', + option: '1st-level escape' + }], + nextState: '0' + } + }, + '[(...)]': { + 'r|rt': { + action_: 'rd=', + nextState: 'rd' + }, + 'rd|rdt': { + action_: 'rq=', + nextState: 'rdq' + } + }, + '...': { + 'o|d|D|dq|qd|qD': { + action_: ['output', { + type_: 'bond', + option: "..." + }], + nextState: '3' + }, + '*': { + action_: [{ + type_: 'output', + option: 1 + }, { + type_: 'insert', + option: 'ellipsis' + }], + nextState: '1' + } + }, + '. |* ': { + '*': { + action_: ['output', { + type_: 'insert', + option: 'addition compound' + }], + nextState: '1' + } + }, + 'state of aggregation $': { + '*': { + action_: ['output', 'state of aggregation'], + nextState: '1' + } + }, + '{[(': { + 'a|as|o': { + action_: ['o=', 'output', 'parenthesisLevel++'], + nextState: '2' + }, + '0|1|2|3': { + action_: ['o=', 'output', 'parenthesisLevel++'], + nextState: '2' + }, + '*': { + action_: ['output', 'o=', 'output', 'parenthesisLevel++'], + nextState: '2' + } + }, + ')]}': { + '0|1|2|3|b|p|bp|o': { + action_: ['o=', 'parenthesisLevel--'], + nextState: 'o' + }, + 'a|as|d|D|q|qd|qD|dq': { + action_: ['output', 'o=', 'parenthesisLevel--'], + nextState: 'o' + } + }, + ', ': { + '*': { + action_: ['output', 'comma'], + nextState: '0' + } + }, + '^_': { + // ^ and _ without a sensible argument + '*': {} + }, + '^{(...)}|^($...$)': { + '0|1|2|as': { + action_: 'b=', + nextState: 'b' + }, + 'p': { + action_: 'b=', + nextState: 'bp' + }, + '3|o': { + action_: 'd= kv', + nextState: 'D' + }, + 'q': { + action_: 'd=', + nextState: 'qD' + }, + 'd|D|qd|qD|dq': { + action_: ['output', 'd='], + nextState: 'D' + } + }, + '^a|^\\x{}{}|^\\x{}|^\\x|\'': { + '0|1|2|as': { + action_: 'b=', + nextState: 'b' + }, + 'p': { + action_: 'b=', + nextState: 'bp' + }, + '3|o': { + action_: 'd= kv', + nextState: 'd' + }, + 'q': { + action_: 'd=', + nextState: 'qd' + }, + 'd|qd|D|qD': { + action_: 'd=' + }, + 'dq': { + action_: ['output', 'd='], + nextState: 'd' + } + }, + '_{(state of aggregation)}$': { + 'd|D|q|qd|qD|dq': { + action_: ['output', 'q='], + nextState: 'q' + } + }, + '_{(...)}|_($...$)|_9|_\\x{}{}|_\\x{}|_\\x': { + '0|1|2|as': { + action_: 'p=', + nextState: 'p' + }, + 'b': { + action_: 'p=', + nextState: 'bp' + }, + '3|o': { + action_: 'q=', + nextState: 'q' + }, + 'd|D': { + action_: 'q=', + nextState: 'dq' + }, + 'q|qd|qD|dq': { + action_: ['output', 'q='], + nextState: 'q' + } + }, + '=<>': { + '0|1|2|3|a|as|o|q|d|D|qd|qD|dq': { + action_: [{ + type_: 'output', + option: 2 + }, 'bond'], + nextState: '3' + } + }, + '#': { + '0|1|2|3|a|as|o': { + action_: [{ + type_: 'output', + option: 2 + }, { + type_: 'bond', + option: "#" + }], + nextState: '3' + } + }, + '{}': { + '*': { + action_: { + type_: 'output', + option: 1 + }, + nextState: '1' + } + }, + '{...}': { + '0|1|2|3|a|as|b|p|bp': { + action_: 'o=', + nextState: 'o' + }, + 'o|d|D|q|qd|qD|dq': { + action_: ['output', 'o='], + nextState: 'o' + } + }, + '$...$': { + 'a': { + action_: 'a=' + }, + // 2$n$ + '0|1|2|3|as|b|p|bp|o': { + action_: 'o=', + nextState: 'o' + }, + // not 'amount' + 'as|o': { + action_: 'o=' + }, + 'q|d|D|qd|qD|dq': { + action_: ['output', 'o='], + nextState: 'o' + } + }, + '\\bond{(...)}': { + '*': { + action_: [{ + type_: 'output', + option: 2 + }, 'bond'], + nextState: "3" + } + }, + '\\frac{(...)}': { + '*': { + action_: [{ + type_: 'output', + option: 1 + }, 'frac-output'], + nextState: '3' + } + }, + '\\overset{(...)}': { + '*': { + action_: [{ + type_: 'output', + option: 2 + }, 'overset-output'], + nextState: '3' + } + }, + '\\underset{(...)}': { + '*': { + action_: [{ + type_: 'output', + option: 2 + }, 'underset-output'], + nextState: '3' + } + }, + '\\underbrace{(...)}': { + '*': { + action_: [{ + type_: 'output', + option: 2 + }, 'underbrace-output'], + nextState: '3' + } + }, + '\\color{(...)}{(...)}1|\\color(...){(...)}2': { + '*': { + action_: [{ + type_: 'output', + option: 2 + }, 'color-output'], + nextState: '3' + } + }, + '\\color{(...)}0': { + '*': { + action_: [{ + type_: 'output', + option: 2 + }, 'color0-output'] + } + }, + '\\ce{(...)}': { + '*': { + action_: [{ + type_: 'output', + option: 2 + }, 'ce'], + nextState: '3' + } + }, + '\\,': { + '*': { + action_: [{ + type_: 'output', + option: 1 + }, 'copy'], + nextState: '1' + } + }, + '\\x{}{}|\\x{}|\\x': { + '0|1|2|3|a|as|b|p|bp|o|c0': { + action_: ['o=', 'output'], + nextState: '3' + }, + '*': { + action_: ['output', 'o=', 'output'], + nextState: '3' + } + }, + 'others': { + '*': { + action_: [{ + type_: 'output', + option: 1 + }, 'copy'], + nextState: '3' + } + }, + 'else2': { + 'a': { + action_: 'a to o', + nextState: 'o', + revisit: true + }, + 'as': { + action_: ['output', 'sb=true'], + nextState: '1', + revisit: true + }, + 'r|rt|rd|rdt|rdq': { + action_: ['output'], + nextState: '0', + revisit: true + }, + '*': { + action_: ['output', 'copy'], + nextState: '3' + } + } + }), + actions: { + 'o after d': function (buffer, m) { + var ret; + if ((buffer.d || "").match(/^[0-9]+$/)) { + var tmp = buffer.d; + buffer.d = undefined; + ret = this['output'](buffer); + buffer.b = tmp; + } else { + ret = this['output'](buffer); + } + mhchemParser.actions['o='](buffer, m); + return ret; + }, + 'd= kv': function (buffer, m) { + buffer.d = m; + buffer.dType = 'kv'; + }, + 'charge or bond': function (buffer, m) { + if (buffer['beginsWithBond']) { + /** @type {ParserOutput[]} */ + var ret = []; + mhchemParser.concatArray(ret, this['output'](buffer)); + mhchemParser.concatArray(ret, mhchemParser.actions['bond'](buffer, m, "-")); + return ret; + } else { + buffer.d = m; + } + }, + '- after o/d': function (buffer, m, isAfterD) { + var c1 = mhchemParser.patterns.match_('orbital', buffer.o || ""); + var c2 = mhchemParser.patterns.match_('one lowercase greek letter $', buffer.o || ""); + var c3 = mhchemParser.patterns.match_('one lowercase latin letter $', buffer.o || ""); + var c4 = mhchemParser.patterns.match_('$one lowercase latin letter$ $', buffer.o || ""); + var hyphenFollows = m === "-" && (c1 && c1.remainder === "" || c2 || c3 || c4); + if (hyphenFollows && !buffer.a && !buffer.b && !buffer.p && !buffer.d && !buffer.q && !c1 && c3) { + buffer.o = '$' + buffer.o + '$'; + } + /** @type {ParserOutput[]} */ + var ret = []; + if (hyphenFollows) { + mhchemParser.concatArray(ret, this['output'](buffer)); + ret.push({ + type_: 'hyphen' + }); + } else { + c1 = mhchemParser.patterns.match_('digits', buffer.d || ""); + if (isAfterD && c1 && c1.remainder === '') { + mhchemParser.concatArray(ret, mhchemParser.actions['d='](buffer, m)); + mhchemParser.concatArray(ret, this['output'](buffer)); + } else { + mhchemParser.concatArray(ret, this['output'](buffer)); + mhchemParser.concatArray(ret, mhchemParser.actions['bond'](buffer, m, "-")); + } + } + return ret; + }, + 'a to o': function (buffer) { + buffer.o = buffer.a; + buffer.a = undefined; + }, + 'sb=true': function (buffer) { + buffer.sb = true; + }, + 'sb=false': function (buffer) { + buffer.sb = false; + }, + 'beginsWithBond=true': function (buffer) { + buffer['beginsWithBond'] = true; + }, + 'beginsWithBond=false': function (buffer) { + buffer['beginsWithBond'] = false; + }, + 'parenthesisLevel++': function (buffer) { + buffer['parenthesisLevel']++; + }, + 'parenthesisLevel--': function (buffer) { + buffer['parenthesisLevel']--; + }, + 'state of aggregation': function (buffer, m) { + return { + type_: 'state of aggregation', + p1: mhchemParser.go(m, 'o') + }; + }, + 'comma': function (buffer, m) { + var a = m.replace(/\s*$/, ''); + var withSpace = a !== m; + if (withSpace && buffer['parenthesisLevel'] === 0) { + return { + type_: 'comma enumeration L', + p1: a + }; + } else { + return { + type_: 'comma enumeration M', + p1: a + }; + } + }, + 'output': function (buffer, m, entityFollows) { + // entityFollows: + // undefined = if we have nothing else to output, also ignore the just read space (buffer.sb) + // 1 = an entity follows, never omit the space if there was one just read before (can only apply to state 1) + // 2 = 1 + the entity can have an amount, so output a\, instead of converting it to o (can only apply to states a|as) + /** @type {ParserOutput | ParserOutput[]} */ + var ret; + if (!buffer.r) { + ret = []; + if (!buffer.a && !buffer.b && !buffer.p && !buffer.o && !buffer.q && !buffer.d && !entityFollows) { + //ret = []; + } else { + if (buffer.sb) { + ret.push({ + type_: 'entitySkip' + }); + } + if (!buffer.o && !buffer.q && !buffer.d && !buffer.b && !buffer.p && entityFollows !== 2) { + buffer.o = buffer.a; + buffer.a = undefined; + } else if (!buffer.o && !buffer.q && !buffer.d && (buffer.b || buffer.p)) { + buffer.o = buffer.a; + buffer.d = buffer.b; + buffer.q = buffer.p; + buffer.a = buffer.b = buffer.p = undefined; + } else { + if (buffer.o && buffer.dType === 'kv' && mhchemParser.patterns.match_('d-oxidation$', buffer.d || "")) { + buffer.dType = 'oxidation'; + } else if (buffer.o && buffer.dType === 'kv' && !buffer.q) { + buffer.dType = undefined; + } + } + ret.push({ + type_: 'chemfive', + a: mhchemParser.go(buffer.a, 'a'), + b: mhchemParser.go(buffer.b, 'bd'), + p: mhchemParser.go(buffer.p, 'pq'), + o: mhchemParser.go(buffer.o, 'o'), + q: mhchemParser.go(buffer.q, 'pq'), + d: mhchemParser.go(buffer.d, buffer.dType === 'oxidation' ? 'oxidation' : 'bd'), + dType: buffer.dType + }); + } + } else { + // r + /** @type {ParserOutput[]} */ + var rd; + if (buffer.rdt === 'M') { + rd = mhchemParser.go(buffer.rd, 'tex-math'); + } else if (buffer.rdt === 'T') { + rd = [{ + type_: 'text', + p1: buffer.rd || "" + }]; + } else { + rd = mhchemParser.go(buffer.rd); + } + /** @type {ParserOutput[]} */ + var rq; + if (buffer.rqt === 'M') { + rq = mhchemParser.go(buffer.rq, 'tex-math'); + } else if (buffer.rqt === 'T') { + rq = [{ + type_: 'text', + p1: buffer.rq || "" + }]; + } else { + rq = mhchemParser.go(buffer.rq); + } + ret = { + type_: 'arrow', + r: buffer.r, + rd: rd, + rq: rq + }; + } + for (var p in buffer) { + if (p !== 'parenthesisLevel' && p !== 'beginsWithBond') { + delete buffer[p]; + } + } + return ret; + }, + 'oxidation-output': function (buffer, m) { + var ret = ["{"]; + mhchemParser.concatArray(ret, mhchemParser.go(m, 'oxidation')); + ret.push("}"); + return ret; + }, + 'frac-output': function (buffer, m) { + return { + type_: 'frac-ce', + p1: mhchemParser.go(m[0]), + p2: mhchemParser.go(m[1]) + }; + }, + 'overset-output': function (buffer, m) { + return { + type_: 'overset', + p1: mhchemParser.go(m[0]), + p2: mhchemParser.go(m[1]) + }; + }, + 'underset-output': function (buffer, m) { + return { + type_: 'underset', + p1: mhchemParser.go(m[0]), + p2: mhchemParser.go(m[1]) + }; + }, + 'underbrace-output': function (buffer, m) { + return { + type_: 'underbrace', + p1: mhchemParser.go(m[0]), + p2: mhchemParser.go(m[1]) + }; + }, + 'color-output': function (buffer, m) { + return { + type_: 'color', + color1: m[0], + color2: mhchemParser.go(m[1]) + }; + }, + 'r=': function (buffer, m) { + buffer.r = m; + }, + 'rdt=': function (buffer, m) { + buffer.rdt = m; + }, + 'rd=': function (buffer, m) { + buffer.rd = m; + }, + 'rqt=': function (buffer, m) { + buffer.rqt = m; + }, + 'rq=': function (buffer, m) { + buffer.rq = m; + }, + 'operator': function (buffer, m, p1) { + return { + type_: 'operator', + kind_: p1 || m + }; + } + } + }, + 'a': { + transitions: mhchemParser.createTransitions({ + 'empty': { + '*': {} + }, + '1/2$': { + '0': { + action_: '1/2' + } + }, + 'else': { + '0': { + nextState: '1', + revisit: true + } + }, + '$(...)$': { + '*': { + action_: 'tex-math tight', + nextState: '1' + } + }, + ',': { + '*': { + action_: { + type_: 'insert', + option: 'commaDecimal' + } + } + }, + 'else2': { + '*': { + action_: 'copy' + } + } + }), + actions: {} + }, + 'o': { + transitions: mhchemParser.createTransitions({ + 'empty': { + '*': {} + }, + '1/2$': { + '0': { + action_: '1/2' + } + }, + 'else': { + '0': { + nextState: '1', + revisit: true + } + }, + 'letters': { + '*': { + action_: 'rm' + } + }, + '\\ca': { + '*': { + action_: { + type_: 'insert', + option: 'circa' + } + } + }, + '\\x{}{}|\\x{}|\\x': { + '*': { + action_: 'copy' + } + }, + '${(...)}$|$(...)$': { + '*': { + action_: 'tex-math' + } + }, + '{(...)}': { + '*': { + action_: '{text}' + } + }, + 'else2': { + '*': { + action_: 'copy' + } + } + }), + actions: {} + }, + 'text': { + transitions: mhchemParser.createTransitions({ + 'empty': { + '*': { + action_: 'output' + } + }, + '{...}': { + '*': { + action_: 'text=' + } + }, + '${(...)}$|$(...)$': { + '*': { + action_: 'tex-math' + } + }, + '\\greek': { + '*': { + action_: ['output', 'rm'] + } + }, + '\\,|\\x{}{}|\\x{}|\\x': { + '*': { + action_: ['output', 'copy'] + } + }, + 'else': { + '*': { + action_: 'text=' + } + } + }), + actions: { + 'output': function (buffer) { + if (buffer.text_) { + /** @type {ParserOutput} */ + var ret = { + type_: 'text', + p1: buffer.text_ + }; + for (var p in buffer) { + delete buffer[p]; + } + return ret; + } + } + } + }, + 'pq': { + transitions: mhchemParser.createTransitions({ + 'empty': { + '*': {} + }, + 'state of aggregation $': { + '*': { + action_: 'state of aggregation' + } + }, + 'i$': { + '0': { + nextState: '!f', + revisit: true + } + }, + '(KV letters),': { + '0': { + action_: 'rm', + nextState: '0' + } + }, + 'formula$': { + '0': { + nextState: 'f', + revisit: true + } + }, + '1/2$': { + '0': { + action_: '1/2' + } + }, + 'else': { + '0': { + nextState: '!f', + revisit: true + } + }, + '${(...)}$|$(...)$': { + '*': { + action_: 'tex-math' + } + }, + '{(...)}': { + '*': { + action_: 'text' + } + }, + 'a-z': { + 'f': { + action_: 'tex-math' + } + }, + 'letters': { + '*': { + action_: 'rm' + } + }, + '-9.,9': { + '*': { + action_: '9,9' + } + }, + ',': { + '*': { + action_: { + type_: 'insert+p1', + option: 'comma enumeration S' + } + } + }, + '\\color{(...)}{(...)}1|\\color(...){(...)}2': { + '*': { + action_: 'color-output' + } + }, + '\\color{(...)}0': { + '*': { + action_: 'color0-output' + } + }, + '\\ce{(...)}': { + '*': { + action_: 'ce' + } + }, + '\\,|\\x{}{}|\\x{}|\\x': { + '*': { + action_: 'copy' + } + }, + 'else2': { + '*': { + action_: 'copy' + } + } + }), + actions: { + 'state of aggregation': function (buffer, m) { + return { + type_: 'state of aggregation subscript', + p1: mhchemParser.go(m, 'o') + }; + }, + 'color-output': function (buffer, m) { + return { + type_: 'color', + color1: m[0], + color2: mhchemParser.go(m[1], 'pq') + }; + } + } + }, + 'bd': { + transitions: mhchemParser.createTransitions({ + 'empty': { + '*': {} + }, + 'x$': { + '0': { + nextState: '!f', + revisit: true + } + }, + 'formula$': { + '0': { + nextState: 'f', + revisit: true + } + }, + 'else': { + '0': { + nextState: '!f', + revisit: true + } + }, + '-9.,9 no missing 0': { + '*': { + action_: '9,9' + } + }, + '.': { + '*': { + action_: { + type_: 'insert', + option: 'electron dot' + } + } + }, + 'a-z': { + 'f': { + action_: 'tex-math' + } + }, + 'x': { + '*': { + action_: { + type_: 'insert', + option: 'KV x' + } + } + }, + 'letters': { + '*': { + action_: 'rm' + } + }, + '\'': { + '*': { + action_: { + type_: 'insert', + option: 'prime' + } + } + }, + '${(...)}$|$(...)$': { + '*': { + action_: 'tex-math' + } + }, + '{(...)}': { + '*': { + action_: 'text' + } + }, + '\\color{(...)}{(...)}1|\\color(...){(...)}2': { + '*': { + action_: 'color-output' + } + }, + '\\color{(...)}0': { + '*': { + action_: 'color0-output' + } + }, + '\\ce{(...)}': { + '*': { + action_: 'ce' + } + }, + '\\,|\\x{}{}|\\x{}|\\x': { + '*': { + action_: 'copy' + } + }, + 'else2': { + '*': { + action_: 'copy' + } + } + }), + actions: { + 'color-output': function (buffer, m) { + return { + type_: 'color', + color1: m[0], + color2: mhchemParser.go(m[1], 'bd') + }; + } + } + }, + 'oxidation': { + transitions: mhchemParser.createTransitions({ + 'empty': { + '*': {} + }, + 'roman numeral': { + '*': { + action_: 'roman-numeral' + } + }, + '${(...)}$|$(...)$': { + '*': { + action_: 'tex-math' + } + }, + 'else': { + '*': { + action_: 'copy' + } + } + }), + actions: { + 'roman-numeral': function (buffer, m) { + return { + type_: 'roman numeral', + p1: m || "" + }; + } + } + }, + 'tex-math': { + transitions: mhchemParser.createTransitions({ + 'empty': { + '*': { + action_: 'output' + } + }, + '\\ce{(...)}': { + '*': { + action_: ['output', 'ce'] + } + }, + '{...}|\\,|\\x{}{}|\\x{}|\\x': { + '*': { + action_: 'o=' + } + }, + 'else': { + '*': { + action_: 'o=' + } + } + }), + actions: { + 'output': function (buffer) { + if (buffer.o) { + /** @type {ParserOutput} */ + var ret = { + type_: 'tex-math', + p1: buffer.o + }; + for (var p in buffer) { + delete buffer[p]; + } + return ret; + } + } + } + }, + 'tex-math tight': { + transitions: mhchemParser.createTransitions({ + 'empty': { + '*': { + action_: 'output' + } + }, + '\\ce{(...)}': { + '*': { + action_: ['output', 'ce'] + } + }, + '{...}|\\,|\\x{}{}|\\x{}|\\x': { + '*': { + action_: 'o=' + } + }, + '-|+': { + '*': { + action_: 'tight operator' + } + }, + 'else': { + '*': { + action_: 'o=' + } + } + }), + actions: { + 'tight operator': function (buffer, m) { + buffer.o = (buffer.o || "") + "{" + m + "}"; + }, + 'output': function (buffer) { + if (buffer.o) { + /** @type {ParserOutput} */ + var ret = { + type_: 'tex-math', + p1: buffer.o + }; + for (var p in buffer) { + delete buffer[p]; + } + return ret; + } + } + } + }, + '9,9': { + transitions: mhchemParser.createTransitions({ + 'empty': { + '*': {} + }, + ',': { + '*': { + action_: 'comma' + } + }, + 'else': { + '*': { + action_: 'copy' + } + } + }), + actions: { + 'comma': function () { + return { + type_: 'commaDecimal' + }; + } + } + }, + //#endregion + // + // \pu state machines + // + //#region pu + 'pu': { + transitions: mhchemParser.createTransitions({ + 'empty': { + '*': { + action_: 'output' + } + }, + 'space$': { + '*': { + action_: ['output', 'space'] + } + }, + '{[(|)]}': { + '0|a': { + action_: 'copy' + } + }, + '(-)(9)^(-9)': { + '0': { + action_: 'number^', + nextState: 'a' + } + }, + '(-)(9.,9)(e)(99)': { + '0': { + action_: 'enumber', + nextState: 'a' + } + }, + 'space': { + '0|a': {} + }, + 'pm-operator': { + '0|a': { + action_: { + type_: 'operator', + option: '\\pm' + }, + nextState: '0' + } + }, + 'operator': { + '0|a': { + action_: 'copy', + nextState: '0' + } + }, + '//': { + 'd': { + action_: 'o=', + nextState: '/' + } + }, + '/': { + 'd': { + action_: 'o=', + nextState: '/' + } + }, + '{...}|else': { + '0|d': { + action_: 'd=', + nextState: 'd' + }, + 'a': { + action_: ['space', 'd='], + nextState: 'd' + }, + '/|q': { + action_: 'q=', + nextState: 'q' + } + } + }), + actions: { + 'enumber': function (buffer, m) { + /** @type {ParserOutput[]} */ + var ret = []; + if (m[0] === "+-" || m[0] === "+/-") { + ret.push("\\pm "); + } else if (m[0]) { + ret.push(m[0]); + } + if (m[1]) { + mhchemParser.concatArray(ret, mhchemParser.go(m[1], 'pu-9,9')); + if (m[2]) { + if (m[2].match(/[,.]/)) { + mhchemParser.concatArray(ret, mhchemParser.go(m[2], 'pu-9,9')); + } else { + ret.push(m[2]); + } + } + m[3] = m[4] || m[3]; + if (m[3]) { + m[3] = m[3].trim(); + if (m[3] === "e" || m[3].substr(0, 1) === "*") { + ret.push({ + type_: 'cdot' + }); + } else { + ret.push({ + type_: 'times' + }); + } + } + } + if (m[3]) { + ret.push("10^{" + m[5] + "}"); + } + return ret; + }, + 'number^': function (buffer, m) { + /** @type {ParserOutput[]} */ + var ret = []; + if (m[0] === "+-" || m[0] === "+/-") { + ret.push("\\pm "); + } else if (m[0]) { + ret.push(m[0]); + } + mhchemParser.concatArray(ret, mhchemParser.go(m[1], 'pu-9,9')); + ret.push("^{" + m[2] + "}"); + return ret; + }, + 'operator': function (buffer, m, p1) { + return { + type_: 'operator', + kind_: p1 || m + }; + }, + 'space': function () { + return { + type_: 'pu-space-1' + }; + }, + 'output': function (buffer) { + /** @type {ParserOutput | ParserOutput[]} */ + var ret; + var md = mhchemParser.patterns.match_('{(...)}', buffer.d || ""); + if (md && md.remainder === '') { + buffer.d = md.match_; + } + var mq = mhchemParser.patterns.match_('{(...)}', buffer.q || ""); + if (mq && mq.remainder === '') { + buffer.q = mq.match_; + } + if (buffer.d) { + buffer.d = buffer.d.replace(/\u00B0C|\^oC|\^{o}C/g, "{}^{\\circ}C"); + buffer.d = buffer.d.replace(/\u00B0F|\^oF|\^{o}F/g, "{}^{\\circ}F"); + } + if (buffer.q) { + // fraction + buffer.q = buffer.q.replace(/\u00B0C|\^oC|\^{o}C/g, "{}^{\\circ}C"); + buffer.q = buffer.q.replace(/\u00B0F|\^oF|\^{o}F/g, "{}^{\\circ}F"); + var b5 = { + d: mhchemParser.go(buffer.d, 'pu'), + q: mhchemParser.go(buffer.q, 'pu') + }; + if (buffer.o === '//') { + ret = { + type_: 'pu-frac', + p1: b5.d, + p2: b5.q + }; + } else { + ret = b5.d; + if (b5.d.length > 1 || b5.q.length > 1) { + ret.push({ + type_: ' / ' + }); + } else { + ret.push({ + type_: '/' + }); + } + mhchemParser.concatArray(ret, b5.q); + } + } else { + // no fraction + ret = mhchemParser.go(buffer.d, 'pu-2'); + } + for (var p in buffer) { + delete buffer[p]; + } + return ret; + } + } + }, + 'pu-2': { + transitions: mhchemParser.createTransitions({ + 'empty': { + '*': { + action_: 'output' + } + }, + '*': { + '*': { + action_: ['output', 'cdot'], + nextState: '0' + } + }, + '\\x': { + '*': { + action_: 'rm=' + } + }, + 'space': { + '*': { + action_: ['output', 'space'], + nextState: '0' + } + }, + '^{(...)}|^(-1)': { + '1': { + action_: '^(-1)' + } + }, + '-9.,9': { + '0': { + action_: 'rm=', + nextState: '0' + }, + '1': { + action_: '^(-1)', + nextState: '0' + } + }, + '{...}|else': { + '*': { + action_: 'rm=', + nextState: '1' + } + } + }), + actions: { + 'cdot': function () { + return { + type_: 'tight cdot' + }; + }, + '^(-1)': function (buffer, m) { + buffer.rm += "^{" + m + "}"; + }, + 'space': function () { + return { + type_: 'pu-space-2' + }; + }, + 'output': function (buffer) { + /** @type {ParserOutput | ParserOutput[]} */ + var ret = []; + if (buffer.rm) { + var mrm = mhchemParser.patterns.match_('{(...)}', buffer.rm || ""); + if (mrm && mrm.remainder === '') { + ret = mhchemParser.go(mrm.match_, 'pu'); + } else { + ret = { + type_: 'rm', + p1: buffer.rm + }; + } + } + for (var p in buffer) { + delete buffer[p]; + } + return ret; + } + } + }, + 'pu-9,9': { + transitions: mhchemParser.createTransitions({ + 'empty': { + '0': { + action_: 'output-0' + }, + 'o': { + action_: 'output-o' + } + }, + ',': { + '0': { + action_: ['output-0', 'comma'], + nextState: 'o' + } + }, + '.': { + '0': { + action_: ['output-0', 'copy'], + nextState: 'o' + } + }, + 'else': { + '*': { + action_: 'text=' + } + } + }), + actions: { + 'comma': function () { + return { + type_: 'commaDecimal' + }; + }, + 'output-0': function (buffer) { + /** @type {ParserOutput[]} */ + var ret = []; + buffer.text_ = buffer.text_ || ""; + if (buffer.text_.length > 4) { + var a = buffer.text_.length % 3; + if (a === 0) { + a = 3; + } + for (var i = buffer.text_.length - 3; i > 0; i -= 3) { + ret.push(buffer.text_.substr(i, 3)); + ret.push({ + type_: '1000 separator' + }); + } + ret.push(buffer.text_.substr(0, a)); + ret.reverse(); + } else { + ret.push(buffer.text_); + } + for (var p in buffer) { + delete buffer[p]; + } + return ret; + }, + 'output-o': function (buffer) { + /** @type {ParserOutput[]} */ + var ret = []; + buffer.text_ = buffer.text_ || ""; + if (buffer.text_.length > 4) { + var a = buffer.text_.length - 3; + for (var i = 0; i < a; i += 3) { + ret.push(buffer.text_.substr(i, 3)); + ret.push({ + type_: '1000 separator' + }); + } + ret.push(buffer.text_.substr(i)); + } else { + ret.push(buffer.text_); + } + for (var p in buffer) { + delete buffer[p]; + } + return ret; + } + } + } + //#endregion +}; + +// +// texify: Take MhchemParser output and convert it to TeX +// +/** @type {Texify} */ +var texify = { + go: function (input, isInner) { + // (recursive, max 4 levels) + if (!input) { + return ""; + } + var res = ""; + var cee = false; + for (var i = 0; i < input.length; i++) { + var inputi = input[i]; + if (typeof inputi === "string") { + res += inputi; + } else { + res += texify._go2(inputi); + if (inputi.type_ === '1st-level escape') { + cee = true; + } + } + } + if (!isInner && !cee && res) { + res = "{" + res + "}"; + } + return res; + }, + _goInner: function (input) { + if (!input) { + return input; + } + return texify.go(input, true); + }, + _go2: function (buf) { + /** @type {undefined | string} */ + var res; + switch (buf.type_) { + case 'chemfive': + res = ""; + var b5 = { + a: texify._goInner(buf.a), + b: texify._goInner(buf.b), + p: texify._goInner(buf.p), + o: texify._goInner(buf.o), + q: texify._goInner(buf.q), + d: texify._goInner(buf.d) + }; + // + // a + // + if (b5.a) { + if (b5.a.match(/^[+\-]/)) { + b5.a = "{" + b5.a + "}"; + } + res += b5.a + "\\,"; + } + // + // b and p + // + if (b5.b || b5.p) { + res += "{\\vphantom{X}}"; + res += "^{\\hphantom{" + (b5.b || "") + "}}_{\\hphantom{" + (b5.p || "") + "}}"; + res += "{\\vphantom{X}}"; + res += "^{\\smash[t]{\\vphantom{2}}\\mathllap{" + (b5.b || "") + "}}"; + res += "_{\\vphantom{2}\\mathllap{\\smash[t]{" + (b5.p || "") + "}}}"; + } + // + // o + // + if (b5.o) { + if (b5.o.match(/^[+\-]/)) { + b5.o = "{" + b5.o + "}"; + } + res += b5.o; + } + // + // q and d + // + if (buf.dType === 'kv') { + if (b5.d || b5.q) { + res += "{\\vphantom{X}}"; + } + if (b5.d) { + res += "^{" + b5.d + "}"; + } + if (b5.q) { + res += "_{\\smash[t]{" + b5.q + "}}"; + } + } else if (buf.dType === 'oxidation') { + if (b5.d) { + res += "{\\vphantom{X}}"; + res += "^{" + b5.d + "}"; + } + if (b5.q) { + res += "{\\vphantom{X}}"; + res += "_{\\smash[t]{" + b5.q + "}}"; + } + } else { + if (b5.q) { + res += "{\\vphantom{X}}"; + res += "_{\\smash[t]{" + b5.q + "}}"; + } + if (b5.d) { + res += "{\\vphantom{X}}"; + res += "^{" + b5.d + "}"; + } + } + break; + case 'rm': + res = "\\mathrm{" + buf.p1 + "}"; + break; + case 'text': + if (buf.p1.match(/[\^_]/)) { + buf.p1 = buf.p1.replace(" ", "~").replace("-", "\\text{-}"); + res = "\\mathrm{" + buf.p1 + "}"; + } else { + res = "\\text{" + buf.p1 + "}"; + } + break; + case 'roman numeral': + res = "\\mathrm{" + buf.p1 + "}"; + break; + case 'state of aggregation': + res = "\\mskip2mu " + texify._goInner(buf.p1); + break; + case 'state of aggregation subscript': + res = "\\mskip1mu " + texify._goInner(buf.p1); + break; + case 'bond': + res = texify._getBond(buf.kind_); + if (!res) { + throw ["MhchemErrorBond", "mhchem Error. Unknown bond type (" + buf.kind_ + ")"]; + } + break; + case 'frac': + var c = "\\frac{" + buf.p1 + "}{" + buf.p2 + "}"; + res = "\\mathchoice{\\textstyle" + c + "}{" + c + "}{" + c + "}{" + c + "}"; + break; + case 'pu-frac': + var d = "\\frac{" + texify._goInner(buf.p1) + "}{" + texify._goInner(buf.p2) + "}"; + res = "\\mathchoice{\\textstyle" + d + "}{" + d + "}{" + d + "}{" + d + "}"; + break; + case 'tex-math': + res = buf.p1 + " "; + break; + case 'frac-ce': + res = "\\frac{" + texify._goInner(buf.p1) + "}{" + texify._goInner(buf.p2) + "}"; + break; + case 'overset': + res = "\\overset{" + texify._goInner(buf.p1) + "}{" + texify._goInner(buf.p2) + "}"; + break; + case 'underset': + res = "\\underset{" + texify._goInner(buf.p1) + "}{" + texify._goInner(buf.p2) + "}"; + break; + case 'underbrace': + res = "\\underbrace{" + texify._goInner(buf.p1) + "}_{" + texify._goInner(buf.p2) + "}"; + break; + case 'color': + res = "{\\color{" + buf.color1 + "}{" + texify._goInner(buf.color2) + "}}"; + break; + case 'color0': + res = "\\color{" + buf.color + "}"; + break; + case 'arrow': + var b6 = { + rd: texify._goInner(buf.rd), + rq: texify._goInner(buf.rq) + }; + var arrow = "\\x" + texify._getArrow(buf.r); + if (b6.rq) { + arrow += "[{" + b6.rq + "}]"; + } + if (b6.rd) { + arrow += "{" + b6.rd + "}"; + } else { + arrow += "{}"; + } + res = arrow; + break; + case 'operator': + res = texify._getOperator(buf.kind_); + break; + case '1st-level escape': + res = buf.p1 + " "; // &, \\\\, \\hlin + break; + case 'space': + res = " "; + break; + case 'entitySkip': + res = "~"; + break; + case 'pu-space-1': + res = "~"; + break; + case 'pu-space-2': + res = "\\mkern3mu "; + break; + case '1000 separator': + res = "\\mkern2mu "; + break; + case 'commaDecimal': + res = "{,}"; + break; + case 'comma enumeration L': + res = "{" + buf.p1 + "}\\mkern6mu "; + break; + case 'comma enumeration M': + res = "{" + buf.p1 + "}\\mkern3mu "; + break; + case 'comma enumeration S': + res = "{" + buf.p1 + "}\\mkern1mu "; + break; + case 'hyphen': + res = "\\text{-}"; + break; + case 'addition compound': + res = "\\,{\\cdot}\\,"; + break; + case 'electron dot': + res = "\\mkern1mu \\bullet\\mkern1mu "; + break; + case 'KV x': + res = "{\\times}"; + break; + case 'prime': + res = "\\prime "; + break; + case 'cdot': + res = "\\cdot "; + break; + case 'tight cdot': + res = "\\mkern1mu{\\cdot}\\mkern1mu "; + break; + case 'times': + res = "\\times "; + break; + case 'circa': + res = "{\\sim}"; + break; + case '^': + res = "uparrow"; + break; + case 'v': + res = "downarrow"; + break; + case 'ellipsis': + res = "\\ldots "; + break; + case '/': + res = "/"; + break; + case ' / ': + res = "\\,/\\,"; + break; + default: + assertNever(buf); + throw ["MhchemBugT", "mhchem bug T. Please report."]; + // Missing texify rule or unknown MhchemParser output + } + assertString(res); + return res; + }, + _getArrow: function (a) { + switch (a) { + case "->": + return "rightarrow"; + case "\u2192": + return "rightarrow"; + case "\u27F6": + return "rightarrow"; + case "<-": + return "leftarrow"; + case "<->": + return "leftrightarrow"; + case "<-->": + return "rightleftarrows"; + case "<=>": + return "rightleftharpoons"; + case "\u21CC": + return "rightleftharpoons"; + case "<=>>": + return "rightequilibrium"; + case "<<=>": + return "leftequilibrium"; + default: + assertNever(a); + throw ["MhchemBugT", "mhchem bug T. Please report."]; + } + }, + _getBond: function (a) { + switch (a) { + case "-": + return "{-}"; + case "1": + return "{-}"; + case "=": + return "{=}"; + case "2": + return "{=}"; + case "#": + return "{\\equiv}"; + case "3": + return "{\\equiv}"; + case "~": + return "{\\tripledash}"; + case "~-": + return "{\\mathrlap{\\raisebox{-.1em}{$-$}}\\raisebox{.1em}{$\\tripledash$}}"; + case "~=": + return "{\\mathrlap{\\raisebox{-.2em}{$-$}}\\mathrlap{\\raisebox{.2em}{$\\tripledash$}}-}"; + case "~--": + return "{\\mathrlap{\\raisebox{-.2em}{$-$}}\\mathrlap{\\raisebox{.2em}{$\\tripledash$}}-}"; + case "-~-": + return "{\\mathrlap{\\raisebox{-.2em}{$-$}}\\mathrlap{\\raisebox{.2em}{$-$}}\\tripledash}"; + case "...": + return "{{\\cdot}{\\cdot}{\\cdot}}"; + case "....": + return "{{\\cdot}{\\cdot}{\\cdot}{\\cdot}}"; + case "->": + return "{\\rightarrow}"; + case "<-": + return "{\\leftarrow}"; + case "<": + return "{<}"; + case ">": + return "{>}"; + default: + assertNever(a); + throw ["MhchemBugT", "mhchem bug T. Please report."]; + } + }, + _getOperator: function (a) { + switch (a) { + case "+": + return " {}+{} "; + case "-": + return " {}-{} "; + case "=": + return " {}={} "; + case "<": + return " {}<{} "; + case ">": + return " {}>{} "; + case "<<": + return " {}\\ll{} "; + case ">>": + return " {}\\gg{} "; + case "\\pm": + return " {}\\pm{} "; + case "\\approx": + return " {}\\approx{} "; + case "$\\approx$": + return " {}\\approx{} "; + case "v": + return " \\downarrow{} "; + case "(v)": + return " \\downarrow{} "; + case "^": + return " \\uparrow{} "; + case "(^)": + return " \\uparrow{} "; + default: + assertNever(a); + throw ["MhchemBugT", "mhchem bug T. Please report."]; + } + } +}; + +// +// Helpers for code analysis +// Will show type error at calling position +// +/** @param {number} a */ +function assertNever(a) {} +/** @param {string} a */ +function assertString(a) {} +__webpack_exports__ = __webpack_exports__["default"]; +/******/ return __webpack_exports__; +/******/ })() +; +}); \ No newline at end of file diff --git a/node_modules/react-katex/node_modules/katex/dist/contrib/mhchem.min.js b/node_modules/react-katex/node_modules/katex/dist/contrib/mhchem.min.js new file mode 100644 index 0000000..2bb40b3 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/dist/contrib/mhchem.min.js @@ -0,0 +1 @@ +!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("katex"));else if("function"==typeof define&&define.amd)define(["katex"],e);else{var n="object"==typeof exports?e(require("katex")):e(t.katex);for(var o in n)("object"==typeof exports?exports:t)[o]=n[o]}}("undefined"!=typeof self?self:this,function(t){return function(){"use strict";var e={757:function(e){e.exports=t}},n={};function o(t){var a=n[t];if(void 0!==a)return a.exports;var r=n[t]={exports:{}};return e[t](r,r.exports,o),r.exports}o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,{a:e}),e},o.d=function(t,e){for(var n in e)o.o(e,n)&&!o.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)};var a={},r=o(757),i=o.n(r);i().__defineMacro("\\ce",function(t){return c(t.consumeArgs(1)[0],"ce")}),i().__defineMacro("\\pu",function(t){return c(t.consumeArgs(1)[0],"pu")}),i().__defineMacro("\\tripledash","{\\vphantom{-}\\raisebox{2.56mu}{$\\mkern2mu\\tiny\\text{-}\\mkern1mu\\text{-}\\mkern1mu\\text{-}\\mkern2mu$}}");var c=function(t,e){for(var n="",o=t.length&&t[t.length-1].loc.start,a=t.length-1;a>=0;a--)t[a].loc.start>o&&(n+=" ",o=t[a].loc.start),n+=t[a].text,o+=t[a].text.length;return p.go(u.go(n,e))},u={go:function(t,e){if(!t)return[];void 0===e&&(e="ce");var n,o="0",a={};a.parenthesisLevel=0,t=(t=(t=t.replace(/\n/g," ")).replace(/[\u2212\u2013\u2014\u2010]/g,"-")).replace(/[\u2026]/g,"...");for(var r=10,i=[];;){n!==t?(r=10,n=t):r--;var c=u.stateMachines[e],p=c.transitions[o]||c.transitions["*"];t:for(var s=0;s0))return i;if(d.revisit||(t=_.remainder),!d.toContinue)break t}}if(r<=0)throw["MhchemBugU","mhchem bug U. Please report."]}},concatArray:function(t,e){if(e)if(Array.isArray(e))for(var n=0;n":/^[=<>]/,"#":/^[#\u2261]/,"+":/^\+/,"-$":/^-(?=[\s_},;\]/]|$|\([a-z]+\))/,"-9":/^-(?=[0-9])/,"- orbital overlap":/^-(?=(?:[spd]|sp)(?:$|[\s,;\)\]\}]))/,"-":/^-/,"pm-operator":/^(?:\\pm|\$\\pm\$|\+-|\+\/-)/,operator:/^(?:\+|(?:[\-=<>]|<<|>>|\\approx|\$\\approx\$)(?=\s|$|-?[0-9]))/,arrowUpDown:/^(?:v|\(v\)|\^|\(\^\))(?=$|[\s,;\)\]\}])/,"\\bond{(...)}":function(t){return u.patterns.findObserveGroups(t,"\\bond{","","","}")},"->":/^(?:<->|<-->|->|<-|<=>>|<<=>|<=>|[\u2192\u27F6\u21CC])/,CMT:/^[CMT](?=\[)/,"[(...)]":function(t){return u.patterns.findObserveGroups(t,"[","","","]")},"1st-level escape":/^(&|\\\\|\\hline)\s*/,"\\,":/^(?:\\[,\ ;:])/,"\\x{}{}":function(t){return u.patterns.findObserveGroups(t,"",/^\\[a-zA-Z]+\{/,"}","","","{","}","",!0)},"\\x{}":function(t){return u.patterns.findObserveGroups(t,"",/^\\[a-zA-Z]+\{/,"}","")},"\\ca":/^\\ca(?:\s+|(?![a-zA-Z]))/,"\\x":/^(?:\\[a-zA-Z]+\s*|\\[_&{}%])/,orbital:/^(?:[0-9]{1,2}[spdfgh]|[0-9]{0,2}sp)(?=$|[^a-zA-Z])/,others:/^[\/~|]/,"\\frac{(...)}":function(t){return u.patterns.findObserveGroups(t,"\\frac{","","","}","{","","","}")},"\\overset{(...)}":function(t){return u.patterns.findObserveGroups(t,"\\overset{","","","}","{","","","}")},"\\underset{(...)}":function(t){return u.patterns.findObserveGroups(t,"\\underset{","","","}","{","","","}")},"\\underbrace{(...)}":function(t){return u.patterns.findObserveGroups(t,"\\underbrace{","","","}_","{","","","}")},"\\color{(...)}0":function(t){return u.patterns.findObserveGroups(t,"\\color{","","","}")},"\\color{(...)}{(...)}1":function(t){return u.patterns.findObserveGroups(t,"\\color{","","","}","{","","","}")},"\\color(...){(...)}2":function(t){return u.patterns.findObserveGroups(t,"\\color","\\","",/^(?=\{)/,"{","","","}")},"\\ce{(...)}":function(t){return u.patterns.findObserveGroups(t,"\\ce{","","","}")},oxidation$:/^(?:[+-][IVX]+|\\pm\s*0|\$\\pm\$\s*0)$/,"d-oxidation$":/^(?:[+-]?\s?[IVX]+|\\pm\s*0|\$\\pm\$\s*0)$/,"roman numeral":/^[IVX]+/,"1/2$":/^[+\-]?(?:[0-9]+|\$[a-z]\$|[a-z])\/[0-9]+(?:\$[a-z]\$|[a-z])?$/,amount:function(t){var e;if(e=t.match(/^(?:(?:(?:\([+\-]?[0-9]+\/[0-9]+\)|[+\-]?(?:[0-9]+|\$[a-z]\$|[a-z])\/[0-9]+|[+\-]?[0-9]+[.,][0-9]+|[+\-]?\.[0-9]+|[+\-]?[0-9]+)(?:[a-z](?=\s*[A-Z]))?)|[+\-]?[a-z](?=\s*[A-Z])|\+(?!\s))/))return{match_:e[0],remainder:t.substr(e[0].length)};var n=u.patterns.findObserveGroups(t,"","$","$","");return n&&(e=n.match_.match(/^\$(?:\(?[+\-]?(?:[0-9]*[a-z]?[+\-])?[0-9]*[a-z](?:[+\-][0-9]*[a-z]?)?\)?|\+|-)\$$/))?{match_:e[0],remainder:t.substr(e[0].length)}:null},amount2:function(t){return this.amount(t)},"(KV letters),":/^(?:[A-Z][a-z]{0,2}|i)(?=,)/,formula$:function(t){if(t.match(/^\([a-z]+\)$/))return null;var e=t.match(/^(?:[a-z]|(?:[0-9\ \+\-\,\.\(\)]+[a-z])+[0-9\ \+\-\,\.\(\)]*|(?:[a-z][0-9\ \+\-\,\.\(\)]+)+[a-z]?)$/);return e?{match_:e[0],remainder:t.substr(e[0].length)}:null},uprightEntities:/^(?:pH|pOH|pC|pK|iPr|iBu)(?=$|[^a-zA-Z])/,"/":/^\s*(\/)\s*/,"//":/^\s*(\/\/)\s*/,"*":/^\s*[*.]\s*/},findObserveGroups:function(t,e,n,o,a,r,i,c,u,p){var s=function(t,e){if("string"==typeof e)return 0!==t.indexOf(e)?null:e;var n=t.match(e);return n?n[0]:null},_=s(t,e);if(null===_)return null;if(t=t.substr(_.length),null===(_=s(t,n)))return null;var d=function(t,e,n){for(var o=0;e":{"0|1|2|3":{action_:"r=",nextState:"r"},"a|as":{action_:["output","r="],nextState:"r"},"*":{action_:["output","r="],nextState:"r"}},"+":{o:{action_:"d= kv",nextState:"d"},"d|D":{action_:"d=",nextState:"d"},q:{action_:"d=",nextState:"qd"},"qd|qD":{action_:"d=",nextState:"qd"},dq:{action_:["output","d="],nextState:"d"},3:{action_:["sb=false","output","operator"],nextState:"0"}},amount:{"0|2":{action_:"a=",nextState:"a"}},"pm-operator":{"0|1|2|a|as":{action_:["sb=false","output",{type_:"operator",option:"\\pm"}],nextState:"0"}},operator:{"0|1|2|a|as":{action_:["sb=false","output","operator"],nextState:"0"}},"-$":{"o|q":{action_:["charge or bond","output"],nextState:"qd"},d:{action_:"d=",nextState:"d"},D:{action_:["output",{type_:"bond",option:"-"}],nextState:"3"},q:{action_:"d=",nextState:"qd"},qd:{action_:"d=",nextState:"qd"},"qD|dq":{action_:["output",{type_:"bond",option:"-"}],nextState:"3"}},"-9":{"3|o":{action_:["output",{type_:"insert",option:"hyphen"}],nextState:"3"}},"- orbital overlap":{o:{action_:["output",{type_:"insert",option:"hyphen"}],nextState:"2"},d:{action_:["output",{type_:"insert",option:"hyphen"}],nextState:"2"}},"-":{"0|1|2":{action_:[{type_:"output",option:1},"beginsWithBond=true",{type_:"bond",option:"-"}],nextState:"3"},3:{action_:{type_:"bond",option:"-"}},a:{action_:["output",{type_:"insert",option:"hyphen"}],nextState:"2"},as:{action_:[{type_:"output",option:2},{type_:"bond",option:"-"}],nextState:"3"},b:{action_:"b="},o:{action_:{type_:"- after o/d",option:!1},nextState:"2"},q:{action_:{type_:"- after o/d",option:!1},nextState:"2"},"d|qd|dq":{action_:{type_:"- after o/d",option:!0},nextState:"2"},"D|qD|p":{action_:["output",{type_:"bond",option:"-"}],nextState:"3"}},amount2:{"1|3":{action_:"a=",nextState:"a"}},letters:{"0|1|2|3|a|as|b|p|bp|o":{action_:"o=",nextState:"o"},"q|dq":{action_:["output","o="],nextState:"o"},"d|D|qd|qD":{action_:"o after d",nextState:"o"}},digits:{o:{action_:"q=",nextState:"q"},"d|D":{action_:"q=",nextState:"dq"},q:{action_:["output","o="],nextState:"o"},a:{action_:"o=",nextState:"o"}},"space A":{"b|p|bp":{}},space:{a:{nextState:"as"},0:{action_:"sb=false"},"1|2":{action_:"sb=true"},"r|rt|rd|rdt|rdq":{action_:"output",nextState:"0"},"*":{action_:["output","sb=true"],nextState:"1"}},"1st-level escape":{"1|2":{action_:["output",{type_:"insert+p1",option:"1st-level escape"}]},"*":{action_:["output",{type_:"insert+p1",option:"1st-level escape"}],nextState:"0"}},"[(...)]":{"r|rt":{action_:"rd=",nextState:"rd"},"rd|rdt":{action_:"rq=",nextState:"rdq"}},"...":{"o|d|D|dq|qd|qD":{action_:["output",{type_:"bond",option:"..."}],nextState:"3"},"*":{action_:[{type_:"output",option:1},{type_:"insert",option:"ellipsis"}],nextState:"1"}},". |* ":{"*":{action_:["output",{type_:"insert",option:"addition compound"}],nextState:"1"}},"state of aggregation $":{"*":{action_:["output","state of aggregation"],nextState:"1"}},"{[(":{"a|as|o":{action_:["o=","output","parenthesisLevel++"],nextState:"2"},"0|1|2|3":{action_:["o=","output","parenthesisLevel++"],nextState:"2"},"*":{action_:["output","o=","output","parenthesisLevel++"],nextState:"2"}},")]}":{"0|1|2|3|b|p|bp|o":{action_:["o=","parenthesisLevel--"],nextState:"o"},"a|as|d|D|q|qd|qD|dq":{action_:["output","o=","parenthesisLevel--"],nextState:"o"}},", ":{"*":{action_:["output","comma"],nextState:"0"}},"^_":{"*":{}},"^{(...)}|^($...$)":{"0|1|2|as":{action_:"b=",nextState:"b"},p:{action_:"b=",nextState:"bp"},"3|o":{action_:"d= kv",nextState:"D"},q:{action_:"d=",nextState:"qD"},"d|D|qd|qD|dq":{action_:["output","d="],nextState:"D"}},"^a|^\\x{}{}|^\\x{}|^\\x|'":{"0|1|2|as":{action_:"b=",nextState:"b"},p:{action_:"b=",nextState:"bp"},"3|o":{action_:"d= kv",nextState:"d"},q:{action_:"d=",nextState:"qd"},"d|qd|D|qD":{action_:"d="},dq:{action_:["output","d="],nextState:"d"}},"_{(state of aggregation)}$":{"d|D|q|qd|qD|dq":{action_:["output","q="],nextState:"q"}},"_{(...)}|_($...$)|_9|_\\x{}{}|_\\x{}|_\\x":{"0|1|2|as":{action_:"p=",nextState:"p"},b:{action_:"p=",nextState:"bp"},"3|o":{action_:"q=",nextState:"q"},"d|D":{action_:"q=",nextState:"dq"},"q|qd|qD|dq":{action_:["output","q="],nextState:"q"}},"=<>":{"0|1|2|3|a|as|o|q|d|D|qd|qD|dq":{action_:[{type_:"output",option:2},"bond"],nextState:"3"}},"#":{"0|1|2|3|a|as|o":{action_:[{type_:"output",option:2},{type_:"bond",option:"#"}],nextState:"3"}},"{}":{"*":{action_:{type_:"output",option:1},nextState:"1"}},"{...}":{"0|1|2|3|a|as|b|p|bp":{action_:"o=",nextState:"o"},"o|d|D|q|qd|qD|dq":{action_:["output","o="],nextState:"o"}},"$...$":{a:{action_:"a="},"0|1|2|3|as|b|p|bp|o":{action_:"o=",nextState:"o"},"as|o":{action_:"o="},"q|d|D|qd|qD|dq":{action_:["output","o="],nextState:"o"}},"\\bond{(...)}":{"*":{action_:[{type_:"output",option:2},"bond"],nextState:"3"}},"\\frac{(...)}":{"*":{action_:[{type_:"output",option:1},"frac-output"],nextState:"3"}},"\\overset{(...)}":{"*":{action_:[{type_:"output",option:2},"overset-output"],nextState:"3"}},"\\underset{(...)}":{"*":{action_:[{type_:"output",option:2},"underset-output"],nextState:"3"}},"\\underbrace{(...)}":{"*":{action_:[{type_:"output",option:2},"underbrace-output"],nextState:"3"}},"\\color{(...)}{(...)}1|\\color(...){(...)}2":{"*":{action_:[{type_:"output",option:2},"color-output"],nextState:"3"}},"\\color{(...)}0":{"*":{action_:[{type_:"output",option:2},"color0-output"]}},"\\ce{(...)}":{"*":{action_:[{type_:"output",option:2},"ce"],nextState:"3"}},"\\,":{"*":{action_:[{type_:"output",option:1},"copy"],nextState:"1"}},"\\x{}{}|\\x{}|\\x":{"0|1|2|3|a|as|b|p|bp|o|c0":{action_:["o=","output"],nextState:"3"},"*":{action_:["output","o=","output"],nextState:"3"}},others:{"*":{action_:[{type_:"output",option:1},"copy"],nextState:"3"}},else2:{a:{action_:"a to o",nextState:"o",revisit:!0},as:{action_:["output","sb=true"],nextState:"1",revisit:!0},"r|rt|rd|rdt|rdq":{action_:["output"],nextState:"0",revisit:!0},"*":{action_:["output","copy"],nextState:"3"}}}),actions:{"o after d":function(t,e){var n;if((t.d||"").match(/^[0-9]+$/)){var o=t.d;t.d=void 0,n=this.output(t),t.b=o}else n=this.output(t);return u.actions["o="](t,e),n},"d= kv":function(t,e){t.d=e,t.dType="kv"},"charge or bond":function(t,e){if(t.beginsWithBond){var n=[];return u.concatArray(n,this.output(t)),u.concatArray(n,u.actions.bond(t,e,"-")),n}t.d=e},"- after o/d":function(t,e,n){var o=u.patterns.match_("orbital",t.o||""),a=u.patterns.match_("one lowercase greek letter $",t.o||""),r=u.patterns.match_("one lowercase latin letter $",t.o||""),i=u.patterns.match_("$one lowercase latin letter$ $",t.o||""),c="-"===e&&(o&&""===o.remainder||a||r||i);!c||t.a||t.b||t.p||t.d||t.q||o||!r||(t.o="$"+t.o+"$");var p=[];return c?(u.concatArray(p,this.output(t)),p.push({type_:"hyphen"})):(o=u.patterns.match_("digits",t.d||""),n&&o&&""===o.remainder?(u.concatArray(p,u.actions["d="](t,e)),u.concatArray(p,this.output(t))):(u.concatArray(p,this.output(t)),u.concatArray(p,u.actions.bond(t,e,"-")))),p},"a to o":function(t){t.o=t.a,t.a=void 0},"sb=true":function(t){t.sb=!0},"sb=false":function(t){t.sb=!1},"beginsWithBond=true":function(t){t.beginsWithBond=!0},"beginsWithBond=false":function(t){t.beginsWithBond=!1},"parenthesisLevel++":function(t){t.parenthesisLevel++},"parenthesisLevel--":function(t){t.parenthesisLevel--},"state of aggregation":function(t,e){return{type_:"state of aggregation",p1:u.go(e,"o")}},comma:function(t,e){var n=e.replace(/\s*$/,"");return n!==e&&0===t.parenthesisLevel?{type_:"comma enumeration L",p1:n}:{type_:"comma enumeration M",p1:n}},output:function(t,e,n){var o,a,r;t.r?(a="M"===t.rdt?u.go(t.rd,"tex-math"):"T"===t.rdt?[{type_:"text",p1:t.rd||""}]:u.go(t.rd),r="M"===t.rqt?u.go(t.rq,"tex-math"):"T"===t.rqt?[{type_:"text",p1:t.rq||""}]:u.go(t.rq),o={type_:"arrow",r:t.r,rd:a,rq:r}):(o=[],(t.a||t.b||t.p||t.o||t.q||t.d||n)&&(t.sb&&o.push({type_:"entitySkip"}),t.o||t.q||t.d||t.b||t.p||2===n?t.o||t.q||t.d||!t.b&&!t.p?t.o&&"kv"===t.dType&&u.patterns.match_("d-oxidation$",t.d||"")?t.dType="oxidation":t.o&&"kv"===t.dType&&!t.q&&(t.dType=void 0):(t.o=t.a,t.d=t.b,t.q=t.p,t.a=t.b=t.p=void 0):(t.o=t.a,t.a=void 0),o.push({type_:"chemfive",a:u.go(t.a,"a"),b:u.go(t.b,"bd"),p:u.go(t.p,"pq"),o:u.go(t.o,"o"),q:u.go(t.q,"pq"),d:u.go(t.d,"oxidation"===t.dType?"oxidation":"bd"),dType:t.dType})));for(var i in t)"parenthesisLevel"!==i&&"beginsWithBond"!==i&&delete t[i];return o},"oxidation-output":function(t,e){var n=["{"];return u.concatArray(n,u.go(e,"oxidation")),n.push("}"),n},"frac-output":function(t,e){return{type_:"frac-ce",p1:u.go(e[0]),p2:u.go(e[1])}},"overset-output":function(t,e){return{type_:"overset",p1:u.go(e[0]),p2:u.go(e[1])}},"underset-output":function(t,e){return{type_:"underset",p1:u.go(e[0]),p2:u.go(e[1])}},"underbrace-output":function(t,e){return{type_:"underbrace",p1:u.go(e[0]),p2:u.go(e[1])}},"color-output":function(t,e){return{type_:"color",color1:e[0],color2:u.go(e[1])}},"r=":function(t,e){t.r=e},"rdt=":function(t,e){t.rdt=e},"rd=":function(t,e){t.rd=e},"rqt=":function(t,e){t.rqt=e},"rq=":function(t,e){t.rq=e},operator:function(t,e,n){return{type_:"operator",kind_:n||e}}}},a:{transitions:u.createTransitions({empty:{"*":{}},"1/2$":{0:{action_:"1/2"}},else:{0:{nextState:"1",revisit:!0}},"$(...)$":{"*":{action_:"tex-math tight",nextState:"1"}},",":{"*":{action_:{type_:"insert",option:"commaDecimal"}}},else2:{"*":{action_:"copy"}}}),actions:{}},o:{transitions:u.createTransitions({empty:{"*":{}},"1/2$":{0:{action_:"1/2"}},else:{0:{nextState:"1",revisit:!0}},letters:{"*":{action_:"rm"}},"\\ca":{"*":{action_:{type_:"insert",option:"circa"}}},"\\x{}{}|\\x{}|\\x":{"*":{action_:"copy"}},"${(...)}$|$(...)$":{"*":{action_:"tex-math"}},"{(...)}":{"*":{action_:"{text}"}},else2:{"*":{action_:"copy"}}}),actions:{}},text:{transitions:u.createTransitions({empty:{"*":{action_:"output"}},"{...}":{"*":{action_:"text="}},"${(...)}$|$(...)$":{"*":{action_:"tex-math"}},"\\greek":{"*":{action_:["output","rm"]}},"\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:["output","copy"]}},else:{"*":{action_:"text="}}}),actions:{output:function(t){if(t.text_){var e={type_:"text",p1:t.text_};for(var n in t)delete t[n];return e}}}},pq:{transitions:u.createTransitions({empty:{"*":{}},"state of aggregation $":{"*":{action_:"state of aggregation"}},i$:{0:{nextState:"!f",revisit:!0}},"(KV letters),":{0:{action_:"rm",nextState:"0"}},formula$:{0:{nextState:"f",revisit:!0}},"1/2$":{0:{action_:"1/2"}},else:{0:{nextState:"!f",revisit:!0}},"${(...)}$|$(...)$":{"*":{action_:"tex-math"}},"{(...)}":{"*":{action_:"text"}},"a-z":{f:{action_:"tex-math"}},letters:{"*":{action_:"rm"}},"-9.,9":{"*":{action_:"9,9"}},",":{"*":{action_:{type_:"insert+p1",option:"comma enumeration S"}}},"\\color{(...)}{(...)}1|\\color(...){(...)}2":{"*":{action_:"color-output"}},"\\color{(...)}0":{"*":{action_:"color0-output"}},"\\ce{(...)}":{"*":{action_:"ce"}},"\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:"copy"}},else2:{"*":{action_:"copy"}}}),actions:{"state of aggregation":function(t,e){return{type_:"state of aggregation subscript",p1:u.go(e,"o")}},"color-output":function(t,e){return{type_:"color",color1:e[0],color2:u.go(e[1],"pq")}}}},bd:{transitions:u.createTransitions({empty:{"*":{}},x$:{0:{nextState:"!f",revisit:!0}},formula$:{0:{nextState:"f",revisit:!0}},else:{0:{nextState:"!f",revisit:!0}},"-9.,9 no missing 0":{"*":{action_:"9,9"}},".":{"*":{action_:{type_:"insert",option:"electron dot"}}},"a-z":{f:{action_:"tex-math"}},x:{"*":{action_:{type_:"insert",option:"KV x"}}},letters:{"*":{action_:"rm"}},"'":{"*":{action_:{type_:"insert",option:"prime"}}},"${(...)}$|$(...)$":{"*":{action_:"tex-math"}},"{(...)}":{"*":{action_:"text"}},"\\color{(...)}{(...)}1|\\color(...){(...)}2":{"*":{action_:"color-output"}},"\\color{(...)}0":{"*":{action_:"color0-output"}},"\\ce{(...)}":{"*":{action_:"ce"}},"\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:"copy"}},else2:{"*":{action_:"copy"}}}),actions:{"color-output":function(t,e){return{type_:"color",color1:e[0],color2:u.go(e[1],"bd")}}}},oxidation:{transitions:u.createTransitions({empty:{"*":{}},"roman numeral":{"*":{action_:"roman-numeral"}},"${(...)}$|$(...)$":{"*":{action_:"tex-math"}},else:{"*":{action_:"copy"}}}),actions:{"roman-numeral":function(t,e){return{type_:"roman numeral",p1:e||""}}}},"tex-math":{transitions:u.createTransitions({empty:{"*":{action_:"output"}},"\\ce{(...)}":{"*":{action_:["output","ce"]}},"{...}|\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:"o="}},else:{"*":{action_:"o="}}}),actions:{output:function(t){if(t.o){var e={type_:"tex-math",p1:t.o};for(var n in t)delete t[n];return e}}}},"tex-math tight":{transitions:u.createTransitions({empty:{"*":{action_:"output"}},"\\ce{(...)}":{"*":{action_:["output","ce"]}},"{...}|\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:"o="}},"-|+":{"*":{action_:"tight operator"}},else:{"*":{action_:"o="}}}),actions:{"tight operator":function(t,e){t.o=(t.o||"")+"{"+e+"}"},output:function(t){if(t.o){var e={type_:"tex-math",p1:t.o};for(var n in t)delete t[n];return e}}}},"9,9":{transitions:u.createTransitions({empty:{"*":{}},",":{"*":{action_:"comma"}},else:{"*":{action_:"copy"}}}),actions:{comma:function(){return{type_:"commaDecimal"}}}},pu:{transitions:u.createTransitions({empty:{"*":{action_:"output"}},space$:{"*":{action_:["output","space"]}},"{[(|)]}":{"0|a":{action_:"copy"}},"(-)(9)^(-9)":{0:{action_:"number^",nextState:"a"}},"(-)(9.,9)(e)(99)":{0:{action_:"enumber",nextState:"a"}},space:{"0|a":{}},"pm-operator":{"0|a":{action_:{type_:"operator",option:"\\pm"},nextState:"0"}},operator:{"0|a":{action_:"copy",nextState:"0"}},"//":{d:{action_:"o=",nextState:"/"}},"/":{d:{action_:"o=",nextState:"/"}},"{...}|else":{"0|d":{action_:"d=",nextState:"d"},a:{action_:["space","d="],nextState:"d"},"/|q":{action_:"q=",nextState:"q"}}}),actions:{enumber:function(t,e){var n=[];return"+-"===e[0]||"+/-"===e[0]?n.push("\\pm "):e[0]&&n.push(e[0]),e[1]&&(u.concatArray(n,u.go(e[1],"pu-9,9")),e[2]&&(e[2].match(/[,.]/)?u.concatArray(n,u.go(e[2],"pu-9,9")):n.push(e[2])),e[3]=e[4]||e[3],e[3]&&(e[3]=e[3].trim(),"e"===e[3]||"*"===e[3].substr(0,1)?n.push({type_:"cdot"}):n.push({type_:"times"}))),e[3]&&n.push("10^{"+e[5]+"}"),n},"number^":function(t,e){var n=[];return"+-"===e[0]||"+/-"===e[0]?n.push("\\pm "):e[0]&&n.push(e[0]),u.concatArray(n,u.go(e[1],"pu-9,9")),n.push("^{"+e[2]+"}"),n},operator:function(t,e,n){return{type_:"operator",kind_:n||e}},space:function(){return{type_:"pu-space-1"}},output:function(t){var e,n=u.patterns.match_("{(...)}",t.d||"");n&&""===n.remainder&&(t.d=n.match_);var o=u.patterns.match_("{(...)}",t.q||"");if(o&&""===o.remainder&&(t.q=o.match_),t.d&&(t.d=t.d.replace(/\u00B0C|\^oC|\^{o}C/g,"{}^{\\circ}C"),t.d=t.d.replace(/\u00B0F|\^oF|\^{o}F/g,"{}^{\\circ}F")),t.q){t.q=t.q.replace(/\u00B0C|\^oC|\^{o}C/g,"{}^{\\circ}C"),t.q=t.q.replace(/\u00B0F|\^oF|\^{o}F/g,"{}^{\\circ}F");var a={d:u.go(t.d,"pu"),q:u.go(t.q,"pu")};"//"===t.o?e={type_:"pu-frac",p1:a.d,p2:a.q}:(e=a.d,a.d.length>1||a.q.length>1?e.push({type_:" / "}):e.push({type_:"/"}),u.concatArray(e,a.q))}else e=u.go(t.d,"pu-2");for(var r in t)delete t[r];return e}}},"pu-2":{transitions:u.createTransitions({empty:{"*":{action_:"output"}},"*":{"*":{action_:["output","cdot"],nextState:"0"}},"\\x":{"*":{action_:"rm="}},space:{"*":{action_:["output","space"],nextState:"0"}},"^{(...)}|^(-1)":{1:{action_:"^(-1)"}},"-9.,9":{0:{action_:"rm=",nextState:"0"},1:{action_:"^(-1)",nextState:"0"}},"{...}|else":{"*":{action_:"rm=",nextState:"1"}}}),actions:{cdot:function(){return{type_:"tight cdot"}},"^(-1)":function(t,e){t.rm+="^{"+e+"}"},space:function(){return{type_:"pu-space-2"}},output:function(t){var e=[];if(t.rm){var n=u.patterns.match_("{(...)}",t.rm||"");e=n&&""===n.remainder?u.go(n.match_,"pu"):{type_:"rm",p1:t.rm}}for(var o in t)delete t[o];return e}}},"pu-9,9":{transitions:u.createTransitions({empty:{0:{action_:"output-0"},o:{action_:"output-o"}},",":{0:{action_:["output-0","comma"],nextState:"o"}},".":{0:{action_:["output-0","copy"],nextState:"o"}},else:{"*":{action_:"text="}}}),actions:{comma:function(){return{type_:"commaDecimal"}},"output-0":function(t){var e=[];if(t.text_=t.text_||"",t.text_.length>4){var n=t.text_.length%3;0===n&&(n=3);for(var o=t.text_.length-3;o>0;o-=3)e.push(t.text_.substr(o,3)),e.push({type_:"1000 separator"});e.push(t.text_.substr(0,n)),e.reverse()}else e.push(t.text_);for(var a in t)delete t[a];return e},"output-o":function(t){var e=[];if(t.text_=t.text_||"",t.text_.length>4){for(var n=t.text_.length-3,o=0;o":case"\u2192":case"\u27f6":return"rightarrow";case"<-":return"leftarrow";case"<->":return"leftrightarrow";case"<--\x3e":return"rightleftarrows";case"<=>":case"\u21cc":return"rightleftharpoons";case"<=>>":return"rightequilibrium";case"<<=>":return"leftequilibrium";default:throw["MhchemBugT","mhchem bug T. Please report."]}},_getBond:function(t){switch(t){case"-":case"1":return"{-}";case"=":case"2":return"{=}";case"#":case"3":return"{\\equiv}";case"~":return"{\\tripledash}";case"~-":return"{\\mathrlap{\\raisebox{-.1em}{$-$}}\\raisebox{.1em}{$\\tripledash$}}";case"~=":case"~--":return"{\\mathrlap{\\raisebox{-.2em}{$-$}}\\mathrlap{\\raisebox{.2em}{$\\tripledash$}}-}";case"-~-":return"{\\mathrlap{\\raisebox{-.2em}{$-$}}\\mathrlap{\\raisebox{.2em}{$-$}}\\tripledash}";case"...":return"{{\\cdot}{\\cdot}{\\cdot}}";case"....":return"{{\\cdot}{\\cdot}{\\cdot}{\\cdot}}";case"->":return"{\\rightarrow}";case"<-":return"{\\leftarrow}";case"<":return"{<}";case">":return"{>}";default:throw["MhchemBugT","mhchem bug T. Please report."]}},_getOperator:function(t){switch(t){case"+":return" {}+{} ";case"-":return" {}-{} ";case"=":return" {}={} ";case"<":return" {}<{} ";case">":return" {}>{} ";case"<<":return" {}\\ll{} ";case">>":return" {}\\gg{} ";case"\\pm":return" {}\\pm{} ";case"\\approx":case"$\\approx$":return" {}\\approx{} ";case"v":case"(v)":return" \\downarrow{} ";case"^":case"(^)":return" \\uparrow{} ";default:throw["MhchemBugT","mhchem bug T. Please report."]}}};return a=a.default}()}); \ No newline at end of file diff --git a/node_modules/react-katex/node_modules/katex/dist/contrib/mhchem.mjs b/node_modules/react-katex/node_modules/katex/dist/contrib/mhchem.mjs new file mode 100644 index 0000000..bbb61fc --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/dist/contrib/mhchem.mjs @@ -0,0 +1,2864 @@ +import katex from '../katex.mjs'; + +/* eslint-disable */ +/* -*- Mode: JavaScript; indent-tabs-mode:nil; js-indent-level: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ + +/************************************************************* + * + * KaTeX mhchem.js + * + * This file implements a KaTeX version of mhchem version 3.3.0. + * It is adapted from MathJax/extensions/TeX/mhchem.js + * It differs from the MathJax version as follows: + * 1. The interface is changed so that it can be called from KaTeX, not MathJax. + * 2. \rlap and \llap are replaced with \mathrlap and \mathllap. + * 3. Four lines of code are edited in order to use \raisebox instead of \raise. + * 4. The reaction arrow code is simplified. All reaction arrows are rendered + * using KaTeX extensible arrows instead of building non-extensible arrows. + * 5. \tripledash vertical alignment is slightly adjusted. + * + * This code, as other KaTeX code, is released under the MIT license. + * + * /************************************************************* + * + * MathJax/extensions/TeX/mhchem.js + * + * Implements the \ce command for handling chemical formulas + * from the mhchem LaTeX package. + * + * --------------------------------------------------------------------- + * + * Copyright (c) 2011-2015 The MathJax Consortium + * Copyright (c) 2015-2018 Martin Hensel + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// +// Coding Style +// - use '' for identifiers that can by minified/uglified +// - use "" for strings that need to stay untouched + +// version: "3.3.0" for MathJax and KaTeX + +// Add \ce, \pu, and \tripledash to the KaTeX macros. + +katex.__defineMacro("\\ce", function (context) { + return chemParse(context.consumeArgs(1)[0], "ce"); +}); +katex.__defineMacro("\\pu", function (context) { + return chemParse(context.consumeArgs(1)[0], "pu"); +}); + +// Needed for \bond for the ~ forms +// Raise by 2.56mu, not 2mu. We're raising a hyphen-minus, U+002D, not +// a mathematical minus, U+2212. So we need that extra 0.56. +katex.__defineMacro("\\tripledash", "{\\vphantom{-}\\raisebox{2.56mu}{$\\mkern2mu" + "\\tiny\\text{-}\\mkern1mu\\text{-}\\mkern1mu\\text{-}\\mkern2mu$}}"); + +// +// This is the main function for handing the \ce and \pu commands. +// It takes the argument to \ce or \pu and returns the corresponding TeX string. +// + +var chemParse = function chemParse(tokens, stateMachine) { + // Recreate the argument string from KaTeX's array of tokens. + var str = ""; + var expectedLoc = tokens.length && tokens[tokens.length - 1].loc.start; + for (var i = tokens.length - 1; i >= 0; i--) { + if (tokens[i].loc.start > expectedLoc) { + // context.consumeArgs has eaten a space. + str += " "; + expectedLoc = tokens[i].loc.start; + } + str += tokens[i].text; + expectedLoc += tokens[i].text.length; + } + var tex = texify.go(mhchemParser.go(str, stateMachine)); + return tex; +}; + +// +// Core parser for mhchem syntax (recursive) +// +/** @type {MhchemParser} */ +var mhchemParser = { + // + // Parses mchem \ce syntax + // + // Call like + // go("H2O"); + // + go: function go(input, stateMachine) { + if (!input) { + return []; + } + if (stateMachine === undefined) { + stateMachine = 'ce'; + } + var state = '0'; + + // + // String buffers for parsing: + // + // buffer.a == amount + // buffer.o == element + // buffer.b == left-side superscript + // buffer.p == left-side subscript + // buffer.q == right-side subscript + // buffer.d == right-side superscript + // + // buffer.r == arrow + // buffer.rdt == arrow, script above, type + // buffer.rd == arrow, script above, content + // buffer.rqt == arrow, script below, type + // buffer.rq == arrow, script below, content + // + // buffer.text_ + // buffer.rm + // etc. + // + // buffer.parenthesisLevel == int, starting at 0 + // buffer.sb == bool, space before + // buffer.beginsWithBond == bool + // + // These letters are also used as state names. + // + // Other states: + // 0 == begin of main part (arrow/operator unlikely) + // 1 == next entity + // 2 == next entity (arrow/operator unlikely) + // 3 == next atom + // c == macro + // + /** @type {Buffer} */ + var buffer = {}; + buffer['parenthesisLevel'] = 0; + input = input.replace(/\n/g, " "); + input = input.replace(/[\u2212\u2013\u2014\u2010]/g, "-"); + input = input.replace(/[\u2026]/g, "..."); + + // + // Looks through mhchemParser.transitions, to execute a matching action + // (recursive) + // + var lastInput; + var watchdog = 10; + /** @type {ParserOutput[]} */ + var output = []; + while (true) { + if (lastInput !== input) { + watchdog = 10; + lastInput = input; + } else { + watchdog--; + } + // + // Find actions in transition table + // + var machine = mhchemParser.stateMachines[stateMachine]; + var t = machine.transitions[state] || machine.transitions['*']; + iterateTransitions: for (var i = 0; i < t.length; i++) { + var matches = mhchemParser.patterns.match_(t[i].pattern, input); + if (matches) { + // + // Execute actions + // + var task = t[i].task; + for (var iA = 0; iA < task.action_.length; iA++) { + var o; + // + // Find and execute action + // + if (machine.actions[task.action_[iA].type_]) { + o = machine.actions[task.action_[iA].type_](buffer, matches.match_, task.action_[iA].option); + } else if (mhchemParser.actions[task.action_[iA].type_]) { + o = mhchemParser.actions[task.action_[iA].type_](buffer, matches.match_, task.action_[iA].option); + } else { + throw ["MhchemBugA", "mhchem bug A. Please report. (" + task.action_[iA].type_ + ")"]; // Trying to use non-existing action + } + // + // Add output + // + mhchemParser.concatArray(output, o); + } + // + // Set next state, + // Shorten input, + // Continue with next character + // (= apply only one transition per position) + // + state = task.nextState || state; + if (input.length > 0) { + if (!task.revisit) { + input = matches.remainder; + } + if (!task.toContinue) { + break iterateTransitions; + } + } else { + return output; + } + } + } + // + // Prevent infinite loop + // + if (watchdog <= 0) { + throw ["MhchemBugU", "mhchem bug U. Please report."]; // Unexpected character + } + } + }, + concatArray: function concatArray(a, b) { + if (b) { + if (Array.isArray(b)) { + for (var iB = 0; iB < b.length; iB++) { + a.push(b[iB]); + } + } else { + a.push(b); + } + } + }, + patterns: { + // + // Matching patterns + // either regexps or function that return null or {match_:"a", remainder:"bc"} + // + patterns: { + // property names must not look like integers ("2") for correct property traversal order, later on + 'empty': /^$/, + 'else': /^./, + 'else2': /^./, + 'space': /^\s/, + 'space A': /^\s(?=[A-Z\\$])/, + 'space$': /^\s$/, + 'a-z': /^[a-z]/, + 'x': /^x/, + 'x$': /^x$/, + 'i$': /^i$/, + 'letters': /^(?:[a-zA-Z\u03B1-\u03C9\u0391-\u03A9?@]|(?:\\(?:alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega|Gamma|Delta|Theta|Lambda|Xi|Pi|Sigma|Upsilon|Phi|Psi|Omega)(?:\s+|\{\}|(?![a-zA-Z]))))+/, + '\\greek': /^\\(?:alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega|Gamma|Delta|Theta|Lambda|Xi|Pi|Sigma|Upsilon|Phi|Psi|Omega)(?:\s+|\{\}|(?![a-zA-Z]))/, + 'one lowercase latin letter $': /^(?:([a-z])(?:$|[^a-zA-Z]))$/, + '$one lowercase latin letter$ $': /^\$(?:([a-z])(?:$|[^a-zA-Z]))\$$/, + 'one lowercase greek letter $': /^(?:\$?[\u03B1-\u03C9]\$?|\$?\\(?:alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega)\s*\$?)(?:\s+|\{\}|(?![a-zA-Z]))$/, + 'digits': /^[0-9]+/, + '-9.,9': /^[+\-]?(?:[0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+))/, + '-9.,9 no missing 0': /^[+\-]?[0-9]+(?:[.,][0-9]+)?/, + '(-)(9.,9)(e)(99)': function e99(input) { + var m = input.match(/^(\+\-|\+\/\-|\+|\-|\\pm\s?)?([0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+))?(\((?:[0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+))\))?(?:([eE]|\s*(\*|x|\\times|\u00D7)\s*10\^)([+\-]?[0-9]+|\{[+\-]?[0-9]+\}))?/); + if (m && m[0]) { + return { + match_: m.splice(1), + remainder: input.substr(m[0].length) + }; + } + return null; + }, + '(-)(9)^(-9)': function _(input) { + var m = input.match(/^(\+\-|\+\/\-|\+|\-|\\pm\s?)?([0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+)?)\^([+\-]?[0-9]+|\{[+\-]?[0-9]+\})/); + if (m && m[0]) { + return { + match_: m.splice(1), + remainder: input.substr(m[0].length) + }; + } + return null; + }, + 'state of aggregation $': function state_of_aggregation_$(input) { + // ... or crystal system + var a = mhchemParser.patterns.findObserveGroups(input, "", /^\([a-z]{1,3}(?=[\),])/, ")", ""); // (aq), (aq,$\infty$), (aq, sat) + if (a && a.remainder.match(/^($|[\s,;\)\]\}])/)) { + return a; + } // AND end of 'phrase' + var m = input.match(/^(?:\((?:\\ca\s?)?\$[amothc]\$\))/); // OR crystal system ($o$) (\ca$c$) + if (m) { + return { + match_: m[0], + remainder: input.substr(m[0].length) + }; + } + return null; + }, + '_{(state of aggregation)}$': /^_\{(\([a-z]{1,3}\))\}/, + '{[(': /^(?:\\\{|\[|\()/, + ')]}': /^(?:\)|\]|\\\})/, + ', ': /^[,;]\s*/, + ',': /^[,;]/, + '.': /^[.]/, + '. ': /^([.\u22C5\u00B7\u2022])\s*/, + '...': /^\.\.\.(?=$|[^.])/, + '* ': /^([*])\s*/, + '^{(...)}': function _(input) { + return mhchemParser.patterns.findObserveGroups(input, "^{", "", "", "}"); + }, + '^($...$)': function $$(input) { + return mhchemParser.patterns.findObserveGroups(input, "^", "$", "$", ""); + }, + '^a': /^\^([0-9]+|[^\\_])/, + '^\\x{}{}': function x(input) { + return mhchemParser.patterns.findObserveGroups(input, "^", /^\\[a-zA-Z]+\{/, "}", "", "", "{", "}", "", true); + }, + '^\\x{}': function x(input) { + return mhchemParser.patterns.findObserveGroups(input, "^", /^\\[a-zA-Z]+\{/, "}", ""); + }, + '^\\x': /^\^(\\[a-zA-Z]+)\s*/, + '^(-1)': /^\^(-?\d+)/, + '\'': /^'/, + '_{(...)}': function _(input) { + return mhchemParser.patterns.findObserveGroups(input, "_{", "", "", "}"); + }, + '_($...$)': function _$$(input) { + return mhchemParser.patterns.findObserveGroups(input, "_", "$", "$", ""); + }, + '_9': /^_([+\-]?[0-9]+|[^\\])/, + '_\\x{}{}': function _X(input) { + return mhchemParser.patterns.findObserveGroups(input, "_", /^\\[a-zA-Z]+\{/, "}", "", "", "{", "}", "", true); + }, + '_\\x{}': function _X(input) { + return mhchemParser.patterns.findObserveGroups(input, "_", /^\\[a-zA-Z]+\{/, "}", ""); + }, + '_\\x': /^_(\\[a-zA-Z]+)\s*/, + '^_': /^(?:\^(?=_)|\_(?=\^)|[\^_]$)/, + '{}': /^\{\}/, + '{...}': function _(input) { + return mhchemParser.patterns.findObserveGroups(input, "", "{", "}", ""); + }, + '{(...)}': function _(input) { + return mhchemParser.patterns.findObserveGroups(input, "{", "", "", "}"); + }, + '$...$': function $$(input) { + return mhchemParser.patterns.findObserveGroups(input, "", "$", "$", ""); + }, + '${(...)}$': function $$(input) { + return mhchemParser.patterns.findObserveGroups(input, "${", "", "", "}$"); + }, + '$(...)$': function $$(input) { + return mhchemParser.patterns.findObserveGroups(input, "$", "", "", "$"); + }, + '=<>': /^[=<>]/, + '#': /^[#\u2261]/, + '+': /^\+/, + '-$': /^-(?=[\s_},;\]/]|$|\([a-z]+\))/, + // -space -, -; -] -/ -$ -state-of-aggregation + '-9': /^-(?=[0-9])/, + '- orbital overlap': /^-(?=(?:[spd]|sp)(?:$|[\s,;\)\]\}]))/, + '-': /^-/, + 'pm-operator': /^(?:\\pm|\$\\pm\$|\+-|\+\/-)/, + 'operator': /^(?:\+|(?:[\-=<>]|<<|>>|\\approx|\$\\approx\$)(?=\s|$|-?[0-9]))/, + 'arrowUpDown': /^(?:v|\(v\)|\^|\(\^\))(?=$|[\s,;\)\]\}])/, + '\\bond{(...)}': function bond(input) { + return mhchemParser.patterns.findObserveGroups(input, "\\bond{", "", "", "}"); + }, + '->': /^(?:<->|<-->|->|<-|<=>>|<<=>|<=>|[\u2192\u27F6\u21CC])/, + 'CMT': /^[CMT](?=\[)/, + '[(...)]': function _(input) { + return mhchemParser.patterns.findObserveGroups(input, "[", "", "", "]"); + }, + '1st-level escape': /^(&|\\\\|\\hline)\s*/, + '\\,': /^(?:\\[,\ ;:])/, + // \\x - but output no space before + '\\x{}{}': function x(input) { + return mhchemParser.patterns.findObserveGroups(input, "", /^\\[a-zA-Z]+\{/, "}", "", "", "{", "}", "", true); + }, + '\\x{}': function x(input) { + return mhchemParser.patterns.findObserveGroups(input, "", /^\\[a-zA-Z]+\{/, "}", ""); + }, + '\\ca': /^\\ca(?:\s+|(?![a-zA-Z]))/, + '\\x': /^(?:\\[a-zA-Z]+\s*|\\[_&{}%])/, + 'orbital': /^(?:[0-9]{1,2}[spdfgh]|[0-9]{0,2}sp)(?=$|[^a-zA-Z])/, + // only those with numbers in front, because the others will be formatted correctly anyway + 'others': /^[\/~|]/, + '\\frac{(...)}': function frac(input) { + return mhchemParser.patterns.findObserveGroups(input, "\\frac{", "", "", "}", "{", "", "", "}"); + }, + '\\overset{(...)}': function overset(input) { + return mhchemParser.patterns.findObserveGroups(input, "\\overset{", "", "", "}", "{", "", "", "}"); + }, + '\\underset{(...)}': function underset(input) { + return mhchemParser.patterns.findObserveGroups(input, "\\underset{", "", "", "}", "{", "", "", "}"); + }, + '\\underbrace{(...)}': function underbrace(input) { + return mhchemParser.patterns.findObserveGroups(input, "\\underbrace{", "", "", "}_", "{", "", "", "}"); + }, + '\\color{(...)}0': function color0(input) { + return mhchemParser.patterns.findObserveGroups(input, "\\color{", "", "", "}"); + }, + '\\color{(...)}{(...)}1': function color1(input) { + return mhchemParser.patterns.findObserveGroups(input, "\\color{", "", "", "}", "{", "", "", "}"); + }, + '\\color(...){(...)}2': function color2(input) { + return mhchemParser.patterns.findObserveGroups(input, "\\color", "\\", "", /^(?=\{)/, "{", "", "", "}"); + }, + '\\ce{(...)}': function ce(input) { + return mhchemParser.patterns.findObserveGroups(input, "\\ce{", "", "", "}"); + }, + 'oxidation$': /^(?:[+-][IVX]+|\\pm\s*0|\$\\pm\$\s*0)$/, + 'd-oxidation$': /^(?:[+-]?\s?[IVX]+|\\pm\s*0|\$\\pm\$\s*0)$/, + // 0 could be oxidation or charge + 'roman numeral': /^[IVX]+/, + '1/2$': /^[+\-]?(?:[0-9]+|\$[a-z]\$|[a-z])\/[0-9]+(?:\$[a-z]\$|[a-z])?$/, + 'amount': function amount(input) { + var match; + // e.g. 2, 0.5, 1/2, -2, n/2, +; $a$ could be added later in parsing + match = input.match(/^(?:(?:(?:\([+\-]?[0-9]+\/[0-9]+\)|[+\-]?(?:[0-9]+|\$[a-z]\$|[a-z])\/[0-9]+|[+\-]?[0-9]+[.,][0-9]+|[+\-]?\.[0-9]+|[+\-]?[0-9]+)(?:[a-z](?=\s*[A-Z]))?)|[+\-]?[a-z](?=\s*[A-Z])|\+(?!\s))/); + if (match) { + return { + match_: match[0], + remainder: input.substr(match[0].length) + }; + } + var a = mhchemParser.patterns.findObserveGroups(input, "", "$", "$", ""); + if (a) { + // e.g. $2n-1$, $-$ + match = a.match_.match(/^\$(?:\(?[+\-]?(?:[0-9]*[a-z]?[+\-])?[0-9]*[a-z](?:[+\-][0-9]*[a-z]?)?\)?|\+|-)\$$/); + if (match) { + return { + match_: match[0], + remainder: input.substr(match[0].length) + }; + } + } + return null; + }, + 'amount2': function amount2(input) { + return this['amount'](input); + }, + '(KV letters),': /^(?:[A-Z][a-z]{0,2}|i)(?=,)/, + 'formula$': function formula$(input) { + if (input.match(/^\([a-z]+\)$/)) { + return null; + } // state of aggregation = no formula + var match = input.match(/^(?:[a-z]|(?:[0-9\ \+\-\,\.\(\)]+[a-z])+[0-9\ \+\-\,\.\(\)]*|(?:[a-z][0-9\ \+\-\,\.\(\)]+)+[a-z]?)$/); + if (match) { + return { + match_: match[0], + remainder: input.substr(match[0].length) + }; + } + return null; + }, + 'uprightEntities': /^(?:pH|pOH|pC|pK|iPr|iBu)(?=$|[^a-zA-Z])/, + '/': /^\s*(\/)\s*/, + '//': /^\s*(\/\/)\s*/, + '*': /^\s*[*.]\s*/ + }, + findObserveGroups: function findObserveGroups(input, begExcl, begIncl, endIncl, endExcl, beg2Excl, beg2Incl, end2Incl, end2Excl, combine) { + /** @type {{(input: string, pattern: string | RegExp): string | string[] | null;}} */ + var _match = function _match(input, pattern) { + if (typeof pattern === "string") { + if (input.indexOf(pattern) !== 0) { + return null; + } + return pattern; + } else { + var match = input.match(pattern); + if (!match) { + return null; + } + return match[0]; + } + }; + /** @type {{(input: string, i: number, endChars: string | RegExp): {endMatchBegin: number, endMatchEnd: number} | null;}} */ + var _findObserveGroups = function _findObserveGroups(input, i, endChars) { + var braces = 0; + while (i < input.length) { + var a = input.charAt(i); + var match = _match(input.substr(i), endChars); + if (match !== null && braces === 0) { + return { + endMatchBegin: i, + endMatchEnd: i + match.length + }; + } else if (a === "{") { + braces++; + } else if (a === "}") { + if (braces === 0) { + throw ["ExtraCloseMissingOpen", "Extra close brace or missing open brace"]; + } else { + braces--; + } + } + i++; + } + if (braces > 0) { + return null; + } + return null; + }; + var match = _match(input, begExcl); + if (match === null) { + return null; + } + input = input.substr(match.length); + match = _match(input, begIncl); + if (match === null) { + return null; + } + var e = _findObserveGroups(input, match.length, endIncl || endExcl); + if (e === null) { + return null; + } + var match1 = input.substring(0, endIncl ? e.endMatchEnd : e.endMatchBegin); + if (!(beg2Excl || beg2Incl)) { + return { + match_: match1, + remainder: input.substr(e.endMatchEnd) + }; + } else { + var group2 = this.findObserveGroups(input.substr(e.endMatchEnd), beg2Excl, beg2Incl, end2Incl, end2Excl); + if (group2 === null) { + return null; + } + /** @type {string[]} */ + var matchRet = [match1, group2.match_]; + return { + match_: combine ? matchRet.join("") : matchRet, + remainder: group2.remainder + }; + } + }, + // + // Matching function + // e.g. match("a", input) will look for the regexp called "a" and see if it matches + // returns null or {match_:"a", remainder:"bc"} + // + match_: function match_(m, input) { + var pattern = mhchemParser.patterns.patterns[m]; + if (pattern === undefined) { + throw ["MhchemBugP", "mhchem bug P. Please report. (" + m + ")"]; // Trying to use non-existing pattern + } else if (typeof pattern === "function") { + return mhchemParser.patterns.patterns[m](input); // cannot use cached var pattern here, because some pattern functions need this===mhchemParser + } else { + // RegExp + var match = input.match(pattern); + if (match) { + var mm; + if (match[2]) { + mm = [match[1], match[2]]; + } else if (match[1]) { + mm = match[1]; + } else { + mm = match[0]; + } + return { + match_: mm, + remainder: input.substr(match[0].length) + }; + } + return null; + } + } + }, + // + // Generic state machine actions + // + actions: { + 'a=': function a(buffer, m) { + buffer.a = (buffer.a || "") + m; + }, + 'b=': function b(buffer, m) { + buffer.b = (buffer.b || "") + m; + }, + 'p=': function p(buffer, m) { + buffer.p = (buffer.p || "") + m; + }, + 'o=': function o(buffer, m) { + buffer.o = (buffer.o || "") + m; + }, + 'q=': function q(buffer, m) { + buffer.q = (buffer.q || "") + m; + }, + 'd=': function d(buffer, m) { + buffer.d = (buffer.d || "") + m; + }, + 'rm=': function rm(buffer, m) { + buffer.rm = (buffer.rm || "") + m; + }, + 'text=': function text(buffer, m) { + buffer.text_ = (buffer.text_ || "") + m; + }, + 'insert': function insert(buffer, m, a) { + return { + type_: a + }; + }, + 'insert+p1': function insertP1(buffer, m, a) { + return { + type_: a, + p1: m + }; + }, + 'insert+p1+p2': function insertP1P2(buffer, m, a) { + return { + type_: a, + p1: m[0], + p2: m[1] + }; + }, + 'copy': function copy(buffer, m) { + return m; + }, + 'rm': function rm(buffer, m) { + return { + type_: 'rm', + p1: m || "" + }; + }, + 'text': function text(buffer, m) { + return mhchemParser.go(m, 'text'); + }, + '{text}': function text(buffer, m) { + var ret = ["{"]; + mhchemParser.concatArray(ret, mhchemParser.go(m, 'text')); + ret.push("}"); + return ret; + }, + 'tex-math': function texMath(buffer, m) { + return mhchemParser.go(m, 'tex-math'); + }, + 'tex-math tight': function texMath_tight(buffer, m) { + return mhchemParser.go(m, 'tex-math tight'); + }, + 'bond': function bond(buffer, m, k) { + return { + type_: 'bond', + kind_: k || m + }; + }, + 'color0-output': function color0Output(buffer, m) { + return { + type_: 'color0', + color: m[0] + }; + }, + 'ce': function ce(buffer, m) { + return mhchemParser.go(m); + }, + '1/2': function _2(buffer, m) { + /** @type {ParserOutput[]} */ + var ret = []; + if (m.match(/^[+\-]/)) { + ret.push(m.substr(0, 1)); + m = m.substr(1); + } + var n = m.match(/^([0-9]+|\$[a-z]\$|[a-z])\/([0-9]+)(\$[a-z]\$|[a-z])?$/); + n[1] = n[1].replace(/\$/g, ""); + ret.push({ + type_: 'frac', + p1: n[1], + p2: n[2] + }); + if (n[3]) { + n[3] = n[3].replace(/\$/g, ""); + ret.push({ + type_: 'tex-math', + p1: n[3] + }); + } + return ret; + }, + '9,9': function _(buffer, m) { + return mhchemParser.go(m, '9,9'); + } + }, + // + // createTransitions + // convert { 'letter': { 'state': { action_: 'output' } } } to { 'state' => [ { pattern: 'letter', task: { action_: [{type_: 'output'}] } } ] } + // with expansion of 'a|b' to 'a' and 'b' (at 2 places) + // + createTransitions: function createTransitions(o) { + var pattern, state; + /** @type {string[]} */ + var stateArray; + var i; + // + // 1. Collect all states + // + /** @type {Transitions} */ + var transitions = {}; + for (pattern in o) { + for (state in o[pattern]) { + stateArray = state.split("|"); + o[pattern][state].stateArray = stateArray; + for (i = 0; i < stateArray.length; i++) { + transitions[stateArray[i]] = []; + } + } + } + // + // 2. Fill states + // + for (pattern in o) { + for (state in o[pattern]) { + stateArray = o[pattern][state].stateArray || []; + for (i = 0; i < stateArray.length; i++) { + // + // 2a. Normalize actions into array: 'text=' ==> [{type_:'text='}] + // (Note to myself: Resolving the function here would be problematic. It would need .bind (for *this*) and currying (for *option*).) + // + /** @type {any} */ + var p = o[pattern][state]; + if (p.action_) { + p.action_ = [].concat(p.action_); + for (var k = 0; k < p.action_.length; k++) { + if (typeof p.action_[k] === "string") { + p.action_[k] = { + type_: p.action_[k] + }; + } + } + } else { + p.action_ = []; + } + // + // 2.b Multi-insert + // + var patternArray = pattern.split("|"); + for (var j = 0; j < patternArray.length; j++) { + if (stateArray[i] === '*') { + // insert into all + for (var t in transitions) { + transitions[t].push({ + pattern: patternArray[j], + task: p + }); + } + } else { + transitions[stateArray[i]].push({ + pattern: patternArray[j], + task: p + }); + } + } + } + } + } + return transitions; + }, + stateMachines: {} +}; + +// +// Definition of state machines +// +mhchemParser.stateMachines = { + // + // \ce state machines + // + //#region ce + 'ce': { + // main parser + transitions: mhchemParser.createTransitions({ + 'empty': { + '*': { + action_: 'output' + } + }, + 'else': { + '0|1|2': { + action_: 'beginsWithBond=false', + revisit: true, + toContinue: true + } + }, + 'oxidation$': { + '0': { + action_: 'oxidation-output' + } + }, + 'CMT': { + 'r': { + action_: 'rdt=', + nextState: 'rt' + }, + 'rd': { + action_: 'rqt=', + nextState: 'rdt' + } + }, + 'arrowUpDown': { + '0|1|2|as': { + action_: ['sb=false', 'output', 'operator'], + nextState: '1' + } + }, + 'uprightEntities': { + '0|1|2': { + action_: ['o=', 'output'], + nextState: '1' + } + }, + 'orbital': { + '0|1|2|3': { + action_: 'o=', + nextState: 'o' + } + }, + '->': { + '0|1|2|3': { + action_: 'r=', + nextState: 'r' + }, + 'a|as': { + action_: ['output', 'r='], + nextState: 'r' + }, + '*': { + action_: ['output', 'r='], + nextState: 'r' + } + }, + '+': { + 'o': { + action_: 'd= kv', + nextState: 'd' + }, + 'd|D': { + action_: 'd=', + nextState: 'd' + }, + 'q': { + action_: 'd=', + nextState: 'qd' + }, + 'qd|qD': { + action_: 'd=', + nextState: 'qd' + }, + 'dq': { + action_: ['output', 'd='], + nextState: 'd' + }, + '3': { + action_: ['sb=false', 'output', 'operator'], + nextState: '0' + } + }, + 'amount': { + '0|2': { + action_: 'a=', + nextState: 'a' + } + }, + 'pm-operator': { + '0|1|2|a|as': { + action_: ['sb=false', 'output', { + type_: 'operator', + option: '\\pm' + }], + nextState: '0' + } + }, + 'operator': { + '0|1|2|a|as': { + action_: ['sb=false', 'output', 'operator'], + nextState: '0' + } + }, + '-$': { + 'o|q': { + action_: ['charge or bond', 'output'], + nextState: 'qd' + }, + 'd': { + action_: 'd=', + nextState: 'd' + }, + 'D': { + action_: ['output', { + type_: 'bond', + option: "-" + }], + nextState: '3' + }, + 'q': { + action_: 'd=', + nextState: 'qd' + }, + 'qd': { + action_: 'd=', + nextState: 'qd' + }, + 'qD|dq': { + action_: ['output', { + type_: 'bond', + option: "-" + }], + nextState: '3' + } + }, + '-9': { + '3|o': { + action_: ['output', { + type_: 'insert', + option: 'hyphen' + }], + nextState: '3' + } + }, + '- orbital overlap': { + 'o': { + action_: ['output', { + type_: 'insert', + option: 'hyphen' + }], + nextState: '2' + }, + 'd': { + action_: ['output', { + type_: 'insert', + option: 'hyphen' + }], + nextState: '2' + } + }, + '-': { + '0|1|2': { + action_: [{ + type_: 'output', + option: 1 + }, 'beginsWithBond=true', { + type_: 'bond', + option: "-" + }], + nextState: '3' + }, + '3': { + action_: { + type_: 'bond', + option: "-" + } + }, + 'a': { + action_: ['output', { + type_: 'insert', + option: 'hyphen' + }], + nextState: '2' + }, + 'as': { + action_: [{ + type_: 'output', + option: 2 + }, { + type_: 'bond', + option: "-" + }], + nextState: '3' + }, + 'b': { + action_: 'b=' + }, + 'o': { + action_: { + type_: '- after o/d', + option: false + }, + nextState: '2' + }, + 'q': { + action_: { + type_: '- after o/d', + option: false + }, + nextState: '2' + }, + 'd|qd|dq': { + action_: { + type_: '- after o/d', + option: true + }, + nextState: '2' + }, + 'D|qD|p': { + action_: ['output', { + type_: 'bond', + option: "-" + }], + nextState: '3' + } + }, + 'amount2': { + '1|3': { + action_: 'a=', + nextState: 'a' + } + }, + 'letters': { + '0|1|2|3|a|as|b|p|bp|o': { + action_: 'o=', + nextState: 'o' + }, + 'q|dq': { + action_: ['output', 'o='], + nextState: 'o' + }, + 'd|D|qd|qD': { + action_: 'o after d', + nextState: 'o' + } + }, + 'digits': { + 'o': { + action_: 'q=', + nextState: 'q' + }, + 'd|D': { + action_: 'q=', + nextState: 'dq' + }, + 'q': { + action_: ['output', 'o='], + nextState: 'o' + }, + 'a': { + action_: 'o=', + nextState: 'o' + } + }, + 'space A': { + 'b|p|bp': {} + }, + 'space': { + 'a': { + nextState: 'as' + }, + '0': { + action_: 'sb=false' + }, + '1|2': { + action_: 'sb=true' + }, + 'r|rt|rd|rdt|rdq': { + action_: 'output', + nextState: '0' + }, + '*': { + action_: ['output', 'sb=true'], + nextState: '1' + } + }, + '1st-level escape': { + '1|2': { + action_: ['output', { + type_: 'insert+p1', + option: '1st-level escape' + }] + }, + '*': { + action_: ['output', { + type_: 'insert+p1', + option: '1st-level escape' + }], + nextState: '0' + } + }, + '[(...)]': { + 'r|rt': { + action_: 'rd=', + nextState: 'rd' + }, + 'rd|rdt': { + action_: 'rq=', + nextState: 'rdq' + } + }, + '...': { + 'o|d|D|dq|qd|qD': { + action_: ['output', { + type_: 'bond', + option: "..." + }], + nextState: '3' + }, + '*': { + action_: [{ + type_: 'output', + option: 1 + }, { + type_: 'insert', + option: 'ellipsis' + }], + nextState: '1' + } + }, + '. |* ': { + '*': { + action_: ['output', { + type_: 'insert', + option: 'addition compound' + }], + nextState: '1' + } + }, + 'state of aggregation $': { + '*': { + action_: ['output', 'state of aggregation'], + nextState: '1' + } + }, + '{[(': { + 'a|as|o': { + action_: ['o=', 'output', 'parenthesisLevel++'], + nextState: '2' + }, + '0|1|2|3': { + action_: ['o=', 'output', 'parenthesisLevel++'], + nextState: '2' + }, + '*': { + action_: ['output', 'o=', 'output', 'parenthesisLevel++'], + nextState: '2' + } + }, + ')]}': { + '0|1|2|3|b|p|bp|o': { + action_: ['o=', 'parenthesisLevel--'], + nextState: 'o' + }, + 'a|as|d|D|q|qd|qD|dq': { + action_: ['output', 'o=', 'parenthesisLevel--'], + nextState: 'o' + } + }, + ', ': { + '*': { + action_: ['output', 'comma'], + nextState: '0' + } + }, + '^_': { + // ^ and _ without a sensible argument + '*': {} + }, + '^{(...)}|^($...$)': { + '0|1|2|as': { + action_: 'b=', + nextState: 'b' + }, + 'p': { + action_: 'b=', + nextState: 'bp' + }, + '3|o': { + action_: 'd= kv', + nextState: 'D' + }, + 'q': { + action_: 'd=', + nextState: 'qD' + }, + 'd|D|qd|qD|dq': { + action_: ['output', 'd='], + nextState: 'D' + } + }, + '^a|^\\x{}{}|^\\x{}|^\\x|\'': { + '0|1|2|as': { + action_: 'b=', + nextState: 'b' + }, + 'p': { + action_: 'b=', + nextState: 'bp' + }, + '3|o': { + action_: 'd= kv', + nextState: 'd' + }, + 'q': { + action_: 'd=', + nextState: 'qd' + }, + 'd|qd|D|qD': { + action_: 'd=' + }, + 'dq': { + action_: ['output', 'd='], + nextState: 'd' + } + }, + '_{(state of aggregation)}$': { + 'd|D|q|qd|qD|dq': { + action_: ['output', 'q='], + nextState: 'q' + } + }, + '_{(...)}|_($...$)|_9|_\\x{}{}|_\\x{}|_\\x': { + '0|1|2|as': { + action_: 'p=', + nextState: 'p' + }, + 'b': { + action_: 'p=', + nextState: 'bp' + }, + '3|o': { + action_: 'q=', + nextState: 'q' + }, + 'd|D': { + action_: 'q=', + nextState: 'dq' + }, + 'q|qd|qD|dq': { + action_: ['output', 'q='], + nextState: 'q' + } + }, + '=<>': { + '0|1|2|3|a|as|o|q|d|D|qd|qD|dq': { + action_: [{ + type_: 'output', + option: 2 + }, 'bond'], + nextState: '3' + } + }, + '#': { + '0|1|2|3|a|as|o': { + action_: [{ + type_: 'output', + option: 2 + }, { + type_: 'bond', + option: "#" + }], + nextState: '3' + } + }, + '{}': { + '*': { + action_: { + type_: 'output', + option: 1 + }, + nextState: '1' + } + }, + '{...}': { + '0|1|2|3|a|as|b|p|bp': { + action_: 'o=', + nextState: 'o' + }, + 'o|d|D|q|qd|qD|dq': { + action_: ['output', 'o='], + nextState: 'o' + } + }, + '$...$': { + 'a': { + action_: 'a=' + }, + // 2$n$ + '0|1|2|3|as|b|p|bp|o': { + action_: 'o=', + nextState: 'o' + }, + // not 'amount' + 'as|o': { + action_: 'o=' + }, + 'q|d|D|qd|qD|dq': { + action_: ['output', 'o='], + nextState: 'o' + } + }, + '\\bond{(...)}': { + '*': { + action_: [{ + type_: 'output', + option: 2 + }, 'bond'], + nextState: "3" + } + }, + '\\frac{(...)}': { + '*': { + action_: [{ + type_: 'output', + option: 1 + }, 'frac-output'], + nextState: '3' + } + }, + '\\overset{(...)}': { + '*': { + action_: [{ + type_: 'output', + option: 2 + }, 'overset-output'], + nextState: '3' + } + }, + '\\underset{(...)}': { + '*': { + action_: [{ + type_: 'output', + option: 2 + }, 'underset-output'], + nextState: '3' + } + }, + '\\underbrace{(...)}': { + '*': { + action_: [{ + type_: 'output', + option: 2 + }, 'underbrace-output'], + nextState: '3' + } + }, + '\\color{(...)}{(...)}1|\\color(...){(...)}2': { + '*': { + action_: [{ + type_: 'output', + option: 2 + }, 'color-output'], + nextState: '3' + } + }, + '\\color{(...)}0': { + '*': { + action_: [{ + type_: 'output', + option: 2 + }, 'color0-output'] + } + }, + '\\ce{(...)}': { + '*': { + action_: [{ + type_: 'output', + option: 2 + }, 'ce'], + nextState: '3' + } + }, + '\\,': { + '*': { + action_: [{ + type_: 'output', + option: 1 + }, 'copy'], + nextState: '1' + } + }, + '\\x{}{}|\\x{}|\\x': { + '0|1|2|3|a|as|b|p|bp|o|c0': { + action_: ['o=', 'output'], + nextState: '3' + }, + '*': { + action_: ['output', 'o=', 'output'], + nextState: '3' + } + }, + 'others': { + '*': { + action_: [{ + type_: 'output', + option: 1 + }, 'copy'], + nextState: '3' + } + }, + 'else2': { + 'a': { + action_: 'a to o', + nextState: 'o', + revisit: true + }, + 'as': { + action_: ['output', 'sb=true'], + nextState: '1', + revisit: true + }, + 'r|rt|rd|rdt|rdq': { + action_: ['output'], + nextState: '0', + revisit: true + }, + '*': { + action_: ['output', 'copy'], + nextState: '3' + } + } + }), + actions: { + 'o after d': function o_after_d(buffer, m) { + var ret; + if ((buffer.d || "").match(/^[0-9]+$/)) { + var tmp = buffer.d; + buffer.d = undefined; + ret = this['output'](buffer); + buffer.b = tmp; + } else { + ret = this['output'](buffer); + } + mhchemParser.actions['o='](buffer, m); + return ret; + }, + 'd= kv': function d_kv(buffer, m) { + buffer.d = m; + buffer.dType = 'kv'; + }, + 'charge or bond': function charge_or_bond(buffer, m) { + if (buffer['beginsWithBond']) { + /** @type {ParserOutput[]} */ + var ret = []; + mhchemParser.concatArray(ret, this['output'](buffer)); + mhchemParser.concatArray(ret, mhchemParser.actions['bond'](buffer, m, "-")); + return ret; + } else { + buffer.d = m; + } + }, + '- after o/d': function _after_o_d(buffer, m, isAfterD) { + var c1 = mhchemParser.patterns.match_('orbital', buffer.o || ""); + var c2 = mhchemParser.patterns.match_('one lowercase greek letter $', buffer.o || ""); + var c3 = mhchemParser.patterns.match_('one lowercase latin letter $', buffer.o || ""); + var c4 = mhchemParser.patterns.match_('$one lowercase latin letter$ $', buffer.o || ""); + var hyphenFollows = m === "-" && (c1 && c1.remainder === "" || c2 || c3 || c4); + if (hyphenFollows && !buffer.a && !buffer.b && !buffer.p && !buffer.d && !buffer.q && !c1 && c3) { + buffer.o = '$' + buffer.o + '$'; + } + /** @type {ParserOutput[]} */ + var ret = []; + if (hyphenFollows) { + mhchemParser.concatArray(ret, this['output'](buffer)); + ret.push({ + type_: 'hyphen' + }); + } else { + c1 = mhchemParser.patterns.match_('digits', buffer.d || ""); + if (isAfterD && c1 && c1.remainder === '') { + mhchemParser.concatArray(ret, mhchemParser.actions['d='](buffer, m)); + mhchemParser.concatArray(ret, this['output'](buffer)); + } else { + mhchemParser.concatArray(ret, this['output'](buffer)); + mhchemParser.concatArray(ret, mhchemParser.actions['bond'](buffer, m, "-")); + } + } + return ret; + }, + 'a to o': function a_to_o(buffer) { + buffer.o = buffer.a; + buffer.a = undefined; + }, + 'sb=true': function sbTrue(buffer) { + buffer.sb = true; + }, + 'sb=false': function sbFalse(buffer) { + buffer.sb = false; + }, + 'beginsWithBond=true': function beginsWithBondTrue(buffer) { + buffer['beginsWithBond'] = true; + }, + 'beginsWithBond=false': function beginsWithBondFalse(buffer) { + buffer['beginsWithBond'] = false; + }, + 'parenthesisLevel++': function parenthesisLevel(buffer) { + buffer['parenthesisLevel']++; + }, + 'parenthesisLevel--': function parenthesisLevel(buffer) { + buffer['parenthesisLevel']--; + }, + 'state of aggregation': function state_of_aggregation(buffer, m) { + return { + type_: 'state of aggregation', + p1: mhchemParser.go(m, 'o') + }; + }, + 'comma': function comma(buffer, m) { + var a = m.replace(/\s*$/, ''); + var withSpace = a !== m; + if (withSpace && buffer['parenthesisLevel'] === 0) { + return { + type_: 'comma enumeration L', + p1: a + }; + } else { + return { + type_: 'comma enumeration M', + p1: a + }; + } + }, + 'output': function output(buffer, m, entityFollows) { + // entityFollows: + // undefined = if we have nothing else to output, also ignore the just read space (buffer.sb) + // 1 = an entity follows, never omit the space if there was one just read before (can only apply to state 1) + // 2 = 1 + the entity can have an amount, so output a\, instead of converting it to o (can only apply to states a|as) + /** @type {ParserOutput | ParserOutput[]} */ + var ret; + if (!buffer.r) { + ret = []; + if (!buffer.a && !buffer.b && !buffer.p && !buffer.o && !buffer.q && !buffer.d && !entityFollows) ; else { + if (buffer.sb) { + ret.push({ + type_: 'entitySkip' + }); + } + if (!buffer.o && !buffer.q && !buffer.d && !buffer.b && !buffer.p && entityFollows !== 2) { + buffer.o = buffer.a; + buffer.a = undefined; + } else if (!buffer.o && !buffer.q && !buffer.d && (buffer.b || buffer.p)) { + buffer.o = buffer.a; + buffer.d = buffer.b; + buffer.q = buffer.p; + buffer.a = buffer.b = buffer.p = undefined; + } else { + if (buffer.o && buffer.dType === 'kv' && mhchemParser.patterns.match_('d-oxidation$', buffer.d || "")) { + buffer.dType = 'oxidation'; + } else if (buffer.o && buffer.dType === 'kv' && !buffer.q) { + buffer.dType = undefined; + } + } + ret.push({ + type_: 'chemfive', + a: mhchemParser.go(buffer.a, 'a'), + b: mhchemParser.go(buffer.b, 'bd'), + p: mhchemParser.go(buffer.p, 'pq'), + o: mhchemParser.go(buffer.o, 'o'), + q: mhchemParser.go(buffer.q, 'pq'), + d: mhchemParser.go(buffer.d, buffer.dType === 'oxidation' ? 'oxidation' : 'bd'), + dType: buffer.dType + }); + } + } else { + // r + /** @type {ParserOutput[]} */ + var rd; + if (buffer.rdt === 'M') { + rd = mhchemParser.go(buffer.rd, 'tex-math'); + } else if (buffer.rdt === 'T') { + rd = [{ + type_: 'text', + p1: buffer.rd || "" + }]; + } else { + rd = mhchemParser.go(buffer.rd); + } + /** @type {ParserOutput[]} */ + var rq; + if (buffer.rqt === 'M') { + rq = mhchemParser.go(buffer.rq, 'tex-math'); + } else if (buffer.rqt === 'T') { + rq = [{ + type_: 'text', + p1: buffer.rq || "" + }]; + } else { + rq = mhchemParser.go(buffer.rq); + } + ret = { + type_: 'arrow', + r: buffer.r, + rd: rd, + rq: rq + }; + } + for (var p in buffer) { + if (p !== 'parenthesisLevel' && p !== 'beginsWithBond') { + delete buffer[p]; + } + } + return ret; + }, + 'oxidation-output': function oxidationOutput(buffer, m) { + var ret = ["{"]; + mhchemParser.concatArray(ret, mhchemParser.go(m, 'oxidation')); + ret.push("}"); + return ret; + }, + 'frac-output': function fracOutput(buffer, m) { + return { + type_: 'frac-ce', + p1: mhchemParser.go(m[0]), + p2: mhchemParser.go(m[1]) + }; + }, + 'overset-output': function oversetOutput(buffer, m) { + return { + type_: 'overset', + p1: mhchemParser.go(m[0]), + p2: mhchemParser.go(m[1]) + }; + }, + 'underset-output': function undersetOutput(buffer, m) { + return { + type_: 'underset', + p1: mhchemParser.go(m[0]), + p2: mhchemParser.go(m[1]) + }; + }, + 'underbrace-output': function underbraceOutput(buffer, m) { + return { + type_: 'underbrace', + p1: mhchemParser.go(m[0]), + p2: mhchemParser.go(m[1]) + }; + }, + 'color-output': function colorOutput(buffer, m) { + return { + type_: 'color', + color1: m[0], + color2: mhchemParser.go(m[1]) + }; + }, + 'r=': function r(buffer, m) { + buffer.r = m; + }, + 'rdt=': function rdt(buffer, m) { + buffer.rdt = m; + }, + 'rd=': function rd(buffer, m) { + buffer.rd = m; + }, + 'rqt=': function rqt(buffer, m) { + buffer.rqt = m; + }, + 'rq=': function rq(buffer, m) { + buffer.rq = m; + }, + 'operator': function operator(buffer, m, p1) { + return { + type_: 'operator', + kind_: p1 || m + }; + } + } + }, + 'a': { + transitions: mhchemParser.createTransitions({ + 'empty': { + '*': {} + }, + '1/2$': { + '0': { + action_: '1/2' + } + }, + 'else': { + '0': { + nextState: '1', + revisit: true + } + }, + '$(...)$': { + '*': { + action_: 'tex-math tight', + nextState: '1' + } + }, + ',': { + '*': { + action_: { + type_: 'insert', + option: 'commaDecimal' + } + } + }, + 'else2': { + '*': { + action_: 'copy' + } + } + }), + actions: {} + }, + 'o': { + transitions: mhchemParser.createTransitions({ + 'empty': { + '*': {} + }, + '1/2$': { + '0': { + action_: '1/2' + } + }, + 'else': { + '0': { + nextState: '1', + revisit: true + } + }, + 'letters': { + '*': { + action_: 'rm' + } + }, + '\\ca': { + '*': { + action_: { + type_: 'insert', + option: 'circa' + } + } + }, + '\\x{}{}|\\x{}|\\x': { + '*': { + action_: 'copy' + } + }, + '${(...)}$|$(...)$': { + '*': { + action_: 'tex-math' + } + }, + '{(...)}': { + '*': { + action_: '{text}' + } + }, + 'else2': { + '*': { + action_: 'copy' + } + } + }), + actions: {} + }, + 'text': { + transitions: mhchemParser.createTransitions({ + 'empty': { + '*': { + action_: 'output' + } + }, + '{...}': { + '*': { + action_: 'text=' + } + }, + '${(...)}$|$(...)$': { + '*': { + action_: 'tex-math' + } + }, + '\\greek': { + '*': { + action_: ['output', 'rm'] + } + }, + '\\,|\\x{}{}|\\x{}|\\x': { + '*': { + action_: ['output', 'copy'] + } + }, + 'else': { + '*': { + action_: 'text=' + } + } + }), + actions: { + 'output': function output(buffer) { + if (buffer.text_) { + /** @type {ParserOutput} */ + var ret = { + type_: 'text', + p1: buffer.text_ + }; + for (var p in buffer) { + delete buffer[p]; + } + return ret; + } + } + } + }, + 'pq': { + transitions: mhchemParser.createTransitions({ + 'empty': { + '*': {} + }, + 'state of aggregation $': { + '*': { + action_: 'state of aggregation' + } + }, + 'i$': { + '0': { + nextState: '!f', + revisit: true + } + }, + '(KV letters),': { + '0': { + action_: 'rm', + nextState: '0' + } + }, + 'formula$': { + '0': { + nextState: 'f', + revisit: true + } + }, + '1/2$': { + '0': { + action_: '1/2' + } + }, + 'else': { + '0': { + nextState: '!f', + revisit: true + } + }, + '${(...)}$|$(...)$': { + '*': { + action_: 'tex-math' + } + }, + '{(...)}': { + '*': { + action_: 'text' + } + }, + 'a-z': { + 'f': { + action_: 'tex-math' + } + }, + 'letters': { + '*': { + action_: 'rm' + } + }, + '-9.,9': { + '*': { + action_: '9,9' + } + }, + ',': { + '*': { + action_: { + type_: 'insert+p1', + option: 'comma enumeration S' + } + } + }, + '\\color{(...)}{(...)}1|\\color(...){(...)}2': { + '*': { + action_: 'color-output' + } + }, + '\\color{(...)}0': { + '*': { + action_: 'color0-output' + } + }, + '\\ce{(...)}': { + '*': { + action_: 'ce' + } + }, + '\\,|\\x{}{}|\\x{}|\\x': { + '*': { + action_: 'copy' + } + }, + 'else2': { + '*': { + action_: 'copy' + } + } + }), + actions: { + 'state of aggregation': function state_of_aggregation(buffer, m) { + return { + type_: 'state of aggregation subscript', + p1: mhchemParser.go(m, 'o') + }; + }, + 'color-output': function colorOutput(buffer, m) { + return { + type_: 'color', + color1: m[0], + color2: mhchemParser.go(m[1], 'pq') + }; + } + } + }, + 'bd': { + transitions: mhchemParser.createTransitions({ + 'empty': { + '*': {} + }, + 'x$': { + '0': { + nextState: '!f', + revisit: true + } + }, + 'formula$': { + '0': { + nextState: 'f', + revisit: true + } + }, + 'else': { + '0': { + nextState: '!f', + revisit: true + } + }, + '-9.,9 no missing 0': { + '*': { + action_: '9,9' + } + }, + '.': { + '*': { + action_: { + type_: 'insert', + option: 'electron dot' + } + } + }, + 'a-z': { + 'f': { + action_: 'tex-math' + } + }, + 'x': { + '*': { + action_: { + type_: 'insert', + option: 'KV x' + } + } + }, + 'letters': { + '*': { + action_: 'rm' + } + }, + '\'': { + '*': { + action_: { + type_: 'insert', + option: 'prime' + } + } + }, + '${(...)}$|$(...)$': { + '*': { + action_: 'tex-math' + } + }, + '{(...)}': { + '*': { + action_: 'text' + } + }, + '\\color{(...)}{(...)}1|\\color(...){(...)}2': { + '*': { + action_: 'color-output' + } + }, + '\\color{(...)}0': { + '*': { + action_: 'color0-output' + } + }, + '\\ce{(...)}': { + '*': { + action_: 'ce' + } + }, + '\\,|\\x{}{}|\\x{}|\\x': { + '*': { + action_: 'copy' + } + }, + 'else2': { + '*': { + action_: 'copy' + } + } + }), + actions: { + 'color-output': function colorOutput(buffer, m) { + return { + type_: 'color', + color1: m[0], + color2: mhchemParser.go(m[1], 'bd') + }; + } + } + }, + 'oxidation': { + transitions: mhchemParser.createTransitions({ + 'empty': { + '*': {} + }, + 'roman numeral': { + '*': { + action_: 'roman-numeral' + } + }, + '${(...)}$|$(...)$': { + '*': { + action_: 'tex-math' + } + }, + 'else': { + '*': { + action_: 'copy' + } + } + }), + actions: { + 'roman-numeral': function romanNumeral(buffer, m) { + return { + type_: 'roman numeral', + p1: m || "" + }; + } + } + }, + 'tex-math': { + transitions: mhchemParser.createTransitions({ + 'empty': { + '*': { + action_: 'output' + } + }, + '\\ce{(...)}': { + '*': { + action_: ['output', 'ce'] + } + }, + '{...}|\\,|\\x{}{}|\\x{}|\\x': { + '*': { + action_: 'o=' + } + }, + 'else': { + '*': { + action_: 'o=' + } + } + }), + actions: { + 'output': function output(buffer) { + if (buffer.o) { + /** @type {ParserOutput} */ + var ret = { + type_: 'tex-math', + p1: buffer.o + }; + for (var p in buffer) { + delete buffer[p]; + } + return ret; + } + } + } + }, + 'tex-math tight': { + transitions: mhchemParser.createTransitions({ + 'empty': { + '*': { + action_: 'output' + } + }, + '\\ce{(...)}': { + '*': { + action_: ['output', 'ce'] + } + }, + '{...}|\\,|\\x{}{}|\\x{}|\\x': { + '*': { + action_: 'o=' + } + }, + '-|+': { + '*': { + action_: 'tight operator' + } + }, + 'else': { + '*': { + action_: 'o=' + } + } + }), + actions: { + 'tight operator': function tight_operator(buffer, m) { + buffer.o = (buffer.o || "") + "{" + m + "}"; + }, + 'output': function output(buffer) { + if (buffer.o) { + /** @type {ParserOutput} */ + var ret = { + type_: 'tex-math', + p1: buffer.o + }; + for (var p in buffer) { + delete buffer[p]; + } + return ret; + } + } + } + }, + '9,9': { + transitions: mhchemParser.createTransitions({ + 'empty': { + '*': {} + }, + ',': { + '*': { + action_: 'comma' + } + }, + 'else': { + '*': { + action_: 'copy' + } + } + }), + actions: { + 'comma': function comma() { + return { + type_: 'commaDecimal' + }; + } + } + }, + //#endregion + // + // \pu state machines + // + //#region pu + 'pu': { + transitions: mhchemParser.createTransitions({ + 'empty': { + '*': { + action_: 'output' + } + }, + 'space$': { + '*': { + action_: ['output', 'space'] + } + }, + '{[(|)]}': { + '0|a': { + action_: 'copy' + } + }, + '(-)(9)^(-9)': { + '0': { + action_: 'number^', + nextState: 'a' + } + }, + '(-)(9.,9)(e)(99)': { + '0': { + action_: 'enumber', + nextState: 'a' + } + }, + 'space': { + '0|a': {} + }, + 'pm-operator': { + '0|a': { + action_: { + type_: 'operator', + option: '\\pm' + }, + nextState: '0' + } + }, + 'operator': { + '0|a': { + action_: 'copy', + nextState: '0' + } + }, + '//': { + 'd': { + action_: 'o=', + nextState: '/' + } + }, + '/': { + 'd': { + action_: 'o=', + nextState: '/' + } + }, + '{...}|else': { + '0|d': { + action_: 'd=', + nextState: 'd' + }, + 'a': { + action_: ['space', 'd='], + nextState: 'd' + }, + '/|q': { + action_: 'q=', + nextState: 'q' + } + } + }), + actions: { + 'enumber': function enumber(buffer, m) { + /** @type {ParserOutput[]} */ + var ret = []; + if (m[0] === "+-" || m[0] === "+/-") { + ret.push("\\pm "); + } else if (m[0]) { + ret.push(m[0]); + } + if (m[1]) { + mhchemParser.concatArray(ret, mhchemParser.go(m[1], 'pu-9,9')); + if (m[2]) { + if (m[2].match(/[,.]/)) { + mhchemParser.concatArray(ret, mhchemParser.go(m[2], 'pu-9,9')); + } else { + ret.push(m[2]); + } + } + m[3] = m[4] || m[3]; + if (m[3]) { + m[3] = m[3].trim(); + if (m[3] === "e" || m[3].substr(0, 1) === "*") { + ret.push({ + type_: 'cdot' + }); + } else { + ret.push({ + type_: 'times' + }); + } + } + } + if (m[3]) { + ret.push("10^{" + m[5] + "}"); + } + return ret; + }, + 'number^': function number(buffer, m) { + /** @type {ParserOutput[]} */ + var ret = []; + if (m[0] === "+-" || m[0] === "+/-") { + ret.push("\\pm "); + } else if (m[0]) { + ret.push(m[0]); + } + mhchemParser.concatArray(ret, mhchemParser.go(m[1], 'pu-9,9')); + ret.push("^{" + m[2] + "}"); + return ret; + }, + 'operator': function operator(buffer, m, p1) { + return { + type_: 'operator', + kind_: p1 || m + }; + }, + 'space': function space() { + return { + type_: 'pu-space-1' + }; + }, + 'output': function output(buffer) { + /** @type {ParserOutput | ParserOutput[]} */ + var ret; + var md = mhchemParser.patterns.match_('{(...)}', buffer.d || ""); + if (md && md.remainder === '') { + buffer.d = md.match_; + } + var mq = mhchemParser.patterns.match_('{(...)}', buffer.q || ""); + if (mq && mq.remainder === '') { + buffer.q = mq.match_; + } + if (buffer.d) { + buffer.d = buffer.d.replace(/\u00B0C|\^oC|\^{o}C/g, "{}^{\\circ}C"); + buffer.d = buffer.d.replace(/\u00B0F|\^oF|\^{o}F/g, "{}^{\\circ}F"); + } + if (buffer.q) { + // fraction + buffer.q = buffer.q.replace(/\u00B0C|\^oC|\^{o}C/g, "{}^{\\circ}C"); + buffer.q = buffer.q.replace(/\u00B0F|\^oF|\^{o}F/g, "{}^{\\circ}F"); + var b5 = { + d: mhchemParser.go(buffer.d, 'pu'), + q: mhchemParser.go(buffer.q, 'pu') + }; + if (buffer.o === '//') { + ret = { + type_: 'pu-frac', + p1: b5.d, + p2: b5.q + }; + } else { + ret = b5.d; + if (b5.d.length > 1 || b5.q.length > 1) { + ret.push({ + type_: ' / ' + }); + } else { + ret.push({ + type_: '/' + }); + } + mhchemParser.concatArray(ret, b5.q); + } + } else { + // no fraction + ret = mhchemParser.go(buffer.d, 'pu-2'); + } + for (var p in buffer) { + delete buffer[p]; + } + return ret; + } + } + }, + 'pu-2': { + transitions: mhchemParser.createTransitions({ + 'empty': { + '*': { + action_: 'output' + } + }, + '*': { + '*': { + action_: ['output', 'cdot'], + nextState: '0' + } + }, + '\\x': { + '*': { + action_: 'rm=' + } + }, + 'space': { + '*': { + action_: ['output', 'space'], + nextState: '0' + } + }, + '^{(...)}|^(-1)': { + '1': { + action_: '^(-1)' + } + }, + '-9.,9': { + '0': { + action_: 'rm=', + nextState: '0' + }, + '1': { + action_: '^(-1)', + nextState: '0' + } + }, + '{...}|else': { + '*': { + action_: 'rm=', + nextState: '1' + } + } + }), + actions: { + 'cdot': function cdot() { + return { + type_: 'tight cdot' + }; + }, + '^(-1)': function _(buffer, m) { + buffer.rm += "^{" + m + "}"; + }, + 'space': function space() { + return { + type_: 'pu-space-2' + }; + }, + 'output': function output(buffer) { + /** @type {ParserOutput | ParserOutput[]} */ + var ret = []; + if (buffer.rm) { + var mrm = mhchemParser.patterns.match_('{(...)}', buffer.rm || ""); + if (mrm && mrm.remainder === '') { + ret = mhchemParser.go(mrm.match_, 'pu'); + } else { + ret = { + type_: 'rm', + p1: buffer.rm + }; + } + } + for (var p in buffer) { + delete buffer[p]; + } + return ret; + } + } + }, + 'pu-9,9': { + transitions: mhchemParser.createTransitions({ + 'empty': { + '0': { + action_: 'output-0' + }, + 'o': { + action_: 'output-o' + } + }, + ',': { + '0': { + action_: ['output-0', 'comma'], + nextState: 'o' + } + }, + '.': { + '0': { + action_: ['output-0', 'copy'], + nextState: 'o' + } + }, + 'else': { + '*': { + action_: 'text=' + } + } + }), + actions: { + 'comma': function comma() { + return { + type_: 'commaDecimal' + }; + }, + 'output-0': function output0(buffer) { + /** @type {ParserOutput[]} */ + var ret = []; + buffer.text_ = buffer.text_ || ""; + if (buffer.text_.length > 4) { + var a = buffer.text_.length % 3; + if (a === 0) { + a = 3; + } + for (var i = buffer.text_.length - 3; i > 0; i -= 3) { + ret.push(buffer.text_.substr(i, 3)); + ret.push({ + type_: '1000 separator' + }); + } + ret.push(buffer.text_.substr(0, a)); + ret.reverse(); + } else { + ret.push(buffer.text_); + } + for (var p in buffer) { + delete buffer[p]; + } + return ret; + }, + 'output-o': function outputO(buffer) { + /** @type {ParserOutput[]} */ + var ret = []; + buffer.text_ = buffer.text_ || ""; + if (buffer.text_.length > 4) { + var a = buffer.text_.length - 3; + for (var i = 0; i < a; i += 3) { + ret.push(buffer.text_.substr(i, 3)); + ret.push({ + type_: '1000 separator' + }); + } + ret.push(buffer.text_.substr(i)); + } else { + ret.push(buffer.text_); + } + for (var p in buffer) { + delete buffer[p]; + } + return ret; + } + } + } + //#endregion +}; + +// +// texify: Take MhchemParser output and convert it to TeX +// +/** @type {Texify} */ +var texify = { + go: function go(input, isInner) { + // (recursive, max 4 levels) + if (!input) { + return ""; + } + var res = ""; + var cee = false; + for (var i = 0; i < input.length; i++) { + var inputi = input[i]; + if (typeof inputi === "string") { + res += inputi; + } else { + res += texify._go2(inputi); + if (inputi.type_ === '1st-level escape') { + cee = true; + } + } + } + if (!isInner && !cee && res) { + res = "{" + res + "}"; + } + return res; + }, + _goInner: function _goInner(input) { + if (!input) { + return input; + } + return texify.go(input, true); + }, + _go2: function _go2(buf) { + /** @type {undefined | string} */ + var res; + switch (buf.type_) { + case 'chemfive': + res = ""; + var b5 = { + a: texify._goInner(buf.a), + b: texify._goInner(buf.b), + p: texify._goInner(buf.p), + o: texify._goInner(buf.o), + q: texify._goInner(buf.q), + d: texify._goInner(buf.d) + }; + // + // a + // + if (b5.a) { + if (b5.a.match(/^[+\-]/)) { + b5.a = "{" + b5.a + "}"; + } + res += b5.a + "\\,"; + } + // + // b and p + // + if (b5.b || b5.p) { + res += "{\\vphantom{X}}"; + res += "^{\\hphantom{" + (b5.b || "") + "}}_{\\hphantom{" + (b5.p || "") + "}}"; + res += "{\\vphantom{X}}"; + res += "^{\\smash[t]{\\vphantom{2}}\\mathllap{" + (b5.b || "") + "}}"; + res += "_{\\vphantom{2}\\mathllap{\\smash[t]{" + (b5.p || "") + "}}}"; + } + // + // o + // + if (b5.o) { + if (b5.o.match(/^[+\-]/)) { + b5.o = "{" + b5.o + "}"; + } + res += b5.o; + } + // + // q and d + // + if (buf.dType === 'kv') { + if (b5.d || b5.q) { + res += "{\\vphantom{X}}"; + } + if (b5.d) { + res += "^{" + b5.d + "}"; + } + if (b5.q) { + res += "_{\\smash[t]{" + b5.q + "}}"; + } + } else if (buf.dType === 'oxidation') { + if (b5.d) { + res += "{\\vphantom{X}}"; + res += "^{" + b5.d + "}"; + } + if (b5.q) { + res += "{\\vphantom{X}}"; + res += "_{\\smash[t]{" + b5.q + "}}"; + } + } else { + if (b5.q) { + res += "{\\vphantom{X}}"; + res += "_{\\smash[t]{" + b5.q + "}}"; + } + if (b5.d) { + res += "{\\vphantom{X}}"; + res += "^{" + b5.d + "}"; + } + } + break; + case 'rm': + res = "\\mathrm{" + buf.p1 + "}"; + break; + case 'text': + if (buf.p1.match(/[\^_]/)) { + buf.p1 = buf.p1.replace(" ", "~").replace("-", "\\text{-}"); + res = "\\mathrm{" + buf.p1 + "}"; + } else { + res = "\\text{" + buf.p1 + "}"; + } + break; + case 'roman numeral': + res = "\\mathrm{" + buf.p1 + "}"; + break; + case 'state of aggregation': + res = "\\mskip2mu " + texify._goInner(buf.p1); + break; + case 'state of aggregation subscript': + res = "\\mskip1mu " + texify._goInner(buf.p1); + break; + case 'bond': + res = texify._getBond(buf.kind_); + if (!res) { + throw ["MhchemErrorBond", "mhchem Error. Unknown bond type (" + buf.kind_ + ")"]; + } + break; + case 'frac': + var c = "\\frac{" + buf.p1 + "}{" + buf.p2 + "}"; + res = "\\mathchoice{\\textstyle" + c + "}{" + c + "}{" + c + "}{" + c + "}"; + break; + case 'pu-frac': + var d = "\\frac{" + texify._goInner(buf.p1) + "}{" + texify._goInner(buf.p2) + "}"; + res = "\\mathchoice{\\textstyle" + d + "}{" + d + "}{" + d + "}{" + d + "}"; + break; + case 'tex-math': + res = buf.p1 + " "; + break; + case 'frac-ce': + res = "\\frac{" + texify._goInner(buf.p1) + "}{" + texify._goInner(buf.p2) + "}"; + break; + case 'overset': + res = "\\overset{" + texify._goInner(buf.p1) + "}{" + texify._goInner(buf.p2) + "}"; + break; + case 'underset': + res = "\\underset{" + texify._goInner(buf.p1) + "}{" + texify._goInner(buf.p2) + "}"; + break; + case 'underbrace': + res = "\\underbrace{" + texify._goInner(buf.p1) + "}_{" + texify._goInner(buf.p2) + "}"; + break; + case 'color': + res = "{\\color{" + buf.color1 + "}{" + texify._goInner(buf.color2) + "}}"; + break; + case 'color0': + res = "\\color{" + buf.color + "}"; + break; + case 'arrow': + var b6 = { + rd: texify._goInner(buf.rd), + rq: texify._goInner(buf.rq) + }; + var arrow = "\\x" + texify._getArrow(buf.r); + if (b6.rq) { + arrow += "[{" + b6.rq + "}]"; + } + if (b6.rd) { + arrow += "{" + b6.rd + "}"; + } else { + arrow += "{}"; + } + res = arrow; + break; + case 'operator': + res = texify._getOperator(buf.kind_); + break; + case '1st-level escape': + res = buf.p1 + " "; // &, \\\\, \\hlin + break; + case 'space': + res = " "; + break; + case 'entitySkip': + res = "~"; + break; + case 'pu-space-1': + res = "~"; + break; + case 'pu-space-2': + res = "\\mkern3mu "; + break; + case '1000 separator': + res = "\\mkern2mu "; + break; + case 'commaDecimal': + res = "{,}"; + break; + case 'comma enumeration L': + res = "{" + buf.p1 + "}\\mkern6mu "; + break; + case 'comma enumeration M': + res = "{" + buf.p1 + "}\\mkern3mu "; + break; + case 'comma enumeration S': + res = "{" + buf.p1 + "}\\mkern1mu "; + break; + case 'hyphen': + res = "\\text{-}"; + break; + case 'addition compound': + res = "\\,{\\cdot}\\,"; + break; + case 'electron dot': + res = "\\mkern1mu \\bullet\\mkern1mu "; + break; + case 'KV x': + res = "{\\times}"; + break; + case 'prime': + res = "\\prime "; + break; + case 'cdot': + res = "\\cdot "; + break; + case 'tight cdot': + res = "\\mkern1mu{\\cdot}\\mkern1mu "; + break; + case 'times': + res = "\\times "; + break; + case 'circa': + res = "{\\sim}"; + break; + case '^': + res = "uparrow"; + break; + case 'v': + res = "downarrow"; + break; + case 'ellipsis': + res = "\\ldots "; + break; + case '/': + res = "/"; + break; + case ' / ': + res = "\\,/\\,"; + break; + default: + throw ["MhchemBugT", "mhchem bug T. Please report."]; + // Missing texify rule or unknown MhchemParser output + } + return res; + }, + _getArrow: function _getArrow(a) { + switch (a) { + case "->": + return "rightarrow"; + case "\u2192": + return "rightarrow"; + case "\u27F6": + return "rightarrow"; + case "<-": + return "leftarrow"; + case "<->": + return "leftrightarrow"; + case "<-->": + return "rightleftarrows"; + case "<=>": + return "rightleftharpoons"; + case "\u21CC": + return "rightleftharpoons"; + case "<=>>": + return "rightequilibrium"; + case "<<=>": + return "leftequilibrium"; + default: + throw ["MhchemBugT", "mhchem bug T. Please report."]; + } + }, + _getBond: function _getBond(a) { + switch (a) { + case "-": + return "{-}"; + case "1": + return "{-}"; + case "=": + return "{=}"; + case "2": + return "{=}"; + case "#": + return "{\\equiv}"; + case "3": + return "{\\equiv}"; + case "~": + return "{\\tripledash}"; + case "~-": + return "{\\mathrlap{\\raisebox{-.1em}{$-$}}\\raisebox{.1em}{$\\tripledash$}}"; + case "~=": + return "{\\mathrlap{\\raisebox{-.2em}{$-$}}\\mathrlap{\\raisebox{.2em}{$\\tripledash$}}-}"; + case "~--": + return "{\\mathrlap{\\raisebox{-.2em}{$-$}}\\mathrlap{\\raisebox{.2em}{$\\tripledash$}}-}"; + case "-~-": + return "{\\mathrlap{\\raisebox{-.2em}{$-$}}\\mathrlap{\\raisebox{.2em}{$-$}}\\tripledash}"; + case "...": + return "{{\\cdot}{\\cdot}{\\cdot}}"; + case "....": + return "{{\\cdot}{\\cdot}{\\cdot}{\\cdot}}"; + case "->": + return "{\\rightarrow}"; + case "<-": + return "{\\leftarrow}"; + case "<": + return "{<}"; + case ">": + return "{>}"; + default: + throw ["MhchemBugT", "mhchem bug T. Please report."]; + } + }, + _getOperator: function _getOperator(a) { + switch (a) { + case "+": + return " {}+{} "; + case "-": + return " {}-{} "; + case "=": + return " {}={} "; + case "<": + return " {}<{} "; + case ">": + return " {}>{} "; + case "<<": + return " {}\\ll{} "; + case ">>": + return " {}\\gg{} "; + case "\\pm": + return " {}\\pm{} "; + case "\\approx": + return " {}\\approx{} "; + case "$\\approx$": + return " {}\\approx{} "; + case "v": + return " \\downarrow{} "; + case "(v)": + return " \\downarrow{} "; + case "^": + return " \\uparrow{} "; + case "(^)": + return " \\uparrow{} "; + default: + throw ["MhchemBugT", "mhchem bug T. Please report."]; + } + } +}; diff --git a/node_modules/react-katex/node_modules/katex/dist/contrib/render-a11y-string.js b/node_modules/react-katex/node_modules/katex/dist/contrib/render-a11y-string.js new file mode 100644 index 0000000..55dbb28 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/dist/contrib/render-a11y-string.js @@ -0,0 +1,827 @@ +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(require("katex")); + else if(typeof define === 'function' && define.amd) + define(["katex"], factory); + else { + var a = typeof exports === 'object' ? factory(require("katex")) : factory(root["katex"]); + for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i]; + } +})((typeof self !== 'undefined' ? self : this), function(__WEBPACK_EXTERNAL_MODULE__757__) { +return /******/ (function() { // webpackBootstrap +/******/ "use strict"; +/******/ var __webpack_modules__ = ({ + +/***/ 757: +/***/ (function(module) { + +module.exports = __WEBPACK_EXTERNAL_MODULE__757__; + +/***/ }) + +/******/ }); +/************************************************************************/ +/******/ // The module cache +/******/ var __webpack_module_cache__ = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ // Check if module is in cache +/******/ var cachedModule = __webpack_module_cache__[moduleId]; +/******/ if (cachedModule !== undefined) { +/******/ return cachedModule.exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = __webpack_module_cache__[moduleId] = { +/******/ // no module.id needed +/******/ // no module.loaded needed +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/************************************************************************/ +/******/ /* webpack/runtime/compat get default export */ +/******/ !function() { +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function() { return module['default']; } : +/******/ function() { return module; }; +/******/ __webpack_require__.d(getter, { a: getter }); +/******/ return getter; +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/define property getters */ +/******/ !function() { +/******/ // define getter functions for harmony exports +/******/ __webpack_require__.d = function(exports, definition) { +/******/ for(var key in definition) { +/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { +/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); +/******/ } +/******/ } +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/hasOwnProperty shorthand */ +/******/ !function() { +/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } +/******/ }(); +/******/ +/************************************************************************/ +var __webpack_exports__ = {}; + +// EXPORTS +__webpack_require__.d(__webpack_exports__, { + "default": function() { return /* binding */ render_a11y_string; } +}); + +;// ./src/atoms.ts +/** + * Small module for atom-group constants and type guard. Kept separate from + * `symbols.ts` so that consumers (notably `contrib/render-a11y-string`) can + * pull in `isAtom` without dragging in the ~870-line symbol tables. + */ + +// Some of these have a "-token" suffix since these are also used as `ParseNode` +// types for raw text tokens, and we want to avoid conflicts with higher-level +// `ParseNode` types. These `ParseNode`s are constructed within `Parser` by +// looking up the `symbols` map. +const ATOMS = { + "bin": 1, + "close": 1, + "inner": 1, + "open": 1, + "punct": 1, + "rel": 1 +}; +const NON_ATOMS = { + "accent-token": 1, + "mathord": 1, + "op-token": 1, + "spacing": 1, + "textord": 1 +}; +function isAtom(value) { + return value in ATOMS; +} +// EXTERNAL MODULE: external "katex" +var external_katex_ = __webpack_require__(757); +var external_katex_default = /*#__PURE__*/__webpack_require__.n(external_katex_); +;// ./contrib/render-a11y-string/render-a11y-string.ts +/** + * renderA11yString returns a readable string. + * + * In some cases the string will have the proper semantic math + * meaning,: + * renderA11yString("\\frac{1}{2}"") + * -> "start fraction, 1, divided by, 2, end fraction" + * + * However, other cases do not: + * renderA11yString("f(x) = x^2") + * -> "f, left parenthesis, x, right parenthesis, equals, x, squared" + * + * The commas in the string aim to increase ease of understanding + * when read by a screenreader. + */ + + + +const stringMap = { + "(": "left parenthesis", + ")": "right parenthesis", + "[": "open bracket", + "]": "close bracket", + "\\{": "left brace", + "\\}": "right brace", + "\\lvert": "open vertical bar", + "\\rvert": "close vertical bar", + "|": "vertical bar", + "\\uparrow": "up arrow", + "\\Uparrow": "up arrow", + "\\downarrow": "down arrow", + "\\Downarrow": "down arrow", + "\\updownarrow": "up down arrow", + "\\leftarrow": "left arrow", + "\\Leftarrow": "left arrow", + "\\rightarrow": "right arrow", + "\\Rightarrow": "right arrow", + "\\langle": "open angle", + "\\rangle": "close angle", + "\\lfloor": "open floor", + "\\rfloor": "close floor", + "\\int": "integral", + "\\intop": "integral", + "\\lim": "limit", + "\\ln": "natural log", + "\\log": "log", + "\\sin": "sine", + "\\cos": "cosine", + "\\tan": "tangent", + "\\cot": "cotangent", + "\\sum": "sum", + "/": "slash", + ",": "comma", + ".": "point", + "-": "negative", + "+": "plus", + "~": "tilde", + ":": "colon", + "?": "question mark", + "'": "apostrophe", + "\\%": "percent", + " ": "space", + "\\ ": "space", + "\\$": "dollar sign", + "\\angle": "angle", + "\\degree": "degree", + "\\circ": "circle", + "\\vec": "vector", + "\\triangle": "triangle", + "\\pi": "pi", + "\\prime": "prime", + "\\infty": "infinity", + "\\alpha": "alpha", + "\\beta": "beta", + "\\gamma": "gamma", + "\\omega": "omega", + "\\theta": "theta", + "\\sigma": "sigma", + "\\lambda": "lambda", + "\\tau": "tau", + "\\Delta": "delta", + "\\delta": "delta", + "\\mu": "mu", + "\\rho": "rho", + "\\nabla": "del", + "\\ell": "ell", + "\\ldots": "dots", + // TODO: add entries for all accents + "\\hat": "hat", + "\\acute": "acute" +}; +const powerMap = { + "prime": "prime", + "degree": "degrees", + "circle": "degrees", + "2": "squared", + "3": "cubed" +}; +const openMap = { + "|": "open vertical bar", + ".": "" +}; +const closeMap = { + "|": "close vertical bar", + ".": "" +}; +const binMap = { + "+": "plus", + "-": "minus", + "\\pm": "plus minus", + "\\cdot": "dot", + "*": "times", + "/": "divided by", + "\\times": "times", + "\\div": "divided by", + "\\circ": "circle", + "\\bullet": "bullet" +}; +const relMap = { + "=": "equals", + "\\approx": "approximately equals", + "≠": "does not equal", + "\\geq": "is greater than or equal to", + "\\ge": "is greater than or equal to", + "\\leq": "is less than or equal to", + "\\le": "is less than or equal to", + ">": "is greater than", + "<": "is less than", + "\\leftarrow": "left arrow", + "\\Leftarrow": "left arrow", + "\\rightarrow": "right arrow", + "\\Rightarrow": "right arrow", + ":": "colon" +}; +const accentUnderMap = { + "\\underleftarrow": "left arrow", + "\\underrightarrow": "right arrow", + "\\underleftrightarrow": "left-right arrow", + "\\undergroup": "group", + "\\underlinesegment": "line segment", + "\\utilde": "tilde" +}; +const buildString = (str, type, a11yStrings) => { + if (!str) { + return; + } + let ret; + if (type === "open") { + ret = str in openMap ? openMap[str] : stringMap[str] || str; + } else if (type === "close") { + ret = str in closeMap ? closeMap[str] : stringMap[str] || str; + } else if (type === "bin") { + ret = binMap[str] || str; + } else if (type === "rel") { + ret = relMap[str] || str; + } else { + ret = stringMap[str] || str; + } + + // If the text to add is a number and there is already a string + // in the list and the last string is a number then we should + // combine them into a single number + const last = a11yStrings[a11yStrings.length - 1]; + if (/^\d+$/.test(ret) && a11yStrings.length > 0 && typeof last === "string" && /^\d+$/.test(last)) { + a11yStrings[a11yStrings.length - 1] += ret; + } else if (ret) { + a11yStrings.push(ret); + } +}; +const buildRegion = (a11yStrings, callback) => { + const regionStrings = []; + a11yStrings.push(regionStrings); + callback(regionStrings); +}; +const handleObject = (tree, a11yStrings, atomType) => { + // Everything else is assumed to be an object... + switch (tree.type) { + case "accent": + { + buildRegion(a11yStrings, a11yStrings => { + buildA11yStrings(tree.base, a11yStrings, atomType); + a11yStrings.push("with"); + buildString(tree.label, "normal", a11yStrings); + a11yStrings.push("on top"); + }); + break; + } + case "accentUnder": + { + buildRegion(a11yStrings, a11yStrings => { + buildA11yStrings(tree.base, a11yStrings, atomType); + a11yStrings.push("with"); + buildString(accentUnderMap[tree.label], "normal", a11yStrings); + a11yStrings.push("underneath"); + }); + break; + } + case "accent-token": + { + // Used internally by accent symbols. + break; + } + case "atom": + { + const { + text + } = tree; + switch (tree.family) { + case "bin": + { + buildString(text, "bin", a11yStrings); + break; + } + case "close": + { + buildString(text, "close", a11yStrings); + break; + } + // TODO(kevinb): figure out what should be done for inner + case "inner": + { + buildString(tree.text, "inner", a11yStrings); + break; + } + case "open": + { + buildString(text, "open", a11yStrings); + break; + } + case "punct": + { + buildString(text, "punct", a11yStrings); + break; + } + case "rel": + { + buildString(text, "rel", a11yStrings); + break; + } + default: + { + tree.family; + throw new Error("\"" + tree.family + "\" is not a valid atom type"); + } + } + break; + } + case "color": + { + const color = tree.color.replace(/katex-/, ""); + buildRegion(a11yStrings, regionStrings => { + regionStrings.push("start color " + color); + buildA11yStrings(tree.body, regionStrings, atomType); + regionStrings.push("end color " + color); + }); + break; + } + case "color-token": + { + // Used by \color, \colorbox, and \fcolorbox but not directly rendered. + // It's a leaf node and has no children so just break. + break; + } + case "delimsizing": + { + if (tree.delim && tree.delim !== ".") { + buildString(tree.delim, "normal", a11yStrings); + } + break; + } + case "genfrac": + { + buildRegion(a11yStrings, regionStrings => { + // genfrac can have unbalanced delimiters + const { + leftDelim, + rightDelim + } = tree; + + // NOTE: Not sure if this is a safe assumption + // hasBarLine true -> fraction, false -> binomial + if (tree.hasBarLine) { + regionStrings.push("start fraction"); + leftDelim && buildString(leftDelim, "open", regionStrings); + buildA11yStrings(tree.numer, regionStrings, atomType); + regionStrings.push("divided by"); + buildA11yStrings(tree.denom, regionStrings, atomType); + rightDelim && buildString(rightDelim, "close", regionStrings); + regionStrings.push("end fraction"); + } else { + regionStrings.push("start binomial"); + leftDelim && buildString(leftDelim, "open", regionStrings); + buildA11yStrings(tree.numer, regionStrings, atomType); + regionStrings.push("over"); + buildA11yStrings(tree.denom, regionStrings, atomType); + rightDelim && buildString(rightDelim, "close", regionStrings); + regionStrings.push("end binomial"); + } + }); + break; + } + case "hbox": + { + buildA11yStrings(tree.body, a11yStrings, atomType); + break; + } + case "kern": + { + // No op: we don't attempt to present kerning information + // to the screen reader. + break; + } + case "leftright": + { + buildRegion(a11yStrings, regionStrings => { + buildString(tree.left, "open", regionStrings); + buildA11yStrings(tree.body, regionStrings, atomType); + buildString(tree.right, "close", regionStrings); + }); + break; + } + case "leftright-right": + { + // TODO: double check that this is a no-op + break; + } + case "lap": + { + buildA11yStrings(tree.body, a11yStrings, atomType); + break; + } + case "mathord": + { + buildString(tree.text, "normal", a11yStrings); + break; + } + case "op": + { + const { + body, + name + } = tree; + if (body) { + buildA11yStrings(body, a11yStrings, atomType); + } else if (name) { + buildString(name, "normal", a11yStrings); + } + break; + } + case "op-token": + { + // Used internally by operator symbols. + buildString(tree.text, atomType, a11yStrings); + break; + } + case "ordgroup": + { + buildA11yStrings(tree.body, a11yStrings, atomType); + break; + } + case "overline": + { + buildRegion(a11yStrings, function (a11yStrings) { + a11yStrings.push("start overline"); + buildA11yStrings(tree.body, a11yStrings, atomType); + a11yStrings.push("end overline"); + }); + break; + } + case "pmb": + { + a11yStrings.push("bold"); + break; + } + case "phantom": + { + a11yStrings.push("empty space"); + break; + } + case "raisebox": + { + buildA11yStrings(tree.body, a11yStrings, atomType); + break; + } + case "rule": + { + a11yStrings.push("rectangle"); + break; + } + case "sizing": + { + buildA11yStrings(tree.body, a11yStrings, atomType); + break; + } + case "spacing": + { + a11yStrings.push("space"); + break; + } + case "styling": + { + // We ignore the styling and just pass through the contents + buildA11yStrings(tree.body, a11yStrings, atomType); + break; + } + case "sqrt": + { + buildRegion(a11yStrings, regionStrings => { + const { + body, + index + } = tree; + if (index) { + const indexString = flatten(buildA11yStrings(index, [], atomType)).join(","); + if (indexString === "3") { + regionStrings.push("cube root of"); + buildA11yStrings(body, regionStrings, atomType); + regionStrings.push("end cube root"); + return; + } + regionStrings.push("root"); + regionStrings.push("start index"); + buildA11yStrings(index, regionStrings, atomType); + regionStrings.push("end index"); + return; + } + regionStrings.push("square root of"); + buildA11yStrings(body, regionStrings, atomType); + regionStrings.push("end square root"); + }); + break; + } + case "supsub": + { + const { + base, + sub, + sup + } = tree; + let isLog = false; + if (base) { + buildA11yStrings(base, a11yStrings, atomType); + isLog = base.type === "op" && base.name === "\\log"; + } + if (sub) { + const regionName = isLog ? "base" : "subscript"; + buildRegion(a11yStrings, function (regionStrings) { + regionStrings.push("start " + regionName); + buildA11yStrings(sub, regionStrings, atomType); + regionStrings.push("end " + regionName); + }); + } + if (sup) { + buildRegion(a11yStrings, function (regionStrings) { + const supString = flatten(buildA11yStrings(sup, [], atomType)).join(","); + if (supString in powerMap) { + regionStrings.push(powerMap[supString]); + return; + } + regionStrings.push("start superscript"); + buildA11yStrings(sup, regionStrings, atomType); + regionStrings.push("end superscript"); + }); + } + break; + } + case "text": + { + // TODO: handle other fonts + if (tree.font === "\\textbf") { + buildRegion(a11yStrings, function (regionStrings) { + regionStrings.push("start bold text"); + buildA11yStrings(tree.body, regionStrings, atomType); + regionStrings.push("end bold text"); + }); + break; + } + buildRegion(a11yStrings, function (regionStrings) { + regionStrings.push("start text"); + buildA11yStrings(tree.body, regionStrings, atomType); + regionStrings.push("end text"); + }); + break; + } + case "textord": + { + buildString(tree.text, atomType, a11yStrings); + break; + } + case "smash": + { + buildA11yStrings(tree.body, a11yStrings, atomType); + break; + } + case "enclose": + { + // TODO: create a map for these. + // TODO: differentiate between a body with a single atom, e.g. + // "cancel a" instead of "start cancel, a, end cancel" + if (/cancel/.test(tree.label)) { + buildRegion(a11yStrings, function (regionStrings) { + regionStrings.push("start cancel"); + buildA11yStrings(tree.body, regionStrings, atomType); + regionStrings.push("end cancel"); + }); + break; + } else if (/box/.test(tree.label)) { + buildRegion(a11yStrings, function (regionStrings) { + regionStrings.push("start box"); + buildA11yStrings(tree.body, regionStrings, atomType); + regionStrings.push("end box"); + }); + break; + } else if (/sout/.test(tree.label)) { + buildRegion(a11yStrings, function (regionStrings) { + regionStrings.push("start strikeout"); + buildA11yStrings(tree.body, regionStrings, atomType); + regionStrings.push("end strikeout"); + }); + break; + } else if (/phase/.test(tree.label)) { + buildRegion(a11yStrings, function (regionStrings) { + regionStrings.push("start phase angle"); + buildA11yStrings(tree.body, regionStrings, atomType); + regionStrings.push("end phase angle"); + }); + break; + } + throw new Error("KaTeX-a11y: enclose node with " + tree.label + " not supported yet"); + } + case "vcenter": + { + buildA11yStrings(tree.body, a11yStrings, atomType); + break; + } + case "vphantom": + { + throw new Error("KaTeX-a11y: vphantom not implemented yet"); + } + case "operatorname": + { + buildA11yStrings(tree.body, a11yStrings, atomType); + break; + } + case "array": + { + throw new Error("KaTeX-a11y: array not implemented yet"); + } + case "raw": + { + throw new Error("KaTeX-a11y: raw not implemented yet"); + } + case "size": + { + // Although there are nodes of type "size" in the parse tree, they have + // no semantic meaning and should be ignored. + break; + } + case "url": + { + throw new Error("KaTeX-a11y: url not implemented yet"); + } + case "tag": + { + throw new Error("KaTeX-a11y: tag not implemented yet"); + } + case "verb": + { + buildString("start verbatim", "normal", a11yStrings); + buildString(tree.body, "normal", a11yStrings); + buildString("end verbatim", "normal", a11yStrings); + break; + } + case "environment": + { + throw new Error("KaTeX-a11y: environment not implemented yet"); + } + case "horizBrace": + { + buildString("start " + tree.label.slice(1), "normal", a11yStrings); + buildA11yStrings(tree.base, a11yStrings, atomType); + buildString("end " + tree.label.slice(1), "normal", a11yStrings); + break; + } + case "infix": + { + // All infix nodes are replace with other nodes. + break; + } + case "includegraphics": + { + throw new Error("KaTeX-a11y: includegraphics not implemented yet"); + } + case "font": + { + // TODO: callout the start/end of specific fonts + // TODO: map \BBb{N} to "the naturals" or something like that + buildA11yStrings(tree.body, a11yStrings, atomType); + break; + } + case "href": + { + throw new Error("KaTeX-a11y: href not implemented yet"); + } + case "cr": + { + // This is used by environments. + throw new Error("KaTeX-a11y: cr not implemented yet"); + } + case "underline": + { + buildRegion(a11yStrings, function (a11yStrings) { + a11yStrings.push("start underline"); + buildA11yStrings(tree.body, a11yStrings, atomType); + a11yStrings.push("end underline"); + }); + break; + } + case "xArrow": + { + throw new Error("KaTeX-a11y: xArrow not implemented yet"); + } + case "cdlabel": + { + throw new Error("KaTeX-a11y: cdlabel not implemented yet"); + } + case "cdlabelparent": + { + throw new Error("KaTeX-a11y: cdlabelparent not implemented yet"); + } + case "mclass": + { + // \neq and \ne are macros so we let "htmlmathml" render the mathmal + // side of things and extract the text from that. + // mclass values are prefixed with "m" (e.g. "mrel" -> "rel") + const atomType = tree.mclass.slice(1); + if (atomType === "normal" || isAtom(atomType)) { + buildA11yStrings(tree.body, a11yStrings, atomType); + } else { + throw new Error("Unexpected mclass atom type: \"" + atomType + "\""); + } + break; + } + case "mathchoice": + { + // TODO: track which style we're using, e.g. display, text, etc. + // default to text style if even that may not be the correct style + buildA11yStrings(tree.text, a11yStrings, atomType); + break; + } + case "htmlmathml": + { + buildA11yStrings(tree.mathml, a11yStrings, atomType); + break; + } + case "middle": + { + buildString(tree.delim, atomType, a11yStrings); + break; + } + case "internal": + { + // internal nodes are never included in the parse tree + break; + } + case "html": + { + buildA11yStrings(tree.body, a11yStrings, atomType); + break; + } + default: + throw new Error("KaTeX a11y un-recognized type: " + tree.type); + } +}; +const buildA11yStrings = function (tree, a11yStrings, atomType) { + if (a11yStrings === void 0) { + a11yStrings = []; + } + if (tree instanceof Array) { + for (let i = 0; i < tree.length; i++) { + buildA11yStrings(tree[i], a11yStrings, atomType); + } + } else { + handleObject(tree, a11yStrings, atomType); + } + return a11yStrings; +}; +const flatten = function (array) { + let result = []; + array.forEach(function (item) { + if (Array.isArray(item)) { + result = result.concat(flatten(item)); + } else { + result.push(item); + } + }); + return result; +}; +const renderA11yString = function (text, settings) { + const tree = external_katex_default().__parse(text, settings); + const a11yStrings = buildA11yStrings(tree, [], "normal"); + return flatten(a11yStrings).join(", "); +}; +/* harmony default export */ var render_a11y_string = (renderA11yString); +__webpack_exports__ = __webpack_exports__["default"]; +/******/ return __webpack_exports__; +/******/ })() +; +}); \ No newline at end of file diff --git a/node_modules/react-katex/node_modules/katex/dist/contrib/render-a11y-string.min.js b/node_modules/react-katex/node_modules/katex/dist/contrib/render-a11y-string.min.js new file mode 100644 index 0000000..abbb3d7 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/dist/contrib/render-a11y-string.min.js @@ -0,0 +1 @@ +!function(e,r){if("object"==typeof exports&&"object"==typeof module)module.exports=r(require("katex"));else if("function"==typeof define&&define.amd)define(["katex"],r);else{var t="object"==typeof exports?r(require("katex")):r(e.katex);for(var a in t)("object"==typeof exports?exports:e)[a]=t[a]}}("undefined"!=typeof self?self:this,function(e){return function(){"use strict";var r={757:function(r){r.exports=e}},t={};function a(e){var o=t[e];if(void 0!==o)return o.exports;var n=t[e]={exports:{}};return r[e](n,n.exports,a),n.exports}a.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(r,{a:r}),r},a.d=function(e,r){for(var t in r)a.o(r,t)&&!a.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},a.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)};var o={};a.d(o,{default:function(){return k}});const n={bin:1,close:1,inner:1,open:1,punct:1,rel:1};var s=a(757),l=a.n(s);const i={"(":"left parenthesis",")":"right parenthesis","[":"open bracket","]":"close bracket","\\{":"left brace","\\}":"right brace","\\lvert":"open vertical bar","\\rvert":"close vertical bar","|":"vertical bar","\\uparrow":"up arrow","\\Uparrow":"up arrow","\\downarrow":"down arrow","\\Downarrow":"down arrow","\\updownarrow":"up down arrow","\\leftarrow":"left arrow","\\Leftarrow":"left arrow","\\rightarrow":"right arrow","\\Rightarrow":"right arrow","\\langle":"open angle","\\rangle":"close angle","\\lfloor":"open floor","\\rfloor":"close floor","\\int":"integral","\\intop":"integral","\\lim":"limit","\\ln":"natural log","\\log":"log","\\sin":"sine","\\cos":"cosine","\\tan":"tangent","\\cot":"cotangent","\\sum":"sum","/":"slash",",":"comma",".":"point","-":"negative","+":"plus","~":"tilde",":":"colon","?":"question mark","'":"apostrophe","\\%":"percent"," ":"space","\\ ":"space","\\$":"dollar sign","\\angle":"angle","\\degree":"degree","\\circ":"circle","\\vec":"vector","\\triangle":"triangle","\\pi":"pi","\\prime":"prime","\\infty":"infinity","\\alpha":"alpha","\\beta":"beta","\\gamma":"gamma","\\omega":"omega","\\theta":"theta","\\sigma":"sigma","\\lambda":"lambda","\\tau":"tau","\\Delta":"delta","\\delta":"delta","\\mu":"mu","\\rho":"rho","\\nabla":"del","\\ell":"ell","\\ldots":"dots","\\hat":"hat","\\acute":"acute"},c={prime:"prime",degree:"degrees",circle:"degrees",2:"squared",3:"cubed"},u={"|":"open vertical bar",".":""},p={"|":"close vertical bar",".":""},d={"+":"plus","-":"minus","\\pm":"plus minus","\\cdot":"dot","*":"times","/":"divided by","\\times":"times","\\div":"divided by","\\circ":"circle","\\bullet":"bullet"},h={"=":"equals","\\approx":"approximately equals","\u2260":"does not equal","\\geq":"is greater than or equal to","\\ge":"is greater than or equal to","\\leq":"is less than or equal to","\\le":"is less than or equal to",">":"is greater than","<":"is less than","\\leftarrow":"left arrow","\\Leftarrow":"left arrow","\\rightarrow":"right arrow","\\Rightarrow":"right arrow",":":"colon"},b={"\\underleftarrow":"left arrow","\\underrightarrow":"right arrow","\\underleftrightarrow":"left-right arrow","\\undergroup":"group","\\underlinesegment":"line segment","\\utilde":"tilde"},m=(e,r,t)=>{if(!e)return;let a;a="open"===r?e in u?u[e]:i[e]||e:"close"===r?e in p?p[e]:i[e]||e:"bin"===r?d[e]||e:"rel"===r?h[e]||e:i[e]||e;const o=t[t.length-1];/^\d+$/.test(a)&&t.length>0&&"string"==typeof o&&/^\d+$/.test(o)?t[t.length-1]+=a:a&&t.push(a)},f=(e,r)=>{const t=[];e.push(t),r(t)},w=(e,r,t)=>{switch(e.type){case"accent":f(r,r=>{g(e.base,r,t),r.push("with"),m(e.label,"normal",r),r.push("on top")});break;case"accentUnder":f(r,r=>{g(e.base,r,t),r.push("with"),m(b[e.label],"normal",r),r.push("underneath")});break;case"accent-token":case"color-token":case"kern":case"leftright-right":case"size":case"infix":case"internal":break;case"atom":{const{text:t}=e;switch(e.family){case"bin":m(t,"bin",r);break;case"close":m(t,"close",r);break;case"inner":m(e.text,"inner",r);break;case"open":m(t,"open",r);break;case"punct":m(t,"punct",r);break;case"rel":m(t,"rel",r);break;default:throw e.family,new Error('"'+e.family+'" is not a valid atom type')}break}case"color":{const a=e.color.replace(/katex-/,"");f(r,r=>{r.push("start color "+a),g(e.body,r,t),r.push("end color "+a)});break}case"delimsizing":e.delim&&"."!==e.delim&&m(e.delim,"normal",r);break;case"genfrac":f(r,r=>{const{leftDelim:a,rightDelim:o}=e;e.hasBarLine?(r.push("start fraction"),a&&m(a,"open",r),g(e.numer,r,t),r.push("divided by"),g(e.denom,r,t),o&&m(o,"close",r),r.push("end fraction")):(r.push("start binomial"),a&&m(a,"open",r),g(e.numer,r,t),r.push("over"),g(e.denom,r,t),o&&m(o,"close",r),r.push("end binomial"))});break;case"hbox":case"lap":case"ordgroup":case"raisebox":case"sizing":case"styling":case"smash":case"vcenter":case"operatorname":case"font":case"html":g(e.body,r,t);break;case"leftright":f(r,r=>{m(e.left,"open",r),g(e.body,r,t),m(e.right,"close",r)});break;case"mathord":m(e.text,"normal",r);break;case"op":{const{body:a,name:o}=e;a?g(a,r,t):o&&m(o,"normal",r);break}case"op-token":case"textord":m(e.text,t,r);break;case"overline":f(r,function(r){r.push("start overline"),g(e.body,r,t),r.push("end overline")});break;case"pmb":r.push("bold");break;case"phantom":r.push("empty space");break;case"rule":r.push("rectangle");break;case"spacing":r.push("space");break;case"sqrt":f(r,r=>{const{body:a,index:o}=e;if(o){return"3"===y(g(o,[],t)).join(",")?(r.push("cube root of"),g(a,r,t),void r.push("end cube root")):(r.push("root"),r.push("start index"),g(o,r,t),void r.push("end index"))}r.push("square root of"),g(a,r,t),r.push("end square root")});break;case"supsub":{const{base:a,sub:o,sup:n}=e;let s=!1;if(a&&(g(a,r,t),s="op"===a.type&&"\\log"===a.name),o){const e=s?"base":"subscript";f(r,function(r){r.push("start "+e),g(o,r,t),r.push("end "+e)})}n&&f(r,function(e){const r=y(g(n,[],t)).join(",");r in c?e.push(c[r]):(e.push("start superscript"),g(n,e,t),e.push("end superscript"))});break}case"text":if("\\textbf"===e.font){f(r,function(r){r.push("start bold text"),g(e.body,r,t),r.push("end bold text")});break}f(r,function(r){r.push("start text"),g(e.body,r,t),r.push("end text")});break;case"enclose":if(/cancel/.test(e.label)){f(r,function(r){r.push("start cancel"),g(e.body,r,t),r.push("end cancel")});break}if(/box/.test(e.label)){f(r,function(r){r.push("start box"),g(e.body,r,t),r.push("end box")});break}if(/sout/.test(e.label)){f(r,function(r){r.push("start strikeout"),g(e.body,r,t),r.push("end strikeout")});break}if(/phase/.test(e.label)){f(r,function(r){r.push("start phase angle"),g(e.body,r,t),r.push("end phase angle")});break}throw new Error("KaTeX-a11y: enclose node with "+e.label+" not supported yet");case"vphantom":throw new Error("KaTeX-a11y: vphantom not implemented yet");case"array":throw new Error("KaTeX-a11y: array not implemented yet");case"raw":throw new Error("KaTeX-a11y: raw not implemented yet");case"url":throw new Error("KaTeX-a11y: url not implemented yet");case"tag":throw new Error("KaTeX-a11y: tag not implemented yet");case"verb":m("start verbatim","normal",r),m(e.body,"normal",r),m("end verbatim","normal",r);break;case"environment":throw new Error("KaTeX-a11y: environment not implemented yet");case"horizBrace":m("start "+e.label.slice(1),"normal",r),g(e.base,r,t),m("end "+e.label.slice(1),"normal",r);break;case"includegraphics":throw new Error("KaTeX-a11y: includegraphics not implemented yet");case"href":throw new Error("KaTeX-a11y: href not implemented yet");case"cr":throw new Error("KaTeX-a11y: cr not implemented yet");case"underline":f(r,function(r){r.push("start underline"),g(e.body,r,t),r.push("end underline")});break;case"xArrow":throw new Error("KaTeX-a11y: xArrow not implemented yet");case"cdlabel":throw new Error("KaTeX-a11y: cdlabel not implemented yet");case"cdlabelparent":throw new Error("KaTeX-a11y: cdlabelparent not implemented yet");case"mclass":{const t=e.mclass.slice(1);if("normal"!==t&&!(t in n))throw new Error('Unexpected mclass atom type: "'+t+'"');g(e.body,r,t);break}case"mathchoice":g(e.text,r,t);break;case"htmlmathml":g(e.mathml,r,t);break;case"middle":m(e.delim,t,r);break;default:throw new Error("KaTeX a11y un-recognized type: "+e.type)}},g=function(e,r,t){if(void 0===r&&(r=[]),e instanceof Array)for(let a=0;a "start fraction, 1, divided by, 2, end fraction" + * + * However, other cases do not: + * renderA11yString("f(x) = x^2") + * -> "f, left parenthesis, x, right parenthesis, equals, x, squared" + * + * The commas in the string aim to increase ease of understanding + * when read by a screenreader. + */ +var stringMap = { + "(": "left parenthesis", + ")": "right parenthesis", + "[": "open bracket", + "]": "close bracket", + "\\{": "left brace", + "\\}": "right brace", + "\\lvert": "open vertical bar", + "\\rvert": "close vertical bar", + "|": "vertical bar", + "\\uparrow": "up arrow", + "\\Uparrow": "up arrow", + "\\downarrow": "down arrow", + "\\Downarrow": "down arrow", + "\\updownarrow": "up down arrow", + "\\leftarrow": "left arrow", + "\\Leftarrow": "left arrow", + "\\rightarrow": "right arrow", + "\\Rightarrow": "right arrow", + "\\langle": "open angle", + "\\rangle": "close angle", + "\\lfloor": "open floor", + "\\rfloor": "close floor", + "\\int": "integral", + "\\intop": "integral", + "\\lim": "limit", + "\\ln": "natural log", + "\\log": "log", + "\\sin": "sine", + "\\cos": "cosine", + "\\tan": "tangent", + "\\cot": "cotangent", + "\\sum": "sum", + "/": "slash", + ",": "comma", + ".": "point", + "-": "negative", + "+": "plus", + "~": "tilde", + ":": "colon", + "?": "question mark", + "'": "apostrophe", + "\\%": "percent", + " ": "space", + "\\ ": "space", + "\\$": "dollar sign", + "\\angle": "angle", + "\\degree": "degree", + "\\circ": "circle", + "\\vec": "vector", + "\\triangle": "triangle", + "\\pi": "pi", + "\\prime": "prime", + "\\infty": "infinity", + "\\alpha": "alpha", + "\\beta": "beta", + "\\gamma": "gamma", + "\\omega": "omega", + "\\theta": "theta", + "\\sigma": "sigma", + "\\lambda": "lambda", + "\\tau": "tau", + "\\Delta": "delta", + "\\delta": "delta", + "\\mu": "mu", + "\\rho": "rho", + "\\nabla": "del", + "\\ell": "ell", + "\\ldots": "dots", + // TODO: add entries for all accents + "\\hat": "hat", + "\\acute": "acute" +}; +var powerMap = { + "prime": "prime", + "degree": "degrees", + "circle": "degrees", + "2": "squared", + "3": "cubed" +}; +var openMap = { + "|": "open vertical bar", + ".": "" +}; +var closeMap = { + "|": "close vertical bar", + ".": "" +}; +var binMap = { + "+": "plus", + "-": "minus", + "\\pm": "plus minus", + "\\cdot": "dot", + "*": "times", + "/": "divided by", + "\\times": "times", + "\\div": "divided by", + "\\circ": "circle", + "\\bullet": "bullet" +}; +var relMap = { + "=": "equals", + "\\approx": "approximately equals", + "≠": "does not equal", + "\\geq": "is greater than or equal to", + "\\ge": "is greater than or equal to", + "\\leq": "is less than or equal to", + "\\le": "is less than or equal to", + ">": "is greater than", + "<": "is less than", + "\\leftarrow": "left arrow", + "\\Leftarrow": "left arrow", + "\\rightarrow": "right arrow", + "\\Rightarrow": "right arrow", + ":": "colon" +}; +var accentUnderMap = { + "\\underleftarrow": "left arrow", + "\\underrightarrow": "right arrow", + "\\underleftrightarrow": "left-right arrow", + "\\undergroup": "group", + "\\underlinesegment": "line segment", + "\\utilde": "tilde" +}; +var buildString = (str, type, a11yStrings) => { + if (!str) { + return; + } + var ret; + if (type === "open") { + ret = str in openMap ? openMap[str] : stringMap[str] || str; + } else if (type === "close") { + ret = str in closeMap ? closeMap[str] : stringMap[str] || str; + } else if (type === "bin") { + ret = binMap[str] || str; + } else if (type === "rel") { + ret = relMap[str] || str; + } else { + ret = stringMap[str] || str; + } + // If the text to add is a number and there is already a string + // in the list and the last string is a number then we should + // combine them into a single number + var last = a11yStrings[a11yStrings.length - 1]; + if (/^\d+$/.test(ret) && a11yStrings.length > 0 && typeof last === "string" && /^\d+$/.test(last)) { + a11yStrings[a11yStrings.length - 1] += ret; + } else if (ret) { + a11yStrings.push(ret); + } +}; +var buildRegion = (a11yStrings, callback) => { + var regionStrings = []; + a11yStrings.push(regionStrings); + callback(regionStrings); +}; +var handleObject = (tree, a11yStrings, atomType) => { + // Everything else is assumed to be an object... + switch (tree.type) { + case "accent": + { + buildRegion(a11yStrings, a11yStrings => { + _buildA11yStrings(tree.base, a11yStrings, atomType); + a11yStrings.push("with"); + buildString(tree.label, "normal", a11yStrings); + a11yStrings.push("on top"); + }); + break; + } + case "accentUnder": + { + buildRegion(a11yStrings, a11yStrings => { + _buildA11yStrings(tree.base, a11yStrings, atomType); + a11yStrings.push("with"); + buildString(accentUnderMap[tree.label], "normal", a11yStrings); + a11yStrings.push("underneath"); + }); + break; + } + case "accent-token": + { + // Used internally by accent symbols. + break; + } + case "atom": + { + var { + text + } = tree; + switch (tree.family) { + case "bin": + { + buildString(text, "bin", a11yStrings); + break; + } + case "close": + { + buildString(text, "close", a11yStrings); + break; + } + // TODO(kevinb): figure out what should be done for inner + case "inner": + { + buildString(tree.text, "inner", a11yStrings); + break; + } + case "open": + { + buildString(text, "open", a11yStrings); + break; + } + case "punct": + { + buildString(text, "punct", a11yStrings); + break; + } + case "rel": + { + buildString(text, "rel", a11yStrings); + break; + } + default: + { + tree.family; + throw new Error("\"" + tree.family + "\" is not a valid atom type"); + } + } + break; + } + case "color": + { + var color = tree.color.replace(/katex-/, ""); + buildRegion(a11yStrings, regionStrings => { + regionStrings.push("start color " + color); + _buildA11yStrings(tree.body, regionStrings, atomType); + regionStrings.push("end color " + color); + }); + break; + } + case "color-token": + { + // Used by \color, \colorbox, and \fcolorbox but not directly rendered. + // It's a leaf node and has no children so just break. + break; + } + case "delimsizing": + { + if (tree.delim && tree.delim !== ".") { + buildString(tree.delim, "normal", a11yStrings); + } + break; + } + case "genfrac": + { + buildRegion(a11yStrings, regionStrings => { + // genfrac can have unbalanced delimiters + var { + leftDelim, + rightDelim + } = tree; + // NOTE: Not sure if this is a safe assumption + // hasBarLine true -> fraction, false -> binomial + if (tree.hasBarLine) { + regionStrings.push("start fraction"); + leftDelim && buildString(leftDelim, "open", regionStrings); + _buildA11yStrings(tree.numer, regionStrings, atomType); + regionStrings.push("divided by"); + _buildA11yStrings(tree.denom, regionStrings, atomType); + rightDelim && buildString(rightDelim, "close", regionStrings); + regionStrings.push("end fraction"); + } else { + regionStrings.push("start binomial"); + leftDelim && buildString(leftDelim, "open", regionStrings); + _buildA11yStrings(tree.numer, regionStrings, atomType); + regionStrings.push("over"); + _buildA11yStrings(tree.denom, regionStrings, atomType); + rightDelim && buildString(rightDelim, "close", regionStrings); + regionStrings.push("end binomial"); + } + }); + break; + } + case "hbox": + { + _buildA11yStrings(tree.body, a11yStrings, atomType); + break; + } + case "kern": + { + // No op: we don't attempt to present kerning information + // to the screen reader. + break; + } + case "leftright": + { + buildRegion(a11yStrings, regionStrings => { + buildString(tree.left, "open", regionStrings); + _buildA11yStrings(tree.body, regionStrings, atomType); + buildString(tree.right, "close", regionStrings); + }); + break; + } + case "leftright-right": + { + // TODO: double check that this is a no-op + break; + } + case "lap": + { + _buildA11yStrings(tree.body, a11yStrings, atomType); + break; + } + case "mathord": + { + buildString(tree.text, "normal", a11yStrings); + break; + } + case "op": + { + var { + body, + name + } = tree; + if (body) { + _buildA11yStrings(body, a11yStrings, atomType); + } else if (name) { + buildString(name, "normal", a11yStrings); + } + break; + } + case "op-token": + { + // Used internally by operator symbols. + buildString(tree.text, atomType, a11yStrings); + break; + } + case "ordgroup": + { + _buildA11yStrings(tree.body, a11yStrings, atomType); + break; + } + case "overline": + { + buildRegion(a11yStrings, function (a11yStrings) { + a11yStrings.push("start overline"); + _buildA11yStrings(tree.body, a11yStrings, atomType); + a11yStrings.push("end overline"); + }); + break; + } + case "pmb": + { + a11yStrings.push("bold"); + break; + } + case "phantom": + { + a11yStrings.push("empty space"); + break; + } + case "raisebox": + { + _buildA11yStrings(tree.body, a11yStrings, atomType); + break; + } + case "rule": + { + a11yStrings.push("rectangle"); + break; + } + case "sizing": + { + _buildA11yStrings(tree.body, a11yStrings, atomType); + break; + } + case "spacing": + { + a11yStrings.push("space"); + break; + } + case "styling": + { + // We ignore the styling and just pass through the contents + _buildA11yStrings(tree.body, a11yStrings, atomType); + break; + } + case "sqrt": + { + buildRegion(a11yStrings, regionStrings => { + var { + body, + index + } = tree; + if (index) { + var indexString = _flatten(_buildA11yStrings(index, [], atomType)).join(","); + if (indexString === "3") { + regionStrings.push("cube root of"); + _buildA11yStrings(body, regionStrings, atomType); + regionStrings.push("end cube root"); + return; + } + regionStrings.push("root"); + regionStrings.push("start index"); + _buildA11yStrings(index, regionStrings, atomType); + regionStrings.push("end index"); + return; + } + regionStrings.push("square root of"); + _buildA11yStrings(body, regionStrings, atomType); + regionStrings.push("end square root"); + }); + break; + } + case "supsub": + { + var { + base, + sub, + sup + } = tree; + var isLog = false; + if (base) { + _buildA11yStrings(base, a11yStrings, atomType); + isLog = base.type === "op" && base.name === "\\log"; + } + if (sub) { + var regionName = isLog ? "base" : "subscript"; + buildRegion(a11yStrings, function (regionStrings) { + regionStrings.push("start " + regionName); + _buildA11yStrings(sub, regionStrings, atomType); + regionStrings.push("end " + regionName); + }); + } + if (sup) { + buildRegion(a11yStrings, function (regionStrings) { + var supString = _flatten(_buildA11yStrings(sup, [], atomType)).join(","); + if (supString in powerMap) { + regionStrings.push(powerMap[supString]); + return; + } + regionStrings.push("start superscript"); + _buildA11yStrings(sup, regionStrings, atomType); + regionStrings.push("end superscript"); + }); + } + break; + } + case "text": + { + // TODO: handle other fonts + if (tree.font === "\\textbf") { + buildRegion(a11yStrings, function (regionStrings) { + regionStrings.push("start bold text"); + _buildA11yStrings(tree.body, regionStrings, atomType); + regionStrings.push("end bold text"); + }); + break; + } + buildRegion(a11yStrings, function (regionStrings) { + regionStrings.push("start text"); + _buildA11yStrings(tree.body, regionStrings, atomType); + regionStrings.push("end text"); + }); + break; + } + case "textord": + { + buildString(tree.text, atomType, a11yStrings); + break; + } + case "smash": + { + _buildA11yStrings(tree.body, a11yStrings, atomType); + break; + } + case "enclose": + { + // TODO: create a map for these. + // TODO: differentiate between a body with a single atom, e.g. + // "cancel a" instead of "start cancel, a, end cancel" + if (/cancel/.test(tree.label)) { + buildRegion(a11yStrings, function (regionStrings) { + regionStrings.push("start cancel"); + _buildA11yStrings(tree.body, regionStrings, atomType); + regionStrings.push("end cancel"); + }); + break; + } else if (/box/.test(tree.label)) { + buildRegion(a11yStrings, function (regionStrings) { + regionStrings.push("start box"); + _buildA11yStrings(tree.body, regionStrings, atomType); + regionStrings.push("end box"); + }); + break; + } else if (/sout/.test(tree.label)) { + buildRegion(a11yStrings, function (regionStrings) { + regionStrings.push("start strikeout"); + _buildA11yStrings(tree.body, regionStrings, atomType); + regionStrings.push("end strikeout"); + }); + break; + } else if (/phase/.test(tree.label)) { + buildRegion(a11yStrings, function (regionStrings) { + regionStrings.push("start phase angle"); + _buildA11yStrings(tree.body, regionStrings, atomType); + regionStrings.push("end phase angle"); + }); + break; + } + throw new Error("KaTeX-a11y: enclose node with " + tree.label + " not supported yet"); + } + case "vcenter": + { + _buildA11yStrings(tree.body, a11yStrings, atomType); + break; + } + case "vphantom": + { + throw new Error("KaTeX-a11y: vphantom not implemented yet"); + } + case "operatorname": + { + _buildA11yStrings(tree.body, a11yStrings, atomType); + break; + } + case "array": + { + throw new Error("KaTeX-a11y: array not implemented yet"); + } + case "raw": + { + throw new Error("KaTeX-a11y: raw not implemented yet"); + } + case "size": + { + // Although there are nodes of type "size" in the parse tree, they have + // no semantic meaning and should be ignored. + break; + } + case "url": + { + throw new Error("KaTeX-a11y: url not implemented yet"); + } + case "tag": + { + throw new Error("KaTeX-a11y: tag not implemented yet"); + } + case "verb": + { + buildString("start verbatim", "normal", a11yStrings); + buildString(tree.body, "normal", a11yStrings); + buildString("end verbatim", "normal", a11yStrings); + break; + } + case "environment": + { + throw new Error("KaTeX-a11y: environment not implemented yet"); + } + case "horizBrace": + { + buildString("start " + tree.label.slice(1), "normal", a11yStrings); + _buildA11yStrings(tree.base, a11yStrings, atomType); + buildString("end " + tree.label.slice(1), "normal", a11yStrings); + break; + } + case "infix": + { + // All infix nodes are replace with other nodes. + break; + } + case "includegraphics": + { + throw new Error("KaTeX-a11y: includegraphics not implemented yet"); + } + case "font": + { + // TODO: callout the start/end of specific fonts + // TODO: map \BBb{N} to "the naturals" or something like that + _buildA11yStrings(tree.body, a11yStrings, atomType); + break; + } + case "href": + { + throw new Error("KaTeX-a11y: href not implemented yet"); + } + case "cr": + { + // This is used by environments. + throw new Error("KaTeX-a11y: cr not implemented yet"); + } + case "underline": + { + buildRegion(a11yStrings, function (a11yStrings) { + a11yStrings.push("start underline"); + _buildA11yStrings(tree.body, a11yStrings, atomType); + a11yStrings.push("end underline"); + }); + break; + } + case "xArrow": + { + throw new Error("KaTeX-a11y: xArrow not implemented yet"); + } + case "cdlabel": + { + throw new Error("KaTeX-a11y: cdlabel not implemented yet"); + } + case "cdlabelparent": + { + throw new Error("KaTeX-a11y: cdlabelparent not implemented yet"); + } + case "mclass": + { + // \neq and \ne are macros so we let "htmlmathml" render the mathmal + // side of things and extract the text from that. + // mclass values are prefixed with "m" (e.g. "mrel" -> "rel") + var _atomType = tree.mclass.slice(1); + if (_atomType === "normal" || isAtom(_atomType)) { + _buildA11yStrings(tree.body, a11yStrings, _atomType); + } else { + throw new Error("Unexpected mclass atom type: \"" + _atomType + "\""); + } + break; + } + case "mathchoice": + { + // TODO: track which style we're using, e.g. display, text, etc. + // default to text style if even that may not be the correct style + _buildA11yStrings(tree.text, a11yStrings, atomType); + break; + } + case "htmlmathml": + { + _buildA11yStrings(tree.mathml, a11yStrings, atomType); + break; + } + case "middle": + { + buildString(tree.delim, atomType, a11yStrings); + break; + } + case "internal": + { + // internal nodes are never included in the parse tree + break; + } + case "html": + { + _buildA11yStrings(tree.body, a11yStrings, atomType); + break; + } + default: + throw new Error("KaTeX a11y un-recognized type: " + tree.type); + } +}; +var _buildA11yStrings = function buildA11yStrings(tree, a11yStrings, atomType) { + if (a11yStrings === void 0) { + a11yStrings = []; + } + if (tree instanceof Array) { + for (var i = 0; i < tree.length; i++) { + _buildA11yStrings(tree[i], a11yStrings, atomType); + } + } else { + handleObject(tree, a11yStrings, atomType); + } + return a11yStrings; +}; +var _flatten = function flatten(array) { + var result = []; + array.forEach(function (item) { + if (Array.isArray(item)) { + result = result.concat(_flatten(item)); + } else { + result.push(item); + } + }); + return result; +}; +var renderA11yString = function renderA11yString(text, settings) { + var tree = katex.__parse(text, settings); + var a11yStrings = _buildA11yStrings(tree, [], "normal"); + return _flatten(a11yStrings).join(", "); +}; + +export { renderA11yString as default }; diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_AMS-Regular.ttf b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_AMS-Regular.ttf new file mode 100644 index 0000000..c6f9a5e Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_AMS-Regular.ttf differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_AMS-Regular.woff b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_AMS-Regular.woff new file mode 100644 index 0000000..b804d7b Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_AMS-Regular.woff differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_AMS-Regular.woff2 b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_AMS-Regular.woff2 new file mode 100644 index 0000000..0acaaff Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_AMS-Regular.woff2 differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Caligraphic-Bold.ttf b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Caligraphic-Bold.ttf new file mode 100644 index 0000000..9ff4a5e Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Caligraphic-Bold.ttf differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Caligraphic-Bold.woff b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Caligraphic-Bold.woff new file mode 100644 index 0000000..9759710 Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Caligraphic-Bold.woff differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Caligraphic-Bold.woff2 b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Caligraphic-Bold.woff2 new file mode 100644 index 0000000..f390922 Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Caligraphic-Bold.woff2 differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Caligraphic-Regular.ttf b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Caligraphic-Regular.ttf new file mode 100644 index 0000000..f522294 Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Caligraphic-Regular.ttf differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Caligraphic-Regular.woff b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Caligraphic-Regular.woff new file mode 100644 index 0000000..9bdd534 Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Caligraphic-Regular.woff differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Caligraphic-Regular.woff2 b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Caligraphic-Regular.woff2 new file mode 100644 index 0000000..75344a1 Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Caligraphic-Regular.woff2 differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Fraktur-Bold.ttf b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Fraktur-Bold.ttf new file mode 100644 index 0000000..4e98259 Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Fraktur-Bold.ttf differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Fraktur-Bold.woff b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Fraktur-Bold.woff new file mode 100644 index 0000000..e7730f6 Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Fraktur-Bold.woff differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Fraktur-Bold.woff2 b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Fraktur-Bold.woff2 new file mode 100644 index 0000000..395f28b Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Fraktur-Bold.woff2 differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Fraktur-Regular.ttf b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Fraktur-Regular.ttf new file mode 100644 index 0000000..b8461b2 Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Fraktur-Regular.ttf differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Fraktur-Regular.woff b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Fraktur-Regular.woff new file mode 100644 index 0000000..acab069 Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Fraktur-Regular.woff differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Fraktur-Regular.woff2 b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Fraktur-Regular.woff2 new file mode 100644 index 0000000..735f694 Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Fraktur-Regular.woff2 differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Main-Bold.ttf b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Main-Bold.ttf new file mode 100644 index 0000000..4060e62 Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Main-Bold.ttf differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Main-Bold.woff b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Main-Bold.woff new file mode 100644 index 0000000..f38136a Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Main-Bold.woff differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Main-Bold.woff2 b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Main-Bold.woff2 new file mode 100644 index 0000000..ab2ad21 Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Main-Bold.woff2 differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Main-BoldItalic.ttf b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Main-BoldItalic.ttf new file mode 100644 index 0000000..dc00797 Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Main-BoldItalic.ttf differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Main-BoldItalic.woff b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Main-BoldItalic.woff new file mode 100644 index 0000000..67807b0 Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Main-BoldItalic.woff differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Main-BoldItalic.woff2 b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Main-BoldItalic.woff2 new file mode 100644 index 0000000..5931794 Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Main-BoldItalic.woff2 differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Main-Italic.ttf b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Main-Italic.ttf new file mode 100644 index 0000000..0e9b0f3 Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Main-Italic.ttf differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Main-Italic.woff b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Main-Italic.woff new file mode 100644 index 0000000..6f43b59 Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Main-Italic.woff differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Main-Italic.woff2 b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Main-Italic.woff2 new file mode 100644 index 0000000..b50920e Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Main-Italic.woff2 differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Main-Regular.ttf b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Main-Regular.ttf new file mode 100644 index 0000000..dd45e1e Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Main-Regular.ttf differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Main-Regular.woff b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Main-Regular.woff new file mode 100644 index 0000000..21f5812 Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Main-Regular.woff differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Main-Regular.woff2 b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Main-Regular.woff2 new file mode 100644 index 0000000..eb24a7b Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Main-Regular.woff2 differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Math-BoldItalic.ttf b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Math-BoldItalic.ttf new file mode 100644 index 0000000..728ce7a Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Math-BoldItalic.ttf differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Math-BoldItalic.woff b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Math-BoldItalic.woff new file mode 100644 index 0000000..0ae390d Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Math-BoldItalic.woff differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Math-BoldItalic.woff2 b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Math-BoldItalic.woff2 new file mode 100644 index 0000000..2965702 Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Math-BoldItalic.woff2 differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Math-Italic.ttf b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Math-Italic.ttf new file mode 100644 index 0000000..70d559b Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Math-Italic.ttf differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Math-Italic.woff b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Math-Italic.woff new file mode 100644 index 0000000..eb5159d Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Math-Italic.woff differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Math-Italic.woff2 b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Math-Italic.woff2 new file mode 100644 index 0000000..215c143 Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Math-Italic.woff2 differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_SansSerif-Bold.ttf b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_SansSerif-Bold.ttf new file mode 100644 index 0000000..2f65a8a Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_SansSerif-Bold.ttf differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_SansSerif-Bold.woff b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_SansSerif-Bold.woff new file mode 100644 index 0000000..8d47c02 Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_SansSerif-Bold.woff differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_SansSerif-Bold.woff2 b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_SansSerif-Bold.woff2 new file mode 100644 index 0000000..cfaa3bd Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_SansSerif-Bold.woff2 differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_SansSerif-Italic.ttf b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_SansSerif-Italic.ttf new file mode 100644 index 0000000..d5850df Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_SansSerif-Italic.ttf differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_SansSerif-Italic.woff b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_SansSerif-Italic.woff new file mode 100644 index 0000000..7e02df9 Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_SansSerif-Italic.woff differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_SansSerif-Italic.woff2 b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_SansSerif-Italic.woff2 new file mode 100644 index 0000000..349c06d Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_SansSerif-Italic.woff2 differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_SansSerif-Regular.ttf b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_SansSerif-Regular.ttf new file mode 100644 index 0000000..537279f Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_SansSerif-Regular.ttf differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_SansSerif-Regular.woff b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_SansSerif-Regular.woff new file mode 100644 index 0000000..31b8482 Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_SansSerif-Regular.woff differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_SansSerif-Regular.woff2 b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_SansSerif-Regular.woff2 new file mode 100644 index 0000000..a90eea8 Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_SansSerif-Regular.woff2 differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Script-Regular.ttf b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Script-Regular.ttf new file mode 100644 index 0000000..fd679bf Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Script-Regular.ttf differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Script-Regular.woff b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Script-Regular.woff new file mode 100644 index 0000000..0e7da82 Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Script-Regular.woff differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Script-Regular.woff2 b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Script-Regular.woff2 new file mode 100644 index 0000000..b3048fc Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Script-Regular.woff2 differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Size1-Regular.ttf b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Size1-Regular.ttf new file mode 100644 index 0000000..871fd7d Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Size1-Regular.ttf differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Size1-Regular.woff b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Size1-Regular.woff new file mode 100644 index 0000000..7f292d9 Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Size1-Regular.woff differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Size1-Regular.woff2 b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Size1-Regular.woff2 new file mode 100644 index 0000000..c5a8462 Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Size1-Regular.woff2 differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Size2-Regular.ttf b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Size2-Regular.ttf new file mode 100644 index 0000000..7a212ca Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Size2-Regular.ttf differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Size2-Regular.woff b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Size2-Regular.woff new file mode 100644 index 0000000..d241d9b Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Size2-Regular.woff differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Size2-Regular.woff2 b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Size2-Regular.woff2 new file mode 100644 index 0000000..e1bccfe Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Size2-Regular.woff2 differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Size3-Regular.ttf b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Size3-Regular.ttf new file mode 100644 index 0000000..00bff34 Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Size3-Regular.ttf differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Size3-Regular.woff b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Size3-Regular.woff new file mode 100644 index 0000000..e6e9b65 Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Size3-Regular.woff differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Size3-Regular.woff2 b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Size3-Regular.woff2 new file mode 100644 index 0000000..249a286 Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Size3-Regular.woff2 differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Size4-Regular.ttf b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Size4-Regular.ttf new file mode 100644 index 0000000..74f0892 Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Size4-Regular.ttf differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Size4-Regular.woff b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Size4-Regular.woff new file mode 100644 index 0000000..e1ec545 Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Size4-Regular.woff differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Size4-Regular.woff2 b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Size4-Regular.woff2 new file mode 100644 index 0000000..680c130 Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Size4-Regular.woff2 differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Typewriter-Regular.ttf b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Typewriter-Regular.ttf new file mode 100644 index 0000000..c83252c Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Typewriter-Regular.ttf differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Typewriter-Regular.woff b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Typewriter-Regular.woff new file mode 100644 index 0000000..2432419 Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Typewriter-Regular.woff differ diff --git a/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Typewriter-Regular.woff2 b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Typewriter-Regular.woff2 new file mode 100644 index 0000000..771f1af Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/dist/fonts/KaTeX_Typewriter-Regular.woff2 differ diff --git a/node_modules/react-katex/node_modules/katex/dist/katex-swap.css b/node_modules/react-katex/node_modules/katex/dist/katex-swap.css new file mode 100644 index 0000000..c5bafd1 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/dist/katex-swap.css @@ -0,0 +1,1241 @@ +/* stylelint-disable font-family-no-missing-generic-family-keyword */ +@font-face { + font-family: "KaTeX_AMS"; + src: url(fonts/KaTeX_AMS-Regular.woff2) format("woff2"), url(fonts/KaTeX_AMS-Regular.woff) format("woff"), url(fonts/KaTeX_AMS-Regular.ttf) format("truetype"); + font-weight: normal; + font-style: normal; + font-display: swap; +} +@font-face { + font-family: "KaTeX_Caligraphic"; + src: url(fonts/KaTeX_Caligraphic-Bold.woff2) format("woff2"), url(fonts/KaTeX_Caligraphic-Bold.woff) format("woff"), url(fonts/KaTeX_Caligraphic-Bold.ttf) format("truetype"); + font-weight: bold; + font-style: normal; + font-display: swap; +} +@font-face { + font-family: "KaTeX_Caligraphic"; + src: url(fonts/KaTeX_Caligraphic-Regular.woff2) format("woff2"), url(fonts/KaTeX_Caligraphic-Regular.woff) format("woff"), url(fonts/KaTeX_Caligraphic-Regular.ttf) format("truetype"); + font-weight: normal; + font-style: normal; + font-display: swap; +} +@font-face { + font-family: "KaTeX_Fraktur"; + src: url(fonts/KaTeX_Fraktur-Bold.woff2) format("woff2"), url(fonts/KaTeX_Fraktur-Bold.woff) format("woff"), url(fonts/KaTeX_Fraktur-Bold.ttf) format("truetype"); + font-weight: bold; + font-style: normal; + font-display: swap; +} +@font-face { + font-family: "KaTeX_Fraktur"; + src: url(fonts/KaTeX_Fraktur-Regular.woff2) format("woff2"), url(fonts/KaTeX_Fraktur-Regular.woff) format("woff"), url(fonts/KaTeX_Fraktur-Regular.ttf) format("truetype"); + font-weight: normal; + font-style: normal; + font-display: swap; +} +@font-face { + font-family: "KaTeX_Main"; + src: url(fonts/KaTeX_Main-Bold.woff2) format("woff2"), url(fonts/KaTeX_Main-Bold.woff) format("woff"), url(fonts/KaTeX_Main-Bold.ttf) format("truetype"); + font-weight: bold; + font-style: normal; + font-display: swap; +} +@font-face { + font-family: "KaTeX_Main"; + src: url(fonts/KaTeX_Main-BoldItalic.woff2) format("woff2"), url(fonts/KaTeX_Main-BoldItalic.woff) format("woff"), url(fonts/KaTeX_Main-BoldItalic.ttf) format("truetype"); + font-weight: bold; + font-style: italic; + font-display: swap; +} +@font-face { + font-family: "KaTeX_Main"; + src: url(fonts/KaTeX_Main-Italic.woff2) format("woff2"), url(fonts/KaTeX_Main-Italic.woff) format("woff"), url(fonts/KaTeX_Main-Italic.ttf) format("truetype"); + font-weight: normal; + font-style: italic; + font-display: swap; +} +@font-face { + font-family: "KaTeX_Main"; + src: url(fonts/KaTeX_Main-Regular.woff2) format("woff2"), url(fonts/KaTeX_Main-Regular.woff) format("woff"), url(fonts/KaTeX_Main-Regular.ttf) format("truetype"); + font-weight: normal; + font-style: normal; + font-display: swap; +} +@font-face { + font-family: "KaTeX_Math"; + src: url(fonts/KaTeX_Math-BoldItalic.woff2) format("woff2"), url(fonts/KaTeX_Math-BoldItalic.woff) format("woff"), url(fonts/KaTeX_Math-BoldItalic.ttf) format("truetype"); + font-weight: bold; + font-style: italic; + font-display: swap; +} +@font-face { + font-family: "KaTeX_Math"; + src: url(fonts/KaTeX_Math-Italic.woff2) format("woff2"), url(fonts/KaTeX_Math-Italic.woff) format("woff"), url(fonts/KaTeX_Math-Italic.ttf) format("truetype"); + font-weight: normal; + font-style: italic; + font-display: swap; +} +@font-face { + font-family: "KaTeX_SansSerif"; + src: url(fonts/KaTeX_SansSerif-Bold.woff2) format("woff2"), url(fonts/KaTeX_SansSerif-Bold.woff) format("woff"), url(fonts/KaTeX_SansSerif-Bold.ttf) format("truetype"); + font-weight: bold; + font-style: normal; + font-display: swap; +} +@font-face { + font-family: "KaTeX_SansSerif"; + src: url(fonts/KaTeX_SansSerif-Italic.woff2) format("woff2"), url(fonts/KaTeX_SansSerif-Italic.woff) format("woff"), url(fonts/KaTeX_SansSerif-Italic.ttf) format("truetype"); + font-weight: normal; + font-style: italic; + font-display: swap; +} +@font-face { + font-family: "KaTeX_SansSerif"; + src: url(fonts/KaTeX_SansSerif-Regular.woff2) format("woff2"), url(fonts/KaTeX_SansSerif-Regular.woff) format("woff"), url(fonts/KaTeX_SansSerif-Regular.ttf) format("truetype"); + font-weight: normal; + font-style: normal; + font-display: swap; +} +@font-face { + font-family: "KaTeX_Script"; + src: url(fonts/KaTeX_Script-Regular.woff2) format("woff2"), url(fonts/KaTeX_Script-Regular.woff) format("woff"), url(fonts/KaTeX_Script-Regular.ttf) format("truetype"); + font-weight: normal; + font-style: normal; + font-display: swap; +} +@font-face { + font-family: "KaTeX_Size1"; + src: url(fonts/KaTeX_Size1-Regular.woff2) format("woff2"), url(fonts/KaTeX_Size1-Regular.woff) format("woff"), url(fonts/KaTeX_Size1-Regular.ttf) format("truetype"); + font-weight: normal; + font-style: normal; + font-display: swap; +} +@font-face { + font-family: "KaTeX_Size2"; + src: url(fonts/KaTeX_Size2-Regular.woff2) format("woff2"), url(fonts/KaTeX_Size2-Regular.woff) format("woff"), url(fonts/KaTeX_Size2-Regular.ttf) format("truetype"); + font-weight: normal; + font-style: normal; + font-display: swap; +} +@font-face { + font-family: "KaTeX_Size3"; + src: url(fonts/KaTeX_Size3-Regular.woff2) format("woff2"), url(fonts/KaTeX_Size3-Regular.woff) format("woff"), url(fonts/KaTeX_Size3-Regular.ttf) format("truetype"); + font-weight: normal; + font-style: normal; + font-display: swap; +} +@font-face { + font-family: "KaTeX_Size4"; + src: url(fonts/KaTeX_Size4-Regular.woff2) format("woff2"), url(fonts/KaTeX_Size4-Regular.woff) format("woff"), url(fonts/KaTeX_Size4-Regular.ttf) format("truetype"); + font-weight: normal; + font-style: normal; + font-display: swap; +} +@font-face { + font-family: "KaTeX_Typewriter"; + src: url(fonts/KaTeX_Typewriter-Regular.woff2) format("woff2"), url(fonts/KaTeX_Typewriter-Regular.woff) format("woff"), url(fonts/KaTeX_Typewriter-Regular.ttf) format("truetype"); + font-weight: normal; + font-style: normal; + font-display: swap; +} +/* stylelint-disable font-family-no-missing-generic-family-keyword */ +.katex { + font: normal 1.21em KaTeX_Main, Times New Roman, serif; + line-height: 1.2; + position: relative; + text-indent: 0; + text-rendering: auto; +} +.katex * { + -ms-high-contrast-adjust: none !important; +} +.katex * { + border-color: currentColor; +} +.katex .katex-version::after { + content: "0.16.47"; +} +.katex .katex-mathml { + /* Accessibility hack to only show to screen readers + Found at: http://a11yproject.com/posts/how-to-hide-content/ */ + position: absolute; + -webkit-clip-path: inset(50%); + clip-path: inset(50%); + padding: 0; + border: 0; + height: 1px; + width: 1px; + overflow: hidden; +} +.katex .katex-html { + /* \newline is an empty block at top level, between .base elements */ +} +.katex .katex-html > .newline { + display: block; +} +.katex .base { + position: relative; + display: inline-block; + white-space: nowrap; + width: -webkit-min-content; + width: -moz-min-content; + width: min-content; +} +.katex .strut { + display: inline-block; +} +.katex .textbf { + font-weight: bold; +} +.katex .textit { + font-style: italic; +} +.katex .textrm { + font-family: KaTeX_Main; +} +.katex .textsf { + font-family: KaTeX_SansSerif; +} +.katex .texttt { + font-family: KaTeX_Typewriter; +} +.katex .mathnormal { + font-family: KaTeX_Math; + font-style: italic; +} +.katex .mathit { + font-family: KaTeX_Main; + font-style: italic; +} +.katex .mathrm { + font-style: normal; +} +.katex .mathbf { + font-family: KaTeX_Main; + font-weight: bold; +} +.katex .boldsymbol { + font-family: KaTeX_Math; + font-weight: bold; + font-style: italic; +} +.katex .amsrm { + font-family: KaTeX_AMS; +} +.katex .mathbb, +.katex .textbb { + font-family: KaTeX_AMS; +} +.katex .mathcal { + font-family: KaTeX_Caligraphic; +} +.katex .mathfrak, +.katex .textfrak { + font-family: KaTeX_Fraktur; +} +.katex .mathboldfrak, +.katex .textboldfrak { + font-family: KaTeX_Fraktur; + font-weight: bold; +} +.katex .mathtt { + font-family: KaTeX_Typewriter; +} +.katex .mathscr, +.katex .textscr { + font-family: KaTeX_Script; +} +.katex .mathsf, +.katex .textsf { + font-family: KaTeX_SansSerif; +} +.katex .mathboldsf, +.katex .textboldsf { + font-family: KaTeX_SansSerif; + font-weight: bold; +} +.katex .mathsfit, +.katex .mathitsf, +.katex .textitsf { + font-family: KaTeX_SansSerif; + font-style: italic; +} +.katex .mainrm { + font-family: KaTeX_Main; + font-style: normal; +} +.katex .vlist-t { + display: inline-table; + table-layout: fixed; + border-collapse: collapse; +} +.katex .vlist-r { + display: table-row; +} +.katex .vlist { + display: table-cell; + vertical-align: bottom; + position: relative; +} +.katex .vlist > span { + display: block; + height: 0; + position: relative; +} +.katex .vlist > span > span { + display: inline-block; +} +.katex .vlist > span > .pstrut { + overflow: hidden; + width: 0; +} +.katex .vlist-t2 { + margin-right: -2px; +} +.katex .vlist-s { + display: table-cell; + vertical-align: bottom; + font-size: 1px; + width: 2px; + min-width: 2px; +} +.katex .vbox { + display: inline-flex; + flex-direction: column; + align-items: baseline; +} +.katex .hbox { + display: inline-flex; + flex-direction: row; + width: 100%; +} +.katex .thinbox { + display: inline-flex; + flex-direction: row; + width: 0; + max-width: 0; +} +.katex .msupsub { + text-align: left; +} +.katex .mfrac > span > span { + text-align: center; +} +.katex .mfrac .frac-line { + display: inline-block; + width: 100%; + border-bottom-style: solid; +} +.katex .mfrac .frac-line, +.katex .overline .overline-line, +.katex .underline .underline-line, +.katex .hline, +.katex .hdashline, +.katex .rule { + min-height: 1px; +} +.katex .mspace { + display: inline-block; +} +.katex .smash { + display: inline; + line-height: 0; +} +.katex .llap, +.katex .rlap, +.katex .clap { + width: 0; + position: relative; +} +.katex .llap > .inner, +.katex .rlap > .inner, +.katex .clap > .inner { + position: absolute; +} +.katex .llap > .fix, +.katex .rlap > .fix, +.katex .clap > .fix { + display: inline-block; +} +.katex .llap > .inner { + right: 0; +} +.katex .rlap > .inner, +.katex .clap > .inner { + left: 0; +} +.katex .clap > .inner > span { + margin-left: -50%; + margin-right: 50%; +} +.katex .rule { + display: inline-block; + border: solid 0; + position: relative; +} +.katex .overline .overline-line, +.katex .underline .underline-line, +.katex .hline { + display: inline-block; + width: 100%; + border-bottom-style: solid; +} +.katex .hdashline { + display: inline-block; + width: 100%; + border-bottom-style: dashed; +} +.katex .sqrt > .root { + /* These values are taken from the definition of `\r@@t`, + `\mkern 5mu` and `\mkern -10mu`. */ + /* stylelint-disable-next-line declaration-property-value-no-unknown */ + margin-left: 0.2777777778em; + /* stylelint-disable-next-line declaration-property-value-no-unknown */ + margin-right: -0.5555555556em; +} +.katex .sizing.reset-size1.size1, +.katex .fontsize-ensurer.reset-size1.size1 { + /* stylelint-disable-next-line */ + font-size: 1em; +} +.katex .sizing.reset-size1.size2, +.katex .fontsize-ensurer.reset-size1.size2 { + /* stylelint-disable-next-line */ + font-size: 1.2em; +} +.katex .sizing.reset-size1.size3, +.katex .fontsize-ensurer.reset-size1.size3 { + /* stylelint-disable-next-line */ + font-size: 1.4em; +} +.katex .sizing.reset-size1.size4, +.katex .fontsize-ensurer.reset-size1.size4 { + /* stylelint-disable-next-line */ + font-size: 1.6em; +} +.katex .sizing.reset-size1.size5, +.katex .fontsize-ensurer.reset-size1.size5 { + /* stylelint-disable-next-line */ + font-size: 1.8em; +} +.katex .sizing.reset-size1.size6, +.katex .fontsize-ensurer.reset-size1.size6 { + /* stylelint-disable-next-line */ + font-size: 2em; +} +.katex .sizing.reset-size1.size7, +.katex .fontsize-ensurer.reset-size1.size7 { + /* stylelint-disable-next-line */ + font-size: 2.4em; +} +.katex .sizing.reset-size1.size8, +.katex .fontsize-ensurer.reset-size1.size8 { + /* stylelint-disable-next-line */ + font-size: 2.88em; +} +.katex .sizing.reset-size1.size9, +.katex .fontsize-ensurer.reset-size1.size9 { + /* stylelint-disable-next-line */ + font-size: 3.456em; +} +.katex .sizing.reset-size1.size10, +.katex .fontsize-ensurer.reset-size1.size10 { + /* stylelint-disable-next-line */ + font-size: 4.148em; +} +.katex .sizing.reset-size1.size11, +.katex .fontsize-ensurer.reset-size1.size11 { + /* stylelint-disable-next-line */ + font-size: 4.976em; +} +.katex .sizing.reset-size2.size1, +.katex .fontsize-ensurer.reset-size2.size1 { + /* stylelint-disable-next-line */ + font-size: 0.8333333333em; +} +.katex .sizing.reset-size2.size2, +.katex .fontsize-ensurer.reset-size2.size2 { + /* stylelint-disable-next-line */ + font-size: 1em; +} +.katex .sizing.reset-size2.size3, +.katex .fontsize-ensurer.reset-size2.size3 { + /* stylelint-disable-next-line */ + font-size: 1.1666666667em; +} +.katex .sizing.reset-size2.size4, +.katex .fontsize-ensurer.reset-size2.size4 { + /* stylelint-disable-next-line */ + font-size: 1.3333333333em; +} +.katex .sizing.reset-size2.size5, +.katex .fontsize-ensurer.reset-size2.size5 { + /* stylelint-disable-next-line */ + font-size: 1.5em; +} +.katex .sizing.reset-size2.size6, +.katex .fontsize-ensurer.reset-size2.size6 { + /* stylelint-disable-next-line */ + font-size: 1.6666666667em; +} +.katex .sizing.reset-size2.size7, +.katex .fontsize-ensurer.reset-size2.size7 { + /* stylelint-disable-next-line */ + font-size: 2em; +} +.katex .sizing.reset-size2.size8, +.katex .fontsize-ensurer.reset-size2.size8 { + /* stylelint-disable-next-line */ + font-size: 2.4em; +} +.katex .sizing.reset-size2.size9, +.katex .fontsize-ensurer.reset-size2.size9 { + /* stylelint-disable-next-line */ + font-size: 2.88em; +} +.katex .sizing.reset-size2.size10, +.katex .fontsize-ensurer.reset-size2.size10 { + /* stylelint-disable-next-line */ + font-size: 3.4566666667em; +} +.katex .sizing.reset-size2.size11, +.katex .fontsize-ensurer.reset-size2.size11 { + /* stylelint-disable-next-line */ + font-size: 4.1466666667em; +} +.katex .sizing.reset-size3.size1, +.katex .fontsize-ensurer.reset-size3.size1 { + /* stylelint-disable-next-line */ + font-size: 0.7142857143em; +} +.katex .sizing.reset-size3.size2, +.katex .fontsize-ensurer.reset-size3.size2 { + /* stylelint-disable-next-line */ + font-size: 0.8571428571em; +} +.katex .sizing.reset-size3.size3, +.katex .fontsize-ensurer.reset-size3.size3 { + /* stylelint-disable-next-line */ + font-size: 1em; +} +.katex .sizing.reset-size3.size4, +.katex .fontsize-ensurer.reset-size3.size4 { + /* stylelint-disable-next-line */ + font-size: 1.1428571429em; +} +.katex .sizing.reset-size3.size5, +.katex .fontsize-ensurer.reset-size3.size5 { + /* stylelint-disable-next-line */ + font-size: 1.2857142857em; +} +.katex .sizing.reset-size3.size6, +.katex .fontsize-ensurer.reset-size3.size6 { + /* stylelint-disable-next-line */ + font-size: 1.4285714286em; +} +.katex .sizing.reset-size3.size7, +.katex .fontsize-ensurer.reset-size3.size7 { + /* stylelint-disable-next-line */ + font-size: 1.7142857143em; +} +.katex .sizing.reset-size3.size8, +.katex .fontsize-ensurer.reset-size3.size8 { + /* stylelint-disable-next-line */ + font-size: 2.0571428571em; +} +.katex .sizing.reset-size3.size9, +.katex .fontsize-ensurer.reset-size3.size9 { + /* stylelint-disable-next-line */ + font-size: 2.4685714286em; +} +.katex .sizing.reset-size3.size10, +.katex .fontsize-ensurer.reset-size3.size10 { + /* stylelint-disable-next-line */ + font-size: 2.9628571429em; +} +.katex .sizing.reset-size3.size11, +.katex .fontsize-ensurer.reset-size3.size11 { + /* stylelint-disable-next-line */ + font-size: 3.5542857143em; +} +.katex .sizing.reset-size4.size1, +.katex .fontsize-ensurer.reset-size4.size1 { + /* stylelint-disable-next-line */ + font-size: 0.625em; +} +.katex .sizing.reset-size4.size2, +.katex .fontsize-ensurer.reset-size4.size2 { + /* stylelint-disable-next-line */ + font-size: 0.75em; +} +.katex .sizing.reset-size4.size3, +.katex .fontsize-ensurer.reset-size4.size3 { + /* stylelint-disable-next-line */ + font-size: 0.875em; +} +.katex .sizing.reset-size4.size4, +.katex .fontsize-ensurer.reset-size4.size4 { + /* stylelint-disable-next-line */ + font-size: 1em; +} +.katex .sizing.reset-size4.size5, +.katex .fontsize-ensurer.reset-size4.size5 { + /* stylelint-disable-next-line */ + font-size: 1.125em; +} +.katex .sizing.reset-size4.size6, +.katex .fontsize-ensurer.reset-size4.size6 { + /* stylelint-disable-next-line */ + font-size: 1.25em; +} +.katex .sizing.reset-size4.size7, +.katex .fontsize-ensurer.reset-size4.size7 { + /* stylelint-disable-next-line */ + font-size: 1.5em; +} +.katex .sizing.reset-size4.size8, +.katex .fontsize-ensurer.reset-size4.size8 { + /* stylelint-disable-next-line */ + font-size: 1.8em; +} +.katex .sizing.reset-size4.size9, +.katex .fontsize-ensurer.reset-size4.size9 { + /* stylelint-disable-next-line */ + font-size: 2.16em; +} +.katex .sizing.reset-size4.size10, +.katex .fontsize-ensurer.reset-size4.size10 { + /* stylelint-disable-next-line */ + font-size: 2.5925em; +} +.katex .sizing.reset-size4.size11, +.katex .fontsize-ensurer.reset-size4.size11 { + /* stylelint-disable-next-line */ + font-size: 3.11em; +} +.katex .sizing.reset-size5.size1, +.katex .fontsize-ensurer.reset-size5.size1 { + /* stylelint-disable-next-line */ + font-size: 0.5555555556em; +} +.katex .sizing.reset-size5.size2, +.katex .fontsize-ensurer.reset-size5.size2 { + /* stylelint-disable-next-line */ + font-size: 0.6666666667em; +} +.katex .sizing.reset-size5.size3, +.katex .fontsize-ensurer.reset-size5.size3 { + /* stylelint-disable-next-line */ + font-size: 0.7777777778em; +} +.katex .sizing.reset-size5.size4, +.katex .fontsize-ensurer.reset-size5.size4 { + /* stylelint-disable-next-line */ + font-size: 0.8888888889em; +} +.katex .sizing.reset-size5.size5, +.katex .fontsize-ensurer.reset-size5.size5 { + /* stylelint-disable-next-line */ + font-size: 1em; +} +.katex .sizing.reset-size5.size6, +.katex .fontsize-ensurer.reset-size5.size6 { + /* stylelint-disable-next-line */ + font-size: 1.1111111111em; +} +.katex .sizing.reset-size5.size7, +.katex .fontsize-ensurer.reset-size5.size7 { + /* stylelint-disable-next-line */ + font-size: 1.3333333333em; +} +.katex .sizing.reset-size5.size8, +.katex .fontsize-ensurer.reset-size5.size8 { + /* stylelint-disable-next-line */ + font-size: 1.6em; +} +.katex .sizing.reset-size5.size9, +.katex .fontsize-ensurer.reset-size5.size9 { + /* stylelint-disable-next-line */ + font-size: 1.92em; +} +.katex .sizing.reset-size5.size10, +.katex .fontsize-ensurer.reset-size5.size10 { + /* stylelint-disable-next-line */ + font-size: 2.3044444444em; +} +.katex .sizing.reset-size5.size11, +.katex .fontsize-ensurer.reset-size5.size11 { + /* stylelint-disable-next-line */ + font-size: 2.7644444444em; +} +.katex .sizing.reset-size6.size1, +.katex .fontsize-ensurer.reset-size6.size1 { + /* stylelint-disable-next-line */ + font-size: 0.5em; +} +.katex .sizing.reset-size6.size2, +.katex .fontsize-ensurer.reset-size6.size2 { + /* stylelint-disable-next-line */ + font-size: 0.6em; +} +.katex .sizing.reset-size6.size3, +.katex .fontsize-ensurer.reset-size6.size3 { + /* stylelint-disable-next-line */ + font-size: 0.7em; +} +.katex .sizing.reset-size6.size4, +.katex .fontsize-ensurer.reset-size6.size4 { + /* stylelint-disable-next-line */ + font-size: 0.8em; +} +.katex .sizing.reset-size6.size5, +.katex .fontsize-ensurer.reset-size6.size5 { + /* stylelint-disable-next-line */ + font-size: 0.9em; +} +.katex .sizing.reset-size6.size6, +.katex .fontsize-ensurer.reset-size6.size6 { + /* stylelint-disable-next-line */ + font-size: 1em; +} +.katex .sizing.reset-size6.size7, +.katex .fontsize-ensurer.reset-size6.size7 { + /* stylelint-disable-next-line */ + font-size: 1.2em; +} +.katex .sizing.reset-size6.size8, +.katex .fontsize-ensurer.reset-size6.size8 { + /* stylelint-disable-next-line */ + font-size: 1.44em; +} +.katex .sizing.reset-size6.size9, +.katex .fontsize-ensurer.reset-size6.size9 { + /* stylelint-disable-next-line */ + font-size: 1.728em; +} +.katex .sizing.reset-size6.size10, +.katex .fontsize-ensurer.reset-size6.size10 { + /* stylelint-disable-next-line */ + font-size: 2.074em; +} +.katex .sizing.reset-size6.size11, +.katex .fontsize-ensurer.reset-size6.size11 { + /* stylelint-disable-next-line */ + font-size: 2.488em; +} +.katex .sizing.reset-size7.size1, +.katex .fontsize-ensurer.reset-size7.size1 { + /* stylelint-disable-next-line */ + font-size: 0.4166666667em; +} +.katex .sizing.reset-size7.size2, +.katex .fontsize-ensurer.reset-size7.size2 { + /* stylelint-disable-next-line */ + font-size: 0.5em; +} +.katex .sizing.reset-size7.size3, +.katex .fontsize-ensurer.reset-size7.size3 { + /* stylelint-disable-next-line */ + font-size: 0.5833333333em; +} +.katex .sizing.reset-size7.size4, +.katex .fontsize-ensurer.reset-size7.size4 { + /* stylelint-disable-next-line */ + font-size: 0.6666666667em; +} +.katex .sizing.reset-size7.size5, +.katex .fontsize-ensurer.reset-size7.size5 { + /* stylelint-disable-next-line */ + font-size: 0.75em; +} +.katex .sizing.reset-size7.size6, +.katex .fontsize-ensurer.reset-size7.size6 { + /* stylelint-disable-next-line */ + font-size: 0.8333333333em; +} +.katex .sizing.reset-size7.size7, +.katex .fontsize-ensurer.reset-size7.size7 { + /* stylelint-disable-next-line */ + font-size: 1em; +} +.katex .sizing.reset-size7.size8, +.katex .fontsize-ensurer.reset-size7.size8 { + /* stylelint-disable-next-line */ + font-size: 1.2em; +} +.katex .sizing.reset-size7.size9, +.katex .fontsize-ensurer.reset-size7.size9 { + /* stylelint-disable-next-line */ + font-size: 1.44em; +} +.katex .sizing.reset-size7.size10, +.katex .fontsize-ensurer.reset-size7.size10 { + /* stylelint-disable-next-line */ + font-size: 1.7283333333em; +} +.katex .sizing.reset-size7.size11, +.katex .fontsize-ensurer.reset-size7.size11 { + /* stylelint-disable-next-line */ + font-size: 2.0733333333em; +} +.katex .sizing.reset-size8.size1, +.katex .fontsize-ensurer.reset-size8.size1 { + /* stylelint-disable-next-line */ + font-size: 0.3472222222em; +} +.katex .sizing.reset-size8.size2, +.katex .fontsize-ensurer.reset-size8.size2 { + /* stylelint-disable-next-line */ + font-size: 0.4166666667em; +} +.katex .sizing.reset-size8.size3, +.katex .fontsize-ensurer.reset-size8.size3 { + /* stylelint-disable-next-line */ + font-size: 0.4861111111em; +} +.katex .sizing.reset-size8.size4, +.katex .fontsize-ensurer.reset-size8.size4 { + /* stylelint-disable-next-line */ + font-size: 0.5555555556em; +} +.katex .sizing.reset-size8.size5, +.katex .fontsize-ensurer.reset-size8.size5 { + /* stylelint-disable-next-line */ + font-size: 0.625em; +} +.katex .sizing.reset-size8.size6, +.katex .fontsize-ensurer.reset-size8.size6 { + /* stylelint-disable-next-line */ + font-size: 0.6944444444em; +} +.katex .sizing.reset-size8.size7, +.katex .fontsize-ensurer.reset-size8.size7 { + /* stylelint-disable-next-line */ + font-size: 0.8333333333em; +} +.katex .sizing.reset-size8.size8, +.katex .fontsize-ensurer.reset-size8.size8 { + /* stylelint-disable-next-line */ + font-size: 1em; +} +.katex .sizing.reset-size8.size9, +.katex .fontsize-ensurer.reset-size8.size9 { + /* stylelint-disable-next-line */ + font-size: 1.2em; +} +.katex .sizing.reset-size8.size10, +.katex .fontsize-ensurer.reset-size8.size10 { + /* stylelint-disable-next-line */ + font-size: 1.4402777778em; +} +.katex .sizing.reset-size8.size11, +.katex .fontsize-ensurer.reset-size8.size11 { + /* stylelint-disable-next-line */ + font-size: 1.7277777778em; +} +.katex .sizing.reset-size9.size1, +.katex .fontsize-ensurer.reset-size9.size1 { + /* stylelint-disable-next-line */ + font-size: 0.2893518519em; +} +.katex .sizing.reset-size9.size2, +.katex .fontsize-ensurer.reset-size9.size2 { + /* stylelint-disable-next-line */ + font-size: 0.3472222222em; +} +.katex .sizing.reset-size9.size3, +.katex .fontsize-ensurer.reset-size9.size3 { + /* stylelint-disable-next-line */ + font-size: 0.4050925926em; +} +.katex .sizing.reset-size9.size4, +.katex .fontsize-ensurer.reset-size9.size4 { + /* stylelint-disable-next-line */ + font-size: 0.462962963em; +} +.katex .sizing.reset-size9.size5, +.katex .fontsize-ensurer.reset-size9.size5 { + /* stylelint-disable-next-line */ + font-size: 0.5208333333em; +} +.katex .sizing.reset-size9.size6, +.katex .fontsize-ensurer.reset-size9.size6 { + /* stylelint-disable-next-line */ + font-size: 0.5787037037em; +} +.katex .sizing.reset-size9.size7, +.katex .fontsize-ensurer.reset-size9.size7 { + /* stylelint-disable-next-line */ + font-size: 0.6944444444em; +} +.katex .sizing.reset-size9.size8, +.katex .fontsize-ensurer.reset-size9.size8 { + /* stylelint-disable-next-line */ + font-size: 0.8333333333em; +} +.katex .sizing.reset-size9.size9, +.katex .fontsize-ensurer.reset-size9.size9 { + /* stylelint-disable-next-line */ + font-size: 1em; +} +.katex .sizing.reset-size9.size10, +.katex .fontsize-ensurer.reset-size9.size10 { + /* stylelint-disable-next-line */ + font-size: 1.2002314815em; +} +.katex .sizing.reset-size9.size11, +.katex .fontsize-ensurer.reset-size9.size11 { + /* stylelint-disable-next-line */ + font-size: 1.4398148148em; +} +.katex .sizing.reset-size10.size1, +.katex .fontsize-ensurer.reset-size10.size1 { + /* stylelint-disable-next-line */ + font-size: 0.2410800386em; +} +.katex .sizing.reset-size10.size2, +.katex .fontsize-ensurer.reset-size10.size2 { + /* stylelint-disable-next-line */ + font-size: 0.2892960463em; +} +.katex .sizing.reset-size10.size3, +.katex .fontsize-ensurer.reset-size10.size3 { + /* stylelint-disable-next-line */ + font-size: 0.337512054em; +} +.katex .sizing.reset-size10.size4, +.katex .fontsize-ensurer.reset-size10.size4 { + /* stylelint-disable-next-line */ + font-size: 0.3857280617em; +} +.katex .sizing.reset-size10.size5, +.katex .fontsize-ensurer.reset-size10.size5 { + /* stylelint-disable-next-line */ + font-size: 0.4339440694em; +} +.katex .sizing.reset-size10.size6, +.katex .fontsize-ensurer.reset-size10.size6 { + /* stylelint-disable-next-line */ + font-size: 0.4821600771em; +} +.katex .sizing.reset-size10.size7, +.katex .fontsize-ensurer.reset-size10.size7 { + /* stylelint-disable-next-line */ + font-size: 0.5785920926em; +} +.katex .sizing.reset-size10.size8, +.katex .fontsize-ensurer.reset-size10.size8 { + /* stylelint-disable-next-line */ + font-size: 0.6943105111em; +} +.katex .sizing.reset-size10.size9, +.katex .fontsize-ensurer.reset-size10.size9 { + /* stylelint-disable-next-line */ + font-size: 0.8331726133em; +} +.katex .sizing.reset-size10.size10, +.katex .fontsize-ensurer.reset-size10.size10 { + /* stylelint-disable-next-line */ + font-size: 1em; +} +.katex .sizing.reset-size10.size11, +.katex .fontsize-ensurer.reset-size10.size11 { + /* stylelint-disable-next-line */ + font-size: 1.1996142719em; +} +.katex .sizing.reset-size11.size1, +.katex .fontsize-ensurer.reset-size11.size1 { + /* stylelint-disable-next-line */ + font-size: 0.2009646302em; +} +.katex .sizing.reset-size11.size2, +.katex .fontsize-ensurer.reset-size11.size2 { + /* stylelint-disable-next-line */ + font-size: 0.2411575563em; +} +.katex .sizing.reset-size11.size3, +.katex .fontsize-ensurer.reset-size11.size3 { + /* stylelint-disable-next-line */ + font-size: 0.2813504823em; +} +.katex .sizing.reset-size11.size4, +.katex .fontsize-ensurer.reset-size11.size4 { + /* stylelint-disable-next-line */ + font-size: 0.3215434084em; +} +.katex .sizing.reset-size11.size5, +.katex .fontsize-ensurer.reset-size11.size5 { + /* stylelint-disable-next-line */ + font-size: 0.3617363344em; +} +.katex .sizing.reset-size11.size6, +.katex .fontsize-ensurer.reset-size11.size6 { + /* stylelint-disable-next-line */ + font-size: 0.4019292605em; +} +.katex .sizing.reset-size11.size7, +.katex .fontsize-ensurer.reset-size11.size7 { + /* stylelint-disable-next-line */ + font-size: 0.4823151125em; +} +.katex .sizing.reset-size11.size8, +.katex .fontsize-ensurer.reset-size11.size8 { + /* stylelint-disable-next-line */ + font-size: 0.578778135em; +} +.katex .sizing.reset-size11.size9, +.katex .fontsize-ensurer.reset-size11.size9 { + /* stylelint-disable-next-line */ + font-size: 0.6945337621em; +} +.katex .sizing.reset-size11.size10, +.katex .fontsize-ensurer.reset-size11.size10 { + /* stylelint-disable-next-line */ + font-size: 0.8336012862em; +} +.katex .sizing.reset-size11.size11, +.katex .fontsize-ensurer.reset-size11.size11 { + /* stylelint-disable-next-line */ + font-size: 1em; +} +.katex .delimsizing.size1 { + font-family: KaTeX_Size1; +} +.katex .delimsizing.size2 { + font-family: KaTeX_Size2; +} +.katex .delimsizing.size3 { + font-family: KaTeX_Size3; +} +.katex .delimsizing.size4 { + font-family: KaTeX_Size4; +} +.katex .delimsizing.mult .delim-size1 > span { + font-family: KaTeX_Size1; +} +.katex .delimsizing.mult .delim-size4 > span { + font-family: KaTeX_Size4; +} +.katex .nulldelimiter { + display: inline-block; + width: 0.12em; +} +.katex .delimcenter { + position: relative; +} +.katex .op-symbol { + position: relative; +} +.katex .op-symbol.small-op { + font-family: KaTeX_Size1; +} +.katex .op-symbol.large-op { + font-family: KaTeX_Size2; +} +.katex .op-limits > .vlist-t { + text-align: center; +} +.katex .accent > .vlist-t { + text-align: center; +} +.katex .accent .accent-body { + position: relative; +} +.katex .accent .accent-body:not(.accent-full) { + width: 0; +} +.katex .overlay { + display: block; +} +.katex .mtable .vertical-separator { + display: inline-block; + min-width: 1px; +} +.katex .mtable .arraycolsep { + display: inline-block; +} +.katex .mtable .col-align-c > .vlist-t { + text-align: center; +} +.katex .mtable .col-align-l > .vlist-t { + text-align: left; +} +.katex .mtable .col-align-r > .vlist-t { + text-align: right; +} +.katex .svg-align { + text-align: left; +} +.katex svg { + display: block; + position: absolute; + width: 100%; + height: inherit; + fill: currentColor; + stroke: currentColor; +} +.katex svg path { + stroke: none; +} +.katex svg { + fill-rule: nonzero; + fill-opacity: 1; + stroke-width: 1; + stroke-linecap: butt; + stroke-linejoin: miter; + stroke-miterlimit: 4; + stroke-dasharray: none; + stroke-dashoffset: 0; + stroke-opacity: 1; +} +.katex img { + border-style: none; + min-width: 0; + min-height: 0; + max-width: none; + max-height: none; +} +.katex .stretchy { + width: 100%; + display: block; + position: relative; + overflow: hidden; +} +.katex .stretchy::before, .katex .stretchy::after { + content: ""; +} +.katex .hide-tail { + width: 100%; + position: relative; + overflow: hidden; +} +.katex .halfarrow-left { + position: absolute; + left: 0; + width: 50.2%; + overflow: hidden; +} +.katex .halfarrow-right { + position: absolute; + right: 0; + width: 50.2%; + overflow: hidden; +} +.katex .brace-left { + position: absolute; + left: 0; + width: 25.1%; + overflow: hidden; +} +.katex .brace-center { + position: absolute; + left: 25%; + width: 50%; + overflow: hidden; +} +.katex .brace-right { + position: absolute; + right: 0; + width: 25.1%; + overflow: hidden; +} +.katex .x-arrow-pad { + padding: 0 0.5em; +} +.katex .cd-arrow-pad { + padding: 0 0.55556em 0 0.27778em; +} +.katex .x-arrow, +.katex .mover, +.katex .munder { + text-align: center; +} +.katex .boxpad { + padding: 0 0.3em; +} +.katex .fbox, +.katex .fcolorbox { + box-sizing: border-box; + border: 0.04em solid; +} +.katex .cancel-pad { + padding: 0 0.2em; +} +.katex .cancel-lap { + margin-left: -0.2em; + margin-right: -0.2em; +} +.katex .sout { + border-bottom-style: solid; + border-bottom-width: 0.08em; +} +.katex .angl { + box-sizing: border-box; + border-top: 0.049em solid; + border-right: 0.049em solid; + margin-right: 0.03889em; +} +.katex .anglpad { + padding: 0 0.03889em; +} +.katex .eqn-num::before { + counter-increment: katexEqnNo; + content: "(" counter(katexEqnNo) ")"; +} +.katex .mml-eqn-num::before { + counter-increment: mmlEqnNo; + content: "(" counter(mmlEqnNo) ")"; +} +.katex .mtr-glue { + width: 50%; +} +.katex .cd-vert-arrow { + display: inline-block; + position: relative; +} +.katex .cd-label-left { + display: inline-block; + position: absolute; + right: calc(50% + 0.3em); + text-align: left; +} +.katex .cd-label-right { + display: inline-block; + position: absolute; + left: calc(50% + 0.3em); + text-align: right; +} + +.katex-display { + display: block; + margin: 1em 0; + text-align: center; +} +.katex-display > .katex { + display: block; + text-align: center; + white-space: nowrap; +} +.katex-display > .katex > .katex-html { + display: block; + position: relative; +} +.katex-display > .katex > .katex-html > .tag { + position: absolute; + right: 0; +} + +.katex-display.leqno > .katex > .katex-html > .tag { + left: 0; + right: auto; +} + +.katex-display.fleqn > .katex { + text-align: left; + padding-left: 2em; +} + +body { + counter-reset: katexEqnNo mmlEqnNo; +} diff --git a/node_modules/react-katex/node_modules/katex/dist/katex-swap.min.css b/node_modules/react-katex/node_modules/katex/dist/katex-swap.min.css new file mode 100644 index 0000000..8aa40fa --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/dist/katex-swap.min.css @@ -0,0 +1 @@ +@font-face{font-display:swap;font-family:KaTeX_AMS;font-style:normal;font-weight:400;src:url(fonts/KaTeX_AMS-Regular.woff2) format("woff2"),url(fonts/KaTeX_AMS-Regular.woff) format("woff"),url(fonts/KaTeX_AMS-Regular.ttf) format("truetype")}@font-face{font-display:swap;font-family:KaTeX_Caligraphic;font-style:normal;font-weight:700;src:url(fonts/KaTeX_Caligraphic-Bold.woff2) format("woff2"),url(fonts/KaTeX_Caligraphic-Bold.woff) format("woff"),url(fonts/KaTeX_Caligraphic-Bold.ttf) format("truetype")}@font-face{font-display:swap;font-family:KaTeX_Caligraphic;font-style:normal;font-weight:400;src:url(fonts/KaTeX_Caligraphic-Regular.woff2) format("woff2"),url(fonts/KaTeX_Caligraphic-Regular.woff) format("woff"),url(fonts/KaTeX_Caligraphic-Regular.ttf) format("truetype")}@font-face{font-display:swap;font-family:KaTeX_Fraktur;font-style:normal;font-weight:700;src:url(fonts/KaTeX_Fraktur-Bold.woff2) format("woff2"),url(fonts/KaTeX_Fraktur-Bold.woff) format("woff"),url(fonts/KaTeX_Fraktur-Bold.ttf) format("truetype")}@font-face{font-display:swap;font-family:KaTeX_Fraktur;font-style:normal;font-weight:400;src:url(fonts/KaTeX_Fraktur-Regular.woff2) format("woff2"),url(fonts/KaTeX_Fraktur-Regular.woff) format("woff"),url(fonts/KaTeX_Fraktur-Regular.ttf) format("truetype")}@font-face{font-display:swap;font-family:KaTeX_Main;font-style:normal;font-weight:700;src:url(fonts/KaTeX_Main-Bold.woff2) format("woff2"),url(fonts/KaTeX_Main-Bold.woff) format("woff"),url(fonts/KaTeX_Main-Bold.ttf) format("truetype")}@font-face{font-display:swap;font-family:KaTeX_Main;font-style:italic;font-weight:700;src:url(fonts/KaTeX_Main-BoldItalic.woff2) format("woff2"),url(fonts/KaTeX_Main-BoldItalic.woff) format("woff"),url(fonts/KaTeX_Main-BoldItalic.ttf) format("truetype")}@font-face{font-display:swap;font-family:KaTeX_Main;font-style:italic;font-weight:400;src:url(fonts/KaTeX_Main-Italic.woff2) format("woff2"),url(fonts/KaTeX_Main-Italic.woff) format("woff"),url(fonts/KaTeX_Main-Italic.ttf) format("truetype")}@font-face{font-display:swap;font-family:KaTeX_Main;font-style:normal;font-weight:400;src:url(fonts/KaTeX_Main-Regular.woff2) format("woff2"),url(fonts/KaTeX_Main-Regular.woff) format("woff"),url(fonts/KaTeX_Main-Regular.ttf) format("truetype")}@font-face{font-display:swap;font-family:KaTeX_Math;font-style:italic;font-weight:700;src:url(fonts/KaTeX_Math-BoldItalic.woff2) format("woff2"),url(fonts/KaTeX_Math-BoldItalic.woff) format("woff"),url(fonts/KaTeX_Math-BoldItalic.ttf) format("truetype")}@font-face{font-display:swap;font-family:KaTeX_Math;font-style:italic;font-weight:400;src:url(fonts/KaTeX_Math-Italic.woff2) format("woff2"),url(fonts/KaTeX_Math-Italic.woff) format("woff"),url(fonts/KaTeX_Math-Italic.ttf) format("truetype")}@font-face{font-display:swap;font-family:"KaTeX_SansSerif";font-style:normal;font-weight:700;src:url(fonts/KaTeX_SansSerif-Bold.woff2) format("woff2"),url(fonts/KaTeX_SansSerif-Bold.woff) format("woff"),url(fonts/KaTeX_SansSerif-Bold.ttf) format("truetype")}@font-face{font-display:swap;font-family:"KaTeX_SansSerif";font-style:italic;font-weight:400;src:url(fonts/KaTeX_SansSerif-Italic.woff2) format("woff2"),url(fonts/KaTeX_SansSerif-Italic.woff) format("woff"),url(fonts/KaTeX_SansSerif-Italic.ttf) format("truetype")}@font-face{font-display:swap;font-family:"KaTeX_SansSerif";font-style:normal;font-weight:400;src:url(fonts/KaTeX_SansSerif-Regular.woff2) format("woff2"),url(fonts/KaTeX_SansSerif-Regular.woff) format("woff"),url(fonts/KaTeX_SansSerif-Regular.ttf) format("truetype")}@font-face{font-display:swap;font-family:KaTeX_Script;font-style:normal;font-weight:400;src:url(fonts/KaTeX_Script-Regular.woff2) format("woff2"),url(fonts/KaTeX_Script-Regular.woff) format("woff"),url(fonts/KaTeX_Script-Regular.ttf) format("truetype")}@font-face{font-display:swap;font-family:KaTeX_Size1;font-style:normal;font-weight:400;src:url(fonts/KaTeX_Size1-Regular.woff2) format("woff2"),url(fonts/KaTeX_Size1-Regular.woff) format("woff"),url(fonts/KaTeX_Size1-Regular.ttf) format("truetype")}@font-face{font-display:swap;font-family:KaTeX_Size2;font-style:normal;font-weight:400;src:url(fonts/KaTeX_Size2-Regular.woff2) format("woff2"),url(fonts/KaTeX_Size2-Regular.woff) format("woff"),url(fonts/KaTeX_Size2-Regular.ttf) format("truetype")}@font-face{font-display:swap;font-family:KaTeX_Size3;font-style:normal;font-weight:400;src:url(fonts/KaTeX_Size3-Regular.woff2) format("woff2"),url(fonts/KaTeX_Size3-Regular.woff) format("woff"),url(fonts/KaTeX_Size3-Regular.ttf) format("truetype")}@font-face{font-display:swap;font-family:KaTeX_Size4;font-style:normal;font-weight:400;src:url(fonts/KaTeX_Size4-Regular.woff2) format("woff2"),url(fonts/KaTeX_Size4-Regular.woff) format("woff"),url(fonts/KaTeX_Size4-Regular.ttf) format("truetype")}@font-face{font-display:swap;font-family:KaTeX_Typewriter;font-style:normal;font-weight:400;src:url(fonts/KaTeX_Typewriter-Regular.woff2) format("woff2"),url(fonts/KaTeX_Typewriter-Regular.woff) format("woff"),url(fonts/KaTeX_Typewriter-Regular.ttf) format("truetype")}.katex{font:normal 1.21em KaTeX_Main,Times New Roman,serif;line-height:1.2;position:relative;text-indent:0;text-rendering:auto}.katex *{-ms-high-contrast-adjust:none!important;border-color:currentColor}.katex .katex-version:after{content:"0.16.47"}.katex .katex-mathml{border:0;-webkit-clip-path:inset(50%);clip-path:inset(50%);height:1px;overflow:hidden;padding:0;position:absolute;width:1px}.katex .katex-html>.newline{display:block}.katex .base{position:relative;white-space:nowrap;width:-webkit-min-content;width:-moz-min-content;width:min-content}.katex .base,.katex .strut{display:inline-block}.katex .textbf{font-weight:700}.katex .textit{font-style:italic}.katex .textrm{font-family:KaTeX_Main}.katex .textsf{font-family:KaTeX_SansSerif}.katex .texttt{font-family:KaTeX_Typewriter}.katex .mathnormal{font-family:KaTeX_Math;font-style:italic}.katex .mathit{font-family:KaTeX_Main;font-style:italic}.katex .mathrm{font-style:normal}.katex .mathbf{font-family:KaTeX_Main;font-weight:700}.katex .boldsymbol{font-family:KaTeX_Math;font-style:italic;font-weight:700}.katex .amsrm,.katex .mathbb,.katex .textbb{font-family:KaTeX_AMS}.katex .mathcal{font-family:KaTeX_Caligraphic}.katex .mathfrak,.katex .textfrak{font-family:KaTeX_Fraktur}.katex .mathboldfrak,.katex .textboldfrak{font-family:KaTeX_Fraktur;font-weight:700}.katex .mathtt{font-family:KaTeX_Typewriter}.katex .mathscr,.katex .textscr{font-family:KaTeX_Script}.katex .mathsf,.katex .textsf{font-family:KaTeX_SansSerif}.katex .mathboldsf,.katex .textboldsf{font-family:KaTeX_SansSerif;font-weight:700}.katex .mathitsf,.katex .mathsfit,.katex .textitsf{font-family:KaTeX_SansSerif;font-style:italic}.katex .mainrm{font-family:KaTeX_Main;font-style:normal}.katex .vlist-t{border-collapse:collapse;display:inline-table;table-layout:fixed}.katex .vlist-r{display:table-row}.katex .vlist{display:table-cell;position:relative;vertical-align:bottom}.katex .vlist>span{display:block;height:0;position:relative}.katex .vlist>span>span{display:inline-block}.katex .vlist>span>.pstrut{overflow:hidden;width:0}.katex .vlist-t2{margin-right:-2px}.katex .vlist-s{display:table-cell;font-size:1px;min-width:2px;vertical-align:bottom;width:2px}.katex .vbox{align-items:baseline;display:inline-flex;flex-direction:column}.katex .hbox{width:100%}.katex .hbox,.katex .thinbox{display:inline-flex;flex-direction:row}.katex .thinbox{max-width:0;width:0}.katex .msupsub{text-align:left}.katex .mfrac>span>span{text-align:center}.katex .mfrac .frac-line{border-bottom-style:solid;display:inline-block;width:100%}.katex .hdashline,.katex .hline,.katex .mfrac .frac-line,.katex .overline .overline-line,.katex .rule,.katex .underline .underline-line{min-height:1px}.katex .mspace{display:inline-block}.katex .smash{display:inline;line-height:0}.katex .clap,.katex .llap,.katex .rlap{position:relative;width:0}.katex .clap>.inner,.katex .llap>.inner,.katex .rlap>.inner{position:absolute}.katex .clap>.fix,.katex .llap>.fix,.katex .rlap>.fix{display:inline-block}.katex .llap>.inner{right:0}.katex .clap>.inner,.katex .rlap>.inner{left:0}.katex .clap>.inner>span{margin-left:-50%;margin-right:50%}.katex .rule{border:0 solid;display:inline-block;position:relative}.katex .hline,.katex .overline .overline-line,.katex .underline .underline-line{border-bottom-style:solid;display:inline-block;width:100%}.katex .hdashline{border-bottom-style:dashed;display:inline-block;width:100%}.katex .sqrt>.root{margin-left:.2777777778em;margin-right:-.5555555556em}.katex .fontsize-ensurer.reset-size1.size1,.katex .sizing.reset-size1.size1{font-size:1em}.katex .fontsize-ensurer.reset-size1.size2,.katex .sizing.reset-size1.size2{font-size:1.2em}.katex .fontsize-ensurer.reset-size1.size3,.katex .sizing.reset-size1.size3{font-size:1.4em}.katex .fontsize-ensurer.reset-size1.size4,.katex .sizing.reset-size1.size4{font-size:1.6em}.katex .fontsize-ensurer.reset-size1.size5,.katex .sizing.reset-size1.size5{font-size:1.8em}.katex .fontsize-ensurer.reset-size1.size6,.katex .sizing.reset-size1.size6{font-size:2em}.katex .fontsize-ensurer.reset-size1.size7,.katex .sizing.reset-size1.size7{font-size:2.4em}.katex .fontsize-ensurer.reset-size1.size8,.katex .sizing.reset-size1.size8{font-size:2.88em}.katex .fontsize-ensurer.reset-size1.size9,.katex .sizing.reset-size1.size9{font-size:3.456em}.katex .fontsize-ensurer.reset-size1.size10,.katex .sizing.reset-size1.size10{font-size:4.148em}.katex .fontsize-ensurer.reset-size1.size11,.katex .sizing.reset-size1.size11{font-size:4.976em}.katex .fontsize-ensurer.reset-size2.size1,.katex .sizing.reset-size2.size1{font-size:.8333333333em}.katex .fontsize-ensurer.reset-size2.size2,.katex .sizing.reset-size2.size2{font-size:1em}.katex .fontsize-ensurer.reset-size2.size3,.katex .sizing.reset-size2.size3{font-size:1.1666666667em}.katex .fontsize-ensurer.reset-size2.size4,.katex .sizing.reset-size2.size4{font-size:1.3333333333em}.katex .fontsize-ensurer.reset-size2.size5,.katex .sizing.reset-size2.size5{font-size:1.5em}.katex .fontsize-ensurer.reset-size2.size6,.katex .sizing.reset-size2.size6{font-size:1.6666666667em}.katex .fontsize-ensurer.reset-size2.size7,.katex .sizing.reset-size2.size7{font-size:2em}.katex .fontsize-ensurer.reset-size2.size8,.katex .sizing.reset-size2.size8{font-size:2.4em}.katex .fontsize-ensurer.reset-size2.size9,.katex .sizing.reset-size2.size9{font-size:2.88em}.katex .fontsize-ensurer.reset-size2.size10,.katex .sizing.reset-size2.size10{font-size:3.4566666667em}.katex .fontsize-ensurer.reset-size2.size11,.katex .sizing.reset-size2.size11{font-size:4.1466666667em}.katex .fontsize-ensurer.reset-size3.size1,.katex .sizing.reset-size3.size1{font-size:.7142857143em}.katex .fontsize-ensurer.reset-size3.size2,.katex .sizing.reset-size3.size2{font-size:.8571428571em}.katex .fontsize-ensurer.reset-size3.size3,.katex .sizing.reset-size3.size3{font-size:1em}.katex .fontsize-ensurer.reset-size3.size4,.katex .sizing.reset-size3.size4{font-size:1.1428571429em}.katex .fontsize-ensurer.reset-size3.size5,.katex .sizing.reset-size3.size5{font-size:1.2857142857em}.katex .fontsize-ensurer.reset-size3.size6,.katex .sizing.reset-size3.size6{font-size:1.4285714286em}.katex .fontsize-ensurer.reset-size3.size7,.katex .sizing.reset-size3.size7{font-size:1.7142857143em}.katex .fontsize-ensurer.reset-size3.size8,.katex .sizing.reset-size3.size8{font-size:2.0571428571em}.katex .fontsize-ensurer.reset-size3.size9,.katex .sizing.reset-size3.size9{font-size:2.4685714286em}.katex .fontsize-ensurer.reset-size3.size10,.katex .sizing.reset-size3.size10{font-size:2.9628571429em}.katex .fontsize-ensurer.reset-size3.size11,.katex .sizing.reset-size3.size11{font-size:3.5542857143em}.katex .fontsize-ensurer.reset-size4.size1,.katex .sizing.reset-size4.size1{font-size:.625em}.katex .fontsize-ensurer.reset-size4.size2,.katex .sizing.reset-size4.size2{font-size:.75em}.katex .fontsize-ensurer.reset-size4.size3,.katex .sizing.reset-size4.size3{font-size:.875em}.katex .fontsize-ensurer.reset-size4.size4,.katex .sizing.reset-size4.size4{font-size:1em}.katex .fontsize-ensurer.reset-size4.size5,.katex .sizing.reset-size4.size5{font-size:1.125em}.katex .fontsize-ensurer.reset-size4.size6,.katex .sizing.reset-size4.size6{font-size:1.25em}.katex .fontsize-ensurer.reset-size4.size7,.katex .sizing.reset-size4.size7{font-size:1.5em}.katex .fontsize-ensurer.reset-size4.size8,.katex .sizing.reset-size4.size8{font-size:1.8em}.katex .fontsize-ensurer.reset-size4.size9,.katex .sizing.reset-size4.size9{font-size:2.16em}.katex .fontsize-ensurer.reset-size4.size10,.katex .sizing.reset-size4.size10{font-size:2.5925em}.katex .fontsize-ensurer.reset-size4.size11,.katex .sizing.reset-size4.size11{font-size:3.11em}.katex .fontsize-ensurer.reset-size5.size1,.katex .sizing.reset-size5.size1{font-size:.5555555556em}.katex .fontsize-ensurer.reset-size5.size2,.katex .sizing.reset-size5.size2{font-size:.6666666667em}.katex .fontsize-ensurer.reset-size5.size3,.katex .sizing.reset-size5.size3{font-size:.7777777778em}.katex .fontsize-ensurer.reset-size5.size4,.katex .sizing.reset-size5.size4{font-size:.8888888889em}.katex .fontsize-ensurer.reset-size5.size5,.katex .sizing.reset-size5.size5{font-size:1em}.katex .fontsize-ensurer.reset-size5.size6,.katex .sizing.reset-size5.size6{font-size:1.1111111111em}.katex .fontsize-ensurer.reset-size5.size7,.katex .sizing.reset-size5.size7{font-size:1.3333333333em}.katex .fontsize-ensurer.reset-size5.size8,.katex .sizing.reset-size5.size8{font-size:1.6em}.katex .fontsize-ensurer.reset-size5.size9,.katex .sizing.reset-size5.size9{font-size:1.92em}.katex .fontsize-ensurer.reset-size5.size10,.katex .sizing.reset-size5.size10{font-size:2.3044444444em}.katex .fontsize-ensurer.reset-size5.size11,.katex .sizing.reset-size5.size11{font-size:2.7644444444em}.katex .fontsize-ensurer.reset-size6.size1,.katex .sizing.reset-size6.size1{font-size:.5em}.katex .fontsize-ensurer.reset-size6.size2,.katex .sizing.reset-size6.size2{font-size:.6em}.katex .fontsize-ensurer.reset-size6.size3,.katex .sizing.reset-size6.size3{font-size:.7em}.katex .fontsize-ensurer.reset-size6.size4,.katex .sizing.reset-size6.size4{font-size:.8em}.katex .fontsize-ensurer.reset-size6.size5,.katex .sizing.reset-size6.size5{font-size:.9em}.katex .fontsize-ensurer.reset-size6.size6,.katex .sizing.reset-size6.size6{font-size:1em}.katex .fontsize-ensurer.reset-size6.size7,.katex .sizing.reset-size6.size7{font-size:1.2em}.katex .fontsize-ensurer.reset-size6.size8,.katex .sizing.reset-size6.size8{font-size:1.44em}.katex .fontsize-ensurer.reset-size6.size9,.katex .sizing.reset-size6.size9{font-size:1.728em}.katex .fontsize-ensurer.reset-size6.size10,.katex .sizing.reset-size6.size10{font-size:2.074em}.katex .fontsize-ensurer.reset-size6.size11,.katex .sizing.reset-size6.size11{font-size:2.488em}.katex .fontsize-ensurer.reset-size7.size1,.katex .sizing.reset-size7.size1{font-size:.4166666667em}.katex .fontsize-ensurer.reset-size7.size2,.katex .sizing.reset-size7.size2{font-size:.5em}.katex .fontsize-ensurer.reset-size7.size3,.katex .sizing.reset-size7.size3{font-size:.5833333333em}.katex .fontsize-ensurer.reset-size7.size4,.katex .sizing.reset-size7.size4{font-size:.6666666667em}.katex .fontsize-ensurer.reset-size7.size5,.katex .sizing.reset-size7.size5{font-size:.75em}.katex .fontsize-ensurer.reset-size7.size6,.katex .sizing.reset-size7.size6{font-size:.8333333333em}.katex .fontsize-ensurer.reset-size7.size7,.katex .sizing.reset-size7.size7{font-size:1em}.katex .fontsize-ensurer.reset-size7.size8,.katex .sizing.reset-size7.size8{font-size:1.2em}.katex .fontsize-ensurer.reset-size7.size9,.katex .sizing.reset-size7.size9{font-size:1.44em}.katex .fontsize-ensurer.reset-size7.size10,.katex .sizing.reset-size7.size10{font-size:1.7283333333em}.katex .fontsize-ensurer.reset-size7.size11,.katex .sizing.reset-size7.size11{font-size:2.0733333333em}.katex .fontsize-ensurer.reset-size8.size1,.katex .sizing.reset-size8.size1{font-size:.3472222222em}.katex .fontsize-ensurer.reset-size8.size2,.katex .sizing.reset-size8.size2{font-size:.4166666667em}.katex .fontsize-ensurer.reset-size8.size3,.katex .sizing.reset-size8.size3{font-size:.4861111111em}.katex .fontsize-ensurer.reset-size8.size4,.katex .sizing.reset-size8.size4{font-size:.5555555556em}.katex .fontsize-ensurer.reset-size8.size5,.katex .sizing.reset-size8.size5{font-size:.625em}.katex .fontsize-ensurer.reset-size8.size6,.katex .sizing.reset-size8.size6{font-size:.6944444444em}.katex .fontsize-ensurer.reset-size8.size7,.katex .sizing.reset-size8.size7{font-size:.8333333333em}.katex .fontsize-ensurer.reset-size8.size8,.katex .sizing.reset-size8.size8{font-size:1em}.katex .fontsize-ensurer.reset-size8.size9,.katex .sizing.reset-size8.size9{font-size:1.2em}.katex .fontsize-ensurer.reset-size8.size10,.katex .sizing.reset-size8.size10{font-size:1.4402777778em}.katex .fontsize-ensurer.reset-size8.size11,.katex .sizing.reset-size8.size11{font-size:1.7277777778em}.katex .fontsize-ensurer.reset-size9.size1,.katex .sizing.reset-size9.size1{font-size:.2893518519em}.katex .fontsize-ensurer.reset-size9.size2,.katex .sizing.reset-size9.size2{font-size:.3472222222em}.katex .fontsize-ensurer.reset-size9.size3,.katex .sizing.reset-size9.size3{font-size:.4050925926em}.katex .fontsize-ensurer.reset-size9.size4,.katex .sizing.reset-size9.size4{font-size:.462962963em}.katex .fontsize-ensurer.reset-size9.size5,.katex .sizing.reset-size9.size5{font-size:.5208333333em}.katex .fontsize-ensurer.reset-size9.size6,.katex .sizing.reset-size9.size6{font-size:.5787037037em}.katex .fontsize-ensurer.reset-size9.size7,.katex .sizing.reset-size9.size7{font-size:.6944444444em}.katex .fontsize-ensurer.reset-size9.size8,.katex .sizing.reset-size9.size8{font-size:.8333333333em}.katex .fontsize-ensurer.reset-size9.size9,.katex .sizing.reset-size9.size9{font-size:1em}.katex .fontsize-ensurer.reset-size9.size10,.katex .sizing.reset-size9.size10{font-size:1.2002314815em}.katex .fontsize-ensurer.reset-size9.size11,.katex .sizing.reset-size9.size11{font-size:1.4398148148em}.katex .fontsize-ensurer.reset-size10.size1,.katex .sizing.reset-size10.size1{font-size:.2410800386em}.katex .fontsize-ensurer.reset-size10.size2,.katex .sizing.reset-size10.size2{font-size:.2892960463em}.katex .fontsize-ensurer.reset-size10.size3,.katex .sizing.reset-size10.size3{font-size:.337512054em}.katex .fontsize-ensurer.reset-size10.size4,.katex .sizing.reset-size10.size4{font-size:.3857280617em}.katex .fontsize-ensurer.reset-size10.size5,.katex .sizing.reset-size10.size5{font-size:.4339440694em}.katex .fontsize-ensurer.reset-size10.size6,.katex .sizing.reset-size10.size6{font-size:.4821600771em}.katex .fontsize-ensurer.reset-size10.size7,.katex .sizing.reset-size10.size7{font-size:.5785920926em}.katex .fontsize-ensurer.reset-size10.size8,.katex .sizing.reset-size10.size8{font-size:.6943105111em}.katex .fontsize-ensurer.reset-size10.size9,.katex .sizing.reset-size10.size9{font-size:.8331726133em}.katex .fontsize-ensurer.reset-size10.size10,.katex .sizing.reset-size10.size10{font-size:1em}.katex .fontsize-ensurer.reset-size10.size11,.katex .sizing.reset-size10.size11{font-size:1.1996142719em}.katex .fontsize-ensurer.reset-size11.size1,.katex .sizing.reset-size11.size1{font-size:.2009646302em}.katex .fontsize-ensurer.reset-size11.size2,.katex .sizing.reset-size11.size2{font-size:.2411575563em}.katex .fontsize-ensurer.reset-size11.size3,.katex .sizing.reset-size11.size3{font-size:.2813504823em}.katex .fontsize-ensurer.reset-size11.size4,.katex .sizing.reset-size11.size4{font-size:.3215434084em}.katex .fontsize-ensurer.reset-size11.size5,.katex .sizing.reset-size11.size5{font-size:.3617363344em}.katex .fontsize-ensurer.reset-size11.size6,.katex .sizing.reset-size11.size6{font-size:.4019292605em}.katex .fontsize-ensurer.reset-size11.size7,.katex .sizing.reset-size11.size7{font-size:.4823151125em}.katex .fontsize-ensurer.reset-size11.size8,.katex .sizing.reset-size11.size8{font-size:.578778135em}.katex .fontsize-ensurer.reset-size11.size9,.katex .sizing.reset-size11.size9{font-size:.6945337621em}.katex .fontsize-ensurer.reset-size11.size10,.katex .sizing.reset-size11.size10{font-size:.8336012862em}.katex .fontsize-ensurer.reset-size11.size11,.katex .sizing.reset-size11.size11{font-size:1em}.katex .delimsizing.size1{font-family:KaTeX_Size1}.katex .delimsizing.size2{font-family:KaTeX_Size2}.katex .delimsizing.size3{font-family:KaTeX_Size3}.katex .delimsizing.size4{font-family:KaTeX_Size4}.katex .delimsizing.mult .delim-size1>span{font-family:KaTeX_Size1}.katex .delimsizing.mult .delim-size4>span{font-family:KaTeX_Size4}.katex .nulldelimiter{display:inline-block;width:.12em}.katex .delimcenter,.katex .op-symbol{position:relative}.katex .op-symbol.small-op{font-family:KaTeX_Size1}.katex .op-symbol.large-op{font-family:KaTeX_Size2}.katex .accent>.vlist-t,.katex .op-limits>.vlist-t{text-align:center}.katex .accent .accent-body{position:relative}.katex .accent .accent-body:not(.accent-full){width:0}.katex .overlay{display:block}.katex .mtable .vertical-separator{display:inline-block;min-width:1px}.katex .mtable .arraycolsep{display:inline-block}.katex .mtable .col-align-c>.vlist-t{text-align:center}.katex .mtable .col-align-l>.vlist-t{text-align:left}.katex .mtable .col-align-r>.vlist-t{text-align:right}.katex .svg-align{text-align:left}.katex svg{fill:currentColor;stroke:currentColor;display:block;height:inherit;position:absolute;width:100%}.katex svg path{stroke:none}.katex svg{fill-rule:nonzero;fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1}.katex img{border-style:none;max-height:none;max-width:none;min-height:0;min-width:0}.katex .stretchy{display:block;overflow:hidden;position:relative;width:100%}.katex .stretchy:after,.katex .stretchy:before{content:""}.katex .hide-tail{overflow:hidden;position:relative;width:100%}.katex .halfarrow-left{left:0;overflow:hidden;position:absolute;width:50.2%}.katex .halfarrow-right{overflow:hidden;position:absolute;right:0;width:50.2%}.katex .brace-left{left:0;overflow:hidden;position:absolute;width:25.1%}.katex .brace-center{left:25%;overflow:hidden;position:absolute;width:50%}.katex .brace-right{overflow:hidden;position:absolute;right:0;width:25.1%}.katex .x-arrow-pad{padding:0 .5em}.katex .cd-arrow-pad{padding:0 .55556em 0 .27778em}.katex .mover,.katex .munder,.katex .x-arrow{text-align:center}.katex .boxpad{padding:0 .3em}.katex .fbox,.katex .fcolorbox{border:.04em solid;box-sizing:border-box}.katex .cancel-pad{padding:0 .2em}.katex .cancel-lap{margin-left:-.2em;margin-right:-.2em}.katex .sout{border-bottom-style:solid;border-bottom-width:.08em}.katex .angl{border-right:.049em solid;border-top:.049em solid;box-sizing:border-box;margin-right:.03889em}.katex .anglpad{padding:0 .03889em}.katex .eqn-num:before{content:"(" counter(katexEqnNo) ")";counter-increment:katexEqnNo}.katex .mml-eqn-num:before{content:"(" counter(mmlEqnNo) ")";counter-increment:mmlEqnNo}.katex .mtr-glue{width:50%}.katex .cd-vert-arrow{display:inline-block;position:relative}.katex .cd-label-left{display:inline-block;position:absolute;right:calc(50% + .3em);text-align:left}.katex .cd-label-right{display:inline-block;left:calc(50% + .3em);position:absolute;text-align:right}.katex-display{display:block;margin:1em 0;text-align:center}.katex-display>.katex{display:block;text-align:center;white-space:nowrap}.katex-display>.katex>.katex-html{display:block;position:relative}.katex-display>.katex>.katex-html>.tag{position:absolute;right:0}.katex-display.leqno>.katex>.katex-html>.tag{left:0;right:auto}.katex-display.fleqn>.katex{padding-left:2em;text-align:left}body{counter-reset:katexEqnNo mmlEqnNo} diff --git a/node_modules/react-katex/node_modules/katex/dist/katex.css b/node_modules/react-katex/node_modules/katex/dist/katex.css new file mode 100644 index 0000000..2420d86 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/dist/katex.css @@ -0,0 +1,1241 @@ +/* stylelint-disable font-family-no-missing-generic-family-keyword */ +@font-face { + font-family: "KaTeX_AMS"; + src: url(fonts/KaTeX_AMS-Regular.woff2) format("woff2"), url(fonts/KaTeX_AMS-Regular.woff) format("woff"), url(fonts/KaTeX_AMS-Regular.ttf) format("truetype"); + font-weight: normal; + font-style: normal; + font-display: block; +} +@font-face { + font-family: "KaTeX_Caligraphic"; + src: url(fonts/KaTeX_Caligraphic-Bold.woff2) format("woff2"), url(fonts/KaTeX_Caligraphic-Bold.woff) format("woff"), url(fonts/KaTeX_Caligraphic-Bold.ttf) format("truetype"); + font-weight: bold; + font-style: normal; + font-display: block; +} +@font-face { + font-family: "KaTeX_Caligraphic"; + src: url(fonts/KaTeX_Caligraphic-Regular.woff2) format("woff2"), url(fonts/KaTeX_Caligraphic-Regular.woff) format("woff"), url(fonts/KaTeX_Caligraphic-Regular.ttf) format("truetype"); + font-weight: normal; + font-style: normal; + font-display: block; +} +@font-face { + font-family: "KaTeX_Fraktur"; + src: url(fonts/KaTeX_Fraktur-Bold.woff2) format("woff2"), url(fonts/KaTeX_Fraktur-Bold.woff) format("woff"), url(fonts/KaTeX_Fraktur-Bold.ttf) format("truetype"); + font-weight: bold; + font-style: normal; + font-display: block; +} +@font-face { + font-family: "KaTeX_Fraktur"; + src: url(fonts/KaTeX_Fraktur-Regular.woff2) format("woff2"), url(fonts/KaTeX_Fraktur-Regular.woff) format("woff"), url(fonts/KaTeX_Fraktur-Regular.ttf) format("truetype"); + font-weight: normal; + font-style: normal; + font-display: block; +} +@font-face { + font-family: "KaTeX_Main"; + src: url(fonts/KaTeX_Main-Bold.woff2) format("woff2"), url(fonts/KaTeX_Main-Bold.woff) format("woff"), url(fonts/KaTeX_Main-Bold.ttf) format("truetype"); + font-weight: bold; + font-style: normal; + font-display: block; +} +@font-face { + font-family: "KaTeX_Main"; + src: url(fonts/KaTeX_Main-BoldItalic.woff2) format("woff2"), url(fonts/KaTeX_Main-BoldItalic.woff) format("woff"), url(fonts/KaTeX_Main-BoldItalic.ttf) format("truetype"); + font-weight: bold; + font-style: italic; + font-display: block; +} +@font-face { + font-family: "KaTeX_Main"; + src: url(fonts/KaTeX_Main-Italic.woff2) format("woff2"), url(fonts/KaTeX_Main-Italic.woff) format("woff"), url(fonts/KaTeX_Main-Italic.ttf) format("truetype"); + font-weight: normal; + font-style: italic; + font-display: block; +} +@font-face { + font-family: "KaTeX_Main"; + src: url(fonts/KaTeX_Main-Regular.woff2) format("woff2"), url(fonts/KaTeX_Main-Regular.woff) format("woff"), url(fonts/KaTeX_Main-Regular.ttf) format("truetype"); + font-weight: normal; + font-style: normal; + font-display: block; +} +@font-face { + font-family: "KaTeX_Math"; + src: url(fonts/KaTeX_Math-BoldItalic.woff2) format("woff2"), url(fonts/KaTeX_Math-BoldItalic.woff) format("woff"), url(fonts/KaTeX_Math-BoldItalic.ttf) format("truetype"); + font-weight: bold; + font-style: italic; + font-display: block; +} +@font-face { + font-family: "KaTeX_Math"; + src: url(fonts/KaTeX_Math-Italic.woff2) format("woff2"), url(fonts/KaTeX_Math-Italic.woff) format("woff"), url(fonts/KaTeX_Math-Italic.ttf) format("truetype"); + font-weight: normal; + font-style: italic; + font-display: block; +} +@font-face { + font-family: "KaTeX_SansSerif"; + src: url(fonts/KaTeX_SansSerif-Bold.woff2) format("woff2"), url(fonts/KaTeX_SansSerif-Bold.woff) format("woff"), url(fonts/KaTeX_SansSerif-Bold.ttf) format("truetype"); + font-weight: bold; + font-style: normal; + font-display: block; +} +@font-face { + font-family: "KaTeX_SansSerif"; + src: url(fonts/KaTeX_SansSerif-Italic.woff2) format("woff2"), url(fonts/KaTeX_SansSerif-Italic.woff) format("woff"), url(fonts/KaTeX_SansSerif-Italic.ttf) format("truetype"); + font-weight: normal; + font-style: italic; + font-display: block; +} +@font-face { + font-family: "KaTeX_SansSerif"; + src: url(fonts/KaTeX_SansSerif-Regular.woff2) format("woff2"), url(fonts/KaTeX_SansSerif-Regular.woff) format("woff"), url(fonts/KaTeX_SansSerif-Regular.ttf) format("truetype"); + font-weight: normal; + font-style: normal; + font-display: block; +} +@font-face { + font-family: "KaTeX_Script"; + src: url(fonts/KaTeX_Script-Regular.woff2) format("woff2"), url(fonts/KaTeX_Script-Regular.woff) format("woff"), url(fonts/KaTeX_Script-Regular.ttf) format("truetype"); + font-weight: normal; + font-style: normal; + font-display: block; +} +@font-face { + font-family: "KaTeX_Size1"; + src: url(fonts/KaTeX_Size1-Regular.woff2) format("woff2"), url(fonts/KaTeX_Size1-Regular.woff) format("woff"), url(fonts/KaTeX_Size1-Regular.ttf) format("truetype"); + font-weight: normal; + font-style: normal; + font-display: block; +} +@font-face { + font-family: "KaTeX_Size2"; + src: url(fonts/KaTeX_Size2-Regular.woff2) format("woff2"), url(fonts/KaTeX_Size2-Regular.woff) format("woff"), url(fonts/KaTeX_Size2-Regular.ttf) format("truetype"); + font-weight: normal; + font-style: normal; + font-display: block; +} +@font-face { + font-family: "KaTeX_Size3"; + src: url(fonts/KaTeX_Size3-Regular.woff2) format("woff2"), url(fonts/KaTeX_Size3-Regular.woff) format("woff"), url(fonts/KaTeX_Size3-Regular.ttf) format("truetype"); + font-weight: normal; + font-style: normal; + font-display: block; +} +@font-face { + font-family: "KaTeX_Size4"; + src: url(fonts/KaTeX_Size4-Regular.woff2) format("woff2"), url(fonts/KaTeX_Size4-Regular.woff) format("woff"), url(fonts/KaTeX_Size4-Regular.ttf) format("truetype"); + font-weight: normal; + font-style: normal; + font-display: block; +} +@font-face { + font-family: "KaTeX_Typewriter"; + src: url(fonts/KaTeX_Typewriter-Regular.woff2) format("woff2"), url(fonts/KaTeX_Typewriter-Regular.woff) format("woff"), url(fonts/KaTeX_Typewriter-Regular.ttf) format("truetype"); + font-weight: normal; + font-style: normal; + font-display: block; +} +/* stylelint-disable font-family-no-missing-generic-family-keyword */ +.katex { + font: normal 1.21em KaTeX_Main, Times New Roman, serif; + line-height: 1.2; + position: relative; + text-indent: 0; + text-rendering: auto; +} +.katex * { + -ms-high-contrast-adjust: none !important; +} +.katex * { + border-color: currentColor; +} +.katex .katex-version::after { + content: "0.16.47"; +} +.katex .katex-mathml { + /* Accessibility hack to only show to screen readers + Found at: http://a11yproject.com/posts/how-to-hide-content/ */ + position: absolute; + -webkit-clip-path: inset(50%); + clip-path: inset(50%); + padding: 0; + border: 0; + height: 1px; + width: 1px; + overflow: hidden; +} +.katex .katex-html { + /* \newline is an empty block at top level, between .base elements */ +} +.katex .katex-html > .newline { + display: block; +} +.katex .base { + position: relative; + display: inline-block; + white-space: nowrap; + width: -webkit-min-content; + width: -moz-min-content; + width: min-content; +} +.katex .strut { + display: inline-block; +} +.katex .textbf { + font-weight: bold; +} +.katex .textit { + font-style: italic; +} +.katex .textrm { + font-family: KaTeX_Main; +} +.katex .textsf { + font-family: KaTeX_SansSerif; +} +.katex .texttt { + font-family: KaTeX_Typewriter; +} +.katex .mathnormal { + font-family: KaTeX_Math; + font-style: italic; +} +.katex .mathit { + font-family: KaTeX_Main; + font-style: italic; +} +.katex .mathrm { + font-style: normal; +} +.katex .mathbf { + font-family: KaTeX_Main; + font-weight: bold; +} +.katex .boldsymbol { + font-family: KaTeX_Math; + font-weight: bold; + font-style: italic; +} +.katex .amsrm { + font-family: KaTeX_AMS; +} +.katex .mathbb, +.katex .textbb { + font-family: KaTeX_AMS; +} +.katex .mathcal { + font-family: KaTeX_Caligraphic; +} +.katex .mathfrak, +.katex .textfrak { + font-family: KaTeX_Fraktur; +} +.katex .mathboldfrak, +.katex .textboldfrak { + font-family: KaTeX_Fraktur; + font-weight: bold; +} +.katex .mathtt { + font-family: KaTeX_Typewriter; +} +.katex .mathscr, +.katex .textscr { + font-family: KaTeX_Script; +} +.katex .mathsf, +.katex .textsf { + font-family: KaTeX_SansSerif; +} +.katex .mathboldsf, +.katex .textboldsf { + font-family: KaTeX_SansSerif; + font-weight: bold; +} +.katex .mathsfit, +.katex .mathitsf, +.katex .textitsf { + font-family: KaTeX_SansSerif; + font-style: italic; +} +.katex .mainrm { + font-family: KaTeX_Main; + font-style: normal; +} +.katex .vlist-t { + display: inline-table; + table-layout: fixed; + border-collapse: collapse; +} +.katex .vlist-r { + display: table-row; +} +.katex .vlist { + display: table-cell; + vertical-align: bottom; + position: relative; +} +.katex .vlist > span { + display: block; + height: 0; + position: relative; +} +.katex .vlist > span > span { + display: inline-block; +} +.katex .vlist > span > .pstrut { + overflow: hidden; + width: 0; +} +.katex .vlist-t2 { + margin-right: -2px; +} +.katex .vlist-s { + display: table-cell; + vertical-align: bottom; + font-size: 1px; + width: 2px; + min-width: 2px; +} +.katex .vbox { + display: inline-flex; + flex-direction: column; + align-items: baseline; +} +.katex .hbox { + display: inline-flex; + flex-direction: row; + width: 100%; +} +.katex .thinbox { + display: inline-flex; + flex-direction: row; + width: 0; + max-width: 0; +} +.katex .msupsub { + text-align: left; +} +.katex .mfrac > span > span { + text-align: center; +} +.katex .mfrac .frac-line { + display: inline-block; + width: 100%; + border-bottom-style: solid; +} +.katex .mfrac .frac-line, +.katex .overline .overline-line, +.katex .underline .underline-line, +.katex .hline, +.katex .hdashline, +.katex .rule { + min-height: 1px; +} +.katex .mspace { + display: inline-block; +} +.katex .smash { + display: inline; + line-height: 0; +} +.katex .llap, +.katex .rlap, +.katex .clap { + width: 0; + position: relative; +} +.katex .llap > .inner, +.katex .rlap > .inner, +.katex .clap > .inner { + position: absolute; +} +.katex .llap > .fix, +.katex .rlap > .fix, +.katex .clap > .fix { + display: inline-block; +} +.katex .llap > .inner { + right: 0; +} +.katex .rlap > .inner, +.katex .clap > .inner { + left: 0; +} +.katex .clap > .inner > span { + margin-left: -50%; + margin-right: 50%; +} +.katex .rule { + display: inline-block; + border: solid 0; + position: relative; +} +.katex .overline .overline-line, +.katex .underline .underline-line, +.katex .hline { + display: inline-block; + width: 100%; + border-bottom-style: solid; +} +.katex .hdashline { + display: inline-block; + width: 100%; + border-bottom-style: dashed; +} +.katex .sqrt > .root { + /* These values are taken from the definition of `\r@@t`, + `\mkern 5mu` and `\mkern -10mu`. */ + /* stylelint-disable-next-line declaration-property-value-no-unknown */ + margin-left: 0.2777777778em; + /* stylelint-disable-next-line declaration-property-value-no-unknown */ + margin-right: -0.5555555556em; +} +.katex .sizing.reset-size1.size1, +.katex .fontsize-ensurer.reset-size1.size1 { + /* stylelint-disable-next-line */ + font-size: 1em; +} +.katex .sizing.reset-size1.size2, +.katex .fontsize-ensurer.reset-size1.size2 { + /* stylelint-disable-next-line */ + font-size: 1.2em; +} +.katex .sizing.reset-size1.size3, +.katex .fontsize-ensurer.reset-size1.size3 { + /* stylelint-disable-next-line */ + font-size: 1.4em; +} +.katex .sizing.reset-size1.size4, +.katex .fontsize-ensurer.reset-size1.size4 { + /* stylelint-disable-next-line */ + font-size: 1.6em; +} +.katex .sizing.reset-size1.size5, +.katex .fontsize-ensurer.reset-size1.size5 { + /* stylelint-disable-next-line */ + font-size: 1.8em; +} +.katex .sizing.reset-size1.size6, +.katex .fontsize-ensurer.reset-size1.size6 { + /* stylelint-disable-next-line */ + font-size: 2em; +} +.katex .sizing.reset-size1.size7, +.katex .fontsize-ensurer.reset-size1.size7 { + /* stylelint-disable-next-line */ + font-size: 2.4em; +} +.katex .sizing.reset-size1.size8, +.katex .fontsize-ensurer.reset-size1.size8 { + /* stylelint-disable-next-line */ + font-size: 2.88em; +} +.katex .sizing.reset-size1.size9, +.katex .fontsize-ensurer.reset-size1.size9 { + /* stylelint-disable-next-line */ + font-size: 3.456em; +} +.katex .sizing.reset-size1.size10, +.katex .fontsize-ensurer.reset-size1.size10 { + /* stylelint-disable-next-line */ + font-size: 4.148em; +} +.katex .sizing.reset-size1.size11, +.katex .fontsize-ensurer.reset-size1.size11 { + /* stylelint-disable-next-line */ + font-size: 4.976em; +} +.katex .sizing.reset-size2.size1, +.katex .fontsize-ensurer.reset-size2.size1 { + /* stylelint-disable-next-line */ + font-size: 0.8333333333em; +} +.katex .sizing.reset-size2.size2, +.katex .fontsize-ensurer.reset-size2.size2 { + /* stylelint-disable-next-line */ + font-size: 1em; +} +.katex .sizing.reset-size2.size3, +.katex .fontsize-ensurer.reset-size2.size3 { + /* stylelint-disable-next-line */ + font-size: 1.1666666667em; +} +.katex .sizing.reset-size2.size4, +.katex .fontsize-ensurer.reset-size2.size4 { + /* stylelint-disable-next-line */ + font-size: 1.3333333333em; +} +.katex .sizing.reset-size2.size5, +.katex .fontsize-ensurer.reset-size2.size5 { + /* stylelint-disable-next-line */ + font-size: 1.5em; +} +.katex .sizing.reset-size2.size6, +.katex .fontsize-ensurer.reset-size2.size6 { + /* stylelint-disable-next-line */ + font-size: 1.6666666667em; +} +.katex .sizing.reset-size2.size7, +.katex .fontsize-ensurer.reset-size2.size7 { + /* stylelint-disable-next-line */ + font-size: 2em; +} +.katex .sizing.reset-size2.size8, +.katex .fontsize-ensurer.reset-size2.size8 { + /* stylelint-disable-next-line */ + font-size: 2.4em; +} +.katex .sizing.reset-size2.size9, +.katex .fontsize-ensurer.reset-size2.size9 { + /* stylelint-disable-next-line */ + font-size: 2.88em; +} +.katex .sizing.reset-size2.size10, +.katex .fontsize-ensurer.reset-size2.size10 { + /* stylelint-disable-next-line */ + font-size: 3.4566666667em; +} +.katex .sizing.reset-size2.size11, +.katex .fontsize-ensurer.reset-size2.size11 { + /* stylelint-disable-next-line */ + font-size: 4.1466666667em; +} +.katex .sizing.reset-size3.size1, +.katex .fontsize-ensurer.reset-size3.size1 { + /* stylelint-disable-next-line */ + font-size: 0.7142857143em; +} +.katex .sizing.reset-size3.size2, +.katex .fontsize-ensurer.reset-size3.size2 { + /* stylelint-disable-next-line */ + font-size: 0.8571428571em; +} +.katex .sizing.reset-size3.size3, +.katex .fontsize-ensurer.reset-size3.size3 { + /* stylelint-disable-next-line */ + font-size: 1em; +} +.katex .sizing.reset-size3.size4, +.katex .fontsize-ensurer.reset-size3.size4 { + /* stylelint-disable-next-line */ + font-size: 1.1428571429em; +} +.katex .sizing.reset-size3.size5, +.katex .fontsize-ensurer.reset-size3.size5 { + /* stylelint-disable-next-line */ + font-size: 1.2857142857em; +} +.katex .sizing.reset-size3.size6, +.katex .fontsize-ensurer.reset-size3.size6 { + /* stylelint-disable-next-line */ + font-size: 1.4285714286em; +} +.katex .sizing.reset-size3.size7, +.katex .fontsize-ensurer.reset-size3.size7 { + /* stylelint-disable-next-line */ + font-size: 1.7142857143em; +} +.katex .sizing.reset-size3.size8, +.katex .fontsize-ensurer.reset-size3.size8 { + /* stylelint-disable-next-line */ + font-size: 2.0571428571em; +} +.katex .sizing.reset-size3.size9, +.katex .fontsize-ensurer.reset-size3.size9 { + /* stylelint-disable-next-line */ + font-size: 2.4685714286em; +} +.katex .sizing.reset-size3.size10, +.katex .fontsize-ensurer.reset-size3.size10 { + /* stylelint-disable-next-line */ + font-size: 2.9628571429em; +} +.katex .sizing.reset-size3.size11, +.katex .fontsize-ensurer.reset-size3.size11 { + /* stylelint-disable-next-line */ + font-size: 3.5542857143em; +} +.katex .sizing.reset-size4.size1, +.katex .fontsize-ensurer.reset-size4.size1 { + /* stylelint-disable-next-line */ + font-size: 0.625em; +} +.katex .sizing.reset-size4.size2, +.katex .fontsize-ensurer.reset-size4.size2 { + /* stylelint-disable-next-line */ + font-size: 0.75em; +} +.katex .sizing.reset-size4.size3, +.katex .fontsize-ensurer.reset-size4.size3 { + /* stylelint-disable-next-line */ + font-size: 0.875em; +} +.katex .sizing.reset-size4.size4, +.katex .fontsize-ensurer.reset-size4.size4 { + /* stylelint-disable-next-line */ + font-size: 1em; +} +.katex .sizing.reset-size4.size5, +.katex .fontsize-ensurer.reset-size4.size5 { + /* stylelint-disable-next-line */ + font-size: 1.125em; +} +.katex .sizing.reset-size4.size6, +.katex .fontsize-ensurer.reset-size4.size6 { + /* stylelint-disable-next-line */ + font-size: 1.25em; +} +.katex .sizing.reset-size4.size7, +.katex .fontsize-ensurer.reset-size4.size7 { + /* stylelint-disable-next-line */ + font-size: 1.5em; +} +.katex .sizing.reset-size4.size8, +.katex .fontsize-ensurer.reset-size4.size8 { + /* stylelint-disable-next-line */ + font-size: 1.8em; +} +.katex .sizing.reset-size4.size9, +.katex .fontsize-ensurer.reset-size4.size9 { + /* stylelint-disable-next-line */ + font-size: 2.16em; +} +.katex .sizing.reset-size4.size10, +.katex .fontsize-ensurer.reset-size4.size10 { + /* stylelint-disable-next-line */ + font-size: 2.5925em; +} +.katex .sizing.reset-size4.size11, +.katex .fontsize-ensurer.reset-size4.size11 { + /* stylelint-disable-next-line */ + font-size: 3.11em; +} +.katex .sizing.reset-size5.size1, +.katex .fontsize-ensurer.reset-size5.size1 { + /* stylelint-disable-next-line */ + font-size: 0.5555555556em; +} +.katex .sizing.reset-size5.size2, +.katex .fontsize-ensurer.reset-size5.size2 { + /* stylelint-disable-next-line */ + font-size: 0.6666666667em; +} +.katex .sizing.reset-size5.size3, +.katex .fontsize-ensurer.reset-size5.size3 { + /* stylelint-disable-next-line */ + font-size: 0.7777777778em; +} +.katex .sizing.reset-size5.size4, +.katex .fontsize-ensurer.reset-size5.size4 { + /* stylelint-disable-next-line */ + font-size: 0.8888888889em; +} +.katex .sizing.reset-size5.size5, +.katex .fontsize-ensurer.reset-size5.size5 { + /* stylelint-disable-next-line */ + font-size: 1em; +} +.katex .sizing.reset-size5.size6, +.katex .fontsize-ensurer.reset-size5.size6 { + /* stylelint-disable-next-line */ + font-size: 1.1111111111em; +} +.katex .sizing.reset-size5.size7, +.katex .fontsize-ensurer.reset-size5.size7 { + /* stylelint-disable-next-line */ + font-size: 1.3333333333em; +} +.katex .sizing.reset-size5.size8, +.katex .fontsize-ensurer.reset-size5.size8 { + /* stylelint-disable-next-line */ + font-size: 1.6em; +} +.katex .sizing.reset-size5.size9, +.katex .fontsize-ensurer.reset-size5.size9 { + /* stylelint-disable-next-line */ + font-size: 1.92em; +} +.katex .sizing.reset-size5.size10, +.katex .fontsize-ensurer.reset-size5.size10 { + /* stylelint-disable-next-line */ + font-size: 2.3044444444em; +} +.katex .sizing.reset-size5.size11, +.katex .fontsize-ensurer.reset-size5.size11 { + /* stylelint-disable-next-line */ + font-size: 2.7644444444em; +} +.katex .sizing.reset-size6.size1, +.katex .fontsize-ensurer.reset-size6.size1 { + /* stylelint-disable-next-line */ + font-size: 0.5em; +} +.katex .sizing.reset-size6.size2, +.katex .fontsize-ensurer.reset-size6.size2 { + /* stylelint-disable-next-line */ + font-size: 0.6em; +} +.katex .sizing.reset-size6.size3, +.katex .fontsize-ensurer.reset-size6.size3 { + /* stylelint-disable-next-line */ + font-size: 0.7em; +} +.katex .sizing.reset-size6.size4, +.katex .fontsize-ensurer.reset-size6.size4 { + /* stylelint-disable-next-line */ + font-size: 0.8em; +} +.katex .sizing.reset-size6.size5, +.katex .fontsize-ensurer.reset-size6.size5 { + /* stylelint-disable-next-line */ + font-size: 0.9em; +} +.katex .sizing.reset-size6.size6, +.katex .fontsize-ensurer.reset-size6.size6 { + /* stylelint-disable-next-line */ + font-size: 1em; +} +.katex .sizing.reset-size6.size7, +.katex .fontsize-ensurer.reset-size6.size7 { + /* stylelint-disable-next-line */ + font-size: 1.2em; +} +.katex .sizing.reset-size6.size8, +.katex .fontsize-ensurer.reset-size6.size8 { + /* stylelint-disable-next-line */ + font-size: 1.44em; +} +.katex .sizing.reset-size6.size9, +.katex .fontsize-ensurer.reset-size6.size9 { + /* stylelint-disable-next-line */ + font-size: 1.728em; +} +.katex .sizing.reset-size6.size10, +.katex .fontsize-ensurer.reset-size6.size10 { + /* stylelint-disable-next-line */ + font-size: 2.074em; +} +.katex .sizing.reset-size6.size11, +.katex .fontsize-ensurer.reset-size6.size11 { + /* stylelint-disable-next-line */ + font-size: 2.488em; +} +.katex .sizing.reset-size7.size1, +.katex .fontsize-ensurer.reset-size7.size1 { + /* stylelint-disable-next-line */ + font-size: 0.4166666667em; +} +.katex .sizing.reset-size7.size2, +.katex .fontsize-ensurer.reset-size7.size2 { + /* stylelint-disable-next-line */ + font-size: 0.5em; +} +.katex .sizing.reset-size7.size3, +.katex .fontsize-ensurer.reset-size7.size3 { + /* stylelint-disable-next-line */ + font-size: 0.5833333333em; +} +.katex .sizing.reset-size7.size4, +.katex .fontsize-ensurer.reset-size7.size4 { + /* stylelint-disable-next-line */ + font-size: 0.6666666667em; +} +.katex .sizing.reset-size7.size5, +.katex .fontsize-ensurer.reset-size7.size5 { + /* stylelint-disable-next-line */ + font-size: 0.75em; +} +.katex .sizing.reset-size7.size6, +.katex .fontsize-ensurer.reset-size7.size6 { + /* stylelint-disable-next-line */ + font-size: 0.8333333333em; +} +.katex .sizing.reset-size7.size7, +.katex .fontsize-ensurer.reset-size7.size7 { + /* stylelint-disable-next-line */ + font-size: 1em; +} +.katex .sizing.reset-size7.size8, +.katex .fontsize-ensurer.reset-size7.size8 { + /* stylelint-disable-next-line */ + font-size: 1.2em; +} +.katex .sizing.reset-size7.size9, +.katex .fontsize-ensurer.reset-size7.size9 { + /* stylelint-disable-next-line */ + font-size: 1.44em; +} +.katex .sizing.reset-size7.size10, +.katex .fontsize-ensurer.reset-size7.size10 { + /* stylelint-disable-next-line */ + font-size: 1.7283333333em; +} +.katex .sizing.reset-size7.size11, +.katex .fontsize-ensurer.reset-size7.size11 { + /* stylelint-disable-next-line */ + font-size: 2.0733333333em; +} +.katex .sizing.reset-size8.size1, +.katex .fontsize-ensurer.reset-size8.size1 { + /* stylelint-disable-next-line */ + font-size: 0.3472222222em; +} +.katex .sizing.reset-size8.size2, +.katex .fontsize-ensurer.reset-size8.size2 { + /* stylelint-disable-next-line */ + font-size: 0.4166666667em; +} +.katex .sizing.reset-size8.size3, +.katex .fontsize-ensurer.reset-size8.size3 { + /* stylelint-disable-next-line */ + font-size: 0.4861111111em; +} +.katex .sizing.reset-size8.size4, +.katex .fontsize-ensurer.reset-size8.size4 { + /* stylelint-disable-next-line */ + font-size: 0.5555555556em; +} +.katex .sizing.reset-size8.size5, +.katex .fontsize-ensurer.reset-size8.size5 { + /* stylelint-disable-next-line */ + font-size: 0.625em; +} +.katex .sizing.reset-size8.size6, +.katex .fontsize-ensurer.reset-size8.size6 { + /* stylelint-disable-next-line */ + font-size: 0.6944444444em; +} +.katex .sizing.reset-size8.size7, +.katex .fontsize-ensurer.reset-size8.size7 { + /* stylelint-disable-next-line */ + font-size: 0.8333333333em; +} +.katex .sizing.reset-size8.size8, +.katex .fontsize-ensurer.reset-size8.size8 { + /* stylelint-disable-next-line */ + font-size: 1em; +} +.katex .sizing.reset-size8.size9, +.katex .fontsize-ensurer.reset-size8.size9 { + /* stylelint-disable-next-line */ + font-size: 1.2em; +} +.katex .sizing.reset-size8.size10, +.katex .fontsize-ensurer.reset-size8.size10 { + /* stylelint-disable-next-line */ + font-size: 1.4402777778em; +} +.katex .sizing.reset-size8.size11, +.katex .fontsize-ensurer.reset-size8.size11 { + /* stylelint-disable-next-line */ + font-size: 1.7277777778em; +} +.katex .sizing.reset-size9.size1, +.katex .fontsize-ensurer.reset-size9.size1 { + /* stylelint-disable-next-line */ + font-size: 0.2893518519em; +} +.katex .sizing.reset-size9.size2, +.katex .fontsize-ensurer.reset-size9.size2 { + /* stylelint-disable-next-line */ + font-size: 0.3472222222em; +} +.katex .sizing.reset-size9.size3, +.katex .fontsize-ensurer.reset-size9.size3 { + /* stylelint-disable-next-line */ + font-size: 0.4050925926em; +} +.katex .sizing.reset-size9.size4, +.katex .fontsize-ensurer.reset-size9.size4 { + /* stylelint-disable-next-line */ + font-size: 0.462962963em; +} +.katex .sizing.reset-size9.size5, +.katex .fontsize-ensurer.reset-size9.size5 { + /* stylelint-disable-next-line */ + font-size: 0.5208333333em; +} +.katex .sizing.reset-size9.size6, +.katex .fontsize-ensurer.reset-size9.size6 { + /* stylelint-disable-next-line */ + font-size: 0.5787037037em; +} +.katex .sizing.reset-size9.size7, +.katex .fontsize-ensurer.reset-size9.size7 { + /* stylelint-disable-next-line */ + font-size: 0.6944444444em; +} +.katex .sizing.reset-size9.size8, +.katex .fontsize-ensurer.reset-size9.size8 { + /* stylelint-disable-next-line */ + font-size: 0.8333333333em; +} +.katex .sizing.reset-size9.size9, +.katex .fontsize-ensurer.reset-size9.size9 { + /* stylelint-disable-next-line */ + font-size: 1em; +} +.katex .sizing.reset-size9.size10, +.katex .fontsize-ensurer.reset-size9.size10 { + /* stylelint-disable-next-line */ + font-size: 1.2002314815em; +} +.katex .sizing.reset-size9.size11, +.katex .fontsize-ensurer.reset-size9.size11 { + /* stylelint-disable-next-line */ + font-size: 1.4398148148em; +} +.katex .sizing.reset-size10.size1, +.katex .fontsize-ensurer.reset-size10.size1 { + /* stylelint-disable-next-line */ + font-size: 0.2410800386em; +} +.katex .sizing.reset-size10.size2, +.katex .fontsize-ensurer.reset-size10.size2 { + /* stylelint-disable-next-line */ + font-size: 0.2892960463em; +} +.katex .sizing.reset-size10.size3, +.katex .fontsize-ensurer.reset-size10.size3 { + /* stylelint-disable-next-line */ + font-size: 0.337512054em; +} +.katex .sizing.reset-size10.size4, +.katex .fontsize-ensurer.reset-size10.size4 { + /* stylelint-disable-next-line */ + font-size: 0.3857280617em; +} +.katex .sizing.reset-size10.size5, +.katex .fontsize-ensurer.reset-size10.size5 { + /* stylelint-disable-next-line */ + font-size: 0.4339440694em; +} +.katex .sizing.reset-size10.size6, +.katex .fontsize-ensurer.reset-size10.size6 { + /* stylelint-disable-next-line */ + font-size: 0.4821600771em; +} +.katex .sizing.reset-size10.size7, +.katex .fontsize-ensurer.reset-size10.size7 { + /* stylelint-disable-next-line */ + font-size: 0.5785920926em; +} +.katex .sizing.reset-size10.size8, +.katex .fontsize-ensurer.reset-size10.size8 { + /* stylelint-disable-next-line */ + font-size: 0.6943105111em; +} +.katex .sizing.reset-size10.size9, +.katex .fontsize-ensurer.reset-size10.size9 { + /* stylelint-disable-next-line */ + font-size: 0.8331726133em; +} +.katex .sizing.reset-size10.size10, +.katex .fontsize-ensurer.reset-size10.size10 { + /* stylelint-disable-next-line */ + font-size: 1em; +} +.katex .sizing.reset-size10.size11, +.katex .fontsize-ensurer.reset-size10.size11 { + /* stylelint-disable-next-line */ + font-size: 1.1996142719em; +} +.katex .sizing.reset-size11.size1, +.katex .fontsize-ensurer.reset-size11.size1 { + /* stylelint-disable-next-line */ + font-size: 0.2009646302em; +} +.katex .sizing.reset-size11.size2, +.katex .fontsize-ensurer.reset-size11.size2 { + /* stylelint-disable-next-line */ + font-size: 0.2411575563em; +} +.katex .sizing.reset-size11.size3, +.katex .fontsize-ensurer.reset-size11.size3 { + /* stylelint-disable-next-line */ + font-size: 0.2813504823em; +} +.katex .sizing.reset-size11.size4, +.katex .fontsize-ensurer.reset-size11.size4 { + /* stylelint-disable-next-line */ + font-size: 0.3215434084em; +} +.katex .sizing.reset-size11.size5, +.katex .fontsize-ensurer.reset-size11.size5 { + /* stylelint-disable-next-line */ + font-size: 0.3617363344em; +} +.katex .sizing.reset-size11.size6, +.katex .fontsize-ensurer.reset-size11.size6 { + /* stylelint-disable-next-line */ + font-size: 0.4019292605em; +} +.katex .sizing.reset-size11.size7, +.katex .fontsize-ensurer.reset-size11.size7 { + /* stylelint-disable-next-line */ + font-size: 0.4823151125em; +} +.katex .sizing.reset-size11.size8, +.katex .fontsize-ensurer.reset-size11.size8 { + /* stylelint-disable-next-line */ + font-size: 0.578778135em; +} +.katex .sizing.reset-size11.size9, +.katex .fontsize-ensurer.reset-size11.size9 { + /* stylelint-disable-next-line */ + font-size: 0.6945337621em; +} +.katex .sizing.reset-size11.size10, +.katex .fontsize-ensurer.reset-size11.size10 { + /* stylelint-disable-next-line */ + font-size: 0.8336012862em; +} +.katex .sizing.reset-size11.size11, +.katex .fontsize-ensurer.reset-size11.size11 { + /* stylelint-disable-next-line */ + font-size: 1em; +} +.katex .delimsizing.size1 { + font-family: KaTeX_Size1; +} +.katex .delimsizing.size2 { + font-family: KaTeX_Size2; +} +.katex .delimsizing.size3 { + font-family: KaTeX_Size3; +} +.katex .delimsizing.size4 { + font-family: KaTeX_Size4; +} +.katex .delimsizing.mult .delim-size1 > span { + font-family: KaTeX_Size1; +} +.katex .delimsizing.mult .delim-size4 > span { + font-family: KaTeX_Size4; +} +.katex .nulldelimiter { + display: inline-block; + width: 0.12em; +} +.katex .delimcenter { + position: relative; +} +.katex .op-symbol { + position: relative; +} +.katex .op-symbol.small-op { + font-family: KaTeX_Size1; +} +.katex .op-symbol.large-op { + font-family: KaTeX_Size2; +} +.katex .op-limits > .vlist-t { + text-align: center; +} +.katex .accent > .vlist-t { + text-align: center; +} +.katex .accent .accent-body { + position: relative; +} +.katex .accent .accent-body:not(.accent-full) { + width: 0; +} +.katex .overlay { + display: block; +} +.katex .mtable .vertical-separator { + display: inline-block; + min-width: 1px; +} +.katex .mtable .arraycolsep { + display: inline-block; +} +.katex .mtable .col-align-c > .vlist-t { + text-align: center; +} +.katex .mtable .col-align-l > .vlist-t { + text-align: left; +} +.katex .mtable .col-align-r > .vlist-t { + text-align: right; +} +.katex .svg-align { + text-align: left; +} +.katex svg { + display: block; + position: absolute; + width: 100%; + height: inherit; + fill: currentColor; + stroke: currentColor; +} +.katex svg path { + stroke: none; +} +.katex svg { + fill-rule: nonzero; + fill-opacity: 1; + stroke-width: 1; + stroke-linecap: butt; + stroke-linejoin: miter; + stroke-miterlimit: 4; + stroke-dasharray: none; + stroke-dashoffset: 0; + stroke-opacity: 1; +} +.katex img { + border-style: none; + min-width: 0; + min-height: 0; + max-width: none; + max-height: none; +} +.katex .stretchy { + width: 100%; + display: block; + position: relative; + overflow: hidden; +} +.katex .stretchy::before, .katex .stretchy::after { + content: ""; +} +.katex .hide-tail { + width: 100%; + position: relative; + overflow: hidden; +} +.katex .halfarrow-left { + position: absolute; + left: 0; + width: 50.2%; + overflow: hidden; +} +.katex .halfarrow-right { + position: absolute; + right: 0; + width: 50.2%; + overflow: hidden; +} +.katex .brace-left { + position: absolute; + left: 0; + width: 25.1%; + overflow: hidden; +} +.katex .brace-center { + position: absolute; + left: 25%; + width: 50%; + overflow: hidden; +} +.katex .brace-right { + position: absolute; + right: 0; + width: 25.1%; + overflow: hidden; +} +.katex .x-arrow-pad { + padding: 0 0.5em; +} +.katex .cd-arrow-pad { + padding: 0 0.55556em 0 0.27778em; +} +.katex .x-arrow, +.katex .mover, +.katex .munder { + text-align: center; +} +.katex .boxpad { + padding: 0 0.3em; +} +.katex .fbox, +.katex .fcolorbox { + box-sizing: border-box; + border: 0.04em solid; +} +.katex .cancel-pad { + padding: 0 0.2em; +} +.katex .cancel-lap { + margin-left: -0.2em; + margin-right: -0.2em; +} +.katex .sout { + border-bottom-style: solid; + border-bottom-width: 0.08em; +} +.katex .angl { + box-sizing: border-box; + border-top: 0.049em solid; + border-right: 0.049em solid; + margin-right: 0.03889em; +} +.katex .anglpad { + padding: 0 0.03889em; +} +.katex .eqn-num::before { + counter-increment: katexEqnNo; + content: "(" counter(katexEqnNo) ")"; +} +.katex .mml-eqn-num::before { + counter-increment: mmlEqnNo; + content: "(" counter(mmlEqnNo) ")"; +} +.katex .mtr-glue { + width: 50%; +} +.katex .cd-vert-arrow { + display: inline-block; + position: relative; +} +.katex .cd-label-left { + display: inline-block; + position: absolute; + right: calc(50% + 0.3em); + text-align: left; +} +.katex .cd-label-right { + display: inline-block; + position: absolute; + left: calc(50% + 0.3em); + text-align: right; +} + +.katex-display { + display: block; + margin: 1em 0; + text-align: center; +} +.katex-display > .katex { + display: block; + text-align: center; + white-space: nowrap; +} +.katex-display > .katex > .katex-html { + display: block; + position: relative; +} +.katex-display > .katex > .katex-html > .tag { + position: absolute; + right: 0; +} + +.katex-display.leqno > .katex > .katex-html > .tag { + left: 0; + right: auto; +} + +.katex-display.fleqn > .katex { + text-align: left; + padding-left: 2em; +} + +body { + counter-reset: katexEqnNo mmlEqnNo; +} diff --git a/node_modules/react-katex/node_modules/katex/dist/katex.js b/node_modules/react-katex/node_modules/katex/dist/katex.js new file mode 100644 index 0000000..2de2003 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/dist/katex.js @@ -0,0 +1,18010 @@ +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(); + else if(typeof define === 'function' && define.amd) + define([], factory); + else if(typeof exports === 'object') + exports["katex"] = factory(); + else + root["katex"] = factory(); +})((typeof self !== 'undefined' ? self : this), function() { +return /******/ (function() { // webpackBootstrap +/******/ "use strict"; +/******/ // The require scope +/******/ var __webpack_require__ = {}; +/******/ +/************************************************************************/ +/******/ /* webpack/runtime/define property getters */ +/******/ !function() { +/******/ // define getter functions for harmony exports +/******/ __webpack_require__.d = function(exports, definition) { +/******/ for(var key in definition) { +/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { +/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); +/******/ } +/******/ } +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/hasOwnProperty shorthand */ +/******/ !function() { +/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } +/******/ }(); +/******/ +/************************************************************************/ +var __webpack_exports__ = {}; + +// EXPORTS +__webpack_require__.d(__webpack_exports__, { + "default": function() { return /* binding */ katex_webpack; } +}); + +;// ./src/ParseError.ts +/** + * This is the ParseError class, which is the main error thrown by KaTeX + * functions when something has gone wrong. This is used to distinguish internal + * errors from errors in the expression that the user provided. + * + * If possible, a caller should provide a Token or ParseNode with information + * about where in the source string the problem occurred. + */ +class ParseError extends Error { + // The underlying error message without any context added. + + constructor(message, + // The error message + token) { + let error = "KaTeX parse error: " + message; + let start; + let end; + const loc = token && token.loc; + if (loc && loc.start <= loc.end) { + // If we have the input and a position, make the error a bit fancier + + // Get the input + const input = loc.lexer.input; + + // Prepend some information + start = loc.start; + end = loc.end; + if (start === input.length) { + error += " at end of input: "; + } else { + error += " at position " + (start + 1) + ": "; + } + + // Underline token in question using combining underscores + const underlined = input.slice(start, end).replace(/[^]/g, "$&\u0332"); + + // Extract some context from the input and add it to the error + let left; + if (start > 15) { + left = "…" + input.slice(start - 15, start); + } else { + left = input.slice(0, start); + } + let right; + if (end + 15 < input.length) { + right = input.slice(end, end + 15) + "…"; + } else { + right = input.slice(end); + } + error += left + underlined + right; + } + super(error); + this.name = "ParseError"; + this.position = void 0; + // Error start position based on passed-in Token or ParseNode. + this.length = void 0; + // Length of affected text based on passed-in Token or ParseNode. + this.rawMessage = void 0; + Object.setPrototypeOf(this, ParseError.prototype); + this.position = start; + if (start != null && end != null) { + this.length = end - start; + } + this.rawMessage = message; + } +} +/* harmony default export */ var src_ParseError = (ParseError); +;// ./src/utils.ts +/** + * This file contains a list of utility functions which are useful in other + * files. + */ + +// hyphenate and escape adapted from Facebook's React under Apache 2 license +const uppercase = /([A-Z])/g; +const hyphenate = str => str.replace(uppercase, "-$1").toLowerCase(); +const ESCAPE_LOOKUP = { + "&": "&", + ">": ">", + "<": "<", + "\"": """, + "'": "'" +}; +const ESCAPE_REGEX = /[&><"']/g; + +/** + * Escapes text to prevent scripting attacks. + */ +const utils_escape = text => String(text).replace(ESCAPE_REGEX, match => ESCAPE_LOOKUP[match]); + +/** + * Sometimes we want to pull out the innermost element of a group. In most + * cases, this will just be the group itself, but when ordgroups and colors have + * a single element, we want to pull that out. + */ +const getBaseElem = group => { + if (group.type === "ordgroup") { + if (group.body.length === 1) { + return getBaseElem(group.body[0]); + } else { + return group; + } + } else if (group.type === "color") { + if (group.body.length === 1) { + return getBaseElem(group.body[0]); + } else { + return group; + } + } else if (group.type === "font") { + return getBaseElem(group.body); + } else { + return group; + } +}; +const characterNodesTypes = new Set(["mathord", "textord", "atom"]); + +/** + * TeXbook algorithms often reference "character boxes", which are simply groups + * with a single character in them. To decide if something is a character box, + * we find its innermost group, and see if it is a single character. + */ +const isCharacterBox = group => characterNodesTypes.has(getBaseElem(group).type); + +/** + * Return the protocol of a URL, or "_relative" if the URL does not specify a + * protocol (and thus is relative), or `null` if URL has invalid protocol + * (so should be outright rejected). + */ +const protocolFromUrl = url => { + // Check for possible leading protocol. + // https://url.spec.whatwg.org/#url-parsing strips leading whitespace + // (U+20) or C0 control (U+00-U+1F) characters. + const protocol = /^[\x00-\x20]*([^\\/#?]*?)(:|�*58|�*3a|&colon)/i.exec(url); + if (!protocol) { + return "_relative"; + } + // Reject weird colons + if (protocol[2] !== ":") { + return null; + } + // Reject invalid characters in scheme according to + // https://datatracker.ietf.org/doc/html/rfc3986#section-3.1 + if (!/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(protocol[1])) { + return null; + } + // Lowercase the protocol + return protocol[1].toLowerCase(); +}; +;// ./src/Settings.ts +/* eslint no-console:0 */ +/** + * This is a module for storing settings passed into KaTeX. It correctly handles + * default settings. + */ + + + + +/** + * Union of all values that appear as schema defaults, cliDefaults, or + * cliProcessor return values. StrictFunction / TrustFunction are + * option-value types, not default/schema values, so they are excluded. + */ + +// TODO: automatically generate documentation +// TODO: check all properties on Settings exist +// TODO: check the type of a property on Settings matches +const SETTINGS_SCHEMA = { + displayMode: { + type: "boolean", + description: "Render math in display mode, which puts the math in " + "display style (so \\int and \\sum are large, for example), and " + "centers the math on the page on its own line.", + cli: "-d, --display-mode" + }, + output: { + type: { + enum: ["htmlAndMathml", "html", "mathml"] + }, + description: "Determines the markup language of the output.", + cli: "-F, --format " + }, + leqno: { + type: "boolean", + description: "Render display math in leqno style (left-justified tags)." + }, + fleqn: { + type: "boolean", + description: "Render display math flush left." + }, + throwOnError: { + type: "boolean", + default: true, + cli: "-t, --no-throw-on-error", + cliDescription: "Render errors (in the color given by --error-color) ins" + "tead of throwing a ParseError exception when encountering an error." + }, + errorColor: { + type: "string", + default: "#cc0000", + cli: "-c, --error-color ", + cliDescription: "A color string given in the format 'rgb' or 'rrggbb' " + "(no #). This option determines the color of errors rendered by the " + "-t option.", + cliProcessor: color => "#" + color + }, + macros: { + type: "object", + cli: "-m, --macro ", + cliDescription: "Define custom macro of the form '\\foo:expansion' (use " + "multiple -m arguments for multiple macros).", + cliDefault: [], + cliProcessor: (def, defs) => { + defs.push(def); + return defs; + } + }, + minRuleThickness: { + type: "number", + description: "Specifies a minimum thickness, in ems, for fraction lines," + " `\\sqrt` top lines, `{array}` vertical lines, `\\hline`, " + "`\\hdashline`, `\\underline`, `\\overline`, and the borders of " + "`\\fbox`, `\\boxed`, and `\\fcolorbox`.", + processor: t => Math.max(0, t), + cli: "--min-rule-thickness ", + cliProcessor: parseFloat + }, + colorIsTextColor: { + type: "boolean", + description: "Makes \\color behave like LaTeX's 2-argument \\textcolor, " + "instead of LaTeX's one-argument \\color mode change.", + cli: "-b, --color-is-text-color" + }, + strict: { + type: [{ + enum: ["warn", "ignore", "error"] + }, "boolean", "function"], + description: "Turn on strict / LaTeX faithfulness mode, which throws an " + "error if the input uses features that are not supported by LaTeX.", + cli: "-S, --strict", + cliDefault: false + }, + trust: { + type: ["boolean", "function"], + description: "Trust the input, enabling all HTML features such as \\url.", + cli: "-T, --trust" + }, + maxSize: { + type: "number", + default: Infinity, + description: "If non-zero, all user-specified sizes, e.g. in " + "\\rule{500em}{500em}, will be capped to maxSize ems. Otherwise, " + "elements and spaces can be arbitrarily large", + processor: s => Math.max(0, s), + cli: "-s, --max-size ", + cliProcessor: parseInt + }, + maxExpand: { + type: "number", + default: 1000, + description: "Limit the number of macro expansions to the specified " + "number, to prevent e.g. infinite macro loops. If set to Infinity, " + "the macro expander will try to fully expand as in LaTeX.", + processor: n => Math.max(0, n), + cli: "-e, --max-expand ", + cliProcessor: n => n === "Infinity" ? Infinity : parseInt(n) + }, + globalGroup: { + type: "boolean", + cli: false + } +}; +function getImplicitDefault(type) { + if (typeof type !== 'string') { + return type.enum[0]; + } + switch (type) { + case 'boolean': + return false; + case 'string': + return ''; + case 'number': + return 0; + case 'object': + return {}; + default: + throw new Error("Unexpected schema type; settings must declare an explicit default."); + } +} +function getDefaultValue(schema) { + if (schema.default !== undefined) { + return schema.default; + } + const type = Array.isArray(schema.type) ? schema.type[0] : schema.type; + return getImplicitDefault(type); +} +function applySetting(target, prop, options, schema) { + const optionValue = options[prop]; + target[prop] = optionValue !== undefined ? schema.processor ? schema.processor(optionValue) : optionValue : getDefaultValue(schema); +} + +/** + * The main Settings object + * + * The current options stored are: + * - displayMode: Whether the expression should be typeset as inline math + * (false, the default), meaning that the math starts in + * \textstyle and is placed in an inline-block); or as display + * math (true), meaning that the math starts in \displaystyle + * and is placed in a block with vertical margin. + */ +class Settings { + constructor(options) { + if (options === void 0) { + options = {}; + } + this.displayMode = void 0; + this.output = void 0; + this.leqno = void 0; + this.fleqn = void 0; + this.throwOnError = void 0; + this.errorColor = void 0; + this.macros = void 0; + this.minRuleThickness = void 0; + this.colorIsTextColor = void 0; + this.strict = void 0; + this.trust = void 0; + this.maxSize = void 0; + this.maxExpand = void 0; + this.globalGroup = void 0; + // allow null options + options = options || {}; + for (const prop of Object.keys(SETTINGS_SCHEMA)) { + const schema = SETTINGS_SCHEMA[prop]; + if (schema) { + // TODO: validate options + applySetting(this, prop, options, schema); + } + } + } + + /** + * Report nonstrict (non-LaTeX-compatible) input. + * Can safely not be called if `this.strict` is false in JavaScript. + */ + reportNonstrict(errorCode, errorMsg, token) { + let strict = this.strict; + if (typeof strict === "function") { + // Allow return value of strict function to be boolean or string + // (or null/undefined, meaning no further processing). + strict = strict(errorCode, errorMsg, token); + } + if (!strict || strict === "ignore") { + return; + } else if (strict === true || strict === "error") { + throw new src_ParseError("LaTeX-incompatible input and strict mode is set to 'error': " + (errorMsg + " [" + errorCode + "]"), token); + } else if (strict === "warn") { + typeof console !== "undefined" && console.warn("LaTeX-incompatible input and strict mode is set to 'warn': " + (errorMsg + " [" + errorCode + "]")); + } else { + // won't happen in type-safe code + typeof console !== "undefined" && console.warn("LaTeX-incompatible input and strict mode is set to " + ("unrecognized '" + strict + "': " + errorMsg + " [" + errorCode + "]")); + } + } + + /** + * Check whether to apply strict (LaTeX-adhering) behavior for unusual + * input (like `\\`). Unlike `nonstrict`, will not throw an error; + * instead, "error" translates to a return value of `true`, while "ignore" + * translates to a return value of `false`. May still print a warning: + * "warn" prints a warning and returns `false`. + * This is for the second category of `errorCode`s listed in the README. + */ + useStrictBehavior(errorCode, errorMsg, token) { + let strict = this.strict; + if (typeof strict === "function") { + // Allow return value of strict function to be boolean or string + // (or null/undefined, meaning no further processing). + // But catch any exceptions thrown by function, treating them + // like "error". + try { + strict = strict(errorCode, errorMsg, token); + } catch (error) { + strict = "error"; + } + } + if (!strict || strict === "ignore") { + return false; + } else if (strict === true || strict === "error") { + return true; + } else if (strict === "warn") { + typeof console !== "undefined" && console.warn("LaTeX-incompatible input and strict mode is set to 'warn': " + (errorMsg + " [" + errorCode + "]")); + return false; + } else { + // won't happen in type-safe code + typeof console !== "undefined" && console.warn("LaTeX-incompatible input and strict mode is set to " + ("unrecognized '" + strict + "': " + errorMsg + " [" + errorCode + "]")); + return false; + } + } + + /** + * Check whether to test potentially dangerous input, and return + * `true` (trusted) or `false` (untrusted). The sole argument `context` + * should be an object with `command` field specifying the relevant LaTeX + * command (as a string starting with `\`), and any other arguments, etc. + * If `context` has a `url` field, a `protocol` field will automatically + * get added by this function (changing the specified object). + */ + isTrusted(context) { + if ("url" in context && context.url && !context.protocol) { + const protocol = protocolFromUrl(context.url); + if (protocol == null) { + return false; + } + context.protocol = protocol; + } + const trust = typeof this.trust === "function" ? this.trust(context) : this.trust; + return Boolean(trust); + } +} +;// ./src/Style.ts +/** + * This file contains information and classes for the various kinds of styles + * used in TeX. It provides a generic `Style` class, which holds information + * about a specific style. It then provides instances of all the different kinds + * of styles possible, and provides functions to move between them and get + * information about them. + */ + +/** + * The main style class. Contains a unique id for the style, a size (which is + * the same for cramped and uncramped version of a style), and a cramped flag. + */ +class Style { + constructor(id, size, cramped) { + this.id = void 0; + this.size = void 0; + this.cramped = void 0; + this.id = id; + this.size = size; + this.cramped = cramped; + } + + /** + * Get the style of a superscript given a base in the current style. + */ + sup() { + return styles[sup[this.id]]; + } + + /** + * Get the style of a subscript given a base in the current style. + */ + sub() { + return styles[sub[this.id]]; + } + + /** + * Get the style of a fraction numerator given the fraction in the current + * style. + */ + fracNum() { + return styles[fracNum[this.id]]; + } + + /** + * Get the style of a fraction denominator given the fraction in the current + * style. + */ + fracDen() { + return styles[fracDen[this.id]]; + } + + /** + * Get the cramped version of a style (in particular, cramping a cramped style + * doesn't change the style). + */ + cramp() { + return styles[cramp[this.id]]; + } + + /** + * Get a text or display version of this style. + */ + text() { + return styles[Style_text[this.id]]; + } + + /** + * Return true if this style is tightly spaced (scriptstyle/scriptscriptstyle) + */ + isTight() { + return this.size >= 2; + } +} + +// Export an interface for type checking, but don't expose the implementation. +// This way, no more styles can be generated. + +// IDs of the different styles +const D = 0; +const Dc = 1; +const T = 2; +const Tc = 3; +const S = 4; +const Sc = 5; +const SS = 6; +const SSc = 7; + +// Instances of the different styles +const styles = [new Style(D, 0, false), new Style(Dc, 0, true), new Style(T, 1, false), new Style(Tc, 1, true), new Style(S, 2, false), new Style(Sc, 2, true), new Style(SS, 3, false), new Style(SSc, 3, true)]; + +// Lookup tables for switching from one style to another +const sup = [S, Sc, S, Sc, SS, SSc, SS, SSc]; +const sub = [Sc, Sc, Sc, Sc, SSc, SSc, SSc, SSc]; +const fracNum = [T, Tc, S, Sc, SS, SSc, SS, SSc]; +const fracDen = [Tc, Tc, Sc, Sc, SSc, SSc, SSc, SSc]; +const cramp = [Dc, Dc, Tc, Tc, Sc, Sc, SSc, SSc]; +const Style_text = [D, Dc, T, Tc, T, Tc, T, Tc]; + +// We only export some of the styles. +/* harmony default export */ var src_Style = ({ + DISPLAY: styles[D], + TEXT: styles[T], + SCRIPT: styles[S], + SCRIPTSCRIPT: styles[SS] +}); +;// ./src/unicodeScripts.ts +/* + * This file defines the Unicode scripts and script families that we + * support. To add new scripts or families, just add a new entry to the + * scriptData array below. Adding scripts to the scriptData array allows + * characters from that script to appear in \text{} environments. + */ + +/** + * Each script or script family has a name and an array of blocks. + * Each block is an array of two numbers which specify the start and + * end points (inclusive) of a block of Unicode codepoints. + */ + +/** + * Unicode block data for the families of scripts we support in \text{}. + * Scripts only need to appear here if they do not have font metrics. + */ +const scriptData = [{ + // Latin characters beyond the Latin-1 characters we have metrics for. + // Needed for Czech, Hungarian and Turkish text, for example. + name: 'latin', + blocks: [[0x0100, 0x024f], + // Latin Extended-A and Latin Extended-B + [0x0300, 0x036f] // Combining Diacritical marks + ] +}, { + // The Cyrillic script used by Russian and related languages. + // A Cyrillic subset used to be supported as explicitly defined + // symbols in symbols.js + name: 'cyrillic', + blocks: [[0x0400, 0x04ff]] +}, { + // Armenian + name: 'armenian', + blocks: [[0x0530, 0x058F]] +}, { + // The Brahmic scripts of South and Southeast Asia + // Devanagari (0900–097F) + // Bengali (0980–09FF) + // Gurmukhi (0A00–0A7F) + // Gujarati (0A80–0AFF) + // Oriya (0B00–0B7F) + // Tamil (0B80–0BFF) + // Telugu (0C00–0C7F) + // Kannada (0C80–0CFF) + // Malayalam (0D00–0D7F) + // Sinhala (0D80–0DFF) + // Thai (0E00–0E7F) + // Lao (0E80–0EFF) + // Tibetan (0F00–0FFF) + // Myanmar (1000–109F) + name: 'brahmic', + blocks: [[0x0900, 0x109F]] +}, { + name: 'georgian', + blocks: [[0x10A0, 0x10ff]] +}, { + // Chinese and Japanese. + // The "k" in cjk is for Korean, but we've separated Korean out + name: "cjk", + blocks: [[0x3000, 0x30FF], + // CJK symbols and punctuation, Hiragana, Katakana + [0x4E00, 0x9FAF], + // CJK ideograms + [0xFF00, 0xFF60] // Fullwidth punctuation + // TODO: add halfwidth Katakana and Romanji glyphs + ] +}, { + // Korean + name: 'hangul', + blocks: [[0xAC00, 0xD7AF]] +}]; + +/** + * Given a codepoint, return the name of the script or script family + * it is from, or null if it is not part of a known block + */ +function scriptFromCodepoint(codepoint) { + for (let i = 0; i < scriptData.length; i++) { + const script = scriptData[i]; + for (let i = 0; i < script.blocks.length; i++) { + const block = script.blocks[i]; + if (codepoint >= block[0] && codepoint <= block[1]) { + return script.name; + } + } + } + return null; +} + +/** + * A flattened version of all the supported blocks in a single array. + * This is an optimization to make supportedCodepoint() fast. + */ +const allBlocks = []; +scriptData.forEach(s => s.blocks.forEach(b => allBlocks.push(...b))); + +/** + * Given a codepoint, return true if it falls within one of the + * scripts or script families defined above and false otherwise. + * + * Micro benchmarks shows that this is faster than + * /[\u3000-\u30FF\u4E00-\u9FAF\uFF00-\uFF60\uAC00-\uD7AF\u0900-\u109F]/.test() + * in Firefox, Chrome and Node. + */ +function supportedCodepoint(codepoint) { + for (let i = 0; i < allBlocks.length; i += 2) { + if (codepoint >= allBlocks[i] && codepoint <= allBlocks[i + 1]) { + return true; + } + } + return false; +} +;// ./src/svgGeometry.ts +/** + * This file provides support to domTree.js and delimiter.js. + * It's a storehouse of path geometry for SVG images. + */ + +// In all paths below, the viewBox-to-em scale is 1000:1. + +// Second Brush Stroke +// Low resolution monitors struggle to display images in fine detail. +// So browsers apply anti-aliasing. A long straight arrow shaft therefore +// will sometimes appear as if it has a blurred edge. + +// To mitigate this, these SVG files contain a second "brush-stroke" on the +// arrow shafts. That is, a second long thin rectangular SVG path has been +// written directly on top of each arrow shaft. This reinforcement causes +// some of the screen pixels to display as black instead of the anti-aliased +// gray pixel that a single path would generate. So we get arrow shafts +// whose edges appear to be sharper. +const doubleBrushStroke = svgPath => svgPath + " " + svgPath; +const hLinePad = 80; // padding above a sqrt vinculum. Prevents image cropping. + +// The vinculum of a \sqrt can be made thicker by a KaTeX rendering option. +// Think of variable extraVinculum as two detours in the SVG path. +// The detour begins at the lower left of the area labeled extraVinculum below. +// The detour proceeds one extraVinculum distance up and slightly to the right, +// displacing the radiused corner between surd and vinculum. The radius is +// traversed as usual, then the detour resumes. It goes right, to the end of +// the very long vinculum, then down one extraVinculum distance, +// after which it resumes regular path geometry for the radical. +/* vinculum + / + /▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒←extraVinculum + / █████████████████████←0.04em (40 unit) std vinculum thickness + / / + / / + / /\ + / / surd +*/ + +const sqrtMain = function (extraVinculum, hLinePad) { + // sqrtMain path geometry is from glyph U221A in the font KaTeX Main + return "M95," + (622 + extraVinculum + hLinePad) + "\nc-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14\nc0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54\nc44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10\ns173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429\nc69,-144,104.5,-217.7,106.5,-221\nl" + extraVinculum / 2.075 + " -" + extraVinculum + "\nc5.3,-9.3,12,-14,20,-14\nH400000v" + (40 + extraVinculum) + "H845.2724\ns-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7\nc-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z\nM" + (834 + extraVinculum) + " " + hLinePad + "h400000v" + (40 + extraVinculum) + "h-400000z"; +}; +const sqrtSize1 = function (extraVinculum, hLinePad) { + // size1 is from glyph U221A in the font KaTeX_Size1-Regular + return "M263," + (601 + extraVinculum + hLinePad) + "c0.7,0,18,39.7,52,119\nc34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120\nc340,-704.7,510.7,-1060.3,512,-1067\nl" + extraVinculum / 2.084 + " -" + extraVinculum + "\nc4.7,-7.3,11,-11,19,-11\nH40000v" + (40 + extraVinculum) + "H1012.3\ns-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232\nc-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1\ns-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26\nc-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z\nM" + (1001 + extraVinculum) + " " + hLinePad + "h400000v" + (40 + extraVinculum) + "h-400000z"; +}; +const sqrtSize2 = function (extraVinculum, hLinePad) { + // size2 is from glyph U221A in the font KaTeX_Size2-Regular + return "M983 " + (10 + extraVinculum + hLinePad) + "\nl" + extraVinculum / 3.13 + " -" + extraVinculum + "\nc4,-6.7,10,-10,18,-10 H400000v" + (40 + extraVinculum) + "\nH1013.1s-83.4,268,-264.1,840c-180.7,572,-277,876.3,-289,913c-4.7,4.7,-12.7,7,-24,7\ns-12,0,-12,0c-1.3,-3.3,-3.7,-11.7,-7,-25c-35.3,-125.3,-106.7,-373.3,-214,-744\nc-10,12,-21,25,-33,39s-32,39,-32,39c-6,-5.3,-15,-14,-27,-26s25,-30,25,-30\nc26.7,-32.7,52,-63,76,-91s52,-60,52,-60s208,722,208,722\nc56,-175.3,126.3,-397.3,211,-666c84.7,-268.7,153.8,-488.2,207.5,-658.5\nc53.7,-170.3,84.5,-266.8,92.5,-289.5z\nM" + (1001 + extraVinculum) + " " + hLinePad + "h400000v" + (40 + extraVinculum) + "h-400000z"; +}; +const sqrtSize3 = function (extraVinculum, hLinePad) { + // size3 is from glyph U221A in the font KaTeX_Size3-Regular + return "M424," + (2398 + extraVinculum + hLinePad) + "\nc-1.3,-0.7,-38.5,-172,-111.5,-514c-73,-342,-109.8,-513.3,-110.5,-514\nc0,-2,-10.7,14.3,-32,49c-4.7,7.3,-9.8,15.7,-15.5,25c-5.7,9.3,-9.8,16,-12.5,20\ns-5,7,-5,7c-4,-3.3,-8.3,-7.7,-13,-13s-13,-13,-13,-13s76,-122,76,-122s77,-121,77,-121\ns209,968,209,968c0,-2,84.7,-361.7,254,-1079c169.3,-717.3,254.7,-1077.7,256,-1081\nl" + extraVinculum / 4.223 + " -" + extraVinculum + "c4,-6.7,10,-10,18,-10 H400000\nv" + (40 + extraVinculum) + "H1014.6\ns-87.3,378.7,-272.6,1166c-185.3,787.3,-279.3,1182.3,-282,1185\nc-2,6,-10,9,-24,9\nc-8,0,-12,-0.7,-12,-2z M" + (1001 + extraVinculum) + " " + hLinePad + "\nh400000v" + (40 + extraVinculum) + "h-400000z"; +}; +const sqrtSize4 = function (extraVinculum, hLinePad) { + // size4 is from glyph U221A in the font KaTeX_Size4-Regular + return "M473," + (2713 + extraVinculum + hLinePad) + "\nc339.3,-1799.3,509.3,-2700,510,-2702 l" + extraVinculum / 5.298 + " -" + extraVinculum + "\nc3.3,-7.3,9.3,-11,18,-11 H400000v" + (40 + extraVinculum) + "H1017.7\ns-90.5,478,-276.2,1466c-185.7,988,-279.5,1483,-281.5,1485c-2,6,-10,9,-24,9\nc-8,0,-12,-0.7,-12,-2c0,-1.3,-5.3,-32,-16,-92c-50.7,-293.3,-119.7,-693.3,-207,-1200\nc0,-1.3,-5.3,8.7,-16,30c-10.7,21.3,-21.3,42.7,-32,64s-16,33,-16,33s-26,-26,-26,-26\ns76,-153,76,-153s77,-151,77,-151c0.7,0.7,35.7,202,105,604c67.3,400.7,102,602.7,104,\n606zM" + (1001 + extraVinculum) + " " + hLinePad + "h400000v" + (40 + extraVinculum) + "H1017.7z"; +}; +const phasePath = function (y) { + const x = y / 2; // x coordinate at top of angle + return "M400000 " + y + " H0 L" + x + " 0 l65 45 L145 " + (y - 80) + " H400000z"; +}; +const sqrtTall = function (extraVinculum, hLinePad, viewBoxHeight) { + // sqrtTall is from glyph U23B7 in the font KaTeX_Size4-Regular + // One path edge has a variable length. It runs vertically from the vinculum + // to a point near (14 units) the bottom of the surd. The vinculum + // is normally 40 units thick. So the length of the line in question is: + const vertSegment = viewBoxHeight - 54 - hLinePad - extraVinculum; + return "M702 " + (extraVinculum + hLinePad) + "H400000" + (40 + extraVinculum) + "\nH742v" + vertSegment + "l-4 4-4 4c-.667.7 -2 1.5-4 2.5s-4.167 1.833-6.5 2.5-5.5 1-9.5 1\nh-12l-28-84c-16.667-52-96.667 -294.333-240-727l-212 -643 -85 170\nc-4-3.333-8.333-7.667-13 -13l-13-13l77-155 77-156c66 199.333 139 419.667\n219 661 l218 661zM702 " + hLinePad + "H400000v" + (40 + extraVinculum) + "H742z"; +}; +const sqrtPath = function (size, extraVinculum, viewBoxHeight) { + extraVinculum = 1000 * extraVinculum; // Convert from document ems to viewBox. + let path = ""; + switch (size) { + case "sqrtMain": + path = sqrtMain(extraVinculum, hLinePad); + break; + case "sqrtSize1": + path = sqrtSize1(extraVinculum, hLinePad); + break; + case "sqrtSize2": + path = sqrtSize2(extraVinculum, hLinePad); + break; + case "sqrtSize3": + path = sqrtSize3(extraVinculum, hLinePad); + break; + case "sqrtSize4": + path = sqrtSize4(extraVinculum, hLinePad); + break; + case "sqrtTall": + path = sqrtTall(extraVinculum, hLinePad, viewBoxHeight); + } + return path; +}; +const innerPath = function (name, height) { + // The inner part of stretchy tall delimiters + switch (name) { + case "\u239c": + return doubleBrushStroke("M291 0 H417 V" + height + " H291z"); + case "\u2223": + return doubleBrushStroke("M145 0 H188 V" + height + " H145z"); + case "\u2225": + return doubleBrushStroke("M145 0 H188 V" + height + " H145z") + doubleBrushStroke("M367 0 H410 V" + height + " H367z"); + case "\u239f": + return doubleBrushStroke("M457 0 H583 V" + height + " H457z"); + case "\u23a2": + return doubleBrushStroke("M319 0 H403 V" + height + " H319z"); + case "\u23a5": + return doubleBrushStroke("M263 0 H347 V" + height + " H263z"); + case "\u23aa": + return doubleBrushStroke("M384 0 H504 V" + height + " H384z"); + case "\u23d0": + return doubleBrushStroke("M312 0 H355 V" + height + " H312z"); + case "\u2016": + return doubleBrushStroke("M257 0 H300 V" + height + " H257z") + doubleBrushStroke("M478 0 H521 V" + height + " H478z"); + default: + return ""; + } +}; +const path = { + // The doubleleftarrow geometry is from glyph U+21D0 in the font KaTeX Main + doubleleftarrow: "M262 157\nl10-10c34-36 62.7-77 86-123 3.3-8 5-13.3 5-16 0-5.3-6.7-8-20-8-7.3\n 0-12.2.5-14.5 1.5-2.3 1-4.8 4.5-7.5 10.5-49.3 97.3-121.7 169.3-217 216-28\n 14-57.3 25-88 33-6.7 2-11 3.8-13 5.5-2 1.7-3 4.2-3 7.5s1 5.8 3 7.5\nc2 1.7 6.3 3.5 13 5.5 68 17.3 128.2 47.8 180.5 91.5 52.3 43.7 93.8 96.2 124.5\n 157.5 9.3 8 15.3 12.3 18 13h6c12-.7 18-4 18-10 0-2-1.7-7-5-15-23.3-46-52-87\n-86-123l-10-10h399738v-40H218c328 0 0 0 0 0l-10-8c-26.7-20-65.7-43-117-69 2.7\n-2 6-3.7 10-5 36.7-16 72.3-37.3 107-64l10-8h399782v-40z\nm8 0v40h399730v-40zm0 194v40h399730v-40z", + // doublerightarrow is from glyph U+21D2 in font KaTeX Main + doublerightarrow: "M399738 392l\n-10 10c-34 36-62.7 77-86 123-3.3 8-5 13.3-5 16 0 5.3 6.7 8 20 8 7.3 0 12.2-.5\n 14.5-1.5 2.3-1 4.8-4.5 7.5-10.5 49.3-97.3 121.7-169.3 217-216 28-14 57.3-25 88\n-33 6.7-2 11-3.8 13-5.5 2-1.7 3-4.2 3-7.5s-1-5.8-3-7.5c-2-1.7-6.3-3.5-13-5.5-68\n-17.3-128.2-47.8-180.5-91.5-52.3-43.7-93.8-96.2-124.5-157.5-9.3-8-15.3-12.3-18\n-13h-6c-12 .7-18 4-18 10 0 2 1.7 7 5 15 23.3 46 52 87 86 123l10 10H0v40h399782\nc-328 0 0 0 0 0l10 8c26.7 20 65.7 43 117 69-2.7 2-6 3.7-10 5-36.7 16-72.3 37.3\n-107 64l-10 8H0v40zM0 157v40h399730v-40zm0 194v40h399730v-40z", + // leftarrow is from glyph U+2190 in font KaTeX Main + leftarrow: "M400000 241H110l3-3c68.7-52.7 113.7-120\n 135-202 4-14.7 6-23 6-25 0-7.3-7-11-21-11-8 0-13.2.8-15.5 2.5-2.3 1.7-4.2 5.8\n-5.5 12.5-1.3 4.7-2.7 10.3-4 17-12 48.7-34.8 92-68.5 130S65.3 228.3 18 247\nc-10 4-16 7.7-18 11 0 8.7 6 14.3 18 17 47.3 18.7 87.8 47 121.5 85S196 441.3 208\n 490c.7 2 1.3 5 2 9s1.2 6.7 1.5 8c.3 1.3 1 3.3 2 6s2.2 4.5 3.5 5.5c1.3 1 3.3\n 1.8 6 2.5s6 1 10 1c14 0 21-3.7 21-11 0-2-2-10.3-6-25-20-79.3-65-146.7-135-202\n l-3-3h399890zM100 241v40h399900v-40z", + // overbrace is from glyphs U+23A9/23A8/23A7 in font KaTeX_Size4-Regular + leftbrace: "M6 548l-6-6v-35l6-11c56-104 135.3-181.3 238-232 57.3-28.7 117\n-45 179-50h399577v120H403c-43.3 7-81 15-113 26-100.7 33-179.7 91-237 174-2.7\n 5-6 9-10 13-.7 1-7.3 1-20 1H6z", + leftbraceunder: "M0 6l6-6h17c12.688 0 19.313.3 20 1 4 4 7.313 8.3 10 13\n 35.313 51.3 80.813 93.8 136.5 127.5 55.688 33.7 117.188 55.8 184.5 66.5.688\n 0 2 .3 4 1 18.688 2.7 76 4.3 172 5h399450v120H429l-6-1c-124.688-8-235-61.7\n-331-161C60.687 138.7 32.312 99.3 7 54L0 41V6z", + // overgroup is from the MnSymbol package (public domain) + leftgroup: "M400000 80\nH435C64 80 168.3 229.4 21 260c-5.9 1.2-18 0-18 0-2 0-3-1-3-3v-38C76 61 257 0\n 435 0h399565z", + leftgroupunder: "M400000 262\nH435C64 262 168.3 112.6 21 82c-5.9-1.2-18 0-18 0-2 0-3 1-3 3v38c76 158 257 219\n 435 219h399565z", + // Harpoons are from glyph U+21BD in font KaTeX Main + leftharpoon: "M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3\n-3.3 10.2-9.5 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5\n-18.3 3-21-1.3-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7\n-196 228-6.7 4.7-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40z", + leftharpoonplus: "M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3-3.3 10.2-9.5\n 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5-18.3 3-21-1.3\n-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7-196 228-6.7 4.7\n-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40zM0 435v40h400000v-40z\nm0 0v40h400000v-40z", + leftharpoondown: "M7 241c-4 4-6.333 8.667-7 14 0 5.333.667 9 2 11s5.333\n 5.333 12 10c90.667 54 156 130 196 228 3.333 10.667 6.333 16.333 9 17 2 .667 5\n 1 9 1h5c10.667 0 16.667-2 18-6 2-2.667 1-9.667-3-21-32-87.333-82.667-157.667\n-152-211l-3-3h399907v-40zM93 281 H400000 v-40L7 241z", + leftharpoondownplus: "M7 435c-4 4-6.3 8.7-7 14 0 5.3.7 9 2 11s5.3 5.3 12\n 10c90.7 54 156 130 196 228 3.3 10.7 6.3 16.3 9 17 2 .7 5 1 9 1h5c10.7 0 16.7\n-2 18-6 2-2.7 1-9.7-3-21-32-87.3-82.7-157.7-152-211l-3-3h399907v-40H7zm93 0\nv40h399900v-40zM0 241v40h399900v-40zm0 0v40h399900v-40z", + // hook is from glyph U+21A9 in font KaTeX Main + lefthook: "M400000 281 H103s-33-11.2-61-33.5S0 197.3 0 164s14.2-61.2 42.5\n-83.5C70.8 58.2 104 47 142 47 c16.7 0 25 6.7 25 20 0 12-8.7 18.7-26 20-40 3.3\n-68.7 15.7-86 37-10 12-15 25.3-15 40 0 22.7 9.8 40.7 29.5 54 19.7 13.3 43.5 21\n 71.5 23h399859zM103 281v-40h399897v40z", + leftlinesegment: doubleBrushStroke("M40 281 V428 H0 V94 H40 V241 H400000 v40z"), + leftbracketunder: doubleBrushStroke("M0 0 h120 V290 H399995 v120 H0z"), + leftbracketover: doubleBrushStroke("M0 440 h120 V150 H399995 v-120 H0z"), + leftmapsto: doubleBrushStroke("M40 281 V448H0V74H40V241H400000v40z"), + // tofrom is from glyph U+21C4 in font KaTeX AMS Regular + leftToFrom: "M0 147h400000v40H0zm0 214c68 40 115.7 95.7 143 167h22c15.3 0 23\n-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69-70-101l-7-8h399905v-40H95l7-8\nc28.7-32 52-65.7 70-101 10.7-23.3 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 265.3\n 68 321 0 361zm0-174v-40h399900v40zm100 154v40h399900v-40z", + longequal: doubleBrushStroke("M0 50 h400000 v40H0z m0 194h40000v40H0z"), + midbrace: "M200428 334\nc-100.7-8.3-195.3-44-280-108-55.3-42-101.7-93-139-153l-9-14c-2.7 4-5.7 8.7-9 14\n-53.3 86.7-123.7 153-211 199-66.7 36-137.3 56.3-212 62H0V214h199568c178.3-11.7\n 311.7-78.3 403-201 6-8 9.7-12 11-12 .7-.7 6.7-1 18-1s17.3.3 18 1c1.3 0 5 4 11\n 12 44.7 59.3 101.3 106.3 170 141s145.3 54.3 229 60h199572v120z", + midbraceunder: "M199572 214\nc100.7 8.3 195.3 44 280 108 55.3 42 101.7 93 139 153l9 14c2.7-4 5.7-8.7 9-14\n 53.3-86.7 123.7-153 211-199 66.7-36 137.3-56.3 212-62h199568v120H200432c-178.3\n 11.7-311.7 78.3-403 201-6 8-9.7 12-11 12-.7.7-6.7 1-18 1s-17.3-.3-18-1c-1.3 0\n-5-4-11-12-44.7-59.3-101.3-106.3-170-141s-145.3-54.3-229-60H0V214z", + oiintSize1: "M512.6 71.6c272.6 0 320.3 106.8 320.3 178.2 0 70.8-47.7 177.6\n-320.3 177.6S193.1 320.6 193.1 249.8c0-71.4 46.9-178.2 319.5-178.2z\nm368.1 178.2c0-86.4-60.9-215.4-368.1-215.4-306.4 0-367.3 129-367.3 215.4 0 85.8\n60.9 214.8 367.3 214.8 307.2 0 368.1-129 368.1-214.8z", + oiintSize2: "M757.8 100.1c384.7 0 451.1 137.6 451.1 230 0 91.3-66.4 228.8\n-451.1 228.8-386.3 0-452.7-137.5-452.7-228.8 0-92.4 66.4-230 452.7-230z\nm502.4 230c0-111.2-82.4-277.2-502.4-277.2s-504 166-504 277.2\nc0 110 84 276 504 276s502.4-166 502.4-276z", + oiiintSize1: "M681.4 71.6c408.9 0 480.5 106.8 480.5 178.2 0 70.8-71.6 177.6\n-480.5 177.6S202.1 320.6 202.1 249.8c0-71.4 70.5-178.2 479.3-178.2z\nm525.8 178.2c0-86.4-86.8-215.4-525.7-215.4-437.9 0-524.7 129-524.7 215.4 0\n85.8 86.8 214.8 524.7 214.8 438.9 0 525.7-129 525.7-214.8z", + oiiintSize2: "M1021.2 53c603.6 0 707.8 165.8 707.8 277.2 0 110-104.2 275.8\n-707.8 275.8-606 0-710.2-165.8-710.2-275.8C311 218.8 415.2 53 1021.2 53z\nm770.4 277.1c0-131.2-126.4-327.6-770.5-327.6S248.4 198.9 248.4 330.1\nc0 130 128.8 326.4 772.7 326.4s770.5-196.4 770.5-326.4z", + rightarrow: "M0 241v40h399891c-47.3 35.3-84 78-110 128\n-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20\n 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7\n 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85\n-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5\n-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67\n 151.7 139 205zm0 0v40h399900v-40z", + rightbrace: "M400000 542l\n-6 6h-17c-12.7 0-19.3-.3-20-1-4-4-7.3-8.3-10-13-35.3-51.3-80.8-93.8-136.5-127.5\ns-117.2-55.8-184.5-66.5c-.7 0-2-.3-4-1-18.7-2.7-76-4.3-172-5H0V214h399571l6 1\nc124.7 8 235 61.7 331 161 31.3 33.3 59.7 72.7 85 118l7 13v35z", + rightbraceunder: "M399994 0l6 6v35l-6 11c-56 104-135.3 181.3-238 232-57.3\n 28.7-117 45-179 50H-300V214h399897c43.3-7 81-15 113-26 100.7-33 179.7-91 237\n-174 2.7-5 6-9 10-13 .7-1 7.3-1 20-1h17z", + rightgroup: "M0 80h399565c371 0 266.7 149.4 414 180 5.9 1.2 18 0 18 0 2 0\n 3-1 3-3v-38c-76-158-257-219-435-219H0z", + rightgroupunder: "M0 262h399565c371 0 266.7-149.4 414-180 5.9-1.2 18 0 18\n 0 2 0 3 1 3 3v38c-76 158-257 219-435 219H0z", + rightharpoon: "M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3\n-3.7-15.3-11-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2\n-10.7 0-16.7 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58\n 69.2 92 94.5zm0 0v40h399900v-40z", + rightharpoonplus: "M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3-3.7-15.3-11\n-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2-10.7 0-16.7\n 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58 69.2 92 94.5z\nm0 0v40h399900v-40z m100 194v40h399900v-40zm0 0v40h399900v-40z", + rightharpoondown: "M399747 511c0 7.3 6.7 11 20 11 8 0 13-.8 15-2.5s4.7-6.8\n 8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3 8.5-5.8 9.5\n-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3-64.7 57-92 95\n-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 241v40h399900v-40z", + rightharpoondownplus: "M399747 705c0 7.3 6.7 11 20 11 8 0 13-.8\n 15-2.5s4.7-6.8 8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3\n 8.5-5.8 9.5-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3\n-64.7 57-92 95-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 435v40h399900v-40z\nm0-194v40h400000v-40zm0 0v40h400000v-40z", + righthook: "M399859 241c-764 0 0 0 0 0 40-3.3 68.7-15.7 86-37 10-12 15-25.3\n 15-40 0-22.7-9.8-40.7-29.5-54-19.7-13.3-43.5-21-71.5-23-17.3-1.3-26-8-26-20 0\n-13.3 8.7-20 26-20 38 0 71 11.2 99 33.5 0 0 7 5.6 21 16.7 14 11.2 21 33.5 21\n 66.8s-14 61.2-42 83.5c-28 22.3-61 33.5-99 33.5L0 241z M0 281v-40h399859v40z", + rightlinesegment: doubleBrushStroke("M399960 241 V94 h40 V428 h-40 V281 H0 v-40z"), + rightbracketunder: doubleBrushStroke("M399995 0 h-120 V290 H0 v120 H400000z"), + rightbracketover: doubleBrushStroke("M399995 440 h-120 V150 H0 v-120 H399995z"), + rightToFrom: "M400000 167c-70.7-42-118-97.7-142-167h-23c-15.3 0-23 .3-23\n 1 0 1.3 5.3 13.7 16 37 18 35.3 41.3 69 70 101l7 8H0v40h399905l-7 8c-28.7 32\n-52 65.7-70 101-10.7 23.3-16 35.7-16 37 0 .7 7.7 1 23 1h23c24-69.3 71.3-125 142\n-167z M100 147v40h399900v-40zM0 341v40h399900v-40z", + // twoheadleftarrow is from glyph U+219E in font KaTeX AMS Regular + twoheadleftarrow: "M0 167c68 40\n 115.7 95.7 143 167h22c15.3 0 23-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69\n-70-101l-7-8h125l9 7c50.7 39.3 85 86 103 140h46c0-4.7-6.3-18.7-19-42-18-35.3\n-40-67.3-66-96l-9-9h399716v-40H284l9-9c26-28.7 48-60.7 66-96 12.7-23.333 19\n-37.333 19-42h-46c-18 54-52.3 100.7-103 140l-9 7H95l7-8c28.7-32 52-65.7 70-101\n 10.7-23.333 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 71.3 68 127 0 167z", + twoheadrightarrow: "M400000 167\nc-68-40-115.7-95.7-143-167h-22c-15.3 0-23 .3-23 1 0 1.3 5.3 13.7 16 37 18 35.3\n 41.3 69 70 101l7 8h-125l-9-7c-50.7-39.3-85-86-103-140h-46c0 4.7 6.3 18.7 19 42\n 18 35.3 40 67.3 66 96l9 9H0v40h399716l-9 9c-26 28.7-48 60.7-66 96-12.7 23.333\n-19 37.333-19 42h46c18-54 52.3-100.7 103-140l9-7h125l-7 8c-28.7 32-52 65.7-70\n 101-10.7 23.333-16 35.7-16 37 0 .7 7.7 1 23 1h22c27.3-71.3 75-127 143-167z", + // tilde1 is a modified version of a glyph from the MnSymbol package + tilde1: "M200 55.538c-77 0-168 73.953-177 73.953-3 0-7\n-2.175-9-5.437L2 97c-1-2-2-4-2-6 0-4 2-7 5-9l20-12C116 12 171 0 207 0c86 0\n 114 68 191 68 78 0 168-68 177-68 4 0 7 2 9 5l12 19c1 2.175 2 4.35 2 6.525 0\n 4.35-2 7.613-5 9.788l-19 13.05c-92 63.077-116.937 75.308-183 76.128\n-68.267.847-113-73.952-191-73.952z", + // ditto tilde2, tilde3, & tilde4 + tilde2: "M344 55.266c-142 0-300.638 81.316-311.5 86.418\n-8.01 3.762-22.5 10.91-23.5 5.562L1 120c-1-2-1-3-1-4 0-5 3-9 8-10l18.4-9C160.9\n 31.9 283 0 358 0c148 0 188 122 331 122s314-97 326-97c4 0 8 2 10 7l7 21.114\nc1 2.14 1 3.21 1 4.28 0 5.347-3 9.626-7 10.696l-22.3 12.622C852.6 158.372 751\n 181.476 676 181.476c-149 0-189-126.21-332-126.21z", + tilde3: "M786 59C457 59 32 175.242 13 175.242c-6 0-10-3.457\n-11-10.37L.15 138c-1-7 3-12 10-13l19.2-6.4C378.4 40.7 634.3 0 804.3 0c337 0\n 411.8 157 746.8 157 328 0 754-112 773-112 5 0 10 3 11 9l1 14.075c1 8.066-.697\n 16.595-6.697 17.492l-21.052 7.31c-367.9 98.146-609.15 122.696-778.15 122.696\n -338 0-409-156.573-744-156.573z", + tilde4: "M786 58C457 58 32 177.487 13 177.487c-6 0-10-3.345\n-11-10.035L.15 143c-1-7 3-12 10-13l22-6.7C381.2 35 637.15 0 807.15 0c337 0 409\n 177 744 177 328 0 754-127 773-127 5 0 10 3 11 9l1 14.794c1 7.805-3 13.38-9\n 14.495l-20.7 5.574c-366.85 99.79-607.3 139.372-776.3 139.372-338 0-409\n -175.236-744-175.236z", + // vec is from glyph U+20D7 in font KaTeX Main + vec: "M377 20c0-5.333 1.833-10 5.5-14S391 0 397 0c4.667 0 8.667 1.667 12 5\n3.333 2.667 6.667 9 10 19 6.667 24.667 20.333 43.667 41 57 7.333 4.667 11\n10.667 11 18 0 6-1 10-3 12s-6.667 5-14 9c-28.667 14.667-53.667 35.667-75 63\n-1.333 1.333-3.167 3.5-5.5 6.5s-4 4.833-5 5.5c-1 .667-2.5 1.333-4.5 2s-4.333 1\n-7 1c-4.667 0-9.167-1.833-13.5-5.5S337 184 337 178c0-12.667 15.667-32.333 47-59\nH213l-171-1c-8.667-6-13-12.333-13-19 0-4.667 4.333-11.333 13-20h359\nc-16-25.333-24-45-24-59z", + // widehat1 is a modified version of a glyph from the MnSymbol package + widehat1: "M529 0h5l519 115c5 1 9 5 9 10 0 1-1 2-1 3l-4 22\nc-1 5-5 9-11 9h-2L532 67 19 159h-2c-5 0-9-4-11-9l-5-22c-1-6 2-12 8-13z", + // ditto widehat2, widehat3, & widehat4 + widehat2: "M1181 0h2l1171 176c6 0 10 5 10 11l-2 23c-1 6-5 10\n-11 10h-1L1182 67 15 220h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z", + widehat3: "M1181 0h2l1171 236c6 0 10 5 10 11l-2 23c-1 6-5 10\n-11 10h-1L1182 67 15 280h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z", + widehat4: "M1181 0h2l1171 296c6 0 10 5 10 11l-2 23c-1 6-5 10\n-11 10h-1L1182 67 15 340h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z", + // widecheck paths are all inverted versions of widehat + widecheck1: "M529,159h5l519,-115c5,-1,9,-5,9,-10c0,-1,-1,-2,-1,-3l-4,-22c-1,\n-5,-5,-9,-11,-9h-2l-512,92l-513,-92h-2c-5,0,-9,4,-11,9l-5,22c-1,6,2,12,8,13z", + widecheck2: "M1181,220h2l1171,-176c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,\n-11,-10h-1l-1168,153l-1167,-153h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z", + widecheck3: "M1181,280h2l1171,-236c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,\n-11,-10h-1l-1168,213l-1167,-213h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z", + widecheck4: "M1181,340h2l1171,-296c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,\n-11,-10h-1l-1168,273l-1167,-273h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z", + // The next ten paths support reaction arrows from the mhchem package. + + // Arrows for \ce{<-->} are offset from xAxis by 0.22ex, per mhchem in LaTeX + // baraboveleftarrow is mostly from glyph U+2190 in font KaTeX Main + baraboveleftarrow: "M400000 620h-399890l3 -3c68.7 -52.7 113.7 -120 135 -202\nc4 -14.7 6 -23 6 -25c0 -7.3 -7 -11 -21 -11c-8 0 -13.2 0.8 -15.5 2.5\nc-2.3 1.7 -4.2 5.8 -5.5 12.5c-1.3 4.7 -2.7 10.3 -4 17c-12 48.7 -34.8 92 -68.5 130\ns-74.2 66.3 -121.5 85c-10 4 -16 7.7 -18 11c0 8.7 6 14.3 18 17c47.3 18.7 87.8 47\n121.5 85s56.5 81.3 68.5 130c0.7 2 1.3 5 2 9s1.2 6.7 1.5 8c0.3 1.3 1 3.3 2 6\ns2.2 4.5 3.5 5.5c1.3 1 3.3 1.8 6 2.5s6 1 10 1c14 0 21 -3.7 21 -11\nc0 -2 -2 -10.3 -6 -25c-20 -79.3 -65 -146.7 -135 -202l-3 -3h399890z\nM100 620v40h399900v-40z M0 241v40h399900v-40zM0 241v40h399900v-40z", + // rightarrowabovebar is mostly from glyph U+2192, KaTeX Main + rightarrowabovebar: "M0 241v40h399891c-47.3 35.3-84 78-110 128-16.7 32\n-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20 11 8 0\n13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7 39\n-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85-40.5\n-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5\n-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67\n151.7 139 205zm96 379h399894v40H0zm0 0h399904v40H0z", + // The short left harpoon has 0.5em (i.e. 500 units) kern on the left end. + // Ref from mhchem.sty: \rlap{\raisebox{-.22ex}{$\kern0.5em + baraboveshortleftharpoon: "M507,435c-4,4,-6.3,8.7,-7,14c0,5.3,0.7,9,2,11\nc1.3,2,5.3,5.3,12,10c90.7,54,156,130,196,228c3.3,10.7,6.3,16.3,9,17\nc2,0.7,5,1,9,1c0,0,5,0,5,0c10.7,0,16.7,-2,18,-6c2,-2.7,1,-9.7,-3,-21\nc-32,-87.3,-82.7,-157.7,-152,-211c0,0,-3,-3,-3,-3l399351,0l0,-40\nc-398570,0,-399437,0,-399437,0z M593 435 v40 H399500 v-40z\nM0 281 v-40 H399908 v40z M0 281 v-40 H399908 v40z", + rightharpoonaboveshortbar: "M0,241 l0,40c399126,0,399993,0,399993,0\nc4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199,\n-231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6\nc-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z\nM0 241 v40 H399908 v-40z M0 475 v-40 H399500 v40z M0 475 v-40 H399500 v40z", + shortbaraboveleftharpoon: "M7,435c-4,4,-6.3,8.7,-7,14c0,5.3,0.7,9,2,11\nc1.3,2,5.3,5.3,12,10c90.7,54,156,130,196,228c3.3,10.7,6.3,16.3,9,17c2,0.7,5,1,9,\n1c0,0,5,0,5,0c10.7,0,16.7,-2,18,-6c2,-2.7,1,-9.7,-3,-21c-32,-87.3,-82.7,-157.7,\n-152,-211c0,0,-3,-3,-3,-3l399907,0l0,-40c-399126,0,-399993,0,-399993,0z\nM93 435 v40 H400000 v-40z M500 241 v40 H400000 v-40z M500 241 v40 H400000 v-40z", + shortrightharpoonabovebar: "M53,241l0,40c398570,0,399437,0,399437,0\nc4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199,\n-231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6\nc-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z\nM500 241 v40 H399408 v-40z M500 435 v40 H400000 v-40z" +}; +const tallDelim = function (label, midHeight) { + switch (label) { + case "lbrack": + return "M403 1759 V84 H666 V0 H319 V1759 v" + midHeight + " v1759 v84 h347 v-84\nH403z M403 1759 V0 H319 V1759 v" + midHeight + " v1759 v84 h84z"; + case "rbrack": + return "M347 1759 V0 H0 V84 H263 V1759 v" + midHeight + " v1759 H0 v84 H347z\nM347 1759 V0 H263 V1759 v" + midHeight + " v1759 h84z"; + case "vert": + return "M145 15 v585 v" + midHeight + " v585 c2.667,10,9.667,15,21,15\nc10,0,16.667,-5,20,-15 v-585 v" + -midHeight + " v-585 c-2.667,-10,-9.667,-15,-21,-15\nc-10,0,-16.667,5,-20,15z M188 15 H145 v585 v" + midHeight + " v585 h43z"; + case "doublevert": + return "M145 15 v585 v" + midHeight + " v585 c2.667,10,9.667,15,21,15\nc10,0,16.667,-5,20,-15 v-585 v" + -midHeight + " v-585 c-2.667,-10,-9.667,-15,-21,-15\nc-10,0,-16.667,5,-20,15z M188 15 H145 v585 v" + midHeight + " v585 h43z\nM367 15 v585 v" + midHeight + " v585 c2.667,10,9.667,15,21,15\nc10,0,16.667,-5,20,-15 v-585 v" + -midHeight + " v-585 c-2.667,-10,-9.667,-15,-21,-15\nc-10,0,-16.667,5,-20,15z M410 15 H367 v585 v" + midHeight + " v585 h43z"; + case "lfloor": + return "M319 602 V0 H403 V602 v" + midHeight + " v1715 h263 v84 H319z\nMM319 602 V0 H403 V602 v" + midHeight + " v1715 H319z"; + case "rfloor": + return "M319 602 V0 H403 V602 v" + midHeight + " v1799 H0 v-84 H319z\nMM319 602 V0 H403 V602 v" + midHeight + " v1715 H319z"; + case "lceil": + return "M403 1759 V84 H666 V0 H319 V1759 v" + midHeight + " v602 h84z\nM403 1759 V0 H319 V1759 v" + midHeight + " v602 h84z"; + case "rceil": + return "M347 1759 V0 H0 V84 H263 V1759 v" + midHeight + " v602 h84z\nM347 1759 V0 h-84 V1759 v" + midHeight + " v602 h84z"; + case "lparen": + return "M863,9c0,-2,-2,-5,-6,-9c0,0,-17,0,-17,0c-12.7,0,-19.3,0.3,-20,1\nc-5.3,5.3,-10.3,11,-15,17c-242.7,294.7,-395.3,682,-458,1162c-21.3,163.3,-33.3,349,\n-36,557 l0," + (midHeight + 84) + "c0.2,6,0,26,0,60c2,159.3,10,310.7,24,454c53.3,528,210,\n949.7,470,1265c4.7,6,9.7,11.7,15,17c0.7,0.7,7,1,19,1c0,0,18,0,18,0c4,-4,6,-7,6,-9\nc0,-2.7,-3.3,-8.7,-10,-18c-135.3,-192.7,-235.5,-414.3,-300.5,-665c-65,-250.7,-102.5,\n-544.7,-112.5,-882c-2,-104,-3,-167,-3,-189\nl0,-" + (midHeight + 92) + "c0,-162.7,5.7,-314,17,-454c20.7,-272,63.7,-513,129,-723c65.3,\n-210,155.3,-396.3,270,-559c6.7,-9.3,10,-15.3,10,-18z"; + case "rparen": + return "M76,0c-16.7,0,-25,3,-25,9c0,2,2,6.3,6,13c21.3,28.7,42.3,60.3,\n63,95c96.7,156.7,172.8,332.5,228.5,527.5c55.7,195,92.8,416.5,111.5,664.5\nc11.3,139.3,17,290.7,17,454c0,28,1.7,43,3.3,45l0," + (midHeight + 9) + "\nc-3,4,-3.3,16.7,-3.3,38c0,162,-5.7,313.7,-17,455c-18.7,248,-55.8,469.3,-111.5,664\nc-55.7,194.7,-131.8,370.3,-228.5,527c-20.7,34.7,-41.7,66.3,-63,95c-2,3.3,-4,7,-6,11\nc0,7.3,5.7,11,17,11c0,0,11,0,11,0c9.3,0,14.3,-0.3,15,-1c5.3,-5.3,10.3,-11,15,-17\nc242.7,-294.7,395.3,-681.7,458,-1161c21.3,-164.7,33.3,-350.7,36,-558\nl0,-" + (midHeight + 144) + "c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,\n-470,-1265c-4.7,-6,-9.7,-11.7,-15,-17c-0.7,-0.7,-6.7,-1,-18,-1z"; + default: + // We should not ever get here. + throw new Error("Unknown stretchy delimiter."); + } +}; +;// ./src/tree.ts +// To ensure that all nodes have compatible signatures for these methods. + +function isMathDomNode(node) { + return 'toText' in node; +} + +/** + * This node represents a document fragment, which contains elements, but when + * placed into the DOM doesn't have any representation itself. It only contains + * children and doesn't have any DOM node properties. + */ +class DocumentFragment { + // Never used; needed for satisfying interface. + + constructor(children) { + this.children = void 0; + this.classes = void 0; + this.height = void 0; + this.depth = void 0; + this.maxFontSize = void 0; + this.style = void 0; + this.children = children; + this.classes = []; + this.height = 0; + this.depth = 0; + this.maxFontSize = 0; + this.style = {}; + } + hasClass(className) { + return this.classes.includes(className); + } + + /** Convert the fragment into a node. */ + toNode() { + const frag = document.createDocumentFragment(); + for (let i = 0; i < this.children.length; i++) { + frag.appendChild(this.children[i].toNode()); + } + return frag; + } + + /** Convert the fragment into HTML markup. */ + toMarkup() { + let markup = ""; + + // Simply concatenate the markup for the children together. + for (let i = 0; i < this.children.length; i++) { + markup += this.children[i].toMarkup(); + } + return markup; + } + + /** + * Converts the math node into a string, similar to innerText. Applies to + * MathDomNode's only. + */ + toText() { + return this.children.map(child => { + if (isMathDomNode(child)) { + return child.toText(); + } + throw new Error("Expected MathDomNode with toText, got " + child.constructor.name); + }).join(""); + } +} +;// ./src/units.ts +/** + * This file does conversion between units. In particular, it provides + * calculateSize to convert other units into ems. + */ + + +// This table gives the number of TeX pts in one of each *absolute* TeX unit. +// Thus, multiplying a length by this number converts the length from units +// into pts. Dividing the result by ptPerEm gives the number of ems +// *assuming* a font size of ptPerEm (normal size, normal style). +const ptPerUnit = { + // https://en.wikibooks.org/wiki/LaTeX/Lengths and + // https://tex.stackexchange.com/a/8263 + "pt": 1, + // TeX point + "mm": 7227 / 2540, + // millimeter + "cm": 7227 / 254, + // centimeter + "in": 72.27, + // inch + "bp": 803 / 800, + // big (PostScript) points + "pc": 12, + // pica + "dd": 1238 / 1157, + // didot + "cc": 14856 / 1157, + // cicero (12 didot) + "nd": 685 / 642, + // new didot + "nc": 1370 / 107, + // new cicero (12 new didot) + "sp": 1 / 65536, + // scaled point (TeX's internal smallest unit) + // https://tex.stackexchange.com/a/41371 + "px": 803 / 800 // \pdfpxdimen defaults to 1 bp in pdfTeX and LuaTeX +}; + +// Dictionary of relative units, for fast validity testing. +const relativeUnit = { + "ex": true, + "em": true, + "mu": true +}; +/** + * Determine whether the specified unit (either a string defining the unit + * or a "size" parse node containing a unit field) is valid. + */ +const validUnit = function (unit) { + if (typeof unit !== "string") { + unit = unit.unit; + } + return unit in ptPerUnit || unit in relativeUnit || unit === "ex"; +}; + +/* + * Convert a "size" parse node (with numeric "number" and string "unit" fields, + * as parsed by functions.js argType "size") into a CSS em value for the + * current style/scale. `options` gives the current options. + */ +const calculateSize = function (sizeValue, options) { + let scale; + if (sizeValue.unit in ptPerUnit) { + // Absolute units + scale = ptPerUnit[sizeValue.unit] // Convert unit to pt + / options.fontMetrics().ptPerEm // Convert pt to CSS em + / options.sizeMultiplier; // Unscale to make absolute units + } else if (sizeValue.unit === "mu") { + // `mu` units scale with scriptstyle/scriptscriptstyle. + scale = options.fontMetrics().cssEmPerMu; + } else { + // Other relative units always refer to the *textstyle* font + // in the current size. + let unitOptions; + if (options.style.isTight()) { + // isTight() means current style is script/scriptscript. + unitOptions = options.havingStyle(options.style.text()); + } else { + unitOptions = options; + } + // TODO: In TeX these units are relative to the quad of the current + // *text* font, e.g. cmr10. KaTeX instead uses values from the + // comparably-sized *Computer Modern symbol* font. At 10pt, these + // match. At 7pt and 5pt, they differ: cmr7=1.138894, cmsy7=1.170641; + // cmr5=1.361133, cmsy5=1.472241. Consider $\scriptsize a\kern1emb$. + // TeX \showlists shows a kern of 1.13889 * fontsize; + // KaTeX shows a kern of 1.171 * fontsize. + if (sizeValue.unit === "ex") { + scale = unitOptions.fontMetrics().xHeight; + } else if (sizeValue.unit === "em") { + scale = unitOptions.fontMetrics().quad; + } else { + throw new src_ParseError("Invalid unit: '" + sizeValue.unit + "'"); + } + if (unitOptions !== options) { + scale *= unitOptions.sizeMultiplier / options.sizeMultiplier; + } + } + return Math.min(sizeValue.number * scale, options.maxSize); +}; + +/** + * Round `n` to 4 decimal places, or to the nearest 1/10,000th em. See + * https://github.com/KaTeX/KaTeX/pull/2460. + */ +const makeEm = function (n) { + return +n.toFixed(4) + "em"; +}; +;// ./src/domTree.ts +/** + * These objects store the data about the DOM nodes we create, as well as some + * extra data. They can then be transformed into real DOM nodes with the + * `toNode` function or HTML markup using `toMarkup`. They are useful for both + * storing extra properties on the nodes, as well as providing a way to easily + * work with the DOM. + * + * Similar functions for working with MathML nodes exist in mathMLTree.js. + * + * TODO: refactor `span` and `anchor` into common superclass when + * target environments support class inheritance + */ + + + + + + +/** + * Create an HTML className based on a list of classes. In addition to joining + * with spaces, we also remove empty classes. + */ +const createClass = function (classes) { + return classes.filter(cls => cls).join(" "); +}; + +/** + * Serialize a CssStyle object into a semicolon-delimited inline-style string + * (hyphenating camelCase property names). Returns "" when no property is set. + */ +const cssStyleToString = function (style) { + let styles = ""; + for (const key of Object.keys(style)) { + const value = style[key]; + if (value !== undefined) { + styles += hyphenate(key) + ":" + value + ";"; + } + } + return styles; +}; +const initNode = function (classes, options, style) { + this.classes = classes || []; + this.attributes = {}; + this.height = 0; + this.depth = 0; + this.maxFontSize = 0; + this.style = style || {}; + if (options) { + if (options.style.isTight()) { + this.classes.push("mtight"); + } + const color = options.getColor(); + if (color) { + this.style.color = color; + } + } +}; + +/** + * Convert into an HTML node + */ +const toNode = function (tagName) { + const node = document.createElement(tagName); + + // Apply the class + node.className = createClass(this.classes); + + // Apply inline styles + Object.assign(node.style, this.style); + + // Apply attributes + for (const attr of Object.keys(this.attributes)) { + node.setAttribute(attr, this.attributes[attr]); + } + + // Append the children, also as HTML nodes + for (let i = 0; i < this.children.length; i++) { + node.appendChild(this.children[i].toNode()); + } + return node; +}; + +/** + * https://w3c.github.io/html-reference/syntax.html#syntax-attributes + * + * > Attribute Names must consist of one or more characters + * other than the space characters, U+0000 NULL, + * '"', "'", ">", "/", "=", the control characters, + * and any characters that are not defined by Unicode. + */ +const invalidAttributeNameRegex = /[\s"'>/=\x00-\x1f]/; + +/** + * Convert into an HTML markup string + */ +const toMarkup = function (tagName) { + let markup = "<" + tagName; + + // Add the class + if (this.classes.length) { + markup += " class=\"" + utils_escape(createClass(this.classes)) + "\""; + } + const styles = cssStyleToString(this.style); + if (styles) { + markup += " style=\"" + utils_escape(styles) + "\""; + } + + // Add the attributes + for (const attr of Object.keys(this.attributes)) { + if (invalidAttributeNameRegex.test(attr)) { + throw new src_ParseError("Invalid attribute name '" + attr + "'"); + } + markup += " " + attr + "=\"" + utils_escape(this.attributes[attr]) + "\""; + } + markup += ">"; + + // Add the markup of the children, also as markup + for (let i = 0; i < this.children.length; i++) { + markup += this.children[i].toMarkup(); + } + markup += ""; + return markup; +}; + +// Making the type below exact with all optional fields doesn't work due to +// - https://github.com/facebook/flow/issues/4582 +// - https://github.com/facebook/flow/issues/5688 +// However, since *all* fields are optional, $Shape<> works as suggested in 5688 +// above. +// This type does not include all CSS properties. Additional properties should +// be added as needed. + +// Span wrapping other DOM nodes. + +// Span wrapping an SVG node. + +/** + * This node represents a span node, with a className, a list of children, and + * an inline style. It also contains information about its height, depth, and + * maxFontSize. + * + * Represents two types with different uses: SvgSpan to wrap an SVG and DomSpan + * otherwise. This typesafety is important when HTML builders access a span's + * children. + */ +class Span { + constructor(classes, children, options, style) { + this.children = void 0; + this.attributes = void 0; + this.classes = void 0; + this.height = void 0; + this.depth = void 0; + this.width = void 0; + this.maxFontSize = void 0; + this.style = void 0; + /** + * Italic correction carried over from a SymbolNode when the symbol is + * wrapped in a vlist (e.g. \oiint / \oiiint). Read by supsub to adjust + * subscript positioning. Only set when nonzero; use `?? 0` at read sites. + */ + this.italic = void 0; + initNode.call(this, classes, options, style); + this.children = children || []; + } + + /** + * Sets an arbitrary attribute on the span. Warning: use this wisely. Not + * all browsers support attributes the same, and having too many custom + * attributes is probably bad. + */ + setAttribute(attribute, value) { + this.attributes[attribute] = value; + } + hasClass(className) { + return this.classes.includes(className); + } + toNode() { + return toNode.call(this, "span"); + } + toMarkup() { + return toMarkup.call(this, "span"); + } +} + +/** + * This node represents an anchor () element with a hyperlink. See `span` + * for further details. + */ +class Anchor { + constructor(href, classes, children, options) { + this.children = void 0; + this.attributes = void 0; + this.classes = void 0; + this.height = void 0; + this.depth = void 0; + this.maxFontSize = void 0; + this.style = void 0; + initNode.call(this, classes, options); + this.children = children || []; + this.setAttribute('href', href); + } + setAttribute(attribute, value) { + this.attributes[attribute] = value; + } + hasClass(className) { + return this.classes.includes(className); + } + toNode() { + return toNode.call(this, "a"); + } + toMarkup() { + return toMarkup.call(this, "a"); + } +} + +/** + * This node represents an image embed () element. + */ +class Img { + constructor(src, alt, style) { + this.src = void 0; + this.alt = void 0; + this.classes = void 0; + this.height = void 0; + this.depth = void 0; + this.maxFontSize = void 0; + this.style = void 0; + this.alt = alt; + this.src = src; + this.classes = ["mord"]; + this.height = 0; + this.depth = 0; + this.maxFontSize = 0; + this.style = style; + } + hasClass(className) { + return this.classes.includes(className); + } + toNode() { + const node = document.createElement("img"); + node.src = this.src; + node.alt = this.alt; + node.className = "mord"; + + // Apply inline styles + Object.assign(node.style, this.style); + return node; + } + toMarkup() { + let markup = "\"" 0) { + span = document.createElement("span"); + span.style.marginRight = makeEm(this.italic); + } + if (this.classes.length > 0) { + span = span || document.createElement("span"); + span.className = createClass(this.classes); + } + if (Object.keys(this.style).length > 0) { + span = span || document.createElement("span"); + Object.assign(span.style, this.style); + } + if (span) { + span.appendChild(node); + return span; + } else { + return node; + } + } + + /** + * Creates markup for a symbol node. + */ + toMarkup() { + // TODO(alpert): More duplication than I'd like from + // span.prototype.toMarkup and symbolNode.prototype.toNode... + let needsSpan = false; + let markup = " 0) { + styles += "margin-right:" + makeEm(this.italic) + ";"; + } + styles += cssStyleToString(this.style); + if (styles) { + needsSpan = true; + markup += " style=\"" + utils_escape(styles) + "\""; + } + const escaped = utils_escape(this.text); + if (needsSpan) { + markup += ">"; + markup += escaped; + markup += ""; + return markup; + } else { + return escaped; + } + } +} + +/** + * SVG nodes are used to render stretchy wide elements. + */ +class SvgNode { + constructor(children, attributes) { + this.children = void 0; + this.attributes = void 0; + this.children = children || []; + this.attributes = attributes || {}; + } + toNode() { + const svgNS = "http://www.w3.org/2000/svg"; + const node = document.createElementNS(svgNS, "svg"); + + // Apply attributes + for (const attr of Object.keys(this.attributes)) { + node.setAttribute(attr, this.attributes[attr]); + } + for (let i = 0; i < this.children.length; i++) { + node.appendChild(this.children[i].toNode()); + } + return node; + } + toMarkup() { + let markup = ""; + } else { + return ""; + } + } +} +class LineNode { + constructor(attributes) { + this.attributes = void 0; + this.attributes = attributes || {}; + } + toNode() { + const svgNS = "http://www.w3.org/2000/svg"; + const node = document.createElementNS(svgNS, "line"); + + // Apply attributes + for (const attr of Object.keys(this.attributes)) { + node.setAttribute(attr, this.attributes[attr]); + } + return node; + } + toMarkup() { + let markup = " but got " + String(group) + "."); + } +} + +/** + * Whether an HtmlDomNode has HtmlDomNode children. + * HtmlDomNode is a base type representing a union of + * SymbolNode, SvgSpan, DomSpan, Anchor, and documentFragment. + * In the last three cases, the children are HtmlDomNode[]. + */ +const hasHtmlDomChildren = node => node instanceof Span || node instanceof Anchor || node instanceof DocumentFragment; +;// ./src/fontMetricsData.js +// This file is GENERATED by buildMetrics.sh. DO NOT MODIFY. +/* harmony default export */ var fontMetricsData = ({ + "AMS-Regular": { + "32": [0, 0, 0, 0, 0.25], + "65": [0, 0.68889, 0, 0, 0.72222], + "66": [0, 0.68889, 0, 0, 0.66667], + "67": [0, 0.68889, 0, 0, 0.72222], + "68": [0, 0.68889, 0, 0, 0.72222], + "69": [0, 0.68889, 0, 0, 0.66667], + "70": [0, 0.68889, 0, 0, 0.61111], + "71": [0, 0.68889, 0, 0, 0.77778], + "72": [0, 0.68889, 0, 0, 0.77778], + "73": [0, 0.68889, 0, 0, 0.38889], + "74": [0.16667, 0.68889, 0, 0, 0.5], + "75": [0, 0.68889, 0, 0, 0.77778], + "76": [0, 0.68889, 0, 0, 0.66667], + "77": [0, 0.68889, 0, 0, 0.94445], + "78": [0, 0.68889, 0, 0, 0.72222], + "79": [0.16667, 0.68889, 0, 0, 0.77778], + "80": [0, 0.68889, 0, 0, 0.61111], + "81": [0.16667, 0.68889, 0, 0, 0.77778], + "82": [0, 0.68889, 0, 0, 0.72222], + "83": [0, 0.68889, 0, 0, 0.55556], + "84": [0, 0.68889, 0, 0, 0.66667], + "85": [0, 0.68889, 0, 0, 0.72222], + "86": [0, 0.68889, 0, 0, 0.72222], + "87": [0, 0.68889, 0, 0, 1.0], + "88": [0, 0.68889, 0, 0, 0.72222], + "89": [0, 0.68889, 0, 0, 0.72222], + "90": [0, 0.68889, 0, 0, 0.66667], + "107": [0, 0.68889, 0, 0, 0.55556], + "160": [0, 0, 0, 0, 0.25], + "165": [0, 0.675, 0.025, 0, 0.75], + "174": [0.15559, 0.69224, 0, 0, 0.94666], + "240": [0, 0.68889, 0, 0, 0.55556], + "295": [0, 0.68889, 0, 0, 0.54028], + "710": [0, 0.825, 0, 0, 2.33334], + "732": [0, 0.9, 0, 0, 2.33334], + "770": [0, 0.825, 0, 0, 2.33334], + "771": [0, 0.9, 0, 0, 2.33334], + "989": [0.08167, 0.58167, 0, 0, 0.77778], + "1008": [0, 0.43056, 0.04028, 0, 0.66667], + "8245": [0, 0.54986, 0, 0, 0.275], + "8463": [0, 0.68889, 0, 0, 0.54028], + "8487": [0, 0.68889, 0, 0, 0.72222], + "8498": [0, 0.68889, 0, 0, 0.55556], + "8502": [0, 0.68889, 0, 0, 0.66667], + "8503": [0, 0.68889, 0, 0, 0.44445], + "8504": [0, 0.68889, 0, 0, 0.66667], + "8513": [0, 0.68889, 0, 0, 0.63889], + "8592": [-0.03598, 0.46402, 0, 0, 0.5], + "8594": [-0.03598, 0.46402, 0, 0, 0.5], + "8602": [-0.13313, 0.36687, 0, 0, 1.0], + "8603": [-0.13313, 0.36687, 0, 0, 1.0], + "8606": [0.01354, 0.52239, 0, 0, 1.0], + "8608": [0.01354, 0.52239, 0, 0, 1.0], + "8610": [0.01354, 0.52239, 0, 0, 1.11111], + "8611": [0.01354, 0.52239, 0, 0, 1.11111], + "8619": [0, 0.54986, 0, 0, 1.0], + "8620": [0, 0.54986, 0, 0, 1.0], + "8621": [-0.13313, 0.37788, 0, 0, 1.38889], + "8622": [-0.13313, 0.36687, 0, 0, 1.0], + "8624": [0, 0.69224, 0, 0, 0.5], + "8625": [0, 0.69224, 0, 0, 0.5], + "8630": [0, 0.43056, 0, 0, 1.0], + "8631": [0, 0.43056, 0, 0, 1.0], + "8634": [0.08198, 0.58198, 0, 0, 0.77778], + "8635": [0.08198, 0.58198, 0, 0, 0.77778], + "8638": [0.19444, 0.69224, 0, 0, 0.41667], + "8639": [0.19444, 0.69224, 0, 0, 0.41667], + "8642": [0.19444, 0.69224, 0, 0, 0.41667], + "8643": [0.19444, 0.69224, 0, 0, 0.41667], + "8644": [0.1808, 0.675, 0, 0, 1.0], + "8646": [0.1808, 0.675, 0, 0, 1.0], + "8647": [0.1808, 0.675, 0, 0, 1.0], + "8648": [0.19444, 0.69224, 0, 0, 0.83334], + "8649": [0.1808, 0.675, 0, 0, 1.0], + "8650": [0.19444, 0.69224, 0, 0, 0.83334], + "8651": [0.01354, 0.52239, 0, 0, 1.0], + "8652": [0.01354, 0.52239, 0, 0, 1.0], + "8653": [-0.13313, 0.36687, 0, 0, 1.0], + "8654": [-0.13313, 0.36687, 0, 0, 1.0], + "8655": [-0.13313, 0.36687, 0, 0, 1.0], + "8666": [0.13667, 0.63667, 0, 0, 1.0], + "8667": [0.13667, 0.63667, 0, 0, 1.0], + "8669": [-0.13313, 0.37788, 0, 0, 1.0], + "8672": [-0.064, 0.437, 0, 0, 1.334], + "8674": [-0.064, 0.437, 0, 0, 1.334], + "8705": [0, 0.825, 0, 0, 0.5], + "8708": [0, 0.68889, 0, 0, 0.55556], + "8709": [0.08167, 0.58167, 0, 0, 0.77778], + "8717": [0, 0.43056, 0, 0, 0.42917], + "8722": [-0.03598, 0.46402, 0, 0, 0.5], + "8724": [0.08198, 0.69224, 0, 0, 0.77778], + "8726": [0.08167, 0.58167, 0, 0, 0.77778], + "8733": [0, 0.69224, 0, 0, 0.77778], + "8736": [0, 0.69224, 0, 0, 0.72222], + "8737": [0, 0.69224, 0, 0, 0.72222], + "8738": [0.03517, 0.52239, 0, 0, 0.72222], + "8739": [0.08167, 0.58167, 0, 0, 0.22222], + "8740": [0.25142, 0.74111, 0, 0, 0.27778], + "8741": [0.08167, 0.58167, 0, 0, 0.38889], + "8742": [0.25142, 0.74111, 0, 0, 0.5], + "8756": [0, 0.69224, 0, 0, 0.66667], + "8757": [0, 0.69224, 0, 0, 0.66667], + "8764": [-0.13313, 0.36687, 0, 0, 0.77778], + "8765": [-0.13313, 0.37788, 0, 0, 0.77778], + "8769": [-0.13313, 0.36687, 0, 0, 0.77778], + "8770": [-0.03625, 0.46375, 0, 0, 0.77778], + "8774": [0.30274, 0.79383, 0, 0, 0.77778], + "8776": [-0.01688, 0.48312, 0, 0, 0.77778], + "8778": [0.08167, 0.58167, 0, 0, 0.77778], + "8782": [0.06062, 0.54986, 0, 0, 0.77778], + "8783": [0.06062, 0.54986, 0, 0, 0.77778], + "8785": [0.08198, 0.58198, 0, 0, 0.77778], + "8786": [0.08198, 0.58198, 0, 0, 0.77778], + "8787": [0.08198, 0.58198, 0, 0, 0.77778], + "8790": [0, 0.69224, 0, 0, 0.77778], + "8791": [0.22958, 0.72958, 0, 0, 0.77778], + "8796": [0.08198, 0.91667, 0, 0, 0.77778], + "8806": [0.25583, 0.75583, 0, 0, 0.77778], + "8807": [0.25583, 0.75583, 0, 0, 0.77778], + "8808": [0.25142, 0.75726, 0, 0, 0.77778], + "8809": [0.25142, 0.75726, 0, 0, 0.77778], + "8812": [0.25583, 0.75583, 0, 0, 0.5], + "8814": [0.20576, 0.70576, 0, 0, 0.77778], + "8815": [0.20576, 0.70576, 0, 0, 0.77778], + "8816": [0.30274, 0.79383, 0, 0, 0.77778], + "8817": [0.30274, 0.79383, 0, 0, 0.77778], + "8818": [0.22958, 0.72958, 0, 0, 0.77778], + "8819": [0.22958, 0.72958, 0, 0, 0.77778], + "8822": [0.1808, 0.675, 0, 0, 0.77778], + "8823": [0.1808, 0.675, 0, 0, 0.77778], + "8828": [0.13667, 0.63667, 0, 0, 0.77778], + "8829": [0.13667, 0.63667, 0, 0, 0.77778], + "8830": [0.22958, 0.72958, 0, 0, 0.77778], + "8831": [0.22958, 0.72958, 0, 0, 0.77778], + "8832": [0.20576, 0.70576, 0, 0, 0.77778], + "8833": [0.20576, 0.70576, 0, 0, 0.77778], + "8840": [0.30274, 0.79383, 0, 0, 0.77778], + "8841": [0.30274, 0.79383, 0, 0, 0.77778], + "8842": [0.13597, 0.63597, 0, 0, 0.77778], + "8843": [0.13597, 0.63597, 0, 0, 0.77778], + "8847": [0.03517, 0.54986, 0, 0, 0.77778], + "8848": [0.03517, 0.54986, 0, 0, 0.77778], + "8858": [0.08198, 0.58198, 0, 0, 0.77778], + "8859": [0.08198, 0.58198, 0, 0, 0.77778], + "8861": [0.08198, 0.58198, 0, 0, 0.77778], + "8862": [0, 0.675, 0, 0, 0.77778], + "8863": [0, 0.675, 0, 0, 0.77778], + "8864": [0, 0.675, 0, 0, 0.77778], + "8865": [0, 0.675, 0, 0, 0.77778], + "8872": [0, 0.69224, 0, 0, 0.61111], + "8873": [0, 0.69224, 0, 0, 0.72222], + "8874": [0, 0.69224, 0, 0, 0.88889], + "8876": [0, 0.68889, 0, 0, 0.61111], + "8877": [0, 0.68889, 0, 0, 0.61111], + "8878": [0, 0.68889, 0, 0, 0.72222], + "8879": [0, 0.68889, 0, 0, 0.72222], + "8882": [0.03517, 0.54986, 0, 0, 0.77778], + "8883": [0.03517, 0.54986, 0, 0, 0.77778], + "8884": [0.13667, 0.63667, 0, 0, 0.77778], + "8885": [0.13667, 0.63667, 0, 0, 0.77778], + "8888": [0, 0.54986, 0, 0, 1.11111], + "8890": [0.19444, 0.43056, 0, 0, 0.55556], + "8891": [0.19444, 0.69224, 0, 0, 0.61111], + "8892": [0.19444, 0.69224, 0, 0, 0.61111], + "8901": [0, 0.54986, 0, 0, 0.27778], + "8903": [0.08167, 0.58167, 0, 0, 0.77778], + "8905": [0.08167, 0.58167, 0, 0, 0.77778], + "8906": [0.08167, 0.58167, 0, 0, 0.77778], + "8907": [0, 0.69224, 0, 0, 0.77778], + "8908": [0, 0.69224, 0, 0, 0.77778], + "8909": [-0.03598, 0.46402, 0, 0, 0.77778], + "8910": [0, 0.54986, 0, 0, 0.76042], + "8911": [0, 0.54986, 0, 0, 0.76042], + "8912": [0.03517, 0.54986, 0, 0, 0.77778], + "8913": [0.03517, 0.54986, 0, 0, 0.77778], + "8914": [0, 0.54986, 0, 0, 0.66667], + "8915": [0, 0.54986, 0, 0, 0.66667], + "8916": [0, 0.69224, 0, 0, 0.66667], + "8918": [0.0391, 0.5391, 0, 0, 0.77778], + "8919": [0.0391, 0.5391, 0, 0, 0.77778], + "8920": [0.03517, 0.54986, 0, 0, 1.33334], + "8921": [0.03517, 0.54986, 0, 0, 1.33334], + "8922": [0.38569, 0.88569, 0, 0, 0.77778], + "8923": [0.38569, 0.88569, 0, 0, 0.77778], + "8926": [0.13667, 0.63667, 0, 0, 0.77778], + "8927": [0.13667, 0.63667, 0, 0, 0.77778], + "8928": [0.30274, 0.79383, 0, 0, 0.77778], + "8929": [0.30274, 0.79383, 0, 0, 0.77778], + "8934": [0.23222, 0.74111, 0, 0, 0.77778], + "8935": [0.23222, 0.74111, 0, 0, 0.77778], + "8936": [0.23222, 0.74111, 0, 0, 0.77778], + "8937": [0.23222, 0.74111, 0, 0, 0.77778], + "8938": [0.20576, 0.70576, 0, 0, 0.77778], + "8939": [0.20576, 0.70576, 0, 0, 0.77778], + "8940": [0.30274, 0.79383, 0, 0, 0.77778], + "8941": [0.30274, 0.79383, 0, 0, 0.77778], + "8994": [0.19444, 0.69224, 0, 0, 0.77778], + "8995": [0.19444, 0.69224, 0, 0, 0.77778], + "9416": [0.15559, 0.69224, 0, 0, 0.90222], + "9484": [0, 0.69224, 0, 0, 0.5], + "9488": [0, 0.69224, 0, 0, 0.5], + "9492": [0, 0.37788, 0, 0, 0.5], + "9496": [0, 0.37788, 0, 0, 0.5], + "9585": [0.19444, 0.68889, 0, 0, 0.88889], + "9586": [0.19444, 0.74111, 0, 0, 0.88889], + "9632": [0, 0.675, 0, 0, 0.77778], + "9633": [0, 0.675, 0, 0, 0.77778], + "9650": [0, 0.54986, 0, 0, 0.72222], + "9651": [0, 0.54986, 0, 0, 0.72222], + "9654": [0.03517, 0.54986, 0, 0, 0.77778], + "9660": [0, 0.54986, 0, 0, 0.72222], + "9661": [0, 0.54986, 0, 0, 0.72222], + "9664": [0.03517, 0.54986, 0, 0, 0.77778], + "9674": [0.11111, 0.69224, 0, 0, 0.66667], + "9733": [0.19444, 0.69224, 0, 0, 0.94445], + "10003": [0, 0.69224, 0, 0, 0.83334], + "10016": [0, 0.69224, 0, 0, 0.83334], + "10731": [0.11111, 0.69224, 0, 0, 0.66667], + "10846": [0.19444, 0.75583, 0, 0, 0.61111], + "10877": [0.13667, 0.63667, 0, 0, 0.77778], + "10878": [0.13667, 0.63667, 0, 0, 0.77778], + "10885": [0.25583, 0.75583, 0, 0, 0.77778], + "10886": [0.25583, 0.75583, 0, 0, 0.77778], + "10887": [0.13597, 0.63597, 0, 0, 0.77778], + "10888": [0.13597, 0.63597, 0, 0, 0.77778], + "10889": [0.26167, 0.75726, 0, 0, 0.77778], + "10890": [0.26167, 0.75726, 0, 0, 0.77778], + "10891": [0.48256, 0.98256, 0, 0, 0.77778], + "10892": [0.48256, 0.98256, 0, 0, 0.77778], + "10901": [0.13667, 0.63667, 0, 0, 0.77778], + "10902": [0.13667, 0.63667, 0, 0, 0.77778], + "10933": [0.25142, 0.75726, 0, 0, 0.77778], + "10934": [0.25142, 0.75726, 0, 0, 0.77778], + "10935": [0.26167, 0.75726, 0, 0, 0.77778], + "10936": [0.26167, 0.75726, 0, 0, 0.77778], + "10937": [0.26167, 0.75726, 0, 0, 0.77778], + "10938": [0.26167, 0.75726, 0, 0, 0.77778], + "10949": [0.25583, 0.75583, 0, 0, 0.77778], + "10950": [0.25583, 0.75583, 0, 0, 0.77778], + "10955": [0.28481, 0.79383, 0, 0, 0.77778], + "10956": [0.28481, 0.79383, 0, 0, 0.77778], + "57350": [0.08167, 0.58167, 0, 0, 0.22222], + "57351": [0.08167, 0.58167, 0, 0, 0.38889], + "57352": [0.08167, 0.58167, 0, 0, 0.77778], + "57353": [0, 0.43056, 0.04028, 0, 0.66667], + "57356": [0.25142, 0.75726, 0, 0, 0.77778], + "57357": [0.25142, 0.75726, 0, 0, 0.77778], + "57358": [0.41951, 0.91951, 0, 0, 0.77778], + "57359": [0.30274, 0.79383, 0, 0, 0.77778], + "57360": [0.30274, 0.79383, 0, 0, 0.77778], + "57361": [0.41951, 0.91951, 0, 0, 0.77778], + "57366": [0.25142, 0.75726, 0, 0, 0.77778], + "57367": [0.25142, 0.75726, 0, 0, 0.77778], + "57368": [0.25142, 0.75726, 0, 0, 0.77778], + "57369": [0.25142, 0.75726, 0, 0, 0.77778], + "57370": [0.13597, 0.63597, 0, 0, 0.77778], + "57371": [0.13597, 0.63597, 0, 0, 0.77778] + }, + "Caligraphic-Regular": { + "32": [0, 0, 0, 0, 0.25], + "65": [0, 0.68333, 0, 0.19445, 0.79847], + "66": [0, 0.68333, 0.03041, 0.13889, 0.65681], + "67": [0, 0.68333, 0.05834, 0.13889, 0.52653], + "68": [0, 0.68333, 0.02778, 0.08334, 0.77139], + "69": [0, 0.68333, 0.08944, 0.11111, 0.52778], + "70": [0, 0.68333, 0.09931, 0.11111, 0.71875], + "71": [0.09722, 0.68333, 0.0593, 0.11111, 0.59487], + "72": [0, 0.68333, 0.00965, 0.11111, 0.84452], + "73": [0, 0.68333, 0.07382, 0, 0.54452], + "74": [0.09722, 0.68333, 0.18472, 0.16667, 0.67778], + "75": [0, 0.68333, 0.01445, 0.05556, 0.76195], + "76": [0, 0.68333, 0, 0.13889, 0.68972], + "77": [0, 0.68333, 0, 0.13889, 1.2009], + "78": [0, 0.68333, 0.14736, 0.08334, 0.82049], + "79": [0, 0.68333, 0.02778, 0.11111, 0.79611], + "80": [0, 0.68333, 0.08222, 0.08334, 0.69556], + "81": [0.09722, 0.68333, 0, 0.11111, 0.81667], + "82": [0, 0.68333, 0, 0.08334, 0.8475], + "83": [0, 0.68333, 0.075, 0.13889, 0.60556], + "84": [0, 0.68333, 0.25417, 0, 0.54464], + "85": [0, 0.68333, 0.09931, 0.08334, 0.62583], + "86": [0, 0.68333, 0.08222, 0, 0.61278], + "87": [0, 0.68333, 0.08222, 0.08334, 0.98778], + "88": [0, 0.68333, 0.14643, 0.13889, 0.7133], + "89": [0.09722, 0.68333, 0.08222, 0.08334, 0.66834], + "90": [0, 0.68333, 0.07944, 0.13889, 0.72473], + "160": [0, 0, 0, 0, 0.25] + }, + "Fraktur-Regular": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69141, 0, 0, 0.29574], + "34": [0, 0.69141, 0, 0, 0.21471], + "38": [0, 0.69141, 0, 0, 0.73786], + "39": [0, 0.69141, 0, 0, 0.21201], + "40": [0.24982, 0.74947, 0, 0, 0.38865], + "41": [0.24982, 0.74947, 0, 0, 0.38865], + "42": [0, 0.62119, 0, 0, 0.27764], + "43": [0.08319, 0.58283, 0, 0, 0.75623], + "44": [0, 0.10803, 0, 0, 0.27764], + "45": [0.08319, 0.58283, 0, 0, 0.75623], + "46": [0, 0.10803, 0, 0, 0.27764], + "47": [0.24982, 0.74947, 0, 0, 0.50181], + "48": [0, 0.47534, 0, 0, 0.50181], + "49": [0, 0.47534, 0, 0, 0.50181], + "50": [0, 0.47534, 0, 0, 0.50181], + "51": [0.18906, 0.47534, 0, 0, 0.50181], + "52": [0.18906, 0.47534, 0, 0, 0.50181], + "53": [0.18906, 0.47534, 0, 0, 0.50181], + "54": [0, 0.69141, 0, 0, 0.50181], + "55": [0.18906, 0.47534, 0, 0, 0.50181], + "56": [0, 0.69141, 0, 0, 0.50181], + "57": [0.18906, 0.47534, 0, 0, 0.50181], + "58": [0, 0.47534, 0, 0, 0.21606], + "59": [0.12604, 0.47534, 0, 0, 0.21606], + "61": [-0.13099, 0.36866, 0, 0, 0.75623], + "63": [0, 0.69141, 0, 0, 0.36245], + "65": [0, 0.69141, 0, 0, 0.7176], + "66": [0, 0.69141, 0, 0, 0.88397], + "67": [0, 0.69141, 0, 0, 0.61254], + "68": [0, 0.69141, 0, 0, 0.83158], + "69": [0, 0.69141, 0, 0, 0.66278], + "70": [0.12604, 0.69141, 0, 0, 0.61119], + "71": [0, 0.69141, 0, 0, 0.78539], + "72": [0.06302, 0.69141, 0, 0, 0.7203], + "73": [0, 0.69141, 0, 0, 0.55448], + "74": [0.12604, 0.69141, 0, 0, 0.55231], + "75": [0, 0.69141, 0, 0, 0.66845], + "76": [0, 0.69141, 0, 0, 0.66602], + "77": [0, 0.69141, 0, 0, 1.04953], + "78": [0, 0.69141, 0, 0, 0.83212], + "79": [0, 0.69141, 0, 0, 0.82699], + "80": [0.18906, 0.69141, 0, 0, 0.82753], + "81": [0.03781, 0.69141, 0, 0, 0.82699], + "82": [0, 0.69141, 0, 0, 0.82807], + "83": [0, 0.69141, 0, 0, 0.82861], + "84": [0, 0.69141, 0, 0, 0.66899], + "85": [0, 0.69141, 0, 0, 0.64576], + "86": [0, 0.69141, 0, 0, 0.83131], + "87": [0, 0.69141, 0, 0, 1.04602], + "88": [0, 0.69141, 0, 0, 0.71922], + "89": [0.18906, 0.69141, 0, 0, 0.83293], + "90": [0.12604, 0.69141, 0, 0, 0.60201], + "91": [0.24982, 0.74947, 0, 0, 0.27764], + "93": [0.24982, 0.74947, 0, 0, 0.27764], + "94": [0, 0.69141, 0, 0, 0.49965], + "97": [0, 0.47534, 0, 0, 0.50046], + "98": [0, 0.69141, 0, 0, 0.51315], + "99": [0, 0.47534, 0, 0, 0.38946], + "100": [0, 0.62119, 0, 0, 0.49857], + "101": [0, 0.47534, 0, 0, 0.40053], + "102": [0.18906, 0.69141, 0, 0, 0.32626], + "103": [0.18906, 0.47534, 0, 0, 0.5037], + "104": [0.18906, 0.69141, 0, 0, 0.52126], + "105": [0, 0.69141, 0, 0, 0.27899], + "106": [0, 0.69141, 0, 0, 0.28088], + "107": [0, 0.69141, 0, 0, 0.38946], + "108": [0, 0.69141, 0, 0, 0.27953], + "109": [0, 0.47534, 0, 0, 0.76676], + "110": [0, 0.47534, 0, 0, 0.52666], + "111": [0, 0.47534, 0, 0, 0.48885], + "112": [0.18906, 0.52396, 0, 0, 0.50046], + "113": [0.18906, 0.47534, 0, 0, 0.48912], + "114": [0, 0.47534, 0, 0, 0.38919], + "115": [0, 0.47534, 0, 0, 0.44266], + "116": [0, 0.62119, 0, 0, 0.33301], + "117": [0, 0.47534, 0, 0, 0.5172], + "118": [0, 0.52396, 0, 0, 0.5118], + "119": [0, 0.52396, 0, 0, 0.77351], + "120": [0.18906, 0.47534, 0, 0, 0.38865], + "121": [0.18906, 0.47534, 0, 0, 0.49884], + "122": [0.18906, 0.47534, 0, 0, 0.39054], + "160": [0, 0, 0, 0, 0.25], + "8216": [0, 0.69141, 0, 0, 0.21471], + "8217": [0, 0.69141, 0, 0, 0.21471], + "58112": [0, 0.62119, 0, 0, 0.49749], + "58113": [0, 0.62119, 0, 0, 0.4983], + "58114": [0.18906, 0.69141, 0, 0, 0.33328], + "58115": [0.18906, 0.69141, 0, 0, 0.32923], + "58116": [0.18906, 0.47534, 0, 0, 0.50343], + "58117": [0, 0.69141, 0, 0, 0.33301], + "58118": [0, 0.62119, 0, 0, 0.33409], + "58119": [0, 0.47534, 0, 0, 0.50073] + }, + "Main-Bold": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0, 0, 0.35], + "34": [0, 0.69444, 0, 0, 0.60278], + "35": [0.19444, 0.69444, 0, 0, 0.95833], + "36": [0.05556, 0.75, 0, 0, 0.575], + "37": [0.05556, 0.75, 0, 0, 0.95833], + "38": [0, 0.69444, 0, 0, 0.89444], + "39": [0, 0.69444, 0, 0, 0.31944], + "40": [0.25, 0.75, 0, 0, 0.44722], + "41": [0.25, 0.75, 0, 0, 0.44722], + "42": [0, 0.75, 0, 0, 0.575], + "43": [0.13333, 0.63333, 0, 0, 0.89444], + "44": [0.19444, 0.15556, 0, 0, 0.31944], + "45": [0, 0.44444, 0, 0, 0.38333], + "46": [0, 0.15556, 0, 0, 0.31944], + "47": [0.25, 0.75, 0, 0, 0.575], + "48": [0, 0.64444, 0, 0, 0.575], + "49": [0, 0.64444, 0, 0, 0.575], + "50": [0, 0.64444, 0, 0, 0.575], + "51": [0, 0.64444, 0, 0, 0.575], + "52": [0, 0.64444, 0, 0, 0.575], + "53": [0, 0.64444, 0, 0, 0.575], + "54": [0, 0.64444, 0, 0, 0.575], + "55": [0, 0.64444, 0, 0, 0.575], + "56": [0, 0.64444, 0, 0, 0.575], + "57": [0, 0.64444, 0, 0, 0.575], + "58": [0, 0.44444, 0, 0, 0.31944], + "59": [0.19444, 0.44444, 0, 0, 0.31944], + "60": [0.08556, 0.58556, 0, 0, 0.89444], + "61": [-0.10889, 0.39111, 0, 0, 0.89444], + "62": [0.08556, 0.58556, 0, 0, 0.89444], + "63": [0, 0.69444, 0, 0, 0.54305], + "64": [0, 0.69444, 0, 0, 0.89444], + "65": [0, 0.68611, 0, 0, 0.86944], + "66": [0, 0.68611, 0, 0, 0.81805], + "67": [0, 0.68611, 0, 0, 0.83055], + "68": [0, 0.68611, 0, 0, 0.88194], + "69": [0, 0.68611, 0, 0, 0.75555], + "70": [0, 0.68611, 0, 0, 0.72361], + "71": [0, 0.68611, 0, 0, 0.90416], + "72": [0, 0.68611, 0, 0, 0.9], + "73": [0, 0.68611, 0, 0, 0.43611], + "74": [0, 0.68611, 0, 0, 0.59444], + "75": [0, 0.68611, 0, 0, 0.90138], + "76": [0, 0.68611, 0, 0, 0.69166], + "77": [0, 0.68611, 0, 0, 1.09166], + "78": [0, 0.68611, 0, 0, 0.9], + "79": [0, 0.68611, 0, 0, 0.86388], + "80": [0, 0.68611, 0, 0, 0.78611], + "81": [0.19444, 0.68611, 0, 0, 0.86388], + "82": [0, 0.68611, 0, 0, 0.8625], + "83": [0, 0.68611, 0, 0, 0.63889], + "84": [0, 0.68611, 0, 0, 0.8], + "85": [0, 0.68611, 0, 0, 0.88472], + "86": [0, 0.68611, 0.01597, 0, 0.86944], + "87": [0, 0.68611, 0.01597, 0, 1.18888], + "88": [0, 0.68611, 0, 0, 0.86944], + "89": [0, 0.68611, 0.02875, 0, 0.86944], + "90": [0, 0.68611, 0, 0, 0.70277], + "91": [0.25, 0.75, 0, 0, 0.31944], + "92": [0.25, 0.75, 0, 0, 0.575], + "93": [0.25, 0.75, 0, 0, 0.31944], + "94": [0, 0.69444, 0, 0, 0.575], + "95": [0.31, 0.13444, 0.03194, 0, 0.575], + "97": [0, 0.44444, 0, 0, 0.55902], + "98": [0, 0.69444, 0, 0, 0.63889], + "99": [0, 0.44444, 0, 0, 0.51111], + "100": [0, 0.69444, 0, 0, 0.63889], + "101": [0, 0.44444, 0, 0, 0.52708], + "102": [0, 0.69444, 0.10903, 0, 0.35139], + "103": [0.19444, 0.44444, 0.01597, 0, 0.575], + "104": [0, 0.69444, 0, 0, 0.63889], + "105": [0, 0.69444, 0, 0, 0.31944], + "106": [0.19444, 0.69444, 0, 0, 0.35139], + "107": [0, 0.69444, 0, 0, 0.60694], + "108": [0, 0.69444, 0, 0, 0.31944], + "109": [0, 0.44444, 0, 0, 0.95833], + "110": [0, 0.44444, 0, 0, 0.63889], + "111": [0, 0.44444, 0, 0, 0.575], + "112": [0.19444, 0.44444, 0, 0, 0.63889], + "113": [0.19444, 0.44444, 0, 0, 0.60694], + "114": [0, 0.44444, 0, 0, 0.47361], + "115": [0, 0.44444, 0, 0, 0.45361], + "116": [0, 0.63492, 0, 0, 0.44722], + "117": [0, 0.44444, 0, 0, 0.63889], + "118": [0, 0.44444, 0.01597, 0, 0.60694], + "119": [0, 0.44444, 0.01597, 0, 0.83055], + "120": [0, 0.44444, 0, 0, 0.60694], + "121": [0.19444, 0.44444, 0.01597, 0, 0.60694], + "122": [0, 0.44444, 0, 0, 0.51111], + "123": [0.25, 0.75, 0, 0, 0.575], + "124": [0.25, 0.75, 0, 0, 0.31944], + "125": [0.25, 0.75, 0, 0, 0.575], + "126": [0.35, 0.34444, 0, 0, 0.575], + "160": [0, 0, 0, 0, 0.25], + "163": [0, 0.69444, 0, 0, 0.86853], + "168": [0, 0.69444, 0, 0, 0.575], + "172": [0, 0.44444, 0, 0, 0.76666], + "176": [0, 0.69444, 0, 0, 0.86944], + "177": [0.13333, 0.63333, 0, 0, 0.89444], + "184": [0.17014, 0, 0, 0, 0.51111], + "198": [0, 0.68611, 0, 0, 1.04166], + "215": [0.13333, 0.63333, 0, 0, 0.89444], + "216": [0.04861, 0.73472, 0, 0, 0.89444], + "223": [0, 0.69444, 0, 0, 0.59722], + "230": [0, 0.44444, 0, 0, 0.83055], + "247": [0.13333, 0.63333, 0, 0, 0.89444], + "248": [0.09722, 0.54167, 0, 0, 0.575], + "305": [0, 0.44444, 0, 0, 0.31944], + "338": [0, 0.68611, 0, 0, 1.16944], + "339": [0, 0.44444, 0, 0, 0.89444], + "567": [0.19444, 0.44444, 0, 0, 0.35139], + "710": [0, 0.69444, 0, 0, 0.575], + "711": [0, 0.63194, 0, 0, 0.575], + "713": [0, 0.59611, 0, 0, 0.575], + "714": [0, 0.69444, 0, 0, 0.575], + "715": [0, 0.69444, 0, 0, 0.575], + "728": [0, 0.69444, 0, 0, 0.575], + "729": [0, 0.69444, 0, 0, 0.31944], + "730": [0, 0.69444, 0, 0, 0.86944], + "732": [0, 0.69444, 0, 0, 0.575], + "733": [0, 0.69444, 0, 0, 0.575], + "915": [0, 0.68611, 0, 0, 0.69166], + "916": [0, 0.68611, 0, 0, 0.95833], + "920": [0, 0.68611, 0, 0, 0.89444], + "923": [0, 0.68611, 0, 0, 0.80555], + "926": [0, 0.68611, 0, 0, 0.76666], + "928": [0, 0.68611, 0, 0, 0.9], + "931": [0, 0.68611, 0, 0, 0.83055], + "933": [0, 0.68611, 0, 0, 0.89444], + "934": [0, 0.68611, 0, 0, 0.83055], + "936": [0, 0.68611, 0, 0, 0.89444], + "937": [0, 0.68611, 0, 0, 0.83055], + "8211": [0, 0.44444, 0.03194, 0, 0.575], + "8212": [0, 0.44444, 0.03194, 0, 1.14999], + "8216": [0, 0.69444, 0, 0, 0.31944], + "8217": [0, 0.69444, 0, 0, 0.31944], + "8220": [0, 0.69444, 0, 0, 0.60278], + "8221": [0, 0.69444, 0, 0, 0.60278], + "8224": [0.19444, 0.69444, 0, 0, 0.51111], + "8225": [0.19444, 0.69444, 0, 0, 0.51111], + "8242": [0, 0.55556, 0, 0, 0.34444], + "8407": [0, 0.72444, 0.15486, 0, 0.575], + "8463": [0, 0.69444, 0, 0, 0.66759], + "8465": [0, 0.69444, 0, 0, 0.83055], + "8467": [0, 0.69444, 0, 0, 0.47361], + "8472": [0.19444, 0.44444, 0, 0, 0.74027], + "8476": [0, 0.69444, 0, 0, 0.83055], + "8501": [0, 0.69444, 0, 0, 0.70277], + "8592": [-0.10889, 0.39111, 0, 0, 1.14999], + "8593": [0.19444, 0.69444, 0, 0, 0.575], + "8594": [-0.10889, 0.39111, 0, 0, 1.14999], + "8595": [0.19444, 0.69444, 0, 0, 0.575], + "8596": [-0.10889, 0.39111, 0, 0, 1.14999], + "8597": [0.25, 0.75, 0, 0, 0.575], + "8598": [0.19444, 0.69444, 0, 0, 1.14999], + "8599": [0.19444, 0.69444, 0, 0, 1.14999], + "8600": [0.19444, 0.69444, 0, 0, 1.14999], + "8601": [0.19444, 0.69444, 0, 0, 1.14999], + "8636": [-0.10889, 0.39111, 0, 0, 1.14999], + "8637": [-0.10889, 0.39111, 0, 0, 1.14999], + "8640": [-0.10889, 0.39111, 0, 0, 1.14999], + "8641": [-0.10889, 0.39111, 0, 0, 1.14999], + "8656": [-0.10889, 0.39111, 0, 0, 1.14999], + "8657": [0.19444, 0.69444, 0, 0, 0.70277], + "8658": [-0.10889, 0.39111, 0, 0, 1.14999], + "8659": [0.19444, 0.69444, 0, 0, 0.70277], + "8660": [-0.10889, 0.39111, 0, 0, 1.14999], + "8661": [0.25, 0.75, 0, 0, 0.70277], + "8704": [0, 0.69444, 0, 0, 0.63889], + "8706": [0, 0.69444, 0.06389, 0, 0.62847], + "8707": [0, 0.69444, 0, 0, 0.63889], + "8709": [0.05556, 0.75, 0, 0, 0.575], + "8711": [0, 0.68611, 0, 0, 0.95833], + "8712": [0.08556, 0.58556, 0, 0, 0.76666], + "8715": [0.08556, 0.58556, 0, 0, 0.76666], + "8722": [0.13333, 0.63333, 0, 0, 0.89444], + "8723": [0.13333, 0.63333, 0, 0, 0.89444], + "8725": [0.25, 0.75, 0, 0, 0.575], + "8726": [0.25, 0.75, 0, 0, 0.575], + "8727": [-0.02778, 0.47222, 0, 0, 0.575], + "8728": [-0.02639, 0.47361, 0, 0, 0.575], + "8729": [-0.02639, 0.47361, 0, 0, 0.575], + "8730": [0.18, 0.82, 0, 0, 0.95833], + "8733": [0, 0.44444, 0, 0, 0.89444], + "8734": [0, 0.44444, 0, 0, 1.14999], + "8736": [0, 0.69224, 0, 0, 0.72222], + "8739": [0.25, 0.75, 0, 0, 0.31944], + "8741": [0.25, 0.75, 0, 0, 0.575], + "8743": [0, 0.55556, 0, 0, 0.76666], + "8744": [0, 0.55556, 0, 0, 0.76666], + "8745": [0, 0.55556, 0, 0, 0.76666], + "8746": [0, 0.55556, 0, 0, 0.76666], + "8747": [0.19444, 0.69444, 0.12778, 0, 0.56875], + "8764": [-0.10889, 0.39111, 0, 0, 0.89444], + "8768": [0.19444, 0.69444, 0, 0, 0.31944], + "8771": [0.00222, 0.50222, 0, 0, 0.89444], + "8773": [0.027, 0.638, 0, 0, 0.894], + "8776": [0.02444, 0.52444, 0, 0, 0.89444], + "8781": [0.00222, 0.50222, 0, 0, 0.89444], + "8801": [0.00222, 0.50222, 0, 0, 0.89444], + "8804": [0.19667, 0.69667, 0, 0, 0.89444], + "8805": [0.19667, 0.69667, 0, 0, 0.89444], + "8810": [0.08556, 0.58556, 0, 0, 1.14999], + "8811": [0.08556, 0.58556, 0, 0, 1.14999], + "8826": [0.08556, 0.58556, 0, 0, 0.89444], + "8827": [0.08556, 0.58556, 0, 0, 0.89444], + "8834": [0.08556, 0.58556, 0, 0, 0.89444], + "8835": [0.08556, 0.58556, 0, 0, 0.89444], + "8838": [0.19667, 0.69667, 0, 0, 0.89444], + "8839": [0.19667, 0.69667, 0, 0, 0.89444], + "8846": [0, 0.55556, 0, 0, 0.76666], + "8849": [0.19667, 0.69667, 0, 0, 0.89444], + "8850": [0.19667, 0.69667, 0, 0, 0.89444], + "8851": [0, 0.55556, 0, 0, 0.76666], + "8852": [0, 0.55556, 0, 0, 0.76666], + "8853": [0.13333, 0.63333, 0, 0, 0.89444], + "8854": [0.13333, 0.63333, 0, 0, 0.89444], + "8855": [0.13333, 0.63333, 0, 0, 0.89444], + "8856": [0.13333, 0.63333, 0, 0, 0.89444], + "8857": [0.13333, 0.63333, 0, 0, 0.89444], + "8866": [0, 0.69444, 0, 0, 0.70277], + "8867": [0, 0.69444, 0, 0, 0.70277], + "8868": [0, 0.69444, 0, 0, 0.89444], + "8869": [0, 0.69444, 0, 0, 0.89444], + "8900": [-0.02639, 0.47361, 0, 0, 0.575], + "8901": [-0.02639, 0.47361, 0, 0, 0.31944], + "8902": [-0.02778, 0.47222, 0, 0, 0.575], + "8968": [0.25, 0.75, 0, 0, 0.51111], + "8969": [0.25, 0.75, 0, 0, 0.51111], + "8970": [0.25, 0.75, 0, 0, 0.51111], + "8971": [0.25, 0.75, 0, 0, 0.51111], + "8994": [-0.13889, 0.36111, 0, 0, 1.14999], + "8995": [-0.13889, 0.36111, 0, 0, 1.14999], + "9651": [0.19444, 0.69444, 0, 0, 1.02222], + "9657": [-0.02778, 0.47222, 0, 0, 0.575], + "9661": [0.19444, 0.69444, 0, 0, 1.02222], + "9667": [-0.02778, 0.47222, 0, 0, 0.575], + "9711": [0.19444, 0.69444, 0, 0, 1.14999], + "9824": [0.12963, 0.69444, 0, 0, 0.89444], + "9825": [0.12963, 0.69444, 0, 0, 0.89444], + "9826": [0.12963, 0.69444, 0, 0, 0.89444], + "9827": [0.12963, 0.69444, 0, 0, 0.89444], + "9837": [0, 0.75, 0, 0, 0.44722], + "9838": [0.19444, 0.69444, 0, 0, 0.44722], + "9839": [0.19444, 0.69444, 0, 0, 0.44722], + "10216": [0.25, 0.75, 0, 0, 0.44722], + "10217": [0.25, 0.75, 0, 0, 0.44722], + "10815": [0, 0.68611, 0, 0, 0.9], + "10927": [0.19667, 0.69667, 0, 0, 0.89444], + "10928": [0.19667, 0.69667, 0, 0, 0.89444], + "57376": [0.19444, 0.69444, 0, 0, 0] + }, + "Main-BoldItalic": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0.11417, 0, 0.38611], + "34": [0, 0.69444, 0.07939, 0, 0.62055], + "35": [0.19444, 0.69444, 0.06833, 0, 0.94444], + "37": [0.05556, 0.75, 0.12861, 0, 0.94444], + "38": [0, 0.69444, 0.08528, 0, 0.88555], + "39": [0, 0.69444, 0.12945, 0, 0.35555], + "40": [0.25, 0.75, 0.15806, 0, 0.47333], + "41": [0.25, 0.75, 0.03306, 0, 0.47333], + "42": [0, 0.75, 0.14333, 0, 0.59111], + "43": [0.10333, 0.60333, 0.03306, 0, 0.88555], + "44": [0.19444, 0.14722, 0, 0, 0.35555], + "45": [0, 0.44444, 0.02611, 0, 0.41444], + "46": [0, 0.14722, 0, 0, 0.35555], + "47": [0.25, 0.75, 0.15806, 0, 0.59111], + "48": [0, 0.64444, 0.13167, 0, 0.59111], + "49": [0, 0.64444, 0.13167, 0, 0.59111], + "50": [0, 0.64444, 0.13167, 0, 0.59111], + "51": [0, 0.64444, 0.13167, 0, 0.59111], + "52": [0.19444, 0.64444, 0.13167, 0, 0.59111], + "53": [0, 0.64444, 0.13167, 0, 0.59111], + "54": [0, 0.64444, 0.13167, 0, 0.59111], + "55": [0.19444, 0.64444, 0.13167, 0, 0.59111], + "56": [0, 0.64444, 0.13167, 0, 0.59111], + "57": [0, 0.64444, 0.13167, 0, 0.59111], + "58": [0, 0.44444, 0.06695, 0, 0.35555], + "59": [0.19444, 0.44444, 0.06695, 0, 0.35555], + "61": [-0.10889, 0.39111, 0.06833, 0, 0.88555], + "63": [0, 0.69444, 0.11472, 0, 0.59111], + "64": [0, 0.69444, 0.09208, 0, 0.88555], + "65": [0, 0.68611, 0, 0, 0.86555], + "66": [0, 0.68611, 0.0992, 0, 0.81666], + "67": [0, 0.68611, 0.14208, 0, 0.82666], + "68": [0, 0.68611, 0.09062, 0, 0.87555], + "69": [0, 0.68611, 0.11431, 0, 0.75666], + "70": [0, 0.68611, 0.12903, 0, 0.72722], + "71": [0, 0.68611, 0.07347, 0, 0.89527], + "72": [0, 0.68611, 0.17208, 0, 0.8961], + "73": [0, 0.68611, 0.15681, 0, 0.47166], + "74": [0, 0.68611, 0.145, 0, 0.61055], + "75": [0, 0.68611, 0.14208, 0, 0.89499], + "76": [0, 0.68611, 0, 0, 0.69777], + "77": [0, 0.68611, 0.17208, 0, 1.07277], + "78": [0, 0.68611, 0.17208, 0, 0.8961], + "79": [0, 0.68611, 0.09062, 0, 0.85499], + "80": [0, 0.68611, 0.0992, 0, 0.78721], + "81": [0.19444, 0.68611, 0.09062, 0, 0.85499], + "82": [0, 0.68611, 0.02559, 0, 0.85944], + "83": [0, 0.68611, 0.11264, 0, 0.64999], + "84": [0, 0.68611, 0.12903, 0, 0.7961], + "85": [0, 0.68611, 0.17208, 0, 0.88083], + "86": [0, 0.68611, 0.18625, 0, 0.86555], + "87": [0, 0.68611, 0.18625, 0, 1.15999], + "88": [0, 0.68611, 0.15681, 0, 0.86555], + "89": [0, 0.68611, 0.19803, 0, 0.86555], + "90": [0, 0.68611, 0.14208, 0, 0.70888], + "91": [0.25, 0.75, 0.1875, 0, 0.35611], + "93": [0.25, 0.75, 0.09972, 0, 0.35611], + "94": [0, 0.69444, 0.06709, 0, 0.59111], + "95": [0.31, 0.13444, 0.09811, 0, 0.59111], + "97": [0, 0.44444, 0.09426, 0, 0.59111], + "98": [0, 0.69444, 0.07861, 0, 0.53222], + "99": [0, 0.44444, 0.05222, 0, 0.53222], + "100": [0, 0.69444, 0.10861, 0, 0.59111], + "101": [0, 0.44444, 0.085, 0, 0.53222], + "102": [0.19444, 0.69444, 0.21778, 0, 0.4], + "103": [0.19444, 0.44444, 0.105, 0, 0.53222], + "104": [0, 0.69444, 0.09426, 0, 0.59111], + "105": [0, 0.69326, 0.11387, 0, 0.35555], + "106": [0.19444, 0.69326, 0.1672, 0, 0.35555], + "107": [0, 0.69444, 0.11111, 0, 0.53222], + "108": [0, 0.69444, 0.10861, 0, 0.29666], + "109": [0, 0.44444, 0.09426, 0, 0.94444], + "110": [0, 0.44444, 0.09426, 0, 0.64999], + "111": [0, 0.44444, 0.07861, 0, 0.59111], + "112": [0.19444, 0.44444, 0.07861, 0, 0.59111], + "113": [0.19444, 0.44444, 0.105, 0, 0.53222], + "114": [0, 0.44444, 0.11111, 0, 0.50167], + "115": [0, 0.44444, 0.08167, 0, 0.48694], + "116": [0, 0.63492, 0.09639, 0, 0.385], + "117": [0, 0.44444, 0.09426, 0, 0.62055], + "118": [0, 0.44444, 0.11111, 0, 0.53222], + "119": [0, 0.44444, 0.11111, 0, 0.76777], + "120": [0, 0.44444, 0.12583, 0, 0.56055], + "121": [0.19444, 0.44444, 0.105, 0, 0.56166], + "122": [0, 0.44444, 0.13889, 0, 0.49055], + "126": [0.35, 0.34444, 0.11472, 0, 0.59111], + "160": [0, 0, 0, 0, 0.25], + "168": [0, 0.69444, 0.11473, 0, 0.59111], + "176": [0, 0.69444, 0, 0, 0.94888], + "184": [0.17014, 0, 0, 0, 0.53222], + "198": [0, 0.68611, 0.11431, 0, 1.02277], + "216": [0.04861, 0.73472, 0.09062, 0, 0.88555], + "223": [0.19444, 0.69444, 0.09736, 0, 0.665], + "230": [0, 0.44444, 0.085, 0, 0.82666], + "248": [0.09722, 0.54167, 0.09458, 0, 0.59111], + "305": [0, 0.44444, 0.09426, 0, 0.35555], + "338": [0, 0.68611, 0.11431, 0, 1.14054], + "339": [0, 0.44444, 0.085, 0, 0.82666], + "567": [0.19444, 0.44444, 0.04611, 0, 0.385], + "710": [0, 0.69444, 0.06709, 0, 0.59111], + "711": [0, 0.63194, 0.08271, 0, 0.59111], + "713": [0, 0.59444, 0.10444, 0, 0.59111], + "714": [0, 0.69444, 0.08528, 0, 0.59111], + "715": [0, 0.69444, 0, 0, 0.59111], + "728": [0, 0.69444, 0.10333, 0, 0.59111], + "729": [0, 0.69444, 0.12945, 0, 0.35555], + "730": [0, 0.69444, 0, 0, 0.94888], + "732": [0, 0.69444, 0.11472, 0, 0.59111], + "733": [0, 0.69444, 0.11472, 0, 0.59111], + "915": [0, 0.68611, 0.12903, 0, 0.69777], + "916": [0, 0.68611, 0, 0, 0.94444], + "920": [0, 0.68611, 0.09062, 0, 0.88555], + "923": [0, 0.68611, 0, 0, 0.80666], + "926": [0, 0.68611, 0.15092, 0, 0.76777], + "928": [0, 0.68611, 0.17208, 0, 0.8961], + "931": [0, 0.68611, 0.11431, 0, 0.82666], + "933": [0, 0.68611, 0.10778, 0, 0.88555], + "934": [0, 0.68611, 0.05632, 0, 0.82666], + "936": [0, 0.68611, 0.10778, 0, 0.88555], + "937": [0, 0.68611, 0.0992, 0, 0.82666], + "8211": [0, 0.44444, 0.09811, 0, 0.59111], + "8212": [0, 0.44444, 0.09811, 0, 1.18221], + "8216": [0, 0.69444, 0.12945, 0, 0.35555], + "8217": [0, 0.69444, 0.12945, 0, 0.35555], + "8220": [0, 0.69444, 0.16772, 0, 0.62055], + "8221": [0, 0.69444, 0.07939, 0, 0.62055] + }, + "Main-Italic": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0.12417, 0, 0.30667], + "34": [0, 0.69444, 0.06961, 0, 0.51444], + "35": [0.19444, 0.69444, 0.06616, 0, 0.81777], + "37": [0.05556, 0.75, 0.13639, 0, 0.81777], + "38": [0, 0.69444, 0.09694, 0, 0.76666], + "39": [0, 0.69444, 0.12417, 0, 0.30667], + "40": [0.25, 0.75, 0.16194, 0, 0.40889], + "41": [0.25, 0.75, 0.03694, 0, 0.40889], + "42": [0, 0.75, 0.14917, 0, 0.51111], + "43": [0.05667, 0.56167, 0.03694, 0, 0.76666], + "44": [0.19444, 0.10556, 0, 0, 0.30667], + "45": [0, 0.43056, 0.02826, 0, 0.35778], + "46": [0, 0.10556, 0, 0, 0.30667], + "47": [0.25, 0.75, 0.16194, 0, 0.51111], + "48": [0, 0.64444, 0.13556, 0, 0.51111], + "49": [0, 0.64444, 0.13556, 0, 0.51111], + "50": [0, 0.64444, 0.13556, 0, 0.51111], + "51": [0, 0.64444, 0.13556, 0, 0.51111], + "52": [0.19444, 0.64444, 0.13556, 0, 0.51111], + "53": [0, 0.64444, 0.13556, 0, 0.51111], + "54": [0, 0.64444, 0.13556, 0, 0.51111], + "55": [0.19444, 0.64444, 0.13556, 0, 0.51111], + "56": [0, 0.64444, 0.13556, 0, 0.51111], + "57": [0, 0.64444, 0.13556, 0, 0.51111], + "58": [0, 0.43056, 0.0582, 0, 0.30667], + "59": [0.19444, 0.43056, 0.0582, 0, 0.30667], + "61": [-0.13313, 0.36687, 0.06616, 0, 0.76666], + "63": [0, 0.69444, 0.1225, 0, 0.51111], + "64": [0, 0.69444, 0.09597, 0, 0.76666], + "65": [0, 0.68333, 0, 0, 0.74333], + "66": [0, 0.68333, 0.10257, 0, 0.70389], + "67": [0, 0.68333, 0.14528, 0, 0.71555], + "68": [0, 0.68333, 0.09403, 0, 0.755], + "69": [0, 0.68333, 0.12028, 0, 0.67833], + "70": [0, 0.68333, 0.13305, 0, 0.65277], + "71": [0, 0.68333, 0.08722, 0, 0.77361], + "72": [0, 0.68333, 0.16389, 0, 0.74333], + "73": [0, 0.68333, 0.15806, 0, 0.38555], + "74": [0, 0.68333, 0.14028, 0, 0.525], + "75": [0, 0.68333, 0.14528, 0, 0.76888], + "76": [0, 0.68333, 0, 0, 0.62722], + "77": [0, 0.68333, 0.16389, 0, 0.89666], + "78": [0, 0.68333, 0.16389, 0, 0.74333], + "79": [0, 0.68333, 0.09403, 0, 0.76666], + "80": [0, 0.68333, 0.10257, 0, 0.67833], + "81": [0.19444, 0.68333, 0.09403, 0, 0.76666], + "82": [0, 0.68333, 0.03868, 0, 0.72944], + "83": [0, 0.68333, 0.11972, 0, 0.56222], + "84": [0, 0.68333, 0.13305, 0, 0.71555], + "85": [0, 0.68333, 0.16389, 0, 0.74333], + "86": [0, 0.68333, 0.18361, 0, 0.74333], + "87": [0, 0.68333, 0.18361, 0, 0.99888], + "88": [0, 0.68333, 0.15806, 0, 0.74333], + "89": [0, 0.68333, 0.19383, 0, 0.74333], + "90": [0, 0.68333, 0.14528, 0, 0.61333], + "91": [0.25, 0.75, 0.1875, 0, 0.30667], + "93": [0.25, 0.75, 0.10528, 0, 0.30667], + "94": [0, 0.69444, 0.06646, 0, 0.51111], + "95": [0.31, 0.12056, 0.09208, 0, 0.51111], + "97": [0, 0.43056, 0.07671, 0, 0.51111], + "98": [0, 0.69444, 0.06312, 0, 0.46], + "99": [0, 0.43056, 0.05653, 0, 0.46], + "100": [0, 0.69444, 0.10333, 0, 0.51111], + "101": [0, 0.43056, 0.07514, 0, 0.46], + "102": [0.19444, 0.69444, 0.21194, 0, 0.30667], + "103": [0.19444, 0.43056, 0.08847, 0, 0.46], + "104": [0, 0.69444, 0.07671, 0, 0.51111], + "105": [0, 0.65536, 0.1019, 0, 0.30667], + "106": [0.19444, 0.65536, 0.14467, 0, 0.30667], + "107": [0, 0.69444, 0.10764, 0, 0.46], + "108": [0, 0.69444, 0.10333, 0, 0.25555], + "109": [0, 0.43056, 0.07671, 0, 0.81777], + "110": [0, 0.43056, 0.07671, 0, 0.56222], + "111": [0, 0.43056, 0.06312, 0, 0.51111], + "112": [0.19444, 0.43056, 0.06312, 0, 0.51111], + "113": [0.19444, 0.43056, 0.08847, 0, 0.46], + "114": [0, 0.43056, 0.10764, 0, 0.42166], + "115": [0, 0.43056, 0.08208, 0, 0.40889], + "116": [0, 0.61508, 0.09486, 0, 0.33222], + "117": [0, 0.43056, 0.07671, 0, 0.53666], + "118": [0, 0.43056, 0.10764, 0, 0.46], + "119": [0, 0.43056, 0.10764, 0, 0.66444], + "120": [0, 0.43056, 0.12042, 0, 0.46389], + "121": [0.19444, 0.43056, 0.08847, 0, 0.48555], + "122": [0, 0.43056, 0.12292, 0, 0.40889], + "126": [0.35, 0.31786, 0.11585, 0, 0.51111], + "160": [0, 0, 0, 0, 0.25], + "168": [0, 0.66786, 0.10474, 0, 0.51111], + "176": [0, 0.69444, 0, 0, 0.83129], + "184": [0.17014, 0, 0, 0, 0.46], + "198": [0, 0.68333, 0.12028, 0, 0.88277], + "216": [0.04861, 0.73194, 0.09403, 0, 0.76666], + "223": [0.19444, 0.69444, 0.10514, 0, 0.53666], + "230": [0, 0.43056, 0.07514, 0, 0.71555], + "248": [0.09722, 0.52778, 0.09194, 0, 0.51111], + "338": [0, 0.68333, 0.12028, 0, 0.98499], + "339": [0, 0.43056, 0.07514, 0, 0.71555], + "710": [0, 0.69444, 0.06646, 0, 0.51111], + "711": [0, 0.62847, 0.08295, 0, 0.51111], + "713": [0, 0.56167, 0.10333, 0, 0.51111], + "714": [0, 0.69444, 0.09694, 0, 0.51111], + "715": [0, 0.69444, 0, 0, 0.51111], + "728": [0, 0.69444, 0.10806, 0, 0.51111], + "729": [0, 0.66786, 0.11752, 0, 0.30667], + "730": [0, 0.69444, 0, 0, 0.83129], + "732": [0, 0.66786, 0.11585, 0, 0.51111], + "733": [0, 0.69444, 0.1225, 0, 0.51111], + "915": [0, 0.68333, 0.13305, 0, 0.62722], + "916": [0, 0.68333, 0, 0, 0.81777], + "920": [0, 0.68333, 0.09403, 0, 0.76666], + "923": [0, 0.68333, 0, 0, 0.69222], + "926": [0, 0.68333, 0.15294, 0, 0.66444], + "928": [0, 0.68333, 0.16389, 0, 0.74333], + "931": [0, 0.68333, 0.12028, 0, 0.71555], + "933": [0, 0.68333, 0.11111, 0, 0.76666], + "934": [0, 0.68333, 0.05986, 0, 0.71555], + "936": [0, 0.68333, 0.11111, 0, 0.76666], + "937": [0, 0.68333, 0.10257, 0, 0.71555], + "8211": [0, 0.43056, 0.09208, 0, 0.51111], + "8212": [0, 0.43056, 0.09208, 0, 1.02222], + "8216": [0, 0.69444, 0.12417, 0, 0.30667], + "8217": [0, 0.69444, 0.12417, 0, 0.30667], + "8220": [0, 0.69444, 0.1685, 0, 0.51444], + "8221": [0, 0.69444, 0.06961, 0, 0.51444], + "8463": [0, 0.68889, 0, 0, 0.54028] + }, + "Main-Regular": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0, 0, 0.27778], + "34": [0, 0.69444, 0, 0, 0.5], + "35": [0.19444, 0.69444, 0, 0, 0.83334], + "36": [0.05556, 0.75, 0, 0, 0.5], + "37": [0.05556, 0.75, 0, 0, 0.83334], + "38": [0, 0.69444, 0, 0, 0.77778], + "39": [0, 0.69444, 0, 0, 0.27778], + "40": [0.25, 0.75, 0, 0, 0.38889], + "41": [0.25, 0.75, 0, 0, 0.38889], + "42": [0, 0.75, 0, 0, 0.5], + "43": [0.08333, 0.58333, 0, 0, 0.77778], + "44": [0.19444, 0.10556, 0, 0, 0.27778], + "45": [0, 0.43056, 0, 0, 0.33333], + "46": [0, 0.10556, 0, 0, 0.27778], + "47": [0.25, 0.75, 0, 0, 0.5], + "48": [0, 0.64444, 0, 0, 0.5], + "49": [0, 0.64444, 0, 0, 0.5], + "50": [0, 0.64444, 0, 0, 0.5], + "51": [0, 0.64444, 0, 0, 0.5], + "52": [0, 0.64444, 0, 0, 0.5], + "53": [0, 0.64444, 0, 0, 0.5], + "54": [0, 0.64444, 0, 0, 0.5], + "55": [0, 0.64444, 0, 0, 0.5], + "56": [0, 0.64444, 0, 0, 0.5], + "57": [0, 0.64444, 0, 0, 0.5], + "58": [0, 0.43056, 0, 0, 0.27778], + "59": [0.19444, 0.43056, 0, 0, 0.27778], + "60": [0.0391, 0.5391, 0, 0, 0.77778], + "61": [-0.13313, 0.36687, 0, 0, 0.77778], + "62": [0.0391, 0.5391, 0, 0, 0.77778], + "63": [0, 0.69444, 0, 0, 0.47222], + "64": [0, 0.69444, 0, 0, 0.77778], + "65": [0, 0.68333, 0, 0, 0.75], + "66": [0, 0.68333, 0, 0, 0.70834], + "67": [0, 0.68333, 0, 0, 0.72222], + "68": [0, 0.68333, 0, 0, 0.76389], + "69": [0, 0.68333, 0, 0, 0.68056], + "70": [0, 0.68333, 0, 0, 0.65278], + "71": [0, 0.68333, 0, 0, 0.78472], + "72": [0, 0.68333, 0, 0, 0.75], + "73": [0, 0.68333, 0, 0, 0.36111], + "74": [0, 0.68333, 0, 0, 0.51389], + "75": [0, 0.68333, 0, 0, 0.77778], + "76": [0, 0.68333, 0, 0, 0.625], + "77": [0, 0.68333, 0, 0, 0.91667], + "78": [0, 0.68333, 0, 0, 0.75], + "79": [0, 0.68333, 0, 0, 0.77778], + "80": [0, 0.68333, 0, 0, 0.68056], + "81": [0.19444, 0.68333, 0, 0, 0.77778], + "82": [0, 0.68333, 0, 0, 0.73611], + "83": [0, 0.68333, 0, 0, 0.55556], + "84": [0, 0.68333, 0, 0, 0.72222], + "85": [0, 0.68333, 0, 0, 0.75], + "86": [0, 0.68333, 0.01389, 0, 0.75], + "87": [0, 0.68333, 0.01389, 0, 1.02778], + "88": [0, 0.68333, 0, 0, 0.75], + "89": [0, 0.68333, 0.025, 0, 0.75], + "90": [0, 0.68333, 0, 0, 0.61111], + "91": [0.25, 0.75, 0, 0, 0.27778], + "92": [0.25, 0.75, 0, 0, 0.5], + "93": [0.25, 0.75, 0, 0, 0.27778], + "94": [0, 0.69444, 0, 0, 0.5], + "95": [0.31, 0.12056, 0.02778, 0, 0.5], + "97": [0, 0.43056, 0, 0, 0.5], + "98": [0, 0.69444, 0, 0, 0.55556], + "99": [0, 0.43056, 0, 0, 0.44445], + "100": [0, 0.69444, 0, 0, 0.55556], + "101": [0, 0.43056, 0, 0, 0.44445], + "102": [0, 0.69444, 0.07778, 0, 0.30556], + "103": [0.19444, 0.43056, 0.01389, 0, 0.5], + "104": [0, 0.69444, 0, 0, 0.55556], + "105": [0, 0.66786, 0, 0, 0.27778], + "106": [0.19444, 0.66786, 0, 0, 0.30556], + "107": [0, 0.69444, 0, 0, 0.52778], + "108": [0, 0.69444, 0, 0, 0.27778], + "109": [0, 0.43056, 0, 0, 0.83334], + "110": [0, 0.43056, 0, 0, 0.55556], + "111": [0, 0.43056, 0, 0, 0.5], + "112": [0.19444, 0.43056, 0, 0, 0.55556], + "113": [0.19444, 0.43056, 0, 0, 0.52778], + "114": [0, 0.43056, 0, 0, 0.39167], + "115": [0, 0.43056, 0, 0, 0.39445], + "116": [0, 0.61508, 0, 0, 0.38889], + "117": [0, 0.43056, 0, 0, 0.55556], + "118": [0, 0.43056, 0.01389, 0, 0.52778], + "119": [0, 0.43056, 0.01389, 0, 0.72222], + "120": [0, 0.43056, 0, 0, 0.52778], + "121": [0.19444, 0.43056, 0.01389, 0, 0.52778], + "122": [0, 0.43056, 0, 0, 0.44445], + "123": [0.25, 0.75, 0, 0, 0.5], + "124": [0.25, 0.75, 0, 0, 0.27778], + "125": [0.25, 0.75, 0, 0, 0.5], + "126": [0.35, 0.31786, 0, 0, 0.5], + "160": [0, 0, 0, 0, 0.25], + "163": [0, 0.69444, 0, 0, 0.76909], + "167": [0.19444, 0.69444, 0, 0, 0.44445], + "168": [0, 0.66786, 0, 0, 0.5], + "172": [0, 0.43056, 0, 0, 0.66667], + "176": [0, 0.69444, 0, 0, 0.75], + "177": [0.08333, 0.58333, 0, 0, 0.77778], + "182": [0.19444, 0.69444, 0, 0, 0.61111], + "184": [0.17014, 0, 0, 0, 0.44445], + "198": [0, 0.68333, 0, 0, 0.90278], + "215": [0.08333, 0.58333, 0, 0, 0.77778], + "216": [0.04861, 0.73194, 0, 0, 0.77778], + "223": [0, 0.69444, 0, 0, 0.5], + "230": [0, 0.43056, 0, 0, 0.72222], + "247": [0.08333, 0.58333, 0, 0, 0.77778], + "248": [0.09722, 0.52778, 0, 0, 0.5], + "305": [0, 0.43056, 0, 0, 0.27778], + "338": [0, 0.68333, 0, 0, 1.01389], + "339": [0, 0.43056, 0, 0, 0.77778], + "567": [0.19444, 0.43056, 0, 0, 0.30556], + "710": [0, 0.69444, 0, 0, 0.5], + "711": [0, 0.62847, 0, 0, 0.5], + "713": [0, 0.56778, 0, 0, 0.5], + "714": [0, 0.69444, 0, 0, 0.5], + "715": [0, 0.69444, 0, 0, 0.5], + "728": [0, 0.69444, 0, 0, 0.5], + "729": [0, 0.66786, 0, 0, 0.27778], + "730": [0, 0.69444, 0, 0, 0.75], + "732": [0, 0.66786, 0, 0, 0.5], + "733": [0, 0.69444, 0, 0, 0.5], + "915": [0, 0.68333, 0, 0, 0.625], + "916": [0, 0.68333, 0, 0, 0.83334], + "920": [0, 0.68333, 0, 0, 0.77778], + "923": [0, 0.68333, 0, 0, 0.69445], + "926": [0, 0.68333, 0, 0, 0.66667], + "928": [0, 0.68333, 0, 0, 0.75], + "931": [0, 0.68333, 0, 0, 0.72222], + "933": [0, 0.68333, 0, 0, 0.77778], + "934": [0, 0.68333, 0, 0, 0.72222], + "936": [0, 0.68333, 0, 0, 0.77778], + "937": [0, 0.68333, 0, 0, 0.72222], + "8211": [0, 0.43056, 0.02778, 0, 0.5], + "8212": [0, 0.43056, 0.02778, 0, 1.0], + "8216": [0, 0.69444, 0, 0, 0.27778], + "8217": [0, 0.69444, 0, 0, 0.27778], + "8220": [0, 0.69444, 0, 0, 0.5], + "8221": [0, 0.69444, 0, 0, 0.5], + "8224": [0.19444, 0.69444, 0, 0, 0.44445], + "8225": [0.19444, 0.69444, 0, 0, 0.44445], + "8230": [0, 0.123, 0, 0, 1.172], + "8242": [0, 0.55556, 0, 0, 0.275], + "8407": [0, 0.71444, 0.15382, 0, 0.5], + "8463": [0, 0.68889, 0, 0, 0.54028], + "8465": [0, 0.69444, 0, 0, 0.72222], + "8467": [0, 0.69444, 0, 0.11111, 0.41667], + "8472": [0.19444, 0.43056, 0, 0.11111, 0.63646], + "8476": [0, 0.69444, 0, 0, 0.72222], + "8501": [0, 0.69444, 0, 0, 0.61111], + "8592": [-0.13313, 0.36687, 0, 0, 1.0], + "8593": [0.19444, 0.69444, 0, 0, 0.5], + "8594": [-0.13313, 0.36687, 0, 0, 1.0], + "8595": [0.19444, 0.69444, 0, 0, 0.5], + "8596": [-0.13313, 0.36687, 0, 0, 1.0], + "8597": [0.25, 0.75, 0, 0, 0.5], + "8598": [0.19444, 0.69444, 0, 0, 1.0], + "8599": [0.19444, 0.69444, 0, 0, 1.0], + "8600": [0.19444, 0.69444, 0, 0, 1.0], + "8601": [0.19444, 0.69444, 0, 0, 1.0], + "8614": [0.011, 0.511, 0, 0, 1.0], + "8617": [0.011, 0.511, 0, 0, 1.126], + "8618": [0.011, 0.511, 0, 0, 1.126], + "8636": [-0.13313, 0.36687, 0, 0, 1.0], + "8637": [-0.13313, 0.36687, 0, 0, 1.0], + "8640": [-0.13313, 0.36687, 0, 0, 1.0], + "8641": [-0.13313, 0.36687, 0, 0, 1.0], + "8652": [0.011, 0.671, 0, 0, 1.0], + "8656": [-0.13313, 0.36687, 0, 0, 1.0], + "8657": [0.19444, 0.69444, 0, 0, 0.61111], + "8658": [-0.13313, 0.36687, 0, 0, 1.0], + "8659": [0.19444, 0.69444, 0, 0, 0.61111], + "8660": [-0.13313, 0.36687, 0, 0, 1.0], + "8661": [0.25, 0.75, 0, 0, 0.61111], + "8704": [0, 0.69444, 0, 0, 0.55556], + "8706": [0, 0.69444, 0.05556, 0.08334, 0.5309], + "8707": [0, 0.69444, 0, 0, 0.55556], + "8709": [0.05556, 0.75, 0, 0, 0.5], + "8711": [0, 0.68333, 0, 0, 0.83334], + "8712": [0.0391, 0.5391, 0, 0, 0.66667], + "8715": [0.0391, 0.5391, 0, 0, 0.66667], + "8722": [0.08333, 0.58333, 0, 0, 0.77778], + "8723": [0.08333, 0.58333, 0, 0, 0.77778], + "8725": [0.25, 0.75, 0, 0, 0.5], + "8726": [0.25, 0.75, 0, 0, 0.5], + "8727": [-0.03472, 0.46528, 0, 0, 0.5], + "8728": [-0.05555, 0.44445, 0, 0, 0.5], + "8729": [-0.05555, 0.44445, 0, 0, 0.5], + "8730": [0.2, 0.8, 0, 0, 0.83334], + "8733": [0, 0.43056, 0, 0, 0.77778], + "8734": [0, 0.43056, 0, 0, 1.0], + "8736": [0, 0.69224, 0, 0, 0.72222], + "8739": [0.25, 0.75, 0, 0, 0.27778], + "8741": [0.25, 0.75, 0, 0, 0.5], + "8743": [0, 0.55556, 0, 0, 0.66667], + "8744": [0, 0.55556, 0, 0, 0.66667], + "8745": [0, 0.55556, 0, 0, 0.66667], + "8746": [0, 0.55556, 0, 0, 0.66667], + "8747": [0.19444, 0.69444, 0.11111, 0, 0.41667], + "8764": [-0.13313, 0.36687, 0, 0, 0.77778], + "8768": [0.19444, 0.69444, 0, 0, 0.27778], + "8771": [-0.03625, 0.46375, 0, 0, 0.77778], + "8773": [-0.022, 0.589, 0, 0, 0.778], + "8776": [-0.01688, 0.48312, 0, 0, 0.77778], + "8781": [-0.03625, 0.46375, 0, 0, 0.77778], + "8784": [-0.133, 0.673, 0, 0, 0.778], + "8801": [-0.03625, 0.46375, 0, 0, 0.77778], + "8804": [0.13597, 0.63597, 0, 0, 0.77778], + "8805": [0.13597, 0.63597, 0, 0, 0.77778], + "8810": [0.0391, 0.5391, 0, 0, 1.0], + "8811": [0.0391, 0.5391, 0, 0, 1.0], + "8826": [0.0391, 0.5391, 0, 0, 0.77778], + "8827": [0.0391, 0.5391, 0, 0, 0.77778], + "8834": [0.0391, 0.5391, 0, 0, 0.77778], + "8835": [0.0391, 0.5391, 0, 0, 0.77778], + "8838": [0.13597, 0.63597, 0, 0, 0.77778], + "8839": [0.13597, 0.63597, 0, 0, 0.77778], + "8846": [0, 0.55556, 0, 0, 0.66667], + "8849": [0.13597, 0.63597, 0, 0, 0.77778], + "8850": [0.13597, 0.63597, 0, 0, 0.77778], + "8851": [0, 0.55556, 0, 0, 0.66667], + "8852": [0, 0.55556, 0, 0, 0.66667], + "8853": [0.08333, 0.58333, 0, 0, 0.77778], + "8854": [0.08333, 0.58333, 0, 0, 0.77778], + "8855": [0.08333, 0.58333, 0, 0, 0.77778], + "8856": [0.08333, 0.58333, 0, 0, 0.77778], + "8857": [0.08333, 0.58333, 0, 0, 0.77778], + "8866": [0, 0.69444, 0, 0, 0.61111], + "8867": [0, 0.69444, 0, 0, 0.61111], + "8868": [0, 0.69444, 0, 0, 0.77778], + "8869": [0, 0.69444, 0, 0, 0.77778], + "8872": [0.249, 0.75, 0, 0, 0.867], + "8900": [-0.05555, 0.44445, 0, 0, 0.5], + "8901": [-0.05555, 0.44445, 0, 0, 0.27778], + "8902": [-0.03472, 0.46528, 0, 0, 0.5], + "8904": [0.005, 0.505, 0, 0, 0.9], + "8942": [0.03, 0.903, 0, 0, 0.278], + "8943": [-0.19, 0.313, 0, 0, 1.172], + "8945": [-0.1, 0.823, 0, 0, 1.282], + "8968": [0.25, 0.75, 0, 0, 0.44445], + "8969": [0.25, 0.75, 0, 0, 0.44445], + "8970": [0.25, 0.75, 0, 0, 0.44445], + "8971": [0.25, 0.75, 0, 0, 0.44445], + "8994": [-0.14236, 0.35764, 0, 0, 1.0], + "8995": [-0.14236, 0.35764, 0, 0, 1.0], + "9136": [0.244, 0.744, 0, 0, 0.412], + "9137": [0.244, 0.745, 0, 0, 0.412], + "9651": [0.19444, 0.69444, 0, 0, 0.88889], + "9657": [-0.03472, 0.46528, 0, 0, 0.5], + "9661": [0.19444, 0.69444, 0, 0, 0.88889], + "9667": [-0.03472, 0.46528, 0, 0, 0.5], + "9711": [0.19444, 0.69444, 0, 0, 1.0], + "9824": [0.12963, 0.69444, 0, 0, 0.77778], + "9825": [0.12963, 0.69444, 0, 0, 0.77778], + "9826": [0.12963, 0.69444, 0, 0, 0.77778], + "9827": [0.12963, 0.69444, 0, 0, 0.77778], + "9837": [0, 0.75, 0, 0, 0.38889], + "9838": [0.19444, 0.69444, 0, 0, 0.38889], + "9839": [0.19444, 0.69444, 0, 0, 0.38889], + "10216": [0.25, 0.75, 0, 0, 0.38889], + "10217": [0.25, 0.75, 0, 0, 0.38889], + "10222": [0.244, 0.744, 0, 0, 0.412], + "10223": [0.244, 0.745, 0, 0, 0.412], + "10229": [0.011, 0.511, 0, 0, 1.609], + "10230": [0.011, 0.511, 0, 0, 1.638], + "10231": [0.011, 0.511, 0, 0, 1.859], + "10232": [0.024, 0.525, 0, 0, 1.609], + "10233": [0.024, 0.525, 0, 0, 1.638], + "10234": [0.024, 0.525, 0, 0, 1.858], + "10236": [0.011, 0.511, 0, 0, 1.638], + "10815": [0, 0.68333, 0, 0, 0.75], + "10927": [0.13597, 0.63597, 0, 0, 0.77778], + "10928": [0.13597, 0.63597, 0, 0, 0.77778], + "57376": [0.19444, 0.69444, 0, 0, 0] + }, + "Math-BoldItalic": { + "32": [0, 0, 0, 0, 0.25], + "48": [0, 0.44444, 0, 0, 0.575], + "49": [0, 0.44444, 0, 0, 0.575], + "50": [0, 0.44444, 0, 0, 0.575], + "51": [0.19444, 0.44444, 0, 0, 0.575], + "52": [0.19444, 0.44444, 0, 0, 0.575], + "53": [0.19444, 0.44444, 0, 0, 0.575], + "54": [0, 0.64444, 0, 0, 0.575], + "55": [0.19444, 0.44444, 0, 0, 0.575], + "56": [0, 0.64444, 0, 0, 0.575], + "57": [0.19444, 0.44444, 0, 0, 0.575], + "65": [0, 0.68611, 0, 0, 0.86944], + "66": [0, 0.68611, 0.04835, 0, 0.8664], + "67": [0, 0.68611, 0.06979, 0, 0.81694], + "68": [0, 0.68611, 0.03194, 0, 0.93812], + "69": [0, 0.68611, 0.05451, 0, 0.81007], + "70": [0, 0.68611, 0.15972, 0, 0.68889], + "71": [0, 0.68611, 0, 0, 0.88673], + "72": [0, 0.68611, 0.08229, 0, 0.98229], + "73": [0, 0.68611, 0.07778, 0, 0.51111], + "74": [0, 0.68611, 0.10069, 0, 0.63125], + "75": [0, 0.68611, 0.06979, 0, 0.97118], + "76": [0, 0.68611, 0, 0, 0.75555], + "77": [0, 0.68611, 0.11424, 0, 1.14201], + "78": [0, 0.68611, 0.11424, 0, 0.95034], + "79": [0, 0.68611, 0.03194, 0, 0.83666], + "80": [0, 0.68611, 0.15972, 0, 0.72309], + "81": [0.19444, 0.68611, 0, 0, 0.86861], + "82": [0, 0.68611, 0.00421, 0, 0.87235], + "83": [0, 0.68611, 0.05382, 0, 0.69271], + "84": [0, 0.68611, 0.15972, 0, 0.63663], + "85": [0, 0.68611, 0.11424, 0, 0.80027], + "86": [0, 0.68611, 0.25555, 0, 0.67778], + "87": [0, 0.68611, 0.15972, 0, 1.09305], + "88": [0, 0.68611, 0.07778, 0, 0.94722], + "89": [0, 0.68611, 0.25555, 0, 0.67458], + "90": [0, 0.68611, 0.06979, 0, 0.77257], + "97": [0, 0.44444, 0, 0, 0.63287], + "98": [0, 0.69444, 0, 0, 0.52083], + "99": [0, 0.44444, 0, 0, 0.51342], + "100": [0, 0.69444, 0, 0, 0.60972], + "101": [0, 0.44444, 0, 0, 0.55361], + "102": [0.19444, 0.69444, 0.11042, 0, 0.56806], + "103": [0.19444, 0.44444, 0.03704, 0, 0.5449], + "104": [0, 0.69444, 0, 0, 0.66759], + "105": [0, 0.69326, 0, 0, 0.4048], + "106": [0.19444, 0.69326, 0.0622, 0, 0.47083], + "107": [0, 0.69444, 0.01852, 0, 0.6037], + "108": [0, 0.69444, 0.0088, 0, 0.34815], + "109": [0, 0.44444, 0, 0, 1.0324], + "110": [0, 0.44444, 0, 0, 0.71296], + "111": [0, 0.44444, 0, 0, 0.58472], + "112": [0.19444, 0.44444, 0, 0, 0.60092], + "113": [0.19444, 0.44444, 0.03704, 0, 0.54213], + "114": [0, 0.44444, 0.03194, 0, 0.5287], + "115": [0, 0.44444, 0, 0, 0.53125], + "116": [0, 0.63492, 0, 0, 0.41528], + "117": [0, 0.44444, 0, 0, 0.68102], + "118": [0, 0.44444, 0.03704, 0, 0.56666], + "119": [0, 0.44444, 0.02778, 0, 0.83148], + "120": [0, 0.44444, 0, 0, 0.65903], + "121": [0.19444, 0.44444, 0.03704, 0, 0.59028], + "122": [0, 0.44444, 0.04213, 0, 0.55509], + "160": [0, 0, 0, 0, 0.25], + "915": [0, 0.68611, 0.15972, 0, 0.65694], + "916": [0, 0.68611, 0, 0, 0.95833], + "920": [0, 0.68611, 0.03194, 0, 0.86722], + "923": [0, 0.68611, 0, 0, 0.80555], + "926": [0, 0.68611, 0.07458, 0, 0.84125], + "928": [0, 0.68611, 0.08229, 0, 0.98229], + "931": [0, 0.68611, 0.05451, 0, 0.88507], + "933": [0, 0.68611, 0.15972, 0, 0.67083], + "934": [0, 0.68611, 0, 0, 0.76666], + "936": [0, 0.68611, 0.11653, 0, 0.71402], + "937": [0, 0.68611, 0.04835, 0, 0.8789], + "945": [0, 0.44444, 0, 0, 0.76064], + "946": [0.19444, 0.69444, 0.03403, 0, 0.65972], + "947": [0.19444, 0.44444, 0.06389, 0, 0.59003], + "948": [0, 0.69444, 0.03819, 0, 0.52222], + "949": [0, 0.44444, 0, 0, 0.52882], + "950": [0.19444, 0.69444, 0.06215, 0, 0.50833], + "951": [0.19444, 0.44444, 0.03704, 0, 0.6], + "952": [0, 0.69444, 0.03194, 0, 0.5618], + "953": [0, 0.44444, 0, 0, 0.41204], + "954": [0, 0.44444, 0, 0, 0.66759], + "955": [0, 0.69444, 0, 0, 0.67083], + "956": [0.19444, 0.44444, 0, 0, 0.70787], + "957": [0, 0.44444, 0.06898, 0, 0.57685], + "958": [0.19444, 0.69444, 0.03021, 0, 0.50833], + "959": [0, 0.44444, 0, 0, 0.58472], + "960": [0, 0.44444, 0.03704, 0, 0.68241], + "961": [0.19444, 0.44444, 0, 0, 0.6118], + "962": [0.09722, 0.44444, 0.07917, 0, 0.42361], + "963": [0, 0.44444, 0.03704, 0, 0.68588], + "964": [0, 0.44444, 0.13472, 0, 0.52083], + "965": [0, 0.44444, 0.03704, 0, 0.63055], + "966": [0.19444, 0.44444, 0, 0, 0.74722], + "967": [0.19444, 0.44444, 0, 0, 0.71805], + "968": [0.19444, 0.69444, 0.03704, 0, 0.75833], + "969": [0, 0.44444, 0.03704, 0, 0.71782], + "977": [0, 0.69444, 0, 0, 0.69155], + "981": [0.19444, 0.69444, 0, 0, 0.7125], + "982": [0, 0.44444, 0.03194, 0, 0.975], + "1009": [0.19444, 0.44444, 0, 0, 0.6118], + "1013": [0, 0.44444, 0, 0, 0.48333], + "57649": [0, 0.44444, 0, 0, 0.39352], + "57911": [0.19444, 0.44444, 0, 0, 0.43889] + }, + "Math-Italic": { + "32": [0, 0, 0, 0, 0.25], + "48": [0, 0.43056, 0, 0, 0.5], + "49": [0, 0.43056, 0, 0, 0.5], + "50": [0, 0.43056, 0, 0, 0.5], + "51": [0.19444, 0.43056, 0, 0, 0.5], + "52": [0.19444, 0.43056, 0, 0, 0.5], + "53": [0.19444, 0.43056, 0, 0, 0.5], + "54": [0, 0.64444, 0, 0, 0.5], + "55": [0.19444, 0.43056, 0, 0, 0.5], + "56": [0, 0.64444, 0, 0, 0.5], + "57": [0.19444, 0.43056, 0, 0, 0.5], + "65": [0, 0.68333, 0, 0.13889, 0.75], + "66": [0, 0.68333, 0.05017, 0.08334, 0.75851], + "67": [0, 0.68333, 0.07153, 0.08334, 0.71472], + "68": [0, 0.68333, 0.02778, 0.05556, 0.82792], + "69": [0, 0.68333, 0.05764, 0.08334, 0.7382], + "70": [0, 0.68333, 0.13889, 0.08334, 0.64306], + "71": [0, 0.68333, 0, 0.08334, 0.78625], + "72": [0, 0.68333, 0.08125, 0.05556, 0.83125], + "73": [0, 0.68333, 0.07847, 0.11111, 0.43958], + "74": [0, 0.68333, 0.09618, 0.16667, 0.55451], + "75": [0, 0.68333, 0.07153, 0.05556, 0.84931], + "76": [0, 0.68333, 0, 0.02778, 0.68056], + "77": [0, 0.68333, 0.10903, 0.08334, 0.97014], + "78": [0, 0.68333, 0.10903, 0.08334, 0.80347], + "79": [0, 0.68333, 0.02778, 0.08334, 0.76278], + "80": [0, 0.68333, 0.13889, 0.08334, 0.64201], + "81": [0.19444, 0.68333, 0, 0.08334, 0.79056], + "82": [0, 0.68333, 0.00773, 0.08334, 0.75929], + "83": [0, 0.68333, 0.05764, 0.08334, 0.6132], + "84": [0, 0.68333, 0.13889, 0.08334, 0.58438], + "85": [0, 0.68333, 0.10903, 0.02778, 0.68278], + "86": [0, 0.68333, 0.22222, 0, 0.58333], + "87": [0, 0.68333, 0.13889, 0, 0.94445], + "88": [0, 0.68333, 0.07847, 0.08334, 0.82847], + "89": [0, 0.68333, 0.22222, 0, 0.58056], + "90": [0, 0.68333, 0.07153, 0.08334, 0.68264], + "97": [0, 0.43056, 0, 0, 0.52859], + "98": [0, 0.69444, 0, 0, 0.42917], + "99": [0, 0.43056, 0, 0.05556, 0.43276], + "100": [0, 0.69444, 0, 0.16667, 0.52049], + "101": [0, 0.43056, 0, 0.05556, 0.46563], + "102": [0.19444, 0.69444, 0.10764, 0.16667, 0.48959], + "103": [0.19444, 0.43056, 0.03588, 0.02778, 0.47697], + "104": [0, 0.69444, 0, 0, 0.57616], + "105": [0, 0.65952, 0, 0, 0.34451], + "106": [0.19444, 0.65952, 0.05724, 0, 0.41181], + "107": [0, 0.69444, 0.03148, 0, 0.5206], + "108": [0, 0.69444, 0.01968, 0.08334, 0.29838], + "109": [0, 0.43056, 0, 0, 0.87801], + "110": [0, 0.43056, 0, 0, 0.60023], + "111": [0, 0.43056, 0, 0.05556, 0.48472], + "112": [0.19444, 0.43056, 0, 0.08334, 0.50313], + "113": [0.19444, 0.43056, 0.03588, 0.08334, 0.44641], + "114": [0, 0.43056, 0.02778, 0.05556, 0.45116], + "115": [0, 0.43056, 0, 0.05556, 0.46875], + "116": [0, 0.61508, 0, 0.08334, 0.36111], + "117": [0, 0.43056, 0, 0.02778, 0.57246], + "118": [0, 0.43056, 0.03588, 0.02778, 0.48472], + "119": [0, 0.43056, 0.02691, 0.08334, 0.71592], + "120": [0, 0.43056, 0, 0.02778, 0.57153], + "121": [0.19444, 0.43056, 0.03588, 0.05556, 0.49028], + "122": [0, 0.43056, 0.04398, 0.05556, 0.46505], + "160": [0, 0, 0, 0, 0.25], + "915": [0, 0.68333, 0.13889, 0.08334, 0.61528], + "916": [0, 0.68333, 0, 0.16667, 0.83334], + "920": [0, 0.68333, 0.02778, 0.08334, 0.76278], + "923": [0, 0.68333, 0, 0.16667, 0.69445], + "926": [0, 0.68333, 0.07569, 0.08334, 0.74236], + "928": [0, 0.68333, 0.08125, 0.05556, 0.83125], + "931": [0, 0.68333, 0.05764, 0.08334, 0.77986], + "933": [0, 0.68333, 0.13889, 0.05556, 0.58333], + "934": [0, 0.68333, 0, 0.08334, 0.66667], + "936": [0, 0.68333, 0.11, 0.05556, 0.61222], + "937": [0, 0.68333, 0.05017, 0.08334, 0.7724], + "945": [0, 0.43056, 0.0037, 0.02778, 0.6397], + "946": [0.19444, 0.69444, 0.05278, 0.08334, 0.56563], + "947": [0.19444, 0.43056, 0.05556, 0, 0.51773], + "948": [0, 0.69444, 0.03785, 0.05556, 0.44444], + "949": [0, 0.43056, 0, 0.08334, 0.46632], + "950": [0.19444, 0.69444, 0.07378, 0.08334, 0.4375], + "951": [0.19444, 0.43056, 0.03588, 0.05556, 0.49653], + "952": [0, 0.69444, 0.02778, 0.08334, 0.46944], + "953": [0, 0.43056, 0, 0.05556, 0.35394], + "954": [0, 0.43056, 0, 0, 0.57616], + "955": [0, 0.69444, 0, 0, 0.58334], + "956": [0.19444, 0.43056, 0, 0.02778, 0.60255], + "957": [0, 0.43056, 0.06366, 0.02778, 0.49398], + "958": [0.19444, 0.69444, 0.04601, 0.11111, 0.4375], + "959": [0, 0.43056, 0, 0.05556, 0.48472], + "960": [0, 0.43056, 0.03588, 0, 0.57003], + "961": [0.19444, 0.43056, 0, 0.08334, 0.51702], + "962": [0.09722, 0.43056, 0.07986, 0.08334, 0.36285], + "963": [0, 0.43056, 0.03588, 0, 0.57141], + "964": [0, 0.43056, 0.1132, 0.02778, 0.43715], + "965": [0, 0.43056, 0.03588, 0.02778, 0.54028], + "966": [0.19444, 0.43056, 0, 0.08334, 0.65417], + "967": [0.19444, 0.43056, 0, 0.05556, 0.62569], + "968": [0.19444, 0.69444, 0.03588, 0.11111, 0.65139], + "969": [0, 0.43056, 0.03588, 0, 0.62245], + "977": [0, 0.69444, 0, 0.08334, 0.59144], + "981": [0.19444, 0.69444, 0, 0.08334, 0.59583], + "982": [0, 0.43056, 0.02778, 0, 0.82813], + "1009": [0.19444, 0.43056, 0, 0.08334, 0.51702], + "1013": [0, 0.43056, 0, 0.05556, 0.4059], + "57649": [0, 0.43056, 0, 0.02778, 0.32246], + "57911": [0.19444, 0.43056, 0, 0.08334, 0.38403] + }, + "SansSerif-Bold": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0, 0, 0.36667], + "34": [0, 0.69444, 0, 0, 0.55834], + "35": [0.19444, 0.69444, 0, 0, 0.91667], + "36": [0.05556, 0.75, 0, 0, 0.55], + "37": [0.05556, 0.75, 0, 0, 1.02912], + "38": [0, 0.69444, 0, 0, 0.83056], + "39": [0, 0.69444, 0, 0, 0.30556], + "40": [0.25, 0.75, 0, 0, 0.42778], + "41": [0.25, 0.75, 0, 0, 0.42778], + "42": [0, 0.75, 0, 0, 0.55], + "43": [0.11667, 0.61667, 0, 0, 0.85556], + "44": [0.10556, 0.13056, 0, 0, 0.30556], + "45": [0, 0.45833, 0, 0, 0.36667], + "46": [0, 0.13056, 0, 0, 0.30556], + "47": [0.25, 0.75, 0, 0, 0.55], + "48": [0, 0.69444, 0, 0, 0.55], + "49": [0, 0.69444, 0, 0, 0.55], + "50": [0, 0.69444, 0, 0, 0.55], + "51": [0, 0.69444, 0, 0, 0.55], + "52": [0, 0.69444, 0, 0, 0.55], + "53": [0, 0.69444, 0, 0, 0.55], + "54": [0, 0.69444, 0, 0, 0.55], + "55": [0, 0.69444, 0, 0, 0.55], + "56": [0, 0.69444, 0, 0, 0.55], + "57": [0, 0.69444, 0, 0, 0.55], + "58": [0, 0.45833, 0, 0, 0.30556], + "59": [0.10556, 0.45833, 0, 0, 0.30556], + "61": [-0.09375, 0.40625, 0, 0, 0.85556], + "63": [0, 0.69444, 0, 0, 0.51945], + "64": [0, 0.69444, 0, 0, 0.73334], + "65": [0, 0.69444, 0, 0, 0.73334], + "66": [0, 0.69444, 0, 0, 0.73334], + "67": [0, 0.69444, 0, 0, 0.70278], + "68": [0, 0.69444, 0, 0, 0.79445], + "69": [0, 0.69444, 0, 0, 0.64167], + "70": [0, 0.69444, 0, 0, 0.61111], + "71": [0, 0.69444, 0, 0, 0.73334], + "72": [0, 0.69444, 0, 0, 0.79445], + "73": [0, 0.69444, 0, 0, 0.33056], + "74": [0, 0.69444, 0, 0, 0.51945], + "75": [0, 0.69444, 0, 0, 0.76389], + "76": [0, 0.69444, 0, 0, 0.58056], + "77": [0, 0.69444, 0, 0, 0.97778], + "78": [0, 0.69444, 0, 0, 0.79445], + "79": [0, 0.69444, 0, 0, 0.79445], + "80": [0, 0.69444, 0, 0, 0.70278], + "81": [0.10556, 0.69444, 0, 0, 0.79445], + "82": [0, 0.69444, 0, 0, 0.70278], + "83": [0, 0.69444, 0, 0, 0.61111], + "84": [0, 0.69444, 0, 0, 0.73334], + "85": [0, 0.69444, 0, 0, 0.76389], + "86": [0, 0.69444, 0.01528, 0, 0.73334], + "87": [0, 0.69444, 0.01528, 0, 1.03889], + "88": [0, 0.69444, 0, 0, 0.73334], + "89": [0, 0.69444, 0.0275, 0, 0.73334], + "90": [0, 0.69444, 0, 0, 0.67223], + "91": [0.25, 0.75, 0, 0, 0.34306], + "93": [0.25, 0.75, 0, 0, 0.34306], + "94": [0, 0.69444, 0, 0, 0.55], + "95": [0.35, 0.10833, 0.03056, 0, 0.55], + "97": [0, 0.45833, 0, 0, 0.525], + "98": [0, 0.69444, 0, 0, 0.56111], + "99": [0, 0.45833, 0, 0, 0.48889], + "100": [0, 0.69444, 0, 0, 0.56111], + "101": [0, 0.45833, 0, 0, 0.51111], + "102": [0, 0.69444, 0.07639, 0, 0.33611], + "103": [0.19444, 0.45833, 0.01528, 0, 0.55], + "104": [0, 0.69444, 0, 0, 0.56111], + "105": [0, 0.69444, 0, 0, 0.25556], + "106": [0.19444, 0.69444, 0, 0, 0.28611], + "107": [0, 0.69444, 0, 0, 0.53056], + "108": [0, 0.69444, 0, 0, 0.25556], + "109": [0, 0.45833, 0, 0, 0.86667], + "110": [0, 0.45833, 0, 0, 0.56111], + "111": [0, 0.45833, 0, 0, 0.55], + "112": [0.19444, 0.45833, 0, 0, 0.56111], + "113": [0.19444, 0.45833, 0, 0, 0.56111], + "114": [0, 0.45833, 0.01528, 0, 0.37222], + "115": [0, 0.45833, 0, 0, 0.42167], + "116": [0, 0.58929, 0, 0, 0.40417], + "117": [0, 0.45833, 0, 0, 0.56111], + "118": [0, 0.45833, 0.01528, 0, 0.5], + "119": [0, 0.45833, 0.01528, 0, 0.74445], + "120": [0, 0.45833, 0, 0, 0.5], + "121": [0.19444, 0.45833, 0.01528, 0, 0.5], + "122": [0, 0.45833, 0, 0, 0.47639], + "126": [0.35, 0.34444, 0, 0, 0.55], + "160": [0, 0, 0, 0, 0.25], + "168": [0, 0.69444, 0, 0, 0.55], + "176": [0, 0.69444, 0, 0, 0.73334], + "180": [0, 0.69444, 0, 0, 0.55], + "184": [0.17014, 0, 0, 0, 0.48889], + "305": [0, 0.45833, 0, 0, 0.25556], + "567": [0.19444, 0.45833, 0, 0, 0.28611], + "710": [0, 0.69444, 0, 0, 0.55], + "711": [0, 0.63542, 0, 0, 0.55], + "713": [0, 0.63778, 0, 0, 0.55], + "728": [0, 0.69444, 0, 0, 0.55], + "729": [0, 0.69444, 0, 0, 0.30556], + "730": [0, 0.69444, 0, 0, 0.73334], + "732": [0, 0.69444, 0, 0, 0.55], + "733": [0, 0.69444, 0, 0, 0.55], + "915": [0, 0.69444, 0, 0, 0.58056], + "916": [0, 0.69444, 0, 0, 0.91667], + "920": [0, 0.69444, 0, 0, 0.85556], + "923": [0, 0.69444, 0, 0, 0.67223], + "926": [0, 0.69444, 0, 0, 0.73334], + "928": [0, 0.69444, 0, 0, 0.79445], + "931": [0, 0.69444, 0, 0, 0.79445], + "933": [0, 0.69444, 0, 0, 0.85556], + "934": [0, 0.69444, 0, 0, 0.79445], + "936": [0, 0.69444, 0, 0, 0.85556], + "937": [0, 0.69444, 0, 0, 0.79445], + "8211": [0, 0.45833, 0.03056, 0, 0.55], + "8212": [0, 0.45833, 0.03056, 0, 1.10001], + "8216": [0, 0.69444, 0, 0, 0.30556], + "8217": [0, 0.69444, 0, 0, 0.30556], + "8220": [0, 0.69444, 0, 0, 0.55834], + "8221": [0, 0.69444, 0, 0, 0.55834] + }, + "SansSerif-Italic": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0.05733, 0, 0.31945], + "34": [0, 0.69444, 0.00316, 0, 0.5], + "35": [0.19444, 0.69444, 0.05087, 0, 0.83334], + "36": [0.05556, 0.75, 0.11156, 0, 0.5], + "37": [0.05556, 0.75, 0.03126, 0, 0.83334], + "38": [0, 0.69444, 0.03058, 0, 0.75834], + "39": [0, 0.69444, 0.07816, 0, 0.27778], + "40": [0.25, 0.75, 0.13164, 0, 0.38889], + "41": [0.25, 0.75, 0.02536, 0, 0.38889], + "42": [0, 0.75, 0.11775, 0, 0.5], + "43": [0.08333, 0.58333, 0.02536, 0, 0.77778], + "44": [0.125, 0.08333, 0, 0, 0.27778], + "45": [0, 0.44444, 0.01946, 0, 0.33333], + "46": [0, 0.08333, 0, 0, 0.27778], + "47": [0.25, 0.75, 0.13164, 0, 0.5], + "48": [0, 0.65556, 0.11156, 0, 0.5], + "49": [0, 0.65556, 0.11156, 0, 0.5], + "50": [0, 0.65556, 0.11156, 0, 0.5], + "51": [0, 0.65556, 0.11156, 0, 0.5], + "52": [0, 0.65556, 0.11156, 0, 0.5], + "53": [0, 0.65556, 0.11156, 0, 0.5], + "54": [0, 0.65556, 0.11156, 0, 0.5], + "55": [0, 0.65556, 0.11156, 0, 0.5], + "56": [0, 0.65556, 0.11156, 0, 0.5], + "57": [0, 0.65556, 0.11156, 0, 0.5], + "58": [0, 0.44444, 0.02502, 0, 0.27778], + "59": [0.125, 0.44444, 0.02502, 0, 0.27778], + "61": [-0.13, 0.37, 0.05087, 0, 0.77778], + "63": [0, 0.69444, 0.11809, 0, 0.47222], + "64": [0, 0.69444, 0.07555, 0, 0.66667], + "65": [0, 0.69444, 0, 0, 0.66667], + "66": [0, 0.69444, 0.08293, 0, 0.66667], + "67": [0, 0.69444, 0.11983, 0, 0.63889], + "68": [0, 0.69444, 0.07555, 0, 0.72223], + "69": [0, 0.69444, 0.11983, 0, 0.59722], + "70": [0, 0.69444, 0.13372, 0, 0.56945], + "71": [0, 0.69444, 0.11983, 0, 0.66667], + "72": [0, 0.69444, 0.08094, 0, 0.70834], + "73": [0, 0.69444, 0.13372, 0, 0.27778], + "74": [0, 0.69444, 0.08094, 0, 0.47222], + "75": [0, 0.69444, 0.11983, 0, 0.69445], + "76": [0, 0.69444, 0, 0, 0.54167], + "77": [0, 0.69444, 0.08094, 0, 0.875], + "78": [0, 0.69444, 0.08094, 0, 0.70834], + "79": [0, 0.69444, 0.07555, 0, 0.73611], + "80": [0, 0.69444, 0.08293, 0, 0.63889], + "81": [0.125, 0.69444, 0.07555, 0, 0.73611], + "82": [0, 0.69444, 0.08293, 0, 0.64584], + "83": [0, 0.69444, 0.09205, 0, 0.55556], + "84": [0, 0.69444, 0.13372, 0, 0.68056], + "85": [0, 0.69444, 0.08094, 0, 0.6875], + "86": [0, 0.69444, 0.1615, 0, 0.66667], + "87": [0, 0.69444, 0.1615, 0, 0.94445], + "88": [0, 0.69444, 0.13372, 0, 0.66667], + "89": [0, 0.69444, 0.17261, 0, 0.66667], + "90": [0, 0.69444, 0.11983, 0, 0.61111], + "91": [0.25, 0.75, 0.15942, 0, 0.28889], + "93": [0.25, 0.75, 0.08719, 0, 0.28889], + "94": [0, 0.69444, 0.0799, 0, 0.5], + "95": [0.35, 0.09444, 0.08616, 0, 0.5], + "97": [0, 0.44444, 0.00981, 0, 0.48056], + "98": [0, 0.69444, 0.03057, 0, 0.51667], + "99": [0, 0.44444, 0.08336, 0, 0.44445], + "100": [0, 0.69444, 0.09483, 0, 0.51667], + "101": [0, 0.44444, 0.06778, 0, 0.44445], + "102": [0, 0.69444, 0.21705, 0, 0.30556], + "103": [0.19444, 0.44444, 0.10836, 0, 0.5], + "104": [0, 0.69444, 0.01778, 0, 0.51667], + "105": [0, 0.67937, 0.09718, 0, 0.23889], + "106": [0.19444, 0.67937, 0.09162, 0, 0.26667], + "107": [0, 0.69444, 0.08336, 0, 0.48889], + "108": [0, 0.69444, 0.09483, 0, 0.23889], + "109": [0, 0.44444, 0.01778, 0, 0.79445], + "110": [0, 0.44444, 0.01778, 0, 0.51667], + "111": [0, 0.44444, 0.06613, 0, 0.5], + "112": [0.19444, 0.44444, 0.0389, 0, 0.51667], + "113": [0.19444, 0.44444, 0.04169, 0, 0.51667], + "114": [0, 0.44444, 0.10836, 0, 0.34167], + "115": [0, 0.44444, 0.0778, 0, 0.38333], + "116": [0, 0.57143, 0.07225, 0, 0.36111], + "117": [0, 0.44444, 0.04169, 0, 0.51667], + "118": [0, 0.44444, 0.10836, 0, 0.46111], + "119": [0, 0.44444, 0.10836, 0, 0.68334], + "120": [0, 0.44444, 0.09169, 0, 0.46111], + "121": [0.19444, 0.44444, 0.10836, 0, 0.46111], + "122": [0, 0.44444, 0.08752, 0, 0.43472], + "126": [0.35, 0.32659, 0.08826, 0, 0.5], + "160": [0, 0, 0, 0, 0.25], + "168": [0, 0.67937, 0.06385, 0, 0.5], + "176": [0, 0.69444, 0, 0, 0.73752], + "184": [0.17014, 0, 0, 0, 0.44445], + "305": [0, 0.44444, 0.04169, 0, 0.23889], + "567": [0.19444, 0.44444, 0.04169, 0, 0.26667], + "710": [0, 0.69444, 0.0799, 0, 0.5], + "711": [0, 0.63194, 0.08432, 0, 0.5], + "713": [0, 0.60889, 0.08776, 0, 0.5], + "714": [0, 0.69444, 0.09205, 0, 0.5], + "715": [0, 0.69444, 0, 0, 0.5], + "728": [0, 0.69444, 0.09483, 0, 0.5], + "729": [0, 0.67937, 0.07774, 0, 0.27778], + "730": [0, 0.69444, 0, 0, 0.73752], + "732": [0, 0.67659, 0.08826, 0, 0.5], + "733": [0, 0.69444, 0.09205, 0, 0.5], + "915": [0, 0.69444, 0.13372, 0, 0.54167], + "916": [0, 0.69444, 0, 0, 0.83334], + "920": [0, 0.69444, 0.07555, 0, 0.77778], + "923": [0, 0.69444, 0, 0, 0.61111], + "926": [0, 0.69444, 0.12816, 0, 0.66667], + "928": [0, 0.69444, 0.08094, 0, 0.70834], + "931": [0, 0.69444, 0.11983, 0, 0.72222], + "933": [0, 0.69444, 0.09031, 0, 0.77778], + "934": [0, 0.69444, 0.04603, 0, 0.72222], + "936": [0, 0.69444, 0.09031, 0, 0.77778], + "937": [0, 0.69444, 0.08293, 0, 0.72222], + "8211": [0, 0.44444, 0.08616, 0, 0.5], + "8212": [0, 0.44444, 0.08616, 0, 1.0], + "8216": [0, 0.69444, 0.07816, 0, 0.27778], + "8217": [0, 0.69444, 0.07816, 0, 0.27778], + "8220": [0, 0.69444, 0.14205, 0, 0.5], + "8221": [0, 0.69444, 0.00316, 0, 0.5] + }, + "SansSerif-Regular": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0, 0, 0.31945], + "34": [0, 0.69444, 0, 0, 0.5], + "35": [0.19444, 0.69444, 0, 0, 0.83334], + "36": [0.05556, 0.75, 0, 0, 0.5], + "37": [0.05556, 0.75, 0, 0, 0.83334], + "38": [0, 0.69444, 0, 0, 0.75834], + "39": [0, 0.69444, 0, 0, 0.27778], + "40": [0.25, 0.75, 0, 0, 0.38889], + "41": [0.25, 0.75, 0, 0, 0.38889], + "42": [0, 0.75, 0, 0, 0.5], + "43": [0.08333, 0.58333, 0, 0, 0.77778], + "44": [0.125, 0.08333, 0, 0, 0.27778], + "45": [0, 0.44444, 0, 0, 0.33333], + "46": [0, 0.08333, 0, 0, 0.27778], + "47": [0.25, 0.75, 0, 0, 0.5], + "48": [0, 0.65556, 0, 0, 0.5], + "49": [0, 0.65556, 0, 0, 0.5], + "50": [0, 0.65556, 0, 0, 0.5], + "51": [0, 0.65556, 0, 0, 0.5], + "52": [0, 0.65556, 0, 0, 0.5], + "53": [0, 0.65556, 0, 0, 0.5], + "54": [0, 0.65556, 0, 0, 0.5], + "55": [0, 0.65556, 0, 0, 0.5], + "56": [0, 0.65556, 0, 0, 0.5], + "57": [0, 0.65556, 0, 0, 0.5], + "58": [0, 0.44444, 0, 0, 0.27778], + "59": [0.125, 0.44444, 0, 0, 0.27778], + "61": [-0.13, 0.37, 0, 0, 0.77778], + "63": [0, 0.69444, 0, 0, 0.47222], + "64": [0, 0.69444, 0, 0, 0.66667], + "65": [0, 0.69444, 0, 0, 0.66667], + "66": [0, 0.69444, 0, 0, 0.66667], + "67": [0, 0.69444, 0, 0, 0.63889], + "68": [0, 0.69444, 0, 0, 0.72223], + "69": [0, 0.69444, 0, 0, 0.59722], + "70": [0, 0.69444, 0, 0, 0.56945], + "71": [0, 0.69444, 0, 0, 0.66667], + "72": [0, 0.69444, 0, 0, 0.70834], + "73": [0, 0.69444, 0, 0, 0.27778], + "74": [0, 0.69444, 0, 0, 0.47222], + "75": [0, 0.69444, 0, 0, 0.69445], + "76": [0, 0.69444, 0, 0, 0.54167], + "77": [0, 0.69444, 0, 0, 0.875], + "78": [0, 0.69444, 0, 0, 0.70834], + "79": [0, 0.69444, 0, 0, 0.73611], + "80": [0, 0.69444, 0, 0, 0.63889], + "81": [0.125, 0.69444, 0, 0, 0.73611], + "82": [0, 0.69444, 0, 0, 0.64584], + "83": [0, 0.69444, 0, 0, 0.55556], + "84": [0, 0.69444, 0, 0, 0.68056], + "85": [0, 0.69444, 0, 0, 0.6875], + "86": [0, 0.69444, 0.01389, 0, 0.66667], + "87": [0, 0.69444, 0.01389, 0, 0.94445], + "88": [0, 0.69444, 0, 0, 0.66667], + "89": [0, 0.69444, 0.025, 0, 0.66667], + "90": [0, 0.69444, 0, 0, 0.61111], + "91": [0.25, 0.75, 0, 0, 0.28889], + "93": [0.25, 0.75, 0, 0, 0.28889], + "94": [0, 0.69444, 0, 0, 0.5], + "95": [0.35, 0.09444, 0.02778, 0, 0.5], + "97": [0, 0.44444, 0, 0, 0.48056], + "98": [0, 0.69444, 0, 0, 0.51667], + "99": [0, 0.44444, 0, 0, 0.44445], + "100": [0, 0.69444, 0, 0, 0.51667], + "101": [0, 0.44444, 0, 0, 0.44445], + "102": [0, 0.69444, 0.06944, 0, 0.30556], + "103": [0.19444, 0.44444, 0.01389, 0, 0.5], + "104": [0, 0.69444, 0, 0, 0.51667], + "105": [0, 0.67937, 0, 0, 0.23889], + "106": [0.19444, 0.67937, 0, 0, 0.26667], + "107": [0, 0.69444, 0, 0, 0.48889], + "108": [0, 0.69444, 0, 0, 0.23889], + "109": [0, 0.44444, 0, 0, 0.79445], + "110": [0, 0.44444, 0, 0, 0.51667], + "111": [0, 0.44444, 0, 0, 0.5], + "112": [0.19444, 0.44444, 0, 0, 0.51667], + "113": [0.19444, 0.44444, 0, 0, 0.51667], + "114": [0, 0.44444, 0.01389, 0, 0.34167], + "115": [0, 0.44444, 0, 0, 0.38333], + "116": [0, 0.57143, 0, 0, 0.36111], + "117": [0, 0.44444, 0, 0, 0.51667], + "118": [0, 0.44444, 0.01389, 0, 0.46111], + "119": [0, 0.44444, 0.01389, 0, 0.68334], + "120": [0, 0.44444, 0, 0, 0.46111], + "121": [0.19444, 0.44444, 0.01389, 0, 0.46111], + "122": [0, 0.44444, 0, 0, 0.43472], + "126": [0.35, 0.32659, 0, 0, 0.5], + "160": [0, 0, 0, 0, 0.25], + "168": [0, 0.67937, 0, 0, 0.5], + "176": [0, 0.69444, 0, 0, 0.66667], + "184": [0.17014, 0, 0, 0, 0.44445], + "305": [0, 0.44444, 0, 0, 0.23889], + "567": [0.19444, 0.44444, 0, 0, 0.26667], + "710": [0, 0.69444, 0, 0, 0.5], + "711": [0, 0.63194, 0, 0, 0.5], + "713": [0, 0.60889, 0, 0, 0.5], + "714": [0, 0.69444, 0, 0, 0.5], + "715": [0, 0.69444, 0, 0, 0.5], + "728": [0, 0.69444, 0, 0, 0.5], + "729": [0, 0.67937, 0, 0, 0.27778], + "730": [0, 0.69444, 0, 0, 0.66667], + "732": [0, 0.67659, 0, 0, 0.5], + "733": [0, 0.69444, 0, 0, 0.5], + "915": [0, 0.69444, 0, 0, 0.54167], + "916": [0, 0.69444, 0, 0, 0.83334], + "920": [0, 0.69444, 0, 0, 0.77778], + "923": [0, 0.69444, 0, 0, 0.61111], + "926": [0, 0.69444, 0, 0, 0.66667], + "928": [0, 0.69444, 0, 0, 0.70834], + "931": [0, 0.69444, 0, 0, 0.72222], + "933": [0, 0.69444, 0, 0, 0.77778], + "934": [0, 0.69444, 0, 0, 0.72222], + "936": [0, 0.69444, 0, 0, 0.77778], + "937": [0, 0.69444, 0, 0, 0.72222], + "8211": [0, 0.44444, 0.02778, 0, 0.5], + "8212": [0, 0.44444, 0.02778, 0, 1.0], + "8216": [0, 0.69444, 0, 0, 0.27778], + "8217": [0, 0.69444, 0, 0, 0.27778], + "8220": [0, 0.69444, 0, 0, 0.5], + "8221": [0, 0.69444, 0, 0, 0.5] + }, + "Script-Regular": { + "32": [0, 0, 0, 0, 0.25], + "65": [0, 0.7, 0.22925, 0, 0.80253], + "66": [0, 0.7, 0.04087, 0, 0.90757], + "67": [0, 0.7, 0.1689, 0, 0.66619], + "68": [0, 0.7, 0.09371, 0, 0.77443], + "69": [0, 0.7, 0.18583, 0, 0.56162], + "70": [0, 0.7, 0.13634, 0, 0.89544], + "71": [0, 0.7, 0.17322, 0, 0.60961], + "72": [0, 0.7, 0.29694, 0, 0.96919], + "73": [0, 0.7, 0.19189, 0, 0.80907], + "74": [0.27778, 0.7, 0.19189, 0, 1.05159], + "75": [0, 0.7, 0.31259, 0, 0.91364], + "76": [0, 0.7, 0.19189, 0, 0.87373], + "77": [0, 0.7, 0.15981, 0, 1.08031], + "78": [0, 0.7, 0.3525, 0, 0.9015], + "79": [0, 0.7, 0.08078, 0, 0.73787], + "80": [0, 0.7, 0.08078, 0, 1.01262], + "81": [0, 0.7, 0.03305, 0, 0.88282], + "82": [0, 0.7, 0.06259, 0, 0.85], + "83": [0, 0.7, 0.19189, 0, 0.86767], + "84": [0, 0.7, 0.29087, 0, 0.74697], + "85": [0, 0.7, 0.25815, 0, 0.79996], + "86": [0, 0.7, 0.27523, 0, 0.62204], + "87": [0, 0.7, 0.27523, 0, 0.80532], + "88": [0, 0.7, 0.26006, 0, 0.94445], + "89": [0, 0.7, 0.2939, 0, 0.70961], + "90": [0, 0.7, 0.24037, 0, 0.8212], + "160": [0, 0, 0, 0, 0.25] + }, + "Size1-Regular": { + "32": [0, 0, 0, 0, 0.25], + "40": [0.35001, 0.85, 0, 0, 0.45834], + "41": [0.35001, 0.85, 0, 0, 0.45834], + "47": [0.35001, 0.85, 0, 0, 0.57778], + "91": [0.35001, 0.85, 0, 0, 0.41667], + "92": [0.35001, 0.85, 0, 0, 0.57778], + "93": [0.35001, 0.85, 0, 0, 0.41667], + "123": [0.35001, 0.85, 0, 0, 0.58334], + "125": [0.35001, 0.85, 0, 0, 0.58334], + "160": [0, 0, 0, 0, 0.25], + "710": [0, 0.72222, 0, 0, 0.55556], + "732": [0, 0.72222, 0, 0, 0.55556], + "770": [0, 0.72222, 0, 0, 0.55556], + "771": [0, 0.72222, 0, 0, 0.55556], + "8214": [-0.00099, 0.601, 0, 0, 0.77778], + "8593": [1e-05, 0.6, 0, 0, 0.66667], + "8595": [1e-05, 0.6, 0, 0, 0.66667], + "8657": [1e-05, 0.6, 0, 0, 0.77778], + "8659": [1e-05, 0.6, 0, 0, 0.77778], + "8719": [0.25001, 0.75, 0, 0, 0.94445], + "8720": [0.25001, 0.75, 0, 0, 0.94445], + "8721": [0.25001, 0.75, 0, 0, 1.05556], + "8730": [0.35001, 0.85, 0, 0, 1.0], + "8739": [-0.00599, 0.606, 0, 0, 0.33333], + "8741": [-0.00599, 0.606, 0, 0, 0.55556], + "8747": [0.30612, 0.805, 0.19445, 0, 0.47222], + "8748": [0.306, 0.805, 0.19445, 0, 0.47222], + "8749": [0.306, 0.805, 0.19445, 0, 0.47222], + "8750": [0.30612, 0.805, 0.19445, 0, 0.47222], + "8896": [0.25001, 0.75, 0, 0, 0.83334], + "8897": [0.25001, 0.75, 0, 0, 0.83334], + "8898": [0.25001, 0.75, 0, 0, 0.83334], + "8899": [0.25001, 0.75, 0, 0, 0.83334], + "8968": [0.35001, 0.85, 0, 0, 0.47222], + "8969": [0.35001, 0.85, 0, 0, 0.47222], + "8970": [0.35001, 0.85, 0, 0, 0.47222], + "8971": [0.35001, 0.85, 0, 0, 0.47222], + "9168": [-0.00099, 0.601, 0, 0, 0.66667], + "10216": [0.35001, 0.85, 0, 0, 0.47222], + "10217": [0.35001, 0.85, 0, 0, 0.47222], + "10752": [0.25001, 0.75, 0, 0, 1.11111], + "10753": [0.25001, 0.75, 0, 0, 1.11111], + "10754": [0.25001, 0.75, 0, 0, 1.11111], + "10756": [0.25001, 0.75, 0, 0, 0.83334], + "10758": [0.25001, 0.75, 0, 0, 0.83334] + }, + "Size2-Regular": { + "32": [0, 0, 0, 0, 0.25], + "40": [0.65002, 1.15, 0, 0, 0.59722], + "41": [0.65002, 1.15, 0, 0, 0.59722], + "47": [0.65002, 1.15, 0, 0, 0.81111], + "91": [0.65002, 1.15, 0, 0, 0.47222], + "92": [0.65002, 1.15, 0, 0, 0.81111], + "93": [0.65002, 1.15, 0, 0, 0.47222], + "123": [0.65002, 1.15, 0, 0, 0.66667], + "125": [0.65002, 1.15, 0, 0, 0.66667], + "160": [0, 0, 0, 0, 0.25], + "710": [0, 0.75, 0, 0, 1.0], + "732": [0, 0.75, 0, 0, 1.0], + "770": [0, 0.75, 0, 0, 1.0], + "771": [0, 0.75, 0, 0, 1.0], + "8719": [0.55001, 1.05, 0, 0, 1.27778], + "8720": [0.55001, 1.05, 0, 0, 1.27778], + "8721": [0.55001, 1.05, 0, 0, 1.44445], + "8730": [0.65002, 1.15, 0, 0, 1.0], + "8747": [0.86225, 1.36, 0.44445, 0, 0.55556], + "8748": [0.862, 1.36, 0.44445, 0, 0.55556], + "8749": [0.862, 1.36, 0.44445, 0, 0.55556], + "8750": [0.86225, 1.36, 0.44445, 0, 0.55556], + "8896": [0.55001, 1.05, 0, 0, 1.11111], + "8897": [0.55001, 1.05, 0, 0, 1.11111], + "8898": [0.55001, 1.05, 0, 0, 1.11111], + "8899": [0.55001, 1.05, 0, 0, 1.11111], + "8968": [0.65002, 1.15, 0, 0, 0.52778], + "8969": [0.65002, 1.15, 0, 0, 0.52778], + "8970": [0.65002, 1.15, 0, 0, 0.52778], + "8971": [0.65002, 1.15, 0, 0, 0.52778], + "10216": [0.65002, 1.15, 0, 0, 0.61111], + "10217": [0.65002, 1.15, 0, 0, 0.61111], + "10752": [0.55001, 1.05, 0, 0, 1.51112], + "10753": [0.55001, 1.05, 0, 0, 1.51112], + "10754": [0.55001, 1.05, 0, 0, 1.51112], + "10756": [0.55001, 1.05, 0, 0, 1.11111], + "10758": [0.55001, 1.05, 0, 0, 1.11111] + }, + "Size3-Regular": { + "32": [0, 0, 0, 0, 0.25], + "40": [0.95003, 1.45, 0, 0, 0.73611], + "41": [0.95003, 1.45, 0, 0, 0.73611], + "47": [0.95003, 1.45, 0, 0, 1.04445], + "91": [0.95003, 1.45, 0, 0, 0.52778], + "92": [0.95003, 1.45, 0, 0, 1.04445], + "93": [0.95003, 1.45, 0, 0, 0.52778], + "123": [0.95003, 1.45, 0, 0, 0.75], + "125": [0.95003, 1.45, 0, 0, 0.75], + "160": [0, 0, 0, 0, 0.25], + "710": [0, 0.75, 0, 0, 1.44445], + "732": [0, 0.75, 0, 0, 1.44445], + "770": [0, 0.75, 0, 0, 1.44445], + "771": [0, 0.75, 0, 0, 1.44445], + "8730": [0.95003, 1.45, 0, 0, 1.0], + "8968": [0.95003, 1.45, 0, 0, 0.58334], + "8969": [0.95003, 1.45, 0, 0, 0.58334], + "8970": [0.95003, 1.45, 0, 0, 0.58334], + "8971": [0.95003, 1.45, 0, 0, 0.58334], + "10216": [0.95003, 1.45, 0, 0, 0.75], + "10217": [0.95003, 1.45, 0, 0, 0.75] + }, + "Size4-Regular": { + "32": [0, 0, 0, 0, 0.25], + "40": [1.25003, 1.75, 0, 0, 0.79167], + "41": [1.25003, 1.75, 0, 0, 0.79167], + "47": [1.25003, 1.75, 0, 0, 1.27778], + "91": [1.25003, 1.75, 0, 0, 0.58334], + "92": [1.25003, 1.75, 0, 0, 1.27778], + "93": [1.25003, 1.75, 0, 0, 0.58334], + "123": [1.25003, 1.75, 0, 0, 0.80556], + "125": [1.25003, 1.75, 0, 0, 0.80556], + "160": [0, 0, 0, 0, 0.25], + "710": [0, 0.825, 0, 0, 1.8889], + "732": [0, 0.825, 0, 0, 1.8889], + "770": [0, 0.825, 0, 0, 1.8889], + "771": [0, 0.825, 0, 0, 1.8889], + "8730": [1.25003, 1.75, 0, 0, 1.0], + "8968": [1.25003, 1.75, 0, 0, 0.63889], + "8969": [1.25003, 1.75, 0, 0, 0.63889], + "8970": [1.25003, 1.75, 0, 0, 0.63889], + "8971": [1.25003, 1.75, 0, 0, 0.63889], + "9115": [0.64502, 1.155, 0, 0, 0.875], + "9116": [1e-05, 0.6, 0, 0, 0.875], + "9117": [0.64502, 1.155, 0, 0, 0.875], + "9118": [0.64502, 1.155, 0, 0, 0.875], + "9119": [1e-05, 0.6, 0, 0, 0.875], + "9120": [0.64502, 1.155, 0, 0, 0.875], + "9121": [0.64502, 1.155, 0, 0, 0.66667], + "9122": [-0.00099, 0.601, 0, 0, 0.66667], + "9123": [0.64502, 1.155, 0, 0, 0.66667], + "9124": [0.64502, 1.155, 0, 0, 0.66667], + "9125": [-0.00099, 0.601, 0, 0, 0.66667], + "9126": [0.64502, 1.155, 0, 0, 0.66667], + "9127": [1e-05, 0.9, 0, 0, 0.88889], + "9128": [0.65002, 1.15, 0, 0, 0.88889], + "9129": [0.90001, 0, 0, 0, 0.88889], + "9130": [0, 0.3, 0, 0, 0.88889], + "9131": [1e-05, 0.9, 0, 0, 0.88889], + "9132": [0.65002, 1.15, 0, 0, 0.88889], + "9133": [0.90001, 0, 0, 0, 0.88889], + "9143": [0.88502, 0.915, 0, 0, 1.05556], + "10216": [1.25003, 1.75, 0, 0, 0.80556], + "10217": [1.25003, 1.75, 0, 0, 0.80556], + "57344": [-0.00499, 0.605, 0, 0, 1.05556], + "57345": [-0.00499, 0.605, 0, 0, 1.05556], + "57680": [0, 0.12, 0, 0, 0.45], + "57681": [0, 0.12, 0, 0, 0.45], + "57682": [0, 0.12, 0, 0, 0.45], + "57683": [0, 0.12, 0, 0, 0.45] + }, + "Typewriter-Regular": { + "32": [0, 0, 0, 0, 0.525], + "33": [0, 0.61111, 0, 0, 0.525], + "34": [0, 0.61111, 0, 0, 0.525], + "35": [0, 0.61111, 0, 0, 0.525], + "36": [0.08333, 0.69444, 0, 0, 0.525], + "37": [0.08333, 0.69444, 0, 0, 0.525], + "38": [0, 0.61111, 0, 0, 0.525], + "39": [0, 0.61111, 0, 0, 0.525], + "40": [0.08333, 0.69444, 0, 0, 0.525], + "41": [0.08333, 0.69444, 0, 0, 0.525], + "42": [0, 0.52083, 0, 0, 0.525], + "43": [-0.08056, 0.53055, 0, 0, 0.525], + "44": [0.13889, 0.125, 0, 0, 0.525], + "45": [-0.08056, 0.53055, 0, 0, 0.525], + "46": [0, 0.125, 0, 0, 0.525], + "47": [0.08333, 0.69444, 0, 0, 0.525], + "48": [0, 0.61111, 0, 0, 0.525], + "49": [0, 0.61111, 0, 0, 0.525], + "50": [0, 0.61111, 0, 0, 0.525], + "51": [0, 0.61111, 0, 0, 0.525], + "52": [0, 0.61111, 0, 0, 0.525], + "53": [0, 0.61111, 0, 0, 0.525], + "54": [0, 0.61111, 0, 0, 0.525], + "55": [0, 0.61111, 0, 0, 0.525], + "56": [0, 0.61111, 0, 0, 0.525], + "57": [0, 0.61111, 0, 0, 0.525], + "58": [0, 0.43056, 0, 0, 0.525], + "59": [0.13889, 0.43056, 0, 0, 0.525], + "60": [-0.05556, 0.55556, 0, 0, 0.525], + "61": [-0.19549, 0.41562, 0, 0, 0.525], + "62": [-0.05556, 0.55556, 0, 0, 0.525], + "63": [0, 0.61111, 0, 0, 0.525], + "64": [0, 0.61111, 0, 0, 0.525], + "65": [0, 0.61111, 0, 0, 0.525], + "66": [0, 0.61111, 0, 0, 0.525], + "67": [0, 0.61111, 0, 0, 0.525], + "68": [0, 0.61111, 0, 0, 0.525], + "69": [0, 0.61111, 0, 0, 0.525], + "70": [0, 0.61111, 0, 0, 0.525], + "71": [0, 0.61111, 0, 0, 0.525], + "72": [0, 0.61111, 0, 0, 0.525], + "73": [0, 0.61111, 0, 0, 0.525], + "74": [0, 0.61111, 0, 0, 0.525], + "75": [0, 0.61111, 0, 0, 0.525], + "76": [0, 0.61111, 0, 0, 0.525], + "77": [0, 0.61111, 0, 0, 0.525], + "78": [0, 0.61111, 0, 0, 0.525], + "79": [0, 0.61111, 0, 0, 0.525], + "80": [0, 0.61111, 0, 0, 0.525], + "81": [0.13889, 0.61111, 0, 0, 0.525], + "82": [0, 0.61111, 0, 0, 0.525], + "83": [0, 0.61111, 0, 0, 0.525], + "84": [0, 0.61111, 0, 0, 0.525], + "85": [0, 0.61111, 0, 0, 0.525], + "86": [0, 0.61111, 0, 0, 0.525], + "87": [0, 0.61111, 0, 0, 0.525], + "88": [0, 0.61111, 0, 0, 0.525], + "89": [0, 0.61111, 0, 0, 0.525], + "90": [0, 0.61111, 0, 0, 0.525], + "91": [0.08333, 0.69444, 0, 0, 0.525], + "92": [0.08333, 0.69444, 0, 0, 0.525], + "93": [0.08333, 0.69444, 0, 0, 0.525], + "94": [0, 0.61111, 0, 0, 0.525], + "95": [0.09514, 0, 0, 0, 0.525], + "96": [0, 0.61111, 0, 0, 0.525], + "97": [0, 0.43056, 0, 0, 0.525], + "98": [0, 0.61111, 0, 0, 0.525], + "99": [0, 0.43056, 0, 0, 0.525], + "100": [0, 0.61111, 0, 0, 0.525], + "101": [0, 0.43056, 0, 0, 0.525], + "102": [0, 0.61111, 0, 0, 0.525], + "103": [0.22222, 0.43056, 0, 0, 0.525], + "104": [0, 0.61111, 0, 0, 0.525], + "105": [0, 0.61111, 0, 0, 0.525], + "106": [0.22222, 0.61111, 0, 0, 0.525], + "107": [0, 0.61111, 0, 0, 0.525], + "108": [0, 0.61111, 0, 0, 0.525], + "109": [0, 0.43056, 0, 0, 0.525], + "110": [0, 0.43056, 0, 0, 0.525], + "111": [0, 0.43056, 0, 0, 0.525], + "112": [0.22222, 0.43056, 0, 0, 0.525], + "113": [0.22222, 0.43056, 0, 0, 0.525], + "114": [0, 0.43056, 0, 0, 0.525], + "115": [0, 0.43056, 0, 0, 0.525], + "116": [0, 0.55358, 0, 0, 0.525], + "117": [0, 0.43056, 0, 0, 0.525], + "118": [0, 0.43056, 0, 0, 0.525], + "119": [0, 0.43056, 0, 0, 0.525], + "120": [0, 0.43056, 0, 0, 0.525], + "121": [0.22222, 0.43056, 0, 0, 0.525], + "122": [0, 0.43056, 0, 0, 0.525], + "123": [0.08333, 0.69444, 0, 0, 0.525], + "124": [0.08333, 0.69444, 0, 0, 0.525], + "125": [0.08333, 0.69444, 0, 0, 0.525], + "126": [0, 0.61111, 0, 0, 0.525], + "127": [0, 0.61111, 0, 0, 0.525], + "160": [0, 0, 0, 0, 0.525], + "176": [0, 0.61111, 0, 0, 0.525], + "184": [0.19445, 0, 0, 0, 0.525], + "305": [0, 0.43056, 0, 0, 0.525], + "567": [0.22222, 0.43056, 0, 0, 0.525], + "711": [0, 0.56597, 0, 0, 0.525], + "713": [0, 0.56555, 0, 0, 0.525], + "714": [0, 0.61111, 0, 0, 0.525], + "715": [0, 0.61111, 0, 0, 0.525], + "728": [0, 0.61111, 0, 0, 0.525], + "730": [0, 0.61111, 0, 0, 0.525], + "770": [0, 0.61111, 0, 0, 0.525], + "771": [0, 0.61111, 0, 0, 0.525], + "776": [0, 0.61111, 0, 0, 0.525], + "915": [0, 0.61111, 0, 0, 0.525], + "916": [0, 0.61111, 0, 0, 0.525], + "920": [0, 0.61111, 0, 0, 0.525], + "923": [0, 0.61111, 0, 0, 0.525], + "926": [0, 0.61111, 0, 0, 0.525], + "928": [0, 0.61111, 0, 0, 0.525], + "931": [0, 0.61111, 0, 0, 0.525], + "933": [0, 0.61111, 0, 0, 0.525], + "934": [0, 0.61111, 0, 0, 0.525], + "936": [0, 0.61111, 0, 0, 0.525], + "937": [0, 0.61111, 0, 0, 0.525], + "8216": [0, 0.61111, 0, 0, 0.525], + "8217": [0, 0.61111, 0, 0, 0.525], + "8242": [0, 0.61111, 0, 0, 0.525], + "9251": [0.11111, 0.21944, 0, 0, 0.525] + } +}); +;// ./src/fontMetrics.ts + +// This map contains a mapping from font name and character code to character +// metrics, including height, depth, italic correction, and skew (kern from the +// character to the corresponding \skewchar) +// This map is generated via `make metrics`. It should not be changed manually. + + +/** + * This file contains metrics regarding fonts and individual symbols. The sigma + * and xi variables, as well as the metricMap map contain data extracted from + * TeX, TeX font metrics, and the TTF files. These data are then exposed via the + * `metrics` variable and the getCharacterMetrics function. + */ + +// In TeX, there are actually three sets of dimensions, one for each of +// textstyle (size index 5 and higher: >=9pt), scriptstyle (size index 3 and 4: +// 7-8pt), and scriptscriptstyle (size index 1 and 2: 5-6pt). These are +// provided in the arrays below, in that order. +// +// The font metrics are stored in fonts cmsy10, cmsy7, and cmsy5 respectively. +// This was determined by running the following script: +// +// latex -interaction=nonstopmode \ +// '\documentclass{article}\usepackage{amsmath}\begin{document}' \ +// '$a$ \expandafter\show\the\textfont2' \ +// '\expandafter\show\the\scriptfont2' \ +// '\expandafter\show\the\scriptscriptfont2' \ +// '\stop' +// +// The metrics themselves were retrieved using the following commands: +// +// tftopl cmsy10 +// tftopl cmsy7 +// tftopl cmsy5 +// +// The output of each of these commands is quite lengthy. The only part we +// care about is the FONTDIMEN section. Each value is measured in EMs. +const sigmasAndXis = { + slant: [0.250, 0.250, 0.250], + // sigma1 + space: [0.000, 0.000, 0.000], + // sigma2 + stretch: [0.000, 0.000, 0.000], + // sigma3 + shrink: [0.000, 0.000, 0.000], + // sigma4 + xHeight: [0.431, 0.431, 0.431], + // sigma5 + quad: [1.000, 1.171, 1.472], + // sigma6 + extraSpace: [0.000, 0.000, 0.000], + // sigma7 + num1: [0.677, 0.732, 0.925], + // sigma8 + num2: [0.394, 0.384, 0.387], + // sigma9 + num3: [0.444, 0.471, 0.504], + // sigma10 + denom1: [0.686, 0.752, 1.025], + // sigma11 + denom2: [0.345, 0.344, 0.532], + // sigma12 + sup1: [0.413, 0.503, 0.504], + // sigma13 + sup2: [0.363, 0.431, 0.404], + // sigma14 + sup3: [0.289, 0.286, 0.294], + // sigma15 + sub1: [0.150, 0.143, 0.200], + // sigma16 + sub2: [0.247, 0.286, 0.400], + // sigma17 + supDrop: [0.386, 0.353, 0.494], + // sigma18 + subDrop: [0.050, 0.071, 0.100], + // sigma19 + delim1: [2.390, 1.700, 1.980], + // sigma20 + delim2: [1.010, 1.157, 1.420], + // sigma21 + axisHeight: [0.250, 0.250, 0.250], + // sigma22 + + // These font metrics are extracted from TeX by using tftopl on cmex10.tfm; + // they correspond to the font parameters of the extension fonts (family 3). + // See the TeXbook, page 441. In AMSTeX, the extension fonts scale; to + // match cmex7, we'd use cmex7.tfm values for script and scriptscript + // values. + defaultRuleThickness: [0.04, 0.049, 0.049], + // xi8; cmex7: 0.049 + bigOpSpacing1: [0.111, 0.111, 0.111], + // xi9 + bigOpSpacing2: [0.166, 0.166, 0.166], + // xi10 + bigOpSpacing3: [0.2, 0.2, 0.2], + // xi11 + bigOpSpacing4: [0.6, 0.611, 0.611], + // xi12; cmex7: 0.611 + bigOpSpacing5: [0.1, 0.143, 0.143], + // xi13; cmex7: 0.143 + + // The \sqrt rule width is taken from the height of the surd character. + // Since we use the same font at all sizes, this thickness doesn't scale. + sqrtRuleThickness: [0.04, 0.04, 0.04], + // This value determines how large a pt is, for metrics which are defined + // in terms of pts. + // This value is also used in katex.scss; if you change it make sure the + // values match. + ptPerEm: [10.0, 10.0, 10.0], + // The space between adjacent `|` columns in an array definition. From + // `\showthe\doublerulesep` in LaTeX. Equals 2.0 / ptPerEm. + doubleRuleSep: [0.2, 0.2, 0.2], + // The width of separator lines in {array} environments. From + // `\showthe\arrayrulewidth` in LaTeX. Equals 0.4 / ptPerEm. + arrayRuleWidth: [0.04, 0.04, 0.04], + // Two values from LaTeX source2e: + fboxsep: [0.3, 0.3, 0.3], + // 3 pt / ptPerEm + fboxrule: [0.04, 0.04, 0.04] // 0.4 pt / ptPerEm +}; + +// These are very rough approximations. We default to Times New Roman which +// should have Latin-1 and Cyrillic characters, but may not depending on the +// operating system. The metrics do not account for extra height from the +// accents. In the case of Cyrillic characters which have both ascenders and +// descenders we prefer approximations with ascenders, primarily to prevent +// the fraction bar or root line from intersecting the glyph. +// TODO(kevinb) allow union of multiple glyph metrics for better accuracy. +const extraCharacterMap = { + // Latin-1 + 'Å': 'A', + 'Ð': 'D', + 'Þ': 'o', + 'å': 'a', + 'ð': 'd', + 'þ': 'o', + // Cyrillic + 'А': 'A', + 'Б': 'B', + 'В': 'B', + 'Г': 'F', + 'Д': 'A', + 'Е': 'E', + 'Ж': 'K', + 'З': '3', + 'И': 'N', + 'Й': 'N', + 'К': 'K', + 'Л': 'N', + 'М': 'M', + 'Н': 'H', + 'О': 'O', + 'П': 'N', + 'Р': 'P', + 'С': 'C', + 'Т': 'T', + 'У': 'y', + 'Ф': 'O', + 'Х': 'X', + 'Ц': 'U', + 'Ч': 'h', + 'Ш': 'W', + 'Щ': 'W', + 'Ъ': 'B', + 'Ы': 'X', + 'Ь': 'B', + 'Э': '3', + 'Ю': 'X', + 'Я': 'R', + 'а': 'a', + 'б': 'b', + 'в': 'a', + 'г': 'r', + 'д': 'y', + 'е': 'e', + 'ж': 'm', + 'з': 'e', + 'и': 'n', + 'й': 'n', + 'к': 'n', + 'л': 'n', + 'м': 'm', + 'н': 'n', + 'о': 'o', + 'п': 'n', + 'р': 'p', + 'с': 'c', + 'т': 'o', + 'у': 'y', + 'ф': 'b', + 'х': 'x', + 'ц': 'n', + 'ч': 'n', + 'ш': 'w', + 'щ': 'w', + 'ъ': 'a', + 'ы': 'm', + 'ь': 'a', + 'э': 'e', + 'ю': 'm', + 'я': 'r' +}; + +/** + * This function adds new font metrics to default metricMap + * It can also override existing metrics + */ +function setFontMetrics(fontName, metrics) { + fontMetricsData[fontName] = metrics; +} + +/** + * This function is a convenience function for looking up information in the + * metricMap table. It takes a character as a string, and a font. + * + * Note: the `width` property may be undefined if fontMetricsData.js wasn't + * built using `Make extended_metrics`. + */ +function getCharacterMetrics(character, font, mode) { + if (!fontMetricsData[font]) { + throw new Error("Font metrics not found for font: " + font + "."); + } + let ch = character.charCodeAt(0); + let metrics = fontMetricsData[font][ch]; + if (!metrics && character[0] in extraCharacterMap) { + ch = extraCharacterMap[character[0]].charCodeAt(0); + metrics = fontMetricsData[font][ch]; + } + if (!metrics && mode === 'text') { + // We don't typically have font metrics for Asian scripts. + // But since we support them in text mode, we need to return + // some sort of metrics. + // So if the character is in a script we support but we + // don't have metrics for it, just use the metrics for + // the Latin capital letter M. This is close enough because + // we (currently) only care about the height of the glyph + // not its width. + if (supportedCodepoint(ch)) { + metrics = fontMetricsData[font][77]; // 77 is the charcode for 'M' + } + } + if (metrics) { + return { + depth: metrics[0], + height: metrics[1], + italic: metrics[2], + skew: metrics[3], + width: metrics[4] + }; + } +} +const fontMetricsBySizeIndex = {}; + +/** + * Get the font metrics for a given size. + */ +function getGlobalMetrics(size) { + let sizeIndex; + if (size >= 5) { + sizeIndex = 0; + } else if (size >= 3) { + sizeIndex = 1; + } else { + sizeIndex = 2; + } + if (!fontMetricsBySizeIndex[sizeIndex]) { + const metrics = fontMetricsBySizeIndex[sizeIndex] = { + cssEmPerMu: sigmasAndXis.quad[sizeIndex] / 18 + }; + for (const key in sigmasAndXis) { + if (sigmasAndXis.hasOwnProperty(key)) { + metrics[key] = sigmasAndXis[key][sizeIndex]; + } + } + } + return fontMetricsBySizeIndex[sizeIndex]; +} +;// ./src/symbols.ts +/** + * This file holds a list of all no-argument functions and single-character + * symbols (like 'a' or ';'). + * + * For each of the symbols, there are three properties they can have: + * - font (required): the font to be used for this symbol. Either "main" (the + normal font), or "ams" (the ams fonts). + * - group (required): the ParseNode group type the symbol should have (i.e. + "textord", "mathord", etc). + See https://github.com/KaTeX/KaTeX/wiki/Examining-TeX#group-types + * - replace: the character that this symbol or function should be + * replaced with (i.e. "\phi" has a replace value of "\u03d5", the phi + * character in the main font). + * + * The outermost map in the table indicates what mode the symbols should be + * accepted in (e.g. "math" or "text"). + */ + +// Some of these have a "-token" suffix since these are also used as `ParseNode` +// types for raw text tokens, and we want to avoid conflicts with higher-level +// `ParseNode` types. These `ParseNode`s are constructed within `Parser` by +// looking up the `symbols` map. + +const symbols = { + "math": {}, + "text": {} +}; +/* harmony default export */ var src_symbols = (symbols); + +/** `acceptUnicodeChar = true` is only applicable if `replace` is set. */ +function defineSymbol(mode, font, group, replace, name, acceptUnicodeChar) { + symbols[mode][name] = { + font, + group, + replace + }; + if (acceptUnicodeChar && replace) { + symbols[mode][replace] = symbols[mode][name]; + } +} + +// Some abbreviations for commonly used strings. +// This helps minify the code, and also spotting typos using jshint. + +// modes: +const math = "math"; +const symbols_text = "text"; + +// fonts: +const main = "main"; +const ams = "ams"; + +// groups: +const accent = "accent-token"; +const bin = "bin"; +const symbols_close = "close"; +const inner = "inner"; +const mathord = "mathord"; +const op = "op-token"; +const symbols_open = "open"; +const punct = "punct"; +const rel = "rel"; +const spacing = "spacing"; +const textord = "textord"; + +// Now comes the symbol table + +// Relation Symbols +defineSymbol(math, main, rel, "\u2261", "\\equiv", true); +defineSymbol(math, main, rel, "\u227a", "\\prec", true); +defineSymbol(math, main, rel, "\u227b", "\\succ", true); +defineSymbol(math, main, rel, "\u223c", "\\sim", true); +defineSymbol(math, main, rel, "\u22a5", "\\perp"); +defineSymbol(math, main, rel, "\u2aaf", "\\preceq", true); +defineSymbol(math, main, rel, "\u2ab0", "\\succeq", true); +defineSymbol(math, main, rel, "\u2243", "\\simeq", true); +defineSymbol(math, main, rel, "\u2223", "\\mid", true); +defineSymbol(math, main, rel, "\u226a", "\\ll", true); +defineSymbol(math, main, rel, "\u226b", "\\gg", true); +defineSymbol(math, main, rel, "\u224d", "\\asymp", true); +defineSymbol(math, main, rel, "\u2225", "\\parallel"); +defineSymbol(math, main, rel, "\u22c8", "\\bowtie", true); +defineSymbol(math, main, rel, "\u2323", "\\smile", true); +defineSymbol(math, main, rel, "\u2291", "\\sqsubseteq", true); +defineSymbol(math, main, rel, "\u2292", "\\sqsupseteq", true); +defineSymbol(math, main, rel, "\u2250", "\\doteq", true); +defineSymbol(math, main, rel, "\u2322", "\\frown", true); +defineSymbol(math, main, rel, "\u220b", "\\ni", true); +defineSymbol(math, main, rel, "\u221d", "\\propto", true); +defineSymbol(math, main, rel, "\u22a2", "\\vdash", true); +defineSymbol(math, main, rel, "\u22a3", "\\dashv", true); +defineSymbol(math, main, rel, "\u220b", "\\owns"); + +// Punctuation +defineSymbol(math, main, punct, "\u002e", "\\ldotp"); +defineSymbol(math, main, punct, "\u22c5", "\\cdotp"); +// The KaTeX fonts do not contain U+00B7. Use the centered dot glyph at U+22C5 +// in both modes, but keep math-mode punctuation spacing only in math mode. +defineSymbol(math, main, punct, "\u22c5", "\u00b7"); +defineSymbol(symbols_text, main, textord, "\u22c5", "\u00b7"); + +// Misc Symbols +defineSymbol(math, main, textord, "\u0023", "\\#"); +defineSymbol(symbols_text, main, textord, "\u0023", "\\#"); +defineSymbol(math, main, textord, "\u0026", "\\&"); +defineSymbol(symbols_text, main, textord, "\u0026", "\\&"); +defineSymbol(math, main, textord, "\u2135", "\\aleph", true); +defineSymbol(math, main, textord, "\u2200", "\\forall", true); +defineSymbol(math, main, textord, "\u210f", "\\hbar", true); +defineSymbol(math, main, textord, "\u2203", "\\exists", true); +defineSymbol(math, main, textord, "\u2207", "\\nabla", true); +defineSymbol(math, main, textord, "\u266d", "\\flat", true); +defineSymbol(math, main, textord, "\u2113", "\\ell", true); +defineSymbol(math, main, textord, "\u266e", "\\natural", true); +defineSymbol(math, main, textord, "\u2663", "\\clubsuit", true); +defineSymbol(math, main, textord, "\u2118", "\\wp", true); +defineSymbol(math, main, textord, "\u266f", "\\sharp", true); +defineSymbol(math, main, textord, "\u2662", "\\diamondsuit", true); +defineSymbol(math, main, textord, "\u211c", "\\Re", true); +defineSymbol(math, main, textord, "\u2661", "\\heartsuit", true); +defineSymbol(math, main, textord, "\u2111", "\\Im", true); +defineSymbol(math, main, textord, "\u2660", "\\spadesuit", true); +defineSymbol(math, main, textord, "\u00a7", "\\S", true); +defineSymbol(symbols_text, main, textord, "\u00a7", "\\S"); +defineSymbol(math, main, textord, "\u00b6", "\\P", true); +defineSymbol(symbols_text, main, textord, "\u00b6", "\\P"); + +// Math and Text +defineSymbol(math, main, textord, "\u2020", "\\dag"); +defineSymbol(symbols_text, main, textord, "\u2020", "\\dag"); +defineSymbol(symbols_text, main, textord, "\u2020", "\\textdagger"); +defineSymbol(math, main, textord, "\u2021", "\\ddag"); +defineSymbol(symbols_text, main, textord, "\u2021", "\\ddag"); +defineSymbol(symbols_text, main, textord, "\u2021", "\\textdaggerdbl"); + +// Large Delimiters +defineSymbol(math, main, symbols_close, "\u23b1", "\\rmoustache", true); +defineSymbol(math, main, symbols_open, "\u23b0", "\\lmoustache", true); +defineSymbol(math, main, symbols_close, "\u27ef", "\\rgroup", true); +defineSymbol(math, main, symbols_open, "\u27ee", "\\lgroup", true); + +// Binary Operators +defineSymbol(math, main, bin, "\u2213", "\\mp", true); +defineSymbol(math, main, bin, "\u2296", "\\ominus", true); +defineSymbol(math, main, bin, "\u228e", "\\uplus", true); +defineSymbol(math, main, bin, "\u2293", "\\sqcap", true); +defineSymbol(math, main, bin, "\u2217", "\\ast"); +defineSymbol(math, main, bin, "\u2294", "\\sqcup", true); +defineSymbol(math, main, bin, "\u25ef", "\\bigcirc", true); +defineSymbol(math, main, bin, "\u2219", "\\bullet", true); +defineSymbol(math, main, bin, "\u2021", "\\ddagger"); +defineSymbol(math, main, bin, "\u2240", "\\wr", true); +defineSymbol(math, main, bin, "\u2a3f", "\\amalg"); +defineSymbol(math, main, bin, "\u0026", "\\And"); // from amsmath + +// Arrow Symbols +defineSymbol(math, main, rel, "\u27f5", "\\longleftarrow", true); +defineSymbol(math, main, rel, "\u21d0", "\\Leftarrow", true); +defineSymbol(math, main, rel, "\u27f8", "\\Longleftarrow", true); +defineSymbol(math, main, rel, "\u27f6", "\\longrightarrow", true); +defineSymbol(math, main, rel, "\u21d2", "\\Rightarrow", true); +defineSymbol(math, main, rel, "\u27f9", "\\Longrightarrow", true); +defineSymbol(math, main, rel, "\u2194", "\\leftrightarrow", true); +defineSymbol(math, main, rel, "\u27f7", "\\longleftrightarrow", true); +defineSymbol(math, main, rel, "\u21d4", "\\Leftrightarrow", true); +defineSymbol(math, main, rel, "\u27fa", "\\Longleftrightarrow", true); +defineSymbol(math, main, rel, "\u21a6", "\\mapsto", true); +defineSymbol(math, main, rel, "\u27fc", "\\longmapsto", true); +defineSymbol(math, main, rel, "\u2197", "\\nearrow", true); +defineSymbol(math, main, rel, "\u21a9", "\\hookleftarrow", true); +defineSymbol(math, main, rel, "\u21aa", "\\hookrightarrow", true); +defineSymbol(math, main, rel, "\u2198", "\\searrow", true); +defineSymbol(math, main, rel, "\u21bc", "\\leftharpoonup", true); +defineSymbol(math, main, rel, "\u21c0", "\\rightharpoonup", true); +defineSymbol(math, main, rel, "\u2199", "\\swarrow", true); +defineSymbol(math, main, rel, "\u21bd", "\\leftharpoondown", true); +defineSymbol(math, main, rel, "\u21c1", "\\rightharpoondown", true); +defineSymbol(math, main, rel, "\u2196", "\\nwarrow", true); +defineSymbol(math, main, rel, "\u21cc", "\\rightleftharpoons", true); + +// AMS Negated Binary Relations +defineSymbol(math, ams, rel, "\u226e", "\\nless", true); +// Symbol names preceded by "@" each have a corresponding macro. +defineSymbol(math, ams, rel, "\ue010", "\\@nleqslant"); +defineSymbol(math, ams, rel, "\ue011", "\\@nleqq"); +defineSymbol(math, ams, rel, "\u2a87", "\\lneq", true); +defineSymbol(math, ams, rel, "\u2268", "\\lneqq", true); +defineSymbol(math, ams, rel, "\ue00c", "\\@lvertneqq"); +defineSymbol(math, ams, rel, "\u22e6", "\\lnsim", true); +defineSymbol(math, ams, rel, "\u2a89", "\\lnapprox", true); +defineSymbol(math, ams, rel, "\u2280", "\\nprec", true); +// unicode-math maps \u22e0 to \npreccurlyeq. We'll use the AMS synonym. +defineSymbol(math, ams, rel, "\u22e0", "\\npreceq", true); +defineSymbol(math, ams, rel, "\u22e8", "\\precnsim", true); +defineSymbol(math, ams, rel, "\u2ab9", "\\precnapprox", true); +defineSymbol(math, ams, rel, "\u2241", "\\nsim", true); +defineSymbol(math, ams, rel, "\ue006", "\\@nshortmid"); +defineSymbol(math, ams, rel, "\u2224", "\\nmid", true); +defineSymbol(math, ams, rel, "\u22ac", "\\nvdash", true); +defineSymbol(math, ams, rel, "\u22ad", "\\nvDash", true); +defineSymbol(math, ams, rel, "\u22ea", "\\ntriangleleft"); +defineSymbol(math, ams, rel, "\u22ec", "\\ntrianglelefteq", true); +defineSymbol(math, ams, rel, "\u228a", "\\subsetneq", true); +defineSymbol(math, ams, rel, "\ue01a", "\\@varsubsetneq"); +defineSymbol(math, ams, rel, "\u2acb", "\\subsetneqq", true); +defineSymbol(math, ams, rel, "\ue017", "\\@varsubsetneqq"); +defineSymbol(math, ams, rel, "\u226f", "\\ngtr", true); +defineSymbol(math, ams, rel, "\ue00f", "\\@ngeqslant"); +defineSymbol(math, ams, rel, "\ue00e", "\\@ngeqq"); +defineSymbol(math, ams, rel, "\u2a88", "\\gneq", true); +defineSymbol(math, ams, rel, "\u2269", "\\gneqq", true); +defineSymbol(math, ams, rel, "\ue00d", "\\@gvertneqq"); +defineSymbol(math, ams, rel, "\u22e7", "\\gnsim", true); +defineSymbol(math, ams, rel, "\u2a8a", "\\gnapprox", true); +defineSymbol(math, ams, rel, "\u2281", "\\nsucc", true); +// unicode-math maps \u22e1 to \nsucccurlyeq. We'll use the AMS synonym. +defineSymbol(math, ams, rel, "\u22e1", "\\nsucceq", true); +defineSymbol(math, ams, rel, "\u22e9", "\\succnsim", true); +defineSymbol(math, ams, rel, "\u2aba", "\\succnapprox", true); +// unicode-math maps \u2246 to \simneqq. We'll use the AMS synonym. +defineSymbol(math, ams, rel, "\u2246", "\\ncong", true); +defineSymbol(math, ams, rel, "\ue007", "\\@nshortparallel"); +defineSymbol(math, ams, rel, "\u2226", "\\nparallel", true); +defineSymbol(math, ams, rel, "\u22af", "\\nVDash", true); +defineSymbol(math, ams, rel, "\u22eb", "\\ntriangleright"); +defineSymbol(math, ams, rel, "\u22ed", "\\ntrianglerighteq", true); +defineSymbol(math, ams, rel, "\ue018", "\\@nsupseteqq"); +defineSymbol(math, ams, rel, "\u228b", "\\supsetneq", true); +defineSymbol(math, ams, rel, "\ue01b", "\\@varsupsetneq"); +defineSymbol(math, ams, rel, "\u2acc", "\\supsetneqq", true); +defineSymbol(math, ams, rel, "\ue019", "\\@varsupsetneqq"); +defineSymbol(math, ams, rel, "\u22ae", "\\nVdash", true); +defineSymbol(math, ams, rel, "\u2ab5", "\\precneqq", true); +defineSymbol(math, ams, rel, "\u2ab6", "\\succneqq", true); +defineSymbol(math, ams, rel, "\ue016", "\\@nsubseteqq"); +defineSymbol(math, ams, bin, "\u22b4", "\\unlhd"); +defineSymbol(math, ams, bin, "\u22b5", "\\unrhd"); + +// AMS Negated Arrows +defineSymbol(math, ams, rel, "\u219a", "\\nleftarrow", true); +defineSymbol(math, ams, rel, "\u219b", "\\nrightarrow", true); +defineSymbol(math, ams, rel, "\u21cd", "\\nLeftarrow", true); +defineSymbol(math, ams, rel, "\u21cf", "\\nRightarrow", true); +defineSymbol(math, ams, rel, "\u21ae", "\\nleftrightarrow", true); +defineSymbol(math, ams, rel, "\u21ce", "\\nLeftrightarrow", true); + +// AMS Misc +defineSymbol(math, ams, rel, "\u25b3", "\\vartriangle"); +defineSymbol(math, ams, textord, "\u210f", "\\hslash"); +defineSymbol(math, ams, textord, "\u25bd", "\\triangledown"); +defineSymbol(math, ams, textord, "\u25ca", "\\lozenge"); +defineSymbol(math, ams, textord, "\u24c8", "\\circledS"); +defineSymbol(math, ams, textord, "\u00ae", "\\circledR"); +defineSymbol(symbols_text, ams, textord, "\u00ae", "\\circledR"); +defineSymbol(math, ams, textord, "\u2221", "\\measuredangle", true); +defineSymbol(math, ams, textord, "\u2204", "\\nexists"); +defineSymbol(math, ams, textord, "\u2127", "\\mho"); +defineSymbol(math, ams, textord, "\u2132", "\\Finv", true); +defineSymbol(math, ams, textord, "\u2141", "\\Game", true); +defineSymbol(math, ams, textord, "\u2035", "\\backprime"); +defineSymbol(math, ams, textord, "\u25b2", "\\blacktriangle"); +defineSymbol(math, ams, textord, "\u25bc", "\\blacktriangledown"); +defineSymbol(math, ams, textord, "\u25a0", "\\blacksquare"); +defineSymbol(math, ams, textord, "\u29eb", "\\blacklozenge"); +defineSymbol(math, ams, textord, "\u2605", "\\bigstar"); +defineSymbol(math, ams, textord, "\u2222", "\\sphericalangle", true); +defineSymbol(math, ams, textord, "\u2201", "\\complement", true); +// unicode-math maps U+F0 to \matheth. We map to AMS function \eth +defineSymbol(math, ams, textord, "\u00f0", "\\eth", true); +defineSymbol(symbols_text, main, textord, "\u00f0", "\u00f0"); +defineSymbol(math, ams, textord, "\u2571", "\\diagup"); +defineSymbol(math, ams, textord, "\u2572", "\\diagdown"); +defineSymbol(math, ams, textord, "\u25a1", "\\square"); +defineSymbol(math, ams, textord, "\u25a1", "\\Box"); +defineSymbol(math, ams, textord, "\u25ca", "\\Diamond"); +// unicode-math maps U+A5 to \mathyen. We map to AMS function \yen +defineSymbol(math, ams, textord, "\u00a5", "\\yen", true); +defineSymbol(symbols_text, ams, textord, "\u00a5", "\\yen", true); +defineSymbol(math, ams, textord, "\u2713", "\\checkmark", true); +defineSymbol(symbols_text, ams, textord, "\u2713", "\\checkmark"); + +// AMS Hebrew +defineSymbol(math, ams, textord, "\u2136", "\\beth", true); +defineSymbol(math, ams, textord, "\u2138", "\\daleth", true); +defineSymbol(math, ams, textord, "\u2137", "\\gimel", true); + +// AMS Greek +defineSymbol(math, ams, textord, "\u03dd", "\\digamma", true); +defineSymbol(math, ams, textord, "\u03f0", "\\varkappa"); + +// AMS Delimiters +defineSymbol(math, ams, symbols_open, "\u250c", "\\@ulcorner", true); +defineSymbol(math, ams, symbols_close, "\u2510", "\\@urcorner", true); +defineSymbol(math, ams, symbols_open, "\u2514", "\\@llcorner", true); +defineSymbol(math, ams, symbols_close, "\u2518", "\\@lrcorner", true); + +// AMS Binary Relations +defineSymbol(math, ams, rel, "\u2266", "\\leqq", true); +defineSymbol(math, ams, rel, "\u2a7d", "\\leqslant", true); +defineSymbol(math, ams, rel, "\u2a95", "\\eqslantless", true); +defineSymbol(math, ams, rel, "\u2272", "\\lesssim", true); +defineSymbol(math, ams, rel, "\u2a85", "\\lessapprox", true); +defineSymbol(math, ams, rel, "\u224a", "\\approxeq", true); +defineSymbol(math, ams, bin, "\u22d6", "\\lessdot"); +defineSymbol(math, ams, rel, "\u22d8", "\\lll", true); +defineSymbol(math, ams, rel, "\u2276", "\\lessgtr", true); +defineSymbol(math, ams, rel, "\u22da", "\\lesseqgtr", true); +defineSymbol(math, ams, rel, "\u2a8b", "\\lesseqqgtr", true); +defineSymbol(math, ams, rel, "\u2251", "\\doteqdot"); +defineSymbol(math, ams, rel, "\u2253", "\\risingdotseq", true); +defineSymbol(math, ams, rel, "\u2252", "\\fallingdotseq", true); +defineSymbol(math, ams, rel, "\u223d", "\\backsim", true); +defineSymbol(math, ams, rel, "\u22cd", "\\backsimeq", true); +defineSymbol(math, ams, rel, "\u2ac5", "\\subseteqq", true); +defineSymbol(math, ams, rel, "\u22d0", "\\Subset", true); +defineSymbol(math, ams, rel, "\u228f", "\\sqsubset", true); +defineSymbol(math, ams, rel, "\u227c", "\\preccurlyeq", true); +defineSymbol(math, ams, rel, "\u22de", "\\curlyeqprec", true); +defineSymbol(math, ams, rel, "\u227e", "\\precsim", true); +defineSymbol(math, ams, rel, "\u2ab7", "\\precapprox", true); +defineSymbol(math, ams, rel, "\u22b2", "\\vartriangleleft"); +defineSymbol(math, ams, rel, "\u22b4", "\\trianglelefteq"); +defineSymbol(math, ams, rel, "\u22a8", "\\vDash", true); +defineSymbol(math, ams, rel, "\u22aa", "\\Vvdash", true); +defineSymbol(math, ams, rel, "\u2323", "\\smallsmile"); +defineSymbol(math, ams, rel, "\u2322", "\\smallfrown"); +defineSymbol(math, ams, rel, "\u224f", "\\bumpeq", true); +defineSymbol(math, ams, rel, "\u224e", "\\Bumpeq", true); +defineSymbol(math, ams, rel, "\u2267", "\\geqq", true); +defineSymbol(math, ams, rel, "\u2a7e", "\\geqslant", true); +defineSymbol(math, ams, rel, "\u2a96", "\\eqslantgtr", true); +defineSymbol(math, ams, rel, "\u2273", "\\gtrsim", true); +defineSymbol(math, ams, rel, "\u2a86", "\\gtrapprox", true); +defineSymbol(math, ams, bin, "\u22d7", "\\gtrdot"); +defineSymbol(math, ams, rel, "\u22d9", "\\ggg", true); +defineSymbol(math, ams, rel, "\u2277", "\\gtrless", true); +defineSymbol(math, ams, rel, "\u22db", "\\gtreqless", true); +defineSymbol(math, ams, rel, "\u2a8c", "\\gtreqqless", true); +defineSymbol(math, ams, rel, "\u2256", "\\eqcirc", true); +defineSymbol(math, ams, rel, "\u2257", "\\circeq", true); +defineSymbol(math, ams, rel, "\u225c", "\\triangleq", true); +defineSymbol(math, ams, rel, "\u223c", "\\thicksim"); +defineSymbol(math, ams, rel, "\u2248", "\\thickapprox"); +defineSymbol(math, ams, rel, "\u2ac6", "\\supseteqq", true); +defineSymbol(math, ams, rel, "\u22d1", "\\Supset", true); +defineSymbol(math, ams, rel, "\u2290", "\\sqsupset", true); +defineSymbol(math, ams, rel, "\u227d", "\\succcurlyeq", true); +defineSymbol(math, ams, rel, "\u22df", "\\curlyeqsucc", true); +defineSymbol(math, ams, rel, "\u227f", "\\succsim", true); +defineSymbol(math, ams, rel, "\u2ab8", "\\succapprox", true); +defineSymbol(math, ams, rel, "\u22b3", "\\vartriangleright"); +defineSymbol(math, ams, rel, "\u22b5", "\\trianglerighteq"); +defineSymbol(math, ams, rel, "\u22a9", "\\Vdash", true); +defineSymbol(math, ams, rel, "\u2223", "\\shortmid"); +defineSymbol(math, ams, rel, "\u2225", "\\shortparallel"); +defineSymbol(math, ams, rel, "\u226c", "\\between", true); +defineSymbol(math, ams, rel, "\u22d4", "\\pitchfork", true); +defineSymbol(math, ams, rel, "\u221d", "\\varpropto"); +defineSymbol(math, ams, rel, "\u25c0", "\\blacktriangleleft"); +// unicode-math says that \therefore is a mathord atom. +// We kept the amssymb atom type, which is rel. +defineSymbol(math, ams, rel, "\u2234", "\\therefore", true); +defineSymbol(math, ams, rel, "\u220d", "\\backepsilon"); +defineSymbol(math, ams, rel, "\u25b6", "\\blacktriangleright"); +// unicode-math says that \because is a mathord atom. +// We kept the amssymb atom type, which is rel. +defineSymbol(math, ams, rel, "\u2235", "\\because", true); +defineSymbol(math, ams, rel, "\u22d8", "\\llless"); +defineSymbol(math, ams, rel, "\u22d9", "\\gggtr"); +defineSymbol(math, ams, bin, "\u22b2", "\\lhd"); +defineSymbol(math, ams, bin, "\u22b3", "\\rhd"); +defineSymbol(math, ams, rel, "\u2242", "\\eqsim", true); +defineSymbol(math, main, rel, "\u22c8", "\\Join"); +defineSymbol(math, ams, rel, "\u2251", "\\Doteq", true); + +// AMS Binary Operators +defineSymbol(math, ams, bin, "\u2214", "\\dotplus", true); +defineSymbol(math, ams, bin, "\u2216", "\\smallsetminus"); +defineSymbol(math, ams, bin, "\u22d2", "\\Cap", true); +defineSymbol(math, ams, bin, "\u22d3", "\\Cup", true); +defineSymbol(math, ams, bin, "\u2a5e", "\\doublebarwedge", true); +defineSymbol(math, ams, bin, "\u229f", "\\boxminus", true); +defineSymbol(math, ams, bin, "\u229e", "\\boxplus", true); +defineSymbol(math, ams, bin, "\u22c7", "\\divideontimes", true); +defineSymbol(math, ams, bin, "\u22c9", "\\ltimes", true); +defineSymbol(math, ams, bin, "\u22ca", "\\rtimes", true); +defineSymbol(math, ams, bin, "\u22cb", "\\leftthreetimes", true); +defineSymbol(math, ams, bin, "\u22cc", "\\rightthreetimes", true); +defineSymbol(math, ams, bin, "\u22cf", "\\curlywedge", true); +defineSymbol(math, ams, bin, "\u22ce", "\\curlyvee", true); +defineSymbol(math, ams, bin, "\u229d", "\\circleddash", true); +defineSymbol(math, ams, bin, "\u229b", "\\circledast", true); +defineSymbol(math, ams, bin, "\u22c5", "\\centerdot"); +defineSymbol(math, ams, bin, "\u22ba", "\\intercal", true); +defineSymbol(math, ams, bin, "\u22d2", "\\doublecap"); +defineSymbol(math, ams, bin, "\u22d3", "\\doublecup"); +defineSymbol(math, ams, bin, "\u22a0", "\\boxtimes", true); + +// AMS Arrows +// Note: unicode-math maps \u21e2 to their own function \rightdasharrow. +// We'll map it to AMS function \dashrightarrow. It produces the same atom. +defineSymbol(math, ams, rel, "\u21e2", "\\dashrightarrow", true); +// unicode-math maps \u21e0 to \leftdasharrow. We'll use the AMS synonym. +defineSymbol(math, ams, rel, "\u21e0", "\\dashleftarrow", true); +defineSymbol(math, ams, rel, "\u21c7", "\\leftleftarrows", true); +defineSymbol(math, ams, rel, "\u21c6", "\\leftrightarrows", true); +defineSymbol(math, ams, rel, "\u21da", "\\Lleftarrow", true); +defineSymbol(math, ams, rel, "\u219e", "\\twoheadleftarrow", true); +defineSymbol(math, ams, rel, "\u21a2", "\\leftarrowtail", true); +defineSymbol(math, ams, rel, "\u21ab", "\\looparrowleft", true); +defineSymbol(math, ams, rel, "\u21cb", "\\leftrightharpoons", true); +defineSymbol(math, ams, rel, "\u21b6", "\\curvearrowleft", true); +// unicode-math maps \u21ba to \acwopencirclearrow. We'll use the AMS synonym. +defineSymbol(math, ams, rel, "\u21ba", "\\circlearrowleft", true); +defineSymbol(math, ams, rel, "\u21b0", "\\Lsh", true); +defineSymbol(math, ams, rel, "\u21c8", "\\upuparrows", true); +defineSymbol(math, ams, rel, "\u21bf", "\\upharpoonleft", true); +defineSymbol(math, ams, rel, "\u21c3", "\\downharpoonleft", true); +defineSymbol(math, main, rel, "\u22b6", "\\origof", true); // not in font +defineSymbol(math, main, rel, "\u22b7", "\\imageof", true); // not in font +defineSymbol(math, ams, rel, "\u22b8", "\\multimap", true); +defineSymbol(math, ams, rel, "\u21ad", "\\leftrightsquigarrow", true); +defineSymbol(math, ams, rel, "\u21c9", "\\rightrightarrows", true); +defineSymbol(math, ams, rel, "\u21c4", "\\rightleftarrows", true); +defineSymbol(math, ams, rel, "\u21a0", "\\twoheadrightarrow", true); +defineSymbol(math, ams, rel, "\u21a3", "\\rightarrowtail", true); +defineSymbol(math, ams, rel, "\u21ac", "\\looparrowright", true); +defineSymbol(math, ams, rel, "\u21b7", "\\curvearrowright", true); +// unicode-math maps \u21bb to \cwopencirclearrow. We'll use the AMS synonym. +defineSymbol(math, ams, rel, "\u21bb", "\\circlearrowright", true); +defineSymbol(math, ams, rel, "\u21b1", "\\Rsh", true); +defineSymbol(math, ams, rel, "\u21ca", "\\downdownarrows", true); +defineSymbol(math, ams, rel, "\u21be", "\\upharpoonright", true); +defineSymbol(math, ams, rel, "\u21c2", "\\downharpoonright", true); +defineSymbol(math, ams, rel, "\u21dd", "\\rightsquigarrow", true); +defineSymbol(math, ams, rel, "\u21dd", "\\leadsto"); +defineSymbol(math, ams, rel, "\u21db", "\\Rrightarrow", true); +defineSymbol(math, ams, rel, "\u21be", "\\restriction"); +defineSymbol(math, main, textord, "\u2018", "`"); +defineSymbol(math, main, textord, "$", "\\$"); +defineSymbol(symbols_text, main, textord, "$", "\\$"); +defineSymbol(symbols_text, main, textord, "$", "\\textdollar"); +defineSymbol(math, main, textord, "%", "\\%"); +defineSymbol(symbols_text, main, textord, "%", "\\%"); +defineSymbol(math, main, textord, "_", "\\_"); +defineSymbol(symbols_text, main, textord, "_", "\\_"); +defineSymbol(symbols_text, main, textord, "_", "\\textunderscore"); +defineSymbol(math, main, textord, "\u2220", "\\angle", true); +defineSymbol(math, main, textord, "\u221e", "\\infty", true); +defineSymbol(math, main, textord, "\u2032", "\\prime"); +defineSymbol(math, main, textord, "\u25b3", "\\triangle"); +defineSymbol(math, main, textord, "\u0393", "\\Gamma", true); +defineSymbol(math, main, textord, "\u0394", "\\Delta", true); +defineSymbol(math, main, textord, "\u0398", "\\Theta", true); +defineSymbol(math, main, textord, "\u039b", "\\Lambda", true); +defineSymbol(math, main, textord, "\u039e", "\\Xi", true); +defineSymbol(math, main, textord, "\u03a0", "\\Pi", true); +defineSymbol(math, main, textord, "\u03a3", "\\Sigma", true); +defineSymbol(math, main, textord, "\u03a5", "\\Upsilon", true); +defineSymbol(math, main, textord, "\u03a6", "\\Phi", true); +defineSymbol(math, main, textord, "\u03a8", "\\Psi", true); +defineSymbol(math, main, textord, "\u03a9", "\\Omega", true); +defineSymbol(math, main, textord, "A", "\u0391"); +defineSymbol(math, main, textord, "B", "\u0392"); +defineSymbol(math, main, textord, "E", "\u0395"); +defineSymbol(math, main, textord, "Z", "\u0396"); +defineSymbol(math, main, textord, "H", "\u0397"); +defineSymbol(math, main, textord, "I", "\u0399"); +defineSymbol(math, main, textord, "K", "\u039A"); +defineSymbol(math, main, textord, "M", "\u039C"); +defineSymbol(math, main, textord, "N", "\u039D"); +defineSymbol(math, main, textord, "O", "\u039F"); +defineSymbol(math, main, textord, "P", "\u03A1"); +defineSymbol(math, main, textord, "T", "\u03A4"); +defineSymbol(math, main, textord, "X", "\u03A7"); +defineSymbol(math, main, textord, "\u00ac", "\\neg", true); +defineSymbol(math, main, textord, "\u00ac", "\\lnot"); +defineSymbol(math, main, textord, "\u22a4", "\\top"); +defineSymbol(math, main, textord, "\u22a5", "\\bot"); +defineSymbol(math, main, textord, "\u2205", "\\emptyset"); +defineSymbol(math, ams, textord, "\u2205", "\\varnothing"); +defineSymbol(math, main, mathord, "\u03b1", "\\alpha", true); +defineSymbol(math, main, mathord, "\u03b2", "\\beta", true); +defineSymbol(math, main, mathord, "\u03b3", "\\gamma", true); +defineSymbol(math, main, mathord, "\u03b4", "\\delta", true); +defineSymbol(math, main, mathord, "\u03f5", "\\epsilon", true); +defineSymbol(math, main, mathord, "\u03b6", "\\zeta", true); +defineSymbol(math, main, mathord, "\u03b7", "\\eta", true); +defineSymbol(math, main, mathord, "\u03b8", "\\theta", true); +defineSymbol(math, main, mathord, "\u03b9", "\\iota", true); +defineSymbol(math, main, mathord, "\u03ba", "\\kappa", true); +defineSymbol(math, main, mathord, "\u03bb", "\\lambda", true); +defineSymbol(math, main, mathord, "\u03bc", "\\mu", true); +defineSymbol(math, main, mathord, "\u03bd", "\\nu", true); +defineSymbol(math, main, mathord, "\u03be", "\\xi", true); +defineSymbol(math, main, mathord, "\u03bf", "\\omicron", true); +defineSymbol(math, main, mathord, "\u03c0", "\\pi", true); +defineSymbol(math, main, mathord, "\u03c1", "\\rho", true); +defineSymbol(math, main, mathord, "\u03c3", "\\sigma", true); +defineSymbol(math, main, mathord, "\u03c4", "\\tau", true); +defineSymbol(math, main, mathord, "\u03c5", "\\upsilon", true); +defineSymbol(math, main, mathord, "\u03d5", "\\phi", true); +defineSymbol(math, main, mathord, "\u03c7", "\\chi", true); +defineSymbol(math, main, mathord, "\u03c8", "\\psi", true); +defineSymbol(math, main, mathord, "\u03c9", "\\omega", true); +defineSymbol(math, main, mathord, "\u03b5", "\\varepsilon", true); +defineSymbol(math, main, mathord, "\u03d1", "\\vartheta", true); +defineSymbol(math, main, mathord, "\u03d6", "\\varpi", true); +defineSymbol(math, main, mathord, "\u03f1", "\\varrho", true); +defineSymbol(math, main, mathord, "\u03c2", "\\varsigma", true); +defineSymbol(math, main, mathord, "\u03c6", "\\varphi", true); +defineSymbol(math, main, bin, "\u2217", "*", true); +defineSymbol(math, main, bin, "+", "+"); +defineSymbol(math, main, bin, "\u2212", "-", true); +defineSymbol(math, main, bin, "\u22c5", "\\cdot", true); +defineSymbol(math, main, bin, "\u2218", "\\circ", true); +defineSymbol(math, main, bin, "\u00f7", "\\div", true); +defineSymbol(math, main, bin, "\u00b1", "\\pm", true); +defineSymbol(math, main, bin, "\u00d7", "\\times", true); +defineSymbol(math, main, bin, "\u2229", "\\cap", true); +defineSymbol(math, main, bin, "\u222a", "\\cup", true); +defineSymbol(math, main, bin, "\u2216", "\\setminus", true); +defineSymbol(math, main, bin, "\u2227", "\\land"); +defineSymbol(math, main, bin, "\u2228", "\\lor"); +defineSymbol(math, main, bin, "\u2227", "\\wedge", true); +defineSymbol(math, main, bin, "\u2228", "\\vee", true); +defineSymbol(math, main, textord, "\u221a", "\\surd"); +defineSymbol(math, main, symbols_open, "\u27e8", "\\langle", true); +defineSymbol(math, main, symbols_open, "\u2223", "\\lvert"); +defineSymbol(math, main, symbols_open, "\u2225", "\\lVert"); +defineSymbol(math, main, symbols_close, "?", "?"); +defineSymbol(math, main, symbols_close, "!", "!"); +defineSymbol(math, main, symbols_close, "\u27e9", "\\rangle", true); +defineSymbol(math, main, symbols_close, "\u2223", "\\rvert"); +defineSymbol(math, main, symbols_close, "\u2225", "\\rVert"); +defineSymbol(math, main, rel, "=", "="); +defineSymbol(math, main, rel, ":", ":"); +defineSymbol(math, main, rel, "\u2248", "\\approx", true); +defineSymbol(math, main, rel, "\u2245", "\\cong", true); +defineSymbol(math, main, rel, "\u2265", "\\ge"); +defineSymbol(math, main, rel, "\u2265", "\\geq", true); +defineSymbol(math, main, rel, "\u2190", "\\gets"); +defineSymbol(math, main, rel, ">", "\\gt", true); +defineSymbol(math, main, rel, "\u2208", "\\in", true); +defineSymbol(math, main, rel, "\ue020", "\\@not"); +defineSymbol(math, main, rel, "\u2282", "\\subset", true); +defineSymbol(math, main, rel, "\u2283", "\\supset", true); +defineSymbol(math, main, rel, "\u2286", "\\subseteq", true); +defineSymbol(math, main, rel, "\u2287", "\\supseteq", true); +defineSymbol(math, ams, rel, "\u2288", "\\nsubseteq", true); +defineSymbol(math, ams, rel, "\u2289", "\\nsupseteq", true); +defineSymbol(math, main, rel, "\u22a8", "\\models"); +defineSymbol(math, main, rel, "\u2190", "\\leftarrow", true); +defineSymbol(math, main, rel, "\u2264", "\\le"); +defineSymbol(math, main, rel, "\u2264", "\\leq", true); +defineSymbol(math, main, rel, "<", "\\lt", true); +defineSymbol(math, main, rel, "\u2192", "\\rightarrow", true); +defineSymbol(math, main, rel, "\u2192", "\\to"); +defineSymbol(math, ams, rel, "\u2271", "\\ngeq", true); +defineSymbol(math, ams, rel, "\u2270", "\\nleq", true); +defineSymbol(math, main, spacing, "\u00a0", "\\ "); +defineSymbol(math, main, spacing, "\u00a0", "\\space"); +// Ref: LaTeX Source 2e: \DeclareRobustCommand{\nobreakspace}{% +defineSymbol(math, main, spacing, "\u00a0", "\\nobreakspace"); +defineSymbol(symbols_text, main, spacing, "\u00a0", "\\ "); +defineSymbol(symbols_text, main, spacing, "\u00a0", " "); +defineSymbol(symbols_text, main, spacing, "\u00a0", "\\space"); +defineSymbol(symbols_text, main, spacing, "\u00a0", "\\nobreakspace"); +defineSymbol(math, main, spacing, "", "\\nobreak"); +defineSymbol(math, main, spacing, "", "\\allowbreak"); +defineSymbol(math, main, punct, ",", ","); +defineSymbol(math, main, punct, ";", ";"); +defineSymbol(math, ams, bin, "\u22bc", "\\barwedge", true); +defineSymbol(math, ams, bin, "\u22bb", "\\veebar", true); +defineSymbol(math, main, bin, "\u2299", "\\odot", true); +defineSymbol(math, main, bin, "\u2295", "\\oplus", true); +defineSymbol(math, main, bin, "\u2297", "\\otimes", true); +defineSymbol(math, main, textord, "\u2202", "\\partial", true); +defineSymbol(math, main, bin, "\u2298", "\\oslash", true); +defineSymbol(math, ams, bin, "\u229a", "\\circledcirc", true); +defineSymbol(math, ams, bin, "\u22a1", "\\boxdot", true); +defineSymbol(math, main, bin, "\u25b3", "\\bigtriangleup"); +defineSymbol(math, main, bin, "\u25bd", "\\bigtriangledown"); +defineSymbol(math, main, bin, "\u2020", "\\dagger"); +defineSymbol(math, main, bin, "\u22c4", "\\diamond"); +defineSymbol(math, main, bin, "\u22c6", "\\star"); +defineSymbol(math, main, bin, "\u25c3", "\\triangleleft"); +defineSymbol(math, main, bin, "\u25b9", "\\triangleright"); +defineSymbol(math, main, symbols_open, "{", "\\{"); +defineSymbol(symbols_text, main, textord, "{", "\\{"); +defineSymbol(symbols_text, main, textord, "{", "\\textbraceleft"); +defineSymbol(math, main, symbols_close, "}", "\\}"); +defineSymbol(symbols_text, main, textord, "}", "\\}"); +defineSymbol(symbols_text, main, textord, "}", "\\textbraceright"); +defineSymbol(math, main, symbols_open, "{", "\\lbrace"); +defineSymbol(math, main, symbols_close, "}", "\\rbrace"); +defineSymbol(math, main, symbols_open, "[", "\\lbrack", true); +defineSymbol(symbols_text, main, textord, "[", "\\lbrack", true); +defineSymbol(math, main, symbols_close, "]", "\\rbrack", true); +defineSymbol(symbols_text, main, textord, "]", "\\rbrack", true); +defineSymbol(math, main, symbols_open, "(", "\\lparen", true); +defineSymbol(math, main, symbols_close, ")", "\\rparen", true); +defineSymbol(symbols_text, main, textord, "<", "\\textless", true); // in T1 fontenc +defineSymbol(symbols_text, main, textord, ">", "\\textgreater", true); // in T1 fontenc +defineSymbol(math, main, symbols_open, "\u230a", "\\lfloor", true); +defineSymbol(math, main, symbols_close, "\u230b", "\\rfloor", true); +defineSymbol(math, main, symbols_open, "\u2308", "\\lceil", true); +defineSymbol(math, main, symbols_close, "\u2309", "\\rceil", true); +defineSymbol(math, main, textord, "\\", "\\backslash"); +defineSymbol(math, main, textord, "\u2223", "|"); +defineSymbol(math, main, textord, "\u2223", "\\vert"); +defineSymbol(symbols_text, main, textord, "|", "\\textbar", true); // in T1 fontenc +defineSymbol(math, main, textord, "\u2225", "\\|"); +defineSymbol(math, main, textord, "\u2225", "\\Vert"); +defineSymbol(symbols_text, main, textord, "\u2225", "\\textbardbl"); +defineSymbol(symbols_text, main, textord, "~", "\\textasciitilde"); +defineSymbol(symbols_text, main, textord, "\\", "\\textbackslash"); +defineSymbol(symbols_text, main, textord, "^", "\\textasciicircum"); +defineSymbol(math, main, rel, "\u2191", "\\uparrow", true); +defineSymbol(math, main, rel, "\u21d1", "\\Uparrow", true); +defineSymbol(math, main, rel, "\u2193", "\\downarrow", true); +defineSymbol(math, main, rel, "\u21d3", "\\Downarrow", true); +defineSymbol(math, main, rel, "\u2195", "\\updownarrow", true); +defineSymbol(math, main, rel, "\u21d5", "\\Updownarrow", true); +defineSymbol(math, main, op, "\u2210", "\\coprod"); +defineSymbol(math, main, op, "\u22c1", "\\bigvee"); +defineSymbol(math, main, op, "\u22c0", "\\bigwedge"); +defineSymbol(math, main, op, "\u2a04", "\\biguplus"); +defineSymbol(math, main, op, "\u22c2", "\\bigcap"); +defineSymbol(math, main, op, "\u22c3", "\\bigcup"); +defineSymbol(math, main, op, "\u222b", "\\int"); +defineSymbol(math, main, op, "\u222b", "\\intop"); +defineSymbol(math, main, op, "\u222c", "\\iint"); +defineSymbol(math, main, op, "\u222d", "\\iiint"); +defineSymbol(math, main, op, "\u220f", "\\prod"); +defineSymbol(math, main, op, "\u2211", "\\sum"); +defineSymbol(math, main, op, "\u2a02", "\\bigotimes"); +defineSymbol(math, main, op, "\u2a01", "\\bigoplus"); +defineSymbol(math, main, op, "\u2a00", "\\bigodot"); +defineSymbol(math, main, op, "\u222e", "\\oint"); +defineSymbol(math, main, op, "\u222f", "\\oiint"); +defineSymbol(math, main, op, "\u2230", "\\oiiint"); +defineSymbol(math, main, op, "\u2a06", "\\bigsqcup"); +defineSymbol(math, main, op, "\u222b", "\\smallint"); +defineSymbol(symbols_text, main, inner, "\u2026", "\\textellipsis"); +defineSymbol(math, main, inner, "\u2026", "\\mathellipsis"); +defineSymbol(symbols_text, main, inner, "\u2026", "\\ldots", true); +defineSymbol(math, main, inner, "\u2026", "\\ldots", true); +defineSymbol(math, main, inner, "\u22ef", "\\@cdots", true); +defineSymbol(math, main, inner, "\u22f1", "\\ddots", true); +// \vdots is a macro that uses one of these two symbols (with made-up names): +defineSymbol(math, main, textord, "\u22ee", "\\varvdots"); +defineSymbol(symbols_text, main, textord, "\u22ee", "\\varvdots"); +defineSymbol(math, main, accent, "\u02ca", "\\acute"); +defineSymbol(math, main, accent, "\u02cb", "\\grave"); +defineSymbol(math, main, accent, "\u00a8", "\\ddot"); +defineSymbol(math, main, accent, "\u007e", "\\tilde"); +defineSymbol(math, main, accent, "\u02c9", "\\bar"); +defineSymbol(math, main, accent, "\u02d8", "\\breve"); +defineSymbol(math, main, accent, "\u02c7", "\\check"); +defineSymbol(math, main, accent, "\u005e", "\\hat"); +defineSymbol(math, main, accent, "\u20d7", "\\vec"); +defineSymbol(math, main, accent, "\u02d9", "\\dot"); +defineSymbol(math, main, accent, "\u02da", "\\mathring"); +// \imath and \jmath should be invariant to \mathrm, \mathbf, etc., so use PUA +defineSymbol(math, main, mathord, "\ue131", "\\@imath"); +defineSymbol(math, main, mathord, "\ue237", "\\@jmath"); +defineSymbol(math, main, textord, "\u0131", "\u0131"); +defineSymbol(math, main, textord, "\u0237", "\u0237"); +defineSymbol(symbols_text, main, textord, "\u0131", "\\i", true); +defineSymbol(symbols_text, main, textord, "\u0237", "\\j", true); +defineSymbol(symbols_text, main, textord, "\u00df", "\\ss", true); +defineSymbol(symbols_text, main, textord, "\u00e6", "\\ae", true); +defineSymbol(symbols_text, main, textord, "\u0153", "\\oe", true); +defineSymbol(symbols_text, main, textord, "\u00f8", "\\o", true); +defineSymbol(symbols_text, main, textord, "\u00c6", "\\AE", true); +defineSymbol(symbols_text, main, textord, "\u0152", "\\OE", true); +defineSymbol(symbols_text, main, textord, "\u00d8", "\\O", true); +defineSymbol(symbols_text, main, accent, "\u02ca", "\\'"); // acute +defineSymbol(symbols_text, main, accent, "\u02cb", "\\`"); // grave +defineSymbol(symbols_text, main, accent, "\u02c6", "\\^"); // circumflex +defineSymbol(symbols_text, main, accent, "\u02dc", "\\~"); // tilde +defineSymbol(symbols_text, main, accent, "\u02c9", "\\="); // macron +defineSymbol(symbols_text, main, accent, "\u02d8", "\\u"); // breve +defineSymbol(symbols_text, main, accent, "\u02d9", "\\."); // dot above +defineSymbol(symbols_text, main, accent, "\u00b8", "\\c"); // cedilla +defineSymbol(symbols_text, main, accent, "\u02da", "\\r"); // ring above +defineSymbol(symbols_text, main, accent, "\u02c7", "\\v"); // caron +defineSymbol(symbols_text, main, accent, "\u00a8", '\\"'); // diaeresis +defineSymbol(symbols_text, main, accent, "\u02dd", "\\H"); // double acute +defineSymbol(symbols_text, main, accent, "\u25ef", "\\textcircled"); // \bigcirc glyph + +// These ligatures are detected and created in Parser.js's `formLigatures`. +const ligatures = { + "--": true, + "---": true, + "``": true, + "''": true +}; +defineSymbol(symbols_text, main, textord, "\u2013", "--", true); +defineSymbol(symbols_text, main, textord, "\u2013", "\\textendash"); +defineSymbol(symbols_text, main, textord, "\u2014", "---", true); +defineSymbol(symbols_text, main, textord, "\u2014", "\\textemdash"); +defineSymbol(symbols_text, main, textord, "\u2018", "`", true); +defineSymbol(symbols_text, main, textord, "\u2018", "\\textquoteleft"); +defineSymbol(symbols_text, main, textord, "\u2019", "'", true); +defineSymbol(symbols_text, main, textord, "\u2019", "\\textquoteright"); +defineSymbol(symbols_text, main, textord, "\u201c", "``", true); +defineSymbol(symbols_text, main, textord, "\u201c", "\\textquotedblleft"); +defineSymbol(symbols_text, main, textord, "\u201d", "''", true); +defineSymbol(symbols_text, main, textord, "\u201d", "\\textquotedblright"); +// \degree from gensymb package +defineSymbol(math, main, textord, "\u00b0", "\\degree", true); +defineSymbol(symbols_text, main, textord, "\u00b0", "\\degree"); +// \textdegree from inputenc package +defineSymbol(symbols_text, main, textord, "\u00b0", "\\textdegree", true); +// TODO: In LaTeX, \pounds can generate a different character in text and math +// mode, but among our fonts, only Main-Regular defines this character "163". +defineSymbol(math, main, textord, "\u00a3", "\\pounds"); +defineSymbol(math, main, textord, "\u00a3", "\\mathsterling", true); +defineSymbol(symbols_text, main, textord, "\u00a3", "\\pounds"); +defineSymbol(symbols_text, main, textord, "\u00a3", "\\textsterling", true); +defineSymbol(math, ams, textord, "\u2720", "\\maltese"); +defineSymbol(symbols_text, ams, textord, "\u2720", "\\maltese"); + +// There are lots of symbols which are the same, so we add them in afterwards. +// All of these are textords in math mode +const mathTextSymbols = "0123456789/@.\""; +for (let i = 0; i < mathTextSymbols.length; i++) { + const ch = mathTextSymbols.charAt(i); + defineSymbol(math, main, textord, ch, ch); +} + +// All of these are textords in text mode +const textSymbols = "0123456789!@*()-=+\";:?/.,"; +for (let i = 0; i < textSymbols.length; i++) { + const ch = textSymbols.charAt(i); + defineSymbol(symbols_text, main, textord, ch, ch); +} + +// All of these are textords in text mode, and mathords in math mode +const letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; +for (let i = 0; i < letters.length; i++) { + const ch = letters.charAt(i); + defineSymbol(math, main, mathord, ch, ch); + defineSymbol(symbols_text, main, textord, ch, ch); +} + +// Blackboard bold and script letters in Unicode range +defineSymbol(math, ams, textord, "C", "\u2102"); // blackboard bold +defineSymbol(symbols_text, ams, textord, "C", "\u2102"); +defineSymbol(math, ams, textord, "H", "\u210D"); +defineSymbol(symbols_text, ams, textord, "H", "\u210D"); +defineSymbol(math, ams, textord, "N", "\u2115"); +defineSymbol(symbols_text, ams, textord, "N", "\u2115"); +defineSymbol(math, ams, textord, "P", "\u2119"); +defineSymbol(symbols_text, ams, textord, "P", "\u2119"); +defineSymbol(math, ams, textord, "Q", "\u211A"); +defineSymbol(symbols_text, ams, textord, "Q", "\u211A"); +defineSymbol(math, ams, textord, "R", "\u211D"); +defineSymbol(symbols_text, ams, textord, "R", "\u211D"); +defineSymbol(math, ams, textord, "Z", "\u2124"); +defineSymbol(symbols_text, ams, textord, "Z", "\u2124"); +defineSymbol(math, main, mathord, "h", "\u210E"); // italic h, Planck constant +defineSymbol(symbols_text, main, mathord, "h", "\u210E"); + +// The next loop loads wide (surrogate pair) characters. +// We support some letters in the Unicode range U+1D400 to U+1D7FF, +// Mathematical Alphanumeric Symbols. +// Some editors do not deal well with wide characters. So don't write the +// string into this file. Instead, create the string from the surrogate pair. +let wideChar; +for (let i = 0; i < letters.length; i++) { + const ch = letters.charAt(i); + + // The hex numbers in the next line are a surrogate pair. + // 0xD835 is the high surrogate for all letters in the range we support. + // 0xDC00 is the low surrogate for bold A. + wideChar = String.fromCharCode(0xD835, 0xDC00 + i); // A-Z a-z bold + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(symbols_text, main, textord, ch, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDC34 + i); // A-Z a-z italic + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(symbols_text, main, textord, ch, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDC68 + i); // A-Z a-z bold italic + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(symbols_text, main, textord, ch, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDD04 + i); // A-Z a-z Fraktur + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(symbols_text, main, textord, ch, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDD6C + i); // A-Z a-z bold Fraktur + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(symbols_text, main, textord, ch, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDDA0 + i); // A-Z a-z sans-serif + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(symbols_text, main, textord, ch, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDDD4 + i); // A-Z a-z sans bold + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(symbols_text, main, textord, ch, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDE08 + i); // A-Z a-z sans italic + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(symbols_text, main, textord, ch, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDE70 + i); // A-Z a-z monospace + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(symbols_text, main, textord, ch, wideChar); + if (i < 26) { + // KaTeX fonts have only capital letters for blackboard bold and script. + // See exception for k below. + wideChar = String.fromCharCode(0xD835, 0xDD38 + i); // A-Z double struck + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(symbols_text, main, textord, ch, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDC9C + i); // A-Z script + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(symbols_text, main, textord, ch, wideChar); + } + + // TODO: Add bold script when it is supported by a KaTeX font. +} +// "k" is the only double struck lower case letter in the KaTeX fonts. +wideChar = String.fromCharCode(0xD835, 0xDD5C); // k double struck +defineSymbol(math, main, mathord, "k", wideChar); +defineSymbol(symbols_text, main, textord, "k", wideChar); + +// Next, some wide character numerals +for (let i = 0; i < 10; i++) { + const ch = i.toString(); + wideChar = String.fromCharCode(0xD835, 0xDFCE + i); // 0-9 bold + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(symbols_text, main, textord, ch, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDFE2 + i); // 0-9 sans serif + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(symbols_text, main, textord, ch, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDFEC + i); // 0-9 bold sans + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(symbols_text, main, textord, ch, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDFF6 + i); // 0-9 monospace + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(symbols_text, main, textord, ch, wideChar); +} + +// We add these Latin-1 letters as symbols for backwards-compatibility, +// but they are not actually in the font, nor are they supported by the +// Unicode accent mechanism, so they fall back to Times font and look ugly. +// TODO(edemaine): Fix this. +const extraLatin = "\u00d0\u00de\u00fe"; +for (let i = 0; i < extraLatin.length; i++) { + const ch = extraLatin.charAt(i); + defineSymbol(math, main, mathord, ch, ch); + defineSymbol(symbols_text, main, textord, ch, ch); +} +;// ./src/wide-character.ts +/** + * This file provides support for Unicode range U+1D400 to U+1D7FF, + * Mathematical Alphanumeric Symbols. + * + * Function wideCharacterFont takes a wide character as input and returns + * the font information necessary to render it properly. + */ + + +const boldUpright = { + mathClass: "mathbf", + textClass: "textbf", + font: "Main-Bold" +}; +const italic = { + mathClass: "mathnormal", + textClass: "textit", + font: "Math-Italic" +}; +const boldItalic = { + mathClass: "boldsymbol", + textClass: "boldsymbol", + font: "Main-BoldItalic" +}; +const script = { + mathClass: "mathscr", + textClass: "textscr", + font: "Script-Regular" +}; +const noFont = { + mathClass: "", + textClass: "", + font: "" +}; +const fraktur = { + mathClass: "mathfrak", + textClass: "textfrak", + font: "Fraktur-Regular" +}; +const doubleStruck = { + mathClass: "mathbb", + textClass: "textbb", + font: "AMS-Regular" +}; +const boldFraktur = { + mathClass: "mathboldfrak", + textClass: "textboldfrak", + font: "Fraktur-Regular" +}; +const sansSerif = { + mathClass: "mathsf", + textClass: "textsf", + font: "SansSerif-Regular" +}; +const boldSansSerif = { + mathClass: "mathboldsf", + textClass: "textboldsf", + font: "SansSerif-Bold" +}; +const italicSansSerif = { + mathClass: "mathitsf", + textClass: "textitsf", + font: "SansSerif-Italic" +}; +const monospace = { + mathClass: "mathtt", + textClass: "texttt", + font: "Typewriter-Regular" +}; + +/** + * Data below is from https://www.unicode.org/charts/PDF/U1D400.pdf + * That document sorts characters into groups by font type, say bold or italic. + * + * In the arrays below, each object consists of three properties: + * * The CSS class of that group when in math mode. + * * The CSS class of that group when in text mode. + * * The font name, so that KaTeX can get font metrics. + */ + +const wideLatinLetterData = [boldUpright, boldUpright, +// A-Z, a-z +italic, italic, +// A-Z, a-z +boldItalic, boldItalic, +// A-Z, a-z +// Map fancy A-Z letters to script, not calligraphic. +// This aligns with unicode-math and math fonts (except Cambria Math). +script, noFont, +// A-Z script, a-z — no font +noFont, noFont, +// A-Z bold script, a-z bold script — no font +fraktur, fraktur, +// A-Z, a-z +doubleStruck, doubleStruck, +// A-Z double-struck, k double-struck +// Note that we are using a bold font, but font metrics for regular Fraktur. +boldFraktur, boldFraktur, +// A-Z, a-z +sansSerif, sansSerif, +// A-Z, a-z +boldSansSerif, boldSansSerif, +// A-Z, a-z +italicSansSerif, italicSansSerif, +// A-Z, a-z +noFont, noFont, +// A-Z bold italic sans, a-z bold italic sans - no font +monospace, monospace // A-Z, a-z +]; +const wideNumeralData = [boldUpright, +// 0-9 +noFont, +// 0-9 double-struck. No KaTeX font. +sansSerif, +// 0-9 +boldSansSerif, +// 0-9 +monospace // 0-9 +]; +const wideCharacterFont = wideChar => { + // IE doesn't support codePointAt(). So work with the surrogate pair. + const H = wideChar.charCodeAt(0); // high surrogate + const L = wideChar.charCodeAt(1); // low surrogate + const codePoint = (H - 0xD800) * 0x400 + (L - 0xDC00) + 0x10000; + if (0x1D400 <= codePoint && codePoint < 0x1D6A4) { + // wideLatinLetterData contains exactly 26 chars on each row. + // So we can calculate the relevant row. No traverse necessary. + const i = Math.floor((codePoint - 0x1D400) / 26); + return wideLatinLetterData[i]; + } else if (0x1D7CE <= codePoint && codePoint <= 0x1D7FF) { + // Numerals, ten per row. + const i = Math.floor((codePoint - 0x1D7CE) / 10); + return wideNumeralData[i]; + } else if (codePoint === 0x1D6A5 || codePoint === 0x1D6A6) { + // dotless i or j + return wideLatinLetterData[0]; + } else if (0x1D6A6 < codePoint && codePoint < 0x1D7CE) { + // Greek letters. Not supported, yet. + return noFont; + } else { + // We don't support any wide characters outside 1D400–1D7FF. + throw new src_ParseError("Unsupported character: " + wideChar); + } +}; +;// ./src/buildCommon.ts +/* eslint no-console:0 */ +/** + * This module contains general functions that can be used for building + * different kinds of domTree nodes in a consistent manner. + */ + + + + + + + +/** + * Looks up the given symbol in fontMetrics, after applying any symbol + * replacements defined in symbol.js + */ +const lookupSymbol = function (value, fontName, mode) { + // Replace the value with its replaced value from symbol.js + if (src_symbols[mode][value]) { + const replacement = src_symbols[mode][value].replace; + if (replacement) { + value = replacement; + } + } + return { + value, + metrics: getCharacterMetrics(value, fontName, mode) + }; +}; + +/** + * Makes a symbolNode after translation via the list of symbols in symbols.js. + * Correctly pulls out metrics for the character, and optionally takes a list of + * classes to be attached to the node. + * + * TODO: make argument order closer to makeSpan + * TODO: add a separate argument for math class (e.g. `mop`, `mbin`), which + * should if present come first in `classes`. + * TODO(#953): Make `options` mandatory and always pass it in. + */ +const makeSymbol = function (value, fontName, mode, options, classes) { + const lookup = lookupSymbol(value, fontName, mode); + const metrics = lookup.metrics; + value = lookup.value; + let symbolNode; + if (metrics) { + let italic = metrics.italic; + if (mode === "text" || options && options.font === "mathit") { + italic = 0; + } + symbolNode = new SymbolNode(value, metrics.height, metrics.depth, italic, metrics.skew, metrics.width, classes); + } else { + // TODO(emily): Figure out a good way to only print this in development + typeof console !== "undefined" && console.warn("No character metrics " + ("for '" + value + "' in style '" + fontName + "' and mode '" + mode + "'")); + symbolNode = new SymbolNode(value, 0, 0, 0, 0, 0, classes); + } + if (options) { + symbolNode.maxFontSize = options.sizeMultiplier; + if (options.style.isTight()) { + symbolNode.classes.push("mtight"); + } + const color = options.getColor(); + if (color) { + symbolNode.style.color = color; + } + } + return symbolNode; +}; + +/** + * Makes a symbol in Main-Regular or AMS-Regular. + * Used for rel, bin, open, close, inner, and punct. + */ +const mathsym = function (value, mode, options, classes) { + if (classes === void 0) { + classes = []; + } + // Decide what font to render the symbol in by its entry in the symbols + // table. + // Have a special case for when the value = \ because the \ is used as a + // textord in unsupported command errors but cannot be parsed as a regular + // text ordinal and is therefore not present as a symbol in the symbols + // table for text, as well as a special case for boldsymbol because it + // can be used for bold + and - + if (options.font === "boldsymbol" && lookupSymbol(value, "Main-Bold", mode).metrics) { + return makeSymbol(value, "Main-Bold", mode, options, classes.concat(["mathbf"])); + } else if (value === "\\" || src_symbols[mode][value].font === "main") { + return makeSymbol(value, "Main-Regular", mode, options, classes); + } else { + return makeSymbol(value, "AMS-Regular", mode, options, classes.concat(["amsrm"])); + } +}; + +/** + * Determines which of the two font names (Main-Bold and Math-BoldItalic) and + * corresponding style tags (mathbf or boldsymbol) to use for font "boldsymbol", + * depending on the symbol. Use this function instead of fontMap for font + * "boldsymbol". + */ +const boldSymbol = function (value, mode, type) { + if (type !== "textord" && lookupSymbol(value, "Math-BoldItalic", mode).metrics) { + return { + fontName: "Math-BoldItalic", + fontClass: "boldsymbol" + }; + } else { + // Some glyphs do not exist in Math-BoldItalic so we need to use + // Main-Bold instead. + return { + fontName: "Main-Bold", + fontClass: "mathbf" + }; + } +}; + +/** + * Makes either a mathord or textord in the correct font and color. + */ +const makeOrd = function (group, options, type) { + const mode = group.mode; + const text = group.text; + const classes = ["mord"]; + const { + font, + fontFamily, + fontWeight, + fontShape + } = options; + + // Math mode or Old font (i.e. \rm) + const useFont = mode === "math" || mode === "text" && !!font; + const fontOrFamily = useFont ? font : fontFamily; + let wideFontName = ""; + let wideFontClass = ""; + if (text.charCodeAt(0) === 0xD835) { + const wideCharData = wideCharacterFont(text); + wideFontName = wideCharData.font; + wideFontClass = wideCharData[mode + "Class"]; + } + if (wideFontName) { + // surrogate pairs get special treatment + return makeSymbol(text, wideFontName, mode, options, classes.concat(wideFontClass)); + } else if (fontOrFamily) { + let fontName; + let fontClasses; + if (fontOrFamily === "boldsymbol") { + const fontData = boldSymbol(text, mode, type); + fontName = fontData.fontName; + fontClasses = [fontData.fontClass]; + } else if (useFont) { + fontName = fontMap[font].fontName; + fontClasses = [font]; + } else { + fontName = retrieveTextFontName(fontFamily, fontWeight, fontShape); + fontClasses = [fontFamily, fontWeight, fontShape]; + } + if (lookupSymbol(text, fontName, mode).metrics) { + return makeSymbol(text, fontName, mode, options, classes.concat(fontClasses)); + } else if (ligatures.hasOwnProperty(text) && fontName.slice(0, 10) === "Typewriter") { + // Deconstruct ligatures in monospace fonts (\texttt, \tt). + const parts = []; + for (let i = 0; i < text.length; i++) { + parts.push(makeSymbol(text[i], fontName, mode, options, classes.concat(fontClasses))); + } + return makeFragment(parts); + } + } + + // Makes a symbol in the default font for mathords and textords. + if (type === "mathord") { + return makeSymbol(text, "Math-Italic", mode, options, classes.concat(["mathnormal"])); + } else if (type === "textord") { + const font = src_symbols[mode][text] && src_symbols[mode][text].font; + if (font === "ams") { + const fontName = retrieveTextFontName("amsrm", fontWeight, fontShape); + return makeSymbol(text, fontName, mode, options, classes.concat("amsrm", fontWeight, fontShape)); + } else if (font === "main" || !font) { + const fontName = retrieveTextFontName("textrm", fontWeight, fontShape); + return makeSymbol(text, fontName, mode, options, classes.concat(fontWeight, fontShape)); + } else { + // fonts added by plugins + const fontName = retrieveTextFontName(font, fontWeight, fontShape); + // We add font name as a css class + return makeSymbol(text, fontName, mode, options, classes.concat(fontName, fontWeight, fontShape)); + } + } else { + throw new Error("unexpected type: " + type + " in makeOrd"); + } +}; + +/** + * Returns true if subsequent symbolNodes have the same classes, skew, maxFont, + * and styles. For mathnormal text, the left node must also have zero italic + * correction so we don't lose spacing between combined glyphs. + */ +const canCombine = (prev, next) => { + if (createClass(prev.classes) !== createClass(next.classes) || prev.skew !== next.skew || prev.maxFontSize !== next.maxFontSize || prev.italic !== 0 && prev.hasClass("mathnormal")) { + return false; + } + + // If prev and next both are just "mbin"s or "mord"s we don't combine them + // so that the proper spacing can be preserved. + if (prev.classes.length === 1) { + const cls = prev.classes[0]; + if (cls === "mbin" || cls === "mord") { + return false; + } + } + for (const key of Object.keys(prev.style)) { + if (prev.style[key] !== next.style[key]) { + return false; + } + } + for (const key of Object.keys(next.style)) { + if (prev.style[key] !== next.style[key]) { + return false; + } + } + return true; +}; + +/** + * Combine consecutive domTree.symbolNodes into a single symbolNode. + * Note: this function mutates the argument. + */ +const tryCombineChars = chars => { + for (let i = 0; i < chars.length - 1; i++) { + const prev = chars[i]; + const next = chars[i + 1]; + if (prev instanceof SymbolNode && next instanceof SymbolNode && canCombine(prev, next)) { + prev.text += next.text; + prev.height = Math.max(prev.height, next.height); + prev.depth = Math.max(prev.depth, next.depth); + // Use the last character's italic correction since we use + // it to add padding to the right of the span created from + // the combined characters. + prev.italic = next.italic; + chars.splice(i + 1, 1); + i--; + } + } + return chars; +}; + +/** + * Calculate the height, depth, and maxFontSize of an element based on its + * children. + */ +const sizeElementFromChildren = function (elem) { + let height = 0; + let depth = 0; + let maxFontSize = 0; + for (let i = 0; i < elem.children.length; i++) { + const child = elem.children[i]; + if (child.height > height) { + height = child.height; + } + if (child.depth > depth) { + depth = child.depth; + } + if (child.maxFontSize > maxFontSize) { + maxFontSize = child.maxFontSize; + } + } + elem.height = height; + elem.depth = depth; + elem.maxFontSize = maxFontSize; +}; + +/** + * Makes a span with the given list of classes, list of children, and options. + * + * TODO(#953): Ensure that `options` is always provided (currently some call + * sites don't pass it) and make the type below mandatory. + * TODO: add a separate argument for math class (e.g. `mop`, `mbin`), which + * should if present come first in `classes`. + */ +const makeSpan = function (classes, children, options, style) { + const span = new Span(classes, children, options, style); + sizeElementFromChildren(span); + return span; +}; + +// SVG one is simpler -- doesn't require height, depth, max-font setting. +// This is also a separate method for typesafety. +const makeSvgSpan = (classes, children, options, style) => new Span(classes, children, options, style); +const makeLineSpan = function (className, options, thickness) { + const line = makeSpan([className], [], options); + line.height = Math.max(thickness || options.fontMetrics().defaultRuleThickness, options.minRuleThickness); + line.style.borderBottomWidth = makeEm(line.height); + line.maxFontSize = 1.0; + return line; +}; + +/** + * Makes an anchor with the given href, list of classes, list of children, + * and options. + */ +const makeAnchor = function (href, classes, children, options) { + const anchor = new Anchor(href, classes, children, options); + sizeElementFromChildren(anchor); + return anchor; +}; + +/** + * Makes a document fragment with the given list of children. + */ +const makeFragment = function (children) { + const fragment = new DocumentFragment(children); + sizeElementFromChildren(fragment); + return fragment; +}; + +/** + * Wraps group in a span if it's a document fragment, allowing to apply classes + * and styles + */ +const wrapFragment = function (group, options) { + if (group instanceof DocumentFragment) { + return makeSpan([], [group], options); + } + return group; +}; + +// A list of child or kern nodes to be stacked on top of each other (i.e. the +// first element will be at the bottom, and the last at the top). + +// Computes the updated `children` list and the overall depth. +// +// This helper function for makeVList makes it easier to enforce type safety by +// allowing early exits (returns) in the logic. +const getVListChildrenAndDepth = function (params) { + if (params.positionType === "individualShift") { + const oldChildren = params.children; + const children = [oldChildren[0]]; + + // Add in kerns to the list of params.children to get each element to be + // shifted to the correct specified shift + const depth = -oldChildren[0].shift - oldChildren[0].elem.depth; + let currPos = depth; + for (let i = 1; i < oldChildren.length; i++) { + const diff = -oldChildren[i].shift - currPos - oldChildren[i].elem.depth; + const size = diff - (oldChildren[i - 1].elem.height + oldChildren[i - 1].elem.depth); + currPos = currPos + diff; + children.push({ + type: "kern", + size + }); + children.push(oldChildren[i]); + } + return { + children, + depth + }; + } + let depth; + if (params.positionType === "top") { + // We always start at the bottom, so calculate the bottom by adding up + // all the sizes + let bottom = params.positionData; + for (let i = 0; i < params.children.length; i++) { + const child = params.children[i]; + bottom -= child.type === "kern" ? child.size : child.elem.height + child.elem.depth; + } + depth = bottom; + } else if (params.positionType === "bottom") { + depth = -params.positionData; + } else { + const firstChild = params.children[0]; + if (firstChild.type !== "elem") { + throw new Error('First child must have type "elem".'); + } + if (params.positionType === "shift") { + depth = -firstChild.elem.depth - params.positionData; + } else if (params.positionType === "firstBaseline") { + depth = -firstChild.elem.depth; + } else { + throw new Error("Invalid positionType " + params.positionType + "."); + } + } + return { + children: params.children, + depth + }; +}; + +/** + * Makes a vertical list by stacking elements and kerns on top of each other. + * Allows for many different ways of specifying the positioning method. + * + * See VListParam documentation above. + */ +const makeVList = function (params, options) { + const { + children, + depth + } = getVListChildrenAndDepth(params); + + // Create a strut that is taller than any list item. The strut is added to + // each item, where it will determine the item's baseline. Since it has + // `overflow:hidden`, the strut's top edge will sit on the item's line box's + // top edge and the strut's bottom edge will sit on the item's baseline, + // with no additional line-height spacing. This allows the item baseline to + // be positioned precisely without worrying about font ascent and + // line-height. + let pstrutSize = 0; + for (let i = 0; i < children.length; i++) { + const child = children[i]; + if (child.type === "elem") { + const elem = child.elem; + pstrutSize = Math.max(pstrutSize, elem.maxFontSize, elem.height); + } + } + pstrutSize += 2; + const pstrut = makeSpan(["pstrut"], []); + pstrut.style.height = makeEm(pstrutSize); + + // Create a new list of actual children at the correct offsets + const realChildren = []; + let minPos = depth; + let maxPos = depth; + let currPos = depth; + for (let i = 0; i < children.length; i++) { + const child = children[i]; + if (child.type === "kern") { + currPos += child.size; + } else { + const elem = child.elem; + const classes = child.wrapperClasses || []; + const style = child.wrapperStyle || {}; + const childWrap = makeSpan(classes, [pstrut, elem], undefined, style); + childWrap.style.top = makeEm(-pstrutSize - currPos - elem.depth); + if (child.marginLeft) { + childWrap.style.marginLeft = child.marginLeft; + } + if (child.marginRight) { + childWrap.style.marginRight = child.marginRight; + } + realChildren.push(childWrap); + currPos += elem.height + elem.depth; + } + minPos = Math.min(minPos, currPos); + maxPos = Math.max(maxPos, currPos); + } + + // The vlist contents go in a table-cell with `vertical-align:bottom`. + // This cell's bottom edge will determine the containing table's baseline + // without overly expanding the containing line-box. + const vlist = makeSpan(["vlist"], realChildren); + vlist.style.height = makeEm(maxPos); + + // A second row is used if necessary to represent the vlist's depth. + let rows; + if (minPos < 0) { + // We will define depth in an empty span with display: table-cell. + // It should render with the height that we define. But Chrome, in + // contenteditable mode only, treats that span as if it contains some + // text content. And that min-height over-rides our desired height. + // So we put another empty span inside the depth strut span. + const emptySpan = makeSpan([], []); + const depthStrut = makeSpan(["vlist"], [emptySpan]); + depthStrut.style.height = makeEm(-minPos); + + // Safari wants the first row to have inline content; otherwise it + // puts the bottom of the *second* row on the baseline. + const topStrut = makeSpan(["vlist-s"], [new SymbolNode("\u200b")]); + rows = [makeSpan(["vlist-r"], [vlist, topStrut]), makeSpan(["vlist-r"], [depthStrut])]; + } else { + rows = [makeSpan(["vlist-r"], [vlist])]; + } + const vtable = makeSpan(["vlist-t"], rows); + if (rows.length === 2) { + vtable.classes.push("vlist-t2"); + } + vtable.height = maxPos; + vtable.depth = -minPos; + return vtable; +}; + +// Glue is a concept from TeX which is a flexible space between elements in +// either a vertical or horizontal list. In KaTeX, at least for now, it's +// static space between elements in a horizontal layout. +const makeGlue = (measurement, options) => { + // Make an empty span for the space + const rule = makeSpan(["mspace"], [], options); + const size = calculateSize(measurement, options); + rule.style.marginRight = makeEm(size); + return rule; +}; + +// Takes font options, and returns the appropriate fontLookup name +const retrieveTextFontName = (fontFamily, fontWeight, fontShape) => { + let baseFontName; + let fontStylesName; + switch (fontFamily) { + case "amsrm": + baseFontName = "AMS"; + break; + case "textrm": + baseFontName = "Main"; + break; + case "textsf": + baseFontName = "SansSerif"; + break; + case "texttt": + baseFontName = "Typewriter"; + break; + default: + baseFontName = fontFamily; + // use fonts added by a plugin + } + if (fontWeight === "textbf" && fontShape === "textit") { + fontStylesName = "BoldItalic"; + } else if (fontWeight === "textbf") { + fontStylesName = "Bold"; + } else if (fontShape === "textit") { + fontStylesName = "Italic"; + } else { + fontStylesName = "Regular"; + } + return baseFontName + "-" + fontStylesName; +}; + +/** + * Maps TeX font commands to objects containing: + * - variant: string used for "mathvariant" attribute in buildMathML.js + * - fontName: the "style" parameter to fontMetrics.getCharacterMetrics + */ +// A map between tex font commands an MathML mathvariant attribute values +const fontMap = { + // styles + "mathbf": { + variant: "bold", + fontName: "Main-Bold" + }, + "mathrm": { + variant: "normal", + fontName: "Main-Regular" + }, + "textit": { + variant: "italic", + fontName: "Main-Italic" + }, + "mathit": { + variant: "italic", + fontName: "Main-Italic" + }, + "mathnormal": { + variant: "italic", + fontName: "Math-Italic" + }, + "mathsfit": { + variant: "sans-serif-italic", + fontName: "SansSerif-Italic" + }, + // "boldsymbol" is missing because they require the use of multiple fonts: + // Math-BoldItalic and Main-Bold. This is handled by a special case in + // makeOrd which ends up calling boldsymbol. + + // families + "mathbb": { + variant: "double-struck", + fontName: "AMS-Regular" + }, + "mathcal": { + variant: "script", + fontName: "Caligraphic-Regular" + }, + "mathfrak": { + variant: "fraktur", + fontName: "Fraktur-Regular" + }, + "mathscr": { + variant: "script", + fontName: "Script-Regular" + }, + "mathsf": { + variant: "sans-serif", + fontName: "SansSerif-Regular" + }, + "mathtt": { + variant: "monospace", + fontName: "Typewriter-Regular" + } +}; +const svgData = { + // path, width, height + vec: ["vec", 0.471, 0.714], + // values from the font glyph + oiintSize1: ["oiintSize1", 0.957, 0.499], + // oval to overlay the integrand + oiintSize2: ["oiintSize2", 1.472, 0.659], + oiiintSize1: ["oiiintSize1", 1.304, 0.499], + oiiintSize2: ["oiiintSize2", 1.98, 0.659] +}; +const staticSvg = function (value, options) { + // Create a span with inline SVG for the element. + const [pathName, width, height] = svgData[value]; + const path = new PathNode(pathName); + const svgNode = new SvgNode([path], { + "width": makeEm(width), + "height": makeEm(height), + // Override CSS rule `.katex svg { width: 100% }` + "style": "width:" + makeEm(width), + "viewBox": "0 0 " + 1000 * width + " " + 1000 * height, + "preserveAspectRatio": "xMinYMin" + }); + const span = makeSvgSpan(["overlay"], [svgNode], options); + span.height = height; + span.style.height = makeEm(height); + span.style.width = makeEm(width); + return span; +}; +;// ./src/spacingData.ts +/** + * Describes spaces between different classes of atoms. + */ + +const thinspace = { + number: 3, + unit: "mu" +}; +const mediumspace = { + number: 4, + unit: "mu" +}; +const thickspace = { + number: 5, + unit: "mu" +}; + +// Making the type below exact with all optional fields doesn't work due to +// - https://github.com/facebook/flow/issues/4582 +// - https://github.com/facebook/flow/issues/5688 +// However, since *all* fields are optional, $Shape<> works as suggested in 5688 +// above. + +// Spacing relationships for display and text styles +const spacings = { + mord: { + mop: thinspace, + mbin: mediumspace, + mrel: thickspace, + minner: thinspace + }, + mop: { + mord: thinspace, + mop: thinspace, + mrel: thickspace, + minner: thinspace + }, + mbin: { + mord: mediumspace, + mop: mediumspace, + mopen: mediumspace, + minner: mediumspace + }, + mrel: { + mord: thickspace, + mop: thickspace, + mopen: thickspace, + minner: thickspace + }, + mopen: {}, + mclose: { + mop: thinspace, + mbin: mediumspace, + mrel: thickspace, + minner: thinspace + }, + mpunct: { + mord: thinspace, + mop: thinspace, + mrel: thickspace, + mopen: thinspace, + mclose: thinspace, + mpunct: thinspace, + minner: thinspace + }, + minner: { + mord: thinspace, + mop: thinspace, + mbin: mediumspace, + mrel: thickspace, + mopen: thinspace, + mpunct: thinspace, + minner: thinspace + } +}; + +// Spacing relationships for script and scriptscript styles +const tightSpacings = { + mord: { + mop: thinspace + }, + mop: { + mord: thinspace, + mop: thinspace + }, + mbin: {}, + mrel: {}, + mopen: {}, + mclose: { + mop: thinspace + }, + mpunct: {}, + minner: { + mop: thinspace + } +}; +;// ./src/defineFunction.ts +/** Context provided to function handlers for error messages. */ + +// Note: reverse the order of the return type union will cause a flow error. +// See https://github.com/facebook/flow/issues/3663. + +// More general version of `HtmlBuilder` for nodes (e.g. \sum, accent types) +// whose presence impacts super/subscripting. In this case, ParseNode<"supsub"> +// delegates its HTML building to the HtmlBuilder corresponding to these nodes. + +/** + * Final function spec for use at parse time. + * This is almost identical to `FunctionPropSpec`, except it + * 1. includes the function handler, and + * 2. requires all arguments except argTypes. + * It is generated by `defineFunction()` below. + */ + +/** + * All registered functions. + * `functions.js` just exports this same dictionary again and makes it public. + * `Parser.js` requires this dictionary. + */ +const _functions = {}; + +/** + * All HTML builders. Should be only used in the `define*` and the `build*ML` + * functions. + * + * Builders for different node types are stored side by side, but + * `HtmlBuilder` is contravariant in `T`, so there is no single type + * argument that makes storing/retrieving them typecheck. `any` is used + * as an existential-quantifier escape hatch. + */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any +const _htmlGroupBuilders = {}; + +/** + * All MathML builders. Should be only used in the `define*` and the `build*ML` + * functions. See `_htmlGroupBuilders` above for the rationale behind `any`. + */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any +const _mathmlGroupBuilders = {}; +function defineFunction(_ref) { + let { + type, + names, + props, + handler, + htmlBuilder, + mathmlBuilder + } = _ref; + // Set default values of functions + const data = { + type, + numArgs: props.numArgs, + argTypes: props.argTypes, + allowedInArgument: !!props.allowedInArgument, + allowedInText: !!props.allowedInText, + allowedInMath: props.allowedInMath === undefined ? true : props.allowedInMath, + numOptionalArgs: props.numOptionalArgs || 0, + infix: !!props.infix, + primitive: !!props.primitive, + handler + }; + for (let i = 0; i < names.length; ++i) { + _functions[names[i]] = data; + } + if (type) { + if (htmlBuilder) { + _htmlGroupBuilders[type] = htmlBuilder; + } + if (mathmlBuilder) { + _mathmlGroupBuilders[type] = mathmlBuilder; + } + } +} + +/** + * Use this to register only the HTML and MathML builders for a function (e.g. + * if the function's ParseNode is generated in Parser.js rather than via a + * stand-alone handler provided to `defineFunction`). + */ +function defineFunctionBuilders(_ref2) { + let { + type, + htmlBuilder, + mathmlBuilder + } = _ref2; + defineFunction({ + type, + names: [], + props: { + numArgs: 0 + }, + handler() { + throw new Error('Should never be called.'); + }, + htmlBuilder, + mathmlBuilder + }); +} +const normalizeArgument = function (arg) { + return arg.type === "ordgroup" && arg.body.length === 1 ? arg.body[0] : arg; +}; + +// Since the corresponding buildHTML/buildMathML function expects a +// list of elements, we normalize for different kinds of arguments +const ordargument = function (arg) { + return arg.type === "ordgroup" ? arg.body : [arg]; +}; +;// ./src/buildHTML.ts +/** + * This file does the main work of building a domTree structure from a parse + * tree. The entry point is the `buildHTML` function, which takes a parse tree. + * Then, the buildExpression, buildGroup, and various groupBuilders functions + * are called, to produce a final HTML tree. + */ + + + + + + + + + +// Binary atoms (first class `mbin`) change into ordinary atoms (`mord`) +// depending on their surroundings. See TeXbook pg. 442-446, Rules 5 and 6, +// and the text before Rule 19. +const binLeftCanceller = new Set(["leftmost", "mbin", "mopen", "mrel", "mop", "mpunct"]); +const binRightCanceller = new Set(["rightmost", "mrel", "mclose", "mpunct"]); +const styleMap = { + "display": src_Style.DISPLAY, + "text": src_Style.TEXT, + "script": src_Style.SCRIPT, + "scriptscript": src_Style.SCRIPTSCRIPT +}; +const DomEnum = { + mord: "mord", + mop: "mop", + mbin: "mbin", + mrel: "mrel", + mopen: "mopen", + mclose: "mclose", + mpunct: "mpunct", + minner: "minner" +}; +/** + * Take a list of nodes, build them in order, and return a list of the built + * nodes. documentFragments are flattened into their contents, so the + * returned list contains no fragments. `isRealGroup` is true if `expression` + * is a real group (no atoms will be added on either side), as opposed to + * a partial group (e.g. one created by \color). `surrounding` is an array + * consisting type of nodes that will be added to the left and right. + */ +const buildExpression = function (expression, options, isRealGroup, surrounding) { + if (surrounding === void 0) { + surrounding = [null, null]; + } + // Parse expressions into `groups`. + const groups = []; + for (let i = 0; i < expression.length; i++) { + const output = buildGroup(expression[i], options); + if (output instanceof DocumentFragment) { + const children = output.children; + groups.push(...children); + } else { + groups.push(output); + } + } + + // Combine consecutive domTree.symbolNodes into a single symbolNode. + tryCombineChars(groups); + + // If `expression` is a partial group, let the parent handle spacings + // to avoid processing groups multiple times. + if (!isRealGroup) { + return groups; + } + let glueOptions = options; + if (expression.length === 1) { + const node = expression[0]; + if (node.type === "sizing") { + glueOptions = options.havingSize(node.size); + } else if (node.type === "styling") { + glueOptions = options.havingStyle(styleMap[node.style]); + } + } + + // Dummy spans for determining spacings between surrounding atoms. + // If `expression` has no atoms on the left or right, class "leftmost" + // or "rightmost", respectively, is used to indicate it. + const dummyPrev = makeSpan([surrounding[0] || "leftmost"], [], options); + const dummyNext = makeSpan([surrounding[1] || "rightmost"], [], options); + + // TODO: These code assumes that a node's math class is the first element + // of its `classes` array. A later cleanup should ensure this, for + // instance by changing the signature of `makeSpan`. + + // Before determining what spaces to insert, perform bin cancellation. + // Binary operators change to ordinary symbols in some contexts. + const isRoot = isRealGroup === "root"; + traverseNonSpaceNodes(groups, (node, prev) => { + const prevType = prev.classes[0]; + const type = node.classes[0]; + if (prevType === "mbin" && binRightCanceller.has(type)) { + prev.classes[0] = "mord"; + } else if (type === "mbin" && binLeftCanceller.has(prevType)) { + node.classes[0] = "mord"; + } + }, { + node: dummyPrev + }, dummyNext, isRoot); + traverseNonSpaceNodes(groups, (node, prev) => { + var _tightSpacings$prevTy, _spacings$prevType; + const prevType = getTypeOfDomTree(prev); + const type = getTypeOfDomTree(node); + + // 'mtight' indicates that the node is script or scriptscript style. + const space = prevType && type ? node.hasClass("mtight") ? (_tightSpacings$prevTy = tightSpacings[prevType]) == null ? void 0 : _tightSpacings$prevTy[type] : (_spacings$prevType = spacings[prevType]) == null ? void 0 : _spacings$prevType[type] : null; + if (space) { + // Insert glue (spacing) after the `prev`. + return makeGlue(space, glueOptions); + } + }, { + node: dummyPrev + }, dummyNext, isRoot); + return groups; +}; + +// Depth-first traverse non-space `nodes`, calling `callback` with the current and +// previous node as arguments, optionally returning a node to insert after the +// previous node. `prev` is an object with the previous node and `insertAfter` +// function to insert after it. `next` is a node that will be added to the right. +// Used for bin cancellation and inserting spacings. +const traverseNonSpaceNodes = function (nodes, callback, prev, next, isRoot) { + if (next) { + // temporarily append the right node, if exists + nodes.push(next); + } + let i = 0; + for (; i < nodes.length; i++) { + const node = nodes[i]; + const partialGroup = checkPartialGroup(node); + if (partialGroup) { + // Recursive DFS + // TODO(ts): partialGroup.children is ReadonlyArray but this + // function mutates the array (insertAfter splices into it). + traverseNonSpaceNodes(partialGroup.children, callback, prev, null, isRoot); + continue; + } + + // Ignore explicit spaces (e.g., \;, \,) when determining what implicit + // spacing should go between atoms of different classes + const nonspace = !node.hasClass("mspace"); + if (nonspace) { + const result = callback(node, prev.node); + if (result) { + if (prev.insertAfter) { + prev.insertAfter(result); + } else { + // insert at front + nodes.unshift(result); + i++; + } + } + } + if (nonspace) { + prev.node = node; + } else if (isRoot && node.hasClass("newline")) { + prev.node = makeSpan(["leftmost"]); // treat like beginning of line + } + prev.insertAfter = (index => n => { + nodes.splice(index + 1, 0, n); + i++; + })(i); + } + if (next) { + nodes.pop(); + } +}; + +// Check if given node is a partial group, i.e., does not affect spacing around. +const checkPartialGroup = function (node) { + if (node instanceof DocumentFragment || node instanceof Anchor || node instanceof Span && node.hasClass("enclosing")) { + return node; + } + return null; +}; + +// Return the outermost node of a domTree. +const getOutermostNode = function (node, side) { + const partialGroup = checkPartialGroup(node); + if (partialGroup) { + const children = partialGroup.children; + if (children.length) { + if (side === "right") { + return getOutermostNode(children[children.length - 1], "right"); + } else if (side === "left") { + return getOutermostNode(children[0], "left"); + } + } + } + return node; +}; + +// Return math atom class (mclass) of a domTree. +// If `side` is given, it will get the type of the outermost node at given side. +const getTypeOfDomTree = function (node, side) { + if (!node) { + return null; + } + if (side) { + node = getOutermostNode(node, side); + } + // This makes a lot of assumptions as to where the type of atom + // appears. We should do a better job of enforcing this. + const className = node.classes[0]; + return DomEnum[className] || null; +}; +const makeNullDelimiter = function (options, classes) { + const moreClasses = ["nulldelimiter"].concat(options.baseSizingClasses()); + return makeSpan(classes.concat(moreClasses)); +}; + +/** + * buildGroup is the function that takes a group and calls the correct groupType + * function for it. It also handles the interaction of size and style changes + * between parents and children. + */ +const buildGroup = function (group, options, baseOptions) { + if (!group) { + return makeSpan(); + } + if (_htmlGroupBuilders[group.type]) { + // TODO(ts): groupBuilders is Record>; + // a type-safe registry would need a mapped type keyed by NodeType. + let groupNode = _htmlGroupBuilders[group.type](group, options); + + // If the size changed between the parent and the current group, account + // for that size difference. + if (baseOptions && options.size !== baseOptions.size) { + groupNode = makeSpan(options.sizingClasses(baseOptions), [groupNode], options); + const multiplier = options.sizeMultiplier / baseOptions.sizeMultiplier; + groupNode.height *= multiplier; + groupNode.depth *= multiplier; + } + return groupNode; + } else { + throw new src_ParseError("Got group of unknown type: '" + group.type + "'"); + } +}; + +/** + * Combine an array of HTML DOM nodes (e.g., the output of `buildExpression`) + * into an unbreakable HTML node of class .base, with proper struts to + * guarantee correct vertical extent. `buildHTML` calls this repeatedly to + * make up the entire expression as a sequence of unbreakable units. + */ +function buildHTMLUnbreakable(children, options) { + // Compute height and depth of this chunk. + const body = makeSpan(["base"], children, options); + + // Add strut, which ensures that the top of the HTML element falls at + // the height of the expression, and the bottom of the HTML element + // falls at the depth of the expression. + const strut = makeSpan(["strut"]); + strut.style.height = makeEm(body.height + body.depth); + if (body.depth) { + strut.style.verticalAlign = makeEm(-body.depth); + } + body.children.unshift(strut); + return body; +} + +/** + * Take an entire parse tree, and build it into an appropriate set of HTML + * nodes. + */ +function buildHTML(tree, options) { + // Strip off outer tag wrapper for processing below. + let tag = null; + if (tree.length === 1 && tree[0].type === "tag") { + tag = tree[0].tag; + tree = tree[0].body; + } + + // Build the expression contained in the tree + const expression = buildExpression(tree, options, "root"); + let eqnNum; + if (expression.length === 2 && expression[1].hasClass("tag")) { + // An environment with automatic equation numbers, e.g. {gather}. + eqnNum = expression.pop(); + } + const children = []; + + // Create one base node for each chunk between potential line breaks. + // The TeXBook [p.173] says "A formula will be broken only after a + // relation symbol like $=$ or $<$ or $\rightarrow$, or after a binary + // operation symbol like $+$ or $-$ or $\times$, where the relation or + // binary operation is on the ``outer level'' of the formula (i.e., not + // enclosed in {...} and not part of an \over construction)." + + let parts = []; + for (let i = 0; i < expression.length; i++) { + parts.push(expression[i]); + if (expression[i].hasClass("mbin") || expression[i].hasClass("mrel") || expression[i].hasClass("allowbreak")) { + // Put any post-operator glue on same line as operator. + // Watch for \nobreak along the way, and stop at \newline. + let nobreak = false; + while (i < expression.length - 1 && expression[i + 1].hasClass("mspace") && !expression[i + 1].hasClass("newline")) { + i++; + parts.push(expression[i]); + if (expression[i].hasClass("nobreak")) { + nobreak = true; + } + } + // Don't allow break if \nobreak among the post-operator glue. + if (!nobreak) { + children.push(buildHTMLUnbreakable(parts, options)); + parts = []; + } + } else if (expression[i].hasClass("newline")) { + // Write the line except the newline + parts.pop(); + if (parts.length > 0) { + children.push(buildHTMLUnbreakable(parts, options)); + parts = []; + } + // Put the newline at the top level + children.push(expression[i]); + } + } + if (parts.length > 0) { + children.push(buildHTMLUnbreakable(parts, options)); + } + + // Now, if there was a tag, build it too and append it as a final child. + let tagChild; + if (tag) { + tagChild = buildHTMLUnbreakable(buildExpression(tag, options, true), options); + tagChild.classes = ["tag"]; + children.push(tagChild); + } else if (eqnNum) { + children.push(eqnNum); + } + const htmlNode = makeSpan(["katex-html"], children); + htmlNode.setAttribute("aria-hidden", "true"); + + // Adjust the strut of the tag to be the maximum height of all children + // (the height of the enclosing htmlNode) for proper vertical alignment. + if (tagChild) { + const strut = tagChild.children[0]; + strut.style.height = makeEm(htmlNode.height + htmlNode.depth); + if (htmlNode.depth) { + strut.style.verticalAlign = makeEm(-htmlNode.depth); + } + } + return htmlNode; +} +;// ./src/mathMLTree.ts +/** + * These objects store data about MathML nodes. This is the MathML equivalent + * of the types in domTree.js. Since MathML handles its own rendering, and + * since we're mainly using MathML to improve accessibility, we don't manage + * any of the styling state that the plain DOM nodes do. + * + * The `toNode` and `toMarkup` functions work similarly to how they do in + * domTree.js, creating namespaced DOM nodes and HTML text markup respectively. + */ + + + + + + +/** + * MathML node types used in KaTeX. For a complete list of MathML nodes, see + * https://developer.mozilla.org/en-US/docs/Web/MathML/Element. + */ + +function newDocumentFragment(children) { + return new DocumentFragment(children); +} + +/** + * This node represents a general purpose MathML node of any type. The + * constructor requires the type of node to create (for example, `"mo"` or + * `"mspace"`, corresponding to `` and `` tags). + */ +class MathNode { + constructor(type, children, classes) { + this.type = void 0; + this.attributes = void 0; + this.children = void 0; + this.classes = void 0; + this.type = type; + this.attributes = {}; + this.children = children || []; + this.classes = classes || []; + } + + /** + * Sets an attribute on a MathML node. MathML depends on attributes to convey a + * semantic content, so this is used heavily. + */ + setAttribute(name, value) { + this.attributes[name] = value; + } + + /** + * Gets an attribute on a MathML node. + */ + getAttribute(name) { + return this.attributes[name]; + } + + /** + * Converts the math node into a MathML-namespaced DOM element. + */ + toNode() { + const node = document.createElementNS("http://www.w3.org/1998/Math/MathML", this.type); + for (const attr in this.attributes) { + if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) { + node.setAttribute(attr, this.attributes[attr]); + } + } + if (this.classes.length > 0) { + node.className = createClass(this.classes); + } + for (let i = 0; i < this.children.length; i++) { + // Combine multiple TextNodes into one TextNode, to prevent + // screen readers from reading each as a separate word [#3995] + if (this.children[i] instanceof TextNode && this.children[i + 1] instanceof TextNode) { + let text = this.children[i].toText() + this.children[++i].toText(); + while (this.children[i + 1] instanceof TextNode) { + text += this.children[++i].toText(); + } + node.appendChild(new TextNode(text).toNode()); + } else { + node.appendChild(this.children[i].toNode()); + } + } + return node; + } + + /** + * Converts the math node into an HTML markup string. + */ + toMarkup() { + let markup = "<" + this.type; + + // Add the attributes + for (const attr in this.attributes) { + if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) { + markup += " " + attr + "=\""; + markup += utils_escape(this.attributes[attr]); + markup += "\""; + } + } + if (this.classes.length > 0) { + markup += " class =\"" + utils_escape(createClass(this.classes)) + "\""; + } + markup += ">"; + for (let i = 0; i < this.children.length; i++) { + markup += this.children[i].toMarkup(); + } + markup += ""; + return markup; + } + + /** + * Converts the math node into a string, similar to innerText, but escaped. + */ + toText() { + return this.children.map(child => child.toText()).join(""); + } +} + +/** + * This node represents a piece of text. + */ +class TextNode { + constructor(text) { + this.text = void 0; + this.text = text; + } + + /** + * Converts the text node into a DOM text node. + */ + toNode() { + return document.createTextNode(this.text); + } + + /** + * Converts the text node into escaped HTML markup + * (representing the text itself). + */ + toMarkup() { + return utils_escape(this.toText()); + } + + /** + * Converts the text node into a string + * (representing the text itself). + */ + toText() { + return this.text; + } +} + +/** + * This node represents a space, but may render as or as text, + * depending on the width. + */ +class SpaceNode { + /** + * Create a Space node with width given in CSS ems. + */ + constructor(width) { + this.width = void 0; + this.character = void 0; + this.width = width; + // See https://www.w3.org/TR/2000/WD-MathML2-20000328/chapter6.html + // for a table of space-like characters. We use Unicode + // representations instead of &LongNames; as it's not clear how to + // make the latter via document.createTextNode. + if (width >= 0.05555 && width <= 0.05556) { + this.character = "\u200a"; //   + } else if (width >= 0.1666 && width <= 0.1667) { + this.character = "\u2009"; //   + } else if (width >= 0.2222 && width <= 0.2223) { + this.character = "\u2005"; //   + } else if (width >= 0.2777 && width <= 0.2778) { + this.character = "\u2005\u200a"; //    + } else if (width >= -0.05556 && width <= -0.05555) { + this.character = "\u200a\u2063"; // ​ + } else if (width >= -0.1667 && width <= -0.1666) { + this.character = "\u2009\u2063"; // ​ + } else if (width >= -0.2223 && width <= -0.2222) { + this.character = "\u205f\u2063"; // ​ + } else if (width >= -0.2778 && width <= -0.2777) { + this.character = "\u2005\u2063"; // ​ + } else { + this.character = null; + } + } + + /** + * Converts the math node into a MathML-namespaced DOM element. + */ + toNode() { + if (this.character) { + return document.createTextNode(this.character); + } else { + const node = document.createElementNS("http://www.w3.org/1998/Math/MathML", "mspace"); + node.setAttribute("width", makeEm(this.width)); + return node; + } + } + + /** + * Converts the math node into an HTML markup string. + */ + toMarkup() { + if (this.character) { + return "" + this.character + ""; + } else { + return ""; + } + } + + /** + * Converts the math node into a string, similar to innerText. + */ + toText() { + if (this.character) { + return this.character; + } else { + return " "; + } + } +} +;// ./src/buildMathML.ts +/** + * This file converts a parse tree into a corresponding MathML tree. The main + * entry point is the `buildMathML` function, which takes a parse tree from the + * parser. + */ + + + + + + + +const noVariantSymbols = new Set(["\\imath", "\\jmath"]); +const rowLikeTypes = new Set(["mrow", "mtable"]); + +/** + * Takes a symbol and converts it into a MathML text node after performing + * optional replacement from symbols.js. + */ +const makeText = function (text, mode, options) { + if (src_symbols[mode][text] && src_symbols[mode][text].replace && text.charCodeAt(0) !== 0xD835 && !(ligatures.hasOwnProperty(text) && options && (options.fontFamily && options.fontFamily.slice(4, 6) === "tt" || options.font && options.font.slice(4, 6) === "tt"))) { + text = src_symbols[mode][text].replace; + } + return new TextNode(text); +}; + +/** + * Wrap the given array of nodes in an node if needed, i.e., + * unless the array has length 1. Always returns a single node. + */ +const makeRow = function (body) { + if (body.length === 1) { + return body[0]; + } else { + return new MathNode("mrow", body); + } +}; +const mathFontVariants = { + mathit: "italic", + boldsymbol: group => group.type === "textord" ? "bold" : "bold-italic", + mathbf: "bold", + mathbb: "double-struck", + mathsfit: "sans-serif-italic", + mathfrak: "fraktur", + mathscr: "script", + mathcal: "script", + mathsf: "sans-serif", + mathtt: "monospace" +}; + +/** + * Returns the math variant as a string or null if none is required. + */ +const getVariant = (group, options) => { + // Handle \text... font specifiers as best we can. + // MathML has a limited list of allowable mathvariant specifiers; see + // https://www.w3.org/TR/MathML3/chapter3.html#presm.commatt + if (group.mode === "text") { + if (options.fontFamily === "texttt") { + return "monospace"; + } else if (options.fontFamily === "textsf") { + if (options.fontShape === "textit" && options.fontWeight === "textbf") { + return "sans-serif-bold-italic"; + } else if (options.fontShape === "textit") { + return "sans-serif-italic"; + } else if (options.fontWeight === "textbf") { + return "bold-sans-serif"; + } else { + return "sans-serif"; + } + } else if (options.fontShape === "textit" && options.fontWeight === "textbf") { + return "bold-italic"; + } else if (options.fontShape === "textit") { + return "italic"; + } else if (options.fontWeight === "textbf") { + return "bold"; + } + } + const font = options.font; + if (!font || font === "mathnormal") { + return null; + } + const mode = group.mode; + const mathVariant = mathFontVariants[font]; + if (mathVariant) { + return typeof mathVariant === "function" ? mathVariant(group) : mathVariant; + } + let text = group.text; + if (noVariantSymbols.has(text)) { + return null; + } + if (src_symbols[mode][text]) { + const replacement = src_symbols[mode][text].replace; + if (replacement) { + text = replacement; + } + } + const fontName = fontMap[font].fontName; + if (getCharacterMetrics(text, fontName, mode)) { + return fontMap[font].variant; + } + return null; +}; + +/** + * Check for . which is how a dot renders in MathML, + * or , + * which is how a braced comma {,} renders in MathML + */ +function isNumberPunctuation(group) { + if (!group) { + return false; + } + if (group.type === 'mi' && group.children.length === 1) { + const child = group.children[0]; + return child instanceof TextNode && child.text === '.'; + } else if (group.type === 'mo' && group.children.length === 1 && group.getAttribute('separator') === 'true' && group.getAttribute('lspace') === '0em' && group.getAttribute('rspace') === '0em') { + const child = group.children[0]; + return child instanceof TextNode && child.text === ','; + } else { + return false; + } +} + +/** + * Takes a list of nodes, builds them, and returns a list of the generated + * MathML nodes. Also combine consecutive outputs into a single + * tag. + */ +const buildMathML_buildExpression = function (expression, options, isOrdgroup) { + if (expression.length === 1) { + const group = buildMathML_buildGroup(expression[0], options); + if (isOrdgroup && group instanceof MathNode && group.type === "mo") { + // When TeX writers want to suppress spacing on an operator, + // they often put the operator by itself inside braces. + group.setAttribute("lspace", "0em"); + group.setAttribute("rspace", "0em"); + } + return [group]; + } + const groups = []; + let lastGroup; + for (let i = 0; i < expression.length; i++) { + const group = buildMathML_buildGroup(expression[i], options); + if (group instanceof MathNode && lastGroup instanceof MathNode) { + // Concatenate adjacent s + if (group.type === 'mtext' && lastGroup.type === 'mtext' && group.getAttribute('mathvariant') === lastGroup.getAttribute('mathvariant')) { + lastGroup.children.push(...group.children); + continue; + // Concatenate adjacent s + } else if (group.type === 'mn' && lastGroup.type === 'mn') { + lastGroup.children.push(...group.children); + continue; + // Concatenate ... followed by . + } else if (isNumberPunctuation(group) && lastGroup.type === 'mn') { + lastGroup.children.push(...group.children); + continue; + // Concatenate . followed by ... + } else if (group.type === 'mn' && isNumberPunctuation(lastGroup)) { + group.children = [...lastGroup.children, ...group.children]; + groups.pop(); + // Put preceding ... or . inside base of + // ...base......exponent... (or ) + } else if ((group.type === 'msup' || group.type === 'msub') && group.children.length >= 1 && (lastGroup.type === 'mn' || isNumberPunctuation(lastGroup))) { + const base = group.children[0]; + if (base instanceof MathNode && base.type === 'mn') { + base.children = [...lastGroup.children, ...base.children]; + groups.pop(); + } + // \not + } else if (lastGroup.type === 'mi' && lastGroup.children.length === 1) { + const lastChild = lastGroup.children[0]; + if (lastChild instanceof TextNode && lastChild.text === '\u0338' && (group.type === 'mo' || group.type === 'mi' || group.type === 'mn')) { + const child = group.children[0]; + if (child instanceof TextNode && child.text.length > 0) { + // Overlay with combining character long solidus + child.text = child.text.slice(0, 1) + "\u0338" + child.text.slice(1); + groups.pop(); + } + } + } + } + groups.push(group); + lastGroup = group; + } + return groups; +}; + +/** + * Equivalent to buildExpression, but wraps the elements in an + * if there's more than one. Returns a single node instead of an array. + */ +const buildExpressionRow = function (expression, options, isOrdgroup) { + return makeRow(buildMathML_buildExpression(expression, options, isOrdgroup)); +}; + +/** + * Takes a group from the parser and calls the appropriate groupBuilders function + * on it to produce a MathML node. + */ +const buildMathML_buildGroup = function (group, options) { + if (!group) { + return new MathNode("mrow"); + } + if (_mathmlGroupBuilders[group.type]) { + // TODO(ts): MathMLBuilder returns MathDomNode but all concrete + // builders return MathNode. Widening the return type here would + // require updating all callers that assume MathNode. + return _mathmlGroupBuilders[group.type](group, options); + } else { + throw new src_ParseError("Got group of unknown type: '" + group.type + "'"); + } +}; + +/** + * Takes a full parse tree and settings and builds a MathML representation of + * it. In particular, we put the elements from building the parse tree into a + * tag so we can also include that TeX source as an annotation. + * + * Note that we actually return a domTree element with a `` inside it so + * we can do appropriate styling. + */ +function buildMathML(tree, texExpression, options, isDisplayMode, forMathmlOnly) { + const expression = buildMathML_buildExpression(tree, options); + + // TODO: Make a pass thru the MathML similar to buildHTML.traverseNonSpaceNodes + // and add spacing nodes. This is necessary only adjacent to math operators + // like \sin or \lim or to subsup elements that contain math operators. + // MathML takes care of the other spacing issues. + + // Wrap up the expression in an mrow so it is presented in the semantics + // tag correctly, unless it's a single or . + let wrapper; + if (expression.length === 1 && expression[0] instanceof MathNode && rowLikeTypes.has(expression[0].type)) { + wrapper = expression[0]; + } else { + wrapper = new MathNode("mrow", expression); + } + + // Build a TeX annotation of the source + const annotation = new MathNode("annotation", [new TextNode(texExpression)]); + annotation.setAttribute("encoding", "application/x-tex"); + const semantics = new MathNode("semantics", [wrapper, annotation]); + const math = new MathNode("math", [semantics]); + math.setAttribute("xmlns", "http://www.w3.org/1998/Math/MathML"); + if (isDisplayMode) { + math.setAttribute("display", "block"); + } + + // You can't style nodes, so we wrap the node in a span. + // NOTE: The span class is not typed to have nodes as children, and + // we don't want to make the children type more generic since the children + // of span are expected to have more fields in `buildHtml` contexts. + // The MathNode implements VirtualNode (toNode/toMarkup) which is all that + // Span needs from its children for rendering. + // TODO(ts): Span's child type is HtmlDomNode, but MathNode only implements + // VirtualNode. The double-cast acknowledges this architectural limitation. + const wrapperClass = forMathmlOnly ? "katex" : "katex-mathml"; + return makeSpan([wrapperClass], [math]); +} +;// ./src/Options.ts +/** + * This file contains information about the options that the Parser carries + * around with it while parsing. Data is held in an `Options` object, and when + * recursing, a new `Options` object can be created with the `.with*` and + * `.reset` functions. + */ + + +const sizeStyleMap = [ +// Each element contains [textsize, scriptsize, scriptscriptsize]. +// The size mappings are taken from TeX with \normalsize=10pt. +[1, 1, 1], +// size1: [5, 5, 5] \tiny +[2, 1, 1], +// size2: [6, 5, 5] +[3, 1, 1], +// size3: [7, 5, 5] \scriptsize +[4, 2, 1], +// size4: [8, 6, 5] \footnotesize +[5, 2, 1], +// size5: [9, 6, 5] \small +[6, 3, 1], +// size6: [10, 7, 5] \normalsize +[7, 4, 2], +// size7: [12, 8, 6] \large +[8, 6, 3], +// size8: [14.4, 10, 7] \Large +[9, 7, 6], +// size9: [17.28, 12, 10] \LARGE +[10, 8, 7], +// size10: [20.74, 14.4, 12] \huge +[11, 10, 9] // size11: [24.88, 20.74, 17.28] \HUGE +]; +const sizeMultipliers = [ +// fontMetrics.js:getGlobalMetrics also uses size indexes, so if +// you change size indexes, change that function. +0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.2, 1.44, 1.728, 2.074, 2.488]; +const sizeAtStyle = function (size, style) { + return style.size < 2 ? size : sizeStyleMap[size - 1][style.size - 1]; +}; +/** + * This is the main options class. It contains the current style, size, color, + * and font. + * + * Options objects should not be modified. To create a new Options with + * different properties, call a `.having*` method. + */ +class Options { + constructor(data) { + this.style = void 0; + this.color = void 0; + this.size = void 0; + this.textSize = void 0; + this.phantom = void 0; + // A font family applies to a group of fonts (i.e. SansSerif), while a font + // represents a specific font (i.e. SansSerif Bold). + // See: https://tex.stackexchange.com/questions/22350/difference-between-textrm-and-mathrm + this.font = void 0; + this.fontFamily = void 0; + this.fontWeight = void 0; + this.fontShape = void 0; + this.sizeMultiplier = void 0; + this.maxSize = void 0; + this.minRuleThickness = void 0; + this._fontMetrics = void 0; + this.style = data.style; + this.color = data.color; + this.size = data.size || Options.BASESIZE; + this.textSize = data.textSize || this.size; + this.phantom = !!data.phantom; + this.font = data.font || ""; + this.fontFamily = data.fontFamily || ""; + this.fontWeight = data.fontWeight || ""; + this.fontShape = data.fontShape || ""; + this.sizeMultiplier = sizeMultipliers[this.size - 1]; + this.maxSize = data.maxSize; + this.minRuleThickness = data.minRuleThickness; + this._fontMetrics = undefined; + } + + /** + * Returns a new options object with the same properties as "this". Properties + * from "extension" will be copied to the new options object. + */ + extend(extension) { + const data = { + style: this.style, + size: this.size, + textSize: this.textSize, + color: this.color, + phantom: this.phantom, + font: this.font, + fontFamily: this.fontFamily, + fontWeight: this.fontWeight, + fontShape: this.fontShape, + maxSize: this.maxSize, + minRuleThickness: this.minRuleThickness + }; + Object.assign(data, extension); + return new Options(data); + } + + /** + * Return an options object with the given style. If `this.style === style`, + * returns `this`. + */ + havingStyle(style) { + if (this.style === style) { + return this; + } else { + return this.extend({ + style: style, + size: sizeAtStyle(this.textSize, style) + }); + } + } + + /** + * Return an options object with a cramped version of the current style. If + * the current style is cramped, returns `this`. + */ + havingCrampedStyle() { + return this.havingStyle(this.style.cramp()); + } + + /** + * Return an options object with the given size and in at least `\textstyle`. + * Returns `this` if appropriate. + */ + havingSize(size) { + if (this.size === size && this.textSize === size) { + return this; + } else { + return this.extend({ + style: this.style.text(), + size: size, + textSize: size, + sizeMultiplier: sizeMultipliers[size - 1] + }); + } + } + + /** + * Like `this.havingSize(BASESIZE).havingStyle(style)`. If `style` is omitted, + * changes to at least `\textstyle`. + */ + havingBaseStyle(style) { + style = style || this.style.text(); + const wantSize = sizeAtStyle(Options.BASESIZE, style); + if (this.size === wantSize && this.textSize === Options.BASESIZE && this.style === style) { + return this; + } else { + return this.extend({ + style: style, + size: wantSize + }); + } + } + + /** + * Remove the effect of sizing changes such as \Huge. + * Keep the effect of the current style, such as \scriptstyle. + */ + havingBaseSizing() { + let size; + switch (this.style.id) { + case 4: + case 5: + size = 3; // normalsize in scriptstyle + break; + case 6: + case 7: + size = 1; // normalsize in scriptscriptstyle + break; + default: + size = 6; + // normalsize in textstyle or displaystyle + } + return this.extend({ + style: this.style.text(), + size: size + }); + } + + /** + * Create a new options object with the given color. + */ + withColor(color) { + return this.extend({ + color: color + }); + } + + /** + * Create a new options object with "phantom" set to true. + */ + withPhantom() { + return this.extend({ + phantom: true + }); + } + + /** + * Creates a new options object with the given math font or old text font. + * @type {[type]} + */ + withFont(font) { + return this.extend({ + font + }); + } + + /** + * Create a new options objects with the given fontFamily. + */ + withTextFontFamily(fontFamily) { + return this.extend({ + fontFamily, + font: "" + }); + } + + /** + * Creates a new options object with the given font weight + */ + withTextFontWeight(fontWeight) { + return this.extend({ + fontWeight, + font: "" + }); + } + + /** + * Creates a new options object with the given font weight + */ + withTextFontShape(fontShape) { + return this.extend({ + fontShape, + font: "" + }); + } + + /** + * Return the CSS sizing classes required to switch from enclosing options + * `oldOptions` to `this`. Returns an array of classes. + */ + sizingClasses(oldOptions) { + if (oldOptions.size !== this.size) { + return ["sizing", "reset-size" + oldOptions.size, "size" + this.size]; + } else { + return []; + } + } + + /** + * Return the CSS sizing classes required to switch to the base size. Like + * `this.havingSize(BASESIZE).sizingClasses(this)`. + */ + baseSizingClasses() { + if (this.size !== Options.BASESIZE) { + return ["sizing", "reset-size" + this.size, "size" + Options.BASESIZE]; + } else { + return []; + } + } + + /** + * Return the font metrics for this size. + */ + fontMetrics() { + if (!this._fontMetrics) { + this._fontMetrics = getGlobalMetrics(this.size); + } + return this._fontMetrics; + } + + /** + * Gets the CSS color of the current options object + */ + getColor() { + if (this.phantom) { + return "transparent"; + } else { + return this.color; + } + } +} +/** + * The base size index. + */ +Options.BASESIZE = 6; +/* harmony default export */ var src_Options = (Options); +;// ./src/buildTree.ts + + + + + +const optionsFromSettings = function (settings) { + return new src_Options({ + style: settings.displayMode ? src_Style.DISPLAY : src_Style.TEXT, + maxSize: settings.maxSize, + minRuleThickness: settings.minRuleThickness + }); +}; +const displayWrap = function (node, settings) { + if (settings.displayMode) { + const classes = ["katex-display"]; + if (settings.leqno) { + classes.push("leqno"); + } + if (settings.fleqn) { + classes.push("fleqn"); + } + node = makeSpan(classes, [node]); + } + return node; +}; +const buildTree = function (tree, expression, settings) { + const options = optionsFromSettings(settings); + let katexNode; + if (settings.output === "mathml") { + return buildMathML(tree, expression, options, settings.displayMode, true); + } else if (settings.output === "html") { + const htmlNode = buildHTML(tree, options); + katexNode = makeSpan(["katex"], [htmlNode]); + } else { + const mathMLNode = buildMathML(tree, expression, options, settings.displayMode, false); + const htmlNode = buildHTML(tree, options); + katexNode = makeSpan(["katex"], [mathMLNode, htmlNode]); + } + return displayWrap(katexNode, settings); +}; +const buildHTMLTree = function (tree, expression, settings) { + const options = optionsFromSettings(settings); + const htmlNode = buildHTML(tree, options); + const katexNode = makeSpan(["katex"], [htmlNode]); + return displayWrap(katexNode, settings); +}; +/* harmony default export */ var src_buildTree = ((/* unused pure expression or super */ null && (buildTree))); +;// ./src/stretchy.ts +/** + * This file provides support to buildMathML.js and buildHTML.js + * for stretchy wide elements rendered from SVG files + * and other CSS trickery. + */ + + + + + +const stretchyCodePoint = { + widehat: "^", + widecheck: "ˇ", + widetilde: "~", + utilde: "~", + overleftarrow: "\u2190", + underleftarrow: "\u2190", + xleftarrow: "\u2190", + overrightarrow: "\u2192", + underrightarrow: "\u2192", + xrightarrow: "\u2192", + underbrace: "\u23df", + overbrace: "\u23de", + underbracket: "\u23b5", + overbracket: "\u23b4", + overgroup: "\u23e0", + undergroup: "\u23e1", + overleftrightarrow: "\u2194", + underleftrightarrow: "\u2194", + xleftrightarrow: "\u2194", + Overrightarrow: "\u21d2", + xRightarrow: "\u21d2", + overleftharpoon: "\u21bc", + xleftharpoonup: "\u21bc", + overrightharpoon: "\u21c0", + xrightharpoonup: "\u21c0", + xLeftarrow: "\u21d0", + xLeftrightarrow: "\u21d4", + xhookleftarrow: "\u21a9", + xhookrightarrow: "\u21aa", + xmapsto: "\u21a6", + xrightharpoondown: "\u21c1", + xleftharpoondown: "\u21bd", + xrightleftharpoons: "\u21cc", + xleftrightharpoons: "\u21cb", + xtwoheadleftarrow: "\u219e", + xtwoheadrightarrow: "\u21a0", + xlongequal: "=", + xtofrom: "\u21c4", + xrightleftarrows: "\u21c4", + xrightequilibrium: "\u21cc", + // Not a perfect match. + xleftequilibrium: "\u21cb", + // None better available. + "\\cdrightarrow": "\u2192", + "\\cdleftarrow": "\u2190", + "\\cdlongequal": "=" +}; +const stretchyMathML = function (label) { + const node = new MathNode("mo", [new TextNode(stretchyCodePoint[label.replace(/^\\/, '')])]); + node.setAttribute("stretchy", "true"); + return node; +}; + +// Many of the KaTeX SVG images have been adapted from glyphs in KaTeX fonts. +// Copyright (c) 2009-2010, Design Science, Inc. () +// Copyright (c) 2014-2017 Khan Academy () +// Licensed under the SIL Open Font License, Version 1.1. +// See \nhttp://scripts.sil.org/OFL + +// Very Long SVGs +// Many of the KaTeX stretchy wide elements use a long SVG image and an +// overflow: hidden tactic to achieve a stretchy image while avoiding +// distortion of arrowheads or brace corners. + +// The SVG typically contains a very long (400 em) arrow. + +// The SVG is in a container span that has overflow: hidden, so the span +// acts like a window that exposes only part of the SVG. + +// The SVG always has a longer, thinner aspect ratio than the container span. +// After the SVG fills 100% of the height of the container span, +// there is a long arrow shaft left over. That left-over shaft is not shown. +// Instead, it is sliced off because the span's CSS has overflow: hidden. + +// Thus, the reader sees an arrow that matches the subject matter width +// without distortion. + +// Some functions, such as \cancel, need to vary their aspect ratio. These +// functions do not get the overflow SVG treatment. + +// In the katexImagesData object just below, the dimensions all +// correspond to path geometry inside the relevant SVG. +// For example, \overrightarrow uses the same arrowhead as glyph U+2192 +// from the KaTeX Main font. The scaling factor is 1000. +// That is, inside the font, that arrowhead is 522 units tall, which +// corresponds to 0.522 em inside the document. + +const katexImagesData = { + // path(s), minWidth, height, align + overrightarrow: [["rightarrow"], 0.888, 522, "xMaxYMin"], + overleftarrow: [["leftarrow"], 0.888, 522, "xMinYMin"], + underrightarrow: [["rightarrow"], 0.888, 522, "xMaxYMin"], + underleftarrow: [["leftarrow"], 0.888, 522, "xMinYMin"], + xrightarrow: [["rightarrow"], 1.469, 522, "xMaxYMin"], + "\\cdrightarrow": [["rightarrow"], 3.0, 522, "xMaxYMin"], + // CD minwwidth2.5pc + xleftarrow: [["leftarrow"], 1.469, 522, "xMinYMin"], + "\\cdleftarrow": [["leftarrow"], 3.0, 522, "xMinYMin"], + Overrightarrow: [["doublerightarrow"], 0.888, 560, "xMaxYMin"], + xRightarrow: [["doublerightarrow"], 1.526, 560, "xMaxYMin"], + xLeftarrow: [["doubleleftarrow"], 1.526, 560, "xMinYMin"], + overleftharpoon: [["leftharpoon"], 0.888, 522, "xMinYMin"], + xleftharpoonup: [["leftharpoon"], 0.888, 522, "xMinYMin"], + xleftharpoondown: [["leftharpoondown"], 0.888, 522, "xMinYMin"], + overrightharpoon: [["rightharpoon"], 0.888, 522, "xMaxYMin"], + xrightharpoonup: [["rightharpoon"], 0.888, 522, "xMaxYMin"], + xrightharpoondown: [["rightharpoondown"], 0.888, 522, "xMaxYMin"], + xlongequal: [["longequal"], 0.888, 334, "xMinYMin"], + "\\cdlongequal": [["longequal"], 3.0, 334, "xMinYMin"], + xtwoheadleftarrow: [["twoheadleftarrow"], 0.888, 334, "xMinYMin"], + xtwoheadrightarrow: [["twoheadrightarrow"], 0.888, 334, "xMaxYMin"], + overleftrightarrow: [["leftarrow", "rightarrow"], 0.888, 522], + overbrace: [["leftbrace", "midbrace", "rightbrace"], 1.6, 548], + underbrace: [["leftbraceunder", "midbraceunder", "rightbraceunder"], 1.6, 548], + underleftrightarrow: [["leftarrow", "rightarrow"], 0.888, 522], + xleftrightarrow: [["leftarrow", "rightarrow"], 1.75, 522], + xLeftrightarrow: [["doubleleftarrow", "doublerightarrow"], 1.75, 560], + xrightleftharpoons: [["leftharpoondownplus", "rightharpoonplus"], 1.75, 716], + xleftrightharpoons: [["leftharpoonplus", "rightharpoondownplus"], 1.75, 716], + xhookleftarrow: [["leftarrow", "righthook"], 1.08, 522], + xhookrightarrow: [["lefthook", "rightarrow"], 1.08, 522], + overlinesegment: [["leftlinesegment", "rightlinesegment"], 0.888, 522], + underlinesegment: [["leftlinesegment", "rightlinesegment"], 0.888, 522], + overbracket: [["leftbracketover", "rightbracketover"], 1.6, 440], + underbracket: [["leftbracketunder", "rightbracketunder"], 1.6, 410], + overgroup: [["leftgroup", "rightgroup"], 0.888, 342], + undergroup: [["leftgroupunder", "rightgroupunder"], 0.888, 342], + xmapsto: [["leftmapsto", "rightarrow"], 1.5, 522], + xtofrom: [["leftToFrom", "rightToFrom"], 1.75, 528], + // The next three arrows are from the mhchem package. + // In mhchem.sty, min-length is 2.0em. But these arrows might appear in the + // document as \xrightarrow or \xrightleftharpoons. Those have + // min-length = 1.75em, so we set min-length on these next three to match. + xrightleftarrows: [["baraboveleftarrow", "rightarrowabovebar"], 1.75, 901], + xrightequilibrium: [["baraboveshortleftharpoon", "rightharpoonaboveshortbar"], 1.75, 716], + xleftequilibrium: [["shortbaraboveleftharpoon", "shortrightharpoonabovebar"], 1.75, 716] +}; +const wideAccentLabels = new Set(["widehat", "widecheck", "widetilde", "utilde"]); +const stretchySvg = function (group, options) { + // Create a span with inline SVG for the element. + function buildSvgSpan_() { + let viewBoxWidth = 400000; // default + const label = group.label.slice(1); + if (wideAccentLabels.has(label) && 'base' in group) { + // There are four SVG images available for each function. + // Choose a taller image when there are more characters. + const numChars = group.base.type === "ordgroup" ? group.base.body.length : 1; + let viewBoxHeight; + let pathName; + let height; + if (numChars > 5) { + if (label === "widehat" || label === "widecheck") { + viewBoxHeight = 420; + viewBoxWidth = 2364; + height = 0.42; + pathName = label + "4"; + } else { + viewBoxHeight = 312; + viewBoxWidth = 2340; + height = 0.34; + pathName = "tilde4"; + } + } else { + const imgIndex = [1, 1, 2, 2, 3, 3][numChars]; + if (label === "widehat" || label === "widecheck") { + viewBoxWidth = [0, 1062, 2364, 2364, 2364][imgIndex]; + viewBoxHeight = [0, 239, 300, 360, 420][imgIndex]; + height = [0, 0.24, 0.3, 0.3, 0.36, 0.42][imgIndex]; + pathName = label + imgIndex; + } else { + viewBoxWidth = [0, 600, 1033, 2339, 2340][imgIndex]; + viewBoxHeight = [0, 260, 286, 306, 312][imgIndex]; + height = [0, 0.26, 0.286, 0.3, 0.306, 0.34][imgIndex]; + pathName = "tilde" + imgIndex; + } + } + const path = new PathNode(pathName); + const svgNode = new SvgNode([path], { + "width": "100%", + "height": makeEm(height), + "viewBox": "0 0 " + viewBoxWidth + " " + viewBoxHeight, + "preserveAspectRatio": "none" + }); + return { + span: makeSvgSpan([], [svgNode], options), + minWidth: 0, + height + }; + } else { + const spans = []; + const data = katexImagesData[label]; + if (!data) { + throw new Error("No SVG data for \"" + label + "\"."); + } + const [paths, minWidth, viewBoxHeight] = data; + const height = viewBoxHeight / 1000; + const numSvgChildren = paths.length; + let widthClasses; + let aligns; + if (numSvgChildren === 1) { + if (data.length !== 4) { + throw new Error("Expected 4-tuple for single-path SVG data \"" + label + "\"."); + } + widthClasses = ["hide-tail"]; + aligns = [data[3]]; + } else if (numSvgChildren === 2) { + widthClasses = ["halfarrow-left", "halfarrow-right"]; + aligns = ["xMinYMin", "xMaxYMin"]; + } else if (numSvgChildren === 3) { + widthClasses = ["brace-left", "brace-center", "brace-right"]; + aligns = ["xMinYMin", "xMidYMin", "xMaxYMin"]; + } else { + throw new Error("Correct katexImagesData or update code here to support\n " + numSvgChildren + " children."); + } + for (let i = 0; i < numSvgChildren; i++) { + const path = new PathNode(paths[i]); + const svgNode = new SvgNode([path], { + "width": "400em", + "height": makeEm(height), + "viewBox": "0 0 " + viewBoxWidth + " " + viewBoxHeight, + "preserveAspectRatio": aligns[i] + " slice" + }); + const span = makeSvgSpan([widthClasses[i]], [svgNode], options); + if (numSvgChildren === 1) { + return { + span, + minWidth, + height + }; + } else { + span.style.height = makeEm(height); + spans.push(span); + } + } + return { + span: makeSpan(["stretchy"], spans, options), + minWidth, + height + }; + } + } // buildSvgSpan_() + const { + span, + minWidth, + height + } = buildSvgSpan_(); + + // Note that we are returning span.depth = 0. + // Any adjustments relative to the baseline must be done in buildHTML. + span.height = height; + span.style.height = makeEm(height); + if (minWidth > 0) { + span.style.minWidth = makeEm(minWidth); + } + return span; +}; +const stretchyEnclose = function (inner, label, topPad, bottomPad, options) { + // Return an image span for \cancel, \bcancel, \xcancel, \fbox, or \angl + let img; + const totalHeight = inner.height + inner.depth + topPad + bottomPad; + if (/fbox|color|angl/.test(label)) { + img = makeSpan(["stretchy", label], [], options); + if (label === "fbox") { + const color = options.color && options.getColor(); + if (color) { + img.style.borderColor = color; + } + } + } else { + // \cancel, \bcancel, or \xcancel + // Since \cancel's SVG is inline and it omits the viewBox attribute, + // its stroke-width will not vary with span area. + + const lines = []; + if (/^[bx]cancel$/.test(label)) { + lines.push(new LineNode({ + "x1": "0", + "y1": "0", + "x2": "100%", + "y2": "100%", + "stroke-width": "0.046em" + })); + } + if (/^x?cancel$/.test(label)) { + lines.push(new LineNode({ + "x1": "0", + "y1": "100%", + "x2": "100%", + "y2": "0", + "stroke-width": "0.046em" + })); + } + const svgNode = new SvgNode(lines, { + "width": "100%", + "height": makeEm(totalHeight) + }); + img = makeSvgSpan([], [svgNode], options); + } + img.height = totalHeight; + img.style.height = makeEm(totalHeight); + return img; +}; +;// ./src/atoms.ts +/** + * Small module for atom-group constants and type guard. Kept separate from + * `symbols.ts` so that consumers (notably `contrib/render-a11y-string`) can + * pull in `isAtom` without dragging in the ~870-line symbol tables. + */ + +// Some of these have a "-token" suffix since these are also used as `ParseNode` +// types for raw text tokens, and we want to avoid conflicts with higher-level +// `ParseNode` types. These `ParseNode`s are constructed within `Parser` by +// looking up the `symbols` map. +const ATOMS = { + "bin": 1, + "close": 1, + "inner": 1, + "open": 1, + "punct": 1, + "rel": 1 +}; +const NON_ATOMS = { + "accent-token": 1, + "mathord": 1, + "op-token": 1, + "spacing": 1, + "textord": 1 +}; +function isAtom(value) { + return value in ATOMS; +} +;// ./src/parseNode.ts + + +// ParseNode's corresponding to Symbol `Group`s in symbols.js. + +// ParseNode from `Parser.formatUnsupportedCmd` + +// Union of all possible `ParseNode<>` types. + +// Map from `NodeType` to the corresponding `ParseNode`. + +/** + * Asserts that the node is of the given type and returns it with stricter + * typing. Throws if the node's type does not match. + */ +function assertNodeType(node, type) { + if (!node || node.type !== type) { + throw new Error("Expected node of type " + type + ", but got " + (node ? "node of type " + node.type : String(node))); + } + return node; +} + +/** + * Returns the node more strictly typed iff it is of the given type. Otherwise, + * returns null. + */ +function assertSymbolNodeType(node) { + const typedNode = checkSymbolNodeType(node); + if (!typedNode) { + throw new Error("Expected node of symbol group type, but got " + (node ? "node of type " + node.type : String(node))); + } + return typedNode; +} + +/** + * Returns the node more strictly typed iff it is of the given type. Otherwise, + * returns null. + */ +function checkSymbolNodeType(node) { + if (node && (node.type === "atom" || NON_ATOMS.hasOwnProperty(node.type))) { + return node; + } + return null; +} +;// ./src/functions/accent.ts + + + + + + + + + + +const getBaseSymbol = group => { + if (group instanceof SymbolNode) { + return group; + } + if (hasHtmlDomChildren(group) && group.children.length === 1) { + return getBaseSymbol(group.children[0]); + } +}; + +// NOTE: Unlike most `htmlBuilder`s, this one handles not only "accent", but +// also "supsub" since an accent can affect super/subscripting. +const htmlBuilder = (grp, options) => { + // Accents are handled in the TeXbook pg. 443, rule 12. + let base; + let group; + let supSubGroup; + if (grp && grp.type === "supsub") { + // If our base is a character box, and we have superscripts and + // subscripts, the supsub will defer to us. In particular, we want + // to attach the superscripts and subscripts to the inner body (so + // that the position of the superscripts and subscripts won't be + // affected by the height of the accent). We accomplish this by + // sticking the base of the accent into the base of the supsub, and + // rendering that, while keeping track of where the accent is. + + // The real accent group is the base of the supsub group + group = assertNodeType(grp.base, "accent"); + // The character box is the base of the accent group + base = group.base; + // Stick the character box into the base of the supsub group + grp.base = base; + + // Rerender the supsub group with its new base, and store that + // result. + supSubGroup = assertSpan(buildGroup(grp, options)); + + // reset original base + grp.base = group; + } else { + group = assertNodeType(grp, "accent"); + base = group.base; + } + + // Build the base group + const body = buildGroup(base, options.havingCrampedStyle()); + + // Does the accent need to shift for the skew of a character? + const mustShift = group.isShifty && isCharacterBox(base); + + // Calculate the skew of the accent. This is based on the line "If the + // nucleus is not a single character, let s = 0; otherwise set s to the + // kern amount for the nucleus followed by the \skewchar of its font." + // Note that our skew metrics are just the kern between each character + // and the skewchar. + let skew = 0; + if (mustShift) { + var _getBaseSymbol$skew, _getBaseSymbol; + // Read the skew from the rendered base symbol. + // This preserves font metrics from font wrappers like \mathbb. + skew = (_getBaseSymbol$skew = (_getBaseSymbol = getBaseSymbol(body)) == null ? void 0 : _getBaseSymbol.skew) != null ? _getBaseSymbol$skew : 0; + } + const accentBelow = group.label === "\\c"; + + // calculate the amount of space between the body and the accent + let clearance = accentBelow ? body.height + body.depth : Math.min(body.height, options.fontMetrics().xHeight); + + // Build the accent + let accentBody; + if (!group.isStretchy) { + let accent; + let width; + if (group.label === "\\vec") { + // Before version 0.9, \vec used the combining font glyph U+20D7. + // But browsers, especially Safari, are not consistent in how they + // render combining characters when not preceded by a character. + // So now we use an SVG. + // If Safari reforms, we should consider reverting to the glyph. + accent = staticSvg("vec", options); + width = svgData.vec[1]; + } else { + accent = makeOrd({ + type: "textord", + mode: group.mode, + text: group.label + }, options, "textord"); + accent = assertSymbolDomNode(accent); + // Remove the italic correction of the accent, because it only serves to + // shift the accent over to a place we don't want. + accent.italic = 0; + width = accent.width; + if (accentBelow) { + clearance += accent.depth; + } + } + accentBody = makeSpan(["accent-body"], [accent]); + + // "Full" accents expand the width of the resulting symbol to be + // at least the width of the accent, and overlap directly onto the + // character without any vertical offset. + const accentFull = group.label === "\\textcircled"; + if (accentFull) { + accentBody.classes.push('accent-full'); + clearance = body.height; + } + + // Shift the accent over by the skew. + let left = skew; + + // CSS defines `.katex .accent .accent-body:not(.accent-full) { width: 0 }` + // so that the accent doesn't contribute to the bounding box. + // We need to shift the character by its width (effectively half + // its width) to compensate. + if (!accentFull) { + left -= width / 2; + } + accentBody.style.left = makeEm(left); + + // \textcircled uses the \bigcirc glyph, so it needs some + // vertical adjustment to match LaTeX. + if (group.label === "\\textcircled") { + accentBody.style.top = ".2em"; + } + accentBody = makeVList({ + positionType: "firstBaseline", + children: [{ + type: "elem", + elem: body + }, { + type: "kern", + size: -clearance + }, { + type: "elem", + elem: accentBody + }] + }, options); + } else { + accentBody = stretchySvg(group, options); + accentBody = makeVList({ + positionType: "firstBaseline", + children: [{ + type: "elem", + elem: body + }, { + type: "elem", + elem: accentBody, + wrapperClasses: ["svg-align"], + wrapperStyle: skew > 0 ? { + width: "calc(100% - " + makeEm(2 * skew) + ")", + marginLeft: makeEm(2 * skew) + } : undefined + }] + }, options); + } + const accentWrap = makeSpan(["mord", "accent"], [accentBody], options); + if (supSubGroup) { + // Here, we replace the "base" child of the supsub with our newly + // generated accent. + supSubGroup.children[0] = accentWrap; + + // Since we don't rerun the height calculation after replacing the + // accent, we manually recalculate height. + supSubGroup.height = Math.max(accentWrap.height, supSubGroup.height); + + // Accents should always be ords, even when their innards are not. + supSubGroup.classes[0] = "mord"; + return supSubGroup; + } else { + return accentWrap; + } +}; +const mathmlBuilder = (group, options) => { + const accentNode = group.isStretchy ? stretchyMathML(group.label) : new MathNode("mo", [makeText(group.label, group.mode)]); + const node = new MathNode("mover", [buildMathML_buildGroup(group.base, options), accentNode]); + node.setAttribute("accent", "true"); + return node; +}; +const NON_STRETCHY_ACCENT_REGEX = new RegExp(["\\acute", "\\grave", "\\ddot", "\\tilde", "\\bar", "\\breve", "\\check", "\\hat", "\\vec", "\\dot", "\\mathring"].map(accent => "\\" + accent).join("|")); + +// Accents +defineFunction({ + type: "accent", + names: ["\\acute", "\\grave", "\\ddot", "\\tilde", "\\bar", "\\breve", "\\check", "\\hat", "\\vec", "\\dot", "\\mathring", "\\widecheck", "\\widehat", "\\widetilde", "\\overrightarrow", "\\overleftarrow", "\\Overrightarrow", "\\overleftrightarrow", "\\overgroup", "\\overlinesegment", "\\overleftharpoon", "\\overrightharpoon"], + props: { + numArgs: 1 + }, + handler: (context, args) => { + const base = normalizeArgument(args[0]); + const isStretchy = !NON_STRETCHY_ACCENT_REGEX.test(context.funcName); + const isShifty = !isStretchy || context.funcName === "\\widehat" || context.funcName === "\\widetilde" || context.funcName === "\\widecheck"; + return { + type: "accent", + mode: context.parser.mode, + label: context.funcName, + isStretchy: isStretchy, + isShifty: isShifty, + base: base + }; + }, + htmlBuilder, + mathmlBuilder +}); + +// Text-mode accents +defineFunction({ + type: "accent", + names: ["\\'", "\\`", "\\^", "\\~", "\\=", "\\u", "\\.", '\\"', "\\c", "\\r", "\\H", "\\v", "\\textcircled"], + props: { + numArgs: 1, + allowedInText: true, + allowedInMath: true, + // unless in strict mode + argTypes: ["primitive"] + }, + handler: (context, args) => { + const base = args[0]; + let mode = context.parser.mode; + if (mode === "math") { + context.parser.settings.reportNonstrict("mathVsTextAccents", "LaTeX's accent " + context.funcName + " works only in text mode"); + mode = "text"; + } + return { + type: "accent", + mode: mode, + label: context.funcName, + isStretchy: false, + isShifty: true, + base: base + }; + }, + htmlBuilder, + mathmlBuilder +}); +;// ./src/functions/accentunder.ts +// Horizontal overlap functions + + + + + + +defineFunction({ + type: "accentUnder", + names: ["\\underleftarrow", "\\underrightarrow", "\\underleftrightarrow", "\\undergroup", "\\underlinesegment", "\\utilde"], + props: { + numArgs: 1 + }, + handler: (_ref, args) => { + let { + parser, + funcName + } = _ref; + const base = args[0]; + return { + type: "accentUnder", + mode: parser.mode, + label: funcName, + base: base + }; + }, + htmlBuilder: (group, options) => { + // Treat under accents much like underlines. + const innerGroup = buildGroup(group.base, options); + const accentBody = stretchySvg(group, options); + const kern = group.label === "\\utilde" ? 0.12 : 0; + + // Generate the vlist, with the appropriate kerns + const vlist = makeVList({ + positionType: "top", + positionData: innerGroup.height, + children: [{ + type: "elem", + elem: accentBody, + wrapperClasses: ["svg-align"] + }, { + type: "kern", + size: kern + }, { + type: "elem", + elem: innerGroup + }] + }, options); + return makeSpan(["mord", "accentunder"], [vlist], options); + }, + mathmlBuilder: (group, options) => { + const accentNode = stretchyMathML(group.label); + const node = new MathNode("munder", [buildMathML_buildGroup(group.base, options), accentNode]); + node.setAttribute("accentunder", "true"); + return node; + } +}); +;// ./src/functions/arrow.ts + + + + + + +// Helper function +const paddedNode = group => { + const node = new MathNode("mpadded", group ? [group] : []); + node.setAttribute("width", "+0.6em"); + node.setAttribute("lspace", "0.3em"); + return node; +}; + +// Stretchy arrows with an optional argument +defineFunction({ + type: "xArrow", + names: ["\\xleftarrow", "\\xrightarrow", "\\xLeftarrow", "\\xRightarrow", "\\xleftrightarrow", "\\xLeftrightarrow", "\\xhookleftarrow", "\\xhookrightarrow", "\\xmapsto", "\\xrightharpoondown", "\\xrightharpoonup", "\\xleftharpoondown", "\\xleftharpoonup", "\\xrightleftharpoons", "\\xleftrightharpoons", "\\xlongequal", "\\xtwoheadrightarrow", "\\xtwoheadleftarrow", "\\xtofrom", + // The next 3 functions are here to support the mhchem extension. + // Direct use of these functions is discouraged and may break someday. + "\\xrightleftarrows", "\\xrightequilibrium", "\\xleftequilibrium", + // The next 3 functions are here only to support the {CD} environment. + "\\\\cdrightarrow", "\\\\cdleftarrow", "\\\\cdlongequal"], + props: { + numArgs: 1, + numOptionalArgs: 1 + }, + handler(_ref, args, optArgs) { + let { + parser, + funcName + } = _ref; + return { + type: "xArrow", + mode: parser.mode, + label: funcName, + body: args[0], + below: optArgs[0] + }; + }, + htmlBuilder(group, options) { + const style = options.style; + + // Build the argument groups in the appropriate style. + // Ref: amsmath.dtx: \hbox{$\scriptstyle\mkern#3mu{#6}\mkern#4mu$}% + + // Some groups can return document fragments. Handle those by wrapping + // them in a span. + let newOptions = options.havingStyle(style.sup()); + const upperGroup = wrapFragment(buildGroup(group.body, newOptions, options), options); + const arrowPrefix = group.label.slice(0, 2) === "\\x" ? "x" : "cd"; + upperGroup.classes.push(arrowPrefix + "-arrow-pad"); + let lowerGroup; + if (group.below) { + // Build the lower group + newOptions = options.havingStyle(style.sub()); + lowerGroup = wrapFragment(buildGroup(group.below, newOptions, options), options); + lowerGroup.classes.push(arrowPrefix + "-arrow-pad"); + } + const arrowBody = stretchySvg(group, options); + + // Re shift: Note that stretchySvg returned arrowBody.depth = 0. + // The point we want on the math axis is at 0.5 * arrowBody.height. + const arrowShift = -options.fontMetrics().axisHeight + 0.5 * arrowBody.height; + // 2 mu kern. Ref: amsmath.dtx: #7\if0#2\else\mkern#2mu\fi + let upperShift = -options.fontMetrics().axisHeight - 0.5 * arrowBody.height - 0.111; // 0.111 em = 2 mu + if (upperGroup.depth > 0.25 || group.label === "\\xleftequilibrium") { + upperShift -= upperGroup.depth; // shift up if depth encroaches + } + + // Generate the vlist + let vlist; + if (lowerGroup) { + const lowerShift = -options.fontMetrics().axisHeight + lowerGroup.height + 0.5 * arrowBody.height + 0.111; + vlist = makeVList({ + positionType: "individualShift", + children: [{ + type: "elem", + elem: upperGroup, + shift: upperShift + }, { + type: "elem", + elem: arrowBody, + shift: arrowShift, + wrapperClasses: ["svg-align"] + }, { + type: "elem", + elem: lowerGroup, + shift: lowerShift + }] + }, options); + } else { + vlist = makeVList({ + positionType: "individualShift", + children: [{ + type: "elem", + elem: upperGroup, + shift: upperShift + }, { + type: "elem", + elem: arrowBody, + shift: arrowShift, + wrapperClasses: ["svg-align"] + }] + }, options); + } + return makeSpan(["mrel", "x-arrow"], [vlist], options); + }, + mathmlBuilder(group, options) { + const arrowNode = stretchyMathML(group.label); + arrowNode.setAttribute("minsize", group.label.charAt(0) === "x" ? "1.75em" : "3.0em"); + let node; + if (group.body) { + const upperNode = paddedNode(buildMathML_buildGroup(group.body, options)); + if (group.below) { + const lowerNode = paddedNode(buildMathML_buildGroup(group.below, options)); + node = new MathNode("munderover", [arrowNode, lowerNode, upperNode]); + } else { + node = new MathNode("mover", [arrowNode, upperNode]); + } + } else if (group.below) { + const lowerNode = paddedNode(buildMathML_buildGroup(group.below, options)); + node = new MathNode("munder", [arrowNode, lowerNode]); + } else { + // This should never happen. + // Parser.js throws an error if there is no argument. + node = paddedNode(); + node = new MathNode("mover", [arrowNode, node]); + } + return node; + } +}); +;// ./src/functions/mclass.ts + + + + + + +function mclass_htmlBuilder(group, options) { + const elements = buildExpression(group.body, options, true); + return makeSpan([group.mclass], elements, options); +} +function mclass_mathmlBuilder(group, options) { + let node; + const inner = buildMathML_buildExpression(group.body, options); + if (group.mclass === "minner") { + node = new MathNode("mpadded", inner); + } else if (group.mclass === "mord") { + if (group.isCharacterBox) { + node = inner[0]; + node.type = "mi"; + } else { + node = new MathNode("mi", inner); + } + } else { + if (group.isCharacterBox) { + node = inner[0]; + node.type = "mo"; + } else { + node = new MathNode("mo", inner); + } + + // Set spacing based on what is the most likely adjacent atom type. + // See TeXbook p170. + if (group.mclass === "mbin") { + node.attributes.lspace = "0.22em"; // medium space + node.attributes.rspace = "0.22em"; + } else if (group.mclass === "mpunct") { + node.attributes.lspace = "0em"; + node.attributes.rspace = "0.17em"; // thinspace + } else if (group.mclass === "mopen" || group.mclass === "mclose") { + node.attributes.lspace = "0em"; + node.attributes.rspace = "0em"; + } else if (group.mclass === "minner") { + node.attributes.lspace = "0.0556em"; // 1 mu is the most likely option + node.attributes.width = "+0.1111em"; + } + // MathML default space is 5/18 em, so needs no action. + // Ref: https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mo + } + return node; +} + +// Math class commands except \mathop +defineFunction({ + type: "mclass", + names: ["\\mathord", "\\mathbin", "\\mathrel", "\\mathopen", "\\mathclose", "\\mathpunct", "\\mathinner"], + props: { + numArgs: 1, + primitive: true + }, + handler(_ref, args) { + let { + parser, + funcName + } = _ref; + const body = args[0]; + return { + type: "mclass", + mode: parser.mode, + mclass: "m" + funcName.slice(5), + // TODO(kevinb): don't prefix with 'm' + body: ordargument(body), + isCharacterBox: isCharacterBox(body) + }; + }, + htmlBuilder: mclass_htmlBuilder, + mathmlBuilder: mclass_mathmlBuilder +}); +const binrelClass = arg => { + // \binrel@ spacing varies with (bin|rel|ord) of the atom in the argument. + // (by rendering separately and with {}s before and after, and measuring + // the change in spacing). We'll do roughly the same by detecting the + // atom type directly. + const atom = arg.type === "ordgroup" && arg.body.length ? arg.body[0] : arg; + if (atom.type === "atom" && (atom.family === "bin" || atom.family === "rel")) { + return "m" + atom.family; + } else { + return "mord"; + } +}; + +// \@binrel{x}{y} renders like y but as mbin/mrel/mord if x is mbin/mrel/mord. +// This is equivalent to \binrel@{x}\binrel@@{y} in AMSTeX. +defineFunction({ + type: "mclass", + names: ["\\@binrel"], + props: { + numArgs: 2 + }, + handler(_ref2, args) { + let { + parser + } = _ref2; + return { + type: "mclass", + mode: parser.mode, + mclass: binrelClass(args[0]), + body: ordargument(args[1]), + isCharacterBox: isCharacterBox(args[1]) + }; + } +}); + +// Build a relation or stacked op by placing one symbol on top of another +defineFunction({ + type: "mclass", + names: ["\\stackrel", "\\overset", "\\underset"], + props: { + numArgs: 2 + }, + handler(_ref3, args) { + let { + parser, + funcName + } = _ref3; + const baseArg = args[1]; + const shiftedArg = args[0]; + let mclass; + if (funcName !== "\\stackrel") { + // LaTeX applies \binrel spacing to \overset and \underset. + mclass = binrelClass(baseArg); + } else { + mclass = "mrel"; // for \stackrel + } + const baseOp = { + type: "op", + mode: baseArg.mode, + limits: true, + alwaysHandleSupSub: true, + parentIsSupSub: false, + symbol: false, + suppressBaseShift: funcName !== "\\stackrel", + body: ordargument(baseArg) + }; + const supsub = { + type: "supsub", + mode: shiftedArg.mode, + base: baseOp, + sup: funcName === "\\underset" ? null : shiftedArg, + sub: funcName === "\\underset" ? shiftedArg : null + }; + return { + type: "mclass", + mode: parser.mode, + mclass, + body: [supsub], + isCharacterBox: isCharacterBox(supsub) + }; + }, + htmlBuilder: mclass_htmlBuilder, + mathmlBuilder: mclass_mathmlBuilder +}); +;// ./src/functions/pmb.ts + + + + + + +// \pmb is a simulation of bold font. +// The version of \pmb in ambsy.sty works by typesetting three copies +// with small offsets. We use CSS text-shadow. +// It's a hack. Not as good as a real bold font. Better than nothing. + +defineFunction({ + type: "pmb", + names: ["\\pmb"], + props: { + numArgs: 1, + allowedInText: true + }, + handler(_ref, args) { + let { + parser + } = _ref; + return { + type: "pmb", + mode: parser.mode, + mclass: binrelClass(args[0]), + body: ordargument(args[0]) + }; + }, + htmlBuilder(group, options) { + const elements = buildExpression(group.body, options, true); + const node = makeSpan([group.mclass], elements, options); + node.style.textShadow = "0.02em 0.01em 0.04px"; + return node; + }, + mathmlBuilder(group, style) { + const inner = buildMathML_buildExpression(group.body, style); + // Wrap with an element. + const node = new MathNode("mstyle", inner); + node.setAttribute("style", "text-shadow: 0.02em 0.01em 0.04px"); + return node; + } +}); +;// ./src/environments/cd.ts + + + + + + + + +const cdArrowFunctionName = { + ">": "\\\\cdrightarrow", + "<": "\\\\cdleftarrow", + "=": "\\\\cdlongequal", + "A": "\\uparrow", + "V": "\\downarrow", + "|": "\\Vert", + ".": "no arrow" +}; +const newCell = () => { + // Create an empty cell, to be filled below with parse nodes. + // The parseTree from this module must be constructed like the + // one created by parseArray(), so an empty CD cell must + // be a ParseNode<"styling">. And CD is always displaystyle. + return { + type: "styling", + body: [], + mode: "math", + style: "display", + resetFont: true + }; +}; +const isStartOfArrow = node => { + return node.type === "textord" && node.text === "@"; +}; +const isLabelEnd = (node, endChar) => { + return (node.type === "mathord" || node.type === "atom") && node.text === endChar; +}; +function cdArrow(arrowChar, labels, parser) { + // Return a parse tree of an arrow and its labels. + // This acts in a way similar to a macro expansion. + const funcName = cdArrowFunctionName[arrowChar]; + switch (funcName) { + case "\\\\cdrightarrow": + case "\\\\cdleftarrow": + return parser.callFunction(funcName, [labels[0]], [labels[1]]); + case "\\uparrow": + case "\\downarrow": + { + const leftLabel = parser.callFunction("\\\\cdleft", [labels[0]], []); + const bareArrow = { + type: "atom", + text: funcName, + mode: "math", + family: "rel" + }; + const sizedArrow = parser.callFunction("\\Big", [bareArrow], []); + const rightLabel = parser.callFunction("\\\\cdright", [labels[1]], []); + const arrowGroup = { + type: "ordgroup", + mode: "math", + body: [leftLabel, sizedArrow, rightLabel] + }; + return parser.callFunction("\\\\cdparent", [arrowGroup], []); + } + case "\\\\cdlongequal": + return parser.callFunction("\\\\cdlongequal", [], []); + case "\\Vert": + { + const arrow = { + type: "textord", + text: "\\Vert", + mode: "math" + }; + return parser.callFunction("\\Big", [arrow], []); + } + default: + return { + type: "textord", + text: " ", + mode: "math" + }; + } +} +function parseCD(parser) { + // Get the array's parse nodes with \\ temporarily mapped to \cr. + const parsedRows = []; + parser.gullet.beginGroup(); + parser.gullet.macros.set("\\cr", "\\\\\\relax"); + parser.gullet.beginGroup(); + while (true) { + // Get the parse nodes for the next row. + parsedRows.push(parser.parseExpression(false, "\\\\")); + parser.gullet.endGroup(); + parser.gullet.beginGroup(); + const next = parser.fetch().text; + if (next === "&" || next === "\\\\") { + parser.consume(); + } else if (next === "\\end") { + if (parsedRows[parsedRows.length - 1].length === 0) { + parsedRows.pop(); // final row ended in \\ + } + break; + } else { + throw new src_ParseError("Expected \\\\ or \\cr or \\end", parser.nextToken); + } + } + let row = []; + const body = [row]; + + // Loop thru the parse nodes. Collect them into cells and arrows. + for (let i = 0; i < parsedRows.length; i++) { + // Start a new row. + const rowNodes = parsedRows[i]; + // Create the first cell. + let cell = newCell(); + for (let j = 0; j < rowNodes.length; j++) { + if (!isStartOfArrow(rowNodes[j])) { + // If a parseNode is not an arrow, it goes into a cell. + cell.body.push(rowNodes[j]); + } else { + // Parse node j is an "@", the start of an arrow. + // Before starting on the arrow, push the cell into `row`. + row.push(cell); + + // Now collect parseNodes into an arrow. + // The character after "@" defines the arrow type. + j += 1; + const arrowChar = assertSymbolNodeType(rowNodes[j]).text; + + // Create two empty label nodes. We may or may not use them. + const labels = new Array(2); + labels[0] = { + type: "ordgroup", + mode: "math", + body: [] + }; + labels[1] = { + type: "ordgroup", + mode: "math", + body: [] + }; + + // Process the arrow. + if ("=|.".includes(arrowChar)) { + // Three "arrows", ``@=`, `@|`, and `@.`, do not take labels. + // Do nothing here. + } else if ("<>AV".includes(arrowChar)) { + // Four arrows, `@>>>`, `@<<<`, `@AAA`, and `@VVV`, each take + // two optional labels. E.g. the right-point arrow syntax is + // really: @>{optional label}>{optional label}> + // Collect parseNodes into labels. + for (let labelNum = 0; labelNum < 2; labelNum++) { + let inLabel = true; + for (let k = j + 1; k < rowNodes.length; k++) { + if (isLabelEnd(rowNodes[k], arrowChar)) { + inLabel = false; + j = k; + break; + } + if (isStartOfArrow(rowNodes[k])) { + throw new src_ParseError("Missing a " + arrowChar + " character to complete a CD arrow.", rowNodes[k]); + } + labels[labelNum].body.push(rowNodes[k]); + } + if (inLabel) { + // isLabelEnd never returned a true. + throw new src_ParseError("Missing a " + arrowChar + " character to complete a CD arrow.", rowNodes[j]); + } + } + } else { + throw new src_ParseError("Expected one of \"<>AV=|.\" after @", rowNodes[j]); + } + + // Now join the arrow to its labels. + const arrow = cdArrow(arrowChar, labels, parser); + + // Wrap the arrow in ParseNode<"styling">. + // This is done to match parseArray() behavior. + const wrappedArrow = { + type: "styling", + body: [arrow], + mode: "math", + style: "display", + // CD is always displaystyle. + resetFont: true + }; + row.push(wrappedArrow); + // In CD's syntax, cells are implicit. That is, everything that + // is not an arrow gets collected into a cell. So create an empty + // cell now. It will collect upcoming parseNodes. + cell = newCell(); + } + } + if (i % 2 === 0) { + // Even-numbered rows consist of: cell, arrow, cell, arrow, ... cell + // The last cell is not yet pushed into `row`, so: + row.push(cell); + } else { + // Odd-numbered rows consist of: vert arrow, empty cell, ... vert arrow + // Remove the empty cell that was placed at the beginning of `row`. + row.shift(); + } + row = []; + body.push(row); + } + + // End row group + parser.gullet.endGroup(); + // End array group defining \\ + parser.gullet.endGroup(); + + // define column separation. + const cols = new Array(body[0].length).fill({ + type: "align", + align: "c", + pregap: 0.25, + // CD package sets \enskip between columns. + postgap: 0.25 // So pre and post each get half an \enskip, i.e. 0.25em. + }); + return { + type: "array", + mode: "math", + body, + arraystretch: 1, + addJot: true, + rowGaps: [null], + cols, + colSeparationType: "CD", + hLinesBeforeRow: new Array(body.length + 1).fill([]) + }; +} + +// The functions below are not available for general use. +// They are here only for internal use by the {CD} environment in placing labels +// next to vertical arrows. + +// We don't need any such functions for horizontal arrows because we can reuse +// the functionality that already exists for extensible arrows. + +defineFunction({ + type: "cdlabel", + names: ["\\\\cdleft", "\\\\cdright"], + props: { + numArgs: 1 + }, + handler(_ref, args) { + let { + parser, + funcName + } = _ref; + return { + type: "cdlabel", + mode: parser.mode, + side: funcName.slice(4), + label: args[0] + }; + }, + htmlBuilder(group, options) { + const newOptions = options.havingStyle(options.style.sup()); + const label = wrapFragment(buildGroup(group.label, newOptions, options), options); + label.classes.push("cd-label-" + group.side); + label.style.bottom = makeEm(0.8 - label.depth); + // Zero out label height & depth, so vertical align of arrow is set + // by the arrow height, not by the label. + label.height = 0; + label.depth = 0; + return label; + }, + mathmlBuilder(group, options) { + let label = new MathNode("mrow", [buildMathML_buildGroup(group.label, options)]); + label = new MathNode("mpadded", [label]); + label.setAttribute("width", "0"); + if (group.side === "left") { + label.setAttribute("lspace", "-1width"); + } + // We have to guess at vertical alignment. We know the arrow is 1.8em tall, + // But we don't know the height or depth of the label. + label.setAttribute("voffset", "0.7em"); + label = new MathNode("mstyle", [label]); + label.setAttribute("displaystyle", "false"); + label.setAttribute("scriptlevel", "1"); + return label; + } +}); +defineFunction({ + type: "cdlabelparent", + names: ["\\\\cdparent"], + props: { + numArgs: 1 + }, + handler(_ref2, args) { + let { + parser + } = _ref2; + return { + type: "cdlabelparent", + mode: parser.mode, + fragment: args[0] + }; + }, + htmlBuilder(group, options) { + // Wrap the vertical arrow and its labels. + // The parent gets position: relative. The child gets position: absolute. + // So CSS can locate the label correctly. + const parent = wrapFragment(buildGroup(group.fragment, options), options); + parent.classes.push("cd-vert-arrow"); + return parent; + }, + mathmlBuilder(group, options) { + return new MathNode("mrow", [buildMathML_buildGroup(group.fragment, options)]); + } +}); +;// ./src/functions/char.ts + + + + +// \@char is an internal function that takes a grouped decimal argument like +// {123} and converts into symbol with code 123. It is used by the *macro* +// \char defined in macros.js. +defineFunction({ + type: "textord", + names: ["\\@char"], + props: { + numArgs: 1, + allowedInText: true + }, + handler(_ref, args) { + let { + parser + } = _ref; + const arg = assertNodeType(args[0], "ordgroup"); + const group = arg.body; + let number = ""; + for (let i = 0; i < group.length; i++) { + const node = assertNodeType(group[i], "textord"); + number += node.text; + } + let code = parseInt(number); + let text; + if (isNaN(code)) { + throw new src_ParseError("\\@char has non-numeric argument " + number); + // If we drop IE support, the following code could be replaced with + // text = String.fromCodePoint(code) + } else if (code < 0 || code >= 0x10ffff) { + throw new src_ParseError("\\@char with invalid code point " + number); + } else if (code <= 0xffff) { + text = String.fromCharCode(code); + } else { + // Astral code point; split into surrogate halves + code -= 0x10000; + text = String.fromCharCode((code >> 10) + 0xd800, (code & 0x3ff) + 0xdc00); + } + return { + type: "textord", + mode: parser.mode, + text: text + }; + } +}); +;// ./src/functions/color.ts + + + + + + +const color_htmlBuilder = (group, options) => { + const elements = buildExpression(group.body, options.withColor(group.color), false); + + // \color isn't supposed to affect the type of the elements it contains. + // To accomplish this, we wrap the results in a fragment, so the inner + // elements will be able to directly interact with their neighbors. For + // example, `\color{red}{2 +} 3` has the same spacing as `2 + 3` + return makeFragment(elements); +}; +const color_mathmlBuilder = (group, options) => { + const inner = buildMathML_buildExpression(group.body, options.withColor(group.color)); + const node = new MathNode("mstyle", inner); + node.setAttribute("mathcolor", group.color); + return node; +}; +defineFunction({ + type: "color", + names: ["\\textcolor"], + props: { + numArgs: 2, + allowedInText: true, + argTypes: ["color", "original"] + }, + handler(_ref, args) { + let { + parser + } = _ref; + const color = assertNodeType(args[0], "color-token").color; + const body = args[1]; + return { + type: "color", + mode: parser.mode, + color, + body: ordargument(body) + }; + }, + htmlBuilder: color_htmlBuilder, + mathmlBuilder: color_mathmlBuilder +}); +defineFunction({ + type: "color", + names: ["\\color"], + props: { + numArgs: 1, + allowedInText: true, + argTypes: ["color"] + }, + handler(_ref2, args) { + let { + parser, + breakOnTokenText + } = _ref2; + const color = assertNodeType(args[0], "color-token").color; + + // Set macro \current@color in current namespace to store the current + // color, mimicking the behavior of color.sty. + // This is currently used just to correctly color a \right + // that follows a \color command. + parser.gullet.macros.set("\\current@color", color); + + // Parse out the implicit body that should be colored. + const body = parser.parseExpression(true, breakOnTokenText); + return { + type: "color", + mode: parser.mode, + color, + body + }; + }, + htmlBuilder: color_htmlBuilder, + mathmlBuilder: color_mathmlBuilder +}); +;// ./src/functions/cr.ts +// Row breaks within tabular environments, and line breaks at top level + + + + + + + +// \DeclareRobustCommand\\{...\@xnewline} +defineFunction({ + type: "cr", + names: ["\\\\"], + props: { + numArgs: 0, + numOptionalArgs: 0, + allowedInText: true + }, + handler(_ref, args, optArgs) { + let { + parser + } = _ref; + const size = parser.gullet.future().text === "[" ? parser.parseSizeGroup(true) : null; + const newLine = !parser.settings.displayMode || !parser.settings.useStrictBehavior("newLineInDisplayMode", "In LaTeX, \\\\ or \\newline " + "does nothing in display mode"); + return { + type: "cr", + mode: parser.mode, + newLine, + size: size && assertNodeType(size, "size").value + }; + }, + // The following builders are called only at the top level, + // not within tabular/array environments. + + htmlBuilder(group, options) { + const span = makeSpan(["mspace"], [], options); + if (group.newLine) { + span.classes.push("newline"); + if (group.size) { + span.style.marginTop = makeEm(calculateSize(group.size, options)); + } + } + return span; + }, + mathmlBuilder(group, options) { + const node = new MathNode("mspace"); + if (group.newLine) { + node.setAttribute("linebreak", "newline"); + if (group.size) { + node.setAttribute("height", makeEm(calculateSize(group.size, options))); + } + } + return node; + } +}); +;// ./src/functions/def.ts + + + +const globalMap = { + "\\global": "\\global", + "\\long": "\\\\globallong", + "\\\\globallong": "\\\\globallong", + "\\def": "\\gdef", + "\\gdef": "\\gdef", + "\\edef": "\\xdef", + "\\xdef": "\\xdef", + "\\let": "\\\\globallet", + "\\futurelet": "\\\\globalfuture" +}; +const checkControlSequence = tok => { + const name = tok.text; + if (/^(?:[\\{}$&#^_]|EOF)$/.test(name)) { + throw new src_ParseError("Expected a control sequence", tok); + } + return name; +}; +const getRHS = parser => { + let tok = parser.gullet.popToken(); + if (tok.text === "=") { + // consume optional equals + tok = parser.gullet.popToken(); + if (tok.text === " ") { + // consume one optional space + tok = parser.gullet.popToken(); + } + } + return tok; +}; +const letCommand = (parser, name, tok, global) => { + let macro = parser.gullet.macros.get(tok.text); + if (macro == null) { + // don't expand it later even if a macro with the same name is defined + // e.g., \let\foo=\frac \def\frac{\relax} \frac12 + tok.noexpand = true; + macro = { + tokens: [tok], + numArgs: 0, + // reproduce the same behavior in expansion + unexpandable: !parser.gullet.isExpandable(tok.text) + }; + } + parser.gullet.macros.set(name, macro, global); +}; + +// -> | +// -> |\global +// -> | +// -> \global|\long|\outer +defineFunction({ + type: "internal", + names: ["\\global", "\\long", "\\\\globallong" // can’t be entered directly + ], + props: { + numArgs: 0, + allowedInText: true + }, + handler(_ref) { + let { + parser, + funcName + } = _ref; + parser.consumeSpaces(); + const token = parser.fetch(); + if (globalMap[token.text]) { + // KaTeX doesn't have \par, so ignore \long + if (funcName === "\\global" || funcName === "\\\\globallong") { + token.text = globalMap[token.text]; + } + return assertNodeType(parser.parseFunction(), "internal"); + } + throw new src_ParseError("Invalid token after macro prefix", token); + } +}); + +// Basic support for macro definitions: \def, \gdef, \edef, \xdef +// -> +// -> \def|\gdef|\edef|\xdef +// -> +defineFunction({ + type: "internal", + names: ["\\def", "\\gdef", "\\edef", "\\xdef"], + props: { + numArgs: 0, + allowedInText: true, + primitive: true + }, + handler(_ref2) { + let { + parser, + funcName + } = _ref2; + let tok = parser.gullet.popToken(); + const name = tok.text; + if (/^(?:[\\{}$&#^_]|EOF)$/.test(name)) { + throw new src_ParseError("Expected a control sequence", tok); + } + let numArgs = 0; + let insert; + const delimiters = [[]]; + // contains no braces + while (parser.gullet.future().text !== "{") { + tok = parser.gullet.popToken(); + if (tok.text === "#") { + // If the very last character of the is #, so that + // this # is immediately followed by {, TeX will behave as if the { + // had been inserted at the right end of both the parameter text + // and the replacement text. + if (parser.gullet.future().text === "{") { + insert = parser.gullet.future(); + delimiters[numArgs].push("{"); + break; + } + + // A parameter, the first appearance of # must be followed by 1, + // the next by 2, and so on; up to nine #’s are allowed + tok = parser.gullet.popToken(); + if (!/^[1-9]$/.test(tok.text)) { + throw new src_ParseError("Invalid argument number \"" + tok.text + "\""); + } + if (parseInt(tok.text) !== numArgs + 1) { + throw new src_ParseError("Argument number \"" + tok.text + "\" out of order"); + } + numArgs++; + delimiters.push([]); + } else if (tok.text === "EOF") { + throw new src_ParseError("Expected a macro definition"); + } else { + delimiters[numArgs].push(tok.text); + } + } + // replacement text, enclosed in '{' and '}' and properly nested + let { + tokens + } = parser.gullet.consumeArg(); + if (insert) { + tokens.unshift(insert); + } + if (funcName === "\\edef" || funcName === "\\xdef") { + tokens = parser.gullet.expandTokens(tokens); + tokens.reverse(); // to fit in with stack order + } + // Final arg is the expansion of the macro + parser.gullet.macros.set(name, { + tokens, + numArgs, + delimiters + }, funcName === globalMap[funcName]); + return { + type: "internal", + mode: parser.mode + }; + } +}); + +// -> +// -> \futurelet +// | \let +// -> |= +defineFunction({ + type: "internal", + names: ["\\let", "\\\\globallet" // can’t be entered directly + ], + props: { + numArgs: 0, + allowedInText: true, + primitive: true + }, + handler(_ref3) { + let { + parser, + funcName + } = _ref3; + const name = checkControlSequence(parser.gullet.popToken()); + parser.gullet.consumeSpaces(); + const tok = getRHS(parser); + letCommand(parser, name, tok, funcName === "\\\\globallet"); + return { + type: "internal", + mode: parser.mode + }; + } +}); + +// ref: https://www.tug.org/TUGboat/tb09-3/tb22bechtolsheim.pdf +defineFunction({ + type: "internal", + names: ["\\futurelet", "\\\\globalfuture" // can’t be entered directly + ], + props: { + numArgs: 0, + allowedInText: true, + primitive: true + }, + handler(_ref4) { + let { + parser, + funcName + } = _ref4; + const name = checkControlSequence(parser.gullet.popToken()); + const middle = parser.gullet.popToken(); + const tok = parser.gullet.popToken(); + letCommand(parser, name, tok, funcName === "\\\\globalfuture"); + parser.gullet.pushToken(tok); + parser.gullet.pushToken(middle); + return { + type: "internal", + mode: parser.mode + }; + } +}); +;// ./src/delimiter.ts +/** + * This file 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`. + */ + + + + + + + + + + +/** + * Get the metrics for a given symbol and font, after transformation (i.e. + * after following replacement from symbols.js) + */ +const getMetrics = function (symbol, font, mode) { + const replace = src_symbols.math[symbol] && src_symbols.math[symbol].replace; + const metrics = getCharacterMetrics(replace || symbol, font, mode); + if (!metrics) { + throw new Error("Unsupported symbol " + symbol + " and font size " + font + "."); + } + return metrics; +}; + +/** + * Puts a delimiter span in a given style, and adds appropriate height, depth, + * and maxFontSizes. + */ +const styleWrap = function (delim, toStyle, options, classes) { + const newOptions = options.havingBaseStyle(toStyle); + const span = makeSpan(classes.concat(newOptions.sizingClasses(options)), [delim], options); + const delimSizeMultiplier = newOptions.sizeMultiplier / options.sizeMultiplier; + span.height *= delimSizeMultiplier; + span.depth *= delimSizeMultiplier; + span.maxFontSize = newOptions.sizeMultiplier; + return span; +}; +const centerSpan = function (span, options, style) { + const newOptions = options.havingBaseStyle(style); + const shift = (1 - options.sizeMultiplier / newOptions.sizeMultiplier) * options.fontMetrics().axisHeight; + span.classes.push("delimcenter"); + span.style.top = makeEm(shift); + span.height -= shift; + span.depth += shift; +}; + +/** + * 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. + */ +const makeSmallDelim = function (delim, style, center, options, mode, classes) { + const text = makeSymbol(delim, "Main-Regular", mode, options); + const span = styleWrap(text, style, options, classes); + if (center) { + centerSpan(span, options, style); + } + return span; +}; + +/** + * Builds a symbol in the given font size (note size is an integer) + */ +const mathrmSize = function (value, size, mode, options) { + return makeSymbol(value, "Size" + size + "-Regular", mode, options); +}; + +/** + * Makes a large delimiter. This is a delimiter that comes in the Size1, Size2, + * Size3, or Size4 fonts. It is always rendered in textstyle. + */ +const makeLargeDelim = function (delim, size, center, options, mode, classes) { + const inner = mathrmSize(delim, size, mode, options); + const span = styleWrap(makeSpan(["delimsizing", "size" + size], [inner], options), src_Style.TEXT, options, classes); + if (center) { + centerSpan(span, options, src_Style.TEXT); + } + return span; +}; + +/** + * Make a span from a font glyph with the given offset and in the given font. + * This is used in makeStackedDelim to make the stacking pieces for the delimiter. + */ +const makeGlyphSpan = function (symbol, font, mode) { + let sizeClass; + // Apply the correct CSS class to choose the right font. + if (font === "Size1-Regular") { + sizeClass = "delim-size1"; + } else /* if (font === "Size4-Regular") */{ + sizeClass = "delim-size4"; + } + const corner = makeSpan(["delimsizinginner", sizeClass], [makeSpan([], [makeSymbol(symbol, font, mode)])]); + + // Since this will be passed into `makeVList` in the end, wrap the element + // in the appropriate tag that VList uses. + return { + type: "elem", + elem: corner + }; +}; +const makeInner = function (ch, height, options) { + // Create a span with inline SVG for the inner part of a tall stacked delimiter. + const width = fontMetricsData['Size4-Regular'][ch.charCodeAt(0)] ? fontMetricsData['Size4-Regular'][ch.charCodeAt(0)][4] : fontMetricsData['Size1-Regular'][ch.charCodeAt(0)][4]; + const path = new PathNode("inner", innerPath(ch, Math.round(1000 * height))); + const svgNode = new SvgNode([path], { + "width": makeEm(width), + "height": makeEm(height), + // Override CSS rule `.katex svg { width: 100% }` + "style": "width:" + makeEm(width), + "viewBox": "0 0 " + 1000 * width + " " + Math.round(1000 * height), + "preserveAspectRatio": "xMinYMin" + }); + const span = makeSvgSpan([], [svgNode], options); + span.height = height; + span.style.height = makeEm(height); + span.style.width = makeEm(width); + return { + type: "elem", + elem: span + }; +}; + +// Helpers for makeStackedDelim +const lapInEms = 0.008; +const lap = { + type: "kern", + size: -1 * lapInEms +}; +const verts = new Set(["|", "\\lvert", "\\rvert", "\\vert"]); +const doubleVerts = new Set(["\\|", "\\lVert", "\\rVert", "\\Vert"]); + +/** + * Make a stacked delimiter out of a given delimiter, with the total height at + * least `heightTotal`. This routine is mentioned on page 442 of the TeXbook. + */ +const makeStackedDelim = function (delim, heightTotal, center, options, mode, classes) { + // There are four parts, the top, an optional middle, a repeated part, and a + // bottom. + let top; + let middle; + let repeat; + let bottom; + let svgLabel = ""; + let viewBoxWidth = 0; + top = repeat = bottom = delim; + middle = null; + // Also keep track of what font the delimiters are in + let font = "Size1-Regular"; + + // We set the parts and font based on the symbol. Note that we use + // '\u23d0' instead of '|' and '\u2016' instead of '\\|' for the + // repeats of the arrows + if (delim === "\\uparrow") { + repeat = bottom = "\u23d0"; + } else if (delim === "\\Uparrow") { + repeat = bottom = "\u2016"; + } else if (delim === "\\downarrow") { + top = repeat = "\u23d0"; + } else if (delim === "\\Downarrow") { + top = repeat = "\u2016"; + } else if (delim === "\\updownarrow") { + top = "\\uparrow"; + repeat = "\u23d0"; + bottom = "\\downarrow"; + } else if (delim === "\\Updownarrow") { + top = "\\Uparrow"; + repeat = "\u2016"; + bottom = "\\Downarrow"; + } else if (verts.has(delim)) { + repeat = "\u2223"; + svgLabel = "vert"; + viewBoxWidth = 333; + } else if (doubleVerts.has(delim)) { + repeat = "\u2225"; + svgLabel = "doublevert"; + viewBoxWidth = 556; + } else if (delim === "[" || delim === "\\lbrack") { + top = "\u23a1"; + repeat = "\u23a2"; + bottom = "\u23a3"; + font = "Size4-Regular"; + svgLabel = "lbrack"; + viewBoxWidth = 667; + } else if (delim === "]" || delim === "\\rbrack") { + top = "\u23a4"; + repeat = "\u23a5"; + bottom = "\u23a6"; + font = "Size4-Regular"; + svgLabel = "rbrack"; + viewBoxWidth = 667; + } else if (delim === "\\lfloor" || delim === "\u230a") { + repeat = top = "\u23a2"; + bottom = "\u23a3"; + font = "Size4-Regular"; + svgLabel = "lfloor"; + viewBoxWidth = 667; + } else if (delim === "\\lceil" || delim === "\u2308") { + top = "\u23a1"; + repeat = bottom = "\u23a2"; + font = "Size4-Regular"; + svgLabel = "lceil"; + viewBoxWidth = 667; + } else if (delim === "\\rfloor" || delim === "\u230b") { + repeat = top = "\u23a5"; + bottom = "\u23a6"; + font = "Size4-Regular"; + svgLabel = "rfloor"; + viewBoxWidth = 667; + } else if (delim === "\\rceil" || delim === "\u2309") { + top = "\u23a4"; + repeat = bottom = "\u23a5"; + font = "Size4-Regular"; + svgLabel = "rceil"; + viewBoxWidth = 667; + } else if (delim === "(" || delim === "\\lparen") { + top = "\u239b"; + repeat = "\u239c"; + bottom = "\u239d"; + font = "Size4-Regular"; + svgLabel = "lparen"; + viewBoxWidth = 875; + } else if (delim === ")" || delim === "\\rparen") { + top = "\u239e"; + repeat = "\u239f"; + bottom = "\u23a0"; + font = "Size4-Regular"; + svgLabel = "rparen"; + viewBoxWidth = 875; + } else if (delim === "\\{" || delim === "\\lbrace") { + top = "\u23a7"; + middle = "\u23a8"; + bottom = "\u23a9"; + repeat = "\u23aa"; + font = "Size4-Regular"; + } else if (delim === "\\}" || delim === "\\rbrace") { + top = "\u23ab"; + middle = "\u23ac"; + bottom = "\u23ad"; + repeat = "\u23aa"; + font = "Size4-Regular"; + } else if (delim === "\\lgroup" || delim === "\u27ee") { + top = "\u23a7"; + bottom = "\u23a9"; + repeat = "\u23aa"; + font = "Size4-Regular"; + } else if (delim === "\\rgroup" || delim === "\u27ef") { + top = "\u23ab"; + bottom = "\u23ad"; + repeat = "\u23aa"; + font = "Size4-Regular"; + } else if (delim === "\\lmoustache" || delim === "\u23b0") { + top = "\u23a7"; + bottom = "\u23ad"; + repeat = "\u23aa"; + font = "Size4-Regular"; + } else if (delim === "\\rmoustache" || delim === "\u23b1") { + top = "\u23ab"; + bottom = "\u23a9"; + repeat = "\u23aa"; + font = "Size4-Regular"; + } + + // Get the metrics of the four sections + const topMetrics = getMetrics(top, font, mode); + const topHeightTotal = topMetrics.height + topMetrics.depth; + const repeatMetrics = getMetrics(repeat, font, mode); + const repeatHeightTotal = repeatMetrics.height + repeatMetrics.depth; + const bottomMetrics = getMetrics(bottom, font, mode); + const bottomHeightTotal = bottomMetrics.height + bottomMetrics.depth; + let middleHeightTotal = 0; + let middleFactor = 1; + if (middle !== null) { + const middleMetrics = getMetrics(middle, font, mode); + middleHeightTotal = middleMetrics.height + middleMetrics.depth; + middleFactor = 2; // repeat symmetrically above and below middle + } + + // Calculate the minimal height that the delimiter can have. + // It is at least the size of the top, bottom, and optional middle combined. + const minHeight = topHeightTotal + bottomHeightTotal + middleHeightTotal; + + // Compute the number of copies of the repeat symbol we will need + const repeatCount = Math.max(0, Math.ceil((heightTotal - minHeight) / (middleFactor * repeatHeightTotal))); + + // Compute the total height of the delimiter including all the symbols + const realHeightTotal = minHeight + repeatCount * middleFactor * repeatHeightTotal; + + // The center of the delimiter is placed at the center of the axis. Note + // that in this context, "center" means that the delimiter should be + // centered around the axis in the current style, while normally it is + // centered around the axis in textstyle. + let axisHeight = options.fontMetrics().axisHeight; + if (center) { + axisHeight *= options.sizeMultiplier; + } + // Calculate the depth + const depth = realHeightTotal / 2 - axisHeight; + + // Now, we start building the pieces that will go into the vlist + // Keep a list of the pieces of the stacked delimiter + const stack = []; + if (svgLabel.length > 0) { + // Instead of stacking glyphs, create a single SVG. + // This evades browser problems with imprecise positioning of spans. + const midHeight = realHeightTotal - topHeightTotal - bottomHeightTotal; + const viewBoxHeight = Math.round(realHeightTotal * 1000); + const pathStr = tallDelim(svgLabel, Math.round(midHeight * 1000)); + const path = new PathNode(svgLabel, pathStr); + const width = makeEm(viewBoxWidth / 1000); + const height = makeEm(viewBoxHeight / 1000); + const svg = new SvgNode([path], { + "width": width, + "height": height, + "viewBox": "0 0 " + viewBoxWidth + " " + viewBoxHeight + }); + const wrapper = makeSvgSpan([], [svg], options); + wrapper.height = viewBoxHeight / 1000; + wrapper.style.width = width; + wrapper.style.height = height; + stack.push({ + type: "elem", + elem: wrapper + }); + } else { + // Stack glyphs + // Start by adding the bottom symbol + stack.push(makeGlyphSpan(bottom, font, mode)); + stack.push(lap); // overlap + + if (middle === null) { + // The middle section will be an SVG. Make it an extra 0.016em tall. + // We'll overlap by 0.008em at top and bottom. + const innerHeight = realHeightTotal - topHeightTotal - bottomHeightTotal + 2 * lapInEms; + stack.push(makeInner(repeat, innerHeight, options)); + } else { + // When there is a middle bit, we need the middle part and two repeated + // sections + const innerHeight = (realHeightTotal - topHeightTotal - bottomHeightTotal - middleHeightTotal) / 2 + 2 * lapInEms; + stack.push(makeInner(repeat, innerHeight, options)); + // Now insert the middle of the brace. + stack.push(lap); + stack.push(makeGlyphSpan(middle, font, mode)); + stack.push(lap); + stack.push(makeInner(repeat, innerHeight, options)); + } + + // Add the top symbol + stack.push(lap); + stack.push(makeGlyphSpan(top, font, mode)); + } + + // Finally, build the vlist + const newOptions = options.havingBaseStyle(src_Style.TEXT); + const inner = makeVList({ + positionType: "bottom", + positionData: depth, + children: stack + }, newOptions); + return styleWrap(makeSpan(["delimsizing", "mult"], [inner], newOptions), src_Style.TEXT, options, classes); +}; + +// All surds have 0.08em padding above the vinculum inside the SVG. +// That keeps browser span height rounding error from pinching the line. +const vbPad = 80; // padding above the surd, measured inside the viewBox. +const emPad = 0.08; // padding, in ems, measured in the document. + +const sqrtSvg = function (sqrtName, height, viewBoxHeight, extraVinculum, options) { + const path = sqrtPath(sqrtName, extraVinculum, viewBoxHeight); + const pathNode = new PathNode(sqrtName, path); + const svg = new SvgNode([pathNode], { + // Note: 1000:1 ratio of viewBox to document em width. + "width": "400em", + "height": makeEm(height), + "viewBox": "0 0 400000 " + viewBoxHeight, + "preserveAspectRatio": "xMinYMin slice" + }); + return makeSvgSpan(["hide-tail"], [svg], options); +}; + +/** + * Make a sqrt image of the given height, + */ +const makeSqrtImage = function (height, options) { + // Define a newOptions that removes the effect of size changes such as \Huge. + // We don't pick different a height surd for \Huge. For it, we scale up. + const newOptions = options.havingBaseSizing(); + + // Pick the desired surd glyph from a sequence of surds. + const delim = traverseSequence("\\surd", height * newOptions.sizeMultiplier, stackLargeDelimiterSequence, newOptions); + let sizeMultiplier = newOptions.sizeMultiplier; // default + + // The standard sqrt SVGs each have a 0.04em thick vinculum. + // If Settings.minRuleThickness is larger than that, we add extraVinculum. + const extraVinculum = Math.max(0, options.minRuleThickness - options.fontMetrics().sqrtRuleThickness); + + // Create a span containing an SVG image of a sqrt symbol. + let span; + let spanHeight; + let texHeight; + let viewBoxHeight; + let advanceWidth; + + // We create viewBoxes with 80 units of "padding" above each surd. + // Then browser rounding error on the parent span height will not + // encroach on the ink of the vinculum. But that padding is not + // included in the TeX-like `height` used for calculation of + // vertical alignment. So texHeight = span.height < span.style.height. + + if (delim.type === "small") { + // Get an SVG that is derived from glyph U+221A in font KaTeX-Main. + // 1000 unit normal glyph height. + viewBoxHeight = 1000 + 1000 * extraVinculum + vbPad; + if (height < 1.0) { + sizeMultiplier = 1.0; // mimic a \textfont radical + } else if (height < 1.4) { + sizeMultiplier = 0.7; // mimic a \scriptfont radical + } + spanHeight = (1.0 + extraVinculum + emPad) / sizeMultiplier; + texHeight = (1.00 + extraVinculum) / sizeMultiplier; + span = sqrtSvg("sqrtMain", spanHeight, viewBoxHeight, extraVinculum, options); + span.style.minWidth = "0.853em"; + advanceWidth = 0.833 / sizeMultiplier; // from the font. + } else if (delim.type === "large") { + // These SVGs come from fonts: KaTeX_Size1, _Size2, etc. + viewBoxHeight = (1000 + vbPad) * sizeToMaxHeight[delim.size]; + texHeight = (sizeToMaxHeight[delim.size] + extraVinculum) / sizeMultiplier; + spanHeight = (sizeToMaxHeight[delim.size] + extraVinculum + emPad) / sizeMultiplier; + span = sqrtSvg("sqrtSize" + delim.size, spanHeight, viewBoxHeight, extraVinculum, options); + span.style.minWidth = "1.02em"; + advanceWidth = 1.0 / sizeMultiplier; // 1.0 from the font. + } else { + // Tall sqrt. In TeX, this would be stacked using multiple glyphs. + // We'll use a single SVG to accomplish the same thing. + spanHeight = height + extraVinculum + emPad; + texHeight = height + extraVinculum; + viewBoxHeight = Math.floor(1000 * height + extraVinculum) + vbPad; + span = sqrtSvg("sqrtTall", spanHeight, viewBoxHeight, extraVinculum, options); + span.style.minWidth = "0.742em"; + advanceWidth = 1.056; + } + span.height = texHeight; + span.style.height = makeEm(spanHeight); + return { + span, + advanceWidth, + // Calculate the actual line width. + // This actually should depend on the chosen font -- e.g. \boldmath + // should use the thicker surd symbols from e.g. KaTeX_Main-Bold, and + // have thicker rules. + ruleWidth: (options.fontMetrics().sqrtRuleThickness + extraVinculum) * sizeMultiplier + }; +}; + +// There are three kinds of delimiters, delimiters that stack when they become +// too large +const stackLargeDelimiters = new Set(["(", "\\lparen", ")", "\\rparen", "[", "\\lbrack", "]", "\\rbrack", "\\{", "\\lbrace", "\\}", "\\rbrace", "\\lfloor", "\\rfloor", "\u230a", "\u230b", "\\lceil", "\\rceil", "\u2308", "\u2309", "\\surd"]); + +// delimiters that always stack +const stackAlwaysDelimiters = new Set(["\\uparrow", "\\downarrow", "\\updownarrow", "\\Uparrow", "\\Downarrow", "\\Updownarrow", "|", "\\|", "\\vert", "\\Vert", "\\lvert", "\\rvert", "\\lVert", "\\rVert", "\\lgroup", "\\rgroup", "\u27ee", "\u27ef", "\\lmoustache", "\\rmoustache", "\u23b0", "\u23b1"]); + +// and delimiters that never stack +const stackNeverDelimiters = new Set(["<", ">", "\\langle", "\\rangle", "/", "\\backslash", "\\lt", "\\gt"]); + +// Metrics of the different sizes. Found by looking at TeX's output of +// $\bigl| // \Bigl| \biggl| \Biggl| \showlists$ +// Used to create stacked delimiters of appropriate sizes in makeSizedDelim. +const sizeToMaxHeight = [0, 1.2, 1.8, 2.4, 3.0]; + +/** + * Used to create a delimiter of a specific size, where `size` is 1, 2, 3, or 4. + */ +const makeSizedDelim = function (delim, size, options, mode, classes) { + // < and > turn into \langle and \rangle in delimiters + if (delim === "<" || delim === "\\lt" || delim === "\u27e8") { + delim = "\\langle"; + } else if (delim === ">" || delim === "\\gt" || delim === "\u27e9") { + delim = "\\rangle"; + } + + // Sized delimiters are never centered. + if (stackLargeDelimiters.has(delim) || stackNeverDelimiters.has(delim)) { + return makeLargeDelim(delim, size, false, options, mode, classes); + } else if (stackAlwaysDelimiters.has(delim)) { + return makeStackedDelim(delim, sizeToMaxHeight[size], false, options, mode, classes); + } else { + throw new src_ParseError("Illegal delimiter: '" + delim + "'"); + } +}; + +/** + * There are three different sequences of delimiter sizes that the delimiters + * follow depending on the kind of delimiter. This is used when creating custom + * sized delimiters to decide whether to create a small, large, or stacked + * delimiter. + * + * In real TeX, these sequences aren't explicitly defined, but are instead + * defined inside the font metrics. Since there are only three sequences that + * are possible for the delimiters that TeX defines, it is easier to just encode + * them explicitly here. + */ + +// Delimiters that never stack try small delimiters and large delimiters only +const stackNeverDelimiterSequence = [{ + type: "small", + style: src_Style.SCRIPTSCRIPT +}, { + type: "small", + style: src_Style.SCRIPT +}, { + type: "small", + style: src_Style.TEXT +}, { + type: "large", + size: 1 +}, { + type: "large", + size: 2 +}, { + type: "large", + size: 3 +}, { + type: "large", + size: 4 +}]; + +// Delimiters that always stack try the small delimiters first, then stack +const stackAlwaysDelimiterSequence = [{ + type: "small", + style: src_Style.SCRIPTSCRIPT +}, { + type: "small", + style: src_Style.SCRIPT +}, { + type: "small", + style: src_Style.TEXT +}, { + type: "stack" +}]; + +// Delimiters that stack when large try the small and then large delimiters, and +// stack afterwards +const stackLargeDelimiterSequence = [{ + type: "small", + style: src_Style.SCRIPTSCRIPT +}, { + type: "small", + style: src_Style.SCRIPT +}, { + type: "small", + style: src_Style.TEXT +}, { + type: "large", + size: 1 +}, { + type: "large", + size: 2 +}, { + type: "large", + size: 3 +}, { + type: "large", + size: 4 +}, { + type: "stack" +}]; + +/** + * Get the font used in a delimiter based on what kind of delimiter it is. + * TODO(#963) Use more specific font family return type once that is introduced. + */ +const delimTypeToFont = function (type) { + if (type.type === "small") { + return "Main-Regular"; + } else if (type.type === "large") { + return "Size" + type.size + "-Regular"; + } else if (type.type === "stack") { + return "Size4-Regular"; + } else { + const delimKind = type.type; + throw new Error("Add support for delim type '" + delimKind + "' here."); + } +}; + +/** + * Traverse a sequence of types of delimiters to decide what kind of delimiter + * should be used to create a delimiter of the given height+depth. + */ +const traverseSequence = function (delim, height, sequence, options) { + // Here, we choose the index we should start at in the sequences. In smaller + // sizes (which correspond to larger numbers in style.size) we start earlier + // in the sequence. Thus, scriptscript starts at index 3-3=0, script starts + // at index 3-2=1, text starts at 3-1=2, and display starts at min(2,3-0)=2 + const start = Math.min(2, 3 - options.style.size); + for (let i = start; i < sequence.length; i++) { + const delimType = sequence[i]; + if (delimType.type === "stack") { + // This is always the last delimiter, so we just break the loop now. + break; + } + const metrics = getMetrics(delim, delimTypeToFont(delimType), "math"); + let heightDepth = metrics.height + metrics.depth; + + // Small delimiters are scaled down versions of the same font, so we + // account for the style change size. + if (delimType.type === "small") { + const newOptions = options.havingBaseStyle(delimType.style); + heightDepth *= newOptions.sizeMultiplier; + } + + // Check if the delimiter at this size works for the given height. + if (heightDepth > height) { + return delimType; + } + } + + // If we reached the end of the sequence, return the last sequence element. + return sequence[sequence.length - 1]; +}; + +/** + * Make a delimiter of a given height+depth, with optional centering. Here, we + * traverse the sequences, and create a delimiter that the sequence tells us to. + */ +const makeCustomSizedDelim = function (delim, height, center, options, mode, classes) { + if (delim === "<" || delim === "\\lt" || delim === "\u27e8") { + delim = "\\langle"; + } else if (delim === ">" || delim === "\\gt" || delim === "\u27e9") { + delim = "\\rangle"; + } + + // Decide what sequence to use + let sequence; + if (stackNeverDelimiters.has(delim)) { + sequence = stackNeverDelimiterSequence; + } else if (stackLargeDelimiters.has(delim)) { + sequence = stackLargeDelimiterSequence; + } else { + sequence = stackAlwaysDelimiterSequence; + } + + // Look through the sequence + const delimType = traverseSequence(delim, height, sequence, options); + + // Get the delimiter from font glyphs. + // Depending on the sequence element we decided on, call the + // appropriate function. + if (delimType.type === "small") { + return makeSmallDelim(delim, delimType.style, center, options, mode, classes); + } else if (delimType.type === "large") { + return makeLargeDelim(delim, delimType.size, center, options, mode, classes); + } else /* if (delimType.type === "stack") */{ + return makeStackedDelim(delim, height, center, options, mode, classes); + } +}; + +/** + * Make a delimiter for use with `\left` and `\right`, given a height and depth + * of an expression that the delimiters surround. + */ +const makeLeftRightDelim = function (delim, height, depth, options, mode, classes) { + // We always center \left/\right delimiters, so the axis is always shifted + const axisHeight = options.fontMetrics().axisHeight * options.sizeMultiplier; + + // Taken from TeX source, tex.web, function make_left_right + const delimiterFactor = 901; + const delimiterExtend = 5.0 / options.fontMetrics().ptPerEm; + const maxDistFromAxis = Math.max(height - axisHeight, depth + axisHeight); + const totalHeight = Math.max( + // In real TeX, calculations are done using integral values which are + // 65536 per pt, or 655360 per em. So, the division here truncates in + // TeX but doesn't here, producing different results. If we wanted to + // exactly match TeX's calculation, we could do + // Math.floor(655360 * maxDistFromAxis / 500) * + // delimiterFactor / 655360 + // (To see the difference, compare + // x^{x^{\left(\rule{0.1em}{0.68em}\right)}} + // in TeX and KaTeX) + maxDistFromAxis / 500 * delimiterFactor, 2 * maxDistFromAxis - delimiterExtend); + + // Finally, we defer to `makeCustomSizedDelim` with our calculated total + // height + return makeCustomSizedDelim(delim, totalHeight, true, options, mode, classes); +}; +;// ./src/functions/delimsizing.ts + + + + + + + + + +// Extra data needed for the delimiter handler down below +const delimiterSizes = { + "\\bigl": { + mclass: "mopen", + size: 1 + }, + "\\Bigl": { + mclass: "mopen", + size: 2 + }, + "\\biggl": { + mclass: "mopen", + size: 3 + }, + "\\Biggl": { + mclass: "mopen", + size: 4 + }, + "\\bigr": { + mclass: "mclose", + size: 1 + }, + "\\Bigr": { + mclass: "mclose", + size: 2 + }, + "\\biggr": { + mclass: "mclose", + size: 3 + }, + "\\Biggr": { + mclass: "mclose", + size: 4 + }, + "\\bigm": { + mclass: "mrel", + size: 1 + }, + "\\Bigm": { + mclass: "mrel", + size: 2 + }, + "\\biggm": { + mclass: "mrel", + size: 3 + }, + "\\Biggm": { + mclass: "mrel", + size: 4 + }, + "\\big": { + mclass: "mord", + size: 1 + }, + "\\Big": { + mclass: "mord", + size: 2 + }, + "\\bigg": { + mclass: "mord", + size: 3 + }, + "\\Bigg": { + mclass: "mord", + size: 4 + } +}; +const delimiters = new Set(["(", "\\lparen", ")", "\\rparen", "[", "\\lbrack", "]", "\\rbrack", "\\{", "\\lbrace", "\\}", "\\rbrace", "\\lfloor", "\\rfloor", "\u230a", "\u230b", "\\lceil", "\\rceil", "\u2308", "\u2309", "<", ">", "\\langle", "\u27e8", "\\rangle", "\u27e9", "\\lt", "\\gt", "\\lvert", "\\rvert", "\\lVert", "\\rVert", "\\lgroup", "\\rgroup", "\u27ee", "\u27ef", "\\lmoustache", "\\rmoustache", "\u23b0", "\u23b1", "/", "\\backslash", "|", "\\vert", "\\|", "\\Vert", "\\uparrow", "\\Uparrow", "\\downarrow", "\\Downarrow", "\\updownarrow", "\\Updownarrow", "."]); + +/** + * An HtmlDomNode that carries an `isMiddle` property, used by the + * \middle command to communicate delimiter info to the \left/\right builder. + */ + +function isMiddleDelimNode(node) { + return 'isMiddle' in node; +} + +// Delimiter functions +function checkDelimiter(delim, context) { + const symDelim = checkSymbolNodeType(delim); + if (symDelim && delimiters.has(symDelim.text)) { + return symDelim; + } else if (symDelim) { + throw new src_ParseError("Invalid delimiter '" + symDelim.text + "' after '" + context.funcName + "'", delim); + } else { + throw new src_ParseError("Invalid delimiter type '" + delim.type + "'", delim); + } +} +defineFunction({ + type: "delimsizing", + names: ["\\bigl", "\\Bigl", "\\biggl", "\\Biggl", "\\bigr", "\\Bigr", "\\biggr", "\\Biggr", "\\bigm", "\\Bigm", "\\biggm", "\\Biggm", "\\big", "\\Big", "\\bigg", "\\Bigg"], + props: { + numArgs: 1, + argTypes: ["primitive"] + }, + handler: (context, args) => { + const delim = checkDelimiter(args[0], context); + return { + type: "delimsizing", + mode: context.parser.mode, + size: delimiterSizes[context.funcName].size, + mclass: delimiterSizes[context.funcName].mclass, + delim: delim.text + }; + }, + htmlBuilder: (group, options) => { + if (group.delim === ".") { + // Empty delimiters still count as elements, even though they don't + // show anything. + return makeSpan([group.mclass]); + } + return makeSizedDelim(group.delim, group.size, options, group.mode, [group.mclass]); + }, + mathmlBuilder: group => { + const children = []; + if (group.delim !== ".") { + children.push(makeText(group.delim, group.mode)); + } + const node = new MathNode("mo", children); + if (group.mclass === "mopen" || group.mclass === "mclose") { + // Only some of the delimsizing functions act as fences, and they + // return "mopen" or "mclose" mclass. + node.setAttribute("fence", "true"); + } else { + // Explicitly disable fencing if it's not a fence, to override the + // defaults. + node.setAttribute("fence", "false"); + } + node.setAttribute("stretchy", "true"); + const size = makeEm(sizeToMaxHeight[group.size]); + node.setAttribute("minsize", size); + node.setAttribute("maxsize", size); + return node; + } +}); +function assertParsed(group) { + if (!group.body) { + throw new Error("Bug: The leftright ParseNode wasn't fully parsed."); + } +} +defineFunction({ + type: "leftright-right", + names: ["\\right"], + props: { + numArgs: 1, + primitive: true + }, + handler: (context, args) => { + // \left case below triggers parsing of \right in + // `const right = parser.parseFunction();` + // uses this return value. + const color = context.parser.gullet.macros.get("\\current@color"); + if (color && typeof color !== "string") { + throw new src_ParseError("\\current@color set to non-string in \\right"); + } + return { + type: "leftright-right", + mode: context.parser.mode, + delim: checkDelimiter(args[0], context).text, + color: color // undefined if not set via \color + }; + } +}); +defineFunction({ + type: "leftright", + names: ["\\left"], + props: { + numArgs: 1, + primitive: true + }, + handler: (context, args) => { + const delim = checkDelimiter(args[0], context); + const parser = context.parser; + // Parse out the implicit body + ++parser.leftrightDepth; + // parseExpression stops before '\\right' + const body = parser.parseExpression(false); + --parser.leftrightDepth; + // Check the next token + parser.expect("\\right", false); + const right = assertNodeType(parser.parseFunction(), "leftright-right"); + return { + type: "leftright", + mode: parser.mode, + body, + left: delim.text, + right: right.delim, + rightColor: right.color + }; + }, + htmlBuilder: (group, options) => { + assertParsed(group); + // Build the inner expression + const inner = buildExpression(group.body, options, true, ["mopen", "mclose"]); + let innerHeight = 0; + let innerDepth = 0; + let hadMiddle = false; + + // Calculate its height and depth + for (let i = 0; i < inner.length; i++) { + const node = inner[i]; + if (isMiddleDelimNode(node)) { + hadMiddle = true; + } else { + innerHeight = Math.max(inner[i].height, innerHeight); + innerDepth = Math.max(inner[i].depth, innerDepth); + } + } + + // The size of delimiters is the same, regardless of what style we are + // in. Thus, to correctly calculate the size of delimiter we need around + // a group, we scale down the inner size based on the size. + innerHeight *= options.sizeMultiplier; + innerDepth *= options.sizeMultiplier; + let leftDelim; + if (group.left === ".") { + // Empty delimiters in \left and \right make null delimiter spaces. + leftDelim = makeNullDelimiter(options, ["mopen"]); + } else { + // Otherwise, use leftRightDelim to generate the correct sized + // delimiter. + leftDelim = makeLeftRightDelim(group.left, innerHeight, innerDepth, options, group.mode, ["mopen"]); + } + // Add it to the beginning of the expression + inner.unshift(leftDelim); + + // Handle middle delimiters + if (hadMiddle) { + for (let i = 1; i < inner.length; i++) { + const middleDelim = inner[i]; + if (isMiddleDelimNode(middleDelim)) { + const isMiddle = middleDelim.isMiddle; + // Apply the options that were active when \middle was called + inner[i] = makeLeftRightDelim(isMiddle.delim, innerHeight, innerDepth, isMiddle.options, group.mode, []); + } + } + } + let rightDelim; + // Same for the right delimiter, but using color specified by \color + if (group.right === ".") { + rightDelim = makeNullDelimiter(options, ["mclose"]); + } else { + const colorOptions = group.rightColor ? options.withColor(group.rightColor) : options; + rightDelim = makeLeftRightDelim(group.right, innerHeight, innerDepth, colorOptions, group.mode, ["mclose"]); + } + // Add it to the end of the expression. + inner.push(rightDelim); + return makeSpan(["minner"], inner, options); + }, + mathmlBuilder: (group, options) => { + assertParsed(group); + const inner = buildMathML_buildExpression(group.body, options); + if (group.left !== ".") { + const leftNode = new MathNode("mo", [makeText(group.left, group.mode)]); + leftNode.setAttribute("fence", "true"); + inner.unshift(leftNode); + } + if (group.right !== ".") { + const rightNode = new MathNode("mo", [makeText(group.right, group.mode)]); + rightNode.setAttribute("fence", "true"); + if (group.rightColor) { + rightNode.setAttribute("mathcolor", group.rightColor); + } + inner.push(rightNode); + } + return makeRow(inner); + } +}); +defineFunction({ + type: "middle", + names: ["\\middle"], + props: { + numArgs: 1, + primitive: true + }, + handler: (context, args) => { + const delim = checkDelimiter(args[0], context); + if (!context.parser.leftrightDepth) { + throw new src_ParseError("\\middle without preceding \\left", delim); + } + return { + type: "middle", + mode: context.parser.mode, + delim: delim.text + }; + }, + htmlBuilder: (group, options) => { + let middleDelim; + if (group.delim === ".") { + middleDelim = makeNullDelimiter(options, []); + } else { + middleDelim = makeSizedDelim(group.delim, 1, options, group.mode, []); + + // Patch an ad-hoc property onto the node so the \left/\right + // builder can reconstruct appropriately sized middle delimiters. + // isMiddle is not part of HtmlDomNode; the read side uses + // isMiddleDelimNode() to check before accessing. + middleDelim.isMiddle = { + delim: group.delim, + options + }; + } + return middleDelim; + }, + mathmlBuilder: (group, options) => { + // A Firefox \middle will stretch a character vertically only if it + // is in the fence part of the operator dictionary at: + // https://www.w3.org/TR/MathML3/appendixc.html. + // So we need to avoid U+2223 and use plain "|" instead. + const textNode = group.delim === "\\vert" || group.delim === "|" ? makeText("|", "text") : makeText(group.delim, group.mode); + const middleNode = new MathNode("mo", [textNode]); + middleNode.setAttribute("fence", "true"); + // MathML gives 5/18em spacing to each element. + // \middle should get delimiter spacing instead. + middleNode.setAttribute("lspace", "0.05em"); + middleNode.setAttribute("rspace", "0.05em"); + return middleNode; + } +}); +;// ./src/functions/enclose.ts + + + + + + + + + + + +const enclose_htmlBuilder = (group, options) => { + // \cancel, \bcancel, \xcancel, \sout, \fbox, \colorbox, \fcolorbox, \phase + // Some groups can return document fragments. Handle those by wrapping + // them in a span. + const inner = wrapFragment(buildGroup(group.body, options), options); + const label = group.label.slice(1); + let scale = options.sizeMultiplier; + let img; + let imgShift; + + // In the LaTeX cancel package, line geometry is slightly different + // depending on whether the subject is wider than it is tall, or vice versa. + // We don't know the width of a group, so as a proxy, we test if + // the subject is a single character. This captures most of the + // subjects that should get the "tall" treatment. + const isSingleChar = isCharacterBox(group.body); + if (label === "sout") { + img = makeSpan(["stretchy", "sout"]); + img.height = options.fontMetrics().defaultRuleThickness / scale; + imgShift = -0.5 * options.fontMetrics().xHeight; + } else if (label === "phase") { + // Set a couple of dimensions from the steinmetz package. + const lineWeight = calculateSize({ + number: 0.6, + unit: "pt" + }, options); + const clearance = calculateSize({ + number: 0.35, + unit: "ex" + }, options); + + // Prevent size changes like \Huge from affecting line thickness + const newOptions = options.havingBaseSizing(); + scale = scale / newOptions.sizeMultiplier; + const angleHeight = inner.height + inner.depth + lineWeight + clearance; + // Reserve a left pad for the angle. + inner.style.paddingLeft = makeEm(angleHeight / 2 + lineWeight); + + // Create an SVG + const viewBoxHeight = Math.floor(1000 * angleHeight * scale); + const path = phasePath(viewBoxHeight); + const svgNode = new SvgNode([new PathNode("phase", path)], { + "width": "400em", + "height": makeEm(viewBoxHeight / 1000), + "viewBox": "0 0 400000 " + viewBoxHeight, + "preserveAspectRatio": "xMinYMin slice" + }); + // Wrap it in a span with overflow: hidden. + img = makeSvgSpan(["hide-tail"], [svgNode], options); + img.style.height = makeEm(angleHeight); + imgShift = inner.depth + lineWeight + clearance; + } else { + // Add horizontal padding + if (/cancel/.test(label)) { + if (!isSingleChar) { + inner.classes.push("cancel-pad"); + } + } else if (label === "angl") { + inner.classes.push("anglpad"); + } else { + inner.classes.push("boxpad"); + } + + // Add vertical padding + let topPad; + let bottomPad; + let ruleThickness = 0; + // ref: cancel package: \advance\totalheight2\p@ % "+2" + if (/box/.test(label)) { + ruleThickness = Math.max(options.fontMetrics().fboxrule, + // default + options.minRuleThickness // User override. + ); + topPad = options.fontMetrics().fboxsep + (label === "colorbox" ? 0 : ruleThickness); + bottomPad = topPad; + } else if (label === "angl") { + ruleThickness = Math.max(options.fontMetrics().defaultRuleThickness, options.minRuleThickness); + topPad = 4 * ruleThickness; // gap = 3 × line, plus the line itself. + bottomPad = Math.max(0, 0.25 - inner.depth); + } else { + topPad = isSingleChar ? 0.2 : 0; + bottomPad = topPad; + } + img = stretchyEnclose(inner, label, topPad, bottomPad, options); + if (/fbox|boxed|fcolorbox/.test(label)) { + img.style.borderStyle = "solid"; + img.style.borderWidth = makeEm(ruleThickness); + } else if (label === "angl" && ruleThickness !== 0.049) { + img.style.borderTopWidth = makeEm(ruleThickness); + img.style.borderRightWidth = makeEm(ruleThickness); + } + imgShift = inner.depth + bottomPad; + if (group.backgroundColor) { + img.style.backgroundColor = group.backgroundColor; + if (group.borderColor) { + img.style.borderColor = group.borderColor; + } + } + } + let vlist; + if (group.backgroundColor) { + vlist = makeVList({ + positionType: "individualShift", + children: [ + // Put the color background behind inner; + { + type: "elem", + elem: img, + shift: imgShift + }, { + type: "elem", + elem: inner, + shift: 0 + }] + }, options); + } else { + const classes = /cancel|phase/.test(label) ? ["svg-align"] : []; + vlist = makeVList({ + positionType: "individualShift", + children: [ + // Write the \cancel stroke on top of inner. + { + type: "elem", + elem: inner, + shift: 0 + }, { + type: "elem", + elem: img, + shift: imgShift, + wrapperClasses: classes + }] + }, options); + } + if (/cancel/.test(label)) { + // The cancel package documentation says that cancel lines add their height + // to the expression, but tests show that isn't how it actually works. + vlist.height = inner.height; + vlist.depth = inner.depth; + } + if (/cancel/.test(label) && !isSingleChar) { + // cancel does not create horiz space for its line extension. + return makeSpan(["mord", "cancel-lap"], [vlist], options); + } else { + return makeSpan(["mord"], [vlist], options); + } +}; +const enclose_mathmlBuilder = (group, options) => { + let fboxsep; + const node = new MathNode(group.label.includes("colorbox") ? "mpadded" : "menclose", [buildMathML_buildGroup(group.body, options)]); + switch (group.label) { + case "\\cancel": + node.setAttribute("notation", "updiagonalstrike"); + break; + case "\\bcancel": + node.setAttribute("notation", "downdiagonalstrike"); + break; + case "\\phase": + node.setAttribute("notation", "phasorangle"); + break; + case "\\sout": + node.setAttribute("notation", "horizontalstrike"); + break; + case "\\fbox": + node.setAttribute("notation", "box"); + break; + case "\\angl": + node.setAttribute("notation", "actuarial"); + break; + case "\\fcolorbox": + case "\\colorbox": + // doesn't have a good notation option. So use + // instead. Set some attributes that come included with . + fboxsep = options.fontMetrics().fboxsep * options.fontMetrics().ptPerEm; + node.setAttribute("width", "+" + 2 * fboxsep + "pt"); + node.setAttribute("height", "+" + 2 * fboxsep + "pt"); + node.setAttribute("lspace", fboxsep + "pt"); // + node.setAttribute("voffset", fboxsep + "pt"); + if (group.label === "\\fcolorbox") { + const thk = Math.max(options.fontMetrics().fboxrule, + // default + options.minRuleThickness // user override + ); + node.setAttribute("style", "border: " + makeEm(thk) + " solid " + group.borderColor); + } + break; + case "\\xcancel": + node.setAttribute("notation", "updiagonalstrike downdiagonalstrike"); + break; + } + if (group.backgroundColor) { + node.setAttribute("mathbackground", group.backgroundColor); + } + return node; +}; +defineFunction({ + type: "enclose", + names: ["\\colorbox"], + props: { + numArgs: 2, + allowedInText: true, + argTypes: ["color", "hbox"] + }, + handler(_ref, args, optArgs) { + let { + parser, + funcName + } = _ref; + const color = assertNodeType(args[0], "color-token").color; + const body = args[1]; + return { + type: "enclose", + mode: parser.mode, + label: funcName, + backgroundColor: color, + body + }; + }, + htmlBuilder: enclose_htmlBuilder, + mathmlBuilder: enclose_mathmlBuilder +}); +defineFunction({ + type: "enclose", + names: ["\\fcolorbox"], + props: { + numArgs: 3, + allowedInText: true, + argTypes: ["color", "color", "hbox"] + }, + handler(_ref2, args, optArgs) { + let { + parser, + funcName + } = _ref2; + const borderColor = assertNodeType(args[0], "color-token").color; + const backgroundColor = assertNodeType(args[1], "color-token").color; + const body = args[2]; + return { + type: "enclose", + mode: parser.mode, + label: funcName, + backgroundColor, + borderColor, + body + }; + }, + htmlBuilder: enclose_htmlBuilder, + mathmlBuilder: enclose_mathmlBuilder +}); +defineFunction({ + type: "enclose", + names: ["\\fbox"], + props: { + numArgs: 1, + argTypes: ["hbox"], + allowedInText: true + }, + handler(_ref3, args) { + let { + parser + } = _ref3; + return { + type: "enclose", + mode: parser.mode, + label: "\\fbox", + body: args[0] + }; + } +}); +defineFunction({ + type: "enclose", + names: ["\\cancel", "\\bcancel", "\\xcancel", "\\phase"], + props: { + numArgs: 1 + }, + handler(_ref4, args) { + let { + parser, + funcName + } = _ref4; + const body = args[0]; + return { + type: "enclose", + mode: parser.mode, + label: funcName, + body + }; + }, + htmlBuilder: enclose_htmlBuilder, + mathmlBuilder: enclose_mathmlBuilder +}); +defineFunction({ + type: "enclose", + names: ["\\sout"], + props: { + numArgs: 1, + allowedInText: true + }, + handler(_ref5, args) { + let { + parser, + funcName + } = _ref5; + if (parser.mode === "math") { + parser.settings.reportNonstrict("mathVsSout", "LaTeX's \\sout works only in text mode"); + } + const body = args[0]; + return { + type: "enclose", + mode: parser.mode, + label: funcName, + body + }; + }, + htmlBuilder: enclose_htmlBuilder, + mathmlBuilder: enclose_mathmlBuilder +}); +defineFunction({ + type: "enclose", + names: ["\\angl"], + props: { + numArgs: 1, + argTypes: ["hbox"], + allowedInText: false + }, + handler(_ref6, args) { + let { + parser + } = _ref6; + return { + type: "enclose", + mode: parser.mode, + label: "\\angl", + body: args[0] + }; + } +}); +;// ./src/defineEnvironment.ts + + +/** + * The context contains the following properties: + * - mode: current parsing mode. + * - envName: the name of the environment, one of the listed names. + * - parser: the parser object. + */ + +/** + * - context: information and references provided by the parser + * - args: an array of arguments passed to \begin{name} + * - optArgs: an array of optional arguments passed to \begin{name} + */ + +/** + * - numArgs: (default 0) The number of arguments after the \begin{name} function. + * - argTypes: (optional) Just like for a function + * - allowedInText: (default false) Whether or not the environment is allowed + * inside text mode (not enforced yet). + * - numOptionalArgs: (default 0) Just like for a function + */ + +/** + * Final environment spec for use at parse time. + * This is almost identical to `EnvDefSpec`, except it + * 1. includes the function handler + * 2. requires all arguments except argType + * It is generated by `defineEnvironment()` below. + */ + +/** + * All registered environments. + * `environments.js` exports this same dictionary again and makes it public. + * `Parser.js` requires this dictionary via `environments.js`. + */ +const _environments = {}; +function defineEnvironment(_ref) { + let { + type, + names, + props, + handler, + htmlBuilder, + mathmlBuilder + } = _ref; + // Set default values of environments. + const data = { + type, + numArgs: props.numArgs || 0, + allowedInText: false, + numOptionalArgs: 0, + handler + }; + for (let i = 0; i < names.length; ++i) { + // TODO: The value type of _environments should be a type union of all + // possible `EnvSpec<>` possibilities instead of `EnvSpec<*>`, which is + // an existential type. + _environments[names[i]] = data; + } + if (htmlBuilder) { + _htmlGroupBuilders[type] = htmlBuilder; + } + if (mathmlBuilder) { + _mathmlGroupBuilders[type] = mathmlBuilder; + } +} +;// ./src/defineMacro.ts +/** + * Provides context to macros defined by functions. Implemented by + * MacroExpander. + */ + +/** Macro tokens (in reverse order). */ + +/** + * All registered global/built-in macros. + * `macros.js` exports this same dictionary again and makes it public. + * `Parser.js` requires this dictionary via `macros.js`. + */ +const _macros = {}; + +// This function might one day accept an additional argument and do more things. +function defineMacro(name, body) { + _macros[name] = body; +} +;// ./src/SourceLocation.ts +/** + * Lexing or parsing positional information for error reporting. + * This object is immutable. + */ +class SourceLocation { + // End offset, zero-based exclusive. + + constructor(lexer, start, end) { + // The + prefix indicates that these fields aren't writeable + this.lexer = void 0; + // Lexer holding the input string. + this.start = void 0; + // Start offset, zero-based inclusive. + this.end = void 0; + this.lexer = lexer; + this.start = start; + this.end = end; + } + + /** + * Merges two `SourceLocation`s from location providers, given they are + * provided in order of appearance. + * - Returns the first one's location if only the first is provided. + * - Returns a merged range of the first and the last if both are provided + * and their lexers match. + * - Otherwise, returns null. + */ + static range(first, second) { + if (!second) { + return first && first.loc; + } else if (!first || !first.loc || !second.loc || first.loc.lexer !== second.loc.lexer) { + return null; + } else { + return new SourceLocation(first.loc.lexer, first.loc.start, second.loc.end); + } + } +} +;// ./src/Token.ts + + +/** + * Interface required to break circular dependency between Token, Lexer, and + * ParseError. + */ + +/** + * The resulting token returned from `lex`. + * + * It consists of the token text plus some position information. + * The position information is essentially a range in an input string, + * but instead of referencing the bare input string, we refer to the lexer. + * That way it is possible to attach extra metadata to the input string, + * like for example a file name or similar. + * + * The position information is optional, so it is OK to construct synthetic + * tokens if appropriate. Not providing available position information may + * lead to degraded error reporting, though. + */ +class Token { + // used in \noexpand + + constructor(text, + // the text of this token + loc) { + this.text = void 0; + this.loc = void 0; + this.noexpand = void 0; + // don't expand the token + this.treatAsRelax = void 0; + this.text = text; + this.loc = loc; + } + + /** + * Given a pair of tokens (this and endToken), compute a `Token` encompassing + * the whole input range enclosed by these two. + */ + range(endToken, + // last token of the range, inclusive + text // the text of the newly constructed token + ) { + return new Token(text, SourceLocation.range(this, endToken)); + } +} +;// ./src/environments/array.ts + + + + + + + + + + + + + + + +// Data stored in the ParseNode associated with the environment. + +// Type to indicate column separation in MathML + +// Helper functions +function getHLines(parser) { + // Return an array. The array length = number of hlines. + // Each element in the array tells if the line is dashed. + const hlineInfo = []; + parser.consumeSpaces(); + let nxt = parser.fetch().text; + if (nxt === "\\relax") { + // \relax is an artifact of the \cr macro below + parser.consume(); + parser.consumeSpaces(); + nxt = parser.fetch().text; + } + while (nxt === "\\hline" || nxt === "\\hdashline") { + parser.consume(); + hlineInfo.push(nxt === "\\hdashline"); + parser.consumeSpaces(); + nxt = parser.fetch().text; + } + return hlineInfo; +} +const validateAmsEnvironmentContext = context => { + const settings = context.parser.settings; + if (!settings.displayMode) { + throw new src_ParseError("{" + context.envName + "} can be used only in" + " display mode."); + } +}; +const gatherEnvironments = new Set(["gather", "gather*"]); + +// autoTag (an argument to parseArray) can be one of three values: +// * undefined: Regular (not-top-level) array; no tags on each row +// * true: Automatic equation numbering, overridable by \tag +// * false: Tags allowed on each row, but no automatic numbering +// This function *doesn't* work with the "split" environment name. +function getAutoTag(name) { + if (!name.includes("ed")) { + return !name.includes("*"); + } + // return undefined; +} + +/** + * Parse the body of the environment, with rows delimited by \\ and + * columns delimited by &, and create a nested list in row-major order + * with one group per cell. If given an optional argument style + * ("text", "display", etc.), then each cell is cast into that style. + */ +function parseArray(parser, _ref, style) { + let { + hskipBeforeAndAfter, + addJot, + cols, + arraystretch, + colSeparationType, + autoTag, + singleRow, + emptySingleRow, + maxNumCols, + leqno + } = _ref; + parser.gullet.beginGroup(); + if (!singleRow) { + // \cr is equivalent to \\ without the optional size argument (see below) + // TODO: provide helpful error when \cr is used outside array environment + parser.gullet.macros.set("\\cr", "\\\\\\relax"); + } + + // Get current arraystretch if it's not set by the environment + if (!arraystretch) { + const stretch = parser.gullet.expandMacroAsText("\\arraystretch"); + if (stretch == null) { + // Default \arraystretch from lttab.dtx + arraystretch = 1; + } else { + arraystretch = parseFloat(stretch); + if (!arraystretch || arraystretch < 0) { + throw new src_ParseError("Invalid \\arraystretch: " + stretch); + } + } + } + + // Start group for first cell + parser.gullet.beginGroup(); + let row = []; + const body = [row]; + const rowGaps = []; + const hLinesBeforeRow = []; + const tags = autoTag != null ? [] : undefined; + + // amsmath uses \global\@eqnswtrue and \global\@eqnswfalse to represent + // whether this row should have an equation number. Simulate this with + // a \@eqnsw macro set to 1 or 0. + function beginRow() { + if (autoTag) { + parser.gullet.macros.set("\\@eqnsw", "1", true); + } + } + function endRow() { + if (tags) { + if (parser.gullet.macros.get("\\df@tag")) { + tags.push(parser.subparse([new Token("\\df@tag")])); + parser.gullet.macros.set("\\df@tag", undefined, true); + } else { + tags.push(Boolean(autoTag) && parser.gullet.macros.get("\\@eqnsw") === "1"); + } + } + } + beginRow(); + + // Test for \hline at the top of the array. + hLinesBeforeRow.push(getHLines(parser)); + while (true) { + // Parse each cell in its own group (namespace) + const cellBody = parser.parseExpression(false, singleRow ? "\\end" : "\\\\"); + parser.gullet.endGroup(); + parser.gullet.beginGroup(); + let cell = { + type: "ordgroup", + mode: parser.mode, + body: cellBody + }; + if (style) { + cell = { + type: "styling", + mode: parser.mode, + style, + resetFont: true, + body: [cell] + }; + } + row.push(cell); + const next = parser.fetch().text; + if (next === "&") { + if (maxNumCols && row.length === maxNumCols) { + if (singleRow || colSeparationType) { + // {equation} or {split} + throw new src_ParseError("Too many tab characters: &", parser.nextToken); + } else { + // {array} environment + parser.settings.reportNonstrict("textEnv", "Too few columns " + "specified in the {array} column argument."); + } + } + parser.consume(); + } else if (next === "\\end") { + endRow(); + // Arrays terminate newlines with `\crcr` which consumes a `\cr` if + // the last line is empty. However, AMS environments keep the + // empty row if it's the only one. + // NOTE: Currently, `cell` is the last item added into `row`. + if (row.length === 1 && cell.type === "styling" && cell.body.length === 1 && cell.body[0].type === "ordgroup" && cell.body[0].body.length === 0 && (body.length > 1 || !emptySingleRow)) { + body.pop(); + } + if (hLinesBeforeRow.length < body.length + 1) { + hLinesBeforeRow.push([]); + } + break; + } else if (next === "\\\\") { + parser.consume(); + let size; + // \def\Let@{\let\\\math@cr} + // \def\math@cr{...\math@cr@} + // \def\math@cr@{\new@ifnextchar[\math@cr@@{\math@cr@@[\z@]}} + // \def\math@cr@@[#1]{...\math@cr@@@...} + // \def\math@cr@@@{\cr} + if (parser.gullet.future().text !== " ") { + size = parser.parseSizeGroup(true); + } + rowGaps.push(size ? size.value : null); + endRow(); + + // check for \hline(s) following the row separator + hLinesBeforeRow.push(getHLines(parser)); + row = []; + body.push(row); + beginRow(); + } else { + throw new src_ParseError("Expected & or \\\\ or \\cr or \\end", parser.nextToken); + } + } + + // End cell group + parser.gullet.endGroup(); + // End array group defining \cr + parser.gullet.endGroup(); + return { + type: "array", + mode: parser.mode, + addJot, + arraystretch, + body, + cols, + rowGaps, + hskipBeforeAndAfter, + hLinesBeforeRow, + colSeparationType, + tags, + leqno + }; +} + +// Decides on a style for cells in an array according to whether the given +// environment name starts with the letter 'd'. +function dCellStyle(envName) { + if (envName.slice(0, 1) === "d") { + return "display"; + } else { + return "text"; + } +} +const array_htmlBuilder = function (group, options) { + let r; + let c; + const nr = group.body.length; + const hLinesBeforeRow = group.hLinesBeforeRow; + let nc = 0; + const body = new Array(nr); + const hlines = []; + const ruleThickness = Math.max( + // From LaTeX \showthe\arrayrulewidth. Equals 0.04 em. + options.fontMetrics().arrayRuleWidth, options.minRuleThickness // User override. + ); + + // Horizontal spacing + const pt = 1 / options.fontMetrics().ptPerEm; + let arraycolsep = 5 * pt; // default value, i.e. \arraycolsep in article.cls + if (group.colSeparationType && group.colSeparationType === "small") { + // We're in a {smallmatrix}. Default column space is \thickspace, + // i.e. 5/18em = 0.2778em, per amsmath.dtx for {smallmatrix}. + // But that needs adjustment because LaTeX applies \scriptstyle to the + // entire array, including the colspace, but this function applies + // \scriptstyle only inside each element. + const localMultiplier = options.havingStyle(src_Style.SCRIPT).sizeMultiplier; + arraycolsep = 0.2778 * (localMultiplier / options.sizeMultiplier); + } + + // Vertical spacing + const baselineskip = group.colSeparationType === "CD" ? calculateSize({ + number: 3, + unit: "ex" + }, options) : 12 * pt; // see size10.clo + // Default \jot from ltmath.dtx + // TODO(edemaine): allow overriding \jot via \setlength (#687) + const jot = 3 * pt; + const arrayskip = group.arraystretch * baselineskip; + const arstrutHeight = 0.7 * arrayskip; // \strutbox in ltfsstrc.dtx and + const arstrutDepth = 0.3 * arrayskip; // \@arstrutbox in lttab.dtx + + let totalHeight = 0; + + // Set a position for \hline(s) at the top of the array, if any. + function setHLinePos(hlinesInGap) { + for (let i = 0; i < hlinesInGap.length; ++i) { + if (i > 0) { + totalHeight += 0.25; + } + hlines.push({ + pos: totalHeight, + isDashed: hlinesInGap[i] + }); + } + } + setHLinePos(hLinesBeforeRow[0]); + for (r = 0; r < group.body.length; ++r) { + const inrow = group.body[r]; + let height = arstrutHeight; // \@array adds an \@arstrut + let depth = arstrutDepth; // to each tow (via the template) + + if (nc < inrow.length) { + nc = inrow.length; + } + const outrow = { + cells: new Array(inrow.length), + height: 0, + depth: 0, + pos: 0 + }; + for (c = 0; c < inrow.length; ++c) { + const elt = buildGroup(inrow[c], options); + if (depth < elt.depth) { + depth = elt.depth; + } + if (height < elt.height) { + height = elt.height; + } + outrow.cells[c] = elt; + } + const rowGap = group.rowGaps[r]; + let gap = 0; + if (rowGap) { + gap = calculateSize(rowGap, options); + if (gap > 0) { + // \@argarraycr + gap += arstrutDepth; + if (depth < gap) { + depth = gap; // \@xargarraycr + } + gap = 0; + } + } + // In AMS multiline environments such as aligned and gathered, rows + // correspond to lines that have additional \jot added between lines + // via \openup. + // We simulate this by adding \jot depth to each row except the last. + if (group.addJot && r < group.body.length - 1) { + depth += jot; + } + outrow.height = height; + outrow.depth = depth; + totalHeight += height; + outrow.pos = totalHeight; + totalHeight += depth + gap; // \@yargarraycr + body[r] = outrow; + + // Set a position for \hline(s), if any. + setHLinePos(hLinesBeforeRow[r + 1]); + } + const offset = totalHeight / 2 + options.fontMetrics().axisHeight; + const colDescriptions = group.cols || []; + const cols = []; + let colSep; + let colDescrNum; + const tagSpans = []; + if (group.tags && group.tags.some(tag => tag)) { + // An environment with manual tags and/or automatic equation numbers. + // Create node(s), the latter of which trigger CSS counter increment. + for (r = 0; r < nr; ++r) { + const rw = body[r]; + const shift = rw.pos - offset; + const tag = group.tags[r]; + let tagSpan; + if (tag === true) { + // automatic numbering + tagSpan = makeSpan(["eqn-num"], [], options); + } else if (tag === false) { + // \nonumber/\notag or starred environment + tagSpan = makeSpan([], [], options); + } else { + // manual \tag + tagSpan = makeSpan([], buildExpression(tag, options, true), options); + } + tagSpan.depth = rw.depth; + tagSpan.height = rw.height; + tagSpans.push({ + type: "elem", + elem: tagSpan, + shift + }); + } + } + for (c = 0, colDescrNum = 0; + // Continue while either there are more columns or more column + // descriptions, so trailing separators don't get lost. + c < nc || colDescrNum < colDescriptions.length; ++c, ++colDescrNum) { + var _colDescr3; + let colDescr = colDescriptions[colDescrNum]; + let firstSeparator = true; + while (((_colDescr = colDescr) == null ? void 0 : _colDescr.type) === "separator") { + var _colDescr; + // If there is more than one separator in a row, add a space + // between them. + if (!firstSeparator) { + colSep = makeSpan(["arraycolsep"], []); + colSep.style.width = makeEm(options.fontMetrics().doubleRuleSep); + cols.push(colSep); + } + if (colDescr.separator === "|" || colDescr.separator === ":") { + const lineType = colDescr.separator === "|" ? "solid" : "dashed"; + const separator = makeSpan(["vertical-separator"], [], options); + separator.style.height = makeEm(totalHeight); + separator.style.borderRightWidth = makeEm(ruleThickness); + separator.style.borderRightStyle = lineType; + separator.style.margin = "0 " + makeEm(-ruleThickness / 2); + const shift = totalHeight - offset; + if (shift) { + separator.style.verticalAlign = makeEm(-shift); + } + cols.push(separator); + } else { + throw new src_ParseError("Invalid separator type: " + colDescr.separator); + } + colDescrNum++; + colDescr = colDescriptions[colDescrNum]; + firstSeparator = false; + } + if (c >= nc) { + continue; + } + let sepwidth; + if (c > 0 || group.hskipBeforeAndAfter) { + var _colDescr$pregap, _colDescr2; + sepwidth = (_colDescr$pregap = (_colDescr2 = colDescr) == null ? void 0 : _colDescr2.pregap) != null ? _colDescr$pregap : arraycolsep; + if (sepwidth !== 0) { + colSep = makeSpan(["arraycolsep"], []); + colSep.style.width = makeEm(sepwidth); + cols.push(colSep); + } + } + const colElems = []; + for (r = 0; r < nr; ++r) { + const row = body[r]; + const elem = row.cells[c]; + if (!elem) { + continue; + } + const shift = row.pos - offset; + elem.depth = row.depth; + elem.height = row.height; + colElems.push({ + type: "elem", + elem: elem, + shift: shift + }); + } + const colVList = makeVList({ + positionType: "individualShift", + children: colElems + }, options); + const colSpan = makeSpan(["col-align-" + (((_colDescr3 = colDescr) == null ? void 0 : _colDescr3.align) || "c")], [colVList]); + cols.push(colSpan); + if (c < nc - 1 || group.hskipBeforeAndAfter) { + var _colDescr$postgap, _colDescr4; + sepwidth = (_colDescr$postgap = (_colDescr4 = colDescr) == null ? void 0 : _colDescr4.postgap) != null ? _colDescr$postgap : arraycolsep; + if (sepwidth !== 0) { + colSep = makeSpan(["arraycolsep"], []); + colSep.style.width = makeEm(sepwidth); + cols.push(colSep); + } + } + } + let tableBody = makeSpan(["mtable"], cols); + + // Add \hline(s), if any. + if (hlines.length > 0) { + const line = makeLineSpan("hline", options, ruleThickness); + const dashes = makeLineSpan("hdashline", options, ruleThickness); + const vListElems = [{ + type: "elem", + elem: tableBody, + shift: 0 + }]; + while (hlines.length > 0) { + const hline = hlines.pop(); + const lineShift = hline.pos - offset; + if (hline.isDashed) { + vListElems.push({ + type: "elem", + elem: dashes, + shift: lineShift + }); + } else { + vListElems.push({ + type: "elem", + elem: line, + shift: lineShift + }); + } + } + tableBody = makeVList({ + positionType: "individualShift", + children: vListElems + }, options); + } + if (tagSpans.length === 0) { + return makeSpan(["mord"], [tableBody], options); + } else { + const eqnNumCol = makeVList({ + positionType: "individualShift", + children: tagSpans + }, options); + const tagCol = makeSpan(["tag"], [eqnNumCol], options); + return makeFragment([tableBody, tagCol]); + } +}; +const alignMap = { + c: "center ", + l: "left ", + r: "right " +}; +const array_mathmlBuilder = function (group, options) { + const tbl = []; + const glue = new MathNode("mtd", [], ["mtr-glue"]); + const tag = new MathNode("mtd", [], ["mml-eqn-num"]); + for (let i = 0; i < group.body.length; i++) { + const rw = group.body[i]; + const row = []; + for (let j = 0; j < rw.length; j++) { + row.push(new MathNode("mtd", [buildMathML_buildGroup(rw[j], options)])); + } + if (group.tags && group.tags[i]) { + row.unshift(glue); + row.push(glue); + if (group.leqno) { + row.unshift(tag); + } else { + row.push(tag); + } + } + tbl.push(new MathNode("mtr", row)); + } + let table = new MathNode("mtable", tbl); + + // Set column alignment, row spacing, column spacing, and + // array lines by setting attributes on the table element. + + // Set the row spacing. In MathML, we specify a gap distance. + // We do not use rowGap[] because MathML automatically increases + // cell height with the height/depth of the element content. + + // LaTeX \arraystretch multiplies the row baseline-to-baseline distance. + // We simulate this by adding (arraystretch - 1)em to the gap. This + // does a reasonable job of adjusting arrays containing 1 em tall content. + + // The 0.16 and 0.09 values are found empirically. They produce an array + // similar to LaTeX and in which content does not interfere with \hlines. + const gap = group.arraystretch === 0.5 ? 0.1 // {smallmatrix}, {subarray} + : 0.16 + group.arraystretch - 1 + (group.addJot ? 0.09 : 0); + table.setAttribute("rowspacing", makeEm(gap)); + + // MathML table lines go only between cells. + // To place a line on an edge we'll use , if necessary. + let menclose = ""; + let align = ""; + if (group.cols && group.cols.length > 0) { + // Find column alignment, column spacing, and vertical lines. + const cols = group.cols; + let columnLines = ""; + let prevTypeWasAlign = false; + let iStart = 0; + let iEnd = cols.length; + if (cols[0].type === "separator") { + menclose += "top "; + iStart = 1; + } + if (cols[cols.length - 1].type === "separator") { + menclose += "bottom "; + iEnd -= 1; + } + for (let i = iStart; i < iEnd; i++) { + const col = cols[i]; + if (col.type === "align") { + align += alignMap[col.align]; + if (prevTypeWasAlign) { + columnLines += "none "; + } + prevTypeWasAlign = true; + } else if (col.type === "separator") { + // MathML accepts only single lines between cells. + // So we read only the first of consecutive separators. + if (prevTypeWasAlign) { + columnLines += col.separator === "|" ? "solid " : "dashed "; + prevTypeWasAlign = false; + } + } + } + table.setAttribute("columnalign", align.trim()); + if (/[sd]/.test(columnLines)) { + table.setAttribute("columnlines", columnLines.trim()); + } + } + + // Set column spacing. + if (group.colSeparationType === "align") { + const cols = group.cols || []; + let spacing = ""; + for (let i = 1; i < cols.length; i++) { + spacing += i % 2 ? "0em " : "1em "; + } + table.setAttribute("columnspacing", spacing.trim()); + } else if (group.colSeparationType === "alignat" || group.colSeparationType === "gather") { + table.setAttribute("columnspacing", "0em"); + } else if (group.colSeparationType === "small") { + table.setAttribute("columnspacing", "0.2778em"); + } else if (group.colSeparationType === "CD") { + table.setAttribute("columnspacing", "0.5em"); + } else { + table.setAttribute("columnspacing", "1em"); + } + + // Address \hline and \hdashline + let rowLines = ""; + const hlines = group.hLinesBeforeRow; + menclose += hlines[0].length > 0 ? "left " : ""; + menclose += hlines[hlines.length - 1].length > 0 ? "right " : ""; + for (let i = 1; i < hlines.length - 1; i++) { + rowLines += hlines[i].length === 0 ? "none " + // MathML accepts only a single line between rows. Read one element. + : hlines[i][0] ? "dashed " : "solid "; + } + if (/[sd]/.test(rowLines)) { + table.setAttribute("rowlines", rowLines.trim()); + } + if (menclose !== "") { + table = new MathNode("menclose", [table]); + table.setAttribute("notation", menclose.trim()); + } + if (group.arraystretch && group.arraystretch < 1) { + // A small array. Wrap in scriptstyle so row gap is not too large. + table = new MathNode("mstyle", [table]); + table.setAttribute("scriptlevel", "1"); + } + return table; +}; + +// Convenience function for align, align*, aligned, alignat, alignat*, alignedat. +const alignedHandler = function (context, args) { + if (!context.envName.includes("ed")) { + validateAmsEnvironmentContext(context); + } + const cols = []; + const separationType = context.envName.includes("at") ? "alignat" : "align"; + const isSplit = context.envName === "split"; + const res = parseArray(context.parser, { + cols, + addJot: true, + autoTag: isSplit ? undefined : getAutoTag(context.envName), + emptySingleRow: true, + colSeparationType: separationType, + maxNumCols: isSplit ? 2 : undefined, + leqno: context.parser.settings.leqno + }, "display"); + + // Determining number of columns. + // 1. If the first argument is given, we use it as a number of columns, + // and makes sure that each row doesn't exceed that number. + // 2. Otherwise, just count number of columns = maximum number + // of cells in each row ("aligned" mode -- isAligned will be true). + // + // At the same time, prepend empty group {} at beginning of every second + // cell in each row (starting with second cell) so that operators become + // binary. This behavior is implemented in amsmath's \start@aligned. + let numMaths = 0; + let numCols = 0; + const emptyGroup = { + type: "ordgroup", + mode: context.mode, + body: [] + }; + if (args[0] && args[0].type === "ordgroup") { + let arg0 = ""; + for (let i = 0; i < args[0].body.length; i++) { + const textord = assertNodeType(args[0].body[i], "textord"); + arg0 += textord.text; + } + numMaths = Number(arg0); + numCols = numMaths * 2; + } + const isAligned = !numCols; + res.body.forEach(function (row) { + for (let i = 1; i < row.length; i += 2) { + // Modify ordgroup node within styling node + const styling = assertNodeType(row[i], "styling"); + const ordgroup = assertNodeType(styling.body[0], "ordgroup"); + ordgroup.body.unshift(emptyGroup); + } + if (!isAligned) { + // Case 1 + const curMaths = row.length / 2; + if (numMaths < curMaths) { + throw new src_ParseError("Too many math in a row: " + ("expected " + numMaths + ", but got " + curMaths), row[0]); + } + } else if (numCols < row.length) { + // Case 2 + numCols = row.length; + } + }); + + // Adjusting alignment. + // In aligned mode, we add one \qquad between columns; + // otherwise we add nothing. + for (let i = 0; i < numCols; ++i) { + let align = "r"; + let pregap = 0; + if (i % 2 === 1) { + align = "l"; + } else if (i > 0 && isAligned) { + // "aligned" mode. + pregap = 1; // add one \quad + } + cols[i] = { + type: "align", + align: align, + pregap: pregap, + postgap: 0 + }; + } + res.colSeparationType = isAligned ? "align" : "alignat"; + return res; +}; + +// Arrays are part of LaTeX, defined in lttab.dtx so its documentation +// is part of the source2e.pdf file of LaTeX2e source documentation. +// {darray} is an {array} environment where cells are set in \displaystyle, +// as defined in nccmath.sty. +defineEnvironment({ + type: "array", + names: ["array", "darray"], + props: { + numArgs: 1 + }, + handler(context, args) { + // Since no types are specified above, the two possibilities are + // - The argument is wrapped in {} or [], in which case Parser's + // parseGroup() returns an "ordgroup" wrapping some symbol node. + // - The argument is a bare symbol node. + const symNode = checkSymbolNodeType(args[0]); + const colalign = symNode ? [args[0]] : assertNodeType(args[0], "ordgroup").body; + const cols = colalign.map(function (nde) { + const node = assertSymbolNodeType(nde); + const ca = node.text; + if ("lcr".includes(ca)) { + return { + type: "align", + align: ca + }; + } else if (ca === "|") { + return { + type: "separator", + separator: "|" + }; + } else if (ca === ":") { + return { + type: "separator", + separator: ":" + }; + } + throw new src_ParseError("Unknown column alignment: " + ca, nde); + }); + const res = { + cols, + hskipBeforeAndAfter: true, + // \@preamble in lttab.dtx + maxNumCols: cols.length + }; + return parseArray(context.parser, res, dCellStyle(context.envName)); + }, + htmlBuilder: array_htmlBuilder, + mathmlBuilder: array_mathmlBuilder +}); + +// The matrix environments of amsmath builds on the array environment +// of LaTeX, which is discussed above. +// The mathtools package adds starred versions of the same environments. +// These have an optional argument to choose left|center|right justification. +defineEnvironment({ + type: "array", + names: ["matrix", "pmatrix", "bmatrix", "Bmatrix", "vmatrix", "Vmatrix", "matrix*", "pmatrix*", "bmatrix*", "Bmatrix*", "vmatrix*", "Vmatrix*"], + props: { + numArgs: 0 + }, + handler(context) { + const delimiters = { + "matrix": null, + "pmatrix": ["(", ")"], + "bmatrix": ["[", "]"], + "Bmatrix": ["\\{", "\\}"], + "vmatrix": ["|", "|"], + "Vmatrix": ["\\Vert", "\\Vert"] + }[context.envName.replace("*", "")]; + // \hskip -\arraycolsep in amsmath + let colAlign = "c"; + const payload = { + hskipBeforeAndAfter: false, + cols: [{ + type: "align", + align: colAlign + }] + }; + if (context.envName.charAt(context.envName.length - 1) === "*") { + // It's one of the mathtools starred functions. + // Parse the optional alignment argument. + const parser = context.parser; + parser.consumeSpaces(); + if (parser.fetch().text === "[") { + parser.consume(); + parser.consumeSpaces(); + colAlign = parser.fetch().text; + if (!"lcr".includes(colAlign)) { + throw new src_ParseError("Expected l or c or r", parser.nextToken); + } + parser.consume(); + parser.consumeSpaces(); + parser.expect("]"); + parser.consume(); + payload.cols = [{ + type: "align", + align: colAlign + }]; + } + } + const res = parseArray(context.parser, payload, dCellStyle(context.envName)); + // Populate cols with the correct number of column alignment specs. + const numCols = Math.max(0, ...res.body.map(row => row.length)); + res.cols = new Array(numCols).fill({ + type: "align", + align: colAlign + }); + return delimiters ? { + type: "leftright", + mode: context.mode, + body: [res], + left: delimiters[0], + right: delimiters[1], + rightColor: undefined // \right uninfluenced by \color in array + } : res; + }, + htmlBuilder: array_htmlBuilder, + mathmlBuilder: array_mathmlBuilder +}); +defineEnvironment({ + type: "array", + names: ["smallmatrix"], + props: { + numArgs: 0 + }, + handler(context) { + const payload = { + arraystretch: 0.5 + }; + const res = parseArray(context.parser, payload, "script"); + res.colSeparationType = "small"; + return res; + }, + htmlBuilder: array_htmlBuilder, + mathmlBuilder: array_mathmlBuilder +}); +defineEnvironment({ + type: "array", + names: ["subarray"], + props: { + numArgs: 1 + }, + handler(context, args) { + // Parsing of {subarray} is similar to {array} + const symNode = checkSymbolNodeType(args[0]); + const colalign = symNode ? [args[0]] : assertNodeType(args[0], "ordgroup").body; + const cols = colalign.map(function (nde) { + const node = assertSymbolNodeType(nde); + const ca = node.text; + // {subarray} only recognizes "l" & "c" + if ("lc".includes(ca)) { + return { + type: "align", + align: ca + }; + } + throw new src_ParseError("Unknown column alignment: " + ca, nde); + }); + if (cols.length > 1) { + throw new src_ParseError("{subarray} can contain only one column"); + } + const payload = { + cols, + hskipBeforeAndAfter: false, + arraystretch: 0.5 + }; + const res = parseArray(context.parser, payload, "script"); + if (res.body.length > 0 && res.body[0].length > 1) { + throw new src_ParseError("{subarray} can contain only one column"); + } + return res; + }, + htmlBuilder: array_htmlBuilder, + mathmlBuilder: array_mathmlBuilder +}); + +// A cases environment (in amsmath.sty) is almost equivalent to +// \def\arraystretch{1.2}% +// \left\{\begin{array}{@{}l@{\quad}l@{}} … \end{array}\right. +// {dcases} is a {cases} environment where cells are set in \displaystyle, +// as defined in mathtools.sty. +// {rcases} is another mathtools environment. It's brace is on the right side. +defineEnvironment({ + type: "array", + names: ["cases", "dcases", "rcases", "drcases"], + props: { + numArgs: 0 + }, + handler(context) { + const payload = { + arraystretch: 1.2, + cols: [{ + type: "align", + align: "l", + pregap: 0, + // TODO(kevinb) get the current style. + // For now we use the metrics for TEXT style which is what we were + // doing before. Before attempting to get the current style we + // should look at TeX's behavior especially for \over and matrices. + postgap: 1.0 /* 1em quad */ + }, { + type: "align", + align: "l", + pregap: 0, + postgap: 0 + }] + }; + const res = parseArray(context.parser, payload, dCellStyle(context.envName)); + return { + type: "leftright", + mode: context.mode, + body: [res], + left: context.envName.includes("r") ? "." : "\\{", + right: context.envName.includes("r") ? "\\}" : ".", + rightColor: undefined + }; + }, + htmlBuilder: array_htmlBuilder, + mathmlBuilder: array_mathmlBuilder +}); + +// In the align environment, one uses ampersands, &, to specify number of +// columns in each row, and to locate spacing between each column. +// align gets automatic numbering. align* and aligned do not. +// The alignedat environment can be used in math mode. +// Note that we assume \nomallineskiplimit to be zero, +// so that \strut@ is the same as \strut. +defineEnvironment({ + type: "array", + names: ["align", "align*", "aligned", "split"], + props: { + numArgs: 0 + }, + handler: alignedHandler, + htmlBuilder: array_htmlBuilder, + mathmlBuilder: array_mathmlBuilder +}); + +// A gathered environment is like an array environment with one centered +// column, but where rows are considered lines so get \jot line spacing +// and contents are set in \displaystyle. +defineEnvironment({ + type: "array", + names: ["gathered", "gather", "gather*"], + props: { + numArgs: 0 + }, + handler(context) { + if (gatherEnvironments.has(context.envName)) { + validateAmsEnvironmentContext(context); + } + const res = { + cols: [{ + type: "align", + align: "c" + }], + addJot: true, + colSeparationType: "gather", + autoTag: getAutoTag(context.envName), + emptySingleRow: true, + leqno: context.parser.settings.leqno + }; + return parseArray(context.parser, res, "display"); + }, + htmlBuilder: array_htmlBuilder, + mathmlBuilder: array_mathmlBuilder +}); + +// alignat environment is like an align environment, but one must explicitly +// specify maximum number of columns in each row, and can adjust spacing between +// each columns. +defineEnvironment({ + type: "array", + names: ["alignat", "alignat*", "alignedat"], + props: { + numArgs: 1 + }, + handler: alignedHandler, + htmlBuilder: array_htmlBuilder, + mathmlBuilder: array_mathmlBuilder +}); +defineEnvironment({ + type: "array", + names: ["equation", "equation*"], + props: { + numArgs: 0 + }, + handler(context) { + validateAmsEnvironmentContext(context); + const res = { + autoTag: getAutoTag(context.envName), + emptySingleRow: true, + singleRow: true, + maxNumCols: 1, + leqno: context.parser.settings.leqno + }; + return parseArray(context.parser, res, "display"); + }, + htmlBuilder: array_htmlBuilder, + mathmlBuilder: array_mathmlBuilder +}); +defineEnvironment({ + type: "array", + names: ["CD"], + props: { + numArgs: 0 + }, + handler(context) { + validateAmsEnvironmentContext(context); + return parseCD(context.parser); + }, + htmlBuilder: array_htmlBuilder, + mathmlBuilder: array_mathmlBuilder +}); +defineMacro("\\nonumber", "\\gdef\\@eqnsw{0}"); +defineMacro("\\notag", "\\nonumber"); + +// Catch \hline outside array environment +defineFunction({ + type: "text", + // Doesn't matter what this is. + names: ["\\hline", "\\hdashline"], + props: { + numArgs: 0, + allowedInText: true, + allowedInMath: true + }, + handler(context, args) { + throw new src_ParseError(context.funcName + " valid only within array environment"); + } +}); +;// ./src/environments.ts + +const environments = _environments; +/* harmony default export */ var src_environments = (environments); + +// All environment definitions should be imported below + +;// ./src/functions/environment.ts + + + + +// Environment delimiters. HTML/MathML rendering is defined in the corresponding +// defineEnvironment definitions. +defineFunction({ + type: "environment", + names: ["\\begin", "\\end"], + props: { + numArgs: 1, + argTypes: ["text"] + }, + handler(_ref, args) { + let { + parser, + funcName + } = _ref; + const nameGroup = args[0]; + if (nameGroup.type !== "ordgroup") { + throw new src_ParseError("Invalid environment name", nameGroup); + } + let envName = ""; + for (let i = 0; i < nameGroup.body.length; ++i) { + envName += assertNodeType(nameGroup.body[i], "textord").text; + } + if (funcName === "\\begin") { + // begin...end is similar to left...right + if (!src_environments.hasOwnProperty(envName)) { + throw new src_ParseError("No such environment: " + envName, nameGroup); + } + // Build the environment object. Arguments and other information will + // be made available to the begin and end methods using properties. + const env = src_environments[envName]; + const { + args, + optArgs + } = parser.parseArguments("\\begin{" + envName + "}", env); + const context = { + mode: parser.mode, + envName, + parser + }; + const result = env.handler(context, args, optArgs); + parser.expect("\\end", false); + const endNameToken = parser.nextToken; + const end = assertNodeType(parser.parseFunction(), "environment"); + if (end.name !== envName) { + throw new src_ParseError("Mismatch: \\begin{" + envName + "} matched by \\end{" + end.name + "}", endNameToken); + } + // env.handler returns the specific node type (e.g. "array"), + // not "environment". This cast is unavoidable: defineFunction + // requires the handler to return ParseNode<"environment"> but + // \begin delegates to environment handlers with different types. + return result; + } + return { + type: "environment", + mode: parser.mode, + name: envName, + nameGroup + }; + } +}); +;// ./src/functions/font.ts +// TODO(kevinb): implement \\sl and \\sc + + + + + + +const font_htmlBuilder = (group, options) => { + const font = group.font; + const newOptions = options.withFont(font); + return buildGroup(group.body, newOptions); +}; +const font_mathmlBuilder = (group, options) => { + const font = group.font; + const newOptions = options.withFont(font); + return buildMathML_buildGroup(group.body, newOptions); +}; +const fontAliases = { + "\\Bbb": "\\mathbb", + "\\bold": "\\mathbf", + "\\frak": "\\mathfrak" +}; +defineFunction({ + type: "font", + names: [ + // styles, except \boldsymbol defined below + "\\mathrm", "\\mathit", "\\mathbf", "\\mathnormal", "\\mathsfit", + // families + "\\mathbb", "\\mathcal", "\\mathfrak", "\\mathscr", "\\mathsf", "\\mathtt", + // aliases, except \bm defined below + "\\Bbb", "\\bold", "\\frak"], + props: { + numArgs: 1, + allowedInArgument: true + }, + handler: (_ref, args) => { + let { + parser, + funcName + } = _ref; + const body = normalizeArgument(args[0]); + let func = funcName; + if (func in fontAliases) { + func = fontAliases[func]; + } + return { + type: "font", + mode: parser.mode, + font: func.slice(1), + body + }; + }, + htmlBuilder: font_htmlBuilder, + mathmlBuilder: font_mathmlBuilder +}); +defineFunction({ + type: "mclass", + names: ["\\boldsymbol", "\\bm"], + props: { + numArgs: 1 + }, + handler: (_ref2, args) => { + let { + parser + } = _ref2; + const body = args[0]; + // amsbsy.sty's \boldsymbol uses \binrel spacing to inherit the + // argument's bin|rel|ord status + return { + type: "mclass", + mode: parser.mode, + mclass: binrelClass(body), + body: [{ + type: "font", + mode: parser.mode, + font: "boldsymbol", + body + }], + isCharacterBox: isCharacterBox(body) + }; + } +}); + +// Old font changing functions +defineFunction({ + type: "font", + names: ["\\rm", "\\sf", "\\tt", "\\bf", "\\it", "\\cal"], + props: { + numArgs: 0, + allowedInText: true + }, + handler: (_ref3, args) => { + let { + parser, + funcName, + breakOnTokenText + } = _ref3; + const { + mode + } = parser; + const body = parser.parseExpression(true, breakOnTokenText); + return { + type: "font", + mode: mode, + font: "math" + funcName.slice(1), + body: { + type: "ordgroup", + mode: parser.mode, + body + } + }; + }, + htmlBuilder: font_htmlBuilder, + mathmlBuilder: font_mathmlBuilder +}); +;// ./src/functions/genfrac.ts + + + + + + + + + +const genfrac_htmlBuilder = (group, options) => { + // Fractions are handled in the TeXbook on pages 444-445, rules 15(a-e). + const style = options.style; + const nstyle = style.fracNum(); + const dstyle = style.fracDen(); + let newOptions; + newOptions = options.havingStyle(nstyle); + const numerm = buildGroup(group.numer, newOptions, options); + if (group.continued) { + // \cfrac inserts a \strut into the numerator. + // Get \strut dimensions from TeXbook page 353. + const hStrut = 8.5 / options.fontMetrics().ptPerEm; + const dStrut = 3.5 / options.fontMetrics().ptPerEm; + numerm.height = numerm.height < hStrut ? hStrut : numerm.height; + numerm.depth = numerm.depth < dStrut ? dStrut : numerm.depth; + } + newOptions = options.havingStyle(dstyle); + const denomm = buildGroup(group.denom, newOptions, options); + let rule; + let ruleWidth; + let ruleSpacing; + if (group.hasBarLine) { + if (group.barSize) { + ruleWidth = calculateSize(group.barSize, options); + rule = makeLineSpan("frac-line", options, ruleWidth); + } else { + rule = makeLineSpan("frac-line", options); + } + ruleWidth = rule.height; + ruleSpacing = rule.height; + } else { + rule = null; + ruleWidth = 0; + ruleSpacing = options.fontMetrics().defaultRuleThickness; + } + + // Rule 15b + let numShift; + let clearance; + let denomShift; + if (style.size === src_Style.DISPLAY.size) { + numShift = options.fontMetrics().num1; + if (ruleWidth > 0) { + clearance = 3 * ruleSpacing; + } else { + clearance = 7 * ruleSpacing; + } + denomShift = options.fontMetrics().denom1; + } else { + if (ruleWidth > 0) { + numShift = options.fontMetrics().num2; + clearance = ruleSpacing; + } else { + numShift = options.fontMetrics().num3; + clearance = 3 * ruleSpacing; + } + denomShift = options.fontMetrics().denom2; + } + let frac; + if (!rule) { + // Rule 15c + const candidateClearance = numShift - numerm.depth - (denomm.height - denomShift); + if (candidateClearance < clearance) { + numShift += 0.5 * (clearance - candidateClearance); + denomShift += 0.5 * (clearance - candidateClearance); + } + frac = makeVList({ + positionType: "individualShift", + children: [{ + type: "elem", + elem: denomm, + shift: denomShift + }, { + type: "elem", + elem: numerm, + shift: -numShift + }] + }, options); + } else { + // Rule 15d + const axisHeight = options.fontMetrics().axisHeight; + if (numShift - numerm.depth - (axisHeight + 0.5 * ruleWidth) < clearance) { + numShift += clearance - (numShift - numerm.depth - (axisHeight + 0.5 * ruleWidth)); + } + if (axisHeight - 0.5 * ruleWidth - (denomm.height - denomShift) < clearance) { + denomShift += clearance - (axisHeight - 0.5 * ruleWidth - (denomm.height - denomShift)); + } + const midShift = -(axisHeight - 0.5 * ruleWidth); + frac = makeVList({ + positionType: "individualShift", + children: [{ + type: "elem", + elem: denomm, + shift: denomShift + }, { + type: "elem", + elem: rule, + shift: midShift + }, { + type: "elem", + elem: numerm, + shift: -numShift + }] + }, options); + } + + // Since we manually change the style sometimes (with \dfrac or \tfrac), + // account for the possible size change here. + newOptions = options.havingStyle(style); + frac.height *= newOptions.sizeMultiplier / options.sizeMultiplier; + frac.depth *= newOptions.sizeMultiplier / options.sizeMultiplier; + + // Rule 15e + let delimSize; + if (style.size === src_Style.DISPLAY.size) { + delimSize = options.fontMetrics().delim1; + } else if (style.size === src_Style.SCRIPTSCRIPT.size) { + delimSize = options.havingStyle(src_Style.SCRIPT).fontMetrics().delim2; + } else { + delimSize = options.fontMetrics().delim2; + } + let leftDelim; + let rightDelim; + if (group.leftDelim == null) { + leftDelim = makeNullDelimiter(options, ["mopen"]); + } else { + leftDelim = makeCustomSizedDelim(group.leftDelim, delimSize, true, options.havingStyle(style), group.mode, ["mopen"]); + } + if (group.continued) { + rightDelim = makeSpan([]); // zero width for \cfrac + } else if (group.rightDelim == null) { + rightDelim = makeNullDelimiter(options, ["mclose"]); + } else { + rightDelim = makeCustomSizedDelim(group.rightDelim, delimSize, true, options.havingStyle(style), group.mode, ["mclose"]); + } + return makeSpan(["mord"].concat(newOptions.sizingClasses(options)), [leftDelim, makeSpan(["mfrac"], [frac]), rightDelim], options); +}; +const genfrac_mathmlBuilder = (group, options) => { + const node = new MathNode("mfrac", [buildMathML_buildGroup(group.numer, options), buildMathML_buildGroup(group.denom, options)]); + if (!group.hasBarLine) { + node.setAttribute("linethickness", "0px"); + } else if (group.barSize) { + const ruleWidth = calculateSize(group.barSize, options); + node.setAttribute("linethickness", makeEm(ruleWidth)); + } + if (group.leftDelim != null || group.rightDelim != null) { + const withDelims = []; + if (group.leftDelim != null) { + const leftOp = new MathNode("mo", [new TextNode(group.leftDelim.replace("\\", ""))]); + leftOp.setAttribute("fence", "true"); + withDelims.push(leftOp); + } + withDelims.push(node); + if (group.rightDelim != null) { + const rightOp = new MathNode("mo", [new TextNode(group.rightDelim.replace("\\", ""))]); + rightOp.setAttribute("fence", "true"); + withDelims.push(rightOp); + } + return makeRow(withDelims); + } + return node; +}; +const wrapWithStyle = (frac, style) => { + if (!style) { + return frac; + } + const wrapper = { + type: "styling", + mode: frac.mode, + style, + body: [frac] + }; + + // @ts-ignore defineFunction handler needs to return ParseNode<"genfrac"> + return wrapper; +}; +defineFunction({ + type: "genfrac", + names: ["\\cfrac", "\\dfrac", "\\frac", "\\tfrac", "\\dbinom", "\\binom", "\\tbinom", "\\\\atopfrac", + // can’t be entered directly + "\\\\bracefrac", "\\\\brackfrac" // ditto + ], + props: { + numArgs: 2, + allowedInArgument: true + }, + handler: (_ref, args) => { + let { + parser, + funcName + } = _ref; + const numer = args[0]; + const denom = args[1]; + let hasBarLine; + let leftDelim = null; + let rightDelim = null; + switch (funcName) { + case "\\cfrac": + case "\\dfrac": + case "\\frac": + case "\\tfrac": + hasBarLine = true; + break; + case "\\\\atopfrac": + hasBarLine = false; + break; + case "\\dbinom": + case "\\binom": + case "\\tbinom": + hasBarLine = false; + leftDelim = "("; + rightDelim = ")"; + break; + case "\\\\bracefrac": + hasBarLine = false; + leftDelim = "\\{"; + rightDelim = "\\}"; + break; + case "\\\\brackfrac": + hasBarLine = false; + leftDelim = "["; + rightDelim = "]"; + break; + default: + throw new Error("Unrecognized genfrac command"); + } + const continued = funcName === "\\cfrac"; + let style = null; + if (continued || funcName.startsWith("\\d")) { + style = "display"; + } else if (funcName.startsWith("\\t")) { + style = "text"; + } + return wrapWithStyle({ + type: "genfrac", + mode: parser.mode, + numer, + denom, + continued, + hasBarLine, + leftDelim, + rightDelim, + barSize: null + }, style); + }, + htmlBuilder: genfrac_htmlBuilder, + mathmlBuilder: genfrac_mathmlBuilder +}); + +// Infix generalized fractions -- these are not rendered directly, but replaced +// immediately by one of the variants above. +defineFunction({ + type: "infix", + names: ["\\over", "\\choose", "\\atop", "\\brace", "\\brack"], + props: { + numArgs: 0, + infix: true + }, + handler(_ref2) { + let { + parser, + funcName, + token + } = _ref2; + let replaceWith; + switch (funcName) { + case "\\over": + replaceWith = "\\frac"; + break; + case "\\choose": + replaceWith = "\\binom"; + break; + case "\\atop": + replaceWith = "\\\\atopfrac"; + break; + case "\\brace": + replaceWith = "\\\\bracefrac"; + break; + case "\\brack": + replaceWith = "\\\\brackfrac"; + break; + default: + throw new Error("Unrecognized infix genfrac command"); + } + return { + type: "infix", + mode: parser.mode, + replaceWith, + token + }; + } +}); +const stylArray = ["display", "text", "script", "scriptscript"]; +const delimFromValue = function (delimString) { + let delim = null; + if (delimString.length > 0) { + delim = delimString; + delim = delim === "." ? null : delim; + } + return delim; +}; +defineFunction({ + type: "genfrac", + names: ["\\genfrac"], + props: { + numArgs: 6, + allowedInArgument: true, + argTypes: ["math", "math", "size", "text", "math", "math"] + }, + handler(_ref3, args) { + let { + parser + } = _ref3; + const numer = args[4]; + const denom = args[5]; + + // Look into the parse nodes to get the desired delimiters. + const leftNode = normalizeArgument(args[0]); + const leftDelim = leftNode.type === "atom" && leftNode.family === "open" ? delimFromValue(leftNode.text) : null; + const rightNode = normalizeArgument(args[1]); + const rightDelim = rightNode.type === "atom" && rightNode.family === "close" ? delimFromValue(rightNode.text) : null; + const barNode = assertNodeType(args[2], "size"); + let hasBarLine; + let barSize = null; + if (barNode.isBlank) { + // \genfrac acts differently than \above. + // \genfrac treats an empty size group as a signal to use a + // standard bar size. \above would see size = 0 and omit the bar. + hasBarLine = true; + } else { + barSize = barNode.value; + hasBarLine = barSize.number > 0; + } + + // Find out if we want displaystyle, textstyle, etc. + let size = null; + let styl = args[3]; + if (styl.type === "ordgroup") { + if (styl.body.length > 0) { + const textOrd = assertNodeType(styl.body[0], "textord"); + size = stylArray[Number(textOrd.text)]; + } + } else { + styl = assertNodeType(styl, "textord"); + size = stylArray[Number(styl.text)]; + } + return wrapWithStyle({ + type: "genfrac", + mode: parser.mode, + numer, + denom, + continued: false, + hasBarLine, + barSize, + leftDelim, + rightDelim + }, size); + } +}); + +// \above is an infix fraction that also defines a fraction bar size. +defineFunction({ + type: "infix", + names: ["\\above"], + props: { + numArgs: 1, + argTypes: ["size"], + infix: true + }, + handler(_ref4, args) { + let { + parser, + funcName, + token + } = _ref4; + return { + type: "infix", + mode: parser.mode, + replaceWith: "\\\\abovefrac", + size: assertNodeType(args[0], "size").value, + token + }; + } +}); +defineFunction({ + type: "genfrac", + names: ["\\\\abovefrac"], + props: { + numArgs: 3, + argTypes: ["math", "size", "math"] + }, + handler: (_ref5, args) => { + let { + parser, + funcName + } = _ref5; + const numer = args[0]; + const barSize = assertNodeType(args[1], "infix").size; + if (!barSize) { + throw new Error("\\\\abovefrac expected size, but got " + String(barSize)); + } + const denom = args[2]; + const hasBarLine = barSize.number > 0; + return { + type: "genfrac", + mode: parser.mode, + numer, + denom, + continued: false, + hasBarLine, + barSize, + leftDelim: null, + rightDelim: null + }; + } +}); +;// ./src/functions/horizBrace.ts + + + + + + + + +// NOTE: Unlike most `htmlBuilder`s, this one handles not only "horizBrace", but +// also "supsub" since an over/underbrace can affect super/subscripting. +const horizBrace_htmlBuilder = (grp, options) => { + const style = options.style; + + // Pull out the `ParseNode<"horizBrace">` if `grp` is a "supsub" node. + let supSubGroup; + let group; + if (grp.type === "supsub") { + // Ref: LaTeX source2e: }}}}\limits} + // i.e. LaTeX treats the brace similar to an op and passes it + // with \limits, so we need to assign supsub style. + supSubGroup = grp.sup ? buildGroup(grp.sup, options.havingStyle(style.sup()), options) : buildGroup(grp.sub, options.havingStyle(style.sub()), options); + group = assertNodeType(grp.base, "horizBrace"); + } else { + group = assertNodeType(grp, "horizBrace"); + } + + // Build the base group + const body = buildGroup(group.base, options.havingBaseStyle(src_Style.DISPLAY)); + + // Create the stretchy element + const braceBody = stretchySvg(group, options); + + // Generate the vlist, with the appropriate kerns ┏━━━━━━━━┓ + // This first vlist contains the content and the brace: equation + let vlist; + if (group.isOver) { + vlist = makeVList({ + positionType: "firstBaseline", + children: [{ + type: "elem", + elem: body + }, { + type: "kern", + size: 0.1 + }, { + type: "elem", + elem: braceBody, + wrapperClasses: ["svg-align"] + }] + }, options); + } else { + vlist = makeVList({ + positionType: "bottom", + positionData: body.depth + 0.1 + braceBody.height, + children: [{ + type: "elem", + elem: braceBody, + wrapperClasses: ["svg-align"] + }, { + type: "kern", + size: 0.1 + }, { + type: "elem", + elem: body + }] + }, options); + } + if (supSubGroup) { + // To write the supsub, wrap the first vlist in another vlist: + // They can't all go in the same vlist, because the note might be + // wider than the equation. We want the equation to control the + // brace width. + + // note long note long note + // ┏━━━━━━━━┓ or ┏━━━┓ not ┏━━━━━━━━━┓ + // equation eqn eqn + + const vSpan = makeSpan(["minner", group.isOver ? "mover" : "munder"], [vlist], options); + if (group.isOver) { + vlist = makeVList({ + positionType: "firstBaseline", + children: [{ + type: "elem", + elem: vSpan + }, { + type: "kern", + size: 0.2 + }, { + type: "elem", + elem: supSubGroup + }] + }, options); + } else { + vlist = makeVList({ + positionType: "bottom", + positionData: vSpan.depth + 0.2 + supSubGroup.height + supSubGroup.depth, + children: [{ + type: "elem", + elem: supSubGroup + }, { + type: "kern", + size: 0.2 + }, { + type: "elem", + elem: vSpan + }] + }, options); + } + } + return makeSpan(["minner", group.isOver ? "mover" : "munder"], [vlist], options); +}; +const horizBrace_mathmlBuilder = (group, options) => { + const accentNode = stretchyMathML(group.label); + return new MathNode(group.isOver ? "mover" : "munder", [buildMathML_buildGroup(group.base, options), accentNode]); +}; + +// Horizontal stretchy braces +defineFunction({ + type: "horizBrace", + names: ["\\overbrace", "\\underbrace", "\\overbracket", "\\underbracket"], + props: { + numArgs: 1 + }, + handler(_ref, args) { + let { + parser, + funcName + } = _ref; + return { + type: "horizBrace", + mode: parser.mode, + label: funcName, + isOver: funcName.includes("\\over"), + base: args[0] + }; + }, + htmlBuilder: horizBrace_htmlBuilder, + mathmlBuilder: horizBrace_mathmlBuilder +}); +;// ./src/functions/href.ts + + + + + + +defineFunction({ + type: "href", + names: ["\\href"], + props: { + numArgs: 2, + argTypes: ["url", "original"], + allowedInText: true + }, + handler: (_ref, args) => { + let { + parser + } = _ref; + const body = args[1]; + const href = assertNodeType(args[0], "url").url; + if (!parser.settings.isTrusted({ + command: "\\href", + url: href + })) { + return parser.formatUnsupportedCmd("\\href"); + } + return { + type: "href", + mode: parser.mode, + href, + body: ordargument(body) + }; + }, + htmlBuilder: (group, options) => { + const elements = buildExpression(group.body, options, false); + return makeAnchor(group.href, [], elements, options); + }, + mathmlBuilder: (group, options) => { + let math = buildExpressionRow(group.body, options); + if (!(math instanceof MathNode)) { + math = new MathNode("mrow", [math]); + } + math.setAttribute("href", group.href); + return math; + } +}); +defineFunction({ + type: "href", + names: ["\\url"], + props: { + numArgs: 1, + argTypes: ["url"], + allowedInText: true + }, + handler: (_ref2, args) => { + let { + parser + } = _ref2; + const href = assertNodeType(args[0], "url").url; + if (!parser.settings.isTrusted({ + command: "\\url", + url: href + })) { + return parser.formatUnsupportedCmd("\\url"); + } + const chars = []; + for (let i = 0; i < href.length; i++) { + let c = href[i]; + if (c === "~") { + c = "\\textasciitilde"; + } + chars.push({ + type: "textord", + mode: "text", + text: c + }); + } + const body = { + type: "text", + mode: parser.mode, + font: "\\texttt", + body: chars + }; + return { + type: "href", + mode: parser.mode, + href, + body: ordargument(body) + }; + } +}); +;// ./src/functions/hbox.ts + + + + + + +// \hbox is provided for compatibility with LaTeX \vcenter. +// In LaTeX, \vcenter can act only on a box, as in +// \vcenter{\hbox{$\frac{a+b}{\dfrac{c}{d}}$}} +// This function by itself doesn't do anything but prevent a soft line break. + +defineFunction({ + type: "hbox", + names: ["\\hbox"], + props: { + numArgs: 1, + argTypes: ["text"], + allowedInText: true, + primitive: true + }, + handler(_ref, args) { + let { + parser + } = _ref; + return { + type: "hbox", + mode: parser.mode, + body: ordargument(args[0]) + }; + }, + htmlBuilder(group, options) { + const elements = buildExpression(group.body, options.withFont(''), false); + return makeFragment(elements); + }, + mathmlBuilder(group, options) { + return new MathNode("mrow", buildMathML_buildExpression(group.body, options.withFont(''))); + } +}); +;// ./src/functions/html.ts + + + + + + +defineFunction({ + type: "html", + names: ["\\htmlClass", "\\htmlId", "\\htmlStyle", "\\htmlData"], + props: { + numArgs: 2, + argTypes: ["raw", "original"], + allowedInText: true + }, + handler: (_ref, args) => { + let { + parser, + funcName, + token + } = _ref; + const value = assertNodeType(args[0], "raw").string; + const body = args[1]; + if (parser.settings.strict) { + parser.settings.reportNonstrict("htmlExtension", "HTML extension is disabled on strict mode"); + } + let trustContext; + const attributes = {}; + switch (funcName) { + case "\\htmlClass": + attributes.class = value; + trustContext = { + command: "\\htmlClass", + class: value + }; + break; + case "\\htmlId": + attributes.id = value; + trustContext = { + command: "\\htmlId", + id: value + }; + break; + case "\\htmlStyle": + attributes.style = value; + trustContext = { + command: "\\htmlStyle", + style: value + }; + break; + case "\\htmlData": + { + const data = value.split(","); + for (let i = 0; i < data.length; i++) { + const item = data[i]; + const firstEquals = item.indexOf("="); + if (firstEquals < 0) { + throw new src_ParseError("\\htmlData key/value '" + item + "'" + " missing equals sign"); + } + const key = item.slice(0, firstEquals); + const value = item.slice(firstEquals + 1); + attributes["data-" + key.trim()] = value; + } + trustContext = { + command: "\\htmlData", + attributes + }; + break; + } + default: + throw new Error("Unrecognized html command"); + } + if (!parser.settings.isTrusted(trustContext)) { + return parser.formatUnsupportedCmd(funcName); + } + return { + type: "html", + mode: parser.mode, + attributes, + body: ordargument(body) + }; + }, + htmlBuilder: (group, options) => { + const elements = buildExpression(group.body, options, false); + const classes = ["enclosing"]; + if (group.attributes.class) { + classes.push(...group.attributes.class.trim().split(/\s+/)); + } + const span = makeSpan(classes, elements, options); + for (const attr in group.attributes) { + if (attr !== "class" && group.attributes.hasOwnProperty(attr)) { + span.setAttribute(attr, group.attributes[attr]); + } + } + return span; + }, + mathmlBuilder: (group, options) => { + return buildExpressionRow(group.body, options); + } +}); +;// ./src/functions/htmlmathml.ts + + + + +defineFunction({ + type: "htmlmathml", + names: ["\\html@mathml"], + props: { + numArgs: 2, + allowedInArgument: true, + allowedInText: true + }, + handler: (_ref, args) => { + let { + parser + } = _ref; + return { + type: "htmlmathml", + mode: parser.mode, + html: ordargument(args[0]), + mathml: ordargument(args[1]) + }; + }, + htmlBuilder: (group, options) => { + const elements = buildExpression(group.html, options, false); + return makeFragment(elements); + }, + mathmlBuilder: (group, options) => { + return buildExpressionRow(group.mathml, options); + } +}); +;// ./src/functions/includegraphics.ts + + + + + + +const sizeData = function (str) { + if (/^[-+]? *(\d+(\.\d*)?|\.\d+)$/.test(str)) { + // str is a number with no unit specified. + // default unit is bp, per graphix package. + return { + number: +str, + unit: "bp" + }; + } else { + const match = /([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(str); + if (!match) { + throw new src_ParseError("Invalid size: '" + str + "' in \\includegraphics"); + } + const data = { + number: +(match[1] + match[2]), + // sign + magnitude, cast to number + unit: match[3] + }; + if (!validUnit(data)) { + throw new src_ParseError("Invalid unit: '" + data.unit + "' in \\includegraphics."); + } + return data; + } +}; +defineFunction({ + type: "includegraphics", + names: ["\\includegraphics"], + props: { + numArgs: 1, + numOptionalArgs: 1, + argTypes: ["raw", "url"], + allowedInText: false + }, + handler: (_ref, args, optArgs) => { + let { + parser + } = _ref; + let width = { + number: 0, + unit: "em" + }; + let height = { + number: 0.9, + unit: "em" + }; // sorta character sized. + let totalheight = { + number: 0, + unit: "em" + }; + let alt = ""; + if (optArgs[0]) { + const attributeStr = assertNodeType(optArgs[0], "raw").string; + + // Parser.js does not parse key/value pairs. We get a string. + const attributes = attributeStr.split(","); + for (let i = 0; i < attributes.length; i++) { + const keyVal = attributes[i].split("="); + if (keyVal.length === 2) { + const str = keyVal[1].trim(); + switch (keyVal[0].trim()) { + case "alt": + alt = str; + break; + case "width": + width = sizeData(str); + break; + case "height": + height = sizeData(str); + break; + case "totalheight": + totalheight = sizeData(str); + break; + default: + throw new src_ParseError("Invalid key: '" + keyVal[0] + "' in \\includegraphics."); + } + } + } + } + const src = assertNodeType(args[0], "url").url; + if (alt === "") { + // No alt given. Use the file name. Strip away the path. + alt = src; + alt = alt.replace(/^.*[\\/]/, ''); + alt = alt.substring(0, alt.lastIndexOf('.')); + } + if (!parser.settings.isTrusted({ + command: "\\includegraphics", + url: src + })) { + return parser.formatUnsupportedCmd("\\includegraphics"); + } + return { + type: "includegraphics", + mode: parser.mode, + alt: alt, + width: width, + height: height, + totalheight: totalheight, + src: src + }; + }, + htmlBuilder: (group, options) => { + const height = calculateSize(group.height, options); + let depth = 0; + if (group.totalheight.number > 0) { + depth = calculateSize(group.totalheight, options) - height; + } + let width = 0; + if (group.width.number > 0) { + width = calculateSize(group.width, options); + } + const style = { + height: makeEm(height + depth) + }; + if (width > 0) { + style.width = makeEm(width); + } + if (depth > 0) { + style.verticalAlign = makeEm(-depth); + } + const node = new Img(group.src, group.alt, style); + node.height = height; + node.depth = depth; + return node; + }, + mathmlBuilder: (group, options) => { + const node = new MathNode("mglyph", []); + node.setAttribute("alt", group.alt); + const height = calculateSize(group.height, options); + let depth = 0; + if (group.totalheight.number > 0) { + depth = calculateSize(group.totalheight, options) - height; + node.setAttribute("valign", makeEm(-depth)); + } + node.setAttribute("height", makeEm(height + depth)); + if (group.width.number > 0) { + const width = calculateSize(group.width, options); + node.setAttribute("width", makeEm(width)); + } + node.setAttribute("src", group.src); + return node; + } +}); +;// ./src/functions/kern.ts +// Horizontal spacing commands + + + + + + + +// TODO: \hskip and \mskip should support plus and minus in lengths + +defineFunction({ + type: "kern", + names: ["\\kern", "\\mkern", "\\hskip", "\\mskip"], + props: { + numArgs: 1, + argTypes: ["size"], + primitive: true, + allowedInText: true + }, + handler(_ref, args) { + let { + parser, + funcName + } = _ref; + const size = assertNodeType(args[0], "size"); + if (parser.settings.strict) { + const mathFunction = funcName[1] === 'm'; // \mkern, \mskip + const muUnit = size.value.unit === 'mu'; + if (mathFunction) { + if (!muUnit) { + parser.settings.reportNonstrict("mathVsTextUnits", "LaTeX's " + funcName + " supports only mu units, " + ("not " + size.value.unit + " units")); + } + if (parser.mode !== "math") { + parser.settings.reportNonstrict("mathVsTextUnits", "LaTeX's " + funcName + " works only in math mode"); + } + } else { + // !mathFunction + if (muUnit) { + parser.settings.reportNonstrict("mathVsTextUnits", "LaTeX's " + funcName + " doesn't support mu units"); + } + } + } + return { + type: "kern", + mode: parser.mode, + dimension: size.value + }; + }, + htmlBuilder(group, options) { + return makeGlue(group.dimension, options); + }, + mathmlBuilder(group, options) { + const dimension = calculateSize(group.dimension, options); + return new SpaceNode(dimension); + } +}); +;// ./src/functions/lap.ts +// Horizontal overlap functions + + + + + + +defineFunction({ + type: "lap", + names: ["\\mathllap", "\\mathrlap", "\\mathclap"], + props: { + numArgs: 1, + allowedInText: true + }, + handler: (_ref, args) => { + let { + parser, + funcName + } = _ref; + const body = args[0]; + return { + type: "lap", + mode: parser.mode, + alignment: funcName.slice(5), + body + }; + }, + htmlBuilder: (group, options) => { + // mathllap, mathrlap, mathclap + let inner; + if (group.alignment === "clap") { + // ref: https://www.math.lsu.edu/~aperlis/publications/mathclap/ + inner = makeSpan([], [buildGroup(group.body, options)]); + // wrap, since CSS will center a .clap > .inner > span + inner = makeSpan(["inner"], [inner], options); + } else { + inner = makeSpan(["inner"], [buildGroup(group.body, options)]); + } + const fix = makeSpan(["fix"], []); + let node = makeSpan([group.alignment], [inner, fix], options); + + // At this point, we have correctly set horizontal alignment of the + // two items involved in the lap. + // Next, use a strut to set the height of the HTML bounding box. + // Otherwise, a tall argument may be misplaced. + // This code resolved issue #1153 + const strut = makeSpan(["strut"]); + strut.style.height = makeEm(node.height + node.depth); + if (node.depth) { + strut.style.verticalAlign = makeEm(-node.depth); + } + node.children.unshift(strut); + + // Next, prevent vertical misplacement when next to something tall. + // This code resolves issue #1234 + node = makeSpan(["thinbox"], [node], options); + return makeSpan(["mord", "vbox"], [node], options); + }, + mathmlBuilder: (group, options) => { + // mathllap, mathrlap, mathclap + const node = new MathNode("mpadded", [buildMathML_buildGroup(group.body, options)]); + if (group.alignment !== "rlap") { + const offset = group.alignment === "llap" ? "-1" : "-0.5"; + node.setAttribute("lspace", offset + "width"); + } + node.setAttribute("width", "0px"); + return node; + } +}); +;// ./src/functions/math.ts + + + +// Switching from text mode back to math mode +defineFunction({ + type: "styling", + names: ["\\(", "$"], + props: { + numArgs: 0, + allowedInText: true, + allowedInMath: false + }, + handler(_ref, args) { + let { + funcName, + parser + } = _ref; + const outerMode = parser.mode; + parser.switchMode("math"); + const close = funcName === "\\(" ? "\\)" : "$"; + const body = parser.parseExpression(false, close); + parser.expect(close); + parser.switchMode(outerMode); + return { + type: "styling", + mode: parser.mode, + style: "text", + resetFont: true, + body + }; + } +}); + +// Check for extra closing math delimiters +defineFunction({ + type: "text", + // Doesn't matter what this is. + names: ["\\)", "\\]"], + props: { + numArgs: 0, + allowedInText: true, + allowedInMath: false + }, + handler(context, args) { + throw new src_ParseError("Mismatched " + context.funcName); + } +}); +;// ./src/functions/mathchoice.ts + + + + + +const chooseMathStyle = (group, options) => { + switch (options.style.size) { + case src_Style.DISPLAY.size: + return group.display; + case src_Style.TEXT.size: + return group.text; + case src_Style.SCRIPT.size: + return group.script; + case src_Style.SCRIPTSCRIPT.size: + return group.scriptscript; + default: + return group.text; + } +}; +defineFunction({ + type: "mathchoice", + names: ["\\mathchoice"], + props: { + numArgs: 4, + primitive: true + }, + handler: (_ref, args) => { + let { + parser + } = _ref; + return { + type: "mathchoice", + mode: parser.mode, + display: ordargument(args[0]), + text: ordargument(args[1]), + script: ordargument(args[2]), + scriptscript: ordargument(args[3]) + }; + }, + htmlBuilder: (group, options) => { + const body = chooseMathStyle(group, options); + const elements = buildExpression(body, options, false); + return makeFragment(elements); + }, + mathmlBuilder: (group, options) => { + const body = chooseMathStyle(group, options); + return buildExpressionRow(body, options); + } +}); +;// ./src/functions/utils/assembleSupSub.ts + + + + + +// For an operator with limits, assemble the base, sup, and sub into a span. + +const assembleSupSub = (base, supGroup, subGroup, options, style, slant, baseShift) => { + base = makeSpan([], [base]); + const subIsSingleCharacter = subGroup && isCharacterBox(subGroup); + let sub; + let sup; + // We manually have to handle the superscripts and subscripts. This, + // aside from the kern calculations, is copied from supsub. + if (supGroup) { + const elem = buildGroup(supGroup, options.havingStyle(style.sup()), options); + sup = { + elem, + kern: Math.max(options.fontMetrics().bigOpSpacing1, options.fontMetrics().bigOpSpacing3 - elem.depth) + }; + } + if (subGroup) { + const elem = buildGroup(subGroup, options.havingStyle(style.sub()), options); + sub = { + elem, + kern: Math.max(options.fontMetrics().bigOpSpacing2, options.fontMetrics().bigOpSpacing4 - elem.height) + }; + } + + // Build the final group as a vlist of the possible subscript, base, + // and possible superscript. + let finalGroup; + if (sup && sub) { + const bottom = options.fontMetrics().bigOpSpacing5 + sub.elem.height + sub.elem.depth + sub.kern + base.depth + baseShift; + finalGroup = makeVList({ + positionType: "bottom", + positionData: bottom, + children: [{ + type: "kern", + size: options.fontMetrics().bigOpSpacing5 + }, { + type: "elem", + elem: sub.elem, + marginLeft: makeEm(-slant) + }, { + type: "kern", + size: sub.kern + }, { + type: "elem", + elem: base + }, { + type: "kern", + size: sup.kern + }, { + type: "elem", + elem: sup.elem, + marginLeft: makeEm(slant) + }, { + type: "kern", + size: options.fontMetrics().bigOpSpacing5 + }] + }, options); + } else if (sub) { + const top = base.height - baseShift; + + // Shift the limits by the slant of the symbol. Note + // that we are supposed to shift the limits by 1/2 of the slant, + // but since we are centering the limits adding a full slant of + // margin will shift by 1/2 that. + finalGroup = makeVList({ + positionType: "top", + positionData: top, + children: [{ + type: "kern", + size: options.fontMetrics().bigOpSpacing5 + }, { + type: "elem", + elem: sub.elem, + marginLeft: makeEm(-slant) + }, { + type: "kern", + size: sub.kern + }, { + type: "elem", + elem: base + }] + }, options); + } else if (sup) { + const bottom = base.depth + baseShift; + finalGroup = makeVList({ + positionType: "bottom", + positionData: bottom, + children: [{ + type: "elem", + elem: base + }, { + type: "kern", + size: sup.kern + }, { + type: "elem", + elem: sup.elem, + marginLeft: makeEm(slant) + }, { + type: "kern", + size: options.fontMetrics().bigOpSpacing5 + }] + }, options); + } else { + // This case probably shouldn't occur (this would mean the + // supsub was sending us a group with no superscript or + // subscript) but be safe. + return base; + } + const parts = [finalGroup]; + if (sub && slant !== 0 && !subIsSingleCharacter) { + // A negative margin-left was applied to the lower limit. + // Avoid an overlap by placing a spacer on the left on the group. + const spacer = makeSpan(["mspace"], [], options); + spacer.style.marginRight = makeEm(slant); + parts.unshift(spacer); + } + return makeSpan(["mop", "op-limits"], parts, options); +}; +;// ./src/functions/op.ts +// Limits, symbols + + + + + + + + + + +// Most operators have a large successor symbol, but these don't. +const noSuccessor = new Set(["\\smallint"]); + +// NOTE: Unlike most `htmlBuilder`s, this one handles not only "op", but also +// "supsub" since some of them (like \int) can affect super/subscripting. +const op_htmlBuilder = (grp, options) => { + // Operators are handled in the TeXbook pg. 443-444, rule 13(a). + let supGroup; + let subGroup; + let hasLimits = false; + let group; + if (grp.type === "supsub") { + // If we have limits, supsub will pass us its group to handle. Pull + // out the superscript and subscript and set the group to the op in + // its base. + supGroup = grp.sup; + subGroup = grp.sub; + group = assertNodeType(grp.base, "op"); + hasLimits = true; + } else { + group = assertNodeType(grp, "op"); + } + const style = options.style; + let large = false; + if (style.size === src_Style.DISPLAY.size && group.symbol && !noSuccessor.has(group.name)) { + // Most symbol operators get larger in displaystyle (rule 13) + large = true; + } + let base; + // Italic correction from the symbol glyph, captured before the symbol + // may be wrapped in a vlist (for \oiint/\oiiint). Stays 0 for non-symbol ops. + let symbolItalic; + if (group.symbol) { + // If this is a symbol, create the symbol. + const fontName = large ? "Size2-Regular" : "Size1-Regular"; + let stash = ""; + if (group.name === "\\oiint" || group.name === "\\oiiint") { + // No font glyphs yet, so use a glyph w/o the oval. + // TODO: When font glyphs are available, delete this code. + stash = group.name.slice(1); + group.name = stash === "oiint" ? "\\iint" : "\\iiint"; + } + base = makeSymbol(group.name, fontName, "math", options, ["mop", "op-symbol", large ? "large-op" : "small-op"]); + symbolItalic = base.italic; + if (stash.length > 0) { + // We're in \oiint or \oiiint. Overlay the oval. + // TODO: When font glyphs are available, delete this code. + const oval = staticSvg(stash + "Size" + (large ? "2" : "1"), options); + base = makeVList({ + positionType: "individualShift", + children: [{ + type: "elem", + elem: base, + shift: 0 + }, { + type: "elem", + elem: oval, + shift: large ? 0.08 : 0 + }] + }, options); + group.name = "\\" + stash; + base.classes.unshift("mop"); + // Carry the italic correction from the original symbol to the + // vlist wrapper so supsub can use it for subscript positioning. + base.italic = symbolItalic; + } + } else if (group.body) { + // If this is a list, compose that list. + const inner = buildExpression(group.body, options, true); + if (inner.length === 1 && inner[0] instanceof SymbolNode) { + base = inner[0]; + base.classes[0] = "mop"; // replace old mclass + } else { + base = makeSpan(["mop"], inner, options); + } + } else { + // Otherwise, this is a text operator. Build the text from the + // operator's name. + const output = []; + for (let i = 1; i < group.name.length; i++) { + output.push(mathsym(group.name[i], group.mode, options)); + } + base = makeSpan(["mop"], output, options); + } + + // If content of op is a single symbol, shift it vertically. + let baseShift = 0; + let slant = 0; + if ((base instanceof SymbolNode || group.name === "\\oiint" || group.name === "\\oiiint") && !group.suppressBaseShift) { + var _base$italic; + // We suppress the shift of the base of \overset and \underset. Otherwise, + // shift the symbol so its center lies on the axis (rule 13). It + // appears that our fonts have the centers of the symbols already + // almost on the axis, so these numbers are very small. Note we + // don't actually apply this here, but instead it is used either in + // the vlist creation or separately when there are no limits. + baseShift = (base.height - base.depth) / 2 - options.fontMetrics().axisHeight; + + // The slant of the symbol is just its italic correction. + // SymbolNode carries .italic natively; Span (for \oiint/\oiiint) + // only has it set when nonzero, so default to 0. + slant = (_base$italic = base.italic) != null ? _base$italic : 0; + } + if (hasLimits) { + return assembleSupSub(base, supGroup, subGroup, options, style, slant, baseShift); + } else { + if (baseShift) { + base.style.position = "relative"; + base.style.top = makeEm(baseShift); + } + return base; + } +}; +const op_mathmlBuilder = (group, options) => { + let node; + if (group.symbol) { + // This is a symbol. Just add the symbol. + node = new MathNode("mo", [makeText(group.name, group.mode)]); + if (noSuccessor.has(group.name)) { + node.setAttribute("largeop", "false"); + } + } else if (group.body) { + // This is an operator with children. Add them. + node = new MathNode("mo", buildMathML_buildExpression(group.body, options)); + } else { + // This is a text operator. Add all the characters from the + // operator's name. + node = new MathNode("mi", [new TextNode(group.name.slice(1))]); + // Append an . + // ref: https://www.w3.org/TR/REC-MathML/chap3_2.html#sec3.2.4 + const operator = new MathNode("mo", [makeText("\u2061", "text")]); + if (group.parentIsSupSub) { + node = new MathNode("mrow", [node, operator]); + } else { + node = newDocumentFragment([node, operator]); + } + } + return node; +}; +const singleCharBigOps = { + "\u220F": "\\prod", + "\u2210": "\\coprod", + "\u2211": "\\sum", + "\u22c0": "\\bigwedge", + "\u22c1": "\\bigvee", + "\u22c2": "\\bigcap", + "\u22c3": "\\bigcup", + "\u2a00": "\\bigodot", + "\u2a01": "\\bigoplus", + "\u2a02": "\\bigotimes", + "\u2a04": "\\biguplus", + "\u2a06": "\\bigsqcup" +}; +defineFunction({ + type: "op", + names: ["\\coprod", "\\bigvee", "\\bigwedge", "\\biguplus", "\\bigcap", "\\bigcup", "\\intop", "\\prod", "\\sum", "\\bigotimes", "\\bigoplus", "\\bigodot", "\\bigsqcup", "\\smallint", "\u220F", "\u2210", "\u2211", "\u22c0", "\u22c1", "\u22c2", "\u22c3", "\u2a00", "\u2a01", "\u2a02", "\u2a04", "\u2a06"], + props: { + numArgs: 0 + }, + handler: (_ref, args) => { + let { + parser, + funcName + } = _ref; + let fName = funcName; + if (fName.length === 1) { + fName = singleCharBigOps[fName]; + } + return { + type: "op", + mode: parser.mode, + limits: true, + parentIsSupSub: false, + symbol: true, + name: fName + }; + }, + htmlBuilder: op_htmlBuilder, + mathmlBuilder: op_mathmlBuilder +}); + +// Note: calling defineFunction with a type that's already been defined only +// works because the same htmlBuilder and mathmlBuilder are being used. +defineFunction({ + type: "op", + names: ["\\mathop"], + props: { + numArgs: 1, + primitive: true + }, + handler: (_ref2, args) => { + let { + parser + } = _ref2; + const body = args[0]; + return { + type: "op", + mode: parser.mode, + limits: false, + parentIsSupSub: false, + symbol: false, + body: ordargument(body) + }; + }, + htmlBuilder: op_htmlBuilder, + mathmlBuilder: op_mathmlBuilder +}); + +// There are 2 flags for operators; whether they produce limits in +// displaystyle, and whether they are symbols and should grow in +// displaystyle. These four groups cover the four possible choices. +const singleCharIntegrals = { + "\u222b": "\\int", + "\u222c": "\\iint", + "\u222d": "\\iiint", + "\u222e": "\\oint", + "\u222f": "\\oiint", + "\u2230": "\\oiiint" +}; + +// No limits, not symbols +defineFunction({ + type: "op", + names: ["\\arcsin", "\\arccos", "\\arctan", "\\arctg", "\\arcctg", "\\arg", "\\ch", "\\cos", "\\cosec", "\\cosh", "\\cot", "\\cotg", "\\coth", "\\csc", "\\ctg", "\\cth", "\\deg", "\\dim", "\\exp", "\\hom", "\\ker", "\\lg", "\\ln", "\\log", "\\sec", "\\sin", "\\sinh", "\\sh", "\\tan", "\\tanh", "\\tg", "\\th"], + props: { + numArgs: 0 + }, + handler(_ref3) { + let { + parser, + funcName + } = _ref3; + return { + type: "op", + mode: parser.mode, + limits: false, + parentIsSupSub: false, + symbol: false, + name: funcName + }; + }, + htmlBuilder: op_htmlBuilder, + mathmlBuilder: op_mathmlBuilder +}); + +// Limits, not symbols +defineFunction({ + type: "op", + names: ["\\det", "\\gcd", "\\inf", "\\lim", "\\max", "\\min", "\\Pr", "\\sup"], + props: { + numArgs: 0 + }, + handler(_ref4) { + let { + parser, + funcName + } = _ref4; + return { + type: "op", + mode: parser.mode, + limits: true, + parentIsSupSub: false, + symbol: false, + name: funcName + }; + }, + htmlBuilder: op_htmlBuilder, + mathmlBuilder: op_mathmlBuilder +}); + +// No limits, symbols +defineFunction({ + type: "op", + names: ["\\int", "\\iint", "\\iiint", "\\oint", "\\oiint", "\\oiiint", "\u222b", "\u222c", "\u222d", "\u222e", "\u222f", "\u2230"], + props: { + numArgs: 0, + allowedInArgument: true + }, + handler(_ref5) { + let { + parser, + funcName + } = _ref5; + let fName = funcName; + if (fName.length === 1) { + fName = singleCharIntegrals[fName]; + } + return { + type: "op", + mode: parser.mode, + limits: false, + parentIsSupSub: false, + symbol: true, + name: fName + }; + }, + htmlBuilder: op_htmlBuilder, + mathmlBuilder: op_mathmlBuilder +}); +;// ./src/functions/operatorname.ts + + + + + + + + + +// NOTE: Unlike most `htmlBuilder`s, this one handles not only +// "operatorname", but also "supsub" since \operatorname* can +// affect super/subscripting. +const operatorname_htmlBuilder = (grp, options) => { + // Operators are handled in the TeXbook pg. 443-444, rule 13(a). + let supGroup; + let subGroup; + let hasLimits = false; + let group; + if (grp.type === "supsub") { + // If we have limits, supsub will pass us its group to handle. Pull + // out the superscript and subscript and set the group to the op in + // its base. + supGroup = grp.sup; + subGroup = grp.sub; + group = assertNodeType(grp.base, "operatorname"); + hasLimits = true; + } else { + group = assertNodeType(grp, "operatorname"); + } + let base; + if (group.body.length > 0) { + const body = group.body.map(child => { + const childText = "text" in child ? child.text : undefined; + if (typeof childText === "string") { + return { + type: "textord", + mode: child.mode, + text: childText + }; + } else { + return child; + } + }); + + // Consolidate function names into symbol characters. + const expression = buildExpression(body, options.withFont("mathrm"), true); + for (let i = 0; i < expression.length; i++) { + const child = expression[i]; + if (child instanceof SymbolNode) { + // Per amsopn package, + // change minus to hyphen and \ast to asterisk + child.text = child.text.replace(/\u2212/, "-").replace(/\u2217/, "*"); + } + } + base = makeSpan(["mop"], expression, options); + } else { + base = makeSpan(["mop"], [], options); + } + if (hasLimits) { + return assembleSupSub(base, supGroup, subGroup, options, options.style, 0, 0); + } else { + return base; + } +}; +const operatorname_mathmlBuilder = (group, options) => { + // The steps taken here are similar to the html version. + let expression = buildMathML_buildExpression(group.body, options.withFont("mathrm")); + + // Is expression a string or has it something like a fraction? + let isAllString = true; // default + for (let i = 0; i < expression.length; i++) { + const node = expression[i]; + if (node instanceof SpaceNode) { + // Do nothing + } else if (node instanceof MathNode) { + switch (node.type) { + case "mi": + case "mn": + case "mspace": + case "mtext": + break; + // Do nothing yet. + case "mo": + { + const child = node.children[0]; + if (node.children.length === 1 && child instanceof TextNode) { + child.text = child.text.replace(/\u2212/, "-").replace(/\u2217/, "*"); + } else { + isAllString = false; + } + break; + } + default: + isAllString = false; + } + } else { + isAllString = false; + } + } + if (isAllString) { + // Write a single TextNode instead of multiple nested tags. + const word = expression.map(node => node.toText()).join(""); + expression = [new TextNode(word)]; + } + const identifier = new MathNode("mi", expression); + identifier.setAttribute("mathvariant", "normal"); + + // \u2061 is the same as ⁡ + // ref: https://www.w3schools.com/charsets/ref_html_entities_a.asp + const operator = new MathNode("mo", [makeText("\u2061", "text")]); + if (group.parentIsSupSub) { + return new MathNode("mrow", [identifier, operator]); + } else { + return newDocumentFragment([identifier, operator]); + } +}; + +// \operatorname +// amsopn.dtx: \mathop{#1\kern\z@\operator@font#3}\newmcodes@ +defineFunction({ + type: "operatorname", + names: ["\\operatorname@", "\\operatornamewithlimits"], + props: { + numArgs: 1 + }, + handler: (_ref, args) => { + let { + parser, + funcName + } = _ref; + const body = args[0]; + return { + type: "operatorname", + mode: parser.mode, + body: ordargument(body), + alwaysHandleSupSub: funcName === "\\operatornamewithlimits", + limits: false, + parentIsSupSub: false + }; + }, + htmlBuilder: operatorname_htmlBuilder, + mathmlBuilder: operatorname_mathmlBuilder +}); +defineMacro("\\operatorname", "\\@ifstar\\operatornamewithlimits\\operatorname@"); +;// ./src/functions/ordgroup.ts + + + + +defineFunctionBuilders({ + type: "ordgroup", + htmlBuilder(group, options) { + if (group.semisimple) { + return makeFragment(buildExpression(group.body, options, false)); + } + return makeSpan(["mord"], buildExpression(group.body, options, true), options); + }, + mathmlBuilder(group, options) { + return buildExpressionRow(group.body, options, true); + } +}); +;// ./src/functions/overline.ts + + + + + +defineFunction({ + type: "overline", + names: ["\\overline"], + props: { + numArgs: 1 + }, + handler(_ref, args) { + let { + parser + } = _ref; + const body = args[0]; + return { + type: "overline", + mode: parser.mode, + body + }; + }, + htmlBuilder(group, options) { + // Overlines are handled in the TeXbook pg 443, Rule 9. + + // Build the inner group in the cramped style. + const innerGroup = buildGroup(group.body, options.havingCrampedStyle()); + + // Create the line above the body + const line = makeLineSpan("overline-line", options); + + // Generate the vlist, with the appropriate kerns + const defaultRuleThickness = options.fontMetrics().defaultRuleThickness; + const vlist = makeVList({ + positionType: "firstBaseline", + children: [{ + type: "elem", + elem: innerGroup + }, { + type: "kern", + size: 3 * defaultRuleThickness + }, { + type: "elem", + elem: line + }, { + type: "kern", + size: defaultRuleThickness + }] + }, options); + return makeSpan(["mord", "overline"], [vlist], options); + }, + mathmlBuilder(group, options) { + const operator = new MathNode("mo", [new TextNode("\u203e")]); + operator.setAttribute("stretchy", "true"); + const node = new MathNode("mover", [buildMathML_buildGroup(group.body, options), operator]); + node.setAttribute("accent", "true"); + return node; + } +}); +;// ./src/functions/phantom.ts + + + + + + +defineFunction({ + type: "phantom", + names: ["\\phantom"], + props: { + numArgs: 1, + allowedInText: true + }, + handler: (_ref, args) => { + let { + parser + } = _ref; + const body = args[0]; + return { + type: "phantom", + mode: parser.mode, + body: ordargument(body) + }; + }, + htmlBuilder: (group, options) => { + const elements = buildExpression(group.body, options.withPhantom(), false); + + // \phantom isn't supposed to affect the elements it contains. + // See "color" for more details. + return makeFragment(elements); + }, + mathmlBuilder: (group, options) => { + const inner = buildMathML_buildExpression(group.body, options); + return new MathNode("mphantom", inner); + } +}); +defineMacro("\\hphantom", "\\smash{\\phantom{#1}}"); +defineFunction({ + type: "vphantom", + names: ["\\vphantom"], + props: { + numArgs: 1, + allowedInText: true + }, + handler: (_ref2, args) => { + let { + parser + } = _ref2; + const body = args[0]; + return { + type: "vphantom", + mode: parser.mode, + body + }; + }, + htmlBuilder: (group, options) => { + const inner = makeSpan(["inner"], [buildGroup(group.body, options.withPhantom())]); + const fix = makeSpan(["fix"], []); + return makeSpan(["mord", "rlap"], [inner, fix], options); + }, + mathmlBuilder: (group, options) => { + const inner = buildMathML_buildExpression(ordargument(group.body), options); + const phantom = new MathNode("mphantom", inner); + const node = new MathNode("mpadded", [phantom]); + node.setAttribute("width", "0px"); + return node; + } +}); +;// ./src/functions/raisebox.ts + + + + + + + + +// Box manipulation +defineFunction({ + type: "raisebox", + names: ["\\raisebox"], + props: { + numArgs: 2, + argTypes: ["size", "hbox"], + allowedInText: true + }, + handler(_ref, args) { + let { + parser + } = _ref; + const amount = assertNodeType(args[0], "size").value; + const body = args[1]; + return { + type: "raisebox", + mode: parser.mode, + dy: amount, + body + }; + }, + htmlBuilder(group, options) { + const body = buildGroup(group.body, options); + const dy = calculateSize(group.dy, options); + return makeVList({ + positionType: "shift", + positionData: -dy, + children: [{ + type: "elem", + elem: body + }] + }, options); + }, + mathmlBuilder(group, options) { + const node = new MathNode("mpadded", [buildMathML_buildGroup(group.body, options)]); + const dy = group.dy.number + group.dy.unit; + node.setAttribute("voffset", dy); + return node; + } +}); +;// ./src/functions/relax.ts + +defineFunction({ + type: "internal", + names: ["\\relax"], + props: { + numArgs: 0, + allowedInText: true, + allowedInArgument: true + }, + handler(_ref) { + let { + parser + } = _ref; + return { + type: "internal", + mode: parser.mode + }; + } +}); +;// ./src/functions/rule.ts + + + + + +defineFunction({ + type: "rule", + names: ["\\rule"], + props: { + numArgs: 2, + numOptionalArgs: 1, + allowedInText: true, + allowedInMath: true, + argTypes: ["size", "size", "size"] + }, + handler(_ref, args, optArgs) { + let { + parser + } = _ref; + const shift = optArgs[0]; + const width = assertNodeType(args[0], "size"); + const height = assertNodeType(args[1], "size"); + return { + type: "rule", + mode: parser.mode, + shift: shift && assertNodeType(shift, "size").value, + width: width.value, + height: height.value + }; + }, + htmlBuilder(group, options) { + // Make an empty span for the rule + const rule = makeSpan(["mord", "rule"], [], options); + + // Calculate the shift, width, and height of the rule, and account for units + const width = calculateSize(group.width, options); + const height = calculateSize(group.height, options); + const shift = group.shift ? calculateSize(group.shift, options) : 0; + + // Style the rule to the right size + rule.style.borderRightWidth = makeEm(width); + rule.style.borderTopWidth = makeEm(height); + rule.style.bottom = makeEm(shift); + + // Record the height and width + rule.width = width; + rule.height = height + shift; + rule.depth = -shift; + // Font size is the number large enough that the browser will + // reserve at least `absHeight` space above the baseline. + // The 1.125 factor was empirically determined + rule.maxFontSize = height * 1.125 * options.sizeMultiplier; + return rule; + }, + mathmlBuilder(group, options) { + const width = calculateSize(group.width, options); + const height = calculateSize(group.height, options); + const shift = group.shift ? calculateSize(group.shift, options) : 0; + const color = options.color && options.getColor() || "black"; + const rule = new MathNode("mspace"); + rule.setAttribute("mathbackground", color); + rule.setAttribute("width", makeEm(width)); + rule.setAttribute("height", makeEm(height)); + const wrapper = new MathNode("mpadded", [rule]); + if (shift >= 0) { + wrapper.setAttribute("height", makeEm(shift)); + } else { + wrapper.setAttribute("height", makeEm(shift)); + wrapper.setAttribute("depth", makeEm(-shift)); + } + wrapper.setAttribute("voffset", makeEm(shift)); + return wrapper; + } +}); +;// ./src/functions/sizing.ts + + + + + + +function sizingGroup(value, options, baseOptions) { + const inner = buildExpression(value, options, false); + const multiplier = options.sizeMultiplier / baseOptions.sizeMultiplier; + + // Add size-resetting classes to the inner list and set maxFontSize + // manually. Handle nested size changes. + for (let i = 0; i < inner.length; i++) { + const pos = inner[i].classes.indexOf("sizing"); + if (pos < 0) { + Array.prototype.push.apply(inner[i].classes, options.sizingClasses(baseOptions)); + } else if (inner[i].classes[pos + 1] === "reset-size" + options.size) { + // This is a nested size change: e.g., inner[i] is the "b" in + // `\Huge a \small b`. Override the old size (the `reset-` class) + // but not the new size. + inner[i].classes[pos + 1] = "reset-size" + baseOptions.size; + } + inner[i].height *= multiplier; + inner[i].depth *= multiplier; + } + return makeFragment(inner); +} +const sizeFuncs = ["\\tiny", "\\sixptsize", "\\scriptsize", "\\footnotesize", "\\small", "\\normalsize", "\\large", "\\Large", "\\LARGE", "\\huge", "\\Huge"]; +const sizing_htmlBuilder = (group, options) => { + // Handle sizing operators like \Huge. Real TeX doesn't actually allow + // these functions inside of math expressions, so we do some special + // handling. + const newOptions = options.havingSize(group.size); + return sizingGroup(group.body, newOptions, options); +}; +defineFunction({ + type: "sizing", + names: sizeFuncs, + props: { + numArgs: 0, + allowedInText: true + }, + handler: (_ref, args) => { + let { + breakOnTokenText, + funcName, + parser + } = _ref; + const body = parser.parseExpression(false, breakOnTokenText); + return { + type: "sizing", + mode: parser.mode, + // Figure out what size to use based on the list of functions above + size: sizeFuncs.indexOf(funcName) + 1, + body + }; + }, + htmlBuilder: sizing_htmlBuilder, + mathmlBuilder: (group, options) => { + const newOptions = options.havingSize(group.size); + const inner = buildMathML_buildExpression(group.body, newOptions); + const node = new MathNode("mstyle", inner); + + // TODO(emily): This doesn't produce the correct size for nested size + // changes, because we don't keep state of what style we're currently + // in, so we can't reset the size to normal before changing it. Now + // that we're passing an options parameter we should be able to fix + // this. + node.setAttribute("mathsize", makeEm(newOptions.sizeMultiplier)); + return node; + } +}); +;// ./src/functions/smash.ts +// smash, with optional [tb], as in AMS + + + + + + +defineFunction({ + type: "smash", + names: ["\\smash"], + props: { + numArgs: 1, + numOptionalArgs: 1, + allowedInText: true + }, + handler: (_ref, args, optArgs) => { + let { + parser + } = _ref; + let smashHeight = false; + let smashDepth = false; + const tbArg = optArgs[0] && assertNodeType(optArgs[0], "ordgroup"); + if (tbArg) { + // Optional [tb] argument is engaged. + // ref: amsmath: \renewcommand{\smash}[1][tb]{% + // def\mb@t{\ht}\def\mb@b{\dp}\def\mb@tb{\ht\z@\z@\dp}% + let letter; + for (let i = 0; i < tbArg.body.length; ++i) { + const node = tbArg.body[i]; + letter = assertSymbolNodeType(node).text; + if (letter === "t") { + smashHeight = true; + } else if (letter === "b") { + smashDepth = true; + } else { + smashHeight = false; + smashDepth = false; + break; + } + } + } else { + smashHeight = true; + smashDepth = true; + } + const body = args[0]; + return { + type: "smash", + mode: parser.mode, + body, + smashHeight, + smashDepth + }; + }, + htmlBuilder: (group, options) => { + const node = makeSpan([], [buildGroup(group.body, options)]); + if (!group.smashHeight && !group.smashDepth) { + return node; + } + if (group.smashHeight) { + node.height = 0; + } + if (group.smashDepth) { + node.depth = 0; + } + if (group.smashHeight && group.smashDepth) { + // Symmetric \smash can stay in inline layout. + return makeSpan(["mord", "smash"], [node], options); + } + + // In order to influence makeVList for asymmetric smashing, we have to + // reset the children. + if (node.children) { + for (let i = 0; i < node.children.length; i++) { + if (group.smashHeight) { + node.children[i].height = 0; + } + if (group.smashDepth) { + node.children[i].depth = 0; + } + } + } + + // At this point, we've reset the TeX-like height and depth values. + // But the span still has an HTML line height. + // makeVList applies "display: table-cell", which prevents the browser + // from acting on that line height. So we'll call makeVList now. + + const smashedNode = makeVList({ + positionType: "firstBaseline", + children: [{ + type: "elem", + elem: node + }] + }, options); + + // For spacing, TeX treats \smash as a math group (same spacing as ord). + return makeSpan(["mord"], [smashedNode], options); + }, + mathmlBuilder: (group, options) => { + const node = new MathNode("mpadded", [buildMathML_buildGroup(group.body, options)]); + if (group.smashHeight) { + node.setAttribute("height", "0px"); + } + if (group.smashDepth) { + node.setAttribute("depth", "0px"); + } + return node; + } +}); +;// ./src/functions/sqrt.ts + + + + + + + + +defineFunction({ + type: "sqrt", + names: ["\\sqrt"], + props: { + numArgs: 1, + numOptionalArgs: 1 + }, + handler(_ref, args, optArgs) { + let { + parser + } = _ref; + const index = optArgs[0]; + const body = args[0]; + return { + type: "sqrt", + mode: parser.mode, + body, + index + }; + }, + htmlBuilder(group, options) { + // Square roots are handled in the TeXbook pg. 443, Rule 11. + + // First, we do the same steps as in overline to build the inner group + // and line + let inner = buildGroup(group.body, options.havingCrampedStyle()); + if (inner.height === 0) { + // Render a small surd. + inner.height = options.fontMetrics().xHeight; + } + + // Some groups can return document fragments. Handle those by wrapping + // them in a span. + inner = wrapFragment(inner, options); + + // Calculate the minimum size for the \surd delimiter + const metrics = options.fontMetrics(); + const theta = metrics.defaultRuleThickness; + let phi = theta; + if (options.style.id < src_Style.TEXT.id) { + phi = options.fontMetrics().xHeight; + } + + // Calculate the clearance between the body and line + let lineClearance = theta + phi / 4; + const minDelimiterHeight = inner.height + inner.depth + lineClearance + theta; + + // Create a sqrt SVG of the required minimum size + const { + span: img, + ruleWidth, + advanceWidth + } = makeSqrtImage(minDelimiterHeight, options); + const delimDepth = img.height - ruleWidth; + + // Adjust the clearance based on the delimiter size + if (delimDepth > inner.height + inner.depth + lineClearance) { + lineClearance = (lineClearance + delimDepth - inner.height - inner.depth) / 2; + } + + // Shift the sqrt image + const imgShift = img.height - inner.height - lineClearance - ruleWidth; + inner.style.paddingLeft = makeEm(advanceWidth); + + // Overlay the image and the argument. + const body = makeVList({ + positionType: "firstBaseline", + children: [{ + type: "elem", + elem: inner, + wrapperClasses: ["svg-align"] + }, { + type: "kern", + size: -(inner.height + imgShift) + }, { + type: "elem", + elem: img + }, { + type: "kern", + size: ruleWidth + }] + }, options); + if (!group.index) { + return makeSpan(["mord", "sqrt"], [body], options); + } else { + // Handle the optional root index + + // The index is always in scriptscript style + const newOptions = options.havingStyle(src_Style.SCRIPTSCRIPT); + const rootm = buildGroup(group.index, newOptions, options); + + // The amount the index is shifted by. This is taken from the TeX + // source, in the definition of `\r@@t`. + const toShift = 0.6 * (body.height - body.depth); + + // Build a VList with the superscript shifted up correctly + const rootVList = makeVList({ + positionType: "shift", + positionData: -toShift, + children: [{ + type: "elem", + elem: rootm + }] + }, options); + // Add a class surrounding it so we can add on the appropriate + // kerning + const rootVListWrap = makeSpan(["root"], [rootVList]); + return makeSpan(["mord", "sqrt"], [rootVListWrap, body], options); + } + }, + mathmlBuilder(group, options) { + const { + body, + index + } = group; + return index ? new MathNode("mroot", [buildMathML_buildGroup(body, options), buildMathML_buildGroup(index, options)]) : new MathNode("msqrt", [buildMathML_buildGroup(body, options)]); + } +}); +;// ./src/functions/styling.ts + + + + + +const styling_styleMap = { + "display": src_Style.DISPLAY, + "text": src_Style.TEXT, + "script": src_Style.SCRIPT, + "scriptscript": src_Style.SCRIPTSCRIPT +}; +function isStyleStr(s) { + return s in styling_styleMap; +} +defineFunction({ + type: "styling", + names: ["\\displaystyle", "\\textstyle", "\\scriptstyle", "\\scriptscriptstyle"], + props: { + numArgs: 0, + allowedInText: true, + primitive: true + }, + handler(_ref, args) { + let { + breakOnTokenText, + funcName, + parser + } = _ref; + // parse out the implicit body + const body = parser.parseExpression(true, breakOnTokenText); + + // TODO: Refactor to avoid duplicating styleMap in multiple places (e.g. + // here and in buildHTML and de-dupe the enumeration of all the styles). + const style = funcName.slice(1, funcName.length - 5); + if (!isStyleStr(style)) { + throw new Error("Unknown style: " + style); + } + return { + type: "styling", + mode: parser.mode, + // Figure out what style to use by pulling out the style from + // the function name + style, + body + }; + }, + htmlBuilder(group, options) { + // Style changes are handled in the TeXbook on pg. 442, Rule 3. + const newStyle = styling_styleMap[group.style]; + let newOptions = options.havingStyle(newStyle); + if (group.resetFont) { + newOptions = newOptions.withFont(''); + } + return sizingGroup(group.body, newOptions, options); + }, + mathmlBuilder(group, options) { + // Figure out what style we're changing to. + const newStyle = styling_styleMap[group.style]; + let newOptions = options.havingStyle(newStyle); + if (group.resetFont) { + newOptions = newOptions.withFont(''); + } + const inner = buildMathML_buildExpression(group.body, newOptions); + const node = new MathNode("mstyle", inner); + const styleAttributes = { + "display": ["0", "true"], + "text": ["0", "false"], + "script": ["1", "false"], + "scriptscript": ["2", "false"] + }; + const attr = styleAttributes[group.style]; + node.setAttribute("scriptlevel", attr[0]); + node.setAttribute("displaystyle", attr[1]); + return node; + } +}); +;// ./src/functions/supsub.ts + + + + + + + + + + + + + +/** + * Sometimes, groups perform special rules when they have superscripts or + * subscripts attached to them. This function lets the `supsub` group know that + * Sometimes, groups perform special rules when they have superscripts or + * its inner element should handle the superscripts and subscripts instead of + * handling them itself. + */ +const htmlBuilderDelegate = function (group, options +// eslint-disable-next-line @typescript-eslint/no-explicit-any +) { + const base = group.base; + if (!base) { + return null; + } else if (base.type === "op") { + // Operators handle supsubs differently when they have limits + // (e.g. `\displaystyle\sum_2^3`) + const delegate = base.limits && (options.style.size === src_Style.DISPLAY.size || base.alwaysHandleSupSub); + return delegate ? op_htmlBuilder : null; + } else if (base.type === "operatorname") { + const delegate = base.alwaysHandleSupSub && (options.style.size === src_Style.DISPLAY.size || base.limits); + return delegate ? operatorname_htmlBuilder : null; + } else if (base.type === "accent") { + return isCharacterBox(base.base) ? htmlBuilder : null; + } else if (base.type === "horizBrace") { + const isSup = !group.sub; + return isSup === base.isOver ? horizBrace_htmlBuilder : null; + } else { + return null; + } +}; + +// Super scripts and subscripts, whose precise placement can depend on other +// functions that precede them. +defineFunctionBuilders({ + type: "supsub", + htmlBuilder(group, options) { + // Superscript and subscripts are handled in the TeXbook on page + // 445-446, rules 18(a-f). + + // Here is where we defer to the inner group if it should handle + // superscripts and subscripts itself. + const builderDelegate = htmlBuilderDelegate(group, options); + if (builderDelegate) { + return builderDelegate(group, options); + } + const { + base: valueBase, + sup: valueSup, + sub: valueSub + } = group; + const base = buildGroup(valueBase, options); + let supm; + let subm; + const metrics = options.fontMetrics(); + + // Rule 18a + let supShift = 0; + let subShift = 0; + const isCharBox = valueBase && isCharacterBox(valueBase); + if (valueSup) { + const newOptions = options.havingStyle(options.style.sup()); + supm = buildGroup(valueSup, newOptions, options); + if (!isCharBox) { + supShift = base.height - newOptions.fontMetrics().supDrop * newOptions.sizeMultiplier / options.sizeMultiplier; + } + } + if (valueSub) { + const newOptions = options.havingStyle(options.style.sub()); + subm = buildGroup(valueSub, newOptions, options); + if (!isCharBox) { + subShift = base.depth + newOptions.fontMetrics().subDrop * newOptions.sizeMultiplier / options.sizeMultiplier; + } + } + + // Rule 18c + let minSupShift; + if (options.style === src_Style.DISPLAY) { + minSupShift = metrics.sup1; + } else if (options.style.cramped) { + minSupShift = metrics.sup3; + } else { + minSupShift = metrics.sup2; + } + + // scriptspace is a font-size-independent size, so scale it + // appropriately for use as the marginRight. + const multiplier = options.sizeMultiplier; + const marginRight = makeEm(0.5 / metrics.ptPerEm / multiplier); + let marginLeft = null; + if (subm) { + // Subscripts shouldn't be shifted by the base's italic correction. + // Account for that by shifting the subscript back the appropriate + // amount. Note we only do this when the base is a single symbol. + const isOiint = group.base && group.base.type === "op" && group.base.name && (group.base.name === "\\oiint" || group.base.name === "\\oiiint"); + if (base instanceof SymbolNode || isOiint) { + var _italic; + // SymbolNode has .italic natively; for \oiint/\oiiint the + // op builder stores .italic on the wrapping Span. + marginLeft = makeEm(-((_italic = base.italic) != null ? _italic : 0)); + } + } + let supsub; + if (supm && subm) { + supShift = Math.max(supShift, minSupShift, supm.depth + 0.25 * metrics.xHeight); + subShift = Math.max(subShift, metrics.sub2); + const ruleWidth = metrics.defaultRuleThickness; + + // Rule 18e + const maxWidth = 4 * ruleWidth; + if (supShift - supm.depth - (subm.height - subShift) < maxWidth) { + subShift = maxWidth - (supShift - supm.depth) + subm.height; + const psi = 0.8 * metrics.xHeight - (supShift - supm.depth); + if (psi > 0) { + supShift += psi; + subShift -= psi; + } + } + const vlistElem = [{ + type: "elem", + elem: subm, + shift: subShift, + marginRight, + marginLeft + }, { + type: "elem", + elem: supm, + shift: -supShift, + marginRight + }]; + supsub = makeVList({ + positionType: "individualShift", + children: vlistElem + }, options); + } else if (subm) { + // Rule 18b + subShift = Math.max(subShift, metrics.sub1, subm.height - 0.8 * metrics.xHeight); + const vlistElem = [{ + type: "elem", + elem: subm, + marginLeft, + marginRight + }]; + supsub = makeVList({ + positionType: "shift", + positionData: subShift, + children: vlistElem + }, options); + } else if (supm) { + // Rule 18c, d + supShift = Math.max(supShift, minSupShift, supm.depth + 0.25 * metrics.xHeight); + supsub = makeVList({ + positionType: "shift", + positionData: -supShift, + children: [{ + type: "elem", + elem: supm, + marginRight + }] + }, options); + } else { + throw new Error("supsub must have either sup or sub."); + } + + // Wrap the supsub vlist in a span.msupsub to reset text-align. + const mclass = getTypeOfDomTree(base, "right") || "mord"; + return makeSpan([mclass], [base, makeSpan(["msupsub"], [supsub])], options); + }, + mathmlBuilder(group, options) { + // Is the inner group a relevant horizontal brace? + let isBrace = false; + let isOver; + let isSup; + if (group.base && group.base.type === "horizBrace") { + isSup = !!group.sup; + if (isSup === group.base.isOver) { + isBrace = true; + isOver = group.base.isOver; + } + } + if (group.base && (group.base.type === "op" || group.base.type === "operatorname")) { + group.base.parentIsSupSub = true; + } + const children = [buildMathML_buildGroup(group.base, options)]; + if (group.sub) { + children.push(buildMathML_buildGroup(group.sub, options)); + } + if (group.sup) { + children.push(buildMathML_buildGroup(group.sup, options)); + } + let nodeType; + if (isBrace) { + nodeType = isOver ? "mover" : "munder"; + } else if (!group.sub) { + const base = group.base; + if (base && base.type === "op" && base.limits && (options.style === src_Style.DISPLAY || base.alwaysHandleSupSub)) { + nodeType = "mover"; + } else if (base && base.type === "operatorname" && base.alwaysHandleSupSub && (base.limits || options.style === src_Style.DISPLAY)) { + nodeType = "mover"; + } else { + nodeType = "msup"; + } + } else if (!group.sup) { + const base = group.base; + if (base && base.type === "op" && base.limits && (options.style === src_Style.DISPLAY || base.alwaysHandleSupSub)) { + nodeType = "munder"; + } else if (base && base.type === "operatorname" && base.alwaysHandleSupSub && (base.limits || options.style === src_Style.DISPLAY)) { + nodeType = "munder"; + } else { + nodeType = "msub"; + } + } else { + const base = group.base; + if (base && base.type === "op" && base.limits && options.style === src_Style.DISPLAY) { + nodeType = "munderover"; + } else if (base && base.type === "operatorname" && base.alwaysHandleSupSub && (options.style === src_Style.DISPLAY || base.limits)) { + nodeType = "munderover"; + } else { + nodeType = "msubsup"; + } + } + return new MathNode(nodeType, children); + } +}); +;// ./src/functions/symbolsOp.ts + + + + + +// Operator ParseNodes created in Parser.js from symbol Groups in src/symbols.js. + +defineFunctionBuilders({ + type: "atom", + htmlBuilder(group, options) { + return mathsym(group.text, group.mode, options, ["m" + group.family]); + }, + mathmlBuilder(group, options) { + const node = new MathNode("mo", [makeText(group.text, group.mode)]); + if (group.family === "bin") { + const variant = getVariant(group, options); + if (variant === "bold-italic") { + node.setAttribute("mathvariant", variant); + } + } else if (group.family === "punct") { + node.setAttribute("separator", "true"); + } else if (group.family === "open" || group.family === "close") { + // Delims built here should not stretch vertically. + // See delimsizing.js for stretchy delims. + node.setAttribute("stretchy", "false"); + } + return node; + } +}); +;// ./src/functions/symbolsOrd.ts + + + + +// "mathord" and "textord" ParseNodes created in Parser.js from symbol Groups in +// src/symbols.js. + +const defaultVariant = { + "mi": "italic", + "mn": "normal", + "mtext": "normal" +}; +defineFunctionBuilders({ + type: "mathord", + htmlBuilder(group, options) { + return makeOrd(group, options, "mathord"); + }, + mathmlBuilder(group, options) { + const node = new MathNode("mi", [makeText(group.text, group.mode, options)]); + const variant = getVariant(group, options) || "italic"; + if (variant !== defaultVariant[node.type]) { + node.setAttribute("mathvariant", variant); + } + return node; + } +}); +defineFunctionBuilders({ + type: "textord", + htmlBuilder(group, options) { + return makeOrd(group, options, "textord"); + }, + mathmlBuilder(group, options) { + const text = makeText(group.text, group.mode, options); + const variant = getVariant(group, options) || "normal"; + let node; + if (group.mode === 'text') { + node = new MathNode("mtext", [text]); + } else if (/[0-9]/.test(group.text)) { + node = new MathNode("mn", [text]); + } else if (group.text === "\\prime") { + node = new MathNode("mo", [text]); + } else { + node = new MathNode("mi", [text]); + } + if (variant !== defaultVariant[node.type]) { + node.setAttribute("mathvariant", variant); + } + return node; + } +}); +;// ./src/functions/symbolsSpacing.ts + + + + + +// A map of CSS-based spacing functions to their CSS class. +const cssSpace = { + "\\nobreak": "nobreak", + "\\allowbreak": "allowbreak" +}; + +// A lookup table to determine whether a spacing function/symbol should be +// treated like a regular space character. If a symbol or command is a key +// in this table, then it should be a regular space character. Furthermore, +// the associated value may have a `className` specifying an extra CSS class +// to add to the created `span`. +const regularSpace = { + " ": {}, + "\\ ": {}, + "~": { + className: "nobreak" + }, + "\\space": {}, + "\\nobreakspace": { + className: "nobreak" + } +}; + +// ParseNode<"spacing"> created in Parser.js from the "spacing" symbol Groups in +// src/symbols.js. +defineFunctionBuilders({ + type: "spacing", + htmlBuilder(group, options) { + if (regularSpace.hasOwnProperty(group.text)) { + const className = regularSpace[group.text].className || ""; + // Spaces are generated by adding an actual space. Each of these + // things has an entry in the symbols table, so these will be turned + // into appropriate outputs. + if (group.mode === "text") { + const ord = makeOrd(group, options, "textord"); + ord.classes.push(className); + return ord; + } else { + return makeSpan(["mspace", className], [mathsym(group.text, group.mode, options)], options); + } + } else if (cssSpace.hasOwnProperty(group.text)) { + // Spaces based on just a CSS class. + return makeSpan(["mspace", cssSpace[group.text]], [], options); + } else { + throw new src_ParseError("Unknown type of space \"" + group.text + "\""); + } + }, + mathmlBuilder(group, options) { + let node; + if (regularSpace.hasOwnProperty(group.text)) { + node = new MathNode("mtext", [new TextNode("\u00a0")]); + } else if (cssSpace.hasOwnProperty(group.text)) { + // CSS-based MathML spaces (\nobreak, \allowbreak) are ignored + return new MathNode("mspace"); + } else { + throw new src_ParseError("Unknown type of space \"" + group.text + "\""); + } + return node; + } +}); +;// ./src/functions/tag.ts + + + +const pad = () => { + const padNode = new MathNode("mtd", []); + padNode.setAttribute("width", "50%"); + return padNode; +}; +defineFunctionBuilders({ + type: "tag", + mathmlBuilder(group, options) { + const table = new MathNode("mtable", [new MathNode("mtr", [pad(), new MathNode("mtd", [buildExpressionRow(group.body, options)]), pad(), new MathNode("mtd", [buildExpressionRow(group.tag, options)])])]); + table.setAttribute("width", "100%"); + return table; + + // TODO: Left-aligned tags. + // Currently, the group and options passed here do not contain + // enough info to set tag alignment. `leqno` is in Settings but it is + // not passed to Options. On the HTML side, leqno is + // set by a CSS class applied in buildTree.js. That would have worked + // in MathML if browsers supported . Since they don't, we + // need to rewrite the way this function is called. + } +}); +;// ./src/functions/text.ts + + + + +// Non-mathy text, possibly in a font +const textFontFamilies = { + "\\text": undefined, + "\\textrm": "textrm", + "\\textsf": "textsf", + "\\texttt": "texttt", + "\\textnormal": "textrm" +}; +const textFontWeights = { + "\\textbf": "textbf", + "\\textmd": "textmd" +}; +const textFontShapes = { + "\\textit": "textit", + "\\textup": "textup" +}; +const optionsWithFont = (group, options) => { + const font = group.font; + // Checks if the argument is a font family or a font style. + if (!font) { + return options; + } else if (textFontFamilies[font]) { + return options.withTextFontFamily(textFontFamilies[font]); + } else if (textFontWeights[font]) { + return options.withTextFontWeight(textFontWeights[font]); + } else if (font === "\\emph") { + return options.fontShape === "textit" ? options.withTextFontShape("textup") : options.withTextFontShape("textit"); + } + return options.withTextFontShape(textFontShapes[font]); +}; +defineFunction({ + type: "text", + names: [ + // Font families + "\\text", "\\textrm", "\\textsf", "\\texttt", "\\textnormal", + // Font weights + "\\textbf", "\\textmd", + // Font Shapes + "\\textit", "\\textup", "\\emph"], + props: { + numArgs: 1, + argTypes: ["text"], + allowedInArgument: true, + allowedInText: true + }, + handler(_ref, args) { + let { + parser, + funcName + } = _ref; + const body = args[0]; + return { + type: "text", + mode: parser.mode, + body: ordargument(body), + font: funcName + }; + }, + htmlBuilder(group, options) { + const newOptions = optionsWithFont(group, options); + const inner = buildExpression(group.body, newOptions, true); + return makeSpan(["mord", "text"], inner, newOptions); + }, + mathmlBuilder(group, options) { + const newOptions = optionsWithFont(group, options); + return buildExpressionRow(group.body, newOptions); + } +}); +;// ./src/functions/underline.ts + + + + + +defineFunction({ + type: "underline", + names: ["\\underline"], + props: { + numArgs: 1, + allowedInText: true + }, + handler(_ref, args) { + let { + parser + } = _ref; + return { + type: "underline", + mode: parser.mode, + body: args[0] + }; + }, + htmlBuilder(group, options) { + // Underlines are handled in the TeXbook pg 443, Rule 10. + // Build the inner group. + const innerGroup = buildGroup(group.body, options); + + // Create the line to go below the body + const line = makeLineSpan("underline-line", options); + + // Generate the vlist, with the appropriate kerns + const defaultRuleThickness = options.fontMetrics().defaultRuleThickness; + const vlist = makeVList({ + positionType: "top", + positionData: innerGroup.height, + children: [{ + type: "kern", + size: defaultRuleThickness + }, { + type: "elem", + elem: line + }, { + type: "kern", + size: 3 * defaultRuleThickness + }, { + type: "elem", + elem: innerGroup + }] + }, options); + return makeSpan(["mord", "underline"], [vlist], options); + }, + mathmlBuilder(group, options) { + const operator = new MathNode("mo", [new TextNode("\u203e")]); + operator.setAttribute("stretchy", "true"); + const node = new MathNode("munder", [buildMathML_buildGroup(group.body, options), operator]); + node.setAttribute("accentunder", "true"); + return node; + } +}); +;// ./src/functions/vcenter.ts + + + + + + +// \vcenter: Vertically center the argument group on the math axis. + +defineFunction({ + type: "vcenter", + names: ["\\vcenter"], + props: { + numArgs: 1, + argTypes: ["original"], + // In LaTeX, \vcenter can act only on a box. + allowedInText: false + }, + handler(_ref, args) { + let { + parser + } = _ref; + return { + type: "vcenter", + mode: parser.mode, + body: args[0] + }; + }, + htmlBuilder(group, options) { + const body = buildGroup(group.body, options); + const axisHeight = options.fontMetrics().axisHeight; + const dy = 0.5 * (body.height - axisHeight - (body.depth + axisHeight)); + return makeVList({ + positionType: "shift", + positionData: dy, + children: [{ + type: "elem", + elem: body + }] + }, options); + }, + mathmlBuilder(group, options) { + // There is no way to do this in MathML. + // Write a class as a breadcrumb in case some post-processor wants + // to perform a vcenter adjustment. + // Wrap in mrow to ensure valid MathML when placed inside mo (e.g., \mathrel) + const mpadded = new MathNode("mpadded", [buildMathML_buildGroup(group.body, options)], ["vcenter"]); + return new MathNode("mrow", [mpadded]); + } +}); +;// ./src/functions/verb.ts + + + + +defineFunction({ + type: "verb", + names: ["\\verb"], + props: { + numArgs: 0, + allowedInText: true + }, + handler(context, args, optArgs) { + // \verb and \verb* are dealt with directly in Parser.js. + // If we end up here, it's because of a failure to match the two delimiters + // in the regex in Lexer.js. LaTeX raises the following error when \verb is + // terminated by end of line (or file). + throw new src_ParseError("\\verb ended by end of line instead of matching delimiter"); + }, + htmlBuilder(group, options) { + const text = makeVerb(group); + const body = []; + // \verb enters text mode and therefore is sized like \textstyle + const newOptions = options.havingStyle(options.style.text()); + for (let i = 0; i < text.length; i++) { + let c = text[i]; + if (c === '~') { + c = '\\textasciitilde'; + } + body.push(makeSymbol(c, "Typewriter-Regular", group.mode, newOptions, ["mord", "texttt"])); + } + return makeSpan(["mord", "text"].concat(newOptions.sizingClasses(options)), tryCombineChars(body), newOptions); + }, + mathmlBuilder(group, options) { + const text = new TextNode(makeVerb(group)); + const node = new MathNode("mtext", [text]); + node.setAttribute("mathvariant", "monospace"); + return node; + } +}); + +/** + * Converts verb group into body string. + * + * \verb* replaces each space with an open box \u2423 + * \verb replaces each space with a no-break space \xA0 + */ +const makeVerb = group => group.body.replace(/ /g, group.star ? '\u2423' : '\xA0'); +;// ./src/functions.ts +/** Include this to ensure that all functions are defined. */ + +const functions = _functions; +/* harmony default export */ var src_functions = (functions); + +// TODO(kevinb): have functions return an object and call defineFunction with +// that object in this file instead of relying on side-effects. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +;// ./src/Lexer.ts +/** + * The Lexer class handles tokenizing the input in various ways. Since our + * parser expects us to be able to backtrack, the lexer allows lexing from any + * given starting point. + * + * Its main exposed function is the `lex` function, which takes a position to + * lex from and a type of token to lex. It defers to the appropriate `_innerLex` + * function. + * + * The various `_innerLex` functions perform the actual lexing of different + * kinds. + */ + + + + +/* The following tokenRegex + * - matches typical whitespace (but not NBSP etc.) using its first group + * - does not match any control character \x00-\x1f except whitespace + * - does not match a bare backslash + * - matches any ASCII character except those just mentioned + * - does not match the BMP private use area \uE000-\uF8FF + * - does not match bare surrogate code units + * - matches any BMP character except for those just described + * - matches any valid Unicode surrogate pair + * - matches a backslash followed by one or more whitespace characters + * - matches a backslash followed by one or more letters then whitespace + * - matches a backslash followed by any BMP character + * Capturing groups: + * [1] regular whitespace + * [2] backslash followed by whitespace + * [3] anything else, which may include: + * [4] left character of \verb* + * [5] left character of \verb + * [6] backslash followed by word, excluding any trailing whitespace + * Just because the Lexer matches something doesn't mean it's valid input: + * If there is no matching function or symbol definition, the Parser will + * still reject the input. + */ +const spaceRegexString = "[ \r\n\t]"; +const controlWordRegexString = "\\\\[a-zA-Z@]+"; +const controlSymbolRegexString = "\\\\[^\uD800-\uDFFF]"; +const controlWordWhitespaceRegexString = "(" + controlWordRegexString + ")" + spaceRegexString + "*"; +const controlSpaceRegexString = "\\\\(\n|[ \r\t]+\n?)[ \r\t]*"; +const combiningDiacriticalMarkString = "[\u0300-\u036f]"; +const combiningDiacriticalMarksEndRegex = new RegExp(combiningDiacriticalMarkString + "+$"); +const tokenRegexString = "(" + spaceRegexString + "+)|" + (// whitespace +controlSpaceRegexString + "|") + +// \whitespace +"([!-\\[\\]-\u2027\u202A-\uD7FF\uF900-\uFFFF]" + (// single codepoint +combiningDiacriticalMarkString + "*") + +// ...plus accents +"|[\uD800-\uDBFF][\uDC00-\uDFFF]" + (// surrogate pair +combiningDiacriticalMarkString + "*") + +// ...plus accents +"|\\\\verb\\*([^]).*?\\4" + +// \verb* +"|\\\\verb([^*a-zA-Z]).*?\\5" + (// \verb unstarred +"|" + controlWordWhitespaceRegexString) + (// \macroName + spaces +"|" + controlSymbolRegexString + ")"); // \\, \', etc. + +/** Main Lexer class */ +class Lexer { + constructor(input, settings) { + this.input = void 0; + this.settings = void 0; + this.tokenRegex = void 0; + // Category codes. The lexer only supports comment characters (14) for now. + // MacroExpander additionally distinguishes active (13). + this.catcodes = void 0; + // Separate accents from characters + this.input = input; + this.settings = settings; + this.tokenRegex = new RegExp(tokenRegexString, 'g'); + this.catcodes = { + "%": 14, + // comment character + "~": 13 // active character + }; + } + setCatcode(char, code) { + this.catcodes[char] = code; + } + + /** + * This function lexes a single token. + */ + lex() { + const input = this.input; + const pos = this.tokenRegex.lastIndex; + if (pos === input.length) { + return new Token("EOF", new SourceLocation(this, pos, pos)); + } + const match = this.tokenRegex.exec(input); + if (match === null || match.index !== pos) { + throw new src_ParseError("Unexpected character: '" + input[pos] + "'", new Token(input[pos], new SourceLocation(this, pos, pos + 1))); + } + const text = match[6] || match[3] || (match[2] ? "\\ " : " "); + if (this.catcodes[text] === 14) { + // comment character + const nlIndex = input.indexOf('\n', this.tokenRegex.lastIndex); + if (nlIndex === -1) { + this.tokenRegex.lastIndex = input.length; // EOF + this.settings.reportNonstrict("commentAtEnd", "% comment has no terminating newline; LaTeX would " + "fail because of commenting the end of math mode (e.g. $)"); + } else { + this.tokenRegex.lastIndex = nlIndex + 1; + } + return this.lex(); + } + return new Token(text, new SourceLocation(this, pos, this.tokenRegex.lastIndex)); + } +} +;// ./src/Namespace.ts +/** + * A `Namespace` refers to a space of nameable things like macros or lengths, + * which can be `set` either globally or local to a nested group, using an + * undo stack similar to how TeX implements this functionality. + * Performance-wise, `get` and local `set` take constant time, while global + * `set` takes time proportional to the depth of group nesting. + */ + + +class Namespace { + /** + * Both arguments are optional. The first argument is an object of + * built-in mappings which never change. The second argument is an object + * of initial (global-level) mappings, which will constantly change + * according to any global/top-level `set`s done. + */ + constructor(builtins, globalMacros) { + if (builtins === void 0) { + builtins = {}; + } + if (globalMacros === void 0) { + globalMacros = {}; + } + this.current = void 0; + this.builtins = void 0; + this.undefStack = void 0; + this.current = globalMacros; + this.builtins = builtins; + this.undefStack = []; + } + + /** + * Start a new nested group, affecting future local `set`s. + */ + beginGroup() { + this.undefStack.push({}); + } + + /** + * End current nested group, restoring values before the group began. + */ + endGroup() { + if (this.undefStack.length === 0) { + throw new src_ParseError("Unbalanced namespace destruction: attempt " + "to pop global namespace; please report this as a bug"); + } + const undefs = this.undefStack.pop(); + for (const undef in undefs) { + if (undefs.hasOwnProperty(undef)) { + if (undefs[undef] == null) { + delete this.current[undef]; + } else { + this.current[undef] = undefs[undef]; + } + } + } + } + + /** + * Ends all currently nested groups (if any), restoring values before the + * groups began. Useful in case of an error in the middle of parsing. + */ + endGroups() { + while (this.undefStack.length > 0) { + this.endGroup(); + } + } + + /** + * Detect whether `name` has a definition. Equivalent to + * `get(name) != null`. + */ + has(name) { + return this.current.hasOwnProperty(name) || this.builtins.hasOwnProperty(name); + } + + /** + * Get the current value of a name, or `undefined` if there is no value. + * + * Note: Do not use `if (namespace.get(...))` to detect whether a macro + * is defined, as the definition may be the empty string which evaluates + * to `false` in JavaScript. Use `if (namespace.get(...) != null)` or + * `if (namespace.has(...))`. + */ + get(name) { + if (this.current.hasOwnProperty(name)) { + return this.current[name]; + } else { + return this.builtins[name]; + } + } + + /** + * Set the current value of a name, and optionally set it globally too. + * Local set() sets the current value and (when appropriate) adds an undo + * operation to the undo stack. Global set() may change the undo + * operation at every level, so takes time linear in their number. + * A value of undefined means to delete existing definitions. + */ + set(name, value, global) { + if (global === void 0) { + global = false; + } + if (global) { + // Global set is equivalent to setting in all groups. Simulate this + // by destroying any undos currently scheduled for this name, + // and adding an undo with the *new* value (in case it later gets + // locally reset within this environment). + for (let i = 0; i < this.undefStack.length; i++) { + delete this.undefStack[i][name]; + } + if (this.undefStack.length > 0) { + this.undefStack[this.undefStack.length - 1][name] = value; + } + } else { + // Undo this set at end of this group (possibly to `undefined`), + // unless an undo is already in place, in which case that older + // value is the correct one. + const top = this.undefStack[this.undefStack.length - 1]; + if (top && !top.hasOwnProperty(name)) { + top[name] = this.current[name]; + } + } + if (value == null) { + delete this.current[name]; + } else { + this.current[name] = value; + } + } +} +;// ./src/macros.ts +/** + * Predefined macros for KaTeX. + * This can be used to define some commands in terms of others. + */ + +// Export global macros object from defineMacro + +const macros = _macros; +/* harmony default export */ var src_macros = (macros); + + + + + +////////////////////////////////////////////////////////////////////// +// macro tools + +defineMacro("\\noexpand", function (context) { + // The expansion is the token itself; but that token is interpreted + // as if its meaning were ‘\relax’ if it is a control sequence that + // would ordinarily be expanded by TeX’s expansion rules. + const t = context.popToken(); + if (context.isExpandable(t.text)) { + t.noexpand = true; + t.treatAsRelax = true; + } + return { + tokens: [t], + numArgs: 0 + }; +}); +defineMacro("\\expandafter", function (context) { + // TeX first reads the token that comes immediately after \expandafter, + // without expanding it; let’s call this token t. Then TeX reads the + // token that comes after t (and possibly more tokens, if that token + // has an argument), replacing it by its expansion. Finally TeX puts + // t back in front of that expansion. + const t = context.popToken(); + context.expandOnce(true); // expand only an expandable token + return { + tokens: [t], + numArgs: 0 + }; +}); + +// LaTeX's \@firstoftwo{#1}{#2} expands to #1, skipping #2 +// TeX source: \long\def\@firstoftwo#1#2{#1} +defineMacro("\\@firstoftwo", function (context) { + const args = context.consumeArgs(2); + return { + tokens: args[0], + numArgs: 0 + }; +}); + +// LaTeX's \@secondoftwo{#1}{#2} expands to #2, skipping #1 +// TeX source: \long\def\@secondoftwo#1#2{#2} +defineMacro("\\@secondoftwo", function (context) { + const args = context.consumeArgs(2); + return { + tokens: args[1], + numArgs: 0 + }; +}); + +// LaTeX's \@ifnextchar{#1}{#2}{#3} looks ahead to the next (unexpanded) +// symbol that isn't a space, consuming any spaces but not consuming the +// first nonspace character. If that nonspace character matches #1, then +// the macro expands to #2; otherwise, it expands to #3. +defineMacro("\\@ifnextchar", function (context) { + const args = context.consumeArgs(3); // symbol, if, else + context.consumeSpaces(); + const nextToken = context.future(); + if (args[0].length === 1 && args[0][0].text === nextToken.text) { + return { + tokens: args[1], + numArgs: 0 + }; + } else { + return { + tokens: args[2], + numArgs: 0 + }; + } +}); + +// LaTeX's \@ifstar{#1}{#2} looks ahead to the next (unexpanded) symbol. +// If it is `*`, then it consumes the symbol, and the macro expands to #1; +// otherwise, the macro expands to #2 (without consuming the symbol). +// TeX source: \def\@ifstar#1{\@ifnextchar *{\@firstoftwo{#1}}} +defineMacro("\\@ifstar", "\\@ifnextchar *{\\@firstoftwo{#1}}"); + +// LaTeX's \TextOrMath{#1}{#2} expands to #1 in text mode, #2 in math mode +defineMacro("\\TextOrMath", function (context) { + const args = context.consumeArgs(2); + if (context.mode === 'text') { + return { + tokens: args[0], + numArgs: 0 + }; + } else { + return { + tokens: args[1], + numArgs: 0 + }; + } +}); + +// Lookup table for parsing numbers in base 8 through 16 +const digitToNumber = { + "0": 0, + "1": 1, + "2": 2, + "3": 3, + "4": 4, + "5": 5, + "6": 6, + "7": 7, + "8": 8, + "9": 9, + "a": 10, + "A": 10, + "b": 11, + "B": 11, + "c": 12, + "C": 12, + "d": 13, + "D": 13, + "e": 14, + "E": 14, + "f": 15, + "F": 15 +}; + +// TeX \char makes a literal character (catcode 12) using the following forms: +// (see The TeXBook, p. 43) +// \char123 -- decimal +// \char'123 -- octal +// \char"123 -- hex +// \char`x -- character that can be written (i.e. isn't active) +// \char`\x -- character that cannot be written (e.g. %) +// These all refer to characters from the font, so we turn them into special +// calls to a function \@char dealt with in the Parser. +defineMacro("\\char", function (context) { + let token = context.popToken(); + let base; + let number = 0; + if (token.text === "'") { + base = 8; + token = context.popToken(); + } else if (token.text === '"') { + base = 16; + token = context.popToken(); + } else if (token.text === "`") { + token = context.popToken(); + if (token.text[0] === "\\") { + number = token.text.charCodeAt(1); + } else if (token.text === "EOF") { + throw new src_ParseError("\\char` missing argument"); + } else { + number = token.text.charCodeAt(0); + } + } else { + base = 10; + } + if (base) { + // Parse a number in the given base, starting with first `token`. + number = digitToNumber[token.text]; + if (number == null || number >= base) { + throw new src_ParseError("Invalid base-" + base + " digit " + token.text); + } + let digit; + while ((digit = digitToNumber[context.future().text]) != null && digit < base) { + number *= base; + number += digit; + context.popToken(); + } + } + return "\\@char{" + number + "}"; +}); + +// \newcommand{\macro}[args]{definition} +// \renewcommand{\macro}[args]{definition} +// TODO: Optional arguments: \newcommand{\macro}[args][default]{definition} +const newcommand = (context, existsOK, nonexistsOK, skipIfExists) => { + let arg = context.consumeArg().tokens; + if (arg.length !== 1) { + throw new src_ParseError("\\newcommand's first argument must be a macro name"); + } + const name = arg[0].text; + const exists = context.isDefined(name); + if (exists && !existsOK) { + throw new src_ParseError("\\newcommand{" + name + "} attempting to redefine " + (name + "; use \\renewcommand")); + } + if (!exists && !nonexistsOK) { + throw new src_ParseError("\\renewcommand{" + name + "} when command " + name + " " + "does not yet exist; use \\newcommand"); + } + let numArgs = 0; + arg = context.consumeArg().tokens; + if (arg.length === 1 && arg[0].text === "[") { + let argText = ''; + let token = context.expandNextToken(); + while (token.text !== "]" && token.text !== "EOF") { + // TODO: Should properly expand arg, e.g., ignore {}s + argText += token.text; + token = context.expandNextToken(); + } + if (!argText.match(/^\s*[0-9]+\s*$/)) { + throw new src_ParseError("Invalid number of arguments: " + argText); + } + numArgs = parseInt(argText); + arg = context.consumeArg().tokens; + } + if (!(exists && skipIfExists)) { + // Final arg is the expansion of the macro + context.macros.set(name, { + tokens: arg, + numArgs + }); + } + return ''; +}; +defineMacro("\\newcommand", context => newcommand(context, false, true, false)); +defineMacro("\\renewcommand", context => newcommand(context, true, false, false)); +defineMacro("\\providecommand", context => newcommand(context, true, true, true)); + +// terminal (console) tools +defineMacro("\\message", context => { + const arg = context.consumeArgs(1)[0]; + // eslint-disable-next-line no-console + console.log(arg.reverse().map(token => token.text).join("")); + return ''; +}); +defineMacro("\\errmessage", context => { + const arg = context.consumeArgs(1)[0]; + // eslint-disable-next-line no-console + console.error(arg.reverse().map(token => token.text).join("")); + return ''; +}); +defineMacro("\\show", context => { + const tok = context.popToken(); + const name = tok.text; + // eslint-disable-next-line no-console + console.log(tok, context.macros.get(name), src_functions[name], src_symbols.math[name], src_symbols.text[name]); + return ''; +}); + +////////////////////////////////////////////////////////////////////// +// Grouping +// \let\bgroup={ \let\egroup=} +defineMacro("\\bgroup", "{"); +defineMacro("\\egroup", "}"); + +// Symbols from latex.ltx: +// \def~{\nobreakspace{}} +// \def\lq{`} +// \def\rq{'} +// \def \aa {\r a} +// \def \AA {\r A} +defineMacro("~", "\\nobreakspace"); +defineMacro("\\lq", "`"); +defineMacro("\\rq", "'"); +defineMacro("\\aa", "\\r a"); +defineMacro("\\AA", "\\r A"); + +// Copyright (C) and registered (R) symbols. Use raw symbol in MathML. +// \DeclareTextCommandDefault{\textcopyright}{\textcircled{c}} +// \DeclareTextCommandDefault{\textregistered}{\textcircled{% +// \check@mathfonts\fontsize\sf@size\z@\math@fontsfalse\selectfont R}} +// \DeclareRobustCommand{\copyright}{% +// \ifmmode{\nfss@text{\textcopyright}}\else\textcopyright\fi} +defineMacro("\\textcopyright", "\\html@mathml{\\textcircled{c}}{\\char`©}"); +defineMacro("\\copyright", "\\TextOrMath{\\textcopyright}{\\text{\\textcopyright}}"); +defineMacro("\\textregistered", "\\html@mathml{\\textcircled{\\scriptsize R}}{\\char`®}"); + +// Characters omitted from Unicode range 1D400–1D7FF +defineMacro("\u212C", "\\mathscr{B}"); // script +defineMacro("\u2130", "\\mathscr{E}"); +defineMacro("\u2131", "\\mathscr{F}"); +defineMacro("\u210B", "\\mathscr{H}"); +defineMacro("\u2110", "\\mathscr{I}"); +defineMacro("\u2112", "\\mathscr{L}"); +defineMacro("\u2133", "\\mathscr{M}"); +defineMacro("\u211B", "\\mathscr{R}"); +defineMacro("\u212D", "\\mathfrak{C}"); // Fraktur +defineMacro("\u210C", "\\mathfrak{H}"); +defineMacro("\u2128", "\\mathfrak{Z}"); + +// Define \Bbbk with a macro that works in both HTML and MathML. +defineMacro("\\Bbbk", "\\Bbb{k}"); + +// \llap and \rlap render their contents in text mode +defineMacro("\\llap", "\\mathllap{\\textrm{#1}}"); +defineMacro("\\rlap", "\\mathrlap{\\textrm{#1}}"); +defineMacro("\\clap", "\\mathclap{\\textrm{#1}}"); + +// \mathstrut from the TeXbook, p 360 +defineMacro("\\mathstrut", "\\vphantom{(}"); + +// \underbar from TeXbook p 353 +defineMacro("\\underbar", "\\underline{\\text{#1}}"); + +// \not is defined by base/fontmath.ltx via +// \DeclareMathSymbol{\not}{\mathrel}{symbols}{"36} +// It's thus treated like a \mathrel, but defined by a symbol that has zero +// width but extends to the right. We use \rlap to get that spacing. +// For MathML we write U+0338 here. buildMathML.js will then do the overlay. +defineMacro("\\not", "\\html@mathml{\\mathrel{\\mathrlap\\@not}\\nobreak}" + "{\\char\"338}"); + +// Negated symbols from base/fontmath.ltx: +// \def\neq{\not=} \let\ne=\neq +// \DeclareRobustCommand +// \notin{\mathrel{\m@th\mathpalette\c@ncel\in}} +// \def\c@ncel#1#2{\m@th\ooalign{$\hfil#1\mkern1mu/\hfil$\crcr$#1#2$}} +defineMacro("\\neq", "\\html@mathml{\\mathrel{\\not=}}{\\mathrel{\\char`≠}}"); +defineMacro("\\ne", "\\neq"); +defineMacro("\u2260", "\\neq"); +defineMacro("\\notin", "\\html@mathml{\\mathrel{{\\in}\\mathllap{/\\mskip1mu}}}" + "{\\mathrel{\\char`∉}}"); +defineMacro("\u2209", "\\notin"); + +// Unicode stacked relations +defineMacro("\u2258", "\\html@mathml{" + "\\mathrel{=\\kern{-1em}\\raisebox{0.4em}{$\\scriptsize\\frown$}}" + "}{\\mathrel{\\char`\u2258}}"); +defineMacro("\u2259", "\\html@mathml{\\stackrel{\\tiny\\wedge}{=}}{\\mathrel{\\char`\u2258}}"); +defineMacro("\u225A", "\\html@mathml{\\stackrel{\\tiny\\vee}{=}}{\\mathrel{\\char`\u225A}}"); +defineMacro("\u225B", "\\html@mathml{\\stackrel{\\scriptsize\\star}{=}}" + "{\\mathrel{\\char`\u225B}}"); +defineMacro("\u225D", "\\html@mathml{\\stackrel{\\tiny\\mathrm{def}}{=}}" + "{\\mathrel{\\char`\u225D}}"); +defineMacro("\u225E", "\\html@mathml{\\stackrel{\\tiny\\mathrm{m}}{=}}" + "{\\mathrel{\\char`\u225E}}"); +defineMacro("\u225F", "\\html@mathml{\\stackrel{\\tiny?}{=}}{\\mathrel{\\char`\u225F}}"); + +// Misc Unicode +defineMacro("\u27C2", "\\perp"); +defineMacro("\u203C", "\\mathclose{!\\mkern-0.8mu!}"); +defineMacro("\u220C", "\\notni"); +defineMacro("\u231C", "\\ulcorner"); +defineMacro("\u231D", "\\urcorner"); +defineMacro("\u231E", "\\llcorner"); +defineMacro("\u231F", "\\lrcorner"); +defineMacro("\u00A9", "\\copyright"); +defineMacro("\u00AE", "\\textregistered"); + +// The KaTeX fonts have corners at codepoints that don't match Unicode. +// For MathML purposes, use the Unicode code point. +defineMacro("\\ulcorner", "\\html@mathml{\\@ulcorner}{\\mathop{\\char\"231c}}"); +defineMacro("\\urcorner", "\\html@mathml{\\@urcorner}{\\mathop{\\char\"231d}}"); +defineMacro("\\llcorner", "\\html@mathml{\\@llcorner}{\\mathop{\\char\"231e}}"); +defineMacro("\\lrcorner", "\\html@mathml{\\@lrcorner}{\\mathop{\\char\"231f}}"); + +////////////////////////////////////////////////////////////////////// +// LaTeX_2ε + +// \vdots{\vbox{\baselineskip4\p@ \lineskiplimit\z@ +// \kern6\p@\hbox{.}\hbox{.}\hbox{.}}} +// We'll call \varvdots, which gets a glyph from symbols.js. +// The zero-width rule gets us an equivalent to the vertical 6pt kern. +defineMacro("\\vdots", "{\\varvdots\\rule{0pt}{15pt}}"); +defineMacro("\u22ee", "\\vdots"); + +////////////////////////////////////////////////////////////////////// +// amsmath.sty +// http://mirrors.concertpass.com/tex-archive/macros/latex/required/amsmath/amsmath.pdf + +// Italic Greek capital letters. AMS defines these with \DeclareMathSymbol, +// but they are equivalent to \mathit{\Letter}. +defineMacro("\\varGamma", "\\mathit{\\Gamma}"); +defineMacro("\\varDelta", "\\mathit{\\Delta}"); +defineMacro("\\varTheta", "\\mathit{\\Theta}"); +defineMacro("\\varLambda", "\\mathit{\\Lambda}"); +defineMacro("\\varXi", "\\mathit{\\Xi}"); +defineMacro("\\varPi", "\\mathit{\\Pi}"); +defineMacro("\\varSigma", "\\mathit{\\Sigma}"); +defineMacro("\\varUpsilon", "\\mathit{\\Upsilon}"); +defineMacro("\\varPhi", "\\mathit{\\Phi}"); +defineMacro("\\varPsi", "\\mathit{\\Psi}"); +defineMacro("\\varOmega", "\\mathit{\\Omega}"); + +//\newcommand{\substack}[1]{\subarray{c}#1\endsubarray} +defineMacro("\\substack", "\\begin{subarray}{c}#1\\end{subarray}"); + +// \renewcommand{\colon}{\nobreak\mskip2mu\mathpunct{}\nonscript +// \mkern-\thinmuskip{:}\mskip6muplus1mu\relax} +defineMacro("\\colon", "\\nobreak\\mskip2mu\\mathpunct{}" + "\\mathchoice{\\mkern-3mu}{\\mkern-3mu}{}{}{:}\\mskip6mu\\relax"); + +// \newcommand{\boxed}[1]{\fbox{\m@th$\displaystyle#1$}} +defineMacro("\\boxed", "\\fbox{$\\displaystyle{#1}$}"); + +// \def\iff{\DOTSB\;\Longleftrightarrow\;} +// \def\implies{\DOTSB\;\Longrightarrow\;} +// \def\impliedby{\DOTSB\;\Longleftarrow\;} +defineMacro("\\iff", "\\DOTSB\\;\\Longleftrightarrow\\;"); +defineMacro("\\implies", "\\DOTSB\\;\\Longrightarrow\\;"); +defineMacro("\\impliedby", "\\DOTSB\\;\\Longleftarrow\\;"); + +// \def\dddot#1{{\mathop{#1}\limits^{\vbox to-1.4\ex@{\kern-\tw@\ex@ +// \hbox{\normalfont ...}\vss}}}} +// We use \overset which avoids the vertical shift of \mathop. +defineMacro("\\dddot", "{\\overset{\\raisebox{-0.1ex}{\\normalsize ...}}{#1}}"); +defineMacro("\\ddddot", "{\\overset{\\raisebox{-0.1ex}{\\normalsize ....}}{#1}}"); + +// AMSMath's automatic \dots, based on \mdots@@ macro. +const dotsByToken = { + ',': '\\dotsc', + '\\not': '\\dotsb', + // \keybin@ checks for the following: + '+': '\\dotsb', + '=': '\\dotsb', + '<': '\\dotsb', + '>': '\\dotsb', + '-': '\\dotsb', + '*': '\\dotsb', + ':': '\\dotsb', + // Symbols whose definition starts with \DOTSB: + '\\DOTSB': '\\dotsb', + '\\coprod': '\\dotsb', + '\\bigvee': '\\dotsb', + '\\bigwedge': '\\dotsb', + '\\biguplus': '\\dotsb', + '\\bigcap': '\\dotsb', + '\\bigcup': '\\dotsb', + '\\prod': '\\dotsb', + '\\sum': '\\dotsb', + '\\bigotimes': '\\dotsb', + '\\bigoplus': '\\dotsb', + '\\bigodot': '\\dotsb', + '\\bigsqcup': '\\dotsb', + '\\And': '\\dotsb', + '\\longrightarrow': '\\dotsb', + '\\Longrightarrow': '\\dotsb', + '\\longleftarrow': '\\dotsb', + '\\Longleftarrow': '\\dotsb', + '\\longleftrightarrow': '\\dotsb', + '\\Longleftrightarrow': '\\dotsb', + '\\mapsto': '\\dotsb', + '\\longmapsto': '\\dotsb', + '\\hookrightarrow': '\\dotsb', + '\\doteq': '\\dotsb', + // Symbols whose definition starts with \mathbin: + '\\mathbin': '\\dotsb', + // Symbols whose definition starts with \mathrel: + '\\mathrel': '\\dotsb', + '\\relbar': '\\dotsb', + '\\Relbar': '\\dotsb', + '\\xrightarrow': '\\dotsb', + '\\xleftarrow': '\\dotsb', + // Symbols whose definition starts with \DOTSI: + '\\DOTSI': '\\dotsi', + '\\int': '\\dotsi', + '\\oint': '\\dotsi', + '\\iint': '\\dotsi', + '\\iiint': '\\dotsi', + '\\iiiint': '\\dotsi', + '\\idotsint': '\\dotsi', + // Symbols whose definition starts with \DOTSX: + '\\DOTSX': '\\dotsx' +}; +const dotsbGroups = new Set(['bin', 'rel']); +defineMacro("\\dots", function (context) { + // TODO: If used in text mode, should expand to \textellipsis. + // However, in KaTeX, \textellipsis and \ldots behave the same + // (in text mode), and it's unlikely we'd see any of the math commands + // that affect the behavior of \dots when in text mode. So fine for now + // (until we support \ifmmode ... \else ... \fi). + let thedots = '\\dotso'; + const next = context.expandAfterFuture().text; + if (next in dotsByToken) { + thedots = dotsByToken[next]; + } else if (next.slice(0, 4) === '\\not') { + thedots = '\\dotsb'; + } else if (next in src_symbols.math) { + if (dotsbGroups.has(src_symbols.math[next].group)) { + thedots = '\\dotsb'; + } + } + return thedots; +}); +const spaceAfterDots = { + // \rightdelim@ checks for the following: + ')': true, + ']': true, + '\\rbrack': true, + '\\}': true, + '\\rbrace': true, + '\\rangle': true, + '\\rceil': true, + '\\rfloor': true, + '\\rgroup': true, + '\\rmoustache': true, + '\\right': true, + '\\bigr': true, + '\\biggr': true, + '\\Bigr': true, + '\\Biggr': true, + // \extra@ also tests for the following: + '$': true, + // \extrap@ checks for the following: + ';': true, + '.': true, + ',': true +}; +defineMacro("\\dotso", function (context) { + const next = context.future().text; + if (next in spaceAfterDots) { + return "\\ldots\\,"; + } else { + return "\\ldots"; + } +}); +defineMacro("\\dotsc", function (context) { + const next = context.future().text; + // \dotsc uses \extra@ but not \extrap@, instead specially checking for + // ';' and '.', but doesn't check for ','. + if (next in spaceAfterDots && next !== ',') { + return "\\ldots\\,"; + } else { + return "\\ldots"; + } +}); +defineMacro("\\cdots", function (context) { + const next = context.future().text; + if (next in spaceAfterDots) { + return "\\@cdots\\,"; + } else { + return "\\@cdots"; + } +}); +defineMacro("\\dotsb", "\\cdots"); +defineMacro("\\dotsm", "\\cdots"); +defineMacro("\\dotsi", "\\!\\cdots"); +// amsmath doesn't actually define \dotsx, but \dots followed by a macro +// starting with \DOTSX implies \dotso, and then \extra@ detects this case +// and forces the added `\,`. +defineMacro("\\dotsx", "\\ldots\\,"); + +// \let\DOTSI\relax +// \let\DOTSB\relax +// \let\DOTSX\relax +defineMacro("\\DOTSI", "\\relax"); +defineMacro("\\DOTSB", "\\relax"); +defineMacro("\\DOTSX", "\\relax"); + +// Spacing, based on amsmath.sty's override of LaTeX defaults +// \DeclareRobustCommand{\tmspace}[3]{% +// \ifmmode\mskip#1#2\else\kern#1#3\fi\relax} +defineMacro("\\tmspace", "\\TextOrMath{\\kern#1#3}{\\mskip#1#2}\\relax"); +// \renewcommand{\,}{\tmspace+\thinmuskip{.1667em}} +// TODO: math mode should use \thinmuskip +defineMacro("\\,", "\\tmspace+{3mu}{.1667em}"); +// \let\thinspace\, +defineMacro("\\thinspace", "\\,"); +// \def\>{\mskip\medmuskip} +// \renewcommand{\:}{\tmspace+\medmuskip{.2222em}} +// TODO: \> and math mode of \: should use \medmuskip = 4mu plus 2mu minus 4mu +defineMacro("\\>", "\\mskip{4mu}"); +defineMacro("\\:", "\\tmspace+{4mu}{.2222em}"); +// \let\medspace\: +defineMacro("\\medspace", "\\:"); +// \renewcommand{\;}{\tmspace+\thickmuskip{.2777em}} +// TODO: math mode should use \thickmuskip = 5mu plus 5mu +defineMacro("\\;", "\\tmspace+{5mu}{.2777em}"); +// \let\thickspace\; +defineMacro("\\thickspace", "\\;"); +// \renewcommand{\!}{\tmspace-\thinmuskip{.1667em}} +// TODO: math mode should use \thinmuskip +defineMacro("\\!", "\\tmspace-{3mu}{.1667em}"); +// \let\negthinspace\! +defineMacro("\\negthinspace", "\\!"); +// \newcommand{\negmedspace}{\tmspace-\medmuskip{.2222em}} +// TODO: math mode should use \medmuskip +defineMacro("\\negmedspace", "\\tmspace-{4mu}{.2222em}"); +// \newcommand{\negthickspace}{\tmspace-\thickmuskip{.2777em}} +// TODO: math mode should use \thickmuskip +defineMacro("\\negthickspace", "\\tmspace-{5mu}{.277em}"); +// \def\enspace{\kern.5em } +defineMacro("\\enspace", "\\kern.5em "); +// \def\enskip{\hskip.5em\relax} +defineMacro("\\enskip", "\\hskip.5em\\relax"); +// \def\quad{\hskip1em\relax} +defineMacro("\\quad", "\\hskip1em\\relax"); +// \def\qquad{\hskip2em\relax} +defineMacro("\\qquad", "\\hskip2em\\relax"); + +// \tag@in@display form of \tag +defineMacro("\\tag", "\\@ifstar\\tag@literal\\tag@paren"); +defineMacro("\\tag@paren", "\\tag@literal{({#1})}"); +defineMacro("\\tag@literal", context => { + if (context.macros.get("\\df@tag")) { + throw new src_ParseError("Multiple \\tag"); + } + return "\\gdef\\df@tag{\\text{#1}}"; +}); + +// \renewcommand{\bmod}{\nonscript\mskip-\medmuskip\mkern5mu\mathbin +// {\operator@font mod}\penalty900 +// \mkern5mu\nonscript\mskip-\medmuskip} +// \newcommand{\pod}[1]{\allowbreak +// \if@display\mkern18mu\else\mkern8mu\fi(#1)} +// \renewcommand{\pmod}[1]{\pod{{\operator@font mod}\mkern6mu#1}} +// \newcommand{\mod}[1]{\allowbreak\if@display\mkern18mu +// \else\mkern12mu\fi{\operator@font mod}\,\,#1} +// TODO: math mode should use \medmuskip = 4mu plus 2mu minus 4mu +defineMacro("\\bmod", "\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}" + "\\mathbin{\\rm mod}" + "\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}"); +defineMacro("\\pod", "\\allowbreak" + "\\mathchoice{\\mkern18mu}{\\mkern8mu}{\\mkern8mu}{\\mkern8mu}(#1)"); +defineMacro("\\pmod", "\\pod{{\\rm mod}\\mkern6mu#1}"); +defineMacro("\\mod", "\\allowbreak" + "\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}" + "{\\rm mod}\\,\\,#1"); + +////////////////////////////////////////////////////////////////////// +// LaTeX source2e + +// \expandafter\let\expandafter\@normalcr +// \csname\expandafter\@gobble\string\\ \endcsname +// \DeclareRobustCommand\newline{\@normalcr\relax} +defineMacro("\\newline", "\\\\\\relax"); + +// \def\TeX{T\kern-.1667em\lower.5ex\hbox{E}\kern-.125emX\@} +// TODO: Doesn't normally work in math mode because \@ fails. KaTeX doesn't +// support \@ yet, so that's omitted, and we add \text so that the result +// doesn't look funny in math mode. +defineMacro("\\TeX", "\\textrm{\\html@mathml{" + "T\\kern-.1667em\\raisebox{-.5ex}{E}\\kern-.125emX" + "}{TeX}}"); + +// \DeclareRobustCommand{\LaTeX}{L\kern-.36em% +// {\sbox\z@ T% +// \vbox to\ht\z@{\hbox{\check@mathfonts +// \fontsize\sf@size\z@ +// \math@fontsfalse\selectfont +// A}% +// \vss}% +// }% +// \kern-.15em% +// \TeX} +// This code aligns the top of the A with the T (from the perspective of TeX's +// boxes, though visually the A appears to extend above slightly). +// We compute the corresponding \raisebox when A is rendered in \normalsize +// \scriptstyle, which has a scale factor of 0.7 (see Options.js). +const latexRaiseA = makeEm(fontMetricsData['Main-Regular']["T".charCodeAt(0)][1] - 0.7 * fontMetricsData['Main-Regular']["A".charCodeAt(0)][1]); +defineMacro("\\LaTeX", "\\textrm{\\html@mathml{" + ("L\\kern-.36em\\raisebox{" + latexRaiseA + "}{\\scriptstyle A}") + "\\kern-.15em\\TeX}{LaTeX}}"); + +// New KaTeX logo based on tweaking LaTeX logo +defineMacro("\\KaTeX", "\\textrm{\\html@mathml{" + ("K\\kern-.17em\\raisebox{" + latexRaiseA + "}{\\scriptstyle A}") + "\\kern-.15em\\TeX}{KaTeX}}"); + +// \DeclareRobustCommand\hspace{\@ifstar\@hspacer\@hspace} +// \def\@hspace#1{\hskip #1\relax} +// \def\@hspacer#1{\vrule \@width\z@\nobreak +// \hskip #1\hskip \z@skip} +defineMacro("\\hspace", "\\@ifstar\\@hspacer\\@hspace"); +defineMacro("\\@hspace", "\\hskip #1\\relax"); +defineMacro("\\@hspacer", "\\rule{0pt}{0pt}\\hskip #1\\relax"); + +////////////////////////////////////////////////////////////////////// +// mathtools.sty + +//\providecommand\ordinarycolon{:} +defineMacro("\\ordinarycolon", ":"); +//\def\vcentcolon{\mathrel{\mathop\ordinarycolon}} +//TODO(edemaine): Not yet centered. Fix via \raisebox or #726 +defineMacro("\\vcentcolon", "\\mathrel{\\mathop\\ordinarycolon}"); +// \providecommand*\dblcolon{\vcentcolon\mathrel{\mkern-.9mu}\vcentcolon} +defineMacro("\\dblcolon", "\\html@mathml{" + "\\mathrel{\\vcentcolon\\mathrel{\\mkern-.9mu}\\vcentcolon}}" + "{\\mathop{\\char\"2237}}"); +// \providecommand*\coloneqq{\vcentcolon\mathrel{\mkern-1.2mu}=} +defineMacro("\\coloneqq", "\\html@mathml{" + "\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}=}}" + "{\\mathop{\\char\"2254}}"); // ≔ +// \providecommand*\Coloneqq{\dblcolon\mathrel{\mkern-1.2mu}=} +defineMacro("\\Coloneqq", "\\html@mathml{" + "\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}=}}" + "{\\mathop{\\char\"2237\\char\"3d}}"); +// \providecommand*\coloneq{\vcentcolon\mathrel{\mkern-1.2mu}\mathrel{-}} +defineMacro("\\coloneq", "\\html@mathml{" + "\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}" + "{\\mathop{\\char\"3a\\char\"2212}}"); +// \providecommand*\Coloneq{\dblcolon\mathrel{\mkern-1.2mu}\mathrel{-}} +defineMacro("\\Coloneq", "\\html@mathml{" + "\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}" + "{\\mathop{\\char\"2237\\char\"2212}}"); +// \providecommand*\eqqcolon{=\mathrel{\mkern-1.2mu}\vcentcolon} +defineMacro("\\eqqcolon", "\\html@mathml{" + "\\mathrel{=\\mathrel{\\mkern-1.2mu}\\vcentcolon}}" + "{\\mathop{\\char\"2255}}"); // ≕ +// \providecommand*\Eqqcolon{=\mathrel{\mkern-1.2mu}\dblcolon} +defineMacro("\\Eqqcolon", "\\html@mathml{" + "\\mathrel{=\\mathrel{\\mkern-1.2mu}\\dblcolon}}" + "{\\mathop{\\char\"3d\\char\"2237}}"); +// \providecommand*\eqcolon{\mathrel{-}\mathrel{\mkern-1.2mu}\vcentcolon} +defineMacro("\\eqcolon", "\\html@mathml{" + "\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\vcentcolon}}" + "{\\mathop{\\char\"2239}}"); +// \providecommand*\Eqcolon{\mathrel{-}\mathrel{\mkern-1.2mu}\dblcolon} +defineMacro("\\Eqcolon", "\\html@mathml{" + "\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\dblcolon}}" + "{\\mathop{\\char\"2212\\char\"2237}}"); +// \providecommand*\colonapprox{\vcentcolon\mathrel{\mkern-1.2mu}\approx} +defineMacro("\\colonapprox", "\\html@mathml{" + "\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\approx}}" + "{\\mathop{\\char\"3a\\char\"2248}}"); +// \providecommand*\Colonapprox{\dblcolon\mathrel{\mkern-1.2mu}\approx} +defineMacro("\\Colonapprox", "\\html@mathml{" + "\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\approx}}" + "{\\mathop{\\char\"2237\\char\"2248}}"); +// \providecommand*\colonsim{\vcentcolon\mathrel{\mkern-1.2mu}\sim} +defineMacro("\\colonsim", "\\html@mathml{" + "\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\sim}}" + "{\\mathop{\\char\"3a\\char\"223c}}"); +// \providecommand*\Colonsim{\dblcolon\mathrel{\mkern-1.2mu}\sim} +defineMacro("\\Colonsim", "\\html@mathml{" + "\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\sim}}" + "{\\mathop{\\char\"2237\\char\"223c}}"); + +// Some Unicode characters are implemented with macros to mathtools functions. +defineMacro("\u2237", "\\dblcolon"); // :: +defineMacro("\u2239", "\\eqcolon"); // -: +defineMacro("\u2254", "\\coloneqq"); // := +defineMacro("\u2255", "\\eqqcolon"); // =: +defineMacro("\u2A74", "\\Coloneqq"); // ::= + +////////////////////////////////////////////////////////////////////// +// colonequals.sty + +// Alternate names for mathtools's macros: +defineMacro("\\ratio", "\\vcentcolon"); +defineMacro("\\coloncolon", "\\dblcolon"); +defineMacro("\\colonequals", "\\coloneqq"); +defineMacro("\\coloncolonequals", "\\Coloneqq"); +defineMacro("\\equalscolon", "\\eqqcolon"); +defineMacro("\\equalscoloncolon", "\\Eqqcolon"); +defineMacro("\\colonminus", "\\coloneq"); +defineMacro("\\coloncolonminus", "\\Coloneq"); +defineMacro("\\minuscolon", "\\eqcolon"); +defineMacro("\\minuscoloncolon", "\\Eqcolon"); +// \colonapprox name is same in mathtools and colonequals. +defineMacro("\\coloncolonapprox", "\\Colonapprox"); +// \colonsim name is same in mathtools and colonequals. +defineMacro("\\coloncolonsim", "\\Colonsim"); + +// Additional macros, implemented by analogy with mathtools definitions: +defineMacro("\\simcolon", "\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\vcentcolon}"); +defineMacro("\\simcoloncolon", "\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\dblcolon}"); +defineMacro("\\approxcolon", "\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\vcentcolon}"); +defineMacro("\\approxcoloncolon", "\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\dblcolon}"); + +// Present in newtxmath, pxfonts and txfonts +defineMacro("\\notni", "\\html@mathml{\\not\\ni}{\\mathrel{\\char`\u220C}}"); +defineMacro("\\limsup", "\\DOTSB\\operatorname*{lim\\,sup}"); +defineMacro("\\liminf", "\\DOTSB\\operatorname*{lim\\,inf}"); + +////////////////////////////////////////////////////////////////////// +// From amsopn.sty +defineMacro("\\injlim", "\\DOTSB\\operatorname*{inj\\,lim}"); +defineMacro("\\projlim", "\\DOTSB\\operatorname*{proj\\,lim}"); +defineMacro("\\varlimsup", "\\DOTSB\\operatorname*{\\overline{lim}}"); +defineMacro("\\varliminf", "\\DOTSB\\operatorname*{\\underline{lim}}"); +defineMacro("\\varinjlim", "\\DOTSB\\operatorname*{\\underrightarrow{lim}}"); +defineMacro("\\varprojlim", "\\DOTSB\\operatorname*{\\underleftarrow{lim}}"); + +////////////////////////////////////////////////////////////////////// +// MathML alternates for KaTeX glyphs in the Unicode private area +defineMacro("\\gvertneqq", "\\html@mathml{\\@gvertneqq}{\u2269}"); +defineMacro("\\lvertneqq", "\\html@mathml{\\@lvertneqq}{\u2268}"); +defineMacro("\\ngeqq", "\\html@mathml{\\@ngeqq}{\u2271}"); +defineMacro("\\ngeqslant", "\\html@mathml{\\@ngeqslant}{\u2271}"); +defineMacro("\\nleqq", "\\html@mathml{\\@nleqq}{\u2270}"); +defineMacro("\\nleqslant", "\\html@mathml{\\@nleqslant}{\u2270}"); +defineMacro("\\nshortmid", "\\html@mathml{\\@nshortmid}{∤}"); +defineMacro("\\nshortparallel", "\\html@mathml{\\@nshortparallel}{∦}"); +defineMacro("\\nsubseteqq", "\\html@mathml{\\@nsubseteqq}{\u2288}"); +defineMacro("\\nsupseteqq", "\\html@mathml{\\@nsupseteqq}{\u2289}"); +defineMacro("\\varsubsetneq", "\\html@mathml{\\@varsubsetneq}{⊊}"); +defineMacro("\\varsubsetneqq", "\\html@mathml{\\@varsubsetneqq}{⫋}"); +defineMacro("\\varsupsetneq", "\\html@mathml{\\@varsupsetneq}{⊋}"); +defineMacro("\\varsupsetneqq", "\\html@mathml{\\@varsupsetneqq}{⫌}"); +defineMacro("\\imath", "\\html@mathml{\\@imath}{\u0131}"); +defineMacro("\\jmath", "\\html@mathml{\\@jmath}{\u0237}"); + +////////////////////////////////////////////////////////////////////// +// stmaryrd and semantic + +// The stmaryrd and semantic packages render the next four items by calling a +// glyph. Those glyphs do not exist in the KaTeX fonts. Hence the macros. + +defineMacro("\\llbracket", "\\html@mathml{" + "\\mathopen{[\\mkern-3.2mu[}}" + "{\\mathopen{\\char`\u27e6}}"); +defineMacro("\\rrbracket", "\\html@mathml{" + "\\mathclose{]\\mkern-3.2mu]}}" + "{\\mathclose{\\char`\u27e7}}"); +defineMacro("\u27e6", "\\llbracket"); // blackboard bold [ +defineMacro("\u27e7", "\\rrbracket"); // blackboard bold ] + +defineMacro("\\lBrace", "\\html@mathml{" + "\\mathopen{\\{\\mkern-3.2mu[}}" + "{\\mathopen{\\char`\u2983}}"); +defineMacro("\\rBrace", "\\html@mathml{" + "\\mathclose{]\\mkern-3.2mu\\}}}" + "{\\mathclose{\\char`\u2984}}"); +defineMacro("\u2983", "\\lBrace"); // blackboard bold { +defineMacro("\u2984", "\\rBrace"); // blackboard bold } + +// TODO: Create variable sized versions of the last two items. I believe that +// will require new font glyphs. + +// The stmaryrd function `\minuso` provides a "Plimsoll" symbol that +// superimposes the characters \circ and \mathminus. Used in chemistry. +defineMacro("\\minuso", "\\mathbin{\\html@mathml{" + "{\\mathrlap{\\mathchoice{\\kern{0.145em}}{\\kern{0.145em}}" + "{\\kern{0.1015em}}{\\kern{0.0725em}}\\circ}{-}}}" + "{\\char`⦵}}"); +defineMacro("⦵", "\\minuso"); + +////////////////////////////////////////////////////////////////////// +// texvc.sty + +// The texvc package contains macros available in mediawiki pages. +// We omit the functions deprecated at +// https://en.wikipedia.org/wiki/Help:Displaying_a_formula#Deprecated_syntax + +// We also omit texvc's \O, which conflicts with \text{\O} + +defineMacro("\\darr", "\\downarrow"); +defineMacro("\\dArr", "\\Downarrow"); +defineMacro("\\Darr", "\\Downarrow"); +defineMacro("\\lang", "\\langle"); +defineMacro("\\rang", "\\rangle"); +defineMacro("\\uarr", "\\uparrow"); +defineMacro("\\uArr", "\\Uparrow"); +defineMacro("\\Uarr", "\\Uparrow"); +defineMacro("\\N", "\\mathbb{N}"); +defineMacro("\\R", "\\mathbb{R}"); +defineMacro("\\Z", "\\mathbb{Z}"); +defineMacro("\\alef", "\\aleph"); +defineMacro("\\alefsym", "\\aleph"); +defineMacro("\\Alpha", "\\mathrm{A}"); +defineMacro("\\Beta", "\\mathrm{B}"); +defineMacro("\\bull", "\\bullet"); +defineMacro("\\Chi", "\\mathrm{X}"); +defineMacro("\\clubs", "\\clubsuit"); +defineMacro("\\cnums", "\\mathbb{C}"); +defineMacro("\\Complex", "\\mathbb{C}"); +defineMacro("\\Dagger", "\\ddagger"); +defineMacro("\\diamonds", "\\diamondsuit"); +defineMacro("\\empty", "\\emptyset"); +defineMacro("\\Epsilon", "\\mathrm{E}"); +defineMacro("\\Eta", "\\mathrm{H}"); +defineMacro("\\exist", "\\exists"); +defineMacro("\\harr", "\\leftrightarrow"); +defineMacro("\\hArr", "\\Leftrightarrow"); +defineMacro("\\Harr", "\\Leftrightarrow"); +defineMacro("\\hearts", "\\heartsuit"); +defineMacro("\\image", "\\Im"); +defineMacro("\\infin", "\\infty"); +defineMacro("\\Iota", "\\mathrm{I}"); +defineMacro("\\isin", "\\in"); +defineMacro("\\Kappa", "\\mathrm{K}"); +defineMacro("\\larr", "\\leftarrow"); +defineMacro("\\lArr", "\\Leftarrow"); +defineMacro("\\Larr", "\\Leftarrow"); +defineMacro("\\lrarr", "\\leftrightarrow"); +defineMacro("\\lrArr", "\\Leftrightarrow"); +defineMacro("\\Lrarr", "\\Leftrightarrow"); +defineMacro("\\Mu", "\\mathrm{M}"); +defineMacro("\\natnums", "\\mathbb{N}"); +defineMacro("\\Nu", "\\mathrm{N}"); +defineMacro("\\Omicron", "\\mathrm{O}"); +defineMacro("\\plusmn", "\\pm"); +defineMacro("\\rarr", "\\rightarrow"); +defineMacro("\\rArr", "\\Rightarrow"); +defineMacro("\\Rarr", "\\Rightarrow"); +defineMacro("\\real", "\\Re"); +defineMacro("\\reals", "\\mathbb{R}"); +defineMacro("\\Reals", "\\mathbb{R}"); +defineMacro("\\Rho", "\\mathrm{P}"); +defineMacro("\\sdot", "\\cdot"); +defineMacro("\\sect", "\\S"); +defineMacro("\\spades", "\\spadesuit"); +defineMacro("\\sub", "\\subset"); +defineMacro("\\sube", "\\subseteq"); +defineMacro("\\supe", "\\supseteq"); +defineMacro("\\Tau", "\\mathrm{T}"); +defineMacro("\\thetasym", "\\vartheta"); +// TODO: defineMacro("\\varcoppa", "\\\mbox{\\coppa}"); +defineMacro("\\weierp", "\\wp"); +defineMacro("\\Zeta", "\\mathrm{Z}"); + +////////////////////////////////////////////////////////////////////// +// statmath.sty +// https://ctan.math.illinois.edu/macros/latex/contrib/statmath/statmath.pdf + +defineMacro("\\argmin", "\\DOTSB\\operatorname*{arg\\,min}"); +defineMacro("\\argmax", "\\DOTSB\\operatorname*{arg\\,max}"); +defineMacro("\\plim", "\\DOTSB\\mathop{\\operatorname{plim}}\\limits"); + +////////////////////////////////////////////////////////////////////// +// braket.sty +// http://ctan.math.washington.edu/tex-archive/macros/latex/contrib/braket/braket.pdf + +defineMacro("\\bra", "\\mathinner{\\langle{#1}|}"); +defineMacro("\\ket", "\\mathinner{|{#1}\\rangle}"); +defineMacro("\\braket", "\\mathinner{\\langle{#1}\\rangle}"); +defineMacro("\\Bra", "\\left\\langle#1\\right|"); +defineMacro("\\Ket", "\\left|#1\\right\\rangle"); +const braketHelper = one => context => { + const left = context.consumeArg().tokens; + const middle = context.consumeArg().tokens; + const middleDouble = context.consumeArg().tokens; + const right = context.consumeArg().tokens; + const oldMiddle = context.macros.get("|"); + const oldMiddleDouble = context.macros.get("\\|"); + context.macros.beginGroup(); + const midMacro = double => context => { + if (one) { + // Only modify the first instance of | or \| + context.macros.set("|", oldMiddle); + if (middleDouble.length) { + context.macros.set("\\|", oldMiddleDouble); + } + } + let doubled = double; + if (!double && middleDouble.length) { + // Mimic \@ifnextchar + const nextToken = context.future(); + if (nextToken.text === "|") { + context.popToken(); + doubled = true; + } + } + return { + tokens: doubled ? middleDouble : middle, + numArgs: 0 + }; + }; + context.macros.set("|", midMacro(false)); + if (middleDouble.length) { + context.macros.set("\\|", midMacro(true)); + } + const arg = context.consumeArg().tokens; + const expanded = context.expandTokens([...right, ...arg, ...left // reversed + ]); + context.macros.endGroup(); + return { + tokens: expanded.reverse(), + numArgs: 0 + }; +}; +defineMacro("\\bra@ket", braketHelper(false)); +defineMacro("\\bra@set", braketHelper(true)); +defineMacro("\\Braket", "\\bra@ket{\\left\\langle}" + "{\\,\\middle\\vert\\,}{\\,\\middle\\vert\\,}{\\right\\rangle}"); +defineMacro("\\Set", "\\bra@set{\\left\\{\\:}" + "{\\;\\middle\\vert\\;}{\\;\\middle\\Vert\\;}{\\:\\right\\}}"); +defineMacro("\\set", "\\bra@set{\\{\\,}{\\mid}{}{\\,\\}}"); +// has no support for special || or \| + +////////////////////////////////////////////////////////////////////// +// actuarialangle.dtx +defineMacro("\\angln", "{\\angl n}"); + +// Custom Khan Academy colors, should be moved to an optional package +defineMacro("\\blue", "\\textcolor{##6495ed}{#1}"); +defineMacro("\\orange", "\\textcolor{##ffa500}{#1}"); +defineMacro("\\pink", "\\textcolor{##ff00af}{#1}"); +defineMacro("\\red", "\\textcolor{##df0030}{#1}"); +defineMacro("\\green", "\\textcolor{##28ae7b}{#1}"); +defineMacro("\\gray", "\\textcolor{gray}{#1}"); +defineMacro("\\purple", "\\textcolor{##9d38bd}{#1}"); +defineMacro("\\blueA", "\\textcolor{##ccfaff}{#1}"); +defineMacro("\\blueB", "\\textcolor{##80f6ff}{#1}"); +defineMacro("\\blueC", "\\textcolor{##63d9ea}{#1}"); +defineMacro("\\blueD", "\\textcolor{##11accd}{#1}"); +defineMacro("\\blueE", "\\textcolor{##0c7f99}{#1}"); +defineMacro("\\tealA", "\\textcolor{##94fff5}{#1}"); +defineMacro("\\tealB", "\\textcolor{##26edd5}{#1}"); +defineMacro("\\tealC", "\\textcolor{##01d1c1}{#1}"); +defineMacro("\\tealD", "\\textcolor{##01a995}{#1}"); +defineMacro("\\tealE", "\\textcolor{##208170}{#1}"); +defineMacro("\\greenA", "\\textcolor{##b6ffb0}{#1}"); +defineMacro("\\greenB", "\\textcolor{##8af281}{#1}"); +defineMacro("\\greenC", "\\textcolor{##74cf70}{#1}"); +defineMacro("\\greenD", "\\textcolor{##1fab54}{#1}"); +defineMacro("\\greenE", "\\textcolor{##0d923f}{#1}"); +defineMacro("\\goldA", "\\textcolor{##ffd0a9}{#1}"); +defineMacro("\\goldB", "\\textcolor{##ffbb71}{#1}"); +defineMacro("\\goldC", "\\textcolor{##ff9c39}{#1}"); +defineMacro("\\goldD", "\\textcolor{##e07d10}{#1}"); +defineMacro("\\goldE", "\\textcolor{##a75a05}{#1}"); +defineMacro("\\redA", "\\textcolor{##fca9a9}{#1}"); +defineMacro("\\redB", "\\textcolor{##ff8482}{#1}"); +defineMacro("\\redC", "\\textcolor{##f9685d}{#1}"); +defineMacro("\\redD", "\\textcolor{##e84d39}{#1}"); +defineMacro("\\redE", "\\textcolor{##bc2612}{#1}"); +defineMacro("\\maroonA", "\\textcolor{##ffbde0}{#1}"); +defineMacro("\\maroonB", "\\textcolor{##ff92c6}{#1}"); +defineMacro("\\maroonC", "\\textcolor{##ed5fa6}{#1}"); +defineMacro("\\maroonD", "\\textcolor{##ca337c}{#1}"); +defineMacro("\\maroonE", "\\textcolor{##9e034e}{#1}"); +defineMacro("\\purpleA", "\\textcolor{##ddd7ff}{#1}"); +defineMacro("\\purpleB", "\\textcolor{##c6b9fc}{#1}"); +defineMacro("\\purpleC", "\\textcolor{##aa87ff}{#1}"); +defineMacro("\\purpleD", "\\textcolor{##7854ab}{#1}"); +defineMacro("\\purpleE", "\\textcolor{##543b78}{#1}"); +defineMacro("\\mintA", "\\textcolor{##f5f9e8}{#1}"); +defineMacro("\\mintB", "\\textcolor{##edf2df}{#1}"); +defineMacro("\\mintC", "\\textcolor{##e0e5cc}{#1}"); +defineMacro("\\grayA", "\\textcolor{##f6f7f7}{#1}"); +defineMacro("\\grayB", "\\textcolor{##f0f1f2}{#1}"); +defineMacro("\\grayC", "\\textcolor{##e3e5e6}{#1}"); +defineMacro("\\grayD", "\\textcolor{##d6d8da}{#1}"); +defineMacro("\\grayE", "\\textcolor{##babec2}{#1}"); +defineMacro("\\grayF", "\\textcolor{##888d93}{#1}"); +defineMacro("\\grayG", "\\textcolor{##626569}{#1}"); +defineMacro("\\grayH", "\\textcolor{##3b3e40}{#1}"); +defineMacro("\\grayI", "\\textcolor{##21242c}{#1}"); +defineMacro("\\kaBlue", "\\textcolor{##314453}{#1}"); +defineMacro("\\kaGreen", "\\textcolor{##71B307}{#1}"); +;// ./src/MacroExpander.ts +/** + * This file contains the “gullet” where macros are expanded + * until only non-macro tokens remain. + */ + + + + + + + + + +// List of commands that act like macros but aren't defined as a macro, +// function, or symbol. Used in `isDefined`. +const implicitCommands = { + "^": true, + // Parser.js + "_": true, + // Parser.js + "\\limits": true, + // Parser.js + "\\nolimits": true // Parser.js +}; +class MacroExpander { + constructor(input, settings, mode) { + this.settings = void 0; + this.expansionCount = void 0; + this.lexer = void 0; + this.macros = void 0; + this.stack = void 0; + this.mode = void 0; + this.settings = settings; + this.expansionCount = 0; + this.feed(input); + // Make new global namespace + this.macros = new Namespace(src_macros, settings.macros); + this.mode = mode; + this.stack = []; // contains tokens in REVERSE order + } + + /** + * Feed a new input string to the same MacroExpander + * (with existing macros etc.). + */ + feed(input) { + this.lexer = new Lexer(input, this.settings); + } + + /** + * Switches between "text" and "math" modes. + */ + switchMode(newMode) { + this.mode = newMode; + } + + /** + * Start a new group nesting within all namespaces. + */ + beginGroup() { + this.macros.beginGroup(); + } + + /** + * End current group nesting within all namespaces. + */ + endGroup() { + this.macros.endGroup(); + } + + /** + * Ends all currently nested groups (if any), restoring values before the + * groups began. Useful in case of an error in the middle of parsing. + */ + endGroups() { + this.macros.endGroups(); + } + + /** + * Returns the topmost token on the stack, without expanding it. + * Similar in behavior to TeX's `\futurelet`. + */ + future() { + if (this.stack.length === 0) { + this.pushToken(this.lexer.lex()); + } + return this.stack[this.stack.length - 1]; + } + + /** + * Remove and return the next unexpanded token. + */ + popToken() { + this.future(); // ensure non-empty stack + return this.stack.pop(); + } + + /** + * Add a given token to the token stack. In particular, this get be used + * to put back a token returned from one of the other methods. + */ + pushToken(token) { + this.stack.push(token); + } + + /** + * Append an array of tokens to the token stack. + */ + pushTokens(tokens) { + this.stack.push(...tokens); + } + + /** + * Find an macro argument without expanding tokens and append the array of + * tokens to the token stack. Uses Token as a container for the result. + */ + scanArgument(isOptional) { + let start; + let end; + let tokens; + if (isOptional) { + this.consumeSpaces(); // \@ifnextchar gobbles any space following it + if (this.future().text !== "[") { + return null; + } + start = this.popToken(); // don't include [ in tokens + ({ + tokens, + end + } = this.consumeArg(["]"])); + } else { + ({ + tokens, + start, + end + } = this.consumeArg()); + } + + // indicate the end of an argument + this.pushToken(new Token("EOF", end.loc)); + this.pushTokens(tokens); + return new Token("", SourceLocation.range(start, end)); + } + + /** + * Consume all following space tokens, without expansion. + */ + consumeSpaces() { + for (;;) { + const token = this.future(); + if (token.text === " ") { + this.stack.pop(); + } else { + break; + } + } + } + + /** + * Consume an argument from the token stream, and return the resulting array + * of tokens and start/end token. + */ + consumeArg(delims) { + // The argument for a delimited parameter is the shortest (possibly + // empty) sequence of tokens with properly nested {...} groups that is + // followed ... by this particular list of non-parameter tokens. + // The argument for an undelimited parameter is the next nonblank + // token, unless that token is ‘{’, when the argument will be the + // entire {...} group that follows. + const tokens = []; + const isDelimited = delims && delims.length > 0; + if (!isDelimited) { + // Ignore spaces between arguments. As the TeXbook says: + // "After you have said ‘\def\row#1#2{...}’, you are allowed to + // put spaces between the arguments (e.g., ‘\row x n’), because + // TeX doesn’t use single spaces as undelimited arguments." + this.consumeSpaces(); + } + const start = this.future(); + let tok; + let depth = 0; + let match = 0; + do { + tok = this.popToken(); + tokens.push(tok); + if (tok.text === "{") { + ++depth; + } else if (tok.text === "}") { + --depth; + if (depth === -1) { + throw new src_ParseError("Extra }", tok); + } + } else if (tok.text === "EOF") { + throw new src_ParseError("Unexpected end of input in a macro argument" + ", expected '" + (delims && isDelimited ? delims[match] : "}") + "'", tok); + } + if (delims && isDelimited) { + if ((depth === 0 || depth === 1 && delims[match] === "{") && tok.text === delims[match]) { + ++match; + if (match === delims.length) { + // don't include delims in tokens + tokens.splice(-match, match); + break; + } + } else { + match = 0; + } + } + } while (depth !== 0 || isDelimited); + // If the argument found ... has the form ‘{}’, + // ... the outermost braces enclosing the argument are removed + if (start.text === "{" && tokens[tokens.length - 1].text === "}") { + tokens.pop(); + tokens.shift(); + } + tokens.reverse(); // to fit in with stack order + return { + tokens, + start, + end: tok + }; + } + + /** + * Consume the specified number of (delimited) arguments from the token + * stream and return the resulting array of arguments. + */ + consumeArgs(numArgs, delimiters) { + if (delimiters) { + if (delimiters.length !== numArgs + 1) { + throw new src_ParseError("The length of delimiters doesn't match the number of args!"); + } + const delims = delimiters[0]; + for (let i = 0; i < delims.length; i++) { + const tok = this.popToken(); + if (delims[i] !== tok.text) { + throw new src_ParseError("Use of the macro doesn't match its definition", tok); + } + } + } + const args = []; + for (let i = 0; i < numArgs; i++) { + args.push(this.consumeArg(delimiters && delimiters[i + 1]).tokens); + } + return args; + } + + /** + * Increment `expansionCount` by the specified amount. + * Throw an error if it exceeds `maxExpand`. + */ + countExpansion(amount) { + this.expansionCount += amount; + if (this.expansionCount > this.settings.maxExpand) { + throw new src_ParseError("Too many expansions: infinite loop or " + "need to increase maxExpand setting"); + } + } + + /** + * Expand the next token only once if possible. + * + * If the token is expanded, the resulting tokens will be pushed onto + * the stack in reverse order, and the number of such tokens will be + * returned. This number might be zero or positive. + * + * If not, the return value is `false`, and the next token remains at the + * top of the stack. + * + * In either case, the next token will be on the top of the stack, + * or the stack will be empty (in case of empty expansion + * and no other tokens). + * + * Used to implement `expandAfterFuture` and `expandNextToken`. + * + * If expandableOnly, only expandable tokens are expanded and + * an undefined control sequence results in an error. + */ + expandOnce(expandableOnly) { + const topToken = this.popToken(); + const name = topToken.text; + const expansion = !topToken.noexpand ? this._getExpansion(name) : null; + if (expansion == null || expandableOnly && expansion.unexpandable) { + if (expandableOnly && expansion == null && name[0] === "\\" && !this.isDefined(name)) { + throw new src_ParseError("Undefined control sequence: " + name); + } + this.pushToken(topToken); + return false; + } + this.countExpansion(1); + let tokens = expansion.tokens; + const args = this.consumeArgs(expansion.numArgs, expansion.delimiters); + if (expansion.numArgs) { + // paste arguments in place of the placeholders + tokens = tokens.slice(); // make a shallow copy + for (let i = tokens.length - 1; i >= 0; --i) { + let tok = tokens[i]; + if (tok.text === "#") { + if (i === 0) { + throw new src_ParseError("Incomplete placeholder at end of macro body", tok); + } + tok = tokens[--i]; // next token on stack + if (tok.text === "#") { + // ## → # + tokens.splice(i + 1, 1); // drop first # + } else if (/^[1-9]$/.test(tok.text)) { + // replace the placeholder with the indicated argument + tokens.splice(i, 2, ...args[+tok.text - 1]); + } else { + throw new src_ParseError("Not a valid argument number", tok); + } + } + } + } + // Concatenate expansion onto top of stack. + this.pushTokens(tokens); + return tokens.length; + } + + /** + * Expand the next token only once (if possible), and return the resulting + * top token on the stack (without removing anything from the stack). + * Similar in behavior to TeX's `\expandafter\futurelet`. + * Equivalent to expandOnce() followed by future(). + */ + expandAfterFuture() { + this.expandOnce(); + return this.future(); + } + + /** + * Recursively expand first token, then return first non-expandable token. + */ + expandNextToken() { + for (;;) { + if (this.expandOnce() === false) { + // fully expanded + const token = this.stack.pop(); + // the token after \noexpand is interpreted as if its meaning + // were ‘\relax’ + if (token.treatAsRelax) { + token.text = "\\relax"; + } + return token; + } + } + } + + /** + * Fully expand the given macro name and return the resulting list of + * tokens, or return `undefined` if no such macro is defined. + */ + expandMacro(name) { + return this.macros.has(name) ? this.expandTokens([new Token(name)]) : undefined; + } + + /** + * Fully expand the given token stream and return the resulting list of + * tokens. Note that the input tokens are in reverse order, but the + * output tokens are in forward order. + */ + expandTokens(tokens) { + const output = []; + const oldStackLength = this.stack.length; + this.pushTokens(tokens); + while (this.stack.length > oldStackLength) { + // Expand only expandable tokens + if (this.expandOnce(true) === false) { + // fully expanded + const token = this.stack.pop(); + if (token.treatAsRelax) { + // the expansion of \noexpand is the token itself + token.noexpand = false; + token.treatAsRelax = false; + } + output.push(token); + } + } + // Count all of these tokens as additional expansions, to prevent + // exponential blowup from linearly many \edef's. + this.countExpansion(output.length); + return output; + } + + /** + * Fully expand the given macro name and return the result as a string, + * or return `undefined` if no such macro is defined. + */ + expandMacroAsText(name) { + const tokens = this.expandMacro(name); + if (tokens) { + return tokens.map(token => token.text).join(""); + } else { + return tokens; + } + } + + /** + * Returns the expanded macro as a reversed array of tokens and a macro + * argument count. Or returns `null` if no such macro. + */ + _getExpansion(name) { + const definition = this.macros.get(name); + if (definition == null) { + // mainly checking for undefined here + return definition; + } + // If a single character has an associated catcode other than 13 + // (active character), then don't expand it. + if (name.length === 1) { + const catcode = this.lexer.catcodes[name]; + if (catcode != null && catcode !== 13) { + return; + } + } + const expansion = typeof definition === "function" ? definition(this) : definition; + if (typeof expansion === "string") { + let numArgs = 0; + if (expansion.includes("#")) { + const stripped = expansion.replace(/##/g, ""); + while (stripped.includes("#" + (numArgs + 1))) { + ++numArgs; + } + } + const bodyLexer = new Lexer(expansion, this.settings); + const tokens = []; + let tok = bodyLexer.lex(); + while (tok.text !== "EOF") { + tokens.push(tok); + tok = bodyLexer.lex(); + } + tokens.reverse(); // to fit in with stack using push and pop + const expanded = { + tokens, + numArgs + }; + return expanded; + } + return expansion; + } + + /** + * Determine whether a command is currently "defined" (has some + * functionality), meaning that it's a macro (in the current group), + * a function, a symbol, or one of the special commands listed in + * `implicitCommands`. + */ + isDefined(name) { + return this.macros.has(name) || src_functions.hasOwnProperty(name) || src_symbols.math.hasOwnProperty(name) || src_symbols.text.hasOwnProperty(name) || implicitCommands.hasOwnProperty(name); + } + + /** + * Determine whether a command is expandable. + */ + isExpandable(name) { + const macro = this.macros.get(name); + return macro != null ? typeof macro === "string" || typeof macro === "function" || !macro.unexpandable : src_functions.hasOwnProperty(name) && !src_functions[name].primitive; + } +} +;// ./src/unicodeSupOrSub.ts +// Helpers for Parser.js handling of Unicode (sub|super)script characters. + +const unicodeSubRegEx = /^[₊₋₌₍₎₀₁₂₃₄₅₆₇₈₉ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓᵦᵧᵨᵩᵪ]/; +const uSubsAndSups = Object.freeze({ + '₊': '+', + '₋': '-', + '₌': '=', + '₍': '(', + '₎': ')', + '₀': '0', + '₁': '1', + '₂': '2', + '₃': '3', + '₄': '4', + '₅': '5', + '₆': '6', + '₇': '7', + '₈': '8', + '₉': '9', + '\u2090': 'a', + '\u2091': 'e', + '\u2095': 'h', + '\u1D62': 'i', + '\u2C7C': 'j', + '\u2096': 'k', + '\u2097': 'l', + '\u2098': 'm', + '\u2099': 'n', + '\u2092': 'o', + '\u209A': 'p', + '\u1D63': 'r', + '\u209B': 's', + '\u209C': 't', + '\u1D64': 'u', + '\u1D65': 'v', + '\u2093': 'x', + '\u1D66': 'β', + '\u1D67': 'γ', + '\u1D68': 'ρ', + '\u1D69': '\u03d5', + '\u1D6A': 'χ', + '⁺': '+', + '⁻': '-', + '⁼': '=', + '⁽': '(', + '⁾': ')', + '⁰': '0', + '¹': '1', + '²': '2', + '³': '3', + '⁴': '4', + '⁵': '5', + '⁶': '6', + '⁷': '7', + '⁸': '8', + '⁹': '9', + '\u1D2C': 'A', + '\u1D2E': 'B', + '\u1D30': 'D', + '\u1D31': 'E', + '\u1D33': 'G', + '\u1D34': 'H', + '\u1D35': 'I', + '\u1D36': 'J', + '\u1D37': 'K', + '\u1D38': 'L', + '\u1D39': 'M', + '\u1D3A': 'N', + '\u1D3C': 'O', + '\u1D3E': 'P', + '\u1D3F': 'R', + '\u1D40': 'T', + '\u1D41': 'U', + '\u2C7D': 'V', + '\u1D42': 'W', + '\u1D43': 'a', + '\u1D47': 'b', + '\u1D9C': 'c', + '\u1D48': 'd', + '\u1D49': 'e', + '\u1DA0': 'f', + '\u1D4D': 'g', + '\u02B0': 'h', + '\u2071': 'i', + '\u02B2': 'j', + '\u1D4F': 'k', + '\u02E1': 'l', + '\u1D50': 'm', + '\u207F': 'n', + '\u1D52': 'o', + '\u1D56': 'p', + '\u02B3': 'r', + '\u02E2': 's', + '\u1D57': 't', + '\u1D58': 'u', + '\u1D5B': 'v', + '\u02B7': 'w', + '\u02E3': 'x', + '\u02B8': 'y', + '\u1DBB': 'z', + '\u1D5D': 'β', + '\u1D5E': 'γ', + '\u1D5F': 'δ', + '\u1D60': '\u03d5', + '\u1D61': 'χ', + '\u1DBF': 'θ' +}); +;// ./src/Parser.ts +/* eslint no-constant-condition:0 */ + + + + + + + + + + + + +// Pre-evaluate both modules as unicodeSymbols require String.normalize() +const unicodeAccents = { + "́": { + "text": "\\'", + "math": "\\acute" + }, + "̀": { + "text": "\\`", + "math": "\\grave" + }, + "̈": { + "text": "\\\"", + "math": "\\ddot" + }, + "̃": { + "text": "\\~", + "math": "\\tilde" + }, + "̄": { + "text": "\\=", + "math": "\\bar" + }, + "̆": { + "text": "\\u", + "math": "\\breve" + }, + "̌": { + "text": "\\v", + "math": "\\check" + }, + "̂": { + "text": "\\^", + "math": "\\hat" + }, + "̇": { + "text": "\\.", + "math": "\\dot" + }, + "̊": { + "text": "\\r", + "math": "\\mathring" + }, + "̋": { + "text": "\\H" + }, + "̧": { + "text": "\\c" + } +}; +const unicodeSymbols = { + "á": "á", + "à": "à", + "ä": "ä", + "ǟ": "ǟ", + "ã": "ã", + "ā": "ā", + "ă": "ă", + "ắ": "ắ", + "ằ": "ằ", + "ẵ": "ẵ", + "ǎ": "ǎ", + "â": "â", + "ấ": "ấ", + "ầ": "ầ", + "ẫ": "ẫ", + "ȧ": "ȧ", + "ǡ": "ǡ", + "å": "å", + "ǻ": "ǻ", + "ḃ": "ḃ", + "ć": "ć", + "ḉ": "ḉ", + "č": "č", + "ĉ": "ĉ", + "ċ": "ċ", + "ç": "ç", + "ď": "ď", + "ḋ": "ḋ", + "ḑ": "ḑ", + "é": "é", + "è": "è", + "ë": "ë", + "ẽ": "ẽ", + "ē": "ē", + "ḗ": "ḗ", + "ḕ": "ḕ", + "ĕ": "ĕ", + "ḝ": "ḝ", + "ě": "ě", + "ê": "ê", + "ế": "ế", + "ề": "ề", + "ễ": "ễ", + "ė": "ė", + "ȩ": "ȩ", + "ḟ": "ḟ", + "ǵ": "ǵ", + "ḡ": "ḡ", + "ğ": "ğ", + "ǧ": "ǧ", + "ĝ": "ĝ", + "ġ": "ġ", + "ģ": "ģ", + "ḧ": "ḧ", + "ȟ": "ȟ", + "ĥ": "ĥ", + "ḣ": "ḣ", + "ḩ": "ḩ", + "í": "í", + "ì": "ì", + "ï": "ï", + "ḯ": "ḯ", + "ĩ": "ĩ", + "ī": "ī", + "ĭ": "ĭ", + "ǐ": "ǐ", + "î": "î", + "ǰ": "ǰ", + "ĵ": "ĵ", + "ḱ": "ḱ", + "ǩ": "ǩ", + "ķ": "ķ", + "ĺ": "ĺ", + "ľ": "ľ", + "ļ": "ļ", + "ḿ": "ḿ", + "ṁ": "ṁ", + "ń": "ń", + "ǹ": "ǹ", + "ñ": "ñ", + "ň": "ň", + "ṅ": "ṅ", + "ņ": "ņ", + "ó": "ó", + "ò": "ò", + "ö": "ö", + "ȫ": "ȫ", + "õ": "õ", + "ṍ": "ṍ", + "ṏ": "ṏ", + "ȭ": "ȭ", + "ō": "ō", + "ṓ": "ṓ", + "ṑ": "ṑ", + "ŏ": "ŏ", + "ǒ": "ǒ", + "ô": "ô", + "ố": "ố", + "ồ": "ồ", + "ỗ": "ỗ", + "ȯ": "ȯ", + "ȱ": "ȱ", + "ő": "ő", + "ṕ": "ṕ", + "ṗ": "ṗ", + "ŕ": "ŕ", + "ř": "ř", + "ṙ": "ṙ", + "ŗ": "ŗ", + "ś": "ś", + "ṥ": "ṥ", + "š": "š", + "ṧ": "ṧ", + "ŝ": "ŝ", + "ṡ": "ṡ", + "ş": "ş", + "ẗ": "ẗ", + "ť": "ť", + "ṫ": "ṫ", + "ţ": "ţ", + "ú": "ú", + "ù": "ù", + "ü": "ü", + "ǘ": "ǘ", + "ǜ": "ǜ", + "ǖ": "ǖ", + "ǚ": "ǚ", + "ũ": "ũ", + "ṹ": "ṹ", + "ū": "ū", + "ṻ": "ṻ", + "ŭ": "ŭ", + "ǔ": "ǔ", + "û": "û", + "ů": "ů", + "ű": "ű", + "ṽ": "ṽ", + "ẃ": "ẃ", + "ẁ": "ẁ", + "ẅ": "ẅ", + "ŵ": "ŵ", + "ẇ": "ẇ", + "ẘ": "ẘ", + "ẍ": "ẍ", + "ẋ": "ẋ", + "ý": "ý", + "ỳ": "ỳ", + "ÿ": "ÿ", + "ỹ": "ỹ", + "ȳ": "ȳ", + "ŷ": "ŷ", + "ẏ": "ẏ", + "ẙ": "ẙ", + "ź": "ź", + "ž": "ž", + "ẑ": "ẑ", + "ż": "ż", + "Á": "Á", + "À": "À", + "Ä": "Ä", + "Ǟ": "Ǟ", + "Ã": "Ã", + "Ā": "Ā", + "Ă": "Ă", + "Ắ": "Ắ", + "Ằ": "Ằ", + "Ẵ": "Ẵ", + "Ǎ": "Ǎ", + "Â": "Â", + "Ấ": "Ấ", + "Ầ": "Ầ", + "Ẫ": "Ẫ", + "Ȧ": "Ȧ", + "Ǡ": "Ǡ", + "Å": "Å", + "Ǻ": "Ǻ", + "Ḃ": "Ḃ", + "Ć": "Ć", + "Ḉ": "Ḉ", + "Č": "Č", + "Ĉ": "Ĉ", + "Ċ": "Ċ", + "Ç": "Ç", + "Ď": "Ď", + "Ḋ": "Ḋ", + "Ḑ": "Ḑ", + "É": "É", + "È": "È", + "Ë": "Ë", + "Ẽ": "Ẽ", + "Ē": "Ē", + "Ḗ": "Ḗ", + "Ḕ": "Ḕ", + "Ĕ": "Ĕ", + "Ḝ": "Ḝ", + "Ě": "Ě", + "Ê": "Ê", + "Ế": "Ế", + "Ề": "Ề", + "Ễ": "Ễ", + "Ė": "Ė", + "Ȩ": "Ȩ", + "Ḟ": "Ḟ", + "Ǵ": "Ǵ", + "Ḡ": "Ḡ", + "Ğ": "Ğ", + "Ǧ": "Ǧ", + "Ĝ": "Ĝ", + "Ġ": "Ġ", + "Ģ": "Ģ", + "Ḧ": "Ḧ", + "Ȟ": "Ȟ", + "Ĥ": "Ĥ", + "Ḣ": "Ḣ", + "Ḩ": "Ḩ", + "Í": "Í", + "Ì": "Ì", + "Ï": "Ï", + "Ḯ": "Ḯ", + "Ĩ": "Ĩ", + "Ī": "Ī", + "Ĭ": "Ĭ", + "Ǐ": "Ǐ", + "Î": "Î", + "İ": "İ", + "Ĵ": "Ĵ", + "Ḱ": "Ḱ", + "Ǩ": "Ǩ", + "Ķ": "Ķ", + "Ĺ": "Ĺ", + "Ľ": "Ľ", + "Ļ": "Ļ", + "Ḿ": "Ḿ", + "Ṁ": "Ṁ", + "Ń": "Ń", + "Ǹ": "Ǹ", + "Ñ": "Ñ", + "Ň": "Ň", + "Ṅ": "Ṅ", + "Ņ": "Ņ", + "Ó": "Ó", + "Ò": "Ò", + "Ö": "Ö", + "Ȫ": "Ȫ", + "Õ": "Õ", + "Ṍ": "Ṍ", + "Ṏ": "Ṏ", + "Ȭ": "Ȭ", + "Ō": "Ō", + "Ṓ": "Ṓ", + "Ṑ": "Ṑ", + "Ŏ": "Ŏ", + "Ǒ": "Ǒ", + "Ô": "Ô", + "Ố": "Ố", + "Ồ": "Ồ", + "Ỗ": "Ỗ", + "Ȯ": "Ȯ", + "Ȱ": "Ȱ", + "Ő": "Ő", + "Ṕ": "Ṕ", + "Ṗ": "Ṗ", + "Ŕ": "Ŕ", + "Ř": "Ř", + "Ṙ": "Ṙ", + "Ŗ": "Ŗ", + "Ś": "Ś", + "Ṥ": "Ṥ", + "Š": "Š", + "Ṧ": "Ṧ", + "Ŝ": "Ŝ", + "Ṡ": "Ṡ", + "Ş": "Ş", + "Ť": "Ť", + "Ṫ": "Ṫ", + "Ţ": "Ţ", + "Ú": "Ú", + "Ù": "Ù", + "Ü": "Ü", + "Ǘ": "Ǘ", + "Ǜ": "Ǜ", + "Ǖ": "Ǖ", + "Ǚ": "Ǚ", + "Ũ": "Ũ", + "Ṹ": "Ṹ", + "Ū": "Ū", + "Ṻ": "Ṻ", + "Ŭ": "Ŭ", + "Ǔ": "Ǔ", + "Û": "Û", + "Ů": "Ů", + "Ű": "Ű", + "Ṽ": "Ṽ", + "Ẃ": "Ẃ", + "Ẁ": "Ẁ", + "Ẅ": "Ẅ", + "Ŵ": "Ŵ", + "Ẇ": "Ẇ", + "Ẍ": "Ẍ", + "Ẋ": "Ẋ", + "Ý": "Ý", + "Ỳ": "Ỳ", + "Ÿ": "Ÿ", + "Ỹ": "Ỹ", + "Ȳ": "Ȳ", + "Ŷ": "Ŷ", + "Ẏ": "Ẏ", + "Ź": "Ź", + "Ž": "Ž", + "Ẑ": "Ẑ", + "Ż": "Ż", + "ά": "ά", + "ὰ": "ὰ", + "ᾱ": "ᾱ", + "ᾰ": "ᾰ", + "έ": "έ", + "ὲ": "ὲ", + "ή": "ή", + "ὴ": "ὴ", + "ί": "ί", + "ὶ": "ὶ", + "ϊ": "ϊ", + "ΐ": "ΐ", + "ῒ": "ῒ", + "ῑ": "ῑ", + "ῐ": "ῐ", + "ό": "ό", + "ὸ": "ὸ", + "ύ": "ύ", + "ὺ": "ὺ", + "ϋ": "ϋ", + "ΰ": "ΰ", + "ῢ": "ῢ", + "ῡ": "ῡ", + "ῠ": "ῠ", + "ώ": "ώ", + "ὼ": "ὼ", + "Ύ": "Ύ", + "Ὺ": "Ὺ", + "Ϋ": "Ϋ", + "Ῡ": "Ῡ", + "Ῠ": "Ῠ", + "Ώ": "Ώ", + "Ὼ": "Ὼ" +}; +/** + * This file contains the parser used to parse out a TeX expression from the + * input. Since TeX isn't context-free, standard parsers don't work particularly + * well. + * + * The strategy of this parser is as such: + * + * The main functions (the `.parse...` ones) take a position in the current + * parse string to parse tokens from. The lexer (found in Lexer.js, stored at + * this.gullet.lexer) also supports pulling out tokens at arbitrary places. When + * individual tokens are needed at a position, the lexer is called to pull out a + * token, which is then used. + * + * The parser has a property called "mode" indicating the mode that + * the parser is currently in. Currently it has to be one of "math" or + * "text", which denotes whether the current environment is a math-y + * one or a text-y one (e.g. inside \text). Currently, this serves to + * limit the functions which can be used in text mode. + * + * The main functions then return an object which contains the useful data that + * was parsed at its given point, and a new position at the end of the parsed + * data. The main functions can call each other and continue the parsing by + * using the returned position as a new starting point. + * + * There are also extra `.handle...` functions, which pull out some reused + * functionality into self-contained functions. + * + * The functions return ParseNodes. + */ + +class Parser { + constructor(input, settings) { + this.mode = void 0; + this.gullet = void 0; + this.settings = void 0; + this.leftrightDepth = void 0; + this.nextToken = void 0; + // Start in math mode + this.mode = "math"; + // Create a new macro expander (gullet) and (indirectly via that) also a + // new lexer (mouth) for this parser (stomach, in the language of TeX) + this.gullet = new MacroExpander(input, settings, this.mode); + // Store the settings for use in parsing + this.settings = settings; + // Count leftright depth (for \middle errors) + this.leftrightDepth = 0; + this.nextToken = null; + } + + /** + * Checks a result to make sure it has the right type, and throws an + * appropriate error otherwise. + */ + expect(text, consume) { + if (consume === void 0) { + consume = true; + } + if (this.fetch().text !== text) { + throw new src_ParseError("Expected '" + text + "', got '" + this.fetch().text + "'", this.fetch()); + } + if (consume) { + this.consume(); + } + } + + /** + * Discards the current lookahead token, considering it consumed. + */ + consume() { + this.nextToken = null; + } + + /** + * Return the current lookahead token, or if there isn't one (at the + * beginning, or if the previous lookahead token was consume()d), + * fetch the next token as the new lookahead token and return it. + */ + fetch() { + if (this.nextToken == null) { + this.nextToken = this.gullet.expandNextToken(); + } + return this.nextToken; + } + + /** + * Switches between "text" and "math" modes. + */ + switchMode(newMode) { + this.mode = newMode; + this.gullet.switchMode(newMode); + } + + /** + * Main parsing function, which parses an entire input. + */ + parse() { + if (!this.settings.globalGroup) { + // Create a group namespace for the math expression. + // (LaTeX creates a new group for every $...$, $$...$$, \[...\].) + this.gullet.beginGroup(); + } + + // Use old \color behavior (same as LaTeX's \textcolor) if requested. + // We do this within the group for the math expression, so it doesn't + // pollute settings.macros. + if (this.settings.colorIsTextColor) { + this.gullet.macros.set("\\color", "\\textcolor"); + } + try { + // Try to parse the input + const parse = this.parseExpression(false); + + // If we succeeded, make sure there's an EOF at the end + this.expect("EOF"); + + // End the group namespace for the expression + if (!this.settings.globalGroup) { + this.gullet.endGroup(); + } + return parse; + + // Close any leftover groups in case of a parse error. + } finally { + this.gullet.endGroups(); + } + } + + /** + * Fully parse a separate sequence of tokens as a separate job. + * Tokens should be specified in reverse order, as in a MacroDefinition. + */ + subparse(tokens) { + // Save the next token from the current job. + const oldToken = this.nextToken; + this.consume(); + + // Run the new job, terminating it with an excess '}' + this.gullet.pushToken(new Token("}")); + this.gullet.pushTokens(tokens); + const parse = this.parseExpression(false); + this.expect("}"); + + // Restore the next token from the current job. + this.nextToken = oldToken; + return parse; + } + /** + * Parses an "expression", which is a list of atoms. + * + * `breakOnInfix`: Should the parsing stop when we hit infix nodes? This + * happens when functions have higher precedence than infix + * nodes in implicit parses. + * + * `breakOnTokenText`: The text of the token that the expression should end + * with, or `null` if something else should end the + * expression. + */ + parseExpression(breakOnInfix, breakOnTokenText) { + const body = []; + // Keep adding atoms to the body until we can't parse any more atoms (either + // we reached the end, a }, or a \right) + while (true) { + // Ignore spaces in math mode + if (this.mode === "math") { + this.consumeSpaces(); + } + const lex = this.fetch(); + if (Parser.endOfExpression.has(lex.text)) { + break; + } + if (breakOnTokenText && lex.text === breakOnTokenText) { + break; + } + if (breakOnInfix && src_functions[lex.text] && src_functions[lex.text].infix) { + break; + } + const atom = this.parseAtom(breakOnTokenText); + if (!atom) { + break; + } else if (atom.type === "internal") { + // Internal nodes do not appear in parse tree + continue; + } + body.push(atom); + } + if (this.mode === "text") { + this.formLigatures(body); + } + return this.handleInfixNodes(body); + } + + /** + * Rewrites infix operators such as \over with corresponding commands such + * as \frac. + * + * There can only be one infix operator per group. If there's more than one + * then the expression is ambiguous. This can be resolved by adding {}. + */ + handleInfixNodes(body) { + let overIndex = -1; + let funcName; + for (let i = 0; i < body.length; i++) { + const node = body[i]; + if (node.type === "infix") { + if (overIndex !== -1) { + throw new src_ParseError("only one infix operator per group", node.token); + } + overIndex = i; + funcName = node.replaceWith; + } + } + if (overIndex !== -1 && funcName) { + let numerNode; + let denomNode; + const numerBody = body.slice(0, overIndex); + const denomBody = body.slice(overIndex + 1); + if (numerBody.length === 1 && numerBody[0].type === "ordgroup") { + numerNode = numerBody[0]; + } else { + numerNode = { + type: "ordgroup", + mode: this.mode, + body: numerBody + }; + } + if (denomBody.length === 1 && denomBody[0].type === "ordgroup") { + denomNode = denomBody[0]; + } else { + denomNode = { + type: "ordgroup", + mode: this.mode, + body: denomBody + }; + } + let node; + if (funcName === "\\\\abovefrac") { + node = this.callFunction(funcName, [numerNode, body[overIndex], denomNode], []); + } else { + node = this.callFunction(funcName, [numerNode, denomNode], []); + } + return [node]; + } else { + return body; + } + } + + /** + * Handle a subscript or superscript with nice errors. + */ + handleSupSubscript(name // For error reporting. + ) { + const symbolToken = this.fetch(); + const symbol = symbolToken.text; + this.consume(); + this.consumeSpaces(); // ignore spaces before sup/subscript argument + + // Skip over allowed internal nodes such as \relax + let group; + do { + var _group; + group = this.parseGroup(name); + } while (((_group = group) == null ? void 0 : _group.type) === "internal"); + if (!group) { + throw new src_ParseError("Expected group after '" + symbol + "'", symbolToken); + } + return group; + } + + /** + * Converts the textual input of an unsupported command into a text node + * contained within a color node whose color is determined by errorColor + */ + formatUnsupportedCmd(text) { + const textordArray = []; + for (let i = 0; i < text.length; i++) { + textordArray.push({ + type: "textord", + mode: "text", + text: text[i] + }); + } + const textNode = { + type: "text", + mode: this.mode, + body: textordArray + }; + const colorNode = { + type: "color", + mode: this.mode, + color: this.settings.errorColor, + body: [textNode] + }; + return colorNode; + } + + /** + * Parses a group with optional super/subscripts. + */ + parseAtom(breakOnTokenText) { + // The body of an atom is an implicit group, so that things like + // \left(x\right)^2 work correctly. + const base = this.parseGroup("atom", breakOnTokenText); + + // Internal nodes (e.g. \relax) cannot support super/subscripts. + // Instead we will pick up super/subscripts with blank base next round. + if ((base == null ? void 0 : base.type) === "internal") { + return base; + } + + // In text mode, we don't have superscripts or subscripts + if (this.mode === "text") { + return base; + } + + // Note that base may be empty (i.e. null) at this point. + + let superscript; + let subscript; + while (true) { + // Guaranteed in math mode, so eat any spaces first. + this.consumeSpaces(); + + // Lex the first token + const lex = this.fetch(); + if (lex.text === "\\limits" || lex.text === "\\nolimits") { + // We got a limit control + if (base && base.type === "op") { + const limits = lex.text === "\\limits"; + base.limits = limits; + base.alwaysHandleSupSub = true; + } else if (base && base.type === "operatorname") { + if (base.alwaysHandleSupSub) { + base.limits = lex.text === "\\limits"; + } + } else { + throw new src_ParseError("Limit controls must follow a math operator", lex); + } + this.consume(); + } else if (lex.text === "^") { + // We got a superscript start + if (superscript) { + throw new src_ParseError("Double superscript", lex); + } + superscript = this.handleSupSubscript("superscript"); + } else if (lex.text === "_") { + // We got a subscript start + if (subscript) { + throw new src_ParseError("Double subscript", lex); + } + subscript = this.handleSupSubscript("subscript"); + } else if (lex.text === "'") { + // We got a prime + if (superscript) { + throw new src_ParseError("Double superscript", lex); + } + const prime = { + type: "textord", + mode: this.mode, + text: "\\prime" + }; + + // Many primes can be grouped together, so we handle this here + const primes = [prime]; + this.consume(); + // Keep lexing tokens until we get something that's not a prime + while (this.fetch().text === "'") { + // For each one, add another prime to the list + primes.push(prime); + this.consume(); + } + // If there's a superscript following the primes, combine that + // superscript in with the primes. + if (this.fetch().text === "^") { + primes.push(this.handleSupSubscript("superscript")); + } + // Put everything into an ordgroup as the superscript + superscript = { + type: "ordgroup", + mode: this.mode, + body: primes + }; + } else if (uSubsAndSups[lex.text]) { + // A Unicode subscript or superscript character. + // We treat these similarly to the unicode-math package. + // So we render a string of Unicode (sub|super)scripts the + // same as a (sub|super)script of regular characters. + const isSub = unicodeSubRegEx.test(lex.text); + const subsupTokens = []; + subsupTokens.push(new Token(uSubsAndSups[lex.text])); + this.consume(); + // Continue fetching tokens to fill out the string. + while (true) { + const token = this.fetch().text; + if (!uSubsAndSups[token]) { + break; + } + if (unicodeSubRegEx.test(token) !== isSub) { + break; + } + subsupTokens.unshift(new Token(uSubsAndSups[token])); + this.consume(); + } + // Now create a (sub|super)script. + const body = this.subparse(subsupTokens); + if (isSub) { + subscript = { + type: "ordgroup", + mode: "math", + body + }; + } else { + superscript = { + type: "ordgroup", + mode: "math", + body + }; + } + } else { + // If it wasn't ^, _, or ', stop parsing super/subscripts + break; + } + } + + // Base must be set if superscript or subscript are set per logic above, + // but need to check here for type check to pass. + if (superscript || subscript) { + // If we got either a superscript or subscript, create a supsub + return { + type: "supsub", + mode: this.mode, + base: base, + sup: superscript, + sub: subscript + }; + } else { + // Otherwise return the original body + return base; + } + } + + /** + * Parses an entire function, including its base and all of its arguments. + */ + parseFunction(breakOnTokenText, name // For determining its context + ) { + const token = this.fetch(); + const func = token.text; + const funcData = src_functions[func]; + if (!funcData) { + return null; + } + this.consume(); // consume command token + + if (name && name !== "atom" && !funcData.allowedInArgument) { + throw new src_ParseError("Got function '" + func + "' with no arguments" + (name ? " as " + name : ""), token); + } else if (this.mode === "text" && !funcData.allowedInText) { + throw new src_ParseError("Can't use function '" + func + "' in text mode", token); + } else if (this.mode === "math" && funcData.allowedInMath === false) { + throw new src_ParseError("Can't use function '" + func + "' in math mode", token); + } + const { + args, + optArgs + } = this.parseArguments(func, funcData); + return this.callFunction(func, args, optArgs, token, breakOnTokenText); + } + + /** + * Call a function handler with a suitable context and arguments. + */ + callFunction(name, args, optArgs, token, breakOnTokenText) { + const context = { + funcName: name, + parser: this, + token, + breakOnTokenText + }; + const func = src_functions[name]; + if (func && func.handler) { + return func.handler(context, args, optArgs); + } else { + throw new src_ParseError("No function handler for " + name); + } + } + + /** + * Parses the arguments of a function or environment + */ + parseArguments(func, + // Should look like "\name" or "\begin{name}". + funcData) { + const totalArgs = funcData.numArgs + funcData.numOptionalArgs; + if (totalArgs === 0) { + return { + args: [], + optArgs: [] + }; + } + const args = []; + const optArgs = []; + for (let i = 0; i < totalArgs; i++) { + let argType = funcData.argTypes && funcData.argTypes[i]; + const isOptional = i < funcData.numOptionalArgs; + if ("primitive" in funcData && funcData.primitive && argType == null || + // \sqrt expands into primitive if optional argument doesn't exist + funcData.type === "sqrt" && i === 1 && optArgs[0] == null) { + argType = "primitive"; + } + const arg = this.parseGroupOfType("argument to '" + func + "'", argType, isOptional); + if (isOptional) { + optArgs.push(arg); + } else if (arg != null) { + args.push(arg); + } else { + // should be unreachable + throw new src_ParseError("Null argument, please report this as a bug"); + } + } + return { + args, + optArgs + }; + } + + /** + * Parses a group when the mode is changing. + */ + parseGroupOfType(name, type, optional) { + switch (type) { + case "color": + return this.parseColorGroup(optional); + case "size": + return this.parseSizeGroup(optional); + case "url": + return this.parseUrlGroup(optional); + case "math": + case "text": + return this.parseArgumentGroup(optional, type); + case "hbox": + { + // hbox argument type wraps the argument in the equivalent of + // \hbox, which is like \text but switching to \textstyle size + // and resetting math font. + const group = this.parseArgumentGroup(optional, "text"); + return group != null ? { + type: "styling", + mode: group.mode, + body: [group], + style: "text", + // simulate \textstyle + resetFont: true + } : null; + } + case "raw": + { + const token = this.parseStringGroup("raw", optional); + return token != null ? { + type: "raw", + mode: "text", + string: token.text + } : null; + } + case "primitive": + { + if (optional) { + throw new src_ParseError("A primitive argument cannot be optional"); + } + const group = this.parseGroup(name); + if (group == null) { + throw new src_ParseError("Expected group as " + name, this.fetch()); + } + return group; + } + case "original": + case null: + case undefined: + return this.parseArgumentGroup(optional); + default: + throw new src_ParseError("Unknown group type as " + name, this.fetch()); + } + } + + /** + * Discard any space tokens, fetching the next non-space token. + */ + consumeSpaces() { + while (this.fetch().text === " ") { + this.consume(); + } + } + + /** + * Parses a group, essentially returning the string formed by the + * brace-enclosed tokens plus some position information. + */ + parseStringGroup(modeName, + // Used to describe the mode in error messages. + optional) { + const argToken = this.gullet.scanArgument(optional); + if (argToken == null) { + return null; + } + let str = ""; + let nextToken; + while ((nextToken = this.fetch()).text !== "EOF") { + str += nextToken.text; + this.consume(); + } + this.consume(); // consume the end of the argument + argToken.text = str; + return argToken; + } + + /** + * Parses a regex-delimited group: the largest sequence of tokens + * whose concatenated strings match `regex`. Returns the string + * formed by the tokens plus some position information. + */ + parseRegexGroup(regex, modeName // Used to describe the mode in error messages. + ) { + const firstToken = this.fetch(); + let lastToken = firstToken; + let str = ""; + let nextToken; + while ((nextToken = this.fetch()).text !== "EOF" && regex.test(str + nextToken.text)) { + lastToken = nextToken; + str += lastToken.text; + this.consume(); + } + if (str === "") { + throw new src_ParseError("Invalid " + modeName + ": '" + firstToken.text + "'", firstToken); + } + return firstToken.range(lastToken, str); + } + + /** + * Parses a color description. + */ + parseColorGroup(optional) { + const res = this.parseStringGroup("color", optional); + if (res == null) { + return null; + } + const match = /^(#[a-f0-9]{3,4}|#[a-f0-9]{6}|#[a-f0-9]{8}|[a-f0-9]{6}|[a-z]+)$/i.exec(res.text); + if (!match) { + throw new src_ParseError("Invalid color: '" + res.text + "'", res); + } + let color = match[0]; + if (/^[0-9a-f]{6}$/i.test(color)) { + // We allow a 6-digit HTML color spec without a leading "#". + // This follows the xcolor package's HTML color model. + // Predefined color names are all missed by this RegEx pattern. + color = "#" + color; + } + return { + type: "color-token", + mode: this.mode, + color + }; + } + + /** + * Parses a size specification, consisting of magnitude and unit. + */ + parseSizeGroup(optional) { + let res; + let isBlank = false; + // don't expand before parseStringGroup + this.gullet.consumeSpaces(); + if (!optional && this.gullet.future().text !== "{") { + res = this.parseRegexGroup(/^[-+]? *(?:$|\d+|\d+\.\d*|\.\d*) *[a-z]{0,2} *$/, "size"); + } else { + res = this.parseStringGroup("size", optional); + } + if (!res) { + return null; + } + if (!optional && res.text.length === 0) { + // Because we've tested for what is !optional, this block won't + // affect \kern, \hspace, etc. It will capture the mandatory arguments + // to \genfrac and \above. + res.text = "0pt"; // Enable \above{} + isBlank = true; // This is here specifically for \genfrac + } + const match = /([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(res.text); + if (!match) { + throw new src_ParseError("Invalid size: '" + res.text + "'", res); + } + const data = { + number: +(match[1] + match[2]), + // sign + magnitude, cast to number + unit: match[3] + }; + if (!validUnit(data)) { + throw new src_ParseError("Invalid unit: '" + data.unit + "'", res); + } + return { + type: "size", + mode: this.mode, + value: data, + isBlank + }; + } + + /** + * Parses an URL, checking escaped letters and allowed protocols, + * and setting the catcode of % as an active character (as in \hyperref). + */ + parseUrlGroup(optional) { + this.gullet.lexer.setCatcode("%", 13); // active character + this.gullet.lexer.setCatcode("~", 12); // other character + const res = this.parseStringGroup("url", optional); + this.gullet.lexer.setCatcode("%", 14); // comment character + this.gullet.lexer.setCatcode("~", 13); // active character + if (res == null) { + return null; + } + // hyperref package allows backslashes alone in href, but doesn't + // generate valid links in such cases; we interpret this as + // "undefined" behaviour, and keep them as-is. Some browser will + // replace backslashes with forward slashes. + const url = res.text.replace(/\\([#$%&~_^{}])/g, '$1'); + return { + type: "url", + mode: this.mode, + url + }; + } + + /** + * Parses an argument with the mode specified. + */ + parseArgumentGroup(optional, mode) { + const argToken = this.gullet.scanArgument(optional); + if (argToken == null) { + return null; + } + const outerMode = this.mode; + if (mode) { + // Switch to specified mode + this.switchMode(mode); + } + this.gullet.beginGroup(); + const expression = this.parseExpression(false, "EOF"); + // TODO: find an alternative way to denote the end + this.expect("EOF"); // expect the end of the argument + this.gullet.endGroup(); + const result = { + type: "ordgroup", + mode: this.mode, + loc: argToken.loc, + body: expression + }; + if (mode) { + // Switch mode back + this.switchMode(outerMode); + } + return result; + } + + /** + * Parses an ordinary group, which is either a single nucleus (like "x") + * or an expression in braces (like "{x+y}") or an implicit group, a group + * that starts at the current position, and ends right before a higher explicit + * group ends, or at EOF. + */ + parseGroup(name, + // For error reporting. + breakOnTokenText) { + const firstToken = this.fetch(); + const text = firstToken.text; + let result; + // Try to parse an open brace or \begingroup + if (text === "{" || text === "\\begingroup") { + this.consume(); + const groupEnd = text === "{" ? "}" : "\\endgroup"; + this.gullet.beginGroup(); + // If we get a brace, parse an expression + const expression = this.parseExpression(false, groupEnd); + const lastToken = this.fetch(); + this.expect(groupEnd); // Check that we got a matching closing brace + this.gullet.endGroup(); + result = { + type: "ordgroup", + mode: this.mode, + loc: SourceLocation.range(firstToken, lastToken), + body: expression, + // A group formed by \begingroup...\endgroup is a semi-simple group + // which doesn't affect spacing in math mode, i.e., is transparent. + // https://tex.stackexchange.com/questions/1930/when-should-one- + // use-begingroup-instead-of-bgroup + semisimple: text === "\\begingroup" || undefined + }; + } else { + // If there exists a function with this name, parse the function. + // Otherwise, just return a nucleus + result = this.parseFunction(breakOnTokenText, name) || this.parseSymbol(); + if (result == null && text[0] === "\\" && !implicitCommands.hasOwnProperty(text)) { + if (this.settings.throwOnError) { + throw new src_ParseError("Undefined control sequence: " + text, firstToken); + } + result = this.formatUnsupportedCmd(text); + this.consume(); + } + } + return result; + } + + /** + * Form ligature-like combinations of characters for text mode. + * This includes inputs like "--", "---", "``" and "''". + * The result will simply replace multiple textord nodes with a single + * character in each value by a single textord node having multiple + * characters in its value. The representation is still ASCII source. + * The group will be modified in place. + */ + formLigatures(group) { + let n = group.length - 1; + for (let i = 0; i < n; ++i) { + const a = group[i]; + if (a.type !== "textord") { + continue; + } + const v = a.text; + const next = group[i + 1]; + if (!next || next.type !== "textord") { + continue; + } + if (v === "-" && next.text === "-") { + const afterNext = group[i + 2]; + if (i + 1 < n && afterNext && afterNext.type === "textord" && afterNext.text === "-") { + group.splice(i, 3, { + type: "textord", + mode: "text", + loc: SourceLocation.range(a, afterNext), + text: "---" + }); + n -= 2; + } else { + group.splice(i, 2, { + type: "textord", + mode: "text", + loc: SourceLocation.range(a, next), + text: "--" + }); + n -= 1; + } + } + if ((v === "'" || v === "`") && next.text === v) { + group.splice(i, 2, { + type: "textord", + mode: "text", + loc: SourceLocation.range(a, next), + text: v + v + }); + n -= 1; + } + } + } + + /** + * Parse a single symbol out of the string. Here, we handle single character + * symbols and special functions like \verb. + */ + parseSymbol() { + const nucleus = this.fetch(); + let text = nucleus.text; + if (/^\\verb[^a-zA-Z]/.test(text)) { + this.consume(); + let arg = text.slice(5); + const star = arg.charAt(0) === "*"; + if (star) { + arg = arg.slice(1); + } + // Lexer's tokenRegex is constructed to always have matching + // first/last characters. + if (arg.length < 2 || arg.charAt(0) !== arg.slice(-1)) { + throw new src_ParseError("\\verb assertion failed --\n please report what input caused this bug"); + } + arg = arg.slice(1, -1); // remove first and last char + + return { + type: "verb", + mode: "text", + body: arg, + star + }; + } + // At this point, we should have a symbol, possibly with accents. + // First expand any accented base symbol according to unicodeSymbols. + if (unicodeSymbols.hasOwnProperty(text[0]) && !src_symbols[this.mode][text[0]]) { + // This behavior is not strict (XeTeX-compatible) in math mode. + if (this.settings.strict && this.mode === "math") { + this.settings.reportNonstrict("unicodeTextInMathMode", "Accented Unicode text character \"" + text[0] + "\" used in " + "math mode", nucleus); + } + text = unicodeSymbols[text[0]] + text.slice(1); + } + // Strip off any combining characters + const match = combiningDiacriticalMarksEndRegex.exec(text); + if (match) { + text = text.substring(0, match.index); + if (text === 'i') { + text = '\u0131'; // dotless i, in math and text mode + } else if (text === 'j') { + text = '\u0237'; // dotless j, in math and text mode + } + } + // Recognize base symbol + let symbol; + if (src_symbols[this.mode][text]) { + if (this.settings.strict && this.mode === 'math' && extraLatin.includes(text)) { + this.settings.reportNonstrict("unicodeTextInMathMode", "Latin-1/Unicode text character \"" + text[0] + "\" used in " + "math mode", nucleus); + } + const group = src_symbols[this.mode][text].group; + const loc = SourceLocation.range(nucleus); + let s; + if (isAtom(group)) { + s = { + type: "atom", + mode: this.mode, + family: group, + loc, + text + }; + } else { + s = { + type: group, + mode: this.mode, + loc, + text + }; + } + symbol = s; + } else if (text.charCodeAt(0) >= 0x80) { + // no symbol for e.g. ^ + if (this.settings.strict) { + if (!supportedCodepoint(text.charCodeAt(0))) { + this.settings.reportNonstrict("unknownSymbol", "Unrecognized Unicode character \"" + text[0] + "\"" + (" (" + text.charCodeAt(0) + ")"), nucleus); + } else if (this.mode === "math") { + this.settings.reportNonstrict("unicodeTextInMathMode", "Unicode text character \"" + text[0] + "\" used in math mode", nucleus); + } + } + // All nonmathematical Unicode characters are rendered as if they + // are in text mode (wrapped in \text) because that's what it + // takes to render them in LaTeX. Setting `mode: this.mode` is + // another natural choice (the user requested math mode), but + // this makes it more difficult for getCharacterMetrics() to + // distinguish Unicode characters without metrics and those for + // which we want to simulate the letter M. + symbol = { + type: "textord", + mode: "text", + loc: SourceLocation.range(nucleus), + text + }; + } else { + return null; // EOF, ^, _, {, }, etc. + } + this.consume(); + // Transform combining characters into accents + if (match) { + for (let i = 0; i < match[0].length; i++) { + const accent = match[0][i]; + if (!unicodeAccents[accent]) { + throw new src_ParseError("Unknown accent ' " + accent + "'", nucleus); + } + const command = unicodeAccents[accent][this.mode] || unicodeAccents[accent].text; + if (!command) { + throw new src_ParseError("Accent " + accent + " unsupported in " + this.mode + " mode", nucleus); + } + symbol = { + type: "accent", + mode: this.mode, + loc: SourceLocation.range(nucleus), + label: command, + isStretchy: false, + isShifty: true, + base: symbol + }; + } + } + return symbol; + } +} +Parser.endOfExpression = new Set(["}", "\\endgroup", "\\end", "\\right", "&"]); +;// ./src/parseTree.ts +/** + * Provides a single function for parsing an expression using a Parser + * TODO(emily): Remove this + */ + + + + +/** + * Parses an expression using a Parser, then returns the parsed result. + */ +const parseTree = function (toParse, settings) { + if (!(typeof toParse === 'string' || toParse instanceof String)) { + throw new TypeError('KaTeX can only parse string typed expression'); + } + const parser = new Parser(toParse, settings); + + // Blank out any \df@tag to avoid spurious "Duplicate \tag" errors + delete parser.gullet.macros.current["\\df@tag"]; + let tree = parser.parse(); + + // Prevent a color definition from persisting between calls to katex.render(). + delete parser.gullet.macros.current["\\current@color"]; + delete parser.gullet.macros.current["\\color"]; + + // If the input used \tag, it will set the \df@tag macro to the tag. + // In this case, we separately parse the tag and wrap the tree. + if (parser.gullet.macros.get("\\df@tag")) { + if (!settings.displayMode) { + throw new src_ParseError("\\tag works only in display equations"); + } + tree = [{ + type: "tag", + mode: "text", + body: tree, + tag: parser.subparse([new Token("\\df@tag")]) + }]; + } + return tree; +}; +/* harmony default export */ var src_parseTree = (parseTree); +;// ./katex.ts +/* eslint no-console:0 */ +/** + * This is the main entry point for KaTeX. Here, we expose functions for + * rendering expressions either to DOM nodes or to markup strings. + * + * We also expose the ParseError class to check if errors thrown from KaTeX are + * errors in the expression, or errors in javascript handling. + */ + + + + + + + + + + + +/** + * Parse and build an expression, and place that expression in the DOM node + * given. + */ +let render = function (expression, baseNode, options) { + baseNode.textContent = ""; + const node = renderToDomTree(expression, options).toNode(); + baseNode.appendChild(node); +}; + +// KaTeX's styles don't work properly in quirks mode. Print out an error, and +// disable rendering. +if (typeof document !== "undefined") { + if (document.compatMode !== "CSS1Compat") { + typeof console !== "undefined" && console.warn("Warning: KaTeX doesn't work in quirks mode. Make sure your " + "website has a suitable doctype."); + render = function () { + throw new src_ParseError("KaTeX doesn't work in quirks mode."); + }; + } +} + +/** + * Parse and build an expression, and return the markup for that. + */ +const renderToString = function (expression, options) { + const markup = renderToDomTree(expression, options).toMarkup(); + return markup; +}; + +/** + * Parse an expression and return the parse tree. + */ +const generateParseTree = function (expression, options) { + const settings = new Settings(options); + return src_parseTree(expression, settings); +}; + +/** + * If the given error is a KaTeX ParseError and options.throwOnError is false, + * renders the invalid LaTeX as a span with hover title giving the KaTeX + * error message. Otherwise, simply throws the error. + */ +const renderError = function (error, expression, options) { + if (options.throwOnError || !(error instanceof src_ParseError)) { + throw error; + } + const node = makeSpan(["katex-error"], [new SymbolNode(expression)]); + node.setAttribute("title", error.toString()); + node.setAttribute("style", "color:" + options.errorColor); + return node; +}; + +/** + * Generates and returns the katex build tree. This is used for advanced + * use cases (like rendering to custom output). + */ +const renderToDomTree = function (expression, options) { + const settings = new Settings(options); + try { + const tree = src_parseTree(expression, settings); + return buildTree(tree, expression, settings); + } catch (error) { + return renderError(error, expression, settings); + } +}; + +/** + * Generates and returns the katex build tree, with just HTML (no MathML). + * This is used for advanced use cases (like rendering to custom output). + */ +const renderToHTMLTree = function (expression, options) { + const settings = new Settings(options); + try { + const tree = src_parseTree(expression, settings); + return buildHTMLTree(tree, expression, settings); + } catch (error) { + return renderError(error, expression, settings); + } +}; +const version = "0.16.47"; +const __domTree = { + Span: Span, + Anchor: Anchor, + SymbolNode: SymbolNode, + SvgNode: SvgNode, + PathNode: PathNode, + LineNode: LineNode +}; + +// ESM exports + + +// CJS exports and ESM default export +/* harmony default export */ var katex = ({ + /** + * Current KaTeX version + */ + version, + /** + * Renders the given LaTeX into an HTML+MathML combination, and adds + * it as a child to the specified DOM node. + */ + render, + /** + * Renders the given LaTeX into an HTML+MathML combination string, + * for sending to the client. + */ + renderToString, + /** + * KaTeX error, usually during parsing. + */ + ParseError: src_ParseError, + /** + * The schema of Settings + */ + SETTINGS_SCHEMA: SETTINGS_SCHEMA, + /** + * Parses the given LaTeX into KaTeX's internal parse tree structure, + * without rendering to HTML or MathML. + * + * NOTE: This method is not currently recommended for public use. + * The internal tree representation is unstable and is very likely + * to change. Use at your own risk. + */ + __parse: generateParseTree, + /** + * Renders the given LaTeX into an HTML+MathML internal DOM tree + * representation, without flattening that representation to a string. + * + * NOTE: This method is not currently recommended for public use. + * The internal tree representation is unstable and is very likely + * to change. Use at your own risk. + */ + __renderToDomTree: renderToDomTree, + /** + * Renders the given LaTeX into an HTML internal DOM tree representation, + * without MathML and without flattening that representation to a string. + * + * NOTE: This method is not currently recommended for public use. + * The internal tree representation is unstable and is very likely + * to change. Use at your own risk. + */ + __renderToHTMLTree: renderToHTMLTree, + /** + * extends internal font metrics object with a new object + * each key in the new object represents a font name + */ + __setFontMetrics: setFontMetrics, + /** + * adds a new symbol to builtin symbols table + */ + __defineSymbol: defineSymbol, + /** + * adds a new function to builtin function list, + * which directly produce parse tree elements + * and have their own html/mathml builders + */ + __defineFunction: defineFunction, + /** + * adds a new macro to builtin macro list + */ + __defineMacro: defineMacro, + /** + * Expose the dom tree node types, which can be useful for type checking nodes. + * + * NOTE: These methods are not currently recommended for public use. + * The internal tree representation is unstable and is very likely + * to change. Use at your own risk. + */ + __domTree +}); +;// ./katex.webpack.js +/** + * This is the webpack entry point for KaTeX. As ECMAScript, flow[1] and jest[2] + * doesn't support CSS modules natively, a separate entry point is used and + * it is not flowtyped. + * + * [1] https://gist.github.com/lambdahands/d19e0da96285b749f0ef + * [2] https://facebook.github.io/jest/docs/en/webpack.html + */ + + +/* harmony default export */ var katex_webpack = (katex); +__webpack_exports__ = __webpack_exports__["default"]; +/******/ return __webpack_exports__; +/******/ })() +; +}); \ No newline at end of file diff --git a/node_modules/react-katex/node_modules/katex/dist/katex.min.css b/node_modules/react-katex/node_modules/katex/dist/katex.min.css new file mode 100644 index 0000000..6cf3198 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/dist/katex.min.css @@ -0,0 +1 @@ +@font-face{font-display:block;font-family:KaTeX_AMS;font-style:normal;font-weight:400;src:url(fonts/KaTeX_AMS-Regular.woff2) format("woff2"),url(fonts/KaTeX_AMS-Regular.woff) format("woff"),url(fonts/KaTeX_AMS-Regular.ttf) format("truetype")}@font-face{font-display:block;font-family:KaTeX_Caligraphic;font-style:normal;font-weight:700;src:url(fonts/KaTeX_Caligraphic-Bold.woff2) format("woff2"),url(fonts/KaTeX_Caligraphic-Bold.woff) format("woff"),url(fonts/KaTeX_Caligraphic-Bold.ttf) format("truetype")}@font-face{font-display:block;font-family:KaTeX_Caligraphic;font-style:normal;font-weight:400;src:url(fonts/KaTeX_Caligraphic-Regular.woff2) format("woff2"),url(fonts/KaTeX_Caligraphic-Regular.woff) format("woff"),url(fonts/KaTeX_Caligraphic-Regular.ttf) format("truetype")}@font-face{font-display:block;font-family:KaTeX_Fraktur;font-style:normal;font-weight:700;src:url(fonts/KaTeX_Fraktur-Bold.woff2) format("woff2"),url(fonts/KaTeX_Fraktur-Bold.woff) format("woff"),url(fonts/KaTeX_Fraktur-Bold.ttf) format("truetype")}@font-face{font-display:block;font-family:KaTeX_Fraktur;font-style:normal;font-weight:400;src:url(fonts/KaTeX_Fraktur-Regular.woff2) format("woff2"),url(fonts/KaTeX_Fraktur-Regular.woff) format("woff"),url(fonts/KaTeX_Fraktur-Regular.ttf) format("truetype")}@font-face{font-display:block;font-family:KaTeX_Main;font-style:normal;font-weight:700;src:url(fonts/KaTeX_Main-Bold.woff2) format("woff2"),url(fonts/KaTeX_Main-Bold.woff) format("woff"),url(fonts/KaTeX_Main-Bold.ttf) format("truetype")}@font-face{font-display:block;font-family:KaTeX_Main;font-style:italic;font-weight:700;src:url(fonts/KaTeX_Main-BoldItalic.woff2) format("woff2"),url(fonts/KaTeX_Main-BoldItalic.woff) format("woff"),url(fonts/KaTeX_Main-BoldItalic.ttf) format("truetype")}@font-face{font-display:block;font-family:KaTeX_Main;font-style:italic;font-weight:400;src:url(fonts/KaTeX_Main-Italic.woff2) format("woff2"),url(fonts/KaTeX_Main-Italic.woff) format("woff"),url(fonts/KaTeX_Main-Italic.ttf) format("truetype")}@font-face{font-display:block;font-family:KaTeX_Main;font-style:normal;font-weight:400;src:url(fonts/KaTeX_Main-Regular.woff2) format("woff2"),url(fonts/KaTeX_Main-Regular.woff) format("woff"),url(fonts/KaTeX_Main-Regular.ttf) format("truetype")}@font-face{font-display:block;font-family:KaTeX_Math;font-style:italic;font-weight:700;src:url(fonts/KaTeX_Math-BoldItalic.woff2) format("woff2"),url(fonts/KaTeX_Math-BoldItalic.woff) format("woff"),url(fonts/KaTeX_Math-BoldItalic.ttf) format("truetype")}@font-face{font-display:block;font-family:KaTeX_Math;font-style:italic;font-weight:400;src:url(fonts/KaTeX_Math-Italic.woff2) format("woff2"),url(fonts/KaTeX_Math-Italic.woff) format("woff"),url(fonts/KaTeX_Math-Italic.ttf) format("truetype")}@font-face{font-display:block;font-family:"KaTeX_SansSerif";font-style:normal;font-weight:700;src:url(fonts/KaTeX_SansSerif-Bold.woff2) format("woff2"),url(fonts/KaTeX_SansSerif-Bold.woff) format("woff"),url(fonts/KaTeX_SansSerif-Bold.ttf) format("truetype")}@font-face{font-display:block;font-family:"KaTeX_SansSerif";font-style:italic;font-weight:400;src:url(fonts/KaTeX_SansSerif-Italic.woff2) format("woff2"),url(fonts/KaTeX_SansSerif-Italic.woff) format("woff"),url(fonts/KaTeX_SansSerif-Italic.ttf) format("truetype")}@font-face{font-display:block;font-family:"KaTeX_SansSerif";font-style:normal;font-weight:400;src:url(fonts/KaTeX_SansSerif-Regular.woff2) format("woff2"),url(fonts/KaTeX_SansSerif-Regular.woff) format("woff"),url(fonts/KaTeX_SansSerif-Regular.ttf) format("truetype")}@font-face{font-display:block;font-family:KaTeX_Script;font-style:normal;font-weight:400;src:url(fonts/KaTeX_Script-Regular.woff2) format("woff2"),url(fonts/KaTeX_Script-Regular.woff) format("woff"),url(fonts/KaTeX_Script-Regular.ttf) format("truetype")}@font-face{font-display:block;font-family:KaTeX_Size1;font-style:normal;font-weight:400;src:url(fonts/KaTeX_Size1-Regular.woff2) format("woff2"),url(fonts/KaTeX_Size1-Regular.woff) format("woff"),url(fonts/KaTeX_Size1-Regular.ttf) format("truetype")}@font-face{font-display:block;font-family:KaTeX_Size2;font-style:normal;font-weight:400;src:url(fonts/KaTeX_Size2-Regular.woff2) format("woff2"),url(fonts/KaTeX_Size2-Regular.woff) format("woff"),url(fonts/KaTeX_Size2-Regular.ttf) format("truetype")}@font-face{font-display:block;font-family:KaTeX_Size3;font-style:normal;font-weight:400;src:url(fonts/KaTeX_Size3-Regular.woff2) format("woff2"),url(fonts/KaTeX_Size3-Regular.woff) format("woff"),url(fonts/KaTeX_Size3-Regular.ttf) format("truetype")}@font-face{font-display:block;font-family:KaTeX_Size4;font-style:normal;font-weight:400;src:url(fonts/KaTeX_Size4-Regular.woff2) format("woff2"),url(fonts/KaTeX_Size4-Regular.woff) format("woff"),url(fonts/KaTeX_Size4-Regular.ttf) format("truetype")}@font-face{font-display:block;font-family:KaTeX_Typewriter;font-style:normal;font-weight:400;src:url(fonts/KaTeX_Typewriter-Regular.woff2) format("woff2"),url(fonts/KaTeX_Typewriter-Regular.woff) format("woff"),url(fonts/KaTeX_Typewriter-Regular.ttf) format("truetype")}.katex{font:normal 1.21em KaTeX_Main,Times New Roman,serif;line-height:1.2;position:relative;text-indent:0;text-rendering:auto}.katex *{-ms-high-contrast-adjust:none!important;border-color:currentColor}.katex .katex-version:after{content:"0.16.47"}.katex .katex-mathml{border:0;-webkit-clip-path:inset(50%);clip-path:inset(50%);height:1px;overflow:hidden;padding:0;position:absolute;width:1px}.katex .katex-html>.newline{display:block}.katex .base{position:relative;white-space:nowrap;width:-webkit-min-content;width:-moz-min-content;width:min-content}.katex .base,.katex .strut{display:inline-block}.katex .textbf{font-weight:700}.katex .textit{font-style:italic}.katex .textrm{font-family:KaTeX_Main}.katex .textsf{font-family:KaTeX_SansSerif}.katex .texttt{font-family:KaTeX_Typewriter}.katex .mathnormal{font-family:KaTeX_Math;font-style:italic}.katex .mathit{font-family:KaTeX_Main;font-style:italic}.katex .mathrm{font-style:normal}.katex .mathbf{font-family:KaTeX_Main;font-weight:700}.katex .boldsymbol{font-family:KaTeX_Math;font-style:italic;font-weight:700}.katex .amsrm,.katex .mathbb,.katex .textbb{font-family:KaTeX_AMS}.katex .mathcal{font-family:KaTeX_Caligraphic}.katex .mathfrak,.katex .textfrak{font-family:KaTeX_Fraktur}.katex .mathboldfrak,.katex .textboldfrak{font-family:KaTeX_Fraktur;font-weight:700}.katex .mathtt{font-family:KaTeX_Typewriter}.katex .mathscr,.katex .textscr{font-family:KaTeX_Script}.katex .mathsf,.katex .textsf{font-family:KaTeX_SansSerif}.katex .mathboldsf,.katex .textboldsf{font-family:KaTeX_SansSerif;font-weight:700}.katex .mathitsf,.katex .mathsfit,.katex .textitsf{font-family:KaTeX_SansSerif;font-style:italic}.katex .mainrm{font-family:KaTeX_Main;font-style:normal}.katex .vlist-t{border-collapse:collapse;display:inline-table;table-layout:fixed}.katex .vlist-r{display:table-row}.katex .vlist{display:table-cell;position:relative;vertical-align:bottom}.katex .vlist>span{display:block;height:0;position:relative}.katex .vlist>span>span{display:inline-block}.katex .vlist>span>.pstrut{overflow:hidden;width:0}.katex .vlist-t2{margin-right:-2px}.katex .vlist-s{display:table-cell;font-size:1px;min-width:2px;vertical-align:bottom;width:2px}.katex .vbox{align-items:baseline;display:inline-flex;flex-direction:column}.katex .hbox{width:100%}.katex .hbox,.katex .thinbox{display:inline-flex;flex-direction:row}.katex .thinbox{max-width:0;width:0}.katex .msupsub{text-align:left}.katex .mfrac>span>span{text-align:center}.katex .mfrac .frac-line{border-bottom-style:solid;display:inline-block;width:100%}.katex .hdashline,.katex .hline,.katex .mfrac .frac-line,.katex .overline .overline-line,.katex .rule,.katex .underline .underline-line{min-height:1px}.katex .mspace{display:inline-block}.katex .smash{display:inline;line-height:0}.katex .clap,.katex .llap,.katex .rlap{position:relative;width:0}.katex .clap>.inner,.katex .llap>.inner,.katex .rlap>.inner{position:absolute}.katex .clap>.fix,.katex .llap>.fix,.katex .rlap>.fix{display:inline-block}.katex .llap>.inner{right:0}.katex .clap>.inner,.katex .rlap>.inner{left:0}.katex .clap>.inner>span{margin-left:-50%;margin-right:50%}.katex .rule{border:0 solid;display:inline-block;position:relative}.katex .hline,.katex .overline .overline-line,.katex .underline .underline-line{border-bottom-style:solid;display:inline-block;width:100%}.katex .hdashline{border-bottom-style:dashed;display:inline-block;width:100%}.katex .sqrt>.root{margin-left:.2777777778em;margin-right:-.5555555556em}.katex .fontsize-ensurer.reset-size1.size1,.katex .sizing.reset-size1.size1{font-size:1em}.katex .fontsize-ensurer.reset-size1.size2,.katex .sizing.reset-size1.size2{font-size:1.2em}.katex .fontsize-ensurer.reset-size1.size3,.katex .sizing.reset-size1.size3{font-size:1.4em}.katex .fontsize-ensurer.reset-size1.size4,.katex .sizing.reset-size1.size4{font-size:1.6em}.katex .fontsize-ensurer.reset-size1.size5,.katex .sizing.reset-size1.size5{font-size:1.8em}.katex .fontsize-ensurer.reset-size1.size6,.katex .sizing.reset-size1.size6{font-size:2em}.katex .fontsize-ensurer.reset-size1.size7,.katex .sizing.reset-size1.size7{font-size:2.4em}.katex .fontsize-ensurer.reset-size1.size8,.katex .sizing.reset-size1.size8{font-size:2.88em}.katex .fontsize-ensurer.reset-size1.size9,.katex .sizing.reset-size1.size9{font-size:3.456em}.katex .fontsize-ensurer.reset-size1.size10,.katex .sizing.reset-size1.size10{font-size:4.148em}.katex .fontsize-ensurer.reset-size1.size11,.katex .sizing.reset-size1.size11{font-size:4.976em}.katex .fontsize-ensurer.reset-size2.size1,.katex .sizing.reset-size2.size1{font-size:.8333333333em}.katex .fontsize-ensurer.reset-size2.size2,.katex .sizing.reset-size2.size2{font-size:1em}.katex .fontsize-ensurer.reset-size2.size3,.katex .sizing.reset-size2.size3{font-size:1.1666666667em}.katex .fontsize-ensurer.reset-size2.size4,.katex .sizing.reset-size2.size4{font-size:1.3333333333em}.katex .fontsize-ensurer.reset-size2.size5,.katex .sizing.reset-size2.size5{font-size:1.5em}.katex .fontsize-ensurer.reset-size2.size6,.katex .sizing.reset-size2.size6{font-size:1.6666666667em}.katex .fontsize-ensurer.reset-size2.size7,.katex .sizing.reset-size2.size7{font-size:2em}.katex .fontsize-ensurer.reset-size2.size8,.katex .sizing.reset-size2.size8{font-size:2.4em}.katex .fontsize-ensurer.reset-size2.size9,.katex .sizing.reset-size2.size9{font-size:2.88em}.katex .fontsize-ensurer.reset-size2.size10,.katex .sizing.reset-size2.size10{font-size:3.4566666667em}.katex .fontsize-ensurer.reset-size2.size11,.katex .sizing.reset-size2.size11{font-size:4.1466666667em}.katex .fontsize-ensurer.reset-size3.size1,.katex .sizing.reset-size3.size1{font-size:.7142857143em}.katex .fontsize-ensurer.reset-size3.size2,.katex .sizing.reset-size3.size2{font-size:.8571428571em}.katex .fontsize-ensurer.reset-size3.size3,.katex .sizing.reset-size3.size3{font-size:1em}.katex .fontsize-ensurer.reset-size3.size4,.katex .sizing.reset-size3.size4{font-size:1.1428571429em}.katex .fontsize-ensurer.reset-size3.size5,.katex .sizing.reset-size3.size5{font-size:1.2857142857em}.katex .fontsize-ensurer.reset-size3.size6,.katex .sizing.reset-size3.size6{font-size:1.4285714286em}.katex .fontsize-ensurer.reset-size3.size7,.katex .sizing.reset-size3.size7{font-size:1.7142857143em}.katex .fontsize-ensurer.reset-size3.size8,.katex .sizing.reset-size3.size8{font-size:2.0571428571em}.katex .fontsize-ensurer.reset-size3.size9,.katex .sizing.reset-size3.size9{font-size:2.4685714286em}.katex .fontsize-ensurer.reset-size3.size10,.katex .sizing.reset-size3.size10{font-size:2.9628571429em}.katex .fontsize-ensurer.reset-size3.size11,.katex .sizing.reset-size3.size11{font-size:3.5542857143em}.katex .fontsize-ensurer.reset-size4.size1,.katex .sizing.reset-size4.size1{font-size:.625em}.katex .fontsize-ensurer.reset-size4.size2,.katex .sizing.reset-size4.size2{font-size:.75em}.katex .fontsize-ensurer.reset-size4.size3,.katex .sizing.reset-size4.size3{font-size:.875em}.katex .fontsize-ensurer.reset-size4.size4,.katex .sizing.reset-size4.size4{font-size:1em}.katex .fontsize-ensurer.reset-size4.size5,.katex .sizing.reset-size4.size5{font-size:1.125em}.katex .fontsize-ensurer.reset-size4.size6,.katex .sizing.reset-size4.size6{font-size:1.25em}.katex .fontsize-ensurer.reset-size4.size7,.katex .sizing.reset-size4.size7{font-size:1.5em}.katex .fontsize-ensurer.reset-size4.size8,.katex .sizing.reset-size4.size8{font-size:1.8em}.katex .fontsize-ensurer.reset-size4.size9,.katex .sizing.reset-size4.size9{font-size:2.16em}.katex .fontsize-ensurer.reset-size4.size10,.katex .sizing.reset-size4.size10{font-size:2.5925em}.katex .fontsize-ensurer.reset-size4.size11,.katex .sizing.reset-size4.size11{font-size:3.11em}.katex .fontsize-ensurer.reset-size5.size1,.katex .sizing.reset-size5.size1{font-size:.5555555556em}.katex .fontsize-ensurer.reset-size5.size2,.katex .sizing.reset-size5.size2{font-size:.6666666667em}.katex .fontsize-ensurer.reset-size5.size3,.katex .sizing.reset-size5.size3{font-size:.7777777778em}.katex .fontsize-ensurer.reset-size5.size4,.katex .sizing.reset-size5.size4{font-size:.8888888889em}.katex .fontsize-ensurer.reset-size5.size5,.katex .sizing.reset-size5.size5{font-size:1em}.katex .fontsize-ensurer.reset-size5.size6,.katex .sizing.reset-size5.size6{font-size:1.1111111111em}.katex .fontsize-ensurer.reset-size5.size7,.katex .sizing.reset-size5.size7{font-size:1.3333333333em}.katex .fontsize-ensurer.reset-size5.size8,.katex .sizing.reset-size5.size8{font-size:1.6em}.katex .fontsize-ensurer.reset-size5.size9,.katex .sizing.reset-size5.size9{font-size:1.92em}.katex .fontsize-ensurer.reset-size5.size10,.katex .sizing.reset-size5.size10{font-size:2.3044444444em}.katex .fontsize-ensurer.reset-size5.size11,.katex .sizing.reset-size5.size11{font-size:2.7644444444em}.katex .fontsize-ensurer.reset-size6.size1,.katex .sizing.reset-size6.size1{font-size:.5em}.katex .fontsize-ensurer.reset-size6.size2,.katex .sizing.reset-size6.size2{font-size:.6em}.katex .fontsize-ensurer.reset-size6.size3,.katex .sizing.reset-size6.size3{font-size:.7em}.katex .fontsize-ensurer.reset-size6.size4,.katex .sizing.reset-size6.size4{font-size:.8em}.katex .fontsize-ensurer.reset-size6.size5,.katex .sizing.reset-size6.size5{font-size:.9em}.katex .fontsize-ensurer.reset-size6.size6,.katex .sizing.reset-size6.size6{font-size:1em}.katex .fontsize-ensurer.reset-size6.size7,.katex .sizing.reset-size6.size7{font-size:1.2em}.katex .fontsize-ensurer.reset-size6.size8,.katex .sizing.reset-size6.size8{font-size:1.44em}.katex .fontsize-ensurer.reset-size6.size9,.katex .sizing.reset-size6.size9{font-size:1.728em}.katex .fontsize-ensurer.reset-size6.size10,.katex .sizing.reset-size6.size10{font-size:2.074em}.katex .fontsize-ensurer.reset-size6.size11,.katex .sizing.reset-size6.size11{font-size:2.488em}.katex .fontsize-ensurer.reset-size7.size1,.katex .sizing.reset-size7.size1{font-size:.4166666667em}.katex .fontsize-ensurer.reset-size7.size2,.katex .sizing.reset-size7.size2{font-size:.5em}.katex .fontsize-ensurer.reset-size7.size3,.katex .sizing.reset-size7.size3{font-size:.5833333333em}.katex .fontsize-ensurer.reset-size7.size4,.katex .sizing.reset-size7.size4{font-size:.6666666667em}.katex .fontsize-ensurer.reset-size7.size5,.katex .sizing.reset-size7.size5{font-size:.75em}.katex .fontsize-ensurer.reset-size7.size6,.katex .sizing.reset-size7.size6{font-size:.8333333333em}.katex .fontsize-ensurer.reset-size7.size7,.katex .sizing.reset-size7.size7{font-size:1em}.katex .fontsize-ensurer.reset-size7.size8,.katex .sizing.reset-size7.size8{font-size:1.2em}.katex .fontsize-ensurer.reset-size7.size9,.katex .sizing.reset-size7.size9{font-size:1.44em}.katex .fontsize-ensurer.reset-size7.size10,.katex .sizing.reset-size7.size10{font-size:1.7283333333em}.katex .fontsize-ensurer.reset-size7.size11,.katex .sizing.reset-size7.size11{font-size:2.0733333333em}.katex .fontsize-ensurer.reset-size8.size1,.katex .sizing.reset-size8.size1{font-size:.3472222222em}.katex .fontsize-ensurer.reset-size8.size2,.katex .sizing.reset-size8.size2{font-size:.4166666667em}.katex .fontsize-ensurer.reset-size8.size3,.katex .sizing.reset-size8.size3{font-size:.4861111111em}.katex .fontsize-ensurer.reset-size8.size4,.katex .sizing.reset-size8.size4{font-size:.5555555556em}.katex .fontsize-ensurer.reset-size8.size5,.katex .sizing.reset-size8.size5{font-size:.625em}.katex .fontsize-ensurer.reset-size8.size6,.katex .sizing.reset-size8.size6{font-size:.6944444444em}.katex .fontsize-ensurer.reset-size8.size7,.katex .sizing.reset-size8.size7{font-size:.8333333333em}.katex .fontsize-ensurer.reset-size8.size8,.katex .sizing.reset-size8.size8{font-size:1em}.katex .fontsize-ensurer.reset-size8.size9,.katex .sizing.reset-size8.size9{font-size:1.2em}.katex .fontsize-ensurer.reset-size8.size10,.katex .sizing.reset-size8.size10{font-size:1.4402777778em}.katex .fontsize-ensurer.reset-size8.size11,.katex .sizing.reset-size8.size11{font-size:1.7277777778em}.katex .fontsize-ensurer.reset-size9.size1,.katex .sizing.reset-size9.size1{font-size:.2893518519em}.katex .fontsize-ensurer.reset-size9.size2,.katex .sizing.reset-size9.size2{font-size:.3472222222em}.katex .fontsize-ensurer.reset-size9.size3,.katex .sizing.reset-size9.size3{font-size:.4050925926em}.katex .fontsize-ensurer.reset-size9.size4,.katex .sizing.reset-size9.size4{font-size:.462962963em}.katex .fontsize-ensurer.reset-size9.size5,.katex .sizing.reset-size9.size5{font-size:.5208333333em}.katex .fontsize-ensurer.reset-size9.size6,.katex .sizing.reset-size9.size6{font-size:.5787037037em}.katex .fontsize-ensurer.reset-size9.size7,.katex .sizing.reset-size9.size7{font-size:.6944444444em}.katex .fontsize-ensurer.reset-size9.size8,.katex .sizing.reset-size9.size8{font-size:.8333333333em}.katex .fontsize-ensurer.reset-size9.size9,.katex .sizing.reset-size9.size9{font-size:1em}.katex .fontsize-ensurer.reset-size9.size10,.katex .sizing.reset-size9.size10{font-size:1.2002314815em}.katex .fontsize-ensurer.reset-size9.size11,.katex .sizing.reset-size9.size11{font-size:1.4398148148em}.katex .fontsize-ensurer.reset-size10.size1,.katex .sizing.reset-size10.size1{font-size:.2410800386em}.katex .fontsize-ensurer.reset-size10.size2,.katex .sizing.reset-size10.size2{font-size:.2892960463em}.katex .fontsize-ensurer.reset-size10.size3,.katex .sizing.reset-size10.size3{font-size:.337512054em}.katex .fontsize-ensurer.reset-size10.size4,.katex .sizing.reset-size10.size4{font-size:.3857280617em}.katex .fontsize-ensurer.reset-size10.size5,.katex .sizing.reset-size10.size5{font-size:.4339440694em}.katex .fontsize-ensurer.reset-size10.size6,.katex .sizing.reset-size10.size6{font-size:.4821600771em}.katex .fontsize-ensurer.reset-size10.size7,.katex .sizing.reset-size10.size7{font-size:.5785920926em}.katex .fontsize-ensurer.reset-size10.size8,.katex .sizing.reset-size10.size8{font-size:.6943105111em}.katex .fontsize-ensurer.reset-size10.size9,.katex .sizing.reset-size10.size9{font-size:.8331726133em}.katex .fontsize-ensurer.reset-size10.size10,.katex .sizing.reset-size10.size10{font-size:1em}.katex .fontsize-ensurer.reset-size10.size11,.katex .sizing.reset-size10.size11{font-size:1.1996142719em}.katex .fontsize-ensurer.reset-size11.size1,.katex .sizing.reset-size11.size1{font-size:.2009646302em}.katex .fontsize-ensurer.reset-size11.size2,.katex .sizing.reset-size11.size2{font-size:.2411575563em}.katex .fontsize-ensurer.reset-size11.size3,.katex .sizing.reset-size11.size3{font-size:.2813504823em}.katex .fontsize-ensurer.reset-size11.size4,.katex .sizing.reset-size11.size4{font-size:.3215434084em}.katex .fontsize-ensurer.reset-size11.size5,.katex .sizing.reset-size11.size5{font-size:.3617363344em}.katex .fontsize-ensurer.reset-size11.size6,.katex .sizing.reset-size11.size6{font-size:.4019292605em}.katex .fontsize-ensurer.reset-size11.size7,.katex .sizing.reset-size11.size7{font-size:.4823151125em}.katex .fontsize-ensurer.reset-size11.size8,.katex .sizing.reset-size11.size8{font-size:.578778135em}.katex .fontsize-ensurer.reset-size11.size9,.katex .sizing.reset-size11.size9{font-size:.6945337621em}.katex .fontsize-ensurer.reset-size11.size10,.katex .sizing.reset-size11.size10{font-size:.8336012862em}.katex .fontsize-ensurer.reset-size11.size11,.katex .sizing.reset-size11.size11{font-size:1em}.katex .delimsizing.size1{font-family:KaTeX_Size1}.katex .delimsizing.size2{font-family:KaTeX_Size2}.katex .delimsizing.size3{font-family:KaTeX_Size3}.katex .delimsizing.size4{font-family:KaTeX_Size4}.katex .delimsizing.mult .delim-size1>span{font-family:KaTeX_Size1}.katex .delimsizing.mult .delim-size4>span{font-family:KaTeX_Size4}.katex .nulldelimiter{display:inline-block;width:.12em}.katex .delimcenter,.katex .op-symbol{position:relative}.katex .op-symbol.small-op{font-family:KaTeX_Size1}.katex .op-symbol.large-op{font-family:KaTeX_Size2}.katex .accent>.vlist-t,.katex .op-limits>.vlist-t{text-align:center}.katex .accent .accent-body{position:relative}.katex .accent .accent-body:not(.accent-full){width:0}.katex .overlay{display:block}.katex .mtable .vertical-separator{display:inline-block;min-width:1px}.katex .mtable .arraycolsep{display:inline-block}.katex .mtable .col-align-c>.vlist-t{text-align:center}.katex .mtable .col-align-l>.vlist-t{text-align:left}.katex .mtable .col-align-r>.vlist-t{text-align:right}.katex .svg-align{text-align:left}.katex svg{fill:currentColor;stroke:currentColor;display:block;height:inherit;position:absolute;width:100%}.katex svg path{stroke:none}.katex svg{fill-rule:nonzero;fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1}.katex img{border-style:none;max-height:none;max-width:none;min-height:0;min-width:0}.katex .stretchy{display:block;overflow:hidden;position:relative;width:100%}.katex .stretchy:after,.katex .stretchy:before{content:""}.katex .hide-tail{overflow:hidden;position:relative;width:100%}.katex .halfarrow-left{left:0;overflow:hidden;position:absolute;width:50.2%}.katex .halfarrow-right{overflow:hidden;position:absolute;right:0;width:50.2%}.katex .brace-left{left:0;overflow:hidden;position:absolute;width:25.1%}.katex .brace-center{left:25%;overflow:hidden;position:absolute;width:50%}.katex .brace-right{overflow:hidden;position:absolute;right:0;width:25.1%}.katex .x-arrow-pad{padding:0 .5em}.katex .cd-arrow-pad{padding:0 .55556em 0 .27778em}.katex .mover,.katex .munder,.katex .x-arrow{text-align:center}.katex .boxpad{padding:0 .3em}.katex .fbox,.katex .fcolorbox{border:.04em solid;box-sizing:border-box}.katex .cancel-pad{padding:0 .2em}.katex .cancel-lap{margin-left:-.2em;margin-right:-.2em}.katex .sout{border-bottom-style:solid;border-bottom-width:.08em}.katex .angl{border-right:.049em solid;border-top:.049em solid;box-sizing:border-box;margin-right:.03889em}.katex .anglpad{padding:0 .03889em}.katex .eqn-num:before{content:"(" counter(katexEqnNo) ")";counter-increment:katexEqnNo}.katex .mml-eqn-num:before{content:"(" counter(mmlEqnNo) ")";counter-increment:mmlEqnNo}.katex .mtr-glue{width:50%}.katex .cd-vert-arrow{display:inline-block;position:relative}.katex .cd-label-left{display:inline-block;position:absolute;right:calc(50% + .3em);text-align:left}.katex .cd-label-right{display:inline-block;left:calc(50% + .3em);position:absolute;text-align:right}.katex-display{display:block;margin:1em 0;text-align:center}.katex-display>.katex{display:block;text-align:center;white-space:nowrap}.katex-display>.katex>.katex-html{display:block;position:relative}.katex-display>.katex>.katex-html>.tag{position:absolute;right:0}.katex-display.leqno>.katex>.katex-html>.tag{left:0;right:auto}.katex-display.fleqn>.katex{padding-left:2em;text-align:left}body{counter-reset:katexEqnNo mmlEqnNo} diff --git a/node_modules/react-katex/node_modules/katex/dist/katex.min.js b/node_modules/react-katex/node_modules/katex/dist/katex.min.js new file mode 100644 index 0000000..a638f46 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/dist/katex.min.js @@ -0,0 +1 @@ +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.katex=t():e.katex=t()}("undefined"!=typeof self?self:this,function(){return function(){"use strict";var e={d:function(t,r){for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}},t={};e.d(t,{default:function(){return ko}});class r extends Error{constructor(e,t){let n,o,s="KaTeX parse error: "+e;const i=t&&t.loc;if(i&&i.start<=i.end){const e=i.lexer.input;n=i.start,o=i.end,n===e.length?s+=" at end of input: ":s+=" at position "+(n+1)+": ";const t=e.slice(n,o).replace(/[^]/g,"$&\u0332");let r,l;r=n>15?"\u2026"+e.slice(n-15,n):e.slice(0,n),l=o+15e.replace(o,"-$1").toLowerCase(),i={"&":"&",">":">","<":"<",'"':""","'":"'"},l=/[&><"']/g,a=e=>String(e).replace(l,e=>i[e]),c=e=>"ordgroup"===e.type||"color"===e.type?1===e.body.length?c(e.body[0]):e:"font"===e.type?c(e.body):e,h=new Set(["mathord","textord","atom"]),m=e=>h.has(c(e).type),u={displayMode:{type:"boolean",description:"Render math in display mode, which puts the math in display style (so \\int and \\sum are large, for example), and centers the math on the page on its own line.",cli:"-d, --display-mode"},output:{type:{enum:["htmlAndMathml","html","mathml"]},description:"Determines the markup language of the output.",cli:"-F, --format "},leqno:{type:"boolean",description:"Render display math in leqno style (left-justified tags)."},fleqn:{type:"boolean",description:"Render display math flush left."},throwOnError:{type:"boolean",default:!0,cli:"-t, --no-throw-on-error",cliDescription:"Render errors (in the color given by --error-color) instead of throwing a ParseError exception when encountering an error."},errorColor:{type:"string",default:"#cc0000",cli:"-c, --error-color ",cliDescription:"A color string given in the format 'rgb' or 'rrggbb' (no #). This option determines the color of errors rendered by the -t option.",cliProcessor:e=>"#"+e},macros:{type:"object",cli:"-m, --macro ",cliDescription:"Define custom macro of the form '\\foo:expansion' (use multiple -m arguments for multiple macros).",cliDefault:[],cliProcessor:(e,t)=>(t.push(e),t)},minRuleThickness:{type:"number",description:"Specifies a minimum thickness, in ems, for fraction lines, `\\sqrt` top lines, `{array}` vertical lines, `\\hline`, `\\hdashline`, `\\underline`, `\\overline`, and the borders of `\\fbox`, `\\boxed`, and `\\fcolorbox`.",processor:e=>Math.max(0,e),cli:"--min-rule-thickness ",cliProcessor:parseFloat},colorIsTextColor:{type:"boolean",description:"Makes \\color behave like LaTeX's 2-argument \\textcolor, instead of LaTeX's one-argument \\color mode change.",cli:"-b, --color-is-text-color"},strict:{type:[{enum:["warn","ignore","error"]},"boolean","function"],description:"Turn on strict / LaTeX faithfulness mode, which throws an error if the input uses features that are not supported by LaTeX.",cli:"-S, --strict",cliDefault:!1},trust:{type:["boolean","function"],description:"Trust the input, enabling all HTML features such as \\url.",cli:"-T, --trust"},maxSize:{type:"number",default:1/0,description:"If non-zero, all user-specified sizes, e.g. in \\rule{500em}{500em}, will be capped to maxSize ems. Otherwise, elements and spaces can be arbitrarily large",processor:e=>Math.max(0,e),cli:"-s, --max-size ",cliProcessor:parseInt},maxExpand:{type:"number",default:1e3,description:"Limit the number of macro expansions to the specified number, to prevent e.g. infinite macro loops. If set to Infinity, the macro expander will try to fully expand as in LaTeX.",processor:e=>Math.max(0,e),cli:"-e, --max-expand ",cliProcessor:e=>"Infinity"===e?1/0:parseInt(e)},globalGroup:{type:"boolean",cli:!1}};function p(e){if(void 0!==e.default)return e.default;return function(e){if("string"!=typeof e)return e.enum[0];switch(e){case"boolean":return!1;case"string":return"";case"number":return 0;case"object":return{};default:throw new Error("Unexpected schema type; settings must declare an explicit default.")}}(Array.isArray(e.type)?e.type[0]:e.type)}function d(e,t,r,n){const o=r[t];e[t]=void 0!==o?n.processor?n.processor(o):o:p(n)}class g{constructor(e){void 0===e&&(e={}),this.displayMode=void 0,this.output=void 0,this.leqno=void 0,this.fleqn=void 0,this.throwOnError=void 0,this.errorColor=void 0,this.macros=void 0,this.minRuleThickness=void 0,this.colorIsTextColor=void 0,this.strict=void 0,this.trust=void 0,this.maxSize=void 0,this.maxExpand=void 0,this.globalGroup=void 0,e=e||{};for(const t of Object.keys(u)){const r=u[t];r&&d(this,t,e,r)}}reportNonstrict(e,t,r){let o=this.strict;if("function"==typeof o&&(o=o(e,t,r)),o&&"ignore"!==o){if(!0===o||"error"===o)throw new n("LaTeX-incompatible input and strict mode is set to 'error': "+t+" ["+e+"]",r);"warn"===o?"undefined"!=typeof console&&console.warn("LaTeX-incompatible input and strict mode is set to 'warn': "+t+" ["+e+"]"):"undefined"!=typeof console&&console.warn("LaTeX-incompatible input and strict mode is set to unrecognized '"+o+"': "+t+" ["+e+"]")}}useStrictBehavior(e,t,r){let n=this.strict;if("function"==typeof n)try{n=n(e,t,r)}catch(e){n="error"}return!(!n||"ignore"===n)&&(!0===n||"error"===n||("warn"===n?("undefined"!=typeof console&&console.warn("LaTeX-incompatible input and strict mode is set to 'warn': "+t+" ["+e+"]"),!1):("undefined"!=typeof console&&console.warn("LaTeX-incompatible input and strict mode is set to unrecognized '"+n+"': "+t+" ["+e+"]"),!1)))}isTrusted(e){if("url"in e&&e.url&&!e.protocol){const t=(e=>{const t=/^[\x00-\x20]*([^\\/#?]*?)(:|�*58|�*3a|&colon)/i.exec(e);return t?":"!==t[2]?null:/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(t[1])?t[1].toLowerCase():null:"_relative"})(e.url);if(null==t)return!1;e.protocol=t}const t="function"==typeof this.trust?this.trust(e):this.trust;return Boolean(t)}}class f{constructor(e,t,r){this.id=void 0,this.size=void 0,this.cramped=void 0,this.id=e,this.size=t,this.cramped=r}sup(){return b[y[this.id]]}sub(){return b[x[this.id]]}fracNum(){return b[w[this.id]]}fracDen(){return b[v[this.id]]}cramp(){return b[k[this.id]]}text(){return b[z[this.id]]}isTight(){return this.size>=2}}const b=[new f(0,0,!1),new f(1,0,!0),new f(2,1,!1),new f(3,1,!0),new f(4,2,!1),new f(5,2,!0),new f(6,3,!1),new f(7,3,!0)],y=[4,5,4,5,6,7,6,7],x=[5,5,5,5,7,7,7,7],w=[2,3,4,5,6,7,6,7],v=[3,3,5,5,7,7,7,7],k=[1,1,3,3,5,5,7,7],z=[0,1,2,3,2,3,2,3];var S={DISPLAY:b[0],TEXT:b[2],SCRIPT:b[4],SCRIPTSCRIPT:b[6]};const M=[{name:"latin",blocks:[[256,591],[768,879]]},{name:"cyrillic",blocks:[[1024,1279]]},{name:"armenian",blocks:[[1328,1423]]},{name:"brahmic",blocks:[[2304,4255]]},{name:"georgian",blocks:[[4256,4351]]},{name:"cjk",blocks:[[12288,12543],[19968,40879],[65280,65376]]},{name:"hangul",blocks:[[44032,55215]]}];const A=[];function T(e){for(let t=0;t=A[t]&&e<=A[t+1])return!0;return!1}M.forEach(e=>e.blocks.forEach(e=>A.push(...e)));const B=e=>e+" "+e,C=80,q={doubleleftarrow:"M262 157\nl10-10c34-36 62.7-77 86-123 3.3-8 5-13.3 5-16 0-5.3-6.7-8-20-8-7.3\n 0-12.2.5-14.5 1.5-2.3 1-4.8 4.5-7.5 10.5-49.3 97.3-121.7 169.3-217 216-28\n 14-57.3 25-88 33-6.7 2-11 3.8-13 5.5-2 1.7-3 4.2-3 7.5s1 5.8 3 7.5\nc2 1.7 6.3 3.5 13 5.5 68 17.3 128.2 47.8 180.5 91.5 52.3 43.7 93.8 96.2 124.5\n 157.5 9.3 8 15.3 12.3 18 13h6c12-.7 18-4 18-10 0-2-1.7-7-5-15-23.3-46-52-87\n-86-123l-10-10h399738v-40H218c328 0 0 0 0 0l-10-8c-26.7-20-65.7-43-117-69 2.7\n-2 6-3.7 10-5 36.7-16 72.3-37.3 107-64l10-8h399782v-40z\nm8 0v40h399730v-40zm0 194v40h399730v-40z",doublerightarrow:"M399738 392l\n-10 10c-34 36-62.7 77-86 123-3.3 8-5 13.3-5 16 0 5.3 6.7 8 20 8 7.3 0 12.2-.5\n 14.5-1.5 2.3-1 4.8-4.5 7.5-10.5 49.3-97.3 121.7-169.3 217-216 28-14 57.3-25 88\n-33 6.7-2 11-3.8 13-5.5 2-1.7 3-4.2 3-7.5s-1-5.8-3-7.5c-2-1.7-6.3-3.5-13-5.5-68\n-17.3-128.2-47.8-180.5-91.5-52.3-43.7-93.8-96.2-124.5-157.5-9.3-8-15.3-12.3-18\n-13h-6c-12 .7-18 4-18 10 0 2 1.7 7 5 15 23.3 46 52 87 86 123l10 10H0v40h399782\nc-328 0 0 0 0 0l10 8c26.7 20 65.7 43 117 69-2.7 2-6 3.7-10 5-36.7 16-72.3 37.3\n-107 64l-10 8H0v40zM0 157v40h399730v-40zm0 194v40h399730v-40z",leftarrow:"M400000 241H110l3-3c68.7-52.7 113.7-120\n 135-202 4-14.7 6-23 6-25 0-7.3-7-11-21-11-8 0-13.2.8-15.5 2.5-2.3 1.7-4.2 5.8\n-5.5 12.5-1.3 4.7-2.7 10.3-4 17-12 48.7-34.8 92-68.5 130S65.3 228.3 18 247\nc-10 4-16 7.7-18 11 0 8.7 6 14.3 18 17 47.3 18.7 87.8 47 121.5 85S196 441.3 208\n 490c.7 2 1.3 5 2 9s1.2 6.7 1.5 8c.3 1.3 1 3.3 2 6s2.2 4.5 3.5 5.5c1.3 1 3.3\n 1.8 6 2.5s6 1 10 1c14 0 21-3.7 21-11 0-2-2-10.3-6-25-20-79.3-65-146.7-135-202\n l-3-3h399890zM100 241v40h399900v-40z",leftbrace:"M6 548l-6-6v-35l6-11c56-104 135.3-181.3 238-232 57.3-28.7 117\n-45 179-50h399577v120H403c-43.3 7-81 15-113 26-100.7 33-179.7 91-237 174-2.7\n 5-6 9-10 13-.7 1-7.3 1-20 1H6z",leftbraceunder:"M0 6l6-6h17c12.688 0 19.313.3 20 1 4 4 7.313 8.3 10 13\n 35.313 51.3 80.813 93.8 136.5 127.5 55.688 33.7 117.188 55.8 184.5 66.5.688\n 0 2 .3 4 1 18.688 2.7 76 4.3 172 5h399450v120H429l-6-1c-124.688-8-235-61.7\n-331-161C60.687 138.7 32.312 99.3 7 54L0 41V6z",leftgroup:"M400000 80\nH435C64 80 168.3 229.4 21 260c-5.9 1.2-18 0-18 0-2 0-3-1-3-3v-38C76 61 257 0\n 435 0h399565z",leftgroupunder:"M400000 262\nH435C64 262 168.3 112.6 21 82c-5.9-1.2-18 0-18 0-2 0-3 1-3 3v38c76 158 257 219\n 435 219h399565z",leftharpoon:"M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3\n-3.3 10.2-9.5 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5\n-18.3 3-21-1.3-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7\n-196 228-6.7 4.7-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40z",leftharpoonplus:"M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3-3.3 10.2-9.5\n 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5-18.3 3-21-1.3\n-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7-196 228-6.7 4.7\n-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40zM0 435v40h400000v-40z\nm0 0v40h400000v-40z",leftharpoondown:"M7 241c-4 4-6.333 8.667-7 14 0 5.333.667 9 2 11s5.333\n 5.333 12 10c90.667 54 156 130 196 228 3.333 10.667 6.333 16.333 9 17 2 .667 5\n 1 9 1h5c10.667 0 16.667-2 18-6 2-2.667 1-9.667-3-21-32-87.333-82.667-157.667\n-152-211l-3-3h399907v-40zM93 281 H400000 v-40L7 241z",leftharpoondownplus:"M7 435c-4 4-6.3 8.7-7 14 0 5.3.7 9 2 11s5.3 5.3 12\n 10c90.7 54 156 130 196 228 3.3 10.7 6.3 16.3 9 17 2 .7 5 1 9 1h5c10.7 0 16.7\n-2 18-6 2-2.7 1-9.7-3-21-32-87.3-82.7-157.7-152-211l-3-3h399907v-40H7zm93 0\nv40h399900v-40zM0 241v40h399900v-40zm0 0v40h399900v-40z",lefthook:"M400000 281 H103s-33-11.2-61-33.5S0 197.3 0 164s14.2-61.2 42.5\n-83.5C70.8 58.2 104 47 142 47 c16.7 0 25 6.7 25 20 0 12-8.7 18.7-26 20-40 3.3\n-68.7 15.7-86 37-10 12-15 25.3-15 40 0 22.7 9.8 40.7 29.5 54 19.7 13.3 43.5 21\n 71.5 23h399859zM103 281v-40h399897v40z",leftlinesegment:B("M40 281 V428 H0 V94 H40 V241 H400000 v40z"),leftbracketunder:B("M0 0 h120 V290 H399995 v120 H0z"),leftbracketover:B("M0 440 h120 V150 H399995 v-120 H0z"),leftmapsto:B("M40 281 V448H0V74H40V241H400000v40z"),leftToFrom:"M0 147h400000v40H0zm0 214c68 40 115.7 95.7 143 167h22c15.3 0 23\n-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69-70-101l-7-8h399905v-40H95l7-8\nc28.7-32 52-65.7 70-101 10.7-23.3 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 265.3\n 68 321 0 361zm0-174v-40h399900v40zm100 154v40h399900v-40z",longequal:B("M0 50 h400000 v40H0z m0 194h40000v40H0z"),midbrace:"M200428 334\nc-100.7-8.3-195.3-44-280-108-55.3-42-101.7-93-139-153l-9-14c-2.7 4-5.7 8.7-9 14\n-53.3 86.7-123.7 153-211 199-66.7 36-137.3 56.3-212 62H0V214h199568c178.3-11.7\n 311.7-78.3 403-201 6-8 9.7-12 11-12 .7-.7 6.7-1 18-1s17.3.3 18 1c1.3 0 5 4 11\n 12 44.7 59.3 101.3 106.3 170 141s145.3 54.3 229 60h199572v120z",midbraceunder:"M199572 214\nc100.7 8.3 195.3 44 280 108 55.3 42 101.7 93 139 153l9 14c2.7-4 5.7-8.7 9-14\n 53.3-86.7 123.7-153 211-199 66.7-36 137.3-56.3 212-62h199568v120H200432c-178.3\n 11.7-311.7 78.3-403 201-6 8-9.7 12-11 12-.7.7-6.7 1-18 1s-17.3-.3-18-1c-1.3 0\n-5-4-11-12-44.7-59.3-101.3-106.3-170-141s-145.3-54.3-229-60H0V214z",oiintSize1:"M512.6 71.6c272.6 0 320.3 106.8 320.3 178.2 0 70.8-47.7 177.6\n-320.3 177.6S193.1 320.6 193.1 249.8c0-71.4 46.9-178.2 319.5-178.2z\nm368.1 178.2c0-86.4-60.9-215.4-368.1-215.4-306.4 0-367.3 129-367.3 215.4 0 85.8\n60.9 214.8 367.3 214.8 307.2 0 368.1-129 368.1-214.8z",oiintSize2:"M757.8 100.1c384.7 0 451.1 137.6 451.1 230 0 91.3-66.4 228.8\n-451.1 228.8-386.3 0-452.7-137.5-452.7-228.8 0-92.4 66.4-230 452.7-230z\nm502.4 230c0-111.2-82.4-277.2-502.4-277.2s-504 166-504 277.2\nc0 110 84 276 504 276s502.4-166 502.4-276z",oiiintSize1:"M681.4 71.6c408.9 0 480.5 106.8 480.5 178.2 0 70.8-71.6 177.6\n-480.5 177.6S202.1 320.6 202.1 249.8c0-71.4 70.5-178.2 479.3-178.2z\nm525.8 178.2c0-86.4-86.8-215.4-525.7-215.4-437.9 0-524.7 129-524.7 215.4 0\n85.8 86.8 214.8 524.7 214.8 438.9 0 525.7-129 525.7-214.8z",oiiintSize2:"M1021.2 53c603.6 0 707.8 165.8 707.8 277.2 0 110-104.2 275.8\n-707.8 275.8-606 0-710.2-165.8-710.2-275.8C311 218.8 415.2 53 1021.2 53z\nm770.4 277.1c0-131.2-126.4-327.6-770.5-327.6S248.4 198.9 248.4 330.1\nc0 130 128.8 326.4 772.7 326.4s770.5-196.4 770.5-326.4z",rightarrow:"M0 241v40h399891c-47.3 35.3-84 78-110 128\n-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20\n 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7\n 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85\n-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5\n-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67\n 151.7 139 205zm0 0v40h399900v-40z",rightbrace:"M400000 542l\n-6 6h-17c-12.7 0-19.3-.3-20-1-4-4-7.3-8.3-10-13-35.3-51.3-80.8-93.8-136.5-127.5\ns-117.2-55.8-184.5-66.5c-.7 0-2-.3-4-1-18.7-2.7-76-4.3-172-5H0V214h399571l6 1\nc124.7 8 235 61.7 331 161 31.3 33.3 59.7 72.7 85 118l7 13v35z",rightbraceunder:"M399994 0l6 6v35l-6 11c-56 104-135.3 181.3-238 232-57.3\n 28.7-117 45-179 50H-300V214h399897c43.3-7 81-15 113-26 100.7-33 179.7-91 237\n-174 2.7-5 6-9 10-13 .7-1 7.3-1 20-1h17z",rightgroup:"M0 80h399565c371 0 266.7 149.4 414 180 5.9 1.2 18 0 18 0 2 0\n 3-1 3-3v-38c-76-158-257-219-435-219H0z",rightgroupunder:"M0 262h399565c371 0 266.7-149.4 414-180 5.9-1.2 18 0 18\n 0 2 0 3 1 3 3v38c-76 158-257 219-435 219H0z",rightharpoon:"M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3\n-3.7-15.3-11-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2\n-10.7 0-16.7 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58\n 69.2 92 94.5zm0 0v40h399900v-40z",rightharpoonplus:"M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3-3.7-15.3-11\n-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2-10.7 0-16.7\n 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58 69.2 92 94.5z\nm0 0v40h399900v-40z m100 194v40h399900v-40zm0 0v40h399900v-40z",rightharpoondown:"M399747 511c0 7.3 6.7 11 20 11 8 0 13-.8 15-2.5s4.7-6.8\n 8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3 8.5-5.8 9.5\n-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3-64.7 57-92 95\n-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 241v40h399900v-40z",rightharpoondownplus:"M399747 705c0 7.3 6.7 11 20 11 8 0 13-.8\n 15-2.5s4.7-6.8 8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3\n 8.5-5.8 9.5-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3\n-64.7 57-92 95-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 435v40h399900v-40z\nm0-194v40h400000v-40zm0 0v40h400000v-40z",righthook:"M399859 241c-764 0 0 0 0 0 40-3.3 68.7-15.7 86-37 10-12 15-25.3\n 15-40 0-22.7-9.8-40.7-29.5-54-19.7-13.3-43.5-21-71.5-23-17.3-1.3-26-8-26-20 0\n-13.3 8.7-20 26-20 38 0 71 11.2 99 33.5 0 0 7 5.6 21 16.7 14 11.2 21 33.5 21\n 66.8s-14 61.2-42 83.5c-28 22.3-61 33.5-99 33.5L0 241z M0 281v-40h399859v40z",rightlinesegment:B("M399960 241 V94 h40 V428 h-40 V281 H0 v-40z"),rightbracketunder:B("M399995 0 h-120 V290 H0 v120 H400000z"),rightbracketover:B("M399995 440 h-120 V150 H0 v-120 H399995z"),rightToFrom:"M400000 167c-70.7-42-118-97.7-142-167h-23c-15.3 0-23 .3-23\n 1 0 1.3 5.3 13.7 16 37 18 35.3 41.3 69 70 101l7 8H0v40h399905l-7 8c-28.7 32\n-52 65.7-70 101-10.7 23.3-16 35.7-16 37 0 .7 7.7 1 23 1h23c24-69.3 71.3-125 142\n-167z M100 147v40h399900v-40zM0 341v40h399900v-40z",twoheadleftarrow:"M0 167c68 40\n 115.7 95.7 143 167h22c15.3 0 23-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69\n-70-101l-7-8h125l9 7c50.7 39.3 85 86 103 140h46c0-4.7-6.3-18.7-19-42-18-35.3\n-40-67.3-66-96l-9-9h399716v-40H284l9-9c26-28.7 48-60.7 66-96 12.7-23.333 19\n-37.333 19-42h-46c-18 54-52.3 100.7-103 140l-9 7H95l7-8c28.7-32 52-65.7 70-101\n 10.7-23.333 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 71.3 68 127 0 167z",twoheadrightarrow:"M400000 167\nc-68-40-115.7-95.7-143-167h-22c-15.3 0-23 .3-23 1 0 1.3 5.3 13.7 16 37 18 35.3\n 41.3 69 70 101l7 8h-125l-9-7c-50.7-39.3-85-86-103-140h-46c0 4.7 6.3 18.7 19 42\n 18 35.3 40 67.3 66 96l9 9H0v40h399716l-9 9c-26 28.7-48 60.7-66 96-12.7 23.333\n-19 37.333-19 42h46c18-54 52.3-100.7 103-140l9-7h125l-7 8c-28.7 32-52 65.7-70\n 101-10.7 23.333-16 35.7-16 37 0 .7 7.7 1 23 1h22c27.3-71.3 75-127 143-167z",tilde1:"M200 55.538c-77 0-168 73.953-177 73.953-3 0-7\n-2.175-9-5.437L2 97c-1-2-2-4-2-6 0-4 2-7 5-9l20-12C116 12 171 0 207 0c86 0\n 114 68 191 68 78 0 168-68 177-68 4 0 7 2 9 5l12 19c1 2.175 2 4.35 2 6.525 0\n 4.35-2 7.613-5 9.788l-19 13.05c-92 63.077-116.937 75.308-183 76.128\n-68.267.847-113-73.952-191-73.952z",tilde2:"M344 55.266c-142 0-300.638 81.316-311.5 86.418\n-8.01 3.762-22.5 10.91-23.5 5.562L1 120c-1-2-1-3-1-4 0-5 3-9 8-10l18.4-9C160.9\n 31.9 283 0 358 0c148 0 188 122 331 122s314-97 326-97c4 0 8 2 10 7l7 21.114\nc1 2.14 1 3.21 1 4.28 0 5.347-3 9.626-7 10.696l-22.3 12.622C852.6 158.372 751\n 181.476 676 181.476c-149 0-189-126.21-332-126.21z",tilde3:"M786 59C457 59 32 175.242 13 175.242c-6 0-10-3.457\n-11-10.37L.15 138c-1-7 3-12 10-13l19.2-6.4C378.4 40.7 634.3 0 804.3 0c337 0\n 411.8 157 746.8 157 328 0 754-112 773-112 5 0 10 3 11 9l1 14.075c1 8.066-.697\n 16.595-6.697 17.492l-21.052 7.31c-367.9 98.146-609.15 122.696-778.15 122.696\n -338 0-409-156.573-744-156.573z",tilde4:"M786 58C457 58 32 177.487 13 177.487c-6 0-10-3.345\n-11-10.035L.15 143c-1-7 3-12 10-13l22-6.7C381.2 35 637.15 0 807.15 0c337 0 409\n 177 744 177 328 0 754-127 773-127 5 0 10 3 11 9l1 14.794c1 7.805-3 13.38-9\n 14.495l-20.7 5.574c-366.85 99.79-607.3 139.372-776.3 139.372-338 0-409\n -175.236-744-175.236z",vec:"M377 20c0-5.333 1.833-10 5.5-14S391 0 397 0c4.667 0 8.667 1.667 12 5\n3.333 2.667 6.667 9 10 19 6.667 24.667 20.333 43.667 41 57 7.333 4.667 11\n10.667 11 18 0 6-1 10-3 12s-6.667 5-14 9c-28.667 14.667-53.667 35.667-75 63\n-1.333 1.333-3.167 3.5-5.5 6.5s-4 4.833-5 5.5c-1 .667-2.5 1.333-4.5 2s-4.333 1\n-7 1c-4.667 0-9.167-1.833-13.5-5.5S337 184 337 178c0-12.667 15.667-32.333 47-59\nH213l-171-1c-8.667-6-13-12.333-13-19 0-4.667 4.333-11.333 13-20h359\nc-16-25.333-24-45-24-59z",widehat1:"M529 0h5l519 115c5 1 9 5 9 10 0 1-1 2-1 3l-4 22\nc-1 5-5 9-11 9h-2L532 67 19 159h-2c-5 0-9-4-11-9l-5-22c-1-6 2-12 8-13z",widehat2:"M1181 0h2l1171 176c6 0 10 5 10 11l-2 23c-1 6-5 10\n-11 10h-1L1182 67 15 220h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z",widehat3:"M1181 0h2l1171 236c6 0 10 5 10 11l-2 23c-1 6-5 10\n-11 10h-1L1182 67 15 280h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z",widehat4:"M1181 0h2l1171 296c6 0 10 5 10 11l-2 23c-1 6-5 10\n-11 10h-1L1182 67 15 340h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z",widecheck1:"M529,159h5l519,-115c5,-1,9,-5,9,-10c0,-1,-1,-2,-1,-3l-4,-22c-1,\n-5,-5,-9,-11,-9h-2l-512,92l-513,-92h-2c-5,0,-9,4,-11,9l-5,22c-1,6,2,12,8,13z",widecheck2:"M1181,220h2l1171,-176c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,\n-11,-10h-1l-1168,153l-1167,-153h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z",widecheck3:"M1181,280h2l1171,-236c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,\n-11,-10h-1l-1168,213l-1167,-213h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z",widecheck4:"M1181,340h2l1171,-296c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,\n-11,-10h-1l-1168,273l-1167,-273h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z",baraboveleftarrow:"M400000 620h-399890l3 -3c68.7 -52.7 113.7 -120 135 -202\nc4 -14.7 6 -23 6 -25c0 -7.3 -7 -11 -21 -11c-8 0 -13.2 0.8 -15.5 2.5\nc-2.3 1.7 -4.2 5.8 -5.5 12.5c-1.3 4.7 -2.7 10.3 -4 17c-12 48.7 -34.8 92 -68.5 130\ns-74.2 66.3 -121.5 85c-10 4 -16 7.7 -18 11c0 8.7 6 14.3 18 17c47.3 18.7 87.8 47\n121.5 85s56.5 81.3 68.5 130c0.7 2 1.3 5 2 9s1.2 6.7 1.5 8c0.3 1.3 1 3.3 2 6\ns2.2 4.5 3.5 5.5c1.3 1 3.3 1.8 6 2.5s6 1 10 1c14 0 21 -3.7 21 -11\nc0 -2 -2 -10.3 -6 -25c-20 -79.3 -65 -146.7 -135 -202l-3 -3h399890z\nM100 620v40h399900v-40z M0 241v40h399900v-40zM0 241v40h399900v-40z",rightarrowabovebar:"M0 241v40h399891c-47.3 35.3-84 78-110 128-16.7 32\n-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20 11 8 0\n13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7 39\n-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85-40.5\n-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5\n-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67\n151.7 139 205zm96 379h399894v40H0zm0 0h399904v40H0z",baraboveshortleftharpoon:"M507,435c-4,4,-6.3,8.7,-7,14c0,5.3,0.7,9,2,11\nc1.3,2,5.3,5.3,12,10c90.7,54,156,130,196,228c3.3,10.7,6.3,16.3,9,17\nc2,0.7,5,1,9,1c0,0,5,0,5,0c10.7,0,16.7,-2,18,-6c2,-2.7,1,-9.7,-3,-21\nc-32,-87.3,-82.7,-157.7,-152,-211c0,0,-3,-3,-3,-3l399351,0l0,-40\nc-398570,0,-399437,0,-399437,0z M593 435 v40 H399500 v-40z\nM0 281 v-40 H399908 v40z M0 281 v-40 H399908 v40z",rightharpoonaboveshortbar:"M0,241 l0,40c399126,0,399993,0,399993,0\nc4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199,\n-231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6\nc-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z\nM0 241 v40 H399908 v-40z M0 475 v-40 H399500 v40z M0 475 v-40 H399500 v40z",shortbaraboveleftharpoon:"M7,435c-4,4,-6.3,8.7,-7,14c0,5.3,0.7,9,2,11\nc1.3,2,5.3,5.3,12,10c90.7,54,156,130,196,228c3.3,10.7,6.3,16.3,9,17c2,0.7,5,1,9,\n1c0,0,5,0,5,0c10.7,0,16.7,-2,18,-6c2,-2.7,1,-9.7,-3,-21c-32,-87.3,-82.7,-157.7,\n-152,-211c0,0,-3,-3,-3,-3l399907,0l0,-40c-399126,0,-399993,0,-399993,0z\nM93 435 v40 H400000 v-40z M500 241 v40 H400000 v-40z M500 241 v40 H400000 v-40z",shortrightharpoonabovebar:"M53,241l0,40c398570,0,399437,0,399437,0\nc4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199,\n-231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6\nc-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z\nM500 241 v40 H399408 v-40z M500 435 v40 H400000 v-40z"};class I{constructor(e){this.children=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,this.children=e,this.classes=[],this.height=0,this.depth=0,this.maxFontSize=0,this.style={}}hasClass(e){return this.classes.includes(e)}toNode(){const e=document.createDocumentFragment();for(let t=0;t{if("toText"in e)return e.toText();throw new Error("Expected MathDomNode with toText, got "+e.constructor.name)}).join("")}}const R={pt:1,mm:7227/2540,cm:7227/254,in:72.27,bp:1.00375,pc:12,dd:1238/1157,cc:14856/1157,nd:685/642,nc:1370/107,sp:1/65536,px:1.00375},E={ex:!0,em:!0,mu:!0},H=function(e){return"string"!=typeof e&&(e=e.unit),e in R||e in E||"ex"===e},N=function(e,t){let r;if(e.unit in R)r=R[e.unit]/t.fontMetrics().ptPerEm/t.sizeMultiplier;else if("mu"===e.unit)r=t.fontMetrics().cssEmPerMu;else{let o;if(o=t.style.isTight()?t.havingStyle(t.style.text()):t,"ex"===e.unit)r=o.fontMetrics().xHeight;else{if("em"!==e.unit)throw new n("Invalid unit: '"+e.unit+"'");r=o.fontMetrics().quad}o!==t&&(r*=o.sizeMultiplier/t.sizeMultiplier)}return Math.min(e.number*r,t.maxSize)},O=function(e){return+e.toFixed(4)+"em"},D=function(e){return e.filter(e=>e).join(" ")},L=function(e){let t="";for(const r of Object.keys(e)){const n=e[r];void 0!==n&&(t+=s(r)+":"+n+";")}return t},P=function(e,t,r){if(this.classes=e||[],this.attributes={},this.height=0,this.depth=0,this.maxFontSize=0,this.style=r||{},t){t.style.isTight()&&this.classes.push("mtight");const e=t.getColor();e&&(this.style.color=e)}},F=function(e){const t=document.createElement(e);t.className=D(this.classes),Object.assign(t.style,this.style);for(const e of Object.keys(this.attributes))t.setAttribute(e,this.attributes[e]);for(let e=0;e/=\x00-\x1f]/,G=function(e){let t="<"+e;this.classes.length&&(t+=' class="'+a(D(this.classes))+'"');const r=L(this.style);r&&(t+=' style="'+a(r)+'"');for(const e of Object.keys(this.attributes)){if(V.test(e))throw new n("Invalid attribute name '"+e+"'");t+=" "+e+'="'+a(this.attributes[e])+'"'}t+=">";for(let e=0;e",t};class U{constructor(e,t,r,n){this.children=void 0,this.attributes=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.width=void 0,this.maxFontSize=void 0,this.style=void 0,this.italic=void 0,P.call(this,e,r,n),this.children=t||[]}setAttribute(e,t){this.attributes[e]=t}hasClass(e){return this.classes.includes(e)}toNode(){return F.call(this,"span")}toMarkup(){return G.call(this,"span")}}class X{constructor(e,t,r,n){this.children=void 0,this.attributes=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,P.call(this,t,n),this.children=r||[],this.setAttribute("href",e)}setAttribute(e,t){this.attributes[e]=t}hasClass(e){return this.classes.includes(e)}toNode(){return F.call(this,"a")}toMarkup(){return G.call(this,"a")}}class Y{constructor(e,t,r){this.src=void 0,this.alt=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,this.alt=t,this.src=e,this.classes=["mord"],this.height=0,this.depth=0,this.maxFontSize=0,this.style=r}hasClass(e){return this.classes.includes(e)}toNode(){const e=document.createElement("img");return e.src=this.src,e.alt=this.alt,e.className="mord",Object.assign(e.style,this.style),e}toMarkup(){let e=''+a(this.alt)+'=n[0]&&e<=n[1])return r.name}}return null}(this.text.charCodeAt(0));a&&this.classes.push(a+"_fallback"),/[\xee\xef\xed\xec]/.test(this.text)&&(this.text=j[this.text])}hasClass(e){return this.classes.includes(e)}toNode(){const e=document.createTextNode(this.text);let t=null;return this.italic>0&&(t=document.createElement("span"),t.style.marginRight=O(this.italic)),this.classes.length>0&&(t=t||document.createElement("span"),t.className=D(this.classes)),Object.keys(this.style).length>0&&(t=t||document.createElement("span"),Object.assign(t.style,this.style)),t?(t.appendChild(e),t):e}toMarkup(){let e=!1,t="0&&(r+="margin-right:"+O(this.italic)+";"),r+=L(this.style),r&&(e=!0,t+=' style="'+a(r)+'"');const n=a(this.text);return e?(t+=">",t+=n,t+="",t):n}}class _{constructor(e,t){this.children=void 0,this.attributes=void 0,this.children=e||[],this.attributes=t||{}}toNode(){const e=document.createElementNS("http://www.w3.org/2000/svg","svg");for(const t of Object.keys(this.attributes))e.setAttribute(t,this.attributes[t]);for(let t=0;t':''}}class Z{constructor(e){this.attributes=void 0,this.attributes=e||{}}toNode(){const e=document.createElementNS("http://www.w3.org/2000/svg","line");for(const t of Object.keys(this.attributes))e.setAttribute(t,this.attributes[t]);return e}toMarkup(){let e="","\\gt",!0),oe(se,le,be,"\u2208","\\in",!0),oe(se,le,be,"\ue020","\\@not"),oe(se,le,be,"\u2282","\\subset",!0),oe(se,le,be,"\u2283","\\supset",!0),oe(se,le,be,"\u2286","\\subseteq",!0),oe(se,le,be,"\u2287","\\supseteq",!0),oe(se,ae,be,"\u2288","\\nsubseteq",!0),oe(se,ae,be,"\u2289","\\nsupseteq",!0),oe(se,le,be,"\u22a8","\\models"),oe(se,le,be,"\u2190","\\leftarrow",!0),oe(se,le,be,"\u2264","\\le"),oe(se,le,be,"\u2264","\\leq",!0),oe(se,le,be,"<","\\lt",!0),oe(se,le,be,"\u2192","\\rightarrow",!0),oe(se,le,be,"\u2192","\\to"),oe(se,ae,be,"\u2271","\\ngeq",!0),oe(se,ae,be,"\u2270","\\nleq",!0),oe(se,le,ye,"\xa0","\\ "),oe(se,le,ye,"\xa0","\\space"),oe(se,le,ye,"\xa0","\\nobreakspace"),oe(ie,le,ye,"\xa0","\\ "),oe(ie,le,ye,"\xa0"," "),oe(ie,le,ye,"\xa0","\\space"),oe(ie,le,ye,"\xa0","\\nobreakspace"),oe(se,le,ye,"","\\nobreak"),oe(se,le,ye,"","\\allowbreak"),oe(se,le,fe,",",","),oe(se,le,fe,";",";"),oe(se,ae,he,"\u22bc","\\barwedge",!0),oe(se,ae,he,"\u22bb","\\veebar",!0),oe(se,le,he,"\u2299","\\odot",!0),oe(se,le,he,"\u2295","\\oplus",!0),oe(se,le,he,"\u2297","\\otimes",!0),oe(se,le,xe,"\u2202","\\partial",!0),oe(se,le,he,"\u2298","\\oslash",!0),oe(se,ae,he,"\u229a","\\circledcirc",!0),oe(se,ae,he,"\u22a1","\\boxdot",!0),oe(se,le,he,"\u25b3","\\bigtriangleup"),oe(se,le,he,"\u25bd","\\bigtriangledown"),oe(se,le,he,"\u2020","\\dagger"),oe(se,le,he,"\u22c4","\\diamond"),oe(se,le,he,"\u22c6","\\star"),oe(se,le,he,"\u25c3","\\triangleleft"),oe(se,le,he,"\u25b9","\\triangleright"),oe(se,le,ge,"{","\\{"),oe(ie,le,xe,"{","\\{"),oe(ie,le,xe,"{","\\textbraceleft"),oe(se,le,me,"}","\\}"),oe(ie,le,xe,"}","\\}"),oe(ie,le,xe,"}","\\textbraceright"),oe(se,le,ge,"{","\\lbrace"),oe(se,le,me,"}","\\rbrace"),oe(se,le,ge,"[","\\lbrack",!0),oe(ie,le,xe,"[","\\lbrack",!0),oe(se,le,me,"]","\\rbrack",!0),oe(ie,le,xe,"]","\\rbrack",!0),oe(se,le,ge,"(","\\lparen",!0),oe(se,le,me,")","\\rparen",!0),oe(ie,le,xe,"<","\\textless",!0),oe(ie,le,xe,">","\\textgreater",!0),oe(se,le,ge,"\u230a","\\lfloor",!0),oe(se,le,me,"\u230b","\\rfloor",!0),oe(se,le,ge,"\u2308","\\lceil",!0),oe(se,le,me,"\u2309","\\rceil",!0),oe(se,le,xe,"\\","\\backslash"),oe(se,le,xe,"\u2223","|"),oe(se,le,xe,"\u2223","\\vert"),oe(ie,le,xe,"|","\\textbar",!0),oe(se,le,xe,"\u2225","\\|"),oe(se,le,xe,"\u2225","\\Vert"),oe(ie,le,xe,"\u2225","\\textbardbl"),oe(ie,le,xe,"~","\\textasciitilde"),oe(ie,le,xe,"\\","\\textbackslash"),oe(ie,le,xe,"^","\\textasciicircum"),oe(se,le,be,"\u2191","\\uparrow",!0),oe(se,le,be,"\u21d1","\\Uparrow",!0),oe(se,le,be,"\u2193","\\downarrow",!0),oe(se,le,be,"\u21d3","\\Downarrow",!0),oe(se,le,be,"\u2195","\\updownarrow",!0),oe(se,le,be,"\u21d5","\\Updownarrow",!0),oe(se,le,de,"\u2210","\\coprod"),oe(se,le,de,"\u22c1","\\bigvee"),oe(se,le,de,"\u22c0","\\bigwedge"),oe(se,le,de,"\u2a04","\\biguplus"),oe(se,le,de,"\u22c2","\\bigcap"),oe(se,le,de,"\u22c3","\\bigcup"),oe(se,le,de,"\u222b","\\int"),oe(se,le,de,"\u222b","\\intop"),oe(se,le,de,"\u222c","\\iint"),oe(se,le,de,"\u222d","\\iiint"),oe(se,le,de,"\u220f","\\prod"),oe(se,le,de,"\u2211","\\sum"),oe(se,le,de,"\u2a02","\\bigotimes"),oe(se,le,de,"\u2a01","\\bigoplus"),oe(se,le,de,"\u2a00","\\bigodot"),oe(se,le,de,"\u222e","\\oint"),oe(se,le,de,"\u222f","\\oiint"),oe(se,le,de,"\u2230","\\oiiint"),oe(se,le,de,"\u2a06","\\bigsqcup"),oe(se,le,de,"\u222b","\\smallint"),oe(ie,le,ue,"\u2026","\\textellipsis"),oe(se,le,ue,"\u2026","\\mathellipsis"),oe(ie,le,ue,"\u2026","\\ldots",!0),oe(se,le,ue,"\u2026","\\ldots",!0),oe(se,le,ue,"\u22ef","\\@cdots",!0),oe(se,le,ue,"\u22f1","\\ddots",!0),oe(se,le,xe,"\u22ee","\\varvdots"),oe(ie,le,xe,"\u22ee","\\varvdots"),oe(se,le,ce,"\u02ca","\\acute"),oe(se,le,ce,"\u02cb","\\grave"),oe(se,le,ce,"\xa8","\\ddot"),oe(se,le,ce,"~","\\tilde"),oe(se,le,ce,"\u02c9","\\bar"),oe(se,le,ce,"\u02d8","\\breve"),oe(se,le,ce,"\u02c7","\\check"),oe(se,le,ce,"^","\\hat"),oe(se,le,ce,"\u20d7","\\vec"),oe(se,le,ce,"\u02d9","\\dot"),oe(se,le,ce,"\u02da","\\mathring"),oe(se,le,pe,"\ue131","\\@imath"),oe(se,le,pe,"\ue237","\\@jmath"),oe(se,le,xe,"\u0131","\u0131"),oe(se,le,xe,"\u0237","\u0237"),oe(ie,le,xe,"\u0131","\\i",!0),oe(ie,le,xe,"\u0237","\\j",!0),oe(ie,le,xe,"\xdf","\\ss",!0),oe(ie,le,xe,"\xe6","\\ae",!0),oe(ie,le,xe,"\u0153","\\oe",!0),oe(ie,le,xe,"\xf8","\\o",!0),oe(ie,le,xe,"\xc6","\\AE",!0),oe(ie,le,xe,"\u0152","\\OE",!0),oe(ie,le,xe,"\xd8","\\O",!0),oe(ie,le,ce,"\u02ca","\\'"),oe(ie,le,ce,"\u02cb","\\`"),oe(ie,le,ce,"\u02c6","\\^"),oe(ie,le,ce,"\u02dc","\\~"),oe(ie,le,ce,"\u02c9","\\="),oe(ie,le,ce,"\u02d8","\\u"),oe(ie,le,ce,"\u02d9","\\."),oe(ie,le,ce,"\xb8","\\c"),oe(ie,le,ce,"\u02da","\\r"),oe(ie,le,ce,"\u02c7","\\v"),oe(ie,le,ce,"\xa8",'\\"'),oe(ie,le,ce,"\u02dd","\\H"),oe(ie,le,ce,"\u25ef","\\textcircled");const we={"--":!0,"---":!0,"``":!0,"''":!0};oe(ie,le,xe,"\u2013","--",!0),oe(ie,le,xe,"\u2013","\\textendash"),oe(ie,le,xe,"\u2014","---",!0),oe(ie,le,xe,"\u2014","\\textemdash"),oe(ie,le,xe,"\u2018","`",!0),oe(ie,le,xe,"\u2018","\\textquoteleft"),oe(ie,le,xe,"\u2019","'",!0),oe(ie,le,xe,"\u2019","\\textquoteright"),oe(ie,le,xe,"\u201c","``",!0),oe(ie,le,xe,"\u201c","\\textquotedblleft"),oe(ie,le,xe,"\u201d","''",!0),oe(ie,le,xe,"\u201d","\\textquotedblright"),oe(se,le,xe,"\xb0","\\degree",!0),oe(ie,le,xe,"\xb0","\\degree"),oe(ie,le,xe,"\xb0","\\textdegree",!0),oe(se,le,xe,"\xa3","\\pounds"),oe(se,le,xe,"\xa3","\\mathsterling",!0),oe(ie,le,xe,"\xa3","\\pounds"),oe(ie,le,xe,"\xa3","\\textsterling",!0),oe(se,ae,xe,"\u2720","\\maltese"),oe(ie,ae,xe,"\u2720","\\maltese");const ve='0123456789/@."';for(let e=0;e<14;e++){const t=ve.charAt(e);oe(se,le,xe,t,t)}const ke='0123456789!@*()-=+";:?/.,';for(let e=0;e<25;e++){const t=ke.charAt(e);oe(ie,le,xe,t,t)}const ze="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";for(let e=0;e<52;e++){const t=ze.charAt(e);oe(se,le,pe,t,t),oe(ie,le,xe,t,t)}let Se;oe(se,ae,xe,"C","\u2102"),oe(ie,ae,xe,"C","\u2102"),oe(se,ae,xe,"H","\u210d"),oe(ie,ae,xe,"H","\u210d"),oe(se,ae,xe,"N","\u2115"),oe(ie,ae,xe,"N","\u2115"),oe(se,ae,xe,"P","\u2119"),oe(ie,ae,xe,"P","\u2119"),oe(se,ae,xe,"Q","\u211a"),oe(ie,ae,xe,"Q","\u211a"),oe(se,ae,xe,"R","\u211d"),oe(ie,ae,xe,"R","\u211d"),oe(se,ae,xe,"Z","\u2124"),oe(ie,ae,xe,"Z","\u2124"),oe(se,le,pe,"h","\u210e"),oe(ie,le,pe,"h","\u210e");for(let e=0;e<52;e++){const t=ze.charAt(e);Se=String.fromCharCode(55349,56320+e),oe(se,le,pe,t,Se),oe(ie,le,xe,t,Se),Se=String.fromCharCode(55349,56372+e),oe(se,le,pe,t,Se),oe(ie,le,xe,t,Se),Se=String.fromCharCode(55349,56424+e),oe(se,le,pe,t,Se),oe(ie,le,xe,t,Se),Se=String.fromCharCode(55349,56580+e),oe(se,le,pe,t,Se),oe(ie,le,xe,t,Se),Se=String.fromCharCode(55349,56684+e),oe(se,le,pe,t,Se),oe(ie,le,xe,t,Se),Se=String.fromCharCode(55349,56736+e),oe(se,le,pe,t,Se),oe(ie,le,xe,t,Se),Se=String.fromCharCode(55349,56788+e),oe(se,le,pe,t,Se),oe(ie,le,xe,t,Se),Se=String.fromCharCode(55349,56840+e),oe(se,le,pe,t,Se),oe(ie,le,xe,t,Se),Se=String.fromCharCode(55349,56944+e),oe(se,le,pe,t,Se),oe(ie,le,xe,t,Se),e<26&&(Se=String.fromCharCode(55349,56632+e),oe(se,le,pe,t,Se),oe(ie,le,xe,t,Se),Se=String.fromCharCode(55349,56476+e),oe(se,le,pe,t,Se),oe(ie,le,xe,t,Se))}Se=String.fromCharCode(55349,56668),oe(se,le,pe,"k",Se),oe(ie,le,xe,"k",Se);for(let e=0;e<10;e++){const t=e.toString();Se=String.fromCharCode(55349,57294+e),oe(se,le,pe,t,Se),oe(ie,le,xe,t,Se),Se=String.fromCharCode(55349,57314+e),oe(se,le,pe,t,Se),oe(ie,le,xe,t,Se),Se=String.fromCharCode(55349,57324+e),oe(se,le,pe,t,Se),oe(ie,le,xe,t,Se),Se=String.fromCharCode(55349,57334+e),oe(se,le,pe,t,Se),oe(ie,le,xe,t,Se)}const Me="\xd0\xde\xfe";for(let e=0;e<3;e++){const t=Me.charAt(e);oe(se,le,pe,t,t),oe(ie,le,xe,t,t)}const Ae={mathClass:"mathbf",textClass:"textbf",font:"Main-Bold"},Te={mathClass:"mathnormal",textClass:"textit",font:"Math-Italic"},Be={mathClass:"boldsymbol",textClass:"boldsymbol",font:"Main-BoldItalic"},Ce={mathClass:"",textClass:"",font:""},qe={mathClass:"mathfrak",textClass:"textfrak",font:"Fraktur-Regular"},Ie={mathClass:"mathbb",textClass:"textbb",font:"AMS-Regular"},Re={mathClass:"mathboldfrak",textClass:"textboldfrak",font:"Fraktur-Regular"},Ee={mathClass:"mathsf",textClass:"textsf",font:"SansSerif-Regular"},He={mathClass:"mathboldsf",textClass:"textboldsf",font:"SansSerif-Bold"},Ne={mathClass:"mathitsf",textClass:"textitsf",font:"SansSerif-Italic"},Oe={mathClass:"mathtt",textClass:"texttt",font:"Typewriter-Regular"},De=[Ae,Ae,Te,Te,Be,Be,{mathClass:"mathscr",textClass:"textscr",font:"Script-Regular"},Ce,Ce,Ce,qe,qe,Ie,Ie,Re,Re,Ee,Ee,He,He,Ne,Ne,Ce,Ce,Oe,Oe],Le=[Ae,Ce,Ee,He,Oe],Pe=function(e,t,r){if(ne[r][e]){const t=ne[r][e].replace;t&&(e=t)}return{value:e,metrics:ee(e,t,r)}},Fe=function(e,t,r,n,o){const s=Pe(e,t,r),i=s.metrics;let l;if(e=s.value,i){let t=i.italic;("text"===r||n&&"mathit"===n.font)&&(t=0),l=new W(e,i.height,i.depth,t,i.skew,i.width,o)}else"undefined"!=typeof console&&console.warn("No character metrics for '"+e+"' in style '"+t+"' and mode '"+r+"'"),l=new W(e,0,0,0,0,0,o);if(n){l.maxFontSize=n.sizeMultiplier,n.style.isTight()&&l.classes.push("mtight");const e=n.getColor();e&&(l.style.color=e)}return l},Ve=function(e,t,r,n){return void 0===n&&(n=[]),"boldsymbol"===r.font&&Pe(e,"Main-Bold",t).metrics?Fe(e,"Main-Bold",t,r,n.concat(["mathbf"])):"\\"===e||"main"===ne[t][e].font?Fe(e,"Main-Regular",t,r,n):Fe(e,"AMS-Regular",t,r,n.concat(["amsrm"]))},Ge=function(e,t,r){const o=e.mode,s=e.text,i=["mord"],{font:l,fontFamily:a,fontWeight:c,fontShape:h}=t,m="math"===o||"text"===o&&!!l,u=m?l:a;let p="",d="";if(55349===s.charCodeAt(0)){const e=(e=>{const t=1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320)+65536;if(119808<=t&&t<120484){const e=Math.floor((t-119808)/26);return De[e]}if(120782<=t&&t<=120831){const e=Math.floor((t-120782)/10);return Le[e]}if(120485===t||120486===t)return De[0];if(120486{if(D(e.classes)!==D(t.classes)||e.skew!==t.skew||e.maxFontSize!==t.maxFontSize||0!==e.italic&&e.hasClass("mathnormal"))return!1;if(1===e.classes.length){const t=e.classes[0];if("mbin"===t||"mord"===t)return!1}for(const r of Object.keys(e.style))if(e.style[r]!==t.style[r])return!1;for(const r of Object.keys(t.style))if(e.style[r]!==t.style[r])return!1;return!0},Xe=e=>{for(let t=0;tt&&(t=s.height),s.depth>r&&(r=s.depth),s.maxFontSize>n&&(n=s.maxFontSize)}e.height=t,e.depth=r,e.maxFontSize=n},je=function(e,t,r,n){const o=new U(e,t,r,n);return Ye(o),o},We=(e,t,r,n)=>new U(e,t,r,n),_e=function(e,t,r){const n=je([e],[],t);return n.height=Math.max(r||t.fontMetrics().defaultRuleThickness,t.minRuleThickness),n.style.borderBottomWidth=O(n.height),n.maxFontSize=1,n},$e=function(e){const t=new I(e);return Ye(t),t},Ze=function(e,t){return e instanceof I?je([],[e],t):e},Ke=function(e,t){const{children:r,depth:n}=function(e){if("individualShift"===e.positionType){const t=e.children,r=[t[0]],n=-t[0].shift-t[0].elem.depth;let o=n;for(let e=1;e{const r=je(["mspace"],[],t),n=N(e,t);return r.style.marginRight=O(n),r},Qe=(e,t,r)=>{let n,o;switch(e){case"amsrm":n="AMS";break;case"textrm":n="Main";break;case"textsf":n="SansSerif";break;case"texttt":n="Typewriter";break;default:n=e}return o="textbf"===t&&"textit"===r?"BoldItalic":"textbf"===t?"Bold":"textit"===r?"Italic":"Regular",n+"-"+o},et={mathbf:{variant:"bold",fontName:"Main-Bold"},mathrm:{variant:"normal",fontName:"Main-Regular"},textit:{variant:"italic",fontName:"Main-Italic"},mathit:{variant:"italic",fontName:"Main-Italic"},mathnormal:{variant:"italic",fontName:"Math-Italic"},mathsfit:{variant:"sans-serif-italic",fontName:"SansSerif-Italic"},mathbb:{variant:"double-struck",fontName:"AMS-Regular"},mathcal:{variant:"script",fontName:"Caligraphic-Regular"},mathfrak:{variant:"fraktur",fontName:"Fraktur-Regular"},mathscr:{variant:"script",fontName:"Script-Regular"},mathsf:{variant:"sans-serif",fontName:"SansSerif-Regular"},mathtt:{variant:"monospace",fontName:"Typewriter-Regular"}},tt={vec:["vec",.471,.714],oiintSize1:["oiintSize1",.957,.499],oiintSize2:["oiintSize2",1.472,.659],oiiintSize1:["oiiintSize1",1.304,.499],oiiintSize2:["oiiintSize2",1.98,.659]},rt=function(e,t){const[r,n,o]=tt[e],s=new $(r),i=new _([s],{width:O(n),height:O(o),style:"width:"+O(n),viewBox:"0 0 "+1e3*n+" "+1e3*o,preserveAspectRatio:"xMinYMin"}),l=We(["overlay"],[i],t);return l.height=o,l.style.height=O(o),l.style.width=O(n),l},nt={number:3,unit:"mu"},ot={number:4,unit:"mu"},st={number:5,unit:"mu"},it={mord:{mop:nt,mbin:ot,mrel:st,minner:nt},mop:{mord:nt,mop:nt,mrel:st,minner:nt},mbin:{mord:ot,mop:ot,mopen:ot,minner:ot},mrel:{mord:st,mop:st,mopen:st,minner:st},mopen:{},mclose:{mop:nt,mbin:ot,mrel:st,minner:nt},mpunct:{mord:nt,mop:nt,mrel:st,mopen:nt,mclose:nt,mpunct:nt,minner:nt},minner:{mord:nt,mop:nt,mbin:ot,mrel:st,mopen:nt,mpunct:nt,minner:nt}},lt={mord:{mop:nt},mop:{mord:nt,mop:nt},mbin:{},mrel:{},mopen:{},mclose:{mop:nt},mpunct:{},minner:{mop:nt}},at={},ct={},ht={};function mt(e){let{type:t,names:r,props:n,handler:o,htmlBuilder:s,mathmlBuilder:i}=e;const l={type:t,numArgs:n.numArgs,argTypes:n.argTypes,allowedInArgument:!!n.allowedInArgument,allowedInText:!!n.allowedInText,allowedInMath:void 0===n.allowedInMath||n.allowedInMath,numOptionalArgs:n.numOptionalArgs||0,infix:!!n.infix,primitive:!!n.primitive,handler:o};for(let e=0;e{const r=t.classes[0],n=e.classes[0];"mbin"===r&&ft.has(n)?t.classes[0]="mord":"mbin"===n&>.has(r)&&(e.classes[0]="mord")},{node:i},l,a),wt(o,(e,t)=>{var r,n;const o=zt(t),i=zt(e),l=o&&i?e.hasClass("mtight")?null==(r=lt[o])?void 0:r[i]:null==(n=it[o])?void 0:n[i]:null;if(l)return Je(l,s)},{node:i},l,a),o},wt=function(e,t,r,n,o){n&&e.push(n);let s=0;for(;sr=>{e.splice(t+1,0,r),s++})(s)}n&&e.pop()},vt=function(e){return e instanceof I||e instanceof X||e instanceof U&&e.hasClass("enclosing")?e:null},kt=function(e,t){const r=vt(e);if(r){const e=r.children;if(e.length){if("right"===t)return kt(e[e.length-1],"right");if("left"===t)return kt(e[0],"left")}}return e},zt=function(e,t){if(!e)return null;t&&(e=kt(e,t));const r=e.classes[0];return yt[r]||null},St=function(e,t){const r=["nulldelimiter"].concat(e.baseSizingClasses());return je(t.concat(r))},Mt=function(e,t,r){if(!e)return je();if(ct[e.type]){let n=ct[e.type](e,t);if(r&&t.size!==r.size){n=je(t.sizingClasses(r),[n],t);const e=t.sizeMultiplier/r.sizeMultiplier;n.height*=e,n.depth*=e}return n}throw new n("Got group of unknown type: '"+e.type+"'")};function At(e,t){const r=je(["base"],e,t),n=je(["strut"]);return n.style.height=O(r.height+r.depth),r.depth&&(n.style.verticalAlign=O(-r.depth)),r.children.unshift(n),r}function Tt(e,t){let r=null;1===e.length&&"tag"===e[0].type&&(r=e[0].tag,e=e[0].body);const n=xt(e,t,"root");let o;2===n.length&&n[1].hasClass("tag")&&(o=n.pop());const s=[];let i,l=[];for(let e=0;e0&&(s.push(At(l,t)),l=[]),s.push(n[e]));l.length>0&&s.push(At(l,t)),r?(i=At(xt(r,t,!0),t),i.classes=["tag"],s.push(i)):o&&s.push(o);const a=je(["katex-html"],s);if(a.setAttribute("aria-hidden","true"),i){const e=i.children[0];e.style.height=O(a.height+a.depth),a.depth&&(e.style.verticalAlign=O(-a.depth))}return a}function Bt(e){return new I(e)}class Ct{constructor(e,t,r){this.type=void 0,this.attributes=void 0,this.children=void 0,this.classes=void 0,this.type=e,this.attributes={},this.children=t||[],this.classes=r||[]}setAttribute(e,t){this.attributes[e]=t}getAttribute(e){return this.attributes[e]}toNode(){const e=document.createElementNS("http://www.w3.org/1998/Math/MathML",this.type);for(const t in this.attributes)Object.prototype.hasOwnProperty.call(this.attributes,t)&&e.setAttribute(t,this.attributes[t]);this.classes.length>0&&(e.className=D(this.classes));for(let t=0;t0&&(e+=' class ="'+a(D(this.classes))+'"'),e+=">";for(let t=0;t",e}toText(){return this.children.map(e=>e.toText()).join("")}}class qt{constructor(e){this.text=void 0,this.text=e}toNode(){return document.createTextNode(this.text)}toMarkup(){return a(this.toText())}toText(){return this.text}}class It{constructor(e){this.width=void 0,this.character=void 0,this.width=e,this.character=e>=.05555&&e<=.05556?"\u200a":e>=.1666&&e<=.1667?"\u2009":e>=.2222&&e<=.2223?"\u2005":e>=.2777&&e<=.2778?"\u2005\u200a":e>=-.05556&&e<=-.05555?"\u200a\u2063":e>=-.1667&&e<=-.1666?"\u2009\u2063":e>=-.2223&&e<=-.2222?"\u205f\u2063":e>=-.2778&&e<=-.2777?"\u2005\u2063":null}toNode(){if(this.character)return document.createTextNode(this.character);{const e=document.createElementNS("http://www.w3.org/1998/Math/MathML","mspace");return e.setAttribute("width",O(this.width)),e}}toMarkup(){return this.character?""+this.character+"":''}toText(){return this.character?this.character:" "}}const Rt=new Set(["\\imath","\\jmath"]),Et=new Set(["mrow","mtable"]),Ht=function(e,t,r){return!ne[t][e]||!ne[t][e].replace||55349===e.charCodeAt(0)||we.hasOwnProperty(e)&&r&&(r.fontFamily&&"tt"===r.fontFamily.slice(4,6)||r.font&&"tt"===r.font.slice(4,6))||(e=ne[t][e].replace),new qt(e)},Nt=function(e){return 1===e.length?e[0]:new Ct("mrow",e)},Ot={mathit:"italic",boldsymbol:e=>"textord"===e.type?"bold":"bold-italic",mathbf:"bold",mathbb:"double-struck",mathsfit:"sans-serif-italic",mathfrak:"fraktur",mathscr:"script",mathcal:"script",mathsf:"sans-serif",mathtt:"monospace"},Dt=(e,t)=>{if("text"===e.mode){if("texttt"===t.fontFamily)return"monospace";if("textsf"===t.fontFamily)return"textit"===t.fontShape&&"textbf"===t.fontWeight?"sans-serif-bold-italic":"textit"===t.fontShape?"sans-serif-italic":"textbf"===t.fontWeight?"bold-sans-serif":"sans-serif";if("textit"===t.fontShape&&"textbf"===t.fontWeight)return"bold-italic";if("textit"===t.fontShape)return"italic";if("textbf"===t.fontWeight)return"bold"}const r=t.font;if(!r||"mathnormal"===r)return null;const n=e.mode,o=Ot[r];if(o)return"function"==typeof o?o(e):o;let s=e.text;if(Rt.has(s))return null;if(ne[n][s]){const e=ne[n][s].replace;e&&(s=e)}return ee(s,et[r].fontName,n)?et[r].variant:null};function Lt(e){if(!e)return!1;if("mi"===e.type&&1===e.children.length){const t=e.children[0];return t instanceof qt&&"."===t.text}if("mo"===e.type&&1===e.children.length&&"true"===e.getAttribute("separator")&&"0em"===e.getAttribute("lspace")&&"0em"===e.getAttribute("rspace")){const t=e.children[0];return t instanceof qt&&","===t.text}return!1}const Pt=function(e,t,r){if(1===e.length){const n=Vt(e[0],t);return r&&n instanceof Ct&&"mo"===n.type&&(n.setAttribute("lspace","0em"),n.setAttribute("rspace","0em")),[n]}const n=[];let o;for(let r=0;r=1&&("mn"===o.type||Lt(o))){const e=s.children[0];e instanceof Ct&&"mn"===e.type&&(e.children=[...o.children,...e.children],n.pop())}else if("mi"===o.type&&1===o.children.length){const e=o.children[0];if(e instanceof qt&&"\u0338"===e.text&&("mo"===s.type||"mi"===s.type||"mn"===s.type)){const e=s.children[0];e instanceof qt&&e.text.length>0&&(e.text=e.text.slice(0,1)+"\u0338"+e.text.slice(1),n.pop())}}}n.push(s),o=s}return n},Ft=function(e,t,r){return Nt(Pt(e,t,r))},Vt=function(e,t){if(!e)return new Ct("mrow");if(ht[e.type])return ht[e.type](e,t);throw new n("Got group of unknown type: '"+e.type+"'")};function Gt(e,t,r,n,o){const s=Pt(e,r);let i;i=1===s.length&&s[0]instanceof Ct&&Et.has(s[0].type)?s[0]:new Ct("mrow",s);const l=new Ct("annotation",[new qt(t)]);l.setAttribute("encoding","application/x-tex");const a=new Ct("semantics",[i,l]),c=new Ct("math",[a]);c.setAttribute("xmlns","http://www.w3.org/1998/Math/MathML"),n&&c.setAttribute("display","block");return je([o?"katex":"katex-mathml"],[c])}const Ut=[[1,1,1],[2,1,1],[3,1,1],[4,2,1],[5,2,1],[6,3,1],[7,4,2],[8,6,3],[9,7,6],[10,8,7],[11,10,9]],Xt=[.5,.6,.7,.8,.9,1,1.2,1.44,1.728,2.074,2.488],Yt=function(e,t){return t.size<2?e:Ut[e-1][t.size-1]};class jt{constructor(e){this.style=void 0,this.color=void 0,this.size=void 0,this.textSize=void 0,this.phantom=void 0,this.font=void 0,this.fontFamily=void 0,this.fontWeight=void 0,this.fontShape=void 0,this.sizeMultiplier=void 0,this.maxSize=void 0,this.minRuleThickness=void 0,this._fontMetrics=void 0,this.style=e.style,this.color=e.color,this.size=e.size||jt.BASESIZE,this.textSize=e.textSize||this.size,this.phantom=!!e.phantom,this.font=e.font||"",this.fontFamily=e.fontFamily||"",this.fontWeight=e.fontWeight||"",this.fontShape=e.fontShape||"",this.sizeMultiplier=Xt[this.size-1],this.maxSize=e.maxSize,this.minRuleThickness=e.minRuleThickness,this._fontMetrics=void 0}extend(e){const t={style:this.style,size:this.size,textSize:this.textSize,color:this.color,phantom:this.phantom,font:this.font,fontFamily:this.fontFamily,fontWeight:this.fontWeight,fontShape:this.fontShape,maxSize:this.maxSize,minRuleThickness:this.minRuleThickness};return Object.assign(t,e),new jt(t)}havingStyle(e){return this.style===e?this:this.extend({style:e,size:Yt(this.textSize,e)})}havingCrampedStyle(){return this.havingStyle(this.style.cramp())}havingSize(e){return this.size===e&&this.textSize===e?this:this.extend({style:this.style.text(),size:e,textSize:e,sizeMultiplier:Xt[e-1]})}havingBaseStyle(e){e=e||this.style.text();const t=Yt(jt.BASESIZE,e);return this.size===t&&this.textSize===jt.BASESIZE&&this.style===e?this:this.extend({style:e,size:t})}havingBaseSizing(){let e;switch(this.style.id){case 4:case 5:e=3;break;case 6:case 7:e=1;break;default:e=6}return this.extend({style:this.style.text(),size:e})}withColor(e){return this.extend({color:e})}withPhantom(){return this.extend({phantom:!0})}withFont(e){return this.extend({font:e})}withTextFontFamily(e){return this.extend({fontFamily:e,font:""})}withTextFontWeight(e){return this.extend({fontWeight:e,font:""})}withTextFontShape(e){return this.extend({fontShape:e,font:""})}sizingClasses(e){return e.size!==this.size?["sizing","reset-size"+e.size,"size"+this.size]:[]}baseSizingClasses(){return this.size!==jt.BASESIZE?["sizing","reset-size"+this.size,"size"+jt.BASESIZE]:[]}fontMetrics(){return this._fontMetrics||(this._fontMetrics=function(e){let t;if(t=e>=5?0:e>=3?1:2,!te[t]){const e=te[t]={cssEmPerMu:J.quad[t]/18};for(const r in J)J.hasOwnProperty(r)&&(e[r]=J[r][t])}return te[t]}(this.size)),this._fontMetrics}getColor(){return this.phantom?"transparent":this.color}}jt.BASESIZE=6;var Wt=jt;const _t=function(e){return new Wt({style:e.displayMode?S.DISPLAY:S.TEXT,maxSize:e.maxSize,minRuleThickness:e.minRuleThickness})},$t=function(e,t){if(t.displayMode){const r=["katex-display"];t.leqno&&r.push("leqno"),t.fleqn&&r.push("fleqn"),e=je(r,[e])}return e},Zt=function(e,t,r){const n=_t(r);let o;if("mathml"===r.output)return Gt(e,t,n,r.displayMode,!0);if("html"===r.output){const t=Tt(e,n);o=je(["katex"],[t])}else{const s=Gt(e,t,n,r.displayMode,!1),i=Tt(e,n);o=je(["katex"],[s,i])}return $t(o,r)};const Kt={widehat:"^",widecheck:"\u02c7",widetilde:"~",utilde:"~",overleftarrow:"\u2190",underleftarrow:"\u2190",xleftarrow:"\u2190",overrightarrow:"\u2192",underrightarrow:"\u2192",xrightarrow:"\u2192",underbrace:"\u23df",overbrace:"\u23de",underbracket:"\u23b5",overbracket:"\u23b4",overgroup:"\u23e0",undergroup:"\u23e1",overleftrightarrow:"\u2194",underleftrightarrow:"\u2194",xleftrightarrow:"\u2194",Overrightarrow:"\u21d2",xRightarrow:"\u21d2",overleftharpoon:"\u21bc",xleftharpoonup:"\u21bc",overrightharpoon:"\u21c0",xrightharpoonup:"\u21c0",xLeftarrow:"\u21d0",xLeftrightarrow:"\u21d4",xhookleftarrow:"\u21a9",xhookrightarrow:"\u21aa",xmapsto:"\u21a6",xrightharpoondown:"\u21c1",xleftharpoondown:"\u21bd",xrightleftharpoons:"\u21cc",xleftrightharpoons:"\u21cb",xtwoheadleftarrow:"\u219e",xtwoheadrightarrow:"\u21a0",xlongequal:"=",xtofrom:"\u21c4",xrightleftarrows:"\u21c4",xrightequilibrium:"\u21cc",xleftequilibrium:"\u21cb","\\cdrightarrow":"\u2192","\\cdleftarrow":"\u2190","\\cdlongequal":"="},Jt=function(e){const t=new Ct("mo",[new qt(Kt[e.replace(/^\\/,"")])]);return t.setAttribute("stretchy","true"),t},Qt={overrightarrow:[["rightarrow"],.888,522,"xMaxYMin"],overleftarrow:[["leftarrow"],.888,522,"xMinYMin"],underrightarrow:[["rightarrow"],.888,522,"xMaxYMin"],underleftarrow:[["leftarrow"],.888,522,"xMinYMin"],xrightarrow:[["rightarrow"],1.469,522,"xMaxYMin"],"\\cdrightarrow":[["rightarrow"],3,522,"xMaxYMin"],xleftarrow:[["leftarrow"],1.469,522,"xMinYMin"],"\\cdleftarrow":[["leftarrow"],3,522,"xMinYMin"],Overrightarrow:[["doublerightarrow"],.888,560,"xMaxYMin"],xRightarrow:[["doublerightarrow"],1.526,560,"xMaxYMin"],xLeftarrow:[["doubleleftarrow"],1.526,560,"xMinYMin"],overleftharpoon:[["leftharpoon"],.888,522,"xMinYMin"],xleftharpoonup:[["leftharpoon"],.888,522,"xMinYMin"],xleftharpoondown:[["leftharpoondown"],.888,522,"xMinYMin"],overrightharpoon:[["rightharpoon"],.888,522,"xMaxYMin"],xrightharpoonup:[["rightharpoon"],.888,522,"xMaxYMin"],xrightharpoondown:[["rightharpoondown"],.888,522,"xMaxYMin"],xlongequal:[["longequal"],.888,334,"xMinYMin"],"\\cdlongequal":[["longequal"],3,334,"xMinYMin"],xtwoheadleftarrow:[["twoheadleftarrow"],.888,334,"xMinYMin"],xtwoheadrightarrow:[["twoheadrightarrow"],.888,334,"xMaxYMin"],overleftrightarrow:[["leftarrow","rightarrow"],.888,522],overbrace:[["leftbrace","midbrace","rightbrace"],1.6,548],underbrace:[["leftbraceunder","midbraceunder","rightbraceunder"],1.6,548],underleftrightarrow:[["leftarrow","rightarrow"],.888,522],xleftrightarrow:[["leftarrow","rightarrow"],1.75,522],xLeftrightarrow:[["doubleleftarrow","doublerightarrow"],1.75,560],xrightleftharpoons:[["leftharpoondownplus","rightharpoonplus"],1.75,716],xleftrightharpoons:[["leftharpoonplus","rightharpoondownplus"],1.75,716],xhookleftarrow:[["leftarrow","righthook"],1.08,522],xhookrightarrow:[["lefthook","rightarrow"],1.08,522],overlinesegment:[["leftlinesegment","rightlinesegment"],.888,522],underlinesegment:[["leftlinesegment","rightlinesegment"],.888,522],overbracket:[["leftbracketover","rightbracketover"],1.6,440],underbracket:[["leftbracketunder","rightbracketunder"],1.6,410],overgroup:[["leftgroup","rightgroup"],.888,342],undergroup:[["leftgroupunder","rightgroupunder"],.888,342],xmapsto:[["leftmapsto","rightarrow"],1.5,522],xtofrom:[["leftToFrom","rightToFrom"],1.75,528],xrightleftarrows:[["baraboveleftarrow","rightarrowabovebar"],1.75,901],xrightequilibrium:[["baraboveshortleftharpoon","rightharpoonaboveshortbar"],1.75,716],xleftequilibrium:[["shortbaraboveleftharpoon","shortrightharpoonabovebar"],1.75,716]},er=new Set(["widehat","widecheck","widetilde","utilde"]),tr=function(e,t){const{span:r,minWidth:n,height:o}=function(){let r=4e5;const n=e.label.slice(1);if(er.has(n)&&"base"in e){const o="ordgroup"===e.base.type?e.base.body.length:1;let s,i,l;if(o>5)"widehat"===n||"widecheck"===n?(s=420,r=2364,l=.42,i=n+"4"):(s=312,r=2340,l=.34,i="tilde4");else{const e=[1,1,2,2,3,3][o];"widehat"===n||"widecheck"===n?(r=[0,1062,2364,2364,2364][e],s=[0,239,300,360,420][e],l=[0,.24,.3,.3,.36,.42][e],i=n+e):(r=[0,600,1033,2339,2340][e],s=[0,260,286,306,312][e],l=[0,.26,.286,.3,.306,.34][e],i="tilde"+e)}const a=new $(i),c=new _([a],{width:"100%",height:O(l),viewBox:"0 0 "+r+" "+s,preserveAspectRatio:"none"});return{span:We([],[c],t),minWidth:0,height:l}}{const e=[],o=Qt[n];if(!o)throw new Error('No SVG data for "'+n+'".');const[s,i,l]=o,a=l/1e3,c=s.length;let h,m;if(1===c){if(4!==o.length)throw new Error('Expected 4-tuple for single-path SVG data "'+n+'".');h=["hide-tail"],m=[o[3]]}else if(2===c)h=["halfarrow-left","halfarrow-right"],m=["xMinYMin","xMaxYMin"];else{if(3!==c)throw new Error("Correct katexImagesData or update code here to support\n "+c+" children.");h=["brace-left","brace-center","brace-right"],m=["xMinYMin","xMidYMin","xMaxYMin"]}for(let n=0;n0&&(r.style.minWidth=O(n)),r},rr={bin:1,close:1,inner:1,open:1,punct:1,rel:1},nr={"accent-token":1,mathord:1,"op-token":1,spacing:1,textord:1};function or(e,t){if(!e||e.type!==t)throw new Error("Expected node of type "+t+", but got "+(e?"node of type "+e.type:String(e)));return e}function sr(e){const t=ir(e);if(!t)throw new Error("Expected node of symbol group type, but got "+(e?"node of type "+e.type:String(e)));return t}function ir(e){return e&&("atom"===e.type||nr.hasOwnProperty(e.type))?e:null}const lr=e=>{return e instanceof W?e:((t=e)instanceof U||t instanceof X||t instanceof I)&&1===e.children.length?lr(e.children[0]):void 0;var t},ar=(e,t)=>{let r,n,o;e&&"supsub"===e.type?(n=or(e.base,"accent"),r=n.base,e.base=r,o=function(e){if(e instanceof U)return e;throw new Error("Expected span but got "+String(e)+".")}(Mt(e,t)),e.base=n):(n=or(e,"accent"),r=n.base);const s=Mt(r,t.havingCrampedStyle());let i=0;var l,a;n.isShifty&&m(r)&&(i=null!=(l=null==(a=lr(s))?void 0:a.skew)?l:0);const c="\\c"===n.label;let h,u=c?s.height+s.depth:Math.min(s.height,t.fontMetrics().xHeight);if(n.isStretchy)h=tr(n,t),h=Ke({positionType:"firstBaseline",children:[{type:"elem",elem:s},{type:"elem",elem:h,wrapperClasses:["svg-align"],wrapperStyle:i>0?{width:"calc(100% - "+O(2*i)+")",marginLeft:O(2*i)}:void 0}]});else{let e,r;"\\vec"===n.label?(e=rt("vec",t),r=tt.vec[1]):(e=Ge({type:"textord",mode:n.mode,text:n.label},t,"textord"),e=function(e){if(e instanceof W)return e;throw new Error("Expected symbolNode but got "+String(e)+".")}(e),e.italic=0,r=e.width,c&&(u+=e.depth)),h=je(["accent-body"],[e]);const o="\\textcircled"===n.label;o&&(h.classes.push("accent-full"),u=s.height);let l=i;o||(l-=r/2),h.style.left=O(l),"\\textcircled"===n.label&&(h.style.top=".2em"),h=Ke({positionType:"firstBaseline",children:[{type:"elem",elem:s},{type:"kern",size:-u},{type:"elem",elem:h}]})}const p=je(["mord","accent"],[h],t);return o?(o.children[0]=p,o.height=Math.max(p.height,o.height),o.classes[0]="mord",o):p},cr=(e,t)=>{const r=e.isStretchy?Jt(e.label):new Ct("mo",[Ht(e.label,e.mode)]),n=new Ct("mover",[Vt(e.base,t),r]);return n.setAttribute("accent","true"),n},hr=new RegExp(["\\acute","\\grave","\\ddot","\\tilde","\\bar","\\breve","\\check","\\hat","\\vec","\\dot","\\mathring"].map(e=>"\\"+e).join("|"));mt({type:"accent",names:["\\acute","\\grave","\\ddot","\\tilde","\\bar","\\breve","\\check","\\hat","\\vec","\\dot","\\mathring","\\widecheck","\\widehat","\\widetilde","\\overrightarrow","\\overleftarrow","\\Overrightarrow","\\overleftrightarrow","\\overgroup","\\overlinesegment","\\overleftharpoon","\\overrightharpoon"],props:{numArgs:1},handler:(e,t)=>{const r=pt(t[0]),n=!hr.test(e.funcName),o=!n||"\\widehat"===e.funcName||"\\widetilde"===e.funcName||"\\widecheck"===e.funcName;return{type:"accent",mode:e.parser.mode,label:e.funcName,isStretchy:n,isShifty:o,base:r}},htmlBuilder:ar,mathmlBuilder:cr}),mt({type:"accent",names:["\\'","\\`","\\^","\\~","\\=","\\u","\\.",'\\"',"\\c","\\r","\\H","\\v","\\textcircled"],props:{numArgs:1,allowedInText:!0,allowedInMath:!0,argTypes:["primitive"]},handler:(e,t)=>{const r=t[0];let n=e.parser.mode;return"math"===n&&(e.parser.settings.reportNonstrict("mathVsTextAccents","LaTeX's accent "+e.funcName+" works only in text mode"),n="text"),{type:"accent",mode:n,label:e.funcName,isStretchy:!1,isShifty:!0,base:r}},htmlBuilder:ar,mathmlBuilder:cr}),mt({type:"accentUnder",names:["\\underleftarrow","\\underrightarrow","\\underleftrightarrow","\\undergroup","\\underlinesegment","\\utilde"],props:{numArgs:1},handler:(e,t)=>{let{parser:r,funcName:n}=e;const o=t[0];return{type:"accentUnder",mode:r.mode,label:n,base:o}},htmlBuilder:(e,t)=>{const r=Mt(e.base,t),n=tr(e,t),o="\\utilde"===e.label?.12:0,s=Ke({positionType:"top",positionData:r.height,children:[{type:"elem",elem:n,wrapperClasses:["svg-align"]},{type:"kern",size:o},{type:"elem",elem:r}]});return je(["mord","accentunder"],[s],t)},mathmlBuilder:(e,t)=>{const r=Jt(e.label),n=new Ct("munder",[Vt(e.base,t),r]);return n.setAttribute("accentunder","true"),n}});const mr=e=>{const t=new Ct("mpadded",e?[e]:[]);return t.setAttribute("width","+0.6em"),t.setAttribute("lspace","0.3em"),t};function ur(e,t){const r=xt(e.body,t,!0);return je([e.mclass],r,t)}function pr(e,t){let r;const n=Pt(e.body,t);return"minner"===e.mclass?r=new Ct("mpadded",n):"mord"===e.mclass?e.isCharacterBox?(r=n[0],r.type="mi"):r=new Ct("mi",n):(e.isCharacterBox?(r=n[0],r.type="mo"):r=new Ct("mo",n),"mbin"===e.mclass?(r.attributes.lspace="0.22em",r.attributes.rspace="0.22em"):"mpunct"===e.mclass?(r.attributes.lspace="0em",r.attributes.rspace="0.17em"):"mopen"===e.mclass||"mclose"===e.mclass?(r.attributes.lspace="0em",r.attributes.rspace="0em"):"minner"===e.mclass&&(r.attributes.lspace="0.0556em",r.attributes.width="+0.1111em")),r}mt({type:"xArrow",names:["\\xleftarrow","\\xrightarrow","\\xLeftarrow","\\xRightarrow","\\xleftrightarrow","\\xLeftrightarrow","\\xhookleftarrow","\\xhookrightarrow","\\xmapsto","\\xrightharpoondown","\\xrightharpoonup","\\xleftharpoondown","\\xleftharpoonup","\\xrightleftharpoons","\\xleftrightharpoons","\\xlongequal","\\xtwoheadrightarrow","\\xtwoheadleftarrow","\\xtofrom","\\xrightleftarrows","\\xrightequilibrium","\\xleftequilibrium","\\\\cdrightarrow","\\\\cdleftarrow","\\\\cdlongequal"],props:{numArgs:1,numOptionalArgs:1},handler(e,t,r){let{parser:n,funcName:o}=e;return{type:"xArrow",mode:n.mode,label:o,body:t[0],below:r[0]}},htmlBuilder(e,t){const r=t.style;let n=t.havingStyle(r.sup());const o=Ze(Mt(e.body,n,t),t),s="\\x"===e.label.slice(0,2)?"x":"cd";let i;o.classes.push(s+"-arrow-pad"),e.below&&(n=t.havingStyle(r.sub()),i=Ze(Mt(e.below,n,t),t),i.classes.push(s+"-arrow-pad"));const l=tr(e,t),a=-t.fontMetrics().axisHeight+.5*l.height;let c,h=-t.fontMetrics().axisHeight-.5*l.height-.111;if((o.depth>.25||"\\xleftequilibrium"===e.label)&&(h-=o.depth),i){const e=-t.fontMetrics().axisHeight+i.height+.5*l.height+.111;c=Ke({positionType:"individualShift",children:[{type:"elem",elem:o,shift:h},{type:"elem",elem:l,shift:a,wrapperClasses:["svg-align"]},{type:"elem",elem:i,shift:e}]})}else c=Ke({positionType:"individualShift",children:[{type:"elem",elem:o,shift:h},{type:"elem",elem:l,shift:a,wrapperClasses:["svg-align"]}]});return je(["mrel","x-arrow"],[c],t)},mathmlBuilder(e,t){const r=Jt(e.label);let n;if(r.setAttribute("minsize","x"===e.label.charAt(0)?"1.75em":"3.0em"),e.body){const o=mr(Vt(e.body,t));if(e.below){const s=mr(Vt(e.below,t));n=new Ct("munderover",[r,s,o])}else n=new Ct("mover",[r,o])}else if(e.below){const o=mr(Vt(e.below,t));n=new Ct("munder",[r,o])}else n=mr(),n=new Ct("mover",[r,n]);return n}}),mt({type:"mclass",names:["\\mathord","\\mathbin","\\mathrel","\\mathopen","\\mathclose","\\mathpunct","\\mathinner"],props:{numArgs:1,primitive:!0},handler(e,t){let{parser:r,funcName:n}=e;const o=t[0];return{type:"mclass",mode:r.mode,mclass:"m"+n.slice(5),body:dt(o),isCharacterBox:m(o)}},htmlBuilder:ur,mathmlBuilder:pr});const dr=e=>{const t="ordgroup"===e.type&&e.body.length?e.body[0]:e;return"atom"!==t.type||"bin"!==t.family&&"rel"!==t.family?"mord":"m"+t.family};mt({type:"mclass",names:["\\@binrel"],props:{numArgs:2},handler(e,t){let{parser:r}=e;return{type:"mclass",mode:r.mode,mclass:dr(t[0]),body:dt(t[1]),isCharacterBox:m(t[1])}}}),mt({type:"mclass",names:["\\stackrel","\\overset","\\underset"],props:{numArgs:2},handler(e,t){let{parser:r,funcName:n}=e;const o=t[1],s=t[0];let i;i="\\stackrel"!==n?dr(o):"mrel";const l={type:"op",mode:o.mode,limits:!0,alwaysHandleSupSub:!0,parentIsSupSub:!1,symbol:!1,suppressBaseShift:"\\stackrel"!==n,body:dt(o)},a={type:"supsub",mode:s.mode,base:l,sup:"\\underset"===n?null:s,sub:"\\underset"===n?s:null};return{type:"mclass",mode:r.mode,mclass:i,body:[a],isCharacterBox:m(a)}},htmlBuilder:ur,mathmlBuilder:pr}),mt({type:"pmb",names:["\\pmb"],props:{numArgs:1,allowedInText:!0},handler(e,t){let{parser:r}=e;return{type:"pmb",mode:r.mode,mclass:dr(t[0]),body:dt(t[0])}},htmlBuilder(e,t){const r=xt(e.body,t,!0),n=je([e.mclass],r,t);return n.style.textShadow="0.02em 0.01em 0.04px",n},mathmlBuilder(e,t){const r=Pt(e.body,t),n=new Ct("mstyle",r);return n.setAttribute("style","text-shadow: 0.02em 0.01em 0.04px"),n}});const gr={">":"\\\\cdrightarrow","<":"\\\\cdleftarrow","=":"\\\\cdlongequal",A:"\\uparrow",V:"\\downarrow","|":"\\Vert",".":"no arrow"},fr=()=>({type:"styling",body:[],mode:"math",style:"display",resetFont:!0}),br=e=>"textord"===e.type&&"@"===e.text,yr=(e,t)=>("mathord"===e.type||"atom"===e.type)&&e.text===t;function xr(e,t,r){const n=gr[e];switch(n){case"\\\\cdrightarrow":case"\\\\cdleftarrow":return r.callFunction(n,[t[0]],[t[1]]);case"\\uparrow":case"\\downarrow":{const e={type:"atom",text:n,mode:"math",family:"rel"},o={type:"ordgroup",mode:"math",body:[r.callFunction("\\\\cdleft",[t[0]],[]),r.callFunction("\\Big",[e],[]),r.callFunction("\\\\cdright",[t[1]],[])]};return r.callFunction("\\\\cdparent",[o],[])}case"\\\\cdlongequal":return r.callFunction("\\\\cdlongequal",[],[]);case"\\Vert":{const e={type:"textord",text:"\\Vert",mode:"math"};return r.callFunction("\\Big",[e],[])}default:return{type:"textord",text:" ",mode:"math"}}}mt({type:"cdlabel",names:["\\\\cdleft","\\\\cdright"],props:{numArgs:1},handler(e,t){let{parser:r,funcName:n}=e;return{type:"cdlabel",mode:r.mode,side:n.slice(4),label:t[0]}},htmlBuilder(e,t){const r=t.havingStyle(t.style.sup()),n=Ze(Mt(e.label,r,t),t);return n.classes.push("cd-label-"+e.side),n.style.bottom=O(.8-n.depth),n.height=0,n.depth=0,n},mathmlBuilder(e,t){let r=new Ct("mrow",[Vt(e.label,t)]);return r=new Ct("mpadded",[r]),r.setAttribute("width","0"),"left"===e.side&&r.setAttribute("lspace","-1width"),r.setAttribute("voffset","0.7em"),r=new Ct("mstyle",[r]),r.setAttribute("displaystyle","false"),r.setAttribute("scriptlevel","1"),r}}),mt({type:"cdlabelparent",names:["\\\\cdparent"],props:{numArgs:1},handler(e,t){let{parser:r}=e;return{type:"cdlabelparent",mode:r.mode,fragment:t[0]}},htmlBuilder(e,t){const r=Ze(Mt(e.fragment,t),t);return r.classes.push("cd-vert-arrow"),r},mathmlBuilder(e,t){return new Ct("mrow",[Vt(e.fragment,t)])}}),mt({type:"textord",names:["\\@char"],props:{numArgs:1,allowedInText:!0},handler(e,t){let{parser:r}=e;const o=or(t[0],"ordgroup").body;let s="";for(let e=0;e=1114111)throw new n("\\@char with invalid code point "+s);return l<=65535?i=String.fromCharCode(l):(l-=65536,i=String.fromCharCode(55296+(l>>10),56320+(1023&l))),{type:"textord",mode:r.mode,text:i}}});const wr=(e,t)=>{const r=xt(e.body,t.withColor(e.color),!1);return $e(r)},vr=(e,t)=>{const r=Pt(e.body,t.withColor(e.color)),n=new Ct("mstyle",r);return n.setAttribute("mathcolor",e.color),n};mt({type:"color",names:["\\textcolor"],props:{numArgs:2,allowedInText:!0,argTypes:["color","original"]},handler(e,t){let{parser:r}=e;const n=or(t[0],"color-token").color,o=t[1];return{type:"color",mode:r.mode,color:n,body:dt(o)}},htmlBuilder:wr,mathmlBuilder:vr}),mt({type:"color",names:["\\color"],props:{numArgs:1,allowedInText:!0,argTypes:["color"]},handler(e,t){let{parser:r,breakOnTokenText:n}=e;const o=or(t[0],"color-token").color;r.gullet.macros.set("\\current@color",o);const s=r.parseExpression(!0,n);return{type:"color",mode:r.mode,color:o,body:s}},htmlBuilder:wr,mathmlBuilder:vr}),mt({type:"cr",names:["\\\\"],props:{numArgs:0,numOptionalArgs:0,allowedInText:!0},handler(e,t,r){let{parser:n}=e;const o="["===n.gullet.future().text?n.parseSizeGroup(!0):null,s=!n.settings.displayMode||!n.settings.useStrictBehavior("newLineInDisplayMode","In LaTeX, \\\\ or \\newline does nothing in display mode");return{type:"cr",mode:n.mode,newLine:s,size:o&&or(o,"size").value}},htmlBuilder(e,t){const r=je(["mspace"],[],t);return e.newLine&&(r.classes.push("newline"),e.size&&(r.style.marginTop=O(N(e.size,t)))),r},mathmlBuilder(e,t){const r=new Ct("mspace");return e.newLine&&(r.setAttribute("linebreak","newline"),e.size&&r.setAttribute("height",O(N(e.size,t)))),r}});const kr={"\\global":"\\global","\\long":"\\\\globallong","\\\\globallong":"\\\\globallong","\\def":"\\gdef","\\gdef":"\\gdef","\\edef":"\\xdef","\\xdef":"\\xdef","\\let":"\\\\globallet","\\futurelet":"\\\\globalfuture"},zr=e=>{const t=e.text;if(/^(?:[\\{}$&#^_]|EOF)$/.test(t))throw new n("Expected a control sequence",e);return t},Sr=(e,t,r,n)=>{let o=e.gullet.macros.get(r.text);null==o&&(r.noexpand=!0,o={tokens:[r],numArgs:0,unexpandable:!e.gullet.isExpandable(r.text)}),e.gullet.macros.set(t,o,n)};mt({type:"internal",names:["\\global","\\long","\\\\globallong"],props:{numArgs:0,allowedInText:!0},handler(e){let{parser:t,funcName:r}=e;t.consumeSpaces();const o=t.fetch();if(kr[o.text])return"\\global"!==r&&"\\\\globallong"!==r||(o.text=kr[o.text]),or(t.parseFunction(),"internal");throw new n("Invalid token after macro prefix",o)}}),mt({type:"internal",names:["\\def","\\gdef","\\edef","\\xdef"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler(e){let{parser:t,funcName:r}=e,o=t.gullet.popToken();const s=o.text;if(/^(?:[\\{}$&#^_]|EOF)$/.test(s))throw new n("Expected a control sequence",o);let i,l=0;const a=[[]];for(;"{"!==t.gullet.future().text;)if(o=t.gullet.popToken(),"#"===o.text){if("{"===t.gullet.future().text){i=t.gullet.future(),a[l].push("{");break}if(o=t.gullet.popToken(),!/^[1-9]$/.test(o.text))throw new n('Invalid argument number "'+o.text+'"');if(parseInt(o.text)!==l+1)throw new n('Argument number "'+o.text+'" out of order');l++,a.push([])}else{if("EOF"===o.text)throw new n("Expected a macro definition");a[l].push(o.text)}let{tokens:c}=t.gullet.consumeArg();return i&&c.unshift(i),"\\edef"!==r&&"\\xdef"!==r||(c=t.gullet.expandTokens(c),c.reverse()),t.gullet.macros.set(s,{tokens:c,numArgs:l,delimiters:a},r===kr[r]),{type:"internal",mode:t.mode}}}),mt({type:"internal",names:["\\let","\\\\globallet"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler(e){let{parser:t,funcName:r}=e;const n=zr(t.gullet.popToken());t.gullet.consumeSpaces();const o=(e=>{let t=e.gullet.popToken();return"="===t.text&&(t=e.gullet.popToken()," "===t.text&&(t=e.gullet.popToken())),t})(t);return Sr(t,n,o,"\\\\globallet"===r),{type:"internal",mode:t.mode}}}),mt({type:"internal",names:["\\futurelet","\\\\globalfuture"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler(e){let{parser:t,funcName:r}=e;const n=zr(t.gullet.popToken()),o=t.gullet.popToken(),s=t.gullet.popToken();return Sr(t,n,s,"\\\\globalfuture"===r),t.gullet.pushToken(s),t.gullet.pushToken(o),{type:"internal",mode:t.mode}}});const Mr=function(e,t,r){const n=ee(ne.math[e]&&ne.math[e].replace||e,t,r);if(!n)throw new Error("Unsupported symbol "+e+" and font size "+t+".");return n},Ar=function(e,t,r,n){const o=r.havingBaseStyle(t),s=je(n.concat(o.sizingClasses(r)),[e],r),i=o.sizeMultiplier/r.sizeMultiplier;return s.height*=i,s.depth*=i,s.maxFontSize=o.sizeMultiplier,s},Tr=function(e,t,r){const n=t.havingBaseStyle(r),o=(1-t.sizeMultiplier/n.sizeMultiplier)*t.fontMetrics().axisHeight;e.classes.push("delimcenter"),e.style.top=O(o),e.height-=o,e.depth+=o},Br=function(e,t,r,n,o,s){const i=function(e,t,r,n){return Fe(e,"Size"+t+"-Regular",r,n)}(e,t,o,n),l=Ar(je(["delimsizing","size"+t],[i],n),S.TEXT,n,s);return r&&Tr(l,n,S.TEXT),l},Cr=function(e,t,r){let n;n="Size1-Regular"===t?"delim-size1":"delim-size4";return{type:"elem",elem:je(["delimsizinginner",n],[je([],[Fe(e,t,r)])])}},qr=function(e,t,r){const n=K["Size4-Regular"][e.charCodeAt(0)]?K["Size4-Regular"][e.charCodeAt(0)][4]:K["Size1-Regular"][e.charCodeAt(0)][4],o=new $("inner",function(e,t){switch(e){case"\u239c":return B("M291 0 H417 V"+t+" H291z");case"\u2223":return B("M145 0 H188 V"+t+" H145z");case"\u2225":return B("M145 0 H188 V"+t+" H145z")+B("M367 0 H410 V"+t+" H367z");case"\u239f":return B("M457 0 H583 V"+t+" H457z");case"\u23a2":return B("M319 0 H403 V"+t+" H319z");case"\u23a5":return B("M263 0 H347 V"+t+" H263z");case"\u23aa":return B("M384 0 H504 V"+t+" H384z");case"\u23d0":return B("M312 0 H355 V"+t+" H312z");case"\u2016":return B("M257 0 H300 V"+t+" H257z")+B("M478 0 H521 V"+t+" H478z");default:return""}}(e,Math.round(1e3*t))),s=new _([o],{width:O(n),height:O(t),style:"width:"+O(n),viewBox:"0 0 "+1e3*n+" "+Math.round(1e3*t),preserveAspectRatio:"xMinYMin"}),i=We([],[s],r);return i.height=t,i.style.height=O(t),i.style.width=O(n),{type:"elem",elem:i}},Ir={type:"kern",size:-.008},Rr=new Set(["|","\\lvert","\\rvert","\\vert"]),Er=new Set(["\\|","\\lVert","\\rVert","\\Vert"]),Hr=function(e,t,r,n,o,s){let i,l,a,c,h="",m=0;i=a=c=e,l=null;let u="Size1-Regular";"\\uparrow"===e?a=c="\u23d0":"\\Uparrow"===e?a=c="\u2016":"\\downarrow"===e?i=a="\u23d0":"\\Downarrow"===e?i=a="\u2016":"\\updownarrow"===e?(i="\\uparrow",a="\u23d0",c="\\downarrow"):"\\Updownarrow"===e?(i="\\Uparrow",a="\u2016",c="\\Downarrow"):Rr.has(e)?(a="\u2223",h="vert",m=333):Er.has(e)?(a="\u2225",h="doublevert",m=556):"["===e||"\\lbrack"===e?(i="\u23a1",a="\u23a2",c="\u23a3",u="Size4-Regular",h="lbrack",m=667):"]"===e||"\\rbrack"===e?(i="\u23a4",a="\u23a5",c="\u23a6",u="Size4-Regular",h="rbrack",m=667):"\\lfloor"===e||"\u230a"===e?(a=i="\u23a2",c="\u23a3",u="Size4-Regular",h="lfloor",m=667):"\\lceil"===e||"\u2308"===e?(i="\u23a1",a=c="\u23a2",u="Size4-Regular",h="lceil",m=667):"\\rfloor"===e||"\u230b"===e?(a=i="\u23a5",c="\u23a6",u="Size4-Regular",h="rfloor",m=667):"\\rceil"===e||"\u2309"===e?(i="\u23a4",a=c="\u23a5",u="Size4-Regular",h="rceil",m=667):"("===e||"\\lparen"===e?(i="\u239b",a="\u239c",c="\u239d",u="Size4-Regular",h="lparen",m=875):")"===e||"\\rparen"===e?(i="\u239e",a="\u239f",c="\u23a0",u="Size4-Regular",h="rparen",m=875):"\\{"===e||"\\lbrace"===e?(i="\u23a7",l="\u23a8",c="\u23a9",a="\u23aa",u="Size4-Regular"):"\\}"===e||"\\rbrace"===e?(i="\u23ab",l="\u23ac",c="\u23ad",a="\u23aa",u="Size4-Regular"):"\\lgroup"===e||"\u27ee"===e?(i="\u23a7",c="\u23a9",a="\u23aa",u="Size4-Regular"):"\\rgroup"===e||"\u27ef"===e?(i="\u23ab",c="\u23ad",a="\u23aa",u="Size4-Regular"):"\\lmoustache"===e||"\u23b0"===e?(i="\u23a7",c="\u23ad",a="\u23aa",u="Size4-Regular"):"\\rmoustache"!==e&&"\u23b1"!==e||(i="\u23ab",c="\u23a9",a="\u23aa",u="Size4-Regular");const p=Mr(i,u,o),d=p.height+p.depth,g=Mr(a,u,o),f=g.height+g.depth,b=Mr(c,u,o),y=b.height+b.depth;let x=0,w=1;if(null!==l){const e=Mr(l,u,o);x=e.height+e.depth,w=2}const v=d+y+x,k=v+Math.max(0,Math.ceil((t-v)/(w*f)))*w*f;let z=n.fontMetrics().axisHeight;r&&(z*=n.sizeMultiplier);const M=k/2-z,A=[];if(h.length>0){const e=k-d-y,t=Math.round(1e3*k),r=function(e,t){switch(e){case"lbrack":return"M403 1759 V84 H666 V0 H319 V1759 v"+t+" v1759 v84 h347 v-84\nH403z M403 1759 V0 H319 V1759 v"+t+" v1759 v84 h84z";case"rbrack":return"M347 1759 V0 H0 V84 H263 V1759 v"+t+" v1759 H0 v84 H347z\nM347 1759 V0 H263 V1759 v"+t+" v1759 h84z";case"vert":return"M145 15 v585 v"+t+" v585 c2.667,10,9.667,15,21,15\nc10,0,16.667,-5,20,-15 v-585 v"+-t+" v-585 c-2.667,-10,-9.667,-15,-21,-15\nc-10,0,-16.667,5,-20,15z M188 15 H145 v585 v"+t+" v585 h43z";case"doublevert":return"M145 15 v585 v"+t+" v585 c2.667,10,9.667,15,21,15\nc10,0,16.667,-5,20,-15 v-585 v"+-t+" v-585 c-2.667,-10,-9.667,-15,-21,-15\nc-10,0,-16.667,5,-20,15z M188 15 H145 v585 v"+t+" v585 h43z\nM367 15 v585 v"+t+" v585 c2.667,10,9.667,15,21,15\nc10,0,16.667,-5,20,-15 v-585 v"+-t+" v-585 c-2.667,-10,-9.667,-15,-21,-15\nc-10,0,-16.667,5,-20,15z M410 15 H367 v585 v"+t+" v585 h43z";case"lfloor":return"M319 602 V0 H403 V602 v"+t+" v1715 h263 v84 H319z\nMM319 602 V0 H403 V602 v"+t+" v1715 H319z";case"rfloor":return"M319 602 V0 H403 V602 v"+t+" v1799 H0 v-84 H319z\nMM319 602 V0 H403 V602 v"+t+" v1715 H319z";case"lceil":return"M403 1759 V84 H666 V0 H319 V1759 v"+t+" v602 h84z\nM403 1759 V0 H319 V1759 v"+t+" v602 h84z";case"rceil":return"M347 1759 V0 H0 V84 H263 V1759 v"+t+" v602 h84z\nM347 1759 V0 h-84 V1759 v"+t+" v602 h84z";case"lparen":return"M863,9c0,-2,-2,-5,-6,-9c0,0,-17,0,-17,0c-12.7,0,-19.3,0.3,-20,1\nc-5.3,5.3,-10.3,11,-15,17c-242.7,294.7,-395.3,682,-458,1162c-21.3,163.3,-33.3,349,\n-36,557 l0,"+(t+84)+"c0.2,6,0,26,0,60c2,159.3,10,310.7,24,454c53.3,528,210,\n949.7,470,1265c4.7,6,9.7,11.7,15,17c0.7,0.7,7,1,19,1c0,0,18,0,18,0c4,-4,6,-7,6,-9\nc0,-2.7,-3.3,-8.7,-10,-18c-135.3,-192.7,-235.5,-414.3,-300.5,-665c-65,-250.7,-102.5,\n-544.7,-112.5,-882c-2,-104,-3,-167,-3,-189\nl0,-"+(t+92)+"c0,-162.7,5.7,-314,17,-454c20.7,-272,63.7,-513,129,-723c65.3,\n-210,155.3,-396.3,270,-559c6.7,-9.3,10,-15.3,10,-18z";case"rparen":return"M76,0c-16.7,0,-25,3,-25,9c0,2,2,6.3,6,13c21.3,28.7,42.3,60.3,\n63,95c96.7,156.7,172.8,332.5,228.5,527.5c55.7,195,92.8,416.5,111.5,664.5\nc11.3,139.3,17,290.7,17,454c0,28,1.7,43,3.3,45l0,"+(t+9)+"\nc-3,4,-3.3,16.7,-3.3,38c0,162,-5.7,313.7,-17,455c-18.7,248,-55.8,469.3,-111.5,664\nc-55.7,194.7,-131.8,370.3,-228.5,527c-20.7,34.7,-41.7,66.3,-63,95c-2,3.3,-4,7,-6,11\nc0,7.3,5.7,11,17,11c0,0,11,0,11,0c9.3,0,14.3,-0.3,15,-1c5.3,-5.3,10.3,-11,15,-17\nc242.7,-294.7,395.3,-681.7,458,-1161c21.3,-164.7,33.3,-350.7,36,-558\nl0,-"+(t+144)+"c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,\n-470,-1265c-4.7,-6,-9.7,-11.7,-15,-17c-0.7,-0.7,-6.7,-1,-18,-1z";default:throw new Error("Unknown stretchy delimiter.")}}(h,Math.round(1e3*e)),o=new $(h,r),s=O(m/1e3),i=O(t/1e3),l=new _([o],{width:s,height:i,viewBox:"0 0 "+m+" "+t}),a=We([],[l],n);a.height=t/1e3,a.style.width=s,a.style.height=i,A.push({type:"elem",elem:a})}else{if(A.push(Cr(c,u,o)),A.push(Ir),null===l){const e=k-d-y+.016;A.push(qr(a,e,n))}else{const e=(k-d-y-x)/2+.016;A.push(qr(a,e,n)),A.push(Ir),A.push(Cr(l,u,o)),A.push(Ir),A.push(qr(a,e,n))}A.push(Ir),A.push(Cr(i,u,o))}const T=n.havingBaseStyle(S.TEXT),B=Ke({positionType:"bottom",positionData:M,children:A});return Ar(je(["delimsizing","mult"],[B],T),S.TEXT,n,s)},Nr=.08,Or=function(e,t,r,n,o){const s=function(e,t,r){t*=1e3;let n="";switch(e){case"sqrtMain":n=function(e,t){return"M95,"+(622+e+t)+"\nc-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14\nc0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54\nc44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10\ns173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429\nc69,-144,104.5,-217.7,106.5,-221\nl"+e/2.075+" -"+e+"\nc5.3,-9.3,12,-14,20,-14\nH400000v"+(40+e)+"H845.2724\ns-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7\nc-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z\nM"+(834+e)+" "+t+"h400000v"+(40+e)+"h-400000z"}(t,C);break;case"sqrtSize1":n=function(e,t){return"M263,"+(601+e+t)+"c0.7,0,18,39.7,52,119\nc34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120\nc340,-704.7,510.7,-1060.3,512,-1067\nl"+e/2.084+" -"+e+"\nc4.7,-7.3,11,-11,19,-11\nH40000v"+(40+e)+"H1012.3\ns-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232\nc-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1\ns-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26\nc-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z\nM"+(1001+e)+" "+t+"h400000v"+(40+e)+"h-400000z"}(t,C);break;case"sqrtSize2":n=function(e,t){return"M983 "+(10+e+t)+"\nl"+e/3.13+" -"+e+"\nc4,-6.7,10,-10,18,-10 H400000v"+(40+e)+"\nH1013.1s-83.4,268,-264.1,840c-180.7,572,-277,876.3,-289,913c-4.7,4.7,-12.7,7,-24,7\ns-12,0,-12,0c-1.3,-3.3,-3.7,-11.7,-7,-25c-35.3,-125.3,-106.7,-373.3,-214,-744\nc-10,12,-21,25,-33,39s-32,39,-32,39c-6,-5.3,-15,-14,-27,-26s25,-30,25,-30\nc26.7,-32.7,52,-63,76,-91s52,-60,52,-60s208,722,208,722\nc56,-175.3,126.3,-397.3,211,-666c84.7,-268.7,153.8,-488.2,207.5,-658.5\nc53.7,-170.3,84.5,-266.8,92.5,-289.5z\nM"+(1001+e)+" "+t+"h400000v"+(40+e)+"h-400000z"}(t,C);break;case"sqrtSize3":n=function(e,t){return"M424,"+(2398+e+t)+"\nc-1.3,-0.7,-38.5,-172,-111.5,-514c-73,-342,-109.8,-513.3,-110.5,-514\nc0,-2,-10.7,14.3,-32,49c-4.7,7.3,-9.8,15.7,-15.5,25c-5.7,9.3,-9.8,16,-12.5,20\ns-5,7,-5,7c-4,-3.3,-8.3,-7.7,-13,-13s-13,-13,-13,-13s76,-122,76,-122s77,-121,77,-121\ns209,968,209,968c0,-2,84.7,-361.7,254,-1079c169.3,-717.3,254.7,-1077.7,256,-1081\nl"+e/4.223+" -"+e+"c4,-6.7,10,-10,18,-10 H400000\nv"+(40+e)+"H1014.6\ns-87.3,378.7,-272.6,1166c-185.3,787.3,-279.3,1182.3,-282,1185\nc-2,6,-10,9,-24,9\nc-8,0,-12,-0.7,-12,-2z M"+(1001+e)+" "+t+"\nh400000v"+(40+e)+"h-400000z"}(t,C);break;case"sqrtSize4":n=function(e,t){return"M473,"+(2713+e+t)+"\nc339.3,-1799.3,509.3,-2700,510,-2702 l"+e/5.298+" -"+e+"\nc3.3,-7.3,9.3,-11,18,-11 H400000v"+(40+e)+"H1017.7\ns-90.5,478,-276.2,1466c-185.7,988,-279.5,1483,-281.5,1485c-2,6,-10,9,-24,9\nc-8,0,-12,-0.7,-12,-2c0,-1.3,-5.3,-32,-16,-92c-50.7,-293.3,-119.7,-693.3,-207,-1200\nc0,-1.3,-5.3,8.7,-16,30c-10.7,21.3,-21.3,42.7,-32,64s-16,33,-16,33s-26,-26,-26,-26\ns76,-153,76,-153s77,-151,77,-151c0.7,0.7,35.7,202,105,604c67.3,400.7,102,602.7,104,\n606zM"+(1001+e)+" "+t+"h400000v"+(40+e)+"H1017.7z"}(t,C);break;case"sqrtTall":n=function(e,t,r){return"M702 "+(e+t)+"H400000"+(40+e)+"\nH742v"+(r-54-t-e)+"l-4 4-4 4c-.667.7 -2 1.5-4 2.5s-4.167 1.833-6.5 2.5-5.5 1-9.5 1\nh-12l-28-84c-16.667-52-96.667 -294.333-240-727l-212 -643 -85 170\nc-4-3.333-8.333-7.667-13 -13l-13-13l77-155 77-156c66 199.333 139 419.667\n219 661 l218 661zM702 "+t+"H400000v"+(40+e)+"H742z"}(t,C,r)}return n}(e,n,r),i=new $(e,s),l=new _([i],{width:"400em",height:O(t),viewBox:"0 0 400000 "+r,preserveAspectRatio:"xMinYMin slice"});return We(["hide-tail"],[l],o)},Dr=new Set(["(","\\lparen",")","\\rparen","[","\\lbrack","]","\\rbrack","\\{","\\lbrace","\\}","\\rbrace","\\lfloor","\\rfloor","\u230a","\u230b","\\lceil","\\rceil","\u2308","\u2309","\\surd"]),Lr=new Set(["\\uparrow","\\downarrow","\\updownarrow","\\Uparrow","\\Downarrow","\\Updownarrow","|","\\|","\\vert","\\Vert","\\lvert","\\rvert","\\lVert","\\rVert","\\lgroup","\\rgroup","\u27ee","\u27ef","\\lmoustache","\\rmoustache","\u23b0","\u23b1"]),Pr=new Set(["<",">","\\langle","\\rangle","/","\\backslash","\\lt","\\gt"]),Fr=[0,1.2,1.8,2.4,3],Vr=function(e,t,r,o,s){if("<"===e||"\\lt"===e||"\u27e8"===e?e="\\langle":">"!==e&&"\\gt"!==e&&"\u27e9"!==e||(e="\\rangle"),Dr.has(e)||Pr.has(e))return Br(e,t,!1,r,o,s);if(Lr.has(e))return Hr(e,Fr[t],!1,r,o,s);throw new n("Illegal delimiter: '"+e+"'")},Gr=[{type:"small",style:S.SCRIPTSCRIPT},{type:"small",style:S.SCRIPT},{type:"small",style:S.TEXT},{type:"large",size:1},{type:"large",size:2},{type:"large",size:3},{type:"large",size:4}],Ur=[{type:"small",style:S.SCRIPTSCRIPT},{type:"small",style:S.SCRIPT},{type:"small",style:S.TEXT},{type:"stack"}],Xr=[{type:"small",style:S.SCRIPTSCRIPT},{type:"small",style:S.SCRIPT},{type:"small",style:S.TEXT},{type:"large",size:1},{type:"large",size:2},{type:"large",size:3},{type:"large",size:4},{type:"stack"}],Yr=function(e){if("small"===e.type)return"Main-Regular";if("large"===e.type)return"Size"+e.size+"-Regular";if("stack"===e.type)return"Size4-Regular";{const t=e.type;throw new Error("Add support for delim type '"+t+"' here.")}},jr=function(e,t,r,n){for(let o=Math.min(2,3-n.style.size);ot)return s}return r[r.length-1]},Wr=function(e,t,r,n,o,s){let i;"<"===e||"\\lt"===e||"\u27e8"===e?e="\\langle":">"!==e&&"\\gt"!==e&&"\u27e9"!==e||(e="\\rangle"),i=Pr.has(e)?Gr:Dr.has(e)?Xr:Ur;const l=jr(e,t,i,n);return"small"===l.type?function(e,t,r,n,o,s){const i=Fe(e,"Main-Regular",o,n),l=Ar(i,t,n,s);return r&&Tr(l,n,t),l}(e,l.style,r,n,o,s):"large"===l.type?Br(e,l.size,r,n,o,s):Hr(e,t,r,n,o,s)},_r=function(e,t,r,n,o,s){const i=n.fontMetrics().axisHeight*n.sizeMultiplier,l=5/n.fontMetrics().ptPerEm,a=Math.max(t-i,r+i),c=Math.max(a/500*901,2*a-l);return Wr(e,c,!0,n,o,s)},$r={"\\bigl":{mclass:"mopen",size:1},"\\Bigl":{mclass:"mopen",size:2},"\\biggl":{mclass:"mopen",size:3},"\\Biggl":{mclass:"mopen",size:4},"\\bigr":{mclass:"mclose",size:1},"\\Bigr":{mclass:"mclose",size:2},"\\biggr":{mclass:"mclose",size:3},"\\Biggr":{mclass:"mclose",size:4},"\\bigm":{mclass:"mrel",size:1},"\\Bigm":{mclass:"mrel",size:2},"\\biggm":{mclass:"mrel",size:3},"\\Biggm":{mclass:"mrel",size:4},"\\big":{mclass:"mord",size:1},"\\Big":{mclass:"mord",size:2},"\\bigg":{mclass:"mord",size:3},"\\Bigg":{mclass:"mord",size:4}},Zr=new Set(["(","\\lparen",")","\\rparen","[","\\lbrack","]","\\rbrack","\\{","\\lbrace","\\}","\\rbrace","\\lfloor","\\rfloor","\u230a","\u230b","\\lceil","\\rceil","\u2308","\u2309","<",">","\\langle","\u27e8","\\rangle","\u27e9","\\lt","\\gt","\\lvert","\\rvert","\\lVert","\\rVert","\\lgroup","\\rgroup","\u27ee","\u27ef","\\lmoustache","\\rmoustache","\u23b0","\u23b1","/","\\backslash","|","\\vert","\\|","\\Vert","\\uparrow","\\Uparrow","\\downarrow","\\Downarrow","\\updownarrow","\\Updownarrow","."]);function Kr(e){return"isMiddle"in e}function Jr(e,t){const r=ir(e);if(r&&Zr.has(r.text))return r;throw new n(r?"Invalid delimiter '"+r.text+"' after '"+t.funcName+"'":"Invalid delimiter type '"+e.type+"'",e)}function Qr(e){if(!e.body)throw new Error("Bug: The leftright ParseNode wasn't fully parsed.")}mt({type:"delimsizing",names:["\\bigl","\\Bigl","\\biggl","\\Biggl","\\bigr","\\Bigr","\\biggr","\\Biggr","\\bigm","\\Bigm","\\biggm","\\Biggm","\\big","\\Big","\\bigg","\\Bigg"],props:{numArgs:1,argTypes:["primitive"]},handler:(e,t)=>{const r=Jr(t[0],e);return{type:"delimsizing",mode:e.parser.mode,size:$r[e.funcName].size,mclass:$r[e.funcName].mclass,delim:r.text}},htmlBuilder:(e,t)=>"."===e.delim?je([e.mclass]):Vr(e.delim,e.size,t,e.mode,[e.mclass]),mathmlBuilder:e=>{const t=[];"."!==e.delim&&t.push(Ht(e.delim,e.mode));const r=new Ct("mo",t);"mopen"===e.mclass||"mclose"===e.mclass?r.setAttribute("fence","true"):r.setAttribute("fence","false"),r.setAttribute("stretchy","true");const n=O(Fr[e.size]);return r.setAttribute("minsize",n),r.setAttribute("maxsize",n),r}}),mt({type:"leftright-right",names:["\\right"],props:{numArgs:1,primitive:!0},handler:(e,t)=>{const r=e.parser.gullet.macros.get("\\current@color");if(r&&"string"!=typeof r)throw new n("\\current@color set to non-string in \\right");return{type:"leftright-right",mode:e.parser.mode,delim:Jr(t[0],e).text,color:r}}}),mt({type:"leftright",names:["\\left"],props:{numArgs:1,primitive:!0},handler:(e,t)=>{const r=Jr(t[0],e),n=e.parser;++n.leftrightDepth;const o=n.parseExpression(!1);--n.leftrightDepth,n.expect("\\right",!1);const s=or(n.parseFunction(),"leftright-right");return{type:"leftright",mode:n.mode,body:o,left:r.text,right:s.delim,rightColor:s.color}},htmlBuilder:(e,t)=>{Qr(e);const r=xt(e.body,t,!0,["mopen","mclose"]);let n,o,s=0,i=0,l=!1;for(let e=0;e{Qr(e);const r=Pt(e.body,t);if("."!==e.left){const t=new Ct("mo",[Ht(e.left,e.mode)]);t.setAttribute("fence","true"),r.unshift(t)}if("."!==e.right){const t=new Ct("mo",[Ht(e.right,e.mode)]);t.setAttribute("fence","true"),e.rightColor&&t.setAttribute("mathcolor",e.rightColor),r.push(t)}return Nt(r)}}),mt({type:"middle",names:["\\middle"],props:{numArgs:1,primitive:!0},handler:(e,t)=>{const r=Jr(t[0],e);if(!e.parser.leftrightDepth)throw new n("\\middle without preceding \\left",r);return{type:"middle",mode:e.parser.mode,delim:r.text}},htmlBuilder:(e,t)=>{let r;return"."===e.delim?r=St(t,[]):(r=Vr(e.delim,1,t,e.mode,[]),r.isMiddle={delim:e.delim,options:t}),r},mathmlBuilder:(e,t)=>{const r="\\vert"===e.delim||"|"===e.delim?Ht("|","text"):Ht(e.delim,e.mode),n=new Ct("mo",[r]);return n.setAttribute("fence","true"),n.setAttribute("lspace","0.05em"),n.setAttribute("rspace","0.05em"),n}});const en=(e,t)=>{const r=Ze(Mt(e.body,t),t),n=e.label.slice(1);let o,s,i=t.sizeMultiplier;const l=m(e.body);if("sout"===n)o=je(["stretchy","sout"]),o.height=t.fontMetrics().defaultRuleThickness/i,s=-.5*t.fontMetrics().xHeight;else if("phase"===n){const e=N({number:.6,unit:"pt"},t),n=N({number:.35,unit:"ex"},t);i/=t.havingBaseSizing().sizeMultiplier;const l=r.height+r.depth+e+n;r.style.paddingLeft=O(l/2+e);const c=Math.floor(1e3*l*i),h="M400000 "+(a=c)+" H0 L"+a/2+" 0 l65 45 L145 "+(a-80)+" H400000z",m=new _([new $("phase",h)],{width:"400em",height:O(c/1e3),viewBox:"0 0 400000 "+c,preserveAspectRatio:"xMinYMin slice"});o=We(["hide-tail"],[m],t),o.style.height=O(l),s=r.depth+e+n}else{let i,a;/cancel/.test(n)?l||r.classes.push("cancel-pad"):"angl"===n?r.classes.push("anglpad"):r.classes.push("boxpad");let c=0;/box/.test(n)?(c=Math.max(t.fontMetrics().fboxrule,t.minRuleThickness),i=t.fontMetrics().fboxsep+("colorbox"===n?0:c),a=i):"angl"===n?(c=Math.max(t.fontMetrics().defaultRuleThickness,t.minRuleThickness),i=4*c,a=Math.max(0,.25-r.depth)):(i=l?.2:0,a=i),o=function(e,t,r,n,o){let s;const i=e.height+e.depth+r+n;if(/fbox|color|angl/.test(t)){if(s=je(["stretchy",t],[],o),"fbox"===t){const e=o.color&&o.getColor();e&&(s.style.borderColor=e)}}else{const e=[];/^[bx]cancel$/.test(t)&&e.push(new Z({x1:"0",y1:"0",x2:"100%",y2:"100%","stroke-width":"0.046em"})),/^x?cancel$/.test(t)&&e.push(new Z({x1:"0",y1:"100%",x2:"100%",y2:"0","stroke-width":"0.046em"}));const r=new _(e,{width:"100%",height:O(i)});s=We([],[r],o)}return s.height=i,s.style.height=O(i),s}(r,n,i,a,t),/fbox|boxed|fcolorbox/.test(n)?(o.style.borderStyle="solid",o.style.borderWidth=O(c)):"angl"===n&&.049!==c&&(o.style.borderTopWidth=O(c),o.style.borderRightWidth=O(c)),s=r.depth+a,e.backgroundColor&&(o.style.backgroundColor=e.backgroundColor,e.borderColor&&(o.style.borderColor=e.borderColor))}var a;let c;if(e.backgroundColor)c=Ke({positionType:"individualShift",children:[{type:"elem",elem:o,shift:s},{type:"elem",elem:r,shift:0}]});else{const e=/cancel|phase/.test(n)?["svg-align"]:[];c=Ke({positionType:"individualShift",children:[{type:"elem",elem:r,shift:0},{type:"elem",elem:o,shift:s,wrapperClasses:e}]})}return/cancel/.test(n)&&(c.height=r.height,c.depth=r.depth),/cancel/.test(n)&&!l?je(["mord","cancel-lap"],[c],t):je(["mord"],[c],t)},tn=(e,t)=>{let r;const n=new Ct(e.label.includes("colorbox")?"mpadded":"menclose",[Vt(e.body,t)]);switch(e.label){case"\\cancel":n.setAttribute("notation","updiagonalstrike");break;case"\\bcancel":n.setAttribute("notation","downdiagonalstrike");break;case"\\phase":n.setAttribute("notation","phasorangle");break;case"\\sout":n.setAttribute("notation","horizontalstrike");break;case"\\fbox":n.setAttribute("notation","box");break;case"\\angl":n.setAttribute("notation","actuarial");break;case"\\fcolorbox":case"\\colorbox":if(r=t.fontMetrics().fboxsep*t.fontMetrics().ptPerEm,n.setAttribute("width","+"+2*r+"pt"),n.setAttribute("height","+"+2*r+"pt"),n.setAttribute("lspace",r+"pt"),n.setAttribute("voffset",r+"pt"),"\\fcolorbox"===e.label){const r=Math.max(t.fontMetrics().fboxrule,t.minRuleThickness);n.setAttribute("style","border: "+O(r)+" solid "+e.borderColor)}break;case"\\xcancel":n.setAttribute("notation","updiagonalstrike downdiagonalstrike")}return e.backgroundColor&&n.setAttribute("mathbackground",e.backgroundColor),n};mt({type:"enclose",names:["\\colorbox"],props:{numArgs:2,allowedInText:!0,argTypes:["color","hbox"]},handler(e,t,r){let{parser:n,funcName:o}=e;const s=or(t[0],"color-token").color,i=t[1];return{type:"enclose",mode:n.mode,label:o,backgroundColor:s,body:i}},htmlBuilder:en,mathmlBuilder:tn}),mt({type:"enclose",names:["\\fcolorbox"],props:{numArgs:3,allowedInText:!0,argTypes:["color","color","hbox"]},handler(e,t,r){let{parser:n,funcName:o}=e;const s=or(t[0],"color-token").color,i=or(t[1],"color-token").color,l=t[2];return{type:"enclose",mode:n.mode,label:o,backgroundColor:i,borderColor:s,body:l}},htmlBuilder:en,mathmlBuilder:tn}),mt({type:"enclose",names:["\\fbox"],props:{numArgs:1,argTypes:["hbox"],allowedInText:!0},handler(e,t){let{parser:r}=e;return{type:"enclose",mode:r.mode,label:"\\fbox",body:t[0]}}}),mt({type:"enclose",names:["\\cancel","\\bcancel","\\xcancel","\\phase"],props:{numArgs:1},handler(e,t){let{parser:r,funcName:n}=e;const o=t[0];return{type:"enclose",mode:r.mode,label:n,body:o}},htmlBuilder:en,mathmlBuilder:tn}),mt({type:"enclose",names:["\\sout"],props:{numArgs:1,allowedInText:!0},handler(e,t){let{parser:r,funcName:n}=e;"math"===r.mode&&r.settings.reportNonstrict("mathVsSout","LaTeX's \\sout works only in text mode");const o=t[0];return{type:"enclose",mode:r.mode,label:n,body:o}},htmlBuilder:en,mathmlBuilder:tn}),mt({type:"enclose",names:["\\angl"],props:{numArgs:1,argTypes:["hbox"],allowedInText:!1},handler(e,t){let{parser:r}=e;return{type:"enclose",mode:r.mode,label:"\\angl",body:t[0]}}});const rn={};function nn(e){let{type:t,names:r,props:n,handler:o,htmlBuilder:s,mathmlBuilder:i}=e;const l={type:t,numArgs:n.numArgs||0,allowedInText:!1,numOptionalArgs:0,handler:o};for(let e=0;e{if(!e.parser.settings.displayMode)throw new n("{"+e.envName+"} can be used only in display mode.")},mn=new Set(["gather","gather*"]);function un(e){if(!e.includes("ed"))return!e.includes("*")}function pn(e,t,r){let{hskipBeforeAndAfter:o,addJot:s,cols:i,arraystretch:l,colSeparationType:a,autoTag:c,singleRow:h,emptySingleRow:m,maxNumCols:u,leqno:p}=t;if(e.gullet.beginGroup(),h||e.gullet.macros.set("\\cr","\\\\\\relax"),!l){const t=e.gullet.expandMacroAsText("\\arraystretch");if(null==t)l=1;else if(l=parseFloat(t),!l||l<0)throw new n("Invalid \\arraystretch: "+t)}e.gullet.beginGroup();let d=[];const g=[d],f=[],b=[],y=null!=c?[]:void 0;function x(){c&&e.gullet.macros.set("\\@eqnsw","1",!0)}function w(){y&&(e.gullet.macros.get("\\df@tag")?(y.push(e.subparse([new an("\\df@tag")])),e.gullet.macros.set("\\df@tag",void 0,!0)):y.push(Boolean(c)&&"1"===e.gullet.macros.get("\\@eqnsw")))}for(x(),b.push(cn(e));;){const t=e.parseExpression(!1,h?"\\end":"\\\\");e.gullet.endGroup(),e.gullet.beginGroup();let o={type:"ordgroup",mode:e.mode,body:t};r&&(o={type:"styling",mode:e.mode,style:r,resetFont:!0,body:[o]}),d.push(o);const s=e.fetch().text;if("&"===s){if(u&&d.length===u){if(h||a)throw new n("Too many tab characters: &",e.nextToken);e.settings.reportNonstrict("textEnv","Too few columns specified in the {array} column argument.")}e.consume()}else{if("\\end"===s){w(),1===d.length&&"styling"===o.type&&1===o.body.length&&"ordgroup"===o.body[0].type&&0===o.body[0].body.length&&(g.length>1||!m)&&g.pop(),b.length0&&(y+=.25),c.push({pos:y,isDashed:e[t]})}for(x(i[0]),r=0;r0&&(u+=b,ce))for(r=0;r=l)continue;var C,q;if(o>0||e.hskipBeforeAndAfter)i=null!=(C=null==(q=c)?void 0:q.pregap)?C:u,0!==i&&(z=je(["arraycolsep"],[]),z.style.width=O(i),k.push(z));const p=[];for(r=0;r0){const e=_e("hline",t,h),r=_e("hdashline",t,h),n=[{type:"elem",elem:E,shift:0}];for(;c.length>0;){const t=c.pop(),o=t.pos-w;t.isDashed?n.push({type:"elem",elem:r,shift:o}):n.push({type:"elem",elem:e,shift:o})}E=Ke({positionType:"individualShift",children:n})}if(0===A.length)return je(["mord"],[E],t);{const e=Ke({positionType:"individualShift",children:A}),r=je(["tag"],[e],t);return $e([E,r])}},fn={c:"center ",l:"left ",r:"right "},bn=function(e,t){const r=[],n=new Ct("mtd",[],["mtr-glue"]),o=new Ct("mtd",[],["mml-eqn-num"]);for(let s=0;s0){const t=e.cols;let r="",n=!1,o=0,i=t.length;"separator"===t[0].type&&(l+="top ",o=1),"separator"===t[t.length-1].type&&(l+="bottom ",i-=1);for(let e=o;e0?"left ":"",l+=h[h.length-1].length>0?"right ":"";for(let e=1;e0&&h&&(n=1),r[e]={type:"align",align:t,pregap:n,postgap:0}}return i.colSeparationType=h?"align":"alignat",i};nn({type:"array",names:["array","darray"],props:{numArgs:1},handler(e,t){const r=(ir(t[0])?[t[0]]:or(t[0],"ordgroup").body).map(function(e){const t=sr(e).text;if("lcr".includes(t))return{type:"align",align:t};if("|"===t)return{type:"separator",separator:"|"};if(":"===t)return{type:"separator",separator:":"};throw new n("Unknown column alignment: "+t,e)}),o={cols:r,hskipBeforeAndAfter:!0,maxNumCols:r.length};return pn(e.parser,o,dn(e.envName))},htmlBuilder:gn,mathmlBuilder:bn}),nn({type:"array",names:["matrix","pmatrix","bmatrix","Bmatrix","vmatrix","Vmatrix","matrix*","pmatrix*","bmatrix*","Bmatrix*","vmatrix*","Vmatrix*"],props:{numArgs:0},handler(e){const t={matrix:null,pmatrix:["(",")"],bmatrix:["[","]"],Bmatrix:["\\{","\\}"],vmatrix:["|","|"],Vmatrix:["\\Vert","\\Vert"]}[e.envName.replace("*","")];let r="c";const o={hskipBeforeAndAfter:!1,cols:[{type:"align",align:r}]};if("*"===e.envName.charAt(e.envName.length-1)){const t=e.parser;if(t.consumeSpaces(),"["===t.fetch().text){if(t.consume(),t.consumeSpaces(),r=t.fetch().text,!"lcr".includes(r))throw new n("Expected l or c or r",t.nextToken);t.consume(),t.consumeSpaces(),t.expect("]"),t.consume(),o.cols=[{type:"align",align:r}]}}const s=pn(e.parser,o,dn(e.envName)),i=Math.max(0,...s.body.map(e=>e.length));return s.cols=new Array(i).fill({type:"align",align:r}),t?{type:"leftright",mode:e.mode,body:[s],left:t[0],right:t[1],rightColor:void 0}:s},htmlBuilder:gn,mathmlBuilder:bn}),nn({type:"array",names:["smallmatrix"],props:{numArgs:0},handler(e){const t=pn(e.parser,{arraystretch:.5},"script");return t.colSeparationType="small",t},htmlBuilder:gn,mathmlBuilder:bn}),nn({type:"array",names:["subarray"],props:{numArgs:1},handler(e,t){const r=(ir(t[0])?[t[0]]:or(t[0],"ordgroup").body).map(function(e){const t=sr(e).text;if("lc".includes(t))return{type:"align",align:t};throw new n("Unknown column alignment: "+t,e)});if(r.length>1)throw new n("{subarray} can contain only one column");const o={cols:r,hskipBeforeAndAfter:!1,arraystretch:.5},s=pn(e.parser,o,"script");if(s.body.length>0&&s.body[0].length>1)throw new n("{subarray} can contain only one column");return s},htmlBuilder:gn,mathmlBuilder:bn}),nn({type:"array",names:["cases","dcases","rcases","drcases"],props:{numArgs:0},handler(e){const t=pn(e.parser,{arraystretch:1.2,cols:[{type:"align",align:"l",pregap:0,postgap:1},{type:"align",align:"l",pregap:0,postgap:0}]},dn(e.envName));return{type:"leftright",mode:e.mode,body:[t],left:e.envName.includes("r")?".":"\\{",right:e.envName.includes("r")?"\\}":".",rightColor:void 0}},htmlBuilder:gn,mathmlBuilder:bn}),nn({type:"array",names:["align","align*","aligned","split"],props:{numArgs:0},handler:yn,htmlBuilder:gn,mathmlBuilder:bn}),nn({type:"array",names:["gathered","gather","gather*"],props:{numArgs:0},handler(e){mn.has(e.envName)&&hn(e);const t={cols:[{type:"align",align:"c"}],addJot:!0,colSeparationType:"gather",autoTag:un(e.envName),emptySingleRow:!0,leqno:e.parser.settings.leqno};return pn(e.parser,t,"display")},htmlBuilder:gn,mathmlBuilder:bn}),nn({type:"array",names:["alignat","alignat*","alignedat"],props:{numArgs:1},handler:yn,htmlBuilder:gn,mathmlBuilder:bn}),nn({type:"array",names:["equation","equation*"],props:{numArgs:0},handler(e){hn(e);const t={autoTag:un(e.envName),emptySingleRow:!0,singleRow:!0,maxNumCols:1,leqno:e.parser.settings.leqno};return pn(e.parser,t,"display")},htmlBuilder:gn,mathmlBuilder:bn}),nn({type:"array",names:["CD"],props:{numArgs:0},handler(e){return hn(e),function(e){const t=[];for(e.gullet.beginGroup(),e.gullet.macros.set("\\cr","\\\\\\relax"),e.gullet.beginGroup();;){t.push(e.parseExpression(!1,"\\\\")),e.gullet.endGroup(),e.gullet.beginGroup();const r=e.fetch().text;if("&"!==r&&"\\\\"!==r){if("\\end"===r){0===t[t.length-1].length&&t.pop();break}throw new n("Expected \\\\ or \\cr or \\end",e.nextToken)}e.consume()}let r=[];const o=[r];for(let s=0;sAV".includes(o))throw new n('Expected one of "<>AV=|." after @',i[t]);for(let e=0;e<2;e++){let r=!0;for(let l=t+1;l{const r=e.font,n=t.withFont(r);return Mt(e.body,n)},vn=(e,t)=>{const r=e.font,n=t.withFont(r);return Vt(e.body,n)},kn={"\\Bbb":"\\mathbb","\\bold":"\\mathbf","\\frak":"\\mathfrak"};mt({type:"font",names:["\\mathrm","\\mathit","\\mathbf","\\mathnormal","\\mathsfit","\\mathbb","\\mathcal","\\mathfrak","\\mathscr","\\mathsf","\\mathtt","\\Bbb","\\bold","\\frak"],props:{numArgs:1,allowedInArgument:!0},handler:(e,t)=>{let{parser:r,funcName:n}=e;const o=pt(t[0]);let s=n;return s in kn&&(s=kn[s]),{type:"font",mode:r.mode,font:s.slice(1),body:o}},htmlBuilder:wn,mathmlBuilder:vn}),mt({type:"mclass",names:["\\boldsymbol","\\bm"],props:{numArgs:1},handler:(e,t)=>{let{parser:r}=e;const n=t[0];return{type:"mclass",mode:r.mode,mclass:dr(n),body:[{type:"font",mode:r.mode,font:"boldsymbol",body:n}],isCharacterBox:m(n)}}}),mt({type:"font",names:["\\rm","\\sf","\\tt","\\bf","\\it","\\cal"],props:{numArgs:0,allowedInText:!0},handler:(e,t)=>{let{parser:r,funcName:n,breakOnTokenText:o}=e;const{mode:s}=r,i=r.parseExpression(!0,o);return{type:"font",mode:s,font:"math"+n.slice(1),body:{type:"ordgroup",mode:r.mode,body:i}}},htmlBuilder:wn,mathmlBuilder:vn});const zn=(e,t)=>{if(!t)return e;return{type:"styling",mode:e.mode,style:t,body:[e]}};mt({type:"genfrac",names:["\\cfrac","\\dfrac","\\frac","\\tfrac","\\dbinom","\\binom","\\tbinom","\\\\atopfrac","\\\\bracefrac","\\\\brackfrac"],props:{numArgs:2,allowedInArgument:!0},handler:(e,t)=>{let{parser:r,funcName:n}=e;const o=t[0],s=t[1];let i,l=null,a=null;switch(n){case"\\cfrac":case"\\dfrac":case"\\frac":case"\\tfrac":i=!0;break;case"\\\\atopfrac":i=!1;break;case"\\dbinom":case"\\binom":case"\\tbinom":i=!1,l="(",a=")";break;case"\\\\bracefrac":i=!1,l="\\{",a="\\}";break;case"\\\\brackfrac":i=!1,l="[",a="]";break;default:throw new Error("Unrecognized genfrac command")}const c="\\cfrac"===n;let h=null;return c||n.startsWith("\\d")?h="display":n.startsWith("\\t")&&(h="text"),zn({type:"genfrac",mode:r.mode,numer:o,denom:s,continued:c,hasBarLine:i,leftDelim:l,rightDelim:a,barSize:null},h)},htmlBuilder:(e,t)=>{const r=t.style,n=r.fracNum(),o=r.fracDen();let s;s=t.havingStyle(n);const i=Mt(e.numer,s,t);if(e.continued){const e=8.5/t.fontMetrics().ptPerEm,r=3.5/t.fontMetrics().ptPerEm;i.height=i.height0?3*h:7*h,p=t.fontMetrics().denom1):(c>0?(m=t.fontMetrics().num2,u=h):(m=t.fontMetrics().num3,u=3*h),p=t.fontMetrics().denom2),a){const e=t.fontMetrics().axisHeight;m-i.depth-(e+.5*c){const r=new Ct("mfrac",[Vt(e.numer,t),Vt(e.denom,t)]);if(e.hasBarLine){if(e.barSize){const n=N(e.barSize,t);r.setAttribute("linethickness",O(n))}}else r.setAttribute("linethickness","0px");if(null!=e.leftDelim||null!=e.rightDelim){const t=[];if(null!=e.leftDelim){const r=new Ct("mo",[new qt(e.leftDelim.replace("\\",""))]);r.setAttribute("fence","true"),t.push(r)}if(t.push(r),null!=e.rightDelim){const r=new Ct("mo",[new qt(e.rightDelim.replace("\\",""))]);r.setAttribute("fence","true"),t.push(r)}return Nt(t)}return r}}),mt({type:"infix",names:["\\over","\\choose","\\atop","\\brace","\\brack"],props:{numArgs:0,infix:!0},handler(e){let t,{parser:r,funcName:n,token:o}=e;switch(n){case"\\over":t="\\frac";break;case"\\choose":t="\\binom";break;case"\\atop":t="\\\\atopfrac";break;case"\\brace":t="\\\\bracefrac";break;case"\\brack":t="\\\\brackfrac";break;default:throw new Error("Unrecognized infix genfrac command")}return{type:"infix",mode:r.mode,replaceWith:t,token:o}}});const Sn=["display","text","script","scriptscript"],Mn=function(e){let t=null;return e.length>0&&(t=e,t="."===t?null:t),t};mt({type:"genfrac",names:["\\genfrac"],props:{numArgs:6,allowedInArgument:!0,argTypes:["math","math","size","text","math","math"]},handler(e,t){let{parser:r}=e;const n=t[4],o=t[5],s=pt(t[0]),i="atom"===s.type&&"open"===s.family?Mn(s.text):null,l=pt(t[1]),a="atom"===l.type&&"close"===l.family?Mn(l.text):null,c=or(t[2],"size");let h,m=null;c.isBlank?h=!0:(m=c.value,h=m.number>0);let u=null,p=t[3];if("ordgroup"===p.type){if(p.body.length>0){const e=or(p.body[0],"textord");u=Sn[Number(e.text)]}}else p=or(p,"textord"),u=Sn[Number(p.text)];return zn({type:"genfrac",mode:r.mode,numer:n,denom:o,continued:!1,hasBarLine:h,barSize:m,leftDelim:i,rightDelim:a},u)}}),mt({type:"infix",names:["\\above"],props:{numArgs:1,argTypes:["size"],infix:!0},handler(e,t){let{parser:r,funcName:n,token:o}=e;return{type:"infix",mode:r.mode,replaceWith:"\\\\abovefrac",size:or(t[0],"size").value,token:o}}}),mt({type:"genfrac",names:["\\\\abovefrac"],props:{numArgs:3,argTypes:["math","size","math"]},handler:(e,t)=>{let{parser:r,funcName:n}=e;const o=t[0],s=or(t[1],"infix").size;if(!s)throw new Error("\\\\abovefrac expected size, but got "+String(s));const i=t[2],l=s.number>0;return{type:"genfrac",mode:r.mode,numer:o,denom:i,continued:!1,hasBarLine:l,barSize:s,leftDelim:null,rightDelim:null}}});const An=(e,t)=>{const r=t.style;let n,o;"supsub"===e.type?(n=e.sup?Mt(e.sup,t.havingStyle(r.sup()),t):Mt(e.sub,t.havingStyle(r.sub()),t),o=or(e.base,"horizBrace")):o=or(e,"horizBrace");const s=Mt(o.base,t.havingBaseStyle(S.DISPLAY)),i=tr(o,t);let l;if(l=o.isOver?Ke({positionType:"firstBaseline",children:[{type:"elem",elem:s},{type:"kern",size:.1},{type:"elem",elem:i,wrapperClasses:["svg-align"]}]}):Ke({positionType:"bottom",positionData:s.depth+.1+i.height,children:[{type:"elem",elem:i,wrapperClasses:["svg-align"]},{type:"kern",size:.1},{type:"elem",elem:s}]}),n){const e=je(["minner",o.isOver?"mover":"munder"],[l],t);l=o.isOver?Ke({positionType:"firstBaseline",children:[{type:"elem",elem:e},{type:"kern",size:.2},{type:"elem",elem:n}]}):Ke({positionType:"bottom",positionData:e.depth+.2+n.height+n.depth,children:[{type:"elem",elem:n},{type:"kern",size:.2},{type:"elem",elem:e}]})}return je(["minner",o.isOver?"mover":"munder"],[l],t)};mt({type:"horizBrace",names:["\\overbrace","\\underbrace","\\overbracket","\\underbracket"],props:{numArgs:1},handler(e,t){let{parser:r,funcName:n}=e;return{type:"horizBrace",mode:r.mode,label:n,isOver:n.includes("\\over"),base:t[0]}},htmlBuilder:An,mathmlBuilder:(e,t)=>{const r=Jt(e.label);return new Ct(e.isOver?"mover":"munder",[Vt(e.base,t),r])}}),mt({type:"href",names:["\\href"],props:{numArgs:2,argTypes:["url","original"],allowedInText:!0},handler:(e,t)=>{let{parser:r}=e;const n=t[1],o=or(t[0],"url").url;return r.settings.isTrusted({command:"\\href",url:o})?{type:"href",mode:r.mode,href:o,body:dt(n)}:r.formatUnsupportedCmd("\\href")},htmlBuilder:(e,t)=>{const r=xt(e.body,t,!1);return function(e,t,r,n){const o=new X(e,t,r,n);return Ye(o),o}(e.href,[],r,t)},mathmlBuilder:(e,t)=>{let r=Ft(e.body,t);return r instanceof Ct||(r=new Ct("mrow",[r])),r.setAttribute("href",e.href),r}}),mt({type:"href",names:["\\url"],props:{numArgs:1,argTypes:["url"],allowedInText:!0},handler:(e,t)=>{let{parser:r}=e;const n=or(t[0],"url").url;if(!r.settings.isTrusted({command:"\\url",url:n}))return r.formatUnsupportedCmd("\\url");const o=[];for(let e=0;e{let{parser:r,funcName:o,token:s}=e;const i=or(t[0],"raw").string,l=t[1];let a;r.settings.strict&&r.settings.reportNonstrict("htmlExtension","HTML extension is disabled on strict mode");const c={};switch(o){case"\\htmlClass":c.class=i,a={command:"\\htmlClass",class:i};break;case"\\htmlId":c.id=i,a={command:"\\htmlId",id:i};break;case"\\htmlStyle":c.style=i,a={command:"\\htmlStyle",style:i};break;case"\\htmlData":{const e=i.split(",");for(let t=0;t{const r=xt(e.body,t,!1),n=["enclosing"];e.attributes.class&&n.push(...e.attributes.class.trim().split(/\s+/));const o=je(n,r,t);for(const t in e.attributes)"class"!==t&&e.attributes.hasOwnProperty(t)&&o.setAttribute(t,e.attributes[t]);return o},mathmlBuilder:(e,t)=>Ft(e.body,t)}),mt({type:"htmlmathml",names:["\\html@mathml"],props:{numArgs:2,allowedInArgument:!0,allowedInText:!0},handler:(e,t)=>{let{parser:r}=e;return{type:"htmlmathml",mode:r.mode,html:dt(t[0]),mathml:dt(t[1])}},htmlBuilder:(e,t)=>{const r=xt(e.html,t,!1);return $e(r)},mathmlBuilder:(e,t)=>Ft(e.mathml,t)});const Tn=function(e){if(/^[-+]? *(\d+(\.\d*)?|\.\d+)$/.test(e))return{number:+e,unit:"bp"};{const t=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(e);if(!t)throw new n("Invalid size: '"+e+"' in \\includegraphics");const r={number:+(t[1]+t[2]),unit:t[3]};if(!H(r))throw new n("Invalid unit: '"+r.unit+"' in \\includegraphics.");return r}};mt({type:"includegraphics",names:["\\includegraphics"],props:{numArgs:1,numOptionalArgs:1,argTypes:["raw","url"],allowedInText:!1},handler:(e,t,r)=>{let{parser:o}=e,s={number:0,unit:"em"},i={number:.9,unit:"em"},l={number:0,unit:"em"},a="";if(r[0]){const e=or(r[0],"raw").string.split(",");for(let t=0;t{const r=N(e.height,t);let n=0;e.totalheight.number>0&&(n=N(e.totalheight,t)-r);let o=0;e.width.number>0&&(o=N(e.width,t));const s={height:O(r+n)};o>0&&(s.width=O(o)),n>0&&(s.verticalAlign=O(-n));const i=new Y(e.src,e.alt,s);return i.height=r,i.depth=n,i},mathmlBuilder:(e,t)=>{const r=new Ct("mglyph",[]);r.setAttribute("alt",e.alt);const n=N(e.height,t);let o=0;if(e.totalheight.number>0&&(o=N(e.totalheight,t)-n,r.setAttribute("valign",O(-o))),r.setAttribute("height",O(n+o)),e.width.number>0){const n=N(e.width,t);r.setAttribute("width",O(n))}return r.setAttribute("src",e.src),r}}),mt({type:"kern",names:["\\kern","\\mkern","\\hskip","\\mskip"],props:{numArgs:1,argTypes:["size"],primitive:!0,allowedInText:!0},handler(e,t){let{parser:r,funcName:n}=e;const o=or(t[0],"size");if(r.settings.strict){const e="m"===n[1],t="mu"===o.value.unit;e?(t||r.settings.reportNonstrict("mathVsTextUnits","LaTeX's "+n+" supports only mu units, not "+o.value.unit+" units"),"math"!==r.mode&&r.settings.reportNonstrict("mathVsTextUnits","LaTeX's "+n+" works only in math mode")):t&&r.settings.reportNonstrict("mathVsTextUnits","LaTeX's "+n+" doesn't support mu units")}return{type:"kern",mode:r.mode,dimension:o.value}},htmlBuilder(e,t){return Je(e.dimension,t)},mathmlBuilder(e,t){const r=N(e.dimension,t);return new It(r)}}),mt({type:"lap",names:["\\mathllap","\\mathrlap","\\mathclap"],props:{numArgs:1,allowedInText:!0},handler:(e,t)=>{let{parser:r,funcName:n}=e;const o=t[0];return{type:"lap",mode:r.mode,alignment:n.slice(5),body:o}},htmlBuilder:(e,t)=>{let r;"clap"===e.alignment?(r=je([],[Mt(e.body,t)]),r=je(["inner"],[r],t)):r=je(["inner"],[Mt(e.body,t)]);const n=je(["fix"],[]);let o=je([e.alignment],[r,n],t);const s=je(["strut"]);return s.style.height=O(o.height+o.depth),o.depth&&(s.style.verticalAlign=O(-o.depth)),o.children.unshift(s),o=je(["thinbox"],[o],t),je(["mord","vbox"],[o],t)},mathmlBuilder:(e,t)=>{const r=new Ct("mpadded",[Vt(e.body,t)]);if("rlap"!==e.alignment){const t="llap"===e.alignment?"-1":"-0.5";r.setAttribute("lspace",t+"width")}return r.setAttribute("width","0px"),r}}),mt({type:"styling",names:["\\(","$"],props:{numArgs:0,allowedInText:!0,allowedInMath:!1},handler(e,t){let{funcName:r,parser:n}=e;const o=n.mode;n.switchMode("math");const s="\\("===r?"\\)":"$",i=n.parseExpression(!1,s);return n.expect(s),n.switchMode(o),{type:"styling",mode:n.mode,style:"text",resetFont:!0,body:i}}}),mt({type:"text",names:["\\)","\\]"],props:{numArgs:0,allowedInText:!0,allowedInMath:!1},handler(e,t){throw new n("Mismatched "+e.funcName)}});const Bn=(e,t)=>{switch(t.style.size){case S.DISPLAY.size:return e.display;case S.TEXT.size:return e.text;case S.SCRIPT.size:return e.script;case S.SCRIPTSCRIPT.size:return e.scriptscript;default:return e.text}};mt({type:"mathchoice",names:["\\mathchoice"],props:{numArgs:4,primitive:!0},handler:(e,t)=>{let{parser:r}=e;return{type:"mathchoice",mode:r.mode,display:dt(t[0]),text:dt(t[1]),script:dt(t[2]),scriptscript:dt(t[3])}},htmlBuilder:(e,t)=>{const r=Bn(e,t),n=xt(r,t,!1);return $e(n)},mathmlBuilder:(e,t)=>{const r=Bn(e,t);return Ft(r,t)}});const Cn=(e,t,r,n,o,s,i)=>{e=je([],[e]);const l=r&&m(r);let a,c,h;if(t){const e=Mt(t,n.havingStyle(o.sup()),n);c={elem:e,kern:Math.max(n.fontMetrics().bigOpSpacing1,n.fontMetrics().bigOpSpacing3-e.depth)}}if(r){const e=Mt(r,n.havingStyle(o.sub()),n);a={elem:e,kern:Math.max(n.fontMetrics().bigOpSpacing2,n.fontMetrics().bigOpSpacing4-e.height)}}if(c&&a){const t=n.fontMetrics().bigOpSpacing5+a.elem.height+a.elem.depth+a.kern+e.depth+i;h=Ke({positionType:"bottom",positionData:t,children:[{type:"kern",size:n.fontMetrics().bigOpSpacing5},{type:"elem",elem:a.elem,marginLeft:O(-s)},{type:"kern",size:a.kern},{type:"elem",elem:e},{type:"kern",size:c.kern},{type:"elem",elem:c.elem,marginLeft:O(s)},{type:"kern",size:n.fontMetrics().bigOpSpacing5}]})}else if(a){const t=e.height-i;h=Ke({positionType:"top",positionData:t,children:[{type:"kern",size:n.fontMetrics().bigOpSpacing5},{type:"elem",elem:a.elem,marginLeft:O(-s)},{type:"kern",size:a.kern},{type:"elem",elem:e}]})}else{if(!c)return e;{const t=e.depth+i;h=Ke({positionType:"bottom",positionData:t,children:[{type:"elem",elem:e},{type:"kern",size:c.kern},{type:"elem",elem:c.elem,marginLeft:O(s)},{type:"kern",size:n.fontMetrics().bigOpSpacing5}]})}}const u=[h];if(a&&0!==s&&!l){const e=je(["mspace"],[],n);e.style.marginRight=O(s),u.unshift(e)}return je(["mop","op-limits"],u,n)},qn=new Set(["\\smallint"]),In=(e,t)=>{let r,n,o,s=!1;"supsub"===e.type?(r=e.sup,n=e.sub,o=or(e.base,"op"),s=!0):o=or(e,"op");const i=t.style;let l,a,c=!1;if(i.size===S.DISPLAY.size&&o.symbol&&!qn.has(o.name)&&(c=!0),o.symbol){const e=c?"Size2-Regular":"Size1-Regular";let r="";if("\\oiint"!==o.name&&"\\oiiint"!==o.name||(r=o.name.slice(1),o.name="oiint"===r?"\\iint":"\\iiint"),l=Fe(o.name,e,"math",t,["mop","op-symbol",c?"large-op":"small-op"]),a=l.italic,r.length>0){const e=rt(r+"Size"+(c?"2":"1"),t);l=Ke({positionType:"individualShift",children:[{type:"elem",elem:l,shift:0},{type:"elem",elem:e,shift:c?.08:0}]}),o.name="\\"+r,l.classes.unshift("mop"),l.italic=a}}else if(o.body){const e=xt(o.body,t,!0);1===e.length&&e[0]instanceof W?(l=e[0],l.classes[0]="mop"):l=je(["mop"],e,t)}else{const e=[];for(let r=1;r{let r;if(e.symbol)r=new Ct("mo",[Ht(e.name,e.mode)]),qn.has(e.name)&&r.setAttribute("largeop","false");else if(e.body)r=new Ct("mo",Pt(e.body,t));else{r=new Ct("mi",[new qt(e.name.slice(1))]);const t=new Ct("mo",[Ht("\u2061","text")]);r=e.parentIsSupSub?new Ct("mrow",[r,t]):Bt([r,t])}return r},En={"\u220f":"\\prod","\u2210":"\\coprod","\u2211":"\\sum","\u22c0":"\\bigwedge","\u22c1":"\\bigvee","\u22c2":"\\bigcap","\u22c3":"\\bigcup","\u2a00":"\\bigodot","\u2a01":"\\bigoplus","\u2a02":"\\bigotimes","\u2a04":"\\biguplus","\u2a06":"\\bigsqcup"};mt({type:"op",names:["\\coprod","\\bigvee","\\bigwedge","\\biguplus","\\bigcap","\\bigcup","\\intop","\\prod","\\sum","\\bigotimes","\\bigoplus","\\bigodot","\\bigsqcup","\\smallint","\u220f","\u2210","\u2211","\u22c0","\u22c1","\u22c2","\u22c3","\u2a00","\u2a01","\u2a02","\u2a04","\u2a06"],props:{numArgs:0},handler:(e,t)=>{let{parser:r,funcName:n}=e,o=n;return 1===o.length&&(o=En[o]),{type:"op",mode:r.mode,limits:!0,parentIsSupSub:!1,symbol:!0,name:o}},htmlBuilder:In,mathmlBuilder:Rn}),mt({type:"op",names:["\\mathop"],props:{numArgs:1,primitive:!0},handler:(e,t)=>{let{parser:r}=e;const n=t[0];return{type:"op",mode:r.mode,limits:!1,parentIsSupSub:!1,symbol:!1,body:dt(n)}},htmlBuilder:In,mathmlBuilder:Rn});const Hn={"\u222b":"\\int","\u222c":"\\iint","\u222d":"\\iiint","\u222e":"\\oint","\u222f":"\\oiint","\u2230":"\\oiiint"};mt({type:"op",names:["\\arcsin","\\arccos","\\arctan","\\arctg","\\arcctg","\\arg","\\ch","\\cos","\\cosec","\\cosh","\\cot","\\cotg","\\coth","\\csc","\\ctg","\\cth","\\deg","\\dim","\\exp","\\hom","\\ker","\\lg","\\ln","\\log","\\sec","\\sin","\\sinh","\\sh","\\tan","\\tanh","\\tg","\\th"],props:{numArgs:0},handler(e){let{parser:t,funcName:r}=e;return{type:"op",mode:t.mode,limits:!1,parentIsSupSub:!1,symbol:!1,name:r}},htmlBuilder:In,mathmlBuilder:Rn}),mt({type:"op",names:["\\det","\\gcd","\\inf","\\lim","\\max","\\min","\\Pr","\\sup"],props:{numArgs:0},handler(e){let{parser:t,funcName:r}=e;return{type:"op",mode:t.mode,limits:!0,parentIsSupSub:!1,symbol:!1,name:r}},htmlBuilder:In,mathmlBuilder:Rn}),mt({type:"op",names:["\\int","\\iint","\\iiint","\\oint","\\oiint","\\oiiint","\u222b","\u222c","\u222d","\u222e","\u222f","\u2230"],props:{numArgs:0,allowedInArgument:!0},handler(e){let{parser:t,funcName:r}=e,n=r;return 1===n.length&&(n=Hn[n]),{type:"op",mode:t.mode,limits:!1,parentIsSupSub:!1,symbol:!0,name:n}},htmlBuilder:In,mathmlBuilder:Rn});const Nn=(e,t)=>{let r,n,o,s,i=!1;if("supsub"===e.type?(r=e.sup,n=e.sub,o=or(e.base,"operatorname"),i=!0):o=or(e,"operatorname"),o.body.length>0){const e=o.body.map(e=>{const t="text"in e?e.text:void 0;return"string"==typeof t?{type:"textord",mode:e.mode,text:t}:e}),r=xt(e,t.withFont("mathrm"),!0);for(let e=0;e{let{parser:r,funcName:n}=e;const o=t[0];return{type:"operatorname",mode:r.mode,body:dt(o),alwaysHandleSupSub:"\\operatornamewithlimits"===n,limits:!1,parentIsSupSub:!1}},htmlBuilder:Nn,mathmlBuilder:(e,t)=>{let r=Pt(e.body,t.withFont("mathrm")),n=!0;for(let e=0;ee.toText()).join("");r=[new qt(e)]}const o=new Ct("mi",r);o.setAttribute("mathvariant","normal");const s=new Ct("mo",[Ht("\u2061","text")]);return e.parentIsSupSub?new Ct("mrow",[o,s]):Bt([o,s])}}),sn("\\operatorname","\\@ifstar\\operatornamewithlimits\\operatorname@"),ut({type:"ordgroup",htmlBuilder(e,t){return e.semisimple?$e(xt(e.body,t,!1)):je(["mord"],xt(e.body,t,!0),t)},mathmlBuilder(e,t){return Ft(e.body,t,!0)}}),mt({type:"overline",names:["\\overline"],props:{numArgs:1},handler(e,t){let{parser:r}=e;const n=t[0];return{type:"overline",mode:r.mode,body:n}},htmlBuilder(e,t){const r=Mt(e.body,t.havingCrampedStyle()),n=_e("overline-line",t),o=t.fontMetrics().defaultRuleThickness,s=Ke({positionType:"firstBaseline",children:[{type:"elem",elem:r},{type:"kern",size:3*o},{type:"elem",elem:n},{type:"kern",size:o}]});return je(["mord","overline"],[s],t)},mathmlBuilder(e,t){const r=new Ct("mo",[new qt("\u203e")]);r.setAttribute("stretchy","true");const n=new Ct("mover",[Vt(e.body,t),r]);return n.setAttribute("accent","true"),n}}),mt({type:"phantom",names:["\\phantom"],props:{numArgs:1,allowedInText:!0},handler:(e,t)=>{let{parser:r}=e;const n=t[0];return{type:"phantom",mode:r.mode,body:dt(n)}},htmlBuilder:(e,t)=>{const r=xt(e.body,t.withPhantom(),!1);return $e(r)},mathmlBuilder:(e,t)=>{const r=Pt(e.body,t);return new Ct("mphantom",r)}}),sn("\\hphantom","\\smash{\\phantom{#1}}"),mt({type:"vphantom",names:["\\vphantom"],props:{numArgs:1,allowedInText:!0},handler:(e,t)=>{let{parser:r}=e;const n=t[0];return{type:"vphantom",mode:r.mode,body:n}},htmlBuilder:(e,t)=>{const r=je(["inner"],[Mt(e.body,t.withPhantom())]),n=je(["fix"],[]);return je(["mord","rlap"],[r,n],t)},mathmlBuilder:(e,t)=>{const r=Pt(dt(e.body),t),n=new Ct("mphantom",r),o=new Ct("mpadded",[n]);return o.setAttribute("width","0px"),o}}),mt({type:"raisebox",names:["\\raisebox"],props:{numArgs:2,argTypes:["size","hbox"],allowedInText:!0},handler(e,t){let{parser:r}=e;const n=or(t[0],"size").value,o=t[1];return{type:"raisebox",mode:r.mode,dy:n,body:o}},htmlBuilder(e,t){const r=Mt(e.body,t),n=N(e.dy,t);return Ke({positionType:"shift",positionData:-n,children:[{type:"elem",elem:r}]})},mathmlBuilder(e,t){const r=new Ct("mpadded",[Vt(e.body,t)]),n=e.dy.number+e.dy.unit;return r.setAttribute("voffset",n),r}}),mt({type:"internal",names:["\\relax"],props:{numArgs:0,allowedInText:!0,allowedInArgument:!0},handler(e){let{parser:t}=e;return{type:"internal",mode:t.mode}}}),mt({type:"rule",names:["\\rule"],props:{numArgs:2,numOptionalArgs:1,allowedInText:!0,allowedInMath:!0,argTypes:["size","size","size"]},handler(e,t,r){let{parser:n}=e;const o=r[0],s=or(t[0],"size"),i=or(t[1],"size");return{type:"rule",mode:n.mode,shift:o&&or(o,"size").value,width:s.value,height:i.value}},htmlBuilder(e,t){const r=je(["mord","rule"],[],t),n=N(e.width,t),o=N(e.height,t),s=e.shift?N(e.shift,t):0;return r.style.borderRightWidth=O(n),r.style.borderTopWidth=O(o),r.style.bottom=O(s),r.width=n,r.height=o+s,r.depth=-s,r.maxFontSize=1.125*o*t.sizeMultiplier,r},mathmlBuilder(e,t){const r=N(e.width,t),n=N(e.height,t),o=e.shift?N(e.shift,t):0,s=t.color&&t.getColor()||"black",i=new Ct("mspace");i.setAttribute("mathbackground",s),i.setAttribute("width",O(r)),i.setAttribute("height",O(n));const l=new Ct("mpadded",[i]);return o>=0?l.setAttribute("height",O(o)):(l.setAttribute("height",O(o)),l.setAttribute("depth",O(-o))),l.setAttribute("voffset",O(o)),l}});const Dn=["\\tiny","\\sixptsize","\\scriptsize","\\footnotesize","\\small","\\normalsize","\\large","\\Large","\\LARGE","\\huge","\\Huge"];mt({type:"sizing",names:Dn,props:{numArgs:0,allowedInText:!0},handler:(e,t)=>{let{breakOnTokenText:r,funcName:n,parser:o}=e;const s=o.parseExpression(!1,r);return{type:"sizing",mode:o.mode,size:Dn.indexOf(n)+1,body:s}},htmlBuilder:(e,t)=>{const r=t.havingSize(e.size);return On(e.body,r,t)},mathmlBuilder:(e,t)=>{const r=t.havingSize(e.size),n=Pt(e.body,r),o=new Ct("mstyle",n);return o.setAttribute("mathsize",O(r.sizeMultiplier)),o}}),mt({type:"smash",names:["\\smash"],props:{numArgs:1,numOptionalArgs:1,allowedInText:!0},handler:(e,t,r)=>{let{parser:n}=e,o=!1,s=!1;const i=r[0]&&or(r[0],"ordgroup");if(i){let e;for(let t=0;t{const r=je([],[Mt(e.body,t)]);if(!e.smashHeight&&!e.smashDepth)return r;if(e.smashHeight&&(r.height=0),e.smashDepth&&(r.depth=0),e.smashHeight&&e.smashDepth)return je(["mord","smash"],[r],t);if(r.children)for(let t=0;t{const r=new Ct("mpadded",[Vt(e.body,t)]);return e.smashHeight&&r.setAttribute("height","0px"),e.smashDepth&&r.setAttribute("depth","0px"),r}}),mt({type:"sqrt",names:["\\sqrt"],props:{numArgs:1,numOptionalArgs:1},handler(e,t,r){let{parser:n}=e;const o=r[0],s=t[0];return{type:"sqrt",mode:n.mode,body:s,index:o}},htmlBuilder(e,t){let r=Mt(e.body,t.havingCrampedStyle());0===r.height&&(r.height=t.fontMetrics().xHeight),r=Ze(r,t);const n=t.fontMetrics().defaultRuleThickness;let o=n;t.style.idr.height+r.depth+s&&(s=(s+h-r.height-r.depth)/2);const m=l.height-r.height-s-a;r.style.paddingLeft=O(c);const u=Ke({positionType:"firstBaseline",children:[{type:"elem",elem:r,wrapperClasses:["svg-align"]},{type:"kern",size:-(r.height+m)},{type:"elem",elem:l},{type:"kern",size:a}]});if(e.index){const r=t.havingStyle(S.SCRIPTSCRIPT),n=Mt(e.index,r,t),o=.6*(u.height-u.depth),s=Ke({positionType:"shift",positionData:-o,children:[{type:"elem",elem:n}]}),i=je(["root"],[s]);return je(["mord","sqrt"],[i,u],t)}return je(["mord","sqrt"],[u],t)},mathmlBuilder(e,t){const{body:r,index:n}=e;return n?new Ct("mroot",[Vt(r,t),Vt(n,t)]):new Ct("msqrt",[Vt(r,t)])}});const Ln={display:S.DISPLAY,text:S.TEXT,script:S.SCRIPT,scriptscript:S.SCRIPTSCRIPT};mt({type:"styling",names:["\\displaystyle","\\textstyle","\\scriptstyle","\\scriptscriptstyle"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler(e,t){let{breakOnTokenText:r,funcName:n,parser:o}=e;const s=o.parseExpression(!0,r),i=n.slice(1,n.length-5);if(!(i in Ln))throw new Error("Unknown style: "+i);return{type:"styling",mode:o.mode,style:i,body:s}},htmlBuilder(e,t){const r=Ln[e.style];let n=t.havingStyle(r);return e.resetFont&&(n=n.withFont("")),On(e.body,n,t)},mathmlBuilder(e,t){const r=Ln[e.style];let n=t.havingStyle(r);e.resetFont&&(n=n.withFont(""));const o=Pt(e.body,n),s=new Ct("mstyle",o),i={display:["0","true"],text:["0","false"],script:["1","false"],scriptscript:["2","false"]}[e.style];return s.setAttribute("scriptlevel",i[0]),s.setAttribute("displaystyle",i[1]),s}});ut({type:"supsub",htmlBuilder(e,t){const r=function(e,t){const r=e.base;if(r)return"op"===r.type?r.limits&&(t.style.size===S.DISPLAY.size||r.alwaysHandleSupSub)?In:null:"operatorname"===r.type?r.alwaysHandleSupSub&&(t.style.size===S.DISPLAY.size||r.limits)?Nn:null:"accent"===r.type?m(r.base)?ar:null:"horizBrace"===r.type&&!e.sub===r.isOver?An:null;return null}(e,t);if(r)return r(e,t);const{base:n,sup:o,sub:s}=e,i=Mt(n,t);let l,a;const c=t.fontMetrics();let h=0,u=0;const p=n&&m(n);if(o){const e=t.havingStyle(t.style.sup());l=Mt(o,e,t),p||(h=i.height-e.fontMetrics().supDrop*e.sizeMultiplier/t.sizeMultiplier)}if(s){const e=t.havingStyle(t.style.sub());a=Mt(s,e,t),p||(u=i.depth+e.fontMetrics().subDrop*e.sizeMultiplier/t.sizeMultiplier)}let d;d=t.style===S.DISPLAY?c.sup1:t.style.cramped?c.sup3:c.sup2;const g=t.sizeMultiplier,f=O(.5/c.ptPerEm/g);let b,y=null;if(a){const t=e.base&&"op"===e.base.type&&e.base.name&&("\\oiint"===e.base.name||"\\oiiint"===e.base.name);var x;if(i instanceof W||t)y=O(-(null!=(x=i.italic)?x:0))}if(l&&a){h=Math.max(h,d,l.depth+.25*c.xHeight),u=Math.max(u,c.sub2);const e=4*c.defaultRuleThickness;if(h-l.depth-(a.height-u)0&&(h+=t,u-=t)}b=Ke({positionType:"individualShift",children:[{type:"elem",elem:a,shift:u,marginRight:f,marginLeft:y},{type:"elem",elem:l,shift:-h,marginRight:f}]})}else if(a){u=Math.max(u,c.sub1,a.height-.8*c.xHeight);b=Ke({positionType:"shift",positionData:u,children:[{type:"elem",elem:a,marginLeft:y,marginRight:f}]})}else{if(!l)throw new Error("supsub must have either sup or sub.");h=Math.max(h,d,l.depth+.25*c.xHeight),b=Ke({positionType:"shift",positionData:-h,children:[{type:"elem",elem:l,marginRight:f}]})}const w=zt(i,"right")||"mord";return je([w],[i,je(["msupsub"],[b])],t)},mathmlBuilder(e,t){let r,n,o=!1;e.base&&"horizBrace"===e.base.type&&(n=!!e.sup,n===e.base.isOver&&(o=!0,r=e.base.isOver)),!e.base||"op"!==e.base.type&&"operatorname"!==e.base.type||(e.base.parentIsSupSub=!0);const s=[Vt(e.base,t)];let i;if(e.sub&&s.push(Vt(e.sub,t)),e.sup&&s.push(Vt(e.sup,t)),o)i=r?"mover":"munder";else if(e.sub)if(e.sup){const r=e.base;i=r&&"op"===r.type&&r.limits&&t.style===S.DISPLAY||r&&"operatorname"===r.type&&r.alwaysHandleSupSub&&(t.style===S.DISPLAY||r.limits)?"munderover":"msubsup"}else{const r=e.base;i=r&&"op"===r.type&&r.limits&&(t.style===S.DISPLAY||r.alwaysHandleSupSub)||r&&"operatorname"===r.type&&r.alwaysHandleSupSub&&(r.limits||t.style===S.DISPLAY)?"munder":"msub"}else{const r=e.base;i=r&&"op"===r.type&&r.limits&&(t.style===S.DISPLAY||r.alwaysHandleSupSub)||r&&"operatorname"===r.type&&r.alwaysHandleSupSub&&(r.limits||t.style===S.DISPLAY)?"mover":"msup"}return new Ct(i,s)}}),ut({type:"atom",htmlBuilder(e,t){return Ve(e.text,e.mode,t,["m"+e.family])},mathmlBuilder(e,t){const r=new Ct("mo",[Ht(e.text,e.mode)]);if("bin"===e.family){const n=Dt(e,t);"bold-italic"===n&&r.setAttribute("mathvariant",n)}else"punct"===e.family?r.setAttribute("separator","true"):"open"!==e.family&&"close"!==e.family||r.setAttribute("stretchy","false");return r}});const Pn={mi:"italic",mn:"normal",mtext:"normal"};ut({type:"mathord",htmlBuilder(e,t){return Ge(e,t,"mathord")},mathmlBuilder(e,t){const r=new Ct("mi",[Ht(e.text,e.mode,t)]),n=Dt(e,t)||"italic";return n!==Pn[r.type]&&r.setAttribute("mathvariant",n),r}}),ut({type:"textord",htmlBuilder(e,t){return Ge(e,t,"textord")},mathmlBuilder(e,t){const r=Ht(e.text,e.mode,t),n=Dt(e,t)||"normal";let o;return o="text"===e.mode?new Ct("mtext",[r]):/[0-9]/.test(e.text)?new Ct("mn",[r]):"\\prime"===e.text?new Ct("mo",[r]):new Ct("mi",[r]),n!==Pn[o.type]&&o.setAttribute("mathvariant",n),o}});const Fn={"\\nobreak":"nobreak","\\allowbreak":"allowbreak"},Vn={" ":{},"\\ ":{},"~":{className:"nobreak"},"\\space":{},"\\nobreakspace":{className:"nobreak"}};ut({type:"spacing",htmlBuilder(e,t){if(Vn.hasOwnProperty(e.text)){const r=Vn[e.text].className||"";if("text"===e.mode){const n=Ge(e,t,"textord");return n.classes.push(r),n}return je(["mspace",r],[Ve(e.text,e.mode,t)],t)}if(Fn.hasOwnProperty(e.text))return je(["mspace",Fn[e.text]],[],t);throw new n('Unknown type of space "'+e.text+'"')},mathmlBuilder(e,t){let r;if(!Vn.hasOwnProperty(e.text)){if(Fn.hasOwnProperty(e.text))return new Ct("mspace");throw new n('Unknown type of space "'+e.text+'"')}return r=new Ct("mtext",[new qt("\xa0")]),r}});const Gn=()=>{const e=new Ct("mtd",[]);return e.setAttribute("width","50%"),e};ut({type:"tag",mathmlBuilder(e,t){const r=new Ct("mtable",[new Ct("mtr",[Gn(),new Ct("mtd",[Ft(e.body,t)]),Gn(),new Ct("mtd",[Ft(e.tag,t)])])]);return r.setAttribute("width","100%"),r}});const Un={"\\text":void 0,"\\textrm":"textrm","\\textsf":"textsf","\\texttt":"texttt","\\textnormal":"textrm"},Xn={"\\textbf":"textbf","\\textmd":"textmd"},Yn={"\\textit":"textit","\\textup":"textup"},jn=(e,t)=>{const r=e.font;return r?Un[r]?t.withTextFontFamily(Un[r]):Xn[r]?t.withTextFontWeight(Xn[r]):"\\emph"===r?"textit"===t.fontShape?t.withTextFontShape("textup"):t.withTextFontShape("textit"):t.withTextFontShape(Yn[r]):t};mt({type:"text",names:["\\text","\\textrm","\\textsf","\\texttt","\\textnormal","\\textbf","\\textmd","\\textit","\\textup","\\emph"],props:{numArgs:1,argTypes:["text"],allowedInArgument:!0,allowedInText:!0},handler(e,t){let{parser:r,funcName:n}=e;const o=t[0];return{type:"text",mode:r.mode,body:dt(o),font:n}},htmlBuilder(e,t){const r=jn(e,t),n=xt(e.body,r,!0);return je(["mord","text"],n,r)},mathmlBuilder(e,t){const r=jn(e,t);return Ft(e.body,r)}}),mt({type:"underline",names:["\\underline"],props:{numArgs:1,allowedInText:!0},handler(e,t){let{parser:r}=e;return{type:"underline",mode:r.mode,body:t[0]}},htmlBuilder(e,t){const r=Mt(e.body,t),n=_e("underline-line",t),o=t.fontMetrics().defaultRuleThickness,s=Ke({positionType:"top",positionData:r.height,children:[{type:"kern",size:o},{type:"elem",elem:n},{type:"kern",size:3*o},{type:"elem",elem:r}]});return je(["mord","underline"],[s],t)},mathmlBuilder(e,t){const r=new Ct("mo",[new qt("\u203e")]);r.setAttribute("stretchy","true");const n=new Ct("munder",[Vt(e.body,t),r]);return n.setAttribute("accentunder","true"),n}}),mt({type:"vcenter",names:["\\vcenter"],props:{numArgs:1,argTypes:["original"],allowedInText:!1},handler(e,t){let{parser:r}=e;return{type:"vcenter",mode:r.mode,body:t[0]}},htmlBuilder(e,t){const r=Mt(e.body,t),n=t.fontMetrics().axisHeight,o=.5*(r.height-n-(r.depth+n));return Ke({positionType:"shift",positionData:o,children:[{type:"elem",elem:r}]})},mathmlBuilder(e,t){const r=new Ct("mpadded",[Vt(e.body,t)],["vcenter"]);return new Ct("mrow",[r])}}),mt({type:"verb",names:["\\verb"],props:{numArgs:0,allowedInText:!0},handler(e,t,r){throw new n("\\verb ended by end of line instead of matching delimiter")},htmlBuilder(e,t){const r=Wn(e),n=[],o=t.havingStyle(t.style.text());for(let t=0;te.body.replace(/ /g,e.star?"\u2423":"\xa0");var _n=at;const $n="[ \r\n\t]",Zn="(\\\\[a-zA-Z@]+)"+$n+"*",Kn="[\u0300-\u036f]",Jn=new RegExp(Kn+"+$"),Qn="("+$n+"+)|\\\\(\n|[ \r\t]+\n?)[ \r\t]*|([!-\\[\\]-\u2027\u202a-\ud7ff\uf900-\uffff]"+Kn+"*|[\ud800-\udbff][\udc00-\udfff]"+Kn+"*|\\\\verb\\*([^]).*?\\4|\\\\verb([^*a-zA-Z]).*?\\5|"+Zn+"|\\\\[^\ud800-\udfff])";class eo{constructor(e,t){this.input=void 0,this.settings=void 0,this.tokenRegex=void 0,this.catcodes=void 0,this.input=e,this.settings=t,this.tokenRegex=new RegExp(Qn,"g"),this.catcodes={"%":14,"~":13}}setCatcode(e,t){this.catcodes[e]=t}lex(){const e=this.input,t=this.tokenRegex.lastIndex;if(t===e.length)return new an("EOF",new ln(this,t,t));const r=this.tokenRegex.exec(e);if(null===r||r.index!==t)throw new n("Unexpected character: '"+e[t]+"'",new an(e[t],new ln(this,t,t+1)));const o=r[6]||r[3]||(r[2]?"\\ ":" ");if(14===this.catcodes[o]){const t=e.indexOf("\n",this.tokenRegex.lastIndex);return-1===t?(this.tokenRegex.lastIndex=e.length,this.settings.reportNonstrict("commentAtEnd","% comment has no terminating newline; LaTeX would fail because of commenting the end of math mode (e.g. $)")):this.tokenRegex.lastIndex=t+1,this.lex()}return new an(o,new ln(this,t,this.tokenRegex.lastIndex))}}class to{constructor(e,t){void 0===e&&(e={}),void 0===t&&(t={}),this.current=void 0,this.builtins=void 0,this.undefStack=void 0,this.current=t,this.builtins=e,this.undefStack=[]}beginGroup(){this.undefStack.push({})}endGroup(){if(0===this.undefStack.length)throw new n("Unbalanced namespace destruction: attempt to pop global namespace; please report this as a bug");const e=this.undefStack.pop();for(const t in e)e.hasOwnProperty(t)&&(null==e[t]?delete this.current[t]:this.current[t]=e[t])}endGroups(){for(;this.undefStack.length>0;)this.endGroup()}has(e){return this.current.hasOwnProperty(e)||this.builtins.hasOwnProperty(e)}get(e){return this.current.hasOwnProperty(e)?this.current[e]:this.builtins[e]}set(e,t,r){if(void 0===r&&(r=!1),r){for(let t=0;t0&&(this.undefStack[this.undefStack.length-1][e]=t)}else{const t=this.undefStack[this.undefStack.length-1];t&&!t.hasOwnProperty(e)&&(t[e]=this.current[e])}null==t?delete this.current[e]:this.current[e]=t}}var ro=on;sn("\\noexpand",function(e){const t=e.popToken();return e.isExpandable(t.text)&&(t.noexpand=!0,t.treatAsRelax=!0),{tokens:[t],numArgs:0}}),sn("\\expandafter",function(e){const t=e.popToken();return e.expandOnce(!0),{tokens:[t],numArgs:0}}),sn("\\@firstoftwo",function(e){return{tokens:e.consumeArgs(2)[0],numArgs:0}}),sn("\\@secondoftwo",function(e){return{tokens:e.consumeArgs(2)[1],numArgs:0}}),sn("\\@ifnextchar",function(e){const t=e.consumeArgs(3);e.consumeSpaces();const r=e.future();return 1===t[0].length&&t[0][0].text===r.text?{tokens:t[1],numArgs:0}:{tokens:t[2],numArgs:0}}),sn("\\@ifstar","\\@ifnextchar *{\\@firstoftwo{#1}}"),sn("\\TextOrMath",function(e){const t=e.consumeArgs(2);return"text"===e.mode?{tokens:t[0],numArgs:0}:{tokens:t[1],numArgs:0}});const no={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,A:10,b:11,B:11,c:12,C:12,d:13,D:13,e:14,E:14,f:15,F:15};sn("\\char",function(e){let t,r=e.popToken(),o=0;if("'"===r.text)t=8,r=e.popToken();else if('"'===r.text)t=16,r=e.popToken();else if("`"===r.text)if(r=e.popToken(),"\\"===r.text[0])o=r.text.charCodeAt(1);else{if("EOF"===r.text)throw new n("\\char` missing argument");o=r.text.charCodeAt(0)}else t=10;if(t){if(o=no[r.text],null==o||o>=t)throw new n("Invalid base-"+t+" digit "+r.text);let s;for(;null!=(s=no[e.future().text])&&s{let s=e.consumeArg().tokens;if(1!==s.length)throw new n("\\newcommand's first argument must be a macro name");const i=s[0].text,l=e.isDefined(i);if(l&&!t)throw new n("\\newcommand{"+i+"} attempting to redefine "+i+"; use \\renewcommand");if(!l&&!r)throw new n("\\renewcommand{"+i+"} when command "+i+" does not yet exist; use \\newcommand");let a=0;if(s=e.consumeArg().tokens,1===s.length&&"["===s[0].text){let t="",r=e.expandNextToken();for(;"]"!==r.text&&"EOF"!==r.text;)t+=r.text,r=e.expandNextToken();if(!t.match(/^\s*[0-9]+\s*$/))throw new n("Invalid number of arguments: "+t);a=parseInt(t),s=e.consumeArg().tokens}return l&&o||e.macros.set(i,{tokens:s,numArgs:a}),""};sn("\\newcommand",e=>oo(e,!1,!0,!1)),sn("\\renewcommand",e=>oo(e,!0,!1,!1)),sn("\\providecommand",e=>oo(e,!0,!0,!0)),sn("\\message",e=>{const t=e.consumeArgs(1)[0];return console.log(t.reverse().map(e=>e.text).join("")),""}),sn("\\errmessage",e=>{const t=e.consumeArgs(1)[0];return console.error(t.reverse().map(e=>e.text).join("")),""}),sn("\\show",e=>{const t=e.popToken(),r=t.text;return console.log(t,e.macros.get(r),_n[r],ne.math[r],ne.text[r]),""}),sn("\\bgroup","{"),sn("\\egroup","}"),sn("~","\\nobreakspace"),sn("\\lq","`"),sn("\\rq","'"),sn("\\aa","\\r a"),sn("\\AA","\\r A"),sn("\\textcopyright","\\html@mathml{\\textcircled{c}}{\\char`\xa9}"),sn("\\copyright","\\TextOrMath{\\textcopyright}{\\text{\\textcopyright}}"),sn("\\textregistered","\\html@mathml{\\textcircled{\\scriptsize R}}{\\char`\xae}"),sn("\u212c","\\mathscr{B}"),sn("\u2130","\\mathscr{E}"),sn("\u2131","\\mathscr{F}"),sn("\u210b","\\mathscr{H}"),sn("\u2110","\\mathscr{I}"),sn("\u2112","\\mathscr{L}"),sn("\u2133","\\mathscr{M}"),sn("\u211b","\\mathscr{R}"),sn("\u212d","\\mathfrak{C}"),sn("\u210c","\\mathfrak{H}"),sn("\u2128","\\mathfrak{Z}"),sn("\\Bbbk","\\Bbb{k}"),sn("\\llap","\\mathllap{\\textrm{#1}}"),sn("\\rlap","\\mathrlap{\\textrm{#1}}"),sn("\\clap","\\mathclap{\\textrm{#1}}"),sn("\\mathstrut","\\vphantom{(}"),sn("\\underbar","\\underline{\\text{#1}}"),sn("\\not",'\\html@mathml{\\mathrel{\\mathrlap\\@not}\\nobreak}{\\char"338}'),sn("\\neq","\\html@mathml{\\mathrel{\\not=}}{\\mathrel{\\char`\u2260}}"),sn("\\ne","\\neq"),sn("\u2260","\\neq"),sn("\\notin","\\html@mathml{\\mathrel{{\\in}\\mathllap{/\\mskip1mu}}}{\\mathrel{\\char`\u2209}}"),sn("\u2209","\\notin"),sn("\u2258","\\html@mathml{\\mathrel{=\\kern{-1em}\\raisebox{0.4em}{$\\scriptsize\\frown$}}}{\\mathrel{\\char`\u2258}}"),sn("\u2259","\\html@mathml{\\stackrel{\\tiny\\wedge}{=}}{\\mathrel{\\char`\u2258}}"),sn("\u225a","\\html@mathml{\\stackrel{\\tiny\\vee}{=}}{\\mathrel{\\char`\u225a}}"),sn("\u225b","\\html@mathml{\\stackrel{\\scriptsize\\star}{=}}{\\mathrel{\\char`\u225b}}"),sn("\u225d","\\html@mathml{\\stackrel{\\tiny\\mathrm{def}}{=}}{\\mathrel{\\char`\u225d}}"),sn("\u225e","\\html@mathml{\\stackrel{\\tiny\\mathrm{m}}{=}}{\\mathrel{\\char`\u225e}}"),sn("\u225f","\\html@mathml{\\stackrel{\\tiny?}{=}}{\\mathrel{\\char`\u225f}}"),sn("\u27c2","\\perp"),sn("\u203c","\\mathclose{!\\mkern-0.8mu!}"),sn("\u220c","\\notni"),sn("\u231c","\\ulcorner"),sn("\u231d","\\urcorner"),sn("\u231e","\\llcorner"),sn("\u231f","\\lrcorner"),sn("\xa9","\\copyright"),sn("\xae","\\textregistered"),sn("\\ulcorner",'\\html@mathml{\\@ulcorner}{\\mathop{\\char"231c}}'),sn("\\urcorner",'\\html@mathml{\\@urcorner}{\\mathop{\\char"231d}}'),sn("\\llcorner",'\\html@mathml{\\@llcorner}{\\mathop{\\char"231e}}'),sn("\\lrcorner",'\\html@mathml{\\@lrcorner}{\\mathop{\\char"231f}}'),sn("\\vdots","{\\varvdots\\rule{0pt}{15pt}}"),sn("\u22ee","\\vdots"),sn("\\varGamma","\\mathit{\\Gamma}"),sn("\\varDelta","\\mathit{\\Delta}"),sn("\\varTheta","\\mathit{\\Theta}"),sn("\\varLambda","\\mathit{\\Lambda}"),sn("\\varXi","\\mathit{\\Xi}"),sn("\\varPi","\\mathit{\\Pi}"),sn("\\varSigma","\\mathit{\\Sigma}"),sn("\\varUpsilon","\\mathit{\\Upsilon}"),sn("\\varPhi","\\mathit{\\Phi}"),sn("\\varPsi","\\mathit{\\Psi}"),sn("\\varOmega","\\mathit{\\Omega}"),sn("\\substack","\\begin{subarray}{c}#1\\end{subarray}"),sn("\\colon","\\nobreak\\mskip2mu\\mathpunct{}\\mathchoice{\\mkern-3mu}{\\mkern-3mu}{}{}{:}\\mskip6mu\\relax"),sn("\\boxed","\\fbox{$\\displaystyle{#1}$}"),sn("\\iff","\\DOTSB\\;\\Longleftrightarrow\\;"),sn("\\implies","\\DOTSB\\;\\Longrightarrow\\;"),sn("\\impliedby","\\DOTSB\\;\\Longleftarrow\\;"),sn("\\dddot","{\\overset{\\raisebox{-0.1ex}{\\normalsize ...}}{#1}}"),sn("\\ddddot","{\\overset{\\raisebox{-0.1ex}{\\normalsize ....}}{#1}}");const so={",":"\\dotsc","\\not":"\\dotsb","+":"\\dotsb","=":"\\dotsb","<":"\\dotsb",">":"\\dotsb","-":"\\dotsb","*":"\\dotsb",":":"\\dotsb","\\DOTSB":"\\dotsb","\\coprod":"\\dotsb","\\bigvee":"\\dotsb","\\bigwedge":"\\dotsb","\\biguplus":"\\dotsb","\\bigcap":"\\dotsb","\\bigcup":"\\dotsb","\\prod":"\\dotsb","\\sum":"\\dotsb","\\bigotimes":"\\dotsb","\\bigoplus":"\\dotsb","\\bigodot":"\\dotsb","\\bigsqcup":"\\dotsb","\\And":"\\dotsb","\\longrightarrow":"\\dotsb","\\Longrightarrow":"\\dotsb","\\longleftarrow":"\\dotsb","\\Longleftarrow":"\\dotsb","\\longleftrightarrow":"\\dotsb","\\Longleftrightarrow":"\\dotsb","\\mapsto":"\\dotsb","\\longmapsto":"\\dotsb","\\hookrightarrow":"\\dotsb","\\doteq":"\\dotsb","\\mathbin":"\\dotsb","\\mathrel":"\\dotsb","\\relbar":"\\dotsb","\\Relbar":"\\dotsb","\\xrightarrow":"\\dotsb","\\xleftarrow":"\\dotsb","\\DOTSI":"\\dotsi","\\int":"\\dotsi","\\oint":"\\dotsi","\\iint":"\\dotsi","\\iiint":"\\dotsi","\\iiiint":"\\dotsi","\\idotsint":"\\dotsi","\\DOTSX":"\\dotsx"},io=new Set(["bin","rel"]);sn("\\dots",function(e){let t="\\dotso";const r=e.expandAfterFuture().text;return r in so?t=so[r]:("\\not"===r.slice(0,4)||r in ne.math&&io.has(ne.math[r].group))&&(t="\\dotsb"),t});const lo={")":!0,"]":!0,"\\rbrack":!0,"\\}":!0,"\\rbrace":!0,"\\rangle":!0,"\\rceil":!0,"\\rfloor":!0,"\\rgroup":!0,"\\rmoustache":!0,"\\right":!0,"\\bigr":!0,"\\biggr":!0,"\\Bigr":!0,"\\Biggr":!0,$:!0,";":!0,".":!0,",":!0};sn("\\dotso",function(e){return e.future().text in lo?"\\ldots\\,":"\\ldots"}),sn("\\dotsc",function(e){const t=e.future().text;return t in lo&&","!==t?"\\ldots\\,":"\\ldots"}),sn("\\cdots",function(e){return e.future().text in lo?"\\@cdots\\,":"\\@cdots"}),sn("\\dotsb","\\cdots"),sn("\\dotsm","\\cdots"),sn("\\dotsi","\\!\\cdots"),sn("\\dotsx","\\ldots\\,"),sn("\\DOTSI","\\relax"),sn("\\DOTSB","\\relax"),sn("\\DOTSX","\\relax"),sn("\\tmspace","\\TextOrMath{\\kern#1#3}{\\mskip#1#2}\\relax"),sn("\\,","\\tmspace+{3mu}{.1667em}"),sn("\\thinspace","\\,"),sn("\\>","\\mskip{4mu}"),sn("\\:","\\tmspace+{4mu}{.2222em}"),sn("\\medspace","\\:"),sn("\\;","\\tmspace+{5mu}{.2777em}"),sn("\\thickspace","\\;"),sn("\\!","\\tmspace-{3mu}{.1667em}"),sn("\\negthinspace","\\!"),sn("\\negmedspace","\\tmspace-{4mu}{.2222em}"),sn("\\negthickspace","\\tmspace-{5mu}{.277em}"),sn("\\enspace","\\kern.5em "),sn("\\enskip","\\hskip.5em\\relax"),sn("\\quad","\\hskip1em\\relax"),sn("\\qquad","\\hskip2em\\relax"),sn("\\tag","\\@ifstar\\tag@literal\\tag@paren"),sn("\\tag@paren","\\tag@literal{({#1})}"),sn("\\tag@literal",e=>{if(e.macros.get("\\df@tag"))throw new n("Multiple \\tag");return"\\gdef\\df@tag{\\text{#1}}"}),sn("\\bmod","\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}\\mathbin{\\rm mod}\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}"),sn("\\pod","\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern8mu}{\\mkern8mu}{\\mkern8mu}(#1)"),sn("\\pmod","\\pod{{\\rm mod}\\mkern6mu#1}"),sn("\\mod","\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}{\\rm mod}\\,\\,#1"),sn("\\newline","\\\\\\relax"),sn("\\TeX","\\textrm{\\html@mathml{T\\kern-.1667em\\raisebox{-.5ex}{E}\\kern-.125emX}{TeX}}");const ao=O(K["Main-Regular"]["T".charCodeAt(0)][1]-.7*K["Main-Regular"]["A".charCodeAt(0)][1]);sn("\\LaTeX","\\textrm{\\html@mathml{L\\kern-.36em\\raisebox{"+ao+"}{\\scriptstyle A}\\kern-.15em\\TeX}{LaTeX}}"),sn("\\KaTeX","\\textrm{\\html@mathml{K\\kern-.17em\\raisebox{"+ao+"}{\\scriptstyle A}\\kern-.15em\\TeX}{KaTeX}}"),sn("\\hspace","\\@ifstar\\@hspacer\\@hspace"),sn("\\@hspace","\\hskip #1\\relax"),sn("\\@hspacer","\\rule{0pt}{0pt}\\hskip #1\\relax"),sn("\\ordinarycolon",":"),sn("\\vcentcolon","\\mathrel{\\mathop\\ordinarycolon}"),sn("\\dblcolon",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-.9mu}\\vcentcolon}}{\\mathop{\\char"2237}}'),sn("\\coloneqq",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}=}}{\\mathop{\\char"2254}}'),sn("\\Coloneqq",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}=}}{\\mathop{\\char"2237\\char"3d}}'),sn("\\coloneq",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}{\\mathop{\\char"3a\\char"2212}}'),sn("\\Coloneq",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}{\\mathop{\\char"2237\\char"2212}}'),sn("\\eqqcolon",'\\html@mathml{\\mathrel{=\\mathrel{\\mkern-1.2mu}\\vcentcolon}}{\\mathop{\\char"2255}}'),sn("\\Eqqcolon",'\\html@mathml{\\mathrel{=\\mathrel{\\mkern-1.2mu}\\dblcolon}}{\\mathop{\\char"3d\\char"2237}}'),sn("\\eqcolon",'\\html@mathml{\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\vcentcolon}}{\\mathop{\\char"2239}}'),sn("\\Eqcolon",'\\html@mathml{\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\dblcolon}}{\\mathop{\\char"2212\\char"2237}}'),sn("\\colonapprox",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\approx}}{\\mathop{\\char"3a\\char"2248}}'),sn("\\Colonapprox",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\approx}}{\\mathop{\\char"2237\\char"2248}}'),sn("\\colonsim",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\sim}}{\\mathop{\\char"3a\\char"223c}}'),sn("\\Colonsim",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\sim}}{\\mathop{\\char"2237\\char"223c}}'),sn("\u2237","\\dblcolon"),sn("\u2239","\\eqcolon"),sn("\u2254","\\coloneqq"),sn("\u2255","\\eqqcolon"),sn("\u2a74","\\Coloneqq"),sn("\\ratio","\\vcentcolon"),sn("\\coloncolon","\\dblcolon"),sn("\\colonequals","\\coloneqq"),sn("\\coloncolonequals","\\Coloneqq"),sn("\\equalscolon","\\eqqcolon"),sn("\\equalscoloncolon","\\Eqqcolon"),sn("\\colonminus","\\coloneq"),sn("\\coloncolonminus","\\Coloneq"),sn("\\minuscolon","\\eqcolon"),sn("\\minuscoloncolon","\\Eqcolon"),sn("\\coloncolonapprox","\\Colonapprox"),sn("\\coloncolonsim","\\Colonsim"),sn("\\simcolon","\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\vcentcolon}"),sn("\\simcoloncolon","\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\dblcolon}"),sn("\\approxcolon","\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\vcentcolon}"),sn("\\approxcoloncolon","\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\dblcolon}"),sn("\\notni","\\html@mathml{\\not\\ni}{\\mathrel{\\char`\u220c}}"),sn("\\limsup","\\DOTSB\\operatorname*{lim\\,sup}"),sn("\\liminf","\\DOTSB\\operatorname*{lim\\,inf}"),sn("\\injlim","\\DOTSB\\operatorname*{inj\\,lim}"),sn("\\projlim","\\DOTSB\\operatorname*{proj\\,lim}"),sn("\\varlimsup","\\DOTSB\\operatorname*{\\overline{lim}}"),sn("\\varliminf","\\DOTSB\\operatorname*{\\underline{lim}}"),sn("\\varinjlim","\\DOTSB\\operatorname*{\\underrightarrow{lim}}"),sn("\\varprojlim","\\DOTSB\\operatorname*{\\underleftarrow{lim}}"),sn("\\gvertneqq","\\html@mathml{\\@gvertneqq}{\u2269}"),sn("\\lvertneqq","\\html@mathml{\\@lvertneqq}{\u2268}"),sn("\\ngeqq","\\html@mathml{\\@ngeqq}{\u2271}"),sn("\\ngeqslant","\\html@mathml{\\@ngeqslant}{\u2271}"),sn("\\nleqq","\\html@mathml{\\@nleqq}{\u2270}"),sn("\\nleqslant","\\html@mathml{\\@nleqslant}{\u2270}"),sn("\\nshortmid","\\html@mathml{\\@nshortmid}{\u2224}"),sn("\\nshortparallel","\\html@mathml{\\@nshortparallel}{\u2226}"),sn("\\nsubseteqq","\\html@mathml{\\@nsubseteqq}{\u2288}"),sn("\\nsupseteqq","\\html@mathml{\\@nsupseteqq}{\u2289}"),sn("\\varsubsetneq","\\html@mathml{\\@varsubsetneq}{\u228a}"),sn("\\varsubsetneqq","\\html@mathml{\\@varsubsetneqq}{\u2acb}"),sn("\\varsupsetneq","\\html@mathml{\\@varsupsetneq}{\u228b}"),sn("\\varsupsetneqq","\\html@mathml{\\@varsupsetneqq}{\u2acc}"),sn("\\imath","\\html@mathml{\\@imath}{\u0131}"),sn("\\jmath","\\html@mathml{\\@jmath}{\u0237}"),sn("\\llbracket","\\html@mathml{\\mathopen{[\\mkern-3.2mu[}}{\\mathopen{\\char`\u27e6}}"),sn("\\rrbracket","\\html@mathml{\\mathclose{]\\mkern-3.2mu]}}{\\mathclose{\\char`\u27e7}}"),sn("\u27e6","\\llbracket"),sn("\u27e7","\\rrbracket"),sn("\\lBrace","\\html@mathml{\\mathopen{\\{\\mkern-3.2mu[}}{\\mathopen{\\char`\u2983}}"),sn("\\rBrace","\\html@mathml{\\mathclose{]\\mkern-3.2mu\\}}}{\\mathclose{\\char`\u2984}}"),sn("\u2983","\\lBrace"),sn("\u2984","\\rBrace"),sn("\\minuso","\\mathbin{\\html@mathml{{\\mathrlap{\\mathchoice{\\kern{0.145em}}{\\kern{0.145em}}{\\kern{0.1015em}}{\\kern{0.0725em}}\\circ}{-}}}{\\char`\u29b5}}"),sn("\u29b5","\\minuso"),sn("\\darr","\\downarrow"),sn("\\dArr","\\Downarrow"),sn("\\Darr","\\Downarrow"),sn("\\lang","\\langle"),sn("\\rang","\\rangle"),sn("\\uarr","\\uparrow"),sn("\\uArr","\\Uparrow"),sn("\\Uarr","\\Uparrow"),sn("\\N","\\mathbb{N}"),sn("\\R","\\mathbb{R}"),sn("\\Z","\\mathbb{Z}"),sn("\\alef","\\aleph"),sn("\\alefsym","\\aleph"),sn("\\Alpha","\\mathrm{A}"),sn("\\Beta","\\mathrm{B}"),sn("\\bull","\\bullet"),sn("\\Chi","\\mathrm{X}"),sn("\\clubs","\\clubsuit"),sn("\\cnums","\\mathbb{C}"),sn("\\Complex","\\mathbb{C}"),sn("\\Dagger","\\ddagger"),sn("\\diamonds","\\diamondsuit"),sn("\\empty","\\emptyset"),sn("\\Epsilon","\\mathrm{E}"),sn("\\Eta","\\mathrm{H}"),sn("\\exist","\\exists"),sn("\\harr","\\leftrightarrow"),sn("\\hArr","\\Leftrightarrow"),sn("\\Harr","\\Leftrightarrow"),sn("\\hearts","\\heartsuit"),sn("\\image","\\Im"),sn("\\infin","\\infty"),sn("\\Iota","\\mathrm{I}"),sn("\\isin","\\in"),sn("\\Kappa","\\mathrm{K}"),sn("\\larr","\\leftarrow"),sn("\\lArr","\\Leftarrow"),sn("\\Larr","\\Leftarrow"),sn("\\lrarr","\\leftrightarrow"),sn("\\lrArr","\\Leftrightarrow"),sn("\\Lrarr","\\Leftrightarrow"),sn("\\Mu","\\mathrm{M}"),sn("\\natnums","\\mathbb{N}"),sn("\\Nu","\\mathrm{N}"),sn("\\Omicron","\\mathrm{O}"),sn("\\plusmn","\\pm"),sn("\\rarr","\\rightarrow"),sn("\\rArr","\\Rightarrow"),sn("\\Rarr","\\Rightarrow"),sn("\\real","\\Re"),sn("\\reals","\\mathbb{R}"),sn("\\Reals","\\mathbb{R}"),sn("\\Rho","\\mathrm{P}"),sn("\\sdot","\\cdot"),sn("\\sect","\\S"),sn("\\spades","\\spadesuit"),sn("\\sub","\\subset"),sn("\\sube","\\subseteq"),sn("\\supe","\\supseteq"),sn("\\Tau","\\mathrm{T}"),sn("\\thetasym","\\vartheta"),sn("\\weierp","\\wp"),sn("\\Zeta","\\mathrm{Z}"),sn("\\argmin","\\DOTSB\\operatorname*{arg\\,min}"),sn("\\argmax","\\DOTSB\\operatorname*{arg\\,max}"),sn("\\plim","\\DOTSB\\mathop{\\operatorname{plim}}\\limits"),sn("\\bra","\\mathinner{\\langle{#1}|}"),sn("\\ket","\\mathinner{|{#1}\\rangle}"),sn("\\braket","\\mathinner{\\langle{#1}\\rangle}"),sn("\\Bra","\\left\\langle#1\\right|"),sn("\\Ket","\\left|#1\\right\\rangle");const co=e=>t=>{const r=t.consumeArg().tokens,n=t.consumeArg().tokens,o=t.consumeArg().tokens,s=t.consumeArg().tokens,i=t.macros.get("|"),l=t.macros.get("\\|");t.macros.beginGroup();const a=t=>r=>{e&&(r.macros.set("|",i),o.length&&r.macros.set("\\|",l));let s=t;if(!t&&o.length){"|"===r.future().text&&(r.popToken(),s=!0)}return{tokens:s?o:n,numArgs:0}};t.macros.set("|",a(!1)),o.length&&t.macros.set("\\|",a(!0));const c=t.consumeArg().tokens,h=t.expandTokens([...s,...c,...r]);return t.macros.endGroup(),{tokens:h.reverse(),numArgs:0}};sn("\\bra@ket",co(!1)),sn("\\bra@set",co(!0)),sn("\\Braket","\\bra@ket{\\left\\langle}{\\,\\middle\\vert\\,}{\\,\\middle\\vert\\,}{\\right\\rangle}"),sn("\\Set","\\bra@set{\\left\\{\\:}{\\;\\middle\\vert\\;}{\\;\\middle\\Vert\\;}{\\:\\right\\}}"),sn("\\set","\\bra@set{\\{\\,}{\\mid}{}{\\,\\}}"),sn("\\angln","{\\angl n}"),sn("\\blue","\\textcolor{##6495ed}{#1}"),sn("\\orange","\\textcolor{##ffa500}{#1}"),sn("\\pink","\\textcolor{##ff00af}{#1}"),sn("\\red","\\textcolor{##df0030}{#1}"),sn("\\green","\\textcolor{##28ae7b}{#1}"),sn("\\gray","\\textcolor{gray}{#1}"),sn("\\purple","\\textcolor{##9d38bd}{#1}"),sn("\\blueA","\\textcolor{##ccfaff}{#1}"),sn("\\blueB","\\textcolor{##80f6ff}{#1}"),sn("\\blueC","\\textcolor{##63d9ea}{#1}"),sn("\\blueD","\\textcolor{##11accd}{#1}"),sn("\\blueE","\\textcolor{##0c7f99}{#1}"),sn("\\tealA","\\textcolor{##94fff5}{#1}"),sn("\\tealB","\\textcolor{##26edd5}{#1}"),sn("\\tealC","\\textcolor{##01d1c1}{#1}"),sn("\\tealD","\\textcolor{##01a995}{#1}"),sn("\\tealE","\\textcolor{##208170}{#1}"),sn("\\greenA","\\textcolor{##b6ffb0}{#1}"),sn("\\greenB","\\textcolor{##8af281}{#1}"),sn("\\greenC","\\textcolor{##74cf70}{#1}"),sn("\\greenD","\\textcolor{##1fab54}{#1}"),sn("\\greenE","\\textcolor{##0d923f}{#1}"),sn("\\goldA","\\textcolor{##ffd0a9}{#1}"),sn("\\goldB","\\textcolor{##ffbb71}{#1}"),sn("\\goldC","\\textcolor{##ff9c39}{#1}"),sn("\\goldD","\\textcolor{##e07d10}{#1}"),sn("\\goldE","\\textcolor{##a75a05}{#1}"),sn("\\redA","\\textcolor{##fca9a9}{#1}"),sn("\\redB","\\textcolor{##ff8482}{#1}"),sn("\\redC","\\textcolor{##f9685d}{#1}"),sn("\\redD","\\textcolor{##e84d39}{#1}"),sn("\\redE","\\textcolor{##bc2612}{#1}"),sn("\\maroonA","\\textcolor{##ffbde0}{#1}"),sn("\\maroonB","\\textcolor{##ff92c6}{#1}"),sn("\\maroonC","\\textcolor{##ed5fa6}{#1}"),sn("\\maroonD","\\textcolor{##ca337c}{#1}"),sn("\\maroonE","\\textcolor{##9e034e}{#1}"),sn("\\purpleA","\\textcolor{##ddd7ff}{#1}"),sn("\\purpleB","\\textcolor{##c6b9fc}{#1}"),sn("\\purpleC","\\textcolor{##aa87ff}{#1}"),sn("\\purpleD","\\textcolor{##7854ab}{#1}"),sn("\\purpleE","\\textcolor{##543b78}{#1}"),sn("\\mintA","\\textcolor{##f5f9e8}{#1}"),sn("\\mintB","\\textcolor{##edf2df}{#1}"),sn("\\mintC","\\textcolor{##e0e5cc}{#1}"),sn("\\grayA","\\textcolor{##f6f7f7}{#1}"),sn("\\grayB","\\textcolor{##f0f1f2}{#1}"),sn("\\grayC","\\textcolor{##e3e5e6}{#1}"),sn("\\grayD","\\textcolor{##d6d8da}{#1}"),sn("\\grayE","\\textcolor{##babec2}{#1}"),sn("\\grayF","\\textcolor{##888d93}{#1}"),sn("\\grayG","\\textcolor{##626569}{#1}"),sn("\\grayH","\\textcolor{##3b3e40}{#1}"),sn("\\grayI","\\textcolor{##21242c}{#1}"),sn("\\kaBlue","\\textcolor{##314453}{#1}"),sn("\\kaGreen","\\textcolor{##71B307}{#1}");const ho={"^":!0,_:!0,"\\limits":!0,"\\nolimits":!0};class mo{constructor(e,t,r){this.settings=void 0,this.expansionCount=void 0,this.lexer=void 0,this.macros=void 0,this.stack=void 0,this.mode=void 0,this.settings=t,this.expansionCount=0,this.feed(e),this.macros=new to(ro,t.macros),this.mode=r,this.stack=[]}feed(e){this.lexer=new eo(e,this.settings)}switchMode(e){this.mode=e}beginGroup(){this.macros.beginGroup()}endGroup(){this.macros.endGroup()}endGroups(){this.macros.endGroups()}future(){return 0===this.stack.length&&this.pushToken(this.lexer.lex()),this.stack[this.stack.length-1]}popToken(){return this.future(),this.stack.pop()}pushToken(e){this.stack.push(e)}pushTokens(e){this.stack.push(...e)}scanArgument(e){let t,r,n;if(e){if(this.consumeSpaces(),"["!==this.future().text)return null;t=this.popToken(),({tokens:n,end:r}=this.consumeArg(["]"]))}else({tokens:n,start:t,end:r}=this.consumeArg());return this.pushToken(new an("EOF",r.loc)),this.pushTokens(n),new an("",ln.range(t,r))}consumeSpaces(){for(;;){if(" "!==this.future().text)break;this.stack.pop()}}consumeArg(e){const t=[],r=e&&e.length>0;r||this.consumeSpaces();const o=this.future();let s,i=0,l=0;do{if(s=this.popToken(),t.push(s),"{"===s.text)++i;else if("}"===s.text){if(--i,-1===i)throw new n("Extra }",s)}else if("EOF"===s.text)throw new n("Unexpected end of input in a macro argument, expected '"+(e&&r?e[l]:"}")+"'",s);if(e&&r)if((0===i||1===i&&"{"===e[l])&&s.text===e[l]){if(++l,l===e.length){t.splice(-l,l);break}}else l=0}while(0!==i||r);return"{"===o.text&&"}"===t[t.length-1].text&&(t.pop(),t.shift()),t.reverse(),{tokens:t,start:o,end:s}}consumeArgs(e,t){if(t){if(t.length!==e+1)throw new n("The length of delimiters doesn't match the number of args!");const r=t[0];for(let e=0;ethis.settings.maxExpand)throw new n("Too many expansions: infinite loop or need to increase maxExpand setting")}expandOnce(e){const t=this.popToken(),r=t.text,o=t.noexpand?null:this._getExpansion(r);if(null==o||e&&o.unexpandable){if(e&&null==o&&"\\"===r[0]&&!this.isDefined(r))throw new n("Undefined control sequence: "+r);return this.pushToken(t),!1}this.countExpansion(1);let s=o.tokens;const i=this.consumeArgs(o.numArgs,o.delimiters);if(o.numArgs){s=s.slice();for(let e=s.length-1;e>=0;--e){let t=s[e];if("#"===t.text){if(0===e)throw new n("Incomplete placeholder at end of macro body",t);if(t=s[--e],"#"===t.text)s.splice(e+1,1);else{if(!/^[1-9]$/.test(t.text))throw new n("Not a valid argument number",t);s.splice(e,2,...i[+t.text-1])}}}}return this.pushTokens(s),s.length}expandAfterFuture(){return this.expandOnce(),this.future()}expandNextToken(){for(;;)if(!1===this.expandOnce()){const e=this.stack.pop();return e.treatAsRelax&&(e.text="\\relax"),e}}expandMacro(e){return this.macros.has(e)?this.expandTokens([new an(e)]):void 0}expandTokens(e){const t=[],r=this.stack.length;for(this.pushTokens(e);this.stack.length>r;)if(!1===this.expandOnce(!0)){const e=this.stack.pop();e.treatAsRelax&&(e.noexpand=!1,e.treatAsRelax=!1),t.push(e)}return this.countExpansion(t.length),t}expandMacroAsText(e){const t=this.expandMacro(e);return t?t.map(e=>e.text).join(""):t}_getExpansion(e){const t=this.macros.get(e);if(null==t)return t;if(1===e.length){const t=this.lexer.catcodes[e];if(null!=t&&13!==t)return}const r="function"==typeof t?t(this):t;if("string"==typeof r){let e=0;if(r.includes("#")){const t=r.replace(/##/g,"");for(;t.includes("#"+(e+1));)++e}const t=new eo(r,this.settings),n=[];let o=t.lex();for(;"EOF"!==o.text;)n.push(o),o=t.lex();n.reverse();return{tokens:n,numArgs:e}}return r}isDefined(e){return this.macros.has(e)||_n.hasOwnProperty(e)||ne.math.hasOwnProperty(e)||ne.text.hasOwnProperty(e)||ho.hasOwnProperty(e)}isExpandable(e){const t=this.macros.get(e);return null!=t?"string"==typeof t||"function"==typeof t||!t.unexpandable:_n.hasOwnProperty(e)&&!_n[e].primitive}}const uo=/^[\u208a\u208b\u208c\u208d\u208e\u2080\u2081\u2082\u2083\u2084\u2085\u2086\u2087\u2088\u2089\u2090\u2091\u2095\u1d62\u2c7c\u2096\u2097\u2098\u2099\u2092\u209a\u1d63\u209b\u209c\u1d64\u1d65\u2093\u1d66\u1d67\u1d68\u1d69\u1d6a]/,po=Object.freeze({"\u208a":"+","\u208b":"-","\u208c":"=","\u208d":"(","\u208e":")","\u2080":"0","\u2081":"1","\u2082":"2","\u2083":"3","\u2084":"4","\u2085":"5","\u2086":"6","\u2087":"7","\u2088":"8","\u2089":"9","\u2090":"a","\u2091":"e","\u2095":"h","\u1d62":"i","\u2c7c":"j","\u2096":"k","\u2097":"l","\u2098":"m","\u2099":"n","\u2092":"o","\u209a":"p","\u1d63":"r","\u209b":"s","\u209c":"t","\u1d64":"u","\u1d65":"v","\u2093":"x","\u1d66":"\u03b2","\u1d67":"\u03b3","\u1d68":"\u03c1","\u1d69":"\u03d5","\u1d6a":"\u03c7","\u207a":"+","\u207b":"-","\u207c":"=","\u207d":"(","\u207e":")","\u2070":"0","\xb9":"1","\xb2":"2","\xb3":"3","\u2074":"4","\u2075":"5","\u2076":"6","\u2077":"7","\u2078":"8","\u2079":"9","\u1d2c":"A","\u1d2e":"B","\u1d30":"D","\u1d31":"E","\u1d33":"G","\u1d34":"H","\u1d35":"I","\u1d36":"J","\u1d37":"K","\u1d38":"L","\u1d39":"M","\u1d3a":"N","\u1d3c":"O","\u1d3e":"P","\u1d3f":"R","\u1d40":"T","\u1d41":"U","\u2c7d":"V","\u1d42":"W","\u1d43":"a","\u1d47":"b","\u1d9c":"c","\u1d48":"d","\u1d49":"e","\u1da0":"f","\u1d4d":"g","\u02b0":"h","\u2071":"i","\u02b2":"j","\u1d4f":"k","\u02e1":"l","\u1d50":"m","\u207f":"n","\u1d52":"o","\u1d56":"p","\u02b3":"r","\u02e2":"s","\u1d57":"t","\u1d58":"u","\u1d5b":"v","\u02b7":"w","\u02e3":"x","\u02b8":"y","\u1dbb":"z","\u1d5d":"\u03b2","\u1d5e":"\u03b3","\u1d5f":"\u03b4","\u1d60":"\u03d5","\u1d61":"\u03c7","\u1dbf":"\u03b8"}),go={"\u0301":{text:"\\'",math:"\\acute"},"\u0300":{text:"\\`",math:"\\grave"},"\u0308":{text:'\\"',math:"\\ddot"},"\u0303":{text:"\\~",math:"\\tilde"},"\u0304":{text:"\\=",math:"\\bar"},"\u0306":{text:"\\u",math:"\\breve"},"\u030c":{text:"\\v",math:"\\check"},"\u0302":{text:"\\^",math:"\\hat"},"\u0307":{text:"\\.",math:"\\dot"},"\u030a":{text:"\\r",math:"\\mathring"},"\u030b":{text:"\\H"},"\u0327":{text:"\\c"}},fo={"\xe1":"a\u0301","\xe0":"a\u0300","\xe4":"a\u0308","\u01df":"a\u0308\u0304","\xe3":"a\u0303","\u0101":"a\u0304","\u0103":"a\u0306","\u1eaf":"a\u0306\u0301","\u1eb1":"a\u0306\u0300","\u1eb5":"a\u0306\u0303","\u01ce":"a\u030c","\xe2":"a\u0302","\u1ea5":"a\u0302\u0301","\u1ea7":"a\u0302\u0300","\u1eab":"a\u0302\u0303","\u0227":"a\u0307","\u01e1":"a\u0307\u0304","\xe5":"a\u030a","\u01fb":"a\u030a\u0301","\u1e03":"b\u0307","\u0107":"c\u0301","\u1e09":"c\u0327\u0301","\u010d":"c\u030c","\u0109":"c\u0302","\u010b":"c\u0307","\xe7":"c\u0327","\u010f":"d\u030c","\u1e0b":"d\u0307","\u1e11":"d\u0327","\xe9":"e\u0301","\xe8":"e\u0300","\xeb":"e\u0308","\u1ebd":"e\u0303","\u0113":"e\u0304","\u1e17":"e\u0304\u0301","\u1e15":"e\u0304\u0300","\u0115":"e\u0306","\u1e1d":"e\u0327\u0306","\u011b":"e\u030c","\xea":"e\u0302","\u1ebf":"e\u0302\u0301","\u1ec1":"e\u0302\u0300","\u1ec5":"e\u0302\u0303","\u0117":"e\u0307","\u0229":"e\u0327","\u1e1f":"f\u0307","\u01f5":"g\u0301","\u1e21":"g\u0304","\u011f":"g\u0306","\u01e7":"g\u030c","\u011d":"g\u0302","\u0121":"g\u0307","\u0123":"g\u0327","\u1e27":"h\u0308","\u021f":"h\u030c","\u0125":"h\u0302","\u1e23":"h\u0307","\u1e29":"h\u0327","\xed":"i\u0301","\xec":"i\u0300","\xef":"i\u0308","\u1e2f":"i\u0308\u0301","\u0129":"i\u0303","\u012b":"i\u0304","\u012d":"i\u0306","\u01d0":"i\u030c","\xee":"i\u0302","\u01f0":"j\u030c","\u0135":"j\u0302","\u1e31":"k\u0301","\u01e9":"k\u030c","\u0137":"k\u0327","\u013a":"l\u0301","\u013e":"l\u030c","\u013c":"l\u0327","\u1e3f":"m\u0301","\u1e41":"m\u0307","\u0144":"n\u0301","\u01f9":"n\u0300","\xf1":"n\u0303","\u0148":"n\u030c","\u1e45":"n\u0307","\u0146":"n\u0327","\xf3":"o\u0301","\xf2":"o\u0300","\xf6":"o\u0308","\u022b":"o\u0308\u0304","\xf5":"o\u0303","\u1e4d":"o\u0303\u0301","\u1e4f":"o\u0303\u0308","\u022d":"o\u0303\u0304","\u014d":"o\u0304","\u1e53":"o\u0304\u0301","\u1e51":"o\u0304\u0300","\u014f":"o\u0306","\u01d2":"o\u030c","\xf4":"o\u0302","\u1ed1":"o\u0302\u0301","\u1ed3":"o\u0302\u0300","\u1ed7":"o\u0302\u0303","\u022f":"o\u0307","\u0231":"o\u0307\u0304","\u0151":"o\u030b","\u1e55":"p\u0301","\u1e57":"p\u0307","\u0155":"r\u0301","\u0159":"r\u030c","\u1e59":"r\u0307","\u0157":"r\u0327","\u015b":"s\u0301","\u1e65":"s\u0301\u0307","\u0161":"s\u030c","\u1e67":"s\u030c\u0307","\u015d":"s\u0302","\u1e61":"s\u0307","\u015f":"s\u0327","\u1e97":"t\u0308","\u0165":"t\u030c","\u1e6b":"t\u0307","\u0163":"t\u0327","\xfa":"u\u0301","\xf9":"u\u0300","\xfc":"u\u0308","\u01d8":"u\u0308\u0301","\u01dc":"u\u0308\u0300","\u01d6":"u\u0308\u0304","\u01da":"u\u0308\u030c","\u0169":"u\u0303","\u1e79":"u\u0303\u0301","\u016b":"u\u0304","\u1e7b":"u\u0304\u0308","\u016d":"u\u0306","\u01d4":"u\u030c","\xfb":"u\u0302","\u016f":"u\u030a","\u0171":"u\u030b","\u1e7d":"v\u0303","\u1e83":"w\u0301","\u1e81":"w\u0300","\u1e85":"w\u0308","\u0175":"w\u0302","\u1e87":"w\u0307","\u1e98":"w\u030a","\u1e8d":"x\u0308","\u1e8b":"x\u0307","\xfd":"y\u0301","\u1ef3":"y\u0300","\xff":"y\u0308","\u1ef9":"y\u0303","\u0233":"y\u0304","\u0177":"y\u0302","\u1e8f":"y\u0307","\u1e99":"y\u030a","\u017a":"z\u0301","\u017e":"z\u030c","\u1e91":"z\u0302","\u017c":"z\u0307","\xc1":"A\u0301","\xc0":"A\u0300","\xc4":"A\u0308","\u01de":"A\u0308\u0304","\xc3":"A\u0303","\u0100":"A\u0304","\u0102":"A\u0306","\u1eae":"A\u0306\u0301","\u1eb0":"A\u0306\u0300","\u1eb4":"A\u0306\u0303","\u01cd":"A\u030c","\xc2":"A\u0302","\u1ea4":"A\u0302\u0301","\u1ea6":"A\u0302\u0300","\u1eaa":"A\u0302\u0303","\u0226":"A\u0307","\u01e0":"A\u0307\u0304","\xc5":"A\u030a","\u01fa":"A\u030a\u0301","\u1e02":"B\u0307","\u0106":"C\u0301","\u1e08":"C\u0327\u0301","\u010c":"C\u030c","\u0108":"C\u0302","\u010a":"C\u0307","\xc7":"C\u0327","\u010e":"D\u030c","\u1e0a":"D\u0307","\u1e10":"D\u0327","\xc9":"E\u0301","\xc8":"E\u0300","\xcb":"E\u0308","\u1ebc":"E\u0303","\u0112":"E\u0304","\u1e16":"E\u0304\u0301","\u1e14":"E\u0304\u0300","\u0114":"E\u0306","\u1e1c":"E\u0327\u0306","\u011a":"E\u030c","\xca":"E\u0302","\u1ebe":"E\u0302\u0301","\u1ec0":"E\u0302\u0300","\u1ec4":"E\u0302\u0303","\u0116":"E\u0307","\u0228":"E\u0327","\u1e1e":"F\u0307","\u01f4":"G\u0301","\u1e20":"G\u0304","\u011e":"G\u0306","\u01e6":"G\u030c","\u011c":"G\u0302","\u0120":"G\u0307","\u0122":"G\u0327","\u1e26":"H\u0308","\u021e":"H\u030c","\u0124":"H\u0302","\u1e22":"H\u0307","\u1e28":"H\u0327","\xcd":"I\u0301","\xcc":"I\u0300","\xcf":"I\u0308","\u1e2e":"I\u0308\u0301","\u0128":"I\u0303","\u012a":"I\u0304","\u012c":"I\u0306","\u01cf":"I\u030c","\xce":"I\u0302","\u0130":"I\u0307","\u0134":"J\u0302","\u1e30":"K\u0301","\u01e8":"K\u030c","\u0136":"K\u0327","\u0139":"L\u0301","\u013d":"L\u030c","\u013b":"L\u0327","\u1e3e":"M\u0301","\u1e40":"M\u0307","\u0143":"N\u0301","\u01f8":"N\u0300","\xd1":"N\u0303","\u0147":"N\u030c","\u1e44":"N\u0307","\u0145":"N\u0327","\xd3":"O\u0301","\xd2":"O\u0300","\xd6":"O\u0308","\u022a":"O\u0308\u0304","\xd5":"O\u0303","\u1e4c":"O\u0303\u0301","\u1e4e":"O\u0303\u0308","\u022c":"O\u0303\u0304","\u014c":"O\u0304","\u1e52":"O\u0304\u0301","\u1e50":"O\u0304\u0300","\u014e":"O\u0306","\u01d1":"O\u030c","\xd4":"O\u0302","\u1ed0":"O\u0302\u0301","\u1ed2":"O\u0302\u0300","\u1ed6":"O\u0302\u0303","\u022e":"O\u0307","\u0230":"O\u0307\u0304","\u0150":"O\u030b","\u1e54":"P\u0301","\u1e56":"P\u0307","\u0154":"R\u0301","\u0158":"R\u030c","\u1e58":"R\u0307","\u0156":"R\u0327","\u015a":"S\u0301","\u1e64":"S\u0301\u0307","\u0160":"S\u030c","\u1e66":"S\u030c\u0307","\u015c":"S\u0302","\u1e60":"S\u0307","\u015e":"S\u0327","\u0164":"T\u030c","\u1e6a":"T\u0307","\u0162":"T\u0327","\xda":"U\u0301","\xd9":"U\u0300","\xdc":"U\u0308","\u01d7":"U\u0308\u0301","\u01db":"U\u0308\u0300","\u01d5":"U\u0308\u0304","\u01d9":"U\u0308\u030c","\u0168":"U\u0303","\u1e78":"U\u0303\u0301","\u016a":"U\u0304","\u1e7a":"U\u0304\u0308","\u016c":"U\u0306","\u01d3":"U\u030c","\xdb":"U\u0302","\u016e":"U\u030a","\u0170":"U\u030b","\u1e7c":"V\u0303","\u1e82":"W\u0301","\u1e80":"W\u0300","\u1e84":"W\u0308","\u0174":"W\u0302","\u1e86":"W\u0307","\u1e8c":"X\u0308","\u1e8a":"X\u0307","\xdd":"Y\u0301","\u1ef2":"Y\u0300","\u0178":"Y\u0308","\u1ef8":"Y\u0303","\u0232":"Y\u0304","\u0176":"Y\u0302","\u1e8e":"Y\u0307","\u0179":"Z\u0301","\u017d":"Z\u030c","\u1e90":"Z\u0302","\u017b":"Z\u0307","\u03ac":"\u03b1\u0301","\u1f70":"\u03b1\u0300","\u1fb1":"\u03b1\u0304","\u1fb0":"\u03b1\u0306","\u03ad":"\u03b5\u0301","\u1f72":"\u03b5\u0300","\u03ae":"\u03b7\u0301","\u1f74":"\u03b7\u0300","\u03af":"\u03b9\u0301","\u1f76":"\u03b9\u0300","\u03ca":"\u03b9\u0308","\u0390":"\u03b9\u0308\u0301","\u1fd2":"\u03b9\u0308\u0300","\u1fd1":"\u03b9\u0304","\u1fd0":"\u03b9\u0306","\u03cc":"\u03bf\u0301","\u1f78":"\u03bf\u0300","\u03cd":"\u03c5\u0301","\u1f7a":"\u03c5\u0300","\u03cb":"\u03c5\u0308","\u03b0":"\u03c5\u0308\u0301","\u1fe2":"\u03c5\u0308\u0300","\u1fe1":"\u03c5\u0304","\u1fe0":"\u03c5\u0306","\u03ce":"\u03c9\u0301","\u1f7c":"\u03c9\u0300","\u038e":"\u03a5\u0301","\u1fea":"\u03a5\u0300","\u03ab":"\u03a5\u0308","\u1fe9":"\u03a5\u0304","\u1fe8":"\u03a5\u0306","\u038f":"\u03a9\u0301","\u1ffa":"\u03a9\u0300"};class bo{constructor(e,t){this.mode=void 0,this.gullet=void 0,this.settings=void 0,this.leftrightDepth=void 0,this.nextToken=void 0,this.mode="math",this.gullet=new mo(e,t,this.mode),this.settings=t,this.leftrightDepth=0,this.nextToken=null}expect(e,t){if(void 0===t&&(t=!0),this.fetch().text!==e)throw new n("Expected '"+e+"', got '"+this.fetch().text+"'",this.fetch());t&&this.consume()}consume(){this.nextToken=null}fetch(){return null==this.nextToken&&(this.nextToken=this.gullet.expandNextToken()),this.nextToken}switchMode(e){this.mode=e,this.gullet.switchMode(e)}parse(){this.settings.globalGroup||this.gullet.beginGroup(),this.settings.colorIsTextColor&&this.gullet.macros.set("\\color","\\textcolor");try{const e=this.parseExpression(!1);return this.expect("EOF"),this.settings.globalGroup||this.gullet.endGroup(),e}finally{this.gullet.endGroups()}}subparse(e){const t=this.nextToken;this.consume(),this.gullet.pushToken(new an("}")),this.gullet.pushTokens(e);const r=this.parseExpression(!1);return this.expect("}"),this.nextToken=t,r}parseExpression(e,t){const r=[];for(;;){"math"===this.mode&&this.consumeSpaces();const n=this.fetch();if(bo.endOfExpression.has(n.text))break;if(t&&n.text===t)break;if(e&&_n[n.text]&&_n[n.text].infix)break;const o=this.parseAtom(t);if(!o)break;"internal"!==o.type&&r.push(o)}return"text"===this.mode&&this.formLigatures(r),this.handleInfixNodes(r)}handleInfixNodes(e){let t,r=-1;for(let o=0;o=128))return null;this.settings.strict&&(T(t.charCodeAt(0))?"math"===this.mode&&this.settings.reportNonstrict("unicodeTextInMathMode",'Unicode text character "'+t[0]+'" used in math mode',e):this.settings.reportNonstrict("unknownSymbol",'Unrecognized Unicode character "'+t[0]+'" ('+t.charCodeAt(0)+")",e)),o={type:"textord",mode:"text",loc:ln.range(e),text:t}}if(this.consume(),r)for(let t=0;t 15) { + left = "…" + input.slice(start - 15, start); + } else { + left = input.slice(0, start); + } + var right; + if (end + 15 < input.length) { + right = input.slice(end, end + 15) + "…"; + } else { + right = input.slice(end); + } + error += left + underlined + right; + } + super(error); + this.name = "ParseError"; + this.position = void 0; + // Error start position based on passed-in Token or ParseNode. + this.length = void 0; + // Length of affected text based on passed-in Token or ParseNode. + this.rawMessage = void 0; + Object.setPrototypeOf(this, ParseError.prototype); + this.position = start; + if (start != null && end != null) { + this.length = end - start; + } + this.rawMessage = message; + } +} + +/** + * This file contains a list of utility functions which are useful in other + * files. + */ +// hyphenate and escape adapted from Facebook's React under Apache 2 license +var uppercase = /([A-Z])/g; +var hyphenate = str => str.replace(uppercase, "-$1").toLowerCase(); +var ESCAPE_LOOKUP = { + "&": "&", + ">": ">", + "<": "<", + "\"": """, + "'": "'" +}; +var ESCAPE_REGEX = /[&><"']/g; +/** + * Escapes text to prevent scripting attacks. + */ +var escape = text => String(text).replace(ESCAPE_REGEX, match => ESCAPE_LOOKUP[match]); +/** + * Sometimes we want to pull out the innermost element of a group. In most + * cases, this will just be the group itself, but when ordgroups and colors have + * a single element, we want to pull that out. + */ +var getBaseElem = group => { + if (group.type === "ordgroup") { + if (group.body.length === 1) { + return getBaseElem(group.body[0]); + } else { + return group; + } + } else if (group.type === "color") { + if (group.body.length === 1) { + return getBaseElem(group.body[0]); + } else { + return group; + } + } else if (group.type === "font") { + return getBaseElem(group.body); + } else { + return group; + } +}; +var characterNodesTypes = new Set(["mathord", "textord", "atom"]); +/** + * TeXbook algorithms often reference "character boxes", which are simply groups + * with a single character in them. To decide if something is a character box, + * we find its innermost group, and see if it is a single character. + */ +var isCharacterBox = group => characterNodesTypes.has(getBaseElem(group).type); +/** + * Return the protocol of a URL, or "_relative" if the URL does not specify a + * protocol (and thus is relative), or `null` if URL has invalid protocol + * (so should be outright rejected). + */ +var protocolFromUrl = url => { + // Check for possible leading protocol. + // https://url.spec.whatwg.org/#url-parsing strips leading whitespace + // (U+20) or C0 control (U+00-U+1F) characters. + var protocol = /^[\x00-\x20]*([^\\/#?]*?)(:|�*58|�*3a|&colon)/i.exec(url); + if (!protocol) { + return "_relative"; + } + // Reject weird colons + if (protocol[2] !== ":") { + return null; + } + // Reject invalid characters in scheme according to + // https://datatracker.ietf.org/doc/html/rfc3986#section-3.1 + if (!/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(protocol[1])) { + return null; + } + // Lowercase the protocol + return protocol[1].toLowerCase(); +}; + +/* eslint no-console:0 */ +// TODO: automatically generate documentation +// TODO: check all properties on Settings exist +// TODO: check the type of a property on Settings matches +var SETTINGS_SCHEMA = { + displayMode: { + type: "boolean", + description: "Render math in display mode, which puts the math in " + "display style (so \\int and \\sum are large, for example), and " + "centers the math on the page on its own line.", + cli: "-d, --display-mode" + }, + output: { + type: { + enum: ["htmlAndMathml", "html", "mathml"] + }, + description: "Determines the markup language of the output.", + cli: "-F, --format " + }, + leqno: { + type: "boolean", + description: "Render display math in leqno style (left-justified tags)." + }, + fleqn: { + type: "boolean", + description: "Render display math flush left." + }, + throwOnError: { + type: "boolean", + default: true, + cli: "-t, --no-throw-on-error", + cliDescription: "Render errors (in the color given by --error-color) ins" + "tead of throwing a ParseError exception when encountering an error." + }, + errorColor: { + type: "string", + default: "#cc0000", + cli: "-c, --error-color ", + cliDescription: "A color string given in the format 'rgb' or 'rrggbb' " + "(no #). This option determines the color of errors rendered by the " + "-t option.", + cliProcessor: color => "#" + color + }, + macros: { + type: "object", + cli: "-m, --macro ", + cliDescription: "Define custom macro of the form '\\foo:expansion' (use " + "multiple -m arguments for multiple macros).", + cliDefault: [], + cliProcessor: (def, defs) => { + defs.push(def); + return defs; + } + }, + minRuleThickness: { + type: "number", + description: "Specifies a minimum thickness, in ems, for fraction lines," + " `\\sqrt` top lines, `{array}` vertical lines, `\\hline`, " + "`\\hdashline`, `\\underline`, `\\overline`, and the borders of " + "`\\fbox`, `\\boxed`, and `\\fcolorbox`.", + processor: t => Math.max(0, t), + cli: "--min-rule-thickness ", + cliProcessor: parseFloat + }, + colorIsTextColor: { + type: "boolean", + description: "Makes \\color behave like LaTeX's 2-argument \\textcolor, " + "instead of LaTeX's one-argument \\color mode change.", + cli: "-b, --color-is-text-color" + }, + strict: { + type: [{ + enum: ["warn", "ignore", "error"] + }, "boolean", "function"], + description: "Turn on strict / LaTeX faithfulness mode, which throws an " + "error if the input uses features that are not supported by LaTeX.", + cli: "-S, --strict", + cliDefault: false + }, + trust: { + type: ["boolean", "function"], + description: "Trust the input, enabling all HTML features such as \\url.", + cli: "-T, --trust" + }, + maxSize: { + type: "number", + default: Infinity, + description: "If non-zero, all user-specified sizes, e.g. in " + "\\rule{500em}{500em}, will be capped to maxSize ems. Otherwise, " + "elements and spaces can be arbitrarily large", + processor: s => Math.max(0, s), + cli: "-s, --max-size ", + cliProcessor: parseInt + }, + maxExpand: { + type: "number", + default: 1000, + description: "Limit the number of macro expansions to the specified " + "number, to prevent e.g. infinite macro loops. If set to Infinity, " + "the macro expander will try to fully expand as in LaTeX.", + processor: n => Math.max(0, n), + cli: "-e, --max-expand ", + cliProcessor: n => n === "Infinity" ? Infinity : parseInt(n) + }, + globalGroup: { + type: "boolean", + cli: false + } +}; +function getImplicitDefault(type) { + if (typeof type !== 'string') { + return type.enum[0]; + } + switch (type) { + case 'boolean': + return false; + case 'string': + return ''; + case 'number': + return 0; + case 'object': + return {}; + default: + throw new Error("Unexpected schema type; settings must declare an explicit default."); + } +} +function getDefaultValue(schema) { + if (schema.default !== undefined) { + return schema.default; + } + var type = Array.isArray(schema.type) ? schema.type[0] : schema.type; + return getImplicitDefault(type); +} +function applySetting(target, prop, options, schema) { + var optionValue = options[prop]; + target[prop] = optionValue !== undefined ? schema.processor ? schema.processor(optionValue) : optionValue : getDefaultValue(schema); +} +/** + * The main Settings object + * + * The current options stored are: + * - displayMode: Whether the expression should be typeset as inline math + * (false, the default), meaning that the math starts in + * \textstyle and is placed in an inline-block); or as display + * math (true), meaning that the math starts in \displaystyle + * and is placed in a block with vertical margin. + */ +class Settings { + constructor(options) { + if (options === void 0) { + options = {}; + } + this.displayMode = void 0; + this.output = void 0; + this.leqno = void 0; + this.fleqn = void 0; + this.throwOnError = void 0; + this.errorColor = void 0; + this.macros = void 0; + this.minRuleThickness = void 0; + this.colorIsTextColor = void 0; + this.strict = void 0; + this.trust = void 0; + this.maxSize = void 0; + this.maxExpand = void 0; + this.globalGroup = void 0; + // allow null options + options = options || {}; + for (var prop of Object.keys(SETTINGS_SCHEMA)) { + var schema = SETTINGS_SCHEMA[prop]; + if (schema) { + // TODO: validate options + applySetting(this, prop, options, schema); + } + } + } + /** + * Report nonstrict (non-LaTeX-compatible) input. + * Can safely not be called if `this.strict` is false in JavaScript. + */ + reportNonstrict(errorCode, errorMsg, token) { + var strict = this.strict; + if (typeof strict === "function") { + // Allow return value of strict function to be boolean or string + // (or null/undefined, meaning no further processing). + strict = strict(errorCode, errorMsg, token); + } + if (!strict || strict === "ignore") { + return; + } else if (strict === true || strict === "error") { + throw new ParseError("LaTeX-incompatible input and strict mode is set to 'error': " + (errorMsg + " [" + errorCode + "]"), token); + } else if (strict === "warn") { + typeof console !== "undefined" && console.warn("LaTeX-incompatible input and strict mode is set to 'warn': " + (errorMsg + " [" + errorCode + "]")); + } else { + // won't happen in type-safe code + typeof console !== "undefined" && console.warn("LaTeX-incompatible input and strict mode is set to " + ("unrecognized '" + strict + "': " + errorMsg + " [" + errorCode + "]")); + } + } + /** + * Check whether to apply strict (LaTeX-adhering) behavior for unusual + * input (like `\\`). Unlike `nonstrict`, will not throw an error; + * instead, "error" translates to a return value of `true`, while "ignore" + * translates to a return value of `false`. May still print a warning: + * "warn" prints a warning and returns `false`. + * This is for the second category of `errorCode`s listed in the README. + */ + useStrictBehavior(errorCode, errorMsg, token) { + var strict = this.strict; + if (typeof strict === "function") { + // Allow return value of strict function to be boolean or string + // (or null/undefined, meaning no further processing). + // But catch any exceptions thrown by function, treating them + // like "error". + try { + strict = strict(errorCode, errorMsg, token); + } catch (error) { + strict = "error"; + } + } + if (!strict || strict === "ignore") { + return false; + } else if (strict === true || strict === "error") { + return true; + } else if (strict === "warn") { + typeof console !== "undefined" && console.warn("LaTeX-incompatible input and strict mode is set to 'warn': " + (errorMsg + " [" + errorCode + "]")); + return false; + } else { + // won't happen in type-safe code + typeof console !== "undefined" && console.warn("LaTeX-incompatible input and strict mode is set to " + ("unrecognized '" + strict + "': " + errorMsg + " [" + errorCode + "]")); + return false; + } + } + /** + * Check whether to test potentially dangerous input, and return + * `true` (trusted) or `false` (untrusted). The sole argument `context` + * should be an object with `command` field specifying the relevant LaTeX + * command (as a string starting with `\`), and any other arguments, etc. + * If `context` has a `url` field, a `protocol` field will automatically + * get added by this function (changing the specified object). + */ + isTrusted(context) { + if ("url" in context && context.url && !context.protocol) { + var protocol = protocolFromUrl(context.url); + if (protocol == null) { + return false; + } + context.protocol = protocol; + } + var trust = typeof this.trust === "function" ? this.trust(context) : this.trust; + return Boolean(trust); + } +} + +/** + * This file contains information and classes for the various kinds of styles + * used in TeX. It provides a generic `Style` class, which holds information + * about a specific style. It then provides instances of all the different kinds + * of styles possible, and provides functions to move between them and get + * information about them. + */ +/** + * The main style class. Contains a unique id for the style, a size (which is + * the same for cramped and uncramped version of a style), and a cramped flag. + */ +class Style { + constructor(id, size, cramped) { + this.id = void 0; + this.size = void 0; + this.cramped = void 0; + this.id = id; + this.size = size; + this.cramped = cramped; + } + /** + * Get the style of a superscript given a base in the current style. + */ + sup() { + return styles[sup[this.id]]; + } + /** + * Get the style of a subscript given a base in the current style. + */ + sub() { + return styles[sub[this.id]]; + } + /** + * Get the style of a fraction numerator given the fraction in the current + * style. + */ + fracNum() { + return styles[fracNum[this.id]]; + } + /** + * Get the style of a fraction denominator given the fraction in the current + * style. + */ + fracDen() { + return styles[fracDen[this.id]]; + } + /** + * Get the cramped version of a style (in particular, cramping a cramped style + * doesn't change the style). + */ + cramp() { + return styles[cramp[this.id]]; + } + /** + * Get a text or display version of this style. + */ + text() { + return styles[text$1[this.id]]; + } + /** + * Return true if this style is tightly spaced (scriptstyle/scriptscriptstyle) + */ + isTight() { + return this.size >= 2; + } +} +// IDs of the different styles +var D = 0; +var Dc = 1; +var T = 2; +var Tc = 3; +var S = 4; +var Sc = 5; +var SS = 6; +var SSc = 7; +// Instances of the different styles +var styles = [new Style(D, 0, false), new Style(Dc, 0, true), new Style(T, 1, false), new Style(Tc, 1, true), new Style(S, 2, false), new Style(Sc, 2, true), new Style(SS, 3, false), new Style(SSc, 3, true)]; +// Lookup tables for switching from one style to another +var sup = [S, Sc, S, Sc, SS, SSc, SS, SSc]; +var sub = [Sc, Sc, Sc, Sc, SSc, SSc, SSc, SSc]; +var fracNum = [T, Tc, S, Sc, SS, SSc, SS, SSc]; +var fracDen = [Tc, Tc, Sc, Sc, SSc, SSc, SSc, SSc]; +var cramp = [Dc, Dc, Tc, Tc, Sc, Sc, SSc, SSc]; +var text$1 = [D, Dc, T, Tc, T, Tc, T, Tc]; +// We only export some of the styles. +var Style$1 = { + DISPLAY: styles[D], + TEXT: styles[T], + SCRIPT: styles[S], + SCRIPTSCRIPT: styles[SS] +}; + +/* + * This file defines the Unicode scripts and script families that we + * support. To add new scripts or families, just add a new entry to the + * scriptData array below. Adding scripts to the scriptData array allows + * characters from that script to appear in \text{} environments. + */ +/** + * Unicode block data for the families of scripts we support in \text{}. + * Scripts only need to appear here if they do not have font metrics. + */ +var scriptData = [{ + // Latin characters beyond the Latin-1 characters we have metrics for. + // Needed for Czech, Hungarian and Turkish text, for example. + name: 'latin', + blocks: [[0x0100, 0x024f], + // Latin Extended-A and Latin Extended-B + [0x0300, 0x036f] // Combining Diacritical marks + ] +}, { + // The Cyrillic script used by Russian and related languages. + // A Cyrillic subset used to be supported as explicitly defined + // symbols in symbols.js + name: 'cyrillic', + blocks: [[0x0400, 0x04ff]] +}, { + // Armenian + name: 'armenian', + blocks: [[0x0530, 0x058F]] +}, { + // The Brahmic scripts of South and Southeast Asia + // Devanagari (0900–097F) + // Bengali (0980–09FF) + // Gurmukhi (0A00–0A7F) + // Gujarati (0A80–0AFF) + // Oriya (0B00–0B7F) + // Tamil (0B80–0BFF) + // Telugu (0C00–0C7F) + // Kannada (0C80–0CFF) + // Malayalam (0D00–0D7F) + // Sinhala (0D80–0DFF) + // Thai (0E00–0E7F) + // Lao (0E80–0EFF) + // Tibetan (0F00–0FFF) + // Myanmar (1000–109F) + name: 'brahmic', + blocks: [[0x0900, 0x109F]] +}, { + name: 'georgian', + blocks: [[0x10A0, 0x10ff]] +}, { + // Chinese and Japanese. + // The "k" in cjk is for Korean, but we've separated Korean out + name: "cjk", + blocks: [[0x3000, 0x30FF], + // CJK symbols and punctuation, Hiragana, Katakana + [0x4E00, 0x9FAF], + // CJK ideograms + [0xFF00, 0xFF60] // Fullwidth punctuation + // TODO: add halfwidth Katakana and Romanji glyphs + ] +}, { + // Korean + name: 'hangul', + blocks: [[0xAC00, 0xD7AF]] +}]; +/** + * Given a codepoint, return the name of the script or script family + * it is from, or null if it is not part of a known block + */ +function scriptFromCodepoint(codepoint) { + for (var i = 0; i < scriptData.length; i++) { + var script = scriptData[i]; + for (var _i = 0; _i < script.blocks.length; _i++) { + var block = script.blocks[_i]; + if (codepoint >= block[0] && codepoint <= block[1]) { + return script.name; + } + } + } + return null; +} +/** + * A flattened version of all the supported blocks in a single array. + * This is an optimization to make supportedCodepoint() fast. + */ +var allBlocks = []; +scriptData.forEach(s => s.blocks.forEach(b => allBlocks.push(...b))); +/** + * Given a codepoint, return true if it falls within one of the + * scripts or script families defined above and false otherwise. + * + * Micro benchmarks shows that this is faster than + * /[\u3000-\u30FF\u4E00-\u9FAF\uFF00-\uFF60\uAC00-\uD7AF\u0900-\u109F]/.test() + * in Firefox, Chrome and Node. + */ +function supportedCodepoint(codepoint) { + for (var i = 0; i < allBlocks.length; i += 2) { + if (codepoint >= allBlocks[i] && codepoint <= allBlocks[i + 1]) { + return true; + } + } + return false; +} + +/** + * This file provides support to domTree.js and delimiter.js. + * It's a storehouse of path geometry for SVG images. + */ +// In all paths below, the viewBox-to-em scale is 1000:1. +// Second Brush Stroke +// Low resolution monitors struggle to display images in fine detail. +// So browsers apply anti-aliasing. A long straight arrow shaft therefore +// will sometimes appear as if it has a blurred edge. +// To mitigate this, these SVG files contain a second "brush-stroke" on the +// arrow shafts. That is, a second long thin rectangular SVG path has been +// written directly on top of each arrow shaft. This reinforcement causes +// some of the screen pixels to display as black instead of the anti-aliased +// gray pixel that a single path would generate. So we get arrow shafts +// whose edges appear to be sharper. +var doubleBrushStroke = svgPath => svgPath + " " + svgPath; +var hLinePad = 80; // padding above a sqrt vinculum. Prevents image cropping. +// The vinculum of a \sqrt can be made thicker by a KaTeX rendering option. +// Think of variable extraVinculum as two detours in the SVG path. +// The detour begins at the lower left of the area labeled extraVinculum below. +// The detour proceeds one extraVinculum distance up and slightly to the right, +// displacing the radiused corner between surd and vinculum. The radius is +// traversed as usual, then the detour resumes. It goes right, to the end of +// the very long vinculum, then down one extraVinculum distance, +// after which it resumes regular path geometry for the radical. +/* vinculum + / + /▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒←extraVinculum + / █████████████████████←0.04em (40 unit) std vinculum thickness + / / + / / + / /\ + / / surd +*/ +var sqrtMain = function sqrtMain(extraVinculum, hLinePad) { + // sqrtMain path geometry is from glyph U221A in the font KaTeX Main + return "M95," + (622 + extraVinculum + hLinePad) + "\nc-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14\nc0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54\nc44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10\ns173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429\nc69,-144,104.5,-217.7,106.5,-221\nl" + extraVinculum / 2.075 + " -" + extraVinculum + "\nc5.3,-9.3,12,-14,20,-14\nH400000v" + (40 + extraVinculum) + "H845.2724\ns-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7\nc-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z\nM" + (834 + extraVinculum) + " " + hLinePad + "h400000v" + (40 + extraVinculum) + "h-400000z"; +}; +var sqrtSize1 = function sqrtSize1(extraVinculum, hLinePad) { + // size1 is from glyph U221A in the font KaTeX_Size1-Regular + return "M263," + (601 + extraVinculum + hLinePad) + "c0.7,0,18,39.7,52,119\nc34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120\nc340,-704.7,510.7,-1060.3,512,-1067\nl" + extraVinculum / 2.084 + " -" + extraVinculum + "\nc4.7,-7.3,11,-11,19,-11\nH40000v" + (40 + extraVinculum) + "H1012.3\ns-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232\nc-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1\ns-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26\nc-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z\nM" + (1001 + extraVinculum) + " " + hLinePad + "h400000v" + (40 + extraVinculum) + "h-400000z"; +}; +var sqrtSize2 = function sqrtSize2(extraVinculum, hLinePad) { + // size2 is from glyph U221A in the font KaTeX_Size2-Regular + return "M983 " + (10 + extraVinculum + hLinePad) + "\nl" + extraVinculum / 3.13 + " -" + extraVinculum + "\nc4,-6.7,10,-10,18,-10 H400000v" + (40 + extraVinculum) + "\nH1013.1s-83.4,268,-264.1,840c-180.7,572,-277,876.3,-289,913c-4.7,4.7,-12.7,7,-24,7\ns-12,0,-12,0c-1.3,-3.3,-3.7,-11.7,-7,-25c-35.3,-125.3,-106.7,-373.3,-214,-744\nc-10,12,-21,25,-33,39s-32,39,-32,39c-6,-5.3,-15,-14,-27,-26s25,-30,25,-30\nc26.7,-32.7,52,-63,76,-91s52,-60,52,-60s208,722,208,722\nc56,-175.3,126.3,-397.3,211,-666c84.7,-268.7,153.8,-488.2,207.5,-658.5\nc53.7,-170.3,84.5,-266.8,92.5,-289.5z\nM" + (1001 + extraVinculum) + " " + hLinePad + "h400000v" + (40 + extraVinculum) + "h-400000z"; +}; +var sqrtSize3 = function sqrtSize3(extraVinculum, hLinePad) { + // size3 is from glyph U221A in the font KaTeX_Size3-Regular + return "M424," + (2398 + extraVinculum + hLinePad) + "\nc-1.3,-0.7,-38.5,-172,-111.5,-514c-73,-342,-109.8,-513.3,-110.5,-514\nc0,-2,-10.7,14.3,-32,49c-4.7,7.3,-9.8,15.7,-15.5,25c-5.7,9.3,-9.8,16,-12.5,20\ns-5,7,-5,7c-4,-3.3,-8.3,-7.7,-13,-13s-13,-13,-13,-13s76,-122,76,-122s77,-121,77,-121\ns209,968,209,968c0,-2,84.7,-361.7,254,-1079c169.3,-717.3,254.7,-1077.7,256,-1081\nl" + extraVinculum / 4.223 + " -" + extraVinculum + "c4,-6.7,10,-10,18,-10 H400000\nv" + (40 + extraVinculum) + "H1014.6\ns-87.3,378.7,-272.6,1166c-185.3,787.3,-279.3,1182.3,-282,1185\nc-2,6,-10,9,-24,9\nc-8,0,-12,-0.7,-12,-2z M" + (1001 + extraVinculum) + " " + hLinePad + "\nh400000v" + (40 + extraVinculum) + "h-400000z"; +}; +var sqrtSize4 = function sqrtSize4(extraVinculum, hLinePad) { + // size4 is from glyph U221A in the font KaTeX_Size4-Regular + return "M473," + (2713 + extraVinculum + hLinePad) + "\nc339.3,-1799.3,509.3,-2700,510,-2702 l" + extraVinculum / 5.298 + " -" + extraVinculum + "\nc3.3,-7.3,9.3,-11,18,-11 H400000v" + (40 + extraVinculum) + "H1017.7\ns-90.5,478,-276.2,1466c-185.7,988,-279.5,1483,-281.5,1485c-2,6,-10,9,-24,9\nc-8,0,-12,-0.7,-12,-2c0,-1.3,-5.3,-32,-16,-92c-50.7,-293.3,-119.7,-693.3,-207,-1200\nc0,-1.3,-5.3,8.7,-16,30c-10.7,21.3,-21.3,42.7,-32,64s-16,33,-16,33s-26,-26,-26,-26\ns76,-153,76,-153s77,-151,77,-151c0.7,0.7,35.7,202,105,604c67.3,400.7,102,602.7,104,\n606zM" + (1001 + extraVinculum) + " " + hLinePad + "h400000v" + (40 + extraVinculum) + "H1017.7z"; +}; +var phasePath = function phasePath(y) { + var x = y / 2; // x coordinate at top of angle + return "M400000 " + y + " H0 L" + x + " 0 l65 45 L145 " + (y - 80) + " H400000z"; +}; +var sqrtTall = function sqrtTall(extraVinculum, hLinePad, viewBoxHeight) { + // sqrtTall is from glyph U23B7 in the font KaTeX_Size4-Regular + // One path edge has a variable length. It runs vertically from the vinculum + // to a point near (14 units) the bottom of the surd. The vinculum + // is normally 40 units thick. So the length of the line in question is: + var vertSegment = viewBoxHeight - 54 - hLinePad - extraVinculum; + return "M702 " + (extraVinculum + hLinePad) + "H400000" + (40 + extraVinculum) + "\nH742v" + vertSegment + "l-4 4-4 4c-.667.7 -2 1.5-4 2.5s-4.167 1.833-6.5 2.5-5.5 1-9.5 1\nh-12l-28-84c-16.667-52-96.667 -294.333-240-727l-212 -643 -85 170\nc-4-3.333-8.333-7.667-13 -13l-13-13l77-155 77-156c66 199.333 139 419.667\n219 661 l218 661zM702 " + hLinePad + "H400000v" + (40 + extraVinculum) + "H742z"; +}; +var sqrtPath = function sqrtPath(size, extraVinculum, viewBoxHeight) { + extraVinculum = 1000 * extraVinculum; // Convert from document ems to viewBox. + var path = ""; + switch (size) { + case "sqrtMain": + path = sqrtMain(extraVinculum, hLinePad); + break; + case "sqrtSize1": + path = sqrtSize1(extraVinculum, hLinePad); + break; + case "sqrtSize2": + path = sqrtSize2(extraVinculum, hLinePad); + break; + case "sqrtSize3": + path = sqrtSize3(extraVinculum, hLinePad); + break; + case "sqrtSize4": + path = sqrtSize4(extraVinculum, hLinePad); + break; + case "sqrtTall": + path = sqrtTall(extraVinculum, hLinePad, viewBoxHeight); + } + return path; +}; +var innerPath = function innerPath(name, height) { + // The inner part of stretchy tall delimiters + switch (name) { + case "\u239c": + return doubleBrushStroke("M291 0 H417 V" + height + " H291z"); + case "\u2223": + return doubleBrushStroke("M145 0 H188 V" + height + " H145z"); + case "\u2225": + return doubleBrushStroke("M145 0 H188 V" + height + " H145z") + doubleBrushStroke("M367 0 H410 V" + height + " H367z"); + case "\u239f": + return doubleBrushStroke("M457 0 H583 V" + height + " H457z"); + case "\u23a2": + return doubleBrushStroke("M319 0 H403 V" + height + " H319z"); + case "\u23a5": + return doubleBrushStroke("M263 0 H347 V" + height + " H263z"); + case "\u23aa": + return doubleBrushStroke("M384 0 H504 V" + height + " H384z"); + case "\u23d0": + return doubleBrushStroke("M312 0 H355 V" + height + " H312z"); + case "\u2016": + return doubleBrushStroke("M257 0 H300 V" + height + " H257z") + doubleBrushStroke("M478 0 H521 V" + height + " H478z"); + default: + return ""; + } +}; +var path = { + // The doubleleftarrow geometry is from glyph U+21D0 in the font KaTeX Main + doubleleftarrow: "M262 157\nl10-10c34-36 62.7-77 86-123 3.3-8 5-13.3 5-16 0-5.3-6.7-8-20-8-7.3\n 0-12.2.5-14.5 1.5-2.3 1-4.8 4.5-7.5 10.5-49.3 97.3-121.7 169.3-217 216-28\n 14-57.3 25-88 33-6.7 2-11 3.8-13 5.5-2 1.7-3 4.2-3 7.5s1 5.8 3 7.5\nc2 1.7 6.3 3.5 13 5.5 68 17.3 128.2 47.8 180.5 91.5 52.3 43.7 93.8 96.2 124.5\n 157.5 9.3 8 15.3 12.3 18 13h6c12-.7 18-4 18-10 0-2-1.7-7-5-15-23.3-46-52-87\n-86-123l-10-10h399738v-40H218c328 0 0 0 0 0l-10-8c-26.7-20-65.7-43-117-69 2.7\n-2 6-3.7 10-5 36.7-16 72.3-37.3 107-64l10-8h399782v-40z\nm8 0v40h399730v-40zm0 194v40h399730v-40z", + // doublerightarrow is from glyph U+21D2 in font KaTeX Main + doublerightarrow: "M399738 392l\n-10 10c-34 36-62.7 77-86 123-3.3 8-5 13.3-5 16 0 5.3 6.7 8 20 8 7.3 0 12.2-.5\n 14.5-1.5 2.3-1 4.8-4.5 7.5-10.5 49.3-97.3 121.7-169.3 217-216 28-14 57.3-25 88\n-33 6.7-2 11-3.8 13-5.5 2-1.7 3-4.2 3-7.5s-1-5.8-3-7.5c-2-1.7-6.3-3.5-13-5.5-68\n-17.3-128.2-47.8-180.5-91.5-52.3-43.7-93.8-96.2-124.5-157.5-9.3-8-15.3-12.3-18\n-13h-6c-12 .7-18 4-18 10 0 2 1.7 7 5 15 23.3 46 52 87 86 123l10 10H0v40h399782\nc-328 0 0 0 0 0l10 8c26.7 20 65.7 43 117 69-2.7 2-6 3.7-10 5-36.7 16-72.3 37.3\n-107 64l-10 8H0v40zM0 157v40h399730v-40zm0 194v40h399730v-40z", + // leftarrow is from glyph U+2190 in font KaTeX Main + leftarrow: "M400000 241H110l3-3c68.7-52.7 113.7-120\n 135-202 4-14.7 6-23 6-25 0-7.3-7-11-21-11-8 0-13.2.8-15.5 2.5-2.3 1.7-4.2 5.8\n-5.5 12.5-1.3 4.7-2.7 10.3-4 17-12 48.7-34.8 92-68.5 130S65.3 228.3 18 247\nc-10 4-16 7.7-18 11 0 8.7 6 14.3 18 17 47.3 18.7 87.8 47 121.5 85S196 441.3 208\n 490c.7 2 1.3 5 2 9s1.2 6.7 1.5 8c.3 1.3 1 3.3 2 6s2.2 4.5 3.5 5.5c1.3 1 3.3\n 1.8 6 2.5s6 1 10 1c14 0 21-3.7 21-11 0-2-2-10.3-6-25-20-79.3-65-146.7-135-202\n l-3-3h399890zM100 241v40h399900v-40z", + // overbrace is from glyphs U+23A9/23A8/23A7 in font KaTeX_Size4-Regular + leftbrace: "M6 548l-6-6v-35l6-11c56-104 135.3-181.3 238-232 57.3-28.7 117\n-45 179-50h399577v120H403c-43.3 7-81 15-113 26-100.7 33-179.7 91-237 174-2.7\n 5-6 9-10 13-.7 1-7.3 1-20 1H6z", + leftbraceunder: "M0 6l6-6h17c12.688 0 19.313.3 20 1 4 4 7.313 8.3 10 13\n 35.313 51.3 80.813 93.8 136.5 127.5 55.688 33.7 117.188 55.8 184.5 66.5.688\n 0 2 .3 4 1 18.688 2.7 76 4.3 172 5h399450v120H429l-6-1c-124.688-8-235-61.7\n-331-161C60.687 138.7 32.312 99.3 7 54L0 41V6z", + // overgroup is from the MnSymbol package (public domain) + leftgroup: "M400000 80\nH435C64 80 168.3 229.4 21 260c-5.9 1.2-18 0-18 0-2 0-3-1-3-3v-38C76 61 257 0\n 435 0h399565z", + leftgroupunder: "M400000 262\nH435C64 262 168.3 112.6 21 82c-5.9-1.2-18 0-18 0-2 0-3 1-3 3v38c76 158 257 219\n 435 219h399565z", + // Harpoons are from glyph U+21BD in font KaTeX Main + leftharpoon: "M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3\n-3.3 10.2-9.5 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5\n-18.3 3-21-1.3-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7\n-196 228-6.7 4.7-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40z", + leftharpoonplus: "M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3-3.3 10.2-9.5\n 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5-18.3 3-21-1.3\n-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7-196 228-6.7 4.7\n-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40zM0 435v40h400000v-40z\nm0 0v40h400000v-40z", + leftharpoondown: "M7 241c-4 4-6.333 8.667-7 14 0 5.333.667 9 2 11s5.333\n 5.333 12 10c90.667 54 156 130 196 228 3.333 10.667 6.333 16.333 9 17 2 .667 5\n 1 9 1h5c10.667 0 16.667-2 18-6 2-2.667 1-9.667-3-21-32-87.333-82.667-157.667\n-152-211l-3-3h399907v-40zM93 281 H400000 v-40L7 241z", + leftharpoondownplus: "M7 435c-4 4-6.3 8.7-7 14 0 5.3.7 9 2 11s5.3 5.3 12\n 10c90.7 54 156 130 196 228 3.3 10.7 6.3 16.3 9 17 2 .7 5 1 9 1h5c10.7 0 16.7\n-2 18-6 2-2.7 1-9.7-3-21-32-87.3-82.7-157.7-152-211l-3-3h399907v-40H7zm93 0\nv40h399900v-40zM0 241v40h399900v-40zm0 0v40h399900v-40z", + // hook is from glyph U+21A9 in font KaTeX Main + lefthook: "M400000 281 H103s-33-11.2-61-33.5S0 197.3 0 164s14.2-61.2 42.5\n-83.5C70.8 58.2 104 47 142 47 c16.7 0 25 6.7 25 20 0 12-8.7 18.7-26 20-40 3.3\n-68.7 15.7-86 37-10 12-15 25.3-15 40 0 22.7 9.8 40.7 29.5 54 19.7 13.3 43.5 21\n 71.5 23h399859zM103 281v-40h399897v40z", + leftlinesegment: doubleBrushStroke("M40 281 V428 H0 V94 H40 V241 H400000 v40z"), + leftbracketunder: doubleBrushStroke("M0 0 h120 V290 H399995 v120 H0z"), + leftbracketover: doubleBrushStroke("M0 440 h120 V150 H399995 v-120 H0z"), + leftmapsto: doubleBrushStroke("M40 281 V448H0V74H40V241H400000v40z"), + // tofrom is from glyph U+21C4 in font KaTeX AMS Regular + leftToFrom: "M0 147h400000v40H0zm0 214c68 40 115.7 95.7 143 167h22c15.3 0 23\n-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69-70-101l-7-8h399905v-40H95l7-8\nc28.7-32 52-65.7 70-101 10.7-23.3 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 265.3\n 68 321 0 361zm0-174v-40h399900v40zm100 154v40h399900v-40z", + longequal: doubleBrushStroke("M0 50 h400000 v40H0z m0 194h40000v40H0z"), + midbrace: "M200428 334\nc-100.7-8.3-195.3-44-280-108-55.3-42-101.7-93-139-153l-9-14c-2.7 4-5.7 8.7-9 14\n-53.3 86.7-123.7 153-211 199-66.7 36-137.3 56.3-212 62H0V214h199568c178.3-11.7\n 311.7-78.3 403-201 6-8 9.7-12 11-12 .7-.7 6.7-1 18-1s17.3.3 18 1c1.3 0 5 4 11\n 12 44.7 59.3 101.3 106.3 170 141s145.3 54.3 229 60h199572v120z", + midbraceunder: "M199572 214\nc100.7 8.3 195.3 44 280 108 55.3 42 101.7 93 139 153l9 14c2.7-4 5.7-8.7 9-14\n 53.3-86.7 123.7-153 211-199 66.7-36 137.3-56.3 212-62h199568v120H200432c-178.3\n 11.7-311.7 78.3-403 201-6 8-9.7 12-11 12-.7.7-6.7 1-18 1s-17.3-.3-18-1c-1.3 0\n-5-4-11-12-44.7-59.3-101.3-106.3-170-141s-145.3-54.3-229-60H0V214z", + oiintSize1: "M512.6 71.6c272.6 0 320.3 106.8 320.3 178.2 0 70.8-47.7 177.6\n-320.3 177.6S193.1 320.6 193.1 249.8c0-71.4 46.9-178.2 319.5-178.2z\nm368.1 178.2c0-86.4-60.9-215.4-368.1-215.4-306.4 0-367.3 129-367.3 215.4 0 85.8\n60.9 214.8 367.3 214.8 307.2 0 368.1-129 368.1-214.8z", + oiintSize2: "M757.8 100.1c384.7 0 451.1 137.6 451.1 230 0 91.3-66.4 228.8\n-451.1 228.8-386.3 0-452.7-137.5-452.7-228.8 0-92.4 66.4-230 452.7-230z\nm502.4 230c0-111.2-82.4-277.2-502.4-277.2s-504 166-504 277.2\nc0 110 84 276 504 276s502.4-166 502.4-276z", + oiiintSize1: "M681.4 71.6c408.9 0 480.5 106.8 480.5 178.2 0 70.8-71.6 177.6\n-480.5 177.6S202.1 320.6 202.1 249.8c0-71.4 70.5-178.2 479.3-178.2z\nm525.8 178.2c0-86.4-86.8-215.4-525.7-215.4-437.9 0-524.7 129-524.7 215.4 0\n85.8 86.8 214.8 524.7 214.8 438.9 0 525.7-129 525.7-214.8z", + oiiintSize2: "M1021.2 53c603.6 0 707.8 165.8 707.8 277.2 0 110-104.2 275.8\n-707.8 275.8-606 0-710.2-165.8-710.2-275.8C311 218.8 415.2 53 1021.2 53z\nm770.4 277.1c0-131.2-126.4-327.6-770.5-327.6S248.4 198.9 248.4 330.1\nc0 130 128.8 326.4 772.7 326.4s770.5-196.4 770.5-326.4z", + rightarrow: "M0 241v40h399891c-47.3 35.3-84 78-110 128\n-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20\n 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7\n 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85\n-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5\n-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67\n 151.7 139 205zm0 0v40h399900v-40z", + rightbrace: "M400000 542l\n-6 6h-17c-12.7 0-19.3-.3-20-1-4-4-7.3-8.3-10-13-35.3-51.3-80.8-93.8-136.5-127.5\ns-117.2-55.8-184.5-66.5c-.7 0-2-.3-4-1-18.7-2.7-76-4.3-172-5H0V214h399571l6 1\nc124.7 8 235 61.7 331 161 31.3 33.3 59.7 72.7 85 118l7 13v35z", + rightbraceunder: "M399994 0l6 6v35l-6 11c-56 104-135.3 181.3-238 232-57.3\n 28.7-117 45-179 50H-300V214h399897c43.3-7 81-15 113-26 100.7-33 179.7-91 237\n-174 2.7-5 6-9 10-13 .7-1 7.3-1 20-1h17z", + rightgroup: "M0 80h399565c371 0 266.7 149.4 414 180 5.9 1.2 18 0 18 0 2 0\n 3-1 3-3v-38c-76-158-257-219-435-219H0z", + rightgroupunder: "M0 262h399565c371 0 266.7-149.4 414-180 5.9-1.2 18 0 18\n 0 2 0 3 1 3 3v38c-76 158-257 219-435 219H0z", + rightharpoon: "M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3\n-3.7-15.3-11-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2\n-10.7 0-16.7 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58\n 69.2 92 94.5zm0 0v40h399900v-40z", + rightharpoonplus: "M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3-3.7-15.3-11\n-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2-10.7 0-16.7\n 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58 69.2 92 94.5z\nm0 0v40h399900v-40z m100 194v40h399900v-40zm0 0v40h399900v-40z", + rightharpoondown: "M399747 511c0 7.3 6.7 11 20 11 8 0 13-.8 15-2.5s4.7-6.8\n 8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3 8.5-5.8 9.5\n-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3-64.7 57-92 95\n-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 241v40h399900v-40z", + rightharpoondownplus: "M399747 705c0 7.3 6.7 11 20 11 8 0 13-.8\n 15-2.5s4.7-6.8 8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3\n 8.5-5.8 9.5-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3\n-64.7 57-92 95-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 435v40h399900v-40z\nm0-194v40h400000v-40zm0 0v40h400000v-40z", + righthook: "M399859 241c-764 0 0 0 0 0 40-3.3 68.7-15.7 86-37 10-12 15-25.3\n 15-40 0-22.7-9.8-40.7-29.5-54-19.7-13.3-43.5-21-71.5-23-17.3-1.3-26-8-26-20 0\n-13.3 8.7-20 26-20 38 0 71 11.2 99 33.5 0 0 7 5.6 21 16.7 14 11.2 21 33.5 21\n 66.8s-14 61.2-42 83.5c-28 22.3-61 33.5-99 33.5L0 241z M0 281v-40h399859v40z", + rightlinesegment: doubleBrushStroke("M399960 241 V94 h40 V428 h-40 V281 H0 v-40z"), + rightbracketunder: doubleBrushStroke("M399995 0 h-120 V290 H0 v120 H400000z"), + rightbracketover: doubleBrushStroke("M399995 440 h-120 V150 H0 v-120 H399995z"), + rightToFrom: "M400000 167c-70.7-42-118-97.7-142-167h-23c-15.3 0-23 .3-23\n 1 0 1.3 5.3 13.7 16 37 18 35.3 41.3 69 70 101l7 8H0v40h399905l-7 8c-28.7 32\n-52 65.7-70 101-10.7 23.3-16 35.7-16 37 0 .7 7.7 1 23 1h23c24-69.3 71.3-125 142\n-167z M100 147v40h399900v-40zM0 341v40h399900v-40z", + // twoheadleftarrow is from glyph U+219E in font KaTeX AMS Regular + twoheadleftarrow: "M0 167c68 40\n 115.7 95.7 143 167h22c15.3 0 23-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69\n-70-101l-7-8h125l9 7c50.7 39.3 85 86 103 140h46c0-4.7-6.3-18.7-19-42-18-35.3\n-40-67.3-66-96l-9-9h399716v-40H284l9-9c26-28.7 48-60.7 66-96 12.7-23.333 19\n-37.333 19-42h-46c-18 54-52.3 100.7-103 140l-9 7H95l7-8c28.7-32 52-65.7 70-101\n 10.7-23.333 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 71.3 68 127 0 167z", + twoheadrightarrow: "M400000 167\nc-68-40-115.7-95.7-143-167h-22c-15.3 0-23 .3-23 1 0 1.3 5.3 13.7 16 37 18 35.3\n 41.3 69 70 101l7 8h-125l-9-7c-50.7-39.3-85-86-103-140h-46c0 4.7 6.3 18.7 19 42\n 18 35.3 40 67.3 66 96l9 9H0v40h399716l-9 9c-26 28.7-48 60.7-66 96-12.7 23.333\n-19 37.333-19 42h46c18-54 52.3-100.7 103-140l9-7h125l-7 8c-28.7 32-52 65.7-70\n 101-10.7 23.333-16 35.7-16 37 0 .7 7.7 1 23 1h22c27.3-71.3 75-127 143-167z", + // tilde1 is a modified version of a glyph from the MnSymbol package + tilde1: "M200 55.538c-77 0-168 73.953-177 73.953-3 0-7\n-2.175-9-5.437L2 97c-1-2-2-4-2-6 0-4 2-7 5-9l20-12C116 12 171 0 207 0c86 0\n 114 68 191 68 78 0 168-68 177-68 4 0 7 2 9 5l12 19c1 2.175 2 4.35 2 6.525 0\n 4.35-2 7.613-5 9.788l-19 13.05c-92 63.077-116.937 75.308-183 76.128\n-68.267.847-113-73.952-191-73.952z", + // ditto tilde2, tilde3, & tilde4 + tilde2: "M344 55.266c-142 0-300.638 81.316-311.5 86.418\n-8.01 3.762-22.5 10.91-23.5 5.562L1 120c-1-2-1-3-1-4 0-5 3-9 8-10l18.4-9C160.9\n 31.9 283 0 358 0c148 0 188 122 331 122s314-97 326-97c4 0 8 2 10 7l7 21.114\nc1 2.14 1 3.21 1 4.28 0 5.347-3 9.626-7 10.696l-22.3 12.622C852.6 158.372 751\n 181.476 676 181.476c-149 0-189-126.21-332-126.21z", + tilde3: "M786 59C457 59 32 175.242 13 175.242c-6 0-10-3.457\n-11-10.37L.15 138c-1-7 3-12 10-13l19.2-6.4C378.4 40.7 634.3 0 804.3 0c337 0\n 411.8 157 746.8 157 328 0 754-112 773-112 5 0 10 3 11 9l1 14.075c1 8.066-.697\n 16.595-6.697 17.492l-21.052 7.31c-367.9 98.146-609.15 122.696-778.15 122.696\n -338 0-409-156.573-744-156.573z", + tilde4: "M786 58C457 58 32 177.487 13 177.487c-6 0-10-3.345\n-11-10.035L.15 143c-1-7 3-12 10-13l22-6.7C381.2 35 637.15 0 807.15 0c337 0 409\n 177 744 177 328 0 754-127 773-127 5 0 10 3 11 9l1 14.794c1 7.805-3 13.38-9\n 14.495l-20.7 5.574c-366.85 99.79-607.3 139.372-776.3 139.372-338 0-409\n -175.236-744-175.236z", + // vec is from glyph U+20D7 in font KaTeX Main + vec: "M377 20c0-5.333 1.833-10 5.5-14S391 0 397 0c4.667 0 8.667 1.667 12 5\n3.333 2.667 6.667 9 10 19 6.667 24.667 20.333 43.667 41 57 7.333 4.667 11\n10.667 11 18 0 6-1 10-3 12s-6.667 5-14 9c-28.667 14.667-53.667 35.667-75 63\n-1.333 1.333-3.167 3.5-5.5 6.5s-4 4.833-5 5.5c-1 .667-2.5 1.333-4.5 2s-4.333 1\n-7 1c-4.667 0-9.167-1.833-13.5-5.5S337 184 337 178c0-12.667 15.667-32.333 47-59\nH213l-171-1c-8.667-6-13-12.333-13-19 0-4.667 4.333-11.333 13-20h359\nc-16-25.333-24-45-24-59z", + // widehat1 is a modified version of a glyph from the MnSymbol package + widehat1: "M529 0h5l519 115c5 1 9 5 9 10 0 1-1 2-1 3l-4 22\nc-1 5-5 9-11 9h-2L532 67 19 159h-2c-5 0-9-4-11-9l-5-22c-1-6 2-12 8-13z", + // ditto widehat2, widehat3, & widehat4 + widehat2: "M1181 0h2l1171 176c6 0 10 5 10 11l-2 23c-1 6-5 10\n-11 10h-1L1182 67 15 220h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z", + widehat3: "M1181 0h2l1171 236c6 0 10 5 10 11l-2 23c-1 6-5 10\n-11 10h-1L1182 67 15 280h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z", + widehat4: "M1181 0h2l1171 296c6 0 10 5 10 11l-2 23c-1 6-5 10\n-11 10h-1L1182 67 15 340h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z", + // widecheck paths are all inverted versions of widehat + widecheck1: "M529,159h5l519,-115c5,-1,9,-5,9,-10c0,-1,-1,-2,-1,-3l-4,-22c-1,\n-5,-5,-9,-11,-9h-2l-512,92l-513,-92h-2c-5,0,-9,4,-11,9l-5,22c-1,6,2,12,8,13z", + widecheck2: "M1181,220h2l1171,-176c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,\n-11,-10h-1l-1168,153l-1167,-153h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z", + widecheck3: "M1181,280h2l1171,-236c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,\n-11,-10h-1l-1168,213l-1167,-213h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z", + widecheck4: "M1181,340h2l1171,-296c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,\n-11,-10h-1l-1168,273l-1167,-273h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z", + // The next ten paths support reaction arrows from the mhchem package. + // Arrows for \ce{<-->} are offset from xAxis by 0.22ex, per mhchem in LaTeX + // baraboveleftarrow is mostly from glyph U+2190 in font KaTeX Main + baraboveleftarrow: "M400000 620h-399890l3 -3c68.7 -52.7 113.7 -120 135 -202\nc4 -14.7 6 -23 6 -25c0 -7.3 -7 -11 -21 -11c-8 0 -13.2 0.8 -15.5 2.5\nc-2.3 1.7 -4.2 5.8 -5.5 12.5c-1.3 4.7 -2.7 10.3 -4 17c-12 48.7 -34.8 92 -68.5 130\ns-74.2 66.3 -121.5 85c-10 4 -16 7.7 -18 11c0 8.7 6 14.3 18 17c47.3 18.7 87.8 47\n121.5 85s56.5 81.3 68.5 130c0.7 2 1.3 5 2 9s1.2 6.7 1.5 8c0.3 1.3 1 3.3 2 6\ns2.2 4.5 3.5 5.5c1.3 1 3.3 1.8 6 2.5s6 1 10 1c14 0 21 -3.7 21 -11\nc0 -2 -2 -10.3 -6 -25c-20 -79.3 -65 -146.7 -135 -202l-3 -3h399890z\nM100 620v40h399900v-40z M0 241v40h399900v-40zM0 241v40h399900v-40z", + // rightarrowabovebar is mostly from glyph U+2192, KaTeX Main + rightarrowabovebar: "M0 241v40h399891c-47.3 35.3-84 78-110 128-16.7 32\n-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20 11 8 0\n13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7 39\n-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85-40.5\n-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5\n-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67\n151.7 139 205zm96 379h399894v40H0zm0 0h399904v40H0z", + // The short left harpoon has 0.5em (i.e. 500 units) kern on the left end. + // Ref from mhchem.sty: \rlap{\raisebox{-.22ex}{$\kern0.5em + baraboveshortleftharpoon: "M507,435c-4,4,-6.3,8.7,-7,14c0,5.3,0.7,9,2,11\nc1.3,2,5.3,5.3,12,10c90.7,54,156,130,196,228c3.3,10.7,6.3,16.3,9,17\nc2,0.7,5,1,9,1c0,0,5,0,5,0c10.7,0,16.7,-2,18,-6c2,-2.7,1,-9.7,-3,-21\nc-32,-87.3,-82.7,-157.7,-152,-211c0,0,-3,-3,-3,-3l399351,0l0,-40\nc-398570,0,-399437,0,-399437,0z M593 435 v40 H399500 v-40z\nM0 281 v-40 H399908 v40z M0 281 v-40 H399908 v40z", + rightharpoonaboveshortbar: "M0,241 l0,40c399126,0,399993,0,399993,0\nc4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199,\n-231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6\nc-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z\nM0 241 v40 H399908 v-40z M0 475 v-40 H399500 v40z M0 475 v-40 H399500 v40z", + shortbaraboveleftharpoon: "M7,435c-4,4,-6.3,8.7,-7,14c0,5.3,0.7,9,2,11\nc1.3,2,5.3,5.3,12,10c90.7,54,156,130,196,228c3.3,10.7,6.3,16.3,9,17c2,0.7,5,1,9,\n1c0,0,5,0,5,0c10.7,0,16.7,-2,18,-6c2,-2.7,1,-9.7,-3,-21c-32,-87.3,-82.7,-157.7,\n-152,-211c0,0,-3,-3,-3,-3l399907,0l0,-40c-399126,0,-399993,0,-399993,0z\nM93 435 v40 H400000 v-40z M500 241 v40 H400000 v-40z M500 241 v40 H400000 v-40z", + shortrightharpoonabovebar: "M53,241l0,40c398570,0,399437,0,399437,0\nc4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199,\n-231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6\nc-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z\nM500 241 v40 H399408 v-40z M500 435 v40 H400000 v-40z" +}; +var tallDelim = function tallDelim(label, midHeight) { + switch (label) { + case "lbrack": + return "M403 1759 V84 H666 V0 H319 V1759 v" + midHeight + " v1759 v84 h347 v-84\nH403z M403 1759 V0 H319 V1759 v" + midHeight + " v1759 v84 h84z"; + case "rbrack": + return "M347 1759 V0 H0 V84 H263 V1759 v" + midHeight + " v1759 H0 v84 H347z\nM347 1759 V0 H263 V1759 v" + midHeight + " v1759 h84z"; + case "vert": + return "M145 15 v585 v" + midHeight + " v585 c2.667,10,9.667,15,21,15\nc10,0,16.667,-5,20,-15 v-585 v" + -midHeight + " v-585 c-2.667,-10,-9.667,-15,-21,-15\nc-10,0,-16.667,5,-20,15z M188 15 H145 v585 v" + midHeight + " v585 h43z"; + case "doublevert": + return "M145 15 v585 v" + midHeight + " v585 c2.667,10,9.667,15,21,15\nc10,0,16.667,-5,20,-15 v-585 v" + -midHeight + " v-585 c-2.667,-10,-9.667,-15,-21,-15\nc-10,0,-16.667,5,-20,15z M188 15 H145 v585 v" + midHeight + " v585 h43z\nM367 15 v585 v" + midHeight + " v585 c2.667,10,9.667,15,21,15\nc10,0,16.667,-5,20,-15 v-585 v" + -midHeight + " v-585 c-2.667,-10,-9.667,-15,-21,-15\nc-10,0,-16.667,5,-20,15z M410 15 H367 v585 v" + midHeight + " v585 h43z"; + case "lfloor": + return "M319 602 V0 H403 V602 v" + midHeight + " v1715 h263 v84 H319z\nMM319 602 V0 H403 V602 v" + midHeight + " v1715 H319z"; + case "rfloor": + return "M319 602 V0 H403 V602 v" + midHeight + " v1799 H0 v-84 H319z\nMM319 602 V0 H403 V602 v" + midHeight + " v1715 H319z"; + case "lceil": + return "M403 1759 V84 H666 V0 H319 V1759 v" + midHeight + " v602 h84z\nM403 1759 V0 H319 V1759 v" + midHeight + " v602 h84z"; + case "rceil": + return "M347 1759 V0 H0 V84 H263 V1759 v" + midHeight + " v602 h84z\nM347 1759 V0 h-84 V1759 v" + midHeight + " v602 h84z"; + case "lparen": + return "M863,9c0,-2,-2,-5,-6,-9c0,0,-17,0,-17,0c-12.7,0,-19.3,0.3,-20,1\nc-5.3,5.3,-10.3,11,-15,17c-242.7,294.7,-395.3,682,-458,1162c-21.3,163.3,-33.3,349,\n-36,557 l0," + (midHeight + 84) + "c0.2,6,0,26,0,60c2,159.3,10,310.7,24,454c53.3,528,210,\n949.7,470,1265c4.7,6,9.7,11.7,15,17c0.7,0.7,7,1,19,1c0,0,18,0,18,0c4,-4,6,-7,6,-9\nc0,-2.7,-3.3,-8.7,-10,-18c-135.3,-192.7,-235.5,-414.3,-300.5,-665c-65,-250.7,-102.5,\n-544.7,-112.5,-882c-2,-104,-3,-167,-3,-189\nl0,-" + (midHeight + 92) + "c0,-162.7,5.7,-314,17,-454c20.7,-272,63.7,-513,129,-723c65.3,\n-210,155.3,-396.3,270,-559c6.7,-9.3,10,-15.3,10,-18z"; + case "rparen": + return "M76,0c-16.7,0,-25,3,-25,9c0,2,2,6.3,6,13c21.3,28.7,42.3,60.3,\n63,95c96.7,156.7,172.8,332.5,228.5,527.5c55.7,195,92.8,416.5,111.5,664.5\nc11.3,139.3,17,290.7,17,454c0,28,1.7,43,3.3,45l0," + (midHeight + 9) + "\nc-3,4,-3.3,16.7,-3.3,38c0,162,-5.7,313.7,-17,455c-18.7,248,-55.8,469.3,-111.5,664\nc-55.7,194.7,-131.8,370.3,-228.5,527c-20.7,34.7,-41.7,66.3,-63,95c-2,3.3,-4,7,-6,11\nc0,7.3,5.7,11,17,11c0,0,11,0,11,0c9.3,0,14.3,-0.3,15,-1c5.3,-5.3,10.3,-11,15,-17\nc242.7,-294.7,395.3,-681.7,458,-1161c21.3,-164.7,33.3,-350.7,36,-558\nl0,-" + (midHeight + 144) + "c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,\n-470,-1265c-4.7,-6,-9.7,-11.7,-15,-17c-0.7,-0.7,-6.7,-1,-18,-1z"; + default: + // We should not ever get here. + throw new Error("Unknown stretchy delimiter."); + } +}; + +function isMathDomNode(node) { + return 'toText' in node; +} +/** + * This node represents a document fragment, which contains elements, but when + * placed into the DOM doesn't have any representation itself. It only contains + * children and doesn't have any DOM node properties. + */ +class DocumentFragment { + // Never used; needed for satisfying interface. + constructor(children) { + this.children = void 0; + this.classes = void 0; + this.height = void 0; + this.depth = void 0; + this.maxFontSize = void 0; + this.style = void 0; + this.children = children; + this.classes = []; + this.height = 0; + this.depth = 0; + this.maxFontSize = 0; + this.style = {}; + } + hasClass(className) { + return this.classes.includes(className); + } + /** Convert the fragment into a node. */ + toNode() { + var frag = document.createDocumentFragment(); + for (var i = 0; i < this.children.length; i++) { + frag.appendChild(this.children[i].toNode()); + } + return frag; + } + /** Convert the fragment into HTML markup. */ + toMarkup() { + var markup = ""; + // Simply concatenate the markup for the children together. + for (var i = 0; i < this.children.length; i++) { + markup += this.children[i].toMarkup(); + } + return markup; + } + /** + * Converts the math node into a string, similar to innerText. Applies to + * MathDomNode's only. + */ + toText() { + return this.children.map(child => { + if (isMathDomNode(child)) { + return child.toText(); + } + throw new Error("Expected MathDomNode with toText, got " + child.constructor.name); + }).join(""); + } +} + +/** + * This file does conversion between units. In particular, it provides + * calculateSize to convert other units into ems. + */ +// This table gives the number of TeX pts in one of each *absolute* TeX unit. +// Thus, multiplying a length by this number converts the length from units +// into pts. Dividing the result by ptPerEm gives the number of ems +// *assuming* a font size of ptPerEm (normal size, normal style). +var ptPerUnit = { + // https://en.wikibooks.org/wiki/LaTeX/Lengths and + // https://tex.stackexchange.com/a/8263 + "pt": 1, + // TeX point + "mm": 7227 / 2540, + // millimeter + "cm": 7227 / 254, + // centimeter + "in": 72.27, + // inch + "bp": 803 / 800, + // big (PostScript) points + "pc": 12, + // pica + "dd": 1238 / 1157, + // didot + "cc": 14856 / 1157, + // cicero (12 didot) + "nd": 685 / 642, + // new didot + "nc": 1370 / 107, + // new cicero (12 new didot) + "sp": 1 / 65536, + // scaled point (TeX's internal smallest unit) + // https://tex.stackexchange.com/a/41371 + "px": 803 / 800 // \pdfpxdimen defaults to 1 bp in pdfTeX and LuaTeX +}; +// Dictionary of relative units, for fast validity testing. +var relativeUnit = { + "ex": true, + "em": true, + "mu": true +}; +/** + * Determine whether the specified unit (either a string defining the unit + * or a "size" parse node containing a unit field) is valid. + */ +var validUnit = function validUnit(unit) { + if (typeof unit !== "string") { + unit = unit.unit; + } + return unit in ptPerUnit || unit in relativeUnit || unit === "ex"; +}; +/* + * Convert a "size" parse node (with numeric "number" and string "unit" fields, + * as parsed by functions.js argType "size") into a CSS em value for the + * current style/scale. `options` gives the current options. + */ +var calculateSize = function calculateSize(sizeValue, options) { + var scale; + if (sizeValue.unit in ptPerUnit) { + // Absolute units + scale = ptPerUnit[sizeValue.unit] // Convert unit to pt + / options.fontMetrics().ptPerEm // Convert pt to CSS em + / options.sizeMultiplier; // Unscale to make absolute units + } else if (sizeValue.unit === "mu") { + // `mu` units scale with scriptstyle/scriptscriptstyle. + scale = options.fontMetrics().cssEmPerMu; + } else { + // Other relative units always refer to the *textstyle* font + // in the current size. + var unitOptions; + if (options.style.isTight()) { + // isTight() means current style is script/scriptscript. + unitOptions = options.havingStyle(options.style.text()); + } else { + unitOptions = options; + } + // TODO: In TeX these units are relative to the quad of the current + // *text* font, e.g. cmr10. KaTeX instead uses values from the + // comparably-sized *Computer Modern symbol* font. At 10pt, these + // match. At 7pt and 5pt, they differ: cmr7=1.138894, cmsy7=1.170641; + // cmr5=1.361133, cmsy5=1.472241. Consider $\scriptsize a\kern1emb$. + // TeX \showlists shows a kern of 1.13889 * fontsize; + // KaTeX shows a kern of 1.171 * fontsize. + if (sizeValue.unit === "ex") { + scale = unitOptions.fontMetrics().xHeight; + } else if (sizeValue.unit === "em") { + scale = unitOptions.fontMetrics().quad; + } else { + throw new ParseError("Invalid unit: '" + sizeValue.unit + "'"); + } + if (unitOptions !== options) { + scale *= unitOptions.sizeMultiplier / options.sizeMultiplier; + } + } + return Math.min(sizeValue.number * scale, options.maxSize); +}; +/** + * Round `n` to 4 decimal places, or to the nearest 1/10,000th em. See + * https://github.com/KaTeX/KaTeX/pull/2460. + */ +var makeEm = function makeEm(n) { + return +n.toFixed(4) + "em"; +}; + +/** + * These objects store the data about the DOM nodes we create, as well as some + * extra data. They can then be transformed into real DOM nodes with the + * `toNode` function or HTML markup using `toMarkup`. They are useful for both + * storing extra properties on the nodes, as well as providing a way to easily + * work with the DOM. + * + * Similar functions for working with MathML nodes exist in mathMLTree.js. + * + * TODO: refactor `span` and `anchor` into common superclass when + * target environments support class inheritance + */ +/** + * Create an HTML className based on a list of classes. In addition to joining + * with spaces, we also remove empty classes. + */ +var createClass = function createClass(classes) { + return classes.filter(cls => cls).join(" "); +}; +/** + * Serialize a CssStyle object into a semicolon-delimited inline-style string + * (hyphenating camelCase property names). Returns "" when no property is set. + */ +var cssStyleToString = function cssStyleToString(style) { + var styles = ""; + for (var key of Object.keys(style)) { + var value = style[key]; + if (value !== undefined) { + styles += hyphenate(key) + ":" + value + ";"; + } + } + return styles; +}; +var initNode = function initNode(classes, options, style) { + this.classes = classes || []; + this.attributes = {}; + this.height = 0; + this.depth = 0; + this.maxFontSize = 0; + this.style = style || {}; + if (options) { + if (options.style.isTight()) { + this.classes.push("mtight"); + } + var color = options.getColor(); + if (color) { + this.style.color = color; + } + } +}; +/** + * Convert into an HTML node + */ +var toNode = function toNode(tagName) { + var node = document.createElement(tagName); + // Apply the class + node.className = createClass(this.classes); + // Apply inline styles + Object.assign(node.style, this.style); + // Apply attributes + for (var attr of Object.keys(this.attributes)) { + node.setAttribute(attr, this.attributes[attr]); + } + // Append the children, also as HTML nodes + for (var i = 0; i < this.children.length; i++) { + node.appendChild(this.children[i].toNode()); + } + return node; +}; +/** + * https://w3c.github.io/html-reference/syntax.html#syntax-attributes + * + * > Attribute Names must consist of one or more characters + * other than the space characters, U+0000 NULL, + * '"', "'", ">", "/", "=", the control characters, + * and any characters that are not defined by Unicode. + */ +var invalidAttributeNameRegex = /[\s"'>/=\x00-\x1f]/; +/** + * Convert into an HTML markup string + */ +var toMarkup = function toMarkup(tagName) { + var markup = "<" + tagName; + // Add the class + if (this.classes.length) { + markup += " class=\"" + escape(createClass(this.classes)) + "\""; + } + var styles = cssStyleToString(this.style); + if (styles) { + markup += " style=\"" + escape(styles) + "\""; + } + // Add the attributes + for (var attr of Object.keys(this.attributes)) { + if (invalidAttributeNameRegex.test(attr)) { + throw new ParseError("Invalid attribute name '" + attr + "'"); + } + markup += " " + attr + "=\"" + escape(this.attributes[attr]) + "\""; + } + markup += ">"; + // Add the markup of the children, also as markup + for (var i = 0; i < this.children.length; i++) { + markup += this.children[i].toMarkup(); + } + markup += ""; + return markup; +}; +/** + * This node represents a span node, with a className, a list of children, and + * an inline style. It also contains information about its height, depth, and + * maxFontSize. + * + * Represents two types with different uses: SvgSpan to wrap an SVG and DomSpan + * otherwise. This typesafety is important when HTML builders access a span's + * children. + */ +class Span { + constructor(classes, children, options, style) { + this.children = void 0; + this.attributes = void 0; + this.classes = void 0; + this.height = void 0; + this.depth = void 0; + this.width = void 0; + this.maxFontSize = void 0; + this.style = void 0; + /** + * Italic correction carried over from a SymbolNode when the symbol is + * wrapped in a vlist (e.g. \oiint / \oiiint). Read by supsub to adjust + * subscript positioning. Only set when nonzero; use `?? 0` at read sites. + */ + this.italic = void 0; + initNode.call(this, classes, options, style); + this.children = children || []; + } + /** + * Sets an arbitrary attribute on the span. Warning: use this wisely. Not + * all browsers support attributes the same, and having too many custom + * attributes is probably bad. + */ + setAttribute(attribute, value) { + this.attributes[attribute] = value; + } + hasClass(className) { + return this.classes.includes(className); + } + toNode() { + return toNode.call(this, "span"); + } + toMarkup() { + return toMarkup.call(this, "span"); + } +} +/** + * This node represents an anchor () element with a hyperlink. See `span` + * for further details. + */ +class Anchor { + constructor(href, classes, children, options) { + this.children = void 0; + this.attributes = void 0; + this.classes = void 0; + this.height = void 0; + this.depth = void 0; + this.maxFontSize = void 0; + this.style = void 0; + initNode.call(this, classes, options); + this.children = children || []; + this.setAttribute('href', href); + } + setAttribute(attribute, value) { + this.attributes[attribute] = value; + } + hasClass(className) { + return this.classes.includes(className); + } + toNode() { + return toNode.call(this, "a"); + } + toMarkup() { + return toMarkup.call(this, "a"); + } +} +/** + * This node represents an image embed () element. + */ +class Img { + constructor(src, alt, style) { + this.src = void 0; + this.alt = void 0; + this.classes = void 0; + this.height = void 0; + this.depth = void 0; + this.maxFontSize = void 0; + this.style = void 0; + this.alt = alt; + this.src = src; + this.classes = ["mord"]; + this.height = 0; + this.depth = 0; + this.maxFontSize = 0; + this.style = style; + } + hasClass(className) { + return this.classes.includes(className); + } + toNode() { + var node = document.createElement("img"); + node.src = this.src; + node.alt = this.alt; + node.className = "mord"; + // Apply inline styles + Object.assign(node.style, this.style); + return node; + } + toMarkup() { + var markup = "\"" 0) { + span = document.createElement("span"); + span.style.marginRight = makeEm(this.italic); + } + if (this.classes.length > 0) { + span = span || document.createElement("span"); + span.className = createClass(this.classes); + } + if (Object.keys(this.style).length > 0) { + span = span || document.createElement("span"); + Object.assign(span.style, this.style); + } + if (span) { + span.appendChild(node); + return span; + } else { + return node; + } + } + /** + * Creates markup for a symbol node. + */ + toMarkup() { + // TODO(alpert): More duplication than I'd like from + // span.prototype.toMarkup and symbolNode.prototype.toNode... + var needsSpan = false; + var markup = " 0) { + styles += "margin-right:" + makeEm(this.italic) + ";"; + } + styles += cssStyleToString(this.style); + if (styles) { + needsSpan = true; + markup += " style=\"" + escape(styles) + "\""; + } + var escaped = escape(this.text); + if (needsSpan) { + markup += ">"; + markup += escaped; + markup += ""; + return markup; + } else { + return escaped; + } + } +} +/** + * SVG nodes are used to render stretchy wide elements. + */ +class SvgNode { + constructor(children, attributes) { + this.children = void 0; + this.attributes = void 0; + this.children = children || []; + this.attributes = attributes || {}; + } + toNode() { + var svgNS = "http://www.w3.org/2000/svg"; + var node = document.createElementNS(svgNS, "svg"); + // Apply attributes + for (var attr of Object.keys(this.attributes)) { + node.setAttribute(attr, this.attributes[attr]); + } + for (var i = 0; i < this.children.length; i++) { + node.appendChild(this.children[i].toNode()); + } + return node; + } + toMarkup() { + var markup = ""; + } else { + return ""; + } + } +} +class LineNode { + constructor(attributes) { + this.attributes = void 0; + this.attributes = attributes || {}; + } + toNode() { + var svgNS = "http://www.w3.org/2000/svg"; + var node = document.createElementNS(svgNS, "line"); + // Apply attributes + for (var attr of Object.keys(this.attributes)) { + node.setAttribute(attr, this.attributes[attr]); + } + return node; + } + toMarkup() { + var markup = " but got " + String(group) + "."); + } +} +/** + * Whether an HtmlDomNode has HtmlDomNode children. + * HtmlDomNode is a base type representing a union of + * SymbolNode, SvgSpan, DomSpan, Anchor, and documentFragment. + * In the last three cases, the children are HtmlDomNode[]. + */ +var hasHtmlDomChildren = node => node instanceof Span || node instanceof Anchor || node instanceof DocumentFragment; + +// This file is GENERATED by buildMetrics.sh. DO NOT MODIFY. +var fontMetricsData = { + "AMS-Regular": { + "32": [0, 0, 0, 0, 0.25], + "65": [0, 0.68889, 0, 0, 0.72222], + "66": [0, 0.68889, 0, 0, 0.66667], + "67": [0, 0.68889, 0, 0, 0.72222], + "68": [0, 0.68889, 0, 0, 0.72222], + "69": [0, 0.68889, 0, 0, 0.66667], + "70": [0, 0.68889, 0, 0, 0.61111], + "71": [0, 0.68889, 0, 0, 0.77778], + "72": [0, 0.68889, 0, 0, 0.77778], + "73": [0, 0.68889, 0, 0, 0.38889], + "74": [0.16667, 0.68889, 0, 0, 0.5], + "75": [0, 0.68889, 0, 0, 0.77778], + "76": [0, 0.68889, 0, 0, 0.66667], + "77": [0, 0.68889, 0, 0, 0.94445], + "78": [0, 0.68889, 0, 0, 0.72222], + "79": [0.16667, 0.68889, 0, 0, 0.77778], + "80": [0, 0.68889, 0, 0, 0.61111], + "81": [0.16667, 0.68889, 0, 0, 0.77778], + "82": [0, 0.68889, 0, 0, 0.72222], + "83": [0, 0.68889, 0, 0, 0.55556], + "84": [0, 0.68889, 0, 0, 0.66667], + "85": [0, 0.68889, 0, 0, 0.72222], + "86": [0, 0.68889, 0, 0, 0.72222], + "87": [0, 0.68889, 0, 0, 1.0], + "88": [0, 0.68889, 0, 0, 0.72222], + "89": [0, 0.68889, 0, 0, 0.72222], + "90": [0, 0.68889, 0, 0, 0.66667], + "107": [0, 0.68889, 0, 0, 0.55556], + "160": [0, 0, 0, 0, 0.25], + "165": [0, 0.675, 0.025, 0, 0.75], + "174": [0.15559, 0.69224, 0, 0, 0.94666], + "240": [0, 0.68889, 0, 0, 0.55556], + "295": [0, 0.68889, 0, 0, 0.54028], + "710": [0, 0.825, 0, 0, 2.33334], + "732": [0, 0.9, 0, 0, 2.33334], + "770": [0, 0.825, 0, 0, 2.33334], + "771": [0, 0.9, 0, 0, 2.33334], + "989": [0.08167, 0.58167, 0, 0, 0.77778], + "1008": [0, 0.43056, 0.04028, 0, 0.66667], + "8245": [0, 0.54986, 0, 0, 0.275], + "8463": [0, 0.68889, 0, 0, 0.54028], + "8487": [0, 0.68889, 0, 0, 0.72222], + "8498": [0, 0.68889, 0, 0, 0.55556], + "8502": [0, 0.68889, 0, 0, 0.66667], + "8503": [0, 0.68889, 0, 0, 0.44445], + "8504": [0, 0.68889, 0, 0, 0.66667], + "8513": [0, 0.68889, 0, 0, 0.63889], + "8592": [-0.03598, 0.46402, 0, 0, 0.5], + "8594": [-0.03598, 0.46402, 0, 0, 0.5], + "8602": [-0.13313, 0.36687, 0, 0, 1.0], + "8603": [-0.13313, 0.36687, 0, 0, 1.0], + "8606": [0.01354, 0.52239, 0, 0, 1.0], + "8608": [0.01354, 0.52239, 0, 0, 1.0], + "8610": [0.01354, 0.52239, 0, 0, 1.11111], + "8611": [0.01354, 0.52239, 0, 0, 1.11111], + "8619": [0, 0.54986, 0, 0, 1.0], + "8620": [0, 0.54986, 0, 0, 1.0], + "8621": [-0.13313, 0.37788, 0, 0, 1.38889], + "8622": [-0.13313, 0.36687, 0, 0, 1.0], + "8624": [0, 0.69224, 0, 0, 0.5], + "8625": [0, 0.69224, 0, 0, 0.5], + "8630": [0, 0.43056, 0, 0, 1.0], + "8631": [0, 0.43056, 0, 0, 1.0], + "8634": [0.08198, 0.58198, 0, 0, 0.77778], + "8635": [0.08198, 0.58198, 0, 0, 0.77778], + "8638": [0.19444, 0.69224, 0, 0, 0.41667], + "8639": [0.19444, 0.69224, 0, 0, 0.41667], + "8642": [0.19444, 0.69224, 0, 0, 0.41667], + "8643": [0.19444, 0.69224, 0, 0, 0.41667], + "8644": [0.1808, 0.675, 0, 0, 1.0], + "8646": [0.1808, 0.675, 0, 0, 1.0], + "8647": [0.1808, 0.675, 0, 0, 1.0], + "8648": [0.19444, 0.69224, 0, 0, 0.83334], + "8649": [0.1808, 0.675, 0, 0, 1.0], + "8650": [0.19444, 0.69224, 0, 0, 0.83334], + "8651": [0.01354, 0.52239, 0, 0, 1.0], + "8652": [0.01354, 0.52239, 0, 0, 1.0], + "8653": [-0.13313, 0.36687, 0, 0, 1.0], + "8654": [-0.13313, 0.36687, 0, 0, 1.0], + "8655": [-0.13313, 0.36687, 0, 0, 1.0], + "8666": [0.13667, 0.63667, 0, 0, 1.0], + "8667": [0.13667, 0.63667, 0, 0, 1.0], + "8669": [-0.13313, 0.37788, 0, 0, 1.0], + "8672": [-0.064, 0.437, 0, 0, 1.334], + "8674": [-0.064, 0.437, 0, 0, 1.334], + "8705": [0, 0.825, 0, 0, 0.5], + "8708": [0, 0.68889, 0, 0, 0.55556], + "8709": [0.08167, 0.58167, 0, 0, 0.77778], + "8717": [0, 0.43056, 0, 0, 0.42917], + "8722": [-0.03598, 0.46402, 0, 0, 0.5], + "8724": [0.08198, 0.69224, 0, 0, 0.77778], + "8726": [0.08167, 0.58167, 0, 0, 0.77778], + "8733": [0, 0.69224, 0, 0, 0.77778], + "8736": [0, 0.69224, 0, 0, 0.72222], + "8737": [0, 0.69224, 0, 0, 0.72222], + "8738": [0.03517, 0.52239, 0, 0, 0.72222], + "8739": [0.08167, 0.58167, 0, 0, 0.22222], + "8740": [0.25142, 0.74111, 0, 0, 0.27778], + "8741": [0.08167, 0.58167, 0, 0, 0.38889], + "8742": [0.25142, 0.74111, 0, 0, 0.5], + "8756": [0, 0.69224, 0, 0, 0.66667], + "8757": [0, 0.69224, 0, 0, 0.66667], + "8764": [-0.13313, 0.36687, 0, 0, 0.77778], + "8765": [-0.13313, 0.37788, 0, 0, 0.77778], + "8769": [-0.13313, 0.36687, 0, 0, 0.77778], + "8770": [-0.03625, 0.46375, 0, 0, 0.77778], + "8774": [0.30274, 0.79383, 0, 0, 0.77778], + "8776": [-0.01688, 0.48312, 0, 0, 0.77778], + "8778": [0.08167, 0.58167, 0, 0, 0.77778], + "8782": [0.06062, 0.54986, 0, 0, 0.77778], + "8783": [0.06062, 0.54986, 0, 0, 0.77778], + "8785": [0.08198, 0.58198, 0, 0, 0.77778], + "8786": [0.08198, 0.58198, 0, 0, 0.77778], + "8787": [0.08198, 0.58198, 0, 0, 0.77778], + "8790": [0, 0.69224, 0, 0, 0.77778], + "8791": [0.22958, 0.72958, 0, 0, 0.77778], + "8796": [0.08198, 0.91667, 0, 0, 0.77778], + "8806": [0.25583, 0.75583, 0, 0, 0.77778], + "8807": [0.25583, 0.75583, 0, 0, 0.77778], + "8808": [0.25142, 0.75726, 0, 0, 0.77778], + "8809": [0.25142, 0.75726, 0, 0, 0.77778], + "8812": [0.25583, 0.75583, 0, 0, 0.5], + "8814": [0.20576, 0.70576, 0, 0, 0.77778], + "8815": [0.20576, 0.70576, 0, 0, 0.77778], + "8816": [0.30274, 0.79383, 0, 0, 0.77778], + "8817": [0.30274, 0.79383, 0, 0, 0.77778], + "8818": [0.22958, 0.72958, 0, 0, 0.77778], + "8819": [0.22958, 0.72958, 0, 0, 0.77778], + "8822": [0.1808, 0.675, 0, 0, 0.77778], + "8823": [0.1808, 0.675, 0, 0, 0.77778], + "8828": [0.13667, 0.63667, 0, 0, 0.77778], + "8829": [0.13667, 0.63667, 0, 0, 0.77778], + "8830": [0.22958, 0.72958, 0, 0, 0.77778], + "8831": [0.22958, 0.72958, 0, 0, 0.77778], + "8832": [0.20576, 0.70576, 0, 0, 0.77778], + "8833": [0.20576, 0.70576, 0, 0, 0.77778], + "8840": [0.30274, 0.79383, 0, 0, 0.77778], + "8841": [0.30274, 0.79383, 0, 0, 0.77778], + "8842": [0.13597, 0.63597, 0, 0, 0.77778], + "8843": [0.13597, 0.63597, 0, 0, 0.77778], + "8847": [0.03517, 0.54986, 0, 0, 0.77778], + "8848": [0.03517, 0.54986, 0, 0, 0.77778], + "8858": [0.08198, 0.58198, 0, 0, 0.77778], + "8859": [0.08198, 0.58198, 0, 0, 0.77778], + "8861": [0.08198, 0.58198, 0, 0, 0.77778], + "8862": [0, 0.675, 0, 0, 0.77778], + "8863": [0, 0.675, 0, 0, 0.77778], + "8864": [0, 0.675, 0, 0, 0.77778], + "8865": [0, 0.675, 0, 0, 0.77778], + "8872": [0, 0.69224, 0, 0, 0.61111], + "8873": [0, 0.69224, 0, 0, 0.72222], + "8874": [0, 0.69224, 0, 0, 0.88889], + "8876": [0, 0.68889, 0, 0, 0.61111], + "8877": [0, 0.68889, 0, 0, 0.61111], + "8878": [0, 0.68889, 0, 0, 0.72222], + "8879": [0, 0.68889, 0, 0, 0.72222], + "8882": [0.03517, 0.54986, 0, 0, 0.77778], + "8883": [0.03517, 0.54986, 0, 0, 0.77778], + "8884": [0.13667, 0.63667, 0, 0, 0.77778], + "8885": [0.13667, 0.63667, 0, 0, 0.77778], + "8888": [0, 0.54986, 0, 0, 1.11111], + "8890": [0.19444, 0.43056, 0, 0, 0.55556], + "8891": [0.19444, 0.69224, 0, 0, 0.61111], + "8892": [0.19444, 0.69224, 0, 0, 0.61111], + "8901": [0, 0.54986, 0, 0, 0.27778], + "8903": [0.08167, 0.58167, 0, 0, 0.77778], + "8905": [0.08167, 0.58167, 0, 0, 0.77778], + "8906": [0.08167, 0.58167, 0, 0, 0.77778], + "8907": [0, 0.69224, 0, 0, 0.77778], + "8908": [0, 0.69224, 0, 0, 0.77778], + "8909": [-0.03598, 0.46402, 0, 0, 0.77778], + "8910": [0, 0.54986, 0, 0, 0.76042], + "8911": [0, 0.54986, 0, 0, 0.76042], + "8912": [0.03517, 0.54986, 0, 0, 0.77778], + "8913": [0.03517, 0.54986, 0, 0, 0.77778], + "8914": [0, 0.54986, 0, 0, 0.66667], + "8915": [0, 0.54986, 0, 0, 0.66667], + "8916": [0, 0.69224, 0, 0, 0.66667], + "8918": [0.0391, 0.5391, 0, 0, 0.77778], + "8919": [0.0391, 0.5391, 0, 0, 0.77778], + "8920": [0.03517, 0.54986, 0, 0, 1.33334], + "8921": [0.03517, 0.54986, 0, 0, 1.33334], + "8922": [0.38569, 0.88569, 0, 0, 0.77778], + "8923": [0.38569, 0.88569, 0, 0, 0.77778], + "8926": [0.13667, 0.63667, 0, 0, 0.77778], + "8927": [0.13667, 0.63667, 0, 0, 0.77778], + "8928": [0.30274, 0.79383, 0, 0, 0.77778], + "8929": [0.30274, 0.79383, 0, 0, 0.77778], + "8934": [0.23222, 0.74111, 0, 0, 0.77778], + "8935": [0.23222, 0.74111, 0, 0, 0.77778], + "8936": [0.23222, 0.74111, 0, 0, 0.77778], + "8937": [0.23222, 0.74111, 0, 0, 0.77778], + "8938": [0.20576, 0.70576, 0, 0, 0.77778], + "8939": [0.20576, 0.70576, 0, 0, 0.77778], + "8940": [0.30274, 0.79383, 0, 0, 0.77778], + "8941": [0.30274, 0.79383, 0, 0, 0.77778], + "8994": [0.19444, 0.69224, 0, 0, 0.77778], + "8995": [0.19444, 0.69224, 0, 0, 0.77778], + "9416": [0.15559, 0.69224, 0, 0, 0.90222], + "9484": [0, 0.69224, 0, 0, 0.5], + "9488": [0, 0.69224, 0, 0, 0.5], + "9492": [0, 0.37788, 0, 0, 0.5], + "9496": [0, 0.37788, 0, 0, 0.5], + "9585": [0.19444, 0.68889, 0, 0, 0.88889], + "9586": [0.19444, 0.74111, 0, 0, 0.88889], + "9632": [0, 0.675, 0, 0, 0.77778], + "9633": [0, 0.675, 0, 0, 0.77778], + "9650": [0, 0.54986, 0, 0, 0.72222], + "9651": [0, 0.54986, 0, 0, 0.72222], + "9654": [0.03517, 0.54986, 0, 0, 0.77778], + "9660": [0, 0.54986, 0, 0, 0.72222], + "9661": [0, 0.54986, 0, 0, 0.72222], + "9664": [0.03517, 0.54986, 0, 0, 0.77778], + "9674": [0.11111, 0.69224, 0, 0, 0.66667], + "9733": [0.19444, 0.69224, 0, 0, 0.94445], + "10003": [0, 0.69224, 0, 0, 0.83334], + "10016": [0, 0.69224, 0, 0, 0.83334], + "10731": [0.11111, 0.69224, 0, 0, 0.66667], + "10846": [0.19444, 0.75583, 0, 0, 0.61111], + "10877": [0.13667, 0.63667, 0, 0, 0.77778], + "10878": [0.13667, 0.63667, 0, 0, 0.77778], + "10885": [0.25583, 0.75583, 0, 0, 0.77778], + "10886": [0.25583, 0.75583, 0, 0, 0.77778], + "10887": [0.13597, 0.63597, 0, 0, 0.77778], + "10888": [0.13597, 0.63597, 0, 0, 0.77778], + "10889": [0.26167, 0.75726, 0, 0, 0.77778], + "10890": [0.26167, 0.75726, 0, 0, 0.77778], + "10891": [0.48256, 0.98256, 0, 0, 0.77778], + "10892": [0.48256, 0.98256, 0, 0, 0.77778], + "10901": [0.13667, 0.63667, 0, 0, 0.77778], + "10902": [0.13667, 0.63667, 0, 0, 0.77778], + "10933": [0.25142, 0.75726, 0, 0, 0.77778], + "10934": [0.25142, 0.75726, 0, 0, 0.77778], + "10935": [0.26167, 0.75726, 0, 0, 0.77778], + "10936": [0.26167, 0.75726, 0, 0, 0.77778], + "10937": [0.26167, 0.75726, 0, 0, 0.77778], + "10938": [0.26167, 0.75726, 0, 0, 0.77778], + "10949": [0.25583, 0.75583, 0, 0, 0.77778], + "10950": [0.25583, 0.75583, 0, 0, 0.77778], + "10955": [0.28481, 0.79383, 0, 0, 0.77778], + "10956": [0.28481, 0.79383, 0, 0, 0.77778], + "57350": [0.08167, 0.58167, 0, 0, 0.22222], + "57351": [0.08167, 0.58167, 0, 0, 0.38889], + "57352": [0.08167, 0.58167, 0, 0, 0.77778], + "57353": [0, 0.43056, 0.04028, 0, 0.66667], + "57356": [0.25142, 0.75726, 0, 0, 0.77778], + "57357": [0.25142, 0.75726, 0, 0, 0.77778], + "57358": [0.41951, 0.91951, 0, 0, 0.77778], + "57359": [0.30274, 0.79383, 0, 0, 0.77778], + "57360": [0.30274, 0.79383, 0, 0, 0.77778], + "57361": [0.41951, 0.91951, 0, 0, 0.77778], + "57366": [0.25142, 0.75726, 0, 0, 0.77778], + "57367": [0.25142, 0.75726, 0, 0, 0.77778], + "57368": [0.25142, 0.75726, 0, 0, 0.77778], + "57369": [0.25142, 0.75726, 0, 0, 0.77778], + "57370": [0.13597, 0.63597, 0, 0, 0.77778], + "57371": [0.13597, 0.63597, 0, 0, 0.77778] + }, + "Caligraphic-Regular": { + "32": [0, 0, 0, 0, 0.25], + "65": [0, 0.68333, 0, 0.19445, 0.79847], + "66": [0, 0.68333, 0.03041, 0.13889, 0.65681], + "67": [0, 0.68333, 0.05834, 0.13889, 0.52653], + "68": [0, 0.68333, 0.02778, 0.08334, 0.77139], + "69": [0, 0.68333, 0.08944, 0.11111, 0.52778], + "70": [0, 0.68333, 0.09931, 0.11111, 0.71875], + "71": [0.09722, 0.68333, 0.0593, 0.11111, 0.59487], + "72": [0, 0.68333, 0.00965, 0.11111, 0.84452], + "73": [0, 0.68333, 0.07382, 0, 0.54452], + "74": [0.09722, 0.68333, 0.18472, 0.16667, 0.67778], + "75": [0, 0.68333, 0.01445, 0.05556, 0.76195], + "76": [0, 0.68333, 0, 0.13889, 0.68972], + "77": [0, 0.68333, 0, 0.13889, 1.2009], + "78": [0, 0.68333, 0.14736, 0.08334, 0.82049], + "79": [0, 0.68333, 0.02778, 0.11111, 0.79611], + "80": [0, 0.68333, 0.08222, 0.08334, 0.69556], + "81": [0.09722, 0.68333, 0, 0.11111, 0.81667], + "82": [0, 0.68333, 0, 0.08334, 0.8475], + "83": [0, 0.68333, 0.075, 0.13889, 0.60556], + "84": [0, 0.68333, 0.25417, 0, 0.54464], + "85": [0, 0.68333, 0.09931, 0.08334, 0.62583], + "86": [0, 0.68333, 0.08222, 0, 0.61278], + "87": [0, 0.68333, 0.08222, 0.08334, 0.98778], + "88": [0, 0.68333, 0.14643, 0.13889, 0.7133], + "89": [0.09722, 0.68333, 0.08222, 0.08334, 0.66834], + "90": [0, 0.68333, 0.07944, 0.13889, 0.72473], + "160": [0, 0, 0, 0, 0.25] + }, + "Fraktur-Regular": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69141, 0, 0, 0.29574], + "34": [0, 0.69141, 0, 0, 0.21471], + "38": [0, 0.69141, 0, 0, 0.73786], + "39": [0, 0.69141, 0, 0, 0.21201], + "40": [0.24982, 0.74947, 0, 0, 0.38865], + "41": [0.24982, 0.74947, 0, 0, 0.38865], + "42": [0, 0.62119, 0, 0, 0.27764], + "43": [0.08319, 0.58283, 0, 0, 0.75623], + "44": [0, 0.10803, 0, 0, 0.27764], + "45": [0.08319, 0.58283, 0, 0, 0.75623], + "46": [0, 0.10803, 0, 0, 0.27764], + "47": [0.24982, 0.74947, 0, 0, 0.50181], + "48": [0, 0.47534, 0, 0, 0.50181], + "49": [0, 0.47534, 0, 0, 0.50181], + "50": [0, 0.47534, 0, 0, 0.50181], + "51": [0.18906, 0.47534, 0, 0, 0.50181], + "52": [0.18906, 0.47534, 0, 0, 0.50181], + "53": [0.18906, 0.47534, 0, 0, 0.50181], + "54": [0, 0.69141, 0, 0, 0.50181], + "55": [0.18906, 0.47534, 0, 0, 0.50181], + "56": [0, 0.69141, 0, 0, 0.50181], + "57": [0.18906, 0.47534, 0, 0, 0.50181], + "58": [0, 0.47534, 0, 0, 0.21606], + "59": [0.12604, 0.47534, 0, 0, 0.21606], + "61": [-0.13099, 0.36866, 0, 0, 0.75623], + "63": [0, 0.69141, 0, 0, 0.36245], + "65": [0, 0.69141, 0, 0, 0.7176], + "66": [0, 0.69141, 0, 0, 0.88397], + "67": [0, 0.69141, 0, 0, 0.61254], + "68": [0, 0.69141, 0, 0, 0.83158], + "69": [0, 0.69141, 0, 0, 0.66278], + "70": [0.12604, 0.69141, 0, 0, 0.61119], + "71": [0, 0.69141, 0, 0, 0.78539], + "72": [0.06302, 0.69141, 0, 0, 0.7203], + "73": [0, 0.69141, 0, 0, 0.55448], + "74": [0.12604, 0.69141, 0, 0, 0.55231], + "75": [0, 0.69141, 0, 0, 0.66845], + "76": [0, 0.69141, 0, 0, 0.66602], + "77": [0, 0.69141, 0, 0, 1.04953], + "78": [0, 0.69141, 0, 0, 0.83212], + "79": [0, 0.69141, 0, 0, 0.82699], + "80": [0.18906, 0.69141, 0, 0, 0.82753], + "81": [0.03781, 0.69141, 0, 0, 0.82699], + "82": [0, 0.69141, 0, 0, 0.82807], + "83": [0, 0.69141, 0, 0, 0.82861], + "84": [0, 0.69141, 0, 0, 0.66899], + "85": [0, 0.69141, 0, 0, 0.64576], + "86": [0, 0.69141, 0, 0, 0.83131], + "87": [0, 0.69141, 0, 0, 1.04602], + "88": [0, 0.69141, 0, 0, 0.71922], + "89": [0.18906, 0.69141, 0, 0, 0.83293], + "90": [0.12604, 0.69141, 0, 0, 0.60201], + "91": [0.24982, 0.74947, 0, 0, 0.27764], + "93": [0.24982, 0.74947, 0, 0, 0.27764], + "94": [0, 0.69141, 0, 0, 0.49965], + "97": [0, 0.47534, 0, 0, 0.50046], + "98": [0, 0.69141, 0, 0, 0.51315], + "99": [0, 0.47534, 0, 0, 0.38946], + "100": [0, 0.62119, 0, 0, 0.49857], + "101": [0, 0.47534, 0, 0, 0.40053], + "102": [0.18906, 0.69141, 0, 0, 0.32626], + "103": [0.18906, 0.47534, 0, 0, 0.5037], + "104": [0.18906, 0.69141, 0, 0, 0.52126], + "105": [0, 0.69141, 0, 0, 0.27899], + "106": [0, 0.69141, 0, 0, 0.28088], + "107": [0, 0.69141, 0, 0, 0.38946], + "108": [0, 0.69141, 0, 0, 0.27953], + "109": [0, 0.47534, 0, 0, 0.76676], + "110": [0, 0.47534, 0, 0, 0.52666], + "111": [0, 0.47534, 0, 0, 0.48885], + "112": [0.18906, 0.52396, 0, 0, 0.50046], + "113": [0.18906, 0.47534, 0, 0, 0.48912], + "114": [0, 0.47534, 0, 0, 0.38919], + "115": [0, 0.47534, 0, 0, 0.44266], + "116": [0, 0.62119, 0, 0, 0.33301], + "117": [0, 0.47534, 0, 0, 0.5172], + "118": [0, 0.52396, 0, 0, 0.5118], + "119": [0, 0.52396, 0, 0, 0.77351], + "120": [0.18906, 0.47534, 0, 0, 0.38865], + "121": [0.18906, 0.47534, 0, 0, 0.49884], + "122": [0.18906, 0.47534, 0, 0, 0.39054], + "160": [0, 0, 0, 0, 0.25], + "8216": [0, 0.69141, 0, 0, 0.21471], + "8217": [0, 0.69141, 0, 0, 0.21471], + "58112": [0, 0.62119, 0, 0, 0.49749], + "58113": [0, 0.62119, 0, 0, 0.4983], + "58114": [0.18906, 0.69141, 0, 0, 0.33328], + "58115": [0.18906, 0.69141, 0, 0, 0.32923], + "58116": [0.18906, 0.47534, 0, 0, 0.50343], + "58117": [0, 0.69141, 0, 0, 0.33301], + "58118": [0, 0.62119, 0, 0, 0.33409], + "58119": [0, 0.47534, 0, 0, 0.50073] + }, + "Main-Bold": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0, 0, 0.35], + "34": [0, 0.69444, 0, 0, 0.60278], + "35": [0.19444, 0.69444, 0, 0, 0.95833], + "36": [0.05556, 0.75, 0, 0, 0.575], + "37": [0.05556, 0.75, 0, 0, 0.95833], + "38": [0, 0.69444, 0, 0, 0.89444], + "39": [0, 0.69444, 0, 0, 0.31944], + "40": [0.25, 0.75, 0, 0, 0.44722], + "41": [0.25, 0.75, 0, 0, 0.44722], + "42": [0, 0.75, 0, 0, 0.575], + "43": [0.13333, 0.63333, 0, 0, 0.89444], + "44": [0.19444, 0.15556, 0, 0, 0.31944], + "45": [0, 0.44444, 0, 0, 0.38333], + "46": [0, 0.15556, 0, 0, 0.31944], + "47": [0.25, 0.75, 0, 0, 0.575], + "48": [0, 0.64444, 0, 0, 0.575], + "49": [0, 0.64444, 0, 0, 0.575], + "50": [0, 0.64444, 0, 0, 0.575], + "51": [0, 0.64444, 0, 0, 0.575], + "52": [0, 0.64444, 0, 0, 0.575], + "53": [0, 0.64444, 0, 0, 0.575], + "54": [0, 0.64444, 0, 0, 0.575], + "55": [0, 0.64444, 0, 0, 0.575], + "56": [0, 0.64444, 0, 0, 0.575], + "57": [0, 0.64444, 0, 0, 0.575], + "58": [0, 0.44444, 0, 0, 0.31944], + "59": [0.19444, 0.44444, 0, 0, 0.31944], + "60": [0.08556, 0.58556, 0, 0, 0.89444], + "61": [-0.10889, 0.39111, 0, 0, 0.89444], + "62": [0.08556, 0.58556, 0, 0, 0.89444], + "63": [0, 0.69444, 0, 0, 0.54305], + "64": [0, 0.69444, 0, 0, 0.89444], + "65": [0, 0.68611, 0, 0, 0.86944], + "66": [0, 0.68611, 0, 0, 0.81805], + "67": [0, 0.68611, 0, 0, 0.83055], + "68": [0, 0.68611, 0, 0, 0.88194], + "69": [0, 0.68611, 0, 0, 0.75555], + "70": [0, 0.68611, 0, 0, 0.72361], + "71": [0, 0.68611, 0, 0, 0.90416], + "72": [0, 0.68611, 0, 0, 0.9], + "73": [0, 0.68611, 0, 0, 0.43611], + "74": [0, 0.68611, 0, 0, 0.59444], + "75": [0, 0.68611, 0, 0, 0.90138], + "76": [0, 0.68611, 0, 0, 0.69166], + "77": [0, 0.68611, 0, 0, 1.09166], + "78": [0, 0.68611, 0, 0, 0.9], + "79": [0, 0.68611, 0, 0, 0.86388], + "80": [0, 0.68611, 0, 0, 0.78611], + "81": [0.19444, 0.68611, 0, 0, 0.86388], + "82": [0, 0.68611, 0, 0, 0.8625], + "83": [0, 0.68611, 0, 0, 0.63889], + "84": [0, 0.68611, 0, 0, 0.8], + "85": [0, 0.68611, 0, 0, 0.88472], + "86": [0, 0.68611, 0.01597, 0, 0.86944], + "87": [0, 0.68611, 0.01597, 0, 1.18888], + "88": [0, 0.68611, 0, 0, 0.86944], + "89": [0, 0.68611, 0.02875, 0, 0.86944], + "90": [0, 0.68611, 0, 0, 0.70277], + "91": [0.25, 0.75, 0, 0, 0.31944], + "92": [0.25, 0.75, 0, 0, 0.575], + "93": [0.25, 0.75, 0, 0, 0.31944], + "94": [0, 0.69444, 0, 0, 0.575], + "95": [0.31, 0.13444, 0.03194, 0, 0.575], + "97": [0, 0.44444, 0, 0, 0.55902], + "98": [0, 0.69444, 0, 0, 0.63889], + "99": [0, 0.44444, 0, 0, 0.51111], + "100": [0, 0.69444, 0, 0, 0.63889], + "101": [0, 0.44444, 0, 0, 0.52708], + "102": [0, 0.69444, 0.10903, 0, 0.35139], + "103": [0.19444, 0.44444, 0.01597, 0, 0.575], + "104": [0, 0.69444, 0, 0, 0.63889], + "105": [0, 0.69444, 0, 0, 0.31944], + "106": [0.19444, 0.69444, 0, 0, 0.35139], + "107": [0, 0.69444, 0, 0, 0.60694], + "108": [0, 0.69444, 0, 0, 0.31944], + "109": [0, 0.44444, 0, 0, 0.95833], + "110": [0, 0.44444, 0, 0, 0.63889], + "111": [0, 0.44444, 0, 0, 0.575], + "112": [0.19444, 0.44444, 0, 0, 0.63889], + "113": [0.19444, 0.44444, 0, 0, 0.60694], + "114": [0, 0.44444, 0, 0, 0.47361], + "115": [0, 0.44444, 0, 0, 0.45361], + "116": [0, 0.63492, 0, 0, 0.44722], + "117": [0, 0.44444, 0, 0, 0.63889], + "118": [0, 0.44444, 0.01597, 0, 0.60694], + "119": [0, 0.44444, 0.01597, 0, 0.83055], + "120": [0, 0.44444, 0, 0, 0.60694], + "121": [0.19444, 0.44444, 0.01597, 0, 0.60694], + "122": [0, 0.44444, 0, 0, 0.51111], + "123": [0.25, 0.75, 0, 0, 0.575], + "124": [0.25, 0.75, 0, 0, 0.31944], + "125": [0.25, 0.75, 0, 0, 0.575], + "126": [0.35, 0.34444, 0, 0, 0.575], + "160": [0, 0, 0, 0, 0.25], + "163": [0, 0.69444, 0, 0, 0.86853], + "168": [0, 0.69444, 0, 0, 0.575], + "172": [0, 0.44444, 0, 0, 0.76666], + "176": [0, 0.69444, 0, 0, 0.86944], + "177": [0.13333, 0.63333, 0, 0, 0.89444], + "184": [0.17014, 0, 0, 0, 0.51111], + "198": [0, 0.68611, 0, 0, 1.04166], + "215": [0.13333, 0.63333, 0, 0, 0.89444], + "216": [0.04861, 0.73472, 0, 0, 0.89444], + "223": [0, 0.69444, 0, 0, 0.59722], + "230": [0, 0.44444, 0, 0, 0.83055], + "247": [0.13333, 0.63333, 0, 0, 0.89444], + "248": [0.09722, 0.54167, 0, 0, 0.575], + "305": [0, 0.44444, 0, 0, 0.31944], + "338": [0, 0.68611, 0, 0, 1.16944], + "339": [0, 0.44444, 0, 0, 0.89444], + "567": [0.19444, 0.44444, 0, 0, 0.35139], + "710": [0, 0.69444, 0, 0, 0.575], + "711": [0, 0.63194, 0, 0, 0.575], + "713": [0, 0.59611, 0, 0, 0.575], + "714": [0, 0.69444, 0, 0, 0.575], + "715": [0, 0.69444, 0, 0, 0.575], + "728": [0, 0.69444, 0, 0, 0.575], + "729": [0, 0.69444, 0, 0, 0.31944], + "730": [0, 0.69444, 0, 0, 0.86944], + "732": [0, 0.69444, 0, 0, 0.575], + "733": [0, 0.69444, 0, 0, 0.575], + "915": [0, 0.68611, 0, 0, 0.69166], + "916": [0, 0.68611, 0, 0, 0.95833], + "920": [0, 0.68611, 0, 0, 0.89444], + "923": [0, 0.68611, 0, 0, 0.80555], + "926": [0, 0.68611, 0, 0, 0.76666], + "928": [0, 0.68611, 0, 0, 0.9], + "931": [0, 0.68611, 0, 0, 0.83055], + "933": [0, 0.68611, 0, 0, 0.89444], + "934": [0, 0.68611, 0, 0, 0.83055], + "936": [0, 0.68611, 0, 0, 0.89444], + "937": [0, 0.68611, 0, 0, 0.83055], + "8211": [0, 0.44444, 0.03194, 0, 0.575], + "8212": [0, 0.44444, 0.03194, 0, 1.14999], + "8216": [0, 0.69444, 0, 0, 0.31944], + "8217": [0, 0.69444, 0, 0, 0.31944], + "8220": [0, 0.69444, 0, 0, 0.60278], + "8221": [0, 0.69444, 0, 0, 0.60278], + "8224": [0.19444, 0.69444, 0, 0, 0.51111], + "8225": [0.19444, 0.69444, 0, 0, 0.51111], + "8242": [0, 0.55556, 0, 0, 0.34444], + "8407": [0, 0.72444, 0.15486, 0, 0.575], + "8463": [0, 0.69444, 0, 0, 0.66759], + "8465": [0, 0.69444, 0, 0, 0.83055], + "8467": [0, 0.69444, 0, 0, 0.47361], + "8472": [0.19444, 0.44444, 0, 0, 0.74027], + "8476": [0, 0.69444, 0, 0, 0.83055], + "8501": [0, 0.69444, 0, 0, 0.70277], + "8592": [-0.10889, 0.39111, 0, 0, 1.14999], + "8593": [0.19444, 0.69444, 0, 0, 0.575], + "8594": [-0.10889, 0.39111, 0, 0, 1.14999], + "8595": [0.19444, 0.69444, 0, 0, 0.575], + "8596": [-0.10889, 0.39111, 0, 0, 1.14999], + "8597": [0.25, 0.75, 0, 0, 0.575], + "8598": [0.19444, 0.69444, 0, 0, 1.14999], + "8599": [0.19444, 0.69444, 0, 0, 1.14999], + "8600": [0.19444, 0.69444, 0, 0, 1.14999], + "8601": [0.19444, 0.69444, 0, 0, 1.14999], + "8636": [-0.10889, 0.39111, 0, 0, 1.14999], + "8637": [-0.10889, 0.39111, 0, 0, 1.14999], + "8640": [-0.10889, 0.39111, 0, 0, 1.14999], + "8641": [-0.10889, 0.39111, 0, 0, 1.14999], + "8656": [-0.10889, 0.39111, 0, 0, 1.14999], + "8657": [0.19444, 0.69444, 0, 0, 0.70277], + "8658": [-0.10889, 0.39111, 0, 0, 1.14999], + "8659": [0.19444, 0.69444, 0, 0, 0.70277], + "8660": [-0.10889, 0.39111, 0, 0, 1.14999], + "8661": [0.25, 0.75, 0, 0, 0.70277], + "8704": [0, 0.69444, 0, 0, 0.63889], + "8706": [0, 0.69444, 0.06389, 0, 0.62847], + "8707": [0, 0.69444, 0, 0, 0.63889], + "8709": [0.05556, 0.75, 0, 0, 0.575], + "8711": [0, 0.68611, 0, 0, 0.95833], + "8712": [0.08556, 0.58556, 0, 0, 0.76666], + "8715": [0.08556, 0.58556, 0, 0, 0.76666], + "8722": [0.13333, 0.63333, 0, 0, 0.89444], + "8723": [0.13333, 0.63333, 0, 0, 0.89444], + "8725": [0.25, 0.75, 0, 0, 0.575], + "8726": [0.25, 0.75, 0, 0, 0.575], + "8727": [-0.02778, 0.47222, 0, 0, 0.575], + "8728": [-0.02639, 0.47361, 0, 0, 0.575], + "8729": [-0.02639, 0.47361, 0, 0, 0.575], + "8730": [0.18, 0.82, 0, 0, 0.95833], + "8733": [0, 0.44444, 0, 0, 0.89444], + "8734": [0, 0.44444, 0, 0, 1.14999], + "8736": [0, 0.69224, 0, 0, 0.72222], + "8739": [0.25, 0.75, 0, 0, 0.31944], + "8741": [0.25, 0.75, 0, 0, 0.575], + "8743": [0, 0.55556, 0, 0, 0.76666], + "8744": [0, 0.55556, 0, 0, 0.76666], + "8745": [0, 0.55556, 0, 0, 0.76666], + "8746": [0, 0.55556, 0, 0, 0.76666], + "8747": [0.19444, 0.69444, 0.12778, 0, 0.56875], + "8764": [-0.10889, 0.39111, 0, 0, 0.89444], + "8768": [0.19444, 0.69444, 0, 0, 0.31944], + "8771": [0.00222, 0.50222, 0, 0, 0.89444], + "8773": [0.027, 0.638, 0, 0, 0.894], + "8776": [0.02444, 0.52444, 0, 0, 0.89444], + "8781": [0.00222, 0.50222, 0, 0, 0.89444], + "8801": [0.00222, 0.50222, 0, 0, 0.89444], + "8804": [0.19667, 0.69667, 0, 0, 0.89444], + "8805": [0.19667, 0.69667, 0, 0, 0.89444], + "8810": [0.08556, 0.58556, 0, 0, 1.14999], + "8811": [0.08556, 0.58556, 0, 0, 1.14999], + "8826": [0.08556, 0.58556, 0, 0, 0.89444], + "8827": [0.08556, 0.58556, 0, 0, 0.89444], + "8834": [0.08556, 0.58556, 0, 0, 0.89444], + "8835": [0.08556, 0.58556, 0, 0, 0.89444], + "8838": [0.19667, 0.69667, 0, 0, 0.89444], + "8839": [0.19667, 0.69667, 0, 0, 0.89444], + "8846": [0, 0.55556, 0, 0, 0.76666], + "8849": [0.19667, 0.69667, 0, 0, 0.89444], + "8850": [0.19667, 0.69667, 0, 0, 0.89444], + "8851": [0, 0.55556, 0, 0, 0.76666], + "8852": [0, 0.55556, 0, 0, 0.76666], + "8853": [0.13333, 0.63333, 0, 0, 0.89444], + "8854": [0.13333, 0.63333, 0, 0, 0.89444], + "8855": [0.13333, 0.63333, 0, 0, 0.89444], + "8856": [0.13333, 0.63333, 0, 0, 0.89444], + "8857": [0.13333, 0.63333, 0, 0, 0.89444], + "8866": [0, 0.69444, 0, 0, 0.70277], + "8867": [0, 0.69444, 0, 0, 0.70277], + "8868": [0, 0.69444, 0, 0, 0.89444], + "8869": [0, 0.69444, 0, 0, 0.89444], + "8900": [-0.02639, 0.47361, 0, 0, 0.575], + "8901": [-0.02639, 0.47361, 0, 0, 0.31944], + "8902": [-0.02778, 0.47222, 0, 0, 0.575], + "8968": [0.25, 0.75, 0, 0, 0.51111], + "8969": [0.25, 0.75, 0, 0, 0.51111], + "8970": [0.25, 0.75, 0, 0, 0.51111], + "8971": [0.25, 0.75, 0, 0, 0.51111], + "8994": [-0.13889, 0.36111, 0, 0, 1.14999], + "8995": [-0.13889, 0.36111, 0, 0, 1.14999], + "9651": [0.19444, 0.69444, 0, 0, 1.02222], + "9657": [-0.02778, 0.47222, 0, 0, 0.575], + "9661": [0.19444, 0.69444, 0, 0, 1.02222], + "9667": [-0.02778, 0.47222, 0, 0, 0.575], + "9711": [0.19444, 0.69444, 0, 0, 1.14999], + "9824": [0.12963, 0.69444, 0, 0, 0.89444], + "9825": [0.12963, 0.69444, 0, 0, 0.89444], + "9826": [0.12963, 0.69444, 0, 0, 0.89444], + "9827": [0.12963, 0.69444, 0, 0, 0.89444], + "9837": [0, 0.75, 0, 0, 0.44722], + "9838": [0.19444, 0.69444, 0, 0, 0.44722], + "9839": [0.19444, 0.69444, 0, 0, 0.44722], + "10216": [0.25, 0.75, 0, 0, 0.44722], + "10217": [0.25, 0.75, 0, 0, 0.44722], + "10815": [0, 0.68611, 0, 0, 0.9], + "10927": [0.19667, 0.69667, 0, 0, 0.89444], + "10928": [0.19667, 0.69667, 0, 0, 0.89444], + "57376": [0.19444, 0.69444, 0, 0, 0] + }, + "Main-BoldItalic": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0.11417, 0, 0.38611], + "34": [0, 0.69444, 0.07939, 0, 0.62055], + "35": [0.19444, 0.69444, 0.06833, 0, 0.94444], + "37": [0.05556, 0.75, 0.12861, 0, 0.94444], + "38": [0, 0.69444, 0.08528, 0, 0.88555], + "39": [0, 0.69444, 0.12945, 0, 0.35555], + "40": [0.25, 0.75, 0.15806, 0, 0.47333], + "41": [0.25, 0.75, 0.03306, 0, 0.47333], + "42": [0, 0.75, 0.14333, 0, 0.59111], + "43": [0.10333, 0.60333, 0.03306, 0, 0.88555], + "44": [0.19444, 0.14722, 0, 0, 0.35555], + "45": [0, 0.44444, 0.02611, 0, 0.41444], + "46": [0, 0.14722, 0, 0, 0.35555], + "47": [0.25, 0.75, 0.15806, 0, 0.59111], + "48": [0, 0.64444, 0.13167, 0, 0.59111], + "49": [0, 0.64444, 0.13167, 0, 0.59111], + "50": [0, 0.64444, 0.13167, 0, 0.59111], + "51": [0, 0.64444, 0.13167, 0, 0.59111], + "52": [0.19444, 0.64444, 0.13167, 0, 0.59111], + "53": [0, 0.64444, 0.13167, 0, 0.59111], + "54": [0, 0.64444, 0.13167, 0, 0.59111], + "55": [0.19444, 0.64444, 0.13167, 0, 0.59111], + "56": [0, 0.64444, 0.13167, 0, 0.59111], + "57": [0, 0.64444, 0.13167, 0, 0.59111], + "58": [0, 0.44444, 0.06695, 0, 0.35555], + "59": [0.19444, 0.44444, 0.06695, 0, 0.35555], + "61": [-0.10889, 0.39111, 0.06833, 0, 0.88555], + "63": [0, 0.69444, 0.11472, 0, 0.59111], + "64": [0, 0.69444, 0.09208, 0, 0.88555], + "65": [0, 0.68611, 0, 0, 0.86555], + "66": [0, 0.68611, 0.0992, 0, 0.81666], + "67": [0, 0.68611, 0.14208, 0, 0.82666], + "68": [0, 0.68611, 0.09062, 0, 0.87555], + "69": [0, 0.68611, 0.11431, 0, 0.75666], + "70": [0, 0.68611, 0.12903, 0, 0.72722], + "71": [0, 0.68611, 0.07347, 0, 0.89527], + "72": [0, 0.68611, 0.17208, 0, 0.8961], + "73": [0, 0.68611, 0.15681, 0, 0.47166], + "74": [0, 0.68611, 0.145, 0, 0.61055], + "75": [0, 0.68611, 0.14208, 0, 0.89499], + "76": [0, 0.68611, 0, 0, 0.69777], + "77": [0, 0.68611, 0.17208, 0, 1.07277], + "78": [0, 0.68611, 0.17208, 0, 0.8961], + "79": [0, 0.68611, 0.09062, 0, 0.85499], + "80": [0, 0.68611, 0.0992, 0, 0.78721], + "81": [0.19444, 0.68611, 0.09062, 0, 0.85499], + "82": [0, 0.68611, 0.02559, 0, 0.85944], + "83": [0, 0.68611, 0.11264, 0, 0.64999], + "84": [0, 0.68611, 0.12903, 0, 0.7961], + "85": [0, 0.68611, 0.17208, 0, 0.88083], + "86": [0, 0.68611, 0.18625, 0, 0.86555], + "87": [0, 0.68611, 0.18625, 0, 1.15999], + "88": [0, 0.68611, 0.15681, 0, 0.86555], + "89": [0, 0.68611, 0.19803, 0, 0.86555], + "90": [0, 0.68611, 0.14208, 0, 0.70888], + "91": [0.25, 0.75, 0.1875, 0, 0.35611], + "93": [0.25, 0.75, 0.09972, 0, 0.35611], + "94": [0, 0.69444, 0.06709, 0, 0.59111], + "95": [0.31, 0.13444, 0.09811, 0, 0.59111], + "97": [0, 0.44444, 0.09426, 0, 0.59111], + "98": [0, 0.69444, 0.07861, 0, 0.53222], + "99": [0, 0.44444, 0.05222, 0, 0.53222], + "100": [0, 0.69444, 0.10861, 0, 0.59111], + "101": [0, 0.44444, 0.085, 0, 0.53222], + "102": [0.19444, 0.69444, 0.21778, 0, 0.4], + "103": [0.19444, 0.44444, 0.105, 0, 0.53222], + "104": [0, 0.69444, 0.09426, 0, 0.59111], + "105": [0, 0.69326, 0.11387, 0, 0.35555], + "106": [0.19444, 0.69326, 0.1672, 0, 0.35555], + "107": [0, 0.69444, 0.11111, 0, 0.53222], + "108": [0, 0.69444, 0.10861, 0, 0.29666], + "109": [0, 0.44444, 0.09426, 0, 0.94444], + "110": [0, 0.44444, 0.09426, 0, 0.64999], + "111": [0, 0.44444, 0.07861, 0, 0.59111], + "112": [0.19444, 0.44444, 0.07861, 0, 0.59111], + "113": [0.19444, 0.44444, 0.105, 0, 0.53222], + "114": [0, 0.44444, 0.11111, 0, 0.50167], + "115": [0, 0.44444, 0.08167, 0, 0.48694], + "116": [0, 0.63492, 0.09639, 0, 0.385], + "117": [0, 0.44444, 0.09426, 0, 0.62055], + "118": [0, 0.44444, 0.11111, 0, 0.53222], + "119": [0, 0.44444, 0.11111, 0, 0.76777], + "120": [0, 0.44444, 0.12583, 0, 0.56055], + "121": [0.19444, 0.44444, 0.105, 0, 0.56166], + "122": [0, 0.44444, 0.13889, 0, 0.49055], + "126": [0.35, 0.34444, 0.11472, 0, 0.59111], + "160": [0, 0, 0, 0, 0.25], + "168": [0, 0.69444, 0.11473, 0, 0.59111], + "176": [0, 0.69444, 0, 0, 0.94888], + "184": [0.17014, 0, 0, 0, 0.53222], + "198": [0, 0.68611, 0.11431, 0, 1.02277], + "216": [0.04861, 0.73472, 0.09062, 0, 0.88555], + "223": [0.19444, 0.69444, 0.09736, 0, 0.665], + "230": [0, 0.44444, 0.085, 0, 0.82666], + "248": [0.09722, 0.54167, 0.09458, 0, 0.59111], + "305": [0, 0.44444, 0.09426, 0, 0.35555], + "338": [0, 0.68611, 0.11431, 0, 1.14054], + "339": [0, 0.44444, 0.085, 0, 0.82666], + "567": [0.19444, 0.44444, 0.04611, 0, 0.385], + "710": [0, 0.69444, 0.06709, 0, 0.59111], + "711": [0, 0.63194, 0.08271, 0, 0.59111], + "713": [0, 0.59444, 0.10444, 0, 0.59111], + "714": [0, 0.69444, 0.08528, 0, 0.59111], + "715": [0, 0.69444, 0, 0, 0.59111], + "728": [0, 0.69444, 0.10333, 0, 0.59111], + "729": [0, 0.69444, 0.12945, 0, 0.35555], + "730": [0, 0.69444, 0, 0, 0.94888], + "732": [0, 0.69444, 0.11472, 0, 0.59111], + "733": [0, 0.69444, 0.11472, 0, 0.59111], + "915": [0, 0.68611, 0.12903, 0, 0.69777], + "916": [0, 0.68611, 0, 0, 0.94444], + "920": [0, 0.68611, 0.09062, 0, 0.88555], + "923": [0, 0.68611, 0, 0, 0.80666], + "926": [0, 0.68611, 0.15092, 0, 0.76777], + "928": [0, 0.68611, 0.17208, 0, 0.8961], + "931": [0, 0.68611, 0.11431, 0, 0.82666], + "933": [0, 0.68611, 0.10778, 0, 0.88555], + "934": [0, 0.68611, 0.05632, 0, 0.82666], + "936": [0, 0.68611, 0.10778, 0, 0.88555], + "937": [0, 0.68611, 0.0992, 0, 0.82666], + "8211": [0, 0.44444, 0.09811, 0, 0.59111], + "8212": [0, 0.44444, 0.09811, 0, 1.18221], + "8216": [0, 0.69444, 0.12945, 0, 0.35555], + "8217": [0, 0.69444, 0.12945, 0, 0.35555], + "8220": [0, 0.69444, 0.16772, 0, 0.62055], + "8221": [0, 0.69444, 0.07939, 0, 0.62055] + }, + "Main-Italic": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0.12417, 0, 0.30667], + "34": [0, 0.69444, 0.06961, 0, 0.51444], + "35": [0.19444, 0.69444, 0.06616, 0, 0.81777], + "37": [0.05556, 0.75, 0.13639, 0, 0.81777], + "38": [0, 0.69444, 0.09694, 0, 0.76666], + "39": [0, 0.69444, 0.12417, 0, 0.30667], + "40": [0.25, 0.75, 0.16194, 0, 0.40889], + "41": [0.25, 0.75, 0.03694, 0, 0.40889], + "42": [0, 0.75, 0.14917, 0, 0.51111], + "43": [0.05667, 0.56167, 0.03694, 0, 0.76666], + "44": [0.19444, 0.10556, 0, 0, 0.30667], + "45": [0, 0.43056, 0.02826, 0, 0.35778], + "46": [0, 0.10556, 0, 0, 0.30667], + "47": [0.25, 0.75, 0.16194, 0, 0.51111], + "48": [0, 0.64444, 0.13556, 0, 0.51111], + "49": [0, 0.64444, 0.13556, 0, 0.51111], + "50": [0, 0.64444, 0.13556, 0, 0.51111], + "51": [0, 0.64444, 0.13556, 0, 0.51111], + "52": [0.19444, 0.64444, 0.13556, 0, 0.51111], + "53": [0, 0.64444, 0.13556, 0, 0.51111], + "54": [0, 0.64444, 0.13556, 0, 0.51111], + "55": [0.19444, 0.64444, 0.13556, 0, 0.51111], + "56": [0, 0.64444, 0.13556, 0, 0.51111], + "57": [0, 0.64444, 0.13556, 0, 0.51111], + "58": [0, 0.43056, 0.0582, 0, 0.30667], + "59": [0.19444, 0.43056, 0.0582, 0, 0.30667], + "61": [-0.13313, 0.36687, 0.06616, 0, 0.76666], + "63": [0, 0.69444, 0.1225, 0, 0.51111], + "64": [0, 0.69444, 0.09597, 0, 0.76666], + "65": [0, 0.68333, 0, 0, 0.74333], + "66": [0, 0.68333, 0.10257, 0, 0.70389], + "67": [0, 0.68333, 0.14528, 0, 0.71555], + "68": [0, 0.68333, 0.09403, 0, 0.755], + "69": [0, 0.68333, 0.12028, 0, 0.67833], + "70": [0, 0.68333, 0.13305, 0, 0.65277], + "71": [0, 0.68333, 0.08722, 0, 0.77361], + "72": [0, 0.68333, 0.16389, 0, 0.74333], + "73": [0, 0.68333, 0.15806, 0, 0.38555], + "74": [0, 0.68333, 0.14028, 0, 0.525], + "75": [0, 0.68333, 0.14528, 0, 0.76888], + "76": [0, 0.68333, 0, 0, 0.62722], + "77": [0, 0.68333, 0.16389, 0, 0.89666], + "78": [0, 0.68333, 0.16389, 0, 0.74333], + "79": [0, 0.68333, 0.09403, 0, 0.76666], + "80": [0, 0.68333, 0.10257, 0, 0.67833], + "81": [0.19444, 0.68333, 0.09403, 0, 0.76666], + "82": [0, 0.68333, 0.03868, 0, 0.72944], + "83": [0, 0.68333, 0.11972, 0, 0.56222], + "84": [0, 0.68333, 0.13305, 0, 0.71555], + "85": [0, 0.68333, 0.16389, 0, 0.74333], + "86": [0, 0.68333, 0.18361, 0, 0.74333], + "87": [0, 0.68333, 0.18361, 0, 0.99888], + "88": [0, 0.68333, 0.15806, 0, 0.74333], + "89": [0, 0.68333, 0.19383, 0, 0.74333], + "90": [0, 0.68333, 0.14528, 0, 0.61333], + "91": [0.25, 0.75, 0.1875, 0, 0.30667], + "93": [0.25, 0.75, 0.10528, 0, 0.30667], + "94": [0, 0.69444, 0.06646, 0, 0.51111], + "95": [0.31, 0.12056, 0.09208, 0, 0.51111], + "97": [0, 0.43056, 0.07671, 0, 0.51111], + "98": [0, 0.69444, 0.06312, 0, 0.46], + "99": [0, 0.43056, 0.05653, 0, 0.46], + "100": [0, 0.69444, 0.10333, 0, 0.51111], + "101": [0, 0.43056, 0.07514, 0, 0.46], + "102": [0.19444, 0.69444, 0.21194, 0, 0.30667], + "103": [0.19444, 0.43056, 0.08847, 0, 0.46], + "104": [0, 0.69444, 0.07671, 0, 0.51111], + "105": [0, 0.65536, 0.1019, 0, 0.30667], + "106": [0.19444, 0.65536, 0.14467, 0, 0.30667], + "107": [0, 0.69444, 0.10764, 0, 0.46], + "108": [0, 0.69444, 0.10333, 0, 0.25555], + "109": [0, 0.43056, 0.07671, 0, 0.81777], + "110": [0, 0.43056, 0.07671, 0, 0.56222], + "111": [0, 0.43056, 0.06312, 0, 0.51111], + "112": [0.19444, 0.43056, 0.06312, 0, 0.51111], + "113": [0.19444, 0.43056, 0.08847, 0, 0.46], + "114": [0, 0.43056, 0.10764, 0, 0.42166], + "115": [0, 0.43056, 0.08208, 0, 0.40889], + "116": [0, 0.61508, 0.09486, 0, 0.33222], + "117": [0, 0.43056, 0.07671, 0, 0.53666], + "118": [0, 0.43056, 0.10764, 0, 0.46], + "119": [0, 0.43056, 0.10764, 0, 0.66444], + "120": [0, 0.43056, 0.12042, 0, 0.46389], + "121": [0.19444, 0.43056, 0.08847, 0, 0.48555], + "122": [0, 0.43056, 0.12292, 0, 0.40889], + "126": [0.35, 0.31786, 0.11585, 0, 0.51111], + "160": [0, 0, 0, 0, 0.25], + "168": [0, 0.66786, 0.10474, 0, 0.51111], + "176": [0, 0.69444, 0, 0, 0.83129], + "184": [0.17014, 0, 0, 0, 0.46], + "198": [0, 0.68333, 0.12028, 0, 0.88277], + "216": [0.04861, 0.73194, 0.09403, 0, 0.76666], + "223": [0.19444, 0.69444, 0.10514, 0, 0.53666], + "230": [0, 0.43056, 0.07514, 0, 0.71555], + "248": [0.09722, 0.52778, 0.09194, 0, 0.51111], + "338": [0, 0.68333, 0.12028, 0, 0.98499], + "339": [0, 0.43056, 0.07514, 0, 0.71555], + "710": [0, 0.69444, 0.06646, 0, 0.51111], + "711": [0, 0.62847, 0.08295, 0, 0.51111], + "713": [0, 0.56167, 0.10333, 0, 0.51111], + "714": [0, 0.69444, 0.09694, 0, 0.51111], + "715": [0, 0.69444, 0, 0, 0.51111], + "728": [0, 0.69444, 0.10806, 0, 0.51111], + "729": [0, 0.66786, 0.11752, 0, 0.30667], + "730": [0, 0.69444, 0, 0, 0.83129], + "732": [0, 0.66786, 0.11585, 0, 0.51111], + "733": [0, 0.69444, 0.1225, 0, 0.51111], + "915": [0, 0.68333, 0.13305, 0, 0.62722], + "916": [0, 0.68333, 0, 0, 0.81777], + "920": [0, 0.68333, 0.09403, 0, 0.76666], + "923": [0, 0.68333, 0, 0, 0.69222], + "926": [0, 0.68333, 0.15294, 0, 0.66444], + "928": [0, 0.68333, 0.16389, 0, 0.74333], + "931": [0, 0.68333, 0.12028, 0, 0.71555], + "933": [0, 0.68333, 0.11111, 0, 0.76666], + "934": [0, 0.68333, 0.05986, 0, 0.71555], + "936": [0, 0.68333, 0.11111, 0, 0.76666], + "937": [0, 0.68333, 0.10257, 0, 0.71555], + "8211": [0, 0.43056, 0.09208, 0, 0.51111], + "8212": [0, 0.43056, 0.09208, 0, 1.02222], + "8216": [0, 0.69444, 0.12417, 0, 0.30667], + "8217": [0, 0.69444, 0.12417, 0, 0.30667], + "8220": [0, 0.69444, 0.1685, 0, 0.51444], + "8221": [0, 0.69444, 0.06961, 0, 0.51444], + "8463": [0, 0.68889, 0, 0, 0.54028] + }, + "Main-Regular": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0, 0, 0.27778], + "34": [0, 0.69444, 0, 0, 0.5], + "35": [0.19444, 0.69444, 0, 0, 0.83334], + "36": [0.05556, 0.75, 0, 0, 0.5], + "37": [0.05556, 0.75, 0, 0, 0.83334], + "38": [0, 0.69444, 0, 0, 0.77778], + "39": [0, 0.69444, 0, 0, 0.27778], + "40": [0.25, 0.75, 0, 0, 0.38889], + "41": [0.25, 0.75, 0, 0, 0.38889], + "42": [0, 0.75, 0, 0, 0.5], + "43": [0.08333, 0.58333, 0, 0, 0.77778], + "44": [0.19444, 0.10556, 0, 0, 0.27778], + "45": [0, 0.43056, 0, 0, 0.33333], + "46": [0, 0.10556, 0, 0, 0.27778], + "47": [0.25, 0.75, 0, 0, 0.5], + "48": [0, 0.64444, 0, 0, 0.5], + "49": [0, 0.64444, 0, 0, 0.5], + "50": [0, 0.64444, 0, 0, 0.5], + "51": [0, 0.64444, 0, 0, 0.5], + "52": [0, 0.64444, 0, 0, 0.5], + "53": [0, 0.64444, 0, 0, 0.5], + "54": [0, 0.64444, 0, 0, 0.5], + "55": [0, 0.64444, 0, 0, 0.5], + "56": [0, 0.64444, 0, 0, 0.5], + "57": [0, 0.64444, 0, 0, 0.5], + "58": [0, 0.43056, 0, 0, 0.27778], + "59": [0.19444, 0.43056, 0, 0, 0.27778], + "60": [0.0391, 0.5391, 0, 0, 0.77778], + "61": [-0.13313, 0.36687, 0, 0, 0.77778], + "62": [0.0391, 0.5391, 0, 0, 0.77778], + "63": [0, 0.69444, 0, 0, 0.47222], + "64": [0, 0.69444, 0, 0, 0.77778], + "65": [0, 0.68333, 0, 0, 0.75], + "66": [0, 0.68333, 0, 0, 0.70834], + "67": [0, 0.68333, 0, 0, 0.72222], + "68": [0, 0.68333, 0, 0, 0.76389], + "69": [0, 0.68333, 0, 0, 0.68056], + "70": [0, 0.68333, 0, 0, 0.65278], + "71": [0, 0.68333, 0, 0, 0.78472], + "72": [0, 0.68333, 0, 0, 0.75], + "73": [0, 0.68333, 0, 0, 0.36111], + "74": [0, 0.68333, 0, 0, 0.51389], + "75": [0, 0.68333, 0, 0, 0.77778], + "76": [0, 0.68333, 0, 0, 0.625], + "77": [0, 0.68333, 0, 0, 0.91667], + "78": [0, 0.68333, 0, 0, 0.75], + "79": [0, 0.68333, 0, 0, 0.77778], + "80": [0, 0.68333, 0, 0, 0.68056], + "81": [0.19444, 0.68333, 0, 0, 0.77778], + "82": [0, 0.68333, 0, 0, 0.73611], + "83": [0, 0.68333, 0, 0, 0.55556], + "84": [0, 0.68333, 0, 0, 0.72222], + "85": [0, 0.68333, 0, 0, 0.75], + "86": [0, 0.68333, 0.01389, 0, 0.75], + "87": [0, 0.68333, 0.01389, 0, 1.02778], + "88": [0, 0.68333, 0, 0, 0.75], + "89": [0, 0.68333, 0.025, 0, 0.75], + "90": [0, 0.68333, 0, 0, 0.61111], + "91": [0.25, 0.75, 0, 0, 0.27778], + "92": [0.25, 0.75, 0, 0, 0.5], + "93": [0.25, 0.75, 0, 0, 0.27778], + "94": [0, 0.69444, 0, 0, 0.5], + "95": [0.31, 0.12056, 0.02778, 0, 0.5], + "97": [0, 0.43056, 0, 0, 0.5], + "98": [0, 0.69444, 0, 0, 0.55556], + "99": [0, 0.43056, 0, 0, 0.44445], + "100": [0, 0.69444, 0, 0, 0.55556], + "101": [0, 0.43056, 0, 0, 0.44445], + "102": [0, 0.69444, 0.07778, 0, 0.30556], + "103": [0.19444, 0.43056, 0.01389, 0, 0.5], + "104": [0, 0.69444, 0, 0, 0.55556], + "105": [0, 0.66786, 0, 0, 0.27778], + "106": [0.19444, 0.66786, 0, 0, 0.30556], + "107": [0, 0.69444, 0, 0, 0.52778], + "108": [0, 0.69444, 0, 0, 0.27778], + "109": [0, 0.43056, 0, 0, 0.83334], + "110": [0, 0.43056, 0, 0, 0.55556], + "111": [0, 0.43056, 0, 0, 0.5], + "112": [0.19444, 0.43056, 0, 0, 0.55556], + "113": [0.19444, 0.43056, 0, 0, 0.52778], + "114": [0, 0.43056, 0, 0, 0.39167], + "115": [0, 0.43056, 0, 0, 0.39445], + "116": [0, 0.61508, 0, 0, 0.38889], + "117": [0, 0.43056, 0, 0, 0.55556], + "118": [0, 0.43056, 0.01389, 0, 0.52778], + "119": [0, 0.43056, 0.01389, 0, 0.72222], + "120": [0, 0.43056, 0, 0, 0.52778], + "121": [0.19444, 0.43056, 0.01389, 0, 0.52778], + "122": [0, 0.43056, 0, 0, 0.44445], + "123": [0.25, 0.75, 0, 0, 0.5], + "124": [0.25, 0.75, 0, 0, 0.27778], + "125": [0.25, 0.75, 0, 0, 0.5], + "126": [0.35, 0.31786, 0, 0, 0.5], + "160": [0, 0, 0, 0, 0.25], + "163": [0, 0.69444, 0, 0, 0.76909], + "167": [0.19444, 0.69444, 0, 0, 0.44445], + "168": [0, 0.66786, 0, 0, 0.5], + "172": [0, 0.43056, 0, 0, 0.66667], + "176": [0, 0.69444, 0, 0, 0.75], + "177": [0.08333, 0.58333, 0, 0, 0.77778], + "182": [0.19444, 0.69444, 0, 0, 0.61111], + "184": [0.17014, 0, 0, 0, 0.44445], + "198": [0, 0.68333, 0, 0, 0.90278], + "215": [0.08333, 0.58333, 0, 0, 0.77778], + "216": [0.04861, 0.73194, 0, 0, 0.77778], + "223": [0, 0.69444, 0, 0, 0.5], + "230": [0, 0.43056, 0, 0, 0.72222], + "247": [0.08333, 0.58333, 0, 0, 0.77778], + "248": [0.09722, 0.52778, 0, 0, 0.5], + "305": [0, 0.43056, 0, 0, 0.27778], + "338": [0, 0.68333, 0, 0, 1.01389], + "339": [0, 0.43056, 0, 0, 0.77778], + "567": [0.19444, 0.43056, 0, 0, 0.30556], + "710": [0, 0.69444, 0, 0, 0.5], + "711": [0, 0.62847, 0, 0, 0.5], + "713": [0, 0.56778, 0, 0, 0.5], + "714": [0, 0.69444, 0, 0, 0.5], + "715": [0, 0.69444, 0, 0, 0.5], + "728": [0, 0.69444, 0, 0, 0.5], + "729": [0, 0.66786, 0, 0, 0.27778], + "730": [0, 0.69444, 0, 0, 0.75], + "732": [0, 0.66786, 0, 0, 0.5], + "733": [0, 0.69444, 0, 0, 0.5], + "915": [0, 0.68333, 0, 0, 0.625], + "916": [0, 0.68333, 0, 0, 0.83334], + "920": [0, 0.68333, 0, 0, 0.77778], + "923": [0, 0.68333, 0, 0, 0.69445], + "926": [0, 0.68333, 0, 0, 0.66667], + "928": [0, 0.68333, 0, 0, 0.75], + "931": [0, 0.68333, 0, 0, 0.72222], + "933": [0, 0.68333, 0, 0, 0.77778], + "934": [0, 0.68333, 0, 0, 0.72222], + "936": [0, 0.68333, 0, 0, 0.77778], + "937": [0, 0.68333, 0, 0, 0.72222], + "8211": [0, 0.43056, 0.02778, 0, 0.5], + "8212": [0, 0.43056, 0.02778, 0, 1.0], + "8216": [0, 0.69444, 0, 0, 0.27778], + "8217": [0, 0.69444, 0, 0, 0.27778], + "8220": [0, 0.69444, 0, 0, 0.5], + "8221": [0, 0.69444, 0, 0, 0.5], + "8224": [0.19444, 0.69444, 0, 0, 0.44445], + "8225": [0.19444, 0.69444, 0, 0, 0.44445], + "8230": [0, 0.123, 0, 0, 1.172], + "8242": [0, 0.55556, 0, 0, 0.275], + "8407": [0, 0.71444, 0.15382, 0, 0.5], + "8463": [0, 0.68889, 0, 0, 0.54028], + "8465": [0, 0.69444, 0, 0, 0.72222], + "8467": [0, 0.69444, 0, 0.11111, 0.41667], + "8472": [0.19444, 0.43056, 0, 0.11111, 0.63646], + "8476": [0, 0.69444, 0, 0, 0.72222], + "8501": [0, 0.69444, 0, 0, 0.61111], + "8592": [-0.13313, 0.36687, 0, 0, 1.0], + "8593": [0.19444, 0.69444, 0, 0, 0.5], + "8594": [-0.13313, 0.36687, 0, 0, 1.0], + "8595": [0.19444, 0.69444, 0, 0, 0.5], + "8596": [-0.13313, 0.36687, 0, 0, 1.0], + "8597": [0.25, 0.75, 0, 0, 0.5], + "8598": [0.19444, 0.69444, 0, 0, 1.0], + "8599": [0.19444, 0.69444, 0, 0, 1.0], + "8600": [0.19444, 0.69444, 0, 0, 1.0], + "8601": [0.19444, 0.69444, 0, 0, 1.0], + "8614": [0.011, 0.511, 0, 0, 1.0], + "8617": [0.011, 0.511, 0, 0, 1.126], + "8618": [0.011, 0.511, 0, 0, 1.126], + "8636": [-0.13313, 0.36687, 0, 0, 1.0], + "8637": [-0.13313, 0.36687, 0, 0, 1.0], + "8640": [-0.13313, 0.36687, 0, 0, 1.0], + "8641": [-0.13313, 0.36687, 0, 0, 1.0], + "8652": [0.011, 0.671, 0, 0, 1.0], + "8656": [-0.13313, 0.36687, 0, 0, 1.0], + "8657": [0.19444, 0.69444, 0, 0, 0.61111], + "8658": [-0.13313, 0.36687, 0, 0, 1.0], + "8659": [0.19444, 0.69444, 0, 0, 0.61111], + "8660": [-0.13313, 0.36687, 0, 0, 1.0], + "8661": [0.25, 0.75, 0, 0, 0.61111], + "8704": [0, 0.69444, 0, 0, 0.55556], + "8706": [0, 0.69444, 0.05556, 0.08334, 0.5309], + "8707": [0, 0.69444, 0, 0, 0.55556], + "8709": [0.05556, 0.75, 0, 0, 0.5], + "8711": [0, 0.68333, 0, 0, 0.83334], + "8712": [0.0391, 0.5391, 0, 0, 0.66667], + "8715": [0.0391, 0.5391, 0, 0, 0.66667], + "8722": [0.08333, 0.58333, 0, 0, 0.77778], + "8723": [0.08333, 0.58333, 0, 0, 0.77778], + "8725": [0.25, 0.75, 0, 0, 0.5], + "8726": [0.25, 0.75, 0, 0, 0.5], + "8727": [-0.03472, 0.46528, 0, 0, 0.5], + "8728": [-0.05555, 0.44445, 0, 0, 0.5], + "8729": [-0.05555, 0.44445, 0, 0, 0.5], + "8730": [0.2, 0.8, 0, 0, 0.83334], + "8733": [0, 0.43056, 0, 0, 0.77778], + "8734": [0, 0.43056, 0, 0, 1.0], + "8736": [0, 0.69224, 0, 0, 0.72222], + "8739": [0.25, 0.75, 0, 0, 0.27778], + "8741": [0.25, 0.75, 0, 0, 0.5], + "8743": [0, 0.55556, 0, 0, 0.66667], + "8744": [0, 0.55556, 0, 0, 0.66667], + "8745": [0, 0.55556, 0, 0, 0.66667], + "8746": [0, 0.55556, 0, 0, 0.66667], + "8747": [0.19444, 0.69444, 0.11111, 0, 0.41667], + "8764": [-0.13313, 0.36687, 0, 0, 0.77778], + "8768": [0.19444, 0.69444, 0, 0, 0.27778], + "8771": [-0.03625, 0.46375, 0, 0, 0.77778], + "8773": [-0.022, 0.589, 0, 0, 0.778], + "8776": [-0.01688, 0.48312, 0, 0, 0.77778], + "8781": [-0.03625, 0.46375, 0, 0, 0.77778], + "8784": [-0.133, 0.673, 0, 0, 0.778], + "8801": [-0.03625, 0.46375, 0, 0, 0.77778], + "8804": [0.13597, 0.63597, 0, 0, 0.77778], + "8805": [0.13597, 0.63597, 0, 0, 0.77778], + "8810": [0.0391, 0.5391, 0, 0, 1.0], + "8811": [0.0391, 0.5391, 0, 0, 1.0], + "8826": [0.0391, 0.5391, 0, 0, 0.77778], + "8827": [0.0391, 0.5391, 0, 0, 0.77778], + "8834": [0.0391, 0.5391, 0, 0, 0.77778], + "8835": [0.0391, 0.5391, 0, 0, 0.77778], + "8838": [0.13597, 0.63597, 0, 0, 0.77778], + "8839": [0.13597, 0.63597, 0, 0, 0.77778], + "8846": [0, 0.55556, 0, 0, 0.66667], + "8849": [0.13597, 0.63597, 0, 0, 0.77778], + "8850": [0.13597, 0.63597, 0, 0, 0.77778], + "8851": [0, 0.55556, 0, 0, 0.66667], + "8852": [0, 0.55556, 0, 0, 0.66667], + "8853": [0.08333, 0.58333, 0, 0, 0.77778], + "8854": [0.08333, 0.58333, 0, 0, 0.77778], + "8855": [0.08333, 0.58333, 0, 0, 0.77778], + "8856": [0.08333, 0.58333, 0, 0, 0.77778], + "8857": [0.08333, 0.58333, 0, 0, 0.77778], + "8866": [0, 0.69444, 0, 0, 0.61111], + "8867": [0, 0.69444, 0, 0, 0.61111], + "8868": [0, 0.69444, 0, 0, 0.77778], + "8869": [0, 0.69444, 0, 0, 0.77778], + "8872": [0.249, 0.75, 0, 0, 0.867], + "8900": [-0.05555, 0.44445, 0, 0, 0.5], + "8901": [-0.05555, 0.44445, 0, 0, 0.27778], + "8902": [-0.03472, 0.46528, 0, 0, 0.5], + "8904": [0.005, 0.505, 0, 0, 0.9], + "8942": [0.03, 0.903, 0, 0, 0.278], + "8943": [-0.19, 0.313, 0, 0, 1.172], + "8945": [-0.1, 0.823, 0, 0, 1.282], + "8968": [0.25, 0.75, 0, 0, 0.44445], + "8969": [0.25, 0.75, 0, 0, 0.44445], + "8970": [0.25, 0.75, 0, 0, 0.44445], + "8971": [0.25, 0.75, 0, 0, 0.44445], + "8994": [-0.14236, 0.35764, 0, 0, 1.0], + "8995": [-0.14236, 0.35764, 0, 0, 1.0], + "9136": [0.244, 0.744, 0, 0, 0.412], + "9137": [0.244, 0.745, 0, 0, 0.412], + "9651": [0.19444, 0.69444, 0, 0, 0.88889], + "9657": [-0.03472, 0.46528, 0, 0, 0.5], + "9661": [0.19444, 0.69444, 0, 0, 0.88889], + "9667": [-0.03472, 0.46528, 0, 0, 0.5], + "9711": [0.19444, 0.69444, 0, 0, 1.0], + "9824": [0.12963, 0.69444, 0, 0, 0.77778], + "9825": [0.12963, 0.69444, 0, 0, 0.77778], + "9826": [0.12963, 0.69444, 0, 0, 0.77778], + "9827": [0.12963, 0.69444, 0, 0, 0.77778], + "9837": [0, 0.75, 0, 0, 0.38889], + "9838": [0.19444, 0.69444, 0, 0, 0.38889], + "9839": [0.19444, 0.69444, 0, 0, 0.38889], + "10216": [0.25, 0.75, 0, 0, 0.38889], + "10217": [0.25, 0.75, 0, 0, 0.38889], + "10222": [0.244, 0.744, 0, 0, 0.412], + "10223": [0.244, 0.745, 0, 0, 0.412], + "10229": [0.011, 0.511, 0, 0, 1.609], + "10230": [0.011, 0.511, 0, 0, 1.638], + "10231": [0.011, 0.511, 0, 0, 1.859], + "10232": [0.024, 0.525, 0, 0, 1.609], + "10233": [0.024, 0.525, 0, 0, 1.638], + "10234": [0.024, 0.525, 0, 0, 1.858], + "10236": [0.011, 0.511, 0, 0, 1.638], + "10815": [0, 0.68333, 0, 0, 0.75], + "10927": [0.13597, 0.63597, 0, 0, 0.77778], + "10928": [0.13597, 0.63597, 0, 0, 0.77778], + "57376": [0.19444, 0.69444, 0, 0, 0] + }, + "Math-BoldItalic": { + "32": [0, 0, 0, 0, 0.25], + "48": [0, 0.44444, 0, 0, 0.575], + "49": [0, 0.44444, 0, 0, 0.575], + "50": [0, 0.44444, 0, 0, 0.575], + "51": [0.19444, 0.44444, 0, 0, 0.575], + "52": [0.19444, 0.44444, 0, 0, 0.575], + "53": [0.19444, 0.44444, 0, 0, 0.575], + "54": [0, 0.64444, 0, 0, 0.575], + "55": [0.19444, 0.44444, 0, 0, 0.575], + "56": [0, 0.64444, 0, 0, 0.575], + "57": [0.19444, 0.44444, 0, 0, 0.575], + "65": [0, 0.68611, 0, 0, 0.86944], + "66": [0, 0.68611, 0.04835, 0, 0.8664], + "67": [0, 0.68611, 0.06979, 0, 0.81694], + "68": [0, 0.68611, 0.03194, 0, 0.93812], + "69": [0, 0.68611, 0.05451, 0, 0.81007], + "70": [0, 0.68611, 0.15972, 0, 0.68889], + "71": [0, 0.68611, 0, 0, 0.88673], + "72": [0, 0.68611, 0.08229, 0, 0.98229], + "73": [0, 0.68611, 0.07778, 0, 0.51111], + "74": [0, 0.68611, 0.10069, 0, 0.63125], + "75": [0, 0.68611, 0.06979, 0, 0.97118], + "76": [0, 0.68611, 0, 0, 0.75555], + "77": [0, 0.68611, 0.11424, 0, 1.14201], + "78": [0, 0.68611, 0.11424, 0, 0.95034], + "79": [0, 0.68611, 0.03194, 0, 0.83666], + "80": [0, 0.68611, 0.15972, 0, 0.72309], + "81": [0.19444, 0.68611, 0, 0, 0.86861], + "82": [0, 0.68611, 0.00421, 0, 0.87235], + "83": [0, 0.68611, 0.05382, 0, 0.69271], + "84": [0, 0.68611, 0.15972, 0, 0.63663], + "85": [0, 0.68611, 0.11424, 0, 0.80027], + "86": [0, 0.68611, 0.25555, 0, 0.67778], + "87": [0, 0.68611, 0.15972, 0, 1.09305], + "88": [0, 0.68611, 0.07778, 0, 0.94722], + "89": [0, 0.68611, 0.25555, 0, 0.67458], + "90": [0, 0.68611, 0.06979, 0, 0.77257], + "97": [0, 0.44444, 0, 0, 0.63287], + "98": [0, 0.69444, 0, 0, 0.52083], + "99": [0, 0.44444, 0, 0, 0.51342], + "100": [0, 0.69444, 0, 0, 0.60972], + "101": [0, 0.44444, 0, 0, 0.55361], + "102": [0.19444, 0.69444, 0.11042, 0, 0.56806], + "103": [0.19444, 0.44444, 0.03704, 0, 0.5449], + "104": [0, 0.69444, 0, 0, 0.66759], + "105": [0, 0.69326, 0, 0, 0.4048], + "106": [0.19444, 0.69326, 0.0622, 0, 0.47083], + "107": [0, 0.69444, 0.01852, 0, 0.6037], + "108": [0, 0.69444, 0.0088, 0, 0.34815], + "109": [0, 0.44444, 0, 0, 1.0324], + "110": [0, 0.44444, 0, 0, 0.71296], + "111": [0, 0.44444, 0, 0, 0.58472], + "112": [0.19444, 0.44444, 0, 0, 0.60092], + "113": [0.19444, 0.44444, 0.03704, 0, 0.54213], + "114": [0, 0.44444, 0.03194, 0, 0.5287], + "115": [0, 0.44444, 0, 0, 0.53125], + "116": [0, 0.63492, 0, 0, 0.41528], + "117": [0, 0.44444, 0, 0, 0.68102], + "118": [0, 0.44444, 0.03704, 0, 0.56666], + "119": [0, 0.44444, 0.02778, 0, 0.83148], + "120": [0, 0.44444, 0, 0, 0.65903], + "121": [0.19444, 0.44444, 0.03704, 0, 0.59028], + "122": [0, 0.44444, 0.04213, 0, 0.55509], + "160": [0, 0, 0, 0, 0.25], + "915": [0, 0.68611, 0.15972, 0, 0.65694], + "916": [0, 0.68611, 0, 0, 0.95833], + "920": [0, 0.68611, 0.03194, 0, 0.86722], + "923": [0, 0.68611, 0, 0, 0.80555], + "926": [0, 0.68611, 0.07458, 0, 0.84125], + "928": [0, 0.68611, 0.08229, 0, 0.98229], + "931": [0, 0.68611, 0.05451, 0, 0.88507], + "933": [0, 0.68611, 0.15972, 0, 0.67083], + "934": [0, 0.68611, 0, 0, 0.76666], + "936": [0, 0.68611, 0.11653, 0, 0.71402], + "937": [0, 0.68611, 0.04835, 0, 0.8789], + "945": [0, 0.44444, 0, 0, 0.76064], + "946": [0.19444, 0.69444, 0.03403, 0, 0.65972], + "947": [0.19444, 0.44444, 0.06389, 0, 0.59003], + "948": [0, 0.69444, 0.03819, 0, 0.52222], + "949": [0, 0.44444, 0, 0, 0.52882], + "950": [0.19444, 0.69444, 0.06215, 0, 0.50833], + "951": [0.19444, 0.44444, 0.03704, 0, 0.6], + "952": [0, 0.69444, 0.03194, 0, 0.5618], + "953": [0, 0.44444, 0, 0, 0.41204], + "954": [0, 0.44444, 0, 0, 0.66759], + "955": [0, 0.69444, 0, 0, 0.67083], + "956": [0.19444, 0.44444, 0, 0, 0.70787], + "957": [0, 0.44444, 0.06898, 0, 0.57685], + "958": [0.19444, 0.69444, 0.03021, 0, 0.50833], + "959": [0, 0.44444, 0, 0, 0.58472], + "960": [0, 0.44444, 0.03704, 0, 0.68241], + "961": [0.19444, 0.44444, 0, 0, 0.6118], + "962": [0.09722, 0.44444, 0.07917, 0, 0.42361], + "963": [0, 0.44444, 0.03704, 0, 0.68588], + "964": [0, 0.44444, 0.13472, 0, 0.52083], + "965": [0, 0.44444, 0.03704, 0, 0.63055], + "966": [0.19444, 0.44444, 0, 0, 0.74722], + "967": [0.19444, 0.44444, 0, 0, 0.71805], + "968": [0.19444, 0.69444, 0.03704, 0, 0.75833], + "969": [0, 0.44444, 0.03704, 0, 0.71782], + "977": [0, 0.69444, 0, 0, 0.69155], + "981": [0.19444, 0.69444, 0, 0, 0.7125], + "982": [0, 0.44444, 0.03194, 0, 0.975], + "1009": [0.19444, 0.44444, 0, 0, 0.6118], + "1013": [0, 0.44444, 0, 0, 0.48333], + "57649": [0, 0.44444, 0, 0, 0.39352], + "57911": [0.19444, 0.44444, 0, 0, 0.43889] + }, + "Math-Italic": { + "32": [0, 0, 0, 0, 0.25], + "48": [0, 0.43056, 0, 0, 0.5], + "49": [0, 0.43056, 0, 0, 0.5], + "50": [0, 0.43056, 0, 0, 0.5], + "51": [0.19444, 0.43056, 0, 0, 0.5], + "52": [0.19444, 0.43056, 0, 0, 0.5], + "53": [0.19444, 0.43056, 0, 0, 0.5], + "54": [0, 0.64444, 0, 0, 0.5], + "55": [0.19444, 0.43056, 0, 0, 0.5], + "56": [0, 0.64444, 0, 0, 0.5], + "57": [0.19444, 0.43056, 0, 0, 0.5], + "65": [0, 0.68333, 0, 0.13889, 0.75], + "66": [0, 0.68333, 0.05017, 0.08334, 0.75851], + "67": [0, 0.68333, 0.07153, 0.08334, 0.71472], + "68": [0, 0.68333, 0.02778, 0.05556, 0.82792], + "69": [0, 0.68333, 0.05764, 0.08334, 0.7382], + "70": [0, 0.68333, 0.13889, 0.08334, 0.64306], + "71": [0, 0.68333, 0, 0.08334, 0.78625], + "72": [0, 0.68333, 0.08125, 0.05556, 0.83125], + "73": [0, 0.68333, 0.07847, 0.11111, 0.43958], + "74": [0, 0.68333, 0.09618, 0.16667, 0.55451], + "75": [0, 0.68333, 0.07153, 0.05556, 0.84931], + "76": [0, 0.68333, 0, 0.02778, 0.68056], + "77": [0, 0.68333, 0.10903, 0.08334, 0.97014], + "78": [0, 0.68333, 0.10903, 0.08334, 0.80347], + "79": [0, 0.68333, 0.02778, 0.08334, 0.76278], + "80": [0, 0.68333, 0.13889, 0.08334, 0.64201], + "81": [0.19444, 0.68333, 0, 0.08334, 0.79056], + "82": [0, 0.68333, 0.00773, 0.08334, 0.75929], + "83": [0, 0.68333, 0.05764, 0.08334, 0.6132], + "84": [0, 0.68333, 0.13889, 0.08334, 0.58438], + "85": [0, 0.68333, 0.10903, 0.02778, 0.68278], + "86": [0, 0.68333, 0.22222, 0, 0.58333], + "87": [0, 0.68333, 0.13889, 0, 0.94445], + "88": [0, 0.68333, 0.07847, 0.08334, 0.82847], + "89": [0, 0.68333, 0.22222, 0, 0.58056], + "90": [0, 0.68333, 0.07153, 0.08334, 0.68264], + "97": [0, 0.43056, 0, 0, 0.52859], + "98": [0, 0.69444, 0, 0, 0.42917], + "99": [0, 0.43056, 0, 0.05556, 0.43276], + "100": [0, 0.69444, 0, 0.16667, 0.52049], + "101": [0, 0.43056, 0, 0.05556, 0.46563], + "102": [0.19444, 0.69444, 0.10764, 0.16667, 0.48959], + "103": [0.19444, 0.43056, 0.03588, 0.02778, 0.47697], + "104": [0, 0.69444, 0, 0, 0.57616], + "105": [0, 0.65952, 0, 0, 0.34451], + "106": [0.19444, 0.65952, 0.05724, 0, 0.41181], + "107": [0, 0.69444, 0.03148, 0, 0.5206], + "108": [0, 0.69444, 0.01968, 0.08334, 0.29838], + "109": [0, 0.43056, 0, 0, 0.87801], + "110": [0, 0.43056, 0, 0, 0.60023], + "111": [0, 0.43056, 0, 0.05556, 0.48472], + "112": [0.19444, 0.43056, 0, 0.08334, 0.50313], + "113": [0.19444, 0.43056, 0.03588, 0.08334, 0.44641], + "114": [0, 0.43056, 0.02778, 0.05556, 0.45116], + "115": [0, 0.43056, 0, 0.05556, 0.46875], + "116": [0, 0.61508, 0, 0.08334, 0.36111], + "117": [0, 0.43056, 0, 0.02778, 0.57246], + "118": [0, 0.43056, 0.03588, 0.02778, 0.48472], + "119": [0, 0.43056, 0.02691, 0.08334, 0.71592], + "120": [0, 0.43056, 0, 0.02778, 0.57153], + "121": [0.19444, 0.43056, 0.03588, 0.05556, 0.49028], + "122": [0, 0.43056, 0.04398, 0.05556, 0.46505], + "160": [0, 0, 0, 0, 0.25], + "915": [0, 0.68333, 0.13889, 0.08334, 0.61528], + "916": [0, 0.68333, 0, 0.16667, 0.83334], + "920": [0, 0.68333, 0.02778, 0.08334, 0.76278], + "923": [0, 0.68333, 0, 0.16667, 0.69445], + "926": [0, 0.68333, 0.07569, 0.08334, 0.74236], + "928": [0, 0.68333, 0.08125, 0.05556, 0.83125], + "931": [0, 0.68333, 0.05764, 0.08334, 0.77986], + "933": [0, 0.68333, 0.13889, 0.05556, 0.58333], + "934": [0, 0.68333, 0, 0.08334, 0.66667], + "936": [0, 0.68333, 0.11, 0.05556, 0.61222], + "937": [0, 0.68333, 0.05017, 0.08334, 0.7724], + "945": [0, 0.43056, 0.0037, 0.02778, 0.6397], + "946": [0.19444, 0.69444, 0.05278, 0.08334, 0.56563], + "947": [0.19444, 0.43056, 0.05556, 0, 0.51773], + "948": [0, 0.69444, 0.03785, 0.05556, 0.44444], + "949": [0, 0.43056, 0, 0.08334, 0.46632], + "950": [0.19444, 0.69444, 0.07378, 0.08334, 0.4375], + "951": [0.19444, 0.43056, 0.03588, 0.05556, 0.49653], + "952": [0, 0.69444, 0.02778, 0.08334, 0.46944], + "953": [0, 0.43056, 0, 0.05556, 0.35394], + "954": [0, 0.43056, 0, 0, 0.57616], + "955": [0, 0.69444, 0, 0, 0.58334], + "956": [0.19444, 0.43056, 0, 0.02778, 0.60255], + "957": [0, 0.43056, 0.06366, 0.02778, 0.49398], + "958": [0.19444, 0.69444, 0.04601, 0.11111, 0.4375], + "959": [0, 0.43056, 0, 0.05556, 0.48472], + "960": [0, 0.43056, 0.03588, 0, 0.57003], + "961": [0.19444, 0.43056, 0, 0.08334, 0.51702], + "962": [0.09722, 0.43056, 0.07986, 0.08334, 0.36285], + "963": [0, 0.43056, 0.03588, 0, 0.57141], + "964": [0, 0.43056, 0.1132, 0.02778, 0.43715], + "965": [0, 0.43056, 0.03588, 0.02778, 0.54028], + "966": [0.19444, 0.43056, 0, 0.08334, 0.65417], + "967": [0.19444, 0.43056, 0, 0.05556, 0.62569], + "968": [0.19444, 0.69444, 0.03588, 0.11111, 0.65139], + "969": [0, 0.43056, 0.03588, 0, 0.62245], + "977": [0, 0.69444, 0, 0.08334, 0.59144], + "981": [0.19444, 0.69444, 0, 0.08334, 0.59583], + "982": [0, 0.43056, 0.02778, 0, 0.82813], + "1009": [0.19444, 0.43056, 0, 0.08334, 0.51702], + "1013": [0, 0.43056, 0, 0.05556, 0.4059], + "57649": [0, 0.43056, 0, 0.02778, 0.32246], + "57911": [0.19444, 0.43056, 0, 0.08334, 0.38403] + }, + "SansSerif-Bold": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0, 0, 0.36667], + "34": [0, 0.69444, 0, 0, 0.55834], + "35": [0.19444, 0.69444, 0, 0, 0.91667], + "36": [0.05556, 0.75, 0, 0, 0.55], + "37": [0.05556, 0.75, 0, 0, 1.02912], + "38": [0, 0.69444, 0, 0, 0.83056], + "39": [0, 0.69444, 0, 0, 0.30556], + "40": [0.25, 0.75, 0, 0, 0.42778], + "41": [0.25, 0.75, 0, 0, 0.42778], + "42": [0, 0.75, 0, 0, 0.55], + "43": [0.11667, 0.61667, 0, 0, 0.85556], + "44": [0.10556, 0.13056, 0, 0, 0.30556], + "45": [0, 0.45833, 0, 0, 0.36667], + "46": [0, 0.13056, 0, 0, 0.30556], + "47": [0.25, 0.75, 0, 0, 0.55], + "48": [0, 0.69444, 0, 0, 0.55], + "49": [0, 0.69444, 0, 0, 0.55], + "50": [0, 0.69444, 0, 0, 0.55], + "51": [0, 0.69444, 0, 0, 0.55], + "52": [0, 0.69444, 0, 0, 0.55], + "53": [0, 0.69444, 0, 0, 0.55], + "54": [0, 0.69444, 0, 0, 0.55], + "55": [0, 0.69444, 0, 0, 0.55], + "56": [0, 0.69444, 0, 0, 0.55], + "57": [0, 0.69444, 0, 0, 0.55], + "58": [0, 0.45833, 0, 0, 0.30556], + "59": [0.10556, 0.45833, 0, 0, 0.30556], + "61": [-0.09375, 0.40625, 0, 0, 0.85556], + "63": [0, 0.69444, 0, 0, 0.51945], + "64": [0, 0.69444, 0, 0, 0.73334], + "65": [0, 0.69444, 0, 0, 0.73334], + "66": [0, 0.69444, 0, 0, 0.73334], + "67": [0, 0.69444, 0, 0, 0.70278], + "68": [0, 0.69444, 0, 0, 0.79445], + "69": [0, 0.69444, 0, 0, 0.64167], + "70": [0, 0.69444, 0, 0, 0.61111], + "71": [0, 0.69444, 0, 0, 0.73334], + "72": [0, 0.69444, 0, 0, 0.79445], + "73": [0, 0.69444, 0, 0, 0.33056], + "74": [0, 0.69444, 0, 0, 0.51945], + "75": [0, 0.69444, 0, 0, 0.76389], + "76": [0, 0.69444, 0, 0, 0.58056], + "77": [0, 0.69444, 0, 0, 0.97778], + "78": [0, 0.69444, 0, 0, 0.79445], + "79": [0, 0.69444, 0, 0, 0.79445], + "80": [0, 0.69444, 0, 0, 0.70278], + "81": [0.10556, 0.69444, 0, 0, 0.79445], + "82": [0, 0.69444, 0, 0, 0.70278], + "83": [0, 0.69444, 0, 0, 0.61111], + "84": [0, 0.69444, 0, 0, 0.73334], + "85": [0, 0.69444, 0, 0, 0.76389], + "86": [0, 0.69444, 0.01528, 0, 0.73334], + "87": [0, 0.69444, 0.01528, 0, 1.03889], + "88": [0, 0.69444, 0, 0, 0.73334], + "89": [0, 0.69444, 0.0275, 0, 0.73334], + "90": [0, 0.69444, 0, 0, 0.67223], + "91": [0.25, 0.75, 0, 0, 0.34306], + "93": [0.25, 0.75, 0, 0, 0.34306], + "94": [0, 0.69444, 0, 0, 0.55], + "95": [0.35, 0.10833, 0.03056, 0, 0.55], + "97": [0, 0.45833, 0, 0, 0.525], + "98": [0, 0.69444, 0, 0, 0.56111], + "99": [0, 0.45833, 0, 0, 0.48889], + "100": [0, 0.69444, 0, 0, 0.56111], + "101": [0, 0.45833, 0, 0, 0.51111], + "102": [0, 0.69444, 0.07639, 0, 0.33611], + "103": [0.19444, 0.45833, 0.01528, 0, 0.55], + "104": [0, 0.69444, 0, 0, 0.56111], + "105": [0, 0.69444, 0, 0, 0.25556], + "106": [0.19444, 0.69444, 0, 0, 0.28611], + "107": [0, 0.69444, 0, 0, 0.53056], + "108": [0, 0.69444, 0, 0, 0.25556], + "109": [0, 0.45833, 0, 0, 0.86667], + "110": [0, 0.45833, 0, 0, 0.56111], + "111": [0, 0.45833, 0, 0, 0.55], + "112": [0.19444, 0.45833, 0, 0, 0.56111], + "113": [0.19444, 0.45833, 0, 0, 0.56111], + "114": [0, 0.45833, 0.01528, 0, 0.37222], + "115": [0, 0.45833, 0, 0, 0.42167], + "116": [0, 0.58929, 0, 0, 0.40417], + "117": [0, 0.45833, 0, 0, 0.56111], + "118": [0, 0.45833, 0.01528, 0, 0.5], + "119": [0, 0.45833, 0.01528, 0, 0.74445], + "120": [0, 0.45833, 0, 0, 0.5], + "121": [0.19444, 0.45833, 0.01528, 0, 0.5], + "122": [0, 0.45833, 0, 0, 0.47639], + "126": [0.35, 0.34444, 0, 0, 0.55], + "160": [0, 0, 0, 0, 0.25], + "168": [0, 0.69444, 0, 0, 0.55], + "176": [0, 0.69444, 0, 0, 0.73334], + "180": [0, 0.69444, 0, 0, 0.55], + "184": [0.17014, 0, 0, 0, 0.48889], + "305": [0, 0.45833, 0, 0, 0.25556], + "567": [0.19444, 0.45833, 0, 0, 0.28611], + "710": [0, 0.69444, 0, 0, 0.55], + "711": [0, 0.63542, 0, 0, 0.55], + "713": [0, 0.63778, 0, 0, 0.55], + "728": [0, 0.69444, 0, 0, 0.55], + "729": [0, 0.69444, 0, 0, 0.30556], + "730": [0, 0.69444, 0, 0, 0.73334], + "732": [0, 0.69444, 0, 0, 0.55], + "733": [0, 0.69444, 0, 0, 0.55], + "915": [0, 0.69444, 0, 0, 0.58056], + "916": [0, 0.69444, 0, 0, 0.91667], + "920": [0, 0.69444, 0, 0, 0.85556], + "923": [0, 0.69444, 0, 0, 0.67223], + "926": [0, 0.69444, 0, 0, 0.73334], + "928": [0, 0.69444, 0, 0, 0.79445], + "931": [0, 0.69444, 0, 0, 0.79445], + "933": [0, 0.69444, 0, 0, 0.85556], + "934": [0, 0.69444, 0, 0, 0.79445], + "936": [0, 0.69444, 0, 0, 0.85556], + "937": [0, 0.69444, 0, 0, 0.79445], + "8211": [0, 0.45833, 0.03056, 0, 0.55], + "8212": [0, 0.45833, 0.03056, 0, 1.10001], + "8216": [0, 0.69444, 0, 0, 0.30556], + "8217": [0, 0.69444, 0, 0, 0.30556], + "8220": [0, 0.69444, 0, 0, 0.55834], + "8221": [0, 0.69444, 0, 0, 0.55834] + }, + "SansSerif-Italic": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0.05733, 0, 0.31945], + "34": [0, 0.69444, 0.00316, 0, 0.5], + "35": [0.19444, 0.69444, 0.05087, 0, 0.83334], + "36": [0.05556, 0.75, 0.11156, 0, 0.5], + "37": [0.05556, 0.75, 0.03126, 0, 0.83334], + "38": [0, 0.69444, 0.03058, 0, 0.75834], + "39": [0, 0.69444, 0.07816, 0, 0.27778], + "40": [0.25, 0.75, 0.13164, 0, 0.38889], + "41": [0.25, 0.75, 0.02536, 0, 0.38889], + "42": [0, 0.75, 0.11775, 0, 0.5], + "43": [0.08333, 0.58333, 0.02536, 0, 0.77778], + "44": [0.125, 0.08333, 0, 0, 0.27778], + "45": [0, 0.44444, 0.01946, 0, 0.33333], + "46": [0, 0.08333, 0, 0, 0.27778], + "47": [0.25, 0.75, 0.13164, 0, 0.5], + "48": [0, 0.65556, 0.11156, 0, 0.5], + "49": [0, 0.65556, 0.11156, 0, 0.5], + "50": [0, 0.65556, 0.11156, 0, 0.5], + "51": [0, 0.65556, 0.11156, 0, 0.5], + "52": [0, 0.65556, 0.11156, 0, 0.5], + "53": [0, 0.65556, 0.11156, 0, 0.5], + "54": [0, 0.65556, 0.11156, 0, 0.5], + "55": [0, 0.65556, 0.11156, 0, 0.5], + "56": [0, 0.65556, 0.11156, 0, 0.5], + "57": [0, 0.65556, 0.11156, 0, 0.5], + "58": [0, 0.44444, 0.02502, 0, 0.27778], + "59": [0.125, 0.44444, 0.02502, 0, 0.27778], + "61": [-0.13, 0.37, 0.05087, 0, 0.77778], + "63": [0, 0.69444, 0.11809, 0, 0.47222], + "64": [0, 0.69444, 0.07555, 0, 0.66667], + "65": [0, 0.69444, 0, 0, 0.66667], + "66": [0, 0.69444, 0.08293, 0, 0.66667], + "67": [0, 0.69444, 0.11983, 0, 0.63889], + "68": [0, 0.69444, 0.07555, 0, 0.72223], + "69": [0, 0.69444, 0.11983, 0, 0.59722], + "70": [0, 0.69444, 0.13372, 0, 0.56945], + "71": [0, 0.69444, 0.11983, 0, 0.66667], + "72": [0, 0.69444, 0.08094, 0, 0.70834], + "73": [0, 0.69444, 0.13372, 0, 0.27778], + "74": [0, 0.69444, 0.08094, 0, 0.47222], + "75": [0, 0.69444, 0.11983, 0, 0.69445], + "76": [0, 0.69444, 0, 0, 0.54167], + "77": [0, 0.69444, 0.08094, 0, 0.875], + "78": [0, 0.69444, 0.08094, 0, 0.70834], + "79": [0, 0.69444, 0.07555, 0, 0.73611], + "80": [0, 0.69444, 0.08293, 0, 0.63889], + "81": [0.125, 0.69444, 0.07555, 0, 0.73611], + "82": [0, 0.69444, 0.08293, 0, 0.64584], + "83": [0, 0.69444, 0.09205, 0, 0.55556], + "84": [0, 0.69444, 0.13372, 0, 0.68056], + "85": [0, 0.69444, 0.08094, 0, 0.6875], + "86": [0, 0.69444, 0.1615, 0, 0.66667], + "87": [0, 0.69444, 0.1615, 0, 0.94445], + "88": [0, 0.69444, 0.13372, 0, 0.66667], + "89": [0, 0.69444, 0.17261, 0, 0.66667], + "90": [0, 0.69444, 0.11983, 0, 0.61111], + "91": [0.25, 0.75, 0.15942, 0, 0.28889], + "93": [0.25, 0.75, 0.08719, 0, 0.28889], + "94": [0, 0.69444, 0.0799, 0, 0.5], + "95": [0.35, 0.09444, 0.08616, 0, 0.5], + "97": [0, 0.44444, 0.00981, 0, 0.48056], + "98": [0, 0.69444, 0.03057, 0, 0.51667], + "99": [0, 0.44444, 0.08336, 0, 0.44445], + "100": [0, 0.69444, 0.09483, 0, 0.51667], + "101": [0, 0.44444, 0.06778, 0, 0.44445], + "102": [0, 0.69444, 0.21705, 0, 0.30556], + "103": [0.19444, 0.44444, 0.10836, 0, 0.5], + "104": [0, 0.69444, 0.01778, 0, 0.51667], + "105": [0, 0.67937, 0.09718, 0, 0.23889], + "106": [0.19444, 0.67937, 0.09162, 0, 0.26667], + "107": [0, 0.69444, 0.08336, 0, 0.48889], + "108": [0, 0.69444, 0.09483, 0, 0.23889], + "109": [0, 0.44444, 0.01778, 0, 0.79445], + "110": [0, 0.44444, 0.01778, 0, 0.51667], + "111": [0, 0.44444, 0.06613, 0, 0.5], + "112": [0.19444, 0.44444, 0.0389, 0, 0.51667], + "113": [0.19444, 0.44444, 0.04169, 0, 0.51667], + "114": [0, 0.44444, 0.10836, 0, 0.34167], + "115": [0, 0.44444, 0.0778, 0, 0.38333], + "116": [0, 0.57143, 0.07225, 0, 0.36111], + "117": [0, 0.44444, 0.04169, 0, 0.51667], + "118": [0, 0.44444, 0.10836, 0, 0.46111], + "119": [0, 0.44444, 0.10836, 0, 0.68334], + "120": [0, 0.44444, 0.09169, 0, 0.46111], + "121": [0.19444, 0.44444, 0.10836, 0, 0.46111], + "122": [0, 0.44444, 0.08752, 0, 0.43472], + "126": [0.35, 0.32659, 0.08826, 0, 0.5], + "160": [0, 0, 0, 0, 0.25], + "168": [0, 0.67937, 0.06385, 0, 0.5], + "176": [0, 0.69444, 0, 0, 0.73752], + "184": [0.17014, 0, 0, 0, 0.44445], + "305": [0, 0.44444, 0.04169, 0, 0.23889], + "567": [0.19444, 0.44444, 0.04169, 0, 0.26667], + "710": [0, 0.69444, 0.0799, 0, 0.5], + "711": [0, 0.63194, 0.08432, 0, 0.5], + "713": [0, 0.60889, 0.08776, 0, 0.5], + "714": [0, 0.69444, 0.09205, 0, 0.5], + "715": [0, 0.69444, 0, 0, 0.5], + "728": [0, 0.69444, 0.09483, 0, 0.5], + "729": [0, 0.67937, 0.07774, 0, 0.27778], + "730": [0, 0.69444, 0, 0, 0.73752], + "732": [0, 0.67659, 0.08826, 0, 0.5], + "733": [0, 0.69444, 0.09205, 0, 0.5], + "915": [0, 0.69444, 0.13372, 0, 0.54167], + "916": [0, 0.69444, 0, 0, 0.83334], + "920": [0, 0.69444, 0.07555, 0, 0.77778], + "923": [0, 0.69444, 0, 0, 0.61111], + "926": [0, 0.69444, 0.12816, 0, 0.66667], + "928": [0, 0.69444, 0.08094, 0, 0.70834], + "931": [0, 0.69444, 0.11983, 0, 0.72222], + "933": [0, 0.69444, 0.09031, 0, 0.77778], + "934": [0, 0.69444, 0.04603, 0, 0.72222], + "936": [0, 0.69444, 0.09031, 0, 0.77778], + "937": [0, 0.69444, 0.08293, 0, 0.72222], + "8211": [0, 0.44444, 0.08616, 0, 0.5], + "8212": [0, 0.44444, 0.08616, 0, 1.0], + "8216": [0, 0.69444, 0.07816, 0, 0.27778], + "8217": [0, 0.69444, 0.07816, 0, 0.27778], + "8220": [0, 0.69444, 0.14205, 0, 0.5], + "8221": [0, 0.69444, 0.00316, 0, 0.5] + }, + "SansSerif-Regular": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0, 0, 0.31945], + "34": [0, 0.69444, 0, 0, 0.5], + "35": [0.19444, 0.69444, 0, 0, 0.83334], + "36": [0.05556, 0.75, 0, 0, 0.5], + "37": [0.05556, 0.75, 0, 0, 0.83334], + "38": [0, 0.69444, 0, 0, 0.75834], + "39": [0, 0.69444, 0, 0, 0.27778], + "40": [0.25, 0.75, 0, 0, 0.38889], + "41": [0.25, 0.75, 0, 0, 0.38889], + "42": [0, 0.75, 0, 0, 0.5], + "43": [0.08333, 0.58333, 0, 0, 0.77778], + "44": [0.125, 0.08333, 0, 0, 0.27778], + "45": [0, 0.44444, 0, 0, 0.33333], + "46": [0, 0.08333, 0, 0, 0.27778], + "47": [0.25, 0.75, 0, 0, 0.5], + "48": [0, 0.65556, 0, 0, 0.5], + "49": [0, 0.65556, 0, 0, 0.5], + "50": [0, 0.65556, 0, 0, 0.5], + "51": [0, 0.65556, 0, 0, 0.5], + "52": [0, 0.65556, 0, 0, 0.5], + "53": [0, 0.65556, 0, 0, 0.5], + "54": [0, 0.65556, 0, 0, 0.5], + "55": [0, 0.65556, 0, 0, 0.5], + "56": [0, 0.65556, 0, 0, 0.5], + "57": [0, 0.65556, 0, 0, 0.5], + "58": [0, 0.44444, 0, 0, 0.27778], + "59": [0.125, 0.44444, 0, 0, 0.27778], + "61": [-0.13, 0.37, 0, 0, 0.77778], + "63": [0, 0.69444, 0, 0, 0.47222], + "64": [0, 0.69444, 0, 0, 0.66667], + "65": [0, 0.69444, 0, 0, 0.66667], + "66": [0, 0.69444, 0, 0, 0.66667], + "67": [0, 0.69444, 0, 0, 0.63889], + "68": [0, 0.69444, 0, 0, 0.72223], + "69": [0, 0.69444, 0, 0, 0.59722], + "70": [0, 0.69444, 0, 0, 0.56945], + "71": [0, 0.69444, 0, 0, 0.66667], + "72": [0, 0.69444, 0, 0, 0.70834], + "73": [0, 0.69444, 0, 0, 0.27778], + "74": [0, 0.69444, 0, 0, 0.47222], + "75": [0, 0.69444, 0, 0, 0.69445], + "76": [0, 0.69444, 0, 0, 0.54167], + "77": [0, 0.69444, 0, 0, 0.875], + "78": [0, 0.69444, 0, 0, 0.70834], + "79": [0, 0.69444, 0, 0, 0.73611], + "80": [0, 0.69444, 0, 0, 0.63889], + "81": [0.125, 0.69444, 0, 0, 0.73611], + "82": [0, 0.69444, 0, 0, 0.64584], + "83": [0, 0.69444, 0, 0, 0.55556], + "84": [0, 0.69444, 0, 0, 0.68056], + "85": [0, 0.69444, 0, 0, 0.6875], + "86": [0, 0.69444, 0.01389, 0, 0.66667], + "87": [0, 0.69444, 0.01389, 0, 0.94445], + "88": [0, 0.69444, 0, 0, 0.66667], + "89": [0, 0.69444, 0.025, 0, 0.66667], + "90": [0, 0.69444, 0, 0, 0.61111], + "91": [0.25, 0.75, 0, 0, 0.28889], + "93": [0.25, 0.75, 0, 0, 0.28889], + "94": [0, 0.69444, 0, 0, 0.5], + "95": [0.35, 0.09444, 0.02778, 0, 0.5], + "97": [0, 0.44444, 0, 0, 0.48056], + "98": [0, 0.69444, 0, 0, 0.51667], + "99": [0, 0.44444, 0, 0, 0.44445], + "100": [0, 0.69444, 0, 0, 0.51667], + "101": [0, 0.44444, 0, 0, 0.44445], + "102": [0, 0.69444, 0.06944, 0, 0.30556], + "103": [0.19444, 0.44444, 0.01389, 0, 0.5], + "104": [0, 0.69444, 0, 0, 0.51667], + "105": [0, 0.67937, 0, 0, 0.23889], + "106": [0.19444, 0.67937, 0, 0, 0.26667], + "107": [0, 0.69444, 0, 0, 0.48889], + "108": [0, 0.69444, 0, 0, 0.23889], + "109": [0, 0.44444, 0, 0, 0.79445], + "110": [0, 0.44444, 0, 0, 0.51667], + "111": [0, 0.44444, 0, 0, 0.5], + "112": [0.19444, 0.44444, 0, 0, 0.51667], + "113": [0.19444, 0.44444, 0, 0, 0.51667], + "114": [0, 0.44444, 0.01389, 0, 0.34167], + "115": [0, 0.44444, 0, 0, 0.38333], + "116": [0, 0.57143, 0, 0, 0.36111], + "117": [0, 0.44444, 0, 0, 0.51667], + "118": [0, 0.44444, 0.01389, 0, 0.46111], + "119": [0, 0.44444, 0.01389, 0, 0.68334], + "120": [0, 0.44444, 0, 0, 0.46111], + "121": [0.19444, 0.44444, 0.01389, 0, 0.46111], + "122": [0, 0.44444, 0, 0, 0.43472], + "126": [0.35, 0.32659, 0, 0, 0.5], + "160": [0, 0, 0, 0, 0.25], + "168": [0, 0.67937, 0, 0, 0.5], + "176": [0, 0.69444, 0, 0, 0.66667], + "184": [0.17014, 0, 0, 0, 0.44445], + "305": [0, 0.44444, 0, 0, 0.23889], + "567": [0.19444, 0.44444, 0, 0, 0.26667], + "710": [0, 0.69444, 0, 0, 0.5], + "711": [0, 0.63194, 0, 0, 0.5], + "713": [0, 0.60889, 0, 0, 0.5], + "714": [0, 0.69444, 0, 0, 0.5], + "715": [0, 0.69444, 0, 0, 0.5], + "728": [0, 0.69444, 0, 0, 0.5], + "729": [0, 0.67937, 0, 0, 0.27778], + "730": [0, 0.69444, 0, 0, 0.66667], + "732": [0, 0.67659, 0, 0, 0.5], + "733": [0, 0.69444, 0, 0, 0.5], + "915": [0, 0.69444, 0, 0, 0.54167], + "916": [0, 0.69444, 0, 0, 0.83334], + "920": [0, 0.69444, 0, 0, 0.77778], + "923": [0, 0.69444, 0, 0, 0.61111], + "926": [0, 0.69444, 0, 0, 0.66667], + "928": [0, 0.69444, 0, 0, 0.70834], + "931": [0, 0.69444, 0, 0, 0.72222], + "933": [0, 0.69444, 0, 0, 0.77778], + "934": [0, 0.69444, 0, 0, 0.72222], + "936": [0, 0.69444, 0, 0, 0.77778], + "937": [0, 0.69444, 0, 0, 0.72222], + "8211": [0, 0.44444, 0.02778, 0, 0.5], + "8212": [0, 0.44444, 0.02778, 0, 1.0], + "8216": [0, 0.69444, 0, 0, 0.27778], + "8217": [0, 0.69444, 0, 0, 0.27778], + "8220": [0, 0.69444, 0, 0, 0.5], + "8221": [0, 0.69444, 0, 0, 0.5] + }, + "Script-Regular": { + "32": [0, 0, 0, 0, 0.25], + "65": [0, 0.7, 0.22925, 0, 0.80253], + "66": [0, 0.7, 0.04087, 0, 0.90757], + "67": [0, 0.7, 0.1689, 0, 0.66619], + "68": [0, 0.7, 0.09371, 0, 0.77443], + "69": [0, 0.7, 0.18583, 0, 0.56162], + "70": [0, 0.7, 0.13634, 0, 0.89544], + "71": [0, 0.7, 0.17322, 0, 0.60961], + "72": [0, 0.7, 0.29694, 0, 0.96919], + "73": [0, 0.7, 0.19189, 0, 0.80907], + "74": [0.27778, 0.7, 0.19189, 0, 1.05159], + "75": [0, 0.7, 0.31259, 0, 0.91364], + "76": [0, 0.7, 0.19189, 0, 0.87373], + "77": [0, 0.7, 0.15981, 0, 1.08031], + "78": [0, 0.7, 0.3525, 0, 0.9015], + "79": [0, 0.7, 0.08078, 0, 0.73787], + "80": [0, 0.7, 0.08078, 0, 1.01262], + "81": [0, 0.7, 0.03305, 0, 0.88282], + "82": [0, 0.7, 0.06259, 0, 0.85], + "83": [0, 0.7, 0.19189, 0, 0.86767], + "84": [0, 0.7, 0.29087, 0, 0.74697], + "85": [0, 0.7, 0.25815, 0, 0.79996], + "86": [0, 0.7, 0.27523, 0, 0.62204], + "87": [0, 0.7, 0.27523, 0, 0.80532], + "88": [0, 0.7, 0.26006, 0, 0.94445], + "89": [0, 0.7, 0.2939, 0, 0.70961], + "90": [0, 0.7, 0.24037, 0, 0.8212], + "160": [0, 0, 0, 0, 0.25] + }, + "Size1-Regular": { + "32": [0, 0, 0, 0, 0.25], + "40": [0.35001, 0.85, 0, 0, 0.45834], + "41": [0.35001, 0.85, 0, 0, 0.45834], + "47": [0.35001, 0.85, 0, 0, 0.57778], + "91": [0.35001, 0.85, 0, 0, 0.41667], + "92": [0.35001, 0.85, 0, 0, 0.57778], + "93": [0.35001, 0.85, 0, 0, 0.41667], + "123": [0.35001, 0.85, 0, 0, 0.58334], + "125": [0.35001, 0.85, 0, 0, 0.58334], + "160": [0, 0, 0, 0, 0.25], + "710": [0, 0.72222, 0, 0, 0.55556], + "732": [0, 0.72222, 0, 0, 0.55556], + "770": [0, 0.72222, 0, 0, 0.55556], + "771": [0, 0.72222, 0, 0, 0.55556], + "8214": [-0.00099, 0.601, 0, 0, 0.77778], + "8593": [1e-05, 0.6, 0, 0, 0.66667], + "8595": [1e-05, 0.6, 0, 0, 0.66667], + "8657": [1e-05, 0.6, 0, 0, 0.77778], + "8659": [1e-05, 0.6, 0, 0, 0.77778], + "8719": [0.25001, 0.75, 0, 0, 0.94445], + "8720": [0.25001, 0.75, 0, 0, 0.94445], + "8721": [0.25001, 0.75, 0, 0, 1.05556], + "8730": [0.35001, 0.85, 0, 0, 1.0], + "8739": [-0.00599, 0.606, 0, 0, 0.33333], + "8741": [-0.00599, 0.606, 0, 0, 0.55556], + "8747": [0.30612, 0.805, 0.19445, 0, 0.47222], + "8748": [0.306, 0.805, 0.19445, 0, 0.47222], + "8749": [0.306, 0.805, 0.19445, 0, 0.47222], + "8750": [0.30612, 0.805, 0.19445, 0, 0.47222], + "8896": [0.25001, 0.75, 0, 0, 0.83334], + "8897": [0.25001, 0.75, 0, 0, 0.83334], + "8898": [0.25001, 0.75, 0, 0, 0.83334], + "8899": [0.25001, 0.75, 0, 0, 0.83334], + "8968": [0.35001, 0.85, 0, 0, 0.47222], + "8969": [0.35001, 0.85, 0, 0, 0.47222], + "8970": [0.35001, 0.85, 0, 0, 0.47222], + "8971": [0.35001, 0.85, 0, 0, 0.47222], + "9168": [-0.00099, 0.601, 0, 0, 0.66667], + "10216": [0.35001, 0.85, 0, 0, 0.47222], + "10217": [0.35001, 0.85, 0, 0, 0.47222], + "10752": [0.25001, 0.75, 0, 0, 1.11111], + "10753": [0.25001, 0.75, 0, 0, 1.11111], + "10754": [0.25001, 0.75, 0, 0, 1.11111], + "10756": [0.25001, 0.75, 0, 0, 0.83334], + "10758": [0.25001, 0.75, 0, 0, 0.83334] + }, + "Size2-Regular": { + "32": [0, 0, 0, 0, 0.25], + "40": [0.65002, 1.15, 0, 0, 0.59722], + "41": [0.65002, 1.15, 0, 0, 0.59722], + "47": [0.65002, 1.15, 0, 0, 0.81111], + "91": [0.65002, 1.15, 0, 0, 0.47222], + "92": [0.65002, 1.15, 0, 0, 0.81111], + "93": [0.65002, 1.15, 0, 0, 0.47222], + "123": [0.65002, 1.15, 0, 0, 0.66667], + "125": [0.65002, 1.15, 0, 0, 0.66667], + "160": [0, 0, 0, 0, 0.25], + "710": [0, 0.75, 0, 0, 1.0], + "732": [0, 0.75, 0, 0, 1.0], + "770": [0, 0.75, 0, 0, 1.0], + "771": [0, 0.75, 0, 0, 1.0], + "8719": [0.55001, 1.05, 0, 0, 1.27778], + "8720": [0.55001, 1.05, 0, 0, 1.27778], + "8721": [0.55001, 1.05, 0, 0, 1.44445], + "8730": [0.65002, 1.15, 0, 0, 1.0], + "8747": [0.86225, 1.36, 0.44445, 0, 0.55556], + "8748": [0.862, 1.36, 0.44445, 0, 0.55556], + "8749": [0.862, 1.36, 0.44445, 0, 0.55556], + "8750": [0.86225, 1.36, 0.44445, 0, 0.55556], + "8896": [0.55001, 1.05, 0, 0, 1.11111], + "8897": [0.55001, 1.05, 0, 0, 1.11111], + "8898": [0.55001, 1.05, 0, 0, 1.11111], + "8899": [0.55001, 1.05, 0, 0, 1.11111], + "8968": [0.65002, 1.15, 0, 0, 0.52778], + "8969": [0.65002, 1.15, 0, 0, 0.52778], + "8970": [0.65002, 1.15, 0, 0, 0.52778], + "8971": [0.65002, 1.15, 0, 0, 0.52778], + "10216": [0.65002, 1.15, 0, 0, 0.61111], + "10217": [0.65002, 1.15, 0, 0, 0.61111], + "10752": [0.55001, 1.05, 0, 0, 1.51112], + "10753": [0.55001, 1.05, 0, 0, 1.51112], + "10754": [0.55001, 1.05, 0, 0, 1.51112], + "10756": [0.55001, 1.05, 0, 0, 1.11111], + "10758": [0.55001, 1.05, 0, 0, 1.11111] + }, + "Size3-Regular": { + "32": [0, 0, 0, 0, 0.25], + "40": [0.95003, 1.45, 0, 0, 0.73611], + "41": [0.95003, 1.45, 0, 0, 0.73611], + "47": [0.95003, 1.45, 0, 0, 1.04445], + "91": [0.95003, 1.45, 0, 0, 0.52778], + "92": [0.95003, 1.45, 0, 0, 1.04445], + "93": [0.95003, 1.45, 0, 0, 0.52778], + "123": [0.95003, 1.45, 0, 0, 0.75], + "125": [0.95003, 1.45, 0, 0, 0.75], + "160": [0, 0, 0, 0, 0.25], + "710": [0, 0.75, 0, 0, 1.44445], + "732": [0, 0.75, 0, 0, 1.44445], + "770": [0, 0.75, 0, 0, 1.44445], + "771": [0, 0.75, 0, 0, 1.44445], + "8730": [0.95003, 1.45, 0, 0, 1.0], + "8968": [0.95003, 1.45, 0, 0, 0.58334], + "8969": [0.95003, 1.45, 0, 0, 0.58334], + "8970": [0.95003, 1.45, 0, 0, 0.58334], + "8971": [0.95003, 1.45, 0, 0, 0.58334], + "10216": [0.95003, 1.45, 0, 0, 0.75], + "10217": [0.95003, 1.45, 0, 0, 0.75] + }, + "Size4-Regular": { + "32": [0, 0, 0, 0, 0.25], + "40": [1.25003, 1.75, 0, 0, 0.79167], + "41": [1.25003, 1.75, 0, 0, 0.79167], + "47": [1.25003, 1.75, 0, 0, 1.27778], + "91": [1.25003, 1.75, 0, 0, 0.58334], + "92": [1.25003, 1.75, 0, 0, 1.27778], + "93": [1.25003, 1.75, 0, 0, 0.58334], + "123": [1.25003, 1.75, 0, 0, 0.80556], + "125": [1.25003, 1.75, 0, 0, 0.80556], + "160": [0, 0, 0, 0, 0.25], + "710": [0, 0.825, 0, 0, 1.8889], + "732": [0, 0.825, 0, 0, 1.8889], + "770": [0, 0.825, 0, 0, 1.8889], + "771": [0, 0.825, 0, 0, 1.8889], + "8730": [1.25003, 1.75, 0, 0, 1.0], + "8968": [1.25003, 1.75, 0, 0, 0.63889], + "8969": [1.25003, 1.75, 0, 0, 0.63889], + "8970": [1.25003, 1.75, 0, 0, 0.63889], + "8971": [1.25003, 1.75, 0, 0, 0.63889], + "9115": [0.64502, 1.155, 0, 0, 0.875], + "9116": [1e-05, 0.6, 0, 0, 0.875], + "9117": [0.64502, 1.155, 0, 0, 0.875], + "9118": [0.64502, 1.155, 0, 0, 0.875], + "9119": [1e-05, 0.6, 0, 0, 0.875], + "9120": [0.64502, 1.155, 0, 0, 0.875], + "9121": [0.64502, 1.155, 0, 0, 0.66667], + "9122": [-0.00099, 0.601, 0, 0, 0.66667], + "9123": [0.64502, 1.155, 0, 0, 0.66667], + "9124": [0.64502, 1.155, 0, 0, 0.66667], + "9125": [-0.00099, 0.601, 0, 0, 0.66667], + "9126": [0.64502, 1.155, 0, 0, 0.66667], + "9127": [1e-05, 0.9, 0, 0, 0.88889], + "9128": [0.65002, 1.15, 0, 0, 0.88889], + "9129": [0.90001, 0, 0, 0, 0.88889], + "9130": [0, 0.3, 0, 0, 0.88889], + "9131": [1e-05, 0.9, 0, 0, 0.88889], + "9132": [0.65002, 1.15, 0, 0, 0.88889], + "9133": [0.90001, 0, 0, 0, 0.88889], + "9143": [0.88502, 0.915, 0, 0, 1.05556], + "10216": [1.25003, 1.75, 0, 0, 0.80556], + "10217": [1.25003, 1.75, 0, 0, 0.80556], + "57344": [-0.00499, 0.605, 0, 0, 1.05556], + "57345": [-0.00499, 0.605, 0, 0, 1.05556], + "57680": [0, 0.12, 0, 0, 0.45], + "57681": [0, 0.12, 0, 0, 0.45], + "57682": [0, 0.12, 0, 0, 0.45], + "57683": [0, 0.12, 0, 0, 0.45] + }, + "Typewriter-Regular": { + "32": [0, 0, 0, 0, 0.525], + "33": [0, 0.61111, 0, 0, 0.525], + "34": [0, 0.61111, 0, 0, 0.525], + "35": [0, 0.61111, 0, 0, 0.525], + "36": [0.08333, 0.69444, 0, 0, 0.525], + "37": [0.08333, 0.69444, 0, 0, 0.525], + "38": [0, 0.61111, 0, 0, 0.525], + "39": [0, 0.61111, 0, 0, 0.525], + "40": [0.08333, 0.69444, 0, 0, 0.525], + "41": [0.08333, 0.69444, 0, 0, 0.525], + "42": [0, 0.52083, 0, 0, 0.525], + "43": [-0.08056, 0.53055, 0, 0, 0.525], + "44": [0.13889, 0.125, 0, 0, 0.525], + "45": [-0.08056, 0.53055, 0, 0, 0.525], + "46": [0, 0.125, 0, 0, 0.525], + "47": [0.08333, 0.69444, 0, 0, 0.525], + "48": [0, 0.61111, 0, 0, 0.525], + "49": [0, 0.61111, 0, 0, 0.525], + "50": [0, 0.61111, 0, 0, 0.525], + "51": [0, 0.61111, 0, 0, 0.525], + "52": [0, 0.61111, 0, 0, 0.525], + "53": [0, 0.61111, 0, 0, 0.525], + "54": [0, 0.61111, 0, 0, 0.525], + "55": [0, 0.61111, 0, 0, 0.525], + "56": [0, 0.61111, 0, 0, 0.525], + "57": [0, 0.61111, 0, 0, 0.525], + "58": [0, 0.43056, 0, 0, 0.525], + "59": [0.13889, 0.43056, 0, 0, 0.525], + "60": [-0.05556, 0.55556, 0, 0, 0.525], + "61": [-0.19549, 0.41562, 0, 0, 0.525], + "62": [-0.05556, 0.55556, 0, 0, 0.525], + "63": [0, 0.61111, 0, 0, 0.525], + "64": [0, 0.61111, 0, 0, 0.525], + "65": [0, 0.61111, 0, 0, 0.525], + "66": [0, 0.61111, 0, 0, 0.525], + "67": [0, 0.61111, 0, 0, 0.525], + "68": [0, 0.61111, 0, 0, 0.525], + "69": [0, 0.61111, 0, 0, 0.525], + "70": [0, 0.61111, 0, 0, 0.525], + "71": [0, 0.61111, 0, 0, 0.525], + "72": [0, 0.61111, 0, 0, 0.525], + "73": [0, 0.61111, 0, 0, 0.525], + "74": [0, 0.61111, 0, 0, 0.525], + "75": [0, 0.61111, 0, 0, 0.525], + "76": [0, 0.61111, 0, 0, 0.525], + "77": [0, 0.61111, 0, 0, 0.525], + "78": [0, 0.61111, 0, 0, 0.525], + "79": [0, 0.61111, 0, 0, 0.525], + "80": [0, 0.61111, 0, 0, 0.525], + "81": [0.13889, 0.61111, 0, 0, 0.525], + "82": [0, 0.61111, 0, 0, 0.525], + "83": [0, 0.61111, 0, 0, 0.525], + "84": [0, 0.61111, 0, 0, 0.525], + "85": [0, 0.61111, 0, 0, 0.525], + "86": [0, 0.61111, 0, 0, 0.525], + "87": [0, 0.61111, 0, 0, 0.525], + "88": [0, 0.61111, 0, 0, 0.525], + "89": [0, 0.61111, 0, 0, 0.525], + "90": [0, 0.61111, 0, 0, 0.525], + "91": [0.08333, 0.69444, 0, 0, 0.525], + "92": [0.08333, 0.69444, 0, 0, 0.525], + "93": [0.08333, 0.69444, 0, 0, 0.525], + "94": [0, 0.61111, 0, 0, 0.525], + "95": [0.09514, 0, 0, 0, 0.525], + "96": [0, 0.61111, 0, 0, 0.525], + "97": [0, 0.43056, 0, 0, 0.525], + "98": [0, 0.61111, 0, 0, 0.525], + "99": [0, 0.43056, 0, 0, 0.525], + "100": [0, 0.61111, 0, 0, 0.525], + "101": [0, 0.43056, 0, 0, 0.525], + "102": [0, 0.61111, 0, 0, 0.525], + "103": [0.22222, 0.43056, 0, 0, 0.525], + "104": [0, 0.61111, 0, 0, 0.525], + "105": [0, 0.61111, 0, 0, 0.525], + "106": [0.22222, 0.61111, 0, 0, 0.525], + "107": [0, 0.61111, 0, 0, 0.525], + "108": [0, 0.61111, 0, 0, 0.525], + "109": [0, 0.43056, 0, 0, 0.525], + "110": [0, 0.43056, 0, 0, 0.525], + "111": [0, 0.43056, 0, 0, 0.525], + "112": [0.22222, 0.43056, 0, 0, 0.525], + "113": [0.22222, 0.43056, 0, 0, 0.525], + "114": [0, 0.43056, 0, 0, 0.525], + "115": [0, 0.43056, 0, 0, 0.525], + "116": [0, 0.55358, 0, 0, 0.525], + "117": [0, 0.43056, 0, 0, 0.525], + "118": [0, 0.43056, 0, 0, 0.525], + "119": [0, 0.43056, 0, 0, 0.525], + "120": [0, 0.43056, 0, 0, 0.525], + "121": [0.22222, 0.43056, 0, 0, 0.525], + "122": [0, 0.43056, 0, 0, 0.525], + "123": [0.08333, 0.69444, 0, 0, 0.525], + "124": [0.08333, 0.69444, 0, 0, 0.525], + "125": [0.08333, 0.69444, 0, 0, 0.525], + "126": [0, 0.61111, 0, 0, 0.525], + "127": [0, 0.61111, 0, 0, 0.525], + "160": [0, 0, 0, 0, 0.525], + "176": [0, 0.61111, 0, 0, 0.525], + "184": [0.19445, 0, 0, 0, 0.525], + "305": [0, 0.43056, 0, 0, 0.525], + "567": [0.22222, 0.43056, 0, 0, 0.525], + "711": [0, 0.56597, 0, 0, 0.525], + "713": [0, 0.56555, 0, 0, 0.525], + "714": [0, 0.61111, 0, 0, 0.525], + "715": [0, 0.61111, 0, 0, 0.525], + "728": [0, 0.61111, 0, 0, 0.525], + "730": [0, 0.61111, 0, 0, 0.525], + "770": [0, 0.61111, 0, 0, 0.525], + "771": [0, 0.61111, 0, 0, 0.525], + "776": [0, 0.61111, 0, 0, 0.525], + "915": [0, 0.61111, 0, 0, 0.525], + "916": [0, 0.61111, 0, 0, 0.525], + "920": [0, 0.61111, 0, 0, 0.525], + "923": [0, 0.61111, 0, 0, 0.525], + "926": [0, 0.61111, 0, 0, 0.525], + "928": [0, 0.61111, 0, 0, 0.525], + "931": [0, 0.61111, 0, 0, 0.525], + "933": [0, 0.61111, 0, 0, 0.525], + "934": [0, 0.61111, 0, 0, 0.525], + "936": [0, 0.61111, 0, 0, 0.525], + "937": [0, 0.61111, 0, 0, 0.525], + "8216": [0, 0.61111, 0, 0, 0.525], + "8217": [0, 0.61111, 0, 0, 0.525], + "8242": [0, 0.61111, 0, 0, 0.525], + "9251": [0.11111, 0.21944, 0, 0, 0.525] + } +}; + +/** + * This file contains metrics regarding fonts and individual symbols. The sigma + * and xi variables, as well as the metricMap map contain data extracted from + * TeX, TeX font metrics, and the TTF files. These data are then exposed via the + * `metrics` variable and the getCharacterMetrics function. + */ +// In TeX, there are actually three sets of dimensions, one for each of +// textstyle (size index 5 and higher: >=9pt), scriptstyle (size index 3 and 4: +// 7-8pt), and scriptscriptstyle (size index 1 and 2: 5-6pt). These are +// provided in the arrays below, in that order. +// +// The font metrics are stored in fonts cmsy10, cmsy7, and cmsy5 respectively. +// This was determined by running the following script: +// +// latex -interaction=nonstopmode \ +// '\documentclass{article}\usepackage{amsmath}\begin{document}' \ +// '$a$ \expandafter\show\the\textfont2' \ +// '\expandafter\show\the\scriptfont2' \ +// '\expandafter\show\the\scriptscriptfont2' \ +// '\stop' +// +// The metrics themselves were retrieved using the following commands: +// +// tftopl cmsy10 +// tftopl cmsy7 +// tftopl cmsy5 +// +// The output of each of these commands is quite lengthy. The only part we +// care about is the FONTDIMEN section. Each value is measured in EMs. +var sigmasAndXis = { + slant: [0.250, 0.250, 0.250], + // sigma1 + space: [0.000, 0.000, 0.000], + // sigma2 + stretch: [0.000, 0.000, 0.000], + // sigma3 + shrink: [0.000, 0.000, 0.000], + // sigma4 + xHeight: [0.431, 0.431, 0.431], + // sigma5 + quad: [1.000, 1.171, 1.472], + // sigma6 + extraSpace: [0.000, 0.000, 0.000], + // sigma7 + num1: [0.677, 0.732, 0.925], + // sigma8 + num2: [0.394, 0.384, 0.387], + // sigma9 + num3: [0.444, 0.471, 0.504], + // sigma10 + denom1: [0.686, 0.752, 1.025], + // sigma11 + denom2: [0.345, 0.344, 0.532], + // sigma12 + sup1: [0.413, 0.503, 0.504], + // sigma13 + sup2: [0.363, 0.431, 0.404], + // sigma14 + sup3: [0.289, 0.286, 0.294], + // sigma15 + sub1: [0.150, 0.143, 0.200], + // sigma16 + sub2: [0.247, 0.286, 0.400], + // sigma17 + supDrop: [0.386, 0.353, 0.494], + // sigma18 + subDrop: [0.050, 0.071, 0.100], + // sigma19 + delim1: [2.390, 1.700, 1.980], + // sigma20 + delim2: [1.010, 1.157, 1.420], + // sigma21 + axisHeight: [0.250, 0.250, 0.250], + // sigma22 + // These font metrics are extracted from TeX by using tftopl on cmex10.tfm; + // they correspond to the font parameters of the extension fonts (family 3). + // See the TeXbook, page 441. In AMSTeX, the extension fonts scale; to + // match cmex7, we'd use cmex7.tfm values for script and scriptscript + // values. + defaultRuleThickness: [0.04, 0.049, 0.049], + // xi8; cmex7: 0.049 + bigOpSpacing1: [0.111, 0.111, 0.111], + // xi9 + bigOpSpacing2: [0.166, 0.166, 0.166], + // xi10 + bigOpSpacing3: [0.2, 0.2, 0.2], + // xi11 + bigOpSpacing4: [0.6, 0.611, 0.611], + // xi12; cmex7: 0.611 + bigOpSpacing5: [0.1, 0.143, 0.143], + // xi13; cmex7: 0.143 + // The \sqrt rule width is taken from the height of the surd character. + // Since we use the same font at all sizes, this thickness doesn't scale. + sqrtRuleThickness: [0.04, 0.04, 0.04], + // This value determines how large a pt is, for metrics which are defined + // in terms of pts. + // This value is also used in katex.scss; if you change it make sure the + // values match. + ptPerEm: [10.0, 10.0, 10.0], + // The space between adjacent `|` columns in an array definition. From + // `\showthe\doublerulesep` in LaTeX. Equals 2.0 / ptPerEm. + doubleRuleSep: [0.2, 0.2, 0.2], + // The width of separator lines in {array} environments. From + // `\showthe\arrayrulewidth` in LaTeX. Equals 0.4 / ptPerEm. + arrayRuleWidth: [0.04, 0.04, 0.04], + // Two values from LaTeX source2e: + fboxsep: [0.3, 0.3, 0.3], + // 3 pt / ptPerEm + fboxrule: [0.04, 0.04, 0.04] // 0.4 pt / ptPerEm +}; +// These are very rough approximations. We default to Times New Roman which +// should have Latin-1 and Cyrillic characters, but may not depending on the +// operating system. The metrics do not account for extra height from the +// accents. In the case of Cyrillic characters which have both ascenders and +// descenders we prefer approximations with ascenders, primarily to prevent +// the fraction bar or root line from intersecting the glyph. +// TODO(kevinb) allow union of multiple glyph metrics for better accuracy. +var extraCharacterMap = { + // Latin-1 + 'Å': 'A', + 'Ð': 'D', + 'Þ': 'o', + 'å': 'a', + 'ð': 'd', + 'þ': 'o', + // Cyrillic + 'А': 'A', + 'Б': 'B', + 'В': 'B', + 'Г': 'F', + 'Д': 'A', + 'Е': 'E', + 'Ж': 'K', + 'З': '3', + 'И': 'N', + 'Й': 'N', + 'К': 'K', + 'Л': 'N', + 'М': 'M', + 'Н': 'H', + 'О': 'O', + 'П': 'N', + 'Р': 'P', + 'С': 'C', + 'Т': 'T', + 'У': 'y', + 'Ф': 'O', + 'Х': 'X', + 'Ц': 'U', + 'Ч': 'h', + 'Ш': 'W', + 'Щ': 'W', + 'Ъ': 'B', + 'Ы': 'X', + 'Ь': 'B', + 'Э': '3', + 'Ю': 'X', + 'Я': 'R', + 'а': 'a', + 'б': 'b', + 'в': 'a', + 'г': 'r', + 'д': 'y', + 'е': 'e', + 'ж': 'm', + 'з': 'e', + 'и': 'n', + 'й': 'n', + 'к': 'n', + 'л': 'n', + 'м': 'm', + 'н': 'n', + 'о': 'o', + 'п': 'n', + 'р': 'p', + 'с': 'c', + 'т': 'o', + 'у': 'y', + 'ф': 'b', + 'х': 'x', + 'ц': 'n', + 'ч': 'n', + 'ш': 'w', + 'щ': 'w', + 'ъ': 'a', + 'ы': 'm', + 'ь': 'a', + 'э': 'e', + 'ю': 'm', + 'я': 'r' +}; +/** + * This function adds new font metrics to default metricMap + * It can also override existing metrics + */ +function setFontMetrics(fontName, metrics) { + fontMetricsData[fontName] = metrics; +} +/** + * This function is a convenience function for looking up information in the + * metricMap table. It takes a character as a string, and a font. + * + * Note: the `width` property may be undefined if fontMetricsData.js wasn't + * built using `Make extended_metrics`. + */ +function getCharacterMetrics(character, font, mode) { + if (!fontMetricsData[font]) { + throw new Error("Font metrics not found for font: " + font + "."); + } + var ch = character.charCodeAt(0); + var metrics = fontMetricsData[font][ch]; + if (!metrics && character[0] in extraCharacterMap) { + ch = extraCharacterMap[character[0]].charCodeAt(0); + metrics = fontMetricsData[font][ch]; + } + if (!metrics && mode === 'text') { + // We don't typically have font metrics for Asian scripts. + // But since we support them in text mode, we need to return + // some sort of metrics. + // So if the character is in a script we support but we + // don't have metrics for it, just use the metrics for + // the Latin capital letter M. This is close enough because + // we (currently) only care about the height of the glyph + // not its width. + if (supportedCodepoint(ch)) { + metrics = fontMetricsData[font][77]; // 77 is the charcode for 'M' + } + } + if (metrics) { + return { + depth: metrics[0], + height: metrics[1], + italic: metrics[2], + skew: metrics[3], + width: metrics[4] + }; + } +} +var fontMetricsBySizeIndex = {}; +/** + * Get the font metrics for a given size. + */ +function getGlobalMetrics(size) { + var sizeIndex; + if (size >= 5) { + sizeIndex = 0; + } else if (size >= 3) { + sizeIndex = 1; + } else { + sizeIndex = 2; + } + if (!fontMetricsBySizeIndex[sizeIndex]) { + var metrics = fontMetricsBySizeIndex[sizeIndex] = { + cssEmPerMu: sigmasAndXis.quad[sizeIndex] / 18 + }; + for (var key in sigmasAndXis) { + if (sigmasAndXis.hasOwnProperty(key)) { + metrics[key] = sigmasAndXis[key][sizeIndex]; + } + } + } + return fontMetricsBySizeIndex[sizeIndex]; +} + +/** + * This file holds a list of all no-argument functions and single-character + * symbols (like 'a' or ';'). + * + * For each of the symbols, there are three properties they can have: + * - font (required): the font to be used for this symbol. Either "main" (the + normal font), or "ams" (the ams fonts). + * - group (required): the ParseNode group type the symbol should have (i.e. + "textord", "mathord", etc). + See https://github.com/KaTeX/KaTeX/wiki/Examining-TeX#group-types + * - replace: the character that this symbol or function should be + * replaced with (i.e. "\phi" has a replace value of "\u03d5", the phi + * character in the main font). + * + * The outermost map in the table indicates what mode the symbols should be + * accepted in (e.g. "math" or "text"). + */ +var symbols = { + "math": {}, + "text": {} +}; +/** `acceptUnicodeChar = true` is only applicable if `replace` is set. */ +function defineSymbol(mode, font, group, replace, name, acceptUnicodeChar) { + symbols[mode][name] = { + font, + group, + replace + }; + if (acceptUnicodeChar && replace) { + symbols[mode][replace] = symbols[mode][name]; + } +} +// Some abbreviations for commonly used strings. +// This helps minify the code, and also spotting typos using jshint. +// modes: +var math = "math"; +var text = "text"; +// fonts: +var main = "main"; +var ams = "ams"; +// groups: +var accent = "accent-token"; +var bin = "bin"; +var close = "close"; +var inner = "inner"; +var mathord = "mathord"; +var op = "op-token"; +var open = "open"; +var punct = "punct"; +var rel = "rel"; +var spacing = "spacing"; +var textord = "textord"; +// Now comes the symbol table +// Relation Symbols +defineSymbol(math, main, rel, "\u2261", "\\equiv", true); +defineSymbol(math, main, rel, "\u227a", "\\prec", true); +defineSymbol(math, main, rel, "\u227b", "\\succ", true); +defineSymbol(math, main, rel, "\u223c", "\\sim", true); +defineSymbol(math, main, rel, "\u22a5", "\\perp"); +defineSymbol(math, main, rel, "\u2aaf", "\\preceq", true); +defineSymbol(math, main, rel, "\u2ab0", "\\succeq", true); +defineSymbol(math, main, rel, "\u2243", "\\simeq", true); +defineSymbol(math, main, rel, "\u2223", "\\mid", true); +defineSymbol(math, main, rel, "\u226a", "\\ll", true); +defineSymbol(math, main, rel, "\u226b", "\\gg", true); +defineSymbol(math, main, rel, "\u224d", "\\asymp", true); +defineSymbol(math, main, rel, "\u2225", "\\parallel"); +defineSymbol(math, main, rel, "\u22c8", "\\bowtie", true); +defineSymbol(math, main, rel, "\u2323", "\\smile", true); +defineSymbol(math, main, rel, "\u2291", "\\sqsubseteq", true); +defineSymbol(math, main, rel, "\u2292", "\\sqsupseteq", true); +defineSymbol(math, main, rel, "\u2250", "\\doteq", true); +defineSymbol(math, main, rel, "\u2322", "\\frown", true); +defineSymbol(math, main, rel, "\u220b", "\\ni", true); +defineSymbol(math, main, rel, "\u221d", "\\propto", true); +defineSymbol(math, main, rel, "\u22a2", "\\vdash", true); +defineSymbol(math, main, rel, "\u22a3", "\\dashv", true); +defineSymbol(math, main, rel, "\u220b", "\\owns"); +// Punctuation +defineSymbol(math, main, punct, "\u002e", "\\ldotp"); +defineSymbol(math, main, punct, "\u22c5", "\\cdotp"); +// The KaTeX fonts do not contain U+00B7. Use the centered dot glyph at U+22C5 +// in both modes, but keep math-mode punctuation spacing only in math mode. +defineSymbol(math, main, punct, "\u22c5", "\u00b7"); +defineSymbol(text, main, textord, "\u22c5", "\u00b7"); +// Misc Symbols +defineSymbol(math, main, textord, "\u0023", "\\#"); +defineSymbol(text, main, textord, "\u0023", "\\#"); +defineSymbol(math, main, textord, "\u0026", "\\&"); +defineSymbol(text, main, textord, "\u0026", "\\&"); +defineSymbol(math, main, textord, "\u2135", "\\aleph", true); +defineSymbol(math, main, textord, "\u2200", "\\forall", true); +defineSymbol(math, main, textord, "\u210f", "\\hbar", true); +defineSymbol(math, main, textord, "\u2203", "\\exists", true); +defineSymbol(math, main, textord, "\u2207", "\\nabla", true); +defineSymbol(math, main, textord, "\u266d", "\\flat", true); +defineSymbol(math, main, textord, "\u2113", "\\ell", true); +defineSymbol(math, main, textord, "\u266e", "\\natural", true); +defineSymbol(math, main, textord, "\u2663", "\\clubsuit", true); +defineSymbol(math, main, textord, "\u2118", "\\wp", true); +defineSymbol(math, main, textord, "\u266f", "\\sharp", true); +defineSymbol(math, main, textord, "\u2662", "\\diamondsuit", true); +defineSymbol(math, main, textord, "\u211c", "\\Re", true); +defineSymbol(math, main, textord, "\u2661", "\\heartsuit", true); +defineSymbol(math, main, textord, "\u2111", "\\Im", true); +defineSymbol(math, main, textord, "\u2660", "\\spadesuit", true); +defineSymbol(math, main, textord, "\u00a7", "\\S", true); +defineSymbol(text, main, textord, "\u00a7", "\\S"); +defineSymbol(math, main, textord, "\u00b6", "\\P", true); +defineSymbol(text, main, textord, "\u00b6", "\\P"); +// Math and Text +defineSymbol(math, main, textord, "\u2020", "\\dag"); +defineSymbol(text, main, textord, "\u2020", "\\dag"); +defineSymbol(text, main, textord, "\u2020", "\\textdagger"); +defineSymbol(math, main, textord, "\u2021", "\\ddag"); +defineSymbol(text, main, textord, "\u2021", "\\ddag"); +defineSymbol(text, main, textord, "\u2021", "\\textdaggerdbl"); +// Large Delimiters +defineSymbol(math, main, close, "\u23b1", "\\rmoustache", true); +defineSymbol(math, main, open, "\u23b0", "\\lmoustache", true); +defineSymbol(math, main, close, "\u27ef", "\\rgroup", true); +defineSymbol(math, main, open, "\u27ee", "\\lgroup", true); +// Binary Operators +defineSymbol(math, main, bin, "\u2213", "\\mp", true); +defineSymbol(math, main, bin, "\u2296", "\\ominus", true); +defineSymbol(math, main, bin, "\u228e", "\\uplus", true); +defineSymbol(math, main, bin, "\u2293", "\\sqcap", true); +defineSymbol(math, main, bin, "\u2217", "\\ast"); +defineSymbol(math, main, bin, "\u2294", "\\sqcup", true); +defineSymbol(math, main, bin, "\u25ef", "\\bigcirc", true); +defineSymbol(math, main, bin, "\u2219", "\\bullet", true); +defineSymbol(math, main, bin, "\u2021", "\\ddagger"); +defineSymbol(math, main, bin, "\u2240", "\\wr", true); +defineSymbol(math, main, bin, "\u2a3f", "\\amalg"); +defineSymbol(math, main, bin, "\u0026", "\\And"); // from amsmath +// Arrow Symbols +defineSymbol(math, main, rel, "\u27f5", "\\longleftarrow", true); +defineSymbol(math, main, rel, "\u21d0", "\\Leftarrow", true); +defineSymbol(math, main, rel, "\u27f8", "\\Longleftarrow", true); +defineSymbol(math, main, rel, "\u27f6", "\\longrightarrow", true); +defineSymbol(math, main, rel, "\u21d2", "\\Rightarrow", true); +defineSymbol(math, main, rel, "\u27f9", "\\Longrightarrow", true); +defineSymbol(math, main, rel, "\u2194", "\\leftrightarrow", true); +defineSymbol(math, main, rel, "\u27f7", "\\longleftrightarrow", true); +defineSymbol(math, main, rel, "\u21d4", "\\Leftrightarrow", true); +defineSymbol(math, main, rel, "\u27fa", "\\Longleftrightarrow", true); +defineSymbol(math, main, rel, "\u21a6", "\\mapsto", true); +defineSymbol(math, main, rel, "\u27fc", "\\longmapsto", true); +defineSymbol(math, main, rel, "\u2197", "\\nearrow", true); +defineSymbol(math, main, rel, "\u21a9", "\\hookleftarrow", true); +defineSymbol(math, main, rel, "\u21aa", "\\hookrightarrow", true); +defineSymbol(math, main, rel, "\u2198", "\\searrow", true); +defineSymbol(math, main, rel, "\u21bc", "\\leftharpoonup", true); +defineSymbol(math, main, rel, "\u21c0", "\\rightharpoonup", true); +defineSymbol(math, main, rel, "\u2199", "\\swarrow", true); +defineSymbol(math, main, rel, "\u21bd", "\\leftharpoondown", true); +defineSymbol(math, main, rel, "\u21c1", "\\rightharpoondown", true); +defineSymbol(math, main, rel, "\u2196", "\\nwarrow", true); +defineSymbol(math, main, rel, "\u21cc", "\\rightleftharpoons", true); +// AMS Negated Binary Relations +defineSymbol(math, ams, rel, "\u226e", "\\nless", true); +// Symbol names preceded by "@" each have a corresponding macro. +defineSymbol(math, ams, rel, "\ue010", "\\@nleqslant"); +defineSymbol(math, ams, rel, "\ue011", "\\@nleqq"); +defineSymbol(math, ams, rel, "\u2a87", "\\lneq", true); +defineSymbol(math, ams, rel, "\u2268", "\\lneqq", true); +defineSymbol(math, ams, rel, "\ue00c", "\\@lvertneqq"); +defineSymbol(math, ams, rel, "\u22e6", "\\lnsim", true); +defineSymbol(math, ams, rel, "\u2a89", "\\lnapprox", true); +defineSymbol(math, ams, rel, "\u2280", "\\nprec", true); +// unicode-math maps \u22e0 to \npreccurlyeq. We'll use the AMS synonym. +defineSymbol(math, ams, rel, "\u22e0", "\\npreceq", true); +defineSymbol(math, ams, rel, "\u22e8", "\\precnsim", true); +defineSymbol(math, ams, rel, "\u2ab9", "\\precnapprox", true); +defineSymbol(math, ams, rel, "\u2241", "\\nsim", true); +defineSymbol(math, ams, rel, "\ue006", "\\@nshortmid"); +defineSymbol(math, ams, rel, "\u2224", "\\nmid", true); +defineSymbol(math, ams, rel, "\u22ac", "\\nvdash", true); +defineSymbol(math, ams, rel, "\u22ad", "\\nvDash", true); +defineSymbol(math, ams, rel, "\u22ea", "\\ntriangleleft"); +defineSymbol(math, ams, rel, "\u22ec", "\\ntrianglelefteq", true); +defineSymbol(math, ams, rel, "\u228a", "\\subsetneq", true); +defineSymbol(math, ams, rel, "\ue01a", "\\@varsubsetneq"); +defineSymbol(math, ams, rel, "\u2acb", "\\subsetneqq", true); +defineSymbol(math, ams, rel, "\ue017", "\\@varsubsetneqq"); +defineSymbol(math, ams, rel, "\u226f", "\\ngtr", true); +defineSymbol(math, ams, rel, "\ue00f", "\\@ngeqslant"); +defineSymbol(math, ams, rel, "\ue00e", "\\@ngeqq"); +defineSymbol(math, ams, rel, "\u2a88", "\\gneq", true); +defineSymbol(math, ams, rel, "\u2269", "\\gneqq", true); +defineSymbol(math, ams, rel, "\ue00d", "\\@gvertneqq"); +defineSymbol(math, ams, rel, "\u22e7", "\\gnsim", true); +defineSymbol(math, ams, rel, "\u2a8a", "\\gnapprox", true); +defineSymbol(math, ams, rel, "\u2281", "\\nsucc", true); +// unicode-math maps \u22e1 to \nsucccurlyeq. We'll use the AMS synonym. +defineSymbol(math, ams, rel, "\u22e1", "\\nsucceq", true); +defineSymbol(math, ams, rel, "\u22e9", "\\succnsim", true); +defineSymbol(math, ams, rel, "\u2aba", "\\succnapprox", true); +// unicode-math maps \u2246 to \simneqq. We'll use the AMS synonym. +defineSymbol(math, ams, rel, "\u2246", "\\ncong", true); +defineSymbol(math, ams, rel, "\ue007", "\\@nshortparallel"); +defineSymbol(math, ams, rel, "\u2226", "\\nparallel", true); +defineSymbol(math, ams, rel, "\u22af", "\\nVDash", true); +defineSymbol(math, ams, rel, "\u22eb", "\\ntriangleright"); +defineSymbol(math, ams, rel, "\u22ed", "\\ntrianglerighteq", true); +defineSymbol(math, ams, rel, "\ue018", "\\@nsupseteqq"); +defineSymbol(math, ams, rel, "\u228b", "\\supsetneq", true); +defineSymbol(math, ams, rel, "\ue01b", "\\@varsupsetneq"); +defineSymbol(math, ams, rel, "\u2acc", "\\supsetneqq", true); +defineSymbol(math, ams, rel, "\ue019", "\\@varsupsetneqq"); +defineSymbol(math, ams, rel, "\u22ae", "\\nVdash", true); +defineSymbol(math, ams, rel, "\u2ab5", "\\precneqq", true); +defineSymbol(math, ams, rel, "\u2ab6", "\\succneqq", true); +defineSymbol(math, ams, rel, "\ue016", "\\@nsubseteqq"); +defineSymbol(math, ams, bin, "\u22b4", "\\unlhd"); +defineSymbol(math, ams, bin, "\u22b5", "\\unrhd"); +// AMS Negated Arrows +defineSymbol(math, ams, rel, "\u219a", "\\nleftarrow", true); +defineSymbol(math, ams, rel, "\u219b", "\\nrightarrow", true); +defineSymbol(math, ams, rel, "\u21cd", "\\nLeftarrow", true); +defineSymbol(math, ams, rel, "\u21cf", "\\nRightarrow", true); +defineSymbol(math, ams, rel, "\u21ae", "\\nleftrightarrow", true); +defineSymbol(math, ams, rel, "\u21ce", "\\nLeftrightarrow", true); +// AMS Misc +defineSymbol(math, ams, rel, "\u25b3", "\\vartriangle"); +defineSymbol(math, ams, textord, "\u210f", "\\hslash"); +defineSymbol(math, ams, textord, "\u25bd", "\\triangledown"); +defineSymbol(math, ams, textord, "\u25ca", "\\lozenge"); +defineSymbol(math, ams, textord, "\u24c8", "\\circledS"); +defineSymbol(math, ams, textord, "\u00ae", "\\circledR"); +defineSymbol(text, ams, textord, "\u00ae", "\\circledR"); +defineSymbol(math, ams, textord, "\u2221", "\\measuredangle", true); +defineSymbol(math, ams, textord, "\u2204", "\\nexists"); +defineSymbol(math, ams, textord, "\u2127", "\\mho"); +defineSymbol(math, ams, textord, "\u2132", "\\Finv", true); +defineSymbol(math, ams, textord, "\u2141", "\\Game", true); +defineSymbol(math, ams, textord, "\u2035", "\\backprime"); +defineSymbol(math, ams, textord, "\u25b2", "\\blacktriangle"); +defineSymbol(math, ams, textord, "\u25bc", "\\blacktriangledown"); +defineSymbol(math, ams, textord, "\u25a0", "\\blacksquare"); +defineSymbol(math, ams, textord, "\u29eb", "\\blacklozenge"); +defineSymbol(math, ams, textord, "\u2605", "\\bigstar"); +defineSymbol(math, ams, textord, "\u2222", "\\sphericalangle", true); +defineSymbol(math, ams, textord, "\u2201", "\\complement", true); +// unicode-math maps U+F0 to \matheth. We map to AMS function \eth +defineSymbol(math, ams, textord, "\u00f0", "\\eth", true); +defineSymbol(text, main, textord, "\u00f0", "\u00f0"); +defineSymbol(math, ams, textord, "\u2571", "\\diagup"); +defineSymbol(math, ams, textord, "\u2572", "\\diagdown"); +defineSymbol(math, ams, textord, "\u25a1", "\\square"); +defineSymbol(math, ams, textord, "\u25a1", "\\Box"); +defineSymbol(math, ams, textord, "\u25ca", "\\Diamond"); +// unicode-math maps U+A5 to \mathyen. We map to AMS function \yen +defineSymbol(math, ams, textord, "\u00a5", "\\yen", true); +defineSymbol(text, ams, textord, "\u00a5", "\\yen", true); +defineSymbol(math, ams, textord, "\u2713", "\\checkmark", true); +defineSymbol(text, ams, textord, "\u2713", "\\checkmark"); +// AMS Hebrew +defineSymbol(math, ams, textord, "\u2136", "\\beth", true); +defineSymbol(math, ams, textord, "\u2138", "\\daleth", true); +defineSymbol(math, ams, textord, "\u2137", "\\gimel", true); +// AMS Greek +defineSymbol(math, ams, textord, "\u03dd", "\\digamma", true); +defineSymbol(math, ams, textord, "\u03f0", "\\varkappa"); +// AMS Delimiters +defineSymbol(math, ams, open, "\u250c", "\\@ulcorner", true); +defineSymbol(math, ams, close, "\u2510", "\\@urcorner", true); +defineSymbol(math, ams, open, "\u2514", "\\@llcorner", true); +defineSymbol(math, ams, close, "\u2518", "\\@lrcorner", true); +// AMS Binary Relations +defineSymbol(math, ams, rel, "\u2266", "\\leqq", true); +defineSymbol(math, ams, rel, "\u2a7d", "\\leqslant", true); +defineSymbol(math, ams, rel, "\u2a95", "\\eqslantless", true); +defineSymbol(math, ams, rel, "\u2272", "\\lesssim", true); +defineSymbol(math, ams, rel, "\u2a85", "\\lessapprox", true); +defineSymbol(math, ams, rel, "\u224a", "\\approxeq", true); +defineSymbol(math, ams, bin, "\u22d6", "\\lessdot"); +defineSymbol(math, ams, rel, "\u22d8", "\\lll", true); +defineSymbol(math, ams, rel, "\u2276", "\\lessgtr", true); +defineSymbol(math, ams, rel, "\u22da", "\\lesseqgtr", true); +defineSymbol(math, ams, rel, "\u2a8b", "\\lesseqqgtr", true); +defineSymbol(math, ams, rel, "\u2251", "\\doteqdot"); +defineSymbol(math, ams, rel, "\u2253", "\\risingdotseq", true); +defineSymbol(math, ams, rel, "\u2252", "\\fallingdotseq", true); +defineSymbol(math, ams, rel, "\u223d", "\\backsim", true); +defineSymbol(math, ams, rel, "\u22cd", "\\backsimeq", true); +defineSymbol(math, ams, rel, "\u2ac5", "\\subseteqq", true); +defineSymbol(math, ams, rel, "\u22d0", "\\Subset", true); +defineSymbol(math, ams, rel, "\u228f", "\\sqsubset", true); +defineSymbol(math, ams, rel, "\u227c", "\\preccurlyeq", true); +defineSymbol(math, ams, rel, "\u22de", "\\curlyeqprec", true); +defineSymbol(math, ams, rel, "\u227e", "\\precsim", true); +defineSymbol(math, ams, rel, "\u2ab7", "\\precapprox", true); +defineSymbol(math, ams, rel, "\u22b2", "\\vartriangleleft"); +defineSymbol(math, ams, rel, "\u22b4", "\\trianglelefteq"); +defineSymbol(math, ams, rel, "\u22a8", "\\vDash", true); +defineSymbol(math, ams, rel, "\u22aa", "\\Vvdash", true); +defineSymbol(math, ams, rel, "\u2323", "\\smallsmile"); +defineSymbol(math, ams, rel, "\u2322", "\\smallfrown"); +defineSymbol(math, ams, rel, "\u224f", "\\bumpeq", true); +defineSymbol(math, ams, rel, "\u224e", "\\Bumpeq", true); +defineSymbol(math, ams, rel, "\u2267", "\\geqq", true); +defineSymbol(math, ams, rel, "\u2a7e", "\\geqslant", true); +defineSymbol(math, ams, rel, "\u2a96", "\\eqslantgtr", true); +defineSymbol(math, ams, rel, "\u2273", "\\gtrsim", true); +defineSymbol(math, ams, rel, "\u2a86", "\\gtrapprox", true); +defineSymbol(math, ams, bin, "\u22d7", "\\gtrdot"); +defineSymbol(math, ams, rel, "\u22d9", "\\ggg", true); +defineSymbol(math, ams, rel, "\u2277", "\\gtrless", true); +defineSymbol(math, ams, rel, "\u22db", "\\gtreqless", true); +defineSymbol(math, ams, rel, "\u2a8c", "\\gtreqqless", true); +defineSymbol(math, ams, rel, "\u2256", "\\eqcirc", true); +defineSymbol(math, ams, rel, "\u2257", "\\circeq", true); +defineSymbol(math, ams, rel, "\u225c", "\\triangleq", true); +defineSymbol(math, ams, rel, "\u223c", "\\thicksim"); +defineSymbol(math, ams, rel, "\u2248", "\\thickapprox"); +defineSymbol(math, ams, rel, "\u2ac6", "\\supseteqq", true); +defineSymbol(math, ams, rel, "\u22d1", "\\Supset", true); +defineSymbol(math, ams, rel, "\u2290", "\\sqsupset", true); +defineSymbol(math, ams, rel, "\u227d", "\\succcurlyeq", true); +defineSymbol(math, ams, rel, "\u22df", "\\curlyeqsucc", true); +defineSymbol(math, ams, rel, "\u227f", "\\succsim", true); +defineSymbol(math, ams, rel, "\u2ab8", "\\succapprox", true); +defineSymbol(math, ams, rel, "\u22b3", "\\vartriangleright"); +defineSymbol(math, ams, rel, "\u22b5", "\\trianglerighteq"); +defineSymbol(math, ams, rel, "\u22a9", "\\Vdash", true); +defineSymbol(math, ams, rel, "\u2223", "\\shortmid"); +defineSymbol(math, ams, rel, "\u2225", "\\shortparallel"); +defineSymbol(math, ams, rel, "\u226c", "\\between", true); +defineSymbol(math, ams, rel, "\u22d4", "\\pitchfork", true); +defineSymbol(math, ams, rel, "\u221d", "\\varpropto"); +defineSymbol(math, ams, rel, "\u25c0", "\\blacktriangleleft"); +// unicode-math says that \therefore is a mathord atom. +// We kept the amssymb atom type, which is rel. +defineSymbol(math, ams, rel, "\u2234", "\\therefore", true); +defineSymbol(math, ams, rel, "\u220d", "\\backepsilon"); +defineSymbol(math, ams, rel, "\u25b6", "\\blacktriangleright"); +// unicode-math says that \because is a mathord atom. +// We kept the amssymb atom type, which is rel. +defineSymbol(math, ams, rel, "\u2235", "\\because", true); +defineSymbol(math, ams, rel, "\u22d8", "\\llless"); +defineSymbol(math, ams, rel, "\u22d9", "\\gggtr"); +defineSymbol(math, ams, bin, "\u22b2", "\\lhd"); +defineSymbol(math, ams, bin, "\u22b3", "\\rhd"); +defineSymbol(math, ams, rel, "\u2242", "\\eqsim", true); +defineSymbol(math, main, rel, "\u22c8", "\\Join"); +defineSymbol(math, ams, rel, "\u2251", "\\Doteq", true); +// AMS Binary Operators +defineSymbol(math, ams, bin, "\u2214", "\\dotplus", true); +defineSymbol(math, ams, bin, "\u2216", "\\smallsetminus"); +defineSymbol(math, ams, bin, "\u22d2", "\\Cap", true); +defineSymbol(math, ams, bin, "\u22d3", "\\Cup", true); +defineSymbol(math, ams, bin, "\u2a5e", "\\doublebarwedge", true); +defineSymbol(math, ams, bin, "\u229f", "\\boxminus", true); +defineSymbol(math, ams, bin, "\u229e", "\\boxplus", true); +defineSymbol(math, ams, bin, "\u22c7", "\\divideontimes", true); +defineSymbol(math, ams, bin, "\u22c9", "\\ltimes", true); +defineSymbol(math, ams, bin, "\u22ca", "\\rtimes", true); +defineSymbol(math, ams, bin, "\u22cb", "\\leftthreetimes", true); +defineSymbol(math, ams, bin, "\u22cc", "\\rightthreetimes", true); +defineSymbol(math, ams, bin, "\u22cf", "\\curlywedge", true); +defineSymbol(math, ams, bin, "\u22ce", "\\curlyvee", true); +defineSymbol(math, ams, bin, "\u229d", "\\circleddash", true); +defineSymbol(math, ams, bin, "\u229b", "\\circledast", true); +defineSymbol(math, ams, bin, "\u22c5", "\\centerdot"); +defineSymbol(math, ams, bin, "\u22ba", "\\intercal", true); +defineSymbol(math, ams, bin, "\u22d2", "\\doublecap"); +defineSymbol(math, ams, bin, "\u22d3", "\\doublecup"); +defineSymbol(math, ams, bin, "\u22a0", "\\boxtimes", true); +// AMS Arrows +// Note: unicode-math maps \u21e2 to their own function \rightdasharrow. +// We'll map it to AMS function \dashrightarrow. It produces the same atom. +defineSymbol(math, ams, rel, "\u21e2", "\\dashrightarrow", true); +// unicode-math maps \u21e0 to \leftdasharrow. We'll use the AMS synonym. +defineSymbol(math, ams, rel, "\u21e0", "\\dashleftarrow", true); +defineSymbol(math, ams, rel, "\u21c7", "\\leftleftarrows", true); +defineSymbol(math, ams, rel, "\u21c6", "\\leftrightarrows", true); +defineSymbol(math, ams, rel, "\u21da", "\\Lleftarrow", true); +defineSymbol(math, ams, rel, "\u219e", "\\twoheadleftarrow", true); +defineSymbol(math, ams, rel, "\u21a2", "\\leftarrowtail", true); +defineSymbol(math, ams, rel, "\u21ab", "\\looparrowleft", true); +defineSymbol(math, ams, rel, "\u21cb", "\\leftrightharpoons", true); +defineSymbol(math, ams, rel, "\u21b6", "\\curvearrowleft", true); +// unicode-math maps \u21ba to \acwopencirclearrow. We'll use the AMS synonym. +defineSymbol(math, ams, rel, "\u21ba", "\\circlearrowleft", true); +defineSymbol(math, ams, rel, "\u21b0", "\\Lsh", true); +defineSymbol(math, ams, rel, "\u21c8", "\\upuparrows", true); +defineSymbol(math, ams, rel, "\u21bf", "\\upharpoonleft", true); +defineSymbol(math, ams, rel, "\u21c3", "\\downharpoonleft", true); +defineSymbol(math, main, rel, "\u22b6", "\\origof", true); // not in font +defineSymbol(math, main, rel, "\u22b7", "\\imageof", true); // not in font +defineSymbol(math, ams, rel, "\u22b8", "\\multimap", true); +defineSymbol(math, ams, rel, "\u21ad", "\\leftrightsquigarrow", true); +defineSymbol(math, ams, rel, "\u21c9", "\\rightrightarrows", true); +defineSymbol(math, ams, rel, "\u21c4", "\\rightleftarrows", true); +defineSymbol(math, ams, rel, "\u21a0", "\\twoheadrightarrow", true); +defineSymbol(math, ams, rel, "\u21a3", "\\rightarrowtail", true); +defineSymbol(math, ams, rel, "\u21ac", "\\looparrowright", true); +defineSymbol(math, ams, rel, "\u21b7", "\\curvearrowright", true); +// unicode-math maps \u21bb to \cwopencirclearrow. We'll use the AMS synonym. +defineSymbol(math, ams, rel, "\u21bb", "\\circlearrowright", true); +defineSymbol(math, ams, rel, "\u21b1", "\\Rsh", true); +defineSymbol(math, ams, rel, "\u21ca", "\\downdownarrows", true); +defineSymbol(math, ams, rel, "\u21be", "\\upharpoonright", true); +defineSymbol(math, ams, rel, "\u21c2", "\\downharpoonright", true); +defineSymbol(math, ams, rel, "\u21dd", "\\rightsquigarrow", true); +defineSymbol(math, ams, rel, "\u21dd", "\\leadsto"); +defineSymbol(math, ams, rel, "\u21db", "\\Rrightarrow", true); +defineSymbol(math, ams, rel, "\u21be", "\\restriction"); +defineSymbol(math, main, textord, "\u2018", "`"); +defineSymbol(math, main, textord, "$", "\\$"); +defineSymbol(text, main, textord, "$", "\\$"); +defineSymbol(text, main, textord, "$", "\\textdollar"); +defineSymbol(math, main, textord, "%", "\\%"); +defineSymbol(text, main, textord, "%", "\\%"); +defineSymbol(math, main, textord, "_", "\\_"); +defineSymbol(text, main, textord, "_", "\\_"); +defineSymbol(text, main, textord, "_", "\\textunderscore"); +defineSymbol(math, main, textord, "\u2220", "\\angle", true); +defineSymbol(math, main, textord, "\u221e", "\\infty", true); +defineSymbol(math, main, textord, "\u2032", "\\prime"); +defineSymbol(math, main, textord, "\u25b3", "\\triangle"); +defineSymbol(math, main, textord, "\u0393", "\\Gamma", true); +defineSymbol(math, main, textord, "\u0394", "\\Delta", true); +defineSymbol(math, main, textord, "\u0398", "\\Theta", true); +defineSymbol(math, main, textord, "\u039b", "\\Lambda", true); +defineSymbol(math, main, textord, "\u039e", "\\Xi", true); +defineSymbol(math, main, textord, "\u03a0", "\\Pi", true); +defineSymbol(math, main, textord, "\u03a3", "\\Sigma", true); +defineSymbol(math, main, textord, "\u03a5", "\\Upsilon", true); +defineSymbol(math, main, textord, "\u03a6", "\\Phi", true); +defineSymbol(math, main, textord, "\u03a8", "\\Psi", true); +defineSymbol(math, main, textord, "\u03a9", "\\Omega", true); +defineSymbol(math, main, textord, "A", "\u0391"); +defineSymbol(math, main, textord, "B", "\u0392"); +defineSymbol(math, main, textord, "E", "\u0395"); +defineSymbol(math, main, textord, "Z", "\u0396"); +defineSymbol(math, main, textord, "H", "\u0397"); +defineSymbol(math, main, textord, "I", "\u0399"); +defineSymbol(math, main, textord, "K", "\u039A"); +defineSymbol(math, main, textord, "M", "\u039C"); +defineSymbol(math, main, textord, "N", "\u039D"); +defineSymbol(math, main, textord, "O", "\u039F"); +defineSymbol(math, main, textord, "P", "\u03A1"); +defineSymbol(math, main, textord, "T", "\u03A4"); +defineSymbol(math, main, textord, "X", "\u03A7"); +defineSymbol(math, main, textord, "\u00ac", "\\neg", true); +defineSymbol(math, main, textord, "\u00ac", "\\lnot"); +defineSymbol(math, main, textord, "\u22a4", "\\top"); +defineSymbol(math, main, textord, "\u22a5", "\\bot"); +defineSymbol(math, main, textord, "\u2205", "\\emptyset"); +defineSymbol(math, ams, textord, "\u2205", "\\varnothing"); +defineSymbol(math, main, mathord, "\u03b1", "\\alpha", true); +defineSymbol(math, main, mathord, "\u03b2", "\\beta", true); +defineSymbol(math, main, mathord, "\u03b3", "\\gamma", true); +defineSymbol(math, main, mathord, "\u03b4", "\\delta", true); +defineSymbol(math, main, mathord, "\u03f5", "\\epsilon", true); +defineSymbol(math, main, mathord, "\u03b6", "\\zeta", true); +defineSymbol(math, main, mathord, "\u03b7", "\\eta", true); +defineSymbol(math, main, mathord, "\u03b8", "\\theta", true); +defineSymbol(math, main, mathord, "\u03b9", "\\iota", true); +defineSymbol(math, main, mathord, "\u03ba", "\\kappa", true); +defineSymbol(math, main, mathord, "\u03bb", "\\lambda", true); +defineSymbol(math, main, mathord, "\u03bc", "\\mu", true); +defineSymbol(math, main, mathord, "\u03bd", "\\nu", true); +defineSymbol(math, main, mathord, "\u03be", "\\xi", true); +defineSymbol(math, main, mathord, "\u03bf", "\\omicron", true); +defineSymbol(math, main, mathord, "\u03c0", "\\pi", true); +defineSymbol(math, main, mathord, "\u03c1", "\\rho", true); +defineSymbol(math, main, mathord, "\u03c3", "\\sigma", true); +defineSymbol(math, main, mathord, "\u03c4", "\\tau", true); +defineSymbol(math, main, mathord, "\u03c5", "\\upsilon", true); +defineSymbol(math, main, mathord, "\u03d5", "\\phi", true); +defineSymbol(math, main, mathord, "\u03c7", "\\chi", true); +defineSymbol(math, main, mathord, "\u03c8", "\\psi", true); +defineSymbol(math, main, mathord, "\u03c9", "\\omega", true); +defineSymbol(math, main, mathord, "\u03b5", "\\varepsilon", true); +defineSymbol(math, main, mathord, "\u03d1", "\\vartheta", true); +defineSymbol(math, main, mathord, "\u03d6", "\\varpi", true); +defineSymbol(math, main, mathord, "\u03f1", "\\varrho", true); +defineSymbol(math, main, mathord, "\u03c2", "\\varsigma", true); +defineSymbol(math, main, mathord, "\u03c6", "\\varphi", true); +defineSymbol(math, main, bin, "\u2217", "*", true); +defineSymbol(math, main, bin, "+", "+"); +defineSymbol(math, main, bin, "\u2212", "-", true); +defineSymbol(math, main, bin, "\u22c5", "\\cdot", true); +defineSymbol(math, main, bin, "\u2218", "\\circ", true); +defineSymbol(math, main, bin, "\u00f7", "\\div", true); +defineSymbol(math, main, bin, "\u00b1", "\\pm", true); +defineSymbol(math, main, bin, "\u00d7", "\\times", true); +defineSymbol(math, main, bin, "\u2229", "\\cap", true); +defineSymbol(math, main, bin, "\u222a", "\\cup", true); +defineSymbol(math, main, bin, "\u2216", "\\setminus", true); +defineSymbol(math, main, bin, "\u2227", "\\land"); +defineSymbol(math, main, bin, "\u2228", "\\lor"); +defineSymbol(math, main, bin, "\u2227", "\\wedge", true); +defineSymbol(math, main, bin, "\u2228", "\\vee", true); +defineSymbol(math, main, textord, "\u221a", "\\surd"); +defineSymbol(math, main, open, "\u27e8", "\\langle", true); +defineSymbol(math, main, open, "\u2223", "\\lvert"); +defineSymbol(math, main, open, "\u2225", "\\lVert"); +defineSymbol(math, main, close, "?", "?"); +defineSymbol(math, main, close, "!", "!"); +defineSymbol(math, main, close, "\u27e9", "\\rangle", true); +defineSymbol(math, main, close, "\u2223", "\\rvert"); +defineSymbol(math, main, close, "\u2225", "\\rVert"); +defineSymbol(math, main, rel, "=", "="); +defineSymbol(math, main, rel, ":", ":"); +defineSymbol(math, main, rel, "\u2248", "\\approx", true); +defineSymbol(math, main, rel, "\u2245", "\\cong", true); +defineSymbol(math, main, rel, "\u2265", "\\ge"); +defineSymbol(math, main, rel, "\u2265", "\\geq", true); +defineSymbol(math, main, rel, "\u2190", "\\gets"); +defineSymbol(math, main, rel, ">", "\\gt", true); +defineSymbol(math, main, rel, "\u2208", "\\in", true); +defineSymbol(math, main, rel, "\ue020", "\\@not"); +defineSymbol(math, main, rel, "\u2282", "\\subset", true); +defineSymbol(math, main, rel, "\u2283", "\\supset", true); +defineSymbol(math, main, rel, "\u2286", "\\subseteq", true); +defineSymbol(math, main, rel, "\u2287", "\\supseteq", true); +defineSymbol(math, ams, rel, "\u2288", "\\nsubseteq", true); +defineSymbol(math, ams, rel, "\u2289", "\\nsupseteq", true); +defineSymbol(math, main, rel, "\u22a8", "\\models"); +defineSymbol(math, main, rel, "\u2190", "\\leftarrow", true); +defineSymbol(math, main, rel, "\u2264", "\\le"); +defineSymbol(math, main, rel, "\u2264", "\\leq", true); +defineSymbol(math, main, rel, "<", "\\lt", true); +defineSymbol(math, main, rel, "\u2192", "\\rightarrow", true); +defineSymbol(math, main, rel, "\u2192", "\\to"); +defineSymbol(math, ams, rel, "\u2271", "\\ngeq", true); +defineSymbol(math, ams, rel, "\u2270", "\\nleq", true); +defineSymbol(math, main, spacing, "\u00a0", "\\ "); +defineSymbol(math, main, spacing, "\u00a0", "\\space"); +// Ref: LaTeX Source 2e: \DeclareRobustCommand{\nobreakspace}{% +defineSymbol(math, main, spacing, "\u00a0", "\\nobreakspace"); +defineSymbol(text, main, spacing, "\u00a0", "\\ "); +defineSymbol(text, main, spacing, "\u00a0", " "); +defineSymbol(text, main, spacing, "\u00a0", "\\space"); +defineSymbol(text, main, spacing, "\u00a0", "\\nobreakspace"); +defineSymbol(math, main, spacing, "", "\\nobreak"); +defineSymbol(math, main, spacing, "", "\\allowbreak"); +defineSymbol(math, main, punct, ",", ","); +defineSymbol(math, main, punct, ";", ";"); +defineSymbol(math, ams, bin, "\u22bc", "\\barwedge", true); +defineSymbol(math, ams, bin, "\u22bb", "\\veebar", true); +defineSymbol(math, main, bin, "\u2299", "\\odot", true); +defineSymbol(math, main, bin, "\u2295", "\\oplus", true); +defineSymbol(math, main, bin, "\u2297", "\\otimes", true); +defineSymbol(math, main, textord, "\u2202", "\\partial", true); +defineSymbol(math, main, bin, "\u2298", "\\oslash", true); +defineSymbol(math, ams, bin, "\u229a", "\\circledcirc", true); +defineSymbol(math, ams, bin, "\u22a1", "\\boxdot", true); +defineSymbol(math, main, bin, "\u25b3", "\\bigtriangleup"); +defineSymbol(math, main, bin, "\u25bd", "\\bigtriangledown"); +defineSymbol(math, main, bin, "\u2020", "\\dagger"); +defineSymbol(math, main, bin, "\u22c4", "\\diamond"); +defineSymbol(math, main, bin, "\u22c6", "\\star"); +defineSymbol(math, main, bin, "\u25c3", "\\triangleleft"); +defineSymbol(math, main, bin, "\u25b9", "\\triangleright"); +defineSymbol(math, main, open, "{", "\\{"); +defineSymbol(text, main, textord, "{", "\\{"); +defineSymbol(text, main, textord, "{", "\\textbraceleft"); +defineSymbol(math, main, close, "}", "\\}"); +defineSymbol(text, main, textord, "}", "\\}"); +defineSymbol(text, main, textord, "}", "\\textbraceright"); +defineSymbol(math, main, open, "{", "\\lbrace"); +defineSymbol(math, main, close, "}", "\\rbrace"); +defineSymbol(math, main, open, "[", "\\lbrack", true); +defineSymbol(text, main, textord, "[", "\\lbrack", true); +defineSymbol(math, main, close, "]", "\\rbrack", true); +defineSymbol(text, main, textord, "]", "\\rbrack", true); +defineSymbol(math, main, open, "(", "\\lparen", true); +defineSymbol(math, main, close, ")", "\\rparen", true); +defineSymbol(text, main, textord, "<", "\\textless", true); // in T1 fontenc +defineSymbol(text, main, textord, ">", "\\textgreater", true); // in T1 fontenc +defineSymbol(math, main, open, "\u230a", "\\lfloor", true); +defineSymbol(math, main, close, "\u230b", "\\rfloor", true); +defineSymbol(math, main, open, "\u2308", "\\lceil", true); +defineSymbol(math, main, close, "\u2309", "\\rceil", true); +defineSymbol(math, main, textord, "\\", "\\backslash"); +defineSymbol(math, main, textord, "\u2223", "|"); +defineSymbol(math, main, textord, "\u2223", "\\vert"); +defineSymbol(text, main, textord, "|", "\\textbar", true); // in T1 fontenc +defineSymbol(math, main, textord, "\u2225", "\\|"); +defineSymbol(math, main, textord, "\u2225", "\\Vert"); +defineSymbol(text, main, textord, "\u2225", "\\textbardbl"); +defineSymbol(text, main, textord, "~", "\\textasciitilde"); +defineSymbol(text, main, textord, "\\", "\\textbackslash"); +defineSymbol(text, main, textord, "^", "\\textasciicircum"); +defineSymbol(math, main, rel, "\u2191", "\\uparrow", true); +defineSymbol(math, main, rel, "\u21d1", "\\Uparrow", true); +defineSymbol(math, main, rel, "\u2193", "\\downarrow", true); +defineSymbol(math, main, rel, "\u21d3", "\\Downarrow", true); +defineSymbol(math, main, rel, "\u2195", "\\updownarrow", true); +defineSymbol(math, main, rel, "\u21d5", "\\Updownarrow", true); +defineSymbol(math, main, op, "\u2210", "\\coprod"); +defineSymbol(math, main, op, "\u22c1", "\\bigvee"); +defineSymbol(math, main, op, "\u22c0", "\\bigwedge"); +defineSymbol(math, main, op, "\u2a04", "\\biguplus"); +defineSymbol(math, main, op, "\u22c2", "\\bigcap"); +defineSymbol(math, main, op, "\u22c3", "\\bigcup"); +defineSymbol(math, main, op, "\u222b", "\\int"); +defineSymbol(math, main, op, "\u222b", "\\intop"); +defineSymbol(math, main, op, "\u222c", "\\iint"); +defineSymbol(math, main, op, "\u222d", "\\iiint"); +defineSymbol(math, main, op, "\u220f", "\\prod"); +defineSymbol(math, main, op, "\u2211", "\\sum"); +defineSymbol(math, main, op, "\u2a02", "\\bigotimes"); +defineSymbol(math, main, op, "\u2a01", "\\bigoplus"); +defineSymbol(math, main, op, "\u2a00", "\\bigodot"); +defineSymbol(math, main, op, "\u222e", "\\oint"); +defineSymbol(math, main, op, "\u222f", "\\oiint"); +defineSymbol(math, main, op, "\u2230", "\\oiiint"); +defineSymbol(math, main, op, "\u2a06", "\\bigsqcup"); +defineSymbol(math, main, op, "\u222b", "\\smallint"); +defineSymbol(text, main, inner, "\u2026", "\\textellipsis"); +defineSymbol(math, main, inner, "\u2026", "\\mathellipsis"); +defineSymbol(text, main, inner, "\u2026", "\\ldots", true); +defineSymbol(math, main, inner, "\u2026", "\\ldots", true); +defineSymbol(math, main, inner, "\u22ef", "\\@cdots", true); +defineSymbol(math, main, inner, "\u22f1", "\\ddots", true); +// \vdots is a macro that uses one of these two symbols (with made-up names): +defineSymbol(math, main, textord, "\u22ee", "\\varvdots"); +defineSymbol(text, main, textord, "\u22ee", "\\varvdots"); +defineSymbol(math, main, accent, "\u02ca", "\\acute"); +defineSymbol(math, main, accent, "\u02cb", "\\grave"); +defineSymbol(math, main, accent, "\u00a8", "\\ddot"); +defineSymbol(math, main, accent, "\u007e", "\\tilde"); +defineSymbol(math, main, accent, "\u02c9", "\\bar"); +defineSymbol(math, main, accent, "\u02d8", "\\breve"); +defineSymbol(math, main, accent, "\u02c7", "\\check"); +defineSymbol(math, main, accent, "\u005e", "\\hat"); +defineSymbol(math, main, accent, "\u20d7", "\\vec"); +defineSymbol(math, main, accent, "\u02d9", "\\dot"); +defineSymbol(math, main, accent, "\u02da", "\\mathring"); +// \imath and \jmath should be invariant to \mathrm, \mathbf, etc., so use PUA +defineSymbol(math, main, mathord, "\ue131", "\\@imath"); +defineSymbol(math, main, mathord, "\ue237", "\\@jmath"); +defineSymbol(math, main, textord, "\u0131", "\u0131"); +defineSymbol(math, main, textord, "\u0237", "\u0237"); +defineSymbol(text, main, textord, "\u0131", "\\i", true); +defineSymbol(text, main, textord, "\u0237", "\\j", true); +defineSymbol(text, main, textord, "\u00df", "\\ss", true); +defineSymbol(text, main, textord, "\u00e6", "\\ae", true); +defineSymbol(text, main, textord, "\u0153", "\\oe", true); +defineSymbol(text, main, textord, "\u00f8", "\\o", true); +defineSymbol(text, main, textord, "\u00c6", "\\AE", true); +defineSymbol(text, main, textord, "\u0152", "\\OE", true); +defineSymbol(text, main, textord, "\u00d8", "\\O", true); +defineSymbol(text, main, accent, "\u02ca", "\\'"); // acute +defineSymbol(text, main, accent, "\u02cb", "\\`"); // grave +defineSymbol(text, main, accent, "\u02c6", "\\^"); // circumflex +defineSymbol(text, main, accent, "\u02dc", "\\~"); // tilde +defineSymbol(text, main, accent, "\u02c9", "\\="); // macron +defineSymbol(text, main, accent, "\u02d8", "\\u"); // breve +defineSymbol(text, main, accent, "\u02d9", "\\."); // dot above +defineSymbol(text, main, accent, "\u00b8", "\\c"); // cedilla +defineSymbol(text, main, accent, "\u02da", "\\r"); // ring above +defineSymbol(text, main, accent, "\u02c7", "\\v"); // caron +defineSymbol(text, main, accent, "\u00a8", '\\"'); // diaeresis +defineSymbol(text, main, accent, "\u02dd", "\\H"); // double acute +defineSymbol(text, main, accent, "\u25ef", "\\textcircled"); // \bigcirc glyph +// These ligatures are detected and created in Parser.js's `formLigatures`. +var ligatures = { + "--": true, + "---": true, + "``": true, + "''": true +}; +defineSymbol(text, main, textord, "\u2013", "--", true); +defineSymbol(text, main, textord, "\u2013", "\\textendash"); +defineSymbol(text, main, textord, "\u2014", "---", true); +defineSymbol(text, main, textord, "\u2014", "\\textemdash"); +defineSymbol(text, main, textord, "\u2018", "`", true); +defineSymbol(text, main, textord, "\u2018", "\\textquoteleft"); +defineSymbol(text, main, textord, "\u2019", "'", true); +defineSymbol(text, main, textord, "\u2019", "\\textquoteright"); +defineSymbol(text, main, textord, "\u201c", "``", true); +defineSymbol(text, main, textord, "\u201c", "\\textquotedblleft"); +defineSymbol(text, main, textord, "\u201d", "''", true); +defineSymbol(text, main, textord, "\u201d", "\\textquotedblright"); +// \degree from gensymb package +defineSymbol(math, main, textord, "\u00b0", "\\degree", true); +defineSymbol(text, main, textord, "\u00b0", "\\degree"); +// \textdegree from inputenc package +defineSymbol(text, main, textord, "\u00b0", "\\textdegree", true); +// TODO: In LaTeX, \pounds can generate a different character in text and math +// mode, but among our fonts, only Main-Regular defines this character "163". +defineSymbol(math, main, textord, "\u00a3", "\\pounds"); +defineSymbol(math, main, textord, "\u00a3", "\\mathsterling", true); +defineSymbol(text, main, textord, "\u00a3", "\\pounds"); +defineSymbol(text, main, textord, "\u00a3", "\\textsterling", true); +defineSymbol(math, ams, textord, "\u2720", "\\maltese"); +defineSymbol(text, ams, textord, "\u2720", "\\maltese"); +// There are lots of symbols which are the same, so we add them in afterwards. +// All of these are textords in math mode +var mathTextSymbols = "0123456789/@.\""; +for (var i = 0; i < mathTextSymbols.length; i++) { + var ch = mathTextSymbols.charAt(i); + defineSymbol(math, main, textord, ch, ch); +} +// All of these are textords in text mode +var textSymbols = "0123456789!@*()-=+\";:?/.,"; +for (var _i = 0; _i < textSymbols.length; _i++) { + var _ch = textSymbols.charAt(_i); + defineSymbol(text, main, textord, _ch, _ch); +} +// All of these are textords in text mode, and mathords in math mode +var letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; +for (var _i2 = 0; _i2 < letters.length; _i2++) { + var _ch2 = letters.charAt(_i2); + defineSymbol(math, main, mathord, _ch2, _ch2); + defineSymbol(text, main, textord, _ch2, _ch2); +} +// Blackboard bold and script letters in Unicode range +defineSymbol(math, ams, textord, "C", "\u2102"); // blackboard bold +defineSymbol(text, ams, textord, "C", "\u2102"); +defineSymbol(math, ams, textord, "H", "\u210D"); +defineSymbol(text, ams, textord, "H", "\u210D"); +defineSymbol(math, ams, textord, "N", "\u2115"); +defineSymbol(text, ams, textord, "N", "\u2115"); +defineSymbol(math, ams, textord, "P", "\u2119"); +defineSymbol(text, ams, textord, "P", "\u2119"); +defineSymbol(math, ams, textord, "Q", "\u211A"); +defineSymbol(text, ams, textord, "Q", "\u211A"); +defineSymbol(math, ams, textord, "R", "\u211D"); +defineSymbol(text, ams, textord, "R", "\u211D"); +defineSymbol(math, ams, textord, "Z", "\u2124"); +defineSymbol(text, ams, textord, "Z", "\u2124"); +defineSymbol(math, main, mathord, "h", "\u210E"); // italic h, Planck constant +defineSymbol(text, main, mathord, "h", "\u210E"); +// The next loop loads wide (surrogate pair) characters. +// We support some letters in the Unicode range U+1D400 to U+1D7FF, +// Mathematical Alphanumeric Symbols. +// Some editors do not deal well with wide characters. So don't write the +// string into this file. Instead, create the string from the surrogate pair. +var wideChar; +for (var _i3 = 0; _i3 < letters.length; _i3++) { + var _ch3 = letters.charAt(_i3); + // The hex numbers in the next line are a surrogate pair. + // 0xD835 is the high surrogate for all letters in the range we support. + // 0xDC00 is the low surrogate for bold A. + wideChar = String.fromCharCode(0xD835, 0xDC00 + _i3); // A-Z a-z bold + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(text, main, textord, _ch3, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDC34 + _i3); // A-Z a-z italic + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(text, main, textord, _ch3, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDC68 + _i3); // A-Z a-z bold italic + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(text, main, textord, _ch3, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDD04 + _i3); // A-Z a-z Fraktur + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(text, main, textord, _ch3, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDD6C + _i3); // A-Z a-z bold Fraktur + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(text, main, textord, _ch3, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDDA0 + _i3); // A-Z a-z sans-serif + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(text, main, textord, _ch3, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDDD4 + _i3); // A-Z a-z sans bold + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(text, main, textord, _ch3, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDE08 + _i3); // A-Z a-z sans italic + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(text, main, textord, _ch3, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDE70 + _i3); // A-Z a-z monospace + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(text, main, textord, _ch3, wideChar); + if (_i3 < 26) { + // KaTeX fonts have only capital letters for blackboard bold and script. + // See exception for k below. + wideChar = String.fromCharCode(0xD835, 0xDD38 + _i3); // A-Z double struck + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(text, main, textord, _ch3, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDC9C + _i3); // A-Z script + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(text, main, textord, _ch3, wideChar); + } + // TODO: Add bold script when it is supported by a KaTeX font. +} +// "k" is the only double struck lower case letter in the KaTeX fonts. +wideChar = String.fromCharCode(0xD835, 0xDD5C); // k double struck +defineSymbol(math, main, mathord, "k", wideChar); +defineSymbol(text, main, textord, "k", wideChar); +// Next, some wide character numerals +for (var _i4 = 0; _i4 < 10; _i4++) { + var _ch4 = _i4.toString(); + wideChar = String.fromCharCode(0xD835, 0xDFCE + _i4); // 0-9 bold + defineSymbol(math, main, mathord, _ch4, wideChar); + defineSymbol(text, main, textord, _ch4, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDFE2 + _i4); // 0-9 sans serif + defineSymbol(math, main, mathord, _ch4, wideChar); + defineSymbol(text, main, textord, _ch4, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDFEC + _i4); // 0-9 bold sans + defineSymbol(math, main, mathord, _ch4, wideChar); + defineSymbol(text, main, textord, _ch4, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDFF6 + _i4); // 0-9 monospace + defineSymbol(math, main, mathord, _ch4, wideChar); + defineSymbol(text, main, textord, _ch4, wideChar); +} +// We add these Latin-1 letters as symbols for backwards-compatibility, +// but they are not actually in the font, nor are they supported by the +// Unicode accent mechanism, so they fall back to Times font and look ugly. +// TODO(edemaine): Fix this. +var extraLatin = "\u00d0\u00de\u00fe"; +for (var _i5 = 0; _i5 < extraLatin.length; _i5++) { + var _ch5 = extraLatin.charAt(_i5); + defineSymbol(math, main, mathord, _ch5, _ch5); + defineSymbol(text, main, textord, _ch5, _ch5); +} + +/** + * This file provides support for Unicode range U+1D400 to U+1D7FF, + * Mathematical Alphanumeric Symbols. + * + * Function wideCharacterFont takes a wide character as input and returns + * the font information necessary to render it properly. + */ +var boldUpright = { + mathClass: "mathbf", + textClass: "textbf", + font: "Main-Bold" +}; +var italic = { + mathClass: "mathnormal", + textClass: "textit", + font: "Math-Italic" +}; +var boldItalic = { + mathClass: "boldsymbol", + textClass: "boldsymbol", + font: "Main-BoldItalic" +}; +var script = { + mathClass: "mathscr", + textClass: "textscr", + font: "Script-Regular" +}; +var noFont = { + mathClass: "", + textClass: "", + font: "" +}; +var fraktur = { + mathClass: "mathfrak", + textClass: "textfrak", + font: "Fraktur-Regular" +}; +var doubleStruck = { + mathClass: "mathbb", + textClass: "textbb", + font: "AMS-Regular" +}; +var boldFraktur = { + mathClass: "mathboldfrak", + textClass: "textboldfrak", + font: "Fraktur-Regular" +}; +var sansSerif = { + mathClass: "mathsf", + textClass: "textsf", + font: "SansSerif-Regular" +}; +var boldSansSerif = { + mathClass: "mathboldsf", + textClass: "textboldsf", + font: "SansSerif-Bold" +}; +var italicSansSerif = { + mathClass: "mathitsf", + textClass: "textitsf", + font: "SansSerif-Italic" +}; +var monospace = { + mathClass: "mathtt", + textClass: "texttt", + font: "Typewriter-Regular" +}; +/** + * Data below is from https://www.unicode.org/charts/PDF/U1D400.pdf + * That document sorts characters into groups by font type, say bold or italic. + * + * In the arrays below, each object consists of three properties: + * * The CSS class of that group when in math mode. + * * The CSS class of that group when in text mode. + * * The font name, so that KaTeX can get font metrics. + */ +var wideLatinLetterData = [boldUpright, boldUpright, +// A-Z, a-z +italic, italic, +// A-Z, a-z +boldItalic, boldItalic, +// A-Z, a-z +// Map fancy A-Z letters to script, not calligraphic. +// This aligns with unicode-math and math fonts (except Cambria Math). +script, noFont, +// A-Z script, a-z — no font +noFont, noFont, +// A-Z bold script, a-z bold script — no font +fraktur, fraktur, +// A-Z, a-z +doubleStruck, doubleStruck, +// A-Z double-struck, k double-struck +// Note that we are using a bold font, but font metrics for regular Fraktur. +boldFraktur, boldFraktur, +// A-Z, a-z +sansSerif, sansSerif, +// A-Z, a-z +boldSansSerif, boldSansSerif, +// A-Z, a-z +italicSansSerif, italicSansSerif, +// A-Z, a-z +noFont, noFont, +// A-Z bold italic sans, a-z bold italic sans - no font +monospace, monospace // A-Z, a-z +]; +var wideNumeralData = [boldUpright, +// 0-9 +noFont, +// 0-9 double-struck. No KaTeX font. +sansSerif, +// 0-9 +boldSansSerif, +// 0-9 +monospace // 0-9 +]; +var wideCharacterFont = wideChar => { + // IE doesn't support codePointAt(). So work with the surrogate pair. + var H = wideChar.charCodeAt(0); // high surrogate + var L = wideChar.charCodeAt(1); // low surrogate + var codePoint = (H - 0xD800) * 0x400 + (L - 0xDC00) + 0x10000; + if (0x1D400 <= codePoint && codePoint < 0x1D6A4) { + // wideLatinLetterData contains exactly 26 chars on each row. + // So we can calculate the relevant row. No traverse necessary. + var i = Math.floor((codePoint - 0x1D400) / 26); + return wideLatinLetterData[i]; + } else if (0x1D7CE <= codePoint && codePoint <= 0x1D7FF) { + // Numerals, ten per row. + var _i = Math.floor((codePoint - 0x1D7CE) / 10); + return wideNumeralData[_i]; + } else if (codePoint === 0x1D6A5 || codePoint === 0x1D6A6) { + // dotless i or j + return wideLatinLetterData[0]; + } else if (0x1D6A6 < codePoint && codePoint < 0x1D7CE) { + // Greek letters. Not supported, yet. + return noFont; + } else { + // We don't support any wide characters outside 1D400–1D7FF. + throw new ParseError("Unsupported character: " + wideChar); + } +}; + +/* eslint no-console:0 */ +/** + * Looks up the given symbol in fontMetrics, after applying any symbol + * replacements defined in symbol.js + */ +var lookupSymbol = function lookupSymbol(value, fontName, mode) { + // Replace the value with its replaced value from symbol.js + if (symbols[mode][value]) { + var replacement = symbols[mode][value].replace; + if (replacement) { + value = replacement; + } + } + return { + value, + metrics: getCharacterMetrics(value, fontName, mode) + }; +}; +/** + * Makes a symbolNode after translation via the list of symbols in symbols.js. + * Correctly pulls out metrics for the character, and optionally takes a list of + * classes to be attached to the node. + * + * TODO: make argument order closer to makeSpan + * TODO: add a separate argument for math class (e.g. `mop`, `mbin`), which + * should if present come first in `classes`. + * TODO(#953): Make `options` mandatory and always pass it in. + */ +var makeSymbol = function makeSymbol(value, fontName, mode, options, classes) { + var lookup = lookupSymbol(value, fontName, mode); + var metrics = lookup.metrics; + value = lookup.value; + var symbolNode; + if (metrics) { + var italic = metrics.italic; + if (mode === "text" || options && options.font === "mathit") { + italic = 0; + } + symbolNode = new SymbolNode(value, metrics.height, metrics.depth, italic, metrics.skew, metrics.width, classes); + } else { + // TODO(emily): Figure out a good way to only print this in development + typeof console !== "undefined" && console.warn("No character metrics " + ("for '" + value + "' in style '" + fontName + "' and mode '" + mode + "'")); + symbolNode = new SymbolNode(value, 0, 0, 0, 0, 0, classes); + } + if (options) { + symbolNode.maxFontSize = options.sizeMultiplier; + if (options.style.isTight()) { + symbolNode.classes.push("mtight"); + } + var color = options.getColor(); + if (color) { + symbolNode.style.color = color; + } + } + return symbolNode; +}; +/** + * Makes a symbol in Main-Regular or AMS-Regular. + * Used for rel, bin, open, close, inner, and punct. + */ +var mathsym = function mathsym(value, mode, options, classes) { + if (classes === void 0) { + classes = []; + } + // Decide what font to render the symbol in by its entry in the symbols + // table. + // Have a special case for when the value = \ because the \ is used as a + // textord in unsupported command errors but cannot be parsed as a regular + // text ordinal and is therefore not present as a symbol in the symbols + // table for text, as well as a special case for boldsymbol because it + // can be used for bold + and - + if (options.font === "boldsymbol" && lookupSymbol(value, "Main-Bold", mode).metrics) { + return makeSymbol(value, "Main-Bold", mode, options, classes.concat(["mathbf"])); + } else if (value === "\\" || symbols[mode][value].font === "main") { + return makeSymbol(value, "Main-Regular", mode, options, classes); + } else { + return makeSymbol(value, "AMS-Regular", mode, options, classes.concat(["amsrm"])); + } +}; +/** + * Determines which of the two font names (Main-Bold and Math-BoldItalic) and + * corresponding style tags (mathbf or boldsymbol) to use for font "boldsymbol", + * depending on the symbol. Use this function instead of fontMap for font + * "boldsymbol". + */ +var boldSymbol = function boldSymbol(value, mode, type) { + if (type !== "textord" && lookupSymbol(value, "Math-BoldItalic", mode).metrics) { + return { + fontName: "Math-BoldItalic", + fontClass: "boldsymbol" + }; + } else { + // Some glyphs do not exist in Math-BoldItalic so we need to use + // Main-Bold instead. + return { + fontName: "Main-Bold", + fontClass: "mathbf" + }; + } +}; +/** + * Makes either a mathord or textord in the correct font and color. + */ +var makeOrd = function makeOrd(group, options, type) { + var mode = group.mode; + var text = group.text; + var classes = ["mord"]; + var { + font, + fontFamily, + fontWeight, + fontShape + } = options; + // Math mode or Old font (i.e. \rm) + var useFont = mode === "math" || mode === "text" && !!font; + var fontOrFamily = useFont ? font : fontFamily; + var wideFontName = ""; + var wideFontClass = ""; + if (text.charCodeAt(0) === 0xD835) { + var wideCharData = wideCharacterFont(text); + wideFontName = wideCharData.font; + wideFontClass = wideCharData[mode + "Class"]; + } + if (wideFontName) { + // surrogate pairs get special treatment + return makeSymbol(text, wideFontName, mode, options, classes.concat(wideFontClass)); + } else if (fontOrFamily) { + var fontName; + var fontClasses; + if (fontOrFamily === "boldsymbol") { + var fontData = boldSymbol(text, mode, type); + fontName = fontData.fontName; + fontClasses = [fontData.fontClass]; + } else if (useFont) { + fontName = fontMap[font].fontName; + fontClasses = [font]; + } else { + fontName = retrieveTextFontName(fontFamily, fontWeight, fontShape); + fontClasses = [fontFamily, fontWeight, fontShape]; + } + if (lookupSymbol(text, fontName, mode).metrics) { + return makeSymbol(text, fontName, mode, options, classes.concat(fontClasses)); + } else if (ligatures.hasOwnProperty(text) && fontName.slice(0, 10) === "Typewriter") { + // Deconstruct ligatures in monospace fonts (\texttt, \tt). + var parts = []; + for (var i = 0; i < text.length; i++) { + parts.push(makeSymbol(text[i], fontName, mode, options, classes.concat(fontClasses))); + } + return makeFragment(parts); + } + } + // Makes a symbol in the default font for mathords and textords. + if (type === "mathord") { + return makeSymbol(text, "Math-Italic", mode, options, classes.concat(["mathnormal"])); + } else if (type === "textord") { + var _font = symbols[mode][text] && symbols[mode][text].font; + if (_font === "ams") { + var _fontName = retrieveTextFontName("amsrm", fontWeight, fontShape); + return makeSymbol(text, _fontName, mode, options, classes.concat("amsrm", fontWeight, fontShape)); + } else if (_font === "main" || !_font) { + var _fontName2 = retrieveTextFontName("textrm", fontWeight, fontShape); + return makeSymbol(text, _fontName2, mode, options, classes.concat(fontWeight, fontShape)); + } else { + // fonts added by plugins + var _fontName3 = retrieveTextFontName(_font, fontWeight, fontShape); + // We add font name as a css class + return makeSymbol(text, _fontName3, mode, options, classes.concat(_fontName3, fontWeight, fontShape)); + } + } else { + throw new Error("unexpected type: " + type + " in makeOrd"); + } +}; +/** + * Returns true if subsequent symbolNodes have the same classes, skew, maxFont, + * and styles. For mathnormal text, the left node must also have zero italic + * correction so we don't lose spacing between combined glyphs. + */ +var canCombine = (prev, next) => { + if (createClass(prev.classes) !== createClass(next.classes) || prev.skew !== next.skew || prev.maxFontSize !== next.maxFontSize || prev.italic !== 0 && prev.hasClass("mathnormal")) { + return false; + } + // If prev and next both are just "mbin"s or "mord"s we don't combine them + // so that the proper spacing can be preserved. + if (prev.classes.length === 1) { + var cls = prev.classes[0]; + if (cls === "mbin" || cls === "mord") { + return false; + } + } + for (var key of Object.keys(prev.style)) { + if (prev.style[key] !== next.style[key]) { + return false; + } + } + for (var _key of Object.keys(next.style)) { + if (prev.style[_key] !== next.style[_key]) { + return false; + } + } + return true; +}; +/** + * Combine consecutive domTree.symbolNodes into a single symbolNode. + * Note: this function mutates the argument. + */ +var tryCombineChars = chars => { + for (var i = 0; i < chars.length - 1; i++) { + var prev = chars[i]; + var next = chars[i + 1]; + if (prev instanceof SymbolNode && next instanceof SymbolNode && canCombine(prev, next)) { + prev.text += next.text; + prev.height = Math.max(prev.height, next.height); + prev.depth = Math.max(prev.depth, next.depth); + // Use the last character's italic correction since we use + // it to add padding to the right of the span created from + // the combined characters. + prev.italic = next.italic; + chars.splice(i + 1, 1); + i--; + } + } + return chars; +}; +/** + * Calculate the height, depth, and maxFontSize of an element based on its + * children. + */ +var sizeElementFromChildren = function sizeElementFromChildren(elem) { + var height = 0; + var depth = 0; + var maxFontSize = 0; + for (var i = 0; i < elem.children.length; i++) { + var child = elem.children[i]; + if (child.height > height) { + height = child.height; + } + if (child.depth > depth) { + depth = child.depth; + } + if (child.maxFontSize > maxFontSize) { + maxFontSize = child.maxFontSize; + } + } + elem.height = height; + elem.depth = depth; + elem.maxFontSize = maxFontSize; +}; +/** + * Makes a span with the given list of classes, list of children, and options. + * + * TODO(#953): Ensure that `options` is always provided (currently some call + * sites don't pass it) and make the type below mandatory. + * TODO: add a separate argument for math class (e.g. `mop`, `mbin`), which + * should if present come first in `classes`. + */ +var makeSpan = function makeSpan(classes, children, options, style) { + var span = new Span(classes, children, options, style); + sizeElementFromChildren(span); + return span; +}; +// SVG one is simpler -- doesn't require height, depth, max-font setting. +// This is also a separate method for typesafety. +var makeSvgSpan = (classes, children, options, style) => new Span(classes, children, options, style); +var makeLineSpan = function makeLineSpan(className, options, thickness) { + var line = makeSpan([className], [], options); + line.height = Math.max(thickness || options.fontMetrics().defaultRuleThickness, options.minRuleThickness); + line.style.borderBottomWidth = makeEm(line.height); + line.maxFontSize = 1.0; + return line; +}; +/** + * Makes an anchor with the given href, list of classes, list of children, + * and options. + */ +var makeAnchor = function makeAnchor(href, classes, children, options) { + var anchor = new Anchor(href, classes, children, options); + sizeElementFromChildren(anchor); + return anchor; +}; +/** + * Makes a document fragment with the given list of children. + */ +var makeFragment = function makeFragment(children) { + var fragment = new DocumentFragment(children); + sizeElementFromChildren(fragment); + return fragment; +}; +/** + * Wraps group in a span if it's a document fragment, allowing to apply classes + * and styles + */ +var wrapFragment = function wrapFragment(group, options) { + if (group instanceof DocumentFragment) { + return makeSpan([], [group], options); + } + return group; +}; +// Computes the updated `children` list and the overall depth. +// +// This helper function for makeVList makes it easier to enforce type safety by +// allowing early exits (returns) in the logic. +var getVListChildrenAndDepth = function getVListChildrenAndDepth(params) { + if (params.positionType === "individualShift") { + var oldChildren = params.children; + var children = [oldChildren[0]]; + // Add in kerns to the list of params.children to get each element to be + // shifted to the correct specified shift + var _depth = -oldChildren[0].shift - oldChildren[0].elem.depth; + var currPos = _depth; + for (var i = 1; i < oldChildren.length; i++) { + var diff = -oldChildren[i].shift - currPos - oldChildren[i].elem.depth; + var size = diff - (oldChildren[i - 1].elem.height + oldChildren[i - 1].elem.depth); + currPos = currPos + diff; + children.push({ + type: "kern", + size + }); + children.push(oldChildren[i]); + } + return { + children, + depth: _depth + }; + } + var depth; + if (params.positionType === "top") { + // We always start at the bottom, so calculate the bottom by adding up + // all the sizes + var bottom = params.positionData; + for (var _i = 0; _i < params.children.length; _i++) { + var child = params.children[_i]; + bottom -= child.type === "kern" ? child.size : child.elem.height + child.elem.depth; + } + depth = bottom; + } else if (params.positionType === "bottom") { + depth = -params.positionData; + } else { + var firstChild = params.children[0]; + if (firstChild.type !== "elem") { + throw new Error('First child must have type "elem".'); + } + if (params.positionType === "shift") { + depth = -firstChild.elem.depth - params.positionData; + } else if (params.positionType === "firstBaseline") { + depth = -firstChild.elem.depth; + } else { + throw new Error("Invalid positionType " + params.positionType + "."); + } + } + return { + children: params.children, + depth + }; +}; +/** + * Makes a vertical list by stacking elements and kerns on top of each other. + * Allows for many different ways of specifying the positioning method. + * + * See VListParam documentation above. + */ +var makeVList = function makeVList(params, options) { + var { + children, + depth + } = getVListChildrenAndDepth(params); + // Create a strut that is taller than any list item. The strut is added to + // each item, where it will determine the item's baseline. Since it has + // `overflow:hidden`, the strut's top edge will sit on the item's line box's + // top edge and the strut's bottom edge will sit on the item's baseline, + // with no additional line-height spacing. This allows the item baseline to + // be positioned precisely without worrying about font ascent and + // line-height. + var pstrutSize = 0; + for (var i = 0; i < children.length; i++) { + var child = children[i]; + if (child.type === "elem") { + var elem = child.elem; + pstrutSize = Math.max(pstrutSize, elem.maxFontSize, elem.height); + } + } + pstrutSize += 2; + var pstrut = makeSpan(["pstrut"], []); + pstrut.style.height = makeEm(pstrutSize); + // Create a new list of actual children at the correct offsets + var realChildren = []; + var minPos = depth; + var maxPos = depth; + var currPos = depth; + for (var _i2 = 0; _i2 < children.length; _i2++) { + var _child = children[_i2]; + if (_child.type === "kern") { + currPos += _child.size; + } else { + var _elem = _child.elem; + var classes = _child.wrapperClasses || []; + var style = _child.wrapperStyle || {}; + var childWrap = makeSpan(classes, [pstrut, _elem], undefined, style); + childWrap.style.top = makeEm(-pstrutSize - currPos - _elem.depth); + if (_child.marginLeft) { + childWrap.style.marginLeft = _child.marginLeft; + } + if (_child.marginRight) { + childWrap.style.marginRight = _child.marginRight; + } + realChildren.push(childWrap); + currPos += _elem.height + _elem.depth; + } + minPos = Math.min(minPos, currPos); + maxPos = Math.max(maxPos, currPos); + } + // The vlist contents go in a table-cell with `vertical-align:bottom`. + // This cell's bottom edge will determine the containing table's baseline + // without overly expanding the containing line-box. + var vlist = makeSpan(["vlist"], realChildren); + vlist.style.height = makeEm(maxPos); + // A second row is used if necessary to represent the vlist's depth. + var rows; + if (minPos < 0) { + // We will define depth in an empty span with display: table-cell. + // It should render with the height that we define. But Chrome, in + // contenteditable mode only, treats that span as if it contains some + // text content. And that min-height over-rides our desired height. + // So we put another empty span inside the depth strut span. + var emptySpan = makeSpan([], []); + var depthStrut = makeSpan(["vlist"], [emptySpan]); + depthStrut.style.height = makeEm(-minPos); + // Safari wants the first row to have inline content; otherwise it + // puts the bottom of the *second* row on the baseline. + var topStrut = makeSpan(["vlist-s"], [new SymbolNode("\u200b")]); + rows = [makeSpan(["vlist-r"], [vlist, topStrut]), makeSpan(["vlist-r"], [depthStrut])]; + } else { + rows = [makeSpan(["vlist-r"], [vlist])]; + } + var vtable = makeSpan(["vlist-t"], rows); + if (rows.length === 2) { + vtable.classes.push("vlist-t2"); + } + vtable.height = maxPos; + vtable.depth = -minPos; + return vtable; +}; +// Glue is a concept from TeX which is a flexible space between elements in +// either a vertical or horizontal list. In KaTeX, at least for now, it's +// static space between elements in a horizontal layout. +var makeGlue = (measurement, options) => { + // Make an empty span for the space + var rule = makeSpan(["mspace"], [], options); + var size = calculateSize(measurement, options); + rule.style.marginRight = makeEm(size); + return rule; +}; +// Takes font options, and returns the appropriate fontLookup name +var retrieveTextFontName = (fontFamily, fontWeight, fontShape) => { + var baseFontName; + var fontStylesName; + switch (fontFamily) { + case "amsrm": + baseFontName = "AMS"; + break; + case "textrm": + baseFontName = "Main"; + break; + case "textsf": + baseFontName = "SansSerif"; + break; + case "texttt": + baseFontName = "Typewriter"; + break; + default: + baseFontName = fontFamily; + // use fonts added by a plugin + } + if (fontWeight === "textbf" && fontShape === "textit") { + fontStylesName = "BoldItalic"; + } else if (fontWeight === "textbf") { + fontStylesName = "Bold"; + } else if (fontShape === "textit") { + fontStylesName = "Italic"; + } else { + fontStylesName = "Regular"; + } + return baseFontName + "-" + fontStylesName; +}; +/** + * Maps TeX font commands to objects containing: + * - variant: string used for "mathvariant" attribute in buildMathML.js + * - fontName: the "style" parameter to fontMetrics.getCharacterMetrics + */ +// A map between tex font commands an MathML mathvariant attribute values +var fontMap = { + // styles + "mathbf": { + variant: "bold", + fontName: "Main-Bold" + }, + "mathrm": { + variant: "normal", + fontName: "Main-Regular" + }, + "textit": { + variant: "italic", + fontName: "Main-Italic" + }, + "mathit": { + variant: "italic", + fontName: "Main-Italic" + }, + "mathnormal": { + variant: "italic", + fontName: "Math-Italic" + }, + "mathsfit": { + variant: "sans-serif-italic", + fontName: "SansSerif-Italic" + }, + // "boldsymbol" is missing because they require the use of multiple fonts: + // Math-BoldItalic and Main-Bold. This is handled by a special case in + // makeOrd which ends up calling boldsymbol. + // families + "mathbb": { + variant: "double-struck", + fontName: "AMS-Regular" + }, + "mathcal": { + variant: "script", + fontName: "Caligraphic-Regular" + }, + "mathfrak": { + variant: "fraktur", + fontName: "Fraktur-Regular" + }, + "mathscr": { + variant: "script", + fontName: "Script-Regular" + }, + "mathsf": { + variant: "sans-serif", + fontName: "SansSerif-Regular" + }, + "mathtt": { + variant: "monospace", + fontName: "Typewriter-Regular" + } +}; +var svgData = { + // path, width, height + vec: ["vec", 0.471, 0.714], + // values from the font glyph + oiintSize1: ["oiintSize1", 0.957, 0.499], + // oval to overlay the integrand + oiintSize2: ["oiintSize2", 1.472, 0.659], + oiiintSize1: ["oiiintSize1", 1.304, 0.499], + oiiintSize2: ["oiiintSize2", 1.98, 0.659] +}; +var staticSvg = function staticSvg(value, options) { + // Create a span with inline SVG for the element. + var [pathName, width, height] = svgData[value]; + var path = new PathNode(pathName); + var svgNode = new SvgNode([path], { + "width": makeEm(width), + "height": makeEm(height), + // Override CSS rule `.katex svg { width: 100% }` + "style": "width:" + makeEm(width), + "viewBox": "0 0 " + 1000 * width + " " + 1000 * height, + "preserveAspectRatio": "xMinYMin" + }); + var span = makeSvgSpan(["overlay"], [svgNode], options); + span.height = height; + span.style.height = makeEm(height); + span.style.width = makeEm(width); + return span; +}; + +var thinspace = { + number: 3, + unit: "mu" +}; +var mediumspace = { + number: 4, + unit: "mu" +}; +var thickspace = { + number: 5, + unit: "mu" +}; +// Spacing relationships for display and text styles +var spacings = { + mord: { + mop: thinspace, + mbin: mediumspace, + mrel: thickspace, + minner: thinspace + }, + mop: { + mord: thinspace, + mop: thinspace, + mrel: thickspace, + minner: thinspace + }, + mbin: { + mord: mediumspace, + mop: mediumspace, + mopen: mediumspace, + minner: mediumspace + }, + mrel: { + mord: thickspace, + mop: thickspace, + mopen: thickspace, + minner: thickspace + }, + mopen: {}, + mclose: { + mop: thinspace, + mbin: mediumspace, + mrel: thickspace, + minner: thinspace + }, + mpunct: { + mord: thinspace, + mop: thinspace, + mrel: thickspace, + mopen: thinspace, + mclose: thinspace, + mpunct: thinspace, + minner: thinspace + }, + minner: { + mord: thinspace, + mop: thinspace, + mbin: mediumspace, + mrel: thickspace, + mopen: thinspace, + mpunct: thinspace, + minner: thinspace + } +}; +// Spacing relationships for script and scriptscript styles +var tightSpacings = { + mord: { + mop: thinspace + }, + mop: { + mord: thinspace, + mop: thinspace + }, + mbin: {}, + mrel: {}, + mopen: {}, + mclose: { + mop: thinspace + }, + mpunct: {}, + minner: { + mop: thinspace + } +}; + +/** + * All registered functions. + * `functions.js` just exports this same dictionary again and makes it public. + * `Parser.js` requires this dictionary. + */ +var _functions = {}; +/** + * All HTML builders. Should be only used in the `define*` and the `build*ML` + * functions. + * + * Builders for different node types are stored side by side, but + * `HtmlBuilder` is contravariant in `T`, so there is no single type + * argument that makes storing/retrieving them typecheck. `any` is used + * as an existential-quantifier escape hatch. + */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any +var _htmlGroupBuilders = {}; +/** + * All MathML builders. Should be only used in the `define*` and the `build*ML` + * functions. See `_htmlGroupBuilders` above for the rationale behind `any`. + */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any +var _mathmlGroupBuilders = {}; +function defineFunction(_ref) { + var { + type, + names, + props, + handler, + htmlBuilder, + mathmlBuilder + } = _ref; + // Set default values of functions + var data = { + type, + numArgs: props.numArgs, + argTypes: props.argTypes, + allowedInArgument: !!props.allowedInArgument, + allowedInText: !!props.allowedInText, + allowedInMath: props.allowedInMath === undefined ? true : props.allowedInMath, + numOptionalArgs: props.numOptionalArgs || 0, + infix: !!props.infix, + primitive: !!props.primitive, + handler + }; + for (var i = 0; i < names.length; ++i) { + _functions[names[i]] = data; + } + if (type) { + if (htmlBuilder) { + _htmlGroupBuilders[type] = htmlBuilder; + } + if (mathmlBuilder) { + _mathmlGroupBuilders[type] = mathmlBuilder; + } + } +} +/** + * Use this to register only the HTML and MathML builders for a function (e.g. + * if the function's ParseNode is generated in Parser.js rather than via a + * stand-alone handler provided to `defineFunction`). + */ +function defineFunctionBuilders(_ref2) { + var { + type, + htmlBuilder, + mathmlBuilder + } = _ref2; + defineFunction({ + type, + names: [], + props: { + numArgs: 0 + }, + handler() { + throw new Error('Should never be called.'); + }, + htmlBuilder, + mathmlBuilder + }); +} +var normalizeArgument = function normalizeArgument(arg) { + return arg.type === "ordgroup" && arg.body.length === 1 ? arg.body[0] : arg; +}; +// Since the corresponding buildHTML/buildMathML function expects a +// list of elements, we normalize for different kinds of arguments +var ordargument = function ordargument(arg) { + return arg.type === "ordgroup" ? arg.body : [arg]; +}; + +/** + * This file does the main work of building a domTree structure from a parse + * tree. The entry point is the `buildHTML` function, which takes a parse tree. + * Then, the buildExpression, buildGroup, and various groupBuilders functions + * are called, to produce a final HTML tree. + */ +// Binary atoms (first class `mbin`) change into ordinary atoms (`mord`) +// depending on their surroundings. See TeXbook pg. 442-446, Rules 5 and 6, +// and the text before Rule 19. +var binLeftCanceller = new Set(["leftmost", "mbin", "mopen", "mrel", "mop", "mpunct"]); +var binRightCanceller = new Set(["rightmost", "mrel", "mclose", "mpunct"]); +var styleMap$1 = { + "display": Style$1.DISPLAY, + "text": Style$1.TEXT, + "script": Style$1.SCRIPT, + "scriptscript": Style$1.SCRIPTSCRIPT +}; +var DomEnum = { + mord: "mord", + mop: "mop", + mbin: "mbin", + mrel: "mrel", + mopen: "mopen", + mclose: "mclose", + mpunct: "mpunct", + minner: "minner" +}; +/** + * Take a list of nodes, build them in order, and return a list of the built + * nodes. documentFragments are flattened into their contents, so the + * returned list contains no fragments. `isRealGroup` is true if `expression` + * is a real group (no atoms will be added on either side), as opposed to + * a partial group (e.g. one created by \color). `surrounding` is an array + * consisting type of nodes that will be added to the left and right. + */ +var buildExpression$1 = function buildExpression(expression, options, isRealGroup, surrounding) { + if (surrounding === void 0) { + surrounding = [null, null]; + } + // Parse expressions into `groups`. + var groups = []; + for (var i = 0; i < expression.length; i++) { + var output = buildGroup$1(expression[i], options); + if (output instanceof DocumentFragment) { + var children = output.children; + groups.push(...children); + } else { + groups.push(output); + } + } + // Combine consecutive domTree.symbolNodes into a single symbolNode. + tryCombineChars(groups); + // If `expression` is a partial group, let the parent handle spacings + // to avoid processing groups multiple times. + if (!isRealGroup) { + return groups; + } + var glueOptions = options; + if (expression.length === 1) { + var node = expression[0]; + if (node.type === "sizing") { + glueOptions = options.havingSize(node.size); + } else if (node.type === "styling") { + glueOptions = options.havingStyle(styleMap$1[node.style]); + } + } + // Dummy spans for determining spacings between surrounding atoms. + // If `expression` has no atoms on the left or right, class "leftmost" + // or "rightmost", respectively, is used to indicate it. + var dummyPrev = makeSpan([surrounding[0] || "leftmost"], [], options); + var dummyNext = makeSpan([surrounding[1] || "rightmost"], [], options); + // TODO: These code assumes that a node's math class is the first element + // of its `classes` array. A later cleanup should ensure this, for + // instance by changing the signature of `makeSpan`. + // Before determining what spaces to insert, perform bin cancellation. + // Binary operators change to ordinary symbols in some contexts. + var isRoot = isRealGroup === "root"; + _traverseNonSpaceNodes(groups, (node, prev) => { + var prevType = prev.classes[0]; + var type = node.classes[0]; + if (prevType === "mbin" && binRightCanceller.has(type)) { + prev.classes[0] = "mord"; + } else if (type === "mbin" && binLeftCanceller.has(prevType)) { + node.classes[0] = "mord"; + } + }, { + node: dummyPrev + }, dummyNext, isRoot); + _traverseNonSpaceNodes(groups, (node, prev) => { + var _tightSpacings$prevTy, _spacings$prevType; + var prevType = getTypeOfDomTree(prev); + var type = getTypeOfDomTree(node); + // 'mtight' indicates that the node is script or scriptscript style. + var space = prevType && type ? node.hasClass("mtight") ? (_tightSpacings$prevTy = tightSpacings[prevType]) == null ? void 0 : _tightSpacings$prevTy[type] : (_spacings$prevType = spacings[prevType]) == null ? void 0 : _spacings$prevType[type] : null; + if (space) { + // Insert glue (spacing) after the `prev`. + return makeGlue(space, glueOptions); + } + }, { + node: dummyPrev + }, dummyNext, isRoot); + return groups; +}; +// Depth-first traverse non-space `nodes`, calling `callback` with the current and +// previous node as arguments, optionally returning a node to insert after the +// previous node. `prev` is an object with the previous node and `insertAfter` +// function to insert after it. `next` is a node that will be added to the right. +// Used for bin cancellation and inserting spacings. +var _traverseNonSpaceNodes = function traverseNonSpaceNodes(nodes, callback, prev, next, isRoot) { + if (next) { + // temporarily append the right node, if exists + nodes.push(next); + } + var i = 0; + for (; i < nodes.length; i++) { + var node = nodes[i]; + var partialGroup = checkPartialGroup(node); + if (partialGroup) { + // Recursive DFS + // TODO(ts): partialGroup.children is ReadonlyArray but this + // function mutates the array (insertAfter splices into it). + _traverseNonSpaceNodes(partialGroup.children, callback, prev, null, isRoot); + continue; + } + // Ignore explicit spaces (e.g., \;, \,) when determining what implicit + // spacing should go between atoms of different classes + var nonspace = !node.hasClass("mspace"); + if (nonspace) { + var result = callback(node, prev.node); + if (result) { + if (prev.insertAfter) { + prev.insertAfter(result); + } else { + // insert at front + nodes.unshift(result); + i++; + } + } + } + if (nonspace) { + prev.node = node; + } else if (isRoot && node.hasClass("newline")) { + prev.node = makeSpan(["leftmost"]); // treat like beginning of line + } + prev.insertAfter = (index => n => { + nodes.splice(index + 1, 0, n); + i++; + })(i); + } + if (next) { + nodes.pop(); + } +}; +// Check if given node is a partial group, i.e., does not affect spacing around. +var checkPartialGroup = function checkPartialGroup(node) { + if (node instanceof DocumentFragment || node instanceof Anchor || node instanceof Span && node.hasClass("enclosing")) { + return node; + } + return null; +}; +// Return the outermost node of a domTree. +var _getOutermostNode = function getOutermostNode(node, side) { + var partialGroup = checkPartialGroup(node); + if (partialGroup) { + var children = partialGroup.children; + if (children.length) { + if (side === "right") { + return _getOutermostNode(children[children.length - 1], "right"); + } else if (side === "left") { + return _getOutermostNode(children[0], "left"); + } + } + } + return node; +}; +// Return math atom class (mclass) of a domTree. +// If `side` is given, it will get the type of the outermost node at given side. +var getTypeOfDomTree = function getTypeOfDomTree(node, side) { + if (!node) { + return null; + } + if (side) { + node = _getOutermostNode(node, side); + } + // This makes a lot of assumptions as to where the type of atom + // appears. We should do a better job of enforcing this. + var className = node.classes[0]; + return DomEnum[className] || null; +}; +var makeNullDelimiter = function makeNullDelimiter(options, classes) { + var moreClasses = ["nulldelimiter"].concat(options.baseSizingClasses()); + return makeSpan(classes.concat(moreClasses)); +}; +/** + * buildGroup is the function that takes a group and calls the correct groupType + * function for it. It also handles the interaction of size and style changes + * between parents and children. + */ +var buildGroup$1 = function buildGroup(group, options, baseOptions) { + if (!group) { + return makeSpan(); + } + if (_htmlGroupBuilders[group.type]) { + // TODO(ts): groupBuilders is Record>; + // a type-safe registry would need a mapped type keyed by NodeType. + var groupNode = _htmlGroupBuilders[group.type](group, options); + // If the size changed between the parent and the current group, account + // for that size difference. + if (baseOptions && options.size !== baseOptions.size) { + groupNode = makeSpan(options.sizingClasses(baseOptions), [groupNode], options); + var multiplier = options.sizeMultiplier / baseOptions.sizeMultiplier; + groupNode.height *= multiplier; + groupNode.depth *= multiplier; + } + return groupNode; + } else { + throw new ParseError("Got group of unknown type: '" + group.type + "'"); + } +}; +/** + * Combine an array of HTML DOM nodes (e.g., the output of `buildExpression`) + * into an unbreakable HTML node of class .base, with proper struts to + * guarantee correct vertical extent. `buildHTML` calls this repeatedly to + * make up the entire expression as a sequence of unbreakable units. + */ +function buildHTMLUnbreakable(children, options) { + // Compute height and depth of this chunk. + var body = makeSpan(["base"], children, options); + // Add strut, which ensures that the top of the HTML element falls at + // the height of the expression, and the bottom of the HTML element + // falls at the depth of the expression. + var strut = makeSpan(["strut"]); + strut.style.height = makeEm(body.height + body.depth); + if (body.depth) { + strut.style.verticalAlign = makeEm(-body.depth); + } + body.children.unshift(strut); + return body; +} +/** + * Take an entire parse tree, and build it into an appropriate set of HTML + * nodes. + */ +function buildHTML(tree, options) { + // Strip off outer tag wrapper for processing below. + var tag = null; + if (tree.length === 1 && tree[0].type === "tag") { + tag = tree[0].tag; + tree = tree[0].body; + } + // Build the expression contained in the tree + var expression = buildExpression$1(tree, options, "root"); + var eqnNum; + if (expression.length === 2 && expression[1].hasClass("tag")) { + // An environment with automatic equation numbers, e.g. {gather}. + eqnNum = expression.pop(); + } + var children = []; + // Create one base node for each chunk between potential line breaks. + // The TeXBook [p.173] says "A formula will be broken only after a + // relation symbol like $=$ or $<$ or $\rightarrow$, or after a binary + // operation symbol like $+$ or $-$ or $\times$, where the relation or + // binary operation is on the ``outer level'' of the formula (i.e., not + // enclosed in {...} and not part of an \over construction)." + var parts = []; + for (var i = 0; i < expression.length; i++) { + parts.push(expression[i]); + if (expression[i].hasClass("mbin") || expression[i].hasClass("mrel") || expression[i].hasClass("allowbreak")) { + // Put any post-operator glue on same line as operator. + // Watch for \nobreak along the way, and stop at \newline. + var nobreak = false; + while (i < expression.length - 1 && expression[i + 1].hasClass("mspace") && !expression[i + 1].hasClass("newline")) { + i++; + parts.push(expression[i]); + if (expression[i].hasClass("nobreak")) { + nobreak = true; + } + } + // Don't allow break if \nobreak among the post-operator glue. + if (!nobreak) { + children.push(buildHTMLUnbreakable(parts, options)); + parts = []; + } + } else if (expression[i].hasClass("newline")) { + // Write the line except the newline + parts.pop(); + if (parts.length > 0) { + children.push(buildHTMLUnbreakable(parts, options)); + parts = []; + } + // Put the newline at the top level + children.push(expression[i]); + } + } + if (parts.length > 0) { + children.push(buildHTMLUnbreakable(parts, options)); + } + // Now, if there was a tag, build it too and append it as a final child. + var tagChild; + if (tag) { + tagChild = buildHTMLUnbreakable(buildExpression$1(tag, options, true), options); + tagChild.classes = ["tag"]; + children.push(tagChild); + } else if (eqnNum) { + children.push(eqnNum); + } + var htmlNode = makeSpan(["katex-html"], children); + htmlNode.setAttribute("aria-hidden", "true"); + // Adjust the strut of the tag to be the maximum height of all children + // (the height of the enclosing htmlNode) for proper vertical alignment. + if (tagChild) { + var strut = tagChild.children[0]; + strut.style.height = makeEm(htmlNode.height + htmlNode.depth); + if (htmlNode.depth) { + strut.style.verticalAlign = makeEm(-htmlNode.depth); + } + } + return htmlNode; +} + +/** + * These objects store data about MathML nodes. This is the MathML equivalent + * of the types in domTree.js. Since MathML handles its own rendering, and + * since we're mainly using MathML to improve accessibility, we don't manage + * any of the styling state that the plain DOM nodes do. + * + * The `toNode` and `toMarkup` functions work similarly to how they do in + * domTree.js, creating namespaced DOM nodes and HTML text markup respectively. + */ +function newDocumentFragment(children) { + return new DocumentFragment(children); +} +/** + * This node represents a general purpose MathML node of any type. The + * constructor requires the type of node to create (for example, `"mo"` or + * `"mspace"`, corresponding to `` and `` tags). + */ +class MathNode { + constructor(type, children, classes) { + this.type = void 0; + this.attributes = void 0; + this.children = void 0; + this.classes = void 0; + this.type = type; + this.attributes = {}; + this.children = children || []; + this.classes = classes || []; + } + /** + * Sets an attribute on a MathML node. MathML depends on attributes to convey a + * semantic content, so this is used heavily. + */ + setAttribute(name, value) { + this.attributes[name] = value; + } + /** + * Gets an attribute on a MathML node. + */ + getAttribute(name) { + return this.attributes[name]; + } + /** + * Converts the math node into a MathML-namespaced DOM element. + */ + toNode() { + var node = document.createElementNS("http://www.w3.org/1998/Math/MathML", this.type); + for (var attr in this.attributes) { + if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) { + node.setAttribute(attr, this.attributes[attr]); + } + } + if (this.classes.length > 0) { + node.className = createClass(this.classes); + } + for (var i = 0; i < this.children.length; i++) { + // Combine multiple TextNodes into one TextNode, to prevent + // screen readers from reading each as a separate word [#3995] + if (this.children[i] instanceof TextNode && this.children[i + 1] instanceof TextNode) { + var text = this.children[i].toText() + this.children[++i].toText(); + while (this.children[i + 1] instanceof TextNode) { + text += this.children[++i].toText(); + } + node.appendChild(new TextNode(text).toNode()); + } else { + node.appendChild(this.children[i].toNode()); + } + } + return node; + } + /** + * Converts the math node into an HTML markup string. + */ + toMarkup() { + var markup = "<" + this.type; + // Add the attributes + for (var attr in this.attributes) { + if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) { + markup += " " + attr + "=\""; + markup += escape(this.attributes[attr]); + markup += "\""; + } + } + if (this.classes.length > 0) { + markup += " class =\"" + escape(createClass(this.classes)) + "\""; + } + markup += ">"; + for (var i = 0; i < this.children.length; i++) { + markup += this.children[i].toMarkup(); + } + markup += ""; + return markup; + } + /** + * Converts the math node into a string, similar to innerText, but escaped. + */ + toText() { + return this.children.map(child => child.toText()).join(""); + } +} +/** + * This node represents a piece of text. + */ +class TextNode { + constructor(text) { + this.text = void 0; + this.text = text; + } + /** + * Converts the text node into a DOM text node. + */ + toNode() { + return document.createTextNode(this.text); + } + /** + * Converts the text node into escaped HTML markup + * (representing the text itself). + */ + toMarkup() { + return escape(this.toText()); + } + /** + * Converts the text node into a string + * (representing the text itself). + */ + toText() { + return this.text; + } +} +/** + * This node represents a space, but may render as or as text, + * depending on the width. + */ +class SpaceNode { + /** + * Create a Space node with width given in CSS ems. + */ + constructor(width) { + this.width = void 0; + this.character = void 0; + this.width = width; + // See https://www.w3.org/TR/2000/WD-MathML2-20000328/chapter6.html + // for a table of space-like characters. We use Unicode + // representations instead of &LongNames; as it's not clear how to + // make the latter via document.createTextNode. + if (width >= 0.05555 && width <= 0.05556) { + this.character = "\u200a"; //   + } else if (width >= 0.1666 && width <= 0.1667) { + this.character = "\u2009"; //   + } else if (width >= 0.2222 && width <= 0.2223) { + this.character = "\u2005"; //   + } else if (width >= 0.2777 && width <= 0.2778) { + this.character = "\u2005\u200a"; //    + } else if (width >= -0.05556 && width <= -0.05555) { + this.character = "\u200a\u2063"; // ​ + } else if (width >= -0.1667 && width <= -0.1666) { + this.character = "\u2009\u2063"; // ​ + } else if (width >= -0.2223 && width <= -0.2222) { + this.character = "\u205f\u2063"; // ​ + } else if (width >= -0.2778 && width <= -0.2777) { + this.character = "\u2005\u2063"; // ​ + } else { + this.character = null; + } + } + /** + * Converts the math node into a MathML-namespaced DOM element. + */ + toNode() { + if (this.character) { + return document.createTextNode(this.character); + } else { + var node = document.createElementNS("http://www.w3.org/1998/Math/MathML", "mspace"); + node.setAttribute("width", makeEm(this.width)); + return node; + } + } + /** + * Converts the math node into an HTML markup string. + */ + toMarkup() { + if (this.character) { + return "" + this.character + ""; + } else { + return ""; + } + } + /** + * Converts the math node into a string, similar to innerText. + */ + toText() { + if (this.character) { + return this.character; + } else { + return " "; + } + } +} + +/** + * This file converts a parse tree into a corresponding MathML tree. The main + * entry point is the `buildMathML` function, which takes a parse tree from the + * parser. + */ +var noVariantSymbols = new Set(["\\imath", "\\jmath"]); +var rowLikeTypes = new Set(["mrow", "mtable"]); +/** + * Takes a symbol and converts it into a MathML text node after performing + * optional replacement from symbols.js. + */ +var makeText = function makeText(text, mode, options) { + if (symbols[mode][text] && symbols[mode][text].replace && text.charCodeAt(0) !== 0xD835 && !(ligatures.hasOwnProperty(text) && options && (options.fontFamily && options.fontFamily.slice(4, 6) === "tt" || options.font && options.font.slice(4, 6) === "tt"))) { + text = symbols[mode][text].replace; + } + return new TextNode(text); +}; +/** + * Wrap the given array of nodes in an node if needed, i.e., + * unless the array has length 1. Always returns a single node. + */ +var makeRow = function makeRow(body) { + if (body.length === 1) { + return body[0]; + } else { + return new MathNode("mrow", body); + } +}; +var mathFontVariants = { + mathit: "italic", + boldsymbol: group => group.type === "textord" ? "bold" : "bold-italic", + mathbf: "bold", + mathbb: "double-struck", + mathsfit: "sans-serif-italic", + mathfrak: "fraktur", + mathscr: "script", + mathcal: "script", + mathsf: "sans-serif", + mathtt: "monospace" +}; +/** + * Returns the math variant as a string or null if none is required. + */ +var getVariant = (group, options) => { + // Handle \text... font specifiers as best we can. + // MathML has a limited list of allowable mathvariant specifiers; see + // https://www.w3.org/TR/MathML3/chapter3.html#presm.commatt + if (group.mode === "text") { + if (options.fontFamily === "texttt") { + return "monospace"; + } else if (options.fontFamily === "textsf") { + if (options.fontShape === "textit" && options.fontWeight === "textbf") { + return "sans-serif-bold-italic"; + } else if (options.fontShape === "textit") { + return "sans-serif-italic"; + } else if (options.fontWeight === "textbf") { + return "bold-sans-serif"; + } else { + return "sans-serif"; + } + } else if (options.fontShape === "textit" && options.fontWeight === "textbf") { + return "bold-italic"; + } else if (options.fontShape === "textit") { + return "italic"; + } else if (options.fontWeight === "textbf") { + return "bold"; + } + } + var font = options.font; + if (!font || font === "mathnormal") { + return null; + } + var mode = group.mode; + var mathVariant = mathFontVariants[font]; + if (mathVariant) { + return typeof mathVariant === "function" ? mathVariant(group) : mathVariant; + } + var text = group.text; + if (noVariantSymbols.has(text)) { + return null; + } + if (symbols[mode][text]) { + var replacement = symbols[mode][text].replace; + if (replacement) { + text = replacement; + } + } + var fontName = fontMap[font].fontName; + if (getCharacterMetrics(text, fontName, mode)) { + return fontMap[font].variant; + } + return null; +}; +/** + * Check for . which is how a dot renders in MathML, + * or , + * which is how a braced comma {,} renders in MathML + */ +function isNumberPunctuation(group) { + if (!group) { + return false; + } + if (group.type === 'mi' && group.children.length === 1) { + var child = group.children[0]; + return child instanceof TextNode && child.text === '.'; + } else if (group.type === 'mo' && group.children.length === 1 && group.getAttribute('separator') === 'true' && group.getAttribute('lspace') === '0em' && group.getAttribute('rspace') === '0em') { + var _child = group.children[0]; + return _child instanceof TextNode && _child.text === ','; + } else { + return false; + } +} +/** + * Takes a list of nodes, builds them, and returns a list of the generated + * MathML nodes. Also combine consecutive outputs into a single + * tag. + */ +var buildExpression = function buildExpression(expression, options, isOrdgroup) { + if (expression.length === 1) { + var group = buildGroup(expression[0], options); + if (isOrdgroup && group instanceof MathNode && group.type === "mo") { + // When TeX writers want to suppress spacing on an operator, + // they often put the operator by itself inside braces. + group.setAttribute("lspace", "0em"); + group.setAttribute("rspace", "0em"); + } + return [group]; + } + var groups = []; + var lastGroup; + for (var i = 0; i < expression.length; i++) { + var _group = buildGroup(expression[i], options); + if (_group instanceof MathNode && lastGroup instanceof MathNode) { + // Concatenate adjacent s + if (_group.type === 'mtext' && lastGroup.type === 'mtext' && _group.getAttribute('mathvariant') === lastGroup.getAttribute('mathvariant')) { + lastGroup.children.push(..._group.children); + continue; + // Concatenate adjacent s + } else if (_group.type === 'mn' && lastGroup.type === 'mn') { + lastGroup.children.push(..._group.children); + continue; + // Concatenate ... followed by . + } else if (isNumberPunctuation(_group) && lastGroup.type === 'mn') { + lastGroup.children.push(..._group.children); + continue; + // Concatenate . followed by ... + } else if (_group.type === 'mn' && isNumberPunctuation(lastGroup)) { + _group.children = [...lastGroup.children, ..._group.children]; + groups.pop(); + // Put preceding ... or . inside base of + // ...base......exponent... (or ) + } else if ((_group.type === 'msup' || _group.type === 'msub') && _group.children.length >= 1 && (lastGroup.type === 'mn' || isNumberPunctuation(lastGroup))) { + var base = _group.children[0]; + if (base instanceof MathNode && base.type === 'mn') { + base.children = [...lastGroup.children, ...base.children]; + groups.pop(); + } + // \not + } else if (lastGroup.type === 'mi' && lastGroup.children.length === 1) { + var lastChild = lastGroup.children[0]; + if (lastChild instanceof TextNode && lastChild.text === '\u0338' && (_group.type === 'mo' || _group.type === 'mi' || _group.type === 'mn')) { + var child = _group.children[0]; + if (child instanceof TextNode && child.text.length > 0) { + // Overlay with combining character long solidus + child.text = child.text.slice(0, 1) + "\u0338" + child.text.slice(1); + groups.pop(); + } + } + } + } + groups.push(_group); + lastGroup = _group; + } + return groups; +}; +/** + * Equivalent to buildExpression, but wraps the elements in an + * if there's more than one. Returns a single node instead of an array. + */ +var buildExpressionRow = function buildExpressionRow(expression, options, isOrdgroup) { + return makeRow(buildExpression(expression, options, isOrdgroup)); +}; +/** + * Takes a group from the parser and calls the appropriate groupBuilders function + * on it to produce a MathML node. + */ +var buildGroup = function buildGroup(group, options) { + if (!group) { + return new MathNode("mrow"); + } + if (_mathmlGroupBuilders[group.type]) { + // TODO(ts): MathMLBuilder returns MathDomNode but all concrete + // builders return MathNode. Widening the return type here would + // require updating all callers that assume MathNode. + return _mathmlGroupBuilders[group.type](group, options); + } else { + throw new ParseError("Got group of unknown type: '" + group.type + "'"); + } +}; +/** + * Takes a full parse tree and settings and builds a MathML representation of + * it. In particular, we put the elements from building the parse tree into a + * tag so we can also include that TeX source as an annotation. + * + * Note that we actually return a domTree element with a `` inside it so + * we can do appropriate styling. + */ +function buildMathML(tree, texExpression, options, isDisplayMode, forMathmlOnly) { + var expression = buildExpression(tree, options); + // TODO: Make a pass thru the MathML similar to buildHTML.traverseNonSpaceNodes + // and add spacing nodes. This is necessary only adjacent to math operators + // like \sin or \lim or to subsup elements that contain math operators. + // MathML takes care of the other spacing issues. + // Wrap up the expression in an mrow so it is presented in the semantics + // tag correctly, unless it's a single or . + var wrapper; + if (expression.length === 1 && expression[0] instanceof MathNode && rowLikeTypes.has(expression[0].type)) { + wrapper = expression[0]; + } else { + wrapper = new MathNode("mrow", expression); + } + // Build a TeX annotation of the source + var annotation = new MathNode("annotation", [new TextNode(texExpression)]); + annotation.setAttribute("encoding", "application/x-tex"); + var semantics = new MathNode("semantics", [wrapper, annotation]); + var math = new MathNode("math", [semantics]); + math.setAttribute("xmlns", "http://www.w3.org/1998/Math/MathML"); + if (isDisplayMode) { + math.setAttribute("display", "block"); + } + // You can't style nodes, so we wrap the node in a span. + // NOTE: The span class is not typed to have nodes as children, and + // we don't want to make the children type more generic since the children + // of span are expected to have more fields in `buildHtml` contexts. + // The MathNode implements VirtualNode (toNode/toMarkup) which is all that + // Span needs from its children for rendering. + // TODO(ts): Span's child type is HtmlDomNode, but MathNode only implements + // VirtualNode. The double-cast acknowledges this architectural limitation. + var wrapperClass = forMathmlOnly ? "katex" : "katex-mathml"; + return makeSpan([wrapperClass], [math]); +} + +/** + * This file contains information about the options that the Parser carries + * around with it while parsing. Data is held in an `Options` object, and when + * recursing, a new `Options` object can be created with the `.with*` and + * `.reset` functions. + */ +var sizeStyleMap = [ +// Each element contains [textsize, scriptsize, scriptscriptsize]. +// The size mappings are taken from TeX with \normalsize=10pt. +[1, 1, 1], +// size1: [5, 5, 5] \tiny +[2, 1, 1], +// size2: [6, 5, 5] +[3, 1, 1], +// size3: [7, 5, 5] \scriptsize +[4, 2, 1], +// size4: [8, 6, 5] \footnotesize +[5, 2, 1], +// size5: [9, 6, 5] \small +[6, 3, 1], +// size6: [10, 7, 5] \normalsize +[7, 4, 2], +// size7: [12, 8, 6] \large +[8, 6, 3], +// size8: [14.4, 10, 7] \Large +[9, 7, 6], +// size9: [17.28, 12, 10] \LARGE +[10, 8, 7], +// size10: [20.74, 14.4, 12] \huge +[11, 10, 9] // size11: [24.88, 20.74, 17.28] \HUGE +]; +var sizeMultipliers = [ +// fontMetrics.js:getGlobalMetrics also uses size indexes, so if +// you change size indexes, change that function. +0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.2, 1.44, 1.728, 2.074, 2.488]; +var sizeAtStyle = function sizeAtStyle(size, style) { + return style.size < 2 ? size : sizeStyleMap[size - 1][style.size - 1]; +}; +/** + * This is the main options class. It contains the current style, size, color, + * and font. + * + * Options objects should not be modified. To create a new Options with + * different properties, call a `.having*` method. + */ +class Options { + constructor(data) { + this.style = void 0; + this.color = void 0; + this.size = void 0; + this.textSize = void 0; + this.phantom = void 0; + // A font family applies to a group of fonts (i.e. SansSerif), while a font + // represents a specific font (i.e. SansSerif Bold). + // See: https://tex.stackexchange.com/questions/22350/difference-between-textrm-and-mathrm + this.font = void 0; + this.fontFamily = void 0; + this.fontWeight = void 0; + this.fontShape = void 0; + this.sizeMultiplier = void 0; + this.maxSize = void 0; + this.minRuleThickness = void 0; + this._fontMetrics = void 0; + this.style = data.style; + this.color = data.color; + this.size = data.size || Options.BASESIZE; + this.textSize = data.textSize || this.size; + this.phantom = !!data.phantom; + this.font = data.font || ""; + this.fontFamily = data.fontFamily || ""; + this.fontWeight = data.fontWeight || ""; + this.fontShape = data.fontShape || ""; + this.sizeMultiplier = sizeMultipliers[this.size - 1]; + this.maxSize = data.maxSize; + this.minRuleThickness = data.minRuleThickness; + this._fontMetrics = undefined; + } + /** + * Returns a new options object with the same properties as "this". Properties + * from "extension" will be copied to the new options object. + */ + extend(extension) { + var data = { + style: this.style, + size: this.size, + textSize: this.textSize, + color: this.color, + phantom: this.phantom, + font: this.font, + fontFamily: this.fontFamily, + fontWeight: this.fontWeight, + fontShape: this.fontShape, + maxSize: this.maxSize, + minRuleThickness: this.minRuleThickness + }; + Object.assign(data, extension); + return new Options(data); + } + /** + * Return an options object with the given style. If `this.style === style`, + * returns `this`. + */ + havingStyle(style) { + if (this.style === style) { + return this; + } else { + return this.extend({ + style: style, + size: sizeAtStyle(this.textSize, style) + }); + } + } + /** + * Return an options object with a cramped version of the current style. If + * the current style is cramped, returns `this`. + */ + havingCrampedStyle() { + return this.havingStyle(this.style.cramp()); + } + /** + * Return an options object with the given size and in at least `\textstyle`. + * Returns `this` if appropriate. + */ + havingSize(size) { + if (this.size === size && this.textSize === size) { + return this; + } else { + return this.extend({ + style: this.style.text(), + size: size, + textSize: size, + sizeMultiplier: sizeMultipliers[size - 1] + }); + } + } + /** + * Like `this.havingSize(BASESIZE).havingStyle(style)`. If `style` is omitted, + * changes to at least `\textstyle`. + */ + havingBaseStyle(style) { + style = style || this.style.text(); + var wantSize = sizeAtStyle(Options.BASESIZE, style); + if (this.size === wantSize && this.textSize === Options.BASESIZE && this.style === style) { + return this; + } else { + return this.extend({ + style: style, + size: wantSize + }); + } + } + /** + * Remove the effect of sizing changes such as \Huge. + * Keep the effect of the current style, such as \scriptstyle. + */ + havingBaseSizing() { + var size; + switch (this.style.id) { + case 4: + case 5: + size = 3; // normalsize in scriptstyle + break; + case 6: + case 7: + size = 1; // normalsize in scriptscriptstyle + break; + default: + size = 6; + // normalsize in textstyle or displaystyle + } + return this.extend({ + style: this.style.text(), + size: size + }); + } + /** + * Create a new options object with the given color. + */ + withColor(color) { + return this.extend({ + color: color + }); + } + /** + * Create a new options object with "phantom" set to true. + */ + withPhantom() { + return this.extend({ + phantom: true + }); + } + /** + * Creates a new options object with the given math font or old text font. + * @type {[type]} + */ + withFont(font) { + return this.extend({ + font + }); + } + /** + * Create a new options objects with the given fontFamily. + */ + withTextFontFamily(fontFamily) { + return this.extend({ + fontFamily, + font: "" + }); + } + /** + * Creates a new options object with the given font weight + */ + withTextFontWeight(fontWeight) { + return this.extend({ + fontWeight, + font: "" + }); + } + /** + * Creates a new options object with the given font weight + */ + withTextFontShape(fontShape) { + return this.extend({ + fontShape, + font: "" + }); + } + /** + * Return the CSS sizing classes required to switch from enclosing options + * `oldOptions` to `this`. Returns an array of classes. + */ + sizingClasses(oldOptions) { + if (oldOptions.size !== this.size) { + return ["sizing", "reset-size" + oldOptions.size, "size" + this.size]; + } else { + return []; + } + } + /** + * Return the CSS sizing classes required to switch to the base size. Like + * `this.havingSize(BASESIZE).sizingClasses(this)`. + */ + baseSizingClasses() { + if (this.size !== Options.BASESIZE) { + return ["sizing", "reset-size" + this.size, "size" + Options.BASESIZE]; + } else { + return []; + } + } + /** + * Return the font metrics for this size. + */ + fontMetrics() { + if (!this._fontMetrics) { + this._fontMetrics = getGlobalMetrics(this.size); + } + return this._fontMetrics; + } + /** + * Gets the CSS color of the current options object + */ + getColor() { + if (this.phantom) { + return "transparent"; + } else { + return this.color; + } + } +} +/** + * The base size index. + */ +Options.BASESIZE = 6; + +var optionsFromSettings = function optionsFromSettings(settings) { + return new Options({ + style: settings.displayMode ? Style$1.DISPLAY : Style$1.TEXT, + maxSize: settings.maxSize, + minRuleThickness: settings.minRuleThickness + }); +}; +var displayWrap = function displayWrap(node, settings) { + if (settings.displayMode) { + var classes = ["katex-display"]; + if (settings.leqno) { + classes.push("leqno"); + } + if (settings.fleqn) { + classes.push("fleqn"); + } + node = makeSpan(classes, [node]); + } + return node; +}; +var buildTree = function buildTree(tree, expression, settings) { + var options = optionsFromSettings(settings); + var katexNode; + if (settings.output === "mathml") { + return buildMathML(tree, expression, options, settings.displayMode, true); + } else if (settings.output === "html") { + var htmlNode = buildHTML(tree, options); + katexNode = makeSpan(["katex"], [htmlNode]); + } else { + var mathMLNode = buildMathML(tree, expression, options, settings.displayMode, false); + var _htmlNode = buildHTML(tree, options); + katexNode = makeSpan(["katex"], [mathMLNode, _htmlNode]); + } + return displayWrap(katexNode, settings); +}; +var buildHTMLTree = function buildHTMLTree(tree, expression, settings) { + var options = optionsFromSettings(settings); + var htmlNode = buildHTML(tree, options); + var katexNode = makeSpan(["katex"], [htmlNode]); + return displayWrap(katexNode, settings); +}; + +/** + * This file provides support to buildMathML.js and buildHTML.js + * for stretchy wide elements rendered from SVG files + * and other CSS trickery. + */ +var stretchyCodePoint = { + widehat: "^", + widecheck: "ˇ", + widetilde: "~", + utilde: "~", + overleftarrow: "\u2190", + underleftarrow: "\u2190", + xleftarrow: "\u2190", + overrightarrow: "\u2192", + underrightarrow: "\u2192", + xrightarrow: "\u2192", + underbrace: "\u23df", + overbrace: "\u23de", + underbracket: "\u23b5", + overbracket: "\u23b4", + overgroup: "\u23e0", + undergroup: "\u23e1", + overleftrightarrow: "\u2194", + underleftrightarrow: "\u2194", + xleftrightarrow: "\u2194", + Overrightarrow: "\u21d2", + xRightarrow: "\u21d2", + overleftharpoon: "\u21bc", + xleftharpoonup: "\u21bc", + overrightharpoon: "\u21c0", + xrightharpoonup: "\u21c0", + xLeftarrow: "\u21d0", + xLeftrightarrow: "\u21d4", + xhookleftarrow: "\u21a9", + xhookrightarrow: "\u21aa", + xmapsto: "\u21a6", + xrightharpoondown: "\u21c1", + xleftharpoondown: "\u21bd", + xrightleftharpoons: "\u21cc", + xleftrightharpoons: "\u21cb", + xtwoheadleftarrow: "\u219e", + xtwoheadrightarrow: "\u21a0", + xlongequal: "=", + xtofrom: "\u21c4", + xrightleftarrows: "\u21c4", + xrightequilibrium: "\u21cc", + // Not a perfect match. + xleftequilibrium: "\u21cb", + // None better available. + "\\cdrightarrow": "\u2192", + "\\cdleftarrow": "\u2190", + "\\cdlongequal": "=" +}; +var stretchyMathML = function stretchyMathML(label) { + var node = new MathNode("mo", [new TextNode(stretchyCodePoint[label.replace(/^\\/, '')])]); + node.setAttribute("stretchy", "true"); + return node; +}; +var katexImagesData = { + // path(s), minWidth, height, align + overrightarrow: [["rightarrow"], 0.888, 522, "xMaxYMin"], + overleftarrow: [["leftarrow"], 0.888, 522, "xMinYMin"], + underrightarrow: [["rightarrow"], 0.888, 522, "xMaxYMin"], + underleftarrow: [["leftarrow"], 0.888, 522, "xMinYMin"], + xrightarrow: [["rightarrow"], 1.469, 522, "xMaxYMin"], + "\\cdrightarrow": [["rightarrow"], 3.0, 522, "xMaxYMin"], + // CD minwwidth2.5pc + xleftarrow: [["leftarrow"], 1.469, 522, "xMinYMin"], + "\\cdleftarrow": [["leftarrow"], 3.0, 522, "xMinYMin"], + Overrightarrow: [["doublerightarrow"], 0.888, 560, "xMaxYMin"], + xRightarrow: [["doublerightarrow"], 1.526, 560, "xMaxYMin"], + xLeftarrow: [["doubleleftarrow"], 1.526, 560, "xMinYMin"], + overleftharpoon: [["leftharpoon"], 0.888, 522, "xMinYMin"], + xleftharpoonup: [["leftharpoon"], 0.888, 522, "xMinYMin"], + xleftharpoondown: [["leftharpoondown"], 0.888, 522, "xMinYMin"], + overrightharpoon: [["rightharpoon"], 0.888, 522, "xMaxYMin"], + xrightharpoonup: [["rightharpoon"], 0.888, 522, "xMaxYMin"], + xrightharpoondown: [["rightharpoondown"], 0.888, 522, "xMaxYMin"], + xlongequal: [["longequal"], 0.888, 334, "xMinYMin"], + "\\cdlongequal": [["longequal"], 3.0, 334, "xMinYMin"], + xtwoheadleftarrow: [["twoheadleftarrow"], 0.888, 334, "xMinYMin"], + xtwoheadrightarrow: [["twoheadrightarrow"], 0.888, 334, "xMaxYMin"], + overleftrightarrow: [["leftarrow", "rightarrow"], 0.888, 522], + overbrace: [["leftbrace", "midbrace", "rightbrace"], 1.6, 548], + underbrace: [["leftbraceunder", "midbraceunder", "rightbraceunder"], 1.6, 548], + underleftrightarrow: [["leftarrow", "rightarrow"], 0.888, 522], + xleftrightarrow: [["leftarrow", "rightarrow"], 1.75, 522], + xLeftrightarrow: [["doubleleftarrow", "doublerightarrow"], 1.75, 560], + xrightleftharpoons: [["leftharpoondownplus", "rightharpoonplus"], 1.75, 716], + xleftrightharpoons: [["leftharpoonplus", "rightharpoondownplus"], 1.75, 716], + xhookleftarrow: [["leftarrow", "righthook"], 1.08, 522], + xhookrightarrow: [["lefthook", "rightarrow"], 1.08, 522], + overlinesegment: [["leftlinesegment", "rightlinesegment"], 0.888, 522], + underlinesegment: [["leftlinesegment", "rightlinesegment"], 0.888, 522], + overbracket: [["leftbracketover", "rightbracketover"], 1.6, 440], + underbracket: [["leftbracketunder", "rightbracketunder"], 1.6, 410], + overgroup: [["leftgroup", "rightgroup"], 0.888, 342], + undergroup: [["leftgroupunder", "rightgroupunder"], 0.888, 342], + xmapsto: [["leftmapsto", "rightarrow"], 1.5, 522], + xtofrom: [["leftToFrom", "rightToFrom"], 1.75, 528], + // The next three arrows are from the mhchem package. + // In mhchem.sty, min-length is 2.0em. But these arrows might appear in the + // document as \xrightarrow or \xrightleftharpoons. Those have + // min-length = 1.75em, so we set min-length on these next three to match. + xrightleftarrows: [["baraboveleftarrow", "rightarrowabovebar"], 1.75, 901], + xrightequilibrium: [["baraboveshortleftharpoon", "rightharpoonaboveshortbar"], 1.75, 716], + xleftequilibrium: [["shortbaraboveleftharpoon", "shortrightharpoonabovebar"], 1.75, 716] +}; +var wideAccentLabels = new Set(["widehat", "widecheck", "widetilde", "utilde"]); +var stretchySvg = function stretchySvg(group, options) { + // Create a span with inline SVG for the element. + function buildSvgSpan_() { + var viewBoxWidth = 400000; // default + var label = group.label.slice(1); + if (wideAccentLabels.has(label) && 'base' in group) { + // There are four SVG images available for each function. + // Choose a taller image when there are more characters. + var numChars = group.base.type === "ordgroup" ? group.base.body.length : 1; + var viewBoxHeight; + var pathName; + var _height; + if (numChars > 5) { + if (label === "widehat" || label === "widecheck") { + viewBoxHeight = 420; + viewBoxWidth = 2364; + _height = 0.42; + pathName = label + "4"; + } else { + viewBoxHeight = 312; + viewBoxWidth = 2340; + _height = 0.34; + pathName = "tilde4"; + } + } else { + var imgIndex = [1, 1, 2, 2, 3, 3][numChars]; + if (label === "widehat" || label === "widecheck") { + viewBoxWidth = [0, 1062, 2364, 2364, 2364][imgIndex]; + viewBoxHeight = [0, 239, 300, 360, 420][imgIndex]; + _height = [0, 0.24, 0.3, 0.3, 0.36, 0.42][imgIndex]; + pathName = label + imgIndex; + } else { + viewBoxWidth = [0, 600, 1033, 2339, 2340][imgIndex]; + viewBoxHeight = [0, 260, 286, 306, 312][imgIndex]; + _height = [0, 0.26, 0.286, 0.3, 0.306, 0.34][imgIndex]; + pathName = "tilde" + imgIndex; + } + } + var path = new PathNode(pathName); + var svgNode = new SvgNode([path], { + "width": "100%", + "height": makeEm(_height), + "viewBox": "0 0 " + viewBoxWidth + " " + viewBoxHeight, + "preserveAspectRatio": "none" + }); + return { + span: makeSvgSpan([], [svgNode], options), + minWidth: 0, + height: _height + }; + } else { + var spans = []; + var data = katexImagesData[label]; + if (!data) { + throw new Error("No SVG data for \"" + label + "\"."); + } + var [paths, _minWidth, _viewBoxHeight] = data; + var _height2 = _viewBoxHeight / 1000; + var numSvgChildren = paths.length; + var widthClasses; + var aligns; + if (numSvgChildren === 1) { + if (data.length !== 4) { + throw new Error("Expected 4-tuple for single-path SVG data \"" + label + "\"."); + } + widthClasses = ["hide-tail"]; + aligns = [data[3]]; + } else if (numSvgChildren === 2) { + widthClasses = ["halfarrow-left", "halfarrow-right"]; + aligns = ["xMinYMin", "xMaxYMin"]; + } else if (numSvgChildren === 3) { + widthClasses = ["brace-left", "brace-center", "brace-right"]; + aligns = ["xMinYMin", "xMidYMin", "xMaxYMin"]; + } else { + throw new Error("Correct katexImagesData or update code here to support\n " + numSvgChildren + " children."); + } + for (var i = 0; i < numSvgChildren; i++) { + var _path = new PathNode(paths[i]); + var _svgNode = new SvgNode([_path], { + "width": "400em", + "height": makeEm(_height2), + "viewBox": "0 0 " + viewBoxWidth + " " + _viewBoxHeight, + "preserveAspectRatio": aligns[i] + " slice" + }); + var _span = makeSvgSpan([widthClasses[i]], [_svgNode], options); + if (numSvgChildren === 1) { + return { + span: _span, + minWidth: _minWidth, + height: _height2 + }; + } else { + _span.style.height = makeEm(_height2); + spans.push(_span); + } + } + return { + span: makeSpan(["stretchy"], spans, options), + minWidth: _minWidth, + height: _height2 + }; + } + } // buildSvgSpan_() + var { + span, + minWidth, + height + } = buildSvgSpan_(); + // Note that we are returning span.depth = 0. + // Any adjustments relative to the baseline must be done in buildHTML. + span.height = height; + span.style.height = makeEm(height); + if (minWidth > 0) { + span.style.minWidth = makeEm(minWidth); + } + return span; +}; +var stretchyEnclose = function stretchyEnclose(inner, label, topPad, bottomPad, options) { + // Return an image span for \cancel, \bcancel, \xcancel, \fbox, or \angl + var img; + var totalHeight = inner.height + inner.depth + topPad + bottomPad; + if (/fbox|color|angl/.test(label)) { + img = makeSpan(["stretchy", label], [], options); + if (label === "fbox") { + var color = options.color && options.getColor(); + if (color) { + img.style.borderColor = color; + } + } + } else { + // \cancel, \bcancel, or \xcancel + // Since \cancel's SVG is inline and it omits the viewBox attribute, + // its stroke-width will not vary with span area. + var lines = []; + if (/^[bx]cancel$/.test(label)) { + lines.push(new LineNode({ + "x1": "0", + "y1": "0", + "x2": "100%", + "y2": "100%", + "stroke-width": "0.046em" + })); + } + if (/^x?cancel$/.test(label)) { + lines.push(new LineNode({ + "x1": "0", + "y1": "100%", + "x2": "100%", + "y2": "0", + "stroke-width": "0.046em" + })); + } + var svgNode = new SvgNode(lines, { + "width": "100%", + "height": makeEm(totalHeight) + }); + img = makeSvgSpan([], [svgNode], options); + } + img.height = totalHeight; + img.style.height = makeEm(totalHeight); + return img; +}; + +/** + * Small module for atom-group constants and type guard. Kept separate from + * `symbols.ts` so that consumers (notably `contrib/render-a11y-string`) can + * pull in `isAtom` without dragging in the ~870-line symbol tables. + */ +// Some of these have a "-token" suffix since these are also used as `ParseNode` +// types for raw text tokens, and we want to avoid conflicts with higher-level +// `ParseNode` types. These `ParseNode`s are constructed within `Parser` by +// looking up the `symbols` map. +var ATOMS = { + "bin": 1, + "close": 1, + "inner": 1, + "open": 1, + "punct": 1, + "rel": 1 +}; +var NON_ATOMS = { + "accent-token": 1, + "mathord": 1, + "op-token": 1, + "spacing": 1, + "textord": 1 +}; +function isAtom(value) { + return value in ATOMS; +} + +/** + * Asserts that the node is of the given type and returns it with stricter + * typing. Throws if the node's type does not match. + */ +function assertNodeType(node, type) { + if (!node || node.type !== type) { + throw new Error("Expected node of type " + type + ", but got " + (node ? "node of type " + node.type : String(node))); + } + return node; +} +/** + * Returns the node more strictly typed iff it is of the given type. Otherwise, + * returns null. + */ +function assertSymbolNodeType(node) { + var typedNode = checkSymbolNodeType(node); + if (!typedNode) { + throw new Error("Expected node of symbol group type, but got " + (node ? "node of type " + node.type : String(node))); + } + return typedNode; +} +/** + * Returns the node more strictly typed iff it is of the given type. Otherwise, + * returns null. + */ +function checkSymbolNodeType(node) { + if (node && (node.type === "atom" || NON_ATOMS.hasOwnProperty(node.type))) { + return node; + } + return null; +} + +var getBaseSymbol = group => { + if (group instanceof SymbolNode) { + return group; + } + if (hasHtmlDomChildren(group) && group.children.length === 1) { + return getBaseSymbol(group.children[0]); + } +}; +// NOTE: Unlike most `htmlBuilder`s, this one handles not only "accent", but +// also "supsub" since an accent can affect super/subscripting. +var htmlBuilder$a = (grp, options) => { + // Accents are handled in the TeXbook pg. 443, rule 12. + var base; + var group; + var supSubGroup; + if (grp && grp.type === "supsub") { + // If our base is a character box, and we have superscripts and + // subscripts, the supsub will defer to us. In particular, we want + // to attach the superscripts and subscripts to the inner body (so + // that the position of the superscripts and subscripts won't be + // affected by the height of the accent). We accomplish this by + // sticking the base of the accent into the base of the supsub, and + // rendering that, while keeping track of where the accent is. + // The real accent group is the base of the supsub group + group = assertNodeType(grp.base, "accent"); + // The character box is the base of the accent group + base = group.base; + // Stick the character box into the base of the supsub group + grp.base = base; + // Rerender the supsub group with its new base, and store that + // result. + supSubGroup = assertSpan(buildGroup$1(grp, options)); + // reset original base + grp.base = group; + } else { + group = assertNodeType(grp, "accent"); + base = group.base; + } + // Build the base group + var body = buildGroup$1(base, options.havingCrampedStyle()); + // Does the accent need to shift for the skew of a character? + var mustShift = group.isShifty && isCharacterBox(base); + // Calculate the skew of the accent. This is based on the line "If the + // nucleus is not a single character, let s = 0; otherwise set s to the + // kern amount for the nucleus followed by the \skewchar of its font." + // Note that our skew metrics are just the kern between each character + // and the skewchar. + var skew = 0; + if (mustShift) { + var _getBaseSymbol$skew, _getBaseSymbol; + // Read the skew from the rendered base symbol. + // This preserves font metrics from font wrappers like \mathbb. + skew = (_getBaseSymbol$skew = (_getBaseSymbol = getBaseSymbol(body)) == null ? void 0 : _getBaseSymbol.skew) != null ? _getBaseSymbol$skew : 0; + } + var accentBelow = group.label === "\\c"; + // calculate the amount of space between the body and the accent + var clearance = accentBelow ? body.height + body.depth : Math.min(body.height, options.fontMetrics().xHeight); + // Build the accent + var accentBody; + if (!group.isStretchy) { + var accent; + var width; + if (group.label === "\\vec") { + // Before version 0.9, \vec used the combining font glyph U+20D7. + // But browsers, especially Safari, are not consistent in how they + // render combining characters when not preceded by a character. + // So now we use an SVG. + // If Safari reforms, we should consider reverting to the glyph. + accent = staticSvg("vec", options); + width = svgData.vec[1]; + } else { + accent = makeOrd({ + type: "textord", + mode: group.mode, + text: group.label + }, options, "textord"); + accent = assertSymbolDomNode(accent); + // Remove the italic correction of the accent, because it only serves to + // shift the accent over to a place we don't want. + accent.italic = 0; + width = accent.width; + if (accentBelow) { + clearance += accent.depth; + } + } + accentBody = makeSpan(["accent-body"], [accent]); + // "Full" accents expand the width of the resulting symbol to be + // at least the width of the accent, and overlap directly onto the + // character without any vertical offset. + var accentFull = group.label === "\\textcircled"; + if (accentFull) { + accentBody.classes.push('accent-full'); + clearance = body.height; + } + // Shift the accent over by the skew. + var left = skew; + // CSS defines `.katex .accent .accent-body:not(.accent-full) { width: 0 }` + // so that the accent doesn't contribute to the bounding box. + // We need to shift the character by its width (effectively half + // its width) to compensate. + if (!accentFull) { + left -= width / 2; + } + accentBody.style.left = makeEm(left); + // \textcircled uses the \bigcirc glyph, so it needs some + // vertical adjustment to match LaTeX. + if (group.label === "\\textcircled") { + accentBody.style.top = ".2em"; + } + accentBody = makeVList({ + positionType: "firstBaseline", + children: [{ + type: "elem", + elem: body + }, { + type: "kern", + size: -clearance + }, { + type: "elem", + elem: accentBody + }] + }); + } else { + accentBody = stretchySvg(group, options); + accentBody = makeVList({ + positionType: "firstBaseline", + children: [{ + type: "elem", + elem: body + }, { + type: "elem", + elem: accentBody, + wrapperClasses: ["svg-align"], + wrapperStyle: skew > 0 ? { + width: "calc(100% - " + makeEm(2 * skew) + ")", + marginLeft: makeEm(2 * skew) + } : undefined + }] + }); + } + var accentWrap = makeSpan(["mord", "accent"], [accentBody], options); + if (supSubGroup) { + // Here, we replace the "base" child of the supsub with our newly + // generated accent. + supSubGroup.children[0] = accentWrap; + // Since we don't rerun the height calculation after replacing the + // accent, we manually recalculate height. + supSubGroup.height = Math.max(accentWrap.height, supSubGroup.height); + // Accents should always be ords, even when their innards are not. + supSubGroup.classes[0] = "mord"; + return supSubGroup; + } else { + return accentWrap; + } +}; +var mathmlBuilder$9 = (group, options) => { + var accentNode = group.isStretchy ? stretchyMathML(group.label) : new MathNode("mo", [makeText(group.label, group.mode)]); + var node = new MathNode("mover", [buildGroup(group.base, options), accentNode]); + node.setAttribute("accent", "true"); + return node; +}; +var NON_STRETCHY_ACCENT_REGEX = new RegExp(["\\acute", "\\grave", "\\ddot", "\\tilde", "\\bar", "\\breve", "\\check", "\\hat", "\\vec", "\\dot", "\\mathring"].map(accent => "\\" + accent).join("|")); +// Accents +defineFunction({ + type: "accent", + names: ["\\acute", "\\grave", "\\ddot", "\\tilde", "\\bar", "\\breve", "\\check", "\\hat", "\\vec", "\\dot", "\\mathring", "\\widecheck", "\\widehat", "\\widetilde", "\\overrightarrow", "\\overleftarrow", "\\Overrightarrow", "\\overleftrightarrow", "\\overgroup", "\\overlinesegment", "\\overleftharpoon", "\\overrightharpoon"], + props: { + numArgs: 1 + }, + handler: (context, args) => { + var base = normalizeArgument(args[0]); + var isStretchy = !NON_STRETCHY_ACCENT_REGEX.test(context.funcName); + var isShifty = !isStretchy || context.funcName === "\\widehat" || context.funcName === "\\widetilde" || context.funcName === "\\widecheck"; + return { + type: "accent", + mode: context.parser.mode, + label: context.funcName, + isStretchy: isStretchy, + isShifty: isShifty, + base: base + }; + }, + htmlBuilder: htmlBuilder$a, + mathmlBuilder: mathmlBuilder$9 +}); +// Text-mode accents +defineFunction({ + type: "accent", + names: ["\\'", "\\`", "\\^", "\\~", "\\=", "\\u", "\\.", '\\"', "\\c", "\\r", "\\H", "\\v", "\\textcircled"], + props: { + numArgs: 1, + allowedInText: true, + allowedInMath: true, + // unless in strict mode + argTypes: ["primitive"] + }, + handler: (context, args) => { + var base = args[0]; + var mode = context.parser.mode; + if (mode === "math") { + context.parser.settings.reportNonstrict("mathVsTextAccents", "LaTeX's accent " + context.funcName + " works only in text mode"); + mode = "text"; + } + return { + type: "accent", + mode: mode, + label: context.funcName, + isStretchy: false, + isShifty: true, + base: base + }; + }, + htmlBuilder: htmlBuilder$a, + mathmlBuilder: mathmlBuilder$9 +}); + +// Horizontal overlap functions +defineFunction({ + type: "accentUnder", + names: ["\\underleftarrow", "\\underrightarrow", "\\underleftrightarrow", "\\undergroup", "\\underlinesegment", "\\utilde"], + props: { + numArgs: 1 + }, + handler: (_ref, args) => { + var { + parser, + funcName + } = _ref; + var base = args[0]; + return { + type: "accentUnder", + mode: parser.mode, + label: funcName, + base: base + }; + }, + htmlBuilder: (group, options) => { + // Treat under accents much like underlines. + var innerGroup = buildGroup$1(group.base, options); + var accentBody = stretchySvg(group, options); + var kern = group.label === "\\utilde" ? 0.12 : 0; + // Generate the vlist, with the appropriate kerns + var vlist = makeVList({ + positionType: "top", + positionData: innerGroup.height, + children: [{ + type: "elem", + elem: accentBody, + wrapperClasses: ["svg-align"] + }, { + type: "kern", + size: kern + }, { + type: "elem", + elem: innerGroup + }] + }); + return makeSpan(["mord", "accentunder"], [vlist], options); + }, + mathmlBuilder: (group, options) => { + var accentNode = stretchyMathML(group.label); + var node = new MathNode("munder", [buildGroup(group.base, options), accentNode]); + node.setAttribute("accentunder", "true"); + return node; + } +}); + +// Helper function +var paddedNode = group => { + var node = new MathNode("mpadded", group ? [group] : []); + node.setAttribute("width", "+0.6em"); + node.setAttribute("lspace", "0.3em"); + return node; +}; +// Stretchy arrows with an optional argument +defineFunction({ + type: "xArrow", + names: ["\\xleftarrow", "\\xrightarrow", "\\xLeftarrow", "\\xRightarrow", "\\xleftrightarrow", "\\xLeftrightarrow", "\\xhookleftarrow", "\\xhookrightarrow", "\\xmapsto", "\\xrightharpoondown", "\\xrightharpoonup", "\\xleftharpoondown", "\\xleftharpoonup", "\\xrightleftharpoons", "\\xleftrightharpoons", "\\xlongequal", "\\xtwoheadrightarrow", "\\xtwoheadleftarrow", "\\xtofrom", + // The next 3 functions are here to support the mhchem extension. + // Direct use of these functions is discouraged and may break someday. + "\\xrightleftarrows", "\\xrightequilibrium", "\\xleftequilibrium", + // The next 3 functions are here only to support the {CD} environment. + "\\\\cdrightarrow", "\\\\cdleftarrow", "\\\\cdlongequal"], + props: { + numArgs: 1, + numOptionalArgs: 1 + }, + handler(_ref, args, optArgs) { + var { + parser, + funcName + } = _ref; + return { + type: "xArrow", + mode: parser.mode, + label: funcName, + body: args[0], + below: optArgs[0] + }; + }, + htmlBuilder(group, options) { + var style = options.style; + // Build the argument groups in the appropriate style. + // Ref: amsmath.dtx: \hbox{$\scriptstyle\mkern#3mu{#6}\mkern#4mu$}% + // Some groups can return document fragments. Handle those by wrapping + // them in a span. + var newOptions = options.havingStyle(style.sup()); + var upperGroup = wrapFragment(buildGroup$1(group.body, newOptions, options), options); + var arrowPrefix = group.label.slice(0, 2) === "\\x" ? "x" : "cd"; + upperGroup.classes.push(arrowPrefix + "-arrow-pad"); + var lowerGroup; + if (group.below) { + // Build the lower group + newOptions = options.havingStyle(style.sub()); + lowerGroup = wrapFragment(buildGroup$1(group.below, newOptions, options), options); + lowerGroup.classes.push(arrowPrefix + "-arrow-pad"); + } + var arrowBody = stretchySvg(group, options); + // Re shift: Note that stretchySvg returned arrowBody.depth = 0. + // The point we want on the math axis is at 0.5 * arrowBody.height. + var arrowShift = -options.fontMetrics().axisHeight + 0.5 * arrowBody.height; + // 2 mu kern. Ref: amsmath.dtx: #7\if0#2\else\mkern#2mu\fi + var upperShift = -options.fontMetrics().axisHeight - 0.5 * arrowBody.height - 0.111; // 0.111 em = 2 mu + if (upperGroup.depth > 0.25 || group.label === "\\xleftequilibrium") { + upperShift -= upperGroup.depth; // shift up if depth encroaches + } + // Generate the vlist + var vlist; + if (lowerGroup) { + var lowerShift = -options.fontMetrics().axisHeight + lowerGroup.height + 0.5 * arrowBody.height + 0.111; + vlist = makeVList({ + positionType: "individualShift", + children: [{ + type: "elem", + elem: upperGroup, + shift: upperShift + }, { + type: "elem", + elem: arrowBody, + shift: arrowShift, + wrapperClasses: ["svg-align"] + }, { + type: "elem", + elem: lowerGroup, + shift: lowerShift + }] + }); + } else { + vlist = makeVList({ + positionType: "individualShift", + children: [{ + type: "elem", + elem: upperGroup, + shift: upperShift + }, { + type: "elem", + elem: arrowBody, + shift: arrowShift, + wrapperClasses: ["svg-align"] + }] + }); + } + return makeSpan(["mrel", "x-arrow"], [vlist], options); + }, + mathmlBuilder(group, options) { + var arrowNode = stretchyMathML(group.label); + arrowNode.setAttribute("minsize", group.label.charAt(0) === "x" ? "1.75em" : "3.0em"); + var node; + if (group.body) { + var upperNode = paddedNode(buildGroup(group.body, options)); + if (group.below) { + var lowerNode = paddedNode(buildGroup(group.below, options)); + node = new MathNode("munderover", [arrowNode, lowerNode, upperNode]); + } else { + node = new MathNode("mover", [arrowNode, upperNode]); + } + } else if (group.below) { + var _lowerNode = paddedNode(buildGroup(group.below, options)); + node = new MathNode("munder", [arrowNode, _lowerNode]); + } else { + // This should never happen. + // Parser.js throws an error if there is no argument. + node = paddedNode(); + node = new MathNode("mover", [arrowNode, node]); + } + return node; + } +}); + +function htmlBuilder$9(group, options) { + var elements = buildExpression$1(group.body, options, true); + return makeSpan([group.mclass], elements, options); +} +function mathmlBuilder$8(group, options) { + var node; + var inner = buildExpression(group.body, options); + if (group.mclass === "minner") { + node = new MathNode("mpadded", inner); + } else if (group.mclass === "mord") { + if (group.isCharacterBox) { + node = inner[0]; + node.type = "mi"; + } else { + node = new MathNode("mi", inner); + } + } else { + if (group.isCharacterBox) { + node = inner[0]; + node.type = "mo"; + } else { + node = new MathNode("mo", inner); + } + // Set spacing based on what is the most likely adjacent atom type. + // See TeXbook p170. + if (group.mclass === "mbin") { + node.attributes.lspace = "0.22em"; // medium space + node.attributes.rspace = "0.22em"; + } else if (group.mclass === "mpunct") { + node.attributes.lspace = "0em"; + node.attributes.rspace = "0.17em"; // thinspace + } else if (group.mclass === "mopen" || group.mclass === "mclose") { + node.attributes.lspace = "0em"; + node.attributes.rspace = "0em"; + } else if (group.mclass === "minner") { + node.attributes.lspace = "0.0556em"; // 1 mu is the most likely option + node.attributes.width = "+0.1111em"; + } + // MathML default space is 5/18 em, so needs no action. + // Ref: https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mo + } + return node; +} +// Math class commands except \mathop +defineFunction({ + type: "mclass", + names: ["\\mathord", "\\mathbin", "\\mathrel", "\\mathopen", "\\mathclose", "\\mathpunct", "\\mathinner"], + props: { + numArgs: 1, + primitive: true + }, + handler(_ref, args) { + var { + parser, + funcName + } = _ref; + var body = args[0]; + return { + type: "mclass", + mode: parser.mode, + mclass: "m" + funcName.slice(5), + // TODO(kevinb): don't prefix with 'm' + body: ordargument(body), + isCharacterBox: isCharacterBox(body) + }; + }, + htmlBuilder: htmlBuilder$9, + mathmlBuilder: mathmlBuilder$8 +}); +var binrelClass = arg => { + // \binrel@ spacing varies with (bin|rel|ord) of the atom in the argument. + // (by rendering separately and with {}s before and after, and measuring + // the change in spacing). We'll do roughly the same by detecting the + // atom type directly. + var atom = arg.type === "ordgroup" && arg.body.length ? arg.body[0] : arg; + if (atom.type === "atom" && (atom.family === "bin" || atom.family === "rel")) { + return "m" + atom.family; + } else { + return "mord"; + } +}; +// \@binrel{x}{y} renders like y but as mbin/mrel/mord if x is mbin/mrel/mord. +// This is equivalent to \binrel@{x}\binrel@@{y} in AMSTeX. +defineFunction({ + type: "mclass", + names: ["\\@binrel"], + props: { + numArgs: 2 + }, + handler(_ref2, args) { + var { + parser + } = _ref2; + return { + type: "mclass", + mode: parser.mode, + mclass: binrelClass(args[0]), + body: ordargument(args[1]), + isCharacterBox: isCharacterBox(args[1]) + }; + } +}); +// Build a relation or stacked op by placing one symbol on top of another +defineFunction({ + type: "mclass", + names: ["\\stackrel", "\\overset", "\\underset"], + props: { + numArgs: 2 + }, + handler(_ref3, args) { + var { + parser, + funcName + } = _ref3; + var baseArg = args[1]; + var shiftedArg = args[0]; + var mclass; + if (funcName !== "\\stackrel") { + // LaTeX applies \binrel spacing to \overset and \underset. + mclass = binrelClass(baseArg); + } else { + mclass = "mrel"; // for \stackrel + } + var baseOp = { + type: "op", + mode: baseArg.mode, + limits: true, + alwaysHandleSupSub: true, + parentIsSupSub: false, + symbol: false, + suppressBaseShift: funcName !== "\\stackrel", + body: ordargument(baseArg) + }; + var supsub = { + type: "supsub", + mode: shiftedArg.mode, + base: baseOp, + sup: funcName === "\\underset" ? null : shiftedArg, + sub: funcName === "\\underset" ? shiftedArg : null + }; + return { + type: "mclass", + mode: parser.mode, + mclass, + body: [supsub], + isCharacterBox: isCharacterBox(supsub) + }; + }, + htmlBuilder: htmlBuilder$9, + mathmlBuilder: mathmlBuilder$8 +}); + +// \pmb is a simulation of bold font. +// The version of \pmb in ambsy.sty works by typesetting three copies +// with small offsets. We use CSS text-shadow. +// It's a hack. Not as good as a real bold font. Better than nothing. +defineFunction({ + type: "pmb", + names: ["\\pmb"], + props: { + numArgs: 1, + allowedInText: true + }, + handler(_ref, args) { + var { + parser + } = _ref; + return { + type: "pmb", + mode: parser.mode, + mclass: binrelClass(args[0]), + body: ordargument(args[0]) + }; + }, + htmlBuilder(group, options) { + var elements = buildExpression$1(group.body, options, true); + var node = makeSpan([group.mclass], elements, options); + node.style.textShadow = "0.02em 0.01em 0.04px"; + return node; + }, + mathmlBuilder(group, style) { + var inner = buildExpression(group.body, style); + // Wrap with an element. + var node = new MathNode("mstyle", inner); + node.setAttribute("style", "text-shadow: 0.02em 0.01em 0.04px"); + return node; + } +}); + +var cdArrowFunctionName = { + ">": "\\\\cdrightarrow", + "<": "\\\\cdleftarrow", + "=": "\\\\cdlongequal", + "A": "\\uparrow", + "V": "\\downarrow", + "|": "\\Vert", + ".": "no arrow" +}; +var newCell = () => { + // Create an empty cell, to be filled below with parse nodes. + // The parseTree from this module must be constructed like the + // one created by parseArray(), so an empty CD cell must + // be a ParseNode<"styling">. And CD is always displaystyle. + return { + type: "styling", + body: [], + mode: "math", + style: "display", + resetFont: true + }; +}; +var isStartOfArrow = node => { + return node.type === "textord" && node.text === "@"; +}; +var isLabelEnd = (node, endChar) => { + return (node.type === "mathord" || node.type === "atom") && node.text === endChar; +}; +function cdArrow(arrowChar, labels, parser) { + // Return a parse tree of an arrow and its labels. + // This acts in a way similar to a macro expansion. + var funcName = cdArrowFunctionName[arrowChar]; + switch (funcName) { + case "\\\\cdrightarrow": + case "\\\\cdleftarrow": + return parser.callFunction(funcName, [labels[0]], [labels[1]]); + case "\\uparrow": + case "\\downarrow": + { + var leftLabel = parser.callFunction("\\\\cdleft", [labels[0]], []); + var bareArrow = { + type: "atom", + text: funcName, + mode: "math", + family: "rel" + }; + var sizedArrow = parser.callFunction("\\Big", [bareArrow], []); + var rightLabel = parser.callFunction("\\\\cdright", [labels[1]], []); + var arrowGroup = { + type: "ordgroup", + mode: "math", + body: [leftLabel, sizedArrow, rightLabel] + }; + return parser.callFunction("\\\\cdparent", [arrowGroup], []); + } + case "\\\\cdlongequal": + return parser.callFunction("\\\\cdlongequal", [], []); + case "\\Vert": + { + var arrow = { + type: "textord", + text: "\\Vert", + mode: "math" + }; + return parser.callFunction("\\Big", [arrow], []); + } + default: + return { + type: "textord", + text: " ", + mode: "math" + }; + } +} +function parseCD(parser) { + // Get the array's parse nodes with \\ temporarily mapped to \cr. + var parsedRows = []; + parser.gullet.beginGroup(); + parser.gullet.macros.set("\\cr", "\\\\\\relax"); + parser.gullet.beginGroup(); + while (true) { + // Get the parse nodes for the next row. + parsedRows.push(parser.parseExpression(false, "\\\\")); + parser.gullet.endGroup(); + parser.gullet.beginGroup(); + var next = parser.fetch().text; + if (next === "&" || next === "\\\\") { + parser.consume(); + } else if (next === "\\end") { + if (parsedRows[parsedRows.length - 1].length === 0) { + parsedRows.pop(); // final row ended in \\ + } + break; + } else { + throw new ParseError("Expected \\\\ or \\cr or \\end", parser.nextToken); + } + } + var row = []; + var body = [row]; + // Loop thru the parse nodes. Collect them into cells and arrows. + for (var i = 0; i < parsedRows.length; i++) { + // Start a new row. + var rowNodes = parsedRows[i]; + // Create the first cell. + var cell = newCell(); + for (var j = 0; j < rowNodes.length; j++) { + if (!isStartOfArrow(rowNodes[j])) { + // If a parseNode is not an arrow, it goes into a cell. + cell.body.push(rowNodes[j]); + } else { + // Parse node j is an "@", the start of an arrow. + // Before starting on the arrow, push the cell into `row`. + row.push(cell); + // Now collect parseNodes into an arrow. + // The character after "@" defines the arrow type. + j += 1; + var arrowChar = assertSymbolNodeType(rowNodes[j]).text; + // Create two empty label nodes. We may or may not use them. + var labels = new Array(2); + labels[0] = { + type: "ordgroup", + mode: "math", + body: [] + }; + labels[1] = { + type: "ordgroup", + mode: "math", + body: [] + }; + // Process the arrow. + if ("=|.".includes(arrowChar)) ; else if ("<>AV".includes(arrowChar)) { + // Four arrows, `@>>>`, `@<<<`, `@AAA`, and `@VVV`, each take + // two optional labels. E.g. the right-point arrow syntax is + // really: @>{optional label}>{optional label}> + // Collect parseNodes into labels. + for (var labelNum = 0; labelNum < 2; labelNum++) { + var inLabel = true; + for (var k = j + 1; k < rowNodes.length; k++) { + if (isLabelEnd(rowNodes[k], arrowChar)) { + inLabel = false; + j = k; + break; + } + if (isStartOfArrow(rowNodes[k])) { + throw new ParseError("Missing a " + arrowChar + " character to complete a CD arrow.", rowNodes[k]); + } + labels[labelNum].body.push(rowNodes[k]); + } + if (inLabel) { + // isLabelEnd never returned a true. + throw new ParseError("Missing a " + arrowChar + " character to complete a CD arrow.", rowNodes[j]); + } + } + } else { + throw new ParseError("Expected one of \"<>AV=|.\" after @", rowNodes[j]); + } + // Now join the arrow to its labels. + var arrow = cdArrow(arrowChar, labels, parser); + // Wrap the arrow in ParseNode<"styling">. + // This is done to match parseArray() behavior. + var wrappedArrow = { + type: "styling", + body: [arrow], + mode: "math", + style: "display", + // CD is always displaystyle. + resetFont: true + }; + row.push(wrappedArrow); + // In CD's syntax, cells are implicit. That is, everything that + // is not an arrow gets collected into a cell. So create an empty + // cell now. It will collect upcoming parseNodes. + cell = newCell(); + } + } + if (i % 2 === 0) { + // Even-numbered rows consist of: cell, arrow, cell, arrow, ... cell + // The last cell is not yet pushed into `row`, so: + row.push(cell); + } else { + // Odd-numbered rows consist of: vert arrow, empty cell, ... vert arrow + // Remove the empty cell that was placed at the beginning of `row`. + row.shift(); + } + row = []; + body.push(row); + } + // End row group + parser.gullet.endGroup(); + // End array group defining \\ + parser.gullet.endGroup(); + // define column separation. + var cols = new Array(body[0].length).fill({ + type: "align", + align: "c", + pregap: 0.25, + // CD package sets \enskip between columns. + postgap: 0.25 // So pre and post each get half an \enskip, i.e. 0.25em. + }); + return { + type: "array", + mode: "math", + body, + arraystretch: 1, + addJot: true, + rowGaps: [null], + cols, + colSeparationType: "CD", + hLinesBeforeRow: new Array(body.length + 1).fill([]) + }; +} +// The functions below are not available for general use. +// They are here only for internal use by the {CD} environment in placing labels +// next to vertical arrows. +// We don't need any such functions for horizontal arrows because we can reuse +// the functionality that already exists for extensible arrows. +defineFunction({ + type: "cdlabel", + names: ["\\\\cdleft", "\\\\cdright"], + props: { + numArgs: 1 + }, + handler(_ref, args) { + var { + parser, + funcName + } = _ref; + return { + type: "cdlabel", + mode: parser.mode, + side: funcName.slice(4), + label: args[0] + }; + }, + htmlBuilder(group, options) { + var newOptions = options.havingStyle(options.style.sup()); + var label = wrapFragment(buildGroup$1(group.label, newOptions, options), options); + label.classes.push("cd-label-" + group.side); + label.style.bottom = makeEm(0.8 - label.depth); + // Zero out label height & depth, so vertical align of arrow is set + // by the arrow height, not by the label. + label.height = 0; + label.depth = 0; + return label; + }, + mathmlBuilder(group, options) { + var label = new MathNode("mrow", [buildGroup(group.label, options)]); + label = new MathNode("mpadded", [label]); + label.setAttribute("width", "0"); + if (group.side === "left") { + label.setAttribute("lspace", "-1width"); + } + // We have to guess at vertical alignment. We know the arrow is 1.8em tall, + // But we don't know the height or depth of the label. + label.setAttribute("voffset", "0.7em"); + label = new MathNode("mstyle", [label]); + label.setAttribute("displaystyle", "false"); + label.setAttribute("scriptlevel", "1"); + return label; + } +}); +defineFunction({ + type: "cdlabelparent", + names: ["\\\\cdparent"], + props: { + numArgs: 1 + }, + handler(_ref2, args) { + var { + parser + } = _ref2; + return { + type: "cdlabelparent", + mode: parser.mode, + fragment: args[0] + }; + }, + htmlBuilder(group, options) { + // Wrap the vertical arrow and its labels. + // The parent gets position: relative. The child gets position: absolute. + // So CSS can locate the label correctly. + var parent = wrapFragment(buildGroup$1(group.fragment, options), options); + parent.classes.push("cd-vert-arrow"); + return parent; + }, + mathmlBuilder(group, options) { + return new MathNode("mrow", [buildGroup(group.fragment, options)]); + } +}); + +// \@char is an internal function that takes a grouped decimal argument like +// {123} and converts into symbol with code 123. It is used by the *macro* +// \char defined in macros.js. +defineFunction({ + type: "textord", + names: ["\\@char"], + props: { + numArgs: 1, + allowedInText: true + }, + handler(_ref, args) { + var { + parser + } = _ref; + var arg = assertNodeType(args[0], "ordgroup"); + var group = arg.body; + var number = ""; + for (var i = 0; i < group.length; i++) { + var node = assertNodeType(group[i], "textord"); + number += node.text; + } + var code = parseInt(number); + var text; + if (isNaN(code)) { + throw new ParseError("\\@char has non-numeric argument " + number); + // If we drop IE support, the following code could be replaced with + // text = String.fromCodePoint(code) + } else if (code < 0 || code >= 0x10ffff) { + throw new ParseError("\\@char with invalid code point " + number); + } else if (code <= 0xffff) { + text = String.fromCharCode(code); + } else { + // Astral code point; split into surrogate halves + code -= 0x10000; + text = String.fromCharCode((code >> 10) + 0xd800, (code & 0x3ff) + 0xdc00); + } + return { + type: "textord", + mode: parser.mode, + text: text + }; + } +}); + +var htmlBuilder$8 = (group, options) => { + var elements = buildExpression$1(group.body, options.withColor(group.color), false); + // \color isn't supposed to affect the type of the elements it contains. + // To accomplish this, we wrap the results in a fragment, so the inner + // elements will be able to directly interact with their neighbors. For + // example, `\color{red}{2 +} 3` has the same spacing as `2 + 3` + return makeFragment(elements); +}; +var mathmlBuilder$7 = (group, options) => { + var inner = buildExpression(group.body, options.withColor(group.color)); + var node = new MathNode("mstyle", inner); + node.setAttribute("mathcolor", group.color); + return node; +}; +defineFunction({ + type: "color", + names: ["\\textcolor"], + props: { + numArgs: 2, + allowedInText: true, + argTypes: ["color", "original"] + }, + handler(_ref, args) { + var { + parser + } = _ref; + var color = assertNodeType(args[0], "color-token").color; + var body = args[1]; + return { + type: "color", + mode: parser.mode, + color, + body: ordargument(body) + }; + }, + htmlBuilder: htmlBuilder$8, + mathmlBuilder: mathmlBuilder$7 +}); +defineFunction({ + type: "color", + names: ["\\color"], + props: { + numArgs: 1, + allowedInText: true, + argTypes: ["color"] + }, + handler(_ref2, args) { + var { + parser, + breakOnTokenText + } = _ref2; + var color = assertNodeType(args[0], "color-token").color; + // Set macro \current@color in current namespace to store the current + // color, mimicking the behavior of color.sty. + // This is currently used just to correctly color a \right + // that follows a \color command. + parser.gullet.macros.set("\\current@color", color); + // Parse out the implicit body that should be colored. + var body = parser.parseExpression(true, breakOnTokenText); + return { + type: "color", + mode: parser.mode, + color, + body + }; + }, + htmlBuilder: htmlBuilder$8, + mathmlBuilder: mathmlBuilder$7 +}); + +// Row breaks within tabular environments, and line breaks at top level +// \DeclareRobustCommand\\{...\@xnewline} +defineFunction({ + type: "cr", + names: ["\\\\"], + props: { + numArgs: 0, + numOptionalArgs: 0, + allowedInText: true + }, + handler(_ref, args, optArgs) { + var { + parser + } = _ref; + var size = parser.gullet.future().text === "[" ? parser.parseSizeGroup(true) : null; + var newLine = !parser.settings.displayMode || !parser.settings.useStrictBehavior("newLineInDisplayMode", "In LaTeX, \\\\ or \\newline " + "does nothing in display mode"); + return { + type: "cr", + mode: parser.mode, + newLine, + size: size && assertNodeType(size, "size").value + }; + }, + // The following builders are called only at the top level, + // not within tabular/array environments. + htmlBuilder(group, options) { + var span = makeSpan(["mspace"], [], options); + if (group.newLine) { + span.classes.push("newline"); + if (group.size) { + span.style.marginTop = makeEm(calculateSize(group.size, options)); + } + } + return span; + }, + mathmlBuilder(group, options) { + var node = new MathNode("mspace"); + if (group.newLine) { + node.setAttribute("linebreak", "newline"); + if (group.size) { + node.setAttribute("height", makeEm(calculateSize(group.size, options))); + } + } + return node; + } +}); + +var globalMap = { + "\\global": "\\global", + "\\long": "\\\\globallong", + "\\\\globallong": "\\\\globallong", + "\\def": "\\gdef", + "\\gdef": "\\gdef", + "\\edef": "\\xdef", + "\\xdef": "\\xdef", + "\\let": "\\\\globallet", + "\\futurelet": "\\\\globalfuture" +}; +var checkControlSequence = tok => { + var name = tok.text; + if (/^(?:[\\{}$&#^_]|EOF)$/.test(name)) { + throw new ParseError("Expected a control sequence", tok); + } + return name; +}; +var getRHS = parser => { + var tok = parser.gullet.popToken(); + if (tok.text === "=") { + // consume optional equals + tok = parser.gullet.popToken(); + if (tok.text === " ") { + // consume one optional space + tok = parser.gullet.popToken(); + } + } + return tok; +}; +var letCommand = (parser, name, tok, global) => { + var macro = parser.gullet.macros.get(tok.text); + if (macro == null) { + // don't expand it later even if a macro with the same name is defined + // e.g., \let\foo=\frac \def\frac{\relax} \frac12 + tok.noexpand = true; + macro = { + tokens: [tok], + numArgs: 0, + // reproduce the same behavior in expansion + unexpandable: !parser.gullet.isExpandable(tok.text) + }; + } + parser.gullet.macros.set(name, macro, global); +}; +// -> | +// -> |\global +// -> | +// -> \global|\long|\outer +defineFunction({ + type: "internal", + names: ["\\global", "\\long", "\\\\globallong" // can’t be entered directly + ], + props: { + numArgs: 0, + allowedInText: true + }, + handler(_ref) { + var { + parser, + funcName + } = _ref; + parser.consumeSpaces(); + var token = parser.fetch(); + if (globalMap[token.text]) { + // KaTeX doesn't have \par, so ignore \long + if (funcName === "\\global" || funcName === "\\\\globallong") { + token.text = globalMap[token.text]; + } + return assertNodeType(parser.parseFunction(), "internal"); + } + throw new ParseError("Invalid token after macro prefix", token); + } +}); +// Basic support for macro definitions: \def, \gdef, \edef, \xdef +// -> +// -> \def|\gdef|\edef|\xdef +// -> +defineFunction({ + type: "internal", + names: ["\\def", "\\gdef", "\\edef", "\\xdef"], + props: { + numArgs: 0, + allowedInText: true, + primitive: true + }, + handler(_ref2) { + var { + parser, + funcName + } = _ref2; + var tok = parser.gullet.popToken(); + var name = tok.text; + if (/^(?:[\\{}$&#^_]|EOF)$/.test(name)) { + throw new ParseError("Expected a control sequence", tok); + } + var numArgs = 0; + var insert; + var delimiters = [[]]; + // contains no braces + while (parser.gullet.future().text !== "{") { + tok = parser.gullet.popToken(); + if (tok.text === "#") { + // If the very last character of the is #, so that + // this # is immediately followed by {, TeX will behave as if the { + // had been inserted at the right end of both the parameter text + // and the replacement text. + if (parser.gullet.future().text === "{") { + insert = parser.gullet.future(); + delimiters[numArgs].push("{"); + break; + } + // A parameter, the first appearance of # must be followed by 1, + // the next by 2, and so on; up to nine #’s are allowed + tok = parser.gullet.popToken(); + if (!/^[1-9]$/.test(tok.text)) { + throw new ParseError("Invalid argument number \"" + tok.text + "\""); + } + if (parseInt(tok.text) !== numArgs + 1) { + throw new ParseError("Argument number \"" + tok.text + "\" out of order"); + } + numArgs++; + delimiters.push([]); + } else if (tok.text === "EOF") { + throw new ParseError("Expected a macro definition"); + } else { + delimiters[numArgs].push(tok.text); + } + } + // replacement text, enclosed in '{' and '}' and properly nested + var { + tokens + } = parser.gullet.consumeArg(); + if (insert) { + tokens.unshift(insert); + } + if (funcName === "\\edef" || funcName === "\\xdef") { + tokens = parser.gullet.expandTokens(tokens); + tokens.reverse(); // to fit in with stack order + } + // Final arg is the expansion of the macro + parser.gullet.macros.set(name, { + tokens, + numArgs, + delimiters + }, funcName === globalMap[funcName]); + return { + type: "internal", + mode: parser.mode + }; + } +}); +// -> +// -> \futurelet +// | \let +// -> |= +defineFunction({ + type: "internal", + names: ["\\let", "\\\\globallet" // can’t be entered directly + ], + props: { + numArgs: 0, + allowedInText: true, + primitive: true + }, + handler(_ref3) { + var { + parser, + funcName + } = _ref3; + var name = checkControlSequence(parser.gullet.popToken()); + parser.gullet.consumeSpaces(); + var tok = getRHS(parser); + letCommand(parser, name, tok, funcName === "\\\\globallet"); + return { + type: "internal", + mode: parser.mode + }; + } +}); +// ref: https://www.tug.org/TUGboat/tb09-3/tb22bechtolsheim.pdf +defineFunction({ + type: "internal", + names: ["\\futurelet", "\\\\globalfuture" // can’t be entered directly + ], + props: { + numArgs: 0, + allowedInText: true, + primitive: true + }, + handler(_ref4) { + var { + parser, + funcName + } = _ref4; + var name = checkControlSequence(parser.gullet.popToken()); + var middle = parser.gullet.popToken(); + var tok = parser.gullet.popToken(); + letCommand(parser, name, tok, funcName === "\\\\globalfuture"); + parser.gullet.pushToken(tok); + parser.gullet.pushToken(middle); + return { + type: "internal", + mode: parser.mode + }; + } +}); + +/** + * This file 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`. + */ +/** + * Get the metrics for a given symbol and font, after transformation (i.e. + * after following replacement from symbols.js) + */ +var getMetrics = function getMetrics(symbol, font, mode) { + var replace = symbols.math[symbol] && symbols.math[symbol].replace; + var metrics = getCharacterMetrics(replace || symbol, font, mode); + if (!metrics) { + throw new Error("Unsupported symbol " + symbol + " and font size " + font + "."); + } + return metrics; +}; +/** + * Puts a delimiter span in a given style, and adds appropriate height, depth, + * and maxFontSizes. + */ +var styleWrap = function styleWrap(delim, toStyle, options, classes) { + var newOptions = options.havingBaseStyle(toStyle); + var span = makeSpan(classes.concat(newOptions.sizingClasses(options)), [delim], options); + var delimSizeMultiplier = newOptions.sizeMultiplier / options.sizeMultiplier; + span.height *= delimSizeMultiplier; + span.depth *= delimSizeMultiplier; + span.maxFontSize = newOptions.sizeMultiplier; + return span; +}; +var centerSpan = function centerSpan(span, options, style) { + var newOptions = options.havingBaseStyle(style); + var shift = (1 - options.sizeMultiplier / newOptions.sizeMultiplier) * options.fontMetrics().axisHeight; + span.classes.push("delimcenter"); + span.style.top = makeEm(shift); + span.height -= shift; + span.depth += shift; +}; +/** + * 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. + */ +var makeSmallDelim = function makeSmallDelim(delim, style, center, options, mode, classes) { + var text = makeSymbol(delim, "Main-Regular", mode, options); + var span = styleWrap(text, style, options, classes); + if (center) { + centerSpan(span, options, style); + } + return span; +}; +/** + * Builds a symbol in the given font size (note size is an integer) + */ +var mathrmSize = function mathrmSize(value, size, mode, options) { + return makeSymbol(value, "Size" + size + "-Regular", mode, options); +}; +/** + * Makes a large delimiter. This is a delimiter that comes in the Size1, Size2, + * Size3, or Size4 fonts. It is always rendered in textstyle. + */ +var makeLargeDelim = function makeLargeDelim(delim, size, center, options, mode, classes) { + var inner = mathrmSize(delim, size, mode, options); + var span = styleWrap(makeSpan(["delimsizing", "size" + size], [inner], options), Style$1.TEXT, options, classes); + if (center) { + centerSpan(span, options, Style$1.TEXT); + } + return span; +}; +/** + * Make a span from a font glyph with the given offset and in the given font. + * This is used in makeStackedDelim to make the stacking pieces for the delimiter. + */ +var makeGlyphSpan = function makeGlyphSpan(symbol, font, mode) { + var sizeClass; + // Apply the correct CSS class to choose the right font. + if (font === "Size1-Regular") { + sizeClass = "delim-size1"; + } else /* if (font === "Size4-Regular") */{ + sizeClass = "delim-size4"; + } + var corner = makeSpan(["delimsizinginner", sizeClass], [makeSpan([], [makeSymbol(symbol, font, mode)])]); + // Since this will be passed into `makeVList` in the end, wrap the element + // in the appropriate tag that VList uses. + return { + type: "elem", + elem: corner + }; +}; +var makeInner = function makeInner(ch, height, options) { + // Create a span with inline SVG for the inner part of a tall stacked delimiter. + var width = fontMetricsData['Size4-Regular'][ch.charCodeAt(0)] ? fontMetricsData['Size4-Regular'][ch.charCodeAt(0)][4] : fontMetricsData['Size1-Regular'][ch.charCodeAt(0)][4]; + var path = new PathNode("inner", innerPath(ch, Math.round(1000 * height))); + var svgNode = new SvgNode([path], { + "width": makeEm(width), + "height": makeEm(height), + // Override CSS rule `.katex svg { width: 100% }` + "style": "width:" + makeEm(width), + "viewBox": "0 0 " + 1000 * width + " " + Math.round(1000 * height), + "preserveAspectRatio": "xMinYMin" + }); + var span = makeSvgSpan([], [svgNode], options); + span.height = height; + span.style.height = makeEm(height); + span.style.width = makeEm(width); + return { + type: "elem", + elem: span + }; +}; +// Helpers for makeStackedDelim +var lapInEms = 0.008; +var lap = { + type: "kern", + size: -1 * lapInEms +}; +var verts = new Set(["|", "\\lvert", "\\rvert", "\\vert"]); +var doubleVerts = new Set(["\\|", "\\lVert", "\\rVert", "\\Vert"]); +/** + * Make a stacked delimiter out of a given delimiter, with the total height at + * least `heightTotal`. This routine is mentioned on page 442 of the TeXbook. + */ +var makeStackedDelim = function makeStackedDelim(delim, heightTotal, center, options, mode, classes) { + // There are four parts, the top, an optional middle, a repeated part, and a + // bottom. + var top; + var middle; + var repeat; + var bottom; + var svgLabel = ""; + var viewBoxWidth = 0; + top = repeat = bottom = delim; + middle = null; + // Also keep track of what font the delimiters are in + var font = "Size1-Regular"; + // We set the parts and font based on the symbol. Note that we use + // '\u23d0' instead of '|' and '\u2016' instead of '\\|' for the + // repeats of the arrows + if (delim === "\\uparrow") { + repeat = bottom = "\u23d0"; + } else if (delim === "\\Uparrow") { + repeat = bottom = "\u2016"; + } else if (delim === "\\downarrow") { + top = repeat = "\u23d0"; + } else if (delim === "\\Downarrow") { + top = repeat = "\u2016"; + } else if (delim === "\\updownarrow") { + top = "\\uparrow"; + repeat = "\u23d0"; + bottom = "\\downarrow"; + } else if (delim === "\\Updownarrow") { + top = "\\Uparrow"; + repeat = "\u2016"; + bottom = "\\Downarrow"; + } else if (verts.has(delim)) { + repeat = "\u2223"; + svgLabel = "vert"; + viewBoxWidth = 333; + } else if (doubleVerts.has(delim)) { + repeat = "\u2225"; + svgLabel = "doublevert"; + viewBoxWidth = 556; + } else if (delim === "[" || delim === "\\lbrack") { + top = "\u23a1"; + repeat = "\u23a2"; + bottom = "\u23a3"; + font = "Size4-Regular"; + svgLabel = "lbrack"; + viewBoxWidth = 667; + } else if (delim === "]" || delim === "\\rbrack") { + top = "\u23a4"; + repeat = "\u23a5"; + bottom = "\u23a6"; + font = "Size4-Regular"; + svgLabel = "rbrack"; + viewBoxWidth = 667; + } else if (delim === "\\lfloor" || delim === "\u230a") { + repeat = top = "\u23a2"; + bottom = "\u23a3"; + font = "Size4-Regular"; + svgLabel = "lfloor"; + viewBoxWidth = 667; + } else if (delim === "\\lceil" || delim === "\u2308") { + top = "\u23a1"; + repeat = bottom = "\u23a2"; + font = "Size4-Regular"; + svgLabel = "lceil"; + viewBoxWidth = 667; + } else if (delim === "\\rfloor" || delim === "\u230b") { + repeat = top = "\u23a5"; + bottom = "\u23a6"; + font = "Size4-Regular"; + svgLabel = "rfloor"; + viewBoxWidth = 667; + } else if (delim === "\\rceil" || delim === "\u2309") { + top = "\u23a4"; + repeat = bottom = "\u23a5"; + font = "Size4-Regular"; + svgLabel = "rceil"; + viewBoxWidth = 667; + } else if (delim === "(" || delim === "\\lparen") { + top = "\u239b"; + repeat = "\u239c"; + bottom = "\u239d"; + font = "Size4-Regular"; + svgLabel = "lparen"; + viewBoxWidth = 875; + } else if (delim === ")" || delim === "\\rparen") { + top = "\u239e"; + repeat = "\u239f"; + bottom = "\u23a0"; + font = "Size4-Regular"; + svgLabel = "rparen"; + viewBoxWidth = 875; + } else if (delim === "\\{" || delim === "\\lbrace") { + top = "\u23a7"; + middle = "\u23a8"; + bottom = "\u23a9"; + repeat = "\u23aa"; + font = "Size4-Regular"; + } else if (delim === "\\}" || delim === "\\rbrace") { + top = "\u23ab"; + middle = "\u23ac"; + bottom = "\u23ad"; + repeat = "\u23aa"; + font = "Size4-Regular"; + } else if (delim === "\\lgroup" || delim === "\u27ee") { + top = "\u23a7"; + bottom = "\u23a9"; + repeat = "\u23aa"; + font = "Size4-Regular"; + } else if (delim === "\\rgroup" || delim === "\u27ef") { + top = "\u23ab"; + bottom = "\u23ad"; + repeat = "\u23aa"; + font = "Size4-Regular"; + } else if (delim === "\\lmoustache" || delim === "\u23b0") { + top = "\u23a7"; + bottom = "\u23ad"; + repeat = "\u23aa"; + font = "Size4-Regular"; + } else if (delim === "\\rmoustache" || delim === "\u23b1") { + top = "\u23ab"; + bottom = "\u23a9"; + repeat = "\u23aa"; + font = "Size4-Regular"; + } + // Get the metrics of the four sections + var topMetrics = getMetrics(top, font, mode); + var topHeightTotal = topMetrics.height + topMetrics.depth; + var repeatMetrics = getMetrics(repeat, font, mode); + var repeatHeightTotal = repeatMetrics.height + repeatMetrics.depth; + var bottomMetrics = getMetrics(bottom, font, mode); + var bottomHeightTotal = bottomMetrics.height + bottomMetrics.depth; + var middleHeightTotal = 0; + var middleFactor = 1; + if (middle !== null) { + var middleMetrics = getMetrics(middle, font, mode); + middleHeightTotal = middleMetrics.height + middleMetrics.depth; + middleFactor = 2; // repeat symmetrically above and below middle + } + // Calculate the minimal height that the delimiter can have. + // It is at least the size of the top, bottom, and optional middle combined. + var minHeight = topHeightTotal + bottomHeightTotal + middleHeightTotal; + // Compute the number of copies of the repeat symbol we will need + var repeatCount = Math.max(0, Math.ceil((heightTotal - minHeight) / (middleFactor * repeatHeightTotal))); + // Compute the total height of the delimiter including all the symbols + var realHeightTotal = minHeight + repeatCount * middleFactor * repeatHeightTotal; + // The center of the delimiter is placed at the center of the axis. Note + // that in this context, "center" means that the delimiter should be + // centered around the axis in the current style, while normally it is + // centered around the axis in textstyle. + var axisHeight = options.fontMetrics().axisHeight; + if (center) { + axisHeight *= options.sizeMultiplier; + } + // Calculate the depth + var depth = realHeightTotal / 2 - axisHeight; + // Now, we start building the pieces that will go into the vlist + // Keep a list of the pieces of the stacked delimiter + var stack = []; + if (svgLabel.length > 0) { + // Instead of stacking glyphs, create a single SVG. + // This evades browser problems with imprecise positioning of spans. + var midHeight = realHeightTotal - topHeightTotal - bottomHeightTotal; + var viewBoxHeight = Math.round(realHeightTotal * 1000); + var pathStr = tallDelim(svgLabel, Math.round(midHeight * 1000)); + var path = new PathNode(svgLabel, pathStr); + var width = makeEm(viewBoxWidth / 1000); + var height = makeEm(viewBoxHeight / 1000); + var svg = new SvgNode([path], { + "width": width, + "height": height, + "viewBox": "0 0 " + viewBoxWidth + " " + viewBoxHeight + }); + var wrapper = makeSvgSpan([], [svg], options); + wrapper.height = viewBoxHeight / 1000; + wrapper.style.width = width; + wrapper.style.height = height; + stack.push({ + type: "elem", + elem: wrapper + }); + } else { + // Stack glyphs + // Start by adding the bottom symbol + stack.push(makeGlyphSpan(bottom, font, mode)); + stack.push(lap); // overlap + if (middle === null) { + // The middle section will be an SVG. Make it an extra 0.016em tall. + // We'll overlap by 0.008em at top and bottom. + var innerHeight = realHeightTotal - topHeightTotal - bottomHeightTotal + 2 * lapInEms; + stack.push(makeInner(repeat, innerHeight, options)); + } else { + // When there is a middle bit, we need the middle part and two repeated + // sections + var _innerHeight = (realHeightTotal - topHeightTotal - bottomHeightTotal - middleHeightTotal) / 2 + 2 * lapInEms; + stack.push(makeInner(repeat, _innerHeight, options)); + // Now insert the middle of the brace. + stack.push(lap); + stack.push(makeGlyphSpan(middle, font, mode)); + stack.push(lap); + stack.push(makeInner(repeat, _innerHeight, options)); + } + // Add the top symbol + stack.push(lap); + stack.push(makeGlyphSpan(top, font, mode)); + } + // Finally, build the vlist + var newOptions = options.havingBaseStyle(Style$1.TEXT); + var inner = makeVList({ + positionType: "bottom", + positionData: depth, + children: stack + }); + return styleWrap(makeSpan(["delimsizing", "mult"], [inner], newOptions), Style$1.TEXT, options, classes); +}; +// All surds have 0.08em padding above the vinculum inside the SVG. +// That keeps browser span height rounding error from pinching the line. +var vbPad = 80; // padding above the surd, measured inside the viewBox. +var emPad = 0.08; // padding, in ems, measured in the document. +var sqrtSvg = function sqrtSvg(sqrtName, height, viewBoxHeight, extraVinculum, options) { + var path = sqrtPath(sqrtName, extraVinculum, viewBoxHeight); + var pathNode = new PathNode(sqrtName, path); + var svg = new SvgNode([pathNode], { + // Note: 1000:1 ratio of viewBox to document em width. + "width": "400em", + "height": makeEm(height), + "viewBox": "0 0 400000 " + viewBoxHeight, + "preserveAspectRatio": "xMinYMin slice" + }); + return makeSvgSpan(["hide-tail"], [svg], options); +}; +/** + * Make a sqrt image of the given height, + */ +var makeSqrtImage = function makeSqrtImage(height, options) { + // Define a newOptions that removes the effect of size changes such as \Huge. + // We don't pick different a height surd for \Huge. For it, we scale up. + var newOptions = options.havingBaseSizing(); + // Pick the desired surd glyph from a sequence of surds. + var delim = traverseSequence("\\surd", height * newOptions.sizeMultiplier, stackLargeDelimiterSequence, newOptions); + var sizeMultiplier = newOptions.sizeMultiplier; // default + // The standard sqrt SVGs each have a 0.04em thick vinculum. + // If Settings.minRuleThickness is larger than that, we add extraVinculum. + var extraVinculum = Math.max(0, options.minRuleThickness - options.fontMetrics().sqrtRuleThickness); + // Create a span containing an SVG image of a sqrt symbol. + var span; + var spanHeight; + var texHeight; + var viewBoxHeight; + var advanceWidth; + // We create viewBoxes with 80 units of "padding" above each surd. + // Then browser rounding error on the parent span height will not + // encroach on the ink of the vinculum. But that padding is not + // included in the TeX-like `height` used for calculation of + // vertical alignment. So texHeight = span.height < span.style.height. + if (delim.type === "small") { + // Get an SVG that is derived from glyph U+221A in font KaTeX-Main. + // 1000 unit normal glyph height. + viewBoxHeight = 1000 + 1000 * extraVinculum + vbPad; + if (height < 1.0) { + sizeMultiplier = 1.0; // mimic a \textfont radical + } else if (height < 1.4) { + sizeMultiplier = 0.7; // mimic a \scriptfont radical + } + spanHeight = (1.0 + extraVinculum + emPad) / sizeMultiplier; + texHeight = (1.00 + extraVinculum) / sizeMultiplier; + span = sqrtSvg("sqrtMain", spanHeight, viewBoxHeight, extraVinculum, options); + span.style.minWidth = "0.853em"; + advanceWidth = 0.833 / sizeMultiplier; // from the font. + } else if (delim.type === "large") { + // These SVGs come from fonts: KaTeX_Size1, _Size2, etc. + viewBoxHeight = (1000 + vbPad) * sizeToMaxHeight[delim.size]; + texHeight = (sizeToMaxHeight[delim.size] + extraVinculum) / sizeMultiplier; + spanHeight = (sizeToMaxHeight[delim.size] + extraVinculum + emPad) / sizeMultiplier; + span = sqrtSvg("sqrtSize" + delim.size, spanHeight, viewBoxHeight, extraVinculum, options); + span.style.minWidth = "1.02em"; + advanceWidth = 1.0 / sizeMultiplier; // 1.0 from the font. + } else { + // Tall sqrt. In TeX, this would be stacked using multiple glyphs. + // We'll use a single SVG to accomplish the same thing. + spanHeight = height + extraVinculum + emPad; + texHeight = height + extraVinculum; + viewBoxHeight = Math.floor(1000 * height + extraVinculum) + vbPad; + span = sqrtSvg("sqrtTall", spanHeight, viewBoxHeight, extraVinculum, options); + span.style.minWidth = "0.742em"; + advanceWidth = 1.056; + } + span.height = texHeight; + span.style.height = makeEm(spanHeight); + return { + span, + advanceWidth, + // Calculate the actual line width. + // This actually should depend on the chosen font -- e.g. \boldmath + // should use the thicker surd symbols from e.g. KaTeX_Main-Bold, and + // have thicker rules. + ruleWidth: (options.fontMetrics().sqrtRuleThickness + extraVinculum) * sizeMultiplier + }; +}; +// There are three kinds of delimiters, delimiters that stack when they become +// too large +var stackLargeDelimiters = new Set(["(", "\\lparen", ")", "\\rparen", "[", "\\lbrack", "]", "\\rbrack", "\\{", "\\lbrace", "\\}", "\\rbrace", "\\lfloor", "\\rfloor", "\u230a", "\u230b", "\\lceil", "\\rceil", "\u2308", "\u2309", "\\surd"]); +// delimiters that always stack +var stackAlwaysDelimiters = new Set(["\\uparrow", "\\downarrow", "\\updownarrow", "\\Uparrow", "\\Downarrow", "\\Updownarrow", "|", "\\|", "\\vert", "\\Vert", "\\lvert", "\\rvert", "\\lVert", "\\rVert", "\\lgroup", "\\rgroup", "\u27ee", "\u27ef", "\\lmoustache", "\\rmoustache", "\u23b0", "\u23b1"]); +// and delimiters that never stack +var stackNeverDelimiters = new Set(["<", ">", "\\langle", "\\rangle", "/", "\\backslash", "\\lt", "\\gt"]); +// Metrics of the different sizes. Found by looking at TeX's output of +// $\bigl| // \Bigl| \biggl| \Biggl| \showlists$ +// Used to create stacked delimiters of appropriate sizes in makeSizedDelim. +var sizeToMaxHeight = [0, 1.2, 1.8, 2.4, 3.0]; +/** + * Used to create a delimiter of a specific size, where `size` is 1, 2, 3, or 4. + */ +var makeSizedDelim = function makeSizedDelim(delim, size, options, mode, classes) { + // < and > turn into \langle and \rangle in delimiters + if (delim === "<" || delim === "\\lt" || delim === "\u27e8") { + delim = "\\langle"; + } else if (delim === ">" || delim === "\\gt" || delim === "\u27e9") { + delim = "\\rangle"; + } + // Sized delimiters are never centered. + if (stackLargeDelimiters.has(delim) || stackNeverDelimiters.has(delim)) { + return makeLargeDelim(delim, size, false, options, mode, classes); + } else if (stackAlwaysDelimiters.has(delim)) { + return makeStackedDelim(delim, sizeToMaxHeight[size], false, options, mode, classes); + } else { + throw new ParseError("Illegal delimiter: '" + delim + "'"); + } +}; +// Delimiters that never stack try small delimiters and large delimiters only +var stackNeverDelimiterSequence = [{ + type: "small", + style: Style$1.SCRIPTSCRIPT +}, { + type: "small", + style: Style$1.SCRIPT +}, { + type: "small", + style: Style$1.TEXT +}, { + type: "large", + size: 1 +}, { + type: "large", + size: 2 +}, { + type: "large", + size: 3 +}, { + type: "large", + size: 4 +}]; +// Delimiters that always stack try the small delimiters first, then stack +var stackAlwaysDelimiterSequence = [{ + type: "small", + style: Style$1.SCRIPTSCRIPT +}, { + type: "small", + style: Style$1.SCRIPT +}, { + type: "small", + style: Style$1.TEXT +}, { + type: "stack" +}]; +// Delimiters that stack when large try the small and then large delimiters, and +// stack afterwards +var stackLargeDelimiterSequence = [{ + type: "small", + style: Style$1.SCRIPTSCRIPT +}, { + type: "small", + style: Style$1.SCRIPT +}, { + type: "small", + style: Style$1.TEXT +}, { + type: "large", + size: 1 +}, { + type: "large", + size: 2 +}, { + type: "large", + size: 3 +}, { + type: "large", + size: 4 +}, { + type: "stack" +}]; +/** + * Get the font used in a delimiter based on what kind of delimiter it is. + * TODO(#963) Use more specific font family return type once that is introduced. + */ +var delimTypeToFont = function delimTypeToFont(type) { + if (type.type === "small") { + return "Main-Regular"; + } else if (type.type === "large") { + return "Size" + type.size + "-Regular"; + } else if (type.type === "stack") { + return "Size4-Regular"; + } else { + var delimKind = type.type; + throw new Error("Add support for delim type '" + delimKind + "' here."); + } +}; +/** + * Traverse a sequence of types of delimiters to decide what kind of delimiter + * should be used to create a delimiter of the given height+depth. + */ +var traverseSequence = function traverseSequence(delim, height, sequence, options) { + // Here, we choose the index we should start at in the sequences. In smaller + // sizes (which correspond to larger numbers in style.size) we start earlier + // in the sequence. Thus, scriptscript starts at index 3-3=0, script starts + // at index 3-2=1, text starts at 3-1=2, and display starts at min(2,3-0)=2 + var start = Math.min(2, 3 - options.style.size); + for (var i = start; i < sequence.length; i++) { + var delimType = sequence[i]; + if (delimType.type === "stack") { + // This is always the last delimiter, so we just break the loop now. + break; + } + var metrics = getMetrics(delim, delimTypeToFont(delimType), "math"); + var heightDepth = metrics.height + metrics.depth; + // Small delimiters are scaled down versions of the same font, so we + // account for the style change size. + if (delimType.type === "small") { + var newOptions = options.havingBaseStyle(delimType.style); + heightDepth *= newOptions.sizeMultiplier; + } + // Check if the delimiter at this size works for the given height. + if (heightDepth > height) { + return delimType; + } + } + // If we reached the end of the sequence, return the last sequence element. + return sequence[sequence.length - 1]; +}; +/** + * Make a delimiter of a given height+depth, with optional centering. Here, we + * traverse the sequences, and create a delimiter that the sequence tells us to. + */ +var makeCustomSizedDelim = function makeCustomSizedDelim(delim, height, center, options, mode, classes) { + if (delim === "<" || delim === "\\lt" || delim === "\u27e8") { + delim = "\\langle"; + } else if (delim === ">" || delim === "\\gt" || delim === "\u27e9") { + delim = "\\rangle"; + } + // Decide what sequence to use + var sequence; + if (stackNeverDelimiters.has(delim)) { + sequence = stackNeverDelimiterSequence; + } else if (stackLargeDelimiters.has(delim)) { + sequence = stackLargeDelimiterSequence; + } else { + sequence = stackAlwaysDelimiterSequence; + } + // Look through the sequence + var delimType = traverseSequence(delim, height, sequence, options); + // Get the delimiter from font glyphs. + // Depending on the sequence element we decided on, call the + // appropriate function. + if (delimType.type === "small") { + return makeSmallDelim(delim, delimType.style, center, options, mode, classes); + } else if (delimType.type === "large") { + return makeLargeDelim(delim, delimType.size, center, options, mode, classes); + } else /* if (delimType.type === "stack") */{ + return makeStackedDelim(delim, height, center, options, mode, classes); + } +}; +/** + * Make a delimiter for use with `\left` and `\right`, given a height and depth + * of an expression that the delimiters surround. + */ +var makeLeftRightDelim = function makeLeftRightDelim(delim, height, depth, options, mode, classes) { + // We always center \left/\right delimiters, so the axis is always shifted + var axisHeight = options.fontMetrics().axisHeight * options.sizeMultiplier; + // Taken from TeX source, tex.web, function make_left_right + var delimiterFactor = 901; + var delimiterExtend = 5.0 / options.fontMetrics().ptPerEm; + var maxDistFromAxis = Math.max(height - axisHeight, depth + axisHeight); + var totalHeight = Math.max( + // In real TeX, calculations are done using integral values which are + // 65536 per pt, or 655360 per em. So, the division here truncates in + // TeX but doesn't here, producing different results. If we wanted to + // exactly match TeX's calculation, we could do + // Math.floor(655360 * maxDistFromAxis / 500) * + // delimiterFactor / 655360 + // (To see the difference, compare + // x^{x^{\left(\rule{0.1em}{0.68em}\right)}} + // in TeX and KaTeX) + maxDistFromAxis / 500 * delimiterFactor, 2 * maxDistFromAxis - delimiterExtend); + // Finally, we defer to `makeCustomSizedDelim` with our calculated total + // height + return makeCustomSizedDelim(delim, totalHeight, true, options, mode, classes); +}; + +// Extra data needed for the delimiter handler down below +var delimiterSizes = { + "\\bigl": { + mclass: "mopen", + size: 1 + }, + "\\Bigl": { + mclass: "mopen", + size: 2 + }, + "\\biggl": { + mclass: "mopen", + size: 3 + }, + "\\Biggl": { + mclass: "mopen", + size: 4 + }, + "\\bigr": { + mclass: "mclose", + size: 1 + }, + "\\Bigr": { + mclass: "mclose", + size: 2 + }, + "\\biggr": { + mclass: "mclose", + size: 3 + }, + "\\Biggr": { + mclass: "mclose", + size: 4 + }, + "\\bigm": { + mclass: "mrel", + size: 1 + }, + "\\Bigm": { + mclass: "mrel", + size: 2 + }, + "\\biggm": { + mclass: "mrel", + size: 3 + }, + "\\Biggm": { + mclass: "mrel", + size: 4 + }, + "\\big": { + mclass: "mord", + size: 1 + }, + "\\Big": { + mclass: "mord", + size: 2 + }, + "\\bigg": { + mclass: "mord", + size: 3 + }, + "\\Bigg": { + mclass: "mord", + size: 4 + } +}; +var delimiters = new Set(["(", "\\lparen", ")", "\\rparen", "[", "\\lbrack", "]", "\\rbrack", "\\{", "\\lbrace", "\\}", "\\rbrace", "\\lfloor", "\\rfloor", "\u230a", "\u230b", "\\lceil", "\\rceil", "\u2308", "\u2309", "<", ">", "\\langle", "\u27e8", "\\rangle", "\u27e9", "\\lt", "\\gt", "\\lvert", "\\rvert", "\\lVert", "\\rVert", "\\lgroup", "\\rgroup", "\u27ee", "\u27ef", "\\lmoustache", "\\rmoustache", "\u23b0", "\u23b1", "/", "\\backslash", "|", "\\vert", "\\|", "\\Vert", "\\uparrow", "\\Uparrow", "\\downarrow", "\\Downarrow", "\\updownarrow", "\\Updownarrow", "."]); +function isMiddleDelimNode(node) { + return 'isMiddle' in node; +} +// Delimiter functions +function checkDelimiter(delim, context) { + var symDelim = checkSymbolNodeType(delim); + if (symDelim && delimiters.has(symDelim.text)) { + return symDelim; + } else if (symDelim) { + throw new ParseError("Invalid delimiter '" + symDelim.text + "' after '" + context.funcName + "'", delim); + } else { + throw new ParseError("Invalid delimiter type '" + delim.type + "'", delim); + } +} +defineFunction({ + type: "delimsizing", + names: ["\\bigl", "\\Bigl", "\\biggl", "\\Biggl", "\\bigr", "\\Bigr", "\\biggr", "\\Biggr", "\\bigm", "\\Bigm", "\\biggm", "\\Biggm", "\\big", "\\Big", "\\bigg", "\\Bigg"], + props: { + numArgs: 1, + argTypes: ["primitive"] + }, + handler: (context, args) => { + var delim = checkDelimiter(args[0], context); + return { + type: "delimsizing", + mode: context.parser.mode, + size: delimiterSizes[context.funcName].size, + mclass: delimiterSizes[context.funcName].mclass, + delim: delim.text + }; + }, + htmlBuilder: (group, options) => { + if (group.delim === ".") { + // Empty delimiters still count as elements, even though they don't + // show anything. + return makeSpan([group.mclass]); + } + return makeSizedDelim(group.delim, group.size, options, group.mode, [group.mclass]); + }, + mathmlBuilder: group => { + var children = []; + if (group.delim !== ".") { + children.push(makeText(group.delim, group.mode)); + } + var node = new MathNode("mo", children); + if (group.mclass === "mopen" || group.mclass === "mclose") { + // Only some of the delimsizing functions act as fences, and they + // return "mopen" or "mclose" mclass. + node.setAttribute("fence", "true"); + } else { + // Explicitly disable fencing if it's not a fence, to override the + // defaults. + node.setAttribute("fence", "false"); + } + node.setAttribute("stretchy", "true"); + var size = makeEm(sizeToMaxHeight[group.size]); + node.setAttribute("minsize", size); + node.setAttribute("maxsize", size); + return node; + } +}); +function assertParsed(group) { + if (!group.body) { + throw new Error("Bug: The leftright ParseNode wasn't fully parsed."); + } +} +defineFunction({ + type: "leftright-right", + names: ["\\right"], + props: { + numArgs: 1, + primitive: true + }, + handler: (context, args) => { + // \left case below triggers parsing of \right in + // `const right = parser.parseFunction();` + // uses this return value. + var color = context.parser.gullet.macros.get("\\current@color"); + if (color && typeof color !== "string") { + throw new ParseError("\\current@color set to non-string in \\right"); + } + return { + type: "leftright-right", + mode: context.parser.mode, + delim: checkDelimiter(args[0], context).text, + color: color // undefined if not set via \color + }; + } +}); +defineFunction({ + type: "leftright", + names: ["\\left"], + props: { + numArgs: 1, + primitive: true + }, + handler: (context, args) => { + var delim = checkDelimiter(args[0], context); + var parser = context.parser; + // Parse out the implicit body + ++parser.leftrightDepth; + // parseExpression stops before '\\right' + var body = parser.parseExpression(false); + --parser.leftrightDepth; + // Check the next token + parser.expect("\\right", false); + var right = assertNodeType(parser.parseFunction(), "leftright-right"); + return { + type: "leftright", + mode: parser.mode, + body, + left: delim.text, + right: right.delim, + rightColor: right.color + }; + }, + htmlBuilder: (group, options) => { + assertParsed(group); + // Build the inner expression + var inner = buildExpression$1(group.body, options, true, ["mopen", "mclose"]); + var innerHeight = 0; + var innerDepth = 0; + var hadMiddle = false; + // Calculate its height and depth + for (var i = 0; i < inner.length; i++) { + var node = inner[i]; + if (isMiddleDelimNode(node)) { + hadMiddle = true; + } else { + innerHeight = Math.max(inner[i].height, innerHeight); + innerDepth = Math.max(inner[i].depth, innerDepth); + } + } + // The size of delimiters is the same, regardless of what style we are + // in. Thus, to correctly calculate the size of delimiter we need around + // a group, we scale down the inner size based on the size. + innerHeight *= options.sizeMultiplier; + innerDepth *= options.sizeMultiplier; + var leftDelim; + if (group.left === ".") { + // Empty delimiters in \left and \right make null delimiter spaces. + leftDelim = makeNullDelimiter(options, ["mopen"]); + } else { + // Otherwise, use leftRightDelim to generate the correct sized + // delimiter. + leftDelim = makeLeftRightDelim(group.left, innerHeight, innerDepth, options, group.mode, ["mopen"]); + } + // Add it to the beginning of the expression + inner.unshift(leftDelim); + // Handle middle delimiters + if (hadMiddle) { + for (var _i = 1; _i < inner.length; _i++) { + var middleDelim = inner[_i]; + if (isMiddleDelimNode(middleDelim)) { + var isMiddle = middleDelim.isMiddle; + // Apply the options that were active when \middle was called + inner[_i] = makeLeftRightDelim(isMiddle.delim, innerHeight, innerDepth, isMiddle.options, group.mode, []); + } + } + } + var rightDelim; + // Same for the right delimiter, but using color specified by \color + if (group.right === ".") { + rightDelim = makeNullDelimiter(options, ["mclose"]); + } else { + var colorOptions = group.rightColor ? options.withColor(group.rightColor) : options; + rightDelim = makeLeftRightDelim(group.right, innerHeight, innerDepth, colorOptions, group.mode, ["mclose"]); + } + // Add it to the end of the expression. + inner.push(rightDelim); + return makeSpan(["minner"], inner, options); + }, + mathmlBuilder: (group, options) => { + assertParsed(group); + var inner = buildExpression(group.body, options); + if (group.left !== ".") { + var leftNode = new MathNode("mo", [makeText(group.left, group.mode)]); + leftNode.setAttribute("fence", "true"); + inner.unshift(leftNode); + } + if (group.right !== ".") { + var rightNode = new MathNode("mo", [makeText(group.right, group.mode)]); + rightNode.setAttribute("fence", "true"); + if (group.rightColor) { + rightNode.setAttribute("mathcolor", group.rightColor); + } + inner.push(rightNode); + } + return makeRow(inner); + } +}); +defineFunction({ + type: "middle", + names: ["\\middle"], + props: { + numArgs: 1, + primitive: true + }, + handler: (context, args) => { + var delim = checkDelimiter(args[0], context); + if (!context.parser.leftrightDepth) { + throw new ParseError("\\middle without preceding \\left", delim); + } + return { + type: "middle", + mode: context.parser.mode, + delim: delim.text + }; + }, + htmlBuilder: (group, options) => { + var middleDelim; + if (group.delim === ".") { + middleDelim = makeNullDelimiter(options, []); + } else { + middleDelim = makeSizedDelim(group.delim, 1, options, group.mode, []); + // Patch an ad-hoc property onto the node so the \left/\right + // builder can reconstruct appropriately sized middle delimiters. + // isMiddle is not part of HtmlDomNode; the read side uses + // isMiddleDelimNode() to check before accessing. + middleDelim.isMiddle = { + delim: group.delim, + options + }; + } + return middleDelim; + }, + mathmlBuilder: (group, options) => { + // A Firefox \middle will stretch a character vertically only if it + // is in the fence part of the operator dictionary at: + // https://www.w3.org/TR/MathML3/appendixc.html. + // So we need to avoid U+2223 and use plain "|" instead. + var textNode = group.delim === "\\vert" || group.delim === "|" ? makeText("|", "text") : makeText(group.delim, group.mode); + var middleNode = new MathNode("mo", [textNode]); + middleNode.setAttribute("fence", "true"); + // MathML gives 5/18em spacing to each element. + // \middle should get delimiter spacing instead. + middleNode.setAttribute("lspace", "0.05em"); + middleNode.setAttribute("rspace", "0.05em"); + return middleNode; + } +}); + +var htmlBuilder$7 = (group, options) => { + // \cancel, \bcancel, \xcancel, \sout, \fbox, \colorbox, \fcolorbox, \phase + // Some groups can return document fragments. Handle those by wrapping + // them in a span. + var inner = wrapFragment(buildGroup$1(group.body, options), options); + var label = group.label.slice(1); + var scale = options.sizeMultiplier; + var img; + var imgShift; + // In the LaTeX cancel package, line geometry is slightly different + // depending on whether the subject is wider than it is tall, or vice versa. + // We don't know the width of a group, so as a proxy, we test if + // the subject is a single character. This captures most of the + // subjects that should get the "tall" treatment. + var isSingleChar = isCharacterBox(group.body); + if (label === "sout") { + img = makeSpan(["stretchy", "sout"]); + img.height = options.fontMetrics().defaultRuleThickness / scale; + imgShift = -0.5 * options.fontMetrics().xHeight; + } else if (label === "phase") { + // Set a couple of dimensions from the steinmetz package. + var lineWeight = calculateSize({ + number: 0.6, + unit: "pt" + }, options); + var clearance = calculateSize({ + number: 0.35, + unit: "ex" + }, options); + // Prevent size changes like \Huge from affecting line thickness + var newOptions = options.havingBaseSizing(); + scale = scale / newOptions.sizeMultiplier; + var angleHeight = inner.height + inner.depth + lineWeight + clearance; + // Reserve a left pad for the angle. + inner.style.paddingLeft = makeEm(angleHeight / 2 + lineWeight); + // Create an SVG + var viewBoxHeight = Math.floor(1000 * angleHeight * scale); + var path = phasePath(viewBoxHeight); + var svgNode = new SvgNode([new PathNode("phase", path)], { + "width": "400em", + "height": makeEm(viewBoxHeight / 1000), + "viewBox": "0 0 400000 " + viewBoxHeight, + "preserveAspectRatio": "xMinYMin slice" + }); + // Wrap it in a span with overflow: hidden. + img = makeSvgSpan(["hide-tail"], [svgNode], options); + img.style.height = makeEm(angleHeight); + imgShift = inner.depth + lineWeight + clearance; + } else { + // Add horizontal padding + if (/cancel/.test(label)) { + if (!isSingleChar) { + inner.classes.push("cancel-pad"); + } + } else if (label === "angl") { + inner.classes.push("anglpad"); + } else { + inner.classes.push("boxpad"); + } + // Add vertical padding + var topPad; + var bottomPad; + var ruleThickness = 0; + // ref: cancel package: \advance\totalheight2\p@ % "+2" + if (/box/.test(label)) { + ruleThickness = Math.max(options.fontMetrics().fboxrule, + // default + options.minRuleThickness); + topPad = options.fontMetrics().fboxsep + (label === "colorbox" ? 0 : ruleThickness); + bottomPad = topPad; + } else if (label === "angl") { + ruleThickness = Math.max(options.fontMetrics().defaultRuleThickness, options.minRuleThickness); + topPad = 4 * ruleThickness; // gap = 3 × line, plus the line itself. + bottomPad = Math.max(0, 0.25 - inner.depth); + } else { + topPad = isSingleChar ? 0.2 : 0; + bottomPad = topPad; + } + img = stretchyEnclose(inner, label, topPad, bottomPad, options); + if (/fbox|boxed|fcolorbox/.test(label)) { + img.style.borderStyle = "solid"; + img.style.borderWidth = makeEm(ruleThickness); + } else if (label === "angl" && ruleThickness !== 0.049) { + img.style.borderTopWidth = makeEm(ruleThickness); + img.style.borderRightWidth = makeEm(ruleThickness); + } + imgShift = inner.depth + bottomPad; + if (group.backgroundColor) { + img.style.backgroundColor = group.backgroundColor; + if (group.borderColor) { + img.style.borderColor = group.borderColor; + } + } + } + var vlist; + if (group.backgroundColor) { + vlist = makeVList({ + positionType: "individualShift", + children: [ + // Put the color background behind inner; + { + type: "elem", + elem: img, + shift: imgShift + }, { + type: "elem", + elem: inner, + shift: 0 + }] + }); + } else { + var classes = /cancel|phase/.test(label) ? ["svg-align"] : []; + vlist = makeVList({ + positionType: "individualShift", + children: [ + // Write the \cancel stroke on top of inner. + { + type: "elem", + elem: inner, + shift: 0 + }, { + type: "elem", + elem: img, + shift: imgShift, + wrapperClasses: classes + }] + }); + } + if (/cancel/.test(label)) { + // The cancel package documentation says that cancel lines add their height + // to the expression, but tests show that isn't how it actually works. + vlist.height = inner.height; + vlist.depth = inner.depth; + } + if (/cancel/.test(label) && !isSingleChar) { + // cancel does not create horiz space for its line extension. + return makeSpan(["mord", "cancel-lap"], [vlist], options); + } else { + return makeSpan(["mord"], [vlist], options); + } +}; +var mathmlBuilder$6 = (group, options) => { + var fboxsep; + var node = new MathNode(group.label.includes("colorbox") ? "mpadded" : "menclose", [buildGroup(group.body, options)]); + switch (group.label) { + case "\\cancel": + node.setAttribute("notation", "updiagonalstrike"); + break; + case "\\bcancel": + node.setAttribute("notation", "downdiagonalstrike"); + break; + case "\\phase": + node.setAttribute("notation", "phasorangle"); + break; + case "\\sout": + node.setAttribute("notation", "horizontalstrike"); + break; + case "\\fbox": + node.setAttribute("notation", "box"); + break; + case "\\angl": + node.setAttribute("notation", "actuarial"); + break; + case "\\fcolorbox": + case "\\colorbox": + // doesn't have a good notation option. So use + // instead. Set some attributes that come included with . + fboxsep = options.fontMetrics().fboxsep * options.fontMetrics().ptPerEm; + node.setAttribute("width", "+" + 2 * fboxsep + "pt"); + node.setAttribute("height", "+" + 2 * fboxsep + "pt"); + node.setAttribute("lspace", fboxsep + "pt"); // + node.setAttribute("voffset", fboxsep + "pt"); + if (group.label === "\\fcolorbox") { + var thk = Math.max(options.fontMetrics().fboxrule, + // default + options.minRuleThickness); + node.setAttribute("style", "border: " + makeEm(thk) + " solid " + group.borderColor); + } + break; + case "\\xcancel": + node.setAttribute("notation", "updiagonalstrike downdiagonalstrike"); + break; + } + if (group.backgroundColor) { + node.setAttribute("mathbackground", group.backgroundColor); + } + return node; +}; +defineFunction({ + type: "enclose", + names: ["\\colorbox"], + props: { + numArgs: 2, + allowedInText: true, + argTypes: ["color", "hbox"] + }, + handler(_ref, args, optArgs) { + var { + parser, + funcName + } = _ref; + var color = assertNodeType(args[0], "color-token").color; + var body = args[1]; + return { + type: "enclose", + mode: parser.mode, + label: funcName, + backgroundColor: color, + body + }; + }, + htmlBuilder: htmlBuilder$7, + mathmlBuilder: mathmlBuilder$6 +}); +defineFunction({ + type: "enclose", + names: ["\\fcolorbox"], + props: { + numArgs: 3, + allowedInText: true, + argTypes: ["color", "color", "hbox"] + }, + handler(_ref2, args, optArgs) { + var { + parser, + funcName + } = _ref2; + var borderColor = assertNodeType(args[0], "color-token").color; + var backgroundColor = assertNodeType(args[1], "color-token").color; + var body = args[2]; + return { + type: "enclose", + mode: parser.mode, + label: funcName, + backgroundColor, + borderColor, + body + }; + }, + htmlBuilder: htmlBuilder$7, + mathmlBuilder: mathmlBuilder$6 +}); +defineFunction({ + type: "enclose", + names: ["\\fbox"], + props: { + numArgs: 1, + argTypes: ["hbox"], + allowedInText: true + }, + handler(_ref3, args) { + var { + parser + } = _ref3; + return { + type: "enclose", + mode: parser.mode, + label: "\\fbox", + body: args[0] + }; + } +}); +defineFunction({ + type: "enclose", + names: ["\\cancel", "\\bcancel", "\\xcancel", "\\phase"], + props: { + numArgs: 1 + }, + handler(_ref4, args) { + var { + parser, + funcName + } = _ref4; + var body = args[0]; + return { + type: "enclose", + mode: parser.mode, + label: funcName, + body + }; + }, + htmlBuilder: htmlBuilder$7, + mathmlBuilder: mathmlBuilder$6 +}); +defineFunction({ + type: "enclose", + names: ["\\sout"], + props: { + numArgs: 1, + allowedInText: true + }, + handler(_ref5, args) { + var { + parser, + funcName + } = _ref5; + if (parser.mode === "math") { + parser.settings.reportNonstrict("mathVsSout", "LaTeX's \\sout works only in text mode"); + } + var body = args[0]; + return { + type: "enclose", + mode: parser.mode, + label: funcName, + body + }; + }, + htmlBuilder: htmlBuilder$7, + mathmlBuilder: mathmlBuilder$6 +}); +defineFunction({ + type: "enclose", + names: ["\\angl"], + props: { + numArgs: 1, + argTypes: ["hbox"], + allowedInText: false + }, + handler(_ref6, args) { + var { + parser + } = _ref6; + return { + type: "enclose", + mode: parser.mode, + label: "\\angl", + body: args[0] + }; + } +}); + +/** + * All registered environments. + * `environments.js` exports this same dictionary again and makes it public. + * `Parser.js` requires this dictionary via `environments.js`. + */ +var _environments = {}; +function defineEnvironment(_ref) { + var { + type, + names, + props, + handler, + htmlBuilder, + mathmlBuilder + } = _ref; + // Set default values of environments. + var data = { + type, + numArgs: props.numArgs || 0, + allowedInText: false, + numOptionalArgs: 0, + handler + }; + for (var i = 0; i < names.length; ++i) { + // TODO: The value type of _environments should be a type union of all + // possible `EnvSpec<>` possibilities instead of `EnvSpec<*>`, which is + // an existential type. + _environments[names[i]] = data; + } + if (htmlBuilder) { + _htmlGroupBuilders[type] = htmlBuilder; + } + if (mathmlBuilder) { + _mathmlGroupBuilders[type] = mathmlBuilder; + } +} + +/** + * All registered global/built-in macros. + * `macros.js` exports this same dictionary again and makes it public. + * `Parser.js` requires this dictionary via `macros.js`. + */ +var _macros = {}; +// This function might one day accept an additional argument and do more things. +function defineMacro(name, body) { + _macros[name] = body; +} + +/** + * Lexing or parsing positional information for error reporting. + * This object is immutable. + */ +class SourceLocation { + // End offset, zero-based exclusive. + constructor(lexer, start, end) { + // The + prefix indicates that these fields aren't writeable + this.lexer = void 0; + // Lexer holding the input string. + this.start = void 0; + // Start offset, zero-based inclusive. + this.end = void 0; + this.lexer = lexer; + this.start = start; + this.end = end; + } + /** + * Merges two `SourceLocation`s from location providers, given they are + * provided in order of appearance. + * - Returns the first one's location if only the first is provided. + * - Returns a merged range of the first and the last if both are provided + * and their lexers match. + * - Otherwise, returns null. + */ + static range(first, second) { + if (!second) { + return first && first.loc; + } else if (!first || !first.loc || !second.loc || first.loc.lexer !== second.loc.lexer) { + return null; + } else { + return new SourceLocation(first.loc.lexer, first.loc.start, second.loc.end); + } + } +} + +/** + * The resulting token returned from `lex`. + * + * It consists of the token text plus some position information. + * The position information is essentially a range in an input string, + * but instead of referencing the bare input string, we refer to the lexer. + * That way it is possible to attach extra metadata to the input string, + * like for example a file name or similar. + * + * The position information is optional, so it is OK to construct synthetic + * tokens if appropriate. Not providing available position information may + * lead to degraded error reporting, though. + */ +class Token { + // used in \noexpand + constructor(text, + // the text of this token + loc) { + this.text = void 0; + this.loc = void 0; + this.noexpand = void 0; + // don't expand the token + this.treatAsRelax = void 0; + this.text = text; + this.loc = loc; + } + /** + * Given a pair of tokens (this and endToken), compute a `Token` encompassing + * the whole input range enclosed by these two. + */ + range(endToken, + // last token of the range, inclusive + text) { + return new Token(text, SourceLocation.range(this, endToken)); + } +} + +// Helper functions +function getHLines(parser) { + // Return an array. The array length = number of hlines. + // Each element in the array tells if the line is dashed. + var hlineInfo = []; + parser.consumeSpaces(); + var nxt = parser.fetch().text; + if (nxt === "\\relax") { + // \relax is an artifact of the \cr macro below + parser.consume(); + parser.consumeSpaces(); + nxt = parser.fetch().text; + } + while (nxt === "\\hline" || nxt === "\\hdashline") { + parser.consume(); + hlineInfo.push(nxt === "\\hdashline"); + parser.consumeSpaces(); + nxt = parser.fetch().text; + } + return hlineInfo; +} +var validateAmsEnvironmentContext = context => { + var settings = context.parser.settings; + if (!settings.displayMode) { + throw new ParseError("{" + context.envName + "} can be used only in" + " display mode."); + } +}; +var gatherEnvironments = new Set(["gather", "gather*"]); +// autoTag (an argument to parseArray) can be one of three values: +// * undefined: Regular (not-top-level) array; no tags on each row +// * true: Automatic equation numbering, overridable by \tag +// * false: Tags allowed on each row, but no automatic numbering +// This function *doesn't* work with the "split" environment name. +function getAutoTag(name) { + if (!name.includes("ed")) { + return !name.includes("*"); + } + // return undefined; +} +/** + * Parse the body of the environment, with rows delimited by \\ and + * columns delimited by &, and create a nested list in row-major order + * with one group per cell. If given an optional argument style + * ("text", "display", etc.), then each cell is cast into that style. + */ +function parseArray(parser, _ref, style) { + var { + hskipBeforeAndAfter, + addJot, + cols, + arraystretch, + colSeparationType, + autoTag, + singleRow, + emptySingleRow, + maxNumCols, + leqno + } = _ref; + parser.gullet.beginGroup(); + if (!singleRow) { + // \cr is equivalent to \\ without the optional size argument (see below) + // TODO: provide helpful error when \cr is used outside array environment + parser.gullet.macros.set("\\cr", "\\\\\\relax"); + } + // Get current arraystretch if it's not set by the environment + if (!arraystretch) { + var stretch = parser.gullet.expandMacroAsText("\\arraystretch"); + if (stretch == null) { + // Default \arraystretch from lttab.dtx + arraystretch = 1; + } else { + arraystretch = parseFloat(stretch); + if (!arraystretch || arraystretch < 0) { + throw new ParseError("Invalid \\arraystretch: " + stretch); + } + } + } + // Start group for first cell + parser.gullet.beginGroup(); + var row = []; + var body = [row]; + var rowGaps = []; + var hLinesBeforeRow = []; + var tags = autoTag != null ? [] : undefined; + // amsmath uses \global\@eqnswtrue and \global\@eqnswfalse to represent + // whether this row should have an equation number. Simulate this with + // a \@eqnsw macro set to 1 or 0. + function beginRow() { + if (autoTag) { + parser.gullet.macros.set("\\@eqnsw", "1", true); + } + } + function endRow() { + if (tags) { + if (parser.gullet.macros.get("\\df@tag")) { + tags.push(parser.subparse([new Token("\\df@tag")])); + parser.gullet.macros.set("\\df@tag", undefined, true); + } else { + tags.push(Boolean(autoTag) && parser.gullet.macros.get("\\@eqnsw") === "1"); + } + } + } + beginRow(); + // Test for \hline at the top of the array. + hLinesBeforeRow.push(getHLines(parser)); + while (true) { + // Parse each cell in its own group (namespace) + var cellBody = parser.parseExpression(false, singleRow ? "\\end" : "\\\\"); + parser.gullet.endGroup(); + parser.gullet.beginGroup(); + var cell = { + type: "ordgroup", + mode: parser.mode, + body: cellBody + }; + if (style) { + cell = { + type: "styling", + mode: parser.mode, + style, + resetFont: true, + body: [cell] + }; + } + row.push(cell); + var next = parser.fetch().text; + if (next === "&") { + if (maxNumCols && row.length === maxNumCols) { + if (singleRow || colSeparationType) { + // {equation} or {split} + throw new ParseError("Too many tab characters: &", parser.nextToken); + } else { + // {array} environment + parser.settings.reportNonstrict("textEnv", "Too few columns " + "specified in the {array} column argument."); + } + } + parser.consume(); + } else if (next === "\\end") { + endRow(); + // Arrays terminate newlines with `\crcr` which consumes a `\cr` if + // the last line is empty. However, AMS environments keep the + // empty row if it's the only one. + // NOTE: Currently, `cell` is the last item added into `row`. + if (row.length === 1 && cell.type === "styling" && cell.body.length === 1 && cell.body[0].type === "ordgroup" && cell.body[0].body.length === 0 && (body.length > 1 || !emptySingleRow)) { + body.pop(); + } + if (hLinesBeforeRow.length < body.length + 1) { + hLinesBeforeRow.push([]); + } + break; + } else if (next === "\\\\") { + parser.consume(); + var size = void 0; + // \def\Let@{\let\\\math@cr} + // \def\math@cr{...\math@cr@} + // \def\math@cr@{\new@ifnextchar[\math@cr@@{\math@cr@@[\z@]}} + // \def\math@cr@@[#1]{...\math@cr@@@...} + // \def\math@cr@@@{\cr} + if (parser.gullet.future().text !== " ") { + size = parser.parseSizeGroup(true); + } + rowGaps.push(size ? size.value : null); + endRow(); + // check for \hline(s) following the row separator + hLinesBeforeRow.push(getHLines(parser)); + row = []; + body.push(row); + beginRow(); + } else { + throw new ParseError("Expected & or \\\\ or \\cr or \\end", parser.nextToken); + } + } + // End cell group + parser.gullet.endGroup(); + // End array group defining \cr + parser.gullet.endGroup(); + return { + type: "array", + mode: parser.mode, + addJot, + arraystretch, + body, + cols, + rowGaps, + hskipBeforeAndAfter, + hLinesBeforeRow, + colSeparationType, + tags, + leqno + }; +} +// Decides on a style for cells in an array according to whether the given +// environment name starts with the letter 'd'. +function dCellStyle(envName) { + if (envName.slice(0, 1) === "d") { + return "display"; + } else { + return "text"; + } +} +var htmlBuilder$6 = function htmlBuilder(group, options) { + var r; + var c; + var nr = group.body.length; + var hLinesBeforeRow = group.hLinesBeforeRow; + var nc = 0; + var body = new Array(nr); + var hlines = []; + var ruleThickness = Math.max( + // From LaTeX \showthe\arrayrulewidth. Equals 0.04 em. + options.fontMetrics().arrayRuleWidth, options.minRuleThickness); + // Horizontal spacing + var pt = 1 / options.fontMetrics().ptPerEm; + var arraycolsep = 5 * pt; // default value, i.e. \arraycolsep in article.cls + if (group.colSeparationType && group.colSeparationType === "small") { + // We're in a {smallmatrix}. Default column space is \thickspace, + // i.e. 5/18em = 0.2778em, per amsmath.dtx for {smallmatrix}. + // But that needs adjustment because LaTeX applies \scriptstyle to the + // entire array, including the colspace, but this function applies + // \scriptstyle only inside each element. + var localMultiplier = options.havingStyle(Style$1.SCRIPT).sizeMultiplier; + arraycolsep = 0.2778 * (localMultiplier / options.sizeMultiplier); + } + // Vertical spacing + var baselineskip = group.colSeparationType === "CD" ? calculateSize({ + number: 3, + unit: "ex" + }, options) : 12 * pt; // see size10.clo + // Default \jot from ltmath.dtx + // TODO(edemaine): allow overriding \jot via \setlength (#687) + var jot = 3 * pt; + var arrayskip = group.arraystretch * baselineskip; + var arstrutHeight = 0.7 * arrayskip; // \strutbox in ltfsstrc.dtx and + var arstrutDepth = 0.3 * arrayskip; // \@arstrutbox in lttab.dtx + var totalHeight = 0; + // Set a position for \hline(s) at the top of the array, if any. + function setHLinePos(hlinesInGap) { + for (var i = 0; i < hlinesInGap.length; ++i) { + if (i > 0) { + totalHeight += 0.25; + } + hlines.push({ + pos: totalHeight, + isDashed: hlinesInGap[i] + }); + } + } + setHLinePos(hLinesBeforeRow[0]); + for (r = 0; r < group.body.length; ++r) { + var inrow = group.body[r]; + var height = arstrutHeight; // \@array adds an \@arstrut + var depth = arstrutDepth; // to each tow (via the template) + if (nc < inrow.length) { + nc = inrow.length; + } + var outrow = { + cells: new Array(inrow.length), + height: 0, + depth: 0, + pos: 0 + }; + for (c = 0; c < inrow.length; ++c) { + var elt = buildGroup$1(inrow[c], options); + if (depth < elt.depth) { + depth = elt.depth; + } + if (height < elt.height) { + height = elt.height; + } + outrow.cells[c] = elt; + } + var rowGap = group.rowGaps[r]; + var gap = 0; + if (rowGap) { + gap = calculateSize(rowGap, options); + if (gap > 0) { + // \@argarraycr + gap += arstrutDepth; + if (depth < gap) { + depth = gap; // \@xargarraycr + } + gap = 0; + } + } + // In AMS multiline environments such as aligned and gathered, rows + // correspond to lines that have additional \jot added between lines + // via \openup. + // We simulate this by adding \jot depth to each row except the last. + if (group.addJot && r < group.body.length - 1) { + depth += jot; + } + outrow.height = height; + outrow.depth = depth; + totalHeight += height; + outrow.pos = totalHeight; + totalHeight += depth + gap; // \@yargarraycr + body[r] = outrow; + // Set a position for \hline(s), if any. + setHLinePos(hLinesBeforeRow[r + 1]); + } + var offset = totalHeight / 2 + options.fontMetrics().axisHeight; + var colDescriptions = group.cols || []; + var cols = []; + var colSep; + var colDescrNum; + var tagSpans = []; + if (group.tags && group.tags.some(tag => tag)) { + // An environment with manual tags and/or automatic equation numbers. + // Create node(s), the latter of which trigger CSS counter increment. + for (r = 0; r < nr; ++r) { + var rw = body[r]; + var shift = rw.pos - offset; + var tag = group.tags[r]; + var tagSpan = void 0; + if (tag === true) { + // automatic numbering + tagSpan = makeSpan(["eqn-num"], [], options); + } else if (tag === false) { + // \nonumber/\notag or starred environment + tagSpan = makeSpan([], [], options); + } else { + // manual \tag + tagSpan = makeSpan([], buildExpression$1(tag, options, true), options); + } + tagSpan.depth = rw.depth; + tagSpan.height = rw.height; + tagSpans.push({ + type: "elem", + elem: tagSpan, + shift + }); + } + } + for (c = 0, colDescrNum = 0; + // Continue while either there are more columns or more column + // descriptions, so trailing separators don't get lost. + c < nc || colDescrNum < colDescriptions.length; ++c, ++colDescrNum) { + var _colDescr3; + var colDescr = colDescriptions[colDescrNum]; + var firstSeparator = true; + while (((_colDescr = colDescr) == null ? void 0 : _colDescr.type) === "separator") { + var _colDescr; + // If there is more than one separator in a row, add a space + // between them. + if (!firstSeparator) { + colSep = makeSpan(["arraycolsep"], []); + colSep.style.width = makeEm(options.fontMetrics().doubleRuleSep); + cols.push(colSep); + } + if (colDescr.separator === "|" || colDescr.separator === ":") { + var lineType = colDescr.separator === "|" ? "solid" : "dashed"; + var separator = makeSpan(["vertical-separator"], [], options); + separator.style.height = makeEm(totalHeight); + separator.style.borderRightWidth = makeEm(ruleThickness); + separator.style.borderRightStyle = lineType; + separator.style.margin = "0 " + makeEm(-ruleThickness / 2); + var _shift = totalHeight - offset; + if (_shift) { + separator.style.verticalAlign = makeEm(-_shift); + } + cols.push(separator); + } else { + throw new ParseError("Invalid separator type: " + colDescr.separator); + } + colDescrNum++; + colDescr = colDescriptions[colDescrNum]; + firstSeparator = false; + } + if (c >= nc) { + continue; + } + var sepwidth = void 0; + if (c > 0 || group.hskipBeforeAndAfter) { + var _colDescr$pregap, _colDescr2; + sepwidth = (_colDescr$pregap = (_colDescr2 = colDescr) == null ? void 0 : _colDescr2.pregap) != null ? _colDescr$pregap : arraycolsep; + if (sepwidth !== 0) { + colSep = makeSpan(["arraycolsep"], []); + colSep.style.width = makeEm(sepwidth); + cols.push(colSep); + } + } + var colElems = []; + for (r = 0; r < nr; ++r) { + var row = body[r]; + var elem = row.cells[c]; + if (!elem) { + continue; + } + var _shift2 = row.pos - offset; + elem.depth = row.depth; + elem.height = row.height; + colElems.push({ + type: "elem", + elem: elem, + shift: _shift2 + }); + } + var colVList = makeVList({ + positionType: "individualShift", + children: colElems + }); + var colSpan = makeSpan(["col-align-" + (((_colDescr3 = colDescr) == null ? void 0 : _colDescr3.align) || "c")], [colVList]); + cols.push(colSpan); + if (c < nc - 1 || group.hskipBeforeAndAfter) { + var _colDescr$postgap, _colDescr4; + sepwidth = (_colDescr$postgap = (_colDescr4 = colDescr) == null ? void 0 : _colDescr4.postgap) != null ? _colDescr$postgap : arraycolsep; + if (sepwidth !== 0) { + colSep = makeSpan(["arraycolsep"], []); + colSep.style.width = makeEm(sepwidth); + cols.push(colSep); + } + } + } + var tableBody = makeSpan(["mtable"], cols); + // Add \hline(s), if any. + if (hlines.length > 0) { + var line = makeLineSpan("hline", options, ruleThickness); + var dashes = makeLineSpan("hdashline", options, ruleThickness); + var vListElems = [{ + type: "elem", + elem: tableBody, + shift: 0 + }]; + while (hlines.length > 0) { + var hline = hlines.pop(); + var lineShift = hline.pos - offset; + if (hline.isDashed) { + vListElems.push({ + type: "elem", + elem: dashes, + shift: lineShift + }); + } else { + vListElems.push({ + type: "elem", + elem: line, + shift: lineShift + }); + } + } + tableBody = makeVList({ + positionType: "individualShift", + children: vListElems + }); + } + if (tagSpans.length === 0) { + return makeSpan(["mord"], [tableBody], options); + } else { + var eqnNumCol = makeVList({ + positionType: "individualShift", + children: tagSpans + }); + var tagCol = makeSpan(["tag"], [eqnNumCol], options); + return makeFragment([tableBody, tagCol]); + } +}; +var alignMap = { + c: "center ", + l: "left ", + r: "right " +}; +var mathmlBuilder$5 = function mathmlBuilder(group, options) { + var tbl = []; + var glue = new MathNode("mtd", [], ["mtr-glue"]); + var tag = new MathNode("mtd", [], ["mml-eqn-num"]); + for (var i = 0; i < group.body.length; i++) { + var rw = group.body[i]; + var row = []; + for (var j = 0; j < rw.length; j++) { + row.push(new MathNode("mtd", [buildGroup(rw[j], options)])); + } + if (group.tags && group.tags[i]) { + row.unshift(glue); + row.push(glue); + if (group.leqno) { + row.unshift(tag); + } else { + row.push(tag); + } + } + tbl.push(new MathNode("mtr", row)); + } + var table = new MathNode("mtable", tbl); + // Set column alignment, row spacing, column spacing, and + // array lines by setting attributes on the table element. + // Set the row spacing. In MathML, we specify a gap distance. + // We do not use rowGap[] because MathML automatically increases + // cell height with the height/depth of the element content. + // LaTeX \arraystretch multiplies the row baseline-to-baseline distance. + // We simulate this by adding (arraystretch - 1)em to the gap. This + // does a reasonable job of adjusting arrays containing 1 em tall content. + // The 0.16 and 0.09 values are found empirically. They produce an array + // similar to LaTeX and in which content does not interfere with \hlines. + var gap = group.arraystretch === 0.5 ? 0.1 // {smallmatrix}, {subarray} + : 0.16 + group.arraystretch - 1 + (group.addJot ? 0.09 : 0); + table.setAttribute("rowspacing", makeEm(gap)); + // MathML table lines go only between cells. + // To place a line on an edge we'll use , if necessary. + var menclose = ""; + var align = ""; + if (group.cols && group.cols.length > 0) { + // Find column alignment, column spacing, and vertical lines. + var cols = group.cols; + var columnLines = ""; + var prevTypeWasAlign = false; + var iStart = 0; + var iEnd = cols.length; + if (cols[0].type === "separator") { + menclose += "top "; + iStart = 1; + } + if (cols[cols.length - 1].type === "separator") { + menclose += "bottom "; + iEnd -= 1; + } + for (var _i = iStart; _i < iEnd; _i++) { + var col = cols[_i]; + if (col.type === "align") { + align += alignMap[col.align]; + if (prevTypeWasAlign) { + columnLines += "none "; + } + prevTypeWasAlign = true; + } else if (col.type === "separator") { + // MathML accepts only single lines between cells. + // So we read only the first of consecutive separators. + if (prevTypeWasAlign) { + columnLines += col.separator === "|" ? "solid " : "dashed "; + prevTypeWasAlign = false; + } + } + } + table.setAttribute("columnalign", align.trim()); + if (/[sd]/.test(columnLines)) { + table.setAttribute("columnlines", columnLines.trim()); + } + } + // Set column spacing. + if (group.colSeparationType === "align") { + var _cols = group.cols || []; + var spacing = ""; + for (var _i2 = 1; _i2 < _cols.length; _i2++) { + spacing += _i2 % 2 ? "0em " : "1em "; + } + table.setAttribute("columnspacing", spacing.trim()); + } else if (group.colSeparationType === "alignat" || group.colSeparationType === "gather") { + table.setAttribute("columnspacing", "0em"); + } else if (group.colSeparationType === "small") { + table.setAttribute("columnspacing", "0.2778em"); + } else if (group.colSeparationType === "CD") { + table.setAttribute("columnspacing", "0.5em"); + } else { + table.setAttribute("columnspacing", "1em"); + } + // Address \hline and \hdashline + var rowLines = ""; + var hlines = group.hLinesBeforeRow; + menclose += hlines[0].length > 0 ? "left " : ""; + menclose += hlines[hlines.length - 1].length > 0 ? "right " : ""; + for (var _i3 = 1; _i3 < hlines.length - 1; _i3++) { + rowLines += hlines[_i3].length === 0 ? "none " + // MathML accepts only a single line between rows. Read one element. + : hlines[_i3][0] ? "dashed " : "solid "; + } + if (/[sd]/.test(rowLines)) { + table.setAttribute("rowlines", rowLines.trim()); + } + if (menclose !== "") { + table = new MathNode("menclose", [table]); + table.setAttribute("notation", menclose.trim()); + } + if (group.arraystretch && group.arraystretch < 1) { + // A small array. Wrap in scriptstyle so row gap is not too large. + table = new MathNode("mstyle", [table]); + table.setAttribute("scriptlevel", "1"); + } + return table; +}; +// Convenience function for align, align*, aligned, alignat, alignat*, alignedat. +var alignedHandler = function alignedHandler(context, args) { + if (!context.envName.includes("ed")) { + validateAmsEnvironmentContext(context); + } + var cols = []; + var separationType = context.envName.includes("at") ? "alignat" : "align"; + var isSplit = context.envName === "split"; + var res = parseArray(context.parser, { + cols, + addJot: true, + autoTag: isSplit ? undefined : getAutoTag(context.envName), + emptySingleRow: true, + colSeparationType: separationType, + maxNumCols: isSplit ? 2 : undefined, + leqno: context.parser.settings.leqno + }, "display"); + // Determining number of columns. + // 1. If the first argument is given, we use it as a number of columns, + // and makes sure that each row doesn't exceed that number. + // 2. Otherwise, just count number of columns = maximum number + // of cells in each row ("aligned" mode -- isAligned will be true). + // + // At the same time, prepend empty group {} at beginning of every second + // cell in each row (starting with second cell) so that operators become + // binary. This behavior is implemented in amsmath's \start@aligned. + var numMaths = 0; + var numCols = 0; + var emptyGroup = { + type: "ordgroup", + mode: context.mode, + body: [] + }; + if (args[0] && args[0].type === "ordgroup") { + var arg0 = ""; + for (var i = 0; i < args[0].body.length; i++) { + var textord = assertNodeType(args[0].body[i], "textord"); + arg0 += textord.text; + } + numMaths = Number(arg0); + numCols = numMaths * 2; + } + var isAligned = !numCols; + res.body.forEach(function (row) { + for (var _i4 = 1; _i4 < row.length; _i4 += 2) { + // Modify ordgroup node within styling node + var styling = assertNodeType(row[_i4], "styling"); + var ordgroup = assertNodeType(styling.body[0], "ordgroup"); + ordgroup.body.unshift(emptyGroup); + } + if (!isAligned) { + // Case 1 + var curMaths = row.length / 2; + if (numMaths < curMaths) { + throw new ParseError("Too many math in a row: " + ("expected " + numMaths + ", but got " + curMaths), row[0]); + } + } else if (numCols < row.length) { + // Case 2 + numCols = row.length; + } + }); + // Adjusting alignment. + // In aligned mode, we add one \qquad between columns; + // otherwise we add nothing. + for (var _i5 = 0; _i5 < numCols; ++_i5) { + var align = "r"; + var pregap = 0; + if (_i5 % 2 === 1) { + align = "l"; + } else if (_i5 > 0 && isAligned) { + // "aligned" mode. + pregap = 1; // add one \quad + } + cols[_i5] = { + type: "align", + align: align, + pregap: pregap, + postgap: 0 + }; + } + res.colSeparationType = isAligned ? "align" : "alignat"; + return res; +}; +// Arrays are part of LaTeX, defined in lttab.dtx so its documentation +// is part of the source2e.pdf file of LaTeX2e source documentation. +// {darray} is an {array} environment where cells are set in \displaystyle, +// as defined in nccmath.sty. +defineEnvironment({ + type: "array", + names: ["array", "darray"], + props: { + numArgs: 1 + }, + handler(context, args) { + // Since no types are specified above, the two possibilities are + // - The argument is wrapped in {} or [], in which case Parser's + // parseGroup() returns an "ordgroup" wrapping some symbol node. + // - The argument is a bare symbol node. + var symNode = checkSymbolNodeType(args[0]); + var colalign = symNode ? [args[0]] : assertNodeType(args[0], "ordgroup").body; + var cols = colalign.map(function (nde) { + var node = assertSymbolNodeType(nde); + var ca = node.text; + if ("lcr".includes(ca)) { + return { + type: "align", + align: ca + }; + } else if (ca === "|") { + return { + type: "separator", + separator: "|" + }; + } else if (ca === ":") { + return { + type: "separator", + separator: ":" + }; + } + throw new ParseError("Unknown column alignment: " + ca, nde); + }); + var res = { + cols, + hskipBeforeAndAfter: true, + // \@preamble in lttab.dtx + maxNumCols: cols.length + }; + return parseArray(context.parser, res, dCellStyle(context.envName)); + }, + htmlBuilder: htmlBuilder$6, + mathmlBuilder: mathmlBuilder$5 +}); +// The matrix environments of amsmath builds on the array environment +// of LaTeX, which is discussed above. +// The mathtools package adds starred versions of the same environments. +// These have an optional argument to choose left|center|right justification. +defineEnvironment({ + type: "array", + names: ["matrix", "pmatrix", "bmatrix", "Bmatrix", "vmatrix", "Vmatrix", "matrix*", "pmatrix*", "bmatrix*", "Bmatrix*", "vmatrix*", "Vmatrix*"], + props: { + numArgs: 0 + }, + handler(context) { + var delimiters = { + "matrix": null, + "pmatrix": ["(", ")"], + "bmatrix": ["[", "]"], + "Bmatrix": ["\\{", "\\}"], + "vmatrix": ["|", "|"], + "Vmatrix": ["\\Vert", "\\Vert"] + }[context.envName.replace("*", "")]; + // \hskip -\arraycolsep in amsmath + var colAlign = "c"; + var payload = { + hskipBeforeAndAfter: false, + cols: [{ + type: "align", + align: colAlign + }] + }; + if (context.envName.charAt(context.envName.length - 1) === "*") { + // It's one of the mathtools starred functions. + // Parse the optional alignment argument. + var parser = context.parser; + parser.consumeSpaces(); + if (parser.fetch().text === "[") { + parser.consume(); + parser.consumeSpaces(); + colAlign = parser.fetch().text; + if (!"lcr".includes(colAlign)) { + throw new ParseError("Expected l or c or r", parser.nextToken); + } + parser.consume(); + parser.consumeSpaces(); + parser.expect("]"); + parser.consume(); + payload.cols = [{ + type: "align", + align: colAlign + }]; + } + } + var res = parseArray(context.parser, payload, dCellStyle(context.envName)); + // Populate cols with the correct number of column alignment specs. + var numCols = Math.max(0, ...res.body.map(row => row.length)); + res.cols = new Array(numCols).fill({ + type: "align", + align: colAlign + }); + return delimiters ? { + type: "leftright", + mode: context.mode, + body: [res], + left: delimiters[0], + right: delimiters[1], + rightColor: undefined // \right uninfluenced by \color in array + } : res; + }, + htmlBuilder: htmlBuilder$6, + mathmlBuilder: mathmlBuilder$5 +}); +defineEnvironment({ + type: "array", + names: ["smallmatrix"], + props: { + numArgs: 0 + }, + handler(context) { + var payload = { + arraystretch: 0.5 + }; + var res = parseArray(context.parser, payload, "script"); + res.colSeparationType = "small"; + return res; + }, + htmlBuilder: htmlBuilder$6, + mathmlBuilder: mathmlBuilder$5 +}); +defineEnvironment({ + type: "array", + names: ["subarray"], + props: { + numArgs: 1 + }, + handler(context, args) { + // Parsing of {subarray} is similar to {array} + var symNode = checkSymbolNodeType(args[0]); + var colalign = symNode ? [args[0]] : assertNodeType(args[0], "ordgroup").body; + var cols = colalign.map(function (nde) { + var node = assertSymbolNodeType(nde); + var ca = node.text; + // {subarray} only recognizes "l" & "c" + if ("lc".includes(ca)) { + return { + type: "align", + align: ca + }; + } + throw new ParseError("Unknown column alignment: " + ca, nde); + }); + if (cols.length > 1) { + throw new ParseError("{subarray} can contain only one column"); + } + var payload = { + cols, + hskipBeforeAndAfter: false, + arraystretch: 0.5 + }; + var res = parseArray(context.parser, payload, "script"); + if (res.body.length > 0 && res.body[0].length > 1) { + throw new ParseError("{subarray} can contain only one column"); + } + return res; + }, + htmlBuilder: htmlBuilder$6, + mathmlBuilder: mathmlBuilder$5 +}); +// A cases environment (in amsmath.sty) is almost equivalent to +// \def\arraystretch{1.2}% +// \left\{\begin{array}{@{}l@{\quad}l@{}} … \end{array}\right. +// {dcases} is a {cases} environment where cells are set in \displaystyle, +// as defined in mathtools.sty. +// {rcases} is another mathtools environment. It's brace is on the right side. +defineEnvironment({ + type: "array", + names: ["cases", "dcases", "rcases", "drcases"], + props: { + numArgs: 0 + }, + handler(context) { + var payload = { + arraystretch: 1.2, + cols: [{ + type: "align", + align: "l", + pregap: 0, + // TODO(kevinb) get the current style. + // For now we use the metrics for TEXT style which is what we were + // doing before. Before attempting to get the current style we + // should look at TeX's behavior especially for \over and matrices. + postgap: 1.0 /* 1em quad */ + }, { + type: "align", + align: "l", + pregap: 0, + postgap: 0 + }] + }; + var res = parseArray(context.parser, payload, dCellStyle(context.envName)); + return { + type: "leftright", + mode: context.mode, + body: [res], + left: context.envName.includes("r") ? "." : "\\{", + right: context.envName.includes("r") ? "\\}" : ".", + rightColor: undefined + }; + }, + htmlBuilder: htmlBuilder$6, + mathmlBuilder: mathmlBuilder$5 +}); +// In the align environment, one uses ampersands, &, to specify number of +// columns in each row, and to locate spacing between each column. +// align gets automatic numbering. align* and aligned do not. +// The alignedat environment can be used in math mode. +// Note that we assume \nomallineskiplimit to be zero, +// so that \strut@ is the same as \strut. +defineEnvironment({ + type: "array", + names: ["align", "align*", "aligned", "split"], + props: { + numArgs: 0 + }, + handler: alignedHandler, + htmlBuilder: htmlBuilder$6, + mathmlBuilder: mathmlBuilder$5 +}); +// A gathered environment is like an array environment with one centered +// column, but where rows are considered lines so get \jot line spacing +// and contents are set in \displaystyle. +defineEnvironment({ + type: "array", + names: ["gathered", "gather", "gather*"], + props: { + numArgs: 0 + }, + handler(context) { + if (gatherEnvironments.has(context.envName)) { + validateAmsEnvironmentContext(context); + } + var res = { + cols: [{ + type: "align", + align: "c" + }], + addJot: true, + colSeparationType: "gather", + autoTag: getAutoTag(context.envName), + emptySingleRow: true, + leqno: context.parser.settings.leqno + }; + return parseArray(context.parser, res, "display"); + }, + htmlBuilder: htmlBuilder$6, + mathmlBuilder: mathmlBuilder$5 +}); +// alignat environment is like an align environment, but one must explicitly +// specify maximum number of columns in each row, and can adjust spacing between +// each columns. +defineEnvironment({ + type: "array", + names: ["alignat", "alignat*", "alignedat"], + props: { + numArgs: 1 + }, + handler: alignedHandler, + htmlBuilder: htmlBuilder$6, + mathmlBuilder: mathmlBuilder$5 +}); +defineEnvironment({ + type: "array", + names: ["equation", "equation*"], + props: { + numArgs: 0 + }, + handler(context) { + validateAmsEnvironmentContext(context); + var res = { + autoTag: getAutoTag(context.envName), + emptySingleRow: true, + singleRow: true, + maxNumCols: 1, + leqno: context.parser.settings.leqno + }; + return parseArray(context.parser, res, "display"); + }, + htmlBuilder: htmlBuilder$6, + mathmlBuilder: mathmlBuilder$5 +}); +defineEnvironment({ + type: "array", + names: ["CD"], + props: { + numArgs: 0 + }, + handler(context) { + validateAmsEnvironmentContext(context); + return parseCD(context.parser); + }, + htmlBuilder: htmlBuilder$6, + mathmlBuilder: mathmlBuilder$5 +}); +defineMacro("\\nonumber", "\\gdef\\@eqnsw{0}"); +defineMacro("\\notag", "\\nonumber"); +// Catch \hline outside array environment +defineFunction({ + type: "text", + // Doesn't matter what this is. + names: ["\\hline", "\\hdashline"], + props: { + numArgs: 0, + allowedInText: true, + allowedInMath: true + }, + handler(context, args) { + throw new ParseError(context.funcName + " valid only within array environment"); + } +}); + +var environments = _environments; + +// Environment delimiters. HTML/MathML rendering is defined in the corresponding +// defineEnvironment definitions. +defineFunction({ + type: "environment", + names: ["\\begin", "\\end"], + props: { + numArgs: 1, + argTypes: ["text"] + }, + handler(_ref, args) { + var { + parser, + funcName + } = _ref; + var nameGroup = args[0]; + if (nameGroup.type !== "ordgroup") { + throw new ParseError("Invalid environment name", nameGroup); + } + var envName = ""; + for (var i = 0; i < nameGroup.body.length; ++i) { + envName += assertNodeType(nameGroup.body[i], "textord").text; + } + if (funcName === "\\begin") { + // begin...end is similar to left...right + if (!environments.hasOwnProperty(envName)) { + throw new ParseError("No such environment: " + envName, nameGroup); + } + // Build the environment object. Arguments and other information will + // be made available to the begin and end methods using properties. + var env = environments[envName]; + var { + args: _args, + optArgs + } = parser.parseArguments("\\begin{" + envName + "}", env); + var context = { + mode: parser.mode, + envName, + parser + }; + var result = env.handler(context, _args, optArgs); + parser.expect("\\end", false); + var endNameToken = parser.nextToken; + var end = assertNodeType(parser.parseFunction(), "environment"); + if (end.name !== envName) { + throw new ParseError("Mismatch: \\begin{" + envName + "} matched by \\end{" + end.name + "}", endNameToken); + } + // env.handler returns the specific node type (e.g. "array"), + // not "environment". This cast is unavoidable: defineFunction + // requires the handler to return ParseNode<"environment"> but + // \begin delegates to environment handlers with different types. + return result; + } + return { + type: "environment", + mode: parser.mode, + name: envName, + nameGroup + }; + } +}); + +// TODO(kevinb): implement \\sl and \\sc +var htmlBuilder$5 = (group, options) => { + var font = group.font; + var newOptions = options.withFont(font); + return buildGroup$1(group.body, newOptions); +}; +var mathmlBuilder$4 = (group, options) => { + var font = group.font; + var newOptions = options.withFont(font); + return buildGroup(group.body, newOptions); +}; +var fontAliases = { + "\\Bbb": "\\mathbb", + "\\bold": "\\mathbf", + "\\frak": "\\mathfrak" +}; +defineFunction({ + type: "font", + names: [ + // styles, except \boldsymbol defined below + "\\mathrm", "\\mathit", "\\mathbf", "\\mathnormal", "\\mathsfit", + // families + "\\mathbb", "\\mathcal", "\\mathfrak", "\\mathscr", "\\mathsf", "\\mathtt", + // aliases, except \bm defined below + "\\Bbb", "\\bold", "\\frak"], + props: { + numArgs: 1, + allowedInArgument: true + }, + handler: (_ref, args) => { + var { + parser, + funcName + } = _ref; + var body = normalizeArgument(args[0]); + var func = funcName; + if (func in fontAliases) { + func = fontAliases[func]; + } + return { + type: "font", + mode: parser.mode, + font: func.slice(1), + body + }; + }, + htmlBuilder: htmlBuilder$5, + mathmlBuilder: mathmlBuilder$4 +}); +defineFunction({ + type: "mclass", + names: ["\\boldsymbol", "\\bm"], + props: { + numArgs: 1 + }, + handler: (_ref2, args) => { + var { + parser + } = _ref2; + var body = args[0]; + // amsbsy.sty's \boldsymbol uses \binrel spacing to inherit the + // argument's bin|rel|ord status + return { + type: "mclass", + mode: parser.mode, + mclass: binrelClass(body), + body: [{ + type: "font", + mode: parser.mode, + font: "boldsymbol", + body + }], + isCharacterBox: isCharacterBox(body) + }; + } +}); +// Old font changing functions +defineFunction({ + type: "font", + names: ["\\rm", "\\sf", "\\tt", "\\bf", "\\it", "\\cal"], + props: { + numArgs: 0, + allowedInText: true + }, + handler: (_ref3, args) => { + var { + parser, + funcName, + breakOnTokenText + } = _ref3; + var { + mode + } = parser; + var body = parser.parseExpression(true, breakOnTokenText); + return { + type: "font", + mode: mode, + font: "math" + funcName.slice(1), + body: { + type: "ordgroup", + mode: parser.mode, + body + } + }; + }, + htmlBuilder: htmlBuilder$5, + mathmlBuilder: mathmlBuilder$4 +}); + +var htmlBuilder$4 = (group, options) => { + // Fractions are handled in the TeXbook on pages 444-445, rules 15(a-e). + var style = options.style; + var nstyle = style.fracNum(); + var dstyle = style.fracDen(); + var newOptions; + newOptions = options.havingStyle(nstyle); + var numerm = buildGroup$1(group.numer, newOptions, options); + if (group.continued) { + // \cfrac inserts a \strut into the numerator. + // Get \strut dimensions from TeXbook page 353. + var hStrut = 8.5 / options.fontMetrics().ptPerEm; + var dStrut = 3.5 / options.fontMetrics().ptPerEm; + numerm.height = numerm.height < hStrut ? hStrut : numerm.height; + numerm.depth = numerm.depth < dStrut ? dStrut : numerm.depth; + } + newOptions = options.havingStyle(dstyle); + var denomm = buildGroup$1(group.denom, newOptions, options); + var rule; + var ruleWidth; + var ruleSpacing; + if (group.hasBarLine) { + if (group.barSize) { + ruleWidth = calculateSize(group.barSize, options); + rule = makeLineSpan("frac-line", options, ruleWidth); + } else { + rule = makeLineSpan("frac-line", options); + } + ruleWidth = rule.height; + ruleSpacing = rule.height; + } else { + rule = null; + ruleWidth = 0; + ruleSpacing = options.fontMetrics().defaultRuleThickness; + } + // Rule 15b + var numShift; + var clearance; + var denomShift; + if (style.size === Style$1.DISPLAY.size) { + numShift = options.fontMetrics().num1; + if (ruleWidth > 0) { + clearance = 3 * ruleSpacing; + } else { + clearance = 7 * ruleSpacing; + } + denomShift = options.fontMetrics().denom1; + } else { + if (ruleWidth > 0) { + numShift = options.fontMetrics().num2; + clearance = ruleSpacing; + } else { + numShift = options.fontMetrics().num3; + clearance = 3 * ruleSpacing; + } + denomShift = options.fontMetrics().denom2; + } + var frac; + if (!rule) { + // Rule 15c + var candidateClearance = numShift - numerm.depth - (denomm.height - denomShift); + if (candidateClearance < clearance) { + numShift += 0.5 * (clearance - candidateClearance); + denomShift += 0.5 * (clearance - candidateClearance); + } + frac = makeVList({ + positionType: "individualShift", + children: [{ + type: "elem", + elem: denomm, + shift: denomShift + }, { + type: "elem", + elem: numerm, + shift: -numShift + }] + }); + } else { + // Rule 15d + var axisHeight = options.fontMetrics().axisHeight; + if (numShift - numerm.depth - (axisHeight + 0.5 * ruleWidth) < clearance) { + numShift += clearance - (numShift - numerm.depth - (axisHeight + 0.5 * ruleWidth)); + } + if (axisHeight - 0.5 * ruleWidth - (denomm.height - denomShift) < clearance) { + denomShift += clearance - (axisHeight - 0.5 * ruleWidth - (denomm.height - denomShift)); + } + var midShift = -(axisHeight - 0.5 * ruleWidth); + frac = makeVList({ + positionType: "individualShift", + children: [{ + type: "elem", + elem: denomm, + shift: denomShift + }, { + type: "elem", + elem: rule, + shift: midShift + }, { + type: "elem", + elem: numerm, + shift: -numShift + }] + }); + } + // Since we manually change the style sometimes (with \dfrac or \tfrac), + // account for the possible size change here. + newOptions = options.havingStyle(style); + frac.height *= newOptions.sizeMultiplier / options.sizeMultiplier; + frac.depth *= newOptions.sizeMultiplier / options.sizeMultiplier; + // Rule 15e + var delimSize; + if (style.size === Style$1.DISPLAY.size) { + delimSize = options.fontMetrics().delim1; + } else if (style.size === Style$1.SCRIPTSCRIPT.size) { + delimSize = options.havingStyle(Style$1.SCRIPT).fontMetrics().delim2; + } else { + delimSize = options.fontMetrics().delim2; + } + var leftDelim; + var rightDelim; + if (group.leftDelim == null) { + leftDelim = makeNullDelimiter(options, ["mopen"]); + } else { + leftDelim = makeCustomSizedDelim(group.leftDelim, delimSize, true, options.havingStyle(style), group.mode, ["mopen"]); + } + if (group.continued) { + rightDelim = makeSpan([]); // zero width for \cfrac + } else if (group.rightDelim == null) { + rightDelim = makeNullDelimiter(options, ["mclose"]); + } else { + rightDelim = makeCustomSizedDelim(group.rightDelim, delimSize, true, options.havingStyle(style), group.mode, ["mclose"]); + } + return makeSpan(["mord"].concat(newOptions.sizingClasses(options)), [leftDelim, makeSpan(["mfrac"], [frac]), rightDelim], options); +}; +var mathmlBuilder$3 = (group, options) => { + var node = new MathNode("mfrac", [buildGroup(group.numer, options), buildGroup(group.denom, options)]); + if (!group.hasBarLine) { + node.setAttribute("linethickness", "0px"); + } else if (group.barSize) { + var ruleWidth = calculateSize(group.barSize, options); + node.setAttribute("linethickness", makeEm(ruleWidth)); + } + if (group.leftDelim != null || group.rightDelim != null) { + var withDelims = []; + if (group.leftDelim != null) { + var leftOp = new MathNode("mo", [new TextNode(group.leftDelim.replace("\\", ""))]); + leftOp.setAttribute("fence", "true"); + withDelims.push(leftOp); + } + withDelims.push(node); + if (group.rightDelim != null) { + var rightOp = new MathNode("mo", [new TextNode(group.rightDelim.replace("\\", ""))]); + rightOp.setAttribute("fence", "true"); + withDelims.push(rightOp); + } + return makeRow(withDelims); + } + return node; +}; +var wrapWithStyle = (frac, style) => { + if (!style) { + return frac; + } + var wrapper = { + type: "styling", + mode: frac.mode, + style, + body: [frac] + }; + // @ts-ignore defineFunction handler needs to return ParseNode<"genfrac"> + return wrapper; +}; +defineFunction({ + type: "genfrac", + names: ["\\cfrac", "\\dfrac", "\\frac", "\\tfrac", "\\dbinom", "\\binom", "\\tbinom", "\\\\atopfrac", + // can’t be entered directly + "\\\\bracefrac", "\\\\brackfrac" // ditto + ], + props: { + numArgs: 2, + allowedInArgument: true + }, + handler: (_ref, args) => { + var { + parser, + funcName + } = _ref; + var numer = args[0]; + var denom = args[1]; + var hasBarLine; + var leftDelim = null; + var rightDelim = null; + switch (funcName) { + case "\\cfrac": + case "\\dfrac": + case "\\frac": + case "\\tfrac": + hasBarLine = true; + break; + case "\\\\atopfrac": + hasBarLine = false; + break; + case "\\dbinom": + case "\\binom": + case "\\tbinom": + hasBarLine = false; + leftDelim = "("; + rightDelim = ")"; + break; + case "\\\\bracefrac": + hasBarLine = false; + leftDelim = "\\{"; + rightDelim = "\\}"; + break; + case "\\\\brackfrac": + hasBarLine = false; + leftDelim = "["; + rightDelim = "]"; + break; + default: + throw new Error("Unrecognized genfrac command"); + } + var continued = funcName === "\\cfrac"; + var style = null; + if (continued || funcName.startsWith("\\d")) { + style = "display"; + } else if (funcName.startsWith("\\t")) { + style = "text"; + } + return wrapWithStyle({ + type: "genfrac", + mode: parser.mode, + numer, + denom, + continued, + hasBarLine, + leftDelim, + rightDelim, + barSize: null + }, style); + }, + htmlBuilder: htmlBuilder$4, + mathmlBuilder: mathmlBuilder$3 +}); +// Infix generalized fractions -- these are not rendered directly, but replaced +// immediately by one of the variants above. +defineFunction({ + type: "infix", + names: ["\\over", "\\choose", "\\atop", "\\brace", "\\brack"], + props: { + numArgs: 0, + infix: true + }, + handler(_ref2) { + var { + parser, + funcName, + token + } = _ref2; + var replaceWith; + switch (funcName) { + case "\\over": + replaceWith = "\\frac"; + break; + case "\\choose": + replaceWith = "\\binom"; + break; + case "\\atop": + replaceWith = "\\\\atopfrac"; + break; + case "\\brace": + replaceWith = "\\\\bracefrac"; + break; + case "\\brack": + replaceWith = "\\\\brackfrac"; + break; + default: + throw new Error("Unrecognized infix genfrac command"); + } + return { + type: "infix", + mode: parser.mode, + replaceWith, + token + }; + } +}); +var stylArray = ["display", "text", "script", "scriptscript"]; +var delimFromValue = function delimFromValue(delimString) { + var delim = null; + if (delimString.length > 0) { + delim = delimString; + delim = delim === "." ? null : delim; + } + return delim; +}; +defineFunction({ + type: "genfrac", + names: ["\\genfrac"], + props: { + numArgs: 6, + allowedInArgument: true, + argTypes: ["math", "math", "size", "text", "math", "math"] + }, + handler(_ref3, args) { + var { + parser + } = _ref3; + var numer = args[4]; + var denom = args[5]; + // Look into the parse nodes to get the desired delimiters. + var leftNode = normalizeArgument(args[0]); + var leftDelim = leftNode.type === "atom" && leftNode.family === "open" ? delimFromValue(leftNode.text) : null; + var rightNode = normalizeArgument(args[1]); + var rightDelim = rightNode.type === "atom" && rightNode.family === "close" ? delimFromValue(rightNode.text) : null; + var barNode = assertNodeType(args[2], "size"); + var hasBarLine; + var barSize = null; + if (barNode.isBlank) { + // \genfrac acts differently than \above. + // \genfrac treats an empty size group as a signal to use a + // standard bar size. \above would see size = 0 and omit the bar. + hasBarLine = true; + } else { + barSize = barNode.value; + hasBarLine = barSize.number > 0; + } + // Find out if we want displaystyle, textstyle, etc. + var size = null; + var styl = args[3]; + if (styl.type === "ordgroup") { + if (styl.body.length > 0) { + var textOrd = assertNodeType(styl.body[0], "textord"); + size = stylArray[Number(textOrd.text)]; + } + } else { + styl = assertNodeType(styl, "textord"); + size = stylArray[Number(styl.text)]; + } + return wrapWithStyle({ + type: "genfrac", + mode: parser.mode, + numer, + denom, + continued: false, + hasBarLine, + barSize, + leftDelim, + rightDelim + }, size); + } +}); +// \above is an infix fraction that also defines a fraction bar size. +defineFunction({ + type: "infix", + names: ["\\above"], + props: { + numArgs: 1, + argTypes: ["size"], + infix: true + }, + handler(_ref4, args) { + var { + parser, + funcName, + token + } = _ref4; + return { + type: "infix", + mode: parser.mode, + replaceWith: "\\\\abovefrac", + size: assertNodeType(args[0], "size").value, + token + }; + } +}); +defineFunction({ + type: "genfrac", + names: ["\\\\abovefrac"], + props: { + numArgs: 3, + argTypes: ["math", "size", "math"] + }, + handler: (_ref5, args) => { + var { + parser, + funcName + } = _ref5; + var numer = args[0]; + var barSize = assertNodeType(args[1], "infix").size; + if (!barSize) { + throw new Error("\\\\abovefrac expected size, but got " + String(barSize)); + } + var denom = args[2]; + var hasBarLine = barSize.number > 0; + return { + type: "genfrac", + mode: parser.mode, + numer, + denom, + continued: false, + hasBarLine, + barSize, + leftDelim: null, + rightDelim: null + }; + } +}); + +// NOTE: Unlike most `htmlBuilder`s, this one handles not only "horizBrace", but +// also "supsub" since an over/underbrace can affect super/subscripting. +var htmlBuilder$3 = (grp, options) => { + var style = options.style; + // Pull out the `ParseNode<"horizBrace">` if `grp` is a "supsub" node. + var supSubGroup; + var group; + if (grp.type === "supsub") { + // Ref: LaTeX source2e: }}}}\limits} + // i.e. LaTeX treats the brace similar to an op and passes it + // with \limits, so we need to assign supsub style. + supSubGroup = grp.sup ? buildGroup$1(grp.sup, options.havingStyle(style.sup()), options) : buildGroup$1(grp.sub, options.havingStyle(style.sub()), options); + group = assertNodeType(grp.base, "horizBrace"); + } else { + group = assertNodeType(grp, "horizBrace"); + } + // Build the base group + var body = buildGroup$1(group.base, options.havingBaseStyle(Style$1.DISPLAY)); + // Create the stretchy element + var braceBody = stretchySvg(group, options); + // Generate the vlist, with the appropriate kerns ┏━━━━━━━━┓ + // This first vlist contains the content and the brace: equation + var vlist; + if (group.isOver) { + vlist = makeVList({ + positionType: "firstBaseline", + children: [{ + type: "elem", + elem: body + }, { + type: "kern", + size: 0.1 + }, { + type: "elem", + elem: braceBody, + wrapperClasses: ["svg-align"] + }] + }); + } else { + vlist = makeVList({ + positionType: "bottom", + positionData: body.depth + 0.1 + braceBody.height, + children: [{ + type: "elem", + elem: braceBody, + wrapperClasses: ["svg-align"] + }, { + type: "kern", + size: 0.1 + }, { + type: "elem", + elem: body + }] + }); + } + if (supSubGroup) { + // To write the supsub, wrap the first vlist in another vlist: + // They can't all go in the same vlist, because the note might be + // wider than the equation. We want the equation to control the + // brace width. + // note long note long note + // ┏━━━━━━━━┓ or ┏━━━┓ not ┏━━━━━━━━━┓ + // equation eqn eqn + var vSpan = makeSpan(["minner", group.isOver ? "mover" : "munder"], [vlist], options); + if (group.isOver) { + vlist = makeVList({ + positionType: "firstBaseline", + children: [{ + type: "elem", + elem: vSpan + }, { + type: "kern", + size: 0.2 + }, { + type: "elem", + elem: supSubGroup + }] + }); + } else { + vlist = makeVList({ + positionType: "bottom", + positionData: vSpan.depth + 0.2 + supSubGroup.height + supSubGroup.depth, + children: [{ + type: "elem", + elem: supSubGroup + }, { + type: "kern", + size: 0.2 + }, { + type: "elem", + elem: vSpan + }] + }); + } + } + return makeSpan(["minner", group.isOver ? "mover" : "munder"], [vlist], options); +}; +var mathmlBuilder$2 = (group, options) => { + var accentNode = stretchyMathML(group.label); + return new MathNode(group.isOver ? "mover" : "munder", [buildGroup(group.base, options), accentNode]); +}; +// Horizontal stretchy braces +defineFunction({ + type: "horizBrace", + names: ["\\overbrace", "\\underbrace", "\\overbracket", "\\underbracket"], + props: { + numArgs: 1 + }, + handler(_ref, args) { + var { + parser, + funcName + } = _ref; + return { + type: "horizBrace", + mode: parser.mode, + label: funcName, + isOver: funcName.includes("\\over"), + base: args[0] + }; + }, + htmlBuilder: htmlBuilder$3, + mathmlBuilder: mathmlBuilder$2 +}); + +defineFunction({ + type: "href", + names: ["\\href"], + props: { + numArgs: 2, + argTypes: ["url", "original"], + allowedInText: true + }, + handler: (_ref, args) => { + var { + parser + } = _ref; + var body = args[1]; + var href = assertNodeType(args[0], "url").url; + if (!parser.settings.isTrusted({ + command: "\\href", + url: href + })) { + return parser.formatUnsupportedCmd("\\href"); + } + return { + type: "href", + mode: parser.mode, + href, + body: ordargument(body) + }; + }, + htmlBuilder: (group, options) => { + var elements = buildExpression$1(group.body, options, false); + return makeAnchor(group.href, [], elements, options); + }, + mathmlBuilder: (group, options) => { + var math = buildExpressionRow(group.body, options); + if (!(math instanceof MathNode)) { + math = new MathNode("mrow", [math]); + } + math.setAttribute("href", group.href); + return math; + } +}); +defineFunction({ + type: "href", + names: ["\\url"], + props: { + numArgs: 1, + argTypes: ["url"], + allowedInText: true + }, + handler: (_ref2, args) => { + var { + parser + } = _ref2; + var href = assertNodeType(args[0], "url").url; + if (!parser.settings.isTrusted({ + command: "\\url", + url: href + })) { + return parser.formatUnsupportedCmd("\\url"); + } + var chars = []; + for (var i = 0; i < href.length; i++) { + var c = href[i]; + if (c === "~") { + c = "\\textasciitilde"; + } + chars.push({ + type: "textord", + mode: "text", + text: c + }); + } + var body = { + type: "text", + mode: parser.mode, + font: "\\texttt", + body: chars + }; + return { + type: "href", + mode: parser.mode, + href, + body: ordargument(body) + }; + } +}); + +// \hbox is provided for compatibility with LaTeX \vcenter. +// In LaTeX, \vcenter can act only on a box, as in +// \vcenter{\hbox{$\frac{a+b}{\dfrac{c}{d}}$}} +// This function by itself doesn't do anything but prevent a soft line break. +defineFunction({ + type: "hbox", + names: ["\\hbox"], + props: { + numArgs: 1, + argTypes: ["text"], + allowedInText: true, + primitive: true + }, + handler(_ref, args) { + var { + parser + } = _ref; + return { + type: "hbox", + mode: parser.mode, + body: ordargument(args[0]) + }; + }, + htmlBuilder(group, options) { + var elements = buildExpression$1(group.body, options.withFont(''), false); + return makeFragment(elements); + }, + mathmlBuilder(group, options) { + return new MathNode("mrow", buildExpression(group.body, options.withFont(''))); + } +}); + +defineFunction({ + type: "html", + names: ["\\htmlClass", "\\htmlId", "\\htmlStyle", "\\htmlData"], + props: { + numArgs: 2, + argTypes: ["raw", "original"], + allowedInText: true + }, + handler: (_ref, args) => { + var { + parser, + funcName, + token + } = _ref; + var value = assertNodeType(args[0], "raw").string; + var body = args[1]; + if (parser.settings.strict) { + parser.settings.reportNonstrict("htmlExtension", "HTML extension is disabled on strict mode"); + } + var trustContext; + var attributes = {}; + switch (funcName) { + case "\\htmlClass": + attributes.class = value; + trustContext = { + command: "\\htmlClass", + class: value + }; + break; + case "\\htmlId": + attributes.id = value; + trustContext = { + command: "\\htmlId", + id: value + }; + break; + case "\\htmlStyle": + attributes.style = value; + trustContext = { + command: "\\htmlStyle", + style: value + }; + break; + case "\\htmlData": + { + var data = value.split(","); + for (var i = 0; i < data.length; i++) { + var item = data[i]; + var firstEquals = item.indexOf("="); + if (firstEquals < 0) { + throw new ParseError("\\htmlData key/value '" + item + "'" + " missing equals sign"); + } + var key = item.slice(0, firstEquals); + var _value = item.slice(firstEquals + 1); + attributes["data-" + key.trim()] = _value; + } + trustContext = { + command: "\\htmlData", + attributes + }; + break; + } + default: + throw new Error("Unrecognized html command"); + } + if (!parser.settings.isTrusted(trustContext)) { + return parser.formatUnsupportedCmd(funcName); + } + return { + type: "html", + mode: parser.mode, + attributes, + body: ordargument(body) + }; + }, + htmlBuilder: (group, options) => { + var elements = buildExpression$1(group.body, options, false); + var classes = ["enclosing"]; + if (group.attributes.class) { + classes.push(...group.attributes.class.trim().split(/\s+/)); + } + var span = makeSpan(classes, elements, options); + for (var attr in group.attributes) { + if (attr !== "class" && group.attributes.hasOwnProperty(attr)) { + span.setAttribute(attr, group.attributes[attr]); + } + } + return span; + }, + mathmlBuilder: (group, options) => { + return buildExpressionRow(group.body, options); + } +}); + +defineFunction({ + type: "htmlmathml", + names: ["\\html@mathml"], + props: { + numArgs: 2, + allowedInArgument: true, + allowedInText: true + }, + handler: (_ref, args) => { + var { + parser + } = _ref; + return { + type: "htmlmathml", + mode: parser.mode, + html: ordargument(args[0]), + mathml: ordargument(args[1]) + }; + }, + htmlBuilder: (group, options) => { + var elements = buildExpression$1(group.html, options, false); + return makeFragment(elements); + }, + mathmlBuilder: (group, options) => { + return buildExpressionRow(group.mathml, options); + } +}); + +var sizeData = function sizeData(str) { + if (/^[-+]? *(\d+(\.\d*)?|\.\d+)$/.test(str)) { + // str is a number with no unit specified. + // default unit is bp, per graphix package. + return { + number: +str, + unit: "bp" + }; + } else { + var match = /([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(str); + if (!match) { + throw new ParseError("Invalid size: '" + str + "' in \\includegraphics"); + } + var data = { + number: +(match[1] + match[2]), + // sign + magnitude, cast to number + unit: match[3] + }; + if (!validUnit(data)) { + throw new ParseError("Invalid unit: '" + data.unit + "' in \\includegraphics."); + } + return data; + } +}; +defineFunction({ + type: "includegraphics", + names: ["\\includegraphics"], + props: { + numArgs: 1, + numOptionalArgs: 1, + argTypes: ["raw", "url"], + allowedInText: false + }, + handler: (_ref, args, optArgs) => { + var { + parser + } = _ref; + var width = { + number: 0, + unit: "em" + }; + var height = { + number: 0.9, + unit: "em" + }; // sorta character sized. + var totalheight = { + number: 0, + unit: "em" + }; + var alt = ""; + if (optArgs[0]) { + var attributeStr = assertNodeType(optArgs[0], "raw").string; + // Parser.js does not parse key/value pairs. We get a string. + var attributes = attributeStr.split(","); + for (var i = 0; i < attributes.length; i++) { + var keyVal = attributes[i].split("="); + if (keyVal.length === 2) { + var str = keyVal[1].trim(); + switch (keyVal[0].trim()) { + case "alt": + alt = str; + break; + case "width": + width = sizeData(str); + break; + case "height": + height = sizeData(str); + break; + case "totalheight": + totalheight = sizeData(str); + break; + default: + throw new ParseError("Invalid key: '" + keyVal[0] + "' in \\includegraphics."); + } + } + } + } + var src = assertNodeType(args[0], "url").url; + if (alt === "") { + // No alt given. Use the file name. Strip away the path. + alt = src; + alt = alt.replace(/^.*[\\/]/, ''); + alt = alt.substring(0, alt.lastIndexOf('.')); + } + if (!parser.settings.isTrusted({ + command: "\\includegraphics", + url: src + })) { + return parser.formatUnsupportedCmd("\\includegraphics"); + } + return { + type: "includegraphics", + mode: parser.mode, + alt: alt, + width: width, + height: height, + totalheight: totalheight, + src: src + }; + }, + htmlBuilder: (group, options) => { + var height = calculateSize(group.height, options); + var depth = 0; + if (group.totalheight.number > 0) { + depth = calculateSize(group.totalheight, options) - height; + } + var width = 0; + if (group.width.number > 0) { + width = calculateSize(group.width, options); + } + var style = { + height: makeEm(height + depth) + }; + if (width > 0) { + style.width = makeEm(width); + } + if (depth > 0) { + style.verticalAlign = makeEm(-depth); + } + var node = new Img(group.src, group.alt, style); + node.height = height; + node.depth = depth; + return node; + }, + mathmlBuilder: (group, options) => { + var node = new MathNode("mglyph", []); + node.setAttribute("alt", group.alt); + var height = calculateSize(group.height, options); + var depth = 0; + if (group.totalheight.number > 0) { + depth = calculateSize(group.totalheight, options) - height; + node.setAttribute("valign", makeEm(-depth)); + } + node.setAttribute("height", makeEm(height + depth)); + if (group.width.number > 0) { + var width = calculateSize(group.width, options); + node.setAttribute("width", makeEm(width)); + } + node.setAttribute("src", group.src); + return node; + } +}); + +// Horizontal spacing commands +// TODO: \hskip and \mskip should support plus and minus in lengths +defineFunction({ + type: "kern", + names: ["\\kern", "\\mkern", "\\hskip", "\\mskip"], + props: { + numArgs: 1, + argTypes: ["size"], + primitive: true, + allowedInText: true + }, + handler(_ref, args) { + var { + parser, + funcName + } = _ref; + var size = assertNodeType(args[0], "size"); + if (parser.settings.strict) { + var mathFunction = funcName[1] === 'm'; // \mkern, \mskip + var muUnit = size.value.unit === 'mu'; + if (mathFunction) { + if (!muUnit) { + parser.settings.reportNonstrict("mathVsTextUnits", "LaTeX's " + funcName + " supports only mu units, " + ("not " + size.value.unit + " units")); + } + if (parser.mode !== "math") { + parser.settings.reportNonstrict("mathVsTextUnits", "LaTeX's " + funcName + " works only in math mode"); + } + } else { + // !mathFunction + if (muUnit) { + parser.settings.reportNonstrict("mathVsTextUnits", "LaTeX's " + funcName + " doesn't support mu units"); + } + } + } + return { + type: "kern", + mode: parser.mode, + dimension: size.value + }; + }, + htmlBuilder(group, options) { + return makeGlue(group.dimension, options); + }, + mathmlBuilder(group, options) { + var dimension = calculateSize(group.dimension, options); + return new SpaceNode(dimension); + } +}); + +// Horizontal overlap functions +defineFunction({ + type: "lap", + names: ["\\mathllap", "\\mathrlap", "\\mathclap"], + props: { + numArgs: 1, + allowedInText: true + }, + handler: (_ref, args) => { + var { + parser, + funcName + } = _ref; + var body = args[0]; + return { + type: "lap", + mode: parser.mode, + alignment: funcName.slice(5), + body + }; + }, + htmlBuilder: (group, options) => { + // mathllap, mathrlap, mathclap + var inner; + if (group.alignment === "clap") { + // ref: https://www.math.lsu.edu/~aperlis/publications/mathclap/ + inner = makeSpan([], [buildGroup$1(group.body, options)]); + // wrap, since CSS will center a .clap > .inner > span + inner = makeSpan(["inner"], [inner], options); + } else { + inner = makeSpan(["inner"], [buildGroup$1(group.body, options)]); + } + var fix = makeSpan(["fix"], []); + var node = makeSpan([group.alignment], [inner, fix], options); + // At this point, we have correctly set horizontal alignment of the + // two items involved in the lap. + // Next, use a strut to set the height of the HTML bounding box. + // Otherwise, a tall argument may be misplaced. + // This code resolved issue #1153 + var strut = makeSpan(["strut"]); + strut.style.height = makeEm(node.height + node.depth); + if (node.depth) { + strut.style.verticalAlign = makeEm(-node.depth); + } + node.children.unshift(strut); + // Next, prevent vertical misplacement when next to something tall. + // This code resolves issue #1234 + node = makeSpan(["thinbox"], [node], options); + return makeSpan(["mord", "vbox"], [node], options); + }, + mathmlBuilder: (group, options) => { + // mathllap, mathrlap, mathclap + var node = new MathNode("mpadded", [buildGroup(group.body, options)]); + if (group.alignment !== "rlap") { + var offset = group.alignment === "llap" ? "-1" : "-0.5"; + node.setAttribute("lspace", offset + "width"); + } + node.setAttribute("width", "0px"); + return node; + } +}); + +// Switching from text mode back to math mode +defineFunction({ + type: "styling", + names: ["\\(", "$"], + props: { + numArgs: 0, + allowedInText: true, + allowedInMath: false + }, + handler(_ref, args) { + var { + funcName, + parser + } = _ref; + var outerMode = parser.mode; + parser.switchMode("math"); + var close = funcName === "\\(" ? "\\)" : "$"; + var body = parser.parseExpression(false, close); + parser.expect(close); + parser.switchMode(outerMode); + return { + type: "styling", + mode: parser.mode, + style: "text", + resetFont: true, + body + }; + } +}); +// Check for extra closing math delimiters +defineFunction({ + type: "text", + // Doesn't matter what this is. + names: ["\\)", "\\]"], + props: { + numArgs: 0, + allowedInText: true, + allowedInMath: false + }, + handler(context, args) { + throw new ParseError("Mismatched " + context.funcName); + } +}); + +var chooseMathStyle = (group, options) => { + switch (options.style.size) { + case Style$1.DISPLAY.size: + return group.display; + case Style$1.TEXT.size: + return group.text; + case Style$1.SCRIPT.size: + return group.script; + case Style$1.SCRIPTSCRIPT.size: + return group.scriptscript; + default: + return group.text; + } +}; +defineFunction({ + type: "mathchoice", + names: ["\\mathchoice"], + props: { + numArgs: 4, + primitive: true + }, + handler: (_ref, args) => { + var { + parser + } = _ref; + return { + type: "mathchoice", + mode: parser.mode, + display: ordargument(args[0]), + text: ordargument(args[1]), + script: ordargument(args[2]), + scriptscript: ordargument(args[3]) + }; + }, + htmlBuilder: (group, options) => { + var body = chooseMathStyle(group, options); + var elements = buildExpression$1(body, options, false); + return makeFragment(elements); + }, + mathmlBuilder: (group, options) => { + var body = chooseMathStyle(group, options); + return buildExpressionRow(body, options); + } +}); + +// For an operator with limits, assemble the base, sup, and sub into a span. +var assembleSupSub = (base, supGroup, subGroup, options, style, slant, baseShift) => { + base = makeSpan([], [base]); + var subIsSingleCharacter = subGroup && isCharacterBox(subGroup); + var sub; + var sup; + // We manually have to handle the superscripts and subscripts. This, + // aside from the kern calculations, is copied from supsub. + if (supGroup) { + var elem = buildGroup$1(supGroup, options.havingStyle(style.sup()), options); + sup = { + elem, + kern: Math.max(options.fontMetrics().bigOpSpacing1, options.fontMetrics().bigOpSpacing3 - elem.depth) + }; + } + if (subGroup) { + var _elem = buildGroup$1(subGroup, options.havingStyle(style.sub()), options); + sub = { + elem: _elem, + kern: Math.max(options.fontMetrics().bigOpSpacing2, options.fontMetrics().bigOpSpacing4 - _elem.height) + }; + } + // Build the final group as a vlist of the possible subscript, base, + // and possible superscript. + var finalGroup; + if (sup && sub) { + var bottom = options.fontMetrics().bigOpSpacing5 + sub.elem.height + sub.elem.depth + sub.kern + base.depth + baseShift; + finalGroup = makeVList({ + positionType: "bottom", + positionData: bottom, + children: [{ + type: "kern", + size: options.fontMetrics().bigOpSpacing5 + }, { + type: "elem", + elem: sub.elem, + marginLeft: makeEm(-slant) + }, { + type: "kern", + size: sub.kern + }, { + type: "elem", + elem: base + }, { + type: "kern", + size: sup.kern + }, { + type: "elem", + elem: sup.elem, + marginLeft: makeEm(slant) + }, { + type: "kern", + size: options.fontMetrics().bigOpSpacing5 + }] + }); + } else if (sub) { + var top = base.height - baseShift; + // Shift the limits by the slant of the symbol. Note + // that we are supposed to shift the limits by 1/2 of the slant, + // but since we are centering the limits adding a full slant of + // margin will shift by 1/2 that. + finalGroup = makeVList({ + positionType: "top", + positionData: top, + children: [{ + type: "kern", + size: options.fontMetrics().bigOpSpacing5 + }, { + type: "elem", + elem: sub.elem, + marginLeft: makeEm(-slant) + }, { + type: "kern", + size: sub.kern + }, { + type: "elem", + elem: base + }] + }); + } else if (sup) { + var _bottom = base.depth + baseShift; + finalGroup = makeVList({ + positionType: "bottom", + positionData: _bottom, + children: [{ + type: "elem", + elem: base + }, { + type: "kern", + size: sup.kern + }, { + type: "elem", + elem: sup.elem, + marginLeft: makeEm(slant) + }, { + type: "kern", + size: options.fontMetrics().bigOpSpacing5 + }] + }); + } else { + // This case probably shouldn't occur (this would mean the + // supsub was sending us a group with no superscript or + // subscript) but be safe. + return base; + } + var parts = [finalGroup]; + if (sub && slant !== 0 && !subIsSingleCharacter) { + // A negative margin-left was applied to the lower limit. + // Avoid an overlap by placing a spacer on the left on the group. + var spacer = makeSpan(["mspace"], [], options); + spacer.style.marginRight = makeEm(slant); + parts.unshift(spacer); + } + return makeSpan(["mop", "op-limits"], parts, options); +}; + +// Limits, symbols +// Most operators have a large successor symbol, but these don't. +var noSuccessor = new Set(["\\smallint"]); +// NOTE: Unlike most `htmlBuilder`s, this one handles not only "op", but also +// "supsub" since some of them (like \int) can affect super/subscripting. +var htmlBuilder$2 = (grp, options) => { + // Operators are handled in the TeXbook pg. 443-444, rule 13(a). + var supGroup; + var subGroup; + var hasLimits = false; + var group; + if (grp.type === "supsub") { + // If we have limits, supsub will pass us its group to handle. Pull + // out the superscript and subscript and set the group to the op in + // its base. + supGroup = grp.sup; + subGroup = grp.sub; + group = assertNodeType(grp.base, "op"); + hasLimits = true; + } else { + group = assertNodeType(grp, "op"); + } + var style = options.style; + var large = false; + if (style.size === Style$1.DISPLAY.size && group.symbol && !noSuccessor.has(group.name)) { + // Most symbol operators get larger in displaystyle (rule 13) + large = true; + } + var base; + // Italic correction from the symbol glyph, captured before the symbol + // may be wrapped in a vlist (for \oiint/\oiiint). Stays 0 for non-symbol ops. + var symbolItalic; + if (group.symbol) { + // If this is a symbol, create the symbol. + var fontName = large ? "Size2-Regular" : "Size1-Regular"; + var stash = ""; + if (group.name === "\\oiint" || group.name === "\\oiiint") { + // No font glyphs yet, so use a glyph w/o the oval. + // TODO: When font glyphs are available, delete this code. + stash = group.name.slice(1); + group.name = stash === "oiint" ? "\\iint" : "\\iiint"; + } + base = makeSymbol(group.name, fontName, "math", options, ["mop", "op-symbol", large ? "large-op" : "small-op"]); + symbolItalic = base.italic; + if (stash.length > 0) { + // We're in \oiint or \oiiint. Overlay the oval. + // TODO: When font glyphs are available, delete this code. + var oval = staticSvg(stash + "Size" + (large ? "2" : "1"), options); + base = makeVList({ + positionType: "individualShift", + children: [{ + type: "elem", + elem: base, + shift: 0 + }, { + type: "elem", + elem: oval, + shift: large ? 0.08 : 0 + }] + }); + group.name = "\\" + stash; + base.classes.unshift("mop"); + // Carry the italic correction from the original symbol to the + // vlist wrapper so supsub can use it for subscript positioning. + base.italic = symbolItalic; + } + } else if (group.body) { + // If this is a list, compose that list. + var inner = buildExpression$1(group.body, options, true); + if (inner.length === 1 && inner[0] instanceof SymbolNode) { + base = inner[0]; + base.classes[0] = "mop"; // replace old mclass + } else { + base = makeSpan(["mop"], inner, options); + } + } else { + // Otherwise, this is a text operator. Build the text from the + // operator's name. + var output = []; + for (var i = 1; i < group.name.length; i++) { + output.push(mathsym(group.name[i], group.mode, options)); + } + base = makeSpan(["mop"], output, options); + } + // If content of op is a single symbol, shift it vertically. + var baseShift = 0; + var slant = 0; + if ((base instanceof SymbolNode || group.name === "\\oiint" || group.name === "\\oiiint") && !group.suppressBaseShift) { + var _base$italic; + // We suppress the shift of the base of \overset and \underset. Otherwise, + // shift the symbol so its center lies on the axis (rule 13). It + // appears that our fonts have the centers of the symbols already + // almost on the axis, so these numbers are very small. Note we + // don't actually apply this here, but instead it is used either in + // the vlist creation or separately when there are no limits. + baseShift = (base.height - base.depth) / 2 - options.fontMetrics().axisHeight; + // The slant of the symbol is just its italic correction. + // SymbolNode carries .italic natively; Span (for \oiint/\oiiint) + // only has it set when nonzero, so default to 0. + slant = (_base$italic = base.italic) != null ? _base$italic : 0; + } + if (hasLimits) { + return assembleSupSub(base, supGroup, subGroup, options, style, slant, baseShift); + } else { + if (baseShift) { + base.style.position = "relative"; + base.style.top = makeEm(baseShift); + } + return base; + } +}; +var mathmlBuilder$1 = (group, options) => { + var node; + if (group.symbol) { + // This is a symbol. Just add the symbol. + node = new MathNode("mo", [makeText(group.name, group.mode)]); + if (noSuccessor.has(group.name)) { + node.setAttribute("largeop", "false"); + } + } else if (group.body) { + // This is an operator with children. Add them. + node = new MathNode("mo", buildExpression(group.body, options)); + } else { + // This is a text operator. Add all the characters from the + // operator's name. + node = new MathNode("mi", [new TextNode(group.name.slice(1))]); + // Append an . + // ref: https://www.w3.org/TR/REC-MathML/chap3_2.html#sec3.2.4 + var operator = new MathNode("mo", [makeText("\u2061", "text")]); + if (group.parentIsSupSub) { + node = new MathNode("mrow", [node, operator]); + } else { + node = newDocumentFragment([node, operator]); + } + } + return node; +}; +var singleCharBigOps = { + "\u220F": "\\prod", + "\u2210": "\\coprod", + "\u2211": "\\sum", + "\u22c0": "\\bigwedge", + "\u22c1": "\\bigvee", + "\u22c2": "\\bigcap", + "\u22c3": "\\bigcup", + "\u2a00": "\\bigodot", + "\u2a01": "\\bigoplus", + "\u2a02": "\\bigotimes", + "\u2a04": "\\biguplus", + "\u2a06": "\\bigsqcup" +}; +defineFunction({ + type: "op", + names: ["\\coprod", "\\bigvee", "\\bigwedge", "\\biguplus", "\\bigcap", "\\bigcup", "\\intop", "\\prod", "\\sum", "\\bigotimes", "\\bigoplus", "\\bigodot", "\\bigsqcup", "\\smallint", "\u220F", "\u2210", "\u2211", "\u22c0", "\u22c1", "\u22c2", "\u22c3", "\u2a00", "\u2a01", "\u2a02", "\u2a04", "\u2a06"], + props: { + numArgs: 0 + }, + handler: (_ref, args) => { + var { + parser, + funcName + } = _ref; + var fName = funcName; + if (fName.length === 1) { + fName = singleCharBigOps[fName]; + } + return { + type: "op", + mode: parser.mode, + limits: true, + parentIsSupSub: false, + symbol: true, + name: fName + }; + }, + htmlBuilder: htmlBuilder$2, + mathmlBuilder: mathmlBuilder$1 +}); +// Note: calling defineFunction with a type that's already been defined only +// works because the same htmlBuilder and mathmlBuilder are being used. +defineFunction({ + type: "op", + names: ["\\mathop"], + props: { + numArgs: 1, + primitive: true + }, + handler: (_ref2, args) => { + var { + parser + } = _ref2; + var body = args[0]; + return { + type: "op", + mode: parser.mode, + limits: false, + parentIsSupSub: false, + symbol: false, + body: ordargument(body) + }; + }, + htmlBuilder: htmlBuilder$2, + mathmlBuilder: mathmlBuilder$1 +}); +// There are 2 flags for operators; whether they produce limits in +// displaystyle, and whether they are symbols and should grow in +// displaystyle. These four groups cover the four possible choices. +var singleCharIntegrals = { + "\u222b": "\\int", + "\u222c": "\\iint", + "\u222d": "\\iiint", + "\u222e": "\\oint", + "\u222f": "\\oiint", + "\u2230": "\\oiiint" +}; +// No limits, not symbols +defineFunction({ + type: "op", + names: ["\\arcsin", "\\arccos", "\\arctan", "\\arctg", "\\arcctg", "\\arg", "\\ch", "\\cos", "\\cosec", "\\cosh", "\\cot", "\\cotg", "\\coth", "\\csc", "\\ctg", "\\cth", "\\deg", "\\dim", "\\exp", "\\hom", "\\ker", "\\lg", "\\ln", "\\log", "\\sec", "\\sin", "\\sinh", "\\sh", "\\tan", "\\tanh", "\\tg", "\\th"], + props: { + numArgs: 0 + }, + handler(_ref3) { + var { + parser, + funcName + } = _ref3; + return { + type: "op", + mode: parser.mode, + limits: false, + parentIsSupSub: false, + symbol: false, + name: funcName + }; + }, + htmlBuilder: htmlBuilder$2, + mathmlBuilder: mathmlBuilder$1 +}); +// Limits, not symbols +defineFunction({ + type: "op", + names: ["\\det", "\\gcd", "\\inf", "\\lim", "\\max", "\\min", "\\Pr", "\\sup"], + props: { + numArgs: 0 + }, + handler(_ref4) { + var { + parser, + funcName + } = _ref4; + return { + type: "op", + mode: parser.mode, + limits: true, + parentIsSupSub: false, + symbol: false, + name: funcName + }; + }, + htmlBuilder: htmlBuilder$2, + mathmlBuilder: mathmlBuilder$1 +}); +// No limits, symbols +defineFunction({ + type: "op", + names: ["\\int", "\\iint", "\\iiint", "\\oint", "\\oiint", "\\oiiint", "\u222b", "\u222c", "\u222d", "\u222e", "\u222f", "\u2230"], + props: { + numArgs: 0, + allowedInArgument: true + }, + handler(_ref5) { + var { + parser, + funcName + } = _ref5; + var fName = funcName; + if (fName.length === 1) { + fName = singleCharIntegrals[fName]; + } + return { + type: "op", + mode: parser.mode, + limits: false, + parentIsSupSub: false, + symbol: true, + name: fName + }; + }, + htmlBuilder: htmlBuilder$2, + mathmlBuilder: mathmlBuilder$1 +}); + +// NOTE: Unlike most `htmlBuilder`s, this one handles not only +// "operatorname", but also "supsub" since \operatorname* can +// affect super/subscripting. +var htmlBuilder$1 = (grp, options) => { + // Operators are handled in the TeXbook pg. 443-444, rule 13(a). + var supGroup; + var subGroup; + var hasLimits = false; + var group; + if (grp.type === "supsub") { + // If we have limits, supsub will pass us its group to handle. Pull + // out the superscript and subscript and set the group to the op in + // its base. + supGroup = grp.sup; + subGroup = grp.sub; + group = assertNodeType(grp.base, "operatorname"); + hasLimits = true; + } else { + group = assertNodeType(grp, "operatorname"); + } + var base; + if (group.body.length > 0) { + var body = group.body.map(child => { + var childText = "text" in child ? child.text : undefined; + if (typeof childText === "string") { + return { + type: "textord", + mode: child.mode, + text: childText + }; + } else { + return child; + } + }); + // Consolidate function names into symbol characters. + var expression = buildExpression$1(body, options.withFont("mathrm"), true); + for (var i = 0; i < expression.length; i++) { + var child = expression[i]; + if (child instanceof SymbolNode) { + // Per amsopn package, + // change minus to hyphen and \ast to asterisk + child.text = child.text.replace(/\u2212/, "-").replace(/\u2217/, "*"); + } + } + base = makeSpan(["mop"], expression, options); + } else { + base = makeSpan(["mop"], [], options); + } + if (hasLimits) { + return assembleSupSub(base, supGroup, subGroup, options, options.style, 0, 0); + } else { + return base; + } +}; +var mathmlBuilder = (group, options) => { + // The steps taken here are similar to the html version. + var expression = buildExpression(group.body, options.withFont("mathrm")); + // Is expression a string or has it something like a fraction? + var isAllString = true; // default + for (var i = 0; i < expression.length; i++) { + var node = expression[i]; + if (node instanceof SpaceNode) ; else if (node instanceof MathNode) { + switch (node.type) { + case "mi": + case "mn": + case "mspace": + case "mtext": + break; + // Do nothing yet. + case "mo": + { + var child = node.children[0]; + if (node.children.length === 1 && child instanceof TextNode) { + child.text = child.text.replace(/\u2212/, "-").replace(/\u2217/, "*"); + } else { + isAllString = false; + } + break; + } + default: + isAllString = false; + } + } else { + isAllString = false; + } + } + if (isAllString) { + // Write a single TextNode instead of multiple nested tags. + var word = expression.map(node => node.toText()).join(""); + expression = [new TextNode(word)]; + } + var identifier = new MathNode("mi", expression); + identifier.setAttribute("mathvariant", "normal"); + // \u2061 is the same as ⁡ + // ref: https://www.w3schools.com/charsets/ref_html_entities_a.asp + var operator = new MathNode("mo", [makeText("\u2061", "text")]); + if (group.parentIsSupSub) { + return new MathNode("mrow", [identifier, operator]); + } else { + return newDocumentFragment([identifier, operator]); + } +}; +// \operatorname +// amsopn.dtx: \mathop{#1\kern\z@\operator@font#3}\newmcodes@ +defineFunction({ + type: "operatorname", + names: ["\\operatorname@", "\\operatornamewithlimits"], + props: { + numArgs: 1 + }, + handler: (_ref, args) => { + var { + parser, + funcName + } = _ref; + var body = args[0]; + return { + type: "operatorname", + mode: parser.mode, + body: ordargument(body), + alwaysHandleSupSub: funcName === "\\operatornamewithlimits", + limits: false, + parentIsSupSub: false + }; + }, + htmlBuilder: htmlBuilder$1, + mathmlBuilder +}); +defineMacro("\\operatorname", "\\@ifstar\\operatornamewithlimits\\operatorname@"); + +defineFunctionBuilders({ + type: "ordgroup", + htmlBuilder(group, options) { + if (group.semisimple) { + return makeFragment(buildExpression$1(group.body, options, false)); + } + return makeSpan(["mord"], buildExpression$1(group.body, options, true), options); + }, + mathmlBuilder(group, options) { + return buildExpressionRow(group.body, options, true); + } +}); + +defineFunction({ + type: "overline", + names: ["\\overline"], + props: { + numArgs: 1 + }, + handler(_ref, args) { + var { + parser + } = _ref; + var body = args[0]; + return { + type: "overline", + mode: parser.mode, + body + }; + }, + htmlBuilder(group, options) { + // Overlines are handled in the TeXbook pg 443, Rule 9. + // Build the inner group in the cramped style. + var innerGroup = buildGroup$1(group.body, options.havingCrampedStyle()); + // Create the line above the body + var line = makeLineSpan("overline-line", options); + // Generate the vlist, with the appropriate kerns + var defaultRuleThickness = options.fontMetrics().defaultRuleThickness; + var vlist = makeVList({ + positionType: "firstBaseline", + children: [{ + type: "elem", + elem: innerGroup + }, { + type: "kern", + size: 3 * defaultRuleThickness + }, { + type: "elem", + elem: line + }, { + type: "kern", + size: defaultRuleThickness + }] + }); + return makeSpan(["mord", "overline"], [vlist], options); + }, + mathmlBuilder(group, options) { + var operator = new MathNode("mo", [new TextNode("\u203e")]); + operator.setAttribute("stretchy", "true"); + var node = new MathNode("mover", [buildGroup(group.body, options), operator]); + node.setAttribute("accent", "true"); + return node; + } +}); + +defineFunction({ + type: "phantom", + names: ["\\phantom"], + props: { + numArgs: 1, + allowedInText: true + }, + handler: (_ref, args) => { + var { + parser + } = _ref; + var body = args[0]; + return { + type: "phantom", + mode: parser.mode, + body: ordargument(body) + }; + }, + htmlBuilder: (group, options) => { + var elements = buildExpression$1(group.body, options.withPhantom(), false); + // \phantom isn't supposed to affect the elements it contains. + // See "color" for more details. + return makeFragment(elements); + }, + mathmlBuilder: (group, options) => { + var inner = buildExpression(group.body, options); + return new MathNode("mphantom", inner); + } +}); +defineMacro("\\hphantom", "\\smash{\\phantom{#1}}"); +defineFunction({ + type: "vphantom", + names: ["\\vphantom"], + props: { + numArgs: 1, + allowedInText: true + }, + handler: (_ref2, args) => { + var { + parser + } = _ref2; + var body = args[0]; + return { + type: "vphantom", + mode: parser.mode, + body + }; + }, + htmlBuilder: (group, options) => { + var inner = makeSpan(["inner"], [buildGroup$1(group.body, options.withPhantom())]); + var fix = makeSpan(["fix"], []); + return makeSpan(["mord", "rlap"], [inner, fix], options); + }, + mathmlBuilder: (group, options) => { + var inner = buildExpression(ordargument(group.body), options); + var phantom = new MathNode("mphantom", inner); + var node = new MathNode("mpadded", [phantom]); + node.setAttribute("width", "0px"); + return node; + } +}); + +// Box manipulation +defineFunction({ + type: "raisebox", + names: ["\\raisebox"], + props: { + numArgs: 2, + argTypes: ["size", "hbox"], + allowedInText: true + }, + handler(_ref, args) { + var { + parser + } = _ref; + var amount = assertNodeType(args[0], "size").value; + var body = args[1]; + return { + type: "raisebox", + mode: parser.mode, + dy: amount, + body + }; + }, + htmlBuilder(group, options) { + var body = buildGroup$1(group.body, options); + var dy = calculateSize(group.dy, options); + return makeVList({ + positionType: "shift", + positionData: -dy, + children: [{ + type: "elem", + elem: body + }] + }); + }, + mathmlBuilder(group, options) { + var node = new MathNode("mpadded", [buildGroup(group.body, options)]); + var dy = group.dy.number + group.dy.unit; + node.setAttribute("voffset", dy); + return node; + } +}); + +defineFunction({ + type: "internal", + names: ["\\relax"], + props: { + numArgs: 0, + allowedInText: true, + allowedInArgument: true + }, + handler(_ref) { + var { + parser + } = _ref; + return { + type: "internal", + mode: parser.mode + }; + } +}); + +defineFunction({ + type: "rule", + names: ["\\rule"], + props: { + numArgs: 2, + numOptionalArgs: 1, + allowedInText: true, + allowedInMath: true, + argTypes: ["size", "size", "size"] + }, + handler(_ref, args, optArgs) { + var { + parser + } = _ref; + var shift = optArgs[0]; + var width = assertNodeType(args[0], "size"); + var height = assertNodeType(args[1], "size"); + return { + type: "rule", + mode: parser.mode, + shift: shift && assertNodeType(shift, "size").value, + width: width.value, + height: height.value + }; + }, + htmlBuilder(group, options) { + // Make an empty span for the rule + var rule = makeSpan(["mord", "rule"], [], options); + // Calculate the shift, width, and height of the rule, and account for units + var width = calculateSize(group.width, options); + var height = calculateSize(group.height, options); + var shift = group.shift ? calculateSize(group.shift, options) : 0; + // Style the rule to the right size + rule.style.borderRightWidth = makeEm(width); + rule.style.borderTopWidth = makeEm(height); + rule.style.bottom = makeEm(shift); + // Record the height and width + rule.width = width; + rule.height = height + shift; + rule.depth = -shift; + // Font size is the number large enough that the browser will + // reserve at least `absHeight` space above the baseline. + // The 1.125 factor was empirically determined + rule.maxFontSize = height * 1.125 * options.sizeMultiplier; + return rule; + }, + mathmlBuilder(group, options) { + var width = calculateSize(group.width, options); + var height = calculateSize(group.height, options); + var shift = group.shift ? calculateSize(group.shift, options) : 0; + var color = options.color && options.getColor() || "black"; + var rule = new MathNode("mspace"); + rule.setAttribute("mathbackground", color); + rule.setAttribute("width", makeEm(width)); + rule.setAttribute("height", makeEm(height)); + var wrapper = new MathNode("mpadded", [rule]); + if (shift >= 0) { + wrapper.setAttribute("height", makeEm(shift)); + } else { + wrapper.setAttribute("height", makeEm(shift)); + wrapper.setAttribute("depth", makeEm(-shift)); + } + wrapper.setAttribute("voffset", makeEm(shift)); + return wrapper; + } +}); + +function sizingGroup(value, options, baseOptions) { + var inner = buildExpression$1(value, options, false); + var multiplier = options.sizeMultiplier / baseOptions.sizeMultiplier; + // Add size-resetting classes to the inner list and set maxFontSize + // manually. Handle nested size changes. + for (var i = 0; i < inner.length; i++) { + var pos = inner[i].classes.indexOf("sizing"); + if (pos < 0) { + Array.prototype.push.apply(inner[i].classes, options.sizingClasses(baseOptions)); + } else if (inner[i].classes[pos + 1] === "reset-size" + options.size) { + // This is a nested size change: e.g., inner[i] is the "b" in + // `\Huge a \small b`. Override the old size (the `reset-` class) + // but not the new size. + inner[i].classes[pos + 1] = "reset-size" + baseOptions.size; + } + inner[i].height *= multiplier; + inner[i].depth *= multiplier; + } + return makeFragment(inner); +} +var sizeFuncs = ["\\tiny", "\\sixptsize", "\\scriptsize", "\\footnotesize", "\\small", "\\normalsize", "\\large", "\\Large", "\\LARGE", "\\huge", "\\Huge"]; +var htmlBuilder = (group, options) => { + // Handle sizing operators like \Huge. Real TeX doesn't actually allow + // these functions inside of math expressions, so we do some special + // handling. + var newOptions = options.havingSize(group.size); + return sizingGroup(group.body, newOptions, options); +}; +defineFunction({ + type: "sizing", + names: sizeFuncs, + props: { + numArgs: 0, + allowedInText: true + }, + handler: (_ref, args) => { + var { + breakOnTokenText, + funcName, + parser + } = _ref; + var body = parser.parseExpression(false, breakOnTokenText); + return { + type: "sizing", + mode: parser.mode, + // Figure out what size to use based on the list of functions above + size: sizeFuncs.indexOf(funcName) + 1, + body + }; + }, + htmlBuilder, + mathmlBuilder: (group, options) => { + var newOptions = options.havingSize(group.size); + var inner = buildExpression(group.body, newOptions); + var node = new MathNode("mstyle", inner); + // TODO(emily): This doesn't produce the correct size for nested size + // changes, because we don't keep state of what style we're currently + // in, so we can't reset the size to normal before changing it. Now + // that we're passing an options parameter we should be able to fix + // this. + node.setAttribute("mathsize", makeEm(newOptions.sizeMultiplier)); + return node; + } +}); + +// smash, with optional [tb], as in AMS +defineFunction({ + type: "smash", + names: ["\\smash"], + props: { + numArgs: 1, + numOptionalArgs: 1, + allowedInText: true + }, + handler: (_ref, args, optArgs) => { + var { + parser + } = _ref; + var smashHeight = false; + var smashDepth = false; + var tbArg = optArgs[0] && assertNodeType(optArgs[0], "ordgroup"); + if (tbArg) { + // Optional [tb] argument is engaged. + // ref: amsmath: \renewcommand{\smash}[1][tb]{% + // def\mb@t{\ht}\def\mb@b{\dp}\def\mb@tb{\ht\z@\z@\dp}% + var letter; + for (var i = 0; i < tbArg.body.length; ++i) { + var node = tbArg.body[i]; + letter = assertSymbolNodeType(node).text; + if (letter === "t") { + smashHeight = true; + } else if (letter === "b") { + smashDepth = true; + } else { + smashHeight = false; + smashDepth = false; + break; + } + } + } else { + smashHeight = true; + smashDepth = true; + } + var body = args[0]; + return { + type: "smash", + mode: parser.mode, + body, + smashHeight, + smashDepth + }; + }, + htmlBuilder: (group, options) => { + var node = makeSpan([], [buildGroup$1(group.body, options)]); + if (!group.smashHeight && !group.smashDepth) { + return node; + } + if (group.smashHeight) { + node.height = 0; + } + if (group.smashDepth) { + node.depth = 0; + } + if (group.smashHeight && group.smashDepth) { + // Symmetric \smash can stay in inline layout. + return makeSpan(["mord", "smash"], [node], options); + } + // In order to influence makeVList for asymmetric smashing, we have to + // reset the children. + if (node.children) { + for (var i = 0; i < node.children.length; i++) { + if (group.smashHeight) { + node.children[i].height = 0; + } + if (group.smashDepth) { + node.children[i].depth = 0; + } + } + } + // At this point, we've reset the TeX-like height and depth values. + // But the span still has an HTML line height. + // makeVList applies "display: table-cell", which prevents the browser + // from acting on that line height. So we'll call makeVList now. + var smashedNode = makeVList({ + positionType: "firstBaseline", + children: [{ + type: "elem", + elem: node + }] + }); + // For spacing, TeX treats \smash as a math group (same spacing as ord). + return makeSpan(["mord"], [smashedNode], options); + }, + mathmlBuilder: (group, options) => { + var node = new MathNode("mpadded", [buildGroup(group.body, options)]); + if (group.smashHeight) { + node.setAttribute("height", "0px"); + } + if (group.smashDepth) { + node.setAttribute("depth", "0px"); + } + return node; + } +}); + +defineFunction({ + type: "sqrt", + names: ["\\sqrt"], + props: { + numArgs: 1, + numOptionalArgs: 1 + }, + handler(_ref, args, optArgs) { + var { + parser + } = _ref; + var index = optArgs[0]; + var body = args[0]; + return { + type: "sqrt", + mode: parser.mode, + body, + index + }; + }, + htmlBuilder(group, options) { + // Square roots are handled in the TeXbook pg. 443, Rule 11. + // First, we do the same steps as in overline to build the inner group + // and line + var inner = buildGroup$1(group.body, options.havingCrampedStyle()); + if (inner.height === 0) { + // Render a small surd. + inner.height = options.fontMetrics().xHeight; + } + // Some groups can return document fragments. Handle those by wrapping + // them in a span. + inner = wrapFragment(inner, options); + // Calculate the minimum size for the \surd delimiter + var metrics = options.fontMetrics(); + var theta = metrics.defaultRuleThickness; + var phi = theta; + if (options.style.id < Style$1.TEXT.id) { + phi = options.fontMetrics().xHeight; + } + // Calculate the clearance between the body and line + var lineClearance = theta + phi / 4; + var minDelimiterHeight = inner.height + inner.depth + lineClearance + theta; + // Create a sqrt SVG of the required minimum size + var { + span: img, + ruleWidth, + advanceWidth + } = makeSqrtImage(minDelimiterHeight, options); + var delimDepth = img.height - ruleWidth; + // Adjust the clearance based on the delimiter size + if (delimDepth > inner.height + inner.depth + lineClearance) { + lineClearance = (lineClearance + delimDepth - inner.height - inner.depth) / 2; + } + // Shift the sqrt image + var imgShift = img.height - inner.height - lineClearance - ruleWidth; + inner.style.paddingLeft = makeEm(advanceWidth); + // Overlay the image and the argument. + var body = makeVList({ + positionType: "firstBaseline", + children: [{ + type: "elem", + elem: inner, + wrapperClasses: ["svg-align"] + }, { + type: "kern", + size: -(inner.height + imgShift) + }, { + type: "elem", + elem: img + }, { + type: "kern", + size: ruleWidth + }] + }); + if (!group.index) { + return makeSpan(["mord", "sqrt"], [body], options); + } else { + // Handle the optional root index + // The index is always in scriptscript style + var newOptions = options.havingStyle(Style$1.SCRIPTSCRIPT); + var rootm = buildGroup$1(group.index, newOptions, options); + // The amount the index is shifted by. This is taken from the TeX + // source, in the definition of `\r@@t`. + var toShift = 0.6 * (body.height - body.depth); + // Build a VList with the superscript shifted up correctly + var rootVList = makeVList({ + positionType: "shift", + positionData: -toShift, + children: [{ + type: "elem", + elem: rootm + }] + }); + // Add a class surrounding it so we can add on the appropriate + // kerning + var rootVListWrap = makeSpan(["root"], [rootVList]); + return makeSpan(["mord", "sqrt"], [rootVListWrap, body], options); + } + }, + mathmlBuilder(group, options) { + var { + body, + index + } = group; + return index ? new MathNode("mroot", [buildGroup(body, options), buildGroup(index, options)]) : new MathNode("msqrt", [buildGroup(body, options)]); + } +}); + +var styleMap = { + "display": Style$1.DISPLAY, + "text": Style$1.TEXT, + "script": Style$1.SCRIPT, + "scriptscript": Style$1.SCRIPTSCRIPT +}; +function isStyleStr(s) { + return s in styleMap; +} +defineFunction({ + type: "styling", + names: ["\\displaystyle", "\\textstyle", "\\scriptstyle", "\\scriptscriptstyle"], + props: { + numArgs: 0, + allowedInText: true, + primitive: true + }, + handler(_ref, args) { + var { + breakOnTokenText, + funcName, + parser + } = _ref; + // parse out the implicit body + var body = parser.parseExpression(true, breakOnTokenText); + // TODO: Refactor to avoid duplicating styleMap in multiple places (e.g. + // here and in buildHTML and de-dupe the enumeration of all the styles). + var style = funcName.slice(1, funcName.length - 5); + if (!isStyleStr(style)) { + throw new Error("Unknown style: " + style); + } + return { + type: "styling", + mode: parser.mode, + // Figure out what style to use by pulling out the style from + // the function name + style, + body + }; + }, + htmlBuilder(group, options) { + // Style changes are handled in the TeXbook on pg. 442, Rule 3. + var newStyle = styleMap[group.style]; + var newOptions = options.havingStyle(newStyle); + if (group.resetFont) { + newOptions = newOptions.withFont(''); + } + return sizingGroup(group.body, newOptions, options); + }, + mathmlBuilder(group, options) { + // Figure out what style we're changing to. + var newStyle = styleMap[group.style]; + var newOptions = options.havingStyle(newStyle); + if (group.resetFont) { + newOptions = newOptions.withFont(''); + } + var inner = buildExpression(group.body, newOptions); + var node = new MathNode("mstyle", inner); + var styleAttributes = { + "display": ["0", "true"], + "text": ["0", "false"], + "script": ["1", "false"], + "scriptscript": ["2", "false"] + }; + var attr = styleAttributes[group.style]; + node.setAttribute("scriptlevel", attr[0]); + node.setAttribute("displaystyle", attr[1]); + return node; + } +}); + +/** + * Sometimes, groups perform special rules when they have superscripts or + * subscripts attached to them. This function lets the `supsub` group know that + * Sometimes, groups perform special rules when they have superscripts or + * its inner element should handle the superscripts and subscripts instead of + * handling them itself. + */ +var htmlBuilderDelegate = function htmlBuilderDelegate(group, options) { + var base = group.base; + if (!base) { + return null; + } else if (base.type === "op") { + // Operators handle supsubs differently when they have limits + // (e.g. `\displaystyle\sum_2^3`) + var delegate = base.limits && (options.style.size === Style$1.DISPLAY.size || base.alwaysHandleSupSub); + return delegate ? htmlBuilder$2 : null; + } else if (base.type === "operatorname") { + var _delegate = base.alwaysHandleSupSub && (options.style.size === Style$1.DISPLAY.size || base.limits); + return _delegate ? htmlBuilder$1 : null; + } else if (base.type === "accent") { + return isCharacterBox(base.base) ? htmlBuilder$a : null; + } else if (base.type === "horizBrace") { + var isSup = !group.sub; + return isSup === base.isOver ? htmlBuilder$3 : null; + } else { + return null; + } +}; +// Super scripts and subscripts, whose precise placement can depend on other +// functions that precede them. +defineFunctionBuilders({ + type: "supsub", + htmlBuilder(group, options) { + // Superscript and subscripts are handled in the TeXbook on page + // 445-446, rules 18(a-f). + // Here is where we defer to the inner group if it should handle + // superscripts and subscripts itself. + var builderDelegate = htmlBuilderDelegate(group, options); + if (builderDelegate) { + return builderDelegate(group, options); + } + var { + base: valueBase, + sup: valueSup, + sub: valueSub + } = group; + var base = buildGroup$1(valueBase, options); + var supm; + var subm; + var metrics = options.fontMetrics(); + // Rule 18a + var supShift = 0; + var subShift = 0; + var isCharBox = valueBase && isCharacterBox(valueBase); + if (valueSup) { + var newOptions = options.havingStyle(options.style.sup()); + supm = buildGroup$1(valueSup, newOptions, options); + if (!isCharBox) { + supShift = base.height - newOptions.fontMetrics().supDrop * newOptions.sizeMultiplier / options.sizeMultiplier; + } + } + if (valueSub) { + var _newOptions = options.havingStyle(options.style.sub()); + subm = buildGroup$1(valueSub, _newOptions, options); + if (!isCharBox) { + subShift = base.depth + _newOptions.fontMetrics().subDrop * _newOptions.sizeMultiplier / options.sizeMultiplier; + } + } + // Rule 18c + var minSupShift; + if (options.style === Style$1.DISPLAY) { + minSupShift = metrics.sup1; + } else if (options.style.cramped) { + minSupShift = metrics.sup3; + } else { + minSupShift = metrics.sup2; + } + // scriptspace is a font-size-independent size, so scale it + // appropriately for use as the marginRight. + var multiplier = options.sizeMultiplier; + var marginRight = makeEm(0.5 / metrics.ptPerEm / multiplier); + var marginLeft = null; + if (subm) { + // Subscripts shouldn't be shifted by the base's italic correction. + // Account for that by shifting the subscript back the appropriate + // amount. Note we only do this when the base is a single symbol. + var isOiint = group.base && group.base.type === "op" && group.base.name && (group.base.name === "\\oiint" || group.base.name === "\\oiiint"); + if (base instanceof SymbolNode || isOiint) { + var _base$italic; + // SymbolNode has .italic natively; for \oiint/\oiiint the + // op builder stores .italic on the wrapping Span. + marginLeft = makeEm(-((_base$italic = base.italic) != null ? _base$italic : 0)); + } + } + var supsub; + if (supm && subm) { + supShift = Math.max(supShift, minSupShift, supm.depth + 0.25 * metrics.xHeight); + subShift = Math.max(subShift, metrics.sub2); + var ruleWidth = metrics.defaultRuleThickness; + // Rule 18e + var maxWidth = 4 * ruleWidth; + if (supShift - supm.depth - (subm.height - subShift) < maxWidth) { + subShift = maxWidth - (supShift - supm.depth) + subm.height; + var psi = 0.8 * metrics.xHeight - (supShift - supm.depth); + if (psi > 0) { + supShift += psi; + subShift -= psi; + } + } + var vlistElem = [{ + type: "elem", + elem: subm, + shift: subShift, + marginRight, + marginLeft + }, { + type: "elem", + elem: supm, + shift: -supShift, + marginRight + }]; + supsub = makeVList({ + positionType: "individualShift", + children: vlistElem + }); + } else if (subm) { + // Rule 18b + subShift = Math.max(subShift, metrics.sub1, subm.height - 0.8 * metrics.xHeight); + var _vlistElem = [{ + type: "elem", + elem: subm, + marginLeft, + marginRight + }]; + supsub = makeVList({ + positionType: "shift", + positionData: subShift, + children: _vlistElem + }); + } else if (supm) { + // Rule 18c, d + supShift = Math.max(supShift, minSupShift, supm.depth + 0.25 * metrics.xHeight); + supsub = makeVList({ + positionType: "shift", + positionData: -supShift, + children: [{ + type: "elem", + elem: supm, + marginRight + }] + }); + } else { + throw new Error("supsub must have either sup or sub."); + } + // Wrap the supsub vlist in a span.msupsub to reset text-align. + var mclass = getTypeOfDomTree(base, "right") || "mord"; + return makeSpan([mclass], [base, makeSpan(["msupsub"], [supsub])], options); + }, + mathmlBuilder(group, options) { + // Is the inner group a relevant horizontal brace? + var isBrace = false; + var isOver; + var isSup; + if (group.base && group.base.type === "horizBrace") { + isSup = !!group.sup; + if (isSup === group.base.isOver) { + isBrace = true; + isOver = group.base.isOver; + } + } + if (group.base && (group.base.type === "op" || group.base.type === "operatorname")) { + group.base.parentIsSupSub = true; + } + var children = [buildGroup(group.base, options)]; + if (group.sub) { + children.push(buildGroup(group.sub, options)); + } + if (group.sup) { + children.push(buildGroup(group.sup, options)); + } + var nodeType; + if (isBrace) { + nodeType = isOver ? "mover" : "munder"; + } else if (!group.sub) { + var base = group.base; + if (base && base.type === "op" && base.limits && (options.style === Style$1.DISPLAY || base.alwaysHandleSupSub)) { + nodeType = "mover"; + } else if (base && base.type === "operatorname" && base.alwaysHandleSupSub && (base.limits || options.style === Style$1.DISPLAY)) { + nodeType = "mover"; + } else { + nodeType = "msup"; + } + } else if (!group.sup) { + var _base = group.base; + if (_base && _base.type === "op" && _base.limits && (options.style === Style$1.DISPLAY || _base.alwaysHandleSupSub)) { + nodeType = "munder"; + } else if (_base && _base.type === "operatorname" && _base.alwaysHandleSupSub && (_base.limits || options.style === Style$1.DISPLAY)) { + nodeType = "munder"; + } else { + nodeType = "msub"; + } + } else { + var _base2 = group.base; + if (_base2 && _base2.type === "op" && _base2.limits && options.style === Style$1.DISPLAY) { + nodeType = "munderover"; + } else if (_base2 && _base2.type === "operatorname" && _base2.alwaysHandleSupSub && (options.style === Style$1.DISPLAY || _base2.limits)) { + nodeType = "munderover"; + } else { + nodeType = "msubsup"; + } + } + return new MathNode(nodeType, children); + } +}); + +// Operator ParseNodes created in Parser.js from symbol Groups in src/symbols.js. +defineFunctionBuilders({ + type: "atom", + htmlBuilder(group, options) { + return mathsym(group.text, group.mode, options, ["m" + group.family]); + }, + mathmlBuilder(group, options) { + var node = new MathNode("mo", [makeText(group.text, group.mode)]); + if (group.family === "bin") { + var variant = getVariant(group, options); + if (variant === "bold-italic") { + node.setAttribute("mathvariant", variant); + } + } else if (group.family === "punct") { + node.setAttribute("separator", "true"); + } else if (group.family === "open" || group.family === "close") { + // Delims built here should not stretch vertically. + // See delimsizing.js for stretchy delims. + node.setAttribute("stretchy", "false"); + } + return node; + } +}); + +// "mathord" and "textord" ParseNodes created in Parser.js from symbol Groups in +// src/symbols.js. +var defaultVariant = { + "mi": "italic", + "mn": "normal", + "mtext": "normal" +}; +defineFunctionBuilders({ + type: "mathord", + htmlBuilder(group, options) { + return makeOrd(group, options, "mathord"); + }, + mathmlBuilder(group, options) { + var node = new MathNode("mi", [makeText(group.text, group.mode, options)]); + var variant = getVariant(group, options) || "italic"; + if (variant !== defaultVariant[node.type]) { + node.setAttribute("mathvariant", variant); + } + return node; + } +}); +defineFunctionBuilders({ + type: "textord", + htmlBuilder(group, options) { + return makeOrd(group, options, "textord"); + }, + mathmlBuilder(group, options) { + var text = makeText(group.text, group.mode, options); + var variant = getVariant(group, options) || "normal"; + var node; + if (group.mode === 'text') { + node = new MathNode("mtext", [text]); + } else if (/[0-9]/.test(group.text)) { + node = new MathNode("mn", [text]); + } else if (group.text === "\\prime") { + node = new MathNode("mo", [text]); + } else { + node = new MathNode("mi", [text]); + } + if (variant !== defaultVariant[node.type]) { + node.setAttribute("mathvariant", variant); + } + return node; + } +}); + +// A map of CSS-based spacing functions to their CSS class. +var cssSpace = { + "\\nobreak": "nobreak", + "\\allowbreak": "allowbreak" +}; +// A lookup table to determine whether a spacing function/symbol should be +// treated like a regular space character. If a symbol or command is a key +// in this table, then it should be a regular space character. Furthermore, +// the associated value may have a `className` specifying an extra CSS class +// to add to the created `span`. +var regularSpace = { + " ": {}, + "\\ ": {}, + "~": { + className: "nobreak" + }, + "\\space": {}, + "\\nobreakspace": { + className: "nobreak" + } +}; +// ParseNode<"spacing"> created in Parser.js from the "spacing" symbol Groups in +// src/symbols.js. +defineFunctionBuilders({ + type: "spacing", + htmlBuilder(group, options) { + if (regularSpace.hasOwnProperty(group.text)) { + var className = regularSpace[group.text].className || ""; + // Spaces are generated by adding an actual space. Each of these + // things has an entry in the symbols table, so these will be turned + // into appropriate outputs. + if (group.mode === "text") { + var ord = makeOrd(group, options, "textord"); + ord.classes.push(className); + return ord; + } else { + return makeSpan(["mspace", className], [mathsym(group.text, group.mode, options)], options); + } + } else if (cssSpace.hasOwnProperty(group.text)) { + // Spaces based on just a CSS class. + return makeSpan(["mspace", cssSpace[group.text]], [], options); + } else { + throw new ParseError("Unknown type of space \"" + group.text + "\""); + } + }, + mathmlBuilder(group, options) { + var node; + if (regularSpace.hasOwnProperty(group.text)) { + node = new MathNode("mtext", [new TextNode("\u00a0")]); + } else if (cssSpace.hasOwnProperty(group.text)) { + // CSS-based MathML spaces (\nobreak, \allowbreak) are ignored + return new MathNode("mspace"); + } else { + throw new ParseError("Unknown type of space \"" + group.text + "\""); + } + return node; + } +}); + +var pad = () => { + var padNode = new MathNode("mtd", []); + padNode.setAttribute("width", "50%"); + return padNode; +}; +defineFunctionBuilders({ + type: "tag", + mathmlBuilder(group, options) { + var table = new MathNode("mtable", [new MathNode("mtr", [pad(), new MathNode("mtd", [buildExpressionRow(group.body, options)]), pad(), new MathNode("mtd", [buildExpressionRow(group.tag, options)])])]); + table.setAttribute("width", "100%"); + return table; + // TODO: Left-aligned tags. + // Currently, the group and options passed here do not contain + // enough info to set tag alignment. `leqno` is in Settings but it is + // not passed to Options. On the HTML side, leqno is + // set by a CSS class applied in buildTree.js. That would have worked + // in MathML if browsers supported . Since they don't, we + // need to rewrite the way this function is called. + } +}); + +// Non-mathy text, possibly in a font +var textFontFamilies = { + "\\text": undefined, + "\\textrm": "textrm", + "\\textsf": "textsf", + "\\texttt": "texttt", + "\\textnormal": "textrm" +}; +var textFontWeights = { + "\\textbf": "textbf", + "\\textmd": "textmd" +}; +var textFontShapes = { + "\\textit": "textit", + "\\textup": "textup" +}; +var optionsWithFont = (group, options) => { + var font = group.font; + // Checks if the argument is a font family or a font style. + if (!font) { + return options; + } else if (textFontFamilies[font]) { + return options.withTextFontFamily(textFontFamilies[font]); + } else if (textFontWeights[font]) { + return options.withTextFontWeight(textFontWeights[font]); + } else if (font === "\\emph") { + return options.fontShape === "textit" ? options.withTextFontShape("textup") : options.withTextFontShape("textit"); + } + return options.withTextFontShape(textFontShapes[font]); +}; +defineFunction({ + type: "text", + names: [ + // Font families + "\\text", "\\textrm", "\\textsf", "\\texttt", "\\textnormal", + // Font weights + "\\textbf", "\\textmd", + // Font Shapes + "\\textit", "\\textup", "\\emph"], + props: { + numArgs: 1, + argTypes: ["text"], + allowedInArgument: true, + allowedInText: true + }, + handler(_ref, args) { + var { + parser, + funcName + } = _ref; + var body = args[0]; + return { + type: "text", + mode: parser.mode, + body: ordargument(body), + font: funcName + }; + }, + htmlBuilder(group, options) { + var newOptions = optionsWithFont(group, options); + var inner = buildExpression$1(group.body, newOptions, true); + return makeSpan(["mord", "text"], inner, newOptions); + }, + mathmlBuilder(group, options) { + var newOptions = optionsWithFont(group, options); + return buildExpressionRow(group.body, newOptions); + } +}); + +defineFunction({ + type: "underline", + names: ["\\underline"], + props: { + numArgs: 1, + allowedInText: true + }, + handler(_ref, args) { + var { + parser + } = _ref; + return { + type: "underline", + mode: parser.mode, + body: args[0] + }; + }, + htmlBuilder(group, options) { + // Underlines are handled in the TeXbook pg 443, Rule 10. + // Build the inner group. + var innerGroup = buildGroup$1(group.body, options); + // Create the line to go below the body + var line = makeLineSpan("underline-line", options); + // Generate the vlist, with the appropriate kerns + var defaultRuleThickness = options.fontMetrics().defaultRuleThickness; + var vlist = makeVList({ + positionType: "top", + positionData: innerGroup.height, + children: [{ + type: "kern", + size: defaultRuleThickness + }, { + type: "elem", + elem: line + }, { + type: "kern", + size: 3 * defaultRuleThickness + }, { + type: "elem", + elem: innerGroup + }] + }); + return makeSpan(["mord", "underline"], [vlist], options); + }, + mathmlBuilder(group, options) { + var operator = new MathNode("mo", [new TextNode("\u203e")]); + operator.setAttribute("stretchy", "true"); + var node = new MathNode("munder", [buildGroup(group.body, options), operator]); + node.setAttribute("accentunder", "true"); + return node; + } +}); + +// \vcenter: Vertically center the argument group on the math axis. +defineFunction({ + type: "vcenter", + names: ["\\vcenter"], + props: { + numArgs: 1, + argTypes: ["original"], + // In LaTeX, \vcenter can act only on a box. + allowedInText: false + }, + handler(_ref, args) { + var { + parser + } = _ref; + return { + type: "vcenter", + mode: parser.mode, + body: args[0] + }; + }, + htmlBuilder(group, options) { + var body = buildGroup$1(group.body, options); + var axisHeight = options.fontMetrics().axisHeight; + var dy = 0.5 * (body.height - axisHeight - (body.depth + axisHeight)); + return makeVList({ + positionType: "shift", + positionData: dy, + children: [{ + type: "elem", + elem: body + }] + }); + }, + mathmlBuilder(group, options) { + // There is no way to do this in MathML. + // Write a class as a breadcrumb in case some post-processor wants + // to perform a vcenter adjustment. + // Wrap in mrow to ensure valid MathML when placed inside mo (e.g., \mathrel) + var mpadded = new MathNode("mpadded", [buildGroup(group.body, options)], ["vcenter"]); + return new MathNode("mrow", [mpadded]); + } +}); + +defineFunction({ + type: "verb", + names: ["\\verb"], + props: { + numArgs: 0, + allowedInText: true + }, + handler(context, args, optArgs) { + // \verb and \verb* are dealt with directly in Parser.js. + // If we end up here, it's because of a failure to match the two delimiters + // in the regex in Lexer.js. LaTeX raises the following error when \verb is + // terminated by end of line (or file). + throw new ParseError("\\verb ended by end of line instead of matching delimiter"); + }, + htmlBuilder(group, options) { + var text = makeVerb(group); + var body = []; + // \verb enters text mode and therefore is sized like \textstyle + var newOptions = options.havingStyle(options.style.text()); + for (var i = 0; i < text.length; i++) { + var c = text[i]; + if (c === '~') { + c = '\\textasciitilde'; + } + body.push(makeSymbol(c, "Typewriter-Regular", group.mode, newOptions, ["mord", "texttt"])); + } + return makeSpan(["mord", "text"].concat(newOptions.sizingClasses(options)), tryCombineChars(body), newOptions); + }, + mathmlBuilder(group, options) { + var text = new TextNode(makeVerb(group)); + var node = new MathNode("mtext", [text]); + node.setAttribute("mathvariant", "monospace"); + return node; + } +}); +/** + * Converts verb group into body string. + * + * \verb* replaces each space with an open box \u2423 + * \verb replaces each space with a no-break space \xA0 + */ +var makeVerb = group => group.body.replace(/ /g, group.star ? '\u2423' : '\xA0'); + +/** Include this to ensure that all functions are defined. */ +var functions = _functions; + +/** + * The Lexer class handles tokenizing the input in various ways. Since our + * parser expects us to be able to backtrack, the lexer allows lexing from any + * given starting point. + * + * Its main exposed function is the `lex` function, which takes a position to + * lex from and a type of token to lex. It defers to the appropriate `_innerLex` + * function. + * + * The various `_innerLex` functions perform the actual lexing of different + * kinds. + */ +/* The following tokenRegex + * - matches typical whitespace (but not NBSP etc.) using its first group + * - does not match any control character \x00-\x1f except whitespace + * - does not match a bare backslash + * - matches any ASCII character except those just mentioned + * - does not match the BMP private use area \uE000-\uF8FF + * - does not match bare surrogate code units + * - matches any BMP character except for those just described + * - matches any valid Unicode surrogate pair + * - matches a backslash followed by one or more whitespace characters + * - matches a backslash followed by one or more letters then whitespace + * - matches a backslash followed by any BMP character + * Capturing groups: + * [1] regular whitespace + * [2] backslash followed by whitespace + * [3] anything else, which may include: + * [4] left character of \verb* + * [5] left character of \verb + * [6] backslash followed by word, excluding any trailing whitespace + * Just because the Lexer matches something doesn't mean it's valid input: + * If there is no matching function or symbol definition, the Parser will + * still reject the input. + */ +var spaceRegexString = "[ \r\n\t]"; +var controlWordRegexString = "\\\\[a-zA-Z@]+"; +var controlSymbolRegexString = "\\\\[^\uD800-\uDFFF]"; +var controlWordWhitespaceRegexString = "(" + controlWordRegexString + ")" + spaceRegexString + "*"; +var controlSpaceRegexString = "\\\\(\n|[ \r\t]+\n?)[ \r\t]*"; +var combiningDiacriticalMarkString = "[\u0300-\u036f]"; +var combiningDiacriticalMarksEndRegex = new RegExp(combiningDiacriticalMarkString + "+$"); +var tokenRegexString = "(" + spaceRegexString + "+)|" + (// whitespace +controlSpaceRegexString + "|") + +// \whitespace +"([!-\\[\\]-\u2027\u202A-\uD7FF\uF900-\uFFFF]" + (// single codepoint +combiningDiacriticalMarkString + "*") + +// ...plus accents +"|[\uD800-\uDBFF][\uDC00-\uDFFF]" + (// surrogate pair +combiningDiacriticalMarkString + "*") + +// ...plus accents +"|\\\\verb\\*([^]).*?\\4" + +// \verb* +"|\\\\verb([^*a-zA-Z]).*?\\5" + (// \verb unstarred +"|" + controlWordWhitespaceRegexString) + (// \macroName + spaces +"|" + controlSymbolRegexString + ")"); // \\, \', etc. +/** Main Lexer class */ +class Lexer { + constructor(input, settings) { + this.input = void 0; + this.settings = void 0; + this.tokenRegex = void 0; + // Category codes. The lexer only supports comment characters (14) for now. + // MacroExpander additionally distinguishes active (13). + this.catcodes = void 0; + // Separate accents from characters + this.input = input; + this.settings = settings; + this.tokenRegex = new RegExp(tokenRegexString, 'g'); + this.catcodes = { + "%": 14, + // comment character + "~": 13 // active character + }; + } + setCatcode(char, code) { + this.catcodes[char] = code; + } + /** + * This function lexes a single token. + */ + lex() { + var input = this.input; + var pos = this.tokenRegex.lastIndex; + if (pos === input.length) { + return new Token("EOF", new SourceLocation(this, pos, pos)); + } + var match = this.tokenRegex.exec(input); + if (match === null || match.index !== pos) { + throw new ParseError("Unexpected character: '" + input[pos] + "'", new Token(input[pos], new SourceLocation(this, pos, pos + 1))); + } + var text = match[6] || match[3] || (match[2] ? "\\ " : " "); + if (this.catcodes[text] === 14) { + // comment character + var nlIndex = input.indexOf('\n', this.tokenRegex.lastIndex); + if (nlIndex === -1) { + this.tokenRegex.lastIndex = input.length; // EOF + this.settings.reportNonstrict("commentAtEnd", "% comment has no terminating newline; LaTeX would " + "fail because of commenting the end of math mode (e.g. $)"); + } else { + this.tokenRegex.lastIndex = nlIndex + 1; + } + return this.lex(); + } + return new Token(text, new SourceLocation(this, pos, this.tokenRegex.lastIndex)); + } +} + +/** + * A `Namespace` refers to a space of nameable things like macros or lengths, + * which can be `set` either globally or local to a nested group, using an + * undo stack similar to how TeX implements this functionality. + * Performance-wise, `get` and local `set` take constant time, while global + * `set` takes time proportional to the depth of group nesting. + */ +class Namespace { + /** + * Both arguments are optional. The first argument is an object of + * built-in mappings which never change. The second argument is an object + * of initial (global-level) mappings, which will constantly change + * according to any global/top-level `set`s done. + */ + constructor(builtins, globalMacros) { + if (builtins === void 0) { + builtins = {}; + } + if (globalMacros === void 0) { + globalMacros = {}; + } + this.current = void 0; + this.builtins = void 0; + this.undefStack = void 0; + this.current = globalMacros; + this.builtins = builtins; + this.undefStack = []; + } + /** + * Start a new nested group, affecting future local `set`s. + */ + beginGroup() { + this.undefStack.push({}); + } + /** + * End current nested group, restoring values before the group began. + */ + endGroup() { + if (this.undefStack.length === 0) { + throw new ParseError("Unbalanced namespace destruction: attempt " + "to pop global namespace; please report this as a bug"); + } + var undefs = this.undefStack.pop(); + for (var undef in undefs) { + if (undefs.hasOwnProperty(undef)) { + if (undefs[undef] == null) { + delete this.current[undef]; + } else { + this.current[undef] = undefs[undef]; + } + } + } + } + /** + * Ends all currently nested groups (if any), restoring values before the + * groups began. Useful in case of an error in the middle of parsing. + */ + endGroups() { + while (this.undefStack.length > 0) { + this.endGroup(); + } + } + /** + * Detect whether `name` has a definition. Equivalent to + * `get(name) != null`. + */ + has(name) { + return this.current.hasOwnProperty(name) || this.builtins.hasOwnProperty(name); + } + /** + * Get the current value of a name, or `undefined` if there is no value. + * + * Note: Do not use `if (namespace.get(...))` to detect whether a macro + * is defined, as the definition may be the empty string which evaluates + * to `false` in JavaScript. Use `if (namespace.get(...) != null)` or + * `if (namespace.has(...))`. + */ + get(name) { + if (this.current.hasOwnProperty(name)) { + return this.current[name]; + } else { + return this.builtins[name]; + } + } + /** + * Set the current value of a name, and optionally set it globally too. + * Local set() sets the current value and (when appropriate) adds an undo + * operation to the undo stack. Global set() may change the undo + * operation at every level, so takes time linear in their number. + * A value of undefined means to delete existing definitions. + */ + set(name, value, global) { + if (global === void 0) { + global = false; + } + if (global) { + // Global set is equivalent to setting in all groups. Simulate this + // by destroying any undos currently scheduled for this name, + // and adding an undo with the *new* value (in case it later gets + // locally reset within this environment). + for (var i = 0; i < this.undefStack.length; i++) { + delete this.undefStack[i][name]; + } + if (this.undefStack.length > 0) { + this.undefStack[this.undefStack.length - 1][name] = value; + } + } else { + // Undo this set at end of this group (possibly to `undefined`), + // unless an undo is already in place, in which case that older + // value is the correct one. + var top = this.undefStack[this.undefStack.length - 1]; + if (top && !top.hasOwnProperty(name)) { + top[name] = this.current[name]; + } + } + if (value == null) { + delete this.current[name]; + } else { + this.current[name] = value; + } + } +} + +/** + * Predefined macros for KaTeX. + * This can be used to define some commands in terms of others. + */ +var macros = _macros; +////////////////////////////////////////////////////////////////////// +// macro tools +defineMacro("\\noexpand", function (context) { + // The expansion is the token itself; but that token is interpreted + // as if its meaning were ‘\relax’ if it is a control sequence that + // would ordinarily be expanded by TeX’s expansion rules. + var t = context.popToken(); + if (context.isExpandable(t.text)) { + t.noexpand = true; + t.treatAsRelax = true; + } + return { + tokens: [t], + numArgs: 0 + }; +}); +defineMacro("\\expandafter", function (context) { + // TeX first reads the token that comes immediately after \expandafter, + // without expanding it; let’s call this token t. Then TeX reads the + // token that comes after t (and possibly more tokens, if that token + // has an argument), replacing it by its expansion. Finally TeX puts + // t back in front of that expansion. + var t = context.popToken(); + context.expandOnce(true); // expand only an expandable token + return { + tokens: [t], + numArgs: 0 + }; +}); +// LaTeX's \@firstoftwo{#1}{#2} expands to #1, skipping #2 +// TeX source: \long\def\@firstoftwo#1#2{#1} +defineMacro("\\@firstoftwo", function (context) { + var args = context.consumeArgs(2); + return { + tokens: args[0], + numArgs: 0 + }; +}); +// LaTeX's \@secondoftwo{#1}{#2} expands to #2, skipping #1 +// TeX source: \long\def\@secondoftwo#1#2{#2} +defineMacro("\\@secondoftwo", function (context) { + var args = context.consumeArgs(2); + return { + tokens: args[1], + numArgs: 0 + }; +}); +// LaTeX's \@ifnextchar{#1}{#2}{#3} looks ahead to the next (unexpanded) +// symbol that isn't a space, consuming any spaces but not consuming the +// first nonspace character. If that nonspace character matches #1, then +// the macro expands to #2; otherwise, it expands to #3. +defineMacro("\\@ifnextchar", function (context) { + var args = context.consumeArgs(3); // symbol, if, else + context.consumeSpaces(); + var nextToken = context.future(); + if (args[0].length === 1 && args[0][0].text === nextToken.text) { + return { + tokens: args[1], + numArgs: 0 + }; + } else { + return { + tokens: args[2], + numArgs: 0 + }; + } +}); +// LaTeX's \@ifstar{#1}{#2} looks ahead to the next (unexpanded) symbol. +// If it is `*`, then it consumes the symbol, and the macro expands to #1; +// otherwise, the macro expands to #2 (without consuming the symbol). +// TeX source: \def\@ifstar#1{\@ifnextchar *{\@firstoftwo{#1}}} +defineMacro("\\@ifstar", "\\@ifnextchar *{\\@firstoftwo{#1}}"); +// LaTeX's \TextOrMath{#1}{#2} expands to #1 in text mode, #2 in math mode +defineMacro("\\TextOrMath", function (context) { + var args = context.consumeArgs(2); + if (context.mode === 'text') { + return { + tokens: args[0], + numArgs: 0 + }; + } else { + return { + tokens: args[1], + numArgs: 0 + }; + } +}); +// Lookup table for parsing numbers in base 8 through 16 +var digitToNumber = { + "0": 0, + "1": 1, + "2": 2, + "3": 3, + "4": 4, + "5": 5, + "6": 6, + "7": 7, + "8": 8, + "9": 9, + "a": 10, + "A": 10, + "b": 11, + "B": 11, + "c": 12, + "C": 12, + "d": 13, + "D": 13, + "e": 14, + "E": 14, + "f": 15, + "F": 15 +}; +// TeX \char makes a literal character (catcode 12) using the following forms: +// (see The TeXBook, p. 43) +// \char123 -- decimal +// \char'123 -- octal +// \char"123 -- hex +// \char`x -- character that can be written (i.e. isn't active) +// \char`\x -- character that cannot be written (e.g. %) +// These all refer to characters from the font, so we turn them into special +// calls to a function \@char dealt with in the Parser. +defineMacro("\\char", function (context) { + var token = context.popToken(); + var base; + var number = 0; + if (token.text === "'") { + base = 8; + token = context.popToken(); + } else if (token.text === '"') { + base = 16; + token = context.popToken(); + } else if (token.text === "`") { + token = context.popToken(); + if (token.text[0] === "\\") { + number = token.text.charCodeAt(1); + } else if (token.text === "EOF") { + throw new ParseError("\\char` missing argument"); + } else { + number = token.text.charCodeAt(0); + } + } else { + base = 10; + } + if (base) { + // Parse a number in the given base, starting with first `token`. + number = digitToNumber[token.text]; + if (number == null || number >= base) { + throw new ParseError("Invalid base-" + base + " digit " + token.text); + } + var digit; + while ((digit = digitToNumber[context.future().text]) != null && digit < base) { + number *= base; + number += digit; + context.popToken(); + } + } + return "\\@char{" + number + "}"; +}); +// \newcommand{\macro}[args]{definition} +// \renewcommand{\macro}[args]{definition} +// TODO: Optional arguments: \newcommand{\macro}[args][default]{definition} +var newcommand = (context, existsOK, nonexistsOK, skipIfExists) => { + var arg = context.consumeArg().tokens; + if (arg.length !== 1) { + throw new ParseError("\\newcommand's first argument must be a macro name"); + } + var name = arg[0].text; + var exists = context.isDefined(name); + if (exists && !existsOK) { + throw new ParseError("\\newcommand{" + name + "} attempting to redefine " + (name + "; use \\renewcommand")); + } + if (!exists && !nonexistsOK) { + throw new ParseError("\\renewcommand{" + name + "} when command " + name + " " + "does not yet exist; use \\newcommand"); + } + var numArgs = 0; + arg = context.consumeArg().tokens; + if (arg.length === 1 && arg[0].text === "[") { + var argText = ''; + var token = context.expandNextToken(); + while (token.text !== "]" && token.text !== "EOF") { + // TODO: Should properly expand arg, e.g., ignore {}s + argText += token.text; + token = context.expandNextToken(); + } + if (!argText.match(/^\s*[0-9]+\s*$/)) { + throw new ParseError("Invalid number of arguments: " + argText); + } + numArgs = parseInt(argText); + arg = context.consumeArg().tokens; + } + if (!(exists && skipIfExists)) { + // Final arg is the expansion of the macro + context.macros.set(name, { + tokens: arg, + numArgs + }); + } + return ''; +}; +defineMacro("\\newcommand", context => newcommand(context, false, true, false)); +defineMacro("\\renewcommand", context => newcommand(context, true, false, false)); +defineMacro("\\providecommand", context => newcommand(context, true, true, true)); +// terminal (console) tools +defineMacro("\\message", context => { + var arg = context.consumeArgs(1)[0]; + // eslint-disable-next-line no-console + console.log(arg.reverse().map(token => token.text).join("")); + return ''; +}); +defineMacro("\\errmessage", context => { + var arg = context.consumeArgs(1)[0]; + // eslint-disable-next-line no-console + console.error(arg.reverse().map(token => token.text).join("")); + return ''; +}); +defineMacro("\\show", context => { + var tok = context.popToken(); + var name = tok.text; + // eslint-disable-next-line no-console + console.log(tok, context.macros.get(name), functions[name], symbols.math[name], symbols.text[name]); + return ''; +}); +////////////////////////////////////////////////////////////////////// +// Grouping +// \let\bgroup={ \let\egroup=} +defineMacro("\\bgroup", "{"); +defineMacro("\\egroup", "}"); +// Symbols from latex.ltx: +// \def~{\nobreakspace{}} +// \def\lq{`} +// \def\rq{'} +// \def \aa {\r a} +// \def \AA {\r A} +defineMacro("~", "\\nobreakspace"); +defineMacro("\\lq", "`"); +defineMacro("\\rq", "'"); +defineMacro("\\aa", "\\r a"); +defineMacro("\\AA", "\\r A"); +// Copyright (C) and registered (R) symbols. Use raw symbol in MathML. +// \DeclareTextCommandDefault{\textcopyright}{\textcircled{c}} +// \DeclareTextCommandDefault{\textregistered}{\textcircled{% +// \check@mathfonts\fontsize\sf@size\z@\math@fontsfalse\selectfont R}} +// \DeclareRobustCommand{\copyright}{% +// \ifmmode{\nfss@text{\textcopyright}}\else\textcopyright\fi} +defineMacro("\\textcopyright", "\\html@mathml{\\textcircled{c}}{\\char`©}"); +defineMacro("\\copyright", "\\TextOrMath{\\textcopyright}{\\text{\\textcopyright}}"); +defineMacro("\\textregistered", "\\html@mathml{\\textcircled{\\scriptsize R}}{\\char`®}"); +// Characters omitted from Unicode range 1D400–1D7FF +defineMacro("\u212C", "\\mathscr{B}"); // script +defineMacro("\u2130", "\\mathscr{E}"); +defineMacro("\u2131", "\\mathscr{F}"); +defineMacro("\u210B", "\\mathscr{H}"); +defineMacro("\u2110", "\\mathscr{I}"); +defineMacro("\u2112", "\\mathscr{L}"); +defineMacro("\u2133", "\\mathscr{M}"); +defineMacro("\u211B", "\\mathscr{R}"); +defineMacro("\u212D", "\\mathfrak{C}"); // Fraktur +defineMacro("\u210C", "\\mathfrak{H}"); +defineMacro("\u2128", "\\mathfrak{Z}"); +// Define \Bbbk with a macro that works in both HTML and MathML. +defineMacro("\\Bbbk", "\\Bbb{k}"); +// \llap and \rlap render their contents in text mode +defineMacro("\\llap", "\\mathllap{\\textrm{#1}}"); +defineMacro("\\rlap", "\\mathrlap{\\textrm{#1}}"); +defineMacro("\\clap", "\\mathclap{\\textrm{#1}}"); +// \mathstrut from the TeXbook, p 360 +defineMacro("\\mathstrut", "\\vphantom{(}"); +// \underbar from TeXbook p 353 +defineMacro("\\underbar", "\\underline{\\text{#1}}"); +// \not is defined by base/fontmath.ltx via +// \DeclareMathSymbol{\not}{\mathrel}{symbols}{"36} +// It's thus treated like a \mathrel, but defined by a symbol that has zero +// width but extends to the right. We use \rlap to get that spacing. +// For MathML we write U+0338 here. buildMathML.js will then do the overlay. +defineMacro("\\not", "\\html@mathml{\\mathrel{\\mathrlap\\@not}\\nobreak}" + "{\\char\"338}"); +// Negated symbols from base/fontmath.ltx: +// \def\neq{\not=} \let\ne=\neq +// \DeclareRobustCommand +// \notin{\mathrel{\m@th\mathpalette\c@ncel\in}} +// \def\c@ncel#1#2{\m@th\ooalign{$\hfil#1\mkern1mu/\hfil$\crcr$#1#2$}} +defineMacro("\\neq", "\\html@mathml{\\mathrel{\\not=}}{\\mathrel{\\char`≠}}"); +defineMacro("\\ne", "\\neq"); +defineMacro("\u2260", "\\neq"); +defineMacro("\\notin", "\\html@mathml{\\mathrel{{\\in}\\mathllap{/\\mskip1mu}}}" + "{\\mathrel{\\char`∉}}"); +defineMacro("\u2209", "\\notin"); +// Unicode stacked relations +defineMacro("\u2258", "\\html@mathml{" + "\\mathrel{=\\kern{-1em}\\raisebox{0.4em}{$\\scriptsize\\frown$}}" + "}{\\mathrel{\\char`\u2258}}"); +defineMacro("\u2259", "\\html@mathml{\\stackrel{\\tiny\\wedge}{=}}{\\mathrel{\\char`\u2258}}"); +defineMacro("\u225A", "\\html@mathml{\\stackrel{\\tiny\\vee}{=}}{\\mathrel{\\char`\u225A}}"); +defineMacro("\u225B", "\\html@mathml{\\stackrel{\\scriptsize\\star}{=}}" + "{\\mathrel{\\char`\u225B}}"); +defineMacro("\u225D", "\\html@mathml{\\stackrel{\\tiny\\mathrm{def}}{=}}" + "{\\mathrel{\\char`\u225D}}"); +defineMacro("\u225E", "\\html@mathml{\\stackrel{\\tiny\\mathrm{m}}{=}}" + "{\\mathrel{\\char`\u225E}}"); +defineMacro("\u225F", "\\html@mathml{\\stackrel{\\tiny?}{=}}{\\mathrel{\\char`\u225F}}"); +// Misc Unicode +defineMacro("\u27C2", "\\perp"); +defineMacro("\u203C", "\\mathclose{!\\mkern-0.8mu!}"); +defineMacro("\u220C", "\\notni"); +defineMacro("\u231C", "\\ulcorner"); +defineMacro("\u231D", "\\urcorner"); +defineMacro("\u231E", "\\llcorner"); +defineMacro("\u231F", "\\lrcorner"); +defineMacro("\u00A9", "\\copyright"); +defineMacro("\u00AE", "\\textregistered"); +// The KaTeX fonts have corners at codepoints that don't match Unicode. +// For MathML purposes, use the Unicode code point. +defineMacro("\\ulcorner", "\\html@mathml{\\@ulcorner}{\\mathop{\\char\"231c}}"); +defineMacro("\\urcorner", "\\html@mathml{\\@urcorner}{\\mathop{\\char\"231d}}"); +defineMacro("\\llcorner", "\\html@mathml{\\@llcorner}{\\mathop{\\char\"231e}}"); +defineMacro("\\lrcorner", "\\html@mathml{\\@lrcorner}{\\mathop{\\char\"231f}}"); +////////////////////////////////////////////////////////////////////// +// LaTeX_2ε +// \vdots{\vbox{\baselineskip4\p@ \lineskiplimit\z@ +// \kern6\p@\hbox{.}\hbox{.}\hbox{.}}} +// We'll call \varvdots, which gets a glyph from symbols.js. +// The zero-width rule gets us an equivalent to the vertical 6pt kern. +defineMacro("\\vdots", "{\\varvdots\\rule{0pt}{15pt}}"); +defineMacro("\u22ee", "\\vdots"); +////////////////////////////////////////////////////////////////////// +// amsmath.sty +// http://mirrors.concertpass.com/tex-archive/macros/latex/required/amsmath/amsmath.pdf +// Italic Greek capital letters. AMS defines these with \DeclareMathSymbol, +// but they are equivalent to \mathit{\Letter}. +defineMacro("\\varGamma", "\\mathit{\\Gamma}"); +defineMacro("\\varDelta", "\\mathit{\\Delta}"); +defineMacro("\\varTheta", "\\mathit{\\Theta}"); +defineMacro("\\varLambda", "\\mathit{\\Lambda}"); +defineMacro("\\varXi", "\\mathit{\\Xi}"); +defineMacro("\\varPi", "\\mathit{\\Pi}"); +defineMacro("\\varSigma", "\\mathit{\\Sigma}"); +defineMacro("\\varUpsilon", "\\mathit{\\Upsilon}"); +defineMacro("\\varPhi", "\\mathit{\\Phi}"); +defineMacro("\\varPsi", "\\mathit{\\Psi}"); +defineMacro("\\varOmega", "\\mathit{\\Omega}"); +//\newcommand{\substack}[1]{\subarray{c}#1\endsubarray} +defineMacro("\\substack", "\\begin{subarray}{c}#1\\end{subarray}"); +// \renewcommand{\colon}{\nobreak\mskip2mu\mathpunct{}\nonscript +// \mkern-\thinmuskip{:}\mskip6muplus1mu\relax} +defineMacro("\\colon", "\\nobreak\\mskip2mu\\mathpunct{}" + "\\mathchoice{\\mkern-3mu}{\\mkern-3mu}{}{}{:}\\mskip6mu\\relax"); +// \newcommand{\boxed}[1]{\fbox{\m@th$\displaystyle#1$}} +defineMacro("\\boxed", "\\fbox{$\\displaystyle{#1}$}"); +// \def\iff{\DOTSB\;\Longleftrightarrow\;} +// \def\implies{\DOTSB\;\Longrightarrow\;} +// \def\impliedby{\DOTSB\;\Longleftarrow\;} +defineMacro("\\iff", "\\DOTSB\\;\\Longleftrightarrow\\;"); +defineMacro("\\implies", "\\DOTSB\\;\\Longrightarrow\\;"); +defineMacro("\\impliedby", "\\DOTSB\\;\\Longleftarrow\\;"); +// \def\dddot#1{{\mathop{#1}\limits^{\vbox to-1.4\ex@{\kern-\tw@\ex@ +// \hbox{\normalfont ...}\vss}}}} +// We use \overset which avoids the vertical shift of \mathop. +defineMacro("\\dddot", "{\\overset{\\raisebox{-0.1ex}{\\normalsize ...}}{#1}}"); +defineMacro("\\ddddot", "{\\overset{\\raisebox{-0.1ex}{\\normalsize ....}}{#1}}"); +// AMSMath's automatic \dots, based on \mdots@@ macro. +var dotsByToken = { + ',': '\\dotsc', + '\\not': '\\dotsb', + // \keybin@ checks for the following: + '+': '\\dotsb', + '=': '\\dotsb', + '<': '\\dotsb', + '>': '\\dotsb', + '-': '\\dotsb', + '*': '\\dotsb', + ':': '\\dotsb', + // Symbols whose definition starts with \DOTSB: + '\\DOTSB': '\\dotsb', + '\\coprod': '\\dotsb', + '\\bigvee': '\\dotsb', + '\\bigwedge': '\\dotsb', + '\\biguplus': '\\dotsb', + '\\bigcap': '\\dotsb', + '\\bigcup': '\\dotsb', + '\\prod': '\\dotsb', + '\\sum': '\\dotsb', + '\\bigotimes': '\\dotsb', + '\\bigoplus': '\\dotsb', + '\\bigodot': '\\dotsb', + '\\bigsqcup': '\\dotsb', + '\\And': '\\dotsb', + '\\longrightarrow': '\\dotsb', + '\\Longrightarrow': '\\dotsb', + '\\longleftarrow': '\\dotsb', + '\\Longleftarrow': '\\dotsb', + '\\longleftrightarrow': '\\dotsb', + '\\Longleftrightarrow': '\\dotsb', + '\\mapsto': '\\dotsb', + '\\longmapsto': '\\dotsb', + '\\hookrightarrow': '\\dotsb', + '\\doteq': '\\dotsb', + // Symbols whose definition starts with \mathbin: + '\\mathbin': '\\dotsb', + // Symbols whose definition starts with \mathrel: + '\\mathrel': '\\dotsb', + '\\relbar': '\\dotsb', + '\\Relbar': '\\dotsb', + '\\xrightarrow': '\\dotsb', + '\\xleftarrow': '\\dotsb', + // Symbols whose definition starts with \DOTSI: + '\\DOTSI': '\\dotsi', + '\\int': '\\dotsi', + '\\oint': '\\dotsi', + '\\iint': '\\dotsi', + '\\iiint': '\\dotsi', + '\\iiiint': '\\dotsi', + '\\idotsint': '\\dotsi', + // Symbols whose definition starts with \DOTSX: + '\\DOTSX': '\\dotsx' +}; +var dotsbGroups = new Set(['bin', 'rel']); +defineMacro("\\dots", function (context) { + // TODO: If used in text mode, should expand to \textellipsis. + // However, in KaTeX, \textellipsis and \ldots behave the same + // (in text mode), and it's unlikely we'd see any of the math commands + // that affect the behavior of \dots when in text mode. So fine for now + // (until we support \ifmmode ... \else ... \fi). + var thedots = '\\dotso'; + var next = context.expandAfterFuture().text; + if (next in dotsByToken) { + thedots = dotsByToken[next]; + } else if (next.slice(0, 4) === '\\not') { + thedots = '\\dotsb'; + } else if (next in symbols.math) { + if (dotsbGroups.has(symbols.math[next].group)) { + thedots = '\\dotsb'; + } + } + return thedots; +}); +var spaceAfterDots = { + // \rightdelim@ checks for the following: + ')': true, + ']': true, + '\\rbrack': true, + '\\}': true, + '\\rbrace': true, + '\\rangle': true, + '\\rceil': true, + '\\rfloor': true, + '\\rgroup': true, + '\\rmoustache': true, + '\\right': true, + '\\bigr': true, + '\\biggr': true, + '\\Bigr': true, + '\\Biggr': true, + // \extra@ also tests for the following: + '$': true, + // \extrap@ checks for the following: + ';': true, + '.': true, + ',': true +}; +defineMacro("\\dotso", function (context) { + var next = context.future().text; + if (next in spaceAfterDots) { + return "\\ldots\\,"; + } else { + return "\\ldots"; + } +}); +defineMacro("\\dotsc", function (context) { + var next = context.future().text; + // \dotsc uses \extra@ but not \extrap@, instead specially checking for + // ';' and '.', but doesn't check for ','. + if (next in spaceAfterDots && next !== ',') { + return "\\ldots\\,"; + } else { + return "\\ldots"; + } +}); +defineMacro("\\cdots", function (context) { + var next = context.future().text; + if (next in spaceAfterDots) { + return "\\@cdots\\,"; + } else { + return "\\@cdots"; + } +}); +defineMacro("\\dotsb", "\\cdots"); +defineMacro("\\dotsm", "\\cdots"); +defineMacro("\\dotsi", "\\!\\cdots"); +// amsmath doesn't actually define \dotsx, but \dots followed by a macro +// starting with \DOTSX implies \dotso, and then \extra@ detects this case +// and forces the added `\,`. +defineMacro("\\dotsx", "\\ldots\\,"); +// \let\DOTSI\relax +// \let\DOTSB\relax +// \let\DOTSX\relax +defineMacro("\\DOTSI", "\\relax"); +defineMacro("\\DOTSB", "\\relax"); +defineMacro("\\DOTSX", "\\relax"); +// Spacing, based on amsmath.sty's override of LaTeX defaults +// \DeclareRobustCommand{\tmspace}[3]{% +// \ifmmode\mskip#1#2\else\kern#1#3\fi\relax} +defineMacro("\\tmspace", "\\TextOrMath{\\kern#1#3}{\\mskip#1#2}\\relax"); +// \renewcommand{\,}{\tmspace+\thinmuskip{.1667em}} +// TODO: math mode should use \thinmuskip +defineMacro("\\,", "\\tmspace+{3mu}{.1667em}"); +// \let\thinspace\, +defineMacro("\\thinspace", "\\,"); +// \def\>{\mskip\medmuskip} +// \renewcommand{\:}{\tmspace+\medmuskip{.2222em}} +// TODO: \> and math mode of \: should use \medmuskip = 4mu plus 2mu minus 4mu +defineMacro("\\>", "\\mskip{4mu}"); +defineMacro("\\:", "\\tmspace+{4mu}{.2222em}"); +// \let\medspace\: +defineMacro("\\medspace", "\\:"); +// \renewcommand{\;}{\tmspace+\thickmuskip{.2777em}} +// TODO: math mode should use \thickmuskip = 5mu plus 5mu +defineMacro("\\;", "\\tmspace+{5mu}{.2777em}"); +// \let\thickspace\; +defineMacro("\\thickspace", "\\;"); +// \renewcommand{\!}{\tmspace-\thinmuskip{.1667em}} +// TODO: math mode should use \thinmuskip +defineMacro("\\!", "\\tmspace-{3mu}{.1667em}"); +// \let\negthinspace\! +defineMacro("\\negthinspace", "\\!"); +// \newcommand{\negmedspace}{\tmspace-\medmuskip{.2222em}} +// TODO: math mode should use \medmuskip +defineMacro("\\negmedspace", "\\tmspace-{4mu}{.2222em}"); +// \newcommand{\negthickspace}{\tmspace-\thickmuskip{.2777em}} +// TODO: math mode should use \thickmuskip +defineMacro("\\negthickspace", "\\tmspace-{5mu}{.277em}"); +// \def\enspace{\kern.5em } +defineMacro("\\enspace", "\\kern.5em "); +// \def\enskip{\hskip.5em\relax} +defineMacro("\\enskip", "\\hskip.5em\\relax"); +// \def\quad{\hskip1em\relax} +defineMacro("\\quad", "\\hskip1em\\relax"); +// \def\qquad{\hskip2em\relax} +defineMacro("\\qquad", "\\hskip2em\\relax"); +// \tag@in@display form of \tag +defineMacro("\\tag", "\\@ifstar\\tag@literal\\tag@paren"); +defineMacro("\\tag@paren", "\\tag@literal{({#1})}"); +defineMacro("\\tag@literal", context => { + if (context.macros.get("\\df@tag")) { + throw new ParseError("Multiple \\tag"); + } + return "\\gdef\\df@tag{\\text{#1}}"; +}); +// \renewcommand{\bmod}{\nonscript\mskip-\medmuskip\mkern5mu\mathbin +// {\operator@font mod}\penalty900 +// \mkern5mu\nonscript\mskip-\medmuskip} +// \newcommand{\pod}[1]{\allowbreak +// \if@display\mkern18mu\else\mkern8mu\fi(#1)} +// \renewcommand{\pmod}[1]{\pod{{\operator@font mod}\mkern6mu#1}} +// \newcommand{\mod}[1]{\allowbreak\if@display\mkern18mu +// \else\mkern12mu\fi{\operator@font mod}\,\,#1} +// TODO: math mode should use \medmuskip = 4mu plus 2mu minus 4mu +defineMacro("\\bmod", "\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}" + "\\mathbin{\\rm mod}" + "\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}"); +defineMacro("\\pod", "\\allowbreak" + "\\mathchoice{\\mkern18mu}{\\mkern8mu}{\\mkern8mu}{\\mkern8mu}(#1)"); +defineMacro("\\pmod", "\\pod{{\\rm mod}\\mkern6mu#1}"); +defineMacro("\\mod", "\\allowbreak" + "\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}" + "{\\rm mod}\\,\\,#1"); +////////////////////////////////////////////////////////////////////// +// LaTeX source2e +// \expandafter\let\expandafter\@normalcr +// \csname\expandafter\@gobble\string\\ \endcsname +// \DeclareRobustCommand\newline{\@normalcr\relax} +defineMacro("\\newline", "\\\\\\relax"); +// \def\TeX{T\kern-.1667em\lower.5ex\hbox{E}\kern-.125emX\@} +// TODO: Doesn't normally work in math mode because \@ fails. KaTeX doesn't +// support \@ yet, so that's omitted, and we add \text so that the result +// doesn't look funny in math mode. +defineMacro("\\TeX", "\\textrm{\\html@mathml{" + "T\\kern-.1667em\\raisebox{-.5ex}{E}\\kern-.125emX" + "}{TeX}}"); +// \DeclareRobustCommand{\LaTeX}{L\kern-.36em% +// {\sbox\z@ T% +// \vbox to\ht\z@{\hbox{\check@mathfonts +// \fontsize\sf@size\z@ +// \math@fontsfalse\selectfont +// A}% +// \vss}% +// }% +// \kern-.15em% +// \TeX} +// This code aligns the top of the A with the T (from the perspective of TeX's +// boxes, though visually the A appears to extend above slightly). +// We compute the corresponding \raisebox when A is rendered in \normalsize +// \scriptstyle, which has a scale factor of 0.7 (see Options.js). +var latexRaiseA = makeEm(fontMetricsData['Main-Regular']["T".charCodeAt(0)][1] - 0.7 * fontMetricsData['Main-Regular']["A".charCodeAt(0)][1]); +defineMacro("\\LaTeX", "\\textrm{\\html@mathml{" + ("L\\kern-.36em\\raisebox{" + latexRaiseA + "}{\\scriptstyle A}") + "\\kern-.15em\\TeX}{LaTeX}}"); +// New KaTeX logo based on tweaking LaTeX logo +defineMacro("\\KaTeX", "\\textrm{\\html@mathml{" + ("K\\kern-.17em\\raisebox{" + latexRaiseA + "}{\\scriptstyle A}") + "\\kern-.15em\\TeX}{KaTeX}}"); +// \DeclareRobustCommand\hspace{\@ifstar\@hspacer\@hspace} +// \def\@hspace#1{\hskip #1\relax} +// \def\@hspacer#1{\vrule \@width\z@\nobreak +// \hskip #1\hskip \z@skip} +defineMacro("\\hspace", "\\@ifstar\\@hspacer\\@hspace"); +defineMacro("\\@hspace", "\\hskip #1\\relax"); +defineMacro("\\@hspacer", "\\rule{0pt}{0pt}\\hskip #1\\relax"); +////////////////////////////////////////////////////////////////////// +// mathtools.sty +//\providecommand\ordinarycolon{:} +defineMacro("\\ordinarycolon", ":"); +//\def\vcentcolon{\mathrel{\mathop\ordinarycolon}} +//TODO(edemaine): Not yet centered. Fix via \raisebox or #726 +defineMacro("\\vcentcolon", "\\mathrel{\\mathop\\ordinarycolon}"); +// \providecommand*\dblcolon{\vcentcolon\mathrel{\mkern-.9mu}\vcentcolon} +defineMacro("\\dblcolon", "\\html@mathml{" + "\\mathrel{\\vcentcolon\\mathrel{\\mkern-.9mu}\\vcentcolon}}" + "{\\mathop{\\char\"2237}}"); +// \providecommand*\coloneqq{\vcentcolon\mathrel{\mkern-1.2mu}=} +defineMacro("\\coloneqq", "\\html@mathml{" + "\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}=}}" + "{\\mathop{\\char\"2254}}"); // ≔ +// \providecommand*\Coloneqq{\dblcolon\mathrel{\mkern-1.2mu}=} +defineMacro("\\Coloneqq", "\\html@mathml{" + "\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}=}}" + "{\\mathop{\\char\"2237\\char\"3d}}"); +// \providecommand*\coloneq{\vcentcolon\mathrel{\mkern-1.2mu}\mathrel{-}} +defineMacro("\\coloneq", "\\html@mathml{" + "\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}" + "{\\mathop{\\char\"3a\\char\"2212}}"); +// \providecommand*\Coloneq{\dblcolon\mathrel{\mkern-1.2mu}\mathrel{-}} +defineMacro("\\Coloneq", "\\html@mathml{" + "\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}" + "{\\mathop{\\char\"2237\\char\"2212}}"); +// \providecommand*\eqqcolon{=\mathrel{\mkern-1.2mu}\vcentcolon} +defineMacro("\\eqqcolon", "\\html@mathml{" + "\\mathrel{=\\mathrel{\\mkern-1.2mu}\\vcentcolon}}" + "{\\mathop{\\char\"2255}}"); // ≕ +// \providecommand*\Eqqcolon{=\mathrel{\mkern-1.2mu}\dblcolon} +defineMacro("\\Eqqcolon", "\\html@mathml{" + "\\mathrel{=\\mathrel{\\mkern-1.2mu}\\dblcolon}}" + "{\\mathop{\\char\"3d\\char\"2237}}"); +// \providecommand*\eqcolon{\mathrel{-}\mathrel{\mkern-1.2mu}\vcentcolon} +defineMacro("\\eqcolon", "\\html@mathml{" + "\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\vcentcolon}}" + "{\\mathop{\\char\"2239}}"); +// \providecommand*\Eqcolon{\mathrel{-}\mathrel{\mkern-1.2mu}\dblcolon} +defineMacro("\\Eqcolon", "\\html@mathml{" + "\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\dblcolon}}" + "{\\mathop{\\char\"2212\\char\"2237}}"); +// \providecommand*\colonapprox{\vcentcolon\mathrel{\mkern-1.2mu}\approx} +defineMacro("\\colonapprox", "\\html@mathml{" + "\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\approx}}" + "{\\mathop{\\char\"3a\\char\"2248}}"); +// \providecommand*\Colonapprox{\dblcolon\mathrel{\mkern-1.2mu}\approx} +defineMacro("\\Colonapprox", "\\html@mathml{" + "\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\approx}}" + "{\\mathop{\\char\"2237\\char\"2248}}"); +// \providecommand*\colonsim{\vcentcolon\mathrel{\mkern-1.2mu}\sim} +defineMacro("\\colonsim", "\\html@mathml{" + "\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\sim}}" + "{\\mathop{\\char\"3a\\char\"223c}}"); +// \providecommand*\Colonsim{\dblcolon\mathrel{\mkern-1.2mu}\sim} +defineMacro("\\Colonsim", "\\html@mathml{" + "\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\sim}}" + "{\\mathop{\\char\"2237\\char\"223c}}"); +// Some Unicode characters are implemented with macros to mathtools functions. +defineMacro("\u2237", "\\dblcolon"); // :: +defineMacro("\u2239", "\\eqcolon"); // -: +defineMacro("\u2254", "\\coloneqq"); // := +defineMacro("\u2255", "\\eqqcolon"); // =: +defineMacro("\u2A74", "\\Coloneqq"); // ::= +////////////////////////////////////////////////////////////////////// +// colonequals.sty +// Alternate names for mathtools's macros: +defineMacro("\\ratio", "\\vcentcolon"); +defineMacro("\\coloncolon", "\\dblcolon"); +defineMacro("\\colonequals", "\\coloneqq"); +defineMacro("\\coloncolonequals", "\\Coloneqq"); +defineMacro("\\equalscolon", "\\eqqcolon"); +defineMacro("\\equalscoloncolon", "\\Eqqcolon"); +defineMacro("\\colonminus", "\\coloneq"); +defineMacro("\\coloncolonminus", "\\Coloneq"); +defineMacro("\\minuscolon", "\\eqcolon"); +defineMacro("\\minuscoloncolon", "\\Eqcolon"); +// \colonapprox name is same in mathtools and colonequals. +defineMacro("\\coloncolonapprox", "\\Colonapprox"); +// \colonsim name is same in mathtools and colonequals. +defineMacro("\\coloncolonsim", "\\Colonsim"); +// Additional macros, implemented by analogy with mathtools definitions: +defineMacro("\\simcolon", "\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\vcentcolon}"); +defineMacro("\\simcoloncolon", "\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\dblcolon}"); +defineMacro("\\approxcolon", "\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\vcentcolon}"); +defineMacro("\\approxcoloncolon", "\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\dblcolon}"); +// Present in newtxmath, pxfonts and txfonts +defineMacro("\\notni", "\\html@mathml{\\not\\ni}{\\mathrel{\\char`\u220C}}"); +defineMacro("\\limsup", "\\DOTSB\\operatorname*{lim\\,sup}"); +defineMacro("\\liminf", "\\DOTSB\\operatorname*{lim\\,inf}"); +////////////////////////////////////////////////////////////////////// +// From amsopn.sty +defineMacro("\\injlim", "\\DOTSB\\operatorname*{inj\\,lim}"); +defineMacro("\\projlim", "\\DOTSB\\operatorname*{proj\\,lim}"); +defineMacro("\\varlimsup", "\\DOTSB\\operatorname*{\\overline{lim}}"); +defineMacro("\\varliminf", "\\DOTSB\\operatorname*{\\underline{lim}}"); +defineMacro("\\varinjlim", "\\DOTSB\\operatorname*{\\underrightarrow{lim}}"); +defineMacro("\\varprojlim", "\\DOTSB\\operatorname*{\\underleftarrow{lim}}"); +////////////////////////////////////////////////////////////////////// +// MathML alternates for KaTeX glyphs in the Unicode private area +defineMacro("\\gvertneqq", "\\html@mathml{\\@gvertneqq}{\u2269}"); +defineMacro("\\lvertneqq", "\\html@mathml{\\@lvertneqq}{\u2268}"); +defineMacro("\\ngeqq", "\\html@mathml{\\@ngeqq}{\u2271}"); +defineMacro("\\ngeqslant", "\\html@mathml{\\@ngeqslant}{\u2271}"); +defineMacro("\\nleqq", "\\html@mathml{\\@nleqq}{\u2270}"); +defineMacro("\\nleqslant", "\\html@mathml{\\@nleqslant}{\u2270}"); +defineMacro("\\nshortmid", "\\html@mathml{\\@nshortmid}{∤}"); +defineMacro("\\nshortparallel", "\\html@mathml{\\@nshortparallel}{∦}"); +defineMacro("\\nsubseteqq", "\\html@mathml{\\@nsubseteqq}{\u2288}"); +defineMacro("\\nsupseteqq", "\\html@mathml{\\@nsupseteqq}{\u2289}"); +defineMacro("\\varsubsetneq", "\\html@mathml{\\@varsubsetneq}{⊊}"); +defineMacro("\\varsubsetneqq", "\\html@mathml{\\@varsubsetneqq}{⫋}"); +defineMacro("\\varsupsetneq", "\\html@mathml{\\@varsupsetneq}{⊋}"); +defineMacro("\\varsupsetneqq", "\\html@mathml{\\@varsupsetneqq}{⫌}"); +defineMacro("\\imath", "\\html@mathml{\\@imath}{\u0131}"); +defineMacro("\\jmath", "\\html@mathml{\\@jmath}{\u0237}"); +////////////////////////////////////////////////////////////////////// +// stmaryrd and semantic +// The stmaryrd and semantic packages render the next four items by calling a +// glyph. Those glyphs do not exist in the KaTeX fonts. Hence the macros. +defineMacro("\\llbracket", "\\html@mathml{" + "\\mathopen{[\\mkern-3.2mu[}}" + "{\\mathopen{\\char`\u27e6}}"); +defineMacro("\\rrbracket", "\\html@mathml{" + "\\mathclose{]\\mkern-3.2mu]}}" + "{\\mathclose{\\char`\u27e7}}"); +defineMacro("\u27e6", "\\llbracket"); // blackboard bold [ +defineMacro("\u27e7", "\\rrbracket"); // blackboard bold ] +defineMacro("\\lBrace", "\\html@mathml{" + "\\mathopen{\\{\\mkern-3.2mu[}}" + "{\\mathopen{\\char`\u2983}}"); +defineMacro("\\rBrace", "\\html@mathml{" + "\\mathclose{]\\mkern-3.2mu\\}}}" + "{\\mathclose{\\char`\u2984}}"); +defineMacro("\u2983", "\\lBrace"); // blackboard bold { +defineMacro("\u2984", "\\rBrace"); // blackboard bold } +// TODO: Create variable sized versions of the last two items. I believe that +// will require new font glyphs. +// The stmaryrd function `\minuso` provides a "Plimsoll" symbol that +// superimposes the characters \circ and \mathminus. Used in chemistry. +defineMacro("\\minuso", "\\mathbin{\\html@mathml{" + "{\\mathrlap{\\mathchoice{\\kern{0.145em}}{\\kern{0.145em}}" + "{\\kern{0.1015em}}{\\kern{0.0725em}}\\circ}{-}}}" + "{\\char`⦵}}"); +defineMacro("⦵", "\\minuso"); +////////////////////////////////////////////////////////////////////// +// texvc.sty +// The texvc package contains macros available in mediawiki pages. +// We omit the functions deprecated at +// https://en.wikipedia.org/wiki/Help:Displaying_a_formula#Deprecated_syntax +// We also omit texvc's \O, which conflicts with \text{\O} +defineMacro("\\darr", "\\downarrow"); +defineMacro("\\dArr", "\\Downarrow"); +defineMacro("\\Darr", "\\Downarrow"); +defineMacro("\\lang", "\\langle"); +defineMacro("\\rang", "\\rangle"); +defineMacro("\\uarr", "\\uparrow"); +defineMacro("\\uArr", "\\Uparrow"); +defineMacro("\\Uarr", "\\Uparrow"); +defineMacro("\\N", "\\mathbb{N}"); +defineMacro("\\R", "\\mathbb{R}"); +defineMacro("\\Z", "\\mathbb{Z}"); +defineMacro("\\alef", "\\aleph"); +defineMacro("\\alefsym", "\\aleph"); +defineMacro("\\Alpha", "\\mathrm{A}"); +defineMacro("\\Beta", "\\mathrm{B}"); +defineMacro("\\bull", "\\bullet"); +defineMacro("\\Chi", "\\mathrm{X}"); +defineMacro("\\clubs", "\\clubsuit"); +defineMacro("\\cnums", "\\mathbb{C}"); +defineMacro("\\Complex", "\\mathbb{C}"); +defineMacro("\\Dagger", "\\ddagger"); +defineMacro("\\diamonds", "\\diamondsuit"); +defineMacro("\\empty", "\\emptyset"); +defineMacro("\\Epsilon", "\\mathrm{E}"); +defineMacro("\\Eta", "\\mathrm{H}"); +defineMacro("\\exist", "\\exists"); +defineMacro("\\harr", "\\leftrightarrow"); +defineMacro("\\hArr", "\\Leftrightarrow"); +defineMacro("\\Harr", "\\Leftrightarrow"); +defineMacro("\\hearts", "\\heartsuit"); +defineMacro("\\image", "\\Im"); +defineMacro("\\infin", "\\infty"); +defineMacro("\\Iota", "\\mathrm{I}"); +defineMacro("\\isin", "\\in"); +defineMacro("\\Kappa", "\\mathrm{K}"); +defineMacro("\\larr", "\\leftarrow"); +defineMacro("\\lArr", "\\Leftarrow"); +defineMacro("\\Larr", "\\Leftarrow"); +defineMacro("\\lrarr", "\\leftrightarrow"); +defineMacro("\\lrArr", "\\Leftrightarrow"); +defineMacro("\\Lrarr", "\\Leftrightarrow"); +defineMacro("\\Mu", "\\mathrm{M}"); +defineMacro("\\natnums", "\\mathbb{N}"); +defineMacro("\\Nu", "\\mathrm{N}"); +defineMacro("\\Omicron", "\\mathrm{O}"); +defineMacro("\\plusmn", "\\pm"); +defineMacro("\\rarr", "\\rightarrow"); +defineMacro("\\rArr", "\\Rightarrow"); +defineMacro("\\Rarr", "\\Rightarrow"); +defineMacro("\\real", "\\Re"); +defineMacro("\\reals", "\\mathbb{R}"); +defineMacro("\\Reals", "\\mathbb{R}"); +defineMacro("\\Rho", "\\mathrm{P}"); +defineMacro("\\sdot", "\\cdot"); +defineMacro("\\sect", "\\S"); +defineMacro("\\spades", "\\spadesuit"); +defineMacro("\\sub", "\\subset"); +defineMacro("\\sube", "\\subseteq"); +defineMacro("\\supe", "\\supseteq"); +defineMacro("\\Tau", "\\mathrm{T}"); +defineMacro("\\thetasym", "\\vartheta"); +// TODO: defineMacro("\\varcoppa", "\\\mbox{\\coppa}"); +defineMacro("\\weierp", "\\wp"); +defineMacro("\\Zeta", "\\mathrm{Z}"); +////////////////////////////////////////////////////////////////////// +// statmath.sty +// https://ctan.math.illinois.edu/macros/latex/contrib/statmath/statmath.pdf +defineMacro("\\argmin", "\\DOTSB\\operatorname*{arg\\,min}"); +defineMacro("\\argmax", "\\DOTSB\\operatorname*{arg\\,max}"); +defineMacro("\\plim", "\\DOTSB\\mathop{\\operatorname{plim}}\\limits"); +////////////////////////////////////////////////////////////////////// +// braket.sty +// http://ctan.math.washington.edu/tex-archive/macros/latex/contrib/braket/braket.pdf +defineMacro("\\bra", "\\mathinner{\\langle{#1}|}"); +defineMacro("\\ket", "\\mathinner{|{#1}\\rangle}"); +defineMacro("\\braket", "\\mathinner{\\langle{#1}\\rangle}"); +defineMacro("\\Bra", "\\left\\langle#1\\right|"); +defineMacro("\\Ket", "\\left|#1\\right\\rangle"); +var braketHelper = one => context => { + var left = context.consumeArg().tokens; + var middle = context.consumeArg().tokens; + var middleDouble = context.consumeArg().tokens; + var right = context.consumeArg().tokens; + var oldMiddle = context.macros.get("|"); + var oldMiddleDouble = context.macros.get("\\|"); + context.macros.beginGroup(); + var midMacro = double => context => { + if (one) { + // Only modify the first instance of | or \| + context.macros.set("|", oldMiddle); + if (middleDouble.length) { + context.macros.set("\\|", oldMiddleDouble); + } + } + var doubled = double; + if (!double && middleDouble.length) { + // Mimic \@ifnextchar + var nextToken = context.future(); + if (nextToken.text === "|") { + context.popToken(); + doubled = true; + } + } + return { + tokens: doubled ? middleDouble : middle, + numArgs: 0 + }; + }; + context.macros.set("|", midMacro(false)); + if (middleDouble.length) { + context.macros.set("\\|", midMacro(true)); + } + var arg = context.consumeArg().tokens; + var expanded = context.expandTokens([...right, ...arg, ...left // reversed + ]); + context.macros.endGroup(); + return { + tokens: expanded.reverse(), + numArgs: 0 + }; +}; +defineMacro("\\bra@ket", braketHelper(false)); +defineMacro("\\bra@set", braketHelper(true)); +defineMacro("\\Braket", "\\bra@ket{\\left\\langle}" + "{\\,\\middle\\vert\\,}{\\,\\middle\\vert\\,}{\\right\\rangle}"); +defineMacro("\\Set", "\\bra@set{\\left\\{\\:}" + "{\\;\\middle\\vert\\;}{\\;\\middle\\Vert\\;}{\\:\\right\\}}"); +defineMacro("\\set", "\\bra@set{\\{\\,}{\\mid}{}{\\,\\}}"); +// has no support for special || or \| +////////////////////////////////////////////////////////////////////// +// actuarialangle.dtx +defineMacro("\\angln", "{\\angl n}"); +// Custom Khan Academy colors, should be moved to an optional package +defineMacro("\\blue", "\\textcolor{##6495ed}{#1}"); +defineMacro("\\orange", "\\textcolor{##ffa500}{#1}"); +defineMacro("\\pink", "\\textcolor{##ff00af}{#1}"); +defineMacro("\\red", "\\textcolor{##df0030}{#1}"); +defineMacro("\\green", "\\textcolor{##28ae7b}{#1}"); +defineMacro("\\gray", "\\textcolor{gray}{#1}"); +defineMacro("\\purple", "\\textcolor{##9d38bd}{#1}"); +defineMacro("\\blueA", "\\textcolor{##ccfaff}{#1}"); +defineMacro("\\blueB", "\\textcolor{##80f6ff}{#1}"); +defineMacro("\\blueC", "\\textcolor{##63d9ea}{#1}"); +defineMacro("\\blueD", "\\textcolor{##11accd}{#1}"); +defineMacro("\\blueE", "\\textcolor{##0c7f99}{#1}"); +defineMacro("\\tealA", "\\textcolor{##94fff5}{#1}"); +defineMacro("\\tealB", "\\textcolor{##26edd5}{#1}"); +defineMacro("\\tealC", "\\textcolor{##01d1c1}{#1}"); +defineMacro("\\tealD", "\\textcolor{##01a995}{#1}"); +defineMacro("\\tealE", "\\textcolor{##208170}{#1}"); +defineMacro("\\greenA", "\\textcolor{##b6ffb0}{#1}"); +defineMacro("\\greenB", "\\textcolor{##8af281}{#1}"); +defineMacro("\\greenC", "\\textcolor{##74cf70}{#1}"); +defineMacro("\\greenD", "\\textcolor{##1fab54}{#1}"); +defineMacro("\\greenE", "\\textcolor{##0d923f}{#1}"); +defineMacro("\\goldA", "\\textcolor{##ffd0a9}{#1}"); +defineMacro("\\goldB", "\\textcolor{##ffbb71}{#1}"); +defineMacro("\\goldC", "\\textcolor{##ff9c39}{#1}"); +defineMacro("\\goldD", "\\textcolor{##e07d10}{#1}"); +defineMacro("\\goldE", "\\textcolor{##a75a05}{#1}"); +defineMacro("\\redA", "\\textcolor{##fca9a9}{#1}"); +defineMacro("\\redB", "\\textcolor{##ff8482}{#1}"); +defineMacro("\\redC", "\\textcolor{##f9685d}{#1}"); +defineMacro("\\redD", "\\textcolor{##e84d39}{#1}"); +defineMacro("\\redE", "\\textcolor{##bc2612}{#1}"); +defineMacro("\\maroonA", "\\textcolor{##ffbde0}{#1}"); +defineMacro("\\maroonB", "\\textcolor{##ff92c6}{#1}"); +defineMacro("\\maroonC", "\\textcolor{##ed5fa6}{#1}"); +defineMacro("\\maroonD", "\\textcolor{##ca337c}{#1}"); +defineMacro("\\maroonE", "\\textcolor{##9e034e}{#1}"); +defineMacro("\\purpleA", "\\textcolor{##ddd7ff}{#1}"); +defineMacro("\\purpleB", "\\textcolor{##c6b9fc}{#1}"); +defineMacro("\\purpleC", "\\textcolor{##aa87ff}{#1}"); +defineMacro("\\purpleD", "\\textcolor{##7854ab}{#1}"); +defineMacro("\\purpleE", "\\textcolor{##543b78}{#1}"); +defineMacro("\\mintA", "\\textcolor{##f5f9e8}{#1}"); +defineMacro("\\mintB", "\\textcolor{##edf2df}{#1}"); +defineMacro("\\mintC", "\\textcolor{##e0e5cc}{#1}"); +defineMacro("\\grayA", "\\textcolor{##f6f7f7}{#1}"); +defineMacro("\\grayB", "\\textcolor{##f0f1f2}{#1}"); +defineMacro("\\grayC", "\\textcolor{##e3e5e6}{#1}"); +defineMacro("\\grayD", "\\textcolor{##d6d8da}{#1}"); +defineMacro("\\grayE", "\\textcolor{##babec2}{#1}"); +defineMacro("\\grayF", "\\textcolor{##888d93}{#1}"); +defineMacro("\\grayG", "\\textcolor{##626569}{#1}"); +defineMacro("\\grayH", "\\textcolor{##3b3e40}{#1}"); +defineMacro("\\grayI", "\\textcolor{##21242c}{#1}"); +defineMacro("\\kaBlue", "\\textcolor{##314453}{#1}"); +defineMacro("\\kaGreen", "\\textcolor{##71B307}{#1}"); + +/** + * This file contains the “gullet” where macros are expanded + * until only non-macro tokens remain. + */ +// List of commands that act like macros but aren't defined as a macro, +// function, or symbol. Used in `isDefined`. +var implicitCommands = { + "^": true, + // Parser.js + "_": true, + // Parser.js + "\\limits": true, + // Parser.js + "\\nolimits": true // Parser.js +}; +class MacroExpander { + constructor(input, settings, mode) { + this.settings = void 0; + this.expansionCount = void 0; + this.lexer = void 0; + this.macros = void 0; + this.stack = void 0; + this.mode = void 0; + this.settings = settings; + this.expansionCount = 0; + this.feed(input); + // Make new global namespace + this.macros = new Namespace(macros, settings.macros); + this.mode = mode; + this.stack = []; // contains tokens in REVERSE order + } + /** + * Feed a new input string to the same MacroExpander + * (with existing macros etc.). + */ + feed(input) { + this.lexer = new Lexer(input, this.settings); + } + /** + * Switches between "text" and "math" modes. + */ + switchMode(newMode) { + this.mode = newMode; + } + /** + * Start a new group nesting within all namespaces. + */ + beginGroup() { + this.macros.beginGroup(); + } + /** + * End current group nesting within all namespaces. + */ + endGroup() { + this.macros.endGroup(); + } + /** + * Ends all currently nested groups (if any), restoring values before the + * groups began. Useful in case of an error in the middle of parsing. + */ + endGroups() { + this.macros.endGroups(); + } + /** + * Returns the topmost token on the stack, without expanding it. + * Similar in behavior to TeX's `\futurelet`. + */ + future() { + if (this.stack.length === 0) { + this.pushToken(this.lexer.lex()); + } + return this.stack[this.stack.length - 1]; + } + /** + * Remove and return the next unexpanded token. + */ + popToken() { + this.future(); // ensure non-empty stack + return this.stack.pop(); + } + /** + * Add a given token to the token stack. In particular, this get be used + * to put back a token returned from one of the other methods. + */ + pushToken(token) { + this.stack.push(token); + } + /** + * Append an array of tokens to the token stack. + */ + pushTokens(tokens) { + this.stack.push(...tokens); + } + /** + * Find an macro argument without expanding tokens and append the array of + * tokens to the token stack. Uses Token as a container for the result. + */ + scanArgument(isOptional) { + var start; + var end; + var tokens; + if (isOptional) { + this.consumeSpaces(); // \@ifnextchar gobbles any space following it + if (this.future().text !== "[") { + return null; + } + start = this.popToken(); // don't include [ in tokens + ({ + tokens, + end + } = this.consumeArg(["]"])); + } else { + ({ + tokens, + start, + end + } = this.consumeArg()); + } + // indicate the end of an argument + this.pushToken(new Token("EOF", end.loc)); + this.pushTokens(tokens); + return new Token("", SourceLocation.range(start, end)); + } + /** + * Consume all following space tokens, without expansion. + */ + consumeSpaces() { + for (;;) { + var token = this.future(); + if (token.text === " ") { + this.stack.pop(); + } else { + break; + } + } + } + /** + * Consume an argument from the token stream, and return the resulting array + * of tokens and start/end token. + */ + consumeArg(delims) { + // The argument for a delimited parameter is the shortest (possibly + // empty) sequence of tokens with properly nested {...} groups that is + // followed ... by this particular list of non-parameter tokens. + // The argument for an undelimited parameter is the next nonblank + // token, unless that token is ‘{’, when the argument will be the + // entire {...} group that follows. + var tokens = []; + var isDelimited = delims && delims.length > 0; + if (!isDelimited) { + // Ignore spaces between arguments. As the TeXbook says: + // "After you have said ‘\def\row#1#2{...}’, you are allowed to + // put spaces between the arguments (e.g., ‘\row x n’), because + // TeX doesn’t use single spaces as undelimited arguments." + this.consumeSpaces(); + } + var start = this.future(); + var tok; + var depth = 0; + var match = 0; + do { + tok = this.popToken(); + tokens.push(tok); + if (tok.text === "{") { + ++depth; + } else if (tok.text === "}") { + --depth; + if (depth === -1) { + throw new ParseError("Extra }", tok); + } + } else if (tok.text === "EOF") { + throw new ParseError("Unexpected end of input in a macro argument" + ", expected '" + (delims && isDelimited ? delims[match] : "}") + "'", tok); + } + if (delims && isDelimited) { + if ((depth === 0 || depth === 1 && delims[match] === "{") && tok.text === delims[match]) { + ++match; + if (match === delims.length) { + // don't include delims in tokens + tokens.splice(-match, match); + break; + } + } else { + match = 0; + } + } + } while (depth !== 0 || isDelimited); + // If the argument found ... has the form ‘{}’, + // ... the outermost braces enclosing the argument are removed + if (start.text === "{" && tokens[tokens.length - 1].text === "}") { + tokens.pop(); + tokens.shift(); + } + tokens.reverse(); // to fit in with stack order + return { + tokens, + start, + end: tok + }; + } + /** + * Consume the specified number of (delimited) arguments from the token + * stream and return the resulting array of arguments. + */ + consumeArgs(numArgs, delimiters) { + if (delimiters) { + if (delimiters.length !== numArgs + 1) { + throw new ParseError("The length of delimiters doesn't match the number of args!"); + } + var delims = delimiters[0]; + for (var i = 0; i < delims.length; i++) { + var tok = this.popToken(); + if (delims[i] !== tok.text) { + throw new ParseError("Use of the macro doesn't match its definition", tok); + } + } + } + var args = []; + for (var _i = 0; _i < numArgs; _i++) { + args.push(this.consumeArg(delimiters && delimiters[_i + 1]).tokens); + } + return args; + } + /** + * Increment `expansionCount` by the specified amount. + * Throw an error if it exceeds `maxExpand`. + */ + countExpansion(amount) { + this.expansionCount += amount; + if (this.expansionCount > this.settings.maxExpand) { + throw new ParseError("Too many expansions: infinite loop or " + "need to increase maxExpand setting"); + } + } + /** + * Expand the next token only once if possible. + * + * If the token is expanded, the resulting tokens will be pushed onto + * the stack in reverse order, and the number of such tokens will be + * returned. This number might be zero or positive. + * + * If not, the return value is `false`, and the next token remains at the + * top of the stack. + * + * In either case, the next token will be on the top of the stack, + * or the stack will be empty (in case of empty expansion + * and no other tokens). + * + * Used to implement `expandAfterFuture` and `expandNextToken`. + * + * If expandableOnly, only expandable tokens are expanded and + * an undefined control sequence results in an error. + */ + expandOnce(expandableOnly) { + var topToken = this.popToken(); + var name = topToken.text; + var expansion = !topToken.noexpand ? this._getExpansion(name) : null; + if (expansion == null || expandableOnly && expansion.unexpandable) { + if (expandableOnly && expansion == null && name[0] === "\\" && !this.isDefined(name)) { + throw new ParseError("Undefined control sequence: " + name); + } + this.pushToken(topToken); + return false; + } + this.countExpansion(1); + var tokens = expansion.tokens; + var args = this.consumeArgs(expansion.numArgs, expansion.delimiters); + if (expansion.numArgs) { + // paste arguments in place of the placeholders + tokens = tokens.slice(); // make a shallow copy + for (var i = tokens.length - 1; i >= 0; --i) { + var tok = tokens[i]; + if (tok.text === "#") { + if (i === 0) { + throw new ParseError("Incomplete placeholder at end of macro body", tok); + } + tok = tokens[--i]; // next token on stack + if (tok.text === "#") { + // ## → # + tokens.splice(i + 1, 1); // drop first # + } else if (/^[1-9]$/.test(tok.text)) { + // replace the placeholder with the indicated argument + tokens.splice(i, 2, ...args[+tok.text - 1]); + } else { + throw new ParseError("Not a valid argument number", tok); + } + } + } + } + // Concatenate expansion onto top of stack. + this.pushTokens(tokens); + return tokens.length; + } + /** + * Expand the next token only once (if possible), and return the resulting + * top token on the stack (without removing anything from the stack). + * Similar in behavior to TeX's `\expandafter\futurelet`. + * Equivalent to expandOnce() followed by future(). + */ + expandAfterFuture() { + this.expandOnce(); + return this.future(); + } + /** + * Recursively expand first token, then return first non-expandable token. + */ + expandNextToken() { + for (;;) { + if (this.expandOnce() === false) { + // fully expanded + var token = this.stack.pop(); + // the token after \noexpand is interpreted as if its meaning + // were ‘\relax’ + if (token.treatAsRelax) { + token.text = "\\relax"; + } + return token; + } + } + } + /** + * Fully expand the given macro name and return the resulting list of + * tokens, or return `undefined` if no such macro is defined. + */ + expandMacro(name) { + return this.macros.has(name) ? this.expandTokens([new Token(name)]) : undefined; + } + /** + * Fully expand the given token stream and return the resulting list of + * tokens. Note that the input tokens are in reverse order, but the + * output tokens are in forward order. + */ + expandTokens(tokens) { + var output = []; + var oldStackLength = this.stack.length; + this.pushTokens(tokens); + while (this.stack.length > oldStackLength) { + // Expand only expandable tokens + if (this.expandOnce(true) === false) { + // fully expanded + var token = this.stack.pop(); + if (token.treatAsRelax) { + // the expansion of \noexpand is the token itself + token.noexpand = false; + token.treatAsRelax = false; + } + output.push(token); + } + } + // Count all of these tokens as additional expansions, to prevent + // exponential blowup from linearly many \edef's. + this.countExpansion(output.length); + return output; + } + /** + * Fully expand the given macro name and return the result as a string, + * or return `undefined` if no such macro is defined. + */ + expandMacroAsText(name) { + var tokens = this.expandMacro(name); + if (tokens) { + return tokens.map(token => token.text).join(""); + } else { + return tokens; + } + } + /** + * Returns the expanded macro as a reversed array of tokens and a macro + * argument count. Or returns `null` if no such macro. + */ + _getExpansion(name) { + var definition = this.macros.get(name); + if (definition == null) { + // mainly checking for undefined here + return definition; + } + // If a single character has an associated catcode other than 13 + // (active character), then don't expand it. + if (name.length === 1) { + var catcode = this.lexer.catcodes[name]; + if (catcode != null && catcode !== 13) { + return; + } + } + var expansion = typeof definition === "function" ? definition(this) : definition; + if (typeof expansion === "string") { + var numArgs = 0; + if (expansion.includes("#")) { + var stripped = expansion.replace(/##/g, ""); + while (stripped.includes("#" + (numArgs + 1))) { + ++numArgs; + } + } + var bodyLexer = new Lexer(expansion, this.settings); + var tokens = []; + var tok = bodyLexer.lex(); + while (tok.text !== "EOF") { + tokens.push(tok); + tok = bodyLexer.lex(); + } + tokens.reverse(); // to fit in with stack using push and pop + var expanded = { + tokens, + numArgs + }; + return expanded; + } + return expansion; + } + /** + * Determine whether a command is currently "defined" (has some + * functionality), meaning that it's a macro (in the current group), + * a function, a symbol, or one of the special commands listed in + * `implicitCommands`. + */ + isDefined(name) { + return this.macros.has(name) || functions.hasOwnProperty(name) || symbols.math.hasOwnProperty(name) || symbols.text.hasOwnProperty(name) || implicitCommands.hasOwnProperty(name); + } + /** + * Determine whether a command is expandable. + */ + isExpandable(name) { + var macro = this.macros.get(name); + return macro != null ? typeof macro === "string" || typeof macro === "function" || !macro.unexpandable : functions.hasOwnProperty(name) && !functions[name].primitive; + } +} + +// Helpers for Parser.js handling of Unicode (sub|super)script characters. +var unicodeSubRegEx = /^[₊₋₌₍₎₀₁₂₃₄₅₆₇₈₉ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓᵦᵧᵨᵩᵪ]/; +var uSubsAndSups = Object.freeze({ + '₊': '+', + '₋': '-', + '₌': '=', + '₍': '(', + '₎': ')', + '₀': '0', + '₁': '1', + '₂': '2', + '₃': '3', + '₄': '4', + '₅': '5', + '₆': '6', + '₇': '7', + '₈': '8', + '₉': '9', + '\u2090': 'a', + '\u2091': 'e', + '\u2095': 'h', + '\u1D62': 'i', + '\u2C7C': 'j', + '\u2096': 'k', + '\u2097': 'l', + '\u2098': 'm', + '\u2099': 'n', + '\u2092': 'o', + '\u209A': 'p', + '\u1D63': 'r', + '\u209B': 's', + '\u209C': 't', + '\u1D64': 'u', + '\u1D65': 'v', + '\u2093': 'x', + '\u1D66': 'β', + '\u1D67': 'γ', + '\u1D68': 'ρ', + '\u1D69': '\u03d5', + '\u1D6A': 'χ', + '⁺': '+', + '⁻': '-', + '⁼': '=', + '⁽': '(', + '⁾': ')', + '⁰': '0', + '¹': '1', + '²': '2', + '³': '3', + '⁴': '4', + '⁵': '5', + '⁶': '6', + '⁷': '7', + '⁸': '8', + '⁹': '9', + '\u1D2C': 'A', + '\u1D2E': 'B', + '\u1D30': 'D', + '\u1D31': 'E', + '\u1D33': 'G', + '\u1D34': 'H', + '\u1D35': 'I', + '\u1D36': 'J', + '\u1D37': 'K', + '\u1D38': 'L', + '\u1D39': 'M', + '\u1D3A': 'N', + '\u1D3C': 'O', + '\u1D3E': 'P', + '\u1D3F': 'R', + '\u1D40': 'T', + '\u1D41': 'U', + '\u2C7D': 'V', + '\u1D42': 'W', + '\u1D43': 'a', + '\u1D47': 'b', + '\u1D9C': 'c', + '\u1D48': 'd', + '\u1D49': 'e', + '\u1DA0': 'f', + '\u1D4D': 'g', + '\u02B0': 'h', + '\u2071': 'i', + '\u02B2': 'j', + '\u1D4F': 'k', + '\u02E1': 'l', + '\u1D50': 'm', + '\u207F': 'n', + '\u1D52': 'o', + '\u1D56': 'p', + '\u02B3': 'r', + '\u02E2': 's', + '\u1D57': 't', + '\u1D58': 'u', + '\u1D5B': 'v', + '\u02B7': 'w', + '\u02E3': 'x', + '\u02B8': 'y', + '\u1DBB': 'z', + '\u1D5D': 'β', + '\u1D5E': 'γ', + '\u1D5F': 'δ', + '\u1D60': '\u03d5', + '\u1D61': 'χ', + '\u1DBF': 'θ' +}); + +/* eslint no-constant-condition:0 */ +// Pre-evaluate both modules as unicodeSymbols require String.normalize() +var unicodeAccents = { + "́": { + "text": "\\'", + "math": "\\acute" + }, + "̀": { + "text": "\\`", + "math": "\\grave" + }, + "̈": { + "text": "\\\"", + "math": "\\ddot" + }, + "̃": { + "text": "\\~", + "math": "\\tilde" + }, + "̄": { + "text": "\\=", + "math": "\\bar" + }, + "̆": { + "text": "\\u", + "math": "\\breve" + }, + "̌": { + "text": "\\v", + "math": "\\check" + }, + "̂": { + "text": "\\^", + "math": "\\hat" + }, + "̇": { + "text": "\\.", + "math": "\\dot" + }, + "̊": { + "text": "\\r", + "math": "\\mathring" + }, + "̋": { + "text": "\\H" + }, + "̧": { + "text": "\\c" + } +}; +var unicodeSymbols = { + "á": "á", + "à": "à", + "ä": "ä", + "ǟ": "ǟ", + "ã": "ã", + "ā": "ā", + "ă": "ă", + "ắ": "ắ", + "ằ": "ằ", + "ẵ": "ẵ", + "ǎ": "ǎ", + "â": "â", + "ấ": "ấ", + "ầ": "ầ", + "ẫ": "ẫ", + "ȧ": "ȧ", + "ǡ": "ǡ", + "å": "å", + "ǻ": "ǻ", + "ḃ": "ḃ", + "ć": "ć", + "ḉ": "ḉ", + "č": "č", + "ĉ": "ĉ", + "ċ": "ċ", + "ç": "ç", + "ď": "ď", + "ḋ": "ḋ", + "ḑ": "ḑ", + "é": "é", + "è": "è", + "ë": "ë", + "ẽ": "ẽ", + "ē": "ē", + "ḗ": "ḗ", + "ḕ": "ḕ", + "ĕ": "ĕ", + "ḝ": "ḝ", + "ě": "ě", + "ê": "ê", + "ế": "ế", + "ề": "ề", + "ễ": "ễ", + "ė": "ė", + "ȩ": "ȩ", + "ḟ": "ḟ", + "ǵ": "ǵ", + "ḡ": "ḡ", + "ğ": "ğ", + "ǧ": "ǧ", + "ĝ": "ĝ", + "ġ": "ġ", + "ģ": "ģ", + "ḧ": "ḧ", + "ȟ": "ȟ", + "ĥ": "ĥ", + "ḣ": "ḣ", + "ḩ": "ḩ", + "í": "í", + "ì": "ì", + "ï": "ï", + "ḯ": "ḯ", + "ĩ": "ĩ", + "ī": "ī", + "ĭ": "ĭ", + "ǐ": "ǐ", + "î": "î", + "ǰ": "ǰ", + "ĵ": "ĵ", + "ḱ": "ḱ", + "ǩ": "ǩ", + "ķ": "ķ", + "ĺ": "ĺ", + "ľ": "ľ", + "ļ": "ļ", + "ḿ": "ḿ", + "ṁ": "ṁ", + "ń": "ń", + "ǹ": "ǹ", + "ñ": "ñ", + "ň": "ň", + "ṅ": "ṅ", + "ņ": "ņ", + "ó": "ó", + "ò": "ò", + "ö": "ö", + "ȫ": "ȫ", + "õ": "õ", + "ṍ": "ṍ", + "ṏ": "ṏ", + "ȭ": "ȭ", + "ō": "ō", + "ṓ": "ṓ", + "ṑ": "ṑ", + "ŏ": "ŏ", + "ǒ": "ǒ", + "ô": "ô", + "ố": "ố", + "ồ": "ồ", + "ỗ": "ỗ", + "ȯ": "ȯ", + "ȱ": "ȱ", + "ő": "ő", + "ṕ": "ṕ", + "ṗ": "ṗ", + "ŕ": "ŕ", + "ř": "ř", + "ṙ": "ṙ", + "ŗ": "ŗ", + "ś": "ś", + "ṥ": "ṥ", + "š": "š", + "ṧ": "ṧ", + "ŝ": "ŝ", + "ṡ": "ṡ", + "ş": "ş", + "ẗ": "ẗ", + "ť": "ť", + "ṫ": "ṫ", + "ţ": "ţ", + "ú": "ú", + "ù": "ù", + "ü": "ü", + "ǘ": "ǘ", + "ǜ": "ǜ", + "ǖ": "ǖ", + "ǚ": "ǚ", + "ũ": "ũ", + "ṹ": "ṹ", + "ū": "ū", + "ṻ": "ṻ", + "ŭ": "ŭ", + "ǔ": "ǔ", + "û": "û", + "ů": "ů", + "ű": "ű", + "ṽ": "ṽ", + "ẃ": "ẃ", + "ẁ": "ẁ", + "ẅ": "ẅ", + "ŵ": "ŵ", + "ẇ": "ẇ", + "ẘ": "ẘ", + "ẍ": "ẍ", + "ẋ": "ẋ", + "ý": "ý", + "ỳ": "ỳ", + "ÿ": "ÿ", + "ỹ": "ỹ", + "ȳ": "ȳ", + "ŷ": "ŷ", + "ẏ": "ẏ", + "ẙ": "ẙ", + "ź": "ź", + "ž": "ž", + "ẑ": "ẑ", + "ż": "ż", + "Á": "Á", + "À": "À", + "Ä": "Ä", + "Ǟ": "Ǟ", + "Ã": "Ã", + "Ā": "Ā", + "Ă": "Ă", + "Ắ": "Ắ", + "Ằ": "Ằ", + "Ẵ": "Ẵ", + "Ǎ": "Ǎ", + "Â": "Â", + "Ấ": "Ấ", + "Ầ": "Ầ", + "Ẫ": "Ẫ", + "Ȧ": "Ȧ", + "Ǡ": "Ǡ", + "Å": "Å", + "Ǻ": "Ǻ", + "Ḃ": "Ḃ", + "Ć": "Ć", + "Ḉ": "Ḉ", + "Č": "Č", + "Ĉ": "Ĉ", + "Ċ": "Ċ", + "Ç": "Ç", + "Ď": "Ď", + "Ḋ": "Ḋ", + "Ḑ": "Ḑ", + "É": "É", + "È": "È", + "Ë": "Ë", + "Ẽ": "Ẽ", + "Ē": "Ē", + "Ḗ": "Ḗ", + "Ḕ": "Ḕ", + "Ĕ": "Ĕ", + "Ḝ": "Ḝ", + "Ě": "Ě", + "Ê": "Ê", + "Ế": "Ế", + "Ề": "Ề", + "Ễ": "Ễ", + "Ė": "Ė", + "Ȩ": "Ȩ", + "Ḟ": "Ḟ", + "Ǵ": "Ǵ", + "Ḡ": "Ḡ", + "Ğ": "Ğ", + "Ǧ": "Ǧ", + "Ĝ": "Ĝ", + "Ġ": "Ġ", + "Ģ": "Ģ", + "Ḧ": "Ḧ", + "Ȟ": "Ȟ", + "Ĥ": "Ĥ", + "Ḣ": "Ḣ", + "Ḩ": "Ḩ", + "Í": "Í", + "Ì": "Ì", + "Ï": "Ï", + "Ḯ": "Ḯ", + "Ĩ": "Ĩ", + "Ī": "Ī", + "Ĭ": "Ĭ", + "Ǐ": "Ǐ", + "Î": "Î", + "İ": "İ", + "Ĵ": "Ĵ", + "Ḱ": "Ḱ", + "Ǩ": "Ǩ", + "Ķ": "Ķ", + "Ĺ": "Ĺ", + "Ľ": "Ľ", + "Ļ": "Ļ", + "Ḿ": "Ḿ", + "Ṁ": "Ṁ", + "Ń": "Ń", + "Ǹ": "Ǹ", + "Ñ": "Ñ", + "Ň": "Ň", + "Ṅ": "Ṅ", + "Ņ": "Ņ", + "Ó": "Ó", + "Ò": "Ò", + "Ö": "Ö", + "Ȫ": "Ȫ", + "Õ": "Õ", + "Ṍ": "Ṍ", + "Ṏ": "Ṏ", + "Ȭ": "Ȭ", + "Ō": "Ō", + "Ṓ": "Ṓ", + "Ṑ": "Ṑ", + "Ŏ": "Ŏ", + "Ǒ": "Ǒ", + "Ô": "Ô", + "Ố": "Ố", + "Ồ": "Ồ", + "Ỗ": "Ỗ", + "Ȯ": "Ȯ", + "Ȱ": "Ȱ", + "Ő": "Ő", + "Ṕ": "Ṕ", + "Ṗ": "Ṗ", + "Ŕ": "Ŕ", + "Ř": "Ř", + "Ṙ": "Ṙ", + "Ŗ": "Ŗ", + "Ś": "Ś", + "Ṥ": "Ṥ", + "Š": "Š", + "Ṧ": "Ṧ", + "Ŝ": "Ŝ", + "Ṡ": "Ṡ", + "Ş": "Ş", + "Ť": "Ť", + "Ṫ": "Ṫ", + "Ţ": "Ţ", + "Ú": "Ú", + "Ù": "Ù", + "Ü": "Ü", + "Ǘ": "Ǘ", + "Ǜ": "Ǜ", + "Ǖ": "Ǖ", + "Ǚ": "Ǚ", + "Ũ": "Ũ", + "Ṹ": "Ṹ", + "Ū": "Ū", + "Ṻ": "Ṻ", + "Ŭ": "Ŭ", + "Ǔ": "Ǔ", + "Û": "Û", + "Ů": "Ů", + "Ű": "Ű", + "Ṽ": "Ṽ", + "Ẃ": "Ẃ", + "Ẁ": "Ẁ", + "Ẅ": "Ẅ", + "Ŵ": "Ŵ", + "Ẇ": "Ẇ", + "Ẍ": "Ẍ", + "Ẋ": "Ẋ", + "Ý": "Ý", + "Ỳ": "Ỳ", + "Ÿ": "Ÿ", + "Ỹ": "Ỹ", + "Ȳ": "Ȳ", + "Ŷ": "Ŷ", + "Ẏ": "Ẏ", + "Ź": "Ź", + "Ž": "Ž", + "Ẑ": "Ẑ", + "Ż": "Ż", + "ά": "ά", + "ὰ": "ὰ", + "ᾱ": "ᾱ", + "ᾰ": "ᾰ", + "έ": "έ", + "ὲ": "ὲ", + "ή": "ή", + "ὴ": "ὴ", + "ί": "ί", + "ὶ": "ὶ", + "ϊ": "ϊ", + "ΐ": "ΐ", + "ῒ": "ῒ", + "ῑ": "ῑ", + "ῐ": "ῐ", + "ό": "ό", + "ὸ": "ὸ", + "ύ": "ύ", + "ὺ": "ὺ", + "ϋ": "ϋ", + "ΰ": "ΰ", + "ῢ": "ῢ", + "ῡ": "ῡ", + "ῠ": "ῠ", + "ώ": "ώ", + "ὼ": "ὼ", + "Ύ": "Ύ", + "Ὺ": "Ὺ", + "Ϋ": "Ϋ", + "Ῡ": "Ῡ", + "Ῠ": "Ῠ", + "Ώ": "Ώ", + "Ὼ": "Ὼ" +}; +/** + * This file contains the parser used to parse out a TeX expression from the + * input. Since TeX isn't context-free, standard parsers don't work particularly + * well. + * + * The strategy of this parser is as such: + * + * The main functions (the `.parse...` ones) take a position in the current + * parse string to parse tokens from. The lexer (found in Lexer.js, stored at + * this.gullet.lexer) also supports pulling out tokens at arbitrary places. When + * individual tokens are needed at a position, the lexer is called to pull out a + * token, which is then used. + * + * The parser has a property called "mode" indicating the mode that + * the parser is currently in. Currently it has to be one of "math" or + * "text", which denotes whether the current environment is a math-y + * one or a text-y one (e.g. inside \text). Currently, this serves to + * limit the functions which can be used in text mode. + * + * The main functions then return an object which contains the useful data that + * was parsed at its given point, and a new position at the end of the parsed + * data. The main functions can call each other and continue the parsing by + * using the returned position as a new starting point. + * + * There are also extra `.handle...` functions, which pull out some reused + * functionality into self-contained functions. + * + * The functions return ParseNodes. + */ +class Parser { + constructor(input, settings) { + this.mode = void 0; + this.gullet = void 0; + this.settings = void 0; + this.leftrightDepth = void 0; + this.nextToken = void 0; + // Start in math mode + this.mode = "math"; + // Create a new macro expander (gullet) and (indirectly via that) also a + // new lexer (mouth) for this parser (stomach, in the language of TeX) + this.gullet = new MacroExpander(input, settings, this.mode); + // Store the settings for use in parsing + this.settings = settings; + // Count leftright depth (for \middle errors) + this.leftrightDepth = 0; + this.nextToken = null; + } + /** + * Checks a result to make sure it has the right type, and throws an + * appropriate error otherwise. + */ + expect(text, consume) { + if (consume === void 0) { + consume = true; + } + if (this.fetch().text !== text) { + throw new ParseError("Expected '" + text + "', got '" + this.fetch().text + "'", this.fetch()); + } + if (consume) { + this.consume(); + } + } + /** + * Discards the current lookahead token, considering it consumed. + */ + consume() { + this.nextToken = null; + } + /** + * Return the current lookahead token, or if there isn't one (at the + * beginning, or if the previous lookahead token was consume()d), + * fetch the next token as the new lookahead token and return it. + */ + fetch() { + if (this.nextToken == null) { + this.nextToken = this.gullet.expandNextToken(); + } + return this.nextToken; + } + /** + * Switches between "text" and "math" modes. + */ + switchMode(newMode) { + this.mode = newMode; + this.gullet.switchMode(newMode); + } + /** + * Main parsing function, which parses an entire input. + */ + parse() { + if (!this.settings.globalGroup) { + // Create a group namespace for the math expression. + // (LaTeX creates a new group for every $...$, $$...$$, \[...\].) + this.gullet.beginGroup(); + } + // Use old \color behavior (same as LaTeX's \textcolor) if requested. + // We do this within the group for the math expression, so it doesn't + // pollute settings.macros. + if (this.settings.colorIsTextColor) { + this.gullet.macros.set("\\color", "\\textcolor"); + } + try { + // Try to parse the input + var parse = this.parseExpression(false); + // If we succeeded, make sure there's an EOF at the end + this.expect("EOF"); + // End the group namespace for the expression + if (!this.settings.globalGroup) { + this.gullet.endGroup(); + } + return parse; + // Close any leftover groups in case of a parse error. + } finally { + this.gullet.endGroups(); + } + } + /** + * Fully parse a separate sequence of tokens as a separate job. + * Tokens should be specified in reverse order, as in a MacroDefinition. + */ + subparse(tokens) { + // Save the next token from the current job. + var oldToken = this.nextToken; + this.consume(); + // Run the new job, terminating it with an excess '}' + this.gullet.pushToken(new Token("}")); + this.gullet.pushTokens(tokens); + var parse = this.parseExpression(false); + this.expect("}"); + // Restore the next token from the current job. + this.nextToken = oldToken; + return parse; + } + /** + * Parses an "expression", which is a list of atoms. + * + * `breakOnInfix`: Should the parsing stop when we hit infix nodes? This + * happens when functions have higher precedence than infix + * nodes in implicit parses. + * + * `breakOnTokenText`: The text of the token that the expression should end + * with, or `null` if something else should end the + * expression. + */ + parseExpression(breakOnInfix, breakOnTokenText) { + var body = []; + // Keep adding atoms to the body until we can't parse any more atoms (either + // we reached the end, a }, or a \right) + while (true) { + // Ignore spaces in math mode + if (this.mode === "math") { + this.consumeSpaces(); + } + var lex = this.fetch(); + if (Parser.endOfExpression.has(lex.text)) { + break; + } + if (breakOnTokenText && lex.text === breakOnTokenText) { + break; + } + if (breakOnInfix && functions[lex.text] && functions[lex.text].infix) { + break; + } + var atom = this.parseAtom(breakOnTokenText); + if (!atom) { + break; + } else if (atom.type === "internal") { + // Internal nodes do not appear in parse tree + continue; + } + body.push(atom); + } + if (this.mode === "text") { + this.formLigatures(body); + } + return this.handleInfixNodes(body); + } + /** + * Rewrites infix operators such as \over with corresponding commands such + * as \frac. + * + * There can only be one infix operator per group. If there's more than one + * then the expression is ambiguous. This can be resolved by adding {}. + */ + handleInfixNodes(body) { + var overIndex = -1; + var funcName; + for (var i = 0; i < body.length; i++) { + var node = body[i]; + if (node.type === "infix") { + if (overIndex !== -1) { + throw new ParseError("only one infix operator per group", node.token); + } + overIndex = i; + funcName = node.replaceWith; + } + } + if (overIndex !== -1 && funcName) { + var numerNode; + var denomNode; + var numerBody = body.slice(0, overIndex); + var denomBody = body.slice(overIndex + 1); + if (numerBody.length === 1 && numerBody[0].type === "ordgroup") { + numerNode = numerBody[0]; + } else { + numerNode = { + type: "ordgroup", + mode: this.mode, + body: numerBody + }; + } + if (denomBody.length === 1 && denomBody[0].type === "ordgroup") { + denomNode = denomBody[0]; + } else { + denomNode = { + type: "ordgroup", + mode: this.mode, + body: denomBody + }; + } + var _node; + if (funcName === "\\\\abovefrac") { + _node = this.callFunction(funcName, [numerNode, body[overIndex], denomNode], []); + } else { + _node = this.callFunction(funcName, [numerNode, denomNode], []); + } + return [_node]; + } else { + return body; + } + } + /** + * Handle a subscript or superscript with nice errors. + */ + handleSupSubscript(name) { + var symbolToken = this.fetch(); + var symbol = symbolToken.text; + this.consume(); + this.consumeSpaces(); // ignore spaces before sup/subscript argument + // Skip over allowed internal nodes such as \relax + var group; + do { + var _group; + group = this.parseGroup(name); + } while (((_group = group) == null ? void 0 : _group.type) === "internal"); + if (!group) { + throw new ParseError("Expected group after '" + symbol + "'", symbolToken); + } + return group; + } + /** + * Converts the textual input of an unsupported command into a text node + * contained within a color node whose color is determined by errorColor + */ + formatUnsupportedCmd(text) { + var textordArray = []; + for (var i = 0; i < text.length; i++) { + textordArray.push({ + type: "textord", + mode: "text", + text: text[i] + }); + } + var textNode = { + type: "text", + mode: this.mode, + body: textordArray + }; + var colorNode = { + type: "color", + mode: this.mode, + color: this.settings.errorColor, + body: [textNode] + }; + return colorNode; + } + /** + * Parses a group with optional super/subscripts. + */ + parseAtom(breakOnTokenText) { + // The body of an atom is an implicit group, so that things like + // \left(x\right)^2 work correctly. + var base = this.parseGroup("atom", breakOnTokenText); + // Internal nodes (e.g. \relax) cannot support super/subscripts. + // Instead we will pick up super/subscripts with blank base next round. + if ((base == null ? void 0 : base.type) === "internal") { + return base; + } + // In text mode, we don't have superscripts or subscripts + if (this.mode === "text") { + return base; + } + // Note that base may be empty (i.e. null) at this point. + var superscript; + var subscript; + while (true) { + // Guaranteed in math mode, so eat any spaces first. + this.consumeSpaces(); + // Lex the first token + var lex = this.fetch(); + if (lex.text === "\\limits" || lex.text === "\\nolimits") { + // We got a limit control + if (base && base.type === "op") { + var limits = lex.text === "\\limits"; + base.limits = limits; + base.alwaysHandleSupSub = true; + } else if (base && base.type === "operatorname") { + if (base.alwaysHandleSupSub) { + base.limits = lex.text === "\\limits"; + } + } else { + throw new ParseError("Limit controls must follow a math operator", lex); + } + this.consume(); + } else if (lex.text === "^") { + // We got a superscript start + if (superscript) { + throw new ParseError("Double superscript", lex); + } + superscript = this.handleSupSubscript("superscript"); + } else if (lex.text === "_") { + // We got a subscript start + if (subscript) { + throw new ParseError("Double subscript", lex); + } + subscript = this.handleSupSubscript("subscript"); + } else if (lex.text === "'") { + // We got a prime + if (superscript) { + throw new ParseError("Double superscript", lex); + } + var prime = { + type: "textord", + mode: this.mode, + text: "\\prime" + }; + // Many primes can be grouped together, so we handle this here + var primes = [prime]; + this.consume(); + // Keep lexing tokens until we get something that's not a prime + while (this.fetch().text === "'") { + // For each one, add another prime to the list + primes.push(prime); + this.consume(); + } + // If there's a superscript following the primes, combine that + // superscript in with the primes. + if (this.fetch().text === "^") { + primes.push(this.handleSupSubscript("superscript")); + } + // Put everything into an ordgroup as the superscript + superscript = { + type: "ordgroup", + mode: this.mode, + body: primes + }; + } else if (uSubsAndSups[lex.text]) { + // A Unicode subscript or superscript character. + // We treat these similarly to the unicode-math package. + // So we render a string of Unicode (sub|super)scripts the + // same as a (sub|super)script of regular characters. + var isSub = unicodeSubRegEx.test(lex.text); + var subsupTokens = []; + subsupTokens.push(new Token(uSubsAndSups[lex.text])); + this.consume(); + // Continue fetching tokens to fill out the string. + while (true) { + var token = this.fetch().text; + if (!uSubsAndSups[token]) { + break; + } + if (unicodeSubRegEx.test(token) !== isSub) { + break; + } + subsupTokens.unshift(new Token(uSubsAndSups[token])); + this.consume(); + } + // Now create a (sub|super)script. + var body = this.subparse(subsupTokens); + if (isSub) { + subscript = { + type: "ordgroup", + mode: "math", + body + }; + } else { + superscript = { + type: "ordgroup", + mode: "math", + body + }; + } + } else { + // If it wasn't ^, _, or ', stop parsing super/subscripts + break; + } + } + // Base must be set if superscript or subscript are set per logic above, + // but need to check here for type check to pass. + if (superscript || subscript) { + // If we got either a superscript or subscript, create a supsub + return { + type: "supsub", + mode: this.mode, + base: base, + sup: superscript, + sub: subscript + }; + } else { + // Otherwise return the original body + return base; + } + } + /** + * Parses an entire function, including its base and all of its arguments. + */ + parseFunction(breakOnTokenText, name) { + var token = this.fetch(); + var func = token.text; + var funcData = functions[func]; + if (!funcData) { + return null; + } + this.consume(); // consume command token + if (name && name !== "atom" && !funcData.allowedInArgument) { + throw new ParseError("Got function '" + func + "' with no arguments" + (name ? " as " + name : ""), token); + } else if (this.mode === "text" && !funcData.allowedInText) { + throw new ParseError("Can't use function '" + func + "' in text mode", token); + } else if (this.mode === "math" && funcData.allowedInMath === false) { + throw new ParseError("Can't use function '" + func + "' in math mode", token); + } + var { + args, + optArgs + } = this.parseArguments(func, funcData); + return this.callFunction(func, args, optArgs, token, breakOnTokenText); + } + /** + * Call a function handler with a suitable context and arguments. + */ + callFunction(name, args, optArgs, token, breakOnTokenText) { + var context = { + funcName: name, + parser: this, + token, + breakOnTokenText + }; + var func = functions[name]; + if (func && func.handler) { + return func.handler(context, args, optArgs); + } else { + throw new ParseError("No function handler for " + name); + } + } + /** + * Parses the arguments of a function or environment + */ + parseArguments(func, + // Should look like "\name" or "\begin{name}". + funcData) { + var totalArgs = funcData.numArgs + funcData.numOptionalArgs; + if (totalArgs === 0) { + return { + args: [], + optArgs: [] + }; + } + var args = []; + var optArgs = []; + for (var i = 0; i < totalArgs; i++) { + var argType = funcData.argTypes && funcData.argTypes[i]; + var isOptional = i < funcData.numOptionalArgs; + if ("primitive" in funcData && funcData.primitive && argType == null || + // \sqrt expands into primitive if optional argument doesn't exist + funcData.type === "sqrt" && i === 1 && optArgs[0] == null) { + argType = "primitive"; + } + var arg = this.parseGroupOfType("argument to '" + func + "'", argType, isOptional); + if (isOptional) { + optArgs.push(arg); + } else if (arg != null) { + args.push(arg); + } else { + // should be unreachable + throw new ParseError("Null argument, please report this as a bug"); + } + } + return { + args, + optArgs + }; + } + /** + * Parses a group when the mode is changing. + */ + parseGroupOfType(name, type, optional) { + switch (type) { + case "color": + return this.parseColorGroup(optional); + case "size": + return this.parseSizeGroup(optional); + case "url": + return this.parseUrlGroup(optional); + case "math": + case "text": + return this.parseArgumentGroup(optional, type); + case "hbox": + { + // hbox argument type wraps the argument in the equivalent of + // \hbox, which is like \text but switching to \textstyle size + // and resetting math font. + var group = this.parseArgumentGroup(optional, "text"); + return group != null ? { + type: "styling", + mode: group.mode, + body: [group], + style: "text", + // simulate \textstyle + resetFont: true + } : null; + } + case "raw": + { + var token = this.parseStringGroup("raw", optional); + return token != null ? { + type: "raw", + mode: "text", + string: token.text + } : null; + } + case "primitive": + { + if (optional) { + throw new ParseError("A primitive argument cannot be optional"); + } + var _group2 = this.parseGroup(name); + if (_group2 == null) { + throw new ParseError("Expected group as " + name, this.fetch()); + } + return _group2; + } + case "original": + case null: + case undefined: + return this.parseArgumentGroup(optional); + default: + throw new ParseError("Unknown group type as " + name, this.fetch()); + } + } + /** + * Discard any space tokens, fetching the next non-space token. + */ + consumeSpaces() { + while (this.fetch().text === " ") { + this.consume(); + } + } + /** + * Parses a group, essentially returning the string formed by the + * brace-enclosed tokens plus some position information. + */ + parseStringGroup(modeName, + // Used to describe the mode in error messages. + optional) { + var argToken = this.gullet.scanArgument(optional); + if (argToken == null) { + return null; + } + var str = ""; + var nextToken; + while ((nextToken = this.fetch()).text !== "EOF") { + str += nextToken.text; + this.consume(); + } + this.consume(); // consume the end of the argument + argToken.text = str; + return argToken; + } + /** + * Parses a regex-delimited group: the largest sequence of tokens + * whose concatenated strings match `regex`. Returns the string + * formed by the tokens plus some position information. + */ + parseRegexGroup(regex, modeName) { + var firstToken = this.fetch(); + var lastToken = firstToken; + var str = ""; + var nextToken; + while ((nextToken = this.fetch()).text !== "EOF" && regex.test(str + nextToken.text)) { + lastToken = nextToken; + str += lastToken.text; + this.consume(); + } + if (str === "") { + throw new ParseError("Invalid " + modeName + ": '" + firstToken.text + "'", firstToken); + } + return firstToken.range(lastToken, str); + } + /** + * Parses a color description. + */ + parseColorGroup(optional) { + var res = this.parseStringGroup("color", optional); + if (res == null) { + return null; + } + var match = /^(#[a-f0-9]{3,4}|#[a-f0-9]{6}|#[a-f0-9]{8}|[a-f0-9]{6}|[a-z]+)$/i.exec(res.text); + if (!match) { + throw new ParseError("Invalid color: '" + res.text + "'", res); + } + var color = match[0]; + if (/^[0-9a-f]{6}$/i.test(color)) { + // We allow a 6-digit HTML color spec without a leading "#". + // This follows the xcolor package's HTML color model. + // Predefined color names are all missed by this RegEx pattern. + color = "#" + color; + } + return { + type: "color-token", + mode: this.mode, + color + }; + } + /** + * Parses a size specification, consisting of magnitude and unit. + */ + parseSizeGroup(optional) { + var res; + var isBlank = false; + // don't expand before parseStringGroup + this.gullet.consumeSpaces(); + if (!optional && this.gullet.future().text !== "{") { + res = this.parseRegexGroup(/^[-+]? *(?:$|\d+|\d+\.\d*|\.\d*) *[a-z]{0,2} *$/, "size"); + } else { + res = this.parseStringGroup("size", optional); + } + if (!res) { + return null; + } + if (!optional && res.text.length === 0) { + // Because we've tested for what is !optional, this block won't + // affect \kern, \hspace, etc. It will capture the mandatory arguments + // to \genfrac and \above. + res.text = "0pt"; // Enable \above{} + isBlank = true; // This is here specifically for \genfrac + } + var match = /([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(res.text); + if (!match) { + throw new ParseError("Invalid size: '" + res.text + "'", res); + } + var data = { + number: +(match[1] + match[2]), + // sign + magnitude, cast to number + unit: match[3] + }; + if (!validUnit(data)) { + throw new ParseError("Invalid unit: '" + data.unit + "'", res); + } + return { + type: "size", + mode: this.mode, + value: data, + isBlank + }; + } + /** + * Parses an URL, checking escaped letters and allowed protocols, + * and setting the catcode of % as an active character (as in \hyperref). + */ + parseUrlGroup(optional) { + this.gullet.lexer.setCatcode("%", 13); // active character + this.gullet.lexer.setCatcode("~", 12); // other character + var res = this.parseStringGroup("url", optional); + this.gullet.lexer.setCatcode("%", 14); // comment character + this.gullet.lexer.setCatcode("~", 13); // active character + if (res == null) { + return null; + } + // hyperref package allows backslashes alone in href, but doesn't + // generate valid links in such cases; we interpret this as + // "undefined" behaviour, and keep them as-is. Some browser will + // replace backslashes with forward slashes. + var url = res.text.replace(/\\([#$%&~_^{}])/g, '$1'); + return { + type: "url", + mode: this.mode, + url + }; + } + /** + * Parses an argument with the mode specified. + */ + parseArgumentGroup(optional, mode) { + var argToken = this.gullet.scanArgument(optional); + if (argToken == null) { + return null; + } + var outerMode = this.mode; + if (mode) { + // Switch to specified mode + this.switchMode(mode); + } + this.gullet.beginGroup(); + var expression = this.parseExpression(false, "EOF"); + // TODO: find an alternative way to denote the end + this.expect("EOF"); // expect the end of the argument + this.gullet.endGroup(); + var result = { + type: "ordgroup", + mode: this.mode, + loc: argToken.loc, + body: expression + }; + if (mode) { + // Switch mode back + this.switchMode(outerMode); + } + return result; + } + /** + * Parses an ordinary group, which is either a single nucleus (like "x") + * or an expression in braces (like "{x+y}") or an implicit group, a group + * that starts at the current position, and ends right before a higher explicit + * group ends, or at EOF. + */ + parseGroup(name, + // For error reporting. + breakOnTokenText) { + var firstToken = this.fetch(); + var text = firstToken.text; + var result; + // Try to parse an open brace or \begingroup + if (text === "{" || text === "\\begingroup") { + this.consume(); + var groupEnd = text === "{" ? "}" : "\\endgroup"; + this.gullet.beginGroup(); + // If we get a brace, parse an expression + var expression = this.parseExpression(false, groupEnd); + var lastToken = this.fetch(); + this.expect(groupEnd); // Check that we got a matching closing brace + this.gullet.endGroup(); + result = { + type: "ordgroup", + mode: this.mode, + loc: SourceLocation.range(firstToken, lastToken), + body: expression, + // A group formed by \begingroup...\endgroup is a semi-simple group + // which doesn't affect spacing in math mode, i.e., is transparent. + // https://tex.stackexchange.com/questions/1930/when-should-one- + // use-begingroup-instead-of-bgroup + semisimple: text === "\\begingroup" || undefined + }; + } else { + // If there exists a function with this name, parse the function. + // Otherwise, just return a nucleus + result = this.parseFunction(breakOnTokenText, name) || this.parseSymbol(); + if (result == null && text[0] === "\\" && !implicitCommands.hasOwnProperty(text)) { + if (this.settings.throwOnError) { + throw new ParseError("Undefined control sequence: " + text, firstToken); + } + result = this.formatUnsupportedCmd(text); + this.consume(); + } + } + return result; + } + /** + * Form ligature-like combinations of characters for text mode. + * This includes inputs like "--", "---", "``" and "''". + * The result will simply replace multiple textord nodes with a single + * character in each value by a single textord node having multiple + * characters in its value. The representation is still ASCII source. + * The group will be modified in place. + */ + formLigatures(group) { + var n = group.length - 1; + for (var i = 0; i < n; ++i) { + var a = group[i]; + if (a.type !== "textord") { + continue; + } + var v = a.text; + var next = group[i + 1]; + if (!next || next.type !== "textord") { + continue; + } + if (v === "-" && next.text === "-") { + var afterNext = group[i + 2]; + if (i + 1 < n && afterNext && afterNext.type === "textord" && afterNext.text === "-") { + group.splice(i, 3, { + type: "textord", + mode: "text", + loc: SourceLocation.range(a, afterNext), + text: "---" + }); + n -= 2; + } else { + group.splice(i, 2, { + type: "textord", + mode: "text", + loc: SourceLocation.range(a, next), + text: "--" + }); + n -= 1; + } + } + if ((v === "'" || v === "`") && next.text === v) { + group.splice(i, 2, { + type: "textord", + mode: "text", + loc: SourceLocation.range(a, next), + text: v + v + }); + n -= 1; + } + } + } + /** + * Parse a single symbol out of the string. Here, we handle single character + * symbols and special functions like \verb. + */ + parseSymbol() { + var nucleus = this.fetch(); + var text = nucleus.text; + if (/^\\verb[^a-zA-Z]/.test(text)) { + this.consume(); + var arg = text.slice(5); + var star = arg.charAt(0) === "*"; + if (star) { + arg = arg.slice(1); + } + // Lexer's tokenRegex is constructed to always have matching + // first/last characters. + if (arg.length < 2 || arg.charAt(0) !== arg.slice(-1)) { + throw new ParseError("\\verb assertion failed --\n please report what input caused this bug"); + } + arg = arg.slice(1, -1); // remove first and last char + return { + type: "verb", + mode: "text", + body: arg, + star + }; + } + // At this point, we should have a symbol, possibly with accents. + // First expand any accented base symbol according to unicodeSymbols. + if (unicodeSymbols.hasOwnProperty(text[0]) && !symbols[this.mode][text[0]]) { + // This behavior is not strict (XeTeX-compatible) in math mode. + if (this.settings.strict && this.mode === "math") { + this.settings.reportNonstrict("unicodeTextInMathMode", "Accented Unicode text character \"" + text[0] + "\" used in " + "math mode", nucleus); + } + text = unicodeSymbols[text[0]] + text.slice(1); + } + // Strip off any combining characters + var match = combiningDiacriticalMarksEndRegex.exec(text); + if (match) { + text = text.substring(0, match.index); + if (text === 'i') { + text = '\u0131'; // dotless i, in math and text mode + } else if (text === 'j') { + text = '\u0237'; // dotless j, in math and text mode + } + } + // Recognize base symbol + var symbol; + if (symbols[this.mode][text]) { + if (this.settings.strict && this.mode === 'math' && extraLatin.includes(text)) { + this.settings.reportNonstrict("unicodeTextInMathMode", "Latin-1/Unicode text character \"" + text[0] + "\" used in " + "math mode", nucleus); + } + var group = symbols[this.mode][text].group; + var loc = SourceLocation.range(nucleus); + var s; + if (isAtom(group)) { + s = { + type: "atom", + mode: this.mode, + family: group, + loc, + text + }; + } else { + s = { + type: group, + mode: this.mode, + loc, + text + }; + } + symbol = s; + } else if (text.charCodeAt(0) >= 0x80) { + // no symbol for e.g. ^ + if (this.settings.strict) { + if (!supportedCodepoint(text.charCodeAt(0))) { + this.settings.reportNonstrict("unknownSymbol", "Unrecognized Unicode character \"" + text[0] + "\"" + (" (" + text.charCodeAt(0) + ")"), nucleus); + } else if (this.mode === "math") { + this.settings.reportNonstrict("unicodeTextInMathMode", "Unicode text character \"" + text[0] + "\" used in math mode", nucleus); + } + } + // All nonmathematical Unicode characters are rendered as if they + // are in text mode (wrapped in \text) because that's what it + // takes to render them in LaTeX. Setting `mode: this.mode` is + // another natural choice (the user requested math mode), but + // this makes it more difficult for getCharacterMetrics() to + // distinguish Unicode characters without metrics and those for + // which we want to simulate the letter M. + symbol = { + type: "textord", + mode: "text", + loc: SourceLocation.range(nucleus), + text + }; + } else { + return null; // EOF, ^, _, {, }, etc. + } + this.consume(); + // Transform combining characters into accents + if (match) { + for (var i = 0; i < match[0].length; i++) { + var accent = match[0][i]; + if (!unicodeAccents[accent]) { + throw new ParseError("Unknown accent ' " + accent + "'", nucleus); + } + var command = unicodeAccents[accent][this.mode] || unicodeAccents[accent].text; + if (!command) { + throw new ParseError("Accent " + accent + " unsupported in " + this.mode + " mode", nucleus); + } + symbol = { + type: "accent", + mode: this.mode, + loc: SourceLocation.range(nucleus), + label: command, + isStretchy: false, + isShifty: true, + base: symbol + }; + } + } + return symbol; + } +} +Parser.endOfExpression = new Set(["}", "\\endgroup", "\\end", "\\right", "&"]); + +/** + * Provides a single function for parsing an expression using a Parser + * TODO(emily): Remove this + */ +/** + * Parses an expression using a Parser, then returns the parsed result. + */ +var parseTree = function parseTree(toParse, settings) { + if (!(typeof toParse === 'string' || toParse instanceof String)) { + throw new TypeError('KaTeX can only parse string typed expression'); + } + var parser = new Parser(toParse, settings); + // Blank out any \df@tag to avoid spurious "Duplicate \tag" errors + delete parser.gullet.macros.current["\\df@tag"]; + var tree = parser.parse(); + // Prevent a color definition from persisting between calls to katex.render(). + delete parser.gullet.macros.current["\\current@color"]; + delete parser.gullet.macros.current["\\color"]; + // If the input used \tag, it will set the \df@tag macro to the tag. + // In this case, we separately parse the tag and wrap the tree. + if (parser.gullet.macros.get("\\df@tag")) { + if (!settings.displayMode) { + throw new ParseError("\\tag works only in display equations"); + } + tree = [{ + type: "tag", + mode: "text", + body: tree, + tag: parser.subparse([new Token("\\df@tag")]) + }]; + } + return tree; +}; + +/* eslint no-console:0 */ +/** + * Parse and build an expression, and place that expression in the DOM node + * given. + */ +var render = function render(expression, baseNode, options) { + baseNode.textContent = ""; + var node = renderToDomTree(expression, options).toNode(); + baseNode.appendChild(node); +}; +// KaTeX's styles don't work properly in quirks mode. Print out an error, and +// disable rendering. +if (typeof document !== "undefined") { + if (document.compatMode !== "CSS1Compat") { + typeof console !== "undefined" && console.warn("Warning: KaTeX doesn't work in quirks mode. Make sure your " + "website has a suitable doctype."); + render = function render() { + throw new ParseError("KaTeX doesn't work in quirks mode."); + }; + } +} +/** + * Parse and build an expression, and return the markup for that. + */ +var renderToString = function renderToString(expression, options) { + var markup = renderToDomTree(expression, options).toMarkup(); + return markup; +}; +/** + * Parse an expression and return the parse tree. + */ +var generateParseTree = function generateParseTree(expression, options) { + var settings = new Settings(options); + return parseTree(expression, settings); +}; +/** + * If the given error is a KaTeX ParseError and options.throwOnError is false, + * renders the invalid LaTeX as a span with hover title giving the KaTeX + * error message. Otherwise, simply throws the error. + */ +var renderError = function renderError(error, expression, options) { + if (options.throwOnError || !(error instanceof ParseError)) { + throw error; + } + var node = makeSpan(["katex-error"], [new SymbolNode(expression)]); + node.setAttribute("title", error.toString()); + node.setAttribute("style", "color:" + options.errorColor); + return node; +}; +/** + * Generates and returns the katex build tree. This is used for advanced + * use cases (like rendering to custom output). + */ +var renderToDomTree = function renderToDomTree(expression, options) { + var settings = new Settings(options); + try { + var tree = parseTree(expression, settings); + return buildTree(tree, expression, settings); + } catch (error) { + return renderError(error, expression, settings); + } +}; +/** + * Generates and returns the katex build tree, with just HTML (no MathML). + * This is used for advanced use cases (like rendering to custom output). + */ +var renderToHTMLTree = function renderToHTMLTree(expression, options) { + var settings = new Settings(options); + try { + var tree = parseTree(expression, settings); + return buildHTMLTree(tree, expression, settings); + } catch (error) { + return renderError(error, expression, settings); + } +}; +var version = "0.16.47"; +var __domTree = { + Span, + Anchor, + SymbolNode, + SvgNode, + PathNode, + LineNode +}; +// CJS exports and ESM default export +var katex = { + /** + * Current KaTeX version + */ + version, + /** + * Renders the given LaTeX into an HTML+MathML combination, and adds + * it as a child to the specified DOM node. + */ + render, + /** + * Renders the given LaTeX into an HTML+MathML combination string, + * for sending to the client. + */ + renderToString, + /** + * KaTeX error, usually during parsing. + */ + ParseError, + /** + * The schema of Settings + */ + SETTINGS_SCHEMA, + /** + * Parses the given LaTeX into KaTeX's internal parse tree structure, + * without rendering to HTML or MathML. + * + * NOTE: This method is not currently recommended for public use. + * The internal tree representation is unstable and is very likely + * to change. Use at your own risk. + */ + __parse: generateParseTree, + /** + * Renders the given LaTeX into an HTML+MathML internal DOM tree + * representation, without flattening that representation to a string. + * + * NOTE: This method is not currently recommended for public use. + * The internal tree representation is unstable and is very likely + * to change. Use at your own risk. + */ + __renderToDomTree: renderToDomTree, + /** + * Renders the given LaTeX into an HTML internal DOM tree representation, + * without MathML and without flattening that representation to a string. + * + * NOTE: This method is not currently recommended for public use. + * The internal tree representation is unstable and is very likely + * to change. Use at your own risk. + */ + __renderToHTMLTree: renderToHTMLTree, + /** + * extends internal font metrics object with a new object + * each key in the new object represents a font name + */ + __setFontMetrics: setFontMetrics, + /** + * adds a new symbol to builtin symbols table + */ + __defineSymbol: defineSymbol, + /** + * adds a new function to builtin function list, + * which directly produce parse tree elements + * and have their own html/mathml builders + */ + __defineFunction: defineFunction, + /** + * adds a new macro to builtin macro list + */ + __defineMacro: defineMacro, + /** + * Expose the dom tree node types, which can be useful for type checking nodes. + * + * NOTE: These methods are not currently recommended for public use. + * The internal tree representation is unstable and is very likely + * to change. Use at your own risk. + */ + __domTree +}; + +export { ParseError, SETTINGS_SCHEMA, defineFunction as __defineFunction, defineMacro as __defineMacro, defineSymbol as __defineSymbol, __domTree, generateParseTree as __parse, renderToDomTree as __renderToDomTree, renderToHTMLTree as __renderToHTMLTree, setFontMetrics as __setFontMetrics, katex as default, render, renderToString, version }; diff --git a/node_modules/react-katex/node_modules/katex/katex.ts b/node_modules/react-katex/node_modules/katex/katex.ts new file mode 100644 index 0000000..ad47880 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/katex.ts @@ -0,0 +1,250 @@ +/* eslint no-console:0 */ +/** + * This is the main entry point for KaTeX. Here, we expose functions for + * rendering expressions either to DOM nodes or to markup strings. + * + * We also expose the ParseError class to check if errors thrown from KaTeX are + * errors in the expression, or errors in javascript handling. + */ + +import ParseError from "./src/ParseError"; +import Settings, {SETTINGS_SCHEMA} from "./src/Settings"; + +import {buildTree, buildHTMLTree} from "./src/buildTree"; +import parseTree from "./src/parseTree"; +import {makeSpan} from "./src/buildCommon"; +import { + Span, + Anchor, + SymbolNode, + SvgNode, + PathNode, + LineNode, +} from "./src/domTree"; + +import type {SettingsOptions} from "./src/Settings"; +import type {AnyParseNode} from "./src/parseNode"; +import type {DomSpan} from "./src/domTree"; + +import {defineSymbol} from './src/symbols'; +import defineFunction from './src/defineFunction'; +import defineMacro from './src/defineMacro'; +import {setFontMetrics} from './src/fontMetrics'; + +declare let __VERSION__: string; + +/** + * Parse and build an expression, and place that expression in the DOM node + * given. + */ +let render: ( + expression: string, + baseNode: Node, + options: SettingsOptions, +) => void = function( + expression: string, + baseNode: Node, + options: SettingsOptions, +) { + baseNode.textContent = ""; + const node = renderToDomTree(expression, options).toNode(); + baseNode.appendChild(node); +}; + +// KaTeX's styles don't work properly in quirks mode. Print out an error, and +// disable rendering. +if (typeof document !== "undefined") { + if (document.compatMode !== "CSS1Compat") { + typeof console !== "undefined" && console.warn( + "Warning: KaTeX doesn't work in quirks mode. Make sure your " + + "website has a suitable doctype."); + + render = function() { + throw new ParseError("KaTeX doesn't work in quirks mode."); + }; + } +} + +/** + * Parse and build an expression, and return the markup for that. + */ +const renderToString = function( + expression: string, + options: SettingsOptions, +): string { + const markup = renderToDomTree(expression, options).toMarkup(); + return markup; +}; + +/** + * Parse an expression and return the parse tree. + */ +const generateParseTree = function( + expression: string, + options?: SettingsOptions, +): AnyParseNode[] { + const settings = new Settings(options); + return parseTree(expression, settings); +}; + +/** + * If the given error is a KaTeX ParseError and options.throwOnError is false, + * renders the invalid LaTeX as a span with hover title giving the KaTeX + * error message. Otherwise, simply throws the error. + */ +const renderError = function( + error: unknown, + expression: string, + options: Settings, +) { + if (options.throwOnError || !(error instanceof ParseError)) { + throw error; + } + const node = makeSpan(["katex-error"], + [new SymbolNode(expression)]); + node.setAttribute("title", error.toString()); + node.setAttribute("style", `color:${options.errorColor}`); + return node; +}; + +/** + * Generates and returns the katex build tree. This is used for advanced + * use cases (like rendering to custom output). + */ +const renderToDomTree = function( + expression: string, + options: SettingsOptions, +): DomSpan { + const settings = new Settings(options); + try { + const tree = parseTree(expression, settings); + return buildTree(tree, expression, settings); + } catch (error) { + return renderError(error, expression, settings); + } +}; + +/** + * Generates and returns the katex build tree, with just HTML (no MathML). + * This is used for advanced use cases (like rendering to custom output). + */ +const renderToHTMLTree = function( + expression: string, + options: SettingsOptions, +): DomSpan { + const settings = new Settings(options); + try { + const tree = parseTree(expression, settings); + return buildHTMLTree(tree, expression, settings); + } catch (error) { + return renderError(error, expression, settings); + } +}; + +const version = __VERSION__; + +const __domTree = { + Span, + Anchor, + SymbolNode, + SvgNode, + PathNode, + LineNode, +}; + +// ESM exports +export { + version, + render, + renderToString, + ParseError, + SETTINGS_SCHEMA, + generateParseTree as __parse, + renderToDomTree as __renderToDomTree, + renderToHTMLTree as __renderToHTMLTree, + setFontMetrics as __setFontMetrics, + defineSymbol as __defineSymbol, + defineFunction as __defineFunction, + defineMacro as __defineMacro, + __domTree, +}; + +// CJS exports and ESM default export +export default { + /** + * Current KaTeX version + */ + version, + /** + * Renders the given LaTeX into an HTML+MathML combination, and adds + * it as a child to the specified DOM node. + */ + render, + /** + * Renders the given LaTeX into an HTML+MathML combination string, + * for sending to the client. + */ + renderToString, + /** + * KaTeX error, usually during parsing. + */ + ParseError, + /** + * The schema of Settings + */ + SETTINGS_SCHEMA, + /** + * Parses the given LaTeX into KaTeX's internal parse tree structure, + * without rendering to HTML or MathML. + * + * NOTE: This method is not currently recommended for public use. + * The internal tree representation is unstable and is very likely + * to change. Use at your own risk. + */ + __parse: generateParseTree, + /** + * Renders the given LaTeX into an HTML+MathML internal DOM tree + * representation, without flattening that representation to a string. + * + * NOTE: This method is not currently recommended for public use. + * The internal tree representation is unstable and is very likely + * to change. Use at your own risk. + */ + __renderToDomTree: renderToDomTree, + /** + * Renders the given LaTeX into an HTML internal DOM tree representation, + * without MathML and without flattening that representation to a string. + * + * NOTE: This method is not currently recommended for public use. + * The internal tree representation is unstable and is very likely + * to change. Use at your own risk. + */ + __renderToHTMLTree: renderToHTMLTree, + /** + * extends internal font metrics object with a new object + * each key in the new object represents a font name + */ + __setFontMetrics: setFontMetrics, + /** + * adds a new symbol to builtin symbols table + */ + __defineSymbol: defineSymbol, + /** + * adds a new function to builtin function list, + * which directly produce parse tree elements + * and have their own html/mathml builders + */ + __defineFunction: defineFunction, + /** + * adds a new macro to builtin macro list + */ + __defineMacro: defineMacro, + /** + * Expose the dom tree node types, which can be useful for type checking nodes. + * + * NOTE: These methods are not currently recommended for public use. + * The internal tree representation is unstable and is very likely + * to change. Use at your own risk. + */ + __domTree, +}; diff --git a/node_modules/react-katex/node_modules/katex/package.json b/node_modules/react-katex/node_modules/katex/package.json new file mode 100644 index 0000000..cfdaf5d --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/package.json @@ -0,0 +1,198 @@ +{ + "name": "katex", + "version": "0.16.47", + "description": "Fast math typesetting for the web.", + "main": "dist/katex.js", + "types": "types/katex.d.ts", + "exports": { + ".": { + "require": { + "types": "./types/katex.d.ts", + "default": "./dist/katex.js" + }, + "import": { + "types": "./types/katex.d.ts", + "default": "./dist/katex.mjs" + } + }, + "./contrib/auto-render": { + "require": "./dist/contrib/auto-render.js", + "import": "./dist/contrib/auto-render.mjs" + }, + "./contrib/mhchem": { + "require": "./dist/contrib/mhchem.js", + "import": "./dist/contrib/mhchem.mjs" + }, + "./contrib/copy-tex": { + "require": "./dist/contrib/copy-tex.js", + "import": "./dist/contrib/copy-tex.mjs" + }, + "./contrib/mathtex-script-type": { + "require": "./dist/contrib/mathtex-script-type.js", + "import": "./dist/contrib/mathtex-script-type.mjs" + }, + "./contrib/render-a11y-string": { + "require": "./dist/contrib/render-a11y-string.js", + "import": "./dist/contrib/render-a11y-string.mjs" + }, + "./*": "./*" + }, + "homepage": "https://katex.org", + "repository": { + "type": "git", + "url": "https://github.com/KaTeX/KaTeX.git" + }, + "funding": [ + "https://opencollective.com/katex", + "https://github.com/sponsors/katex" + ], + "files": [ + "katex.ts", + "cli.js", + "src/", + "contrib/", + "dist/", + "types/" + ], + "license": "MIT", + "packageManager": "yarn@4.1.1", + "devDependencies": { + "@babel/core": "^7.29.0", + "@babel/plugin-proposal-class-properties": "^7.18.6", + "@babel/plugin-transform-react-jsx": "^7.28.6", + "@babel/plugin-transform-runtime": "^7.29.0", + "@babel/preset-env": "^7.29.0", + "@babel/preset-react": "^7.28.5", + "@babel/preset-typescript": "^7.28.5", + "@babel/register": "^7.28.6", + "@babel/runtime": "^7.28.6", + "@eslint/eslintrc": "^3.3.5", + "@eslint/js": "^10.0.1", + "@rollup/plugin-babel": "^5.3.1", + "@rollup/plugin-commonjs": "^28.0.9", + "@rollup/plugin-typescript": "^12.3.0", + "@semantic-release/changelog": "^6.0.1", + "@semantic-release/git": "^10.0.1", + "@stylistic/stylelint-plugin": "^5.1.0", + "@typescript-eslint/eslint-plugin": "^8.59.1", + "@typescript-eslint/parser": "^8.59.1", + "babel-jest": "^30.2.0", + "babel-loader": "^8.2.5", + "babel-plugin-istanbul": "^6.1.1", + "babel-plugin-preval": "^5.1.0", + "babel-plugin-version-inline": "^1.0.0", + "benchmark": "^2.1.4", + "browserslist": "^4.21.3", + "caniuse-lite": "^1.0.30001384", + "css-loader": "^6.7.1", + "cssnano": "^5.1.13", + "eslint": "^10.0.3", + "eslint-plugin-actions": "^2.0.0", + "eslint-plugin-react": "^7.37.5", + "fs-extra": "^10.1.0", + "globals": "^17.6.0", + "got": "^11.8.5", + "husky": "^4.3.8", + "istanbul-lib-coverage": "^3.2.0", + "istanbul-lib-report": "^3.0.0", + "istanbul-reports": "^3.1.5", + "jest": "^30.2.0", + "jest-diff": "^30.2.0", + "jest-environment-jsdom": "^30.2.0", + "jest-matcher-utils": "^30.2.0", + "jest-message-util": "^30.2.0", + "jest-serializer-html": "^7.1.0", + "js-yaml": "^4.1.0", + "json-stable-stringify": "^1.0.1", + "jspngopt": "^0.2.0", + "mini-css-extract-plugin": "^2.6.1", + "mkdirp": "^1.0.4", + "p-retry": "^4.6.2", + "pako": "^2.0.4", + "postcss": "^8.4.16", + "postcss-loader": "^7.0.1", + "postcss-preset-env": "^7.8.0", + "postcss-scss": "^4.0.9", + "rimraf": "^3.0.2", + "rollup": "^2.79.2", + "sass": "^1.94.2", + "sass-loader": "^16.0.6", + "selenium-webdriver": "^4.4.0", + "semantic-release": "^19.0.5", + "sri-toolbox": "^0.2.0", + "style-loader": "^3.3.1", + "stylelint": "^17.9.1", + "stylelint-config-standard": "^40.0.0", + "stylelint-scss": "^7.0.0", + "terser-webpack-plugin": "^5.3.6", + "tslib": "^2.8.1", + "typescript": "^5.9.3", + "webpack": "^5.74.0", + "webpack-bundle-analyzer": "^5.0.0", + "webpack-cli": "^5.0.0", + "webpack-dev-server": "^5.0.0", + "webpack-remove-empty-scripts": "^1.0.4" + }, + "bin": "cli.js", + "scripts": { + "test": "yarn test:lint && yarn test:ts && yarn test:jest", + "test:lint": "yarn test:lint:js && yarn test:lint:css", + "test:lint:js": "eslint .", + "test:lint:css": "stylelint src/styles/katex.scss static/main.css website/static/**/*.css", + "test:jest": "jest", + "test:jest:watch": "jest --watch", + "test:jest:update": "jest --updateSnapshot", + "test:jest:coverage": "jest --coverage", + "test:screenshots": "yarn test:screenshots:update --verify", + "test:screenshots:update": "dockers/screenshotter/screenshotter.sh", + "test:perf": "NODE_ENV=test node -e \"require('@babel/register')({extensions:['.js','.ts']}); require('./test/perf-test.ts')\"", + "test:ts": "tsc --noEmit", + "test:build": "node test/verify-build.js", + "clean": "rm -rf dist/ node_modules/", + "clean-install": "yarn clean && yarn", + "start": "webpack serve --config webpack.dev.js", + "analyze": "webpack --config webpack.analyze.js", + "build": "rimraf dist/ && mkdirp dist && cp README.md dist && rollup -c --failAfterWarnings && webpack && node update-sri.js package dist/README.md", + "build:fonts": "dockers/fonts/buildFonts.sh", + "build:metrics": "dockers/fonts/buildMetrics.sh", + "watch": "yarn build --watch", + "postversion": "yarn dist && node update-sri.js package README.md contrib/*/README.md docs/*.md website/pages/index.html", + "semantic-release": "semantic-release", + "dist": "yarn build && yarn dist:zip", + "dist:zip": "rimraf katex/ katex.tar.gz katex.zip && cp -R dist katex && tar czf katex.tar.gz katex && zip -rq katex.zip katex && rimraf katex/" + }, + "dependencies": { + "commander": "^8.3.0" + }, + "husky": { + "hooks": { + "pre-commit": "yarn test:lint" + } + }, + "jest": { + "collectCoverageFrom": [ + "src/**/*.{js,ts}", + "contrib/**/*.{js,ts}", + "!src/unicodeSymbols.{js,ts}", + "!contrib/mhchem/**" + ], + "setupFilesAfterEnv": [ + "/test/setup.ts" + ], + "snapshotSerializers": [ + "jest-serializer-html" + ], + "testMatch": [ + "**/test/*-spec.ts" + ], + "testEnvironmentOptions": { + "url": "http://localhost/" + }, + "transform": { + "^.+\\.(js|ts)$": "babel-jest" + }, + "moduleNameMapper": { + "^katex$": "/katex.ts" + } + } +} diff --git a/node_modules/react-katex/node_modules/katex/src/Lexer.ts b/node_modules/react-katex/node_modules/katex/src/Lexer.ts new file mode 100644 index 0000000..ad3ac38 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/Lexer.ts @@ -0,0 +1,121 @@ +/** + * The Lexer class handles tokenizing the input in various ways. Since our + * parser expects us to be able to backtrack, the lexer allows lexing from any + * given starting point. + * + * Its main exposed function is the `lex` function, which takes a position to + * lex from and a type of token to lex. It defers to the appropriate `_innerLex` + * function. + * + * The various `_innerLex` functions perform the actual lexing of different + * kinds. + */ + +import ParseError from "./ParseError"; +import SourceLocation from "./SourceLocation"; +import {Token} from "./Token"; + +import type {LexerInterface} from "./Token"; +import type Settings from "./Settings"; + +/* The following tokenRegex + * - matches typical whitespace (but not NBSP etc.) using its first group + * - does not match any control character \x00-\x1f except whitespace + * - does not match a bare backslash + * - matches any ASCII character except those just mentioned + * - does not match the BMP private use area \uE000-\uF8FF + * - does not match bare surrogate code units + * - matches any BMP character except for those just described + * - matches any valid Unicode surrogate pair + * - matches a backslash followed by one or more whitespace characters + * - matches a backslash followed by one or more letters then whitespace + * - matches a backslash followed by any BMP character + * Capturing groups: + * [1] regular whitespace + * [2] backslash followed by whitespace + * [3] anything else, which may include: + * [4] left character of \verb* + * [5] left character of \verb + * [6] backslash followed by word, excluding any trailing whitespace + * Just because the Lexer matches something doesn't mean it's valid input: + * If there is no matching function or symbol definition, the Parser will + * still reject the input. + */ +const spaceRegexString = "[ \r\n\t]"; +const controlWordRegexString = "\\\\[a-zA-Z@]+"; +const controlSymbolRegexString = "\\\\[^\uD800-\uDFFF]"; +const controlWordWhitespaceRegexString = + `(${controlWordRegexString})${spaceRegexString}*`; +const controlSpaceRegexString = "\\\\(\n|[ \r\t]+\n?)[ \r\t]*"; +const combiningDiacriticalMarkString = "[\u0300-\u036f]"; +export const combiningDiacriticalMarksEndRegex: RegExp = + new RegExp(`${combiningDiacriticalMarkString}+$`); +const tokenRegexString = `(${spaceRegexString}+)|` + // whitespace + `${controlSpaceRegexString}|` + // \whitespace + "([!-\\[\\]-\u2027\u202A-\uD7FF\uF900-\uFFFF]" + // single codepoint + `${combiningDiacriticalMarkString}*` + // ...plus accents + "|[\uD800-\uDBFF][\uDC00-\uDFFF]" + // surrogate pair + `${combiningDiacriticalMarkString}*` + // ...plus accents + "|\\\\verb\\*([^]).*?\\4" + // \verb* + "|\\\\verb([^*a-zA-Z]).*?\\5" + // \verb unstarred + `|${controlWordWhitespaceRegexString}` + // \macroName + spaces + `|${controlSymbolRegexString})`; // \\, \', etc. + +/** Main Lexer class */ +export default class Lexer implements LexerInterface { + input: string; + settings: Settings; + tokenRegex: RegExp; + // Category codes. The lexer only supports comment characters (14) for now. + // MacroExpander additionally distinguishes active (13). + catcodes: Record; + + constructor(input: string, settings: Settings) { + // Separate accents from characters + this.input = input; + this.settings = settings; + this.tokenRegex = new RegExp(tokenRegexString, 'g'); + this.catcodes = { + "%": 14, // comment character + "~": 13, // active character + }; + } + + setCatcode(char: string, code: number) { + this.catcodes[char] = code; + } + + /** + * This function lexes a single token. + */ + lex(): Token { + const input = this.input; + const pos = this.tokenRegex.lastIndex; + if (pos === input.length) { + return new Token("EOF", new SourceLocation(this, pos, pos)); + } + const match = this.tokenRegex.exec(input); + if (match === null || match.index !== pos) { + throw new ParseError( + `Unexpected character: '${input[pos]}'`, + new Token(input[pos], new SourceLocation(this, pos, pos + 1))); + } + const text = match[6] || match[3] || (match[2] ? "\\ " : " "); + + if (this.catcodes[text] === 14) { // comment character + const nlIndex = input.indexOf('\n', this.tokenRegex.lastIndex); + if (nlIndex === -1) { + this.tokenRegex.lastIndex = input.length; // EOF + this.settings.reportNonstrict("commentAtEnd", + "% comment has no terminating newline; LaTeX would " + + "fail because of commenting the end of math mode (e.g. $)"); + } else { + this.tokenRegex.lastIndex = nlIndex + 1; + } + return this.lex(); + } + + return new Token(text, new SourceLocation(this, pos, + this.tokenRegex.lastIndex)); + } +} diff --git a/node_modules/react-katex/node_modules/katex/src/MacroExpander.ts b/node_modules/react-katex/node_modules/katex/src/MacroExpander.ts new file mode 100644 index 0000000..548724a --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/MacroExpander.ts @@ -0,0 +1,467 @@ +/** + * This file contains the “gullet” where macros are expanded + * until only non-macro tokens remain. + */ + +import functions from "./functions"; +import symbols from "./symbols"; +import Lexer from "./Lexer"; +import {Token} from "./Token"; +import type {Mode} from "./types"; +import ParseError from "./ParseError"; +import SourceLocation from "./SourceLocation"; +import Namespace from "./Namespace"; +import macros from "./macros"; + +import type {MacroContextInterface, MacroDefinition, MacroExpansion, MacroArg} + from "./defineMacro"; +import type Settings from "./Settings"; + +// List of commands that act like macros but aren't defined as a macro, +// function, or symbol. Used in `isDefined`. +export const implicitCommands = { + "^": true, // Parser.js + "_": true, // Parser.js + "\\limits": true, // Parser.js + "\\nolimits": true, // Parser.js +}; + +export default class MacroExpander implements MacroContextInterface { + settings: Settings; + expansionCount: number; + lexer!: Lexer; + macros: Namespace; + stack: Token[]; + mode: Mode; + + constructor(input: string, settings: Settings, mode: Mode) { + this.settings = settings; + this.expansionCount = 0; + this.feed(input); + // Make new global namespace + this.macros = new Namespace(macros, settings.macros); + this.mode = mode; + this.stack = []; // contains tokens in REVERSE order + } + + /** + * Feed a new input string to the same MacroExpander + * (with existing macros etc.). + */ + feed(input: string) { + this.lexer = new Lexer(input, this.settings); + } + + /** + * Switches between "text" and "math" modes. + */ + switchMode(newMode: Mode) { + this.mode = newMode; + } + + /** + * Start a new group nesting within all namespaces. + */ + beginGroup() { + this.macros.beginGroup(); + } + + /** + * End current group nesting within all namespaces. + */ + endGroup() { + this.macros.endGroup(); + } + + /** + * Ends all currently nested groups (if any), restoring values before the + * groups began. Useful in case of an error in the middle of parsing. + */ + endGroups() { + this.macros.endGroups(); + } + + /** + * Returns the topmost token on the stack, without expanding it. + * Similar in behavior to TeX's `\futurelet`. + */ + future(): Token { + if (this.stack.length === 0) { + this.pushToken(this.lexer.lex()); + } + return this.stack[this.stack.length - 1]; + } + + /** + * Remove and return the next unexpanded token. + */ + popToken(): Token { + this.future(); // ensure non-empty stack + return this.stack.pop()!; + } + + /** + * Add a given token to the token stack. In particular, this get be used + * to put back a token returned from one of the other methods. + */ + pushToken(token: Token) { + this.stack.push(token); + } + + /** + * Append an array of tokens to the token stack. + */ + pushTokens(tokens: Token[]) { + this.stack.push(...tokens); + } + + /** + * Find an macro argument without expanding tokens and append the array of + * tokens to the token stack. Uses Token as a container for the result. + */ + scanArgument(isOptional: boolean): Token | null | undefined { + let start; + let end; + let tokens; + if (isOptional) { + this.consumeSpaces(); // \@ifnextchar gobbles any space following it + if (this.future().text !== "[") { + return null; + } + start = this.popToken(); // don't include [ in tokens + ({tokens, end} = this.consumeArg(["]"])); + } else { + ({tokens, start, end} = this.consumeArg()); + } + + // indicate the end of an argument + this.pushToken(new Token("EOF", end.loc)); + + this.pushTokens(tokens); + return new Token("", SourceLocation.range(start, end)); + } + + /** + * Consume all following space tokens, without expansion. + */ + consumeSpaces() { + for (;;) { + const token = this.future(); + if (token.text === " ") { + this.stack.pop(); + } else { + break; + } + } + } + + /** + * Consume an argument from the token stream, and return the resulting array + * of tokens and start/end token. + */ + consumeArg(delims?: string[] | null | undefined): MacroArg { + // The argument for a delimited parameter is the shortest (possibly + // empty) sequence of tokens with properly nested {...} groups that is + // followed ... by this particular list of non-parameter tokens. + // The argument for an undelimited parameter is the next nonblank + // token, unless that token is ‘{’, when the argument will be the + // entire {...} group that follows. + const tokens: Token[] = []; + const isDelimited = delims && delims.length > 0; + if (!isDelimited) { + // Ignore spaces between arguments. As the TeXbook says: + // "After you have said ‘\def\row#1#2{...}’, you are allowed to + // put spaces between the arguments (e.g., ‘\row x n’), because + // TeX doesn’t use single spaces as undelimited arguments." + this.consumeSpaces(); + } + const start = this.future(); + let tok; + let depth = 0; + let match = 0; + do { + tok = this.popToken(); + tokens.push(tok); + if (tok.text === "{") { + ++depth; + } else if (tok.text === "}") { + --depth; + if (depth === -1) { + throw new ParseError("Extra }", tok); + } + } else if (tok.text === "EOF") { + throw new ParseError("Unexpected end of input in a macro argument" + + ", expected '" + (delims && isDelimited ? delims[match] : "}") + + "'", tok); + } + if (delims && isDelimited) { + if ((depth === 0 || (depth === 1 && delims[match] === "{")) && + tok.text === delims[match]) { + ++match; + if (match === delims.length) { + // don't include delims in tokens + tokens.splice(-match, match); + break; + } + } else { + match = 0; + } + } + } while (depth !== 0 || isDelimited); + // If the argument found ... has the form ‘{}’, + // ... the outermost braces enclosing the argument are removed + if (start.text === "{" && tokens[tokens.length - 1].text === "}") { + tokens.pop(); + tokens.shift(); + } + tokens.reverse(); // to fit in with stack order + return {tokens, start, end: tok}; + } + + /** + * Consume the specified number of (delimited) arguments from the token + * stream and return the resulting array of arguments. + */ + consumeArgs(numArgs: number, delimiters?: string[][]): Token[][] { + if (delimiters) { + if (delimiters.length !== numArgs + 1) { + throw new ParseError( + "The length of delimiters doesn't match the number of args!"); + } + const delims = delimiters[0]; + for (let i = 0; i < delims.length; i++) { + const tok = this.popToken(); + if (delims[i] !== tok.text) { + throw new ParseError( + "Use of the macro doesn't match its definition", tok); + } + } + } + + const args: Token[][] = []; + for (let i = 0; i < numArgs; i++) { + args.push(this.consumeArg(delimiters && delimiters[i + 1]).tokens); + } + return args; + } + + /** + * Increment `expansionCount` by the specified amount. + * Throw an error if it exceeds `maxExpand`. + */ + countExpansion(amount: number): void { + this.expansionCount += amount; + if (this.expansionCount > this.settings.maxExpand) { + throw new ParseError("Too many expansions: infinite loop or " + + "need to increase maxExpand setting"); + } + } + + /** + * Expand the next token only once if possible. + * + * If the token is expanded, the resulting tokens will be pushed onto + * the stack in reverse order, and the number of such tokens will be + * returned. This number might be zero or positive. + * + * If not, the return value is `false`, and the next token remains at the + * top of the stack. + * + * In either case, the next token will be on the top of the stack, + * or the stack will be empty (in case of empty expansion + * and no other tokens). + * + * Used to implement `expandAfterFuture` and `expandNextToken`. + * + * If expandableOnly, only expandable tokens are expanded and + * an undefined control sequence results in an error. + */ + expandOnce(expandableOnly?: boolean): number | boolean { + const topToken = this.popToken(); + const name = topToken.text; + const expansion = !topToken.noexpand ? this._getExpansion(name) : null; + if (expansion == null || (expandableOnly && expansion.unexpandable)) { + if (expandableOnly && expansion == null && + name[0] === "\\" && !this.isDefined(name)) { + throw new ParseError("Undefined control sequence: " + name); + } + this.pushToken(topToken); + return false; + } + this.countExpansion(1); + let tokens = expansion.tokens; + const args = this.consumeArgs(expansion.numArgs, expansion.delimiters); + if (expansion.numArgs) { + // paste arguments in place of the placeholders + tokens = tokens.slice(); // make a shallow copy + for (let i = tokens.length - 1; i >= 0; --i) { + let tok = tokens[i]; + if (tok.text === "#") { + if (i === 0) { + throw new ParseError( + "Incomplete placeholder at end of macro body", + tok); + } + tok = tokens[--i]; // next token on stack + if (tok.text === "#") { // ## → # + tokens.splice(i + 1, 1); // drop first # + } else if (/^[1-9]$/.test(tok.text)) { + // replace the placeholder with the indicated argument + tokens.splice(i, 2, ...args[+tok.text - 1]); + } else { + throw new ParseError( + "Not a valid argument number", + tok); + } + } + } + } + // Concatenate expansion onto top of stack. + this.pushTokens(tokens); + return tokens.length; + } + + /** + * Expand the next token only once (if possible), and return the resulting + * top token on the stack (without removing anything from the stack). + * Similar in behavior to TeX's `\expandafter\futurelet`. + * Equivalent to expandOnce() followed by future(). + */ + expandAfterFuture(): Token { + this.expandOnce(); + return this.future(); + } + + /** + * Recursively expand first token, then return first non-expandable token. + */ + expandNextToken(): Token { + for (;;) { + if (this.expandOnce() === false) { // fully expanded + const token = this.stack.pop()!; + // the token after \noexpand is interpreted as if its meaning + // were ‘\relax’ + if (token.treatAsRelax) { + token.text = "\\relax"; + } + return token; + } + } + } + + /** + * Fully expand the given macro name and return the resulting list of + * tokens, or return `undefined` if no such macro is defined. + */ + expandMacro(name: string): Token[] | undefined { + return this.macros.has(name) + ? this.expandTokens([new Token(name)]) : undefined; + } + + /** + * Fully expand the given token stream and return the resulting list of + * tokens. Note that the input tokens are in reverse order, but the + * output tokens are in forward order. + */ + expandTokens(tokens: Token[]): Token[] { + const output: Token[] = []; + const oldStackLength = this.stack.length; + this.pushTokens(tokens); + while (this.stack.length > oldStackLength) { + // Expand only expandable tokens + if (this.expandOnce(true) === false) { // fully expanded + const token = this.stack.pop()!; + if (token.treatAsRelax) { + // the expansion of \noexpand is the token itself + token.noexpand = false; + token.treatAsRelax = false; + } + output.push(token); + } + } + // Count all of these tokens as additional expansions, to prevent + // exponential blowup from linearly many \edef's. + this.countExpansion(output.length); + return output; + } + + /** + * Fully expand the given macro name and return the result as a string, + * or return `undefined` if no such macro is defined. + */ + expandMacroAsText(name: string): string | undefined { + const tokens = this.expandMacro(name); + if (tokens) { + return tokens.map((token) => token.text).join(""); + } else { + return tokens; + } + } + + /** + * Returns the expanded macro as a reversed array of tokens and a macro + * argument count. Or returns `null` if no such macro. + */ + _getExpansion(name: string): MacroExpansion | null | undefined { + const definition = this.macros.get(name); + + if (definition == null) { // mainly checking for undefined here + return definition; + } + // If a single character has an associated catcode other than 13 + // (active character), then don't expand it. + if (name.length === 1) { + const catcode = this.lexer.catcodes[name]; + if (catcode != null && catcode !== 13) { + return; + } + } + const expansion = + typeof definition === "function" ? definition(this) : definition; + if (typeof expansion === "string") { + let numArgs = 0; + if (expansion.includes("#")) { + const stripped = expansion.replace(/##/g, ""); + while (stripped.includes("#" + (numArgs + 1))) { + ++numArgs; + } + } + const bodyLexer = new Lexer(expansion, this.settings); + const tokens = []; + let tok = bodyLexer.lex(); + while (tok.text !== "EOF") { + tokens.push(tok); + tok = bodyLexer.lex(); + } + tokens.reverse(); // to fit in with stack using push and pop + const expanded = {tokens, numArgs}; + return expanded; + } + + return expansion; + } + + /** + * Determine whether a command is currently "defined" (has some + * functionality), meaning that it's a macro (in the current group), + * a function, a symbol, or one of the special commands listed in + * `implicitCommands`. + */ + isDefined(name: string): boolean { + return this.macros.has(name) || + functions.hasOwnProperty(name) || + symbols.math.hasOwnProperty(name) || + symbols.text.hasOwnProperty(name) || + implicitCommands.hasOwnProperty(name); + } + + /** + * Determine whether a command is expandable. + */ + isExpandable(name: string): boolean { + const macro = this.macros.get(name); + return macro != null ? typeof macro === "string" + || typeof macro === "function" || !macro.unexpandable + : functions.hasOwnProperty(name) && !functions[name].primitive; + } +} diff --git a/node_modules/react-katex/node_modules/katex/src/Namespace.ts b/node_modules/react-katex/node_modules/katex/src/Namespace.ts new file mode 100644 index 0000000..523fa32 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/Namespace.ts @@ -0,0 +1,127 @@ + +/** + * A `Namespace` refers to a space of nameable things like macros or lengths, + * which can be `set` either globally or local to a nested group, using an + * undo stack similar to how TeX implements this functionality. + * Performance-wise, `get` and local `set` take constant time, while global + * `set` takes time proportional to the depth of group nesting. + */ + +import ParseError from "./ParseError"; +export type Mapping = Record; + +export default class Namespace { + current: Mapping; + builtins: Mapping; + undefStack: Mapping[]; + + /** + * Both arguments are optional. The first argument is an object of + * built-in mappings which never change. The second argument is an object + * of initial (global-level) mappings, which will constantly change + * according to any global/top-level `set`s done. + */ + constructor(builtins: Mapping = {}, + globalMacros: Mapping = {}) { + this.current = globalMacros; + this.builtins = builtins; + this.undefStack = []; + } + + /** + * Start a new nested group, affecting future local `set`s. + */ + beginGroup() { + this.undefStack.push({}); + } + + /** + * End current nested group, restoring values before the group began. + */ + endGroup() { + if (this.undefStack.length === 0) { + throw new ParseError("Unbalanced namespace destruction: attempt " + + "to pop global namespace; please report this as a bug"); + } + const undefs = this.undefStack.pop(); + for (const undef in undefs) { + if (undefs.hasOwnProperty(undef)) { + if (undefs[undef] == null) { + delete this.current[undef]; + } else { + this.current[undef] = undefs[undef]; + } + } + } + } + + /** + * Ends all currently nested groups (if any), restoring values before the + * groups began. Useful in case of an error in the middle of parsing. + */ + endGroups() { + while (this.undefStack.length > 0) { + this.endGroup(); + } + } + + /** + * Detect whether `name` has a definition. Equivalent to + * `get(name) != null`. + */ + has(name: string): boolean { + return this.current.hasOwnProperty(name) || + this.builtins.hasOwnProperty(name); + } + + /** + * Get the current value of a name, or `undefined` if there is no value. + * + * Note: Do not use `if (namespace.get(...))` to detect whether a macro + * is defined, as the definition may be the empty string which evaluates + * to `false` in JavaScript. Use `if (namespace.get(...) != null)` or + * `if (namespace.has(...))`. + */ + get(name: string): Value | null | undefined { + if (this.current.hasOwnProperty(name)) { + return this.current[name]; + } else { + return this.builtins[name]; + } + } + + /** + * Set the current value of a name, and optionally set it globally too. + * Local set() sets the current value and (when appropriate) adds an undo + * operation to the undo stack. Global set() may change the undo + * operation at every level, so takes time linear in their number. + * A value of undefined means to delete existing definitions. + */ + set(name: string, value: Value | null | undefined, global: boolean = false) { + if (global) { + // Global set is equivalent to setting in all groups. Simulate this + // by destroying any undos currently scheduled for this name, + // and adding an undo with the *new* value (in case it later gets + // locally reset within this environment). + for (let i = 0; i < this.undefStack.length; i++) { + delete this.undefStack[i][name]; + } + if (this.undefStack.length > 0) { + this.undefStack[this.undefStack.length - 1][name] = value; + } + } else { + // Undo this set at end of this group (possibly to `undefined`), + // unless an undo is already in place, in which case that older + // value is the correct one. + const top = this.undefStack[this.undefStack.length - 1]; + if (top && !top.hasOwnProperty(name)) { + top[name] = this.current[name]; + } + } + if (value == null) { + delete this.current[name]; + } else { + this.current[name] = value; + } + } +} diff --git a/node_modules/react-katex/node_modules/katex/src/Options.ts b/node_modules/react-katex/node_modules/katex/src/Options.ts new file mode 100644 index 0000000..5a54af8 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/Options.ts @@ -0,0 +1,315 @@ +/** + * This file contains information about the options that the Parser carries + * around with it while parsing. Data is held in an `Options` object, and when + * recursing, a new `Options` object can be created with the `.with*` and + * `.reset` functions. + */ + +import {getGlobalMetrics} from "./fontMetrics"; +import type {StyleInterface} from "./Style"; +import type {FontMetrics, MathFont, TextFont, FontWeight, FontShape} from "./types/fonts"; + +const sizeStyleMap = [ + // Each element contains [textsize, scriptsize, scriptscriptsize]. + // The size mappings are taken from TeX with \normalsize=10pt. + [1, 1, 1], // size1: [5, 5, 5] \tiny + [2, 1, 1], // size2: [6, 5, 5] + [3, 1, 1], // size3: [7, 5, 5] \scriptsize + [4, 2, 1], // size4: [8, 6, 5] \footnotesize + [5, 2, 1], // size5: [9, 6, 5] \small + [6, 3, 1], // size6: [10, 7, 5] \normalsize + [7, 4, 2], // size7: [12, 8, 6] \large + [8, 6, 3], // size8: [14.4, 10, 7] \Large + [9, 7, 6], // size9: [17.28, 12, 10] \LARGE + [10, 8, 7], // size10: [20.74, 14.4, 12] \huge + [11, 10, 9], // size11: [24.88, 20.74, 17.28] \HUGE +]; + +const sizeMultipliers = [ + // fontMetrics.js:getGlobalMetrics also uses size indexes, so if + // you change size indexes, change that function. + 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.2, 1.44, 1.728, 2.074, 2.488, +]; + +const sizeAtStyle = function(size: number, style: StyleInterface): number { + return style.size < 2 ? size : sizeStyleMap[size - 1][style.size - 1]; +}; + +export type OptionsData = { + style: StyleInterface; + color?: string | undefined; + size?: number; + textSize?: number; + phantom?: boolean; + font?: MathFont; + fontFamily?: TextFont; + fontWeight?: FontWeight; + fontShape?: FontShape; + sizeMultiplier?: number; + maxSize: number; + minRuleThickness: number; +}; + +/** + * This is the main options class. It contains the current style, size, color, + * and font. + * + * Options objects should not be modified. To create a new Options with + * different properties, call a `.having*` method. + */ +class Options { + style: StyleInterface; + color: string | undefined; + size: number; + textSize: number; + phantom: boolean; + // A font family applies to a group of fonts (i.e. SansSerif), while a font + // represents a specific font (i.e. SansSerif Bold). + // See: https://tex.stackexchange.com/questions/22350/difference-between-textrm-and-mathrm + font: MathFont; + fontFamily: TextFont; + fontWeight: FontWeight; + fontShape: FontShape; + sizeMultiplier: number; + maxSize: number; + minRuleThickness: number; + _fontMetrics: FontMetrics | undefined; + + /** + * The base size index. + */ + static BASESIZE: number = 6; + + constructor(data: OptionsData) { + this.style = data.style; + this.color = data.color; + this.size = data.size || Options.BASESIZE; + this.textSize = data.textSize || this.size; + this.phantom = !!data.phantom; + this.font = data.font || ""; + this.fontFamily = data.fontFamily || ""; + this.fontWeight = data.fontWeight || ""; + this.fontShape = data.fontShape || ""; + this.sizeMultiplier = sizeMultipliers[this.size - 1]; + this.maxSize = data.maxSize; + this.minRuleThickness = data.minRuleThickness; + this._fontMetrics = undefined; + } + + /** + * Returns a new options object with the same properties as "this". Properties + * from "extension" will be copied to the new options object. + */ + extend(extension: Partial): Options { + const data: OptionsData = { + style: this.style, + size: this.size, + textSize: this.textSize, + color: this.color, + phantom: this.phantom, + font: this.font, + fontFamily: this.fontFamily, + fontWeight: this.fontWeight, + fontShape: this.fontShape, + maxSize: this.maxSize, + minRuleThickness: this.minRuleThickness, + }; + + Object.assign(data, extension); + + return new Options(data); + } + + /** + * Return an options object with the given style. If `this.style === style`, + * returns `this`. + */ + havingStyle(style: StyleInterface): Options { + if (this.style === style) { + return this; + } else { + return this.extend({ + style: style, + size: sizeAtStyle(this.textSize, style), + }); + } + } + + /** + * Return an options object with a cramped version of the current style. If + * the current style is cramped, returns `this`. + */ + havingCrampedStyle(): Options { + return this.havingStyle(this.style.cramp()); + } + + /** + * Return an options object with the given size and in at least `\textstyle`. + * Returns `this` if appropriate. + */ + havingSize(size: number): Options { + if (this.size === size && this.textSize === size) { + return this; + } else { + return this.extend({ + style: this.style.text(), + size: size, + textSize: size, + sizeMultiplier: sizeMultipliers[size - 1], + }); + } + } + + /** + * Like `this.havingSize(BASESIZE).havingStyle(style)`. If `style` is omitted, + * changes to at least `\textstyle`. + */ + havingBaseStyle(style: StyleInterface): Options { + style = style || this.style.text(); + const wantSize = sizeAtStyle(Options.BASESIZE, style); + if ( + this.size === wantSize && + this.textSize === Options.BASESIZE && + this.style === style + ) { + return this; + } else { + return this.extend({ + style: style, + size: wantSize, + }); + } + } + + /** + * Remove the effect of sizing changes such as \Huge. + * Keep the effect of the current style, such as \scriptstyle. + */ + havingBaseSizing(): Options { + let size; + switch (this.style.id) { + case 4: + case 5: + size = 3; // normalsize in scriptstyle + break; + case 6: + case 7: + size = 1; // normalsize in scriptscriptstyle + break; + default: + size = 6; // normalsize in textstyle or displaystyle + } + return this.extend({ + style: this.style.text(), + size: size, + }); + } + + /** + * Create a new options object with the given color. + */ + withColor(color: string): Options { + return this.extend({ + color: color, + }); + } + + /** + * Create a new options object with "phantom" set to true. + */ + withPhantom(): Options { + return this.extend({ + phantom: true, + }); + } + + /** + * Creates a new options object with the given math font or old text font. + * @type {[type]} + */ + withFont(font: MathFont): Options { + return this.extend({font}); + } + + /** + * Create a new options objects with the given fontFamily. + */ + withTextFontFamily(fontFamily: TextFont): Options { + return this.extend({fontFamily, font: ""}); + } + + /** + * Creates a new options object with the given font weight + */ + withTextFontWeight(fontWeight: FontWeight): Options { + return this.extend({ + fontWeight, + font: "", + }); + } + + /** + * Creates a new options object with the given font weight + */ + withTextFontShape(fontShape: FontShape): Options { + return this.extend({ + fontShape, + font: "", + }); + } + + /** + * Return the CSS sizing classes required to switch from enclosing options + * `oldOptions` to `this`. Returns an array of classes. + */ + sizingClasses(oldOptions: Options): Array { + if (oldOptions.size !== this.size) { + return [ + "sizing", + "reset-size" + oldOptions.size, + "size" + this.size, + ]; + } else { + return []; + } + } + + /** + * Return the CSS sizing classes required to switch to the base size. Like + * `this.havingSize(BASESIZE).sizingClasses(this)`. + */ + baseSizingClasses(): Array { + if (this.size !== Options.BASESIZE) { + return [ + "sizing", + "reset-size" + this.size, + "size" + Options.BASESIZE, + ]; + } else { + return []; + } + } + + /** + * Return the font metrics for this size. + */ + fontMetrics(): FontMetrics { + if (!this._fontMetrics) { + this._fontMetrics = getGlobalMetrics(this.size); + } + return this._fontMetrics; + } + + /** + * Gets the CSS color of the current options object + */ + getColor(): string | undefined { + if (this.phantom) { + return "transparent"; + } else { + return this.color; + } + } +} + +export default Options; diff --git a/node_modules/react-katex/node_modules/katex/src/ParseError.ts b/node_modules/react-katex/node_modules/katex/src/ParseError.ts new file mode 100644 index 0000000..2e0f247 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/ParseError.ts @@ -0,0 +1,76 @@ +import {Token} from "./Token"; + +import type {AnyParseNode} from "./parseNode"; + +/** + * This is the ParseError class, which is the main error thrown by KaTeX + * functions when something has gone wrong. This is used to distinguish internal + * errors from errors in the expression that the user provided. + * + * If possible, a caller should provide a Token or ParseNode with information + * about where in the source string the problem occurred. + */ +class ParseError extends Error { + override name = "ParseError" as const; + position: number | undefined; + // Error start position based on passed-in Token or ParseNode. + length: number | undefined; + // Length of affected text based on passed-in Token or ParseNode. + rawMessage: string; + // The underlying error message without any context added. + + constructor( + message: string, // The error message + token?: Token | null | undefined | AnyParseNode, + ) { + let error = "KaTeX parse error: " + message; + let start; + let end; + + const loc = token && token.loc; + if (loc && loc.start <= loc.end) { + // If we have the input and a position, make the error a bit fancier + + // Get the input + const input = loc.lexer.input; + + // Prepend some information + start = loc.start; + end = loc.end; + if (start === input.length) { + error += " at end of input: "; + } else { + error += " at position " + (start + 1) + ": "; + } + + // Underline token in question using combining underscores + const underlined = input.slice(start, end).replace(/[^]/g, "$&\u0332"); + + // Extract some context from the input and add it to the error + let left; + if (start > 15) { + left = "…" + input.slice(start - 15, start); + } else { + left = input.slice(0, start); + } + let right; + if (end + 15 < input.length) { + right = input.slice(end, end + 15) + "…"; + } else { + right = input.slice(end); + } + error += left + underlined + right; + + } + + super(error); + Object.setPrototypeOf(this, ParseError.prototype); + this.position = start; + if (start != null && end != null) { + this.length = end - start; + } + this.rawMessage = message; + } +} + +export default ParseError; diff --git a/node_modules/react-katex/node_modules/katex/src/Parser.ts b/node_modules/react-katex/node_modules/katex/src/Parser.ts new file mode 100644 index 0000000..89e9566 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/Parser.ts @@ -0,0 +1,1053 @@ +/* eslint no-constant-condition:0 */ +import functions from "./functions"; +import MacroExpander, {implicitCommands} from "./MacroExpander"; +import symbols, {extraLatin} from "./symbols"; +import {isAtom} from "./atoms"; +import {validUnit} from "./units"; +import {supportedCodepoint} from "./unicodeScripts"; +import ParseError from "./ParseError"; +import {combiningDiacriticalMarksEndRegex} from "./Lexer"; +import Settings from "./Settings"; +import SourceLocation from "./SourceLocation"; +import {uSubsAndSups, unicodeSubRegEx} from "./unicodeSupOrSub"; +import {Token} from "./Token"; + +// Pre-evaluate both modules as unicodeSymbols require String.normalize() +import unicodeAccents from /*preval*/ "./unicodeAccents"; +import unicodeSymbols from /*preval*/ "./unicodeSymbols"; + +import type {NodeType, ParseNode, AnyParseNode, SymbolParseNode, + UnsupportedCmdParseNode} from "./parseNode"; +import type {Group} from "./atoms"; +import type {Mode, ArgType, BreakToken} from "./types"; +import type {FunctionContext, FunctionSpec} from "./defineFunction"; +import type {EnvSpec} from "./defineEnvironment"; + +/** + * This file contains the parser used to parse out a TeX expression from the + * input. Since TeX isn't context-free, standard parsers don't work particularly + * well. + * + * The strategy of this parser is as such: + * + * The main functions (the `.parse...` ones) take a position in the current + * parse string to parse tokens from. The lexer (found in Lexer.js, stored at + * this.gullet.lexer) also supports pulling out tokens at arbitrary places. When + * individual tokens are needed at a position, the lexer is called to pull out a + * token, which is then used. + * + * The parser has a property called "mode" indicating the mode that + * the parser is currently in. Currently it has to be one of "math" or + * "text", which denotes whether the current environment is a math-y + * one or a text-y one (e.g. inside \text). Currently, this serves to + * limit the functions which can be used in text mode. + * + * The main functions then return an object which contains the useful data that + * was parsed at its given point, and a new position at the end of the parsed + * data. The main functions can call each other and continue the parsing by + * using the returned position as a new starting point. + * + * There are also extra `.handle...` functions, which pull out some reused + * functionality into self-contained functions. + * + * The functions return ParseNodes. + */ + +export default class Parser { + mode: Mode; + gullet: MacroExpander; + settings: Settings; + leftrightDepth: number; + nextToken: Token | null; + + constructor(input: string, settings: Settings) { + // Start in math mode + this.mode = "math"; + // Create a new macro expander (gullet) and (indirectly via that) also a + // new lexer (mouth) for this parser (stomach, in the language of TeX) + this.gullet = new MacroExpander(input, settings, this.mode); + // Store the settings for use in parsing + this.settings = settings; + // Count leftright depth (for \middle errors) + this.leftrightDepth = 0; + this.nextToken = null; + } + + /** + * Checks a result to make sure it has the right type, and throws an + * appropriate error otherwise. + */ + expect(text: string, consume = true) { + if (this.fetch().text !== text) { + throw new ParseError( + `Expected '${text}', got '${this.fetch().text}'`, this.fetch() + ); + } + if (consume) { + this.consume(); + } + } + + /** + * Discards the current lookahead token, considering it consumed. + */ + consume() { + this.nextToken = null; + } + + /** + * Return the current lookahead token, or if there isn't one (at the + * beginning, or if the previous lookahead token was consume()d), + * fetch the next token as the new lookahead token and return it. + */ + fetch(): Token { + if (this.nextToken == null) { + this.nextToken = this.gullet.expandNextToken(); + } + return this.nextToken; + } + + /** + * Switches between "text" and "math" modes. + */ + switchMode(newMode: Mode) { + this.mode = newMode; + this.gullet.switchMode(newMode); + } + + /** + * Main parsing function, which parses an entire input. + */ + parse(): AnyParseNode[] { + if (!this.settings.globalGroup) { + // Create a group namespace for the math expression. + // (LaTeX creates a new group for every $...$, $$...$$, \[...\].) + this.gullet.beginGroup(); + } + + // Use old \color behavior (same as LaTeX's \textcolor) if requested. + // We do this within the group for the math expression, so it doesn't + // pollute settings.macros. + if (this.settings.colorIsTextColor) { + this.gullet.macros.set("\\color", "\\textcolor"); + } + + try { + // Try to parse the input + const parse = this.parseExpression(false); + + // If we succeeded, make sure there's an EOF at the end + this.expect("EOF"); + + // End the group namespace for the expression + if (!this.settings.globalGroup) { + this.gullet.endGroup(); + } + + return parse; + + // Close any leftover groups in case of a parse error. + } finally { + this.gullet.endGroups(); + } + } + + /** + * Fully parse a separate sequence of tokens as a separate job. + * Tokens should be specified in reverse order, as in a MacroDefinition. + */ + subparse(tokens: Token[]): AnyParseNode[] { + // Save the next token from the current job. + const oldToken = this.nextToken; + this.consume(); + + // Run the new job, terminating it with an excess '}' + this.gullet.pushToken(new Token("}")); + this.gullet.pushTokens(tokens); + const parse = this.parseExpression(false); + this.expect("}"); + + // Restore the next token from the current job. + this.nextToken = oldToken; + + return parse; + } + + static endOfExpression: Set = + new Set(["}", "\\endgroup", "\\end", "\\right", "&"]); + + /** + * Parses an "expression", which is a list of atoms. + * + * `breakOnInfix`: Should the parsing stop when we hit infix nodes? This + * happens when functions have higher precedence than infix + * nodes in implicit parses. + * + * `breakOnTokenText`: The text of the token that the expression should end + * with, or `null` if something else should end the + * expression. + */ + parseExpression( + breakOnInfix: boolean, + breakOnTokenText?: BreakToken, + ): AnyParseNode[] { + const body = []; + // Keep adding atoms to the body until we can't parse any more atoms (either + // we reached the end, a }, or a \right) + while (true) { + // Ignore spaces in math mode + if (this.mode === "math") { + this.consumeSpaces(); + } + const lex = this.fetch(); + if (Parser.endOfExpression.has(lex.text)) { + break; + } + if (breakOnTokenText && lex.text === breakOnTokenText) { + break; + } + if (breakOnInfix && functions[lex.text] && functions[lex.text].infix) { + break; + } + const atom = this.parseAtom(breakOnTokenText); + if (!atom) { + break; + } else if (atom.type === "internal") { + // Internal nodes do not appear in parse tree + continue; + } + body.push(atom); + } + if (this.mode === "text") { + this.formLigatures(body); + } + return this.handleInfixNodes(body); + } + + /** + * Rewrites infix operators such as \over with corresponding commands such + * as \frac. + * + * There can only be one infix operator per group. If there's more than one + * then the expression is ambiguous. This can be resolved by adding {}. + */ + handleInfixNodes(body: AnyParseNode[]): AnyParseNode[] { + let overIndex = -1; + let funcName; + + for (let i = 0; i < body.length; i++) { + const node = body[i]; + if (node.type === "infix") { + if (overIndex !== -1) { + throw new ParseError( + "only one infix operator per group", + node.token); + } + overIndex = i; + funcName = node.replaceWith; + } + } + + if (overIndex !== -1 && funcName) { + let numerNode: AnyParseNode; + let denomNode: AnyParseNode; + + const numerBody = body.slice(0, overIndex); + const denomBody = body.slice(overIndex + 1); + + if (numerBody.length === 1 && numerBody[0].type === "ordgroup") { + numerNode = numerBody[0]; + } else { + numerNode = {type: "ordgroup", mode: this.mode, body: numerBody}; + } + + if (denomBody.length === 1 && denomBody[0].type === "ordgroup") { + denomNode = denomBody[0]; + } else { + denomNode = {type: "ordgroup", mode: this.mode, body: denomBody}; + } + + let node; + if (funcName === "\\\\abovefrac") { + node = this.callFunction(funcName, + [numerNode, body[overIndex], denomNode], []); + } else { + node = this.callFunction(funcName, [numerNode, denomNode], []); + } + return [node]; + } else { + return body; + } + } + + /** + * Handle a subscript or superscript with nice errors. + */ + handleSupSubscript( + name: string, // For error reporting. + ): AnyParseNode { + const symbolToken = this.fetch(); + const symbol = symbolToken.text; + this.consume(); + this.consumeSpaces(); // ignore spaces before sup/subscript argument + + // Skip over allowed internal nodes such as \relax + let group: AnyParseNode | null | undefined; + do { + group = this.parseGroup(name); + } while (group?.type === "internal"); + + if (!group) { + throw new ParseError( + "Expected group after '" + symbol + "'", + symbolToken + ); + } + + return group; + } + + /** + * Converts the textual input of an unsupported command into a text node + * contained within a color node whose color is determined by errorColor + */ + formatUnsupportedCmd(text: string): UnsupportedCmdParseNode { + const textordArray: ParseNode<"textord">[] = []; + + for (let i = 0; i < text.length; i++) { + textordArray.push({type: "textord", mode: "text", text: text[i]}); + } + + const textNode: ParseNode<"text"> = { + type: "text", + mode: this.mode, + body: textordArray, + }; + const colorNode: ParseNode<"color"> = { + type: "color", + mode: this.mode, + color: this.settings.errorColor, + body: [textNode], + }; + + return colorNode; + } + + /** + * Parses a group with optional super/subscripts. + */ + parseAtom(breakOnTokenText?: BreakToken): AnyParseNode | null | undefined { + // The body of an atom is an implicit group, so that things like + // \left(x\right)^2 work correctly. + const base = this.parseGroup("atom", breakOnTokenText); + + // Internal nodes (e.g. \relax) cannot support super/subscripts. + // Instead we will pick up super/subscripts with blank base next round. + if (base?.type === "internal") { + return base; + } + + // In text mode, we don't have superscripts or subscripts + if (this.mode === "text") { + return base; + } + + // Note that base may be empty (i.e. null) at this point. + + let superscript: AnyParseNode | null | undefined; + let subscript: AnyParseNode | null | undefined; + while (true) { + // Guaranteed in math mode, so eat any spaces first. + this.consumeSpaces(); + + // Lex the first token + const lex = this.fetch(); + + if (lex.text === "\\limits" || lex.text === "\\nolimits") { + // We got a limit control + if (base && base.type === "op") { + const limits = lex.text === "\\limits"; + base.limits = limits; + base.alwaysHandleSupSub = true; + } else if (base && base.type === "operatorname") { + if (base.alwaysHandleSupSub) { + base.limits = lex.text === "\\limits"; + } + } else { + throw new ParseError( + "Limit controls must follow a math operator", + lex); + } + this.consume(); + } else if (lex.text === "^") { + // We got a superscript start + if (superscript) { + throw new ParseError("Double superscript", lex); + } + superscript = this.handleSupSubscript("superscript"); + } else if (lex.text === "_") { + // We got a subscript start + if (subscript) { + throw new ParseError("Double subscript", lex); + } + subscript = this.handleSupSubscript("subscript"); + } else if (lex.text === "'") { + // We got a prime + if (superscript) { + throw new ParseError("Double superscript", lex); + } + + const prime: ParseNode<"textord"> = {type: "textord", mode: this.mode, text: "\\prime"}; + + // Many primes can be grouped together, so we handle this here + const primes: AnyParseNode[] = [prime]; + this.consume(); + // Keep lexing tokens until we get something that's not a prime + while (this.fetch().text === "'") { + // For each one, add another prime to the list + primes.push(prime); + this.consume(); + } + // If there's a superscript following the primes, combine that + // superscript in with the primes. + if (this.fetch().text === "^") { + primes.push(this.handleSupSubscript("superscript")); + } + // Put everything into an ordgroup as the superscript + superscript = {type: "ordgroup", mode: this.mode, body: primes}; + } else if (uSubsAndSups[lex.text]) { + // A Unicode subscript or superscript character. + // We treat these similarly to the unicode-math package. + // So we render a string of Unicode (sub|super)scripts the + // same as a (sub|super)script of regular characters. + const isSub = unicodeSubRegEx.test(lex.text); + const subsupTokens = []; + subsupTokens.push(new Token(uSubsAndSups[lex.text])); + this.consume(); + // Continue fetching tokens to fill out the string. + while (true) { + const token = this.fetch().text; + if (!(uSubsAndSups[token])) { break; } + if (unicodeSubRegEx.test(token) !== isSub) { break; } + subsupTokens.unshift(new Token(uSubsAndSups[token])); + this.consume(); + } + // Now create a (sub|super)script. + const body = this.subparse(subsupTokens); + if (isSub) { + subscript = {type: "ordgroup", mode: "math", body}; + } else { + superscript = {type: "ordgroup", mode: "math", body}; + } + } else { + // If it wasn't ^, _, or ', stop parsing super/subscripts + break; + } + } + + // Base must be set if superscript or subscript are set per logic above, + // but need to check here for type check to pass. + if (superscript || subscript) { + // If we got either a superscript or subscript, create a supsub + return { + type: "supsub", + mode: this.mode, + base: base, + sup: superscript, + sub: subscript, + }; + } else { + // Otherwise return the original body + return base; + } + } + + /** + * Parses an entire function, including its base and all of its arguments. + */ + parseFunction( + breakOnTokenText?: BreakToken, + name?: string, // For determining its context + ): AnyParseNode | null | undefined { + const token = this.fetch(); + const func = token.text; + const funcData = functions[func]; + if (!funcData) { + return null; + } + this.consume(); // consume command token + + if (name && name !== "atom" && !funcData.allowedInArgument) { + throw new ParseError( + "Got function '" + func + "' with no arguments" + + (name ? " as " + name : ""), token); + } else if (this.mode === "text" && !funcData.allowedInText) { + throw new ParseError( + "Can't use function '" + func + "' in text mode", token); + } else if (this.mode === "math" && funcData.allowedInMath === false) { + throw new ParseError( + "Can't use function '" + func + "' in math mode", token); + } + + const {args, optArgs} = this.parseArguments(func, funcData); + return this.callFunction(func, args, optArgs, token, breakOnTokenText); + } + + /** + * Call a function handler with a suitable context and arguments. + */ + callFunction( + name: string, + args: AnyParseNode[], + optArgs: (AnyParseNode | null | undefined)[], + token?: Token, + breakOnTokenText?: BreakToken, + ): AnyParseNode { + const context: FunctionContext = { + funcName: name, + parser: this, + token, + breakOnTokenText, + }; + const func = functions[name]; + if (func && func.handler) { + return func.handler(context, args, optArgs); + } else { + throw new ParseError(`No function handler for ${name}`); + } + } + + /** + * Parses the arguments of a function or environment + */ + parseArguments( + func: string, // Should look like "\name" or "\begin{name}". + funcData: FunctionSpec | EnvSpec, + ): { + args: AnyParseNode[]; + optArgs: (AnyParseNode | null | undefined)[]; + } { + const totalArgs = funcData.numArgs + funcData.numOptionalArgs; + if (totalArgs === 0) { + return {args: [], optArgs: []}; + } + + const args: AnyParseNode[] = []; + const optArgs: (AnyParseNode | null | undefined)[] = []; + + for (let i = 0; i < totalArgs; i++) { + let argType = funcData.argTypes && funcData.argTypes[i]; + const isOptional = i < funcData.numOptionalArgs; + + if (("primitive" in funcData && funcData.primitive && argType == null) || + // \sqrt expands into primitive if optional argument doesn't exist + (funcData.type === "sqrt" && i === 1 && optArgs[0] == null) + ) { + argType = "primitive"; + } + + const arg = this.parseGroupOfType(`argument to '${func}'`, + argType as ArgType | null | undefined, isOptional); + if (isOptional) { + optArgs.push(arg); + } else if (arg != null) { + args.push(arg); + } else { // should be unreachable + throw new ParseError("Null argument, please report this as a bug"); + } + } + + return {args, optArgs}; + } + + /** + * Parses a group when the mode is changing. + */ + parseGroupOfType( + name: string, + type: ArgType | null | undefined, + optional: boolean, + ): AnyParseNode | null | undefined { + switch (type) { + case "color": + return this.parseColorGroup(optional); + case "size": + return this.parseSizeGroup(optional); + case "url": + return this.parseUrlGroup(optional); + case "math": + case "text": + return this.parseArgumentGroup(optional, type); + case "hbox": { + // hbox argument type wraps the argument in the equivalent of + // \hbox, which is like \text but switching to \textstyle size + // and resetting math font. + const group = this.parseArgumentGroup(optional, "text"); + return group != null ? { + type: "styling", + mode: group.mode, + body: [group], + style: "text", // simulate \textstyle + resetFont: true, + } : null; + } + case "raw": { + const token = this.parseStringGroup("raw", optional); + return token != null ? { + type: "raw", + mode: "text", + string: token.text, + } : null; + } + case "primitive": { + if (optional) { + throw new ParseError("A primitive argument cannot be optional"); + } + const group = this.parseGroup(name); + if (group == null) { + throw new ParseError("Expected group as " + name, this.fetch()); + } + return group; + } + case "original": + case null: + case undefined: + return this.parseArgumentGroup(optional); + default: + throw new ParseError( + "Unknown group type as " + name, this.fetch()); + } + } + + /** + * Discard any space tokens, fetching the next non-space token. + */ + consumeSpaces() { + while (this.fetch().text === " ") { + this.consume(); + } + } + + /** + * Parses a group, essentially returning the string formed by the + * brace-enclosed tokens plus some position information. + */ + parseStringGroup( + modeName: ArgType, // Used to describe the mode in error messages. + optional: boolean, + ): Token | null | undefined { + const argToken = this.gullet.scanArgument(optional); + if (argToken == null) { + return null; + } + let str = ""; + let nextToken: Token; + while ((nextToken = this.fetch()).text !== "EOF") { + str += nextToken.text; + this.consume(); + } + this.consume(); // consume the end of the argument + argToken.text = str; + return argToken; + } + + /** + * Parses a regex-delimited group: the largest sequence of tokens + * whose concatenated strings match `regex`. Returns the string + * formed by the tokens plus some position information. + */ + parseRegexGroup( + regex: RegExp, + modeName: string, // Used to describe the mode in error messages. + ): Token { + const firstToken = this.fetch(); + let lastToken = firstToken; + let str = ""; + let nextToken: Token; + while ((nextToken = this.fetch()).text !== "EOF" && + regex.test(str + nextToken.text)) { + lastToken = nextToken; + str += lastToken.text; + this.consume(); + } + if (str === "") { + throw new ParseError( + "Invalid " + modeName + ": '" + firstToken.text + "'", + firstToken); + } + return firstToken.range(lastToken, str); + } + + /** + * Parses a color description. + */ + parseColorGroup(optional: boolean): ParseNode<"color-token"> | null | undefined { + const res = this.parseStringGroup("color", optional); + if (res == null) { + return null; + } + const match = ( + /^(#[a-f0-9]{3,4}|#[a-f0-9]{6}|#[a-f0-9]{8}|[a-f0-9]{6}|[a-z]+)$/i + ).exec(res.text); + if (!match) { + throw new ParseError("Invalid color: '" + res.text + "'", res); + } + let color = match[0]; + if (/^[0-9a-f]{6}$/i.test(color)) { + // We allow a 6-digit HTML color spec without a leading "#". + // This follows the xcolor package's HTML color model. + // Predefined color names are all missed by this RegEx pattern. + color = "#" + color; + } + + return { + type: "color-token", + mode: this.mode, + color, + }; + } + + /** + * Parses a size specification, consisting of magnitude and unit. + */ + parseSizeGroup(optional: boolean): ParseNode<"size"> | null | undefined { + let res: Token | null | undefined; + let isBlank = false; + // don't expand before parseStringGroup + this.gullet.consumeSpaces(); + if (!optional && this.gullet.future().text !== "{") { + res = this.parseRegexGroup( + /^[-+]? *(?:$|\d+|\d+\.\d*|\.\d*) *[a-z]{0,2} *$/, "size"); + } else { + res = this.parseStringGroup("size", optional); + } + if (!res) { + return null; + } + if (!optional && res.text.length === 0) { + // Because we've tested for what is !optional, this block won't + // affect \kern, \hspace, etc. It will capture the mandatory arguments + // to \genfrac and \above. + res.text = "0pt"; // Enable \above{} + isBlank = true; // This is here specifically for \genfrac + } + const match = (/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/).exec(res.text); + if (!match) { + throw new ParseError("Invalid size: '" + res.text + "'", res); + } + const data = { + number: +(match[1] + match[2]), // sign + magnitude, cast to number + unit: match[3], + }; + if (!validUnit(data)) { + throw new ParseError("Invalid unit: '" + data.unit + "'", res); + } + + return { + type: "size", + mode: this.mode, + value: data, + isBlank, + }; + } + + /** + * Parses an URL, checking escaped letters and allowed protocols, + * and setting the catcode of % as an active character (as in \hyperref). + */ + parseUrlGroup(optional: boolean): ParseNode<"url"> | null | undefined { + this.gullet.lexer.setCatcode("%", 13); // active character + this.gullet.lexer.setCatcode("~", 12); // other character + const res = this.parseStringGroup("url", optional); + this.gullet.lexer.setCatcode("%", 14); // comment character + this.gullet.lexer.setCatcode("~", 13); // active character + if (res == null) { + return null; + } + // hyperref package allows backslashes alone in href, but doesn't + // generate valid links in such cases; we interpret this as + // "undefined" behaviour, and keep them as-is. Some browser will + // replace backslashes with forward slashes. + const url = res.text.replace(/\\([#$%&~_^{}])/g, '$1'); + return { + type: "url", + mode: this.mode, + url, + }; + } + + /** + * Parses an argument with the mode specified. + */ + parseArgumentGroup(optional: boolean, mode?: Mode): ParseNode<"ordgroup"> | null | undefined { + const argToken = this.gullet.scanArgument(optional); + if (argToken == null) { + return null; + } + const outerMode = this.mode; + if (mode) { // Switch to specified mode + this.switchMode(mode); + } + + this.gullet.beginGroup(); + const expression = this.parseExpression(false, "EOF"); + // TODO: find an alternative way to denote the end + this.expect("EOF"); // expect the end of the argument + this.gullet.endGroup(); + const result: ParseNode<"ordgroup"> = { + type: "ordgroup", + mode: this.mode, + loc: argToken.loc, + body: expression, + }; + + if (mode) { // Switch mode back + this.switchMode(outerMode); + } + return result; + } + + /** + * Parses an ordinary group, which is either a single nucleus (like "x") + * or an expression in braces (like "{x+y}") or an implicit group, a group + * that starts at the current position, and ends right before a higher explicit + * group ends, or at EOF. + */ + parseGroup( + name: string, // For error reporting. + breakOnTokenText?: BreakToken, + ): AnyParseNode | null | undefined { + const firstToken = this.fetch(); + const text = firstToken.text; + + let result: AnyParseNode | null | undefined; + // Try to parse an open brace or \begingroup + if (text === "{" || text === "\\begingroup") { + this.consume(); + const groupEnd = text === "{" ? "}" : "\\endgroup"; + + this.gullet.beginGroup(); + // If we get a brace, parse an expression + const expression = this.parseExpression(false, groupEnd); + const lastToken = this.fetch(); + this.expect(groupEnd); // Check that we got a matching closing brace + this.gullet.endGroup(); + result = { + type: "ordgroup", + mode: this.mode, + loc: SourceLocation.range(firstToken, lastToken), + body: expression, + // A group formed by \begingroup...\endgroup is a semi-simple group + // which doesn't affect spacing in math mode, i.e., is transparent. + // https://tex.stackexchange.com/questions/1930/when-should-one- + // use-begingroup-instead-of-bgroup + semisimple: text === "\\begingroup" || undefined, + }; + } else { + // If there exists a function with this name, parse the function. + // Otherwise, just return a nucleus + result = this.parseFunction(breakOnTokenText, name) || + this.parseSymbol(); + if (result == null && text[0] === "\\" && + !implicitCommands.hasOwnProperty(text)) { + if (this.settings.throwOnError) { + throw new ParseError( + "Undefined control sequence: " + text, firstToken); + } + result = this.formatUnsupportedCmd(text); + this.consume(); + } + } + return result; + } + + /** + * Form ligature-like combinations of characters for text mode. + * This includes inputs like "--", "---", "``" and "''". + * The result will simply replace multiple textord nodes with a single + * character in each value by a single textord node having multiple + * characters in its value. The representation is still ASCII source. + * The group will be modified in place. + */ + formLigatures(group: AnyParseNode[]) { + let n = group.length - 1; + for (let i = 0; i < n; ++i) { + const a = group[i]; + if (a.type !== "textord") { + continue; + } + const v = a.text; + const next = group[i + 1]; + if (!next || next.type !== "textord") { + continue; + } + if (v === "-" && next.text === "-") { + const afterNext = group[i + 2]; + if (i + 1 < n && afterNext && afterNext.type === "textord" && afterNext.text === "-") { + group.splice(i, 3, { + type: "textord", + mode: "text", + loc: SourceLocation.range(a, afterNext), + text: "---", + }); + n -= 2; + } else { + group.splice(i, 2, { + type: "textord", + mode: "text", + loc: SourceLocation.range(a, next), + text: "--", + }); + n -= 1; + } + } + if ((v === "'" || v === "`") && next.text === v) { + group.splice(i, 2, { + type: "textord", + mode: "text", + loc: SourceLocation.range(a, next), + text: v + v, + }); + n -= 1; + } + } + } + + /** + * Parse a single symbol out of the string. Here, we handle single character + * symbols and special functions like \verb. + */ + parseSymbol(): AnyParseNode | null | undefined { + const nucleus = this.fetch(); + let text = nucleus.text; + + if (/^\\verb[^a-zA-Z]/.test(text)) { + this.consume(); + let arg = text.slice(5); + const star = (arg.charAt(0) === "*"); + if (star) { + arg = arg.slice(1); + } + // Lexer's tokenRegex is constructed to always have matching + // first/last characters. + if (arg.length < 2 || arg.charAt(0) !== arg.slice(-1)) { + throw new ParseError(`\\verb assertion failed -- + please report what input caused this bug`); + } + arg = arg.slice(1, -1); // remove first and last char + + return { + type: "verb", + mode: "text", + body: arg, + star, + }; + } + // At this point, we should have a symbol, possibly with accents. + // First expand any accented base symbol according to unicodeSymbols. + if (unicodeSymbols.hasOwnProperty(text[0]) && + !symbols[this.mode][text[0]]) { + // This behavior is not strict (XeTeX-compatible) in math mode. + if (this.settings.strict && this.mode === "math") { + this.settings.reportNonstrict("unicodeTextInMathMode", + `Accented Unicode text character "${text[0]}" used in ` + + `math mode`, nucleus); + } + text = unicodeSymbols[text[0]] + text.slice(1); + } + // Strip off any combining characters + const match = combiningDiacriticalMarksEndRegex.exec(text); + if (match) { + text = text.substring(0, match.index); + if (text === 'i') { + text = '\u0131'; // dotless i, in math and text mode + } else if (text === 'j') { + text = '\u0237'; // dotless j, in math and text mode + } + } + // Recognize base symbol + let symbol: AnyParseNode; + if (symbols[this.mode][text]) { + if (this.settings.strict && this.mode === 'math' && + extraLatin.includes(text)) { + this.settings.reportNonstrict("unicodeTextInMathMode", + `Latin-1/Unicode text character "${text[0]}" used in ` + + `math mode`, nucleus); + } + const group: Group = symbols[this.mode][text].group; + const loc = SourceLocation.range(nucleus); + let s: SymbolParseNode; + if (isAtom(group)) { + s = { + type: "atom", + mode: this.mode, + family: group, + loc, + text, + }; + } else { + s = { + type: group, + mode: this.mode, + loc, + text, + }; + } + symbol = s; + } else if (text.charCodeAt(0) >= 0x80) { // no symbol for e.g. ^ + if (this.settings.strict) { + if (!supportedCodepoint(text.charCodeAt(0))) { + this.settings.reportNonstrict("unknownSymbol", + `Unrecognized Unicode character "${text[0]}"` + + ` (${text.charCodeAt(0)})`, nucleus); + } else if (this.mode === "math") { + this.settings.reportNonstrict("unicodeTextInMathMode", + `Unicode text character "${text[0]}" used in math mode`, + nucleus); + } + } + // All nonmathematical Unicode characters are rendered as if they + // are in text mode (wrapped in \text) because that's what it + // takes to render them in LaTeX. Setting `mode: this.mode` is + // another natural choice (the user requested math mode), but + // this makes it more difficult for getCharacterMetrics() to + // distinguish Unicode characters without metrics and those for + // which we want to simulate the letter M. + symbol = { + type: "textord", + mode: "text", + loc: SourceLocation.range(nucleus), + text, + }; + } else { + return null; // EOF, ^, _, {, }, etc. + } + this.consume(); + // Transform combining characters into accents + if (match) { + for (let i = 0; i < match[0].length; i++) { + const accent: string = match[0][i]; + if (!unicodeAccents[accent]) { + throw new ParseError(`Unknown accent ' ${accent}'`, nucleus); + } + const command = unicodeAccents[accent][this.mode] || + unicodeAccents[accent].text; + if (!command) { + throw new ParseError( + `Accent ${accent} unsupported in ${this.mode} mode`, + nucleus); + } + symbol = { + type: "accent", + mode: this.mode, + loc: SourceLocation.range(nucleus), + label: command, + isStretchy: false, + isShifty: true, + base: symbol, + }; + } + } + return symbol; + } +} diff --git a/node_modules/react-katex/node_modules/katex/src/Settings.ts b/node_modules/react-katex/node_modules/katex/src/Settings.ts new file mode 100644 index 0000000..aa5d411 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/Settings.ts @@ -0,0 +1,477 @@ +/* eslint no-console:0 */ +/** + * This is a module for storing settings passed into KaTeX. It correctly handles + * default settings. + */ + +import {protocolFromUrl} from "./utils"; +import ParseError from "./ParseError"; +import {Token} from "./Token"; + +import type {AnyParseNode} from "./parseNode"; +import type {MacroMap} from "./defineMacro"; + +export type StrictFunction = + (errorCode: string, errorMsg: string, token?: Token | AnyParseNode) => + (boolean | string) | null | undefined; + +export type TrustContextTypes = { + "\\href": { + command: "\\href"; + url: string; + protocol?: string; + }; + "\\includegraphics": { + command: "\\includegraphics"; + url: string; + protocol?: string; + }; + "\\url": { + command: "\\url"; + url: string; + protocol?: string; + }; + "\\htmlClass": { + command: "\\htmlClass"; + class: string; + }; + "\\htmlId": { + command: "\\htmlId"; + id: string; + }; + "\\htmlStyle": { + command: "\\htmlStyle"; + style: string; + }; + "\\htmlData": { + command: "\\htmlData"; + attributes: Record; + }; +}; +export type AnyTrustContext = TrustContextTypes[keyof TrustContextTypes]; +export type TrustFunction = (context: AnyTrustContext) => boolean | null | undefined; +export type SettingsOptions = Partial; + +type EnumType = { + enum: T[]; +}; + +type Type = "boolean" | "string" | "number" | "object" | "function" | EnumType; +/** + * Union of all values that appear as schema defaults, cliDefaults, or + * cliProcessor return values. StrictFunction / TrustFunction are + * option-value types, not default/schema values, so they are excluded. + */ +type SettingsValue = boolean | string | number | MacroMap | string[]; +type DefaultValue = Exclude; + +type SchemaMetadata = { + /** + * The description. + */ + description?: string; + /** + * The function to process the option. + */ + processor?: (value: Settings[K]) => Settings[K]; + /** + * The command line argument. See Commander.js docs for more information. + * If not specified, the name prefixed with -- will be used. Set false not + * to add to the CLI. + */ + cli?: string | false; + /** + * The default value for the CLI. + */ + cliDefault?: SettingsValue; + /** + * The description for the CLI. If not specified, the description for the + * option will be used. + */ + cliDescription?: string; + /** + * The custom argument processor for the CLI. See Commander.js docs for + * more information. Signature varies per setting (e.g. parseFloat, + * or (def, defs) => defs.push(def) for macros). + */ + cliProcessor?: (...args: any[]) => SettingsValue; +}; + +type BooleanSchema = SchemaMetadata & { + /** + * Allowed type(s) of the value. + */ + type: "boolean"; + /** + * The default value. If not specified, false will be used. + */ + default?: Extract; +}; + +type StringSchema = SchemaMetadata & { + /** + * Allowed type(s) of the value. + */ + type: "string"; + /** + * The default value. If not specified, an empty string will be used. + */ + default?: Extract; +}; + +type NumberSchema = SchemaMetadata & { + /** + * Allowed type(s) of the value. + */ + type: "number"; + /** + * The default value. If not specified, 0 will be used. + */ + default?: Extract; +}; + +type ObjectSchema = SchemaMetadata & { + /** + * Allowed type(s) of the value. + */ + type: "object"; + /** + * The default value. If not specified, an empty object will be used. + */ + default?: Extract; +}; + +type FunctionSchema = SchemaMetadata & { + /** + * Allowed type(s) of the value. + */ + type: "function"; + /** + * Settings do not currently use function-valued defaults. + */ + default?: never; +}; + +type EnumSchema = SchemaMetadata & { + /** + * Allowed type(s) of the value. + */ + type: EnumType>; + /** + * The default value. If not specified, the first enum value will be used. + */ + default?: Extract; +}; + +type SingleTypeSchema = + | BooleanSchema + | StringSchema + | NumberSchema + | ObjectSchema + | FunctionSchema + | EnumSchema; + +type MultiTypeSchema = SchemaMetadata & { + /** + * Allowed type(s) of the value. + */ + type: [SingleTypeSchema["type"], ...Array["type"]>]; + /** + * The default value. If not specified, the first allowed type determines + * the default value. + */ + default?: Extract; +}; + +type SchemaEntry = + | SingleTypeSchema + | MultiTypeSchema; + +type Schema = { + [key in keyof SettingsOptions]?: SchemaEntry; +}; + +// TODO: automatically generate documentation +// TODO: check all properties on Settings exist +// TODO: check the type of a property on Settings matches +export const SETTINGS_SCHEMA: Schema = { + displayMode: { + type: "boolean", + description: "Render math in display mode, which puts the math in " + + "display style (so \\int and \\sum are large, for example), and " + + "centers the math on the page on its own line.", + cli: "-d, --display-mode", + }, + output: { + type: {enum: ["htmlAndMathml", "html", "mathml"]}, + description: "Determines the markup language of the output.", + cli: "-F, --format ", + }, + leqno: { + type: "boolean", + description: "Render display math in leqno style (left-justified tags).", + }, + fleqn: { + type: "boolean", + description: "Render display math flush left.", + }, + throwOnError: { + type: "boolean", + default: true, + cli: "-t, --no-throw-on-error", + cliDescription: "Render errors (in the color given by --error-color) ins" + + "tead of throwing a ParseError exception when encountering an error.", + }, + errorColor: { + type: "string", + default: "#cc0000", + cli: "-c, --error-color ", + cliDescription: "A color string given in the format 'rgb' or 'rrggbb' " + + "(no #). This option determines the color of errors rendered by the " + + "-t option.", + cliProcessor: (color) => "#" + color, + }, + macros: { + type: "object", + cli: "-m, --macro ", + cliDescription: "Define custom macro of the form '\\foo:expansion' (use " + + "multiple -m arguments for multiple macros).", + cliDefault: [], + cliProcessor: (def, defs) => { + defs.push(def); + return defs; + }, + }, + minRuleThickness: { + type: "number", + description: "Specifies a minimum thickness, in ems, for fraction lines," + + " `\\sqrt` top lines, `{array}` vertical lines, `\\hline`, " + + "`\\hdashline`, `\\underline`, `\\overline`, and the borders of " + + "`\\fbox`, `\\boxed`, and `\\fcolorbox`.", + processor: (t) => Math.max(0, t), + cli: "--min-rule-thickness ", + cliProcessor: parseFloat, + }, + colorIsTextColor: { + type: "boolean", + description: "Makes \\color behave like LaTeX's 2-argument \\textcolor, " + + "instead of LaTeX's one-argument \\color mode change.", + cli: "-b, --color-is-text-color", + }, + strict: { + type: [{enum: ["warn", "ignore", "error"]}, "boolean", "function"], + description: "Turn on strict / LaTeX faithfulness mode, which throws an " + + "error if the input uses features that are not supported by LaTeX.", + cli: "-S, --strict", + cliDefault: false, + }, + trust: { + type: ["boolean", "function"], + description: "Trust the input, enabling all HTML features such as \\url.", + cli: "-T, --trust", + }, + maxSize: { + type: "number", + default: Infinity, + description: "If non-zero, all user-specified sizes, e.g. in " + + "\\rule{500em}{500em}, will be capped to maxSize ems. Otherwise, " + + "elements and spaces can be arbitrarily large", + processor: (s) => Math.max(0, s), + cli: "-s, --max-size ", + cliProcessor: parseInt, + }, + maxExpand: { + type: "number", + default: 1000, + description: "Limit the number of macro expansions to the specified " + + "number, to prevent e.g. infinite macro loops. If set to Infinity, " + + "the macro expander will try to fully expand as in LaTeX.", + processor: (n) => Math.max(0, n), + cli: "-e, --max-expand ", + cliProcessor: (n) => (n === "Infinity" ? Infinity : parseInt(n)), + }, + globalGroup: { + type: "boolean", + cli: false, + }, +}; + +function getImplicitDefault(type: "boolean"): boolean; +function getImplicitDefault(type: "string"): string; +function getImplicitDefault(type: "number"): number; +function getImplicitDefault(type: "object"): MacroMap; +function getImplicitDefault(type: "function"): never; +function getImplicitDefault(type: EnumType): T; +function getImplicitDefault(type: Type): DefaultValue; +function getImplicitDefault(type: Type): DefaultValue { + if (typeof type !== 'string') { + return type.enum[0]; + } + switch (type) { + case 'boolean': + return false; + case 'string': + return ''; + case 'number': + return 0; + case 'object': + return {}; + default: + throw new Error( + "Unexpected schema type; settings must declare an explicit default."); + } +} + +function getDefaultValue( + schema: SchemaEntry, +): Settings[K]; +function getDefaultValue(schema: SchemaEntry): DefaultValue { + if (schema.default !== undefined) { + return schema.default; + } + const type = Array.isArray(schema.type) ? schema.type[0] : schema.type; + return getImplicitDefault(type); +} + +function applySetting( + target: Settings, + prop: K, + options: SettingsOptions, + schema: SchemaEntry, +) { + const optionValue = options[prop]; + target[prop] = optionValue !== undefined + ? (schema.processor + ? schema.processor(optionValue) + : optionValue) + : getDefaultValue(schema); +} + +/** + * The main Settings object + * + * The current options stored are: + * - displayMode: Whether the expression should be typeset as inline math + * (false, the default), meaning that the math starts in + * \textstyle and is placed in an inline-block); or as display + * math (true), meaning that the math starts in \displaystyle + * and is placed in a block with vertical margin. + */ +export default class Settings { + displayMode!: boolean; + output!: "html" | "mathml" | "htmlAndMathml"; + leqno!: boolean; + fleqn!: boolean; + throwOnError!: boolean; + errorColor!: string; + macros!: MacroMap; + minRuleThickness!: number; + colorIsTextColor!: boolean; + strict!: boolean | "ignore" | "warn" | "error" | StrictFunction; + trust!: boolean | TrustFunction; + maxSize!: number; + maxExpand!: number; + globalGroup!: boolean; + + constructor(options: SettingsOptions = {}) { + // allow null options + options = options || {}; + for (const prop of Object.keys(SETTINGS_SCHEMA) as Array) { + const schema = SETTINGS_SCHEMA[prop] as SchemaEntry | undefined; + if (schema) { + // TODO: validate options + applySetting(this, prop, options, schema); + } + } + } + + /** + * Report nonstrict (non-LaTeX-compatible) input. + * Can safely not be called if `this.strict` is false in JavaScript. + */ + reportNonstrict(errorCode: string, errorMsg: string, + token?: Token | AnyParseNode) { + let strict: Settings["strict"] | ReturnType = this.strict; + if (typeof strict === "function") { + // Allow return value of strict function to be boolean or string + // (or null/undefined, meaning no further processing). + strict = strict(errorCode, errorMsg, token); + } + if (!strict || strict === "ignore") { + return; + } else if (strict === true || strict === "error") { + throw new ParseError( + "LaTeX-incompatible input and strict mode is set to 'error': " + + `${errorMsg} [${errorCode}]`, token); + } else if (strict === "warn") { + typeof console !== "undefined" && console.warn( + "LaTeX-incompatible input and strict mode is set to 'warn': " + + `${errorMsg} [${errorCode}]`); + } else { // won't happen in type-safe code + typeof console !== "undefined" && console.warn( + "LaTeX-incompatible input and strict mode is set to " + + `unrecognized '${strict}': ${errorMsg} [${errorCode}]`); + } + } + + /** + * Check whether to apply strict (LaTeX-adhering) behavior for unusual + * input (like `\\`). Unlike `nonstrict`, will not throw an error; + * instead, "error" translates to a return value of `true`, while "ignore" + * translates to a return value of `false`. May still print a warning: + * "warn" prints a warning and returns `false`. + * This is for the second category of `errorCode`s listed in the README. + */ + useStrictBehavior(errorCode: string, errorMsg: string, + token?: Token | AnyParseNode): boolean { + let strict: Settings["strict"] | ReturnType = this.strict; + if (typeof strict === "function") { + // Allow return value of strict function to be boolean or string + // (or null/undefined, meaning no further processing). + // But catch any exceptions thrown by function, treating them + // like "error". + try { + strict = strict(errorCode, errorMsg, token); + } catch (error) { + strict = "error"; + } + } + if (!strict || strict === "ignore") { + return false; + } else if (strict === true || strict === "error") { + return true; + } else if (strict === "warn") { + typeof console !== "undefined" && console.warn( + "LaTeX-incompatible input and strict mode is set to 'warn': " + + `${errorMsg} [${errorCode}]`); + return false; + } else { // won't happen in type-safe code + typeof console !== "undefined" && console.warn( + "LaTeX-incompatible input and strict mode is set to " + + `unrecognized '${strict}': ${errorMsg} [${errorCode}]`); + return false; + } + } + + /** + * Check whether to test potentially dangerous input, and return + * `true` (trusted) or `false` (untrusted). The sole argument `context` + * should be an object with `command` field specifying the relevant LaTeX + * command (as a string starting with `\`), and any other arguments, etc. + * If `context` has a `url` field, a `protocol` field will automatically + * get added by this function (changing the specified object). + */ + isTrusted(context: AnyTrustContext): boolean { + if ("url" in context && context.url && !context.protocol) { + const protocol = protocolFromUrl(context.url); + if (protocol == null) { + return false; + } + context.protocol = protocol; + } + const trust = typeof this.trust === "function" + ? this.trust(context) + : this.trust; + return Boolean(trust); + } +} diff --git a/node_modules/react-katex/node_modules/katex/src/SourceLocation.ts b/node_modules/react-katex/node_modules/katex/src/SourceLocation.ts new file mode 100644 index 0000000..7097484 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/SourceLocation.ts @@ -0,0 +1,41 @@ +import type {LexerInterface} from "./Token"; + +/** + * Lexing or parsing positional information for error reporting. + * This object is immutable. + */ +export default class SourceLocation { + // The + prefix indicates that these fields aren't writeable + readonly lexer: LexerInterface; // Lexer holding the input string. + readonly start: number; // Start offset, zero-based inclusive. + readonly end: number; // End offset, zero-based exclusive. + + constructor(lexer: LexerInterface, start: number, end: number) { + this.lexer = lexer; + this.start = start; + this.end = end; + } + + /** + * Merges two `SourceLocation`s from location providers, given they are + * provided in order of appearance. + * - Returns the first one's location if only the first is provided. + * - Returns a merged range of the first and the last if both are provided + * and their lexers match. + * - Otherwise, returns null. + */ + static range( + first?: {loc?: SourceLocation | null | undefined}, + second?: {loc?: SourceLocation | null | undefined}, + ): SourceLocation | null | undefined { + if (!second) { + return first && first.loc; + } else if (!first || !first.loc || !second.loc || + first.loc.lexer !== second.loc.lexer) { + return null; + } else { + return new SourceLocation( + first.loc.lexer, first.loc.start, second.loc.end); + } + } +} diff --git a/node_modules/react-katex/node_modules/katex/src/Style.ts b/node_modules/react-katex/node_modules/katex/src/Style.ts new file mode 100644 index 0000000..4926258 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/Style.ts @@ -0,0 +1,129 @@ +/** + * This file contains information and classes for the various kinds of styles + * used in TeX. It provides a generic `Style` class, which holds information + * about a specific style. It then provides instances of all the different kinds + * of styles possible, and provides functions to move between them and get + * information about them. + */ + +/** + * The main style class. Contains a unique id for the style, a size (which is + * the same for cramped and uncramped version of a style), and a cramped flag. + */ +class Style implements StyleInterface { + id: number; + size: number; + cramped: boolean; + + constructor(id: number, size: number, cramped: boolean) { + this.id = id; + this.size = size; + this.cramped = cramped; + } + + /** + * Get the style of a superscript given a base in the current style. + */ + sup(): Style { + return styles[sup[this.id]]; + } + + /** + * Get the style of a subscript given a base in the current style. + */ + sub(): Style { + return styles[sub[this.id]]; + } + + /** + * Get the style of a fraction numerator given the fraction in the current + * style. + */ + fracNum(): Style { + return styles[fracNum[this.id]]; + } + + /** + * Get the style of a fraction denominator given the fraction in the current + * style. + */ + fracDen(): Style { + return styles[fracDen[this.id]]; + } + + /** + * Get the cramped version of a style (in particular, cramping a cramped style + * doesn't change the style). + */ + cramp(): Style { + return styles[cramp[this.id]]; + } + + /** + * Get a text or display version of this style. + */ + text(): Style { + return styles[text[this.id]]; + } + + /** + * Return true if this style is tightly spaced (scriptstyle/scriptscriptstyle) + */ + isTight(): boolean { + return this.size >= 2; + } +} + +// Export an interface for type checking, but don't expose the implementation. +// This way, no more styles can be generated. +export interface StyleInterface { + id: number; + size: number; + cramped: boolean; + + sup(): StyleInterface; + sub(): StyleInterface; + fracNum(): StyleInterface; + fracDen(): StyleInterface; + cramp(): StyleInterface; + text(): StyleInterface; + isTight(): boolean; +} + +// IDs of the different styles +const D = 0; +const Dc = 1; +const T = 2; +const Tc = 3; +const S = 4; +const Sc = 5; +const SS = 6; +const SSc = 7; + +// Instances of the different styles +const styles = [ + new Style(D, 0, false), + new Style(Dc, 0, true), + new Style(T, 1, false), + new Style(Tc, 1, true), + new Style(S, 2, false), + new Style(Sc, 2, true), + new Style(SS, 3, false), + new Style(SSc, 3, true), +]; + +// Lookup tables for switching from one style to another +const sup = [S, Sc, S, Sc, SS, SSc, SS, SSc]; +const sub = [Sc, Sc, Sc, Sc, SSc, SSc, SSc, SSc]; +const fracNum = [T, Tc, S, Sc, SS, SSc, SS, SSc]; +const fracDen = [Tc, Tc, Sc, Sc, SSc, SSc, SSc, SSc]; +const cramp = [Dc, Dc, Tc, Tc, Sc, Sc, SSc, SSc]; +const text = [D, Dc, T, Tc, T, Tc, T, Tc]; + +// We only export some of the styles. +export default { + DISPLAY: (styles[D] as Style), + TEXT: (styles[T] as Style), + SCRIPT: (styles[S] as Style), + SCRIPTSCRIPT: (styles[SS] as Style), +}; diff --git a/node_modules/react-katex/node_modules/katex/src/Token.ts b/node_modules/react-katex/node_modules/katex/src/Token.ts new file mode 100644 index 0000000..78cee4f --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/Token.ts @@ -0,0 +1,49 @@ +import SourceLocation from "./SourceLocation"; + +/** + * Interface required to break circular dependency between Token, Lexer, and + * ParseError. + */ +export interface LexerInterface { + input: string; + tokenRegex: RegExp; +} + +/** + * The resulting token returned from `lex`. + * + * It consists of the token text plus some position information. + * The position information is essentially a range in an input string, + * but instead of referencing the bare input string, we refer to the lexer. + * That way it is possible to attach extra metadata to the input string, + * like for example a file name or similar. + * + * The position information is optional, so it is OK to construct synthetic + * tokens if appropriate. Not providing available position information may + * lead to degraded error reporting, though. + */ +export class Token { + text: string; + loc: SourceLocation | null | undefined; + noexpand: boolean | null | undefined; // don't expand the token + treatAsRelax: boolean | null | undefined; // used in \noexpand + + constructor( + text: string, // the text of this token + loc?: SourceLocation | null | undefined, + ) { + this.text = text; + this.loc = loc; + } + + /** + * Given a pair of tokens (this and endToken), compute a `Token` encompassing + * the whole input range enclosed by these two. + */ + range( + endToken: Token, // last token of the range, inclusive + text: string, // the text of the newly constructed token + ): Token { + return new Token(text, SourceLocation.range(this, endToken)); + } +} diff --git a/node_modules/react-katex/node_modules/katex/src/atoms.ts b/node_modules/react-katex/node_modules/katex/src/atoms.ts new file mode 100644 index 0000000..b7fa920 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/atoms.ts @@ -0,0 +1,33 @@ +/** + * Small module for atom-group constants and type guard. Kept separate from + * `symbols.ts` so that consumers (notably `contrib/render-a11y-string`) can + * pull in `isAtom` without dragging in the ~870-line symbol tables. + */ + +// Some of these have a "-token" suffix since these are also used as `ParseNode` +// types for raw text tokens, and we want to avoid conflicts with higher-level +// `ParseNode` types. These `ParseNode`s are constructed within `Parser` by +// looking up the `symbols` map. +export const ATOMS = { + "bin": 1, + "close": 1, + "inner": 1, + "open": 1, + "punct": 1, + "rel": 1, +}; +export const NON_ATOMS = { + "accent-token": 1, + "mathord": 1, + "op-token": 1, + "spacing": 1, + "textord": 1, +}; + +export type Atom = keyof typeof ATOMS; +export type NonAtom = keyof typeof NON_ATOMS; +export type Group = Atom | NonAtom; + +export function isAtom(value: string): value is Atom { + return value in ATOMS; +} diff --git a/node_modules/react-katex/node_modules/katex/src/buildCommon.ts b/node_modules/react-katex/node_modules/katex/src/buildCommon.ts new file mode 100644 index 0000000..0a37357 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/buildCommon.ts @@ -0,0 +1,783 @@ +/* eslint no-console:0 */ +/** + * This module contains general functions that can be used for building + * different kinds of domTree nodes in a consistent manner. + */ + +import {SymbolNode, Anchor, Span, PathNode, SvgNode, createClass} from "./domTree"; +import {getCharacterMetrics} from "./fontMetrics"; +import symbols, {ligatures} from "./symbols"; +import {wideCharacterFont} from "./wide-character"; +import {calculateSize, makeEm} from "./units"; +import {DocumentFragment} from "./tree"; + +import type Options from "./Options"; +import type {ParseNode} from "./parseNode"; +import type {Mode} from "./types"; +import type {documentFragment as HtmlDocumentFragment} from "./domTree"; +import type {HtmlDomNode, DomSpan, SvgSpan, CssStyle} from "./domTree"; +import type {Measurement} from "./units"; +import type { + CharacterMetrics, + FontName, + FontShape, + FontVariant, + FontWeight, + TextFont, +} from "./types/fonts"; + +/** + * Looks up the given symbol in fontMetrics, after applying any symbol + * replacements defined in symbol.js + */ +const lookupSymbol = function( + value: string, + fontName: FontName, + mode: Mode, +): { + value: string; + metrics: CharacterMetrics | null | undefined; +} { + // Replace the value with its replaced value from symbol.js + if (symbols[mode][value]) { + const replacement = symbols[mode][value].replace; + if (replacement) { + value = replacement; + } + } + + return { + value, + metrics: getCharacterMetrics(value, fontName, mode), + }; +}; + +/** + * Makes a symbolNode after translation via the list of symbols in symbols.js. + * Correctly pulls out metrics for the character, and optionally takes a list of + * classes to be attached to the node. + * + * TODO: make argument order closer to makeSpan + * TODO: add a separate argument for math class (e.g. `mop`, `mbin`), which + * should if present come first in `classes`. + * TODO(#953): Make `options` mandatory and always pass it in. + */ +export const makeSymbol = function( + value: string, + fontName: FontName, + mode: Mode, + options?: Options, + classes?: string[], +): SymbolNode { + const lookup = lookupSymbol(value, fontName, mode); + const metrics = lookup.metrics; + value = lookup.value; + + let symbolNode; + if (metrics) { + let italic = metrics.italic; + if (mode === "text" || (options && options.font === "mathit")) { + italic = 0; + } + symbolNode = new SymbolNode( + value, metrics.height, metrics.depth, italic, metrics.skew, + metrics.width, classes); + } else { + // TODO(emily): Figure out a good way to only print this in development + typeof console !== "undefined" && console.warn("No character metrics " + + `for '${value}' in style '${fontName}' and mode '${mode}'`); + symbolNode = new SymbolNode(value, 0, 0, 0, 0, 0, classes); + } + + if (options) { + symbolNode.maxFontSize = options.sizeMultiplier; + if (options.style.isTight()) { + symbolNode.classes.push("mtight"); + } + const color = options.getColor(); + if (color) { + symbolNode.style.color = color; + } + } + + return symbolNode; +}; + +/** + * Makes a symbol in Main-Regular or AMS-Regular. + * Used for rel, bin, open, close, inner, and punct. + */ +export const mathsym = function( + value: string, + mode: Mode, + options: Options, + classes: string[] = [], +): SymbolNode { + // Decide what font to render the symbol in by its entry in the symbols + // table. + // Have a special case for when the value = \ because the \ is used as a + // textord in unsupported command errors but cannot be parsed as a regular + // text ordinal and is therefore not present as a symbol in the symbols + // table for text, as well as a special case for boldsymbol because it + // can be used for bold + and - + if (options.font === "boldsymbol" && + lookupSymbol(value, "Main-Bold", mode).metrics) { + return makeSymbol(value, "Main-Bold", mode, options, + classes.concat(["mathbf"])); + } else if (value === "\\" || symbols[mode][value].font === "main") { + return makeSymbol(value, "Main-Regular", mode, options, classes); + } else { + return makeSymbol( + value, "AMS-Regular", mode, options, classes.concat(["amsrm"])); + } +}; + +/** + * Determines which of the two font names (Main-Bold and Math-BoldItalic) and + * corresponding style tags (mathbf or boldsymbol) to use for font "boldsymbol", + * depending on the symbol. Use this function instead of fontMap for font + * "boldsymbol". + */ +const boldSymbol = function( + value: string, + mode: Mode, + type: "mathord" | "textord", +): { + fontName: "Math-BoldItalic" | "Main-Bold"; + fontClass: "boldsymbol" | "mathbf"; +} { + if ( + type !== "textord" && + lookupSymbol(value, "Math-BoldItalic", mode).metrics + ) { + return { + fontName: "Math-BoldItalic", + fontClass: "boldsymbol", + }; + } else { + // Some glyphs do not exist in Math-BoldItalic so we need to use + // Main-Bold instead. + return { + fontName: "Main-Bold", + fontClass: "mathbf", + }; + } +}; + +/** + * Makes either a mathord or textord in the correct font and color. + */ +export const makeOrd = function( + group: ParseNode, + options: Options, + type: "mathord" | "textord", +): HtmlDocumentFragment | SymbolNode { + const mode = group.mode; + const text = group.text; + const classes = ["mord"]; + const {font, fontFamily, fontWeight, fontShape} = options; + + // Math mode or Old font (i.e. \rm) + const useFont = mode === "math" || (mode === "text" && !!font); + const fontOrFamily = useFont ? font : fontFamily; + let wideFontName: FontName | "" = ""; + let wideFontClass = ""; + if (text.charCodeAt(0) === 0xD835) { + const wideCharData = wideCharacterFont(text); + wideFontName = wideCharData.font; + wideFontClass = wideCharData[`${mode}Class`]; + } + if (wideFontName) { + // surrogate pairs get special treatment + return makeSymbol(text, wideFontName, mode, options, classes.concat(wideFontClass)); + } else if (fontOrFamily) { + let fontName; + let fontClasses; + if (fontOrFamily === "boldsymbol") { + const fontData = boldSymbol(text, mode, type); + fontName = fontData.fontName; + fontClasses = [fontData.fontClass]; + } else if (useFont) { + fontName = fontMap[font].fontName; + fontClasses = [font]; + } else { + fontName = retrieveTextFontName( + fontFamily, + fontWeight, + fontShape, + ); + fontClasses = [fontFamily, fontWeight, fontShape]; + } + + if (lookupSymbol(text, fontName, mode).metrics) { + return makeSymbol(text, fontName, mode, options, + classes.concat(fontClasses)); + } else if (ligatures.hasOwnProperty(text) && + fontName.slice(0, 10) === "Typewriter") { + // Deconstruct ligatures in monospace fonts (\texttt, \tt). + const parts = []; + for (let i = 0; i < text.length; i++) { + parts.push(makeSymbol(text[i], fontName, mode, options, + classes.concat(fontClasses))); + } + return makeFragment(parts); + } + } + + // Makes a symbol in the default font for mathords and textords. + if (type === "mathord") { + return makeSymbol(text, "Math-Italic", mode, options, + classes.concat(["mathnormal"])); + } else if (type === "textord") { + const font = symbols[mode][text] && symbols[mode][text].font; + if (font === "ams") { + const fontName = retrieveTextFontName("amsrm", fontWeight, fontShape); + return makeSymbol( + text, fontName, mode, options, + classes.concat("amsrm", fontWeight, fontShape)); + } else if (font === "main" || !font) { + const fontName = retrieveTextFontName("textrm", fontWeight, fontShape); + return makeSymbol( + text, fontName, mode, options, + classes.concat(fontWeight, fontShape)); + } else { // fonts added by plugins + const fontName = retrieveTextFontName(font, fontWeight, fontShape); + // We add font name as a css class + return makeSymbol( + text, fontName, mode, options, + classes.concat(fontName, fontWeight, fontShape)); + } + } else { + throw new Error("unexpected type: " + type + " in makeOrd"); + } +}; + +/** + * Returns true if subsequent symbolNodes have the same classes, skew, maxFont, + * and styles. For mathnormal text, the left node must also have zero italic + * correction so we don't lose spacing between combined glyphs. + */ +const canCombine = (prev: SymbolNode, next: SymbolNode) => { + if (createClass(prev.classes) !== createClass(next.classes) + || prev.skew !== next.skew + || prev.maxFontSize !== next.maxFontSize + || (prev.italic !== 0 && prev.hasClass("mathnormal"))) { + return false; + } + + // If prev and next both are just "mbin"s or "mord"s we don't combine them + // so that the proper spacing can be preserved. + if (prev.classes.length === 1) { + const cls = prev.classes[0]; + if (cls === "mbin" || cls === "mord") { + return false; + } + } + + for (const key of Object.keys(prev.style) as Array) { + if (prev.style[key] !== next.style[key]) { + return false; + } + } + + for (const key of Object.keys(next.style) as Array) { + if (prev.style[key] !== next.style[key]) { + return false; + } + } + + return true; +}; + +/** + * Combine consecutive domTree.symbolNodes into a single symbolNode. + * Note: this function mutates the argument. + */ +export const tryCombineChars = (chars: HtmlDomNode[]): HtmlDomNode[] => { + for (let i = 0; i < chars.length - 1; i++) { + const prev = chars[i]; + const next = chars[i + 1]; + if (prev instanceof SymbolNode + && next instanceof SymbolNode + && canCombine(prev, next)) { + + prev.text += next.text; + prev.height = Math.max(prev.height, next.height); + prev.depth = Math.max(prev.depth, next.depth); + // Use the last character's italic correction since we use + // it to add padding to the right of the span created from + // the combined characters. + prev.italic = next.italic; + chars.splice(i + 1, 1); + i--; + } + } + return chars; +}; + +/** + * Calculate the height, depth, and maxFontSize of an element based on its + * children. + */ +const sizeElementFromChildren = function( + elem: DomSpan | Anchor | HtmlDocumentFragment, +) { + let height = 0; + let depth = 0; + let maxFontSize = 0; + + for (let i = 0; i < elem.children.length; i++) { + const child = elem.children[i]; + if (child.height > height) { + height = child.height; + } + if (child.depth > depth) { + depth = child.depth; + } + if (child.maxFontSize > maxFontSize) { + maxFontSize = child.maxFontSize; + } + } + + elem.height = height; + elem.depth = depth; + elem.maxFontSize = maxFontSize; +}; + +/** + * Makes a span with the given list of classes, list of children, and options. + * + * TODO(#953): Ensure that `options` is always provided (currently some call + * sites don't pass it) and make the type below mandatory. + * TODO: add a separate argument for math class (e.g. `mop`, `mbin`), which + * should if present come first in `classes`. + */ +export const makeSpan = function( + classes?: string[], + children?: HtmlDomNode[], + options?: Options, + style?: CssStyle, +): DomSpan { + const span = new Span(classes, children, options, style); + + sizeElementFromChildren(span); + + return span; +}; + +// SVG one is simpler -- doesn't require height, depth, max-font setting. +// This is also a separate method for typesafety. +export const makeSvgSpan = ( + classes?: string[], + children?: SvgNode[], + options?: Options, + style?: CssStyle, +): SvgSpan => new Span(classes, children, options, style); + +export const makeLineSpan = function( + className: string, + options: Options, + thickness?: number, +): DomSpan { + const line = makeSpan([className], [], options); + line.height = Math.max( + thickness || options.fontMetrics().defaultRuleThickness, + options.minRuleThickness, + ); + line.style.borderBottomWidth = makeEm(line.height); + line.maxFontSize = 1.0; + return line; +}; + +/** + * Makes an anchor with the given href, list of classes, list of children, + * and options. + */ +export const makeAnchor = function( + href: string, + classes: string[], + children: HtmlDomNode[], + options: Options, +): Anchor { + const anchor = new Anchor(href, classes, children, options); + + sizeElementFromChildren(anchor); + + return anchor; +}; + +/** + * Makes a document fragment with the given list of children. + */ +export const makeFragment = function( + children: HtmlDomNode[], +): HtmlDocumentFragment { + const fragment = new DocumentFragment(children); + + sizeElementFromChildren(fragment); + + return fragment; +}; + +/** + * Wraps group in a span if it's a document fragment, allowing to apply classes + * and styles + */ +export const wrapFragment = function( + group: HtmlDomNode, + options: Options, +): HtmlDomNode { + if (group instanceof DocumentFragment) { + return makeSpan([], [group], options); + } + return group; +}; + +export type VListElem = { + type: "elem"; + elem: HtmlDomNode; + marginLeft?: string | null | undefined; + marginRight?: string; + wrapperClasses?: string[]; + wrapperStyle?: CssStyle; +}; +type VListElemAndShift = { + type: "elem"; + elem: HtmlDomNode; + shift: number; + marginLeft?: string | null | undefined; + marginRight?: string; + wrapperClasses?: string[]; + wrapperStyle?: CssStyle; +}; +type VListKern = { + type: "kern"; + size: number; +}; + +// A list of child or kern nodes to be stacked on top of each other (i.e. the +// first element will be at the bottom, and the last at the top). +type VListChild = VListElem | VListKern; +type VListParam = { + // Each child contains how much it should be shifted downward. + positionType: "individualShift"; + children: VListElemAndShift[]; +} | { + // "top": The positionData specifies the topmost point of the vlist (note this + // is expected to be a height, so positive values move up). + // "bottom": The positionData specifies the bottommost point of the vlist (note + // this is expected to be a depth, so positive values move down). + // "shift": The vlist will be positioned such that its baseline is positionData + // away from the baseline of the first child which MUST be an + // "elem". Positive values move downwards. + positionType: "top" | "bottom" | "shift"; + positionData: number; + children: VListChild[]; +} | { + // The vlist is positioned so that its baseline is aligned with the baseline + // of the first child which MUST be an "elem". This is equivalent to "shift" + // with positionData=0. + positionType: "firstBaseline"; + children: VListChild[]; +}; + +// Computes the updated `children` list and the overall depth. +// +// This helper function for makeVList makes it easier to enforce type safety by +// allowing early exits (returns) in the logic. +const getVListChildrenAndDepth = function(params: VListParam): { + children: (VListChild | VListElemAndShift)[] | VListChild[]; + depth: number; +} { + if (params.positionType === "individualShift") { + const oldChildren = params.children; + const children: (VListChild | VListElemAndShift)[] = [oldChildren[0]]; + + // Add in kerns to the list of params.children to get each element to be + // shifted to the correct specified shift + const depth = -oldChildren[0].shift - oldChildren[0].elem.depth; + let currPos = depth; + for (let i = 1; i < oldChildren.length; i++) { + const diff = -oldChildren[i].shift - currPos - + oldChildren[i].elem.depth; + const size = diff - + (oldChildren[i - 1].elem.height + + oldChildren[i - 1].elem.depth); + + currPos = currPos + diff; + children.push({type: "kern", size}); + children.push(oldChildren[i]); + } + + return {children, depth}; + } + + let depth; + if (params.positionType === "top") { + // We always start at the bottom, so calculate the bottom by adding up + // all the sizes + let bottom = params.positionData; + for (let i = 0; i < params.children.length; i++) { + const child = params.children[i]; + bottom -= child.type === "kern" + ? child.size + : child.elem.height + child.elem.depth; + } + depth = bottom; + } else if (params.positionType === "bottom") { + depth = -params.positionData; + } else { + const firstChild = params.children[0]; + if (firstChild.type !== "elem") { + throw new Error('First child must have type "elem".'); + } + if (params.positionType === "shift") { + depth = -firstChild.elem.depth - params.positionData; + } else if (params.positionType === "firstBaseline") { + depth = -firstChild.elem.depth; + } else { + throw new Error(`Invalid positionType ${params.positionType}.`); + } + } + + return {children: params.children, depth}; +}; + +/** + * Makes a vertical list by stacking elements and kerns on top of each other. + * Allows for many different ways of specifying the positioning method. + * + * See VListParam documentation above. + */ +export const makeVList = function(params: VListParam, options: Options): DomSpan { + const {children, depth} = getVListChildrenAndDepth(params); + + // Create a strut that is taller than any list item. The strut is added to + // each item, where it will determine the item's baseline. Since it has + // `overflow:hidden`, the strut's top edge will sit on the item's line box's + // top edge and the strut's bottom edge will sit on the item's baseline, + // with no additional line-height spacing. This allows the item baseline to + // be positioned precisely without worrying about font ascent and + // line-height. + let pstrutSize = 0; + for (let i = 0; i < children.length; i++) { + const child = children[i]; + if (child.type === "elem") { + const elem = child.elem; + pstrutSize = Math.max(pstrutSize, elem.maxFontSize, elem.height); + } + } + pstrutSize += 2; + const pstrut = makeSpan(["pstrut"], []); + pstrut.style.height = makeEm(pstrutSize); + + // Create a new list of actual children at the correct offsets + const realChildren = []; + let minPos = depth; + let maxPos = depth; + let currPos = depth; + for (let i = 0; i < children.length; i++) { + const child = children[i]; + if (child.type === "kern") { + currPos += child.size; + } else { + const elem = child.elem; + const classes = child.wrapperClasses || []; + const style = child.wrapperStyle || {}; + + const childWrap = makeSpan(classes, [pstrut, elem], undefined, style); + childWrap.style.top = makeEm(-pstrutSize - currPos - elem.depth); + if (child.marginLeft) { + childWrap.style.marginLeft = child.marginLeft; + } + if (child.marginRight) { + childWrap.style.marginRight = child.marginRight; + } + + realChildren.push(childWrap); + currPos += elem.height + elem.depth; + } + minPos = Math.min(minPos, currPos); + maxPos = Math.max(maxPos, currPos); + } + + // The vlist contents go in a table-cell with `vertical-align:bottom`. + // This cell's bottom edge will determine the containing table's baseline + // without overly expanding the containing line-box. + const vlist = makeSpan(["vlist"], realChildren); + vlist.style.height = makeEm(maxPos); + + // A second row is used if necessary to represent the vlist's depth. + let rows; + if (minPos < 0) { + // We will define depth in an empty span with display: table-cell. + // It should render with the height that we define. But Chrome, in + // contenteditable mode only, treats that span as if it contains some + // text content. And that min-height over-rides our desired height. + // So we put another empty span inside the depth strut span. + const emptySpan = makeSpan([], []); + const depthStrut = makeSpan(["vlist"], [emptySpan]); + depthStrut.style.height = makeEm(-minPos); + + // Safari wants the first row to have inline content; otherwise it + // puts the bottom of the *second* row on the baseline. + const topStrut = makeSpan(["vlist-s"], [new SymbolNode("\u200b")]); + + rows = [makeSpan(["vlist-r"], [vlist, topStrut]), + makeSpan(["vlist-r"], [depthStrut])]; + } else { + rows = [makeSpan(["vlist-r"], [vlist])]; + } + + const vtable = makeSpan(["vlist-t"], rows); + if (rows.length === 2) { + vtable.classes.push("vlist-t2"); + } + vtable.height = maxPos; + vtable.depth = -minPos; + return vtable; +}; + +// Glue is a concept from TeX which is a flexible space between elements in +// either a vertical or horizontal list. In KaTeX, at least for now, it's +// static space between elements in a horizontal layout. +export const makeGlue = (measurement: Measurement, options: Options): DomSpan => { + // Make an empty span for the space + const rule = makeSpan(["mspace"], [], options); + const size = calculateSize(measurement, options); + rule.style.marginRight = makeEm(size); + return rule; +}; + +// Takes font options, and returns the appropriate fontLookup name +const retrieveTextFontName = ( + fontFamily: TextFont, + fontWeight: FontWeight, + fontShape: FontShape, +): FontName => { + let baseFontName: "AMS" | "Main" | "SansSerif" | "Typewriter" | TextFont; + let fontStylesName: "BoldItalic" | "Bold" | "Italic" | "Regular"; + + switch (fontFamily) { + case "amsrm": + baseFontName = "AMS"; + break; + case "textrm": + baseFontName = "Main"; + break; + case "textsf": + baseFontName = "SansSerif"; + break; + case "texttt": + baseFontName = "Typewriter"; + break; + default: + baseFontName = fontFamily; // use fonts added by a plugin + } + + if (fontWeight === "textbf" && fontShape === "textit") { + fontStylesName = "BoldItalic"; + } else if (fontWeight === "textbf") { + fontStylesName = "Bold"; + } else if (fontShape === "textit") { + fontStylesName = "Italic"; + } else { + fontStylesName = "Regular"; + } + + return `${baseFontName}-${fontStylesName}` as FontName; +}; + +/** + * Maps TeX font commands to objects containing: + * - variant: string used for "mathvariant" attribute in buildMathML.js + * - fontName: the "style" parameter to fontMetrics.getCharacterMetrics + */ +// A map between tex font commands an MathML mathvariant attribute values +export const fontMap: Record = { + // styles + "mathbf": { + variant: "bold", + fontName: "Main-Bold", + }, + "mathrm": { + variant: "normal", + fontName: "Main-Regular", + }, + "textit": { + variant: "italic", + fontName: "Main-Italic", + }, + "mathit": { + variant: "italic", + fontName: "Main-Italic", + }, + "mathnormal": { + variant: "italic", + fontName: "Math-Italic", + }, + "mathsfit": { + variant: "sans-serif-italic", + fontName: "SansSerif-Italic", + }, + // "boldsymbol" is missing because they require the use of multiple fonts: + // Math-BoldItalic and Main-Bold. This is handled by a special case in + // makeOrd which ends up calling boldsymbol. + + // families + "mathbb": { + variant: "double-struck", + fontName: "AMS-Regular", + }, + "mathcal": { + variant: "script", + fontName: "Caligraphic-Regular", + }, + "mathfrak": { + variant: "fraktur", + fontName: "Fraktur-Regular", + }, + "mathscr": { + variant: "script", + fontName: "Script-Regular", + }, + "mathsf": { + variant: "sans-serif", + fontName: "SansSerif-Regular", + }, + "mathtt": { + variant: "monospace", + fontName: "Typewriter-Regular", + }, +}; + +export const svgData: Record = { + // path, width, height + vec: ["vec", 0.471, 0.714], // values from the font glyph + oiintSize1: ["oiintSize1", 0.957, 0.499], // oval to overlay the integrand + oiintSize2: ["oiintSize2", 1.472, 0.659], + oiiintSize1: ["oiiintSize1", 1.304, 0.499], + oiiintSize2: ["oiiintSize2", 1.98, 0.659], +}; + +export const staticSvg = function(value: string, options: Options): SvgSpan { + // Create a span with inline SVG for the element. + const [pathName, width, height] = svgData[value]; + const path = new PathNode(pathName); + const svgNode = new SvgNode([path], { + "width": makeEm(width), + "height": makeEm(height), + // Override CSS rule `.katex svg { width: 100% }` + "style": "width:" + makeEm(width), + "viewBox": "0 0 " + 1000 * width + " " + 1000 * height, + "preserveAspectRatio": "xMinYMin", + }); + const span = makeSvgSpan(["overlay"], [svgNode], options); + span.height = height; + span.style.height = makeEm(height); + span.style.width = makeEm(width); + return span; +}; diff --git a/node_modules/react-katex/node_modules/katex/src/buildHTML.ts b/node_modules/react-katex/node_modules/katex/src/buildHTML.ts new file mode 100644 index 0000000..3458ea3 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/buildHTML.ts @@ -0,0 +1,412 @@ +/** + * This file does the main work of building a domTree structure from a parse + * tree. The entry point is the `buildHTML` function, which takes a parse tree. + * Then, the buildExpression, buildGroup, and various groupBuilders functions + * are called, to produce a final HTML tree. + */ + +import ParseError from "./ParseError"; +import Style from "./Style"; +import {makeGlue, makeSpan, tryCombineChars} from "./buildCommon"; +import {Span, Anchor} from "./domTree"; +import {makeEm} from "./units"; +import {spacings, tightSpacings} from "./spacingData"; +import {_htmlGroupBuilders as groupBuilders} from "./defineFunction"; +import {DocumentFragment} from "./tree"; + +import type Options from "./Options"; +import type {AnyParseNode} from "./parseNode"; +import type {HtmlDomNode, DomSpan} from "./domTree"; + +// Binary atoms (first class `mbin`) change into ordinary atoms (`mord`) +// depending on their surroundings. See TeXbook pg. 442-446, Rules 5 and 6, +// and the text before Rule 19. +const binLeftCanceller = new Set([ + "leftmost", "mbin", "mopen", "mrel", "mop", "mpunct", +]); +const binRightCanceller = new Set([ + "rightmost", "mrel", "mclose", "mpunct", +]); + +const styleMap = { + "display": Style.DISPLAY, + "text": Style.TEXT, + "script": Style.SCRIPT, + "scriptscript": Style.SCRIPTSCRIPT, +}; + +type Side = "left" | "right"; + +const DomEnum = { + mord: "mord", + mop: "mop", + mbin: "mbin", + mrel: "mrel", + mopen: "mopen", + mclose: "mclose", + mpunct: "mpunct", + minner: "minner", +}; +type DomType = keyof typeof DomEnum; + +/** + * Take a list of nodes, build them in order, and return a list of the built + * nodes. documentFragments are flattened into their contents, so the + * returned list contains no fragments. `isRealGroup` is true if `expression` + * is a real group (no atoms will be added on either side), as opposed to + * a partial group (e.g. one created by \color). `surrounding` is an array + * consisting type of nodes that will be added to the left and right. + */ +export const buildExpression = function( + expression: AnyParseNode[], + options: Options, + isRealGroup: boolean | "root", + surrounding: [DomType | null | undefined, DomType | null | undefined] = [null, null], +): HtmlDomNode[] { + // Parse expressions into `groups`. + const groups: HtmlDomNode[] = []; + for (let i = 0; i < expression.length; i++) { + const output = buildGroup(expression[i], options); + if (output instanceof DocumentFragment) { + const children: ReadonlyArray = output.children; + groups.push(...children); + } else { + groups.push(output); + } + } + + // Combine consecutive domTree.symbolNodes into a single symbolNode. + tryCombineChars(groups); + + // If `expression` is a partial group, let the parent handle spacings + // to avoid processing groups multiple times. + if (!isRealGroup) { + return groups; + } + + let glueOptions = options; + if (expression.length === 1) { + const node = expression[0]; + if (node.type === "sizing") { + glueOptions = options.havingSize(node.size); + } else if (node.type === "styling") { + glueOptions = options.havingStyle(styleMap[node.style]); + } + } + + // Dummy spans for determining spacings between surrounding atoms. + // If `expression` has no atoms on the left or right, class "leftmost" + // or "rightmost", respectively, is used to indicate it. + const dummyPrev = makeSpan([surrounding[0] || "leftmost"], [], options); + const dummyNext = makeSpan([surrounding[1] || "rightmost"], [], options); + + // TODO: These code assumes that a node's math class is the first element + // of its `classes` array. A later cleanup should ensure this, for + // instance by changing the signature of `makeSpan`. + + // Before determining what spaces to insert, perform bin cancellation. + // Binary operators change to ordinary symbols in some contexts. + const isRoot = (isRealGroup === "root"); + traverseNonSpaceNodes(groups, (node, prev): void => { + const prevType = prev.classes[0]; + const type = node.classes[0]; + if (prevType === "mbin" && binRightCanceller.has(type)) { + prev.classes[0] = "mord"; + } else if (type === "mbin" && binLeftCanceller.has(prevType)) { + node.classes[0] = "mord"; + } + }, {node: dummyPrev}, dummyNext, isRoot); + + traverseNonSpaceNodes(groups, (node, prev): HtmlDomNode | undefined => { + const prevType = getTypeOfDomTree(prev); + const type = getTypeOfDomTree(node); + + // 'mtight' indicates that the node is script or scriptscript style. + const space = prevType && type ? (node.hasClass("mtight") + ? tightSpacings[prevType]?.[type] + : spacings[prevType]?.[type]) : null; + + if (space) { // Insert glue (spacing) after the `prev`. + return makeGlue(space, glueOptions); + } + }, {node: dummyPrev}, dummyNext, isRoot); + + return groups; +}; + +// Depth-first traverse non-space `nodes`, calling `callback` with the current and +// previous node as arguments, optionally returning a node to insert after the +// previous node. `prev` is an object with the previous node and `insertAfter` +// function to insert after it. `next` is a node that will be added to the right. +// Used for bin cancellation and inserting spacings. +const traverseNonSpaceNodes = function( + nodes: HtmlDomNode[], + callback: (arg0: HtmlDomNode, arg1: HtmlDomNode) => + HtmlDomNode | null | void, + prev: { + node: HtmlDomNode, + insertAfter?: (arg0: HtmlDomNode) => void, + }, + next: HtmlDomNode | null | undefined, + isRoot: boolean, +) { + if (next) { // temporarily append the right node, if exists + nodes.push(next); + } + let i = 0; + for (; i < nodes.length; i++) { + const node = nodes[i]; + const partialGroup = checkPartialGroup(node); + + if (partialGroup) { // Recursive DFS + // TODO(ts): partialGroup.children is ReadonlyArray but this + // function mutates the array (insertAfter splices into it). + traverseNonSpaceNodes(partialGroup.children as HtmlDomNode[], + callback, prev, null, isRoot); + continue; + } + + // Ignore explicit spaces (e.g., \;, \,) when determining what implicit + // spacing should go between atoms of different classes + const nonspace = !node.hasClass("mspace"); + if (nonspace) { + const result = callback(node, prev.node); + if (result) { + if (prev.insertAfter) { + prev.insertAfter(result); + } else { // insert at front + nodes.unshift(result); + i++; + } + } + } + + if (nonspace) { + prev.node = node; + } else if (isRoot && node.hasClass("newline")) { + prev.node = makeSpan(["leftmost"]); // treat like beginning of line + } + prev.insertAfter = (index => n => { + nodes.splice(index + 1, 0, n); + i++; + })(i); + } + + if (next) { + nodes.pop(); + } +}; + +// Check if given node is a partial group, i.e., does not affect spacing around. +const checkPartialGroup = function( + node: HtmlDomNode, +): DocumentFragment | Anchor | DomSpan | null | undefined { + if (node instanceof DocumentFragment || node instanceof Anchor + || (node instanceof Span && node.hasClass("enclosing"))) { + return node; + } + return null; +}; + +// Return the outermost node of a domTree. +const getOutermostNode = function( + node: HtmlDomNode, + side: Side, +): HtmlDomNode { + const partialGroup = checkPartialGroup(node); + if (partialGroup) { + const children = partialGroup.children; + if (children.length) { + if (side === "right") { + return getOutermostNode(children[children.length - 1], "right"); + } else if (side === "left") { + return getOutermostNode(children[0], "left"); + } + } + } + return node; +}; + +// Return math atom class (mclass) of a domTree. +// If `side` is given, it will get the type of the outermost node at given side. +export const getTypeOfDomTree = function( + node: HtmlDomNode | null | undefined, + side?: Side | null | undefined, +): DomType | null | undefined { + if (!node) { + return null; + } + if (side) { + node = getOutermostNode(node, side); + } + // This makes a lot of assumptions as to where the type of atom + // appears. We should do a better job of enforcing this. + const className = node.classes[0] as keyof typeof DomEnum; + return (DomEnum[className] as DomType | undefined) || null; +}; +export const makeNullDelimiter = function( + options: Options, + classes: string[], +): DomSpan { + const moreClasses = ["nulldelimiter"].concat(options.baseSizingClasses()); + return makeSpan(classes.concat(moreClasses)); +}; + +/** + * buildGroup is the function that takes a group and calls the correct groupType + * function for it. It also handles the interaction of size and style changes + * between parents and children. + */ +export const buildGroup = function( + group: AnyParseNode | null | undefined, + options: Options, + baseOptions?: Options, +): HtmlDomNode { + if (!group) { + return makeSpan(); + } + + if (groupBuilders[group.type]) { + // TODO(ts): groupBuilders is Record>; + // a type-safe registry would need a mapped type keyed by NodeType. + let groupNode: HtmlDomNode = groupBuilders[group.type](group, options); + + // If the size changed between the parent and the current group, account + // for that size difference. + if (baseOptions && options.size !== baseOptions.size) { + groupNode = makeSpan(options.sizingClasses(baseOptions), + [groupNode], options); + + const multiplier = + options.sizeMultiplier / baseOptions.sizeMultiplier; + + groupNode.height *= multiplier; + groupNode.depth *= multiplier; + } + + return groupNode; + } else { + throw new ParseError( + "Got group of unknown type: '" + group.type + "'"); + } +}; + +/** + * Combine an array of HTML DOM nodes (e.g., the output of `buildExpression`) + * into an unbreakable HTML node of class .base, with proper struts to + * guarantee correct vertical extent. `buildHTML` calls this repeatedly to + * make up the entire expression as a sequence of unbreakable units. + */ +function buildHTMLUnbreakable(children: HtmlDomNode[], options: Options) { + // Compute height and depth of this chunk. + const body = makeSpan(["base"], children, options); + + // Add strut, which ensures that the top of the HTML element falls at + // the height of the expression, and the bottom of the HTML element + // falls at the depth of the expression. + const strut = makeSpan(["strut"]); + strut.style.height = makeEm(body.height + body.depth); + if (body.depth) { + strut.style.verticalAlign = makeEm(-body.depth); + } + body.children.unshift(strut); + + return body; +} + +/** + * Take an entire parse tree, and build it into an appropriate set of HTML + * nodes. + */ +export default function buildHTML(tree: AnyParseNode[], options: Options): DomSpan { + // Strip off outer tag wrapper for processing below. + let tag = null; + if (tree.length === 1 && tree[0].type === "tag") { + tag = tree[0].tag; + tree = tree[0].body; + } + + // Build the expression contained in the tree + const expression = buildExpression(tree, options, "root"); + + let eqnNum; + if (expression.length === 2 && expression[1].hasClass("tag")) { + // An environment with automatic equation numbers, e.g. {gather}. + eqnNum = expression.pop(); + } + + const children = []; + + // Create one base node for each chunk between potential line breaks. + // The TeXBook [p.173] says "A formula will be broken only after a + // relation symbol like $=$ or $<$ or $\rightarrow$, or after a binary + // operation symbol like $+$ or $-$ or $\times$, where the relation or + // binary operation is on the ``outer level'' of the formula (i.e., not + // enclosed in {...} and not part of an \over construction)." + + let parts = []; + for (let i = 0; i < expression.length; i++) { + parts.push(expression[i]); + if (expression[i].hasClass("mbin") || + expression[i].hasClass("mrel") || + expression[i].hasClass("allowbreak")) { + // Put any post-operator glue on same line as operator. + // Watch for \nobreak along the way, and stop at \newline. + let nobreak = false; + while (i < expression.length - 1 && + expression[i + 1].hasClass("mspace") && + !expression[i + 1].hasClass("newline")) { + i++; + parts.push(expression[i]); + if (expression[i].hasClass("nobreak")) { + nobreak = true; + } + } + // Don't allow break if \nobreak among the post-operator glue. + if (!nobreak) { + children.push(buildHTMLUnbreakable(parts, options)); + parts = []; + } + } else if (expression[i].hasClass("newline")) { + // Write the line except the newline + parts.pop(); + if (parts.length > 0) { + children.push(buildHTMLUnbreakable(parts, options)); + parts = []; + } + // Put the newline at the top level + children.push(expression[i]); + } + } + if (parts.length > 0) { + children.push(buildHTMLUnbreakable(parts, options)); + } + + // Now, if there was a tag, build it too and append it as a final child. + let tagChild; + if (tag) { + tagChild = buildHTMLUnbreakable( + buildExpression(tag, options, true), + options, + ); + tagChild.classes = ["tag"]; + children.push(tagChild); + } else if (eqnNum) { + children.push(eqnNum); + } + + const htmlNode = makeSpan(["katex-html"], children); + htmlNode.setAttribute("aria-hidden", "true"); + + // Adjust the strut of the tag to be the maximum height of all children + // (the height of the enclosing htmlNode) for proper vertical alignment. + if (tagChild) { + const strut = tagChild.children[0]; + strut.style.height = makeEm(htmlNode.height + htmlNode.depth); + if (htmlNode.depth) { + strut.style.verticalAlign = makeEm(-htmlNode.depth); + } + } + + return htmlNode; +} diff --git a/node_modules/react-katex/node_modules/katex/src/buildMathML.ts b/node_modules/react-katex/node_modules/katex/src/buildMathML.ts new file mode 100644 index 0000000..044cc2d --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/buildMathML.ts @@ -0,0 +1,332 @@ +/** + * This file converts a parse tree into a corresponding MathML tree. The main + * entry point is the `buildMathML` function, which takes a parse tree from the + * parser. + */ + +import {fontMap, makeSpan} from "./buildCommon"; +import {getCharacterMetrics} from "./fontMetrics"; +import ParseError from "./ParseError"; +import symbols, {ligatures} from "./symbols"; +import {_mathmlGroupBuilders as groupBuilders} from "./defineFunction"; +import {MathNode, TextNode} from "./mathMLTree"; + +import type Options from "./Options"; +import type {AnyParseNode, SymbolParseNode} from "./parseNode"; +import type {DomSpan, HtmlDomNode} from "./domTree"; +import type {MathDomNode} from "./mathMLTree"; +import type {Mode} from "./types"; +import type {FontVariant, MathFont} from "./types/fonts"; + +const noVariantSymbols = new Set(["\\imath", "\\jmath"]); +const rowLikeTypes = new Set(["mrow", "mtable"]); + +/** + * Takes a symbol and converts it into a MathML text node after performing + * optional replacement from symbols.js. + */ +export const makeText = function( + text: string, + mode: Mode, + options?: Options, +): TextNode { + if (symbols[mode][text] && symbols[mode][text].replace && + text.charCodeAt(0) !== 0xD835 && + !(ligatures.hasOwnProperty(text) && options && + ((options.fontFamily && options.fontFamily.slice(4, 6) === "tt") || + (options.font && options.font.slice(4, 6) === "tt")))) { + text = symbols[mode][text].replace!; + } + + return new TextNode(text); +}; + +/** + * Wrap the given array of nodes in an node if needed, i.e., + * unless the array has length 1. Always returns a single node. + */ +export const makeRow = function(body: MathDomNode[]): MathDomNode { + if (body.length === 1) { + return body[0]; + } else { + return new MathNode("mrow", body); + } +}; + +const mathFontVariants: Partial< + Record FontVariant)> +> = { + mathit: "italic", + boldsymbol: (group) => (group.type === "textord" ? "bold" : "bold-italic"), + mathbf: "bold", + mathbb: "double-struck", + mathsfit: "sans-serif-italic", + mathfrak: "fraktur", + mathscr: "script", + mathcal: "script", + mathsf: "sans-serif", + mathtt: "monospace", +}; + +/** + * Returns the math variant as a string or null if none is required. + */ +export const getVariant = ( + group: SymbolParseNode, + options: Options, +): FontVariant | null | undefined => { + // Handle \text... font specifiers as best we can. + // MathML has a limited list of allowable mathvariant specifiers; see + // https://www.w3.org/TR/MathML3/chapter3.html#presm.commatt + if (group.mode === "text") { + if (options.fontFamily === "texttt") { + return "monospace"; + } else if (options.fontFamily === "textsf") { + if (options.fontShape === "textit" && + options.fontWeight === "textbf") { + return "sans-serif-bold-italic"; + } else if (options.fontShape === "textit") { + return "sans-serif-italic"; + } else if (options.fontWeight === "textbf") { + return "bold-sans-serif"; + } else { + return "sans-serif"; + } + } else if (options.fontShape === "textit" && + options.fontWeight === "textbf") { + return "bold-italic"; + } else if (options.fontShape === "textit") { + return "italic"; + } else if (options.fontWeight === "textbf") { + return "bold"; + } + } + + const font = options.font; + if (!font || font === "mathnormal") { + return null; + } + + const mode = group.mode; + const mathVariant = mathFontVariants[font]; + + if (mathVariant) { + return typeof mathVariant === "function" + ? mathVariant(group) + : mathVariant; + } + + let text = group.text; + if (noVariantSymbols.has(text)) { + return null; + } + + if (symbols[mode][text]) { + const replacement = symbols[mode][text].replace; + if (replacement) { + text = replacement; + } + } + + const fontName = fontMap[font].fontName; + if (getCharacterMetrics(text, fontName, mode)) { + return fontMap[font].variant; + } + + return null; +}; + +/** + * Check for . which is how a dot renders in MathML, + * or , + * which is how a braced comma {,} renders in MathML + */ +function isNumberPunctuation(group: MathNode | null | undefined): boolean { + if (!group) { + return false; + } + if (group.type === 'mi' && group.children.length === 1) { + const child = group.children[0]; + return child instanceof TextNode && child.text === '.'; + } else if (group.type === 'mo' && group.children.length === 1 && + group.getAttribute('separator') === 'true' && + group.getAttribute('lspace') === '0em' && + group.getAttribute('rspace') === '0em' + ) { + const child = group.children[0]; + return child instanceof TextNode && child.text === ','; + } else { + return false; + } +} + +/** + * Takes a list of nodes, builds them, and returns a list of the generated + * MathML nodes. Also combine consecutive outputs into a single + * tag. + */ +export const buildExpression = function( + expression: AnyParseNode[], + options: Options, + isOrdgroup?: boolean, +): MathNode[] { + if (expression.length === 1) { + const group = buildGroup(expression[0], options); + if (isOrdgroup && group instanceof MathNode && group.type === "mo") { + // When TeX writers want to suppress spacing on an operator, + // they often put the operator by itself inside braces. + group.setAttribute("lspace", "0em"); + group.setAttribute("rspace", "0em"); + } + return [group]; + } + + const groups = []; + let lastGroup; + for (let i = 0; i < expression.length; i++) { + const group = buildGroup(expression[i], options); + if (group instanceof MathNode && lastGroup instanceof MathNode) { + // Concatenate adjacent s + if (group.type === 'mtext' && lastGroup.type === 'mtext' + && group.getAttribute('mathvariant') === + lastGroup.getAttribute('mathvariant')) { + lastGroup.children.push(...group.children); + continue; + // Concatenate adjacent s + } else if (group.type === 'mn' && lastGroup.type === 'mn') { + lastGroup.children.push(...group.children); + continue; + // Concatenate ... followed by . + } else if (isNumberPunctuation(group) && lastGroup.type === 'mn') { + lastGroup.children.push(...group.children); + continue; + // Concatenate . followed by ... + } else if (group.type === 'mn' && isNumberPunctuation(lastGroup)) { + group.children = [...lastGroup.children, ...group.children]; + groups.pop(); + // Put preceding ... or . inside base of + // ...base......exponent... (or ) + } else if ((group.type === 'msup' || group.type === 'msub') && + group.children.length >= 1 && + (lastGroup.type === 'mn' || isNumberPunctuation(lastGroup)) + ) { + const base = group.children[0]; + if (base instanceof MathNode && base.type === 'mn') { + base.children = [...lastGroup.children, ...base.children]; + groups.pop(); + } + // \not + } else if (lastGroup.type === 'mi' && lastGroup.children.length === 1) { + const lastChild = lastGroup.children[0]; + if (lastChild instanceof TextNode && lastChild.text === '\u0338' && + (group.type === 'mo' || group.type === 'mi' || + group.type === 'mn')) { + const child = group.children[0]; + if (child instanceof TextNode && child.text.length > 0) { + // Overlay with combining character long solidus + child.text = child.text.slice(0, 1) + "\u0338" + + child.text.slice(1); + groups.pop(); + } + } + } + } + groups.push(group); + lastGroup = group; + } + return groups; +}; + +/** + * Equivalent to buildExpression, but wraps the elements in an + * if there's more than one. Returns a single node instead of an array. + */ +export const buildExpressionRow = function( + expression: AnyParseNode[], + options: Options, + isOrdgroup?: boolean, +): MathDomNode { + return makeRow(buildExpression(expression, options, isOrdgroup)); +}; + +/** + * Takes a group from the parser and calls the appropriate groupBuilders function + * on it to produce a MathML node. + */ +export const buildGroup = function( + group: AnyParseNode | null | undefined, + options: Options, +): MathNode { + if (!group) { + return new MathNode("mrow"); + } + + if (groupBuilders[group.type]) { + // TODO(ts): MathMLBuilder returns MathDomNode but all concrete + // builders return MathNode. Widening the return type here would + // require updating all callers that assume MathNode. + return groupBuilders[group.type](group, options) as MathNode; + } else { + throw new ParseError( + "Got group of unknown type: '" + group.type + "'"); + } +}; + +/** + * Takes a full parse tree and settings and builds a MathML representation of + * it. In particular, we put the elements from building the parse tree into a + * tag so we can also include that TeX source as an annotation. + * + * Note that we actually return a domTree element with a `` inside it so + * we can do appropriate styling. + */ +export default function buildMathML( + tree: AnyParseNode[], + texExpression: string, + options: Options, + isDisplayMode: boolean, + forMathmlOnly: boolean, +): DomSpan { + const expression = buildExpression(tree, options); + + // TODO: Make a pass thru the MathML similar to buildHTML.traverseNonSpaceNodes + // and add spacing nodes. This is necessary only adjacent to math operators + // like \sin or \lim or to subsup elements that contain math operators. + // MathML takes care of the other spacing issues. + + // Wrap up the expression in an mrow so it is presented in the semantics + // tag correctly, unless it's a single or . + let wrapper; + if (expression.length === 1 && expression[0] instanceof MathNode && + rowLikeTypes.has(expression[0].type)) { + wrapper = expression[0]; + } else { + wrapper = new MathNode("mrow", expression); + } + + // Build a TeX annotation of the source + const annotation = new MathNode( + "annotation", [new TextNode(texExpression)]); + + annotation.setAttribute("encoding", "application/x-tex"); + + const semantics = new MathNode( + "semantics", [wrapper, annotation]); + + const math = new MathNode("math", [semantics]); + math.setAttribute("xmlns", "http://www.w3.org/1998/Math/MathML"); + if (isDisplayMode) { + math.setAttribute("display", "block"); + } + + // You can't style nodes, so we wrap the node in a span. + // NOTE: The span class is not typed to have nodes as children, and + // we don't want to make the children type more generic since the children + // of span are expected to have more fields in `buildHtml` contexts. + // The MathNode implements VirtualNode (toNode/toMarkup) which is all that + // Span needs from its children for rendering. + // TODO(ts): Span's child type is HtmlDomNode, but MathNode only implements + // VirtualNode. The double-cast acknowledges this architectural limitation. + const wrapperClass = forMathmlOnly ? "katex" : "katex-mathml"; + return makeSpan([wrapperClass], [math as unknown as HtmlDomNode]); +} diff --git a/node_modules/react-katex/node_modules/katex/src/buildTree.ts b/node_modules/react-katex/node_modules/katex/src/buildTree.ts new file mode 100644 index 0000000..1feefa2 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/buildTree.ts @@ -0,0 +1,66 @@ +import buildHTML from "./buildHTML"; +import buildMathML from "./buildMathML"; +import {makeSpan} from "./buildCommon"; +import Options from "./Options"; +import Settings from "./Settings"; +import Style from "./Style"; + +import type {AnyParseNode} from "./parseNode"; +import type {DomSpan} from "./domTree"; + +const optionsFromSettings = function(settings: Settings) { + return new Options({ + style: (settings.displayMode ? Style.DISPLAY : Style.TEXT), + maxSize: settings.maxSize, + minRuleThickness: settings.minRuleThickness, + }); +}; + +const displayWrap = function(node: DomSpan, settings: Settings): DomSpan { + if (settings.displayMode) { + const classes = ["katex-display"]; + if (settings.leqno) { + classes.push("leqno"); + } + if (settings.fleqn) { + classes.push("fleqn"); + } + node = makeSpan(classes, [node]); + } + return node; +}; + +export const buildTree = function( + tree: AnyParseNode[], + expression: string, + settings: Settings, +): DomSpan { + const options = optionsFromSettings(settings); + let katexNode; + if (settings.output === "mathml") { + return buildMathML(tree, expression, options, settings.displayMode, true); + } else if (settings.output === "html") { + const htmlNode = buildHTML(tree, options); + katexNode = makeSpan(["katex"], [htmlNode]); + } else { + const mathMLNode = buildMathML(tree, expression, options, + settings.displayMode, false); + const htmlNode = buildHTML(tree, options); + katexNode = makeSpan(["katex"], [mathMLNode, htmlNode]); + } + + return displayWrap(katexNode, settings); +}; + +export const buildHTMLTree = function( + tree: AnyParseNode[], + expression: string, + settings: Settings, +): DomSpan { + const options = optionsFromSettings(settings); + const htmlNode = buildHTML(tree, options); + const katexNode = makeSpan(["katex"], [htmlNode]); + return displayWrap(katexNode, settings); +}; + +export default buildTree; diff --git a/node_modules/react-katex/node_modules/katex/src/defineEnvironment.ts b/node_modules/react-katex/node_modules/katex/src/defineEnvironment.ts new file mode 100644 index 0000000..6fe3c6b --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/defineEnvironment.ts @@ -0,0 +1,116 @@ +import {_htmlGroupBuilders, _mathmlGroupBuilders} from "./defineFunction"; + +import type Parser from "./Parser"; +import type {AnyParseNode} from "./parseNode"; +import type {ArgType, Mode} from "./types"; +import type {NodeType} from "./parseNode"; +import type {HtmlBuilder, MathMLBuilder} from "./defineFunction"; + +/** + * The context contains the following properties: + * - mode: current parsing mode. + * - envName: the name of the environment, one of the listed names. + * - parser: the parser object. + */ +type EnvContext = { + mode: Mode; + envName: string; + parser: Parser; +}; + +/** + * - context: information and references provided by the parser + * - args: an array of arguments passed to \begin{name} + * - optArgs: an array of optional arguments passed to \begin{name} + */ +type EnvHandler = ( + context: EnvContext, + args: AnyParseNode[], + optArgs: (AnyParseNode | null | undefined)[], +) => AnyParseNode; + +/** + * - numArgs: (default 0) The number of arguments after the \begin{name} function. + * - argTypes: (optional) Just like for a function + * - allowedInText: (default false) Whether or not the environment is allowed + * inside text mode (not enforced yet). + * - numOptionalArgs: (default 0) Just like for a function + */ +type EnvProps = { + numArgs: number; +}; + +/** + * Final environment spec for use at parse time. + * This is almost identical to `EnvDefSpec`, except it + * 1. includes the function handler + * 2. requires all arguments except argType + * It is generated by `defineEnvironment()` below. + */ +export type EnvSpec = { + type: NODETYPE; + // Need to use the type to avoid error. See NOTES below. + numArgs: number; + argTypes?: ArgType[]; + allowedInText: boolean; + numOptionalArgs: number; + handler: EnvHandler; +}; + +/** + * All registered environments. + * `environments.js` exports this same dictionary again and makes it public. + * `Parser.js` requires this dictionary via `environments.js`. + */ +export const _environments: Record> = {}; + +type EnvDefSpec = { + // Unique string to differentiate parse nodes. + type: NODETYPE; + + // List of functions which use the give handler, htmlBuilder, + // and mathmlBuilder. + names: Array; + + // Properties that control how the environments are parsed. + props: EnvProps; + handler: EnvHandler; + + // This function returns an object representing the DOM structure to be + // created when rendering the defined LaTeX function. + htmlBuilder: HtmlBuilder; + + // This function returns an object representing the MathML structure to be + // created when rendering the defined LaTeX function. + mathmlBuilder: MathMLBuilder; +}; + +export default function defineEnvironment({ + type, + names, + props, + handler, + htmlBuilder, + mathmlBuilder, +}: EnvDefSpec) { + // Set default values of environments. + const data = { + type, + numArgs: props.numArgs || 0, + allowedInText: false, + numOptionalArgs: 0, + handler, + }; + for (let i = 0; i < names.length; ++i) { + // TODO: The value type of _environments should be a type union of all + // possible `EnvSpec<>` possibilities instead of `EnvSpec<*>`, which is + // an existential type. + _environments[names[i]] = data; + } + if (htmlBuilder) { + _htmlGroupBuilders[type] = htmlBuilder; + } + if (mathmlBuilder) { + _mathmlGroupBuilders[type] = mathmlBuilder; + } +} diff --git a/node_modules/react-katex/node_modules/katex/src/defineFunction.ts b/node_modules/react-katex/node_modules/katex/src/defineFunction.ts new file mode 100644 index 0000000..e4de451 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/defineFunction.ts @@ -0,0 +1,228 @@ +import type Parser from "./Parser"; +import type {ParseNode, AnyParseNode, NodeType, UnsupportedCmdParseNode} + from "./parseNode"; +import type Options from "./Options"; +import type {ArgType, BreakToken} from "./types"; +import type {HtmlDomNode} from "./domTree"; +import type {Token} from "./Token"; +import type {MathDomNode} from "./mathMLTree"; + +/** Context provided to function handlers for error messages. */ +export type FunctionContext = { + funcName: string; + parser: Parser; + token?: Token; + breakOnTokenText?: BreakToken; +}; + +export type FunctionHandler = ( + context: FunctionContext, + args: AnyParseNode[], + optArgs: (AnyParseNode | null | undefined)[], +) => UnsupportedCmdParseNode | ParseNode; +// Note: reverse the order of the return type union will cause a flow error. +// See https://github.com/facebook/flow/issues/3663. + +export type HtmlBuilder = + (group: ParseNode, options: Options) => HtmlDomNode; +export type MathMLBuilder = + (group: ParseNode, options: Options) => MathDomNode; + +// More general version of `HtmlBuilder` for nodes (e.g. \sum, accent types) +// whose presence impacts super/subscripting. In this case, ParseNode<"supsub"> +// delegates its HTML building to the HtmlBuilder corresponding to these nodes. +export type HtmlBuilderSupSub = + (group: ParseNode<"supsub"> | ParseNode, options: Options) => HtmlDomNode; + +export type FunctionPropSpec = { + // The number of arguments the function takes. + numArgs: number; + + // An array corresponding to each argument of the function, giving the + // type of argument that should be parsed. Its length should be equal + // to `numOptionalArgs + numArgs`, and types for optional arguments + // should appear before types for mandatory arguments. + argTypes?: ArgType[]; + + // Whether it expands to a single token or a braced group of tokens. + // If it's grouped, it can be used as an argument to primitive commands, + // such as \sqrt (without the optional argument) and super/subscript. + allowedInArgument?: boolean; + + // Whether or not the function is allowed inside text mode + // (default false) + allowedInText?: boolean; + + // Whether or not the function is allowed inside text mode + // (default true) + allowedInMath?: boolean; + + // (optional) The number of optional arguments the function + // should parse. If the optional arguments aren't found, + // `null` will be passed to the handler in their place. + // (default 0) + numOptionalArgs?: number; + + // Must be true if the function is an infix operator. + infix?: boolean; + + // Whether or not the function is a TeX primitive. + primitive?: boolean; +}; + +type FunctionDefSpec = { + // Unique string to differentiate parse nodes. + // Also determines the type of the value returned by `handler`. + type: NODETYPE; + + // The first argument to defineFunction is a single name or a list of names. + // All functions named in such a list will share a single implementation. + names: Array; + + // Properties that control how the functions are parsed. + props: FunctionPropSpec; + + // The handler is called to handle these functions and their arguments and + // returns a `ParseNode`. + handler: FunctionHandler | null | undefined; + + // This function returns an object representing the DOM structure to be + // created when rendering the defined LaTeX function. + // This should not modify the `ParseNode`. + htmlBuilder?: HtmlBuilder; + + // This function returns an object representing the MathML structure to be + // created when rendering the defined LaTeX function. + // This should not modify the `ParseNode`. + mathmlBuilder?: MathMLBuilder; +}; + +/** + * Final function spec for use at parse time. + * This is almost identical to `FunctionPropSpec`, except it + * 1. includes the function handler, and + * 2. requires all arguments except argTypes. + * It is generated by `defineFunction()` below. + */ +export type FunctionSpec = { + type: NODETYPE; // Need to use the type to avoid error. See NOTES below. + numArgs: number; + argTypes?: ArgType[]; + allowedInArgument: boolean; + allowedInText: boolean; + allowedInMath: boolean; + numOptionalArgs: number; + infix: boolean; + primitive: boolean; + + // FLOW TYPE NOTES: Doing either one of the following two + // + // - removing the NODETYPE type parameter in FunctionSpec above; + // - using ?FunctionHandler below; + // + // results in a confusing flow typing error: + // "string literal `styling`. This type is incompatible with..." + // pointing to the definition of `defineFunction` and finishing with + // "some incompatible instantiation of `NODETYPE`" + // + // Having FunctionSpec above and FunctionHandler<*> below seems to + // circumvent this error. This is not harmful for catching errors since + // _functions is typed FunctionSpec<*> (it stores all TeX function specs). + + // Must be specified unless it's handled directly in the parser. + handler: FunctionHandler | null | undefined; +}; + +/** + * All registered functions. + * `functions.js` just exports this same dictionary again and makes it public. + * `Parser.js` requires this dictionary. + */ +export const _functions: Record> = {}; + +/** + * All HTML builders. Should be only used in the `define*` and the `build*ML` + * functions. + * + * Builders for different node types are stored side by side, but + * `HtmlBuilder` is contravariant in `T`, so there is no single type + * argument that makes storing/retrieving them typecheck. `any` is used + * as an existential-quantifier escape hatch. + */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any +export const _htmlGroupBuilders: Record> = {}; + +/** + * All MathML builders. Should be only used in the `define*` and the `build*ML` + * functions. See `_htmlGroupBuilders` above for the rationale behind `any`. + */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any +export const _mathmlGroupBuilders: Record> = {}; + +export default function defineFunction({ + type, + names, + props, + handler, + htmlBuilder, + mathmlBuilder, +}: FunctionDefSpec) { + // Set default values of functions + const data = { + type, + numArgs: props.numArgs, + argTypes: props.argTypes, + allowedInArgument: !!props.allowedInArgument, + allowedInText: !!props.allowedInText, + allowedInMath: (props.allowedInMath === undefined) + ? true + : props.allowedInMath, + numOptionalArgs: props.numOptionalArgs || 0, + infix: !!props.infix, + primitive: !!props.primitive, + handler, + }; + for (let i = 0; i < names.length; ++i) { + _functions[names[i]] = data; + } + if (type) { + if (htmlBuilder) { + _htmlGroupBuilders[type] = htmlBuilder; + } + if (mathmlBuilder) { + _mathmlGroupBuilders[type] = mathmlBuilder; + } + } +} + +/** + * Use this to register only the HTML and MathML builders for a function (e.g. + * if the function's ParseNode is generated in Parser.js rather than via a + * stand-alone handler provided to `defineFunction`). + */ +export function defineFunctionBuilders({ + type, htmlBuilder, mathmlBuilder, +}: { + type: NODETYPE; + htmlBuilder?: HtmlBuilder; + mathmlBuilder: MathMLBuilder; +}) { + defineFunction({ + type, + names: [], + props: {numArgs: 0}, + handler() { throw new Error('Should never be called.'); }, + htmlBuilder, + mathmlBuilder, + }); +} + +export const normalizeArgument = function(arg: AnyParseNode): AnyParseNode { + return arg.type === "ordgroup" && arg.body.length === 1 ? arg.body[0] : arg; +}; + +// Since the corresponding buildHTML/buildMathML function expects a +// list of elements, we normalize for different kinds of arguments +export const ordargument = function(arg: AnyParseNode): AnyParseNode[] { + return arg.type === "ordgroup" ? arg.body : [arg]; +}; diff --git a/node_modules/react-katex/node_modules/katex/src/defineMacro.ts b/node_modules/react-katex/node_modules/katex/src/defineMacro.ts new file mode 100644 index 0000000..aee9bf2 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/defineMacro.ts @@ -0,0 +1,124 @@ + +import {Token} from "./Token"; +import type Namespace from "./Namespace"; +import type {Mode} from "./types"; + +/** + * Provides context to macros defined by functions. Implemented by + * MacroExpander. + */ +export interface MacroContextInterface { + mode: Mode; + + /** + * Object mapping macros to their expansions. + */ + macros: Namespace; + + /** + * Returns the topmost token on the stack, without expanding it. + * Similar in behavior to TeX's `\futurelet`. + */ + future(): Token; + + /** + * Remove and return the next unexpanded token. + */ + popToken(): Token; + + /** + * Consume all following space tokens, without expansion. + */ + consumeSpaces(): void; + + /** + * Expand the next token only once if possible. + */ + expandOnce(expandableOnly?: boolean): number | boolean; + + /** + * Expand the next token only once (if possible), and return the resulting + * top token on the stack (without removing anything from the stack). + * Similar in behavior to TeX's `\expandafter\futurelet`. + */ + expandAfterFuture(): Token; + + /** + * Recursively expand first token, then return first non-expandable token. + */ + expandNextToken(): Token; + + /** + * Fully expand the given macro name and return the resulting list of + * tokens, or return `undefined` if no such macro is defined. + */ + expandMacro(name: string): Token[] | undefined; + + /** + * Fully expand the given macro name and return the result as a string, + * or return `undefined` if no such macro is defined. + */ + expandMacroAsText(name: string): string | undefined; + + /** + * Fully expand the given token stream and return the resulting list of + * tokens. Note that the input tokens are in reverse order, but the + * output tokens are in forward order. + */ + expandTokens(tokens: Token[]): Token[]; + + /** + * Consume an argument from the token stream, and return the resulting array + * of tokens and start/end token. + */ + consumeArg(delims?: string[] | null | undefined): MacroArg; + + /** + * Consume the specified number of arguments from the token stream, + * and return the resulting array of arguments. + */ + consumeArgs(numArgs: number): Token[][]; + + /** + * Determine whether a command is currently "defined" (has some + * functionality), meaning that it's a macro (in the current group), + * a function, a symbol, or one of the special commands listed in + * `implicitCommands`. + */ + isDefined(name: string): boolean; + + /** + * Determine whether a command is expandable. + */ + isExpandable(name: string): boolean; +} + +export type MacroArg = { + tokens: Token[]; + start: Token; + end: Token; +}; + +/** Macro tokens (in reverse order). */ +export type MacroExpansion = { + tokens: Token[]; + numArgs: number; + delimiters?: string[][]; + unexpandable?: boolean; // used in \let +}; + +export type MacroDefinition = string | MacroExpansion | + ((arg0: MacroContextInterface) => string | MacroExpansion); +export type MacroMap = Record; + +/** + * All registered global/built-in macros. + * `macros.js` exports this same dictionary again and makes it public. + * `Parser.js` requires this dictionary via `macros.js`. + */ +export const _macros: MacroMap = {}; + +// This function might one day accept an additional argument and do more things. +export default function defineMacro(name: string, body: MacroDefinition) { + _macros[name] = body; +} diff --git a/node_modules/react-katex/node_modules/katex/src/delimiter.ts b/node_modules/react-katex/node_modules/katex/src/delimiter.ts new file mode 100644 index 0000000..b808799 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/delimiter.ts @@ -0,0 +1,832 @@ +/** + * This file 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`. + */ + +import ParseError from "./ParseError"; +import Style from "./Style"; + +import {PathNode, SvgNode, SymbolNode} from "./domTree"; +import {sqrtPath, innerPath, tallDelim} from "./svgGeometry"; +import {makeSpan, makeSymbol, makeSvgSpan, makeVList} from "./buildCommon"; +import {getCharacterMetrics} from "./fontMetrics"; +import symbols from "./symbols"; +import {makeEm} from "./units"; +import fontMetricsData from "./fontMetricsData"; + +import type Options from "./Options"; +import type {HtmlDomNode, DomSpan, SvgSpan} from "./domTree"; +import type {DelimiterSize, Mode} from "./types"; +import type {StyleInterface} from "./Style"; +import type {VListElem} from "./buildCommon"; +import type {CharacterMetrics, FontName} from "./types/fonts"; + +type StackedDelimiterFont = "Size1-Regular" | "Size4-Regular"; + +/** + * Get the metrics for a given symbol and font, after transformation (i.e. + * after following replacement from symbols.js) + */ +const getMetrics = function( + symbol: string, + font: string, + mode: Mode, +): CharacterMetrics { + const replace = symbols.math[symbol] && symbols.math[symbol].replace; + const metrics = + getCharacterMetrics(replace || symbol, font, mode); + if (!metrics) { + throw new Error(`Unsupported symbol ${symbol} and font size ${font}.`); + } + return metrics; +}; + +/** + * Puts a delimiter span in a given style, and adds appropriate height, depth, + * and maxFontSizes. + */ +const styleWrap = function( + delim: HtmlDomNode, + toStyle: StyleInterface, + options: Options, + classes: string[], +): DomSpan { + const newOptions = options.havingBaseStyle(toStyle); + + const span = makeSpan( + classes.concat(newOptions.sizingClasses(options)), + [delim], options); + + const delimSizeMultiplier = + newOptions.sizeMultiplier / options.sizeMultiplier; + span.height *= delimSizeMultiplier; + span.depth *= delimSizeMultiplier; + span.maxFontSize = newOptions.sizeMultiplier; + + return span; +}; + +const centerSpan = function( + span: DomSpan, + options: Options, + style: StyleInterface, +) { + const newOptions = options.havingBaseStyle(style); + const shift = + (1 - options.sizeMultiplier / newOptions.sizeMultiplier) * + options.fontMetrics().axisHeight; + + span.classes.push("delimcenter"); + span.style.top = makeEm(shift); + span.height -= shift; + span.depth += shift; +}; + +/** + * 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. + */ +const makeSmallDelim = function( + delim: string, + style: StyleInterface, + center: boolean, + options: Options, + mode: Mode, + classes: string[], +): DomSpan { + const text = makeSymbol(delim, "Main-Regular", mode, options); + const span = styleWrap(text, style, options, classes); + if (center) { + centerSpan(span, options, style); + } + return span; +}; + +/** + * Builds a symbol in the given font size (note size is an integer) + */ +const mathrmSize = function( + value: string, + size: DelimiterSize, + mode: Mode, + options: Options, +): SymbolNode { + return makeSymbol(value, `Size${size}-Regular`, mode, options); +}; + +/** + * Makes a large delimiter. This is a delimiter that comes in the Size1, Size2, + * Size3, or Size4 fonts. It is always rendered in textstyle. + */ +const makeLargeDelim = function(delim: string, + size: DelimiterSize, + center: boolean, + options: Options, + mode: Mode, + classes: string[], +): DomSpan { + const inner = mathrmSize(delim, size, mode, options); + const span = styleWrap( + makeSpan(["delimsizing", "size" + size], [inner], options), + Style.TEXT, options, classes); + if (center) { + centerSpan(span, options, Style.TEXT); + } + return span; +}; + +/** + * Make a span from a font glyph with the given offset and in the given font. + * This is used in makeStackedDelim to make the stacking pieces for the delimiter. + */ +const makeGlyphSpan = function( + symbol: string, + font: StackedDelimiterFont, + mode: Mode, +): VListElem { + let sizeClass; + // Apply the correct CSS class to choose the right font. + if (font === "Size1-Regular") { + sizeClass = "delim-size1"; + } else /* if (font === "Size4-Regular") */ { + sizeClass = "delim-size4"; + } + + const corner = makeSpan( + ["delimsizinginner", sizeClass], + [makeSpan([], [makeSymbol(symbol, font, mode)])]); + + // Since this will be passed into `makeVList` in the end, wrap the element + // in the appropriate tag that VList uses. + return {type: "elem", elem: corner}; +}; + +const makeInner = function( + ch: string, + height: number, + options: Options +): VListElem { + // Create a span with inline SVG for the inner part of a tall stacked delimiter. + const width = fontMetricsData['Size4-Regular'][ch.charCodeAt(0)] + ? fontMetricsData['Size4-Regular'][ch.charCodeAt(0)][4] + : fontMetricsData['Size1-Regular'][ch.charCodeAt(0)][4]; + const path = new PathNode("inner", innerPath(ch, Math.round(1000 * height))); + const svgNode = new SvgNode([path], { + "width": makeEm(width), + "height": makeEm(height), + // Override CSS rule `.katex svg { width: 100% }` + "style": "width:" + makeEm(width), + "viewBox": "0 0 " + 1000 * width + " " + Math.round(1000 * height), + "preserveAspectRatio": "xMinYMin", + }); + const span = makeSvgSpan([], [svgNode], options); + span.height = height; + span.style.height = makeEm(height); + span.style.width = makeEm(width); + return {type: "elem", elem: span}; +}; + +// Helpers for makeStackedDelim +const lapInEms = 0.008; +const lap: {type: "kern"; size: number} = {type: "kern", size: -1 * lapInEms}; +const verts = new Set(["|", "\\lvert", "\\rvert", "\\vert"]); +const doubleVerts = new Set(["\\|", "\\lVert", "\\rVert", "\\Vert"]); + +/** + * Make a stacked delimiter out of a given delimiter, with the total height at + * least `heightTotal`. This routine is mentioned on page 442 of the TeXbook. + */ +const makeStackedDelim = function( + delim: string, + heightTotal: number, + center: boolean, + options: Options, + mode: Mode, + classes: string[], +): DomSpan { + // There are four parts, the top, an optional middle, a repeated part, and a + // bottom. + let top; + let middle; + let repeat; + let bottom; + let svgLabel = ""; + let viewBoxWidth = 0; + top = repeat = bottom = delim; + middle = null; + // Also keep track of what font the delimiters are in + let font: StackedDelimiterFont = "Size1-Regular"; + + // We set the parts and font based on the symbol. Note that we use + // '\u23d0' instead of '|' and '\u2016' instead of '\\|' for the + // repeats of the arrows + if (delim === "\\uparrow") { + repeat = bottom = "\u23d0"; + } else if (delim === "\\Uparrow") { + repeat = bottom = "\u2016"; + } else if (delim === "\\downarrow") { + top = repeat = "\u23d0"; + } else if (delim === "\\Downarrow") { + top = repeat = "\u2016"; + } else if (delim === "\\updownarrow") { + top = "\\uparrow"; + repeat = "\u23d0"; + bottom = "\\downarrow"; + } else if (delim === "\\Updownarrow") { + top = "\\Uparrow"; + repeat = "\u2016"; + bottom = "\\Downarrow"; + } else if (verts.has(delim)) { + repeat = "\u2223"; + svgLabel = "vert"; + viewBoxWidth = 333; + } else if (doubleVerts.has(delim)) { + repeat = "\u2225"; + svgLabel = "doublevert"; + viewBoxWidth = 556; + } else if (delim === "[" || delim === "\\lbrack") { + top = "\u23a1"; + repeat = "\u23a2"; + bottom = "\u23a3"; + font = "Size4-Regular"; + svgLabel = "lbrack"; + viewBoxWidth = 667; + } else if (delim === "]" || delim === "\\rbrack") { + top = "\u23a4"; + repeat = "\u23a5"; + bottom = "\u23a6"; + font = "Size4-Regular"; + svgLabel = "rbrack"; + viewBoxWidth = 667; + } else if (delim === "\\lfloor" || delim === "\u230a") { + repeat = top = "\u23a2"; + bottom = "\u23a3"; + font = "Size4-Regular"; + svgLabel = "lfloor"; + viewBoxWidth = 667; + } else if (delim === "\\lceil" || delim === "\u2308") { + top = "\u23a1"; + repeat = bottom = "\u23a2"; + font = "Size4-Regular"; + svgLabel = "lceil"; + viewBoxWidth = 667; + } else if (delim === "\\rfloor" || delim === "\u230b") { + repeat = top = "\u23a5"; + bottom = "\u23a6"; + font = "Size4-Regular"; + svgLabel = "rfloor"; + viewBoxWidth = 667; + } else if (delim === "\\rceil" || delim === "\u2309") { + top = "\u23a4"; + repeat = bottom = "\u23a5"; + font = "Size4-Regular"; + svgLabel = "rceil"; + viewBoxWidth = 667; + } else if (delim === "(" || delim === "\\lparen") { + top = "\u239b"; + repeat = "\u239c"; + bottom = "\u239d"; + font = "Size4-Regular"; + svgLabel = "lparen"; + viewBoxWidth = 875; + } else if (delim === ")" || delim === "\\rparen") { + top = "\u239e"; + repeat = "\u239f"; + bottom = "\u23a0"; + font = "Size4-Regular"; + svgLabel = "rparen"; + viewBoxWidth = 875; + } else if (delim === "\\{" || delim === "\\lbrace") { + top = "\u23a7"; + middle = "\u23a8"; + bottom = "\u23a9"; + repeat = "\u23aa"; + font = "Size4-Regular"; + } else if (delim === "\\}" || delim === "\\rbrace") { + top = "\u23ab"; + middle = "\u23ac"; + bottom = "\u23ad"; + repeat = "\u23aa"; + font = "Size4-Regular"; + } else if (delim === "\\lgroup" || delim === "\u27ee") { + top = "\u23a7"; + bottom = "\u23a9"; + repeat = "\u23aa"; + font = "Size4-Regular"; + } else if (delim === "\\rgroup" || delim === "\u27ef") { + top = "\u23ab"; + bottom = "\u23ad"; + repeat = "\u23aa"; + font = "Size4-Regular"; + } else if (delim === "\\lmoustache" || delim === "\u23b0") { + top = "\u23a7"; + bottom = "\u23ad"; + repeat = "\u23aa"; + font = "Size4-Regular"; + } else if (delim === "\\rmoustache" || delim === "\u23b1") { + top = "\u23ab"; + bottom = "\u23a9"; + repeat = "\u23aa"; + font = "Size4-Regular"; + } + + // Get the metrics of the four sections + const topMetrics = getMetrics(top, font, mode); + const topHeightTotal = topMetrics.height + topMetrics.depth; + const repeatMetrics = getMetrics(repeat, font, mode); + const repeatHeightTotal = repeatMetrics.height + repeatMetrics.depth; + const bottomMetrics = getMetrics(bottom, font, mode); + const bottomHeightTotal = bottomMetrics.height + bottomMetrics.depth; + let middleHeightTotal = 0; + let middleFactor = 1; + if (middle !== null) { + const middleMetrics = getMetrics(middle, font, mode); + middleHeightTotal = middleMetrics.height + middleMetrics.depth; + middleFactor = 2; // repeat symmetrically above and below middle + } + + // Calculate the minimal height that the delimiter can have. + // It is at least the size of the top, bottom, and optional middle combined. + const minHeight = topHeightTotal + bottomHeightTotal + middleHeightTotal; + + // Compute the number of copies of the repeat symbol we will need + const repeatCount = Math.max(0, Math.ceil( + (heightTotal - minHeight) / (middleFactor * repeatHeightTotal))); + + // Compute the total height of the delimiter including all the symbols + const realHeightTotal = + minHeight + repeatCount * middleFactor * repeatHeightTotal; + + // The center of the delimiter is placed at the center of the axis. Note + // that in this context, "center" means that the delimiter should be + // centered around the axis in the current style, while normally it is + // centered around the axis in textstyle. + let axisHeight = options.fontMetrics().axisHeight; + if (center) { + axisHeight *= options.sizeMultiplier; + } + // Calculate the depth + const depth = realHeightTotal / 2 - axisHeight; + + // Now, we start building the pieces that will go into the vlist + // Keep a list of the pieces of the stacked delimiter + const stack: Array = []; + + if (svgLabel.length > 0) { + // Instead of stacking glyphs, create a single SVG. + // This evades browser problems with imprecise positioning of spans. + const midHeight = realHeightTotal - topHeightTotal - bottomHeightTotal; + const viewBoxHeight = Math.round(realHeightTotal * 1000); + const pathStr = tallDelim(svgLabel, Math.round(midHeight * 1000)); + const path = new PathNode(svgLabel, pathStr); + const width = makeEm(viewBoxWidth / 1000); + const height = makeEm(viewBoxHeight / 1000); + const svg = new SvgNode([path], { + "width": width, + "height": height, + "viewBox": `0 0 ${viewBoxWidth} ${viewBoxHeight}`, + }); + const wrapper = makeSvgSpan([], [svg], options); + wrapper.height = viewBoxHeight / 1000; + wrapper.style.width = width; + wrapper.style.height = height; + stack.push({type: "elem", elem: wrapper}); + } else { + // Stack glyphs + // Start by adding the bottom symbol + stack.push(makeGlyphSpan(bottom, font, mode)); + stack.push(lap); // overlap + + if (middle === null) { + // The middle section will be an SVG. Make it an extra 0.016em tall. + // We'll overlap by 0.008em at top and bottom. + const innerHeight = realHeightTotal - topHeightTotal - bottomHeightTotal + + 2 * lapInEms; + stack.push(makeInner(repeat, innerHeight, options)); + } else { + // When there is a middle bit, we need the middle part and two repeated + // sections + const innerHeight = (realHeightTotal - topHeightTotal - + bottomHeightTotal - middleHeightTotal) / 2 + 2 * lapInEms; + stack.push(makeInner(repeat, innerHeight, options)); + // Now insert the middle of the brace. + stack.push(lap); + stack.push(makeGlyphSpan(middle, font, mode)); + stack.push(lap); + stack.push(makeInner(repeat, innerHeight, options)); + } + + // Add the top symbol + stack.push(lap); + stack.push(makeGlyphSpan(top, font, mode)); + } + + // Finally, build the vlist + const newOptions = options.havingBaseStyle(Style.TEXT); + const inner = makeVList({ + positionType: "bottom", + positionData: depth, + children: stack, + }, newOptions); + + return styleWrap( + makeSpan(["delimsizing", "mult"], [inner], newOptions), + Style.TEXT, options, classes); +}; + +// All surds have 0.08em padding above the vinculum inside the SVG. +// That keeps browser span height rounding error from pinching the line. +const vbPad = 80; // padding above the surd, measured inside the viewBox. +const emPad = 0.08; // padding, in ems, measured in the document. + +const sqrtSvg = function( + sqrtName: string, + height: number, + viewBoxHeight: number, + extraVinculum: number, + options: Options, +): SvgSpan { + const path = sqrtPath(sqrtName, extraVinculum, viewBoxHeight); + const pathNode = new PathNode(sqrtName, path); + + const svg = new SvgNode([pathNode], { + // Note: 1000:1 ratio of viewBox to document em width. + "width": "400em", + "height": makeEm(height), + "viewBox": "0 0 400000 " + viewBoxHeight, + "preserveAspectRatio": "xMinYMin slice", + }); + + return makeSvgSpan(["hide-tail"], [svg], options); +}; + +/** + * Make a sqrt image of the given height, + */ +export const makeSqrtImage = function( + height: number, + options: Options, +): { + span: SvgSpan, + ruleWidth: number, + advanceWidth: number, +} { + // Define a newOptions that removes the effect of size changes such as \Huge. + // We don't pick different a height surd for \Huge. For it, we scale up. + const newOptions = options.havingBaseSizing(); + + // Pick the desired surd glyph from a sequence of surds. + const delim = traverseSequence("\\surd", height * newOptions.sizeMultiplier, + stackLargeDelimiterSequence, newOptions); + + let sizeMultiplier = newOptions.sizeMultiplier; // default + + // The standard sqrt SVGs each have a 0.04em thick vinculum. + // If Settings.minRuleThickness is larger than that, we add extraVinculum. + const extraVinculum = Math.max(0, + options.minRuleThickness - options.fontMetrics().sqrtRuleThickness); + + // Create a span containing an SVG image of a sqrt symbol. + let span; + let spanHeight; + let texHeight; + let viewBoxHeight; + let advanceWidth; + + // We create viewBoxes with 80 units of "padding" above each surd. + // Then browser rounding error on the parent span height will not + // encroach on the ink of the vinculum. But that padding is not + // included in the TeX-like `height` used for calculation of + // vertical alignment. So texHeight = span.height < span.style.height. + + if (delim.type === "small") { + // Get an SVG that is derived from glyph U+221A in font KaTeX-Main. + // 1000 unit normal glyph height. + viewBoxHeight = 1000 + 1000 * extraVinculum + vbPad; + if (height < 1.0) { + sizeMultiplier = 1.0; // mimic a \textfont radical + } else if (height < 1.4) { + sizeMultiplier = 0.7; // mimic a \scriptfont radical + } + spanHeight = (1.0 + extraVinculum + emPad) / sizeMultiplier; + texHeight = (1.00 + extraVinculum) / sizeMultiplier; + span = sqrtSvg("sqrtMain", spanHeight, viewBoxHeight, extraVinculum, + options); + span.style.minWidth = "0.853em"; + advanceWidth = 0.833 / sizeMultiplier; // from the font. + + } else if (delim.type === "large") { + // These SVGs come from fonts: KaTeX_Size1, _Size2, etc. + viewBoxHeight = (1000 + vbPad) * sizeToMaxHeight[delim.size]; + texHeight = (sizeToMaxHeight[delim.size] + extraVinculum) / sizeMultiplier; + spanHeight = (sizeToMaxHeight[delim.size] + extraVinculum + emPad) + / sizeMultiplier; + span = sqrtSvg("sqrtSize" + delim.size, spanHeight, viewBoxHeight, + extraVinculum, options); + span.style.minWidth = "1.02em"; + advanceWidth = 1.0 / sizeMultiplier; // 1.0 from the font. + + } else { + // Tall sqrt. In TeX, this would be stacked using multiple glyphs. + // We'll use a single SVG to accomplish the same thing. + spanHeight = height + extraVinculum + emPad; + texHeight = height + extraVinculum; + viewBoxHeight = Math.floor(1000 * height + extraVinculum) + vbPad; + span = sqrtSvg("sqrtTall", spanHeight, viewBoxHeight, extraVinculum, + options); + span.style.minWidth = "0.742em"; + advanceWidth = 1.056; + } + + span.height = texHeight; + span.style.height = makeEm(spanHeight); + + return { + span, + advanceWidth, + // Calculate the actual line width. + // This actually should depend on the chosen font -- e.g. \boldmath + // should use the thicker surd symbols from e.g. KaTeX_Main-Bold, and + // have thicker rules. + ruleWidth: (options.fontMetrics().sqrtRuleThickness + extraVinculum) + * sizeMultiplier, + }; +}; + +// There are three kinds of delimiters, delimiters that stack when they become +// too large +const stackLargeDelimiters = new Set([ + "(", "\\lparen", ")", "\\rparen", + "[", "\\lbrack", "]", "\\rbrack", + "\\{", "\\lbrace", "\\}", "\\rbrace", + "\\lfloor", "\\rfloor", "\u230a", "\u230b", + "\\lceil", "\\rceil", "\u2308", "\u2309", + "\\surd", +]); + +// delimiters that always stack +const stackAlwaysDelimiters = new Set([ + "\\uparrow", "\\downarrow", "\\updownarrow", + "\\Uparrow", "\\Downarrow", "\\Updownarrow", + "|", "\\|", "\\vert", "\\Vert", + "\\lvert", "\\rvert", "\\lVert", "\\rVert", + "\\lgroup", "\\rgroup", "\u27ee", "\u27ef", + "\\lmoustache", "\\rmoustache", "\u23b0", "\u23b1", +]); + +// and delimiters that never stack +const stackNeverDelimiters = new Set([ + "<", ">", "\\langle", "\\rangle", "/", "\\backslash", "\\lt", "\\gt", +]); + +// Metrics of the different sizes. Found by looking at TeX's output of +// $\bigl| // \Bigl| \biggl| \Biggl| \showlists$ +// Used to create stacked delimiters of appropriate sizes in makeSizedDelim. +export const sizeToMaxHeight = [0, 1.2, 1.8, 2.4, 3.0]; + +/** + * Used to create a delimiter of a specific size, where `size` is 1, 2, 3, or 4. + */ +export const makeSizedDelim = function( + delim: string, + size: DelimiterSize, + options: Options, + mode: Mode, + classes: string[], +): DomSpan { + // < and > turn into \langle and \rangle in delimiters + if (delim === "<" || delim === "\\lt" || delim === "\u27e8") { + delim = "\\langle"; + } else if (delim === ">" || delim === "\\gt" || delim === "\u27e9") { + delim = "\\rangle"; + } + + // Sized delimiters are never centered. + if (stackLargeDelimiters.has(delim) || stackNeverDelimiters.has(delim)) { + return makeLargeDelim(delim, size, false, options, mode, classes); + } else if (stackAlwaysDelimiters.has(delim)) { + return makeStackedDelim( + delim, + sizeToMaxHeight[size], + false, + options, + mode, + classes, + ); + } else { + throw new ParseError("Illegal delimiter: '" + delim + "'"); + } +}; + +/** + * There are three different sequences of delimiter sizes that the delimiters + * follow depending on the kind of delimiter. This is used when creating custom + * sized delimiters to decide whether to create a small, large, or stacked + * delimiter. + * + * In real TeX, these sequences aren't explicitly defined, but are instead + * defined inside the font metrics. Since there are only three sequences that + * are possible for the delimiters that TeX defines, it is easier to just encode + * them explicitly here. + */ + +type Delimiter = + {type: "small", style: StyleInterface} | + {type: "large", size: 1 | 2 | 3 | 4} | + {type: "stack"}; + +// Delimiters that never stack try small delimiters and large delimiters only +const stackNeverDelimiterSequence: Delimiter[] = [ + {type: "small", style: Style.SCRIPTSCRIPT}, + {type: "small", style: Style.SCRIPT}, + {type: "small", style: Style.TEXT}, + {type: "large", size: 1}, + {type: "large", size: 2}, + {type: "large", size: 3}, + {type: "large", size: 4}, +]; + +// Delimiters that always stack try the small delimiters first, then stack +const stackAlwaysDelimiterSequence: Delimiter[] = [ + {type: "small", style: Style.SCRIPTSCRIPT}, + {type: "small", style: Style.SCRIPT}, + {type: "small", style: Style.TEXT}, + {type: "stack"}, +]; + +// Delimiters that stack when large try the small and then large delimiters, and +// stack afterwards +const stackLargeDelimiterSequence: Delimiter[] = [ + {type: "small", style: Style.SCRIPTSCRIPT}, + {type: "small", style: Style.SCRIPT}, + {type: "small", style: Style.TEXT}, + {type: "large", size: 1}, + {type: "large", size: 2}, + {type: "large", size: 3}, + {type: "large", size: 4}, + {type: "stack"}, +]; + +/** + * Get the font used in a delimiter based on what kind of delimiter it is. + * TODO(#963) Use more specific font family return type once that is introduced. + */ +const delimTypeToFont = function(type: Delimiter): string { + if (type.type === "small") { + return "Main-Regular"; + } else if (type.type === "large") { + return "Size" + type.size + "-Regular"; + } else if (type.type === "stack") { + return "Size4-Regular"; + } else { + const delimKind = (type as Delimiter).type; + throw new Error(`Add support for delim type '${delimKind}' here.`); + } +}; + +/** + * Traverse a sequence of types of delimiters to decide what kind of delimiter + * should be used to create a delimiter of the given height+depth. + */ +const traverseSequence = function( + delim: string, + height: number, + sequence: Delimiter[], + options: Options, +): Delimiter { + // Here, we choose the index we should start at in the sequences. In smaller + // sizes (which correspond to larger numbers in style.size) we start earlier + // in the sequence. Thus, scriptscript starts at index 3-3=0, script starts + // at index 3-2=1, text starts at 3-1=2, and display starts at min(2,3-0)=2 + const start = Math.min(2, 3 - options.style.size); + for (let i = start; i < sequence.length; i++) { + const delimType = sequence[i]; + if (delimType.type === "stack") { + // This is always the last delimiter, so we just break the loop now. + break; + } + + const metrics = getMetrics(delim, delimTypeToFont(delimType), "math"); + let heightDepth = metrics.height + metrics.depth; + + // Small delimiters are scaled down versions of the same font, so we + // account for the style change size. + if (delimType.type === "small") { + const newOptions = options.havingBaseStyle(delimType.style); + heightDepth *= newOptions.sizeMultiplier; + } + + // Check if the delimiter at this size works for the given height. + if (heightDepth > height) { + return delimType; + } + } + + // If we reached the end of the sequence, return the last sequence element. + return sequence[sequence.length - 1]; +}; + +/** + * Make a delimiter of a given height+depth, with optional centering. Here, we + * traverse the sequences, and create a delimiter that the sequence tells us to. + */ +export const makeCustomSizedDelim = function( + delim: string, + height: number, + center: boolean, + options: Options, + mode: Mode, + classes: string[], +): DomSpan { + if (delim === "<" || delim === "\\lt" || delim === "\u27e8") { + delim = "\\langle"; + } else if (delim === ">" || delim === "\\gt" || delim === "\u27e9") { + delim = "\\rangle"; + } + + // Decide what sequence to use + let sequence: Delimiter[]; + if (stackNeverDelimiters.has(delim)) { + sequence = stackNeverDelimiterSequence; + } else if (stackLargeDelimiters.has(delim)) { + sequence = stackLargeDelimiterSequence; + } else { + sequence = stackAlwaysDelimiterSequence; + } + + // Look through the sequence + const delimType = traverseSequence(delim, height, sequence, options); + + // Get the delimiter from font glyphs. + // Depending on the sequence element we decided on, call the + // appropriate function. + if (delimType.type === "small") { + return makeSmallDelim(delim, delimType.style, center, options, + mode, classes); + } else if (delimType.type === "large") { + return makeLargeDelim(delim, delimType.size, center, options, mode, + classes); + } else /* if (delimType.type === "stack") */ { + return makeStackedDelim(delim, height, center, options, mode, + classes); + } +}; + +/** + * Make a delimiter for use with `\left` and `\right`, given a height and depth + * of an expression that the delimiters surround. + */ +export const makeLeftRightDelim = function( + delim: string, + height: number, + depth: number, + options: Options, + mode: Mode, + classes: string[], +): DomSpan { + // We always center \left/\right delimiters, so the axis is always shifted + const axisHeight = + options.fontMetrics().axisHeight * options.sizeMultiplier; + + // Taken from TeX source, tex.web, function make_left_right + const delimiterFactor = 901; + const delimiterExtend = 5.0 / options.fontMetrics().ptPerEm; + + const maxDistFromAxis = Math.max( + height - axisHeight, depth + axisHeight); + + const totalHeight = Math.max( + // In real TeX, calculations are done using integral values which are + // 65536 per pt, or 655360 per em. So, the division here truncates in + // TeX but doesn't here, producing different results. If we wanted to + // exactly match TeX's calculation, we could do + // Math.floor(655360 * maxDistFromAxis / 500) * + // delimiterFactor / 655360 + // (To see the difference, compare + // x^{x^{\left(\rule{0.1em}{0.68em}\right)}} + // in TeX and KaTeX) + maxDistFromAxis / 500 * delimiterFactor, + 2 * maxDistFromAxis - delimiterExtend); + + // Finally, we defer to `makeCustomSizedDelim` with our calculated total + // height + return makeCustomSizedDelim(delim, totalHeight, true, options, mode, classes); +}; diff --git a/node_modules/react-katex/node_modules/katex/src/domTree.ts b/node_modules/react-katex/node_modules/katex/src/domTree.ts new file mode 100644 index 0000000..50d79df --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/domTree.ts @@ -0,0 +1,641 @@ +/** + * These objects store the data about the DOM nodes we create, as well as some + * extra data. They can then be transformed into real DOM nodes with the + * `toNode` function or HTML markup using `toMarkup`. They are useful for both + * storing extra properties on the nodes, as well as providing a way to easily + * work with the DOM. + * + * Similar functions for working with MathML nodes exist in mathMLTree.js. + * + * TODO: refactor `span` and `anchor` into common superclass when + * target environments support class inheritance + */ +import {scriptFromCodepoint} from "./unicodeScripts"; +import {escape, hyphenate} from "./utils"; +import {path} from "./svgGeometry"; +import type Options from "./Options"; +import {DocumentFragment} from "./tree"; +import {makeEm} from "./units"; +import ParseError from "./ParseError"; + +import type {VirtualNode} from "./tree"; + +/** + * Create an HTML className based on a list of classes. In addition to joining + * with spaces, we also remove empty classes. + */ +export const createClass = function(classes: string[]): string { + return classes.filter(cls => cls).join(" "); +}; + +/** + * Serialize a CssStyle object into a semicolon-delimited inline-style string + * (hyphenating camelCase property names). Returns "" when no property is set. + */ +const cssStyleToString = function(style: CssStyle): string { + let styles = ""; + for (const key of Object.keys(style) as Array) { + const value = style[key]; + if (value !== undefined) { + styles += `${hyphenate(key)}:${value};`; + } + } + return styles; +}; + +type InitNodeData = { + classes: string[]; + attributes: Record; + height: number; + depth: number; + maxFontSize: number; + style: CssStyle; +}; + +type HtmlNodeData = InitNodeData & { + children: VirtualNode[]; +}; + +const initNode = function( + this: InitNodeData, + classes?: string[], + options?: Options, + style?: CssStyle, +) { + this.classes = classes || []; + this.attributes = {}; + this.height = 0; + this.depth = 0; + this.maxFontSize = 0; + this.style = style || {}; + if (options) { + if (options.style.isTight()) { + this.classes.push("mtight"); + } + const color = options.getColor(); + if (color) { + this.style.color = color; + } + } +}; + +/** + * Convert into an HTML node + */ +const toNode = function(this: HtmlNodeData, tagName: string): HTMLElement { + const node = document.createElement(tagName); + + // Apply the class + node.className = createClass(this.classes); + + // Apply inline styles + Object.assign(node.style, this.style); + + // Apply attributes + for (const attr of Object.keys(this.attributes)) { + node.setAttribute(attr, this.attributes[attr]); + } + + // Append the children, also as HTML nodes + for (let i = 0; i < this.children.length; i++) { + node.appendChild(this.children[i].toNode()); + } + + return node; +}; + +/** + * https://w3c.github.io/html-reference/syntax.html#syntax-attributes + * + * > Attribute Names must consist of one or more characters + * other than the space characters, U+0000 NULL, + * '"', "'", ">", "/", "=", the control characters, + * and any characters that are not defined by Unicode. + */ +const invalidAttributeNameRegex = /[\s"'>/=\x00-\x1f]/; + +/** + * Convert into an HTML markup string + */ +const toMarkup = function(this: HtmlNodeData, tagName: string): string { + let markup = `<${tagName}`; + + // Add the class + if (this.classes.length) { + markup += ` class="${escape(createClass(this.classes))}"`; + } + + const styles = cssStyleToString(this.style); + if (styles) { + markup += ` style="${escape(styles)}"`; + } + + // Add the attributes + for (const attr of Object.keys(this.attributes)) { + if (invalidAttributeNameRegex.test(attr)) { + throw new ParseError(`Invalid attribute name '${attr}'`); + } + markup += ` ${attr}="${escape(this.attributes[attr])}"`; + } + + markup += ">"; + + // Add the markup of the children, also as markup + for (let i = 0; i < this.children.length; i++) { + markup += this.children[i].toMarkup(); + } + + markup += ``; + + return markup; +}; + +// Making the type below exact with all optional fields doesn't work due to +// - https://github.com/facebook/flow/issues/4582 +// - https://github.com/facebook/flow/issues/5688 +// However, since *all* fields are optional, $Shape<> works as suggested in 5688 +// above. +// This type does not include all CSS properties. Additional properties should +// be added as needed. +export type CssStyle = Partial<{ + backgroundColor: string; + borderBottomWidth: string; + borderColor: string; + borderRightStyle: string; + borderRightWidth: string; + borderTopWidth: string; + borderStyle: string; + borderWidth: string; + bottom: string; + color: string; + height: string; + left: string; + margin: string; + marginLeft: string; + marginRight: string; + marginTop: string; + minWidth: string; + paddingLeft: string; + position: string; + textShadow: string; + top: string; + width: string; + verticalAlign: string; +}> & {}; + +export interface HtmlDomNode extends VirtualNode { + classes: string[]; + height: number; + depth: number; + maxFontSize: number; + style: CssStyle; + hasClass(className: string): boolean; +} + +// Span wrapping other DOM nodes. +export type DomSpan = Span; +// Span wrapping an SVG node. +export type SvgSpan = Span; + +export type SvgChildNode = PathNode | LineNode; +export type documentFragment = DocumentFragment; + +/** + * This node represents a span node, with a className, a list of children, and + * an inline style. It also contains information about its height, depth, and + * maxFontSize. + * + * Represents two types with different uses: SvgSpan to wrap an SVG and DomSpan + * otherwise. This typesafety is important when HTML builders access a span's + * children. + */ +export class Span implements HtmlDomNode { + children: ChildType[]; + attributes!: Record; + classes!: string[]; + height!: number; + depth!: number; + width: number | null | undefined; + maxFontSize!: number; + style!: CssStyle; + /** + * Italic correction carried over from a SymbolNode when the symbol is + * wrapped in a vlist (e.g. \oiint / \oiiint). Read by supsub to adjust + * subscript positioning. Only set when nonzero; use `?? 0` at read sites. + */ + italic?: number; + + constructor( + classes?: string[], + children?: ChildType[], + options?: Options, + style?: CssStyle, + ) { + initNode.call(this, classes, options, style); + this.children = children || []; + } + + /** + * Sets an arbitrary attribute on the span. Warning: use this wisely. Not + * all browsers support attributes the same, and having too many custom + * attributes is probably bad. + */ + setAttribute(attribute: string, value: string) { + this.attributes[attribute] = value; + } + + hasClass(className: string): boolean { + return this.classes.includes(className); + } + + toNode(): HTMLElement { + return toNode.call(this, "span"); + } + + toMarkup(): string { + return toMarkup.call(this, "span"); + } +} + +/** + * This node represents an anchor () element with a hyperlink. See `span` + * for further details. + */ +export class Anchor implements HtmlDomNode { + children: HtmlDomNode[]; + attributes!: Record; + classes!: string[]; + height!: number; + depth!: number; + maxFontSize!: number; + style!: CssStyle; + + constructor( + href: string, + classes: string[], + children: HtmlDomNode[], + options: Options, + ) { + initNode.call(this, classes, options); + this.children = children || []; + this.setAttribute('href', href); + } + + setAttribute(attribute: string, value: string) { + this.attributes[attribute] = value; + } + + hasClass(className: string): boolean { + return this.classes.includes(className); + } + + toNode(): HTMLElement { + return toNode.call(this, "a"); + } + + toMarkup(): string { + return toMarkup.call(this, "a"); + } +} + +/** + * This node represents an image embed () element. + */ +export class Img implements VirtualNode { + src: string; + alt: string; + classes: string[]; + height: number; + depth: number; + maxFontSize: number; + style: CssStyle; + + constructor( + src: string, + alt: string, + style: CssStyle, + ) { + this.alt = alt; + this.src = src; + this.classes = ["mord"]; + this.height = 0; + this.depth = 0; + this.maxFontSize = 0; + this.style = style; + } + + hasClass(className: string): boolean { + return this.classes.includes(className); + } + + toNode(): Node { + const node = document.createElement("img"); + node.src = this.src; + node.alt = this.alt; + node.className = "mord"; + + // Apply inline styles + Object.assign(node.style, this.style); + + return node; + } + + toMarkup(): string { + let markup = `${escape(this.alt)} = { + 'î': '\u0131\u0302', + 'ï': '\u0131\u0308', + 'í': '\u0131\u0301', + // 'ī': '\u0131\u0304', // enable when we add Extended Latin + 'ì': '\u0131\u0300', +}; + +/** + * A symbol node contains information about a single symbol. It either renders + * to a single text node, or a span with a single text node in it, depending on + * whether it has CSS classes, styles, or needs italic correction. + */ +export class SymbolNode implements HtmlDomNode { + text: string; + height: number; + depth: number; + italic: number; + skew: number; + width: number; + maxFontSize: number; + classes: string[]; + style: CssStyle; + + constructor( + text: string, + height?: number, + depth?: number, + italic?: number, + skew?: number, + width?: number, + classes?: string[], + style?: CssStyle, + ) { + this.text = text; + this.height = height || 0; + this.depth = depth || 0; + this.italic = italic || 0; + this.skew = skew || 0; + this.width = width || 0; + this.classes = classes || []; + this.style = style || {}; + this.maxFontSize = 0; + + // Mark text from non-Latin scripts with specific classes so that we + // can specify which fonts to use. This allows us to render these + // characters with a serif font in situations where the browser would + // either default to a sans serif or render a placeholder character. + // We use CSS class names like cjk_fallback, hangul_fallback and + // brahmic_fallback. See ./unicodeScripts.js for the set of possible + // script names + const script = scriptFromCodepoint(this.text.charCodeAt(0)); + if (script) { + this.classes.push(script + "_fallback"); + } + + if (/[îïíì]/.test(this.text)) { // add ī when we add Extended Latin + this.text = iCombinations[this.text]; + } + } + + hasClass(className: string): boolean { + return this.classes.includes(className); + } + + /** + * Creates a text node or span from a symbol node. Note that a span is only + * created if it is needed. + */ + toNode(): Node { + const node = document.createTextNode(this.text); + let span = null; + + if (this.italic > 0) { + span = document.createElement("span"); + span.style.marginRight = makeEm(this.italic); + } + + if (this.classes.length > 0) { + span = span || document.createElement("span"); + span.className = createClass(this.classes); + } + + if (Object.keys(this.style).length > 0) { + span = span || document.createElement("span"); + Object.assign(span.style, this.style); + } + + if (span) { + span.appendChild(node); + return span; + } else { + return node; + } + } + + /** + * Creates markup for a symbol node. + */ + toMarkup(): string { + // TODO(alpert): More duplication than I'd like from + // span.prototype.toMarkup and symbolNode.prototype.toNode... + let needsSpan = false; + + let markup = " 0) { + styles += `margin-right:${makeEm(this.italic)};`; + } + styles += cssStyleToString(this.style); + + if (styles) { + needsSpan = true; + markup += " style=\"" + escape(styles) + "\""; + } + + const escaped = escape(this.text); + if (needsSpan) { + markup += ">"; + markup += escaped; + markup += ""; + return markup; + } else { + return escaped; + } + } +} + +/** + * SVG nodes are used to render stretchy wide elements. + */ +export class SvgNode implements VirtualNode { + children: SvgChildNode[]; + attributes: Record; + + constructor( + children?: SvgChildNode[], + attributes?: Record, + ) { + this.children = children || []; + this.attributes = attributes || {}; + } + + toNode(): Node { + const svgNS = "http://www.w3.org/2000/svg"; + const node = document.createElementNS(svgNS, "svg"); + + // Apply attributes + for (const attr of Object.keys(this.attributes)) { + node.setAttribute(attr, this.attributes[attr]); + } + + for (let i = 0; i < this.children.length; i++) { + node.appendChild(this.children[i].toNode()); + } + return node; + } + + toMarkup(): string { + let markup = ``; + } else { + return ``; + } + } +} + +export class LineNode implements VirtualNode { + attributes: Record; + + constructor( + attributes?: Record, + ) { + this.attributes = attributes || {}; + } + + toNode(): Node { + const svgNS = "http://www.w3.org/2000/svg"; + const node = document.createElementNS(svgNS, "line"); + + // Apply attributes + for (const attr of Object.keys(this.attributes)) { + node.setAttribute(attr, this.attributes[attr]); + } + + return node; + } + + toMarkup(): string { + let markup = " { + if (group instanceof Span) { + return group; + } else { + throw new Error(`Expected span but got ${String(group)}.`); + } +} + +/** + * Whether an HtmlDomNode has HtmlDomNode children. + * HtmlDomNode is a base type representing a union of + * SymbolNode, SvgSpan, DomSpan, Anchor, and documentFragment. + * In the last three cases, the children are HtmlDomNode[]. + */ +export const hasHtmlDomChildren = ( + node: HtmlDomNode, +): node is DomSpan | Anchor | documentFragment => + node instanceof Span || + node instanceof Anchor || + node instanceof DocumentFragment; diff --git a/node_modules/react-katex/node_modules/katex/src/environments.ts b/node_modules/react-katex/node_modules/katex/src/environments.ts new file mode 100644 index 0000000..fb26eec --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/environments.ts @@ -0,0 +1,8 @@ +import {_environments} from "./defineEnvironment"; + +const environments = _environments; + +export default environments; + +// All environment definitions should be imported below +import "./environments/array"; diff --git a/node_modules/react-katex/node_modules/katex/src/environments/array.ts b/node_modules/react-katex/node_modules/katex/src/environments/array.ts new file mode 100644 index 0000000..cf1cf32 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/environments/array.ts @@ -0,0 +1,1136 @@ +import {makeFragment, makeLineSpan, makeSpan, makeVList} from "../buildCommon"; +import Style from "../Style"; +import defineEnvironment from "../defineEnvironment"; +import {parseCD} from "./cd"; +import defineFunction from "../defineFunction"; +import defineMacro from "../defineMacro"; +import {MathNode} from "../mathMLTree"; +import ParseError from "../ParseError"; +import {assertNodeType, assertSymbolNodeType} from "../parseNode"; +import {checkSymbolNodeType} from "../parseNode"; +import {Token} from "../Token"; +import {calculateSize, makeEm} from "../units"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; + +import type Parser from "../Parser"; +import type {ParseNode, AnyParseNode} from "../parseNode"; +import type {StyleStr, Mode} from "../types"; +import type {HtmlBuilder, MathMLBuilder} from "../defineFunction"; +import type {HtmlDomNode} from "../domTree"; + +type EnvContextLike = { + parser: Parser; + envName: string; + mode: Mode; +}; + +// Data stored in the ParseNode associated with the environment. +export type AlignSpec = {type: "separator", separator: string} | { + type: "align"; + align: string; + pregap?: number; + postgap?: number; +}; + +// Type to indicate column separation in MathML +export type ColSeparationType = "align" | "alignat" | "gather" | "small" | "CD"; + +// Helper functions +function getHLines(parser: Parser): boolean[] { + // Return an array. The array length = number of hlines. + // Each element in the array tells if the line is dashed. + const hlineInfo = []; + parser.consumeSpaces(); + let nxt = parser.fetch().text; + if (nxt === "\\relax") { // \relax is an artifact of the \cr macro below + parser.consume(); + parser.consumeSpaces(); + nxt = parser.fetch().text; + } + while (nxt === "\\hline" || nxt === "\\hdashline") { + parser.consume(); + hlineInfo.push(nxt === "\\hdashline"); + parser.consumeSpaces(); + nxt = parser.fetch().text; + } + return hlineInfo; +} + +const validateAmsEnvironmentContext = (context: EnvContextLike) => { + const settings = context.parser.settings; + if (!settings.displayMode) { + throw new ParseError(`{${context.envName}} can be used only in` + + ` display mode.`); + } +}; + +const gatherEnvironments = new Set(["gather", "gather*"]); + +// autoTag (an argument to parseArray) can be one of three values: +// * undefined: Regular (not-top-level) array; no tags on each row +// * true: Automatic equation numbering, overridable by \tag +// * false: Tags allowed on each row, but no automatic numbering +// This function *doesn't* work with the "split" environment name. +function getAutoTag(name: string): boolean | null | undefined { + if (!name.includes("ed")) { + return !name.includes("*"); + } + // return undefined; +} + +/** + * Parse the body of the environment, with rows delimited by \\ and + * columns delimited by &, and create a nested list in row-major order + * with one group per cell. If given an optional argument style + * ("text", "display", etc.), then each cell is cast into that style. + */ +function parseArray( + parser: Parser, + { + hskipBeforeAndAfter, + addJot, + cols, + arraystretch, + colSeparationType, + autoTag, + singleRow, + emptySingleRow, + maxNumCols, + leqno, + }: { + hskipBeforeAndAfter?: boolean; + addJot?: boolean; + cols?: AlignSpec[]; + arraystretch?: number; + colSeparationType?: ColSeparationType; + autoTag?: boolean | null | undefined; + singleRow?: boolean; + emptySingleRow?: boolean; + maxNumCols?: number; + leqno?: boolean; + }, + style: StyleStr, +): ParseNode<"array"> { + parser.gullet.beginGroup(); + if (!singleRow) { + // \cr is equivalent to \\ without the optional size argument (see below) + // TODO: provide helpful error when \cr is used outside array environment + parser.gullet.macros.set("\\cr", "\\\\\\relax"); + } + + // Get current arraystretch if it's not set by the environment + if (!arraystretch) { + const stretch = parser.gullet.expandMacroAsText("\\arraystretch"); + if (stretch == null) { + // Default \arraystretch from lttab.dtx + arraystretch = 1; + } else { + arraystretch = parseFloat(stretch); + if (!arraystretch || arraystretch < 0) { + throw new ParseError(`Invalid \\arraystretch: ${stretch}`); + } + } + } + + // Start group for first cell + parser.gullet.beginGroup(); + + let row: AnyParseNode[] = []; + const body: AnyParseNode[][] = [row]; + const rowGaps = []; + const hLinesBeforeRow = []; + const tags: Array | undefined = + (autoTag != null ? [] : undefined); + + // amsmath uses \global\@eqnswtrue and \global\@eqnswfalse to represent + // whether this row should have an equation number. Simulate this with + // a \@eqnsw macro set to 1 or 0. + function beginRow() { + if (autoTag) { + parser.gullet.macros.set("\\@eqnsw", "1", true); + } + } + function endRow() { + if (tags) { + if (parser.gullet.macros.get("\\df@tag")) { + tags.push(parser.subparse([new Token("\\df@tag")])); + parser.gullet.macros.set("\\df@tag", undefined, true); + } else { + tags.push(Boolean(autoTag) && + parser.gullet.macros.get("\\@eqnsw") === "1"); + } + } + } + beginRow(); + + // Test for \hline at the top of the array. + hLinesBeforeRow.push(getHLines(parser)); + + while (true) { + // Parse each cell in its own group (namespace) + const cellBody = parser.parseExpression(false, singleRow ? "\\end" : "\\\\"); + parser.gullet.endGroup(); + parser.gullet.beginGroup(); + let cell: AnyParseNode = { + type: "ordgroup", + mode: parser.mode, + body: cellBody, + }; + if (style) { + cell = { + type: "styling", + mode: parser.mode, + style, + resetFont: true, + body: [cell], + }; + } + row.push(cell); + const next = parser.fetch().text; + if (next === "&") { + if (maxNumCols && row.length === maxNumCols) { + if (singleRow || colSeparationType) { + // {equation} or {split} + throw new ParseError("Too many tab characters: &", + parser.nextToken); + } else { + // {array} environment + parser.settings.reportNonstrict("textEnv", "Too few columns " + + "specified in the {array} column argument."); + } + } + parser.consume(); + } else if (next === "\\end") { + endRow(); + // Arrays terminate newlines with `\crcr` which consumes a `\cr` if + // the last line is empty. However, AMS environments keep the + // empty row if it's the only one. + // NOTE: Currently, `cell` is the last item added into `row`. + if (row.length === 1 && cell.type === "styling" && + cell.body.length === 1 && cell.body[0].type === "ordgroup" && + cell.body[0].body.length === 0 && + (body.length > 1 || !emptySingleRow)) { + body.pop(); + } + if (hLinesBeforeRow.length < body.length + 1) { + hLinesBeforeRow.push([]); + } + break; + } else if (next === "\\\\") { + parser.consume(); + let size; + // \def\Let@{\let\\\math@cr} + // \def\math@cr{...\math@cr@} + // \def\math@cr@{\new@ifnextchar[\math@cr@@{\math@cr@@[\z@]}} + // \def\math@cr@@[#1]{...\math@cr@@@...} + // \def\math@cr@@@{\cr} + if (parser.gullet.future().text !== " ") { + size = parser.parseSizeGroup(true); + } + rowGaps.push(size ? size.value : null); + endRow(); + + // check for \hline(s) following the row separator + hLinesBeforeRow.push(getHLines(parser)); + + row = []; + body.push(row); + beginRow(); + } else { + throw new ParseError("Expected & or \\\\ or \\cr or \\end", + parser.nextToken); + } + } + + // End cell group + parser.gullet.endGroup(); + // End array group defining \cr + parser.gullet.endGroup(); + + return { + type: "array", + mode: parser.mode, + addJot, + arraystretch, + body, + cols, + rowGaps, + hskipBeforeAndAfter, + hLinesBeforeRow, + colSeparationType, + tags, + leqno, + }; +} + +// Decides on a style for cells in an array according to whether the given +// environment name starts with the letter 'd'. +function dCellStyle(envName: string): StyleStr { + if (envName.slice(0, 1) === "d") { + return "display"; + } else { + return "text"; + } +} + +type Outrow = { + cells: HtmlDomNode[]; + height: number; + depth: number; + pos: number; +}; + +const htmlBuilder: HtmlBuilder<"array"> = function(group, options) { + let r; + let c; + const nr = group.body.length; + const hLinesBeforeRow = group.hLinesBeforeRow; + let nc = 0; + const body: Outrow[] = new Array(nr); + const hlines: Array<{pos: number; isDashed: boolean}> = []; + const ruleThickness = Math.max( + // From LaTeX \showthe\arrayrulewidth. Equals 0.04 em. + options.fontMetrics().arrayRuleWidth, + options.minRuleThickness, // User override. + ); + + // Horizontal spacing + const pt = 1 / options.fontMetrics().ptPerEm; + let arraycolsep = 5 * pt; // default value, i.e. \arraycolsep in article.cls + if (group.colSeparationType && group.colSeparationType === "small") { + // We're in a {smallmatrix}. Default column space is \thickspace, + // i.e. 5/18em = 0.2778em, per amsmath.dtx for {smallmatrix}. + // But that needs adjustment because LaTeX applies \scriptstyle to the + // entire array, including the colspace, but this function applies + // \scriptstyle only inside each element. + const localMultiplier = options.havingStyle(Style.SCRIPT).sizeMultiplier; + arraycolsep = 0.2778 * (localMultiplier / options.sizeMultiplier); + } + + // Vertical spacing + const baselineskip = group.colSeparationType === "CD" + ? calculateSize({number: 3, unit: "ex"}, options) + : 12 * pt; // see size10.clo + // Default \jot from ltmath.dtx + // TODO(edemaine): allow overriding \jot via \setlength (#687) + const jot = 3 * pt; + const arrayskip = group.arraystretch * baselineskip; + const arstrutHeight = 0.7 * arrayskip; // \strutbox in ltfsstrc.dtx and + const arstrutDepth = 0.3 * arrayskip; // \@arstrutbox in lttab.dtx + + let totalHeight = 0; + + // Set a position for \hline(s) at the top of the array, if any. + function setHLinePos(hlinesInGap: boolean[]) { + for (let i = 0; i < hlinesInGap.length; ++i) { + if (i > 0) { + totalHeight += 0.25; + } + hlines.push({pos: totalHeight, isDashed: hlinesInGap[i]}); + } + } + setHLinePos(hLinesBeforeRow[0]); + + for (r = 0; r < group.body.length; ++r) { + const inrow = group.body[r]; + let height = arstrutHeight; // \@array adds an \@arstrut + let depth = arstrutDepth; // to each tow (via the template) + + if (nc < inrow.length) { + nc = inrow.length; + } + + const outrow: Outrow = { + cells: new Array(inrow.length), + height: 0, + depth: 0, + pos: 0, + }; + for (c = 0; c < inrow.length; ++c) { + const elt = html.buildGroup(inrow[c], options); + if (depth < elt.depth) { + depth = elt.depth; + } + if (height < elt.height) { + height = elt.height; + } + outrow.cells[c] = elt; + } + + const rowGap = group.rowGaps[r]; + let gap = 0; + if (rowGap) { + gap = calculateSize(rowGap, options); + if (gap > 0) { // \@argarraycr + gap += arstrutDepth; + if (depth < gap) { + depth = gap; // \@xargarraycr + } + gap = 0; + } + } + // In AMS multiline environments such as aligned and gathered, rows + // correspond to lines that have additional \jot added between lines + // via \openup. + // We simulate this by adding \jot depth to each row except the last. + if (group.addJot && r < group.body.length - 1) { + depth += jot; + } + + outrow.height = height; + outrow.depth = depth; + totalHeight += height; + outrow.pos = totalHeight; + totalHeight += depth + gap; // \@yargarraycr + body[r] = outrow; + + // Set a position for \hline(s), if any. + setHLinePos(hLinesBeforeRow[r + 1]); + } + + const offset = totalHeight / 2 + options.fontMetrics().axisHeight; + const colDescriptions = group.cols || []; + const cols: HtmlDomNode[] = []; + let colSep; + let colDescrNum; + const tagSpans: Array<{ + type: "elem"; + elem: HtmlDomNode; + shift: number; + }> = []; + + if (group.tags && group.tags.some(tag => tag)) { + // An environment with manual tags and/or automatic equation numbers. + // Create node(s), the latter of which trigger CSS counter increment. + for (r = 0; r < nr; ++r) { + const rw = body[r]; + const shift = rw.pos - offset; + const tag = group.tags[r]; + let tagSpan; + if (tag === true) { // automatic numbering + tagSpan = makeSpan(["eqn-num"], [], options); + } else if (tag === false) { + // \nonumber/\notag or starred environment + tagSpan = makeSpan([], [], options); + } else { // manual \tag + tagSpan = makeSpan([], + html.buildExpression(tag, options, true), options); + } + tagSpan.depth = rw.depth; + tagSpan.height = rw.height; + tagSpans.push({type: "elem", elem: tagSpan, shift}); + } + } + + for (c = 0, colDescrNum = 0; + // Continue while either there are more columns or more column + // descriptions, so trailing separators don't get lost. + c < nc || colDescrNum < colDescriptions.length; + ++c, ++colDescrNum) { + let colDescr: AlignSpec | undefined = colDescriptions[colDescrNum]; + + let firstSeparator = true; + while (colDescr?.type === "separator") { + // If there is more than one separator in a row, add a space + // between them. + if (!firstSeparator) { + colSep = makeSpan(["arraycolsep"], []); + colSep.style.width = + makeEm(options.fontMetrics().doubleRuleSep); + cols.push(colSep); + } + + if (colDescr.separator === "|" || colDescr.separator === ":") { + const lineType = colDescr.separator === "|" ? "solid" : "dashed"; + const separator = makeSpan(["vertical-separator"], [], options); + separator.style.height = makeEm(totalHeight); + separator.style.borderRightWidth = makeEm(ruleThickness); + separator.style.borderRightStyle = lineType; + separator.style.margin = `0 ${makeEm(-ruleThickness / 2)}`; + const shift = totalHeight - offset; + if (shift) { + separator.style.verticalAlign = makeEm(-shift); + } + + cols.push(separator); + } else { + throw new ParseError( + "Invalid separator type: " + colDescr.separator); + } + + colDescrNum++; + colDescr = colDescriptions[colDescrNum]; + firstSeparator = false; + } + + if (c >= nc) { + continue; + } + + let sepwidth; + if (c > 0 || group.hskipBeforeAndAfter) { + sepwidth = colDescr?.pregap ?? arraycolsep; + if (sepwidth !== 0) { + colSep = makeSpan(["arraycolsep"], []); + colSep.style.width = makeEm(sepwidth); + cols.push(colSep); + } + } + + const colElems: Array<{ + type: "elem"; + elem: HtmlDomNode; + shift: number; + }> = []; + for (r = 0; r < nr; ++r) { + const row = body[r]; + const elem = row.cells[c]; + if (!elem) { + continue; + } + const shift = row.pos - offset; + elem.depth = row.depth; + elem.height = row.height; + colElems.push({type: "elem", elem: elem, shift: shift}); + } + + const colVList = makeVList({ + positionType: "individualShift", + children: colElems, + }, options); + const colSpan = makeSpan( + ["col-align-" + (colDescr?.align || "c")], + [colVList], + ); + cols.push(colSpan); + + if (c < nc - 1 || group.hskipBeforeAndAfter) { + sepwidth = colDescr?.postgap ?? arraycolsep; + if (sepwidth !== 0) { + colSep = makeSpan(["arraycolsep"], []); + colSep.style.width = makeEm(sepwidth); + cols.push(colSep); + } + } + } + + let tableBody: HtmlDomNode = makeSpan(["mtable"], cols); + + // Add \hline(s), if any. + if (hlines.length > 0) { + const line = makeLineSpan("hline", options, ruleThickness); + const dashes = makeLineSpan("hdashline", options, ruleThickness); + const vListElems = [{type: "elem" as const, elem: tableBody, shift: 0}]; + while (hlines.length > 0) { + const hline = hlines.pop()!; + const lineShift = hline.pos - offset; + if (hline.isDashed) { + vListElems.push({type: "elem" as const, elem: dashes, shift: lineShift}); + } else { + vListElems.push({type: "elem" as const, elem: line, shift: lineShift}); + } + } + + tableBody = makeVList({ + positionType: "individualShift", + children: vListElems, + }, options); + } + + if (tagSpans.length === 0) { + return makeSpan(["mord"], [tableBody], options); + } else { + const eqnNumCol = makeVList({ + positionType: "individualShift", + children: tagSpans, + }, options); + const tagCol = makeSpan(["tag"], [eqnNumCol], options); + return makeFragment([tableBody, tagCol]); + } +}; + +const alignMap: Record = { + c: "center ", + l: "left ", + r: "right ", +}; + +const mathmlBuilder: MathMLBuilder<"array"> = function(group, options) { + const tbl = []; + const glue = new MathNode("mtd", [], ["mtr-glue"]); + const tag = new MathNode("mtd", [], ["mml-eqn-num"]); + for (let i = 0; i < group.body.length; i++) { + const rw = group.body[i]; + const row = []; + for (let j = 0; j < rw.length; j++) { + row.push(new MathNode("mtd", + [mml.buildGroup(rw[j], options)])); + } + if (group.tags && group.tags[i]) { + row.unshift(glue); + row.push(glue); + if (group.leqno) { + row.unshift(tag); + } else { + row.push(tag); + } + } + tbl.push(new MathNode("mtr", row)); + } + let table = new MathNode("mtable", tbl); + + // Set column alignment, row spacing, column spacing, and + // array lines by setting attributes on the table element. + + // Set the row spacing. In MathML, we specify a gap distance. + // We do not use rowGap[] because MathML automatically increases + // cell height with the height/depth of the element content. + + // LaTeX \arraystretch multiplies the row baseline-to-baseline distance. + // We simulate this by adding (arraystretch - 1)em to the gap. This + // does a reasonable job of adjusting arrays containing 1 em tall content. + + // The 0.16 and 0.09 values are found empirically. They produce an array + // similar to LaTeX and in which content does not interfere with \hlines. + const gap = (group.arraystretch === 0.5) + ? 0.1 // {smallmatrix}, {subarray} + : 0.16 + group.arraystretch - 1 + (group.addJot ? 0.09 : 0); + table.setAttribute("rowspacing", makeEm(gap)); + + // MathML table lines go only between cells. + // To place a line on an edge we'll use , if necessary. + let menclose = ""; + let align = ""; + + if (group.cols && group.cols.length > 0) { + // Find column alignment, column spacing, and vertical lines. + const cols = group.cols; + let columnLines = ""; + let prevTypeWasAlign = false; + let iStart = 0; + let iEnd = cols.length; + + if (cols[0].type === "separator") { + menclose += "top "; + iStart = 1; + } + if (cols[cols.length - 1].type === "separator") { + menclose += "bottom "; + iEnd -= 1; + } + + for (let i = iStart; i < iEnd; i++) { + const col = cols[i]; + if (col.type === "align") { + align += alignMap[col.align]; + + if (prevTypeWasAlign) { + columnLines += "none "; + } + prevTypeWasAlign = true; + } else if (col.type === "separator") { + // MathML accepts only single lines between cells. + // So we read only the first of consecutive separators. + if (prevTypeWasAlign) { + columnLines += col.separator === "|" ? "solid " : "dashed "; + prevTypeWasAlign = false; + } + } + } + + table.setAttribute("columnalign", align.trim()); + + if (/[sd]/.test(columnLines)) { + table.setAttribute("columnlines", columnLines.trim()); + } + } + + // Set column spacing. + if (group.colSeparationType === "align") { + const cols = group.cols || []; + let spacing = ""; + for (let i = 1; i < cols.length; i++) { + spacing += i % 2 ? "0em " : "1em "; + } + table.setAttribute("columnspacing", spacing.trim()); + } else if (group.colSeparationType === "alignat" || + group.colSeparationType === "gather") { + table.setAttribute("columnspacing", "0em"); + } else if (group.colSeparationType === "small") { + table.setAttribute("columnspacing", "0.2778em"); + } else if (group.colSeparationType === "CD") { + table.setAttribute("columnspacing", "0.5em"); + } else { + table.setAttribute("columnspacing", "1em"); + } + + // Address \hline and \hdashline + let rowLines = ""; + const hlines = group.hLinesBeforeRow; + + menclose += hlines[0].length > 0 ? "left " : ""; + menclose += hlines[hlines.length - 1].length > 0 ? "right " : ""; + + for (let i = 1; i < hlines.length - 1; i++) { + rowLines += (hlines[i].length === 0) + ? "none " + // MathML accepts only a single line between rows. Read one element. + : hlines[i][0] ? "dashed " : "solid "; + } + if (/[sd]/.test(rowLines)) { + table.setAttribute("rowlines", rowLines.trim()); + } + + if (menclose !== "") { + table = new MathNode("menclose", [table]); + table.setAttribute("notation", menclose.trim()); + } + + if (group.arraystretch && group.arraystretch < 1) { + // A small array. Wrap in scriptstyle so row gap is not too large. + table = new MathNode("mstyle", [table]); + table.setAttribute("scriptlevel", "1"); + } + + return table; +}; + +// Convenience function for align, align*, aligned, alignat, alignat*, alignedat. +const alignedHandler = function(context: EnvContextLike, args: AnyParseNode[]) { + if (!context.envName.includes("ed")) { + validateAmsEnvironmentContext(context); + } + const cols: AlignSpec[] = []; + const separationType: ColSeparationType = context.envName.includes("at") ? "alignat" : "align"; + const isSplit = context.envName === "split"; + const res = parseArray(context.parser, + { + cols, + addJot: true, + autoTag: isSplit ? undefined : getAutoTag(context.envName), + emptySingleRow: true, + colSeparationType: separationType, + maxNumCols: isSplit ? 2 : undefined, + leqno: context.parser.settings.leqno, + }, + "display" + ); + + // Determining number of columns. + // 1. If the first argument is given, we use it as a number of columns, + // and makes sure that each row doesn't exceed that number. + // 2. Otherwise, just count number of columns = maximum number + // of cells in each row ("aligned" mode -- isAligned will be true). + // + // At the same time, prepend empty group {} at beginning of every second + // cell in each row (starting with second cell) so that operators become + // binary. This behavior is implemented in amsmath's \start@aligned. + let numMaths = 0; + let numCols = 0; + const emptyGroup: ParseNode<"ordgroup"> = { + type: "ordgroup", + mode: context.mode, + body: [], + }; + if (args[0] && args[0].type === "ordgroup") { + let arg0 = ""; + for (let i = 0; i < args[0].body.length; i++) { + const textord = assertNodeType(args[0].body[i], "textord"); + arg0 += textord.text; + } + numMaths = Number(arg0); + numCols = numMaths * 2; + } + const isAligned = !numCols; + res.body.forEach(function(row) { + for (let i = 1; i < row.length; i += 2) { + // Modify ordgroup node within styling node + const styling = assertNodeType(row[i], "styling"); + const ordgroup = assertNodeType(styling.body[0], "ordgroup"); + ordgroup.body.unshift(emptyGroup); + } + if (!isAligned) { // Case 1 + const curMaths = row.length / 2; + if (numMaths < curMaths) { + throw new ParseError( + "Too many math in a row: " + + `expected ${numMaths}, but got ${curMaths}`, + row[0]); + } + } else if (numCols < row.length) { // Case 2 + numCols = row.length; + } + }); + + // Adjusting alignment. + // In aligned mode, we add one \qquad between columns; + // otherwise we add nothing. + for (let i = 0; i < numCols; ++i) { + let align = "r"; + let pregap = 0; + if (i % 2 === 1) { + align = "l"; + } else if (i > 0 && isAligned) { // "aligned" mode. + pregap = 1; // add one \quad + } + cols[i] = { + type: "align", + align: align, + pregap: pregap, + postgap: 0, + }; + } + res.colSeparationType = isAligned ? "align" : "alignat"; + return res; +}; + +// Arrays are part of LaTeX, defined in lttab.dtx so its documentation +// is part of the source2e.pdf file of LaTeX2e source documentation. +// {darray} is an {array} environment where cells are set in \displaystyle, +// as defined in nccmath.sty. +defineEnvironment({ + type: "array", + names: ["array", "darray"], + props: { + numArgs: 1, + }, + handler(context, args) { + // Since no types are specified above, the two possibilities are + // - The argument is wrapped in {} or [], in which case Parser's + // parseGroup() returns an "ordgroup" wrapping some symbol node. + // - The argument is a bare symbol node. + const symNode = checkSymbolNodeType(args[0]); + const colalign: AnyParseNode[] = + symNode ? [args[0]] : assertNodeType(args[0], "ordgroup").body; + const cols: AlignSpec[] = colalign.map(function(nde) { + const node = assertSymbolNodeType(nde); + const ca = node.text; + if ("lcr".includes(ca)) { + return { + type: "align", + align: ca, + }; + } else if (ca === "|") { + return { + type: "separator", + separator: "|", + }; + } else if (ca === ":") { + return { + type: "separator", + separator: ":", + }; + } + throw new ParseError("Unknown column alignment: " + ca, nde); + }); + const res: Parameters[1] = { + cols, + hskipBeforeAndAfter: true, // \@preamble in lttab.dtx + maxNumCols: cols.length, + }; + return parseArray(context.parser, res, dCellStyle(context.envName)); + }, + htmlBuilder, + mathmlBuilder, +}); + +// The matrix environments of amsmath builds on the array environment +// of LaTeX, which is discussed above. +// The mathtools package adds starred versions of the same environments. +// These have an optional argument to choose left|center|right justification. +defineEnvironment({ + type: "array", + names: [ + "matrix", + "pmatrix", + "bmatrix", + "Bmatrix", + "vmatrix", + "Vmatrix", + "matrix*", + "pmatrix*", + "bmatrix*", + "Bmatrix*", + "vmatrix*", + "Vmatrix*", + ], + props: { + numArgs: 0, + }, + handler(context) { + const delimiters = { + "matrix": null, + "pmatrix": ["(", ")"], + "bmatrix": ["[", "]"], + "Bmatrix": ["\\{", "\\}"], + "vmatrix": ["|", "|"], + "Vmatrix": ["\\Vert", "\\Vert"], + }[context.envName.replace("*", "")]; + // \hskip -\arraycolsep in amsmath + let colAlign = "c"; + const payload: Parameters[1] = { + hskipBeforeAndAfter: false, + cols: [{type: "align", align: colAlign}], + }; + if (context.envName.charAt(context.envName.length - 1) === "*") { + // It's one of the mathtools starred functions. + // Parse the optional alignment argument. + const parser = context.parser; + parser.consumeSpaces(); + if (parser.fetch().text === "[") { + parser.consume(); + parser.consumeSpaces(); + colAlign = parser.fetch().text; + if (!"lcr".includes(colAlign)) { + throw new ParseError("Expected l or c or r", parser.nextToken); + } + parser.consume(); + parser.consumeSpaces(); + parser.expect("]"); + parser.consume(); + payload.cols = [{type: "align", align: colAlign}]; + } + } + const res: ParseNode<"array"> = + parseArray(context.parser, payload, dCellStyle(context.envName)); + // Populate cols with the correct number of column alignment specs. + const numCols = Math.max(0, ...res.body.map(row => row.length)); + res.cols = new Array(numCols).fill( + {type: "align", align: colAlign} + ); + return delimiters ? { + type: "leftright", + mode: context.mode, + body: [res], + left: delimiters[0], + right: delimiters[1], + rightColor: undefined, // \right uninfluenced by \color in array + } : res; + }, + htmlBuilder, + mathmlBuilder, +}); + +defineEnvironment({ + type: "array", + names: ["smallmatrix"], + props: { + numArgs: 0, + }, + handler(context) { + const payload: Parameters[1] = {arraystretch: 0.5}; + const res = parseArray(context.parser, payload, "script"); + res.colSeparationType = "small"; + return res; + }, + htmlBuilder, + mathmlBuilder, +}); + +defineEnvironment({ + type: "array", + names: ["subarray"], + props: { + numArgs: 1, + }, + handler(context, args) { + // Parsing of {subarray} is similar to {array} + const symNode = checkSymbolNodeType(args[0]); + const colalign: AnyParseNode[] = + symNode ? [args[0]] : assertNodeType(args[0], "ordgroup").body; + const cols: AlignSpec[] = colalign.map(function(nde) { + const node = assertSymbolNodeType(nde); + const ca = node.text; + // {subarray} only recognizes "l" & "c" + if ("lc".includes(ca)) { + return { + type: "align", + align: ca, + }; + } + throw new ParseError("Unknown column alignment: " + ca, nde); + }); + if (cols.length > 1) { + throw new ParseError("{subarray} can contain only one column"); + } + const payload: Parameters[1] = { + cols, + hskipBeforeAndAfter: false, + arraystretch: 0.5, + }; + const res = parseArray(context.parser, payload, "script"); + if (res.body.length > 0 && res.body[0].length > 1) { + throw new ParseError("{subarray} can contain only one column"); + } + return res; + }, + htmlBuilder, + mathmlBuilder, +}); + +// A cases environment (in amsmath.sty) is almost equivalent to +// \def\arraystretch{1.2}% +// \left\{\begin{array}{@{}l@{\quad}l@{}} … \end{array}\right. +// {dcases} is a {cases} environment where cells are set in \displaystyle, +// as defined in mathtools.sty. +// {rcases} is another mathtools environment. It's brace is on the right side. +defineEnvironment({ + type: "array", + names: [ + "cases", + "dcases", + "rcases", + "drcases", + ], + props: { + numArgs: 0, + }, + handler(context) { + const payload: Parameters[1] = { + arraystretch: 1.2, + cols: [{ + type: "align", + align: "l", + pregap: 0, + // TODO(kevinb) get the current style. + // For now we use the metrics for TEXT style which is what we were + // doing before. Before attempting to get the current style we + // should look at TeX's behavior especially for \over and matrices. + postgap: 1.0, /* 1em quad */ + }, { + type: "align", + align: "l", + pregap: 0, + postgap: 0, + }], + }; + const res: ParseNode<"array"> = + parseArray(context.parser, payload, dCellStyle(context.envName)); + return { + type: "leftright", + mode: context.mode, + body: [res], + left: context.envName.includes("r") ? "." : "\\{", + right: context.envName.includes("r") ? "\\}" : ".", + rightColor: undefined, + }; + }, + htmlBuilder, + mathmlBuilder, +}); + +// In the align environment, one uses ampersands, &, to specify number of +// columns in each row, and to locate spacing between each column. +// align gets automatic numbering. align* and aligned do not. +// The alignedat environment can be used in math mode. +// Note that we assume \nomallineskiplimit to be zero, +// so that \strut@ is the same as \strut. +defineEnvironment({ + type: "array", + names: ["align", "align*", "aligned", "split"], + props: { + numArgs: 0, + }, + handler: alignedHandler, + htmlBuilder, + mathmlBuilder, +}); + +// A gathered environment is like an array environment with one centered +// column, but where rows are considered lines so get \jot line spacing +// and contents are set in \displaystyle. +defineEnvironment({ + type: "array", + names: ["gathered", "gather", "gather*"], + props: { + numArgs: 0, + }, + handler(context) { + if (gatherEnvironments.has(context.envName)) { + validateAmsEnvironmentContext(context); + } + const res: Parameters[1] = { + cols: [{ + type: "align", + align: "c", + }], + addJot: true, + colSeparationType: "gather", + autoTag: getAutoTag(context.envName), + emptySingleRow: true, + leqno: context.parser.settings.leqno, + }; + return parseArray(context.parser, res, "display"); + }, + htmlBuilder, + mathmlBuilder, +}); + +// alignat environment is like an align environment, but one must explicitly +// specify maximum number of columns in each row, and can adjust spacing between +// each columns. +defineEnvironment({ + type: "array", + names: ["alignat", "alignat*", "alignedat"], + props: { + numArgs: 1, + }, + handler: alignedHandler, + htmlBuilder, + mathmlBuilder, +}); + +defineEnvironment({ + type: "array", + names: ["equation", "equation*"], + props: { + numArgs: 0, + }, + handler(context) { + validateAmsEnvironmentContext(context); + const res: Parameters[1] = { + autoTag: getAutoTag(context.envName), + emptySingleRow: true, + singleRow: true, + maxNumCols: 1, + leqno: context.parser.settings.leqno, + }; + return parseArray(context.parser, res, "display"); + }, + htmlBuilder, + mathmlBuilder, +}); + +defineEnvironment({ + type: "array", + names: ["CD"], + props: { + numArgs: 0, + }, + handler(context) { + validateAmsEnvironmentContext(context); + return parseCD(context.parser); + }, + htmlBuilder, + mathmlBuilder, +}); + +defineMacro("\\nonumber", "\\gdef\\@eqnsw{0}"); +defineMacro("\\notag", "\\nonumber"); + +// Catch \hline outside array environment +defineFunction({ + type: "text", // Doesn't matter what this is. + names: ["\\hline", "\\hdashline"], + props: { + numArgs: 0, + allowedInText: true, + allowedInMath: true, + }, + handler(context, args) { + throw new ParseError( + `${context.funcName} valid only within array environment`); + }, +}); diff --git a/node_modules/react-katex/node_modules/katex/src/environments/cd.ts b/node_modules/react-katex/node_modules/katex/src/environments/cd.ts new file mode 100644 index 0000000..93b78f3 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/environments/cd.ts @@ -0,0 +1,318 @@ +import {wrapFragment} from "../buildCommon"; +import defineFunction from "../defineFunction"; +import {MathNode} from "../mathMLTree"; +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; +import {assertSymbolNodeType} from "../parseNode"; +import ParseError from "../ParseError"; +import {makeEm} from "../units"; + +import type Parser from "../Parser"; +import type {ParseNode, AnyParseNode} from "../parseNode"; + +const cdArrowFunctionName: Record = { + ">": "\\\\cdrightarrow", + "<": "\\\\cdleftarrow", + "=": "\\\\cdlongequal", + "A": "\\uparrow", + "V": "\\downarrow", + "|": "\\Vert", + ".": "no arrow", +}; + +const newCell = (): ParseNode<"styling"> => { + // Create an empty cell, to be filled below with parse nodes. + // The parseTree from this module must be constructed like the + // one created by parseArray(), so an empty CD cell must + // be a ParseNode<"styling">. And CD is always displaystyle. + return { + type: "styling", + body: [], + mode: "math", + style: "display", + resetFont: true, + }; +}; + +const isStartOfArrow = (node: AnyParseNode) => { + return (node.type === "textord" && node.text === "@"); +}; + +const isLabelEnd = (node: AnyParseNode, endChar: string): boolean => { + return ((node.type === "mathord" || node.type === "atom") && + node.text === endChar); +}; + +function cdArrow( + arrowChar: string, + labels: ParseNode<"ordgroup">[], + parser: Parser +): AnyParseNode { + // Return a parse tree of an arrow and its labels. + // This acts in a way similar to a macro expansion. + const funcName = cdArrowFunctionName[arrowChar]; + switch (funcName) { + case "\\\\cdrightarrow": + case "\\\\cdleftarrow": + return parser.callFunction( + funcName, [labels[0]], [labels[1]] + ); + case "\\uparrow": + case "\\downarrow": { + const leftLabel = parser.callFunction( + "\\\\cdleft", [labels[0]], [] + ); + const bareArrow: ParseNode<"atom"> = { + type: "atom", + text: funcName, + mode: "math", + family: "rel", + }; + const sizedArrow = parser.callFunction("\\Big", [bareArrow], []); + const rightLabel = parser.callFunction( + "\\\\cdright", [labels[1]], [] + ); + const arrowGroup: ParseNode<"ordgroup"> = { + type: "ordgroup", + mode: "math", + body: [leftLabel, sizedArrow, rightLabel], + }; + return parser.callFunction("\\\\cdparent", [arrowGroup], []); + } + case "\\\\cdlongequal": + return parser.callFunction("\\\\cdlongequal", [], []); + case "\\Vert": { + const arrow: ParseNode<"textord"> = {type: "textord", text: "\\Vert", mode: "math"}; + return parser.callFunction("\\Big", [arrow], []); + } + default: + return {type: "textord", text: " ", mode: "math"}; + } +} + +export function parseCD(parser: Parser): ParseNode<"array"> { + // Get the array's parse nodes with \\ temporarily mapped to \cr. + const parsedRows: AnyParseNode[][] = []; + parser.gullet.beginGroup(); + parser.gullet.macros.set("\\cr", "\\\\\\relax"); + parser.gullet.beginGroup(); + while (true) { + // Get the parse nodes for the next row. + parsedRows.push(parser.parseExpression(false, "\\\\")); + parser.gullet.endGroup(); + parser.gullet.beginGroup(); + const next = parser.fetch().text; + if (next === "&" || next === "\\\\") { + parser.consume(); + } else if (next === "\\end") { + if (parsedRows[parsedRows.length - 1].length === 0) { + parsedRows.pop(); // final row ended in \\ + } + break; + } else { + throw new ParseError("Expected \\\\ or \\cr or \\end", + parser.nextToken); + } + } + + let row: ParseNode<"styling">[] = []; + const body: ParseNode<"styling">[][] = [row]; + + // Loop thru the parse nodes. Collect them into cells and arrows. + for (let i = 0; i < parsedRows.length; i++) { + // Start a new row. + const rowNodes = parsedRows[i]; + // Create the first cell. + let cell = newCell(); + + for (let j = 0; j < rowNodes.length; j++) { + if (!isStartOfArrow(rowNodes[j])) { + // If a parseNode is not an arrow, it goes into a cell. + cell.body.push(rowNodes[j]); + } else { + // Parse node j is an "@", the start of an arrow. + // Before starting on the arrow, push the cell into `row`. + row.push(cell); + + // Now collect parseNodes into an arrow. + // The character after "@" defines the arrow type. + j += 1; + const arrowChar = assertSymbolNodeType(rowNodes[j]).text; + + // Create two empty label nodes. We may or may not use them. + const labels: ParseNode<"ordgroup">[] = new Array(2); + labels[0] = {type: "ordgroup", mode: "math", body: []}; + labels[1] = {type: "ordgroup", mode: "math", body: []}; + + // Process the arrow. + if ("=|.".includes(arrowChar)) { + // Three "arrows", ``@=`, `@|`, and `@.`, do not take labels. + // Do nothing here. + } else if ("<>AV".includes(arrowChar)) { + // Four arrows, `@>>>`, `@<<<`, `@AAA`, and `@VVV`, each take + // two optional labels. E.g. the right-point arrow syntax is + // really: @>{optional label}>{optional label}> + // Collect parseNodes into labels. + for (let labelNum = 0; labelNum < 2; labelNum++) { + let inLabel = true; + for (let k = j + 1; k < rowNodes.length; k++) { + if (isLabelEnd(rowNodes[k], arrowChar)) { + inLabel = false; + j = k; + break; + } + if (isStartOfArrow(rowNodes[k])) { + throw new ParseError("Missing a " + arrowChar + + " character to complete a CD arrow.", rowNodes[k]); + } + + labels[labelNum].body.push(rowNodes[k]); + } + if (inLabel) { + // isLabelEnd never returned a true. + throw new ParseError("Missing a " + arrowChar + + " character to complete a CD arrow.", rowNodes[j]); + } + } + } else { + throw new ParseError(`Expected one of "<>AV=|." after @`, + rowNodes[j]); + } + + // Now join the arrow to its labels. + const arrow: AnyParseNode = cdArrow(arrowChar, labels, parser); + + // Wrap the arrow in ParseNode<"styling">. + // This is done to match parseArray() behavior. + const wrappedArrow: ParseNode<"styling"> = { + type: "styling", + body: [arrow], + mode: "math", + style: "display", // CD is always displaystyle. + resetFont: true, + }; + row.push(wrappedArrow); + // In CD's syntax, cells are implicit. That is, everything that + // is not an arrow gets collected into a cell. So create an empty + // cell now. It will collect upcoming parseNodes. + cell = newCell(); + } + } + if (i % 2 === 0) { + // Even-numbered rows consist of: cell, arrow, cell, arrow, ... cell + // The last cell is not yet pushed into `row`, so: + row.push(cell); + } else { + // Odd-numbered rows consist of: vert arrow, empty cell, ... vert arrow + // Remove the empty cell that was placed at the beginning of `row`. + row.shift(); + } + row = []; + body.push(row); + } + + // End row group + parser.gullet.endGroup(); + // End array group defining \\ + parser.gullet.endGroup(); + + // define column separation. + const cols = new Array(body[0].length).fill({ + type: "align", + align: "c", + pregap: 0.25, // CD package sets \enskip between columns. + postgap: 0.25, // So pre and post each get half an \enskip, i.e. 0.25em. + }); + + return { + type: "array", + mode: "math", + body, + arraystretch: 1, + addJot: true, + rowGaps: [null], + cols, + colSeparationType: "CD", + hLinesBeforeRow: new Array(body.length + 1).fill([]), + }; +} + +// The functions below are not available for general use. +// They are here only for internal use by the {CD} environment in placing labels +// next to vertical arrows. + +// We don't need any such functions for horizontal arrows because we can reuse +// the functionality that already exists for extensible arrows. + +defineFunction({ + type: "cdlabel", + names: ["\\\\cdleft", "\\\\cdright"], + props: { + numArgs: 1, + }, + handler({parser, funcName}, args) { + return { + type: "cdlabel", + mode: parser.mode, + side: funcName.slice(4), + label: args[0], + }; + }, + htmlBuilder(group, options) { + const newOptions = options.havingStyle(options.style.sup()); + const label = wrapFragment( + html.buildGroup(group.label, newOptions, options), options); + label.classes.push("cd-label-" + group.side); + label.style.bottom = makeEm(0.8 - label.depth); + // Zero out label height & depth, so vertical align of arrow is set + // by the arrow height, not by the label. + label.height = 0; + label.depth = 0; + return label; + }, + mathmlBuilder(group, options) { + let label = new MathNode("mrow", + [mml.buildGroup(group.label, options)]); + label = new MathNode("mpadded", [label]); + label.setAttribute("width", "0"); + if (group.side === "left") { + label.setAttribute("lspace", "-1width"); + } + // We have to guess at vertical alignment. We know the arrow is 1.8em tall, + // But we don't know the height or depth of the label. + label.setAttribute("voffset", "0.7em"); + label = new MathNode("mstyle", [label]); + label.setAttribute("displaystyle", "false"); + label.setAttribute("scriptlevel", "1"); + return label; + }, +}); + +defineFunction({ + type: "cdlabelparent", + names: ["\\\\cdparent"], + props: { + numArgs: 1, + }, + handler({parser}, args) { + return { + type: "cdlabelparent", + mode: parser.mode, + fragment: args[0], + }; + }, + htmlBuilder(group, options) { + // Wrap the vertical arrow and its labels. + // The parent gets position: relative. The child gets position: absolute. + // So CSS can locate the label correctly. + const parent = wrapFragment( + html.buildGroup(group.fragment, options), options + ); + parent.classes.push("cd-vert-arrow"); + return parent; + }, + mathmlBuilder(group, options) { + return new MathNode("mrow", + [mml.buildGroup(group.fragment, options)]); + }, +}); diff --git a/node_modules/react-katex/node_modules/katex/src/fontMetrics.ts b/node_modules/react-katex/node_modules/katex/src/fontMetrics.ts new file mode 100644 index 0000000..acd75c2 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/fontMetrics.ts @@ -0,0 +1,267 @@ +import {supportedCodepoint} from "./unicodeScripts"; + +import type {Mode} from "./types"; +import type {CharacterMetrics, CharacterMetricsTuple, FontMetrics} from "./types/fonts"; +// This map contains a mapping from font name and character code to character +// metrics, including height, depth, italic correction, and skew (kern from the +// character to the corresponding \skewchar) +// This map is generated via `make metrics`. It should not be changed manually. +import metricMap from "./fontMetricsData"; + +/** + * This file contains metrics regarding fonts and individual symbols. The sigma + * and xi variables, as well as the metricMap map contain data extracted from + * TeX, TeX font metrics, and the TTF files. These data are then exposed via the + * `metrics` variable and the getCharacterMetrics function. + */ + +// In TeX, there are actually three sets of dimensions, one for each of +// textstyle (size index 5 and higher: >=9pt), scriptstyle (size index 3 and 4: +// 7-8pt), and scriptscriptstyle (size index 1 and 2: 5-6pt). These are +// provided in the arrays below, in that order. +// +// The font metrics are stored in fonts cmsy10, cmsy7, and cmsy5 respectively. +// This was determined by running the following script: +// +// latex -interaction=nonstopmode \ +// '\documentclass{article}\usepackage{amsmath}\begin{document}' \ +// '$a$ \expandafter\show\the\textfont2' \ +// '\expandafter\show\the\scriptfont2' \ +// '\expandafter\show\the\scriptscriptfont2' \ +// '\stop' +// +// The metrics themselves were retrieved using the following commands: +// +// tftopl cmsy10 +// tftopl cmsy7 +// tftopl cmsy5 +// +// The output of each of these commands is quite lengthy. The only part we +// care about is the FONTDIMEN section. Each value is measured in EMs. +const sigmasAndXis: Record = { + slant: [0.250, 0.250, 0.250], // sigma1 + space: [0.000, 0.000, 0.000], // sigma2 + stretch: [0.000, 0.000, 0.000], // sigma3 + shrink: [0.000, 0.000, 0.000], // sigma4 + xHeight: [0.431, 0.431, 0.431], // sigma5 + quad: [1.000, 1.171, 1.472], // sigma6 + extraSpace: [0.000, 0.000, 0.000], // sigma7 + num1: [0.677, 0.732, 0.925], // sigma8 + num2: [0.394, 0.384, 0.387], // sigma9 + num3: [0.444, 0.471, 0.504], // sigma10 + denom1: [0.686, 0.752, 1.025], // sigma11 + denom2: [0.345, 0.344, 0.532], // sigma12 + sup1: [0.413, 0.503, 0.504], // sigma13 + sup2: [0.363, 0.431, 0.404], // sigma14 + sup3: [0.289, 0.286, 0.294], // sigma15 + sub1: [0.150, 0.143, 0.200], // sigma16 + sub2: [0.247, 0.286, 0.400], // sigma17 + supDrop: [0.386, 0.353, 0.494], // sigma18 + subDrop: [0.050, 0.071, 0.100], // sigma19 + delim1: [2.390, 1.700, 1.980], // sigma20 + delim2: [1.010, 1.157, 1.420], // sigma21 + axisHeight: [0.250, 0.250, 0.250], // sigma22 + + // These font metrics are extracted from TeX by using tftopl on cmex10.tfm; + // they correspond to the font parameters of the extension fonts (family 3). + // See the TeXbook, page 441. In AMSTeX, the extension fonts scale; to + // match cmex7, we'd use cmex7.tfm values for script and scriptscript + // values. + defaultRuleThickness: [0.04, 0.049, 0.049], // xi8; cmex7: 0.049 + bigOpSpacing1: [0.111, 0.111, 0.111], // xi9 + bigOpSpacing2: [0.166, 0.166, 0.166], // xi10 + bigOpSpacing3: [0.2, 0.2, 0.2], // xi11 + bigOpSpacing4: [0.6, 0.611, 0.611], // xi12; cmex7: 0.611 + bigOpSpacing5: [0.1, 0.143, 0.143], // xi13; cmex7: 0.143 + + // The \sqrt rule width is taken from the height of the surd character. + // Since we use the same font at all sizes, this thickness doesn't scale. + sqrtRuleThickness: [0.04, 0.04, 0.04], + + // This value determines how large a pt is, for metrics which are defined + // in terms of pts. + // This value is also used in katex.scss; if you change it make sure the + // values match. + ptPerEm: [10.0, 10.0, 10.0], + + // The space between adjacent `|` columns in an array definition. From + // `\showthe\doublerulesep` in LaTeX. Equals 2.0 / ptPerEm. + doubleRuleSep: [0.2, 0.2, 0.2], + + // The width of separator lines in {array} environments. From + // `\showthe\arrayrulewidth` in LaTeX. Equals 0.4 / ptPerEm. + arrayRuleWidth: [0.04, 0.04, 0.04], + + // Two values from LaTeX source2e: + fboxsep: [0.3, 0.3, 0.3], // 3 pt / ptPerEm + fboxrule: [0.04, 0.04, 0.04], // 0.4 pt / ptPerEm +}; + +// These are very rough approximations. We default to Times New Roman which +// should have Latin-1 and Cyrillic characters, but may not depending on the +// operating system. The metrics do not account for extra height from the +// accents. In the case of Cyrillic characters which have both ascenders and +// descenders we prefer approximations with ascenders, primarily to prevent +// the fraction bar or root line from intersecting the glyph. +// TODO(kevinb) allow union of multiple glyph metrics for better accuracy. +const extraCharacterMap: Record = { + // Latin-1 + 'Å': 'A', + 'Ð': 'D', + 'Þ': 'o', + 'å': 'a', + 'ð': 'd', + 'þ': 'o', + + // Cyrillic + 'А': 'A', + 'Б': 'B', + 'В': 'B', + 'Г': 'F', + 'Д': 'A', + 'Е': 'E', + 'Ж': 'K', + 'З': '3', + 'И': 'N', + 'Й': 'N', + 'К': 'K', + 'Л': 'N', + 'М': 'M', + 'Н': 'H', + 'О': 'O', + 'П': 'N', + 'Р': 'P', + 'С': 'C', + 'Т': 'T', + 'У': 'y', + 'Ф': 'O', + 'Х': 'X', + 'Ц': 'U', + 'Ч': 'h', + 'Ш': 'W', + 'Щ': 'W', + 'Ъ': 'B', + 'Ы': 'X', + 'Ь': 'B', + 'Э': '3', + 'Ю': 'X', + 'Я': 'R', + 'а': 'a', + 'б': 'b', + 'в': 'a', + 'г': 'r', + 'д': 'y', + 'е': 'e', + 'ж': 'm', + 'з': 'e', + 'и': 'n', + 'й': 'n', + 'к': 'n', + 'л': 'n', + 'м': 'm', + 'н': 'n', + 'о': 'o', + 'п': 'n', + 'р': 'p', + 'с': 'c', + 'т': 'o', + 'у': 'y', + 'ф': 'b', + 'х': 'x', + 'ц': 'n', + 'ч': 'n', + 'ш': 'w', + 'щ': 'w', + 'ъ': 'a', + 'ы': 'm', + 'ь': 'a', + 'э': 'e', + 'ю': 'm', + 'я': 'r', +}; + +/** + * This function adds new font metrics to default metricMap + * It can also override existing metrics + */ +export function setFontMetrics( + fontName: string, + metrics: {[key: string]: CharacterMetricsTuple} +) { + metricMap[fontName] = metrics; +} + +/** + * This function is a convenience function for looking up information in the + * metricMap table. It takes a character as a string, and a font. + * + * Note: the `width` property may be undefined if fontMetricsData.js wasn't + * built using `Make extended_metrics`. + */ +export function getCharacterMetrics( + character: string, + font: string, + mode: Mode, +): CharacterMetrics | null | undefined { + if (!metricMap[font]) { + throw new Error(`Font metrics not found for font: ${font}.`); + } + let ch = character.charCodeAt(0); + let metrics = metricMap[font][ch]; + if (!metrics && character[0] in extraCharacterMap) { + ch = extraCharacterMap[character[0]].charCodeAt(0); + metrics = metricMap[font][ch]; + } + + if (!metrics && mode === 'text') { + // We don't typically have font metrics for Asian scripts. + // But since we support them in text mode, we need to return + // some sort of metrics. + // So if the character is in a script we support but we + // don't have metrics for it, just use the metrics for + // the Latin capital letter M. This is close enough because + // we (currently) only care about the height of the glyph + // not its width. + if (supportedCodepoint(ch)) { + metrics = metricMap[font][77]; // 77 is the charcode for 'M' + } + } + + if (metrics) { + return { + depth: metrics[0], + height: metrics[1], + italic: metrics[2], + skew: metrics[3], + width: metrics[4], + }; + } +} + +type FontSizeIndex = 0 | 1 | 2; +const fontMetricsBySizeIndex: Partial> = {}; + +/** + * Get the font metrics for a given size. + */ +export function getGlobalMetrics(size: number): FontMetrics { + let sizeIndex: FontSizeIndex; + if (size >= 5) { + sizeIndex = 0; + } else if (size >= 3) { + sizeIndex = 1; + } else { + sizeIndex = 2; + } + if (!fontMetricsBySizeIndex[sizeIndex]) { + const metrics: FontMetrics = fontMetricsBySizeIndex[sizeIndex] = { + cssEmPerMu: sigmasAndXis.quad[sizeIndex] / 18, + }; + for (const key in sigmasAndXis) { + if (sigmasAndXis.hasOwnProperty(key)) { + metrics[key] = sigmasAndXis[key][sizeIndex]; + } + } + } + return fontMetricsBySizeIndex[sizeIndex]!; +} diff --git a/node_modules/react-katex/node_modules/katex/src/fontMetricsData.d.ts b/node_modules/react-katex/node_modules/katex/src/fontMetricsData.d.ts new file mode 100644 index 0000000..aa7dc66 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/fontMetricsData.d.ts @@ -0,0 +1,8 @@ +import type {CharacterMetricsTuple, FontName} from "./types/fonts"; + +type FontMetrics = Record; + +declare const fontMetricsData: Record & + Record; + +export default fontMetricsData; diff --git a/node_modules/react-katex/node_modules/katex/src/fontMetricsData.js b/node_modules/react-katex/node_modules/katex/src/fontMetricsData.js new file mode 100644 index 0000000..2557245 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/fontMetricsData.js @@ -0,0 +1,2077 @@ +// This file is GENERATED by buildMetrics.sh. DO NOT MODIFY. +export default { + "AMS-Regular": { + "32": [0, 0, 0, 0, 0.25], + "65": [0, 0.68889, 0, 0, 0.72222], + "66": [0, 0.68889, 0, 0, 0.66667], + "67": [0, 0.68889, 0, 0, 0.72222], + "68": [0, 0.68889, 0, 0, 0.72222], + "69": [0, 0.68889, 0, 0, 0.66667], + "70": [0, 0.68889, 0, 0, 0.61111], + "71": [0, 0.68889, 0, 0, 0.77778], + "72": [0, 0.68889, 0, 0, 0.77778], + "73": [0, 0.68889, 0, 0, 0.38889], + "74": [0.16667, 0.68889, 0, 0, 0.5], + "75": [0, 0.68889, 0, 0, 0.77778], + "76": [0, 0.68889, 0, 0, 0.66667], + "77": [0, 0.68889, 0, 0, 0.94445], + "78": [0, 0.68889, 0, 0, 0.72222], + "79": [0.16667, 0.68889, 0, 0, 0.77778], + "80": [0, 0.68889, 0, 0, 0.61111], + "81": [0.16667, 0.68889, 0, 0, 0.77778], + "82": [0, 0.68889, 0, 0, 0.72222], + "83": [0, 0.68889, 0, 0, 0.55556], + "84": [0, 0.68889, 0, 0, 0.66667], + "85": [0, 0.68889, 0, 0, 0.72222], + "86": [0, 0.68889, 0, 0, 0.72222], + "87": [0, 0.68889, 0, 0, 1.0], + "88": [0, 0.68889, 0, 0, 0.72222], + "89": [0, 0.68889, 0, 0, 0.72222], + "90": [0, 0.68889, 0, 0, 0.66667], + "107": [0, 0.68889, 0, 0, 0.55556], + "160": [0, 0, 0, 0, 0.25], + "165": [0, 0.675, 0.025, 0, 0.75], + "174": [0.15559, 0.69224, 0, 0, 0.94666], + "240": [0, 0.68889, 0, 0, 0.55556], + "295": [0, 0.68889, 0, 0, 0.54028], + "710": [0, 0.825, 0, 0, 2.33334], + "732": [0, 0.9, 0, 0, 2.33334], + "770": [0, 0.825, 0, 0, 2.33334], + "771": [0, 0.9, 0, 0, 2.33334], + "989": [0.08167, 0.58167, 0, 0, 0.77778], + "1008": [0, 0.43056, 0.04028, 0, 0.66667], + "8245": [0, 0.54986, 0, 0, 0.275], + "8463": [0, 0.68889, 0, 0, 0.54028], + "8487": [0, 0.68889, 0, 0, 0.72222], + "8498": [0, 0.68889, 0, 0, 0.55556], + "8502": [0, 0.68889, 0, 0, 0.66667], + "8503": [0, 0.68889, 0, 0, 0.44445], + "8504": [0, 0.68889, 0, 0, 0.66667], + "8513": [0, 0.68889, 0, 0, 0.63889], + "8592": [-0.03598, 0.46402, 0, 0, 0.5], + "8594": [-0.03598, 0.46402, 0, 0, 0.5], + "8602": [-0.13313, 0.36687, 0, 0, 1.0], + "8603": [-0.13313, 0.36687, 0, 0, 1.0], + "8606": [0.01354, 0.52239, 0, 0, 1.0], + "8608": [0.01354, 0.52239, 0, 0, 1.0], + "8610": [0.01354, 0.52239, 0, 0, 1.11111], + "8611": [0.01354, 0.52239, 0, 0, 1.11111], + "8619": [0, 0.54986, 0, 0, 1.0], + "8620": [0, 0.54986, 0, 0, 1.0], + "8621": [-0.13313, 0.37788, 0, 0, 1.38889], + "8622": [-0.13313, 0.36687, 0, 0, 1.0], + "8624": [0, 0.69224, 0, 0, 0.5], + "8625": [0, 0.69224, 0, 0, 0.5], + "8630": [0, 0.43056, 0, 0, 1.0], + "8631": [0, 0.43056, 0, 0, 1.0], + "8634": [0.08198, 0.58198, 0, 0, 0.77778], + "8635": [0.08198, 0.58198, 0, 0, 0.77778], + "8638": [0.19444, 0.69224, 0, 0, 0.41667], + "8639": [0.19444, 0.69224, 0, 0, 0.41667], + "8642": [0.19444, 0.69224, 0, 0, 0.41667], + "8643": [0.19444, 0.69224, 0, 0, 0.41667], + "8644": [0.1808, 0.675, 0, 0, 1.0], + "8646": [0.1808, 0.675, 0, 0, 1.0], + "8647": [0.1808, 0.675, 0, 0, 1.0], + "8648": [0.19444, 0.69224, 0, 0, 0.83334], + "8649": [0.1808, 0.675, 0, 0, 1.0], + "8650": [0.19444, 0.69224, 0, 0, 0.83334], + "8651": [0.01354, 0.52239, 0, 0, 1.0], + "8652": [0.01354, 0.52239, 0, 0, 1.0], + "8653": [-0.13313, 0.36687, 0, 0, 1.0], + "8654": [-0.13313, 0.36687, 0, 0, 1.0], + "8655": [-0.13313, 0.36687, 0, 0, 1.0], + "8666": [0.13667, 0.63667, 0, 0, 1.0], + "8667": [0.13667, 0.63667, 0, 0, 1.0], + "8669": [-0.13313, 0.37788, 0, 0, 1.0], + "8672": [-0.064, 0.437, 0, 0, 1.334], + "8674": [-0.064, 0.437, 0, 0, 1.334], + "8705": [0, 0.825, 0, 0, 0.5], + "8708": [0, 0.68889, 0, 0, 0.55556], + "8709": [0.08167, 0.58167, 0, 0, 0.77778], + "8717": [0, 0.43056, 0, 0, 0.42917], + "8722": [-0.03598, 0.46402, 0, 0, 0.5], + "8724": [0.08198, 0.69224, 0, 0, 0.77778], + "8726": [0.08167, 0.58167, 0, 0, 0.77778], + "8733": [0, 0.69224, 0, 0, 0.77778], + "8736": [0, 0.69224, 0, 0, 0.72222], + "8737": [0, 0.69224, 0, 0, 0.72222], + "8738": [0.03517, 0.52239, 0, 0, 0.72222], + "8739": [0.08167, 0.58167, 0, 0, 0.22222], + "8740": [0.25142, 0.74111, 0, 0, 0.27778], + "8741": [0.08167, 0.58167, 0, 0, 0.38889], + "8742": [0.25142, 0.74111, 0, 0, 0.5], + "8756": [0, 0.69224, 0, 0, 0.66667], + "8757": [0, 0.69224, 0, 0, 0.66667], + "8764": [-0.13313, 0.36687, 0, 0, 0.77778], + "8765": [-0.13313, 0.37788, 0, 0, 0.77778], + "8769": [-0.13313, 0.36687, 0, 0, 0.77778], + "8770": [-0.03625, 0.46375, 0, 0, 0.77778], + "8774": [0.30274, 0.79383, 0, 0, 0.77778], + "8776": [-0.01688, 0.48312, 0, 0, 0.77778], + "8778": [0.08167, 0.58167, 0, 0, 0.77778], + "8782": [0.06062, 0.54986, 0, 0, 0.77778], + "8783": [0.06062, 0.54986, 0, 0, 0.77778], + "8785": [0.08198, 0.58198, 0, 0, 0.77778], + "8786": [0.08198, 0.58198, 0, 0, 0.77778], + "8787": [0.08198, 0.58198, 0, 0, 0.77778], + "8790": [0, 0.69224, 0, 0, 0.77778], + "8791": [0.22958, 0.72958, 0, 0, 0.77778], + "8796": [0.08198, 0.91667, 0, 0, 0.77778], + "8806": [0.25583, 0.75583, 0, 0, 0.77778], + "8807": [0.25583, 0.75583, 0, 0, 0.77778], + "8808": [0.25142, 0.75726, 0, 0, 0.77778], + "8809": [0.25142, 0.75726, 0, 0, 0.77778], + "8812": [0.25583, 0.75583, 0, 0, 0.5], + "8814": [0.20576, 0.70576, 0, 0, 0.77778], + "8815": [0.20576, 0.70576, 0, 0, 0.77778], + "8816": [0.30274, 0.79383, 0, 0, 0.77778], + "8817": [0.30274, 0.79383, 0, 0, 0.77778], + "8818": [0.22958, 0.72958, 0, 0, 0.77778], + "8819": [0.22958, 0.72958, 0, 0, 0.77778], + "8822": [0.1808, 0.675, 0, 0, 0.77778], + "8823": [0.1808, 0.675, 0, 0, 0.77778], + "8828": [0.13667, 0.63667, 0, 0, 0.77778], + "8829": [0.13667, 0.63667, 0, 0, 0.77778], + "8830": [0.22958, 0.72958, 0, 0, 0.77778], + "8831": [0.22958, 0.72958, 0, 0, 0.77778], + "8832": [0.20576, 0.70576, 0, 0, 0.77778], + "8833": [0.20576, 0.70576, 0, 0, 0.77778], + "8840": [0.30274, 0.79383, 0, 0, 0.77778], + "8841": [0.30274, 0.79383, 0, 0, 0.77778], + "8842": [0.13597, 0.63597, 0, 0, 0.77778], + "8843": [0.13597, 0.63597, 0, 0, 0.77778], + "8847": [0.03517, 0.54986, 0, 0, 0.77778], + "8848": [0.03517, 0.54986, 0, 0, 0.77778], + "8858": [0.08198, 0.58198, 0, 0, 0.77778], + "8859": [0.08198, 0.58198, 0, 0, 0.77778], + "8861": [0.08198, 0.58198, 0, 0, 0.77778], + "8862": [0, 0.675, 0, 0, 0.77778], + "8863": [0, 0.675, 0, 0, 0.77778], + "8864": [0, 0.675, 0, 0, 0.77778], + "8865": [0, 0.675, 0, 0, 0.77778], + "8872": [0, 0.69224, 0, 0, 0.61111], + "8873": [0, 0.69224, 0, 0, 0.72222], + "8874": [0, 0.69224, 0, 0, 0.88889], + "8876": [0, 0.68889, 0, 0, 0.61111], + "8877": [0, 0.68889, 0, 0, 0.61111], + "8878": [0, 0.68889, 0, 0, 0.72222], + "8879": [0, 0.68889, 0, 0, 0.72222], + "8882": [0.03517, 0.54986, 0, 0, 0.77778], + "8883": [0.03517, 0.54986, 0, 0, 0.77778], + "8884": [0.13667, 0.63667, 0, 0, 0.77778], + "8885": [0.13667, 0.63667, 0, 0, 0.77778], + "8888": [0, 0.54986, 0, 0, 1.11111], + "8890": [0.19444, 0.43056, 0, 0, 0.55556], + "8891": [0.19444, 0.69224, 0, 0, 0.61111], + "8892": [0.19444, 0.69224, 0, 0, 0.61111], + "8901": [0, 0.54986, 0, 0, 0.27778], + "8903": [0.08167, 0.58167, 0, 0, 0.77778], + "8905": [0.08167, 0.58167, 0, 0, 0.77778], + "8906": [0.08167, 0.58167, 0, 0, 0.77778], + "8907": [0, 0.69224, 0, 0, 0.77778], + "8908": [0, 0.69224, 0, 0, 0.77778], + "8909": [-0.03598, 0.46402, 0, 0, 0.77778], + "8910": [0, 0.54986, 0, 0, 0.76042], + "8911": [0, 0.54986, 0, 0, 0.76042], + "8912": [0.03517, 0.54986, 0, 0, 0.77778], + "8913": [0.03517, 0.54986, 0, 0, 0.77778], + "8914": [0, 0.54986, 0, 0, 0.66667], + "8915": [0, 0.54986, 0, 0, 0.66667], + "8916": [0, 0.69224, 0, 0, 0.66667], + "8918": [0.0391, 0.5391, 0, 0, 0.77778], + "8919": [0.0391, 0.5391, 0, 0, 0.77778], + "8920": [0.03517, 0.54986, 0, 0, 1.33334], + "8921": [0.03517, 0.54986, 0, 0, 1.33334], + "8922": [0.38569, 0.88569, 0, 0, 0.77778], + "8923": [0.38569, 0.88569, 0, 0, 0.77778], + "8926": [0.13667, 0.63667, 0, 0, 0.77778], + "8927": [0.13667, 0.63667, 0, 0, 0.77778], + "8928": [0.30274, 0.79383, 0, 0, 0.77778], + "8929": [0.30274, 0.79383, 0, 0, 0.77778], + "8934": [0.23222, 0.74111, 0, 0, 0.77778], + "8935": [0.23222, 0.74111, 0, 0, 0.77778], + "8936": [0.23222, 0.74111, 0, 0, 0.77778], + "8937": [0.23222, 0.74111, 0, 0, 0.77778], + "8938": [0.20576, 0.70576, 0, 0, 0.77778], + "8939": [0.20576, 0.70576, 0, 0, 0.77778], + "8940": [0.30274, 0.79383, 0, 0, 0.77778], + "8941": [0.30274, 0.79383, 0, 0, 0.77778], + "8994": [0.19444, 0.69224, 0, 0, 0.77778], + "8995": [0.19444, 0.69224, 0, 0, 0.77778], + "9416": [0.15559, 0.69224, 0, 0, 0.90222], + "9484": [0, 0.69224, 0, 0, 0.5], + "9488": [0, 0.69224, 0, 0, 0.5], + "9492": [0, 0.37788, 0, 0, 0.5], + "9496": [0, 0.37788, 0, 0, 0.5], + "9585": [0.19444, 0.68889, 0, 0, 0.88889], + "9586": [0.19444, 0.74111, 0, 0, 0.88889], + "9632": [0, 0.675, 0, 0, 0.77778], + "9633": [0, 0.675, 0, 0, 0.77778], + "9650": [0, 0.54986, 0, 0, 0.72222], + "9651": [0, 0.54986, 0, 0, 0.72222], + "9654": [0.03517, 0.54986, 0, 0, 0.77778], + "9660": [0, 0.54986, 0, 0, 0.72222], + "9661": [0, 0.54986, 0, 0, 0.72222], + "9664": [0.03517, 0.54986, 0, 0, 0.77778], + "9674": [0.11111, 0.69224, 0, 0, 0.66667], + "9733": [0.19444, 0.69224, 0, 0, 0.94445], + "10003": [0, 0.69224, 0, 0, 0.83334], + "10016": [0, 0.69224, 0, 0, 0.83334], + "10731": [0.11111, 0.69224, 0, 0, 0.66667], + "10846": [0.19444, 0.75583, 0, 0, 0.61111], + "10877": [0.13667, 0.63667, 0, 0, 0.77778], + "10878": [0.13667, 0.63667, 0, 0, 0.77778], + "10885": [0.25583, 0.75583, 0, 0, 0.77778], + "10886": [0.25583, 0.75583, 0, 0, 0.77778], + "10887": [0.13597, 0.63597, 0, 0, 0.77778], + "10888": [0.13597, 0.63597, 0, 0, 0.77778], + "10889": [0.26167, 0.75726, 0, 0, 0.77778], + "10890": [0.26167, 0.75726, 0, 0, 0.77778], + "10891": [0.48256, 0.98256, 0, 0, 0.77778], + "10892": [0.48256, 0.98256, 0, 0, 0.77778], + "10901": [0.13667, 0.63667, 0, 0, 0.77778], + "10902": [0.13667, 0.63667, 0, 0, 0.77778], + "10933": [0.25142, 0.75726, 0, 0, 0.77778], + "10934": [0.25142, 0.75726, 0, 0, 0.77778], + "10935": [0.26167, 0.75726, 0, 0, 0.77778], + "10936": [0.26167, 0.75726, 0, 0, 0.77778], + "10937": [0.26167, 0.75726, 0, 0, 0.77778], + "10938": [0.26167, 0.75726, 0, 0, 0.77778], + "10949": [0.25583, 0.75583, 0, 0, 0.77778], + "10950": [0.25583, 0.75583, 0, 0, 0.77778], + "10955": [0.28481, 0.79383, 0, 0, 0.77778], + "10956": [0.28481, 0.79383, 0, 0, 0.77778], + "57350": [0.08167, 0.58167, 0, 0, 0.22222], + "57351": [0.08167, 0.58167, 0, 0, 0.38889], + "57352": [0.08167, 0.58167, 0, 0, 0.77778], + "57353": [0, 0.43056, 0.04028, 0, 0.66667], + "57356": [0.25142, 0.75726, 0, 0, 0.77778], + "57357": [0.25142, 0.75726, 0, 0, 0.77778], + "57358": [0.41951, 0.91951, 0, 0, 0.77778], + "57359": [0.30274, 0.79383, 0, 0, 0.77778], + "57360": [0.30274, 0.79383, 0, 0, 0.77778], + "57361": [0.41951, 0.91951, 0, 0, 0.77778], + "57366": [0.25142, 0.75726, 0, 0, 0.77778], + "57367": [0.25142, 0.75726, 0, 0, 0.77778], + "57368": [0.25142, 0.75726, 0, 0, 0.77778], + "57369": [0.25142, 0.75726, 0, 0, 0.77778], + "57370": [0.13597, 0.63597, 0, 0, 0.77778], + "57371": [0.13597, 0.63597, 0, 0, 0.77778], + }, + "Caligraphic-Regular": { + "32": [0, 0, 0, 0, 0.25], + "65": [0, 0.68333, 0, 0.19445, 0.79847], + "66": [0, 0.68333, 0.03041, 0.13889, 0.65681], + "67": [0, 0.68333, 0.05834, 0.13889, 0.52653], + "68": [0, 0.68333, 0.02778, 0.08334, 0.77139], + "69": [0, 0.68333, 0.08944, 0.11111, 0.52778], + "70": [0, 0.68333, 0.09931, 0.11111, 0.71875], + "71": [0.09722, 0.68333, 0.0593, 0.11111, 0.59487], + "72": [0, 0.68333, 0.00965, 0.11111, 0.84452], + "73": [0, 0.68333, 0.07382, 0, 0.54452], + "74": [0.09722, 0.68333, 0.18472, 0.16667, 0.67778], + "75": [0, 0.68333, 0.01445, 0.05556, 0.76195], + "76": [0, 0.68333, 0, 0.13889, 0.68972], + "77": [0, 0.68333, 0, 0.13889, 1.2009], + "78": [0, 0.68333, 0.14736, 0.08334, 0.82049], + "79": [0, 0.68333, 0.02778, 0.11111, 0.79611], + "80": [0, 0.68333, 0.08222, 0.08334, 0.69556], + "81": [0.09722, 0.68333, 0, 0.11111, 0.81667], + "82": [0, 0.68333, 0, 0.08334, 0.8475], + "83": [0, 0.68333, 0.075, 0.13889, 0.60556], + "84": [0, 0.68333, 0.25417, 0, 0.54464], + "85": [0, 0.68333, 0.09931, 0.08334, 0.62583], + "86": [0, 0.68333, 0.08222, 0, 0.61278], + "87": [0, 0.68333, 0.08222, 0.08334, 0.98778], + "88": [0, 0.68333, 0.14643, 0.13889, 0.7133], + "89": [0.09722, 0.68333, 0.08222, 0.08334, 0.66834], + "90": [0, 0.68333, 0.07944, 0.13889, 0.72473], + "160": [0, 0, 0, 0, 0.25], + }, + "Fraktur-Regular": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69141, 0, 0, 0.29574], + "34": [0, 0.69141, 0, 0, 0.21471], + "38": [0, 0.69141, 0, 0, 0.73786], + "39": [0, 0.69141, 0, 0, 0.21201], + "40": [0.24982, 0.74947, 0, 0, 0.38865], + "41": [0.24982, 0.74947, 0, 0, 0.38865], + "42": [0, 0.62119, 0, 0, 0.27764], + "43": [0.08319, 0.58283, 0, 0, 0.75623], + "44": [0, 0.10803, 0, 0, 0.27764], + "45": [0.08319, 0.58283, 0, 0, 0.75623], + "46": [0, 0.10803, 0, 0, 0.27764], + "47": [0.24982, 0.74947, 0, 0, 0.50181], + "48": [0, 0.47534, 0, 0, 0.50181], + "49": [0, 0.47534, 0, 0, 0.50181], + "50": [0, 0.47534, 0, 0, 0.50181], + "51": [0.18906, 0.47534, 0, 0, 0.50181], + "52": [0.18906, 0.47534, 0, 0, 0.50181], + "53": [0.18906, 0.47534, 0, 0, 0.50181], + "54": [0, 0.69141, 0, 0, 0.50181], + "55": [0.18906, 0.47534, 0, 0, 0.50181], + "56": [0, 0.69141, 0, 0, 0.50181], + "57": [0.18906, 0.47534, 0, 0, 0.50181], + "58": [0, 0.47534, 0, 0, 0.21606], + "59": [0.12604, 0.47534, 0, 0, 0.21606], + "61": [-0.13099, 0.36866, 0, 0, 0.75623], + "63": [0, 0.69141, 0, 0, 0.36245], + "65": [0, 0.69141, 0, 0, 0.7176], + "66": [0, 0.69141, 0, 0, 0.88397], + "67": [0, 0.69141, 0, 0, 0.61254], + "68": [0, 0.69141, 0, 0, 0.83158], + "69": [0, 0.69141, 0, 0, 0.66278], + "70": [0.12604, 0.69141, 0, 0, 0.61119], + "71": [0, 0.69141, 0, 0, 0.78539], + "72": [0.06302, 0.69141, 0, 0, 0.7203], + "73": [0, 0.69141, 0, 0, 0.55448], + "74": [0.12604, 0.69141, 0, 0, 0.55231], + "75": [0, 0.69141, 0, 0, 0.66845], + "76": [0, 0.69141, 0, 0, 0.66602], + "77": [0, 0.69141, 0, 0, 1.04953], + "78": [0, 0.69141, 0, 0, 0.83212], + "79": [0, 0.69141, 0, 0, 0.82699], + "80": [0.18906, 0.69141, 0, 0, 0.82753], + "81": [0.03781, 0.69141, 0, 0, 0.82699], + "82": [0, 0.69141, 0, 0, 0.82807], + "83": [0, 0.69141, 0, 0, 0.82861], + "84": [0, 0.69141, 0, 0, 0.66899], + "85": [0, 0.69141, 0, 0, 0.64576], + "86": [0, 0.69141, 0, 0, 0.83131], + "87": [0, 0.69141, 0, 0, 1.04602], + "88": [0, 0.69141, 0, 0, 0.71922], + "89": [0.18906, 0.69141, 0, 0, 0.83293], + "90": [0.12604, 0.69141, 0, 0, 0.60201], + "91": [0.24982, 0.74947, 0, 0, 0.27764], + "93": [0.24982, 0.74947, 0, 0, 0.27764], + "94": [0, 0.69141, 0, 0, 0.49965], + "97": [0, 0.47534, 0, 0, 0.50046], + "98": [0, 0.69141, 0, 0, 0.51315], + "99": [0, 0.47534, 0, 0, 0.38946], + "100": [0, 0.62119, 0, 0, 0.49857], + "101": [0, 0.47534, 0, 0, 0.40053], + "102": [0.18906, 0.69141, 0, 0, 0.32626], + "103": [0.18906, 0.47534, 0, 0, 0.5037], + "104": [0.18906, 0.69141, 0, 0, 0.52126], + "105": [0, 0.69141, 0, 0, 0.27899], + "106": [0, 0.69141, 0, 0, 0.28088], + "107": [0, 0.69141, 0, 0, 0.38946], + "108": [0, 0.69141, 0, 0, 0.27953], + "109": [0, 0.47534, 0, 0, 0.76676], + "110": [0, 0.47534, 0, 0, 0.52666], + "111": [0, 0.47534, 0, 0, 0.48885], + "112": [0.18906, 0.52396, 0, 0, 0.50046], + "113": [0.18906, 0.47534, 0, 0, 0.48912], + "114": [0, 0.47534, 0, 0, 0.38919], + "115": [0, 0.47534, 0, 0, 0.44266], + "116": [0, 0.62119, 0, 0, 0.33301], + "117": [0, 0.47534, 0, 0, 0.5172], + "118": [0, 0.52396, 0, 0, 0.5118], + "119": [0, 0.52396, 0, 0, 0.77351], + "120": [0.18906, 0.47534, 0, 0, 0.38865], + "121": [0.18906, 0.47534, 0, 0, 0.49884], + "122": [0.18906, 0.47534, 0, 0, 0.39054], + "160": [0, 0, 0, 0, 0.25], + "8216": [0, 0.69141, 0, 0, 0.21471], + "8217": [0, 0.69141, 0, 0, 0.21471], + "58112": [0, 0.62119, 0, 0, 0.49749], + "58113": [0, 0.62119, 0, 0, 0.4983], + "58114": [0.18906, 0.69141, 0, 0, 0.33328], + "58115": [0.18906, 0.69141, 0, 0, 0.32923], + "58116": [0.18906, 0.47534, 0, 0, 0.50343], + "58117": [0, 0.69141, 0, 0, 0.33301], + "58118": [0, 0.62119, 0, 0, 0.33409], + "58119": [0, 0.47534, 0, 0, 0.50073], + }, + "Main-Bold": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0, 0, 0.35], + "34": [0, 0.69444, 0, 0, 0.60278], + "35": [0.19444, 0.69444, 0, 0, 0.95833], + "36": [0.05556, 0.75, 0, 0, 0.575], + "37": [0.05556, 0.75, 0, 0, 0.95833], + "38": [0, 0.69444, 0, 0, 0.89444], + "39": [0, 0.69444, 0, 0, 0.31944], + "40": [0.25, 0.75, 0, 0, 0.44722], + "41": [0.25, 0.75, 0, 0, 0.44722], + "42": [0, 0.75, 0, 0, 0.575], + "43": [0.13333, 0.63333, 0, 0, 0.89444], + "44": [0.19444, 0.15556, 0, 0, 0.31944], + "45": [0, 0.44444, 0, 0, 0.38333], + "46": [0, 0.15556, 0, 0, 0.31944], + "47": [0.25, 0.75, 0, 0, 0.575], + "48": [0, 0.64444, 0, 0, 0.575], + "49": [0, 0.64444, 0, 0, 0.575], + "50": [0, 0.64444, 0, 0, 0.575], + "51": [0, 0.64444, 0, 0, 0.575], + "52": [0, 0.64444, 0, 0, 0.575], + "53": [0, 0.64444, 0, 0, 0.575], + "54": [0, 0.64444, 0, 0, 0.575], + "55": [0, 0.64444, 0, 0, 0.575], + "56": [0, 0.64444, 0, 0, 0.575], + "57": [0, 0.64444, 0, 0, 0.575], + "58": [0, 0.44444, 0, 0, 0.31944], + "59": [0.19444, 0.44444, 0, 0, 0.31944], + "60": [0.08556, 0.58556, 0, 0, 0.89444], + "61": [-0.10889, 0.39111, 0, 0, 0.89444], + "62": [0.08556, 0.58556, 0, 0, 0.89444], + "63": [0, 0.69444, 0, 0, 0.54305], + "64": [0, 0.69444, 0, 0, 0.89444], + "65": [0, 0.68611, 0, 0, 0.86944], + "66": [0, 0.68611, 0, 0, 0.81805], + "67": [0, 0.68611, 0, 0, 0.83055], + "68": [0, 0.68611, 0, 0, 0.88194], + "69": [0, 0.68611, 0, 0, 0.75555], + "70": [0, 0.68611, 0, 0, 0.72361], + "71": [0, 0.68611, 0, 0, 0.90416], + "72": [0, 0.68611, 0, 0, 0.9], + "73": [0, 0.68611, 0, 0, 0.43611], + "74": [0, 0.68611, 0, 0, 0.59444], + "75": [0, 0.68611, 0, 0, 0.90138], + "76": [0, 0.68611, 0, 0, 0.69166], + "77": [0, 0.68611, 0, 0, 1.09166], + "78": [0, 0.68611, 0, 0, 0.9], + "79": [0, 0.68611, 0, 0, 0.86388], + "80": [0, 0.68611, 0, 0, 0.78611], + "81": [0.19444, 0.68611, 0, 0, 0.86388], + "82": [0, 0.68611, 0, 0, 0.8625], + "83": [0, 0.68611, 0, 0, 0.63889], + "84": [0, 0.68611, 0, 0, 0.8], + "85": [0, 0.68611, 0, 0, 0.88472], + "86": [0, 0.68611, 0.01597, 0, 0.86944], + "87": [0, 0.68611, 0.01597, 0, 1.18888], + "88": [0, 0.68611, 0, 0, 0.86944], + "89": [0, 0.68611, 0.02875, 0, 0.86944], + "90": [0, 0.68611, 0, 0, 0.70277], + "91": [0.25, 0.75, 0, 0, 0.31944], + "92": [0.25, 0.75, 0, 0, 0.575], + "93": [0.25, 0.75, 0, 0, 0.31944], + "94": [0, 0.69444, 0, 0, 0.575], + "95": [0.31, 0.13444, 0.03194, 0, 0.575], + "97": [0, 0.44444, 0, 0, 0.55902], + "98": [0, 0.69444, 0, 0, 0.63889], + "99": [0, 0.44444, 0, 0, 0.51111], + "100": [0, 0.69444, 0, 0, 0.63889], + "101": [0, 0.44444, 0, 0, 0.52708], + "102": [0, 0.69444, 0.10903, 0, 0.35139], + "103": [0.19444, 0.44444, 0.01597, 0, 0.575], + "104": [0, 0.69444, 0, 0, 0.63889], + "105": [0, 0.69444, 0, 0, 0.31944], + "106": [0.19444, 0.69444, 0, 0, 0.35139], + "107": [0, 0.69444, 0, 0, 0.60694], + "108": [0, 0.69444, 0, 0, 0.31944], + "109": [0, 0.44444, 0, 0, 0.95833], + "110": [0, 0.44444, 0, 0, 0.63889], + "111": [0, 0.44444, 0, 0, 0.575], + "112": [0.19444, 0.44444, 0, 0, 0.63889], + "113": [0.19444, 0.44444, 0, 0, 0.60694], + "114": [0, 0.44444, 0, 0, 0.47361], + "115": [0, 0.44444, 0, 0, 0.45361], + "116": [0, 0.63492, 0, 0, 0.44722], + "117": [0, 0.44444, 0, 0, 0.63889], + "118": [0, 0.44444, 0.01597, 0, 0.60694], + "119": [0, 0.44444, 0.01597, 0, 0.83055], + "120": [0, 0.44444, 0, 0, 0.60694], + "121": [0.19444, 0.44444, 0.01597, 0, 0.60694], + "122": [0, 0.44444, 0, 0, 0.51111], + "123": [0.25, 0.75, 0, 0, 0.575], + "124": [0.25, 0.75, 0, 0, 0.31944], + "125": [0.25, 0.75, 0, 0, 0.575], + "126": [0.35, 0.34444, 0, 0, 0.575], + "160": [0, 0, 0, 0, 0.25], + "163": [0, 0.69444, 0, 0, 0.86853], + "168": [0, 0.69444, 0, 0, 0.575], + "172": [0, 0.44444, 0, 0, 0.76666], + "176": [0, 0.69444, 0, 0, 0.86944], + "177": [0.13333, 0.63333, 0, 0, 0.89444], + "184": [0.17014, 0, 0, 0, 0.51111], + "198": [0, 0.68611, 0, 0, 1.04166], + "215": [0.13333, 0.63333, 0, 0, 0.89444], + "216": [0.04861, 0.73472, 0, 0, 0.89444], + "223": [0, 0.69444, 0, 0, 0.59722], + "230": [0, 0.44444, 0, 0, 0.83055], + "247": [0.13333, 0.63333, 0, 0, 0.89444], + "248": [0.09722, 0.54167, 0, 0, 0.575], + "305": [0, 0.44444, 0, 0, 0.31944], + "338": [0, 0.68611, 0, 0, 1.16944], + "339": [0, 0.44444, 0, 0, 0.89444], + "567": [0.19444, 0.44444, 0, 0, 0.35139], + "710": [0, 0.69444, 0, 0, 0.575], + "711": [0, 0.63194, 0, 0, 0.575], + "713": [0, 0.59611, 0, 0, 0.575], + "714": [0, 0.69444, 0, 0, 0.575], + "715": [0, 0.69444, 0, 0, 0.575], + "728": [0, 0.69444, 0, 0, 0.575], + "729": [0, 0.69444, 0, 0, 0.31944], + "730": [0, 0.69444, 0, 0, 0.86944], + "732": [0, 0.69444, 0, 0, 0.575], + "733": [0, 0.69444, 0, 0, 0.575], + "915": [0, 0.68611, 0, 0, 0.69166], + "916": [0, 0.68611, 0, 0, 0.95833], + "920": [0, 0.68611, 0, 0, 0.89444], + "923": [0, 0.68611, 0, 0, 0.80555], + "926": [0, 0.68611, 0, 0, 0.76666], + "928": [0, 0.68611, 0, 0, 0.9], + "931": [0, 0.68611, 0, 0, 0.83055], + "933": [0, 0.68611, 0, 0, 0.89444], + "934": [0, 0.68611, 0, 0, 0.83055], + "936": [0, 0.68611, 0, 0, 0.89444], + "937": [0, 0.68611, 0, 0, 0.83055], + "8211": [0, 0.44444, 0.03194, 0, 0.575], + "8212": [0, 0.44444, 0.03194, 0, 1.14999], + "8216": [0, 0.69444, 0, 0, 0.31944], + "8217": [0, 0.69444, 0, 0, 0.31944], + "8220": [0, 0.69444, 0, 0, 0.60278], + "8221": [0, 0.69444, 0, 0, 0.60278], + "8224": [0.19444, 0.69444, 0, 0, 0.51111], + "8225": [0.19444, 0.69444, 0, 0, 0.51111], + "8242": [0, 0.55556, 0, 0, 0.34444], + "8407": [0, 0.72444, 0.15486, 0, 0.575], + "8463": [0, 0.69444, 0, 0, 0.66759], + "8465": [0, 0.69444, 0, 0, 0.83055], + "8467": [0, 0.69444, 0, 0, 0.47361], + "8472": [0.19444, 0.44444, 0, 0, 0.74027], + "8476": [0, 0.69444, 0, 0, 0.83055], + "8501": [0, 0.69444, 0, 0, 0.70277], + "8592": [-0.10889, 0.39111, 0, 0, 1.14999], + "8593": [0.19444, 0.69444, 0, 0, 0.575], + "8594": [-0.10889, 0.39111, 0, 0, 1.14999], + "8595": [0.19444, 0.69444, 0, 0, 0.575], + "8596": [-0.10889, 0.39111, 0, 0, 1.14999], + "8597": [0.25, 0.75, 0, 0, 0.575], + "8598": [0.19444, 0.69444, 0, 0, 1.14999], + "8599": [0.19444, 0.69444, 0, 0, 1.14999], + "8600": [0.19444, 0.69444, 0, 0, 1.14999], + "8601": [0.19444, 0.69444, 0, 0, 1.14999], + "8636": [-0.10889, 0.39111, 0, 0, 1.14999], + "8637": [-0.10889, 0.39111, 0, 0, 1.14999], + "8640": [-0.10889, 0.39111, 0, 0, 1.14999], + "8641": [-0.10889, 0.39111, 0, 0, 1.14999], + "8656": [-0.10889, 0.39111, 0, 0, 1.14999], + "8657": [0.19444, 0.69444, 0, 0, 0.70277], + "8658": [-0.10889, 0.39111, 0, 0, 1.14999], + "8659": [0.19444, 0.69444, 0, 0, 0.70277], + "8660": [-0.10889, 0.39111, 0, 0, 1.14999], + "8661": [0.25, 0.75, 0, 0, 0.70277], + "8704": [0, 0.69444, 0, 0, 0.63889], + "8706": [0, 0.69444, 0.06389, 0, 0.62847], + "8707": [0, 0.69444, 0, 0, 0.63889], + "8709": [0.05556, 0.75, 0, 0, 0.575], + "8711": [0, 0.68611, 0, 0, 0.95833], + "8712": [0.08556, 0.58556, 0, 0, 0.76666], + "8715": [0.08556, 0.58556, 0, 0, 0.76666], + "8722": [0.13333, 0.63333, 0, 0, 0.89444], + "8723": [0.13333, 0.63333, 0, 0, 0.89444], + "8725": [0.25, 0.75, 0, 0, 0.575], + "8726": [0.25, 0.75, 0, 0, 0.575], + "8727": [-0.02778, 0.47222, 0, 0, 0.575], + "8728": [-0.02639, 0.47361, 0, 0, 0.575], + "8729": [-0.02639, 0.47361, 0, 0, 0.575], + "8730": [0.18, 0.82, 0, 0, 0.95833], + "8733": [0, 0.44444, 0, 0, 0.89444], + "8734": [0, 0.44444, 0, 0, 1.14999], + "8736": [0, 0.69224, 0, 0, 0.72222], + "8739": [0.25, 0.75, 0, 0, 0.31944], + "8741": [0.25, 0.75, 0, 0, 0.575], + "8743": [0, 0.55556, 0, 0, 0.76666], + "8744": [0, 0.55556, 0, 0, 0.76666], + "8745": [0, 0.55556, 0, 0, 0.76666], + "8746": [0, 0.55556, 0, 0, 0.76666], + "8747": [0.19444, 0.69444, 0.12778, 0, 0.56875], + "8764": [-0.10889, 0.39111, 0, 0, 0.89444], + "8768": [0.19444, 0.69444, 0, 0, 0.31944], + "8771": [0.00222, 0.50222, 0, 0, 0.89444], + "8773": [0.027, 0.638, 0, 0, 0.894], + "8776": [0.02444, 0.52444, 0, 0, 0.89444], + "8781": [0.00222, 0.50222, 0, 0, 0.89444], + "8801": [0.00222, 0.50222, 0, 0, 0.89444], + "8804": [0.19667, 0.69667, 0, 0, 0.89444], + "8805": [0.19667, 0.69667, 0, 0, 0.89444], + "8810": [0.08556, 0.58556, 0, 0, 1.14999], + "8811": [0.08556, 0.58556, 0, 0, 1.14999], + "8826": [0.08556, 0.58556, 0, 0, 0.89444], + "8827": [0.08556, 0.58556, 0, 0, 0.89444], + "8834": [0.08556, 0.58556, 0, 0, 0.89444], + "8835": [0.08556, 0.58556, 0, 0, 0.89444], + "8838": [0.19667, 0.69667, 0, 0, 0.89444], + "8839": [0.19667, 0.69667, 0, 0, 0.89444], + "8846": [0, 0.55556, 0, 0, 0.76666], + "8849": [0.19667, 0.69667, 0, 0, 0.89444], + "8850": [0.19667, 0.69667, 0, 0, 0.89444], + "8851": [0, 0.55556, 0, 0, 0.76666], + "8852": [0, 0.55556, 0, 0, 0.76666], + "8853": [0.13333, 0.63333, 0, 0, 0.89444], + "8854": [0.13333, 0.63333, 0, 0, 0.89444], + "8855": [0.13333, 0.63333, 0, 0, 0.89444], + "8856": [0.13333, 0.63333, 0, 0, 0.89444], + "8857": [0.13333, 0.63333, 0, 0, 0.89444], + "8866": [0, 0.69444, 0, 0, 0.70277], + "8867": [0, 0.69444, 0, 0, 0.70277], + "8868": [0, 0.69444, 0, 0, 0.89444], + "8869": [0, 0.69444, 0, 0, 0.89444], + "8900": [-0.02639, 0.47361, 0, 0, 0.575], + "8901": [-0.02639, 0.47361, 0, 0, 0.31944], + "8902": [-0.02778, 0.47222, 0, 0, 0.575], + "8968": [0.25, 0.75, 0, 0, 0.51111], + "8969": [0.25, 0.75, 0, 0, 0.51111], + "8970": [0.25, 0.75, 0, 0, 0.51111], + "8971": [0.25, 0.75, 0, 0, 0.51111], + "8994": [-0.13889, 0.36111, 0, 0, 1.14999], + "8995": [-0.13889, 0.36111, 0, 0, 1.14999], + "9651": [0.19444, 0.69444, 0, 0, 1.02222], + "9657": [-0.02778, 0.47222, 0, 0, 0.575], + "9661": [0.19444, 0.69444, 0, 0, 1.02222], + "9667": [-0.02778, 0.47222, 0, 0, 0.575], + "9711": [0.19444, 0.69444, 0, 0, 1.14999], + "9824": [0.12963, 0.69444, 0, 0, 0.89444], + "9825": [0.12963, 0.69444, 0, 0, 0.89444], + "9826": [0.12963, 0.69444, 0, 0, 0.89444], + "9827": [0.12963, 0.69444, 0, 0, 0.89444], + "9837": [0, 0.75, 0, 0, 0.44722], + "9838": [0.19444, 0.69444, 0, 0, 0.44722], + "9839": [0.19444, 0.69444, 0, 0, 0.44722], + "10216": [0.25, 0.75, 0, 0, 0.44722], + "10217": [0.25, 0.75, 0, 0, 0.44722], + "10815": [0, 0.68611, 0, 0, 0.9], + "10927": [0.19667, 0.69667, 0, 0, 0.89444], + "10928": [0.19667, 0.69667, 0, 0, 0.89444], + "57376": [0.19444, 0.69444, 0, 0, 0], + }, + "Main-BoldItalic": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0.11417, 0, 0.38611], + "34": [0, 0.69444, 0.07939, 0, 0.62055], + "35": [0.19444, 0.69444, 0.06833, 0, 0.94444], + "37": [0.05556, 0.75, 0.12861, 0, 0.94444], + "38": [0, 0.69444, 0.08528, 0, 0.88555], + "39": [0, 0.69444, 0.12945, 0, 0.35555], + "40": [0.25, 0.75, 0.15806, 0, 0.47333], + "41": [0.25, 0.75, 0.03306, 0, 0.47333], + "42": [0, 0.75, 0.14333, 0, 0.59111], + "43": [0.10333, 0.60333, 0.03306, 0, 0.88555], + "44": [0.19444, 0.14722, 0, 0, 0.35555], + "45": [0, 0.44444, 0.02611, 0, 0.41444], + "46": [0, 0.14722, 0, 0, 0.35555], + "47": [0.25, 0.75, 0.15806, 0, 0.59111], + "48": [0, 0.64444, 0.13167, 0, 0.59111], + "49": [0, 0.64444, 0.13167, 0, 0.59111], + "50": [0, 0.64444, 0.13167, 0, 0.59111], + "51": [0, 0.64444, 0.13167, 0, 0.59111], + "52": [0.19444, 0.64444, 0.13167, 0, 0.59111], + "53": [0, 0.64444, 0.13167, 0, 0.59111], + "54": [0, 0.64444, 0.13167, 0, 0.59111], + "55": [0.19444, 0.64444, 0.13167, 0, 0.59111], + "56": [0, 0.64444, 0.13167, 0, 0.59111], + "57": [0, 0.64444, 0.13167, 0, 0.59111], + "58": [0, 0.44444, 0.06695, 0, 0.35555], + "59": [0.19444, 0.44444, 0.06695, 0, 0.35555], + "61": [-0.10889, 0.39111, 0.06833, 0, 0.88555], + "63": [0, 0.69444, 0.11472, 0, 0.59111], + "64": [0, 0.69444, 0.09208, 0, 0.88555], + "65": [0, 0.68611, 0, 0, 0.86555], + "66": [0, 0.68611, 0.0992, 0, 0.81666], + "67": [0, 0.68611, 0.14208, 0, 0.82666], + "68": [0, 0.68611, 0.09062, 0, 0.87555], + "69": [0, 0.68611, 0.11431, 0, 0.75666], + "70": [0, 0.68611, 0.12903, 0, 0.72722], + "71": [0, 0.68611, 0.07347, 0, 0.89527], + "72": [0, 0.68611, 0.17208, 0, 0.8961], + "73": [0, 0.68611, 0.15681, 0, 0.47166], + "74": [0, 0.68611, 0.145, 0, 0.61055], + "75": [0, 0.68611, 0.14208, 0, 0.89499], + "76": [0, 0.68611, 0, 0, 0.69777], + "77": [0, 0.68611, 0.17208, 0, 1.07277], + "78": [0, 0.68611, 0.17208, 0, 0.8961], + "79": [0, 0.68611, 0.09062, 0, 0.85499], + "80": [0, 0.68611, 0.0992, 0, 0.78721], + "81": [0.19444, 0.68611, 0.09062, 0, 0.85499], + "82": [0, 0.68611, 0.02559, 0, 0.85944], + "83": [0, 0.68611, 0.11264, 0, 0.64999], + "84": [0, 0.68611, 0.12903, 0, 0.7961], + "85": [0, 0.68611, 0.17208, 0, 0.88083], + "86": [0, 0.68611, 0.18625, 0, 0.86555], + "87": [0, 0.68611, 0.18625, 0, 1.15999], + "88": [0, 0.68611, 0.15681, 0, 0.86555], + "89": [0, 0.68611, 0.19803, 0, 0.86555], + "90": [0, 0.68611, 0.14208, 0, 0.70888], + "91": [0.25, 0.75, 0.1875, 0, 0.35611], + "93": [0.25, 0.75, 0.09972, 0, 0.35611], + "94": [0, 0.69444, 0.06709, 0, 0.59111], + "95": [0.31, 0.13444, 0.09811, 0, 0.59111], + "97": [0, 0.44444, 0.09426, 0, 0.59111], + "98": [0, 0.69444, 0.07861, 0, 0.53222], + "99": [0, 0.44444, 0.05222, 0, 0.53222], + "100": [0, 0.69444, 0.10861, 0, 0.59111], + "101": [0, 0.44444, 0.085, 0, 0.53222], + "102": [0.19444, 0.69444, 0.21778, 0, 0.4], + "103": [0.19444, 0.44444, 0.105, 0, 0.53222], + "104": [0, 0.69444, 0.09426, 0, 0.59111], + "105": [0, 0.69326, 0.11387, 0, 0.35555], + "106": [0.19444, 0.69326, 0.1672, 0, 0.35555], + "107": [0, 0.69444, 0.11111, 0, 0.53222], + "108": [0, 0.69444, 0.10861, 0, 0.29666], + "109": [0, 0.44444, 0.09426, 0, 0.94444], + "110": [0, 0.44444, 0.09426, 0, 0.64999], + "111": [0, 0.44444, 0.07861, 0, 0.59111], + "112": [0.19444, 0.44444, 0.07861, 0, 0.59111], + "113": [0.19444, 0.44444, 0.105, 0, 0.53222], + "114": [0, 0.44444, 0.11111, 0, 0.50167], + "115": [0, 0.44444, 0.08167, 0, 0.48694], + "116": [0, 0.63492, 0.09639, 0, 0.385], + "117": [0, 0.44444, 0.09426, 0, 0.62055], + "118": [0, 0.44444, 0.11111, 0, 0.53222], + "119": [0, 0.44444, 0.11111, 0, 0.76777], + "120": [0, 0.44444, 0.12583, 0, 0.56055], + "121": [0.19444, 0.44444, 0.105, 0, 0.56166], + "122": [0, 0.44444, 0.13889, 0, 0.49055], + "126": [0.35, 0.34444, 0.11472, 0, 0.59111], + "160": [0, 0, 0, 0, 0.25], + "168": [0, 0.69444, 0.11473, 0, 0.59111], + "176": [0, 0.69444, 0, 0, 0.94888], + "184": [0.17014, 0, 0, 0, 0.53222], + "198": [0, 0.68611, 0.11431, 0, 1.02277], + "216": [0.04861, 0.73472, 0.09062, 0, 0.88555], + "223": [0.19444, 0.69444, 0.09736, 0, 0.665], + "230": [0, 0.44444, 0.085, 0, 0.82666], + "248": [0.09722, 0.54167, 0.09458, 0, 0.59111], + "305": [0, 0.44444, 0.09426, 0, 0.35555], + "338": [0, 0.68611, 0.11431, 0, 1.14054], + "339": [0, 0.44444, 0.085, 0, 0.82666], + "567": [0.19444, 0.44444, 0.04611, 0, 0.385], + "710": [0, 0.69444, 0.06709, 0, 0.59111], + "711": [0, 0.63194, 0.08271, 0, 0.59111], + "713": [0, 0.59444, 0.10444, 0, 0.59111], + "714": [0, 0.69444, 0.08528, 0, 0.59111], + "715": [0, 0.69444, 0, 0, 0.59111], + "728": [0, 0.69444, 0.10333, 0, 0.59111], + "729": [0, 0.69444, 0.12945, 0, 0.35555], + "730": [0, 0.69444, 0, 0, 0.94888], + "732": [0, 0.69444, 0.11472, 0, 0.59111], + "733": [0, 0.69444, 0.11472, 0, 0.59111], + "915": [0, 0.68611, 0.12903, 0, 0.69777], + "916": [0, 0.68611, 0, 0, 0.94444], + "920": [0, 0.68611, 0.09062, 0, 0.88555], + "923": [0, 0.68611, 0, 0, 0.80666], + "926": [0, 0.68611, 0.15092, 0, 0.76777], + "928": [0, 0.68611, 0.17208, 0, 0.8961], + "931": [0, 0.68611, 0.11431, 0, 0.82666], + "933": [0, 0.68611, 0.10778, 0, 0.88555], + "934": [0, 0.68611, 0.05632, 0, 0.82666], + "936": [0, 0.68611, 0.10778, 0, 0.88555], + "937": [0, 0.68611, 0.0992, 0, 0.82666], + "8211": [0, 0.44444, 0.09811, 0, 0.59111], + "8212": [0, 0.44444, 0.09811, 0, 1.18221], + "8216": [0, 0.69444, 0.12945, 0, 0.35555], + "8217": [0, 0.69444, 0.12945, 0, 0.35555], + "8220": [0, 0.69444, 0.16772, 0, 0.62055], + "8221": [0, 0.69444, 0.07939, 0, 0.62055], + }, + "Main-Italic": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0.12417, 0, 0.30667], + "34": [0, 0.69444, 0.06961, 0, 0.51444], + "35": [0.19444, 0.69444, 0.06616, 0, 0.81777], + "37": [0.05556, 0.75, 0.13639, 0, 0.81777], + "38": [0, 0.69444, 0.09694, 0, 0.76666], + "39": [0, 0.69444, 0.12417, 0, 0.30667], + "40": [0.25, 0.75, 0.16194, 0, 0.40889], + "41": [0.25, 0.75, 0.03694, 0, 0.40889], + "42": [0, 0.75, 0.14917, 0, 0.51111], + "43": [0.05667, 0.56167, 0.03694, 0, 0.76666], + "44": [0.19444, 0.10556, 0, 0, 0.30667], + "45": [0, 0.43056, 0.02826, 0, 0.35778], + "46": [0, 0.10556, 0, 0, 0.30667], + "47": [0.25, 0.75, 0.16194, 0, 0.51111], + "48": [0, 0.64444, 0.13556, 0, 0.51111], + "49": [0, 0.64444, 0.13556, 0, 0.51111], + "50": [0, 0.64444, 0.13556, 0, 0.51111], + "51": [0, 0.64444, 0.13556, 0, 0.51111], + "52": [0.19444, 0.64444, 0.13556, 0, 0.51111], + "53": [0, 0.64444, 0.13556, 0, 0.51111], + "54": [0, 0.64444, 0.13556, 0, 0.51111], + "55": [0.19444, 0.64444, 0.13556, 0, 0.51111], + "56": [0, 0.64444, 0.13556, 0, 0.51111], + "57": [0, 0.64444, 0.13556, 0, 0.51111], + "58": [0, 0.43056, 0.0582, 0, 0.30667], + "59": [0.19444, 0.43056, 0.0582, 0, 0.30667], + "61": [-0.13313, 0.36687, 0.06616, 0, 0.76666], + "63": [0, 0.69444, 0.1225, 0, 0.51111], + "64": [0, 0.69444, 0.09597, 0, 0.76666], + "65": [0, 0.68333, 0, 0, 0.74333], + "66": [0, 0.68333, 0.10257, 0, 0.70389], + "67": [0, 0.68333, 0.14528, 0, 0.71555], + "68": [0, 0.68333, 0.09403, 0, 0.755], + "69": [0, 0.68333, 0.12028, 0, 0.67833], + "70": [0, 0.68333, 0.13305, 0, 0.65277], + "71": [0, 0.68333, 0.08722, 0, 0.77361], + "72": [0, 0.68333, 0.16389, 0, 0.74333], + "73": [0, 0.68333, 0.15806, 0, 0.38555], + "74": [0, 0.68333, 0.14028, 0, 0.525], + "75": [0, 0.68333, 0.14528, 0, 0.76888], + "76": [0, 0.68333, 0, 0, 0.62722], + "77": [0, 0.68333, 0.16389, 0, 0.89666], + "78": [0, 0.68333, 0.16389, 0, 0.74333], + "79": [0, 0.68333, 0.09403, 0, 0.76666], + "80": [0, 0.68333, 0.10257, 0, 0.67833], + "81": [0.19444, 0.68333, 0.09403, 0, 0.76666], + "82": [0, 0.68333, 0.03868, 0, 0.72944], + "83": [0, 0.68333, 0.11972, 0, 0.56222], + "84": [0, 0.68333, 0.13305, 0, 0.71555], + "85": [0, 0.68333, 0.16389, 0, 0.74333], + "86": [0, 0.68333, 0.18361, 0, 0.74333], + "87": [0, 0.68333, 0.18361, 0, 0.99888], + "88": [0, 0.68333, 0.15806, 0, 0.74333], + "89": [0, 0.68333, 0.19383, 0, 0.74333], + "90": [0, 0.68333, 0.14528, 0, 0.61333], + "91": [0.25, 0.75, 0.1875, 0, 0.30667], + "93": [0.25, 0.75, 0.10528, 0, 0.30667], + "94": [0, 0.69444, 0.06646, 0, 0.51111], + "95": [0.31, 0.12056, 0.09208, 0, 0.51111], + "97": [0, 0.43056, 0.07671, 0, 0.51111], + "98": [0, 0.69444, 0.06312, 0, 0.46], + "99": [0, 0.43056, 0.05653, 0, 0.46], + "100": [0, 0.69444, 0.10333, 0, 0.51111], + "101": [0, 0.43056, 0.07514, 0, 0.46], + "102": [0.19444, 0.69444, 0.21194, 0, 0.30667], + "103": [0.19444, 0.43056, 0.08847, 0, 0.46], + "104": [0, 0.69444, 0.07671, 0, 0.51111], + "105": [0, 0.65536, 0.1019, 0, 0.30667], + "106": [0.19444, 0.65536, 0.14467, 0, 0.30667], + "107": [0, 0.69444, 0.10764, 0, 0.46], + "108": [0, 0.69444, 0.10333, 0, 0.25555], + "109": [0, 0.43056, 0.07671, 0, 0.81777], + "110": [0, 0.43056, 0.07671, 0, 0.56222], + "111": [0, 0.43056, 0.06312, 0, 0.51111], + "112": [0.19444, 0.43056, 0.06312, 0, 0.51111], + "113": [0.19444, 0.43056, 0.08847, 0, 0.46], + "114": [0, 0.43056, 0.10764, 0, 0.42166], + "115": [0, 0.43056, 0.08208, 0, 0.40889], + "116": [0, 0.61508, 0.09486, 0, 0.33222], + "117": [0, 0.43056, 0.07671, 0, 0.53666], + "118": [0, 0.43056, 0.10764, 0, 0.46], + "119": [0, 0.43056, 0.10764, 0, 0.66444], + "120": [0, 0.43056, 0.12042, 0, 0.46389], + "121": [0.19444, 0.43056, 0.08847, 0, 0.48555], + "122": [0, 0.43056, 0.12292, 0, 0.40889], + "126": [0.35, 0.31786, 0.11585, 0, 0.51111], + "160": [0, 0, 0, 0, 0.25], + "168": [0, 0.66786, 0.10474, 0, 0.51111], + "176": [0, 0.69444, 0, 0, 0.83129], + "184": [0.17014, 0, 0, 0, 0.46], + "198": [0, 0.68333, 0.12028, 0, 0.88277], + "216": [0.04861, 0.73194, 0.09403, 0, 0.76666], + "223": [0.19444, 0.69444, 0.10514, 0, 0.53666], + "230": [0, 0.43056, 0.07514, 0, 0.71555], + "248": [0.09722, 0.52778, 0.09194, 0, 0.51111], + "338": [0, 0.68333, 0.12028, 0, 0.98499], + "339": [0, 0.43056, 0.07514, 0, 0.71555], + "710": [0, 0.69444, 0.06646, 0, 0.51111], + "711": [0, 0.62847, 0.08295, 0, 0.51111], + "713": [0, 0.56167, 0.10333, 0, 0.51111], + "714": [0, 0.69444, 0.09694, 0, 0.51111], + "715": [0, 0.69444, 0, 0, 0.51111], + "728": [0, 0.69444, 0.10806, 0, 0.51111], + "729": [0, 0.66786, 0.11752, 0, 0.30667], + "730": [0, 0.69444, 0, 0, 0.83129], + "732": [0, 0.66786, 0.11585, 0, 0.51111], + "733": [0, 0.69444, 0.1225, 0, 0.51111], + "915": [0, 0.68333, 0.13305, 0, 0.62722], + "916": [0, 0.68333, 0, 0, 0.81777], + "920": [0, 0.68333, 0.09403, 0, 0.76666], + "923": [0, 0.68333, 0, 0, 0.69222], + "926": [0, 0.68333, 0.15294, 0, 0.66444], + "928": [0, 0.68333, 0.16389, 0, 0.74333], + "931": [0, 0.68333, 0.12028, 0, 0.71555], + "933": [0, 0.68333, 0.11111, 0, 0.76666], + "934": [0, 0.68333, 0.05986, 0, 0.71555], + "936": [0, 0.68333, 0.11111, 0, 0.76666], + "937": [0, 0.68333, 0.10257, 0, 0.71555], + "8211": [0, 0.43056, 0.09208, 0, 0.51111], + "8212": [0, 0.43056, 0.09208, 0, 1.02222], + "8216": [0, 0.69444, 0.12417, 0, 0.30667], + "8217": [0, 0.69444, 0.12417, 0, 0.30667], + "8220": [0, 0.69444, 0.1685, 0, 0.51444], + "8221": [0, 0.69444, 0.06961, 0, 0.51444], + "8463": [0, 0.68889, 0, 0, 0.54028], + }, + "Main-Regular": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0, 0, 0.27778], + "34": [0, 0.69444, 0, 0, 0.5], + "35": [0.19444, 0.69444, 0, 0, 0.83334], + "36": [0.05556, 0.75, 0, 0, 0.5], + "37": [0.05556, 0.75, 0, 0, 0.83334], + "38": [0, 0.69444, 0, 0, 0.77778], + "39": [0, 0.69444, 0, 0, 0.27778], + "40": [0.25, 0.75, 0, 0, 0.38889], + "41": [0.25, 0.75, 0, 0, 0.38889], + "42": [0, 0.75, 0, 0, 0.5], + "43": [0.08333, 0.58333, 0, 0, 0.77778], + "44": [0.19444, 0.10556, 0, 0, 0.27778], + "45": [0, 0.43056, 0, 0, 0.33333], + "46": [0, 0.10556, 0, 0, 0.27778], + "47": [0.25, 0.75, 0, 0, 0.5], + "48": [0, 0.64444, 0, 0, 0.5], + "49": [0, 0.64444, 0, 0, 0.5], + "50": [0, 0.64444, 0, 0, 0.5], + "51": [0, 0.64444, 0, 0, 0.5], + "52": [0, 0.64444, 0, 0, 0.5], + "53": [0, 0.64444, 0, 0, 0.5], + "54": [0, 0.64444, 0, 0, 0.5], + "55": [0, 0.64444, 0, 0, 0.5], + "56": [0, 0.64444, 0, 0, 0.5], + "57": [0, 0.64444, 0, 0, 0.5], + "58": [0, 0.43056, 0, 0, 0.27778], + "59": [0.19444, 0.43056, 0, 0, 0.27778], + "60": [0.0391, 0.5391, 0, 0, 0.77778], + "61": [-0.13313, 0.36687, 0, 0, 0.77778], + "62": [0.0391, 0.5391, 0, 0, 0.77778], + "63": [0, 0.69444, 0, 0, 0.47222], + "64": [0, 0.69444, 0, 0, 0.77778], + "65": [0, 0.68333, 0, 0, 0.75], + "66": [0, 0.68333, 0, 0, 0.70834], + "67": [0, 0.68333, 0, 0, 0.72222], + "68": [0, 0.68333, 0, 0, 0.76389], + "69": [0, 0.68333, 0, 0, 0.68056], + "70": [0, 0.68333, 0, 0, 0.65278], + "71": [0, 0.68333, 0, 0, 0.78472], + "72": [0, 0.68333, 0, 0, 0.75], + "73": [0, 0.68333, 0, 0, 0.36111], + "74": [0, 0.68333, 0, 0, 0.51389], + "75": [0, 0.68333, 0, 0, 0.77778], + "76": [0, 0.68333, 0, 0, 0.625], + "77": [0, 0.68333, 0, 0, 0.91667], + "78": [0, 0.68333, 0, 0, 0.75], + "79": [0, 0.68333, 0, 0, 0.77778], + "80": [0, 0.68333, 0, 0, 0.68056], + "81": [0.19444, 0.68333, 0, 0, 0.77778], + "82": [0, 0.68333, 0, 0, 0.73611], + "83": [0, 0.68333, 0, 0, 0.55556], + "84": [0, 0.68333, 0, 0, 0.72222], + "85": [0, 0.68333, 0, 0, 0.75], + "86": [0, 0.68333, 0.01389, 0, 0.75], + "87": [0, 0.68333, 0.01389, 0, 1.02778], + "88": [0, 0.68333, 0, 0, 0.75], + "89": [0, 0.68333, 0.025, 0, 0.75], + "90": [0, 0.68333, 0, 0, 0.61111], + "91": [0.25, 0.75, 0, 0, 0.27778], + "92": [0.25, 0.75, 0, 0, 0.5], + "93": [0.25, 0.75, 0, 0, 0.27778], + "94": [0, 0.69444, 0, 0, 0.5], + "95": [0.31, 0.12056, 0.02778, 0, 0.5], + "97": [0, 0.43056, 0, 0, 0.5], + "98": [0, 0.69444, 0, 0, 0.55556], + "99": [0, 0.43056, 0, 0, 0.44445], + "100": [0, 0.69444, 0, 0, 0.55556], + "101": [0, 0.43056, 0, 0, 0.44445], + "102": [0, 0.69444, 0.07778, 0, 0.30556], + "103": [0.19444, 0.43056, 0.01389, 0, 0.5], + "104": [0, 0.69444, 0, 0, 0.55556], + "105": [0, 0.66786, 0, 0, 0.27778], + "106": [0.19444, 0.66786, 0, 0, 0.30556], + "107": [0, 0.69444, 0, 0, 0.52778], + "108": [0, 0.69444, 0, 0, 0.27778], + "109": [0, 0.43056, 0, 0, 0.83334], + "110": [0, 0.43056, 0, 0, 0.55556], + "111": [0, 0.43056, 0, 0, 0.5], + "112": [0.19444, 0.43056, 0, 0, 0.55556], + "113": [0.19444, 0.43056, 0, 0, 0.52778], + "114": [0, 0.43056, 0, 0, 0.39167], + "115": [0, 0.43056, 0, 0, 0.39445], + "116": [0, 0.61508, 0, 0, 0.38889], + "117": [0, 0.43056, 0, 0, 0.55556], + "118": [0, 0.43056, 0.01389, 0, 0.52778], + "119": [0, 0.43056, 0.01389, 0, 0.72222], + "120": [0, 0.43056, 0, 0, 0.52778], + "121": [0.19444, 0.43056, 0.01389, 0, 0.52778], + "122": [0, 0.43056, 0, 0, 0.44445], + "123": [0.25, 0.75, 0, 0, 0.5], + "124": [0.25, 0.75, 0, 0, 0.27778], + "125": [0.25, 0.75, 0, 0, 0.5], + "126": [0.35, 0.31786, 0, 0, 0.5], + "160": [0, 0, 0, 0, 0.25], + "163": [0, 0.69444, 0, 0, 0.76909], + "167": [0.19444, 0.69444, 0, 0, 0.44445], + "168": [0, 0.66786, 0, 0, 0.5], + "172": [0, 0.43056, 0, 0, 0.66667], + "176": [0, 0.69444, 0, 0, 0.75], + "177": [0.08333, 0.58333, 0, 0, 0.77778], + "182": [0.19444, 0.69444, 0, 0, 0.61111], + "184": [0.17014, 0, 0, 0, 0.44445], + "198": [0, 0.68333, 0, 0, 0.90278], + "215": [0.08333, 0.58333, 0, 0, 0.77778], + "216": [0.04861, 0.73194, 0, 0, 0.77778], + "223": [0, 0.69444, 0, 0, 0.5], + "230": [0, 0.43056, 0, 0, 0.72222], + "247": [0.08333, 0.58333, 0, 0, 0.77778], + "248": [0.09722, 0.52778, 0, 0, 0.5], + "305": [0, 0.43056, 0, 0, 0.27778], + "338": [0, 0.68333, 0, 0, 1.01389], + "339": [0, 0.43056, 0, 0, 0.77778], + "567": [0.19444, 0.43056, 0, 0, 0.30556], + "710": [0, 0.69444, 0, 0, 0.5], + "711": [0, 0.62847, 0, 0, 0.5], + "713": [0, 0.56778, 0, 0, 0.5], + "714": [0, 0.69444, 0, 0, 0.5], + "715": [0, 0.69444, 0, 0, 0.5], + "728": [0, 0.69444, 0, 0, 0.5], + "729": [0, 0.66786, 0, 0, 0.27778], + "730": [0, 0.69444, 0, 0, 0.75], + "732": [0, 0.66786, 0, 0, 0.5], + "733": [0, 0.69444, 0, 0, 0.5], + "915": [0, 0.68333, 0, 0, 0.625], + "916": [0, 0.68333, 0, 0, 0.83334], + "920": [0, 0.68333, 0, 0, 0.77778], + "923": [0, 0.68333, 0, 0, 0.69445], + "926": [0, 0.68333, 0, 0, 0.66667], + "928": [0, 0.68333, 0, 0, 0.75], + "931": [0, 0.68333, 0, 0, 0.72222], + "933": [0, 0.68333, 0, 0, 0.77778], + "934": [0, 0.68333, 0, 0, 0.72222], + "936": [0, 0.68333, 0, 0, 0.77778], + "937": [0, 0.68333, 0, 0, 0.72222], + "8211": [0, 0.43056, 0.02778, 0, 0.5], + "8212": [0, 0.43056, 0.02778, 0, 1.0], + "8216": [0, 0.69444, 0, 0, 0.27778], + "8217": [0, 0.69444, 0, 0, 0.27778], + "8220": [0, 0.69444, 0, 0, 0.5], + "8221": [0, 0.69444, 0, 0, 0.5], + "8224": [0.19444, 0.69444, 0, 0, 0.44445], + "8225": [0.19444, 0.69444, 0, 0, 0.44445], + "8230": [0, 0.123, 0, 0, 1.172], + "8242": [0, 0.55556, 0, 0, 0.275], + "8407": [0, 0.71444, 0.15382, 0, 0.5], + "8463": [0, 0.68889, 0, 0, 0.54028], + "8465": [0, 0.69444, 0, 0, 0.72222], + "8467": [0, 0.69444, 0, 0.11111, 0.41667], + "8472": [0.19444, 0.43056, 0, 0.11111, 0.63646], + "8476": [0, 0.69444, 0, 0, 0.72222], + "8501": [0, 0.69444, 0, 0, 0.61111], + "8592": [-0.13313, 0.36687, 0, 0, 1.0], + "8593": [0.19444, 0.69444, 0, 0, 0.5], + "8594": [-0.13313, 0.36687, 0, 0, 1.0], + "8595": [0.19444, 0.69444, 0, 0, 0.5], + "8596": [-0.13313, 0.36687, 0, 0, 1.0], + "8597": [0.25, 0.75, 0, 0, 0.5], + "8598": [0.19444, 0.69444, 0, 0, 1.0], + "8599": [0.19444, 0.69444, 0, 0, 1.0], + "8600": [0.19444, 0.69444, 0, 0, 1.0], + "8601": [0.19444, 0.69444, 0, 0, 1.0], + "8614": [0.011, 0.511, 0, 0, 1.0], + "8617": [0.011, 0.511, 0, 0, 1.126], + "8618": [0.011, 0.511, 0, 0, 1.126], + "8636": [-0.13313, 0.36687, 0, 0, 1.0], + "8637": [-0.13313, 0.36687, 0, 0, 1.0], + "8640": [-0.13313, 0.36687, 0, 0, 1.0], + "8641": [-0.13313, 0.36687, 0, 0, 1.0], + "8652": [0.011, 0.671, 0, 0, 1.0], + "8656": [-0.13313, 0.36687, 0, 0, 1.0], + "8657": [0.19444, 0.69444, 0, 0, 0.61111], + "8658": [-0.13313, 0.36687, 0, 0, 1.0], + "8659": [0.19444, 0.69444, 0, 0, 0.61111], + "8660": [-0.13313, 0.36687, 0, 0, 1.0], + "8661": [0.25, 0.75, 0, 0, 0.61111], + "8704": [0, 0.69444, 0, 0, 0.55556], + "8706": [0, 0.69444, 0.05556, 0.08334, 0.5309], + "8707": [0, 0.69444, 0, 0, 0.55556], + "8709": [0.05556, 0.75, 0, 0, 0.5], + "8711": [0, 0.68333, 0, 0, 0.83334], + "8712": [0.0391, 0.5391, 0, 0, 0.66667], + "8715": [0.0391, 0.5391, 0, 0, 0.66667], + "8722": [0.08333, 0.58333, 0, 0, 0.77778], + "8723": [0.08333, 0.58333, 0, 0, 0.77778], + "8725": [0.25, 0.75, 0, 0, 0.5], + "8726": [0.25, 0.75, 0, 0, 0.5], + "8727": [-0.03472, 0.46528, 0, 0, 0.5], + "8728": [-0.05555, 0.44445, 0, 0, 0.5], + "8729": [-0.05555, 0.44445, 0, 0, 0.5], + "8730": [0.2, 0.8, 0, 0, 0.83334], + "8733": [0, 0.43056, 0, 0, 0.77778], + "8734": [0, 0.43056, 0, 0, 1.0], + "8736": [0, 0.69224, 0, 0, 0.72222], + "8739": [0.25, 0.75, 0, 0, 0.27778], + "8741": [0.25, 0.75, 0, 0, 0.5], + "8743": [0, 0.55556, 0, 0, 0.66667], + "8744": [0, 0.55556, 0, 0, 0.66667], + "8745": [0, 0.55556, 0, 0, 0.66667], + "8746": [0, 0.55556, 0, 0, 0.66667], + "8747": [0.19444, 0.69444, 0.11111, 0, 0.41667], + "8764": [-0.13313, 0.36687, 0, 0, 0.77778], + "8768": [0.19444, 0.69444, 0, 0, 0.27778], + "8771": [-0.03625, 0.46375, 0, 0, 0.77778], + "8773": [-0.022, 0.589, 0, 0, 0.778], + "8776": [-0.01688, 0.48312, 0, 0, 0.77778], + "8781": [-0.03625, 0.46375, 0, 0, 0.77778], + "8784": [-0.133, 0.673, 0, 0, 0.778], + "8801": [-0.03625, 0.46375, 0, 0, 0.77778], + "8804": [0.13597, 0.63597, 0, 0, 0.77778], + "8805": [0.13597, 0.63597, 0, 0, 0.77778], + "8810": [0.0391, 0.5391, 0, 0, 1.0], + "8811": [0.0391, 0.5391, 0, 0, 1.0], + "8826": [0.0391, 0.5391, 0, 0, 0.77778], + "8827": [0.0391, 0.5391, 0, 0, 0.77778], + "8834": [0.0391, 0.5391, 0, 0, 0.77778], + "8835": [0.0391, 0.5391, 0, 0, 0.77778], + "8838": [0.13597, 0.63597, 0, 0, 0.77778], + "8839": [0.13597, 0.63597, 0, 0, 0.77778], + "8846": [0, 0.55556, 0, 0, 0.66667], + "8849": [0.13597, 0.63597, 0, 0, 0.77778], + "8850": [0.13597, 0.63597, 0, 0, 0.77778], + "8851": [0, 0.55556, 0, 0, 0.66667], + "8852": [0, 0.55556, 0, 0, 0.66667], + "8853": [0.08333, 0.58333, 0, 0, 0.77778], + "8854": [0.08333, 0.58333, 0, 0, 0.77778], + "8855": [0.08333, 0.58333, 0, 0, 0.77778], + "8856": [0.08333, 0.58333, 0, 0, 0.77778], + "8857": [0.08333, 0.58333, 0, 0, 0.77778], + "8866": [0, 0.69444, 0, 0, 0.61111], + "8867": [0, 0.69444, 0, 0, 0.61111], + "8868": [0, 0.69444, 0, 0, 0.77778], + "8869": [0, 0.69444, 0, 0, 0.77778], + "8872": [0.249, 0.75, 0, 0, 0.867], + "8900": [-0.05555, 0.44445, 0, 0, 0.5], + "8901": [-0.05555, 0.44445, 0, 0, 0.27778], + "8902": [-0.03472, 0.46528, 0, 0, 0.5], + "8904": [0.005, 0.505, 0, 0, 0.9], + "8942": [0.03, 0.903, 0, 0, 0.278], + "8943": [-0.19, 0.313, 0, 0, 1.172], + "8945": [-0.1, 0.823, 0, 0, 1.282], + "8968": [0.25, 0.75, 0, 0, 0.44445], + "8969": [0.25, 0.75, 0, 0, 0.44445], + "8970": [0.25, 0.75, 0, 0, 0.44445], + "8971": [0.25, 0.75, 0, 0, 0.44445], + "8994": [-0.14236, 0.35764, 0, 0, 1.0], + "8995": [-0.14236, 0.35764, 0, 0, 1.0], + "9136": [0.244, 0.744, 0, 0, 0.412], + "9137": [0.244, 0.745, 0, 0, 0.412], + "9651": [0.19444, 0.69444, 0, 0, 0.88889], + "9657": [-0.03472, 0.46528, 0, 0, 0.5], + "9661": [0.19444, 0.69444, 0, 0, 0.88889], + "9667": [-0.03472, 0.46528, 0, 0, 0.5], + "9711": [0.19444, 0.69444, 0, 0, 1.0], + "9824": [0.12963, 0.69444, 0, 0, 0.77778], + "9825": [0.12963, 0.69444, 0, 0, 0.77778], + "9826": [0.12963, 0.69444, 0, 0, 0.77778], + "9827": [0.12963, 0.69444, 0, 0, 0.77778], + "9837": [0, 0.75, 0, 0, 0.38889], + "9838": [0.19444, 0.69444, 0, 0, 0.38889], + "9839": [0.19444, 0.69444, 0, 0, 0.38889], + "10216": [0.25, 0.75, 0, 0, 0.38889], + "10217": [0.25, 0.75, 0, 0, 0.38889], + "10222": [0.244, 0.744, 0, 0, 0.412], + "10223": [0.244, 0.745, 0, 0, 0.412], + "10229": [0.011, 0.511, 0, 0, 1.609], + "10230": [0.011, 0.511, 0, 0, 1.638], + "10231": [0.011, 0.511, 0, 0, 1.859], + "10232": [0.024, 0.525, 0, 0, 1.609], + "10233": [0.024, 0.525, 0, 0, 1.638], + "10234": [0.024, 0.525, 0, 0, 1.858], + "10236": [0.011, 0.511, 0, 0, 1.638], + "10815": [0, 0.68333, 0, 0, 0.75], + "10927": [0.13597, 0.63597, 0, 0, 0.77778], + "10928": [0.13597, 0.63597, 0, 0, 0.77778], + "57376": [0.19444, 0.69444, 0, 0, 0], + }, + "Math-BoldItalic": { + "32": [0, 0, 0, 0, 0.25], + "48": [0, 0.44444, 0, 0, 0.575], + "49": [0, 0.44444, 0, 0, 0.575], + "50": [0, 0.44444, 0, 0, 0.575], + "51": [0.19444, 0.44444, 0, 0, 0.575], + "52": [0.19444, 0.44444, 0, 0, 0.575], + "53": [0.19444, 0.44444, 0, 0, 0.575], + "54": [0, 0.64444, 0, 0, 0.575], + "55": [0.19444, 0.44444, 0, 0, 0.575], + "56": [0, 0.64444, 0, 0, 0.575], + "57": [0.19444, 0.44444, 0, 0, 0.575], + "65": [0, 0.68611, 0, 0, 0.86944], + "66": [0, 0.68611, 0.04835, 0, 0.8664], + "67": [0, 0.68611, 0.06979, 0, 0.81694], + "68": [0, 0.68611, 0.03194, 0, 0.93812], + "69": [0, 0.68611, 0.05451, 0, 0.81007], + "70": [0, 0.68611, 0.15972, 0, 0.68889], + "71": [0, 0.68611, 0, 0, 0.88673], + "72": [0, 0.68611, 0.08229, 0, 0.98229], + "73": [0, 0.68611, 0.07778, 0, 0.51111], + "74": [0, 0.68611, 0.10069, 0, 0.63125], + "75": [0, 0.68611, 0.06979, 0, 0.97118], + "76": [0, 0.68611, 0, 0, 0.75555], + "77": [0, 0.68611, 0.11424, 0, 1.14201], + "78": [0, 0.68611, 0.11424, 0, 0.95034], + "79": [0, 0.68611, 0.03194, 0, 0.83666], + "80": [0, 0.68611, 0.15972, 0, 0.72309], + "81": [0.19444, 0.68611, 0, 0, 0.86861], + "82": [0, 0.68611, 0.00421, 0, 0.87235], + "83": [0, 0.68611, 0.05382, 0, 0.69271], + "84": [0, 0.68611, 0.15972, 0, 0.63663], + "85": [0, 0.68611, 0.11424, 0, 0.80027], + "86": [0, 0.68611, 0.25555, 0, 0.67778], + "87": [0, 0.68611, 0.15972, 0, 1.09305], + "88": [0, 0.68611, 0.07778, 0, 0.94722], + "89": [0, 0.68611, 0.25555, 0, 0.67458], + "90": [0, 0.68611, 0.06979, 0, 0.77257], + "97": [0, 0.44444, 0, 0, 0.63287], + "98": [0, 0.69444, 0, 0, 0.52083], + "99": [0, 0.44444, 0, 0, 0.51342], + "100": [0, 0.69444, 0, 0, 0.60972], + "101": [0, 0.44444, 0, 0, 0.55361], + "102": [0.19444, 0.69444, 0.11042, 0, 0.56806], + "103": [0.19444, 0.44444, 0.03704, 0, 0.5449], + "104": [0, 0.69444, 0, 0, 0.66759], + "105": [0, 0.69326, 0, 0, 0.4048], + "106": [0.19444, 0.69326, 0.0622, 0, 0.47083], + "107": [0, 0.69444, 0.01852, 0, 0.6037], + "108": [0, 0.69444, 0.0088, 0, 0.34815], + "109": [0, 0.44444, 0, 0, 1.0324], + "110": [0, 0.44444, 0, 0, 0.71296], + "111": [0, 0.44444, 0, 0, 0.58472], + "112": [0.19444, 0.44444, 0, 0, 0.60092], + "113": [0.19444, 0.44444, 0.03704, 0, 0.54213], + "114": [0, 0.44444, 0.03194, 0, 0.5287], + "115": [0, 0.44444, 0, 0, 0.53125], + "116": [0, 0.63492, 0, 0, 0.41528], + "117": [0, 0.44444, 0, 0, 0.68102], + "118": [0, 0.44444, 0.03704, 0, 0.56666], + "119": [0, 0.44444, 0.02778, 0, 0.83148], + "120": [0, 0.44444, 0, 0, 0.65903], + "121": [0.19444, 0.44444, 0.03704, 0, 0.59028], + "122": [0, 0.44444, 0.04213, 0, 0.55509], + "160": [0, 0, 0, 0, 0.25], + "915": [0, 0.68611, 0.15972, 0, 0.65694], + "916": [0, 0.68611, 0, 0, 0.95833], + "920": [0, 0.68611, 0.03194, 0, 0.86722], + "923": [0, 0.68611, 0, 0, 0.80555], + "926": [0, 0.68611, 0.07458, 0, 0.84125], + "928": [0, 0.68611, 0.08229, 0, 0.98229], + "931": [0, 0.68611, 0.05451, 0, 0.88507], + "933": [0, 0.68611, 0.15972, 0, 0.67083], + "934": [0, 0.68611, 0, 0, 0.76666], + "936": [0, 0.68611, 0.11653, 0, 0.71402], + "937": [0, 0.68611, 0.04835, 0, 0.8789], + "945": [0, 0.44444, 0, 0, 0.76064], + "946": [0.19444, 0.69444, 0.03403, 0, 0.65972], + "947": [0.19444, 0.44444, 0.06389, 0, 0.59003], + "948": [0, 0.69444, 0.03819, 0, 0.52222], + "949": [0, 0.44444, 0, 0, 0.52882], + "950": [0.19444, 0.69444, 0.06215, 0, 0.50833], + "951": [0.19444, 0.44444, 0.03704, 0, 0.6], + "952": [0, 0.69444, 0.03194, 0, 0.5618], + "953": [0, 0.44444, 0, 0, 0.41204], + "954": [0, 0.44444, 0, 0, 0.66759], + "955": [0, 0.69444, 0, 0, 0.67083], + "956": [0.19444, 0.44444, 0, 0, 0.70787], + "957": [0, 0.44444, 0.06898, 0, 0.57685], + "958": [0.19444, 0.69444, 0.03021, 0, 0.50833], + "959": [0, 0.44444, 0, 0, 0.58472], + "960": [0, 0.44444, 0.03704, 0, 0.68241], + "961": [0.19444, 0.44444, 0, 0, 0.6118], + "962": [0.09722, 0.44444, 0.07917, 0, 0.42361], + "963": [0, 0.44444, 0.03704, 0, 0.68588], + "964": [0, 0.44444, 0.13472, 0, 0.52083], + "965": [0, 0.44444, 0.03704, 0, 0.63055], + "966": [0.19444, 0.44444, 0, 0, 0.74722], + "967": [0.19444, 0.44444, 0, 0, 0.71805], + "968": [0.19444, 0.69444, 0.03704, 0, 0.75833], + "969": [0, 0.44444, 0.03704, 0, 0.71782], + "977": [0, 0.69444, 0, 0, 0.69155], + "981": [0.19444, 0.69444, 0, 0, 0.7125], + "982": [0, 0.44444, 0.03194, 0, 0.975], + "1009": [0.19444, 0.44444, 0, 0, 0.6118], + "1013": [0, 0.44444, 0, 0, 0.48333], + "57649": [0, 0.44444, 0, 0, 0.39352], + "57911": [0.19444, 0.44444, 0, 0, 0.43889], + }, + "Math-Italic": { + "32": [0, 0, 0, 0, 0.25], + "48": [0, 0.43056, 0, 0, 0.5], + "49": [0, 0.43056, 0, 0, 0.5], + "50": [0, 0.43056, 0, 0, 0.5], + "51": [0.19444, 0.43056, 0, 0, 0.5], + "52": [0.19444, 0.43056, 0, 0, 0.5], + "53": [0.19444, 0.43056, 0, 0, 0.5], + "54": [0, 0.64444, 0, 0, 0.5], + "55": [0.19444, 0.43056, 0, 0, 0.5], + "56": [0, 0.64444, 0, 0, 0.5], + "57": [0.19444, 0.43056, 0, 0, 0.5], + "65": [0, 0.68333, 0, 0.13889, 0.75], + "66": [0, 0.68333, 0.05017, 0.08334, 0.75851], + "67": [0, 0.68333, 0.07153, 0.08334, 0.71472], + "68": [0, 0.68333, 0.02778, 0.05556, 0.82792], + "69": [0, 0.68333, 0.05764, 0.08334, 0.7382], + "70": [0, 0.68333, 0.13889, 0.08334, 0.64306], + "71": [0, 0.68333, 0, 0.08334, 0.78625], + "72": [0, 0.68333, 0.08125, 0.05556, 0.83125], + "73": [0, 0.68333, 0.07847, 0.11111, 0.43958], + "74": [0, 0.68333, 0.09618, 0.16667, 0.55451], + "75": [0, 0.68333, 0.07153, 0.05556, 0.84931], + "76": [0, 0.68333, 0, 0.02778, 0.68056], + "77": [0, 0.68333, 0.10903, 0.08334, 0.97014], + "78": [0, 0.68333, 0.10903, 0.08334, 0.80347], + "79": [0, 0.68333, 0.02778, 0.08334, 0.76278], + "80": [0, 0.68333, 0.13889, 0.08334, 0.64201], + "81": [0.19444, 0.68333, 0, 0.08334, 0.79056], + "82": [0, 0.68333, 0.00773, 0.08334, 0.75929], + "83": [0, 0.68333, 0.05764, 0.08334, 0.6132], + "84": [0, 0.68333, 0.13889, 0.08334, 0.58438], + "85": [0, 0.68333, 0.10903, 0.02778, 0.68278], + "86": [0, 0.68333, 0.22222, 0, 0.58333], + "87": [0, 0.68333, 0.13889, 0, 0.94445], + "88": [0, 0.68333, 0.07847, 0.08334, 0.82847], + "89": [0, 0.68333, 0.22222, 0, 0.58056], + "90": [0, 0.68333, 0.07153, 0.08334, 0.68264], + "97": [0, 0.43056, 0, 0, 0.52859], + "98": [0, 0.69444, 0, 0, 0.42917], + "99": [0, 0.43056, 0, 0.05556, 0.43276], + "100": [0, 0.69444, 0, 0.16667, 0.52049], + "101": [0, 0.43056, 0, 0.05556, 0.46563], + "102": [0.19444, 0.69444, 0.10764, 0.16667, 0.48959], + "103": [0.19444, 0.43056, 0.03588, 0.02778, 0.47697], + "104": [0, 0.69444, 0, 0, 0.57616], + "105": [0, 0.65952, 0, 0, 0.34451], + "106": [0.19444, 0.65952, 0.05724, 0, 0.41181], + "107": [0, 0.69444, 0.03148, 0, 0.5206], + "108": [0, 0.69444, 0.01968, 0.08334, 0.29838], + "109": [0, 0.43056, 0, 0, 0.87801], + "110": [0, 0.43056, 0, 0, 0.60023], + "111": [0, 0.43056, 0, 0.05556, 0.48472], + "112": [0.19444, 0.43056, 0, 0.08334, 0.50313], + "113": [0.19444, 0.43056, 0.03588, 0.08334, 0.44641], + "114": [0, 0.43056, 0.02778, 0.05556, 0.45116], + "115": [0, 0.43056, 0, 0.05556, 0.46875], + "116": [0, 0.61508, 0, 0.08334, 0.36111], + "117": [0, 0.43056, 0, 0.02778, 0.57246], + "118": [0, 0.43056, 0.03588, 0.02778, 0.48472], + "119": [0, 0.43056, 0.02691, 0.08334, 0.71592], + "120": [0, 0.43056, 0, 0.02778, 0.57153], + "121": [0.19444, 0.43056, 0.03588, 0.05556, 0.49028], + "122": [0, 0.43056, 0.04398, 0.05556, 0.46505], + "160": [0, 0, 0, 0, 0.25], + "915": [0, 0.68333, 0.13889, 0.08334, 0.61528], + "916": [0, 0.68333, 0, 0.16667, 0.83334], + "920": [0, 0.68333, 0.02778, 0.08334, 0.76278], + "923": [0, 0.68333, 0, 0.16667, 0.69445], + "926": [0, 0.68333, 0.07569, 0.08334, 0.74236], + "928": [0, 0.68333, 0.08125, 0.05556, 0.83125], + "931": [0, 0.68333, 0.05764, 0.08334, 0.77986], + "933": [0, 0.68333, 0.13889, 0.05556, 0.58333], + "934": [0, 0.68333, 0, 0.08334, 0.66667], + "936": [0, 0.68333, 0.11, 0.05556, 0.61222], + "937": [0, 0.68333, 0.05017, 0.08334, 0.7724], + "945": [0, 0.43056, 0.0037, 0.02778, 0.6397], + "946": [0.19444, 0.69444, 0.05278, 0.08334, 0.56563], + "947": [0.19444, 0.43056, 0.05556, 0, 0.51773], + "948": [0, 0.69444, 0.03785, 0.05556, 0.44444], + "949": [0, 0.43056, 0, 0.08334, 0.46632], + "950": [0.19444, 0.69444, 0.07378, 0.08334, 0.4375], + "951": [0.19444, 0.43056, 0.03588, 0.05556, 0.49653], + "952": [0, 0.69444, 0.02778, 0.08334, 0.46944], + "953": [0, 0.43056, 0, 0.05556, 0.35394], + "954": [0, 0.43056, 0, 0, 0.57616], + "955": [0, 0.69444, 0, 0, 0.58334], + "956": [0.19444, 0.43056, 0, 0.02778, 0.60255], + "957": [0, 0.43056, 0.06366, 0.02778, 0.49398], + "958": [0.19444, 0.69444, 0.04601, 0.11111, 0.4375], + "959": [0, 0.43056, 0, 0.05556, 0.48472], + "960": [0, 0.43056, 0.03588, 0, 0.57003], + "961": [0.19444, 0.43056, 0, 0.08334, 0.51702], + "962": [0.09722, 0.43056, 0.07986, 0.08334, 0.36285], + "963": [0, 0.43056, 0.03588, 0, 0.57141], + "964": [0, 0.43056, 0.1132, 0.02778, 0.43715], + "965": [0, 0.43056, 0.03588, 0.02778, 0.54028], + "966": [0.19444, 0.43056, 0, 0.08334, 0.65417], + "967": [0.19444, 0.43056, 0, 0.05556, 0.62569], + "968": [0.19444, 0.69444, 0.03588, 0.11111, 0.65139], + "969": [0, 0.43056, 0.03588, 0, 0.62245], + "977": [0, 0.69444, 0, 0.08334, 0.59144], + "981": [0.19444, 0.69444, 0, 0.08334, 0.59583], + "982": [0, 0.43056, 0.02778, 0, 0.82813], + "1009": [0.19444, 0.43056, 0, 0.08334, 0.51702], + "1013": [0, 0.43056, 0, 0.05556, 0.4059], + "57649": [0, 0.43056, 0, 0.02778, 0.32246], + "57911": [0.19444, 0.43056, 0, 0.08334, 0.38403], + }, + "SansSerif-Bold": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0, 0, 0.36667], + "34": [0, 0.69444, 0, 0, 0.55834], + "35": [0.19444, 0.69444, 0, 0, 0.91667], + "36": [0.05556, 0.75, 0, 0, 0.55], + "37": [0.05556, 0.75, 0, 0, 1.02912], + "38": [0, 0.69444, 0, 0, 0.83056], + "39": [0, 0.69444, 0, 0, 0.30556], + "40": [0.25, 0.75, 0, 0, 0.42778], + "41": [0.25, 0.75, 0, 0, 0.42778], + "42": [0, 0.75, 0, 0, 0.55], + "43": [0.11667, 0.61667, 0, 0, 0.85556], + "44": [0.10556, 0.13056, 0, 0, 0.30556], + "45": [0, 0.45833, 0, 0, 0.36667], + "46": [0, 0.13056, 0, 0, 0.30556], + "47": [0.25, 0.75, 0, 0, 0.55], + "48": [0, 0.69444, 0, 0, 0.55], + "49": [0, 0.69444, 0, 0, 0.55], + "50": [0, 0.69444, 0, 0, 0.55], + "51": [0, 0.69444, 0, 0, 0.55], + "52": [0, 0.69444, 0, 0, 0.55], + "53": [0, 0.69444, 0, 0, 0.55], + "54": [0, 0.69444, 0, 0, 0.55], + "55": [0, 0.69444, 0, 0, 0.55], + "56": [0, 0.69444, 0, 0, 0.55], + "57": [0, 0.69444, 0, 0, 0.55], + "58": [0, 0.45833, 0, 0, 0.30556], + "59": [0.10556, 0.45833, 0, 0, 0.30556], + "61": [-0.09375, 0.40625, 0, 0, 0.85556], + "63": [0, 0.69444, 0, 0, 0.51945], + "64": [0, 0.69444, 0, 0, 0.73334], + "65": [0, 0.69444, 0, 0, 0.73334], + "66": [0, 0.69444, 0, 0, 0.73334], + "67": [0, 0.69444, 0, 0, 0.70278], + "68": [0, 0.69444, 0, 0, 0.79445], + "69": [0, 0.69444, 0, 0, 0.64167], + "70": [0, 0.69444, 0, 0, 0.61111], + "71": [0, 0.69444, 0, 0, 0.73334], + "72": [0, 0.69444, 0, 0, 0.79445], + "73": [0, 0.69444, 0, 0, 0.33056], + "74": [0, 0.69444, 0, 0, 0.51945], + "75": [0, 0.69444, 0, 0, 0.76389], + "76": [0, 0.69444, 0, 0, 0.58056], + "77": [0, 0.69444, 0, 0, 0.97778], + "78": [0, 0.69444, 0, 0, 0.79445], + "79": [0, 0.69444, 0, 0, 0.79445], + "80": [0, 0.69444, 0, 0, 0.70278], + "81": [0.10556, 0.69444, 0, 0, 0.79445], + "82": [0, 0.69444, 0, 0, 0.70278], + "83": [0, 0.69444, 0, 0, 0.61111], + "84": [0, 0.69444, 0, 0, 0.73334], + "85": [0, 0.69444, 0, 0, 0.76389], + "86": [0, 0.69444, 0.01528, 0, 0.73334], + "87": [0, 0.69444, 0.01528, 0, 1.03889], + "88": [0, 0.69444, 0, 0, 0.73334], + "89": [0, 0.69444, 0.0275, 0, 0.73334], + "90": [0, 0.69444, 0, 0, 0.67223], + "91": [0.25, 0.75, 0, 0, 0.34306], + "93": [0.25, 0.75, 0, 0, 0.34306], + "94": [0, 0.69444, 0, 0, 0.55], + "95": [0.35, 0.10833, 0.03056, 0, 0.55], + "97": [0, 0.45833, 0, 0, 0.525], + "98": [0, 0.69444, 0, 0, 0.56111], + "99": [0, 0.45833, 0, 0, 0.48889], + "100": [0, 0.69444, 0, 0, 0.56111], + "101": [0, 0.45833, 0, 0, 0.51111], + "102": [0, 0.69444, 0.07639, 0, 0.33611], + "103": [0.19444, 0.45833, 0.01528, 0, 0.55], + "104": [0, 0.69444, 0, 0, 0.56111], + "105": [0, 0.69444, 0, 0, 0.25556], + "106": [0.19444, 0.69444, 0, 0, 0.28611], + "107": [0, 0.69444, 0, 0, 0.53056], + "108": [0, 0.69444, 0, 0, 0.25556], + "109": [0, 0.45833, 0, 0, 0.86667], + "110": [0, 0.45833, 0, 0, 0.56111], + "111": [0, 0.45833, 0, 0, 0.55], + "112": [0.19444, 0.45833, 0, 0, 0.56111], + "113": [0.19444, 0.45833, 0, 0, 0.56111], + "114": [0, 0.45833, 0.01528, 0, 0.37222], + "115": [0, 0.45833, 0, 0, 0.42167], + "116": [0, 0.58929, 0, 0, 0.40417], + "117": [0, 0.45833, 0, 0, 0.56111], + "118": [0, 0.45833, 0.01528, 0, 0.5], + "119": [0, 0.45833, 0.01528, 0, 0.74445], + "120": [0, 0.45833, 0, 0, 0.5], + "121": [0.19444, 0.45833, 0.01528, 0, 0.5], + "122": [0, 0.45833, 0, 0, 0.47639], + "126": [0.35, 0.34444, 0, 0, 0.55], + "160": [0, 0, 0, 0, 0.25], + "168": [0, 0.69444, 0, 0, 0.55], + "176": [0, 0.69444, 0, 0, 0.73334], + "180": [0, 0.69444, 0, 0, 0.55], + "184": [0.17014, 0, 0, 0, 0.48889], + "305": [0, 0.45833, 0, 0, 0.25556], + "567": [0.19444, 0.45833, 0, 0, 0.28611], + "710": [0, 0.69444, 0, 0, 0.55], + "711": [0, 0.63542, 0, 0, 0.55], + "713": [0, 0.63778, 0, 0, 0.55], + "728": [0, 0.69444, 0, 0, 0.55], + "729": [0, 0.69444, 0, 0, 0.30556], + "730": [0, 0.69444, 0, 0, 0.73334], + "732": [0, 0.69444, 0, 0, 0.55], + "733": [0, 0.69444, 0, 0, 0.55], + "915": [0, 0.69444, 0, 0, 0.58056], + "916": [0, 0.69444, 0, 0, 0.91667], + "920": [0, 0.69444, 0, 0, 0.85556], + "923": [0, 0.69444, 0, 0, 0.67223], + "926": [0, 0.69444, 0, 0, 0.73334], + "928": [0, 0.69444, 0, 0, 0.79445], + "931": [0, 0.69444, 0, 0, 0.79445], + "933": [0, 0.69444, 0, 0, 0.85556], + "934": [0, 0.69444, 0, 0, 0.79445], + "936": [0, 0.69444, 0, 0, 0.85556], + "937": [0, 0.69444, 0, 0, 0.79445], + "8211": [0, 0.45833, 0.03056, 0, 0.55], + "8212": [0, 0.45833, 0.03056, 0, 1.10001], + "8216": [0, 0.69444, 0, 0, 0.30556], + "8217": [0, 0.69444, 0, 0, 0.30556], + "8220": [0, 0.69444, 0, 0, 0.55834], + "8221": [0, 0.69444, 0, 0, 0.55834], + }, + "SansSerif-Italic": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0.05733, 0, 0.31945], + "34": [0, 0.69444, 0.00316, 0, 0.5], + "35": [0.19444, 0.69444, 0.05087, 0, 0.83334], + "36": [0.05556, 0.75, 0.11156, 0, 0.5], + "37": [0.05556, 0.75, 0.03126, 0, 0.83334], + "38": [0, 0.69444, 0.03058, 0, 0.75834], + "39": [0, 0.69444, 0.07816, 0, 0.27778], + "40": [0.25, 0.75, 0.13164, 0, 0.38889], + "41": [0.25, 0.75, 0.02536, 0, 0.38889], + "42": [0, 0.75, 0.11775, 0, 0.5], + "43": [0.08333, 0.58333, 0.02536, 0, 0.77778], + "44": [0.125, 0.08333, 0, 0, 0.27778], + "45": [0, 0.44444, 0.01946, 0, 0.33333], + "46": [0, 0.08333, 0, 0, 0.27778], + "47": [0.25, 0.75, 0.13164, 0, 0.5], + "48": [0, 0.65556, 0.11156, 0, 0.5], + "49": [0, 0.65556, 0.11156, 0, 0.5], + "50": [0, 0.65556, 0.11156, 0, 0.5], + "51": [0, 0.65556, 0.11156, 0, 0.5], + "52": [0, 0.65556, 0.11156, 0, 0.5], + "53": [0, 0.65556, 0.11156, 0, 0.5], + "54": [0, 0.65556, 0.11156, 0, 0.5], + "55": [0, 0.65556, 0.11156, 0, 0.5], + "56": [0, 0.65556, 0.11156, 0, 0.5], + "57": [0, 0.65556, 0.11156, 0, 0.5], + "58": [0, 0.44444, 0.02502, 0, 0.27778], + "59": [0.125, 0.44444, 0.02502, 0, 0.27778], + "61": [-0.13, 0.37, 0.05087, 0, 0.77778], + "63": [0, 0.69444, 0.11809, 0, 0.47222], + "64": [0, 0.69444, 0.07555, 0, 0.66667], + "65": [0, 0.69444, 0, 0, 0.66667], + "66": [0, 0.69444, 0.08293, 0, 0.66667], + "67": [0, 0.69444, 0.11983, 0, 0.63889], + "68": [0, 0.69444, 0.07555, 0, 0.72223], + "69": [0, 0.69444, 0.11983, 0, 0.59722], + "70": [0, 0.69444, 0.13372, 0, 0.56945], + "71": [0, 0.69444, 0.11983, 0, 0.66667], + "72": [0, 0.69444, 0.08094, 0, 0.70834], + "73": [0, 0.69444, 0.13372, 0, 0.27778], + "74": [0, 0.69444, 0.08094, 0, 0.47222], + "75": [0, 0.69444, 0.11983, 0, 0.69445], + "76": [0, 0.69444, 0, 0, 0.54167], + "77": [0, 0.69444, 0.08094, 0, 0.875], + "78": [0, 0.69444, 0.08094, 0, 0.70834], + "79": [0, 0.69444, 0.07555, 0, 0.73611], + "80": [0, 0.69444, 0.08293, 0, 0.63889], + "81": [0.125, 0.69444, 0.07555, 0, 0.73611], + "82": [0, 0.69444, 0.08293, 0, 0.64584], + "83": [0, 0.69444, 0.09205, 0, 0.55556], + "84": [0, 0.69444, 0.13372, 0, 0.68056], + "85": [0, 0.69444, 0.08094, 0, 0.6875], + "86": [0, 0.69444, 0.1615, 0, 0.66667], + "87": [0, 0.69444, 0.1615, 0, 0.94445], + "88": [0, 0.69444, 0.13372, 0, 0.66667], + "89": [0, 0.69444, 0.17261, 0, 0.66667], + "90": [0, 0.69444, 0.11983, 0, 0.61111], + "91": [0.25, 0.75, 0.15942, 0, 0.28889], + "93": [0.25, 0.75, 0.08719, 0, 0.28889], + "94": [0, 0.69444, 0.0799, 0, 0.5], + "95": [0.35, 0.09444, 0.08616, 0, 0.5], + "97": [0, 0.44444, 0.00981, 0, 0.48056], + "98": [0, 0.69444, 0.03057, 0, 0.51667], + "99": [0, 0.44444, 0.08336, 0, 0.44445], + "100": [0, 0.69444, 0.09483, 0, 0.51667], + "101": [0, 0.44444, 0.06778, 0, 0.44445], + "102": [0, 0.69444, 0.21705, 0, 0.30556], + "103": [0.19444, 0.44444, 0.10836, 0, 0.5], + "104": [0, 0.69444, 0.01778, 0, 0.51667], + "105": [0, 0.67937, 0.09718, 0, 0.23889], + "106": [0.19444, 0.67937, 0.09162, 0, 0.26667], + "107": [0, 0.69444, 0.08336, 0, 0.48889], + "108": [0, 0.69444, 0.09483, 0, 0.23889], + "109": [0, 0.44444, 0.01778, 0, 0.79445], + "110": [0, 0.44444, 0.01778, 0, 0.51667], + "111": [0, 0.44444, 0.06613, 0, 0.5], + "112": [0.19444, 0.44444, 0.0389, 0, 0.51667], + "113": [0.19444, 0.44444, 0.04169, 0, 0.51667], + "114": [0, 0.44444, 0.10836, 0, 0.34167], + "115": [0, 0.44444, 0.0778, 0, 0.38333], + "116": [0, 0.57143, 0.07225, 0, 0.36111], + "117": [0, 0.44444, 0.04169, 0, 0.51667], + "118": [0, 0.44444, 0.10836, 0, 0.46111], + "119": [0, 0.44444, 0.10836, 0, 0.68334], + "120": [0, 0.44444, 0.09169, 0, 0.46111], + "121": [0.19444, 0.44444, 0.10836, 0, 0.46111], + "122": [0, 0.44444, 0.08752, 0, 0.43472], + "126": [0.35, 0.32659, 0.08826, 0, 0.5], + "160": [0, 0, 0, 0, 0.25], + "168": [0, 0.67937, 0.06385, 0, 0.5], + "176": [0, 0.69444, 0, 0, 0.73752], + "184": [0.17014, 0, 0, 0, 0.44445], + "305": [0, 0.44444, 0.04169, 0, 0.23889], + "567": [0.19444, 0.44444, 0.04169, 0, 0.26667], + "710": [0, 0.69444, 0.0799, 0, 0.5], + "711": [0, 0.63194, 0.08432, 0, 0.5], + "713": [0, 0.60889, 0.08776, 0, 0.5], + "714": [0, 0.69444, 0.09205, 0, 0.5], + "715": [0, 0.69444, 0, 0, 0.5], + "728": [0, 0.69444, 0.09483, 0, 0.5], + "729": [0, 0.67937, 0.07774, 0, 0.27778], + "730": [0, 0.69444, 0, 0, 0.73752], + "732": [0, 0.67659, 0.08826, 0, 0.5], + "733": [0, 0.69444, 0.09205, 0, 0.5], + "915": [0, 0.69444, 0.13372, 0, 0.54167], + "916": [0, 0.69444, 0, 0, 0.83334], + "920": [0, 0.69444, 0.07555, 0, 0.77778], + "923": [0, 0.69444, 0, 0, 0.61111], + "926": [0, 0.69444, 0.12816, 0, 0.66667], + "928": [0, 0.69444, 0.08094, 0, 0.70834], + "931": [0, 0.69444, 0.11983, 0, 0.72222], + "933": [0, 0.69444, 0.09031, 0, 0.77778], + "934": [0, 0.69444, 0.04603, 0, 0.72222], + "936": [0, 0.69444, 0.09031, 0, 0.77778], + "937": [0, 0.69444, 0.08293, 0, 0.72222], + "8211": [0, 0.44444, 0.08616, 0, 0.5], + "8212": [0, 0.44444, 0.08616, 0, 1.0], + "8216": [0, 0.69444, 0.07816, 0, 0.27778], + "8217": [0, 0.69444, 0.07816, 0, 0.27778], + "8220": [0, 0.69444, 0.14205, 0, 0.5], + "8221": [0, 0.69444, 0.00316, 0, 0.5], + }, + "SansSerif-Regular": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0, 0, 0.31945], + "34": [0, 0.69444, 0, 0, 0.5], + "35": [0.19444, 0.69444, 0, 0, 0.83334], + "36": [0.05556, 0.75, 0, 0, 0.5], + "37": [0.05556, 0.75, 0, 0, 0.83334], + "38": [0, 0.69444, 0, 0, 0.75834], + "39": [0, 0.69444, 0, 0, 0.27778], + "40": [0.25, 0.75, 0, 0, 0.38889], + "41": [0.25, 0.75, 0, 0, 0.38889], + "42": [0, 0.75, 0, 0, 0.5], + "43": [0.08333, 0.58333, 0, 0, 0.77778], + "44": [0.125, 0.08333, 0, 0, 0.27778], + "45": [0, 0.44444, 0, 0, 0.33333], + "46": [0, 0.08333, 0, 0, 0.27778], + "47": [0.25, 0.75, 0, 0, 0.5], + "48": [0, 0.65556, 0, 0, 0.5], + "49": [0, 0.65556, 0, 0, 0.5], + "50": [0, 0.65556, 0, 0, 0.5], + "51": [0, 0.65556, 0, 0, 0.5], + "52": [0, 0.65556, 0, 0, 0.5], + "53": [0, 0.65556, 0, 0, 0.5], + "54": [0, 0.65556, 0, 0, 0.5], + "55": [0, 0.65556, 0, 0, 0.5], + "56": [0, 0.65556, 0, 0, 0.5], + "57": [0, 0.65556, 0, 0, 0.5], + "58": [0, 0.44444, 0, 0, 0.27778], + "59": [0.125, 0.44444, 0, 0, 0.27778], + "61": [-0.13, 0.37, 0, 0, 0.77778], + "63": [0, 0.69444, 0, 0, 0.47222], + "64": [0, 0.69444, 0, 0, 0.66667], + "65": [0, 0.69444, 0, 0, 0.66667], + "66": [0, 0.69444, 0, 0, 0.66667], + "67": [0, 0.69444, 0, 0, 0.63889], + "68": [0, 0.69444, 0, 0, 0.72223], + "69": [0, 0.69444, 0, 0, 0.59722], + "70": [0, 0.69444, 0, 0, 0.56945], + "71": [0, 0.69444, 0, 0, 0.66667], + "72": [0, 0.69444, 0, 0, 0.70834], + "73": [0, 0.69444, 0, 0, 0.27778], + "74": [0, 0.69444, 0, 0, 0.47222], + "75": [0, 0.69444, 0, 0, 0.69445], + "76": [0, 0.69444, 0, 0, 0.54167], + "77": [0, 0.69444, 0, 0, 0.875], + "78": [0, 0.69444, 0, 0, 0.70834], + "79": [0, 0.69444, 0, 0, 0.73611], + "80": [0, 0.69444, 0, 0, 0.63889], + "81": [0.125, 0.69444, 0, 0, 0.73611], + "82": [0, 0.69444, 0, 0, 0.64584], + "83": [0, 0.69444, 0, 0, 0.55556], + "84": [0, 0.69444, 0, 0, 0.68056], + "85": [0, 0.69444, 0, 0, 0.6875], + "86": [0, 0.69444, 0.01389, 0, 0.66667], + "87": [0, 0.69444, 0.01389, 0, 0.94445], + "88": [0, 0.69444, 0, 0, 0.66667], + "89": [0, 0.69444, 0.025, 0, 0.66667], + "90": [0, 0.69444, 0, 0, 0.61111], + "91": [0.25, 0.75, 0, 0, 0.28889], + "93": [0.25, 0.75, 0, 0, 0.28889], + "94": [0, 0.69444, 0, 0, 0.5], + "95": [0.35, 0.09444, 0.02778, 0, 0.5], + "97": [0, 0.44444, 0, 0, 0.48056], + "98": [0, 0.69444, 0, 0, 0.51667], + "99": [0, 0.44444, 0, 0, 0.44445], + "100": [0, 0.69444, 0, 0, 0.51667], + "101": [0, 0.44444, 0, 0, 0.44445], + "102": [0, 0.69444, 0.06944, 0, 0.30556], + "103": [0.19444, 0.44444, 0.01389, 0, 0.5], + "104": [0, 0.69444, 0, 0, 0.51667], + "105": [0, 0.67937, 0, 0, 0.23889], + "106": [0.19444, 0.67937, 0, 0, 0.26667], + "107": [0, 0.69444, 0, 0, 0.48889], + "108": [0, 0.69444, 0, 0, 0.23889], + "109": [0, 0.44444, 0, 0, 0.79445], + "110": [0, 0.44444, 0, 0, 0.51667], + "111": [0, 0.44444, 0, 0, 0.5], + "112": [0.19444, 0.44444, 0, 0, 0.51667], + "113": [0.19444, 0.44444, 0, 0, 0.51667], + "114": [0, 0.44444, 0.01389, 0, 0.34167], + "115": [0, 0.44444, 0, 0, 0.38333], + "116": [0, 0.57143, 0, 0, 0.36111], + "117": [0, 0.44444, 0, 0, 0.51667], + "118": [0, 0.44444, 0.01389, 0, 0.46111], + "119": [0, 0.44444, 0.01389, 0, 0.68334], + "120": [0, 0.44444, 0, 0, 0.46111], + "121": [0.19444, 0.44444, 0.01389, 0, 0.46111], + "122": [0, 0.44444, 0, 0, 0.43472], + "126": [0.35, 0.32659, 0, 0, 0.5], + "160": [0, 0, 0, 0, 0.25], + "168": [0, 0.67937, 0, 0, 0.5], + "176": [0, 0.69444, 0, 0, 0.66667], + "184": [0.17014, 0, 0, 0, 0.44445], + "305": [0, 0.44444, 0, 0, 0.23889], + "567": [0.19444, 0.44444, 0, 0, 0.26667], + "710": [0, 0.69444, 0, 0, 0.5], + "711": [0, 0.63194, 0, 0, 0.5], + "713": [0, 0.60889, 0, 0, 0.5], + "714": [0, 0.69444, 0, 0, 0.5], + "715": [0, 0.69444, 0, 0, 0.5], + "728": [0, 0.69444, 0, 0, 0.5], + "729": [0, 0.67937, 0, 0, 0.27778], + "730": [0, 0.69444, 0, 0, 0.66667], + "732": [0, 0.67659, 0, 0, 0.5], + "733": [0, 0.69444, 0, 0, 0.5], + "915": [0, 0.69444, 0, 0, 0.54167], + "916": [0, 0.69444, 0, 0, 0.83334], + "920": [0, 0.69444, 0, 0, 0.77778], + "923": [0, 0.69444, 0, 0, 0.61111], + "926": [0, 0.69444, 0, 0, 0.66667], + "928": [0, 0.69444, 0, 0, 0.70834], + "931": [0, 0.69444, 0, 0, 0.72222], + "933": [0, 0.69444, 0, 0, 0.77778], + "934": [0, 0.69444, 0, 0, 0.72222], + "936": [0, 0.69444, 0, 0, 0.77778], + "937": [0, 0.69444, 0, 0, 0.72222], + "8211": [0, 0.44444, 0.02778, 0, 0.5], + "8212": [0, 0.44444, 0.02778, 0, 1.0], + "8216": [0, 0.69444, 0, 0, 0.27778], + "8217": [0, 0.69444, 0, 0, 0.27778], + "8220": [0, 0.69444, 0, 0, 0.5], + "8221": [0, 0.69444, 0, 0, 0.5], + }, + "Script-Regular": { + "32": [0, 0, 0, 0, 0.25], + "65": [0, 0.7, 0.22925, 0, 0.80253], + "66": [0, 0.7, 0.04087, 0, 0.90757], + "67": [0, 0.7, 0.1689, 0, 0.66619], + "68": [0, 0.7, 0.09371, 0, 0.77443], + "69": [0, 0.7, 0.18583, 0, 0.56162], + "70": [0, 0.7, 0.13634, 0, 0.89544], + "71": [0, 0.7, 0.17322, 0, 0.60961], + "72": [0, 0.7, 0.29694, 0, 0.96919], + "73": [0, 0.7, 0.19189, 0, 0.80907], + "74": [0.27778, 0.7, 0.19189, 0, 1.05159], + "75": [0, 0.7, 0.31259, 0, 0.91364], + "76": [0, 0.7, 0.19189, 0, 0.87373], + "77": [0, 0.7, 0.15981, 0, 1.08031], + "78": [0, 0.7, 0.3525, 0, 0.9015], + "79": [0, 0.7, 0.08078, 0, 0.73787], + "80": [0, 0.7, 0.08078, 0, 1.01262], + "81": [0, 0.7, 0.03305, 0, 0.88282], + "82": [0, 0.7, 0.06259, 0, 0.85], + "83": [0, 0.7, 0.19189, 0, 0.86767], + "84": [0, 0.7, 0.29087, 0, 0.74697], + "85": [0, 0.7, 0.25815, 0, 0.79996], + "86": [0, 0.7, 0.27523, 0, 0.62204], + "87": [0, 0.7, 0.27523, 0, 0.80532], + "88": [0, 0.7, 0.26006, 0, 0.94445], + "89": [0, 0.7, 0.2939, 0, 0.70961], + "90": [0, 0.7, 0.24037, 0, 0.8212], + "160": [0, 0, 0, 0, 0.25], + }, + "Size1-Regular": { + "32": [0, 0, 0, 0, 0.25], + "40": [0.35001, 0.85, 0, 0, 0.45834], + "41": [0.35001, 0.85, 0, 0, 0.45834], + "47": [0.35001, 0.85, 0, 0, 0.57778], + "91": [0.35001, 0.85, 0, 0, 0.41667], + "92": [0.35001, 0.85, 0, 0, 0.57778], + "93": [0.35001, 0.85, 0, 0, 0.41667], + "123": [0.35001, 0.85, 0, 0, 0.58334], + "125": [0.35001, 0.85, 0, 0, 0.58334], + "160": [0, 0, 0, 0, 0.25], + "710": [0, 0.72222, 0, 0, 0.55556], + "732": [0, 0.72222, 0, 0, 0.55556], + "770": [0, 0.72222, 0, 0, 0.55556], + "771": [0, 0.72222, 0, 0, 0.55556], + "8214": [-0.00099, 0.601, 0, 0, 0.77778], + "8593": [1e-05, 0.6, 0, 0, 0.66667], + "8595": [1e-05, 0.6, 0, 0, 0.66667], + "8657": [1e-05, 0.6, 0, 0, 0.77778], + "8659": [1e-05, 0.6, 0, 0, 0.77778], + "8719": [0.25001, 0.75, 0, 0, 0.94445], + "8720": [0.25001, 0.75, 0, 0, 0.94445], + "8721": [0.25001, 0.75, 0, 0, 1.05556], + "8730": [0.35001, 0.85, 0, 0, 1.0], + "8739": [-0.00599, 0.606, 0, 0, 0.33333], + "8741": [-0.00599, 0.606, 0, 0, 0.55556], + "8747": [0.30612, 0.805, 0.19445, 0, 0.47222], + "8748": [0.306, 0.805, 0.19445, 0, 0.47222], + "8749": [0.306, 0.805, 0.19445, 0, 0.47222], + "8750": [0.30612, 0.805, 0.19445, 0, 0.47222], + "8896": [0.25001, 0.75, 0, 0, 0.83334], + "8897": [0.25001, 0.75, 0, 0, 0.83334], + "8898": [0.25001, 0.75, 0, 0, 0.83334], + "8899": [0.25001, 0.75, 0, 0, 0.83334], + "8968": [0.35001, 0.85, 0, 0, 0.47222], + "8969": [0.35001, 0.85, 0, 0, 0.47222], + "8970": [0.35001, 0.85, 0, 0, 0.47222], + "8971": [0.35001, 0.85, 0, 0, 0.47222], + "9168": [-0.00099, 0.601, 0, 0, 0.66667], + "10216": [0.35001, 0.85, 0, 0, 0.47222], + "10217": [0.35001, 0.85, 0, 0, 0.47222], + "10752": [0.25001, 0.75, 0, 0, 1.11111], + "10753": [0.25001, 0.75, 0, 0, 1.11111], + "10754": [0.25001, 0.75, 0, 0, 1.11111], + "10756": [0.25001, 0.75, 0, 0, 0.83334], + "10758": [0.25001, 0.75, 0, 0, 0.83334], + }, + "Size2-Regular": { + "32": [0, 0, 0, 0, 0.25], + "40": [0.65002, 1.15, 0, 0, 0.59722], + "41": [0.65002, 1.15, 0, 0, 0.59722], + "47": [0.65002, 1.15, 0, 0, 0.81111], + "91": [0.65002, 1.15, 0, 0, 0.47222], + "92": [0.65002, 1.15, 0, 0, 0.81111], + "93": [0.65002, 1.15, 0, 0, 0.47222], + "123": [0.65002, 1.15, 0, 0, 0.66667], + "125": [0.65002, 1.15, 0, 0, 0.66667], + "160": [0, 0, 0, 0, 0.25], + "710": [0, 0.75, 0, 0, 1.0], + "732": [0, 0.75, 0, 0, 1.0], + "770": [0, 0.75, 0, 0, 1.0], + "771": [0, 0.75, 0, 0, 1.0], + "8719": [0.55001, 1.05, 0, 0, 1.27778], + "8720": [0.55001, 1.05, 0, 0, 1.27778], + "8721": [0.55001, 1.05, 0, 0, 1.44445], + "8730": [0.65002, 1.15, 0, 0, 1.0], + "8747": [0.86225, 1.36, 0.44445, 0, 0.55556], + "8748": [0.862, 1.36, 0.44445, 0, 0.55556], + "8749": [0.862, 1.36, 0.44445, 0, 0.55556], + "8750": [0.86225, 1.36, 0.44445, 0, 0.55556], + "8896": [0.55001, 1.05, 0, 0, 1.11111], + "8897": [0.55001, 1.05, 0, 0, 1.11111], + "8898": [0.55001, 1.05, 0, 0, 1.11111], + "8899": [0.55001, 1.05, 0, 0, 1.11111], + "8968": [0.65002, 1.15, 0, 0, 0.52778], + "8969": [0.65002, 1.15, 0, 0, 0.52778], + "8970": [0.65002, 1.15, 0, 0, 0.52778], + "8971": [0.65002, 1.15, 0, 0, 0.52778], + "10216": [0.65002, 1.15, 0, 0, 0.61111], + "10217": [0.65002, 1.15, 0, 0, 0.61111], + "10752": [0.55001, 1.05, 0, 0, 1.51112], + "10753": [0.55001, 1.05, 0, 0, 1.51112], + "10754": [0.55001, 1.05, 0, 0, 1.51112], + "10756": [0.55001, 1.05, 0, 0, 1.11111], + "10758": [0.55001, 1.05, 0, 0, 1.11111], + }, + "Size3-Regular": { + "32": [0, 0, 0, 0, 0.25], + "40": [0.95003, 1.45, 0, 0, 0.73611], + "41": [0.95003, 1.45, 0, 0, 0.73611], + "47": [0.95003, 1.45, 0, 0, 1.04445], + "91": [0.95003, 1.45, 0, 0, 0.52778], + "92": [0.95003, 1.45, 0, 0, 1.04445], + "93": [0.95003, 1.45, 0, 0, 0.52778], + "123": [0.95003, 1.45, 0, 0, 0.75], + "125": [0.95003, 1.45, 0, 0, 0.75], + "160": [0, 0, 0, 0, 0.25], + "710": [0, 0.75, 0, 0, 1.44445], + "732": [0, 0.75, 0, 0, 1.44445], + "770": [0, 0.75, 0, 0, 1.44445], + "771": [0, 0.75, 0, 0, 1.44445], + "8730": [0.95003, 1.45, 0, 0, 1.0], + "8968": [0.95003, 1.45, 0, 0, 0.58334], + "8969": [0.95003, 1.45, 0, 0, 0.58334], + "8970": [0.95003, 1.45, 0, 0, 0.58334], + "8971": [0.95003, 1.45, 0, 0, 0.58334], + "10216": [0.95003, 1.45, 0, 0, 0.75], + "10217": [0.95003, 1.45, 0, 0, 0.75], + }, + "Size4-Regular": { + "32": [0, 0, 0, 0, 0.25], + "40": [1.25003, 1.75, 0, 0, 0.79167], + "41": [1.25003, 1.75, 0, 0, 0.79167], + "47": [1.25003, 1.75, 0, 0, 1.27778], + "91": [1.25003, 1.75, 0, 0, 0.58334], + "92": [1.25003, 1.75, 0, 0, 1.27778], + "93": [1.25003, 1.75, 0, 0, 0.58334], + "123": [1.25003, 1.75, 0, 0, 0.80556], + "125": [1.25003, 1.75, 0, 0, 0.80556], + "160": [0, 0, 0, 0, 0.25], + "710": [0, 0.825, 0, 0, 1.8889], + "732": [0, 0.825, 0, 0, 1.8889], + "770": [0, 0.825, 0, 0, 1.8889], + "771": [0, 0.825, 0, 0, 1.8889], + "8730": [1.25003, 1.75, 0, 0, 1.0], + "8968": [1.25003, 1.75, 0, 0, 0.63889], + "8969": [1.25003, 1.75, 0, 0, 0.63889], + "8970": [1.25003, 1.75, 0, 0, 0.63889], + "8971": [1.25003, 1.75, 0, 0, 0.63889], + "9115": [0.64502, 1.155, 0, 0, 0.875], + "9116": [1e-05, 0.6, 0, 0, 0.875], + "9117": [0.64502, 1.155, 0, 0, 0.875], + "9118": [0.64502, 1.155, 0, 0, 0.875], + "9119": [1e-05, 0.6, 0, 0, 0.875], + "9120": [0.64502, 1.155, 0, 0, 0.875], + "9121": [0.64502, 1.155, 0, 0, 0.66667], + "9122": [-0.00099, 0.601, 0, 0, 0.66667], + "9123": [0.64502, 1.155, 0, 0, 0.66667], + "9124": [0.64502, 1.155, 0, 0, 0.66667], + "9125": [-0.00099, 0.601, 0, 0, 0.66667], + "9126": [0.64502, 1.155, 0, 0, 0.66667], + "9127": [1e-05, 0.9, 0, 0, 0.88889], + "9128": [0.65002, 1.15, 0, 0, 0.88889], + "9129": [0.90001, 0, 0, 0, 0.88889], + "9130": [0, 0.3, 0, 0, 0.88889], + "9131": [1e-05, 0.9, 0, 0, 0.88889], + "9132": [0.65002, 1.15, 0, 0, 0.88889], + "9133": [0.90001, 0, 0, 0, 0.88889], + "9143": [0.88502, 0.915, 0, 0, 1.05556], + "10216": [1.25003, 1.75, 0, 0, 0.80556], + "10217": [1.25003, 1.75, 0, 0, 0.80556], + "57344": [-0.00499, 0.605, 0, 0, 1.05556], + "57345": [-0.00499, 0.605, 0, 0, 1.05556], + "57680": [0, 0.12, 0, 0, 0.45], + "57681": [0, 0.12, 0, 0, 0.45], + "57682": [0, 0.12, 0, 0, 0.45], + "57683": [0, 0.12, 0, 0, 0.45], + }, + "Typewriter-Regular": { + "32": [0, 0, 0, 0, 0.525], + "33": [0, 0.61111, 0, 0, 0.525], + "34": [0, 0.61111, 0, 0, 0.525], + "35": [0, 0.61111, 0, 0, 0.525], + "36": [0.08333, 0.69444, 0, 0, 0.525], + "37": [0.08333, 0.69444, 0, 0, 0.525], + "38": [0, 0.61111, 0, 0, 0.525], + "39": [0, 0.61111, 0, 0, 0.525], + "40": [0.08333, 0.69444, 0, 0, 0.525], + "41": [0.08333, 0.69444, 0, 0, 0.525], + "42": [0, 0.52083, 0, 0, 0.525], + "43": [-0.08056, 0.53055, 0, 0, 0.525], + "44": [0.13889, 0.125, 0, 0, 0.525], + "45": [-0.08056, 0.53055, 0, 0, 0.525], + "46": [0, 0.125, 0, 0, 0.525], + "47": [0.08333, 0.69444, 0, 0, 0.525], + "48": [0, 0.61111, 0, 0, 0.525], + "49": [0, 0.61111, 0, 0, 0.525], + "50": [0, 0.61111, 0, 0, 0.525], + "51": [0, 0.61111, 0, 0, 0.525], + "52": [0, 0.61111, 0, 0, 0.525], + "53": [0, 0.61111, 0, 0, 0.525], + "54": [0, 0.61111, 0, 0, 0.525], + "55": [0, 0.61111, 0, 0, 0.525], + "56": [0, 0.61111, 0, 0, 0.525], + "57": [0, 0.61111, 0, 0, 0.525], + "58": [0, 0.43056, 0, 0, 0.525], + "59": [0.13889, 0.43056, 0, 0, 0.525], + "60": [-0.05556, 0.55556, 0, 0, 0.525], + "61": [-0.19549, 0.41562, 0, 0, 0.525], + "62": [-0.05556, 0.55556, 0, 0, 0.525], + "63": [0, 0.61111, 0, 0, 0.525], + "64": [0, 0.61111, 0, 0, 0.525], + "65": [0, 0.61111, 0, 0, 0.525], + "66": [0, 0.61111, 0, 0, 0.525], + "67": [0, 0.61111, 0, 0, 0.525], + "68": [0, 0.61111, 0, 0, 0.525], + "69": [0, 0.61111, 0, 0, 0.525], + "70": [0, 0.61111, 0, 0, 0.525], + "71": [0, 0.61111, 0, 0, 0.525], + "72": [0, 0.61111, 0, 0, 0.525], + "73": [0, 0.61111, 0, 0, 0.525], + "74": [0, 0.61111, 0, 0, 0.525], + "75": [0, 0.61111, 0, 0, 0.525], + "76": [0, 0.61111, 0, 0, 0.525], + "77": [0, 0.61111, 0, 0, 0.525], + "78": [0, 0.61111, 0, 0, 0.525], + "79": [0, 0.61111, 0, 0, 0.525], + "80": [0, 0.61111, 0, 0, 0.525], + "81": [0.13889, 0.61111, 0, 0, 0.525], + "82": [0, 0.61111, 0, 0, 0.525], + "83": [0, 0.61111, 0, 0, 0.525], + "84": [0, 0.61111, 0, 0, 0.525], + "85": [0, 0.61111, 0, 0, 0.525], + "86": [0, 0.61111, 0, 0, 0.525], + "87": [0, 0.61111, 0, 0, 0.525], + "88": [0, 0.61111, 0, 0, 0.525], + "89": [0, 0.61111, 0, 0, 0.525], + "90": [0, 0.61111, 0, 0, 0.525], + "91": [0.08333, 0.69444, 0, 0, 0.525], + "92": [0.08333, 0.69444, 0, 0, 0.525], + "93": [0.08333, 0.69444, 0, 0, 0.525], + "94": [0, 0.61111, 0, 0, 0.525], + "95": [0.09514, 0, 0, 0, 0.525], + "96": [0, 0.61111, 0, 0, 0.525], + "97": [0, 0.43056, 0, 0, 0.525], + "98": [0, 0.61111, 0, 0, 0.525], + "99": [0, 0.43056, 0, 0, 0.525], + "100": [0, 0.61111, 0, 0, 0.525], + "101": [0, 0.43056, 0, 0, 0.525], + "102": [0, 0.61111, 0, 0, 0.525], + "103": [0.22222, 0.43056, 0, 0, 0.525], + "104": [0, 0.61111, 0, 0, 0.525], + "105": [0, 0.61111, 0, 0, 0.525], + "106": [0.22222, 0.61111, 0, 0, 0.525], + "107": [0, 0.61111, 0, 0, 0.525], + "108": [0, 0.61111, 0, 0, 0.525], + "109": [0, 0.43056, 0, 0, 0.525], + "110": [0, 0.43056, 0, 0, 0.525], + "111": [0, 0.43056, 0, 0, 0.525], + "112": [0.22222, 0.43056, 0, 0, 0.525], + "113": [0.22222, 0.43056, 0, 0, 0.525], + "114": [0, 0.43056, 0, 0, 0.525], + "115": [0, 0.43056, 0, 0, 0.525], + "116": [0, 0.55358, 0, 0, 0.525], + "117": [0, 0.43056, 0, 0, 0.525], + "118": [0, 0.43056, 0, 0, 0.525], + "119": [0, 0.43056, 0, 0, 0.525], + "120": [0, 0.43056, 0, 0, 0.525], + "121": [0.22222, 0.43056, 0, 0, 0.525], + "122": [0, 0.43056, 0, 0, 0.525], + "123": [0.08333, 0.69444, 0, 0, 0.525], + "124": [0.08333, 0.69444, 0, 0, 0.525], + "125": [0.08333, 0.69444, 0, 0, 0.525], + "126": [0, 0.61111, 0, 0, 0.525], + "127": [0, 0.61111, 0, 0, 0.525], + "160": [0, 0, 0, 0, 0.525], + "176": [0, 0.61111, 0, 0, 0.525], + "184": [0.19445, 0, 0, 0, 0.525], + "305": [0, 0.43056, 0, 0, 0.525], + "567": [0.22222, 0.43056, 0, 0, 0.525], + "711": [0, 0.56597, 0, 0, 0.525], + "713": [0, 0.56555, 0, 0, 0.525], + "714": [0, 0.61111, 0, 0, 0.525], + "715": [0, 0.61111, 0, 0, 0.525], + "728": [0, 0.61111, 0, 0, 0.525], + "730": [0, 0.61111, 0, 0, 0.525], + "770": [0, 0.61111, 0, 0, 0.525], + "771": [0, 0.61111, 0, 0, 0.525], + "776": [0, 0.61111, 0, 0, 0.525], + "915": [0, 0.61111, 0, 0, 0.525], + "916": [0, 0.61111, 0, 0, 0.525], + "920": [0, 0.61111, 0, 0, 0.525], + "923": [0, 0.61111, 0, 0, 0.525], + "926": [0, 0.61111, 0, 0, 0.525], + "928": [0, 0.61111, 0, 0, 0.525], + "931": [0, 0.61111, 0, 0, 0.525], + "933": [0, 0.61111, 0, 0, 0.525], + "934": [0, 0.61111, 0, 0, 0.525], + "936": [0, 0.61111, 0, 0, 0.525], + "937": [0, 0.61111, 0, 0, 0.525], + "8216": [0, 0.61111, 0, 0, 0.525], + "8217": [0, 0.61111, 0, 0, 0.525], + "8242": [0, 0.61111, 0, 0, 0.525], + "9251": [0.11111, 0.21944, 0, 0, 0.525], + }, +}; diff --git a/node_modules/react-katex/node_modules/katex/src/fonts/Makefile b/node_modules/react-katex/node_modules/katex/src/fonts/Makefile new file mode 100644 index 0000000..83c22db --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/fonts/Makefile @@ -0,0 +1,139 @@ +#!gmake +# +# Version: Apache License 2.0 +# +# Copyright (c) 2013 MathJax Project +# Copyright (c) 2013 The MathJax Consortium +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +CUSTOM=custom.cfg + +-include $(CUSTOM) + +MFTRACE_MODIFIED=lib/mftrace-modified + +all: config fonts + +$(CUSTOM): + @cp default.cfg $(CUSTOM); + +$(CUSTOM).pl: $(CUSTOM) + @echo "Creating Perl config file..." + @cp $(CUSTOM) $(CUSTOM).pl + @echo >> $(CUSTOM).pl # ensure that the config file ends by a new line + @echo "MFTRACE_PATH=`$(WHICH) $(MFTRACE)`" >> $(CUSTOM).pl + @$(SED) -i "s|^\([A-Z_0-9]*\)=\(.*\)|$$\1='\2';|" $(CUSTOM).pl + @echo "1;" >> $(CUSTOM).pl + +.PHONY: config +config: $(CUSTOM).pl + +blacker: $(MFTRACE_MODIFIED) +$(MFTRACE_MODIFIED): + $(PERL) -I. makeBlacker 15 # values between 10 and 30 seem best + +pfa: $(MFTRACE_MODIFIED) + @echo "cmr10" + $(PYTHON) $(MFTRACE_MODIFIED) --magnification 1000 --simplify cmr10 + + @echo "cmmi10" + $(PYTHON) $(MFTRACE_MODIFIED) --magnification 1000 --encoding $(TETEXENCODING)/aae443f0.enc --simplify cmmi10 + + @echo "cmsy10" + $(PYTHON) $(MFTRACE_MODIFIED) --magnification 1000 --encoding $(TETEXENCODING)/10037936.enc --simplify cmsy10 + + @echo "cmex10" + $(PYTHON) $(MFTRACE_MODIFIED) --magnification 1000 --simplify cmex10 + + @echo "cmbx10" + $(PYTHON) $(MFTRACE_MODIFIED) --magnification 1000 --simplify cmbx10 + + @echo "cmbxti10" + $(PYTHON) $(MFTRACE_MODIFIED) --magnification 1000 --simplify cmbxti10 + + @echo "cmti10" + $(PYTHON) $(MFTRACE_MODIFIED) --magnification 1000 --simplify cmti10 + + @echo "msam10" + $(PYTHON) $(MFTRACE_MODIFIED) --magnification 1000 --simplify --encoding $(TETEXENCODING)/10037936.enc msam10 + + @echo "msbm10" + $(PYTHON) $(MFTRACE_MODIFIED) --magnification 1000 --simplify --encoding $(TETEXENCODING)/10037936.enc msbm10 + + @echo "cmmib10" + $(PYTHON) $(MFTRACE_MODIFIED) --magnification 1000 --encoding $(TETEXENCODING)/aae443f0.enc --simplify cmmib10 + + @echo "cmbsy10" + $(PYTHON) $(MFTRACE_MODIFIED) --magnification 1000 --encoding $(TETEXENCODING)/10037936.enc --simplify cmbsy10 + + @echo "cmtt10" + $(PYTHON) $(MFTRACE_MODIFIED) --magnification 1000 --simplify cmtt10 + + @echo "cmss10" + $(PYTHON) $(MFTRACE_MODIFIED) --magnification 1000 --simplify cmss10 + @echo "cmssi10" + $(PYTHON) $(MFTRACE_MODIFIED) --magnification 1000 --simplify cmssi10 + @echo "cmssbx10" + $(PYTHON) $(MFTRACE_MODIFIED) --magnification 1000 --simplify cmssbx10 + + @echo "eufm10" + cp "`$(KPSEWHICH) eufm10.pfb`" eufm10.pfb + @echo "eufb10" + cp "`$(KPSEWHICH) eufb10.pfb`" eufb10.pfb + + # echo "eusm10" + # $(PYTHON) $(MFTRACE_MODIFIED) --magnification 1000 --simplify eusm10 + # echo "eusb10" + # $(PYTHON) $(MFTRACE_MODIFIED) --magnification 1000 --simplify eusb10 + + @echo "rsfs10" + $(PYTHON) $(MFTRACE_MODIFIED) --magnification 1000 --simplify --encoding $(BASEENCODING)/tex256.enc rsfs10 + + mkdir -p pfa + rm -f pfa/* + mv *.pfa pfa + mv *.pfb pfa + +ff: pfa + mkdir -p ff otf + rm -f ff/* otf/* + $(PERL) -I. makeFF + +.PHONY: fonts +fonts: ff + mkdir -p ttf woff woff2 + rm -f ttf/* woff/* woff2/* + + @for file in `ls ff/*.ff | $(SED) 's|ff/\(.*\)\.ff|\1|'`; do \ + echo ""; \ + echo $$file; \ + $(FONTFORGE) -lang=ff -script ff/$$file.ff; \ + \ + echo "Hinting $$file"; \ + if echo "$$file" | $(GREP) -q -e "Size[1-4]" -e "Typewriter"; then \ + $(TTFAUTOHINT) -f none -S --windows-compatibility --symbol ttf/$$file.ttf ttf/$$file.ttf.hinted; \ + else \ + $(TTFAUTOHINT) -f none -S --windows-compatibility ttf/$$file.ttf ttf/$$file.ttf.hinted; \ + fi; \ + mv ttf/$$file.ttf.hinted ttf/$$file.ttf; \ + \ + echo "Generating $$file..."; \ + $(PYTHON) generate_fonts.py ttf/$$file.ttf; \ + done + +clean: + rm -f $(CUSTOM).pl + rm -f $(MFTRACE_MODIFIED) lib/blacker.mf + rm -rf pfa ff otf ttf woff woff2 diff --git a/node_modules/react-katex/node_modules/katex/src/fonts/default.cfg b/node_modules/react-katex/node_modules/katex/src/fonts/default.cfg new file mode 100644 index 0000000..2c39c31 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/fonts/default.cfg @@ -0,0 +1,20 @@ +# Note: paths should be absolute, unless they point to programs in your $PATH. + +##### Standard programs ##### +GREP=grep +PERL=perl +PYTHON=python3 +SED=sed +WHICH=which +KPSEWHICH=kpsewhich + +##### Font tools ##### +# Most of the tools below are standard and should be available from your package manager. +FONTFORGE=fontforge +MFTRACE=mftrace +TTX=ttx +TTFAUTOHINT=ttfautohint + +##### TeXLive Encoding +TETEXENCODING=/usr/share/texlive/texmf-texlive/fonts/enc/dvips/tetex/ +BASEENCODING=/usr/share/texlive/texmf-texlive/fonts/enc/dvips/base/ diff --git a/node_modules/react-katex/node_modules/katex/src/fonts/generate_fonts.py b/node_modules/react-katex/node_modules/katex/src/fonts/generate_fonts.py new file mode 100644 index 0000000..d606b82 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/fonts/generate_fonts.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python3 + +import sys +import os +import json + +from fontTools.ttLib import TTFont, sfnt +from fontTools.misc.timeTools import timestampNow +sfnt.USE_ZOPFLI = True + +if len(sys.argv) < 2: + print("Usage: %s " % sys.argv[0]) + sys.exit(1) + +font_file = sys.argv[1] +font_name = os.path.splitext(os.path.basename(font_file))[0] + + +font = TTFont(font_file, recalcBBoxes=False, recalcTimestamp=False) + +# fix timestamp to the epoch +font['head'].created = 0 +font['head'].modified = 0 + +# remove fontforge timestamps +if 'FFTM' in font: + del font['FFTM'] + +# remove redundant GDEF table +if 'GDEF' in font: + del font['GDEF'] + +# remove Macintosh table +# https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6cmap.html +font['name'].names = [record for record in font['name'].names if record.platformID != 1] +font['cmap'].tables = [table for table in font['cmap'].tables if table.platformID != 1] + +# fix OS/2 and hhea metrics +glyf = font['glyf'] +ascent = int(max(glyf[c].yMax for c in font.getGlyphOrder() if hasattr(glyf[c], "yMax"))) +descent = -int(min(glyf[c].yMin for c in font.getGlyphOrder() if hasattr(glyf[c], "yMin"))) + +font['OS/2'].usWinAscent = ascent +font['OS/2'].usWinDescent = descent + +font['hhea'].ascent = ascent +font['hhea'].descent = -descent + +# save TTF +font.save(font_file, reorderTables=None) + +# save WOFF +font.flavor = 'woff' +font.save(os.path.join('woff', font_name + '.woff'), reorderTables=None) + +# save WOFF2 +font.flavor = 'woff2' +font.save(os.path.join('woff2', font_name + '.woff2'), reorderTables=None) diff --git a/node_modules/react-katex/node_modules/katex/src/fonts/lib/Extra.otf b/node_modules/react-katex/node_modules/katex/src/fonts/lib/Extra.otf new file mode 100644 index 0000000..e1c84f8 Binary files /dev/null and b/node_modules/react-katex/node_modules/katex/src/fonts/lib/Extra.otf differ diff --git a/node_modules/react-katex/node_modules/katex/src/fonts/lib/Space.ttx b/node_modules/react-katex/node_modules/katex/src/fonts/lib/Space.ttx new file mode 100644 index 0000000..cfed4af --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/fonts/lib/Space.ttx @@ -0,0 +1,234 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Copyright (c) 2009-2010 Design Science, Inc. +Copyright (c) 2014-2018 Khan Academy + + + *NAME* + + + *WEIGHT_S* + + + FontForge 2.0 : *NAME*-*WEIGHT* + + + *NAME*-*WEIGHT* + + + Version 1.1 + + + *NAME*-*WEIGHT* + + + Copyright (c) 2009-2010, Design Science, Inc. (<www.mathjax.org>) +Copyright (c) 2014-2018 Khan Academy (<www.khanacademy.org>), +with Reserved Font Name *NAME*. + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license available with a FAQ at: +http://scripts.sil.org/OFL + + + http://scripts.sil.org/OFL + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 50 433 50 hstem + 50 50 50 50 vstem + 50 hmoveto + 150 533 -150 hlineto + 50 -483 rmoveto + 433 50 -433 vlineto + endchar + + + endchar + + + endchar + + + + + + + + + + + + + + + + diff --git a/node_modules/react-katex/node_modules/katex/src/fonts/makeBlacker b/node_modules/react-katex/node_modules/katex/src/fonts/makeBlacker new file mode 100644 index 0000000..69b0737 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/fonts/makeBlacker @@ -0,0 +1,49 @@ +#! /usr/bin/perl + +# Creates the metafont file needed for darker copies of the TeX fonts, +# and modifies mftrace to use it. +# +# Usage: ./makeBlacker blackness + +require "custom.cfg.pl"; + +$blacker = shift; +unless ($blacker) { + print stderr "Usage: ./makeBlacker blackness\n"; + exit; +} + +sub editMftrace { + my $oldMFTRACE = $MFTRACE_PATH; + $MFTRACE = "./lib/mftrace-modified"; + print "Editing mftrace\n"; + open(MFT,$oldMFTRACE) || die "Can't read '$oldMFTRACE': $!\n"; + my $MFT = join("",); + close(MFT); + $MFT =~ s!r"mf '\\mode:=(?:[^;]*)(; [^"]*)"!r"""mf '\\smode:="lib/blacker.mf"$1"""!; + open(MFT,">$MFTRACE") || die "Can't write '$MFTRACE': $!\n"; + print MFT $MFT; + close(MFT); + chmod 0755, $MFTRACE; +} + +sub makeBlackerMF { + my $blacker = shift; + print "Using blacker = $blacker\n"; + open(BLACKER,">lib/blacker.mf") || die "Can't write 'lib/blacker.mf': $!\n"; + print BLACKER << " END"; + proofing:=0; + fontmaking:=1; + tracingtitles:=0; + pixels_per_inch:=1200; + blacker:=$blacker; + fillin:=0; + o_correction:=1; + END + close(BLACKER); +} + +editMftrace(); +makeBlackerMF($blacker); + +1; diff --git a/node_modules/react-katex/node_modules/katex/src/fonts/makeFF b/node_modules/react-katex/node_modules/katex/src/fonts/makeFF new file mode 100644 index 0000000..606d5fd --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/fonts/makeFF @@ -0,0 +1,2005 @@ +#! /usr/bin/perl + +# Creates the FontForge files needed to create the +# KaTeX fonts from the TeX source files, constructing some +# glyphs from two or more parts, when needed. +# +# Usage: ./makeFF + +require "custom.cfg.pl"; + +######################################################################### + +$map{cmr10} = { + "Main-Regular" => [ + [0,1] => 0x393, # \Gamma, \Delta + 2 => 0x398, # \Theta + 3 => 0x39B, # \Lambda + 4 => 0x39E, # \Xi + 5 => 0x3A0, # \Pi + 6 => 0x3A3, # \Sigma + [7,8] => 0x3A5, # \Upsilon, \Phi + [9,0xA] => 0x3A8, # \Psi, \Omega + + 0x10 => 0x131, # \i + 0x11 => 0x237, # \j + 0x12 => 0x2CB, # \grave + 0x13 => 0x2CA, # \acute + 0x14 => 0x2C7, # \check + 0x15 => 0x2D8, # \breve + 0x16 => 0x2C9, # \bar + 0x17 => [0xB0,-125,0], # \degree + 0x17 => 0x02DA, # \r, ring above + 0x18 => 0xB8, # \c, cedilla + + [0x21,0x2F] => 0x21, # !, ", #, $, %, &, ', (, ), *, +, comma, -, ., / + 0x22 => 0x201D, # " + 0x27 => 0x2019, # ' + [0x30,0x39] => 0x30, # 0-9 + [0x3A,0x3B] => 0x3A, # :, ; + 0x3D => 0x3D, # = + [0x3F,0x40] => 0x3F, # ?, @ + [0x41,0x5A] => 0x41, # A-Z + 0x5B => 0x5B, # [ + 0x5C => 0x201C, # `` + [0x5D,0x5E] => 0x5D, # ], ^ + 0x5E => 0x2C6, # \hat + 0x5F => 0x2D9, # \dot + 0x60 => 0x2018, # ` + [0x61,0x7A] => 0x61, # a-z + [0x7B,0x7C] => 0x2013, # \endash, \emdash + 0x7B => [0x5F,0,-310], # underline + 0x7D => 0x2DD, # double acute + 0x7E => [0x7E,0,-350], # ~ + 0x7E => 0x2DC, # \tilde + 0x7F => 0xA8, # \ddot + 0x19 => 0xDF, # sharp S + 0x1A => 0xE6, # ae ligature + 0x1B => 0x153, # oe ligature + 0x1C => 0xF8, # o with slash + 0x1D => 0xC6, # AE ligature + 0x1E => 0x152, # OE ligature + 0x1F => 0xD8, # O with slash + ], +}; + +$map{cmmi10} = { + "Math-Italic" => [ + [0,1] => 0x393, # \Gamma, \Delta + 2 => 0x398, # \Theta + 3 => 0x39B, # \Lambda + 4 => 0x39E, # \Xi + 5 => 0x3A0, # \Pi + 6 => 0x3A3, # \Sigma + [7,8] => 0x3A5, # \Upsilon, \Phi + [9,0xA] => 0x3A8, # \Psi, \Omega + + [0xB,0xE] => 0x3B1, # \alpha, \beta, \gamma, \delta + 0xF => 0x3F5, # \elpsilon + [0x10,0x18] => 0x3B6, # \zeta, \eta, \theta, \iota, \kappa, \lambda, \mu, \nu, \xi + [0x19,0x1A] => 0x3C0, # \pi, \rho + [0x1B,0x1D] => 0x3C3, # \sigma, \tau, \upsilon + 0x1E => 0x3D5, # \phi + [0x1F,0x21] => 0x3C7, # \chi, \psi, \omega + 0x22 => 0x3B5, # \varepsilon + 0x23 => 0x3D1, # \vartheta + 0x24 => 0x3D6, # \varpi + 0x25 => 0x3F1, # \varrho + 0x26 => 0x3C2, # \varsigma + 0x27 => 0x3C6, # \varphi + + [0x41,0x5A] => 0x41, # A-Z + [0x61,0x7A] => 0x61, # a - z + [0x30,0x39] => 0x30, # Oldstyle 0-9 + + 0x6F => 0x3BF, # omicron + 0x7B => 0xE131, # \imath (These differ from \i and \j, so use PUA character) + 0x7C => 0xE237, # \jmath + ], + + "Main-Regular" => [ + 0x28 => 0x21BC, # \leftharpoonup + 0x29 => 0x21BD, # \leftharpoondown + 0x2A => 0x21C0, # \rightharpoonup + 0x2B => 0x21C1, # \rightharpoondown + + 0x2E => 0x25B9, # \triangleright + 0x2F => 0x25C3, # \triangleleft + + 0x3A => 0x2E, # . + 0x3B => 0x2C, # , + 0x3C => 0x3C, # < + 0x3D => 0x2215, # / + 0x3E => 0x3E, # > + 0x3F => 0x22C6, # \star + 0x40 => 0x2202, # \partial + + [0x5B,0x5D] => 0x266D, # \flat, \natural, \sharp + 0x5E => 0x2323, # \smile + 0x5F => 0x2322, # \frown + 0x60 => 0x2113, # \ell + + 0x7D => 0x2118, # \wp + 0x7E => [0x20D7,-653,0],# \vec + ], +}; + +$map{cmsy10} = { + "Main-Regular" => [ + [0,1] => 0x2212, # - + 1 => 0x22C5, # \cdot + 2 => 0xD7, # \times + 3 => 0x2217, # \ast + 4 => 0xF7, # \div + 5 => 0x22C4, # \diamond + 6 => 0xB1, # \pm + 7 => 0x2213, # \mp + [8,0xC] => 0x2295, # \oplus, \ominus, \otimes, \oslash, \odot + 0xD => 0x25EF, # \bigcirc + [0xE,0xF] => 0x2218, # \circ, \bullet + + 0x10 => 0x224D, # \asymp + 0x11 => 0x2261, # \equiv + [0x12,0x13] => 0x2286, # \subseteq, \supseteq + [0x14,0x15] => 0x2264, # \leq, \geq + [0x16,0x17] => 0x2AAF, # \preceq, \succeq + 0x18 => 0x223C, # \sim + 0x19 => 0x2248, # \approx + [0x1A,0x1B] => 0x2282, # \subset, \supset + [0x1C,0x1D] => 0x226A, # \ll, \gg + [0x1E,0x1F] => 0x227A, # \prec, \succ + + 0x20 => 0x2190, # \leftarrow + 0x21 => 0x2192, # \rightarrow + 0x22 => 0x2191, # \uparrow + 0x23 => 0x2193, # \downarrow + 0x24 => 0x2194, # \leftrightarrow + 0x25 => 0x2197, # \nearrow + 0x26 => 0x2198, # \searrow + 0x27 => 0x2243, # \simeq + + 0x28 => 0x21D0, # \Leftarrow + 0x29 => 0x21D2, # \Rightarrow + 0x2A => 0x21D1, # \Uparrow + 0x2B => 0x21D3, # \Downarrow + 0x2C => 0x21D4, # \Leftrightarrow + 0x2D => 0x2196, # \nwarrow + 0x2E => 0x2199, # \swarrow + 0x2F => 0x221D, # \propto + + 0x30 => 0x2032, # \prime + 0x31 => 0x221E, # \infty + 0x32 => 0x2208, # \in + 0x33 => 0x220B, # \ni + 0x34 => 0x25B3, # \bigtriangleup and \triangle + 0x35 => 0x25BD, # \bigtriangledown + 0x36 => 0xE020, # \not (U+0338 COMBINING LONG SOLIDUS OVERLAY would + # be most natural, but we don't use a negative + # leading space, so use PUA character) + + 0x38 => 0x2200, # \forall + 0x39 => 0x2203, # \exists + 0x3A => 0xAC, # \neg + 0x3B => 0x2205, # \emptyset + 0x3C => 0x211C, # \Re + 0x3D => 0x2111, # \Im + 0x3E => 0x22A4, # \top + 0x3F => 0x22A5, # \bot + + 0x40 => 0x2135, # \aleph + + 0x5B => 0x222A, # \cup + 0x5C => 0x2229, # \cap + 0x5D => 0x228E, # \uplus + [0x5E,0x5F] => 0x2227, # \wedge, \vee + + [0x60,0x61] => 0x22A2, # \vdash, \dashv + [0x62,0x63] => 0x230A, # \lfloor, \rfloor + [0x64,0x65] => 0x2308, # \lceil, \rceil + 0x66 => 0x7B, # { + 0x67 => 0x7D, # } + [0x68,0x69] => 0x27E8, # \langle, \rangle + 0x6A => 0x7C, # | + 0x6A => 0x2223, # \vert + 0x6B => 0x2225, # \Vert + 0x6C => 0x2195, # \updownarrow + 0x6D => 0x21D5, # \Updownarrow + 0x6E => 0x5C, # \backslash + 0x6E => 0x2216, # \setminus + 0x6F => 0x2240, # \wr + + 0x70 => [0x221A,0,760], # \surd ### adjust position so font doesn't have a large depth + 0x71 => 0x2A3F, # \amalg + 0x72 => 0x2207, # \nabla + 0x73 => 0x222B, # \int + 0x74 => 0x2294, # \sqcup + 0x75 => 0x2293, # \sqcap + [0x76,0x77] => 0x2291, # \sqsubseteq, \sqsupseteq + 0x78 => 0xA7, # \S + [0x79,0x7A] => 0x2020, # \dagger, \ddagger + 0x7B => 0xB6, # \P + 0x7C => 0x2663, # \clubsuit + 0x7D => 0x2662, # \diamondsuit + 0x7E => 0x2661, # \heartsuit + 0x7F => 0x2660, # \spadesuit + ], + + "Caligraphic" => [ + [0x41,0x5A] => 0x41, # A-Z + ], +}; + +$map{cmex10} = { + "Size1" => [ + 0 => [0x28,0,810], # ( + 1 => [0x29,0,810], # ) + 2 => [0x5B,0,810], # [ + 3 => [0x5D,0,810], # ] + 4 => [0x230A,0,810], # \lfloor + 5 => [0x230B,0,810], # \rfloor + 6 => [0x2308,0,810], # \lceil + 7 => [0x2309,0,810], # \rceil + 8 => [0x7B,0,810], # { + 9 => [0x7D,0,810], # } + 0xA => [0x27E8,0,810], # \langle + 0xB => [0x27E9,0,810], # \rangle + 0xC => [0x2223,0,606], # \vert + 0xD => [0x2225,0,606], # \Vert + 0xE => [0x2F,0,810], # / + 0xF => [0x5C,0,810], # \ + + 0x46 => [0x2A06,0,750], # \bigsqcup + 0x48 => [0x222E,0,805], # \oint + 0x4A => [0x2A00,0,750], # \bigodot + 0x4C => [0x2A01,0,750], # \bigoplus + 0x4E => [0x2A02,0,750], # \bigotimes + + 0x50 => [0x2211,0,750], # \sum + 0x51 => [0x220F,0,750], # \prod + 0x52 => [0x222B,0,805], # \int + 0x53 => [0x22C3,0,750], # \bigcup + 0x54 => [0x22C2,0,750], # \bigcap + 0x55 => [0x2A04,0,750], # \biguplus + 0x56 => [0x22C0,0,750], # \bigwedge + 0x57 => [0x22C1,0,750], # \bigvee + + 0x60 => [0x2210,0,750], # \coprod + 0x62 => 0x2C6, # \widehat + 0x62 => [0x302,-556,0], # \widehat (combining) + 0x65 => 0x2DC, # \widetilde + 0x65 => [0x303,-556,0], # \widetilde (combining) + + 0x70 => [0x221A,0,810], # surd + 0x3F => [0x23D0,0,601], # arrow extension + 0x77 => [0x2016,0,601], # Arrow extension (non-standard) + 0x78 => [0x2191,0,600], # uparrow top + 0x79 => [0x2193,0,600], # downarrow bottom + 0x7E => [0x21D1,0,600], # Uparrow top + 0x7F => [0x21D3,0,600], # Downarrow bottom + ], + + "Size2" => [ + 0x10 => [0x28,0,1110], # ( + 0x11 => [0x29,0,1110], # ) + 0x2E => [0x2F,0,1110], # / + 0x2F => [0x5C,0,1110], # \ + 0x44 => [0x27E8,0,1110],# \langle + 0x45 => [0x27E9,0,1110],# \rangle + + 0x47 => [0x2A06,0,950], # \bigsqcup + 0x49 => [0x222E,0,1360],# \oint + 0x4B => [0x2A00,0,950], # \bigodot + 0x4D => [0x2A01,0,950], # \bigoplus + 0x4F => [0x2A02,0,950], # \bigotimes + + 0x58 => [0x2211,0,950], # \sum + 0x59 => [0x220F,0,950], # \prod + 0x5A => [0x222B,0,1360],# \int + 0x5B => [0x22C3,0,950], # \bigcup + 0x5C => [0x22C2,0,950], # \bigcap + 0x5D => [0x2A04,0,950], # \biguplus + 0x5E => [0x22C0,0,950], # \bigwedge + 0x5F => [0x22C1,0,950], # \bigvee + 0x61 => [0x2210,0,950], # \coprod + + 0x63 => 0x2C6, # \widehat + 0x63 => [0x302,-1000,0],# \widehat (combining) + 0x66 => 0x2DC, # \widetilde + 0x66 => [0x303,-1000,0],# \widetilde (combining) + + 0x68 => [0x5B,0,1110], # [ + 0x69 => [0x5D,0,1110], # ] + 0x6A => [0x230A,0,1110],# \lfloor + 0x6B => [0x230B,0,1110],# \rfloor + 0x6C => [0x2308,0,1110],# \lceil + 0x6D => [0x2309,0,1110],# \rceil + 0x6E => [0x7B,0,1110], # { + 0x6F => [0x7D,0,1110], # } + 0x71 => [0x221A,0,1110],# surd + ], + + "Size3" => [ + 0x12 => [0x28,0,1410], # ( + 0x13 => [0x29,0,1410], # ) + 0x14 => [0x5B,0,1410], # [ + 0x15 => [0x5D,0,1410], # ] + 0x16 => [0x230A,0,1410],# \lfloor + 0x17 => [0x230B,0,1410],# \rfloor + 0x18 => [0x2308,0,1410],# \lceil + 0x19 => [0x2309,0,1410],# \rceil + 0x1A => [0x7B,0,1410], # { + 0x1B => [0x7D,0,1410], # } + 0x1C => [0x27E8,0,1410],# \langle + 0x1D => [0x27E9,0,1410],# \rangle + 0x1E => [0x2F,0,1410], # / + 0x1F => [0x5C,0,1410], # \ + 0x64 => 0x2C6, # \widehat + 0x64 => [0x302,-1444,0],# \widehat (combining) + 0x67 => 0x2DC, # \widetilde + 0x67 => [0x303,-1444,0],# \widetilde (combining) + 0x72 => [0x221A,0,1410],# surd + ], + + "Size4" => [ + 0x20 => [0x28,0,1710], # ( + 0x21 => [0x29,0,1710], # ) + 0x22 => [0x5B,0,1710], # [ + 0x23 => [0x5D,0,1710], # ] + 0x24 => [0x230A,0,1710],# \lfloor + 0x25 => [0x230B,0,1710],# \rfloor + 0x26 => [0x2308,0,1710],# \lceil + 0x27 => [0x2309,0,1710],# \rceil + 0x28 => [0x7B,0,1710], # { + 0x29 => [0x7D,0,1710], # } + 0x2A => [0x27E8,0,1710],# \langle + 0x2B => [0x27E9,0,1710],# \rangle + 0x2C => [0x2F,0,1710], # / + 0x2D => [0x5C,0,1710], # \ + 0x73 => [0x221A,0,1710],# surd + + 0x30 => [0x239B,0,1115],# left paren upper hook + 0x31 => [0x239E,0,1115],# right paren upper hook + 0x32 => [0x23A1,0,1115],# left square bracket upper corner + 0x33 => [0x23A4,0,1115],# right square bracket upper corner + 0x34 => [0x23A3,0,1115],# left square bracket lower corner + 0x35 => [0x23A6,0,1115],# right square bracket lower hook + 0x36 => [0x23A2,0,601], # left square bracket extension + 0x37 => [0x23A5,0,601], # right square bracket extension + 0x38 => [0x23A7,0,900], # left curly brace upper hook + 0x39 => [0x23AB,0,900], # right curly brace upper hook + 0x3A => 0x23A9, # left curly brace lower hook + 0x3B => 0x23AD, # right curly brace lower hook + 0x3C => [0x23A8,0,1150],# left curly brace middle + 0x3D => [0x23AC,0,1150],# right curly brace middle + 0x3E => [0x23AA,0,300], # curly brace extension + + 0x40 => [0x239D,0,1115],# left paren lower hook + 0x41 => [0x23A0,0,1115],# right paren lower hook + 0x42 => [0x239C,0,600], # left paren extension + 0x43 => [0x239F,0,600], # right paren extension + + 0x74 => [0x23B7,0,915], # radical bottom + 0x75 => [0xE000,0,605], # radical extension (PUA) + 0x76 => [0xE001,0,565], # radical top (PUA) + [0x7A,0x7D] => 0xE150, # \braceld, \bracerd, \bracelu, \braceru (PUA) + ], + + "Main-Regular" => [ + 0x38 => [0x23B0,0,900], # left curly brace upper hook, for lgroup, lmoustache + 0x39 => [0x23B1,0,900], # right curly brace upper hook, for rgroup, rmoustache + 0x3A => 0x23A9, # left curly brace lower hook, for lgroup, rmoustache + 0x3B => 0x23AD, # right curly brace lower hook, for rgroup, lmoustache + ], +}; + +$map{cmti10} = { + "Main-Italic" => [ + [0,1] => 0x393, # \Gamma, \Delta + 2 => 0x398, # \Theta + 3 => 0x39B, # \Lambda + 4 => 0x39E, # \Xi + 5 => 0x3A0, # \Pi + 6 => 0x3A3, # \Sigma + [7,8] => 0x3A5, # \Upsilon, \Phi + [9,0xA] => 0x3A8, # \Psi, \Omega + + 0x10 => 0x131, # \i + 0x11 => 0x237, # \j + 0x12 => 0x2CB, # \grave + 0x13 => 0x2CA, # \acute + 0x14 => 0x2C7, # \check + 0x15 => 0x2D8, # \breve + 0x16 => 0x2C9, # \bar + 0x17 => [0xB0,-160,0], # \degree + 0x17 => 0x02DA, # \r, ring above + 0x18 => 0xB8, # \c, cedilla + + [0x21,0x23] => 0x21, # !, ", #, + 0x22 => 0x201D, # " + [0x25,0x2F] => 0x25, # %, &, ', (, ), *, +, comma, -, ., / + 0x27 => 0x2019, # ' + [0x30,0x39] => 0x30, # 0-9 + [0x3A,0x3B] => 0x3A, # :, ; + 0x3D => 0x3D, # = + [0x3F,0x40] => 0x3F, # ?, @ + [0x41,0x5A] => 0x41, # A-Z + 0x5B => 0x5B, # [ + 0x5C => 0x201C, # `` + [0x5D,0x5E] => 0x5D, # ], ^ + 0x5E => 0x2C6, # \hat + 0x5F => 0x2D9, # \dot + 0x60 => 0x2018, # ` + [0x61,0x7A] => 0x61, # a-z + [0x7B,0x7C] => 0x2013, # \endash, \emdash + 0x7B => [0x5F,0,-310], # underline + 0x7D => 0x2DD, # double acute + 0x7E => [0x7E,0,-350], # ~ + 0x7E => 0x2DC, # \tilde + 0x7F => 0xA8, # \ddot + 0x19 => 0xDF, # sharp S + 0x1A => 0xE6, # ae ligature + 0x1B => 0x153, # oe ligature + 0x1C => 0xF8, # o with slash + 0x1D => 0xC6, # AE ligature + 0x1E => 0x152, # OE ligature + 0x1F => 0xD8, # O with slash + ], + + "Main-Regular" => [ + 0x24 => 0xA3, # pound sign + ], +}; + +$map{cmbx10} = { + "Main-Bold" => [ + [0,1] => 0x393, # \Gamma, \Delta + 2 => 0x398, # \Theta + 3 => 0x39B, # \Lambda + 4 => 0x39E, # \Xi + 5 => 0x3A0, # \Pi + 6 => 0x3A3, # \Sigma + [7,8] => 0x3A5, # \Upsilon, \Phi + [9,0xA] => 0x3A8, # \Psi, \Omega + + 0x10 => 0x131, # \i + 0x11 => 0x237, # \j + 0x12 => 0x2CB, # \grave + 0x13 => 0x2CA, # \acute + 0x14 => 0x2C7, # \check + 0x15 => 0x2D8, # \breve + 0x16 => 0x2C9, # \bar + 0x17 => [0xB0,-147,0], # \degree + 0x17 => 0x02DA, # \r, ring above + 0x18 => 0xB8, # \c, cedilla + + [0x21,0x2F] => 0x21, # !, ", #, $, %, &, ', (, ), *, +, comma, -, ., / + 0x22 => 0x201D, # " + 0x27 => 0x2019, # ' + [0x30,0x39] => 0x30, # 0-9 + [0x3A,0x3B] => 0x3A, # :, ; + 0x3D => 0x3D, # = + [0x3F,0x40] => 0x3F, # ?, @ + [0x41,0x5A] => 0x41, # A-Z + 0x5B => 0x5B, # [ + 0x5C => 0x201C, # `` + [0x5D,0x5E] => 0x5D, # ], ^ + 0x5E => 0x2C6, # \hat + 0x5F => 0x2D9, # \dot + 0x60 => 0x2018, # ` + [0x61,0x7A] => 0x61, # a-z + [0x7B,0x7C] => 0x2013, # \endash, \emdash + 0x7B => [0x5F,0,-310], # underline + 0x7D => 0x2DD, # double acute + 0x7E => [0x7E,0,-350], # ~ + 0x7E => 0x2DC, # \tilde + 0x7F => 0xA8, # \ddot + 0x19 => 0xDF, # sharp S + 0x1A => 0xE6, # ae ligature + 0x1B => 0x153, # oe ligature + 0x1C => 0xF8, # o with slash + 0x1D => 0xC6, # AE ligature + 0x1E => 0x152, # OE ligature + 0x1F => 0xD8, # O with slash + ], +}; + +$map{cmbxti10} = { + "Main-BoldItalic" => [ + [0,1] => 0x393, # \Gamma, \Delta + 2 => 0x398, # \Theta + 3 => 0x39B, # \Lambda + 4 => 0x39E, # \Xi + 5 => 0x3A0, # \Pi + 6 => 0x3A3, # \Sigma + [7,8] => 0x3A5, # \Upsilon, \Phi + [9,0xA] => 0x3A8, # \Psi, \Omega + + 0x10 => 0x131, # \i + 0x11 => 0x237, # \j + 0x12 => 0x2CB, # \grave + 0x13 => 0x2CA, # \acute + 0x14 => 0x2C7, # \check + 0x15 => 0x2D8, # \breve + 0x16 => 0x2C9, # \bar + 0x17 => [0xB0,-160,0], # \degree + 0x17 => 0x02DA, # \r, ring above + 0x18 => 0xB8, # \c, cedilla + + [0x21,0x23] => 0x21, # !, ", #, + 0x22 => 0x201D, # " + [0x25,0x2F] => 0x25, # %, &, ', (, ), *, +, comma, -, ., / + 0x27 => 0x2019, # ' + [0x30,0x39] => 0x30, # 0-9 + [0x3A,0x3B] => 0x3A, # :, ; + 0x3D => 0x3D, # = + [0x3F,0x40] => 0x3F, # ?, @ + [0x41,0x5A] => 0x41, # A-Z + 0x5B => 0x5B, # [ + 0x5C => 0x201C, # `` + [0x5D,0x5E] => 0x5D, # ], ^ + 0x5E => 0x2C6, # \hat + 0x5F => 0x2D9, # \dot + 0x60 => 0x2018, # ` + [0x61,0x7A] => 0x61, # a-z + [0x7B,0x7C] => 0x2013, # \endash, \emdash + 0x7B => [0x5F,0,-310], # underline + 0x7D => 0x2DD, # double acute + 0x7E => [0x7E,0,-350], # ~ + 0x7E => 0x2DC, # \tilde + 0x7F => 0xA8, # \ddot + 0x19 => 0xDF, # sharp S + 0x1A => 0xE6, # ae ligature + 0x1B => 0x153, # oe ligature + 0x1C => 0xF8, # o with slash + 0x1D => 0xC6, # AE ligature + 0x1E => 0x152, # OE ligature + 0x1F => 0xD8, # O with slash + ], + + "Main-Bold" => [ + 0x24 => 0xA3, # pound sign + ], +}; + +$map{cmmib10} = { + "Math-BoldItalic" => [ + [0,1] => 0x393, # \Gamma, \Delta + 2 => 0x398, # \Theta + 3 => 0x39B, # \Lambda + 4 => 0x39E, # \Xi + 5 => 0x3A0, # \Pi + 6 => 0x3A3, # \Sigma + [7,8] => 0x3A5, # \Upsilon, \Phi + [9,0xA] => 0x3A8, # \Psi, \Omega + + [0xB,0xE] => 0x3B1, # \alpha, \beta, \gamma, \delta + 0xF => 0x3F5, # \elpsilon + [0x10,0x18] => 0x3B6, # \zeta, \eta, \theta, \iota, \kappa, \lambda, \mu, \nu, \xi + [0x19,0x1A] => 0x3C0, # \pi, \rho + [0x1B,0x1D] => 0x3C3, # \sigma, \tau, \upsilon + 0x1E => 0x3D5, # \phi + [0x1F,0x21] => 0x3C7, # \chi, \psi, \omega + 0x22 => 0x3B5, # \varepsilon + 0x23 => 0x3D1, # \vartheta + 0x24 => 0x3D6, # \varpi + 0x25 => 0x3F1, # \varrho + 0x26 => 0x3C2, # \varsigma + 0x27 => 0x3C6, # \varphi + + [0x30,0x39] => 0x30, # Oldstyle 0-9 + [0x41,0x5A] => 0x41, # A-Z + [0x61,0x7A] => 0x61, # a - z + + 0x6F => 0x3BF, # omicron + 0x7B => 0xE131, # \imath (PUA) + 0x7C => 0xE237, # \jmath (PUA) + ], + + "Main-Bold" => [ + 0x28 => 0x21BC, # \leftharpoonup + 0x29 => 0x21BD, # \leftharpoondown + 0x2A => 0x21C0, # \rightharpoonup + 0x2B => 0x21C1, # \rightharpoondown + + 0x2E => 0x25B9, # \triangleright + 0x2F => 0x25C3, # \triangleleft + + 0x3A => 0x2E, # . + 0x3B => 0x2C, # , + 0x3C => 0x3C, # < + 0x3D => 0x2215, # / + 0x3E => 0x3E, # > + 0x3F => 0x22C6, # \star + 0x40 => 0x2202, # \partial + + [0x5B,0x5D] => 0x266D, # \flat, \natural, \sharp + 0x5E => 0x2323, # \smile + 0x5F => 0x2322, # \frown + 0x60 => 0x2113, # \ell + 0x68 => 0x210F, # \hbar (bar added below) + + 0x7D => 0x2118, # \wp + 0x7E => [0x20D7,-729,0],# \vec + ], +}; + +$map{cmbsy10} = { + "Main-Bold" => [ + [0,1] => 0x2212, # - + 1 => 0x22C5, # \cdot + 2 => 0xD7, # \times + 3 => 0x2217, # \ast + 4 => 0xF7, # \div + 5 => 0x22C4, # \diamond + 6 => 0xB1, # \pm + 7 => 0x2213, # \mp + [8,0xC] => 0x2295, # \oplus, \ominus, \otimes, \oslash, \odot + 0xD => 0x25EF, # \bigcirc + [0xE,0xF] => 0x2218, # \circ, \bullet + + 0x10 => 0x224D, # \asymp + 0x11 => 0x2261, # \equiv + [0x12,0x13] => 0x2286, # \subseteq, \supseteq + [0x14,0x15] => 0x2264, # \leq, \geq + [0x16,0x17] => 0x2AAF, # \preceq, \succeq + 0x18 => 0x223C, # \sim + 0x19 => 0x2248, # \approx + [0x1A,0x1B] => 0x2282, # \subset, \supset + [0x1C,0x1D] => 0x226A, # \ll, \gg + [0x1E,0x1F] => 0x227A, # \prec, \succ + + 0x20 => 0x2190, # \leftarrow + 0x21 => 0x2192, # \rightarrow + 0x22 => 0x2191, # \uparrow + 0x23 => 0x2193, # \downarrow + 0x24 => 0x2194, # \leftrightarrow + 0x25 => 0x2197, # \nearrow + 0x26 => 0x2198, # \searrow + 0x27 => 0x2243, # \simeq + + 0x28 => 0x21D0, # \Leftarrow + 0x29 => 0x21D2, # \Rightarrow + 0x2A => 0x21D1, # \Uparrow + 0x2B => 0x21D3, # \Downarrow + 0x2C => 0x21D4, # \Leftrightarrow + 0x2D => 0x2196, # \nwarrow + 0x2E => 0x2199, # \swarrow + 0x2F => 0x221D, # \propto + + 0x30 => 0x2032, # \prime + 0x31 => 0x221E, # \infty + 0x32 => 0x2208, # \in + 0x33 => 0x220B, # \ni + 0x34 => 0x25B3, # \bigtriangleup and \triangle + 0x35 => 0x25BD, # \bigtriangledown + 0x36 => 0xE020, # \not + + 0x38 => 0x2200, # \forall + 0x39 => 0x2203, # \exists + 0x3A => 0xAC, # \neg + 0x3B => 0x2205, # \emptyset + 0x3C => 0x211C, # \Re + 0x3D => 0x2111, # \Im + 0x3E => 0x22A4, # \top + 0x3F => 0x22A5, # \bot + + 0x40 => 0x2135, # \aleph + + 0x5B => 0x222A, # \cup + 0x5C => 0x2229, # \cap + 0x5D => 0x228E, # \uplus + [0x5E,0x5F] => 0x2227, # \wedge, \vee + + [0x60,0x61] => 0x22A2, # \vdash, \dashv + [0x62,0x63] => 0x230A, # \lfloor, \rfloor + [0x64,0x65] => 0x2308, # \lceil, \rceil + 0x66 => 0x7B, # { + 0x67 => 0x7D, # } + [0x68,0x69] => 0x27E8, # \langle, \rangle + 0x6A => 0x7C, # | + 0x6A => 0x2223, # \vert + 0x6B => 0x2225, # \Vert + 0x6C => 0x2195, # \updownarrow + 0x6D => 0x21D5, # \Updownarrow + 0x6E => 0x5C, # \backslash + 0x6E => 0x2216, # \setminus + 0x6F => 0x2240, # \wr + + 0x70 => [0x221A,0,760], # \surd ### adjust position so font doesn't have a large depth + 0x71 => 0x2A3F, # \amalg + 0x72 => 0x2207, # \nabla + 0x73 => 0x222B, # \int + 0x74 => 0x2294, # \sqcup + 0x75 => 0x2293, # \sqcap + [0x76,0x77] => 0x2291, # \sqsubseteq, \sqsupseteq + + [0x79,0x7A] => 0x2020, # \dagger, \ddagger + + 0x7C => 0x2663, # \clubsuit + 0x7D => 0x2662, # \diamondsuit + 0x7E => 0x2661, # \heartsuit + 0x7F => 0x2660, # \spadesuit + ], + + "Caligraphic-Bold" => [ + [0x41,0x5A] => 0x41, # A-Z + ], +}; + +$map{msam10} = { + "Main-Regular" => [ + 0x5C => 0x2220, # \angle + ], + + "Main-Bold" => [ + 0x5C => 0x2220, # \angle (emboldened below) + ], + + "AMS" => [ + 0x00 => 0x22A1, # \boxdot + 0x01 => 0x229E, # \boxplus + 0x02 => 0x22A0, # \boxtimes + 0x03 => 0x25A1, # \square + 0x04 => 0x25A0, # \blacksquare + 0x05 => 0x22C5, # \centerdot + 0x06 => 0x25CA, # \lozenge + 0x07 => 0x29EB, # \blacklozenge + 0x08 => 0x21BB, # \circlearrowright + 0x09 => 0x21BA, # \circlearrowleft + 0x0A => 0x21CC, # \rightleftharpoons + 0x0B => 0x21CB, # \leftrightharpoons + 0x0C => 0x229F, # \boxminus + 0x0D => 0x22A9, # \Vdash + 0x0E => 0x22AA, # \Vvdash + 0x0F => 0x22A8, # \vDash + 0x10 => 0x21A0, # \twoheadrightarrow + 0x11 => 0x219E, # \twoheadleftarrow + 0x12 => 0x21C7, # \leftleftarrows + 0x13 => 0x21C9, # \rightrightarrows + 0x14 => 0x21C8, # \upuparrows + 0x15 => 0x21CA, # \downdownarrows + 0x16 => 0x21BE, # \upharpoonright + 0x17 => 0x21C2, # \downharpoonright + 0x18 => 0x21BF, # \upharpoonleft + 0x19 => 0x21C3, # \downharpoonleft + 0x1A => 0x21A3, # \rightarrowtail + 0x1B => 0x21A2, # \leftarrowtail + 0x1C => 0x21C6, # \leftrightarrows + 0x1D => 0x21C4, # \rightleftarrows + 0x1E => 0x21B0, # \Lsh + 0x1F => 0x21B1, # \Rsh + 0x20 => 0x21DD, # \rightsquigarrow + 0x21 => 0x21AD, # \leftrightsquigarrow + 0x22 => 0x21AB, # \looparrowleft + 0x23 => 0x21AC, # \looparrowright + 0x24 => 0x2257, # \circeq + 0x25 => 0x227F, # \succsim + 0x26 => 0x2273, # \gtrsim + 0x27 => 0x2A86, # \gtrapprox + 0x28 => 0x22B8, # \multimap + 0x29 => 0x2234, # \therefore + 0x2A => 0x2235, # \because + 0x2B => 0x2251, # \doteqdot + 0x2C => 0x225C, # \triangleq + 0x2D => 0x227E, # \precsim + 0x2E => 0x2272, # \lesssim + 0x2F => 0x2A85, # \lessapprox + 0x30 => 0x2A95, # \eqslantless + 0x31 => 0x2A96, # \eqslantgtr + 0x32 => 0x22DE, # \curlyeqprec + 0x33 => 0x22DF, # \curlyeqsucc + 0x34 => 0x227C, # \preccurlyeq + 0x35 => 0x2266, # \leqq + 0x36 => 0x2A7D, # \leqslant + 0x37 => 0x2276, # \lessgtr + 0x38 => 0x2035, # \backprime + 0x39 => 0x2212, # dahsed arrow extension + 0x3A => 0x2253, # \risingdotseq + 0x3B => 0x2252, # \fallingdotseq + 0x3C => 0x227D, # \succcurlyeq + 0x3D => 0x2267, # \geqq + 0x3E => 0x2A7E, # \geqslant + 0x3F => 0x2277, # \gtrless + 0x40 => 0x228F, # \sqsubset + 0x41 => 0x2290, # \sqsupset + 0x42 => 0x22B3, # \vartriangleright + 0x43 => 0x22B2, # \vartriangleleft + 0x44 => 0x22B5, # \trianglerighteq + 0x45 => 0x22B4, # \trianglelefteq + 0x46 => 0x2605, # \bigstar + 0x47 => 0x226C, # \between + 0x48 => 0x25BC, # \blacktriangledown + 0x49 => 0x25B6, # \blacktriangleright + 0x4A => 0x25C0, # \blacktriangleleft + 0x4B => 0x2192, # rightarrow + 0x4C => 0x2190, # leftarrow + 0x4D => 0x25B3, # \vartriangle + 0x4E => 0x25B2, # \blacktriangle + 0x4F => 0x25BD, # \triangledown + 0x50 => 0x2256, # \eqcirc + 0x51 => 0x22DA, # \lesseqgtr + 0x52 => 0x22DB, # \gtreqless + 0x53 => 0x2A8B, # \lesseqqgtr + 0x54 => 0x2A8C, # \gtreqqless + 0x55 => 0x00A5, # yen + 0x56 => 0x21DB, # \Rrightarrow + 0x57 => 0x21DA, # \Lleftarrow + 0x58 => 0x2713, # checkmark + 0x59 => 0x22BB, # \veebar + 0x5A => 0x22BC, # \barwedge + 0x5B => 0x2A5E, # \doublebarwedge + 0x5C => 0x2220, # \angle + 0x5D => 0x2221, # \measuredangle + 0x5E => 0x2222, # \sphericalangle + 0x5F => 0x221D, # \varpropto + 0x60 => 0x2323, # \smallsmile + 0x61 => 0x2322, # \smallfrown + 0x62 => 0x22D0, # \Subset + 0x63 => 0x22D1, # \Supset + 0x64 => 0x22D3, # \Cup + 0x65 => 0x22D2, # \Cap + 0x66 => 0x22CF, # \curlywedge + 0x67 => 0x22CE, # \curlyvee + 0x68 => 0x22CB, # \leftthreetimes + 0x69 => 0x22CC, # \rightthreetimes + 0x6A => 0x2AC5, # \subseteqq + 0x6B => 0x2AC6, # \supseteqq + 0x6C => 0x224F, # \bumpeq + 0x6D => 0x224E, # \Bumpeq + 0x6E => 0x22D8, # \lll + 0x6F => 0x22D9, # \ggg + 0x70 => 0x250C, # \ulcorner + 0x71 => 0x2510, # \urcorner + 0x72 => 0x00AE, # registered sign + 0x73 => 0x24C8, # \circledS + 0x74 => 0x22D4, # \pitchfork + 0x75 => 0x2214, # \dotplus + 0x76 => 0x223D, # \backsim + 0x77 => 0x22CD, # \backsimeq + 0x78 => 0x2514, # \llcorner + 0x79 => 0x2518, # \lrcorner + 0x7A => 0x2720, # maltese cross + 0x7B => 0x2201, # \complement + 0x7C => 0x22BA, # \intercal + 0x7D => 0x229A, # \circledcirc + 0x7E => 0x229B, # \circledast + 0x7F => 0x229D, # \circleddash + ], +}; + +$map{msbm10} = { + "Size4" => [ + 0x5B => 0x2C6, # \widehat + 0x5B => [0x302,-1889,0],# \widehat (combining) + 0x5D => 0x2DC, # \widetilde + 0x5D => [0x303,-1889,0],# \widetilde (combining) + ], + + "Main-Regular" => [ + 0x7E => 0x210F, # \hbar + ], + + "Main-Italic" => [ + 0x7D => 0x210F, # \hbar (with slant) + ], + + "AMS" => [ + 0x00 => 0xE00C, # \lvertneqq + 0x01 => 0xE00D, # \gvertneqq + 0x02 => 0x2270, # \nleq + 0x03 => 0x2271, # \ngeq + 0x04 => 0x226E, # \nless + 0x05 => 0x226F, # \ngtr + 0x06 => 0x2280, # \nprec + 0x07 => 0x2281, # \nsucc + 0x08 => 0x2268, # \lneqq + 0x09 => 0x2269, # \gneqq + 0x0A => 0xE010, # \nleqslant + 0x0B => 0xE00F, # \ngeqslant + 0x0C => 0x2A87, # \lneq + 0x0D => 0x2A88, # \gneq + 0x0E => 0x22E0, # \npreceq + 0x0F => 0x22E1, # \nsucceq + 0x10 => 0x22E8, # \precnsim + 0x11 => 0x22E9, # \succnsim + 0x12 => 0x22E6, # \lnsim + 0x13 => 0x22E7, # \gnsim + 0x14 => 0xE011, # \nleqq + 0x15 => 0xE00E, # \ngeqq + 0x16 => 0x2AB5, # \precneqq + 0x17 => 0x2AB6, # \succneqq + 0x18 => 0x2AB9, # \precnapprox + 0x19 => 0x2ABA, # \succnapprox + 0x1A => 0x2A89, # \lnapprox + 0x1B => 0x2A8A, # \gnapprox + 0x1C => 0x2241, # \nsim + 0x1D => 0x2246, # \ncong + 0x1E => 0x2571, # \diagup + 0x1F => 0x2572, # \diagdown + 0x20 => 0xE01A, # \varsubsetneq + 0x21 => 0xE01B, # \varsupsetneq + 0x22 => 0xE016, # \nsubseteqq + 0x23 => 0xE018, # \nsupseteqq + 0x24 => 0x2ACB, # \subsetneqq + 0x25 => 0x2ACC, # \supsetneqq + 0x26 => 0xE017, # \varsubsetneqq + 0x27 => 0xE019, # \varsupsetneqq + 0x28 => 0x228A, # \subsetneq + 0x29 => 0x228B, # \supsetneq + 0x2A => 0x2288, # \nsubseteq + 0x2B => 0x2289, # \nsupseteq + 0x2C => 0x2226, # \nparallel + 0x2D => 0x2224, # \nmid + 0x2E => 0xE006, # \nshortmid + 0x2F => 0xE007, # \nshortparallel + 0x30 => 0x22AC, # \nvdash + 0x31 => 0x22AE, # \nVdash + 0x32 => 0x22AD, # \nvDash + 0x33 => 0x22AF, # \nVDash + 0x34 => 0x22ED, # \ntrianglerighteq + 0x35 => 0x22EC, # \ntrianglelefteq + 0x36 => 0x22EA, # \ntriangleleft + 0x37 => 0x22EB, # \ntriangleright + 0x38 => 0x219A, # \nleftarrow + 0x39 => 0x219B, # \nrightarrow + 0x3A => 0x21CD, # \nLeftarrow + 0x3B => 0x21CF, # \nRightarrow + 0x3C => 0x21CE, # \nLeftrightarrow + 0x3D => 0x21AE, # \nleftrightarrow + 0x3E => 0x22C7, # \divideontimes + 0x3F => 0x2205, # \varnothing + 0x40 => 0x2204, # \nexists + + [0x41,0x5A] => 0x41, # A-Z + 0x5C => 0x2C6, # \widehat + 0x5C => [0x302,-2333,0],# \widehat (combining) + 0x5E => 0x2DC, # \widetilde + 0x5E => [0x303,-2333,0],# \widetilde (combining) + + 0x60 => 0x2132, # \Finv + 0x61 => 0x2141, # \Game + 0x66 => 0x2127, # \mho + 0x67 => 0x00F0, # \eth + 0x68 => 0x2242, # minus-tilde + 0x69 => 0x2136, # \beth + 0x6A => 0x2137, # \gimel + 0x6B => 0x2138, # \daleth + 0x6C => 0x22D6, # \lessdot + 0x6D => 0x22D7, # \gtrdot + 0x6E => 0x22C9, # \ltimes + 0x6F => 0x22CA, # \rtimes + 0x70 => 0x2223, # \shortmid + 0x71 => 0x2225, # \shortparallel + 0x72 => 0x2216, # \smallsetminus + 0x73 => 0x223C, # \thicksim + 0x74 => 0x2248, # \thickapprox + 0x75 => 0x224A, # \approxeq + 0x76 => 0x2AB8, # \succapprox + 0x77 => 0x2AB7, # \precapprox + 0x78 => 0x21B6, # \curvearrowleft + 0x79 => 0x21B7, # \curvearrowright + 0x7A => 0x03DD, # \digamma + 0x7B => 0x03F0, # \varkappa + 0x7A => 0xE008, # \digamma (non-standard, for IE) + 0x7B => 0xE009, # \varkappa (non-standard, for IE) + 0x7C => 0x006B, # \Bbbk + 0x7D => 0x210F, # \hslash + 0x7E => 0x0127, # \hbar + 0x7F => 0x220D, # \backepsilon + ], +}; + +$map{cmss10} = { + "SansSerif-Regular" => [ + [0,1] => 0x393, # \Gamma, \Delta + 2 => 0x398, # \Theta + 3 => 0x39B, # \Lambda + 4 => 0x39E, # \Xi + 5 => 0x3A0, # \Pi + 6 => 0x3A3, # \Sigma + [7,8] => 0x3A5, # \Upsilon, \Phi + [9,0xA] => 0x3A8, # \Psi, \Omega + + 0x10 => 0x131, # \i + 0x11 => 0x237, # \j + 0x12 => 0x2CB, # \grave + 0x13 => 0x2CA, # \acute + 0x14 => 0x2C7, # \check + 0x15 => 0x2D8, # \breve + 0x16 => 0x2C9, # \bar + 0x17 => [0xB0,-142,0], # \degree + 0x17 => 0x02DA, # \r, ring above + 0x18 => 0xB8, # \c, cedilla + + [0x21,0x2F] => 0x21, # !, ", #, $, %, &, ', (, ), *, +, comma, -, ., / + 0x22 => 0x201D, # " + 0x27 => 0x2019, # ' + [0x30,0x39] => 0x30, # 0-9 + [0x3A,0x3B] => 0x3A, # :, ; + 0x3D => 0x3D, # = + [0x3F,0x40] => 0x3F, # ?, @ + [0x41,0x5A] => 0x41, # A-Z + 0x5B => 0x5B, # [ + 0x5C => 0x201C, # `` + [0x5D,0x5E] => 0x5D, # ], ^ + 0x5E => 0x2C6, # \hat + 0x5F => 0x2D9, # \dot + 0x60 => 0x2018, # ` + [0x61,0x7A] => 0x61, # a-z + [0x7B,0x7C] => 0x2013, # \endash, \emdash + 0x7B => [0x5F,0,-350], # underline + 0x7D => 0x2DD, # double acute + 0x7E => [0x7E,0,-350], # ~ + 0x7E => 0x2DC, # \tilde + 0x7F => 0xA8, # \ddot + ], +}; + +$map{cmssi10} = { + "SansSerif-Italic" => [ + [0,1] => 0x393, # \Gamma, \Delta + 2 => 0x398, # \Theta + 3 => 0x39B, # \Lambda + 4 => 0x39E, # \Xi + 5 => 0x3A0, # \Pi + 6 => 0x3A3, # \Sigma + [7,8] => 0x3A5, # \Upsilon, \Phi + [9,0xA] => 0x3A8, # \Psi, \Omega + + 0x10 => 0x131, # \i + 0x11 => 0x237, # \j + 0x12 => 0x2CB, # \grave + 0x13 => 0x2CA, # \acute + 0x14 => 0x2C7, # \check + 0x15 => 0x2D8, # \breve + 0x16 => 0x2C9, # \bar + 0x17 => [0xB0,-113,0], # \degree + 0x17 => 0x02DA, # \r, ring above + 0x18 => 0xB8, # \c, cedilla + + [0x21,0x2F] => 0x21, # !, ", #, $, %, &, ', (, ), *, +, comma, -, ., / + 0x22 => 0x201D, # " + 0x27 => 0x2019, # ' + [0x30,0x39] => 0x30, # 0-9 + [0x3A,0x3B] => 0x3A, # :, ; + 0x3D => 0x3D, # = + [0x3F,0x40] => 0x3F, # ?, @ + [0x41,0x5A] => 0x41, # A-Z + 0x5B => 0x5B, # [ + 0x5C => 0x201C, # `` + [0x5D,0x5E] => 0x5D, # ], ^ + 0x5E => 0x2C6, # \hat + 0x5F => 0x2D9, # \dot + 0x60 => 0x2018, # ` + [0x61,0x7A] => 0x61, # a-z + [0x7B,0x7C] => 0x2013, # \endash, \emdash + 0x7B => [0x5F,0,-350], # underline + 0x7D => 0x2DD, # double acute + 0x7E => [0x7E,0,-350], # ~ + 0x7E => 0x2DC, # \tilde + 0x7F => 0xA8, # \ddot + ], +}; + +$map{cmssbx10} = { + "SansSerif-Bold" => [ + [0,1] => 0x393, # \Gamma, \Delta + 2 => 0x398, # \Theta + 3 => 0x39B, # \Lambda + 4 => 0x39E, # \Xi + 5 => 0x3A0, # \Pi + 6 => 0x3A3, # \Sigma + [7,8] => 0x3A5, # \Upsilon, \Phi + [9,0xA] => 0x3A8, # \Psi, \Omega + + 0x10 => 0x131, # \i + 0x11 => 0x237, # \j + 0x13 => 0xB4, # \acute + 0x14 => 0x2C7, # \check + 0x15 => 0x2D8, # \breve + 0x16 => 0x2C9, # \bar + 0x17 => [0xB0,-58,0], # \degree + 0x17 => 0x02DA, # \r, ring above + 0x18 => 0xB8, # \c, cedilla + + [0x21,0x2F] => 0x21, # !, ", #, $, %, &, ', (, ), *, +, comma, -, ., / + 0x22 => 0x201D, # " + 0x27 => 0x2019, # ' + [0x30,0x39] => 0x30, # 0-9 + [0x3A,0x3B] => 0x3A, # :, ; + 0x3D => 0x3D, # = + [0x3F,0x40] => 0x3F, # ?, @ + [0x41,0x5A] => 0x41, # A-Z + 0x5B => 0x5B, # [ + 0x5C => 0x201C, # `` + [0x5D,0x5E] => 0x5D, # ], ^ + 0x5E => 0x2C6, # \hat + 0x5F => 0x2D9, # \dot + 0x60 => 0x2018, # ` + [0x61,0x7A] => 0x61, # a-z + [0x7B,0x7C] => 0x2013, # \endash, \emdash + 0x7B => [0x5F,0,-350], # underline + 0x7D => 0x2DD, # double acute + 0x7E => [0x7E,0,-350], # ~ + 0x7E => 0x2DC, # \tilde + 0x7F => 0xA8, # \ddot + ], +}; + +$map{eufm10} = { + "Fraktur-Regular" => [ + [0,7] => 0xE300, # variants + 0x12 => 0x2018, # left quote + 0x13 => 0x2019, # right quote + 0x21 => 0x21, # ! + [0x26,0x2F] => 0x26, # &, ', (, ), *, +, comma, -, ., / + [0x30,0x39] => 0x30, # 0-9 + [0x3A,0x3B] => 0x3A, # :, ; + 0x3D => 0x3D, # = + 0x3F => 0x3F, # ? + [0x41,0x5A] => 0x41, # A-Z + 0x5B => 0x5B, # [ + [0x5D,0x5E] => 0x5D, # ], ^ + [0x61,0x7A] => 0x61, # a-z + 0x7D => 0x22, # " + ], +}; + +$map{eufb10} = { + "Fraktur-Bold" => [ + [1,5] => 0xE301, # variants + [8,9] => 0xE308, # variants + 0x12 => 0x2018, # left quote + 0x13 => 0x2019, # right quote + 0x21 => 0x21, # ! + [0x26,0x2F] => 0x26, # &, ', (, ), *, +, comma, -, ., / + [0x30,0x39] => 0x30, # 0-9 + [0x3A,0x3B] => 0x3A, # :, ; + 0x3D => 0x3D, # = + 0x3F => 0x3F, # ? + [0x41,0x5A] => 0x41, # A-Z + 0x5B => 0x5B, # [ + [0x5D,0x5E] => 0x5D, # ], ^ + [0x61,0x7A] => 0x61, # a-z + 0x7D => 0x22, # " + ], +}; + +$map{rsfs10} = { + "Script-Regular" => [ + [0x41,0x5A] => 0x41, # A-Z + ] +}; + +#$map{eusm10} = { +# "Script-Regular" => [ +# 0x3C => 0x211C, # \Re +# 0x3D => 0x2111, # \Im +# 0x40 => 0x2135, # \aleph +# [0x41,0x5A] => 0x41, # A-Z +# 0x66 => 0x7B, # { +# 0x67 => 0x7D, # } +# 0x78 => 0xA7, # \S +# ], +#}; + +#$map{eusb10} = { +# "Script-Bold" => [ +# 0x3C => 0x211C, # \Re +# 0x3D => 0x2111, # \Im +# 0x40 => 0x2135, # \aleph +# [0x41,0x5A] => 0x41, # A-Z +# 0x66 => 0x7B, # { +# 0x67 => 0x7D, # } +# 0x78 => 0xA7, # \S +# ], +#}; + +$map{cmtt10} = { + "Typewriter" => [ + [0,1] => 0x393, # \Gamma, \Delta + 2 => 0x398, # \Theta + 3 => 0x39B, # \Lambda + 4 => 0x39E, # \Xi + 5 => 0x3A0, # \Pi + 6 => 0x3A3, # \Sigma + [7,8] => 0x3A5, # \Upsilon, \Phi + [9,0xA] => 0x3A8, # \Psi, \Omega + 0xD => 0x2032, # ' + + 0x10 => 0x131, # \i + 0x11 => 0x237, # \j + 0x12 => 0x2CB, # \grave + 0x13 => 0x2CA, # \acute + 0x14 => 0x2C7, # \check + 0x15 => 0x2D8, # \breve + 0x16 => 0x2C9, # \bar + 0x17 => 0xB0, # \degree + 0x17 => 0x02DA, # \r, ring above + 0x18 => 0xB8, # \c, cedilla + 0x20 => 0x2423, # graphic representation of space + + [0x21,0x7F] => 0x21, + + 0x60 => 0x2018, # left quote + 0x27 => 0x2019, # right quote + 0x5E => 0x2C6, # \hat + 0x5F => 0x2D9, # \dot + 0x7D => 0x2DD, # double acute + 0x7E => [0x7E,0,-350], # ~ + 0x7E => 0x2DC, # \tilde + 0x7F => 0xA8, # \ddot + ] +}; + +######################################################################### + +$extra{'Main-Regular'} = { + cdots => [ + 'Select(0u22C5)','Copy()', + 'Select(0u22EF)','Paste()', + 'PasteWithOffset(447,0)', + 'PasteWithOffset(894,0)', + 'SetRBearing(894,1)', + ], + + ldots => [ + 'Select(0u2E)','Copy()', + 'Select(0u2026)','Paste()', + 'PasteWithOffset(447,0)', + 'PasteWithOffset(894,0)', + 'SetRBearing(894,1)', + ], + + vdots => [ + 'Select(0u2E)','Copy()', + 'Select(0u22EE)','Clear()', + 'PasteWithOffset(0,-30)', + 'PasteWithOffset(0,380)', + 'PasteWithOffset(0,780)', + 'SetRBearing(-722,1)', + ], + + ddots => [ + 'Select(0u2E)','Copy()', + 'Select(0u22F1)','Clear()', + 'PasteWithOffset(55,700)', + 'PasteWithOffset(502,400)', + 'PasteWithOffset(949,100)', + 'SetRBearing(282,1)', + ], + + spaceEn => [ + 'Select(0u2002)', + 'SetRBearing(500)', + ], + + spaceEm => [ + 'Select(0u2003)', + 'SetRBearing(999)', + ], + + space3 => [ + 'Select(0u2004)', + 'SetRBearing(333)', + ], + + space4 => [ + 'Select(0u2005)', + 'SetRBearing(250)', + ], + + space6 => [ + 'Select(0u2006)', + 'SetRBearing(167)', + ], + + thinspace => [ + 'Select(0u2009)', + 'SetRBearing(167)', + ], + + hairspace => [ + 'Select(0u200A)', + 'SetRBearing(83)', + ], + + cong => [ + 'Select(0u223C)','Copy()', + 'Select(0u2245)','Clear()', + 'PasteWithOffset(0,222)', + 'Select(0u3D)','Copy()', + 'Select(0u2245)', + 'PasteWithOffset(0,-111)', + 'SetWidth(778)', + ], + + bowtie => [ + 'Select(0u25B9)','Copy()', + 'Select(0u22C8)','Paste()', + 'Select(0u25C3)','Copy()', + 'Select(0u22C8)', + 'PasteWithOffset(400,0)', + 'SetRBearing(400,1)', + 'RemoveOverlap()', + ], + + models => [ + 'Select(0u2223)','Copy()', + 'Select(0u22A8)','Paste()', + 'Select(0u3D)','Copy()', + 'Select(0u22A8)', + 'PasteWithOffset(89,0)', + 'SetRBearing(589,1)', + 'RemoveOverlap()', + ], + + doteq => [ + 'Select(0u3D)','Copy()', + 'Select(0u2250)','Paste()', + 'Select(0u2E)','Copy()', + 'Select(0u2250)', + 'PasteWithOffset(251,550)', + ], + + not => [ + 'Select(0uE020)', + 'SetRBearing(778,1)', + ], + + #notin => [ + # 'Select(0u2208)','Copy()', + # 'Select(0u2209)','Paste()', + # 'Select(0u338)','Copy()', + # 'Select(0u2209)', + # 'PasteWithOffset(-55,0)', + # 'RemoveOverlap()', + #], + + #noteq => [ + # 'Select(0u3D)','Copy()', + # 'Select(0u2260)','Paste()', + # 'Select(0u338)','Copy()', + # 'Select(0u2260)', + # 'PasteWithOffset(0,0)', + # 'RemoveOverlap()', + #], + + longleftarrow => [ + 'Select(0u2190)','Copy()', + 'Select(0u27F5)','Paste()', + 'Select(0u2212)','Copy()', + 'Select(0u27F5)', + 'PasteWithOffset(831,0)', + 'SetRBearing(609,1)', + 'RemoveOverlap()','Simplify()', + ], + + Longleftarrow => [ + 'Select(0u21D0)','Copy()', + 'Select(0u27F8)','Paste()', + 'Select(0u3D)','Copy()', + 'Select(0u27F8)', + 'PasteWithOffset(831,0)', + 'SetRBearing(609,1)', + 'RemoveOverlap()','Simplify()', + ], + + longrightarrow => [ + 'Select(0u2212)','Copy()', + 'Select(0u27F6)','Paste()', + 'Select(0u2192)','Copy()', + 'Select(0u27F6)', + 'PasteWithOffset(609,0)', + 'SetRBearing(860,1)', + 'RemoveOverlap()','Simplify()', + ], + + Longrightarrow => [ + 'Select(0u3D)','Copy()', + 'Select(0u27F9)','Paste()', + 'Select(0u21D2)','Copy()', + 'Select(0u27F9)', + 'PasteWithOffset(638,0)', + 'SetRBearing(860,1)', + 'RemoveOverlap()','Simplify()', + ], + + leftrightarrow => [ + 'Select(0u2190)','Copy()', + 'Select(0u27F7)','Paste()', + 'Select(0u2192)','Copy()', + 'Select(0u27F7)', + 'PasteWithOffset(859,0)', + 'SetRBearing(859,1)', + 'RemoveOverlap()','Simplify()', + ], + + Leftrightarrow => [ + 'Select(0u21D0)','Copy()', + 'Select(0u27FA)','Paste()', + 'Select(0u21D2)','Copy()', + 'Select(0u27FA)', + 'PasteWithOffset(858,0)', + 'SetRBearing(858,1)', + 'RemoveOverlap()','Simplify()', + ], + + mapsto => [ + 'Select(0u2192)','Copy()', + 'Select(0u21A6)','Paste()', + 'Generate("otf/KaTeX_Main-Regular.otf")', + 'Open("pfa/cmsy10.pfa")', + 'Select(0x37)','Copy()', + 'Open("otf/KaTeX_Main-Regular.otf")', + 'Select(0u21A6)', + 'PasteWithOffset(0,0)', + 'RemoveOverlap()','Simplify()', + ], + + xlongmapsto => [ + 'Select(0u27F6)','Copy()', + 'Select(0u27FC)','Paste()', + 'Generate("otf/KaTeX_Main-Regular.otf")', + 'Open("pfa/cmsy10.pfa")', + 'Select(0x37)','Copy()', + 'Open("otf/KaTeX_Main-Regular.otf")', + 'Select(0u27FC)', + 'PasteWithOffset(0,0)', + 'RemoveOverlap()','Simplify()', + ], + + hookleftarrow => [ + 'Select(0u2190)','Copy()', + 'Select(0u21A9)','Paste()', + 'Generate("otf/KaTeX_Main-Regular.otf")', + 'Open("pfa/cmmi10.pfa")', + 'Select(0x2D)','Copy()', + 'Open("otf/KaTeX_Main-Regular.otf")', + 'Select(0u21A9)', + 'PasteWithOffset(848,0)', + 'SetRBearing(126,1)', + 'RemoveOverlap()','Simplify()', + ], + + hookrightarrow => [ + 'Generate("otf/KaTeX_Main-Regular.otf")', + 'Open("pfa/cmmi10.pfa")', + 'Select(0x2C)','Copy()', + 'Open("otf/KaTeX_Main-Regular.otf")', + 'Select(0u21AA)','Paste()', + 'Select(0u2192)','Copy()', + 'Select(0u21AA)', + 'PasteWithOffset(126,0)', + 'SetRBearing(848,1)', + 'RemoveOverlap()','Simplify()', + ], + + rightleftharpoons => [ + 'Select(0u21BD)','Copy()', + 'Select(0u21CC)','Paste()', + 'Select(0u21C0)','Copy()', + 'Select(0u21CC)', + 'PasteWithOffset(0,160)', + 'RemoveOverlap()','Simplify()', + ], + + lgroup => [ + 'Select(0u23B0)','Copy()', + 'Select(0u27EE)','Paste()', + 'Select(0u23A9)','Copy()', + 'Select(0u27EE)', + 'PasteWithOffset(0,0)', + 'Scale(55,0,0)','RoundToInt()','Move(-38,250)', + 'RemoveOverlap()','Simplify()', + 'SetRBearing(-38,1)', + ], + + rgroup => [ + 'Select(0u23B1)','Copy()', + 'Select(0u27EF)','Paste()', + 'Select(0u23AD)','Copy()', + 'Select(0u27EF)', + 'PasteWithOffset(1,0)', + 'Scale(55,0,0)','RoundToInt()','Move(-38,250)', + 'RemoveOverlap()','Simplify()', + 'SetRBearing(-38,1)', + ], + + lmoustache => [ + 'Select(0u23AD)','Copy()', + 'Select(0u23B0)', + 'PasteWithOffset(0,0)', + 'Scale(55,0,0)','RoundToInt()','Move(-38,250)', + 'RemoveOverlap()','Simplify()', + 'SetRBearing(-38,1)', + ], + + rmoustache => [ + 'Select(0u23A9)','Copy()', + 'Select(0u23B1)', + 'PasteWithOffset(0,0)', + 'Scale(55,0,0)','RoundToInt()','Move(-38,250)', + 'RemoveOverlap()','Simplify()', + 'SetRBearing(-38,1)', + ], + + diacriticals => [ + 'Select(0uB0)', 'SetRBearing(-125,1)', # \degree + 'Select(0u20D7)','SetRBearing(153,1)', # \vec + ], + +}; + +$extra{'Main-Bold'} = { + cdots => [ + 'Select(0u22C5)','Copy()', + 'Select(0u22EF)','Paste()', + 'PasteWithOffset(488,0)', + 'PasteWithOffset(976,0)', + 'SetRBearing(976,1)', + ], + + ldots => [ + 'Select(0u2E)','Copy()', + 'Select(0u2026)','Paste()', + 'PasteWithOffset(488,0)', + 'PasteWithOffset(976,0)', + 'SetRBearing(976,1)', + ], + + vdots => [ + 'Select(0u2E)','Copy()', + 'Select(0u22EE)','Clear()', + 'PasteWithOffset(0,-30)', + 'PasteWithOffset(0,380)', + 'PasteWithOffset(0,780)', + 'SetRBearing(-681,1)', + ], + + ddots => [ + 'Select(0u2E)','Copy()', + 'Select(0u22F1)','Clear()', + 'PasteWithOffset(55,700)', + 'PasteWithOffset(502,400)', + 'PasteWithOffset(949,100)', + 'SetRBearing(323,1)', + ], + + spaceEn => [ + 'Select(0u2002)', + 'SetRBearing(500)', + ], + + spaceEm => [ + 'Select(0u2003)', + 'SetRBearing(999)', + ], + + space3 => [ + 'Select(0u2004)', + 'SetRBearing(333)', + ], + + space4 => [ + 'Select(0u2005)', + 'SetRBearing(250)', + ], + + space6 => [ + 'Select(0u2006)', + 'SetRBearing(167)', + ], + + thinspace => [ + 'Select(0u2009)', + 'SetRBearing(167)', + ], + + hairspace => [ + 'Select(0u200A)', + 'SetRBearing(83)', + ], + + cong => [ + 'Select(0u223C)','Copy()', + 'Select(0u2245)','Clear()', + 'PasteWithOffset(0,247)', + 'Select(0u3D)','Copy()', + 'Select(0u2245)', + 'PasteWithOffset(0,-136)', + 'SetWidth(894)', + ], + + bowtie => [ + 'Select(0u25B9)','Copy()', + 'Select(0u22C8)','Paste()', + 'Select(0u25C3)','Copy()', + 'Select(0u22C8)', + 'PasteWithOffset(425,0)', + 'SetRBearing(425,1)', + 'RemoveOverlap()', + ], + + models => [ + 'Select(0u2223)','Copy()', + 'Select(0u22A8)','Paste()', + 'Select(0u3D)','Copy()', + 'Select(0u22A8)', + 'PasteWithOffset(89,0)', + 'SetRBearing(655,1)', + 'RemoveOverlap()', + ], + + doteq => [ + 'Select(0u3D)','Copy()', + 'Select(0u2250)','Paste()', + 'Select(0u2E)','Copy()', + 'Select(0u2250)', + 'PasteWithOffset(288,550)', + ], + + not => [ + 'Select(0uE020)', + 'SetRBearing(894,1)', + ], + +# notin => [ +# 'Select(0u2208)','Copy()', +# 'Select(0u2209)','Paste()', +# 'Select(0u338)','Copy()', +# 'Select(0u2209)', +# 'PasteWithOffset(-63,0)', +# 'PasteWithOffset(831,0)', +# 'RemoveOverlap()', +# ], + +# noteq => [ +# 'Select(0u3D)','Copy()', +# 'Select(0u2260)','Paste()', +# 'Select(0u338)','Copy()', +# 'Select(0u2260)', +# 'PasteWithOffset(0,0)', +# 'PasteWithOffset(894,0)', +# 'RemoveOverlap()', +# ], + + longleftarrow => [ + 'Select(0u2190)','Copy()', + 'Select(0u27F5)','Paste()', + 'Select(0u2212)','Copy()', + 'Select(0u27F5)', + 'PasteWithOffset(944,0)', + 'SetRBearing(655,1)', + 'RemoveOverlap()','Simplify()', + ], + + Longleftarrow => [ + 'Select(0u21D0)','Copy()', + 'Select(0u27F8)','Paste()', + 'Select(0u3D)','Copy()', + 'Select(0u27F8)', + 'PasteWithOffset(975,0)', + 'SetRBearing(718,1)', + 'RemoveOverlap()','Simplify()', + ], + + longrightarrow => [ + 'Select(0u2212)','Copy()', + 'Select(0u27F6)','Paste()', + 'Select(0u2192)','Copy()', + 'Select(0u27F6)', + 'PasteWithOffset(688,0)', + 'SetRBearing(939,1)', + 'RemoveOverlap()','Simplify()', + ], + + Longrightarrow => [ + 'Select(0u3D)','Copy()', + 'Select(0u27F9)','Paste()', + 'Select(0u21D2)','Copy()', + 'Select(0u27F9)', + 'PasteWithOffset(720,0)', + 'SetRBearing(976,1)', + 'RemoveOverlap()','Simplify()', + ], + + leftrightarrow => [ + 'Select(0u2190)','Copy()', + 'Select(0u27F7)','Paste()', + 'Select(0u2192)','Copy()', + 'Select(0u27F7)', + 'PasteWithOffset(976,0)', + 'SetRBearing(976,1)', + 'RemoveOverlap()','Simplify()', + ], + + Leftrightarrow => [ + 'Select(0u21D0)','Copy()', + 'Select(0u27FA)','Paste()', + 'Select(0u21D2)','Copy()', + 'Select(0u27FA)', + 'PasteWithOffset(976,0)', + 'SetRBearing(976,1)', + 'RemoveOverlap()','Simplify()', + ], + + mapsto => [ + 'Select(0u2192)','Copy()', + 'Select(0u21A6)','Paste()', + 'Generate("otf/KaTeX_Main-Bold.otf")', + 'Open("pfa/cmbsy10.pfa")', + 'Select(0x37)','Copy()', + 'Open("otf/KaTeX_Main-Bold.otf")', + 'Select(0u21A6)', + 'PasteWithOffset(0,0)', + 'RemoveOverlap()','Simplify()', + ], + + xlongmapsto => [ + 'Select(0u27F6)','Copy()', + 'Select(0u27FC)','Paste()', + 'Generate("otf/KaTeX_Main-Bold.otf")', + 'Open("pfa/cmbsy10.pfa")', + 'Select(0x37)','Copy()', + 'Open("otf/KaTeX_Main-Bold.otf")', + 'Select(0u27FC)', + 'PasteWithOffset(0,0)', + 'RemoveOverlap()','Simplify()', + ], + + hookleftarrow => [ + 'Select(0u2190)','Copy()', + 'Select(0u21A9)','Paste()', + 'Generate("otf/KaTeX_Main-Bold.otf")', + 'Open("pfa/cmmib10.pfa")', + 'Select(0x2D)','Copy()', + 'Open("otf/KaTeX_Main-Bold.otf")', + 'Select(0u21A9)', + 'PasteWithOffset(965,0)', + 'SetRBearing(132,1)', + 'RemoveOverlap()','Simplify()', + ], + + hookrightarrow => [ + 'Generate("otf/KaTeX_Main-Bold.otf")', + 'Open("pfa/cmmib10.pfa")', + 'Select(0x2C)','Copy()', + 'Open("otf/KaTeX_Main-Bold.otf")', + 'Select(0u21AA)','Paste()', + 'Select(0u2192)','Copy()', + 'Select(0u21AA)', + 'PasteWithOffset(132,0)', + 'SetRBearing(963,1)', + 'RemoveOverlap()','Simplify()', + ], + + rightleftharpoons => [ + 'Select(0u21BD)','Copy()', + 'Select(0u21CC)','Paste()', + 'Select(0u21C0)','Copy()', + 'Select(0u21CC)', + 'PasteWithOffset(0,200)', + 'RemoveOverlap()','Simplify()', + ], + + hbar => [ + 'Select(0u2C9)','Copy()', + 'Select(0u210F)','PasteWithOffset(0,0)', + 'RemoveOverlap()','Simplify()', + ], + + angle => [ + 'Select(0u2220)','Copy()', + 'PasteWithOffset(0,10)', + 'PasteWithOffset(0,20)', + 'RemoveOverlap()','Simplify()', + 'PasteWithOffset(10,0)', + 'RemoveOverlap()','Simplify()', + ], + + diacriticals => [ + 'Select(0uB0)', 'SetRBearing(-147,1)', # \degree + 'Select(0u20D7)','SetRBearing(154,1)', # \vec + ], +}; + +$extra{'Main-Italic'} = { + diacriticals => [ + 'Select(0uB0)', 'SetRBearing(-160,1)', # \degree + ], +}; + +$extra{'Size1'} = { + iint => [ + 'Select(0u222B)', 'Copy()', + 'Select(0u222C)', 'Paste()', + 'PasteWithOffset(347,0)', + 'SetRBearing(347,1)', + ], + + iiint => [ + 'Select(0u222B)', 'Copy()', + 'Select(0u222D)', 'Paste()', + 'PasteWithOffset(347,0)', + 'PasteWithOffset(694,0)', + 'SetRBearing(694,1)', + ], +}; + +$extra{'Size2'} = { + iint => [ + 'Select(0u222B)', 'Copy()', + 'Select(0u222C)', 'Paste()', + 'PasteWithOffset(528,0)', + 'SetRBearing(528,1)', + ], + + iiint => [ + 'Select(0u222B)', 'Copy()', + 'Select(0u222D)', 'Paste()', + 'PasteWithOffset(528,0)', + 'PasteWithOffset(1036,0)', + 'SetRBearing(1036,1)', + ], +}; + +$extra{'Size4'} = { + braceext => [ + 'Open("lib/Extra.otf")', + 'Select(0u5F)','Copy()', + 'Open("otf/KaTeX_Size4-Regular.otf")', + 'Select(0uE154)','Paste()', + ], +}; + +$extra{"AMS"} = { + dashleftarrow => [ + 'Select(0u2190)', 'Copy()', + 'Select(0u21E0)', 'Paste()', + 'Select(0u2212)','Copy()', + 'Select(0u21E0)', + 'PasteWithOffset(417,0)', + 'PasteWithOffset(834,0)', + 'SetRBearing(834,1)', + ], + + dashrightarrow => [ + 'Select(0u2212)', 'Copy()', + 'Select(0u21E2)', 'Paste()', + 'PasteWithOffset(417,0)', + 'Select(0u2192)','Copy()', + 'Select(0u21E2)','PasteWithOffset(834,0)', + 'SetRBearing(834,1)', + ], +}; + +$extra{'Typewriter'} = { + space => [ + 'Select(0u20)','Clear()', + 'SetRBearing(525)', + ], + + spaceNB => [ + 'Select(0uA0)','Clear()', + 'SetRBearing(525)', + ], +}; + +$extra{"SansSerif-Regular"} = { + diacriticals => [ + 'Select(0uB0)', 'SetRBearing(-142,1)', # \degree + ], +}; + +$extra{"SansSerif-Italic"} = { + diacriticals => [ + 'Select(0uB0)', 'SetRBearing(-113,1)', # \degree + ], +}; + +$extra{"SansSerif-Bold"} = { + diacriticals => [ + 'Select(0uB0)', 'SetRBearing(-58,1)', # \degree + ], +}; + +######################################################################### + +foreach $cmfont (sort (keys %map)) { + print "Reading $cmfont...\n"; + foreach $mjfont (keys %{$map{$cmfont}}) { + $fontname = "KaTeX_$mjfont"; + $style = $fontname; $style =~ s/.*?(-|$)//; $style = "Regular" unless $style; + $normal = "Normal"; $normal = "Bold" if style =~ m/Bold/; + $family = $fontname; $family =~ s/-.*//; + $fontname = "$family-$style"; + $STYLE = $style; $STYLE = "Bold Italic" if $STYLE eq "BoldItalic"; + $otf = "otf/$fontname.otf"; + unless (defined($script{$mjfont})) { + open(SPACE,"lib/Space.ttx"); $lines = join("",); close(SPACE); + $lines =~ s/\*NAME\*/$family/g; $lines =~ s/\*WEIGHT\*/$style/g; + $lines =~ s/\*WEIGHT_S\*/$STYLE/g; $lines =~ s/\*NORMAL\*/$normal/g; + if ($style eq "Regular") {$lines =~ s/\* WEIGHT\*//g} else {$lines =~ s/\* WEIGHT\*/ $STYLE/g} + open(SPACE,">Space.ttx"); print SPACE $lines; close(SPACE); + `$TTX -f Space.ttx; mv Space.otf '$otf'`; unlink("Space.ttx"); + $script{$mjfont} = [ + 'Open("'.$otf.'")', + 'SetPanose([0,0,'.($style eq 'Bold' ? '8' : '0').',0,0,0,0,0,0,0])', + 'SetOS2Value("Weight",'.($style =~ m/Bold/ ? 700 : 400).')', + 'SetGasp(8,2,16,1,65535,3)', + 'Reencode("unicode")', + 'Generate("'.$otf.'")', + ]; + } + $script = $script{$mjfont}; + @remap = @{$map{$cmfont}{$mjfont}}; + while (defined($item = shift(@remap))) { + $remap = shift(@remap); + if ($cmfont =~ /^eu/) { + push(@$script,'Open("pfa/'.$cmfont.'.pfb")'); + } else { + push(@$script,'Open("pfa/'.$cmfont.'.pfa")'); + } + if (ref($item) eq "ARRAY") { + push(@$script,'Select('.sprintf("%d,%d",@$item).')'); + } else { + push(@$script,'Select('.$item.')'); + } + push(@$script,"Copy()",'Open("'.$otf.'")'); + if (ref($item) eq "ARRAY") { + push(@$script, + 'Select('.sprintf("0u%04x,0u%04x",$remap,$remap+($item->[1]-$item->[0])).')', + 'Paste()', + ); + } elsif (ref($remap) eq "ARRAY") { + push(@$script, + 'Select('.sprintf("0u%04x",$remap->[0]).')', + 'Paste()', + 'Move('.$remap->[1].','.$remap->[2].')', + ); + } else { + push(@$script,'Select('.sprintf("0u%04x",$remap).')','Paste()'); + } + push(@$script,'Generate("'.$otf.'")'); + } + } +} +print "\n"; + + +# +# Add extra characters by hand +# +foreach $font (keys %extra) { + foreach $char (sort(keys %{$extra{$font}})) { + push(@{$script{$font}},join(";\n",@{$extra{$font}{$char}}),""); + } +} + +# Cleanup temporary glyphs +push(@{$script{'Main-Regular'}}, + 'Select(0u23A9)', + 'Clear()', + 'Select(0u23AD)', + 'Clear()', +); + +# +# Write all scripts +# +foreach $font (sort keys %script) { + $family = $font; $family .= "-Regular" unless $family =~ m/-/; + print "KaTeX_$font\n"; + open(SCRIPT,">","ff/KaTeX_$family.ff"); + print SCRIPT join(";\n",@{$script{$font}},"", + 'SelectAll()','RoundToInt()', + 'Simplify()','AddExtrema()','Simplify()', + 'ClearHints()','AutoHint()','RoundToInt()', + 'Generate("otf/KaTeX_'.$family.'.otf")', + 'SelectAll()','AutoInstr()', + 'Generate("ttf/KaTeX_'.$family.'.ttf")'),"\n"; + close(SCRIPT); +} + +1; diff --git a/node_modules/react-katex/node_modules/katex/src/fonts/xbbold.mf b/node_modules/react-katex/node_modules/katex/src/fonts/xbbold.mf new file mode 100644 index 0000000..64a6683 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/fonts/xbbold.mf @@ -0,0 +1,182 @@ +%% filename: xbbold.mf +%% version: 2.2 +%% date: 1995/01/04 +%% +%% (katex-fonts) The line 69 is modified to prevent overflow +%% +%% American Mathematical Society +%% Technical Support +%% Publications Technical Group +%% 201 Charles Street +%% Providence, RI 02904 +%% USA +%% tel: (401) 455-4080 +%% (800) 321-4267 (USA and Canada only) +%% fax: (401) 331-3842 +%% email: tech-support@ams.org +%% +%% Copyright 1995, 2009 American Mathematical Society. +%% +%% This Font Software is licensed under the SIL Open Font License, +%% Version 1.1. This license is in the accompanying file OFL.txt, and +%% is also available with a FAQ at: http://scripts.sil.org/OFL. +%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% Changes of minimal parameters in outlined characters for version 2.1 +% done by Stefan Lindner, 18-April-1991 + +input xbbase; +%%mode_setup; %called by amsyb.mf; two calls confuse Metafont. NGB 15-OCT-1991 + +%%%%designsize:= font_size; % was 10pt#; +width#:= designsize; % was 10pt#; +unit#:= width#/18; +u#:= width#/54; +smallu#:= width#/162; +ascender#:= 37/3*unit#; +cap#:= 37/3*unit#; +number#:= 36/3*unit#; +xheight#:= 25/3*unit#; +descender#:= 12/4*unit#; +define_whole_vertical_pixels + (width,unit,u,smallu,ascender,cap,number,xheight,descender); +wpix(1.90u) (linethickness); +wpix(0.65u) (Sover_bot); +wpix(1.00u) (Aapex,Napex,Vapex,Wapex,Cover,Gover,Oover,Sover_top,Uover); +wpix(9.00u) (Uthin_bracket); +wpix(8.00u) (Kthin_diag_bracket,Xthin_diag_bracket,Ythin_diag_bracket); +wpix(7.00u) (k_thin_diag); +wpix(6.00u) (c_thin_stem_bracket); +wpix(5.00u) (c_thick_stem_bracket,c_inner_bracket,lc_thick_stem_bracket); +wpix(4.00u) (c_round_bracket); +adjpix(1.35u) (serif_thickness); +adjpix(1.30u) (Emid_tip,inbeak); +adjpix(1.50u) (Atip,Btopthin,Bmidthin,Ebot_tip,Ltip,Mapex, + Ntip,Ttip,Vtip,Wtip,Ztip,outbeak); +adjpix(1.65u) (Bbotthin,Gbotthin,Stopthin); +adjpix(1.75u) (Dtopthin,Ebotarm,Lthin,Tthin); +adjpix(1.80u) (Abar,Ctopthin,Dbotthin,Gtopthin,Jbotthin,Pmidarm,Sbotthin); +adjpix(1.90u) (Emidarm,Etoparm,Othin,Pthin,Rthin,Ydiag,Zthin); +adjpix(2.00u) (kthin,Mthin_diag,Wleftthin); +adjpix(2.10u) (Ctip); +adjpix(2.25u) (Athin,Kthin,Mthin_vert,Nthin,Uthin,Vthin,Wrightthin,Xthin); +adjpix(2.50u) (Hbar); +adjpix(2.60u) (Cbotthin); + + +%%%% Begin of changes for version 2.1 +%(katex-fonts) Originally was pixels_per_inch*designsize < 1500: +if pixels_per_inch < 1500/designsize: + if pixels_per_inch*designsize < 1000: + if pixels_per_inch*designsize < 800: + if pixels_per_inch*designsize < 700: + minadjpix(0)(8.80u) (stem); + minadjpix(0)(6.80u) (kdiag); + minadjpix(0)(7.40u) (kstem); + minadjpix(0)(7.80u) (Jbulb,Mdiag); + minadjpix(0)(8.20u) (Kdiag); + minadjpix(0)(8.30u) (Gstem,Mstem); + minadjpix(0)(8.60u) (Lstem,Ustem,Ythick_diag); + minadjpix(0)(8.50u) (Bstem,Estem,Fstem,Ndiag,Rdiag,Xdiag,Zdiag); + minadjpix(0)(8.90u) (Btopcurve); + minadjpix(1)(9.30u) (Bbotcurve,Pcurve,Rcurve); + minadjpix(1)(9.50u) (Ccurve,Dcurve,Gcurve,Ocurve); + else: + minadjpix(1)(8.80u) (stem); + minadjpix(1)(6.80u) (kdiag); + minadjpix(1)(7.40u) (kstem); + minadjpix(1)(7.80u) (Jbulb,Mdiag); + minadjpix(1)(8.20u) (Kdiag); + minadjpix(1)(8.30u) (Gstem,Mstem); + minadjpix(1)(8.60u) (Lstem,Ustem,Ythick_diag); + minadjpix(1)(8.50u) (Bstem,Estem,Fstem,Ndiag,Rdiag,Xdiag,Zdiag); + minadjpix(1)(8.90u) (Btopcurve); + minadjpix(2)(9.30u) (Bbotcurve,Pcurve,Rcurve); + minadjpix(2)(9.50u) (Ccurve,Dcurve,Gcurve,Ocurve); + fi + else: + adjpix(3.0u) (Mapex); + minadjpix(1)(8.80u) (stem); + minadjpix(2)(6.80u) (kdiag); + minadjpix(2)(7.40u) (kstem); + minadjpix(2)(7.80u) (Jbulb); + minadjpix(1)(6.00u) (Mdiag); + minadjpix(2)(8.20u) (Kdiag); + minadjpix(2)(8.30u) (Gstem) + minadjpix(2)(8.30u) (Mstem); + minadjpix(2)(8.60u) (Lstem,Ustem,Ythick_diag); + minadjpix(2)(8.50u) (Bstem,Ndiag,Rdiag,Xdiag,Zdiag); + minadjpix(1)(8.50u) (Estem, Fstem); + minadjpix(2)(8.90u) (Btopcurve); + minadjpix(3)(9.30u) (Bbotcurve,Pcurve,Rcurve); + minadjpix(3)(9.50u) (Ccurve,Dcurve,Gcurve,Ocurve); + fi + else: + adjpix(3.0u) (Mapex); + minadjpix(2)(8.80u) (stem); + minadjpix(3)(6.80u) (kdiag); + minadjpix(3)(7.40u) (kstem); + minadjpix(3)(7.80u) (Jbulb); + minadjpix(1)(5.00u) (Mdiag); + minadjpix(3)(8.20u) (Kdiag); + minadjpix(3)(8.30u) (Gstem); + minadjpix(2)(8.30u) (Mstem); + minadjpix(3)(8.60u) (Lstem,Ustem,Ythick_diag); + minadjpix(3)(8.50u) (Estem,Fstem,Ndiag,Rdiag,Xdiag,Zdiag); + minadjpix(2)(8.50u) (Bstem); + minadjpix(3)(8.90u) (Btopcurve); + minadjpix(3)(9.30u) (Bbotcurve,Pcurve,Rcurve); + minadjpix(3)(9.50u) (Ccurve,Dcurve,Gcurve,Ocurve) + fi +else: + minadjpix(4)(8.80u) (stem); + minadjpix(4)(6.80u) (kdiag); + minadjpix(4)(7.40u) (kstem); + minadjpix(4)(7.80u) (Jbulb,Mdiag); + minadjpix(4)(8.20u) (Kdiag); + minadjpix(4)(8.30u) (Gstem,Mstem); + minadjpix(4)(8.60u) (Lstem,Ustem,Ythick_diag); + minadjpix(4)(8.50u) (Bstem,Estem,Fstem,Ndiag,Rdiag,Xdiag,Zdiag); + minadjpix(4)(8.90u) (Btopcurve); + minadjpix(5)(9.30u) (Bbotcurve,Pcurve,Rcurve); + minadjpix(5)(9.50u) (Ccurve,Dcurve,Gcurve,Ocurve) +fi; +%%%% end of changes for version 2.1 + +boolean lowres; lowres:=width<50; +highres_lowres(pullin) (.85)(1); % Emidarm +highres_lowres(pulleven) (1)(1.3); % Etoparm,Tarms,Zarms +highres_lowres(pullout) (1.1)(1); % Ebotarm,Lbotarm +highres_lowres(bracket0) (.0)(0); % Ntopleft +highres_lowres(bracket3) (.3)(0); % Nthinstems +highres_lowres(bracket01) (.0)(.1); % Uthin +highres_lowres(bracket32) (.3)(.2); % Vstems +highres_lowres(bracket4) (.4)(0); % P-all,R-all,I-all,F-all +highres_lowres(bracket42) (.4)(.2); % Xdiag + +bool(ctrls):=false; +entasis:=inlimit(0)(0,1); +serif_constant_amt:=0pt; +join_radius:=1; +bool(softpath):=true; + +c_thick_stem_bracket:=min(.5cap-eps,c_thick_stem_bracket); +rulepen:=pensquare scaled 1; +extra_beginchar:=extra_beginchar&"save t,p,ref; path p[],p[]',p[]'',ref[];"; +extra_beginchar:=extra_beginchar&"pickup pencircle scaled linethickness;"; + +for x:="R": + wanted[byte x]:=true; endfor % test these characters + let iff=always_iff; % tests all chars in the file + +font_normal_space .3width#; % TeX fontdimen 2 normal word space +font_normal_stretch .15width#; % TeX fontdimen 3 interword stretch +font_normal_shrink .1width#; % TeX fontdimen 4 interword shrink +font_x_height xheight#; % Tex fontdinem 5 for accents +font_quad width#; % TeX fontdimen 6 quad width +font_extra_space .1width#; % TeX fontdimen 7 extra space(period) + + +input xbcaps +bye % changed from "end" 26 Aug 93; bnb diff --git a/node_modules/react-katex/node_modules/katex/src/functions.ts b/node_modules/react-katex/node_modules/katex/src/functions.ts new file mode 100644 index 0000000..bb0a155 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/functions.ts @@ -0,0 +1,54 @@ +/** Include this to ensure that all functions are defined. */ +import {_functions} from "./defineFunction"; + +const functions = _functions; +export default functions; + +// TODO(kevinb): have functions return an object and call defineFunction with +// that object in this file instead of relying on side-effects. +import "./functions/accent"; +import "./functions/accentunder"; +import "./functions/arrow"; +import "./functions/pmb"; +import "./environments/cd"; +import "./functions/char"; +import "./functions/color"; +import "./functions/cr"; +import "./functions/def"; +import "./functions/delimsizing"; +import "./functions/enclose"; +import "./functions/environment"; +import "./functions/font"; +import "./functions/genfrac"; +import "./functions/horizBrace"; +import "./functions/href"; +import "./functions/hbox"; +import "./functions/html"; +import "./functions/htmlmathml"; +import "./functions/includegraphics"; +import "./functions/kern"; +import "./functions/lap"; +import "./functions/math"; +import "./functions/mathchoice"; +import "./functions/mclass"; +import "./functions/op"; +import "./functions/operatorname"; +import "./functions/ordgroup"; +import "./functions/overline"; +import "./functions/phantom"; +import "./functions/raisebox"; +import "./functions/relax"; +import "./functions/rule"; +import "./functions/sizing"; +import "./functions/smash"; +import "./functions/sqrt"; +import "./functions/styling"; +import "./functions/supsub"; +import "./functions/symbolsOp"; +import "./functions/symbolsOrd"; +import "./functions/symbolsSpacing"; +import "./functions/tag"; +import "./functions/text"; +import "./functions/underline"; +import "./functions/vcenter"; +import "./functions/verb"; diff --git a/node_modules/react-katex/node_modules/katex/src/functions/accent.ts b/node_modules/react-katex/node_modules/katex/src/functions/accent.ts new file mode 100644 index 0000000..1c9d9ec --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/functions/accent.ts @@ -0,0 +1,285 @@ +import defineFunction, {normalizeArgument} from "../defineFunction"; +import {makeOrd, makeSpan, makeVList, staticSvg, svgData} from "../buildCommon"; +import {isCharacterBox} from "../utils"; +import {MathNode} from "../mathMLTree"; +import {stretchyMathML, stretchySvg} from "../stretchy"; +import {assertNodeType} from "../parseNode"; +import {assertSpan, assertSymbolDomNode, hasHtmlDomChildren, SymbolNode} from "../domTree"; +import {makeEm} from "../units"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; + +import type {ParseNode, AnyParseNode} from "../parseNode"; +import type {HtmlBuilderSupSub, MathMLBuilder} from "../defineFunction"; +import type {HtmlDomNode} from "../domTree"; + +const getBaseSymbol = (group: HtmlDomNode): SymbolNode | undefined => { + if (group instanceof SymbolNode) { + return group; + } + if (hasHtmlDomChildren(group) && group.children.length === 1) { + return getBaseSymbol(group.children[0]); + } +}; + +// NOTE: Unlike most `htmlBuilder`s, this one handles not only "accent", but +// also "supsub" since an accent can affect super/subscripting. +export const htmlBuilder: HtmlBuilderSupSub<"accent"> = (grp, options) => { + // Accents are handled in the TeXbook pg. 443, rule 12. + let base: AnyParseNode; + let group: ParseNode<"accent">; + + let supSubGroup; + if (grp && grp.type === "supsub") { + // If our base is a character box, and we have superscripts and + // subscripts, the supsub will defer to us. In particular, we want + // to attach the superscripts and subscripts to the inner body (so + // that the position of the superscripts and subscripts won't be + // affected by the height of the accent). We accomplish this by + // sticking the base of the accent into the base of the supsub, and + // rendering that, while keeping track of where the accent is. + + // The real accent group is the base of the supsub group + group = assertNodeType(grp.base, "accent"); + // The character box is the base of the accent group + base = group.base; + // Stick the character box into the base of the supsub group + grp.base = base; + + // Rerender the supsub group with its new base, and store that + // result. + supSubGroup = assertSpan(html.buildGroup(grp, options)); + + // reset original base + grp.base = group; + } else { + group = assertNodeType(grp, "accent"); + base = group.base; + } + + // Build the base group + const body = html.buildGroup(base, options.havingCrampedStyle()); + + // Does the accent need to shift for the skew of a character? + const mustShift = group.isShifty && isCharacterBox(base); + + // Calculate the skew of the accent. This is based on the line "If the + // nucleus is not a single character, let s = 0; otherwise set s to the + // kern amount for the nucleus followed by the \skewchar of its font." + // Note that our skew metrics are just the kern between each character + // and the skewchar. + let skew = 0; + if (mustShift) { + // Read the skew from the rendered base symbol. + // This preserves font metrics from font wrappers like \mathbb. + skew = getBaseSymbol(body)?.skew ?? 0; + } + + const accentBelow = group.label === "\\c"; + + // calculate the amount of space between the body and the accent + let clearance = accentBelow + ? body.height + body.depth + : Math.min( + body.height, + options.fontMetrics().xHeight); + + // Build the accent + let accentBody; + if (!group.isStretchy) { + let accent; + let width: number; + if (group.label === "\\vec") { + // Before version 0.9, \vec used the combining font glyph U+20D7. + // But browsers, especially Safari, are not consistent in how they + // render combining characters when not preceded by a character. + // So now we use an SVG. + // If Safari reforms, we should consider reverting to the glyph. + accent = staticSvg("vec", options); + width = svgData.vec[1]; + } else { + accent = makeOrd({type: "textord", mode: group.mode, text: group.label}, + options, "textord"); + accent = assertSymbolDomNode(accent); + // Remove the italic correction of the accent, because it only serves to + // shift the accent over to a place we don't want. + accent.italic = 0; + width = accent.width; + if (accentBelow) { + clearance += accent.depth; + } + } + + accentBody = makeSpan(["accent-body"], [accent]); + + // "Full" accents expand the width of the resulting symbol to be + // at least the width of the accent, and overlap directly onto the + // character without any vertical offset. + const accentFull = (group.label === "\\textcircled"); + if (accentFull) { + accentBody.classes.push('accent-full'); + clearance = body.height; + } + + // Shift the accent over by the skew. + let left = skew; + + // CSS defines `.katex .accent .accent-body:not(.accent-full) { width: 0 }` + // so that the accent doesn't contribute to the bounding box. + // We need to shift the character by its width (effectively half + // its width) to compensate. + if (!accentFull) { + left -= width / 2; + } + + accentBody.style.left = makeEm(left); + + // \textcircled uses the \bigcirc glyph, so it needs some + // vertical adjustment to match LaTeX. + if (group.label === "\\textcircled") { + accentBody.style.top = ".2em"; + } + + accentBody = makeVList({ + positionType: "firstBaseline", + children: [ + {type: "elem", elem: body}, + {type: "kern", size: -clearance}, + {type: "elem", elem: accentBody}, + ], + }, options); + + } else { + accentBody = stretchySvg(group, options); + + accentBody = makeVList({ + positionType: "firstBaseline", + children: [ + {type: "elem", elem: body}, + { + type: "elem", + elem: accentBody, + wrapperClasses: ["svg-align"], + wrapperStyle: skew > 0 + ? { + width: `calc(100% - ${makeEm(2 * skew)})`, + marginLeft: makeEm(2 * skew), + } + : undefined, + }, + ], + }, options); + } + + const accentWrap = + makeSpan(["mord", "accent"], [accentBody], options); + + if (supSubGroup) { + // Here, we replace the "base" child of the supsub with our newly + // generated accent. + supSubGroup.children[0] = accentWrap; + + // Since we don't rerun the height calculation after replacing the + // accent, we manually recalculate height. + supSubGroup.height = Math.max(accentWrap.height, supSubGroup.height); + + // Accents should always be ords, even when their innards are not. + supSubGroup.classes[0] = "mord"; + + return supSubGroup; + } else { + return accentWrap; + } +}; + +const mathmlBuilder: MathMLBuilder<"accent"> = (group, options) => { + const accentNode = + group.isStretchy ? + stretchyMathML(group.label) : + new MathNode("mo", [mml.makeText(group.label, group.mode)]); + + const node = new MathNode( + "mover", + [mml.buildGroup(group.base, options), accentNode]); + + node.setAttribute("accent", "true"); + + return node; +}; + +const NON_STRETCHY_ACCENT_REGEX = new RegExp([ + "\\acute", "\\grave", "\\ddot", "\\tilde", "\\bar", "\\breve", + "\\check", "\\hat", "\\vec", "\\dot", "\\mathring", +].map(accent => `\\${accent}`).join("|")); + +// Accents +defineFunction({ + type: "accent", + names: [ + "\\acute", "\\grave", "\\ddot", "\\tilde", "\\bar", "\\breve", + "\\check", "\\hat", "\\vec", "\\dot", "\\mathring", "\\widecheck", + "\\widehat", "\\widetilde", "\\overrightarrow", "\\overleftarrow", + "\\Overrightarrow", "\\overleftrightarrow", "\\overgroup", + "\\overlinesegment", "\\overleftharpoon", "\\overrightharpoon", + ], + props: { + numArgs: 1, + }, + handler: (context, args) => { + const base = normalizeArgument(args[0]); + + const isStretchy = !NON_STRETCHY_ACCENT_REGEX.test(context.funcName); + const isShifty = !isStretchy || + context.funcName === "\\widehat" || + context.funcName === "\\widetilde" || + context.funcName === "\\widecheck"; + + return { + type: "accent", + mode: context.parser.mode, + label: context.funcName, + isStretchy: isStretchy, + isShifty: isShifty, + base: base, + }; + }, + htmlBuilder, + mathmlBuilder, +}); + +// Text-mode accents +defineFunction({ + type: "accent", + names: [ + "\\'", "\\`", "\\^", "\\~", "\\=", "\\u", "\\.", '\\"', + "\\c", "\\r", "\\H", "\\v", "\\textcircled", + ], + props: { + numArgs: 1, + allowedInText: true, + allowedInMath: true, // unless in strict mode + argTypes: ["primitive"], + }, + handler: (context, args) => { + const base = args[0]; + let mode = context.parser.mode; + + if (mode === "math") { + context.parser.settings.reportNonstrict("mathVsTextAccents", + `LaTeX's accent ${context.funcName} works only in text mode`); + mode = "text"; + } + + return { + type: "accent", + mode: mode, + label: context.funcName, + isStretchy: false, + isShifty: true, + base: base, + }; + }, + htmlBuilder, + mathmlBuilder, +}); diff --git a/node_modules/react-katex/node_modules/katex/src/functions/accentunder.ts b/node_modules/react-katex/node_modules/katex/src/functions/accentunder.ts new file mode 100644 index 0000000..56a724e --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/functions/accentunder.ts @@ -0,0 +1,59 @@ +// Horizontal overlap functions +import defineFunction from "../defineFunction"; +import {makeSpan, makeVList} from "../buildCommon"; +import {MathNode} from "../mathMLTree"; +import {stretchyMathML, stretchySvg} from "../stretchy"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; + +import type {ParseNode} from "../parseNode"; + +defineFunction({ + type: "accentUnder", + names: [ + "\\underleftarrow", "\\underrightarrow", "\\underleftrightarrow", + "\\undergroup", "\\underlinesegment", "\\utilde", + ], + props: { + numArgs: 1, + }, + handler: ({parser, funcName}, args) => { + const base = args[0]; + return { + type: "accentUnder", + mode: parser.mode, + label: funcName, + base: base, + }; + }, + htmlBuilder: (group: ParseNode<"accentUnder">, options) => { + // Treat under accents much like underlines. + const innerGroup = html.buildGroup(group.base, options); + + const accentBody = stretchySvg(group, options); + const kern = group.label === "\\utilde" ? 0.12 : 0; + + // Generate the vlist, with the appropriate kerns + const vlist = makeVList({ + positionType: "top", + positionData: innerGroup.height, + children: [ + {type: "elem", elem: accentBody, wrapperClasses: ["svg-align"]}, + {type: "kern", size: kern}, + {type: "elem", elem: innerGroup}, + ], + }, options); + + return makeSpan(["mord", "accentunder"], [vlist], options); + }, + mathmlBuilder: (group, options) => { + const accentNode = stretchyMathML(group.label); + const node = new MathNode( + "munder", + [mml.buildGroup(group.base, options), accentNode] + ); + node.setAttribute("accentunder", "true"); + return node; + }, +}); diff --git a/node_modules/react-katex/node_modules/katex/src/functions/arrow.ts b/node_modules/react-katex/node_modules/katex/src/functions/arrow.ts new file mode 100644 index 0000000..34dfe08 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/functions/arrow.ts @@ -0,0 +1,141 @@ +import defineFunction from "../defineFunction"; +import {makeSpan, makeVList, wrapFragment} from "../buildCommon"; +import {MathNode} from "../mathMLTree"; +import {stretchyMathML, stretchySvg} from "../stretchy"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; + +import type {ParseNode} from "../parseNode"; +import type {MathDomNode} from "../mathMLTree"; + +// Helper function +const paddedNode = (group?: MathDomNode | null | undefined) => { + const node = new MathNode("mpadded", group ? [group] : []); + node.setAttribute("width", "+0.6em"); + node.setAttribute("lspace", "0.3em"); + return node; +}; + +// Stretchy arrows with an optional argument +defineFunction({ + type: "xArrow", + names: [ + "\\xleftarrow", "\\xrightarrow", "\\xLeftarrow", "\\xRightarrow", + "\\xleftrightarrow", "\\xLeftrightarrow", "\\xhookleftarrow", + "\\xhookrightarrow", "\\xmapsto", "\\xrightharpoondown", + "\\xrightharpoonup", "\\xleftharpoondown", "\\xleftharpoonup", + "\\xrightleftharpoons", "\\xleftrightharpoons", "\\xlongequal", + "\\xtwoheadrightarrow", "\\xtwoheadleftarrow", "\\xtofrom", + // The next 3 functions are here to support the mhchem extension. + // Direct use of these functions is discouraged and may break someday. + "\\xrightleftarrows", "\\xrightequilibrium", "\\xleftequilibrium", + // The next 3 functions are here only to support the {CD} environment. + "\\\\cdrightarrow", "\\\\cdleftarrow", "\\\\cdlongequal", + ], + props: { + numArgs: 1, + numOptionalArgs: 1, + }, + handler({parser, funcName}, args, optArgs) { + return { + type: "xArrow", + mode: parser.mode, + label: funcName, + body: args[0], + below: optArgs[0], + }; + }, + htmlBuilder(group: ParseNode<"xArrow">, options) { + const style = options.style; + + // Build the argument groups in the appropriate style. + // Ref: amsmath.dtx: \hbox{$\scriptstyle\mkern#3mu{#6}\mkern#4mu$}% + + // Some groups can return document fragments. Handle those by wrapping + // them in a span. + let newOptions = options.havingStyle(style.sup()); + const upperGroup = wrapFragment( + html.buildGroup(group.body, newOptions, options), options); + const arrowPrefix = group.label.slice(0, 2) === "\\x" ? "x" : "cd"; + upperGroup.classes.push(arrowPrefix + "-arrow-pad"); + + let lowerGroup; + if (group.below) { + // Build the lower group + newOptions = options.havingStyle(style.sub()); + lowerGroup = wrapFragment( + html.buildGroup(group.below, newOptions, options), options); + lowerGroup.classes.push(arrowPrefix + "-arrow-pad"); + } + + const arrowBody = stretchySvg(group, options); + + // Re shift: Note that stretchySvg returned arrowBody.depth = 0. + // The point we want on the math axis is at 0.5 * arrowBody.height. + const arrowShift = -options.fontMetrics().axisHeight + + 0.5 * arrowBody.height; + // 2 mu kern. Ref: amsmath.dtx: #7\if0#2\else\mkern#2mu\fi + let upperShift = -options.fontMetrics().axisHeight + - 0.5 * arrowBody.height - 0.111; // 0.111 em = 2 mu + if (upperGroup.depth > 0.25 || group.label === "\\xleftequilibrium") { + upperShift -= upperGroup.depth; // shift up if depth encroaches + } + + // Generate the vlist + let vlist; + if (lowerGroup) { + const lowerShift = -options.fontMetrics().axisHeight + + lowerGroup.height + 0.5 * arrowBody.height + + 0.111; + vlist = makeVList({ + positionType: "individualShift", + children: [ + {type: "elem", elem: upperGroup, shift: upperShift}, + {type: "elem", elem: arrowBody, shift: arrowShift, + wrapperClasses: ["svg-align"]}, + {type: "elem", elem: lowerGroup, shift: lowerShift}, + ], + }, options); + } else { + vlist = makeVList({ + positionType: "individualShift", + children: [ + {type: "elem", elem: upperGroup, shift: upperShift}, + {type: "elem", elem: arrowBody, shift: arrowShift, + wrapperClasses: ["svg-align"]}, + ], + }, options); + } + + return makeSpan(["mrel", "x-arrow"], [vlist], options); + }, + mathmlBuilder(group, options) { + const arrowNode = stretchyMathML(group.label); + arrowNode.setAttribute( + "minsize", group.label.charAt(0) === "x" ? "1.75em" : "3.0em" + ); + let node; + + if (group.body) { + const upperNode = paddedNode(mml.buildGroup(group.body, options)); + if (group.below) { + const lowerNode = paddedNode(mml.buildGroup(group.below, options)); + node = new MathNode( + "munderover", [arrowNode, lowerNode, upperNode] + ); + } else { + node = new MathNode("mover", [arrowNode, upperNode]); + } + } else if (group.below) { + const lowerNode = paddedNode(mml.buildGroup(group.below, options)); + node = new MathNode("munder", [arrowNode, lowerNode]); + } else { + // This should never happen. + // Parser.js throws an error if there is no argument. + node = paddedNode(); + node = new MathNode("mover", [arrowNode, node]); + } + return node; + }, +}); diff --git a/node_modules/react-katex/node_modules/katex/src/functions/char.ts b/node_modules/react-katex/node_modules/katex/src/functions/char.ts new file mode 100644 index 0000000..bf65fd2 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/functions/char.ts @@ -0,0 +1,44 @@ +import defineFunction from "../defineFunction"; +import ParseError from "../ParseError"; +import {assertNodeType} from "../parseNode"; + +// \@char is an internal function that takes a grouped decimal argument like +// {123} and converts into symbol with code 123. It is used by the *macro* +// \char defined in macros.js. +defineFunction({ + type: "textord", + names: ["\\@char"], + props: { + numArgs: 1, + allowedInText: true, + }, + handler({parser}, args) { + const arg = assertNodeType(args[0], "ordgroup"); + const group = arg.body; + let number = ""; + for (let i = 0; i < group.length; i++) { + const node = assertNodeType(group[i], "textord"); + number += node.text; + } + let code = parseInt(number); + let text; + if (isNaN(code)) { + throw new ParseError(`\\@char has non-numeric argument ${number}`); + // If we drop IE support, the following code could be replaced with + // text = String.fromCodePoint(code) + } else if (code < 0 || code >= 0x10ffff) { + throw new ParseError(`\\@char with invalid code point ${number}`); + } else if (code <= 0xffff) { + text = String.fromCharCode(code); + } else { // Astral code point; split into surrogate halves + code -= 0x10000; + text = String.fromCharCode((code >> 10) + 0xd800, + (code & 0x3ff) + 0xdc00); + } + return { + type: "textord", + mode: parser.mode, + text: text, + }; + }, +}); diff --git a/node_modules/react-katex/node_modules/katex/src/functions/color.ts b/node_modules/react-katex/node_modules/katex/src/functions/color.ts new file mode 100644 index 0000000..c508d00 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/functions/color.ts @@ -0,0 +1,87 @@ +import defineFunction, {ordargument} from "../defineFunction"; +import {makeFragment} from "../buildCommon"; +import {MathNode} from "../mathMLTree"; +import {assertNodeType} from "../parseNode"; +import type {AnyParseNode} from "../parseNode"; +import type {HtmlBuilder, MathMLBuilder} from "../defineFunction"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; + +const htmlBuilder: HtmlBuilder<"color"> = (group, options) => { + const elements = html.buildExpression( + group.body, + options.withColor(group.color), + false + ); + + // \color isn't supposed to affect the type of the elements it contains. + // To accomplish this, we wrap the results in a fragment, so the inner + // elements will be able to directly interact with their neighbors. For + // example, `\color{red}{2 +} 3` has the same spacing as `2 + 3` + return makeFragment(elements); +}; + +const mathmlBuilder: MathMLBuilder<"color"> = (group, options) => { + const inner = mml.buildExpression(group.body, + options.withColor(group.color)); + + const node = new MathNode("mstyle", inner); + + node.setAttribute("mathcolor", group.color); + + return node; +}; + +defineFunction({ + type: "color", + names: ["\\textcolor"], + props: { + numArgs: 2, + allowedInText: true, + argTypes: ["color", "original"], + }, + handler({parser}, args) { + const color = assertNodeType(args[0], "color-token").color; + const body = args[1]; + return { + type: "color", + mode: parser.mode, + color, + body: (ordargument(body) as AnyParseNode[]), + }; + }, + htmlBuilder, + mathmlBuilder, +}); + +defineFunction({ + type: "color", + names: ["\\color"], + props: { + numArgs: 1, + allowedInText: true, + argTypes: ["color"], + }, + handler({parser, breakOnTokenText}, args) { + const color = assertNodeType(args[0], "color-token").color; + + // Set macro \current@color in current namespace to store the current + // color, mimicking the behavior of color.sty. + // This is currently used just to correctly color a \right + // that follows a \color command. + parser.gullet.macros.set("\\current@color", color); + + // Parse out the implicit body that should be colored. + const body: AnyParseNode[] = parser.parseExpression(true, breakOnTokenText); + + return { + type: "color", + mode: parser.mode, + color, + body, + }; + }, + htmlBuilder, + mathmlBuilder, +}); diff --git a/node_modules/react-katex/node_modules/katex/src/functions/cr.ts b/node_modules/react-katex/node_modules/katex/src/functions/cr.ts new file mode 100644 index 0000000..16172cd --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/functions/cr.ts @@ -0,0 +1,60 @@ +// Row breaks within tabular environments, and line breaks at top level + +import defineFunction from "../defineFunction"; +import {makeSpan} from "../buildCommon"; +import {MathNode} from "../mathMLTree"; +import {calculateSize, makeEm} from "../units"; +import {assertNodeType} from "../parseNode"; + +// \DeclareRobustCommand\\{...\@xnewline} +defineFunction({ + type: "cr", + names: ["\\\\"], + props: { + numArgs: 0, + numOptionalArgs: 0, + allowedInText: true, + }, + + handler({parser}, args, optArgs) { + const size = parser.gullet.future().text === "[" ? + parser.parseSizeGroup(true) : null; + const newLine = !parser.settings.displayMode || + !parser.settings.useStrictBehavior( + "newLineInDisplayMode", "In LaTeX, \\\\ or \\newline " + + "does nothing in display mode"); + return { + type: "cr", + mode: parser.mode, + newLine, + size: size && assertNodeType(size, "size").value, + }; + }, + + // The following builders are called only at the top level, + // not within tabular/array environments. + + htmlBuilder(group, options) { + const span = makeSpan(["mspace"], [], options); + if (group.newLine) { + span.classes.push("newline"); + if (group.size) { + span.style.marginTop = + makeEm(calculateSize(group.size, options)); + } + } + return span; + }, + + mathmlBuilder(group, options) { + const node = new MathNode("mspace"); + if (group.newLine) { + node.setAttribute("linebreak", "newline"); + if (group.size) { + node.setAttribute("height", + makeEm(calculateSize(group.size, options))); + } + } + return node; + }, +}); diff --git a/node_modules/react-katex/node_modules/katex/src/functions/def.ts b/node_modules/react-katex/node_modules/katex/src/functions/def.ts new file mode 100644 index 0000000..45baac7 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/functions/def.ts @@ -0,0 +1,212 @@ +import defineFunction from "../defineFunction"; +import ParseError from "../ParseError"; +import {assertNodeType} from "../parseNode"; +import {Token} from "../Token"; + +import type Parser from "../Parser"; + +const globalMap: Record = { + "\\global": "\\global", + "\\long": "\\\\globallong", + "\\\\globallong": "\\\\globallong", + "\\def": "\\gdef", + "\\gdef": "\\gdef", + "\\edef": "\\xdef", + "\\xdef": "\\xdef", + "\\let": "\\\\globallet", + "\\futurelet": "\\\\globalfuture", +}; + +const checkControlSequence = (tok: Token): string => { + const name = tok.text; + if (/^(?:[\\{}$&#^_]|EOF)$/.test(name)) { + throw new ParseError("Expected a control sequence", tok); + } + return name; +}; + +const getRHS = (parser: Parser): Token => { + let tok = parser.gullet.popToken(); + if (tok.text === "=") { // consume optional equals + tok = parser.gullet.popToken(); + if (tok.text === " ") { // consume one optional space + tok = parser.gullet.popToken(); + } + } + return tok; +}; + +const letCommand = (parser: Parser, name: string, tok: Token, global: boolean) => { + let macro = parser.gullet.macros.get(tok.text); + if (macro == null) { + // don't expand it later even if a macro with the same name is defined + // e.g., \let\foo=\frac \def\frac{\relax} \frac12 + tok.noexpand = true; + macro = { + tokens: [tok], + numArgs: 0, + // reproduce the same behavior in expansion + unexpandable: !parser.gullet.isExpandable(tok.text), + }; + } + parser.gullet.macros.set(name, macro, global); +}; + +// -> | +// -> |\global +// -> | +// -> \global|\long|\outer +defineFunction({ + type: "internal", + names: [ + "\\global", "\\long", + "\\\\globallong", // can’t be entered directly + ], + props: { + numArgs: 0, + allowedInText: true, + }, + handler({parser, funcName}) { + parser.consumeSpaces(); + const token = parser.fetch(); + if (globalMap[token.text]) { + // KaTeX doesn't have \par, so ignore \long + if (funcName === "\\global" || funcName === "\\\\globallong") { + token.text = globalMap[token.text]; + } + return assertNodeType(parser.parseFunction(), "internal"); + } + throw new ParseError(`Invalid token after macro prefix`, token); + }, +}); + +// Basic support for macro definitions: \def, \gdef, \edef, \xdef +// -> +// -> \def|\gdef|\edef|\xdef +// -> +defineFunction({ + type: "internal", + names: ["\\def", "\\gdef", "\\edef", "\\xdef"], + props: { + numArgs: 0, + allowedInText: true, + primitive: true, + }, + handler({parser, funcName}) { + let tok = parser.gullet.popToken(); + const name = tok.text; + if (/^(?:[\\{}$&#^_]|EOF)$/.test(name)) { + throw new ParseError("Expected a control sequence", tok); + } + + let numArgs = 0; + let insert: Token | undefined; + const delimiters: string[][] = [[]]; + // contains no braces + while (parser.gullet.future().text !== "{") { + tok = parser.gullet.popToken(); + if (tok.text === "#") { + // If the very last character of the is #, so that + // this # is immediately followed by {, TeX will behave as if the { + // had been inserted at the right end of both the parameter text + // and the replacement text. + if (parser.gullet.future().text === "{") { + insert = parser.gullet.future(); + delimiters[numArgs].push("{"); + break; + } + + // A parameter, the first appearance of # must be followed by 1, + // the next by 2, and so on; up to nine #’s are allowed + tok = parser.gullet.popToken(); + if (!(/^[1-9]$/.test(tok.text))) { + throw new ParseError(`Invalid argument number "${tok.text}"`); + } + if (parseInt(tok.text) !== numArgs + 1) { + throw new ParseError( + `Argument number "${tok.text}" out of order`); + } + numArgs++; + delimiters.push([]); + } else if (tok.text === "EOF") { + throw new ParseError("Expected a macro definition"); + } else { + delimiters[numArgs].push(tok.text); + } + } + // replacement text, enclosed in '{' and '}' and properly nested + let {tokens} = parser.gullet.consumeArg(); + if (insert) { + tokens.unshift(insert); + } + + if (funcName === "\\edef" || funcName === "\\xdef") { + tokens = parser.gullet.expandTokens(tokens); + tokens.reverse(); // to fit in with stack order + } + // Final arg is the expansion of the macro + parser.gullet.macros.set(name, { + tokens, + numArgs, + delimiters, + }, funcName === globalMap[funcName]); + + return { + type: "internal", + mode: parser.mode, + }; + }, +}); + +// -> +// -> \futurelet +// | \let +// -> |= +defineFunction({ + type: "internal", + names: [ + "\\let", + "\\\\globallet", // can’t be entered directly + ], + props: { + numArgs: 0, + allowedInText: true, + primitive: true, + }, + handler({parser, funcName}) { + const name = checkControlSequence(parser.gullet.popToken()); + parser.gullet.consumeSpaces(); + const tok = getRHS(parser); + letCommand(parser, name, tok, funcName === "\\\\globallet"); + return { + type: "internal", + mode: parser.mode, + }; + }, +}); + +// ref: https://www.tug.org/TUGboat/tb09-3/tb22bechtolsheim.pdf +defineFunction({ + type: "internal", + names: [ + "\\futurelet", + "\\\\globalfuture", // can’t be entered directly + ], + props: { + numArgs: 0, + allowedInText: true, + primitive: true, + }, + handler({parser, funcName}) { + const name = checkControlSequence(parser.gullet.popToken()); + const middle = parser.gullet.popToken(); + const tok = parser.gullet.popToken(); + letCommand(parser, name, tok, funcName === "\\\\globalfuture"); + parser.gullet.pushToken(tok); + parser.gullet.pushToken(middle); + return { + type: "internal", + mode: parser.mode, + }; + }, +}); diff --git a/node_modules/react-katex/node_modules/katex/src/functions/delimsizing.ts b/node_modules/react-katex/node_modules/katex/src/functions/delimsizing.ts new file mode 100644 index 0000000..5814c39 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/functions/delimsizing.ts @@ -0,0 +1,366 @@ +import {makeSpan} from "../buildCommon"; +import defineFunction from "../defineFunction"; +import {makeLeftRightDelim, makeSizedDelim, sizeToMaxHeight} from "../delimiter"; +import {MathNode} from "../mathMLTree"; +import ParseError from "../ParseError"; +import {assertNodeType, checkSymbolNodeType} from "../parseNode"; +import {makeEm} from "../units"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; + +import type Options from "../Options"; +import type {AnyParseNode, ParseNode, SymbolParseNode} from "../parseNode"; +import type {FunctionContext} from "../defineFunction"; +import type {HtmlDomNode} from "../domTree"; + +// Extra data needed for the delimiter handler down below +const delimiterSizes: Record = { + "\\bigl" : {mclass: "mopen", size: 1}, + "\\Bigl" : {mclass: "mopen", size: 2}, + "\\biggl": {mclass: "mopen", size: 3}, + "\\Biggl": {mclass: "mopen", size: 4}, + "\\bigr" : {mclass: "mclose", size: 1}, + "\\Bigr" : {mclass: "mclose", size: 2}, + "\\biggr": {mclass: "mclose", size: 3}, + "\\Biggr": {mclass: "mclose", size: 4}, + "\\bigm" : {mclass: "mrel", size: 1}, + "\\Bigm" : {mclass: "mrel", size: 2}, + "\\biggm": {mclass: "mrel", size: 3}, + "\\Biggm": {mclass: "mrel", size: 4}, + "\\big" : {mclass: "mord", size: 1}, + "\\Big" : {mclass: "mord", size: 2}, + "\\bigg" : {mclass: "mord", size: 3}, + "\\Bigg" : {mclass: "mord", size: 4}, +}; + +const delimiters = new Set([ + "(", "\\lparen", ")", "\\rparen", + "[", "\\lbrack", "]", "\\rbrack", + "\\{", "\\lbrace", "\\}", "\\rbrace", + "\\lfloor", "\\rfloor", "\u230a", "\u230b", + "\\lceil", "\\rceil", "\u2308", "\u2309", + "<", ">", "\\langle", "\u27e8", "\\rangle", "\u27e9", "\\lt", "\\gt", + "\\lvert", "\\rvert", "\\lVert", "\\rVert", + "\\lgroup", "\\rgroup", "\u27ee", "\u27ef", + "\\lmoustache", "\\rmoustache", "\u23b0", "\u23b1", + "/", "\\backslash", + "|", "\\vert", "\\|", "\\Vert", + "\\uparrow", "\\Uparrow", + "\\downarrow", "\\Downarrow", + "\\updownarrow", "\\Updownarrow", + ".", +]); + +type IsMiddle = {delim: string, options: Options}; + +/** + * An HtmlDomNode that carries an `isMiddle` property, used by the + * \middle command to communicate delimiter info to the \left/\right builder. + */ +type MiddleDelimNode = HtmlDomNode & {isMiddle: IsMiddle}; + +function isMiddleDelimNode(node: HtmlDomNode): node is MiddleDelimNode { + return 'isMiddle' in node; +} + +// Delimiter functions +function checkDelimiter( + delim: AnyParseNode, + context: FunctionContext, +): SymbolParseNode { + const symDelim = checkSymbolNodeType(delim); + if (symDelim && delimiters.has(symDelim.text)) { + return symDelim; + } else if (symDelim) { + throw new ParseError( + `Invalid delimiter '${symDelim.text}' after '${context.funcName}'`, + delim); + } else { + throw new ParseError(`Invalid delimiter type '${delim.type}'`, delim); + } +} + +defineFunction({ + type: "delimsizing", + names: [ + "\\bigl", "\\Bigl", "\\biggl", "\\Biggl", + "\\bigr", "\\Bigr", "\\biggr", "\\Biggr", + "\\bigm", "\\Bigm", "\\biggm", "\\Biggm", + "\\big", "\\Big", "\\bigg", "\\Bigg", + ], + props: { + numArgs: 1, + argTypes: ["primitive"], + }, + handler: (context, args) => { + const delim = checkDelimiter(args[0], context); + + return { + type: "delimsizing", + mode: context.parser.mode, + size: delimiterSizes[context.funcName].size, + mclass: delimiterSizes[context.funcName].mclass, + delim: delim.text, + }; + }, + htmlBuilder: (group, options) => { + if (group.delim === ".") { + // Empty delimiters still count as elements, even though they don't + // show anything. + return makeSpan([group.mclass]); + } + + return makeSizedDelim( + group.delim, group.size, options, group.mode, [group.mclass]); + }, + mathmlBuilder: (group) => { + const children = []; + + if (group.delim !== ".") { + children.push(mml.makeText(group.delim, group.mode)); + } + + const node = new MathNode("mo", children); + + if (group.mclass === "mopen" || + group.mclass === "mclose") { + // Only some of the delimsizing functions act as fences, and they + // return "mopen" or "mclose" mclass. + node.setAttribute("fence", "true"); + } else { + // Explicitly disable fencing if it's not a fence, to override the + // defaults. + node.setAttribute("fence", "false"); + } + + node.setAttribute("stretchy", "true"); + const size = makeEm(sizeToMaxHeight[group.size]); + node.setAttribute("minsize", size); + node.setAttribute("maxsize", size); + + return node; + }, +}); + + +function assertParsed(group: ParseNode<"leftright">) { + if (!group.body) { + throw new Error("Bug: The leftright ParseNode wasn't fully parsed."); + } +} + + +defineFunction({ + type: "leftright-right", + names: ["\\right"], + props: { + numArgs: 1, + primitive: true, + }, + handler: (context, args) => { + // \left case below triggers parsing of \right in + // `const right = parser.parseFunction();` + // uses this return value. + const color = context.parser.gullet.macros.get("\\current@color"); + if (color && typeof color !== "string") { + throw new ParseError( + "\\current@color set to non-string in \\right"); + } + return { + type: "leftright-right", + mode: context.parser.mode, + delim: checkDelimiter(args[0], context).text, + color: color as string | null | undefined, // undefined if not set via \color + }; + }, +}); + + +defineFunction({ + type: "leftright", + names: ["\\left"], + props: { + numArgs: 1, + primitive: true, + }, + handler: (context, args) => { + const delim = checkDelimiter(args[0], context); + + const parser = context.parser; + // Parse out the implicit body + ++parser.leftrightDepth; + // parseExpression stops before '\\right' + const body = parser.parseExpression(false); + --parser.leftrightDepth; + // Check the next token + parser.expect("\\right", false); + const right = assertNodeType(parser.parseFunction(), "leftright-right"); + return { + type: "leftright", + mode: parser.mode, + body, + left: delim.text, + right: right.delim, + rightColor: right.color, + }; + }, + htmlBuilder: (group, options) => { + assertParsed(group); + // Build the inner expression + const inner = html.buildExpression(group.body, options, true, + ["mopen", "mclose"]); + + let innerHeight = 0; + let innerDepth = 0; + let hadMiddle = false; + + // Calculate its height and depth + for (let i = 0; i < inner.length; i++) { + const node = inner[i]; + if (isMiddleDelimNode(node)) { + hadMiddle = true; + } else { + innerHeight = Math.max(inner[i].height, innerHeight); + innerDepth = Math.max(inner[i].depth, innerDepth); + } + } + + // The size of delimiters is the same, regardless of what style we are + // in. Thus, to correctly calculate the size of delimiter we need around + // a group, we scale down the inner size based on the size. + innerHeight *= options.sizeMultiplier; + innerDepth *= options.sizeMultiplier; + + let leftDelim; + if (group.left === ".") { + // Empty delimiters in \left and \right make null delimiter spaces. + leftDelim = html.makeNullDelimiter(options, ["mopen"]); + } else { + // Otherwise, use leftRightDelim to generate the correct sized + // delimiter. + leftDelim = makeLeftRightDelim( + group.left, innerHeight, innerDepth, options, + group.mode, ["mopen"]); + } + // Add it to the beginning of the expression + inner.unshift(leftDelim); + + // Handle middle delimiters + if (hadMiddle) { + for (let i = 1; i < inner.length; i++) { + const middleDelim = inner[i]; + if (isMiddleDelimNode(middleDelim)) { + const isMiddle = middleDelim.isMiddle; + // Apply the options that were active when \middle was called + inner[i] = makeLeftRightDelim( + isMiddle.delim, innerHeight, innerDepth, + isMiddle.options, group.mode, []); + } + } + } + + let rightDelim; + // Same for the right delimiter, but using color specified by \color + if (group.right === ".") { + rightDelim = html.makeNullDelimiter(options, ["mclose"]); + } else { + const colorOptions = group.rightColor ? + options.withColor(group.rightColor) : options; + rightDelim = makeLeftRightDelim( + group.right, innerHeight, innerDepth, colorOptions, + group.mode, ["mclose"]); + } + // Add it to the end of the expression. + inner.push(rightDelim); + + return makeSpan(["minner"], inner, options); + }, + mathmlBuilder: (group, options) => { + assertParsed(group); + const inner = mml.buildExpression(group.body, options); + + if (group.left !== ".") { + const leftNode = new MathNode( + "mo", [mml.makeText(group.left, group.mode)]); + + leftNode.setAttribute("fence", "true"); + + inner.unshift(leftNode); + } + + if (group.right !== ".") { + const rightNode = new MathNode( + "mo", [mml.makeText(group.right, group.mode)]); + + rightNode.setAttribute("fence", "true"); + + if (group.rightColor) { + rightNode.setAttribute("mathcolor", group.rightColor); + } + + inner.push(rightNode); + } + + return mml.makeRow(inner); + }, +}); + +defineFunction({ + type: "middle", + names: ["\\middle"], + props: { + numArgs: 1, + primitive: true, + }, + handler: (context, args) => { + const delim = checkDelimiter(args[0], context); + if (!context.parser.leftrightDepth) { + throw new ParseError("\\middle without preceding \\left", delim); + } + + return { + type: "middle", + mode: context.parser.mode, + delim: delim.text, + }; + }, + htmlBuilder: (group, options) => { + let middleDelim; + if (group.delim === ".") { + middleDelim = html.makeNullDelimiter(options, []); + } else { + middleDelim = makeSizedDelim( + group.delim, 1, options, + group.mode, []); + + // Patch an ad-hoc property onto the node so the \left/\right + // builder can reconstruct appropriately sized middle delimiters. + // isMiddle is not part of HtmlDomNode; the read side uses + // isMiddleDelimNode() to check before accessing. + (middleDelim as unknown as MiddleDelimNode).isMiddle = { + delim: group.delim, options, + }; + } + return middleDelim; + }, + mathmlBuilder: (group, options) => { + // A Firefox \middle will stretch a character vertically only if it + // is in the fence part of the operator dictionary at: + // https://www.w3.org/TR/MathML3/appendixc.html. + // So we need to avoid U+2223 and use plain "|" instead. + const textNode = (group.delim === "\\vert" || group.delim === "|") + ? mml.makeText("|", "text") + : mml.makeText(group.delim, group.mode); + const middleNode = new MathNode("mo", [textNode]); + middleNode.setAttribute("fence", "true"); + // MathML gives 5/18em spacing to each element. + // \middle should get delimiter spacing instead. + middleNode.setAttribute("lspace", "0.05em"); + middleNode.setAttribute("rspace", "0.05em"); + return middleNode; + }, +}); diff --git a/node_modules/react-katex/node_modules/katex/src/functions/enclose.ts b/node_modules/react-katex/node_modules/katex/src/functions/enclose.ts new file mode 100644 index 0000000..54e170f --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/functions/enclose.ts @@ -0,0 +1,345 @@ +import defineFunction from "../defineFunction"; +import {makeSpan, makeSvgSpan, makeVList, wrapFragment} from "../buildCommon"; +import {isCharacterBox} from "../utils"; +import {MathNode} from "../mathMLTree"; +import {stretchyEnclose} from "../stretchy"; +import {phasePath} from "../svgGeometry"; +import {PathNode, SvgNode} from "../domTree"; +import {calculateSize, makeEm} from "../units"; +import {assertNodeType} from "../parseNode"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; +import type {HtmlBuilder, MathMLBuilder} from "../defineFunction"; + +const htmlBuilder: HtmlBuilder<"enclose"> = (group, options) => { + // \cancel, \bcancel, \xcancel, \sout, \fbox, \colorbox, \fcolorbox, \phase + // Some groups can return document fragments. Handle those by wrapping + // them in a span. + const inner = wrapFragment( + html.buildGroup(group.body, options), options); + + const label = group.label.slice(1); + let scale = options.sizeMultiplier; + let img; + let imgShift; + + // In the LaTeX cancel package, line geometry is slightly different + // depending on whether the subject is wider than it is tall, or vice versa. + // We don't know the width of a group, so as a proxy, we test if + // the subject is a single character. This captures most of the + // subjects that should get the "tall" treatment. + const isSingleChar = isCharacterBox(group.body); + + if (label === "sout") { + img = makeSpan(["stretchy", "sout"]); + img.height = options.fontMetrics().defaultRuleThickness / scale; + imgShift = -0.5 * options.fontMetrics().xHeight; + + } else if (label === "phase") { + // Set a couple of dimensions from the steinmetz package. + const lineWeight = calculateSize({number: 0.6, unit: "pt"}, options); + const clearance = calculateSize({number: 0.35, unit: "ex"}, options); + + // Prevent size changes like \Huge from affecting line thickness + const newOptions = options.havingBaseSizing(); + scale = scale / newOptions.sizeMultiplier; + + const angleHeight = inner.height + inner.depth + lineWeight + clearance; + // Reserve a left pad for the angle. + inner.style.paddingLeft = makeEm(angleHeight / 2 + lineWeight); + + // Create an SVG + const viewBoxHeight = Math.floor(1000 * angleHeight * scale); + const path = phasePath(viewBoxHeight); + const svgNode = new SvgNode([new PathNode("phase", path)], { + "width": "400em", + "height": makeEm(viewBoxHeight / 1000), + "viewBox": `0 0 400000 ${viewBoxHeight}`, + "preserveAspectRatio": "xMinYMin slice", + }); + // Wrap it in a span with overflow: hidden. + img = makeSvgSpan(["hide-tail"], [svgNode], options); + img.style.height = makeEm(angleHeight); + imgShift = inner.depth + lineWeight + clearance; + + } else { + // Add horizontal padding + if (/cancel/.test(label)) { + if (!isSingleChar) { + inner.classes.push("cancel-pad"); + } + } else if (label === "angl") { + inner.classes.push("anglpad"); + } else { + inner.classes.push("boxpad"); + } + + // Add vertical padding + let topPad; + let bottomPad; + let ruleThickness = 0; + // ref: cancel package: \advance\totalheight2\p@ % "+2" + if (/box/.test(label)) { + ruleThickness = Math.max( + options.fontMetrics().fboxrule, // default + options.minRuleThickness, // User override. + ); + topPad = options.fontMetrics().fboxsep + + (label === "colorbox" ? 0 : ruleThickness); + bottomPad = topPad; + } else if (label === "angl") { + ruleThickness = Math.max( + options.fontMetrics().defaultRuleThickness, + options.minRuleThickness + ); + topPad = 4 * ruleThickness; // gap = 3 × line, plus the line itself. + bottomPad = Math.max(0, 0.25 - inner.depth); + } else { + topPad = isSingleChar ? 0.2 : 0; + bottomPad = topPad; + } + + img = stretchyEnclose(inner, label, topPad, bottomPad, options); + if (/fbox|boxed|fcolorbox/.test(label)) { + img.style.borderStyle = "solid"; + img.style.borderWidth = makeEm(ruleThickness); + } else if (label === "angl" && ruleThickness !== 0.049) { + img.style.borderTopWidth = makeEm(ruleThickness); + img.style.borderRightWidth = makeEm(ruleThickness); + } + imgShift = inner.depth + bottomPad; + + if (group.backgroundColor) { + img.style.backgroundColor = group.backgroundColor; + if (group.borderColor) { + img.style.borderColor = group.borderColor; + } + } + } + + let vlist; + if (group.backgroundColor) { + vlist = makeVList({ + positionType: "individualShift", + children: [ + // Put the color background behind inner; + {type: "elem", elem: img, shift: imgShift}, + {type: "elem", elem: inner, shift: 0}, + ], + }, options); + } else { + const classes = /cancel|phase/.test(label) ? ["svg-align"] : []; + vlist = makeVList({ + positionType: "individualShift", + children: [ + // Write the \cancel stroke on top of inner. + { + type: "elem", + elem: inner, + shift: 0, + }, + { + type: "elem", + elem: img, + shift: imgShift, + wrapperClasses: classes, + }, + ], + }, options); + } + + if (/cancel/.test(label)) { + // The cancel package documentation says that cancel lines add their height + // to the expression, but tests show that isn't how it actually works. + vlist.height = inner.height; + vlist.depth = inner.depth; + } + + if (/cancel/.test(label) && !isSingleChar) { + // cancel does not create horiz space for its line extension. + return makeSpan(["mord", "cancel-lap"], [vlist], options); + } else { + return makeSpan(["mord"], [vlist], options); + } +}; + +const mathmlBuilder: MathMLBuilder<"enclose"> = (group, options) => { + let fboxsep; + const node = new MathNode( + group.label.includes("colorbox") ? "mpadded" : "menclose", + [mml.buildGroup(group.body, options)] + ); + switch (group.label) { + case "\\cancel": + node.setAttribute("notation", "updiagonalstrike"); + break; + case "\\bcancel": + node.setAttribute("notation", "downdiagonalstrike"); + break; + case "\\phase": + node.setAttribute("notation", "phasorangle"); + break; + case "\\sout": + node.setAttribute("notation", "horizontalstrike"); + break; + case "\\fbox": + node.setAttribute("notation", "box"); + break; + case "\\angl": + node.setAttribute("notation", "actuarial"); + break; + case "\\fcolorbox": + case "\\colorbox": + // doesn't have a good notation option. So use + // instead. Set some attributes that come included with . + fboxsep = options.fontMetrics().fboxsep * + options.fontMetrics().ptPerEm; + node.setAttribute("width", `+${2 * fboxsep}pt`); + node.setAttribute("height", `+${2 * fboxsep}pt`); + node.setAttribute("lspace", `${fboxsep}pt`); // + node.setAttribute("voffset", `${fboxsep}pt`); + if (group.label === "\\fcolorbox") { + const thk = Math.max( + options.fontMetrics().fboxrule, // default + options.minRuleThickness, // user override + ); + node.setAttribute("style", `border: ${makeEm(thk)} solid ${group.borderColor}`); + } + break; + case "\\xcancel": + node.setAttribute("notation", "updiagonalstrike downdiagonalstrike"); + break; + } + if (group.backgroundColor) { + node.setAttribute("mathbackground", group.backgroundColor); + } + return node; +}; + +defineFunction({ + type: "enclose", + names: ["\\colorbox"], + props: { + numArgs: 2, + allowedInText: true, + argTypes: ["color", "hbox"], + }, + handler({parser, funcName}, args, optArgs) { + const color = assertNodeType(args[0], "color-token").color; + const body = args[1]; + return { + type: "enclose", + mode: parser.mode, + label: funcName, + backgroundColor: color, + body, + }; + }, + htmlBuilder, + mathmlBuilder, +}); + +defineFunction({ + type: "enclose", + names: ["\\fcolorbox"], + props: { + numArgs: 3, + allowedInText: true, + argTypes: ["color", "color", "hbox"], + }, + handler({parser, funcName}, args, optArgs) { + const borderColor = assertNodeType(args[0], "color-token").color; + const backgroundColor = assertNodeType(args[1], "color-token").color; + const body = args[2]; + return { + type: "enclose", + mode: parser.mode, + label: funcName, + backgroundColor, + borderColor, + body, + }; + }, + htmlBuilder, + mathmlBuilder, +}); + +defineFunction({ + type: "enclose", + names: ["\\fbox"], + props: { + numArgs: 1, + argTypes: ["hbox"], + allowedInText: true, + }, + handler({parser}, args) { + return { + type: "enclose", + mode: parser.mode, + label: "\\fbox", + body: args[0], + }; + }, +}); + +defineFunction({ + type: "enclose", + names: ["\\cancel", "\\bcancel", "\\xcancel", "\\phase"], + props: { + numArgs: 1, + }, + handler({parser, funcName}, args) { + const body = args[0]; + return { + type: "enclose", + mode: parser.mode, + label: funcName, + body, + }; + }, + htmlBuilder, + mathmlBuilder, +}); + +defineFunction({ + type: "enclose", + names: ["\\sout"], + props: { + numArgs: 1, + allowedInText: true, + }, + handler({parser, funcName}, args) { + if (parser.mode === "math") { + parser.settings.reportNonstrict("mathVsSout", + `LaTeX's \\sout works only in text mode`); + } + const body = args[0]; + return { + type: "enclose", + mode: parser.mode, + label: funcName, + body, + }; + }, + htmlBuilder, + mathmlBuilder, +}); + +defineFunction({ + type: "enclose", + names: ["\\angl"], + props: { + numArgs: 1, + argTypes: ["hbox"], + allowedInText: false, + }, + handler({parser}, args) { + return { + type: "enclose", + mode: parser.mode, + label: "\\angl", + body: args[0], + }; + }, +}); diff --git a/node_modules/react-katex/node_modules/katex/src/functions/environment.ts b/node_modules/react-katex/node_modules/katex/src/functions/environment.ts new file mode 100644 index 0000000..7ddc65f --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/functions/environment.ts @@ -0,0 +1,66 @@ +import defineFunction from "../defineFunction"; +import ParseError from "../ParseError"; +import {assertNodeType} from "../parseNode"; +import environments from "../environments"; + +import type {ParseNode} from "../parseNode"; + +// Environment delimiters. HTML/MathML rendering is defined in the corresponding +// defineEnvironment definitions. +defineFunction({ + type: "environment", + names: ["\\begin", "\\end"], + props: { + numArgs: 1, + argTypes: ["text"], + }, + handler({parser, funcName}, args) { + const nameGroup = args[0]; + if (nameGroup.type !== "ordgroup") { + throw new ParseError("Invalid environment name", nameGroup); + } + let envName = ""; + for (let i = 0; i < nameGroup.body.length; ++i) { + envName += assertNodeType(nameGroup.body[i], "textord").text; + } + + if (funcName === "\\begin") { + // begin...end is similar to left...right + if (!environments.hasOwnProperty(envName)) { + throw new ParseError( + "No such environment: " + envName, nameGroup); + } + // Build the environment object. Arguments and other information will + // be made available to the begin and end methods using properties. + const env = environments[envName]; + const {args, optArgs} = + parser.parseArguments("\\begin{" + envName + "}", env); + const context = { + mode: parser.mode, + envName, + parser, + }; + const result = env.handler(context, args, optArgs); + parser.expect("\\end", false); + const endNameToken = parser.nextToken; + const end = assertNodeType(parser.parseFunction(), "environment"); + if (end.name !== envName) { + throw new ParseError( + `Mismatch: \\begin{${envName}} matched by \\end{${end.name}}`, + endNameToken); + } + // env.handler returns the specific node type (e.g. "array"), + // not "environment". This cast is unavoidable: defineFunction + // requires the handler to return ParseNode<"environment"> but + // \begin delegates to environment handlers with different types. + return result as unknown as ParseNode<"environment">; + } + + return { + type: "environment", + mode: parser.mode, + name: envName, + nameGroup, + }; + }, +}); diff --git a/node_modules/react-katex/node_modules/katex/src/functions/font.ts b/node_modules/react-katex/node_modules/katex/src/functions/font.ts new file mode 100644 index 0000000..a6e2cfb --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/functions/font.ts @@ -0,0 +1,124 @@ +// TODO(kevinb): implement \\sl and \\sc + +import {binrelClass} from "./mclass"; +import defineFunction, {normalizeArgument} from "../defineFunction"; +import {isCharacterBox} from "../utils"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; + +import type Options from "../Options"; +import type {ParseNode} from "../parseNode"; +import type {Slice1} from "../types"; + +const htmlBuilder = (group: ParseNode<"font">, options: Options) => { + const font = group.font; + const newOptions = options.withFont(font); + return html.buildGroup(group.body, newOptions); +}; + +const mathmlBuilder = (group: ParseNode<"font">, options: Options) => { + const font = group.font; + const newOptions = options.withFont(font); + return mml.buildGroup(group.body, newOptions); +}; + +const fontAliases = { + "\\Bbb": "\\mathbb", + "\\bold": "\\mathbf", + "\\frak": "\\mathfrak", +} as const; + +type OldFontCommands = "\\rm" | "\\sf" | "\\tt" | "\\bf" | "\\it" | "\\cal"; +type FontCommands = + "\\mathrm" | "\\mathit" | "\\mathbf" | "\\mathnormal" | "\\mathsfit" | + "\\mathbb" | "\\mathcal" | "\\mathfrak" | "\\mathscr" | "\\mathsf" | + "\\mathtt"; + +defineFunction({ + type: "font", + names: [ + // styles, except \boldsymbol defined below + "\\mathrm", "\\mathit", "\\mathbf", "\\mathnormal", "\\mathsfit", + + // families + "\\mathbb", "\\mathcal", "\\mathfrak", "\\mathscr", "\\mathsf", + "\\mathtt", + + // aliases, except \bm defined below + "\\Bbb", "\\bold", "\\frak", + ] satisfies (FontCommands | keyof typeof fontAliases)[], + props: { + numArgs: 1, + allowedInArgument: true, + }, + handler: ({parser, funcName}, args) => { + const body = normalizeArgument(args[0]); + let func = funcName; + if (func in fontAliases) { + func = fontAliases[func as keyof typeof fontAliases]; + } + return { + type: "font", + mode: parser.mode, + font: func.slice(1) as Slice1, + body, + }; + }, + htmlBuilder, + mathmlBuilder, +}); + +defineFunction({ + type: "mclass", + names: ["\\boldsymbol", "\\bm"], + props: { + numArgs: 1, + }, + handler: ({parser}, args) => { + const body = args[0]; + // amsbsy.sty's \boldsymbol uses \binrel spacing to inherit the + // argument's bin|rel|ord status + return { + type: "mclass", + mode: parser.mode, + mclass: binrelClass(body), + body: [ + { + type: "font", + mode: parser.mode, + font: "boldsymbol", + body, + }, + ], + isCharacterBox: isCharacterBox(body), + }; + }, +}); + +// Old font changing functions +defineFunction({ + type: "font", + names: ["\\rm", "\\sf", "\\tt", "\\bf", "\\it", "\\cal"], + props: { + numArgs: 0, + allowedInText: true, + }, + handler: ({parser, funcName, breakOnTokenText}, args) => { + const {mode} = parser; + const body = parser.parseExpression(true, breakOnTokenText); + + return { + type: "font", + mode: mode, + font: `math${funcName.slice(1) as Slice1}`, + body: { + type: "ordgroup", + mode: parser.mode, + body, + }, + }; + }, + htmlBuilder, + mathmlBuilder, +}); diff --git a/node_modules/react-katex/node_modules/katex/src/functions/genfrac.ts b/node_modules/react-katex/node_modules/katex/src/functions/genfrac.ts new file mode 100644 index 0000000..27678f5 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/functions/genfrac.ts @@ -0,0 +1,470 @@ +import defineFunction, {normalizeArgument} from "../defineFunction"; +import {makeLineSpan, makeSpan, makeVList} from "../buildCommon"; +import {makeCustomSizedDelim} from "../delimiter"; +import {MathNode, TextNode} from "../mathMLTree"; +import type {ParseNode} from "../parseNode"; +import Style from "../Style"; +import {assertNodeType} from "../parseNode"; +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; +import {calculateSize, makeEm} from "../units"; +import type {StyleStr} from "../types"; +import type {HtmlBuilder, MathMLBuilder} from "../defineFunction"; + +const htmlBuilder: HtmlBuilder<"genfrac"> = (group, options) => { + // Fractions are handled in the TeXbook on pages 444-445, rules 15(a-e). + const style = options.style; + + const nstyle = style.fracNum(); + const dstyle = style.fracDen(); + let newOptions; + + newOptions = options.havingStyle(nstyle); + const numerm = html.buildGroup(group.numer, newOptions, options); + + if (group.continued) { + // \cfrac inserts a \strut into the numerator. + // Get \strut dimensions from TeXbook page 353. + const hStrut = 8.5 / options.fontMetrics().ptPerEm; + const dStrut = 3.5 / options.fontMetrics().ptPerEm; + numerm.height = numerm.height < hStrut ? hStrut : numerm.height; + numerm.depth = numerm.depth < dStrut ? dStrut : numerm.depth; + } + + newOptions = options.havingStyle(dstyle); + const denomm = html.buildGroup(group.denom, newOptions, options); + + let rule; + let ruleWidth; + let ruleSpacing; + if (group.hasBarLine) { + if (group.barSize) { + ruleWidth = calculateSize(group.barSize, options); + rule = makeLineSpan("frac-line", options, ruleWidth); + } else { + rule = makeLineSpan("frac-line", options); + } + ruleWidth = rule.height; + ruleSpacing = rule.height; + } else { + rule = null; + ruleWidth = 0; + ruleSpacing = options.fontMetrics().defaultRuleThickness; + } + + // Rule 15b + let numShift; + let clearance; + let denomShift; + if (style.size === Style.DISPLAY.size) { + numShift = options.fontMetrics().num1; + if (ruleWidth > 0) { + clearance = 3 * ruleSpacing; + } else { + clearance = 7 * ruleSpacing; + } + denomShift = options.fontMetrics().denom1; + } else { + if (ruleWidth > 0) { + numShift = options.fontMetrics().num2; + clearance = ruleSpacing; + } else { + numShift = options.fontMetrics().num3; + clearance = 3 * ruleSpacing; + } + denomShift = options.fontMetrics().denom2; + } + + let frac; + if (!rule) { + // Rule 15c + const candidateClearance = + (numShift - numerm.depth) - (denomm.height - denomShift); + if (candidateClearance < clearance) { + numShift += 0.5 * (clearance - candidateClearance); + denomShift += 0.5 * (clearance - candidateClearance); + } + + frac = makeVList({ + positionType: "individualShift", + children: [ + {type: "elem", elem: denomm, shift: denomShift}, + {type: "elem", elem: numerm, shift: -numShift}, + ], + }, options); + } else { + // Rule 15d + const axisHeight = options.fontMetrics().axisHeight; + + if ((numShift - numerm.depth) - (axisHeight + 0.5 * ruleWidth) < + clearance) { + numShift += + clearance - ((numShift - numerm.depth) - + (axisHeight + 0.5 * ruleWidth)); + } + + if ((axisHeight - 0.5 * ruleWidth) - (denomm.height - denomShift) < + clearance) { + denomShift += + clearance - ((axisHeight - 0.5 * ruleWidth) - + (denomm.height - denomShift)); + } + + const midShift = -(axisHeight - 0.5 * ruleWidth); + + frac = makeVList({ + positionType: "individualShift", + children: [ + {type: "elem", elem: denomm, shift: denomShift}, + {type: "elem", elem: rule, shift: midShift}, + {type: "elem", elem: numerm, shift: -numShift}, + ], + }, options); + } + + // Since we manually change the style sometimes (with \dfrac or \tfrac), + // account for the possible size change here. + newOptions = options.havingStyle(style); + frac.height *= newOptions.sizeMultiplier / options.sizeMultiplier; + frac.depth *= newOptions.sizeMultiplier / options.sizeMultiplier; + + // Rule 15e + let delimSize; + if (style.size === Style.DISPLAY.size) { + delimSize = options.fontMetrics().delim1; + } else if (style.size === Style.SCRIPTSCRIPT.size) { + delimSize = options.havingStyle(Style.SCRIPT).fontMetrics().delim2; + } else { + delimSize = options.fontMetrics().delim2; + } + + let leftDelim; + let rightDelim; + if (group.leftDelim == null) { + leftDelim = html.makeNullDelimiter(options, ["mopen"]); + } else { + leftDelim = makeCustomSizedDelim( + group.leftDelim, delimSize, true, + options.havingStyle(style), group.mode, ["mopen"]); + } + + if (group.continued) { + rightDelim = makeSpan([]); // zero width for \cfrac + } else if (group.rightDelim == null) { + rightDelim = html.makeNullDelimiter(options, ["mclose"]); + } else { + rightDelim = makeCustomSizedDelim( + group.rightDelim, delimSize, true, + options.havingStyle(style), group.mode, ["mclose"]); + } + + return makeSpan( + ["mord"].concat(newOptions.sizingClasses(options)), + [leftDelim, makeSpan(["mfrac"], [frac]), rightDelim], + options); +}; + +const mathmlBuilder: MathMLBuilder<"genfrac"> = (group, options) => { + const node = new MathNode( + "mfrac", + [ + mml.buildGroup(group.numer, options), + mml.buildGroup(group.denom, options), + ]); + + if (!group.hasBarLine) { + node.setAttribute("linethickness", "0px"); + } else if (group.barSize) { + const ruleWidth = calculateSize(group.barSize, options); + node.setAttribute("linethickness", makeEm(ruleWidth)); + } + + if (group.leftDelim != null || group.rightDelim != null) { + const withDelims = []; + + if (group.leftDelim != null) { + const leftOp = new MathNode( + "mo", + [new TextNode(group.leftDelim.replace("\\", ""))] + ); + + leftOp.setAttribute("fence", "true"); + + withDelims.push(leftOp); + } + + withDelims.push(node); + + if (group.rightDelim != null) { + const rightOp = new MathNode( + "mo", + [new TextNode(group.rightDelim.replace("\\", ""))] + ); + + rightOp.setAttribute("fence", "true"); + + withDelims.push(rightOp); + } + + return mml.makeRow(withDelims); + } + + return node; +}; + +const wrapWithStyle = ( + frac: ParseNode<"genfrac">, + style?: StyleStr | null, +): ParseNode<"genfrac"> => { + if (!style) { + return frac; + } + + const wrapper: ParseNode<"styling"> = { + type: "styling", + mode: frac.mode, + style, + body: [frac], + }; + + // @ts-ignore defineFunction handler needs to return ParseNode<"genfrac"> + return wrapper; +}; + +defineFunction({ + type: "genfrac", + names: [ + "\\cfrac", "\\dfrac", "\\frac", "\\tfrac", + "\\dbinom", "\\binom", "\\tbinom", + "\\\\atopfrac", // can’t be entered directly + "\\\\bracefrac", "\\\\brackfrac", // ditto + ], + props: { + numArgs: 2, + allowedInArgument: true, + }, + handler: ({parser, funcName}, args) => { + const numer = args[0]; + const denom = args[1]; + let hasBarLine: boolean; + let leftDelim: string | null = null; + let rightDelim: string | null = null; + + switch (funcName) { + case "\\cfrac": + case "\\dfrac": + case "\\frac": + case "\\tfrac": + hasBarLine = true; + break; + case "\\\\atopfrac": + hasBarLine = false; + break; + case "\\dbinom": + case "\\binom": + case "\\tbinom": + hasBarLine = false; + leftDelim = "("; + rightDelim = ")"; + break; + case "\\\\bracefrac": + hasBarLine = false; + leftDelim = "\\{"; + rightDelim = "\\}"; + break; + case "\\\\brackfrac": + hasBarLine = false; + leftDelim = "["; + rightDelim = "]"; + break; + default: + throw new Error("Unrecognized genfrac command"); + } + + const continued = funcName === "\\cfrac"; + let style = null; + if (continued || funcName.startsWith("\\d")) { + style = "display" as StyleStr; + } else if (funcName.startsWith("\\t")) { + style = "text" as StyleStr; + } + + return wrapWithStyle({ + type: "genfrac", + mode: parser.mode, + numer, + denom, + continued, + hasBarLine, + leftDelim, + rightDelim, + barSize: null, + }, style); + }, + + htmlBuilder, + mathmlBuilder, +}); + +// Infix generalized fractions -- these are not rendered directly, but replaced +// immediately by one of the variants above. +defineFunction({ + type: "infix", + names: ["\\over", "\\choose", "\\atop", "\\brace", "\\brack"], + props: { + numArgs: 0, + infix: true, + }, + handler({parser, funcName, token}) { + let replaceWith; + switch (funcName) { + case "\\over": + replaceWith = "\\frac"; + break; + case "\\choose": + replaceWith = "\\binom"; + break; + case "\\atop": + replaceWith = "\\\\atopfrac"; + break; + case "\\brace": + replaceWith = "\\\\bracefrac"; + break; + case "\\brack": + replaceWith = "\\\\brackfrac"; + break; + default: + throw new Error("Unrecognized infix genfrac command"); + } + return { + type: "infix", + mode: parser.mode, + replaceWith, + token, + }; + }, +}); + +const stylArray: StyleStr[] = ["display", "text", "script", "scriptscript"]; + +const delimFromValue = function(delimString: string): string | null { + let delim = null; + if (delimString.length > 0) { + delim = delimString; + delim = delim === "." ? null : delim; + } + return delim; +}; + +defineFunction({ + type: "genfrac", + names: ["\\genfrac"], + props: { + numArgs: 6, + allowedInArgument: true, + argTypes: ["math", "math", "size", "text", "math", "math"], + }, + handler({parser}, args) { + const numer = args[4]; + const denom = args[5]; + + // Look into the parse nodes to get the desired delimiters. + const leftNode = normalizeArgument(args[0]); + const leftDelim = leftNode.type === "atom" && leftNode.family === "open" + ? delimFromValue(leftNode.text) : null; + const rightNode = normalizeArgument(args[1]); + const rightDelim = rightNode.type === "atom" && rightNode.family === "close" + ? delimFromValue(rightNode.text) : null; + + const barNode = assertNodeType(args[2], "size"); + let hasBarLine: boolean; + let barSize = null; + if (barNode.isBlank) { + // \genfrac acts differently than \above. + // \genfrac treats an empty size group as a signal to use a + // standard bar size. \above would see size = 0 and omit the bar. + hasBarLine = true; + } else { + barSize = barNode.value; + hasBarLine = barSize.number > 0; + } + + // Find out if we want displaystyle, textstyle, etc. + let size = null; + let styl = args[3]; + if (styl.type === "ordgroup") { + if (styl.body.length > 0) { + const textOrd = assertNodeType(styl.body[0], "textord"); + size = stylArray[Number(textOrd.text)] as StyleStr; + } + } else { + styl = assertNodeType(styl, "textord"); + size = stylArray[Number(styl.text)] as StyleStr; + } + + return wrapWithStyle({ + type: "genfrac", + mode: parser.mode, + numer, + denom, + continued: false, + hasBarLine, + barSize, + leftDelim, + rightDelim, + }, size); + }, +}); + +// \above is an infix fraction that also defines a fraction bar size. +defineFunction({ + type: "infix", + names: ["\\above"], + props: { + numArgs: 1, + argTypes: ["size"], + infix: true, + }, + handler({parser, funcName, token}, args) { + return { + type: "infix", + mode: parser.mode, + replaceWith: "\\\\abovefrac", + size: assertNodeType(args[0], "size").value, + token, + }; + }, +}); + +defineFunction({ + type: "genfrac", + names: ["\\\\abovefrac"], + props: { + numArgs: 3, + argTypes: ["math", "size", "math"], + }, + handler: ({parser, funcName}, args) => { + const numer = args[0]; + const barSize = assertNodeType(args[1], "infix").size; + + if (!barSize) { + throw new Error( + `\\\\abovefrac expected size, but got ${String(barSize)}`); + } + + const denom = args[2]; + + const hasBarLine = barSize.number > 0; + return { + type: "genfrac", + mode: parser.mode, + numer, + denom, + continued: false, + hasBarLine, + barSize, + leftDelim: null, + rightDelim: null, + }; + }, +}); diff --git a/node_modules/react-katex/node_modules/katex/src/functions/hbox.ts b/node_modules/react-katex/node_modules/katex/src/functions/hbox.ts new file mode 100644 index 0000000..f15dae8 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/functions/hbox.ts @@ -0,0 +1,38 @@ +import defineFunction, {ordargument} from "../defineFunction"; +import {makeFragment} from "../buildCommon"; +import {MathNode} from "../mathMLTree"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; + +// \hbox is provided for compatibility with LaTeX \vcenter. +// In LaTeX, \vcenter can act only on a box, as in +// \vcenter{\hbox{$\frac{a+b}{\dfrac{c}{d}}$}} +// This function by itself doesn't do anything but prevent a soft line break. + +defineFunction({ + type: "hbox", + names: ["\\hbox"], + props: { + numArgs: 1, + argTypes: ["text"], + allowedInText: true, + primitive: true, + }, + handler({parser}, args) { + return { + type: "hbox", + mode: parser.mode, + body: ordargument(args[0]), + }; + }, + htmlBuilder(group, options) { + const elements = html.buildExpression(group.body, options.withFont(''), false); + return makeFragment(elements); + }, + mathmlBuilder(group, options) { + return new MathNode( + "mrow", mml.buildExpression(group.body, options.withFont('')) + ); + }, +}); diff --git a/node_modules/react-katex/node_modules/katex/src/functions/horizBrace.ts b/node_modules/react-katex/node_modules/katex/src/functions/horizBrace.ts new file mode 100644 index 0000000..eda2da9 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/functions/horizBrace.ts @@ -0,0 +1,134 @@ +import defineFunction from "../defineFunction"; +import {makeSpan, makeVList} from "../buildCommon"; +import {MathNode} from "../mathMLTree"; +import {stretchyMathML, stretchySvg} from "../stretchy"; +import Style from "../Style"; +import {assertNodeType} from "../parseNode"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; + +import type {HtmlBuilderSupSub, MathMLBuilder} from "../defineFunction"; +import type {ParseNode} from "../parseNode"; + +// NOTE: Unlike most `htmlBuilder`s, this one handles not only "horizBrace", but +// also "supsub" since an over/underbrace can affect super/subscripting. +export const htmlBuilder: HtmlBuilderSupSub<"horizBrace"> = (grp, options) => { + const style = options.style; + + // Pull out the `ParseNode<"horizBrace">` if `grp` is a "supsub" node. + let supSubGroup; + let group: ParseNode<"horizBrace">; + if (grp.type === "supsub") { + // Ref: LaTeX source2e: }}}}\limits} + // i.e. LaTeX treats the brace similar to an op and passes it + // with \limits, so we need to assign supsub style. + supSubGroup = grp.sup ? + html.buildGroup(grp.sup, options.havingStyle(style.sup()), options) : + html.buildGroup(grp.sub, options.havingStyle(style.sub()), options); + group = assertNodeType(grp.base, "horizBrace"); + } else { + group = assertNodeType(grp, "horizBrace"); + } + + // Build the base group + const body = html.buildGroup( + group.base, options.havingBaseStyle(Style.DISPLAY)); + + // Create the stretchy element + const braceBody = stretchySvg(group, options); + + // Generate the vlist, with the appropriate kerns ┏━━━━━━━━┓ + // This first vlist contains the content and the brace: equation + let vlist; + if (group.isOver) { + vlist = makeVList({ + positionType: "firstBaseline", + children: [ + {type: "elem", elem: body}, + {type: "kern", size: 0.1}, + {type: "elem", elem: braceBody, + wrapperClasses: ["svg-align"]}, + ], + }, options); + } else { + vlist = makeVList({ + positionType: "bottom", + positionData: body.depth + 0.1 + braceBody.height, + children: [ + {type: "elem", elem: braceBody, + wrapperClasses: ["svg-align"]}, + {type: "kern", size: 0.1}, + {type: "elem", elem: body}, + ], + }, options); + } + + if (supSubGroup) { + // To write the supsub, wrap the first vlist in another vlist: + // They can't all go in the same vlist, because the note might be + // wider than the equation. We want the equation to control the + // brace width. + + // note long note long note + // ┏━━━━━━━━┓ or ┏━━━┓ not ┏━━━━━━━━━┓ + // equation eqn eqn + + const vSpan = makeSpan( + ["minner", (group.isOver ? "mover" : "munder")], + [vlist], options); + + if (group.isOver) { + vlist = makeVList({ + positionType: "firstBaseline", + children: [ + {type: "elem", elem: vSpan}, + {type: "kern", size: 0.2}, + {type: "elem", elem: supSubGroup}, + ], + }, options); + } else { + vlist = makeVList({ + positionType: "bottom", + positionData: vSpan.depth + 0.2 + supSubGroup.height + + supSubGroup.depth, + children: [ + {type: "elem", elem: supSubGroup}, + {type: "kern", size: 0.2}, + {type: "elem", elem: vSpan}, + ], + }, options); + } + } + + return makeSpan( + ["minner", (group.isOver ? "mover" : "munder")], [vlist], options); +}; + +const mathmlBuilder: MathMLBuilder<"horizBrace"> = (group, options) => { + const accentNode = stretchyMathML(group.label); + return new MathNode( + (group.isOver ? "mover" : "munder"), + [mml.buildGroup(group.base, options), accentNode] + ); +}; + +// Horizontal stretchy braces +defineFunction({ + type: "horizBrace", + names: ["\\overbrace", "\\underbrace", "\\overbracket", "\\underbracket"], + props: { + numArgs: 1, + }, + handler({parser, funcName}, args) { + return { + type: "horizBrace", + mode: parser.mode, + label: funcName, + isOver: funcName.includes("\\over"), + base: args[0], + }; + }, + htmlBuilder, + mathmlBuilder, +}); diff --git a/node_modules/react-katex/node_modules/katex/src/functions/href.ts b/node_modules/react-katex/node_modules/katex/src/functions/href.ts new file mode 100644 index 0000000..285c054 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/functions/href.ts @@ -0,0 +1,93 @@ +import defineFunction, {ordargument} from "../defineFunction"; +import {makeAnchor} from "../buildCommon"; +import {assertNodeType} from "../parseNode"; +import {MathNode} from "../mathMLTree"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; +import type {ParseNode} from "../parseNode"; + +defineFunction({ + type: "href", + names: ["\\href"], + props: { + numArgs: 2, + argTypes: ["url", "original"], + allowedInText: true, + }, + handler: ({parser}, args) => { + const body = args[1]; + const href = assertNodeType(args[0], "url").url; + + if (!parser.settings.isTrusted({ + command: "\\href", + url: href, + })) { + return parser.formatUnsupportedCmd("\\href"); + } + + return { + type: "href", + mode: parser.mode, + href, + body: ordargument(body), + }; + }, + htmlBuilder: (group, options) => { + const elements = html.buildExpression(group.body, options, false); + return makeAnchor(group.href, [], elements, options); + }, + mathmlBuilder: (group, options) => { + let math = mml.buildExpressionRow(group.body, options); + if (!(math instanceof MathNode)) { + math = new MathNode("mrow", [math]); + } + (math as MathNode).setAttribute("href", group.href); + return math; + }, +}); + +defineFunction({ + type: "href", + names: ["\\url"], + props: { + numArgs: 1, + argTypes: ["url"], + allowedInText: true, + }, + handler: ({parser}, args) => { + const href = assertNodeType(args[0], "url").url; + + if (!parser.settings.isTrusted({ + command: "\\url", + url: href, + })) { + return parser.formatUnsupportedCmd("\\url"); + } + + const chars: ParseNode<"textord">[] = []; + for (let i = 0; i < href.length; i++) { + let c = href[i]; + if (c === "~") { + c = "\\textasciitilde"; + } + chars.push({ + type: "textord", + mode: "text", + text: c, + }); + } + const body: ParseNode<"text"> = { + type: "text", + mode: parser.mode, + font: "\\texttt", + body: chars, + }; + return { + type: "href", + mode: parser.mode, + href, + body: ordargument(body), + }; + }, +}); diff --git a/node_modules/react-katex/node_modules/katex/src/functions/html.ts b/node_modules/react-katex/node_modules/katex/src/functions/html.ts new file mode 100644 index 0000000..d9e1661 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/functions/html.ts @@ -0,0 +1,105 @@ +import defineFunction, {ordargument} from "../defineFunction"; +import {makeSpan} from "../buildCommon"; +import {assertNodeType} from "../parseNode"; +import ParseError from "../ParseError"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; +import type {AnyTrustContext} from "../Settings"; + +defineFunction({ + type: "html", + names: ["\\htmlClass", "\\htmlId", "\\htmlStyle", "\\htmlData"], + props: { + numArgs: 2, + argTypes: ["raw", "original"], + allowedInText: true, + }, + handler: ({parser, funcName, token}, args) => { + const value = assertNodeType(args[0], "raw").string; + const body = args[1]; + + if (parser.settings.strict) { + parser.settings.reportNonstrict("htmlExtension", + "HTML extension is disabled on strict mode"); + } + + let trustContext: AnyTrustContext; + const attributes: Record = {}; + + switch (funcName) { + case "\\htmlClass": + attributes.class = value; + trustContext = { + command: "\\htmlClass", + class: value, + }; + break; + case "\\htmlId": + attributes.id = value; + trustContext = { + command: "\\htmlId", + id: value, + }; + break; + case "\\htmlStyle": + attributes.style = value; + trustContext = { + command: "\\htmlStyle", + style: value, + }; + break; + case "\\htmlData": { + const data = value.split(","); + for (let i = 0; i < data.length; i++) { + const item = data[i]; + const firstEquals = item.indexOf("="); + if (firstEquals < 0) { + throw new ParseError(`\\htmlData key/value '${item}'` + + ` missing equals sign`); + } + const key = item.slice(0, firstEquals); + const value = item.slice(firstEquals + 1); + attributes["data-" + key.trim()] = value; + } + + trustContext = { + command: "\\htmlData", + attributes, + }; + break; + } + default: + throw new Error("Unrecognized html command"); + } + + if (!parser.settings.isTrusted(trustContext)) { + return parser.formatUnsupportedCmd(funcName); + } + return { + type: "html", + mode: parser.mode, + attributes, + body: ordargument(body), + }; + }, + htmlBuilder: (group, options) => { + const elements = html.buildExpression(group.body, options, false); + + const classes = ["enclosing"]; + if (group.attributes.class) { + classes.push(...group.attributes.class.trim().split(/\s+/)); + } + + const span = makeSpan(classes, elements, options); + for (const attr in group.attributes) { + if (attr !== "class" && group.attributes.hasOwnProperty(attr)) { + span.setAttribute(attr, group.attributes[attr]); + } + } + return span; + }, + mathmlBuilder: (group, options) => { + return mml.buildExpressionRow(group.body, options); + }, +}); diff --git a/node_modules/react-katex/node_modules/katex/src/functions/htmlmathml.ts b/node_modules/react-katex/node_modules/katex/src/functions/htmlmathml.ts new file mode 100644 index 0000000..fc209f3 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/functions/htmlmathml.ts @@ -0,0 +1,34 @@ +import defineFunction, {ordargument} from "../defineFunction"; +import {makeFragment} from "../buildCommon"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; + +defineFunction({ + type: "htmlmathml", + names: ["\\html@mathml"], + props: { + numArgs: 2, + allowedInArgument: true, + allowedInText: true, + }, + handler: ({parser}, args) => { + return { + type: "htmlmathml", + mode: parser.mode, + html: ordargument(args[0]), + mathml: ordargument(args[1]), + }; + }, + htmlBuilder: (group, options) => { + const elements = html.buildExpression( + group.html, + options, + false + ); + return makeFragment(elements); + }, + mathmlBuilder: (group, options) => { + return mml.buildExpressionRow(group.mathml, options); + }, +}); diff --git a/node_modules/react-katex/node_modules/katex/src/functions/includegraphics.ts b/node_modules/react-katex/node_modules/katex/src/functions/includegraphics.ts new file mode 100644 index 0000000..20856f7 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/functions/includegraphics.ts @@ -0,0 +1,150 @@ +import defineFunction from "../defineFunction"; +import type {Measurement} from "../units"; +import {calculateSize, validUnit, makeEm} from "../units"; +import ParseError from "../ParseError"; +import {Img} from "../domTree"; +import {MathNode} from "../mathMLTree"; +import {assertNodeType} from "../parseNode"; +import type {CssStyle} from "../domTree"; + +const sizeData = function(str: string): Measurement { + if (/^[-+]? *(\d+(\.\d*)?|\.\d+)$/.test(str)) { + // str is a number with no unit specified. + // default unit is bp, per graphix package. + return {number: +str, unit: "bp"}; + } else { + const match = (/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/).exec(str); + if (!match) { + throw new ParseError("Invalid size: '" + str + + "' in \\includegraphics"); + } + const data = { + number: +(match[1] + match[2]), // sign + magnitude, cast to number + unit: match[3], + }; + if (!validUnit(data)) { + throw new ParseError("Invalid unit: '" + data.unit + + "' in \\includegraphics."); + } + return data; + } +}; + +defineFunction({ + type: "includegraphics", + names: ["\\includegraphics"], + props: { + numArgs: 1, + numOptionalArgs: 1, + argTypes: ["raw", "url"], + allowedInText: false, + }, + handler: ({parser}, args, optArgs) => { + let width = {number: 0, unit: "em"}; + let height = {number: 0.9, unit: "em"}; // sorta character sized. + let totalheight = {number: 0, unit: "em"}; + let alt = ""; + + if (optArgs[0]) { + const attributeStr = assertNodeType(optArgs[0], "raw").string; + + // Parser.js does not parse key/value pairs. We get a string. + const attributes = attributeStr.split(","); + for (let i = 0; i < attributes.length; i++) { + const keyVal = attributes[i].split("="); + if (keyVal.length === 2) { + const str = keyVal[1].trim(); + switch (keyVal[0].trim()) { + case "alt": + alt = str; + break; + case "width": + width = sizeData(str); + break; + case "height": + height = sizeData(str); + break; + case "totalheight": + totalheight = sizeData(str); + break; + default: + throw new ParseError("Invalid key: '" + keyVal[0] + + "' in \\includegraphics."); + } + } + } + } + + const src = assertNodeType(args[0], "url").url; + + if (alt === "") { + // No alt given. Use the file name. Strip away the path. + alt = src; + alt = alt.replace(/^.*[\\/]/, ''); + alt = alt.substring(0, alt.lastIndexOf('.')); + } + + if (!parser.settings.isTrusted({ + command: "\\includegraphics", + url: src, + })) { + return parser.formatUnsupportedCmd("\\includegraphics"); + } + + return { + type: "includegraphics", + mode: parser.mode, + alt: alt, + width: width, + height: height, + totalheight: totalheight, + src: src, + }; + }, + htmlBuilder: (group, options) => { + const height = calculateSize(group.height, options); + let depth = 0; + + if (group.totalheight.number > 0) { + depth = calculateSize(group.totalheight, options) - height; + } + + let width = 0; + if (group.width.number > 0) { + width = calculateSize(group.width, options); + } + + const style: CssStyle = {height: makeEm(height + depth)}; + if (width > 0) { + style.width = makeEm(width); + } + if (depth > 0) { + style.verticalAlign = makeEm(-depth); + } + + const node = new Img(group.src, group.alt, style); + node.height = height; + node.depth = depth; + + return node; + }, + mathmlBuilder: (group, options) => { + const node = new MathNode("mglyph", []); + node.setAttribute("alt", group.alt); + + const height = calculateSize(group.height, options); + let depth = 0; + if (group.totalheight.number > 0) { + depth = calculateSize(group.totalheight, options) - height; + node.setAttribute("valign", makeEm(-depth)); + } + node.setAttribute("height", makeEm(height + depth)); + + if (group.width.number > 0) { + const width = calculateSize(group.width, options); + node.setAttribute("width", makeEm(width)); + } + node.setAttribute("src", group.src); + return node; + }, +}); diff --git a/node_modules/react-katex/node_modules/katex/src/functions/kern.ts b/node_modules/react-katex/node_modules/katex/src/functions/kern.ts new file mode 100644 index 0000000..002700a --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/functions/kern.ts @@ -0,0 +1,55 @@ +// Horizontal spacing commands + +import defineFunction from "../defineFunction"; +import {makeGlue} from "../buildCommon"; +import {SpaceNode} from "../mathMLTree"; +import {calculateSize} from "../units"; +import {assertNodeType} from "../parseNode"; + +// TODO: \hskip and \mskip should support plus and minus in lengths + +defineFunction({ + type: "kern", + names: ["\\kern", "\\mkern", "\\hskip", "\\mskip"], + props: { + numArgs: 1, + argTypes: ["size"], + primitive: true, + allowedInText: true, + }, + handler({parser, funcName}, args) { + const size = assertNodeType(args[0], "size"); + if (parser.settings.strict) { + const mathFunction = (funcName[1] === 'm'); // \mkern, \mskip + const muUnit = (size.value.unit === 'mu'); + if (mathFunction) { + if (!muUnit) { + parser.settings.reportNonstrict("mathVsTextUnits", + `LaTeX's ${funcName} supports only mu units, ` + + `not ${size.value.unit} units`); + } + if (parser.mode !== "math") { + parser.settings.reportNonstrict("mathVsTextUnits", + `LaTeX's ${funcName} works only in math mode`); + } + } else { // !mathFunction + if (muUnit) { + parser.settings.reportNonstrict("mathVsTextUnits", + `LaTeX's ${funcName} doesn't support mu units`); + } + } + } + return { + type: "kern", + mode: parser.mode, + dimension: size.value, + }; + }, + htmlBuilder(group, options) { + return makeGlue(group.dimension, options); + }, + mathmlBuilder(group, options) { + const dimension = calculateSize(group.dimension, options); + return new SpaceNode(dimension); + }, +}); diff --git a/node_modules/react-katex/node_modules/katex/src/functions/lap.ts b/node_modules/react-katex/node_modules/katex/src/functions/lap.ts new file mode 100644 index 0000000..35700bf --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/functions/lap.ts @@ -0,0 +1,73 @@ +// Horizontal overlap functions +import defineFunction from "../defineFunction"; +import {makeSpan} from "../buildCommon"; +import {MathNode} from "../mathMLTree"; +import {makeEm} from "../units"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; + +defineFunction({ + type: "lap", + names: ["\\mathllap", "\\mathrlap", "\\mathclap"], + props: { + numArgs: 1, + allowedInText: true, + }, + handler: ({parser, funcName}, args) => { + const body = args[0]; + return { + type: "lap", + mode: parser.mode, + alignment: funcName.slice(5), + body, + }; + }, + htmlBuilder: (group, options) => { + // mathllap, mathrlap, mathclap + let inner; + if (group.alignment === "clap") { + // ref: https://www.math.lsu.edu/~aperlis/publications/mathclap/ + inner = makeSpan( + [], [html.buildGroup(group.body, options)]); + // wrap, since CSS will center a .clap > .inner > span + inner = makeSpan(["inner"], [inner], options); + } else { + inner = makeSpan( + ["inner"], [html.buildGroup(group.body, options)]); + } + const fix = makeSpan(["fix"], []); + let node = makeSpan( + [group.alignment], [inner, fix], options); + + // At this point, we have correctly set horizontal alignment of the + // two items involved in the lap. + // Next, use a strut to set the height of the HTML bounding box. + // Otherwise, a tall argument may be misplaced. + // This code resolved issue #1153 + const strut = makeSpan(["strut"]); + strut.style.height = makeEm(node.height + node.depth); + if (node.depth) { + strut.style.verticalAlign = makeEm(-node.depth); + } + node.children.unshift(strut); + + // Next, prevent vertical misplacement when next to something tall. + // This code resolves issue #1234 + node = makeSpan(["thinbox"], [node], options); + return makeSpan(["mord", "vbox"], [node], options); + }, + mathmlBuilder: (group, options) => { + // mathllap, mathrlap, mathclap + const node = new MathNode( + "mpadded", [mml.buildGroup(group.body, options)]); + + if (group.alignment !== "rlap") { + const offset = (group.alignment === "llap" ? "-1" : "-0.5"); + node.setAttribute("lspace", offset + "width"); + } + node.setAttribute("width", "0px"); + + return node; + }, +}); diff --git a/node_modules/react-katex/node_modules/katex/src/functions/math.ts b/node_modules/react-katex/node_modules/katex/src/functions/math.ts new file mode 100644 index 0000000..6c2a969 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/functions/math.ts @@ -0,0 +1,42 @@ +import defineFunction from "../defineFunction"; +import ParseError from "../ParseError"; + +// Switching from text mode back to math mode +defineFunction({ + type: "styling", + names: ["\\(", "$"], + props: { + numArgs: 0, + allowedInText: true, + allowedInMath: false, + }, + handler({funcName, parser}, args) { + const outerMode = parser.mode; + parser.switchMode("math"); + const close = (funcName === "\\(" ? "\\)" : "$"); + const body = parser.parseExpression(false, close); + parser.expect(close); + parser.switchMode(outerMode); + return { + type: "styling", + mode: parser.mode, + style: "text", + resetFont: true, + body, + }; + }, +}); + +// Check for extra closing math delimiters +defineFunction({ + type: "text", // Doesn't matter what this is. + names: ["\\)", "\\]"], + props: { + numArgs: 0, + allowedInText: true, + allowedInMath: false, + }, + handler(context, args) { + throw new ParseError(`Mismatched ${context.funcName}`); + }, +}); diff --git a/node_modules/react-katex/node_modules/katex/src/functions/mathchoice.ts b/node_modules/react-katex/node_modules/katex/src/functions/mathchoice.ts new file mode 100644 index 0000000..f11787f --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/functions/mathchoice.ts @@ -0,0 +1,51 @@ +import defineFunction, {ordargument} from "../defineFunction"; +import {makeFragment} from "../buildCommon"; +import Style from "../Style"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; + +import type Options from "../Options"; +import type {ParseNode} from "../parseNode"; + +const chooseMathStyle = (group: ParseNode<"mathchoice">, options: Options) => { + switch (options.style.size) { + case Style.DISPLAY.size: return group.display; + case Style.TEXT.size: return group.text; + case Style.SCRIPT.size: return group.script; + case Style.SCRIPTSCRIPT.size: return group.scriptscript; + default: return group.text; + } +}; + +defineFunction({ + type: "mathchoice", + names: ["\\mathchoice"], + props: { + numArgs: 4, + primitive: true, + }, + handler: ({parser}, args) => { + return { + type: "mathchoice", + mode: parser.mode, + display: ordargument(args[0]), + text: ordargument(args[1]), + script: ordargument(args[2]), + scriptscript: ordargument(args[3]), + }; + }, + htmlBuilder: (group, options) => { + const body = chooseMathStyle(group, options); + const elements = html.buildExpression( + body, + options, + false + ); + return makeFragment(elements); + }, + mathmlBuilder: (group, options) => { + const body = chooseMathStyle(group, options); + return mml.buildExpressionRow(body, options); + }, +}); diff --git a/node_modules/react-katex/node_modules/katex/src/functions/mclass.ts b/node_modules/react-katex/node_modules/katex/src/functions/mclass.ts new file mode 100644 index 0000000..788eddc --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/functions/mclass.ts @@ -0,0 +1,165 @@ +import defineFunction, {ordargument} from "../defineFunction"; +import {makeSpan} from "../buildCommon"; +import {isCharacterBox} from "../utils"; +import {MathNode} from "../mathMLTree"; +import type {AnyParseNode} from "../parseNode"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; + +import type Options from "../Options"; +import type {ParseNode} from "../parseNode"; + +function htmlBuilder(group: ParseNode<"mclass">, options: Options) { + const elements = html.buildExpression(group.body, options, true); + return makeSpan([group.mclass], elements, options); +} + +function mathmlBuilder(group: ParseNode<"mclass">, options: Options) { + let node: MathNode; + const inner = mml.buildExpression(group.body, options); + + if (group.mclass === "minner") { + node = new MathNode("mpadded", inner); + } else if (group.mclass === "mord") { + if (group.isCharacterBox) { + node = inner[0]; + node.type = "mi"; + } else { + node = new MathNode("mi", inner); + } + } else { + if (group.isCharacterBox) { + node = inner[0]; + node.type = "mo"; + } else { + node = new MathNode("mo", inner); + } + + // Set spacing based on what is the most likely adjacent atom type. + // See TeXbook p170. + if (group.mclass === "mbin") { + node.attributes.lspace = "0.22em"; // medium space + node.attributes.rspace = "0.22em"; + } else if (group.mclass === "mpunct") { + node.attributes.lspace = "0em"; + node.attributes.rspace = "0.17em"; // thinspace + } else if (group.mclass === "mopen" || group.mclass === "mclose") { + node.attributes.lspace = "0em"; + node.attributes.rspace = "0em"; + } else if (group.mclass === "minner") { + node.attributes.lspace = "0.0556em"; // 1 mu is the most likely option + node.attributes.width = "+0.1111em"; + } + // MathML default space is 5/18 em, so needs no action. + // Ref: https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mo + } + return node; +} + +// Math class commands except \mathop +defineFunction({ + type: "mclass", + names: [ + "\\mathord", "\\mathbin", "\\mathrel", "\\mathopen", + "\\mathclose", "\\mathpunct", "\\mathinner", + ], + props: { + numArgs: 1, + primitive: true, + }, + handler({parser, funcName}, args) { + const body = args[0]; + return { + type: "mclass", + mode: parser.mode, + mclass: "m" + funcName.slice(5), // TODO(kevinb): don't prefix with 'm' + body: ordargument(body), + isCharacterBox: isCharacterBox(body), + }; + }, + htmlBuilder, + mathmlBuilder, +}); + +export const binrelClass = (arg: AnyParseNode): string => { + // \binrel@ spacing varies with (bin|rel|ord) of the atom in the argument. + // (by rendering separately and with {}s before and after, and measuring + // the change in spacing). We'll do roughly the same by detecting the + // atom type directly. + const atom = (arg.type === "ordgroup" && arg.body.length ? arg.body[0] : arg); + if (atom.type === "atom" && (atom.family === "bin" || atom.family === "rel")) { + return "m" + atom.family; + } else { + return "mord"; + } +}; + +// \@binrel{x}{y} renders like y but as mbin/mrel/mord if x is mbin/mrel/mord. +// This is equivalent to \binrel@{x}\binrel@@{y} in AMSTeX. +defineFunction({ + type: "mclass", + names: ["\\@binrel"], + props: { + numArgs: 2, + }, + handler({parser}, args) { + return { + type: "mclass", + mode: parser.mode, + mclass: binrelClass(args[0]), + body: ordargument(args[1]), + isCharacterBox: isCharacterBox(args[1]), + }; + }, +}); + +// Build a relation or stacked op by placing one symbol on top of another +defineFunction({ + type: "mclass", + names: ["\\stackrel", "\\overset", "\\underset"], + props: { + numArgs: 2, + }, + handler({parser, funcName}, args) { + const baseArg = args[1]; + const shiftedArg = args[0]; + + let mclass; + if (funcName !== "\\stackrel") { + // LaTeX applies \binrel spacing to \overset and \underset. + mclass = binrelClass(baseArg); + } else { + mclass = "mrel"; // for \stackrel + } + + const baseOp: ParseNode<"op"> = { + type: "op", + mode: baseArg.mode, + limits: true, + alwaysHandleSupSub: true, + parentIsSupSub: false, + symbol: false, + suppressBaseShift: funcName !== "\\stackrel", + body: ordargument(baseArg), + }; + + const supsub: ParseNode<"supsub"> = { + type: "supsub", + mode: shiftedArg.mode, + base: baseOp, + sup: funcName === "\\underset" ? null : shiftedArg, + sub: funcName === "\\underset" ? shiftedArg : null, + }; + + return { + type: "mclass", + mode: parser.mode, + mclass, + body: [supsub], + isCharacterBox: isCharacterBox(supsub), + }; + }, + htmlBuilder, + mathmlBuilder, +}); diff --git a/node_modules/react-katex/node_modules/katex/src/functions/op.ts b/node_modules/react-katex/node_modules/katex/src/functions/op.ts new file mode 100644 index 0000000..1d62314 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/functions/op.ts @@ -0,0 +1,337 @@ +// Limits, symbols +import defineFunction, {ordargument} from "../defineFunction"; +import {mathsym, makeSpan, makeSymbol, makeVList, staticSvg} from "../buildCommon"; +import {SymbolNode} from "../domTree"; +import {MathNode, newDocumentFragment, TextNode} from "../mathMLTree"; +import Style from "../Style"; +import {assembleSupSub} from "./utils/assembleSupSub"; +import {assertNodeType} from "../parseNode"; +import {makeEm} from "../units"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; + +import type {HtmlBuilderSupSub, MathMLBuilder} from "../defineFunction"; +import type {ParseNode} from "../parseNode"; + +// Most operators have a large successor symbol, but these don't. +const noSuccessor = new Set([ + "\\smallint", +]); + +// NOTE: Unlike most `htmlBuilder`s, this one handles not only "op", but also +// "supsub" since some of them (like \int) can affect super/subscripting. +export const htmlBuilder: HtmlBuilderSupSub<"op"> = (grp, options) => { + // Operators are handled in the TeXbook pg. 443-444, rule 13(a). + let supGroup; + let subGroup; + let hasLimits = false; + let group: ParseNode<"op">; + if (grp.type === "supsub") { + // If we have limits, supsub will pass us its group to handle. Pull + // out the superscript and subscript and set the group to the op in + // its base. + supGroup = grp.sup; + subGroup = grp.sub; + group = assertNodeType(grp.base, "op"); + hasLimits = true; + } else { + group = assertNodeType(grp, "op"); + } + + const style = options.style; + + let large = false; + if (style.size === Style.DISPLAY.size && + group.symbol && + !noSuccessor.has(group.name)) { + + // Most symbol operators get larger in displaystyle (rule 13) + large = true; + } + + let base; + // Italic correction from the symbol glyph, captured before the symbol + // may be wrapped in a vlist (for \oiint/\oiiint). Stays 0 for non-symbol ops. + let symbolItalic; + if (group.symbol) { + // If this is a symbol, create the symbol. + const fontName = large ? "Size2-Regular" : "Size1-Regular"; + + let stash = ""; + if (group.name === "\\oiint" || group.name === "\\oiiint") { + // No font glyphs yet, so use a glyph w/o the oval. + // TODO: When font glyphs are available, delete this code. + stash = group.name.slice(1); + group.name = stash === "oiint" ? "\\iint" : "\\iiint"; + } + + base = makeSymbol( + group.name, fontName, "math", options, + ["mop", "op-symbol", large ? "large-op" : "small-op"]); + symbolItalic = base.italic; + + if (stash.length > 0) { + // We're in \oiint or \oiiint. Overlay the oval. + // TODO: When font glyphs are available, delete this code. + const oval = staticSvg(stash + "Size" + + (large ? "2" : "1"), options); + base = makeVList({ + positionType: "individualShift", + children: [ + {type: "elem", elem: base, shift: 0}, + {type: "elem", elem: oval, shift: large ? 0.08 : 0}, + ], + }, options); + group.name = "\\" + stash; + base.classes.unshift("mop"); + // Carry the italic correction from the original symbol to the + // vlist wrapper so supsub can use it for subscript positioning. + base.italic = symbolItalic; + } + } else if (group.body) { + // If this is a list, compose that list. + const inner = html.buildExpression(group.body, options, true); + if (inner.length === 1 && inner[0] instanceof SymbolNode) { + base = inner[0]; + base.classes[0] = "mop"; // replace old mclass + } else { + base = makeSpan(["mop"], inner, options); + } + } else { + // Otherwise, this is a text operator. Build the text from the + // operator's name. + const output = []; + for (let i = 1; i < group.name!.length; i++) { + output.push(mathsym(group.name![i], group.mode, options)); + } + base = makeSpan(["mop"], output, options); + } + + // If content of op is a single symbol, shift it vertically. + let baseShift = 0; + let slant = 0; + if ((base instanceof SymbolNode + || group.name === "\\oiint" || group.name === "\\oiiint") + && !group.suppressBaseShift) { + // We suppress the shift of the base of \overset and \underset. Otherwise, + // shift the symbol so its center lies on the axis (rule 13). It + // appears that our fonts have the centers of the symbols already + // almost on the axis, so these numbers are very small. Note we + // don't actually apply this here, but instead it is used either in + // the vlist creation or separately when there are no limits. + baseShift = (base.height - base.depth) / 2 - + options.fontMetrics().axisHeight; + + // The slant of the symbol is just its italic correction. + // SymbolNode carries .italic natively; Span (for \oiint/\oiiint) + // only has it set when nonzero, so default to 0. + slant = base.italic ?? 0; + } + + if (hasLimits) { + return assembleSupSub(base, supGroup, subGroup, options, + style, slant, baseShift); + + } else { + if (baseShift) { + base.style.position = "relative"; + base.style.top = makeEm(baseShift); + } + + return base; + } +}; + +const mathmlBuilder: MathMLBuilder<"op"> = (group, options) => { + let node; + + if (group.symbol) { + // This is a symbol. Just add the symbol. + node = new MathNode( + "mo", [mml.makeText(group.name, group.mode)]); + if (noSuccessor.has(group.name)) { + node.setAttribute("largeop", "false"); + } + } else if (group.body) { + // This is an operator with children. Add them. + node = new MathNode( + "mo", mml.buildExpression(group.body, options)); + } else { + // This is a text operator. Add all the characters from the + // operator's name. + node = new MathNode( + "mi", [new TextNode(group.name!.slice(1))]); + // Append an . + // ref: https://www.w3.org/TR/REC-MathML/chap3_2.html#sec3.2.4 + const operator = new MathNode("mo", + [mml.makeText("\u2061", "text")]); + if (group.parentIsSupSub) { + node = new MathNode("mrow", [node, operator]); + } else { + node = newDocumentFragment([node, operator]); + } + } + + return node; +}; + +const singleCharBigOps: Record = { + "\u220F": "\\prod", + "\u2210": "\\coprod", + "\u2211": "\\sum", + "\u22c0": "\\bigwedge", + "\u22c1": "\\bigvee", + "\u22c2": "\\bigcap", + "\u22c3": "\\bigcup", + "\u2a00": "\\bigodot", + "\u2a01": "\\bigoplus", + "\u2a02": "\\bigotimes", + "\u2a04": "\\biguplus", + "\u2a06": "\\bigsqcup", +}; + +defineFunction({ + type: "op", + names: [ + "\\coprod", "\\bigvee", "\\bigwedge", "\\biguplus", "\\bigcap", + "\\bigcup", "\\intop", "\\prod", "\\sum", "\\bigotimes", + "\\bigoplus", "\\bigodot", "\\bigsqcup", "\\smallint", "\u220F", + "\u2210", "\u2211", "\u22c0", "\u22c1", "\u22c2", "\u22c3", "\u2a00", + "\u2a01", "\u2a02", "\u2a04", "\u2a06", + ], + props: { + numArgs: 0, + }, + handler: ({parser, funcName}, args) => { + let fName = funcName; + if (fName.length === 1) { + fName = singleCharBigOps[fName]; + } + return { + type: "op", + mode: parser.mode, + limits: true, + parentIsSupSub: false, + symbol: true, + name: fName, + }; + }, + htmlBuilder, + mathmlBuilder, +}); + +// Note: calling defineFunction with a type that's already been defined only +// works because the same htmlBuilder and mathmlBuilder are being used. +defineFunction({ + type: "op", + names: ["\\mathop"], + props: { + numArgs: 1, + primitive: true, + }, + handler: ({parser}, args) => { + const body = args[0]; + return { + type: "op", + mode: parser.mode, + limits: false, + parentIsSupSub: false, + symbol: false, + body: ordargument(body), + }; + }, + htmlBuilder, + mathmlBuilder, +}); + +// There are 2 flags for operators; whether they produce limits in +// displaystyle, and whether they are symbols and should grow in +// displaystyle. These four groups cover the four possible choices. +const singleCharIntegrals: Record = { + "\u222b": "\\int", + "\u222c": "\\iint", + "\u222d": "\\iiint", + "\u222e": "\\oint", + "\u222f": "\\oiint", + "\u2230": "\\oiiint", +}; + +// No limits, not symbols +defineFunction({ + type: "op", + names: [ + "\\arcsin", "\\arccos", "\\arctan", "\\arctg", "\\arcctg", + "\\arg", "\\ch", "\\cos", "\\cosec", "\\cosh", "\\cot", "\\cotg", + "\\coth", "\\csc", "\\ctg", "\\cth", "\\deg", "\\dim", "\\exp", + "\\hom", "\\ker", "\\lg", "\\ln", "\\log", "\\sec", "\\sin", + "\\sinh", "\\sh", "\\tan", "\\tanh", "\\tg", "\\th", + ], + props: { + numArgs: 0, + }, + handler({parser, funcName}) { + return { + type: "op", + mode: parser.mode, + limits: false, + parentIsSupSub: false, + symbol: false, + name: funcName, + }; + }, + htmlBuilder, + mathmlBuilder, +}); + +// Limits, not symbols +defineFunction({ + type: "op", + names: [ + "\\det", "\\gcd", "\\inf", "\\lim", "\\max", "\\min", "\\Pr", "\\sup", + ], + props: { + numArgs: 0, + }, + handler({parser, funcName}) { + return { + type: "op", + mode: parser.mode, + limits: true, + parentIsSupSub: false, + symbol: false, + name: funcName, + }; + }, + htmlBuilder, + mathmlBuilder, +}); + +// No limits, symbols +defineFunction({ + type: "op", + names: [ + "\\int", "\\iint", "\\iiint", "\\oint", "\\oiint", "\\oiiint", + "\u222b", "\u222c", "\u222d", "\u222e", "\u222f", "\u2230", + ], + props: { + numArgs: 0, + allowedInArgument: true, + }, + handler({parser, funcName}) { + let fName = funcName; + if (fName.length === 1) { + fName = singleCharIntegrals[fName]; + } + return { + type: "op", + mode: parser.mode, + limits: false, + parentIsSupSub: false, + symbol: true, + name: fName, + }; + }, + htmlBuilder, + mathmlBuilder, +}); diff --git a/node_modules/react-katex/node_modules/katex/src/functions/operatorname.ts b/node_modules/react-katex/node_modules/katex/src/functions/operatorname.ts new file mode 100644 index 0000000..f3d1fd9 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/functions/operatorname.ts @@ -0,0 +1,161 @@ +import defineFunction, {ordargument} from "../defineFunction"; +import defineMacro from "../defineMacro"; +import {makeSpan} from "../buildCommon"; +import {MathNode, newDocumentFragment, SpaceNode, TextNode} from "../mathMLTree"; +import {SymbolNode} from "../domTree"; +import {assembleSupSub} from "./utils/assembleSupSub"; +import {assertNodeType} from "../parseNode"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; + +import type {HtmlBuilderSupSub, MathMLBuilder} from "../defineFunction"; +import type {AnyParseNode, ParseNode} from "../parseNode"; + +// NOTE: Unlike most `htmlBuilder`s, this one handles not only +// "operatorname", but also "supsub" since \operatorname* can +// affect super/subscripting. +export const htmlBuilder: HtmlBuilderSupSub<"operatorname"> = (grp, options) => { + // Operators are handled in the TeXbook pg. 443-444, rule 13(a). + let supGroup; + let subGroup; + let hasLimits = false; + let group: ParseNode<"operatorname">; + if (grp.type === "supsub") { + // If we have limits, supsub will pass us its group to handle. Pull + // out the superscript and subscript and set the group to the op in + // its base. + supGroup = grp.sup; + subGroup = grp.sub; + group = assertNodeType(grp.base, "operatorname"); + hasLimits = true; + } else { + group = assertNodeType(grp, "operatorname"); + } + + let base; + if (group.body.length > 0) { + const body = group.body.map((child): AnyParseNode => { + const childText = "text" in child ? child.text : undefined; + if (typeof childText === "string") { + return { + type: "textord", + mode: child.mode, + text: childText, + }; + } else { + return child; + } + }); + + // Consolidate function names into symbol characters. + const expression = html.buildExpression( + body, options.withFont("mathrm"), true); + + for (let i = 0; i < expression.length; i++) { + const child = expression[i]; + if (child instanceof SymbolNode) { + // Per amsopn package, + // change minus to hyphen and \ast to asterisk + child.text = child.text.replace(/\u2212/, "-") + .replace(/\u2217/, "*"); + } + } + base = makeSpan(["mop"], expression, options); + } else { + base = makeSpan(["mop"], [], options); + } + + if (hasLimits) { + return assembleSupSub(base, supGroup, subGroup, options, + options.style, 0, 0); + + } else { + return base; + } +}; + +const mathmlBuilder: MathMLBuilder<"operatorname"> = (group, options) => { + // The steps taken here are similar to the html version. + let expression: Array = mml.buildExpression( + group.body, options.withFont("mathrm")); + + // Is expression a string or has it something like a fraction? + let isAllString = true; // default + for (let i = 0; i < expression.length; i++) { + const node = expression[i]; + if (node instanceof SpaceNode) { + // Do nothing + } else if (node instanceof MathNode) { + switch (node.type) { + case "mi": + case "mn": + case "mspace": + case "mtext": + break; // Do nothing yet. + case "mo": { + const child = node.children[0]; + if (node.children.length === 1 && + child instanceof TextNode) { + child.text = + child.text.replace(/\u2212/, "-") + .replace(/\u2217/, "*"); + } else { + isAllString = false; + } + break; + } + default: + isAllString = false; + } + } else { + isAllString = false; + } + } + + if (isAllString) { + // Write a single TextNode instead of multiple nested tags. + const word = expression.map(node => node.toText()).join(""); + expression = [new TextNode(word)]; + } + + const identifier = new MathNode("mi", expression); + identifier.setAttribute("mathvariant", "normal"); + + // \u2061 is the same as ⁡ + // ref: https://www.w3schools.com/charsets/ref_html_entities_a.asp + const operator = new MathNode("mo", + [mml.makeText("\u2061", "text")]); + + if (group.parentIsSupSub) { + return new MathNode("mrow", [identifier, operator]); + } else { + return newDocumentFragment([identifier, operator]); + } +}; + +// \operatorname +// amsopn.dtx: \mathop{#1\kern\z@\operator@font#3}\newmcodes@ +defineFunction({ + type: "operatorname", + names: ["\\operatorname@", "\\operatornamewithlimits"], + props: { + numArgs: 1, + }, + handler: ({parser, funcName}, args) => { + const body = args[0]; + return { + type: "operatorname", + mode: parser.mode, + body: ordargument(body), + alwaysHandleSupSub: (funcName === "\\operatornamewithlimits"), + limits: false, + parentIsSupSub: false, + }; + }, + htmlBuilder, + mathmlBuilder, +}); + +defineMacro("\\operatorname", + "\\@ifstar\\operatornamewithlimits\\operatorname@"); diff --git a/node_modules/react-katex/node_modules/katex/src/functions/ordgroup.ts b/node_modules/react-katex/node_modules/katex/src/functions/ordgroup.ts new file mode 100644 index 0000000..adf828a --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/functions/ordgroup.ts @@ -0,0 +1,20 @@ +import {defineFunctionBuilders} from "../defineFunction"; +import {makeFragment, makeSpan} from "../buildCommon"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; + +defineFunctionBuilders({ + type: "ordgroup", + htmlBuilder(group, options) { + if (group.semisimple) { + return makeFragment( + html.buildExpression(group.body, options, false)); + } + return makeSpan( + ["mord"], html.buildExpression(group.body, options, true), options); + }, + mathmlBuilder(group, options) { + return mml.buildExpressionRow(group.body, options, true); + }, +}); diff --git a/node_modules/react-katex/node_modules/katex/src/functions/overline.ts b/node_modules/react-katex/node_modules/katex/src/functions/overline.ts new file mode 100644 index 0000000..ec79991 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/functions/overline.ts @@ -0,0 +1,58 @@ +import defineFunction from "../defineFunction"; +import {makeLineSpan, makeSpan, makeVList} from "../buildCommon"; +import {MathNode, TextNode} from "../mathMLTree"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; + +defineFunction({ + type: "overline", + names: ["\\overline"], + props: { + numArgs: 1, + }, + handler({parser}, args) { + const body = args[0]; + return { + type: "overline", + mode: parser.mode, + body, + }; + }, + htmlBuilder(group, options) { + // Overlines are handled in the TeXbook pg 443, Rule 9. + + // Build the inner group in the cramped style. + const innerGroup = html.buildGroup(group.body, + options.havingCrampedStyle()); + + // Create the line above the body + const line = makeLineSpan("overline-line", options); + + // Generate the vlist, with the appropriate kerns + const defaultRuleThickness = options.fontMetrics().defaultRuleThickness; + const vlist = makeVList({ + positionType: "firstBaseline", + children: [ + {type: "elem", elem: innerGroup}, + {type: "kern", size: 3 * defaultRuleThickness}, + {type: "elem", elem: line}, + {type: "kern", size: defaultRuleThickness}, + ], + }, options); + + return makeSpan(["mord", "overline"], [vlist], options); + }, + mathmlBuilder(group, options) { + const operator = new MathNode( + "mo", [new TextNode("\u203e")]); + operator.setAttribute("stretchy", "true"); + + const node = new MathNode( + "mover", + [mml.buildGroup(group.body, options), operator]); + node.setAttribute("accent", "true"); + + return node; + }, +}); diff --git a/node_modules/react-katex/node_modules/katex/src/functions/phantom.ts b/node_modules/react-katex/node_modules/katex/src/functions/phantom.ts new file mode 100644 index 0000000..ea0c513 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/functions/phantom.ts @@ -0,0 +1,73 @@ +import defineFunction, {ordargument} from "../defineFunction"; +import defineMacro from "../defineMacro"; +import {makeFragment, makeSpan} from "../buildCommon"; +import {MathNode} from "../mathMLTree"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; + +defineFunction({ + type: "phantom", + names: ["\\phantom"], + props: { + numArgs: 1, + allowedInText: true, + }, + handler: ({parser}, args) => { + const body = args[0]; + return { + type: "phantom", + mode: parser.mode, + body: ordargument(body), + }; + }, + htmlBuilder: (group, options) => { + const elements = html.buildExpression( + group.body, + options.withPhantom(), + false + ); + + // \phantom isn't supposed to affect the elements it contains. + // See "color" for more details. + return makeFragment(elements); + }, + mathmlBuilder: (group, options) => { + const inner = mml.buildExpression(group.body, options); + return new MathNode("mphantom", inner); + }, +}); + +defineMacro("\\hphantom", "\\smash{\\phantom{#1}}"); + +defineFunction({ + type: "vphantom", + names: ["\\vphantom"], + props: { + numArgs: 1, + allowedInText: true, + }, + handler: ({parser}, args) => { + const body = args[0]; + return { + type: "vphantom", + mode: parser.mode, + body, + }; + }, + htmlBuilder: (group, options) => { + const inner = makeSpan( + ["inner"], + [html.buildGroup(group.body, options.withPhantom())]); + const fix = makeSpan(["fix"], []); + return makeSpan( + ["mord", "rlap"], [inner, fix], options); + }, + mathmlBuilder: (group, options) => { + const inner = mml.buildExpression(ordargument(group.body), options); + const phantom = new MathNode("mphantom", inner); + const node = new MathNode("mpadded", [phantom]); + node.setAttribute("width", "0px"); + return node; + }, +}); diff --git a/node_modules/react-katex/node_modules/katex/src/functions/pmb.ts b/node_modules/react-katex/node_modules/katex/src/functions/pmb.ts new file mode 100644 index 0000000..bdcb4af --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/functions/pmb.ts @@ -0,0 +1,43 @@ +import defineFunction, {ordargument} from "../defineFunction"; +import {makeSpan} from "../buildCommon"; +import {MathNode} from "../mathMLTree"; +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; +import {binrelClass} from "./mclass"; + +import type {ParseNode} from "../parseNode"; + +// \pmb is a simulation of bold font. +// The version of \pmb in ambsy.sty works by typesetting three copies +// with small offsets. We use CSS text-shadow. +// It's a hack. Not as good as a real bold font. Better than nothing. + +defineFunction({ + type: "pmb", + names: ["\\pmb"], + props: { + numArgs: 1, + allowedInText: true, + }, + handler({parser}, args) { + return { + type: "pmb", + mode: parser.mode, + mclass: binrelClass(args[0]), + body: ordargument(args[0]), + }; + }, + htmlBuilder(group: ParseNode<"pmb">, options) { + const elements = html.buildExpression(group.body, options, true); + const node = makeSpan([group.mclass], elements, options); + node.style.textShadow = "0.02em 0.01em 0.04px"; + return node; + }, + mathmlBuilder(group: ParseNode<"pmb">, style) { + const inner = mml.buildExpression(group.body, style); + // Wrap with an element. + const node = new MathNode("mstyle", inner); + node.setAttribute("style", "text-shadow: 0.02em 0.01em 0.04px"); + return node; + }, +}); diff --git a/node_modules/react-katex/node_modules/katex/src/functions/raisebox.ts b/node_modules/react-katex/node_modules/katex/src/functions/raisebox.ts new file mode 100644 index 0000000..fb5836a --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/functions/raisebox.ts @@ -0,0 +1,45 @@ +import defineFunction from "../defineFunction"; +import {makeVList} from "../buildCommon"; +import {MathNode} from "../mathMLTree"; +import {assertNodeType} from "../parseNode"; +import {calculateSize} from "../units"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; + +// Box manipulation +defineFunction({ + type: "raisebox", + names: ["\\raisebox"], + props: { + numArgs: 2, + argTypes: ["size", "hbox"], + allowedInText: true, + }, + handler({parser}, args) { + const amount = assertNodeType(args[0], "size").value; + const body = args[1]; + return { + type: "raisebox", + mode: parser.mode, + dy: amount, + body, + }; + }, + htmlBuilder(group, options) { + const body = html.buildGroup(group.body, options); + const dy = calculateSize(group.dy, options); + return makeVList({ + positionType: "shift", + positionData: -dy, + children: [{type: "elem", elem: body}], + }, options); + }, + mathmlBuilder(group, options) { + const node = new MathNode( + "mpadded", [mml.buildGroup(group.body, options)]); + const dy = group.dy.number + group.dy.unit; + node.setAttribute("voffset", dy); + return node; + }, +}); diff --git a/node_modules/react-katex/node_modules/katex/src/functions/relax.ts b/node_modules/react-katex/node_modules/katex/src/functions/relax.ts new file mode 100644 index 0000000..bf8ed08 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/functions/relax.ts @@ -0,0 +1,17 @@ +import defineFunction from "../defineFunction"; + +defineFunction({ + type: "internal", + names: ["\\relax"], + props: { + numArgs: 0, + allowedInText: true, + allowedInArgument: true, + }, + handler({parser}) { + return { + type: "internal", + mode: parser.mode, + }; + }, +}); diff --git a/node_modules/react-katex/node_modules/katex/src/functions/rule.ts b/node_modules/react-katex/node_modules/katex/src/functions/rule.ts new file mode 100644 index 0000000..c697fb8 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/functions/rule.ts @@ -0,0 +1,76 @@ +import {makeSpan} from "../buildCommon"; +import defineFunction from "../defineFunction"; +import {MathNode} from "../mathMLTree"; +import {assertNodeType} from "../parseNode"; +import {calculateSize, makeEm} from "../units"; + +defineFunction({ + type: "rule", + names: ["\\rule"], + props: { + numArgs: 2, + numOptionalArgs: 1, + allowedInText: true, + allowedInMath: true, + argTypes: ["size", "size", "size"], + }, + handler({parser}, args, optArgs) { + const shift = optArgs[0]; + const width = assertNodeType(args[0], "size"); + const height = assertNodeType(args[1], "size"); + return { + type: "rule", + mode: parser.mode, + shift: shift && assertNodeType(shift, "size").value, + width: width.value, + height: height.value, + }; + }, + htmlBuilder(group, options) { + // Make an empty span for the rule + const rule = makeSpan(["mord", "rule"], [], options); + + // Calculate the shift, width, and height of the rule, and account for units + const width = calculateSize(group.width, options); + const height = calculateSize(group.height, options); + const shift = (group.shift) ? calculateSize(group.shift, options) : 0; + + // Style the rule to the right size + rule.style.borderRightWidth = makeEm(width); + rule.style.borderTopWidth = makeEm(height); + rule.style.bottom = makeEm(shift); + + // Record the height and width + rule.width = width; + rule.height = height + shift; + rule.depth = -shift; + // Font size is the number large enough that the browser will + // reserve at least `absHeight` space above the baseline. + // The 1.125 factor was empirically determined + rule.maxFontSize = height * 1.125 * options.sizeMultiplier; + + return rule; + }, + mathmlBuilder(group, options) { + const width = calculateSize(group.width, options); + const height = calculateSize(group.height, options); + const shift = (group.shift) ? calculateSize(group.shift, options) : 0; + const color = options.color && options.getColor() || "black"; + + const rule = new MathNode("mspace"); + rule.setAttribute("mathbackground", color); + rule.setAttribute("width", makeEm(width)); + rule.setAttribute("height", makeEm(height)); + + const wrapper = new MathNode("mpadded", [rule]); + if (shift >= 0) { + wrapper.setAttribute("height", makeEm(shift)); + } else { + wrapper.setAttribute("height", makeEm(shift)); + wrapper.setAttribute("depth", makeEm(-shift)); + } + wrapper.setAttribute("voffset", makeEm(shift)); + + return wrapper; + }, +}); diff --git a/node_modules/react-katex/node_modules/katex/src/functions/sizing.ts b/node_modules/react-katex/node_modules/katex/src/functions/sizing.ts new file mode 100644 index 0000000..573ce25 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/functions/sizing.ts @@ -0,0 +1,90 @@ +import {makeFragment} from "../buildCommon"; +import defineFunction from "../defineFunction"; +import {MathNode} from "../mathMLTree"; +import {makeEm} from "../units"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; + +import type Options from "../Options"; +import type {AnyParseNode} from "../parseNode"; +import type {HtmlBuilder} from "../defineFunction"; +import type {documentFragment as HtmlDocumentFragment} from "../domTree"; + +export function sizingGroup( + value: AnyParseNode[], + options: Options, + baseOptions: Options, +): HtmlDocumentFragment { + const inner = html.buildExpression(value, options, false); + const multiplier = options.sizeMultiplier / baseOptions.sizeMultiplier; + + // Add size-resetting classes to the inner list and set maxFontSize + // manually. Handle nested size changes. + for (let i = 0; i < inner.length; i++) { + const pos = inner[i].classes.indexOf("sizing"); + if (pos < 0) { + Array.prototype.push.apply(inner[i].classes, + options.sizingClasses(baseOptions)); + } else if (inner[i].classes[pos + 1] === "reset-size" + options.size) { + // This is a nested size change: e.g., inner[i] is the "b" in + // `\Huge a \small b`. Override the old size (the `reset-` class) + // but not the new size. + inner[i].classes[pos + 1] = "reset-size" + baseOptions.size; + } + + inner[i].height *= multiplier; + inner[i].depth *= multiplier; + } + + return makeFragment(inner); +} + +const sizeFuncs = [ + "\\tiny", "\\sixptsize", "\\scriptsize", "\\footnotesize", "\\small", + "\\normalsize", "\\large", "\\Large", "\\LARGE", "\\huge", "\\Huge", +]; + +export const htmlBuilder: HtmlBuilder<"sizing"> = (group, options) => { + // Handle sizing operators like \Huge. Real TeX doesn't actually allow + // these functions inside of math expressions, so we do some special + // handling. + const newOptions = options.havingSize(group.size); + return sizingGroup(group.body, newOptions, options); +}; + +defineFunction({ + type: "sizing", + names: sizeFuncs, + props: { + numArgs: 0, + allowedInText: true, + }, + handler: ({breakOnTokenText, funcName, parser}, args) => { + const body = parser.parseExpression(false, breakOnTokenText); + + return { + type: "sizing", + mode: parser.mode, + // Figure out what size to use based on the list of functions above + size: sizeFuncs.indexOf(funcName) + 1, + body, + }; + }, + htmlBuilder, + mathmlBuilder: (group, options) => { + const newOptions = options.havingSize(group.size); + const inner = mml.buildExpression(group.body, newOptions); + + const node = new MathNode("mstyle", inner); + + // TODO(emily): This doesn't produce the correct size for nested size + // changes, because we don't keep state of what style we're currently + // in, so we can't reset the size to normal before changing it. Now + // that we're passing an options parameter we should be able to fix + // this. + node.setAttribute("mathsize", makeEm(newOptions.sizeMultiplier)); + + return node; + }, +}); diff --git a/node_modules/react-katex/node_modules/katex/src/functions/smash.ts b/node_modules/react-katex/node_modules/katex/src/functions/smash.ts new file mode 100644 index 0000000..7e59f3e --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/functions/smash.ts @@ -0,0 +1,115 @@ +// smash, with optional [tb], as in AMS +import defineFunction from "../defineFunction"; +import {makeSpan, makeVList} from "../buildCommon"; +import {MathNode} from "../mathMLTree"; +import {assertNodeType, assertSymbolNodeType} from "../parseNode"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; + +defineFunction({ + type: "smash", + names: ["\\smash"], + props: { + numArgs: 1, + numOptionalArgs: 1, + allowedInText: true, + }, + handler: ({parser}, args, optArgs) => { + let smashHeight = false; + let smashDepth = false; + const tbArg = optArgs[0] && assertNodeType(optArgs[0], "ordgroup"); + if (tbArg) { + // Optional [tb] argument is engaged. + // ref: amsmath: \renewcommand{\smash}[1][tb]{% + // def\mb@t{\ht}\def\mb@b{\dp}\def\mb@tb{\ht\z@\z@\dp}% + let letter; + for (let i = 0; i < tbArg.body.length; ++i) { + const node = tbArg.body[i]; + letter = assertSymbolNodeType(node).text; + if (letter === "t") { + smashHeight = true; + } else if (letter === "b") { + smashDepth = true; + } else { + smashHeight = false; + smashDepth = false; + break; + } + } + } else { + smashHeight = true; + smashDepth = true; + } + + const body = args[0]; + return { + type: "smash", + mode: parser.mode, + body, + smashHeight, + smashDepth, + }; + }, + htmlBuilder: (group, options) => { + const node = makeSpan( + [], [html.buildGroup(group.body, options)]); + + if (!group.smashHeight && !group.smashDepth) { + return node; + } + + if (group.smashHeight) { + node.height = 0; + } + + if (group.smashDepth) { + node.depth = 0; + } + + if (group.smashHeight && group.smashDepth) { + // Symmetric \smash can stay in inline layout. + return makeSpan(["mord", "smash"], [node], options); + } + + // In order to influence makeVList for asymmetric smashing, we have to + // reset the children. + if (node.children) { + for (let i = 0; i < node.children.length; i++) { + if (group.smashHeight) { + node.children[i].height = 0; + } + if (group.smashDepth) { + node.children[i].depth = 0; + } + } + } + + // At this point, we've reset the TeX-like height and depth values. + // But the span still has an HTML line height. + // makeVList applies "display: table-cell", which prevents the browser + // from acting on that line height. So we'll call makeVList now. + + const smashedNode = makeVList({ + positionType: "firstBaseline", + children: [{type: "elem", elem: node}], + }, options); + + // For spacing, TeX treats \smash as a math group (same spacing as ord). + return makeSpan(["mord"], [smashedNode], options); + }, + mathmlBuilder: (group, options) => { + const node = new MathNode( + "mpadded", [mml.buildGroup(group.body, options)]); + + if (group.smashHeight) { + node.setAttribute("height", "0px"); + } + + if (group.smashDepth) { + node.setAttribute("depth", "0px"); + } + + return node; + }, +}); diff --git a/node_modules/react-katex/node_modules/katex/src/functions/sqrt.ts b/node_modules/react-katex/node_modules/katex/src/functions/sqrt.ts new file mode 100644 index 0000000..0b9b1d0 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/functions/sqrt.ts @@ -0,0 +1,124 @@ +import defineFunction from "../defineFunction"; +import {makeSpan, makeVList, wrapFragment} from "../buildCommon"; +import {MathNode} from "../mathMLTree"; +import {makeSqrtImage} from "../delimiter"; +import Style from "../Style"; +import {makeEm} from "../units"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; + +defineFunction({ + type: "sqrt", + names: ["\\sqrt"], + props: { + numArgs: 1, + numOptionalArgs: 1, + }, + handler({parser}, args, optArgs) { + const index = optArgs[0]; + const body = args[0]; + return { + type: "sqrt", + mode: parser.mode, + body, + index, + }; + }, + htmlBuilder(group, options) { + // Square roots are handled in the TeXbook pg. 443, Rule 11. + + // First, we do the same steps as in overline to build the inner group + // and line + let inner = html.buildGroup(group.body, options.havingCrampedStyle()); + if (inner.height === 0) { + // Render a small surd. + inner.height = options.fontMetrics().xHeight; + } + + // Some groups can return document fragments. Handle those by wrapping + // them in a span. + inner = wrapFragment(inner, options); + + // Calculate the minimum size for the \surd delimiter + const metrics = options.fontMetrics(); + const theta = metrics.defaultRuleThickness; + + let phi = theta; + if (options.style.id < Style.TEXT.id) { + phi = options.fontMetrics().xHeight; + } + + // Calculate the clearance between the body and line + let lineClearance = theta + phi / 4; + + const minDelimiterHeight = (inner.height + inner.depth + + lineClearance + theta); + + // Create a sqrt SVG of the required minimum size + const {span: img, ruleWidth, advanceWidth} = + makeSqrtImage(minDelimiterHeight, options); + + const delimDepth = img.height - ruleWidth; + + // Adjust the clearance based on the delimiter size + if (delimDepth > inner.height + inner.depth + lineClearance) { + lineClearance = + (lineClearance + delimDepth - inner.height - inner.depth) / 2; + } + + // Shift the sqrt image + const imgShift = img.height - inner.height - lineClearance - ruleWidth; + + inner.style.paddingLeft = makeEm(advanceWidth); + + // Overlay the image and the argument. + const body = makeVList({ + positionType: "firstBaseline", + children: [ + {type: "elem", elem: inner, wrapperClasses: ["svg-align"]}, + {type: "kern", size: -(inner.height + imgShift)}, + {type: "elem", elem: img}, + {type: "kern", size: ruleWidth}, + ], + }, options); + + if (!group.index) { + return makeSpan(["mord", "sqrt"], [body], options); + } else { + // Handle the optional root index + + // The index is always in scriptscript style + const newOptions = options.havingStyle(Style.SCRIPTSCRIPT); + const rootm = html.buildGroup(group.index, newOptions, options); + + // The amount the index is shifted by. This is taken from the TeX + // source, in the definition of `\r@@t`. + const toShift = 0.6 * (body.height - body.depth); + + // Build a VList with the superscript shifted up correctly + const rootVList = makeVList({ + positionType: "shift", + positionData: -toShift, + children: [{type: "elem", elem: rootm}], + }, options); + // Add a class surrounding it so we can add on the appropriate + // kerning + const rootVListWrap = makeSpan(["root"], [rootVList]); + + return makeSpan(["mord", "sqrt"], + [rootVListWrap, body], options); + } + }, + mathmlBuilder(group, options) { + const {body, index} = group; + return index ? + new MathNode( + "mroot", [ + mml.buildGroup(body, options), + mml.buildGroup(index, options), + ]) : + new MathNode( + "msqrt", [mml.buildGroup(body, options)]); + }, +}); diff --git a/node_modules/react-katex/node_modules/katex/src/functions/styling.ts b/node_modules/react-katex/node_modules/katex/src/functions/styling.ts new file mode 100644 index 0000000..57dce8d --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/functions/styling.ts @@ -0,0 +1,85 @@ +import defineFunction from "../defineFunction"; +import {MathNode} from "../mathMLTree"; +import Style from "../Style"; +import {sizingGroup} from "./sizing"; + +import * as mml from "../buildMathML"; +import type {StyleStr} from "../types"; + +const styleMap: Record = { + "display": Style.DISPLAY, + "text": Style.TEXT, + "script": Style.SCRIPT, + "scriptscript": Style.SCRIPTSCRIPT, +}; + +function isStyleStr(s: string): s is StyleStr { + return s in styleMap; +} + +defineFunction({ + type: "styling", + names: [ + "\\displaystyle", "\\textstyle", "\\scriptstyle", + "\\scriptscriptstyle", + ], + props: { + numArgs: 0, + allowedInText: true, + primitive: true, + }, + handler({breakOnTokenText, funcName, parser}, args) { + // parse out the implicit body + const body = parser.parseExpression(true, breakOnTokenText); + + // TODO: Refactor to avoid duplicating styleMap in multiple places (e.g. + // here and in buildHTML and de-dupe the enumeration of all the styles). + const style = funcName.slice(1, funcName.length - 5); + if (!isStyleStr(style)) { + throw new Error(`Unknown style: ${style}`); + } + return { + type: "styling", + mode: parser.mode, + // Figure out what style to use by pulling out the style from + // the function name + style, + body, + }; + }, + htmlBuilder(group, options) { + // Style changes are handled in the TeXbook on pg. 442, Rule 3. + const newStyle = styleMap[group.style]; + let newOptions = options.havingStyle(newStyle); + if (group.resetFont) { + newOptions = newOptions.withFont(''); + } + return sizingGroup(group.body, newOptions, options); + }, + mathmlBuilder(group, options) { + // Figure out what style we're changing to. + const newStyle = styleMap[group.style]; + let newOptions = options.havingStyle(newStyle); + if (group.resetFont) { + newOptions = newOptions.withFont(''); + } + + const inner = mml.buildExpression(group.body, newOptions); + + const node = new MathNode("mstyle", inner); + + const styleAttributes = { + "display": ["0", "true"], + "text": ["0", "false"], + "script": ["1", "false"], + "scriptscript": ["2", "false"], + }; + + const attr = styleAttributes[group.style]; + + node.setAttribute("scriptlevel", attr[0]); + node.setAttribute("displaystyle", attr[1]); + + return node; + }, +}); diff --git a/node_modules/react-katex/node_modules/katex/src/functions/supsub.ts b/node_modules/react-katex/node_modules/katex/src/functions/supsub.ts new file mode 100644 index 0000000..477fab4 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/functions/supsub.ts @@ -0,0 +1,268 @@ +import {defineFunctionBuilders} from "../defineFunction"; +import {makeSpan, makeVList} from "../buildCommon"; +import {Span, SymbolNode, type HtmlDomNode} from "../domTree"; +import {isCharacterBox} from "../utils"; +import {MathNode} from "../mathMLTree"; +import {makeEm} from "../units"; +import Style from "../Style"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; +import * as accent from "./accent"; +import * as horizBrace from "./horizBrace"; +import * as op from "./op"; +import * as operatorname from "./operatorname"; + +import type Options from "../Options"; +import type {ParseNode} from "../parseNode"; +import type {HtmlBuilder} from "../defineFunction"; +import type {MathNodeType} from "../mathMLTree"; + +/** + * Sometimes, groups perform special rules when they have superscripts or + * subscripts attached to them. This function lets the `supsub` group know that + * Sometimes, groups perform special rules when they have superscripts or + * its inner element should handle the superscripts and subscripts instead of + * handling them itself. + */ +const htmlBuilderDelegate = function( + group: ParseNode<"supsub">, + options: Options, +// eslint-disable-next-line @typescript-eslint/no-explicit-any +): HtmlBuilder | null | undefined { + const base = group.base; + if (!base) { + return null; + } else if (base.type === "op") { + // Operators handle supsubs differently when they have limits + // (e.g. `\displaystyle\sum_2^3`) + const delegate = base.limits && + (options.style.size === Style.DISPLAY.size || + base.alwaysHandleSupSub); + return delegate ? op.htmlBuilder : null; + } else if (base.type === "operatorname") { + const delegate = base.alwaysHandleSupSub && + (options.style.size === Style.DISPLAY.size || base.limits); + return delegate ? operatorname.htmlBuilder : null; + } else if (base.type === "accent") { + return isCharacterBox(base.base) ? accent.htmlBuilder : null; + } else if (base.type === "horizBrace") { + const isSup = !group.sub; + return isSup === base.isOver ? horizBrace.htmlBuilder : null; + } else { + return null; + } +}; + +// Super scripts and subscripts, whose precise placement can depend on other +// functions that precede them. +defineFunctionBuilders({ + type: "supsub", + htmlBuilder(group, options) { + // Superscript and subscripts are handled in the TeXbook on page + // 445-446, rules 18(a-f). + + // Here is where we defer to the inner group if it should handle + // superscripts and subscripts itself. + const builderDelegate = htmlBuilderDelegate(group, options); + if (builderDelegate) { + return builderDelegate(group, options); + } + + const {base: valueBase, sup: valueSup, sub: valueSub} = group; + const base = html.buildGroup(valueBase, options); + let supm; + let subm; + + const metrics = options.fontMetrics(); + + // Rule 18a + let supShift = 0; + let subShift = 0; + + const isCharBox = valueBase && isCharacterBox(valueBase); + if (valueSup) { + const newOptions = options.havingStyle(options.style.sup()); + supm = html.buildGroup(valueSup, newOptions, options); + if (!isCharBox) { + supShift = base.height - newOptions.fontMetrics().supDrop + * newOptions.sizeMultiplier / options.sizeMultiplier; + } + } + + if (valueSub) { + const newOptions = options.havingStyle(options.style.sub()); + subm = html.buildGroup(valueSub, newOptions, options); + if (!isCharBox) { + subShift = base.depth + newOptions.fontMetrics().subDrop + * newOptions.sizeMultiplier / options.sizeMultiplier; + } + } + + // Rule 18c + let minSupShift; + if (options.style === Style.DISPLAY) { + minSupShift = metrics.sup1; + } else if (options.style.cramped) { + minSupShift = metrics.sup3; + } else { + minSupShift = metrics.sup2; + } + + // scriptspace is a font-size-independent size, so scale it + // appropriately for use as the marginRight. + const multiplier = options.sizeMultiplier; + const marginRight = makeEm((0.5 / metrics.ptPerEm) / multiplier); + + let marginLeft = null; + if (subm) { + // Subscripts shouldn't be shifted by the base's italic correction. + // Account for that by shifting the subscript back the appropriate + // amount. Note we only do this when the base is a single symbol. + const isOiint = + group.base && group.base.type === "op" && group.base.name && + (group.base.name === "\\oiint" || group.base.name === "\\oiiint"); + if (base instanceof SymbolNode || isOiint) { + // SymbolNode has .italic natively; for \oiint/\oiiint the + // op builder stores .italic on the wrapping Span. + marginLeft = makeEm( + -((base as SymbolNode | Span).italic ?? 0)); + } + } + + let supsub; + if (supm && subm) { + supShift = Math.max( + supShift, minSupShift, supm.depth + 0.25 * metrics.xHeight); + subShift = Math.max(subShift, metrics.sub2); + + const ruleWidth = metrics.defaultRuleThickness; + + // Rule 18e + const maxWidth = 4 * ruleWidth; + if ((supShift - supm.depth) - (subm.height - subShift) < maxWidth) { + subShift = maxWidth - (supShift - supm.depth) + subm.height; + const psi = 0.8 * metrics.xHeight - (supShift - supm.depth); + if (psi > 0) { + supShift += psi; + subShift -= psi; + } + } + + const vlistElem = [ + {type: "elem" as const, elem: subm, shift: subShift, marginRight, + marginLeft}, + {type: "elem" as const, elem: supm, shift: -supShift, marginRight}, + ]; + + supsub = makeVList({ + positionType: "individualShift", + children: vlistElem, + }, options); + } else if (subm) { + // Rule 18b + subShift = Math.max( + subShift, metrics.sub1, + subm.height - 0.8 * metrics.xHeight); + + const vlistElem = + [{type: "elem" as const, elem: subm, marginLeft, marginRight}]; + + supsub = makeVList({ + positionType: "shift", + positionData: subShift, + children: vlistElem, + }, options); + } else if (supm) { + // Rule 18c, d + supShift = Math.max(supShift, minSupShift, + supm.depth + 0.25 * metrics.xHeight); + + supsub = makeVList({ + positionType: "shift", + positionData: -supShift, + children: [{type: "elem" as const, elem: supm, marginRight}], + }, options); + } else { + throw new Error("supsub must have either sup or sub."); + } + + // Wrap the supsub vlist in a span.msupsub to reset text-align. + const mclass = html.getTypeOfDomTree(base, "right") || "mord"; + return makeSpan([mclass], + [base, makeSpan(["msupsub"], [supsub])], + options); + }, + mathmlBuilder(group, options) { + // Is the inner group a relevant horizontal brace? + let isBrace = false; + let isOver; + let isSup; + + if (group.base && group.base.type === "horizBrace") { + isSup = !!group.sup; + if (isSup === group.base.isOver) { + isBrace = true; + isOver = group.base.isOver; + } + } + + if (group.base && + (group.base.type === "op" || group.base.type === "operatorname")) { + group.base.parentIsSupSub = true; + } + + const children = [mml.buildGroup(group.base, options)]; + + if (group.sub) { + children.push(mml.buildGroup(group.sub, options)); + } + + if (group.sup) { + children.push(mml.buildGroup(group.sup, options)); + } + + let nodeType: MathNodeType; + if (isBrace) { + nodeType = (isOver ? "mover" : "munder"); + } else if (!group.sub) { + const base = group.base; + if (base && base.type === "op" && base.limits && + (options.style === Style.DISPLAY || base.alwaysHandleSupSub)) { + nodeType = "mover"; + } else if (base && base.type === "operatorname" && + base.alwaysHandleSupSub && + (base.limits || options.style === Style.DISPLAY)) { + nodeType = "mover"; + } else { + nodeType = "msup"; + } + } else if (!group.sup) { + const base = group.base; + if (base && base.type === "op" && base.limits && + (options.style === Style.DISPLAY || base.alwaysHandleSupSub)) { + nodeType = "munder"; + } else if (base && base.type === "operatorname" && + base.alwaysHandleSupSub && + (base.limits || options.style === Style.DISPLAY)) { + nodeType = "munder"; + } else { + nodeType = "msub"; + } + } else { + const base = group.base; + if (base && base.type === "op" && base.limits && + options.style === Style.DISPLAY) { + nodeType = "munderover"; + } else if (base && base.type === "operatorname" && + base.alwaysHandleSupSub && + (options.style === Style.DISPLAY || base.limits)) { + nodeType = "munderover"; + } else { + nodeType = "msubsup"; + } + } + + return new MathNode(nodeType, children); + }, +}); diff --git a/node_modules/react-katex/node_modules/katex/src/functions/symbolsOp.ts b/node_modules/react-katex/node_modules/katex/src/functions/symbolsOp.ts new file mode 100644 index 0000000..b0c5086 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/functions/symbolsOp.ts @@ -0,0 +1,32 @@ +import {defineFunctionBuilders} from "../defineFunction"; +import {mathsym} from "../buildCommon"; +import {MathNode} from "../mathMLTree"; + +import * as mml from "../buildMathML"; + +// Operator ParseNodes created in Parser.js from symbol Groups in src/symbols.js. + +defineFunctionBuilders({ + type: "atom", + htmlBuilder(group, options) { + return mathsym( + group.text, group.mode, options, ["m" + group.family]); + }, + mathmlBuilder(group, options) { + const node = new MathNode( + "mo", [mml.makeText(group.text, group.mode)]); + if (group.family === "bin") { + const variant = mml.getVariant(group, options); + if (variant === "bold-italic") { + node.setAttribute("mathvariant", variant); + } + } else if (group.family === "punct") { + node.setAttribute("separator", "true"); + } else if (group.family === "open" || group.family === "close") { + // Delims built here should not stretch vertically. + // See delimsizing.js for stretchy delims. + node.setAttribute("stretchy", "false"); + } + return node; + }, +}); diff --git a/node_modules/react-katex/node_modules/katex/src/functions/symbolsOrd.ts b/node_modules/react-katex/node_modules/katex/src/functions/symbolsOrd.ts new file mode 100644 index 0000000..1ccbfdd --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/functions/symbolsOrd.ts @@ -0,0 +1,61 @@ +import {defineFunctionBuilders} from "../defineFunction"; +import {makeOrd} from "../buildCommon"; +import {MathNode} from "../mathMLTree"; + +import * as mml from "../buildMathML"; + +import type {ParseNode} from "../parseNode"; + +// "mathord" and "textord" ParseNodes created in Parser.js from symbol Groups in +// src/symbols.js. + +const defaultVariant: Record = { + "mi": "italic", + "mn": "normal", + "mtext": "normal", +}; + +defineFunctionBuilders({ + type: "mathord", + htmlBuilder(group, options) { + return makeOrd(group, options, "mathord"); + }, + mathmlBuilder(group: ParseNode<"mathord">, options) { + const node = new MathNode( + "mi", + [mml.makeText(group.text, group.mode, options)]); + + const variant = mml.getVariant(group, options) || "italic"; + if (variant !== defaultVariant[node.type]) { + node.setAttribute("mathvariant", variant); + } + return node; + }, +}); + +defineFunctionBuilders({ + type: "textord", + htmlBuilder(group, options) { + return makeOrd(group, options, "textord"); + }, + mathmlBuilder(group: ParseNode<"textord">, options) { + const text = mml.makeText(group.text, group.mode, options); + const variant = mml.getVariant(group, options) || "normal"; + + let node; + if (group.mode === 'text') { + node = new MathNode("mtext", [text]); + } else if (/[0-9]/.test(group.text)) { + node = new MathNode("mn", [text]); + } else if (group.text === "\\prime") { + node = new MathNode("mo", [text]); + } else { + node = new MathNode("mi", [text]); + } + if (variant !== defaultVariant[node.type]) { + node.setAttribute("mathvariant", variant); + } + + return node; + }, +}); diff --git a/node_modules/react-katex/node_modules/katex/src/functions/symbolsSpacing.ts b/node_modules/react-katex/node_modules/katex/src/functions/symbolsSpacing.ts new file mode 100644 index 0000000..9cfb2cd --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/functions/symbolsSpacing.ts @@ -0,0 +1,72 @@ +import {defineFunctionBuilders} from "../defineFunction"; +import {mathsym, makeOrd, makeSpan} from "../buildCommon"; +import {MathNode, TextNode} from "../mathMLTree"; +import ParseError from "../ParseError"; + +// A map of CSS-based spacing functions to their CSS class. +const cssSpace: Record = { + "\\nobreak": "nobreak", + "\\allowbreak": "allowbreak", +}; + +// A lookup table to determine whether a spacing function/symbol should be +// treated like a regular space character. If a symbol or command is a key +// in this table, then it should be a regular space character. Furthermore, +// the associated value may have a `className` specifying an extra CSS class +// to add to the created `span`. +const regularSpace: Record = { + " ": {}, + "\\ ": {}, + "~": { + className: "nobreak", + }, + "\\space": {}, + "\\nobreakspace": { + className: "nobreak", + }, +}; + +// ParseNode<"spacing"> created in Parser.js from the "spacing" symbol Groups in +// src/symbols.js. +defineFunctionBuilders({ + type: "spacing", + htmlBuilder(group, options) { + if (regularSpace.hasOwnProperty(group.text)) { + const className = regularSpace[group.text].className || ""; + // Spaces are generated by adding an actual space. Each of these + // things has an entry in the symbols table, so these will be turned + // into appropriate outputs. + if (group.mode === "text") { + const ord = makeOrd(group, options, "textord"); + ord.classes.push(className); + return ord; + } else { + return makeSpan(["mspace", className], + [mathsym(group.text, group.mode, options)], + options); + } + } else if (cssSpace.hasOwnProperty(group.text)) { + // Spaces based on just a CSS class. + return makeSpan( + ["mspace", cssSpace[group.text]], + [], options); + } else { + throw new ParseError(`Unknown type of space "${group.text}"`); + } + }, + mathmlBuilder(group, options) { + let node; + + if (regularSpace.hasOwnProperty(group.text)) { + node = new MathNode( + "mtext", [new TextNode("\u00a0")]); + } else if (cssSpace.hasOwnProperty(group.text)) { + // CSS-based MathML spaces (\nobreak, \allowbreak) are ignored + return new MathNode("mspace"); + } else { + throw new ParseError(`Unknown type of space "${group.text}"`); + } + + return node; + }, +}); diff --git a/node_modules/react-katex/node_modules/katex/src/functions/tag.ts b/node_modules/react-katex/node_modules/katex/src/functions/tag.ts new file mode 100644 index 0000000..9803a82 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/functions/tag.ts @@ -0,0 +1,38 @@ +import {defineFunctionBuilders} from "../defineFunction"; +import {MathNode} from "../mathMLTree"; + +import * as mml from "../buildMathML"; + +const pad = () => { + const padNode = new MathNode("mtd", []); + padNode.setAttribute("width", "50%"); + return padNode; +}; + +defineFunctionBuilders({ + type: "tag", + mathmlBuilder(group, options) { + const table = new MathNode("mtable", [ + new MathNode("mtr", [ + pad(), + new MathNode("mtd", [ + mml.buildExpressionRow(group.body, options), + ]), + pad(), + new MathNode("mtd", [ + mml.buildExpressionRow(group.tag, options), + ]), + ]), + ]); + table.setAttribute("width", "100%"); + return table; + + // TODO: Left-aligned tags. + // Currently, the group and options passed here do not contain + // enough info to set tag alignment. `leqno` is in Settings but it is + // not passed to Options. On the HTML side, leqno is + // set by a CSS class applied in buildTree.js. That would have worked + // in MathML if browsers supported . Since they don't, we + // need to rewrite the way this function is called. + }, +}); diff --git a/node_modules/react-katex/node_modules/katex/src/functions/text.ts b/node_modules/react-katex/node_modules/katex/src/functions/text.ts new file mode 100644 index 0000000..8642dfb --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/functions/text.ts @@ -0,0 +1,81 @@ +import defineFunction, {ordargument} from "../defineFunction"; +import type {TextFont} from "../types/fonts"; +import {makeSpan} from "../buildCommon"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; +import type Options from "../Options"; +import type {ParseNode} from "../parseNode"; + +// Non-mathy text, possibly in a font +const textFontFamilies: Record = { + "\\text": undefined, + "\\textrm": "textrm", + "\\textsf": "textsf", + "\\texttt": "texttt", + "\\textnormal": "textrm", +}; + +const textFontWeights: Record = { + "\\textbf": "textbf", + "\\textmd": "textmd", +}; + +const textFontShapes: Record = { + "\\textit": "textit", + "\\textup": "textup", +}; + +const optionsWithFont = (group: ParseNode<"text">, options: Options): Options => { + const font = group.font; + // Checks if the argument is a font family or a font style. + if (!font) { + return options; + } else if (textFontFamilies[font]) { + return options.withTextFontFamily(textFontFamilies[font]); + } else if (textFontWeights[font]) { + return options.withTextFontWeight(textFontWeights[font]); + } else if (font === "\\emph") { + return options.fontShape === "textit" ? + options.withTextFontShape("textup") : + options.withTextFontShape("textit"); + } + + return options.withTextFontShape(textFontShapes[font] as "textit" | "textup"); +}; + +defineFunction({ + type: "text", + names: [ + // Font families + "\\text", "\\textrm", "\\textsf", "\\texttt", "\\textnormal", + // Font weights + "\\textbf", "\\textmd", + // Font Shapes + "\\textit", "\\textup", "\\emph", + ], + props: { + numArgs: 1, + argTypes: ["text"], + allowedInArgument: true, + allowedInText: true, + }, + handler({parser, funcName}, args) { + const body = args[0]; + return { + type: "text", + mode: parser.mode, + body: ordargument(body), + font: funcName, + }; + }, + htmlBuilder(group, options) { + const newOptions = optionsWithFont(group, options); + const inner = html.buildExpression(group.body, newOptions, true); + return makeSpan(["mord", "text"], inner, newOptions); + }, + mathmlBuilder(group, options) { + const newOptions = optionsWithFont(group, options); + return mml.buildExpressionRow(group.body, newOptions); + }, +}); diff --git a/node_modules/react-katex/node_modules/katex/src/functions/underline.ts b/node_modules/react-katex/node_modules/katex/src/functions/underline.ts new file mode 100644 index 0000000..8a12cfb --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/functions/underline.ts @@ -0,0 +1,57 @@ +import defineFunction from "../defineFunction"; +import {makeLineSpan, makeSpan, makeVList} from "../buildCommon"; +import {MathNode, TextNode} from "../mathMLTree"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; + +defineFunction({ + type: "underline", + names: ["\\underline"], + props: { + numArgs: 1, + allowedInText: true, + }, + handler({parser}, args) { + return { + type: "underline", + mode: parser.mode, + body: args[0], + }; + }, + htmlBuilder(group, options) { + // Underlines are handled in the TeXbook pg 443, Rule 10. + // Build the inner group. + const innerGroup = html.buildGroup(group.body, options); + + // Create the line to go below the body + const line = makeLineSpan("underline-line", options); + + // Generate the vlist, with the appropriate kerns + const defaultRuleThickness = options.fontMetrics().defaultRuleThickness; + const vlist = makeVList({ + positionType: "top", + positionData: innerGroup.height, + children: [ + {type: "kern", size: defaultRuleThickness}, + {type: "elem", elem: line}, + {type: "kern", size: 3 * defaultRuleThickness}, + {type: "elem", elem: innerGroup}, + ], + }, options); + + return makeSpan(["mord", "underline"], [vlist], options); + }, + mathmlBuilder(group, options) { + const operator = new MathNode( + "mo", [new TextNode("\u203e")]); + operator.setAttribute("stretchy", "true"); + + const node = new MathNode( + "munder", + [mml.buildGroup(group.body, options), operator]); + node.setAttribute("accentunder", "true"); + + return node; + }, +}); diff --git a/node_modules/react-katex/node_modules/katex/src/functions/utils/assembleSupSub.ts b/node_modules/react-katex/node_modules/katex/src/functions/utils/assembleSupSub.ts new file mode 100644 index 0000000..5523b24 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/functions/utils/assembleSupSub.ts @@ -0,0 +1,119 @@ +import {makeSpan, makeVList} from "../../buildCommon"; +import * as html from "../../buildHTML"; +import {isCharacterBox} from "../../utils"; +import type {StyleInterface} from "../../Style"; +import type Options from "../../Options"; +import type {DomSpan, SymbolNode} from "../../domTree"; +import type {AnyParseNode} from "../../parseNode"; +import {makeEm} from "../../units"; + +// For an operator with limits, assemble the base, sup, and sub into a span. + +export const assembleSupSub = ( + base: DomSpan | SymbolNode, + supGroup: AnyParseNode | null | undefined, + subGroup: AnyParseNode | null | undefined, + options: Options, + style: StyleInterface, + slant: number, + baseShift: number, +): DomSpan => { + base = makeSpan([], [base]); + const subIsSingleCharacter = subGroup && isCharacterBox(subGroup); + let sub; + let sup; + // We manually have to handle the superscripts and subscripts. This, + // aside from the kern calculations, is copied from supsub. + if (supGroup) { + const elem = html.buildGroup( + supGroup, options.havingStyle(style.sup()), options); + + sup = { + elem, + kern: Math.max( + options.fontMetrics().bigOpSpacing1, + options.fontMetrics().bigOpSpacing3 - elem.depth), + }; + } + + if (subGroup) { + const elem = html.buildGroup( + subGroup, options.havingStyle(style.sub()), options); + + sub = { + elem, + kern: Math.max( + options.fontMetrics().bigOpSpacing2, + options.fontMetrics().bigOpSpacing4 - elem.height), + }; + } + + // Build the final group as a vlist of the possible subscript, base, + // and possible superscript. + let finalGroup; + if (sup && sub) { + const bottom = options.fontMetrics().bigOpSpacing5 + + sub.elem.height + sub.elem.depth + + sub.kern + + base.depth + baseShift; + + finalGroup = makeVList({ + positionType: "bottom", + positionData: bottom, + children: [ + {type: "kern", size: options.fontMetrics().bigOpSpacing5}, + {type: "elem", elem: sub.elem, marginLeft: makeEm(-slant)}, + {type: "kern", size: sub.kern}, + {type: "elem", elem: base}, + {type: "kern", size: sup.kern}, + {type: "elem", elem: sup.elem, marginLeft: makeEm(slant)}, + {type: "kern", size: options.fontMetrics().bigOpSpacing5}, + ], + }, options); + } else if (sub) { + const top = base.height - baseShift; + + // Shift the limits by the slant of the symbol. Note + // that we are supposed to shift the limits by 1/2 of the slant, + // but since we are centering the limits adding a full slant of + // margin will shift by 1/2 that. + finalGroup = makeVList({ + positionType: "top", + positionData: top, + children: [ + {type: "kern", size: options.fontMetrics().bigOpSpacing5}, + {type: "elem", elem: sub.elem, marginLeft: makeEm(-slant)}, + {type: "kern", size: sub.kern}, + {type: "elem", elem: base}, + ], + }, options); + } else if (sup) { + const bottom = base.depth + baseShift; + + finalGroup = makeVList({ + positionType: "bottom", + positionData: bottom, + children: [ + {type: "elem", elem: base}, + {type: "kern", size: sup.kern}, + {type: "elem", elem: sup.elem, marginLeft: makeEm(slant)}, + {type: "kern", size: options.fontMetrics().bigOpSpacing5}, + ], + }, options); + } else { + // This case probably shouldn't occur (this would mean the + // supsub was sending us a group with no superscript or + // subscript) but be safe. + return base; + } + + const parts = [finalGroup]; + if (sub && slant !== 0 && !subIsSingleCharacter) { + // A negative margin-left was applied to the lower limit. + // Avoid an overlap by placing a spacer on the left on the group. + const spacer = makeSpan(["mspace"], [], options); + spacer.style.marginRight = makeEm(slant); + parts.unshift(spacer); + } + return makeSpan(["mop", "op-limits"], parts, options); +}; diff --git a/node_modules/react-katex/node_modules/katex/src/functions/vcenter.ts b/node_modules/react-katex/node_modules/katex/src/functions/vcenter.ts new file mode 100644 index 0000000..171f0ab --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/functions/vcenter.ts @@ -0,0 +1,44 @@ +import defineFunction from "../defineFunction"; +import {makeVList} from "../buildCommon"; +import {MathNode} from "../mathMLTree"; + +import * as html from "../buildHTML"; +import * as mml from "../buildMathML"; + +// \vcenter: Vertically center the argument group on the math axis. + +defineFunction({ + type: "vcenter", + names: ["\\vcenter"], + props: { + numArgs: 1, + argTypes: ["original"], // In LaTeX, \vcenter can act only on a box. + allowedInText: false, + }, + handler({parser}, args) { + return { + type: "vcenter", + mode: parser.mode, + body: args[0], + }; + }, + htmlBuilder(group, options) { + const body = html.buildGroup(group.body, options); + const axisHeight = options.fontMetrics().axisHeight; + const dy = 0.5 * ((body.height - axisHeight) - (body.depth + axisHeight)); + return makeVList({ + positionType: "shift", + positionData: dy, + children: [{type: "elem", elem: body}], + }, options); + }, + mathmlBuilder(group, options) { + // There is no way to do this in MathML. + // Write a class as a breadcrumb in case some post-processor wants + // to perform a vcenter adjustment. + // Wrap in mrow to ensure valid MathML when placed inside mo (e.g., \mathrel) + const mpadded = new MathNode( + "mpadded", [mml.buildGroup(group.body, options)], ["vcenter"]); + return new MathNode("mrow", [mpadded]); + }, +}); diff --git a/node_modules/react-katex/node_modules/katex/src/functions/verb.ts b/node_modules/react-katex/node_modules/katex/src/functions/verb.ts new file mode 100644 index 0000000..46fa0d2 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/functions/verb.ts @@ -0,0 +1,57 @@ +import defineFunction from "../defineFunction"; +import {makeSpan, makeSymbol, tryCombineChars} from "../buildCommon"; +import {MathNode, TextNode} from "../mathMLTree"; +import ParseError from "../ParseError"; + +import type {ParseNode} from "../parseNode"; + +defineFunction({ + type: "verb", + names: ["\\verb"], + props: { + numArgs: 0, + allowedInText: true, + }, + handler(context, args, optArgs) { + // \verb and \verb* are dealt with directly in Parser.js. + // If we end up here, it's because of a failure to match the two delimiters + // in the regex in Lexer.js. LaTeX raises the following error when \verb is + // terminated by end of line (or file). + throw new ParseError( + "\\verb ended by end of line instead of matching delimiter"); + }, + htmlBuilder(group, options) { + const text = makeVerb(group); + const body = []; + // \verb enters text mode and therefore is sized like \textstyle + const newOptions = options.havingStyle(options.style.text()); + for (let i = 0; i < text.length; i++) { + let c = text[i]; + if (c === '~') { + c = '\\textasciitilde'; + } + body.push(makeSymbol(c, "Typewriter-Regular", + group.mode, newOptions, ["mord", "texttt"])); + } + return makeSpan( + ["mord", "text"].concat(newOptions.sizingClasses(options)), + tryCombineChars(body), + newOptions, + ); + }, + mathmlBuilder(group, options) { + const text = new TextNode(makeVerb(group)); + const node = new MathNode("mtext", [text]); + node.setAttribute("mathvariant", "monospace"); + return node; + }, +}); + +/** + * Converts verb group into body string. + * + * \verb* replaces each space with an open box \u2423 + * \verb replaces each space with a no-break space \xA0 + */ +const makeVerb = (group: ParseNode<"verb">): string => + group.body.replace(/ /g, group.star ? '\u2423' : '\xA0'); diff --git a/node_modules/react-katex/node_modules/katex/src/macros.ts b/node_modules/react-katex/node_modules/katex/src/macros.ts new file mode 100644 index 0000000..f714f9e --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/macros.ts @@ -0,0 +1,1032 @@ +/** + * Predefined macros for KaTeX. + * This can be used to define some commands in terms of others. + */ + +// Export global macros object from defineMacro +import defineMacro, {_macros} from "./defineMacro"; +const macros = _macros; +export default macros; + +import fontMetricsData from "./fontMetricsData"; +import functions from "./functions"; +import symbols from "./symbols"; +import {makeEm} from "./units"; +import ParseError from "./ParseError"; + +import type {MacroContextInterface} from "./defineMacro"; + +////////////////////////////////////////////////////////////////////// +// macro tools + +defineMacro("\\noexpand", function(context) { + // The expansion is the token itself; but that token is interpreted + // as if its meaning were ‘\relax’ if it is a control sequence that + // would ordinarily be expanded by TeX’s expansion rules. + const t = context.popToken(); + if (context.isExpandable(t.text)) { + t.noexpand = true; + t.treatAsRelax = true; + } + return {tokens: [t], numArgs: 0}; +}); + +defineMacro("\\expandafter", function(context) { + // TeX first reads the token that comes immediately after \expandafter, + // without expanding it; let’s call this token t. Then TeX reads the + // token that comes after t (and possibly more tokens, if that token + // has an argument), replacing it by its expansion. Finally TeX puts + // t back in front of that expansion. + const t = context.popToken(); + context.expandOnce(true); // expand only an expandable token + return {tokens: [t], numArgs: 0}; +}); + +// LaTeX's \@firstoftwo{#1}{#2} expands to #1, skipping #2 +// TeX source: \long\def\@firstoftwo#1#2{#1} +defineMacro("\\@firstoftwo", function(context) { + const args = context.consumeArgs(2); + return {tokens: args[0], numArgs: 0}; +}); + +// LaTeX's \@secondoftwo{#1}{#2} expands to #2, skipping #1 +// TeX source: \long\def\@secondoftwo#1#2{#2} +defineMacro("\\@secondoftwo", function(context) { + const args = context.consumeArgs(2); + return {tokens: args[1], numArgs: 0}; +}); + +// LaTeX's \@ifnextchar{#1}{#2}{#3} looks ahead to the next (unexpanded) +// symbol that isn't a space, consuming any spaces but not consuming the +// first nonspace character. If that nonspace character matches #1, then +// the macro expands to #2; otherwise, it expands to #3. +defineMacro("\\@ifnextchar", function(context) { + const args = context.consumeArgs(3); // symbol, if, else + context.consumeSpaces(); + const nextToken = context.future(); + if (args[0].length === 1 && args[0][0].text === nextToken.text) { + return {tokens: args[1], numArgs: 0}; + } else { + return {tokens: args[2], numArgs: 0}; + } +}); + +// LaTeX's \@ifstar{#1}{#2} looks ahead to the next (unexpanded) symbol. +// If it is `*`, then it consumes the symbol, and the macro expands to #1; +// otherwise, the macro expands to #2 (without consuming the symbol). +// TeX source: \def\@ifstar#1{\@ifnextchar *{\@firstoftwo{#1}}} +defineMacro("\\@ifstar", "\\@ifnextchar *{\\@firstoftwo{#1}}"); + +// LaTeX's \TextOrMath{#1}{#2} expands to #1 in text mode, #2 in math mode +defineMacro("\\TextOrMath", function(context) { + const args = context.consumeArgs(2); + if (context.mode === 'text') { + return {tokens: args[0], numArgs: 0}; + } else { + return {tokens: args[1], numArgs: 0}; + } +}); + +// Lookup table for parsing numbers in base 8 through 16 +const digitToNumber: Record = { + "0": 0, "1": 1, "2": 2, "3": 3, "4": 4, "5": 5, "6": 6, "7": 7, "8": 8, + "9": 9, "a": 10, "A": 10, "b": 11, "B": 11, "c": 12, "C": 12, + "d": 13, "D": 13, "e": 14, "E": 14, "f": 15, "F": 15, +}; + +// TeX \char makes a literal character (catcode 12) using the following forms: +// (see The TeXBook, p. 43) +// \char123 -- decimal +// \char'123 -- octal +// \char"123 -- hex +// \char`x -- character that can be written (i.e. isn't active) +// \char`\x -- character that cannot be written (e.g. %) +// These all refer to characters from the font, so we turn them into special +// calls to a function \@char dealt with in the Parser. +defineMacro("\\char", function(context) { + let token = context.popToken(); + let base; + let number = 0; + if (token.text === "'") { + base = 8; + token = context.popToken(); + } else if (token.text === '"') { + base = 16; + token = context.popToken(); + } else if (token.text === "`") { + token = context.popToken(); + if (token.text[0] === "\\") { + number = token.text.charCodeAt(1); + } else if (token.text === "EOF") { + throw new ParseError("\\char` missing argument"); + } else { + number = token.text.charCodeAt(0); + } + } else { + base = 10; + } + if (base) { + // Parse a number in the given base, starting with first `token`. + number = digitToNumber[token.text]; + if (number == null || number >= base) { + throw new ParseError(`Invalid base-${base} digit ${token.text}`); + } + let digit; + while ((digit = digitToNumber[context.future().text]) != null && + digit < base) { + number *= base; + number += digit; + context.popToken(); + } + } + return `\\@char{${number}}`; +}); + +// \newcommand{\macro}[args]{definition} +// \renewcommand{\macro}[args]{definition} +// TODO: Optional arguments: \newcommand{\macro}[args][default]{definition} +const newcommand = ( + context: MacroContextInterface, + existsOK: boolean, + nonexistsOK: boolean, + skipIfExists: boolean, +) => { + let arg = context.consumeArg().tokens; + if (arg.length !== 1) { + throw new ParseError( + "\\newcommand's first argument must be a macro name"); + } + const name = arg[0].text; + + const exists = context.isDefined(name); + if (exists && !existsOK) { + throw new ParseError(`\\newcommand{${name}} attempting to redefine ` + + `${name}; use \\renewcommand`); + } + if (!exists && !nonexistsOK) { + throw new ParseError(`\\renewcommand{${name}} when command ${name} ` + + `does not yet exist; use \\newcommand`); + } + + let numArgs = 0; + arg = context.consumeArg().tokens; + if (arg.length === 1 && arg[0].text === "[") { + let argText = ''; + let token = context.expandNextToken(); + while (token.text !== "]" && token.text !== "EOF") { + // TODO: Should properly expand arg, e.g., ignore {}s + argText += token.text; + token = context.expandNextToken(); + } + if (!argText.match(/^\s*[0-9]+\s*$/)) { + throw new ParseError(`Invalid number of arguments: ${argText}`); + } + numArgs = parseInt(argText); + arg = context.consumeArg().tokens; + } + + if (!(exists && skipIfExists)) { + // Final arg is the expansion of the macro + context.macros.set(name, { + tokens: arg, + numArgs, + }); + } + return ''; +}; +defineMacro("\\newcommand", + (context) => newcommand(context, false, true, false)); +defineMacro("\\renewcommand", + (context) => newcommand(context, true, false, false)); +defineMacro("\\providecommand", + (context) => newcommand(context, true, true, true)); + +// terminal (console) tools +defineMacro("\\message", (context) => { + const arg = context.consumeArgs(1)[0]; + // eslint-disable-next-line no-console + console.log(arg.reverse().map(token => token.text).join("")); + return ''; +}); +defineMacro("\\errmessage", (context) => { + const arg = context.consumeArgs(1)[0]; + // eslint-disable-next-line no-console + console.error(arg.reverse().map(token => token.text).join("")); + return ''; +}); +defineMacro("\\show", (context) => { + const tok = context.popToken(); + const name = tok.text; + // eslint-disable-next-line no-console + console.log(tok, context.macros.get(name), functions[name], + symbols.math[name], symbols.text[name]); + return ''; +}); + +////////////////////////////////////////////////////////////////////// +// Grouping +// \let\bgroup={ \let\egroup=} +defineMacro("\\bgroup", "{"); +defineMacro("\\egroup", "}"); + +// Symbols from latex.ltx: +// \def~{\nobreakspace{}} +// \def\lq{`} +// \def\rq{'} +// \def \aa {\r a} +// \def \AA {\r A} +defineMacro("~", "\\nobreakspace"); +defineMacro("\\lq", "`"); +defineMacro("\\rq", "'"); +defineMacro("\\aa", "\\r a"); +defineMacro("\\AA", "\\r A"); + +// Copyright (C) and registered (R) symbols. Use raw symbol in MathML. +// \DeclareTextCommandDefault{\textcopyright}{\textcircled{c}} +// \DeclareTextCommandDefault{\textregistered}{\textcircled{% +// \check@mathfonts\fontsize\sf@size\z@\math@fontsfalse\selectfont R}} +// \DeclareRobustCommand{\copyright}{% +// \ifmmode{\nfss@text{\textcopyright}}\else\textcopyright\fi} +defineMacro("\\textcopyright", "\\html@mathml{\\textcircled{c}}{\\char`©}"); +defineMacro("\\copyright", + "\\TextOrMath{\\textcopyright}{\\text{\\textcopyright}}"); +defineMacro("\\textregistered", + "\\html@mathml{\\textcircled{\\scriptsize R}}{\\char`®}"); + +// Characters omitted from Unicode range 1D400–1D7FF +defineMacro("\u212C", "\\mathscr{B}"); // script +defineMacro("\u2130", "\\mathscr{E}"); +defineMacro("\u2131", "\\mathscr{F}"); +defineMacro("\u210B", "\\mathscr{H}"); +defineMacro("\u2110", "\\mathscr{I}"); +defineMacro("\u2112", "\\mathscr{L}"); +defineMacro("\u2133", "\\mathscr{M}"); +defineMacro("\u211B", "\\mathscr{R}"); +defineMacro("\u212D", "\\mathfrak{C}"); // Fraktur +defineMacro("\u210C", "\\mathfrak{H}"); +defineMacro("\u2128", "\\mathfrak{Z}"); + +// Define \Bbbk with a macro that works in both HTML and MathML. +defineMacro("\\Bbbk", "\\Bbb{k}"); + +// \llap and \rlap render their contents in text mode +defineMacro("\\llap", "\\mathllap{\\textrm{#1}}"); +defineMacro("\\rlap", "\\mathrlap{\\textrm{#1}}"); +defineMacro("\\clap", "\\mathclap{\\textrm{#1}}"); + +// \mathstrut from the TeXbook, p 360 +defineMacro("\\mathstrut", "\\vphantom{(}"); + +// \underbar from TeXbook p 353 +defineMacro("\\underbar", "\\underline{\\text{#1}}"); + +// \not is defined by base/fontmath.ltx via +// \DeclareMathSymbol{\not}{\mathrel}{symbols}{"36} +// It's thus treated like a \mathrel, but defined by a symbol that has zero +// width but extends to the right. We use \rlap to get that spacing. +// For MathML we write U+0338 here. buildMathML.js will then do the overlay. +defineMacro("\\not", "\\html@mathml{\\mathrel{\\mathrlap\\@not}\\nobreak}" + + "{\\char\"338}"); + +// Negated symbols from base/fontmath.ltx: +// \def\neq{\not=} \let\ne=\neq +// \DeclareRobustCommand +// \notin{\mathrel{\m@th\mathpalette\c@ncel\in}} +// \def\c@ncel#1#2{\m@th\ooalign{$\hfil#1\mkern1mu/\hfil$\crcr$#1#2$}} +defineMacro("\\neq", "\\html@mathml{\\mathrel{\\not=}}{\\mathrel{\\char`≠}}"); +defineMacro("\\ne", "\\neq"); +defineMacro("\u2260", "\\neq"); +defineMacro("\\notin", "\\html@mathml{\\mathrel{{\\in}\\mathllap{/\\mskip1mu}}}" + + "{\\mathrel{\\char`∉}}"); +defineMacro("\u2209", "\\notin"); + +// Unicode stacked relations +defineMacro("\u2258", "\\html@mathml{" + + "\\mathrel{=\\kern{-1em}\\raisebox{0.4em}{$\\scriptsize\\frown$}}" + + "}{\\mathrel{\\char`\u2258}}"); +defineMacro("\u2259", + "\\html@mathml{\\stackrel{\\tiny\\wedge}{=}}{\\mathrel{\\char`\u2258}}"); +defineMacro("\u225A", + "\\html@mathml{\\stackrel{\\tiny\\vee}{=}}{\\mathrel{\\char`\u225A}}"); +defineMacro("\u225B", + "\\html@mathml{\\stackrel{\\scriptsize\\star}{=}}" + + "{\\mathrel{\\char`\u225B}}"); +defineMacro("\u225D", + "\\html@mathml{\\stackrel{\\tiny\\mathrm{def}}{=}}" + + "{\\mathrel{\\char`\u225D}}"); +defineMacro("\u225E", + "\\html@mathml{\\stackrel{\\tiny\\mathrm{m}}{=}}" + + "{\\mathrel{\\char`\u225E}}"); +defineMacro("\u225F", + "\\html@mathml{\\stackrel{\\tiny?}{=}}{\\mathrel{\\char`\u225F}}"); + +// Misc Unicode +defineMacro("\u27C2", "\\perp"); +defineMacro("\u203C", "\\mathclose{!\\mkern-0.8mu!}"); +defineMacro("\u220C", "\\notni"); +defineMacro("\u231C", "\\ulcorner"); +defineMacro("\u231D", "\\urcorner"); +defineMacro("\u231E", "\\llcorner"); +defineMacro("\u231F", "\\lrcorner"); +defineMacro("\u00A9", "\\copyright"); +defineMacro("\u00AE", "\\textregistered"); + +// The KaTeX fonts have corners at codepoints that don't match Unicode. +// For MathML purposes, use the Unicode code point. +defineMacro("\\ulcorner", "\\html@mathml{\\@ulcorner}{\\mathop{\\char\"231c}}"); +defineMacro("\\urcorner", "\\html@mathml{\\@urcorner}{\\mathop{\\char\"231d}}"); +defineMacro("\\llcorner", "\\html@mathml{\\@llcorner}{\\mathop{\\char\"231e}}"); +defineMacro("\\lrcorner", "\\html@mathml{\\@lrcorner}{\\mathop{\\char\"231f}}"); + +////////////////////////////////////////////////////////////////////// +// LaTeX_2ε + +// \vdots{\vbox{\baselineskip4\p@ \lineskiplimit\z@ +// \kern6\p@\hbox{.}\hbox{.}\hbox{.}}} +// We'll call \varvdots, which gets a glyph from symbols.js. +// The zero-width rule gets us an equivalent to the vertical 6pt kern. +defineMacro("\\vdots", "{\\varvdots\\rule{0pt}{15pt}}"); +defineMacro("\u22ee", "\\vdots"); + +////////////////////////////////////////////////////////////////////// +// amsmath.sty +// http://mirrors.concertpass.com/tex-archive/macros/latex/required/amsmath/amsmath.pdf + +// Italic Greek capital letters. AMS defines these with \DeclareMathSymbol, +// but they are equivalent to \mathit{\Letter}. +defineMacro("\\varGamma", "\\mathit{\\Gamma}"); +defineMacro("\\varDelta", "\\mathit{\\Delta}"); +defineMacro("\\varTheta", "\\mathit{\\Theta}"); +defineMacro("\\varLambda", "\\mathit{\\Lambda}"); +defineMacro("\\varXi", "\\mathit{\\Xi}"); +defineMacro("\\varPi", "\\mathit{\\Pi}"); +defineMacro("\\varSigma", "\\mathit{\\Sigma}"); +defineMacro("\\varUpsilon", "\\mathit{\\Upsilon}"); +defineMacro("\\varPhi", "\\mathit{\\Phi}"); +defineMacro("\\varPsi", "\\mathit{\\Psi}"); +defineMacro("\\varOmega", "\\mathit{\\Omega}"); + +//\newcommand{\substack}[1]{\subarray{c}#1\endsubarray} +defineMacro("\\substack", "\\begin{subarray}{c}#1\\end{subarray}"); + +// \renewcommand{\colon}{\nobreak\mskip2mu\mathpunct{}\nonscript +// \mkern-\thinmuskip{:}\mskip6muplus1mu\relax} +defineMacro("\\colon", "\\nobreak\\mskip2mu\\mathpunct{}" + + "\\mathchoice{\\mkern-3mu}{\\mkern-3mu}{}{}{:}\\mskip6mu\\relax"); + +// \newcommand{\boxed}[1]{\fbox{\m@th$\displaystyle#1$}} +defineMacro("\\boxed", "\\fbox{$\\displaystyle{#1}$}"); + +// \def\iff{\DOTSB\;\Longleftrightarrow\;} +// \def\implies{\DOTSB\;\Longrightarrow\;} +// \def\impliedby{\DOTSB\;\Longleftarrow\;} +defineMacro("\\iff", "\\DOTSB\\;\\Longleftrightarrow\\;"); +defineMacro("\\implies", "\\DOTSB\\;\\Longrightarrow\\;"); +defineMacro("\\impliedby", "\\DOTSB\\;\\Longleftarrow\\;"); + +// \def\dddot#1{{\mathop{#1}\limits^{\vbox to-1.4\ex@{\kern-\tw@\ex@ +// \hbox{\normalfont ...}\vss}}}} +// We use \overset which avoids the vertical shift of \mathop. +defineMacro("\\dddot", "{\\overset{\\raisebox{-0.1ex}{\\normalsize ...}}{#1}}"); +defineMacro("\\ddddot", "{\\overset{\\raisebox{-0.1ex}{\\normalsize ....}}{#1}}"); + +// AMSMath's automatic \dots, based on \mdots@@ macro. +const dotsByToken: Record = { + ',': '\\dotsc', + '\\not': '\\dotsb', + // \keybin@ checks for the following: + '+': '\\dotsb', + '=': '\\dotsb', + '<': '\\dotsb', + '>': '\\dotsb', + '-': '\\dotsb', + '*': '\\dotsb', + ':': '\\dotsb', + // Symbols whose definition starts with \DOTSB: + '\\DOTSB': '\\dotsb', + '\\coprod': '\\dotsb', + '\\bigvee': '\\dotsb', + '\\bigwedge': '\\dotsb', + '\\biguplus': '\\dotsb', + '\\bigcap': '\\dotsb', + '\\bigcup': '\\dotsb', + '\\prod': '\\dotsb', + '\\sum': '\\dotsb', + '\\bigotimes': '\\dotsb', + '\\bigoplus': '\\dotsb', + '\\bigodot': '\\dotsb', + '\\bigsqcup': '\\dotsb', + '\\And': '\\dotsb', + '\\longrightarrow': '\\dotsb', + '\\Longrightarrow': '\\dotsb', + '\\longleftarrow': '\\dotsb', + '\\Longleftarrow': '\\dotsb', + '\\longleftrightarrow': '\\dotsb', + '\\Longleftrightarrow': '\\dotsb', + '\\mapsto': '\\dotsb', + '\\longmapsto': '\\dotsb', + '\\hookrightarrow': '\\dotsb', + '\\doteq': '\\dotsb', + // Symbols whose definition starts with \mathbin: + '\\mathbin': '\\dotsb', + // Symbols whose definition starts with \mathrel: + '\\mathrel': '\\dotsb', + '\\relbar': '\\dotsb', + '\\Relbar': '\\dotsb', + '\\xrightarrow': '\\dotsb', + '\\xleftarrow': '\\dotsb', + // Symbols whose definition starts with \DOTSI: + '\\DOTSI': '\\dotsi', + '\\int': '\\dotsi', + '\\oint': '\\dotsi', + '\\iint': '\\dotsi', + '\\iiint': '\\dotsi', + '\\iiiint': '\\dotsi', + '\\idotsint': '\\dotsi', + // Symbols whose definition starts with \DOTSX: + '\\DOTSX': '\\dotsx', +}; + +const dotsbGroups = new Set(['bin', 'rel']); + +defineMacro("\\dots", function(context) { + // TODO: If used in text mode, should expand to \textellipsis. + // However, in KaTeX, \textellipsis and \ldots behave the same + // (in text mode), and it's unlikely we'd see any of the math commands + // that affect the behavior of \dots when in text mode. So fine for now + // (until we support \ifmmode ... \else ... \fi). + let thedots = '\\dotso'; + const next = context.expandAfterFuture().text; + if (next in dotsByToken) { + thedots = dotsByToken[next]; + } else if (next.slice(0, 4) === '\\not') { + thedots = '\\dotsb'; + } else if (next in symbols.math) { + if (dotsbGroups.has(symbols.math[next].group)) { + thedots = '\\dotsb'; + } + } + return thedots; +}); + +const spaceAfterDots = { + // \rightdelim@ checks for the following: + ')': true, + ']': true, + '\\rbrack': true, + '\\}': true, + '\\rbrace': true, + '\\rangle': true, + '\\rceil': true, + '\\rfloor': true, + '\\rgroup': true, + '\\rmoustache': true, + '\\right': true, + '\\bigr': true, + '\\biggr': true, + '\\Bigr': true, + '\\Biggr': true, + // \extra@ also tests for the following: + '$': true, + // \extrap@ checks for the following: + ';': true, + '.': true, + ',': true, +}; + +defineMacro("\\dotso", function(context) { + const next = context.future().text; + if (next in spaceAfterDots) { + return "\\ldots\\,"; + } else { + return "\\ldots"; + } +}); + +defineMacro("\\dotsc", function(context) { + const next = context.future().text; + // \dotsc uses \extra@ but not \extrap@, instead specially checking for + // ';' and '.', but doesn't check for ','. + if (next in spaceAfterDots && next !== ',') { + return "\\ldots\\,"; + } else { + return "\\ldots"; + } +}); + +defineMacro("\\cdots", function(context) { + const next = context.future().text; + if (next in spaceAfterDots) { + return "\\@cdots\\,"; + } else { + return "\\@cdots"; + } +}); + +defineMacro("\\dotsb", "\\cdots"); +defineMacro("\\dotsm", "\\cdots"); +defineMacro("\\dotsi", "\\!\\cdots"); +// amsmath doesn't actually define \dotsx, but \dots followed by a macro +// starting with \DOTSX implies \dotso, and then \extra@ detects this case +// and forces the added `\,`. +defineMacro("\\dotsx", "\\ldots\\,"); + +// \let\DOTSI\relax +// \let\DOTSB\relax +// \let\DOTSX\relax +defineMacro("\\DOTSI", "\\relax"); +defineMacro("\\DOTSB", "\\relax"); +defineMacro("\\DOTSX", "\\relax"); + +// Spacing, based on amsmath.sty's override of LaTeX defaults +// \DeclareRobustCommand{\tmspace}[3]{% +// \ifmmode\mskip#1#2\else\kern#1#3\fi\relax} +defineMacro("\\tmspace", "\\TextOrMath{\\kern#1#3}{\\mskip#1#2}\\relax"); +// \renewcommand{\,}{\tmspace+\thinmuskip{.1667em}} +// TODO: math mode should use \thinmuskip +defineMacro("\\,", "\\tmspace+{3mu}{.1667em}"); +// \let\thinspace\, +defineMacro("\\thinspace", "\\,"); +// \def\>{\mskip\medmuskip} +// \renewcommand{\:}{\tmspace+\medmuskip{.2222em}} +// TODO: \> and math mode of \: should use \medmuskip = 4mu plus 2mu minus 4mu +defineMacro("\\>", "\\mskip{4mu}"); +defineMacro("\\:", "\\tmspace+{4mu}{.2222em}"); +// \let\medspace\: +defineMacro("\\medspace", "\\:"); +// \renewcommand{\;}{\tmspace+\thickmuskip{.2777em}} +// TODO: math mode should use \thickmuskip = 5mu plus 5mu +defineMacro("\\;", "\\tmspace+{5mu}{.2777em}"); +// \let\thickspace\; +defineMacro("\\thickspace", "\\;"); +// \renewcommand{\!}{\tmspace-\thinmuskip{.1667em}} +// TODO: math mode should use \thinmuskip +defineMacro("\\!", "\\tmspace-{3mu}{.1667em}"); +// \let\negthinspace\! +defineMacro("\\negthinspace", "\\!"); +// \newcommand{\negmedspace}{\tmspace-\medmuskip{.2222em}} +// TODO: math mode should use \medmuskip +defineMacro("\\negmedspace", "\\tmspace-{4mu}{.2222em}"); +// \newcommand{\negthickspace}{\tmspace-\thickmuskip{.2777em}} +// TODO: math mode should use \thickmuskip +defineMacro("\\negthickspace", "\\tmspace-{5mu}{.277em}"); +// \def\enspace{\kern.5em } +defineMacro("\\enspace", "\\kern.5em "); +// \def\enskip{\hskip.5em\relax} +defineMacro("\\enskip", "\\hskip.5em\\relax"); +// \def\quad{\hskip1em\relax} +defineMacro("\\quad", "\\hskip1em\\relax"); +// \def\qquad{\hskip2em\relax} +defineMacro("\\qquad", "\\hskip2em\\relax"); + +// \tag@in@display form of \tag +defineMacro("\\tag", "\\@ifstar\\tag@literal\\tag@paren"); +defineMacro("\\tag@paren", "\\tag@literal{({#1})}"); +defineMacro("\\tag@literal", (context) => { + if (context.macros.get("\\df@tag")) { + throw new ParseError("Multiple \\tag"); + } + return "\\gdef\\df@tag{\\text{#1}}"; +}); + +// \renewcommand{\bmod}{\nonscript\mskip-\medmuskip\mkern5mu\mathbin +// {\operator@font mod}\penalty900 +// \mkern5mu\nonscript\mskip-\medmuskip} +// \newcommand{\pod}[1]{\allowbreak +// \if@display\mkern18mu\else\mkern8mu\fi(#1)} +// \renewcommand{\pmod}[1]{\pod{{\operator@font mod}\mkern6mu#1}} +// \newcommand{\mod}[1]{\allowbreak\if@display\mkern18mu +// \else\mkern12mu\fi{\operator@font mod}\,\,#1} +// TODO: math mode should use \medmuskip = 4mu plus 2mu minus 4mu +defineMacro("\\bmod", + "\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}" + + "\\mathbin{\\rm mod}" + + "\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}"); +defineMacro("\\pod", "\\allowbreak" + + "\\mathchoice{\\mkern18mu}{\\mkern8mu}{\\mkern8mu}{\\mkern8mu}(#1)"); +defineMacro("\\pmod", "\\pod{{\\rm mod}\\mkern6mu#1}"); +defineMacro("\\mod", "\\allowbreak" + + "\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}" + + "{\\rm mod}\\,\\,#1"); + +////////////////////////////////////////////////////////////////////// +// LaTeX source2e + +// \expandafter\let\expandafter\@normalcr +// \csname\expandafter\@gobble\string\\ \endcsname +// \DeclareRobustCommand\newline{\@normalcr\relax} +defineMacro("\\newline", "\\\\\\relax"); + +// \def\TeX{T\kern-.1667em\lower.5ex\hbox{E}\kern-.125emX\@} +// TODO: Doesn't normally work in math mode because \@ fails. KaTeX doesn't +// support \@ yet, so that's omitted, and we add \text so that the result +// doesn't look funny in math mode. +defineMacro("\\TeX", "\\textrm{\\html@mathml{" + + "T\\kern-.1667em\\raisebox{-.5ex}{E}\\kern-.125emX" + + "}{TeX}}"); + +// \DeclareRobustCommand{\LaTeX}{L\kern-.36em% +// {\sbox\z@ T% +// \vbox to\ht\z@{\hbox{\check@mathfonts +// \fontsize\sf@size\z@ +// \math@fontsfalse\selectfont +// A}% +// \vss}% +// }% +// \kern-.15em% +// \TeX} +// This code aligns the top of the A with the T (from the perspective of TeX's +// boxes, though visually the A appears to extend above slightly). +// We compute the corresponding \raisebox when A is rendered in \normalsize +// \scriptstyle, which has a scale factor of 0.7 (see Options.js). +const latexRaiseA = makeEm(fontMetricsData['Main-Regular']["T".charCodeAt(0)][1] - + 0.7 * fontMetricsData['Main-Regular']["A".charCodeAt(0)][1]); +defineMacro("\\LaTeX", "\\textrm{\\html@mathml{" + + `L\\kern-.36em\\raisebox{${latexRaiseA}}{\\scriptstyle A}` + + "\\kern-.15em\\TeX}{LaTeX}}"); + +// New KaTeX logo based on tweaking LaTeX logo +defineMacro("\\KaTeX", "\\textrm{\\html@mathml{" + + `K\\kern-.17em\\raisebox{${latexRaiseA}}{\\scriptstyle A}` + + "\\kern-.15em\\TeX}{KaTeX}}"); + +// \DeclareRobustCommand\hspace{\@ifstar\@hspacer\@hspace} +// \def\@hspace#1{\hskip #1\relax} +// \def\@hspacer#1{\vrule \@width\z@\nobreak +// \hskip #1\hskip \z@skip} +defineMacro("\\hspace", "\\@ifstar\\@hspacer\\@hspace"); +defineMacro("\\@hspace", "\\hskip #1\\relax"); +defineMacro("\\@hspacer", "\\rule{0pt}{0pt}\\hskip #1\\relax"); + +////////////////////////////////////////////////////////////////////// +// mathtools.sty + +//\providecommand\ordinarycolon{:} +defineMacro("\\ordinarycolon", ":"); +//\def\vcentcolon{\mathrel{\mathop\ordinarycolon}} +//TODO(edemaine): Not yet centered. Fix via \raisebox or #726 +defineMacro("\\vcentcolon", "\\mathrel{\\mathop\\ordinarycolon}"); +// \providecommand*\dblcolon{\vcentcolon\mathrel{\mkern-.9mu}\vcentcolon} +defineMacro("\\dblcolon", "\\html@mathml{" + + "\\mathrel{\\vcentcolon\\mathrel{\\mkern-.9mu}\\vcentcolon}}" + + "{\\mathop{\\char\"2237}}"); +// \providecommand*\coloneqq{\vcentcolon\mathrel{\mkern-1.2mu}=} +defineMacro("\\coloneqq", "\\html@mathml{" + + "\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}=}}" + + "{\\mathop{\\char\"2254}}"); // ≔ +// \providecommand*\Coloneqq{\dblcolon\mathrel{\mkern-1.2mu}=} +defineMacro("\\Coloneqq", "\\html@mathml{" + + "\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}=}}" + + "{\\mathop{\\char\"2237\\char\"3d}}"); +// \providecommand*\coloneq{\vcentcolon\mathrel{\mkern-1.2mu}\mathrel{-}} +defineMacro("\\coloneq", "\\html@mathml{" + + "\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}" + + "{\\mathop{\\char\"3a\\char\"2212}}"); +// \providecommand*\Coloneq{\dblcolon\mathrel{\mkern-1.2mu}\mathrel{-}} +defineMacro("\\Coloneq", "\\html@mathml{" + + "\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}" + + "{\\mathop{\\char\"2237\\char\"2212}}"); +// \providecommand*\eqqcolon{=\mathrel{\mkern-1.2mu}\vcentcolon} +defineMacro("\\eqqcolon", "\\html@mathml{" + + "\\mathrel{=\\mathrel{\\mkern-1.2mu}\\vcentcolon}}" + + "{\\mathop{\\char\"2255}}"); // ≕ +// \providecommand*\Eqqcolon{=\mathrel{\mkern-1.2mu}\dblcolon} +defineMacro("\\Eqqcolon", "\\html@mathml{" + + "\\mathrel{=\\mathrel{\\mkern-1.2mu}\\dblcolon}}" + + "{\\mathop{\\char\"3d\\char\"2237}}"); +// \providecommand*\eqcolon{\mathrel{-}\mathrel{\mkern-1.2mu}\vcentcolon} +defineMacro("\\eqcolon", "\\html@mathml{" + + "\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\vcentcolon}}" + + "{\\mathop{\\char\"2239}}"); +// \providecommand*\Eqcolon{\mathrel{-}\mathrel{\mkern-1.2mu}\dblcolon} +defineMacro("\\Eqcolon", "\\html@mathml{" + + "\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\dblcolon}}" + + "{\\mathop{\\char\"2212\\char\"2237}}"); +// \providecommand*\colonapprox{\vcentcolon\mathrel{\mkern-1.2mu}\approx} +defineMacro("\\colonapprox", "\\html@mathml{" + + "\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\approx}}" + + "{\\mathop{\\char\"3a\\char\"2248}}"); +// \providecommand*\Colonapprox{\dblcolon\mathrel{\mkern-1.2mu}\approx} +defineMacro("\\Colonapprox", "\\html@mathml{" + + "\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\approx}}" + + "{\\mathop{\\char\"2237\\char\"2248}}"); +// \providecommand*\colonsim{\vcentcolon\mathrel{\mkern-1.2mu}\sim} +defineMacro("\\colonsim", "\\html@mathml{" + + "\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\sim}}" + + "{\\mathop{\\char\"3a\\char\"223c}}"); +// \providecommand*\Colonsim{\dblcolon\mathrel{\mkern-1.2mu}\sim} +defineMacro("\\Colonsim", "\\html@mathml{" + + "\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\sim}}" + + "{\\mathop{\\char\"2237\\char\"223c}}"); + +// Some Unicode characters are implemented with macros to mathtools functions. +defineMacro("\u2237", "\\dblcolon"); // :: +defineMacro("\u2239", "\\eqcolon"); // -: +defineMacro("\u2254", "\\coloneqq"); // := +defineMacro("\u2255", "\\eqqcolon"); // =: +defineMacro("\u2A74", "\\Coloneqq"); // ::= + +////////////////////////////////////////////////////////////////////// +// colonequals.sty + +// Alternate names for mathtools's macros: +defineMacro("\\ratio", "\\vcentcolon"); +defineMacro("\\coloncolon", "\\dblcolon"); +defineMacro("\\colonequals", "\\coloneqq"); +defineMacro("\\coloncolonequals", "\\Coloneqq"); +defineMacro("\\equalscolon", "\\eqqcolon"); +defineMacro("\\equalscoloncolon", "\\Eqqcolon"); +defineMacro("\\colonminus", "\\coloneq"); +defineMacro("\\coloncolonminus", "\\Coloneq"); +defineMacro("\\minuscolon", "\\eqcolon"); +defineMacro("\\minuscoloncolon", "\\Eqcolon"); +// \colonapprox name is same in mathtools and colonequals. +defineMacro("\\coloncolonapprox", "\\Colonapprox"); +// \colonsim name is same in mathtools and colonequals. +defineMacro("\\coloncolonsim", "\\Colonsim"); + +// Additional macros, implemented by analogy with mathtools definitions: +defineMacro("\\simcolon", + "\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\vcentcolon}"); +defineMacro("\\simcoloncolon", + "\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\dblcolon}"); +defineMacro("\\approxcolon", + "\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\vcentcolon}"); +defineMacro("\\approxcoloncolon", + "\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\dblcolon}"); + +// Present in newtxmath, pxfonts and txfonts +defineMacro("\\notni", "\\html@mathml{\\not\\ni}{\\mathrel{\\char`\u220C}}"); +defineMacro("\\limsup", "\\DOTSB\\operatorname*{lim\\,sup}"); +defineMacro("\\liminf", "\\DOTSB\\operatorname*{lim\\,inf}"); + +////////////////////////////////////////////////////////////////////// +// From amsopn.sty +defineMacro("\\injlim", "\\DOTSB\\operatorname*{inj\\,lim}"); +defineMacro("\\projlim", "\\DOTSB\\operatorname*{proj\\,lim}"); +defineMacro("\\varlimsup", "\\DOTSB\\operatorname*{\\overline{lim}}"); +defineMacro("\\varliminf", "\\DOTSB\\operatorname*{\\underline{lim}}"); +defineMacro("\\varinjlim", "\\DOTSB\\operatorname*{\\underrightarrow{lim}}"); +defineMacro("\\varprojlim", "\\DOTSB\\operatorname*{\\underleftarrow{lim}}"); + +////////////////////////////////////////////////////////////////////// +// MathML alternates for KaTeX glyphs in the Unicode private area +defineMacro("\\gvertneqq", "\\html@mathml{\\@gvertneqq}{\u2269}"); +defineMacro("\\lvertneqq", "\\html@mathml{\\@lvertneqq}{\u2268}"); +defineMacro("\\ngeqq", "\\html@mathml{\\@ngeqq}{\u2271}"); +defineMacro("\\ngeqslant", "\\html@mathml{\\@ngeqslant}{\u2271}"); +defineMacro("\\nleqq", "\\html@mathml{\\@nleqq}{\u2270}"); +defineMacro("\\nleqslant", "\\html@mathml{\\@nleqslant}{\u2270}"); +defineMacro("\\nshortmid", "\\html@mathml{\\@nshortmid}{∤}"); +defineMacro("\\nshortparallel", "\\html@mathml{\\@nshortparallel}{∦}"); +defineMacro("\\nsubseteqq", "\\html@mathml{\\@nsubseteqq}{\u2288}"); +defineMacro("\\nsupseteqq", "\\html@mathml{\\@nsupseteqq}{\u2289}"); +defineMacro("\\varsubsetneq", "\\html@mathml{\\@varsubsetneq}{⊊}"); +defineMacro("\\varsubsetneqq", "\\html@mathml{\\@varsubsetneqq}{⫋}"); +defineMacro("\\varsupsetneq", "\\html@mathml{\\@varsupsetneq}{⊋}"); +defineMacro("\\varsupsetneqq", "\\html@mathml{\\@varsupsetneqq}{⫌}"); +defineMacro("\\imath", "\\html@mathml{\\@imath}{\u0131}"); +defineMacro("\\jmath", "\\html@mathml{\\@jmath}{\u0237}"); + +////////////////////////////////////////////////////////////////////// +// stmaryrd and semantic + +// The stmaryrd and semantic packages render the next four items by calling a +// glyph. Those glyphs do not exist in the KaTeX fonts. Hence the macros. + +defineMacro("\\llbracket", "\\html@mathml{" + + "\\mathopen{[\\mkern-3.2mu[}}" + + "{\\mathopen{\\char`\u27e6}}"); +defineMacro("\\rrbracket", "\\html@mathml{" + + "\\mathclose{]\\mkern-3.2mu]}}" + + "{\\mathclose{\\char`\u27e7}}"); + +defineMacro("\u27e6", "\\llbracket"); // blackboard bold [ +defineMacro("\u27e7", "\\rrbracket"); // blackboard bold ] + +defineMacro("\\lBrace", "\\html@mathml{" + + "\\mathopen{\\{\\mkern-3.2mu[}}" + + "{\\mathopen{\\char`\u2983}}"); +defineMacro("\\rBrace", "\\html@mathml{" + + "\\mathclose{]\\mkern-3.2mu\\}}}" + + "{\\mathclose{\\char`\u2984}}"); + +defineMacro("\u2983", "\\lBrace"); // blackboard bold { +defineMacro("\u2984", "\\rBrace"); // blackboard bold } + +// TODO: Create variable sized versions of the last two items. I believe that +// will require new font glyphs. + +// The stmaryrd function `\minuso` provides a "Plimsoll" symbol that +// superimposes the characters \circ and \mathminus. Used in chemistry. +defineMacro("\\minuso", "\\mathbin{\\html@mathml{" + + "{\\mathrlap{\\mathchoice{\\kern{0.145em}}{\\kern{0.145em}}" + + "{\\kern{0.1015em}}{\\kern{0.0725em}}\\circ}{-}}}" + + "{\\char`⦵}}"); +defineMacro("⦵", "\\minuso"); + +////////////////////////////////////////////////////////////////////// +// texvc.sty + +// The texvc package contains macros available in mediawiki pages. +// We omit the functions deprecated at +// https://en.wikipedia.org/wiki/Help:Displaying_a_formula#Deprecated_syntax + +// We also omit texvc's \O, which conflicts with \text{\O} + +defineMacro("\\darr", "\\downarrow"); +defineMacro("\\dArr", "\\Downarrow"); +defineMacro("\\Darr", "\\Downarrow"); +defineMacro("\\lang", "\\langle"); +defineMacro("\\rang", "\\rangle"); +defineMacro("\\uarr", "\\uparrow"); +defineMacro("\\uArr", "\\Uparrow"); +defineMacro("\\Uarr", "\\Uparrow"); +defineMacro("\\N", "\\mathbb{N}"); +defineMacro("\\R", "\\mathbb{R}"); +defineMacro("\\Z", "\\mathbb{Z}"); +defineMacro("\\alef", "\\aleph"); +defineMacro("\\alefsym", "\\aleph"); +defineMacro("\\Alpha", "\\mathrm{A}"); +defineMacro("\\Beta", "\\mathrm{B}"); +defineMacro("\\bull", "\\bullet"); +defineMacro("\\Chi", "\\mathrm{X}"); +defineMacro("\\clubs", "\\clubsuit"); +defineMacro("\\cnums", "\\mathbb{C}"); +defineMacro("\\Complex", "\\mathbb{C}"); +defineMacro("\\Dagger", "\\ddagger"); +defineMacro("\\diamonds", "\\diamondsuit"); +defineMacro("\\empty", "\\emptyset"); +defineMacro("\\Epsilon", "\\mathrm{E}"); +defineMacro("\\Eta", "\\mathrm{H}"); +defineMacro("\\exist", "\\exists"); +defineMacro("\\harr", "\\leftrightarrow"); +defineMacro("\\hArr", "\\Leftrightarrow"); +defineMacro("\\Harr", "\\Leftrightarrow"); +defineMacro("\\hearts", "\\heartsuit"); +defineMacro("\\image", "\\Im"); +defineMacro("\\infin", "\\infty"); +defineMacro("\\Iota", "\\mathrm{I}"); +defineMacro("\\isin", "\\in"); +defineMacro("\\Kappa", "\\mathrm{K}"); +defineMacro("\\larr", "\\leftarrow"); +defineMacro("\\lArr", "\\Leftarrow"); +defineMacro("\\Larr", "\\Leftarrow"); +defineMacro("\\lrarr", "\\leftrightarrow"); +defineMacro("\\lrArr", "\\Leftrightarrow"); +defineMacro("\\Lrarr", "\\Leftrightarrow"); +defineMacro("\\Mu", "\\mathrm{M}"); +defineMacro("\\natnums", "\\mathbb{N}"); +defineMacro("\\Nu", "\\mathrm{N}"); +defineMacro("\\Omicron", "\\mathrm{O}"); +defineMacro("\\plusmn", "\\pm"); +defineMacro("\\rarr", "\\rightarrow"); +defineMacro("\\rArr", "\\Rightarrow"); +defineMacro("\\Rarr", "\\Rightarrow"); +defineMacro("\\real", "\\Re"); +defineMacro("\\reals", "\\mathbb{R}"); +defineMacro("\\Reals", "\\mathbb{R}"); +defineMacro("\\Rho", "\\mathrm{P}"); +defineMacro("\\sdot", "\\cdot"); +defineMacro("\\sect", "\\S"); +defineMacro("\\spades", "\\spadesuit"); +defineMacro("\\sub", "\\subset"); +defineMacro("\\sube", "\\subseteq"); +defineMacro("\\supe", "\\supseteq"); +defineMacro("\\Tau", "\\mathrm{T}"); +defineMacro("\\thetasym", "\\vartheta"); +// TODO: defineMacro("\\varcoppa", "\\\mbox{\\coppa}"); +defineMacro("\\weierp", "\\wp"); +defineMacro("\\Zeta", "\\mathrm{Z}"); + +////////////////////////////////////////////////////////////////////// +// statmath.sty +// https://ctan.math.illinois.edu/macros/latex/contrib/statmath/statmath.pdf + +defineMacro("\\argmin", "\\DOTSB\\operatorname*{arg\\,min}"); +defineMacro("\\argmax", "\\DOTSB\\operatorname*{arg\\,max}"); +defineMacro("\\plim", "\\DOTSB\\mathop{\\operatorname{plim}}\\limits"); + +////////////////////////////////////////////////////////////////////// +// braket.sty +// http://ctan.math.washington.edu/tex-archive/macros/latex/contrib/braket/braket.pdf + +defineMacro("\\bra", "\\mathinner{\\langle{#1}|}"); +defineMacro("\\ket", "\\mathinner{|{#1}\\rangle}"); +defineMacro("\\braket", "\\mathinner{\\langle{#1}\\rangle}"); +defineMacro("\\Bra", "\\left\\langle#1\\right|"); +defineMacro("\\Ket", "\\left|#1\\right\\rangle"); +const braketHelper = (one: boolean) => (context: MacroContextInterface) => { + const left = context.consumeArg().tokens; + const middle = context.consumeArg().tokens; + const middleDouble = context.consumeArg().tokens; + const right = context.consumeArg().tokens; + const oldMiddle = context.macros.get("|"); + const oldMiddleDouble = context.macros.get("\\|"); + context.macros.beginGroup(); + const midMacro = (double: boolean) => (context: MacroContextInterface) => { + if (one) { + // Only modify the first instance of | or \| + context.macros.set("|", oldMiddle); + if (middleDouble.length) { + context.macros.set("\\|", oldMiddleDouble); + } + } + let doubled = double; + if (!double && middleDouble.length) { + // Mimic \@ifnextchar + const nextToken = context.future(); + if (nextToken.text === "|") { + context.popToken(); + doubled = true; + } + } + return { + tokens: doubled ? middleDouble : middle, + numArgs: 0, + }; + }; + context.macros.set("|", midMacro(false)); + if (middleDouble.length) { + context.macros.set("\\|", midMacro(true)); + } + const arg = context.consumeArg().tokens; + const expanded = context.expandTokens([ + ...right, ...arg, ...left, // reversed + ]); + context.macros.endGroup(); + return { + tokens: expanded.reverse(), + numArgs: 0, + }; +}; +defineMacro("\\bra@ket", braketHelper(false)); +defineMacro("\\bra@set", braketHelper(true)); +defineMacro("\\Braket", "\\bra@ket{\\left\\langle}" + + "{\\,\\middle\\vert\\,}{\\,\\middle\\vert\\,}{\\right\\rangle}"); +defineMacro("\\Set", "\\bra@set{\\left\\{\\:}" + + "{\\;\\middle\\vert\\;}{\\;\\middle\\Vert\\;}{\\:\\right\\}}"); +defineMacro("\\set", "\\bra@set{\\{\\,}{\\mid}{}{\\,\\}}"); + // has no support for special || or \| + +////////////////////////////////////////////////////////////////////// +// actuarialangle.dtx +defineMacro("\\angln", "{\\angl n}"); + +// Custom Khan Academy colors, should be moved to an optional package +defineMacro("\\blue", "\\textcolor{##6495ed}{#1}"); +defineMacro("\\orange", "\\textcolor{##ffa500}{#1}"); +defineMacro("\\pink", "\\textcolor{##ff00af}{#1}"); +defineMacro("\\red", "\\textcolor{##df0030}{#1}"); +defineMacro("\\green", "\\textcolor{##28ae7b}{#1}"); +defineMacro("\\gray", "\\textcolor{gray}{#1}"); +defineMacro("\\purple", "\\textcolor{##9d38bd}{#1}"); +defineMacro("\\blueA", "\\textcolor{##ccfaff}{#1}"); +defineMacro("\\blueB", "\\textcolor{##80f6ff}{#1}"); +defineMacro("\\blueC", "\\textcolor{##63d9ea}{#1}"); +defineMacro("\\blueD", "\\textcolor{##11accd}{#1}"); +defineMacro("\\blueE", "\\textcolor{##0c7f99}{#1}"); +defineMacro("\\tealA", "\\textcolor{##94fff5}{#1}"); +defineMacro("\\tealB", "\\textcolor{##26edd5}{#1}"); +defineMacro("\\tealC", "\\textcolor{##01d1c1}{#1}"); +defineMacro("\\tealD", "\\textcolor{##01a995}{#1}"); +defineMacro("\\tealE", "\\textcolor{##208170}{#1}"); +defineMacro("\\greenA", "\\textcolor{##b6ffb0}{#1}"); +defineMacro("\\greenB", "\\textcolor{##8af281}{#1}"); +defineMacro("\\greenC", "\\textcolor{##74cf70}{#1}"); +defineMacro("\\greenD", "\\textcolor{##1fab54}{#1}"); +defineMacro("\\greenE", "\\textcolor{##0d923f}{#1}"); +defineMacro("\\goldA", "\\textcolor{##ffd0a9}{#1}"); +defineMacro("\\goldB", "\\textcolor{##ffbb71}{#1}"); +defineMacro("\\goldC", "\\textcolor{##ff9c39}{#1}"); +defineMacro("\\goldD", "\\textcolor{##e07d10}{#1}"); +defineMacro("\\goldE", "\\textcolor{##a75a05}{#1}"); +defineMacro("\\redA", "\\textcolor{##fca9a9}{#1}"); +defineMacro("\\redB", "\\textcolor{##ff8482}{#1}"); +defineMacro("\\redC", "\\textcolor{##f9685d}{#1}"); +defineMacro("\\redD", "\\textcolor{##e84d39}{#1}"); +defineMacro("\\redE", "\\textcolor{##bc2612}{#1}"); +defineMacro("\\maroonA", "\\textcolor{##ffbde0}{#1}"); +defineMacro("\\maroonB", "\\textcolor{##ff92c6}{#1}"); +defineMacro("\\maroonC", "\\textcolor{##ed5fa6}{#1}"); +defineMacro("\\maroonD", "\\textcolor{##ca337c}{#1}"); +defineMacro("\\maroonE", "\\textcolor{##9e034e}{#1}"); +defineMacro("\\purpleA", "\\textcolor{##ddd7ff}{#1}"); +defineMacro("\\purpleB", "\\textcolor{##c6b9fc}{#1}"); +defineMacro("\\purpleC", "\\textcolor{##aa87ff}{#1}"); +defineMacro("\\purpleD", "\\textcolor{##7854ab}{#1}"); +defineMacro("\\purpleE", "\\textcolor{##543b78}{#1}"); +defineMacro("\\mintA", "\\textcolor{##f5f9e8}{#1}"); +defineMacro("\\mintB", "\\textcolor{##edf2df}{#1}"); +defineMacro("\\mintC", "\\textcolor{##e0e5cc}{#1}"); +defineMacro("\\grayA", "\\textcolor{##f6f7f7}{#1}"); +defineMacro("\\grayB", "\\textcolor{##f0f1f2}{#1}"); +defineMacro("\\grayC", "\\textcolor{##e3e5e6}{#1}"); +defineMacro("\\grayD", "\\textcolor{##d6d8da}{#1}"); +defineMacro("\\grayE", "\\textcolor{##babec2}{#1}"); +defineMacro("\\grayF", "\\textcolor{##888d93}{#1}"); +defineMacro("\\grayG", "\\textcolor{##626569}{#1}"); +defineMacro("\\grayH", "\\textcolor{##3b3e40}{#1}"); +defineMacro("\\grayI", "\\textcolor{##21242c}{#1}"); +defineMacro("\\kaBlue", "\\textcolor{##314453}{#1}"); +defineMacro("\\kaGreen", "\\textcolor{##71B307}{#1}"); diff --git a/node_modules/react-katex/node_modules/katex/src/mathMLTree.ts b/node_modules/react-katex/node_modules/katex/src/mathMLTree.ts new file mode 100644 index 0000000..4bb925f --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/mathMLTree.ts @@ -0,0 +1,259 @@ +/** + * These objects store data about MathML nodes. This is the MathML equivalent + * of the types in domTree.js. Since MathML handles its own rendering, and + * since we're mainly using MathML to improve accessibility, we don't manage + * any of the styling state that the plain DOM nodes do. + * + * The `toNode` and `toMarkup` functions work similarly to how they do in + * domTree.js, creating namespaced DOM nodes and HTML text markup respectively. + */ + +import {escape} from "./utils"; +import {DocumentFragment} from "./tree"; +import {createClass} from "./domTree"; +import {makeEm} from "./units"; + +import type {VirtualNode} from "./tree"; + +/** + * MathML node types used in KaTeX. For a complete list of MathML nodes, see + * https://developer.mozilla.org/en-US/docs/Web/MathML/Element. + */ +export type MathNodeType = + "math" | "annotation" | "semantics" | + "mtext" | "mn" | "mo" | "mi" | "mspace" | + "mover" | "munder" | "munderover" | "msup" | "msub" | "msubsup" | + "mfrac" | "mroot" | "msqrt" | + "mtable" | "mtr" | "mtd" | "mlabeledtr" | + "mrow" | "menclose" | + "mstyle" | "mpadded" | "mphantom" | "mglyph"; + +export interface MathDomNode extends VirtualNode { + toText(): string; +} + +export type documentFragment = DocumentFragment; +export function newDocumentFragment( + children: ReadonlyArray +): documentFragment { + return new DocumentFragment(children); +} + +/** + * This node represents a general purpose MathML node of any type. The + * constructor requires the type of node to create (for example, `"mo"` or + * `"mspace"`, corresponding to `` and `` tags). + */ +export class MathNode implements MathDomNode { + type: MathNodeType; + attributes: Record; + children: MathDomNode[]; + classes: string[]; + + constructor( + type: MathNodeType, + children?: MathDomNode[], + classes?: string[] + ) { + this.type = type; + this.attributes = {}; + this.children = children || []; + this.classes = classes || []; + } + + /** + * Sets an attribute on a MathML node. MathML depends on attributes to convey a + * semantic content, so this is used heavily. + */ + setAttribute(name: string, value: string) { + this.attributes[name] = value; + } + + /** + * Gets an attribute on a MathML node. + */ + getAttribute(name: string): string { + return this.attributes[name]; + } + + /** + * Converts the math node into a MathML-namespaced DOM element. + */ + toNode(): Node { + const node = document.createElementNS( + "http://www.w3.org/1998/Math/MathML", this.type); + + for (const attr in this.attributes) { + if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) { + node.setAttribute(attr, this.attributes[attr]); + } + } + + if (this.classes.length > 0) { + node.className = createClass(this.classes); + } + + for (let i = 0; i < this.children.length; i++) { + // Combine multiple TextNodes into one TextNode, to prevent + // screen readers from reading each as a separate word [#3995] + if (this.children[i] instanceof TextNode && + this.children[i + 1] instanceof TextNode) { + let text = this.children[i].toText() + this.children[++i].toText(); + while (this.children[i + 1] instanceof TextNode) { + text += this.children[++i].toText(); + } + node.appendChild(new TextNode(text).toNode()); + } else { + node.appendChild(this.children[i].toNode()); + } + } + + return node; + } + + /** + * Converts the math node into an HTML markup string. + */ + toMarkup(): string { + let markup = "<" + this.type; + + // Add the attributes + for (const attr in this.attributes) { + if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) { + markup += " " + attr + "=\""; + markup += escape(this.attributes[attr]); + markup += "\""; + } + } + + if (this.classes.length > 0) { + markup += ` class ="${escape(createClass(this.classes))}"`; + } + + markup += ">"; + + for (let i = 0; i < this.children.length; i++) { + markup += this.children[i].toMarkup(); + } + + markup += ""; + + return markup; + } + + /** + * Converts the math node into a string, similar to innerText, but escaped. + */ + toText(): string { + return this.children.map(child => child.toText()).join(""); + } +} + +/** + * This node represents a piece of text. + */ +export class TextNode implements MathDomNode { + text: string; + + constructor(text: string) { + this.text = text; + } + + /** + * Converts the text node into a DOM text node. + */ + toNode(): Node { + return document.createTextNode(this.text); + } + + /** + * Converts the text node into escaped HTML markup + * (representing the text itself). + */ + toMarkup(): string { + return escape(this.toText()); + } + + /** + * Converts the text node into a string + * (representing the text itself). + */ + toText(): string { + return this.text; + } +} + +/** + * This node represents a space, but may render as or as text, + * depending on the width. + */ +export class SpaceNode implements MathDomNode { + width: number; + character: string | null | undefined; + + /** + * Create a Space node with width given in CSS ems. + */ + constructor(width: number) { + this.width = width; + // See https://www.w3.org/TR/2000/WD-MathML2-20000328/chapter6.html + // for a table of space-like characters. We use Unicode + // representations instead of &LongNames; as it's not clear how to + // make the latter via document.createTextNode. + if (width >= 0.05555 && width <= 0.05556) { + this.character = "\u200a"; //   + } else if (width >= 0.1666 && width <= 0.1667) { + this.character = "\u2009"; //   + } else if (width >= 0.2222 && width <= 0.2223) { + this.character = "\u2005"; //   + } else if (width >= 0.2777 && width <= 0.2778) { + this.character = "\u2005\u200a"; //    + } else if (width >= -0.05556 && width <= -0.05555) { + this.character = "\u200a\u2063"; // ​ + } else if (width >= -0.1667 && width <= -0.1666) { + this.character = "\u2009\u2063"; // ​ + } else if (width >= -0.2223 && width <= -0.2222) { + this.character = "\u205f\u2063"; // ​ + } else if (width >= -0.2778 && width <= -0.2777) { + this.character = "\u2005\u2063"; // ​ + } else { + this.character = null; + } + } + + /** + * Converts the math node into a MathML-namespaced DOM element. + */ + toNode(): Node { + if (this.character) { + return document.createTextNode(this.character); + } else { + const node = document.createElementNS( + "http://www.w3.org/1998/Math/MathML", "mspace"); + node.setAttribute("width", makeEm(this.width)); + return node; + } + } + + /** + * Converts the math node into an HTML markup string. + */ + toMarkup(): string { + if (this.character) { + return `${this.character}`; + } else { + return ``; + } + } + + /** + * Converts the math node into a string, similar to innerText. + */ + toText(): string { + if (this.character) { + return this.character; + } else { + return " "; + } + } +} diff --git a/node_modules/react-katex/node_modules/katex/src/metrics/README.md b/node_modules/react-katex/node_modules/katex/src/metrics/README.md new file mode 100644 index 0000000..c340e72 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/metrics/README.md @@ -0,0 +1,23 @@ +### How to generate new metrics +------------------------------- + +There are several requirements for generating the metrics used by KaTeX. + +- You need to have an installation of TeX which supports kpathsea. You can check + this by running `tex --version`, and seeing if it has a line that looks like + > kpathsea version 6.2.0 + +- You need the Perl module `JSON`. You can install this either from CPAN + (e.g. using the `cpan` command line tool: `cpan install JSON`) + or with your package manager. + +- You need the Python module `fonttools`. You can install this either from PyPI + (using `easy_install` or `pip`: `pip install fonttools`) + or with your package manager. + +Once you have these things, run the following command from the root directory: + + sh ./dockers/fonts/buildMetrics.sh + +which should generate new metrics and place them into `fontMetricsData.json`. +You're done! diff --git a/node_modules/react-katex/node_modules/katex/src/metrics/extract_tfms.py b/node_modules/react-katex/node_modules/katex/src/metrics/extract_tfms.py new file mode 100644 index 0000000..70297dc --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/metrics/extract_tfms.py @@ -0,0 +1,114 @@ +#!/usr/bin/env python3 + +import collections +import json +import parse_tfm +import subprocess +import sys + + +def find_font_path(font_name): + try: + font_path = subprocess.check_output(['kpsewhich', font_name]) + except OSError: + raise RuntimeError("Couldn't find kpsewhich program, make sure you" + + " have TeX installed") + except subprocess.CalledProcessError: + raise RuntimeError("Couldn't find font metrics: '%s'" % font_name) + return font_path.strip() + + +def main(): + mapping = json.load(sys.stdin) + + fonts = [ + 'cmbsy10.tfm', + 'cmbx10.tfm', + 'cmbxti10.tfm', + 'cmex10.tfm', + 'cmmi10.tfm', + 'cmmib10.tfm', + 'cmr10.tfm', + 'cmsy10.tfm', + 'cmti10.tfm', + 'msam10.tfm', + 'msbm10.tfm', + 'eufm10.tfm', + 'cmtt10.tfm', + 'rsfs10.tfm', + 'cmss10.tfm', + 'cmssbx10.tfm', + 'cmssi10.tfm', + ] + + # Extracted by running `\font\a=` and then `\showthe\skewchar\a` in + # TeX, where `` is the name of the font listed here. The skewchar + # will be printed out in the output. If it outputs `-1`, that means there + # is no skewchar, so we use `None` here. + font_skewchar = { + 'cmbsy10': None, + 'cmbx10': None, + 'cmbxti10': None, + 'cmex10': None, + 'cmmi10': 127, + 'cmmib10': None, + 'cmr10': None, + 'cmsy10': 48, + 'cmti10': None, + 'msam10': None, + 'msbm10': None, + 'eufm10': None, + 'cmtt10': None, + 'rsfs10': None, + 'cmss10': None, + 'cmssbx10': None, + 'cmssi10': None, + } + + font_name_to_tfm = {} + + for font_name in fonts: + font_basename = font_name.split('.')[0] + font_path = find_font_path(font_name) + font_name_to_tfm[font_basename] = parse_tfm.read_tfm_file(font_path) + + families = collections.defaultdict(dict) + + for family, chars in mapping.items(): + for char, char_data in chars.items(): + char_num = int(char) + + font = char_data['font'] + tex_char_num = int(char_data['char']) + yshift = float(char_data['yshift']) + + if family == "Script-Regular": + tfm_char = font_name_to_tfm[font].get_char_metrics(tex_char_num, + fix_rsfs=True) + else: + tfm_char = font_name_to_tfm[font].get_char_metrics(tex_char_num) + + height = round(tfm_char.height + yshift / 1000.0, 5) + depth = round(tfm_char.depth - yshift / 1000.0, 5) + italic = round(tfm_char.italic_correction, 5) + width = round(tfm_char.width, 5) + + skewkern = 0.0 + if (font_skewchar[font] and + font_skewchar[font] in tfm_char.kern_table): + skewkern = round( + tfm_char.kern_table[font_skewchar[font]], 5) + + families[family][char_num] = { + 'height': height, + 'depth': depth, + 'italic': italic, + 'skew': skewkern, + 'width': width + } + + sys.stdout.write( + json.dumps(families, separators=(',', ':'), sort_keys=True)) + +if __name__ == '__main__': + main() diff --git a/node_modules/react-katex/node_modules/katex/src/metrics/extract_ttfs.py b/node_modules/react-katex/node_modules/katex/src/metrics/extract_ttfs.py new file mode 100644 index 0000000..29f9225 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/metrics/extract_ttfs.py @@ -0,0 +1,122 @@ +#!/usr/bin/env python3 + +from fontTools.ttLib import TTFont +import sys +import json + +# map of characters to extract +metrics_to_extract = { + # Font name + "AMS-Regular": { + u"\u21e2": None, # \dashrightarrow + u"\u21e0": None, # \dashleftarrow + }, + "Main-Regular": { + # Skew and italic metrics can't be easily parsed from the TTF. Instead, + # we map each character to a "base character", which is a character + # from the same font with correct italic and skew metrics. A character + # maps to None if it doesn't have a base. + + #u"\u2209": None, # \notin + #u"\u2260": None, # \neq + u"\u2245": None, # \cong + u"\u2026": None, # \ldots + u"\u22ef": None, # \cdots + u"\u22f1": None, # \ddots + u"\u22ee": None, # \vdots + u"\u22ee": None, # \vdots + u"\u22a8": None, # \models + u"\u22c8": None, # \bowtie + u"\u2250": None, # \doteq + u"\u23b0": None, # \lmoustache + u"\u23b1": None, # \rmoustache + u"\u27ee": None, # \lgroup + u"\u27ef": None, # \rgroup + u"\u27f5": None, # \longleftarrow + u"\u27f8": None, # \Longleftarrow + u"\u27f6": None, # \longrightarrow + u"\u27f9": None, # \Longrightarrow + u"\u27f7": None, # \longleftrightarrow + u"\u27fa": None, # \Longleftrightarrow + u"\u21a6": None, # \mapsto + u"\u27fc": None, # \longmapsto + u"\u21a9": None, # \hookleftarrow + u"\u21aa": None, # \hookrightarrow + u"\u21cc": None, # \rightleftharpoons + }, + "Main-Bold": { + u"\u2245": None, # \cong + }, + "Size1-Regular": { + u"\u222c": u"\u222b", # \iint, based on \int + u"\u222d": u"\u222b", # \iiint, based on \int + }, + "Size2-Regular": { + u"\u222c": u"\u222b", # \iint, based on \int + u"\u222d": u"\u222b", # \iiint, based on \int + }, +} + + +def main(): + start_json = json.load(sys.stdin) + + for font in start_json: + fontInfo = TTFont("../../fonts/KaTeX_" + font + ".ttf") + glyf = fontInfo["glyf"] + widths = fontInfo.getGlyphSet() + unitsPerEm = float(fontInfo["head"].unitsPerEm) + + # We keep ALL Unicode cmaps, not just fontInfo["cmap"].getcmap(3, 1). + # This is playing it extra safe, since it reports inconsistencies. + # Platform 0 is Unicode, platform 3 is Windows. For platform 3, + # encoding 1 is UCS-2 and encoding 10 is UCS-4. + cmap = [t.cmap for t in fontInfo["cmap"].tables + if (t.platformID == 0) + or (t.platformID == 3 and t.platEncID in (1, 10))] + + chars = metrics_to_extract.get(font, {}) + chars[u"\u0020"] = None # space + chars[u"\u00a0"] = None # nbsp + + for char, base_char in chars.items(): + code = ord(char) + names = set(t.get(code) for t in cmap) + if not names: + sys.stderr.write( + "Codepoint {} of font {} maps to no name\n" + .format(code, font)) + continue + if len(names) != 1: + sys.stderr.write( + "Codepoint {} of font {} maps to multiple names: {}\n" + .format(code, font, ", ".join(sorted(names)))) + continue + name = names.pop() + + height = depth = italic = skew = width = 0 + glyph = glyf[name] + if glyph.numberOfContours: + height = glyph.yMax / unitsPerEm + depth = -glyph.yMin / unitsPerEm + width = widths[name].width / unitsPerEm + if base_char: + base_char_str = str(ord(base_char)) + base_metrics = start_json[font][base_char_str] + italic = base_metrics["italic"] + skew = base_metrics["skew"] + width = base_metrics["width"] + + start_json[font][str(code)] = { + "height": height, + "depth": depth, + "italic": italic, + "skew": skew, + "width": width + } + + sys.stdout.write( + json.dumps(start_json, separators=(',', ':'), sort_keys=True)) + +if __name__ == "__main__": + main() diff --git a/node_modules/react-katex/node_modules/katex/src/metrics/format_json.py b/node_modules/react-katex/node_modules/katex/src/metrics/format_json.py new file mode 100644 index 0000000..0918d4d --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/metrics/format_json.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python3 + +import sys +import json + +props = ['depth', 'height', 'italic', 'skew'] + +if len(sys.argv) > 1: + if sys.argv[1] == '--width': + props.append('width') + +data = json.load(sys.stdin) +sys.stdout.write( + "// This file is GENERATED by buildMetrics.sh. DO NOT MODIFY.\n") +sep = "export default {\n " +for font in sorted(data): + sys.stdout.write(sep + json.dumps(font)) + sep = ": {\n " + for glyph in sorted(data[font], key=int): + sys.stdout.write(sep + json.dumps(glyph) + ": ") + + values = [value if value != 0.0 else 0 for value in + [data[font][glyph][key] for key in props]] + + sys.stdout.write(json.dumps(values)) + sep = ",\n " + sep = ",\n },\n " +sys.stdout.write(",\n },\n};\n") diff --git a/node_modules/react-katex/node_modules/katex/src/metrics/mapping.pl b/node_modules/react-katex/node_modules/katex/src/metrics/mapping.pl new file mode 100644 index 0000000..dabc7ce --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/metrics/mapping.pl @@ -0,0 +1,1224 @@ +#! /usr/bin/perl + +# Adapted from the MathJax-dev repository file /fonts/OTF/TeX/makeFF under the +# Apache 2 license + +# We use this file to recover the mapping from TeX fonts to KaTeX fonts, to +# accurately extract the metrics from the corresponding .tfm (TeX font metric) +# files + +use JSON; + +$map{cmr10} = { + "Main-Regular" => [ + [0,1] => 0x393, # \Gamma, \Delta + 2 => 0x398, # \Theta + 3 => 0x39B, # \Lambda + 4 => 0x39E, # \Xi + 5 => 0x3A0, # \Pi + 6 => 0x3A3, # \Sigma + [7,8] => 0x3A5, # \Upsilon, \Phi + [9,0xA] => 0x3A8, # \Psi, \Omega + + 0x10 => 0x131, # \i + 0x11 => 0x237, # \j + 0x12 => 0x2CB, # \grave + 0x13 => 0x2CA, # \acute + 0x14 => 0x2C7, # \check + 0x15 => 0x2D8, # \breve + 0x16 => 0x2C9, # \bar + 0x17 => [0xB0,-125,0], # \degree + 0x17 => 0x02DA, # \r, ring above + 0x18 => 0xB8, # \c, cedilla + + [0x21,0x2F] => 0x21, # !, ", #, $, %, &, ', (, ), *, +, comma, -, ., / + 0x22 => 0x201D, # " + 0x27 => 0x2019, # ' + [0x30,0x39] => 0x30, # 0-9 + [0x3A,0x3B] => 0x3A, # :, ; + 0x3D => 0x3D, # = + [0x3F,0x40] => 0x3F, # ?, @ + [0x41,0x5A] => 0x41, # A-Z + 0x5B => 0x5B, # [ + 0x5C => 0x201C, # `` + [0x5D,0x5E] => 0x5D, # ], ^ + 0x5E => 0x2C6, # \hat + 0x5F => 0x2D9, # \dot + 0x60 => 0x2018, # ` + [0x61,0x7A] => 0x61, # a-z + [0x7B,0x7C] => 0x2013, # \endash, \emdash + 0x7B => [0x5F,0,-310], # underline + 0x7D => 0x2DD, # double acute + 0x7E => [0x7E,0,-350], # ~ + 0x7E => 0x2DC, # \tilde + 0x7F => 0xA8, # \ddot + 0x19 => 0xDF, # sharp S + 0x1A => 0xE6, # ae ligature + 0x1B => 0x153, # oe ligature + 0x1C => 0xF8, # o with slash + 0x1D => 0xC6, # AE ligature + 0x1E => 0x152, # OE ligature + 0x1F => 0xD8, # O with slash + ], +}; + +$map{cmmi10} = { + "Math-Italic" => [ + [0,1] => 0x393, # \Gamma, \Delta + 2 => 0x398, # \Theta + 3 => 0x39B, # \Lambda + 4 => 0x39E, # \Xi + 5 => 0x3A0, # \Pi + 6 => 0x3A3, # \Sigma + [7,8] => 0x3A5, # \Upsilon, \Phi + [9,0xA] => 0x3A8, # \Psi, \Omega + + [0xB,0xE] => 0x3B1, # \alpha, \beta, \gamma, \delta + 0xF => 0x3F5, # \elpsilon + [0x10,0x18] => 0x3B6, # \zeta, \eta, \theta, \iota, \kappa, \lambda, \mu, \nu, \xi + [0x19,0x1A] => 0x3C0, # \pi, \rho + [0x1B,0x1D] => 0x3C3, # \sigma, \tau, \upsilon + 0x1E => 0x3D5, # \phi + [0x1F,0x21] => 0x3C7, # \chi, \psi, \omega + 0x22 => 0x3B5, # \varepsilon + 0x23 => 0x3D1, # \vartheta + 0x24 => 0x3D6, # \varpi + 0x25 => 0x3F1, # \varrho + 0x26 => 0x3C2, # \varsigma + 0x27 => 0x3C6, # \varphi + + [0x30,0x39] => 0x30, # Oldstyle 0-9 + [0x41,0x5A] => 0x41, # A-Z + [0x61,0x7A] => 0x61, # a - z + + 0x6F => 0x3BF, # omicron + 0x7B => 0xE131, # \imath (PUA) + 0x7C => 0xE237, # \jmath (PUA) + ], + + "Main-Regular" => [ + 0x28 => 0x21BC, # \leftharpoonup + 0x29 => 0x21BD, # \leftharpoondown + 0x2A => 0x21C0, # \rightharpoonup + 0x2B => 0x21C1, # \rightharpoondown + + 0x2E => 0x25B9, # \triangleright + 0x2F => 0x25C3, # \triangleleft + + 0x3C => 0x3C, # < + 0x3D => 0x2215, # / + 0x3E => 0x3E, # > + 0x3F => 0x22C6, # \star + 0x40 => 0x2202, # \partial + + [0x5B,0x5D] => 0x266D, # \flat, \natural, \sharp + 0x5E => 0x2323, # \smile + 0x5F => 0x2322, # \frown + 0x60 => 0x2113, # \ell + + 0x7D => 0x2118, # \wp + 0x7E => [0x20D7,-653,0],# \vec + ], +}; + +$map{cmsy10} = { + "Main-Regular" => [ + 0 => 0x2212, # - + 1 => 0x22C5, # \cdot + 2 => 0xD7, # \times + 3 => 0x2217, # \ast + 4 => 0xF7, # \div + 5 => 0x22C4, # \diamond + 6 => 0xB1, # \pm + 7 => 0x2213, # \mp + [8,0xC] => 0x2295, # \oplus, \ominus, \otimes, \oslash, \odot + 0xD => 0x25EF, # \bigcirc + [0xE,0xF] => 0x2218, # \circ, \bullet + + 0x10 => 0x224D, # \asymp + 0x11 => 0x2261, # \equiv + [0x12,0x13] => 0x2286, # \subseteq, \supseteq + [0x14,0x15] => 0x2264, # \leq, \geq + [0x16,0x17] => 0x2AAF, # \preceq, \succeq + 0x18 => 0x223C, # \sim + 0x19 => 0x2248, # \approx + [0x1A,0x1B] => 0x2282, # \subset, \supset + [0x1C,0x1D] => 0x226A, # \ll, \gg + [0x1E,0x1F] => 0x227A, # \prec, \succ + + 0x20 => 0x2190, # \leftarrow + 0x21 => 0x2192, # \rightarrow + 0x22 => 0x2191, # \uparrow + 0x23 => 0x2193, # \downarrow + 0x24 => 0x2194, # \leftrightarrow + 0x25 => 0x2197, # \nearrow + 0x26 => 0x2198, # \searrow + 0x27 => 0x2243, # \simeq + + 0x28 => 0x21D0, # \Leftarrow + 0x29 => 0x21D2, # \Rightarrow + 0x2A => 0x21D1, # \Uparrow + 0x2B => 0x21D3, # \Downarrow + 0x2C => 0x21D4, # \Leftrightarrow + 0x2D => 0x2196, # \nwarrow + 0x2E => 0x2199, # \swarrow + 0x2F => 0x221D, # \propto + + 0x30 => 0x2032, # \prime + 0x31 => 0x221E, # \infty + 0x32 => 0x2208, # \in + 0x33 => 0x220B, # \ni + 0x34 => 0x25B3, # \bigtriangleup and \triangle + 0x35 => 0x25BD, # \bigtriangledown + 0x36 => 0xE020, # \not + + 0x38 => 0x2200, # \forall + 0x39 => 0x2203, # \exists + 0x3A => 0xAC, # \neg + 0x3B => 0x2205, # \emptyset + 0x3C => 0x211C, # \Re + 0x3D => 0x2111, # \Im + 0x3E => 0x22A4, # \top + 0x3F => 0x22A5, # \bot + + 0x40 => 0x2135, # \aleph + + 0x5B => 0x222A, # \cup + 0x5C => 0x2229, # \cap + 0x5D => 0x228E, # \uplus + [0x5E,0x5F] => 0x2227, # \wedge, \vee + + [0x60,0x61] => 0x22A2, # \vdash, \dashv + [0x62,0x63] => 0x230A, # \lfloor, \rfloor + [0x64,0x65] => 0x2308, # \lceil, \rceil + 0x66 => 0x7B, # { + 0x67 => 0x7D, # } + [0x68,0x69] => 0x27E8, # \langle, \rangle + 0x6A => 0x7C, # | + 0x6A => 0x2223, # \vert + 0x6B => 0x2225, # \Vert + 0x6C => 0x2195, # \updownarrow + 0x6D => 0x21D5, # \Updownarrow + 0x6E => 0x5C, # \backslash + 0x6E => 0x2216, # \setminus + 0x6F => 0x2240, # \wr + + 0x70 => [0x221A,0,760], # \surd ### adjust position so font doesn't have a large depth + 0x71 => 0x2A3F, # \amalg + 0x72 => 0x2207, # \nabla + 0x73 => 0x222B, # \int + 0x74 => 0x2294, # \sqcup + 0x75 => 0x2293, # \sqcap + [0x76,0x77] => 0x2291, # \sqsubseteq, \sqsupseteq + 0x78 => 0xA7, # \S + [0x79,0x7A] => 0x2020, # \dagger, \ddagger + 0x7B => 0xB6, # \P + 0x7C => 0x2663, # \clubsuit + 0x7D => 0x2662, # \diamondsuit + 0x7E => 0x2661, # \heartsuit + 0x7F => 0x2660, # \spadesuit + ], + + "Caligraphic-Regular" => [ + [0x41,0x5A] => 0x41, # A-Z + ], +}; + +$map{cmex10} = { + "Size1" => [ + 0 => [0x28,0,810], # ( + 1 => [0x29,0,810], # ) + 2 => [0x5B,0,810], # [ + 3 => [0x5D,0,810], # ] + 4 => [0x230A,0,810], # \lfloor + 5 => [0x230B,0,810], # \rfloor + 6 => [0x2308,0,810], # \lceil + 7 => [0x2309,0,810], # \rceil + 8 => [0x7B,0,810], # { + 9 => [0x7D,0,810], # } + 0xA => [0x27E8,0,810], # \langle + 0xB => [0x27E9,0,810], # \rangle + 0xC => [0x2223,0,606], # \vert + 0xD => [0x2225,0,606], # \Vert + 0xE => [0x2F,0,810], # / + 0xF => [0x5C,0,810], # \ + + 0x46 => [0x2A06,0,750], # \bigsqcup + 0x48 => [0x222E,0,805], # \oint + 0x4A => [0x2A00,0,750], # \bigodot + 0x4C => [0x2A01,0,750], # \bigoplus + 0x4E => [0x2A02,0,750], # \bigotimes + + 0x50 => [0x2211,0,750], # \sum + 0x51 => [0x220F,0,750], # \prod + 0x52 => [0x222B,0,805], # \int + 0x53 => [0x22C3,0,750], # \bigcup + 0x54 => [0x22C2,0,750], # \bigcap + 0x55 => [0x2A04,0,750], # \biguplus + 0x56 => [0x22C0,0,750], # \bigwedge + 0x57 => [0x22C1,0,750], # \bigvee + + 0x60 => [0x2210,0,750], # \coprod + 0x62 => 0x2C6, # \widehat + 0x62 => [0x302,-556,0], # \widehat (combining) + 0x65 => 0x2DC, # \widetilde + 0x65 => [0x303,-556,0], # \widetilde (combining) + + 0x70 => [0x221A,0,810], # surd + 0x3F => [0x23D0,0,601], # arrow extension + 0x77 => [0x2016,0,601], # Arrow extension (non-standard) + 0x78 => [0x2191,0,600], # uparrow top + 0x79 => [0x2193,0,600], # downarrow bottom + 0x7E => [0x21D1,0,600], # Uparrow top + 0x7F => [0x21D3,0,600], # Downarrow bottom + ], + + "Size2" => [ + 0x10 => [0x28,0,1110], # ( + 0x11 => [0x29,0,1110], # ) + 0x2E => [0x2F,0,1110], # / + 0x2F => [0x5C,0,1110], # \ + 0x44 => [0x27E8,0,1110],# \langle + 0x45 => [0x27E9,0,1110],# \rangle + + 0x47 => [0x2A06,0,950], # \bigsqcup + 0x49 => [0x222E,0,1360],# \oint + 0x4B => [0x2A00,0,950], # \bigodot + 0x4D => [0x2A01,0,950], # \bigoplus + 0x4F => [0x2A02,0,950], # \bigotimes + + 0x58 => [0x2211,0,950], # \sum + 0x59 => [0x220F,0,950], # \prod + 0x5A => [0x222B,0,1360],# \int + 0x5B => [0x22C3,0,950], # \bigcup + 0x5C => [0x22C2,0,950], # \bigcap + 0x5D => [0x2A04,0,950], # \biguplus + 0x5E => [0x22C0,0,950], # \bigwedge + 0x5F => [0x22C1,0,950], # \bigvee + 0x61 => [0x2210,0,950], # \coprod + + 0x63 => 0x2C6, # \widehat + 0x63 => [0x302,-1000,0],# \widehat (combining) + 0x66 => 0x2DC, # \widetilde + 0x66 => [0x303,-1000,0],# \widetilde (combining) + + 0x68 => [0x5B,0,1110], # [ + 0x69 => [0x5D,0,1110], # ] + 0x6A => [0x230A,0,1110],# \lfloor + 0x6B => [0x230B,0,1110],# \rfloor + 0x6C => [0x2308,0,1110],# \lceil + 0x6D => [0x2309,0,1110],# \rceil + 0x6E => [0x7B,0,1110], # { + 0x6F => [0x7D,0,1110], # } + 0x71 => [0x221A,0,1110],# surd + ], + + "Size3" => [ + 0x12 => [0x28,0,1410], # ( + 0x13 => [0x29,0,1410], # ) + 0x14 => [0x5B,0,1410], # [ + 0x15 => [0x5D,0,1410], # ] + 0x16 => [0x230A,0,1410],# \lfloor + 0x17 => [0x230B,0,1410],# \rfloor + 0x18 => [0x2308,0,1410],# \lceil + 0x19 => [0x2309,0,1410],# \rceil + 0x1A => [0x7B,0,1410], # { + 0x1B => [0x7D,0,1410], # } + 0x1C => [0x27E8,0,1410],# \langle + 0x1D => [0x27E9,0,1410],# \rangle + 0x1E => [0x2F,0,1410], # / + 0x1F => [0x5C,0,1410], # \ + 0x64 => 0x2C6, # \widehat + 0x64 => [0x302,-1444,0],# \widehat (combining) + 0x67 => 0x2DC, # \widetilde + 0x67 => [0x303,-1444,0],# \widetilde (combining) + 0x72 => [0x221A,0,1410],# surd + ], + + "Size4" => [ + 0x20 => [0x28,0,1710], # ( + 0x21 => [0x29,0,1710], # ) + 0x22 => [0x5B,0,1710], # [ + 0x23 => [0x5D,0,1710], # ] + 0x24 => [0x230A,0,1710],# \lfloor + 0x25 => [0x230B,0,1710],# \rfloor + 0x26 => [0x2308,0,1710],# \lceil + 0x27 => [0x2309,0,1710],# \rceil + 0x28 => [0x7B,0,1710], # { + 0x29 => [0x7D,0,1710], # } + 0x2A => [0x27E8,0,1710],# \langle + 0x2B => [0x27E9,0,1710],# \rangle + 0x2C => [0x2F,0,1710], # / + 0x2D => [0x5C,0,1710], # \ + 0x73 => [0x221A,0,1710],# surd + + 0x30 => [0x239B,0,1115],# left paren upper hook + 0x31 => [0x239E,0,1115],# right paren upper hook + 0x32 => [0x23A1,0,1115],# left square bracket upper corner + 0x33 => [0x23A4,0,1115],# right square bracket upper corner + 0x34 => [0x23A3,0,1115],# left square bracket lower corner + 0x35 => [0x23A6,0,1115],# right square bracket lower hook + 0x36 => [0x23A2,0,601], # left square bracket extension + 0x37 => [0x23A5,0,601], # right square bracket extension + 0x38 => [0x23A7,0,900], # left curly brace upper hook + 0x39 => [0x23AB,0,900], # right curly brace upper hook + 0x3A => 0x23A9, # left curly brace lower hook + 0x3B => 0x23AD, # right curly brace lower hook + 0x3C => [0x23A8,0,1150],# left curly brace middle + 0x3D => [0x23AC,0,1150],# right curly brace middle + 0x3E => [0x23AA,0,300], # curly brace extension + + 0x40 => [0x239D,0,1115],# left paren lower hook + 0x41 => [0x23A0,0,1115],# right paren lower hook + 0x42 => [0x239C,0,600], # left paren extension + 0x43 => [0x239F,0,600], # right paren extension + + 0x74 => [0x23B7,0,915], # radical bottom + 0x75 => [0xE000,0,605], # radical extension (PUA) + 0x76 => [0xE001,0,565], # radical top (PUA) + [0x7A,0x7D] => 0xE150, # \braceld, \bracerd, \bracelu, \braceru (PUA) + ], +}; + +$map{cmti10} = { + "Main-Italic" => [ + [0,1] => 0x393, # \Gamma, \Delta + 2 => 0x398, # \Theta + 3 => 0x39B, # \Lambda + 4 => 0x39E, # \Xi + 5 => 0x3A0, # \Pi + 6 => 0x3A3, # \Sigma + [7,8] => 0x3A5, # \Upsilon, \Phi + [9,0xA] => 0x3A8, # \Psi, \Omega + + 0x12 => 0x2CB, # \grave + 0x13 => 0x2CA, # \acute + 0x14 => 0x2C7, # \check + 0x15 => 0x2D8, # \breve + 0x16 => 0x2C9, # \bar + 0x17 => [0xB0,-160,0], # \degree + 0x17 => 0x02DA, # \r, ring above + 0x18 => 0xB8, # \c, cedilla + + [0x21,0x23] => 0x21, # !, ", #, + 0x22 => 0x201D, # " + [0x25,0x2F] => 0x25, # %, &, ', (, ), *, +, comma, -, ., / + 0x27 => 0x2019, # ' + [0x30,0x39] => 0x30, # 0-9 + [0x3A,0x3B] => 0x3A, # :, ; + 0x3D => 0x3D, # = + [0x3F,0x40] => 0x3F, # ?, @ + [0x41,0x5A] => 0x41, # A-Z + 0x5B => 0x5B, # [ + 0x5C => 0x201C, # `` + [0x5D,0x5E] => 0x5D, # ], ^ + 0x5E => 0x2C6, # \hat + 0x5F => 0x2D9, # \dot + 0x60 => 0x2018, # ` + [0x61,0x7A] => 0x61, # a-z + [0x7B,0x7C] => 0x2013, # \endash, \emdash + 0x7B => [0x5F,0,-310], # underline + 0x7D => 0x2DD, # double acute + 0x7E => [0x7E,0,-350], # ~ + 0x7E => 0x2DC, # \tilde + 0x7F => 0xA8, # \ddot + 0x19 => 0xDF, # sharp S + 0x1A => 0xE6, # ae ligature + 0x1B => 0x153, # oe ligature + 0x1C => 0xF8, # o with slash + 0x1D => 0xC6, # AE ligature + 0x1E => 0x152, # OE ligature + 0x1F => 0xD8, # O with slash + ], + + "Main-Regular" => [ + 0x24 => 0xA3, # pound sign + ], +}; + +$map{cmbx10} = { + "Main-Bold" => [ + [0,1] => 0x393, # \Gamma, \Delta + 2 => 0x398, # \Theta + 3 => 0x39B, # \Lambda + 4 => 0x39E, # \Xi + 5 => 0x3A0, # \Pi + 6 => 0x3A3, # \Sigma + [7,8] => 0x3A5, # \Upsilon, \Phi + [9,0xA] => 0x3A8, # \Psi, \Omega + + 0x10 => 0x131, # \i + 0x11 => 0x237, # \j + 0x12 => 0x2CB, # \grave + 0x13 => 0x2CA, # \acute + 0x14 => 0x2C7, # \check + 0x15 => 0x2D8, # \breve + 0x16 => 0x2C9, # \bar + 0x17 => [0xB0,-147,0], # \degree + 0x17 => 0x02DA, # \r, ring above + 0x18 => 0xB8, # \c, cedilla + + [0x21,0x2F] => 0x21, # !, ", #, $, %, &, ', (, ), *, +, comma, -, ., / + 0x22 => 0x201D, # " + 0x27 => 0x2019, # ' + [0x30,0x39] => 0x30, # 0-9 + [0x3A,0x3B] => 0x3A, # :, ; + 0x3D => 0x3D, # = + [0x3F,0x40] => 0x3F, # ?, @ + [0x41,0x5A] => 0x41, # A-Z + 0x5B => 0x5B, # [ + 0x5C => 0x201C, # `` + [0x5D,0x5E] => 0x5D, # ], ^ + 0x5E => 0x2C6, # \hat + 0x5F => 0x2D9, # \dot + 0x60 => 0x2018, # ` + [0x61,0x7A] => 0x61, # a-z + [0x7B,0x7C] => 0x2013, # \endash, \emdash + 0x7B => [0x5F,0,-310], # underline + 0x7D => 0x2DD, # double acute + 0x7E => [0x7E,0,-350], # ~ + 0x7E => 0x2DC, # \tilde + 0x7F => 0xA8, # \ddot + 0x19 => 0xDF, # sharp S + 0x1A => 0xE6, # ae ligature + 0x1B => 0x153, # oe ligature + 0x1C => 0xF8, # o with slash + 0x1D => 0xC6, # AE ligature + 0x1E => 0x152, # OE ligature + 0x1F => 0xD8, # O with slash + ], +}; + +$map{cmbxti10} = { + "Main-BoldItalic" => [ + [0,1] => 0x393, # \Gamma, \Delta + 2 => 0x398, # \Theta + 3 => 0x39B, # \Lambda + 4 => 0x39E, # \Xi + 5 => 0x3A0, # \Pi + 6 => 0x3A3, # \Sigma + [7,8] => 0x3A5, # \Upsilon, \Phi + [9,0xA] => 0x3A8, # \Psi, \Omega + + 0x10 => 0x131, # \i + 0x11 => 0x237, # \j + 0x12 => 0x2CB, # \grave + 0x13 => 0x2CA, # \acute + 0x14 => 0x2C7, # \check + 0x15 => 0x2D8, # \breve + 0x16 => 0x2C9, # \bar + 0x17 => [0xB0,-160,0], # \degree + 0x17 => 0x02DA, # \r, ring above + 0x18 => 0xB8, # \c, cedilla + + [0x21,0x23] => 0x21, # !, ", #, + 0x22 => 0x201D, # " + [0x25,0x2F] => 0x25, # %, &, ', (, ), *, +, comma, -, ., / + 0x27 => 0x2019, # ' + [0x30,0x39] => 0x30, # 0-9 + [0x3A,0x3B] => 0x3A, # :, ; + 0x3D => 0x3D, # = + [0x3F,0x40] => 0x3F, # ?, @ + [0x41,0x5A] => 0x41, # A-Z + 0x5B => 0x5B, # [ + 0x5C => 0x201C, # `` + [0x5D,0x5E] => 0x5D, # ], ^ + 0x5E => 0x2C6, # \hat + 0x5F => 0x2D9, # \dot + 0x60 => 0x2018, # ` + [0x61,0x7A] => 0x61, # a-z + [0x7B,0x7C] => 0x2013, # \endash, \emdash + 0x7B => [0x5F,0,-310], # underline + 0x7D => 0x2DD, # double acute + 0x7E => [0x7E,0,-350], # ~ + 0x7E => 0x2DC, # \tilde + 0x7F => 0xA8, # \ddot + 0x19 => 0xDF, # sharp S + 0x1A => 0xE6, # ae ligature + 0x1B => 0x153, # oe ligature + 0x1C => 0xF8, # o with slash + 0x1D => 0xC6, # AE ligature + 0x1E => 0x152, # OE ligature + 0x1F => 0xD8, # O with slash + ], + + "Main-Bold" => [ + 0x24 => 0xA3, # pound sign + ], +}; + +$map{cmmib10} = { + "Math-BoldItalic" => [ + [0,1] => 0x393, # \Gamma, \Delta + 2 => 0x398, # \Theta + 3 => 0x39B, # \Lambda + 4 => 0x39E, # \Xi + 5 => 0x3A0, # \Pi + 6 => 0x3A3, # \Sigma + [7,8] => 0x3A5, # \Upsilon, \Phi + [9,0xA] => 0x3A8, # \Psi, \Omega + + [0xB,0xE] => 0x3B1, # \alpha, \beta, \gamma, \delta + 0xF => 0x3F5, # \elpsilon + [0x10,0x18] => 0x3B6, # \zeta, \eta, \theta, \iota, \kappa, \lambda, \mu, \nu, \xi + [0x19,0x1A] => 0x3C0, # \pi, \rho + [0x1B,0x1D] => 0x3C3, # \sigma, \tau, \upsilon + 0x1E => 0x3D5, # \phi + [0x1F,0x21] => 0x3C7, # \chi, \psi, \omega + 0x22 => 0x3B5, # \varepsilon + 0x23 => 0x3D1, # \vartheta + 0x24 => 0x3D6, # \varpi + 0x25 => 0x3F1, # \varrho + 0x26 => 0x3C2, # \varsigma + 0x27 => 0x3C6, # \varphi + + [0x41,0x5A] => 0x41, # A-Z + [0x61,0x7A] => 0x61, # a - z + [0x30,0x39] => 0x30, # Oldstyle 0-9 + + 0x6F => 0x3BF, # omicron + 0x7B => 0xE131, # \imath (PUA) + 0x7C => 0xE237, # \jmath (PUA) + ], + + "Main-Bold" => [ + 0x28 => 0x21BC, # \leftharpoonup + 0x29 => 0x21BD, # \leftharpoondown + 0x2A => 0x21C0, # \rightharpoonup + 0x2B => 0x21C1, # \rightharpoondown + + 0x2E => 0x25B9, # \triangleright + 0x2F => 0x25C3, # \triangleleft + + 0x3C => 0x3C, # < + 0x3D => 0x2215, # / + 0x3E => 0x3E, # > + 0x3F => 0x22C6, # \star + 0x40 => 0x2202, # \partial + + [0x5B,0x5D] => 0x266D, # \flat, \natural, \sharp + 0x5E => 0x2323, # \smile + 0x5F => 0x2322, # \frown + 0x60 => 0x2113, # \ell + 0x68 => 0x210F, # \hbar (bar added below) + + 0x7D => 0x2118, # \wp + 0x7E => [0x20D7,-729,0],# \vec + ], +}; + +$map{cmbsy10} = { + "Main-Bold" => [ + 0 => 0x2212, # - + 1 => 0x22C5, # \cdot + 2 => 0xD7, # \times + 3 => 0x2217, # \ast + 4 => 0xF7, # \div + 5 => 0x22C4, # \diamond + 6 => 0xB1, # \pm + 7 => 0x2213, # \mp + [8,0xC] => 0x2295, # \oplus, \ominus, \otimes, \oslash, \odot + 0xD => 0x25EF, # \bigcirc + [0xE,0xF] => 0x2218, # \circ, \bullet + + 0x10 => 0x224D, # \asymp + 0x11 => 0x2261, # \equiv + [0x12,0x13] => 0x2286, # \subseteq, \supseteq + [0x14,0x15] => 0x2264, # \leq, \geq + [0x16,0x17] => 0x2AAF, # \preceq, \succeq + 0x18 => 0x223C, # \sim + 0x19 => 0x2248, # \approx + [0x1A,0x1B] => 0x2282, # \subset, \supset + [0x1C,0x1D] => 0x226A, # \ll, \gg + [0x1E,0x1F] => 0x227A, # \prec, \succ + + 0x20 => 0x2190, # \leftarrow + 0x21 => 0x2192, # \rightarrow + 0x22 => 0x2191, # \uparrow + 0x23 => 0x2193, # \downarrow + 0x24 => 0x2194, # \leftrightarrow + 0x25 => 0x2197, # \nearrow + 0x26 => 0x2198, # \searrow + 0x27 => 0x2243, # \simeq + + 0x28 => 0x21D0, # \Leftarrow + 0x29 => 0x21D2, # \Rightarrow + 0x2A => 0x21D1, # \Uparrow + 0x2B => 0x21D3, # \Downarrow + 0x2C => 0x21D4, # \Leftrightarrow + 0x2D => 0x2196, # \nwarrow + 0x2E => 0x2199, # \swarrow + 0x2F => 0x221D, # \propto + + 0x30 => 0x2032, # \prime + 0x31 => 0x221E, # \infty + 0x32 => 0x2208, # \in + 0x33 => 0x220B, # \ni + 0x34 => 0x25B3, # \bigtriangleup and \triangle + 0x35 => 0x25BD, # \bigtriangledown + 0x36 => 0xE020, # \not + + 0x38 => 0x2200, # \forall + 0x39 => 0x2203, # \exists + 0x3A => 0xAC, # \neg + 0x3B => 0x2205, # \emptyset + 0x3C => 0x211C, # \Re + 0x3D => 0x2111, # \Im + 0x3E => 0x22A4, # \top + 0x3F => 0x22A5, # \bot + + 0x40 => 0x2135, # \aleph + + 0x5B => 0x222A, # \cup + 0x5C => 0x2229, # \cap + 0x5D => 0x228E, # \uplus + [0x5E,0x5F] => 0x2227, # \wedge, \vee + + [0x60,0x61] => 0x22A2, # \vdash, \dashv + [0x62,0x63] => 0x230A, # \lfloor, \rfloor + [0x64,0x65] => 0x2308, # \lceil, \rceil + 0x66 => 0x7B, # { + 0x67 => 0x7D, # } + [0x68,0x69] => 0x27E8, # \langle, \rangle + 0x6A => 0x7C, # | + 0x6A => 0x2223, # \vert + 0x6B => 0x2225, # \Vert + 0x6C => 0x2195, # \updownarrow + 0x6D => 0x21D5, # \Updownarrow + 0x6E => 0x5C, # \backslash + 0x6E => 0x2216, # \setminus + 0x6F => 0x2240, # \wr + + 0x70 => [0x221A,0,760], # \surd ### adjust position so font doesn't have a large depth + 0x71 => 0x2A3F, # \amalg + 0x72 => 0x2207, # \nabla + 0x73 => 0x222B, # \int + 0x74 => 0x2294, # \sqcup + 0x75 => 0x2293, # \sqcap + [0x76,0x77] => 0x2291, # \sqsubseteq, \sqsupseteq + + [0x79,0x7A] => 0x2020, # \dagger, \ddagger + + 0x7C => 0x2663, # \clubsuit + 0x7D => 0x2662, # \diamondsuit + 0x7E => 0x2661, # \heartsuit + 0x7F => 0x2660, # \spadesuit + ], +}; + +$map{msam10} = { + "Main-Regular" => [ + 0x5C => 0x2220, # \angle + ], + + "Main-Bold" => [ + 0x5C => 0x2220, # \angle (emboldened below) + ], + + "AMS" => [ + 0x00 => 0x22A1, # \boxdot + 0x01 => 0x229E, # \boxplus + 0x02 => 0x22A0, # \boxtimes + 0x03 => 0x25A1, # \square + 0x04 => 0x25A0, # \blacksquare + 0x05 => 0x22C5, # \centerdot + 0x06 => 0x25CA, # \lozenge + 0x07 => 0x29EB, # \blacklozenge + 0x08 => 0x21BB, # \circlearrowright + 0x09 => 0x21BA, # \circlearrowleft + 0x0A => 0x21CC, # \rightleftharpoons + 0x0B => 0x21CB, # \leftrightharpoons + 0x0C => 0x229F, # \boxminus + 0x0D => 0x22A9, # \Vdash + 0x0E => 0x22AA, # \Vvdash + 0x0F => 0x22A8, # \vDash + 0x10 => 0x21A0, # \twoheadrightarrow + 0x11 => 0x219E, # \twoheadleftarrow + 0x12 => 0x21C7, # \leftleftarrows + 0x13 => 0x21C9, # \rightrightarrows + 0x14 => 0x21C8, # \upuparrows + 0x15 => 0x21CA, # \downdownarrows + 0x16 => 0x21BE, # \upharpoonright + 0x17 => 0x21C2, # \downharpoonright + 0x18 => 0x21BF, # \upharpoonleft + 0x19 => 0x21C3, # \downharpoonleft + 0x1A => 0x21A3, # \rightarrowtail + 0x1B => 0x21A2, # \leftarrowtail + 0x1C => 0x21C6, # \leftrightarrows + 0x1D => 0x21C4, # \rightleftarrows + 0x1E => 0x21B0, # \Lsh + 0x1F => 0x21B1, # \Rsh + 0x20 => 0x21DD, # \rightsquigarrow + 0x21 => 0x21AD, # \leftrightsquigarrow + 0x22 => 0x21AB, # \looparrowleft + 0x23 => 0x21AC, # \looparrowright + 0x24 => 0x2257, # \circeq + 0x25 => 0x227F, # \succsim + 0x26 => 0x2273, # \gtrsim + 0x27 => 0x2A86, # \gtrapprox + 0x28 => 0x22B8, # \multimap + 0x29 => 0x2234, # \therefore + 0x2A => 0x2235, # \because + 0x2B => 0x2251, # \doteqdot + 0x2C => 0x225C, # \triangleq + 0x2D => 0x227E, # \precsim + 0x2E => 0x2272, # \lesssim + 0x2F => 0x2A85, # \lessapprox + 0x30 => 0x2A95, # \eqslantless + 0x31 => 0x2A96, # \eqslantgtr + 0x32 => 0x22DE, # \curlyeqprec + 0x33 => 0x22DF, # \curlyeqsucc + 0x34 => 0x227C, # \preccurlyeq + 0x35 => 0x2266, # \leqq + 0x36 => 0x2A7D, # \leqslant + 0x37 => 0x2276, # \lessgtr + 0x38 => 0x2035, # \backprime + 0x39 => 0x2212, # dahsed arrow extension + 0x3A => 0x2253, # \risingdotseq + 0x3B => 0x2252, # \fallingdotseq + 0x3C => 0x227D, # \succcurlyeq + 0x3D => 0x2267, # \geqq + 0x3E => 0x2A7E, # \geqslant + 0x3F => 0x2277, # \gtrless + 0x40 => 0x228F, # \sqsubset + 0x41 => 0x2290, # \sqsupset + 0x42 => 0x22B3, # \vartriangleright + 0x43 => 0x22B2, # \vartriangleleft + 0x44 => 0x22B5, # \trianglerighteq + 0x45 => 0x22B4, # \trianglelefteq + 0x46 => 0x2605, # \bigstar + 0x47 => 0x226C, # \between + 0x48 => 0x25BC, # \blacktriangledown + 0x49 => 0x25B6, # \blacktriangleright + 0x4A => 0x25C0, # \blacktriangleleft + 0x4B => 0x2192, # rightarrow + 0x4C => 0x2190, # leftarrow + 0x4D => 0x25B3, # \vartriangle + 0x4E => 0x25B2, # \blacktriangle + 0x4F => 0x25BD, # \triangledown + 0x50 => 0x2256, # \eqcirc + 0x51 => 0x22DA, # \lesseqgtr + 0x52 => 0x22DB, # \gtreqless + 0x53 => 0x2A8B, # \lesseqqgtr + 0x54 => 0x2A8C, # \gtreqqless + 0x55 => 0x00A5, # yen + 0x56 => 0x21DB, # \Rrightarrow + 0x57 => 0x21DA, # \Lleftarrow + 0x58 => 0x2713, # checkmark + 0x59 => 0x22BB, # \veebar + 0x5A => 0x22BC, # \barwedge + 0x5B => 0x2A5E, # \doublebarwedge + 0x5C => 0x2220, # \angle + 0x5D => 0x2221, # \measuredangle + 0x5E => 0x2222, # \sphericalangle + 0x5F => 0x221D, # \varpropto + 0x60 => 0x2323, # \smallsmile + 0x61 => 0x2322, # \smallfrown + 0x62 => 0x22D0, # \Subset + 0x63 => 0x22D1, # \Supset + 0x64 => 0x22D3, # \Cup + 0x65 => 0x22D2, # \Cap + 0x66 => 0x22CF, # \curlywedge + 0x67 => 0x22CE, # \curlyvee + 0x68 => 0x22CB, # \leftthreetimes + 0x69 => 0x22CC, # \rightthreetimes + 0x6A => 0x2AC5, # \subseteqq + 0x6B => 0x2AC6, # \supseteqq + 0x6C => 0x224F, # \bumpeq + 0x6D => 0x224E, # \Bumpeq + 0x6E => 0x22D8, # \lll + 0x6F => 0x22D9, # \ggg + 0x70 => 0x250C, # \ulcorner + 0x71 => 0x2510, # \urcorner + 0x72 => 0x00AE, # registered sign + 0x73 => 0x24C8, # \circledS + 0x74 => 0x22D4, # \pitchfork + 0x75 => 0x2214, # \dotplus + 0x76 => 0x223D, # \backsim + 0x77 => 0x22CD, # \backsimeq + 0x78 => 0x2514, # \llcorner + 0x79 => 0x2518, # \lrcorner + 0x7A => 0x2720, # maltese cross + 0x7B => 0x2201, # \complement + 0x7C => 0x22BA, # \intercal + 0x7D => 0x229A, # \circledcirc + 0x7E => 0x229B, # \circledast + 0x7F => 0x229D, # \circleddash + ], +}; + +$map{msbm10} = { + "Size4" => [ + 0x5B => 0x2C6, # \widehat + 0x5B => [0x302,-1889,0],# \widehat (combining) + 0x5D => 0x2DC, # \widetilde + 0x5D => [0x303,-1889,0],# \widetilde (combining) + ], + + "Main-Regular" => [ + 0x7E => 0x210F, # \hbar + ], + + "Main-Italic" => [ + 0x7D => 0x210F, # \hbar (with slant) + ], + + "AMS" => [ + 0x00 => 0xE00C, # \lvertneqq + 0x01 => 0xE00D, # \gvertneqq + 0x02 => 0x2270, # \nleq + 0x03 => 0x2271, # \ngeq + 0x04 => 0x226E, # \nless + 0x05 => 0x226F, # \ngtr + 0x06 => 0x2280, # \nprec + 0x07 => 0x2281, # \nsucc + 0x08 => 0x2268, # \lneqq + 0x09 => 0x2269, # \gneqq + 0x0A => 0xE010, # \nleqslant + 0x0B => 0xE00F, # \ngeqslant + 0x0C => 0x2A87, # \lneq + 0x0D => 0x2A88, # \gneq + 0x0E => 0x22E0, # \npreceq + 0x0F => 0x22E1, # \nsucceq + 0x10 => 0x22E8, # \precnsim + 0x11 => 0x22E9, # \succnsim + 0x12 => 0x22E6, # \lnsim + 0x13 => 0x22E7, # \gnsim + 0x14 => 0xE011, # \nleqq + 0x15 => 0xE00E, # \ngeqq + 0x16 => 0x2AB5, # \precneqq + 0x17 => 0x2AB6, # \succneqq + 0x18 => 0x2AB9, # \precnapprox + 0x19 => 0x2ABA, # \succnapprox + 0x1A => 0x2A89, # \lnapprox + 0x1B => 0x2A8A, # \gnapprox + 0x1C => 0x2241, # \nsim + 0x1D => 0x2246, # \ncong + 0x1E => 0x2571, # \diagup + 0x1F => 0x2572, # \diagdown + 0x20 => 0xE01A, # \varsubsetneq + 0x21 => 0xE01B, # \varsupsetneq + 0x22 => 0xE016, # \nsubseteqq + 0x23 => 0xE018, # \nsupseteqq + 0x24 => 0x2ACB, # \subsetneqq + 0x25 => 0x2ACC, # \supsetneqq + 0x26 => 0xE017, # \varsubsetneqq + 0x27 => 0xE019, # \varsupsetneqq + 0x28 => 0x228A, # \subsetneq + 0x29 => 0x228B, # \supsetneq + 0x2A => 0x2288, # \nsubseteq + 0x2B => 0x2289, # \nsupseteq + 0x2C => 0x2226, # \nparallel + 0x2D => 0x2224, # \nmid + 0x2E => 0xE006, # \nshortmid + 0x2F => 0xE007, # \nshortparallel + 0x30 => 0x22AC, # \nvdash + 0x31 => 0x22AE, # \nVdash + 0x32 => 0x22AD, # \nvDash + 0x33 => 0x22AF, # \nVDash + 0x34 => 0x22ED, # \ntrianglerighteq + 0x35 => 0x22EC, # \ntrianglelefteq + 0x36 => 0x22EA, # \ntriangleleft + 0x37 => 0x22EB, # \ntriangleright + 0x38 => 0x219A, # \nleftarrow + 0x39 => 0x219B, # \nrightarrow + 0x3A => 0x21CD, # \nLeftarrow + 0x3B => 0x21CF, # \nRightarrow + 0x3C => 0x21CE, # \nLeftrightarrow + 0x3D => 0x21AE, # \nleftrightarrow + 0x3E => 0x22C7, # \divideontimes + 0x3F => 0x2205, # \varnothing + 0x40 => 0x2204, # \nexists + + [0x41,0x5A] => 0x41, # A-Z + 0x5C => 0x2C6, # \widehat + 0x5C => [0x302,-2333,0],# \widehat (combining) + 0x5E => 0x2DC, # \widetilde + 0x5E => [0x303,-2333,0],# \widetilde (combining) + + 0x60 => 0x2132, # \Finv + 0x61 => 0x2141, # \Game + 0x66 => 0x2127, # \mho + 0x67 => 0x00F0, # \eth + 0x68 => 0x2242, # minus-tilde + 0x69 => 0x2136, # \beth + 0x6A => 0x2137, # \gimel + 0x6B => 0x2138, # \daleth + 0x6C => 0x22D6, # \lessdot + 0x6D => 0x22D7, # \gtrdot + 0x6E => 0x22C9, # \ltimes + 0x6F => 0x22CA, # \rtimes + 0x70 => 0x2223, # \shortmid + 0x71 => 0x2225, # \shortparallel + 0x72 => 0x2216, # \smallsetminus + 0x73 => 0x223C, # \thicksim + 0x74 => 0x2248, # \thickapprox + 0x75 => 0x224A, # \approxeq + 0x76 => 0x2AB8, # \succapprox + 0x77 => 0x2AB7, # \precapprox + 0x78 => 0x21B6, # \curvearrowleft + 0x79 => 0x21B7, # \curvearrowright + 0x7A => 0x03DD, # \digamma + 0x7B => 0x03F0, # \varkappa + 0x7A => 0xE008, # \digamma (non-standard, for IE) + 0x7B => 0xE009, # \varkappa (non-standard, for IE) + 0x7C => 0x006B, # \Bbbk + 0x7D => 0x210F, # \hslash + 0x7E => 0x0127, # \hbar + 0x7F => 0x220D, # \backepsilon + ], +}; + +$map{eufm10} = { + "Fraktur-Regular" => [ + [0,7] => 0xE300, # variants + 0x12 => 0x2018, # left quote + 0x13 => 0x2019, # right quote + 0x21 => 0x21, # ! + [0x26,0x2F] => 0x26, # &, ', (, ), *, +, comma, -, ., / + [0x30,0x39] => 0x30, # 0-9 + [0x3A,0x3B] => 0x3A, # :, ; + 0x3D => 0x3D, # = + 0x3F => 0x3F, # ? + [0x41,0x5A] => 0x41, # A-Z + 0x5B => 0x5B, # [ + [0x5D,0x5E] => 0x5D, # ], ^ + [0x61,0x7A] => 0x61, # a-z + 0x7D => 0x22, # " + ], +}; + +$map{cmtt10} = { + "Typewriter-Regular" => [ + [0,1] => 0x393, # \Gamma, \Delta + 2 => 0x398, # \Theta + 3 => 0x39B, # \Lambda + 4 => 0x39E, # \Xi + 5 => 0x3A0, # \Pi + 6 => 0x3A3, # \Sigma + [7,8] => 0x3A5, # \Upsilon, \Phi + [9,0xA] => 0x3A8, # \Psi, \Omega + 0xD => 0x2032, # ' + + 0x10 => 0x131, # \i + 0x11 => 0x237, # \j + 0x12 => 0x2CB, # \grave + 0x13 => 0x2CA, # \acute + 0x14 => 0x2C7, # \check + 0x15 => 0x2D8, # \breve + 0x16 => 0x2C9, # \bar + 0x17 => 0xB0, # \degree + 0x17 => 0x02DA, # \r, ring above + 0x18 => 0xB8, # \c, cedilla + 0x20 => 0x2423, # graphic representation of space + + [0x21,0x7F] => 0x21, + + 0x27 => 0x2018, # left quote + 0x60 => 0x2019, # right quote + 0x5E => [0x302,-525,0], # \hat (combining) + 0x7E => [0x303,-525,0], # \tilde (combining) + 0x7F => [0x308,-525,0], # \ddot (combining) + ], +}; + +$map{rsfs10} = { + "Script-Regular" => [ + [0x41,0x5A] => 0x41, # A-Z + ], +}; + +$map{cmssbx10} = { + "SansSerif-Bold" => [ + [0,1] => 0x393, # \Gamma, \Delta + 2 => 0x398, # \Theta + 3 => 0x39B, # \Lambda + 4 => 0x39E, # \Xi + 5 => 0x3A0, # \Pi + 6 => 0x3A3, # \Sigma + [7,8] => 0x3A5, # \Upsilon, \Phi + [9,0xA] => 0x3A8, # \Psi, \Omega + + 0x10 => 0x131, # \i + 0x11 => 0x237, # \j + 0x13 => 0xB4, # \acute + 0x14 => 0x2C7, # \check + 0x15 => 0x2D8, # \breve + 0x16 => 0x2C9, # \bar + 0x17 => [0xB0,-58,0], # \degree + 0x17 => 0x02DA, # \r, ring above + 0x18 => 0xB8, # \c, cedilla + + [0x21,0x2F] => 0x21, # !, ", #, $, %, &, ', (, ), *, +, comma, -, ., / + 0x22 => 0x201D, # " + 0x27 => 0x2019, # ' + [0x30,0x39] => 0x30, # 0-9 + [0x3A,0x3B] => 0x3A, # :, ; + 0x3D => 0x3D, # = + [0x3F,0x40] => 0x3F, # ?, @ + [0x41,0x5A] => 0x41, # A-Z + 0x5B => 0x5B, # [ + 0x5C => 0x201C, # `` + [0x5D,0x5E] => 0x5D, # ], ^ + 0x5E => 0x2C6, # \hat + 0x5F => 0x2D9, # \dot + 0x60 => 0x2018, # ` + [0x61,0x7A] => 0x61, # a-z + [0x7B,0x7C] => 0x2013, # \endash, \emdash + 0x7B => [0x5F,0,-350], # underline + 0x7D => 0x2DD, # double acute + 0x7E => [0x7E,0,-350], # ~ + 0x7E => 0x2DC, # \tilde + 0x7F => 0xA8, # \ddot + ], +}; + +$map{cmss10} = { + "SansSerif-Regular" => [ + [0,1] => 0x393, # \Gamma, \Delta + 2 => 0x398, # \Theta + 3 => 0x39B, # \Lambda + 4 => 0x39E, # \Xi + 5 => 0x3A0, # \Pi + 6 => 0x3A3, # \Sigma + [7,8] => 0x3A5, # \Upsilon, \Phi + [9,0xA] => 0x3A8, # \Psi, \Omega + + 0x10 => 0x131, # \i + 0x11 => 0x237, # \j + 0x12 => 0x2CB, # \grave + 0x13 => 0x2CA, # \acute + 0x14 => 0x2C7, # \check + 0x15 => 0x2D8, # \breve + 0x16 => 0x2C9, # \bar + 0x17 => [0xB0,-142,0], # \degree + 0x17 => 0x02DA, # \r, ring above + 0x18 => 0xB8, # \c, cedilla + + [0x21,0x2F] => 0x21, # !, ", #, $, %, &, ', (, ), *, +, comma, -, ., / + 0x22 => 0x201D, # " + 0x27 => 0x2019, # ' + [0x30,0x39] => 0x30, # 0-9 + [0x3A,0x3B] => 0x3A, # :, ; + 0x3D => 0x3D, # = + [0x3F,0x40] => 0x3F, # ?, @ + [0x41,0x5A] => 0x41, # A-Z + 0x5B => 0x5B, # [ + 0x5C => 0x201C, # `` + [0x5D,0x5E] => 0x5D, # ], ^ + 0x5E => 0x2C6, # \hat + 0x5F => 0x2D9, # \dot + 0x60 => 0x2018, # ` + [0x61,0x7A] => 0x61, # a-z + [0x7B,0x7C] => 0x2013, # \endash, \emdash + 0x7B => [0x5F,0,-350], # underline + 0x7D => 0x2DD, # double acute + 0x7E => [0x7E,0,-350], # ~ + 0x7E => 0x2DC, # \tilde + 0x7F => 0xA8, # \ddot + ], +}; + +$map{cmssi10} = { + "SansSerif-Italic" => [ + [0,1] => 0x393, # \Gamma, \Delta + 2 => 0x398, # \Theta + 3 => 0x39B, # \Lambda + 4 => 0x39E, # \Xi + 5 => 0x3A0, # \Pi + 6 => 0x3A3, # \Sigma + [7,8] => 0x3A5, # \Upsilon, \Phi + [9,0xA] => 0x3A8, # \Psi, \Omega + + 0x10 => 0x131, # \i + 0x11 => 0x237, # \j + 0x12 => 0x2CB, # \grave + 0x13 => 0x2CA, # \acute + 0x14 => 0x2C7, # \check + 0x15 => 0x2D8, # \breve + 0x16 => 0x2C9, # \bar + 0x17 => [0xB0,-113,0], # \degree + 0x17 => 0x02DA, # \r, ring above + 0x18 => 0xB8, # \c, cedilla + + [0x21,0x2F] => 0x21, # !, ", #, $, %, &, ', (, ), *, +, comma, -, ., / + 0x22 => 0x201D, # " + 0x27 => 0x2019, # ' + [0x30,0x39] => 0x30, # 0-9 + [0x3A,0x3B] => 0x3A, # :, ; + 0x3D => 0x3D, # = + [0x3F,0x40] => 0x3F, # ?, @ + [0x41,0x5A] => 0x41, # A-Z + 0x5B => 0x5B, # [ + 0x5C => 0x201C, # `` + [0x5D,0x5E] => 0x5D, # ], ^ + 0x5E => 0x2C6, # \hat + 0x5F => 0x2D9, # \dot + 0x60 => 0x2018, # ` + [0x61,0x7A] => 0x61, # a-z + [0x7B,0x7C] => 0x2013, # \endash, \emdash + 0x7B => [0x5F,0,-350], # underline + 0x7D => 0x2DD, # double acute + 0x7E => [0x7E,0,-350], # ~ + 0x7E => 0x2DC, # \tilde + 0x7F => 0xA8, # \ddot + ], +}; + +foreach $cmfont (keys %map) { + foreach $mjfont (keys %{$map{$cmfont}}) { + $style = $mjfont; $style =~ s/.*?(-|$)//; $style = "Regular" unless $style; + $family = $mjfont; $family =~ s/-.*//; + $fontname = "$family-$style"; + @{$reverse{$fontname}{$cmfont}} = @{$map{$cmfont}{$mjfont}}; + } +} + +my %output; + +sub add_to_output { + my ($mjfont,$cmfont,$from,$to) = @_; + + my $xshift = 0, $yshift = 0; + + if (ref($to) eq "ARRAY") { + $xshift = $to->[1]; + $yshift = $to->[2]; + $to = $to->[0]; + } + + $data = { + "font" => $cmfont, + "char" => $from, + "xshift" => $xshift, + "yshift" => $yshift + }; + + if (defined($output{$mjfont}{$to})) { + print STDERR "Duplicate mapping $to for $mjfont: " . + $output{$mjfont}{$to}{font} . ":" . + $output{$mjfont}{$to}{char} . " vs. $cmfont:$from\n"; + die "Duplicate mapping!"; # disable this line to see all of them + } + $output{$mjfont}{$to} = $data; +} + +foreach $mjfont (keys %reverse) { + foreach $cmfont (keys %{$reverse{$mjfont}}) { + @remap = @{$reverse{$mjfont}{$cmfont}}; + while (defined($item = shift(@remap))) { + $remap = shift(@remap); + + if (ref($item) eq "ARRAY") { + foreach $from ($item->[0]...$item->[1]) { + $to = $from - $item->[0] + $remap; + add_to_output($mjfont, $cmfont, $from, $to); + } + } else { + add_to_output($mjfont, $cmfont, $item, $remap); + } + } + } +} + +print(encode_json(\%output)); diff --git a/node_modules/react-katex/node_modules/katex/src/metrics/parse_tfm.py b/node_modules/react-katex/node_modules/katex/src/metrics/parse_tfm.py new file mode 100644 index 0000000..56f2db0 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/metrics/parse_tfm.py @@ -0,0 +1,211 @@ +class CharInfoWord(object): + def __init__(self, word): + b1, b2, b3, b4 = (word >> 24, + (word & 0xff0000) >> 16, + (word & 0xff00) >> 8, + word & 0xff) + + self.width_index = b1 + self.height_index = b2 >> 4 + self.depth_index = b2 & 0x0f + self.italic_index = (b3 & 0b11111100) >> 2 + self.tag = b3 & 0b11 + self.remainder = b4 + + def has_ligkern(self): + return self.tag == 1 + + def ligkern_start(self): + return self.remainder + + +class LigKernProgram(object): + def __init__(self, program): + self.program = program + + def execute(self, start, next_char): + curr_instruction = start + while True: + instruction = self.program[curr_instruction] + (skip, inst_next_char, op, remainder) = instruction + + if inst_next_char == next_char: + if op < 128: + # Don't worry about ligatures for now, we only need kerns + return None + else: + return 256 * (op - 128) + remainder + elif skip >= 128: + return None + else: + curr_instruction += 1 + skip + + +class TfmCharMetrics(object): + def __init__(self, width, height, depth, italic, kern_table): + self.width = width + self.height = height + self.depth = depth + self.italic_correction = italic + self.kern_table = kern_table + + +class TfmFile(object): + def __init__(self, start_char, end_char, char_info, width_table, + height_table, depth_table, italic_table, ligkern_table, + kern_table): + self.start_char = start_char + self.end_char = end_char + self.char_info = char_info + self.width_table = width_table + self.height_table = height_table + self.depth_table = depth_table + self.italic_table = italic_table + self.ligkern_program = LigKernProgram(ligkern_table) + self.kern_table = kern_table + + def get_char_metrics(self, char_num, fix_rsfs=False): + """Return glyph metrics for a unicode code point. + + Arguments: + char_num: a unicode code point + fix_rsfs: adjust for rsfs10.tfm's different indexing system + """ + if char_num < self.start_char or char_num > self.end_char: + raise RuntimeError("Invalid character number") + + if fix_rsfs: + # all of the char_nums contained start from zero in rsfs10.tfm + info = self.char_info[char_num - self.start_char] + else: + info = self.char_info[char_num + self.start_char] + + char_kern_table = {} + if info.has_ligkern(): + for char in range(self.start_char, self.end_char + 1): + kern = self.ligkern_program.execute(info.ligkern_start(), char) + if kern: + char_kern_table[char] = self.kern_table[kern] + + return TfmCharMetrics( + self.width_table[info.width_index], + self.height_table[info.height_index], + self.depth_table[info.depth_index], + self.italic_table[info.italic_index], + char_kern_table) + + +class TfmReader(object): + def __init__(self, f): + self.f = f + + def read_byte(self): + return ord(self.f.read(1)) + + def read_halfword(self): + b1 = self.read_byte() + b2 = self.read_byte() + return (b1 << 8) | b2 + + def read_word(self): + b1 = self.read_byte() + b2 = self.read_byte() + b3 = self.read_byte() + b4 = self.read_byte() + return (b1 << 24) | (b2 << 16) | (b3 << 8) | b4 + + def read_fixword(self): + word = self.read_word() + + neg = False + if word & 0x80000000: + neg = True + word = (-word & 0xffffffff) + + return (-1 if neg else 1) * word / float(1 << 20) + + def read_bcpl(self, length): + str_length = self.read_byte() + data = self.f.read(length - 1) + return data[:str_length] + + +def read_tfm_file(file_name): + with open(file_name, 'rb') as f: + reader = TfmReader(f) + + # file_size + reader.read_halfword() + header_size = reader.read_halfword() + + start_char = reader.read_halfword() + end_char = reader.read_halfword() + + width_table_size = reader.read_halfword() + height_table_size = reader.read_halfword() + depth_table_size = reader.read_halfword() + italic_table_size = reader.read_halfword() + + ligkern_table_size = reader.read_halfword() + kern_table_size = reader.read_halfword() + + # extensible_table_size + reader.read_halfword() + # parameter_table_size + reader.read_halfword() + + # checksum + reader.read_word() + # design_size + reader.read_fixword() + + if header_size > 2: + # coding_scheme + reader.read_bcpl(40) + + if header_size > 12: + # font_family + reader.read_bcpl(20) + + for i in range(header_size - 17): + reader.read_word() + + char_info = [] + for i in range(start_char, end_char + 1): + char_info.append(CharInfoWord(reader.read_word())) + + width_table = [] + for i in range(width_table_size): + width_table.append(reader.read_fixword()) + + height_table = [] + for i in range(height_table_size): + height_table.append(reader.read_fixword()) + + depth_table = [] + for i in range(depth_table_size): + depth_table.append(reader.read_fixword()) + + italic_table = [] + for i in range(italic_table_size): + italic_table.append(reader.read_fixword()) + + ligkern_table = [] + for i in range(ligkern_table_size): + skip = reader.read_byte() + next_char = reader.read_byte() + op = reader.read_byte() + remainder = reader.read_byte() + + ligkern_table.append((skip, next_char, op, remainder)) + + kern_table = [] + for i in range(kern_table_size): + kern_table.append(reader.read_fixword()) + + # There is more information, like the ligkern, kern, extensible, and + # param table, but we don't need these for now + + return TfmFile(start_char, end_char, char_info, width_table, + height_table, depth_table, italic_table, + ligkern_table, kern_table) diff --git a/node_modules/react-katex/node_modules/katex/src/parseNode.ts b/node_modules/react-katex/node_modules/katex/src/parseNode.ts new file mode 100644 index 0000000..65e8102 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/parseNode.ts @@ -0,0 +1,518 @@ +import {NON_ATOMS} from "./atoms"; +import type {Atom} from "./atoms"; +import type SourceLocation from "./SourceLocation"; +import type {AlignSpec, ColSeparationType} from "./environments/array"; +import type {DelimiterSize, Mode, StyleStr} from "./types"; +import type {MathFont} from "./types/fonts"; +import type {Token} from "./Token"; +import type {Measurement} from "./units"; +export type NodeType = keyof ParseNodeTypes; +export type ParseNode = ParseNodeTypes[TYPE]; + +// ParseNode's corresponding to Symbol `Group`s in symbols.js. +export type SymbolParseNode = + ParseNode<"atom"> | + ParseNode<"accent-token"> | + ParseNode<"mathord"> | + ParseNode<"op-token"> | + ParseNode<"spacing"> | + ParseNode<"textord">; + +// ParseNode from `Parser.formatUnsupportedCmd` +export type UnsupportedCmdParseNode = ParseNode<"color">; + +// Union of all possible `ParseNode<>` types. +export type AnyParseNode = ParseNodeTypes[keyof ParseNodeTypes]; + +// Map from `NodeType` to the corresponding `ParseNode`. +type ParseNodeTypes = { + "array": { + type: "array"; + mode: Mode; + loc?: SourceLocation | null | undefined; + colSeparationType?: ColSeparationType; + hskipBeforeAndAfter?: boolean; + addJot?: boolean; + cols?: AlignSpec[]; + arraystretch: number; + body: AnyParseNode[][]; + // List of rows in the (2D) array. + rowGaps: (Measurement | null | undefined)[]; + hLinesBeforeRow: Array; + // Whether each row should be automatically numbered, or an explicit tag + tags?: (boolean | AnyParseNode[])[]; + leqno?: boolean; + isCD?: boolean; + }; + "cdlabel": { + type: "cdlabel"; + mode: Mode; + loc?: SourceLocation | null | undefined; + side: string; + label: AnyParseNode; + }; + "cdlabelparent": { + type: "cdlabelparent"; + mode: Mode; + loc?: SourceLocation | null | undefined; + fragment: AnyParseNode; + }; + "color": { + type: "color"; + mode: Mode; + loc?: SourceLocation | null | undefined; + color: string; + body: AnyParseNode[]; + }; + "color-token": { + type: "color-token"; + mode: Mode; + loc?: SourceLocation | null | undefined; + color: string; + }; + // To avoid requiring run-time type assertions, this more carefully captures + // the requirements on the fields per the op.js htmlBuilder logic: + // - `body` and `value` are NEVER set simultaneously. + // - When `symbol` is true, `body` is set. + "op": { + type: "op"; + mode: Mode; + loc?: SourceLocation | null | undefined; + limits: boolean; + alwaysHandleSupSub?: boolean; + suppressBaseShift?: boolean; + parentIsSupSub: boolean; + symbol: boolean; + name: string; + body?: void; + } | { + type: "op"; + mode: Mode; + loc?: SourceLocation | null | undefined; + limits: boolean; + alwaysHandleSupSub?: boolean; + suppressBaseShift?: boolean; + parentIsSupSub: boolean; + symbol: false; + // If 'symbol' is true, `body` *must* be set. + name?: void; + body: AnyParseNode[]; + }; + "ordgroup": { + type: "ordgroup"; + mode: Mode; + loc?: SourceLocation | null | undefined; + body: AnyParseNode[]; + semisimple?: boolean; + }; + "raw": { + type: "raw"; + mode: Mode; + loc?: SourceLocation | null | undefined; + string: string; + }; + "size": { + type: "size"; + mode: Mode; + loc?: SourceLocation | null | undefined; + value: Measurement; + isBlank: boolean; + }; + "styling": { + type: "styling"; + mode: Mode; + loc?: SourceLocation | null | undefined; + style: StyleStr; + resetFont?: boolean; + body: AnyParseNode[]; + }; + "supsub": { + type: "supsub"; + mode: Mode; + loc?: SourceLocation | null | undefined; + base: AnyParseNode | null | undefined; + sup?: AnyParseNode | null | undefined; + sub?: AnyParseNode | null | undefined; + }; + "tag": { + type: "tag"; + mode: Mode; + loc?: SourceLocation | null | undefined; + body: AnyParseNode[]; + tag: AnyParseNode[]; + }; + "text": { + type: "text"; + mode: Mode; + loc?: SourceLocation | null | undefined; + body: AnyParseNode[]; + font?: string; + }; + "url": { + type: "url"; + mode: Mode; + loc?: SourceLocation | null | undefined; + url: string; + }; + "verb": { + type: "verb"; + mode: Mode; + loc?: SourceLocation | null | undefined; + body: string; + star: boolean; + }; + // From symbol groups, constructed in Parser.js via `symbols` lookup. + // (Some of these have "-token" suffix to distinguish them from existing + // `ParseNode` types.) + "atom": { + type: "atom"; + family: Atom; + mode: Mode; + loc?: SourceLocation | null | undefined; + text: string; + }; + "mathord": { + type: "mathord"; + mode: Mode; + loc?: SourceLocation | null | undefined; + text: string; + }; + "spacing": { + type: "spacing"; + mode: Mode; + loc?: SourceLocation | null | undefined; + text: string; + }; + "textord": { + type: "textord"; + mode: Mode; + loc?: SourceLocation | null | undefined; + text: string; + }; + // These "-token" types don't have corresponding HTML/MathML builders. + "accent-token": { + type: "accent-token"; + mode: Mode; + loc?: SourceLocation | null | undefined; + text: string; + }; + "op-token": { + type: "op-token"; + mode: Mode; + loc?: SourceLocation | null | undefined; + text: string; + }; + // From functions.js and functions/*.js. See also "color", "op", "styling", + // and "text" above. + "accent": { + type: "accent"; + mode: Mode; + loc?: SourceLocation | null | undefined; + label: string; + isStretchy?: boolean; + isShifty?: boolean; + base: AnyParseNode; + }; + "accentUnder": { + type: "accentUnder"; + mode: Mode; + loc?: SourceLocation | null | undefined; + label: string; + isStretchy?: boolean; + isShifty?: boolean; + base: AnyParseNode; + }; + "cr": { + type: "cr"; + mode: Mode; + loc?: SourceLocation | null | undefined; + newLine: boolean; + size: Measurement | null | undefined; + }; + "delimsizing": { + type: "delimsizing"; + mode: Mode; + loc?: SourceLocation | null | undefined; + size: DelimiterSize; + mclass: "mopen" | "mclose" | "mrel" | "mord"; + delim: string; + }; + "enclose": { + type: "enclose"; + mode: Mode; + loc?: SourceLocation | null | undefined; + label: string; + backgroundColor?: string; + borderColor?: string; + body: AnyParseNode; + }; + "environment": { + type: "environment"; + mode: Mode; + loc?: SourceLocation | null | undefined; + name: string; + nameGroup: AnyParseNode; + }; + "font": { + type: "font"; + mode: Mode; + loc?: SourceLocation | null | undefined; + font: Exclude; + body: AnyParseNode; + }; + "genfrac": { + type: "genfrac"; + mode: Mode; + loc?: SourceLocation | null | undefined; + continued: boolean; + numer: AnyParseNode; + denom: AnyParseNode; + hasBarLine: boolean; + leftDelim: string | null | undefined; + rightDelim: string | null | undefined; + barSize: Measurement | null; + }; + "hbox": { + type: "hbox"; + mode: Mode; + loc?: SourceLocation | null | undefined; + body: AnyParseNode[]; + }; + "horizBrace": { + type: "horizBrace"; + mode: Mode; + loc?: SourceLocation | null | undefined; + label: string; + isOver: boolean; + base: AnyParseNode; + }; + "href": { + type: "href"; + mode: Mode; + loc?: SourceLocation | null | undefined; + href: string; + body: AnyParseNode[]; + }; + "html": { + type: "html"; + mode: Mode; + loc?: SourceLocation | null | undefined; + attributes: Record; + body: AnyParseNode[]; + }; + "htmlmathml": { + type: "htmlmathml"; + mode: Mode; + loc?: SourceLocation | null | undefined; + html: AnyParseNode[]; + mathml: AnyParseNode[]; + }; + "includegraphics": { + type: "includegraphics"; + mode: Mode; + loc?: SourceLocation | null | undefined; + alt: string; + width: Measurement; + height: Measurement; + totalheight: Measurement; + src: string; + }; + "infix": { + type: "infix"; + mode: Mode; + loc?: SourceLocation | null | undefined; + replaceWith: string; + size?: Measurement; + token: Token | null | undefined; + }; + "internal": { + type: "internal"; + mode: Mode; + loc?: SourceLocation | null | undefined; + }; + "kern": { + type: "kern"; + mode: Mode; + loc?: SourceLocation | null | undefined; + dimension: Measurement; + }; + "lap": { + type: "lap"; + mode: Mode; + loc?: SourceLocation | null | undefined; + alignment: string; + body: AnyParseNode; + }; + "leftright": { + type: "leftright"; + mode: Mode; + loc?: SourceLocation | null | undefined; + body: AnyParseNode[]; + left: string; + right: string; + rightColor: string | null | undefined; // undefined means "inherit" + }; + "leftright-right": { + type: "leftright-right"; + mode: Mode; + loc?: SourceLocation | null | undefined; + delim: string; + color: string | null | undefined; // undefined means "inherit" + }; + "mathchoice": { + type: "mathchoice"; + mode: Mode; + loc?: SourceLocation | null | undefined; + display: AnyParseNode[]; + text: AnyParseNode[]; + script: AnyParseNode[]; + scriptscript: AnyParseNode[]; + }; + "middle": { + type: "middle"; + mode: Mode; + loc?: SourceLocation | null | undefined; + delim: string; + }; + "mclass": { + type: "mclass"; + mode: Mode; + loc?: SourceLocation | null | undefined; + mclass: string; + body: AnyParseNode[]; + isCharacterBox: boolean; + }; + "operatorname": { + type: "operatorname"; + mode: Mode; + loc?: SourceLocation | null | undefined; + body: AnyParseNode[]; + alwaysHandleSupSub: boolean; + limits: boolean; + parentIsSupSub: boolean; + }; + "overline": { + type: "overline"; + mode: Mode; + loc?: SourceLocation | null | undefined; + body: AnyParseNode; + }; + "phantom": { + type: "phantom"; + mode: Mode; + loc?: SourceLocation | null | undefined; + body: AnyParseNode[]; + }; + "vphantom": { + type: "vphantom"; + mode: Mode; + loc?: SourceLocation | null | undefined; + body: AnyParseNode; + }; + "pmb": { + type: "pmb"; + mode: Mode; + loc?: SourceLocation | null | undefined; + mclass: string; + body: AnyParseNode[]; + }; + "raisebox": { + type: "raisebox"; + mode: Mode; + loc?: SourceLocation | null | undefined; + dy: Measurement; + body: AnyParseNode; + }; + "rule": { + type: "rule"; + mode: Mode; + loc?: SourceLocation | null | undefined; + shift: Measurement | null | undefined; + width: Measurement; + height: Measurement; + }; + "sizing": { + type: "sizing"; + mode: Mode; + loc?: SourceLocation | null | undefined; + size: number; + body: AnyParseNode[]; + }; + "smash": { + type: "smash"; + mode: Mode; + loc?: SourceLocation | null | undefined; + body: AnyParseNode; + smashHeight: boolean; + smashDepth: boolean; + }; + "sqrt": { + type: "sqrt"; + mode: Mode; + loc?: SourceLocation | null | undefined; + body: AnyParseNode; + index: AnyParseNode | null | undefined; + }; + "underline": { + type: "underline"; + mode: Mode; + loc?: SourceLocation | null | undefined; + body: AnyParseNode; + }; + "vcenter": { + type: "vcenter"; + mode: Mode; + loc?: SourceLocation | null | undefined; + body: AnyParseNode; + }; + "xArrow": { + type: "xArrow"; + mode: Mode; + loc?: SourceLocation | null | undefined; + label: string; + body: AnyParseNode; + below: AnyParseNode | null | undefined; + }; +}; + +/** + * Asserts that the node is of the given type and returns it with stricter + * typing. Throws if the node's type does not match. + */ +export function assertNodeType( + node: AnyParseNode | null | undefined, + type: NODETYPE, +): ParseNode { + if (!node || node.type !== type) { + throw new Error( + `Expected node of type ${type}, but got ` + + (node ? `node of type ${node.type}` : String(node))); + } + + return node as ParseNode; +} + +/** + * Returns the node more strictly typed iff it is of the given type. Otherwise, + * returns null. + */ +export function assertSymbolNodeType(node: AnyParseNode | null | undefined): SymbolParseNode { + const typedNode = checkSymbolNodeType(node); + if (!typedNode) { + throw new Error( + `Expected node of symbol group type, but got ` + + (node ? `node of type ${node.type}` : String(node))); + } + return typedNode; +} + +/** + * Returns the node more strictly typed iff it is of the given type. Otherwise, + * returns null. + */ +export function checkSymbolNodeType(node: AnyParseNode | null | undefined): SymbolParseNode | null | undefined { + if (node && (node.type === "atom" || NON_ATOMS.hasOwnProperty(node.type))) { + return node as SymbolParseNode; + } + return null; +} diff --git a/node_modules/react-katex/node_modules/katex/src/parseTree.ts b/node_modules/react-katex/node_modules/katex/src/parseTree.ts new file mode 100644 index 0000000..93dd338 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/parseTree.ts @@ -0,0 +1,51 @@ +/** + * Provides a single function for parsing an expression using a Parser + * TODO(emily): Remove this + */ + +import Parser from "./Parser"; +import ParseError from "./ParseError"; +import {Token} from "./Token"; + +import type Settings from "./Settings"; +import type {AnyParseNode} from "./parseNode"; + +/** + * Parses an expression using a Parser, then returns the parsed result. + */ +const parseTree = function( + toParse: string | InstanceType, + settings: Settings, +): AnyParseNode[] { + if (!(typeof toParse === 'string' || toParse instanceof String)) { + throw new TypeError('KaTeX can only parse string typed expression'); + } + const parser = new Parser(toParse as string, settings); + + // Blank out any \df@tag to avoid spurious "Duplicate \tag" errors + delete parser.gullet.macros.current["\\df@tag"]; + + let tree = parser.parse(); + + // Prevent a color definition from persisting between calls to katex.render(). + delete parser.gullet.macros.current["\\current@color"]; + delete parser.gullet.macros.current["\\color"]; + + // If the input used \tag, it will set the \df@tag macro to the tag. + // In this case, we separately parse the tag and wrap the tree. + if (parser.gullet.macros.get("\\df@tag")) { + if (!settings.displayMode) { + throw new ParseError("\\tag works only in display equations"); + } + tree = [{ + type: "tag", + mode: "text", + body: tree, + tag: parser.subparse([new Token("\\df@tag")]), + }]; + } + + return tree; +}; + +export default parseTree; diff --git a/node_modules/react-katex/node_modules/katex/src/spacingData.ts b/node_modules/react-katex/node_modules/katex/src/spacingData.ts new file mode 100644 index 0000000..7980e99 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/spacingData.ts @@ -0,0 +1,107 @@ +/** + * Describes spaces between different classes of atoms. + */ +import type {Measurement} from "./units"; + +const thinspace: Measurement = { + number: 3, + unit: "mu", +}; +const mediumspace: Measurement = { + number: 4, + unit: "mu", +}; +const thickspace: Measurement = { + number: 5, + unit: "mu", +}; + +// Making the type below exact with all optional fields doesn't work due to +// - https://github.com/facebook/flow/issues/4582 +// - https://github.com/facebook/flow/issues/5688 +// However, since *all* fields are optional, $Shape<> works as suggested in 5688 +// above. +export type Spacings = Partial<{ + mord: Measurement; + mop: Measurement; + mbin: Measurement; + mrel: Measurement; + mopen: Measurement; + mclose: Measurement; + mpunct: Measurement; + minner: Measurement; +}> & {}; + +// Spacing relationships for display and text styles +export const spacings: {[key in keyof Spacings]?: Spacings} = { + mord: { + mop: thinspace, + mbin: mediumspace, + mrel: thickspace, + minner: thinspace, + }, + mop: { + mord: thinspace, + mop: thinspace, + mrel: thickspace, + minner: thinspace, + }, + mbin: { + mord: mediumspace, + mop: mediumspace, + mopen: mediumspace, + minner: mediumspace, + }, + mrel: { + mord: thickspace, + mop: thickspace, + mopen: thickspace, + minner: thickspace, + }, + mopen: {}, + mclose: { + mop: thinspace, + mbin: mediumspace, + mrel: thickspace, + minner: thinspace, + }, + mpunct: { + mord: thinspace, + mop: thinspace, + mrel: thickspace, + mopen: thinspace, + mclose: thinspace, + mpunct: thinspace, + minner: thinspace, + }, + minner: { + mord: thinspace, + mop: thinspace, + mbin: mediumspace, + mrel: thickspace, + mopen: thinspace, + mpunct: thinspace, + minner: thinspace, + }, +}; + +// Spacing relationships for script and scriptscript styles +export const tightSpacings: {[key in keyof Spacings]?: Spacings} = { + mord: { + mop: thinspace, + }, + mop: { + mord: thinspace, + mop: thinspace, + }, + mbin: {}, + mrel: {}, + mopen: {}, + mclose: { + mop: thinspace, + }, + mpunct: {}, + minner: { + mop: thinspace, + }, +}; diff --git a/node_modules/react-katex/node_modules/katex/src/stretchy.ts b/node_modules/react-katex/node_modules/katex/src/stretchy.ts new file mode 100644 index 0000000..0f6f117 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/stretchy.ts @@ -0,0 +1,358 @@ +/** + * This file provides support to buildMathML.js and buildHTML.js + * for stretchy wide elements rendered from SVG files + * and other CSS trickery. + */ + +import {LineNode, PathNode, SvgNode} from "./domTree"; +import {makeSpan, makeSvgSpan} from "./buildCommon"; +import {MathNode, TextNode} from "./mathMLTree"; +import {makeEm} from "./units"; + +import type Options from "./Options"; +import type {ParseNode} from "./parseNode"; +import type {DomSpan, HtmlDomNode, SvgSpan} from "./domTree"; + +const stretchyCodePoint: Record = { + widehat: "^", + widecheck: "ˇ", + widetilde: "~", + utilde: "~", + overleftarrow: "\u2190", + underleftarrow: "\u2190", + xleftarrow: "\u2190", + overrightarrow: "\u2192", + underrightarrow: "\u2192", + xrightarrow: "\u2192", + underbrace: "\u23df", + overbrace: "\u23de", + underbracket: "\u23b5", + overbracket: "\u23b4", + overgroup: "\u23e0", + undergroup: "\u23e1", + overleftrightarrow: "\u2194", + underleftrightarrow: "\u2194", + xleftrightarrow: "\u2194", + Overrightarrow: "\u21d2", + xRightarrow: "\u21d2", + overleftharpoon: "\u21bc", + xleftharpoonup: "\u21bc", + overrightharpoon: "\u21c0", + xrightharpoonup: "\u21c0", + xLeftarrow: "\u21d0", + xLeftrightarrow: "\u21d4", + xhookleftarrow: "\u21a9", + xhookrightarrow: "\u21aa", + xmapsto: "\u21a6", + xrightharpoondown: "\u21c1", + xleftharpoondown: "\u21bd", + xrightleftharpoons: "\u21cc", + xleftrightharpoons: "\u21cb", + xtwoheadleftarrow: "\u219e", + xtwoheadrightarrow: "\u21a0", + xlongequal: "=", + xtofrom: "\u21c4", + xrightleftarrows: "\u21c4", + xrightequilibrium: "\u21cc", // Not a perfect match. + xleftequilibrium: "\u21cb", // None better available. + "\\cdrightarrow": "\u2192", + "\\cdleftarrow": "\u2190", + "\\cdlongequal": "=", +}; + +export const stretchyMathML = function(label: string): MathNode { + const node = new MathNode( + "mo", + [new TextNode(stretchyCodePoint[label.replace(/^\\/, '')])], + ); + node.setAttribute("stretchy", "true"); + return node; +}; + +// Many of the KaTeX SVG images have been adapted from glyphs in KaTeX fonts. +// Copyright (c) 2009-2010, Design Science, Inc. () +// Copyright (c) 2014-2017 Khan Academy () +// Licensed under the SIL Open Font License, Version 1.1. +// See \nhttp://scripts.sil.org/OFL + +// Very Long SVGs +// Many of the KaTeX stretchy wide elements use a long SVG image and an +// overflow: hidden tactic to achieve a stretchy image while avoiding +// distortion of arrowheads or brace corners. + +// The SVG typically contains a very long (400 em) arrow. + +// The SVG is in a container span that has overflow: hidden, so the span +// acts like a window that exposes only part of the SVG. + +// The SVG always has a longer, thinner aspect ratio than the container span. +// After the SVG fills 100% of the height of the container span, +// there is a long arrow shaft left over. That left-over shaft is not shown. +// Instead, it is sliced off because the span's CSS has overflow: hidden. + +// Thus, the reader sees an arrow that matches the subject matter width +// without distortion. + +// Some functions, such as \cancel, need to vary their aspect ratio. These +// functions do not get the overflow SVG treatment. + +// In the katexImagesData object just below, the dimensions all +// correspond to path geometry inside the relevant SVG. +// For example, \overrightarrow uses the same arrowhead as glyph U+2192 +// from the KaTeX Main font. The scaling factor is 1000. +// That is, inside the font, that arrowhead is 522 units tall, which +// corresponds to 0.522 em inside the document. + +type SvgData = [string[], number, number, string?]; + +const katexImagesData: {[key: string]: SvgData} = { + // path(s), minWidth, height, align + overrightarrow: [["rightarrow"], 0.888, 522, "xMaxYMin"], + overleftarrow: [["leftarrow"], 0.888, 522, "xMinYMin"], + underrightarrow: [["rightarrow"], 0.888, 522, "xMaxYMin"], + underleftarrow: [["leftarrow"], 0.888, 522, "xMinYMin"], + xrightarrow: [["rightarrow"], 1.469, 522, "xMaxYMin"], + "\\cdrightarrow": [["rightarrow"], 3.0, 522, "xMaxYMin"], // CD minwwidth2.5pc + xleftarrow: [["leftarrow"], 1.469, 522, "xMinYMin"], + "\\cdleftarrow": [["leftarrow"], 3.0, 522, "xMinYMin"], + Overrightarrow: [["doublerightarrow"], 0.888, 560, "xMaxYMin"], + xRightarrow: [["doublerightarrow"], 1.526, 560, "xMaxYMin"], + xLeftarrow: [["doubleleftarrow"], 1.526, 560, "xMinYMin"], + overleftharpoon: [["leftharpoon"], 0.888, 522, "xMinYMin"], + xleftharpoonup: [["leftharpoon"], 0.888, 522, "xMinYMin"], + xleftharpoondown: [["leftharpoondown"], 0.888, 522, "xMinYMin"], + overrightharpoon: [["rightharpoon"], 0.888, 522, "xMaxYMin"], + xrightharpoonup: [["rightharpoon"], 0.888, 522, "xMaxYMin"], + xrightharpoondown: [["rightharpoondown"], 0.888, 522, "xMaxYMin"], + xlongequal: [["longequal"], 0.888, 334, "xMinYMin"], + "\\cdlongequal": [["longequal"], 3.0, 334, "xMinYMin"], + xtwoheadleftarrow: [["twoheadleftarrow"], 0.888, 334, "xMinYMin"], + xtwoheadrightarrow: [["twoheadrightarrow"], 0.888, 334, "xMaxYMin"], + + overleftrightarrow: [["leftarrow", "rightarrow"], 0.888, 522], + overbrace: [["leftbrace", "midbrace", "rightbrace"], 1.6, 548], + underbrace: [["leftbraceunder", "midbraceunder", "rightbraceunder"], + 1.6, 548], + underleftrightarrow: [["leftarrow", "rightarrow"], 0.888, 522], + xleftrightarrow: [["leftarrow", "rightarrow"], 1.75, 522], + xLeftrightarrow: [["doubleleftarrow", "doublerightarrow"], 1.75, 560], + xrightleftharpoons: [["leftharpoondownplus", "rightharpoonplus"], 1.75, 716], + xleftrightharpoons: [["leftharpoonplus", "rightharpoondownplus"], + 1.75, 716], + xhookleftarrow: [["leftarrow", "righthook"], 1.08, 522], + xhookrightarrow: [["lefthook", "rightarrow"], 1.08, 522], + overlinesegment: [["leftlinesegment", "rightlinesegment"], 0.888, 522], + underlinesegment: [["leftlinesegment", "rightlinesegment"], 0.888, 522], + overbracket: [["leftbracketover", "rightbracketover"], 1.6, 440], + underbracket: [["leftbracketunder", "rightbracketunder"], 1.6, 410], + overgroup: [["leftgroup", "rightgroup"], 0.888, 342], + undergroup: [["leftgroupunder", "rightgroupunder"], 0.888, 342], + xmapsto: [["leftmapsto", "rightarrow"], 1.5, 522], + xtofrom: [["leftToFrom", "rightToFrom"], 1.75, 528], + + // The next three arrows are from the mhchem package. + // In mhchem.sty, min-length is 2.0em. But these arrows might appear in the + // document as \xrightarrow or \xrightleftharpoons. Those have + // min-length = 1.75em, so we set min-length on these next three to match. + xrightleftarrows: [["baraboveleftarrow", "rightarrowabovebar"], 1.75, 901], + xrightequilibrium: [["baraboveshortleftharpoon", + "rightharpoonaboveshortbar"], 1.75, 716], + xleftequilibrium: [["shortbaraboveleftharpoon", + "shortrightharpoonabovebar"], 1.75, 716], +}; + +const wideAccentLabels = + new Set(["widehat", "widecheck", "widetilde", "utilde"]); + +export const stretchySvg = function( + group: ParseNode<"accent"> | ParseNode<"accentUnder"> | ParseNode<"xArrow"> + | ParseNode<"horizBrace">, + options: Options, +): DomSpan | SvgSpan { + // Create a span with inline SVG for the element. + function buildSvgSpan_(): { + span: DomSpan | SvgSpan, + minWidth: number, + height: number, + } { + let viewBoxWidth = 400000; // default + const label = group.label.slice(1); + if (wideAccentLabels.has(label) && 'base' in group) { + // There are four SVG images available for each function. + // Choose a taller image when there are more characters. + const numChars = group.base.type === "ordgroup" ? + group.base.body.length : 1; + let viewBoxHeight; + let pathName; + let height; + + if (numChars > 5) { + if (label === "widehat" || label === "widecheck") { + viewBoxHeight = 420; + viewBoxWidth = 2364; + height = 0.42; + pathName = label + "4"; + } else { + viewBoxHeight = 312; + viewBoxWidth = 2340; + height = 0.34; + pathName = "tilde4"; + } + } else { + const imgIndex = [1, 1, 2, 2, 3, 3][numChars]; + if (label === "widehat" || label === "widecheck") { + viewBoxWidth = [0, 1062, 2364, 2364, 2364][imgIndex]; + viewBoxHeight = [0, 239, 300, 360, 420][imgIndex]; + height = [0, 0.24, 0.3, 0.3, 0.36, 0.42][imgIndex]; + pathName = label + imgIndex; + } else { + viewBoxWidth = [0, 600, 1033, 2339, 2340][imgIndex]; + viewBoxHeight = [0, 260, 286, 306, 312][imgIndex]; + height = [0, 0.26, 0.286, 0.3, 0.306, 0.34][imgIndex]; + pathName = "tilde" + imgIndex; + } + } + const path = new PathNode(pathName); + const svgNode = new SvgNode([path], { + "width": "100%", + "height": makeEm(height), + "viewBox": `0 0 ${viewBoxWidth} ${viewBoxHeight}`, + "preserveAspectRatio": "none", + }); + return { + span: makeSvgSpan([], [svgNode], options), + minWidth: 0, + height, + }; + } else { + const spans = []; + + const data = katexImagesData[label]; + if (!data) { + throw new Error(`No SVG data for "${label}".`); + } + const [paths, minWidth, viewBoxHeight] = data; + const height = viewBoxHeight / 1000; + + const numSvgChildren = paths.length; + let widthClasses; + let aligns; + if (numSvgChildren === 1) { + if (data.length !== 4) { + throw new Error( + `Expected 4-tuple for single-path SVG data "${label}".`); + } + widthClasses = ["hide-tail"]; + aligns = [data[3]]; + } else if (numSvgChildren === 2) { + widthClasses = ["halfarrow-left", "halfarrow-right"]; + aligns = ["xMinYMin", "xMaxYMin"]; + } else if (numSvgChildren === 3) { + widthClasses = ["brace-left", "brace-center", "brace-right"]; + aligns = ["xMinYMin", "xMidYMin", "xMaxYMin"]; + } else { + throw new Error( + `Correct katexImagesData or update code here to support + ${numSvgChildren} children.`); + } + + for (let i = 0; i < numSvgChildren; i++) { + const path = new PathNode(paths[i]); + + const svgNode = new SvgNode([path], { + "width": "400em", + "height": makeEm(height), + "viewBox": `0 0 ${viewBoxWidth} ${viewBoxHeight}`, + "preserveAspectRatio": aligns[i] + " slice", + }); + + const span = makeSvgSpan( + [widthClasses[i]], [svgNode], options); + if (numSvgChildren === 1) { + return {span, minWidth, height}; + } else { + span.style.height = makeEm(height); + spans.push(span); + } + } + + return { + span: makeSpan(["stretchy"], spans, options), + minWidth, + height, + }; + } + } // buildSvgSpan_() + const {span, minWidth, height} = buildSvgSpan_(); + + // Note that we are returning span.depth = 0. + // Any adjustments relative to the baseline must be done in buildHTML. + span.height = height; + span.style.height = makeEm(height); + if (minWidth > 0) { + span.style.minWidth = makeEm(minWidth); + } + + return span; +}; + +export const stretchyEnclose = function( + inner: HtmlDomNode, + label: string, + topPad: number, + bottomPad: number, + options: Options, +): DomSpan | SvgSpan { + // Return an image span for \cancel, \bcancel, \xcancel, \fbox, or \angl + let img; + const totalHeight = inner.height + inner.depth + topPad + bottomPad; + + if (/fbox|color|angl/.test(label)) { + img = makeSpan(["stretchy", label], [], options); + + if (label === "fbox") { + const color = options.color && options.getColor(); + if (color) { + img.style.borderColor = color; + } + } + + } else { + // \cancel, \bcancel, or \xcancel + // Since \cancel's SVG is inline and it omits the viewBox attribute, + // its stroke-width will not vary with span area. + + const lines = []; + if (/^[bx]cancel$/.test(label)) { + lines.push(new LineNode({ + "x1": "0", + "y1": "0", + "x2": "100%", + "y2": "100%", + "stroke-width": "0.046em", + })); + } + + if (/^x?cancel$/.test(label)) { + lines.push(new LineNode({ + "x1": "0", + "y1": "100%", + "x2": "100%", + "y2": "0", + "stroke-width": "0.046em", + })); + } + + const svgNode = new SvgNode(lines, { + "width": "100%", + "height": makeEm(totalHeight), + }); + + img = makeSvgSpan([], [svgNode], options); + } + + img.height = totalHeight; + img.style.height = makeEm(totalHeight); + + return img; +}; diff --git a/node_modules/react-katex/node_modules/katex/src/styles/fonts.scss b/node_modules/react-katex/node_modules/katex/src/styles/fonts.scss new file mode 100644 index 0000000..430da86 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/styles/fonts.scss @@ -0,0 +1,75 @@ +@use "sass:list"; + +$font-folder: "../../fonts" !default; +$use-woff2: true !default; +$use-woff: true !default; +$use-ttf: true !default; +$font-display: block !default; + +@function generate-src($family, $family-suffix) { + $src: null; + @if $use-woff2 { + $src: list.append($src, url('#{$font-folder}/KaTeX_#{$family}-#{$family-suffix}.woff2') format('woff2'), comma); + } + @if $use-woff { + $src: list.append($src, url('#{$font-folder}/KaTeX_#{$family}-#{$family-suffix}.woff') format('woff'), comma); + } + @if $use-ttf { + $src: list.append($src, url('#{$font-folder}/KaTeX_#{$family}-#{$family-suffix}.ttf') format('truetype'), comma); + } + + @return $src; +} + +@function generate-suffix($weight, $style) { + $suffix: null; + + @if $weight == normal and $style == normal { + $suffix: 'Regular'; + } + @if $weight == normal and $style == italic { + $suffix: 'Italic'; + } + @if $weight == bold and $style == normal { + $suffix: 'Bold'; + } + @if $weight == bold and $style == italic { + $suffix: 'BoldItalic'; + } + + @return $suffix; +} + +@mixin font-face($family, $weight, $style) { + $suffix: generate-suffix($weight, $style); + $src: generate-src($family, $suffix); + + @font-face { + font-family: 'KaTeX_#{$family}'; + src: $src; + font-weight: $weight; + font-style: $style; + font-display: $font-display; + } +} + +@include font-face('AMS', normal, normal); +@include font-face('Caligraphic', bold, normal); +@include font-face('Caligraphic', normal, normal); +@include font-face('Fraktur', bold, normal); +@include font-face('Fraktur', normal, normal); +@include font-face('Main', bold, normal); +@include font-face('Main', bold, italic); +@include font-face('Main', normal, italic); +@include font-face('Main', normal, normal); +@include font-face('Math', bold, italic); +@include font-face('Math', normal, italic); +@include font-face('SansSerif', bold, normal); +@include font-face('SansSerif', normal, italic); +@include font-face('SansSerif', normal, normal); +@include font-face('Script', normal, normal); +@include font-face('Size1', normal, normal); +@include font-face('Size2', normal, normal); +@include font-face('Size3', normal, normal); +@include font-face('Size4', normal, normal); +@include font-face('Typewriter', normal, normal); diff --git a/node_modules/react-katex/node_modules/katex/src/styles/katex-swap.scss b/node_modules/react-katex/node_modules/katex/src/styles/katex-swap.scss new file mode 100644 index 0000000..ac46cb0 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/styles/katex-swap.scss @@ -0,0 +1,4 @@ +@use 'katex' with ( + $font-display: swap, + $version: $version, +); diff --git a/node_modules/react-katex/node_modules/katex/src/styles/katex.scss b/node_modules/react-katex/node_modules/katex/src/styles/katex.scss new file mode 100644 index 0000000..f3223f9 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/styles/katex.scss @@ -0,0 +1,683 @@ +/* stylelint-disable font-family-no-missing-generic-family-keyword */ +@use "sass:list"; +@use "sass:math"; + +@forward "fonts.scss" with ( + $font-folder: "../../fonts" !default, + $use-woff2: true !default, + $use-woff: true !default, + $use-ttf: true !default, + $font-display: block !default +); + +@use "fonts.scss"; + +// The mu unit is defined as 1/18 em +$mu: calc(1em / 18); + +// The version is dynamically set from package.json via webpack.common.js +$version: "" !default; + +// CSS margin property for math in display mode +$display-margin: 1em 0 !default; + +.katex { + font: normal 1.21em KaTeX_Main, Times New Roman, serif; + line-height: 1.2; + position: relative; + + // Protect elements inside .katex from inheriting text-indent. + text-indent: 0; + + // Prevent a rendering bug that misplaces \vec in Chrome. + text-rendering: auto; + + * { + // Prevent background resetting on elements in Windows's high-contrast + // mode, while still allowing background/foreground setting on root .katex + -ms-high-contrast-adjust: none !important; + + // Insulate fraction bars and rules from CSS that sets border-color. + border-color: currentColor; + } + + .katex-version::after { + content: $version; + } + + .katex-mathml { + /* Accessibility hack to only show to screen readers + Found at: http://a11yproject.com/posts/how-to-hide-content/ */ + position: absolute; + clip-path: inset(50%); + padding: 0; + border: 0; + height: 1px; + width: 1px; + overflow: hidden; + } + + .katex-html { + /* \newline is an empty block at top level, between .base elements */ + > .newline { + display: block; + } + } + + .base { + position: relative; + display: inline-block; + white-space: nowrap; + + // Fix width of containers of negative spaces, working around Chrome bug. + width: min-content; + } + + .strut { + display: inline-block; + } + + // Text font weights + .textbf { + font-weight: bold; + } + + // Text font shapes. + .textit { + font-style: italic; + } + + // Text font families. + .textrm { + font-family: KaTeX_Main; + } + + .textsf { + font-family: KaTeX_SansSerif; + } + + .texttt { + font-family: KaTeX_Typewriter; + } + + // Math fonts. + .mathnormal { + font-family: KaTeX_Math; + font-style: italic; + } + + .mathit { + font-family: KaTeX_Main; + font-style: italic; + } + + .mathrm { + font-style: normal; + } + + .mathbf { + font-family: KaTeX_Main; + font-weight: bold; + } + + .boldsymbol { + font-family: KaTeX_Math; + font-weight: bold; + font-style: italic; + } + + .amsrm { + font-family: KaTeX_AMS; + } + + .mathbb, + .textbb { + font-family: KaTeX_AMS; + } + + .mathcal { + font-family: KaTeX_Caligraphic; + } + + .mathfrak, + .textfrak { + font-family: KaTeX_Fraktur; + } + + .mathboldfrak, + .textboldfrak { + font-family: KaTeX_Fraktur; + font-weight: bold; + } + + .mathtt { + font-family: KaTeX_Typewriter; + } + + .mathscr, + .textscr { + font-family: KaTeX_Script; + } + + .mathsf, + .textsf { + font-family: KaTeX_SansSerif; + } + + .mathboldsf, + .textboldsf { + font-family: KaTeX_SansSerif; + font-weight: bold; + } + + .mathsfit, + .mathitsf, + .textitsf { + font-family: KaTeX_SansSerif; + font-style: italic; + } + + .mainrm { + font-family: KaTeX_Main; + font-style: normal; + } + + // This value is also used in fontMetrics.js, if you change it make sure the + // values match. + $ptperem: 10; + $nulldelimiterspace: calc(1.2em / $ptperem); + + $muspace: 0.055556em; // 1mu + $thinspace: 0.16667em; // 3mu + $mediumspace: 0.22222em; // 4mu + $thickspace: 0.27778em; // 5mu + + .vlist-t { + display: inline-table; + table-layout: fixed; + border-collapse: collapse; + } + + .vlist-r { + display: table-row; + } + + .vlist { + display: table-cell; + vertical-align: bottom; + position: relative; + + > span { + display: block; + height: 0; + position: relative; + + > span { + display: inline-block; + } + + > .pstrut { + overflow: hidden; + width: 0; + } + } + } + + .vlist-t2 { + margin-right: -2px; + } + + .vlist-s { + // This cell solves Safari rendering problems. It has text content, so + // its baseline is used for the table. A very small font avoids line-box + // issues; absolute units prevent user font-size overrides from breaking + // rendering. Safari refuses to make the box zero-width, so we give it + // a known width and compensate with negative right margin on the + // inline-table. To prevent the "width: min-content" Chrome workaround + // from shrinking this box, we also set min-width. + display: table-cell; + vertical-align: bottom; + font-size: 1px; + width: 2px; + min-width: 2px; + } + + .vbox { + display: inline-flex; + flex-direction: column; + align-items: baseline; + } + + .hbox { + display: inline-flex; + flex-direction: row; + width: 100%; + } + + .thinbox { + display: inline-flex; + flex-direction: row; + width: 0; + max-width: 0; // necessary for Safari + } + + .msupsub { + text-align: left; + } + + .mfrac { + > span > span { + text-align: center; + } + + .frac-line { + display: inline-block; + width: 100%; + border-bottom-style: solid; + } + } + + // Prevent Chrome from disappearing frac-lines, rules, etc. + .mfrac .frac-line, + .overline .overline-line, + .underline .underline-line, + .hline, + .hdashline, + .rule { + min-height: 1px; + } + + .mspace { + display: inline-block; + } + + .smash { + display: inline; + line-height: 0; + } + + .llap, + .rlap, + .clap { + width: 0; + position: relative; + + > .inner { + position: absolute; + } + + > .fix { + display: inline-block; + } + } + + .llap > .inner { + right: 0; + } + + .rlap > .inner, + .clap > .inner { + left: 0; + } + + .clap > .inner > span { + margin-left: -50%; + margin-right: 50%; + } + + .rule { + display: inline-block; + border: solid 0; + position: relative; + } + + .overline .overline-line, + .underline .underline-line, + .hline { + display: inline-block; + width: 100%; + border-bottom-style: solid; + } + + .hdashline { + display: inline-block; + width: 100%; + border-bottom-style: dashed; + } + + .sqrt { + > .root { + /* These values are taken from the definition of `\r@@t`, + `\mkern 5mu` and `\mkern -10mu`. */ + /* stylelint-disable-next-line declaration-property-value-no-unknown */ + margin-left: calc(5*$mu); + /* stylelint-disable-next-line declaration-property-value-no-unknown */ + margin-right: calc(-10*$mu); + } + } + + .sizing, + .fontsize-ensurer { + $sizes: 0.5, 0.6, 0.7, 0.8, 0.9, 1, 1.2, 1.44, 1.728, 2.074, 2.488; + + @for $from from 1 through list.length($sizes) { + @for $to from 1 through list.length($sizes) { + &.reset-size#{$from}.size#{$to} { + /* stylelint-disable-next-line */ + font-size: calc(math.div(list.nth($sizes, $to), list.nth($sizes, $from)) * 1em); + } + } + } + } + + .delimsizing { + &.size1 { font-family: KaTeX_Size1; } + &.size2 { font-family: KaTeX_Size2; } + &.size3 { font-family: KaTeX_Size3; } + &.size4 { font-family: KaTeX_Size4; } + + &.mult { + .delim-size1 > span { + font-family: KaTeX_Size1; + } + + .delim-size4 > span { + font-family: KaTeX_Size4; + } + } + } + + .nulldelimiter { + display: inline-block; + width: $nulldelimiterspace; + } + + .delimcenter { + position: relative; + } + + .op-symbol { + position: relative; + + &.small-op { + font-family: KaTeX_Size1; + } + + &.large-op { + font-family: KaTeX_Size2; + } + } + + .op-limits { + > .vlist-t { + text-align: center; + } + } + + .accent { + > .vlist-t { + text-align: center; + } + + .accent-body { + position: relative; // so that 'left' can shift the accent + } + + // Accents that are not of the accent-full class have zero width + // (do not contribute to the width of the final symbol). + .accent-body:not(.accent-full) { + width: 0; + } + } + + .overlay { + display: block; + } + + .mtable { + .vertical-separator { + display: inline-block; + // margin and border-right are set in JavaScript + min-width: 1px; // Prevent Chrome from omitting a line. + } + + .arraycolsep { + display: inline-block; + } + + .col-align-c > .vlist-t { + text-align: center; + } + + .col-align-l > .vlist-t { + text-align: left; + } + + .col-align-r > .vlist-t { + text-align: right; + } + } + + .svg-align { + text-align: left; + } + + svg { + display: block; + position: absolute; // absolute relative to parent + width: 100%; + height: inherit; + + // We want to inherit colors from our environment + fill: currentColor; + stroke: currentColor; + + // But path elements should not have an outline by default + // that would make them bigger than we expect. + path { + stroke: none; + } + + // And we don't want to inherit any other style properties + // that could affect SVG rendering without affecting font + // rendering. So we reset these properties to their default + // values for every element. + // See https://www.w3.org/TR/SVG/painting.html + fill-rule: nonzero; + fill-opacity: 1; + stroke-width: 1; + stroke-linecap: butt; + stroke-linejoin: miter; + stroke-miterlimit: 4; + stroke-dasharray: none; + stroke-dashoffset: 0; + stroke-opacity: 1; + } + + img { + border-style: none; + min-width: 0; + min-height: 0; + max-width: none; + max-height: none; + } + + // Define CSS for image whose width will match its span width. + .stretchy { + width: 100%; + display: block; + position: relative; + overflow: hidden; + + &::before, + &::after { + content: ""; + } + } + + // Hide the long tail of a stretchy SVG. + .hide-tail { + width: 100%; // necessary only to get IE to work properly + position: relative; // ditto + overflow: hidden; // This line applies to all browsers. + } + + .halfarrow-left { + position: absolute; + left: 0; + width: 50.2%; + overflow: hidden; + } + + .halfarrow-right { + position: absolute; + right: 0; + width: 50.2%; + overflow: hidden; + } + + .brace-left { + position: absolute; + left: 0; + width: 25.1%; + overflow: hidden; + } + + .brace-center { + position: absolute; + left: 25%; + width: 50%; + overflow: hidden; + } + + .brace-right { + position: absolute; + right: 0; + width: 25.1%; + overflow: hidden; + } + + // Lengthen the extensible arrows via padding. + .x-arrow-pad { + padding: 0 0.5em; + } + + .cd-arrow-pad { + padding: 0 0.55556em 0 0.27778em; // \;{#1}\;\; + } + + .x-arrow, + .mover, + .munder { + text-align: center; + } + + .boxpad { + padding: 0 0.3em; // \fboxsep = 3pt + } + + .fbox, + .fcolorbox { + box-sizing: border-box; + border: 0.04em solid; // \fboxrule = 0.4pt + } + + .cancel-pad { + padding: 0 0.2em; // ref: cancel package \advance\dimen@ 2\p@ % "+2" + } + + .cancel-lap { + margin-left: -0.2em; // \cancel does not affect horizontal spacing. + margin-right: -0.2em; // Apply negative margin to correct for 0.2em padding + } // inside the \cancel group. + + .sout { + border-bottom-style: solid; + border-bottom-width: 0.08em; + } + + .angl { + // from package actuarialangle, which is always used in a subscript. + box-sizing: border-box; + border-top: 0.049em solid; // defaultRuleThickness in scriptstyle + border-right: 0.049em solid; // ditto + margin-right: 0.03889em; // 1 mu + } + + .anglpad { + padding: 0 0.03889em; // pad 1mu left and right (in scriptstyle) + } + + .eqn-num::before { + counter-increment: katexEqnNo; + content: "(" counter(katexEqnNo) ")"; + } + + .mml-eqn-num::before { + counter-increment: mmlEqnNo; + content: "(" counter(mmlEqnNo) ")"; + } + + .mtr-glue { + width: 50%; + } + + .cd-vert-arrow { + display: inline-block; + position: relative; + } + + .cd-label-left { + display: inline-block; + position: absolute; + right: calc(50% + 0.3em); + text-align: left; + } + + .cd-label-right { + display: inline-block; + position: absolute; + left: calc(50% + 0.3em); + text-align: right; + } +} + +.katex-display { + display: block; + margin: $display-margin; + text-align: center; + + > .katex { + display: block; + text-align: center; + white-space: nowrap; + + > .katex-html { + display: block; + position: relative; + + > .tag { + position: absolute; + right: 0; + } + } + } +} + +// Left-justified tags (default is right-justified) +.katex-display.leqno > .katex > .katex-html > .tag { + left: 0; + right: auto; +} + +// Flush-left display math +.katex-display.fleqn > .katex { + text-align: left; + padding-left: 2em; +} + +// Automatic equation numbers for some environments. +// Use parallel counters for HTML and MathML. +body { + counter-reset: katexEqnNo mmlEqnNo; +} diff --git a/node_modules/react-katex/node_modules/katex/src/svgGeometry.ts b/node_modules/react-katex/node_modules/katex/src/svgGeometry.ts new file mode 100644 index 0000000..0765eef --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/svgGeometry.ts @@ -0,0 +1,561 @@ +/** + * This file provides support to domTree.js and delimiter.js. + * It's a storehouse of path geometry for SVG images. + */ + +// In all paths below, the viewBox-to-em scale is 1000:1. + +// Second Brush Stroke +// Low resolution monitors struggle to display images in fine detail. +// So browsers apply anti-aliasing. A long straight arrow shaft therefore +// will sometimes appear as if it has a blurred edge. + +// To mitigate this, these SVG files contain a second "brush-stroke" on the +// arrow shafts. That is, a second long thin rectangular SVG path has been +// written directly on top of each arrow shaft. This reinforcement causes +// some of the screen pixels to display as black instead of the anti-aliased +// gray pixel that a single path would generate. So we get arrow shafts +// whose edges appear to be sharper. +const doubleBrushStroke = (svgPath: string): string => `${svgPath} ${svgPath}`; + +const hLinePad = 80; // padding above a sqrt vinculum. Prevents image cropping. + +// The vinculum of a \sqrt can be made thicker by a KaTeX rendering option. +// Think of variable extraVinculum as two detours in the SVG path. +// The detour begins at the lower left of the area labeled extraVinculum below. +// The detour proceeds one extraVinculum distance up and slightly to the right, +// displacing the radiused corner between surd and vinculum. The radius is +// traversed as usual, then the detour resumes. It goes right, to the end of +// the very long vinculum, then down one extraVinculum distance, +// after which it resumes regular path geometry for the radical. +/* vinculum + / + /▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒←extraVinculum + / █████████████████████←0.04em (40 unit) std vinculum thickness + / / + / / + / /\ + / / surd +*/ + +const sqrtMain = function(extraVinculum: number, hLinePad: number): string { + // sqrtMain path geometry is from glyph U221A in the font KaTeX Main + return `M95,${622 + extraVinculum + hLinePad} +c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14 +c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54 +c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10 +s173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429 +c69,-144,104.5,-217.7,106.5,-221 +l${extraVinculum / 2.075} -${extraVinculum} +c5.3,-9.3,12,-14,20,-14 +H400000v${40 + extraVinculum}H845.2724 +s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7 +c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z +M${834 + extraVinculum} ${hLinePad}h400000v${40 + extraVinculum}h-400000z`; +}; + +const sqrtSize1 = function(extraVinculum: number, hLinePad: number): string { + // size1 is from glyph U221A in the font KaTeX_Size1-Regular + return `M263,${601 + extraVinculum + hLinePad}c0.7,0,18,39.7,52,119 +c34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120 +c340,-704.7,510.7,-1060.3,512,-1067 +l${extraVinculum / 2.084} -${extraVinculum} +c4.7,-7.3,11,-11,19,-11 +H40000v${40 + extraVinculum}H1012.3 +s-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232 +c-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1 +s-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26 +c-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z +M${1001 + extraVinculum} ${hLinePad}h400000v${40 + extraVinculum}h-400000z`; +}; + +const sqrtSize2 = function(extraVinculum: number, hLinePad: number): string { + // size2 is from glyph U221A in the font KaTeX_Size2-Regular + return `M983 ${10 + extraVinculum + hLinePad} +l${extraVinculum / 3.13} -${extraVinculum} +c4,-6.7,10,-10,18,-10 H400000v${40 + extraVinculum} +H1013.1s-83.4,268,-264.1,840c-180.7,572,-277,876.3,-289,913c-4.7,4.7,-12.7,7,-24,7 +s-12,0,-12,0c-1.3,-3.3,-3.7,-11.7,-7,-25c-35.3,-125.3,-106.7,-373.3,-214,-744 +c-10,12,-21,25,-33,39s-32,39,-32,39c-6,-5.3,-15,-14,-27,-26s25,-30,25,-30 +c26.7,-32.7,52,-63,76,-91s52,-60,52,-60s208,722,208,722 +c56,-175.3,126.3,-397.3,211,-666c84.7,-268.7,153.8,-488.2,207.5,-658.5 +c53.7,-170.3,84.5,-266.8,92.5,-289.5z +M${1001 + extraVinculum} ${hLinePad}h400000v${40 + extraVinculum}h-400000z`; +}; + +const sqrtSize3 = function(extraVinculum: number, hLinePad: number): string { + // size3 is from glyph U221A in the font KaTeX_Size3-Regular + return `M424,${2398 + extraVinculum + hLinePad} +c-1.3,-0.7,-38.5,-172,-111.5,-514c-73,-342,-109.8,-513.3,-110.5,-514 +c0,-2,-10.7,14.3,-32,49c-4.7,7.3,-9.8,15.7,-15.5,25c-5.7,9.3,-9.8,16,-12.5,20 +s-5,7,-5,7c-4,-3.3,-8.3,-7.7,-13,-13s-13,-13,-13,-13s76,-122,76,-122s77,-121,77,-121 +s209,968,209,968c0,-2,84.7,-361.7,254,-1079c169.3,-717.3,254.7,-1077.7,256,-1081 +l${extraVinculum / 4.223} -${extraVinculum}c4,-6.7,10,-10,18,-10 H400000 +v${40 + extraVinculum}H1014.6 +s-87.3,378.7,-272.6,1166c-185.3,787.3,-279.3,1182.3,-282,1185 +c-2,6,-10,9,-24,9 +c-8,0,-12,-0.7,-12,-2z M${1001 + extraVinculum} ${hLinePad} +h400000v${40 + extraVinculum}h-400000z`; +}; + +const sqrtSize4 = function(extraVinculum: number, hLinePad: number): string { + // size4 is from glyph U221A in the font KaTeX_Size4-Regular + return `M473,${2713 + extraVinculum + hLinePad} +c339.3,-1799.3,509.3,-2700,510,-2702 l${extraVinculum / 5.298} -${extraVinculum} +c3.3,-7.3,9.3,-11,18,-11 H400000v${40 + extraVinculum}H1017.7 +s-90.5,478,-276.2,1466c-185.7,988,-279.5,1483,-281.5,1485c-2,6,-10,9,-24,9 +c-8,0,-12,-0.7,-12,-2c0,-1.3,-5.3,-32,-16,-92c-50.7,-293.3,-119.7,-693.3,-207,-1200 +c0,-1.3,-5.3,8.7,-16,30c-10.7,21.3,-21.3,42.7,-32,64s-16,33,-16,33s-26,-26,-26,-26 +s76,-153,76,-153s77,-151,77,-151c0.7,0.7,35.7,202,105,604c67.3,400.7,102,602.7,104, +606zM${1001 + extraVinculum} ${hLinePad}h400000v${40 + extraVinculum}H1017.7z`; +}; + +export const phasePath = function(y: number): string { + const x = y / 2; // x coordinate at top of angle + return `M400000 ${y} H0 L${x} 0 l65 45 L145 ${y - 80} H400000z`; +}; + +const sqrtTall = function( + extraVinculum: number, + hLinePad: number, + viewBoxHeight: number +): string { + // sqrtTall is from glyph U23B7 in the font KaTeX_Size4-Regular + // One path edge has a variable length. It runs vertically from the vinculum + // to a point near (14 units) the bottom of the surd. The vinculum + // is normally 40 units thick. So the length of the line in question is: + const vertSegment = viewBoxHeight - 54 - hLinePad - extraVinculum; + + return `M702 ${extraVinculum + hLinePad}H400000${40 + extraVinculum} +H742v${vertSegment}l-4 4-4 4c-.667.7 -2 1.5-4 2.5s-4.167 1.833-6.5 2.5-5.5 1-9.5 1 +h-12l-28-84c-16.667-52-96.667 -294.333-240-727l-212 -643 -85 170 +c-4-3.333-8.333-7.667-13 -13l-13-13l77-155 77-156c66 199.333 139 419.667 +219 661 l218 661zM702 ${hLinePad}H400000v${40 + extraVinculum}H742z`; +}; + +export const sqrtPath = function( + size: string, + extraVinculum: number, + viewBoxHeight: number +): string { + extraVinculum = 1000 * extraVinculum; // Convert from document ems to viewBox. + let path = ""; + + switch (size) { + case "sqrtMain": + path = sqrtMain(extraVinculum, hLinePad); + break; + case "sqrtSize1": + path = sqrtSize1(extraVinculum, hLinePad); + break; + case "sqrtSize2": + path = sqrtSize2(extraVinculum, hLinePad); + break; + case "sqrtSize3": + path = sqrtSize3(extraVinculum, hLinePad); + break; + case "sqrtSize4": + path = sqrtSize4(extraVinculum, hLinePad); + break; + case "sqrtTall": + path = sqrtTall(extraVinculum, hLinePad, viewBoxHeight); + } + return path; +}; + +export const innerPath = function(name: string, height: number): string { + // The inner part of stretchy tall delimiters + switch (name) { + case "\u239c": + return doubleBrushStroke(`M291 0 H417 V${height} H291z`); + case "\u2223": + return doubleBrushStroke(`M145 0 H188 V${height} H145z`); + case "\u2225": + return doubleBrushStroke(`M145 0 H188 V${height} H145z`) + + doubleBrushStroke(`M367 0 H410 V${height} H367z`); + case "\u239f": + return doubleBrushStroke(`M457 0 H583 V${height} H457z`); + case "\u23a2": + return doubleBrushStroke(`M319 0 H403 V${height} H319z`); + case "\u23a5": + return doubleBrushStroke(`M263 0 H347 V${height} H263z`); + case "\u23aa": + return doubleBrushStroke(`M384 0 H504 V${height} H384z`); + case "\u23d0": + return doubleBrushStroke(`M312 0 H355 V${height} H312z`); + case "\u2016": + return doubleBrushStroke(`M257 0 H300 V${height} H257z`) + + doubleBrushStroke(`M478 0 H521 V${height} H478z`); + default: + return ""; + } +}; + +export const path: Record = { + // The doubleleftarrow geometry is from glyph U+21D0 in the font KaTeX Main + doubleleftarrow: `M262 157 +l10-10c34-36 62.7-77 86-123 3.3-8 5-13.3 5-16 0-5.3-6.7-8-20-8-7.3 + 0-12.2.5-14.5 1.5-2.3 1-4.8 4.5-7.5 10.5-49.3 97.3-121.7 169.3-217 216-28 + 14-57.3 25-88 33-6.7 2-11 3.8-13 5.5-2 1.7-3 4.2-3 7.5s1 5.8 3 7.5 +c2 1.7 6.3 3.5 13 5.5 68 17.3 128.2 47.8 180.5 91.5 52.3 43.7 93.8 96.2 124.5 + 157.5 9.3 8 15.3 12.3 18 13h6c12-.7 18-4 18-10 0-2-1.7-7-5-15-23.3-46-52-87 +-86-123l-10-10h399738v-40H218c328 0 0 0 0 0l-10-8c-26.7-20-65.7-43-117-69 2.7 +-2 6-3.7 10-5 36.7-16 72.3-37.3 107-64l10-8h399782v-40z +m8 0v40h399730v-40zm0 194v40h399730v-40z`, + + // doublerightarrow is from glyph U+21D2 in font KaTeX Main + doublerightarrow: `M399738 392l +-10 10c-34 36-62.7 77-86 123-3.3 8-5 13.3-5 16 0 5.3 6.7 8 20 8 7.3 0 12.2-.5 + 14.5-1.5 2.3-1 4.8-4.5 7.5-10.5 49.3-97.3 121.7-169.3 217-216 28-14 57.3-25 88 +-33 6.7-2 11-3.8 13-5.5 2-1.7 3-4.2 3-7.5s-1-5.8-3-7.5c-2-1.7-6.3-3.5-13-5.5-68 +-17.3-128.2-47.8-180.5-91.5-52.3-43.7-93.8-96.2-124.5-157.5-9.3-8-15.3-12.3-18 +-13h-6c-12 .7-18 4-18 10 0 2 1.7 7 5 15 23.3 46 52 87 86 123l10 10H0v40h399782 +c-328 0 0 0 0 0l10 8c26.7 20 65.7 43 117 69-2.7 2-6 3.7-10 5-36.7 16-72.3 37.3 +-107 64l-10 8H0v40zM0 157v40h399730v-40zm0 194v40h399730v-40z`, + + // leftarrow is from glyph U+2190 in font KaTeX Main + leftarrow: `M400000 241H110l3-3c68.7-52.7 113.7-120 + 135-202 4-14.7 6-23 6-25 0-7.3-7-11-21-11-8 0-13.2.8-15.5 2.5-2.3 1.7-4.2 5.8 +-5.5 12.5-1.3 4.7-2.7 10.3-4 17-12 48.7-34.8 92-68.5 130S65.3 228.3 18 247 +c-10 4-16 7.7-18 11 0 8.7 6 14.3 18 17 47.3 18.7 87.8 47 121.5 85S196 441.3 208 + 490c.7 2 1.3 5 2 9s1.2 6.7 1.5 8c.3 1.3 1 3.3 2 6s2.2 4.5 3.5 5.5c1.3 1 3.3 + 1.8 6 2.5s6 1 10 1c14 0 21-3.7 21-11 0-2-2-10.3-6-25-20-79.3-65-146.7-135-202 + l-3-3h399890zM100 241v40h399900v-40z`, + + // overbrace is from glyphs U+23A9/23A8/23A7 in font KaTeX_Size4-Regular + leftbrace: `M6 548l-6-6v-35l6-11c56-104 135.3-181.3 238-232 57.3-28.7 117 +-45 179-50h399577v120H403c-43.3 7-81 15-113 26-100.7 33-179.7 91-237 174-2.7 + 5-6 9-10 13-.7 1-7.3 1-20 1H6z`, + + leftbraceunder: `M0 6l6-6h17c12.688 0 19.313.3 20 1 4 4 7.313 8.3 10 13 + 35.313 51.3 80.813 93.8 136.5 127.5 55.688 33.7 117.188 55.8 184.5 66.5.688 + 0 2 .3 4 1 18.688 2.7 76 4.3 172 5h399450v120H429l-6-1c-124.688-8-235-61.7 +-331-161C60.687 138.7 32.312 99.3 7 54L0 41V6z`, + + // overgroup is from the MnSymbol package (public domain) + leftgroup: `M400000 80 +H435C64 80 168.3 229.4 21 260c-5.9 1.2-18 0-18 0-2 0-3-1-3-3v-38C76 61 257 0 + 435 0h399565z`, + + leftgroupunder: `M400000 262 +H435C64 262 168.3 112.6 21 82c-5.9-1.2-18 0-18 0-2 0-3 1-3 3v38c76 158 257 219 + 435 219h399565z`, + + // Harpoons are from glyph U+21BD in font KaTeX Main + leftharpoon: `M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3 +-3.3 10.2-9.5 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5 +-18.3 3-21-1.3-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7 +-196 228-6.7 4.7-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40z`, + + leftharpoonplus: `M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3-3.3 10.2-9.5 + 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5-18.3 3-21-1.3 +-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7-196 228-6.7 4.7 +-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40zM0 435v40h400000v-40z +m0 0v40h400000v-40z`, + + leftharpoondown: `M7 241c-4 4-6.333 8.667-7 14 0 5.333.667 9 2 11s5.333 + 5.333 12 10c90.667 54 156 130 196 228 3.333 10.667 6.333 16.333 9 17 2 .667 5 + 1 9 1h5c10.667 0 16.667-2 18-6 2-2.667 1-9.667-3-21-32-87.333-82.667-157.667 +-152-211l-3-3h399907v-40zM93 281 H400000 v-40L7 241z`, + + leftharpoondownplus: `M7 435c-4 4-6.3 8.7-7 14 0 5.3.7 9 2 11s5.3 5.3 12 + 10c90.7 54 156 130 196 228 3.3 10.7 6.3 16.3 9 17 2 .7 5 1 9 1h5c10.7 0 16.7 +-2 18-6 2-2.7 1-9.7-3-21-32-87.3-82.7-157.7-152-211l-3-3h399907v-40H7zm93 0 +v40h399900v-40zM0 241v40h399900v-40zm0 0v40h399900v-40z`, + + // hook is from glyph U+21A9 in font KaTeX Main + lefthook: `M400000 281 H103s-33-11.2-61-33.5S0 197.3 0 164s14.2-61.2 42.5 +-83.5C70.8 58.2 104 47 142 47 c16.7 0 25 6.7 25 20 0 12-8.7 18.7-26 20-40 3.3 +-68.7 15.7-86 37-10 12-15 25.3-15 40 0 22.7 9.8 40.7 29.5 54 19.7 13.3 43.5 21 + 71.5 23h399859zM103 281v-40h399897v40z`, + + leftlinesegment: doubleBrushStroke(`M40 281 V428 H0 V94 H40 V241 H400000 v40z`), + + leftbracketunder: doubleBrushStroke(`M0 0 h120 V290 H399995 v120 H0z`), + + leftbracketover: doubleBrushStroke(`M0 440 h120 V150 H399995 v-120 H0z`), + + leftmapsto: doubleBrushStroke(`M40 281 V448H0V74H40V241H400000v40z`), + + // tofrom is from glyph U+21C4 in font KaTeX AMS Regular + leftToFrom: `M0 147h400000v40H0zm0 214c68 40 115.7 95.7 143 167h22c15.3 0 23 +-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69-70-101l-7-8h399905v-40H95l7-8 +c28.7-32 52-65.7 70-101 10.7-23.3 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 265.3 + 68 321 0 361zm0-174v-40h399900v40zm100 154v40h399900v-40z`, + + longequal: doubleBrushStroke(`M0 50 h400000 v40H0z m0 194h40000v40H0z`), + + midbrace: `M200428 334 +c-100.7-8.3-195.3-44-280-108-55.3-42-101.7-93-139-153l-9-14c-2.7 4-5.7 8.7-9 14 +-53.3 86.7-123.7 153-211 199-66.7 36-137.3 56.3-212 62H0V214h199568c178.3-11.7 + 311.7-78.3 403-201 6-8 9.7-12 11-12 .7-.7 6.7-1 18-1s17.3.3 18 1c1.3 0 5 4 11 + 12 44.7 59.3 101.3 106.3 170 141s145.3 54.3 229 60h199572v120z`, + + midbraceunder: `M199572 214 +c100.7 8.3 195.3 44 280 108 55.3 42 101.7 93 139 153l9 14c2.7-4 5.7-8.7 9-14 + 53.3-86.7 123.7-153 211-199 66.7-36 137.3-56.3 212-62h199568v120H200432c-178.3 + 11.7-311.7 78.3-403 201-6 8-9.7 12-11 12-.7.7-6.7 1-18 1s-17.3-.3-18-1c-1.3 0 +-5-4-11-12-44.7-59.3-101.3-106.3-170-141s-145.3-54.3-229-60H0V214z`, + + oiintSize1: `M512.6 71.6c272.6 0 320.3 106.8 320.3 178.2 0 70.8-47.7 177.6 +-320.3 177.6S193.1 320.6 193.1 249.8c0-71.4 46.9-178.2 319.5-178.2z +m368.1 178.2c0-86.4-60.9-215.4-368.1-215.4-306.4 0-367.3 129-367.3 215.4 0 85.8 +60.9 214.8 367.3 214.8 307.2 0 368.1-129 368.1-214.8z`, + + oiintSize2: `M757.8 100.1c384.7 0 451.1 137.6 451.1 230 0 91.3-66.4 228.8 +-451.1 228.8-386.3 0-452.7-137.5-452.7-228.8 0-92.4 66.4-230 452.7-230z +m502.4 230c0-111.2-82.4-277.2-502.4-277.2s-504 166-504 277.2 +c0 110 84 276 504 276s502.4-166 502.4-276z`, + + oiiintSize1: `M681.4 71.6c408.9 0 480.5 106.8 480.5 178.2 0 70.8-71.6 177.6 +-480.5 177.6S202.1 320.6 202.1 249.8c0-71.4 70.5-178.2 479.3-178.2z +m525.8 178.2c0-86.4-86.8-215.4-525.7-215.4-437.9 0-524.7 129-524.7 215.4 0 +85.8 86.8 214.8 524.7 214.8 438.9 0 525.7-129 525.7-214.8z`, + + oiiintSize2: `M1021.2 53c603.6 0 707.8 165.8 707.8 277.2 0 110-104.2 275.8 +-707.8 275.8-606 0-710.2-165.8-710.2-275.8C311 218.8 415.2 53 1021.2 53z +m770.4 277.1c0-131.2-126.4-327.6-770.5-327.6S248.4 198.9 248.4 330.1 +c0 130 128.8 326.4 772.7 326.4s770.5-196.4 770.5-326.4z`, + + rightarrow: `M0 241v40h399891c-47.3 35.3-84 78-110 128 +-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20 + 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7 + 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85 +-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5 +-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67 + 151.7 139 205zm0 0v40h399900v-40z`, + + rightbrace: `M400000 542l +-6 6h-17c-12.7 0-19.3-.3-20-1-4-4-7.3-8.3-10-13-35.3-51.3-80.8-93.8-136.5-127.5 +s-117.2-55.8-184.5-66.5c-.7 0-2-.3-4-1-18.7-2.7-76-4.3-172-5H0V214h399571l6 1 +c124.7 8 235 61.7 331 161 31.3 33.3 59.7 72.7 85 118l7 13v35z`, + + rightbraceunder: `M399994 0l6 6v35l-6 11c-56 104-135.3 181.3-238 232-57.3 + 28.7-117 45-179 50H-300V214h399897c43.3-7 81-15 113-26 100.7-33 179.7-91 237 +-174 2.7-5 6-9 10-13 .7-1 7.3-1 20-1h17z`, + + rightgroup: `M0 80h399565c371 0 266.7 149.4 414 180 5.9 1.2 18 0 18 0 2 0 + 3-1 3-3v-38c-76-158-257-219-435-219H0z`, + + rightgroupunder: `M0 262h399565c371 0 266.7-149.4 414-180 5.9-1.2 18 0 18 + 0 2 0 3 1 3 3v38c-76 158-257 219-435 219H0z`, + + rightharpoon: `M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3 +-3.7-15.3-11-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2 +-10.7 0-16.7 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58 + 69.2 92 94.5zm0 0v40h399900v-40z`, + + rightharpoonplus: `M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3-3.7-15.3-11 +-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2-10.7 0-16.7 + 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58 69.2 92 94.5z +m0 0v40h399900v-40z m100 194v40h399900v-40zm0 0v40h399900v-40z`, + + rightharpoondown: `M399747 511c0 7.3 6.7 11 20 11 8 0 13-.8 15-2.5s4.7-6.8 + 8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3 8.5-5.8 9.5 +-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3-64.7 57-92 95 +-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 241v40h399900v-40z`, + + rightharpoondownplus: `M399747 705c0 7.3 6.7 11 20 11 8 0 13-.8 + 15-2.5s4.7-6.8 8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3 + 8.5-5.8 9.5-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3 +-64.7 57-92 95-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 435v40h399900v-40z +m0-194v40h400000v-40zm0 0v40h400000v-40z`, + + righthook: `M399859 241c-764 0 0 0 0 0 40-3.3 68.7-15.7 86-37 10-12 15-25.3 + 15-40 0-22.7-9.8-40.7-29.5-54-19.7-13.3-43.5-21-71.5-23-17.3-1.3-26-8-26-20 0 +-13.3 8.7-20 26-20 38 0 71 11.2 99 33.5 0 0 7 5.6 21 16.7 14 11.2 21 33.5 21 + 66.8s-14 61.2-42 83.5c-28 22.3-61 33.5-99 33.5L0 241z M0 281v-40h399859v40z`, + + rightlinesegment: doubleBrushStroke(`M399960 241 V94 h40 V428 h-40 V281 H0 v-40z`), + + rightbracketunder: doubleBrushStroke(`M399995 0 h-120 V290 H0 v120 H400000z`), + + rightbracketover: doubleBrushStroke(`M399995 440 h-120 V150 H0 v-120 H399995z`), + + rightToFrom: `M400000 167c-70.7-42-118-97.7-142-167h-23c-15.3 0-23 .3-23 + 1 0 1.3 5.3 13.7 16 37 18 35.3 41.3 69 70 101l7 8H0v40h399905l-7 8c-28.7 32 +-52 65.7-70 101-10.7 23.3-16 35.7-16 37 0 .7 7.7 1 23 1h23c24-69.3 71.3-125 142 +-167z M100 147v40h399900v-40zM0 341v40h399900v-40z`, + + // twoheadleftarrow is from glyph U+219E in font KaTeX AMS Regular + twoheadleftarrow: `M0 167c68 40 + 115.7 95.7 143 167h22c15.3 0 23-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69 +-70-101l-7-8h125l9 7c50.7 39.3 85 86 103 140h46c0-4.7-6.3-18.7-19-42-18-35.3 +-40-67.3-66-96l-9-9h399716v-40H284l9-9c26-28.7 48-60.7 66-96 12.7-23.333 19 +-37.333 19-42h-46c-18 54-52.3 100.7-103 140l-9 7H95l7-8c28.7-32 52-65.7 70-101 + 10.7-23.333 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 71.3 68 127 0 167z`, + + twoheadrightarrow: `M400000 167 +c-68-40-115.7-95.7-143-167h-22c-15.3 0-23 .3-23 1 0 1.3 5.3 13.7 16 37 18 35.3 + 41.3 69 70 101l7 8h-125l-9-7c-50.7-39.3-85-86-103-140h-46c0 4.7 6.3 18.7 19 42 + 18 35.3 40 67.3 66 96l9 9H0v40h399716l-9 9c-26 28.7-48 60.7-66 96-12.7 23.333 +-19 37.333-19 42h46c18-54 52.3-100.7 103-140l9-7h125l-7 8c-28.7 32-52 65.7-70 + 101-10.7 23.333-16 35.7-16 37 0 .7 7.7 1 23 1h22c27.3-71.3 75-127 143-167z`, + + // tilde1 is a modified version of a glyph from the MnSymbol package + tilde1: `M200 55.538c-77 0-168 73.953-177 73.953-3 0-7 +-2.175-9-5.437L2 97c-1-2-2-4-2-6 0-4 2-7 5-9l20-12C116 12 171 0 207 0c86 0 + 114 68 191 68 78 0 168-68 177-68 4 0 7 2 9 5l12 19c1 2.175 2 4.35 2 6.525 0 + 4.35-2 7.613-5 9.788l-19 13.05c-92 63.077-116.937 75.308-183 76.128 +-68.267.847-113-73.952-191-73.952z`, + + // ditto tilde2, tilde3, & tilde4 + tilde2: `M344 55.266c-142 0-300.638 81.316-311.5 86.418 +-8.01 3.762-22.5 10.91-23.5 5.562L1 120c-1-2-1-3-1-4 0-5 3-9 8-10l18.4-9C160.9 + 31.9 283 0 358 0c148 0 188 122 331 122s314-97 326-97c4 0 8 2 10 7l7 21.114 +c1 2.14 1 3.21 1 4.28 0 5.347-3 9.626-7 10.696l-22.3 12.622C852.6 158.372 751 + 181.476 676 181.476c-149 0-189-126.21-332-126.21z`, + + tilde3: `M786 59C457 59 32 175.242 13 175.242c-6 0-10-3.457 +-11-10.37L.15 138c-1-7 3-12 10-13l19.2-6.4C378.4 40.7 634.3 0 804.3 0c337 0 + 411.8 157 746.8 157 328 0 754-112 773-112 5 0 10 3 11 9l1 14.075c1 8.066-.697 + 16.595-6.697 17.492l-21.052 7.31c-367.9 98.146-609.15 122.696-778.15 122.696 + -338 0-409-156.573-744-156.573z`, + + tilde4: `M786 58C457 58 32 177.487 13 177.487c-6 0-10-3.345 +-11-10.035L.15 143c-1-7 3-12 10-13l22-6.7C381.2 35 637.15 0 807.15 0c337 0 409 + 177 744 177 328 0 754-127 773-127 5 0 10 3 11 9l1 14.794c1 7.805-3 13.38-9 + 14.495l-20.7 5.574c-366.85 99.79-607.3 139.372-776.3 139.372-338 0-409 + -175.236-744-175.236z`, + + // vec is from glyph U+20D7 in font KaTeX Main + vec: `M377 20c0-5.333 1.833-10 5.5-14S391 0 397 0c4.667 0 8.667 1.667 12 5 +3.333 2.667 6.667 9 10 19 6.667 24.667 20.333 43.667 41 57 7.333 4.667 11 +10.667 11 18 0 6-1 10-3 12s-6.667 5-14 9c-28.667 14.667-53.667 35.667-75 63 +-1.333 1.333-3.167 3.5-5.5 6.5s-4 4.833-5 5.5c-1 .667-2.5 1.333-4.5 2s-4.333 1 +-7 1c-4.667 0-9.167-1.833-13.5-5.5S337 184 337 178c0-12.667 15.667-32.333 47-59 +H213l-171-1c-8.667-6-13-12.333-13-19 0-4.667 4.333-11.333 13-20h359 +c-16-25.333-24-45-24-59z`, + + // widehat1 is a modified version of a glyph from the MnSymbol package + widehat1: `M529 0h5l519 115c5 1 9 5 9 10 0 1-1 2-1 3l-4 22 +c-1 5-5 9-11 9h-2L532 67 19 159h-2c-5 0-9-4-11-9l-5-22c-1-6 2-12 8-13z`, + + // ditto widehat2, widehat3, & widehat4 + widehat2: `M1181 0h2l1171 176c6 0 10 5 10 11l-2 23c-1 6-5 10 +-11 10h-1L1182 67 15 220h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z`, + + widehat3: `M1181 0h2l1171 236c6 0 10 5 10 11l-2 23c-1 6-5 10 +-11 10h-1L1182 67 15 280h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z`, + + widehat4: `M1181 0h2l1171 296c6 0 10 5 10 11l-2 23c-1 6-5 10 +-11 10h-1L1182 67 15 340h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z`, + + // widecheck paths are all inverted versions of widehat + widecheck1: `M529,159h5l519,-115c5,-1,9,-5,9,-10c0,-1,-1,-2,-1,-3l-4,-22c-1, +-5,-5,-9,-11,-9h-2l-512,92l-513,-92h-2c-5,0,-9,4,-11,9l-5,22c-1,6,2,12,8,13z`, + + widecheck2: `M1181,220h2l1171,-176c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10, +-11,-10h-1l-1168,153l-1167,-153h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z`, + + widecheck3: `M1181,280h2l1171,-236c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10, +-11,-10h-1l-1168,213l-1167,-213h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z`, + + widecheck4: `M1181,340h2l1171,-296c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10, +-11,-10h-1l-1168,273l-1167,-273h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z`, + + // The next ten paths support reaction arrows from the mhchem package. + + // Arrows for \ce{<-->} are offset from xAxis by 0.22ex, per mhchem in LaTeX + // baraboveleftarrow is mostly from glyph U+2190 in font KaTeX Main + baraboveleftarrow: `M400000 620h-399890l3 -3c68.7 -52.7 113.7 -120 135 -202 +c4 -14.7 6 -23 6 -25c0 -7.3 -7 -11 -21 -11c-8 0 -13.2 0.8 -15.5 2.5 +c-2.3 1.7 -4.2 5.8 -5.5 12.5c-1.3 4.7 -2.7 10.3 -4 17c-12 48.7 -34.8 92 -68.5 130 +s-74.2 66.3 -121.5 85c-10 4 -16 7.7 -18 11c0 8.7 6 14.3 18 17c47.3 18.7 87.8 47 +121.5 85s56.5 81.3 68.5 130c0.7 2 1.3 5 2 9s1.2 6.7 1.5 8c0.3 1.3 1 3.3 2 6 +s2.2 4.5 3.5 5.5c1.3 1 3.3 1.8 6 2.5s6 1 10 1c14 0 21 -3.7 21 -11 +c0 -2 -2 -10.3 -6 -25c-20 -79.3 -65 -146.7 -135 -202l-3 -3h399890z +M100 620v40h399900v-40z M0 241v40h399900v-40zM0 241v40h399900v-40z`, + + // rightarrowabovebar is mostly from glyph U+2192, KaTeX Main + rightarrowabovebar: `M0 241v40h399891c-47.3 35.3-84 78-110 128-16.7 32 +-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20 11 8 0 +13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7 39 +-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85-40.5 +-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5 +-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67 +151.7 139 205zm96 379h399894v40H0zm0 0h399904v40H0z`, + + // The short left harpoon has 0.5em (i.e. 500 units) kern on the left end. + // Ref from mhchem.sty: \rlap{\raisebox{-.22ex}{$\kern0.5em + baraboveshortleftharpoon: `M507,435c-4,4,-6.3,8.7,-7,14c0,5.3,0.7,9,2,11 +c1.3,2,5.3,5.3,12,10c90.7,54,156,130,196,228c3.3,10.7,6.3,16.3,9,17 +c2,0.7,5,1,9,1c0,0,5,0,5,0c10.7,0,16.7,-2,18,-6c2,-2.7,1,-9.7,-3,-21 +c-32,-87.3,-82.7,-157.7,-152,-211c0,0,-3,-3,-3,-3l399351,0l0,-40 +c-398570,0,-399437,0,-399437,0z M593 435 v40 H399500 v-40z +M0 281 v-40 H399908 v40z M0 281 v-40 H399908 v40z`, + + rightharpoonaboveshortbar: `M0,241 l0,40c399126,0,399993,0,399993,0 +c4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199, +-231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6 +c-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z +M0 241 v40 H399908 v-40z M0 475 v-40 H399500 v40z M0 475 v-40 H399500 v40z`, + + shortbaraboveleftharpoon: `M7,435c-4,4,-6.3,8.7,-7,14c0,5.3,0.7,9,2,11 +c1.3,2,5.3,5.3,12,10c90.7,54,156,130,196,228c3.3,10.7,6.3,16.3,9,17c2,0.7,5,1,9, +1c0,0,5,0,5,0c10.7,0,16.7,-2,18,-6c2,-2.7,1,-9.7,-3,-21c-32,-87.3,-82.7,-157.7, +-152,-211c0,0,-3,-3,-3,-3l399907,0l0,-40c-399126,0,-399993,0,-399993,0z +M93 435 v40 H400000 v-40z M500 241 v40 H400000 v-40z M500 241 v40 H400000 v-40z`, + + shortrightharpoonabovebar: `M53,241l0,40c398570,0,399437,0,399437,0 +c4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199, +-231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6 +c-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z +M500 241 v40 H399408 v-40z M500 435 v40 H400000 v-40z`, +}; + +export const tallDelim = function(label: string, midHeight: number): string { + switch (label) { + case "lbrack": + return `M403 1759 V84 H666 V0 H319 V1759 v${midHeight} v1759 v84 h347 v-84 +H403z M403 1759 V0 H319 V1759 v${midHeight} v1759 v84 h84z`; + case "rbrack": + return `M347 1759 V0 H0 V84 H263 V1759 v${midHeight} v1759 H0 v84 H347z +M347 1759 V0 H263 V1759 v${midHeight} v1759 h84z`; + case "vert": + return `M145 15 v585 v${midHeight} v585 c2.667,10,9.667,15,21,15 +c10,0,16.667,-5,20,-15 v-585 v${-midHeight} v-585 c-2.667,-10,-9.667,-15,-21,-15 +c-10,0,-16.667,5,-20,15z M188 15 H145 v585 v${midHeight} v585 h43z`; + case "doublevert": + return `M145 15 v585 v${midHeight} v585 c2.667,10,9.667,15,21,15 +c10,0,16.667,-5,20,-15 v-585 v${-midHeight} v-585 c-2.667,-10,-9.667,-15,-21,-15 +c-10,0,-16.667,5,-20,15z M188 15 H145 v585 v${midHeight} v585 h43z +M367 15 v585 v${midHeight} v585 c2.667,10,9.667,15,21,15 +c10,0,16.667,-5,20,-15 v-585 v${-midHeight} v-585 c-2.667,-10,-9.667,-15,-21,-15 +c-10,0,-16.667,5,-20,15z M410 15 H367 v585 v${midHeight} v585 h43z`; + case "lfloor": + return `M319 602 V0 H403 V602 v${midHeight} v1715 h263 v84 H319z +MM319 602 V0 H403 V602 v${midHeight} v1715 H319z`; + case "rfloor": + return `M319 602 V0 H403 V602 v${midHeight} v1799 H0 v-84 H319z +MM319 602 V0 H403 V602 v${midHeight} v1715 H319z`; + case "lceil": + return `M403 1759 V84 H666 V0 H319 V1759 v${midHeight} v602 h84z +M403 1759 V0 H319 V1759 v${midHeight} v602 h84z`; + case "rceil": + return `M347 1759 V0 H0 V84 H263 V1759 v${midHeight} v602 h84z +M347 1759 V0 h-84 V1759 v${midHeight} v602 h84z`; + case "lparen": + return `M863,9c0,-2,-2,-5,-6,-9c0,0,-17,0,-17,0c-12.7,0,-19.3,0.3,-20,1 +c-5.3,5.3,-10.3,11,-15,17c-242.7,294.7,-395.3,682,-458,1162c-21.3,163.3,-33.3,349, +-36,557 l0,${midHeight + 84}c0.2,6,0,26,0,60c2,159.3,10,310.7,24,454c53.3,528,210, +949.7,470,1265c4.7,6,9.7,11.7,15,17c0.7,0.7,7,1,19,1c0,0,18,0,18,0c4,-4,6,-7,6,-9 +c0,-2.7,-3.3,-8.7,-10,-18c-135.3,-192.7,-235.5,-414.3,-300.5,-665c-65,-250.7,-102.5, +-544.7,-112.5,-882c-2,-104,-3,-167,-3,-189 +l0,-${midHeight + 92}c0,-162.7,5.7,-314,17,-454c20.7,-272,63.7,-513,129,-723c65.3, +-210,155.3,-396.3,270,-559c6.7,-9.3,10,-15.3,10,-18z`; + case "rparen": + return `M76,0c-16.7,0,-25,3,-25,9c0,2,2,6.3,6,13c21.3,28.7,42.3,60.3, +63,95c96.7,156.7,172.8,332.5,228.5,527.5c55.7,195,92.8,416.5,111.5,664.5 +c11.3,139.3,17,290.7,17,454c0,28,1.7,43,3.3,45l0,${midHeight + 9} +c-3,4,-3.3,16.7,-3.3,38c0,162,-5.7,313.7,-17,455c-18.7,248,-55.8,469.3,-111.5,664 +c-55.7,194.7,-131.8,370.3,-228.5,527c-20.7,34.7,-41.7,66.3,-63,95c-2,3.3,-4,7,-6,11 +c0,7.3,5.7,11,17,11c0,0,11,0,11,0c9.3,0,14.3,-0.3,15,-1c5.3,-5.3,10.3,-11,15,-17 +c242.7,-294.7,395.3,-681.7,458,-1161c21.3,-164.7,33.3,-350.7,36,-558 +l0,-${midHeight + 144}c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7, +-470,-1265c-4.7,-6,-9.7,-11.7,-15,-17c-0.7,-0.7,-6.7,-1,-18,-1z`; + default: + // We should not ever get here. + throw new Error("Unknown stretchy delimiter."); + } +}; diff --git a/node_modules/react-katex/node_modules/katex/src/symbols.ts b/node_modules/react-katex/node_modules/katex/src/symbols.ts new file mode 100644 index 0000000..d6a02c2 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/symbols.ts @@ -0,0 +1,879 @@ +/** + * This file holds a list of all no-argument functions and single-character + * symbols (like 'a' or ';'). + * + * For each of the symbols, there are three properties they can have: + * - font (required): the font to be used for this symbol. Either "main" (the + normal font), or "ams" (the ams fonts). + * - group (required): the ParseNode group type the symbol should have (i.e. + "textord", "mathord", etc). + See https://github.com/KaTeX/KaTeX/wiki/Examining-TeX#group-types + * - replace: the character that this symbol or function should be + * replaced with (i.e. "\phi" has a replace value of "\u03d5", the phi + * character in the main font). + * + * The outermost map in the table indicates what mode the symbols should be + * accepted in (e.g. "math" or "text"). + */ + +import type {Group} from "./atoms"; +import type {Mode} from "./types"; +import type {SymbolFont} from "./types/fonts"; + +// Some of these have a "-token" suffix since these are also used as `ParseNode` +// types for raw text tokens, and we want to avoid conflicts with higher-level +// `ParseNode` types. These `ParseNode`s are constructed within `Parser` by +// looking up the `symbols` map. + +type CharInfoMap = Record< + string, + {font: SymbolFont; group: Group; replace: string | null | undefined} +>; + +const symbols: Record = { + "math": {}, + "text": {}, +}; +export default symbols; + +/** `acceptUnicodeChar = true` is only applicable if `replace` is set. */ +export function defineSymbol( + mode: Mode, + font: SymbolFont, + group: Group, + replace: string, + name: string, + acceptUnicodeChar?: boolean, +) { + symbols[mode][name] = {font, group, replace}; + + if (acceptUnicodeChar && replace) { + symbols[mode][replace] = symbols[mode][name]; + } +} + +// Some abbreviations for commonly used strings. +// This helps minify the code, and also spotting typos using jshint. + +// modes: +const math = "math"; +const text = "text"; + +// fonts: +const main = "main"; +const ams = "ams"; + +// groups: +const accent = "accent-token"; +const bin = "bin"; +const close = "close"; +const inner = "inner"; +const mathord = "mathord"; +const op = "op-token"; +const open = "open"; +const punct = "punct"; +const rel = "rel"; +const spacing = "spacing"; +const textord = "textord"; + +// Now comes the symbol table + +// Relation Symbols +defineSymbol(math, main, rel, "\u2261", "\\equiv", true); +defineSymbol(math, main, rel, "\u227a", "\\prec", true); +defineSymbol(math, main, rel, "\u227b", "\\succ", true); +defineSymbol(math, main, rel, "\u223c", "\\sim", true); +defineSymbol(math, main, rel, "\u22a5", "\\perp"); +defineSymbol(math, main, rel, "\u2aaf", "\\preceq", true); +defineSymbol(math, main, rel, "\u2ab0", "\\succeq", true); +defineSymbol(math, main, rel, "\u2243", "\\simeq", true); +defineSymbol(math, main, rel, "\u2223", "\\mid", true); +defineSymbol(math, main, rel, "\u226a", "\\ll", true); +defineSymbol(math, main, rel, "\u226b", "\\gg", true); +defineSymbol(math, main, rel, "\u224d", "\\asymp", true); +defineSymbol(math, main, rel, "\u2225", "\\parallel"); +defineSymbol(math, main, rel, "\u22c8", "\\bowtie", true); +defineSymbol(math, main, rel, "\u2323", "\\smile", true); +defineSymbol(math, main, rel, "\u2291", "\\sqsubseteq", true); +defineSymbol(math, main, rel, "\u2292", "\\sqsupseteq", true); +defineSymbol(math, main, rel, "\u2250", "\\doteq", true); +defineSymbol(math, main, rel, "\u2322", "\\frown", true); +defineSymbol(math, main, rel, "\u220b", "\\ni", true); +defineSymbol(math, main, rel, "\u221d", "\\propto", true); +defineSymbol(math, main, rel, "\u22a2", "\\vdash", true); +defineSymbol(math, main, rel, "\u22a3", "\\dashv", true); +defineSymbol(math, main, rel, "\u220b", "\\owns"); + +// Punctuation +defineSymbol(math, main, punct, "\u002e", "\\ldotp"); +defineSymbol(math, main, punct, "\u22c5", "\\cdotp"); +// The KaTeX fonts do not contain U+00B7. Use the centered dot glyph at U+22C5 +// in both modes, but keep math-mode punctuation spacing only in math mode. +defineSymbol(math, main, punct, "\u22c5", "\u00b7"); +defineSymbol(text, main, textord, "\u22c5", "\u00b7"); + +// Misc Symbols +defineSymbol(math, main, textord, "\u0023", "\\#"); +defineSymbol(text, main, textord, "\u0023", "\\#"); +defineSymbol(math, main, textord, "\u0026", "\\&"); +defineSymbol(text, main, textord, "\u0026", "\\&"); +defineSymbol(math, main, textord, "\u2135", "\\aleph", true); +defineSymbol(math, main, textord, "\u2200", "\\forall", true); +defineSymbol(math, main, textord, "\u210f", "\\hbar", true); +defineSymbol(math, main, textord, "\u2203", "\\exists", true); +defineSymbol(math, main, textord, "\u2207", "\\nabla", true); +defineSymbol(math, main, textord, "\u266d", "\\flat", true); +defineSymbol(math, main, textord, "\u2113", "\\ell", true); +defineSymbol(math, main, textord, "\u266e", "\\natural", true); +defineSymbol(math, main, textord, "\u2663", "\\clubsuit", true); +defineSymbol(math, main, textord, "\u2118", "\\wp", true); +defineSymbol(math, main, textord, "\u266f", "\\sharp", true); +defineSymbol(math, main, textord, "\u2662", "\\diamondsuit", true); +defineSymbol(math, main, textord, "\u211c", "\\Re", true); +defineSymbol(math, main, textord, "\u2661", "\\heartsuit", true); +defineSymbol(math, main, textord, "\u2111", "\\Im", true); +defineSymbol(math, main, textord, "\u2660", "\\spadesuit", true); +defineSymbol(math, main, textord, "\u00a7", "\\S", true); +defineSymbol(text, main, textord, "\u00a7", "\\S"); +defineSymbol(math, main, textord, "\u00b6", "\\P", true); +defineSymbol(text, main, textord, "\u00b6", "\\P"); + +// Math and Text +defineSymbol(math, main, textord, "\u2020", "\\dag"); +defineSymbol(text, main, textord, "\u2020", "\\dag"); +defineSymbol(text, main, textord, "\u2020", "\\textdagger"); +defineSymbol(math, main, textord, "\u2021", "\\ddag"); +defineSymbol(text, main, textord, "\u2021", "\\ddag"); +defineSymbol(text, main, textord, "\u2021", "\\textdaggerdbl"); + +// Large Delimiters +defineSymbol(math, main, close, "\u23b1", "\\rmoustache", true); +defineSymbol(math, main, open, "\u23b0", "\\lmoustache", true); +defineSymbol(math, main, close, "\u27ef", "\\rgroup", true); +defineSymbol(math, main, open, "\u27ee", "\\lgroup", true); + +// Binary Operators +defineSymbol(math, main, bin, "\u2213", "\\mp", true); +defineSymbol(math, main, bin, "\u2296", "\\ominus", true); +defineSymbol(math, main, bin, "\u228e", "\\uplus", true); +defineSymbol(math, main, bin, "\u2293", "\\sqcap", true); +defineSymbol(math, main, bin, "\u2217", "\\ast"); +defineSymbol(math, main, bin, "\u2294", "\\sqcup", true); +defineSymbol(math, main, bin, "\u25ef", "\\bigcirc", true); +defineSymbol(math, main, bin, "\u2219", "\\bullet", true); +defineSymbol(math, main, bin, "\u2021", "\\ddagger"); +defineSymbol(math, main, bin, "\u2240", "\\wr", true); +defineSymbol(math, main, bin, "\u2a3f", "\\amalg"); +defineSymbol(math, main, bin, "\u0026", "\\And"); // from amsmath + +// Arrow Symbols +defineSymbol(math, main, rel, "\u27f5", "\\longleftarrow", true); +defineSymbol(math, main, rel, "\u21d0", "\\Leftarrow", true); +defineSymbol(math, main, rel, "\u27f8", "\\Longleftarrow", true); +defineSymbol(math, main, rel, "\u27f6", "\\longrightarrow", true); +defineSymbol(math, main, rel, "\u21d2", "\\Rightarrow", true); +defineSymbol(math, main, rel, "\u27f9", "\\Longrightarrow", true); +defineSymbol(math, main, rel, "\u2194", "\\leftrightarrow", true); +defineSymbol(math, main, rel, "\u27f7", "\\longleftrightarrow", true); +defineSymbol(math, main, rel, "\u21d4", "\\Leftrightarrow", true); +defineSymbol(math, main, rel, "\u27fa", "\\Longleftrightarrow", true); +defineSymbol(math, main, rel, "\u21a6", "\\mapsto", true); +defineSymbol(math, main, rel, "\u27fc", "\\longmapsto", true); +defineSymbol(math, main, rel, "\u2197", "\\nearrow", true); +defineSymbol(math, main, rel, "\u21a9", "\\hookleftarrow", true); +defineSymbol(math, main, rel, "\u21aa", "\\hookrightarrow", true); +defineSymbol(math, main, rel, "\u2198", "\\searrow", true); +defineSymbol(math, main, rel, "\u21bc", "\\leftharpoonup", true); +defineSymbol(math, main, rel, "\u21c0", "\\rightharpoonup", true); +defineSymbol(math, main, rel, "\u2199", "\\swarrow", true); +defineSymbol(math, main, rel, "\u21bd", "\\leftharpoondown", true); +defineSymbol(math, main, rel, "\u21c1", "\\rightharpoondown", true); +defineSymbol(math, main, rel, "\u2196", "\\nwarrow", true); +defineSymbol(math, main, rel, "\u21cc", "\\rightleftharpoons", true); + +// AMS Negated Binary Relations +defineSymbol(math, ams, rel, "\u226e", "\\nless", true); +// Symbol names preceded by "@" each have a corresponding macro. +defineSymbol(math, ams, rel, "\ue010", "\\@nleqslant"); +defineSymbol(math, ams, rel, "\ue011", "\\@nleqq"); +defineSymbol(math, ams, rel, "\u2a87", "\\lneq", true); +defineSymbol(math, ams, rel, "\u2268", "\\lneqq", true); +defineSymbol(math, ams, rel, "\ue00c", "\\@lvertneqq"); +defineSymbol(math, ams, rel, "\u22e6", "\\lnsim", true); +defineSymbol(math, ams, rel, "\u2a89", "\\lnapprox", true); +defineSymbol(math, ams, rel, "\u2280", "\\nprec", true); +// unicode-math maps \u22e0 to \npreccurlyeq. We'll use the AMS synonym. +defineSymbol(math, ams, rel, "\u22e0", "\\npreceq", true); +defineSymbol(math, ams, rel, "\u22e8", "\\precnsim", true); +defineSymbol(math, ams, rel, "\u2ab9", "\\precnapprox", true); +defineSymbol(math, ams, rel, "\u2241", "\\nsim", true); +defineSymbol(math, ams, rel, "\ue006", "\\@nshortmid"); +defineSymbol(math, ams, rel, "\u2224", "\\nmid", true); +defineSymbol(math, ams, rel, "\u22ac", "\\nvdash", true); +defineSymbol(math, ams, rel, "\u22ad", "\\nvDash", true); +defineSymbol(math, ams, rel, "\u22ea", "\\ntriangleleft"); +defineSymbol(math, ams, rel, "\u22ec", "\\ntrianglelefteq", true); +defineSymbol(math, ams, rel, "\u228a", "\\subsetneq", true); +defineSymbol(math, ams, rel, "\ue01a", "\\@varsubsetneq"); +defineSymbol(math, ams, rel, "\u2acb", "\\subsetneqq", true); +defineSymbol(math, ams, rel, "\ue017", "\\@varsubsetneqq"); +defineSymbol(math, ams, rel, "\u226f", "\\ngtr", true); +defineSymbol(math, ams, rel, "\ue00f", "\\@ngeqslant"); +defineSymbol(math, ams, rel, "\ue00e", "\\@ngeqq"); +defineSymbol(math, ams, rel, "\u2a88", "\\gneq", true); +defineSymbol(math, ams, rel, "\u2269", "\\gneqq", true); +defineSymbol(math, ams, rel, "\ue00d", "\\@gvertneqq"); +defineSymbol(math, ams, rel, "\u22e7", "\\gnsim", true); +defineSymbol(math, ams, rel, "\u2a8a", "\\gnapprox", true); +defineSymbol(math, ams, rel, "\u2281", "\\nsucc", true); +// unicode-math maps \u22e1 to \nsucccurlyeq. We'll use the AMS synonym. +defineSymbol(math, ams, rel, "\u22e1", "\\nsucceq", true); +defineSymbol(math, ams, rel, "\u22e9", "\\succnsim", true); +defineSymbol(math, ams, rel, "\u2aba", "\\succnapprox", true); +// unicode-math maps \u2246 to \simneqq. We'll use the AMS synonym. +defineSymbol(math, ams, rel, "\u2246", "\\ncong", true); +defineSymbol(math, ams, rel, "\ue007", "\\@nshortparallel"); +defineSymbol(math, ams, rel, "\u2226", "\\nparallel", true); +defineSymbol(math, ams, rel, "\u22af", "\\nVDash", true); +defineSymbol(math, ams, rel, "\u22eb", "\\ntriangleright"); +defineSymbol(math, ams, rel, "\u22ed", "\\ntrianglerighteq", true); +defineSymbol(math, ams, rel, "\ue018", "\\@nsupseteqq"); +defineSymbol(math, ams, rel, "\u228b", "\\supsetneq", true); +defineSymbol(math, ams, rel, "\ue01b", "\\@varsupsetneq"); +defineSymbol(math, ams, rel, "\u2acc", "\\supsetneqq", true); +defineSymbol(math, ams, rel, "\ue019", "\\@varsupsetneqq"); +defineSymbol(math, ams, rel, "\u22ae", "\\nVdash", true); +defineSymbol(math, ams, rel, "\u2ab5", "\\precneqq", true); +defineSymbol(math, ams, rel, "\u2ab6", "\\succneqq", true); +defineSymbol(math, ams, rel, "\ue016", "\\@nsubseteqq"); +defineSymbol(math, ams, bin, "\u22b4", "\\unlhd"); +defineSymbol(math, ams, bin, "\u22b5", "\\unrhd"); + +// AMS Negated Arrows +defineSymbol(math, ams, rel, "\u219a", "\\nleftarrow", true); +defineSymbol(math, ams, rel, "\u219b", "\\nrightarrow", true); +defineSymbol(math, ams, rel, "\u21cd", "\\nLeftarrow", true); +defineSymbol(math, ams, rel, "\u21cf", "\\nRightarrow", true); +defineSymbol(math, ams, rel, "\u21ae", "\\nleftrightarrow", true); +defineSymbol(math, ams, rel, "\u21ce", "\\nLeftrightarrow", true); + +// AMS Misc +defineSymbol(math, ams, rel, "\u25b3", "\\vartriangle"); +defineSymbol(math, ams, textord, "\u210f", "\\hslash"); +defineSymbol(math, ams, textord, "\u25bd", "\\triangledown"); +defineSymbol(math, ams, textord, "\u25ca", "\\lozenge"); +defineSymbol(math, ams, textord, "\u24c8", "\\circledS"); +defineSymbol(math, ams, textord, "\u00ae", "\\circledR"); +defineSymbol(text, ams, textord, "\u00ae", "\\circledR"); +defineSymbol(math, ams, textord, "\u2221", "\\measuredangle", true); +defineSymbol(math, ams, textord, "\u2204", "\\nexists"); +defineSymbol(math, ams, textord, "\u2127", "\\mho"); +defineSymbol(math, ams, textord, "\u2132", "\\Finv", true); +defineSymbol(math, ams, textord, "\u2141", "\\Game", true); +defineSymbol(math, ams, textord, "\u2035", "\\backprime"); +defineSymbol(math, ams, textord, "\u25b2", "\\blacktriangle"); +defineSymbol(math, ams, textord, "\u25bc", "\\blacktriangledown"); +defineSymbol(math, ams, textord, "\u25a0", "\\blacksquare"); +defineSymbol(math, ams, textord, "\u29eb", "\\blacklozenge"); +defineSymbol(math, ams, textord, "\u2605", "\\bigstar"); +defineSymbol(math, ams, textord, "\u2222", "\\sphericalangle", true); +defineSymbol(math, ams, textord, "\u2201", "\\complement", true); +// unicode-math maps U+F0 to \matheth. We map to AMS function \eth +defineSymbol(math, ams, textord, "\u00f0", "\\eth", true); +defineSymbol(text, main, textord, "\u00f0", "\u00f0"); +defineSymbol(math, ams, textord, "\u2571", "\\diagup"); +defineSymbol(math, ams, textord, "\u2572", "\\diagdown"); +defineSymbol(math, ams, textord, "\u25a1", "\\square"); +defineSymbol(math, ams, textord, "\u25a1", "\\Box"); +defineSymbol(math, ams, textord, "\u25ca", "\\Diamond"); +// unicode-math maps U+A5 to \mathyen. We map to AMS function \yen +defineSymbol(math, ams, textord, "\u00a5", "\\yen", true); +defineSymbol(text, ams, textord, "\u00a5", "\\yen", true); +defineSymbol(math, ams, textord, "\u2713", "\\checkmark", true); +defineSymbol(text, ams, textord, "\u2713", "\\checkmark"); + +// AMS Hebrew +defineSymbol(math, ams, textord, "\u2136", "\\beth", true); +defineSymbol(math, ams, textord, "\u2138", "\\daleth", true); +defineSymbol(math, ams, textord, "\u2137", "\\gimel", true); + +// AMS Greek +defineSymbol(math, ams, textord, "\u03dd", "\\digamma", true); +defineSymbol(math, ams, textord, "\u03f0", "\\varkappa"); + +// AMS Delimiters +defineSymbol(math, ams, open, "\u250c", "\\@ulcorner", true); +defineSymbol(math, ams, close, "\u2510", "\\@urcorner", true); +defineSymbol(math, ams, open, "\u2514", "\\@llcorner", true); +defineSymbol(math, ams, close, "\u2518", "\\@lrcorner", true); + +// AMS Binary Relations +defineSymbol(math, ams, rel, "\u2266", "\\leqq", true); +defineSymbol(math, ams, rel, "\u2a7d", "\\leqslant", true); +defineSymbol(math, ams, rel, "\u2a95", "\\eqslantless", true); +defineSymbol(math, ams, rel, "\u2272", "\\lesssim", true); +defineSymbol(math, ams, rel, "\u2a85", "\\lessapprox", true); +defineSymbol(math, ams, rel, "\u224a", "\\approxeq", true); +defineSymbol(math, ams, bin, "\u22d6", "\\lessdot"); +defineSymbol(math, ams, rel, "\u22d8", "\\lll", true); +defineSymbol(math, ams, rel, "\u2276", "\\lessgtr", true); +defineSymbol(math, ams, rel, "\u22da", "\\lesseqgtr", true); +defineSymbol(math, ams, rel, "\u2a8b", "\\lesseqqgtr", true); +defineSymbol(math, ams, rel, "\u2251", "\\doteqdot"); +defineSymbol(math, ams, rel, "\u2253", "\\risingdotseq", true); +defineSymbol(math, ams, rel, "\u2252", "\\fallingdotseq", true); +defineSymbol(math, ams, rel, "\u223d", "\\backsim", true); +defineSymbol(math, ams, rel, "\u22cd", "\\backsimeq", true); +defineSymbol(math, ams, rel, "\u2ac5", "\\subseteqq", true); +defineSymbol(math, ams, rel, "\u22d0", "\\Subset", true); +defineSymbol(math, ams, rel, "\u228f", "\\sqsubset", true); +defineSymbol(math, ams, rel, "\u227c", "\\preccurlyeq", true); +defineSymbol(math, ams, rel, "\u22de", "\\curlyeqprec", true); +defineSymbol(math, ams, rel, "\u227e", "\\precsim", true); +defineSymbol(math, ams, rel, "\u2ab7", "\\precapprox", true); +defineSymbol(math, ams, rel, "\u22b2", "\\vartriangleleft"); +defineSymbol(math, ams, rel, "\u22b4", "\\trianglelefteq"); +defineSymbol(math, ams, rel, "\u22a8", "\\vDash", true); +defineSymbol(math, ams, rel, "\u22aa", "\\Vvdash", true); +defineSymbol(math, ams, rel, "\u2323", "\\smallsmile"); +defineSymbol(math, ams, rel, "\u2322", "\\smallfrown"); +defineSymbol(math, ams, rel, "\u224f", "\\bumpeq", true); +defineSymbol(math, ams, rel, "\u224e", "\\Bumpeq", true); +defineSymbol(math, ams, rel, "\u2267", "\\geqq", true); +defineSymbol(math, ams, rel, "\u2a7e", "\\geqslant", true); +defineSymbol(math, ams, rel, "\u2a96", "\\eqslantgtr", true); +defineSymbol(math, ams, rel, "\u2273", "\\gtrsim", true); +defineSymbol(math, ams, rel, "\u2a86", "\\gtrapprox", true); +defineSymbol(math, ams, bin, "\u22d7", "\\gtrdot"); +defineSymbol(math, ams, rel, "\u22d9", "\\ggg", true); +defineSymbol(math, ams, rel, "\u2277", "\\gtrless", true); +defineSymbol(math, ams, rel, "\u22db", "\\gtreqless", true); +defineSymbol(math, ams, rel, "\u2a8c", "\\gtreqqless", true); +defineSymbol(math, ams, rel, "\u2256", "\\eqcirc", true); +defineSymbol(math, ams, rel, "\u2257", "\\circeq", true); +defineSymbol(math, ams, rel, "\u225c", "\\triangleq", true); +defineSymbol(math, ams, rel, "\u223c", "\\thicksim"); +defineSymbol(math, ams, rel, "\u2248", "\\thickapprox"); +defineSymbol(math, ams, rel, "\u2ac6", "\\supseteqq", true); +defineSymbol(math, ams, rel, "\u22d1", "\\Supset", true); +defineSymbol(math, ams, rel, "\u2290", "\\sqsupset", true); +defineSymbol(math, ams, rel, "\u227d", "\\succcurlyeq", true); +defineSymbol(math, ams, rel, "\u22df", "\\curlyeqsucc", true); +defineSymbol(math, ams, rel, "\u227f", "\\succsim", true); +defineSymbol(math, ams, rel, "\u2ab8", "\\succapprox", true); +defineSymbol(math, ams, rel, "\u22b3", "\\vartriangleright"); +defineSymbol(math, ams, rel, "\u22b5", "\\trianglerighteq"); +defineSymbol(math, ams, rel, "\u22a9", "\\Vdash", true); +defineSymbol(math, ams, rel, "\u2223", "\\shortmid"); +defineSymbol(math, ams, rel, "\u2225", "\\shortparallel"); +defineSymbol(math, ams, rel, "\u226c", "\\between", true); +defineSymbol(math, ams, rel, "\u22d4", "\\pitchfork", true); +defineSymbol(math, ams, rel, "\u221d", "\\varpropto"); +defineSymbol(math, ams, rel, "\u25c0", "\\blacktriangleleft"); +// unicode-math says that \therefore is a mathord atom. +// We kept the amssymb atom type, which is rel. +defineSymbol(math, ams, rel, "\u2234", "\\therefore", true); +defineSymbol(math, ams, rel, "\u220d", "\\backepsilon"); +defineSymbol(math, ams, rel, "\u25b6", "\\blacktriangleright"); +// unicode-math says that \because is a mathord atom. +// We kept the amssymb atom type, which is rel. +defineSymbol(math, ams, rel, "\u2235", "\\because", true); +defineSymbol(math, ams, rel, "\u22d8", "\\llless"); +defineSymbol(math, ams, rel, "\u22d9", "\\gggtr"); +defineSymbol(math, ams, bin, "\u22b2", "\\lhd"); +defineSymbol(math, ams, bin, "\u22b3", "\\rhd"); +defineSymbol(math, ams, rel, "\u2242", "\\eqsim", true); +defineSymbol(math, main, rel, "\u22c8", "\\Join"); +defineSymbol(math, ams, rel, "\u2251", "\\Doteq", true); + +// AMS Binary Operators +defineSymbol(math, ams, bin, "\u2214", "\\dotplus", true); +defineSymbol(math, ams, bin, "\u2216", "\\smallsetminus"); +defineSymbol(math, ams, bin, "\u22d2", "\\Cap", true); +defineSymbol(math, ams, bin, "\u22d3", "\\Cup", true); +defineSymbol(math, ams, bin, "\u2a5e", "\\doublebarwedge", true); +defineSymbol(math, ams, bin, "\u229f", "\\boxminus", true); +defineSymbol(math, ams, bin, "\u229e", "\\boxplus", true); +defineSymbol(math, ams, bin, "\u22c7", "\\divideontimes", true); +defineSymbol(math, ams, bin, "\u22c9", "\\ltimes", true); +defineSymbol(math, ams, bin, "\u22ca", "\\rtimes", true); +defineSymbol(math, ams, bin, "\u22cb", "\\leftthreetimes", true); +defineSymbol(math, ams, bin, "\u22cc", "\\rightthreetimes", true); +defineSymbol(math, ams, bin, "\u22cf", "\\curlywedge", true); +defineSymbol(math, ams, bin, "\u22ce", "\\curlyvee", true); +defineSymbol(math, ams, bin, "\u229d", "\\circleddash", true); +defineSymbol(math, ams, bin, "\u229b", "\\circledast", true); +defineSymbol(math, ams, bin, "\u22c5", "\\centerdot"); +defineSymbol(math, ams, bin, "\u22ba", "\\intercal", true); +defineSymbol(math, ams, bin, "\u22d2", "\\doublecap"); +defineSymbol(math, ams, bin, "\u22d3", "\\doublecup"); +defineSymbol(math, ams, bin, "\u22a0", "\\boxtimes", true); + +// AMS Arrows +// Note: unicode-math maps \u21e2 to their own function \rightdasharrow. +// We'll map it to AMS function \dashrightarrow. It produces the same atom. +defineSymbol(math, ams, rel, "\u21e2", "\\dashrightarrow", true); +// unicode-math maps \u21e0 to \leftdasharrow. We'll use the AMS synonym. +defineSymbol(math, ams, rel, "\u21e0", "\\dashleftarrow", true); +defineSymbol(math, ams, rel, "\u21c7", "\\leftleftarrows", true); +defineSymbol(math, ams, rel, "\u21c6", "\\leftrightarrows", true); +defineSymbol(math, ams, rel, "\u21da", "\\Lleftarrow", true); +defineSymbol(math, ams, rel, "\u219e", "\\twoheadleftarrow", true); +defineSymbol(math, ams, rel, "\u21a2", "\\leftarrowtail", true); +defineSymbol(math, ams, rel, "\u21ab", "\\looparrowleft", true); +defineSymbol(math, ams, rel, "\u21cb", "\\leftrightharpoons", true); +defineSymbol(math, ams, rel, "\u21b6", "\\curvearrowleft", true); +// unicode-math maps \u21ba to \acwopencirclearrow. We'll use the AMS synonym. +defineSymbol(math, ams, rel, "\u21ba", "\\circlearrowleft", true); +defineSymbol(math, ams, rel, "\u21b0", "\\Lsh", true); +defineSymbol(math, ams, rel, "\u21c8", "\\upuparrows", true); +defineSymbol(math, ams, rel, "\u21bf", "\\upharpoonleft", true); +defineSymbol(math, ams, rel, "\u21c3", "\\downharpoonleft", true); +defineSymbol(math, main, rel, "\u22b6", "\\origof", true); // not in font +defineSymbol(math, main, rel, "\u22b7", "\\imageof", true); // not in font +defineSymbol(math, ams, rel, "\u22b8", "\\multimap", true); +defineSymbol(math, ams, rel, "\u21ad", "\\leftrightsquigarrow", true); +defineSymbol(math, ams, rel, "\u21c9", "\\rightrightarrows", true); +defineSymbol(math, ams, rel, "\u21c4", "\\rightleftarrows", true); +defineSymbol(math, ams, rel, "\u21a0", "\\twoheadrightarrow", true); +defineSymbol(math, ams, rel, "\u21a3", "\\rightarrowtail", true); +defineSymbol(math, ams, rel, "\u21ac", "\\looparrowright", true); +defineSymbol(math, ams, rel, "\u21b7", "\\curvearrowright", true); +// unicode-math maps \u21bb to \cwopencirclearrow. We'll use the AMS synonym. +defineSymbol(math, ams, rel, "\u21bb", "\\circlearrowright", true); +defineSymbol(math, ams, rel, "\u21b1", "\\Rsh", true); +defineSymbol(math, ams, rel, "\u21ca", "\\downdownarrows", true); +defineSymbol(math, ams, rel, "\u21be", "\\upharpoonright", true); +defineSymbol(math, ams, rel, "\u21c2", "\\downharpoonright", true); +defineSymbol(math, ams, rel, "\u21dd", "\\rightsquigarrow", true); +defineSymbol(math, ams, rel, "\u21dd", "\\leadsto"); +defineSymbol(math, ams, rel, "\u21db", "\\Rrightarrow", true); +defineSymbol(math, ams, rel, "\u21be", "\\restriction"); + +defineSymbol(math, main, textord, "\u2018", "`"); +defineSymbol(math, main, textord, "$", "\\$"); +defineSymbol(text, main, textord, "$", "\\$"); +defineSymbol(text, main, textord, "$", "\\textdollar"); +defineSymbol(math, main, textord, "%", "\\%"); +defineSymbol(text, main, textord, "%", "\\%"); +defineSymbol(math, main, textord, "_", "\\_"); +defineSymbol(text, main, textord, "_", "\\_"); +defineSymbol(text, main, textord, "_", "\\textunderscore"); +defineSymbol(math, main, textord, "\u2220", "\\angle", true); +defineSymbol(math, main, textord, "\u221e", "\\infty", true); +defineSymbol(math, main, textord, "\u2032", "\\prime"); +defineSymbol(math, main, textord, "\u25b3", "\\triangle"); +defineSymbol(math, main, textord, "\u0393", "\\Gamma", true); +defineSymbol(math, main, textord, "\u0394", "\\Delta", true); +defineSymbol(math, main, textord, "\u0398", "\\Theta", true); +defineSymbol(math, main, textord, "\u039b", "\\Lambda", true); +defineSymbol(math, main, textord, "\u039e", "\\Xi", true); +defineSymbol(math, main, textord, "\u03a0", "\\Pi", true); +defineSymbol(math, main, textord, "\u03a3", "\\Sigma", true); +defineSymbol(math, main, textord, "\u03a5", "\\Upsilon", true); +defineSymbol(math, main, textord, "\u03a6", "\\Phi", true); +defineSymbol(math, main, textord, "\u03a8", "\\Psi", true); +defineSymbol(math, main, textord, "\u03a9", "\\Omega", true); +defineSymbol(math, main, textord, "A", "\u0391"); +defineSymbol(math, main, textord, "B", "\u0392"); +defineSymbol(math, main, textord, "E", "\u0395"); +defineSymbol(math, main, textord, "Z", "\u0396"); +defineSymbol(math, main, textord, "H", "\u0397"); +defineSymbol(math, main, textord, "I", "\u0399"); +defineSymbol(math, main, textord, "K", "\u039A"); +defineSymbol(math, main, textord, "M", "\u039C"); +defineSymbol(math, main, textord, "N", "\u039D"); +defineSymbol(math, main, textord, "O", "\u039F"); +defineSymbol(math, main, textord, "P", "\u03A1"); +defineSymbol(math, main, textord, "T", "\u03A4"); +defineSymbol(math, main, textord, "X", "\u03A7"); +defineSymbol(math, main, textord, "\u00ac", "\\neg", true); +defineSymbol(math, main, textord, "\u00ac", "\\lnot"); +defineSymbol(math, main, textord, "\u22a4", "\\top"); +defineSymbol(math, main, textord, "\u22a5", "\\bot"); +defineSymbol(math, main, textord, "\u2205", "\\emptyset"); +defineSymbol(math, ams, textord, "\u2205", "\\varnothing"); +defineSymbol(math, main, mathord, "\u03b1", "\\alpha", true); +defineSymbol(math, main, mathord, "\u03b2", "\\beta", true); +defineSymbol(math, main, mathord, "\u03b3", "\\gamma", true); +defineSymbol(math, main, mathord, "\u03b4", "\\delta", true); +defineSymbol(math, main, mathord, "\u03f5", "\\epsilon", true); +defineSymbol(math, main, mathord, "\u03b6", "\\zeta", true); +defineSymbol(math, main, mathord, "\u03b7", "\\eta", true); +defineSymbol(math, main, mathord, "\u03b8", "\\theta", true); +defineSymbol(math, main, mathord, "\u03b9", "\\iota", true); +defineSymbol(math, main, mathord, "\u03ba", "\\kappa", true); +defineSymbol(math, main, mathord, "\u03bb", "\\lambda", true); +defineSymbol(math, main, mathord, "\u03bc", "\\mu", true); +defineSymbol(math, main, mathord, "\u03bd", "\\nu", true); +defineSymbol(math, main, mathord, "\u03be", "\\xi", true); +defineSymbol(math, main, mathord, "\u03bf", "\\omicron", true); +defineSymbol(math, main, mathord, "\u03c0", "\\pi", true); +defineSymbol(math, main, mathord, "\u03c1", "\\rho", true); +defineSymbol(math, main, mathord, "\u03c3", "\\sigma", true); +defineSymbol(math, main, mathord, "\u03c4", "\\tau", true); +defineSymbol(math, main, mathord, "\u03c5", "\\upsilon", true); +defineSymbol(math, main, mathord, "\u03d5", "\\phi", true); +defineSymbol(math, main, mathord, "\u03c7", "\\chi", true); +defineSymbol(math, main, mathord, "\u03c8", "\\psi", true); +defineSymbol(math, main, mathord, "\u03c9", "\\omega", true); +defineSymbol(math, main, mathord, "\u03b5", "\\varepsilon", true); +defineSymbol(math, main, mathord, "\u03d1", "\\vartheta", true); +defineSymbol(math, main, mathord, "\u03d6", "\\varpi", true); +defineSymbol(math, main, mathord, "\u03f1", "\\varrho", true); +defineSymbol(math, main, mathord, "\u03c2", "\\varsigma", true); +defineSymbol(math, main, mathord, "\u03c6", "\\varphi", true); +defineSymbol(math, main, bin, "\u2217", "*", true); +defineSymbol(math, main, bin, "+", "+"); +defineSymbol(math, main, bin, "\u2212", "-", true); +defineSymbol(math, main, bin, "\u22c5", "\\cdot", true); +defineSymbol(math, main, bin, "\u2218", "\\circ", true); +defineSymbol(math, main, bin, "\u00f7", "\\div", true); +defineSymbol(math, main, bin, "\u00b1", "\\pm", true); +defineSymbol(math, main, bin, "\u00d7", "\\times", true); +defineSymbol(math, main, bin, "\u2229", "\\cap", true); +defineSymbol(math, main, bin, "\u222a", "\\cup", true); +defineSymbol(math, main, bin, "\u2216", "\\setminus", true); +defineSymbol(math, main, bin, "\u2227", "\\land"); +defineSymbol(math, main, bin, "\u2228", "\\lor"); +defineSymbol(math, main, bin, "\u2227", "\\wedge", true); +defineSymbol(math, main, bin, "\u2228", "\\vee", true); +defineSymbol(math, main, textord, "\u221a", "\\surd"); +defineSymbol(math, main, open, "\u27e8", "\\langle", true); +defineSymbol(math, main, open, "\u2223", "\\lvert"); +defineSymbol(math, main, open, "\u2225", "\\lVert"); +defineSymbol(math, main, close, "?", "?"); +defineSymbol(math, main, close, "!", "!"); +defineSymbol(math, main, close, "\u27e9", "\\rangle", true); +defineSymbol(math, main, close, "\u2223", "\\rvert"); +defineSymbol(math, main, close, "\u2225", "\\rVert"); +defineSymbol(math, main, rel, "=", "="); +defineSymbol(math, main, rel, ":", ":"); +defineSymbol(math, main, rel, "\u2248", "\\approx", true); +defineSymbol(math, main, rel, "\u2245", "\\cong", true); +defineSymbol(math, main, rel, "\u2265", "\\ge"); +defineSymbol(math, main, rel, "\u2265", "\\geq", true); +defineSymbol(math, main, rel, "\u2190", "\\gets"); +defineSymbol(math, main, rel, ">", "\\gt", true); +defineSymbol(math, main, rel, "\u2208", "\\in", true); +defineSymbol(math, main, rel, "\ue020", "\\@not"); +defineSymbol(math, main, rel, "\u2282", "\\subset", true); +defineSymbol(math, main, rel, "\u2283", "\\supset", true); +defineSymbol(math, main, rel, "\u2286", "\\subseteq", true); +defineSymbol(math, main, rel, "\u2287", "\\supseteq", true); +defineSymbol(math, ams, rel, "\u2288", "\\nsubseteq", true); +defineSymbol(math, ams, rel, "\u2289", "\\nsupseteq", true); +defineSymbol(math, main, rel, "\u22a8", "\\models"); +defineSymbol(math, main, rel, "\u2190", "\\leftarrow", true); +defineSymbol(math, main, rel, "\u2264", "\\le"); +defineSymbol(math, main, rel, "\u2264", "\\leq", true); +defineSymbol(math, main, rel, "<", "\\lt", true); +defineSymbol(math, main, rel, "\u2192", "\\rightarrow", true); +defineSymbol(math, main, rel, "\u2192", "\\to"); +defineSymbol(math, ams, rel, "\u2271", "\\ngeq", true); +defineSymbol(math, ams, rel, "\u2270", "\\nleq", true); +defineSymbol(math, main, spacing, "\u00a0", "\\ "); +defineSymbol(math, main, spacing, "\u00a0", "\\space"); +// Ref: LaTeX Source 2e: \DeclareRobustCommand{\nobreakspace}{% +defineSymbol(math, main, spacing, "\u00a0", "\\nobreakspace"); +defineSymbol(text, main, spacing, "\u00a0", "\\ "); +defineSymbol(text, main, spacing, "\u00a0", " "); +defineSymbol(text, main, spacing, "\u00a0", "\\space"); +defineSymbol(text, main, spacing, "\u00a0", "\\nobreakspace"); +defineSymbol(math, main, spacing, "", "\\nobreak"); +defineSymbol(math, main, spacing, "", "\\allowbreak"); +defineSymbol(math, main, punct, ",", ","); +defineSymbol(math, main, punct, ";", ";"); +defineSymbol(math, ams, bin, "\u22bc", "\\barwedge", true); +defineSymbol(math, ams, bin, "\u22bb", "\\veebar", true); +defineSymbol(math, main, bin, "\u2299", "\\odot", true); +defineSymbol(math, main, bin, "\u2295", "\\oplus", true); +defineSymbol(math, main, bin, "\u2297", "\\otimes", true); +defineSymbol(math, main, textord, "\u2202", "\\partial", true); +defineSymbol(math, main, bin, "\u2298", "\\oslash", true); +defineSymbol(math, ams, bin, "\u229a", "\\circledcirc", true); +defineSymbol(math, ams, bin, "\u22a1", "\\boxdot", true); +defineSymbol(math, main, bin, "\u25b3", "\\bigtriangleup"); +defineSymbol(math, main, bin, "\u25bd", "\\bigtriangledown"); +defineSymbol(math, main, bin, "\u2020", "\\dagger"); +defineSymbol(math, main, bin, "\u22c4", "\\diamond"); +defineSymbol(math, main, bin, "\u22c6", "\\star"); +defineSymbol(math, main, bin, "\u25c3", "\\triangleleft"); +defineSymbol(math, main, bin, "\u25b9", "\\triangleright"); +defineSymbol(math, main, open, "{", "\\{"); +defineSymbol(text, main, textord, "{", "\\{"); +defineSymbol(text, main, textord, "{", "\\textbraceleft"); +defineSymbol(math, main, close, "}", "\\}"); +defineSymbol(text, main, textord, "}", "\\}"); +defineSymbol(text, main, textord, "}", "\\textbraceright"); +defineSymbol(math, main, open, "{", "\\lbrace"); +defineSymbol(math, main, close, "}", "\\rbrace"); +defineSymbol(math, main, open, "[", "\\lbrack", true); +defineSymbol(text, main, textord, "[", "\\lbrack", true); +defineSymbol(math, main, close, "]", "\\rbrack", true); +defineSymbol(text, main, textord, "]", "\\rbrack", true); +defineSymbol(math, main, open, "(", "\\lparen", true); +defineSymbol(math, main, close, ")", "\\rparen", true); +defineSymbol(text, main, textord, "<", "\\textless", true); // in T1 fontenc +defineSymbol(text, main, textord, ">", "\\textgreater", true); // in T1 fontenc +defineSymbol(math, main, open, "\u230a", "\\lfloor", true); +defineSymbol(math, main, close, "\u230b", "\\rfloor", true); +defineSymbol(math, main, open, "\u2308", "\\lceil", true); +defineSymbol(math, main, close, "\u2309", "\\rceil", true); +defineSymbol(math, main, textord, "\\", "\\backslash"); +defineSymbol(math, main, textord, "\u2223", "|"); +defineSymbol(math, main, textord, "\u2223", "\\vert"); +defineSymbol(text, main, textord, "|", "\\textbar", true); // in T1 fontenc +defineSymbol(math, main, textord, "\u2225", "\\|"); +defineSymbol(math, main, textord, "\u2225", "\\Vert"); +defineSymbol(text, main, textord, "\u2225", "\\textbardbl"); +defineSymbol(text, main, textord, "~", "\\textasciitilde"); +defineSymbol(text, main, textord, "\\", "\\textbackslash"); +defineSymbol(text, main, textord, "^", "\\textasciicircum"); +defineSymbol(math, main, rel, "\u2191", "\\uparrow", true); +defineSymbol(math, main, rel, "\u21d1", "\\Uparrow", true); +defineSymbol(math, main, rel, "\u2193", "\\downarrow", true); +defineSymbol(math, main, rel, "\u21d3", "\\Downarrow", true); +defineSymbol(math, main, rel, "\u2195", "\\updownarrow", true); +defineSymbol(math, main, rel, "\u21d5", "\\Updownarrow", true); +defineSymbol(math, main, op, "\u2210", "\\coprod"); +defineSymbol(math, main, op, "\u22c1", "\\bigvee"); +defineSymbol(math, main, op, "\u22c0", "\\bigwedge"); +defineSymbol(math, main, op, "\u2a04", "\\biguplus"); +defineSymbol(math, main, op, "\u22c2", "\\bigcap"); +defineSymbol(math, main, op, "\u22c3", "\\bigcup"); +defineSymbol(math, main, op, "\u222b", "\\int"); +defineSymbol(math, main, op, "\u222b", "\\intop"); +defineSymbol(math, main, op, "\u222c", "\\iint"); +defineSymbol(math, main, op, "\u222d", "\\iiint"); +defineSymbol(math, main, op, "\u220f", "\\prod"); +defineSymbol(math, main, op, "\u2211", "\\sum"); +defineSymbol(math, main, op, "\u2a02", "\\bigotimes"); +defineSymbol(math, main, op, "\u2a01", "\\bigoplus"); +defineSymbol(math, main, op, "\u2a00", "\\bigodot"); +defineSymbol(math, main, op, "\u222e", "\\oint"); +defineSymbol(math, main, op, "\u222f", "\\oiint"); +defineSymbol(math, main, op, "\u2230", "\\oiiint"); +defineSymbol(math, main, op, "\u2a06", "\\bigsqcup"); +defineSymbol(math, main, op, "\u222b", "\\smallint"); +defineSymbol(text, main, inner, "\u2026", "\\textellipsis"); +defineSymbol(math, main, inner, "\u2026", "\\mathellipsis"); +defineSymbol(text, main, inner, "\u2026", "\\ldots", true); +defineSymbol(math, main, inner, "\u2026", "\\ldots", true); +defineSymbol(math, main, inner, "\u22ef", "\\@cdots", true); +defineSymbol(math, main, inner, "\u22f1", "\\ddots", true); +// \vdots is a macro that uses one of these two symbols (with made-up names): +defineSymbol(math, main, textord, "\u22ee", "\\varvdots"); +defineSymbol(text, main, textord, "\u22ee", "\\varvdots"); +defineSymbol(math, main, accent, "\u02ca", "\\acute"); +defineSymbol(math, main, accent, "\u02cb", "\\grave"); +defineSymbol(math, main, accent, "\u00a8", "\\ddot"); +defineSymbol(math, main, accent, "\u007e", "\\tilde"); +defineSymbol(math, main, accent, "\u02c9", "\\bar"); +defineSymbol(math, main, accent, "\u02d8", "\\breve"); +defineSymbol(math, main, accent, "\u02c7", "\\check"); +defineSymbol(math, main, accent, "\u005e", "\\hat"); +defineSymbol(math, main, accent, "\u20d7", "\\vec"); +defineSymbol(math, main, accent, "\u02d9", "\\dot"); +defineSymbol(math, main, accent, "\u02da", "\\mathring"); +// \imath and \jmath should be invariant to \mathrm, \mathbf, etc., so use PUA +defineSymbol(math, main, mathord, "\ue131", "\\@imath"); +defineSymbol(math, main, mathord, "\ue237", "\\@jmath"); +defineSymbol(math, main, textord, "\u0131", "\u0131"); +defineSymbol(math, main, textord, "\u0237", "\u0237"); +defineSymbol(text, main, textord, "\u0131", "\\i", true); +defineSymbol(text, main, textord, "\u0237", "\\j", true); +defineSymbol(text, main, textord, "\u00df", "\\ss", true); +defineSymbol(text, main, textord, "\u00e6", "\\ae", true); +defineSymbol(text, main, textord, "\u0153", "\\oe", true); +defineSymbol(text, main, textord, "\u00f8", "\\o", true); +defineSymbol(text, main, textord, "\u00c6", "\\AE", true); +defineSymbol(text, main, textord, "\u0152", "\\OE", true); +defineSymbol(text, main, textord, "\u00d8", "\\O", true); +defineSymbol(text, main, accent, "\u02ca", "\\'"); // acute +defineSymbol(text, main, accent, "\u02cb", "\\`"); // grave +defineSymbol(text, main, accent, "\u02c6", "\\^"); // circumflex +defineSymbol(text, main, accent, "\u02dc", "\\~"); // tilde +defineSymbol(text, main, accent, "\u02c9", "\\="); // macron +defineSymbol(text, main, accent, "\u02d8", "\\u"); // breve +defineSymbol(text, main, accent, "\u02d9", "\\."); // dot above +defineSymbol(text, main, accent, "\u00b8", "\\c"); // cedilla +defineSymbol(text, main, accent, "\u02da", "\\r"); // ring above +defineSymbol(text, main, accent, "\u02c7", "\\v"); // caron +defineSymbol(text, main, accent, "\u00a8", '\\"'); // diaeresis +defineSymbol(text, main, accent, "\u02dd", "\\H"); // double acute +defineSymbol(text, main, accent, "\u25ef", "\\textcircled"); // \bigcirc glyph + +// These ligatures are detected and created in Parser.js's `formLigatures`. +export const ligatures = { + "--": true, + "---": true, + "``": true, + "''": true, +}; + +defineSymbol(text, main, textord, "\u2013", "--", true); +defineSymbol(text, main, textord, "\u2013", "\\textendash"); +defineSymbol(text, main, textord, "\u2014", "---", true); +defineSymbol(text, main, textord, "\u2014", "\\textemdash"); +defineSymbol(text, main, textord, "\u2018", "`", true); +defineSymbol(text, main, textord, "\u2018", "\\textquoteleft"); +defineSymbol(text, main, textord, "\u2019", "'", true); +defineSymbol(text, main, textord, "\u2019", "\\textquoteright"); +defineSymbol(text, main, textord, "\u201c", "``", true); +defineSymbol(text, main, textord, "\u201c", "\\textquotedblleft"); +defineSymbol(text, main, textord, "\u201d", "''", true); +defineSymbol(text, main, textord, "\u201d", "\\textquotedblright"); +// \degree from gensymb package +defineSymbol(math, main, textord, "\u00b0", "\\degree", true); +defineSymbol(text, main, textord, "\u00b0", "\\degree"); +// \textdegree from inputenc package +defineSymbol(text, main, textord, "\u00b0", "\\textdegree", true); +// TODO: In LaTeX, \pounds can generate a different character in text and math +// mode, but among our fonts, only Main-Regular defines this character "163". +defineSymbol(math, main, textord, "\u00a3", "\\pounds"); +defineSymbol(math, main, textord, "\u00a3", "\\mathsterling", true); +defineSymbol(text, main, textord, "\u00a3", "\\pounds"); +defineSymbol(text, main, textord, "\u00a3", "\\textsterling", true); +defineSymbol(math, ams, textord, "\u2720", "\\maltese"); +defineSymbol(text, ams, textord, "\u2720", "\\maltese"); + +// There are lots of symbols which are the same, so we add them in afterwards. +// All of these are textords in math mode +const mathTextSymbols = "0123456789/@.\""; +for (let i = 0; i < mathTextSymbols.length; i++) { + const ch = mathTextSymbols.charAt(i); + defineSymbol(math, main, textord, ch, ch); +} + +// All of these are textords in text mode +const textSymbols = "0123456789!@*()-=+\";:?/.,"; +for (let i = 0; i < textSymbols.length; i++) { + const ch = textSymbols.charAt(i); + defineSymbol(text, main, textord, ch, ch); +} + +// All of these are textords in text mode, and mathords in math mode +const letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; +for (let i = 0; i < letters.length; i++) { + const ch = letters.charAt(i); + defineSymbol(math, main, mathord, ch, ch); + defineSymbol(text, main, textord, ch, ch); +} + +// Blackboard bold and script letters in Unicode range +defineSymbol(math, ams, textord, "C", "\u2102"); // blackboard bold +defineSymbol(text, ams, textord, "C", "\u2102"); +defineSymbol(math, ams, textord, "H", "\u210D"); +defineSymbol(text, ams, textord, "H", "\u210D"); +defineSymbol(math, ams, textord, "N", "\u2115"); +defineSymbol(text, ams, textord, "N", "\u2115"); +defineSymbol(math, ams, textord, "P", "\u2119"); +defineSymbol(text, ams, textord, "P", "\u2119"); +defineSymbol(math, ams, textord, "Q", "\u211A"); +defineSymbol(text, ams, textord, "Q", "\u211A"); +defineSymbol(math, ams, textord, "R", "\u211D"); +defineSymbol(text, ams, textord, "R", "\u211D"); +defineSymbol(math, ams, textord, "Z", "\u2124"); +defineSymbol(text, ams, textord, "Z", "\u2124"); +defineSymbol(math, main, mathord, "h", "\u210E"); // italic h, Planck constant +defineSymbol(text, main, mathord, "h", "\u210E"); + +// The next loop loads wide (surrogate pair) characters. +// We support some letters in the Unicode range U+1D400 to U+1D7FF, +// Mathematical Alphanumeric Symbols. +// Some editors do not deal well with wide characters. So don't write the +// string into this file. Instead, create the string from the surrogate pair. +let wideChar; +for (let i = 0; i < letters.length; i++) { + const ch = letters.charAt(i); + + // The hex numbers in the next line are a surrogate pair. + // 0xD835 is the high surrogate for all letters in the range we support. + // 0xDC00 is the low surrogate for bold A. + wideChar = String.fromCharCode(0xD835, 0xDC00 + i); // A-Z a-z bold + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(text, main, textord, ch, wideChar); + + wideChar = String.fromCharCode(0xD835, 0xDC34 + i); // A-Z a-z italic + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(text, main, textord, ch, wideChar); + + wideChar = String.fromCharCode(0xD835, 0xDC68 + i); // A-Z a-z bold italic + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(text, main, textord, ch, wideChar); + + wideChar = String.fromCharCode(0xD835, 0xDD04 + i); // A-Z a-z Fraktur + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(text, main, textord, ch, wideChar); + + wideChar = String.fromCharCode(0xD835, 0xDD6C + i); // A-Z a-z bold Fraktur + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(text, main, textord, ch, wideChar); + + wideChar = String.fromCharCode(0xD835, 0xDDA0 + i); // A-Z a-z sans-serif + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(text, main, textord, ch, wideChar); + + wideChar = String.fromCharCode(0xD835, 0xDDD4 + i); // A-Z a-z sans bold + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(text, main, textord, ch, wideChar); + + wideChar = String.fromCharCode(0xD835, 0xDE08 + i); // A-Z a-z sans italic + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(text, main, textord, ch, wideChar); + + wideChar = String.fromCharCode(0xD835, 0xDE70 + i); // A-Z a-z monospace + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(text, main, textord, ch, wideChar); + + if (i < 26) { + // KaTeX fonts have only capital letters for blackboard bold and script. + // See exception for k below. + wideChar = String.fromCharCode(0xD835, 0xDD38 + i); // A-Z double struck + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(text, main, textord, ch, wideChar); + + wideChar = String.fromCharCode(0xD835, 0xDC9C + i); // A-Z script + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(text, main, textord, ch, wideChar); + } + + // TODO: Add bold script when it is supported by a KaTeX font. +} +// "k" is the only double struck lower case letter in the KaTeX fonts. +wideChar = String.fromCharCode(0xD835, 0xDD5C); // k double struck +defineSymbol(math, main, mathord, "k", wideChar); +defineSymbol(text, main, textord, "k", wideChar); + +// Next, some wide character numerals +for (let i = 0; i < 10; i++) { + const ch = i.toString(); + + wideChar = String.fromCharCode(0xD835, 0xDFCE + i); // 0-9 bold + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(text, main, textord, ch, wideChar); + + wideChar = String.fromCharCode(0xD835, 0xDFE2 + i); // 0-9 sans serif + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(text, main, textord, ch, wideChar); + + wideChar = String.fromCharCode(0xD835, 0xDFEC + i); // 0-9 bold sans + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(text, main, textord, ch, wideChar); + + wideChar = String.fromCharCode(0xD835, 0xDFF6 + i); // 0-9 monospace + defineSymbol(math, main, mathord, ch, wideChar); + defineSymbol(text, main, textord, ch, wideChar); +} + +// We add these Latin-1 letters as symbols for backwards-compatibility, +// but they are not actually in the font, nor are they supported by the +// Unicode accent mechanism, so they fall back to Times font and look ugly. +// TODO(edemaine): Fix this. +export const extraLatin = "\u00d0\u00de\u00fe"; +for (let i = 0; i < extraLatin.length; i++) { + const ch = extraLatin.charAt(i); + defineSymbol(math, main, mathord, ch, ch); + defineSymbol(text, main, textord, ch, ch); +} diff --git a/node_modules/react-katex/node_modules/katex/src/tree.ts b/node_modules/react-katex/node_modules/katex/src/tree.ts new file mode 100644 index 0000000..8e5dbee --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/tree.ts @@ -0,0 +1,79 @@ +import type {CssStyle, HtmlDomNode} from "./domTree"; +import type {MathDomNode} from "./mathMLTree"; + + +// To ensure that all nodes have compatible signatures for these methods. +export interface VirtualNode { + toNode(): Node; + toMarkup(): string; +} + +function isMathDomNode(node: VirtualNode): node is MathDomNode { + return 'toText' in node; +} + + +/** + * This node represents a document fragment, which contains elements, but when + * placed into the DOM doesn't have any representation itself. It only contains + * children and doesn't have any DOM node properties. + */ +export class DocumentFragment + implements HtmlDomNode, MathDomNode { + children: ReadonlyArray; + classes: string[]; + height: number; + depth: number; + maxFontSize: number; + style: CssStyle; // Never used; needed for satisfying interface. + + constructor(children: ReadonlyArray) { + this.children = children; + this.classes = []; + this.height = 0; + this.depth = 0; + this.maxFontSize = 0; + this.style = {}; + } + + hasClass(className: string): boolean { + return this.classes.includes(className); + } + + /** Convert the fragment into a node. */ + toNode(): Node { + const frag = document.createDocumentFragment(); + + for (let i = 0; i < this.children.length; i++) { + frag.appendChild(this.children[i].toNode()); + } + + return frag; + } + + /** Convert the fragment into HTML markup. */ + toMarkup(): string { + let markup = ""; + + // Simply concatenate the markup for the children together. + for (let i = 0; i < this.children.length; i++) { + markup += this.children[i].toMarkup(); + } + + return markup; + } + + /** + * Converts the math node into a string, similar to innerText. Applies to + * MathDomNode's only. + */ + toText(): string { + return this.children.map((child: ChildType): string => { + if (isMathDomNode(child)) { + return child.toText(); + } + throw new Error( + `Expected MathDomNode with toText, got ${child.constructor.name}`); + }).join(""); + } +} diff --git a/node_modules/react-katex/node_modules/katex/src/types/fonts.ts b/node_modules/react-katex/node_modules/katex/src/types/fonts.ts new file mode 100644 index 0000000..e4c0872 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/types/fonts.ts @@ -0,0 +1,73 @@ +// Math font variants. +export type FontVariant = + | "bold" + | "bold-italic" + | "bold-sans-serif" + | "double-struck" + | "fraktur" + | "italic" + | "monospace" + | "normal" + | "sans-serif" + | "sans-serif-bold-italic" + | "sans-serif-italic" + | "script"; + +export type FontName = + | "AMS-Regular" + | "Caligraphic-Regular" + | "Fraktur-Regular" + | "Main-Bold" + | "Main-BoldItalic" + | "Main-Italic" + | "Main-Regular" + | "Math-BoldItalic" + | "Math-Italic" + | "SansSerif-Regular" + | "SansSerif-Bold" + | "SansSerif-Italic" + | "Script-Regular" + | "Size1-Regular" + | "Size2-Regular" + | "Size3-Regular" + | "Size4-Regular" + | "Typewriter-Regular"; + +//[depth, height, italic, skew, width] +export type CharacterMetricsTuple = [depth: number, height: number, italic: number, skew: number, width: number]; + +export type CharacterMetrics = { + depth: number; + height: number; + italic: number; + skew: number; + width: number; +}; + +export type FontMetrics = { + cssEmPerMu: number; + [key: string]: number; +}; + +export type SymbolFont = "main" | "ams"; + +export type MathFont = + | "" + | "mathrm" + | "mathit" + | "mathbf" + | "mathnormal" + | "mathsfit" + | "mathbb" + | "mathcal" + | "mathfrak" + | "mathscr" + | "mathsf" + | "mathtt" + | "boldsymbol"; + +export type TextFont = "textrm" | "textsf" | "texttt" | "amsrm" | ""; + +// In these types, "" (empty string) means "no change". +export type FontWeight = "textbf" | "textmd" | ""; +export type FontShape = "textit" | "textup" | ""; diff --git a/node_modules/react-katex/node_modules/katex/src/types/index.ts b/node_modules/react-katex/node_modules/katex/src/types/index.ts new file mode 100644 index 0000000..78ae3fd --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/types/index.ts @@ -0,0 +1,29 @@ +export type Mode = "math" | "text"; + +// LaTeX argument type. +// - "size": A size-like thing, such as "1em" or "5ex" +// - "color": An html color, like "#abc" or "blue" +// - "url": An url string, in which "\" will be ignored +// - if it precedes [#$%&~_^\{}] +// - "raw": A string, allowing single character, percent sign, +// and nested braces +// - "original": The same type as the environment that the +// function being parsed is in (e.g. used for the +// bodies of functions like \textcolor where the +// first argument is special and the second +// argument is parsed normally) +// - Mode: Node group parsed in given mode. +export type ArgType = "color" | "size" | "url" | "raw" | "original" | "hbox" | + "primitive" | Mode; + +// LaTeX display style. +export type StyleStr = "text" | "display" | "script" | "scriptscript"; + +// Allowable token text for "break" arguments in parser. +export type BreakToken = "]" | "}" | "\\endgroup" | "$" | "\\)" | "\\\\" | "\\end" | + "EOF"; + +export type DelimiterSize = 1 | 2 | 3 | 4; + +export type Slice1 = + S extends `${string}${infer Rest}` ? Rest : ""; diff --git a/node_modules/react-katex/node_modules/katex/src/unicodeAccents.js b/node_modules/react-katex/node_modules/katex/src/unicodeAccents.js new file mode 100644 index 0000000..3acd07e --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/unicodeAccents.js @@ -0,0 +1,21 @@ +// Mapping of Unicode accent characters to their LaTeX equivalent in text and +// math mode (when they exist). +// This exports a CommonJS module, allowing to be required in unicodeSymbols +// without transpiling. +/** @type {Record} */ +const unicodeAccents = { + '\u0301': {text: "\\'", math: '\\acute'}, + '\u0300': {text: '\\`', math: '\\grave'}, + '\u0308': {text: '\\"', math: '\\ddot'}, + '\u0303': {text: '\\~', math: '\\tilde'}, + '\u0304': {text: '\\=', math: '\\bar'}, + '\u0306': {text: '\\u', math: '\\breve'}, + '\u030c': {text: '\\v', math: '\\check'}, + '\u0302': {text: '\\^', math: '\\hat'}, + '\u0307': {text: '\\.', math: '\\dot'}, + '\u030a': {text: '\\r', math: '\\mathring'}, + '\u030b': {text: '\\H'}, + '\u0327': {text: '\\c'}, +}; + +module.exports = unicodeAccents; diff --git a/node_modules/react-katex/node_modules/katex/src/unicodeScripts.ts b/node_modules/react-katex/node_modules/katex/src/unicodeScripts.ts new file mode 100644 index 0000000..316f4d0 --- /dev/null +++ b/node_modules/react-katex/node_modules/katex/src/unicodeScripts.ts @@ -0,0 +1,124 @@ +/* + * This file defines the Unicode scripts and script families that we + * support. To add new scripts or families, just add a new entry to the + * scriptData array below. Adding scripts to the scriptData array allows + * characters from that script to appear in \text{} environments. + */ + +/** + * Each script or script family has a name and an array of blocks. + * Each block is an array of two numbers which specify the start and + * end points (inclusive) of a block of Unicode codepoints. + */ +type Script = { + name: string; + blocks: Array>; +}; + +/** + * Unicode block data for the families of scripts we support in \text{}. + * Scripts only need to appear here if they do not have font metrics. + */ +const scriptData: Array