1
0

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

200
node_modules/mathjax-full/ts/core/Tree/Factory.ts generated vendored Normal file
View File

@@ -0,0 +1,200 @@
/*************************************************************
*
* 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 The generic Factory class for creating arbitrary objects
*
* @author dpvc@mathjax.org (Davide Cervone)
*/
/*****************************************************************/
/**
* The Factory node interfaces (one for the node instance, one for the node class)
*/
export interface FactoryNode {
readonly kind: string;
}
/**
* @template N The Node type being created by the factory
*/
export interface FactoryNodeClass<N extends FactoryNode> {
/**
* @param {Factory<N, FactoryNodeClass<N>>} factory The factory for creating more nodes
* @param {any[]} args Any additional arguments needed by the node
* @return {N} The newly created node
*/
new(factory: Factory<N, FactoryNodeClass<N>>, ...args: any[]): N;
}
/*****************************************************************/
/**
* The Factory interface
*
* Factory<N, C> takes a node type N and a node class C, which give
* the interfaces for the node instance and the node constructors. We
* need both for two reasons: first, you can't use typeof N to get C,
* since N is a type not an object, and if N has static members, we
* may want to access them from the results of getNodeClass(kind)
* (this is done in MmlNodes, for example).
*
* @template N The node type created by the factory
* @template C The class of the node being constructed (for access to static properties)
*/
export interface Factory<N extends FactoryNode, C extends FactoryNodeClass<N>> {
/**
* @param {string} kind The kind of node to create
* @return {N} The newly created node of the given kind
*/
create(kind: string): N;
/**
* Defines a class for a given node kind
*
* @param {string} kind The kind whose class is being defined
* @param {C} nodeClass The class for the given kind
*/
setNodeClass(kind: string, nodeClass: C): void;
/**
* @param {string} kind The kind of node whose class is to be returned
* @return {C} The class object for the given kind
*/
getNodeClass(kind: string): C;
/**
* @param {string} kind The kind whose definition is to be deleted
*/
deleteNodeClass(kind: string): void;
/**
* @param {N} node The node to test if it is of a given kind
* @param {string} kind The kind to test for
* @return {boolean} True if the node is of the given kind, false otherwise
*/
nodeIsKind(node: N, kind: string): boolean;
/**
* @return {string[]} The names of all the available kinds of nodes
*/
getKinds(): string[];
}
/*****************************************************************/
/**
* The generic AbstractFactoryClass interface
* (needed for access to defaultNodes via the constructor)
*
* @template N The node type created by the factory
* @template C The class of the node being constructed (for access to static properties)
*/
interface AbstractFactoryClass<N extends FactoryNode, C extends FactoryNodeClass<N>> extends Function {
defaultNodes: {[kind: string]: C};
}
/*****************************************************************/
/**
* The generic AbstractFactory class
*
* @template N The node type created by the factory
* @template C The class of the node being constructed (for access to static properties)
*/
export abstract class AbstractFactory<N extends FactoryNode, C extends FactoryNodeClass<N>> implements Factory<N, C> {
/**
* The default collection of objects to use for the node map
*/
public static defaultNodes = {};
/**
* The default kind
*/
public defaultKind = 'unknown';
/**
* The map of node kinds to node classes
*/
protected nodeMap: Map<string, C> = new Map();
/**
* An object containing functions for creating the various node kinds
*/
protected node: {[kind: string]: (...args: any[]) => N} = {};
/**
* @override
*/
constructor(nodes: {[kind: string]: C} = null) {
if (nodes === null) {
nodes = (this.constructor as AbstractFactoryClass<N, C>).defaultNodes;
}
for (const kind of Object.keys(nodes)) {
this.setNodeClass(kind, nodes[kind]);
}
}
/**
* @override
*/
public create(kind: string, ...args: any[]) {
return (this.node[kind] || this.node[this.defaultKind])(...args);
}
/**
* @override
*/
public setNodeClass(kind: string, nodeClass: C) {
this.nodeMap.set(kind, nodeClass);
let THIS = this;
let KIND = this.nodeMap.get(kind);
this.node[kind] = (...args: any[]) => {
return new KIND(THIS, ...args);
};
}
/**
* @override
*/
public getNodeClass(kind: string): C {
return this.nodeMap.get(kind);
}
/**
* @override
*/
public deleteNodeClass(kind: string) {
this.nodeMap.delete(kind);
delete this.node[kind];
}
/**
* @override
*/
public nodeIsKind(node: N, kind: string) {
return (node instanceof this.getNodeClass(kind));
}
/**
* @override
*/
public getKinds() {
return Array.from(this.nodeMap.keys());
}
}

