@manuscripts/transform 1.5.7 → 1.5.8-LEAN-3030-1

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.
Files changed (133) hide show
  1. package/dist/cjs/index.js +1 -1
  2. package/dist/cjs/jats/importer/index.js +1 -3
  3. package/dist/cjs/jats/importer/jats-body-dom-parser.js +23 -227
  4. package/dist/cjs/jats/importer/jats-body-transformations.js +110 -201
  5. package/dist/cjs/jats/importer/jats-comments.js +100 -98
  6. package/dist/cjs/jats/importer/jats-front-parser.js +87 -81
  7. package/dist/cjs/jats/importer/jats-journal-meta-parser.js +51 -39
  8. package/dist/cjs/jats/importer/jats-parser-utils.js +17 -56
  9. package/dist/cjs/jats/importer/jats-reference-parser.js +24 -79
  10. package/dist/cjs/jats/importer/jats-references.js +34 -0
  11. package/dist/cjs/jats/importer/parse-jats-article.js +67 -173
  12. package/dist/cjs/jats/index.js +1 -3
  13. package/dist/cjs/jats/jats-exporter.js +33 -54
  14. package/dist/cjs/lib/section-group-type.js +30 -0
  15. package/dist/cjs/lib/utils.js +14 -12
  16. package/dist/cjs/schema/index.js +20 -17
  17. package/dist/cjs/schema/nodes/abstracts.js +27 -0
  18. package/dist/cjs/schema/nodes/affiliations.js +27 -0
  19. package/dist/cjs/schema/nodes/backmatter.js +27 -0
  20. package/dist/cjs/schema/nodes/body.js +27 -0
  21. package/dist/cjs/schema/nodes/citation.js +10 -15
  22. package/dist/cjs/schema/nodes/{comment_list.js → comments.js} +4 -4
  23. package/dist/cjs/schema/nodes/contributors.js +27 -0
  24. package/dist/cjs/schema/nodes/{meta_section.js → core_section.js} +6 -5
  25. package/dist/cjs/schema/nodes/cross_reference.js +4 -3
  26. package/dist/cjs/schema/nodes/inline_footnote.js +6 -5
  27. package/dist/cjs/schema/nodes/keyword.js +0 -1
  28. package/dist/cjs/schema/nodes/{keywords_group.js → keyword_group.js} +6 -6
  29. package/dist/cjs/schema/nodes/{keywords_section.js → keywords.js} +7 -7
  30. package/dist/cjs/schema/nodes/keywords_element.js +1 -1
  31. package/dist/cjs/schema/nodes/manuscript.js +5 -2
  32. package/dist/cjs/transformer/builders.js +9 -86
  33. package/dist/cjs/transformer/decode.js +129 -165
  34. package/dist/cjs/transformer/encode.js +54 -45
  35. package/dist/cjs/transformer/highlight-markers.js +4 -4
  36. package/dist/cjs/transformer/html.js +5 -20
  37. package/dist/cjs/transformer/labels.js +3 -17
  38. package/dist/cjs/transformer/node-names.js +1 -1
  39. package/dist/cjs/transformer/node-title.js +1 -1
  40. package/dist/cjs/transformer/node-types.js +7 -6
  41. package/dist/cjs/transformer/object-types.js +1 -2
  42. package/dist/cjs/transformer/section-category.js +31 -31
  43. package/dist/es/index.js +1 -1
  44. package/dist/es/jats/importer/index.js +1 -1
  45. package/dist/es/jats/importer/jats-body-dom-parser.js +23 -227
  46. package/dist/es/jats/importer/jats-body-transformations.js +111 -202
  47. package/dist/es/jats/importer/jats-comments.js +97 -96
  48. package/dist/es/jats/importer/jats-front-parser.js +88 -82
  49. package/dist/es/jats/importer/jats-journal-meta-parser.js +51 -39
  50. package/dist/es/jats/importer/jats-parser-utils.js +16 -54
  51. package/dist/es/jats/importer/jats-reference-parser.js +27 -82
  52. package/dist/es/jats/importer/jats-references.js +30 -0
  53. package/dist/es/jats/importer/parse-jats-article.js +70 -174
  54. package/dist/es/jats/index.js +1 -1
  55. package/dist/es/jats/jats-exporter.js +33 -54
  56. package/dist/es/lib/section-group-type.js +27 -0
  57. package/dist/es/lib/utils.js +12 -10
  58. package/dist/es/schema/index.js +21 -18
  59. package/dist/es/schema/nodes/abstracts.js +24 -0
  60. package/dist/es/schema/nodes/affiliations.js +24 -0
  61. package/dist/es/schema/nodes/backmatter.js +24 -0
  62. package/dist/es/schema/nodes/body.js +24 -0
  63. package/dist/es/schema/nodes/citation.js +10 -15
  64. package/dist/es/schema/nodes/{comment_list.js → comments.js} +3 -3
  65. package/dist/es/schema/nodes/contributors.js +24 -0
  66. package/dist/es/schema/nodes/{meta_section.js → core_section.js} +5 -4
  67. package/dist/es/schema/nodes/cross_reference.js +4 -3
  68. package/dist/es/schema/nodes/inline_footnote.js +6 -5
  69. package/dist/es/schema/nodes/keyword.js +0 -1
  70. package/dist/es/schema/nodes/{keywords_group.js → keyword_group.js} +4 -4
  71. package/dist/es/schema/nodes/{keywords_section.js → keywords.js} +5 -5
  72. package/dist/es/schema/nodes/keywords_element.js +1 -1
  73. package/dist/es/schema/nodes/manuscript.js +3 -1
  74. package/dist/es/transformer/builders.js +6 -73
  75. package/dist/es/transformer/decode.js +129 -164
  76. package/dist/es/transformer/encode.js +57 -48
  77. package/dist/es/transformer/highlight-markers.js +1 -1
  78. package/dist/es/transformer/html.js +5 -20
  79. package/dist/es/transformer/labels.js +3 -17
  80. package/dist/es/transformer/node-names.js +1 -1
  81. package/dist/es/transformer/node-title.js +1 -1
  82. package/dist/es/transformer/node-types.js +7 -6
  83. package/dist/es/transformer/object-types.js +0 -1
  84. package/dist/es/transformer/section-category.js +29 -29
  85. package/dist/types/index.d.ts +1 -1
  86. package/dist/types/jats/importer/index.d.ts +1 -1
  87. package/dist/types/jats/importer/jats-body-transformations.d.ts +16 -19
  88. package/dist/types/jats/importer/jats-comments.d.ts +13 -9
  89. package/dist/types/jats/importer/jats-front-parser.d.ts +35 -12
  90. package/dist/types/jats/importer/jats-journal-meta-parser.d.ts +4 -4
  91. package/dist/types/jats/importer/jats-parser-utils.d.ts +1 -6
  92. package/dist/types/jats/importer/jats-reference-parser.d.ts +2 -6
  93. package/dist/types/jats/importer/jats-references.d.ts +12 -0
  94. package/dist/types/jats/importer/parse-jats-article.d.ts +5 -17
  95. package/dist/types/jats/index.d.ts +1 -1
  96. package/dist/types/lib/section-group-type.d.ts +23 -0
  97. package/dist/types/lib/utils.d.ts +3 -2
  98. package/dist/types/schema/index.d.ts +4 -5
  99. package/dist/types/schema/nodes/{meta_section.d.ts → abstracts.d.ts} +1 -9
  100. package/dist/types/schema/nodes/affiliations.d.ts +17 -0
  101. package/dist/types/schema/nodes/backmatter.d.ts +17 -0
  102. package/dist/types/schema/nodes/body.d.ts +17 -0
  103. package/dist/types/schema/nodes/citation.d.ts +3 -5
  104. package/dist/types/schema/nodes/comments.d.ts +17 -0
  105. package/dist/types/schema/nodes/contributors.d.ts +17 -0
  106. package/dist/types/schema/nodes/core_section.d.ts +17 -0
  107. package/dist/types/schema/nodes/cross_reference.d.ts +1 -1
  108. package/dist/types/schema/nodes/inline_footnote.d.ts +1 -1
  109. package/dist/types/schema/nodes/keyword.d.ts +0 -1
  110. package/dist/types/schema/nodes/{contributors_element.d.ts → keyword_group.d.ts} +3 -4
  111. package/dist/types/schema/nodes/{comment_list.d.ts → keywords.d.ts} +3 -2
  112. package/dist/types/schema/nodes/manuscript.d.ts +1 -0
  113. package/dist/types/schema/types.d.ts +1 -1
  114. package/dist/types/transformer/builders.d.ts +2 -14
  115. package/dist/types/transformer/decode.d.ts +5 -9
  116. package/dist/types/transformer/encode.d.ts +1 -1
  117. package/dist/types/transformer/highlight-markers.d.ts +1 -0
  118. package/dist/types/transformer/object-types.d.ts +1 -2
  119. package/dist/types/transformer/section-category.d.ts +4 -3
  120. package/package.json +1 -1
  121. package/dist/cjs/lib/core-section-categories.js +0 -29
  122. package/dist/cjs/schema/nodes/affiliations_section.js +0 -36
  123. package/dist/cjs/schema/nodes/contributors_element.js +0 -49
  124. package/dist/cjs/schema/nodes/contributors_section.js +0 -36
  125. package/dist/es/lib/core-section-categories.js +0 -26
  126. package/dist/es/schema/nodes/affiliations_section.js +0 -32
  127. package/dist/es/schema/nodes/contributors_element.js +0 -46
  128. package/dist/es/schema/nodes/contributors_section.js +0 -32
  129. package/dist/types/lib/core-section-categories.d.ts +0 -8
  130. package/dist/types/schema/nodes/affiliations_section.d.ts +0 -11
  131. package/dist/types/schema/nodes/contributors_section.d.ts +0 -12
  132. package/dist/types/schema/nodes/keywords_group.d.ts +0 -26
  133. package/dist/types/schema/nodes/keywords_section.d.ts +0 -26
