@manuscripts/transform 3.0.4-LEAN-4011.0 → 3.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/jats/exporter/jats-exporter.js +14 -67
- package/dist/cjs/jats/importer/jats-body-transformations.js +326 -0
- package/dist/cjs/jats/importer/jats-dom-parser.js +5 -43
- package/dist/cjs/lib/utils.js +1 -14
- package/dist/cjs/schema/nodes/bibliography_element.js +0 -1
- package/dist/cjs/schema/nodes/bibliography_item.js +0 -1
- package/dist/cjs/schema/nodes/blockquote_element.js +0 -3
- package/dist/cjs/schema/nodes/citation.js +0 -2
- package/dist/cjs/schema/nodes/cross_reference.js +1 -13
- package/dist/cjs/schema/nodes/equation_element.js +0 -1
- package/dist/cjs/schema/nodes/figure.js +0 -1
- package/dist/cjs/schema/nodes/figure_element.js +1 -28
- package/dist/cjs/schema/nodes/footnote.js +1 -5
- package/dist/cjs/schema/nodes/footnotes_element.js +1 -5
- package/dist/cjs/schema/nodes/graphical_abstract_section.js +0 -1
- package/dist/cjs/schema/nodes/keywords_element.js +0 -2
- package/dist/cjs/schema/nodes/list.js +0 -3
- package/dist/cjs/schema/nodes/listing_element.js +0 -2
- package/dist/cjs/schema/nodes/manuscript.js +0 -6
- package/dist/cjs/schema/nodes/missing_figure.js +0 -1
- package/dist/cjs/schema/nodes/paragraph.js +0 -3
- package/dist/cjs/schema/nodes/pullquote_element.js +1 -6
- package/dist/cjs/schema/nodes/section.js +2 -44
- package/dist/cjs/schema/nodes/table_element.js +0 -11
- package/dist/cjs/schema/nodes/toc_element.js +0 -1
- package/dist/cjs/version.js +1 -1
- package/dist/es/jats/exporter/jats-exporter.js +14 -67
- package/dist/es/jats/importer/jats-body-transformations.js +323 -0
- package/dist/es/jats/importer/jats-dom-parser.js +6 -44
- package/dist/es/lib/utils.js +0 -12
- package/dist/es/schema/nodes/bibliography_element.js +0 -1
- package/dist/es/schema/nodes/bibliography_item.js +0 -1
- package/dist/es/schema/nodes/blockquote_element.js +0 -3
- package/dist/es/schema/nodes/citation.js +0 -2
- package/dist/es/schema/nodes/cross_reference.js +1 -13
- package/dist/es/schema/nodes/equation_element.js +0 -1
- package/dist/es/schema/nodes/figure.js +0 -1
- package/dist/es/schema/nodes/figure_element.js +1 -28
- package/dist/es/schema/nodes/footnote.js +1 -5
- package/dist/es/schema/nodes/footnotes_element.js +1 -5
- package/dist/es/schema/nodes/graphical_abstract_section.js +0 -1
- package/dist/es/schema/nodes/keywords_element.js +0 -2
- package/dist/es/schema/nodes/list.js +0 -3
- package/dist/es/schema/nodes/listing_element.js +0 -2
- package/dist/es/schema/nodes/manuscript.js +0 -6
- package/dist/es/schema/nodes/missing_figure.js +0 -1
- package/dist/es/schema/nodes/paragraph.js +0 -3
- package/dist/es/schema/nodes/pullquote_element.js +1 -6
- package/dist/es/schema/nodes/section.js +1 -43
- package/dist/es/schema/nodes/table_element.js +0 -11
- package/dist/es/schema/nodes/toc_element.js +0 -1
- package/dist/es/version.js +1 -1
- package/dist/types/jats/exporter/jats-exporter.d.ts +1 -1
- package/dist/types/jats/importer/jats-body-transformations.d.ts +40 -0
- package/dist/types/lib/utils.d.ts +0 -1
- package/dist/types/schema/nodes/bibliography_element.d.ts +0 -1
- package/dist/types/schema/nodes/bibliography_item.d.ts +0 -1
- package/dist/types/schema/nodes/blockquote_element.d.ts +0 -1
- package/dist/types/schema/nodes/citation.d.ts +0 -1
- package/dist/types/schema/nodes/cross_reference.d.ts +0 -1
- package/dist/types/schema/nodes/equation_element.d.ts +0 -1
- package/dist/types/schema/nodes/figure_element.d.ts +0 -14
- package/dist/types/schema/nodes/footnote.d.ts +0 -1
- package/dist/types/schema/nodes/footnotes_element.d.ts +0 -1
- package/dist/types/schema/nodes/keywords_element.d.ts +1 -2
- package/dist/types/schema/nodes/list.d.ts +0 -1
- package/dist/types/schema/nodes/listing_element.d.ts +0 -2
- package/dist/types/schema/nodes/manuscript.d.ts +0 -6
- package/dist/types/schema/nodes/paragraph.d.ts +0 -1
- package/dist/types/schema/nodes/pullquote_element.d.ts +0 -1
- package/dist/types/schema/nodes/section.d.ts +1 -8
- package/dist/types/schema/nodes/table_element.d.ts +0 -8
- package/dist/types/schema/nodes/toc_element.d.ts +0 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -1
- package/dist/cjs/lib/attributes.js +0 -26
- package/dist/es/lib/attributes.js +0 -22
- package/dist/types/lib/attributes.d.ts +0 -20
|
@@ -291,35 +291,6 @@ class JATSExporter {
|
|
|
291
291
|
supplementaryMaterial.append(caption);
|
|
292
292
|
articleMeta.append(supplementaryMaterial);
|
|
293
293
|
});
|
|
294
|
-
const history = articleMeta.querySelector('history') ||
|
|
295
|
-
this.document.createElement('history');
|
|
296
|
-
if (this.manuscriptNode.attrs.acceptanceDate) {
|
|
297
|
-
const date = this.buildDateElement(this.manuscriptNode.attrs.acceptanceDate, 'accepted');
|
|
298
|
-
history.appendChild(date);
|
|
299
|
-
}
|
|
300
|
-
if (this.manuscriptNode.attrs.correctionDate) {
|
|
301
|
-
const date = this.buildDateElement(this.manuscriptNode.attrs.correctionDate, 'corrected');
|
|
302
|
-
history.appendChild(date);
|
|
303
|
-
}
|
|
304
|
-
if (this.manuscriptNode.attrs.retractionDate) {
|
|
305
|
-
const date = this.buildDateElement(this.manuscriptNode.attrs.retractionDate, 'retracted');
|
|
306
|
-
history.appendChild(date);
|
|
307
|
-
}
|
|
308
|
-
if (this.manuscriptNode.attrs.receiveDate) {
|
|
309
|
-
const date = this.buildDateElement(this.manuscriptNode.attrs.receiveDate, 'received');
|
|
310
|
-
history.appendChild(date);
|
|
311
|
-
}
|
|
312
|
-
if (this.manuscriptNode.attrs.revisionReceiveDate) {
|
|
313
|
-
const date = this.buildDateElement(this.manuscriptNode.attrs.revisionReceiveDate, 'rev-recd');
|
|
314
|
-
history.appendChild(date);
|
|
315
|
-
}
|
|
316
|
-
if (this.manuscriptNode.attrs.revisionRequestDate) {
|
|
317
|
-
const date = this.buildDateElement(this.manuscriptNode.attrs.revisionRequestDate, 'rev-request');
|
|
318
|
-
history.appendChild(date);
|
|
319
|
-
}
|
|
320
|
-
if (history.childElementCount) {
|
|
321
|
-
articleMeta.appendChild(history);
|
|
322
|
-
}
|
|
323
294
|
this.buildKeywords(articleMeta);
|
|
324
295
|
let countingElements = [];
|
|
325
296
|
const figureCount = (0, prosemirror_utils_1.findChildrenByType)(this.manuscriptNode, schema_1.schema.nodes.figure).length;
|
|
@@ -610,17 +581,18 @@ class JATSExporter {
|
|
|
610
581
|
return xref;
|
|
611
582
|
},
|
|
612
583
|
cross_reference: (node) => {
|
|
613
|
-
var _a;
|
|
584
|
+
var _a, _b, _c;
|
|
614
585
|
const cross = node;
|
|
615
586
|
const rids = cross.attrs.rids;
|
|
616
587
|
if (!rids.length) {
|
|
617
|
-
return cross.attrs.label;
|
|
588
|
+
return (_a = cross.attrs.label) !== null && _a !== void 0 ? _a : '';
|
|
618
589
|
}
|
|
619
|
-
const
|
|
620
|
-
const
|
|
590
|
+
const rid = rids[0];
|
|
591
|
+
const text = cross.attrs.label || ((_b = this.labelTargets.get(rid)) === null || _b === void 0 ? void 0 : _b.label);
|
|
592
|
+
const target = (_c = (0, prosemirror_utils_1.findChildrenByAttr)(this.manuscriptNode, (attrs) => attrs.id === rid)[0]) === null || _c === void 0 ? void 0 : _c.node;
|
|
621
593
|
if (!target) {
|
|
622
594
|
warn('');
|
|
623
|
-
return text;
|
|
595
|
+
return text || '';
|
|
624
596
|
}
|
|
625
597
|
const xref = this.document.createElement('xref');
|
|
626
598
|
const type = chooseRefType(target.type);
|
|
@@ -631,7 +603,7 @@ class JATSExporter {
|
|
|
631
603
|
warn(`Unset ref-type for schema type ${target.type.name}`);
|
|
632
604
|
}
|
|
633
605
|
xref.setAttribute('rid', normalizeID(rids.join(' ')));
|
|
634
|
-
xref.textContent = text;
|
|
606
|
+
xref.textContent = text !== null && text !== void 0 ? text : '';
|
|
635
607
|
return xref;
|
|
636
608
|
},
|
|
637
609
|
doc: () => '',
|
|
@@ -1219,22 +1191,6 @@ class JATSExporter {
|
|
|
1219
1191
|
this.fixBody = (body) => {
|
|
1220
1192
|
this.manuscriptNode.descendants((node) => {
|
|
1221
1193
|
if (node.attrs.id) {
|
|
1222
|
-
if (node.attrs.titleSuppressed) {
|
|
1223
|
-
const title = body.querySelector(`#${normalizeID(node.attrs.id)} > title`);
|
|
1224
|
-
if (title && title.parentNode) {
|
|
1225
|
-
title.parentNode.removeChild(title);
|
|
1226
|
-
}
|
|
1227
|
-
}
|
|
1228
|
-
if (node.attrs.suppressCaption) {
|
|
1229
|
-
const caption = body.querySelector(`#${normalizeID(node.attrs.id)} > caption`);
|
|
1230
|
-
if (caption) {
|
|
1231
|
-
caption.remove();
|
|
1232
|
-
}
|
|
1233
|
-
const label = body.querySelector(`#${normalizeID(node.attrs.id)} > label`);
|
|
1234
|
-
if (label) {
|
|
1235
|
-
label.remove();
|
|
1236
|
-
}
|
|
1237
|
-
}
|
|
1238
1194
|
if ((0, transformer_1.isNodeType)(node, 'general_table_footnote')) {
|
|
1239
1195
|
const generalTableFootnote = body.querySelector(`#${normalizeID(node.attrs.id)}`);
|
|
1240
1196
|
if (generalTableFootnote) {
|
|
@@ -1250,13 +1206,8 @@ class JATSExporter {
|
|
|
1250
1206
|
for (const childNode of tableElement.childNodes) {
|
|
1251
1207
|
switch (childNode.nodeName) {
|
|
1252
1208
|
case 'caption': {
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
}
|
|
1256
|
-
else {
|
|
1257
|
-
const label = tableElement.querySelector('label');
|
|
1258
|
-
tableElement.insertBefore(childNode, label ? label.nextSibling : tableElement.firstChild);
|
|
1259
|
-
}
|
|
1209
|
+
const label = tableElement.querySelector('label');
|
|
1210
|
+
tableElement.insertBefore(childNode, label ? label.nextSibling : tableElement.firstChild);
|
|
1260
1211
|
break;
|
|
1261
1212
|
}
|
|
1262
1213
|
case 'table': {
|
|
@@ -1300,19 +1251,15 @@ class JATSExporter {
|
|
|
1300
1251
|
const headerCell = row.querySelector('th[scope="col"], th[scope="colgroup"]');
|
|
1301
1252
|
if (i === 0 || headerCell) {
|
|
1302
1253
|
tbody === null || tbody === void 0 ? void 0 : tbody.removeChild(row);
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
this.changeTag(td, 'th');
|
|
1307
|
-
}
|
|
1308
|
-
thead.appendChild(row);
|
|
1254
|
+
const tableCells = row.querySelectorAll('td');
|
|
1255
|
+
for (const td of tableCells) {
|
|
1256
|
+
this.changeTag(td, 'th');
|
|
1309
1257
|
}
|
|
1258
|
+
thead.appendChild(row);
|
|
1310
1259
|
}
|
|
1311
1260
|
else if (i === tbodyRows.length - 1) {
|
|
1312
1261
|
tbody === null || tbody === void 0 ? void 0 : tbody.removeChild(row);
|
|
1313
|
-
|
|
1314
|
-
tfoot.appendChild(row);
|
|
1315
|
-
}
|
|
1262
|
+
tfoot.appendChild(row);
|
|
1316
1263
|
}
|
|
1317
1264
|
}
|
|
1318
1265
|
});
|
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* © 2020 Atypon Systems LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.jatsBodyTransformations = void 0;
|
|
19
|
+
const section_group_type_1 = require("../../lib/section-group-type");
|
|
20
|
+
const transformer_1 = require("../../transformer");
|
|
21
|
+
const removeNodeFromParent = (node) => node.parentNode && node.parentNode.removeChild(node);
|
|
22
|
+
const capitalizeFirstLetter = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
|
23
|
+
const createSectionGroup = (type, createElement) => {
|
|
24
|
+
const sec = createElement('sec');
|
|
25
|
+
sec.setAttribute('sec-type', type._id);
|
|
26
|
+
const title = createElement('title');
|
|
27
|
+
title.textContent = type.title;
|
|
28
|
+
sec.appendChild(title);
|
|
29
|
+
return sec;
|
|
30
|
+
};
|
|
31
|
+
exports.jatsBodyTransformations = {
|
|
32
|
+
ensureSection(body, createElement) {
|
|
33
|
+
let section;
|
|
34
|
+
const element = body.firstElementChild;
|
|
35
|
+
if (element && element.tagName === 'sec') {
|
|
36
|
+
section = element;
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
section = createElement('sec');
|
|
40
|
+
body.insertBefore(section, body.firstChild);
|
|
41
|
+
}
|
|
42
|
+
body.childNodes.forEach((child) => {
|
|
43
|
+
if (child.nodeType === Node.ELEMENT_NODE) {
|
|
44
|
+
const element = child;
|
|
45
|
+
if (element.tagName !== 'sec') {
|
|
46
|
+
section.appendChild(element);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
section = element;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
createAbstractSection(abstractNode, createElement) {
|
|
55
|
+
const abstractType = abstractNode.getAttribute('abstract-type');
|
|
56
|
+
const section = createElement('sec');
|
|
57
|
+
const sectionType = abstractType ? `abstract-${abstractType}` : 'abstract';
|
|
58
|
+
section.setAttribute('sec-type', sectionType);
|
|
59
|
+
if (!abstractNode.querySelector('abstract > title')) {
|
|
60
|
+
const title = createElement('title');
|
|
61
|
+
title.textContent = abstractType
|
|
62
|
+
? `${capitalizeFirstLetter(abstractType)} Abstract`
|
|
63
|
+
: 'Abstract';
|
|
64
|
+
section.appendChild(title);
|
|
65
|
+
}
|
|
66
|
+
while (abstractNode.firstChild) {
|
|
67
|
+
section.appendChild(abstractNode.firstChild);
|
|
68
|
+
}
|
|
69
|
+
return section;
|
|
70
|
+
},
|
|
71
|
+
createAcknowledgmentsSection(ackNode, createElement) {
|
|
72
|
+
const section = createElement('sec');
|
|
73
|
+
section.setAttribute('sec-type', 'acknowledgments');
|
|
74
|
+
const titleNode = ackNode.querySelector('title');
|
|
75
|
+
if (titleNode) {
|
|
76
|
+
section.appendChild(titleNode);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
const title = createElement('title');
|
|
80
|
+
title.textContent = 'Acknowledgements';
|
|
81
|
+
section.appendChild(title);
|
|
82
|
+
}
|
|
83
|
+
while (ackNode.firstChild) {
|
|
84
|
+
section.appendChild(ackNode.firstChild);
|
|
85
|
+
}
|
|
86
|
+
return section;
|
|
87
|
+
},
|
|
88
|
+
createFootnotesSection(footnoteGroups, createElement) {
|
|
89
|
+
const section = createElement('sec');
|
|
90
|
+
section.setAttribute('sec-type', 'endnotes');
|
|
91
|
+
const titleNode = footnoteGroups
|
|
92
|
+
.map((g) => g.querySelector('title'))
|
|
93
|
+
.filter((t) => t !== null)[0];
|
|
94
|
+
if (titleNode) {
|
|
95
|
+
section.appendChild(titleNode);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
const title = createElement('title');
|
|
99
|
+
title.textContent = 'Footnotes';
|
|
100
|
+
section.appendChild(title);
|
|
101
|
+
}
|
|
102
|
+
for (const footnoteGroup of footnoteGroups) {
|
|
103
|
+
section.appendChild(footnoteGroup);
|
|
104
|
+
}
|
|
105
|
+
return section;
|
|
106
|
+
},
|
|
107
|
+
createAppendixSection(app, createElement) {
|
|
108
|
+
const section = createElement('sec');
|
|
109
|
+
section.setAttribute('sec-type', 'appendices');
|
|
110
|
+
section.append(...app.children);
|
|
111
|
+
return section;
|
|
112
|
+
},
|
|
113
|
+
createFloatsGroupSection(group, createElement) {
|
|
114
|
+
const section = createElement('sec');
|
|
115
|
+
section.setAttribute('sec-type', 'floating-element');
|
|
116
|
+
const title = createElement('title');
|
|
117
|
+
title.textContent = 'Floating Group';
|
|
118
|
+
section.appendChild(title);
|
|
119
|
+
section.append(...group.children);
|
|
120
|
+
return section;
|
|
121
|
+
},
|
|
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);
|
|
128
|
+
});
|
|
129
|
+
},
|
|
130
|
+
wrapBodySections(doc, group) {
|
|
131
|
+
const bodySections = doc.querySelectorAll('body > sec:not([sec-type="backmatter"]), body > sec:not([sec-type])');
|
|
132
|
+
bodySections.forEach((section) => {
|
|
133
|
+
removeNodeFromParent(section);
|
|
134
|
+
group.appendChild(section);
|
|
135
|
+
});
|
|
136
|
+
},
|
|
137
|
+
moveBackSections(doc, group) {
|
|
138
|
+
for (const section of doc.querySelectorAll('back > sec')) {
|
|
139
|
+
removeNodeFromParent(section);
|
|
140
|
+
group.appendChild(section);
|
|
141
|
+
}
|
|
142
|
+
},
|
|
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);
|
|
149
|
+
}
|
|
150
|
+
},
|
|
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);
|
|
155
|
+
removeNodeFromParent(app);
|
|
156
|
+
group.appendChild(sec);
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
createBoxedElementSection(doc, body, createElement) {
|
|
160
|
+
const boxedTexts = body.querySelectorAll('boxed-text');
|
|
161
|
+
for (const boxedText of boxedTexts) {
|
|
162
|
+
const boxElementSec = createElement('sec');
|
|
163
|
+
boxElementSec.setAttribute('sec-type', 'box-element');
|
|
164
|
+
const title = createElement('title');
|
|
165
|
+
title.textContent = 'BoxElement';
|
|
166
|
+
boxElementSec.append(title);
|
|
167
|
+
for (const element of [...boxedText.children]) {
|
|
168
|
+
if ((element === null || element === void 0 ? void 0 : element.tagName) === 'label' || (element === null || element === void 0 ? void 0 : element.tagName) === 'caption') {
|
|
169
|
+
boxElementSec.append(element);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
const containerSection = createElement('sec');
|
|
173
|
+
containerSection.append(...boxedText.children);
|
|
174
|
+
boxElementSec.append(containerSection);
|
|
175
|
+
boxedText.replaceWith(boxElementSec);
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
createBody(doc, body, createElement) {
|
|
179
|
+
const group = createSectionGroup(section_group_type_1.bodyType, createElement);
|
|
180
|
+
this.wrapBodySections(doc, group);
|
|
181
|
+
this.moveFloatsGroupToBody(doc, group, createElement);
|
|
182
|
+
body.append(group);
|
|
183
|
+
},
|
|
184
|
+
createAbstracts(doc, body, createElement) {
|
|
185
|
+
const group = createSectionGroup(section_group_type_1.abstractsType, createElement);
|
|
186
|
+
this.moveAbstracts(doc, group, createElement);
|
|
187
|
+
body.insertBefore(group, body.lastElementChild);
|
|
188
|
+
},
|
|
189
|
+
createBackmatter(doc, body, createElement) {
|
|
190
|
+
const group = createSectionGroup(section_group_type_1.backmatterType, createElement);
|
|
191
|
+
this.moveBackSections(doc, group);
|
|
192
|
+
this.moveAppendices(doc, group, createElement);
|
|
193
|
+
this.moveSpecialFootnotes(doc, group, createElement);
|
|
194
|
+
this.moveFootnotes(doc, group, createElement);
|
|
195
|
+
this.moveAcknowledgments(doc, group, createElement);
|
|
196
|
+
body.append(group);
|
|
197
|
+
},
|
|
198
|
+
moveSpecialFootnotes(doc, group, createElement) {
|
|
199
|
+
var _a;
|
|
200
|
+
const fns = [...doc.querySelectorAll('fn[fn-type]')];
|
|
201
|
+
for (const fn of fns) {
|
|
202
|
+
const type = fn.getAttribute('fn-type') || '';
|
|
203
|
+
const category = (0, transformer_1.chooseSectionCategoryByType)(type);
|
|
204
|
+
if (category) {
|
|
205
|
+
const section = createElement('sec');
|
|
206
|
+
const title = fn.querySelector('p[content-type="fn-title"]');
|
|
207
|
+
if (title) {
|
|
208
|
+
const sectionTitleElement = createElement('title');
|
|
209
|
+
const titleTextContent = (_a = title.textContent) === null || _a === void 0 ? void 0 : _a.trim();
|
|
210
|
+
if (titleTextContent) {
|
|
211
|
+
sectionTitleElement.textContent = titleTextContent;
|
|
212
|
+
}
|
|
213
|
+
removeNodeFromParent(title);
|
|
214
|
+
section.append(sectionTitleElement);
|
|
215
|
+
}
|
|
216
|
+
section.append(...fn.children);
|
|
217
|
+
removeNodeFromParent(fn);
|
|
218
|
+
section.setAttribute('sec-type', (0, transformer_1.chooseSecType)(category));
|
|
219
|
+
group.append(section);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
moveFootnotes(doc, group, createElement) {
|
|
224
|
+
var _a;
|
|
225
|
+
const footnotes = Array.from(doc.querySelectorAll('fn:not(table-wrap-foot fn, author-notes fn)'));
|
|
226
|
+
let footnotesSection = doc.querySelector('sec[sec-type="endnotes"]');
|
|
227
|
+
const containingGroup = (footnotesSection === null || footnotesSection === void 0 ? void 0 : footnotesSection.querySelector('fn-group')) || createElement('fn-group');
|
|
228
|
+
footnotes.forEach((footnote) => {
|
|
229
|
+
if (!footnote.getAttribute('fn-type')) {
|
|
230
|
+
containingGroup.appendChild(footnote);
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
if (!footnotesSection && containingGroup.innerHTML) {
|
|
234
|
+
footnotesSection = this.createFootnotesSection([containingGroup], createElement);
|
|
235
|
+
}
|
|
236
|
+
if (footnotesSection) {
|
|
237
|
+
group.insertBefore(footnotesSection, ((_a = group.firstChild) === null || _a === void 0 ? void 0 : _a.nextSibling) || group.firstChild);
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
moveCaptionsToEnd(body) {
|
|
241
|
+
const captions = body.querySelectorAll('caption');
|
|
242
|
+
for (const caption of captions) {
|
|
243
|
+
if (caption.parentNode &&
|
|
244
|
+
caption.parentNode.nodeName !== 'table-wrap' &&
|
|
245
|
+
caption.parentNode.nodeName !== 'boxed-text') {
|
|
246
|
+
caption.parentNode.appendChild(caption);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
fixTables(body, createElement) {
|
|
251
|
+
const tableWraps = body.querySelectorAll('table-wrap');
|
|
252
|
+
tableWraps.forEach((tableWrap) => {
|
|
253
|
+
const table = tableWrap.querySelector('table');
|
|
254
|
+
if (!table) {
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
const colgroup = table.querySelector('colgroup');
|
|
258
|
+
const cols = table.querySelectorAll('col');
|
|
259
|
+
if (!colgroup && table.firstChild && cols.length > 0) {
|
|
260
|
+
const colgroup = createElement('colgroup');
|
|
261
|
+
for (const col of cols) {
|
|
262
|
+
colgroup.appendChild(col);
|
|
263
|
+
}
|
|
264
|
+
tableWrap.insertBefore(colgroup, table.nextSibling);
|
|
265
|
+
}
|
|
266
|
+
const tableFootWrap = tableWrap.querySelector('table-wrap-foot');
|
|
267
|
+
if (tableFootWrap) {
|
|
268
|
+
const paragraphs = tableFootWrap.querySelectorAll(':scope > p');
|
|
269
|
+
if (paragraphs.length) {
|
|
270
|
+
const generalTableFootnote = createElement('general-table-footnote');
|
|
271
|
+
for (const paragraph of paragraphs) {
|
|
272
|
+
removeNodeFromParent(paragraph);
|
|
273
|
+
generalTableFootnote.append(paragraph);
|
|
274
|
+
}
|
|
275
|
+
tableFootWrap.prepend(generalTableFootnote);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
},
|
|
280
|
+
orderTableFootnote(doc, body) {
|
|
281
|
+
const tableInlineFootnotesIds = new Set(Array.from(body.querySelectorAll('tbody > tr > td > xref[ref-type="fn"]').values()).map((inlineFootnote) => inlineFootnote.getAttribute('rid')));
|
|
282
|
+
const fnGroups = doc.querySelectorAll('table-wrap-foot > fn-group');
|
|
283
|
+
fnGroups.forEach((fnGroup) => {
|
|
284
|
+
const orderedFootnotes = Array.from(fnGroup.querySelectorAll('fn')).sort((fn) => tableInlineFootnotesIds.has(fn.getAttribute('id'))
|
|
285
|
+
? -1
|
|
286
|
+
: 0);
|
|
287
|
+
fnGroup.replaceChildren(...orderedFootnotes);
|
|
288
|
+
});
|
|
289
|
+
},
|
|
290
|
+
moveFloatsGroupToBody(doc, body, createElement) {
|
|
291
|
+
const group = doc.querySelector('floats-group');
|
|
292
|
+
if (group) {
|
|
293
|
+
const sec = this.createFloatsGroupSection(group, createElement);
|
|
294
|
+
removeNodeFromParent(group);
|
|
295
|
+
body.appendChild(sec);
|
|
296
|
+
}
|
|
297
|
+
},
|
|
298
|
+
createKeywords(document, body, createElement) {
|
|
299
|
+
const keywordGroups = [...document.querySelectorAll('kwd-group')];
|
|
300
|
+
if (keywordGroups.length > 0) {
|
|
301
|
+
const section = createElement('sec');
|
|
302
|
+
section.setAttribute('sec-type', 'keywords');
|
|
303
|
+
const title = createElement('title');
|
|
304
|
+
title.textContent = 'Keywords';
|
|
305
|
+
section.append(title);
|
|
306
|
+
const keywordsElement = createElement('kwd-group-list');
|
|
307
|
+
keywordsElement.append(keywordGroups[0]);
|
|
308
|
+
section.append(keywordsElement);
|
|
309
|
+
body.prepend(section);
|
|
310
|
+
}
|
|
311
|
+
},
|
|
312
|
+
createSuppleMaterials(document, body, createElement) {
|
|
313
|
+
const suppleMaterials = [
|
|
314
|
+
...document.querySelectorAll('article-meta > supplementary-material'),
|
|
315
|
+
];
|
|
316
|
+
if (suppleMaterials.length > 0) {
|
|
317
|
+
const section = createElement('sec');
|
|
318
|
+
section.setAttribute('sec-type', 'supplementary-material');
|
|
319
|
+
const title = createElement('title');
|
|
320
|
+
title.textContent = 'supplementary-material';
|
|
321
|
+
section.append(title);
|
|
322
|
+
section.append(...suppleMaterials);
|
|
323
|
+
body.prepend(section);
|
|
324
|
+
}
|
|
325
|
+
},
|
|
326
|
+
};
|
|
@@ -69,42 +69,6 @@ const getEquationContent = (p) => {
|
|
|
69
69
|
}
|
|
70
70
|
return { id, format, contents };
|
|
71
71
|
};
|
|
72
|
-
const parseDates = (historyNode) => {
|
|
73
|
-
if (!historyNode) {
|
|
74
|
-
return undefined;
|
|
75
|
-
}
|
|
76
|
-
const history = {};
|
|
77
|
-
for (const date of historyNode.children) {
|
|
78
|
-
const dateType = date.getAttribute('date-type');
|
|
79
|
-
switch (dateType) {
|
|
80
|
-
case 'received': {
|
|
81
|
-
history.receiveDate = (0, utils_1.dateToTimestamp)(date);
|
|
82
|
-
break;
|
|
83
|
-
}
|
|
84
|
-
case 'rev-recd': {
|
|
85
|
-
history.revisionReceiveDate = (0, utils_1.dateToTimestamp)(date);
|
|
86
|
-
break;
|
|
87
|
-
}
|
|
88
|
-
case 'accepted': {
|
|
89
|
-
history.acceptanceDate = (0, utils_1.dateToTimestamp)(date);
|
|
90
|
-
break;
|
|
91
|
-
}
|
|
92
|
-
case 'rev-request': {
|
|
93
|
-
history.revisionRequestDate = (0, utils_1.dateToTimestamp)(date);
|
|
94
|
-
break;
|
|
95
|
-
}
|
|
96
|
-
case 'retracted': {
|
|
97
|
-
history.retractionDate = (0, utils_1.dateToTimestamp)(date);
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
case 'corrected': {
|
|
101
|
-
history.correctionDate = (0, utils_1.dateToTimestamp)(date);
|
|
102
|
-
break;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
return history;
|
|
107
|
-
};
|
|
108
72
|
const getEmail = (element) => {
|
|
109
73
|
var _a, _b, _c;
|
|
110
74
|
const email = element.querySelector('email');
|
|
@@ -277,9 +241,11 @@ const nodes = [
|
|
|
277
241
|
var _a, _b;
|
|
278
242
|
const element = node;
|
|
279
243
|
const doi = element.querySelector('front > article-meta > article-id[pub-id-type="doi"]');
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
244
|
+
return {
|
|
245
|
+
doi: doi === null || doi === void 0 ? void 0 : doi.textContent,
|
|
246
|
+
articleType: (_a = element.getAttribute('article-type')) !== null && _a !== void 0 ? _a : '',
|
|
247
|
+
primaryLanguageCode: (_b = element.getAttribute('lang')) !== null && _b !== void 0 ? _b : '',
|
|
248
|
+
};
|
|
283
249
|
},
|
|
284
250
|
},
|
|
285
251
|
{
|
|
@@ -472,10 +438,6 @@ const nodes = [
|
|
|
472
438
|
tag: 'back',
|
|
473
439
|
ignore: true,
|
|
474
440
|
},
|
|
475
|
-
{
|
|
476
|
-
tag: 'history',
|
|
477
|
-
ignore: true,
|
|
478
|
-
},
|
|
479
441
|
{
|
|
480
442
|
tag: 'break',
|
|
481
443
|
node: 'hard_break',
|
package/dist/cjs/lib/utils.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.
|
|
18
|
+
exports.timestamp = exports.getTrimmedTextContent = exports.findParentNodeClosestToPos = exports.isInBibliographySection = exports.isInGraphicalAbstractSection = exports.findNodePositions = exports.iterateChildren = void 0;
|
|
19
19
|
const bibliography_section_1 = require("../schema/nodes/bibliography_section");
|
|
20
20
|
const graphical_abstract_section_1 = require("../schema/nodes/graphical_abstract_section");
|
|
21
21
|
function* iterateChildren(node, recurse = false) {
|
|
@@ -85,16 +85,3 @@ const getTrimmedTextContent = (node, querySelector) => {
|
|
|
85
85
|
exports.getTrimmedTextContent = getTrimmedTextContent;
|
|
86
86
|
const timestamp = () => Math.floor(Date.now() / 1000);
|
|
87
87
|
exports.timestamp = timestamp;
|
|
88
|
-
const dateToTimestamp = (dateElement) => {
|
|
89
|
-
const selectors = ['year', 'month', 'day'];
|
|
90
|
-
const values = [];
|
|
91
|
-
for (const selector of selectors) {
|
|
92
|
-
const value = (0, exports.getTrimmedTextContent)(dateElement, selector);
|
|
93
|
-
if (!value || isNaN(+value)) {
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
values.push(+value);
|
|
97
|
-
}
|
|
98
|
-
return Date.UTC(values[0], values[1], values[2]) / 1000;
|
|
99
|
-
};
|
|
100
|
-
exports.dateToTimestamp = dateToTimestamp;
|
|
@@ -17,12 +17,10 @@
|
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.isBlockquoteElement = exports.blockquoteElement = void 0;
|
|
19
19
|
const json_schema_1 = require("@manuscripts/json-schema");
|
|
20
|
-
const attributes_1 = require("../../lib/attributes");
|
|
21
20
|
exports.blockquoteElement = {
|
|
22
21
|
content: 'paragraph+ attribution',
|
|
23
22
|
attrs: {
|
|
24
23
|
id: { default: '' },
|
|
25
|
-
paragraphStyle: { default: '' },
|
|
26
24
|
placeholder: { default: '' },
|
|
27
25
|
dataTracked: { default: null },
|
|
28
26
|
},
|
|
@@ -50,7 +48,6 @@ exports.blockquoteElement = {
|
|
|
50
48
|
if (blockquoteElementNode.attrs.id) {
|
|
51
49
|
attrs.id = blockquoteElementNode.attrs.id;
|
|
52
50
|
}
|
|
53
|
-
attrs.class = (0, attributes_1.buildElementClass)(blockquoteElementNode.attrs);
|
|
54
51
|
attrs['data-object-type'] = json_schema_1.ObjectTypes.QuoteElement;
|
|
55
52
|
if (blockquoteElementNode.attrs.placeholder) {
|
|
56
53
|
attrs['data-placeholder-text'] = blockquoteElementNode.attrs.placeholder;
|
|
@@ -24,7 +24,6 @@ exports.citation = {
|
|
|
24
24
|
attrs: {
|
|
25
25
|
id: { default: '' },
|
|
26
26
|
rids: { default: [] },
|
|
27
|
-
contents: { default: '' },
|
|
28
27
|
selectedText: { default: '' },
|
|
29
28
|
dataTracked: { default: null },
|
|
30
29
|
},
|
|
@@ -37,7 +36,6 @@ exports.citation = {
|
|
|
37
36
|
return {
|
|
38
37
|
id: dom.getAttribute('data-id'),
|
|
39
38
|
rids: ((_a = dom.getAttribute('data-reference-id')) === null || _a === void 0 ? void 0 : _a.split(/\s+/)) || [],
|
|
40
|
-
contents: dom.innerHTML,
|
|
41
39
|
};
|
|
42
40
|
},
|
|
43
41
|
},
|
|
@@ -24,7 +24,6 @@ exports.crossReference = {
|
|
|
24
24
|
attrs: {
|
|
25
25
|
rids: { default: [] },
|
|
26
26
|
label: { default: '' },
|
|
27
|
-
customLabel: { default: '' },
|
|
28
27
|
dataTracked: { default: null },
|
|
29
28
|
},
|
|
30
29
|
parseDOM: [
|
|
@@ -35,7 +34,6 @@ exports.crossReference = {
|
|
|
35
34
|
const dom = p;
|
|
36
35
|
return {
|
|
37
36
|
rids: ((_a = dom.getAttribute('data-reference-id')) === null || _a === void 0 ? void 0 : _a.split(/\s+/)) || [],
|
|
38
|
-
label: dom.textContent,
|
|
39
37
|
};
|
|
40
38
|
},
|
|
41
39
|
},
|
|
@@ -48,17 +46,7 @@ exports.crossReference = {
|
|
|
48
46
|
class: 'cross-reference',
|
|
49
47
|
'data-reference-id': crossReferenceNode.attrs.rids.join(' '),
|
|
50
48
|
},
|
|
51
|
-
|
|
52
|
-
'span',
|
|
53
|
-
{
|
|
54
|
-
class: 'kind elementIndex',
|
|
55
|
-
},
|
|
56
|
-
[
|
|
57
|
-
'b',
|
|
58
|
-
crossReferenceNode.attrs.customLabel ||
|
|
59
|
-
crossReferenceNode.attrs.label,
|
|
60
|
-
],
|
|
61
|
-
],
|
|
49
|
+
crossReferenceNode.attrs.label,
|
|
62
50
|
];
|
|
63
51
|
},
|
|
64
52
|
};
|