395
node_modules/mathjax-full/ts/core/Tree/Node.ts generated vendored Normal file
View File

@@ -0,0 +1,395 @@
/*************************************************************
*
* 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 Generic Node classes for node trees
*
* @author dpvc@mathjax.org (Davide Cervone)
*/
import {NodeFactory} from './NodeFactory.js';
/**
* PropertyList and Property are for string data like
* attributes and other properties
*/
export type Property = string | number | boolean;
export type PropertyList = {[key: string]: Property};
/*********************************************************/
/**
* The generic Node interface
*/
export interface Node {
readonly kind: string;
/**
* The NodeFactory to use to create additional nodes, as needed
*/
readonly factory: NodeFactory<Node, NodeClass>;
parent: Node;
childNodes: Node[];
/**
* @param {string} name The name of the property to set
* @param {Property} value The value to which the property will be set
*/
setProperty(name: string, value: Property): void;
/**
* @param {string} name The name of the property to get
* @return {Property} The value of the named property
*/
getProperty(name: string): Property;
/**
* @return {string[]} An array of the names of every property currently defined
*/
getPropertyNames(): string[];
/**
* @return {PropertyList} The propery list containing all the properties of the node
*/
getAllProperties(): PropertyList;
/**
* @param {string[]} names The names of the properties to be removed
*/
removeProperty(...names: string[]): void;
/**
* @param {string} kind The type of node to test for
* @return {boolean} True when the node is of the given type
*/
isKind(kind: string): boolean;
/**
* @param {Node[]} children The child nodes to add to this node
*/
setChildren(children: Node[]): void;
/**
* @param {Node} child A node to add to this node's children
* @return {Node} The child node that was added
*/
appendChild(child: Node): Node;
/**
* @param {Node} newChild A child node to be inserted
* @param {Node} oldChild A child node to be replaced
* @return {Node} The old child node that was removed
*/
replaceChild(newChild: Node, oldChild: Node): Node;
/**
* @param {Node} child Child node to be removed
* @return {Node} The old child node that was removed
*/
removeChild(child: Node): Node;
/**
* @param {Node} child A child node whose index in childNodes is desired
* @return {number} The index of the child in childNodes, or null if not found
*/
childIndex(child: Node): number;
/**
* Make a deep copy of the node (but with no parent).
*/
copy(): Node;
/**
* @param {string} kind The kind of nodes to be located in the tree
* @return {Node[]} An array of nodes that are children (at any depth) of the given kind
*/
findNodes(kind: string): Node[];
/**
* @param {Function} func A function to apply to each node in the tree rooted at this node
* @param {any} data Data to pass to the function (as state information)
*/
walkTree(func: (node: Node, data?: any) => void, data?: any): void;
}
/*********************************************************/
/**
* The generic Node class interface
*/
export interface NodeClass {
/**
* @param {NodeFactory} factory The NodeFactory to use to create new nodes when needed
* @param {PropertyList} properties Any properties to be added to the node, if any
* @param {Node[]} children The initial child nodes, if any
* @return {Node} The newly created node
*/
new (factory: NodeFactory<Node, NodeClass>, properties?: PropertyList, children?: Node[]): Node;
}
/*********************************************************/
/**
* The abstract Node class
*/
export abstract class AbstractNode implements Node {
/**
* The parent node for this one
*/
public parent: Node = null;
/**
* The properties for this node
*/
protected properties: PropertyList = {};
/**
* The children for this node
*/
public childNodes: Node[] = [];
/**
* @param {NodeFactory} factory The NodeFactory to use to create new nodes when needed
* @param {PropertyList} properties Any properties to be added to the node, if any
* @param {Node[]} children The initial child nodes, if any
*
* @constructor
* @implements {Node}
*/
constructor(readonly factory: NodeFactory<Node, NodeClass>, properties: PropertyList = {}, children: Node[] = []) {
for (const name of Object.keys(properties)) {
this.setProperty(name, properties[name]);
}
if (children.length) {
this.setChildren(children);
}
}
/**
* @override
*/
public get kind() {
return 'unknown';
}
/**
* @override
*/
public setProperty(name: string, value: Property) {
this.properties[name] = value;
}
/**
* @override
*/
public getProperty(name: string) {
return this.properties[name];
}
/**
* @override
*/
public getPropertyNames() {
return Object.keys(this.properties);
}
/**
* @override
*/
public getAllProperties() {
return this.properties;
}
/**
* @override
*/
public removeProperty(...names: string[]) {
for (const name of names) {
delete this.properties[name];
}
}
/**
* @override
*/
public isKind(kind: string): boolean {
return this.factory.nodeIsKind(this, kind);
}
/**
* @override
*/
public setChildren(children: Node[]) {
this.childNodes = [];
for (let child of children) {
this.appendChild(child);
}
}
/**
* @override
*/
public appendChild(child: Node) {
this.childNodes.push(child);
child.parent = this;
return child;
}
/**
* @override
*/
public replaceChild(newChild: Node, oldChild: Node) {
let i = this.childIndex(oldChild);
// If i === null should we error? return null? silently fail?
if (i !== null) {
this.childNodes[i] = newChild;
newChild.parent = this;
oldChild.parent = null;
}
return newChild;
}
/**
* @override
*/
public removeChild(child: Node) {
const i = this.childIndex(child);
if (i !== null) {
this.childNodes.splice(i, 1);
child.parent = null;
}
return child;
}
/**
* @override
*/
public childIndex(node: Node) {
let i = this.childNodes.indexOf(node);
return (i === -1 ? null : i);
}
/**
* @override
*/
public copy() {
const node = (this as AbstractNode).factory.create(this.kind) as AbstractNode;
node.properties = {...this.properties};
for (const child of this.childNodes || []) {
if (child) {
node.appendChild(child.copy());
}
}
return node;
}
/**
* @override
*/
public findNodes(kind: string) {
let nodes: Node[] = [];
this.walkTree((node: Node) => {
if (node.isKind(kind)) {
nodes.push(node);
}
});
return nodes;
}
/**
* @override
*/
public walkTree(func: (node: Node, data?: any) => void, data?: any) {
func(this, data);
for (const child of this.childNodes) {
if (child) {
child.walkTree(func, data);
}
}
return data;
}
/**
* Simple string version for debugging, just to get the structure.
*/
public toString() {
return this.kind + '(' + this.childNodes.join(',') + ')';
}
}
/*********************************************************/
/**
* The abstract EmptyNode class
*/
export abstract class AbstractEmptyNode extends AbstractNode {
/**
* We don't have children, so ignore these methods
*/
/**
* @override
*/
public setChildren(_children: Node[]) {
}
/**
* @override
*/
public appendChild(child: Node) {
return child;
}
/**
* @override
*/
public replaceChild(_newChild: Node, oldChild: Node) {
return oldChild;
}
/**
* @override
*/
public childIndex(_node: Node) {
return null as number;
}
/**
* Don't step into children (there aren't any)
*
* @override
*/
public walkTree(func: (node: Node, data?: any) => void, data?: any) {
func(this, data);
return data;
}
/**
* Simple string version for debugging, just to get the structure.
*/
public toString() {
return this.kind;
}
}

