@manuscripts/transform 2.1.4 → 2.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +0 -1
- package/dist/cjs/jats/importer/jats-body-dom-parser.js +27 -72
- package/dist/cjs/jats/importer/jats-parser-utils.js +6 -0
- package/dist/cjs/jats/jats-exporter.js +30 -38
- package/dist/cjs/schema/index.js +0 -1
- package/dist/cjs/schema/nodes/equation.js +12 -14
- package/dist/cjs/schema/nodes/equation_element.js +4 -5
- package/dist/cjs/schema/nodes/inline_equation.js +13 -15
- package/dist/cjs/transformer/builders.js +1 -8
- package/dist/cjs/transformer/decode.js +4 -7
- package/dist/cjs/transformer/encode.js +5 -25
- package/dist/cjs/transformer/node-types.js +0 -1
- package/dist/cjs/transformer/object-types.js +0 -1
- package/dist/es/index.js +0 -1
- package/dist/es/jats/importer/jats-body-dom-parser.js +28 -73
- package/dist/es/jats/importer/jats-parser-utils.js +6 -0
- package/dist/es/jats/jats-exporter.js +30 -38
- package/dist/es/schema/index.js +0 -1
- package/dist/es/schema/nodes/equation.js +12 -14
- package/dist/es/schema/nodes/equation_element.js +4 -5
- package/dist/es/schema/nodes/inline_equation.js +13 -15
- package/dist/es/transformer/builders.js +0 -6
- package/dist/es/transformer/decode.js +4 -7
- package/dist/es/transformer/encode.js +5 -25
- package/dist/es/transformer/node-types.js +0 -1
- package/dist/es/transformer/object-types.js +0 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/jats/jats-exporter.d.ts +1 -0
- package/dist/types/schema/index.d.ts +0 -1
- package/dist/types/schema/nodes/equation.d.ts +3 -4
- package/dist/types/schema/nodes/equation_element.d.ts +1 -2
- package/dist/types/schema/nodes/inline_equation.d.ts +4 -3
- package/dist/types/transformer/builders.d.ts +1 -2
- package/package.json +4 -5
- package/dist/cjs/mathjax/index.js +0 -41
- package/dist/cjs/mathjax/mathjax-packages.js +0 -20
- package/dist/cjs/mathjax/mathml-to-svg.js +0 -70
- package/dist/cjs/mathjax/tex-to-mathml.js +0 -49
- package/dist/cjs/mathjax/tex-to-svg.js +0 -59
- package/dist/es/mathjax/index.js +0 -12
- package/dist/es/mathjax/mathjax-packages.js +0 -17
- package/dist/es/mathjax/mathml-to-svg.js +0 -66
- package/dist/es/mathjax/tex-to-mathml.js +0 -45
- package/dist/es/mathjax/tex-to-svg.js +0 -55
- package/dist/types/mathjax/index.d.ts +0 -3
- package/dist/types/mathjax/mathjax-packages.d.ts +0 -16
- package/dist/types/mathjax/mathml-to-svg.d.ts +0 -17
- package/dist/types/mathjax/tex-to-mathml.d.ts +0 -17
- package/dist/types/mathjax/tex-to-svg.d.ts +0 -17
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.convertTeXToSVG = exports.convertTeXToMathML = exports.convertMathMLToSVG = void 0;
|
|
27
|
-
const convertMathMLToSVG = async (mathml, display) => {
|
|
28
|
-
const { convertMathMLToSVG } = await Promise.resolve().then(() => __importStar(require('./mathml-to-svg')));
|
|
29
|
-
return convertMathMLToSVG(mathml, display);
|
|
30
|
-
};
|
|
31
|
-
exports.convertMathMLToSVG = convertMathMLToSVG;
|
|
32
|
-
const convertTeXToMathML = async (tex, display) => {
|
|
33
|
-
const { convertTeXToMathML } = await Promise.resolve().then(() => __importStar(require('./tex-to-mathml')));
|
|
34
|
-
return convertTeXToMathML(tex, display);
|
|
35
|
-
};
|
|
36
|
-
exports.convertTeXToMathML = convertTeXToMathML;
|
|
37
|
-
const convertTeXToSVG = async (tex, display) => {
|
|
38
|
-
const { convertTeXToSVG } = await Promise.resolve().then(() => __importStar(require('./tex-to-svg')));
|
|
39
|
-
return convertTeXToSVG(tex, display);
|
|
40
|
-
};
|
|
41
|
-
exports.convertTeXToSVG = convertTeXToSVG;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*!
|
|
3
|
-
* © 2019 Atypon Systems LLC
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.packages = void 0;
|
|
19
|
-
const AllPackages_1 = require("mathjax-full/js/input/tex/AllPackages");
|
|
20
|
-
exports.packages = AllPackages_1.AllPackages.filter((name) => name !== 'html' && name !== 'bussproofs');
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*!
|
|
3
|
-
* © 2019 Atypon Systems LLC
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.convertMathMLToSVG = void 0;
|
|
19
|
-
require("mathjax-full/js/util/entities/all");
|
|
20
|
-
const HTMLAdaptor_1 = require("mathjax-full/js/adaptors/HTMLAdaptor");
|
|
21
|
-
const MmlFactory_1 = require("mathjax-full/js/core/MmlTree/MmlFactory");
|
|
22
|
-
const HTMLDocument_1 = require("mathjax-full/js/handlers/html/HTMLDocument");
|
|
23
|
-
const mathml_1 = require("mathjax-full/js/input/mathml");
|
|
24
|
-
const svg_1 = require("mathjax-full/js/output/svg");
|
|
25
|
-
const transformer_1 = require("../transformer");
|
|
26
|
-
class ManuscriptsMmlFactory extends MmlFactory_1.MmlFactory {
|
|
27
|
-
constructor() {
|
|
28
|
-
super();
|
|
29
|
-
this.nodeMap.set('image', this.nodeMap.get('none'));
|
|
30
|
-
}
|
|
31
|
-
create(kind, properties = {}, children = []) {
|
|
32
|
-
if (kind === 'image') {
|
|
33
|
-
return this.node['none'](properties, children);
|
|
34
|
-
}
|
|
35
|
-
return this.node[kind](properties, children);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
class ManuscriptsHTMLAdaptor extends HTMLAdaptor_1.HTMLAdaptor {
|
|
39
|
-
setAttribute(node, name, value, ns) {
|
|
40
|
-
if (name !== 'xmlns') {
|
|
41
|
-
ns ? node.setAttributeNS(ns, name, value) : node.setAttribute(name, value);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
const InputJax = new mathml_1.MathML();
|
|
46
|
-
const OutputJax = new svg_1.SVG({
|
|
47
|
-
fontCache: 'none',
|
|
48
|
-
});
|
|
49
|
-
const adaptor = new ManuscriptsHTMLAdaptor(window);
|
|
50
|
-
const doc = new HTMLDocument_1.HTMLDocument(document, adaptor, {
|
|
51
|
-
InputJax,
|
|
52
|
-
OutputJax,
|
|
53
|
-
MmlFactory: new ManuscriptsMmlFactory(),
|
|
54
|
-
});
|
|
55
|
-
doc.addStyleSheet();
|
|
56
|
-
const convertMathMLToSVG = (mathml, display) => {
|
|
57
|
-
const item = doc.convert(mathml, {
|
|
58
|
-
display,
|
|
59
|
-
em: 16,
|
|
60
|
-
ex: 8,
|
|
61
|
-
containerWidth: 1000000,
|
|
62
|
-
lineWidth: 1000000,
|
|
63
|
-
scale: 1,
|
|
64
|
-
});
|
|
65
|
-
if (!item || !item.firstChild) {
|
|
66
|
-
return null;
|
|
67
|
-
}
|
|
68
|
-
return transformer_1.xmlSerializer.serializeToString(item.firstChild);
|
|
69
|
-
};
|
|
70
|
-
exports.convertMathMLToSVG = convertMathMLToSVG;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*!
|
|
3
|
-
* © 2019 Atypon Systems LLC
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.convertTeXToMathML = void 0;
|
|
19
|
-
require("mathjax-full/js/util/entities/all");
|
|
20
|
-
const HTMLAdaptor_1 = require("mathjax-full/js/adaptors/HTMLAdaptor");
|
|
21
|
-
const MathItem_js_1 = require("mathjax-full/js/core/MathItem.js");
|
|
22
|
-
const SerializedMmlVisitor_1 = require("mathjax-full/js/core/MmlTree/SerializedMmlVisitor");
|
|
23
|
-
const HTMLDocument_1 = require("mathjax-full/js/handlers/html/HTMLDocument");
|
|
24
|
-
const tex_1 = require("mathjax-full/js/input/tex");
|
|
25
|
-
const mathjax_packages_1 = require("./mathjax-packages");
|
|
26
|
-
const InputJax = new tex_1.TeX({
|
|
27
|
-
packages: mathjax_packages_1.packages,
|
|
28
|
-
});
|
|
29
|
-
const adaptor = new HTMLAdaptor_1.HTMLAdaptor(window);
|
|
30
|
-
const doc = new HTMLDocument_1.HTMLDocument(document, adaptor, {
|
|
31
|
-
InputJax,
|
|
32
|
-
});
|
|
33
|
-
const visitor = new SerializedMmlVisitor_1.SerializedMmlVisitor();
|
|
34
|
-
const convertTeXToMathML = (tex, display) => {
|
|
35
|
-
const item = doc.convert(tex, {
|
|
36
|
-
display,
|
|
37
|
-
em: 16,
|
|
38
|
-
ex: 8,
|
|
39
|
-
containerWidth: 1000000,
|
|
40
|
-
lineWidth: 1000000,
|
|
41
|
-
scale: 1,
|
|
42
|
-
end: MathItem_js_1.STATE.CONVERT,
|
|
43
|
-
});
|
|
44
|
-
if (!item) {
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
return visitor.visitTree(item);
|
|
48
|
-
};
|
|
49
|
-
exports.convertTeXToMathML = convertTeXToMathML;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*!
|
|
3
|
-
* © 2019 Atypon Systems LLC
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.convertTeXToSVG = void 0;
|
|
19
|
-
require("mathjax-full/js/util/entities/all");
|
|
20
|
-
const HTMLAdaptor_1 = require("mathjax-full/js/adaptors/HTMLAdaptor");
|
|
21
|
-
const HTMLDocument_1 = require("mathjax-full/js/handlers/html/HTMLDocument");
|
|
22
|
-
const tex_1 = require("mathjax-full/js/input/tex");
|
|
23
|
-
const svg_1 = require("mathjax-full/js/output/svg");
|
|
24
|
-
const transformer_1 = require("../transformer");
|
|
25
|
-
const mathjax_packages_1 = require("./mathjax-packages");
|
|
26
|
-
class ManuscriptsHTMLAdaptor extends HTMLAdaptor_1.HTMLAdaptor {
|
|
27
|
-
setAttribute(node, name, value, ns) {
|
|
28
|
-
if (name !== 'xmlns') {
|
|
29
|
-
ns ? node.setAttributeNS(ns, name, value) : node.setAttribute(name, value);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
const InputJax = new tex_1.TeX({
|
|
34
|
-
packages: mathjax_packages_1.packages,
|
|
35
|
-
});
|
|
36
|
-
const OutputJax = new svg_1.SVG({
|
|
37
|
-
fontCache: 'none',
|
|
38
|
-
});
|
|
39
|
-
const adaptor = new ManuscriptsHTMLAdaptor(window);
|
|
40
|
-
const doc = new HTMLDocument_1.HTMLDocument(document, adaptor, {
|
|
41
|
-
InputJax,
|
|
42
|
-
OutputJax,
|
|
43
|
-
});
|
|
44
|
-
doc.addStyleSheet();
|
|
45
|
-
const convertTeXToSVG = (tex, display) => {
|
|
46
|
-
const item = doc.convert(tex, {
|
|
47
|
-
display,
|
|
48
|
-
em: 16,
|
|
49
|
-
ex: 8,
|
|
50
|
-
containerWidth: 1000000,
|
|
51
|
-
lineWidth: 1000000,
|
|
52
|
-
scale: 1,
|
|
53
|
-
});
|
|
54
|
-
if (!item || !item.firstChild) {
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
return transformer_1.xmlSerializer.serializeToString(item.firstChild);
|
|
58
|
-
};
|
|
59
|
-
exports.convertTeXToSVG = convertTeXToSVG;
|
package/dist/es/mathjax/index.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export const convertMathMLToSVG = async (mathml, display) => {
|
|
2
|
-
const { convertMathMLToSVG } = await import('./mathml-to-svg');
|
|
3
|
-
return convertMathMLToSVG(mathml, display);
|
|
4
|
-
};
|
|
5
|
-
export const convertTeXToMathML = async (tex, display) => {
|
|
6
|
-
const { convertTeXToMathML } = await import('./tex-to-mathml');
|
|
7
|
-
return convertTeXToMathML(tex, display);
|
|
8
|
-
};
|
|
9
|
-
export const convertTeXToSVG = async (tex, display) => {
|
|
10
|
-
const { convertTeXToSVG } = await import('./tex-to-svg');
|
|
11
|
-
return convertTeXToSVG(tex, display);
|
|
12
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* © 2019 Atypon Systems LLC
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import { AllPackages } from 'mathjax-full/js/input/tex/AllPackages';
|
|
17
|
-
export const packages = AllPackages.filter((name) => name !== 'html' && name !== 'bussproofs');
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* © 2019 Atypon Systems LLC
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import 'mathjax-full/js/util/entities/all';
|
|
17
|
-
import { HTMLAdaptor } from 'mathjax-full/js/adaptors/HTMLAdaptor';
|
|
18
|
-
import { MmlFactory } from 'mathjax-full/js/core/MmlTree/MmlFactory';
|
|
19
|
-
import { HTMLDocument } from 'mathjax-full/js/handlers/html/HTMLDocument';
|
|
20
|
-
import { MathML } from 'mathjax-full/js/input/mathml';
|
|
21
|
-
import { SVG } from 'mathjax-full/js/output/svg';
|
|
22
|
-
import { xmlSerializer } from '../transformer';
|
|
23
|
-
class ManuscriptsMmlFactory extends MmlFactory {
|
|
24
|
-
constructor() {
|
|
25
|
-
super();
|
|
26
|
-
this.nodeMap.set('image', this.nodeMap.get('none'));
|
|
27
|
-
}
|
|
28
|
-
create(kind, properties = {}, children = []) {
|
|
29
|
-
if (kind === 'image') {
|
|
30
|
-
return this.node['none'](properties, children);
|
|
31
|
-
}
|
|
32
|
-
return this.node[kind](properties, children);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
class ManuscriptsHTMLAdaptor extends HTMLAdaptor {
|
|
36
|
-
setAttribute(node, name, value, ns) {
|
|
37
|
-
if (name !== 'xmlns') {
|
|
38
|
-
ns ? node.setAttributeNS(ns, name, value) : node.setAttribute(name, value);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
const InputJax = new MathML();
|
|
43
|
-
const OutputJax = new SVG({
|
|
44
|
-
fontCache: 'none',
|
|
45
|
-
});
|
|
46
|
-
const adaptor = new ManuscriptsHTMLAdaptor(window);
|
|
47
|
-
const doc = new HTMLDocument(document, adaptor, {
|
|
48
|
-
InputJax,
|
|
49
|
-
OutputJax,
|
|
50
|
-
MmlFactory: new ManuscriptsMmlFactory(),
|
|
51
|
-
});
|
|
52
|
-
doc.addStyleSheet();
|
|
53
|
-
export const convertMathMLToSVG = (mathml, display) => {
|
|
54
|
-
const item = doc.convert(mathml, {
|
|
55
|
-
display,
|
|
56
|
-
em: 16,
|
|
57
|
-
ex: 8,
|
|
58
|
-
containerWidth: 1000000,
|
|
59
|
-
lineWidth: 1000000,
|
|
60
|
-
scale: 1,
|
|
61
|
-
});
|
|
62
|
-
if (!item || !item.firstChild) {
|
|
63
|
-
return null;
|
|
64
|
-
}
|
|
65
|
-
return xmlSerializer.serializeToString(item.firstChild);
|
|
66
|
-
};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* © 2019 Atypon Systems LLC
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import 'mathjax-full/js/util/entities/all';
|
|
17
|
-
import { HTMLAdaptor } from 'mathjax-full/js/adaptors/HTMLAdaptor';
|
|
18
|
-
import { STATE } from 'mathjax-full/js/core/MathItem.js';
|
|
19
|
-
import { SerializedMmlVisitor } from 'mathjax-full/js/core/MmlTree/SerializedMmlVisitor';
|
|
20
|
-
import { HTMLDocument } from 'mathjax-full/js/handlers/html/HTMLDocument';
|
|
21
|
-
import { TeX } from 'mathjax-full/js/input/tex';
|
|
22
|
-
import { packages } from './mathjax-packages';
|
|
23
|
-
const InputJax = new TeX({
|
|
24
|
-
packages,
|
|
25
|
-
});
|
|
26
|
-
const adaptor = new HTMLAdaptor(window);
|
|
27
|
-
const doc = new HTMLDocument(document, adaptor, {
|
|
28
|
-
InputJax,
|
|
29
|
-
});
|
|
30
|
-
const visitor = new SerializedMmlVisitor();
|
|
31
|
-
export const convertTeXToMathML = (tex, display) => {
|
|
32
|
-
const item = doc.convert(tex, {
|
|
33
|
-
display,
|
|
34
|
-
em: 16,
|
|
35
|
-
ex: 8,
|
|
36
|
-
containerWidth: 1000000,
|
|
37
|
-
lineWidth: 1000000,
|
|
38
|
-
scale: 1,
|
|
39
|
-
end: STATE.CONVERT,
|
|
40
|
-
});
|
|
41
|
-
if (!item) {
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
return visitor.visitTree(item);
|
|
45
|
-
};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* © 2019 Atypon Systems LLC
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import 'mathjax-full/js/util/entities/all';
|
|
17
|
-
import { HTMLAdaptor } from 'mathjax-full/js/adaptors/HTMLAdaptor';
|
|
18
|
-
import { HTMLDocument } from 'mathjax-full/js/handlers/html/HTMLDocument';
|
|
19
|
-
import { TeX } from 'mathjax-full/js/input/tex';
|
|
20
|
-
import { SVG } from 'mathjax-full/js/output/svg';
|
|
21
|
-
import { xmlSerializer } from '../transformer';
|
|
22
|
-
import { packages } from './mathjax-packages';
|
|
23
|
-
class ManuscriptsHTMLAdaptor extends HTMLAdaptor {
|
|
24
|
-
setAttribute(node, name, value, ns) {
|
|
25
|
-
if (name !== 'xmlns') {
|
|
26
|
-
ns ? node.setAttributeNS(ns, name, value) : node.setAttribute(name, value);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
const InputJax = new TeX({
|
|
31
|
-
packages,
|
|
32
|
-
});
|
|
33
|
-
const OutputJax = new SVG({
|
|
34
|
-
fontCache: 'none',
|
|
35
|
-
});
|
|
36
|
-
const adaptor = new ManuscriptsHTMLAdaptor(window);
|
|
37
|
-
const doc = new HTMLDocument(document, adaptor, {
|
|
38
|
-
InputJax,
|
|
39
|
-
OutputJax,
|
|
40
|
-
});
|
|
41
|
-
doc.addStyleSheet();
|
|
42
|
-
export const convertTeXToSVG = (tex, display) => {
|
|
43
|
-
const item = doc.convert(tex, {
|
|
44
|
-
display,
|
|
45
|
-
em: 16,
|
|
46
|
-
ex: 8,
|
|
47
|
-
containerWidth: 1000000,
|
|
48
|
-
lineWidth: 1000000,
|
|
49
|
-
scale: 1,
|
|
50
|
-
});
|
|
51
|
-
if (!item || !item.firstChild) {
|
|
52
|
-
return null;
|
|
53
|
-
}
|
|
54
|
-
return xmlSerializer.serializeToString(item.firstChild);
|
|
55
|
-
};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export declare const convertMathMLToSVG: (mathml: string, display: boolean) => Promise<string | null>;
|
|
2
|
-
export declare const convertTeXToMathML: (tex: string, display: boolean) => Promise<string | null>;
|
|
3
|
-
export declare const convertTeXToSVG: (tex: string, display: boolean) => Promise<string | null>;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* © 2019 Atypon Systems LLC
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
export declare const packages: string[];
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* © 2019 Atypon Systems LLC
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import 'mathjax-full/js/util/entities/all';
|
|
17
|
-
export declare const convertMathMLToSVG: (mathml: string, display: boolean) => string | null;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* © 2019 Atypon Systems LLC
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import 'mathjax-full/js/util/entities/all';
|
|
17
|
-
export declare const convertTeXToMathML: (tex: string, display: boolean) => string | null;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* © 2019 Atypon Systems LLC
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import 'mathjax-full/js/util/entities/all';
|
|
17
|
-
export declare const convertTeXToSVG: (tex: string, display: boolean) => string | null;
|