@manuscripts/transform 1.4.6 → 1.5.0-LEAN-2852-9
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/jats/importer/jats-body-dom-parser.js +126 -0
- package/dist/cjs/jats/importer/jats-body-transformations.js +59 -0
- package/dist/cjs/jats/importer/jats-front-parser.js +7 -7
- package/dist/cjs/jats/importer/jats-parser-utils.js +4 -0
- package/dist/cjs/jats/importer/parse-jats-article.js +18 -7
- package/dist/cjs/jats/jats-exporter.js +10 -8
- package/dist/cjs/lib/core-section-categories.js +2 -2
- package/dist/cjs/schema/index.js +9 -6
- package/dist/cjs/schema/nodes/affiliation.js +3 -0
- package/dist/cjs/schema/nodes/affiliations_section.js +15 -0
- package/dist/cjs/schema/nodes/contributor.js +8 -1
- package/dist/cjs/schema/nodes/contributors_section.js +15 -0
- package/dist/cjs/schema/nodes/meta_section.js +1 -1
- package/dist/cjs/schema/nodes/titles.js +32 -0
- package/dist/cjs/transformer/builders.js +1 -2
- package/dist/cjs/transformer/decode.js +74 -23
- package/dist/cjs/transformer/encode.js +26 -0
- package/dist/cjs/transformer/html.js +6 -5
- package/dist/cjs/transformer/node-types.js +3 -0
- package/dist/cjs/transformer/project-bundle.js +22 -1
- package/dist/cjs/transformer/section-category.js +12 -0
- package/dist/es/jats/importer/jats-body-dom-parser.js +126 -0
- package/dist/es/jats/importer/jats-body-transformations.js +59 -0
- package/dist/es/jats/importer/jats-front-parser.js +1 -1
- package/dist/es/jats/importer/jats-parser-utils.js +4 -0
- package/dist/es/jats/importer/parse-jats-article.js +18 -7
- package/dist/es/jats/jats-exporter.js +11 -9
- package/dist/es/lib/core-section-categories.js +2 -2
- package/dist/es/schema/index.js +9 -6
- package/dist/es/schema/nodes/affiliation.js +3 -0
- package/dist/es/schema/nodes/affiliations_section.js +11 -0
- package/dist/es/schema/nodes/contributor.js +6 -0
- package/dist/es/schema/nodes/contributors_section.js +11 -0
- package/dist/es/schema/nodes/meta_section.js +1 -1
- package/dist/es/schema/nodes/titles.js +29 -0
- package/dist/es/transformer/builders.js +1 -2
- package/dist/es/transformer/decode.js +74 -23
- package/dist/es/transformer/encode.js +26 -0
- package/dist/es/transformer/html.js +7 -6
- package/dist/es/transformer/node-types.js +3 -0
- package/dist/es/transformer/project-bundle.js +20 -0
- package/dist/es/transformer/section-category.js +12 -0
- package/dist/types/jats/importer/jats-body-transformations.d.ts +4 -1
- package/dist/types/jats/importer/jats-front-parser.d.ts +5 -5
- package/dist/types/jats/importer/parse-jats-article.d.ts +5 -2
- package/dist/types/schema/index.d.ts +3 -2
- package/dist/types/schema/nodes/affiliation.d.ts +1 -0
- package/dist/types/schema/nodes/affiliations_section.d.ts +11 -0
- package/dist/types/schema/nodes/contributor.d.ts +2 -0
- package/dist/types/schema/nodes/contributors_section.d.ts +11 -0
- package/dist/types/schema/nodes/titles.d.ts +28 -0
- package/dist/types/schema/types.d.ts +1 -1
- package/dist/types/transformer/builders.d.ts +1 -1
- package/dist/types/transformer/decode.d.ts +4 -2
- package/dist/types/transformer/project-bundle.d.ts +2 -1
- package/dist/types/transformer/section-category.d.ts +2 -2
- package/package.json +3 -3
- package/dist/cjs/schema/nodes/affiliation_list.js +0 -10
- package/dist/cjs/schema/nodes/contributor_list.js +0 -10
- package/dist/es/schema/nodes/affiliation_list.js +0 -7
- package/dist/es/schema/nodes/contributor_list.js +0 -7
- package/dist/types/schema/nodes/affiliation_list.d.ts +0 -10
- package/dist/types/schema/nodes/contributor_list.d.ts +0 -10
|
@@ -505,6 +505,132 @@ const nodes = [
|
|
|
505
505
|
};
|
|
506
506
|
},
|
|
507
507
|
},
|
|
508
|
+
{
|
|
509
|
+
tag: 'sec[sec-type="affiliations"]',
|
|
510
|
+
node: 'affiliations_section',
|
|
511
|
+
getAttrs: (node) => {
|
|
512
|
+
const element = node;
|
|
513
|
+
return {
|
|
514
|
+
id: element.getAttribute('id'),
|
|
515
|
+
category: 'MPSectionCategory:affiliations',
|
|
516
|
+
};
|
|
517
|
+
},
|
|
518
|
+
},
|
|
519
|
+
{
|
|
520
|
+
tag: 'aff',
|
|
521
|
+
node: 'affiliation',
|
|
522
|
+
context: 'affiliations_section/',
|
|
523
|
+
getAttrs: (node) => {
|
|
524
|
+
const element = node;
|
|
525
|
+
const aff = {
|
|
526
|
+
id: element.getAttribute('id'),
|
|
527
|
+
};
|
|
528
|
+
const institution = element.getAttribute('institution');
|
|
529
|
+
if (institution) {
|
|
530
|
+
aff.institution = institution;
|
|
531
|
+
}
|
|
532
|
+
const email = element.getAttribute('email');
|
|
533
|
+
if (email) {
|
|
534
|
+
aff.bibliographicName = JSON.parse(email);
|
|
535
|
+
}
|
|
536
|
+
const department = element.getAttribute('department');
|
|
537
|
+
if (department) {
|
|
538
|
+
aff.department = department;
|
|
539
|
+
}
|
|
540
|
+
const addressLine1 = element.getAttribute('addressLine1');
|
|
541
|
+
if (addressLine1) {
|
|
542
|
+
aff.addressLine1 = addressLine1;
|
|
543
|
+
}
|
|
544
|
+
const addressLine2 = element.getAttribute('addressLine2');
|
|
545
|
+
if (addressLine2) {
|
|
546
|
+
aff.addressLine2 = addressLine2;
|
|
547
|
+
}
|
|
548
|
+
const addressLine3 = element.getAttribute('addressLine3');
|
|
549
|
+
if (addressLine3) {
|
|
550
|
+
aff.addressLine3 = addressLine3;
|
|
551
|
+
}
|
|
552
|
+
const postCode = element.getAttribute('postCode');
|
|
553
|
+
if (postCode) {
|
|
554
|
+
aff.postCode = postCode;
|
|
555
|
+
}
|
|
556
|
+
const country = element.getAttribute('country');
|
|
557
|
+
if (country) {
|
|
558
|
+
aff.country = country;
|
|
559
|
+
}
|
|
560
|
+
const priority = element.getAttribute('priority');
|
|
561
|
+
if (priority) {
|
|
562
|
+
aff.priority = parseInt(priority);
|
|
563
|
+
}
|
|
564
|
+
return aff;
|
|
565
|
+
},
|
|
566
|
+
},
|
|
567
|
+
{
|
|
568
|
+
tag: 'sec[sec-type="contributors"]',
|
|
569
|
+
node: 'contributors_section',
|
|
570
|
+
getAttrs: (node) => {
|
|
571
|
+
const element = node;
|
|
572
|
+
return {
|
|
573
|
+
id: element.getAttribute('id'),
|
|
574
|
+
category: 'MPSectionCategory:contributors',
|
|
575
|
+
};
|
|
576
|
+
},
|
|
577
|
+
},
|
|
578
|
+
{
|
|
579
|
+
tag: 'contrib',
|
|
580
|
+
node: 'contributor',
|
|
581
|
+
context: 'contributors_section/',
|
|
582
|
+
getAttrs: (node) => {
|
|
583
|
+
const element = node;
|
|
584
|
+
const contrib = {
|
|
585
|
+
id: element.getAttribute('id'),
|
|
586
|
+
};
|
|
587
|
+
const role = element.getAttribute('role');
|
|
588
|
+
if (role) {
|
|
589
|
+
contrib.role = role;
|
|
590
|
+
}
|
|
591
|
+
const affiliations = element.getAttribute('affiliations');
|
|
592
|
+
if (affiliations) {
|
|
593
|
+
contrib.affiliations = JSON.parse(affiliations);
|
|
594
|
+
}
|
|
595
|
+
const footnote = element.getAttribute('footnote');
|
|
596
|
+
if (footnote) {
|
|
597
|
+
contrib.footnote = JSON.parse(footnote);
|
|
598
|
+
}
|
|
599
|
+
const corresp = element.getAttribute('corresp');
|
|
600
|
+
if (corresp) {
|
|
601
|
+
contrib.corresp = JSON.parse(corresp);
|
|
602
|
+
}
|
|
603
|
+
const bibliographicName = element.getAttribute('bibliographicName');
|
|
604
|
+
if (bibliographicName) {
|
|
605
|
+
contrib.bibliographicName = JSON.parse(bibliographicName);
|
|
606
|
+
}
|
|
607
|
+
const userID = element.getAttribute('userID');
|
|
608
|
+
if (userID) {
|
|
609
|
+
contrib.userID = userID;
|
|
610
|
+
}
|
|
611
|
+
const priority = element.getAttribute('priority');
|
|
612
|
+
if (priority) {
|
|
613
|
+
contrib.priority = parseInt(priority);
|
|
614
|
+
}
|
|
615
|
+
const invitationID = element.getAttribute('invitationID');
|
|
616
|
+
if (invitationID) {
|
|
617
|
+
contrib.invitationID = invitationID;
|
|
618
|
+
}
|
|
619
|
+
const objectType = element.getAttribute('objectType');
|
|
620
|
+
if (objectType) {
|
|
621
|
+
contrib.objectType = objectType;
|
|
622
|
+
}
|
|
623
|
+
const isCorresponding = element.getAttribute('isCorresponding');
|
|
624
|
+
if (isCorresponding) {
|
|
625
|
+
contrib.isCorresponding = JSON.parse(isCorresponding);
|
|
626
|
+
}
|
|
627
|
+
const ORCIDIdentifier = element.getAttribute('ORCIDIdentifier');
|
|
628
|
+
if (ORCIDIdentifier) {
|
|
629
|
+
contrib.ORCIDIdentifier = ORCIDIdentifier;
|
|
630
|
+
}
|
|
631
|
+
return contrib;
|
|
632
|
+
},
|
|
633
|
+
},
|
|
508
634
|
{
|
|
509
635
|
tag: 'sec[sec-type="keywords"]',
|
|
510
636
|
node: 'keywords_section',
|
|
@@ -284,6 +284,65 @@ exports.jatsBodyTransformations = {
|
|
|
284
284
|
}
|
|
285
285
|
}
|
|
286
286
|
},
|
|
287
|
+
moveAffiliationsToBody(doc, affiliations, body, createElement) {
|
|
288
|
+
if (affiliations === null || affiliations === void 0 ? void 0 : affiliations.length) {
|
|
289
|
+
const section = createElement('sec');
|
|
290
|
+
section.setAttribute('sec-type', 'affiliations');
|
|
291
|
+
affiliations.forEach((affiliation) => {
|
|
292
|
+
const item = doc.createElement('aff');
|
|
293
|
+
item.setAttribute('id', affiliation._id);
|
|
294
|
+
affiliation.institution &&
|
|
295
|
+
item.setAttribute('institution', affiliation.institution);
|
|
296
|
+
affiliation.email &&
|
|
297
|
+
item.setAttribute('email', JSON.stringify(affiliation.email));
|
|
298
|
+
affiliation.department &&
|
|
299
|
+
item.setAttribute('department', affiliation.department);
|
|
300
|
+
affiliation.addressLine1 &&
|
|
301
|
+
item.setAttribute('addressLine1', affiliation.addressLine1);
|
|
302
|
+
affiliation.addressLine2 &&
|
|
303
|
+
item.setAttribute('addressLine2', affiliation.addressLine2);
|
|
304
|
+
affiliation.addressLine3 &&
|
|
305
|
+
item.setAttribute('addressLine3', affiliation.addressLine3);
|
|
306
|
+
affiliation.postCode &&
|
|
307
|
+
item.setAttribute('postCode', affiliation.postCode);
|
|
308
|
+
affiliation.country && item.setAttribute('country', affiliation.country);
|
|
309
|
+
(affiliation.priority === 0 || affiliation.priority) &&
|
|
310
|
+
item.setAttribute('priority', affiliation.priority.toString());
|
|
311
|
+
section.appendChild(item);
|
|
312
|
+
});
|
|
313
|
+
body.prepend(section);
|
|
314
|
+
}
|
|
315
|
+
},
|
|
316
|
+
moveAuthorsToBody(doc, authors, body, createElement) {
|
|
317
|
+
if (authors === null || authors === void 0 ? void 0 : authors.length) {
|
|
318
|
+
const section = createElement('sec');
|
|
319
|
+
section.setAttribute('sec-type', 'contributors');
|
|
320
|
+
authors.forEach((author) => {
|
|
321
|
+
const item = doc.createElement('contrib');
|
|
322
|
+
item.setAttribute('id', author._id);
|
|
323
|
+
author.role && item.setAttribute('role', author.role);
|
|
324
|
+
author.affiliations &&
|
|
325
|
+
item.setAttribute('affiliations', JSON.stringify(author.affiliations));
|
|
326
|
+
author.footnote &&
|
|
327
|
+
item.setAttribute('footnote', JSON.stringify(author.footnote));
|
|
328
|
+
author.corresp &&
|
|
329
|
+
item.setAttribute('corresp', JSON.stringify(author.corresp));
|
|
330
|
+
author.bibliographicName &&
|
|
331
|
+
item.setAttribute('bibliographicName', JSON.stringify(author.bibliographicName));
|
|
332
|
+
author.userID && item.setAttribute('userID', author.userID);
|
|
333
|
+
author.invitationID &&
|
|
334
|
+
item.setAttribute('invitationID', author.invitationID);
|
|
335
|
+
author.isCorresponding &&
|
|
336
|
+
item.setAttribute('isCorresponding', JSON.stringify(author.isCorresponding));
|
|
337
|
+
author.ORCIDIdentifier &&
|
|
338
|
+
item.setAttribute('ORCIDIdentifier', author.ORCIDIdentifier);
|
|
339
|
+
(author.priority === 0 || author.priority) &&
|
|
340
|
+
item.setAttribute('priority', author.priority.toString());
|
|
341
|
+
section.appendChild(item);
|
|
342
|
+
});
|
|
343
|
+
body.prepend(section);
|
|
344
|
+
}
|
|
345
|
+
},
|
|
287
346
|
moveFloatsGroupToBody(doc, body, createElement) {
|
|
288
347
|
const floatsGroup = doc.querySelector('floats-group');
|
|
289
348
|
if (floatsGroup) {
|
|
@@ -21,7 +21,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
21
21
|
exports.jatsFrontParser = void 0;
|
|
22
22
|
const debug_1 = __importDefault(require("debug"));
|
|
23
23
|
const utils_1 = require("../../lib/utils");
|
|
24
|
-
const
|
|
24
|
+
const transformer_1 = require("../../transformer");
|
|
25
25
|
const jats_journal_meta_parser_1 = require("./jats-journal-meta-parser");
|
|
26
26
|
const warn = (0, debug_1.default)('manuscripts-transform');
|
|
27
27
|
const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
|
|
@@ -126,7 +126,7 @@ exports.jatsFrontParser = {
|
|
|
126
126
|
for (const supplementNode of supplementNodes) {
|
|
127
127
|
const supplTitle = (_a = (0, utils_1.getTrimmedTextContent)(supplementNode, 'caption > title')) !== null && _a !== void 0 ? _a : '';
|
|
128
128
|
const href = (_b = supplementNode.getAttributeNS(XLINK_NAMESPACE, 'href')) !== null && _b !== void 0 ? _b : '';
|
|
129
|
-
const supplementaryMaterial = (0,
|
|
129
|
+
const supplementaryMaterial = (0, transformer_1.buildSupplementaryMaterial)(supplTitle, href);
|
|
130
130
|
const mimeType = (_c = supplementNode.getAttribute('mimetype')) !== null && _c !== void 0 ? _c : '';
|
|
131
131
|
const mimeSubtype = (_d = supplementNode.getAttribute('mime-subtype')) !== null && _d !== void 0 ? _d : '';
|
|
132
132
|
if (mimeType && mimeSubtype) {
|
|
@@ -140,7 +140,7 @@ exports.jatsFrontParser = {
|
|
|
140
140
|
const affiliationIDs = new Map();
|
|
141
141
|
const affiliations = affiliationNodes.map((affiliationNode, priority) => {
|
|
142
142
|
var _a, _b;
|
|
143
|
-
const affiliation = (0,
|
|
143
|
+
const affiliation = (0, transformer_1.buildAffiliation)('', priority);
|
|
144
144
|
for (const node of affiliationNode.querySelectorAll('institution')) {
|
|
145
145
|
const content = (_a = node.textContent) === null || _a === void 0 ? void 0 : _a.trim();
|
|
146
146
|
if (!content) {
|
|
@@ -190,7 +190,7 @@ exports.jatsFrontParser = {
|
|
|
190
190
|
parseFootnoteNodes(footnoteNodes) {
|
|
191
191
|
const footnoteIDs = new Map();
|
|
192
192
|
const footnotes = footnoteNodes.map((footnoteNode) => {
|
|
193
|
-
const fn = (0,
|
|
193
|
+
const fn = (0, transformer_1.buildFootnote)('', footnoteNode.innerHTML);
|
|
194
194
|
const id = footnoteNode.getAttribute('id');
|
|
195
195
|
if (id) {
|
|
196
196
|
footnoteIDs.set(id, fn._id);
|
|
@@ -210,7 +210,7 @@ exports.jatsFrontParser = {
|
|
|
210
210
|
if (label) {
|
|
211
211
|
label.remove();
|
|
212
212
|
}
|
|
213
|
-
const corresponding = (0,
|
|
213
|
+
const corresponding = (0, transformer_1.buildCorresp)((_b = (_a = correspNode.textContent) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : '');
|
|
214
214
|
corresponding.label = ((_c = label === null || label === void 0 ? void 0 : label.textContent) === null || _c === void 0 ? void 0 : _c.trim()) || undefined;
|
|
215
215
|
const id = correspNode.getAttribute('id');
|
|
216
216
|
if (id) {
|
|
@@ -226,7 +226,7 @@ exports.jatsFrontParser = {
|
|
|
226
226
|
parseAuthorNodes(authorNodes, affiliationIDs, footnoteIDs, correspondingIDs) {
|
|
227
227
|
return authorNodes.map((authorNode, priority) => {
|
|
228
228
|
var _a, _b;
|
|
229
|
-
const name = (0,
|
|
229
|
+
const name = (0, transformer_1.buildBibliographicName)({});
|
|
230
230
|
const given = (0, utils_1.getTrimmedTextContent)(authorNode, 'name > given-names');
|
|
231
231
|
if (given) {
|
|
232
232
|
name.given = given;
|
|
@@ -235,7 +235,7 @@ exports.jatsFrontParser = {
|
|
|
235
235
|
if (surname) {
|
|
236
236
|
name.family = surname;
|
|
237
237
|
}
|
|
238
|
-
const contributor = (0,
|
|
238
|
+
const contributor = (0, transformer_1.buildContributor)(name, 'author', priority);
|
|
239
239
|
const corresponding = authorNode.getAttribute('corresp') === 'yes';
|
|
240
240
|
if (corresponding) {
|
|
241
241
|
contributor.isCorresponding = corresponding;
|
|
@@ -19,6 +19,7 @@ exports.htmlFromJatsNode = exports.fixBodyPMNode = exports.flatten = void 0;
|
|
|
19
19
|
const json_schema_1 = require("@manuscripts/json-schema");
|
|
20
20
|
const transformer_1 = require("../../transformer");
|
|
21
21
|
const isAuxiliaryObjectReference = (0, transformer_1.hasObjectType)(json_schema_1.ObjectTypes.AuxiliaryObjectReference);
|
|
22
|
+
const excludedObjectTypes = [json_schema_1.ObjectTypes.Contributor, json_schema_1.ObjectTypes.Affiliation];
|
|
22
23
|
function flatten(arrays) {
|
|
23
24
|
return [].concat(...arrays);
|
|
24
25
|
}
|
|
@@ -49,6 +50,9 @@ const addMissingID = (node, replacements, warnings) => {
|
|
|
49
50
|
warnings.push(`Unknown object type for node type ${node.type.name}`);
|
|
50
51
|
return;
|
|
51
52
|
}
|
|
53
|
+
if (excludedObjectTypes.includes(objectType)) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
52
56
|
const previousID = node.attrs.id;
|
|
53
57
|
const nextID = (0, transformer_1.generateID)(objectType);
|
|
54
58
|
if (previousID) {
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.getElementsOrder = exports.parseJATSArticle = exports.parseJATSBody = exports.parseJATSReferences = exports.parseJATSFront = void 0;
|
|
19
|
+
const json_schema_1 = require("@manuscripts/json-schema");
|
|
19
20
|
const prosemirror_model_1 = require("prosemirror-model");
|
|
20
21
|
const errors_1 = require("../../errors");
|
|
21
22
|
const html_1 = require("../../lib/html");
|
|
@@ -51,9 +52,16 @@ const parseJATSFront = async (front) => {
|
|
|
51
52
|
const title = (_a = articleMeta === null || articleMeta === void 0 ? void 0 : articleMeta.querySelector('title-group > article-title')) === null || _a === void 0 ? void 0 : _a.innerHTML;
|
|
52
53
|
const subtitle = (_b = articleMeta === null || articleMeta === void 0 ? void 0 : articleMeta.querySelector('title-group > subtitle')) === null || _b === void 0 ? void 0 : _b.innerHTML;
|
|
53
54
|
const runningTitle = (_c = articleMeta === null || articleMeta === void 0 ? void 0 : articleMeta.querySelector('title-group > alt-title[alt-title-type="right-running"]')) === null || _c === void 0 ? void 0 : _c.innerHTML;
|
|
54
|
-
const manuscriptMeta = Object.assign({
|
|
55
|
+
const manuscriptMeta = Object.assign({}, jats_front_parser_1.jatsFrontParser.parseCounts(articleMeta === null || articleMeta === void 0 ? void 0 : articleMeta.querySelector('counts')));
|
|
56
|
+
const titles = {
|
|
57
|
+
objectType: json_schema_1.ObjectTypes.Titles,
|
|
58
|
+
_id: (0, id_1.generateID)(json_schema_1.ObjectTypes.Titles),
|
|
59
|
+
title: title ? inlineContentsFromJATSTitle(title) : undefined,
|
|
60
|
+
subtitle: subtitle ? inlineContentsFromJATSTitle(subtitle) : undefined,
|
|
61
|
+
runningTitle: runningTitle
|
|
55
62
|
? inlineContentsFromJATSTitle(runningTitle)
|
|
56
|
-
: undefined
|
|
63
|
+
: undefined,
|
|
64
|
+
};
|
|
57
65
|
const { affiliations, affiliationIDs } = jats_front_parser_1.jatsFrontParser.parseAffiliationNodes([
|
|
58
66
|
...front.querySelectorAll('article-meta > contrib-group > aff'),
|
|
59
67
|
]);
|
|
@@ -73,14 +81,15 @@ const parseJATSFront = async (front) => {
|
|
|
73
81
|
const manuscript = Object.assign(Object.assign(Object.assign({}, (0, builders_1.buildManuscript)()), manuscriptMeta), history);
|
|
74
82
|
return {
|
|
75
83
|
models: generateModelIDs([
|
|
84
|
+
titles,
|
|
76
85
|
manuscript,
|
|
77
|
-
...affiliations,
|
|
78
|
-
...authors,
|
|
79
86
|
...footnotes,
|
|
80
87
|
...correspondingList,
|
|
81
88
|
journal,
|
|
82
89
|
...supplements,
|
|
83
90
|
]),
|
|
91
|
+
authors: [...authors],
|
|
92
|
+
affiliations: [...affiliations],
|
|
84
93
|
};
|
|
85
94
|
};
|
|
86
95
|
exports.parseJATSFront = parseJATSFront;
|
|
@@ -106,7 +115,7 @@ const parseJATSReferences = (back, body, createElement) => {
|
|
|
106
115
|
};
|
|
107
116
|
};
|
|
108
117
|
exports.parseJATSReferences = parseJATSReferences;
|
|
109
|
-
const parseJATSBody = (document, body, bibliographyItems, refModels, referenceIdsMap, footnotesOrder) => {
|
|
118
|
+
const parseJATSBody = (document, body, bibliographyItems, authors, affiliations, refModels, referenceIdsMap, footnotesOrder) => {
|
|
110
119
|
const createElement = createElementFn(document);
|
|
111
120
|
const orderedFootnotesIDs = (0, footnotes_order_1.createOrderedFootnotesIDs)(document);
|
|
112
121
|
jats_body_transformations_1.jatsBodyTransformations.moveFloatsGroupToBody(document, body, createElement);
|
|
@@ -116,6 +125,8 @@ const parseJATSBody = (document, body, bibliographyItems, refModels, referenceId
|
|
|
116
125
|
jats_body_transformations_1.jatsBodyTransformations.moveTableFooterToEnd(body);
|
|
117
126
|
jats_body_transformations_1.jatsBodyTransformations.moveBlockNodesFromParagraph(document, body, createElement);
|
|
118
127
|
jats_body_transformations_1.jatsBodyTransformations.moveKeywordsToBody(document, body, createElement);
|
|
128
|
+
jats_body_transformations_1.jatsBodyTransformations.moveAffiliationsToBody(document, affiliations, body, createElement);
|
|
129
|
+
jats_body_transformations_1.jatsBodyTransformations.moveAuthorsToBody(document, authors, body, createElement);
|
|
119
130
|
const node = jats_body_dom_parser_1.jatsBodyDOMParser.parse(body);
|
|
120
131
|
if (!node.firstChild) {
|
|
121
132
|
throw new Error('No content was parsed from the JATS article body');
|
|
@@ -168,14 +179,14 @@ const parseJATSArticle = async (doc) => {
|
|
|
168
179
|
}
|
|
169
180
|
const authorQueriesMap = (0, jats_comments_1.markProcessingInstructions)(doc);
|
|
170
181
|
const createElement = createElementFn(document);
|
|
171
|
-
const { models: frontModels } = await (0, exports.parseJATSFront)(front);
|
|
182
|
+
const { models: frontModels, authors, affiliations, } = await (0, exports.parseJATSFront)(front);
|
|
172
183
|
const { references, crossReferences, referenceQueriesMap, referenceIdsMap } = (0, exports.parseJATSReferences)(back, body, createElement);
|
|
173
184
|
transformTables(doc.querySelectorAll('table-wrap > table'), createElement);
|
|
174
185
|
const footnotesOrder = (0, footnotes_order_1.createEmptyFootnotesOrder)();
|
|
175
186
|
let elementsOrder = [];
|
|
176
187
|
const bodyModels = [];
|
|
177
188
|
if (body) {
|
|
178
|
-
const bodyDoc = (0, exports.parseJATSBody)(doc, body, references, crossReferences, referenceIdsMap, footnotesOrder);
|
|
189
|
+
const bodyDoc = (0, exports.parseJATSBody)(doc, body, references, authors, affiliations, crossReferences, referenceIdsMap, footnotesOrder);
|
|
179
190
|
bodyModels.push(...(0, encode_1.encode)(bodyDoc).values());
|
|
180
191
|
elementsOrder = (0, exports.getElementsOrder)(bodyDoc);
|
|
181
192
|
}
|
|
@@ -238,6 +238,7 @@ class JATSExporter {
|
|
|
238
238
|
this.buildFront = (doi, id, links) => {
|
|
239
239
|
var _a, _b, _c, _d;
|
|
240
240
|
const manuscript = (0, project_bundle_1.findManuscript)(this.modelMap);
|
|
241
|
+
const titles = (0, project_bundle_1.findTitles)(this.modelMap);
|
|
241
242
|
const front = this.document.createElement('front');
|
|
242
243
|
const journalMeta = this.document.createElement('journal-meta');
|
|
243
244
|
front.appendChild(journalMeta);
|
|
@@ -315,20 +316,20 @@ class JATSExporter {
|
|
|
315
316
|
articleMeta.appendChild(link);
|
|
316
317
|
}
|
|
317
318
|
}
|
|
318
|
-
if (
|
|
319
|
+
if (titles.title) {
|
|
319
320
|
const element = this.document.createElement('article-title');
|
|
320
|
-
this.setTitleContent(element,
|
|
321
|
+
this.setTitleContent(element, titles.title);
|
|
321
322
|
titleGroup.appendChild(element);
|
|
322
323
|
}
|
|
323
|
-
if (
|
|
324
|
+
if (titles.subtitle) {
|
|
324
325
|
const element = this.document.createElement('subtitle');
|
|
325
|
-
this.setTitleContent(element,
|
|
326
|
+
this.setTitleContent(element, titles.subtitle);
|
|
326
327
|
titleGroup.appendChild(element);
|
|
327
328
|
}
|
|
328
|
-
if (
|
|
329
|
+
if (titles.runningTitle) {
|
|
329
330
|
const element = this.document.createElement('alt-title');
|
|
330
331
|
element.setAttribute('alt-title-type', 'right-running');
|
|
331
|
-
this.setTitleContent(element,
|
|
332
|
+
this.setTitleContent(element, titles.runningTitle);
|
|
332
333
|
titleGroup.appendChild(element);
|
|
333
334
|
}
|
|
334
335
|
const supplements = [...this.modelMap.values()].filter((model) => model.objectType === json_schema_1.ObjectTypes.Supplement);
|
|
@@ -598,10 +599,11 @@ class JATSExporter {
|
|
|
598
599
|
this.createSerializer = () => {
|
|
599
600
|
const getModel = (id) => id ? this.modelMap.get(id) : undefined;
|
|
600
601
|
const nodes = {
|
|
602
|
+
titles: () => '',
|
|
603
|
+
affiliations_section: () => '',
|
|
604
|
+
contributors_section: () => '',
|
|
601
605
|
table_element_footer: () => ['table-wrap-foot', 0],
|
|
602
|
-
contributor_list: () => '',
|
|
603
606
|
contributor: () => '',
|
|
604
|
-
affiliation_list: () => '',
|
|
605
607
|
affiliation: () => '',
|
|
606
608
|
meta_section: () => '',
|
|
607
609
|
attribution: () => ['attrib', 0],
|
|
@@ -16,7 +16,7 @@ exports.coreSectionCategories = [
|
|
|
16
16
|
desc: 'Backmatter section for grouping',
|
|
17
17
|
objectType: 'MPSectionCategory',
|
|
18
18
|
titles: [],
|
|
19
|
-
priority:
|
|
19
|
+
priority: 180,
|
|
20
20
|
},
|
|
21
21
|
{
|
|
22
22
|
_id: 'MPSectionCategory:body',
|
|
@@ -24,6 +24,6 @@ exports.coreSectionCategories = [
|
|
|
24
24
|
desc: 'Body section for grouping',
|
|
25
25
|
objectType: 'MPSectionCategory',
|
|
26
26
|
titles: [],
|
|
27
|
-
priority:
|
|
27
|
+
priority: 200,
|
|
28
28
|
},
|
|
29
29
|
];
|
package/dist/cjs/schema/index.js
CHANGED
|
@@ -33,7 +33,7 @@ exports.schema = void 0;
|
|
|
33
33
|
const prosemirror_model_1 = require("prosemirror-model");
|
|
34
34
|
const marks_1 = require("./marks");
|
|
35
35
|
const affiliation_1 = require("./nodes/affiliation");
|
|
36
|
-
const
|
|
36
|
+
const affiliations_section_1 = require("./nodes/affiliations_section");
|
|
37
37
|
const attribution_1 = require("./nodes/attribution");
|
|
38
38
|
const bibliography_element_1 = require("./nodes/bibliography_element");
|
|
39
39
|
const bibliography_item_1 = require("./nodes/bibliography_item");
|
|
@@ -45,7 +45,7 @@ const citation_1 = require("./nodes/citation");
|
|
|
45
45
|
const comment_1 = require("./nodes/comment");
|
|
46
46
|
const comment_list_1 = require("./nodes/comment_list");
|
|
47
47
|
const contributor_1 = require("./nodes/contributor");
|
|
48
|
-
const
|
|
48
|
+
const contributors_section_1 = require("./nodes/contributors_section");
|
|
49
49
|
const cross_reference_1 = require("./nodes/cross_reference");
|
|
50
50
|
const doc_1 = require("./nodes/doc");
|
|
51
51
|
const equation_1 = require("./nodes/equation");
|
|
@@ -85,6 +85,7 @@ const table_element_1 = require("./nodes/table_element");
|
|
|
85
85
|
const table_element_footer_1 = require("./nodes/table_element_footer");
|
|
86
86
|
const table_row_1 = require("./nodes/table_row");
|
|
87
87
|
const text_1 = require("./nodes/text");
|
|
88
|
+
const titles_1 = require("./nodes/titles");
|
|
88
89
|
const toc_element_1 = require("./nodes/toc_element");
|
|
89
90
|
const toc_section_1 = require("./nodes/toc_section");
|
|
90
91
|
__exportStar(require("./groups"), exports);
|
|
@@ -137,11 +138,12 @@ __exportStar(require("./nodes/text"), exports);
|
|
|
137
138
|
__exportStar(require("./nodes/toc_element"), exports);
|
|
138
139
|
__exportStar(require("./nodes/toc_section"), exports);
|
|
139
140
|
__exportStar(require("./nodes/affiliation"), exports);
|
|
140
|
-
__exportStar(require("./nodes/affiliation_list"), exports);
|
|
141
141
|
__exportStar(require("./nodes/meta_section"), exports);
|
|
142
|
-
__exportStar(require("./nodes/contributor_list"), exports);
|
|
143
142
|
__exportStar(require("./nodes/contributor"), exports);
|
|
144
143
|
__exportStar(require("./nodes/table_element_footer"), exports);
|
|
144
|
+
__exportStar(require("./nodes/titles"), exports);
|
|
145
|
+
__exportStar(require("./nodes/affiliations_section"), exports);
|
|
146
|
+
__exportStar(require("./nodes/contributors_section"), exports);
|
|
145
147
|
exports.schema = new prosemirror_model_1.Schema({
|
|
146
148
|
marks: {
|
|
147
149
|
bold: marks_1.bold,
|
|
@@ -214,9 +216,10 @@ exports.schema = new prosemirror_model_1.Schema({
|
|
|
214
216
|
toc_section: toc_section_1.tocSection,
|
|
215
217
|
affiliation: affiliation_1.affiliation,
|
|
216
218
|
meta_section: meta_section_1.metaSection,
|
|
217
|
-
affiliation_list: affiliation_list_1.affiliationList,
|
|
218
|
-
contributor_list: contributor_list_1.contributorList,
|
|
219
219
|
contributor: contributor_1.contributor,
|
|
220
220
|
table_element_footer: table_element_footer_1.tableElementFooter,
|
|
221
|
+
titles: titles_1.Titles,
|
|
222
|
+
affiliations_section: affiliations_section_1.affiliationsSection,
|
|
223
|
+
contributors_section: contributors_section_1.contributorsSection,
|
|
221
224
|
},
|
|
222
225
|
});
|
|
@@ -11,6 +11,7 @@ exports.affiliation = {
|
|
|
11
11
|
addressLine3: { default: '' },
|
|
12
12
|
postCode: { default: '' },
|
|
13
13
|
country: { default: '' },
|
|
14
|
+
priority: { default: undefined },
|
|
14
15
|
email: {
|
|
15
16
|
default: {
|
|
16
17
|
href: undefined,
|
|
@@ -18,6 +19,8 @@ exports.affiliation = {
|
|
|
18
19
|
},
|
|
19
20
|
},
|
|
20
21
|
},
|
|
22
|
+
group: 'block element',
|
|
23
|
+
toDOM: () => ['span'],
|
|
21
24
|
};
|
|
22
25
|
const isAffiliationNode = (node) => node.type === node.type.schema.nodes.affiliation;
|
|
23
26
|
exports.isAffiliationNode = isAffiliationNode;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isAffiliationsSectionNode = exports.affiliationsSection = void 0;
|
|
4
|
+
exports.affiliationsSection = {
|
|
5
|
+
content: 'section_title? affiliation*',
|
|
6
|
+
attrs: {
|
|
7
|
+
id: { default: '' },
|
|
8
|
+
dataTracked: { default: null },
|
|
9
|
+
},
|
|
10
|
+
group: 'block sections',
|
|
11
|
+
selectable: false,
|
|
12
|
+
toDOM: () => ['section', 0],
|
|
13
|
+
};
|
|
14
|
+
const isAffiliationsSectionNode = (node) => node.type === node.type.schema.nodes.affiliations_section;
|
|
15
|
+
exports.isAffiliationsSectionNode = isAffiliationsSectionNode;
|
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.contributor = void 0;
|
|
3
|
+
exports.isContributorNode = exports.contributor = void 0;
|
|
4
4
|
exports.contributor = {
|
|
5
5
|
attrs: {
|
|
6
6
|
id: { default: '' },
|
|
7
7
|
role: { default: '' },
|
|
8
8
|
affiliations: { default: [] },
|
|
9
|
+
footnote: { default: undefined },
|
|
10
|
+
corresp: { default: undefined },
|
|
9
11
|
bibliographicName: { default: {} },
|
|
10
12
|
userID: { default: undefined },
|
|
11
13
|
invitationID: { default: undefined },
|
|
12
14
|
isCorresponding: { default: undefined },
|
|
13
15
|
ORCIDIdentifier: { default: undefined },
|
|
16
|
+
priority: { default: undefined },
|
|
14
17
|
},
|
|
18
|
+
group: 'block element',
|
|
19
|
+
toDOM: () => ['span'],
|
|
15
20
|
};
|
|
21
|
+
const isContributorNode = (node) => node.type === node.type.schema.nodes.contributor;
|
|
22
|
+
exports.isContributorNode = isContributorNode;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isContributorsSectionNode = exports.contributorsSection = void 0;
|
|
4
|
+
exports.contributorsSection = {
|
|
5
|
+
content: 'section_title? contributor*',
|
|
6
|
+
attrs: {
|
|
7
|
+
id: { default: '' },
|
|
8
|
+
dataTracked: { default: null },
|
|
9
|
+
},
|
|
10
|
+
group: 'block sections',
|
|
11
|
+
selectable: false,
|
|
12
|
+
toDOM: () => ['section', 0],
|
|
13
|
+
};
|
|
14
|
+
const isContributorsSectionNode = (node) => node.type === node.type.schema.nodes.contributors_section;
|
|
15
|
+
exports.isContributorsSectionNode = isContributorsSectionNode;
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.metaSection = void 0;
|
|
19
19
|
exports.metaSection = {
|
|
20
|
-
content: '
|
|
20
|
+
content: 'comment_list',
|
|
21
21
|
attrs: {
|
|
22
22
|
id: { default: 'META_SECTION' },
|
|
23
23
|
},
|
|
@@ -0,0 +1,32 @@
|
|
|
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.Titles = void 0;
|
|
19
|
+
exports.Titles = {
|
|
20
|
+
content: 'text*',
|
|
21
|
+
marks: 'italic smallcaps subscript superscript',
|
|
22
|
+
attrs: {
|
|
23
|
+
id: { default: '' },
|
|
24
|
+
title: { default: '' },
|
|
25
|
+
subtitle: { default: '' },
|
|
26
|
+
runningTitle: { default: '' },
|
|
27
|
+
dataTracked: { default: null },
|
|
28
|
+
},
|
|
29
|
+
group: 'block element',
|
|
30
|
+
parseDOM: [{ tag: 'div' }],
|
|
31
|
+
toDOM: () => ['div', 0],
|
|
32
|
+
};
|
|
@@ -35,10 +35,9 @@ const buildProject = (owner) => ({
|
|
|
35
35
|
title: '',
|
|
36
36
|
});
|
|
37
37
|
exports.buildProject = buildProject;
|
|
38
|
-
const buildManuscript = (
|
|
38
|
+
const buildManuscript = () => ({
|
|
39
39
|
_id: (0, id_1.generateID)(json_schema_1.ObjectTypes.Manuscript),
|
|
40
40
|
objectType: json_schema_1.ObjectTypes.Manuscript,
|
|
41
|
-
title,
|
|
42
41
|
});
|
|
43
42
|
exports.buildManuscript = buildManuscript;
|
|
44
43
|
const buildContributor = (bibliographicName, role = 'author', priority = 0, userID, invitationID) => ({
|