59
node_modules/mathjax-full/ts/core/Tree/NodeFactory.ts generated vendored Normal file
View File

@@ -0,0 +1,59 @@
/*************************************************************
*
* 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 The generic NodeFactory class for creating Node objects
*
* @author dpvc@mathjax.org (Davide Cervone)
*/
import {Node, PropertyList} from './Node.js';
import {Factory, FactoryNodeClass, AbstractFactory} from './Factory.js';
/*****************************************************************/
/**
* The NodeFactory interface
*
* @template N The node type created by the factory
* @template C The class of the node being constructed (for access to static properties)
*/
export interface NodeFactory<N extends Node, C extends FactoryNodeClass<N>> extends Factory<N, C> {
/**
* @param {string} kind The kind of node to create
* @param {PropertyList} properties The list of initial properties for the node (if any)
* @param {N[]} children The array of initial child nodes (if any)
* @return {N} The newly created node of the given kind
*/
create(kind: string, properties?: PropertyList, children?: N[]): N;
}
/*****************************************************************/
/**
* The generic NodeFactory class
*
* @template N The node type created by the factory
* @template C The class of the node being constructed (for access to static properties)
*/
export abstract class AbstractNodeFactory<N extends Node, C extends FactoryNodeClass<N>> extends AbstractFactory<N, C> {
/**
* @override
*/
public create(kind: string, properties: PropertyList = {}, children: N[] = []) {
return this.node[kind](properties, children);
}
}

