@manuscripts/transform 1.5.8 → 2.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 +1 -1
- package/dist/cjs/jats/importer/index.js +1 -3
- package/dist/cjs/jats/importer/jats-body-dom-parser.js +23 -227
- package/dist/cjs/jats/importer/jats-body-transformations.js +110 -201
- package/dist/cjs/jats/importer/jats-comments.js +100 -98
- package/dist/cjs/jats/importer/jats-front-parser.js +87 -81
- package/dist/cjs/jats/importer/jats-journal-meta-parser.js +51 -39
- package/dist/cjs/jats/importer/jats-parser-utils.js +17 -56
- package/dist/cjs/jats/importer/jats-reference-parser.js +24 -79
- package/dist/cjs/jats/importer/jats-references.js +34 -0
- package/dist/cjs/jats/importer/parse-jats-article.js +67 -173
- package/dist/cjs/jats/index.js +1 -3
- package/dist/cjs/jats/jats-exporter.js +34 -55
- package/dist/cjs/lib/section-group-type.js +30 -0
- package/dist/cjs/lib/utils.js +1 -25
- package/dist/cjs/schema/index.js +20 -17
- package/dist/cjs/schema/nodes/abstracts.js +27 -0
- package/dist/cjs/schema/nodes/affiliations.js +27 -0
- package/dist/cjs/schema/nodes/backmatter.js +27 -0
- package/dist/cjs/schema/nodes/body.js +27 -0
- package/dist/cjs/schema/nodes/citation.js +10 -15
- package/dist/cjs/schema/nodes/{comment_list.js → comments.js} +4 -4
- package/dist/cjs/schema/nodes/contributors.js +27 -0
- package/dist/cjs/schema/nodes/{meta_section.js → core_section.js} +6 -5
- package/dist/cjs/schema/nodes/cross_reference.js +4 -3
- package/dist/cjs/schema/nodes/inline_footnote.js +6 -5
- package/dist/cjs/schema/nodes/keyword.js +0 -1
- package/dist/cjs/schema/nodes/{keywords_group.js → keyword_group.js} +6 -6
- package/dist/cjs/schema/nodes/{keywords_section.js → keywords.js} +7 -7
- package/dist/cjs/schema/nodes/keywords_element.js +1 -1
- package/dist/cjs/schema/nodes/manuscript.js +5 -2
- package/dist/cjs/transformer/builders.js +9 -86
- package/dist/cjs/transformer/decode.js +147 -176
- package/dist/cjs/transformer/encode.js +66 -67
- package/dist/cjs/transformer/highlight-markers.js +48 -36
- package/dist/cjs/transformer/html.js +7 -23
- package/dist/cjs/transformer/labels.js +3 -17
- package/dist/cjs/transformer/node-names.js +1 -1
- package/dist/cjs/transformer/node-title.js +1 -1
- package/dist/cjs/transformer/node-types.js +7 -6
- package/dist/cjs/transformer/object-types.js +1 -2
- package/dist/cjs/transformer/section-category.js +31 -31
- package/dist/es/index.js +1 -1
- package/dist/es/jats/importer/index.js +1 -1
- package/dist/es/jats/importer/jats-body-dom-parser.js +23 -227
- package/dist/es/jats/importer/jats-body-transformations.js +111 -202
- package/dist/es/jats/importer/jats-comments.js +97 -96
- package/dist/es/jats/importer/jats-front-parser.js +88 -82
- package/dist/es/jats/importer/jats-journal-meta-parser.js +51 -39
- package/dist/es/jats/importer/jats-parser-utils.js +16 -54
- package/dist/es/jats/importer/jats-reference-parser.js +27 -82
- package/dist/es/jats/importer/jats-references.js +30 -0
- package/dist/es/jats/importer/parse-jats-article.js +70 -174
- package/dist/es/jats/index.js +1 -1
- package/dist/es/jats/jats-exporter.js +34 -55
- package/dist/es/lib/section-group-type.js +27 -0
- package/dist/es/lib/utils.js +0 -22
- package/dist/es/schema/index.js +21 -18
- package/dist/es/schema/nodes/abstracts.js +24 -0
- package/dist/es/schema/nodes/affiliations.js +24 -0
- package/dist/es/schema/nodes/backmatter.js +24 -0
- package/dist/es/schema/nodes/body.js +24 -0
- package/dist/es/schema/nodes/citation.js +10 -15
- package/dist/es/schema/nodes/{comment_list.js → comments.js} +3 -3
- package/dist/es/schema/nodes/contributors.js +24 -0
- package/dist/es/schema/nodes/{meta_section.js → core_section.js} +5 -4
- package/dist/es/schema/nodes/cross_reference.js +4 -3
- package/dist/es/schema/nodes/inline_footnote.js +6 -5
- package/dist/es/schema/nodes/keyword.js +0 -1
- package/dist/es/schema/nodes/{keywords_group.js → keyword_group.js} +4 -4
- package/dist/es/schema/nodes/{keywords_section.js → keywords.js} +5 -5
- package/dist/es/schema/nodes/keywords_element.js +1 -1
- package/dist/es/schema/nodes/manuscript.js +3 -1
- package/dist/es/transformer/builders.js +6 -73
- package/dist/es/transformer/decode.js +147 -175
- package/dist/es/transformer/encode.js +70 -71
- package/dist/es/transformer/highlight-markers.js +44 -32
- package/dist/es/transformer/html.js +7 -23
- package/dist/es/transformer/labels.js +3 -17
- package/dist/es/transformer/node-names.js +1 -1
- package/dist/es/transformer/node-title.js +1 -1
- package/dist/es/transformer/node-types.js +7 -6
- package/dist/es/transformer/object-types.js +0 -1
- package/dist/es/transformer/section-category.js +29 -29
- package/dist/types/index.d.ts +1 -1
- package/dist/types/jats/importer/index.d.ts +1 -1
- package/dist/types/jats/importer/jats-body-transformations.d.ts +16 -19
- package/dist/types/jats/importer/jats-comments.d.ts +13 -9
- package/dist/types/jats/importer/jats-front-parser.d.ts +35 -12
- package/dist/types/jats/importer/jats-journal-meta-parser.d.ts +4 -4
- package/dist/types/jats/importer/jats-parser-utils.d.ts +1 -6
- package/dist/types/jats/importer/jats-reference-parser.d.ts +2 -6
- package/dist/types/jats/importer/jats-references.d.ts +12 -0
- package/dist/types/jats/importer/parse-jats-article.d.ts +5 -17
- package/dist/types/jats/index.d.ts +1 -1
- package/dist/types/lib/section-group-type.d.ts +23 -0
- package/dist/types/lib/utils.d.ts +1 -4
- package/dist/types/schema/index.d.ts +4 -5
- package/dist/types/schema/nodes/{meta_section.d.ts → abstracts.d.ts} +1 -9
- package/dist/types/schema/nodes/affiliations.d.ts +17 -0
- package/dist/types/schema/nodes/backmatter.d.ts +17 -0
- package/dist/types/schema/nodes/body.d.ts +17 -0
- package/dist/types/schema/nodes/citation.d.ts +3 -5
- package/dist/types/schema/nodes/comments.d.ts +17 -0
- package/dist/types/schema/nodes/contributors.d.ts +17 -0
- package/dist/types/schema/nodes/core_section.d.ts +17 -0
- package/dist/types/schema/nodes/cross_reference.d.ts +1 -1
- package/dist/types/schema/nodes/inline_footnote.d.ts +1 -1
- package/dist/types/schema/nodes/keyword.d.ts +0 -1
- package/dist/types/schema/nodes/{contributors_element.d.ts → keyword_group.d.ts} +3 -4
- package/dist/types/schema/nodes/{comment_list.d.ts → keywords.d.ts} +3 -2
- package/dist/types/schema/nodes/manuscript.d.ts +1 -0
- package/dist/types/schema/types.d.ts +1 -1
- package/dist/types/transformer/builders.d.ts +2 -14
- package/dist/types/transformer/decode.d.ts +5 -9
- package/dist/types/transformer/encode.d.ts +4 -4
- package/dist/types/transformer/highlight-markers.d.ts +7 -2
- package/dist/types/transformer/object-types.d.ts +1 -2
- package/dist/types/transformer/section-category.d.ts +4 -3
- package/package.json +1 -6
- package/dist/cjs/lib/core-section-categories.js +0 -29
- package/dist/cjs/schema/nodes/affiliations_section.js +0 -36
- package/dist/cjs/schema/nodes/contributors_element.js +0 -49
- package/dist/cjs/schema/nodes/contributors_section.js +0 -36
- package/dist/es/lib/core-section-categories.js +0 -26
- package/dist/es/schema/nodes/affiliations_section.js +0 -32
- package/dist/es/schema/nodes/contributors_element.js +0 -46
- package/dist/es/schema/nodes/contributors_section.js +0 -32
- package/dist/types/lib/core-section-categories.d.ts +0 -8
- package/dist/types/schema/nodes/affiliations_section.d.ts +0 -11
- package/dist/types/schema/nodes/contributors_section.d.ts +0 -12
- package/dist/types/schema/nodes/keywords_group.d.ts +0 -26
- package/dist/types/schema/nodes/keywords_section.d.ts +0 -26
|
@@ -16,34 +16,27 @@
|
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.jatsBodyTransformations = void 0;
|
|
19
|
+
const section_group_type_1 = require("../../lib/section-group-type");
|
|
19
20
|
const transformer_1 = require("../../transformer");
|
|
20
21
|
const removeNodeFromParent = (node) => node.parentNode && node.parentNode.removeChild(node);
|
|
21
22
|
const capitalizeFirstLetter = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
sectionContainer.setAttribute('sec-type', sectionCategory ? (0, transformer_1.chooseSecType)(sectionCategory) : '');
|
|
23
|
+
const createSectionGroup = (type, createElement) => {
|
|
24
|
+
const sec = createElement('sec');
|
|
25
|
+
sec.setAttribute('sec-type', type._id);
|
|
26
26
|
const title = createElement('title');
|
|
27
|
-
title.textContent =
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
sectionContainer.appendChild(title);
|
|
31
|
-
return sectionContainer;
|
|
27
|
+
title.textContent = type.title;
|
|
28
|
+
sec.appendChild(title);
|
|
29
|
+
return sec;
|
|
32
30
|
};
|
|
33
31
|
exports.jatsBodyTransformations = {
|
|
34
32
|
ensureSection(body, createElement) {
|
|
35
|
-
let section
|
|
36
|
-
const
|
|
37
|
-
if (
|
|
38
|
-
|
|
39
|
-
title.textContent = '';
|
|
40
|
-
section.appendChild(title);
|
|
41
|
-
}
|
|
42
|
-
const { firstElementChild } = body;
|
|
43
|
-
if (firstElementChild && firstElementChild.tagName === 'sec') {
|
|
44
|
-
section = firstElementChild;
|
|
33
|
+
let section;
|
|
34
|
+
const element = body.firstElementChild;
|
|
35
|
+
if (element && element.tagName === 'sec') {
|
|
36
|
+
section = element;
|
|
45
37
|
}
|
|
46
38
|
else {
|
|
39
|
+
section = createElement('sec');
|
|
47
40
|
body.insertBefore(section, body.firstChild);
|
|
48
41
|
}
|
|
49
42
|
body.childNodes.forEach((child) => {
|
|
@@ -58,7 +51,7 @@ exports.jatsBodyTransformations = {
|
|
|
58
51
|
}
|
|
59
52
|
});
|
|
60
53
|
},
|
|
61
|
-
|
|
54
|
+
createAbstractSection(abstractNode, createElement) {
|
|
62
55
|
const abstractType = abstractNode.getAttribute('abstract-type');
|
|
63
56
|
const section = createElement('sec');
|
|
64
57
|
const sectionType = abstractType ? `abstract-${abstractType}` : 'abstract';
|
|
@@ -75,7 +68,7 @@ exports.jatsBodyTransformations = {
|
|
|
75
68
|
}
|
|
76
69
|
return section;
|
|
77
70
|
},
|
|
78
|
-
|
|
71
|
+
createAcknowledgmentsSection(ackNode, createElement) {
|
|
79
72
|
const section = createElement('sec');
|
|
80
73
|
section.setAttribute('sec-type', 'acknowledgments');
|
|
81
74
|
const titleNode = ackNode.querySelector('title');
|
|
@@ -92,40 +85,7 @@ exports.jatsBodyTransformations = {
|
|
|
92
85
|
}
|
|
93
86
|
return section;
|
|
94
87
|
},
|
|
95
|
-
|
|
96
|
-
const bibSec = doc.createElement('sec');
|
|
97
|
-
bibSec.setAttribute('sec-type', 'bibliography');
|
|
98
|
-
const titleNode = doc.querySelector('back > ref-list > title');
|
|
99
|
-
if (titleNode) {
|
|
100
|
-
bibSec.appendChild(titleNode);
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
const title = createElement('title');
|
|
104
|
-
title.textContent = 'References';
|
|
105
|
-
bibSec.appendChild(title);
|
|
106
|
-
}
|
|
107
|
-
const refList = doc.createElement('ref-list');
|
|
108
|
-
for (const ref of references) {
|
|
109
|
-
const item = doc.createElement('ref');
|
|
110
|
-
item.setAttribute('id', ref._id);
|
|
111
|
-
item.setAttribute('type', ref.type);
|
|
112
|
-
item.setAttribute('author', JSON.stringify(ref.author));
|
|
113
|
-
item.setAttribute('issued', JSON.stringify(ref.issued));
|
|
114
|
-
ref['container-title'] &&
|
|
115
|
-
item.setAttribute('container-title', ref['container-title']);
|
|
116
|
-
ref.DOI && item.setAttribute('doi', ref.DOI);
|
|
117
|
-
ref.volume && item.setAttribute('volume', ref.volume.toString());
|
|
118
|
-
ref.issue && item.setAttribute('issue', ref.issue.toString());
|
|
119
|
-
ref.supplement && item.setAttribute('supplement', ref.supplement);
|
|
120
|
-
ref.page && item.setAttribute('page', ref.page.toString());
|
|
121
|
-
ref.title && item.setAttribute('title', ref.title);
|
|
122
|
-
ref.literal && item.setAttribute('literal', ref.literal);
|
|
123
|
-
refList.appendChild(item);
|
|
124
|
-
}
|
|
125
|
-
bibSec.appendChild(refList);
|
|
126
|
-
return bibSec;
|
|
127
|
-
},
|
|
128
|
-
createFootnotes(footnoteGroups, createElement) {
|
|
88
|
+
createFootnotesSection(footnoteGroups, createElement) {
|
|
129
89
|
const section = createElement('sec');
|
|
130
90
|
section.setAttribute('sec-type', 'endnotes');
|
|
131
91
|
const titleNode = footnoteGroups
|
|
@@ -150,81 +110,81 @@ exports.jatsBodyTransformations = {
|
|
|
150
110
|
section.append(...app.children);
|
|
151
111
|
return section;
|
|
152
112
|
},
|
|
153
|
-
createFloatsGroupSection(
|
|
113
|
+
createFloatsGroupSection(group, createElement) {
|
|
154
114
|
const section = createElement('sec');
|
|
155
115
|
section.setAttribute('sec-type', 'floating-element');
|
|
156
116
|
const title = createElement('title');
|
|
157
117
|
title.textContent = 'Floating Group';
|
|
158
118
|
section.appendChild(title);
|
|
159
|
-
section.append(...
|
|
119
|
+
section.append(...group.children);
|
|
160
120
|
return section;
|
|
161
121
|
},
|
|
162
|
-
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
const
|
|
166
|
-
removeNodeFromParent(
|
|
167
|
-
|
|
122
|
+
moveAbstracts(doc, group, createElement) {
|
|
123
|
+
const abstracts = doc.querySelectorAll('front > article-meta > abstract');
|
|
124
|
+
abstracts.forEach((abstract) => {
|
|
125
|
+
const sec = this.createAbstractSection(abstract, createElement);
|
|
126
|
+
removeNodeFromParent(abstract);
|
|
127
|
+
group.appendChild(sec);
|
|
168
128
|
});
|
|
169
129
|
},
|
|
170
|
-
wrapBodySections(doc,
|
|
130
|
+
wrapBodySections(doc, group) {
|
|
171
131
|
const bodySections = doc.querySelectorAll('body > sec:not([sec-type="backmatter"]), body > sec:not([sec-type])');
|
|
172
132
|
bodySections.forEach((section) => {
|
|
173
133
|
removeNodeFromParent(section);
|
|
174
|
-
|
|
134
|
+
group.appendChild(section);
|
|
175
135
|
});
|
|
176
136
|
},
|
|
177
|
-
|
|
137
|
+
moveBackSections(doc, group) {
|
|
178
138
|
for (const section of doc.querySelectorAll('back > sec')) {
|
|
179
139
|
removeNodeFromParent(section);
|
|
180
|
-
|
|
140
|
+
group.appendChild(section);
|
|
181
141
|
}
|
|
182
142
|
},
|
|
183
|
-
|
|
184
|
-
const
|
|
185
|
-
if (
|
|
186
|
-
const
|
|
187
|
-
removeNodeFromParent(
|
|
188
|
-
|
|
143
|
+
moveAcknowledgments(doc, group, createElement) {
|
|
144
|
+
const ack = doc.querySelector('back > ack');
|
|
145
|
+
if (ack) {
|
|
146
|
+
const sec = this.createAcknowledgmentsSection(ack, createElement);
|
|
147
|
+
removeNodeFromParent(ack);
|
|
148
|
+
group.appendChild(sec);
|
|
189
149
|
}
|
|
190
150
|
},
|
|
191
|
-
|
|
192
|
-
const
|
|
193
|
-
for (const app of
|
|
194
|
-
const
|
|
151
|
+
moveAppendices(doc, group, createElement) {
|
|
152
|
+
const apps = doc.querySelectorAll('back > app-group > app');
|
|
153
|
+
for (const app of apps) {
|
|
154
|
+
const sec = this.createAppendixSection(app, createElement);
|
|
195
155
|
removeNodeFromParent(app);
|
|
196
|
-
|
|
156
|
+
group.appendChild(sec);
|
|
197
157
|
}
|
|
198
158
|
},
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
159
|
+
createBody(doc, body, createElement) {
|
|
160
|
+
const group = createSectionGroup(section_group_type_1.bodyType, createElement);
|
|
161
|
+
this.wrapBodySections(doc, group);
|
|
162
|
+
this.moveFloatsGroupToBody(doc, group, createElement);
|
|
163
|
+
body.append(group);
|
|
164
|
+
},
|
|
165
|
+
createAbstracts(doc, body, createElement) {
|
|
166
|
+
const group = createSectionGroup(section_group_type_1.abstractsType, createElement);
|
|
167
|
+
this.moveAbstracts(doc, group, createElement);
|
|
168
|
+
body.insertBefore(group, body.lastElementChild);
|
|
203
169
|
},
|
|
204
|
-
|
|
205
|
-
const
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
this.
|
|
209
|
-
this.
|
|
210
|
-
this.
|
|
211
|
-
|
|
212
|
-
this.moveAcknowledgmentsIntoContainer(doc, backmatterContainer, createElement);
|
|
213
|
-
this.moveAppendicesIntoContainer(doc, backmatterContainer, createElement);
|
|
214
|
-
this.moveBibliographyIntoContainer(doc, backmatterContainer, references, createElement);
|
|
215
|
-
body.insertBefore(abstractsContainer, body.firstChild);
|
|
216
|
-
body.insertBefore(bodyContainer, abstractsContainer.nextSibling);
|
|
217
|
-
body.append(backmatterContainer);
|
|
170
|
+
createBackmatter(doc, body, createElement) {
|
|
171
|
+
const group = createSectionGroup(section_group_type_1.backmatterType, createElement);
|
|
172
|
+
this.moveBackSections(doc, group);
|
|
173
|
+
this.moveAppendices(doc, group, createElement);
|
|
174
|
+
this.moveSpecialFootnotes(doc, group, createElement);
|
|
175
|
+
this.moveFootnotes(doc, group, createElement);
|
|
176
|
+
this.moveAcknowledgments(doc, group, createElement);
|
|
177
|
+
body.append(group);
|
|
218
178
|
},
|
|
219
|
-
|
|
179
|
+
moveSpecialFootnotes(doc, group, createElement) {
|
|
220
180
|
var _a;
|
|
221
|
-
const
|
|
222
|
-
for (const
|
|
223
|
-
const type =
|
|
181
|
+
const fns = [...doc.querySelectorAll('fn[fn-type]')];
|
|
182
|
+
for (const fn of fns) {
|
|
183
|
+
const type = fn.getAttribute('fn-type') || '';
|
|
224
184
|
const category = (0, transformer_1.chooseSectionCategoryByType)(type);
|
|
225
185
|
if (category) {
|
|
226
186
|
const section = createElement('sec');
|
|
227
|
-
const title =
|
|
187
|
+
const title = fn.querySelector('p[content-type="fn-title"]');
|
|
228
188
|
if (title) {
|
|
229
189
|
const sectionTitleElement = createElement('title');
|
|
230
190
|
const titleTextContent = (_a = title.textContent) === null || _a === void 0 ? void 0 : _a.trim();
|
|
@@ -234,12 +194,14 @@ exports.jatsBodyTransformations = {
|
|
|
234
194
|
removeNodeFromParent(title);
|
|
235
195
|
section.append(sectionTitleElement);
|
|
236
196
|
}
|
|
237
|
-
section.append(...
|
|
238
|
-
removeNodeFromParent(
|
|
197
|
+
section.append(...fn.children);
|
|
198
|
+
removeNodeFromParent(fn);
|
|
239
199
|
section.setAttribute('sec-type', (0, transformer_1.chooseSecType)(category));
|
|
240
|
-
|
|
200
|
+
group.append(section);
|
|
241
201
|
}
|
|
242
202
|
}
|
|
203
|
+
},
|
|
204
|
+
moveFootnotes(doc, group, createElement) {
|
|
243
205
|
const footnotes = [...doc.querySelectorAll('fn:not(table-wrap-foot fn)')];
|
|
244
206
|
const footnotesSection = doc.querySelector('sec[sec-type="endnotes"]');
|
|
245
207
|
const footnotesSectionGroup = footnotesSection === null || footnotesSection === void 0 ? void 0 : footnotesSection.querySelector('fn-group');
|
|
@@ -251,8 +213,8 @@ exports.jatsBodyTransformations = {
|
|
|
251
213
|
}
|
|
252
214
|
}
|
|
253
215
|
if (!footnotesSection && containingGroup.innerHTML) {
|
|
254
|
-
const section = this.
|
|
255
|
-
|
|
216
|
+
const section = this.createFootnotesSection([containingGroup], createElement);
|
|
217
|
+
group.append(section);
|
|
256
218
|
}
|
|
257
219
|
let regularFootnoteGroups = [
|
|
258
220
|
...doc.querySelectorAll('back > fn-group:not([fn-type])'),
|
|
@@ -264,8 +226,8 @@ exports.jatsBodyTransformations = {
|
|
|
264
226
|
});
|
|
265
227
|
if (regularFootnoteGroups.length > 0) {
|
|
266
228
|
regularFootnoteGroups.map((g) => removeNodeFromParent(g));
|
|
267
|
-
const footnotes = this.
|
|
268
|
-
|
|
229
|
+
const footnotes = this.createFootnotesSection(regularFootnoteGroups, createElement);
|
|
230
|
+
group.appendChild(footnotes);
|
|
269
231
|
}
|
|
270
232
|
},
|
|
271
233
|
moveCaptionsToEnd(body) {
|
|
@@ -276,103 +238,50 @@ exports.jatsBodyTransformations = {
|
|
|
276
238
|
}
|
|
277
239
|
}
|
|
278
240
|
},
|
|
279
|
-
|
|
280
|
-
const
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
241
|
+
fixTables(body, createElement) {
|
|
242
|
+
const tables = body.querySelectorAll('table-wrap > table');
|
|
243
|
+
tables.forEach((table) => {
|
|
244
|
+
const colgroup = table.querySelector('colgroup');
|
|
245
|
+
const cols = table.querySelectorAll('col');
|
|
246
|
+
if (!colgroup && table.firstChild && cols.length > 0) {
|
|
247
|
+
const colgroup = createElement('colgroup');
|
|
248
|
+
for (const col of cols) {
|
|
249
|
+
colgroup.appendChild(col);
|
|
250
|
+
}
|
|
251
|
+
table.insertBefore(colgroup, table.firstChild);
|
|
284
252
|
}
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
const
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
item.setAttribute('department', affiliation.department);
|
|
300
|
-
affiliation.addressLine1 &&
|
|
301
|
-
item.setAttribute('addressLine1', affiliation.addressLine1);
|
|
302
|
-
affiliation.addressLine2 &&
|
|
303
|
-
item.setAttribute('addressLine2', affiliation.addressLine2);
|
|
304
|
-
affiliation.addressLine3 &&
|
|
305
|
-
item.setAttribute('addressLine3', affiliation.addressLine3);
|
|
306
|
-
affiliation.postCode &&
|
|
307
|
-
item.setAttribute('postCode', affiliation.postCode);
|
|
308
|
-
affiliation.country && item.setAttribute('country', affiliation.country);
|
|
309
|
-
(affiliation.priority === 0 || affiliation.priority) &&
|
|
310
|
-
item.setAttribute('priority', affiliation.priority.toString());
|
|
311
|
-
section.appendChild(item);
|
|
312
|
-
});
|
|
313
|
-
body.prepend(section);
|
|
314
|
-
}
|
|
253
|
+
const tbody = table.querySelector('tbody');
|
|
254
|
+
if (tbody) {
|
|
255
|
+
const headerRow = table.querySelector('thead > tr');
|
|
256
|
+
if (!headerRow) {
|
|
257
|
+
const tr = createElement('tr');
|
|
258
|
+
tbody.insertBefore(tr, tbody.firstElementChild);
|
|
259
|
+
}
|
|
260
|
+
const footerRow = table.querySelector('tfoot > tr');
|
|
261
|
+
if (!footerRow) {
|
|
262
|
+
const tr = createElement('tr');
|
|
263
|
+
tbody.appendChild(tr);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
});
|
|
315
267
|
},
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
item.setAttribute('id', author._id);
|
|
323
|
-
author.role && item.setAttribute('role', author.role);
|
|
324
|
-
author.affiliations &&
|
|
325
|
-
item.setAttribute('affiliations', JSON.stringify(author.affiliations));
|
|
326
|
-
author.footnote &&
|
|
327
|
-
item.setAttribute('footnote', JSON.stringify(author.footnote));
|
|
328
|
-
author.corresp &&
|
|
329
|
-
item.setAttribute('corresp', JSON.stringify(author.corresp));
|
|
330
|
-
author.bibliographicName &&
|
|
331
|
-
item.setAttribute('bibliographicName', JSON.stringify(author.bibliographicName));
|
|
332
|
-
author.userID && item.setAttribute('userID', author.userID);
|
|
333
|
-
author.invitationID &&
|
|
334
|
-
item.setAttribute('invitationID', author.invitationID);
|
|
335
|
-
author.isCorresponding &&
|
|
336
|
-
item.setAttribute('isCorresponding', JSON.stringify(author.isCorresponding));
|
|
337
|
-
author.ORCIDIdentifier &&
|
|
338
|
-
item.setAttribute('ORCIDIdentifier', author.ORCIDIdentifier);
|
|
339
|
-
(author.priority === 0 || author.priority) &&
|
|
340
|
-
item.setAttribute('priority', author.priority.toString());
|
|
341
|
-
section.appendChild(item);
|
|
342
|
-
});
|
|
343
|
-
body.prepend(section);
|
|
268
|
+
moveTableFooterToEnd(body) {
|
|
269
|
+
const footers = body.querySelectorAll('table-wrap-foot');
|
|
270
|
+
for (const footer of footers) {
|
|
271
|
+
if (footer.parentNode) {
|
|
272
|
+
footer.parentNode.appendChild(footer);
|
|
273
|
+
}
|
|
344
274
|
}
|
|
345
275
|
},
|
|
346
276
|
moveFloatsGroupToBody(doc, body, createElement) {
|
|
347
|
-
const
|
|
348
|
-
if (
|
|
349
|
-
const
|
|
350
|
-
removeNodeFromParent(
|
|
351
|
-
body.appendChild(
|
|
277
|
+
const group = doc.querySelector('floats-group');
|
|
278
|
+
if (group) {
|
|
279
|
+
const sec = this.createFloatsGroupSection(group, createElement);
|
|
280
|
+
removeNodeFromParent(group);
|
|
281
|
+
body.appendChild(sec);
|
|
352
282
|
}
|
|
353
283
|
},
|
|
354
|
-
|
|
355
|
-
const blockNodes = ['disp-formula'];
|
|
356
|
-
const paragraphs = [...body.querySelectorAll('sec > p')].filter((node) => blockNodes.find((node_name) => node.querySelector(`:scope > ${node_name}`)));
|
|
357
|
-
paragraphs.map((paragraph) => {
|
|
358
|
-
let newParagraph = createElement('p');
|
|
359
|
-
const parent = doc.createDocumentFragment();
|
|
360
|
-
while (paragraph === null || paragraph === void 0 ? void 0 : paragraph.firstChild) {
|
|
361
|
-
if (blockNodes.includes(paragraph === null || paragraph === void 0 ? void 0 : paragraph.firstChild.nodeName)) {
|
|
362
|
-
if (newParagraph.innerHTML.trim().length > 0) {
|
|
363
|
-
parent.append(newParagraph);
|
|
364
|
-
newParagraph = createElement('p');
|
|
365
|
-
}
|
|
366
|
-
parent.append(paragraph === null || paragraph === void 0 ? void 0 : paragraph.firstChild);
|
|
367
|
-
}
|
|
368
|
-
else {
|
|
369
|
-
newParagraph.append(paragraph === null || paragraph === void 0 ? void 0 : paragraph.firstChild);
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
paragraph === null || paragraph === void 0 ? void 0 : paragraph.replaceWith(parent);
|
|
373
|
-
});
|
|
374
|
-
},
|
|
375
|
-
moveKeywordsToBody(document, body, createElement) {
|
|
284
|
+
createKeywords(document, body, createElement) {
|
|
376
285
|
const keywordGroups = [...document.querySelectorAll('kwd-group')];
|
|
377
286
|
if (keywordGroups.length > 0) {
|
|
378
287
|
const section = createElement('sec');
|
|
@@ -380,9 +289,9 @@ exports.jatsBodyTransformations = {
|
|
|
380
289
|
const title = createElement('title');
|
|
381
290
|
title.textContent = 'Keywords';
|
|
382
291
|
section.append(title);
|
|
383
|
-
const
|
|
384
|
-
|
|
385
|
-
section.append(
|
|
292
|
+
const keywordsElement = createElement('kwd-group-list');
|
|
293
|
+
keywordsElement.append(keywordGroups[0]);
|
|
294
|
+
section.append(keywordsElement);
|
|
386
295
|
body.prepend(section);
|
|
387
296
|
}
|
|
388
297
|
},
|