@manuscripts/transform 2.0.4 → 2.1.1-LEAN-3094
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 +44 -73
- package/dist/cjs/jats/importer/jats-body-transformations.js +14 -0
- package/dist/cjs/jats/importer/jats-front-parser.js +0 -19
- package/dist/cjs/jats/importer/parse-jats-article.js +1 -4
- package/dist/cjs/jats/jats-exporter.js +19 -37
- package/dist/cjs/schema/index.js +6 -1
- package/dist/cjs/schema/nodes/affiliation.js +4 -1
- package/dist/cjs/schema/nodes/contributor.js +3 -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 +12 -16
- package/dist/cjs/schema/nodes/manuscript.js +1 -1
- package/dist/cjs/schema/nodes/supplement.js +63 -0
- package/dist/cjs/schema/nodes/supplements.js +45 -0
- package/dist/cjs/transformer/builders.js +1 -8
- package/dist/cjs/transformer/decode.js +31 -7
- package/dist/cjs/transformer/encode.js +16 -25
- package/dist/cjs/transformer/node-types.js +1 -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 +45 -74
- package/dist/es/jats/importer/jats-body-transformations.js +14 -0
- package/dist/es/jats/importer/jats-front-parser.js +1 -20
- package/dist/es/jats/importer/parse-jats-article.js +1 -4
- package/dist/es/jats/jats-exporter.js +19 -37
- package/dist/es/schema/index.js +6 -1
- package/dist/es/schema/nodes/affiliation.js +4 -1
- package/dist/es/schema/nodes/contributor.js +3 -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 +12 -16
- package/dist/es/schema/nodes/manuscript.js +1 -1
- package/dist/es/schema/nodes/supplement.js +60 -0
- package/dist/es/schema/nodes/supplements.js +42 -0
- package/dist/es/transformer/builders.js +0 -6
- package/dist/es/transformer/decode.js +31 -7
- package/dist/es/transformer/encode.js +16 -25
- package/dist/es/transformer/node-types.js +1 -1
- package/dist/es/transformer/object-types.js +0 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/jats/importer/jats-body-transformations.d.ts +1 -0
- package/dist/types/jats/importer/jats-front-parser.d.ts +0 -1
- package/dist/types/schema/index.d.ts +2 -1
- package/dist/types/schema/nodes/affiliation.d.ts +2 -0
- package/dist/types/schema/nodes/contributor.d.ts +4 -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 -4
- package/dist/{cjs/mathjax/mathjax-packages.js → types/schema/nodes/supplement.d.ts} +14 -5
- package/dist/{es/mathjax/mathjax-packages.js → types/schema/nodes/supplements.d.ts} +10 -2
- 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 +4 -5
- package/dist/cjs/mathjax/index.js +0 -41
- 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/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
|
@@ -0,0 +1,45 @@
|
|
|
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.supplements = void 0;
|
|
19
|
+
exports.supplements = {
|
|
20
|
+
content: 'section_title supplement*',
|
|
21
|
+
attrs: {
|
|
22
|
+
id: { default: '' },
|
|
23
|
+
dataTracked: { default: null },
|
|
24
|
+
},
|
|
25
|
+
group: 'block',
|
|
26
|
+
selectable: false,
|
|
27
|
+
parseDOM: [
|
|
28
|
+
{
|
|
29
|
+
tag: 'div.supplements',
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
toDOM: (node) => {
|
|
33
|
+
const supplements = node;
|
|
34
|
+
return [
|
|
35
|
+
'div',
|
|
36
|
+
{
|
|
37
|
+
id: supplements.attrs.id,
|
|
38
|
+
class: 'supplements',
|
|
39
|
+
spellcheck: 'false',
|
|
40
|
+
contenteditable: false,
|
|
41
|
+
},
|
|
42
|
+
0,
|
|
43
|
+
];
|
|
44
|
+
},
|
|
45
|
+
};
|
|
@@ -18,7 +18,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
18
18
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
19
|
};
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.buildTitles = exports.buildElementsOrder = exports.auxiliaryObjectTypes = exports.buildJournal = exports.buildAttribution = exports.buildContributorRole = exports.buildContribution = exports.buildColor = exports.buildParagraph = exports.buildSection = exports.buildCorresp = exports.buildFootnotesOrder = exports.buildFootnote = exports.
|
|
21
|
+
exports.buildTitles = exports.buildElementsOrder = exports.auxiliaryObjectTypes = exports.buildJournal = exports.buildAttribution = exports.buildContributorRole = exports.buildContribution = exports.buildColor = exports.buildParagraph = exports.buildSection = exports.buildCorresp = exports.buildFootnotesOrder = exports.buildFootnote = exports.buildNote = exports.buildComment = exports.buildSupplementaryMaterial = exports.buildAffiliation = exports.buildFigure = exports.buildKeywordGroup = exports.buildKeyword = exports.buildBibliographyElement = exports.buildBibliographicDate = exports.buildBibliographicName = exports.buildBibliographyItem = exports.buildContributor = exports.buildManuscript = exports.buildProject = void 0;
|
|
22
22
|
const json_schema_1 = require("@manuscripts/json-schema");
|
|
23
23
|
const w3c_xmlserializer_1 = __importDefault(require("w3c-xmlserializer"));
|
|
24
24
|
const schema_1 = require("../schema");
|
|
@@ -115,13 +115,6 @@ const buildNote = (target, source, contents = '') => ({
|
|
|
115
115
|
contents,
|
|
116
116
|
});
|
|
117
117
|
exports.buildNote = buildNote;
|
|
118
|
-
const buildInlineMathFragment = (containingObject, TeXRepresentation) => ({
|
|
119
|
-
_id: (0, id_1.generateID)(json_schema_1.ObjectTypes.InlineMathFragment),
|
|
120
|
-
objectType: json_schema_1.ObjectTypes.InlineMathFragment,
|
|
121
|
-
containingObject: containingObject || undefined,
|
|
122
|
-
TeXRepresentation,
|
|
123
|
-
});
|
|
124
|
-
exports.buildInlineMathFragment = buildInlineMathFragment;
|
|
125
118
|
const buildFootnote = (containingObject, contents, kind = 'footnote') => ({
|
|
126
119
|
_id: (0, id_1.generateID)(json_schema_1.ObjectTypes.Footnote),
|
|
127
120
|
objectType: json_schema_1.ObjectTypes.Footnote,
|
|
@@ -64,6 +64,7 @@ const getSections = (modelMap) => (0, exports.getModelsByType)(modelMap, json_sc
|
|
|
64
64
|
const getAffiliations = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Affiliation);
|
|
65
65
|
const getContributors = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Contributor);
|
|
66
66
|
const getKeywordElements = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.KeywordsElement);
|
|
67
|
+
const getSupplements = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Supplement);
|
|
67
68
|
const getKeywordGroups = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.KeywordGroup);
|
|
68
69
|
const getKeywords = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Keyword);
|
|
69
70
|
const getTitles = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Titles)[0];
|
|
@@ -102,6 +103,15 @@ class Decoder {
|
|
|
102
103
|
...elements,
|
|
103
104
|
]);
|
|
104
105
|
}
|
|
106
|
+
createSupplementsNode() {
|
|
107
|
+
const elements = getSupplements(this.modelMap)
|
|
108
|
+
.map((e) => this.decode(e))
|
|
109
|
+
.filter(Boolean);
|
|
110
|
+
return schema_1.schema.nodes.supplements.createAndFill({}, [
|
|
111
|
+
schema_1.schema.nodes.section_title.create({}, schema_1.schema.text('SupplementaryMaterials')),
|
|
112
|
+
...elements,
|
|
113
|
+
]);
|
|
114
|
+
}
|
|
105
115
|
createCommentsNode() {
|
|
106
116
|
return schema_1.schema.nodes.comments.createAndFill({}, [
|
|
107
117
|
...this.comments.values(),
|
|
@@ -271,9 +281,8 @@ class Decoder {
|
|
|
271
281
|
const model = data;
|
|
272
282
|
return schema_1.schema.nodes.equation.createChecked({
|
|
273
283
|
id: model._id,
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
TeXRepresentation: model.TeXRepresentation,
|
|
284
|
+
contents: model.contents,
|
|
285
|
+
format: model.format,
|
|
277
286
|
});
|
|
278
287
|
},
|
|
279
288
|
[json_schema_1.ObjectTypes.EquationElement]: (data) => {
|
|
@@ -292,12 +301,10 @@ class Decoder {
|
|
|
292
301
|
else {
|
|
293
302
|
throw new errors_1.MissingElement(model.containedObjectID);
|
|
294
303
|
}
|
|
295
|
-
const figcaption = this.getFigcaption(model);
|
|
296
304
|
return schema_1.schema.nodes.equation_element.createChecked({
|
|
297
305
|
id: model._id,
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
}, [equation, figcaption]);
|
|
306
|
+
label: model.label,
|
|
307
|
+
}, [equation]);
|
|
301
308
|
},
|
|
302
309
|
[json_schema_1.ObjectTypes.FootnotesElement]: (data) => {
|
|
303
310
|
const foonotesElementModel = data;
|
|
@@ -618,6 +625,8 @@ class Decoder {
|
|
|
618
625
|
addressLine3: model.addressLine3,
|
|
619
626
|
postCode: model.postCode,
|
|
620
627
|
country: model.country,
|
|
628
|
+
county: model.county,
|
|
629
|
+
city: model.city,
|
|
621
630
|
email: model.email,
|
|
622
631
|
department: model.department,
|
|
623
632
|
priority: model.priority,
|
|
@@ -629,6 +638,8 @@ class Decoder {
|
|
|
629
638
|
id: model._id,
|
|
630
639
|
role: model.role,
|
|
631
640
|
affiliations: model.affiliations,
|
|
641
|
+
email: model.email,
|
|
642
|
+
isJointContributor: model.isJointContributor,
|
|
632
643
|
bibliographicName: model.bibliographicName,
|
|
633
644
|
userID: model.userID,
|
|
634
645
|
invitationID: model.invitationID,
|
|
@@ -639,6 +650,17 @@ class Decoder {
|
|
|
639
650
|
priority: model.priority,
|
|
640
651
|
}, schema_1.schema.text('_'));
|
|
641
652
|
},
|
|
653
|
+
[json_schema_1.ObjectTypes.Supplement]: (data) => {
|
|
654
|
+
var _a, _b;
|
|
655
|
+
const model = data;
|
|
656
|
+
return schema_1.schema.nodes.supplement.create({
|
|
657
|
+
id: model._id,
|
|
658
|
+
href: model.href,
|
|
659
|
+
mimeType: (_a = model.MIME) === null || _a === void 0 ? void 0 : _a.split('/')[0],
|
|
660
|
+
mimeSubType: (_b = model.MIME) === null || _b === void 0 ? void 0 : _b.split('/')[1],
|
|
661
|
+
title: model.title,
|
|
662
|
+
});
|
|
663
|
+
},
|
|
642
664
|
};
|
|
643
665
|
this.decode = (model) => {
|
|
644
666
|
if (!this.creators[model.objectType]) {
|
|
@@ -653,6 +675,7 @@ class Decoder {
|
|
|
653
675
|
const contributors = this.createContributorsNode();
|
|
654
676
|
const affiliations = this.createAffiliationsNode();
|
|
655
677
|
const keywords = this.createKeywordsNode();
|
|
678
|
+
const suppl = this.createSupplementsNode();
|
|
656
679
|
const { abstracts, body, backmatter } = this.createContentSections();
|
|
657
680
|
const comments = this.createCommentsNode();
|
|
658
681
|
const contents = [
|
|
@@ -660,6 +683,7 @@ class Decoder {
|
|
|
660
683
|
contributors,
|
|
661
684
|
affiliations,
|
|
662
685
|
keywords,
|
|
686
|
+
suppl,
|
|
663
687
|
abstracts,
|
|
664
688
|
body,
|
|
665
689
|
backmatter,
|
|
@@ -62,12 +62,6 @@ const listContents = (node) => {
|
|
|
62
62
|
}
|
|
63
63
|
return (0, w3c_xmlserializer_1.default)(output);
|
|
64
64
|
};
|
|
65
|
-
const svgDefs = (svg) => {
|
|
66
|
-
const template = document.createElement('template');
|
|
67
|
-
template.innerHTML = svg.trim();
|
|
68
|
-
const defs = template.content.querySelector('defs');
|
|
69
|
-
return defs ? (0, w3c_xmlserializer_1.default)(defs) : undefined;
|
|
70
|
-
};
|
|
71
65
|
const tableRowDisplayStyle = (tagName, parent) => {
|
|
72
66
|
switch (tagName) {
|
|
73
67
|
case 'thead':
|
|
@@ -353,20 +347,12 @@ const encoders = {
|
|
|
353
347
|
: false,
|
|
354
348
|
}),
|
|
355
349
|
equation: (node) => ({
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
SVGStringRepresentation: node.attrs.SVGStringRepresentation,
|
|
350
|
+
contents: node.attrs.contents,
|
|
351
|
+
format: node.attrs.format,
|
|
359
352
|
}),
|
|
360
353
|
equation_element: (node) => ({
|
|
361
354
|
containedObjectID: attributeOfNodeType(node, 'equation', 'id'),
|
|
362
|
-
|
|
363
|
-
title: inlineContentOfChildNodeType(node, node.type.schema.nodes.figcaption, node.type.schema.nodes.caption_title, false),
|
|
364
|
-
elementType: 'p',
|
|
365
|
-
suppressCaption: Boolean(node.attrs.suppressCaption) || undefined,
|
|
366
|
-
suppressTitle: node.attrs.suppressTitle === undefined ||
|
|
367
|
-
node.attrs.suppressTitle === true
|
|
368
|
-
? undefined
|
|
369
|
-
: false,
|
|
355
|
+
label: node.attrs.label,
|
|
370
356
|
}),
|
|
371
357
|
figure: (node) => ({
|
|
372
358
|
contentType: node.attrs.contentType || undefined,
|
|
@@ -413,12 +399,6 @@ const encoders = {
|
|
|
413
399
|
.map((childNode) => childNode.attrs.id)
|
|
414
400
|
.filter((id) => id),
|
|
415
401
|
}),
|
|
416
|
-
inline_equation: (node, parent) => ({
|
|
417
|
-
containingObject: parent.attrs.id,
|
|
418
|
-
TeXRepresentation: node.attrs.TeXRepresentation,
|
|
419
|
-
SVGRepresentation: node.attrs.SVGRepresentation,
|
|
420
|
-
SVGGlyphs: svgDefs(node.attrs.SVGRepresentation),
|
|
421
|
-
}),
|
|
422
402
|
keyword: (node, parent) => ({
|
|
423
403
|
containedGroup: parent.attrs.id,
|
|
424
404
|
name: keywordContents(node),
|
|
@@ -508,8 +488,11 @@ const encoders = {
|
|
|
508
488
|
addressLine1: node.attrs.addressLine1,
|
|
509
489
|
addressLine2: node.attrs.addressLine2,
|
|
510
490
|
addressLine3: node.attrs.addressLine3,
|
|
491
|
+
department: node.attrs.department,
|
|
511
492
|
postCode: node.attrs.postCode,
|
|
512
493
|
country: node.attrs.country,
|
|
494
|
+
county: node.attrs.county,
|
|
495
|
+
city: node.attrs.city,
|
|
513
496
|
email: node.attrs.email,
|
|
514
497
|
priority: node.attrs.priority,
|
|
515
498
|
}),
|
|
@@ -520,11 +503,19 @@ const encoders = {
|
|
|
520
503
|
userID: node.attrs.userID,
|
|
521
504
|
invitationID: node.attrs.invitationID,
|
|
522
505
|
isCorresponding: node.attrs.isCorresponding,
|
|
506
|
+
isJointContributor: node.attrs.isJointContributor,
|
|
523
507
|
ORCIDIdentifier: node.attrs.ORCIDIdentifier,
|
|
524
508
|
footnote: node.attrs.footnote,
|
|
525
509
|
corresp: node.attrs.corresp,
|
|
526
510
|
priority: node.attrs.priority,
|
|
527
511
|
}),
|
|
512
|
+
supplement: (node) => ({
|
|
513
|
+
href: node.attrs.href,
|
|
514
|
+
title: node.attrs.title,
|
|
515
|
+
MIME: node.attrs.mimeType && node.attrs.mimeSubType
|
|
516
|
+
? [node.attrs.mimeType, node.attrs.mimeSubType].join('/')
|
|
517
|
+
: '',
|
|
518
|
+
}),
|
|
528
519
|
};
|
|
529
520
|
const modelData = (node, parent, path, priority) => {
|
|
530
521
|
const encoder = encoders[node.type.name];
|
|
@@ -553,6 +544,7 @@ const containerTypes = [
|
|
|
553
544
|
schema_1.schema.nodes.contributors,
|
|
554
545
|
schema_1.schema.nodes.affiliations,
|
|
555
546
|
schema_1.schema.nodes.keywords,
|
|
547
|
+
schema_1.schema.nodes.supplements,
|
|
556
548
|
schema_1.schema.nodes.abstracts,
|
|
557
549
|
schema_1.schema.nodes.body,
|
|
558
550
|
schema_1.schema.nodes.backmatter,
|
|
@@ -580,8 +572,7 @@ const encode = (node) => {
|
|
|
580
572
|
if (placeholderTypes.includes(child.type)) {
|
|
581
573
|
return;
|
|
582
574
|
}
|
|
583
|
-
if (parent.type === schema_1.schema.nodes.paragraph
|
|
584
|
-
child.type !== schema_1.schema.nodes.inline_equation) {
|
|
575
|
+
if (parent.type === schema_1.schema.nodes.paragraph) {
|
|
585
576
|
return;
|
|
586
577
|
}
|
|
587
578
|
const { model, markers } = (0, exports.modelFromNode)(child, parent, path, priority);
|
|
@@ -39,7 +39,6 @@ exports.nodeTypesMap = new Map([
|
|
|
39
39
|
[schema_1.schema.nodes.footnotes_section, json_schema_1.ObjectTypes.Section],
|
|
40
40
|
[schema_1.schema.nodes.graphical_abstract_section, json_schema_1.ObjectTypes.Section],
|
|
41
41
|
[schema_1.schema.nodes.highlight_marker, json_schema_1.ObjectTypes.HighlightMarker],
|
|
42
|
-
[schema_1.schema.nodes.inline_equation, json_schema_1.ObjectTypes.InlineMathFragment],
|
|
43
42
|
[schema_1.schema.nodes.keyword, json_schema_1.ObjectTypes.Keyword],
|
|
44
43
|
[schema_1.schema.nodes.keywords_element, json_schema_1.ObjectTypes.KeywordsElement],
|
|
45
44
|
[schema_1.schema.nodes.keywords, json_schema_1.ObjectTypes.Section],
|
|
@@ -61,6 +60,7 @@ exports.nodeTypesMap = new Map([
|
|
|
61
60
|
[schema_1.schema.nodes.contributors, json_schema_1.ObjectTypes.Section],
|
|
62
61
|
[schema_1.schema.nodes.affiliations, json_schema_1.ObjectTypes.Section],
|
|
63
62
|
[schema_1.schema.nodes.title, json_schema_1.ObjectTypes.Titles],
|
|
63
|
+
[schema_1.schema.nodes.supplement, json_schema_1.ObjectTypes.Supplement],
|
|
64
64
|
]);
|
|
65
65
|
const isExecutableNodeType = (type) => (0, schema_1.hasGroup)(type, schema_1.GROUP_EXECUTABLE);
|
|
66
66
|
exports.isExecutableNodeType = isExecutableNodeType;
|
|
@@ -38,7 +38,6 @@ exports.manuscriptObjects = [
|
|
|
38
38
|
json_schema_1.ObjectTypes.CommentAnnotation,
|
|
39
39
|
json_schema_1.ObjectTypes.Contributor,
|
|
40
40
|
json_schema_1.ObjectTypes.Footnote,
|
|
41
|
-
json_schema_1.ObjectTypes.InlineMathFragment,
|
|
42
41
|
json_schema_1.ObjectTypes.Section,
|
|
43
42
|
].concat(exports.elementObjects);
|
|
44
43
|
const isManuscriptModel = (model) => {
|
package/dist/es/index.js
CHANGED
|
@@ -15,10 +15,8 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import mime from 'mime';
|
|
17
17
|
import { DOMParser, Fragment } from 'prosemirror-model';
|
|
18
|
-
import { convertMathMLToSVG } from '../../mathjax/mathml-to-svg';
|
|
19
|
-
import { convertTeXToSVG } from '../../mathjax/tex-to-svg';
|
|
20
18
|
import { schema } from '../../schema';
|
|
21
|
-
import { chooseSectionCategory
|
|
19
|
+
import { chooseSectionCategory } from '../../transformer';
|
|
22
20
|
const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
|
|
23
21
|
const chooseContentType = (graphicNode) => {
|
|
24
22
|
if (graphicNode) {
|
|
@@ -33,6 +31,24 @@ const chooseContentType = (graphicNode) => {
|
|
|
33
31
|
}
|
|
34
32
|
}
|
|
35
33
|
};
|
|
34
|
+
const getEquationContent = (p) => {
|
|
35
|
+
var _a;
|
|
36
|
+
const element = p;
|
|
37
|
+
const container = (_a = element.querySelector('alternatives')) !== null && _a !== void 0 ? _a : element;
|
|
38
|
+
let contents = '';
|
|
39
|
+
let format = '';
|
|
40
|
+
for (const child of container.childNodes) {
|
|
41
|
+
const nodeName = child.nodeName.replace(/^[a-z]:/, '');
|
|
42
|
+
switch (nodeName) {
|
|
43
|
+
case 'tex-math':
|
|
44
|
+
case 'mml:math':
|
|
45
|
+
contents = child.outerHTML;
|
|
46
|
+
format = nodeName === 'tex-math' ? 'tex' : 'mathml';
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return { format, contents };
|
|
51
|
+
};
|
|
36
52
|
const marks = [
|
|
37
53
|
{
|
|
38
54
|
tag: 'bold',
|
|
@@ -141,91 +157,27 @@ const nodes = [
|
|
|
141
157
|
tag: 'inline-formula',
|
|
142
158
|
node: 'inline_equation',
|
|
143
159
|
getAttrs: (node) => {
|
|
144
|
-
var _a, _b, _c, _d, _e;
|
|
145
160
|
const element = node;
|
|
146
|
-
|
|
147
|
-
id: element.getAttribute('id'),
|
|
148
|
-
MathMLRepresentation: '',
|
|
149
|
-
SVGRepresentation: '',
|
|
150
|
-
TeXRepresentation: '',
|
|
151
|
-
};
|
|
152
|
-
const container = (_a = element.querySelector('alternatives')) !== null && _a !== void 0 ? _a : element;
|
|
153
|
-
for (const child of container.childNodes) {
|
|
154
|
-
const nodeName = child.nodeName.replace(/^[a-z]:/, '');
|
|
155
|
-
switch (nodeName) {
|
|
156
|
-
case 'tex-math':
|
|
157
|
-
attrs.TeXRepresentation = (_c = (_b = child.textContent) === null || _b === void 0 ? void 0 : _b.trim()) !== null && _c !== void 0 ? _c : '';
|
|
158
|
-
if (attrs.TeXRepresentation) {
|
|
159
|
-
attrs.SVGRepresentation =
|
|
160
|
-
(_d = convertTeXToSVG(attrs.TeXRepresentation, true)) !== null && _d !== void 0 ? _d : '';
|
|
161
|
-
}
|
|
162
|
-
break;
|
|
163
|
-
case 'mml:math':
|
|
164
|
-
;
|
|
165
|
-
child.removeAttribute('id');
|
|
166
|
-
attrs.MathMLRepresentation = xmlSerializer.serializeToString(child);
|
|
167
|
-
if (attrs.MathMLRepresentation) {
|
|
168
|
-
attrs.SVGRepresentation =
|
|
169
|
-
(_e = convertMathMLToSVG(attrs.MathMLRepresentation, true)) !== null && _e !== void 0 ? _e : '';
|
|
170
|
-
}
|
|
171
|
-
break;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
return attrs;
|
|
161
|
+
return getEquationContent(element);
|
|
175
162
|
},
|
|
176
163
|
},
|
|
177
164
|
{
|
|
178
165
|
tag: 'disp-formula',
|
|
179
166
|
node: 'equation_element',
|
|
180
167
|
getAttrs: (node) => {
|
|
168
|
+
var _a, _b;
|
|
181
169
|
const element = node;
|
|
182
|
-
const caption = element.querySelector('figcaption');
|
|
183
170
|
return {
|
|
184
171
|
id: element.getAttribute('id'),
|
|
185
|
-
|
|
172
|
+
label: (_b = (_a = element.querySelector('label')) === null || _a === void 0 ? void 0 : _a.textContent) !== null && _b !== void 0 ? _b : '',
|
|
186
173
|
};
|
|
187
174
|
},
|
|
188
175
|
getContent: (node, schema) => {
|
|
189
|
-
var _a, _b, _c, _d, _e;
|
|
190
176
|
const element = node;
|
|
191
|
-
const attrs =
|
|
192
|
-
|
|
193
|
-
SVGStringRepresentation: '',
|
|
194
|
-
TeXRepresentation: '',
|
|
195
|
-
};
|
|
196
|
-
const container = (_a = element.querySelector('alternatives')) !== null && _a !== void 0 ? _a : element;
|
|
197
|
-
for (const child of container.childNodes) {
|
|
198
|
-
const nodeName = child.nodeName.replace(/^[a-z]:/, '');
|
|
199
|
-
switch (nodeName) {
|
|
200
|
-
case 'tex-math':
|
|
201
|
-
attrs.TeXRepresentation = (_c = (_b = child.textContent) === null || _b === void 0 ? void 0 : _b.trim()) !== null && _c !== void 0 ? _c : '';
|
|
202
|
-
if (attrs.TeXRepresentation) {
|
|
203
|
-
attrs.SVGStringRepresentation =
|
|
204
|
-
(_d = convertTeXToSVG(attrs.TeXRepresentation, true)) !== null && _d !== void 0 ? _d : '';
|
|
205
|
-
}
|
|
206
|
-
break;
|
|
207
|
-
case 'mml:math':
|
|
208
|
-
;
|
|
209
|
-
child.removeAttribute('id');
|
|
210
|
-
attrs.MathMLStringRepresentation =
|
|
211
|
-
xmlSerializer.serializeToString(child);
|
|
212
|
-
if (attrs.MathMLStringRepresentation) {
|
|
213
|
-
attrs.SVGStringRepresentation =
|
|
214
|
-
(_e = convertMathMLToSVG(attrs.MathMLStringRepresentation, true)) !== null && _e !== void 0 ? _e : '';
|
|
215
|
-
}
|
|
216
|
-
break;
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
const caption = element.querySelector('figcaption');
|
|
220
|
-
const figcaption = schema.nodes.figcaption.create();
|
|
177
|
+
const attrs = getEquationContent(element);
|
|
178
|
+
const id = element.getAttribute('id');
|
|
221
179
|
return Fragment.from([
|
|
222
|
-
schema.nodes.equation.createChecked(attrs),
|
|
223
|
-
caption
|
|
224
|
-
?
|
|
225
|
-
jatsBodyDOMParser.parse(caption, {
|
|
226
|
-
topNode: figcaption,
|
|
227
|
-
})
|
|
228
|
-
: figcaption,
|
|
180
|
+
schema.nodes.equation.createChecked(Object.assign({ id }, attrs)),
|
|
229
181
|
]);
|
|
230
182
|
},
|
|
231
183
|
},
|
|
@@ -424,6 +376,25 @@ const nodes = [
|
|
|
424
376
|
tag: 'sec[sec-type="keywords"]',
|
|
425
377
|
node: 'keywords',
|
|
426
378
|
},
|
|
379
|
+
{
|
|
380
|
+
tag: 'sec[sec-type="supplementary-material"]',
|
|
381
|
+
node: 'supplements',
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
tag: 'supplementary-material',
|
|
385
|
+
node: 'supplement',
|
|
386
|
+
getAttrs: (node) => {
|
|
387
|
+
var _a;
|
|
388
|
+
const element = node;
|
|
389
|
+
return {
|
|
390
|
+
id: element.getAttribute('id'),
|
|
391
|
+
href: element.getAttributeNS(XLINK_NAMESPACE, 'href'),
|
|
392
|
+
mimeType: element.getAttribute('mimetype'),
|
|
393
|
+
mimeSubType: element.getAttribute('mime-subtype'),
|
|
394
|
+
title: (_a = element.querySelector('title')) === null || _a === void 0 ? void 0 : _a.textContent,
|
|
395
|
+
};
|
|
396
|
+
},
|
|
397
|
+
},
|
|
427
398
|
{
|
|
428
399
|
tag: 'sec[sec-type="abstracts"]',
|
|
429
400
|
node: 'abstracts',
|
|
@@ -520,7 +491,7 @@ const nodes = [
|
|
|
520
491
|
{
|
|
521
492
|
tag: 'title',
|
|
522
493
|
node: 'section_title',
|
|
523
|
-
context: 'section/|footnotes_section/|bibliography_section/|keywords/',
|
|
494
|
+
context: 'section/|footnotes_section/|bibliography_section/|keywords/|supplements/',
|
|
524
495
|
},
|
|
525
496
|
{
|
|
526
497
|
tag: 'title',
|
|
@@ -284,4 +284,18 @@ export const jatsBodyTransformations = {
|
|
|
284
284
|
body.prepend(section);
|
|
285
285
|
}
|
|
286
286
|
},
|
|
287
|
+
createSuppleMaterials(document, body, createElement) {
|
|
288
|
+
const suppleMaterials = [
|
|
289
|
+
...document.querySelectorAll('article-meta > supplementary-material'),
|
|
290
|
+
];
|
|
291
|
+
if (suppleMaterials.length > 0) {
|
|
292
|
+
const section = createElement('sec');
|
|
293
|
+
section.setAttribute('sec-type', 'supplementary-material');
|
|
294
|
+
const title = createElement('title');
|
|
295
|
+
title.textContent = 'supplementary-material';
|
|
296
|
+
section.append(title);
|
|
297
|
+
section.append(...suppleMaterials);
|
|
298
|
+
body.prepend(section);
|
|
299
|
+
}
|
|
300
|
+
},
|
|
287
301
|
};
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import debug from 'debug';
|
|
17
17
|
import { getTrimmedTextContent } from '../../lib/utils';
|
|
18
|
-
import { buildAffiliation, buildBibliographicName, buildContributor, buildCorresp, buildFootnote, buildJournal,
|
|
18
|
+
import { buildAffiliation, buildBibliographicName, buildContributor, buildCorresp, buildFootnote, buildJournal, buildTitles, } from '../../transformer';
|
|
19
19
|
import { parseJournalMeta } from './jats-journal-meta-parser';
|
|
20
20
|
import { htmlFromJatsNode } from './jats-parser-utils';
|
|
21
21
|
const warn = debug('manuscripts-transform');
|
|
@@ -122,25 +122,6 @@ export const jatsFrontParser = {
|
|
|
122
122
|
}
|
|
123
123
|
return history;
|
|
124
124
|
},
|
|
125
|
-
parseSupplements(elements) {
|
|
126
|
-
var _a, _b, _c, _d;
|
|
127
|
-
if (!(elements === null || elements === void 0 ? void 0 : elements.length)) {
|
|
128
|
-
return [];
|
|
129
|
-
}
|
|
130
|
-
const supplements = [];
|
|
131
|
-
for (const element of elements) {
|
|
132
|
-
const title = (_a = getTrimmedTextContent(element, 'caption > title')) !== null && _a !== void 0 ? _a : '';
|
|
133
|
-
const href = (_b = element.getAttributeNS(XLINK_NAMESPACE, 'href')) !== null && _b !== void 0 ? _b : '';
|
|
134
|
-
const supplement = buildSupplementaryMaterial(title, href);
|
|
135
|
-
const mimeType = (_c = element.getAttribute('mimetype')) !== null && _c !== void 0 ? _c : '';
|
|
136
|
-
const mimeSubtype = (_d = element.getAttribute('mime-subtype')) !== null && _d !== void 0 ? _d : '';
|
|
137
|
-
if (mimeType && mimeSubtype) {
|
|
138
|
-
supplement.MIME = [mimeType, mimeSubtype].join('/');
|
|
139
|
-
}
|
|
140
|
-
supplements.push(supplement);
|
|
141
|
-
}
|
|
142
|
-
return supplements;
|
|
143
|
-
},
|
|
144
125
|
parseAffiliations(elements) {
|
|
145
126
|
const affiliationIDs = new Map();
|
|
146
127
|
const affiliations = elements.map((element, priority) => {
|
|
@@ -40,9 +40,6 @@ export const parseJATSFront = (doc, front) => {
|
|
|
40
40
|
const authors = jatsFrontParser.parseContributors([
|
|
41
41
|
...front.querySelectorAll('article-meta > contrib-group > contrib[contrib-type="author"]'),
|
|
42
42
|
], affiliationIDs, footnoteIDs, correspondingIDs);
|
|
43
|
-
const supplements = jatsFrontParser.parseSupplements([
|
|
44
|
-
...front.querySelectorAll('article-meta > supplementary-material'),
|
|
45
|
-
]);
|
|
46
43
|
const history = jatsFrontParser.parseDates(front.querySelector('article-meta > history'));
|
|
47
44
|
const counts = jatsFrontParser.parseCounts(front.querySelector('article-meta counts'));
|
|
48
45
|
const manuscript = Object.assign(Object.assign(Object.assign({}, buildManuscript()), counts), history);
|
|
@@ -54,7 +51,6 @@ export const parseJATSFront = (doc, front) => {
|
|
|
54
51
|
...authors,
|
|
55
52
|
...affiliations,
|
|
56
53
|
...correspondingList,
|
|
57
|
-
...supplements,
|
|
58
54
|
]);
|
|
59
55
|
};
|
|
60
56
|
export const parseJATSBody = (doc, body, references) => {
|
|
@@ -65,6 +61,7 @@ export const parseJATSBody = (doc, body, references) => {
|
|
|
65
61
|
jatsBodyTransformations.createBody(doc, body, createElement);
|
|
66
62
|
jatsBodyTransformations.createAbstracts(doc, body, createElement);
|
|
67
63
|
jatsBodyTransformations.createBackmatter(doc, body, createElement);
|
|
64
|
+
jatsBodyTransformations.createSuppleMaterials(doc, body, createElement);
|
|
68
65
|
jatsBodyTransformations.createKeywords(doc, body, createElement);
|
|
69
66
|
const node = jatsBodyDOMParser.parse(body).firstChild;
|
|
70
67
|
if (!node) {
|
|
@@ -156,6 +156,7 @@ export class JATSExporter {
|
|
|
156
156
|
};
|
|
157
157
|
this.nodeFromJATS = (JATSFragment) => {
|
|
158
158
|
JATSFragment = JATSFragment.trim();
|
|
159
|
+
JATSFragment = JATSFragment.replace(' ', ' ');
|
|
159
160
|
if (!JATSFragment.length) {
|
|
160
161
|
return null;
|
|
161
162
|
}
|
|
@@ -620,6 +621,8 @@ export class JATSExporter {
|
|
|
620
621
|
body: () => ['body', 0],
|
|
621
622
|
abstracts: () => ['abstract', 0],
|
|
622
623
|
backmatter: () => ['backmatter', 0],
|
|
624
|
+
supplement: () => '',
|
|
625
|
+
supplements: () => '',
|
|
623
626
|
bibliography_section: (node) => [
|
|
624
627
|
'ref-list',
|
|
625
628
|
{ id: normalizeID(node.attrs.id) },
|
|
@@ -676,22 +679,23 @@ export class JATSExporter {
|
|
|
676
679
|
},
|
|
677
680
|
doc: () => '',
|
|
678
681
|
equation: (node) => {
|
|
679
|
-
const
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
682
|
+
const math = this.nodeFromJATS(node.attrs.contents);
|
|
683
|
+
const mathEl = math;
|
|
684
|
+
mathEl.setAttribute('id', normalizeID(node.attrs.id));
|
|
685
|
+
return mathEl;
|
|
686
|
+
},
|
|
687
|
+
inline_equation: (node) => {
|
|
688
|
+
const eqElement = this.document.createElement('inline-formula');
|
|
689
|
+
const math = this.nodeFromJATS(node.attrs.contents);
|
|
690
|
+
eqElement.append(math);
|
|
691
|
+
return eqElement;
|
|
692
|
+
},
|
|
693
|
+
equation_element: (node) => {
|
|
694
|
+
const eqElement = this.document.createElement('disp-formula');
|
|
695
|
+
eqElement.setAttribute('id', normalizeID(node.attrs.id));
|
|
696
|
+
processChildNodes(eqElement, node, schema.nodes.equation);
|
|
697
|
+
return eqElement;
|
|
693
698
|
},
|
|
694
|
-
equation_element: (node) => createFigureElement(node, 'fig', node.type.schema.nodes.equation, 'equation'),
|
|
695
699
|
figcaption: (node) => {
|
|
696
700
|
if (!node.textContent) {
|
|
697
701
|
return '';
|
|
@@ -741,28 +745,6 @@ export class JATSExporter {
|
|
|
741
745
|
},
|
|
742
746
|
hard_break: () => '',
|
|
743
747
|
highlight_marker: () => '',
|
|
744
|
-
inline_equation: (node) => {
|
|
745
|
-
const formula = this.document.createElement('inline-formula');
|
|
746
|
-
formula.setAttribute('id', normalizeID(node.attrs.id));
|
|
747
|
-
if (node.attrs.TeXRepresentation) {
|
|
748
|
-
const math = this.document.createElement('tex-math');
|
|
749
|
-
math.textContent = node.attrs.TeXRepresentation;
|
|
750
|
-
formula.appendChild(math);
|
|
751
|
-
}
|
|
752
|
-
else if (node.attrs.MathMLRepresentation) {
|
|
753
|
-
const math = this.nodeFromJATS(node.attrs.MathMLRepresentation);
|
|
754
|
-
if (math) {
|
|
755
|
-
formula.appendChild(math);
|
|
756
|
-
}
|
|
757
|
-
}
|
|
758
|
-
else if (node.attrs.SVGRepresentation) {
|
|
759
|
-
const math = this.nodeFromJATS(node.attrs.SVGRepresentation);
|
|
760
|
-
if (math) {
|
|
761
|
-
formula.appendChild(math);
|
|
762
|
-
}
|
|
763
|
-
}
|
|
764
|
-
return formula;
|
|
765
|
-
},
|
|
766
748
|
inline_footnote: (node) => {
|
|
767
749
|
const xref = this.document.createElement('xref');
|
|
768
750
|
xref.setAttribute('ref-type', 'fn');
|