@manuscripts/transform 2.3.35 → 2.3.37-LEAN-3911.0
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 +252 -354
- package/dist/cjs/{transformer → jats}/labels.js +3 -3
- package/dist/cjs/lib/utils.js +9 -1
- package/dist/cjs/schema/index.js +2 -0
- package/dist/cjs/schema/nodes/box_element.js +55 -0
- package/dist/cjs/transformer/id.js +10 -5
- package/dist/cjs/transformer/index.js +0 -18
- package/dist/cjs/transformer/node-types.js +1 -0
- package/dist/cjs/transformer/section-category.js +8 -0
- 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 +254 -356
- package/dist/es/{transformer → jats}/labels.js +3 -3
- package/dist/es/lib/utils.js +7 -0
- package/dist/es/schema/index.js +2 -0
- package/dist/es/schema/nodes/box_element.js +52 -0
- package/dist/es/transformer/id.js +8 -3
- package/dist/es/transformer/index.js +0 -16
- package/dist/es/transformer/node-types.js +1 -0
- package/dist/es/transformer/section-category.js +8 -0
- 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 +10 -29
- 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/{es/transformer/models.js → types/schema/nodes/box_element.d.ts} +10 -0
- package/dist/types/schema/nodes/contributor.d.ts +10 -0
- package/dist/types/schema/nodes/keyword_group.d.ts +1 -0
- package/dist/types/schema/types.d.ts +1 -1
- package/dist/types/transformer/id.d.ts +5 -2
- package/dist/types/transformer/index.d.ts +0 -16
- package/dist/types/transformer/section-category.d.ts +2 -2
- package/dist/types/version.d.ts +1 -1
- package/package.json +2 -1
- 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/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, csl, manuscript, jorunal) => {
|
|
124
|
+
const version = '1.2';
|
|
125
|
+
this.manuscriptNode = manuscriptNode;
|
|
126
|
+
this.generateCitationTexts(csl, manuscriptNode.attrs.id);
|
|
128
127
|
this.createSerializer();
|
|
129
128
|
const versionIds = selectVersionIds(version);
|
|
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(manuscript, jorunal);
|
|
134
133
|
article.appendChild(front);
|
|
135
|
-
const manuscript = findManuscriptById(this.modelMap, manuscriptID);
|
|
136
134
|
article.setAttribute('article-type', manuscript.articleType || 'other');
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
}
|
|
152
|
-
await this.rewriteIDs(idGenerator);
|
|
153
|
-
if (mediaPathGenerator) {
|
|
154
|
-
await this.rewriteMediaPaths(mediaPathGenerator);
|
|
155
|
-
}
|
|
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 = (manuscript, 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,92 +268,35 @@ 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 (manuscript.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
302
|
if (manuscript.genericCounts) {
|
|
@@ -375,11 +309,16 @@ export class JATSExporter {
|
|
|
375
309
|
});
|
|
376
310
|
countingElements.push(...elements);
|
|
377
311
|
}
|
|
378
|
-
|
|
379
|
-
countingElements.push(this.buildCountingElement('
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
312
|
+
const figureCount = findChildrenByType(this.manuscriptNode, schema.nodes.figure).length;
|
|
313
|
+
countingElements.push(this.buildCountingElement('fig-count', figureCount));
|
|
314
|
+
const equationCount = findChildrenByType(this.manuscriptNode, schema.nodes.equation_element).length;
|
|
315
|
+
const tableCount = findChildrenByType(this.manuscriptNode, schema.nodes.table).length;
|
|
316
|
+
const referencesCount = findChildrenByType(this.manuscriptNode, schema.nodes.bibliography_item).length;
|
|
317
|
+
countingElements.push(this.buildCountingElement('table-count', tableCount));
|
|
318
|
+
countingElements.push(this.buildCountingElement('equation-count', equationCount));
|
|
319
|
+
countingElements.push(this.buildCountingElement('ref-count', referencesCount));
|
|
320
|
+
const wordCount = this.manuscriptNode.textContent.split(/\s+/).length;
|
|
321
|
+
countingElements.push(this.buildCountingElement('word-count', wordCount));
|
|
383
322
|
countingElements = countingElements.filter((el) => el);
|
|
384
323
|
if (countingElements.length > 0) {
|
|
385
324
|
const counts = this.document.createElement('counts');
|
|
@@ -414,16 +353,17 @@ export class JATSExporter {
|
|
|
414
353
|
return wordCount;
|
|
415
354
|
}
|
|
416
355
|
};
|
|
417
|
-
this.buildBody = (
|
|
356
|
+
this.buildBody = () => {
|
|
418
357
|
const body = this.document.createElement('body');
|
|
419
|
-
|
|
358
|
+
this.manuscriptNode.forEach((cFragment) => {
|
|
420
359
|
const serializedNode = this.serializeNode(cFragment);
|
|
421
360
|
body.append(...serializedNode.childNodes);
|
|
422
361
|
});
|
|
423
|
-
this.fixBody(body
|
|
362
|
+
this.fixBody(body);
|
|
424
363
|
return body;
|
|
425
364
|
};
|
|
426
365
|
this.buildBack = (body) => {
|
|
366
|
+
var _a;
|
|
427
367
|
const back = this.document.createElement('back');
|
|
428
368
|
this.moveSectionsToBack(back, body);
|
|
429
369
|
const footnotesElements = this.document.querySelectorAll('sec > fn-group');
|
|
@@ -448,7 +388,7 @@ export class JATSExporter {
|
|
|
448
388
|
back.appendChild(refList);
|
|
449
389
|
const [meta] = this.citationProvider.makeBibliography();
|
|
450
390
|
for (const id of meta.entry_ids) {
|
|
451
|
-
const
|
|
391
|
+
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
392
|
const ref = this.document.createElement('ref');
|
|
453
393
|
ref.setAttribute('id', normalizeID(id[0]));
|
|
454
394
|
const updateCitationPubType = (citationEl, pubType) => {
|
|
@@ -467,21 +407,21 @@ export class JATSExporter {
|
|
|
467
407
|
citationEl.setAttribute('publication-type', 'journal');
|
|
468
408
|
}
|
|
469
409
|
};
|
|
470
|
-
if (
|
|
410
|
+
if (bibliographyNode === null || bibliographyNode === void 0 ? void 0 : bibliographyNode.attrs.literal) {
|
|
471
411
|
const mixedCitation = this.document.createElement('mixed-citation');
|
|
472
|
-
updateCitationPubType(mixedCitation,
|
|
473
|
-
mixedCitation.textContent =
|
|
412
|
+
updateCitationPubType(mixedCitation, bibliographyNode.attrs.type);
|
|
413
|
+
mixedCitation.textContent = bibliographyNode.attrs.literal;
|
|
474
414
|
ref.appendChild(mixedCitation);
|
|
475
415
|
refList.appendChild(ref);
|
|
476
416
|
}
|
|
477
417
|
else {
|
|
478
418
|
const citation = this.document.createElement('element-citation');
|
|
479
|
-
updateCitationPubType(citation,
|
|
480
|
-
if (
|
|
419
|
+
updateCitationPubType(citation, bibliographyNode === null || bibliographyNode === void 0 ? void 0 : bibliographyNode.attrs.type);
|
|
420
|
+
if (bibliographyNode === null || bibliographyNode === void 0 ? void 0 : bibliographyNode.attrs.author) {
|
|
481
421
|
const personGroupNode = this.document.createElement('person-group');
|
|
482
422
|
personGroupNode.setAttribute('person-group-type', 'author');
|
|
483
423
|
citation.appendChild(personGroupNode);
|
|
484
|
-
|
|
424
|
+
bibliographyNode.attrs.author.forEach((author) => {
|
|
485
425
|
const name = this.document.createElement('string-name');
|
|
486
426
|
if (author.family) {
|
|
487
427
|
const node = this.document.createElement('surname');
|
|
@@ -503,8 +443,8 @@ export class JATSExporter {
|
|
|
503
443
|
}
|
|
504
444
|
});
|
|
505
445
|
}
|
|
506
|
-
if (
|
|
507
|
-
const dateParts =
|
|
446
|
+
if (bibliographyNode === null || bibliographyNode === void 0 ? void 0 : bibliographyNode.attrs.issued) {
|
|
447
|
+
const dateParts = bibliographyNode === null || bibliographyNode === void 0 ? void 0 : bibliographyNode.attrs.issued['date-parts'];
|
|
508
448
|
if (dateParts && dateParts.length) {
|
|
509
449
|
const [[year, month, day]] = dateParts;
|
|
510
450
|
if (year) {
|
|
@@ -524,33 +464,33 @@ export class JATSExporter {
|
|
|
524
464
|
}
|
|
525
465
|
}
|
|
526
466
|
}
|
|
527
|
-
if (
|
|
467
|
+
if (bibliographyNode === null || bibliographyNode === void 0 ? void 0 : bibliographyNode.attrs.title) {
|
|
528
468
|
const node = this.document.createElement('article-title');
|
|
529
|
-
this.setTitleContent(node,
|
|
469
|
+
this.setTitleContent(node, bibliographyNode === null || bibliographyNode === void 0 ? void 0 : bibliographyNode.attrs.title);
|
|
530
470
|
citation.appendChild(node);
|
|
531
471
|
}
|
|
532
|
-
if (
|
|
472
|
+
if (bibliographyNode === null || bibliographyNode === void 0 ? void 0 : bibliographyNode.attrs.containerTitle) {
|
|
533
473
|
const node = this.document.createElement('source');
|
|
534
|
-
node.textContent =
|
|
474
|
+
node.textContent = bibliographyNode === null || bibliographyNode === void 0 ? void 0 : bibliographyNode.attrs.containerTitle;
|
|
535
475
|
citation.appendChild(node);
|
|
536
476
|
}
|
|
537
|
-
if (
|
|
477
|
+
if (bibliographyNode === null || bibliographyNode === void 0 ? void 0 : bibliographyNode.attrs.volume) {
|
|
538
478
|
const node = this.document.createElement('volume');
|
|
539
|
-
node.textContent = String(
|
|
479
|
+
node.textContent = String(bibliographyNode === null || bibliographyNode === void 0 ? void 0 : bibliographyNode.attrs.volume);
|
|
540
480
|
citation.appendChild(node);
|
|
541
481
|
}
|
|
542
|
-
if (
|
|
482
|
+
if (bibliographyNode === null || bibliographyNode === void 0 ? void 0 : bibliographyNode.attrs.issue) {
|
|
543
483
|
const node = this.document.createElement('issue');
|
|
544
|
-
node.textContent = String(
|
|
484
|
+
node.textContent = String(bibliographyNode === null || bibliographyNode === void 0 ? void 0 : bibliographyNode.attrs.issue);
|
|
545
485
|
citation.appendChild(node);
|
|
546
486
|
}
|
|
547
|
-
if (
|
|
487
|
+
if (bibliographyNode === null || bibliographyNode === void 0 ? void 0 : bibliographyNode.attrs.supplement) {
|
|
548
488
|
const node = this.document.createElement('supplement');
|
|
549
|
-
node.textContent =
|
|
489
|
+
node.textContent = bibliographyNode === null || bibliographyNode === void 0 ? void 0 : bibliographyNode.attrs.supplement;
|
|
550
490
|
citation.appendChild(node);
|
|
551
491
|
}
|
|
552
|
-
if (
|
|
553
|
-
const pageString = String(
|
|
492
|
+
if (bibliographyNode === null || bibliographyNode === void 0 ? void 0 : bibliographyNode.attrs.page) {
|
|
493
|
+
const pageString = String(bibliographyNode === null || bibliographyNode === void 0 ? void 0 : bibliographyNode.attrs.page);
|
|
554
494
|
if (/^\d+$/.test(pageString)) {
|
|
555
495
|
const node = this.document.createElement('fpage');
|
|
556
496
|
node.textContent = pageString;
|
|
@@ -571,10 +511,10 @@ export class JATSExporter {
|
|
|
571
511
|
citation.appendChild(node);
|
|
572
512
|
}
|
|
573
513
|
}
|
|
574
|
-
if (
|
|
514
|
+
if (bibliographyNode === null || bibliographyNode === void 0 ? void 0 : bibliographyNode.attrs.doi) {
|
|
575
515
|
const node = this.document.createElement('pub-id');
|
|
576
516
|
node.setAttribute('pub-id-type', 'doi');
|
|
577
|
-
node.textContent = String(
|
|
517
|
+
node.textContent = String(bibliographyNode === null || bibliographyNode === void 0 ? void 0 : bibliographyNode.attrs.doi);
|
|
578
518
|
citation.appendChild(node);
|
|
579
519
|
}
|
|
580
520
|
ref.appendChild(citation);
|
|
@@ -584,8 +524,8 @@ export class JATSExporter {
|
|
|
584
524
|
return back;
|
|
585
525
|
};
|
|
586
526
|
this.createSerializer = () => {
|
|
587
|
-
const getModel = (id) => id ? this.modelMap.get(id) : undefined;
|
|
588
527
|
const nodes = {
|
|
528
|
+
box_element: () => ['boxed-text', 0],
|
|
589
529
|
author_notes: () => '',
|
|
590
530
|
corresp: () => '',
|
|
591
531
|
title: () => '',
|
|
@@ -646,24 +586,25 @@ export class JATSExporter {
|
|
|
646
586
|
return xref;
|
|
647
587
|
},
|
|
648
588
|
cross_reference: (node) => {
|
|
589
|
+
var _a;
|
|
649
590
|
const cross = node;
|
|
650
591
|
const rids = cross.attrs.rids;
|
|
651
592
|
if (!rids.length) {
|
|
652
593
|
return cross.attrs.label;
|
|
653
594
|
}
|
|
654
595
|
const text = cross.attrs.customLabel || cross.attrs.label;
|
|
655
|
-
const
|
|
656
|
-
if (!
|
|
596
|
+
const target = (_a = findChildrenByAttr(this.manuscriptNode, (attrs) => attrs.id === rids[0])[0]) === null || _a === void 0 ? void 0 : _a.node;
|
|
597
|
+
if (!target) {
|
|
657
598
|
warn('');
|
|
658
599
|
return text;
|
|
659
600
|
}
|
|
660
601
|
const xref = this.document.createElement('xref');
|
|
661
|
-
const type = chooseRefType(
|
|
602
|
+
const type = chooseRefType(target.type);
|
|
662
603
|
if (type) {
|
|
663
604
|
xref.setAttribute('ref-type', type);
|
|
664
605
|
}
|
|
665
606
|
else {
|
|
666
|
-
warn(`Unset ref-type for
|
|
607
|
+
warn(`Unset ref-type for schema type ${target.type.name}`);
|
|
667
608
|
}
|
|
668
609
|
xref.setAttribute('rid', normalizeID(rids.join(' ')));
|
|
669
610
|
xref.textContent = text;
|
|
@@ -735,7 +676,10 @@ export class JATSExporter {
|
|
|
735
676
|
hard_break: () => '',
|
|
736
677
|
highlight_marker: () => '',
|
|
737
678
|
inline_footnote: (node) => {
|
|
738
|
-
const rids = node.attrs.rids.filter(
|
|
679
|
+
const rids = node.attrs.rids.filter((rid) => {
|
|
680
|
+
var _a;
|
|
681
|
+
return (_a = findChildrenByAttr(this.manuscriptNode, (attrs) => attrs.id === rid)[0]) === null || _a === void 0 ? void 0 : _a.node;
|
|
682
|
+
});
|
|
739
683
|
if (rids.length == 0) {
|
|
740
684
|
return '';
|
|
741
685
|
}
|
|
@@ -854,14 +798,7 @@ export class JATSExporter {
|
|
|
854
798
|
italic: () => ['italic'],
|
|
855
799
|
smallcaps: () => ['sc'],
|
|
856
800
|
strikethrough: () => ['strike'],
|
|
857
|
-
styled: (
|
|
858
|
-
const inlineStyle = getModel(mark.attrs.rid);
|
|
859
|
-
const attrs = {};
|
|
860
|
-
if (inlineStyle && inlineStyle.title) {
|
|
861
|
-
attrs.style = normalizeStyleName(inlineStyle.title);
|
|
862
|
-
}
|
|
863
|
-
return ['styled-content', attrs];
|
|
864
|
-
},
|
|
801
|
+
styled: () => ['styled-content'],
|
|
865
802
|
superscript: () => ['sup'],
|
|
866
803
|
subscript: () => ['sub'],
|
|
867
804
|
underline: () => ['underline'],
|
|
@@ -912,14 +849,16 @@ export class JATSExporter {
|
|
|
912
849
|
}
|
|
913
850
|
};
|
|
914
851
|
const appendChildNodeOfType = (element, node, type) => {
|
|
915
|
-
|
|
852
|
+
var _a;
|
|
853
|
+
const childNode = (_a = findChildrenByType(node, type)[0]) === null || _a === void 0 ? void 0 : _a.node;
|
|
916
854
|
if (childNode) {
|
|
917
855
|
element.appendChild(this.serializeNode(childNode));
|
|
918
856
|
}
|
|
919
857
|
};
|
|
920
858
|
const appendTable = (element, node) => {
|
|
921
|
-
|
|
922
|
-
const
|
|
859
|
+
var _a, _b;
|
|
860
|
+
const tableNode = (_a = findChildrenByType(node, node.type.schema.nodes.table)[0]) === null || _a === void 0 ? void 0 : _a.node;
|
|
861
|
+
const colGroupNode = (_b = findChildrenByType(node, node.type.schema.nodes.table_colgroup)[0]) === null || _b === void 0 ? void 0 : _b.node;
|
|
923
862
|
if (!tableNode) {
|
|
924
863
|
return;
|
|
925
864
|
}
|
|
@@ -965,7 +904,8 @@ export class JATSExporter {
|
|
|
965
904
|
return element;
|
|
966
905
|
};
|
|
967
906
|
const processExecutableNode = (node, element) => {
|
|
968
|
-
|
|
907
|
+
var _a;
|
|
908
|
+
const listingNode = (_a = findChildrenByType(node, node.type.schema.nodes.listing)[0]) === null || _a === void 0 ? void 0 : _a.node;
|
|
969
909
|
if (listingNode) {
|
|
970
910
|
const { contents, languageKey } = listingNode.attrs;
|
|
971
911
|
if (contents && languageKey) {
|
|
@@ -999,25 +939,25 @@ export class JATSExporter {
|
|
|
999
939
|
}
|
|
1000
940
|
};
|
|
1001
941
|
};
|
|
1002
|
-
this.serializeFragment = (fragment) => this.serializer.serializeFragment(fragment, {
|
|
1003
|
-
document: this.document,
|
|
1004
|
-
});
|
|
1005
942
|
this.serializeNode = (node) => this.serializer.serializeNode(node, {
|
|
1006
943
|
document: this.document,
|
|
1007
944
|
});
|
|
1008
945
|
this.validateContributor = (contributor) => {
|
|
1009
|
-
if (!contributor.bibliographicName) {
|
|
1010
|
-
throw new Error(`${contributor.
|
|
946
|
+
if (!contributor.attrs.bibliographicName) {
|
|
947
|
+
throw new Error(`${contributor.attrs.id} has no bibliographicName`);
|
|
1011
948
|
}
|
|
1012
|
-
const { family, given } = contributor.bibliographicName;
|
|
949
|
+
const { family, given } = contributor.attrs.bibliographicName;
|
|
1013
950
|
if (!family && !given) {
|
|
1014
|
-
throw new Error(`${contributor.
|
|
951
|
+
throw new Error(`${contributor.attrs.id} has neither family nor given name`);
|
|
1015
952
|
}
|
|
1016
953
|
};
|
|
1017
954
|
this.buildContributors = (articleMeta) => {
|
|
1018
|
-
const
|
|
1019
|
-
const
|
|
1020
|
-
.filter((
|
|
955
|
+
const contributorNodes = findChildrenByType(this.manuscriptNode, schema.nodes.contributor).map((result) => result.node);
|
|
956
|
+
const authorContributorNodes = contributorNodes
|
|
957
|
+
.filter((n) => n.attrs.role === 'author')
|
|
958
|
+
.sort(sortContributors);
|
|
959
|
+
const otherContributorsNodes = contributorNodes
|
|
960
|
+
.filter((n) => n.attrs.role !== 'author')
|
|
1021
961
|
.sort(sortContributors);
|
|
1022
962
|
const affiliationLabels = new Map();
|
|
1023
963
|
const creatAffiliationLabel = (rid) => {
|
|
@@ -1035,11 +975,11 @@ export class JATSExporter {
|
|
|
1035
975
|
sup.textContent = String(content);
|
|
1036
976
|
return sup;
|
|
1037
977
|
};
|
|
1038
|
-
if (
|
|
978
|
+
if (authorContributorNodes.length) {
|
|
1039
979
|
const contribGroup = this.document.createElement('contrib-group');
|
|
1040
980
|
contribGroup.setAttribute('content-type', 'authors');
|
|
1041
981
|
articleMeta.appendChild(contribGroup);
|
|
1042
|
-
|
|
982
|
+
authorContributorNodes.forEach((contributor) => {
|
|
1043
983
|
try {
|
|
1044
984
|
this.validateContributor(contributor);
|
|
1045
985
|
}
|
|
@@ -1049,39 +989,25 @@ export class JATSExporter {
|
|
|
1049
989
|
}
|
|
1050
990
|
const contrib = this.document.createElement('contrib');
|
|
1051
991
|
contrib.setAttribute('contrib-type', 'author');
|
|
1052
|
-
contrib.setAttribute('id', normalizeID(contributor.
|
|
1053
|
-
if (contributor.isCorresponding) {
|
|
992
|
+
contrib.setAttribute('id', normalizeID(contributor.attrs.id));
|
|
993
|
+
if (contributor.attrs.isCorresponding) {
|
|
1054
994
|
contrib.setAttribute('corresp', 'yes');
|
|
1055
995
|
}
|
|
1056
|
-
if (contributor.ORCIDIdentifier) {
|
|
996
|
+
if (contributor.attrs.ORCIDIdentifier) {
|
|
1057
997
|
const identifier = this.document.createElement('contrib-id');
|
|
1058
998
|
identifier.setAttribute('contrib-id-type', 'orcid');
|
|
1059
|
-
identifier.textContent = contributor.ORCIDIdentifier;
|
|
999
|
+
identifier.textContent = contributor.attrs.ORCIDIdentifier;
|
|
1060
1000
|
contrib.appendChild(identifier);
|
|
1061
1001
|
}
|
|
1062
1002
|
const name = this.buildContributorName(contributor);
|
|
1063
1003
|
contrib.appendChild(name);
|
|
1064
|
-
if (contributor.email) {
|
|
1004
|
+
if (contributor.attrs.email) {
|
|
1065
1005
|
const email = this.document.createElement('email');
|
|
1066
|
-
email.textContent = contributor.email;
|
|
1006
|
+
email.textContent = contributor.attrs.email;
|
|
1067
1007
|
contrib.appendChild(email);
|
|
1068
1008
|
}
|
|
1069
|
-
if (contributor.
|
|
1070
|
-
contributor.
|
|
1071
|
-
const contributorRole = this.modelMap.get(rid);
|
|
1072
|
-
if (contributorRole) {
|
|
1073
|
-
const role = this.document.createElement('role');
|
|
1074
|
-
const attributes = chooseRoleVocabAttributes(contributorRole);
|
|
1075
|
-
for (const [key, value] of Object.entries(attributes)) {
|
|
1076
|
-
role.setAttribute(key, value);
|
|
1077
|
-
}
|
|
1078
|
-
role.textContent = contributorRole.name;
|
|
1079
|
-
contrib.appendChild(role);
|
|
1080
|
-
}
|
|
1081
|
-
});
|
|
1082
|
-
}
|
|
1083
|
-
if (contributor.affiliations) {
|
|
1084
|
-
contributor.affiliations.forEach((rid) => {
|
|
1009
|
+
if (contributor.attrs.affiliations) {
|
|
1010
|
+
contributor.attrs.affiliations.forEach((rid) => {
|
|
1085
1011
|
const xref = this.document.createElement('xref');
|
|
1086
1012
|
xref.setAttribute('ref-type', 'aff');
|
|
1087
1013
|
xref.setAttribute('rid', normalizeID(rid));
|
|
@@ -1089,8 +1015,8 @@ export class JATSExporter {
|
|
|
1089
1015
|
contrib.appendChild(xref);
|
|
1090
1016
|
});
|
|
1091
1017
|
}
|
|
1092
|
-
if (contributor.footnote) {
|
|
1093
|
-
contributor.footnote.map((note) => {
|
|
1018
|
+
if (contributor.attrs.footnote) {
|
|
1019
|
+
contributor.attrs.footnote.map((note) => {
|
|
1094
1020
|
const xref = this.document.createElement('xref');
|
|
1095
1021
|
xref.setAttribute('ref-type', 'fn');
|
|
1096
1022
|
xref.setAttribute('rid', normalizeID(note.noteID));
|
|
@@ -1098,8 +1024,8 @@ export class JATSExporter {
|
|
|
1098
1024
|
contrib.appendChild(xref);
|
|
1099
1025
|
});
|
|
1100
1026
|
}
|
|
1101
|
-
if (contributor.corresp) {
|
|
1102
|
-
contributor.corresp.map((corresp) => {
|
|
1027
|
+
if (contributor.attrs.corresp) {
|
|
1028
|
+
contributor.attrs.corresp.map((corresp) => {
|
|
1103
1029
|
const xref = this.document.createElement('xref');
|
|
1104
1030
|
xref.setAttribute('ref-type', 'corresp');
|
|
1105
1031
|
xref.setAttribute('rid', normalizeID(corresp.correspID));
|
|
@@ -1109,13 +1035,10 @@ export class JATSExporter {
|
|
|
1109
1035
|
}
|
|
1110
1036
|
contribGroup.appendChild(contrib);
|
|
1111
1037
|
});
|
|
1112
|
-
|
|
1113
|
-
.filter((contributor) => contributor.role !== 'author')
|
|
1114
|
-
.sort(sortContributors);
|
|
1115
|
-
if (otherContributors.length) {
|
|
1038
|
+
if (otherContributorsNodes.length) {
|
|
1116
1039
|
const contribGroup = this.document.createElement('contrib-group');
|
|
1117
1040
|
articleMeta.appendChild(contribGroup);
|
|
1118
|
-
|
|
1041
|
+
otherContributorsNodes.forEach((contributor) => {
|
|
1119
1042
|
try {
|
|
1120
1043
|
this.validateContributor(contributor);
|
|
1121
1044
|
}
|
|
@@ -1124,30 +1047,16 @@ export class JATSExporter {
|
|
|
1124
1047
|
return;
|
|
1125
1048
|
}
|
|
1126
1049
|
const contrib = this.document.createElement('contrib');
|
|
1127
|
-
contrib.setAttribute('id', normalizeID(contributor.
|
|
1050
|
+
contrib.setAttribute('id', normalizeID(contributor.attrs.id));
|
|
1128
1051
|
const name = this.buildContributorName(contributor);
|
|
1129
1052
|
contrib.appendChild(name);
|
|
1130
|
-
if (contributor.email) {
|
|
1053
|
+
if (contributor.attrs.email) {
|
|
1131
1054
|
const email = this.document.createElement('email');
|
|
1132
|
-
email.textContent = contributor.email;
|
|
1055
|
+
email.textContent = contributor.attrs.email;
|
|
1133
1056
|
contrib.appendChild(email);
|
|
1134
1057
|
}
|
|
1135
|
-
if (contributor.
|
|
1136
|
-
contributor.
|
|
1137
|
-
const contributorRole = this.modelMap.get(rid);
|
|
1138
|
-
if (contributorRole) {
|
|
1139
|
-
const role = this.document.createElement('role');
|
|
1140
|
-
const attributes = chooseRoleVocabAttributes(contributorRole);
|
|
1141
|
-
for (const [key, value] of Object.entries(attributes)) {
|
|
1142
|
-
role.setAttribute(key, value);
|
|
1143
|
-
}
|
|
1144
|
-
role.textContent = contributorRole.name;
|
|
1145
|
-
contrib.appendChild(role);
|
|
1146
|
-
}
|
|
1147
|
-
});
|
|
1148
|
-
}
|
|
1149
|
-
if (contributor.affiliations) {
|
|
1150
|
-
contributor.affiliations.forEach((rid) => {
|
|
1058
|
+
if (contributor.attrs.affiliations) {
|
|
1059
|
+
contributor.attrs.affiliations.forEach((rid) => {
|
|
1151
1060
|
const xref = this.document.createElement('xref');
|
|
1152
1061
|
xref.setAttribute('ref-type', 'aff');
|
|
1153
1062
|
xref.setAttribute('rid', normalizeID(rid));
|
|
@@ -1155,8 +1064,8 @@ export class JATSExporter {
|
|
|
1155
1064
|
contrib.appendChild(xref);
|
|
1156
1065
|
});
|
|
1157
1066
|
}
|
|
1158
|
-
if (contributor.footnote) {
|
|
1159
|
-
contributor.footnote.map((note) => {
|
|
1067
|
+
if (contributor.attrs.footnote) {
|
|
1068
|
+
contributor.attrs.footnote.map((note) => {
|
|
1160
1069
|
const xref = this.document.createElement('xref');
|
|
1161
1070
|
xref.setAttribute('ref-type', 'fn');
|
|
1162
1071
|
xref.setAttribute('rid', normalizeID(note.noteID));
|
|
@@ -1168,64 +1077,68 @@ export class JATSExporter {
|
|
|
1168
1077
|
});
|
|
1169
1078
|
}
|
|
1170
1079
|
const affiliationRIDs = [];
|
|
1171
|
-
const sortedContributors = [
|
|
1080
|
+
const sortedContributors = [
|
|
1081
|
+
...authorContributorNodes,
|
|
1082
|
+
...otherContributorsNodes,
|
|
1083
|
+
];
|
|
1172
1084
|
for (const contributor of sortedContributors) {
|
|
1173
|
-
if (contributor.affiliations) {
|
|
1174
|
-
affiliationRIDs.push(...contributor.affiliations);
|
|
1085
|
+
if (contributor.attrs.affiliations) {
|
|
1086
|
+
affiliationRIDs.push(...contributor.attrs.affiliations);
|
|
1175
1087
|
}
|
|
1176
1088
|
}
|
|
1177
|
-
const affiliations = this.
|
|
1089
|
+
const affiliations = findChildrenByType(this.manuscriptNode, schema.nodes.affiliation).map((result) => result.node);
|
|
1178
1090
|
if (affiliations) {
|
|
1179
|
-
const usedAffiliations = affiliations.filter((affiliation) => affiliationRIDs.includes(affiliation.
|
|
1180
|
-
usedAffiliations.sort((a, b) => affiliationRIDs.indexOf(a.
|
|
1091
|
+
const usedAffiliations = affiliations.filter((affiliation) => affiliationRIDs.includes(affiliation.attrs.id));
|
|
1092
|
+
usedAffiliations.sort((a, b) => affiliationRIDs.indexOf(a.attrs.id) -
|
|
1093
|
+
affiliationRIDs.indexOf(b.attrs.id));
|
|
1181
1094
|
usedAffiliations.forEach((affiliation) => {
|
|
1182
1095
|
var _a, _b;
|
|
1183
1096
|
const aff = this.document.createElement('aff');
|
|
1184
|
-
aff.setAttribute('id', normalizeID(affiliation.
|
|
1097
|
+
aff.setAttribute('id', normalizeID(affiliation.attrs.id));
|
|
1185
1098
|
contribGroup.appendChild(aff);
|
|
1186
|
-
if (affiliation.department) {
|
|
1099
|
+
if (affiliation.attrs.department) {
|
|
1187
1100
|
const department = this.document.createElement('institution');
|
|
1188
1101
|
department.setAttribute('content-type', 'dept');
|
|
1189
|
-
department.textContent = affiliation.department;
|
|
1102
|
+
department.textContent = affiliation.attrs.department;
|
|
1190
1103
|
aff.appendChild(department);
|
|
1191
1104
|
}
|
|
1192
|
-
if (affiliation.institution) {
|
|
1105
|
+
if (affiliation.attrs.institution) {
|
|
1193
1106
|
const institution = this.document.createElement('institution');
|
|
1194
|
-
institution.textContent = affiliation.institution;
|
|
1107
|
+
institution.textContent = affiliation.attrs.institution;
|
|
1195
1108
|
aff.appendChild(institution);
|
|
1196
1109
|
}
|
|
1197
|
-
if (affiliation.addressLine1) {
|
|
1110
|
+
if (affiliation.attrs.addressLine1) {
|
|
1198
1111
|
const addressLine = this.document.createElement('addr-line');
|
|
1199
|
-
addressLine.textContent = affiliation.addressLine1;
|
|
1112
|
+
addressLine.textContent = affiliation.attrs.addressLine1;
|
|
1200
1113
|
aff.appendChild(addressLine);
|
|
1201
1114
|
}
|
|
1202
|
-
if (affiliation.addressLine2) {
|
|
1115
|
+
if (affiliation.attrs.addressLine2) {
|
|
1203
1116
|
const addressLine = this.document.createElement('addr-line');
|
|
1204
|
-
addressLine.textContent = affiliation.addressLine2;
|
|
1117
|
+
addressLine.textContent = affiliation.attrs.addressLine2;
|
|
1205
1118
|
aff.appendChild(addressLine);
|
|
1206
1119
|
}
|
|
1207
|
-
if (affiliation.addressLine3) {
|
|
1120
|
+
if (affiliation.attrs.addressLine3) {
|
|
1208
1121
|
const addressLine = this.document.createElement('addr-line');
|
|
1209
|
-
addressLine.textContent = affiliation.addressLine3;
|
|
1122
|
+
addressLine.textContent = affiliation.attrs.addressLine3;
|
|
1210
1123
|
aff.appendChild(addressLine);
|
|
1211
1124
|
}
|
|
1212
|
-
if (affiliation.city) {
|
|
1125
|
+
if (affiliation.attrs.city) {
|
|
1213
1126
|
const city = this.document.createElement('city');
|
|
1214
|
-
city.textContent = affiliation.city;
|
|
1127
|
+
city.textContent = affiliation.attrs.city;
|
|
1215
1128
|
aff.appendChild(city);
|
|
1216
1129
|
}
|
|
1217
|
-
if (affiliation.country) {
|
|
1130
|
+
if (affiliation.attrs.country) {
|
|
1218
1131
|
const country = this.document.createElement('country');
|
|
1219
|
-
country.textContent = affiliation.country;
|
|
1132
|
+
country.textContent = affiliation.attrs.country;
|
|
1220
1133
|
aff.appendChild(country);
|
|
1221
1134
|
}
|
|
1222
|
-
if (affiliation.email) {
|
|
1135
|
+
if (affiliation.attrs.email) {
|
|
1223
1136
|
const email = this.document.createElement('email');
|
|
1224
|
-
email.setAttributeNS(XLINK_NAMESPACE, 'href', (_a = affiliation.email.href) !== null && _a !== void 0 ? _a : '');
|
|
1225
|
-
email.textContent = (_b = affiliation.email.text) !== null && _b !== void 0 ? _b : '';
|
|
1137
|
+
email.setAttributeNS(XLINK_NAMESPACE, 'href', (_a = affiliation.attrs.email.href) !== null && _a !== void 0 ? _a : '');
|
|
1138
|
+
email.textContent = (_b = affiliation.attrs.email.text) !== null && _b !== void 0 ? _b : '';
|
|
1226
1139
|
aff.appendChild(email);
|
|
1227
1140
|
}
|
|
1228
|
-
const labelNumber = affiliationLabels.get(affiliation.
|
|
1141
|
+
const labelNumber = affiliationLabels.get(affiliation.attrs.id);
|
|
1229
1142
|
if (labelNumber) {
|
|
1230
1143
|
const label = this.document.createElement('label');
|
|
1231
1144
|
label.textContent = String(labelNumber);
|
|
@@ -1242,41 +1155,48 @@ export class JATSExporter {
|
|
|
1242
1155
|
this.createAuthorNotesElement = () => {
|
|
1243
1156
|
var _a;
|
|
1244
1157
|
const authorNotesEl = this.document.createElement('author-notes');
|
|
1245
|
-
const
|
|
1246
|
-
if (
|
|
1247
|
-
this.appendModelsToAuthorNotes(authorNotesEl,
|
|
1158
|
+
const authorNotesNode = (_a = findChildrenByType(this.manuscriptNode, schema.nodes.author_notes)[0]) === null || _a === void 0 ? void 0 : _a.node;
|
|
1159
|
+
if (authorNotesNode) {
|
|
1160
|
+
this.appendModelsToAuthorNotes(authorNotesEl, authorNotesNode);
|
|
1248
1161
|
}
|
|
1249
1162
|
return authorNotesEl;
|
|
1250
1163
|
};
|
|
1251
1164
|
this.appendCorrespondingToElement = (corresponding, element) => {
|
|
1252
1165
|
const correspondingEl = this.document.createElement('corresp');
|
|
1253
|
-
correspondingEl.setAttribute('id', normalizeID(corresponding.
|
|
1254
|
-
if (corresponding.label) {
|
|
1166
|
+
correspondingEl.setAttribute('id', normalizeID(corresponding.attrs.id));
|
|
1167
|
+
if (corresponding.attrs.label) {
|
|
1255
1168
|
const labelEl = this.document.createElement('label');
|
|
1256
|
-
labelEl.textContent = corresponding.label;
|
|
1169
|
+
labelEl.textContent = corresponding.attrs.label;
|
|
1257
1170
|
correspondingEl.appendChild(labelEl);
|
|
1258
1171
|
}
|
|
1259
|
-
correspondingEl.append(corresponding.
|
|
1172
|
+
correspondingEl.append(corresponding.textContent);
|
|
1260
1173
|
element.appendChild(correspondingEl);
|
|
1261
1174
|
};
|
|
1262
1175
|
this.appendParagraphToElement = (paragraph, element) => {
|
|
1263
|
-
const parsedDoc = new DOMParser().parseFromString(paragraph.
|
|
1176
|
+
const parsedDoc = new DOMParser().parseFromString(paragraph.textContent, 'text/html');
|
|
1264
1177
|
const parsedParagraph = parsedDoc.body.querySelector('p');
|
|
1265
1178
|
if (parsedParagraph) {
|
|
1266
1179
|
const paragraphEl = this.document.createElement('p');
|
|
1267
1180
|
paragraphEl.innerHTML = parsedParagraph.innerHTML;
|
|
1268
|
-
paragraphEl.setAttribute('id', normalizeID(paragraph.
|
|
1181
|
+
paragraphEl.setAttribute('id', normalizeID(paragraph.attrs.id));
|
|
1269
1182
|
element.appendChild(paragraphEl);
|
|
1270
1183
|
}
|
|
1271
1184
|
};
|
|
1272
1185
|
this.appendFootnoteToElement = (footnote, element) => {
|
|
1273
1186
|
const footnoteEl = this.document.createElement('fn');
|
|
1274
|
-
footnoteEl.setAttribute('id', normalizeID(footnote.
|
|
1275
|
-
|
|
1187
|
+
footnoteEl.setAttribute('id', normalizeID(footnote.attrs.id));
|
|
1188
|
+
if (!footnote.textContent.includes('<p>')) {
|
|
1189
|
+
const p = this.document.createElement('p');
|
|
1190
|
+
p.innerHTML = footnote.textContent;
|
|
1191
|
+
footnoteEl.appendChild(p);
|
|
1192
|
+
}
|
|
1193
|
+
else {
|
|
1194
|
+
footnoteEl.innerHTML = footnote.textContent;
|
|
1195
|
+
}
|
|
1276
1196
|
element.appendChild(footnoteEl);
|
|
1277
1197
|
};
|
|
1278
|
-
this.fixBody = (body
|
|
1279
|
-
|
|
1198
|
+
this.fixBody = (body) => {
|
|
1199
|
+
this.manuscriptNode.descendants((node) => {
|
|
1280
1200
|
if (node.attrs.id) {
|
|
1281
1201
|
if (node.attrs.titleSuppressed) {
|
|
1282
1202
|
const title = body.querySelector(`#${normalizeID(node.attrs.id)} > title`);
|
|
@@ -1537,36 +1457,36 @@ export class JATSExporter {
|
|
|
1537
1457
|
};
|
|
1538
1458
|
this.buildContributorName = (contributor) => {
|
|
1539
1459
|
const name = this.document.createElement('name');
|
|
1540
|
-
if (contributor.bibliographicName.family) {
|
|
1460
|
+
if (contributor.attrs.bibliographicName.family) {
|
|
1541
1461
|
const surname = this.document.createElement('surname');
|
|
1542
|
-
surname.textContent = contributor.bibliographicName.family;
|
|
1462
|
+
surname.textContent = contributor.attrs.bibliographicName.family;
|
|
1543
1463
|
name.appendChild(surname);
|
|
1544
1464
|
}
|
|
1545
|
-
if (contributor.bibliographicName.given) {
|
|
1465
|
+
if (contributor.attrs.bibliographicName.given) {
|
|
1546
1466
|
const givenNames = this.document.createElement('given-names');
|
|
1547
|
-
givenNames.textContent = contributor.bibliographicName.given;
|
|
1467
|
+
givenNames.textContent = contributor.attrs.bibliographicName.given;
|
|
1548
1468
|
name.appendChild(givenNames);
|
|
1549
1469
|
}
|
|
1550
1470
|
return name;
|
|
1551
1471
|
};
|
|
1552
1472
|
}
|
|
1553
|
-
generateCitations(
|
|
1473
|
+
generateCitations() {
|
|
1554
1474
|
const nodes = [];
|
|
1555
|
-
|
|
1475
|
+
this.manuscriptNode.descendants((node) => {
|
|
1556
1476
|
if (isCitationNode(node)) {
|
|
1557
1477
|
nodes.push(node);
|
|
1558
1478
|
}
|
|
1559
1479
|
});
|
|
1560
1480
|
return buildCitations(nodes);
|
|
1561
1481
|
}
|
|
1562
|
-
generateCitationTexts(
|
|
1482
|
+
generateCitationTexts(csl, manuscriptID) {
|
|
1563
1483
|
this.citationTexts = new Map();
|
|
1564
1484
|
this.citationProvider = new CitationProvider({
|
|
1565
|
-
getLibraryItem:
|
|
1485
|
+
getLibraryItem: this.getLibraryItem(manuscriptID),
|
|
1566
1486
|
locale: csl.locale,
|
|
1567
1487
|
citationStyle: csl.style,
|
|
1568
1488
|
});
|
|
1569
|
-
const citations = this.generateCitations(
|
|
1489
|
+
const citations = this.generateCitations();
|
|
1570
1490
|
this.citationProvider.rebuildState(citations).forEach(([id, , output]) => {
|
|
1571
1491
|
this.citationTexts.set(id, output);
|
|
1572
1492
|
});
|
|
@@ -1593,72 +1513,50 @@ export class JATSExporter {
|
|
|
1593
1513
|
return mathml;
|
|
1594
1514
|
}
|
|
1595
1515
|
}
|
|
1596
|
-
appendModelsToAuthorNotes(authorNotesEl,
|
|
1597
|
-
const
|
|
1598
|
-
const usedCorrespondings = this.getUsedCorrespondings(
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
}
|
|
1604
|
-
switch (model.objectType) {
|
|
1605
|
-
case ObjectTypes.ParagraphElement:
|
|
1606
|
-
this.appendParagraphToElement(model, authorNotesEl);
|
|
1516
|
+
appendModelsToAuthorNotes(authorNotesEl, authorNotesNode) {
|
|
1517
|
+
const contributorsNodes = findChildrenByType(this.manuscriptNode, schema.nodes.contributor).map((result) => result.node);
|
|
1518
|
+
const usedCorrespondings = this.getUsedCorrespondings(contributorsNodes);
|
|
1519
|
+
authorNotesNode.descendants((node) => {
|
|
1520
|
+
switch (node.type) {
|
|
1521
|
+
case schema.nodes.paragraph:
|
|
1522
|
+
this.appendParagraphToElement(node, authorNotesEl);
|
|
1607
1523
|
break;
|
|
1608
|
-
case
|
|
1609
|
-
this.appendFootnoteToElement(
|
|
1524
|
+
case schema.nodes.footnote:
|
|
1525
|
+
this.appendFootnoteToElement(node, authorNotesEl);
|
|
1610
1526
|
break;
|
|
1611
|
-
case
|
|
1612
|
-
if (usedCorrespondings.includes(
|
|
1613
|
-
this.appendCorrespondingToElement(
|
|
1527
|
+
case schema.nodes.corresp:
|
|
1528
|
+
if (usedCorrespondings.includes(node)) {
|
|
1529
|
+
this.appendCorrespondingToElement(node, authorNotesEl);
|
|
1614
1530
|
}
|
|
1615
1531
|
break;
|
|
1616
1532
|
}
|
|
1533
|
+
return false;
|
|
1617
1534
|
});
|
|
1618
1535
|
}
|
|
1619
1536
|
getUsedCorrespondings(contributors) {
|
|
1620
1537
|
return contributors
|
|
1621
|
-
.flatMap((c) => { var _a; return (_a = c.corresp) !== null && _a !== void 0 ? _a : []; })
|
|
1622
|
-
.map((corresp) =>
|
|
1538
|
+
.flatMap((c) => { var _a; return (_a = c.attrs.corresp) !== null && _a !== void 0 ? _a : []; })
|
|
1539
|
+
.map((corresp) => {
|
|
1540
|
+
var _a;
|
|
1541
|
+
return (_a = findChildrenByAttr(this.manuscriptNode, (attr) => attr.id === corresp.correspID)[0]) === null || _a === void 0 ? void 0 : _a.node;
|
|
1542
|
+
})
|
|
1623
1543
|
.filter((corresp) => !!corresp);
|
|
1624
1544
|
}
|
|
1625
1545
|
buildKeywords(articleMeta) {
|
|
1626
|
-
const
|
|
1627
|
-
|
|
1628
|
-
keywords.forEach((keyword) => {
|
|
1629
|
-
const containedGroup = keyword.containedGroup || '';
|
|
1630
|
-
const group = keywordGroups.get(containedGroup);
|
|
1631
|
-
if (group) {
|
|
1632
|
-
group.push(keyword);
|
|
1633
|
-
}
|
|
1634
|
-
else {
|
|
1635
|
-
keywordGroups.set(containedGroup, [keyword]);
|
|
1636
|
-
}
|
|
1637
|
-
});
|
|
1638
|
-
for (const [groupID, keywords] of keywordGroups) {
|
|
1639
|
-
const keywordGroup = (this.modelMap.get(groupID) || {});
|
|
1546
|
+
const keywordGroups = findChildrenByType(this.manuscriptNode, schema.nodes.keyword_group).map((result) => result.node);
|
|
1547
|
+
keywordGroups.forEach((group) => {
|
|
1640
1548
|
const kwdGroup = this.document.createElement('kwd-group');
|
|
1641
|
-
if (
|
|
1642
|
-
kwdGroup.setAttribute('kwd-group-type',
|
|
1643
|
-
}
|
|
1644
|
-
if (keywordGroup.label) {
|
|
1645
|
-
const label = this.document.createElement('label');
|
|
1646
|
-
label.textContent = keywordGroup.label;
|
|
1647
|
-
kwdGroup.appendChild(label);
|
|
1648
|
-
}
|
|
1649
|
-
if (keywordGroup.title) {
|
|
1650
|
-
const title = this.document.createElement('title');
|
|
1651
|
-
title.textContent = keywordGroup.title;
|
|
1652
|
-
kwdGroup.appendChild(title);
|
|
1549
|
+
if (group.attrs.type) {
|
|
1550
|
+
kwdGroup.setAttribute('kwd-group-type', group.attrs.type);
|
|
1653
1551
|
}
|
|
1654
1552
|
articleMeta.appendChild(kwdGroup);
|
|
1655
|
-
|
|
1553
|
+
group.content.forEach((keyword) => {
|
|
1656
1554
|
const kwd = this.document.createElement('kwd');
|
|
1657
|
-
kwd.textContent = keyword.
|
|
1555
|
+
kwd.textContent = keyword.textContent;
|
|
1658
1556
|
kwdGroup.appendChild(kwd);
|
|
1659
|
-
}
|
|
1557
|
+
});
|
|
1660
1558
|
articleMeta.appendChild(kwdGroup);
|
|
1661
|
-
}
|
|
1559
|
+
});
|
|
1662
1560
|
}
|
|
1663
1561
|
moveCoiStatementToAuthorNotes(back, front) {
|
|
1664
1562
|
const fnGroups = back.querySelectorAll('fn-group');
|