@manuscripts/transform 1.5.2-LEAN-3034 → 1.5.2-LEAN-3032
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/importer/jats-body-dom-parser.js +19 -7
- package/dist/cjs/jats/jats-exporter.js +12 -37
- package/dist/cjs/lib/utils.js +10 -1
- package/dist/cjs/schema/index.js +7 -3
- package/dist/cjs/schema/nodes/affiliations_section.js +1 -1
- package/dist/cjs/schema/nodes/contributors_section.js +1 -1
- package/dist/cjs/schema/nodes/core_section.js +27 -0
- package/dist/cjs/schema/nodes/keywords_section.js +1 -1
- package/dist/cjs/schema/nodes/manuscript.js +1 -1
- package/dist/cjs/transformer/decode.js +67 -19
- package/dist/cjs/transformer/encode.js +12 -25
- 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 +6 -3
- package/dist/cjs/transformer/section-category.js +35 -8
- package/dist/es/jats/importer/jats-body-dom-parser.js +19 -7
- package/dist/es/jats/jats-exporter.js +13 -38
- package/dist/es/lib/utils.js +8 -0
- package/dist/es/schema/index.js +7 -3
- package/dist/es/schema/nodes/affiliations_section.js +1 -1
- package/dist/es/schema/nodes/contributors_section.js +1 -1
- package/dist/es/schema/nodes/core_section.js +24 -0
- package/dist/es/schema/nodes/keywords_section.js +1 -1
- package/dist/es/schema/nodes/manuscript.js +1 -1
- package/dist/es/transformer/decode.js +68 -20
- package/dist/es/transformer/encode.js +12 -25
- 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 +6 -3
- package/dist/es/transformer/section-category.js +33 -7
- package/dist/types/jats/jats-exporter.d.ts +1 -8
- package/dist/types/lib/utils.d.ts +1 -0
- package/dist/types/{lib/citationProvider.d.ts → schema/nodes/core_section.d.ts} +8 -14
- package/dist/types/schema/types.d.ts +1 -1
- package/dist/types/transformer/decode.d.ts +3 -0
- package/dist/types/transformer/section-category.d.ts +1 -0
- package/package.json +2 -3
- package/dist/cjs/lib/citationProvider.js +0 -50
- package/dist/cjs/lib/defaultLocale.js +0 -3
- package/dist/es/lib/citationProvider.js +0 -43
- package/dist/es/lib/defaultLocale.js +0 -1
- package/dist/types/lib/defaultLocale.d.ts +0 -2
|
@@ -507,7 +507,7 @@ const nodes = [
|
|
|
507
507
|
},
|
|
508
508
|
{
|
|
509
509
|
tag: 'sec[sec-type="affiliations"]',
|
|
510
|
-
node: '
|
|
510
|
+
node: 'affiliations',
|
|
511
511
|
getAttrs: (node) => {
|
|
512
512
|
const element = node;
|
|
513
513
|
return {
|
|
@@ -519,7 +519,7 @@ const nodes = [
|
|
|
519
519
|
{
|
|
520
520
|
tag: 'aff',
|
|
521
521
|
node: 'affiliation',
|
|
522
|
-
context: '
|
|
522
|
+
context: 'affiliations/',
|
|
523
523
|
getAttrs: (node) => {
|
|
524
524
|
const element = node;
|
|
525
525
|
const aff = {
|
|
@@ -566,7 +566,7 @@ const nodes = [
|
|
|
566
566
|
},
|
|
567
567
|
{
|
|
568
568
|
tag: 'sec[sec-type="contributors"]',
|
|
569
|
-
node: '
|
|
569
|
+
node: 'contributors',
|
|
570
570
|
getAttrs: (node) => {
|
|
571
571
|
const element = node;
|
|
572
572
|
return {
|
|
@@ -578,7 +578,7 @@ const nodes = [
|
|
|
578
578
|
{
|
|
579
579
|
tag: 'contrib',
|
|
580
580
|
node: 'contributor',
|
|
581
|
-
context: '
|
|
581
|
+
context: 'contributors/',
|
|
582
582
|
getAttrs: (node) => {
|
|
583
583
|
const element = node;
|
|
584
584
|
const contrib = {
|
|
@@ -633,7 +633,7 @@ const nodes = [
|
|
|
633
633
|
},
|
|
634
634
|
{
|
|
635
635
|
tag: 'sec[sec-type="keywords"]',
|
|
636
|
-
node: '
|
|
636
|
+
node: 'keywords',
|
|
637
637
|
getAttrs: (node) => {
|
|
638
638
|
const element = node;
|
|
639
639
|
return {
|
|
@@ -644,9 +644,21 @@ const nodes = [
|
|
|
644
644
|
},
|
|
645
645
|
{
|
|
646
646
|
tag: 'kwd-group-list',
|
|
647
|
-
context: '
|
|
647
|
+
context: 'keywords/',
|
|
648
648
|
node: 'keywords_element',
|
|
649
649
|
},
|
|
650
|
+
{
|
|
651
|
+
tag: 'sec[sec-type="abstracts"]',
|
|
652
|
+
node: 'abstracts',
|
|
653
|
+
},
|
|
654
|
+
{
|
|
655
|
+
tag: 'sec[sec-type="body"]',
|
|
656
|
+
node: 'body',
|
|
657
|
+
},
|
|
658
|
+
{
|
|
659
|
+
tag: 'sec[sec-type="backmatter"]',
|
|
660
|
+
node: 'backmatter',
|
|
661
|
+
},
|
|
650
662
|
{
|
|
651
663
|
tag: 'sec',
|
|
652
664
|
node: 'section',
|
|
@@ -726,7 +738,7 @@ const nodes = [
|
|
|
726
738
|
{
|
|
727
739
|
tag: 'title',
|
|
728
740
|
node: 'section_title',
|
|
729
|
-
context: 'section/|footnotes_section/|bibliography_section/|
|
|
741
|
+
context: 'section/|footnotes_section/|bibliography_section/|keywords/',
|
|
730
742
|
},
|
|
731
743
|
{
|
|
732
744
|
tag: 'title',
|
|
@@ -23,7 +23,6 @@ const json_schema_1 = require("@manuscripts/json-schema");
|
|
|
23
23
|
const debug_1 = __importDefault(require("debug"));
|
|
24
24
|
const prosemirror_model_1 = require("prosemirror-model");
|
|
25
25
|
const w3c_xmlserializer_1 = __importDefault(require("w3c-xmlserializer"));
|
|
26
|
-
const citationProvider_1 = require("../lib/citationProvider");
|
|
27
26
|
const html_1 = require("../lib/html");
|
|
28
27
|
const styled_content_1 = require("../lib/styled-content");
|
|
29
28
|
const utils_1 = require("../lib/utils");
|
|
@@ -119,16 +118,9 @@ const sortContributors = (a, b) => Number(a.priority) - Number(b.priority);
|
|
|
119
118
|
class JATSExporter {
|
|
120
119
|
constructor() {
|
|
121
120
|
this.serializeToJATS = async (fragment, modelMap, manuscriptID, options = {}) => {
|
|
122
|
-
const { version = '1.2', doi, id, frontMatterOnly = false, links, idGenerator, mediaPathGenerator,
|
|
121
|
+
const { version = '1.2', doi, id, frontMatterOnly = false, links, idGenerator, mediaPathGenerator, } = options;
|
|
123
122
|
this.modelMap = modelMap;
|
|
124
123
|
this.models = Array.from(this.modelMap.values());
|
|
125
|
-
if (citationStyle) {
|
|
126
|
-
this.citeProcEngine = citationProvider_1.CitationProvider.getEngine({
|
|
127
|
-
bibliographyItemsMap: this.getBibliographyItemsMap(),
|
|
128
|
-
citationStyle: citationStyle,
|
|
129
|
-
locale: locale,
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
124
|
this.createSerializer();
|
|
133
125
|
const versionIds = (0, jats_versions_1.selectVersionIds)(version);
|
|
134
126
|
this.document = document.implementation.createDocument(null, 'article', document.implementation.createDocumentType('article', versionIds.publicId, versionIds.systemId));
|
|
@@ -438,9 +430,11 @@ class JATSExporter {
|
|
|
438
430
|
}
|
|
439
431
|
};
|
|
440
432
|
this.buildBody = (fragment) => {
|
|
441
|
-
const content = this.serializeFragment(fragment);
|
|
442
433
|
const body = this.document.createElement('body');
|
|
443
|
-
|
|
434
|
+
fragment.forEach((cFragment) => {
|
|
435
|
+
const serializedNode = this.serializeNode(cFragment);
|
|
436
|
+
body.append(...serializedNode.childNodes);
|
|
437
|
+
});
|
|
444
438
|
this.fixBody(body, fragment);
|
|
445
439
|
return body;
|
|
446
440
|
};
|
|
@@ -606,8 +600,8 @@ class JATSExporter {
|
|
|
606
600
|
this.createSerializer = () => {
|
|
607
601
|
const getModel = (id) => id ? this.modelMap.get(id) : undefined;
|
|
608
602
|
const nodes = {
|
|
609
|
-
|
|
610
|
-
|
|
603
|
+
affiliations: () => '',
|
|
604
|
+
contributors: () => '',
|
|
611
605
|
table_element_footer: () => ['table-wrap-foot', 0],
|
|
612
606
|
contributor: () => '',
|
|
613
607
|
affiliation: () => '',
|
|
@@ -617,6 +611,9 @@ class JATSExporter {
|
|
|
617
611
|
bibliography_item: () => '',
|
|
618
612
|
comment_list: () => '',
|
|
619
613
|
keywords_group: () => '',
|
|
614
|
+
body: () => ['body', 0],
|
|
615
|
+
abstracts: () => ['abstract', 0],
|
|
616
|
+
backmatter: () => ['backmatter', 0],
|
|
620
617
|
bibliography_section: (node) => [
|
|
621
618
|
'ref-list',
|
|
622
619
|
{ id: normalizeID(node.attrs.id) },
|
|
@@ -651,10 +648,7 @@ class JATSExporter {
|
|
|
651
648
|
const xref = this.document.createElement('xref');
|
|
652
649
|
xref.setAttribute('ref-type', 'bibr');
|
|
653
650
|
xref.setAttribute('rid', rids.map((item) => normalizeID(item.bibliographyItem)).join(' '));
|
|
654
|
-
if (
|
|
655
|
-
xref.textContent = this.generateCitationContent(node);
|
|
656
|
-
}
|
|
657
|
-
else if (node.attrs.contents) {
|
|
651
|
+
if (node.attrs.contents) {
|
|
658
652
|
const text = (0, html_1.textFromHTML)(node.attrs.contents);
|
|
659
653
|
if (text !== null && text.length) {
|
|
660
654
|
xref.textContent = text;
|
|
@@ -798,7 +792,7 @@ class JATSExporter {
|
|
|
798
792
|
},
|
|
799
793
|
keyword: () => '',
|
|
800
794
|
keywords_element: () => '',
|
|
801
|
-
|
|
795
|
+
keywords: () => '',
|
|
802
796
|
link: (node) => {
|
|
803
797
|
const text = node.textContent;
|
|
804
798
|
if (!text) {
|
|
@@ -1584,25 +1578,6 @@ class JATSExporter {
|
|
|
1584
1578
|
return name;
|
|
1585
1579
|
};
|
|
1586
1580
|
}
|
|
1587
|
-
getBibliographyItemsMap() {
|
|
1588
|
-
const map = new Map();
|
|
1589
|
-
this.modelMap.forEach((model) => {
|
|
1590
|
-
if (model.objectType === json_schema_1.ObjectTypes.BibliographyItem) {
|
|
1591
|
-
map.set(model._id, model);
|
|
1592
|
-
}
|
|
1593
|
-
});
|
|
1594
|
-
return map;
|
|
1595
|
-
}
|
|
1596
|
-
generateCitationContent(node) {
|
|
1597
|
-
var _a;
|
|
1598
|
-
const citationItems = (_a = node.attrs.embeddedCitationItems) === null || _a === void 0 ? void 0 : _a.map(({ bibliographyItem }) => ({
|
|
1599
|
-
id: bibliographyItem,
|
|
1600
|
-
}));
|
|
1601
|
-
return this.citeProcEngine.previewCitationCluster({
|
|
1602
|
-
citationID: node.attrs.rid,
|
|
1603
|
-
citationItems: citationItems,
|
|
1604
|
-
}, [], [], 'text');
|
|
1605
|
-
}
|
|
1606
1581
|
buildKeywords(articleMeta) {
|
|
1607
1582
|
const keywords = [...this.modelMap.values()].filter((model) => model.objectType === json_schema_1.ObjectTypes.Keyword);
|
|
1608
1583
|
const keywordGroups = new Map();
|
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.getTrimmedTextContent = exports.findParentNodeClosestToPos = exports.isInAbstractsSection = exports.isInBibliographySection = exports.isInGraphicalAbstractSection = exports.findNodePositions = exports.iterateChildren = void 0;
|
|
18
|
+
exports.groupBy = exports.getTrimmedTextContent = exports.findParentNodeClosestToPos = exports.isInAbstractsSection = 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) {
|
|
@@ -94,3 +94,12 @@ const getTrimmedTextContent = (node, querySelector) => {
|
|
|
94
94
|
return (_b = (_a = node.querySelector(querySelector)) === null || _a === void 0 ? void 0 : _a.textContent) === null || _b === void 0 ? void 0 : _b.trim();
|
|
95
95
|
};
|
|
96
96
|
exports.getTrimmedTextContent = getTrimmedTextContent;
|
|
97
|
+
const groupBy = (list, getKey) => list.reduce((previous, currentItem) => {
|
|
98
|
+
const group = getKey(currentItem);
|
|
99
|
+
if (!previous[group]) {
|
|
100
|
+
previous[group] = [];
|
|
101
|
+
}
|
|
102
|
+
previous[group].push(currentItem);
|
|
103
|
+
return previous;
|
|
104
|
+
}, {});
|
|
105
|
+
exports.groupBy = groupBy;
|
package/dist/cjs/schema/index.js
CHANGED
|
@@ -46,6 +46,7 @@ const comment_1 = require("./nodes/comment");
|
|
|
46
46
|
const comment_list_1 = require("./nodes/comment_list");
|
|
47
47
|
const contributor_1 = require("./nodes/contributor");
|
|
48
48
|
const contributors_section_1 = require("./nodes/contributors_section");
|
|
49
|
+
const core_section_1 = require("./nodes/core_section");
|
|
49
50
|
const cross_reference_1 = require("./nodes/cross_reference");
|
|
50
51
|
const doc_1 = require("./nodes/doc");
|
|
51
52
|
const equation_1 = require("./nodes/equation");
|
|
@@ -168,6 +169,9 @@ exports.schema = new prosemirror_model_1.Schema({
|
|
|
168
169
|
caption: caption_1.caption,
|
|
169
170
|
caption_title: caption_title_1.captionTitle,
|
|
170
171
|
citation: citation_1.citation,
|
|
172
|
+
abstracts: core_section_1.coreSection,
|
|
173
|
+
body: core_section_1.coreSection,
|
|
174
|
+
backmatter: core_section_1.coreSection,
|
|
171
175
|
cross_reference: cross_reference_1.crossReference,
|
|
172
176
|
doc: doc_1.doc,
|
|
173
177
|
equation: equation_1.equation,
|
|
@@ -185,7 +189,7 @@ exports.schema = new prosemirror_model_1.Schema({
|
|
|
185
189
|
inline_footnote: inline_footnote_1.inlineFootnote,
|
|
186
190
|
keyword: keyword_1.keyword,
|
|
187
191
|
keywords_element: keywords_element_1.keywordsElement,
|
|
188
|
-
|
|
192
|
+
keywords: keywords_section_1.keywordsSection,
|
|
189
193
|
keywords_group: keywords_group_1.keywordsGroup,
|
|
190
194
|
link: link_1.link,
|
|
191
195
|
list_item: list_1.listItem,
|
|
@@ -216,7 +220,7 @@ exports.schema = new prosemirror_model_1.Schema({
|
|
|
216
220
|
meta_section: meta_section_1.metaSection,
|
|
217
221
|
contributor: contributor_1.contributor,
|
|
218
222
|
table_element_footer: table_element_footer_1.tableElementFooter,
|
|
219
|
-
|
|
220
|
-
|
|
223
|
+
affiliations: affiliations_section_1.affiliationsSection,
|
|
224
|
+
contributors: contributors_section_1.contributorsSection,
|
|
221
225
|
},
|
|
222
226
|
});
|
|
@@ -11,5 +11,5 @@ exports.affiliationsSection = {
|
|
|
11
11
|
selectable: false,
|
|
12
12
|
toDOM: () => ['section', 0],
|
|
13
13
|
};
|
|
14
|
-
const isAffiliationsSectionNode = (node) => node.type === node.type.schema.nodes.
|
|
14
|
+
const isAffiliationsSectionNode = (node) => node.type === node.type.schema.nodes.affiliations;
|
|
15
15
|
exports.isAffiliationsSectionNode = isAffiliationsSectionNode;
|
|
@@ -11,5 +11,5 @@ exports.contributorsSection = {
|
|
|
11
11
|
selectable: false,
|
|
12
12
|
toDOM: () => ['section', 0],
|
|
13
13
|
};
|
|
14
|
-
const isContributorsSectionNode = (node) => node.type === node.type.schema.nodes.
|
|
14
|
+
const isContributorsSectionNode = (node) => node.type === node.type.schema.nodes.contributors;
|
|
15
15
|
exports.isContributorsSectionNode = isContributorsSectionNode;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* © 2019 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.coreSection = void 0;
|
|
19
|
+
exports.coreSection = {
|
|
20
|
+
content: '(section | sections)*',
|
|
21
|
+
atom: true,
|
|
22
|
+
attrs: {
|
|
23
|
+
id: { default: '' },
|
|
24
|
+
},
|
|
25
|
+
group: 'block sections',
|
|
26
|
+
toDOM: () => ['section', 0],
|
|
27
|
+
};
|
|
@@ -43,5 +43,5 @@ exports.keywordsSection = {
|
|
|
43
43
|
];
|
|
44
44
|
},
|
|
45
45
|
};
|
|
46
|
-
const isKeywordsSectionNode = (node) => node.type === node.type.schema.nodes.
|
|
46
|
+
const isKeywordsSectionNode = (node) => node.type === node.type.schema.nodes.keywords;
|
|
47
47
|
exports.isKeywordsSectionNode = isKeywordsSectionNode;
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.manuscript = void 0;
|
|
19
19
|
exports.manuscript = {
|
|
20
|
-
content: '
|
|
20
|
+
content: 'contributors? affiliations? keywords? abstracts body backmatter meta_section',
|
|
21
21
|
attrs: {
|
|
22
22
|
id: { default: '' },
|
|
23
23
|
},
|
|
@@ -34,6 +34,7 @@ const json_schema_1 = require("@manuscripts/json-schema");
|
|
|
34
34
|
const debug_1 = __importDefault(require("debug"));
|
|
35
35
|
const prosemirror_model_1 = require("prosemirror-model");
|
|
36
36
|
const errors_1 = require("../errors");
|
|
37
|
+
const utils_1 = require("../lib/utils");
|
|
37
38
|
const schema_1 = require("../schema");
|
|
38
39
|
const highlight_markers_1 = require("./highlight-markers");
|
|
39
40
|
const id_1 = require("./id");
|
|
@@ -62,6 +63,7 @@ exports.sortSectionsByPriority = sortSectionsByPriority;
|
|
|
62
63
|
const getSections = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Section).sort(exports.sortSectionsByPriority);
|
|
63
64
|
const getAffiliations = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Affiliation);
|
|
64
65
|
const getContributors = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Contributor);
|
|
66
|
+
const getKeywordElements = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.KeywordsElement);
|
|
65
67
|
const isManuscriptNode = (model) => model !== null;
|
|
66
68
|
exports.isManuscriptNode = isManuscriptNode;
|
|
67
69
|
const isParagraphElement = (0, object_types_1.hasObjectType)(json_schema_1.ObjectTypes.ParagraphElement);
|
|
@@ -86,10 +88,13 @@ class Decoder {
|
|
|
86
88
|
]);
|
|
87
89
|
}
|
|
88
90
|
handleMissingRootSectionNodes(rootSectionNodes) {
|
|
89
|
-
if (!rootSectionNodes.find((node) => node.type.name === '
|
|
91
|
+
if (!rootSectionNodes.find((node) => node.type.name === 'keywords')) {
|
|
92
|
+
this.createKeywordsSectionNode(rootSectionNodes);
|
|
93
|
+
}
|
|
94
|
+
if (!rootSectionNodes.find((node) => node.type.name === 'affiliations')) {
|
|
90
95
|
this.createAffiliationSectionNode(rootSectionNodes);
|
|
91
96
|
}
|
|
92
|
-
if (!rootSectionNodes.find((node) => node.type.name === '
|
|
97
|
+
if (!rootSectionNodes.find((node) => node.type.name === 'contributors')) {
|
|
93
98
|
this.createContributorSectionNode(rootSectionNodes);
|
|
94
99
|
}
|
|
95
100
|
}
|
|
@@ -97,37 +102,79 @@ class Decoder {
|
|
|
97
102
|
const affiliationNodes = getAffiliations(this.modelMap)
|
|
98
103
|
.map((affiliation) => this.decode(affiliation))
|
|
99
104
|
.filter(Boolean);
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
rootSectionNodes.unshift(node);
|
|
105
|
-
}
|
|
105
|
+
const node = schema_1.schema.nodes.affiliations.createAndFill({
|
|
106
|
+
id: (0, id_1.generateNodeID)(schema_1.schema.nodes.section),
|
|
107
|
+
}, affiliationNodes);
|
|
108
|
+
rootSectionNodes.unshift(node);
|
|
106
109
|
}
|
|
107
110
|
createContributorSectionNode(rootSectionNodes) {
|
|
108
111
|
const contributorNodes = getContributors(this.modelMap)
|
|
109
112
|
.map((contributor) => this.decode(contributor))
|
|
110
113
|
.filter(Boolean);
|
|
111
|
-
|
|
112
|
-
|
|
114
|
+
const node = schema_1.schema.nodes.contributors.createAndFill({
|
|
115
|
+
id: (0, id_1.generateNodeID)(schema_1.schema.nodes.section),
|
|
116
|
+
}, contributorNodes);
|
|
117
|
+
rootSectionNodes.unshift(node);
|
|
118
|
+
}
|
|
119
|
+
createKeywordsSectionNode(rootSectionNodes) {
|
|
120
|
+
const keywordElementNodes = getKeywordElements(this.modelMap)
|
|
121
|
+
.map((keywordEl) => this.decode(keywordEl))
|
|
122
|
+
.filter(Boolean);
|
|
123
|
+
if (keywordElementNodes) {
|
|
124
|
+
const node = schema_1.schema.nodes.keywords.createAndFill({
|
|
113
125
|
id: (0, id_1.generateNodeID)(schema_1.schema.nodes.section),
|
|
114
|
-
},
|
|
126
|
+
}, [
|
|
127
|
+
schema_1.schema.nodes.section_title.create({}, schema_1.schema.text('Keywords')),
|
|
128
|
+
...keywordElementNodes,
|
|
129
|
+
]);
|
|
115
130
|
rootSectionNodes.unshift(node);
|
|
116
131
|
}
|
|
117
132
|
}
|
|
118
133
|
createRootSectionNodes() {
|
|
119
|
-
let rootSections = getSections(this.modelMap)
|
|
134
|
+
let rootSections = getSections(this.modelMap)
|
|
135
|
+
.filter((section) => !section.path || section.path.length <= 1)
|
|
136
|
+
.filter((section) => section.category !== 'MPSectionCategory:contributors' &&
|
|
137
|
+
section.category !== 'MPSectionCategory:affiliations' &&
|
|
138
|
+
section.category !== 'MPSectionCategory:keywords');
|
|
120
139
|
rootSections = this.addGeneratedLabels(rootSections);
|
|
121
|
-
const
|
|
140
|
+
const sectionGroups = (0, utils_1.groupBy)(rootSections, (sec) => {
|
|
141
|
+
var _a;
|
|
142
|
+
return (0, section_category_1.chooseCoreSectionBySection)((_a = sec.category) !== null && _a !== void 0 ? _a : '');
|
|
143
|
+
});
|
|
144
|
+
this.ensureCoreSectionsExist(sectionGroups);
|
|
145
|
+
const absSectionNode = sectionGroups['MPSectionCategory:abstracts']
|
|
122
146
|
.map(this.decode)
|
|
123
147
|
.filter(exports.isManuscriptNode);
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
148
|
+
const bodySectionNodes = sectionGroups['MPSectionCategory:body']
|
|
149
|
+
.map(this.decode)
|
|
150
|
+
.filter(exports.isManuscriptNode);
|
|
151
|
+
const backmatterSectionNodes = sectionGroups['MPSectionCategory:backmatter']
|
|
152
|
+
.map(this.decode)
|
|
153
|
+
.filter(exports.isManuscriptNode);
|
|
154
|
+
const abstractCoreSectionNodes = this.createAndFill(schema_1.schema.nodes.abstracts, absSectionNode);
|
|
155
|
+
const bodyCoreSectionNodes = this.createAndFill(schema_1.schema.nodes.body, bodySectionNodes);
|
|
156
|
+
const backmatterCoreSectionNodes = this.createAndFill(schema_1.schema.nodes.backmatter, backmatterSectionNodes);
|
|
157
|
+
return [
|
|
158
|
+
abstractCoreSectionNodes,
|
|
159
|
+
bodyCoreSectionNodes,
|
|
160
|
+
backmatterCoreSectionNodes,
|
|
161
|
+
];
|
|
162
|
+
}
|
|
163
|
+
ensureCoreSectionsExist(coreSections) {
|
|
164
|
+
if (!coreSections['MPSectionCategory:abstracts']) {
|
|
165
|
+
coreSections['MPSectionCategory:abstracts'] = [];
|
|
129
166
|
}
|
|
130
|
-
|
|
167
|
+
if (!coreSections['MPSectionCategory:body']) {
|
|
168
|
+
coreSections['MPSectionCategory:body'] = [];
|
|
169
|
+
}
|
|
170
|
+
if (!coreSections['MPSectionCategory:backmatter']) {
|
|
171
|
+
coreSections['MPSectionCategory:backmatter'] = [];
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
createAndFill(nodeType, content) {
|
|
175
|
+
return nodeType.createAndFill({
|
|
176
|
+
id: (0, id_1.generateNodeID)(nodeType),
|
|
177
|
+
}, content);
|
|
131
178
|
}
|
|
132
179
|
createCommentsNode(model) {
|
|
133
180
|
const comments = [];
|
|
@@ -632,6 +679,7 @@ class Decoder {
|
|
|
632
679
|
this.getModel = (id) => this.modelMap.get(id);
|
|
633
680
|
this.createArticleNode = (manuscriptID) => {
|
|
634
681
|
const rootSectionNodes = this.createRootSectionNodes();
|
|
682
|
+
this.handleMissingRootSectionNodes(rootSectionNodes);
|
|
635
683
|
const metaSectionNode = this.createMetaSectionNode();
|
|
636
684
|
const contents = [...rootSectionNodes, metaSectionNode];
|
|
637
685
|
return schema_1.schema.nodes.manuscript.create({
|
|
@@ -425,31 +425,6 @@ const encoders = {
|
|
|
425
425
|
keywords_group: (node) => ({
|
|
426
426
|
type: node.attrs.type,
|
|
427
427
|
}),
|
|
428
|
-
keywords_section: (node, parent, path, priority) => ({
|
|
429
|
-
category: (0, section_category_1.buildSectionCategory)(node),
|
|
430
|
-
priority: priority.value++,
|
|
431
|
-
title: inlineContentsOfNodeType(node, node.type.schema.nodes.section_title),
|
|
432
|
-
path: path.concat([node.attrs.id]),
|
|
433
|
-
elementIDs: childElements(node)
|
|
434
|
-
.map((childNode) => childNode.attrs.id)
|
|
435
|
-
.filter((id) => id),
|
|
436
|
-
}),
|
|
437
|
-
affiliations_section: (node, parent, path, priority) => ({
|
|
438
|
-
category: (0, section_category_1.buildSectionCategory)(node),
|
|
439
|
-
priority: priority.value++,
|
|
440
|
-
path: path.concat([node.attrs.id]),
|
|
441
|
-
elementIDs: childElements(node)
|
|
442
|
-
.map((childNode) => childNode.attrs.id)
|
|
443
|
-
.filter((id) => id),
|
|
444
|
-
}),
|
|
445
|
-
contributors_section: (node, parent, path, priority) => ({
|
|
446
|
-
category: (0, section_category_1.buildSectionCategory)(node),
|
|
447
|
-
priority: priority.value++,
|
|
448
|
-
path: path.concat([node.attrs.id]),
|
|
449
|
-
elementIDs: childElements(node)
|
|
450
|
-
.map((childNode) => childNode.attrs.id)
|
|
451
|
-
.filter((id) => id),
|
|
452
|
-
}),
|
|
453
428
|
missing_figure: (node) => ({
|
|
454
429
|
position: node.attrs.position || undefined,
|
|
455
430
|
}),
|
|
@@ -570,6 +545,14 @@ const modelFromNode = (node, parent, path, priority) => {
|
|
|
570
545
|
return { model, commentAnnotationsMap };
|
|
571
546
|
};
|
|
572
547
|
exports.modelFromNode = modelFromNode;
|
|
548
|
+
function isCoreSection(child) {
|
|
549
|
+
return (child.type === schema_1.schema.nodes.abstracts ||
|
|
550
|
+
child.type === schema_1.schema.nodes.body ||
|
|
551
|
+
child.type === schema_1.schema.nodes.backmatter ||
|
|
552
|
+
child.type === schema_1.schema.nodes.affiliations ||
|
|
553
|
+
child.type === schema_1.schema.nodes.contributors ||
|
|
554
|
+
child.type === schema_1.schema.nodes.keywords);
|
|
555
|
+
}
|
|
573
556
|
const encode = (node) => {
|
|
574
557
|
const models = new Map();
|
|
575
558
|
const priority = {
|
|
@@ -577,6 +560,10 @@ const encode = (node) => {
|
|
|
577
560
|
};
|
|
578
561
|
const placeholders = ['placeholder', 'placeholder_element'];
|
|
579
562
|
const addModel = (path, parent) => (child) => {
|
|
563
|
+
if (isCoreSection(child)) {
|
|
564
|
+
child.forEach(addModel([], child));
|
|
565
|
+
return;
|
|
566
|
+
}
|
|
580
567
|
if (!child.attrs.id) {
|
|
581
568
|
return;
|
|
582
569
|
}
|
|
@@ -38,6 +38,6 @@ exports.nodeNames = new Map([
|
|
|
38
38
|
[schema_1.schema.nodes.table_element, 'Table'],
|
|
39
39
|
[schema_1.schema.nodes.blockquote_element, 'Block Quote'],
|
|
40
40
|
[schema_1.schema.nodes.pullquote_element, 'Pull Quote'],
|
|
41
|
-
[schema_1.schema.nodes.
|
|
41
|
+
[schema_1.schema.nodes.keywords, 'Section'],
|
|
42
42
|
[schema_1.schema.nodes.toc_section, 'Section'],
|
|
43
43
|
]);
|
|
@@ -48,7 +48,7 @@ const nodeTitle = (node) => {
|
|
|
48
48
|
case nodes.section:
|
|
49
49
|
case nodes.bibliography_section:
|
|
50
50
|
case nodes.footnotes_section:
|
|
51
|
-
case nodes.
|
|
51
|
+
case nodes.keywords:
|
|
52
52
|
case nodes.toc_section:
|
|
53
53
|
case nodes.graphical_abstract_section:
|
|
54
54
|
return snippetOfNodeType(node, nodes.section_title);
|
|
@@ -19,6 +19,9 @@ exports.isNodeType = exports.isSectionNodeType = exports.isElementNodeType = exp
|
|
|
19
19
|
const json_schema_1 = require("@manuscripts/json-schema");
|
|
20
20
|
const schema_1 = require("../schema");
|
|
21
21
|
exports.nodeTypesMap = new Map([
|
|
22
|
+
[schema_1.schema.nodes.abstracts, json_schema_1.ObjectTypes.Section],
|
|
23
|
+
[schema_1.schema.nodes.body, json_schema_1.ObjectTypes.Section],
|
|
24
|
+
[schema_1.schema.nodes.backmatter, json_schema_1.ObjectTypes.Section],
|
|
22
25
|
[schema_1.schema.nodes.comment, json_schema_1.ObjectTypes.CommentAnnotation],
|
|
23
26
|
[schema_1.schema.nodes.bibliography_item, json_schema_1.ObjectTypes.BibliographyItem],
|
|
24
27
|
[schema_1.schema.nodes.bibliography_element, json_schema_1.ObjectTypes.BibliographyElement],
|
|
@@ -40,7 +43,7 @@ exports.nodeTypesMap = new Map([
|
|
|
40
43
|
[schema_1.schema.nodes.inline_equation, json_schema_1.ObjectTypes.InlineMathFragment],
|
|
41
44
|
[schema_1.schema.nodes.keyword, json_schema_1.ObjectTypes.Keyword],
|
|
42
45
|
[schema_1.schema.nodes.keywords_element, json_schema_1.ObjectTypes.KeywordsElement],
|
|
43
|
-
[schema_1.schema.nodes.
|
|
46
|
+
[schema_1.schema.nodes.keywords, json_schema_1.ObjectTypes.Section],
|
|
44
47
|
[schema_1.schema.nodes.keywords_group, json_schema_1.ObjectTypes.KeywordGroup],
|
|
45
48
|
[schema_1.schema.nodes.listing, json_schema_1.ObjectTypes.Listing],
|
|
46
49
|
[schema_1.schema.nodes.listing_element, json_schema_1.ObjectTypes.ListingElement],
|
|
@@ -57,8 +60,8 @@ exports.nodeTypesMap = new Map([
|
|
|
57
60
|
[schema_1.schema.nodes.affiliation, json_schema_1.ObjectTypes.Affiliation],
|
|
58
61
|
[schema_1.schema.nodes.contributor, json_schema_1.ObjectTypes.Contributor],
|
|
59
62
|
[schema_1.schema.nodes.table_element_footer, json_schema_1.ObjectTypes.TableElementFooter],
|
|
60
|
-
[schema_1.schema.nodes.
|
|
61
|
-
[schema_1.schema.nodes.
|
|
63
|
+
[schema_1.schema.nodes.contributors, json_schema_1.ObjectTypes.Section],
|
|
64
|
+
[schema_1.schema.nodes.affiliations, json_schema_1.ObjectTypes.Section],
|
|
62
65
|
]);
|
|
63
66
|
const isExecutableNodeType = (type) => (0, schema_1.hasGroup)(type, schema_1.GROUP_EXECUTABLE);
|
|
64
67
|
exports.isExecutableNodeType = isExecutableNodeType;
|
|
@@ -15,14 +15,14 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.chooseSectionCategoryFromTitle = exports.chooseSectionCategory = exports.chooseSectionCategoryByType = exports.chooseSecType = exports.chooseJatsFnType = exports.buildSectionCategory = exports.guessSectionCategory = exports.chooseSectionLableName = exports.chooseSectionNodeType = exports.isAnySectionNode = exports.getCoreSectionTitles = void 0;
|
|
18
|
+
exports.chooseSectionCategoryFromTitle = exports.chooseSectionCategory = exports.chooseSectionCategoryByType = exports.chooseCoreSectionBySection = exports.chooseSecType = exports.chooseJatsFnType = exports.buildSectionCategory = exports.guessSectionCategory = exports.chooseSectionLableName = exports.chooseSectionNodeType = exports.isAnySectionNode = exports.getCoreSectionTitles = void 0;
|
|
19
19
|
const json_schema_1 = require("@manuscripts/json-schema");
|
|
20
20
|
const core_section_categories_1 = require("../lib/core-section-categories");
|
|
21
21
|
const schema_1 = require("../schema");
|
|
22
22
|
const sectionNodeTypes = [
|
|
23
23
|
schema_1.schema.nodes.bibliography_section,
|
|
24
24
|
schema_1.schema.nodes.footnotes_section,
|
|
25
|
-
schema_1.schema.nodes.
|
|
25
|
+
schema_1.schema.nodes.keywords,
|
|
26
26
|
schema_1.schema.nodes.section,
|
|
27
27
|
schema_1.schema.nodes.toc_section,
|
|
28
28
|
];
|
|
@@ -45,11 +45,11 @@ const chooseSectionNodeType = (category) => {
|
|
|
45
45
|
case 'MPSectionCategory:endnotes':
|
|
46
46
|
return schema_1.schema.nodes.footnotes_section;
|
|
47
47
|
case 'MPSectionCategory:keywords':
|
|
48
|
-
return schema_1.schema.nodes.
|
|
48
|
+
return schema_1.schema.nodes.keywords;
|
|
49
49
|
case 'MPSectionCategory:affiliations':
|
|
50
|
-
return schema_1.schema.nodes.
|
|
50
|
+
return schema_1.schema.nodes.affiliations;
|
|
51
51
|
case 'MPSectionCategory:contributors':
|
|
52
|
-
return schema_1.schema.nodes.
|
|
52
|
+
return schema_1.schema.nodes.contributors;
|
|
53
53
|
case 'MPSectionCategory:toc':
|
|
54
54
|
return schema_1.schema.nodes.toc_section;
|
|
55
55
|
default:
|
|
@@ -90,15 +90,15 @@ const buildSectionCategory = (node) => {
|
|
|
90
90
|
return 'MPSectionCategory:bibliography';
|
|
91
91
|
case schema_1.schema.nodes.footnotes_section:
|
|
92
92
|
return 'MPSectionCategory:endnotes';
|
|
93
|
-
case schema_1.schema.nodes.
|
|
93
|
+
case schema_1.schema.nodes.keywords:
|
|
94
94
|
return 'MPSectionCategory:keywords';
|
|
95
95
|
case schema_1.schema.nodes.toc_section:
|
|
96
96
|
return 'MPSectionCategory:toc';
|
|
97
97
|
case schema_1.schema.nodes.graphical_abstract_section:
|
|
98
98
|
return 'MPSectionCategory:abstract-graphical';
|
|
99
|
-
case schema_1.schema.nodes.
|
|
99
|
+
case schema_1.schema.nodes.affiliations:
|
|
100
100
|
return 'MPSectionCategory:affiliations';
|
|
101
|
-
case schema_1.schema.nodes.
|
|
101
|
+
case schema_1.schema.nodes.contributors:
|
|
102
102
|
return 'MPSectionCategory:contributors';
|
|
103
103
|
default:
|
|
104
104
|
return node.attrs.category || undefined;
|
|
@@ -128,6 +128,33 @@ const chooseSecType = (sectionCategory) => {
|
|
|
128
128
|
}
|
|
129
129
|
};
|
|
130
130
|
exports.chooseSecType = chooseSecType;
|
|
131
|
+
const chooseCoreSectionBySection = (section) => {
|
|
132
|
+
switch (section) {
|
|
133
|
+
case 'MPSectionCategory:abstract':
|
|
134
|
+
case 'MPSectionCategory:abstract-teaser':
|
|
135
|
+
case 'MPSectionCategory:abstract-graphical':
|
|
136
|
+
return 'MPSectionCategory:abstracts';
|
|
137
|
+
case 'MPSectionCategory:acknowledgement':
|
|
138
|
+
case 'MPSectionCategory:availability':
|
|
139
|
+
case 'MPSectionCategory:conclusions':
|
|
140
|
+
case 'MPSectionCategory:bibliography':
|
|
141
|
+
case 'MPSectionCategory:discussion':
|
|
142
|
+
case 'MPSectionCategory:endnotes':
|
|
143
|
+
case 'MPSectionCategory:appendices':
|
|
144
|
+
case 'MPSectionCategory:competing-interests':
|
|
145
|
+
case 'MPSectionCategory:con':
|
|
146
|
+
case 'MPSectionCategory:deceased':
|
|
147
|
+
case 'MPSectionCategory:ethics-statement':
|
|
148
|
+
case 'MPSectionCategory:financial-disclosure':
|
|
149
|
+
case 'MPSectionCategory:supplementary-material':
|
|
150
|
+
case 'MPSectionCategory:supported-by':
|
|
151
|
+
case 'MPSectionCategory:abbreviations':
|
|
152
|
+
case 'MPSectionCategory:results':
|
|
153
|
+
return 'MPSectionCategory:backmatter';
|
|
154
|
+
}
|
|
155
|
+
return 'MPSectionCategory:body';
|
|
156
|
+
};
|
|
157
|
+
exports.chooseCoreSectionBySection = chooseCoreSectionBySection;
|
|
131
158
|
const chooseSectionCategoryByType = (secType) => {
|
|
132
159
|
switch (secType) {
|
|
133
160
|
case 'abstract':
|