@manuscripts/transform 2.3.36 → 2.3.37-LEAN-3911.1
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/create-article-node.js +31 -0
- package/dist/cjs/jats/importer/index.js +3 -3
- package/dist/cjs/jats/importer/jats-body-transformations.js +70 -0
- package/dist/cjs/jats/importer/jats-comments.js +27 -104
- package/dist/cjs/jats/importer/{jats-body-dom-parser.js → jats-dom-parser.js} +229 -9
- package/dist/cjs/jats/importer/jats-front-transformations.js +262 -0
- package/dist/cjs/jats/importer/jats-journal-meta-parser.js +8 -1
- package/dist/cjs/jats/importer/jats-parser-utils.js +39 -5
- package/dist/cjs/jats/importer/jats-reference-parser.js +16 -27
- package/dist/cjs/jats/importer/jats-references.js +18 -18
- package/dist/cjs/jats/importer/parse-jats-article.js +42 -78
- package/dist/cjs/jats/index.js +4 -3
- package/dist/cjs/jats/jats-exporter.js +253 -366
- package/dist/cjs/{transformer → jats}/labels.js +3 -3
- package/dist/cjs/lib/utils.js +9 -1
- package/dist/cjs/transformer/id.js +10 -5
- package/dist/cjs/transformer/index.js +0 -18
- package/dist/cjs/version.js +1 -1
- package/dist/{cjs/transformer/serializer.js → es/jats/importer/create-article-node.js} +12 -8
- package/dist/es/jats/importer/index.js +2 -1
- package/dist/es/jats/importer/jats-body-transformations.js +70 -0
- package/dist/es/jats/importer/jats-comments.js +26 -101
- package/dist/es/jats/importer/{jats-body-dom-parser.js → jats-dom-parser.js} +230 -10
- package/dist/es/jats/importer/jats-front-transformations.js +259 -0
- package/dist/es/jats/importer/jats-journal-meta-parser.js +6 -0
- package/dist/es/jats/importer/jats-parser-utils.js +40 -6
- package/dist/es/jats/importer/jats-reference-parser.js +16 -27
- package/dist/es/jats/importer/jats-references.js +18 -18
- package/dist/es/jats/importer/parse-jats-article.js +43 -77
- package/dist/es/jats/index.js +3 -1
- package/dist/es/jats/jats-exporter.js +255 -368
- package/dist/es/{transformer → jats}/labels.js +3 -3
- package/dist/es/lib/utils.js +7 -0
- package/dist/es/transformer/id.js +8 -3
- package/dist/es/transformer/index.js +0 -16
- package/dist/es/version.js +1 -1
- package/dist/{cjs/transformer/models.js → types/jats/importer/create-article-node.d.ts} +3 -3
- package/dist/types/jats/importer/index.d.ts +2 -1
- package/dist/types/jats/importer/jats-body-transformations.d.ts +5 -0
- package/dist/types/jats/importer/jats-comments.d.ts +4 -10
- package/dist/types/jats/importer/{jats-body-dom-parser.d.ts → jats-dom-parser.d.ts} +1 -1
- package/dist/types/jats/importer/jats-front-transformations.d.ts +38 -0
- package/dist/types/jats/importer/jats-journal-meta-parser.d.ts +10 -0
- package/dist/types/jats/importer/jats-references.d.ts +19 -8
- package/dist/types/jats/importer/parse-jats-article.d.ts +12 -5
- package/dist/types/jats/index.d.ts +3 -1
- package/dist/types/jats/jats-exporter.d.ts +14 -27
- package/dist/types/{transformer → jats}/labels.d.ts +2 -1
- package/dist/types/lib/utils.d.ts +3 -0
- package/dist/types/schema/nodes/bibliography_item.d.ts +28 -5
- package/dist/types/schema/nodes/contributor.d.ts +10 -0
- package/dist/types/schema/nodes/keyword_group.d.ts +1 -0
- package/dist/types/transformer/id.d.ts +5 -2
- package/dist/types/transformer/index.d.ts +0 -16
- package/dist/types/version.d.ts +1 -1
- package/package.json +3 -2
- package/dist/cjs/__tests__/data/project-dump.json +0 -825
- package/dist/cjs/jats/importer/jats-front-parser.js +0 -321
- package/dist/cjs/transformer/__tests__/__helpers__/doc.js +0 -37
- package/dist/cjs/transformer/builders.js +0 -219
- package/dist/cjs/transformer/decode.js +0 -874
- package/dist/cjs/transformer/document-object-types.js +0 -31
- package/dist/cjs/transformer/encode.js +0 -664
- package/dist/cjs/transformer/footnote-category.js +0 -20
- package/dist/cjs/transformer/footnotes-order.js +0 -60
- package/dist/cjs/transformer/highlight-markers.js +0 -138
- package/dist/cjs/transformer/html.js +0 -400
- package/dist/cjs/transformer/manuscript-dependencies.js +0 -21
- package/dist/cjs/transformer/model-map.js +0 -26
- package/dist/cjs/transformer/object-types.js +0 -57
- package/dist/cjs/transformer/project-bundle.js +0 -94
- package/dist/cjs/transformer/update-identifiers.js +0 -93
- package/dist/es/__tests__/data/project-dump.json +0 -825
- package/dist/es/jats/importer/jats-front-parser.js +0 -315
- package/dist/es/transformer/__tests__/__helpers__/doc.js +0 -29
- package/dist/es/transformer/builders.js +0 -186
- package/dist/es/transformer/decode.js +0 -864
- package/dist/es/transformer/document-object-types.js +0 -28
- package/dist/es/transformer/encode.js +0 -654
- package/dist/es/transformer/footnote-category.js +0 -16
- package/dist/es/transformer/footnotes-order.js +0 -55
- package/dist/es/transformer/highlight-markers.js +0 -132
- package/dist/es/transformer/html.js +0 -393
- package/dist/es/transformer/manuscript-dependencies.js +0 -17
- package/dist/es/transformer/model-map.js +0 -22
- package/dist/es/transformer/models.js +0 -16
- package/dist/es/transformer/object-types.js +0 -52
- package/dist/es/transformer/project-bundle.js +0 -85
- package/dist/es/transformer/serializer.js +0 -17
- package/dist/es/transformer/update-identifiers.js +0 -87
- package/dist/types/jats/importer/jats-front-parser.d.ts +0 -84
- package/dist/types/transformer/__tests__/__helpers__/doc.d.ts +0 -18
- package/dist/types/transformer/builders.d.ts +0 -61
- package/dist/types/transformer/decode.d.ts +0 -51
- package/dist/types/transformer/document-object-types.d.ts +0 -17
- package/dist/types/transformer/encode.d.ts +0 -29
- package/dist/types/transformer/footnote-category.d.ts +0 -17
- package/dist/types/transformer/footnotes-order.d.ts +0 -22
- package/dist/types/transformer/highlight-markers.d.ts +0 -31
- package/dist/types/transformer/html.d.ts +0 -36
- package/dist/types/transformer/manuscript-dependencies.d.ts +0 -4
- package/dist/types/transformer/model-map.d.ts +0 -19
- package/dist/types/transformer/models.d.ts +0 -48
- package/dist/types/transformer/object-types.d.ts +0 -30
- package/dist/types/transformer/project-bundle.d.ts +0 -30
- package/dist/types/transformer/serializer.d.ts +0 -19
- package/dist/types/transformer/update-identifiers.d.ts +0 -23
- /package/dist/cjs/{transformer → jats}/filename.js +0 -0
- /package/dist/cjs/{transformer → jats}/timestamp.js +0 -0
- /package/dist/es/{transformer → jats}/filename.js +0 -0
- /package/dist/es/{transformer → jats}/timestamp.js +0 -0
- /package/dist/types/{transformer → jats}/filename.d.ts +0 -0
- /package/dist/types/{transformer → jats}/timestamp.d.ts +0 -0
|
@@ -13,48 +13,23 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import {
|
|
16
|
+
import { ObjectTypes, } from '@manuscripts/json-schema';
|
|
17
17
|
import { CitationProvider } from '@manuscripts/library';
|
|
18
18
|
import debug from 'debug';
|
|
19
|
-
import { DOMParser as ProsemirrorDOMParser,
|
|
19
|
+
import { DOMSerializer, DOMParser as ProsemirrorDOMParser, } from 'prosemirror-model';
|
|
20
|
+
import { findChildrenByAttr, findChildrenByType } from 'prosemirror-utils';
|
|
20
21
|
import serializeToXML from 'w3c-xmlserializer';
|
|
21
22
|
import { nodeFromHTML, textFromHTML } from '../lib/html';
|
|
22
|
-
import { normalizeStyleName } from '../lib/styled-content';
|
|
23
|
-
import { iterateChildren } from '../lib/utils';
|
|
24
23
|
import { isCitationNode, schema, } from '../schema';
|
|
25
|
-
import { generateAttachmentFilename } from '../transformer/filename';
|
|
26
|
-
import { buildTargets } from '../transformer/labels';
|
|
27
24
|
import { isExecutableNodeType, isNodeType } from '../transformer/node-types';
|
|
28
|
-
import { hasObjectType } from '../transformer/object-types';
|
|
29
|
-
import { findManuscript, findManuscriptById, findTitles, } from '../transformer/project-bundle';
|
|
30
25
|
import { chooseJatsFnType, chooseSecType, } from '../transformer/section-category';
|
|
26
|
+
import { generateAttachmentFilename } from './filename';
|
|
31
27
|
import { selectVersionIds } from './jats-versions';
|
|
28
|
+
import { buildTargets } from './labels';
|
|
32
29
|
const warn = debug('manuscripts-transform');
|
|
33
30
|
const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
|
|
34
31
|
const normalizeID = (id) => id.replace(/:/g, '_');
|
|
35
32
|
const parser = ProsemirrorDOMParser.fromSchema(schema);
|
|
36
|
-
const findChildNodeOfType = (node, nodeType) => {
|
|
37
|
-
for (const child of iterateChildren(node)) {
|
|
38
|
-
if (child.type === nodeType) {
|
|
39
|
-
return child;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
const isContributor = hasObjectType(ObjectTypes.Contributor);
|
|
44
|
-
const CREDIT_VOCAB_IDENTIFIER = 'https://dictionary.casrai.org/Contributor_Roles';
|
|
45
|
-
const chooseRoleVocabAttributes = (role) => {
|
|
46
|
-
if (role.uri && role.uri.startsWith(CREDIT_VOCAB_IDENTIFIER)) {
|
|
47
|
-
return {
|
|
48
|
-
vocab: 'credit',
|
|
49
|
-
'vocab-identifier': CREDIT_VOCAB_IDENTIFIER,
|
|
50
|
-
'vocab-term': role.name,
|
|
51
|
-
'vocab-term-identifier': role.uri,
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
return {
|
|
55
|
-
vocab: 'uncontrolled',
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
33
|
const insertAbstractNode = (articleMeta, abstractNode) => {
|
|
59
34
|
const siblings = [
|
|
60
35
|
'kwd-group',
|
|
@@ -91,24 +66,24 @@ const createDefaultIdGenerator = () => {
|
|
|
91
66
|
return `${element.localName}-${value}`;
|
|
92
67
|
};
|
|
93
68
|
};
|
|
94
|
-
const chooseRefType = (
|
|
95
|
-
switch (
|
|
96
|
-
case
|
|
97
|
-
case
|
|
69
|
+
const chooseRefType = (type) => {
|
|
70
|
+
switch (type) {
|
|
71
|
+
case schema.nodes.figure:
|
|
72
|
+
case schema.nodes.figure_element:
|
|
98
73
|
return 'fig';
|
|
99
|
-
case
|
|
74
|
+
case schema.nodes.footnote:
|
|
100
75
|
return 'fn';
|
|
101
|
-
case
|
|
102
|
-
case
|
|
76
|
+
case schema.nodes.table:
|
|
77
|
+
case schema.nodes.table_element:
|
|
103
78
|
return 'table';
|
|
104
|
-
case
|
|
79
|
+
case schema.nodes.section:
|
|
105
80
|
return 'sec';
|
|
106
|
-
case
|
|
107
|
-
case
|
|
81
|
+
case schema.nodes.equation:
|
|
82
|
+
case schema.nodes.equation_element:
|
|
108
83
|
return 'disp-formula';
|
|
109
84
|
}
|
|
110
85
|
};
|
|
111
|
-
const sortContributors = (a, b) => Number(a.priority) - Number(b.priority);
|
|
86
|
+
const sortContributors = (a, b) => Number(a.attrs.priority) - Number(b.attrs.priority);
|
|
112
87
|
export const buildCitations = (citations) => citations.map((citation) => ({
|
|
113
88
|
citationID: citation.attrs.id,
|
|
114
89
|
citationItems: citation.attrs.rids.map((rid) => ({
|
|
@@ -120,39 +95,57 @@ export const buildCitations = (citations) => citations.map((citation) => ({
|
|
|
120
95
|
}));
|
|
121
96
|
export class JATSExporter {
|
|
122
97
|
constructor() {
|
|
123
|
-
this.
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
98
|
+
this.getLibraryItem = (manuscriptID) => {
|
|
99
|
+
return (id) => {
|
|
100
|
+
var _a;
|
|
101
|
+
const node = (_a = findChildrenByAttr(this.manuscriptNode, (attrs) => attrs.id === id)[0]) === null || _a === void 0 ? void 0 : _a.node;
|
|
102
|
+
if (!node) {
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
105
|
+
return {
|
|
106
|
+
_id: node.attrs.id,
|
|
107
|
+
issued: node.attrs.issued,
|
|
108
|
+
DOI: node.attrs.doi,
|
|
109
|
+
manuscriptID,
|
|
110
|
+
objectType: ObjectTypes.BibliographyItem,
|
|
111
|
+
author: node.attrs.author,
|
|
112
|
+
'container-title': node.attrs.containerTitle,
|
|
113
|
+
volume: node.attrs.volume,
|
|
114
|
+
issue: node.attrs.issue,
|
|
115
|
+
supplement: node.attrs.supplement,
|
|
116
|
+
page: node.attrs.page,
|
|
117
|
+
title: node.attrs.title,
|
|
118
|
+
literal: node.attrs.literal,
|
|
119
|
+
type: node.attrs.type,
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
this.serializeToJATS = async (manuscriptNode, options) => {
|
|
124
|
+
var _a;
|
|
125
|
+
this.manuscriptNode = manuscriptNode;
|
|
126
|
+
this.generateCitationTexts(options.csl, manuscriptNode.attrs.id);
|
|
128
127
|
this.createSerializer();
|
|
129
|
-
const versionIds = selectVersionIds(version);
|
|
128
|
+
const versionIds = selectVersionIds((_a = options.version) !== null && _a !== void 0 ? _a : "1.2");
|
|
130
129
|
this.document = document.implementation.createDocument(null, 'article', document.implementation.createDocumentType('article', versionIds.publicId, versionIds.systemId));
|
|
131
130
|
const article = this.document.documentElement;
|
|
132
131
|
article.setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:xlink', XLINK_NAMESPACE);
|
|
133
|
-
const front = this.buildFront(
|
|
132
|
+
const front = this.buildFront(options.journal);
|
|
134
133
|
article.appendChild(front);
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
this.fillEmptyFootnotes(article);
|
|
151
|
-
}
|
|
152
|
-
await this.rewriteIDs(idGenerator);
|
|
153
|
-
if (mediaPathGenerator) {
|
|
154
|
-
await this.rewriteMediaPaths(mediaPathGenerator);
|
|
155
|
-
}
|
|
134
|
+
article.setAttribute('article-type', manuscriptNode.attrs.articleType || 'other');
|
|
135
|
+
this.labelTargets = buildTargets(manuscriptNode);
|
|
136
|
+
const body = this.buildBody();
|
|
137
|
+
article.appendChild(body);
|
|
138
|
+
const back = this.buildBack(body);
|
|
139
|
+
this.moveCoiStatementToAuthorNotes(back, front);
|
|
140
|
+
article.appendChild(back);
|
|
141
|
+
this.unwrapBody(body);
|
|
142
|
+
this.moveAbstracts(front, body);
|
|
143
|
+
this.moveFloatsGroup(body, article);
|
|
144
|
+
this.removeBackContainer(body);
|
|
145
|
+
this.updateFootnoteTypes(front, back);
|
|
146
|
+
this.fillEmptyTableFooters(article);
|
|
147
|
+
this.fillEmptyFootnotes(article);
|
|
148
|
+
await this.rewriteIDs();
|
|
156
149
|
return serializeToXML(this.document);
|
|
157
150
|
};
|
|
158
151
|
this.nodeFromJATS = (JATSFragment) => {
|
|
@@ -219,16 +212,14 @@ export class JATSExporter {
|
|
|
219
212
|
}
|
|
220
213
|
}
|
|
221
214
|
};
|
|
222
|
-
this.buildFront = (
|
|
223
|
-
var _a
|
|
224
|
-
const
|
|
225
|
-
const titles = findTitles(this.modelMap);
|
|
215
|
+
this.buildFront = (journal) => {
|
|
216
|
+
var _a;
|
|
217
|
+
const titleNode = (_a = findChildrenByType(this.manuscriptNode, schema.nodes.title)[0]) === null || _a === void 0 ? void 0 : _a.node;
|
|
226
218
|
const front = this.document.createElement('front');
|
|
227
219
|
const journalMeta = this.document.createElement('journal-meta');
|
|
228
220
|
front.appendChild(journalMeta);
|
|
229
221
|
const articleMeta = this.document.createElement('article-meta');
|
|
230
222
|
front.appendChild(articleMeta);
|
|
231
|
-
const journal = [...this.modelMap.values()].find((model) => model.objectType === ObjectTypes.Journal);
|
|
232
223
|
if (journal) {
|
|
233
224
|
if (journal.journalIdentifiers) {
|
|
234
225
|
for (const item of journal.journalIdentifiers) {
|
|
@@ -277,109 +268,47 @@ export class JATSExporter {
|
|
|
277
268
|
journalMeta.appendChild(publisher);
|
|
278
269
|
}
|
|
279
270
|
}
|
|
280
|
-
if (
|
|
281
|
-
const articleID = this.document.createElement('article-id');
|
|
282
|
-
articleID.setAttribute('pub-id-type', 'publisher-id');
|
|
283
|
-
articleID.textContent = id;
|
|
284
|
-
articleMeta.appendChild(articleID);
|
|
285
|
-
}
|
|
286
|
-
if (doi || manuscript.DOI) {
|
|
271
|
+
if (this.manuscriptNode.attrs.doi) {
|
|
287
272
|
const articleID = this.document.createElement('article-id');
|
|
288
273
|
articleID.setAttribute('pub-id-type', 'doi');
|
|
289
|
-
articleID.textContent =
|
|
274
|
+
articleID.textContent = manuscript.DOI;
|
|
290
275
|
articleMeta.appendChild(articleID);
|
|
291
276
|
}
|
|
292
277
|
const titleGroup = this.document.createElement('title-group');
|
|
293
278
|
articleMeta.appendChild(titleGroup);
|
|
294
279
|
this.buildContributors(articleMeta);
|
|
295
|
-
if (
|
|
296
|
-
for (const [key, value] of Object.entries(links.self)) {
|
|
297
|
-
const link = this.document.createElement('self-uri');
|
|
298
|
-
link.setAttribute('content-type', key);
|
|
299
|
-
link.setAttributeNS(XLINK_NAMESPACE, 'href', value);
|
|
300
|
-
articleMeta.appendChild(link);
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
if (titles.title) {
|
|
280
|
+
if (titleNode) {
|
|
304
281
|
const element = this.document.createElement('article-title');
|
|
305
|
-
this.setTitleContent(element,
|
|
282
|
+
this.setTitleContent(element, titleNode.textContent);
|
|
306
283
|
titleGroup.appendChild(element);
|
|
307
284
|
}
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
this.
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
supplementaryMaterial.setAttribute('id', normalizeID(supplement._id));
|
|
324
|
-
supplementaryMaterial.setAttributeNS(XLINK_NAMESPACE, 'href', (_b = supplement.href) !== null && _b !== void 0 ? _b : '');
|
|
325
|
-
const mimeType = (_c = supplement.MIME) === null || _c === void 0 ? void 0 : _c.split('/')[0];
|
|
326
|
-
const mimeSubType = (_d = supplement.MIME) === null || _d === void 0 ? void 0 : _d.split('/')[1];
|
|
327
|
-
supplementaryMaterial.setAttribute('mimetype', mimeType !== null && mimeType !== void 0 ? mimeType : '');
|
|
328
|
-
supplementaryMaterial.setAttribute('mime-subtype', mimeSubType !== null && mimeSubType !== void 0 ? mimeSubType : '');
|
|
329
|
-
const caption = this.document.createElement('caption');
|
|
330
|
-
const title = this.document.createElement('title');
|
|
331
|
-
title.textContent = (_e = supplement.title) !== null && _e !== void 0 ? _e : '';
|
|
332
|
-
caption.append(title);
|
|
333
|
-
supplementaryMaterial.append(caption);
|
|
334
|
-
articleMeta.append(supplementaryMaterial);
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
const history = articleMeta.querySelector('history') ||
|
|
338
|
-
this.document.createElement('history');
|
|
339
|
-
if (manuscript.acceptanceDate) {
|
|
340
|
-
const date = this.buildDateElement(manuscript.acceptanceDate, 'accepted');
|
|
341
|
-
history.appendChild(date);
|
|
342
|
-
}
|
|
343
|
-
if (manuscript.correctionDate) {
|
|
344
|
-
const date = this.buildDateElement(manuscript.correctionDate, 'corrected');
|
|
345
|
-
history.appendChild(date);
|
|
346
|
-
}
|
|
347
|
-
if (manuscript.retractionDate) {
|
|
348
|
-
const date = this.buildDateElement(manuscript.retractionDate, 'retracted');
|
|
349
|
-
history.appendChild(date);
|
|
350
|
-
}
|
|
351
|
-
if (manuscript.receiveDate) {
|
|
352
|
-
const date = this.buildDateElement(manuscript.receiveDate, 'received');
|
|
353
|
-
history.appendChild(date);
|
|
354
|
-
}
|
|
355
|
-
if (manuscript.revisionReceiveDate) {
|
|
356
|
-
const date = this.buildDateElement(manuscript.revisionReceiveDate, 'rev-recd');
|
|
357
|
-
history.appendChild(date);
|
|
358
|
-
}
|
|
359
|
-
if (manuscript.revisionRequestDate) {
|
|
360
|
-
const date = this.buildDateElement(manuscript.revisionRequestDate, 'rev-request');
|
|
361
|
-
history.appendChild(date);
|
|
362
|
-
}
|
|
363
|
-
if (history.childElementCount) {
|
|
364
|
-
articleMeta.appendChild(history);
|
|
365
|
-
}
|
|
285
|
+
const supplementsNodes = findChildrenByType(this.manuscriptNode, schema.nodes.supplement);
|
|
286
|
+
supplementsNodes.forEach(({ node }) => {
|
|
287
|
+
var _a, _b, _c, _d;
|
|
288
|
+
const supplementaryMaterial = this.document.createElement('supplementary-material');
|
|
289
|
+
supplementaryMaterial.setAttribute('id', normalizeID(node.attrs.id));
|
|
290
|
+
supplementaryMaterial.setAttributeNS(XLINK_NAMESPACE, 'href', (_a = node.attrs.href) !== null && _a !== void 0 ? _a : '');
|
|
291
|
+
supplementaryMaterial.setAttribute('mimetype', (_b = node.attrs.mimeType) !== null && _b !== void 0 ? _b : '');
|
|
292
|
+
supplementaryMaterial.setAttribute('mime-subtype', (_c = node.attrs.mimeSubType) !== null && _c !== void 0 ? _c : '');
|
|
293
|
+
const caption = this.document.createElement('caption');
|
|
294
|
+
const title = this.document.createElement('title');
|
|
295
|
+
title.textContent = (_d = node.attrs.title) !== null && _d !== void 0 ? _d : '';
|
|
296
|
+
caption.append(title);
|
|
297
|
+
supplementaryMaterial.append(caption);
|
|
298
|
+
articleMeta.append(supplementaryMaterial);
|
|
299
|
+
});
|
|
366
300
|
this.buildKeywords(articleMeta);
|
|
367
301
|
let countingElements = [];
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
countingElements.push(this.buildCountingElement('fig-count', manuscript.figureCount));
|
|
379
|
-
countingElements.push(this.buildCountingElement('table-count', manuscript.tableCount));
|
|
380
|
-
countingElements.push(this.buildCountingElement('equation-count', manuscript.equationCount));
|
|
381
|
-
countingElements.push(this.buildCountingElement('ref-count', manuscript.referencesCount));
|
|
382
|
-
countingElements.push(this.buildCountingElement('word-count', manuscript.wordCount));
|
|
302
|
+
const figureCount = findChildrenByType(this.manuscriptNode, schema.nodes.figure).length;
|
|
303
|
+
countingElements.push(this.buildCountingElement('fig-count', figureCount));
|
|
304
|
+
const equationCount = findChildrenByType(this.manuscriptNode, schema.nodes.equation_element).length;
|
|
305
|
+
const tableCount = findChildrenByType(this.manuscriptNode, schema.nodes.table).length;
|
|
306
|
+
const referencesCount = findChildrenByType(this.manuscriptNode, schema.nodes.bibliography_item).length;
|
|
307
|
+
countingElements.push(this.buildCountingElement('table-count', tableCount));
|
|
308
|
+
countingElements.push(this.buildCountingElement('equation-count', equationCount));
|
|
309
|
+
countingElements.push(this.buildCountingElement('ref-count', referencesCount));
|
|
310
|
+
const wordCount = this.manuscriptNode.textContent.split(/\s+/).length;
|
|
311
|
+
countingElements.push(this.buildCountingElement('word-count', wordCount));
|
|
383
312
|
countingElements = countingElements.filter((el) => el);
|
|
384
313
|
if (countingElements.length > 0) {
|
|
385
314
|
const counts = this.document.createElement('counts');
|
|
@@ -414,16 +343,17 @@ export class JATSExporter {
|
|
|
414
343
|
return wordCount;
|
|
415
344
|
}
|
|
416
345
|
};
|
|
417
|
-
this.buildBody = (
|
|
346
|
+
this.buildBody = () => {
|
|
418
347
|
const body = this.document.createElement('body');
|
|
419
|
-
|
|
348
|
+
this.manuscriptNode.forEach((cFragment) => {
|
|
420
349
|
const serializedNode = this.serializeNode(cFragment);
|
|
421
350
|
body.append(...serializedNode.childNodes);
|
|
422
351
|
});
|
|
423
|
-
this.fixBody(body
|
|
352
|
+
this.fixBody(body);
|
|
424
353
|
return body;
|
|
425
354
|
};
|
|
426
355
|
this.buildBack = (body) => {
|
|
356
|
+
var _a;
|
|
427
357
|
const back = this.document.createElement('back');
|
|
428
358
|
this.moveSectionsToBack(back, body);
|
|
429
359
|
const footnotesElements = this.document.querySelectorAll('sec > fn-group');
|
|
@@ -448,7 +378,7 @@ export class JATSExporter {
|
|
|
448
378
|
back.appendChild(refList);
|
|
449
379
|
const [meta] = this.citationProvider.makeBibliography();
|
|
450
380
|
for (const id of meta.entry_ids) {
|
|
451
|
-
const
|
|
381
|
+
const bibliographyNode = (_a = findChildrenByType(this.manuscriptNode, schema.nodes.bibliography_item).find(({ node }) => node.attrs.id === id[0])) === null || _a === void 0 ? void 0 : _a.node;
|
|
452
382
|
const ref = this.document.createElement('ref');
|
|
453
383
|
ref.setAttribute('id', normalizeID(id[0]));
|
|
454
384
|
const updateCitationPubType = (citationEl, pubType) => {
|
|
@@ -467,21 +397,21 @@ export class JATSExporter {
|
|
|
467
397
|
citationEl.setAttribute('publication-type', 'journal');
|
|
468
398
|
}
|
|
469
399
|
};
|
|
470
|
-
if (
|
|
400
|
+
if (bibliographyNode === null || bibliographyNode === void 0 ? void 0 : bibliographyNode.attrs.literal) {
|
|
471
401
|
const mixedCitation = this.document.createElement('mixed-citation');
|
|
472
|
-
updateCitationPubType(mixedCitation,
|
|
473
|
-
mixedCitation.textContent =
|
|
402
|
+
updateCitationPubType(mixedCitation, bibliographyNode.attrs.type);
|
|
403
|
+
mixedCitation.textContent = bibliographyNode.attrs.literal;
|
|
474
404
|
ref.appendChild(mixedCitation);
|
|
475
405
|
refList.appendChild(ref);
|
|
476
406
|
}
|
|
477
407
|
else {
|
|
478
408
|
const citation = this.document.createElement('element-citation');
|
|
479
|
-
updateCitationPubType(citation,
|
|
480
|
-
if (
|
|
409
|
+
updateCitationPubType(citation, bibliographyNode === null || bibliographyNode === void 0 ? void 0 : bibliographyNode.attrs.type);
|
|
410
|
+
if (bibliographyNode === null || bibliographyNode === void 0 ? void 0 : bibliographyNode.attrs.author) {
|
|
481
411
|
const personGroupNode = this.document.createElement('person-group');
|
|
482
412
|
personGroupNode.setAttribute('person-group-type', 'author');
|
|
483
413
|
citation.appendChild(personGroupNode);
|
|
484
|
-
|
|
414
|
+
bibliographyNode.attrs.author.forEach((author) => {
|
|
485
415
|
const name = this.document.createElement('string-name');
|
|
486
416
|
if (author.family) {
|
|
487
417
|
const node = this.document.createElement('surname');
|
|
@@ -503,8 +433,8 @@ export class JATSExporter {
|
|
|
503
433
|
}
|
|
504
434
|
});
|
|
505
435
|
}
|
|
506
|
-
if (
|
|
507
|
-
const dateParts =
|
|
436
|
+
if (bibliographyNode === null || bibliographyNode === void 0 ? void 0 : bibliographyNode.attrs.issued) {
|
|
437
|
+
const dateParts = bibliographyNode === null || bibliographyNode === void 0 ? void 0 : bibliographyNode.attrs.issued['date-parts'];
|
|
508
438
|
if (dateParts && dateParts.length) {
|
|
509
439
|
const [[year, month, day]] = dateParts;
|
|
510
440
|
if (year) {
|
|
@@ -524,33 +454,33 @@ export class JATSExporter {
|
|
|
524
454
|
}
|
|
525
455
|
}
|
|
526
456
|
}
|
|
527
|
-
if (
|
|
457
|
+
if (bibliographyNode === null || bibliographyNode === void 0 ? void 0 : bibliographyNode.attrs.title) {
|
|
528
458
|
const node = this.document.createElement('article-title');
|
|
529
|
-
this.setTitleContent(node,
|
|
459
|
+
this.setTitleContent(node, bibliographyNode === null || bibliographyNode === void 0 ? void 0 : bibliographyNode.attrs.title);
|
|
530
460
|
citation.appendChild(node);
|
|
531
461
|
}
|
|
532
|
-
if (
|
|
462
|
+
if (bibliographyNode === null || bibliographyNode === void 0 ? void 0 : bibliographyNode.attrs.containerTitle) {
|
|
533
463
|
const node = this.document.createElement('source');
|
|
534
|
-
node.textContent =
|
|
464
|
+
node.textContent = bibliographyNode === null || bibliographyNode === void 0 ? void 0 : bibliographyNode.attrs.containerTitle;
|
|
535
465
|
citation.appendChild(node);
|
|
536
466
|
}
|
|
537
|
-
if (
|
|
467
|
+
if (bibliographyNode === null || bibliographyNode === void 0 ? void 0 : bibliographyNode.attrs.volume) {
|
|
538
468
|
const node = this.document.createElement('volume');
|
|
539
|
-
node.textContent = String(
|
|
469
|
+
node.textContent = String(bibliographyNode === null || bibliographyNode === void 0 ? void 0 : bibliographyNode.attrs.volume);
|
|
540
470
|
citation.appendChild(node);
|
|
541
471
|
}
|
|
542
|
-
if (
|
|
472
|
+
if (bibliographyNode === null || bibliographyNode === void 0 ? void 0 : bibliographyNode.attrs.issue) {
|
|
543
473
|
const node = this.document.createElement('issue');
|
|
544
|
-
node.textContent = String(
|
|
474
|
+
node.textContent = String(bibliographyNode === null || bibliographyNode === void 0 ? void 0 : bibliographyNode.attrs.issue);
|
|
545
475
|
citation.appendChild(node);
|
|
546
476
|
}
|
|
547
|
-
if (
|
|
477
|
+
if (bibliographyNode === null || bibliographyNode === void 0 ? void 0 : bibliographyNode.attrs.supplement) {
|
|
548
478
|
const node = this.document.createElement('supplement');
|
|
549
|
-
node.textContent =
|
|
479
|
+
node.textContent = bibliographyNode === null || bibliographyNode === void 0 ? void 0 : bibliographyNode.attrs.supplement;
|
|
550
480
|
citation.appendChild(node);
|
|
551
481
|
}
|
|
552
|
-
if (
|
|
553
|
-
const pageString = String(
|
|
482
|
+
if (bibliographyNode === null || bibliographyNode === void 0 ? void 0 : bibliographyNode.attrs.page) {
|
|
483
|
+
const pageString = String(bibliographyNode === null || bibliographyNode === void 0 ? void 0 : bibliographyNode.attrs.page);
|
|
554
484
|
if (/^\d+$/.test(pageString)) {
|
|
555
485
|
const node = this.document.createElement('fpage');
|
|
556
486
|
node.textContent = pageString;
|
|
@@ -571,10 +501,10 @@ export class JATSExporter {
|
|
|
571
501
|
citation.appendChild(node);
|
|
572
502
|
}
|
|
573
503
|
}
|
|
574
|
-
if (
|
|
504
|
+
if (bibliographyNode === null || bibliographyNode === void 0 ? void 0 : bibliographyNode.attrs.doi) {
|
|
575
505
|
const node = this.document.createElement('pub-id');
|
|
576
506
|
node.setAttribute('pub-id-type', 'doi');
|
|
577
|
-
node.textContent = String(
|
|
507
|
+
node.textContent = String(bibliographyNode === null || bibliographyNode === void 0 ? void 0 : bibliographyNode.attrs.doi);
|
|
578
508
|
citation.appendChild(node);
|
|
579
509
|
}
|
|
580
510
|
ref.appendChild(citation);
|
|
@@ -584,7 +514,6 @@ export class JATSExporter {
|
|
|
584
514
|
return back;
|
|
585
515
|
};
|
|
586
516
|
this.createSerializer = () => {
|
|
587
|
-
const getModel = (id) => id ? this.modelMap.get(id) : undefined;
|
|
588
517
|
const nodes = {
|
|
589
518
|
box_element: () => ['boxed-text', 0],
|
|
590
519
|
author_notes: () => '',
|
|
@@ -647,24 +576,25 @@ export class JATSExporter {
|
|
|
647
576
|
return xref;
|
|
648
577
|
},
|
|
649
578
|
cross_reference: (node) => {
|
|
579
|
+
var _a;
|
|
650
580
|
const cross = node;
|
|
651
581
|
const rids = cross.attrs.rids;
|
|
652
582
|
if (!rids.length) {
|
|
653
583
|
return cross.attrs.label;
|
|
654
584
|
}
|
|
655
585
|
const text = cross.attrs.customLabel || cross.attrs.label;
|
|
656
|
-
const
|
|
657
|
-
if (!
|
|
586
|
+
const target = (_a = findChildrenByAttr(this.manuscriptNode, (attrs) => attrs.id === rids[0])[0]) === null || _a === void 0 ? void 0 : _a.node;
|
|
587
|
+
if (!target) {
|
|
658
588
|
warn('');
|
|
659
589
|
return text;
|
|
660
590
|
}
|
|
661
591
|
const xref = this.document.createElement('xref');
|
|
662
|
-
const type = chooseRefType(
|
|
592
|
+
const type = chooseRefType(target.type);
|
|
663
593
|
if (type) {
|
|
664
594
|
xref.setAttribute('ref-type', type);
|
|
665
595
|
}
|
|
666
596
|
else {
|
|
667
|
-
warn(`Unset ref-type for
|
|
597
|
+
warn(`Unset ref-type for schema type ${target.type.name}`);
|
|
668
598
|
}
|
|
669
599
|
xref.setAttribute('rid', normalizeID(rids.join(' ')));
|
|
670
600
|
xref.textContent = text;
|
|
@@ -736,7 +666,10 @@ export class JATSExporter {
|
|
|
736
666
|
hard_break: () => '',
|
|
737
667
|
highlight_marker: () => '',
|
|
738
668
|
inline_footnote: (node) => {
|
|
739
|
-
const rids = node.attrs.rids.filter(
|
|
669
|
+
const rids = node.attrs.rids.filter((rid) => {
|
|
670
|
+
var _a;
|
|
671
|
+
return (_a = findChildrenByAttr(this.manuscriptNode, (attrs) => attrs.id === rid)[0]) === null || _a === void 0 ? void 0 : _a.node;
|
|
672
|
+
});
|
|
740
673
|
if (rids.length == 0) {
|
|
741
674
|
return '';
|
|
742
675
|
}
|
|
@@ -855,14 +788,7 @@ export class JATSExporter {
|
|
|
855
788
|
italic: () => ['italic'],
|
|
856
789
|
smallcaps: () => ['sc'],
|
|
857
790
|
strikethrough: () => ['strike'],
|
|
858
|
-
styled: (
|
|
859
|
-
const inlineStyle = getModel(mark.attrs.rid);
|
|
860
|
-
const attrs = {};
|
|
861
|
-
if (inlineStyle && inlineStyle.title) {
|
|
862
|
-
attrs.style = normalizeStyleName(inlineStyle.title);
|
|
863
|
-
}
|
|
864
|
-
return ['styled-content', attrs];
|
|
865
|
-
},
|
|
791
|
+
styled: () => ['styled-content'],
|
|
866
792
|
superscript: () => ['sup'],
|
|
867
793
|
subscript: () => ['sub'],
|
|
868
794
|
underline: () => ['underline'],
|
|
@@ -913,14 +839,16 @@ export class JATSExporter {
|
|
|
913
839
|
}
|
|
914
840
|
};
|
|
915
841
|
const appendChildNodeOfType = (element, node, type) => {
|
|
916
|
-
|
|
842
|
+
var _a;
|
|
843
|
+
const childNode = (_a = findChildrenByType(node, type)[0]) === null || _a === void 0 ? void 0 : _a.node;
|
|
917
844
|
if (childNode) {
|
|
918
845
|
element.appendChild(this.serializeNode(childNode));
|
|
919
846
|
}
|
|
920
847
|
};
|
|
921
848
|
const appendTable = (element, node) => {
|
|
922
|
-
|
|
923
|
-
const
|
|
849
|
+
var _a, _b;
|
|
850
|
+
const tableNode = (_a = findChildrenByType(node, node.type.schema.nodes.table)[0]) === null || _a === void 0 ? void 0 : _a.node;
|
|
851
|
+
const colGroupNode = (_b = findChildrenByType(node, node.type.schema.nodes.table_colgroup)[0]) === null || _b === void 0 ? void 0 : _b.node;
|
|
924
852
|
if (!tableNode) {
|
|
925
853
|
return;
|
|
926
854
|
}
|
|
@@ -966,7 +894,8 @@ export class JATSExporter {
|
|
|
966
894
|
return element;
|
|
967
895
|
};
|
|
968
896
|
const processExecutableNode = (node, element) => {
|
|
969
|
-
|
|
897
|
+
var _a;
|
|
898
|
+
const listingNode = (_a = findChildrenByType(node, node.type.schema.nodes.listing)[0]) === null || _a === void 0 ? void 0 : _a.node;
|
|
970
899
|
if (listingNode) {
|
|
971
900
|
const { contents, languageKey } = listingNode.attrs;
|
|
972
901
|
if (contents && languageKey) {
|
|
@@ -1000,25 +929,25 @@ export class JATSExporter {
|
|
|
1000
929
|
}
|
|
1001
930
|
};
|
|
1002
931
|
};
|
|
1003
|
-
this.serializeFragment = (fragment) => this.serializer.serializeFragment(fragment, {
|
|
1004
|
-
document: this.document,
|
|
1005
|
-
});
|
|
1006
932
|
this.serializeNode = (node) => this.serializer.serializeNode(node, {
|
|
1007
933
|
document: this.document,
|
|
1008
934
|
});
|
|
1009
935
|
this.validateContributor = (contributor) => {
|
|
1010
|
-
if (!contributor.bibliographicName) {
|
|
1011
|
-
throw new Error(`${contributor.
|
|
936
|
+
if (!contributor.attrs.bibliographicName) {
|
|
937
|
+
throw new Error(`${contributor.attrs.id} has no bibliographicName`);
|
|
1012
938
|
}
|
|
1013
|
-
const { family, given } = contributor.bibliographicName;
|
|
939
|
+
const { family, given } = contributor.attrs.bibliographicName;
|
|
1014
940
|
if (!family && !given) {
|
|
1015
|
-
throw new Error(`${contributor.
|
|
941
|
+
throw new Error(`${contributor.attrs.id} has neither family nor given name`);
|
|
1016
942
|
}
|
|
1017
943
|
};
|
|
1018
944
|
this.buildContributors = (articleMeta) => {
|
|
1019
|
-
const
|
|
1020
|
-
const
|
|
1021
|
-
.filter((
|
|
945
|
+
const contributorNodes = findChildrenByType(this.manuscriptNode, schema.nodes.contributor).map((result) => result.node);
|
|
946
|
+
const authorContributorNodes = contributorNodes
|
|
947
|
+
.filter((n) => n.attrs.role === 'author')
|
|
948
|
+
.sort(sortContributors);
|
|
949
|
+
const otherContributorsNodes = contributorNodes
|
|
950
|
+
.filter((n) => n.attrs.role !== 'author')
|
|
1022
951
|
.sort(sortContributors);
|
|
1023
952
|
const affiliationLabels = new Map();
|
|
1024
953
|
const creatAffiliationLabel = (rid) => {
|
|
@@ -1036,11 +965,11 @@ export class JATSExporter {
|
|
|
1036
965
|
sup.textContent = String(content);
|
|
1037
966
|
return sup;
|
|
1038
967
|
};
|
|
1039
|
-
if (
|
|
968
|
+
if (authorContributorNodes.length) {
|
|
1040
969
|
const contribGroup = this.document.createElement('contrib-group');
|
|
1041
970
|
contribGroup.setAttribute('content-type', 'authors');
|
|
1042
971
|
articleMeta.appendChild(contribGroup);
|
|
1043
|
-
|
|
972
|
+
authorContributorNodes.forEach((contributor) => {
|
|
1044
973
|
try {
|
|
1045
974
|
this.validateContributor(contributor);
|
|
1046
975
|
}
|
|
@@ -1050,39 +979,25 @@ export class JATSExporter {
|
|
|
1050
979
|
}
|
|
1051
980
|
const contrib = this.document.createElement('contrib');
|
|
1052
981
|
contrib.setAttribute('contrib-type', 'author');
|
|
1053
|
-
contrib.setAttribute('id', normalizeID(contributor.
|
|
1054
|
-
if (contributor.isCorresponding) {
|
|
982
|
+
contrib.setAttribute('id', normalizeID(contributor.attrs.id));
|
|
983
|
+
if (contributor.attrs.isCorresponding) {
|
|
1055
984
|
contrib.setAttribute('corresp', 'yes');
|
|
1056
985
|
}
|
|
1057
|
-
if (contributor.ORCIDIdentifier) {
|
|
986
|
+
if (contributor.attrs.ORCIDIdentifier) {
|
|
1058
987
|
const identifier = this.document.createElement('contrib-id');
|
|
1059
988
|
identifier.setAttribute('contrib-id-type', 'orcid');
|
|
1060
|
-
identifier.textContent = contributor.ORCIDIdentifier;
|
|
989
|
+
identifier.textContent = contributor.attrs.ORCIDIdentifier;
|
|
1061
990
|
contrib.appendChild(identifier);
|
|
1062
991
|
}
|
|
1063
992
|
const name = this.buildContributorName(contributor);
|
|
1064
993
|
contrib.appendChild(name);
|
|
1065
|
-
if (contributor.email) {
|
|
994
|
+
if (contributor.attrs.email) {
|
|
1066
995
|
const email = this.document.createElement('email');
|
|
1067
|
-
email.textContent = contributor.email;
|
|
996
|
+
email.textContent = contributor.attrs.email;
|
|
1068
997
|
contrib.appendChild(email);
|
|
1069
998
|
}
|
|
1070
|
-
if (contributor.
|
|
1071
|
-
contributor.
|
|
1072
|
-
const contributorRole = this.modelMap.get(rid);
|
|
1073
|
-
if (contributorRole) {
|
|
1074
|
-
const role = this.document.createElement('role');
|
|
1075
|
-
const attributes = chooseRoleVocabAttributes(contributorRole);
|
|
1076
|
-
for (const [key, value] of Object.entries(attributes)) {
|
|
1077
|
-
role.setAttribute(key, value);
|
|
1078
|
-
}
|
|
1079
|
-
role.textContent = contributorRole.name;
|
|
1080
|
-
contrib.appendChild(role);
|
|
1081
|
-
}
|
|
1082
|
-
});
|
|
1083
|
-
}
|
|
1084
|
-
if (contributor.affiliations) {
|
|
1085
|
-
contributor.affiliations.forEach((rid) => {
|
|
999
|
+
if (contributor.attrs.affiliations) {
|
|
1000
|
+
contributor.attrs.affiliations.forEach((rid) => {
|
|
1086
1001
|
const xref = this.document.createElement('xref');
|
|
1087
1002
|
xref.setAttribute('ref-type', 'aff');
|
|
1088
1003
|
xref.setAttribute('rid', normalizeID(rid));
|
|
@@ -1090,8 +1005,8 @@ export class JATSExporter {
|
|
|
1090
1005
|
contrib.appendChild(xref);
|
|
1091
1006
|
});
|
|
1092
1007
|
}
|
|
1093
|
-
if (contributor.footnote) {
|
|
1094
|
-
contributor.footnote.map((note) => {
|
|
1008
|
+
if (contributor.attrs.footnote) {
|
|
1009
|
+
contributor.attrs.footnote.map((note) => {
|
|
1095
1010
|
const xref = this.document.createElement('xref');
|
|
1096
1011
|
xref.setAttribute('ref-type', 'fn');
|
|
1097
1012
|
xref.setAttribute('rid', normalizeID(note.noteID));
|
|
@@ -1099,8 +1014,8 @@ export class JATSExporter {
|
|
|
1099
1014
|
contrib.appendChild(xref);
|
|
1100
1015
|
});
|
|
1101
1016
|
}
|
|
1102
|
-
if (contributor.corresp) {
|
|
1103
|
-
contributor.corresp.map((corresp) => {
|
|
1017
|
+
if (contributor.attrs.corresp) {
|
|
1018
|
+
contributor.attrs.corresp.map((corresp) => {
|
|
1104
1019
|
const xref = this.document.createElement('xref');
|
|
1105
1020
|
xref.setAttribute('ref-type', 'corresp');
|
|
1106
1021
|
xref.setAttribute('rid', normalizeID(corresp.correspID));
|
|
@@ -1110,13 +1025,10 @@ export class JATSExporter {
|
|
|
1110
1025
|
}
|
|
1111
1026
|
contribGroup.appendChild(contrib);
|
|
1112
1027
|
});
|
|
1113
|
-
|
|
1114
|
-
.filter((contributor) => contributor.role !== 'author')
|
|
1115
|
-
.sort(sortContributors);
|
|
1116
|
-
if (otherContributors.length) {
|
|
1028
|
+
if (otherContributorsNodes.length) {
|
|
1117
1029
|
const contribGroup = this.document.createElement('contrib-group');
|
|
1118
1030
|
articleMeta.appendChild(contribGroup);
|
|
1119
|
-
|
|
1031
|
+
otherContributorsNodes.forEach((contributor) => {
|
|
1120
1032
|
try {
|
|
1121
1033
|
this.validateContributor(contributor);
|
|
1122
1034
|
}
|
|
@@ -1125,30 +1037,16 @@ export class JATSExporter {
|
|
|
1125
1037
|
return;
|
|
1126
1038
|
}
|
|
1127
1039
|
const contrib = this.document.createElement('contrib');
|
|
1128
|
-
contrib.setAttribute('id', normalizeID(contributor.
|
|
1040
|
+
contrib.setAttribute('id', normalizeID(contributor.attrs.id));
|
|
1129
1041
|
const name = this.buildContributorName(contributor);
|
|
1130
1042
|
contrib.appendChild(name);
|
|
1131
|
-
if (contributor.email) {
|
|
1043
|
+
if (contributor.attrs.email) {
|
|
1132
1044
|
const email = this.document.createElement('email');
|
|
1133
|
-
email.textContent = contributor.email;
|
|
1045
|
+
email.textContent = contributor.attrs.email;
|
|
1134
1046
|
contrib.appendChild(email);
|
|
1135
1047
|
}
|
|
1136
|
-
if (contributor.
|
|
1137
|
-
contributor.
|
|
1138
|
-
const contributorRole = this.modelMap.get(rid);
|
|
1139
|
-
if (contributorRole) {
|
|
1140
|
-
const role = this.document.createElement('role');
|
|
1141
|
-
const attributes = chooseRoleVocabAttributes(contributorRole);
|
|
1142
|
-
for (const [key, value] of Object.entries(attributes)) {
|
|
1143
|
-
role.setAttribute(key, value);
|
|
1144
|
-
}
|
|
1145
|
-
role.textContent = contributorRole.name;
|
|
1146
|
-
contrib.appendChild(role);
|
|
1147
|
-
}
|
|
1148
|
-
});
|
|
1149
|
-
}
|
|
1150
|
-
if (contributor.affiliations) {
|
|
1151
|
-
contributor.affiliations.forEach((rid) => {
|
|
1048
|
+
if (contributor.attrs.affiliations) {
|
|
1049
|
+
contributor.attrs.affiliations.forEach((rid) => {
|
|
1152
1050
|
const xref = this.document.createElement('xref');
|
|
1153
1051
|
xref.setAttribute('ref-type', 'aff');
|
|
1154
1052
|
xref.setAttribute('rid', normalizeID(rid));
|
|
@@ -1156,8 +1054,8 @@ export class JATSExporter {
|
|
|
1156
1054
|
contrib.appendChild(xref);
|
|
1157
1055
|
});
|
|
1158
1056
|
}
|
|
1159
|
-
if (contributor.footnote) {
|
|
1160
|
-
contributor.footnote.map((note) => {
|
|
1057
|
+
if (contributor.attrs.footnote) {
|
|
1058
|
+
contributor.attrs.footnote.map((note) => {
|
|
1161
1059
|
const xref = this.document.createElement('xref');
|
|
1162
1060
|
xref.setAttribute('ref-type', 'fn');
|
|
1163
1061
|
xref.setAttribute('rid', normalizeID(note.noteID));
|
|
@@ -1169,64 +1067,68 @@ export class JATSExporter {
|
|
|
1169
1067
|
});
|
|
1170
1068
|
}
|
|
1171
1069
|
const affiliationRIDs = [];
|
|
1172
|
-
const sortedContributors = [
|
|
1070
|
+
const sortedContributors = [
|
|
1071
|
+
...authorContributorNodes,
|
|
1072
|
+
...otherContributorsNodes,
|
|
1073
|
+
];
|
|
1173
1074
|
for (const contributor of sortedContributors) {
|
|
1174
|
-
if (contributor.affiliations) {
|
|
1175
|
-
affiliationRIDs.push(...contributor.affiliations);
|
|
1075
|
+
if (contributor.attrs.affiliations) {
|
|
1076
|
+
affiliationRIDs.push(...contributor.attrs.affiliations);
|
|
1176
1077
|
}
|
|
1177
1078
|
}
|
|
1178
|
-
const affiliations = this.
|
|
1079
|
+
const affiliations = findChildrenByType(this.manuscriptNode, schema.nodes.affiliation).map((result) => result.node);
|
|
1179
1080
|
if (affiliations) {
|
|
1180
|
-
const usedAffiliations = affiliations.filter((affiliation) => affiliationRIDs.includes(affiliation.
|
|
1181
|
-
usedAffiliations.sort((a, b) => affiliationRIDs.indexOf(a.
|
|
1081
|
+
const usedAffiliations = affiliations.filter((affiliation) => affiliationRIDs.includes(affiliation.attrs.id));
|
|
1082
|
+
usedAffiliations.sort((a, b) => affiliationRIDs.indexOf(a.attrs.id) -
|
|
1083
|
+
affiliationRIDs.indexOf(b.attrs.id));
|
|
1182
1084
|
usedAffiliations.forEach((affiliation) => {
|
|
1183
1085
|
var _a, _b;
|
|
1184
1086
|
const aff = this.document.createElement('aff');
|
|
1185
|
-
aff.setAttribute('id', normalizeID(affiliation.
|
|
1087
|
+
aff.setAttribute('id', normalizeID(affiliation.attrs.id));
|
|
1186
1088
|
contribGroup.appendChild(aff);
|
|
1187
|
-
if (affiliation.department) {
|
|
1089
|
+
if (affiliation.attrs.department) {
|
|
1188
1090
|
const department = this.document.createElement('institution');
|
|
1189
1091
|
department.setAttribute('content-type', 'dept');
|
|
1190
|
-
department.textContent = affiliation.department;
|
|
1092
|
+
department.textContent = affiliation.attrs.department;
|
|
1191
1093
|
aff.appendChild(department);
|
|
1192
1094
|
}
|
|
1193
|
-
if (affiliation.institution) {
|
|
1095
|
+
if (affiliation.attrs.institution) {
|
|
1194
1096
|
const institution = this.document.createElement('institution');
|
|
1195
|
-
institution.textContent = affiliation.institution;
|
|
1097
|
+
institution.textContent = affiliation.attrs.institution;
|
|
1196
1098
|
aff.appendChild(institution);
|
|
1197
1099
|
}
|
|
1198
|
-
if (affiliation.addressLine1) {
|
|
1100
|
+
if (affiliation.attrs.addressLine1) {
|
|
1199
1101
|
const addressLine = this.document.createElement('addr-line');
|
|
1200
|
-
addressLine.textContent = affiliation.addressLine1;
|
|
1102
|
+
addressLine.textContent = affiliation.attrs.addressLine1;
|
|
1201
1103
|
aff.appendChild(addressLine);
|
|
1202
1104
|
}
|
|
1203
|
-
if (affiliation.addressLine2) {
|
|
1105
|
+
if (affiliation.attrs.addressLine2) {
|
|
1204
1106
|
const addressLine = this.document.createElement('addr-line');
|
|
1205
|
-
addressLine.textContent = affiliation.addressLine2;
|
|
1107
|
+
addressLine.textContent = affiliation.attrs.addressLine2;
|
|
1206
1108
|
aff.appendChild(addressLine);
|
|
1207
1109
|
}
|
|
1208
|
-
if (affiliation.addressLine3) {
|
|
1110
|
+
if (affiliation.attrs.addressLine3) {
|
|
1209
1111
|
const addressLine = this.document.createElement('addr-line');
|
|
1210
|
-
addressLine.textContent = affiliation.addressLine3;
|
|
1112
|
+
addressLine.textContent = affiliation.attrs.addressLine3;
|
|
1211
1113
|
aff.appendChild(addressLine);
|
|
1212
1114
|
}
|
|
1213
|
-
if (affiliation.city) {
|
|
1115
|
+
if (affiliation.attrs.city) {
|
|
1214
1116
|
const city = this.document.createElement('city');
|
|
1215
|
-
city.textContent = affiliation.city;
|
|
1117
|
+
city.textContent = affiliation.attrs.city;
|
|
1216
1118
|
aff.appendChild(city);
|
|
1217
1119
|
}
|
|
1218
|
-
if (affiliation.country) {
|
|
1120
|
+
if (affiliation.attrs.country) {
|
|
1219
1121
|
const country = this.document.createElement('country');
|
|
1220
|
-
country.textContent = affiliation.country;
|
|
1122
|
+
country.textContent = affiliation.attrs.country;
|
|
1221
1123
|
aff.appendChild(country);
|
|
1222
1124
|
}
|
|
1223
|
-
if (affiliation.email) {
|
|
1125
|
+
if (affiliation.attrs.email) {
|
|
1224
1126
|
const email = this.document.createElement('email');
|
|
1225
|
-
email.setAttributeNS(XLINK_NAMESPACE, 'href', (_a = affiliation.email.href) !== null && _a !== void 0 ? _a : '');
|
|
1226
|
-
email.textContent = (_b = affiliation.email.text) !== null && _b !== void 0 ? _b : '';
|
|
1127
|
+
email.setAttributeNS(XLINK_NAMESPACE, 'href', (_a = affiliation.attrs.email.href) !== null && _a !== void 0 ? _a : '');
|
|
1128
|
+
email.textContent = (_b = affiliation.attrs.email.text) !== null && _b !== void 0 ? _b : '';
|
|
1227
1129
|
aff.appendChild(email);
|
|
1228
1130
|
}
|
|
1229
|
-
const labelNumber = affiliationLabels.get(affiliation.
|
|
1131
|
+
const labelNumber = affiliationLabels.get(affiliation.attrs.id);
|
|
1230
1132
|
if (labelNumber) {
|
|
1231
1133
|
const label = this.document.createElement('label');
|
|
1232
1134
|
label.textContent = String(labelNumber);
|
|
@@ -1243,41 +1145,48 @@ export class JATSExporter {
|
|
|
1243
1145
|
this.createAuthorNotesElement = () => {
|
|
1244
1146
|
var _a;
|
|
1245
1147
|
const authorNotesEl = this.document.createElement('author-notes');
|
|
1246
|
-
const
|
|
1247
|
-
if (
|
|
1248
|
-
this.appendModelsToAuthorNotes(authorNotesEl,
|
|
1148
|
+
const authorNotesNode = (_a = findChildrenByType(this.manuscriptNode, schema.nodes.author_notes)[0]) === null || _a === void 0 ? void 0 : _a.node;
|
|
1149
|
+
if (authorNotesNode) {
|
|
1150
|
+
this.appendModelsToAuthorNotes(authorNotesEl, authorNotesNode);
|
|
1249
1151
|
}
|
|
1250
1152
|
return authorNotesEl;
|
|
1251
1153
|
};
|
|
1252
1154
|
this.appendCorrespondingToElement = (corresponding, element) => {
|
|
1253
1155
|
const correspondingEl = this.document.createElement('corresp');
|
|
1254
|
-
correspondingEl.setAttribute('id', normalizeID(corresponding.
|
|
1255
|
-
if (corresponding.label) {
|
|
1156
|
+
correspondingEl.setAttribute('id', normalizeID(corresponding.attrs.id));
|
|
1157
|
+
if (corresponding.attrs.label) {
|
|
1256
1158
|
const labelEl = this.document.createElement('label');
|
|
1257
|
-
labelEl.textContent = corresponding.label;
|
|
1159
|
+
labelEl.textContent = corresponding.attrs.label;
|
|
1258
1160
|
correspondingEl.appendChild(labelEl);
|
|
1259
1161
|
}
|
|
1260
|
-
correspondingEl.append(corresponding.
|
|
1162
|
+
correspondingEl.append(corresponding.textContent);
|
|
1261
1163
|
element.appendChild(correspondingEl);
|
|
1262
1164
|
};
|
|
1263
1165
|
this.appendParagraphToElement = (paragraph, element) => {
|
|
1264
|
-
const parsedDoc = new DOMParser().parseFromString(paragraph.
|
|
1166
|
+
const parsedDoc = new DOMParser().parseFromString(paragraph.textContent, 'text/html');
|
|
1265
1167
|
const parsedParagraph = parsedDoc.body.querySelector('p');
|
|
1266
1168
|
if (parsedParagraph) {
|
|
1267
1169
|
const paragraphEl = this.document.createElement('p');
|
|
1268
1170
|
paragraphEl.innerHTML = parsedParagraph.innerHTML;
|
|
1269
|
-
paragraphEl.setAttribute('id', normalizeID(paragraph.
|
|
1171
|
+
paragraphEl.setAttribute('id', normalizeID(paragraph.attrs.id));
|
|
1270
1172
|
element.appendChild(paragraphEl);
|
|
1271
1173
|
}
|
|
1272
1174
|
};
|
|
1273
1175
|
this.appendFootnoteToElement = (footnote, element) => {
|
|
1274
1176
|
const footnoteEl = this.document.createElement('fn');
|
|
1275
|
-
footnoteEl.setAttribute('id', normalizeID(footnote.
|
|
1276
|
-
|
|
1177
|
+
footnoteEl.setAttribute('id', normalizeID(footnote.attrs.id));
|
|
1178
|
+
if (!footnote.textContent.includes('<p>')) {
|
|
1179
|
+
const p = this.document.createElement('p');
|
|
1180
|
+
p.innerHTML = footnote.textContent;
|
|
1181
|
+
footnoteEl.appendChild(p);
|
|
1182
|
+
}
|
|
1183
|
+
else {
|
|
1184
|
+
footnoteEl.innerHTML = footnote.textContent;
|
|
1185
|
+
}
|
|
1277
1186
|
element.appendChild(footnoteEl);
|
|
1278
1187
|
};
|
|
1279
|
-
this.fixBody = (body
|
|
1280
|
-
|
|
1188
|
+
this.fixBody = (body) => {
|
|
1189
|
+
this.manuscriptNode.descendants((node) => {
|
|
1281
1190
|
if (node.attrs.id) {
|
|
1282
1191
|
if (node.attrs.titleSuppressed) {
|
|
1283
1192
|
const title = body.querySelector(`#${normalizeID(node.attrs.id)} > title`);
|
|
@@ -1538,36 +1447,36 @@ export class JATSExporter {
|
|
|
1538
1447
|
};
|
|
1539
1448
|
this.buildContributorName = (contributor) => {
|
|
1540
1449
|
const name = this.document.createElement('name');
|
|
1541
|
-
if (contributor.bibliographicName.family) {
|
|
1450
|
+
if (contributor.attrs.bibliographicName.family) {
|
|
1542
1451
|
const surname = this.document.createElement('surname');
|
|
1543
|
-
surname.textContent = contributor.bibliographicName.family;
|
|
1452
|
+
surname.textContent = contributor.attrs.bibliographicName.family;
|
|
1544
1453
|
name.appendChild(surname);
|
|
1545
1454
|
}
|
|
1546
|
-
if (contributor.bibliographicName.given) {
|
|
1455
|
+
if (contributor.attrs.bibliographicName.given) {
|
|
1547
1456
|
const givenNames = this.document.createElement('given-names');
|
|
1548
|
-
givenNames.textContent = contributor.bibliographicName.given;
|
|
1457
|
+
givenNames.textContent = contributor.attrs.bibliographicName.given;
|
|
1549
1458
|
name.appendChild(givenNames);
|
|
1550
1459
|
}
|
|
1551
1460
|
return name;
|
|
1552
1461
|
};
|
|
1553
1462
|
}
|
|
1554
|
-
generateCitations(
|
|
1463
|
+
generateCitations() {
|
|
1555
1464
|
const nodes = [];
|
|
1556
|
-
|
|
1465
|
+
this.manuscriptNode.descendants((node) => {
|
|
1557
1466
|
if (isCitationNode(node)) {
|
|
1558
1467
|
nodes.push(node);
|
|
1559
1468
|
}
|
|
1560
1469
|
});
|
|
1561
1470
|
return buildCitations(nodes);
|
|
1562
1471
|
}
|
|
1563
|
-
generateCitationTexts(
|
|
1472
|
+
generateCitationTexts(csl, manuscriptID) {
|
|
1564
1473
|
this.citationTexts = new Map();
|
|
1565
1474
|
this.citationProvider = new CitationProvider({
|
|
1566
|
-
getLibraryItem:
|
|
1475
|
+
getLibraryItem: this.getLibraryItem(manuscriptID),
|
|
1567
1476
|
locale: csl.locale,
|
|
1568
1477
|
citationStyle: csl.style,
|
|
1569
1478
|
});
|
|
1570
|
-
const citations = this.generateCitations(
|
|
1479
|
+
const citations = this.generateCitations();
|
|
1571
1480
|
this.citationProvider.rebuildState(citations).forEach(([id, , output]) => {
|
|
1572
1481
|
this.citationTexts.set(id, output);
|
|
1573
1482
|
});
|
|
@@ -1594,72 +1503,50 @@ export class JATSExporter {
|
|
|
1594
1503
|
return mathml;
|
|
1595
1504
|
}
|
|
1596
1505
|
}
|
|
1597
|
-
appendModelsToAuthorNotes(authorNotesEl,
|
|
1598
|
-
const
|
|
1599
|
-
const usedCorrespondings = this.getUsedCorrespondings(
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
}
|
|
1605
|
-
switch (model.objectType) {
|
|
1606
|
-
case ObjectTypes.ParagraphElement:
|
|
1607
|
-
this.appendParagraphToElement(model, authorNotesEl);
|
|
1506
|
+
appendModelsToAuthorNotes(authorNotesEl, authorNotesNode) {
|
|
1507
|
+
const contributorsNodes = findChildrenByType(this.manuscriptNode, schema.nodes.contributor).map((result) => result.node);
|
|
1508
|
+
const usedCorrespondings = this.getUsedCorrespondings(contributorsNodes);
|
|
1509
|
+
authorNotesNode.descendants((node) => {
|
|
1510
|
+
switch (node.type) {
|
|
1511
|
+
case schema.nodes.paragraph:
|
|
1512
|
+
this.appendParagraphToElement(node, authorNotesEl);
|
|
1608
1513
|
break;
|
|
1609
|
-
case
|
|
1610
|
-
this.appendFootnoteToElement(
|
|
1514
|
+
case schema.nodes.footnote:
|
|
1515
|
+
this.appendFootnoteToElement(node, authorNotesEl);
|
|
1611
1516
|
break;
|
|
1612
|
-
case
|
|
1613
|
-
if (usedCorrespondings.includes(
|
|
1614
|
-
this.appendCorrespondingToElement(
|
|
1517
|
+
case schema.nodes.corresp:
|
|
1518
|
+
if (usedCorrespondings.includes(node)) {
|
|
1519
|
+
this.appendCorrespondingToElement(node, authorNotesEl);
|
|
1615
1520
|
}
|
|
1616
1521
|
break;
|
|
1617
1522
|
}
|
|
1523
|
+
return false;
|
|
1618
1524
|
});
|
|
1619
1525
|
}
|
|
1620
1526
|
getUsedCorrespondings(contributors) {
|
|
1621
1527
|
return contributors
|
|
1622
|
-
.flatMap((c) => { var _a; return (_a = c.corresp) !== null && _a !== void 0 ? _a : []; })
|
|
1623
|
-
.map((corresp) =>
|
|
1528
|
+
.flatMap((c) => { var _a; return (_a = c.attrs.corresp) !== null && _a !== void 0 ? _a : []; })
|
|
1529
|
+
.map((corresp) => {
|
|
1530
|
+
var _a;
|
|
1531
|
+
return (_a = findChildrenByAttr(this.manuscriptNode, (attr) => attr.id === corresp.correspID)[0]) === null || _a === void 0 ? void 0 : _a.node;
|
|
1532
|
+
})
|
|
1624
1533
|
.filter((corresp) => !!corresp);
|
|
1625
1534
|
}
|
|
1626
1535
|
buildKeywords(articleMeta) {
|
|
1627
|
-
const
|
|
1628
|
-
|
|
1629
|
-
keywords.forEach((keyword) => {
|
|
1630
|
-
const containedGroup = keyword.containedGroup || '';
|
|
1631
|
-
const group = keywordGroups.get(containedGroup);
|
|
1632
|
-
if (group) {
|
|
1633
|
-
group.push(keyword);
|
|
1634
|
-
}
|
|
1635
|
-
else {
|
|
1636
|
-
keywordGroups.set(containedGroup, [keyword]);
|
|
1637
|
-
}
|
|
1638
|
-
});
|
|
1639
|
-
for (const [groupID, keywords] of keywordGroups) {
|
|
1640
|
-
const keywordGroup = (this.modelMap.get(groupID) || {});
|
|
1536
|
+
const keywordGroups = findChildrenByType(this.manuscriptNode, schema.nodes.keyword_group).map((result) => result.node);
|
|
1537
|
+
keywordGroups.forEach((group) => {
|
|
1641
1538
|
const kwdGroup = this.document.createElement('kwd-group');
|
|
1642
|
-
if (
|
|
1643
|
-
kwdGroup.setAttribute('kwd-group-type',
|
|
1644
|
-
}
|
|
1645
|
-
if (keywordGroup.label) {
|
|
1646
|
-
const label = this.document.createElement('label');
|
|
1647
|
-
label.textContent = keywordGroup.label;
|
|
1648
|
-
kwdGroup.appendChild(label);
|
|
1649
|
-
}
|
|
1650
|
-
if (keywordGroup.title) {
|
|
1651
|
-
const title = this.document.createElement('title');
|
|
1652
|
-
title.textContent = keywordGroup.title;
|
|
1653
|
-
kwdGroup.appendChild(title);
|
|
1539
|
+
if (group.attrs.type) {
|
|
1540
|
+
kwdGroup.setAttribute('kwd-group-type', group.attrs.type);
|
|
1654
1541
|
}
|
|
1655
1542
|
articleMeta.appendChild(kwdGroup);
|
|
1656
|
-
|
|
1543
|
+
group.content.forEach((keyword) => {
|
|
1657
1544
|
const kwd = this.document.createElement('kwd');
|
|
1658
|
-
kwd.textContent = keyword.
|
|
1545
|
+
kwd.textContent = keyword.textContent;
|
|
1659
1546
|
kwdGroup.appendChild(kwd);
|
|
1660
|
-
}
|
|
1547
|
+
});
|
|
1661
1548
|
articleMeta.appendChild(kwdGroup);
|
|
1662
|
-
}
|
|
1549
|
+
});
|
|
1663
1550
|
}
|
|
1664
1551
|
moveCoiStatementToAuthorNotes(back, front) {
|
|
1665
1552
|
const fnGroups = back.querySelectorAll('fn-group');
|