@@ -15,15 +15,15 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.insertHighlightMarkers = exports.extractHighlightMarkers = exports.isHighlightableModel = void 0;
18
+ exports.insertHighlightMarkers = exports.extractHighlightMarkers = exports.isHighlightableModel = exports.highlightableFields = void 0;
19
19
  const builders_1 = require("./builders");
20
- const highlightableFields = [
20
+ exports.highlightableFields = [
21
21
  'caption',
22
22
  'contents',
23
23
  'title',
24
24
  ];
25
25
  const isHighlightableModel = (model) => {
26
- for (const field of highlightableFields) {
26
+ for (const field of exports.highlightableFields) {
27
27
  if (field in model) {
28
28
  return true;
29
29
  }
@@ -32,7 +32,7 @@ const isHighlightableModel = (model) => {
32
32
  };
33
33
  exports.isHighlightableModel = isHighlightableModel;
34
34
  const extractHighlightMarkers = (model, commentAnnotationsMap) => {
35
- for (const field of highlightableFields) {
35
+ for (const field of exports.highlightableFields) {
36
36
  let html = model[field];
37
37
  if (html === undefined) {
38
38
  continue;
@@ -200,11 +200,9 @@ class HTMLTransformer {
200
200
  const citationNode = node;
201
201
  const element = this.document.createElement('span');
202
202
  element.setAttribute('class', 'citation');
203
- const citation = getModel(citationNode.attrs.rid);
204
- if (citation) {
205
- element.setAttribute('data-reference-ids', citation.embeddedCitationItems
206
- .map((item) => item.bibliographyItem)
207
- .join(' '));
203
+ const rids = citationNode.attrs.rids;
204
+ if (rids.length) {
205
+ element.setAttribute('data-reference-ids', rids.join(' '));
208
206
  }
209
207
  if (citationNode.attrs.contents) {
210
208
  element.innerHTML = citationNode.attrs.contents;
@@ -215,20 +213,7 @@ class HTMLTransformer {
215
213
  const crossReferenceNode = node;
216
214
  const element = this.document.createElement('a');
217
215
  element.classList.add('cross-reference');
218
- const auxiliaryObjectReference = getModel(crossReferenceNode.attrs.rid);
219
- if (auxiliaryObjectReference &&
220
- auxiliaryObjectReference.referencedObject) {
221
- if (auxiliaryObjectReference.referencedObject.startsWith('MPFigureElement')) {
222
- const model = getModel(auxiliaryObjectReference.referencedObject);
223
- if (model && model.containedObjectIDs.length > 0) {
224
- element.setAttribute('href', `#${model.containedObjectIDs[0]}`);
225
- }
226
- }
227
- else {
228
- element.setAttribute('href', `#${auxiliaryObjectReference.referencedObject}`);
229
- }
230
- element.setAttribute('data-reference-ids', crossReferenceNode.attrs.rid);
231
- }
216
+ element.setAttribute('data-reference-ids', crossReferenceNode.attrs.rids.join(' '));
232
217
  element.textContent =
233
218
  crossReferenceNode.attrs.customLabel || crossReferenceNode.attrs.label;
234
219
  return element;
@@ -262,7 +247,7 @@ class HTMLTransformer {
262
247
  };
263
248
  return ['span', attrs];
264
249
  };
265
- nodes.meta_section = () => '';
250
+ nodes.comments = () => '';
266
251
  const serializer = new prosemirror_model_1.DOMSerializer(nodes, marks);
267
252
  return serializer.serializeFragment(fragment, { document });
268
253
  };
@@ -30,6 +30,7 @@ const labelProperties = new Map([
30
30
  [schema_1.schema.nodes.equation_element, 'equationElementLabel'],
31
31
  [schema_1.schema.nodes.listing_element, 'listingElementLabel'],
32
32
  ]);
33
+ const excludedTypes = [schema_1.schema.nodes.graphical_abstract_section];
33
34
  const chooseLabel = (nodeType, manuscript) => {
34
35
  const labelProperty = labelProperties.get(nodeType);
35
36
  if (labelProperty) {
@@ -54,25 +55,10 @@ const buildTargets = (fragment, manuscript) => {
54
55
  return `${counter.label} ${counter.index}`;
55
56
  };
56
57
  const targets = new Map();
57
- const figures = [];
58
- fragment.forEach((node) => {
59
- if (node.attrs.category === 'MPSectionCategory:abstracts') {
60
- node.forEach((child) => {
61
- if (child.type === node.type.schema.nodes.graphical_abstract_section) {
62
- child.forEach((item) => {
63
- if (item.type === node.type.schema.nodes.figure_element) {
64
- figures.push(item.attrs.id);
65
- }
66
- });
67
- }
68
- });
69
- }
70
- });
71
- fragment.descendants((node) => {
58
+ fragment.descendants((node, pos, parent) => {
72
59
  var _a;
73
60
  if (node.type.name in counters) {
74
- const isInGraphicalAbstract = figures.indexOf(node.attrs.id) > -1;
75
- if (isInGraphicalAbstract) {
61
+ if (parent && excludedTypes.includes(parent.type)) {
76
62
  return;
77
63
  }
78
64
  const label = buildLabel(node.type);
@@ -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.keywords_section, 'Section'],
41
+ [schema_1.schema.nodes.keywords, 'Section'],
42
42
  [schema_1.schema.nodes.toc_section, 'Section'],
43
43
  ]);
@@ -50,7 +50,7 @@ const nodeTitle = (node) => {
50
50
  case nodes.section:
51
51
  case nodes.bibliography_section:
52
52
  case nodes.footnotes_section:
53
- case nodes.keywords_section:
53
+ case nodes.keywords:
54
54
  case nodes.toc_section:
55
55
  case nodes.graphical_abstract_section:
56
56
  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],
@@ -26,7 +29,6 @@ exports.nodeTypesMap = new Map([
26
29
  [schema_1.schema.nodes.blockquote_element, json_schema_1.ObjectTypes.QuoteElement],
27
30
  [schema_1.schema.nodes.bullet_list, json_schema_1.ObjectTypes.ListElement],
28
31
  [schema_1.schema.nodes.citation, json_schema_1.ObjectTypes.Citation],
29
- [schema_1.schema.nodes.cross_reference, json_schema_1.ObjectTypes.AuxiliaryObjectReference],
30
32
  [schema_1.schema.nodes.equation, json_schema_1.ObjectTypes.Equation],
31
33
  [schema_1.schema.nodes.equation_element, json_schema_1.ObjectTypes.EquationElement],
32
34
  [schema_1.schema.nodes.figure, json_schema_1.ObjectTypes.Figure],
@@ -40,8 +42,8 @@ exports.nodeTypesMap = new Map([
40
42
  [schema_1.schema.nodes.inline_equation, json_schema_1.ObjectTypes.InlineMathFragment],
41
43
  [schema_1.schema.nodes.keyword, json_schema_1.ObjectTypes.Keyword],
42
44
  [schema_1.schema.nodes.keywords_element, json_schema_1.ObjectTypes.KeywordsElement],
43
- [schema_1.schema.nodes.keywords_section, json_schema_1.ObjectTypes.Section],
44
- [schema_1.schema.nodes.keywords_group, json_schema_1.ObjectTypes.KeywordGroup],
45
+ [schema_1.schema.nodes.keywords, json_schema_1.ObjectTypes.Section],
46
+ [schema_1.schema.nodes.keyword_group, json_schema_1.ObjectTypes.KeywordGroup],
45
47
  [schema_1.schema.nodes.listing, json_schema_1.ObjectTypes.Listing],
46
48
  [schema_1.schema.nodes.listing_element, json_schema_1.ObjectTypes.ListingElement],
47
49
  [schema_1.schema.nodes.manuscript, json_schema_1.ObjectTypes.Manuscript],
@@ -53,13 +55,12 @@ exports.nodeTypesMap = new Map([
53
55
  [schema_1.schema.nodes.table_element, json_schema_1.ObjectTypes.TableElement],
54
56
  [schema_1.schema.nodes.toc_element, json_schema_1.ObjectTypes.TOCElement],
55
57
  [schema_1.schema.nodes.toc_section, json_schema_1.ObjectTypes.Section],
56
- [schema_1.schema.nodes.meta_section, json_schema_1.ObjectTypes.MetaSection],
57
58
  [schema_1.schema.nodes.affiliation, json_schema_1.ObjectTypes.Affiliation],
58
59
  [schema_1.schema.nodes.contributor, json_schema_1.ObjectTypes.Contributor],
59
60
  [schema_1.schema.nodes.table_element_footer, json_schema_1.ObjectTypes.TableElementFooter],
61
+ [schema_1.schema.nodes.contributors, json_schema_1.ObjectTypes.Section],
62
+ [schema_1.schema.nodes.affiliations, json_schema_1.ObjectTypes.Section],
60
63
  [schema_1.schema.nodes.title, json_schema_1.ObjectTypes.Titles],
61
- [schema_1.schema.nodes.contributors_section, json_schema_1.ObjectTypes.Section],
62
- [schema_1.schema.nodes.affiliations_section, json_schema_1.ObjectTypes.Section],
63
64
  ]);
64
65
  const isExecutableNodeType = (type) => (0, schema_1.hasGroup)(type, schema_1.GROUP_EXECUTABLE);
65
66
  exports.isExecutableNodeType = isExecutableNodeType;
@@ -15,7 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.isKeyword = exports.isCommentAnnotation = exports.isUserProfile = exports.isTable = exports.isManuscript = exports.isFigure = exports.hasObjectType = exports.isManuscriptModel = exports.manuscriptObjects = exports.elementObjects = exports.ExtraObjectTypes = void 0;
18
+ exports.isKeyword = exports.isCommentAnnotation = exports.isTable = exports.isManuscript = exports.isFigure = exports.hasObjectType = exports.isManuscriptModel = exports.manuscriptObjects = exports.elementObjects = exports.ExtraObjectTypes = void 0;
19
19
  const json_schema_1 = require("@manuscripts/json-schema");
20
20
  var ExtraObjectTypes;
21
21
  (function (ExtraObjectTypes) {
@@ -53,6 +53,5 @@ exports.hasObjectType = hasObjectType;
53
53
  exports.isFigure = (0, exports.hasObjectType)(json_schema_1.ObjectTypes.Figure);
54
54
  exports.isManuscript = (0, exports.hasObjectType)(json_schema_1.ObjectTypes.Manuscript);
55
55
  exports.isTable = (0, exports.hasObjectType)(json_schema_1.ObjectTypes.Table);
56
- exports.isUserProfile = (0, exports.hasObjectType)(json_schema_1.ObjectTypes.UserProfile);
57
56
  exports.isCommentAnnotation = (0, exports.hasObjectType)(json_schema_1.ObjectTypes.CommentAnnotation);
58
57
  exports.isKeyword = (0, exports.hasObjectType)(json_schema_1.ObjectTypes.Keyword);
@@ -15,25 +15,17 @@
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.getSectionGroupType = exports.chooseSecType = exports.chooseJatsFnType = exports.buildSectionCategory = exports.guessSectionCategory = exports.chooseSectionLableName = exports.chooseSectionNodeType = exports.isAnySectionNode = void 0;
19
19
  const json_schema_1 = require("@manuscripts/json-schema");
20
- const core_section_categories_1 = require("../lib/core-section-categories");
20
+ const section_group_type_1 = require("../lib/section-group-type");
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.keywords_section,
25
+ schema_1.schema.nodes.keywords,
26
26
  schema_1.schema.nodes.section,
27
27
  schema_1.schema.nodes.toc_section,
28
28
  ];
29
- const getCoreSectionTitles = (sectionCategory) => {
30
- const category = core_section_categories_1.coreSectionCategories.find((section) => section._id === sectionCategory);
31
- if (category) {
32
- return category.titles.length ? category.titles : [' '];
33
- }
34
- throw new Error(`${sectionCategory} not found in core sections`);
35
- };
36
- exports.getCoreSectionTitles = getCoreSectionTitles;
37
29
  const isAnySectionNode = (node) => sectionNodeTypes.includes(node.type);
38
30
  exports.isAnySectionNode = isAnySectionNode;
39
31
  const chooseSectionNodeType = (category) => {
@@ -45,11 +37,7 @@ const chooseSectionNodeType = (category) => {
45
37
  case 'MPSectionCategory:endnotes':
46
38
  return schema_1.schema.nodes.footnotes_section;
47
39
  case 'MPSectionCategory:keywords':
48
- return schema_1.schema.nodes.keywords_section;
49
- case 'MPSectionCategory:affiliations':
50
- return schema_1.schema.nodes.affiliations_section;
51
- case 'MPSectionCategory:contributors':
52
- return schema_1.schema.nodes.contributors_section;
40
+ return schema_1.schema.nodes.keywords;
53
41
  case 'MPSectionCategory:toc':
54
42
  return schema_1.schema.nodes.toc_section;
55
43
  default:
@@ -90,16 +78,12 @@ const buildSectionCategory = (node) => {
90
78
  return 'MPSectionCategory:bibliography';
91
79
  case schema_1.schema.nodes.footnotes_section:
92
80
  return 'MPSectionCategory:endnotes';
93
- case schema_1.schema.nodes.keywords_section:
81
+ case schema_1.schema.nodes.keywords:
94
82
  return 'MPSectionCategory:keywords';
95
83
  case schema_1.schema.nodes.toc_section:
96
84
  return 'MPSectionCategory:toc';
97
85
  case schema_1.schema.nodes.graphical_abstract_section:
98
86
  return 'MPSectionCategory:abstract-graphical';
99
- case schema_1.schema.nodes.affiliations_section:
100
- return 'MPSectionCategory:affiliations';
101
- case schema_1.schema.nodes.contributors_section:
102
- return 'MPSectionCategory:contributors';
103
87
  default:
104
88
  return node.attrs.category || undefined;
105
89
  }
@@ -128,6 +112,32 @@ const chooseSecType = (sectionCategory) => {
128
112
  }
129
113
  };
130
114
  exports.chooseSecType = chooseSecType;
115
+ const getSectionGroupType = (category) => {
116
+ switch (category) {
117
+ case 'MPSectionCategory:abstract':
118
+ case 'MPSectionCategory:abstract-graphical':
119
+ return section_group_type_1.abstractsType;
120
+ case 'MPSectionCategory:competing-interests':
121
+ case 'MPSectionCategory:con':
122
+ case 'MPSectionCategory:ethics-statement':
123
+ case 'MPSectionCategory:financial-disclosure':
124
+ case 'MPSectionCategory:supplementary-material':
125
+ case 'MPSectionCategory:supported-by':
126
+ case 'MPSectionCategory:availability':
127
+ case 'MPSectionCategory:acknowledgement':
128
+ case 'MPSectionCategory:endnotes':
129
+ case 'MPSectionCategory:bibliography':
130
+ case 'MPSectionCategory:appendices':
131
+ case 'MPSectionCategory:deceased':
132
+ case 'MPSectionCategory:equal':
133
+ case 'MPSectionCategory:present-address':
134
+ case 'MPSectionCategory:presented-at':
135
+ case 'MPSectionCategory:previously-at':
136
+ return section_group_type_1.backmatterType;
137
+ }
138
+ return section_group_type_1.bodyType;
139
+ };
140
+ exports.getSectionGroupType = getSectionGroupType;
131
141
  const chooseSectionCategoryByType = (secType) => {
132
142
  switch (secType) {
133
143
  case 'abstract':
@@ -187,16 +197,6 @@ const chooseSectionCategoryByType = (secType) => {
187
197
  return 'MPSectionCategory:supported-by';
188
198
  case 'ethics-statement':
189
199
  return 'MPSectionCategory:ethics-statement';
190
- case 'body':
191
- return 'MPSectionCategory:body';
192
- case 'backmatter':
193
- return 'MPSectionCategory:backmatter';
194
- case 'abstracts':
195
- return 'MPSectionCategory:abstracts';
196
- case 'affiliations':
197
- return 'MPSectionCategory:affiliations';
198
- case 'contributors':
199
- return 'MPSectionCategory:contributors';
200
200
  default:
201
201
  return undefined;
202
202
  }
package/dist/es/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export * from './lib/core-section-categories';
1
+ export * from './lib/section-group-type';
2
2
  export * from './lib/table-cell-styles';
3
3
  export * from './lib/utils';
4
4
  export * from './mathjax';
@@ -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, parseJATSReferences, parseJATSArticle, getElementsOrder, } from './parse-jats-article';
16
+ export { parseJATSFront, parseJATSBody, parseJATSArticle, } from './parse-jats-article';
@@ -332,75 +332,6 @@ const nodes = [
332
332
  };
333
333
  },
334
334
  },
335
- {
336
- tag: 'ref',
337
- node: 'bibliography_item',
338
- context: 'bibliography_element/',
339
- getAttrs: (node) => {
340
- const element = node;
341
- const ref = {
342
- id: element.getAttribute('id'),
343
- type: element.getAttribute('type'),
344
- };
345
- const author = element.getAttribute('author');
346
- if (author) {
347
- ref.author = author;
348
- }
349
- const issued = element.getAttribute('issued');
350
- if (issued) {
351
- ref.issued = issued;
352
- }
353
- const containerTitle = element.getAttribute('container-title');
354
- if (containerTitle) {
355
- ref.containerTitle = containerTitle;
356
- }
357
- const doi = element.getAttribute('doi');
358
- if (doi) {
359
- ref.doi = doi;
360
- }
361
- const volume = element.getAttribute('volume');
362
- if (volume) {
363
- ref.volume = volume;
364
- }
365
- const issue = element.getAttribute('issue');
366
- if (issue) {
367
- ref.issue = issue;
368
- }
369
- const supplement = element.getAttribute('supplement');
370
- if (supplement) {
371
- ref.supplement = supplement;
372
- }
373
- const page = element.getAttribute('page');
374
- if (page) {
375
- ref.page = page;
376
- }
377
- const title = element.getAttribute('title');
378
- if (title) {
379
- ref.title = title;
380
- }
381
- const literal = element.getAttribute('literal');
382
- if (literal) {
383
- ref.literal = literal;
384
- }
385
- return ref;
386
- },
387
- },
388
- {
389
- tag: 'ref-list',
390
- node: 'bibliography_element',
391
- context: 'bibliography_section/',
392
- getAttrs: (node) => {
393
- const element = node;
394
- const titleNode = element.querySelector('title');
395
- if (titleNode) {
396
- element.removeChild(titleNode);
397
- }
398
- return {
399
- id: element.getAttribute('id'),
400
- contents: '',
401
- };
402
- },
403
- },
404
335
  {
405
336
  tag: 'fn-group',
406
337
  node: 'footnotes_element',
@@ -490,144 +421,24 @@ const nodes = [
490
421
  },
491
422
  },
492
423
  {
493
- tag: 'sec[sec-type="bibliography"]',
494
- node: 'bibliography_section',
495
- getAttrs: (node) => {
496
- const element = node;
497
- return {
498
- id: element.getAttribute('id'),
499
- };
500
- },
501
- },
502
- {
503
- tag: 'sec[sec-type="affiliations"]',
504
- node: 'affiliations_section',
505
- getAttrs: (node) => {
506
- const element = node;
507
- return {
508
- id: element.getAttribute('id'),
509
- category: 'MPSectionCategory:affiliations',
510
- };
511
- },
424
+ tag: 'sec[sec-type="keywords"]',
425
+ node: 'keywords',
512
426
  },
513
427
  {
514
- tag: 'aff',
515
- node: 'affiliation',
516
- context: 'affiliations_section/',
517
- getAttrs: (node) => {
518
- const element = node;
519
- const aff = {
520
- id: element.getAttribute('id'),
521
- };
522
- const institution = element.getAttribute('institution');
523
- if (institution) {
524
- aff.institution = institution;
525
- }
526
- const email = element.getAttribute('email');
527
- if (email) {
528
- aff.bibliographicName = JSON.parse(email);
529
- }
530
- const department = element.getAttribute('department');
531
- if (department) {
532
- aff.department = department;
533
- }
534
- const addressLine1 = element.getAttribute('addressLine1');
535
- if (addressLine1) {
536
- aff.addressLine1 = addressLine1;
537
- }
538
- const addressLine2 = element.getAttribute('addressLine2');
539
- if (addressLine2) {
540
- aff.addressLine2 = addressLine2;
541
- }
542
- const addressLine3 = element.getAttribute('addressLine3');
543
- if (addressLine3) {
544
- aff.addressLine3 = addressLine3;
545
- }
546
- const postCode = element.getAttribute('postCode');
547
- if (postCode) {
548
- aff.postCode = postCode;
549
- }
550
- const country = element.getAttribute('country');
551
- if (country) {
552
- aff.country = country;
553
- }
554
- const priority = element.getAttribute('priority');
555
- if (priority) {
556
- aff.priority = parseInt(priority);
557
- }
558
- return aff;
559
- },
428
+ tag: 'sec[sec-type="abstracts"]',
429
+ node: 'abstracts',
560
430
  },
561
431
  {
562
- tag: 'sec[sec-type="contributors"]',
563
- node: 'contributors_section',
564
- getAttrs: (node) => {
565
- const element = node;
566
- return {
567
- id: element.getAttribute('id'),
568
- category: 'MPSectionCategory:contributors',
569
- };
570
- },
432
+ tag: 'sec[sec-type="body"]',
433
+ node: 'body',
571
434
  },
572
435
  {
573
- tag: 'contrib',
574
- node: 'contributor',
575
- context: 'contributors_section/',
576
- getAttrs: (node) => {
577
- const element = node;
578
- const contrib = {
579
- id: element.getAttribute('id'),
580
- };
581
- const role = element.getAttribute('role');
582
- if (role) {
583
- contrib.role = role;
584
- }
585
- const affiliations = element.getAttribute('affiliations');
586
- if (affiliations) {
587
- contrib.affiliations = JSON.parse(affiliations);
588
- }
589
- const footnote = element.getAttribute('footnote');
590
- if (footnote) {
591
- contrib.footnote = JSON.parse(footnote);
592
- }
593
- const corresp = element.getAttribute('corresp');
594
- if (corresp) {
595
- contrib.corresp = JSON.parse(corresp);
596
- }
597
- const bibliographicName = element.getAttribute('bibliographicName');
598
- if (bibliographicName) {
599
- contrib.bibliographicName = JSON.parse(bibliographicName);
600
- }
601
- const userID = element.getAttribute('userID');
602
- if (userID) {
603
- contrib.userID = userID;
604
- }
605
- const priority = element.getAttribute('priority');
606
- if (priority) {
607
- contrib.priority = parseInt(priority);
608
- }
609
- const invitationID = element.getAttribute('invitationID');
610
- if (invitationID) {
611
- contrib.invitationID = invitationID;
612
- }
613
- const objectType = element.getAttribute('objectType');
614
- if (objectType) {
615
- contrib.objectType = objectType;
616
- }
617
- const isCorresponding = element.getAttribute('isCorresponding');
618
- if (isCorresponding) {
619
- contrib.isCorresponding = JSON.parse(isCorresponding);
620
- }
621
- const ORCIDIdentifier = element.getAttribute('ORCIDIdentifier');
622
- if (ORCIDIdentifier) {
623
- contrib.ORCIDIdentifier = ORCIDIdentifier;
624
- }
625
- return contrib;
626
- },
436
+ tag: 'sec[sec-type="backmatter"]',
437
+ node: 'backmatter',
627
438
  },
628
439
  {
629
- tag: 'sec[sec-type="keywords"]',
630
- node: 'keywords_section',
440
+ tag: 'sec',
441
+ node: 'section',
631
442
  getAttrs: (node) => {
632
443
  const element = node;
633
444
  return {
@@ -638,24 +449,13 @@ const nodes = [
638
449
  },
639
450
  {
640
451
  tag: 'kwd-group-list',
641
- context: 'keywords_section/',
452
+ context: 'keywords/',
642
453
  node: 'keywords_element',
643
454
  },
644
- {
645
- tag: 'sec',
646
- node: 'section',
647
- getAttrs: (node) => {
648
- const element = node;
649
- return {
650
- id: element.getAttribute('id'),
651
- category: chooseSectionCategory(element),
652
- };
653
- },
654
- },
655
455
  {
656
456
  tag: 'kwd-group',
657
457
  context: 'keywords_element/',
658
- node: 'keywords_group',
458
+ node: 'keyword_group',
659
459
  getAttrs: (node) => {
660
460
  const element = node;
661
461
  return {
@@ -665,7 +465,7 @@ const nodes = [
665
465
  },
666
466
  {
667
467
  tag: 'kwd',
668
- context: 'keywords_group//',
468
+ context: 'keyword_group//',
669
469
  node: 'keyword',
670
470
  },
671
471
  {
@@ -720,7 +520,7 @@ const nodes = [
720
520
  {
721
521
  tag: 'title',
722
522
  node: 'section_title',
723
- context: 'section/|footnotes_section/|bibliography_section/|keywords_section/',
523
+ context: 'section/|footnotes_section/|bibliography_section/|keywords/',
724
524
  },
725
525
  {
726
526
  tag: 'title',
@@ -769,15 +569,11 @@ const nodes = [
769
569
  tag: 'xref[ref-type="bibr"]',
770
570
  node: 'citation',
771
571
  getAttrs: (node) => {
772
- var _a;
572
+ var _a, _b;
773
573
  const element = node;
774
- const embeddedCitationAttr = element.getAttribute('data-reference-embedded-citation');
775
574
  return {
776
- rid: element.getAttribute('rid'),
777
- contents: (_a = element.textContent) === null || _a === void 0 ? void 0 : _a.trim(),
778
- embeddedCitationItems: embeddedCitationAttr
779
- ? JSON.parse(embeddedCitationAttr)
780
- : null,
575
+ rids: ((_a = element.getAttribute('rid')) === null || _a === void 0 ? void 0 : _a.split(/\s+/)) || [],
576
+ contents: (_b = element.textContent) === null || _b === void 0 ? void 0 : _b.trim(),
781
577
  };
782
578
  },
783
579
  },
@@ -785,11 +581,11 @@ const nodes = [
785
581
  tag: 'xref[ref-type="fn"]',
786
582
  node: 'inline_footnote',
787
583
  getAttrs: (node) => {
788
- var _a;
584
+ var _a, _b;
789
585
  const element = node;
790
586
  return {
791
- rid: element.getAttribute('rid'),
792
- contents: (_a = element.textContent) === null || _a === void 0 ? void 0 : _a.trim(),
587
+ rids: ((_a = element.getAttribute('rid')) === null || _a === void 0 ? void 0 : _a.split(/\s+/)) || [],
588
+ contents: (_b = element.textContent) === null || _b === void 0 ? void 0 : _b.trim(),
793
589
  };
794
590
  },
795
591
  },
@@ -797,11 +593,11 @@ const nodes = [
797
593
  tag: 'xref',
798
594
  node: 'cross_reference',
799
595
  getAttrs: (node) => {
800
- var _a;
596
+ var _a, _b;
801
597
  const element = node;
802
598
  return {
803
- rid: element.getAttribute('rid'),
804
- label: (_a = element.textContent) === null || _a === void 0 ? void 0 : _a.trim(),
599
+ rids: ((_a = element.getAttribute('rid')) === null || _a === void 0 ? void 0 : _a.split(/\s+/)) || [],
600
+ label: (_b = element.textContent) === null || _b === void 0 ? void 0 : _b.trim(),
805
601
  };
806
602
  },
807
603
  },