@manuscripts/transform 4.5.2 → 4.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/dist/cjs/jats/__tests__/data/section-categories.js +5 -5
  2. package/dist/cjs/jats/__tests__/jats-importer.test.js +19 -5
  3. package/dist/cjs/jats/exporter/jats-exporter.js +725 -910
  4. package/dist/cjs/jats/exporter/jats-versions.js +9 -9
  5. package/dist/cjs/jats/importer/jats-dom-parser.js +25 -24
  6. package/dist/cjs/jats/importer/jats-transformations.js +14 -30
  7. package/dist/cjs/lib/section-categories.js +31 -1
  8. package/dist/cjs/schema/index.js +3 -0
  9. package/dist/cjs/schema/migration/migration-scripts/4.5.3.js +37 -0
  10. package/dist/cjs/schema/migration/migration-scripts/index.js +2 -0
  11. package/dist/cjs/schema/nodes/abstract.js +51 -0
  12. package/dist/cjs/schema/nodes/abstracts.js +1 -1
  13. package/dist/cjs/transformer/node-names.js +1 -0
  14. package/dist/cjs/transformer/node-title.js +2 -0
  15. package/dist/cjs/version.js +1 -1
  16. package/dist/es/jats/__tests__/data/section-categories.js +5 -5
  17. package/dist/es/jats/__tests__/jats-importer.test.js +19 -5
  18. package/dist/es/jats/exporter/jats-exporter.js +728 -913
  19. package/dist/es/jats/exporter/jats-versions.js +7 -7
  20. package/dist/es/jats/importer/jats-dom-parser.js +25 -24
  21. package/dist/es/jats/importer/jats-transformations.js +14 -30
  22. package/dist/es/lib/section-categories.js +28 -0
  23. package/dist/es/schema/index.js +3 -0
  24. package/dist/es/schema/migration/migration-scripts/4.5.3.js +35 -0
  25. package/dist/es/schema/migration/migration-scripts/index.js +2 -0
  26. package/dist/es/schema/nodes/abstract.js +47 -0
  27. package/dist/es/schema/nodes/abstracts.js +1 -1
  28. package/dist/es/transformer/node-names.js +1 -0
  29. package/dist/es/transformer/node-title.js +2 -0
  30. package/dist/es/version.js +1 -1
  31. package/dist/types/jats/exporter/jats-exporter.d.ts +31 -27
  32. package/dist/types/jats/exporter/jats-versions.d.ts +4 -4
  33. package/dist/types/jats/importer/jats-dom-parser.d.ts +0 -1
  34. package/dist/types/lib/section-categories.d.ts +3 -0
  35. package/dist/types/schema/index.d.ts +1 -0
  36. package/dist/types/schema/migration/migration-scripts/4.5.3.d.ts +8 -0
  37. package/dist/types/schema/migration/migration-scripts/index.d.ts +2 -1
  38. package/dist/types/schema/nodes/abstract.d.ts +26 -0
  39. package/dist/types/schema/types.d.ts +1 -1
  40. package/dist/types/version.d.ts +1 -1
  41. package/package.json +1 -1
  42. package/src/jats/__tests__/__snapshots__/jats-exporter.test.ts.snap +3 -3
  43. package/src/jats/__tests__/__snapshots__/jats-importer.test.ts.snap +86 -132
  44. package/src/jats/__tests__/__snapshots__/jats-roundtrip.test.ts.snap +3 -3
  45. package/src/jats/__tests__/data/section-categories.ts +5 -5
  46. package/src/jats/__tests__/jats-importer.test.ts +22 -6
  47. package/src/jats/exporter/jats-exporter.ts +855 -1126
  48. package/src/jats/exporter/jats-versions.ts +11 -11
  49. package/src/jats/importer/jats-dom-parser.ts +34 -34
  50. package/src/jats/importer/jats-transformations.ts +21 -37
  51. package/src/lib/section-categories.ts +36 -0
  52. package/src/schema/index.ts +3 -0
  53. package/src/schema/migration/migration-scripts/4.5.3.ts +57 -0
  54. package/src/schema/migration/migration-scripts/index.ts +2 -0
  55. package/src/schema/nodes/abstract.ts +66 -0
  56. package/src/schema/nodes/abstracts.ts +2 -1
  57. package/src/schema/types.ts +1 -0
  58. package/src/transformer/node-names.ts +1 -0
  59. package/src/transformer/node-title.ts +2 -0
  60. package/src/version.ts +1 -1
