@manuscripts/transform 1.5.7 → 1.5.8-LEAN-3030
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 +33 -54
- package/dist/cjs/lib/section-group-type.js +30 -0
- package/dist/cjs/lib/utils.js +23 -1
- 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 +143 -162
- package/dist/cjs/transformer/encode.js +54 -45
- package/dist/cjs/transformer/highlight-markers.js +4 -4
- package/dist/cjs/transformer/html.js +5 -20
- 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 +35 -17
- 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 +33 -54
- package/dist/es/lib/section-group-type.js +27 -0
- package/dist/es/lib/utils.js +20 -0
- 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 +143 -161
- package/dist/es/transformer/encode.js +57 -48
- package/dist/es/transformer/highlight-markers.js +1 -1
- package/dist/es/transformer/html.js +5 -20
- 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 +33 -15
- 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 +31 -0
- package/dist/types/lib/utils.d.ts +4 -1
- 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 +7 -9
- package/dist/types/transformer/encode.d.ts +1 -1
- package/dist/types/transformer/highlight-markers.d.ts +1 -0
- package/dist/types/transformer/object-types.d.ts +1 -2
- package/dist/types/transformer/section-category.d.ts +1 -1
- package/package.json +1 -1
- 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
|
@@ -15,10 +15,11 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { DOMSerializer } from 'prosemirror-model';
|
|
17
17
|
import serializeToXML from 'w3c-xmlserializer';
|
|
18
|
-
import { iterateChildren } from '../lib/utils';
|
|
19
|
-
import { hasGroup, isHighlightMarkerNode, isSectionNode, schema, } from '../schema';
|
|
20
|
-
import { buildAttribution } from './builders';
|
|
18
|
+
import { iterateChildren, modelsEqual } from '../lib/utils';
|
|
19
|
+
import { hasGroup, isHighlightMarkerNode, isManuscriptNode, isSectionNode, schema, } from '../schema';
|
|
20
|
+
import { auxiliaryObjectTypes, buildAttribution, buildElementsOrder, } from './builders';
|
|
21
21
|
import { extractHighlightMarkers, isHighlightableModel, } from './highlight-markers';
|
|
22
|
+
import { generateID } from './id';
|
|
22
23
|
import { nodeTypesMap } from './node-types';
|
|
23
24
|
import { buildSectionCategory } from './section-category';
|
|
24
25
|
const serializer = DOMSerializer.fromSchema(schema);
|
|
@@ -420,34 +421,9 @@ const encoders = {
|
|
|
420
421
|
elementType: 'div',
|
|
421
422
|
paragraphStyle: node.attrs.paragraphStyle || undefined,
|
|
422
423
|
}),
|
|
423
|
-
|
|
424
|
+
keyword_group: (node) => ({
|
|
424
425
|
type: node.attrs.type,
|
|
425
426
|
}),
|
|
426
|
-
keywords_section: (node, parent, path, priority) => ({
|
|
427
|
-
category: buildSectionCategory(node),
|
|
428
|
-
priority: priority.value++,
|
|
429
|
-
title: inlineContentsOfNodeType(node, node.type.schema.nodes.section_title),
|
|
430
|
-
path: path.concat([node.attrs.id]),
|
|
431
|
-
elementIDs: childElements(node)
|
|
432
|
-
.map((childNode) => childNode.attrs.id)
|
|
433
|
-
.filter((id) => id),
|
|
434
|
-
}),
|
|
435
|
-
affiliations_section: (node, parent, path, priority) => ({
|
|
436
|
-
category: buildSectionCategory(node),
|
|
437
|
-
priority: priority.value++,
|
|
438
|
-
path: path.concat([node.attrs.id]),
|
|
439
|
-
elementIDs: childElements(node)
|
|
440
|
-
.map((childNode) => childNode.attrs.id)
|
|
441
|
-
.filter((id) => id),
|
|
442
|
-
}),
|
|
443
|
-
contributors_section: (node, parent, path, priority) => ({
|
|
444
|
-
category: buildSectionCategory(node),
|
|
445
|
-
priority: priority.value++,
|
|
446
|
-
path: path.concat([node.attrs.id]),
|
|
447
|
-
elementIDs: childElements(node)
|
|
448
|
-
.map((childNode) => childNode.attrs.id)
|
|
449
|
-
.filter((id) => id),
|
|
450
|
-
}),
|
|
451
427
|
missing_figure: (node) => ({
|
|
452
428
|
position: node.attrs.position || undefined,
|
|
453
429
|
}),
|
|
@@ -568,28 +544,48 @@ export const modelFromNode = (node, parent, path, priority) => {
|
|
|
568
544
|
const comments = [...commentAnnotationsMap.values()];
|
|
569
545
|
return { model, comments };
|
|
570
546
|
};
|
|
571
|
-
|
|
547
|
+
const containerTypes = [
|
|
548
|
+
schema.nodes.affiliations,
|
|
549
|
+
schema.nodes.contributors,
|
|
550
|
+
schema.nodes.affiliations,
|
|
551
|
+
schema.nodes.keywords,
|
|
552
|
+
schema.nodes.abstracts,
|
|
553
|
+
schema.nodes.body,
|
|
554
|
+
schema.nodes.backmatter,
|
|
555
|
+
schema.nodes.comments,
|
|
556
|
+
];
|
|
557
|
+
export const encode = (node, preserveWithRepeatedID = false) => {
|
|
572
558
|
const models = new Map();
|
|
573
559
|
const priority = {
|
|
574
560
|
value: 1,
|
|
575
561
|
};
|
|
576
562
|
const placeholders = ['placeholder', 'placeholder_element'];
|
|
577
|
-
const
|
|
563
|
+
const processNode = (path, parent) => (child) => {
|
|
564
|
+
if (containerTypes.includes(child.type)) {
|
|
565
|
+
child.forEach(processNode([], child));
|
|
566
|
+
return;
|
|
567
|
+
}
|
|
578
568
|
if (!child.attrs.id) {
|
|
579
569
|
return;
|
|
580
570
|
}
|
|
581
571
|
if (isHighlightMarkerNode(child)) {
|
|
582
572
|
return;
|
|
583
573
|
}
|
|
584
|
-
if (child.type
|
|
574
|
+
if (placeholders.includes(child.type.name)) {
|
|
585
575
|
return;
|
|
586
576
|
}
|
|
587
|
-
if (
|
|
577
|
+
if (parent.type === schema.nodes.paragraph) {
|
|
588
578
|
return;
|
|
589
579
|
}
|
|
590
580
|
const { model, comments } = modelFromNode(child, parent, path, priority);
|
|
591
|
-
|
|
592
|
-
|
|
581
|
+
const existingModel = models.get(model._id);
|
|
582
|
+
if (existingModel) {
|
|
583
|
+
if (preserveWithRepeatedID && !modelsEqual(model, existingModel)) {
|
|
584
|
+
model._id = generateID(model.objectType);
|
|
585
|
+
}
|
|
586
|
+
else {
|
|
587
|
+
throw Error(`Encountered duplicate ids in models map while encoding: ${model._id}`);
|
|
588
|
+
}
|
|
593
589
|
}
|
|
594
590
|
comments.forEach((comment) => {
|
|
595
591
|
const proseMirrorComment = models.get(comment._id);
|
|
@@ -600,22 +596,35 @@ export const encode = (node) => {
|
|
|
600
596
|
}
|
|
601
597
|
});
|
|
602
598
|
models.set(model._id, model);
|
|
603
|
-
child.forEach(
|
|
599
|
+
child.forEach(processNode(path.concat(child.attrs.id), child));
|
|
604
600
|
};
|
|
605
|
-
node.forEach((
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
601
|
+
node.forEach(processNode([], node));
|
|
602
|
+
if (isManuscriptNode(node)) {
|
|
603
|
+
auxiliaryObjectTypes.forEach((t) => {
|
|
604
|
+
const order = generateElementOrder(node, t);
|
|
605
|
+
if (order) {
|
|
606
|
+
models.set(order._id, order);
|
|
607
|
+
}
|
|
608
|
+
});
|
|
609
|
+
}
|
|
611
610
|
return models;
|
|
612
611
|
};
|
|
613
|
-
const
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
models.set(model._id, model);
|
|
612
|
+
const generateElementOrder = (node, nodeType) => {
|
|
613
|
+
const ids = [];
|
|
614
|
+
node.descendants((n) => {
|
|
615
|
+
if (n.type === nodeType) {
|
|
616
|
+
ids.push(n.attrs.id);
|
|
619
617
|
}
|
|
618
|
+
return true;
|
|
620
619
|
});
|
|
620
|
+
if (!ids.length) {
|
|
621
|
+
return undefined;
|
|
622
|
+
}
|
|
623
|
+
const type = nodeTypesMap.get(nodeType);
|
|
624
|
+
if (!type) {
|
|
625
|
+
return undefined;
|
|
626
|
+
}
|
|
627
|
+
const order = buildElementsOrder(type);
|
|
628
|
+
order.elements = ids;
|
|
629
|
+
return order;
|
|
621
630
|
};
|
|
@@ -194,11 +194,9 @@ export class HTMLTransformer {
|
|
|
194
194
|
const citationNode = node;
|
|
195
195
|
const element = this.document.createElement('span');
|
|
196
196
|
element.setAttribute('class', 'citation');
|
|
197
|
-
const
|
|
198
|
-
if (
|
|
199
|
-
element.setAttribute('data-reference-ids',
|
|
200
|
-
.map((item) => item.bibliographyItem)
|
|
201
|
-
.join(' '));
|
|
197
|
+
const rids = citationNode.attrs.rids;
|
|
198
|
+
if (rids.length) {
|
|
199
|
+
element.setAttribute('data-reference-ids', rids.join(' '));
|
|
202
200
|
}
|
|
203
201
|
if (citationNode.attrs.contents) {
|
|
204
202
|
element.innerHTML = citationNode.attrs.contents;
|
|
@@ -209,20 +207,7 @@ export class HTMLTransformer {
|
|
|
209
207
|
const crossReferenceNode = node;
|
|
210
208
|
const element = this.document.createElement('a');
|
|
211
209
|
element.classList.add('cross-reference');
|
|
212
|
-
|
|
213
|
-
if (auxiliaryObjectReference &&
|
|
214
|
-
auxiliaryObjectReference.referencedObject) {
|
|
215
|
-
if (auxiliaryObjectReference.referencedObject.startsWith('MPFigureElement')) {
|
|
216
|
-
const model = getModel(auxiliaryObjectReference.referencedObject);
|
|
217
|
-
if (model && model.containedObjectIDs.length > 0) {
|
|
218
|
-
element.setAttribute('href', `#${model.containedObjectIDs[0]}`);
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
else {
|
|
222
|
-
element.setAttribute('href', `#${auxiliaryObjectReference.referencedObject}`);
|
|
223
|
-
}
|
|
224
|
-
element.setAttribute('data-reference-ids', crossReferenceNode.attrs.rid);
|
|
225
|
-
}
|
|
210
|
+
element.setAttribute('data-reference-ids', crossReferenceNode.attrs.rids.join(' '));
|
|
226
211
|
element.textContent =
|
|
227
212
|
crossReferenceNode.attrs.customLabel || crossReferenceNode.attrs.label;
|
|
228
213
|
return element;
|
|
@@ -256,7 +241,7 @@ export class HTMLTransformer {
|
|
|
256
241
|
};
|
|
257
242
|
return ['span', attrs];
|
|
258
243
|
};
|
|
259
|
-
nodes.
|
|
244
|
+
nodes.comments = () => '';
|
|
260
245
|
const serializer = new DOMSerializer(nodes, marks);
|
|
261
246
|
return serializer.serializeFragment(fragment, { document });
|
|
262
247
|
};
|
|
@@ -35,6 +35,6 @@ export const nodeNames = new Map([
|
|
|
35
35
|
[schema.nodes.table_element, 'Table'],
|
|
36
36
|
[schema.nodes.blockquote_element, 'Block Quote'],
|
|
37
37
|
[schema.nodes.pullquote_element, 'Pull Quote'],
|
|
38
|
-
[schema.nodes.
|
|
38
|
+
[schema.nodes.keywords, 'Section'],
|
|
39
39
|
[schema.nodes.toc_section, 'Section'],
|
|
40
40
|
]);
|
|
@@ -47,7 +47,7 @@ export const nodeTitle = (node) => {
|
|
|
47
47
|
case nodes.section:
|
|
48
48
|
case nodes.bibliography_section:
|
|
49
49
|
case nodes.footnotes_section:
|
|
50
|
-
case nodes.
|
|
50
|
+
case nodes.keywords:
|
|
51
51
|
case nodes.toc_section:
|
|
52
52
|
case nodes.graphical_abstract_section:
|
|
53
53
|
return snippetOfNodeType(node, nodes.section_title);
|
|
@@ -16,6 +16,9 @@
|
|
|
16
16
|
import { ObjectTypes } from '@manuscripts/json-schema';
|
|
17
17
|
import { GROUP_ELEMENT, GROUP_EXECUTABLE, GROUP_SECTION, hasGroup, schema, } from '../schema';
|
|
18
18
|
export const nodeTypesMap = new Map([
|
|
19
|
+
[schema.nodes.abstracts, ObjectTypes.Section],
|
|
20
|
+
[schema.nodes.body, ObjectTypes.Section],
|
|
21
|
+
[schema.nodes.backmatter, ObjectTypes.Section],
|
|
19
22
|
[schema.nodes.comment, ObjectTypes.CommentAnnotation],
|
|
20
23
|
[schema.nodes.bibliography_item, ObjectTypes.BibliographyItem],
|
|
21
24
|
[schema.nodes.bibliography_element, ObjectTypes.BibliographyElement],
|
|
@@ -23,7 +26,6 @@ export const nodeTypesMap = new Map([
|
|
|
23
26
|
[schema.nodes.blockquote_element, ObjectTypes.QuoteElement],
|
|
24
27
|
[schema.nodes.bullet_list, ObjectTypes.ListElement],
|
|
25
28
|
[schema.nodes.citation, ObjectTypes.Citation],
|
|
26
|
-
[schema.nodes.cross_reference, ObjectTypes.AuxiliaryObjectReference],
|
|
27
29
|
[schema.nodes.equation, ObjectTypes.Equation],
|
|
28
30
|
[schema.nodes.equation_element, ObjectTypes.EquationElement],
|
|
29
31
|
[schema.nodes.figure, ObjectTypes.Figure],
|
|
@@ -37,8 +39,8 @@ export const nodeTypesMap = new Map([
|
|
|
37
39
|
[schema.nodes.inline_equation, ObjectTypes.InlineMathFragment],
|
|
38
40
|
[schema.nodes.keyword, ObjectTypes.Keyword],
|
|
39
41
|
[schema.nodes.keywords_element, ObjectTypes.KeywordsElement],
|
|
40
|
-
[schema.nodes.
|
|
41
|
-
[schema.nodes.
|
|
42
|
+
[schema.nodes.keywords, ObjectTypes.Section],
|
|
43
|
+
[schema.nodes.keyword_group, ObjectTypes.KeywordGroup],
|
|
42
44
|
[schema.nodes.listing, ObjectTypes.Listing],
|
|
43
45
|
[schema.nodes.listing_element, ObjectTypes.ListingElement],
|
|
44
46
|
[schema.nodes.manuscript, ObjectTypes.Manuscript],
|
|
@@ -50,13 +52,12 @@ export const nodeTypesMap = new Map([
|
|
|
50
52
|
[schema.nodes.table_element, ObjectTypes.TableElement],
|
|
51
53
|
[schema.nodes.toc_element, ObjectTypes.TOCElement],
|
|
52
54
|
[schema.nodes.toc_section, ObjectTypes.Section],
|
|
53
|
-
[schema.nodes.meta_section, ObjectTypes.MetaSection],
|
|
54
55
|
[schema.nodes.affiliation, ObjectTypes.Affiliation],
|
|
55
56
|
[schema.nodes.contributor, ObjectTypes.Contributor],
|
|
56
57
|
[schema.nodes.table_element_footer, ObjectTypes.TableElementFooter],
|
|
58
|
+
[schema.nodes.contributors, ObjectTypes.Section],
|
|
59
|
+
[schema.nodes.affiliations, ObjectTypes.Section],
|
|
57
60
|
[schema.nodes.title, ObjectTypes.Titles],
|
|
58
|
-
[schema.nodes.contributors_section, ObjectTypes.Section],
|
|
59
|
-
[schema.nodes.affiliations_section, ObjectTypes.Section],
|
|
60
61
|
]);
|
|
61
62
|
export const isExecutableNodeType = (type) => hasGroup(type, GROUP_EXECUTABLE);
|
|
62
63
|
export const isElementNodeType = (type) => hasGroup(type, GROUP_ELEMENT);
|
|
@@ -48,6 +48,5 @@ export const hasObjectType = (objectType) => (model) => model.objectType === obj
|
|
|
48
48
|
export const isFigure = hasObjectType(ObjectTypes.Figure);
|
|
49
49
|
export const isManuscript = hasObjectType(ObjectTypes.Manuscript);
|
|
50
50
|
export const isTable = hasObjectType(ObjectTypes.Table);
|
|
51
|
-
export const isUserProfile = hasObjectType(ObjectTypes.UserProfile);
|
|
52
51
|
export const isCommentAnnotation = hasObjectType(ObjectTypes.CommentAnnotation);
|
|
53
52
|
export const isKeyword = hasObjectType(ObjectTypes.Keyword);
|
|
@@ -14,22 +14,14 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { ObjectTypes } from '@manuscripts/json-schema';
|
|
17
|
-
import { coreSectionCategories } from '../lib/core-section-categories';
|
|
18
17
|
import { schema } from '../schema';
|
|
19
18
|
const sectionNodeTypes = [
|
|
20
19
|
schema.nodes.bibliography_section,
|
|
21
20
|
schema.nodes.footnotes_section,
|
|
22
|
-
schema.nodes.
|
|
21
|
+
schema.nodes.keywords,
|
|
23
22
|
schema.nodes.section,
|
|
24
23
|
schema.nodes.toc_section,
|
|
25
24
|
];
|
|
26
|
-
export const getCoreSectionTitles = (sectionCategory) => {
|
|
27
|
-
const category = coreSectionCategories.find((section) => section._id === sectionCategory);
|
|
28
|
-
if (category) {
|
|
29
|
-
return category.titles.length ? category.titles : [' '];
|
|
30
|
-
}
|
|
31
|
-
throw new Error(`${sectionCategory} not found in core sections`);
|
|
32
|
-
};
|
|
33
25
|
export const isAnySectionNode = (node) => sectionNodeTypes.includes(node.type);
|
|
34
26
|
export const chooseSectionNodeType = (category) => {
|
|
35
27
|
switch (category) {
|
|
@@ -40,11 +32,11 @@ export const chooseSectionNodeType = (category) => {
|
|
|
40
32
|
case 'MPSectionCategory:endnotes':
|
|
41
33
|
return schema.nodes.footnotes_section;
|
|
42
34
|
case 'MPSectionCategory:keywords':
|
|
43
|
-
return schema.nodes.
|
|
35
|
+
return schema.nodes.keywords;
|
|
44
36
|
case 'MPSectionCategory:affiliations':
|
|
45
|
-
return schema.nodes.
|
|
37
|
+
return schema.nodes.affiliations;
|
|
46
38
|
case 'MPSectionCategory:contributors':
|
|
47
|
-
return schema.nodes.
|
|
39
|
+
return schema.nodes.contributors;
|
|
48
40
|
case 'MPSectionCategory:toc':
|
|
49
41
|
return schema.nodes.toc_section;
|
|
50
42
|
default:
|
|
@@ -82,15 +74,15 @@ export const buildSectionCategory = (node) => {
|
|
|
82
74
|
return 'MPSectionCategory:bibliography';
|
|
83
75
|
case schema.nodes.footnotes_section:
|
|
84
76
|
return 'MPSectionCategory:endnotes';
|
|
85
|
-
case schema.nodes.
|
|
77
|
+
case schema.nodes.keywords:
|
|
86
78
|
return 'MPSectionCategory:keywords';
|
|
87
79
|
case schema.nodes.toc_section:
|
|
88
80
|
return 'MPSectionCategory:toc';
|
|
89
81
|
case schema.nodes.graphical_abstract_section:
|
|
90
82
|
return 'MPSectionCategory:abstract-graphical';
|
|
91
|
-
case schema.nodes.
|
|
83
|
+
case schema.nodes.affiliations:
|
|
92
84
|
return 'MPSectionCategory:affiliations';
|
|
93
|
-
case schema.nodes.
|
|
85
|
+
case schema.nodes.contributors:
|
|
94
86
|
return 'MPSectionCategory:contributors';
|
|
95
87
|
default:
|
|
96
88
|
return node.attrs.category || undefined;
|
|
@@ -117,6 +109,32 @@ export const chooseSecType = (sectionCategory) => {
|
|
|
117
109
|
return suffix;
|
|
118
110
|
}
|
|
119
111
|
};
|
|
112
|
+
export const chooseCoreSectionBySection = (section) => {
|
|
113
|
+
switch (section) {
|
|
114
|
+
case 'MPSectionCategory:abstract':
|
|
115
|
+
case 'MPSectionCategory:abstract-teaser':
|
|
116
|
+
case 'MPSectionCategory:abstract-graphical':
|
|
117
|
+
return 'MPSectionCategory:abstracts';
|
|
118
|
+
case 'MPSectionCategory:acknowledgement':
|
|
119
|
+
case 'MPSectionCategory:availability':
|
|
120
|
+
case 'MPSectionCategory:conclusions':
|
|
121
|
+
case 'MPSectionCategory:bibliography':
|
|
122
|
+
case 'MPSectionCategory:discussion':
|
|
123
|
+
case 'MPSectionCategory:endnotes':
|
|
124
|
+
case 'MPSectionCategory:appendices':
|
|
125
|
+
case 'MPSectionCategory:competing-interests':
|
|
126
|
+
case 'MPSectionCategory:con':
|
|
127
|
+
case 'MPSectionCategory:deceased':
|
|
128
|
+
case 'MPSectionCategory:ethics-statement':
|
|
129
|
+
case 'MPSectionCategory:financial-disclosure':
|
|
130
|
+
case 'MPSectionCategory:supplementary-material':
|
|
131
|
+
case 'MPSectionCategory:supported-by':
|
|
132
|
+
case 'MPSectionCategory:abbreviations':
|
|
133
|
+
case 'MPSectionCategory:results':
|
|
134
|
+
return 'MPSectionCategory:backmatter';
|
|
135
|
+
}
|
|
136
|
+
return 'MPSectionCategory:body';
|
|
137
|
+
};
|
|
120
138
|
export const chooseSectionCategoryByType = (secType) => {
|
|
121
139
|
switch (secType) {
|
|
122
140
|
case 'abstract':
|
package/dist/types/index.d.ts
CHANGED
|
@@ -13,4 +13,4 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
export { parseJATSFront, parseJATSBody,
|
|
16
|
+
export { parseJATSFront, parseJATSBody, parseJATSArticle, } from './parse-jats-article';
|
|
@@ -13,29 +13,26 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { Affiliation, BibliographyItem, Contributor } from '@manuscripts/json-schema';
|
|
17
|
-
import { Build } from '../../transformer';
|
|
18
16
|
export declare const jatsBodyTransformations: {
|
|
19
17
|
ensureSection(body: Element, createElement: (tagName: string) => HTMLElement): void;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
createFootnotes(footnoteGroups: Element[], createElement: (tagName: string) => HTMLElement): HTMLElement;
|
|
18
|
+
createAbstractSection(abstractNode: Element, createElement: (tagName: string) => HTMLElement): HTMLElement;
|
|
19
|
+
createAcknowledgmentsSection(ackNode: Element, createElement: (tagName: string) => HTMLElement): HTMLElement;
|
|
20
|
+
createFootnotesSection(footnoteGroups: Element[], createElement: (tagName: string) => HTMLElement): HTMLElement;
|
|
24
21
|
createAppendixSection(app: Element, createElement: (tagName: string) => HTMLElement): HTMLElement;
|
|
25
|
-
createFloatsGroupSection(
|
|
26
|
-
|
|
27
|
-
wrapBodySections(doc: Document,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
22
|
+
createFloatsGroupSection(group: Element, createElement: (tagName: string) => HTMLElement): HTMLElement;
|
|
23
|
+
moveAbstracts(doc: Document, group: Element, createElement: (tagName: string) => HTMLElement): void;
|
|
24
|
+
wrapBodySections(doc: Document, group: Element): void;
|
|
25
|
+
moveBackSections(doc: Document, group: Element): void;
|
|
26
|
+
moveAcknowledgments(doc: Document, group: Element, createElement: (tagName: string) => HTMLElement): void;
|
|
27
|
+
moveAppendices(doc: Document, group: Element, createElement: (tagName: string) => HTMLElement): void;
|
|
28
|
+
createBody(doc: Document, body: Element, createElement: (tagName: string) => HTMLElement): void;
|
|
29
|
+
createAbstracts(doc: Document, body: Element, createElement: (tagName: string) => HTMLElement): void;
|
|
30
|
+
createBackmatter(doc: Document, body: Element, createElement: (tagName: string) => HTMLElement): void;
|
|
31
|
+
moveSpecialFootnotes(doc: Document, group: Element, createElement: (tagName: string) => HTMLElement): void;
|
|
32
|
+
moveFootnotes(doc: Document, group: Element, createElement: (tagName: string) => HTMLElement): void;
|
|
34
33
|
moveCaptionsToEnd(body: Element): void;
|
|
34
|
+
fixTables(body: Element, createElement: (tagName: string) => HTMLElement): void;
|
|
35
35
|
moveTableFooterToEnd(body: Element): void;
|
|
36
|
-
moveAffiliationsToBody(doc: Document, affiliations: Build<Affiliation>[] | undefined, body: Element, createElement: (tagName: string) => HTMLElement): void;
|
|
37
|
-
moveAuthorsToBody(doc: Document, authors: Build<Contributor>[] | undefined, body: Element, createElement: (tagName: string) => HTMLElement): void;
|
|
38
36
|
moveFloatsGroupToBody(doc: Document, body: Element, createElement: (tagName: string) => HTMLElement): void;
|
|
39
|
-
|
|
40
|
-
moveKeywordsToBody(document: Document, body: Element, createElement: (tagName: string) => HTMLElement): void;
|
|
37
|
+
createKeywords(document: Document, body: Element, createElement: (tagName: string) => HTMLElement): void;
|
|
41
38
|
};
|
|
@@ -13,14 +13,18 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
type
|
|
16
|
+
import { CommentAnnotation, Model } from '@manuscripts/json-schema';
|
|
17
|
+
import { References } from './jats-references';
|
|
18
|
+
export type JATSComment = {
|
|
19
19
|
id: string;
|
|
20
|
-
|
|
20
|
+
text: string;
|
|
21
21
|
};
|
|
22
|
-
export
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
export
|
|
22
|
+
export type JATSCommentMark = {
|
|
23
|
+
token: string;
|
|
24
|
+
comment: JATSComment;
|
|
25
|
+
};
|
|
26
|
+
export declare const isJATSComment: (node: Node) => boolean;
|
|
27
|
+
export declare const parseJATSComment: (node: Node) => JATSComment | undefined;
|
|
28
|
+
export declare const markComments: (doc: Document) => JATSCommentMark[];
|
|
29
|
+
export declare const createComments: (models: Model[], marks: JATSCommentMark[]) => CommentAnnotation[];
|
|
30
|
+
export declare const createReferenceComments: (references: References) => CommentAnnotation[];
|
|
@@ -13,20 +13,43 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { Journal } from '@manuscripts/json-schema';
|
|
17
16
|
export declare const jatsFrontParser: {
|
|
18
|
-
|
|
17
|
+
parseTitles(element: Element | null, createElement: (tagName: string) => HTMLElement): import("../../transformer").Build<import("@manuscripts/json-schema/dist/types").Titles>;
|
|
18
|
+
parseCounts(counts: Element | null): {
|
|
19
19
|
wordCount: number | undefined;
|
|
20
20
|
figureCount: number | undefined;
|
|
21
21
|
tableCount: number | undefined;
|
|
22
22
|
equationCount: number | undefined;
|
|
23
23
|
referencesCount: number | undefined;
|
|
24
24
|
genericCounts: {
|
|
25
|
-
count: number;
|
|
25
|
+
count: number | undefined;
|
|
26
26
|
countType: string;
|
|
27
27
|
}[] | undefined;
|
|
28
28
|
} | undefined;
|
|
29
|
-
parseJournal(
|
|
29
|
+
parseJournal(element: Element | null): {
|
|
30
|
+
title: string | undefined;
|
|
31
|
+
templateID?: string | undefined;
|
|
32
|
+
ISSNs: {
|
|
33
|
+
[k: string]: any;
|
|
34
|
+
ISSN: string;
|
|
35
|
+
publicationType?: string | undefined;
|
|
36
|
+
}[];
|
|
37
|
+
abbreviatedTitles: {
|
|
38
|
+
[k: string]: any;
|
|
39
|
+
abbreviatedTitle: string;
|
|
40
|
+
abbrevType?: string | undefined;
|
|
41
|
+
}[];
|
|
42
|
+
journalIdentifiers: {
|
|
43
|
+
[k: string]: any;
|
|
44
|
+
journalID: string;
|
|
45
|
+
journalIDType?: string | undefined;
|
|
46
|
+
}[];
|
|
47
|
+
submittable?: boolean | undefined;
|
|
48
|
+
publisherName: string | undefined;
|
|
49
|
+
_id: string;
|
|
50
|
+
objectType: string;
|
|
51
|
+
contributions?: import("@manuscripts/json-schema/dist/types").Contribution[] | undefined;
|
|
52
|
+
};
|
|
30
53
|
parseDates(historyNode: Element | null): {
|
|
31
54
|
acceptanceDate?: number | undefined;
|
|
32
55
|
correctionDate?: number | undefined;
|
|
@@ -35,18 +58,18 @@ export declare const jatsFrontParser: {
|
|
|
35
58
|
revisionReceiveDate?: number | undefined;
|
|
36
59
|
receiveDate?: number | undefined;
|
|
37
60
|
} | undefined;
|
|
38
|
-
parseSupplements(
|
|
39
|
-
|
|
40
|
-
affiliations: import("../../transformer").Build<import("@manuscripts/json-schema").Affiliation>[];
|
|
61
|
+
parseSupplements(elements: Element[] | null): import("../../transformer").Build<import("@manuscripts/json-schema/dist/types").Supplement>[];
|
|
62
|
+
parseAffiliations(elements: Element[]): {
|
|
63
|
+
affiliations: import("../../transformer").Build<import("@manuscripts/json-schema/dist/types").Affiliation>[];
|
|
41
64
|
affiliationIDs: Map<string, string>;
|
|
42
65
|
};
|
|
43
|
-
|
|
44
|
-
footnotes: import("../../transformer").Build<import("@manuscripts/json-schema").Footnote>[];
|
|
66
|
+
parseAuthorNotes(elements: Element[]): {
|
|
67
|
+
footnotes: import("../../transformer").Build<import("@manuscripts/json-schema/dist/types").Footnote>[];
|
|
45
68
|
footnoteIDs: Map<string, string>;
|
|
46
69
|
};
|
|
47
|
-
|
|
48
|
-
correspondingList: import("../../transformer").Build<import("@manuscripts/json-schema").Corresponding>[];
|
|
70
|
+
parseCorresp(elements: Element[]): {
|
|
71
|
+
correspondingList: import("../../transformer").Build<import("@manuscripts/json-schema/dist/types").Corresponding>[];
|
|
49
72
|
correspondingIDs: Map<string, string>;
|
|
50
73
|
};
|
|
51
|
-
|
|
74
|
+
parseContributors(elements: Element[], affiliationIDs: Map<string, string>, footnoteIDs: Map<string, string>, correspondingIDs: Map<string, string>): import("../../transformer").Build<import("@manuscripts/json-schema/dist/types").Contributor>[];
|
|
52
75
|
};
|
|
@@ -25,10 +25,10 @@ export type JournalIdentifier = {
|
|
|
25
25
|
journalID: string;
|
|
26
26
|
journalIDType?: string;
|
|
27
27
|
};
|
|
28
|
-
export declare const parseJournalIdentifiers: (
|
|
29
|
-
export declare const parseJournalAbbreviatedTitles: (
|
|
30
|
-
export declare const parseJournalISSNs: (
|
|
31
|
-
export declare const parseJournalMeta: (
|
|
28
|
+
export declare const parseJournalIdentifiers: (element: Element | null) => JournalIdentifier[];
|
|
29
|
+
export declare const parseJournalAbbreviatedTitles: (element: Element | null) => AbbreviatedTitle[];
|
|
30
|
+
export declare const parseJournalISSNs: (element: Element | null) => ISSN[];
|
|
31
|
+
export declare const parseJournalMeta: (element: Element | null) => {
|
|
32
32
|
abbreviatedTitles: AbbreviatedTitle[];
|
|
33
33
|
journalIdentifiers: JournalIdentifier[];
|
|
34
34
|
ISSNs: ISSN[];
|
|
@@ -13,11 +13,6 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { Model } from '@manuscripts/json-schema';
|
|
17
16
|
import { ManuscriptNode } from '../../schema';
|
|
18
|
-
export declare
|
|
19
|
-
export declare const fixBodyPMNode: (output: ManuscriptNode, models: Model[], referenceIdsMap?: Map<string, string>) => {
|
|
20
|
-
warnings: string[];
|
|
21
|
-
replacements: Map<string, string>;
|
|
22
|
-
};
|
|
17
|
+
export declare const updateDocumentIDs: (node: ManuscriptNode, replacements: Map<string, string>) => string[];
|
|
23
18
|
export declare const htmlFromJatsNode: (element: Element | undefined | null, createElement: (tagName: string) => HTMLElement) => string | undefined;
|
|
@@ -13,11 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
import { References } from './jats-references';
|
|
16
17
|
export declare const jatsReferenceParser: {
|
|
17
|
-
parseReferences(
|
|
18
|
-
references: import("../../transformer/builders").Build<import("@manuscripts/json-schema").BibliographyItem>[];
|
|
19
|
-
referenceIDs: Map<string, string>;
|
|
20
|
-
referenceQueries: Map<string, string[]>;
|
|
21
|
-
};
|
|
22
|
-
parseCrossReferences(crossReferenceNodes: Element[], referenceIDs: Map<string, string>): (import("../../transformer/builders").Build<import("@manuscripts/json-schema").AuxiliaryObjectReference> | import("../../transformer/builders").Build<import("@manuscripts/json-schema").Citation>)[];
|
|
18
|
+
parseReferences(elements: Element[], createElement: (tagName: string) => HTMLElement): References;
|
|
23
19
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BibliographyItem } from '@manuscripts/json-schema';
|
|
2
|
+
import { JATSComment } from './jats-comments';
|
|
3
|
+
export declare class References {
|
|
4
|
+
items: Map<string, BibliographyItem>;
|
|
5
|
+
IDs: Map<string, string>;
|
|
6
|
+
comments: Map<string, JATSComment[]>;
|
|
7
|
+
constructor();
|
|
8
|
+
add(item: BibliographyItem, id: string | null, comments: JATSComment[]): void;
|
|
9
|
+
getBibliographyItems(): BibliographyItem[];
|
|
10
|
+
getComments(id: string): JATSComment[];
|
|
11
|
+
private getValue;
|
|
12
|
+
}
|
|
@@ -13,20 +13,8 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
|
|
19
|
-
export declare const
|
|
20
|
-
|
|
21
|
-
authors: Build<Contributor>[];
|
|
22
|
-
affiliations: Build<Affiliation>[];
|
|
23
|
-
}>;
|
|
24
|
-
export declare const parseJATSReferences: (back: Element | null, body: Element | null, createElement: (tagName: string) => HTMLElement) => {
|
|
25
|
-
references: Model[];
|
|
26
|
-
crossReferences: Model[];
|
|
27
|
-
referenceQueriesMap: Map<string, string[]> | undefined;
|
|
28
|
-
referenceIdsMap: Map<string, string> | undefined;
|
|
29
|
-
};
|
|
30
|
-
export declare const parseJATSBody: (document: Document, body: Element, bibliographyItems: BibliographyItem[] | null, authors: Build<Contributor>[], affiliations: Build<Affiliation>[], refModels: Model[], referenceIdsMap: Map<string, string> | undefined, footnotesOrder?: FootnotesOrder) => ManuscriptNode;
|
|
31
|
-
export declare const parseJATSArticle: (doc: Document) => Promise<Model[]>;
|
|
32
|
-
export declare const getElementsOrder: (node: ManuscriptNode) => ElementsOrder[];
|
|
16
|
+
import { Model } from '@manuscripts/json-schema';
|
|
17
|
+
import { References } from './jats-references';
|
|
18
|
+
export declare const parseJATSFront: (doc: Document, front: Element) => Model[];
|
|
19
|
+
export declare const parseJATSBody: (doc: Document, body: Element, references?: References) => IterableIterator<Model>;
|
|
20
|
+
export declare const parseJATSArticle: (doc: Document) => Model[];
|
|
@@ -13,6 +13,6 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
export { parseJATSFront,
|
|
16
|
+
export { parseJATSFront, parseJATSBody, parseJATSArticle, } from './importer';
|
|
17
17
|
export * from './jats-exporter';
|
|
18
18
|
export * from './jats-versions';
|