@manuscripts/transform 4.4.3 → 4.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/jats/__tests__/jats-exporter.test.js +21 -0
- package/dist/cjs/jats/exporter/jats-exporter.js +7 -3
- package/dist/cjs/jats/exporter/labels.js +4 -1
- package/dist/cjs/version.js +1 -1
- package/dist/es/jats/__tests__/jats-exporter.test.js +22 -1
- package/dist/es/jats/exporter/jats-exporter.js +7 -3
- package/dist/es/jats/exporter/labels.js +4 -1
- package/dist/es/version.js +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/jats/__tests__/__snapshots__/jats-roundtrip.test.ts.snap +1 -1
- package/src/jats/__tests__/jats-exporter.test.ts +28 -1
- package/src/jats/exporter/jats-exporter.ts +14 -3
- package/src/jats/exporter/labels.ts +4 -1
- package/src/version.ts +1 -1
|
@@ -156,6 +156,27 @@ describe('JATS exporter', () => {
|
|
|
156
156
|
expect(mimeSubtypeAttr?.value()).toBe('vnd.openxmlformats-officedocument.wordprocessingml.document');
|
|
157
157
|
expect(hrefAttr?.value()).toBe('attachment:7d9d686b-5488-44a5-a1c5-46351e7f9312');
|
|
158
158
|
});
|
|
159
|
+
test('exports uncited references alongside cited ones', async () => {
|
|
160
|
+
const input = await (0, files_1.readAndParseFixture)('jats-document.xml');
|
|
161
|
+
const node = (0, parse_jats_article_1.parseJATSArticle)(input, section_categories_1.sectionCategories);
|
|
162
|
+
const bibliographyItemIDs = new Set();
|
|
163
|
+
const citedIDs = new Set();
|
|
164
|
+
node.descendants((n) => {
|
|
165
|
+
if ((0, schema_1.isBibliographyItemNode)(n)) {
|
|
166
|
+
bibliographyItemIDs.add(n.attrs.id);
|
|
167
|
+
}
|
|
168
|
+
if ((0, schema_1.isCitationNode)(n)) {
|
|
169
|
+
n.attrs.rids.forEach((rid) => citedIDs.add(rid));
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
const xml = await new jats_exporter_1.JATSExporter().serializeToJATS(node, {
|
|
173
|
+
csl: citations_1.DEFAULT_CSL_OPTIONS,
|
|
174
|
+
});
|
|
175
|
+
const refCount = parseXMLWithDTD(xml).find('//ref-list/ref').length;
|
|
176
|
+
expect(refCount).toBe(bibliographyItemIDs.size);
|
|
177
|
+
const { errors } = parseXMLWithDTD(xml);
|
|
178
|
+
expect(errors).toHaveLength(0);
|
|
179
|
+
});
|
|
159
180
|
test('export footnotes', async () => {
|
|
160
181
|
const transformer = new jats_exporter_1.JATSExporter();
|
|
161
182
|
const input = await (0, files_1.readAndParseFixture)('jats-fn-group.xml');
|
|
@@ -132,7 +132,7 @@ class JATSExporter {
|
|
|
132
132
|
this.serializeToJATS = async (manuscriptNode, options) => {
|
|
133
133
|
this.manuscriptNode = manuscriptNode;
|
|
134
134
|
this.populateNodesMap();
|
|
135
|
-
this.initCiteprocEngine(options
|
|
135
|
+
this.initCiteprocEngine(options);
|
|
136
136
|
this.createSerializer();
|
|
137
137
|
const versionIds = (0, jats_versions_1.selectVersionIds)(options.version ?? '1.2');
|
|
138
138
|
this.document = document.implementation.createDocument(null, 'article', document.implementation.createDocumentType('article', versionIds.publicId, versionIds.systemId));
|
|
@@ -183,15 +183,18 @@ class JATSExporter {
|
|
|
183
183
|
element.appendChild(caption);
|
|
184
184
|
}
|
|
185
185
|
};
|
|
186
|
-
this.initCiteprocEngine = (
|
|
186
|
+
this.initCiteprocEngine = (options) => {
|
|
187
|
+
const { csl } = options;
|
|
187
188
|
const bibitems = new Map();
|
|
188
189
|
const citations = new Map();
|
|
190
|
+
const citedItemIDs = new Set();
|
|
189
191
|
this.manuscriptNode.descendants((n) => {
|
|
190
192
|
if ((0, schema_1.isBibliographyItemNode)(n)) {
|
|
191
193
|
bibitems.set(n.attrs.id, n.attrs);
|
|
192
194
|
}
|
|
193
195
|
if ((0, schema_1.isCitationNode)(n)) {
|
|
194
196
|
citations.set(n.attrs.id, (0, citeproc_1.buildCiteprocCitation)(n.attrs));
|
|
197
|
+
n.attrs.rids.forEach((rid) => citedItemIDs.add(rid));
|
|
195
198
|
}
|
|
196
199
|
});
|
|
197
200
|
(0, citeproc_2.initJats)();
|
|
@@ -207,7 +210,8 @@ class JATSExporter {
|
|
|
207
210
|
variableWrapper: citeproc_2.jatsVariableWrapper,
|
|
208
211
|
}, csl.style);
|
|
209
212
|
engine.setOutputFormat('jats');
|
|
210
|
-
const
|
|
213
|
+
const uncitedItemIDs = [...bibitems.keys()].filter((id) => !citedItemIDs.has(id));
|
|
214
|
+
const output = engine.rebuildProcessorState([...citations.values()], undefined, uncitedItemIDs);
|
|
211
215
|
this.engine = engine;
|
|
212
216
|
this.renderedCitations = new Map(output.map((i) => [i[0], i[2]]));
|
|
213
217
|
};
|
|
@@ -27,7 +27,10 @@ const labelledNodeTypes = [
|
|
|
27
27
|
schema_1.schema.nodes.embed,
|
|
28
28
|
schema_1.schema.nodes.image_element,
|
|
29
29
|
];
|
|
30
|
-
const excludedTypes = [
|
|
30
|
+
const excludedTypes = [
|
|
31
|
+
schema_1.schema.nodes.graphical_abstract_section,
|
|
32
|
+
schema_1.schema.nodes.trans_graphical_abstract,
|
|
33
|
+
];
|
|
31
34
|
const chooseLabel = (nodeType) => {
|
|
32
35
|
return node_names_1.nodeNames.get(nodeType);
|
|
33
36
|
};
|
package/dist/cjs/version.js
CHANGED
|
@@ -19,7 +19,7 @@ import { parseJATSArticle } from '../importer/parse-jats-article';
|
|
|
19
19
|
import { DEFAULT_CSL_OPTIONS } from './citations';
|
|
20
20
|
import { sectionCategories } from './data/section-categories';
|
|
21
21
|
import { readAndParseFixture } from './files';
|
|
22
|
-
import { isBibliographyItemNode } from '../../schema';
|
|
22
|
+
import { isBibliographyItemNode, isCitationNode, } from '../../schema';
|
|
23
23
|
const parseXMLWithDTD = (data) => parseXml(data, {
|
|
24
24
|
dtdload: true,
|
|
25
25
|
dtdvalid: true,
|
|
@@ -154,6 +154,27 @@ describe('JATS exporter', () => {
|
|
|
154
154
|
expect(mimeSubtypeAttr?.value()).toBe('vnd.openxmlformats-officedocument.wordprocessingml.document');
|
|
155
155
|
expect(hrefAttr?.value()).toBe('attachment:7d9d686b-5488-44a5-a1c5-46351e7f9312');
|
|
156
156
|
});
|
|
157
|
+
test('exports uncited references alongside cited ones', async () => {
|
|
158
|
+
const input = await readAndParseFixture('jats-document.xml');
|
|
159
|
+
const node = parseJATSArticle(input, sectionCategories);
|
|
160
|
+
const bibliographyItemIDs = new Set();
|
|
161
|
+
const citedIDs = new Set();
|
|
162
|
+
node.descendants((n) => {
|
|
163
|
+
if (isBibliographyItemNode(n)) {
|
|
164
|
+
bibliographyItemIDs.add(n.attrs.id);
|
|
165
|
+
}
|
|
166
|
+
if (isCitationNode(n)) {
|
|
167
|
+
n.attrs.rids.forEach((rid) => citedIDs.add(rid));
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
const xml = await new JATSExporter().serializeToJATS(node, {
|
|
171
|
+
csl: DEFAULT_CSL_OPTIONS,
|
|
172
|
+
});
|
|
173
|
+
const refCount = parseXMLWithDTD(xml).find('//ref-list/ref').length;
|
|
174
|
+
expect(refCount).toBe(bibliographyItemIDs.size);
|
|
175
|
+
const { errors } = parseXMLWithDTD(xml);
|
|
176
|
+
expect(errors).toHaveLength(0);
|
|
177
|
+
});
|
|
157
178
|
test('export footnotes', async () => {
|
|
158
179
|
const transformer = new JATSExporter();
|
|
159
180
|
const input = await readAndParseFixture('jats-fn-group.xml');
|
|
@@ -92,7 +92,7 @@ export class JATSExporter {
|
|
|
92
92
|
this.serializeToJATS = async (manuscriptNode, options) => {
|
|
93
93
|
this.manuscriptNode = manuscriptNode;
|
|
94
94
|
this.populateNodesMap();
|
|
95
|
-
this.initCiteprocEngine(options
|
|
95
|
+
this.initCiteprocEngine(options);
|
|
96
96
|
this.createSerializer();
|
|
97
97
|
const versionIds = selectVersionIds(options.version ?? '1.2');
|
|
98
98
|
this.document = document.implementation.createDocument(null, 'article', document.implementation.createDocumentType('article', versionIds.publicId, versionIds.systemId));
|
|
@@ -143,15 +143,18 @@ export class JATSExporter {
|
|
|
143
143
|
element.appendChild(caption);
|
|
144
144
|
}
|
|
145
145
|
};
|
|
146
|
-
this.initCiteprocEngine = (
|
|
146
|
+
this.initCiteprocEngine = (options) => {
|
|
147
|
+
const { csl } = options;
|
|
147
148
|
const bibitems = new Map();
|
|
148
149
|
const citations = new Map();
|
|
150
|
+
const citedItemIDs = new Set();
|
|
149
151
|
this.manuscriptNode.descendants((n) => {
|
|
150
152
|
if (isBibliographyItemNode(n)) {
|
|
151
153
|
bibitems.set(n.attrs.id, n.attrs);
|
|
152
154
|
}
|
|
153
155
|
if (isCitationNode(n)) {
|
|
154
156
|
citations.set(n.attrs.id, buildCiteprocCitation(n.attrs));
|
|
157
|
+
n.attrs.rids.forEach((rid) => citedItemIDs.add(rid));
|
|
155
158
|
}
|
|
156
159
|
});
|
|
157
160
|
initJats();
|
|
@@ -167,7 +170,8 @@ export class JATSExporter {
|
|
|
167
170
|
variableWrapper: jatsVariableWrapper,
|
|
168
171
|
}, csl.style);
|
|
169
172
|
engine.setOutputFormat('jats');
|
|
170
|
-
const
|
|
173
|
+
const uncitedItemIDs = [...bibitems.keys()].filter((id) => !citedItemIDs.has(id));
|
|
174
|
+
const output = engine.rebuildProcessorState([...citations.values()], undefined, uncitedItemIDs);
|
|
171
175
|
this.engine = engine;
|
|
172
176
|
this.renderedCitations = new Map(output.map((i) => [i[0], i[2]]));
|
|
173
177
|
};
|
|
@@ -24,7 +24,10 @@ const labelledNodeTypes = [
|
|
|
24
24
|
schema.nodes.embed,
|
|
25
25
|
schema.nodes.image_element,
|
|
26
26
|
];
|
|
27
|
-
const excludedTypes = [
|
|
27
|
+
const excludedTypes = [
|
|
28
|
+
schema.nodes.graphical_abstract_section,
|
|
29
|
+
schema.nodes.trans_graphical_abstract,
|
|
30
|
+
];
|
|
28
31
|
const chooseLabel = (nodeType) => {
|
|
29
32
|
return nodeNames.get(nodeType);
|
|
30
33
|
};
|
package/dist/es/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "4.4.
|
|
1
|
+
export const VERSION = "4.4.5";
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "4.4.
|
|
1
|
+
export declare const VERSION = "4.4.5";
|
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.4.
|
|
4
|
+
"version": "4.4.5",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-transform",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|
|
@@ -15,4 +15,4 @@ exports[`JATS roundtrip > jats-import.xml roundtrip 1`] = `
|
|
|
15
15
|
Registry, annual report 2011. 2011. Ref Type: Generic.</mixed-citation></ref><ref id=\\"ref-6\\"><label>6. </label><mixed-citation publication-type=\\"journal\\"><person-group person-group-type=\\"author\\"><string-name><surname>Friday</surname> <given-names>G</given-names></string-name>, <string-name><surname>Alter</surname> <given-names>M</given-names></string-name>, <string-name><surname>Lai</surname> <given-names>SM</given-names></string-name></person-group>. <article-title>Control of hypertension and risk of stroke</article-title> <source><italic>Stroke</italic></source>. <year>2002</year>;<volume>33</volume>:<fpage>2652</fpage>-<lpage>2657</lpage>. doi:<pub-id pub-id-type=\\"doi\\">https://doi.org/10.1161/01.STR.0000033929.62136.6F</pub-id></mixed-citation></ref><ref id=\\"ref-7\\"><label>7. </label><mixed-citation publication-type=\\"journal\\"><person-group person-group-type=\\"author\\"><string-name><surname>Lai</surname> <given-names>SM</given-names></string-name>, <string-name><surname>Alter</surname> <given-names>M</given-names></string-name>, <string-name><surname>Friday</surname> <given-names>G</given-names></string-name>, <string-name><surname>Sobel</surname> <given-names>E</given-names></string-name></person-group>. <article-title>A multifactorial analysis of risk</article-title> <source><italic>Stroke</italic></source>. <year>1994</year>;<volume>25</volume>:<fpage>958</fpage>-<lpage>962</lpage>. doi:<pub-id pub-id-type=\\"doi\\">https://doi.org/10.1161/01.STR.25.5.958</pub-id></mixed-citation></ref><ref id=\\"ref-8\\"><label>8. </label><mixed-citation publication-type=\\"journal\\"><person-group person-group-type=\\"author\\"><string-name><surname>Prencipe</surname> <given-names>M</given-names></string-name>, <string-name><surname>Culasso</surname> <given-names>F</given-names></string-name>, <string-name><surname>Rasura</surname> <given-names>M</given-names></string-name>, et al</person-group>. <article-title>Long-term prognosis after a minor</article-title> <source><italic>Stroke</italic></source>. <year>1998</year>;<volume>29</volume>:<fpage>126</fpage>-<lpage>132</lpage>. doi:<pub-id pub-id-type=\\"doi\\">https://doi.org/10.1161/01.STR.29.1.126</pub-id></mixed-citation></ref><ref id=\\"ref-9\\"><label>9. </label><mixed-citation publication-type=\\"journal\\"><person-group person-group-type=\\"author\\"><string-name><surname>Rashid</surname> <given-names>P</given-names></string-name>, <string-name><surname>Leonardi-Bee</surname> <given-names>J</given-names></string-name>, <string-name><surname>Bath</surname> <given-names>P</given-names></string-name></person-group>. <article-title>Blood pressure reduction and secondary</article-title> <source><italic>Stroke</italic></source>. <year>2003</year>;<volume>34</volume>:<fpage>2741</fpage>-<lpage>2748</lpage>. doi:<pub-id pub-id-type=\\"doi\\">https://doi.org/10.1161/01.STR.0000092488.40085.15</pub-id></mixed-citation></ref><ref id=\\"ref-10\\"><label>10. </label><mixed-citation publication-type=\\"journal\\"><person-group person-group-type=\\"author\\"><string-name><surname>Girot</surname> <given-names>M</given-names></string-name>, <string-name><surname>Mackowiak-Cordoliani</surname> <given-names>MA</given-names></string-name>, <string-name><surname>Deplanque</surname> <given-names>D</given-names></string-name>, <string-name><surname>Hénon</surname> <given-names>H</given-names></string-name>, <string-name><surname>Lucas</surname> <given-names>C</given-names></string-name>, <string-name><surname>Leys</surname> <given-names>D</given-names></string-name></person-group>. <article-title>Secondary prevention after ischemic</article-title> <source><italic>Journal of Neurology</italic></source>. <year>2005</year>;<volume>252</volume>:<fpage>14</fpage>-<lpage>20</lpage>. doi:<pub-id pub-id-type=\\"doi\\">https://doi.org/10.1007/s00415-005-0591-8</pub-id></mixed-citation></ref><ref id=\\"ref-11\\"><label>11. </label><mixed-citation publication-type=\\"journal\\"><person-group person-group-type=\\"author\\"><string-name><surname>Johnson</surname> <given-names>P</given-names></string-name>, <string-name><surname>Rosewell</surname> <given-names>M</given-names></string-name>, <string-name><surname>James</surname> <given-names>MA</given-names></string-name></person-group>. <article-title>How good is the management of vascular risk after stroke</article-title>, <source><italic>Cerebrovascular Diseases (Basel, Switzerland)</italic></source>. <year>2007</year>;<volume>23</volume>:<fpage>156</fpage>-<lpage>161</lpage>. doi:<pub-id pub-id-type=\\"doi\\">https://doi.org/10.1159/000097053</pub-id></mixed-citation></ref><ref id=\\"ref-12\\"><label>12. </label><mixed-citation publication-type=\\"journal\\"><person-group person-group-type=\\"author\\"><string-name><surname>Paul</surname> <given-names>SL</given-names></string-name>, <string-name><surname>Thrift</surname> <given-names>AG</given-names></string-name></person-group>. <article-title>Control of hypertension 5 years after stroke in the North</article-title> <source><italic>Hypertension</italic></source>. <year>2006</year>;<volume>48</volume>:<fpage>260</fpage>-<lpage>265</lpage>. doi:<pub-id pub-id-type=\\"doi\\">https://doi.org/10.1161/01.HYP.0000230610.81947.04</pub-id></mixed-citation></ref><ref id=\\"ref-13\\"><label>13. </label><mixed-citation publication-type=\\"journal\\"><person-group person-group-type=\\"author\\"><string-name><surname>Hornnes</surname> <given-names>N</given-names></string-name>, <string-name><surname>Larsen</surname> <given-names>K</given-names></string-name>, <string-name><surname>Boysen</surname> <given-names>G</given-names></string-name></person-group>. <article-title>Little change of modifiable risk factors</article-title> <source><italic>International Journal of Stroke</italic></source>. <year>2010</year>;<volume>5</volume>:<fpage>157</fpage>-<lpage>162</lpage>. doi:<pub-id pub-id-type=\\"doi\\">https://doi.org/10.1111/j.1747-4949.2010.00424.x</pub-id></mixed-citation></ref><ref id=\\"ref-14\\"><label>14. </label><mixed-citation publication-type=\\"journal\\"><person-group person-group-type=\\"author\\"><string-name><surname>Adie</surname> <given-names>K</given-names></string-name>, <string-name><surname>James</surname> <given-names>MA</given-names></string-name></person-group>. <article-title>Does telephone follow-up improve blood pressure after minor</article-title> <source><italic>Age and Ageing</italic></source>. <year>2010</year>;<volume>39</volume>:<fpage>598</fpage>-<lpage>603</lpage>. doi:<pub-id pub-id-type=\\"doi\\">https://doi.org/10.1093/ageing/afq085</pub-id></mixed-citation></ref><ref id=\\"ref-15\\"><label>15. </label><mixed-citation publication-type=\\"journal\\"><person-group person-group-type=\\"author\\"><string-name><surname>Chiu</surname> <given-names>CC</given-names></string-name>, <string-name><surname>Wu</surname> <given-names>SS</given-names></string-name>, <string-name><surname>Lee</surname> <given-names>PY</given-names></string-name>, <string-name><surname>Huang</surname> <given-names>YC</given-names></string-name>, <string-name><surname>Tan</surname> <given-names>TY</given-names></string-name>, <string-name><surname>Chang</surname> <given-names>KC</given-names></string-name></person-group>. <article-title>Control of modifiable risk factors in ischemic stroke</article-title> <source><italic>Journal of Clinical Pharmacy and Therapeutics</italic></source>. <year>2008</year>;<volume>33</volume>:<fpage>529</fpage>-<lpage>535</lpage>. doi:<pub-id pub-id-type=\\"doi\\">https://doi.org/10.1111/j.1365-2710.2008.00940.x</pub-id></mixed-citation></ref><ref id=\\"ref-16\\"><label>16. </label><mixed-citation publication-type=\\"journal\\"><person-group person-group-type=\\"author\\"><string-name><surname>Ellis</surname> <given-names>G</given-names></string-name>, <string-name><surname>Rodger</surname> <given-names>J</given-names></string-name>, <string-name><surname>McAlpine</surname> <given-names>C</given-names></string-name>, <string-name><surname>Langhorne</surname> <given-names>P</given-names></string-name></person-group>. <article-title>The impact of stroke nurse specialist</article-title> <source><italic>Age and Ageing</italic></source>. <year>2005</year>;<volume>34</volume>:<fpage>389</fpage>-<lpage>392</lpage>. doi:<pub-id pub-id-type=\\"doi\\">https://doi.org/10.1093/ageing/afi075</pub-id></mixed-citation></ref><ref id=\\"ref-17\\"><label>17. </label><mixed-citation publication-type=\\"journal\\"><person-group person-group-type=\\"author\\"><string-name><surname>Hornnes</surname> <given-names>N</given-names></string-name>, <string-name><surname>Larsen</surname> <given-names>K</given-names></string-name>, <string-name><surname>Boysen</surname> <given-names>G</given-names></string-name></person-group>. <article-title>Blood pressure 1 year after stroke: The</article-title> <source><italic>Journal of Stroke and Cerebrovascular Diseases</italic></source>. <year>2011</year>;<volume>20</volume>:<fpage>16</fpage>-<lpage>23</lpage>. doi:<pub-id pub-id-type=\\"doi\\">https://doi.org/10.1016/j.jstrokecerebrovasdis.2009.10.002</pub-id></mixed-citation></ref><ref id=\\"ref-18\\"><label>18. </label><mixed-citation publication-type=\\"journal\\"><person-group person-group-type=\\"author\\"><string-name><surname>Johnston</surname> <given-names>SC</given-names></string-name>, <string-name><surname>Sidney</surname> <given-names>S</given-names></string-name>, <string-name><surname>Hills</surname> <given-names>NK</given-names></string-name>, et al</person-group>. <article-title>Standardized discharge orders after</article-title> <source><italic>Annals of Neurology</italic></source>. <year>2010</year>;<volume>67</volume>:<fpage>579</fpage>-<lpage>589</lpage>. doi:<pub-id pub-id-type=\\"doi\\">https://doi.org/10.1002/ana.22019</pub-id></mixed-citation></ref><ref id=\\"ref-19\\"><label>19. </label><mixed-citation publication-type=\\"journal\\"><person-group person-group-type=\\"author\\"><string-name><surname>Joubert</surname> <given-names>J</given-names></string-name>, <string-name><surname>Reid</surname> <given-names>C</given-names></string-name>, <string-name><surname>Barton</surname> <given-names>D</given-names></string-name>, et al</person-group>. <article-title>Integrated care improves risk-factor</article-title> <source><italic>Journal of Neurology, Neurosurgery, and Psychiatry</italic></source>. <year>2009</year>;<volume>80</volume>:<fpage>279</fpage>-<lpage>284</lpage>. doi:<pub-id pub-id-type=\\"doi\\">https://doi.org/10.1136/jnnp.2008.148122</pub-id></mixed-citation></ref><ref id=\\"ref-20\\"><label>20. </label><mixed-citation publication-type=\\"journal\\"><person-group person-group-type=\\"author\\"><string-name><surname>Fahey</surname> <given-names>T</given-names></string-name>, <string-name><surname>Schroeder</surname> <given-names>K</given-names></string-name>, <string-name><surname>Ebrahim</surname> <given-names>S</given-names></string-name></person-group>. <article-title>Interventions used to improve control of</article-title> <source><italic>Cochrane Database of Systematic Reviews</italic></source>. <year>2006</year>.</mixed-citation></ref><ref id=\\"ref-21\\"><label>21. </label><mixed-citation publication-type=\\"journal\\"><person-group person-group-type=\\"author\\"><string-name><surname>Furie</surname> <given-names>KL</given-names></string-name>, <string-name><surname>Kasner</surname> <given-names>SE</given-names></string-name>, <string-name><surname>Adams</surname> <given-names>RJ</given-names></string-name>, et al</person-group>. <article-title>Guidelines for the prevention of stroke</article-title> <source><italic>Stroke</italic></source>. <year>2011</year>;<volume>42</volume>:<fpage>227</fpage>-<lpage>276</lpage>. doi:<pub-id pub-id-type=\\"doi\\">https://doi.org/10.1161/STR.0b013e3181f7d043</pub-id></mixed-citation></ref><ref id=\\"ref-22\\"><label>22. </label><mixed-citation publication-type=\\"journal\\"><person-group person-group-type=\\"author\\"><string-name><surname>Bridgwood</surname> <given-names>B</given-names></string-name>, <string-name><surname>Lager</surname> <given-names>KE</given-names></string-name>, <string-name><surname>Mistri</surname> <given-names>AK</given-names></string-name>, <string-name><surname>Khunti</surname> <given-names>K</given-names></string-name>, <string-name><surname>Wilson</surname> <given-names>AD</given-names></string-name>, <string-name><surname>Modi</surname> <given-names>P</given-names></string-name></person-group>. <article-title>Interventions for improving modifiable</article-title> <source><italic>Cochrane Database of Systematic Reviews</italic></source>. <year>2018</year>;<volume>5</volume>.</mixed-citation></ref><ref id=\\"ref-23\\"><label>23. </label><mixed-citation publication-type=\\"journal\\"><person-group person-group-type=\\"author\\"><string-name><surname>Mancia</surname> <given-names>G</given-names></string-name>, <string-name><surname>Fagard</surname> <given-names>R</given-names></string-name>, <string-name><surname>Narkiewicz</surname> <given-names>K</given-names></string-name>, et al</person-group>. <article-title>2013 Practice guidelines for the management of arterial</article-title> <source><italic>Journal of Hypertension</italic></source>. <year>2013</year>;<volume>31</volume>:<fpage>1925</fpage>-<lpage>1938</lpage>. doi:<pub-id pub-id-type=\\"doi\\">https://doi.org/10.1097/HJH.0b013e328364ca4c</pub-id></mixed-citation></ref><ref id=\\"ref-24\\"><label>24. </label><mixed-citation publication-type=\\"journal\\"><person-group person-group-type=\\"author\\"><string-name><surname>Boan</surname> <given-names>AD</given-names></string-name>, <string-name><surname>Lackland</surname> <given-names>DT</given-names></string-name>, <string-name><surname>Ovbiagele</surname> <given-names>B</given-names></string-name></person-group>. <article-title>Lowering of blood pressure for recurrent</article-title> <source><italic>Stroke</italic></source>. <year>2014</year>;<volume>45</volume>:<fpage>2506</fpage>-<lpage>2513</lpage>. doi:<pub-id pub-id-type=\\"doi\\">https://doi.org/10.1161/STROKEAHA.114.003666</pub-id></mixed-citation></ref><ref id=\\"ref-25\\"><label>25. </label><mixed-citation publication-type=\\"journal\\"><person-group person-group-type=\\"author\\"><string-name><surname>McAlister</surname> <given-names>FA</given-names></string-name>, <string-name><surname>Majumdar</surname> <given-names>SR</given-names></string-name>, <string-name><surname>Padwal</surname> <given-names>RS</given-names></string-name>, et al</person-group>. <article-title>Case management for blood pressure and</article-title> <source><italic>Canadian Medical Association Journal</italic></source>. <year>2014</year>;<volume>186</volume>:<fpage>577</fpage>-<lpage>584</lpage>. doi:<pub-id pub-id-type=\\"doi\\">https://doi.org/10.1503/cmaj.140053</pub-id></mixed-citation></ref></ref-list></back><floats-group><graphic xlink:href=\\"fig1.png\\" content-type=\\"leading\\"><alt-text>example of alt text for hero-image</alt-text><long-desc>example of long desc for hero image</long-desc></graphic></floats-group></article>"
|
|
16
16
|
`;
|
|
17
17
|
|
|
18
|
-
exports[`JATS roundtrip > jats-roundtrip.xml roundtrip 1`] = `"<!DOCTYPE article PUBLIC \\"-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD with OASIS Tables with MathML3 v1.2 20190208//EN\\" \\"http://jats.nlm.nih.gov/archiving/1.2/JATS-archive-oasis-article1-mathml3.dtd\\"><article xmlns:xlink=\\"http://www.w3.org/1999/xlink\\" article-type=\\"research-article\\" xml:lang=\\"en\\"><front><article-meta><title-group><article-title>A complete manuscript</article-title></title-group><contrib-group content-type=\\"authors\\"><contrib contrib-type=\\"author\\" id=\\"contrib-1\\"><name><surname>Macintosh</surname><given-names>Alfred</given-names></name><email>flinserl@hotmail.com</email></contrib><contrib contrib-type=\\"author\\" id=\\"contrib-2\\" corresp=\\"yes\\"><name><surname>Adam</surname><given-names>Rein</given-names></name><email>rein.brys@inbo.be</email></contrib></contrib-group><author-notes><p id=\\"p-1\\">rana nofal testing</p></author-notes><counts><fig-count count=\\"2\\"/><ref-count count=\\"2\\"/><word-count count=\\"107\\"/></counts></article-meta></front><body><sec id=\\"sec-1\\"><title>Figures</title><fig id=\\"fig-1\\" fig-type=\\"half-left\\"><label>Figure 1</label><caption><p>Test1</p><p>Test2</p></caption><p id=\\"p-2\\">A paragraph</p><graphic xlink:href=\\"graphic/111111.jpeg\\"/><graphic specific-use=\\"MISSING\\" xlink:href=\\"\\"/><graphic xlink:href=\\"graphic/333333.jpeg\\"/><attrib>Source: Wikipedia.</attrib></fig></sec></body><back><app-group/><fn-group><fn fn-type=\\"con\\"><label>Author contributions</label><p id=\\"p-3\\">JM and AB wrote the manuscript. All co-authors provided comments and helped revising the manuscript.</p></fn><fn fn-type=\\"financial-disclosure\\"><label>FUNDING INFORMATION</label><p id=\\"p-4\\">This work was supported by the National Natural Science Foundation of China (81771439), Jiangsu Provincial Key <xref ref-type=\\"bibr\\" rid=\\"ref-1\\"><sup>1</sup></xref>Research and Development Program (BE2020661 and BE2018662), Jiangsu Provincial Health Commission Science Research Program (QNRC2016228, H2019056 and LGY2018010), Jiangsu Provincial Six Talent Peaks Project (WSN-165), Suzhou Municipal Health Commission Science Research Program (SZYJTD201715, LCZX201820, Kjxw2018048 and Gwzx201801), Suzhou Municipal Sci-Tech Bureau Program (SZS201722, SS201706, SYS2019113 and SS2019009), and CAS Key Laboratory of Mental Health, Institute of Psychology (KLMH2019K03).</p></fn></fn-group><ref-list><ref id=\\"ref-1\\"><label>1. </label><mixed-citation publication-type=\\"journal\\"><person-group person-group-type=\\"author\\"><string-name><surname>Caldwell</surname> <given-names>CB</given-names></string-name>, <string-name><surname>Gottesman</surname> <given-names>II</given-names></string-name></person-group>. <article-title>Schizophrenia-a high-risk factor for suicide: clues to risk reduction</article-title>. <source><italic>Suicide Life Threat Behav</italic></source>. <year>1992</year>;<volume>22</volume><issue>(4)</issue>:<fpage>479</fpage>-<lpage>493</lpage>.</mixed-citation></ref></ref-list></back></article>"`;
|
|
18
|
+
exports[`JATS roundtrip > jats-roundtrip.xml roundtrip 1`] = `"<!DOCTYPE article PUBLIC \\"-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD with OASIS Tables with MathML3 v1.2 20190208//EN\\" \\"http://jats.nlm.nih.gov/archiving/1.2/JATS-archive-oasis-article1-mathml3.dtd\\"><article xmlns:xlink=\\"http://www.w3.org/1999/xlink\\" article-type=\\"research-article\\" xml:lang=\\"en\\"><front><article-meta><title-group><article-title>A complete manuscript</article-title></title-group><contrib-group content-type=\\"authors\\"><contrib contrib-type=\\"author\\" id=\\"contrib-1\\"><name><surname>Macintosh</surname><given-names>Alfred</given-names></name><email>flinserl@hotmail.com</email></contrib><contrib contrib-type=\\"author\\" id=\\"contrib-2\\" corresp=\\"yes\\"><name><surname>Adam</surname><given-names>Rein</given-names></name><email>rein.brys@inbo.be</email></contrib></contrib-group><author-notes><p id=\\"p-1\\">rana nofal testing</p></author-notes><counts><fig-count count=\\"2\\"/><ref-count count=\\"2\\"/><word-count count=\\"107\\"/></counts></article-meta></front><body><sec id=\\"sec-1\\"><title>Figures</title><fig id=\\"fig-1\\" fig-type=\\"half-left\\"><label>Figure 1</label><caption><p>Test1</p><p>Test2</p></caption><p id=\\"p-2\\">A paragraph</p><graphic xlink:href=\\"graphic/111111.jpeg\\"/><graphic specific-use=\\"MISSING\\" xlink:href=\\"\\"/><graphic xlink:href=\\"graphic/333333.jpeg\\"/><attrib>Source: Wikipedia.</attrib></fig></sec></body><back><app-group/><fn-group><fn fn-type=\\"con\\"><label>Author contributions</label><p id=\\"p-3\\">JM and AB wrote the manuscript. All co-authors provided comments and helped revising the manuscript.</p></fn><fn fn-type=\\"financial-disclosure\\"><label>FUNDING INFORMATION</label><p id=\\"p-4\\">This work was supported by the National Natural Science Foundation of China (81771439), Jiangsu Provincial Key <xref ref-type=\\"bibr\\" rid=\\"ref-1\\"><sup>1</sup></xref>Research and Development Program (BE2020661 and BE2018662), Jiangsu Provincial Health Commission Science Research Program (QNRC2016228, H2019056 and LGY2018010), Jiangsu Provincial Six Talent Peaks Project (WSN-165), Suzhou Municipal Health Commission Science Research Program (SZYJTD201715, LCZX201820, Kjxw2018048 and Gwzx201801), Suzhou Municipal Sci-Tech Bureau Program (SZS201722, SS201706, SYS2019113 and SS2019009), and CAS Key Laboratory of Mental Health, Institute of Psychology (KLMH2019K03).</p></fn></fn-group><ref-list><ref id=\\"ref-1\\"><label>1. </label><mixed-citation publication-type=\\"journal\\"><person-group person-group-type=\\"author\\"><string-name><surname>Caldwell</surname> <given-names>CB</given-names></string-name>, <string-name><surname>Gottesman</surname> <given-names>II</given-names></string-name></person-group>. <article-title>Schizophrenia-a high-risk factor for suicide: clues to risk reduction</article-title>. <source><italic>Suicide Life Threat Behav</italic></source>. <year>1992</year>;<volume>22</volume><issue>(4)</issue>:<fpage>479</fpage>-<lpage>493</lpage>.</mixed-citation></ref><ref id=\\"ref-2\\"><label>2. </label><mixed-citation publication-type=\\"journal\\"><person-group person-group-type=\\"author\\"><string-name><surname>Hor</surname> <given-names>K</given-names></string-name>, <string-name><surname>Taylor</surname> <given-names>M</given-names></string-name></person-group>. <article-title>Suicide and schizophrenia: a systematic review of rates and risk factors</article-title>. <source><italic>J Psychopharmacol</italic></source>. <year>2010</year>;<volume>24</volume><issue>(4)</issue>:<fpage>81</fpage>-<lpage>90</lpage>. doi:<pub-id pub-id-type=\\"doi\\">https://doi.org/10.1177/1359786810385490</pub-id></mixed-citation></ref></ref-list></back></article>"`;
|
|
@@ -22,7 +22,11 @@ import { parseJATSArticle } from '../importer/parse-jats-article'
|
|
|
22
22
|
import { DEFAULT_CSL_OPTIONS } from './citations'
|
|
23
23
|
import { sectionCategories } from './data/section-categories'
|
|
24
24
|
import { readAndParseFixture } from './files'
|
|
25
|
-
import {
|
|
25
|
+
import {
|
|
26
|
+
BibliographyItemNode,
|
|
27
|
+
isBibliographyItemNode,
|
|
28
|
+
isCitationNode,
|
|
29
|
+
} from '../../schema'
|
|
26
30
|
|
|
27
31
|
const parseXMLWithDTD = (data: string) =>
|
|
28
32
|
parseXml(data, {
|
|
@@ -197,6 +201,29 @@ describe('JATS exporter', () => {
|
|
|
197
201
|
)
|
|
198
202
|
})
|
|
199
203
|
|
|
204
|
+
test('exports uncited references alongside cited ones', async () => {
|
|
205
|
+
const input = await readAndParseFixture('jats-document.xml')
|
|
206
|
+
const node = parseJATSArticle(input, sectionCategories)
|
|
207
|
+
|
|
208
|
+
const bibliographyItemIDs = new Set<string>()
|
|
209
|
+
const citedIDs = new Set<string>()
|
|
210
|
+
node.descendants((n) => {
|
|
211
|
+
if (isBibliographyItemNode(n)) {
|
|
212
|
+
bibliographyItemIDs.add(n.attrs.id)
|
|
213
|
+
}
|
|
214
|
+
if (isCitationNode(n)) {
|
|
215
|
+
n.attrs.rids.forEach((rid: string) => citedIDs.add(rid))
|
|
216
|
+
}
|
|
217
|
+
})
|
|
218
|
+
const xml = await new JATSExporter().serializeToJATS(node, {
|
|
219
|
+
csl: DEFAULT_CSL_OPTIONS,
|
|
220
|
+
})
|
|
221
|
+
const refCount = parseXMLWithDTD(xml).find('//ref-list/ref').length
|
|
222
|
+
expect(refCount).toBe(bibliographyItemIDs.size)
|
|
223
|
+
const { errors } = parseXMLWithDTD(xml)
|
|
224
|
+
expect(errors).toHaveLength(0)
|
|
225
|
+
})
|
|
226
|
+
|
|
200
227
|
test('export footnotes', async () => {
|
|
201
228
|
const transformer = new JATSExporter()
|
|
202
229
|
const input = await readAndParseFixture('jats-fn-group.xml')
|
|
@@ -191,7 +191,7 @@ export class JATSExporter {
|
|
|
191
191
|
): Promise<string> => {
|
|
192
192
|
this.manuscriptNode = manuscriptNode
|
|
193
193
|
this.populateNodesMap()
|
|
194
|
-
this.initCiteprocEngine(options
|
|
194
|
+
this.initCiteprocEngine(options)
|
|
195
195
|
this.createSerializer()
|
|
196
196
|
const versionIds = selectVersionIds(options.version ?? '1.2')
|
|
197
197
|
|
|
@@ -283,9 +283,11 @@ export class JATSExporter {
|
|
|
283
283
|
element.appendChild(caption)
|
|
284
284
|
}
|
|
285
285
|
}
|
|
286
|
-
private initCiteprocEngine = (
|
|
286
|
+
private initCiteprocEngine = (options: ExportOptions) => {
|
|
287
|
+
const { csl } = options
|
|
287
288
|
const bibitems: Map<string, CSL.Data> = new Map()
|
|
288
289
|
const citations: Map<string, Citeproc.Citation> = new Map()
|
|
290
|
+
const citedItemIDs: Set<string> = new Set()
|
|
289
291
|
|
|
290
292
|
this.manuscriptNode.descendants((n) => {
|
|
291
293
|
if (isBibliographyItemNode(n)) {
|
|
@@ -293,6 +295,7 @@ export class JATSExporter {
|
|
|
293
295
|
}
|
|
294
296
|
if (isCitationNode(n)) {
|
|
295
297
|
citations.set(n.attrs.id, buildCiteprocCitation(n.attrs))
|
|
298
|
+
n.attrs.rids.forEach((rid: string) => citedItemIDs.add(rid))
|
|
296
299
|
}
|
|
297
300
|
})
|
|
298
301
|
|
|
@@ -313,7 +316,15 @@ export class JATSExporter {
|
|
|
313
316
|
)
|
|
314
317
|
engine.setOutputFormat('jats')
|
|
315
318
|
|
|
316
|
-
const
|
|
319
|
+
const uncitedItemIDs = [...bibitems.keys()].filter(
|
|
320
|
+
(id) => !citedItemIDs.has(id)
|
|
321
|
+
)
|
|
322
|
+
|
|
323
|
+
const output = engine.rebuildProcessorState(
|
|
324
|
+
[...citations.values()],
|
|
325
|
+
undefined,
|
|
326
|
+
uncitedItemIDs
|
|
327
|
+
)
|
|
317
328
|
|
|
318
329
|
this.engine = engine
|
|
319
330
|
this.renderedCitations = new Map(output.map((i) => [i[0], i[2]]))
|
|
@@ -43,7 +43,10 @@ const labelledNodeTypes: ManuscriptNodeType[] = [
|
|
|
43
43
|
schema.nodes.image_element,
|
|
44
44
|
]
|
|
45
45
|
|
|
46
|
-
const excludedTypes = [
|
|
46
|
+
const excludedTypes = [
|
|
47
|
+
schema.nodes.graphical_abstract_section,
|
|
48
|
+
schema.nodes.trans_graphical_abstract,
|
|
49
|
+
]
|
|
47
50
|
|
|
48
51
|
const chooseLabel = (nodeType: ManuscriptNodeType): string => {
|
|
49
52
|
return nodeNames.get(nodeType) as string
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "4.4.
|
|
1
|
+
export const VERSION = "4.4.5";
|