@manuscripts/transform 2.3.38-LEAN-3911.0 → 2.6.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/__tests__/data/project-dump.json +825 -0
- package/dist/cjs/index.js +6 -6
- package/dist/cjs/jats/importer/index.js +22 -0
- package/dist/cjs/jats/importer/{jats-dom-parser.js → jats-body-dom-parser.js} +34 -273
- package/dist/cjs/jats/importer/jats-body-transformations.js +22 -74
- package/dist/cjs/jats/importer/jats-comments.js +104 -27
- package/dist/cjs/jats/importer/jats-front-parser.js +321 -0
- package/dist/cjs/jats/importer/jats-journal-meta-parser.js +1 -8
- package/dist/cjs/jats/importer/jats-parser-utils.js +5 -43
- package/dist/cjs/jats/importer/jats-reference-parser.js +23 -16
- package/dist/cjs/jats/importer/jats-references.js +18 -18
- package/dist/cjs/jats/importer/parse-jats-article.js +79 -40
- package/dist/cjs/jats/index.js +7 -7
- package/dist/cjs/jats/{exporter/jats-exporter.js → jats-exporter.js} +398 -264
- package/dist/cjs/jats/{exporter/jats-versions.js → jats-versions.js} +3 -1
- package/dist/cjs/lib/utils.js +1 -12
- package/dist/cjs/transformer/__tests__/__helpers__/doc.js +37 -0
- package/dist/cjs/transformer/builders.js +219 -0
- package/dist/cjs/transformer/decode.js +898 -0
- package/dist/cjs/transformer/document-object-types.js +31 -0
- package/dist/cjs/transformer/encode.js +674 -0
- package/dist/cjs/{jats/importer/create-article-node.js → transformer/filename.js} +9 -10
- package/dist/cjs/transformer/footnote-category.js +20 -0
- package/dist/cjs/transformer/footnotes-order.js +60 -0
- package/dist/cjs/transformer/highlight-markers.js +138 -0
- package/dist/cjs/transformer/html.js +400 -0
- package/dist/cjs/transformer/id.js +5 -10
- package/dist/cjs/transformer/index.js +18 -0
- package/dist/cjs/{jats/exporter → transformer}/labels.js +5 -4
- package/dist/cjs/transformer/manuscript-dependencies.js +21 -0
- package/dist/cjs/transformer/model-map.js +26 -0
- package/dist/cjs/{lib/deafults.js → transformer/models.js} +1 -3
- package/dist/cjs/transformer/node-names.js +1 -0
- package/dist/cjs/transformer/object-types.js +57 -0
- package/dist/cjs/transformer/project-bundle.js +94 -0
- package/dist/cjs/transformer/serializer.js +23 -0
- package/dist/cjs/transformer/timestamp.js +20 -0
- package/dist/cjs/transformer/update-identifiers.js +93 -0
- package/dist/cjs/version.js +1 -1
- package/dist/es/__tests__/data/project-dump.json +825 -0
- package/dist/es/index.js +5 -5
- package/dist/{types/jats/importer/create-article-node.d.ts → es/jats/importer/index.js} +2 -3
- package/dist/es/jats/importer/{jats-dom-parser.js → jats-body-dom-parser.js} +35 -274
- package/dist/es/jats/importer/jats-body-transformations.js +22 -74
- package/dist/es/jats/importer/jats-comments.js +101 -26
- package/dist/es/jats/importer/jats-front-parser.js +315 -0
- package/dist/es/jats/importer/jats-journal-meta-parser.js +0 -6
- package/dist/es/jats/importer/jats-parser-utils.js +6 -44
- package/dist/es/jats/importer/jats-reference-parser.js +23 -16
- package/dist/es/jats/importer/jats-references.js +18 -18
- package/dist/es/jats/importer/parse-jats-article.js +78 -41
- package/dist/es/jats/index.js +3 -5
- package/dist/es/jats/{exporter/jats-exporter.js → jats-exporter.js} +392 -258
- package/dist/es/jats/{exporter/jats-versions.js → jats-versions.js} +1 -0
- package/dist/es/lib/utils.js +0 -9
- package/dist/es/transformer/__tests__/__helpers__/doc.js +29 -0
- package/dist/es/transformer/builders.js +186 -0
- package/dist/es/transformer/decode.js +888 -0
- package/dist/es/transformer/document-object-types.js +28 -0
- package/dist/es/transformer/encode.js +664 -0
- package/dist/es/transformer/filename.js +23 -0
- package/dist/es/transformer/footnote-category.js +16 -0
- package/dist/es/transformer/footnotes-order.js +55 -0
- package/dist/es/transformer/highlight-markers.js +132 -0
- package/dist/es/transformer/html.js +393 -0
- package/dist/es/transformer/id.js +3 -8
- package/dist/es/transformer/index.js +16 -0
- package/dist/es/{jats/exporter → transformer}/labels.js +5 -4
- package/dist/es/transformer/manuscript-dependencies.js +17 -0
- package/dist/es/transformer/model-map.js +22 -0
- package/dist/es/{lib/deafults.js → transformer/models.js} +2 -2
- package/dist/es/transformer/node-names.js +1 -0
- package/dist/es/transformer/object-types.js +52 -0
- package/dist/es/transformer/project-bundle.js +85 -0
- package/dist/es/transformer/serializer.js +17 -0
- package/dist/es/transformer/timestamp.js +16 -0
- package/dist/es/transformer/update-identifiers.js +87 -0
- package/dist/es/version.js +1 -1
- package/dist/types/index.d.ts +6 -6
- package/dist/types/jats/importer/index.d.ts +16 -0
- package/dist/types/jats/importer/{jats-dom-parser.d.ts → jats-body-dom-parser.d.ts} +1 -1
- package/dist/types/jats/importer/jats-body-transformations.d.ts +1 -5
- package/dist/types/jats/importer/jats-comments.d.ts +10 -4
- package/dist/types/jats/importer/jats-front-parser.d.ts +84 -0
- package/dist/types/jats/importer/jats-journal-meta-parser.d.ts +0 -10
- package/dist/types/jats/importer/jats-references.d.ts +8 -19
- package/dist/types/jats/importer/parse-jats-article.d.ts +5 -12
- package/dist/types/jats/index.d.ts +3 -5
- package/dist/types/jats/{exporter/jats-exporter.d.ts → jats-exporter.d.ts} +29 -15
- package/dist/types/jats/{exporter/jats-versions.d.ts → jats-versions.d.ts} +1 -0
- package/dist/types/lib/utils.d.ts +0 -2
- package/dist/types/schema/nodes/bibliography_item.d.ts +3 -3
- package/dist/types/schema/nodes/contributor.d.ts +0 -10
- package/dist/types/schema/nodes/keyword_group.d.ts +0 -1
- package/dist/types/schema/nodes/manuscript.d.ts +7 -8
- package/dist/types/schema/nodes/title.d.ts +3 -0
- package/dist/types/transformer/__tests__/__helpers__/doc.d.ts +18 -0
- package/dist/types/transformer/builders.d.ts +61 -0
- package/dist/types/transformer/decode.d.ts +52 -0
- package/dist/types/transformer/document-object-types.d.ts +17 -0
- package/dist/types/transformer/encode.d.ts +29 -0
- package/dist/types/transformer/filename.d.ts +16 -0
- package/dist/types/transformer/footnote-category.d.ts +17 -0
- package/dist/{es/jats/importer/create-article-node.js → types/transformer/footnotes-order.d.ts} +8 -10
- package/dist/types/transformer/highlight-markers.d.ts +31 -0
- package/dist/types/transformer/html.d.ts +36 -0
- package/dist/types/transformer/id.d.ts +2 -5
- package/dist/types/transformer/index.d.ts +16 -0
- package/dist/types/{jats/exporter → transformer}/labels.d.ts +2 -2
- package/dist/types/transformer/manuscript-dependencies.d.ts +4 -0
- package/dist/types/transformer/model-map.d.ts +19 -0
- package/dist/types/transformer/models.d.ts +48 -0
- package/dist/types/transformer/object-types.d.ts +30 -0
- package/dist/types/transformer/project-bundle.d.ts +30 -0
- package/dist/types/transformer/serializer.d.ts +19 -0
- package/dist/types/{lib/deafults.d.ts → transformer/timestamp.d.ts} +2 -2
- package/dist/types/transformer/update-identifiers.d.ts +23 -0
- package/dist/types/types.d.ts +2 -0
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -2
- package/dist/cjs/jats/importer/jats-front-transformations.js +0 -79
- package/dist/es/jats/importer/jats-front-transformations.js +0 -76
- package/dist/types/jats/importer/jats-front-transformations.d.ts +0 -22
- package/dist/types/jats/types.d.ts +0 -1
- /package/dist/cjs/{jats/types.js → types.js} +0 -0
- /package/dist/es/{jats/types.js → types.js} +0 -0
package/dist/es/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export * from './errors';
|
|
2
|
-
export { getVersion } from './getVersion';
|
|
3
|
-
export * from './jats';
|
|
4
|
-
export * from './jats/types';
|
|
5
1
|
export * from './lib/section-group-type';
|
|
6
2
|
export * from './lib/table-cell-styles';
|
|
7
3
|
export * from './lib/utils';
|
|
8
4
|
export * from './schema';
|
|
5
|
+
export * from './transformer';
|
|
6
|
+
export * from './jats';
|
|
7
|
+
export * from './types';
|
|
8
|
+
export * from './errors';
|
|
9
|
+
export { getVersion } from './getVersion';
|
|
9
10
|
export { migrateFor } from './schema/migration/migrate';
|
|
10
11
|
export { isSectionLabelNode } from './schema/nodes/section_label';
|
|
11
|
-
export * from './transformer';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* ©
|
|
2
|
+
* © 2020 Atypon Systems LLC
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
* you may not use this file except in compliance with the License.
|
|
@@ -13,5 +13,4 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
|
|
17
|
-
export declare const createArticleNode: (attrs: Partial<ManuscriptAttrs>) => import("prosemirror-model").Node;
|
|
16
|
+
export { parseJATSFront, parseJATSBody, parseJATSArticle, } from './parse-jats-article';
|
|
@@ -13,13 +13,10 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { ObjectTypes } from '@manuscripts/json-schema';
|
|
17
16
|
import mime from 'mime';
|
|
18
17
|
import { DOMParser, Fragment } from 'prosemirror-model';
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import { chooseSectionCategory, generateID } from '../../transformer';
|
|
22
|
-
import { DEFAULT_PROFILE_ID } from './jats-comments';
|
|
18
|
+
import { schema } from '../../schema';
|
|
19
|
+
import { chooseSectionCategory } from '../../transformer';
|
|
23
20
|
const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
|
|
24
21
|
const chooseContentType = (graphicNode) => {
|
|
25
22
|
if (graphicNode) {
|
|
@@ -34,12 +31,6 @@ const chooseContentType = (graphicNode) => {
|
|
|
34
31
|
}
|
|
35
32
|
}
|
|
36
33
|
};
|
|
37
|
-
const parsePriority = (priority) => {
|
|
38
|
-
if (!priority) {
|
|
39
|
-
return undefined;
|
|
40
|
-
}
|
|
41
|
-
return parseInt(priority);
|
|
42
|
-
};
|
|
43
34
|
const getEquationContent = (p) => {
|
|
44
35
|
var _a;
|
|
45
36
|
const element = p;
|
|
@@ -104,224 +95,6 @@ const marks = [
|
|
|
104
95
|
},
|
|
105
96
|
];
|
|
106
97
|
const nodes = [
|
|
107
|
-
{
|
|
108
|
-
tag: 'article',
|
|
109
|
-
node: 'manuscript',
|
|
110
|
-
getAttrs: (node) => {
|
|
111
|
-
var _a, _b, _c, _d;
|
|
112
|
-
const element = node;
|
|
113
|
-
return {
|
|
114
|
-
doi: (_a = element.getAttribute('DOI')) !== null && _a !== void 0 ? _a : '',
|
|
115
|
-
articleType: (_b = element.getAttribute('article-type')) !== null && _b !== void 0 ? _b : '',
|
|
116
|
-
prototype: (_c = element.getAttribute('prototype')) !== null && _c !== void 0 ? _c : '',
|
|
117
|
-
primaryLanguageCode: (_d = element.getAttribute('primary-language-code')) !== null && _d !== void 0 ? _d : '',
|
|
118
|
-
};
|
|
119
|
-
},
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
tag: 'article-title',
|
|
123
|
-
node: 'title',
|
|
124
|
-
getAttrs: (node) => {
|
|
125
|
-
const element = node;
|
|
126
|
-
return {
|
|
127
|
-
id: element.getAttribute('id'),
|
|
128
|
-
};
|
|
129
|
-
},
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
tag: 'highlight-marker',
|
|
133
|
-
node: 'highlight_marker',
|
|
134
|
-
getAttrs: (node) => {
|
|
135
|
-
var _a;
|
|
136
|
-
const element = node;
|
|
137
|
-
const id = element.getAttribute('id');
|
|
138
|
-
return {
|
|
139
|
-
id: id,
|
|
140
|
-
position: (_a = element.getAttribute('position')) !== null && _a !== void 0 ? _a : '',
|
|
141
|
-
};
|
|
142
|
-
},
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
tag: 'comment-annotation',
|
|
146
|
-
node: 'comment',
|
|
147
|
-
getAttrs: (node) => {
|
|
148
|
-
const element = node;
|
|
149
|
-
return {
|
|
150
|
-
id: element.getAttribute('id'),
|
|
151
|
-
contents: element.textContent,
|
|
152
|
-
contributions: [
|
|
153
|
-
{
|
|
154
|
-
_id: generateID(ObjectTypes.Contribution),
|
|
155
|
-
objecType: ObjectTypes.Contribution,
|
|
156
|
-
profileID: DEFAULT_PROFILE_ID,
|
|
157
|
-
timestamp: timestamp(),
|
|
158
|
-
},
|
|
159
|
-
],
|
|
160
|
-
};
|
|
161
|
-
},
|
|
162
|
-
},
|
|
163
|
-
{
|
|
164
|
-
tag: 'author-notes',
|
|
165
|
-
node: 'author_notes',
|
|
166
|
-
getAttrs: (node) => {
|
|
167
|
-
const element = node;
|
|
168
|
-
return {
|
|
169
|
-
id: element.getAttribute('id'),
|
|
170
|
-
};
|
|
171
|
-
},
|
|
172
|
-
},
|
|
173
|
-
{
|
|
174
|
-
tag: 'fn:not([fn-type])',
|
|
175
|
-
node: 'footnote',
|
|
176
|
-
context: 'author_notes/',
|
|
177
|
-
getAttrs: (node) => {
|
|
178
|
-
const element = node;
|
|
179
|
-
return {
|
|
180
|
-
id: element.getAttribute('id'),
|
|
181
|
-
kind: 'footnote',
|
|
182
|
-
};
|
|
183
|
-
},
|
|
184
|
-
},
|
|
185
|
-
{
|
|
186
|
-
tag: 'corresp',
|
|
187
|
-
node: 'corresp',
|
|
188
|
-
getAttrs: (node) => {
|
|
189
|
-
var _a;
|
|
190
|
-
const element = node;
|
|
191
|
-
const label = element.querySelector('label');
|
|
192
|
-
if (label) {
|
|
193
|
-
label.remove();
|
|
194
|
-
}
|
|
195
|
-
return {
|
|
196
|
-
id: element.getAttribute('id'),
|
|
197
|
-
label: (_a = label === null || label === void 0 ? void 0 : label.textContent) === null || _a === void 0 ? void 0 : _a.trim(),
|
|
198
|
-
};
|
|
199
|
-
},
|
|
200
|
-
getContent: (node) => {
|
|
201
|
-
var _a;
|
|
202
|
-
const element = node;
|
|
203
|
-
return Fragment.from(schema.text(((_a = element.textContent) === null || _a === void 0 ? void 0 : _a.trim()) || ''));
|
|
204
|
-
},
|
|
205
|
-
},
|
|
206
|
-
{
|
|
207
|
-
tag: 'contrib[contrib-type="author"]',
|
|
208
|
-
node: 'contributor',
|
|
209
|
-
getAttrs: (node) => {
|
|
210
|
-
var _a, _b;
|
|
211
|
-
const element = node;
|
|
212
|
-
const footnote = [];
|
|
213
|
-
const affiliations = [];
|
|
214
|
-
const corresp = [];
|
|
215
|
-
const xrefs = element.querySelectorAll('xref');
|
|
216
|
-
for (const xref of xrefs) {
|
|
217
|
-
const rid = xref.getAttribute('rid');
|
|
218
|
-
const type = xref.getAttribute('ref-type');
|
|
219
|
-
if (!rid) {
|
|
220
|
-
continue;
|
|
221
|
-
}
|
|
222
|
-
switch (type) {
|
|
223
|
-
case 'fn':
|
|
224
|
-
footnote.push({
|
|
225
|
-
noteID: rid,
|
|
226
|
-
noteLabel: ((_a = xref.textContent) === null || _a === void 0 ? void 0 : _a.trim()) || '',
|
|
227
|
-
});
|
|
228
|
-
break;
|
|
229
|
-
case 'corresp':
|
|
230
|
-
corresp.push({
|
|
231
|
-
correspID: rid,
|
|
232
|
-
correspLabel: ((_b = xref.textContent) === null || _b === void 0 ? void 0 : _b.trim()) || '',
|
|
233
|
-
});
|
|
234
|
-
break;
|
|
235
|
-
case 'aff':
|
|
236
|
-
affiliations.push(rid);
|
|
237
|
-
break;
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
return {
|
|
241
|
-
id: element.getAttribute('id'),
|
|
242
|
-
role: 'author',
|
|
243
|
-
affiliations,
|
|
244
|
-
corresp,
|
|
245
|
-
footnote,
|
|
246
|
-
isCorresponding: element.getAttribute('corresp')
|
|
247
|
-
? element.getAttribute('corresp') === 'yes'
|
|
248
|
-
: undefined,
|
|
249
|
-
bibliographicName: {
|
|
250
|
-
given: getTrimmedTextContent(element, 'name > given-names'),
|
|
251
|
-
family: getTrimmedTextContent(element, 'name > surname'),
|
|
252
|
-
ObjectType: ObjectTypes.BibliographicName,
|
|
253
|
-
_id: generateID(ObjectTypes.BibliographicName),
|
|
254
|
-
},
|
|
255
|
-
ORCIDIdentifier: getTrimmedTextContent(element, 'contrib-id[contrib-id-type="orcid"]'),
|
|
256
|
-
priority: parsePriority(element.getAttribute('priority')),
|
|
257
|
-
};
|
|
258
|
-
},
|
|
259
|
-
getContent: () => {
|
|
260
|
-
return Fragment.from(schema.text('_'));
|
|
261
|
-
},
|
|
262
|
-
},
|
|
263
|
-
{
|
|
264
|
-
tag: 'affiliations',
|
|
265
|
-
node: 'affiliations',
|
|
266
|
-
},
|
|
267
|
-
{
|
|
268
|
-
tag: 'aff',
|
|
269
|
-
node: 'affiliation',
|
|
270
|
-
context: 'affiliations/',
|
|
271
|
-
getAttrs: (node) => {
|
|
272
|
-
var _a, _b;
|
|
273
|
-
const element = node;
|
|
274
|
-
const getEmail = (element) => {
|
|
275
|
-
var _a, _b, _c;
|
|
276
|
-
const email = element.querySelector('email');
|
|
277
|
-
if (email) {
|
|
278
|
-
return {
|
|
279
|
-
href: (_a = email.getAttributeNS(XLINK_NAMESPACE, 'href')) !== null && _a !== void 0 ? _a : '',
|
|
280
|
-
text: (_c = (_b = email.textContent) === null || _b === void 0 ? void 0 : _b.trim()) !== null && _c !== void 0 ? _c : '',
|
|
281
|
-
};
|
|
282
|
-
}
|
|
283
|
-
};
|
|
284
|
-
const getInstitutionDetails = (element) => {
|
|
285
|
-
var _a;
|
|
286
|
-
let department = '';
|
|
287
|
-
let institution = '';
|
|
288
|
-
for (const node of element.querySelectorAll('institution')) {
|
|
289
|
-
const content = (_a = node.textContent) === null || _a === void 0 ? void 0 : _a.trim();
|
|
290
|
-
if (!content) {
|
|
291
|
-
continue;
|
|
292
|
-
}
|
|
293
|
-
const type = node.getAttribute('content-type');
|
|
294
|
-
if (type === 'dept') {
|
|
295
|
-
department = content;
|
|
296
|
-
}
|
|
297
|
-
else {
|
|
298
|
-
institution = content;
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
return { department, institution };
|
|
302
|
-
};
|
|
303
|
-
const getAddressLine = (element, index) => {
|
|
304
|
-
return (getTrimmedTextContent(element, `addr-line:nth-of-type(${index})`) ||
|
|
305
|
-
'');
|
|
306
|
-
};
|
|
307
|
-
const { department, institution } = getInstitutionDetails(element);
|
|
308
|
-
return {
|
|
309
|
-
id: element.getAttribute('id'),
|
|
310
|
-
institution: institution !== null && institution !== void 0 ? institution : '',
|
|
311
|
-
department: department !== null && department !== void 0 ? department : '',
|
|
312
|
-
addressLine1: getAddressLine(element, 1),
|
|
313
|
-
addressLine2: getAddressLine(element, 2),
|
|
314
|
-
addressLine3: getAddressLine(element, 3),
|
|
315
|
-
postCode: (_a = getTrimmedTextContent(element, 'postal-code')) !== null && _a !== void 0 ? _a : '',
|
|
316
|
-
country: (_b = getTrimmedTextContent(element, 'country')) !== null && _b !== void 0 ? _b : '',
|
|
317
|
-
email: getEmail(element),
|
|
318
|
-
priority: parsePriority(element.getAttribute('priority')),
|
|
319
|
-
};
|
|
320
|
-
},
|
|
321
|
-
getContent: () => {
|
|
322
|
-
return Fragment.from(schema.text('_'));
|
|
323
|
-
},
|
|
324
|
-
},
|
|
325
98
|
{
|
|
326
99
|
tag: 'attrib',
|
|
327
100
|
node: 'attribution',
|
|
@@ -330,6 +103,10 @@ const nodes = [
|
|
|
330
103
|
tag: 'back',
|
|
331
104
|
ignore: true,
|
|
332
105
|
},
|
|
106
|
+
{
|
|
107
|
+
tag: 'body',
|
|
108
|
+
node: 'manuscript',
|
|
109
|
+
},
|
|
333
110
|
{
|
|
334
111
|
tag: 'break',
|
|
335
112
|
node: 'hard_break',
|
|
@@ -349,13 +126,13 @@ const nodes = [
|
|
|
349
126
|
const title = element.querySelector('title');
|
|
350
127
|
if (title) {
|
|
351
128
|
const captionTitle = schema.nodes.caption_title.create();
|
|
352
|
-
content.push(
|
|
129
|
+
content.push(jatsBodyDOMParser.parse(title, { topNode: captionTitle }));
|
|
353
130
|
}
|
|
354
131
|
const paragraphs = element.querySelectorAll('p');
|
|
355
132
|
if (paragraphs.length) {
|
|
356
133
|
const figcaption = schema.nodes.caption.create();
|
|
357
134
|
for (const paragraph of paragraphs) {
|
|
358
|
-
content.push(
|
|
135
|
+
content.push(jatsBodyDOMParser.parse(paragraph, { topNode: figcaption }));
|
|
359
136
|
}
|
|
360
137
|
}
|
|
361
138
|
return Fragment.from(content);
|
|
@@ -366,6 +143,17 @@ const nodes = [
|
|
|
366
143
|
node: 'figcaption',
|
|
367
144
|
context: 'table_element/',
|
|
368
145
|
},
|
|
146
|
+
{
|
|
147
|
+
tag: 'caption',
|
|
148
|
+
node: 'figcaption',
|
|
149
|
+
context: 'box_element/',
|
|
150
|
+
getAttrs: (node) => {
|
|
151
|
+
const element = node;
|
|
152
|
+
return {
|
|
153
|
+
id: element.getAttribute('id'),
|
|
154
|
+
};
|
|
155
|
+
},
|
|
156
|
+
},
|
|
369
157
|
{
|
|
370
158
|
tag: 'code',
|
|
371
159
|
node: 'listing',
|
|
@@ -546,7 +334,7 @@ const nodes = [
|
|
|
546
334
|
const paragraphs = [];
|
|
547
335
|
node.childNodes.forEach((p) => {
|
|
548
336
|
const paragraph = schema.nodes.paragraph.create();
|
|
549
|
-
const content =
|
|
337
|
+
const content = jatsBodyDOMParser.parse(p, {
|
|
550
338
|
topNode: paragraph,
|
|
551
339
|
});
|
|
552
340
|
paragraphs.push(content);
|
|
@@ -646,50 +434,14 @@ const nodes = [
|
|
|
646
434
|
node: 'backmatter',
|
|
647
435
|
},
|
|
648
436
|
{
|
|
649
|
-
tag: '
|
|
650
|
-
node: '
|
|
651
|
-
getAttrs: (node) => {
|
|
652
|
-
const element = node;
|
|
653
|
-
return {
|
|
654
|
-
id: element.getAttribute('id'),
|
|
655
|
-
};
|
|
656
|
-
},
|
|
657
|
-
},
|
|
658
|
-
{
|
|
659
|
-
tag: 'bibliography-item',
|
|
660
|
-
node: 'bibliography_item',
|
|
437
|
+
tag: 'sec[sec-type="box-element"]',
|
|
438
|
+
node: 'box_element',
|
|
661
439
|
getAttrs: (node) => {
|
|
440
|
+
var _a;
|
|
662
441
|
const element = node;
|
|
663
|
-
const authors = [];
|
|
664
|
-
element.querySelectorAll('author').forEach((author) => {
|
|
665
|
-
authors.push({
|
|
666
|
-
_id: author.getAttribute('id') || '',
|
|
667
|
-
given: author.getAttribute('given') || '',
|
|
668
|
-
family: author.getAttribute('family') || '',
|
|
669
|
-
objectType: 'MPBibliographicName',
|
|
670
|
-
});
|
|
671
|
-
});
|
|
672
|
-
const issuedEl = element.querySelector('issued');
|
|
673
|
-
const issued = issuedEl
|
|
674
|
-
? {
|
|
675
|
-
objectType: 'MPBibliographicDate',
|
|
676
|
-
_id: issuedEl.getAttribute('id'),
|
|
677
|
-
'date-parts': [[issuedEl.getAttribute('year')]],
|
|
678
|
-
}
|
|
679
|
-
: undefined;
|
|
680
442
|
return {
|
|
681
443
|
id: element.getAttribute('id'),
|
|
682
|
-
|
|
683
|
-
containerTitle: element.getAttribute('container-title'),
|
|
684
|
-
volume: element.getAttribute('volume'),
|
|
685
|
-
issue: element.getAttribute('issue'),
|
|
686
|
-
supplement: element.getAttribute('supplement'),
|
|
687
|
-
page: element.getAttribute('page'),
|
|
688
|
-
title: element.getAttribute('title'),
|
|
689
|
-
literal: element.getAttribute('literal'),
|
|
690
|
-
author: authors,
|
|
691
|
-
issued,
|
|
692
|
-
DOI: element.getAttribute('DOI'),
|
|
444
|
+
label: (_a = element.querySelector('label')) === null || _a === void 0 ? void 0 : _a.textContent,
|
|
693
445
|
};
|
|
694
446
|
},
|
|
695
447
|
},
|
|
@@ -725,6 +477,15 @@ const nodes = [
|
|
|
725
477
|
context: 'keyword_group//',
|
|
726
478
|
node: 'keyword',
|
|
727
479
|
},
|
|
480
|
+
{
|
|
481
|
+
tag: 'label',
|
|
482
|
+
context: 'box_element/',
|
|
483
|
+
ignore: true,
|
|
484
|
+
},
|
|
485
|
+
{
|
|
486
|
+
tag: 'boxed-text',
|
|
487
|
+
ignore: true,
|
|
488
|
+
},
|
|
728
489
|
{
|
|
729
490
|
tag: 'label',
|
|
730
491
|
context: 'section/',
|
|
@@ -763,7 +524,7 @@ const nodes = [
|
|
|
763
524
|
{
|
|
764
525
|
tag: 'title',
|
|
765
526
|
node: 'section_title',
|
|
766
|
-
context: 'section/|footnotes_section/|bibliography_section/|keywords/|supplements
|
|
527
|
+
context: 'section/|footnotes_section/|bibliography_section/|keywords/|supplements/',
|
|
767
528
|
},
|
|
768
529
|
{
|
|
769
530
|
tag: 'title',
|
|
@@ -845,4 +606,4 @@ const nodes = [
|
|
|
845
606
|
},
|
|
846
607
|
},
|
|
847
608
|
];
|
|
848
|
-
export const
|
|
609
|
+
export const jatsBodyDOMParser = new DOMParser(schema, [...marks, ...nodes]);
|
|
@@ -153,6 +153,25 @@ export const jatsBodyTransformations = {
|
|
|
153
153
|
group.appendChild(sec);
|
|
154
154
|
}
|
|
155
155
|
},
|
|
156
|
+
createBoxedElementSection(doc, body, createElement) {
|
|
157
|
+
const boxedTexts = body.querySelectorAll('boxed-text');
|
|
158
|
+
for (const boxedText of boxedTexts) {
|
|
159
|
+
const boxElementSec = createElement('sec');
|
|
160
|
+
boxElementSec.setAttribute('sec-type', 'box-element');
|
|
161
|
+
const title = createElement('title');
|
|
162
|
+
title.textContent = 'BoxElement';
|
|
163
|
+
boxElementSec.append(title);
|
|
164
|
+
for (const element of [...boxedText.children]) {
|
|
165
|
+
if ((element === null || element === void 0 ? void 0 : element.tagName) === 'label' || (element === null || element === void 0 ? void 0 : element.tagName) === 'caption') {
|
|
166
|
+
boxElementSec.append(element);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
const containerSection = createElement('sec');
|
|
170
|
+
containerSection.append(...boxedText.children);
|
|
171
|
+
boxElementSec.append(containerSection);
|
|
172
|
+
boxedText.replaceWith(boxElementSec);
|
|
173
|
+
}
|
|
174
|
+
},
|
|
156
175
|
createBody(doc, body, createElement) {
|
|
157
176
|
const group = createSectionGroup(bodyType, createElement);
|
|
158
177
|
this.wrapBodySections(doc, group);
|
|
@@ -218,7 +237,9 @@ export const jatsBodyTransformations = {
|
|
|
218
237
|
moveCaptionsToEnd(body) {
|
|
219
238
|
const captions = body.querySelectorAll('caption');
|
|
220
239
|
for (const caption of captions) {
|
|
221
|
-
if (caption.parentNode &&
|
|
240
|
+
if (caption.parentNode &&
|
|
241
|
+
caption.parentNode.nodeName !== 'table-wrap' &&
|
|
242
|
+
caption.parentNode.nodeName !== 'boxed-text') {
|
|
222
243
|
caption.parentNode.appendChild(caption);
|
|
223
244
|
}
|
|
224
245
|
}
|
|
@@ -299,77 +320,4 @@ export const jatsBodyTransformations = {
|
|
|
299
320
|
body.prepend(section);
|
|
300
321
|
}
|
|
301
322
|
},
|
|
302
|
-
moveReferencesToBackmatter(body, references, createElement) {
|
|
303
|
-
const backmatter = body.querySelector('sec[sec-type="backmatter"]');
|
|
304
|
-
if (!references || !references.items.size || !backmatter) {
|
|
305
|
-
return;
|
|
306
|
-
}
|
|
307
|
-
const bibliographySection = this.createBibliographySection(createElement);
|
|
308
|
-
const bibliographyElement = createElement('bibliography-element');
|
|
309
|
-
references.getBibliographyItems().forEach((item) => {
|
|
310
|
-
const bibliographyItem = this.createBibliographyItem(item, createElement);
|
|
311
|
-
bibliographyElement.appendChild(bibliographyItem);
|
|
312
|
-
});
|
|
313
|
-
bibliographySection.appendChild(bibliographyElement);
|
|
314
|
-
backmatter.appendChild(bibliographySection);
|
|
315
|
-
},
|
|
316
|
-
createBibliographySection(createElement) {
|
|
317
|
-
const section = createElement('sec');
|
|
318
|
-
section.setAttribute('sec-type', 'bibliography_section');
|
|
319
|
-
const title = createElement('title');
|
|
320
|
-
title.textContent = 'References';
|
|
321
|
-
section.appendChild(title);
|
|
322
|
-
return section;
|
|
323
|
-
},
|
|
324
|
-
createBibliographyItem(item, createElement) {
|
|
325
|
-
var _a, _b, _c;
|
|
326
|
-
const bibliographyItem = createElement('bibliography-item');
|
|
327
|
-
bibliographyItem.setAttribute('id', item.id);
|
|
328
|
-
bibliographyItem.setAttribute('type', item.type);
|
|
329
|
-
(_a = item.author) === null || _a === void 0 ? void 0 : _a.forEach((author) => {
|
|
330
|
-
const authorElement = createElement('author');
|
|
331
|
-
authorElement.setAttribute('id', author._id);
|
|
332
|
-
authorElement.setAttribute('family', author.family || '');
|
|
333
|
-
authorElement.setAttribute('given', author.given || '');
|
|
334
|
-
bibliographyItem.appendChild(authorElement);
|
|
335
|
-
});
|
|
336
|
-
if (item.issued) {
|
|
337
|
-
const issuedEl = createElement('issued');
|
|
338
|
-
issuedEl.setAttribute('id', ((_b = item.issued) === null || _b === void 0 ? void 0 : _b._id) || '');
|
|
339
|
-
const dateParts = item.issued['date-parts'];
|
|
340
|
-
const year = (_c = dateParts === null || dateParts === void 0 ? void 0 : dateParts[0]) === null || _c === void 0 ? void 0 : _c[0];
|
|
341
|
-
if (year) {
|
|
342
|
-
issuedEl.setAttribute('year', year.toString());
|
|
343
|
-
}
|
|
344
|
-
bibliographyItem.appendChild(issuedEl);
|
|
345
|
-
}
|
|
346
|
-
if (item.containerTitle) {
|
|
347
|
-
bibliographyItem.setAttribute('containerTitle', item.containerTitle);
|
|
348
|
-
}
|
|
349
|
-
if (item.volume) {
|
|
350
|
-
bibliographyItem.setAttribute('volume', item.volume.toString());
|
|
351
|
-
}
|
|
352
|
-
if (item.issue) {
|
|
353
|
-
bibliographyItem.setAttribute('issue', item.issue.toString());
|
|
354
|
-
}
|
|
355
|
-
if (item.supplement) {
|
|
356
|
-
bibliographyItem.setAttribute('supplement', item.supplement);
|
|
357
|
-
}
|
|
358
|
-
if (item.page) {
|
|
359
|
-
bibliographyItem.setAttribute('page', item.page.toString());
|
|
360
|
-
}
|
|
361
|
-
if (item.title) {
|
|
362
|
-
bibliographyItem.setAttribute('title', item.title);
|
|
363
|
-
}
|
|
364
|
-
if (item.literal) {
|
|
365
|
-
bibliographyItem.setAttribute('literal', item.literal);
|
|
366
|
-
}
|
|
367
|
-
if (item.doi) {
|
|
368
|
-
bibliographyItem.setAttribute('DOI', item.doi);
|
|
369
|
-
}
|
|
370
|
-
if (item.literal) {
|
|
371
|
-
bibliographyItem.setAttribute('literal', item.literal);
|
|
372
|
-
}
|
|
373
|
-
return bibliographyItem;
|
|
374
|
-
},
|
|
375
323
|
};
|