@manuscripts/transform 4.3.21 → 4.3.23
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/README.md +2 -2
- package/dist/cjs/jats/__tests__/jats-exporter.test.js +11 -45
- package/dist/cjs/jats/__tests__/jats-importer.test.js +54 -76
- package/dist/cjs/jats/__tests__/jats-roundtrip.test.js +1 -2
- package/dist/cjs/jats/__tests__/utils.js +4 -17
- package/dist/cjs/jats/exporter/jats-exporter.js +190 -271
- package/dist/cjs/jats/importer/jats-dom-parser.js +16 -42
- package/dist/cjs/jats/importer/jats-parser-utils.js +5 -29
- package/dist/cjs/jats/importer/parse-jats-article.js +1 -6
- package/dist/cjs/schema/__tests__/docs.js +1830 -0
- package/dist/cjs/schema/__tests__/migration.test.js +3 -37
- package/dist/cjs/schema/migration/migration-scripts/4.3.12.js +39 -0
- package/dist/cjs/schema/migration/migration-scripts/index.js +2 -0
- package/dist/cjs/schema/nodes/blockquote_element.js +0 -2
- package/dist/cjs/schema/nodes/comment.js +2 -1
- package/dist/cjs/schema/nodes/contributor.js +11 -11
- package/dist/cjs/schema/nodes/equation.js +1 -3
- package/dist/cjs/schema/nodes/list.js +0 -2
- package/dist/cjs/schema/nodes/listing.js +1 -3
- package/dist/cjs/schema/nodes/paragraph.js +0 -2
- package/dist/cjs/schema/nodes/pullquote_element.js +0 -2
- package/dist/cjs/transformer/id.js +2 -14
- package/dist/cjs/transformer/node-names.js +6 -1
- package/dist/cjs/transformer/node-types.js +1 -47
- package/dist/cjs/version.js +1 -1
- package/dist/es/jats/__tests__/jats-exporter.test.js +11 -45
- package/dist/es/jats/__tests__/jats-importer.test.js +54 -76
- package/dist/es/jats/__tests__/jats-roundtrip.test.js +1 -2
- package/dist/es/jats/__tests__/utils.js +4 -17
- package/dist/es/jats/exporter/jats-exporter.js +190 -271
- package/dist/es/jats/importer/jats-dom-parser.js +16 -42
- package/dist/es/jats/importer/jats-parser-utils.js +6 -30
- package/dist/es/jats/importer/parse-jats-article.js +1 -6
- package/dist/es/schema/__tests__/docs.js +1827 -0
- package/dist/es/schema/__tests__/migration.test.js +3 -4
- package/dist/es/schema/migration/migration-scripts/4.3.12.js +37 -0
- package/dist/es/schema/migration/migration-scripts/index.js +2 -0
- package/dist/es/schema/nodes/blockquote_element.js +0 -2
- package/dist/es/schema/nodes/comment.js +2 -1
- package/dist/es/schema/nodes/contributor.js +11 -11
- package/dist/es/schema/nodes/equation.js +1 -3
- package/dist/es/schema/nodes/list.js +0 -2
- package/dist/es/schema/nodes/listing.js +1 -3
- package/dist/es/schema/nodes/paragraph.js +0 -2
- package/dist/es/schema/nodes/pullquote_element.js +0 -2
- package/dist/es/transformer/id.js +2 -14
- package/dist/es/transformer/node-names.js +4 -0
- package/dist/es/transformer/node-types.js +1 -47
- package/dist/es/version.js +1 -1
- package/dist/types/jats/__tests__/utils.d.ts +1 -11
- package/dist/types/jats/exporter/jats-exporter.d.ts +5 -10
- package/dist/types/jats/importer/jats-dom-parser.d.ts +0 -15
- package/dist/types/jats/importer/parse-jats-article.d.ts +1 -11
- package/dist/types/schema/__tests__/docs.d.ts +2 -0
- package/dist/types/schema/migration/migration-scripts/4.3.12.d.ts +8 -0
- package/dist/types/schema/migration/migration-scripts/index.d.ts +2 -1
- package/dist/types/schema/nodes/comment.d.ts +2 -2
- package/dist/types/schema/nodes/contributor.d.ts +11 -21
- package/dist/types/schema/types.d.ts +22 -0
- package/dist/types/transformer/node-names.d.ts +1 -0
- package/dist/types/transformer/node-types.d.ts +0 -2
- package/dist/types/version.d.ts +1 -1
- package/package.json +2 -2
- package/dist/cjs/jats/importer/jats-journal-meta-parser.js +0 -103
- package/dist/cjs/lib/styled-content.js +0 -28
- package/dist/es/jats/importer/jats-journal-meta-parser.js +0 -95
- package/dist/es/lib/styled-content.js +0 -23
- package/dist/types/jats/importer/jats-journal-meta-parser.d.ts +0 -46
- package/dist/types/lib/styled-content.d.ts +0 -22
|
@@ -1,22 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/*!
|
|
3
|
-
* © 2020 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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
3
|
exports.JATSDOMParser = void 0;
|
|
19
|
-
const json_schema_1 = require("@manuscripts/json-schema");
|
|
20
4
|
const prosemirror_model_1 = require("prosemirror-model");
|
|
21
5
|
const utils_1 = require("../../lib/utils");
|
|
22
6
|
const xml_1 = require("../../lib/xml");
|
|
@@ -307,7 +291,8 @@ class JATSDOMParser {
|
|
|
307
291
|
id: element.getAttribute('id'),
|
|
308
292
|
target: element.getAttribute('target-id'),
|
|
309
293
|
contents: (0, utils_1.getTrimmedTextContent)(element),
|
|
310
|
-
|
|
294
|
+
userID: jats_comments_1.DEFAULT_PROFILE_ID,
|
|
295
|
+
timestamp: Date.now(),
|
|
311
296
|
};
|
|
312
297
|
},
|
|
313
298
|
},
|
|
@@ -381,9 +366,9 @@ class JATSDOMParser {
|
|
|
381
366
|
node: 'contributor',
|
|
382
367
|
getAttrs: (node) => {
|
|
383
368
|
const element = node;
|
|
384
|
-
const
|
|
385
|
-
const
|
|
386
|
-
const
|
|
369
|
+
const footnoteIDs = [];
|
|
370
|
+
const affiliationIDs = [];
|
|
371
|
+
const correspIDs = [];
|
|
387
372
|
const xrefs = element.querySelectorAll('xref');
|
|
388
373
|
for (const xref of xrefs) {
|
|
389
374
|
const rid = xref.getAttribute('rid');
|
|
@@ -393,41 +378,30 @@ class JATSDOMParser {
|
|
|
393
378
|
}
|
|
394
379
|
switch (type) {
|
|
395
380
|
case 'fn':
|
|
396
|
-
|
|
397
|
-
noteID: rid,
|
|
398
|
-
noteLabel: (0, utils_1.getTrimmedTextContent)(xref) || '',
|
|
399
|
-
});
|
|
381
|
+
footnoteIDs.push(rid);
|
|
400
382
|
break;
|
|
401
383
|
case 'corresp':
|
|
402
|
-
|
|
403
|
-
correspID: rid,
|
|
404
|
-
correspLabel: (0, utils_1.getTrimmedTextContent)(xref) || '',
|
|
405
|
-
});
|
|
384
|
+
correspIDs.push(rid);
|
|
406
385
|
break;
|
|
407
386
|
case 'aff':
|
|
408
|
-
|
|
387
|
+
affiliationIDs.push(rid);
|
|
409
388
|
break;
|
|
410
389
|
}
|
|
411
390
|
}
|
|
412
391
|
return {
|
|
413
392
|
id: element.getAttribute('id') || undefined,
|
|
414
393
|
role: (0, utils_1.getTrimmedTextContent)(element, 'role'),
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
isCorresponding: element.getAttribute('corresp')
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
family: this.getSurname(element),
|
|
424
|
-
ObjectType: json_schema_1.ObjectTypes.BibliographicName,
|
|
425
|
-
},
|
|
426
|
-
ORCIDIdentifier: (0, utils_1.getTrimmedTextContent)(element, 'contrib-id[contrib-id-type="orcid"]'),
|
|
394
|
+
affiliationIDs,
|
|
395
|
+
correspIDs,
|
|
396
|
+
footnoteIDs,
|
|
397
|
+
isCorresponding: element.getAttribute('corresp') === 'yes',
|
|
398
|
+
given: (0, utils_1.getTrimmedTextContent)(element, 'given-names'),
|
|
399
|
+
family: this.getSurname(element),
|
|
400
|
+
prefix: (0, utils_1.getTrimmedTextContent)(element, 'prefix'),
|
|
401
|
+
ORCID: (0, utils_1.getTrimmedTextContent)(element, 'contrib-id[contrib-id-type="orcid"]'),
|
|
427
402
|
creditRoles: (0, utils_1.getCreditRole)(element),
|
|
428
403
|
priority: this.parsePriority(element.getAttribute('priority')),
|
|
429
404
|
email: (0, utils_1.getTrimmedTextContent)(element, 'email') || '',
|
|
430
|
-
prefix: (0, utils_1.getTrimmedTextContent)(element, 'prefix'),
|
|
431
405
|
};
|
|
432
406
|
},
|
|
433
407
|
getContent: () => {
|
|
@@ -81,37 +81,13 @@ const updateNodeRIDS = (node, replacements, warnings) => {
|
|
|
81
81
|
};
|
|
82
82
|
};
|
|
83
83
|
const updateContributorNodesIDS = (node, replacements, warnings) => {
|
|
84
|
-
if (
|
|
85
|
-
const
|
|
86
|
-
?.map((fn) => {
|
|
87
|
-
return replacements.get(fn.noteID)
|
|
88
|
-
? {
|
|
89
|
-
...fn,
|
|
90
|
-
noteID: replacements.get(fn.noteID),
|
|
91
|
-
}
|
|
92
|
-
: undefined;
|
|
93
|
-
})
|
|
94
|
-
.filter(Boolean);
|
|
95
|
-
const corresp = node.attrs.corresp
|
|
96
|
-
?.map((corresp) => {
|
|
97
|
-
return replacements.get(corresp.correspID)
|
|
98
|
-
? {
|
|
99
|
-
...corresp,
|
|
100
|
-
correspID: replacements.get(corresp.correspID),
|
|
101
|
-
}
|
|
102
|
-
: undefined;
|
|
103
|
-
})
|
|
104
|
-
.filter(Boolean);
|
|
105
|
-
const affiliations = node.attrs.affiliations
|
|
106
|
-
.map((affiliation) => {
|
|
107
|
-
return replacements.get(affiliation);
|
|
108
|
-
})
|
|
109
|
-
.filter(Boolean);
|
|
84
|
+
if ((0, schema_1.isContributorNode)(node)) {
|
|
85
|
+
const replaceAll = (ids) => ids?.map((i) => replacements.get(i)).filter((id) => !!id);
|
|
110
86
|
node.attrs = {
|
|
111
87
|
...node.attrs,
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
88
|
+
footnoteIDs: replaceAll(node.attrs.footnoteIDs),
|
|
89
|
+
correspIDs: replaceAll(node.attrs.correspIDs),
|
|
90
|
+
affiliationIDs: replaceAll(node.attrs.affiliationIDs),
|
|
115
91
|
};
|
|
116
92
|
}
|
|
117
93
|
if (node.type !== schema_1.schema.nodes.contributors) {
|
|
@@ -19,7 +19,6 @@ exports.parseJATSArticle = void 0;
|
|
|
19
19
|
const schema_1 = require("../../schema");
|
|
20
20
|
const jats_comments_1 = require("./jats-comments");
|
|
21
21
|
const jats_dom_parser_1 = require("./jats-dom-parser");
|
|
22
|
-
const jats_journal_meta_parser_1 = require("./jats-journal-meta-parser");
|
|
23
22
|
const jats_parser_utils_1 = require("./jats-parser-utils");
|
|
24
23
|
const jats_transformations_1 = require("./jats-transformations");
|
|
25
24
|
const processJATS = (doc, sectionCategories) => {
|
|
@@ -64,7 +63,6 @@ const processJATS = (doc, sectionCategories) => {
|
|
|
64
63
|
};
|
|
65
64
|
const createElementFn = (doc) => (tagName) => doc.createElement(tagName);
|
|
66
65
|
const parseJATSArticle = (doc, sectionCategories, template) => {
|
|
67
|
-
const journal = (0, jats_journal_meta_parser_1.parseJournal)(doc);
|
|
68
66
|
processJATS(doc, sectionCategories);
|
|
69
67
|
const node = new jats_dom_parser_1.JATSDOMParser(sectionCategories, schema_1.schema).parse(doc)
|
|
70
68
|
.firstChild;
|
|
@@ -75,9 +73,6 @@ const parseJATSArticle = (doc, sectionCategories, template) => {
|
|
|
75
73
|
if (template) {
|
|
76
74
|
node.attrs.prototype = template;
|
|
77
75
|
}
|
|
78
|
-
return
|
|
79
|
-
node,
|
|
80
|
-
journal,
|
|
81
|
-
};
|
|
76
|
+
return node;
|
|
82
77
|
};
|
|
83
78
|
exports.parseJATSArticle = parseJATSArticle;
|