stuff
This commit is contained in:
parent
bc92231240
commit
b8225c639e
11904 changed files with 1472749 additions and 133 deletions
86
node_modules/mathjax-full/ts/input/tex/ams/AmsConfiguration.ts
generated
vendored
Normal file
86
node_modules/mathjax-full/ts/input/tex/ams/AmsConfiguration.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
/*************************************************************
|
||||
*
|
||||
* Copyright (c) 2018-2022 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.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @fileoverview Configuration file for the AMS package.
|
||||
*
|
||||
* @author v.sorge@mathjax.org (Volker Sorge)
|
||||
*/
|
||||
|
||||
import {Configuration, ParserConfiguration} from '../Configuration.js';
|
||||
import {MultlineItem, FlalignItem} from './AmsItems.js';
|
||||
import {AbstractTags} from '../Tags.js';
|
||||
import {NEW_OPS} from './AmsMethods.js';
|
||||
import './AmsMappings.js';
|
||||
import {CommandMap} from '../SymbolMap.js';
|
||||
|
||||
|
||||
/**
|
||||
* Standard AMS style tagging.
|
||||
* @constructor
|
||||
* @extends {AbstractTags}
|
||||
*/
|
||||
export class AmsTags extends AbstractTags { }
|
||||
|
||||
|
||||
/**
|
||||
* Init method for AMS package.
|
||||
* @param {ParserConfiguration} config The current configuration.
|
||||
*/
|
||||
let init = function(config: ParserConfiguration) {
|
||||
new CommandMap(NEW_OPS, {}, {});
|
||||
config.append(Configuration.local({handler: {macro: [NEW_OPS]},
|
||||
priority: -1}));
|
||||
};
|
||||
|
||||
export const AmsConfiguration = Configuration.create(
|
||||
'ams', {
|
||||
handler: {
|
||||
character: ['AMSmath-operatorLetter'],
|
||||
delimiter: ['AMSsymbols-delimiter', 'AMSmath-delimiter'],
|
||||
macro: ['AMSsymbols-mathchar0mi', 'AMSsymbols-mathchar0mo',
|
||||
'AMSsymbols-delimiter', 'AMSsymbols-macros',
|
||||
'AMSmath-mathchar0mo', 'AMSmath-macros', 'AMSmath-delimiter'],
|
||||
environment: ['AMSmath-environment']
|
||||
},
|
||||
items: {
|
||||
[MultlineItem.prototype.kind]: MultlineItem,
|
||||
[FlalignItem.prototype.kind]: FlalignItem,
|
||||
},
|
||||
tags: {'ams': AmsTags},
|
||||
init: init,
|
||||
config: (_config: ParserConfiguration, jax: any) => {
|
||||
//
|
||||
// Move multlineWidth from old location to ams block (remove in next version)
|
||||
//
|
||||
if (jax.parseOptions.options.multlineWidth) {
|
||||
jax.parseOptions.options.ams.multlineWidth = jax.parseOptions.options.multlineWidth;
|
||||
}
|
||||
delete jax.parseOptions.options.multlineWidth;
|
||||
},
|
||||
options: {
|
||||
multlineWidth: '',
|
||||
ams: {
|
||||
multlineWidth: '100%', // The width to use for multline environments.
|
||||
multlineIndent: '1em', // The margin to use on both sides of multline environments.
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
224
node_modules/mathjax-full/ts/input/tex/ams/AmsItems.ts
generated
vendored
Normal file
224
node_modules/mathjax-full/ts/input/tex/ams/AmsItems.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,224 @@
|
|||
/*************************************************************
|
||||
*
|
||||
* Copyright (c) 2009-2022 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.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @fileoverview StackItems needed for parsing AMS math commands.
|
||||
*
|
||||
* @author v.sorge@mathjax.org (Volker Sorge)
|
||||
*/
|
||||
|
||||
|
||||
import {ArrayItem, EqnArrayItem} from '../base/BaseItems.js';
|
||||
import ParseUtil from '../ParseUtil.js';
|
||||
import NodeUtil from '../NodeUtil.js';
|
||||
import TexError from '../TexError.js';
|
||||
import {TexConstant} from '../TexConstants.js';
|
||||
import {MmlNode} from '../../../core/MmlTree/MmlNode.js';
|
||||
|
||||
|
||||
/**
|
||||
* Item dealing with multiline environments as a special case of arrays. Note,
|
||||
* that all other AMS equation environments (e.g., align, split) can be handled
|
||||
* by the regular EqnArrayItem class.
|
||||
*
|
||||
* Handles tagging information according to the given tagging style.
|
||||
*/
|
||||
export class MultlineItem extends ArrayItem {
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
constructor(factory: any, ...args: any[]) {
|
||||
super(factory);
|
||||
this.factory.configuration.tags.start('multline', true, args[0]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
get kind() {
|
||||
return 'multline';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
public EndEntry() {
|
||||
if (this.table.length) {
|
||||
ParseUtil.fixInitialMO(this.factory.configuration, this.nodes);
|
||||
}
|
||||
const shove = this.getProperty('shove');
|
||||
const mtd = this.create('node',
|
||||
'mtd', this.nodes, shove ? {columnalign: shove} : {});
|
||||
this.setProperty('shove', null);
|
||||
this.row.push(mtd);
|
||||
this.Clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
public EndRow() {
|
||||
if (this.row.length !== 1) {
|
||||
// @test MultlineRowsOneCol
|
||||
throw new TexError(
|
||||
'MultlineRowsOneCol',
|
||||
'The rows within the %1 environment must have exactly one column',
|
||||
'multline');
|
||||
}
|
||||
let row = this.create('node', 'mtr', this.row);
|
||||
this.table.push(row);
|
||||
this.row = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
public EndTable() {
|
||||
super.EndTable();
|
||||
if (this.table.length) {
|
||||
let m = this.table.length - 1, label = -1;
|
||||
if (!NodeUtil.getAttribute(
|
||||
NodeUtil.getChildren(this.table[0])[0], 'columnalign')) {
|
||||
NodeUtil.setAttribute(NodeUtil.getChildren(this.table[0])[0],
|
||||
'columnalign', TexConstant.Align.LEFT);
|
||||
}
|
||||
if (!NodeUtil.getAttribute(
|
||||
NodeUtil.getChildren(this.table[m])[0], 'columnalign')) {
|
||||
NodeUtil.setAttribute(NodeUtil.getChildren(this.table[m])[0],
|
||||
'columnalign', TexConstant.Align.RIGHT);
|
||||
}
|
||||
let tag = this.factory.configuration.tags.getTag();
|
||||
if (tag) {
|
||||
label = (this.arraydef.side === TexConstant.Align.LEFT ? 0 : this.table.length - 1);
|
||||
const mtr = this.table[label];
|
||||
const mlabel = this.create('node', 'mlabeledtr',
|
||||
[tag].concat(NodeUtil.getChildren(mtr)));
|
||||
NodeUtil.copyAttributes(mtr, mlabel);
|
||||
this.table[label] = mlabel;
|
||||
}
|
||||
}
|
||||
this.factory.configuration.tags.end();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* StackItem for handling flalign, xalignat, and xxalignat environments.
|
||||
*/
|
||||
export class FlalignItem extends EqnArrayItem {
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
get kind() {
|
||||
return 'flalign';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
constructor(factory: any, public name: string, public numbered: boolean,
|
||||
public padded: boolean, public center: boolean) {
|
||||
super(factory);
|
||||
this.factory.configuration.tags.start(name, numbered, numbered);
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
public EndEntry() {
|
||||
super.EndEntry();
|
||||
const n = this.getProperty('xalignat') as number;
|
||||
if (!n) return;
|
||||
if (this.row.length > n) {
|
||||
throw new TexError('XalignOverflow', 'Extra %1 in row of %2', '&', this.name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
public EndRow() {
|
||||
let cell: MmlNode;
|
||||
let row = this.row;
|
||||
//
|
||||
// For xalignat and xxalignat, pad the row to the expected number if it is too short.
|
||||
//
|
||||
const n = this.getProperty('xalignat') as number;
|
||||
while (row.length < n) {
|
||||
row.push(this.create('node', 'mtd'));
|
||||
}
|
||||
//
|
||||
// Insert padding cells between pairs of entries, as needed for "fit" columns,
|
||||
// and include initial and end cells if that is needed.
|
||||
//
|
||||
this.row = [];
|
||||
if (this.padded) {
|
||||
this.row.push(this.create('node', 'mtd'));
|
||||
}
|
||||
while ((cell = row.shift())) {
|
||||
this.row.push(cell);
|
||||
cell = row.shift();
|
||||
if (cell) this.row.push(cell);
|
||||
if (row.length || this.padded) {
|
||||
this.row.push(this.create('node', 'mtd'));
|
||||
}
|
||||
}
|
||||
//
|
||||
if (this.row.length > this.maxrow) {
|
||||
this.maxrow = this.row.length;
|
||||
}
|
||||
super.EndRow();
|
||||
//
|
||||
// For full-width environments with labels that aren't supposed to take up space,
|
||||
// move the label into a zero-width mpadded element that laps in the proper direction.
|
||||
//
|
||||
const mtr = this.table[this.table.length - 1];
|
||||
if (this.getProperty('zeroWidthLabel') && mtr.isKind('mlabeledtr')) {
|
||||
const mtd = NodeUtil.getChildren(mtr)[0];
|
||||
const side = this.factory.configuration.options['tagSide'];
|
||||
const def = {width: 0, ...(side === 'right' ? {lspace: '-1width'} : {})};
|
||||
const mpadded = this.create('node', 'mpadded', NodeUtil.getChildren(mtd), def);
|
||||
mtd.setChildren([mpadded]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
public EndTable() {
|
||||
super.EndTable();
|
||||
if (this.center) {
|
||||
//
|
||||
// If there is only one equation (one pair):
|
||||
// Don't make it 100%, and don't change the indentalign.
|
||||
//
|
||||
if (this.maxrow <= 2) {
|
||||
const def = this.arraydef;
|
||||
delete def.width;
|
||||
delete this.global.indentalign;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
443
node_modules/mathjax-full/ts/input/tex/ams/AmsMappings.ts
generated
vendored
Normal file
443
node_modules/mathjax-full/ts/input/tex/ams/AmsMappings.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,443 @@
|
|||
|
||||
/*************************************************************
|
||||
*
|
||||
* Copyright (c) 2017-2022 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.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @fileoverview Mappings for TeX parsing of the AMS math package.
|
||||
*
|
||||
* @author v.sorge@mathjax.org (Volker Sorge)
|
||||
*/
|
||||
|
||||
import {AmsMethods} from './AmsMethods.js';
|
||||
import * as sm from '../SymbolMap.js';
|
||||
import {TexConstant} from '../TexConstants.js';
|
||||
import ParseMethods from '../ParseMethods.js';
|
||||
import ParseUtil from '../ParseUtil.js';
|
||||
import {TEXCLASS} from '../../../core/MmlTree/MmlNode.js';
|
||||
import {MATHSPACE} from '../../../util/lengths.js';
|
||||
|
||||
|
||||
/**
|
||||
* Operators from the AMS Math package.
|
||||
*/
|
||||
new sm.CharacterMap('AMSmath-mathchar0mo', ParseMethods.mathchar0mo, {
|
||||
iiiint: ['\u2A0C', {texClass: TEXCLASS.OP}]
|
||||
});
|
||||
|
||||
/**
|
||||
* Extra characters that are letters in \operatorname
|
||||
*/
|
||||
new sm.RegExpMap('AMSmath-operatorLetter', AmsMethods.operatorLetter, /[-*]/i);
|
||||
|
||||
/**
|
||||
* Macros from the AMS Math package.
|
||||
*/
|
||||
new sm.CommandMap('AMSmath-macros', {
|
||||
mathring: ['Accent', '02DA'], // or 0x30A
|
||||
nobreakspace: 'Tilde',
|
||||
negmedspace: ['Spacer', MATHSPACE.negativemediummathspace],
|
||||
negthickspace: ['Spacer', MATHSPACE.negativethickmathspace],
|
||||
|
||||
idotsint: ['MultiIntegral', '\\int\\cdots\\int'],
|
||||
|
||||
dddot: ['Accent', '20DB'],
|
||||
ddddot: ['Accent', '20DC'],
|
||||
|
||||
sideset: 'SideSet',
|
||||
|
||||
boxed: ['Macro', '\\fbox{$\\displaystyle{#1}$}', 1],
|
||||
|
||||
tag: 'HandleTag',
|
||||
notag: 'HandleNoTag',
|
||||
eqref: ['HandleRef', true],
|
||||
|
||||
substack: ['Macro', '\\begin{subarray}{c}#1\\end{subarray}', 1],
|
||||
|
||||
injlim: ['NamedOp', 'inj lim'],
|
||||
projlim: ['NamedOp', 'proj lim'],
|
||||
varliminf: ['Macro', '\\mathop{\\underline{\\mmlToken{mi}{lim}}}'],
|
||||
varlimsup: ['Macro', '\\mathop{\\overline{\\mmlToken{mi}{lim}}}'],
|
||||
varinjlim: ['Macro', '\\mathop{\\underrightarrow{\\mmlToken{mi}{lim}}}'],
|
||||
varprojlim: ['Macro', '\\mathop{\\underleftarrow{\\mmlToken{mi}{lim}}}'],
|
||||
|
||||
DeclareMathOperator: 'HandleDeclareOp',
|
||||
operatorname: 'HandleOperatorName',
|
||||
|
||||
genfrac: 'Genfrac',
|
||||
frac: ['Genfrac', '', '', '', ''],
|
||||
tfrac: ['Genfrac', '', '', '', '1'],
|
||||
dfrac: ['Genfrac', '', '', '', '0'],
|
||||
binom: ['Genfrac', '(', ')', '0', ''],
|
||||
tbinom: ['Genfrac', '(', ')', '0', '1'],
|
||||
dbinom: ['Genfrac', '(', ')', '0', '0'],
|
||||
|
||||
cfrac: 'CFrac',
|
||||
|
||||
shoveleft: ['HandleShove', TexConstant.Align.LEFT],
|
||||
shoveright: ['HandleShove', TexConstant.Align.RIGHT],
|
||||
|
||||
xrightarrow: ['xArrow', 0x2192, 5, 10],
|
||||
xleftarrow: ['xArrow', 0x2190, 10, 5]
|
||||
}, AmsMethods);
|
||||
|
||||
|
||||
/**
|
||||
* Environments from the AMS Math package.
|
||||
*/
|
||||
new sm.EnvironmentMap('AMSmath-environment', ParseMethods.environment, {
|
||||
'equation*': ['Equation', null, false],
|
||||
'eqnarray*': ['EqnArray', null, false, true, 'rcl',
|
||||
ParseUtil.cols(0, MATHSPACE.thickmathspace), '.5em'],
|
||||
align: ['EqnArray', null, true, true, 'rl', ParseUtil.cols(0, 2)],
|
||||
'align*': ['EqnArray', null, false, true, 'rl', ParseUtil.cols(0, 2)],
|
||||
multline: ['Multline', null, true],
|
||||
'multline*': ['Multline', null, false],
|
||||
split: ['EqnArray', null, false, false, 'rl', ParseUtil.cols(0)],
|
||||
gather: ['EqnArray', null, true, true, 'c'],
|
||||
'gather*': ['EqnArray', null, false, true, 'c'],
|
||||
|
||||
alignat: ['AlignAt', null, true, true],
|
||||
'alignat*': ['AlignAt', null, false, true],
|
||||
alignedat: ['AlignAt', null, false, false],
|
||||
|
||||
aligned: ['AmsEqnArray', null, null, null, 'rl', ParseUtil.cols(0, 2), '.5em', 'D'],
|
||||
gathered: ['AmsEqnArray', null, null, null, 'c', null, '.5em', 'D'],
|
||||
|
||||
xalignat: ['XalignAt', null, true, true],
|
||||
'xalignat*': ['XalignAt', null, false, true],
|
||||
xxalignat: ['XalignAt', null, false, false],
|
||||
flalign: ['FlalignArray', null, true, false, true, 'rlc', 'auto auto fit'],
|
||||
'flalign*': ['FlalignArray', null, false, false, true, 'rlc', 'auto auto fit'],
|
||||
|
||||
subarray: ['Array', null, null, null, null, ParseUtil.cols(0), '0.1em', 'S', 1],
|
||||
smallmatrix: ['Array', null, null, null, 'c', ParseUtil.cols(1 / 3),
|
||||
'.2em', 'S', 1],
|
||||
matrix: ['Array', null, null, null, 'c'],
|
||||
pmatrix: ['Array', null, '(', ')', 'c'],
|
||||
bmatrix: ['Array', null, '[', ']', 'c'],
|
||||
Bmatrix: ['Array', null, '\\{', '\\}', 'c'],
|
||||
vmatrix: ['Array', null, '\\vert', '\\vert', 'c'],
|
||||
Vmatrix: ['Array', null, '\\Vert', '\\Vert', 'c'],
|
||||
cases: ['Array', null, '\\{', '.', 'll', null, '.2em', 'T']
|
||||
}, AmsMethods);
|
||||
|
||||
|
||||
/**
|
||||
* Delimiters from the AMS Math package.
|
||||
*/
|
||||
new sm.DelimiterMap('AMSmath-delimiter', ParseMethods.delimiter, {
|
||||
'\\lvert': ['\u007C', {texClass: TEXCLASS.OPEN}],
|
||||
'\\rvert': ['\u007C', {texClass: TEXCLASS.CLOSE}],
|
||||
'\\lVert': ['\u2016', {texClass: TEXCLASS.OPEN}],
|
||||
'\\rVert': ['\u2016', {texClass: TEXCLASS.CLOSE}]
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Identifiers from the AMS Symbols package.
|
||||
*/
|
||||
new sm.CharacterMap('AMSsymbols-mathchar0mi', ParseMethods.mathchar0mi, {
|
||||
// Lowercase Greek letters
|
||||
digamma: '\u03DD',
|
||||
varkappa: '\u03F0',
|
||||
|
||||
// Uppercase Greek letters
|
||||
varGamma: ['\u0393', {mathvariant: TexConstant.Variant.ITALIC}],
|
||||
varDelta: ['\u0394', {mathvariant: TexConstant.Variant.ITALIC}],
|
||||
varTheta: ['\u0398', {mathvariant: TexConstant.Variant.ITALIC}],
|
||||
varLambda: ['\u039B', {mathvariant: TexConstant.Variant.ITALIC}],
|
||||
varXi: ['\u039E', {mathvariant: TexConstant.Variant.ITALIC}],
|
||||
varPi: ['\u03A0', {mathvariant: TexConstant.Variant.ITALIC}],
|
||||
varSigma: ['\u03A3', {mathvariant: TexConstant.Variant.ITALIC}],
|
||||
varUpsilon: ['\u03A5', {mathvariant: TexConstant.Variant.ITALIC}],
|
||||
varPhi: ['\u03A6', {mathvariant: TexConstant.Variant.ITALIC}],
|
||||
varPsi: ['\u03A8', {mathvariant: TexConstant.Variant.ITALIC}],
|
||||
varOmega: ['\u03A9', {mathvariant: TexConstant.Variant.ITALIC}],
|
||||
|
||||
// Hebrew letters
|
||||
beth: '\u2136',
|
||||
gimel: '\u2137',
|
||||
daleth: '\u2138',
|
||||
|
||||
// Miscellaneous symbols
|
||||
// hbar: '\u0127', // in TeX/jax.js
|
||||
backprime: ['\u2035', {variantForm: true}],
|
||||
hslash: '\u210F',
|
||||
varnothing: ['\u2205', {variantForm: true}],
|
||||
blacktriangle: '\u25B4',
|
||||
triangledown: ['\u25BD', {variantForm: true}],
|
||||
blacktriangledown: '\u25BE',
|
||||
square: '\u25FB',
|
||||
Box: '\u25FB',
|
||||
blacksquare: '\u25FC',
|
||||
lozenge: '\u25CA',
|
||||
Diamond: '\u25CA',
|
||||
blacklozenge: '\u29EB',
|
||||
circledS: ['\u24C8', {mathvariant: TexConstant.Variant.NORMAL}],
|
||||
bigstar: '\u2605',
|
||||
// angle: '\u2220', // in TeX/jax.js
|
||||
sphericalangle: '\u2222',
|
||||
measuredangle: '\u2221',
|
||||
nexists: '\u2204',
|
||||
complement: '\u2201',
|
||||
mho: '\u2127',
|
||||
eth: ['\u00F0', {mathvariant: TexConstant.Variant.NORMAL}],
|
||||
Finv: '\u2132',
|
||||
diagup: '\u2571',
|
||||
Game: '\u2141',
|
||||
diagdown: '\u2572',
|
||||
Bbbk: ['\u006B',
|
||||
{mathvariant: TexConstant.Variant.DOUBLESTRUCK}],
|
||||
|
||||
yen: '\u00A5',
|
||||
circledR: '\u00AE',
|
||||
checkmark: '\u2713',
|
||||
maltese: '\u2720'
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Operators from the AMS Symbols package.
|
||||
*/
|
||||
new sm.CharacterMap('AMSsymbols-mathchar0mo', ParseMethods.mathchar0mo, {
|
||||
// Binary operators
|
||||
dotplus: '\u2214',
|
||||
ltimes: '\u22C9',
|
||||
smallsetminus: ['\u2216', {variantForm: true}],
|
||||
rtimes: '\u22CA',
|
||||
Cap: '\u22D2',
|
||||
doublecap: '\u22D2',
|
||||
leftthreetimes: '\u22CB',
|
||||
Cup: '\u22D3',
|
||||
doublecup: '\u22D3',
|
||||
rightthreetimes: '\u22CC',
|
||||
barwedge: '\u22BC',
|
||||
curlywedge: '\u22CF',
|
||||
veebar: '\u22BB',
|
||||
curlyvee: '\u22CE',
|
||||
doublebarwedge: '\u2A5E',
|
||||
boxminus: '\u229F',
|
||||
circleddash: '\u229D',
|
||||
boxtimes: '\u22A0',
|
||||
circledast: '\u229B',
|
||||
boxdot: '\u22A1',
|
||||
circledcirc: '\u229A',
|
||||
boxplus: '\u229E',
|
||||
centerdot: ['\u22C5', {variantForm: true}],
|
||||
divideontimes: '\u22C7',
|
||||
intercal: '\u22BA',
|
||||
|
||||
// Binary relations
|
||||
leqq: '\u2266',
|
||||
geqq: '\u2267',
|
||||
leqslant: '\u2A7D',
|
||||
geqslant: '\u2A7E',
|
||||
eqslantless: '\u2A95',
|
||||
eqslantgtr: '\u2A96',
|
||||
lesssim: '\u2272',
|
||||
gtrsim: '\u2273',
|
||||
lessapprox: '\u2A85',
|
||||
gtrapprox: '\u2A86',
|
||||
approxeq: '\u224A',
|
||||
lessdot: '\u22D6',
|
||||
gtrdot: '\u22D7',
|
||||
lll: '\u22D8',
|
||||
llless: '\u22D8',
|
||||
ggg: '\u22D9',
|
||||
gggtr: '\u22D9',
|
||||
lessgtr: '\u2276',
|
||||
gtrless: '\u2277',
|
||||
lesseqgtr: '\u22DA',
|
||||
gtreqless: '\u22DB',
|
||||
lesseqqgtr: '\u2A8B',
|
||||
gtreqqless: '\u2A8C',
|
||||
doteqdot: '\u2251',
|
||||
Doteq: '\u2251',
|
||||
eqcirc: '\u2256',
|
||||
risingdotseq: '\u2253',
|
||||
circeq: '\u2257',
|
||||
fallingdotseq: '\u2252',
|
||||
triangleq: '\u225C',
|
||||
backsim: '\u223D',
|
||||
thicksim: ['\u223C', {variantForm: true}],
|
||||
backsimeq: '\u22CD',
|
||||
thickapprox: ['\u2248', {variantForm: true}],
|
||||
subseteqq: '\u2AC5',
|
||||
supseteqq: '\u2AC6',
|
||||
Subset: '\u22D0',
|
||||
Supset: '\u22D1',
|
||||
sqsubset: '\u228F',
|
||||
sqsupset: '\u2290',
|
||||
preccurlyeq: '\u227C',
|
||||
succcurlyeq: '\u227D',
|
||||
curlyeqprec: '\u22DE',
|
||||
curlyeqsucc: '\u22DF',
|
||||
precsim: '\u227E',
|
||||
succsim: '\u227F',
|
||||
precapprox: '\u2AB7',
|
||||
succapprox: '\u2AB8',
|
||||
vartriangleleft: '\u22B2',
|
||||
lhd: '\u22B2',
|
||||
vartriangleright: '\u22B3',
|
||||
rhd: '\u22B3',
|
||||
trianglelefteq: '\u22B4',
|
||||
unlhd: '\u22B4',
|
||||
trianglerighteq: '\u22B5',
|
||||
unrhd: '\u22B5',
|
||||
vDash: ['\u22A8', {variantForm: true}],
|
||||
Vdash: '\u22A9',
|
||||
Vvdash: '\u22AA',
|
||||
smallsmile: ['\u2323', {variantForm: true}],
|
||||
shortmid: ['\u2223', {variantForm: true}],
|
||||
smallfrown: ['\u2322', {variantForm: true}],
|
||||
shortparallel: ['\u2225', {variantForm: true}],
|
||||
bumpeq: '\u224F',
|
||||
between: '\u226C',
|
||||
Bumpeq: '\u224E',
|
||||
pitchfork: '\u22D4',
|
||||
varpropto: ['\u221D', {variantForm: true}],
|
||||
backepsilon: '\u220D',
|
||||
blacktriangleleft: '\u25C2',
|
||||
blacktriangleright: '\u25B8',
|
||||
therefore: '\u2234',
|
||||
because: '\u2235',
|
||||
eqsim: '\u2242',
|
||||
vartriangle: ['\u25B3', {variantForm: true}],
|
||||
Join: '\u22C8',
|
||||
|
||||
// Negated relations
|
||||
nless: '\u226E',
|
||||
ngtr: '\u226F',
|
||||
nleq: '\u2270',
|
||||
ngeq: '\u2271',
|
||||
nleqslant: ['\u2A87', {variantForm: true}],
|
||||
ngeqslant: ['\u2A88', {variantForm: true}],
|
||||
nleqq: ['\u2270', {variantForm: true}],
|
||||
ngeqq: ['\u2271', {variantForm: true}],
|
||||
lneq: '\u2A87',
|
||||
gneq: '\u2A88',
|
||||
lneqq: '\u2268',
|
||||
gneqq: '\u2269',
|
||||
lvertneqq: ['\u2268', {variantForm: true}],
|
||||
gvertneqq: ['\u2269', {variantForm: true}],
|
||||
lnsim: '\u22E6',
|
||||
gnsim: '\u22E7',
|
||||
lnapprox: '\u2A89',
|
||||
gnapprox: '\u2A8A',
|
||||
nprec: '\u2280',
|
||||
nsucc: '\u2281',
|
||||
npreceq: ['\u22E0', {variantForm: true}],
|
||||
nsucceq: ['\u22E1', {variantForm: true}],
|
||||
precneqq: '\u2AB5',
|
||||
succneqq: '\u2AB6',
|
||||
precnsim: '\u22E8',
|
||||
succnsim: '\u22E9',
|
||||
precnapprox: '\u2AB9',
|
||||
succnapprox: '\u2ABA',
|
||||
nsim: '\u2241',
|
||||
ncong: '\u2247',
|
||||
nshortmid: ['\u2224', {variantForm: true}],
|
||||
nshortparallel: ['\u2226', {variantForm: true}],
|
||||
nmid: '\u2224',
|
||||
nparallel: '\u2226',
|
||||
nvdash: '\u22AC',
|
||||
nvDash: '\u22AD',
|
||||
nVdash: '\u22AE',
|
||||
nVDash: '\u22AF',
|
||||
ntriangleleft: '\u22EA',
|
||||
ntriangleright: '\u22EB',
|
||||
ntrianglelefteq: '\u22EC',
|
||||
ntrianglerighteq: '\u22ED',
|
||||
nsubseteq: '\u2288',
|
||||
nsupseteq: '\u2289',
|
||||
nsubseteqq: ['\u2288', {variantForm: true}],
|
||||
nsupseteqq: ['\u2289', {variantForm: true}],
|
||||
subsetneq: '\u228A',
|
||||
supsetneq: '\u228B',
|
||||
varsubsetneq: ['\u228A', {variantForm: true}],
|
||||
varsupsetneq: ['\u228B', {variantForm: true}],
|
||||
subsetneqq: '\u2ACB',
|
||||
supsetneqq: '\u2ACC',
|
||||
varsubsetneqq: ['\u2ACB', {variantForm: true}],
|
||||
varsupsetneqq: ['\u2ACC', {variantForm: true}],
|
||||
|
||||
|
||||
// Arrows
|
||||
leftleftarrows: '\u21C7',
|
||||
rightrightarrows: '\u21C9',
|
||||
leftrightarrows: '\u21C6',
|
||||
rightleftarrows: '\u21C4',
|
||||
Lleftarrow: '\u21DA',
|
||||
Rrightarrow: '\u21DB',
|
||||
twoheadleftarrow: '\u219E',
|
||||
twoheadrightarrow: '\u21A0',
|
||||
leftarrowtail: '\u21A2',
|
||||
rightarrowtail: '\u21A3',
|
||||
looparrowleft: '\u21AB',
|
||||
looparrowright: '\u21AC',
|
||||
leftrightharpoons: '\u21CB',
|
||||
rightleftharpoons: ['\u21CC', {variantForm: true}],
|
||||
curvearrowleft: '\u21B6',
|
||||
curvearrowright: '\u21B7',
|
||||
circlearrowleft: '\u21BA',
|
||||
circlearrowright: '\u21BB',
|
||||
Lsh: '\u21B0',
|
||||
Rsh: '\u21B1',
|
||||
upuparrows: '\u21C8',
|
||||
downdownarrows: '\u21CA',
|
||||
upharpoonleft: '\u21BF',
|
||||
upharpoonright: '\u21BE',
|
||||
downharpoonleft: '\u21C3',
|
||||
restriction: '\u21BE',
|
||||
multimap: '\u22B8',
|
||||
downharpoonright: '\u21C2',
|
||||
leftrightsquigarrow: '\u21AD',
|
||||
rightsquigarrow: '\u21DD',
|
||||
leadsto: '\u21DD',
|
||||
dashrightarrow: '\u21E2',
|
||||
dashleftarrow: '\u21E0',
|
||||
|
||||
// Negated arrows
|
||||
nleftarrow: '\u219A',
|
||||
nrightarrow: '\u219B',
|
||||
nLeftarrow: '\u21CD',
|
||||
nRightarrow: '\u21CF',
|
||||
nleftrightarrow: '\u21AE',
|
||||
nLeftrightarrow: '\u21CE'
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Delimiters from the AMS Symbols package.
|
||||
*/
|
||||
new sm.DelimiterMap('AMSsymbols-delimiter', ParseMethods.delimiter, {
|
||||
// corners
|
||||
'\\ulcorner': '\u231C',
|
||||
'\\urcorner': '\u231D',
|
||||
'\\llcorner': '\u231E',
|
||||
'\\lrcorner': '\u231F'
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Macros from the AMS Symbols package.
|
||||
*/
|
||||
new sm.CommandMap('AMSsymbols-macros', {
|
||||
implies: ['Macro', '\\;\\Longrightarrow\\;'],
|
||||
impliedby: ['Macro', '\\;\\Longleftarrow\\;']
|
||||
}, AmsMethods);
|
||||
602
node_modules/mathjax-full/ts/input/tex/ams/AmsMethods.ts
generated
vendored
Normal file
602
node_modules/mathjax-full/ts/input/tex/ams/AmsMethods.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,602 @@
|
|||
/*************************************************************
|
||||
*
|
||||
* Copyright (c) 2018-2022 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.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @fileoverview The AMS Parse methods.
|
||||
*
|
||||
* @author v.sorge@mathjax.org (Volker Sorge)
|
||||
*/
|
||||
|
||||
|
||||
import {StackItem} from '../StackItem.js';
|
||||
import {ParseMethod} from '../Types.js';
|
||||
import ParseUtil from '../ParseUtil.js';
|
||||
import ParseMethods from '../ParseMethods.js';
|
||||
import NodeUtil from '../NodeUtil.js';
|
||||
import {TexConstant} from '../TexConstants.js';
|
||||
import TexParser from '../TexParser.js';
|
||||
import TexError from '../TexError.js';
|
||||
import {Macro} from '../Symbol.js';
|
||||
import {CommandMap} from '../SymbolMap.js';
|
||||
import {ArrayItem} from '../base/BaseItems.js';
|
||||
import {FlalignItem} from './AmsItems.js';
|
||||
import BaseMethods from '../base/BaseMethods.js';
|
||||
import {TEXCLASS} from '../../../core/MmlTree/MmlNode.js';
|
||||
import {MmlMunderover} from '../../../core/MmlTree/MmlNodes/munderover.js';
|
||||
import {MmlNode, AbstractMmlTokenNode} from '../../../core/MmlTree/MmlNode.js';
|
||||
|
||||
|
||||
// Namespace
|
||||
export const AmsMethods: Record<string, ParseMethod> = {};
|
||||
|
||||
|
||||
/**
|
||||
* Handle AMS array environments.
|
||||
* @param {TexParser} parser The calling parser.
|
||||
* @param {StackItem} begin The opening stackitem.
|
||||
* @param {boolean} numbered Environment numbered.
|
||||
* @param {boolean} taggable Environment taggable (e.g., align* is taggable,
|
||||
* split is not).
|
||||
* @param {string} align Column alignment.
|
||||
* @param {string} spacing Column spacing.
|
||||
* @param {string} style Display style indicator.
|
||||
*/
|
||||
AmsMethods.AmsEqnArray = function(parser: TexParser, begin: StackItem,
|
||||
numbered: boolean, taggable: boolean,
|
||||
align: string, spacing: string,
|
||||
style: string) {
|
||||
// @test Aligned, Gathered
|
||||
const args = parser.GetBrackets('\\begin{' + begin.getName() + '}');
|
||||
const array = BaseMethods.EqnArray(parser, begin, numbered, taggable, align, spacing, style);
|
||||
return ParseUtil.setArrayAlign(array as ArrayItem, args);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Handle AMS alignat environments.
|
||||
* @param {TexParser} parser The calling parser.
|
||||
* @param {StackItem} begin The opening stackitem.
|
||||
* @param {boolean} numbered Environment numbered.
|
||||
* @param {boolean} taggable Environment taggable (e.g., align* is taggable,
|
||||
* split is not).
|
||||
*/
|
||||
AmsMethods.AlignAt = function(parser: TexParser, begin: StackItem,
|
||||
numbered: boolean, taggable: boolean) {
|
||||
const name = begin.getName();
|
||||
let n, valign, align = '', spacing = [];
|
||||
if (!taggable) {
|
||||
// @test Alignedat
|
||||
valign = parser.GetBrackets('\\begin{' + name + '}');
|
||||
}
|
||||
n = parser.GetArgument('\\begin{' + name + '}');
|
||||
if (n.match(/[^0-9]/)) {
|
||||
// @test PositiveIntegerArg
|
||||
throw new TexError('PositiveIntegerArg',
|
||||
'Argument to %1 must me a positive integer',
|
||||
'\\begin{' + name + '}');
|
||||
}
|
||||
let count = parseInt(n, 10);
|
||||
while (count > 0) {
|
||||
align += 'rl';
|
||||
spacing.push('0em 0em');
|
||||
count--;
|
||||
}
|
||||
let spaceStr = spacing.join(' ');
|
||||
if (taggable) {
|
||||
// @test Alignat, Alignat Star
|
||||
return AmsMethods.EqnArray(parser, begin, numbered, taggable, align, spaceStr);
|
||||
}
|
||||
// @test Alignedat
|
||||
let array = AmsMethods.EqnArray(parser, begin, numbered, taggable, align, spaceStr);
|
||||
return ParseUtil.setArrayAlign(array as ArrayItem, valign);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Implements multline environment (mostly handled through STACKITEM below)
|
||||
* @param {TexParser} parser The calling parser.
|
||||
* @param {StackItem} begin The opening stackitem.
|
||||
* @param {boolean} numbered Environment numbered.
|
||||
*/
|
||||
AmsMethods.Multline = function (parser: TexParser, begin: StackItem, numbered: boolean) {
|
||||
// @test Shove*, Multline
|
||||
parser.Push(begin);
|
||||
ParseUtil.checkEqnEnv(parser);
|
||||
const item = parser.itemFactory.create('multline', numbered, parser.stack) as ArrayItem;
|
||||
item.arraydef = {
|
||||
displaystyle: true,
|
||||
rowspacing: '.5em',
|
||||
columnspacing: '100%',
|
||||
width: parser.options.ams['multlineWidth'],
|
||||
side: parser.options['tagSide'],
|
||||
minlabelspacing: parser.options['tagIndent'],
|
||||
framespacing: parser.options.ams['multlineIndent'] + ' 0',
|
||||
frame: '', // Use frame spacing with no actual frame
|
||||
'data-width-includes-label': true // take label space out of 100% width
|
||||
};
|
||||
return item;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Generate an align at environment.
|
||||
* @param {TexParser} parser The current TeX parser.
|
||||
* @param {StackItem} begin The begin stackitem.
|
||||
* @param {boolean} numbered Is this a numbered array.
|
||||
* @param {boolean} padded Is it padded.
|
||||
*/
|
||||
AmsMethods.XalignAt = function(parser: TexParser, begin: StackItem,
|
||||
numbered: boolean, padded: boolean) {
|
||||
let n = parser.GetArgument('\\begin{' + begin.getName() + '}');
|
||||
if (n.match(/[^0-9]/)) {
|
||||
throw new TexError('PositiveIntegerArg',
|
||||
'Argument to %1 must me a positive integer',
|
||||
'\\begin{' + begin.getName() + '}');
|
||||
}
|
||||
const align = (padded ? 'crl' : 'rlc');
|
||||
const width = (padded ? 'fit auto auto' : 'auto auto fit');
|
||||
const item = AmsMethods.FlalignArray(parser, begin, numbered, padded, false, align, width, true) as FlalignItem;
|
||||
item.setProperty('xalignat', 2 * parseInt(n));
|
||||
return item;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Generate an flalign environment.
|
||||
* @param {TexParser} parser The current TeX parser.
|
||||
* @param {StackItem} begin The begin stackitem.
|
||||
* @param {boolean} numbered Is this a numbered array.
|
||||
* @param {boolean} padded Is it padded.
|
||||
* @param {boolean} center Is it centered.
|
||||
* @param {string} align The horizontal alignment for columns
|
||||
* @param {string} width The column widths of the table
|
||||
* @param {boolean} zeroWidthLabel True if the label should be in llap/rlap
|
||||
*/
|
||||
AmsMethods.FlalignArray = function(parser: TexParser, begin: StackItem, numbered: boolean,
|
||||
padded: boolean, center: boolean, align: string,
|
||||
width: string, zeroWidthLabel: boolean = false) {
|
||||
parser.Push(begin);
|
||||
ParseUtil.checkEqnEnv(parser);
|
||||
align = align
|
||||
.split('')
|
||||
.join(' ')
|
||||
.replace(/r/g, 'right')
|
||||
.replace(/l/g, 'left')
|
||||
.replace(/c/g, 'center');
|
||||
const item = parser.itemFactory.create(
|
||||
'flalign', begin.getName(), numbered, padded, center, parser.stack) as FlalignItem;
|
||||
item.arraydef = {
|
||||
width: '100%',
|
||||
displaystyle: true,
|
||||
columnalign: align,
|
||||
columnspacing: '0em',
|
||||
columnwidth: width,
|
||||
rowspacing: '3pt',
|
||||
side: parser.options['tagSide'],
|
||||
minlabelspacing: (zeroWidthLabel ? '0' : parser.options['tagIndent']),
|
||||
'data-width-includes-label': true,
|
||||
};
|
||||
item.setProperty('zeroWidthLabel', zeroWidthLabel);
|
||||
return item;
|
||||
};
|
||||
|
||||
|
||||
export const NEW_OPS = 'ams-declare-ops';
|
||||
|
||||
/**
|
||||
* Handle DeclareMathOperator.
|
||||
* @param {TexParser} parser The calling parser.
|
||||
* @param {string} name The macro name.
|
||||
*/
|
||||
AmsMethods.HandleDeclareOp = function (parser: TexParser, name: string) {
|
||||
let star = (parser.GetStar() ? '*' : '');
|
||||
let cs = ParseUtil.trimSpaces(parser.GetArgument(name));
|
||||
if (cs.charAt(0) === '\\') {
|
||||
cs = cs.substr(1);
|
||||
}
|
||||
let op = parser.GetArgument(name);
|
||||
(parser.configuration.handlers.retrieve(NEW_OPS) as CommandMap).
|
||||
add(cs, new Macro(cs, AmsMethods.Macro, [`\\operatorname${star}{${op}}`]));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Handle operatorname.
|
||||
* @param {TexParser} parser The calling parser.
|
||||
* @param {string} name The macro name.
|
||||
*/
|
||||
AmsMethods.HandleOperatorName = function(parser: TexParser, name: string) {
|
||||
// @test Operatorname
|
||||
const star = parser.GetStar();
|
||||
//
|
||||
// Parse the argument using operator letters and grouping multiple letters.
|
||||
//
|
||||
let op = ParseUtil.trimSpaces(parser.GetArgument(name));
|
||||
let mml = new TexParser(op, {
|
||||
...parser.stack.env,
|
||||
font: TexConstant.Variant.NORMAL,
|
||||
multiLetterIdentifiers: /^[-*a-z]+/i as any,
|
||||
operatorLetters: true
|
||||
}, parser.configuration).mml();
|
||||
//
|
||||
// If we get something other than a single mi, wrap in a TeXAtom.
|
||||
//
|
||||
if (!mml.isKind('mi')) {
|
||||
mml = parser.create('node', 'TeXAtom', [mml]);
|
||||
}
|
||||
//
|
||||
// Mark the limit properties and the TeX class.
|
||||
//
|
||||
NodeUtil.setProperties(mml, {movesupsub: star, movablelimits: true, texClass: TEXCLASS.OP});
|
||||
//
|
||||
// Skip a following \limits macro if not a starred operator
|
||||
//
|
||||
if (!star) {
|
||||
const c = parser.GetNext(), i = parser.i;
|
||||
if (c === '\\' && ++parser.i && parser.GetCS() !== 'limits') {
|
||||
parser.i = i;
|
||||
}
|
||||
}
|
||||
//
|
||||
parser.Push(mml);
|
||||
};
|
||||
|
||||
/**
|
||||
* Handle sideset.
|
||||
* @param {TexParser} parser The calling parser.
|
||||
* @param {string} name The macro name.
|
||||
*/
|
||||
AmsMethods.SideSet = function (parser: TexParser, name: string) {
|
||||
//
|
||||
// Get the pre- and post-scripts, and any extra material from the arguments
|
||||
//
|
||||
const [preScripts, preRest] = splitSideSet(parser.ParseArg(name));
|
||||
const [postScripts, postRest] = splitSideSet(parser.ParseArg(name));
|
||||
const base = parser.ParseArg(name);
|
||||
let mml = base;
|
||||
//
|
||||
// If there are pre-scripts...
|
||||
//
|
||||
if (preScripts) {
|
||||
//
|
||||
// If there is other material...
|
||||
//
|
||||
if (preRest) {
|
||||
//
|
||||
// Replace the empty base of the prescripts with a phantom element of the
|
||||
// original base, with width 0 (but still of the correct height and depth).
|
||||
// so the scripts will be at the right heights.
|
||||
//
|
||||
preScripts.replaceChild(
|
||||
parser.create('node', 'mphantom', [
|
||||
parser.create('node', 'mpadded', [ParseUtil.copyNode(base, parser)], {width: 0})
|
||||
]),
|
||||
NodeUtil.getChildAt(preScripts, 0)
|
||||
);
|
||||
} else {
|
||||
//
|
||||
// If there is no extra meterial, make a mmultiscripts element
|
||||
//
|
||||
mml = parser.create('node', 'mmultiscripts', [base]);
|
||||
//
|
||||
// Add any postscripts
|
||||
//
|
||||
if (postScripts) {
|
||||
NodeUtil.appendChildren(mml, [
|
||||
NodeUtil.getChildAt(postScripts, 1) || parser.create('node', 'none'),
|
||||
NodeUtil.getChildAt(postScripts, 2) || parser.create('node', 'none')
|
||||
]);
|
||||
}
|
||||
//
|
||||
// Add the prescripts (left aligned)
|
||||
//
|
||||
NodeUtil.setProperty(mml, 'scriptalign', 'left');
|
||||
NodeUtil.appendChildren(mml, [
|
||||
parser.create('node', 'mprescripts'),
|
||||
NodeUtil.getChildAt(preScripts, 1) || parser.create('node', 'none'),
|
||||
NodeUtil.getChildAt(preScripts, 2) || parser.create('node', 'none')
|
||||
]);
|
||||
}
|
||||
}
|
||||
//
|
||||
// If there are postscripts and we didn't make a mmultiscript element above...
|
||||
//
|
||||
if (postScripts && mml === base) {
|
||||
//
|
||||
// Replace the emtpy base with actual base, and use that as the mml
|
||||
//
|
||||
postScripts.replaceChild(base, NodeUtil.getChildAt(postScripts, 0));
|
||||
mml = postScripts;
|
||||
}
|
||||
//
|
||||
// Put the needed pieces into a TeXAtom of class OP.
|
||||
// Note that the postScripts are in the mml element,
|
||||
// either as part of the mmultiscripts node, or the
|
||||
// msubsup with the base inserted into it.
|
||||
//
|
||||
const mrow = parser.create('node', 'TeXAtom', [], {texClass: TEXCLASS.OP, movesupsub: true, movablelimits: true});
|
||||
if (preRest) {
|
||||
preScripts && mrow.appendChild(preScripts);
|
||||
mrow.appendChild(preRest);
|
||||
}
|
||||
mrow.appendChild(mml);
|
||||
postRest && mrow.appendChild(postRest);
|
||||
parser.Push(mrow);
|
||||
};
|
||||
|
||||
/**
|
||||
* Utility for breaking the \sideset scripts from any other material.
|
||||
* @param {MmlNode} mml The node to check.
|
||||
* @return {[MmlNode, MmlNode]} The msubsup with the scripts together with any extra nodes.
|
||||
*/
|
||||
function splitSideSet(mml: MmlNode): [MmlNode, MmlNode] {
|
||||
if (!mml || (mml.isInferred && mml.childNodes.length === 0)) return [null, null];
|
||||
if (mml.isKind('msubsup') && checkSideSetBase(mml)) return [mml, null];
|
||||
const child = NodeUtil.getChildAt(mml, 0);
|
||||
if (!(mml.isInferred && child && checkSideSetBase(child))) return [null, mml];
|
||||
mml.childNodes.splice(0, 1); // remove first child
|
||||
return [child, mml];
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility for checking if a \sideset argument has scripts with an empty base.
|
||||
* @param {MmlNode} mml The node to check.
|
||||
* @return {boolean} True if the base is not and empty mi element.
|
||||
*/
|
||||
function checkSideSetBase(mml: MmlNode): boolean {
|
||||
const base = mml.childNodes[0];
|
||||
return base && base.isKind('mi') && (base as AbstractMmlTokenNode).getText() === '';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handle extra letters in \operatorname (- and *), default to normal otherwise.
|
||||
* @param {TexParser} parser The calling parser.
|
||||
* @param {string} c The letter being checked
|
||||
*/
|
||||
AmsMethods.operatorLetter = function (parser: TexParser, c: string) {
|
||||
return parser.stack.env.operatorLetters ? ParseMethods.variable(parser, c) : false;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Handle multi integral signs.
|
||||
* @param {TexParser} parser The calling parser.
|
||||
* @param {string} name The macro name.
|
||||
* @param {string} integral The actual integral sign.
|
||||
*/
|
||||
AmsMethods.MultiIntegral = function(parser: TexParser, name: string,
|
||||
integral: string) {
|
||||
let next = parser.GetNext();
|
||||
if (next === '\\') {
|
||||
// @test MultiInt with Command
|
||||
let i = parser.i;
|
||||
next = parser.GetArgument(name);
|
||||
parser.i = i;
|
||||
if (next === '\\limits') {
|
||||
if (name === '\\idotsint') {
|
||||
// @test MultiInt with Limits
|
||||
integral = '\\!\\!\\mathop{\\,\\,' + integral + '}';
|
||||
}
|
||||
else {
|
||||
// Question: This is not used anymore?
|
||||
integral = '\\!\\!\\!\\mathop{\\,\\,\\,' + integral + '}';
|
||||
}
|
||||
}
|
||||
}
|
||||
// @test MultiInt, MultiInt in Context
|
||||
parser.string = integral + ' ' + parser.string.slice(parser.i);
|
||||
parser.i = 0;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Handle stretchable arrows.
|
||||
* @param {TexParser} parser The calling parser.
|
||||
* @param {string} name The macro name.
|
||||
* @param {number} chr The arrow character in hex code.
|
||||
* @param {number} l Left width.
|
||||
* @param {number} r Right width.
|
||||
*/
|
||||
AmsMethods.xArrow = function(parser: TexParser, name: string,
|
||||
chr: number, l: number, r: number) {
|
||||
let def = {width: '+' + ParseUtil.Em((l + r) / 18), lspace: ParseUtil.Em(l / 18)};
|
||||
let bot = parser.GetBrackets(name);
|
||||
let first = parser.ParseArg(name);
|
||||
let dstrut = parser.create('node', 'mspace', [], {depth: '.25em'});
|
||||
let arrow = parser.create('token',
|
||||
'mo', {stretchy: true, texClass: TEXCLASS.REL}, String.fromCodePoint(chr));
|
||||
arrow = parser.create('node', 'mstyle', [arrow], {scriptlevel: 0});
|
||||
let mml = parser.create('node', 'munderover', [arrow]) as MmlMunderover;
|
||||
let mpadded = parser.create('node', 'mpadded', [first, dstrut], def);
|
||||
NodeUtil.setAttribute(mpadded, 'voffset', '-.2em');
|
||||
NodeUtil.setAttribute(mpadded, 'height', '-.2em');
|
||||
NodeUtil.setChild(mml, mml.over, mpadded);
|
||||
if (bot) {
|
||||
// @test Above Below Left Arrow, Above Below Right Arrow
|
||||
let bottom = new TexParser(bot, parser.stack.env, parser.configuration).mml();
|
||||
let bstrut = parser.create('node', 'mspace', [], {height: '.75em'});
|
||||
mpadded = parser.create('node', 'mpadded', [bottom, bstrut], def);
|
||||
NodeUtil.setAttribute(mpadded, 'voffset', '.15em');
|
||||
NodeUtil.setAttribute(mpadded, 'depth', '-.15em');
|
||||
NodeUtil.setChild(mml, mml.under, mpadded);
|
||||
}
|
||||
// @test Above Left Arrow, Above Right Arrow, Above Left Arrow in Context,
|
||||
// Above Right Arrow in Context
|
||||
NodeUtil.setProperty(mml, 'subsupOK', true);
|
||||
parser.Push(mml);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Record presence of \shoveleft and \shoveright
|
||||
* @param {TexParser} parser The calling parser.
|
||||
* @param {string} name The macro name.
|
||||
* @param {string} shove The shove value.
|
||||
*/
|
||||
AmsMethods.HandleShove = function(parser: TexParser, _name: string,
|
||||
shove: string) {
|
||||
let top = parser.stack.Top();
|
||||
// @test Shove (Left|Right) (Top|Middle|Bottom)
|
||||
if (top.kind !== 'multline') {
|
||||
// @test Shove Error Environment
|
||||
throw new TexError('CommandOnlyAllowedInEnv',
|
||||
'%1 only allowed in %2 environment',
|
||||
parser.currentCS, 'multline');
|
||||
}
|
||||
if (top.Size()) {
|
||||
// @test Shove Error (Top|Middle|Bottom)
|
||||
throw new TexError('CommandAtTheBeginingOfLine',
|
||||
'%1 must come at the beginning of the line', parser.currentCS);
|
||||
}
|
||||
top.setProperty('shove', shove);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Handle \cfrac
|
||||
* @param {TexParser} parser The calling parser.
|
||||
* @param {string} name The macro name.
|
||||
*/
|
||||
AmsMethods.CFrac = function(parser: TexParser, name: string) {
|
||||
let lr = ParseUtil.trimSpaces(parser.GetBrackets(name, ''));
|
||||
let num = parser.GetArgument(name);
|
||||
let den = parser.GetArgument(name);
|
||||
let lrMap: {[key: string]: string} = {
|
||||
l: TexConstant.Align.LEFT, r: TexConstant.Align.RIGHT, '': ''};
|
||||
let numNode = new TexParser('\\strut\\textstyle{' + num + '}',
|
||||
parser.stack.env, parser.configuration).mml();
|
||||
let denNode = new TexParser('\\strut\\textstyle{' + den + '}',
|
||||
parser.stack.env, parser.configuration).mml();
|
||||
let frac = parser.create('node', 'mfrac', [numNode, denNode]);
|
||||
lr = lrMap[lr];
|
||||
if (lr == null) {
|
||||
// @test Center Fraction Error
|
||||
throw new TexError('IllegalAlign', 'Illegal alignment specified in %1', parser.currentCS);
|
||||
}
|
||||
if (lr) {
|
||||
// @test Right Fraction, Left Fraction
|
||||
NodeUtil.setProperties(frac, {numalign: lr, denomalign: lr});
|
||||
}
|
||||
// @test Center Fraction
|
||||
parser.Push(frac);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Implement AMS generalized fraction.
|
||||
* @param {TexParser} parser The calling parser.
|
||||
* @param {string} name The macro name.
|
||||
* @param {string} left Left delimiter.
|
||||
* @param {string} right Right delimiter.
|
||||
* @param {string} thick Line thickness.
|
||||
* @param {string} style Math style.
|
||||
*/
|
||||
AmsMethods.Genfrac = function(parser: TexParser, name: string, left: string,
|
||||
right: string, thick: string, style: string) {
|
||||
if (left == null) { // @test Genfrac
|
||||
left = parser.GetDelimiterArg(name);
|
||||
}
|
||||
if (right == null) { // @test Genfrac
|
||||
right = parser.GetDelimiterArg(name);
|
||||
}
|
||||
if (thick == null) { // @test Genfrac
|
||||
thick = parser.GetArgument(name);
|
||||
}
|
||||
if (style == null) { // @test Genfrac
|
||||
style = ParseUtil.trimSpaces(parser.GetArgument(name));
|
||||
}
|
||||
let num = parser.ParseArg(name);
|
||||
let den = parser.ParseArg(name);
|
||||
let frac = parser.create('node', 'mfrac', [num, den]);
|
||||
if (thick !== '') {
|
||||
// @test Normal Binomial, Text Binomial, Display Binomial
|
||||
NodeUtil.setAttribute(frac, 'linethickness', thick);
|
||||
}
|
||||
if (left || right) {
|
||||
// @test Normal Binomial, Text Binomial, Display Binomial
|
||||
NodeUtil.setProperty(frac, 'withDelims', true);
|
||||
frac = ParseUtil.fixedFence(parser.configuration, left, frac, right);
|
||||
}
|
||||
if (style !== '') {
|
||||
let styleDigit = parseInt(style, 10);
|
||||
let styleAlpha = ['D', 'T', 'S', 'SS'][styleDigit];
|
||||
if (styleAlpha == null) {
|
||||
// @test Genfrac Error
|
||||
throw new TexError('BadMathStyleFor', 'Bad math style for %1', parser.currentCS);
|
||||
}
|
||||
frac = parser.create('node', 'mstyle', [frac]);
|
||||
if (styleAlpha === 'D') {
|
||||
// @test Display Fraction, Display Sub Fraction, Display Binomial,
|
||||
// Display Sub Binomial
|
||||
NodeUtil.setProperties(frac, {displaystyle: true, scriptlevel: 0});
|
||||
}
|
||||
else {
|
||||
// @test Text Fraction, Text Sub Fraction, Text Binomial,
|
||||
// Text Sub Binomial
|
||||
NodeUtil.setProperties(frac, {displaystyle: false,
|
||||
scriptlevel: styleDigit - 1});
|
||||
}
|
||||
}
|
||||
// @test Text Fraction, Normal Sub Binomial, Normal Binomial
|
||||
parser.Push(frac);
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Add the tag to the environment (to be added to the table row later).
|
||||
* @param {TexParser} parser The calling parser.
|
||||
* @param {string} name The macro name.
|
||||
*/
|
||||
AmsMethods.HandleTag = function(parser: TexParser, name: string) {
|
||||
if (!parser.tags.currentTag.taggable && parser.tags.env) {
|
||||
// @test Illegal Tag Error
|
||||
throw new TexError('CommandNotAllowedInEnv',
|
||||
'%1 not allowed in %2 environment',
|
||||
parser.currentCS, parser.tags.env);
|
||||
}
|
||||
if (parser.tags.currentTag.tag) {
|
||||
// @test Double Tag Error
|
||||
throw new TexError('MultipleCommand', 'Multiple %1', parser.currentCS);
|
||||
}
|
||||
let star = parser.GetStar();
|
||||
let tagId = ParseUtil.trimSpaces(parser.GetArgument(name));
|
||||
parser.tags.tag(tagId, star);
|
||||
};
|
||||
|
||||
|
||||
AmsMethods.HandleNoTag = BaseMethods.HandleNoTag;
|
||||
|
||||
AmsMethods.HandleRef = BaseMethods.HandleRef;
|
||||
|
||||
AmsMethods.Macro = BaseMethods.Macro;
|
||||
|
||||
AmsMethods.Accent = BaseMethods.Accent;
|
||||
|
||||
AmsMethods.Tilde = BaseMethods.Tilde;
|
||||
|
||||
AmsMethods.Array = BaseMethods.Array;
|
||||
|
||||
AmsMethods.Spacer = BaseMethods.Spacer;
|
||||
|
||||
AmsMethods.NamedOp = BaseMethods.NamedOp;
|
||||
|
||||
AmsMethods.EqnArray = BaseMethods.EqnArray;
|
||||
|
||||
AmsMethods.Equation = BaseMethods.Equation;
|
||||
Loading…
Add table
Add a link
Reference in a new issue