add initial marp implementation with sample content and build configuration

This commit is contained in:
2025-09-13 18:13:22 +02:00
parent dcacc9b409
commit e5f219507f
10319 changed files with 1402023 additions and 0 deletions
+42
View File
@@ -0,0 +1,42 @@
/*************************************************************
*
* 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 Braket package.
*
* @author v.sorge@mathjax.org (Volker Sorge)
*/
import {Configuration} from '../Configuration.js';
import {BraketItem} from './BraketItems.js';
import './BraketMappings.js';
export const BraketConfiguration = Configuration.create(
'braket', {
handler: {
character: ['Braket-characters'],
macro: ['Braket-macros']
},
items: {
[BraketItem.prototype.kind]: BraketItem,
}
}
);
+89
View File
@@ -0,0 +1,89 @@
/*************************************************************
*
* 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 Stack items for parsing the braket package.
*
* @author v.sorge@mathjax.org (Volker Sorge)
*/
import {CheckType, BaseItem, StackItem} from '../StackItem.js';
import {TEXCLASS} from '../../../core/MmlTree/MmlNode.js';
import ParseUtil from '../ParseUtil.js';
/**
* A bra-ket command. Collates elements from the opening brace to the closing
* brace, adding bars to a given maximal number (e.g., only one in case of
* set). To finalise it adds the surrounding angle brackets or braces.
*/
export class BraketItem extends BaseItem {
/**
* @override
*/
get kind() {
return 'braket';
}
/**
* @override
*/
get isOpen() {
return true;
}
/**
* @override
*/
public checkItem(item: StackItem): CheckType {
if (item.isKind('close')) {
return [[this.factory.create('mml', this.toMml())], true];
}
if (item.isKind('mml')) {
this.Push(item.toMml());
if (this.getProperty('single')) {
return [[this.toMml()], true];
}
return BaseItem.fail;
}
return super.checkItem(item);
}
/**
* @override
*/
public toMml() {
let inner = super.toMml();
let open = this.getProperty('open') as string;
let close = this.getProperty('close') as string;
if (this.getProperty('stretchy')) {
return ParseUtil.fenced(this.factory.configuration, open, inner, close);
}
let attrs = {fence: true, stretchy: false, symmetric: true, texClass: TEXCLASS.OPEN};
let openNode = this.create('token', 'mo', attrs, open);
attrs.texClass = TEXCLASS.CLOSE;
let closeNode = this.create('token', 'mo', attrs, close);
let mrow = this.create('node', 'mrow', [openNode, inner, closeNode],
{open: open, close: close, texClass: TEXCLASS.INNER});
return mrow;
}
}
+56
View File
@@ -0,0 +1,56 @@
/*************************************************************
*
* 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 Mappings for TeX parsing of the braket package.
*
* @author v.sorge@mathjax.org (Volker Sorge)
*/
import {CommandMap, MacroMap} from '../SymbolMap.js';
import BraketMethods from './BraketMethods.js';
/**
* Macros for braket package.
*/
new CommandMap('Braket-macros', {
bra: ['Macro', '{\\langle {#1} \\vert}', 1],
ket: ['Macro', '{\\vert {#1} \\rangle}', 1],
braket: ['Braket', '\u27E8', '\u27E9', false, Infinity],
'set': ['Braket', '{', '}', false, 1],
Bra: ['Macro', '{\\left\\langle {#1} \\right\\vert}', 1],
Ket: ['Macro', '{\\left\\vert {#1} \\right\\rangle}', 1],
Braket: ['Braket', '\u27E8', '\u27E9', true, Infinity],
Set: ['Braket', '{', '}', true, 1],
// Not part of the LaTeX package:
ketbra: ['Macro', '{\\vert {#1} \\rangle\\langle {#2} \\vert}', 2],
Ketbra: ['Macro', '{\\left\\vert {#1} \\right\\rangle\\left\\langle {#2} \\right\\vert}', 2],
// Treatment of bar.
'|': 'Bar'
}, BraketMethods);
/**
* Character map for braket package.
*/
new MacroMap('Braket-characters', {
'|': 'Bar'
}, BraketMethods);
+99
View File
@@ -0,0 +1,99 @@
/*************************************************************
*
* 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 Methods for TeX parsing of the braket package.
*
* @author v.sorge@mathjax.org (Volker Sorge)
*/
import {ParseMethod} from '../Types.js';
import BaseMethods from '../base/BaseMethods.js';
import TexParser from '../TexParser.js';
import {TEXCLASS} from '../../../core/MmlTree/MmlNode.js';
import TexError from '../TexError.js';
let BraketMethods: Record<string, ParseMethod> = {};
BraketMethods.Macro = BaseMethods.Macro;
/**
* Generate a bra-ket expression.
* @param {TexParser} parser The current TeX parser.
* @param {string} name Name of the current control sequence.
* @param {string} open Opening delimiter.
* @param {string} close Closing delimiter.
* @param {boolean} stretchy Is it stretchy.
* @param {number} barmax Maximum number of bars allowed.
*/
BraketMethods.Braket = function(parser: TexParser, _name: string,
open: string, close: string,
stretchy: boolean, barmax: number) {
let next = parser.GetNext();
if (next === '') {
throw new TexError('MissingArgFor', 'Missing argument for %1', parser.currentCS);
}
let single = true;
if (next === '{') {
parser.i++;
single = false;
}
parser.Push(
parser.itemFactory.create('braket')
.setProperties({barmax: barmax, barcount: 0, open: open,
close: close, stretchy: stretchy, single: single}));
};
/**
* Generate a bar. If inside a bra-ket expressions it's handled accordingly.
* @param {TexParser} parser The current TeX parser.
* @param {string} name Name of the current control sequence.
*/
BraketMethods.Bar = function(parser: TexParser, name: string) {
let c = name === '|' ? '|' : '\u2225';
let top = parser.stack.Top();
if (top.kind !== 'braket' ||
top.getProperty('barcount') >= top.getProperty('barmax')) {
let mml = parser.create('token', 'mo', {texClass: TEXCLASS.ORD, stretchy: false}, c);
parser.Push(mml);
return;
}
if (c === '|' && parser.GetNext() === '|') {
parser.i++;
c = '\u2225';
}
let stretchy = top.getProperty('stretchy');
if (!stretchy) {
let node = parser.create('token', 'mo', {stretchy: false, braketbar: true}, c);
parser.Push(node);
return;
}
let node = parser.create('node', 'TeXAtom', [], {texClass: TEXCLASS.CLOSE});
parser.Push(node);
top.setProperty('barcount', top.getProperty('barcount') as number + 1);
node = parser.create('token', 'mo', {stretchy: true, braketbar: true}, c);
parser.Push(node);
node = parser.create('node', 'TeXAtom', [], {texClass: TEXCLASS.OPEN});
parser.Push(node);
};
export default BraketMethods;