add initial marp implementation with sample content and build configuration
This commit is contained in:
33
node_modules/mathjax-full/js/a11y/complexity/collapse.d.ts
generated
vendored
Normal file
33
node_modules/mathjax-full/js/a11y/complexity/collapse.d.ts
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
import { MmlNode } from '../../core/MmlTree/MmlNode.js';
|
||||
import { ComplexityVisitor } from './visitor.js';
|
||||
export declare type CollapseFunction = (node: MmlNode, complexity: number) => number;
|
||||
export declare type CollapseFunctionMap = Map<string, CollapseFunction>;
|
||||
export declare type TypeRole<T> = {
|
||||
[type: string]: T | {
|
||||
[role: string]: T;
|
||||
};
|
||||
};
|
||||
export declare class Collapse {
|
||||
static NOCOLLAPSE: number;
|
||||
complexity: ComplexityVisitor;
|
||||
cutoff: TypeRole<number>;
|
||||
marker: TypeRole<string>;
|
||||
collapse: CollapseFunctionMap;
|
||||
private idCount;
|
||||
constructor(visitor: ComplexityVisitor);
|
||||
check(node: MmlNode, complexity: number): number;
|
||||
protected defaultCheck(node: MmlNode, complexity: number, type: string): number;
|
||||
protected recordCollapse(node: MmlNode, complexity: number, text: string): number;
|
||||
protected unrecordCollapse(node: MmlNode): void;
|
||||
protected canUncollapse(node: MmlNode, n: number, m?: number): MmlNode | null;
|
||||
protected uncollapseChild(complexity: number, node: MmlNode, n: number, m?: number): number;
|
||||
protected splitAttribute(node: MmlNode, id: string): string[];
|
||||
protected getText(node: MmlNode): string;
|
||||
protected findChildText(node: MmlNode, id: string): string;
|
||||
protected findChild(node: MmlNode, id: string): MmlNode | null;
|
||||
makeCollapse(node: MmlNode): void;
|
||||
makeActions(nodes: MmlNode[]): void;
|
||||
private makeId;
|
||||
makeAction(node: MmlNode): void;
|
||||
addMrow(node: MmlNode): MmlNode;
|
||||
}
|
||||
363
node_modules/mathjax-full/js/a11y/complexity/collapse.js
generated
vendored
Normal file
363
node_modules/mathjax-full/js/a11y/complexity/collapse.js
generated
vendored
Normal file
@@ -0,0 +1,363 @@
|
||||
"use strict";
|
||||
var __values = (this && this.__values) || function(o) {
|
||||
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
||||
if (m) return m.call(o);
|
||||
if (o && typeof o.length === "number") return {
|
||||
next: function () {
|
||||
if (o && i >= o.length) o = void 0;
|
||||
return { value: o && o[i++], done: !o };
|
||||
}
|
||||
};
|
||||
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Collapse = void 0;
|
||||
var Collapse = (function () {
|
||||
function Collapse(visitor) {
|
||||
var _this = this;
|
||||
this.cutoff = {
|
||||
identifier: 3,
|
||||
number: 3,
|
||||
text: 10,
|
||||
infixop: 15,
|
||||
relseq: 15,
|
||||
multirel: 15,
|
||||
fenced: 18,
|
||||
bigop: 20,
|
||||
integral: 20,
|
||||
fraction: 12,
|
||||
sqrt: 9,
|
||||
root: 12,
|
||||
vector: 15,
|
||||
matrix: 15,
|
||||
cases: 15,
|
||||
superscript: 9,
|
||||
subscript: 9,
|
||||
subsup: 9,
|
||||
punctuated: {
|
||||
endpunct: Collapse.NOCOLLAPSE,
|
||||
startpunct: Collapse.NOCOLLAPSE,
|
||||
value: 12
|
||||
}
|
||||
};
|
||||
this.marker = {
|
||||
identifier: 'x',
|
||||
number: '#',
|
||||
text: '...',
|
||||
appl: {
|
||||
'limit function': 'lim',
|
||||
value: 'f()'
|
||||
},
|
||||
fraction: '/',
|
||||
sqrt: '\u221A',
|
||||
root: '\u221A',
|
||||
superscript: '\u25FD\u02D9',
|
||||
subscript: '\u25FD.',
|
||||
subsup: '\u25FD:',
|
||||
vector: {
|
||||
binomial: '(:)',
|
||||
determinant: '|:|',
|
||||
value: '\u27E8:\u27E9'
|
||||
},
|
||||
matrix: {
|
||||
squarematrix: '[::]',
|
||||
rowvector: '\u27E8\u22EF\u27E9',
|
||||
columnvector: '\u27E8\u22EE\u27E9',
|
||||
determinant: '|::|',
|
||||
value: '(::)'
|
||||
},
|
||||
cases: '{:',
|
||||
infixop: {
|
||||
addition: '+',
|
||||
subtraction: '\u2212',
|
||||
multiplication: '\u22C5',
|
||||
implicit: '\u22C5',
|
||||
value: '+'
|
||||
},
|
||||
punctuated: {
|
||||
text: '...',
|
||||
value: ','
|
||||
}
|
||||
};
|
||||
this.collapse = new Map([
|
||||
['fenced', function (node, complexity) {
|
||||
complexity = _this.uncollapseChild(complexity, node, 1);
|
||||
if (complexity > _this.cutoff.fenced && node.attributes.get('data-semantic-role') === 'leftright') {
|
||||
complexity = _this.recordCollapse(node, complexity, _this.getText(node.childNodes[0]) +
|
||||
_this.getText(node.childNodes[node.childNodes.length - 1]));
|
||||
}
|
||||
return complexity;
|
||||
}],
|
||||
['appl', function (node, complexity) {
|
||||
if (_this.canUncollapse(node, 2, 2)) {
|
||||
complexity = _this.complexity.visitNode(node, false);
|
||||
var marker = _this.marker.appl;
|
||||
var text = marker[node.attributes.get('data-semantic-role')] || marker.value;
|
||||
complexity = _this.recordCollapse(node, complexity, text);
|
||||
}
|
||||
return complexity;
|
||||
}],
|
||||
['sqrt', function (node, complexity) {
|
||||
complexity = _this.uncollapseChild(complexity, node, 0);
|
||||
if (complexity > _this.cutoff.sqrt) {
|
||||
complexity = _this.recordCollapse(node, complexity, _this.marker.sqrt);
|
||||
}
|
||||
return complexity;
|
||||
}],
|
||||
['root', function (node, complexity) {
|
||||
complexity = _this.uncollapseChild(complexity, node, 0, 2);
|
||||
if (complexity > _this.cutoff.sqrt) {
|
||||
complexity = _this.recordCollapse(node, complexity, _this.marker.sqrt);
|
||||
}
|
||||
return complexity;
|
||||
}],
|
||||
['enclose', function (node, complexity) {
|
||||
if (_this.splitAttribute(node, 'children').length === 1) {
|
||||
var child = _this.canUncollapse(node, 1);
|
||||
if (child) {
|
||||
var marker = child.getProperty('collapse-marker');
|
||||
_this.unrecordCollapse(child);
|
||||
complexity = _this.recordCollapse(node, _this.complexity.visitNode(node, false), marker);
|
||||
}
|
||||
}
|
||||
return complexity;
|
||||
}],
|
||||
['bigop', function (node, complexity) {
|
||||
if (complexity > _this.cutoff.bigop || !node.isKind('mo')) {
|
||||
var id = _this.splitAttribute(node, 'content').pop();
|
||||
var op = _this.findChildText(node, id);
|
||||
complexity = _this.recordCollapse(node, complexity, op);
|
||||
}
|
||||
return complexity;
|
||||
}],
|
||||
['integral', function (node, complexity) {
|
||||
if (complexity > _this.cutoff.integral || !node.isKind('mo')) {
|
||||
var id = _this.splitAttribute(node, 'content').pop();
|
||||
var op = _this.findChildText(node, id);
|
||||
complexity = _this.recordCollapse(node, complexity, op);
|
||||
}
|
||||
return complexity;
|
||||
}],
|
||||
['relseq', function (node, complexity) {
|
||||
if (complexity > _this.cutoff.relseq) {
|
||||
var id = _this.splitAttribute(node, 'content')[0];
|
||||
var text = _this.findChildText(node, id);
|
||||
complexity = _this.recordCollapse(node, complexity, text);
|
||||
}
|
||||
return complexity;
|
||||
}],
|
||||
['multirel', function (node, complexity) {
|
||||
if (complexity > _this.cutoff.relseq) {
|
||||
var id = _this.splitAttribute(node, 'content')[0];
|
||||
var text = _this.findChildText(node, id) + '\u22EF';
|
||||
complexity = _this.recordCollapse(node, complexity, text);
|
||||
}
|
||||
return complexity;
|
||||
}],
|
||||
['superscript', function (node, complexity) {
|
||||
complexity = _this.uncollapseChild(complexity, node, 0, 2);
|
||||
if (complexity > _this.cutoff.superscript) {
|
||||
complexity = _this.recordCollapse(node, complexity, _this.marker.superscript);
|
||||
}
|
||||
return complexity;
|
||||
}],
|
||||
['subscript', function (node, complexity) {
|
||||
complexity = _this.uncollapseChild(complexity, node, 0, 2);
|
||||
if (complexity > _this.cutoff.subscript) {
|
||||
complexity = _this.recordCollapse(node, complexity, _this.marker.subscript);
|
||||
}
|
||||
return complexity;
|
||||
}],
|
||||
['subsup', function (node, complexity) {
|
||||
complexity = _this.uncollapseChild(complexity, node, 0, 3);
|
||||
if (complexity > _this.cutoff.subsup) {
|
||||
complexity = _this.recordCollapse(node, complexity, _this.marker.subsup);
|
||||
}
|
||||
return complexity;
|
||||
}]
|
||||
]);
|
||||
this.idCount = 0;
|
||||
this.complexity = visitor;
|
||||
}
|
||||
Collapse.prototype.check = function (node, complexity) {
|
||||
var type = node.attributes.get('data-semantic-type');
|
||||
if (this.collapse.has(type)) {
|
||||
return this.collapse.get(type).call(this, node, complexity);
|
||||
}
|
||||
if (this.cutoff.hasOwnProperty(type)) {
|
||||
return this.defaultCheck(node, complexity, type);
|
||||
}
|
||||
return complexity;
|
||||
};
|
||||
Collapse.prototype.defaultCheck = function (node, complexity, type) {
|
||||
var role = node.attributes.get('data-semantic-role');
|
||||
var check = this.cutoff[type];
|
||||
var cutoff = (typeof check === 'number' ? check : check[role] || check.value);
|
||||
if (complexity > cutoff) {
|
||||
var marker = this.marker[type] || '??';
|
||||
var text = (typeof marker === 'string' ? marker : marker[role] || marker.value);
|
||||
complexity = this.recordCollapse(node, complexity, text);
|
||||
}
|
||||
return complexity;
|
||||
};
|
||||
Collapse.prototype.recordCollapse = function (node, complexity, text) {
|
||||
text = '\u25C2' + text + '\u25B8';
|
||||
node.setProperty('collapse-marker', text);
|
||||
node.setProperty('collapse-complexity', complexity);
|
||||
return text.length * this.complexity.complexity.text;
|
||||
};
|
||||
Collapse.prototype.unrecordCollapse = function (node) {
|
||||
var complexity = node.getProperty('collapse-complexity');
|
||||
if (complexity != null) {
|
||||
node.attributes.set('data-semantic-complexity', complexity);
|
||||
node.removeProperty('collapse-complexity');
|
||||
node.removeProperty('collapse-marker');
|
||||
}
|
||||
};
|
||||
Collapse.prototype.canUncollapse = function (node, n, m) {
|
||||
if (m === void 0) { m = 1; }
|
||||
if (this.splitAttribute(node, 'children').length === m) {
|
||||
var mml = (node.childNodes.length === 1 &&
|
||||
node.childNodes[0].isInferred ? node.childNodes[0] : node);
|
||||
if (mml && mml.childNodes[n]) {
|
||||
var child = mml.childNodes[n];
|
||||
if (child.getProperty('collapse-marker')) {
|
||||
return child;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
Collapse.prototype.uncollapseChild = function (complexity, node, n, m) {
|
||||
if (m === void 0) { m = 1; }
|
||||
var child = this.canUncollapse(node, n, m);
|
||||
if (child) {
|
||||
this.unrecordCollapse(child);
|
||||
if (child.parent !== node) {
|
||||
child.parent.attributes.set('data-semantic-complexity', undefined);
|
||||
}
|
||||
complexity = this.complexity.visitNode(node, false);
|
||||
}
|
||||
return complexity;
|
||||
};
|
||||
Collapse.prototype.splitAttribute = function (node, id) {
|
||||
return (node.attributes.get('data-semantic-' + id) || '').split(/,/);
|
||||
};
|
||||
Collapse.prototype.getText = function (node) {
|
||||
var _this = this;
|
||||
if (node.isToken)
|
||||
return node.getText();
|
||||
return node.childNodes.map(function (n) { return _this.getText(n); }).join('');
|
||||
};
|
||||
Collapse.prototype.findChildText = function (node, id) {
|
||||
var child = this.findChild(node, id);
|
||||
return this.getText(child.coreMO() || child);
|
||||
};
|
||||
Collapse.prototype.findChild = function (node, id) {
|
||||
var e_1, _a;
|
||||
if (!node || node.attributes.get('data-semantic-id') === id)
|
||||
return node;
|
||||
if (!node.isToken) {
|
||||
try {
|
||||
for (var _b = __values(node.childNodes), _c = _b.next(); !_c.done; _c = _b.next()) {
|
||||
var mml = _c.value;
|
||||
var child = this.findChild(mml, id);
|
||||
if (child)
|
||||
return child;
|
||||
}
|
||||
}
|
||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||
finally {
|
||||
try {
|
||||
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
||||
}
|
||||
finally { if (e_1) throw e_1.error; }
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
Collapse.prototype.makeCollapse = function (node) {
|
||||
var nodes = [];
|
||||
node.walkTree(function (child) {
|
||||
if (child.getProperty('collapse-marker')) {
|
||||
nodes.push(child);
|
||||
}
|
||||
});
|
||||
this.makeActions(nodes);
|
||||
};
|
||||
Collapse.prototype.makeActions = function (nodes) {
|
||||
var e_2, _a;
|
||||
try {
|
||||
for (var nodes_1 = __values(nodes), nodes_1_1 = nodes_1.next(); !nodes_1_1.done; nodes_1_1 = nodes_1.next()) {
|
||||
var node = nodes_1_1.value;
|
||||
this.makeAction(node);
|
||||
}
|
||||
}
|
||||
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
||||
finally {
|
||||
try {
|
||||
if (nodes_1_1 && !nodes_1_1.done && (_a = nodes_1.return)) _a.call(nodes_1);
|
||||
}
|
||||
finally { if (e_2) throw e_2.error; }
|
||||
}
|
||||
};
|
||||
Collapse.prototype.makeId = function () {
|
||||
return 'mjx-collapse-' + this.idCount++;
|
||||
};
|
||||
Collapse.prototype.makeAction = function (node) {
|
||||
if (node.isKind('math')) {
|
||||
node = this.addMrow(node);
|
||||
}
|
||||
var factory = this.complexity.factory;
|
||||
var marker = node.getProperty('collapse-marker');
|
||||
var parent = node.parent;
|
||||
var maction = factory.create('maction', {
|
||||
actiontype: 'toggle',
|
||||
selection: 2,
|
||||
'data-collapsible': true,
|
||||
id: this.makeId(),
|
||||
'data-semantic-complexity': node.attributes.get('data-semantic-complexity')
|
||||
}, [
|
||||
factory.create('mtext', { mathcolor: 'blue' }, [
|
||||
factory.create('text').setText(marker)
|
||||
])
|
||||
]);
|
||||
maction.inheritAttributesFrom(node);
|
||||
node.attributes.set('data-semantic-complexity', node.getProperty('collapse-complexity'));
|
||||
node.removeProperty('collapse-marker');
|
||||
node.removeProperty('collapse-complexity');
|
||||
parent.replaceChild(maction, node);
|
||||
maction.appendChild(node);
|
||||
};
|
||||
Collapse.prototype.addMrow = function (node) {
|
||||
var e_3, _a;
|
||||
var mrow = this.complexity.factory.create('mrow', null, node.childNodes[0].childNodes);
|
||||
node.childNodes[0].setChildren([mrow]);
|
||||
var attributes = node.attributes.getAllAttributes();
|
||||
try {
|
||||
for (var _b = __values(Object.keys(attributes)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
||||
var name_1 = _c.value;
|
||||
if (name_1.substr(0, 14) === 'data-semantic-') {
|
||||
mrow.attributes.set(name_1, attributes[name_1]);
|
||||
delete attributes[name_1];
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
||||
finally {
|
||||
try {
|
||||
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
||||
}
|
||||
finally { if (e_3) throw e_3.error; }
|
||||
}
|
||||
mrow.setProperty('collapse-marker', node.getProperty('collapse-marker'));
|
||||
mrow.setProperty('collapse-complexity', node.getProperty('collapse-complexity'));
|
||||
node.removeProperty('collapse-marker');
|
||||
node.removeProperty('collapse-complexity');
|
||||
return mrow;
|
||||
};
|
||||
Collapse.NOCOLLAPSE = 10000000;
|
||||
return Collapse;
|
||||
}());
|
||||
exports.Collapse = Collapse;
|
||||
//# sourceMappingURL=collapse.js.map
|
||||
1
node_modules/mathjax-full/js/a11y/complexity/collapse.js.map
generated
vendored
Normal file
1
node_modules/mathjax-full/js/a11y/complexity/collapse.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
42
node_modules/mathjax-full/js/a11y/complexity/visitor.d.ts
generated
vendored
Normal file
42
node_modules/mathjax-full/js/a11y/complexity/visitor.d.ts
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
import { MmlNode } from '../../core/MmlTree/MmlNode.js';
|
||||
import { MmlMroot } from '../../core/MmlTree/MmlNodes/mroot.js';
|
||||
import { MmlMaction } from '../../core/MmlTree/MmlNodes/maction.js';
|
||||
import { MmlMsubsup, MmlMsub, MmlMsup } from '../../core/MmlTree/MmlNodes/msubsup.js';
|
||||
import { MmlMunderover, MmlMunder, MmlMover } from '../../core/MmlTree/MmlNodes/munderover.js';
|
||||
import { MmlVisitor } from '../../core/MmlTree/MmlVisitor.js';
|
||||
import { MmlFactory } from '../../core/MmlTree/MmlFactory.js';
|
||||
import { Collapse } from './collapse.js';
|
||||
import { OptionList } from '../../util/Options.js';
|
||||
export declare class ComplexityVisitor extends MmlVisitor {
|
||||
static OPTIONS: OptionList;
|
||||
complexity: {
|
||||
[name: string]: number;
|
||||
};
|
||||
collapse: Collapse;
|
||||
factory: MmlFactory;
|
||||
options: OptionList;
|
||||
constructor(factory: MmlFactory, options: OptionList);
|
||||
visitTree(node: MmlNode): void;
|
||||
visitNode(node: MmlNode, save: boolean): any;
|
||||
visitDefault(node: MmlNode, save: boolean): number;
|
||||
protected visitMfracNode(node: MmlNode, save: boolean): number;
|
||||
protected visitMsqrtNode(node: MmlNode, save: boolean): number;
|
||||
protected visitMrootNode(node: MmlMroot, save: boolean): number;
|
||||
protected visitMphantomNode(node: MmlNode, save: boolean): number;
|
||||
protected visitMsNode(node: MmlNode, save: boolean): number;
|
||||
protected visitMsubsupNode(node: MmlMsubsup, save: boolean): number;
|
||||
protected visitMsubNode(node: MmlMsub, save: boolean): number;
|
||||
protected visitMsupNode(node: MmlMsup, save: boolean): number;
|
||||
protected visitMunderoverNode(node: MmlMunderover, save: boolean): number;
|
||||
protected visitMunderNode(node: MmlMunder, save: boolean): number;
|
||||
protected visitMoverNode(node: MmlMover, save: boolean): number;
|
||||
protected visitMencloseNode(node: MmlNode, save: boolean): number;
|
||||
protected visitMactionNode(node: MmlMaction, save: boolean): number;
|
||||
protected visitMsemanticsNode(node: MmlNode, save: boolean): number;
|
||||
protected visitAnnotationNode(node: MmlNode, save: boolean): number;
|
||||
protected visitAnnotation_xmlNode(node: MmlNode, save: boolean): number;
|
||||
protected visitMglyphNode(node: MmlNode, save: boolean): number;
|
||||
getComplexity(node: MmlNode): number;
|
||||
protected setComplexity(node: MmlNode, complexity: number, save: boolean): number;
|
||||
protected childrenComplexity(node: MmlNode): number;
|
||||
}
|
||||
209
node_modules/mathjax-full/js/a11y/complexity/visitor.js
generated
vendored
Normal file
209
node_modules/mathjax-full/js/a11y/complexity/visitor.js
generated
vendored
Normal file
@@ -0,0 +1,209 @@
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
if (typeof b !== "function" && b !== null)
|
||||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
var __values = (this && this.__values) || function(o) {
|
||||
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
||||
if (m) return m.call(o);
|
||||
if (o && typeof o.length === "number") return {
|
||||
next: function () {
|
||||
if (o && i >= o.length) o = void 0;
|
||||
return { value: o && o[i++], done: !o };
|
||||
}
|
||||
};
|
||||
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ComplexityVisitor = void 0;
|
||||
var MmlVisitor_js_1 = require("../../core/MmlTree/MmlVisitor.js");
|
||||
var collapse_js_1 = require("./collapse.js");
|
||||
var Options_js_1 = require("../../util/Options.js");
|
||||
var ComplexityVisitor = (function (_super) {
|
||||
__extends(ComplexityVisitor, _super);
|
||||
function ComplexityVisitor(factory, options) {
|
||||
var _this = _super.call(this, factory) || this;
|
||||
_this.complexity = {
|
||||
text: .5,
|
||||
token: .5,
|
||||
child: 1,
|
||||
script: .8,
|
||||
sqrt: 2,
|
||||
subsup: 2,
|
||||
underover: 2,
|
||||
fraction: 2,
|
||||
enclose: 2,
|
||||
action: 2,
|
||||
phantom: 0,
|
||||
xml: 2,
|
||||
glyph: 2
|
||||
};
|
||||
var CLASS = _this.constructor;
|
||||
_this.options = (0, Options_js_1.userOptions)((0, Options_js_1.defaultOptions)({}, CLASS.OPTIONS), options);
|
||||
_this.collapse = new _this.options.Collapse(_this);
|
||||
_this.factory = factory;
|
||||
return _this;
|
||||
}
|
||||
ComplexityVisitor.prototype.visitTree = function (node) {
|
||||
_super.prototype.visitTree.call(this, node, true);
|
||||
if (this.options.makeCollapsible) {
|
||||
this.collapse.makeCollapse(node);
|
||||
}
|
||||
};
|
||||
ComplexityVisitor.prototype.visitNode = function (node, save) {
|
||||
if (node.attributes.get('data-semantic-complexity'))
|
||||
return;
|
||||
return _super.prototype.visitNode.call(this, node, save);
|
||||
};
|
||||
ComplexityVisitor.prototype.visitDefault = function (node, save) {
|
||||
var complexity;
|
||||
if (node.isToken) {
|
||||
var text = node.getText();
|
||||
complexity = this.complexity.text * text.length + this.complexity.token;
|
||||
}
|
||||
else {
|
||||
complexity = this.childrenComplexity(node);
|
||||
}
|
||||
return this.setComplexity(node, complexity, save);
|
||||
};
|
||||
ComplexityVisitor.prototype.visitMfracNode = function (node, save) {
|
||||
var complexity = this.childrenComplexity(node) * this.complexity.script + this.complexity.fraction;
|
||||
return this.setComplexity(node, complexity, save);
|
||||
};
|
||||
ComplexityVisitor.prototype.visitMsqrtNode = function (node, save) {
|
||||
var complexity = this.childrenComplexity(node) + this.complexity.sqrt;
|
||||
return this.setComplexity(node, complexity, save);
|
||||
};
|
||||
ComplexityVisitor.prototype.visitMrootNode = function (node, save) {
|
||||
var complexity = this.childrenComplexity(node) + this.complexity.sqrt
|
||||
- (1 - this.complexity.script) * this.getComplexity(node.childNodes[1]);
|
||||
return this.setComplexity(node, complexity, save);
|
||||
};
|
||||
ComplexityVisitor.prototype.visitMphantomNode = function (node, save) {
|
||||
return this.setComplexity(node, this.complexity.phantom, save);
|
||||
};
|
||||
ComplexityVisitor.prototype.visitMsNode = function (node, save) {
|
||||
var text = node.attributes.get('lquote')
|
||||
+ node.getText()
|
||||
+ node.attributes.get('rquote');
|
||||
var complexity = text.length * this.complexity.text;
|
||||
return this.setComplexity(node, complexity, save);
|
||||
};
|
||||
ComplexityVisitor.prototype.visitMsubsupNode = function (node, save) {
|
||||
_super.prototype.visitDefault.call(this, node, true);
|
||||
var sub = node.childNodes[node.sub];
|
||||
var sup = node.childNodes[node.sup];
|
||||
var base = node.childNodes[node.base];
|
||||
var complexity = Math.max(sub ? this.getComplexity(sub) : 0, sup ? this.getComplexity(sup) : 0) * this.complexity.script;
|
||||
complexity += this.complexity.child * ((sub ? 1 : 0) + (sup ? 1 : 0));
|
||||
complexity += (base ? this.getComplexity(base) + this.complexity.child : 0);
|
||||
complexity += this.complexity.subsup;
|
||||
return this.setComplexity(node, complexity, save);
|
||||
};
|
||||
ComplexityVisitor.prototype.visitMsubNode = function (node, save) {
|
||||
return this.visitMsubsupNode(node, save);
|
||||
};
|
||||
ComplexityVisitor.prototype.visitMsupNode = function (node, save) {
|
||||
return this.visitMsubsupNode(node, save);
|
||||
};
|
||||
ComplexityVisitor.prototype.visitMunderoverNode = function (node, save) {
|
||||
_super.prototype.visitDefault.call(this, node, true);
|
||||
var under = node.childNodes[node.under];
|
||||
var over = node.childNodes[node.over];
|
||||
var base = node.childNodes[node.base];
|
||||
var complexity = Math.max(under ? this.getComplexity(under) : 0, over ? this.getComplexity(over) : 0) * this.complexity.script;
|
||||
if (base) {
|
||||
complexity = Math.max(this.getComplexity(base), complexity);
|
||||
}
|
||||
complexity += this.complexity.child * ((under ? 1 : 0) + (over ? 1 : 0) + (base ? 1 : 0));
|
||||
complexity += this.complexity.underover;
|
||||
return this.setComplexity(node, complexity, save);
|
||||
};
|
||||
ComplexityVisitor.prototype.visitMunderNode = function (node, save) {
|
||||
return this.visitMunderoverNode(node, save);
|
||||
};
|
||||
ComplexityVisitor.prototype.visitMoverNode = function (node, save) {
|
||||
return this.visitMunderoverNode(node, save);
|
||||
};
|
||||
ComplexityVisitor.prototype.visitMencloseNode = function (node, save) {
|
||||
var complexity = this.childrenComplexity(node) + this.complexity.enclose;
|
||||
return this.setComplexity(node, complexity, save);
|
||||
};
|
||||
ComplexityVisitor.prototype.visitMactionNode = function (node, save) {
|
||||
this.childrenComplexity(node);
|
||||
var complexity = this.getComplexity(node.selected);
|
||||
return this.setComplexity(node, complexity, save);
|
||||
};
|
||||
ComplexityVisitor.prototype.visitMsemanticsNode = function (node, save) {
|
||||
var child = node.childNodes[0];
|
||||
var complexity = 0;
|
||||
if (child) {
|
||||
this.visitNode(child, true);
|
||||
complexity = this.getComplexity(child);
|
||||
}
|
||||
return this.setComplexity(node, complexity, save);
|
||||
};
|
||||
ComplexityVisitor.prototype.visitAnnotationNode = function (node, save) {
|
||||
return this.setComplexity(node, this.complexity.xml, save);
|
||||
};
|
||||
ComplexityVisitor.prototype.visitAnnotation_xmlNode = function (node, save) {
|
||||
return this.setComplexity(node, this.complexity.xml, save);
|
||||
};
|
||||
ComplexityVisitor.prototype.visitMglyphNode = function (node, save) {
|
||||
return this.setComplexity(node, this.complexity.glyph, save);
|
||||
};
|
||||
ComplexityVisitor.prototype.getComplexity = function (node) {
|
||||
var collapsed = node.getProperty('collapsedComplexity');
|
||||
return (collapsed != null ? collapsed : node.attributes.get('data-semantic-complexity'));
|
||||
};
|
||||
ComplexityVisitor.prototype.setComplexity = function (node, complexity, save) {
|
||||
if (save) {
|
||||
if (this.options.identifyCollapsible) {
|
||||
complexity = this.collapse.check(node, complexity);
|
||||
}
|
||||
node.attributes.set('data-semantic-complexity', complexity);
|
||||
}
|
||||
return complexity;
|
||||
};
|
||||
ComplexityVisitor.prototype.childrenComplexity = function (node) {
|
||||
var e_1, _a;
|
||||
_super.prototype.visitDefault.call(this, node, true);
|
||||
var complexity = 0;
|
||||
try {
|
||||
for (var _b = __values(node.childNodes), _c = _b.next(); !_c.done; _c = _b.next()) {
|
||||
var child = _c.value;
|
||||
complexity += this.getComplexity(child);
|
||||
}
|
||||
}
|
||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||
finally {
|
||||
try {
|
||||
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
||||
}
|
||||
finally { if (e_1) throw e_1.error; }
|
||||
}
|
||||
if (node.childNodes.length > 1) {
|
||||
complexity += node.childNodes.length * this.complexity.child;
|
||||
}
|
||||
return complexity;
|
||||
};
|
||||
ComplexityVisitor.OPTIONS = {
|
||||
identifyCollapsible: true,
|
||||
makeCollapsible: true,
|
||||
Collapse: collapse_js_1.Collapse
|
||||
};
|
||||
return ComplexityVisitor;
|
||||
}(MmlVisitor_js_1.MmlVisitor));
|
||||
exports.ComplexityVisitor = ComplexityVisitor;
|
||||
//# sourceMappingURL=visitor.js.map
|
||||
1
node_modules/mathjax-full/js/a11y/complexity/visitor.js.map
generated
vendored
Normal file
1
node_modules/mathjax-full/js/a11y/complexity/visitor.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user