@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
|
@@ -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,120 +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 { getTableCellStyles, serializeTableCellStyles, } from '../../lib/table-cell-styles';
|
|
17
|
-
const getCellAttrs = (p) => {
|
|
18
|
-
const dom = p;
|
|
19
|
-
const celltype = dom.tagName.toLowerCase();
|
|
20
|
-
const widthAttr = dom.getAttribute('data-colwidth');
|
|
21
|
-
const widths = widthAttr && /^\d+(,\d+)*$/.test(widthAttr)
|
|
22
|
-
? widthAttr.split(',').map((s) => Number(s))
|
|
23
|
-
: null;
|
|
24
|
-
const colspan = Number(dom.getAttribute('colspan') || 1);
|
|
25
|
-
const valign = dom.getAttribute('valign');
|
|
26
|
-
const align = dom.getAttribute('align');
|
|
27
|
-
const scope = dom.getAttribute('scope');
|
|
28
|
-
const style = dom.getAttribute('style');
|
|
29
|
-
return {
|
|
30
|
-
celltype,
|
|
31
|
-
colspan,
|
|
32
|
-
rowspan: Number(dom.getAttribute('rowspan') || 1),
|
|
33
|
-
colwidth: widths && widths.length === colspan ? widths : null,
|
|
34
|
-
placeholder: dom.getAttribute('data-placeholder-text') || '',
|
|
35
|
-
styles: getTableCellStyles(dom.style),
|
|
36
|
-
valign,
|
|
37
|
-
align,
|
|
38
|
-
scope,
|
|
39
|
-
style,
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
export const tableRow = {
|
|
43
|
-
content: 'table_cell+',
|
|
44
|
-
tableRole: 'row',
|
|
45
|
-
attrs: {
|
|
46
|
-
placeholder: { default: '' },
|
|
47
|
-
},
|
|
48
|
-
parseDOM: [
|
|
49
|
-
{
|
|
50
|
-
tag: 'tr',
|
|
51
|
-
priority: 80,
|
|
52
|
-
},
|
|
53
|
-
],
|
|
54
|
-
toDOM: (node) => {
|
|
55
|
-
const tableRowNode = node;
|
|
56
|
-
const attrs = {};
|
|
57
|
-
if (tableRowNode.attrs.placeholder) {
|
|
58
|
-
attrs['data-placeholder-text'] = tableRowNode.attrs.placeholder;
|
|
59
|
-
}
|
|
60
|
-
return ['tr', attrs, 0];
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
export const tableCell = {
|
|
64
|
-
content: 'inline*',
|
|
65
|
-
attrs: {
|
|
66
|
-
celltype: { default: 'td' },
|
|
67
|
-
colspan: { default: 1 },
|
|
68
|
-
rowspan: { default: 1 },
|
|
69
|
-
colwidth: { default: null },
|
|
70
|
-
placeholder: { default: 'Data' },
|
|
71
|
-
styles: { default: {} },
|
|
72
|
-
valign: { default: null },
|
|
73
|
-
align: { default: null },
|
|
74
|
-
scope: { default: null },
|
|
75
|
-
style: { default: null },
|
|
76
|
-
},
|
|
77
|
-
tableRole: 'cell',
|
|
78
|
-
isolating: true,
|
|
79
|
-
parseDOM: [
|
|
80
|
-
{ tag: 'td', getAttrs: getCellAttrs },
|
|
81
|
-
{ tag: 'th', getAttrs: getCellAttrs },
|
|
82
|
-
],
|
|
83
|
-
toDOM: (node) => {
|
|
84
|
-
const tableCellNode = node;
|
|
85
|
-
const attrs = {};
|
|
86
|
-
const tag = tableCellNode.attrs.celltype;
|
|
87
|
-
if (tableCellNode.attrs.colspan && tableCellNode.attrs.colspan !== 1) {
|
|
88
|
-
attrs.colspan = String(tableCellNode.attrs.colspan);
|
|
89
|
-
}
|
|
90
|
-
if (tableCellNode.attrs.rowspan && tableCellNode.attrs.rowspan !== 1) {
|
|
91
|
-
attrs.rowspan = String(tableCellNode.attrs.rowspan);
|
|
92
|
-
}
|
|
93
|
-
if (tableCellNode.attrs.colwidth) {
|
|
94
|
-
attrs['data-colwidth'] = tableCellNode.attrs.colwidth.join(',');
|
|
95
|
-
}
|
|
96
|
-
if (tableCellNode.attrs.placeholder) {
|
|
97
|
-
attrs['data-placeholder-text'] = tableCellNode.attrs.placeholder;
|
|
98
|
-
}
|
|
99
|
-
if (!tableCellNode.textContent) {
|
|
100
|
-
attrs.class = 'placeholder';
|
|
101
|
-
}
|
|
102
|
-
const styleString = serializeTableCellStyles(tableCellNode.attrs.styles);
|
|
103
|
-
if (styleString) {
|
|
104
|
-
attrs.style = styleString;
|
|
105
|
-
}
|
|
106
|
-
if (tableCellNode.attrs.valign) {
|
|
107
|
-
attrs.valign = tableCellNode.attrs.valign;
|
|
108
|
-
}
|
|
109
|
-
if (tableCellNode.attrs.align) {
|
|
110
|
-
attrs.align = tableCellNode.attrs.align;
|
|
111
|
-
}
|
|
112
|
-
if (tableCellNode.attrs.scope) {
|
|
113
|
-
attrs.scope = tableCellNode.attrs.scope;
|
|
114
|
-
}
|
|
115
|
-
if (tableCellNode.attrs.style) {
|
|
116
|
-
attrs.style = tableCellNode.attrs.style;
|
|
117
|
-
}
|
|
118
|
-
return [tag, attrs, 0];
|
|
119
|
-
},
|
|
120
|
-
};
|
|
@@ -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;
|
|
@@ -1,41 +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 { TableCellStyleKey } from '../../lib/table-cell-styles';
|
|
17
|
-
import { ManuscriptNode, TableNodeSpec } from '../types';
|
|
18
|
-
export interface TableRowNode extends ManuscriptNode {
|
|
19
|
-
attrs: {
|
|
20
|
-
placeholder: string;
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
export declare const tableRow: TableNodeSpec;
|
|
24
|
-
export type TableCellStyles = {
|
|
25
|
-
[key in TableCellStyleKey]?: string | null;
|
|
26
|
-
};
|
|
27
|
-
export interface TableCellNode extends ManuscriptNode {
|
|
28
|
-
attrs: {
|
|
29
|
-
celltype: 'td' | 'th';
|
|
30
|
-
colspan: number | null;
|
|
31
|
-
rowspan: number | null;
|
|
32
|
-
colwidth: number[] | null;
|
|
33
|
-
placeholder: string | null;
|
|
34
|
-
styles: TableCellStyles;
|
|
35
|
-
valign: string | null;
|
|
36
|
-
align: string | null;
|
|
37
|
-
scope: string | null;
|
|
38
|
-
style: string | null;
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
export declare const tableCell: TableNodeSpec;
|