@manuscripts/transform 4.3.22 → 4.3.23
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/README.md +2 -2
- package/dist/cjs/jats/__tests__/jats-exporter.test.js +11 -45
- package/dist/cjs/jats/__tests__/jats-importer.test.js +54 -76
- package/dist/cjs/jats/__tests__/jats-roundtrip.test.js +1 -2
- package/dist/cjs/jats/__tests__/utils.js +4 -17
- package/dist/cjs/jats/exporter/jats-exporter.js +190 -271
- package/dist/cjs/jats/importer/jats-dom-parser.js +16 -42
- package/dist/cjs/jats/importer/jats-parser-utils.js +5 -29
- package/dist/cjs/jats/importer/parse-jats-article.js +1 -6
- package/dist/cjs/schema/__tests__/docs.js +1830 -0
- package/dist/cjs/schema/__tests__/migration.test.js +3 -37
- package/dist/cjs/schema/migration/migration-scripts/4.3.12.js +39 -0
- package/dist/cjs/schema/migration/migration-scripts/index.js +2 -0
- package/dist/cjs/schema/nodes/blockquote_element.js +0 -2
- package/dist/cjs/schema/nodes/comment.js +2 -1
- package/dist/cjs/schema/nodes/contributor.js +11 -11
- package/dist/cjs/schema/nodes/equation.js +1 -3
- package/dist/cjs/schema/nodes/list.js +0 -2
- package/dist/cjs/schema/nodes/listing.js +1 -3
- package/dist/cjs/schema/nodes/paragraph.js +0 -2
- package/dist/cjs/schema/nodes/pullquote_element.js +0 -2
- package/dist/cjs/transformer/id.js +2 -14
- package/dist/cjs/transformer/node-names.js +6 -1
- package/dist/cjs/transformer/node-types.js +1 -47
- package/dist/cjs/version.js +1 -1
- package/dist/es/jats/__tests__/jats-exporter.test.js +11 -45
- package/dist/es/jats/__tests__/jats-importer.test.js +54 -76
- package/dist/es/jats/__tests__/jats-roundtrip.test.js +1 -2
- package/dist/es/jats/__tests__/utils.js +4 -17
- package/dist/es/jats/exporter/jats-exporter.js +190 -271
- package/dist/es/jats/importer/jats-dom-parser.js +16 -42
- package/dist/es/jats/importer/jats-parser-utils.js +6 -30
- package/dist/es/jats/importer/parse-jats-article.js +1 -6
- package/dist/es/schema/__tests__/docs.js +1827 -0
- package/dist/es/schema/__tests__/migration.test.js +3 -4
- package/dist/es/schema/migration/migration-scripts/4.3.12.js +37 -0
- package/dist/es/schema/migration/migration-scripts/index.js +2 -0
- package/dist/es/schema/nodes/blockquote_element.js +0 -2
- package/dist/es/schema/nodes/comment.js +2 -1
- package/dist/es/schema/nodes/contributor.js +11 -11
- package/dist/es/schema/nodes/equation.js +1 -3
- package/dist/es/schema/nodes/list.js +0 -2
- package/dist/es/schema/nodes/listing.js +1 -3
- package/dist/es/schema/nodes/paragraph.js +0 -2
- package/dist/es/schema/nodes/pullquote_element.js +0 -2
- package/dist/es/transformer/id.js +2 -14
- package/dist/es/transformer/node-names.js +4 -0
- package/dist/es/transformer/node-types.js +1 -47
- package/dist/es/version.js +1 -1
- package/dist/types/jats/__tests__/utils.d.ts +1 -11
- package/dist/types/jats/exporter/jats-exporter.d.ts +5 -10
- package/dist/types/jats/importer/jats-dom-parser.d.ts +0 -15
- package/dist/types/jats/importer/parse-jats-article.d.ts +1 -11
- package/dist/types/schema/__tests__/docs.d.ts +2 -0
- package/dist/types/schema/migration/migration-scripts/4.3.12.d.ts +8 -0
- package/dist/types/schema/migration/migration-scripts/index.d.ts +2 -1
- package/dist/types/schema/nodes/comment.d.ts +2 -2
- package/dist/types/schema/nodes/contributor.d.ts +11 -21
- package/dist/types/schema/types.d.ts +22 -0
- package/dist/types/transformer/node-names.d.ts +1 -0
- package/dist/types/transformer/node-types.d.ts +0 -2
- package/dist/types/version.d.ts +1 -1
- package/package.json +2 -2
- package/dist/cjs/jats/importer/jats-journal-meta-parser.js +0 -103
- package/dist/cjs/lib/styled-content.js +0 -28
- package/dist/es/jats/importer/jats-journal-meta-parser.js +0 -95
- package/dist/es/lib/styled-content.js +0 -23
- package/dist/types/jats/importer/jats-journal-meta-parser.d.ts +0 -46
- package/dist/types/lib/styled-content.d.ts +0 -22
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ ProseMirror transformer for Manuscripts applications.
|
|
|
4
4
|
|
|
5
5
|
It provides a way to import/export [Manuscript JSON Schema](https://gitlab.com/mpapp-public/manuscripts-json-schema) formatted data from and to other formats such as (JATS XML, STS XML, HTML, [ProseMirror Model](https://prosemirror.net/docs/guide/#doc))
|
|
6
6
|
|
|
7
|
-
# Components
|
|
7
|
+
# Components
|
|
8
8
|
|
|
9
9
|
**Decoder**: converts Manuscript JSON Schema to ProseMirror Model.
|
|
10
10
|
|
|
@@ -24,7 +24,7 @@ It provides a way to import/export [Manuscript JSON Schema](https://gitlab.com/m
|
|
|
24
24
|
|
|
25
25
|
### Manuscript JSON Schema to ProseMirror Model
|
|
26
26
|
|
|
27
|
-
```typescript
|
|
27
|
+
```typescript
|
|
28
28
|
import { Decoder, ContainedModel } from '@manuscripts/manuscript-transform'
|
|
29
29
|
|
|
30
30
|
|
|
@@ -31,17 +31,16 @@ describe('JATS exporter', () => {
|
|
|
31
31
|
test('export latest version', async () => {
|
|
32
32
|
const transformer = new jats_exporter_1.JATSExporter();
|
|
33
33
|
const input = await (0, files_1.readAndParseFixture)('jats-example-full.xml');
|
|
34
|
-
const
|
|
34
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(input, section_categories_1.sectionCategories);
|
|
35
35
|
const result = await transformer.serializeToJATS(node, {
|
|
36
36
|
csl: citations_1.DEFAULT_CSL_OPTIONS,
|
|
37
|
-
journal,
|
|
38
37
|
});
|
|
39
38
|
expect(result).toMatchSnapshot('jats-export');
|
|
40
39
|
});
|
|
41
40
|
test('export with & and < in bibliography metadata', async () => {
|
|
42
41
|
const transformer = new jats_exporter_1.JATSExporter();
|
|
43
42
|
const input = await (0, files_1.readAndParseFixture)('jats-example-full.xml');
|
|
44
|
-
const
|
|
43
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(input, section_categories_1.sectionCategories);
|
|
45
44
|
let biblio = null;
|
|
46
45
|
node.descendants((n) => {
|
|
47
46
|
if ((0, schema_1.isBibliographyItemNode)(n)) {
|
|
@@ -51,17 +50,15 @@ describe('JATS exporter', () => {
|
|
|
51
50
|
biblio.attrs.title += ' & Sons 55 < 135';
|
|
52
51
|
const result = await transformer.serializeToJATS(node, {
|
|
53
52
|
csl: citations_1.DEFAULT_CSL_OPTIONS,
|
|
54
|
-
journal,
|
|
55
53
|
});
|
|
56
54
|
expect(result).toMatchSnapshot('jats-export-with-xml-unsafe-in-biblios');
|
|
57
55
|
});
|
|
58
56
|
test('export v1.1', async () => {
|
|
59
57
|
const transformer = new jats_exporter_1.JATSExporter();
|
|
60
58
|
const input = await (0, files_1.readAndParseFixture)('jats-example-full.xml');
|
|
61
|
-
const
|
|
59
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(input, section_categories_1.sectionCategories);
|
|
62
60
|
const result = await transformer.serializeToJATS(node, {
|
|
63
61
|
csl: citations_1.DEFAULT_CSL_OPTIONS,
|
|
64
|
-
journal,
|
|
65
62
|
version: '1.1',
|
|
66
63
|
});
|
|
67
64
|
expect(result).toMatchSnapshot('jats-export-1.1');
|
|
@@ -69,11 +66,10 @@ describe('JATS exporter', () => {
|
|
|
69
66
|
test('export unknown version', async () => {
|
|
70
67
|
const transformer = new jats_exporter_1.JATSExporter();
|
|
71
68
|
const input = await (0, files_1.readAndParseFixture)('jats-example-full.xml');
|
|
72
|
-
const
|
|
69
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(input, section_categories_1.sectionCategories);
|
|
73
70
|
await expect(async () => {
|
|
74
71
|
await transformer.serializeToJATS(node, {
|
|
75
72
|
csl: citations_1.DEFAULT_CSL_OPTIONS,
|
|
76
|
-
journal,
|
|
77
73
|
version: '1.0',
|
|
78
74
|
});
|
|
79
75
|
}).rejects.toThrow(Error);
|
|
@@ -81,10 +77,9 @@ describe('JATS exporter', () => {
|
|
|
81
77
|
test('export table-wrap-foot', async () => {
|
|
82
78
|
const transformer = new jats_exporter_1.JATSExporter();
|
|
83
79
|
const input = await (0, files_1.readAndParseFixture)('jats-tables-example.xml');
|
|
84
|
-
const
|
|
80
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(input, section_categories_1.sectionCategories);
|
|
85
81
|
const xml = await transformer.serializeToJATS(node, {
|
|
86
82
|
csl: citations_1.DEFAULT_CSL_OPTIONS,
|
|
87
|
-
journal,
|
|
88
83
|
});
|
|
89
84
|
const resultDoc = parseXMLWithDTD(xml);
|
|
90
85
|
const tableWrapFoot = resultDoc.get('//table-wrap/table-wrap-foot');
|
|
@@ -92,36 +87,12 @@ describe('JATS exporter', () => {
|
|
|
92
87
|
expect(paragraph).not.toBeUndefined();
|
|
93
88
|
expect(tableWrapFoot).not.toBeUndefined();
|
|
94
89
|
});
|
|
95
|
-
test('add journal ID', async () => {
|
|
96
|
-
const transformer = new jats_exporter_1.JATSExporter();
|
|
97
|
-
const input = await (0, files_1.readAndParseFixture)('jats-example-full.xml');
|
|
98
|
-
const { node, journal } = (0, parse_jats_article_1.parseJATSArticle)(input, section_categories_1.sectionCategories);
|
|
99
|
-
const xml = await transformer.serializeToJATS(node, {
|
|
100
|
-
csl: citations_1.DEFAULT_CSL_OPTIONS,
|
|
101
|
-
journal,
|
|
102
|
-
});
|
|
103
|
-
expect(xml).toMatchSnapshot('jats-export-submitted');
|
|
104
|
-
});
|
|
105
|
-
test('journal metadata', async () => {
|
|
106
|
-
const transformer = new jats_exporter_1.JATSExporter();
|
|
107
|
-
const input = await (0, files_1.readAndParseFixture)('jats-import.xml');
|
|
108
|
-
const { node, journal } = (0, parse_jats_article_1.parseJATSArticle)(input, section_categories_1.sectionCategories);
|
|
109
|
-
const xml = await transformer.serializeToJATS(node, {
|
|
110
|
-
csl: citations_1.DEFAULT_CSL_OPTIONS,
|
|
111
|
-
journal,
|
|
112
|
-
});
|
|
113
|
-
const output = parseXMLWithDTD(xml);
|
|
114
|
-
expect(output.errors).toHaveLength(0);
|
|
115
|
-
expect(output.get('//journal-title').text()).toBe('Brain and Behavior');
|
|
116
|
-
expect(output.get('//issn').text()).toBe('2162-3279');
|
|
117
|
-
});
|
|
118
90
|
test('DTD validation', async () => {
|
|
119
91
|
const transformer = new jats_exporter_1.JATSExporter();
|
|
120
92
|
const input = await (0, files_1.readAndParseFixture)('jats-import.xml');
|
|
121
|
-
const
|
|
93
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(input, section_categories_1.sectionCategories);
|
|
122
94
|
const xml = await transformer.serializeToJATS(node, {
|
|
123
95
|
csl: citations_1.DEFAULT_CSL_OPTIONS,
|
|
124
|
-
journal,
|
|
125
96
|
});
|
|
126
97
|
const { errors } = parseXMLWithDTD(xml);
|
|
127
98
|
expect(errors).toHaveLength(0);
|
|
@@ -129,10 +100,9 @@ describe('JATS exporter', () => {
|
|
|
129
100
|
test('DTD validation: article with title markup and citations', async () => {
|
|
130
101
|
const transformer = new jats_exporter_1.JATSExporter();
|
|
131
102
|
const input = await (0, files_1.readAndParseFixture)('jats-document.xml');
|
|
132
|
-
const
|
|
103
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(input, section_categories_1.sectionCategories);
|
|
133
104
|
const xml = await transformer.serializeToJATS(node, {
|
|
134
105
|
csl: citations_1.DEFAULT_CSL_OPTIONS,
|
|
135
|
-
journal,
|
|
136
106
|
});
|
|
137
107
|
const { errors } = parseXMLWithDTD(xml);
|
|
138
108
|
expect(errors).toHaveLength(0);
|
|
@@ -140,10 +110,9 @@ describe('JATS exporter', () => {
|
|
|
140
110
|
test('Export link', async () => {
|
|
141
111
|
const transformer = new jats_exporter_1.JATSExporter();
|
|
142
112
|
const input = await (0, files_1.readAndParseFixture)('jats-import.xml');
|
|
143
|
-
const
|
|
113
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(input, section_categories_1.sectionCategories);
|
|
144
114
|
const xml = await transformer.serializeToJATS(node, {
|
|
145
115
|
csl: citations_1.DEFAULT_CSL_OPTIONS,
|
|
146
|
-
journal,
|
|
147
116
|
});
|
|
148
117
|
const output = parseXMLWithDTD(xml);
|
|
149
118
|
const link = output.get('//ext-link[@ext-link-type="uri"]');
|
|
@@ -159,10 +128,9 @@ describe('JATS exporter', () => {
|
|
|
159
128
|
test('DTD validation for MathML representation', async () => {
|
|
160
129
|
const transformer = new jats_exporter_1.JATSExporter();
|
|
161
130
|
const input = await (0, files_1.readAndParseFixture)('jats-example-doc.xml');
|
|
162
|
-
const
|
|
131
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(input, section_categories_1.sectionCategories);
|
|
163
132
|
const xml = await transformer.serializeToJATS(node, {
|
|
164
133
|
csl: citations_1.DEFAULT_CSL_OPTIONS,
|
|
165
|
-
journal,
|
|
166
134
|
});
|
|
167
135
|
const { errors } = parseXMLWithDTD(xml);
|
|
168
136
|
expect(errors).toHaveLength(0);
|
|
@@ -170,10 +138,9 @@ describe('JATS exporter', () => {
|
|
|
170
138
|
test('export with supplement', async () => {
|
|
171
139
|
const transformer = new jats_exporter_1.JATSExporter();
|
|
172
140
|
const input = await (0, files_1.readAndParseFixture)('jats-import.xml');
|
|
173
|
-
const
|
|
141
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(input, section_categories_1.sectionCategories);
|
|
174
142
|
const xml = await transformer.serializeToJATS(node, {
|
|
175
143
|
csl: citations_1.DEFAULT_CSL_OPTIONS,
|
|
176
|
-
journal,
|
|
177
144
|
});
|
|
178
145
|
const resultDoc = parseXMLWithDTD(xml);
|
|
179
146
|
const supplementaryMaterial = resultDoc.get('//supplementary-material');
|
|
@@ -192,10 +159,9 @@ describe('JATS exporter', () => {
|
|
|
192
159
|
test('export footnotes', async () => {
|
|
193
160
|
const transformer = new jats_exporter_1.JATSExporter();
|
|
194
161
|
const input = await (0, files_1.readAndParseFixture)('jats-fn-group.xml');
|
|
195
|
-
const
|
|
162
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(input, section_categories_1.sectionCategories);
|
|
196
163
|
const xml = await transformer.serializeToJATS(node, {
|
|
197
164
|
csl: citations_1.DEFAULT_CSL_OPTIONS,
|
|
198
|
-
journal,
|
|
199
165
|
});
|
|
200
166
|
const footnoteCategories = [
|
|
201
167
|
'con',
|
|
@@ -24,7 +24,7 @@ describe('JATS importer', () => {
|
|
|
24
24
|
describe('title node', () => {
|
|
25
25
|
it('should have title node with content if title element exists', async () => {
|
|
26
26
|
const jats = await (0, files_1.readAndParseFixture)('jats-import.xml');
|
|
27
|
-
const
|
|
27
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(jats, section_categories_1.sectionCategories);
|
|
28
28
|
const titleNode = (0, utils_1.findNodeByType)(node, schema_1.schema.nodes.title);
|
|
29
29
|
expect(titleNode).toBeDefined();
|
|
30
30
|
(0, utils_1.updateNodeID)(titleNode);
|
|
@@ -34,7 +34,7 @@ describe('JATS importer', () => {
|
|
|
34
34
|
const jats = await (0, files_1.readAndParseFixture)('jats-import.xml');
|
|
35
35
|
const titleEl = jats.querySelector('article-meta > title-group > article-title');
|
|
36
36
|
titleEl?.remove();
|
|
37
|
-
const
|
|
37
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(jats, section_categories_1.sectionCategories);
|
|
38
38
|
const titleNode = (0, utils_1.findNodeByType)(node, schema_1.schema.nodes.title);
|
|
39
39
|
(0, utils_1.updateNodeID)(titleNode);
|
|
40
40
|
expect(titleNode).toMatchSnapshot();
|
|
@@ -43,39 +43,17 @@ describe('JATS importer', () => {
|
|
|
43
43
|
describe('contributors node', () => {
|
|
44
44
|
it('should have contributors node with content if contributors element exists', async () => {
|
|
45
45
|
const jats = await (0, files_1.readAndParseFixture)('jats-import.xml');
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
expect(node).toBeDefined();
|
|
49
|
-
expect(contributorsNode).toBeDefined();
|
|
50
|
-
expect((0, utils_1.findNodesByType)(contributorsNode, schema_1.schema.nodes.contributor)).toHaveLength(2);
|
|
51
|
-
});
|
|
52
|
-
it('should correctly parse contributor nodes', async () => {
|
|
53
|
-
const jats = await (0, files_1.readAndParseFixture)('jats-import.xml');
|
|
54
|
-
const contributorsEl = jats.querySelector('article-meta > contrib-group');
|
|
55
|
-
if (!contributorsEl) {
|
|
56
|
-
throw new Error('Contributors element not found');
|
|
57
|
-
}
|
|
58
|
-
const contributors = contributorsEl.querySelectorAll('contrib[contrib-type="author"]');
|
|
59
|
-
const { node } = (0, parse_jats_article_1.parseJATSArticle)(jats, section_categories_1.sectionCategories);
|
|
46
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(jats, section_categories_1.sectionCategories);
|
|
47
|
+
(0, utils_1.changeIDs)(node);
|
|
60
48
|
const contributorNodes = (0, utils_1.findNodesByType)(node, schema_1.schema.nodes.contributor);
|
|
61
|
-
expect(contributorNodes).toHaveLength(
|
|
62
|
-
contributorNodes.forEach((node) => {
|
|
63
|
-
(0, utils_1.updateNodeID)(node);
|
|
64
|
-
node.attrs.affiliations = node.attrs.affiliations.map(() => 'MPAffiliation:test');
|
|
65
|
-
node.attrs.footnote = node.attrs.footnote.map((footnote) => {
|
|
66
|
-
return { ...footnote, noteID: 'MPFootnote:test' };
|
|
67
|
-
});
|
|
68
|
-
node.attrs.corresp = node.attrs.corresp.map((corresp) => {
|
|
69
|
-
return { ...corresp, correspID: 'MPCorrespondance:test' };
|
|
70
|
-
});
|
|
71
|
-
});
|
|
49
|
+
expect(contributorNodes).toHaveLength(2);
|
|
72
50
|
expect(contributorNodes).toMatchSnapshot();
|
|
73
51
|
});
|
|
74
52
|
it('should not have contributors node if contributors element does not exist', async () => {
|
|
75
53
|
const jats = await (0, files_1.readAndParseFixture)('jats-import.xml');
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
const
|
|
54
|
+
const $contribGroup = jats.querySelector('article-meta > contrib-group');
|
|
55
|
+
$contribGroup.remove();
|
|
56
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(jats, section_categories_1.sectionCategories);
|
|
79
57
|
const contributorsNode = (0, utils_1.findNodesByType)(node, schema_1.schema.nodes.contributors);
|
|
80
58
|
const contributorNodes = (0, utils_1.findNodesByType)(node, schema_1.schema.nodes.contributor);
|
|
81
59
|
expect(contributorNodes).toHaveLength(0);
|
|
@@ -85,7 +63,7 @@ describe('JATS importer', () => {
|
|
|
85
63
|
describe('affiliations', () => {
|
|
86
64
|
it('should correctly parse affiliation nodes', async () => {
|
|
87
65
|
const jats = await (0, files_1.readAndParseFixture)('jats-import.xml');
|
|
88
|
-
const
|
|
66
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(jats, section_categories_1.sectionCategories);
|
|
89
67
|
const affiliationNodes = (0, utils_1.findNodesByType)(node, schema_1.schema.nodes.affiliation);
|
|
90
68
|
affiliationNodes.forEach(utils_1.updateNodeID);
|
|
91
69
|
expect(affiliationNodes).toMatchSnapshot();
|
|
@@ -96,7 +74,7 @@ describe('JATS importer', () => {
|
|
|
96
74
|
affiliationsElements.forEach((aff) => {
|
|
97
75
|
aff.remove();
|
|
98
76
|
});
|
|
99
|
-
const
|
|
77
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(jats, section_categories_1.sectionCategories);
|
|
100
78
|
const affiliationsNode = (0, utils_1.findNodeByType)(node, schema_1.schema.nodes.affiliations);
|
|
101
79
|
const affiliationNodes = (0, utils_1.findNodesByType)(node, schema_1.schema.nodes.affiliation);
|
|
102
80
|
expect(affiliationNodes).toHaveLength(0);
|
|
@@ -106,7 +84,7 @@ describe('JATS importer', () => {
|
|
|
106
84
|
describe('author-notes', () => {
|
|
107
85
|
it('should have author notes node with content if author notes element exists', async () => {
|
|
108
86
|
const jats = await (0, files_1.readAndParseFixture)('jats-import.xml');
|
|
109
|
-
const
|
|
87
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(jats, section_categories_1.sectionCategories);
|
|
110
88
|
const authorNotesNode = (0, utils_1.findNodeByType)(node, schema_1.schema.nodes.author_notes);
|
|
111
89
|
expect(authorNotesNode).toBeDefined();
|
|
112
90
|
expect((0, utils_1.findNodesByType)(authorNotesNode, schema_1.schema.nodes.footnote)).toHaveLength(2);
|
|
@@ -118,7 +96,7 @@ describe('JATS importer', () => {
|
|
|
118
96
|
const jats = await (0, files_1.readAndParseFixture)('jats-import.xml');
|
|
119
97
|
const authorNotesEl = jats.querySelector('article-meta > author-notes');
|
|
120
98
|
authorNotesEl?.remove();
|
|
121
|
-
const
|
|
99
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(jats, section_categories_1.sectionCategories);
|
|
122
100
|
const authorNotesNode = (0, utils_1.findNodeByType)(node, schema_1.schema.nodes.authorNotes);
|
|
123
101
|
expect(authorNotesNode).toBeUndefined();
|
|
124
102
|
});
|
|
@@ -126,14 +104,14 @@ describe('JATS importer', () => {
|
|
|
126
104
|
describe('awards', () => {
|
|
127
105
|
it('should have awards node if awards element exists', async () => {
|
|
128
106
|
const jats = await (0, files_1.readAndParseFixture)('jats-import.xml');
|
|
129
|
-
const
|
|
107
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(jats, section_categories_1.sectionCategories);
|
|
130
108
|
const awardsNode = (0, utils_1.findNodeByType)(node, schema_1.schema.nodes.awards);
|
|
131
109
|
expect(awardsNode).toBeDefined();
|
|
132
110
|
expect((0, utils_1.findNodesByType)(awardsNode, schema_1.schema.nodes.award).length).toBeGreaterThan(0);
|
|
133
111
|
});
|
|
134
112
|
it('should correctly parse award nodes', async () => {
|
|
135
113
|
const jats = await (0, files_1.readAndParseFixture)('jats-import.xml');
|
|
136
|
-
const
|
|
114
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(jats, section_categories_1.sectionCategories);
|
|
137
115
|
const awardsNode = (0, utils_1.findNodeByType)(node, schema_1.schema.nodes.awards);
|
|
138
116
|
(0, utils_1.changeIDs)(awardsNode);
|
|
139
117
|
expect(awardsNode).toMatchSnapshot();
|
|
@@ -142,7 +120,7 @@ describe('JATS importer', () => {
|
|
|
142
120
|
const jats = await (0, files_1.readAndParseFixture)('jats-import.xml');
|
|
143
121
|
const awardsEl = jats.querySelector('article-meta > funding-group');
|
|
144
122
|
awardsEl?.remove();
|
|
145
|
-
const
|
|
123
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(jats, section_categories_1.sectionCategories);
|
|
146
124
|
const awardsNode = (0, utils_1.findNodeByType)(node, schema_1.schema.nodes.awards);
|
|
147
125
|
expect(awardsNode).toBeUndefined();
|
|
148
126
|
});
|
|
@@ -150,7 +128,7 @@ describe('JATS importer', () => {
|
|
|
150
128
|
describe('keywords', () => {
|
|
151
129
|
it('should have keywords node with content if keywords element exists', async () => {
|
|
152
130
|
const jats = await (0, files_1.readAndParseFixture)('jats-import.xml');
|
|
153
|
-
const
|
|
131
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(jats, section_categories_1.sectionCategories);
|
|
154
132
|
const keywords = (0, utils_1.findNodeByType)(node, schema_1.schema.nodes.keywords);
|
|
155
133
|
expect(keywords).toBeDefined();
|
|
156
134
|
const keywordsNodes = (0, utils_1.findNodesByType)(keywords, schema_1.schema.nodes.keyword);
|
|
@@ -164,7 +142,7 @@ describe('JATS importer', () => {
|
|
|
164
142
|
const jats = await (0, files_1.readAndParseFixture)('jats-import.xml');
|
|
165
143
|
const keywordGroup = jats.querySelector('kwd-group');
|
|
166
144
|
keywordGroup?.remove();
|
|
167
|
-
const
|
|
145
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(jats, section_categories_1.sectionCategories);
|
|
168
146
|
const keywords = (0, utils_1.findNodeByType)(node, schema_1.schema.nodes.keywords);
|
|
169
147
|
expect(keywords).toBeUndefined();
|
|
170
148
|
});
|
|
@@ -172,7 +150,7 @@ describe('JATS importer', () => {
|
|
|
172
150
|
describe('supplements', () => {
|
|
173
151
|
it('should have supplements node with content if supplementary-material elements exist', async () => {
|
|
174
152
|
const jats = await (0, files_1.readAndParseFixture)('jats-import.xml');
|
|
175
|
-
const
|
|
153
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(jats, section_categories_1.sectionCategories);
|
|
176
154
|
const supplementsNode = (0, utils_1.findNodeByType)(node, schema_1.schema.nodes.supplement);
|
|
177
155
|
(0, utils_1.changeIDs)(supplementsNode);
|
|
178
156
|
expect(supplementsNode).toMatchSnapshot();
|
|
@@ -183,7 +161,7 @@ describe('JATS importer', () => {
|
|
|
183
161
|
supplementryMaterial.forEach((supplement) => {
|
|
184
162
|
supplement.remove();
|
|
185
163
|
});
|
|
186
|
-
const
|
|
164
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(jats, section_categories_1.sectionCategories);
|
|
187
165
|
const supplementsNode = (0, utils_1.findNodeByType)(node, schema_1.schema.nodes.supplements);
|
|
188
166
|
expect(supplementsNode).toBeUndefined();
|
|
189
167
|
});
|
|
@@ -191,7 +169,7 @@ describe('JATS importer', () => {
|
|
|
191
169
|
describe('comments', () => {
|
|
192
170
|
it('should parse keyword comment', async () => {
|
|
193
171
|
const jats = await (0, files_1.readAndParseFixture)('jats-comments.xml');
|
|
194
|
-
const
|
|
172
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(jats, section_categories_1.sectionCategories);
|
|
195
173
|
const group = (0, utils_1.findNodeByType)(node, schema_1.schema.nodes.keyword_group);
|
|
196
174
|
const markers = (0, utils_1.findNodesByType)(group, schema_1.schema.nodes.highlight_marker);
|
|
197
175
|
expect(markers.length).toBe(0);
|
|
@@ -202,7 +180,7 @@ describe('JATS importer', () => {
|
|
|
202
180
|
});
|
|
203
181
|
it('should parse abstract comment', async () => {
|
|
204
182
|
const jats = await (0, files_1.readAndParseFixture)('jats-comments.xml');
|
|
205
|
-
const
|
|
183
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(jats, section_categories_1.sectionCategories);
|
|
206
184
|
const abstracts = (0, utils_1.findNodeByType)(node, schema_1.schema.nodes.abstracts);
|
|
207
185
|
const paragraph = (0, utils_1.findNodeByType)(abstracts, schema_1.schema.nodes.paragraph);
|
|
208
186
|
const marker = (0, utils_1.findNodeByType)(paragraph, schema_1.schema.nodes.highlight_marker);
|
|
@@ -215,7 +193,7 @@ describe('JATS importer', () => {
|
|
|
215
193
|
});
|
|
216
194
|
it('should parse body comment', async () => {
|
|
217
195
|
const jats = await (0, files_1.readAndParseFixture)('jats-comments.xml');
|
|
218
|
-
const
|
|
196
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(jats, section_categories_1.sectionCategories);
|
|
219
197
|
const body = (0, utils_1.findNodeByType)(node, schema_1.schema.nodes.body);
|
|
220
198
|
const paragraph = (0, utils_1.findNodeByType)(body, schema_1.schema.nodes.paragraph);
|
|
221
199
|
const marker = (0, utils_1.findNodeByType)(paragraph, schema_1.schema.nodes.highlight_marker);
|
|
@@ -228,7 +206,7 @@ describe('JATS importer', () => {
|
|
|
228
206
|
});
|
|
229
207
|
it('should parse back comment', async () => {
|
|
230
208
|
const jats = await (0, files_1.readAndParseFixture)('jats-comments.xml');
|
|
231
|
-
const
|
|
209
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(jats, section_categories_1.sectionCategories);
|
|
232
210
|
const back = (0, utils_1.findNodeByType)(node, schema_1.schema.nodes.backmatter);
|
|
233
211
|
const paragraph = (0, utils_1.findNodeByType)(back, schema_1.schema.nodes.paragraph);
|
|
234
212
|
const marker = (0, utils_1.findNodeByType)(paragraph, schema_1.schema.nodes.highlight_marker);
|
|
@@ -241,7 +219,7 @@ describe('JATS importer', () => {
|
|
|
241
219
|
});
|
|
242
220
|
it('should parse ref-list comment', async () => {
|
|
243
221
|
const jats = await (0, files_1.readAndParseFixture)('jats-comments.xml');
|
|
244
|
-
const
|
|
222
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(jats, section_categories_1.sectionCategories);
|
|
245
223
|
const element = (0, utils_1.findNodeByType)(node, schema_1.schema.nodes.bibliography_element);
|
|
246
224
|
const markers = (0, utils_1.findNodesByType)(element, schema_1.schema.nodes.highlight_marker);
|
|
247
225
|
expect(markers.length).toBe(0);
|
|
@@ -255,14 +233,14 @@ describe('JATS importer', () => {
|
|
|
255
233
|
describe('attachments', () => {
|
|
256
234
|
it('should have attachment node if attachment exists', async () => {
|
|
257
235
|
const jats = await (0, files_1.readAndParseFixture)('jats-import.xml');
|
|
258
|
-
const
|
|
236
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(jats, section_categories_1.sectionCategories);
|
|
259
237
|
const attachmentsNode = (0, utils_1.findNodeByType)(node, schema_1.schema.nodes.attachments);
|
|
260
238
|
expect(attachmentsNode).toBeDefined();
|
|
261
239
|
expect((0, utils_1.findNodesByType)(attachmentsNode, schema_1.schema.nodes.attachment).length).toBeGreaterThan(0);
|
|
262
240
|
});
|
|
263
241
|
it('should correctly parse self-uri element', async () => {
|
|
264
242
|
const jats = await (0, files_1.readAndParseFixture)('jats-import.xml');
|
|
265
|
-
const
|
|
243
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(jats, section_categories_1.sectionCategories);
|
|
266
244
|
const attachmentNodes = (0, utils_1.findNodesByType)(node, schema_1.schema.nodes.attachment);
|
|
267
245
|
(0, utils_1.changeIDs)(attachmentNodes[0]);
|
|
268
246
|
expect(attachmentNodes[0].attrs.type).toBe('document');
|
|
@@ -270,7 +248,7 @@ describe('JATS importer', () => {
|
|
|
270
248
|
});
|
|
271
249
|
it('should correctly parse multiple self-uri element', async () => {
|
|
272
250
|
const jats = await (0, files_1.readAndParseFixture)('jats-import.xml');
|
|
273
|
-
const
|
|
251
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(jats, section_categories_1.sectionCategories);
|
|
274
252
|
const attachmentNodes = (0, utils_1.findNodesByType)(node, schema_1.schema.nodes.attachment);
|
|
275
253
|
expect(attachmentNodes.length).toBe(2);
|
|
276
254
|
(0, utils_1.changeIDs)(attachmentNodes[0]);
|
|
@@ -281,7 +259,7 @@ describe('JATS importer', () => {
|
|
|
281
259
|
});
|
|
282
260
|
it('should not have attachments node if no attachment element does not exist', async () => {
|
|
283
261
|
const jats = await (0, files_1.readAndParseFixture)('jats-example.xml');
|
|
284
|
-
const
|
|
262
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(jats, section_categories_1.sectionCategories);
|
|
285
263
|
const attachmentsNode = (0, utils_1.findNodeByType)(node, schema_1.schema.nodes.attachments);
|
|
286
264
|
expect(attachmentsNode).toBeUndefined();
|
|
287
265
|
});
|
|
@@ -293,7 +271,7 @@ describe('JATS importer', () => {
|
|
|
293
271
|
if (!abstractsEl) {
|
|
294
272
|
throw new Error('Abstract element not found');
|
|
295
273
|
}
|
|
296
|
-
const
|
|
274
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(jats, section_categories_1.sectionCategories);
|
|
297
275
|
const abstractsNode = (0, utils_1.findNodeByType)(node, schema_1.schema.nodes.abstracts);
|
|
298
276
|
expect(abstractsNode).toBeDefined();
|
|
299
277
|
});
|
|
@@ -301,7 +279,7 @@ describe('JATS importer', () => {
|
|
|
301
279
|
const jats = await (0, files_1.readAndParseFixture)('jats-import.xml');
|
|
302
280
|
const abstractsEl = jats.querySelector('front > article-meta > abstract');
|
|
303
281
|
abstractsEl?.remove();
|
|
304
|
-
const
|
|
282
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(jats, section_categories_1.sectionCategories);
|
|
305
283
|
const abstractsNode = (0, utils_1.findNodeByType)(node, schema_1.schema.nodes.abstracts);
|
|
306
284
|
expect(abstractsNode).toBeDefined();
|
|
307
285
|
});
|
|
@@ -311,7 +289,7 @@ describe('JATS importer', () => {
|
|
|
311
289
|
if (!abstractEl) {
|
|
312
290
|
throw new Error('Abstract element not found');
|
|
313
291
|
}
|
|
314
|
-
const
|
|
292
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(jats, section_categories_1.sectionCategories);
|
|
315
293
|
const abstractsNode = (0, utils_1.findNodeByType)(node, schema_1.schema.nodes.abstracts);
|
|
316
294
|
const sections = (0, utils_1.findNodesByType)(abstractsNode, schema_1.schema.nodes.section);
|
|
317
295
|
expect(sections).toHaveLength(6);
|
|
@@ -322,7 +300,7 @@ describe('JATS importer', () => {
|
|
|
322
300
|
if (!abstractEl) {
|
|
323
301
|
throw new Error('Abstract element not found');
|
|
324
302
|
}
|
|
325
|
-
const
|
|
303
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(jats, section_categories_1.sectionCategories);
|
|
326
304
|
const abstractsNode = (0, utils_1.findNodeByType)(node, schema_1.schema.nodes.abstracts);
|
|
327
305
|
const sections = (0, utils_1.findNodesByType)(abstractsNode, schema_1.schema.nodes.section);
|
|
328
306
|
const firstSection = sections[0];
|
|
@@ -337,13 +315,13 @@ describe('JATS importer', () => {
|
|
|
337
315
|
if (!bodyEl) {
|
|
338
316
|
throw new Error('Body element not found');
|
|
339
317
|
}
|
|
340
|
-
const
|
|
318
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(jats, section_categories_1.sectionCategories);
|
|
341
319
|
const bodyNode = (0, utils_1.findNodeByType)(node, schema_1.schema.nodes.body);
|
|
342
320
|
expect(bodyNode).toBeDefined();
|
|
343
321
|
});
|
|
344
322
|
it('should have the correct number of sections', async () => {
|
|
345
323
|
const jats = await (0, files_1.readAndParseFixture)('jats-import.xml');
|
|
346
|
-
const
|
|
324
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(jats, section_categories_1.sectionCategories);
|
|
347
325
|
const bodyNode = (0, utils_1.findNodeByType)(node, schema_1.schema.nodes.body);
|
|
348
326
|
const sections = (0, utils_1.findNodesByType)(bodyNode, schema_1.schema.nodes.section, false);
|
|
349
327
|
expect(sections).toHaveLength(5);
|
|
@@ -352,19 +330,19 @@ describe('JATS importer', () => {
|
|
|
352
330
|
const jats = await (0, files_1.readAndParseFixture)('jats-import.xml');
|
|
353
331
|
const bodyEl = jats.querySelector('body');
|
|
354
332
|
bodyEl?.remove();
|
|
355
|
-
const
|
|
333
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(jats, section_categories_1.sectionCategories);
|
|
356
334
|
const bodyNode = (0, utils_1.findNodeByType)(node, schema_1.schema.nodes.body);
|
|
357
335
|
expect(bodyNode).toBeDefined();
|
|
358
336
|
});
|
|
359
337
|
it('should create body element and append to article when body is missing', async () => {
|
|
360
338
|
const jats = await (0, files_1.readAndParseFixture)('jats-abstract-no-body.xml');
|
|
361
|
-
const
|
|
339
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(jats, section_categories_1.sectionCategories);
|
|
362
340
|
const bodyNode = (0, utils_1.findNodeByType)(node, schema_1.schema.nodes.body);
|
|
363
341
|
expect(bodyNode).toBeDefined();
|
|
364
342
|
});
|
|
365
343
|
it('should have abstracts node even when no body element exists in JATS', async () => {
|
|
366
344
|
const jats = await (0, files_1.readAndParseFixture)('jats-abstract-no-body.xml');
|
|
367
|
-
const
|
|
345
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(jats, section_categories_1.sectionCategories);
|
|
368
346
|
const abstractNode = (0, utils_1.findNodeByType)(node, schema_1.schema.nodes.abstracts);
|
|
369
347
|
expect(abstractNode).toBeDefined();
|
|
370
348
|
});
|
|
@@ -376,7 +354,7 @@ describe('JATS importer', () => {
|
|
|
376
354
|
if (!backEl) {
|
|
377
355
|
throw new Error('Back element not found');
|
|
378
356
|
}
|
|
379
|
-
const
|
|
357
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(jats, section_categories_1.sectionCategories);
|
|
380
358
|
const backNode = (0, utils_1.findNodeByType)(node, schema_1.schema.nodes.backmatter);
|
|
381
359
|
expect(backNode).toBeDefined();
|
|
382
360
|
});
|
|
@@ -386,7 +364,7 @@ describe('JATS importer', () => {
|
|
|
386
364
|
if (!appGroup) {
|
|
387
365
|
throw new Error('App group element not found');
|
|
388
366
|
}
|
|
389
|
-
const
|
|
367
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(jats, section_categories_1.sectionCategories);
|
|
390
368
|
const backNode = (0, utils_1.findNodeByType)(node, schema_1.schema.nodes.backmatter);
|
|
391
369
|
const appNode = (0, utils_1.findNodesByType)(backNode, schema_1.schema.nodes.section, false).filter((node) => node.attrs.category === 'appendices');
|
|
392
370
|
expect(appNode).toHaveLength(1);
|
|
@@ -397,14 +375,14 @@ describe('JATS importer', () => {
|
|
|
397
375
|
if (!backEl) {
|
|
398
376
|
throw new Error('Back element not found');
|
|
399
377
|
}
|
|
400
|
-
const
|
|
378
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(jats, section_categories_1.sectionCategories);
|
|
401
379
|
const backNode = (0, utils_1.findNodeByType)(node, schema_1.schema.nodes.backmatter);
|
|
402
380
|
const availabilitySection = (0, utils_1.findNodesByType)(backNode, schema_1.schema.nodes.section, false).filter((node) => node.attrs.category === 'availability');
|
|
403
381
|
expect(availabilitySection).toHaveLength(1);
|
|
404
382
|
});
|
|
405
383
|
it('should create sections for special footnotes', async () => {
|
|
406
384
|
const jats = await (0, files_1.readAndParseFixture)('jats-example-full.xml');
|
|
407
|
-
const
|
|
385
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(jats, section_categories_1.sectionCategories);
|
|
408
386
|
const backNode = (0, utils_1.findNodeByType)(node, schema_1.schema.nodes.backmatter);
|
|
409
387
|
const con = (0, utils_1.findNodesByType)(backNode, schema_1.schema.nodes.section, false).filter((node) => node.attrs.category === 'con');
|
|
410
388
|
const financialDisclosure = (0, utils_1.findNodesByType)(backNode, schema_1.schema.nodes.section, false).filter((node) => node.attrs.category === 'financial-disclosure');
|
|
@@ -415,7 +393,7 @@ describe('JATS importer', () => {
|
|
|
415
393
|
});
|
|
416
394
|
it('should have an endnotes section if either an endnotes section exists or there are footnotes', async () => {
|
|
417
395
|
const jats = await (0, files_1.readAndParseFixture)('jats-example-full.xml');
|
|
418
|
-
const
|
|
396
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(jats, section_categories_1.sectionCategories);
|
|
419
397
|
const backNode = (0, utils_1.findNodeByType)(node, schema_1.schema.nodes.backmatter);
|
|
420
398
|
const endNotesSection = (0, utils_1.findNodesByType)(backNode, schema_1.schema.nodes.footnotes_section, false);
|
|
421
399
|
expect(endNotesSection).toHaveLength(1);
|
|
@@ -426,7 +404,7 @@ describe('JATS importer', () => {
|
|
|
426
404
|
if (!refList) {
|
|
427
405
|
throw new Error('Ref list element not found');
|
|
428
406
|
}
|
|
429
|
-
const
|
|
407
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(jats, section_categories_1.sectionCategories);
|
|
430
408
|
const backNode = (0, utils_1.findNodeByType)(node, schema_1.schema.nodes.backmatter);
|
|
431
409
|
const refSection = (0, utils_1.findNodesByType)(backNode, schema_1.schema.nodes.bibliography_section, false);
|
|
432
410
|
expect(refSection).toHaveLength(1);
|
|
@@ -437,7 +415,7 @@ describe('JATS importer', () => {
|
|
|
437
415
|
if (!ack) {
|
|
438
416
|
throw new Error('Ack element not found');
|
|
439
417
|
}
|
|
440
|
-
const
|
|
418
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(jats, section_categories_1.sectionCategories);
|
|
441
419
|
const backNode = (0, utils_1.findNodeByType)(node, schema_1.schema.nodes.backmatter);
|
|
442
420
|
const ackSection = (0, utils_1.findNodesByType)(backNode, schema_1.schema.nodes.section, false).filter((node) => node.attrs.category === 'acknowledgements');
|
|
443
421
|
expect(ackSection).toHaveLength(1);
|
|
@@ -448,7 +426,7 @@ describe('JATS importer', () => {
|
|
|
448
426
|
if (!refList) {
|
|
449
427
|
throw new Error('Ref list element not found');
|
|
450
428
|
}
|
|
451
|
-
const
|
|
429
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(jats, section_categories_1.sectionCategories);
|
|
452
430
|
const backNode = (0, utils_1.findNodeByType)(node, schema_1.schema.nodes.backmatter);
|
|
453
431
|
const refSection = (0, utils_1.findNodeByType)(backNode, schema_1.schema.nodes.bibliography_section);
|
|
454
432
|
const bibliographyItems = (0, utils_1.findNodesByType)(refSection, schema_1.schema.nodes.bibliography_item);
|
|
@@ -462,7 +440,7 @@ describe('JATS importer', () => {
|
|
|
462
440
|
});
|
|
463
441
|
it('should have the correct number of sections', async () => {
|
|
464
442
|
const jats = await (0, files_1.readAndParseFixture)('jats-example-full.xml');
|
|
465
|
-
const
|
|
443
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(jats, section_categories_1.sectionCategories);
|
|
466
444
|
const backNode = (0, utils_1.findNodeByType)(node, schema_1.schema.nodes.backmatter);
|
|
467
445
|
expect(backNode.childCount).toBe(8);
|
|
468
446
|
});
|
|
@@ -470,43 +448,43 @@ describe('JATS importer', () => {
|
|
|
470
448
|
const jats = await (0, files_1.readAndParseFixture)('jats-import.xml');
|
|
471
449
|
const backEl = jats.querySelector('back');
|
|
472
450
|
backEl?.remove();
|
|
473
|
-
const
|
|
451
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(jats, section_categories_1.sectionCategories);
|
|
474
452
|
const backNode = (0, utils_1.findNodeByType)(node, schema_1.schema.nodes.backmatter);
|
|
475
453
|
expect(backNode).toBeDefined();
|
|
476
454
|
});
|
|
477
455
|
});
|
|
478
456
|
test('parses JATS to Manuscripts document', async () => {
|
|
479
|
-
const
|
|
457
|
+
const node = await (0, utils_1.createNodeFromJATS)('jats-import.xml');
|
|
480
458
|
(0, utils_1.changeIDs)(node);
|
|
481
459
|
expect(node).toMatchSnapshot();
|
|
482
460
|
});
|
|
483
461
|
test('parses JATS AuthorQueries example to Manuscripts document', async () => {
|
|
484
|
-
const
|
|
462
|
+
const node = await (0, utils_1.createNodeFromJATS)('jats-document.xml');
|
|
485
463
|
(0, utils_1.changeIDs)(node);
|
|
486
464
|
expect(node).toMatchSnapshot();
|
|
487
465
|
});
|
|
488
466
|
test('parses full JATS example to Manuscripts document', async () => {
|
|
489
|
-
const
|
|
467
|
+
const node = await (0, utils_1.createNodeFromJATS)('jats-example-doc.xml');
|
|
490
468
|
(0, utils_1.changeIDs)(node);
|
|
491
469
|
expect(node).toMatchSnapshot();
|
|
492
470
|
});
|
|
493
471
|
test("parses JATS article without references and doesn't create empty references section", async () => {
|
|
494
|
-
const
|
|
472
|
+
const node = await (0, utils_1.createNodeFromJATS)('jats-import-no-refs.xml');
|
|
495
473
|
(0, utils_1.changeIDs)(node);
|
|
496
474
|
expect(node).toMatchSnapshot();
|
|
497
475
|
});
|
|
498
476
|
test('parses JATS article to Manuscripts document', async () => {
|
|
499
|
-
const
|
|
477
|
+
const node = await (0, utils_1.createNodeFromJATS)('jats-example.xml');
|
|
500
478
|
(0, utils_1.changeIDs)(node);
|
|
501
479
|
expect(node).toMatchSnapshot();
|
|
502
480
|
});
|
|
503
481
|
test('parses JATS article with tables and table footnotes', async () => {
|
|
504
|
-
const
|
|
482
|
+
const node = await (0, utils_1.createNodeFromJATS)('jats-tables-example.xml');
|
|
505
483
|
(0, utils_1.changeIDs)(node);
|
|
506
484
|
expect(node).toMatchSnapshot();
|
|
507
485
|
});
|
|
508
486
|
test('parses JATS example full', async () => {
|
|
509
|
-
const
|
|
487
|
+
const node = await (0, utils_1.createNodeFromJATS)('jats-example-full.xml');
|
|
510
488
|
(0, utils_1.changeIDs)(node);
|
|
511
489
|
expect(node).toMatchSnapshot();
|
|
512
490
|
});
|
|
@@ -29,10 +29,9 @@ const parseXMLWithDTD = (data) => (0, libxmljs2_1.parseXml)(data, {
|
|
|
29
29
|
const roundtrip = async (filename) => {
|
|
30
30
|
const input = await (0, files_1.readFixture)(filename);
|
|
31
31
|
const doc = new DOMParser().parseFromString(input, 'application/xml');
|
|
32
|
-
const
|
|
32
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(doc, section_categories_1.sectionCategories);
|
|
33
33
|
const exporter = new jats_exporter_1.JATSExporter();
|
|
34
34
|
return await exporter.serializeToJATS(node, {
|
|
35
|
-
journal: journal,
|
|
36
35
|
csl: citations_1.DEFAULT_CSL_OPTIONS,
|
|
37
36
|
});
|
|
38
37
|
};
|