@@ -15,25 +15,25 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.selectVersionIds = void 0;
18
+ exports.selectVersionIDs = void 0;
19
19
  const versions = {
20
20
  '1.1': {
21
- publicId: '-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD with OASIS Tables with MathML3 v1.1 20151215//EN',
22
- systemId: 'http://jats.nlm.nih.gov/archiving/1.1/JATS-archive-oasis-article1-mathml3.dtd',
21
+ publicID: '-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD with OASIS Tables with MathML3 v1.1 20151215//EN',
22
+ systemID: 'http://jats.nlm.nih.gov/archiving/1.1/JATS-archive-oasis-article1-mathml3.dtd',
23
23
  },
24
24
  '1.2d1': {
25
- publicId: '-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD with OASIS Tables with MathML3 v1.2d1 20170631//EN',
26
- systemId: 'http://jats.nlm.nih.gov/archiving/1.2d1/JATS-archive-oasis-article1-mathml3.dtd',
25
+ publicID: '-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD with OASIS Tables with MathML3 v1.2d1 20170631//EN',
26
+ systemID: 'http://jats.nlm.nih.gov/archiving/1.2d1/JATS-archive-oasis-article1-mathml3.dtd',
27
27
  },
28
28
  '1.2': {
29
- publicId: '-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD with OASIS Tables with MathML3 v1.2 20190208//EN',
30
- systemId: 'http://jats.nlm.nih.gov/archiving/1.2/JATS-archive-oasis-article1-mathml3.dtd',
29
+ publicID: '-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD with OASIS Tables with MathML3 v1.2 20190208//EN',
30
+ systemID: 'http://jats.nlm.nih.gov/archiving/1.2/JATS-archive-oasis-article1-mathml3.dtd',
31
31
  },
32
32
  };
