@manuscripts/transform 2.10.0-LEAN-3577 → 3.0.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/index.js +9 -7
- package/dist/cjs/jats/{jats-exporter.js → exporter/jats-exporter.js} +286 -416
- package/dist/cjs/jats/{jats-versions.js → exporter/jats-versions.js} +1 -3
- package/dist/cjs/{transformer → jats/exporter}/labels.js +7 -19
- package/dist/cjs/{transformer/filename.js → jats/importer/create-article-node.js} +12 -9
- package/dist/cjs/jats/importer/jats-body-transformations.js +22 -1
- package/dist/cjs/jats/importer/jats-comments.js +48 -110
- package/dist/cjs/jats/importer/{jats-body-dom-parser.js → jats-dom-parser.js} +364 -11
- package/dist/cjs/jats/importer/jats-journal-meta-parser.js +11 -1
- package/dist/cjs/jats/importer/jats-parser-utils.js +52 -4
- package/dist/cjs/jats/importer/jats-transformations.js +389 -0
- package/dist/cjs/jats/importer/parse-jats-article.js +43 -100
- 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/index.js +10 -0
- package/dist/cjs/schema/migration/migrate.js +3 -9
- package/dist/cjs/schema/migration/migration-script.js +1 -1
- package/dist/cjs/schema/migration/migration-scripts/1.2.5.js +2 -2
- package/dist/cjs/schema/migration/migration-scripts/2.3.22.js +28 -0
- package/dist/cjs/schema/migration/migration-scripts/index.js +3 -2
- package/dist/cjs/schema/nodes/author_notes.js +9 -2
- package/dist/cjs/schema/nodes/award.js +38 -0
- package/dist/cjs/{transformer/serializer.js → schema/nodes/awards.js} +20 -7
- package/dist/cjs/schema/nodes/backmatter.js +3 -2
- package/dist/cjs/schema/nodes/box_element.js +55 -0
- package/dist/cjs/schema/nodes/contributors.js +1 -1
- package/dist/cjs/schema/nodes/corresp.js +13 -2
- package/dist/cjs/schema/nodes/equation_element.js +0 -1
- package/dist/cjs/schema/nodes/figure_element.js +0 -1
- package/dist/cjs/schema/nodes/footnote.js +0 -1
- package/dist/cjs/schema/nodes/footnotes_section.js +1 -1
- package/dist/cjs/schema/nodes/highlight_marker.js +0 -4
- package/dist/cjs/schema/nodes/inline_equation.js +0 -1
- package/dist/cjs/schema/nodes/inline_footnote.js +1 -0
- package/dist/cjs/schema/nodes/keyword.js +0 -1
- package/dist/cjs/schema/nodes/listing.js +0 -1
- package/dist/cjs/schema/nodes/listing_element.js +0 -1
- package/dist/cjs/schema/nodes/manuscript.js +4 -1
- package/dist/cjs/schema/nodes/paragraph.js +0 -1
- package/dist/cjs/schema/nodes/section.js +0 -1
- package/dist/cjs/schema/nodes/table_element.js +1 -2
- package/dist/cjs/schema/nodes/title.js +1 -0
- package/dist/cjs/transformer/id.js +1 -5
- package/dist/cjs/transformer/index.js +0 -18
- package/dist/cjs/transformer/node-names.js +1 -0
- 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/es/index.js +6 -5
- package/dist/es/jats/{jats-exporter.js → exporter/jats-exporter.js} +281 -411
- package/dist/es/jats/{jats-versions.js → exporter/jats-versions.js} +0 -1
- package/dist/es/{transformer → jats/exporter}/labels.js +7 -19
- package/dist/{cjs/transformer/model-map.js → es/jats/importer/create-article-node.js} +10 -10
- package/dist/es/jats/importer/jats-body-transformations.js +22 -1
- package/dist/es/jats/importer/jats-comments.js +49 -107
- package/dist/es/jats/importer/{jats-body-dom-parser.js → jats-dom-parser.js} +364 -11
- package/dist/es/jats/importer/jats-journal-meta-parser.js +9 -0
- package/dist/es/jats/importer/jats-parser-utils.js +54 -6
- package/dist/es/jats/importer/jats-transformations.js +370 -0
- package/dist/es/jats/importer/parse-jats-article.js +43 -98
- 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/index.js +10 -0
- package/dist/es/schema/migration/migrate.js +3 -9
- package/dist/es/schema/migration/migration-script.js +1 -1
- package/dist/es/schema/migration/migration-scripts/1.2.5.js +2 -2
- package/dist/es/schema/migration/migration-scripts/2.3.22.js +26 -0
- package/dist/es/schema/migration/migration-scripts/index.js +3 -2
- package/dist/es/schema/nodes/author_notes.js +9 -2
- package/dist/es/{transformer/__tests__/__helpers__/doc.js → schema/nodes/award.js} +19 -14
- package/dist/es/{transformer/model-map.js → schema/nodes/awards.js} +17 -7
- package/dist/es/schema/nodes/backmatter.js +3 -2
- package/dist/es/schema/nodes/box_element.js +52 -0
- package/dist/es/schema/nodes/contributors.js +1 -1
- package/dist/es/schema/nodes/corresp.js +11 -1
- package/dist/es/schema/nodes/equation_element.js +0 -1
- package/dist/es/schema/nodes/figure_element.js +0 -1
- package/dist/es/schema/nodes/footnote.js +0 -1
- package/dist/es/schema/nodes/footnotes_section.js +1 -1
- package/dist/es/schema/nodes/highlight_marker.js +0 -4
- package/dist/es/schema/nodes/inline_equation.js +0 -1
- package/dist/es/schema/nodes/inline_footnote.js +1 -0
- package/dist/es/schema/nodes/keyword.js +0 -1
- package/dist/es/schema/nodes/listing.js +0 -1
- package/dist/es/schema/nodes/listing_element.js +0 -1
- package/dist/es/schema/nodes/manuscript.js +4 -1
- package/dist/es/schema/nodes/paragraph.js +0 -1
- package/dist/es/schema/nodes/section.js +0 -1
- package/dist/es/schema/nodes/table_element.js +1 -2
- package/dist/es/schema/nodes/title.js +1 -0
- package/dist/es/transformer/id.js +0 -3
- package/dist/es/transformer/index.js +0 -16
- package/dist/es/transformer/node-names.js +1 -0
- 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/types/index.d.ts +6 -5
- package/dist/types/jats/{jats-exporter.d.ts → exporter/jats-exporter.d.ts} +15 -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 -3
- package/dist/{es/transformer/footnote-category.js → types/jats/importer/create-article-node.d.ts} +3 -2
- package/dist/types/jats/importer/jats-body-transformations.d.ts +1 -0
- 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 +32 -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/index.d.ts +4 -0
- package/dist/types/schema/migration/migration-script.d.ts +1 -1
- package/dist/types/schema/migration/migration-scripts/1.2.5.d.ts +1 -1
- package/dist/types/schema/migration/migration-scripts/2.3.22.d.ts +8 -0
- package/dist/types/schema/migration/migration-scripts/index.d.ts +3 -2
- package/dist/types/{transformer/footnotes-order.d.ts → schema/nodes/award.d.ts} +14 -7
- package/dist/{cjs/transformer/footnote-category.js → types/schema/nodes/awards.d.ts} +12 -6
- package/dist/types/schema/nodes/bibliography_item.d.ts +3 -3
- package/dist/{es/transformer/filename.js → types/schema/nodes/box_element.d.ts} +11 -8
- package/dist/types/schema/nodes/contributor.d.ts +10 -0
- package/dist/types/schema/nodes/contributors.d.ts +8 -0
- package/dist/types/schema/nodes/corresp.d.ts +1 -0
- package/dist/types/schema/nodes/equation_element.d.ts +0 -2
- package/dist/types/schema/nodes/figure_element.d.ts +0 -2
- package/dist/types/schema/nodes/footnote.d.ts +0 -2
- package/dist/types/schema/nodes/highlight_marker.d.ts +0 -2
- package/dist/types/schema/nodes/inline_equation.d.ts +0 -2
- package/dist/types/schema/nodes/keyword.d.ts +0 -2
- package/dist/types/schema/nodes/keyword_group.d.ts +1 -0
- package/dist/types/schema/nodes/listing.d.ts +0 -2
- package/dist/types/schema/nodes/listing_element.d.ts +0 -2
- package/dist/types/schema/nodes/manuscript.d.ts +8 -4
- package/dist/types/schema/nodes/paragraph.d.ts +0 -2
- package/dist/types/schema/nodes/section.d.ts +0 -2
- package/dist/types/schema/nodes/table_element.d.ts +0 -2
- package/dist/types/schema/nodes/title.d.ts +1 -3
- package/dist/types/schema/types.d.ts +1 -1
- package/dist/types/transformer/id.d.ts +0 -3
- 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 +7 -8
- package/dist/cjs/__tests__/data/project-dump.json +0 -824
- 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 -878
- package/dist/cjs/transformer/document-object-types.js +0 -31
- package/dist/cjs/transformer/encode.js +0 -654
- 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 -401
- 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/timestamp.js +0 -20
- package/dist/cjs/transformer/update-identifiers.js +0 -93
- package/dist/es/__tests__/data/project-dump.json +0 -824
- 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/builders.js +0 -186
- package/dist/es/transformer/decode.js +0 -868
- package/dist/es/transformer/document-object-types.js +0 -28
- package/dist/es/transformer/encode.js +0 -644
- 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 -394
- package/dist/es/transformer/manuscript-dependencies.js +0 -17
- 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 -50
- 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/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
|
@@ -23,44 +23,17 @@ const json_schema_1 = require("@manuscripts/json-schema");
|
|
|
23
23
|
const library_1 = require("@manuscripts/library");
|
|
24
24
|
const debug_1 = __importDefault(require("debug"));
|
|
25
25
|
const prosemirror_model_1 = require("prosemirror-model");
|
|
26
|
+
const prosemirror_utils_1 = require("prosemirror-utils");
|
|
26
27
|
const w3c_xmlserializer_1 = __importDefault(require("w3c-xmlserializer"));
|
|
27
|
-
const html_1 = require("
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const schema_1 = require("../schema");
|
|
31
|
-
const filename_1 = require("../transformer/filename");
|
|
32
|
-
const labels_1 = require("../transformer/labels");
|
|
33
|
-
const node_types_1 = require("../transformer/node-types");
|
|
34
|
-
const object_types_1 = require("../transformer/object-types");
|
|
35
|
-
const project_bundle_1 = require("../transformer/project-bundle");
|
|
36
|
-
const section_category_1 = require("../transformer/section-category");
|
|
28
|
+
const html_1 = require("../../lib/html");
|
|
29
|
+
const schema_1 = require("../../schema");
|
|
30
|
+
const transformer_1 = require("../../transformer");
|
|
37
31
|
const jats_versions_1 = require("./jats-versions");
|
|
32
|
+
const labels_1 = require("./labels");
|
|
38
33
|
const warn = (0, debug_1.default)('manuscripts-transform');
|
|
39
34
|
const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
|
|
40
35
|
const normalizeID = (id) => id.replace(/:/g, '_');
|
|
41
36
|
const parser = prosemirror_model_1.DOMParser.fromSchema(schema_1.schema);
|
|
42
|
-
const findChildNodeOfType = (node, nodeType) => {
|
|
43
|
-
for (const child of (0, utils_1.iterateChildren)(node)) {
|
|
44
|
-
if (child.type === nodeType) {
|
|
45
|
-
return child;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
const isContributor = (0, object_types_1.hasObjectType)(json_schema_1.ObjectTypes.Contributor);
|
|
50
|
-
const CREDIT_VOCAB_IDENTIFIER = 'https://dictionary.casrai.org/Contributor_Roles';
|
|
51
|
-
const chooseRoleVocabAttributes = (role) => {
|
|
52
|
-
if (role.uri && role.uri.startsWith(CREDIT_VOCAB_IDENTIFIER)) {
|
|
53
|
-
return {
|
|
54
|
-
vocab: 'credit',
|
|
55
|
-
'vocab-identifier': CREDIT_VOCAB_IDENTIFIER,
|
|
56
|
-
'vocab-term': role.name,
|
|
57
|
-
'vocab-term-identifier': role.uri,
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
return {
|
|
61
|
-
vocab: 'uncontrolled',
|
|
62
|
-
};
|
|
63
|
-
};
|
|
64
37
|
const insertAbstractNode = (articleMeta, abstractNode) => {
|
|
65
38
|
const siblings = [
|
|
66
39
|
'kwd-group',
|
|
@@ -98,24 +71,24 @@ const createDefaultIdGenerator = () => {
|
|
|
98
71
|
return `${element.localName}-${value}`;
|
|
99
72
|
};
|
|
100
73
|
};
|
|
101
|
-
const chooseRefType = (
|
|
102
|
-
switch (
|
|
103
|
-
case
|
|
104
|
-
case
|
|
74
|
+
const chooseRefType = (type) => {
|
|
75
|
+
switch (type) {
|
|
76
|
+
case schema_1.schema.nodes.figure:
|
|
77
|
+
case schema_1.schema.nodes.figure_element:
|
|
105
78
|
return 'fig';
|
|
106
|
-
case
|
|
79
|
+
case schema_1.schema.nodes.footnote:
|
|
107
80
|
return 'fn';
|
|
108
|
-
case
|
|
109
|
-
case
|
|
81
|
+
case schema_1.schema.nodes.table:
|
|
82
|
+
case schema_1.schema.nodes.table_element:
|
|
110
83
|
return 'table';
|
|
111
|
-
case
|
|
84
|
+
case schema_1.schema.nodes.section:
|
|
112
85
|
return 'sec';
|
|
113
|
-
case
|
|
114
|
-
case
|
|
86
|
+
case schema_1.schema.nodes.equation:
|
|
87
|
+
case schema_1.schema.nodes.equation_element:
|
|
115
88
|
return 'disp-formula';
|
|
116
89
|
}
|
|
117
90
|
};
|
|
118
|
-
const sortContributors = (a, b) => Number(a.priority) - Number(b.priority);
|
|
91
|
+
const sortContributors = (a, b) => Number(a.attrs.priority) - Number(b.attrs.priority);
|
|
119
92
|
const buildCitations = (citations) => citations.map((citation) => ({
|
|
120
93
|
citationID: citation.attrs.id,
|
|
121
94
|
citationItems: citation.attrs.rids.map((rid) => ({
|
|
@@ -128,39 +101,57 @@ const buildCitations = (citations) => citations.map((citation) => ({
|
|
|
128
101
|
exports.buildCitations = buildCitations;
|
|
129
102
|
class JATSExporter {
|
|
130
103
|
constructor() {
|
|
131
|
-
this.
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
104
|
+
this.getLibraryItem = (manuscriptID) => {
|
|
105
|
+
return (id) => {
|
|
106
|
+
var _a;
|
|
107
|
+
const node = (_a = (0, prosemirror_utils_1.findChildrenByAttr)(this.manuscriptNode, (attrs) => attrs.id === id)[0]) === null || _a === void 0 ? void 0 : _a.node;
|
|
108
|
+
if (!node) {
|
|
109
|
+
return undefined;
|
|
110
|
+
}
|
|
111
|
+
return {
|
|
112
|
+
_id: node.attrs.id,
|
|
113
|
+
issued: node.attrs.issued,
|
|
114
|
+
DOI: node.attrs.doi,
|
|
115
|
+
manuscriptID,
|
|
116
|
+
objectType: json_schema_1.ObjectTypes.BibliographyItem,
|
|
117
|
+
author: node.attrs.author,
|
|
118
|
+
'container-title': node.attrs.containerTitle,
|
|
119
|
+
volume: node.attrs.volume,
|
|
120
|
+
issue: node.attrs.issue,
|
|
121
|
+
supplement: node.attrs.supplement,
|
|
122
|
+
page: node.attrs.page,
|
|
123
|
+
title: node.attrs.title,
|
|
124
|
+
literal: node.attrs.literal,
|
|
125
|
+
type: node.attrs.type,
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
this.serializeToJATS = async (manuscriptNode, options) => {
|
|
130
|
+
var _a;
|
|
131
|
+
this.manuscriptNode = manuscriptNode;
|
|
132
|
+
this.generateCitationTexts(options.csl, manuscriptNode.attrs.id);
|
|
136
133
|
this.createSerializer();
|
|
137
|
-
const versionIds = (0, jats_versions_1.selectVersionIds)(version);
|
|
134
|
+
const versionIds = (0, jats_versions_1.selectVersionIds)((_a = options.version) !== null && _a !== void 0 ? _a : '1.2');
|
|
138
135
|
this.document = document.implementation.createDocument(null, 'article', document.implementation.createDocumentType('article', versionIds.publicId, versionIds.systemId));
|
|
139
136
|
const article = this.document.documentElement;
|
|
140
137
|
article.setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:xlink', XLINK_NAMESPACE);
|
|
141
|
-
const front = this.buildFront(
|
|
138
|
+
const front = this.buildFront(options.journal);
|
|
142
139
|
article.appendChild(front);
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
this.fillEmptyFootnotes(article);
|
|
159
|
-
}
|
|
160
|
-
await this.rewriteIDs(idGenerator);
|
|
161
|
-
if (mediaPathGenerator) {
|
|
162
|
-
await this.rewriteMediaPaths(mediaPathGenerator);
|
|
163
|
-
}
|
|
140
|
+
article.setAttribute('article-type', manuscriptNode.attrs.articleType || 'other');
|
|
141
|
+
this.labelTargets = (0, labels_1.buildTargets)(manuscriptNode);
|
|
142
|
+
const body = this.buildBody();
|
|
143
|
+
article.appendChild(body);
|
|
144
|
+
const back = this.buildBack(body);
|
|
145
|
+
this.moveCoiStatementToAuthorNotes(back, front);
|
|
146
|
+
article.appendChild(back);
|
|
147
|
+
this.unwrapBody(body);
|
|
148
|
+
this.moveAbstracts(front, body);
|
|
149
|
+
this.moveFloatsGroup(body, article);
|
|
150
|
+
this.removeBackContainer(body);
|
|
151
|
+
this.updateFootnoteTypes(front, back);
|
|
152
|
+
this.fillEmptyTableFooters(article);
|
|
153
|
+
this.fillEmptyFootnotes(article);
|
|
154
|
+
await this.rewriteIDs();
|
|
164
155
|
return (0, w3c_xmlserializer_1.default)(this.document);
|
|
165
156
|
};
|
|
166
157
|
this.nodeFromJATS = (JATSFragment) => {
|
|
@@ -173,19 +164,6 @@ class JATSExporter {
|
|
|
173
164
|
template.innerHTML = JATSFragment;
|
|
174
165
|
return template.firstChild;
|
|
175
166
|
};
|
|
176
|
-
this.rewriteMediaPaths = async (generator) => {
|
|
177
|
-
const doc = this.document;
|
|
178
|
-
for (const fig of doc.querySelectorAll('fig')) {
|
|
179
|
-
for (const graphic of fig.querySelectorAll('graphic')) {
|
|
180
|
-
const newHref = await generator(graphic, fig.id);
|
|
181
|
-
graphic.setAttributeNS(XLINK_NAMESPACE, 'href', newHref);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
for (const suppl of doc.querySelectorAll('supplementary-material')) {
|
|
185
|
-
const newHref = await generator(suppl, suppl.id);
|
|
186
|
-
suppl.setAttributeNS(XLINK_NAMESPACE, 'href', newHref);
|
|
187
|
-
}
|
|
188
|
-
};
|
|
189
167
|
this.rewriteIDs = async (generator = createDefaultIdGenerator()) => {
|
|
190
168
|
const ids = new Map();
|
|
191
169
|
for (const element of this.document.querySelectorAll('[id]')) {
|
|
@@ -227,16 +205,14 @@ class JATSExporter {
|
|
|
227
205
|
}
|
|
228
206
|
}
|
|
229
207
|
};
|
|
230
|
-
this.buildFront = (
|
|
231
|
-
var _a
|
|
232
|
-
const
|
|
233
|
-
const titles = (0, project_bundle_1.findTitles)(this.modelMap);
|
|
208
|
+
this.buildFront = (journal) => {
|
|
209
|
+
var _a;
|
|
210
|
+
const titleNode = (_a = (0, prosemirror_utils_1.findChildrenByType)(this.manuscriptNode, schema_1.schema.nodes.title)[0]) === null || _a === void 0 ? void 0 : _a.node;
|
|
234
211
|
const front = this.document.createElement('front');
|
|
235
212
|
const journalMeta = this.document.createElement('journal-meta');
|
|
236
213
|
front.appendChild(journalMeta);
|
|
237
214
|
const articleMeta = this.document.createElement('article-meta');
|
|
238
215
|
front.appendChild(articleMeta);
|
|
239
|
-
const journal = [...this.modelMap.values()].find((model) => model.objectType === json_schema_1.ObjectTypes.Journal);
|
|
240
216
|
if (journal) {
|
|
241
217
|
if (journal.journalIdentifiers) {
|
|
242
218
|
for (const item of journal.journalIdentifiers) {
|
|
@@ -285,109 +261,47 @@ class JATSExporter {
|
|
|
285
261
|
journalMeta.appendChild(publisher);
|
|
286
262
|
}
|
|
287
263
|
}
|
|
288
|
-
if (
|
|
289
|
-
const articleID = this.document.createElement('article-id');
|
|
290
|
-
articleID.setAttribute('pub-id-type', 'publisher-id');
|
|
291
|
-
articleID.textContent = id;
|
|
292
|
-
articleMeta.appendChild(articleID);
|
|
293
|
-
}
|
|
294
|
-
if (doi || manuscript.DOI) {
|
|
264
|
+
if (this.manuscriptNode.attrs.doi) {
|
|
295
265
|
const articleID = this.document.createElement('article-id');
|
|
296
266
|
articleID.setAttribute('pub-id-type', 'doi');
|
|
297
|
-
articleID.textContent =
|
|
267
|
+
articleID.textContent = this.manuscriptNode.attrs.doi;
|
|
298
268
|
articleMeta.appendChild(articleID);
|
|
299
269
|
}
|
|
300
270
|
const titleGroup = this.document.createElement('title-group');
|
|
301
271
|
articleMeta.appendChild(titleGroup);
|
|
302
272
|
this.buildContributors(articleMeta);
|
|
303
|
-
if (
|
|
304
|
-
for (const [key, value] of Object.entries(links.self)) {
|
|
305
|
-
const link = this.document.createElement('self-uri');
|
|
306
|
-
link.setAttribute('content-type', key);
|
|
307
|
-
link.setAttributeNS(XLINK_NAMESPACE, 'href', value);
|
|
308
|
-
articleMeta.appendChild(link);
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
if (titles.title) {
|
|
273
|
+
if (titleNode) {
|
|
312
274
|
const element = this.document.createElement('article-title');
|
|
313
|
-
this.setTitleContent(element,
|
|
314
|
-
titleGroup.appendChild(element);
|
|
315
|
-
}
|
|
316
|
-
if (titles.subtitle) {
|
|
317
|
-
const element = this.document.createElement('subtitle');
|
|
318
|
-
this.setTitleContent(element, titles.subtitle);
|
|
319
|
-
titleGroup.appendChild(element);
|
|
320
|
-
}
|
|
321
|
-
if (titles.runningTitle) {
|
|
322
|
-
const element = this.document.createElement('alt-title');
|
|
323
|
-
element.setAttribute('alt-title-type', 'right-running');
|
|
324
|
-
this.setTitleContent(element, titles.runningTitle);
|
|
275
|
+
this.setTitleContent(element, titleNode.textContent);
|
|
325
276
|
titleGroup.appendChild(element);
|
|
326
277
|
}
|
|
327
|
-
const
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
articleMeta.append(supplementaryMaterial);
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
const history = articleMeta.querySelector('history') ||
|
|
346
|
-
this.document.createElement('history');
|
|
347
|
-
if (manuscript.acceptanceDate) {
|
|
348
|
-
const date = this.buildDateElement(manuscript.acceptanceDate, 'accepted');
|
|
349
|
-
history.appendChild(date);
|
|
350
|
-
}
|
|
351
|
-
if (manuscript.correctionDate) {
|
|
352
|
-
const date = this.buildDateElement(manuscript.correctionDate, 'corrected');
|
|
353
|
-
history.appendChild(date);
|
|
354
|
-
}
|
|
355
|
-
if (manuscript.retractionDate) {
|
|
356
|
-
const date = this.buildDateElement(manuscript.retractionDate, 'retracted');
|
|
357
|
-
history.appendChild(date);
|
|
358
|
-
}
|
|
359
|
-
if (manuscript.receiveDate) {
|
|
360
|
-
const date = this.buildDateElement(manuscript.receiveDate, 'received');
|
|
361
|
-
history.appendChild(date);
|
|
362
|
-
}
|
|
363
|
-
if (manuscript.revisionReceiveDate) {
|
|
364
|
-
const date = this.buildDateElement(manuscript.revisionReceiveDate, 'rev-recd');
|
|
365
|
-
history.appendChild(date);
|
|
366
|
-
}
|
|
367
|
-
if (manuscript.revisionRequestDate) {
|
|
368
|
-
const date = this.buildDateElement(manuscript.revisionRequestDate, 'rev-request');
|
|
369
|
-
history.appendChild(date);
|
|
370
|
-
}
|
|
371
|
-
if (history.childElementCount) {
|
|
372
|
-
articleMeta.appendChild(history);
|
|
373
|
-
}
|
|
278
|
+
const supplementsNodes = (0, prosemirror_utils_1.findChildrenByType)(this.manuscriptNode, schema_1.schema.nodes.supplement);
|
|
279
|
+
supplementsNodes.forEach(({ node }) => {
|
|
280
|
+
var _a, _b, _c, _d;
|
|
281
|
+
const supplementaryMaterial = this.document.createElement('supplementary-material');
|
|
282
|
+
supplementaryMaterial.setAttribute('id', normalizeID(node.attrs.id));
|
|
283
|
+
supplementaryMaterial.setAttributeNS(XLINK_NAMESPACE, 'href', (_a = node.attrs.href) !== null && _a !== void 0 ? _a : '');
|
|
284
|
+
supplementaryMaterial.setAttribute('mimetype', (_b = node.attrs.mimeType) !== null && _b !== void 0 ? _b : '');
|
|
285
|
+
supplementaryMaterial.setAttribute('mime-subtype', (_c = node.attrs.mimeSubType) !== null && _c !== void 0 ? _c : '');
|
|
286
|
+
const caption = this.document.createElement('caption');
|
|
287
|
+
const title = this.document.createElement('title');
|
|
288
|
+
title.textContent = (_d = node.attrs.title) !== null && _d !== void 0 ? _d : '';
|
|
289
|
+
caption.append(title);
|
|
290
|
+
supplementaryMaterial.append(caption);
|
|
291
|
+
articleMeta.append(supplementaryMaterial);
|
|
292
|
+
});
|
|
374
293
|
this.buildKeywords(articleMeta);
|
|
375
294
|
let countingElements = [];
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
countingElements.push(this.buildCountingElement('fig-count', manuscript.figureCount));
|
|
387
|
-
countingElements.push(this.buildCountingElement('table-count', manuscript.tableCount));
|
|
388
|
-
countingElements.push(this.buildCountingElement('equation-count', manuscript.equationCount));
|
|
389
|
-
countingElements.push(this.buildCountingElement('ref-count', manuscript.referencesCount));
|
|
390
|
-
countingElements.push(this.buildCountingElement('word-count', manuscript.wordCount));
|
|
295
|
+
const figureCount = (0, prosemirror_utils_1.findChildrenByType)(this.manuscriptNode, schema_1.schema.nodes.figure).length;
|
|
296
|
+
countingElements.push(this.buildCountingElement('fig-count', figureCount));
|
|
297
|
+
const tableCount = (0, prosemirror_utils_1.findChildrenByType)(this.manuscriptNode, schema_1.schema.nodes.table).length;
|
|
298
|
+
countingElements.push(this.buildCountingElement('table-count', tableCount));
|
|
299
|
+
const equationCount = (0, prosemirror_utils_1.findChildrenByType)(this.manuscriptNode, schema_1.schema.nodes.equation_element).length;
|
|
300
|
+
countingElements.push(this.buildCountingElement('equation-count', equationCount));
|
|
301
|
+
const referencesCount = (0, prosemirror_utils_1.findChildrenByType)(this.manuscriptNode, schema_1.schema.nodes.bibliography_item).length;
|
|
302
|
+
countingElements.push(this.buildCountingElement('ref-count', referencesCount));
|
|
303
|
+
const wordCount = this.manuscriptNode.textContent.split(/\s+/).length;
|
|
304
|
+
countingElements.push(this.buildCountingElement('word-count', wordCount));
|
|
391
305
|
countingElements = countingElements.filter((el) => el);
|
|
392
306
|
if (countingElements.length > 0) {
|
|
393
307
|
const counts = this.document.createElement('counts');
|
|
@@ -422,13 +336,13 @@ class JATSExporter {
|
|
|
422
336
|
return wordCount;
|
|
423
337
|
}
|
|
424
338
|
};
|
|
425
|
-
this.buildBody = (
|
|
339
|
+
this.buildBody = () => {
|
|
426
340
|
const body = this.document.createElement('body');
|
|
427
|
-
|
|
341
|
+
this.manuscriptNode.forEach((cFragment) => {
|
|
428
342
|
const serializedNode = this.serializeNode(cFragment);
|
|
429
343
|
body.append(...serializedNode.childNodes);
|
|
430
344
|
});
|
|
431
|
-
this.fixBody(body
|
|
345
|
+
this.fixBody(body);
|
|
432
346
|
return body;
|
|
433
347
|
};
|
|
434
348
|
this.buildBack = (body) => {
|
|
@@ -454,11 +368,15 @@ class JATSExporter {
|
|
|
454
368
|
refList = this.document.createElement('ref-list');
|
|
455
369
|
}
|
|
456
370
|
back.appendChild(refList);
|
|
371
|
+
const bibliographyItems = (0, prosemirror_utils_1.findChildrenByType)(this.manuscriptNode, schema_1.schema.nodes.bibliography_item).map((n) => n.node);
|
|
457
372
|
const [meta] = this.citationProvider.makeBibliography();
|
|
458
|
-
for (const id of meta.entry_ids) {
|
|
459
|
-
const bibliographyItem =
|
|
373
|
+
for (const [id] of meta.entry_ids) {
|
|
374
|
+
const bibliographyItem = bibliographyItems.find((n) => n.attrs.id === id);
|
|
375
|
+
if (!bibliographyItem) {
|
|
376
|
+
continue;
|
|
377
|
+
}
|
|
460
378
|
const ref = this.document.createElement('ref');
|
|
461
|
-
ref.setAttribute('id', normalizeID(id
|
|
379
|
+
ref.setAttribute('id', normalizeID(id));
|
|
462
380
|
const updateCitationPubType = (citationEl, pubType) => {
|
|
463
381
|
if (pubType) {
|
|
464
382
|
switch (pubType) {
|
|
@@ -475,21 +393,21 @@ class JATSExporter {
|
|
|
475
393
|
citationEl.setAttribute('publication-type', 'journal');
|
|
476
394
|
}
|
|
477
395
|
};
|
|
478
|
-
if (bibliographyItem.literal) {
|
|
396
|
+
if (bibliographyItem.attrs.literal) {
|
|
479
397
|
const mixedCitation = this.document.createElement('mixed-citation');
|
|
480
|
-
updateCitationPubType(mixedCitation, bibliographyItem.type);
|
|
481
|
-
mixedCitation.textContent = bibliographyItem.literal;
|
|
398
|
+
updateCitationPubType(mixedCitation, bibliographyItem.attrs.type);
|
|
399
|
+
mixedCitation.textContent = bibliographyItem.attrs.literal;
|
|
482
400
|
ref.appendChild(mixedCitation);
|
|
483
401
|
refList.appendChild(ref);
|
|
484
402
|
}
|
|
485
403
|
else {
|
|
486
404
|
const citation = this.document.createElement('element-citation');
|
|
487
|
-
updateCitationPubType(citation, bibliographyItem.type);
|
|
488
|
-
if (bibliographyItem.author) {
|
|
405
|
+
updateCitationPubType(citation, bibliographyItem.attrs.type);
|
|
406
|
+
if (bibliographyItem.attrs.author) {
|
|
489
407
|
const personGroupNode = this.document.createElement('person-group');
|
|
490
408
|
personGroupNode.setAttribute('person-group-type', 'author');
|
|
491
409
|
citation.appendChild(personGroupNode);
|
|
492
|
-
bibliographyItem.author.forEach((author) => {
|
|
410
|
+
bibliographyItem.attrs.author.forEach((author) => {
|
|
493
411
|
const name = this.document.createElement('string-name');
|
|
494
412
|
if (author.family) {
|
|
495
413
|
const node = this.document.createElement('surname');
|
|
@@ -511,8 +429,8 @@ class JATSExporter {
|
|
|
511
429
|
}
|
|
512
430
|
});
|
|
513
431
|
}
|
|
514
|
-
if (bibliographyItem.issued) {
|
|
515
|
-
const dateParts = bibliographyItem.issued['date-parts'];
|
|
432
|
+
if (bibliographyItem.attrs.issued) {
|
|
433
|
+
const dateParts = bibliographyItem.attrs.issued['date-parts'];
|
|
516
434
|
if (dateParts && dateParts.length) {
|
|
517
435
|
const [[year, month, day]] = dateParts;
|
|
518
436
|
if (year) {
|
|
@@ -532,33 +450,33 @@ class JATSExporter {
|
|
|
532
450
|
}
|
|
533
451
|
}
|
|
534
452
|
}
|
|
535
|
-
if (bibliographyItem.title) {
|
|
453
|
+
if (bibliographyItem.attrs.title) {
|
|
536
454
|
const node = this.document.createElement('article-title');
|
|
537
|
-
this.setTitleContent(node, bibliographyItem.title);
|
|
455
|
+
this.setTitleContent(node, bibliographyItem.attrs.title);
|
|
538
456
|
citation.appendChild(node);
|
|
539
457
|
}
|
|
540
|
-
if (bibliographyItem
|
|
458
|
+
if (bibliographyItem.attrs.containerTitle) {
|
|
541
459
|
const node = this.document.createElement('source');
|
|
542
|
-
node
|
|
460
|
+
this.setTitleContent(node, bibliographyItem.attrs.containerTitle);
|
|
543
461
|
citation.appendChild(node);
|
|
544
462
|
}
|
|
545
|
-
if (bibliographyItem.volume) {
|
|
463
|
+
if (bibliographyItem.attrs.volume) {
|
|
546
464
|
const node = this.document.createElement('volume');
|
|
547
|
-
node.textContent = String(bibliographyItem.volume);
|
|
465
|
+
node.textContent = String(bibliographyItem.attrs.volume);
|
|
548
466
|
citation.appendChild(node);
|
|
549
467
|
}
|
|
550
|
-
if (bibliographyItem.issue) {
|
|
468
|
+
if (bibliographyItem.attrs.issue) {
|
|
551
469
|
const node = this.document.createElement('issue');
|
|
552
|
-
node.textContent = String(bibliographyItem.issue);
|
|
470
|
+
node.textContent = String(bibliographyItem.attrs.issue);
|
|
553
471
|
citation.appendChild(node);
|
|
554
472
|
}
|
|
555
|
-
if (bibliographyItem.supplement) {
|
|
473
|
+
if (bibliographyItem.attrs.supplement) {
|
|
556
474
|
const node = this.document.createElement('supplement');
|
|
557
|
-
node.textContent = bibliographyItem.supplement;
|
|
475
|
+
node.textContent = bibliographyItem.attrs.supplement;
|
|
558
476
|
citation.appendChild(node);
|
|
559
477
|
}
|
|
560
|
-
if (bibliographyItem.page) {
|
|
561
|
-
const pageString = String(bibliographyItem.page);
|
|
478
|
+
if (bibliographyItem.attrs.page) {
|
|
479
|
+
const pageString = String(bibliographyItem.attrs.page);
|
|
562
480
|
if (/^\d+$/.test(pageString)) {
|
|
563
481
|
const node = this.document.createElement('fpage');
|
|
564
482
|
node.textContent = pageString;
|
|
@@ -579,10 +497,10 @@ class JATSExporter {
|
|
|
579
497
|
citation.appendChild(node);
|
|
580
498
|
}
|
|
581
499
|
}
|
|
582
|
-
if (bibliographyItem.
|
|
500
|
+
if (bibliographyItem.attrs.doi) {
|
|
583
501
|
const node = this.document.createElement('pub-id');
|
|
584
502
|
node.setAttribute('pub-id-type', 'doi');
|
|
585
|
-
node.textContent = String(bibliographyItem.
|
|
503
|
+
node.textContent = String(bibliographyItem.attrs.doi);
|
|
586
504
|
citation.appendChild(node);
|
|
587
505
|
}
|
|
588
506
|
ref.appendChild(citation);
|
|
@@ -592,9 +510,11 @@ class JATSExporter {
|
|
|
592
510
|
return back;
|
|
593
511
|
};
|
|
594
512
|
this.createSerializer = () => {
|
|
595
|
-
const getModel = (id) => id ? this.modelMap.get(id) : undefined;
|
|
596
513
|
const nodes = {
|
|
597
|
-
|
|
514
|
+
award: () => '',
|
|
515
|
+
awards: () => '',
|
|
516
|
+
box_element: (node) => createBoxElement(node),
|
|
517
|
+
author_notes: () => '',
|
|
598
518
|
corresp: () => '',
|
|
599
519
|
title: () => '',
|
|
600
520
|
affiliations: () => '',
|
|
@@ -614,11 +534,7 @@ class JATSExporter {
|
|
|
614
534
|
backmatter: () => ['backmatter', 0],
|
|
615
535
|
supplement: () => '',
|
|
616
536
|
supplements: () => '',
|
|
617
|
-
bibliography_section: (
|
|
618
|
-
'ref-list',
|
|
619
|
-
{ id: normalizeID(node.attrs.id) },
|
|
620
|
-
0,
|
|
621
|
-
],
|
|
537
|
+
bibliography_section: () => '',
|
|
622
538
|
blockquote_element: () => ['disp-quote', { 'content-type': 'quote' }, 0],
|
|
623
539
|
list: (node) => {
|
|
624
540
|
var _a;
|
|
@@ -654,24 +570,25 @@ class JATSExporter {
|
|
|
654
570
|
return xref;
|
|
655
571
|
},
|
|
656
572
|
cross_reference: (node) => {
|
|
573
|
+
var _a;
|
|
657
574
|
const cross = node;
|
|
658
575
|
const rids = cross.attrs.rids;
|
|
659
576
|
if (!rids.length) {
|
|
660
577
|
return cross.attrs.label;
|
|
661
578
|
}
|
|
662
579
|
const text = cross.attrs.customLabel || cross.attrs.label;
|
|
663
|
-
const
|
|
664
|
-
if (!
|
|
580
|
+
const target = (_a = (0, prosemirror_utils_1.findChildrenByAttr)(this.manuscriptNode, (attrs) => attrs.id === rids[0])[0]) === null || _a === void 0 ? void 0 : _a.node;
|
|
581
|
+
if (!target) {
|
|
665
582
|
warn('');
|
|
666
583
|
return text;
|
|
667
584
|
}
|
|
668
585
|
const xref = this.document.createElement('xref');
|
|
669
|
-
const type = chooseRefType(
|
|
586
|
+
const type = chooseRefType(target.type);
|
|
670
587
|
if (type) {
|
|
671
588
|
xref.setAttribute('ref-type', type);
|
|
672
589
|
}
|
|
673
590
|
else {
|
|
674
|
-
warn(`Unset ref-type for
|
|
591
|
+
warn(`Unset ref-type for schema type ${target.type.name}`);
|
|
675
592
|
}
|
|
676
593
|
xref.setAttribute('rid', normalizeID(rids.join(' ')));
|
|
677
594
|
xref.textContent = text;
|
|
@@ -743,7 +660,10 @@ class JATSExporter {
|
|
|
743
660
|
hard_break: () => '',
|
|
744
661
|
highlight_marker: () => '',
|
|
745
662
|
inline_footnote: (node) => {
|
|
746
|
-
const rids = node.attrs.rids.filter(
|
|
663
|
+
const rids = node.attrs.rids.filter((rid) => {
|
|
664
|
+
var _a;
|
|
665
|
+
return (_a = (0, prosemirror_utils_1.findChildrenByAttr)(this.manuscriptNode, (attrs) => attrs.id === rid)[0]) === null || _a === void 0 ? void 0 : _a.node;
|
|
666
|
+
});
|
|
747
667
|
if (rids.length == 0) {
|
|
748
668
|
return '';
|
|
749
669
|
}
|
|
@@ -825,7 +745,7 @@ class JATSExporter {
|
|
|
825
745
|
id: normalizeID(node.attrs.id),
|
|
826
746
|
};
|
|
827
747
|
if (node.attrs.category) {
|
|
828
|
-
attrs['sec-type'] = (0,
|
|
748
|
+
attrs['sec-type'] = (0, transformer_1.chooseSecType)(node.attrs.category);
|
|
829
749
|
}
|
|
830
750
|
return ['sec', attrs, 0];
|
|
831
751
|
},
|
|
@@ -862,14 +782,7 @@ class JATSExporter {
|
|
|
862
782
|
italic: () => ['italic'],
|
|
863
783
|
smallcaps: () => ['sc'],
|
|
864
784
|
strikethrough: () => ['strike'],
|
|
865
|
-
styled: (
|
|
866
|
-
const inlineStyle = getModel(mark.attrs.rid);
|
|
867
|
-
const attrs = {};
|
|
868
|
-
if (inlineStyle && inlineStyle.title) {
|
|
869
|
-
attrs.style = (0, styled_content_1.normalizeStyleName)(inlineStyle.title);
|
|
870
|
-
}
|
|
871
|
-
return ['styled-content', attrs];
|
|
872
|
-
},
|
|
785
|
+
styled: () => ['styled-content'],
|
|
873
786
|
superscript: () => ['sup'],
|
|
874
787
|
subscript: () => ['sub'],
|
|
875
788
|
underline: () => ['underline'],
|
|
@@ -920,14 +833,16 @@ class JATSExporter {
|
|
|
920
833
|
}
|
|
921
834
|
};
|
|
922
835
|
const appendChildNodeOfType = (element, node, type) => {
|
|
923
|
-
|
|
836
|
+
var _a;
|
|
837
|
+
const childNode = (_a = (0, prosemirror_utils_1.findChildrenByType)(node, type)[0]) === null || _a === void 0 ? void 0 : _a.node;
|
|
924
838
|
if (childNode) {
|
|
925
839
|
element.appendChild(this.serializeNode(childNode));
|
|
926
840
|
}
|
|
927
841
|
};
|
|
928
842
|
const appendTable = (element, node) => {
|
|
929
|
-
|
|
930
|
-
const
|
|
843
|
+
var _a, _b;
|
|
844
|
+
const tableNode = (_a = (0, prosemirror_utils_1.findChildrenByType)(node, node.type.schema.nodes.table)[0]) === null || _a === void 0 ? void 0 : _a.node;
|
|
845
|
+
const colGroupNode = (_b = (0, prosemirror_utils_1.findChildrenByType)(node, node.type.schema.nodes.table_colgroup)[0]) === null || _b === void 0 ? void 0 : _b.node;
|
|
931
846
|
if (!tableNode) {
|
|
932
847
|
return;
|
|
933
848
|
}
|
|
@@ -945,6 +860,13 @@ class JATSExporter {
|
|
|
945
860
|
}
|
|
946
861
|
element.appendChild(table);
|
|
947
862
|
};
|
|
863
|
+
const createBoxElement = (node) => {
|
|
864
|
+
const element = createElement(node, 'boxed-text');
|
|
865
|
+
appendLabels(element, node);
|
|
866
|
+
appendChildNodeOfType(element, node, node.type.schema.nodes.figcaption);
|
|
867
|
+
processChildNodes(element, node, node.type.schema.nodes.section);
|
|
868
|
+
return element;
|
|
869
|
+
};
|
|
948
870
|
const createFigureElement = (node, nodeName, contentNodeType, figType) => {
|
|
949
871
|
const element = createElement(node, nodeName);
|
|
950
872
|
if (figType) {
|
|
@@ -955,7 +877,7 @@ class JATSExporter {
|
|
|
955
877
|
appendChildNodeOfType(element, node, node.type.schema.nodes.footnotes_element);
|
|
956
878
|
processChildNodes(element, node, contentNodeType);
|
|
957
879
|
appendAttributions(element, node);
|
|
958
|
-
if ((0,
|
|
880
|
+
if ((0, transformer_1.isExecutableNodeType)(node.type)) {
|
|
959
881
|
processExecutableNode(node, element);
|
|
960
882
|
}
|
|
961
883
|
return element;
|
|
@@ -967,13 +889,14 @@ class JATSExporter {
|
|
|
967
889
|
appendChildNodeOfType(element, node, node.type.schema.nodes.figcaption);
|
|
968
890
|
appendTable(element, node);
|
|
969
891
|
appendChildNodeOfType(element, node, node.type.schema.nodes.table_element_footer);
|
|
970
|
-
if ((0,
|
|
892
|
+
if ((0, transformer_1.isExecutableNodeType)(node.type)) {
|
|
971
893
|
processExecutableNode(node, element);
|
|
972
894
|
}
|
|
973
895
|
return element;
|
|
974
896
|
};
|
|
975
897
|
const processExecutableNode = (node, element) => {
|
|
976
|
-
|
|
898
|
+
var _a;
|
|
899
|
+
const listingNode = (_a = (0, prosemirror_utils_1.findChildrenByType)(node, node.type.schema.nodes.listing)[0]) === null || _a === void 0 ? void 0 : _a.node;
|
|
977
900
|
if (listingNode) {
|
|
978
901
|
const { contents, languageKey } = listingNode.attrs;
|
|
979
902
|
if (contents && languageKey) {
|
|
@@ -985,47 +908,29 @@ class JATSExporter {
|
|
|
985
908
|
code.setAttribute('language', languageKey);
|
|
986
909
|
code.textContent = contents;
|
|
987
910
|
listing.appendChild(code);
|
|
988
|
-
const caption = this.document.createElement('caption');
|
|
989
|
-
listing.appendChild(caption);
|
|
990
|
-
const attachments = [];
|
|
991
|
-
for (const attachment of attachments) {
|
|
992
|
-
const p = this.document.createElement('p');
|
|
993
|
-
caption.appendChild(p);
|
|
994
|
-
const filename = (0, filename_1.generateAttachmentFilename)(`${listingNode.attrs.id}:${attachment.id}`, attachment.type);
|
|
995
|
-
const supp = this.document.createElement('supplementary-material');
|
|
996
|
-
supp.setAttributeNS(XLINK_NAMESPACE, 'xlink:href', `suppl/${filename}`);
|
|
997
|
-
const [mimeType, mimeSubType] = attachment.type.split('/');
|
|
998
|
-
if (mimeType) {
|
|
999
|
-
supp.setAttribute('mimetype', mimeType);
|
|
1000
|
-
if (mimeSubType) {
|
|
1001
|
-
supp.setAttribute('mime-subtype', mimeSubType);
|
|
1002
|
-
}
|
|
1003
|
-
}
|
|
1004
|
-
p.appendChild(supp);
|
|
1005
|
-
}
|
|
1006
911
|
}
|
|
1007
912
|
}
|
|
1008
913
|
};
|
|
1009
914
|
};
|
|
1010
|
-
this.serializeFragment = (fragment) => this.serializer.serializeFragment(fragment, {
|
|
1011
|
-
document: this.document,
|
|
1012
|
-
});
|
|
1013
915
|
this.serializeNode = (node) => this.serializer.serializeNode(node, {
|
|
1014
916
|
document: this.document,
|
|
1015
917
|
});
|
|
1016
918
|
this.validateContributor = (contributor) => {
|
|
1017
|
-
if (!contributor.bibliographicName) {
|
|
1018
|
-
throw new Error(`${contributor.
|
|
919
|
+
if (!contributor.attrs.bibliographicName) {
|
|
920
|
+
throw new Error(`${contributor.attrs.id} has no bibliographicName`);
|
|
1019
921
|
}
|
|
1020
|
-
const { family, given } = contributor.bibliographicName;
|
|
922
|
+
const { family, given } = contributor.attrs.bibliographicName;
|
|
1021
923
|
if (!family && !given) {
|
|
1022
|
-
throw new Error(`${contributor.
|
|
924
|
+
throw new Error(`${contributor.attrs.id} has neither family nor given name`);
|
|
1023
925
|
}
|
|
1024
926
|
};
|
|
1025
927
|
this.buildContributors = (articleMeta) => {
|
|
1026
|
-
const
|
|
1027
|
-
const
|
|
1028
|
-
.filter((
|
|
928
|
+
const contributorNodes = (0, prosemirror_utils_1.findChildrenByType)(this.manuscriptNode, schema_1.schema.nodes.contributor).map((result) => result.node);
|
|
929
|
+
const authorContributorNodes = contributorNodes
|
|
930
|
+
.filter((n) => n.attrs.role === 'author')
|
|
931
|
+
.sort(sortContributors);
|
|
932
|
+
const otherContributorsNodes = contributorNodes
|
|
933
|
+
.filter((n) => n.attrs.role !== 'author')
|
|
1029
934
|
.sort(sortContributors);
|
|
1030
935
|
const affiliationLabels = new Map();
|
|
1031
936
|
const creatAffiliationLabel = (rid) => {
|
|
@@ -1043,11 +948,11 @@ class JATSExporter {
|
|
|
1043
948
|
sup.textContent = String(content);
|
|
1044
949
|
return sup;
|
|
1045
950
|
};
|
|
1046
|
-
if (
|
|
951
|
+
if (authorContributorNodes.length) {
|
|
1047
952
|
const contribGroup = this.document.createElement('contrib-group');
|
|
1048
953
|
contribGroup.setAttribute('content-type', 'authors');
|
|
1049
954
|
articleMeta.appendChild(contribGroup);
|
|
1050
|
-
|
|
955
|
+
authorContributorNodes.forEach((contributor) => {
|
|
1051
956
|
try {
|
|
1052
957
|
this.validateContributor(contributor);
|
|
1053
958
|
}
|
|
@@ -1057,39 +962,25 @@ class JATSExporter {
|
|
|
1057
962
|
}
|
|
1058
963
|
const contrib = this.document.createElement('contrib');
|
|
1059
964
|
contrib.setAttribute('contrib-type', 'author');
|
|
1060
|
-
contrib.setAttribute('id', normalizeID(contributor.
|
|
1061
|
-
if (contributor.isCorresponding) {
|
|
965
|
+
contrib.setAttribute('id', normalizeID(contributor.attrs.id));
|
|
966
|
+
if (contributor.attrs.isCorresponding) {
|
|
1062
967
|
contrib.setAttribute('corresp', 'yes');
|
|
1063
968
|
}
|
|
1064
|
-
if (contributor.ORCIDIdentifier) {
|
|
969
|
+
if (contributor.attrs.ORCIDIdentifier) {
|
|
1065
970
|
const identifier = this.document.createElement('contrib-id');
|
|
1066
971
|
identifier.setAttribute('contrib-id-type', 'orcid');
|
|
1067
|
-
identifier.textContent = contributor.ORCIDIdentifier;
|
|
972
|
+
identifier.textContent = contributor.attrs.ORCIDIdentifier;
|
|
1068
973
|
contrib.appendChild(identifier);
|
|
1069
974
|
}
|
|
1070
975
|
const name = this.buildContributorName(contributor);
|
|
1071
976
|
contrib.appendChild(name);
|
|
1072
|
-
if (contributor.email) {
|
|
977
|
+
if (contributor.attrs.email) {
|
|
1073
978
|
const email = this.document.createElement('email');
|
|
1074
|
-
email.textContent = contributor.email;
|
|
979
|
+
email.textContent = contributor.attrs.email;
|
|
1075
980
|
contrib.appendChild(email);
|
|
1076
981
|
}
|
|
1077
|
-
if (contributor.
|
|
1078
|
-
contributor.
|
|
1079
|
-
const contributorRole = this.modelMap.get(rid);
|
|
1080
|
-
if (contributorRole) {
|
|
1081
|
-
const role = this.document.createElement('role');
|
|
1082
|
-
const attributes = chooseRoleVocabAttributes(contributorRole);
|
|
1083
|
-
for (const [key, value] of Object.entries(attributes)) {
|
|
1084
|
-
role.setAttribute(key, value);
|
|
1085
|
-
}
|
|
1086
|
-
role.textContent = contributorRole.name;
|
|
1087
|
-
contrib.appendChild(role);
|
|
1088
|
-
}
|
|
1089
|
-
});
|
|
1090
|
-
}
|
|
1091
|
-
if (contributor.affiliations) {
|
|
1092
|
-
contributor.affiliations.forEach((rid) => {
|
|
982
|
+
if (contributor.attrs.affiliations) {
|
|
983
|
+
contributor.attrs.affiliations.forEach((rid) => {
|
|
1093
984
|
const xref = this.document.createElement('xref');
|
|
1094
985
|
xref.setAttribute('ref-type', 'aff');
|
|
1095
986
|
xref.setAttribute('rid', normalizeID(rid));
|
|
@@ -1097,8 +988,8 @@ class JATSExporter {
|
|
|
1097
988
|
contrib.appendChild(xref);
|
|
1098
989
|
});
|
|
1099
990
|
}
|
|
1100
|
-
if (contributor.footnote) {
|
|
1101
|
-
contributor.footnote.map((note) => {
|
|
991
|
+
if (contributor.attrs.footnote) {
|
|
992
|
+
contributor.attrs.footnote.map((note) => {
|
|
1102
993
|
const xref = this.document.createElement('xref');
|
|
1103
994
|
xref.setAttribute('ref-type', 'fn');
|
|
1104
995
|
xref.setAttribute('rid', normalizeID(note.noteID));
|
|
@@ -1106,8 +997,8 @@ class JATSExporter {
|
|
|
1106
997
|
contrib.appendChild(xref);
|
|
1107
998
|
});
|
|
1108
999
|
}
|
|
1109
|
-
if (contributor.corresp) {
|
|
1110
|
-
contributor.corresp.map((corresp) => {
|
|
1000
|
+
if (contributor.attrs.corresp) {
|
|
1001
|
+
contributor.attrs.corresp.map((corresp) => {
|
|
1111
1002
|
const xref = this.document.createElement('xref');
|
|
1112
1003
|
xref.setAttribute('ref-type', 'corresp');
|
|
1113
1004
|
xref.setAttribute('rid', normalizeID(corresp.correspID));
|
|
@@ -1117,13 +1008,10 @@ class JATSExporter {
|
|
|
1117
1008
|
}
|
|
1118
1009
|
contribGroup.appendChild(contrib);
|
|
1119
1010
|
});
|
|
1120
|
-
|
|
1121
|
-
.filter((contributor) => contributor.role !== 'author')
|
|
1122
|
-
.sort(sortContributors);
|
|
1123
|
-
if (otherContributors.length) {
|
|
1011
|
+
if (otherContributorsNodes.length) {
|
|
1124
1012
|
const contribGroup = this.document.createElement('contrib-group');
|
|
1125
1013
|
articleMeta.appendChild(contribGroup);
|
|
1126
|
-
|
|
1014
|
+
otherContributorsNodes.forEach((contributor) => {
|
|
1127
1015
|
try {
|
|
1128
1016
|
this.validateContributor(contributor);
|
|
1129
1017
|
}
|
|
@@ -1132,30 +1020,16 @@ class JATSExporter {
|
|
|
1132
1020
|
return;
|
|
1133
1021
|
}
|
|
1134
1022
|
const contrib = this.document.createElement('contrib');
|
|
1135
|
-
contrib.setAttribute('id', normalizeID(contributor.
|
|
1023
|
+
contrib.setAttribute('id', normalizeID(contributor.attrs.id));
|
|
1136
1024
|
const name = this.buildContributorName(contributor);
|
|
1137
1025
|
contrib.appendChild(name);
|
|
1138
|
-
if (contributor.email) {
|
|
1026
|
+
if (contributor.attrs.email) {
|
|
1139
1027
|
const email = this.document.createElement('email');
|
|
1140
|
-
email.textContent = contributor.email;
|
|
1028
|
+
email.textContent = contributor.attrs.email;
|
|
1141
1029
|
contrib.appendChild(email);
|
|
1142
1030
|
}
|
|
1143
|
-
if (contributor.
|
|
1144
|
-
contributor.
|
|
1145
|
-
const contributorRole = this.modelMap.get(rid);
|
|
1146
|
-
if (contributorRole) {
|
|
1147
|
-
const role = this.document.createElement('role');
|
|
1148
|
-
const attributes = chooseRoleVocabAttributes(contributorRole);
|
|
1149
|
-
for (const [key, value] of Object.entries(attributes)) {
|
|
1150
|
-
role.setAttribute(key, value);
|
|
1151
|
-
}
|
|
1152
|
-
role.textContent = contributorRole.name;
|
|
1153
|
-
contrib.appendChild(role);
|
|
1154
|
-
}
|
|
1155
|
-
});
|
|
1156
|
-
}
|
|
1157
|
-
if (contributor.affiliations) {
|
|
1158
|
-
contributor.affiliations.forEach((rid) => {
|
|
1031
|
+
if (contributor.attrs.affiliations) {
|
|
1032
|
+
contributor.attrs.affiliations.forEach((rid) => {
|
|
1159
1033
|
const xref = this.document.createElement('xref');
|
|
1160
1034
|
xref.setAttribute('ref-type', 'aff');
|
|
1161
1035
|
xref.setAttribute('rid', normalizeID(rid));
|
|
@@ -1163,8 +1037,8 @@ class JATSExporter {
|
|
|
1163
1037
|
contrib.appendChild(xref);
|
|
1164
1038
|
});
|
|
1165
1039
|
}
|
|
1166
|
-
if (contributor.footnote) {
|
|
1167
|
-
contributor.footnote.map((note) => {
|
|
1040
|
+
if (contributor.attrs.footnote) {
|
|
1041
|
+
contributor.attrs.footnote.map((note) => {
|
|
1168
1042
|
const xref = this.document.createElement('xref');
|
|
1169
1043
|
xref.setAttribute('ref-type', 'fn');
|
|
1170
1044
|
xref.setAttribute('rid', normalizeID(note.noteID));
|
|
@@ -1176,64 +1050,68 @@ class JATSExporter {
|
|
|
1176
1050
|
});
|
|
1177
1051
|
}
|
|
1178
1052
|
const affiliationRIDs = [];
|
|
1179
|
-
const sortedContributors = [
|
|
1053
|
+
const sortedContributors = [
|
|
1054
|
+
...authorContributorNodes,
|
|
1055
|
+
...otherContributorsNodes,
|
|
1056
|
+
];
|
|
1180
1057
|
for (const contributor of sortedContributors) {
|
|
1181
|
-
if (contributor.affiliations) {
|
|
1182
|
-
affiliationRIDs.push(...contributor.affiliations);
|
|
1058
|
+
if (contributor.attrs.affiliations) {
|
|
1059
|
+
affiliationRIDs.push(...contributor.attrs.affiliations);
|
|
1183
1060
|
}
|
|
1184
1061
|
}
|
|
1185
|
-
const affiliations =
|
|
1062
|
+
const affiliations = (0, prosemirror_utils_1.findChildrenByType)(this.manuscriptNode, schema_1.schema.nodes.affiliation).map((result) => result.node);
|
|
1186
1063
|
if (affiliations) {
|
|
1187
|
-
const usedAffiliations = affiliations.filter((affiliation) => affiliationRIDs.includes(affiliation.
|
|
1188
|
-
usedAffiliations.sort((a, b) => affiliationRIDs.indexOf(a.
|
|
1064
|
+
const usedAffiliations = affiliations.filter((affiliation) => affiliationRIDs.includes(affiliation.attrs.id));
|
|
1065
|
+
usedAffiliations.sort((a, b) => affiliationRIDs.indexOf(a.attrs.id) -
|
|
1066
|
+
affiliationRIDs.indexOf(b.attrs.id));
|
|
1189
1067
|
usedAffiliations.forEach((affiliation) => {
|
|
1190
1068
|
var _a, _b;
|
|
1191
1069
|
const aff = this.document.createElement('aff');
|
|
1192
|
-
aff.setAttribute('id', normalizeID(affiliation.
|
|
1070
|
+
aff.setAttribute('id', normalizeID(affiliation.attrs.id));
|
|
1193
1071
|
contribGroup.appendChild(aff);
|
|
1194
|
-
if (affiliation.department) {
|
|
1072
|
+
if (affiliation.attrs.department) {
|
|
1195
1073
|
const department = this.document.createElement('institution');
|
|
1196
1074
|
department.setAttribute('content-type', 'dept');
|
|
1197
|
-
department.textContent = affiliation.department;
|
|
1075
|
+
department.textContent = affiliation.attrs.department;
|
|
1198
1076
|
aff.appendChild(department);
|
|
1199
1077
|
}
|
|
1200
|
-
if (affiliation.institution) {
|
|
1078
|
+
if (affiliation.attrs.institution) {
|
|
1201
1079
|
const institution = this.document.createElement('institution');
|
|
1202
|
-
institution.textContent = affiliation.institution;
|
|
1080
|
+
institution.textContent = affiliation.attrs.institution;
|
|
1203
1081
|
aff.appendChild(institution);
|
|
1204
1082
|
}
|
|
1205
|
-
if (affiliation.addressLine1) {
|
|
1083
|
+
if (affiliation.attrs.addressLine1) {
|
|
1206
1084
|
const addressLine = this.document.createElement('addr-line');
|
|
1207
|
-
addressLine.textContent = affiliation.addressLine1;
|
|
1085
|
+
addressLine.textContent = affiliation.attrs.addressLine1;
|
|
1208
1086
|
aff.appendChild(addressLine);
|
|
1209
1087
|
}
|
|
1210
|
-
if (affiliation.addressLine2) {
|
|
1088
|
+
if (affiliation.attrs.addressLine2) {
|
|
1211
1089
|
const addressLine = this.document.createElement('addr-line');
|
|
1212
|
-
addressLine.textContent = affiliation.addressLine2;
|
|
1090
|
+
addressLine.textContent = affiliation.attrs.addressLine2;
|
|
1213
1091
|
aff.appendChild(addressLine);
|
|
1214
1092
|
}
|
|
1215
|
-
if (affiliation.addressLine3) {
|
|
1093
|
+
if (affiliation.attrs.addressLine3) {
|
|
1216
1094
|
const addressLine = this.document.createElement('addr-line');
|
|
1217
|
-
addressLine.textContent = affiliation.addressLine3;
|
|
1095
|
+
addressLine.textContent = affiliation.attrs.addressLine3;
|
|
1218
1096
|
aff.appendChild(addressLine);
|
|
1219
1097
|
}
|
|
1220
|
-
if (affiliation.city) {
|
|
1098
|
+
if (affiliation.attrs.city) {
|
|
1221
1099
|
const city = this.document.createElement('city');
|
|
1222
|
-
city.textContent = affiliation.city;
|
|
1100
|
+
city.textContent = affiliation.attrs.city;
|
|
1223
1101
|
aff.appendChild(city);
|
|
1224
1102
|
}
|
|
1225
|
-
if (affiliation.country) {
|
|
1103
|
+
if (affiliation.attrs.country) {
|
|
1226
1104
|
const country = this.document.createElement('country');
|
|
1227
|
-
country.textContent = affiliation.country;
|
|
1105
|
+
country.textContent = affiliation.attrs.country;
|
|
1228
1106
|
aff.appendChild(country);
|
|
1229
1107
|
}
|
|
1230
|
-
if (affiliation.email) {
|
|
1108
|
+
if (affiliation.attrs.email) {
|
|
1231
1109
|
const email = this.document.createElement('email');
|
|
1232
|
-
email.setAttributeNS(XLINK_NAMESPACE, 'href', (_a = affiliation.email.href) !== null && _a !== void 0 ? _a : '');
|
|
1233
|
-
email.textContent = (_b = affiliation.email.text) !== null && _b !== void 0 ? _b : '';
|
|
1110
|
+
email.setAttributeNS(XLINK_NAMESPACE, 'href', (_a = affiliation.attrs.email.href) !== null && _a !== void 0 ? _a : '');
|
|
1111
|
+
email.textContent = (_b = affiliation.attrs.email.text) !== null && _b !== void 0 ? _b : '';
|
|
1234
1112
|
aff.appendChild(email);
|
|
1235
1113
|
}
|
|
1236
|
-
const labelNumber = affiliationLabels.get(affiliation.
|
|
1114
|
+
const labelNumber = affiliationLabels.get(affiliation.attrs.id);
|
|
1237
1115
|
if (labelNumber) {
|
|
1238
1116
|
const label = this.document.createElement('label');
|
|
1239
1117
|
label.textContent = String(labelNumber);
|
|
@@ -1250,41 +1128,48 @@ class JATSExporter {
|
|
|
1250
1128
|
this.createAuthorNotesElement = () => {
|
|
1251
1129
|
var _a;
|
|
1252
1130
|
const authorNotesEl = this.document.createElement('author-notes');
|
|
1253
|
-
const
|
|
1254
|
-
if (
|
|
1255
|
-
this.appendModelsToAuthorNotes(authorNotesEl,
|
|
1131
|
+
const authorNotesNode = (_a = (0, prosemirror_utils_1.findChildrenByType)(this.manuscriptNode, schema_1.schema.nodes.author_notes)[0]) === null || _a === void 0 ? void 0 : _a.node;
|
|
1132
|
+
if (authorNotesNode) {
|
|
1133
|
+
this.appendModelsToAuthorNotes(authorNotesEl, authorNotesNode);
|
|
1256
1134
|
}
|
|
1257
1135
|
return authorNotesEl;
|
|
1258
1136
|
};
|
|
1259
1137
|
this.appendCorrespondingToElement = (corresponding, element) => {
|
|
1260
1138
|
const correspondingEl = this.document.createElement('corresp');
|
|
1261
|
-
correspondingEl.setAttribute('id', normalizeID(corresponding.
|
|
1262
|
-
if (corresponding.label) {
|
|
1139
|
+
correspondingEl.setAttribute('id', normalizeID(corresponding.attrs.id));
|
|
1140
|
+
if (corresponding.attrs.label) {
|
|
1263
1141
|
const labelEl = this.document.createElement('label');
|
|
1264
|
-
labelEl.textContent = corresponding.label;
|
|
1142
|
+
labelEl.textContent = corresponding.attrs.label;
|
|
1265
1143
|
correspondingEl.appendChild(labelEl);
|
|
1266
1144
|
}
|
|
1267
|
-
correspondingEl.append(corresponding.
|
|
1145
|
+
correspondingEl.append(corresponding.textContent);
|
|
1268
1146
|
element.appendChild(correspondingEl);
|
|
1269
1147
|
};
|
|
1270
1148
|
this.appendParagraphToElement = (paragraph, element) => {
|
|
1271
|
-
const parsedDoc = new DOMParser().parseFromString(paragraph.
|
|
1149
|
+
const parsedDoc = new DOMParser().parseFromString(paragraph.textContent, 'text/html');
|
|
1272
1150
|
const parsedParagraph = parsedDoc.body.querySelector('p');
|
|
1273
1151
|
if (parsedParagraph) {
|
|
1274
1152
|
const paragraphEl = this.document.createElement('p');
|
|
1275
1153
|
paragraphEl.innerHTML = parsedParagraph.innerHTML;
|
|
1276
|
-
paragraphEl.setAttribute('id', normalizeID(paragraph.
|
|
1154
|
+
paragraphEl.setAttribute('id', normalizeID(paragraph.attrs.id));
|
|
1277
1155
|
element.appendChild(paragraphEl);
|
|
1278
1156
|
}
|
|
1279
1157
|
};
|
|
1280
1158
|
this.appendFootnoteToElement = (footnote, element) => {
|
|
1281
1159
|
const footnoteEl = this.document.createElement('fn');
|
|
1282
|
-
footnoteEl.setAttribute('id', normalizeID(footnote.
|
|
1283
|
-
|
|
1160
|
+
footnoteEl.setAttribute('id', normalizeID(footnote.attrs.id));
|
|
1161
|
+
if (!footnote.textContent.includes('<p>')) {
|
|
1162
|
+
const p = this.document.createElement('p');
|
|
1163
|
+
p.innerHTML = footnote.textContent;
|
|
1164
|
+
footnoteEl.appendChild(p);
|
|
1165
|
+
}
|
|
1166
|
+
else {
|
|
1167
|
+
footnoteEl.innerHTML = footnote.textContent;
|
|
1168
|
+
}
|
|
1284
1169
|
element.appendChild(footnoteEl);
|
|
1285
1170
|
};
|
|
1286
|
-
this.fixBody = (body
|
|
1287
|
-
|
|
1171
|
+
this.fixBody = (body) => {
|
|
1172
|
+
this.manuscriptNode.descendants((node) => {
|
|
1288
1173
|
if (node.attrs.id) {
|
|
1289
1174
|
if (node.attrs.titleSuppressed) {
|
|
1290
1175
|
const title = body.querySelector(`#${normalizeID(node.attrs.id)} > title`);
|
|
@@ -1302,7 +1187,7 @@ class JATSExporter {
|
|
|
1302
1187
|
label.remove();
|
|
1303
1188
|
}
|
|
1304
1189
|
}
|
|
1305
|
-
if ((0,
|
|
1190
|
+
if ((0, transformer_1.isNodeType)(node, 'general_table_footnote')) {
|
|
1306
1191
|
const generalTableFootnote = body.querySelector(`#${normalizeID(node.attrs.id)}`);
|
|
1307
1192
|
if (generalTableFootnote) {
|
|
1308
1193
|
Array.from(generalTableFootnote.childNodes).forEach((cn) => {
|
|
@@ -1311,7 +1196,7 @@ class JATSExporter {
|
|
|
1311
1196
|
generalTableFootnote.remove();
|
|
1312
1197
|
}
|
|
1313
1198
|
}
|
|
1314
|
-
if ((0,
|
|
1199
|
+
if ((0, transformer_1.isNodeType)(node, 'table_element')) {
|
|
1315
1200
|
const tableElement = body.querySelector(`#${normalizeID(node.attrs.id)}`);
|
|
1316
1201
|
if (tableElement) {
|
|
1317
1202
|
for (const childNode of tableElement.childNodes) {
|
|
@@ -1545,36 +1430,36 @@ class JATSExporter {
|
|
|
1545
1430
|
};
|
|
1546
1431
|
this.buildContributorName = (contributor) => {
|
|
1547
1432
|
const name = this.document.createElement('name');
|
|
1548
|
-
if (contributor.bibliographicName.family) {
|
|
1433
|
+
if (contributor.attrs.bibliographicName.family) {
|
|
1549
1434
|
const surname = this.document.createElement('surname');
|
|
1550
|
-
surname.textContent = contributor.bibliographicName.family;
|
|
1435
|
+
surname.textContent = contributor.attrs.bibliographicName.family;
|
|
1551
1436
|
name.appendChild(surname);
|
|
1552
1437
|
}
|
|
1553
|
-
if (contributor.bibliographicName.given) {
|
|
1438
|
+
if (contributor.attrs.bibliographicName.given) {
|
|
1554
1439
|
const givenNames = this.document.createElement('given-names');
|
|
1555
|
-
givenNames.textContent = contributor.bibliographicName.given;
|
|
1440
|
+
givenNames.textContent = contributor.attrs.bibliographicName.given;
|
|
1556
1441
|
name.appendChild(givenNames);
|
|
1557
1442
|
}
|
|
1558
1443
|
return name;
|
|
1559
1444
|
};
|
|
1560
1445
|
}
|
|
1561
|
-
generateCitations(
|
|
1446
|
+
generateCitations() {
|
|
1562
1447
|
const nodes = [];
|
|
1563
|
-
|
|
1448
|
+
this.manuscriptNode.descendants((node) => {
|
|
1564
1449
|
if ((0, schema_1.isCitationNode)(node)) {
|
|
1565
1450
|
nodes.push(node);
|
|
1566
1451
|
}
|
|
1567
1452
|
});
|
|
1568
1453
|
return (0, exports.buildCitations)(nodes);
|
|
1569
1454
|
}
|
|
1570
|
-
generateCitationTexts(
|
|
1455
|
+
generateCitationTexts(csl, manuscriptID) {
|
|
1571
1456
|
this.citationTexts = new Map();
|
|
1572
1457
|
this.citationProvider = new library_1.CitationProvider({
|
|
1573
|
-
getLibraryItem:
|
|
1458
|
+
getLibraryItem: this.getLibraryItem(manuscriptID),
|
|
1574
1459
|
locale: csl.locale,
|
|
1575
1460
|
citationStyle: csl.style,
|
|
1576
1461
|
});
|
|
1577
|
-
const citations = this.generateCitations(
|
|
1462
|
+
const citations = this.generateCitations();
|
|
1578
1463
|
this.citationProvider.rebuildState(citations).forEach(([id, , output]) => {
|
|
1579
1464
|
this.citationTexts.set(id, output);
|
|
1580
1465
|
});
|
|
@@ -1582,7 +1467,14 @@ class JATSExporter {
|
|
|
1582
1467
|
createEquation(node, isInline = false) {
|
|
1583
1468
|
if (node.attrs.format === 'tex') {
|
|
1584
1469
|
const texMath = this.document.createElement('tex-math');
|
|
1585
|
-
texMath.
|
|
1470
|
+
texMath.setAttribute('notation', 'LaTeX');
|
|
1471
|
+
texMath.setAttribute('version', 'MathJax');
|
|
1472
|
+
if (node.attrs.contents.includes('<![CDATA[')) {
|
|
1473
|
+
texMath.innerHTML = node.attrs.contents;
|
|
1474
|
+
}
|
|
1475
|
+
else {
|
|
1476
|
+
texMath.innerHTML = `<![CDATA[ ${node.attrs.contents} ]]>`;
|
|
1477
|
+
}
|
|
1586
1478
|
return texMath;
|
|
1587
1479
|
}
|
|
1588
1480
|
else {
|
|
@@ -1594,72 +1486,50 @@ class JATSExporter {
|
|
|
1594
1486
|
return mathml;
|
|
1595
1487
|
}
|
|
1596
1488
|
}
|
|
1597
|
-
appendModelsToAuthorNotes(authorNotesEl,
|
|
1598
|
-
const
|
|
1599
|
-
const usedCorrespondings = this.getUsedCorrespondings(
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
}
|
|
1605
|
-
switch (model.objectType) {
|
|
1606
|
-
case json_schema_1.ObjectTypes.ParagraphElement:
|
|
1607
|
-
this.appendParagraphToElement(model, authorNotesEl);
|
|
1489
|
+
appendModelsToAuthorNotes(authorNotesEl, authorNotesNode) {
|
|
1490
|
+
const contributorsNodes = (0, prosemirror_utils_1.findChildrenByType)(this.manuscriptNode, schema_1.schema.nodes.contributor).map((result) => result.node);
|
|
1491
|
+
const usedCorrespondings = this.getUsedCorrespondings(contributorsNodes);
|
|
1492
|
+
authorNotesNode.descendants((node) => {
|
|
1493
|
+
switch (node.type) {
|
|
1494
|
+
case schema_1.schema.nodes.paragraph:
|
|
1495
|
+
this.appendParagraphToElement(node, authorNotesEl);
|
|
1608
1496
|
break;
|
|
1609
|
-
case
|
|
1610
|
-
this.appendFootnoteToElement(
|
|
1497
|
+
case schema_1.schema.nodes.footnote:
|
|
1498
|
+
this.appendFootnoteToElement(node, authorNotesEl);
|
|
1611
1499
|
break;
|
|
1612
|
-
case
|
|
1613
|
-
if (usedCorrespondings.includes(
|
|
1614
|
-
this.appendCorrespondingToElement(
|
|
1500
|
+
case schema_1.schema.nodes.corresp:
|
|
1501
|
+
if (usedCorrespondings.includes(node)) {
|
|
1502
|
+
this.appendCorrespondingToElement(node, authorNotesEl);
|
|
1615
1503
|
}
|
|
1616
1504
|
break;
|
|
1617
1505
|
}
|
|
1506
|
+
return false;
|
|
1618
1507
|
});
|
|
1619
1508
|
}
|
|
1620
1509
|
getUsedCorrespondings(contributors) {
|
|
1621
1510
|
return contributors
|
|
1622
|
-
.flatMap((c) => { var _a; return (_a = c.corresp) !== null && _a !== void 0 ? _a : []; })
|
|
1623
|
-
.map((corresp) =>
|
|
1511
|
+
.flatMap((c) => { var _a; return (_a = c.attrs.corresp) !== null && _a !== void 0 ? _a : []; })
|
|
1512
|
+
.map((corresp) => {
|
|
1513
|
+
var _a;
|
|
1514
|
+
return (_a = (0, prosemirror_utils_1.findChildrenByAttr)(this.manuscriptNode, (attr) => attr.id === corresp.correspID)[0]) === null || _a === void 0 ? void 0 : _a.node;
|
|
1515
|
+
})
|
|
1624
1516
|
.filter((corresp) => !!corresp);
|
|
1625
1517
|
}
|
|
1626
1518
|
buildKeywords(articleMeta) {
|
|
1627
|
-
const
|
|
1628
|
-
|
|
1629
|
-
keywords.forEach((keyword) => {
|
|
1630
|
-
const containedGroup = keyword.containedGroup || '';
|
|
1631
|
-
const group = keywordGroups.get(containedGroup);
|
|
1632
|
-
if (group) {
|
|
1633
|
-
group.push(keyword);
|
|
1634
|
-
}
|
|
1635
|
-
else {
|
|
1636
|
-
keywordGroups.set(containedGroup, [keyword]);
|
|
1637
|
-
}
|
|
1638
|
-
});
|
|
1639
|
-
for (const [groupID, keywords] of keywordGroups) {
|
|
1640
|
-
const keywordGroup = (this.modelMap.get(groupID) || {});
|
|
1519
|
+
const keywordGroups = (0, prosemirror_utils_1.findChildrenByType)(this.manuscriptNode, schema_1.schema.nodes.keyword_group).map((result) => result.node);
|
|
1520
|
+
keywordGroups.forEach((group) => {
|
|
1641
1521
|
const kwdGroup = this.document.createElement('kwd-group');
|
|
1642
|
-
if (
|
|
1643
|
-
kwdGroup.setAttribute('kwd-group-type',
|
|
1644
|
-
}
|
|
1645
|
-
if (keywordGroup.label) {
|
|
1646
|
-
const label = this.document.createElement('label');
|
|
1647
|
-
label.textContent = keywordGroup.label;
|
|
1648
|
-
kwdGroup.appendChild(label);
|
|
1649
|
-
}
|
|
1650
|
-
if (keywordGroup.title) {
|
|
1651
|
-
const title = this.document.createElement('title');
|
|
1652
|
-
title.textContent = keywordGroup.title;
|
|
1653
|
-
kwdGroup.appendChild(title);
|
|
1522
|
+
if (group.attrs.type) {
|
|
1523
|
+
kwdGroup.setAttribute('kwd-group-type', group.attrs.type);
|
|
1654
1524
|
}
|
|
1655
1525
|
articleMeta.appendChild(kwdGroup);
|
|
1656
|
-
|
|
1526
|
+
group.content.forEach((keyword) => {
|
|
1657
1527
|
const kwd = this.document.createElement('kwd');
|
|
1658
|
-
kwd.textContent = keyword.
|
|
1528
|
+
kwd.textContent = keyword.textContent;
|
|
1659
1529
|
kwdGroup.appendChild(kwd);
|
|
1660
|
-
}
|
|
1530
|
+
});
|
|
1661
1531
|
articleMeta.appendChild(kwdGroup);
|
|
1662
|
-
}
|
|
1532
|
+
});
|
|
1663
1533
|
}
|
|
1664
1534
|
moveCoiStatementToAuthorNotes(back, front) {
|
|
1665
1535
|
const fnGroups = back.querySelectorAll('fn-group');
|
|
@@ -1707,7 +1577,7 @@ class JATSExporter {
|
|
|
1707
1577
|
footnotes.forEach((fn) => {
|
|
1708
1578
|
const fnType = fn.getAttribute('fn-type');
|
|
1709
1579
|
if (fnType) {
|
|
1710
|
-
fn.setAttribute('fn-type', (0,
|
|
1580
|
+
fn.setAttribute('fn-type', (0, transformer_1.chooseJatsFnType)(fnType));
|
|
1711
1581
|
}
|
|
1712
1582
|
});
|
|
1713
1583
|
}
|