@manuscripts/transform 2.6.0 → 2.6.1-LEAN-3966.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/index.js +6 -6
- package/dist/cjs/jats/{jats-exporter.js → exporter/jats-exporter.js} +305 -416
- package/dist/cjs/jats/{jats-versions.js → exporter/jats-versions.js} +1 -3
- package/dist/cjs/{transformer → jats/exporter}/labels.js +4 -4
- package/dist/cjs/{transformer/filename.js → jats/importer/create-article-node.js} +10 -9
- package/dist/cjs/jats/importer/jats-comments.js +32 -111
- package/dist/cjs/jats/importer/{jats-body-dom-parser.js → jats-dom-parser.js} +350 -10
- package/dist/cjs/jats/importer/jats-journal-meta-parser.js +11 -1
- package/dist/cjs/jats/importer/jats-parser-utils.js +76 -9
- package/dist/cjs/jats/importer/jats-transformations.js +397 -0
- package/dist/cjs/jats/importer/parse-jats-article.js +44 -101
- package/dist/cjs/jats/index.js +7 -7
- package/dist/cjs/{transformer/models.js → lib/deafults.js} +3 -1
- package/dist/cjs/lib/utils.js +3 -1
- package/dist/cjs/schema/nodes/highlight_marker.js +0 -4
- package/dist/cjs/transformer/id.js +1 -5
- package/dist/cjs/transformer/index.js +0 -18
- package/dist/cjs/version.js +1 -1
- package/dist/es/index.js +5 -5
- package/dist/es/jats/{jats-exporter.js → exporter/jats-exporter.js} +300 -411
- package/dist/es/jats/{jats-versions.js → exporter/jats-versions.js} +0 -1
- package/dist/es/{transformer → jats/exporter}/labels.js +4 -4
- package/dist/{cjs/transformer/model-map.js → es/jats/importer/create-article-node.js} +8 -10
- package/dist/es/jats/importer/jats-comments.js +32 -107
- package/dist/es/jats/importer/{jats-body-dom-parser.js → jats-dom-parser.js} +350 -10
- package/dist/es/jats/importer/jats-journal-meta-parser.js +9 -0
- package/dist/es/jats/importer/jats-parser-utils.js +78 -11
- package/dist/es/jats/importer/jats-transformations.js +377 -0
- package/dist/es/jats/importer/parse-jats-article.js +44 -99
- package/dist/es/jats/index.js +5 -3
- package/dist/{types/transformer/timestamp.d.ts → es/lib/deafults.js} +2 -2
- package/dist/es/lib/utils.js +1 -0
- package/dist/es/schema/nodes/highlight_marker.js +0 -4
- package/dist/es/transformer/id.js +0 -3
- package/dist/es/transformer/index.js +0 -16
- package/dist/es/version.js +1 -1
- package/dist/types/index.d.ts +6 -6
- package/dist/types/jats/{jats-exporter.d.ts → exporter/jats-exporter.d.ts} +16 -29
- package/dist/types/jats/{jats-versions.d.ts → exporter/jats-versions.d.ts} +0 -1
- package/dist/types/{transformer → jats/exporter}/labels.d.ts +2 -2
- package/dist/{es/transformer/footnote-category.js → types/jats/importer/create-article-node.d.ts} +3 -2
- package/dist/types/jats/importer/jats-comments.d.ts +2 -15
- package/dist/types/jats/importer/{jats-body-dom-parser.d.ts → jats-dom-parser.d.ts} +1 -1
- package/dist/types/jats/importer/jats-journal-meta-parser.d.ts +9 -0
- package/dist/types/jats/importer/jats-parser-utils.d.ts +2 -2
- package/dist/types/jats/importer/jats-transformations.d.ts +33 -0
- package/dist/types/jats/importer/parse-jats-article.d.ts +12 -5
- package/dist/types/jats/index.d.ts +5 -3
- package/dist/types/jats/types.d.ts +1 -0
- package/dist/{es/transformer/models.js → types/lib/deafults.d.ts} +2 -2
- package/dist/types/lib/utils.d.ts +1 -0
- package/dist/types/schema/nodes/bibliography_item.d.ts +3 -3
- package/dist/types/schema/nodes/contributor.d.ts +10 -0
- package/dist/types/schema/nodes/highlight_marker.d.ts +0 -2
- package/dist/types/schema/nodes/keyword_group.d.ts +1 -0
- package/dist/types/schema/nodes/manuscript.d.ts +8 -7
- package/dist/types/schema/nodes/title.d.ts +0 -3
- package/dist/types/transformer/id.d.ts +0 -3
- package/dist/types/transformer/index.d.ts +0 -16
- 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/index.js +0 -22
- package/dist/cjs/jats/importer/jats-front-parser.js +0 -321
- package/dist/cjs/jats/importer/jats-reference-parser.js +0 -130
- package/dist/cjs/jats/importer/jats-references.js +0 -34
- 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 -898
- package/dist/cjs/transformer/document-object-types.js +0 -31
- package/dist/cjs/transformer/encode.js +0 -674
- 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/object-types.js +0 -57
- package/dist/cjs/transformer/project-bundle.js +0 -94
- package/dist/cjs/transformer/serializer.js +0 -23
- package/dist/cjs/transformer/timestamp.js +0 -20
- package/dist/cjs/transformer/update-identifiers.js +0 -93
- package/dist/es/__tests__/data/project-dump.json +0 -825
- package/dist/es/jats/importer/index.js +0 -16
- package/dist/es/jats/importer/jats-front-parser.js +0 -315
- package/dist/es/jats/importer/jats-reference-parser.js +0 -127
- package/dist/es/jats/importer/jats-references.js +0 -30
- 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 -888
- package/dist/es/transformer/document-object-types.js +0 -28
- package/dist/es/transformer/encode.js +0 -664
- package/dist/es/transformer/filename.js +0 -23
- 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/timestamp.js +0 -16
- package/dist/es/transformer/update-identifiers.js +0 -87
- package/dist/types/jats/importer/index.d.ts +0 -16
- package/dist/types/jats/importer/jats-front-parser.d.ts +0 -84
- package/dist/types/jats/importer/jats-reference-parser.d.ts +0 -19
- package/dist/types/jats/importer/jats-references.d.ts +0 -12
- 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 -52
- package/dist/types/transformer/document-object-types.d.ts +0 -17
- package/dist/types/transformer/encode.d.ts +0 -29
- package/dist/types/transformer/filename.d.ts +0 -16
- 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/types/types.d.ts +0 -2
- /package/dist/cjs/{types.js → jats/types.js} +0 -0
- /package/dist/es/{types.js → jats/types.js} +0 -0
|
@@ -13,48 +13,21 @@
|
|
|
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
19
|
import { DOMParser as ProsemirrorDOMParser, DOMSerializer, } from 'prosemirror-model';
|
|
20
|
+
import { findChildrenByAttr, findChildrenByType } from 'prosemirror-utils';
|
|
20
21
|
import serializeToXML from 'w3c-xmlserializer';
|
|
21
|
-
import { nodeFromHTML, textFromHTML } from '
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import { isCitationNode, schema, } from '../schema';
|
|
25
|
-
import { generateAttachmentFilename } from '../transformer/filename';
|
|
26
|
-
import { buildTargets } from '../transformer/labels';
|
|
27
|
-
import { isExecutableNodeType, isNodeType } from '../transformer/node-types';
|
|
28
|
-
import { hasObjectType } from '../transformer/object-types';
|
|
29
|
-
import { findManuscript, findManuscriptById, findTitles, } from '../transformer/project-bundle';
|
|
30
|
-
import { chooseJatsFnType, chooseSecType, } from '../transformer/section-category';
|
|
22
|
+
import { nodeFromHTML, textFromHTML } from '../../lib/html';
|
|
23
|
+
import { isCitationNode, schema, } from '../../schema';
|
|
24
|
+
import { chooseJatsFnType, chooseSecType, isExecutableNodeType, isNodeType, } from '../../transformer';
|
|
31
25
|
import { selectVersionIds } from './jats-versions';
|
|
26
|
+
import { buildTargets } from './labels';
|
|
32
27
|
const warn = debug('manuscripts-transform');
|
|
33
28
|
const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
|
|
34
29
|
const normalizeID = (id) => id.replace(/:/g, '_');
|
|
35
30
|
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
31
|
const insertAbstractNode = (articleMeta, abstractNode) => {
|
|
59
32
|
const siblings = [
|
|
60
33
|
'kwd-group',
|
|
@@ -91,24 +64,24 @@ const createDefaultIdGenerator = () => {
|
|
|
91
64
|
return `${element.localName}-${value}`;
|
|
92
65
|
};
|
|
93
66
|
};
|
|
94
|
-
const chooseRefType = (
|
|
95
|
-
switch (
|
|
96
|
-
case
|
|
97
|
-
case
|
|
67
|
+
const chooseRefType = (type) => {
|
|
68
|
+
switch (type) {
|
|
69
|
+
case schema.nodes.figure:
|
|
70
|
+
case schema.nodes.figure_element:
|
|
98
71
|
return 'fig';
|
|
99
|
-
case
|
|
72
|
+
case schema.nodes.footnote:
|
|
100
73
|
return 'fn';
|
|
101
|
-
case
|
|
102
|
-
case
|
|
74
|
+
case schema.nodes.table:
|
|
75
|
+
case schema.nodes.table_element:
|
|
103
76
|
return 'table';
|
|
104
|
-
case
|
|
77
|
+
case schema.nodes.section:
|
|
105
78
|
return 'sec';
|
|
106
|
-
case
|
|
107
|
-
case
|
|
79
|
+
case schema.nodes.equation:
|
|
80
|
+
case schema.nodes.equation_element:
|
|
108
81
|
return 'disp-formula';
|
|
109
82
|
}
|
|
110
83
|
};
|
|
111
|
-
const sortContributors = (a, b) => Number(a.priority) - Number(b.priority);
|
|
84
|
+
const sortContributors = (a, b) => Number(a.attrs.priority) - Number(b.attrs.priority);
|
|
112
85
|
export const buildCitations = (citations) => citations.map((citation) => ({
|
|
113
86
|
citationID: citation.attrs.id,
|
|
114
87
|
citationItems: citation.attrs.rids.map((rid) => ({
|
|
@@ -120,39 +93,58 @@ export const buildCitations = (citations) => citations.map((citation) => ({
|
|
|
120
93
|
}));
|
|
121
94
|
export class JATSExporter {
|
|
122
95
|
constructor() {
|
|
123
|
-
this.
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
96
|
+
this.getLibraryItem = (manuscriptID) => {
|
|
97
|
+
return (id) => {
|
|
98
|
+
var _a;
|
|
99
|
+
const node = (_a = findChildrenByAttr(this.manuscriptNode, (attrs) => attrs.id === id)[0]) === null || _a === void 0 ? void 0 : _a.node;
|
|
100
|
+
if (!node) {
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
103
|
+
return {
|
|
104
|
+
_id: node.attrs.id,
|
|
105
|
+
issued: node.attrs.issued,
|
|
106
|
+
DOI: node.attrs.doi,
|
|
107
|
+
manuscriptID,
|
|
108
|
+
objectType: ObjectTypes.BibliographyItem,
|
|
109
|
+
author: node.attrs.author,
|
|
110
|
+
'container-title': node.attrs.containerTitle,
|
|
111
|
+
volume: node.attrs.volume,
|
|
112
|
+
issue: node.attrs.issue,
|
|
113
|
+
supplement: node.attrs.supplement,
|
|
114
|
+
page: node.attrs.page,
|
|
115
|
+
title: node.attrs.title,
|
|
116
|
+
literal: node.attrs.literal,
|
|
117
|
+
type: node.attrs.type,
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
this.serializeToJATS = async (manuscriptNode, options) => {
|
|
122
|
+
var _a;
|
|
123
|
+
this.manuscriptNode = manuscriptNode;
|
|
124
|
+
this.generateCitationTexts(options.csl, manuscriptNode.attrs.id);
|
|
128
125
|
this.createSerializer();
|
|
129
|
-
const versionIds = selectVersionIds(version);
|
|
126
|
+
const versionIds = selectVersionIds((_a = options.version) !== null && _a !== void 0 ? _a : '1.2');
|
|
130
127
|
this.document = document.implementation.createDocument(null, 'article', document.implementation.createDocumentType('article', versionIds.publicId, versionIds.systemId));
|
|
131
128
|
const article = this.document.documentElement;
|
|
132
129
|
article.setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:xlink', XLINK_NAMESPACE);
|
|
133
|
-
const front = this.buildFront(
|
|
130
|
+
const front = this.buildFront(options.journal);
|
|
134
131
|
article.appendChild(front);
|
|
135
|
-
|
|
136
|
-
|
|
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
|
-
}
|
|
132
|
+
article.setAttribute('article-type', manuscriptNode.attrs.articleType || 'other');
|
|
133
|
+
this.labelTargets = buildTargets(manuscriptNode);
|
|
134
|
+
const body = this.buildBody();
|
|
135
|
+
article.appendChild(body);
|
|
136
|
+
const back = this.buildBack(body);
|
|
137
|
+
this.moveCoiStatementToAuthorNotes(back, front);
|
|
138
|
+
article.appendChild(back);
|
|
139
|
+
this.unwrapBody(body);
|
|
140
|
+
this.moveAbstracts(front, body);
|
|
141
|
+
this.moveFloatsGroup(body, article);
|
|
142
|
+
this.removeBackContainer(body);
|
|
143
|
+
this.updateFootnoteTypes(front, back);
|
|
144
|
+
this.fillEmptyTableFooters(article);
|
|
145
|
+
this.fillEmptyFootnotes(article);
|
|
146
|
+
this.moveAwards(front, body);
|
|
147
|
+
await this.rewriteIDs();
|
|
156
148
|
return serializeToXML(this.document);
|
|
157
149
|
};
|
|
158
150
|
this.nodeFromJATS = (JATSFragment) => {
|
|
@@ -165,19 +157,6 @@ export class JATSExporter {
|
|
|
165
157
|
template.innerHTML = JATSFragment;
|
|
166
158
|
return template.firstChild;
|
|
167
159
|
};
|
|
168
|
-
this.rewriteMediaPaths = async (generator) => {
|
|
169
|
-
const doc = this.document;
|
|
170
|
-
for (const fig of doc.querySelectorAll('fig')) {
|
|
171
|
-
for (const graphic of fig.querySelectorAll('graphic')) {
|
|
172
|
-
const newHref = await generator(graphic, fig.id);
|
|
173
|
-
graphic.setAttributeNS(XLINK_NAMESPACE, 'href', newHref);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
for (const suppl of doc.querySelectorAll('supplementary-material')) {
|
|
177
|
-
const newHref = await generator(suppl, suppl.id);
|
|
178
|
-
suppl.setAttributeNS(XLINK_NAMESPACE, 'href', newHref);
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
160
|
this.rewriteIDs = async (generator = createDefaultIdGenerator()) => {
|
|
182
161
|
const ids = new Map();
|
|
183
162
|
for (const element of this.document.querySelectorAll('[id]')) {
|
|
@@ -219,16 +198,14 @@ export class JATSExporter {
|
|
|
219
198
|
}
|
|
220
199
|
}
|
|
221
200
|
};
|
|
222
|
-
this.buildFront = (
|
|
223
|
-
var _a
|
|
224
|
-
const
|
|
225
|
-
const titles = findTitles(this.modelMap);
|
|
201
|
+
this.buildFront = (journal) => {
|
|
202
|
+
var _a;
|
|
203
|
+
const titleNode = (_a = findChildrenByType(this.manuscriptNode, schema.nodes.title)[0]) === null || _a === void 0 ? void 0 : _a.node;
|
|
226
204
|
const front = this.document.createElement('front');
|
|
227
205
|
const journalMeta = this.document.createElement('journal-meta');
|
|
228
206
|
front.appendChild(journalMeta);
|
|
229
207
|
const articleMeta = this.document.createElement('article-meta');
|
|
230
208
|
front.appendChild(articleMeta);
|
|
231
|
-
const journal = [...this.modelMap.values()].find((model) => model.objectType === ObjectTypes.Journal);
|
|
232
209
|
if (journal) {
|
|
233
210
|
if (journal.journalIdentifiers) {
|
|
234
211
|
for (const item of journal.journalIdentifiers) {
|
|
@@ -277,109 +254,47 @@ export class JATSExporter {
|
|
|
277
254
|
journalMeta.appendChild(publisher);
|
|
278
255
|
}
|
|
279
256
|
}
|
|
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) {
|
|
257
|
+
if (this.manuscriptNode.attrs.doi) {
|
|
287
258
|
const articleID = this.document.createElement('article-id');
|
|
288
259
|
articleID.setAttribute('pub-id-type', 'doi');
|
|
289
|
-
articleID.textContent =
|
|
260
|
+
articleID.textContent = this.manuscriptNode.attrs.doi;
|
|
290
261
|
articleMeta.appendChild(articleID);
|
|
291
262
|
}
|
|
292
263
|
const titleGroup = this.document.createElement('title-group');
|
|
293
264
|
articleMeta.appendChild(titleGroup);
|
|
294
265
|
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) {
|
|
266
|
+
if (titleNode) {
|
|
304
267
|
const element = this.document.createElement('article-title');
|
|
305
|
-
this.setTitleContent(element,
|
|
306
|
-
titleGroup.appendChild(element);
|
|
307
|
-
}
|
|
308
|
-
if (titles.subtitle) {
|
|
309
|
-
const element = this.document.createElement('subtitle');
|
|
310
|
-
this.setTitleContent(element, titles.subtitle);
|
|
311
|
-
titleGroup.appendChild(element);
|
|
312
|
-
}
|
|
313
|
-
if (titles.runningTitle) {
|
|
314
|
-
const element = this.document.createElement('alt-title');
|
|
315
|
-
element.setAttribute('alt-title-type', 'right-running');
|
|
316
|
-
this.setTitleContent(element, titles.runningTitle);
|
|
268
|
+
this.setTitleContent(element, titleNode.textContent);
|
|
317
269
|
titleGroup.appendChild(element);
|
|
318
270
|
}
|
|
319
|
-
const
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
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
|
-
}
|
|
271
|
+
const supplementsNodes = findChildrenByType(this.manuscriptNode, schema.nodes.supplement);
|
|
272
|
+
supplementsNodes.forEach(({ node }) => {
|
|
273
|
+
var _a, _b, _c, _d;
|
|
274
|
+
const supplementaryMaterial = this.document.createElement('supplementary-material');
|
|
275
|
+
supplementaryMaterial.setAttribute('id', normalizeID(node.attrs.id));
|
|
276
|
+
supplementaryMaterial.setAttributeNS(XLINK_NAMESPACE, 'href', (_a = node.attrs.href) !== null && _a !== void 0 ? _a : '');
|
|
277
|
+
supplementaryMaterial.setAttribute('mimetype', (_b = node.attrs.mimeType) !== null && _b !== void 0 ? _b : '');
|
|
278
|
+
supplementaryMaterial.setAttribute('mime-subtype', (_c = node.attrs.mimeSubType) !== null && _c !== void 0 ? _c : '');
|
|
279
|
+
const caption = this.document.createElement('caption');
|
|
280
|
+
const title = this.document.createElement('title');
|
|
281
|
+
title.textContent = (_d = node.attrs.title) !== null && _d !== void 0 ? _d : '';
|
|
282
|
+
caption.append(title);
|
|
283
|
+
supplementaryMaterial.append(caption);
|
|
284
|
+
articleMeta.append(supplementaryMaterial);
|
|
285
|
+
});
|
|
366
286
|
this.buildKeywords(articleMeta);
|
|
367
287
|
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));
|
|
288
|
+
const figureCount = findChildrenByType(this.manuscriptNode, schema.nodes.figure).length;
|
|
289
|
+
countingElements.push(this.buildCountingElement('fig-count', figureCount));
|
|
290
|
+
const equationCount = findChildrenByType(this.manuscriptNode, schema.nodes.equation_element).length;
|
|
291
|
+
countingElements.push(this.buildCountingElement('equation-count', equationCount));
|
|
292
|
+
const tableCount = findChildrenByType(this.manuscriptNode, schema.nodes.table).length;
|
|
293
|
+
countingElements.push(this.buildCountingElement('table-count', tableCount));
|
|
294
|
+
const referencesCount = findChildrenByType(this.manuscriptNode, schema.nodes.bibliography_item).length;
|
|
295
|
+
countingElements.push(this.buildCountingElement('ref-count', referencesCount));
|
|
296
|
+
const wordCount = this.manuscriptNode.textContent.split(/\s+/).length;
|
|
297
|
+
countingElements.push(this.buildCountingElement('word-count', wordCount));
|
|
383
298
|
countingElements = countingElements.filter((el) => el);
|
|
384
299
|
if (countingElements.length > 0) {
|
|
385
300
|
const counts = this.document.createElement('counts');
|
|
@@ -414,13 +329,13 @@ export class JATSExporter {
|
|
|
414
329
|
return wordCount;
|
|
415
330
|
}
|
|
416
331
|
};
|
|
417
|
-
this.buildBody = (
|
|
332
|
+
this.buildBody = () => {
|
|
418
333
|
const body = this.document.createElement('body');
|
|
419
|
-
|
|
334
|
+
this.manuscriptNode.forEach((cFragment) => {
|
|
420
335
|
const serializedNode = this.serializeNode(cFragment);
|
|
421
336
|
body.append(...serializedNode.childNodes);
|
|
422
337
|
});
|
|
423
|
-
this.fixBody(body
|
|
338
|
+
this.fixBody(body);
|
|
424
339
|
return body;
|
|
425
340
|
};
|
|
426
341
|
this.buildBack = (body) => {
|
|
@@ -446,11 +361,15 @@ export class JATSExporter {
|
|
|
446
361
|
refList = this.document.createElement('ref-list');
|
|
447
362
|
}
|
|
448
363
|
back.appendChild(refList);
|
|
364
|
+
const bibliographyItems = findChildrenByType(this.manuscriptNode, schema.nodes.bibliography_item).map((n) => n.node);
|
|
449
365
|
const [meta] = this.citationProvider.makeBibliography();
|
|
450
|
-
for (const id of meta.entry_ids) {
|
|
451
|
-
const bibliographyItem =
|
|
366
|
+
for (const [id] of meta.entry_ids) {
|
|
367
|
+
const bibliographyItem = bibliographyItems.find((n) => n.attrs.id === id);
|
|
368
|
+
if (!bibliographyItem) {
|
|
369
|
+
continue;
|
|
370
|
+
}
|
|
452
371
|
const ref = this.document.createElement('ref');
|
|
453
|
-
ref.setAttribute('id', normalizeID(id
|
|
372
|
+
ref.setAttribute('id', normalizeID(id));
|
|
454
373
|
const updateCitationPubType = (citationEl, pubType) => {
|
|
455
374
|
if (pubType) {
|
|
456
375
|
switch (pubType) {
|
|
@@ -467,21 +386,21 @@ export class JATSExporter {
|
|
|
467
386
|
citationEl.setAttribute('publication-type', 'journal');
|
|
468
387
|
}
|
|
469
388
|
};
|
|
470
|
-
if (bibliographyItem.literal) {
|
|
389
|
+
if (bibliographyItem.attrs.literal) {
|
|
471
390
|
const mixedCitation = this.document.createElement('mixed-citation');
|
|
472
|
-
updateCitationPubType(mixedCitation, bibliographyItem.type);
|
|
473
|
-
mixedCitation.textContent = bibliographyItem.literal;
|
|
391
|
+
updateCitationPubType(mixedCitation, bibliographyItem.attrs.type);
|
|
392
|
+
mixedCitation.textContent = bibliographyItem.attrs.literal;
|
|
474
393
|
ref.appendChild(mixedCitation);
|
|
475
394
|
refList.appendChild(ref);
|
|
476
395
|
}
|
|
477
396
|
else {
|
|
478
397
|
const citation = this.document.createElement('element-citation');
|
|
479
|
-
updateCitationPubType(citation, bibliographyItem.type);
|
|
480
|
-
if (bibliographyItem.author) {
|
|
398
|
+
updateCitationPubType(citation, bibliographyItem.attrs.type);
|
|
399
|
+
if (bibliographyItem.attrs.author) {
|
|
481
400
|
const personGroupNode = this.document.createElement('person-group');
|
|
482
401
|
personGroupNode.setAttribute('person-group-type', 'author');
|
|
483
402
|
citation.appendChild(personGroupNode);
|
|
484
|
-
bibliographyItem.author.forEach((author) => {
|
|
403
|
+
bibliographyItem.attrs.author.forEach((author) => {
|
|
485
404
|
const name = this.document.createElement('string-name');
|
|
486
405
|
if (author.family) {
|
|
487
406
|
const node = this.document.createElement('surname');
|
|
@@ -503,8 +422,8 @@ export class JATSExporter {
|
|
|
503
422
|
}
|
|
504
423
|
});
|
|
505
424
|
}
|
|
506
|
-
if (bibliographyItem.issued) {
|
|
507
|
-
const dateParts = bibliographyItem.issued['date-parts'];
|
|
425
|
+
if (bibliographyItem.attrs.issued) {
|
|
426
|
+
const dateParts = bibliographyItem.attrs.issued['date-parts'];
|
|
508
427
|
if (dateParts && dateParts.length) {
|
|
509
428
|
const [[year, month, day]] = dateParts;
|
|
510
429
|
if (year) {
|
|
@@ -524,33 +443,33 @@ export class JATSExporter {
|
|
|
524
443
|
}
|
|
525
444
|
}
|
|
526
445
|
}
|
|
527
|
-
if (bibliographyItem.title) {
|
|
446
|
+
if (bibliographyItem.attrs.title) {
|
|
528
447
|
const node = this.document.createElement('article-title');
|
|
529
|
-
this.setTitleContent(node, bibliographyItem.title);
|
|
448
|
+
this.setTitleContent(node, bibliographyItem.attrs.title);
|
|
530
449
|
citation.appendChild(node);
|
|
531
450
|
}
|
|
532
|
-
if (bibliographyItem
|
|
451
|
+
if (bibliographyItem.attrs.containerTitle) {
|
|
533
452
|
const node = this.document.createElement('source');
|
|
534
|
-
node
|
|
453
|
+
this.setTitleContent(node, bibliographyItem.attrs.containerTitle);
|
|
535
454
|
citation.appendChild(node);
|
|
536
455
|
}
|
|
537
|
-
if (bibliographyItem.volume) {
|
|
456
|
+
if (bibliographyItem.attrs.volume) {
|
|
538
457
|
const node = this.document.createElement('volume');
|
|
539
|
-
node.textContent = String(bibliographyItem.volume);
|
|
458
|
+
node.textContent = String(bibliographyItem.attrs.volume);
|
|
540
459
|
citation.appendChild(node);
|
|
541
460
|
}
|
|
542
|
-
if (bibliographyItem.issue) {
|
|
461
|
+
if (bibliographyItem.attrs.issue) {
|
|
543
462
|
const node = this.document.createElement('issue');
|
|
544
|
-
node.textContent = String(bibliographyItem.issue);
|
|
463
|
+
node.textContent = String(bibliographyItem.attrs.issue);
|
|
545
464
|
citation.appendChild(node);
|
|
546
465
|
}
|
|
547
|
-
if (bibliographyItem.supplement) {
|
|
466
|
+
if (bibliographyItem.attrs.supplement) {
|
|
548
467
|
const node = this.document.createElement('supplement');
|
|
549
|
-
node.textContent = bibliographyItem.supplement;
|
|
468
|
+
node.textContent = bibliographyItem.attrs.supplement;
|
|
550
469
|
citation.appendChild(node);
|
|
551
470
|
}
|
|
552
|
-
if (bibliographyItem.page) {
|
|
553
|
-
const pageString = String(bibliographyItem.page);
|
|
471
|
+
if (bibliographyItem.attrs.page) {
|
|
472
|
+
const pageString = String(bibliographyItem.attrs.page);
|
|
554
473
|
if (/^\d+$/.test(pageString)) {
|
|
555
474
|
const node = this.document.createElement('fpage');
|
|
556
475
|
node.textContent = pageString;
|
|
@@ -571,10 +490,10 @@ export class JATSExporter {
|
|
|
571
490
|
citation.appendChild(node);
|
|
572
491
|
}
|
|
573
492
|
}
|
|
574
|
-
if (bibliographyItem.
|
|
493
|
+
if (bibliographyItem.attrs.doi) {
|
|
575
494
|
const node = this.document.createElement('pub-id');
|
|
576
495
|
node.setAttribute('pub-id-type', 'doi');
|
|
577
|
-
node.textContent = String(bibliographyItem.
|
|
496
|
+
node.textContent = String(bibliographyItem.attrs.doi);
|
|
578
497
|
citation.appendChild(node);
|
|
579
498
|
}
|
|
580
499
|
ref.appendChild(citation);
|
|
@@ -584,10 +503,19 @@ export class JATSExporter {
|
|
|
584
503
|
return back;
|
|
585
504
|
};
|
|
586
505
|
this.createSerializer = () => {
|
|
587
|
-
const getModel = (id) => id ? this.modelMap.get(id) : undefined;
|
|
588
506
|
const nodes = {
|
|
589
|
-
|
|
590
|
-
|
|
507
|
+
awards: () => ['funding-group', 0],
|
|
508
|
+
award: (node) => {
|
|
509
|
+
const awardGroup = node;
|
|
510
|
+
const awardGroupElement = this.document.createElement('award-group');
|
|
511
|
+
awardGroupElement.setAttribute('id', normalizeID(awardGroup.attrs.id));
|
|
512
|
+
appendChildIfPresent(awardGroupElement, 'funding-source', awardGroup.attrs.source);
|
|
513
|
+
awardGroup.attrs.code
|
|
514
|
+
.split(';')
|
|
515
|
+
.forEach((code) => appendChildIfPresent(awardGroupElement, 'award-id', code));
|
|
516
|
+
appendChildIfPresent(awardGroupElement, 'principal-award-recipient', awardGroup.attrs.recipient);
|
|
517
|
+
return awardGroupElement;
|
|
518
|
+
},
|
|
591
519
|
box_element: (node) => createBoxElement(node),
|
|
592
520
|
author_notes: () => '',
|
|
593
521
|
corresp: () => '',
|
|
@@ -609,11 +537,7 @@ export class JATSExporter {
|
|
|
609
537
|
backmatter: () => ['backmatter', 0],
|
|
610
538
|
supplement: () => '',
|
|
611
539
|
supplements: () => '',
|
|
612
|
-
bibliography_section: (
|
|
613
|
-
'ref-list',
|
|
614
|
-
{ id: normalizeID(node.attrs.id) },
|
|
615
|
-
0,
|
|
616
|
-
],
|
|
540
|
+
bibliography_section: () => '',
|
|
617
541
|
blockquote_element: () => ['disp-quote', { 'content-type': 'quote' }, 0],
|
|
618
542
|
list: (node) => {
|
|
619
543
|
var _a;
|
|
@@ -649,24 +573,25 @@ export class JATSExporter {
|
|
|
649
573
|
return xref;
|
|
650
574
|
},
|
|
651
575
|
cross_reference: (node) => {
|
|
576
|
+
var _a;
|
|
652
577
|
const cross = node;
|
|
653
578
|
const rids = cross.attrs.rids;
|
|
654
579
|
if (!rids.length) {
|
|
655
580
|
return cross.attrs.label;
|
|
656
581
|
}
|
|
657
582
|
const text = cross.attrs.customLabel || cross.attrs.label;
|
|
658
|
-
const
|
|
659
|
-
if (!
|
|
583
|
+
const target = (_a = findChildrenByAttr(this.manuscriptNode, (attrs) => attrs.id === rids[0])[0]) === null || _a === void 0 ? void 0 : _a.node;
|
|
584
|
+
if (!target) {
|
|
660
585
|
warn('');
|
|
661
586
|
return text;
|
|
662
587
|
}
|
|
663
588
|
const xref = this.document.createElement('xref');
|
|
664
|
-
const type = chooseRefType(
|
|
589
|
+
const type = chooseRefType(target.type);
|
|
665
590
|
if (type) {
|
|
666
591
|
xref.setAttribute('ref-type', type);
|
|
667
592
|
}
|
|
668
593
|
else {
|
|
669
|
-
warn(`Unset ref-type for
|
|
594
|
+
warn(`Unset ref-type for schema type ${target.type.name}`);
|
|
670
595
|
}
|
|
671
596
|
xref.setAttribute('rid', normalizeID(rids.join(' ')));
|
|
672
597
|
xref.textContent = text;
|
|
@@ -738,7 +663,10 @@ export class JATSExporter {
|
|
|
738
663
|
hard_break: () => '',
|
|
739
664
|
highlight_marker: () => '',
|
|
740
665
|
inline_footnote: (node) => {
|
|
741
|
-
const rids = node.attrs.rids.filter(
|
|
666
|
+
const rids = node.attrs.rids.filter((rid) => {
|
|
667
|
+
var _a;
|
|
668
|
+
return (_a = findChildrenByAttr(this.manuscriptNode, (attrs) => attrs.id === rid)[0]) === null || _a === void 0 ? void 0 : _a.node;
|
|
669
|
+
});
|
|
742
670
|
if (rids.length == 0) {
|
|
743
671
|
return '';
|
|
744
672
|
}
|
|
@@ -857,14 +785,7 @@ export class JATSExporter {
|
|
|
857
785
|
italic: () => ['italic'],
|
|
858
786
|
smallcaps: () => ['sc'],
|
|
859
787
|
strikethrough: () => ['strike'],
|
|
860
|
-
styled: (
|
|
861
|
-
const inlineStyle = getModel(mark.attrs.rid);
|
|
862
|
-
const attrs = {};
|
|
863
|
-
if (inlineStyle && inlineStyle.title) {
|
|
864
|
-
attrs.style = normalizeStyleName(inlineStyle.title);
|
|
865
|
-
}
|
|
866
|
-
return ['styled-content', attrs];
|
|
867
|
-
},
|
|
788
|
+
styled: () => ['styled-content'],
|
|
868
789
|
superscript: () => ['sup'],
|
|
869
790
|
subscript: () => ['sub'],
|
|
870
791
|
underline: () => ['underline'],
|
|
@@ -872,6 +793,14 @@ export class JATSExporter {
|
|
|
872
793
|
tracked_delete: () => ['del'],
|
|
873
794
|
};
|
|
874
795
|
this.serializer = new DOMSerializer(nodes, marks);
|
|
796
|
+
const appendChildIfPresent = (parent, tagName, textContent) => {
|
|
797
|
+
if (!textContent) {
|
|
798
|
+
return;
|
|
799
|
+
}
|
|
800
|
+
const element = this.document.createElement(tagName);
|
|
801
|
+
element.textContent = textContent;
|
|
802
|
+
parent.appendChild(element);
|
|
803
|
+
};
|
|
875
804
|
const processChildNodes = (element, node, contentNodeType) => {
|
|
876
805
|
node.forEach((childNode) => {
|
|
877
806
|
if (childNode.type === contentNodeType) {
|
|
@@ -915,14 +844,16 @@ export class JATSExporter {
|
|
|
915
844
|
}
|
|
916
845
|
};
|
|
917
846
|
const appendChildNodeOfType = (element, node, type) => {
|
|
918
|
-
|
|
847
|
+
var _a;
|
|
848
|
+
const childNode = (_a = findChildrenByType(node, type)[0]) === null || _a === void 0 ? void 0 : _a.node;
|
|
919
849
|
if (childNode) {
|
|
920
850
|
element.appendChild(this.serializeNode(childNode));
|
|
921
851
|
}
|
|
922
852
|
};
|
|
923
853
|
const appendTable = (element, node) => {
|
|
924
|
-
|
|
925
|
-
const
|
|
854
|
+
var _a, _b;
|
|
855
|
+
const tableNode = (_a = findChildrenByType(node, node.type.schema.nodes.table)[0]) === null || _a === void 0 ? void 0 : _a.node;
|
|
856
|
+
const colGroupNode = (_b = findChildrenByType(node, node.type.schema.nodes.table_colgroup)[0]) === null || _b === void 0 ? void 0 : _b.node;
|
|
926
857
|
if (!tableNode) {
|
|
927
858
|
return;
|
|
928
859
|
}
|
|
@@ -975,7 +906,8 @@ export class JATSExporter {
|
|
|
975
906
|
return element;
|
|
976
907
|
};
|
|
977
908
|
const processExecutableNode = (node, element) => {
|
|
978
|
-
|
|
909
|
+
var _a;
|
|
910
|
+
const listingNode = (_a = findChildrenByType(node, node.type.schema.nodes.listing)[0]) === null || _a === void 0 ? void 0 : _a.node;
|
|
979
911
|
if (listingNode) {
|
|
980
912
|
const { contents, languageKey } = listingNode.attrs;
|
|
981
913
|
if (contents && languageKey) {
|
|
@@ -987,47 +919,29 @@ export class JATSExporter {
|
|
|
987
919
|
code.setAttribute('language', languageKey);
|
|
988
920
|
code.textContent = contents;
|
|
989
921
|
listing.appendChild(code);
|
|
990
|
-
const caption = this.document.createElement('caption');
|
|
991
|
-
listing.appendChild(caption);
|
|
992
|
-
const attachments = [];
|
|
993
|
-
for (const attachment of attachments) {
|
|
994
|
-
const p = this.document.createElement('p');
|
|
995
|
-
caption.appendChild(p);
|
|
996
|
-
const filename = generateAttachmentFilename(`${listingNode.attrs.id}:${attachment.id}`, attachment.type);
|
|
997
|
-
const supp = this.document.createElement('supplementary-material');
|
|
998
|
-
supp.setAttributeNS(XLINK_NAMESPACE, 'xlink:href', `suppl/${filename}`);
|
|
999
|
-
const [mimeType, mimeSubType] = attachment.type.split('/');
|
|
1000
|
-
if (mimeType) {
|
|
1001
|
-
supp.setAttribute('mimetype', mimeType);
|
|
1002
|
-
if (mimeSubType) {
|
|
1003
|
-
supp.setAttribute('mime-subtype', mimeSubType);
|
|
1004
|
-
}
|
|
1005
|
-
}
|
|
1006
|
-
p.appendChild(supp);
|
|
1007
|
-
}
|
|
1008
922
|
}
|
|
1009
923
|
}
|
|
1010
924
|
};
|
|
1011
925
|
};
|
|
1012
|
-
this.serializeFragment = (fragment) => this.serializer.serializeFragment(fragment, {
|
|
1013
|
-
document: this.document,
|
|
1014
|
-
});
|
|
1015
926
|
this.serializeNode = (node) => this.serializer.serializeNode(node, {
|
|
1016
927
|
document: this.document,
|
|
1017
928
|
});
|
|
1018
929
|
this.validateContributor = (contributor) => {
|
|
1019
|
-
if (!contributor.bibliographicName) {
|
|
1020
|
-
throw new Error(`${contributor.
|
|
930
|
+
if (!contributor.attrs.bibliographicName) {
|
|
931
|
+
throw new Error(`${contributor.attrs.id} has no bibliographicName`);
|
|
1021
932
|
}
|
|
1022
|
-
const { family, given } = contributor.bibliographicName;
|
|
933
|
+
const { family, given } = contributor.attrs.bibliographicName;
|
|
1023
934
|
if (!family && !given) {
|
|
1024
|
-
throw new Error(`${contributor.
|
|
935
|
+
throw new Error(`${contributor.attrs.id} has neither family nor given name`);
|
|
1025
936
|
}
|
|
1026
937
|
};
|
|
1027
938
|
this.buildContributors = (articleMeta) => {
|
|
1028
|
-
const
|
|
1029
|
-
const
|
|
1030
|
-
.filter((
|
|
939
|
+
const contributorNodes = findChildrenByType(this.manuscriptNode, schema.nodes.contributor).map((result) => result.node);
|
|
940
|
+
const authorContributorNodes = contributorNodes
|
|
941
|
+
.filter((n) => n.attrs.role === 'author')
|
|
942
|
+
.sort(sortContributors);
|
|
943
|
+
const otherContributorsNodes = contributorNodes
|
|
944
|
+
.filter((n) => n.attrs.role !== 'author')
|
|
1031
945
|
.sort(sortContributors);
|
|
1032
946
|
const affiliationLabels = new Map();
|
|
1033
947
|
const creatAffiliationLabel = (rid) => {
|
|
@@ -1045,11 +959,11 @@ export class JATSExporter {
|
|
|
1045
959
|
sup.textContent = String(content);
|
|
1046
960
|
return sup;
|
|
1047
961
|
};
|
|
1048
|
-
if (
|
|
962
|
+
if (authorContributorNodes.length) {
|
|
1049
963
|
const contribGroup = this.document.createElement('contrib-group');
|
|
1050
964
|
contribGroup.setAttribute('content-type', 'authors');
|
|
1051
965
|
articleMeta.appendChild(contribGroup);
|
|
1052
|
-
|
|
966
|
+
authorContributorNodes.forEach((contributor) => {
|
|
1053
967
|
try {
|
|
1054
968
|
this.validateContributor(contributor);
|
|
1055
969
|
}
|
|
@@ -1059,39 +973,25 @@ export class JATSExporter {
|
|
|
1059
973
|
}
|
|
1060
974
|
const contrib = this.document.createElement('contrib');
|
|
1061
975
|
contrib.setAttribute('contrib-type', 'author');
|
|
1062
|
-
contrib.setAttribute('id', normalizeID(contributor.
|
|
1063
|
-
if (contributor.isCorresponding) {
|
|
976
|
+
contrib.setAttribute('id', normalizeID(contributor.attrs.id));
|
|
977
|
+
if (contributor.attrs.isCorresponding) {
|
|
1064
978
|
contrib.setAttribute('corresp', 'yes');
|
|
1065
979
|
}
|
|
1066
|
-
if (contributor.ORCIDIdentifier) {
|
|
980
|
+
if (contributor.attrs.ORCIDIdentifier) {
|
|
1067
981
|
const identifier = this.document.createElement('contrib-id');
|
|
1068
982
|
identifier.setAttribute('contrib-id-type', 'orcid');
|
|
1069
|
-
identifier.textContent = contributor.ORCIDIdentifier;
|
|
983
|
+
identifier.textContent = contributor.attrs.ORCIDIdentifier;
|
|
1070
984
|
contrib.appendChild(identifier);
|
|
1071
985
|
}
|
|
1072
986
|
const name = this.buildContributorName(contributor);
|
|
1073
987
|
contrib.appendChild(name);
|
|
1074
|
-
if (contributor.email) {
|
|
988
|
+
if (contributor.attrs.email) {
|
|
1075
989
|
const email = this.document.createElement('email');
|
|
1076
|
-
email.textContent = contributor.email;
|
|
990
|
+
email.textContent = contributor.attrs.email;
|
|
1077
991
|
contrib.appendChild(email);
|
|
1078
992
|
}
|
|
1079
|
-
if (contributor.
|
|
1080
|
-
contributor.
|
|
1081
|
-
const contributorRole = this.modelMap.get(rid);
|
|
1082
|
-
if (contributorRole) {
|
|
1083
|
-
const role = this.document.createElement('role');
|
|
1084
|
-
const attributes = chooseRoleVocabAttributes(contributorRole);
|
|
1085
|
-
for (const [key, value] of Object.entries(attributes)) {
|
|
1086
|
-
role.setAttribute(key, value);
|
|
1087
|
-
}
|
|
1088
|
-
role.textContent = contributorRole.name;
|
|
1089
|
-
contrib.appendChild(role);
|
|
1090
|
-
}
|
|
1091
|
-
});
|
|
1092
|
-
}
|
|
1093
|
-
if (contributor.affiliations) {
|
|
1094
|
-
contributor.affiliations.forEach((rid) => {
|
|
993
|
+
if (contributor.attrs.affiliations) {
|
|
994
|
+
contributor.attrs.affiliations.forEach((rid) => {
|
|
1095
995
|
const xref = this.document.createElement('xref');
|
|
1096
996
|
xref.setAttribute('ref-type', 'aff');
|
|
1097
997
|
xref.setAttribute('rid', normalizeID(rid));
|
|
@@ -1099,8 +999,8 @@ export class JATSExporter {
|
|
|
1099
999
|
contrib.appendChild(xref);
|
|
1100
1000
|
});
|
|
1101
1001
|
}
|
|
1102
|
-
if (contributor.footnote) {
|
|
1103
|
-
contributor.footnote.map((note) => {
|
|
1002
|
+
if (contributor.attrs.footnote) {
|
|
1003
|
+
contributor.attrs.footnote.map((note) => {
|
|
1104
1004
|
const xref = this.document.createElement('xref');
|
|
1105
1005
|
xref.setAttribute('ref-type', 'fn');
|
|
1106
1006
|
xref.setAttribute('rid', normalizeID(note.noteID));
|
|
@@ -1108,8 +1008,8 @@ export class JATSExporter {
|
|
|
1108
1008
|
contrib.appendChild(xref);
|
|
1109
1009
|
});
|
|
1110
1010
|
}
|
|
1111
|
-
if (contributor.corresp) {
|
|
1112
|
-
contributor.corresp.map((corresp) => {
|
|
1011
|
+
if (contributor.attrs.corresp) {
|
|
1012
|
+
contributor.attrs.corresp.map((corresp) => {
|
|
1113
1013
|
const xref = this.document.createElement('xref');
|
|
1114
1014
|
xref.setAttribute('ref-type', 'corresp');
|
|
1115
1015
|
xref.setAttribute('rid', normalizeID(corresp.correspID));
|
|
@@ -1119,13 +1019,10 @@ export class JATSExporter {
|
|
|
1119
1019
|
}
|
|
1120
1020
|
contribGroup.appendChild(contrib);
|
|
1121
1021
|
});
|
|
1122
|
-
|
|
1123
|
-
.filter((contributor) => contributor.role !== 'author')
|
|
1124
|
-
.sort(sortContributors);
|
|
1125
|
-
if (otherContributors.length) {
|
|
1022
|
+
if (otherContributorsNodes.length) {
|
|
1126
1023
|
const contribGroup = this.document.createElement('contrib-group');
|
|
1127
1024
|
articleMeta.appendChild(contribGroup);
|
|
1128
|
-
|
|
1025
|
+
otherContributorsNodes.forEach((contributor) => {
|
|
1129
1026
|
try {
|
|
1130
1027
|
this.validateContributor(contributor);
|
|
1131
1028
|
}
|
|
@@ -1134,30 +1031,16 @@ export class JATSExporter {
|
|
|
1134
1031
|
return;
|
|
1135
1032
|
}
|
|
1136
1033
|
const contrib = this.document.createElement('contrib');
|
|
1137
|
-
contrib.setAttribute('id', normalizeID(contributor.
|
|
1034
|
+
contrib.setAttribute('id', normalizeID(contributor.attrs.id));
|
|
1138
1035
|
const name = this.buildContributorName(contributor);
|
|
1139
1036
|
contrib.appendChild(name);
|
|
1140
|
-
if (contributor.email) {
|
|
1037
|
+
if (contributor.attrs.email) {
|
|
1141
1038
|
const email = this.document.createElement('email');
|
|
1142
|
-
email.textContent = contributor.email;
|
|
1039
|
+
email.textContent = contributor.attrs.email;
|
|
1143
1040
|
contrib.appendChild(email);
|
|
1144
1041
|
}
|
|
1145
|
-
if (contributor.
|
|
1146
|
-
contributor.
|
|
1147
|
-
const contributorRole = this.modelMap.get(rid);
|
|
1148
|
-
if (contributorRole) {
|
|
1149
|
-
const role = this.document.createElement('role');
|
|
1150
|
-
const attributes = chooseRoleVocabAttributes(contributorRole);
|
|
1151
|
-
for (const [key, value] of Object.entries(attributes)) {
|
|
1152
|
-
role.setAttribute(key, value);
|
|
1153
|
-
}
|
|
1154
|
-
role.textContent = contributorRole.name;
|
|
1155
|
-
contrib.appendChild(role);
|
|
1156
|
-
}
|
|
1157
|
-
});
|
|
1158
|
-
}
|
|
1159
|
-
if (contributor.affiliations) {
|
|
1160
|
-
contributor.affiliations.forEach((rid) => {
|
|
1042
|
+
if (contributor.attrs.affiliations) {
|
|
1043
|
+
contributor.attrs.affiliations.forEach((rid) => {
|
|
1161
1044
|
const xref = this.document.createElement('xref');
|
|
1162
1045
|
xref.setAttribute('ref-type', 'aff');
|
|
1163
1046
|
xref.setAttribute('rid', normalizeID(rid));
|
|
@@ -1165,8 +1048,8 @@ export class JATSExporter {
|
|
|
1165
1048
|
contrib.appendChild(xref);
|
|
1166
1049
|
});
|
|
1167
1050
|
}
|
|
1168
|
-
if (contributor.footnote) {
|
|
1169
|
-
contributor.footnote.map((note) => {
|
|
1051
|
+
if (contributor.attrs.footnote) {
|
|
1052
|
+
contributor.attrs.footnote.map((note) => {
|
|
1170
1053
|
const xref = this.document.createElement('xref');
|
|
1171
1054
|
xref.setAttribute('ref-type', 'fn');
|
|
1172
1055
|
xref.setAttribute('rid', normalizeID(note.noteID));
|
|
@@ -1178,64 +1061,68 @@ export class JATSExporter {
|
|
|
1178
1061
|
});
|
|
1179
1062
|
}
|
|
1180
1063
|
const affiliationRIDs = [];
|
|
1181
|
-
const sortedContributors = [
|
|
1064
|
+
const sortedContributors = [
|
|
1065
|
+
...authorContributorNodes,
|
|
1066
|
+
...otherContributorsNodes,
|
|
1067
|
+
];
|
|
1182
1068
|
for (const contributor of sortedContributors) {
|
|
1183
|
-
if (contributor.affiliations) {
|
|
1184
|
-
affiliationRIDs.push(...contributor.affiliations);
|
|
1069
|
+
if (contributor.attrs.affiliations) {
|
|
1070
|
+
affiliationRIDs.push(...contributor.attrs.affiliations);
|
|
1185
1071
|
}
|
|
1186
1072
|
}
|
|
1187
|
-
const affiliations = this.
|
|
1073
|
+
const affiliations = findChildrenByType(this.manuscriptNode, schema.nodes.affiliation).map((result) => result.node);
|
|
1188
1074
|
if (affiliations) {
|
|
1189
|
-
const usedAffiliations = affiliations.filter((affiliation) => affiliationRIDs.includes(affiliation.
|
|
1190
|
-
usedAffiliations.sort((a, b) => affiliationRIDs.indexOf(a.
|
|
1075
|
+
const usedAffiliations = affiliations.filter((affiliation) => affiliationRIDs.includes(affiliation.attrs.id));
|
|
1076
|
+
usedAffiliations.sort((a, b) => affiliationRIDs.indexOf(a.attrs.id) -
|
|
1077
|
+
affiliationRIDs.indexOf(b.attrs.id));
|
|
1191
1078
|
usedAffiliations.forEach((affiliation) => {
|
|
1192
1079
|
var _a, _b;
|
|
1193
1080
|
const aff = this.document.createElement('aff');
|
|
1194
|
-
aff.setAttribute('id', normalizeID(affiliation.
|
|
1081
|
+
aff.setAttribute('id', normalizeID(affiliation.attrs.id));
|
|
1195
1082
|
contribGroup.appendChild(aff);
|
|
1196
|
-
if (affiliation.department) {
|
|
1083
|
+
if (affiliation.attrs.department) {
|
|
1197
1084
|
const department = this.document.createElement('institution');
|
|
1198
1085
|
department.setAttribute('content-type', 'dept');
|
|
1199
|
-
department.textContent = affiliation.department;
|
|
1086
|
+
department.textContent = affiliation.attrs.department;
|
|
1200
1087
|
aff.appendChild(department);
|
|
1201
1088
|
}
|
|
1202
|
-
if (affiliation.institution) {
|
|
1089
|
+
if (affiliation.attrs.institution) {
|
|
1203
1090
|
const institution = this.document.createElement('institution');
|
|
1204
|
-
institution.textContent = affiliation.institution;
|
|
1091
|
+
institution.textContent = affiliation.attrs.institution;
|
|
1205
1092
|
aff.appendChild(institution);
|
|
1206
1093
|
}
|
|
1207
|
-
if (affiliation.addressLine1) {
|
|
1094
|
+
if (affiliation.attrs.addressLine1) {
|
|
1208
1095
|
const addressLine = this.document.createElement('addr-line');
|
|
1209
|
-
addressLine.textContent = affiliation.addressLine1;
|
|
1096
|
+
addressLine.textContent = affiliation.attrs.addressLine1;
|
|
1210
1097
|
aff.appendChild(addressLine);
|
|
1211
1098
|
}
|
|
1212
|
-
if (affiliation.addressLine2) {
|
|
1099
|
+
if (affiliation.attrs.addressLine2) {
|
|
1213
1100
|
const addressLine = this.document.createElement('addr-line');
|
|
1214
|
-
addressLine.textContent = affiliation.addressLine2;
|
|
1101
|
+
addressLine.textContent = affiliation.attrs.addressLine2;
|
|
1215
1102
|
aff.appendChild(addressLine);
|
|
1216
1103
|
}
|
|
1217
|
-
if (affiliation.addressLine3) {
|
|
1104
|
+
if (affiliation.attrs.addressLine3) {
|
|
1218
1105
|
const addressLine = this.document.createElement('addr-line');
|
|
1219
|
-
addressLine.textContent = affiliation.addressLine3;
|
|
1106
|
+
addressLine.textContent = affiliation.attrs.addressLine3;
|
|
1220
1107
|
aff.appendChild(addressLine);
|
|
1221
1108
|
}
|
|
1222
|
-
if (affiliation.city) {
|
|
1109
|
+
if (affiliation.attrs.city) {
|
|
1223
1110
|
const city = this.document.createElement('city');
|
|
1224
|
-
city.textContent = affiliation.city;
|
|
1111
|
+
city.textContent = affiliation.attrs.city;
|
|
1225
1112
|
aff.appendChild(city);
|
|
1226
1113
|
}
|
|
1227
|
-
if (affiliation.country) {
|
|
1114
|
+
if (affiliation.attrs.country) {
|
|
1228
1115
|
const country = this.document.createElement('country');
|
|
1229
|
-
country.textContent = affiliation.country;
|
|
1116
|
+
country.textContent = affiliation.attrs.country;
|
|
1230
1117
|
aff.appendChild(country);
|
|
1231
1118
|
}
|
|
1232
|
-
if (affiliation.email) {
|
|
1119
|
+
if (affiliation.attrs.email) {
|
|
1233
1120
|
const email = this.document.createElement('email');
|
|
1234
|
-
email.setAttributeNS(XLINK_NAMESPACE, 'href', (_a = affiliation.email.href) !== null && _a !== void 0 ? _a : '');
|
|
1235
|
-
email.textContent = (_b = affiliation.email.text) !== null && _b !== void 0 ? _b : '';
|
|
1121
|
+
email.setAttributeNS(XLINK_NAMESPACE, 'href', (_a = affiliation.attrs.email.href) !== null && _a !== void 0 ? _a : '');
|
|
1122
|
+
email.textContent = (_b = affiliation.attrs.email.text) !== null && _b !== void 0 ? _b : '';
|
|
1236
1123
|
aff.appendChild(email);
|
|
1237
1124
|
}
|
|
1238
|
-
const labelNumber = affiliationLabels.get(affiliation.
|
|
1125
|
+
const labelNumber = affiliationLabels.get(affiliation.attrs.id);
|
|
1239
1126
|
if (labelNumber) {
|
|
1240
1127
|
const label = this.document.createElement('label');
|
|
1241
1128
|
label.textContent = String(labelNumber);
|
|
@@ -1252,41 +1139,48 @@ export class JATSExporter {
|
|
|
1252
1139
|
this.createAuthorNotesElement = () => {
|
|
1253
1140
|
var _a;
|
|
1254
1141
|
const authorNotesEl = this.document.createElement('author-notes');
|
|
1255
|
-
const
|
|
1256
|
-
if (
|
|
1257
|
-
this.appendModelsToAuthorNotes(authorNotesEl,
|
|
1142
|
+
const authorNotesNode = (_a = findChildrenByType(this.manuscriptNode, schema.nodes.author_notes)[0]) === null || _a === void 0 ? void 0 : _a.node;
|
|
1143
|
+
if (authorNotesNode) {
|
|
1144
|
+
this.appendModelsToAuthorNotes(authorNotesEl, authorNotesNode);
|
|
1258
1145
|
}
|
|
1259
1146
|
return authorNotesEl;
|
|
1260
1147
|
};
|
|
1261
1148
|
this.appendCorrespondingToElement = (corresponding, element) => {
|
|
1262
1149
|
const correspondingEl = this.document.createElement('corresp');
|
|
1263
|
-
correspondingEl.setAttribute('id', normalizeID(corresponding.
|
|
1264
|
-
if (corresponding.label) {
|
|
1150
|
+
correspondingEl.setAttribute('id', normalizeID(corresponding.attrs.id));
|
|
1151
|
+
if (corresponding.attrs.label) {
|
|
1265
1152
|
const labelEl = this.document.createElement('label');
|
|
1266
|
-
labelEl.textContent = corresponding.label;
|
|
1153
|
+
labelEl.textContent = corresponding.attrs.label;
|
|
1267
1154
|
correspondingEl.appendChild(labelEl);
|
|
1268
1155
|
}
|
|
1269
|
-
correspondingEl.append(corresponding.
|
|
1156
|
+
correspondingEl.append(corresponding.textContent);
|
|
1270
1157
|
element.appendChild(correspondingEl);
|
|
1271
1158
|
};
|
|
1272
1159
|
this.appendParagraphToElement = (paragraph, element) => {
|
|
1273
|
-
const parsedDoc = new DOMParser().parseFromString(paragraph.
|
|
1160
|
+
const parsedDoc = new DOMParser().parseFromString(paragraph.textContent, 'text/html');
|
|
1274
1161
|
const parsedParagraph = parsedDoc.body.querySelector('p');
|
|
1275
1162
|
if (parsedParagraph) {
|
|
1276
1163
|
const paragraphEl = this.document.createElement('p');
|
|
1277
1164
|
paragraphEl.innerHTML = parsedParagraph.innerHTML;
|
|
1278
|
-
paragraphEl.setAttribute('id', normalizeID(paragraph.
|
|
1165
|
+
paragraphEl.setAttribute('id', normalizeID(paragraph.attrs.id));
|
|
1279
1166
|
element.appendChild(paragraphEl);
|
|
1280
1167
|
}
|
|
1281
1168
|
};
|
|
1282
1169
|
this.appendFootnoteToElement = (footnote, element) => {
|
|
1283
1170
|
const footnoteEl = this.document.createElement('fn');
|
|
1284
|
-
footnoteEl.setAttribute('id', normalizeID(footnote.
|
|
1285
|
-
|
|
1171
|
+
footnoteEl.setAttribute('id', normalizeID(footnote.attrs.id));
|
|
1172
|
+
if (!footnote.textContent.includes('<p>')) {
|
|
1173
|
+
const p = this.document.createElement('p');
|
|
1174
|
+
p.innerHTML = footnote.textContent;
|
|
1175
|
+
footnoteEl.appendChild(p);
|
|
1176
|
+
}
|
|
1177
|
+
else {
|
|
1178
|
+
footnoteEl.innerHTML = footnote.textContent;
|
|
1179
|
+
}
|
|
1286
1180
|
element.appendChild(footnoteEl);
|
|
1287
1181
|
};
|
|
1288
|
-
this.fixBody = (body
|
|
1289
|
-
|
|
1182
|
+
this.fixBody = (body) => {
|
|
1183
|
+
this.manuscriptNode.descendants((node) => {
|
|
1290
1184
|
if (node.attrs.id) {
|
|
1291
1185
|
if (node.attrs.titleSuppressed) {
|
|
1292
1186
|
const title = body.querySelector(`#${normalizeID(node.attrs.id)} > title`);
|
|
@@ -1414,6 +1308,23 @@ export class JATSExporter {
|
|
|
1414
1308
|
}
|
|
1415
1309
|
body.removeChild(container);
|
|
1416
1310
|
};
|
|
1311
|
+
this.moveAwards = (front, body) => {
|
|
1312
|
+
const awardGroups = body.querySelectorAll(':scope > award-group');
|
|
1313
|
+
if (!awardGroups.length) {
|
|
1314
|
+
return;
|
|
1315
|
+
}
|
|
1316
|
+
const fundingGroup = this.document.createElement('funding-group');
|
|
1317
|
+
awardGroups.forEach((award) => {
|
|
1318
|
+
fundingGroup.appendChild(award);
|
|
1319
|
+
});
|
|
1320
|
+
const articleMeta = front.querySelector(':scope > article-meta');
|
|
1321
|
+
if (articleMeta) {
|
|
1322
|
+
const insertBeforeElement = articleMeta.querySelector(':scope > support-group, :scope > conference, :scope > counts, :scope > custom-meta-group');
|
|
1323
|
+
insertBeforeElement
|
|
1324
|
+
? articleMeta.insertBefore(fundingGroup, insertBeforeElement)
|
|
1325
|
+
: articleMeta.appendChild(fundingGroup);
|
|
1326
|
+
}
|
|
1327
|
+
};
|
|
1417
1328
|
this.moveAbstracts = (front, body) => {
|
|
1418
1329
|
const container = body.querySelector(':scope > sec[sec-type="abstracts"]');
|
|
1419
1330
|
let abstractSections;
|
|
@@ -1547,36 +1458,36 @@ export class JATSExporter {
|
|
|
1547
1458
|
};
|
|
1548
1459
|
this.buildContributorName = (contributor) => {
|
|
1549
1460
|
const name = this.document.createElement('name');
|
|
1550
|
-
if (contributor.bibliographicName.family) {
|
|
1461
|
+
if (contributor.attrs.bibliographicName.family) {
|
|
1551
1462
|
const surname = this.document.createElement('surname');
|
|
1552
|
-
surname.textContent = contributor.bibliographicName.family;
|
|
1463
|
+
surname.textContent = contributor.attrs.bibliographicName.family;
|
|
1553
1464
|
name.appendChild(surname);
|
|
1554
1465
|
}
|
|
1555
|
-
if (contributor.bibliographicName.given) {
|
|
1466
|
+
if (contributor.attrs.bibliographicName.given) {
|
|
1556
1467
|
const givenNames = this.document.createElement('given-names');
|
|
1557
|
-
givenNames.textContent = contributor.bibliographicName.given;
|
|
1468
|
+
givenNames.textContent = contributor.attrs.bibliographicName.given;
|
|
1558
1469
|
name.appendChild(givenNames);
|
|
1559
1470
|
}
|
|
1560
1471
|
return name;
|
|
1561
1472
|
};
|
|
1562
1473
|
}
|
|
1563
|
-
generateCitations(
|
|
1474
|
+
generateCitations() {
|
|
1564
1475
|
const nodes = [];
|
|
1565
|
-
|
|
1476
|
+
this.manuscriptNode.descendants((node) => {
|
|
1566
1477
|
if (isCitationNode(node)) {
|
|
1567
1478
|
nodes.push(node);
|
|
1568
1479
|
}
|
|
1569
1480
|
});
|
|
1570
1481
|
return buildCitations(nodes);
|
|
1571
1482
|
}
|
|
1572
|
-
generateCitationTexts(
|
|
1483
|
+
generateCitationTexts(csl, manuscriptID) {
|
|
1573
1484
|
this.citationTexts = new Map();
|
|
1574
1485
|
this.citationProvider = new CitationProvider({
|
|
1575
|
-
getLibraryItem:
|
|
1486
|
+
getLibraryItem: this.getLibraryItem(manuscriptID),
|
|
1576
1487
|
locale: csl.locale,
|
|
1577
1488
|
citationStyle: csl.style,
|
|
1578
1489
|
});
|
|
1579
|
-
const citations = this.generateCitations(
|
|
1490
|
+
const citations = this.generateCitations();
|
|
1580
1491
|
this.citationProvider.rebuildState(citations).forEach(([id, , output]) => {
|
|
1581
1492
|
this.citationTexts.set(id, output);
|
|
1582
1493
|
});
|
|
@@ -1603,72 +1514,50 @@ export class JATSExporter {
|
|
|
1603
1514
|
return mathml;
|
|
1604
1515
|
}
|
|
1605
1516
|
}
|
|
1606
|
-
appendModelsToAuthorNotes(authorNotesEl,
|
|
1607
|
-
const
|
|
1608
|
-
const usedCorrespondings = this.getUsedCorrespondings(
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
}
|
|
1614
|
-
switch (model.objectType) {
|
|
1615
|
-
case ObjectTypes.ParagraphElement:
|
|
1616
|
-
this.appendParagraphToElement(model, authorNotesEl);
|
|
1517
|
+
appendModelsToAuthorNotes(authorNotesEl, authorNotesNode) {
|
|
1518
|
+
const contributorsNodes = findChildrenByType(this.manuscriptNode, schema.nodes.contributor).map((result) => result.node);
|
|
1519
|
+
const usedCorrespondings = this.getUsedCorrespondings(contributorsNodes);
|
|
1520
|
+
authorNotesNode.descendants((node) => {
|
|
1521
|
+
switch (node.type) {
|
|
1522
|
+
case schema.nodes.paragraph:
|
|
1523
|
+
this.appendParagraphToElement(node, authorNotesEl);
|
|
1617
1524
|
break;
|
|
1618
|
-
case
|
|
1619
|
-
this.appendFootnoteToElement(
|
|
1525
|
+
case schema.nodes.footnote:
|
|
1526
|
+
this.appendFootnoteToElement(node, authorNotesEl);
|
|
1620
1527
|
break;
|
|
1621
|
-
case
|
|
1622
|
-
if (usedCorrespondings.includes(
|
|
1623
|
-
this.appendCorrespondingToElement(
|
|
1528
|
+
case schema.nodes.corresp:
|
|
1529
|
+
if (usedCorrespondings.includes(node)) {
|
|
1530
|
+
this.appendCorrespondingToElement(node, authorNotesEl);
|
|
1624
1531
|
}
|
|
1625
1532
|
break;
|
|
1626
1533
|
}
|
|
1534
|
+
return false;
|
|
1627
1535
|
});
|
|
1628
1536
|
}
|
|
1629
1537
|
getUsedCorrespondings(contributors) {
|
|
1630
1538
|
return contributors
|
|
1631
|
-
.flatMap((c) => { var _a; return (_a = c.corresp) !== null && _a !== void 0 ? _a : []; })
|
|
1632
|
-
.map((corresp) =>
|
|
1539
|
+
.flatMap((c) => { var _a; return (_a = c.attrs.corresp) !== null && _a !== void 0 ? _a : []; })
|
|
1540
|
+
.map((corresp) => {
|
|
1541
|
+
var _a;
|
|
1542
|
+
return (_a = findChildrenByAttr(this.manuscriptNode, (attr) => attr.id === corresp.correspID)[0]) === null || _a === void 0 ? void 0 : _a.node;
|
|
1543
|
+
})
|
|
1633
1544
|
.filter((corresp) => !!corresp);
|
|
1634
1545
|
}
|
|
1635
1546
|
buildKeywords(articleMeta) {
|
|
1636
|
-
const
|
|
1637
|
-
|
|
1638
|
-
keywords.forEach((keyword) => {
|
|
1639
|
-
const containedGroup = keyword.containedGroup || '';
|
|
1640
|
-
const group = keywordGroups.get(containedGroup);
|
|
1641
|
-
if (group) {
|
|
1642
|
-
group.push(keyword);
|
|
1643
|
-
}
|
|
1644
|
-
else {
|
|
1645
|
-
keywordGroups.set(containedGroup, [keyword]);
|
|
1646
|
-
}
|
|
1647
|
-
});
|
|
1648
|
-
for (const [groupID, keywords] of keywordGroups) {
|
|
1649
|
-
const keywordGroup = (this.modelMap.get(groupID) || {});
|
|
1547
|
+
const keywordGroups = findChildrenByType(this.manuscriptNode, schema.nodes.keyword_group).map((result) => result.node);
|
|
1548
|
+
keywordGroups.forEach((group) => {
|
|
1650
1549
|
const kwdGroup = this.document.createElement('kwd-group');
|
|
1651
|
-
if (
|
|
1652
|
-
kwdGroup.setAttribute('kwd-group-type',
|
|
1653
|
-
}
|
|
1654
|
-
if (keywordGroup.label) {
|
|
1655
|
-
const label = this.document.createElement('label');
|
|
1656
|
-
label.textContent = keywordGroup.label;
|
|
1657
|
-
kwdGroup.appendChild(label);
|
|
1658
|
-
}
|
|
1659
|
-
if (keywordGroup.title) {
|
|
1660
|
-
const title = this.document.createElement('title');
|
|
1661
|
-
title.textContent = keywordGroup.title;
|
|
1662
|
-
kwdGroup.appendChild(title);
|
|
1550
|
+
if (group.attrs.type) {
|
|
1551
|
+
kwdGroup.setAttribute('kwd-group-type', group.attrs.type);
|
|
1663
1552
|
}
|
|
1664
1553
|
articleMeta.appendChild(kwdGroup);
|
|
1665
|
-
|
|
1554
|
+
group.content.forEach((keyword) => {
|
|
1666
1555
|
const kwd = this.document.createElement('kwd');
|
|
1667
|
-
kwd.textContent = keyword.
|
|
1556
|
+
kwd.textContent = keyword.textContent;
|
|
1668
1557
|
kwdGroup.appendChild(kwd);
|
|
1669
|
-
}
|
|
1558
|
+
});
|
|
1670
1559
|
articleMeta.appendChild(kwdGroup);
|
|
1671
|
-
}
|
|
1560
|
+
});
|
|
1672
1561
|
}
|
|
1673
1562
|
moveCoiStatementToAuthorNotes(back, front) {
|
|
1674
1563
|
const fnGroups = back.querySelectorAll('fn-group');
|