166
node_modules/mathjax-full/ts/core/Tree/Visitor.ts generated vendored Normal file
View File

@@ -0,0 +1,166 @@
/*************************************************************
*
* 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 The generic visitor class for node trees
*
* @author dpvc@mathjax.org (Davide Cervone)
*/
import {Node, NodeClass, AbstractNode} from './Node.js';
import {NodeFactory} from './NodeFactory.js';
/**
* The type for the functions associated with each node class
*/
export type VisitorFunction = (visitor: NodeFactory<Node, NodeClass>, node: Node, ...args: any[]) => any;
/*****************************************************************/
/**
* Implements the Visitor interface
*/
export interface Visitor {
/**
* Visit the tree rooted at the given node (passing along any needed parameters)
*
* @param {Node} tree The node that is the root of the tree
* @param {any[]} args The arguments to pass to the visitNode functions
* @return {any} Whatever the visitNode function returns for the root tree node
*/
visitTree(tree: Node, ...args: any[]): any;
/**
* Visit a node by calling the visitor function for the given type of node
* (passing along any needed parameters)
*
* @param {Node} node The node to visit
* @param {any[]} args The arguments to pass to the visitor function for this node
* @return {any} Whatever the visitor function returns for this node
*/
visitNode(node: Node, ...args: any[]): any;
/**
* The default visitor function for when no node-specific function is defined
*
* @param {Node} node The node to visit
* @param {any[]} args The arguments to pass to the visitor function for this node
* @return {any} Whatever the visitor function returns for this node
*/
visitDefault(node: Node, ...args: any[]): any;
/**
* Define a visitor function for a given node kind
*
* @param {string} kind The node kind for which the handler is being defined
* @param {VisitorFunction} handler The function to call to handle nodes of this kind
*/
setNodeHandler(kind: string, handler: VisitorFunction): void;
/**
* Remove the visitor function for a given node kind
*
* @param {string} kind The node kind whose visitor function is to be removed
*/
removeNodeHandler(kind: string): void;
/**
* The various visitor functions implemented by the subclasses, and any data they need
*/
[property: string]: any;
}
/*****************************************************************/
/**
* Implements the generic Visitor object
*/
export abstract class AbstractVisitor implements Visitor {
/**
* Holds the mapping from node kinds to visitor funcitons
*/
protected nodeHandlers: Map<string, VisitorFunction> = new Map();
/**
* Visitor functions are named "visitKindNode" where "Kind" is replaced by
* the node kind; e.g., visitTextNode for kind = text.
*
* @param {string} kind The node kind whose method name is needed
* @return {string} The name of the visitor method for the given node kind
*/
protected static methodName(kind: string): string {
return 'visit' + (kind.charAt(0).toUpperCase() + kind.substr(1)).replace(/[^a-z0-9_]/ig, '_') + 'Node';
}
/**
* Create the node handler map by looking for methods with the correct names
* based on the node kinds available from the factory.
*
* @constructor
* @param {NodeFactory} factory The node factory for the kinds of nodes this visitor handles
*/
constructor(factory: NodeFactory<Node, NodeClass>) {
for (const kind of factory.getKinds()) {
let method = (this as Visitor)[AbstractVisitor.methodName(kind)] as VisitorFunction;
if (method) {
this.nodeHandlers.set(kind, method);
}
}
}
/**
* @override
*/
public visitTree(tree: Node, ...args: any[]) {
return this.visitNode(tree, ...args);
}
/**
* @override
*/
public visitNode(node: Node, ...args: any[]) {
let handler = this.nodeHandlers.get(node.kind) || this.visitDefault;
return handler.call(this, node, ...args);
}
/**
* @override
*/
public visitDefault(node: Node, ...args: any[]) {
if (node instanceof AbstractNode) {
for (const child of node.childNodes) {
this.visitNode(child, ...args);
}
}
}
/**
* @override
*/
public setNodeHandler(kind: string, handler: VisitorFunction) {
this.nodeHandlers.set(kind, handler);
}
/**
* @override
*/
public removeNodeHandler(kind: string) {
this.nodeHandlers.delete(kind);
}
}

