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