@manuscripts/transform 2.1.1-LEAN-3092-7 → 2.1.1-LEAN-3336-17
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 +1 -0
- package/dist/cjs/jats/importer/jats-body-dom-parser.js +74 -33
- package/dist/cjs/jats/importer/jats-parser-utils.js +0 -6
- package/dist/cjs/jats/jats-exporter.js +64 -32
- package/dist/cjs/mathjax/index.js +41 -0
- package/dist/cjs/mathjax/mathjax-packages.js +20 -0
- package/dist/cjs/mathjax/mathml-to-svg.js +70 -0
- package/dist/cjs/mathjax/tex-to-mathml.js +49 -0
- package/dist/cjs/mathjax/tex-to-svg.js +59 -0
- package/dist/cjs/schema/index.js +4 -5
- package/dist/cjs/schema/nodes/equation.js +14 -12
- package/dist/cjs/schema/nodes/equation_element.js +5 -4
- package/dist/cjs/schema/nodes/inline_equation.js +15 -13
- package/dist/cjs/schema/nodes/table.js +73 -31
- package/dist/cjs/schema/nodes/table_element.js +1 -1
- package/dist/cjs/transformer/builders.js +8 -1
- package/dist/cjs/transformer/decode.js +26 -7
- package/dist/cjs/transformer/encode.js +27 -6
- package/dist/cjs/transformer/node-types.js +1 -0
- package/dist/cjs/transformer/object-types.js +1 -0
- package/dist/es/index.js +1 -0
- package/dist/es/jats/importer/jats-body-dom-parser.js +75 -34
- package/dist/es/jats/importer/jats-parser-utils.js +0 -6
- package/dist/es/jats/jats-exporter.js +64 -32
- package/dist/es/mathjax/index.js +12 -0
- package/dist/es/mathjax/mathjax-packages.js +17 -0
- package/dist/es/mathjax/mathml-to-svg.js +66 -0
- package/dist/es/mathjax/tex-to-mathml.js +45 -0
- package/dist/es/mathjax/tex-to-svg.js +55 -0
- package/dist/es/schema/index.js +3 -4
- package/dist/es/schema/nodes/equation.js +14 -12
- package/dist/es/schema/nodes/equation_element.js +5 -4
- package/dist/es/schema/nodes/inline_equation.js +15 -13
- package/dist/es/schema/nodes/table.js +72 -30
- package/dist/es/schema/nodes/table_element.js +1 -1
- package/dist/es/transformer/builders.js +6 -0
- package/dist/es/transformer/decode.js +26 -7
- package/dist/es/transformer/encode.js +27 -6
- package/dist/es/transformer/node-types.js +1 -0
- package/dist/es/transformer/object-types.js +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/jats/jats-exporter.d.ts +0 -1
- package/dist/types/mathjax/index.d.ts +3 -0
- package/dist/types/mathjax/mathjax-packages.d.ts +16 -0
- package/dist/types/mathjax/mathml-to-svg.d.ts +17 -0
- package/dist/types/mathjax/tex-to-mathml.d.ts +17 -0
- package/dist/types/mathjax/tex-to-svg.d.ts +17 -0
- package/dist/types/schema/index.d.ts +1 -1
- package/dist/types/schema/nodes/equation.d.ts +4 -3
- package/dist/types/schema/nodes/equation_element.d.ts +2 -1
- package/dist/types/schema/nodes/inline_equation.d.ts +3 -4
- 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 +2 -1
- package/dist/types/transformer/decode.d.ts +1 -0
- package/package.json +7 -5
- package/dist/cjs/schema/nodes/table_row.js +0 -123
- package/dist/es/schema/nodes/table_row.js +0 -120
- package/dist/types/schema/nodes/table_row.d.ts +0 -41
package/dist/cjs/index.js
CHANGED
|
@@ -18,6 +18,7 @@ exports.isSectionLabelNode = void 0;
|
|
|
18
18
|
__exportStar(require("./lib/section-group-type"), exports);
|
|
19
19
|
__exportStar(require("./lib/table-cell-styles"), exports);
|
|
20
20
|
__exportStar(require("./lib/utils"), exports);
|
|
21
|
+
__exportStar(require("./mathjax"), exports);
|
|
21
22
|
__exportStar(require("./schema"), exports);
|
|
22
23
|
__exportStar(require("./transformer"), exports);
|
|
23
24
|
__exportStar(require("./jats"), exports);
|
|
@@ -21,6 +21,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
21
21
|
exports.jatsBodyDOMParser = void 0;
|
|
22
22
|
const mime_1 = __importDefault(require("mime"));
|
|
23
23
|
const prosemirror_model_1 = require("prosemirror-model");
|
|
24
|
+
const mathml_to_svg_1 = require("../../mathjax/mathml-to-svg");
|
|
25
|
+
const tex_to_svg_1 = require("../../mathjax/tex-to-svg");
|
|
24
26
|
const schema_1 = require("../../schema");
|
|
25
27
|
const transformer_1 = require("../../transformer");
|
|
26
28
|
const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
|
|
@@ -37,28 +39,6 @@ const chooseContentType = (graphicNode) => {
|
|
|
37
39
|
}
|
|
38
40
|
}
|
|
39
41
|
};
|
|
40
|
-
const getEquationContent = (p) => {
|
|
41
|
-
var _a;
|
|
42
|
-
const element = p;
|
|
43
|
-
const id = element.getAttribute('id');
|
|
44
|
-
const container = (_a = element.querySelector('alternatives')) !== null && _a !== void 0 ? _a : element;
|
|
45
|
-
let contents = '';
|
|
46
|
-
let format = '';
|
|
47
|
-
for (const child of container.childNodes) {
|
|
48
|
-
const nodeName = child.nodeName.replace(/^[a-z]:/, '');
|
|
49
|
-
switch (nodeName) {
|
|
50
|
-
case 'tex-math':
|
|
51
|
-
contents = child.innerHTML;
|
|
52
|
-
format = 'tex';
|
|
53
|
-
break;
|
|
54
|
-
case 'mml:math':
|
|
55
|
-
contents = child.outerHTML;
|
|
56
|
-
format = 'mathml';
|
|
57
|
-
break;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return { id, format, contents };
|
|
61
|
-
};
|
|
62
42
|
const marks = [
|
|
63
43
|
{
|
|
64
44
|
tag: 'bold',
|
|
@@ -167,26 +147,91 @@ const nodes = [
|
|
|
167
147
|
tag: 'inline-formula',
|
|
168
148
|
node: 'inline_equation',
|
|
169
149
|
getAttrs: (node) => {
|
|
150
|
+
var _a, _b, _c, _d, _e;
|
|
170
151
|
const element = node;
|
|
171
|
-
|
|
152
|
+
const attrs = {
|
|
153
|
+
id: element.getAttribute('id'),
|
|
154
|
+
MathMLRepresentation: '',
|
|
155
|
+
SVGRepresentation: '',
|
|
156
|
+
TeXRepresentation: '',
|
|
157
|
+
};
|
|
158
|
+
const container = (_a = element.querySelector('alternatives')) !== null && _a !== void 0 ? _a : element;
|
|
159
|
+
for (const child of container.childNodes) {
|
|
160
|
+
const nodeName = child.nodeName.replace(/^[a-z]:/, '');
|
|
161
|
+
switch (nodeName) {
|
|
162
|
+
case 'tex-math':
|
|
163
|
+
attrs.TeXRepresentation = (_c = (_b = child.textContent) === null || _b === void 0 ? void 0 : _b.trim()) !== null && _c !== void 0 ? _c : '';
|
|
164
|
+
if (attrs.TeXRepresentation) {
|
|
165
|
+
attrs.SVGRepresentation =
|
|
166
|
+
(_d = (0, tex_to_svg_1.convertTeXToSVG)(attrs.TeXRepresentation, true)) !== null && _d !== void 0 ? _d : '';
|
|
167
|
+
}
|
|
168
|
+
break;
|
|
169
|
+
case 'mml:math':
|
|
170
|
+
;
|
|
171
|
+
child.removeAttribute('id');
|
|
172
|
+
attrs.MathMLRepresentation = transformer_1.xmlSerializer.serializeToString(child);
|
|
173
|
+
if (attrs.MathMLRepresentation) {
|
|
174
|
+
attrs.SVGRepresentation =
|
|
175
|
+
(_e = (0, mathml_to_svg_1.convertMathMLToSVG)(attrs.MathMLRepresentation, true)) !== null && _e !== void 0 ? _e : '';
|
|
176
|
+
}
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return attrs;
|
|
172
181
|
},
|
|
173
182
|
},
|
|
174
183
|
{
|
|
175
184
|
tag: 'disp-formula',
|
|
176
185
|
node: 'equation_element',
|
|
177
186
|
getAttrs: (node) => {
|
|
178
|
-
var _a, _b;
|
|
179
187
|
const element = node;
|
|
188
|
+
const caption = element.querySelector('figcaption');
|
|
180
189
|
return {
|
|
181
190
|
id: element.getAttribute('id'),
|
|
182
|
-
|
|
191
|
+
suppressCaption: !caption,
|
|
183
192
|
};
|
|
184
193
|
},
|
|
185
194
|
getContent: (node, schema) => {
|
|
195
|
+
var _a, _b, _c, _d, _e;
|
|
186
196
|
const element = node;
|
|
187
|
-
const attrs =
|
|
197
|
+
const attrs = {
|
|
198
|
+
MathMLStringRepresentation: '',
|
|
199
|
+
SVGStringRepresentation: '',
|
|
200
|
+
TeXRepresentation: '',
|
|
201
|
+
};
|
|
202
|
+
const container = (_a = element.querySelector('alternatives')) !== null && _a !== void 0 ? _a : element;
|
|
203
|
+
for (const child of container.childNodes) {
|
|
204
|
+
const nodeName = child.nodeName.replace(/^[a-z]:/, '');
|
|
205
|
+
switch (nodeName) {
|
|
206
|
+
case 'tex-math':
|
|
207
|
+
attrs.TeXRepresentation = (_c = (_b = child.textContent) === null || _b === void 0 ? void 0 : _b.trim()) !== null && _c !== void 0 ? _c : '';
|
|
208
|
+
if (attrs.TeXRepresentation) {
|
|
209
|
+
attrs.SVGStringRepresentation =
|
|
210
|
+
(_d = (0, tex_to_svg_1.convertTeXToSVG)(attrs.TeXRepresentation, true)) !== null && _d !== void 0 ? _d : '';
|
|
211
|
+
}
|
|
212
|
+
break;
|
|
213
|
+
case 'mml:math':
|
|
214
|
+
;
|
|
215
|
+
child.removeAttribute('id');
|
|
216
|
+
attrs.MathMLStringRepresentation =
|
|
217
|
+
transformer_1.xmlSerializer.serializeToString(child);
|
|
218
|
+
if (attrs.MathMLStringRepresentation) {
|
|
219
|
+
attrs.SVGStringRepresentation =
|
|
220
|
+
(_e = (0, mathml_to_svg_1.convertMathMLToSVG)(attrs.MathMLStringRepresentation, true)) !== null && _e !== void 0 ? _e : '';
|
|
221
|
+
}
|
|
222
|
+
break;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
const caption = element.querySelector('figcaption');
|
|
226
|
+
const figcaption = schema.nodes.figcaption.create();
|
|
188
227
|
return prosemirror_model_1.Fragment.from([
|
|
189
|
-
schema.nodes.equation.createChecked(
|
|
228
|
+
schema.nodes.equation.createChecked(attrs),
|
|
229
|
+
caption
|
|
230
|
+
?
|
|
231
|
+
exports.jatsBodyDOMParser.parse(caption, {
|
|
232
|
+
topNode: figcaption,
|
|
233
|
+
})
|
|
234
|
+
: figcaption,
|
|
190
235
|
]);
|
|
191
236
|
},
|
|
192
237
|
},
|
|
@@ -485,10 +530,6 @@ const nodes = [
|
|
|
485
530
|
};
|
|
486
531
|
},
|
|
487
532
|
},
|
|
488
|
-
{
|
|
489
|
-
tag: 'tbody',
|
|
490
|
-
skip: true,
|
|
491
|
-
},
|
|
492
533
|
{
|
|
493
534
|
tag: 'tfoot',
|
|
494
535
|
skip: true,
|
|
@@ -523,12 +564,12 @@ const nodes = [
|
|
|
523
564
|
},
|
|
524
565
|
{
|
|
525
566
|
tag: 'th',
|
|
526
|
-
node: '
|
|
567
|
+
node: 'table_header',
|
|
527
568
|
getAttrs: (node) => {
|
|
528
569
|
const element = node;
|
|
529
570
|
const colspan = element.getAttribute('colspan');
|
|
530
571
|
const rowspan = element.getAttribute('rowspan');
|
|
531
|
-
return Object.assign(Object.assign(Object.assign({
|
|
572
|
+
return Object.assign(Object.assign(Object.assign({}, (colspan && { colspan })), (rowspan && { rowspan })), { valign: element.getAttribute('valign'), align: element.getAttribute('align'), scope: element.getAttribute('scope'), style: element.getAttribute('style') });
|
|
532
573
|
},
|
|
533
574
|
},
|
|
534
575
|
{
|
|
@@ -16,8 +16,6 @@
|
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.htmlFromJatsNode = exports.updateDocumentIDs = void 0;
|
|
19
|
-
const crypto_1 = require("crypto");
|
|
20
|
-
const schema_1 = require("../../schema");
|
|
21
19
|
const transformer_1 = require("../../transformer");
|
|
22
20
|
const updateDocumentIDs = (node, replacements) => {
|
|
23
21
|
const warnings = [];
|
|
@@ -32,10 +30,6 @@ function recurseDoc(node, fn) {
|
|
|
32
30
|
node.descendants((n) => fn(n));
|
|
33
31
|
}
|
|
34
32
|
const updateNodeID = (node, replacements, warnings) => {
|
|
35
|
-
if (node.type === schema_1.schema.nodes.inline_equation) {
|
|
36
|
-
node.attrs = Object.assign(Object.assign({}, node.attrs), { id: `InlineMathFragment:${(0, crypto_1.randomUUID)()}` });
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
33
|
if (!('id' in node.attrs)) {
|
|
40
34
|
return;
|
|
41
35
|
}
|
|
@@ -164,7 +164,6 @@ class JATSExporter {
|
|
|
164
164
|
};
|
|
165
165
|
this.nodeFromJATS = (JATSFragment) => {
|
|
166
166
|
JATSFragment = JATSFragment.trim();
|
|
167
|
-
JATSFragment = JATSFragment.replace(' ', ' ');
|
|
168
167
|
if (!JATSFragment.length) {
|
|
169
168
|
return null;
|
|
170
169
|
}
|
|
@@ -615,6 +614,11 @@ class JATSExporter {
|
|
|
615
614
|
this.createSerializer = () => {
|
|
616
615
|
const getModel = (id) => id ? this.modelMap.get(id) : undefined;
|
|
617
616
|
const nodes = {
|
|
617
|
+
table_header: (node) => [
|
|
618
|
+
'th',
|
|
619
|
+
Object.assign(Object.assign({ valign: node.attrs.valign, align: node.attrs.align, scope: node.attrs.scope, style: node.attrs.style }, (node.attrs.rowspan > 1 && { rowspan: node.attrs.rowspan })), (node.attrs.colspan > 1 && { colspan: node.attrs.colspan })),
|
|
620
|
+
0,
|
|
621
|
+
],
|
|
618
622
|
title: () => '',
|
|
619
623
|
affiliations: () => '',
|
|
620
624
|
contributors: () => '',
|
|
@@ -687,20 +691,22 @@ class JATSExporter {
|
|
|
687
691
|
},
|
|
688
692
|
doc: () => '',
|
|
689
693
|
equation: (node) => {
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
694
|
+
const formula = this.document.createElement('disp-formula');
|
|
695
|
+
formula.setAttribute('id', normalizeID(node.attrs.id));
|
|
696
|
+
if (node.attrs.TeXRepresentation) {
|
|
697
|
+
const math = this.document.createElement('tex-math');
|
|
698
|
+
math.textContent = node.attrs.TeXRepresentation;
|
|
699
|
+
formula.appendChild(math);
|
|
700
|
+
}
|
|
701
|
+
else if (node.attrs.MathMLStringRepresentation) {
|
|
702
|
+
const math = this.nodeFromJATS(node.attrs.MathMLStringRepresentation);
|
|
703
|
+
if (math) {
|
|
704
|
+
formula.appendChild(math);
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
return formula;
|
|
703
708
|
},
|
|
709
|
+
equation_element: (node) => createFigureElement(node, 'fig', node.type.schema.nodes.equation, 'equation'),
|
|
704
710
|
figcaption: (node) => {
|
|
705
711
|
if (!node.textContent) {
|
|
706
712
|
return '';
|
|
@@ -750,6 +756,28 @@ class JATSExporter {
|
|
|
750
756
|
},
|
|
751
757
|
hard_break: () => '',
|
|
752
758
|
highlight_marker: () => '',
|
|
759
|
+
inline_equation: (node) => {
|
|
760
|
+
const formula = this.document.createElement('inline-formula');
|
|
761
|
+
formula.setAttribute('id', normalizeID(node.attrs.id));
|
|
762
|
+
if (node.attrs.TeXRepresentation) {
|
|
763
|
+
const math = this.document.createElement('tex-math');
|
|
764
|
+
math.textContent = node.attrs.TeXRepresentation;
|
|
765
|
+
formula.appendChild(math);
|
|
766
|
+
}
|
|
767
|
+
else if (node.attrs.MathMLRepresentation) {
|
|
768
|
+
const math = this.nodeFromJATS(node.attrs.MathMLRepresentation);
|
|
769
|
+
if (math) {
|
|
770
|
+
formula.appendChild(math);
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
else if (node.attrs.SVGRepresentation) {
|
|
774
|
+
const math = this.nodeFromJATS(node.attrs.SVGRepresentation);
|
|
775
|
+
if (math) {
|
|
776
|
+
formula.appendChild(math);
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
return formula;
|
|
780
|
+
},
|
|
753
781
|
inline_footnote: (node) => {
|
|
754
782
|
const xref = this.document.createElement('xref');
|
|
755
783
|
xref.setAttribute('ref-type', 'fn');
|
|
@@ -850,9 +878,8 @@ class JATSExporter {
|
|
|
850
878
|
element.setAttribute('position', 'anchor');
|
|
851
879
|
return element;
|
|
852
880
|
},
|
|
853
|
-
table_body: () => ['tbody', 0],
|
|
854
881
|
table_cell: (node) => [
|
|
855
|
-
|
|
882
|
+
'td',
|
|
856
883
|
Object.assign(Object.assign({ valign: node.attrs.valign, align: node.attrs.align, scope: node.attrs.scope, style: node.attrs.style }, (node.attrs.rowspan > 1 && { rowspan: node.attrs.rowspan })), (node.attrs.colspan > 1 && { colspan: node.attrs.colspan })),
|
|
857
884
|
0,
|
|
858
885
|
],
|
|
@@ -933,6 +960,26 @@ class JATSExporter {
|
|
|
933
960
|
element.appendChild(this.serializeNode(childNode));
|
|
934
961
|
}
|
|
935
962
|
};
|
|
963
|
+
const appendTable = (element, node) => {
|
|
964
|
+
const tableNode = findChildNodeOfType(node, node.type.schema.nodes.table);
|
|
965
|
+
const colGroupNode = findChildNodeOfType(node, node.type.schema.nodes.table_colgroup);
|
|
966
|
+
if (!tableNode) {
|
|
967
|
+
return;
|
|
968
|
+
}
|
|
969
|
+
const table = this.serializeNode(tableNode);
|
|
970
|
+
const tbodyElement = this.document.createElement('tbody');
|
|
971
|
+
while (table.firstChild) {
|
|
972
|
+
const child = table.firstChild;
|
|
973
|
+
table.removeChild(child);
|
|
974
|
+
tbodyElement.appendChild(child);
|
|
975
|
+
}
|
|
976
|
+
table.appendChild(tbodyElement);
|
|
977
|
+
if (colGroupNode) {
|
|
978
|
+
const colGroup = this.serializeNode(colGroupNode);
|
|
979
|
+
table.insertBefore(colGroup, table.firstChild);
|
|
980
|
+
}
|
|
981
|
+
element.appendChild(table);
|
|
982
|
+
};
|
|
936
983
|
const createFigureElement = (node, nodeName, contentNodeType, figType) => {
|
|
937
984
|
const element = createElement(node, nodeName);
|
|
938
985
|
if (figType) {
|
|
@@ -953,7 +1000,7 @@ class JATSExporter {
|
|
|
953
1000
|
const element = createElement(node, nodeName);
|
|
954
1001
|
appendLabels(element, node);
|
|
955
1002
|
appendChildNodeOfType(element, node, node.type.schema.nodes.figcaption);
|
|
956
|
-
|
|
1003
|
+
appendTable(element, node);
|
|
957
1004
|
appendChildNodeOfType(element, node, node.type.schema.nodes.table_element_footer);
|
|
958
1005
|
if ((0, node_types_1.isExecutableNodeType)(node.type)) {
|
|
959
1006
|
processExecutableNode(node, element);
|
|
@@ -1566,21 +1613,6 @@ class JATSExporter {
|
|
|
1566
1613
|
this.citationTexts.set(id, output);
|
|
1567
1614
|
});
|
|
1568
1615
|
}
|
|
1569
|
-
createEquation(node, isInline = false) {
|
|
1570
|
-
if (node.attrs.format === 'tex') {
|
|
1571
|
-
const texMath = this.document.createElement('tex-math');
|
|
1572
|
-
texMath.innerHTML = node.attrs.contents;
|
|
1573
|
-
return texMath;
|
|
1574
|
-
}
|
|
1575
|
-
else {
|
|
1576
|
-
const math = this.nodeFromJATS(node.attrs.contents);
|
|
1577
|
-
const mathml = math;
|
|
1578
|
-
if (!isInline) {
|
|
1579
|
-
mathml.setAttribute('id', normalizeID(node.attrs.id));
|
|
1580
|
-
}
|
|
1581
|
-
return mathml;
|
|
1582
|
-
}
|
|
1583
|
-
}
|
|
1584
1616
|
buildKeywords(articleMeta) {
|
|
1585
1617
|
const keywords = [...this.modelMap.values()].filter((model) => model.objectType === json_schema_1.ObjectTypes.Keyword);
|
|
1586
1618
|
const keywordGroups = new Map();
|
|
@@ -0,0 +1,41 @@
|
|
|
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;
|
|
@@ -0,0 +1,20 @@
|
|
|
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');
|
|
@@ -0,0 +1,70 @@
|
|
|
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;
|
|
@@ -0,0 +1,49 @@
|
|
|
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;
|
|
@@ -0,0 +1,59 @@
|
|
|
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/cjs/schema/index.js
CHANGED
|
@@ -87,7 +87,6 @@ const table_1 = require("./nodes/table");
|
|
|
87
87
|
const table_col_1 = require("./nodes/table_col");
|
|
88
88
|
const table_element_1 = require("./nodes/table_element");
|
|
89
89
|
const table_element_footer_1 = require("./nodes/table_element_footer");
|
|
90
|
-
const table_row_1 = require("./nodes/table_row");
|
|
91
90
|
const text_1 = require("./nodes/text");
|
|
92
91
|
const title_1 = require("./nodes/title");
|
|
93
92
|
const toc_element_1 = require("./nodes/toc_element");
|
|
@@ -117,6 +116,7 @@ __exportStar(require("./nodes/footnotes_section"), exports);
|
|
|
117
116
|
__exportStar(require("./nodes/graphical_abstract_section"), exports);
|
|
118
117
|
__exportStar(require("./nodes/hard_break"), exports);
|
|
119
118
|
__exportStar(require("./nodes/highlight_marker"), exports);
|
|
119
|
+
__exportStar(require("./nodes/inline_equation"), exports);
|
|
120
120
|
__exportStar(require("./nodes/inline_footnote"), exports);
|
|
121
121
|
__exportStar(require("./nodes/keyword"), exports);
|
|
122
122
|
__exportStar(require("./nodes/keywords_element"), exports);
|
|
@@ -136,7 +136,6 @@ __exportStar(require("./nodes/section_title"), exports);
|
|
|
136
136
|
__exportStar(require("./nodes/table"), exports);
|
|
137
137
|
__exportStar(require("./nodes/table_col"), exports);
|
|
138
138
|
__exportStar(require("./nodes/table_element"), exports);
|
|
139
|
-
__exportStar(require("./nodes/table_row"), exports);
|
|
140
139
|
__exportStar(require("./nodes/text"), exports);
|
|
141
140
|
__exportStar(require("./nodes/toc_element"), exports);
|
|
142
141
|
__exportStar(require("./nodes/toc_section"), exports);
|
|
@@ -212,10 +211,9 @@ exports.schema = new prosemirror_model_1.Schema({
|
|
|
212
211
|
section_title: section_title_1.sectionTitle,
|
|
213
212
|
section_title_plain: section_title_1.sectionTitle,
|
|
214
213
|
table: table_1.table,
|
|
215
|
-
|
|
216
|
-
table_cell: table_row_1.tableCell,
|
|
214
|
+
table_cell: table_1.tableCell,
|
|
217
215
|
table_element: table_element_1.tableElement,
|
|
218
|
-
table_row:
|
|
216
|
+
table_row: table_1.tableRow,
|
|
219
217
|
table_col: table_col_1.tableCol,
|
|
220
218
|
table_colgroup: table_col_1.tableColGroup,
|
|
221
219
|
text: text_1.text,
|
|
@@ -229,5 +227,6 @@ exports.schema = new prosemirror_model_1.Schema({
|
|
|
229
227
|
contributors: contributors_1.contributors,
|
|
230
228
|
supplements: supplements_1.supplements,
|
|
231
229
|
supplement: supplement_1.supplement,
|
|
230
|
+
table_header: table_1.tableHeader,
|
|
232
231
|
},
|
|
233
232
|
});
|