@manuscripts/transform 2.3.34-LEAN-3911.2 → 2.3.35
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/__tests__/data/project-dump.json +825 -0
- package/dist/cjs/jats/importer/index.js +3 -3
- package/dist/cjs/jats/importer/{jats-dom-parser.js → jats-body-dom-parser.js} +9 -229
- package/dist/cjs/jats/importer/jats-body-transformations.js +0 -70
- package/dist/cjs/jats/importer/jats-comments.js +104 -27
- package/dist/cjs/jats/importer/jats-front-parser.js +321 -0
- package/dist/cjs/jats/importer/jats-journal-meta-parser.js +1 -8
- package/dist/cjs/jats/importer/jats-parser-utils.js +5 -39
- package/dist/cjs/jats/importer/jats-reference-parser.js +27 -16
- package/dist/cjs/jats/importer/jats-references.js +18 -18
- package/dist/cjs/jats/importer/parse-jats-article.js +78 -42
- package/dist/cjs/jats/index.js +3 -4
- package/dist/cjs/jats/jats-exporter.js +354 -251
- package/dist/cjs/lib/utils.js +1 -9
- package/dist/cjs/schema/nodes/inline_footnote.js +1 -0
- package/dist/cjs/transformer/__tests__/__helpers__/doc.js +37 -0
- package/dist/cjs/transformer/builders.js +219 -0
- package/dist/cjs/transformer/decode.js +874 -0
- package/dist/cjs/transformer/document-object-types.js +31 -0
- package/dist/cjs/transformer/encode.js +664 -0
- package/dist/cjs/transformer/footnote-category.js +20 -0
- package/dist/cjs/transformer/footnotes-order.js +60 -0
- package/dist/cjs/transformer/highlight-markers.js +138 -0
- package/dist/cjs/transformer/html.js +400 -0
- package/dist/cjs/transformer/id.js +6 -6
- package/dist/cjs/transformer/index.js +18 -0
- package/dist/cjs/{jats → transformer}/labels.js +3 -3
- package/dist/cjs/transformer/manuscript-dependencies.js +21 -0
- package/dist/cjs/transformer/model-map.js +26 -0
- package/dist/cjs/transformer/models.js +17 -0
- package/dist/cjs/transformer/object-types.js +57 -0
- package/dist/cjs/transformer/project-bundle.js +94 -0
- package/dist/cjs/transformer/serializer.js +23 -0
- package/dist/cjs/transformer/update-identifiers.js +93 -0
- package/dist/cjs/version.js +1 -1
- package/dist/es/__tests__/data/project-dump.json +825 -0
- package/dist/es/jats/importer/index.js +1 -2
- package/dist/es/jats/importer/{jats-dom-parser.js → jats-body-dom-parser.js} +10 -230
- package/dist/es/jats/importer/jats-body-transformations.js +0 -70
- package/dist/es/jats/importer/jats-comments.js +101 -26
- package/dist/es/jats/importer/jats-front-parser.js +315 -0
- package/dist/es/jats/importer/jats-journal-meta-parser.js +0 -6
- package/dist/es/jats/importer/jats-parser-utils.js +6 -40
- package/dist/es/jats/importer/jats-reference-parser.js +27 -16
- package/dist/es/jats/importer/jats-references.js +18 -18
- package/dist/es/jats/importer/parse-jats-article.js +77 -43
- package/dist/es/jats/index.js +1 -3
- package/dist/es/jats/jats-exporter.js +356 -253
- package/dist/es/lib/utils.js +0 -7
- package/dist/es/schema/nodes/inline_footnote.js +1 -0
- package/dist/es/transformer/__tests__/__helpers__/doc.js +29 -0
- package/dist/es/transformer/builders.js +186 -0
- package/dist/es/transformer/decode.js +864 -0
- package/dist/es/transformer/document-object-types.js +28 -0
- package/dist/es/transformer/encode.js +654 -0
- package/dist/{types/jats/importer/create-article-node.d.ts → es/transformer/footnote-category.js} +2 -3
- package/dist/es/transformer/footnotes-order.js +55 -0
- package/dist/es/transformer/highlight-markers.js +132 -0
- package/dist/es/transformer/html.js +393 -0
- package/dist/es/transformer/id.js +4 -5
- package/dist/es/transformer/index.js +16 -0
- package/dist/es/{jats → transformer}/labels.js +3 -3
- package/dist/es/transformer/manuscript-dependencies.js +17 -0
- package/dist/es/transformer/model-map.js +22 -0
- package/dist/es/transformer/models.js +16 -0
- package/dist/es/transformer/object-types.js +52 -0
- package/dist/es/transformer/project-bundle.js +85 -0
- package/dist/es/transformer/serializer.js +17 -0
- package/dist/es/transformer/update-identifiers.js +87 -0
- package/dist/es/version.js +1 -1
- package/dist/types/jats/importer/index.d.ts +1 -2
- package/dist/types/jats/importer/{jats-dom-parser.d.ts → jats-body-dom-parser.d.ts} +1 -1
- package/dist/types/jats/importer/jats-body-transformations.d.ts +0 -5
- package/dist/types/jats/importer/jats-comments.d.ts +10 -4
- package/dist/types/jats/importer/jats-front-parser.d.ts +84 -0
- package/dist/types/jats/importer/jats-journal-meta-parser.d.ts +0 -10
- package/dist/types/jats/importer/jats-references.d.ts +8 -19
- package/dist/types/jats/importer/parse-jats-article.d.ts +5 -12
- package/dist/types/jats/index.d.ts +1 -3
- package/dist/types/jats/jats-exporter.d.ts +29 -10
- package/dist/types/lib/utils.d.ts +0 -3
- package/dist/types/schema/nodes/bibliography_item.d.ts +6 -16
- package/dist/types/schema/nodes/contributor.d.ts +0 -10
- package/dist/types/schema/nodes/keyword_group.d.ts +0 -1
- package/dist/types/transformer/__tests__/__helpers__/doc.d.ts +18 -0
- package/dist/types/transformer/builders.d.ts +61 -0
- package/dist/types/transformer/decode.d.ts +51 -0
- package/dist/types/transformer/document-object-types.d.ts +17 -0
- package/dist/types/transformer/encode.d.ts +29 -0
- package/dist/types/transformer/footnote-category.d.ts +17 -0
- package/dist/types/transformer/footnotes-order.d.ts +22 -0
- package/dist/types/transformer/highlight-markers.d.ts +31 -0
- package/dist/types/transformer/html.d.ts +36 -0
- package/dist/types/transformer/id.d.ts +3 -4
- package/dist/types/transformer/index.d.ts +16 -0
- package/dist/types/{jats → transformer}/labels.d.ts +1 -2
- package/dist/types/transformer/manuscript-dependencies.d.ts +4 -0
- package/dist/types/transformer/model-map.d.ts +19 -0
- package/dist/types/transformer/models.d.ts +48 -0
- package/dist/types/transformer/object-types.d.ts +30 -0
- package/dist/types/transformer/project-bundle.d.ts +30 -0
- package/dist/types/transformer/serializer.d.ts +19 -0
- package/dist/types/transformer/update-identifiers.d.ts +23 -0
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -2
- package/dist/cjs/jats/importer/create-article-node.js +0 -31
- package/dist/cjs/jats/importer/jats-front-transformations.js +0 -262
- package/dist/es/jats/importer/create-article-node.js +0 -27
- package/dist/es/jats/importer/jats-front-transformations.js +0 -259
- package/dist/types/jats/importer/jats-front-transformations.d.ts +0 -38
- /package/dist/cjs/{jats → transformer}/filename.js +0 -0
- /package/dist/cjs/{jats → transformer}/timestamp.js +0 -0
- /package/dist/es/{jats → transformer}/filename.js +0 -0
- /package/dist/es/{jats → transformer}/timestamp.js +0 -0
- /package/dist/types/{jats → transformer}/filename.d.ts +0 -0
- /package/dist/types/{jats → transformer}/timestamp.d.ts +0 -0
|
@@ -23,19 +23,44 @@ const json_schema_1 = require("@manuscripts/json-schema");
|
|
|
23
23
|
const library_1 = require("@manuscripts/library");
|
|
24
24
|
const debug_1 = __importDefault(require("debug"));
|
|
25
25
|
const prosemirror_model_1 = require("prosemirror-model");
|
|
26
|
-
const prosemirror_utils_1 = require("prosemirror-utils");
|
|
27
26
|
const w3c_xmlserializer_1 = __importDefault(require("w3c-xmlserializer"));
|
|
28
27
|
const html_1 = require("../lib/html");
|
|
28
|
+
const styled_content_1 = require("../lib/styled-content");
|
|
29
|
+
const utils_1 = require("../lib/utils");
|
|
29
30
|
const schema_1 = require("../schema");
|
|
31
|
+
const filename_1 = require("../transformer/filename");
|
|
32
|
+
const labels_1 = require("../transformer/labels");
|
|
30
33
|
const node_types_1 = require("../transformer/node-types");
|
|
34
|
+
const object_types_1 = require("../transformer/object-types");
|
|
35
|
+
const project_bundle_1 = require("../transformer/project-bundle");
|
|
31
36
|
const section_category_1 = require("../transformer/section-category");
|
|
32
|
-
const filename_1 = require("./filename");
|
|
33
37
|
const jats_versions_1 = require("./jats-versions");
|
|
34
|
-
const labels_1 = require("./labels");
|
|
35
38
|
const warn = (0, debug_1.default)('manuscripts-transform');
|
|
36
39
|
const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
|
|
37
40
|
const normalizeID = (id) => id.replace(/:/g, '_');
|
|
38
41
|
const parser = prosemirror_model_1.DOMParser.fromSchema(schema_1.schema);
|
|
42
|
+
const findChildNodeOfType = (node, nodeType) => {
|
|
43
|
+
for (const child of (0, utils_1.iterateChildren)(node)) {
|
|
44
|
+
if (child.type === nodeType) {
|
|
45
|
+
return child;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
const isContributor = (0, object_types_1.hasObjectType)(json_schema_1.ObjectTypes.Contributor);
|
|
50
|
+
const CREDIT_VOCAB_IDENTIFIER = 'https://dictionary.casrai.org/Contributor_Roles';
|
|
51
|
+
const chooseRoleVocabAttributes = (role) => {
|
|
52
|
+
if (role.uri && role.uri.startsWith(CREDIT_VOCAB_IDENTIFIER)) {
|
|
53
|
+
return {
|
|
54
|
+
vocab: 'credit',
|
|
55
|
+
'vocab-identifier': CREDIT_VOCAB_IDENTIFIER,
|
|
56
|
+
'vocab-term': role.name,
|
|
57
|
+
'vocab-term-identifier': role.uri,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
vocab: 'uncontrolled',
|
|
62
|
+
};
|
|
63
|
+
};
|
|
39
64
|
const insertAbstractNode = (articleMeta, abstractNode) => {
|
|
40
65
|
const siblings = [
|
|
41
66
|
'kwd-group',
|
|
@@ -73,24 +98,24 @@ const createDefaultIdGenerator = () => {
|
|
|
73
98
|
return `${element.localName}-${value}`;
|
|
74
99
|
};
|
|
75
100
|
};
|
|
76
|
-
const chooseRefType = (
|
|
77
|
-
switch (
|
|
78
|
-
case
|
|
79
|
-
case
|
|
101
|
+
const chooseRefType = (objectType) => {
|
|
102
|
+
switch (objectType) {
|
|
103
|
+
case json_schema_1.ObjectTypes.Figure:
|
|
104
|
+
case json_schema_1.ObjectTypes.FigureElement:
|
|
80
105
|
return 'fig';
|
|
81
|
-
case
|
|
106
|
+
case json_schema_1.ObjectTypes.Footnote:
|
|
82
107
|
return 'fn';
|
|
83
|
-
case
|
|
84
|
-
case
|
|
108
|
+
case json_schema_1.ObjectTypes.Table:
|
|
109
|
+
case json_schema_1.ObjectTypes.TableElement:
|
|
85
110
|
return 'table';
|
|
86
|
-
case
|
|
111
|
+
case json_schema_1.ObjectTypes.Section:
|
|
87
112
|
return 'sec';
|
|
88
|
-
case
|
|
89
|
-
case
|
|
113
|
+
case json_schema_1.ObjectTypes.Equation:
|
|
114
|
+
case json_schema_1.ObjectTypes.EquationElement:
|
|
90
115
|
return 'disp-formula';
|
|
91
116
|
}
|
|
92
117
|
};
|
|
93
|
-
const sortContributors = (a, b) => Number(a.
|
|
118
|
+
const sortContributors = (a, b) => Number(a.priority) - Number(b.priority);
|
|
94
119
|
const buildCitations = (citations) => citations.map((citation) => ({
|
|
95
120
|
citationID: citation.attrs.id,
|
|
96
121
|
citationItems: citation.attrs.rids.map((rid) => ({
|
|
@@ -103,57 +128,39 @@ const buildCitations = (citations) => citations.map((citation) => ({
|
|
|
103
128
|
exports.buildCitations = buildCitations;
|
|
104
129
|
class JATSExporter {
|
|
105
130
|
constructor() {
|
|
106
|
-
this.
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
return undefined;
|
|
112
|
-
}
|
|
113
|
-
return {
|
|
114
|
-
_id: node.attrs.id,
|
|
115
|
-
issued: node.attrs.issued,
|
|
116
|
-
DOI: node.attrs.doi,
|
|
117
|
-
manuscriptID,
|
|
118
|
-
objectType: json_schema_1.ObjectTypes.BibliographyItem,
|
|
119
|
-
author: node.attrs.author,
|
|
120
|
-
'container-title': node.attrs.containerTitle,
|
|
121
|
-
volume: node.attrs.volume,
|
|
122
|
-
issue: node.attrs.issue,
|
|
123
|
-
supplement: node.attrs.supplement,
|
|
124
|
-
page: node.attrs.page,
|
|
125
|
-
title: node.attrs.title,
|
|
126
|
-
literal: node.attrs.literal,
|
|
127
|
-
type: node.attrs.type,
|
|
128
|
-
};
|
|
129
|
-
};
|
|
130
|
-
};
|
|
131
|
-
this.serializeToJATS = async (manuscriptNode, csl, manuscript, jorunal) => {
|
|
132
|
-
const version = '1.2';
|
|
133
|
-
this.manuscriptNode = manuscriptNode;
|
|
134
|
-
this.generateCitationTexts(csl, manuscriptNode.attrs.id);
|
|
131
|
+
this.serializeToJATS = async (fragment, modelMap, manuscriptID, options) => {
|
|
132
|
+
const { version = '1.2', doi, id, frontMatterOnly = false, links, idGenerator, mediaPathGenerator, csl, } = options;
|
|
133
|
+
this.modelMap = modelMap;
|
|
134
|
+
this.models = Array.from(this.modelMap.values());
|
|
135
|
+
this.generateCitationTexts(fragment, csl);
|
|
135
136
|
this.createSerializer();
|
|
136
137
|
const versionIds = (0, jats_versions_1.selectVersionIds)(version);
|
|
137
138
|
this.document = document.implementation.createDocument(null, 'article', document.implementation.createDocumentType('article', versionIds.publicId, versionIds.systemId));
|
|
138
139
|
const article = this.document.documentElement;
|
|
139
140
|
article.setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:xlink', XLINK_NAMESPACE);
|
|
140
|
-
const front = this.buildFront(
|
|
141
|
+
const front = this.buildFront(doi, id, links);
|
|
141
142
|
article.appendChild(front);
|
|
143
|
+
const manuscript = (0, project_bundle_1.findManuscriptById)(this.modelMap, manuscriptID);
|
|
142
144
|
article.setAttribute('article-type', manuscript.articleType || 'other');
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
145
|
+
if (!frontMatterOnly) {
|
|
146
|
+
this.labelTargets = (0, labels_1.buildTargets)(fragment);
|
|
147
|
+
const body = this.buildBody(fragment);
|
|
148
|
+
article.appendChild(body);
|
|
149
|
+
const back = this.buildBack(body);
|
|
150
|
+
this.moveCoiStatementToAuthorNotes(back, front);
|
|
151
|
+
article.appendChild(back);
|
|
152
|
+
this.unwrapBody(body);
|
|
153
|
+
this.moveAbstracts(front, body);
|
|
154
|
+
this.moveFloatsGroup(body, article);
|
|
155
|
+
this.removeBackContainer(body);
|
|
156
|
+
this.updateFootnoteTypes(front, back);
|
|
157
|
+
this.fillEmptyTableFooters(article);
|
|
158
|
+
this.fillEmptyFootnotes(article);
|
|
159
|
+
}
|
|
160
|
+
await this.rewriteIDs(idGenerator);
|
|
161
|
+
if (mediaPathGenerator) {
|
|
162
|
+
await this.rewriteMediaPaths(mediaPathGenerator);
|
|
163
|
+
}
|
|
157
164
|
return (0, w3c_xmlserializer_1.default)(this.document);
|
|
158
165
|
};
|
|
159
166
|
this.nodeFromJATS = (JATSFragment) => {
|
|
@@ -220,14 +227,16 @@ class JATSExporter {
|
|
|
220
227
|
}
|
|
221
228
|
}
|
|
222
229
|
};
|
|
223
|
-
this.buildFront = (
|
|
224
|
-
var _a;
|
|
225
|
-
const
|
|
230
|
+
this.buildFront = (doi, id, links) => {
|
|
231
|
+
var _a, _b, _c, _d, _e;
|
|
232
|
+
const manuscript = (0, project_bundle_1.findManuscript)(this.modelMap);
|
|
233
|
+
const titles = (0, project_bundle_1.findTitles)(this.modelMap);
|
|
226
234
|
const front = this.document.createElement('front');
|
|
227
235
|
const journalMeta = this.document.createElement('journal-meta');
|
|
228
236
|
front.appendChild(journalMeta);
|
|
229
237
|
const articleMeta = this.document.createElement('article-meta');
|
|
230
238
|
front.appendChild(articleMeta);
|
|
239
|
+
const journal = [...this.modelMap.values()].find((model) => model.objectType === json_schema_1.ObjectTypes.Journal);
|
|
231
240
|
if (journal) {
|
|
232
241
|
if (journal.journalIdentifiers) {
|
|
233
242
|
for (const item of journal.journalIdentifiers) {
|
|
@@ -276,35 +285,92 @@ class JATSExporter {
|
|
|
276
285
|
journalMeta.appendChild(publisher);
|
|
277
286
|
}
|
|
278
287
|
}
|
|
279
|
-
if (
|
|
288
|
+
if (id) {
|
|
289
|
+
const articleID = this.document.createElement('article-id');
|
|
290
|
+
articleID.setAttribute('pub-id-type', 'publisher-id');
|
|
291
|
+
articleID.textContent = id;
|
|
292
|
+
articleMeta.appendChild(articleID);
|
|
293
|
+
}
|
|
294
|
+
if (doi || manuscript.DOI) {
|
|
280
295
|
const articleID = this.document.createElement('article-id');
|
|
281
296
|
articleID.setAttribute('pub-id-type', 'doi');
|
|
282
|
-
articleID.textContent = manuscript.DOI;
|
|
297
|
+
articleID.textContent = (_a = manuscript.DOI) !== null && _a !== void 0 ? _a : doi;
|
|
283
298
|
articleMeta.appendChild(articleID);
|
|
284
299
|
}
|
|
285
300
|
const titleGroup = this.document.createElement('title-group');
|
|
286
301
|
articleMeta.appendChild(titleGroup);
|
|
287
302
|
this.buildContributors(articleMeta);
|
|
288
|
-
if (
|
|
303
|
+
if (links && links.self) {
|
|
304
|
+
for (const [key, value] of Object.entries(links.self)) {
|
|
305
|
+
const link = this.document.createElement('self-uri');
|
|
306
|
+
link.setAttribute('content-type', key);
|
|
307
|
+
link.setAttributeNS(XLINK_NAMESPACE, 'href', value);
|
|
308
|
+
articleMeta.appendChild(link);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
if (titles.title) {
|
|
289
312
|
const element = this.document.createElement('article-title');
|
|
290
|
-
this.setTitleContent(element,
|
|
313
|
+
this.setTitleContent(element, titles.title);
|
|
291
314
|
titleGroup.appendChild(element);
|
|
292
315
|
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
316
|
+
if (titles.subtitle) {
|
|
317
|
+
const element = this.document.createElement('subtitle');
|
|
318
|
+
this.setTitleContent(element, titles.subtitle);
|
|
319
|
+
titleGroup.appendChild(element);
|
|
320
|
+
}
|
|
321
|
+
if (titles.runningTitle) {
|
|
322
|
+
const element = this.document.createElement('alt-title');
|
|
323
|
+
element.setAttribute('alt-title-type', 'right-running');
|
|
324
|
+
this.setTitleContent(element, titles.runningTitle);
|
|
325
|
+
titleGroup.appendChild(element);
|
|
326
|
+
}
|
|
327
|
+
const supplements = [...this.modelMap.values()].filter((model) => model.objectType === json_schema_1.ObjectTypes.Supplement);
|
|
328
|
+
if (supplements && supplements.length > 0) {
|
|
329
|
+
for (const supplement of supplements) {
|
|
330
|
+
const supplementaryMaterial = this.document.createElement('supplementary-material');
|
|
331
|
+
supplementaryMaterial.setAttribute('id', normalizeID(supplement._id));
|
|
332
|
+
supplementaryMaterial.setAttributeNS(XLINK_NAMESPACE, 'href', (_b = supplement.href) !== null && _b !== void 0 ? _b : '');
|
|
333
|
+
const mimeType = (_c = supplement.MIME) === null || _c === void 0 ? void 0 : _c.split('/')[0];
|
|
334
|
+
const mimeSubType = (_d = supplement.MIME) === null || _d === void 0 ? void 0 : _d.split('/')[1];
|
|
335
|
+
supplementaryMaterial.setAttribute('mimetype', mimeType !== null && mimeType !== void 0 ? mimeType : '');
|
|
336
|
+
supplementaryMaterial.setAttribute('mime-subtype', mimeSubType !== null && mimeSubType !== void 0 ? mimeSubType : '');
|
|
337
|
+
const caption = this.document.createElement('caption');
|
|
338
|
+
const title = this.document.createElement('title');
|
|
339
|
+
title.textContent = (_e = supplement.title) !== null && _e !== void 0 ? _e : '';
|
|
340
|
+
caption.append(title);
|
|
341
|
+
supplementaryMaterial.append(caption);
|
|
342
|
+
articleMeta.append(supplementaryMaterial);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
const history = articleMeta.querySelector('history') ||
|
|
346
|
+
this.document.createElement('history');
|
|
347
|
+
if (manuscript.acceptanceDate) {
|
|
348
|
+
const date = this.buildDateElement(manuscript.acceptanceDate, 'accepted');
|
|
349
|
+
history.appendChild(date);
|
|
350
|
+
}
|
|
351
|
+
if (manuscript.correctionDate) {
|
|
352
|
+
const date = this.buildDateElement(manuscript.correctionDate, 'corrected');
|
|
353
|
+
history.appendChild(date);
|
|
354
|
+
}
|
|
355
|
+
if (manuscript.retractionDate) {
|
|
356
|
+
const date = this.buildDateElement(manuscript.retractionDate, 'retracted');
|
|
357
|
+
history.appendChild(date);
|
|
358
|
+
}
|
|
359
|
+
if (manuscript.receiveDate) {
|
|
360
|
+
const date = this.buildDateElement(manuscript.receiveDate, 'received');
|
|
361
|
+
history.appendChild(date);
|
|
362
|
+
}
|
|
363
|
+
if (manuscript.revisionReceiveDate) {
|
|
364
|
+
const date = this.buildDateElement(manuscript.revisionReceiveDate, 'rev-recd');
|
|
365
|
+
history.appendChild(date);
|
|
366
|
+
}
|
|
367
|
+
if (manuscript.revisionRequestDate) {
|
|
368
|
+
const date = this.buildDateElement(manuscript.revisionRequestDate, 'rev-request');
|
|
369
|
+
history.appendChild(date);
|
|
370
|
+
}
|
|
371
|
+
if (history.childElementCount) {
|
|
372
|
+
articleMeta.appendChild(history);
|
|
373
|
+
}
|
|
308
374
|
this.buildKeywords(articleMeta);
|
|
309
375
|
let countingElements = [];
|
|
310
376
|
if (manuscript.genericCounts) {
|
|
@@ -317,16 +383,11 @@ class JATSExporter {
|
|
|
317
383
|
});
|
|
318
384
|
countingElements.push(...elements);
|
|
319
385
|
}
|
|
320
|
-
|
|
321
|
-
countingElements.push(this.buildCountingElement('
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
countingElements.push(this.buildCountingElement('table-count', tableCount));
|
|
326
|
-
countingElements.push(this.buildCountingElement('equation-count', equationCount));
|
|
327
|
-
countingElements.push(this.buildCountingElement('ref-count', referencesCount));
|
|
328
|
-
const wordCount = this.manuscriptNode.textContent.split(/\s+/).length;
|
|
329
|
-
countingElements.push(this.buildCountingElement('word-count', wordCount));
|
|
386
|
+
countingElements.push(this.buildCountingElement('fig-count', manuscript.figureCount));
|
|
387
|
+
countingElements.push(this.buildCountingElement('table-count', manuscript.tableCount));
|
|
388
|
+
countingElements.push(this.buildCountingElement('equation-count', manuscript.equationCount));
|
|
389
|
+
countingElements.push(this.buildCountingElement('ref-count', manuscript.referencesCount));
|
|
390
|
+
countingElements.push(this.buildCountingElement('word-count', manuscript.wordCount));
|
|
330
391
|
countingElements = countingElements.filter((el) => el);
|
|
331
392
|
if (countingElements.length > 0) {
|
|
332
393
|
const counts = this.document.createElement('counts');
|
|
@@ -361,17 +422,16 @@ class JATSExporter {
|
|
|
361
422
|
return wordCount;
|
|
362
423
|
}
|
|
363
424
|
};
|
|
364
|
-
this.buildBody = () => {
|
|
425
|
+
this.buildBody = (fragment) => {
|
|
365
426
|
const body = this.document.createElement('body');
|
|
366
|
-
|
|
427
|
+
fragment.forEach((cFragment) => {
|
|
367
428
|
const serializedNode = this.serializeNode(cFragment);
|
|
368
429
|
body.append(...serializedNode.childNodes);
|
|
369
430
|
});
|
|
370
|
-
this.fixBody(body);
|
|
431
|
+
this.fixBody(body, fragment);
|
|
371
432
|
return body;
|
|
372
433
|
};
|
|
373
434
|
this.buildBack = (body) => {
|
|
374
|
-
var _a;
|
|
375
435
|
const back = this.document.createElement('back');
|
|
376
436
|
this.moveSectionsToBack(back, body);
|
|
377
437
|
const footnotesElements = this.document.querySelectorAll('sec > fn-group');
|
|
@@ -396,7 +456,7 @@ class JATSExporter {
|
|
|
396
456
|
back.appendChild(refList);
|
|
397
457
|
const [meta] = this.citationProvider.makeBibliography();
|
|
398
458
|
for (const id of meta.entry_ids) {
|
|
399
|
-
const
|
|
459
|
+
const bibliographyItem = this.modelMap.get(id[0]);
|
|
400
460
|
const ref = this.document.createElement('ref');
|
|
401
461
|
ref.setAttribute('id', normalizeID(id[0]));
|
|
402
462
|
const updateCitationPubType = (citationEl, pubType) => {
|
|
@@ -415,21 +475,21 @@ class JATSExporter {
|
|
|
415
475
|
citationEl.setAttribute('publication-type', 'journal');
|
|
416
476
|
}
|
|
417
477
|
};
|
|
418
|
-
if (
|
|
478
|
+
if (bibliographyItem.literal) {
|
|
419
479
|
const mixedCitation = this.document.createElement('mixed-citation');
|
|
420
|
-
updateCitationPubType(mixedCitation,
|
|
421
|
-
mixedCitation.textContent =
|
|
480
|
+
updateCitationPubType(mixedCitation, bibliographyItem.type);
|
|
481
|
+
mixedCitation.textContent = bibliographyItem.literal;
|
|
422
482
|
ref.appendChild(mixedCitation);
|
|
423
483
|
refList.appendChild(ref);
|
|
424
484
|
}
|
|
425
485
|
else {
|
|
426
486
|
const citation = this.document.createElement('element-citation');
|
|
427
|
-
updateCitationPubType(citation,
|
|
428
|
-
if (
|
|
487
|
+
updateCitationPubType(citation, bibliographyItem.type);
|
|
488
|
+
if (bibliographyItem.author) {
|
|
429
489
|
const personGroupNode = this.document.createElement('person-group');
|
|
430
490
|
personGroupNode.setAttribute('person-group-type', 'author');
|
|
431
491
|
citation.appendChild(personGroupNode);
|
|
432
|
-
|
|
492
|
+
bibliographyItem.author.forEach((author) => {
|
|
433
493
|
const name = this.document.createElement('string-name');
|
|
434
494
|
if (author.family) {
|
|
435
495
|
const node = this.document.createElement('surname');
|
|
@@ -451,8 +511,8 @@ class JATSExporter {
|
|
|
451
511
|
}
|
|
452
512
|
});
|
|
453
513
|
}
|
|
454
|
-
if (
|
|
455
|
-
const dateParts =
|
|
514
|
+
if (bibliographyItem.issued) {
|
|
515
|
+
const dateParts = bibliographyItem.issued['date-parts'];
|
|
456
516
|
if (dateParts && dateParts.length) {
|
|
457
517
|
const [[year, month, day]] = dateParts;
|
|
458
518
|
if (year) {
|
|
@@ -472,33 +532,33 @@ class JATSExporter {
|
|
|
472
532
|
}
|
|
473
533
|
}
|
|
474
534
|
}
|
|
475
|
-
if (
|
|
535
|
+
if (bibliographyItem.title) {
|
|
476
536
|
const node = this.document.createElement('article-title');
|
|
477
|
-
this.setTitleContent(node,
|
|
537
|
+
this.setTitleContent(node, bibliographyItem.title);
|
|
478
538
|
citation.appendChild(node);
|
|
479
539
|
}
|
|
480
|
-
if (
|
|
540
|
+
if (bibliographyItem['container-title']) {
|
|
481
541
|
const node = this.document.createElement('source');
|
|
482
|
-
node.textContent =
|
|
542
|
+
node.textContent = bibliographyItem['container-title'];
|
|
483
543
|
citation.appendChild(node);
|
|
484
544
|
}
|
|
485
|
-
if (
|
|
545
|
+
if (bibliographyItem.volume) {
|
|
486
546
|
const node = this.document.createElement('volume');
|
|
487
|
-
node.textContent = String(
|
|
547
|
+
node.textContent = String(bibliographyItem.volume);
|
|
488
548
|
citation.appendChild(node);
|
|
489
549
|
}
|
|
490
|
-
if (
|
|
550
|
+
if (bibliographyItem.issue) {
|
|
491
551
|
const node = this.document.createElement('issue');
|
|
492
|
-
node.textContent = String(
|
|
552
|
+
node.textContent = String(bibliographyItem.issue);
|
|
493
553
|
citation.appendChild(node);
|
|
494
554
|
}
|
|
495
|
-
if (
|
|
555
|
+
if (bibliographyItem.supplement) {
|
|
496
556
|
const node = this.document.createElement('supplement');
|
|
497
|
-
node.textContent =
|
|
557
|
+
node.textContent = bibliographyItem.supplement;
|
|
498
558
|
citation.appendChild(node);
|
|
499
559
|
}
|
|
500
|
-
if (
|
|
501
|
-
const pageString = String(
|
|
560
|
+
if (bibliographyItem.page) {
|
|
561
|
+
const pageString = String(bibliographyItem.page);
|
|
502
562
|
if (/^\d+$/.test(pageString)) {
|
|
503
563
|
const node = this.document.createElement('fpage');
|
|
504
564
|
node.textContent = pageString;
|
|
@@ -519,10 +579,10 @@ class JATSExporter {
|
|
|
519
579
|
citation.appendChild(node);
|
|
520
580
|
}
|
|
521
581
|
}
|
|
522
|
-
if (
|
|
582
|
+
if (bibliographyItem.DOI) {
|
|
523
583
|
const node = this.document.createElement('pub-id');
|
|
524
584
|
node.setAttribute('pub-id-type', 'doi');
|
|
525
|
-
node.textContent = String(
|
|
585
|
+
node.textContent = String(bibliographyItem.DOI);
|
|
526
586
|
citation.appendChild(node);
|
|
527
587
|
}
|
|
528
588
|
ref.appendChild(citation);
|
|
@@ -532,6 +592,7 @@ class JATSExporter {
|
|
|
532
592
|
return back;
|
|
533
593
|
};
|
|
534
594
|
this.createSerializer = () => {
|
|
595
|
+
const getModel = (id) => id ? this.modelMap.get(id) : undefined;
|
|
535
596
|
const nodes = {
|
|
536
597
|
author_notes: () => '',
|
|
537
598
|
corresp: () => '',
|
|
@@ -593,25 +654,24 @@ class JATSExporter {
|
|
|
593
654
|
return xref;
|
|
594
655
|
},
|
|
595
656
|
cross_reference: (node) => {
|
|
596
|
-
var _a;
|
|
597
657
|
const cross = node;
|
|
598
658
|
const rids = cross.attrs.rids;
|
|
599
659
|
if (!rids.length) {
|
|
600
660
|
return cross.attrs.label;
|
|
601
661
|
}
|
|
602
662
|
const text = cross.attrs.customLabel || cross.attrs.label;
|
|
603
|
-
const
|
|
604
|
-
if (!
|
|
663
|
+
const model = getModel(rids[0]);
|
|
664
|
+
if (!model) {
|
|
605
665
|
warn('');
|
|
606
666
|
return text;
|
|
607
667
|
}
|
|
608
668
|
const xref = this.document.createElement('xref');
|
|
609
|
-
const type = chooseRefType(
|
|
669
|
+
const type = chooseRefType(model.objectType);
|
|
610
670
|
if (type) {
|
|
611
671
|
xref.setAttribute('ref-type', type);
|
|
612
672
|
}
|
|
613
673
|
else {
|
|
614
|
-
warn(`Unset ref-type for
|
|
674
|
+
warn(`Unset ref-type for objectType ${model.objectType}`);
|
|
615
675
|
}
|
|
616
676
|
xref.setAttribute('rid', normalizeID(rids.join(' ')));
|
|
617
677
|
xref.textContent = text;
|
|
@@ -683,10 +743,7 @@ class JATSExporter {
|
|
|
683
743
|
hard_break: () => '',
|
|
684
744
|
highlight_marker: () => '',
|
|
685
745
|
inline_footnote: (node) => {
|
|
686
|
-
const rids = node.attrs.rids.filter(
|
|
687
|
-
var _a;
|
|
688
|
-
return (_a = (0, prosemirror_utils_1.findChildrenByAttr)(this.manuscriptNode, (attrs) => attrs.id === rid)[0]) === null || _a === void 0 ? void 0 : _a.node;
|
|
689
|
-
});
|
|
746
|
+
const rids = node.attrs.rids.filter(getModel);
|
|
690
747
|
if (rids.length == 0) {
|
|
691
748
|
return '';
|
|
692
749
|
}
|
|
@@ -805,7 +862,14 @@ class JATSExporter {
|
|
|
805
862
|
italic: () => ['italic'],
|
|
806
863
|
smallcaps: () => ['sc'],
|
|
807
864
|
strikethrough: () => ['strike'],
|
|
808
|
-
styled: () =>
|
|
865
|
+
styled: (mark) => {
|
|
866
|
+
const inlineStyle = getModel(mark.attrs.rid);
|
|
867
|
+
const attrs = {};
|
|
868
|
+
if (inlineStyle && inlineStyle.title) {
|
|
869
|
+
attrs.style = (0, styled_content_1.normalizeStyleName)(inlineStyle.title);
|
|
870
|
+
}
|
|
871
|
+
return ['styled-content', attrs];
|
|
872
|
+
},
|
|
809
873
|
superscript: () => ['sup'],
|
|
810
874
|
subscript: () => ['sub'],
|
|
811
875
|
underline: () => ['underline'],
|
|
@@ -856,16 +920,14 @@ class JATSExporter {
|
|
|
856
920
|
}
|
|
857
921
|
};
|
|
858
922
|
const appendChildNodeOfType = (element, node, type) => {
|
|
859
|
-
|
|
860
|
-
const childNode = (_a = (0, prosemirror_utils_1.findChildrenByType)(node, type)[0]) === null || _a === void 0 ? void 0 : _a.node;
|
|
923
|
+
const childNode = findChildNodeOfType(node, type);
|
|
861
924
|
if (childNode) {
|
|
862
925
|
element.appendChild(this.serializeNode(childNode));
|
|
863
926
|
}
|
|
864
927
|
};
|
|
865
928
|
const appendTable = (element, node) => {
|
|
866
|
-
|
|
867
|
-
const
|
|
868
|
-
const colGroupNode = (_b = (0, prosemirror_utils_1.findChildrenByType)(node, node.type.schema.nodes.table_colgroup)[0]) === null || _b === void 0 ? void 0 : _b.node;
|
|
929
|
+
const tableNode = findChildNodeOfType(node, node.type.schema.nodes.table);
|
|
930
|
+
const colGroupNode = findChildNodeOfType(node, node.type.schema.nodes.table_colgroup);
|
|
869
931
|
if (!tableNode) {
|
|
870
932
|
return;
|
|
871
933
|
}
|
|
@@ -911,8 +973,7 @@ class JATSExporter {
|
|
|
911
973
|
return element;
|
|
912
974
|
};
|
|
913
975
|
const processExecutableNode = (node, element) => {
|
|
914
|
-
|
|
915
|
-
const listingNode = (_a = (0, prosemirror_utils_1.findChildrenByType)(node, node.type.schema.nodes.listing)[0]) === null || _a === void 0 ? void 0 : _a.node;
|
|
976
|
+
const listingNode = findChildNodeOfType(node, node.type.schema.nodes.listing);
|
|
916
977
|
if (listingNode) {
|
|
917
978
|
const { contents, languageKey } = listingNode.attrs;
|
|
918
979
|
if (contents && languageKey) {
|
|
@@ -946,25 +1007,25 @@ class JATSExporter {
|
|
|
946
1007
|
}
|
|
947
1008
|
};
|
|
948
1009
|
};
|
|
1010
|
+
this.serializeFragment = (fragment) => this.serializer.serializeFragment(fragment, {
|
|
1011
|
+
document: this.document,
|
|
1012
|
+
});
|
|
949
1013
|
this.serializeNode = (node) => this.serializer.serializeNode(node, {
|
|
950
1014
|
document: this.document,
|
|
951
1015
|
});
|
|
952
1016
|
this.validateContributor = (contributor) => {
|
|
953
|
-
if (!contributor.
|
|
954
|
-
throw new Error(`${contributor.
|
|
1017
|
+
if (!contributor.bibliographicName) {
|
|
1018
|
+
throw new Error(`${contributor._id} has no bibliographicName`);
|
|
955
1019
|
}
|
|
956
|
-
const { family, given } = contributor.
|
|
1020
|
+
const { family, given } = contributor.bibliographicName;
|
|
957
1021
|
if (!family && !given) {
|
|
958
|
-
throw new Error(`${contributor.
|
|
1022
|
+
throw new Error(`${contributor._id} has neither family nor given name`);
|
|
959
1023
|
}
|
|
960
1024
|
};
|
|
961
1025
|
this.buildContributors = (articleMeta) => {
|
|
962
|
-
const
|
|
963
|
-
const
|
|
964
|
-
.filter((
|
|
965
|
-
.sort(sortContributors);
|
|
966
|
-
const otherContributorsNodes = contributorNodes
|
|
967
|
-
.filter((n) => n.attrs.role !== 'author')
|
|
1026
|
+
const contributors = this.models.filter(isContributor);
|
|
1027
|
+
const authorContributors = contributors
|
|
1028
|
+
.filter((contributor) => contributor.role === 'author')
|
|
968
1029
|
.sort(sortContributors);
|
|
969
1030
|
const affiliationLabels = new Map();
|
|
970
1031
|
const creatAffiliationLabel = (rid) => {
|
|
@@ -982,11 +1043,11 @@ class JATSExporter {
|
|
|
982
1043
|
sup.textContent = String(content);
|
|
983
1044
|
return sup;
|
|
984
1045
|
};
|
|
985
|
-
if (
|
|
1046
|
+
if (authorContributors.length) {
|
|
986
1047
|
const contribGroup = this.document.createElement('contrib-group');
|
|
987
1048
|
contribGroup.setAttribute('content-type', 'authors');
|
|
988
1049
|
articleMeta.appendChild(contribGroup);
|
|
989
|
-
|
|
1050
|
+
authorContributors.forEach((contributor) => {
|
|
990
1051
|
try {
|
|
991
1052
|
this.validateContributor(contributor);
|
|
992
1053
|
}
|
|
@@ -996,25 +1057,39 @@ class JATSExporter {
|
|
|
996
1057
|
}
|
|
997
1058
|
const contrib = this.document.createElement('contrib');
|
|
998
1059
|
contrib.setAttribute('contrib-type', 'author');
|
|
999
|
-
contrib.setAttribute('id', normalizeID(contributor.
|
|
1000
|
-
if (contributor.
|
|
1060
|
+
contrib.setAttribute('id', normalizeID(contributor._id));
|
|
1061
|
+
if (contributor.isCorresponding) {
|
|
1001
1062
|
contrib.setAttribute('corresp', 'yes');
|
|
1002
1063
|
}
|
|
1003
|
-
if (contributor.
|
|
1064
|
+
if (contributor.ORCIDIdentifier) {
|
|
1004
1065
|
const identifier = this.document.createElement('contrib-id');
|
|
1005
1066
|
identifier.setAttribute('contrib-id-type', 'orcid');
|
|
1006
|
-
identifier.textContent = contributor.
|
|
1067
|
+
identifier.textContent = contributor.ORCIDIdentifier;
|
|
1007
1068
|
contrib.appendChild(identifier);
|
|
1008
1069
|
}
|
|
1009
1070
|
const name = this.buildContributorName(contributor);
|
|
1010
1071
|
contrib.appendChild(name);
|
|
1011
|
-
if (contributor.
|
|
1072
|
+
if (contributor.email) {
|
|
1012
1073
|
const email = this.document.createElement('email');
|
|
1013
|
-
email.textContent = contributor.
|
|
1074
|
+
email.textContent = contributor.email;
|
|
1014
1075
|
contrib.appendChild(email);
|
|
1015
1076
|
}
|
|
1016
|
-
if (contributor.
|
|
1017
|
-
contributor.
|
|
1077
|
+
if (contributor.roles) {
|
|
1078
|
+
contributor.roles.forEach((rid) => {
|
|
1079
|
+
const contributorRole = this.modelMap.get(rid);
|
|
1080
|
+
if (contributorRole) {
|
|
1081
|
+
const role = this.document.createElement('role');
|
|
1082
|
+
const attributes = chooseRoleVocabAttributes(contributorRole);
|
|
1083
|
+
for (const [key, value] of Object.entries(attributes)) {
|
|
1084
|
+
role.setAttribute(key, value);
|
|
1085
|
+
}
|
|
1086
|
+
role.textContent = contributorRole.name;
|
|
1087
|
+
contrib.appendChild(role);
|
|
1088
|
+
}
|
|
1089
|
+
});
|
|
1090
|
+
}
|
|
1091
|
+
if (contributor.affiliations) {
|
|
1092
|
+
contributor.affiliations.forEach((rid) => {
|
|
1018
1093
|
const xref = this.document.createElement('xref');
|
|
1019
1094
|
xref.setAttribute('ref-type', 'aff');
|
|
1020
1095
|
xref.setAttribute('rid', normalizeID(rid));
|
|
@@ -1022,8 +1097,8 @@ class JATSExporter {
|
|
|
1022
1097
|
contrib.appendChild(xref);
|
|
1023
1098
|
});
|
|
1024
1099
|
}
|
|
1025
|
-
if (contributor.
|
|
1026
|
-
contributor.
|
|
1100
|
+
if (contributor.footnote) {
|
|
1101
|
+
contributor.footnote.map((note) => {
|
|
1027
1102
|
const xref = this.document.createElement('xref');
|
|
1028
1103
|
xref.setAttribute('ref-type', 'fn');
|
|
1029
1104
|
xref.setAttribute('rid', normalizeID(note.noteID));
|
|
@@ -1031,8 +1106,8 @@ class JATSExporter {
|
|
|
1031
1106
|
contrib.appendChild(xref);
|
|
1032
1107
|
});
|
|
1033
1108
|
}
|
|
1034
|
-
if (contributor.
|
|
1035
|
-
contributor.
|
|
1109
|
+
if (contributor.corresp) {
|
|
1110
|
+
contributor.corresp.map((corresp) => {
|
|
1036
1111
|
const xref = this.document.createElement('xref');
|
|
1037
1112
|
xref.setAttribute('ref-type', 'corresp');
|
|
1038
1113
|
xref.setAttribute('rid', normalizeID(corresp.correspID));
|
|
@@ -1042,10 +1117,13 @@ class JATSExporter {
|
|
|
1042
1117
|
}
|
|
1043
1118
|
contribGroup.appendChild(contrib);
|
|
1044
1119
|
});
|
|
1045
|
-
|
|
1120
|
+
const otherContributors = contributors
|
|
1121
|
+
.filter((contributor) => contributor.role !== 'author')
|
|
1122
|
+
.sort(sortContributors);
|
|
1123
|
+
if (otherContributors.length) {
|
|
1046
1124
|
const contribGroup = this.document.createElement('contrib-group');
|
|
1047
1125
|
articleMeta.appendChild(contribGroup);
|
|
1048
|
-
|
|
1126
|
+
otherContributors.forEach((contributor) => {
|
|
1049
1127
|
try {
|
|
1050
1128
|
this.validateContributor(contributor);
|
|
1051
1129
|
}
|
|
@@ -1054,16 +1132,30 @@ class JATSExporter {
|
|
|
1054
1132
|
return;
|
|
1055
1133
|
}
|
|
1056
1134
|
const contrib = this.document.createElement('contrib');
|
|
1057
|
-
contrib.setAttribute('id', normalizeID(contributor.
|
|
1135
|
+
contrib.setAttribute('id', normalizeID(contributor._id));
|
|
1058
1136
|
const name = this.buildContributorName(contributor);
|
|
1059
1137
|
contrib.appendChild(name);
|
|
1060
|
-
if (contributor.
|
|
1138
|
+
if (contributor.email) {
|
|
1061
1139
|
const email = this.document.createElement('email');
|
|
1062
|
-
email.textContent = contributor.
|
|
1140
|
+
email.textContent = contributor.email;
|
|
1063
1141
|
contrib.appendChild(email);
|
|
1064
1142
|
}
|
|
1065
|
-
if (contributor.
|
|
1066
|
-
contributor.
|
|
1143
|
+
if (contributor.roles) {
|
|
1144
|
+
contributor.roles.forEach((rid) => {
|
|
1145
|
+
const contributorRole = this.modelMap.get(rid);
|
|
1146
|
+
if (contributorRole) {
|
|
1147
|
+
const role = this.document.createElement('role');
|
|
1148
|
+
const attributes = chooseRoleVocabAttributes(contributorRole);
|
|
1149
|
+
for (const [key, value] of Object.entries(attributes)) {
|
|
1150
|
+
role.setAttribute(key, value);
|
|
1151
|
+
}
|
|
1152
|
+
role.textContent = contributorRole.name;
|
|
1153
|
+
contrib.appendChild(role);
|
|
1154
|
+
}
|
|
1155
|
+
});
|
|
1156
|
+
}
|
|
1157
|
+
if (contributor.affiliations) {
|
|
1158
|
+
contributor.affiliations.forEach((rid) => {
|
|
1067
1159
|
const xref = this.document.createElement('xref');
|
|
1068
1160
|
xref.setAttribute('ref-type', 'aff');
|
|
1069
1161
|
xref.setAttribute('rid', normalizeID(rid));
|
|
@@ -1071,8 +1163,8 @@ class JATSExporter {
|
|
|
1071
1163
|
contrib.appendChild(xref);
|
|
1072
1164
|
});
|
|
1073
1165
|
}
|
|
1074
|
-
if (contributor.
|
|
1075
|
-
contributor.
|
|
1166
|
+
if (contributor.footnote) {
|
|
1167
|
+
contributor.footnote.map((note) => {
|
|
1076
1168
|
const xref = this.document.createElement('xref');
|
|
1077
1169
|
xref.setAttribute('ref-type', 'fn');
|
|
1078
1170
|
xref.setAttribute('rid', normalizeID(note.noteID));
|
|
@@ -1084,68 +1176,64 @@ class JATSExporter {
|
|
|
1084
1176
|
});
|
|
1085
1177
|
}
|
|
1086
1178
|
const affiliationRIDs = [];
|
|
1087
|
-
const sortedContributors = [
|
|
1088
|
-
...authorContributorNodes,
|
|
1089
|
-
...otherContributorsNodes,
|
|
1090
|
-
];
|
|
1179
|
+
const sortedContributors = [...authorContributors, ...otherContributors];
|
|
1091
1180
|
for (const contributor of sortedContributors) {
|
|
1092
|
-
if (contributor.
|
|
1093
|
-
affiliationRIDs.push(...contributor.
|
|
1181
|
+
if (contributor.affiliations) {
|
|
1182
|
+
affiliationRIDs.push(...contributor.affiliations);
|
|
1094
1183
|
}
|
|
1095
1184
|
}
|
|
1096
|
-
const affiliations = (0,
|
|
1185
|
+
const affiliations = this.models.filter((0, object_types_1.hasObjectType)(json_schema_1.ObjectTypes.Affiliation));
|
|
1097
1186
|
if (affiliations) {
|
|
1098
|
-
const usedAffiliations = affiliations.filter((affiliation) => affiliationRIDs.includes(affiliation.
|
|
1099
|
-
usedAffiliations.sort((a, b) => affiliationRIDs.indexOf(a.
|
|
1100
|
-
affiliationRIDs.indexOf(b.attrs.id));
|
|
1187
|
+
const usedAffiliations = affiliations.filter((affiliation) => affiliationRIDs.includes(affiliation._id));
|
|
1188
|
+
usedAffiliations.sort((a, b) => affiliationRIDs.indexOf(a._id) - affiliationRIDs.indexOf(b._id));
|
|
1101
1189
|
usedAffiliations.forEach((affiliation) => {
|
|
1102
1190
|
var _a, _b;
|
|
1103
1191
|
const aff = this.document.createElement('aff');
|
|
1104
|
-
aff.setAttribute('id', normalizeID(affiliation.
|
|
1192
|
+
aff.setAttribute('id', normalizeID(affiliation._id));
|
|
1105
1193
|
contribGroup.appendChild(aff);
|
|
1106
|
-
if (affiliation.
|
|
1194
|
+
if (affiliation.department) {
|
|
1107
1195
|
const department = this.document.createElement('institution');
|
|
1108
1196
|
department.setAttribute('content-type', 'dept');
|
|
1109
|
-
department.textContent = affiliation.
|
|
1197
|
+
department.textContent = affiliation.department;
|
|
1110
1198
|
aff.appendChild(department);
|
|
1111
1199
|
}
|
|
1112
|
-
if (affiliation.
|
|
1200
|
+
if (affiliation.institution) {
|
|
1113
1201
|
const institution = this.document.createElement('institution');
|
|
1114
|
-
institution.textContent = affiliation.
|
|
1202
|
+
institution.textContent = affiliation.institution;
|
|
1115
1203
|
aff.appendChild(institution);
|
|
1116
1204
|
}
|
|
1117
|
-
if (affiliation.
|
|
1205
|
+
if (affiliation.addressLine1) {
|
|
1118
1206
|
const addressLine = this.document.createElement('addr-line');
|
|
1119
|
-
addressLine.textContent = affiliation.
|
|
1207
|
+
addressLine.textContent = affiliation.addressLine1;
|
|
1120
1208
|
aff.appendChild(addressLine);
|
|
1121
1209
|
}
|
|
1122
|
-
if (affiliation.
|
|
1210
|
+
if (affiliation.addressLine2) {
|
|
1123
1211
|
const addressLine = this.document.createElement('addr-line');
|
|
1124
|
-
addressLine.textContent = affiliation.
|
|
1212
|
+
addressLine.textContent = affiliation.addressLine2;
|
|
1125
1213
|
aff.appendChild(addressLine);
|
|
1126
1214
|
}
|
|
1127
|
-
if (affiliation.
|
|
1215
|
+
if (affiliation.addressLine3) {
|
|
1128
1216
|
const addressLine = this.document.createElement('addr-line');
|
|
1129
|
-
addressLine.textContent = affiliation.
|
|
1217
|
+
addressLine.textContent = affiliation.addressLine3;
|
|
1130
1218
|
aff.appendChild(addressLine);
|
|
1131
1219
|
}
|
|
1132
|
-
if (affiliation.
|
|
1220
|
+
if (affiliation.city) {
|
|
1133
1221
|
const city = this.document.createElement('city');
|
|
1134
|
-
city.textContent = affiliation.
|
|
1222
|
+
city.textContent = affiliation.city;
|
|
1135
1223
|
aff.appendChild(city);
|
|
1136
1224
|
}
|
|
1137
|
-
if (affiliation.
|
|
1225
|
+
if (affiliation.country) {
|
|
1138
1226
|
const country = this.document.createElement('country');
|
|
1139
|
-
country.textContent = affiliation.
|
|
1227
|
+
country.textContent = affiliation.country;
|
|
1140
1228
|
aff.appendChild(country);
|
|
1141
1229
|
}
|
|
1142
|
-
if (affiliation.
|
|
1230
|
+
if (affiliation.email) {
|
|
1143
1231
|
const email = this.document.createElement('email');
|
|
1144
|
-
email.setAttributeNS(XLINK_NAMESPACE, 'href', (_a = affiliation.
|
|
1145
|
-
email.textContent = (_b = affiliation.
|
|
1232
|
+
email.setAttributeNS(XLINK_NAMESPACE, 'href', (_a = affiliation.email.href) !== null && _a !== void 0 ? _a : '');
|
|
1233
|
+
email.textContent = (_b = affiliation.email.text) !== null && _b !== void 0 ? _b : '';
|
|
1146
1234
|
aff.appendChild(email);
|
|
1147
1235
|
}
|
|
1148
|
-
const labelNumber = affiliationLabels.get(affiliation.
|
|
1236
|
+
const labelNumber = affiliationLabels.get(affiliation._id);
|
|
1149
1237
|
if (labelNumber) {
|
|
1150
1238
|
const label = this.document.createElement('label');
|
|
1151
1239
|
label.textContent = String(labelNumber);
|
|
@@ -1162,48 +1250,41 @@ class JATSExporter {
|
|
|
1162
1250
|
this.createAuthorNotesElement = () => {
|
|
1163
1251
|
var _a;
|
|
1164
1252
|
const authorNotesEl = this.document.createElement('author-notes');
|
|
1165
|
-
const
|
|
1166
|
-
if (
|
|
1167
|
-
this.appendModelsToAuthorNotes(authorNotesEl,
|
|
1253
|
+
const authorNotes = (_a = (0, json_schema_1.getModelsByType)(this.modelMap, json_schema_1.ObjectTypes.AuthorNotes)) === null || _a === void 0 ? void 0 : _a[0];
|
|
1254
|
+
if (authorNotes) {
|
|
1255
|
+
this.appendModelsToAuthorNotes(authorNotesEl, authorNotes.containedObjectIDs);
|
|
1168
1256
|
}
|
|
1169
1257
|
return authorNotesEl;
|
|
1170
1258
|
};
|
|
1171
1259
|
this.appendCorrespondingToElement = (corresponding, element) => {
|
|
1172
1260
|
const correspondingEl = this.document.createElement('corresp');
|
|
1173
|
-
correspondingEl.setAttribute('id', normalizeID(corresponding.
|
|
1174
|
-
if (corresponding.
|
|
1261
|
+
correspondingEl.setAttribute('id', normalizeID(corresponding._id));
|
|
1262
|
+
if (corresponding.label) {
|
|
1175
1263
|
const labelEl = this.document.createElement('label');
|
|
1176
|
-
labelEl.textContent = corresponding.
|
|
1264
|
+
labelEl.textContent = corresponding.label;
|
|
1177
1265
|
correspondingEl.appendChild(labelEl);
|
|
1178
1266
|
}
|
|
1179
|
-
correspondingEl.append(corresponding.
|
|
1267
|
+
correspondingEl.append(corresponding.contents);
|
|
1180
1268
|
element.appendChild(correspondingEl);
|
|
1181
1269
|
};
|
|
1182
1270
|
this.appendParagraphToElement = (paragraph, element) => {
|
|
1183
|
-
const parsedDoc = new DOMParser().parseFromString(paragraph.
|
|
1271
|
+
const parsedDoc = new DOMParser().parseFromString(paragraph.contents, 'text/html');
|
|
1184
1272
|
const parsedParagraph = parsedDoc.body.querySelector('p');
|
|
1185
1273
|
if (parsedParagraph) {
|
|
1186
1274
|
const paragraphEl = this.document.createElement('p');
|
|
1187
1275
|
paragraphEl.innerHTML = parsedParagraph.innerHTML;
|
|
1188
|
-
paragraphEl.setAttribute('id', normalizeID(paragraph.
|
|
1276
|
+
paragraphEl.setAttribute('id', normalizeID(paragraph._id));
|
|
1189
1277
|
element.appendChild(paragraphEl);
|
|
1190
1278
|
}
|
|
1191
1279
|
};
|
|
1192
1280
|
this.appendFootnoteToElement = (footnote, element) => {
|
|
1193
1281
|
const footnoteEl = this.document.createElement('fn');
|
|
1194
|
-
footnoteEl.setAttribute('id', normalizeID(footnote.
|
|
1195
|
-
|
|
1196
|
-
const p = this.document.createElement('p');
|
|
1197
|
-
p.innerHTML = footnote.textContent;
|
|
1198
|
-
footnoteEl.appendChild(p);
|
|
1199
|
-
}
|
|
1200
|
-
else {
|
|
1201
|
-
footnoteEl.innerHTML = footnote.textContent;
|
|
1202
|
-
}
|
|
1282
|
+
footnoteEl.setAttribute('id', normalizeID(footnote._id));
|
|
1283
|
+
footnoteEl.innerHTML = footnote.contents;
|
|
1203
1284
|
element.appendChild(footnoteEl);
|
|
1204
1285
|
};
|
|
1205
|
-
this.fixBody = (body) => {
|
|
1206
|
-
|
|
1286
|
+
this.fixBody = (body, fragment) => {
|
|
1287
|
+
fragment.descendants((node) => {
|
|
1207
1288
|
if (node.attrs.id) {
|
|
1208
1289
|
if (node.attrs.titleSuppressed) {
|
|
1209
1290
|
const title = body.querySelector(`#${normalizeID(node.attrs.id)} > title`);
|
|
@@ -1464,36 +1545,36 @@ class JATSExporter {
|
|
|
1464
1545
|
};
|
|
1465
1546
|
this.buildContributorName = (contributor) => {
|
|
1466
1547
|
const name = this.document.createElement('name');
|
|
1467
|
-
if (contributor.
|
|
1548
|
+
if (contributor.bibliographicName.family) {
|
|
1468
1549
|
const surname = this.document.createElement('surname');
|
|
1469
|
-
surname.textContent = contributor.
|
|
1550
|
+
surname.textContent = contributor.bibliographicName.family;
|
|
1470
1551
|
name.appendChild(surname);
|
|
1471
1552
|
}
|
|
1472
|
-
if (contributor.
|
|
1553
|
+
if (contributor.bibliographicName.given) {
|
|
1473
1554
|
const givenNames = this.document.createElement('given-names');
|
|
1474
|
-
givenNames.textContent = contributor.
|
|
1555
|
+
givenNames.textContent = contributor.bibliographicName.given;
|
|
1475
1556
|
name.appendChild(givenNames);
|
|
1476
1557
|
}
|
|
1477
1558
|
return name;
|
|
1478
1559
|
};
|
|
1479
1560
|
}
|
|
1480
|
-
generateCitations() {
|
|
1561
|
+
generateCitations(fragment) {
|
|
1481
1562
|
const nodes = [];
|
|
1482
|
-
|
|
1563
|
+
fragment.descendants((node) => {
|
|
1483
1564
|
if ((0, schema_1.isCitationNode)(node)) {
|
|
1484
1565
|
nodes.push(node);
|
|
1485
1566
|
}
|
|
1486
1567
|
});
|
|
1487
1568
|
return (0, exports.buildCitations)(nodes);
|
|
1488
1569
|
}
|
|
1489
|
-
generateCitationTexts(
|
|
1570
|
+
generateCitationTexts(fragment, csl) {
|
|
1490
1571
|
this.citationTexts = new Map();
|
|
1491
1572
|
this.citationProvider = new library_1.CitationProvider({
|
|
1492
|
-
getLibraryItem: this.
|
|
1573
|
+
getLibraryItem: (id) => this.modelMap.get(id),
|
|
1493
1574
|
locale: csl.locale,
|
|
1494
1575
|
citationStyle: csl.style,
|
|
1495
1576
|
});
|
|
1496
|
-
const citations = this.generateCitations();
|
|
1577
|
+
const citations = this.generateCitations(fragment);
|
|
1497
1578
|
this.citationProvider.rebuildState(citations).forEach(([id, , output]) => {
|
|
1498
1579
|
this.citationTexts.set(id, output);
|
|
1499
1580
|
});
|
|
@@ -1520,50 +1601,72 @@ class JATSExporter {
|
|
|
1520
1601
|
return mathml;
|
|
1521
1602
|
}
|
|
1522
1603
|
}
|
|
1523
|
-
appendModelsToAuthorNotes(authorNotesEl,
|
|
1524
|
-
const
|
|
1525
|
-
const usedCorrespondings = this.getUsedCorrespondings(
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1604
|
+
appendModelsToAuthorNotes(authorNotesEl, containedObjectIDs) {
|
|
1605
|
+
const contributors = this.models.filter(isContributor);
|
|
1606
|
+
const usedCorrespondings = this.getUsedCorrespondings(contributors);
|
|
1607
|
+
containedObjectIDs.forEach((id) => {
|
|
1608
|
+
const model = this.modelMap.get(id);
|
|
1609
|
+
if (!model) {
|
|
1610
|
+
return;
|
|
1611
|
+
}
|
|
1612
|
+
switch (model.objectType) {
|
|
1613
|
+
case json_schema_1.ObjectTypes.ParagraphElement:
|
|
1614
|
+
this.appendParagraphToElement(model, authorNotesEl);
|
|
1530
1615
|
break;
|
|
1531
|
-
case
|
|
1532
|
-
this.appendFootnoteToElement(
|
|
1616
|
+
case json_schema_1.ObjectTypes.Footnote:
|
|
1617
|
+
this.appendFootnoteToElement(model, authorNotesEl);
|
|
1533
1618
|
break;
|
|
1534
|
-
case
|
|
1535
|
-
if (usedCorrespondings.includes(
|
|
1536
|
-
this.appendCorrespondingToElement(
|
|
1619
|
+
case json_schema_1.ObjectTypes.Corresponding:
|
|
1620
|
+
if (usedCorrespondings.includes(model)) {
|
|
1621
|
+
this.appendCorrespondingToElement(model, authorNotesEl);
|
|
1537
1622
|
}
|
|
1538
1623
|
break;
|
|
1539
1624
|
}
|
|
1540
|
-
return false;
|
|
1541
1625
|
});
|
|
1542
1626
|
}
|
|
1543
1627
|
getUsedCorrespondings(contributors) {
|
|
1544
1628
|
return contributors
|
|
1545
|
-
.flatMap((c) => { var _a; return (_a = c.
|
|
1546
|
-
.map((corresp) =>
|
|
1547
|
-
var _a;
|
|
1548
|
-
return (_a = (0, prosemirror_utils_1.findChildrenByAttr)(this.manuscriptNode, (attr) => attr.id === corresp.correspID)[0]) === null || _a === void 0 ? void 0 : _a.node;
|
|
1549
|
-
})
|
|
1629
|
+
.flatMap((c) => { var _a; return (_a = c.corresp) !== null && _a !== void 0 ? _a : []; })
|
|
1630
|
+
.map((corresp) => this.modelMap.get(corresp.correspID))
|
|
1550
1631
|
.filter((corresp) => !!corresp);
|
|
1551
1632
|
}
|
|
1552
1633
|
buildKeywords(articleMeta) {
|
|
1553
|
-
const
|
|
1554
|
-
keywordGroups
|
|
1634
|
+
const keywords = [...this.modelMap.values()].filter((model) => model.objectType === json_schema_1.ObjectTypes.Keyword);
|
|
1635
|
+
const keywordGroups = new Map();
|
|
1636
|
+
keywords.forEach((keyword) => {
|
|
1637
|
+
const containedGroup = keyword.containedGroup || '';
|
|
1638
|
+
const group = keywordGroups.get(containedGroup);
|
|
1639
|
+
if (group) {
|
|
1640
|
+
group.push(keyword);
|
|
1641
|
+
}
|
|
1642
|
+
else {
|
|
1643
|
+
keywordGroups.set(containedGroup, [keyword]);
|
|
1644
|
+
}
|
|
1645
|
+
});
|
|
1646
|
+
for (const [groupID, keywords] of keywordGroups) {
|
|
1647
|
+
const keywordGroup = (this.modelMap.get(groupID) || {});
|
|
1555
1648
|
const kwdGroup = this.document.createElement('kwd-group');
|
|
1556
|
-
if (
|
|
1557
|
-
kwdGroup.setAttribute('kwd-group-type',
|
|
1649
|
+
if (keywordGroup.type) {
|
|
1650
|
+
kwdGroup.setAttribute('kwd-group-type', keywordGroup.type);
|
|
1651
|
+
}
|
|
1652
|
+
if (keywordGroup.label) {
|
|
1653
|
+
const label = this.document.createElement('label');
|
|
1654
|
+
label.textContent = keywordGroup.label;
|
|
1655
|
+
kwdGroup.appendChild(label);
|
|
1656
|
+
}
|
|
1657
|
+
if (keywordGroup.title) {
|
|
1658
|
+
const title = this.document.createElement('title');
|
|
1659
|
+
title.textContent = keywordGroup.title;
|
|
1660
|
+
kwdGroup.appendChild(title);
|
|
1558
1661
|
}
|
|
1559
1662
|
articleMeta.appendChild(kwdGroup);
|
|
1560
|
-
|
|
1663
|
+
for (const keyword of keywords) {
|
|
1561
1664
|
const kwd = this.document.createElement('kwd');
|
|
1562
|
-
kwd.textContent = keyword.
|
|
1665
|
+
kwd.textContent = keyword.name;
|
|
1563
1666
|
kwdGroup.appendChild(kwd);
|
|
1564
|
-
}
|
|
1667
|
+
}
|
|
1565
1668
|
articleMeta.appendChild(kwdGroup);
|
|
1566
|
-
}
|
|
1669
|
+
}
|
|
1567
1670
|
}
|
|
1568
1671
|
moveCoiStatementToAuthorNotes(back, front) {
|
|
1569
1672
|
const fnGroups = back.querySelectorAll('fn-group');
|