109
node_modules/mathjax-full/ts/core/Tree/Wrapper.ts generated vendored Normal file
View File

@@ -0,0 +1,109 @@
/*************************************************************
*
* 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 Generic Wrapper class for adding methods to a Node class for visitors
*
* @author dpvc@mathjax.org (Davide Cervone)
*/
import {Node} from './Node.js';
import {WrapperFactory} from './WrapperFactory.js';
/*********************************************************/
/**
* The Wrapper interface
*
* It points to a Node object. Subclasses add methods for the visitor to call.
*
* @template N The Node type being wrapped
* @template W The Wrapper type being produced
*/
export interface Wrapper<N extends Node, W extends Wrapper<N, W>> {
node: N;
readonly kind: string;
/**
* @param {Node} node A node to be wrapped
* @param {any[]} args Any additional arguments needed when creating the wrapper
* @return {Wrapper} The wrapped node
*/
wrap(node: N, ...args: any[]): W;
}
/*********************************************************/
/**
* The Wrapper class interface
*
* @template N The Node type being wrapped
* @template W The Wrapper type being produced
*/
export interface WrapperClass<N extends Node, W extends Wrapper<N, W>> {
/**
* @param {WrapperFactory} factory The factory used to create more wrappers
* @param {N} node The node to be wrapped
* @param {any[]} args Any additional arguments needed when creating the wrapper
* @return {W} The wrapped node
*/
new(factory: WrapperFactory<N, W, WrapperClass<N, W>>, node: N, ...args: any[]): W;
}
/*********************************************************/
/**
* The abstract Wrapper class
*
* @template N The Node type being created by the factory
* @template W The Wrapper type being produced
*/
export class AbstractWrapper<N extends Node, W extends Wrapper<N, W>> implements Wrapper<N, W> {
/**
* The Node object associated with this instance
*/
public node: N;
/**
* The WrapperFactory to use to wrap child nodes, as needed
*/
protected factory: WrapperFactory<N, W, WrapperClass<N, W>>;
/**
* The kind of this wrapper
*/
get kind() {
return this.node.kind;
}
/**
* @param {WrapperFactory} factory The WrapperFactory to use to wrap child nodes when needed
* @param {Node} node The node to wrap
*
* @constructor
* @implements {Wrapper}
*/
constructor(factory: WrapperFactory<N, W, WrapperClass<N, W>>, node: N) {
this.factory = factory;
this.node = node;
}
/**
* @override
*/
public wrap(node: N) {
return this.factory.wrap(node);
}
}

View File

@@ -0,0 +1,64 @@
/*************************************************************
*
* 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 Generic WrapperFactory class for creating Wrapper objects
*
* @author dpvc@mathjax.org (Davide Cervone)
*/
import {Node} from './Node.js';
import {Wrapper, WrapperClass} from './Wrapper.js';
import {Factory, AbstractFactory} from './Factory.js';
/*****************************************************************/
/**
* The generic WrapperFactory class
*
* @template N The Node type being created by the factory
* @template W The Wrapper type being produced (instance type)
* @template C The Wrapper class (for static values)
*/
export interface WrapperFactory<N extends Node, W extends Wrapper<N, W>, C extends WrapperClass<N, W>>
extends Factory<W, C> {
/**
* @param {N} node The node to be wrapped
* @param {any[]} args Any additional arguments needed when wrapping the node
* @return {W} The newly wrapped node
*/
wrap(node: N, ...args: any[]): W;
}
/*****************************************************************/
/**
* The generic WrapperFactory class
*
* @template N The Node type being created by the factory
* @template W The Wrapper type being produced (instance type)
* @template C The Wrapper class (for static values)
*/
export abstract class AbstractWrapperFactory<N extends Node, W extends Wrapper<N, W>, C extends WrapperClass<N, W>>
extends AbstractFactory<W, C> implements WrapperFactory<N, W, C> {
/**
* @param {N} node The node to be wrapped
* @param {any[]} args Any additional arguments needed when wrapping the node
* @return {W} The newly wrapped node
*/
public wrap(node: N, ...args: any[]): W {
return this.create(node.kind, node, ...args);
}
}