@manuscripts/transform 4.2.18 → 4.2.20

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.
@@ -356,6 +356,18 @@ describe('JATS importer', () => {
356
356
  const bodyNode = (0, utils_1.findNodeByType)(node, schema_1.schema.nodes.body);
357
357
  expect(bodyNode).toBeDefined();
358
358
  });
359
+ it('should create body element and append to article when body is missing', async () => {
360
+ const jats = await (0, files_1.readAndParseFixture)('jats-abstract-no-body.xml');
361
+ const { node } = (0, parse_jats_article_1.parseJATSArticle)(jats, section_categories_1.sectionCategories);
362
+ const bodyNode = (0, utils_1.findNodeByType)(node, schema_1.schema.nodes.body);
363
+ expect(bodyNode).toBeDefined();
364
+ });
365
+ it('should have abstracts node even when no body element exists in JATS', async () => {
366
+ const jats = await (0, files_1.readAndParseFixture)('jats-abstract-no-body.xml');
367
+ const { node } = (0, parse_jats_article_1.parseJATSArticle)(jats, section_categories_1.sectionCategories);
368
+ const abstractNode = (0, utils_1.findNodeByType)(node, schema_1.schema.nodes.abstracts);
369
+ expect(abstractNode).toBeDefined();
370
+ });
359
371
  });
360
372
  describe('backmatter', () => {
361
373
  it('should have backmatter node if back element exists', async () => {
@@ -35,9 +35,14 @@ const processJATS = (doc, sectionCategories) => {
35
35
  (0, jats_transformations_1.moveAffiliations)(front, createElement);
36
36
  (0, jats_transformations_1.moveAuthorNotes)(front, createElement);
37
37
  (0, jats_transformations_1.moveAwards)(front);
38
- const body = doc.querySelector('body');
38
+ let body = doc.querySelector('body');
39
39
  if (!body) {
40
- return;
40
+ body = createElement('body');
41
+ const article = doc.querySelector('article');
42
+ if (!article) {
43
+ return;
44
+ }
45
+ article.append(body);
41
46
  }
42
47
  (0, jats_transformations_1.moveCaptionsToEnd)(body);
43
48
  (0, jats_transformations_1.createBoxedElementSection)(body, createElement);
@@ -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.2.18";
4
+ exports.VERSION = "4.2.20";
@@ -354,6 +354,18 @@ describe('JATS importer', () => {
354
354
  const bodyNode = findNodeByType(node, schema.nodes.body);
355
355
  expect(bodyNode).toBeDefined();
356
356
  });
357
+ it('should create body element and append to article when body is missing', async () => {
358
+ const jats = await readAndParseFixture('jats-abstract-no-body.xml');
359
+ const { node } = parseJATSArticle(jats, sectionCategories);
360
+ const bodyNode = findNodeByType(node, schema.nodes.body);
361
+ expect(bodyNode).toBeDefined();
362
+ });
363
+ it('should have abstracts node even when no body element exists in JATS', async () => {
364
+ const jats = await readAndParseFixture('jats-abstract-no-body.xml');
365
+ const { node } = parseJATSArticle(jats, sectionCategories);
366
+ const abstractNode = findNodeByType(node, schema.nodes.abstracts);
367
+ expect(abstractNode).toBeDefined();
368
+ });
357
369
  });
358
370
  describe('backmatter', () => {
359
371
  it('should have backmatter node if back element exists', async () => {
@@ -32,9 +32,14 @@ const processJATS = (doc, sectionCategories) => {
32
32
  moveAffiliations(front, createElement);
33
33
  moveAuthorNotes(front, createElement);
34
34
  moveAwards(front);
35
- const body = doc.querySelector('body');
35
+ let body = doc.querySelector('body');
36
36
  if (!body) {
37
- return;
37
+ body = createElement('body');
38
+ const article = doc.querySelector('article');
39
+ if (!article) {
40
+ return;
41
+ }
42
+ article.append(body);
38
43
  }
39
44
  moveCaptionsToEnd(body);
40
45
  createBoxedElementSection(body, createElement);
@@ -1 +1 @@
1
- export const VERSION = "4.2.18";
1
+ export const VERSION = "4.2.20";
@@ -1 +1 @@
1
- export declare const VERSION = "4.2.18";
1
+ export declare const VERSION = "4.2.20";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@manuscripts/transform",
3
3
  "description": "ProseMirror transformer for Manuscripts applications",
4
- "version": "4.2.18",
4
+ "version": "4.2.20",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-transform",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",