@manuscripts/transform 2.1.3 → 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 +29 -88
- package/dist/cjs/jats/importer/jats-body-transformations.js +7 -16
- package/dist/cjs/jats/importer/jats-parser-utils.js +6 -0
- package/dist/cjs/jats/jats-exporter.js +57 -41
- package/dist/cjs/schema/index.js +3 -6
- 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/schema/nodes/table.js +52 -30
- package/dist/cjs/schema/nodes/table_element.js +1 -1
- package/dist/cjs/transformer/builders.js +1 -8
- package/dist/cjs/transformer/decode.js +30 -24
- package/dist/cjs/transformer/encode.js +7 -26
- 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 +30 -89
- package/dist/es/jats/importer/jats-body-transformations.js +7 -16
- package/dist/es/jats/importer/jats-parser-utils.js +6 -0
- package/dist/es/jats/jats-exporter.js +57 -41
- package/dist/es/schema/index.js +2 -5
- 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/schema/nodes/table.js +51 -29
- package/dist/es/schema/nodes/table_element.js +1 -1
- package/dist/es/transformer/builders.js +0 -6
- package/dist/es/transformer/decode.js +30 -24
- package/dist/es/transformer/encode.js +7 -26
- 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 -2
- 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/schema/nodes/table.d.ts +5 -12
- package/dist/types/schema/types.d.ts +1 -1
- package/dist/types/transformer/builders.d.ts +1 -2
- package/dist/types/transformer/decode.d.ts +1 -0
- package/package.json +5 -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/cjs/schema/nodes/table_row.js +0 -123
- 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/es/schema/nodes/table_row.js +0 -120
- 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
- package/dist/types/schema/nodes/table_row.d.ts +0 -41
package/dist/types/index.d.ts
CHANGED
|
@@ -82,6 +82,7 @@ export declare class JATSExporter {
|
|
|
82
82
|
protected buildBody: (fragment: ManuscriptFragment) => HTMLBodyElement;
|
|
83
83
|
protected buildBack: (body: HTMLElement) => HTMLElement;
|
|
84
84
|
protected createSerializer: () => void;
|
|
85
|
+
private createEquation;
|
|
85
86
|
protected serializeFragment: (fragment: ManuscriptFragment) => HTMLElement | DocumentFragment;
|
|
86
87
|
protected serializeNode: (node: ManuscriptNode) => Node;
|
|
87
88
|
private validateContributor;
|
|
@@ -40,7 +40,6 @@ export * from './nodes/footnotes_section';
|
|
|
40
40
|
export * from './nodes/graphical_abstract_section';
|
|
41
41
|
export * from './nodes/hard_break';
|
|
42
42
|
export * from './nodes/highlight_marker';
|
|
43
|
-
export * from './nodes/inline_equation';
|
|
44
43
|
export * from './nodes/inline_footnote';
|
|
45
44
|
export * from './nodes/keyword';
|
|
46
45
|
export * from './nodes/keywords_element';
|
|
@@ -60,7 +59,6 @@ export * from './nodes/section_title';
|
|
|
60
59
|
export * from './nodes/table';
|
|
61
60
|
export * from './nodes/table_col';
|
|
62
61
|
export * from './nodes/table_element';
|
|
63
|
-
export * from './nodes/table_row';
|
|
64
62
|
export * from './nodes/text';
|
|
65
63
|
export * from './nodes/toc_element';
|
|
66
64
|
export * from './nodes/toc_section';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* ©
|
|
2
|
+
* © 2023 Atypon Systems LLC
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
* you may not use this file except in compliance with the License.
|
|
@@ -17,9 +17,8 @@ import { NodeSpec } from 'prosemirror-model';
|
|
|
17
17
|
import { ManuscriptNode } from '../types';
|
|
18
18
|
interface Attrs {
|
|
19
19
|
id: string;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
TeXRepresentation: string;
|
|
20
|
+
format: string;
|
|
21
|
+
contents: string;
|
|
23
22
|
}
|
|
24
23
|
export interface EquationNode extends ManuscriptNode {
|
|
25
24
|
attrs: Attrs;
|
|
@@ -18,8 +18,7 @@ import { ManuscriptNode } from '../types';
|
|
|
18
18
|
import { CommentNode } from './comment';
|
|
19
19
|
interface Attrs {
|
|
20
20
|
id: string;
|
|
21
|
-
|
|
22
|
-
suppressTitle?: boolean;
|
|
21
|
+
label: string;
|
|
23
22
|
comments?: CommentNode[];
|
|
24
23
|
}
|
|
25
24
|
export interface EquationElementNode extends ManuscriptNode {
|
|
@@ -15,11 +15,12 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { NodeSpec } from 'prosemirror-model';
|
|
17
17
|
import { ManuscriptNode } from '../types';
|
|
18
|
+
import { CommentNode } from './comment';
|
|
18
19
|
interface Attrs {
|
|
19
20
|
id: string;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
contents: string;
|
|
22
|
+
format: string;
|
|
23
|
+
comments?: CommentNode[];
|
|
23
24
|
}
|
|
24
25
|
export interface InlineEquationNode extends ManuscriptNode {
|
|
25
26
|
attrs: Attrs;
|
|
@@ -13,15 +13,8 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
export
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
headerRows: number;
|
|
22
|
-
footerRows: number;
|
|
23
|
-
comments?: CommentNode[];
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
export declare const table: TableNodeSpec;
|
|
27
|
-
export declare const tableBody: TableNodeSpec;
|
|
16
|
+
import { NodeSpec } from 'prosemirror-model';
|
|
17
|
+
export declare const table: NodeSpec;
|
|
18
|
+
export declare const tableRow: NodeSpec;
|
|
19
|
+
export declare const tableCell: NodeSpec;
|
|
20
|
+
export declare const tableHeader: NodeSpec;
|
|
@@ -17,7 +17,7 @@ import { Fragment, Mark as ProsemirrorMark, MarkType, Node as ProsemirrorNode, N
|
|
|
17
17
|
import { EditorState, NodeSelection, Plugin, TextSelection, Transaction } from 'prosemirror-state';
|
|
18
18
|
import { EditorView, NodeView } from 'prosemirror-view';
|
|
19
19
|
export type Marks = 'bold' | 'code' | 'italic' | 'smallcaps' | 'strikethrough' | 'styled' | 'subscript' | 'superscript' | 'underline' | 'tracked_insert' | 'tracked_delete';
|
|
20
|
-
export type Nodes = 'attribution' | 'bibliography_item' | 'bibliography_element' | 'bibliography_section' | 'blockquote_element' | 'bullet_list' | 'caption' | 'caption_title' | 'comment' | 'comments' | 'citation' | 'cross_reference' | 'doc' | 'equation' | 'equation_element' | 'figcaption' | 'figure' | 'graphical_abstract_section' | 'figure_element' | 'footnote' | 'footnotes_element' | 'footnotes_section' | 'hard_break' | 'highlight_marker' | 'inline_equation' | 'inline_footnote' | 'keyword' | 'keywords_element' | 'keyword_group' | 'keywords' | 'link' | 'list_item' | 'listing' | 'listing_element' | 'manuscript' | 'abstracts' | 'body' | 'backmatter' | 'missing_figure' | 'ordered_list' | 'paragraph' | 'placeholder' | 'placeholder_element' | 'pullquote_element' | 'section' | 'section_label' | 'section_title' | 'section_title_plain' | 'table' | '
|
|
20
|
+
export type Nodes = 'attribution' | 'bibliography_item' | 'bibliography_element' | 'bibliography_section' | 'blockquote_element' | 'bullet_list' | 'caption' | 'caption_title' | 'comment' | 'comments' | 'citation' | 'cross_reference' | 'doc' | 'equation' | 'equation_element' | 'figcaption' | 'figure' | 'graphical_abstract_section' | 'figure_element' | 'footnote' | 'footnotes_element' | 'footnotes_section' | 'hard_break' | 'highlight_marker' | 'inline_equation' | 'inline_footnote' | 'keyword' | 'keywords_element' | 'keyword_group' | 'keywords' | 'link' | 'list_item' | 'listing' | 'listing_element' | 'manuscript' | 'abstracts' | 'body' | 'backmatter' | 'missing_figure' | 'ordered_list' | 'paragraph' | 'placeholder' | 'placeholder_element' | 'pullquote_element' | 'section' | 'section_label' | 'section_title' | 'section_title_plain' | 'table' | 'table_cell' | 'table_element' | 'table_row' | 'table_colgroup' | 'table_col' | 'text' | 'toc_element' | 'toc_section' | 'affiliation' | 'contributor' | 'table_element_footer' | 'title' | 'affiliations' | 'contributors' | 'supplements' | 'supplement' | 'table_header';
|
|
21
21
|
export type ManuscriptSchema = Schema<Nodes, Marks>;
|
|
22
22
|
export type ManuscriptEditorState = EditorState;
|
|
23
23
|
export type ManuscriptEditorView = EditorView;
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { Affiliation, Attribution, BibliographicDate, BibliographicName, BibliographyElement, BibliographyItem, Color, CommentAnnotation, Contribution, Contributor, ContributorRole, Corresponding, ElementsOrder, EmbeddedModel, Figure, Footnote, FootnotesOrder,
|
|
16
|
+
import { Affiliation, Attribution, BibliographicDate, BibliographicName, BibliographyElement, BibliographyItem, Color, CommentAnnotation, Contribution, Contributor, ContributorRole, Corresponding, ElementsOrder, EmbeddedModel, Figure, Footnote, FootnotesOrder, Journal, Keyword, KeywordGroup, Manuscript, ManuscriptNote, ObjectTypes, ParagraphElement, Project, Section, Supplement, Titles } from '@manuscripts/json-schema';
|
|
17
17
|
import { FootnotesOrderIndexList } from './footnotes-order';
|
|
18
18
|
import { CommentSelector, ManuscriptModel, ModelAttachment } from './models';
|
|
19
19
|
export type Build<T> = Pick<T, Exclude<keyof T, keyof ManuscriptModel>> & {
|
|
@@ -44,7 +44,6 @@ export declare const buildAffiliation: (institution: string, priority?: number)
|
|
|
44
44
|
export declare const buildSupplementaryMaterial: (title: string, href: string) => Build<Supplement>;
|
|
45
45
|
export declare const buildComment: (target: string, contents?: string, selector?: CommentSelector, contributions?: Contribution[], annotationColor?: string) => Build<CommentAnnotation>;
|
|
46
46
|
export declare const buildNote: (target: string, source: 'EMAIL' | 'EDITOR' | 'DASHBOARD', contents?: string) => Build<ManuscriptNote>;
|
|
47
|
-
export declare const buildInlineMathFragment: (containingObject: string, TeXRepresentation: string) => Build<InlineMathFragment>;
|
|
48
47
|
export declare const buildFootnote: (containingObject: string, contents: string, kind?: 'footnote' | 'endnote') => Build<Footnote>;
|
|
49
48
|
export declare const buildFootnotesOrder: (footnotesList: FootnotesOrderIndexList, containedObjectID: string) => Build<FootnotesOrder>;
|
|
50
49
|
export declare const buildCorresp: (contents: string) => Build<Corresponding>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@manuscripts/transform",
|
|
3
3
|
"description": "ProseMirror transformer for Manuscripts applications",
|
|
4
|
-
"version": "2.1.
|
|
4
|
+
"version": "2.1.5",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-transform",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|
|
@@ -29,13 +29,13 @@
|
|
|
29
29
|
"version": "yarn build"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@manuscripts/json-schema": "^2.2.
|
|
33
|
-
"@manuscripts/library": "^1.3.
|
|
32
|
+
"@manuscripts/json-schema": "^2.2.5",
|
|
33
|
+
"@manuscripts/library": "^1.3.4",
|
|
34
34
|
"debug": "^4.3.4",
|
|
35
35
|
"jszip": "^3.10.1",
|
|
36
|
-
"mathjax-full": "^3.2.2",
|
|
37
36
|
"mime": "^3.0.0",
|
|
38
37
|
"prosemirror-model": "^1.18.3",
|
|
38
|
+
"prosemirror-tables": "^1.3.5",
|
|
39
39
|
"uuid": "^9.0.0",
|
|
40
40
|
"w3c-xmlserializer": "^4.0.0"
|
|
41
41
|
},
|
|
@@ -64,9 +64,9 @@
|
|
|
64
64
|
"eslint-plugin-mdx": "^2.0.5",
|
|
65
65
|
"eslint-plugin-prettier": "^4.2.1",
|
|
66
66
|
"eslint-plugin-promise": "^6.1.1",
|
|
67
|
-
"eslint-plugin-simple-import-sort": "^8.0.0",
|
|
68
67
|
"eslint-plugin-react": "^7.31.11",
|
|
69
68
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
69
|
+
"eslint-plugin-simple-import-sort": "^8.0.0",
|
|
70
70
|
"husky": "^8.0.2",
|
|
71
71
|
"jest": "^29.3.1",
|
|
72
72
|
"jest-environment-jsdom": "^29.3.1",
|
|
@@ -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;
|
|
@@ -1,123 +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.tableCell = exports.tableRow = void 0;
|
|
19
|
-
const table_cell_styles_1 = require("../../lib/table-cell-styles");
|
|
20
|
-
const getCellAttrs = (p) => {
|
|
21
|
-
const dom = p;
|
|
22
|
-
const celltype = dom.tagName.toLowerCase();
|
|
23
|
-
const widthAttr = dom.getAttribute('data-colwidth');
|
|
24
|
-
const widths = widthAttr && /^\d+(,\d+)*$/.test(widthAttr)
|
|
25
|
-
? widthAttr.split(',').map((s) => Number(s))
|
|
26
|
-
: null;
|
|
27
|
-
const colspan = Number(dom.getAttribute('colspan') || 1);
|
|
28
|
-
const valign = dom.getAttribute('valign');
|
|
29
|
-
const align = dom.getAttribute('align');
|
|
30
|
-
const scope = dom.getAttribute('scope');
|
|
31
|
-
const style = dom.getAttribute('style');
|
|
32
|
-
return {
|
|
33
|
-
celltype,
|
|
34
|
-
colspan,
|
|
35
|
-
rowspan: Number(dom.getAttribute('rowspan') || 1),
|
|
36
|
-
colwidth: widths && widths.length === colspan ? widths : null,
|
|
37
|
-
placeholder: dom.getAttribute('data-placeholder-text') || '',
|
|
38
|
-
styles: (0, table_cell_styles_1.getTableCellStyles)(dom.style),
|
|
39
|
-
valign,
|
|
40
|
-
align,
|
|
41
|
-
scope,
|
|
42
|
-
style,
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
exports.tableRow = {
|
|
46
|
-
content: 'table_cell+',
|
|
47
|
-
tableRole: 'row',
|
|
48
|
-
attrs: {
|
|
49
|
-
placeholder: { default: '' },
|
|
50
|
-
},
|
|
51
|
-
parseDOM: [
|
|
52
|
-
{
|
|
53
|
-
tag: 'tr',
|
|
54
|
-
priority: 80,
|
|
55
|
-
},
|
|
56
|
-
],
|
|
57
|
-
toDOM: (node) => {
|
|
58
|
-
const tableRowNode = node;
|
|
59
|
-
const attrs = {};
|
|
60
|
-
if (tableRowNode.attrs.placeholder) {
|
|
61
|
-
attrs['data-placeholder-text'] = tableRowNode.attrs.placeholder;
|
|
62
|
-
}
|
|
63
|
-
return ['tr', attrs, 0];
|
|
64
|
-
},
|
|
65
|
-
};
|
|
66
|
-
exports.tableCell = {
|
|
67
|
-
content: 'inline*',
|
|
68
|
-
attrs: {
|
|
69
|
-
celltype: { default: 'td' },
|
|
70
|
-
colspan: { default: 1 },
|
|
71
|
-
rowspan: { default: 1 },
|
|
72
|
-
colwidth: { default: null },
|
|
73
|
-
placeholder: { default: 'Data' },
|
|
74
|
-
styles: { default: {} },
|
|
75
|
-
valign: { default: null },
|
|
76
|
-
align: { default: null },
|
|
77
|
-
scope: { default: null },
|
|
78
|
-
style: { default: null },
|
|
79
|
-
},
|
|
80
|
-
tableRole: 'cell',
|
|
81
|
-
isolating: true,
|
|
82
|
-
parseDOM: [
|
|
83
|
-
{ tag: 'td', getAttrs: getCellAttrs },
|
|
84
|
-
{ tag: 'th', getAttrs: getCellAttrs },
|
|
85
|
-
],
|
|
86
|
-
toDOM: (node) => {
|
|
87
|
-
const tableCellNode = node;
|
|
88
|
-
const attrs = {};
|
|
89
|
-
const tag = tableCellNode.attrs.celltype;
|
|
90
|
-
if (tableCellNode.attrs.colspan && tableCellNode.attrs.colspan !== 1) {
|
|
91
|
-
attrs.colspan = String(tableCellNode.attrs.colspan);
|
|
92
|
-
}
|
|
93
|
-
if (tableCellNode.attrs.rowspan && tableCellNode.attrs.rowspan !== 1) {
|
|
94
|
-
attrs.rowspan = String(tableCellNode.attrs.rowspan);
|
|
95
|
-
}
|
|
96
|
-
if (tableCellNode.attrs.colwidth) {
|
|
97
|
-
attrs['data-colwidth'] = tableCellNode.attrs.colwidth.join(',');
|
|
98
|
-
}
|
|
99
|
-
if (tableCellNode.attrs.placeholder) {
|
|
100
|
-
attrs['data-placeholder-text'] = tableCellNode.attrs.placeholder;
|
|
101
|
-
}
|
|
102
|
-
if (!tableCellNode.textContent) {
|
|
103
|
-
attrs.class = 'placeholder';
|
|
104
|
-
}
|
|
105
|
-
const styleString = (0, table_cell_styles_1.serializeTableCellStyles)(tableCellNode.attrs.styles);
|
|
106
|
-
if (styleString) {
|
|
107
|
-
attrs.style = styleString;
|
|
108
|
-
}
|
|
109
|
-
if (tableCellNode.attrs.valign) {
|
|
110
|
-
attrs.valign = tableCellNode.attrs.valign;
|
|
111
|
-
}
|
|
112
|
-
if (tableCellNode.attrs.align) {
|
|
113
|
-
attrs.align = tableCellNode.attrs.align;
|
|
114
|
-
}
|
|
115
|
-
if (tableCellNode.attrs.scope) {
|
|
116
|
-
attrs.scope = tableCellNode.attrs.scope;
|
|
117
|
-
}
|
|
118
|
-
if (tableCellNode.attrs.style) {
|
|
119
|
-
attrs.style = tableCellNode.attrs.style;
|
|
120
|
-
}
|
|
121
|
-
return [tag, attrs, 0];
|
|
122
|
-
},
|
|
123
|
-
};
|
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
|
-
};
|