33
- const selectVersionIds = (version) => {
33
+ const selectVersionIDs = (version) => {
34
34
  if (!(version in versions)) {
35
35
  throw new Error(`Unknown version ${version}`);
36
36
  }
37
37
  return versions[version];
38
38
  };
39
- exports.selectVersionIds = selectVersionIds;
39
+ exports.selectVersionIDs = selectVersionIDs;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.JATSDOMParser = void 0;
4
4
  const prosemirror_model_1 = require("prosemirror-model");
5
+ const section_categories_1 = require("../../lib/section-categories");
5
6
  const utils_1 = require("../../lib/utils");
6
7
  const xml_1 = require("../../lib/xml");
7
8
  const jats_comments_1 = require("./jats-comments");
@@ -461,6 +462,10 @@ class JATSDOMParser {
461
462
  tag: 'history',
462
463
  ignore: true,
463
464
  },
465
+ {
466
+ tag: 'statement',
467
+ ignore: true,
468
+ },
464
469
  {
465
470
  tag: 'break',
466
471
  node: 'hard_break',
@@ -822,7 +827,7 @@ class JATSDOMParser {
822
827
  },
823
828
  },
824
829
  {
825
- tag: 'trans-abstract[sec-type="abstract-graphical"]',
830
+ tag: 'trans-abstract[abstract-type="graphical"]',
826
831
  node: 'trans_graphical_abstract',
827
832
  getAttrs: (node) => {
828
833
  const element = node;
@@ -833,7 +838,7 @@ class JATSDOMParser {
833
838
  },
834
839
  },
835
840
  {
836
- tag: 'trans-abstract[sec-type="abstract-key-image"]',
841
+ tag: 'trans-abstract[abstract-type="key-image"]',
837
842
  node: 'trans_graphical_abstract',
838
843
  getAttrs: (node) => {
839
844
  const element = node;
@@ -893,7 +898,7 @@ class JATSDOMParser {
893
898
  getAttrs: (node) => this.parseRef(node),
894
899
  },
895
900
  {
896
- tag: 'sec[sec-type="abstract-graphical"]',
901
+ tag: 'abstract[abstract-type="graphical"]',
897
902
  node: 'graphical_abstract_section',
898
903
  getAttrs: (node) => {
899
904
  const element = node;
@@ -903,7 +908,7 @@ class JATSDOMParser {
903
908
  },
904
909
  },
905
910
  {
906
- tag: 'sec[sec-type="abstract-key-image"]',
911
+ tag: 'abstract[abstract-type="key-image"]',
907
912
  node: 'graphical_abstract_section',
908
913
  getAttrs: (node) => {
909
914
  const element = node;
@@ -912,6 +917,18 @@ class JATSDOMParser {
912
917
  };
913
918
  },
914
919
  },
920
+ {
921
+ tag: 'abstract',
922
+ node: 'abstract',
923
+ getAttrs: (node) => {
924
+ const element = node;
925
+ return {
926
+ id: element.getAttribute('id'),
927
+ category: this.chooseSectionCategory(element) ||
928
+ (0, section_categories_1.abstractTypeToCategory)(element.getAttribute('abstract-type')),
929
+ };
930
+ },
931
+ },
915
932
  {
916
933
  tag: 'sec',
917
934
  node: 'section',
@@ -974,7 +991,7 @@ class JATSDOMParser {
974
991
  {
975
992
  tag: 'title',
976
993
  node: 'section_title',
977
- context: 'section/|footnotes_section/|bibliography_section/|keywords/|supplements/|author_notes/|graphical_abstract_section/|trans_abstract/|trans_graphical_abstract/',
994
+ context: 'section/|footnotes_section/|bibliography_section/|keywords/|supplements/|author_notes/|abstract/|graphical_abstract_section/|trans_abstract/|trans_graphical_abstract/',
978
995
  },
979
996
  {
980
997
  tag: 'tr',
@@ -1110,29 +1127,13 @@ class JATSDOMParser {
1110
1127
  parse(doc, options) {
1111
1128
  return this.parser.parse(doc, options);
1112
1129
  }
1113
- isMatchingCategory(secType, titleNode, category) {
1114
- if ((secType && category.synonyms.includes(secType)) ||
1115
- category.id === secType) {
1116
- return true;
1117
- }
1118
- if (titleNode && titleNode.nodeName === 'title' && titleNode.textContent) {
1119
- const textContent = titleNode.textContent.trim().toLowerCase();
1120
- if (category.synonyms.includes(textContent)) {
1121
- return true;
1122
- }
1123
- }
1124
- return false;
1125
- }
1126
1130
  chooseSectionCategory(section) {
1127
1131
  const secType = section.getAttribute('sec-type');
1128
1132
  const abstractType = section.getAttribute('abstract-type');
1129
- const effectiveSecType = secType || (abstractType ? `abstract-${abstractType}` : null);
1133
+ const effectiveSecType = secType ?? abstractType;
1130
1134
  const titleNode = section.firstElementChild;
1131
- for (const category of this.sectionCategories) {
1132
- if (this.isMatchingCategory(effectiveSecType, titleNode, category)) {
1133
- return category.id;
1134
- }
1135
- }
1135
+ const titleText = titleNode?.nodeName === 'title' ? titleNode.textContent : null;
1136
+ return (0, section_categories_1.findMatchingCategory)(this.sectionCategories, effectiveSecType, titleText)?.id;
1136
1137
  }
1137
1138
  getNameContent(element, type) {
1138
1139
  const query = `person-group[person-group-type="${type}"] > *`;
@@ -17,7 +17,7 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.fixTables = exports.createAttachments = exports.orderTableFootnote = exports.moveReferencesToBackmatter = exports.createAccessibilityItems = exports.createSupplementaryMaterialsSection = exports.createKeywordsSection = exports.moveCaptionsToEnd = exports.createBackmatter = exports.createAbstracts = exports.createBody = exports.moveHeroImage = exports.moveAbstracts = exports.moveAffiliations = exports.moveContributors = exports.moveAwards = exports.moveAuthorNotes = exports.createTitles = exports.createBoxedElementSection = exports.addMissingCaptions = void 0;
19
19
  const deafults_1 = require("../../lib/deafults");
20
- const xml_1 = require("../../lib/xml");
20
+ const section_categories_1 = require("../../lib/section-categories");
21
21
  const jats_parser_utils_1 = require("./jats-parser-utils");
22
22
  const removeNodeFromParent = (node) => node.parentNode && node.parentNode.removeChild(node);
23
23
  const capitalizeFirstLetter = (str) => str.charAt(0).toUpperCase() + str.slice(1);
@@ -118,8 +118,7 @@ exports.moveAffiliations = moveAffiliations;
118
118
  const moveAbstracts = (front, group, createElement, sectionCategories) => {
119
119
  const abstracts = front.querySelectorAll('article-meta > abstract, article-meta > trans-abstract');
120
120
  abstracts.forEach((abstract) => {
121
- const sec = createAbstractSection(abstract, createElement, sectionCategories);
122
- removeNodeFromParent(abstract);
121
+ const sec = prepareAbstract(abstract, createElement, sectionCategories);
123
122
  group.appendChild(sec);
124
123
  });
125
124
  };
@@ -186,7 +185,7 @@ const moveSpecialFootnotes = (doc, group, sectionCategories, createElement) => {
186
185
  const fns = [...doc.querySelectorAll('fn[fn-type]')];
187
186
  for (const fn of fns) {
188
187
  const type = fn.getAttribute('fn-type') || '';
189
- const category = sectionCategories.find((category) => category.synonyms.includes(type));
188
+ const category = (0, section_categories_1.findMatchingCategory)(sectionCategories, type);
190
189
  if (category) {
191
190
  const section = createElement('sec');
192
191
  const fnTitle = fn.querySelector('label') ||
@@ -221,35 +220,20 @@ const moveCaptionsToEnd = (body) => {
221
220
  }
222
221
  };
223
222
  exports.moveCaptionsToEnd = moveCaptionsToEnd;
224
- const createAbstractSection = (abstract, createElement, sectionCategories) => {
225
- const abstractType = abstract.getAttribute('abstract-type');
226
- const sectionType = abstractType ? `abstract-${abstractType}` : 'abstract';
227
- let section = createElement('sec');
228
- if (abstract.nodeName === 'trans-abstract') {
229
- section = createElement('trans-abstract');
230
- const lang = abstract.getAttributeNS(xml_1.XML_NAMESPACE, 'lang');
231
- if (lang) {
232
- section.setAttributeNS(xml_1.XML_NAMESPACE, 'lang', lang);
233
- }
234
- }
235
- section.setAttribute('sec-type', sectionType);
223
+ const prepareAbstract = (abstract, createElement, sectionCategories) => {
224
+ const rawType = abstract.getAttribute('abstract-type');
225
+ const category = (0, section_categories_1.abstractTypeToCategory)(rawType);
236
226
  if (!abstract.querySelector(':scope > title')) {
227
+ const matched = sectionCategories && (0, section_categories_1.findMatchingCategory)(sectionCategories, category);
237
228
  const title = createElement('title');
238
- const category = sectionCategories?.find((c) => c.id === sectionType || c.synonyms.includes(sectionType));
239
- if (category?.titles[0]) {
240
- title.textContent = category.titles[0];
241
- }
242
- else {
243
- title.textContent = abstractType
244
- ? `${capitalizeFirstLetter(abstractType.split('-').join(' '))} Abstract`
245
- : 'Abstract';
246
- }
247
- section.appendChild(title);
248
- }
249
- while (abstract.firstChild) {
250
- section.appendChild(abstract.firstChild);
229
+ title.textContent =
230
+ matched?.titles[0] ??
231
+ (rawType
232
+ ? `${capitalizeFirstLetter(rawType.split('-').join(' '))} Abstract`
233
+ : 'Abstract');
234
+ abstract.insertBefore(title, abstract.firstChild);
251
235
  }
252
- return section;
236
+ return abstract;
253
237
  };
254
238
  const createAcknowledgmentsSection = (ack, createElement) => {
255
239
  const section = createElement('sec');
@@ -15,7 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.getGroupCategories = void 0;
18
+ exports.FOOTNOTE_SECTION_CATEGORY_IDS = exports.abstractTypeToCategory = exports.findMatchingCategory = exports.getGroupCategories = void 0;
19
19
  const getGroupCategories = (sections, group) => {
20
20
  const sectionsArray = Array.isArray(sections)
21
21
  ? sections
@@ -23,3 +23,33 @@ const getGroupCategories = (sections, group) => {
23
23
  return sectionsArray.filter((section) => section.group === group);
24
24
  };
25
25
  exports.getGroupCategories = getGroupCategories;
26
+ const findMatchingCategory = (categories, type, titleText) => {
27
+ return categories.find((category) => {
28
+ if (type && (category.id === type || category.synonyms.includes(type))) {
29
+ return true;
30
+ }
31
+ if (titleText) {
32
+ const normalizedTitle = titleText.trim().toLowerCase();
33
+ if (category.synonyms.includes(normalizedTitle)) {
34
+ return true;
35
+ }
36
+ }
37
+ return false;
38
+ });
39
+ };
40
+ exports.findMatchingCategory = findMatchingCategory;
41
+ const abstractTypeToCategory = (abstractType) => abstractType || 'abstract';
42
+ exports.abstractTypeToCategory = abstractTypeToCategory;
43
+ exports.FOOTNOTE_SECTION_CATEGORY_IDS = [
44
+ 'con',
45
+ 'conflict',
46
+ 'deceased',
47
+ 'equal',
48
+ 'present-address',
49
+ 'presented-at',
50
+ 'previously-at',
51
+ 'supplementary-material',
52
+ 'supported-by',
53
+ 'financial-disclosure',
54
+ 'coi-statement',
55
+ ];
@@ -33,6 +33,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
33
33
  exports.schema = void 0;
34
34
  const prosemirror_model_1 = require("prosemirror-model");
35
35
  const marks_1 = require("./marks");
36
+ const abstract_1 = require("./nodes/abstract");
36
37
  const abstracts_1 = require("./nodes/abstracts");
37
38
  const affiliation_1 = require("./nodes/affiliation");
38
39
  const affiliations_1 = require("./nodes/affiliations");
@@ -113,6 +114,7 @@ const title_1 = require("./nodes/title");
113
114
  const trans_abstract_1 = require("./nodes/trans_abstract");
114
115
  const trans_graphical_abstract_1 = require("./nodes/trans_graphical_abstract");
115
116
  __exportStar(require("./groups"), exports);
117
+ __exportStar(require("./nodes/abstract"), exports);
116
118
  __exportStar(require("./nodes/affiliation"), exports);
117
119
  __exportStar(require("./nodes/affiliations"), exports);
118
120
  __exportStar(require("./nodes/alt_text"), exports);
@@ -216,6 +218,7 @@ exports.schema = new prosemirror_model_1.Schema({
216
218
  caption: caption_1.caption,
217
219
  caption_title: caption_title_1.captionTitle,
218
220
  citation: citation_1.citation,
221
+ abstract: abstract_1.abstract,
219
222
  abstracts: abstracts_1.abstracts,
220
223
  body: body_1.body,
221
224
  backmatter: backmatter_1.backmatter,
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const TRANS_ABSTRACT_TYPES = ['trans_abstract', 'trans_graphical_abstract'];
4
+ class Migration453 {
5
+ constructor() {
6
+ this.fromVersion = '4.5.2';
7
+ this.toVersion = '4.5.3';
8
+ }
9
+ migrateNode(node) {
10
+ if (node.type !== 'abstracts' || !node.content) {
11
+ return node;
12
+ }
13
+ const children = node.content.map((child) => {
14
+ const type = child.type === 'section' ? 'abstract' : child.type;
15
+ const category = child.attrs?.category;
16
+ const attrs = category && category.startsWith('abstract-')
17
+ ? { ...child.attrs, category: category.slice('abstract-'.length) }
18
+ : child.attrs;
19
+ return { ...child, type, attrs };
20
+ });
21
+ const regular = [];
22
+ const translated = [];
23
+ for (const child of children) {
24
+ if (TRANS_ABSTRACT_TYPES.includes(child.type)) {
25
+ translated.push(child);
26
+ }
27
+ else {
28
+ regular.push(child);
29
+ }
30
+ }
31
+ return {
32
+ ...node,
33
+ content: [...regular, ...translated],
34
+ };
35
+ }
36
+ }
37
+ exports.default = Migration453;
@@ -34,6 +34,7 @@ const _4_3_34_1 = __importDefault(require("./4.3.34"));
34
34
  const _4_3_35_1 = __importDefault(require("./4.3.35"));
35
35
  const _4_4_2_1 = __importDefault(require("./4.4.2"));
36
36
  const _4_4_7_1 = __importDefault(require("./4.4.7"));
37
+ const _4_5_3_1 = __importDefault(require("./4.5.3"));
37
38
  const migrations = [
38
39
  new _1_2_5_1.default(),
39
40
  new _2_3_22_1.default(),
@@ -51,5 +52,6 @@ const migrations = [
51
52
  new _4_3_35_1.default(),
52
53
  new _4_4_2_1.default(),
53
54
  new _4_4_7_1.default(),
55
+ new _4_5_3_1.default(),
54
56
  ];
55
57
  exports.default = migrations;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ /*!
3
+ * © 2026 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.isAbstractNode = exports.abstract = void 0;
19
+ exports.abstract = {
20
+ content: 'section_label? section_title (paragraph | element)* sections*',
21
+ attrs: {
22
+ id: { default: '' },
23
+ category: { default: '' },
24
+ dataTracked: { default: null },
25
+ },
26
+ group: 'block sections',
27
+ selectable: false,
28
+ parseDOM: [
29
+ {
30
+ tag: 'section.abstract',
31
+ getAttrs: (dom) => {
32
+ const element = dom;
33
+ return {
34
+ id: element.getAttribute('id') || '',
35
+ category: element.getAttribute('data-category') || '',
36
+ };
37
+ },
38
+ },
39
+ ],
40
+ toDOM: (node) => {
41
+ const abstractNode = node;
42
+ const { id, category } = abstractNode.attrs;
43
+ const attrs = { id, class: 'abstract' };
44
+ if (category) {
45
+ attrs['data-category'] = category;
46
+ }
47
+ return ['section', attrs, 0];
48
+ },
49
+ };
50
+ const isAbstractNode = (node) => node.type === node.type.schema.nodes.abstract;
51
+ exports.isAbstractNode = isAbstractNode;
@@ -17,7 +17,7 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.abstracts = void 0;
19
19
  exports.abstracts = {
20
- content: 'sections* (trans_abstract | trans_graphical_abstract)*',
20
+ content: '(abstract | graphical_abstract_section)* (trans_abstract | trans_graphical_abstract)*',
21
21
  attrs: {
22
22
  id: { default: '' },
23
23
  },
@@ -54,6 +54,7 @@ exports.nodeNames = new Map([
54
54
  [schema_1.schema.nodes.paragraph, 'Paragraph'],
55
55
  [schema_1.schema.nodes.text_block, 'Paragraph'],
56
56
  [schema_1.schema.nodes.section, 'Section'],
57
+ [schema_1.schema.nodes.abstract, 'Abstract'],
57
58
  [schema_1.schema.nodes.graphical_abstract_section, 'Graphical Abstract'],
58
59
  [schema_1.schema.nodes.trans_abstract, 'Trans Abstract'],
59
60
  [schema_1.schema.nodes.trans_graphical_abstract, 'Trans Graphical Abstract'],
@@ -53,6 +53,7 @@ const nodeTitle = (node) => {
53
53
  case nodes.manuscript:
54
54
  return snippetOfNodeType(node, nodes.title);
55
55
  case nodes.section:
56
+ case nodes.abstract:
56
57
  case nodes.bibliography_section:
57
58
  case nodes.footnotes_section:
58
59
  case nodes.keywords:
@@ -90,6 +91,7 @@ const nodeTitlePlaceholder = (nodeType) => {
90
91
  case nodes.manuscript:
91
92
  return 'Untitled Manuscript';
92
93
  case nodes.section:
94
+ case nodes.abstract:
93
95
  return 'Untitled Section';
94
96
  case nodes.bibliography_section:
95
97
  return 'Bibliography';
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = "4.5.2";
4
+ exports.VERSION = "4.5.4";
@@ -22,35 +22,35 @@ export const sectionCategories = [
22
22
  isUnique: true,
23
23
  },
24
24
  {
25
- id: 'abstract-graphical',
25
+ id: 'graphical',
26
26
  titles: ['Graphical Abstract'],
27
27
  synonyms: [''],
28
28
  group: 'abstracts-graphic',
29
29
  isUnique: true,
30
30
  },
31
31
  {
32
- id: 'abstract-key-image',
32
+ id: 'key-image',
33
33
  titles: ['Key Image'],
34
34
  synonyms: [''],
35
35
  group: 'abstracts-graphic',
36
36
  isUnique: true,
37
37
  },
38
38
  {
39
- id: 'abstract-short',
39
+ id: 'short',
40
40
  titles: ['Short'],
41
41
  synonyms: [''],
42
42
  group: 'abstracts',
43
43
  isUnique: true,
44
44
  },
45
45
  {
46
- id: 'abstract-teaser',
46
+ id: 'teaser',
47
47
  titles: ['Abstract Teaser'],
48
48
  synonyms: [''],
49
49
  isUnique: true,
50
50
  group: 'abstracts',
51
51
  },
52
52
  {
53
- id: 'abstract-toc',
53
+ id: 'toc',
54
54
  titles: ['Table of contents'],
55
55
  synonyms: [''],
56
56
  group: 'abstracts',
@@ -289,8 +289,22 @@ describe('JATS importer', () => {
289
289
  }
290
290
  const node = parseJATSArticle(jats, sectionCategories);
291
291
  const abstractsNode = findNodeByType(node, schema.nodes.abstracts);
292
- const sections = findNodesByType(abstractsNode, schema.nodes.section);
293
- expect(sections).toHaveLength(6);
292
+ const abstracts = findNodesByType(abstractsNode, schema.nodes.abstract);
293
+ expect(abstracts).toHaveLength(2);
294
+ });
295
+ it('should order abstracts children per the schema', async () => {
296
+ const jats = await readAndParseFixture('jats-import.xml');
297
+ const node = parseJATSArticle(jats, sectionCategories);
298
+ const abstractsNode = findNodeByType(node, schema.nodes.abstracts);
299
+ const childTypes = [];
300
+ abstractsNode.content.forEach((child) => childTypes.push(child.type.name));
301
+ expect(childTypes).toEqual([
302
+ 'abstract',
303
+ 'graphical_abstract_section',
304
+ 'graphical_abstract_section',
305
+ 'abstract',
306
+ 'trans_abstract',
307
+ ]);
294
308
  });
295
309
  it('should set the title to Abstract if no title is provided', async () => {
296
310
  const jats = await readAndParseFixture('jats-import.xml');
@@ -300,9 +314,9 @@ describe('JATS importer', () => {
300
314
  }
301
315
  const node = parseJATSArticle(jats, sectionCategories);
302
316
  const abstractsNode = findNodeByType(node, schema.nodes.abstracts);
303
- const sections = findNodesByType(abstractsNode, schema.nodes.section);
304
- const firstSection = sections[0];
305
- const titleNode = findNodeByType(firstSection, schema.nodes.section_title);
317
+ const abstracts = findNodesByType(abstractsNode, schema.nodes.abstract);
318
+ const firstAbstract = abstracts[0];
319
+ const titleNode = findNodeByType(firstAbstract, schema.nodes.section_title);
306
320
  expect(titleNode.textContent).toBe('Abstract');
307
321
  });
308
322
  });