@manuscripts/transform 4.2.10 → 4.2.12
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/getVersion.js +1 -2
- package/dist/cjs/jats/exporter/jats-exporter.js +33 -23
- package/dist/cjs/jats/importer/jats-dom-parser.js +10 -10
- package/dist/cjs/lib/credit-roles.js +1 -1
- package/dist/cjs/lib/utils.js +3 -3
- package/dist/cjs/lib/xml.js +20 -0
- package/dist/cjs/schema/__tests__/migration.test.js +17 -7
- package/dist/cjs/schema/migration/migrate.js +2 -3
- package/dist/cjs/schema/types.js +1 -2
- package/dist/cjs/version.js +1 -1
- package/dist/es/jats/exporter/jats-exporter.js +2 -2
- package/dist/es/jats/importer/jats-dom-parser.js +10 -10
- package/dist/es/lib/xml.js +17 -0
- package/dist/es/version.js +1 -1
- package/dist/types/jats/__tests__/utils.d.ts +1 -1
- package/dist/types/jats/importer/jats-dom-parser.d.ts +0 -1
- package/dist/types/jats/importer/jats-parser-utils.d.ts +1 -1
- package/dist/types/jats/importer/parse-jats-article.d.ts +1 -1
- package/dist/types/lib/html.d.ts +1 -1
- package/dist/types/lib/xml.d.ts +17 -0
- package/dist/types/schema/nodes/manuscript.d.ts +1 -1
- package/dist/types/transformer/node-types.d.ts +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +6 -6
package/dist/cjs/getVersion.js
CHANGED
|
@@ -15,9 +15,8 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.getVersion =
|
|
18
|
+
exports.getVersion = getVersion;
|
|
19
19
|
const version_1 = require("./version");
|
|
20
20
|
function getVersion() {
|
|
21
21
|
return version_1.VERSION;
|
|
22
22
|
}
|
|
23
|
-
exports.getVersion = getVersion;
|
|
@@ -30,13 +30,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
30
30
|
}) : function(o, v) {
|
|
31
31
|
o["default"] = v;
|
|
32
32
|
});
|
|
33
|
-
var __importStar = (this && this.__importStar) || function (
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
};
|
|
33
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
34
|
+
var ownKeys = function(o) {
|
|
35
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
36
|
+
var ar = [];
|
|
37
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
38
|
+
return ar;
|
|
39
|
+
};
|
|
40
|
+
return ownKeys(o);
|
|
41
|
+
};
|
|
42
|
+
return function (mod) {
|
|
43
|
+
if (mod && mod.__esModule) return mod;
|
|
44
|
+
var result = {};
|
|
45
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
46
|
+
__setModuleDefault(result, mod);
|
|
47
|
+
return result;
|
|
48
|
+
};
|
|
49
|
+
})();
|
|
40
50
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
41
51
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
42
52
|
};
|
|
@@ -50,13 +60,12 @@ const citeproc_1 = require("../../lib/citeproc");
|
|
|
50
60
|
const credit_roles_1 = require("../../lib/credit-roles");
|
|
51
61
|
const footnotes_1 = require("../../lib/footnotes");
|
|
52
62
|
const html_1 = require("../../lib/html");
|
|
63
|
+
const xml_1 = require("../../lib/xml");
|
|
53
64
|
const schema_1 = require("../../schema");
|
|
54
65
|
const transformer_1 = require("../../transformer");
|
|
55
66
|
const citeproc_2 = require("./citeproc");
|
|
56
67
|
const jats_versions_1 = require("./jats-versions");
|
|
57
68
|
const labels_1 = require("./labels");
|
|
58
|
-
const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
|
|
59
|
-
const XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
|
|
60
69
|
const normalizeID = (id) => id.replace(/:/g, '_');
|
|
61
70
|
const parser = prosemirror_model_1.DOMParser.fromSchema(schema_1.schema);
|
|
62
71
|
const insertAbstractNode = (front, abstractNode) => {
|
|
@@ -128,10 +137,11 @@ class JATSExporter {
|
|
|
128
137
|
const versionIds = (0, jats_versions_1.selectVersionIds)(options.version ?? '1.2');
|
|
129
138
|
this.document = document.implementation.createDocument(null, 'article', document.implementation.createDocumentType('article', versionIds.publicId, versionIds.systemId));
|
|
130
139
|
const article = this.document.documentElement;
|
|
131
|
-
article.setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:xlink', XLINK_NAMESPACE);
|
|
140
|
+
article.setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:xlink', xml_1.XLINK_NAMESPACE);
|
|
132
141
|
const front = this.buildFront(options.journal);
|
|
133
142
|
article.appendChild(front);
|
|
134
143
|
article.setAttribute('article-type', manuscriptNode.attrs.articleType || 'other');
|
|
144
|
+
article.setAttributeNS(xml_1.XML_NAMESPACE, 'lang', manuscriptNode.attrs.primaryLanguageCode || 'en');
|
|
135
145
|
this.labelTargets = (0, labels_1.buildTargets)(manuscriptNode);
|
|
136
146
|
this.footnoteLabels = (0, footnotes_1.generateFootnoteLabels)(manuscriptNode);
|
|
137
147
|
const body = this.buildBody();
|
|
@@ -315,7 +325,7 @@ class JATSExporter {
|
|
|
315
325
|
supplementsNodes.forEach((node) => {
|
|
316
326
|
const supplementaryMaterial = this.createElement('supplementary-material');
|
|
317
327
|
supplementaryMaterial.setAttribute('id', normalizeID(node.attrs.id));
|
|
318
|
-
supplementaryMaterial.setAttributeNS(XLINK_NAMESPACE, 'href', node.attrs.href ?? '');
|
|
328
|
+
supplementaryMaterial.setAttributeNS(xml_1.XLINK_NAMESPACE, 'href', node.attrs.href ?? '');
|
|
319
329
|
supplementaryMaterial.setAttribute('mimetype', node.attrs.mimeType ?? '');
|
|
320
330
|
supplementaryMaterial.setAttribute('mime-subtype', node.attrs.mimeSubType ?? '');
|
|
321
331
|
const caption = this.createElement('caption');
|
|
@@ -378,7 +388,7 @@ class JATSExporter {
|
|
|
378
388
|
selfUriAttachments.forEach((attachment) => {
|
|
379
389
|
const selfUriElement = this.createElement('self-uri');
|
|
380
390
|
selfUriElement.setAttribute('content-type', attachment.attrs.type);
|
|
381
|
-
selfUriElement.setAttributeNS(XLINK_NAMESPACE, 'href', attachment.attrs.href);
|
|
391
|
+
selfUriElement.setAttributeNS(xml_1.XLINK_NAMESPACE, 'href', attachment.attrs.href);
|
|
382
392
|
const insertBeforeElements = articleMeta.querySelector('related-article, related-object, abstract, trans-abstract, kwd-group, funding-group, support-group, conference, counts, custom-meta-group');
|
|
383
393
|
insertBeforeElements
|
|
384
394
|
? articleMeta.insertBefore(selfUriElement, insertBeforeElements)
|
|
@@ -443,7 +453,7 @@ class JATSExporter {
|
|
|
443
453
|
const parser = new DOMParser();
|
|
444
454
|
const [_, bibliography] = this.engine.makeBibliography();
|
|
445
455
|
for (let i = 0; i < bibliography.length; i++) {
|
|
446
|
-
const item = `<template xmlns:xlink="${XLINK_NAMESPACE}">${bibliography[i]}</template>`;
|
|
456
|
+
const item = `<template xmlns:xlink="${xml_1.XLINK_NAMESPACE}">${bibliography[i]}</template>`;
|
|
447
457
|
const ref = parser.parseFromString(item, 'text/xml').querySelector('ref');
|
|
448
458
|
if (ref) {
|
|
449
459
|
refList.appendChild(ref);
|
|
@@ -473,7 +483,7 @@ class JATSExporter {
|
|
|
473
483
|
id: normalizeID(node.attrs.id),
|
|
474
484
|
};
|
|
475
485
|
if (node.attrs.lang) {
|
|
476
|
-
attrs[`${XML_NAMESPACE} lang`] = node.attrs.lang;
|
|
486
|
+
attrs[`${xml_1.XML_NAMESPACE} lang`] = node.attrs.lang;
|
|
477
487
|
}
|
|
478
488
|
if (node.attrs.category) {
|
|
479
489
|
attrs['sec-type'] = node.attrs.category;
|
|
@@ -507,8 +517,8 @@ class JATSExporter {
|
|
|
507
517
|
}
|
|
508
518
|
const mediaElement = this.createElement('media');
|
|
509
519
|
mediaElement.setAttribute('id', normalizeID(id));
|
|
510
|
-
mediaElement.setAttributeNS(XLINK_NAMESPACE, 'show', 'embed');
|
|
511
|
-
mediaElement.setAttributeNS(XLINK_NAMESPACE, 'href', href);
|
|
520
|
+
mediaElement.setAttributeNS(xml_1.XLINK_NAMESPACE, 'show', 'embed');
|
|
521
|
+
mediaElement.setAttributeNS(xml_1.XLINK_NAMESPACE, 'href', href);
|
|
512
522
|
if (mimetype) {
|
|
513
523
|
mediaElement.setAttribute('mimetype', node.attrs.mimetype);
|
|
514
524
|
}
|
|
@@ -686,10 +696,10 @@ class JATSExporter {
|
|
|
686
696
|
}
|
|
687
697
|
const linkNode = this.createElement('ext-link');
|
|
688
698
|
linkNode.setAttribute('ext-link-type', 'uri');
|
|
689
|
-
linkNode.setAttributeNS(XLINK_NAMESPACE, 'href', node.attrs.href);
|
|
699
|
+
linkNode.setAttributeNS(xml_1.XLINK_NAMESPACE, 'href', node.attrs.href);
|
|
690
700
|
linkNode.textContent = text;
|
|
691
701
|
if (node.attrs.title) {
|
|
692
|
-
linkNode.setAttributeNS(XLINK_NAMESPACE, 'xlink:title', node.attrs.title);
|
|
702
|
+
linkNode.setAttributeNS(xml_1.XLINK_NAMESPACE, 'xlink:title', node.attrs.title);
|
|
693
703
|
}
|
|
694
704
|
return linkNode;
|
|
695
705
|
},
|
|
@@ -706,7 +716,7 @@ class JATSExporter {
|
|
|
706
716
|
missing_figure: () => {
|
|
707
717
|
const graphic = this.createElement('graphic');
|
|
708
718
|
graphic.setAttribute('specific-use', 'MISSING');
|
|
709
|
-
graphic.setAttributeNS(XLINK_NAMESPACE, 'xlink:href', '');
|
|
719
|
+
graphic.setAttributeNS(xml_1.XLINK_NAMESPACE, 'xlink:href', '');
|
|
710
720
|
return graphic;
|
|
711
721
|
},
|
|
712
722
|
paragraph: (node) => {
|
|
@@ -909,7 +919,7 @@ class JATSExporter {
|
|
|
909
919
|
const graphicElement = createGraphic(graphicNode);
|
|
910
920
|
if (node.attrs.extLink) {
|
|
911
921
|
const extLink = this.appendElement(graphicElement, 'ext-link');
|
|
912
|
-
extLink.setAttributeNS(XLINK_NAMESPACE, 'href', node.attrs.extLink);
|
|
922
|
+
extLink.setAttributeNS(xml_1.XLINK_NAMESPACE, 'href', node.attrs.extLink);
|
|
913
923
|
}
|
|
914
924
|
appendChildNodeOfType(graphicElement, node, schema_1.schema.nodes.alt_text);
|
|
915
925
|
appendChildNodeOfType(graphicElement, node, schema_1.schema.nodes.long_desc);
|
|
@@ -917,7 +927,7 @@ class JATSExporter {
|
|
|
917
927
|
};
|
|
918
928
|
const createGraphic = (node) => {
|
|
919
929
|
const graphic = this.createElement('graphic');
|
|
920
|
-
graphic.setAttributeNS(XLINK_NAMESPACE, 'xlink:href', node.attrs.src);
|
|
930
|
+
graphic.setAttributeNS(xml_1.XLINK_NAMESPACE, 'xlink:href', node.attrs.src);
|
|
921
931
|
if (isChildOfNodeType(node.attrs.id, schema_1.schema.nodes.hero_image)) {
|
|
922
932
|
graphic.setAttribute('content-type', 'leading');
|
|
923
933
|
}
|
|
@@ -1134,7 +1144,7 @@ class JATSExporter {
|
|
|
1134
1144
|
}
|
|
1135
1145
|
if (affiliation.attrs.email) {
|
|
1136
1146
|
const email = this.createElement('email');
|
|
1137
|
-
email.setAttributeNS(XLINK_NAMESPACE, 'href', affiliation.attrs.email.href ?? '');
|
|
1147
|
+
email.setAttributeNS(xml_1.XLINK_NAMESPACE, 'href', affiliation.attrs.email.href ?? '');
|
|
1138
1148
|
email.textContent = affiliation.attrs.email.text ?? '';
|
|
1139
1149
|
aff.appendChild(email);
|
|
1140
1150
|
}
|
|
@@ -1531,7 +1541,7 @@ class JATSExporter {
|
|
|
1531
1541
|
}
|
|
1532
1542
|
createTransAbstractNode(transAbstract) {
|
|
1533
1543
|
const transAbstractNode = this.createElement('trans-abstract');
|
|
1534
|
-
transAbstractNode.setAttributeNS(XML_NAMESPACE, 'lang', transAbstract.getAttributeNS(XML_NAMESPACE, 'lang') ?? '');
|
|
1544
|
+
transAbstractNode.setAttributeNS(xml_1.XML_NAMESPACE, 'lang', transAbstract.getAttributeNS(xml_1.XML_NAMESPACE, 'lang') ?? '');
|
|
1535
1545
|
this.setAbstractType(transAbstractNode, transAbstract);
|
|
1536
1546
|
transAbstractNode.append(...transAbstract.childNodes);
|
|
1537
1547
|
return transAbstractNode;
|
|
@@ -19,12 +19,12 @@ exports.JATSDOMParser = void 0;
|
|
|
19
19
|
const json_schema_1 = require("@manuscripts/json-schema");
|
|
20
20
|
const prosemirror_model_1 = require("prosemirror-model");
|
|
21
21
|
const utils_1 = require("../../lib/utils");
|
|
22
|
+
const xml_1 = require("../../lib/xml");
|
|
22
23
|
const jats_comments_1 = require("./jats-comments");
|
|
23
24
|
class JATSDOMParser {
|
|
24
25
|
constructor(sectionCategories, schema) {
|
|
25
26
|
this.sectionCategories = sectionCategories;
|
|
26
27
|
this.schema = schema;
|
|
27
|
-
this.XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
|
|
28
28
|
this.parsePriority = (priority) => {
|
|
29
29
|
if (!priority) {
|
|
30
30
|
return undefined;
|
|
@@ -92,7 +92,7 @@ class JATSDOMParser {
|
|
|
92
92
|
const email = element.querySelector('email');
|
|
93
93
|
if (email) {
|
|
94
94
|
return {
|
|
95
|
-
href: email.getAttributeNS(
|
|
95
|
+
href: email.getAttributeNS(xml_1.XLINK_NAMESPACE, 'href') ?? '',
|
|
96
96
|
text: (0, utils_1.getTrimmedTextContent)(email) ?? '',
|
|
97
97
|
};
|
|
98
98
|
}
|
|
@@ -106,8 +106,8 @@ class JATSDOMParser {
|
|
|
106
106
|
type: parentElement?.getAttribute('fig-type') ??
|
|
107
107
|
element.getAttribute('content-type') ??
|
|
108
108
|
'',
|
|
109
|
-
src: element.getAttributeNS(
|
|
110
|
-
extLink: extLink?.getAttributeNS(
|
|
109
|
+
src: element.getAttributeNS(xml_1.XLINK_NAMESPACE, 'href'),
|
|
110
|
+
extLink: extLink?.getAttributeNS(xml_1.XLINK_NAMESPACE, 'href'),
|
|
111
111
|
};
|
|
112
112
|
};
|
|
113
113
|
this.getInstitutionDetails = (element) => {
|
|
@@ -220,7 +220,7 @@ class JATSDOMParser {
|
|
|
220
220
|
const element = node;
|
|
221
221
|
return {
|
|
222
222
|
id: element.getAttribute('id'),
|
|
223
|
-
href: element.getAttributeNS(
|
|
223
|
+
href: element.getAttributeNS(xml_1.XLINK_NAMESPACE, 'href') || '',
|
|
224
224
|
type: element.getAttribute('content-type') || '',
|
|
225
225
|
};
|
|
226
226
|
},
|
|
@@ -236,7 +236,7 @@ class JATSDOMParser {
|
|
|
236
236
|
return {
|
|
237
237
|
doi: (0, utils_1.getTrimmedTextContent)(doi),
|
|
238
238
|
articleType: element.getAttribute('article-type') || '',
|
|
239
|
-
primaryLanguageCode: element.
|
|
239
|
+
primaryLanguageCode: element.getAttributeNS(xml_1.XML_NAMESPACE, 'lang'),
|
|
240
240
|
...dates,
|
|
241
241
|
};
|
|
242
242
|
},
|
|
@@ -576,8 +576,8 @@ class JATSDOMParser {
|
|
|
576
576
|
getAttrs: (node) => {
|
|
577
577
|
const element = node;
|
|
578
578
|
return {
|
|
579
|
-
href: element.getAttributeNS(
|
|
580
|
-
title: element.getAttributeNS(
|
|
579
|
+
href: element.getAttributeNS(xml_1.XLINK_NAMESPACE, 'href') || '',
|
|
580
|
+
title: element.getAttributeNS(xml_1.XLINK_NAMESPACE, 'title') || '',
|
|
581
581
|
};
|
|
582
582
|
},
|
|
583
583
|
},
|
|
@@ -598,7 +598,7 @@ class JATSDOMParser {
|
|
|
598
598
|
const element = node;
|
|
599
599
|
return {
|
|
600
600
|
id: element.getAttribute('id'),
|
|
601
|
-
href: element.getAttributeNS(
|
|
601
|
+
href: element.getAttributeNS(xml_1.XLINK_NAMESPACE, 'href'),
|
|
602
602
|
mimetype: element.getAttribute('mimetype'),
|
|
603
603
|
mimeSubtype: element.getAttribute('mime-subtype'),
|
|
604
604
|
};
|
|
@@ -773,7 +773,7 @@ class JATSDOMParser {
|
|
|
773
773
|
const element = node;
|
|
774
774
|
return {
|
|
775
775
|
id: element.getAttribute('id'),
|
|
776
|
-
href: element.getAttributeNS(
|
|
776
|
+
href: element.getAttributeNS(xml_1.XLINK_NAMESPACE, 'href'),
|
|
777
777
|
mimeType: element.getAttribute('mimetype'),
|
|
778
778
|
mimeSubType: element.getAttribute('mime-subtype'),
|
|
779
779
|
title: (0, utils_1.getTrimmedTextContent)(element, 'title'),
|
|
@@ -32,7 +32,7 @@ var CreditVocabTerm;
|
|
|
32
32
|
CreditVocabTerm["Visualization"] = "Visualization";
|
|
33
33
|
CreditVocabTerm["WritingOriginalDraft"] = "Writing \u2013 original draft";
|
|
34
34
|
CreditVocabTerm["WritingReviewEditing"] = "Writing \u2013 review & editing";
|
|
35
|
-
})(CreditVocabTerm
|
|
35
|
+
})(CreditVocabTerm || (exports.CreditVocabTerm = CreditVocabTerm = {}));
|
|
36
36
|
exports.CreditRoleUrls = new Map([
|
|
37
37
|
[
|
|
38
38
|
CreditVocabTerm.Conceptualization,
|
package/dist/cjs/lib/utils.js
CHANGED
|
@@ -15,7 +15,9 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.
|
|
18
|
+
exports.dateToTimestamp = exports.getHTMLContent = exports.getTrimmedTextContent = exports.findParentNodeClosestToPos = exports.isInBibliographySection = exports.isInGraphicalAbstractSection = exports.findNodePositions = void 0;
|
|
19
|
+
exports.iterateChildren = iterateChildren;
|
|
20
|
+
exports.getCreditRole = getCreditRole;
|
|
19
21
|
const jats_parser_utils_1 = require("../jats/importer/jats-parser-utils");
|
|
20
22
|
const schema_1 = require("../schema");
|
|
21
23
|
const credit_roles_1 = require("./credit-roles");
|
|
@@ -30,7 +32,6 @@ function* iterateChildren(node, recurse = false) {
|
|
|
30
32
|
}
|
|
31
33
|
}
|
|
32
34
|
}
|
|
33
|
-
exports.iterateChildren = iterateChildren;
|
|
34
35
|
const findNodePositions = (state, predicate) => {
|
|
35
36
|
const found = [];
|
|
36
37
|
state.doc.descendants((node, nodePos) => {
|
|
@@ -116,4 +117,3 @@ function getCreditRole(elem) {
|
|
|
116
117
|
});
|
|
117
118
|
return results;
|
|
118
119
|
}
|
|
119
|
-
exports.getCreditRole = getCreditRole;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* © 2025 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.XML_NAMESPACE = exports.XLINK_NAMESPACE = void 0;
|
|
19
|
+
exports.XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
|
|
20
|
+
exports.XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
|
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
36
|
const prevPackage = __importStar(require("migration-base"));
|
|
27
37
|
const migrate_1 = require("../migration/migrate");
|
|
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.default = migrate;
|
|
7
|
+
exports.migrateFor = migrateFor;
|
|
7
8
|
const lodash_1 = require("lodash");
|
|
8
9
|
const semver_1 = __importDefault(require("semver"));
|
|
9
10
|
const __1 = require("..");
|
|
@@ -18,7 +19,6 @@ function migrate(oldDoc, migrationScript) {
|
|
|
18
19
|
}
|
|
19
20
|
return migrateNode(oldDoc);
|
|
20
21
|
}
|
|
21
|
-
exports.default = migrate;
|
|
22
22
|
function migrateFor(oldDoc, baseVersion) {
|
|
23
23
|
const migrationScripts = ensureVersionAscOrder();
|
|
24
24
|
let migratedDoc = (0, lodash_1.cloneDeep)(oldDoc);
|
|
@@ -32,7 +32,6 @@ function migrateFor(oldDoc, baseVersion) {
|
|
|
32
32
|
}
|
|
33
33
|
return testDoc(migratedDoc, baseVersion);
|
|
34
34
|
}
|
|
35
|
-
exports.migrateFor = migrateFor;
|
|
36
35
|
const ensureVersionAscOrder = () => migration_scripts_1.default.sort((a, b) => semver_1.default.compare(a.toVersion, b.toVersion));
|
|
37
36
|
function testDoc(doc, fromVersion) {
|
|
38
37
|
try {
|
package/dist/cjs/schema/types.js
CHANGED
|
@@ -15,8 +15,7 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.isNodeOfType =
|
|
18
|
+
exports.isNodeOfType = isNodeOfType;
|
|
19
19
|
function isNodeOfType(node, type) {
|
|
20
20
|
return node.type === type;
|
|
21
21
|
}
|
|
22
|
-
exports.isNodeOfType = isNodeOfType;
|
package/dist/cjs/version.js
CHANGED
|
@@ -21,13 +21,12 @@ import { buildCiteprocCitation } from '../../lib/citeproc';
|
|
|
21
21
|
import { CreditRoleUrls } from '../../lib/credit-roles';
|
|
22
22
|
import { generateFootnoteLabels } from '../../lib/footnotes';
|
|
23
23
|
import { nodeFromHTML } from '../../lib/html';
|
|
24
|
+
import { XLINK_NAMESPACE, XML_NAMESPACE } from '../../lib/xml';
|
|
24
25
|
import { isBibliographyItemNode, isCitationNode, isNodeOfType, schema, } from '../../schema';
|
|
25
26
|
import { isExecutableNodeType, isNodeType } from '../../transformer';
|
|
26
27
|
import { initJats, jatsVariableWrapper } from './citeproc';
|
|
27
28
|
import { selectVersionIds } from './jats-versions';
|
|
28
29
|
import { buildTargets } from './labels';
|
|
29
|
-
const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
|
|
30
|
-
const XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
|
|
31
30
|
const normalizeID = (id) => id.replace(/:/g, '_');
|
|
32
31
|
const parser = ProsemirrorDOMParser.fromSchema(schema);
|
|
33
32
|
const insertAbstractNode = (front, abstractNode) => {
|
|
@@ -102,6 +101,7 @@ export class JATSExporter {
|
|
|
102
101
|
const front = this.buildFront(options.journal);
|
|
103
102
|
article.appendChild(front);
|
|
104
103
|
article.setAttribute('article-type', manuscriptNode.attrs.articleType || 'other');
|
|
104
|
+
article.setAttributeNS(XML_NAMESPACE, 'lang', manuscriptNode.attrs.primaryLanguageCode || 'en');
|
|
105
105
|
this.labelTargets = buildTargets(manuscriptNode);
|
|
106
106
|
this.footnoteLabels = generateFootnoteLabels(manuscriptNode);
|
|
107
107
|
const body = this.buildBody();
|
|
@@ -16,12 +16,12 @@
|
|
|
16
16
|
import { buildContribution, ObjectTypes } from '@manuscripts/json-schema';
|
|
17
17
|
import { DOMParser, Fragment } from 'prosemirror-model';
|
|
18
18
|
import { dateToTimestamp, getCreditRole, getHTMLContent, getTrimmedTextContent, } from '../../lib/utils';
|
|
19
|
+
import { XLINK_NAMESPACE, XML_NAMESPACE } from '../../lib/xml';
|
|
19
20
|
import { DEFAULT_PROFILE_ID } from './jats-comments';
|
|
20
21
|
export class JATSDOMParser {
|
|
21
22
|
constructor(sectionCategories, schema) {
|
|
22
23
|
this.sectionCategories = sectionCategories;
|
|
23
24
|
this.schema = schema;
|
|
24
|
-
this.XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
|
|
25
25
|
this.parsePriority = (priority) => {
|
|
26
26
|
if (!priority) {
|
|
27
27
|
return undefined;
|
|
@@ -89,7 +89,7 @@ export class JATSDOMParser {
|
|
|
89
89
|
const email = element.querySelector('email');
|
|
90
90
|
if (email) {
|
|
91
91
|
return {
|
|
92
|
-
href: email.getAttributeNS(
|
|
92
|
+
href: email.getAttributeNS(XLINK_NAMESPACE, 'href') ?? '',
|
|
93
93
|
text: getTrimmedTextContent(email) ?? '',
|
|
94
94
|
};
|
|
95
95
|
}
|
|
@@ -103,8 +103,8 @@ export class JATSDOMParser {
|
|
|
103
103
|
type: parentElement?.getAttribute('fig-type') ??
|
|
104
104
|
element.getAttribute('content-type') ??
|
|
105
105
|
'',
|
|
106
|
-
src: element.getAttributeNS(
|
|
107
|
-
extLink: extLink?.getAttributeNS(
|
|
106
|
+
src: element.getAttributeNS(XLINK_NAMESPACE, 'href'),
|
|
107
|
+
extLink: extLink?.getAttributeNS(XLINK_NAMESPACE, 'href'),
|
|
108
108
|
};
|
|
109
109
|
};
|
|
110
110
|
this.getInstitutionDetails = (element) => {
|
|
@@ -217,7 +217,7 @@ export class JATSDOMParser {
|
|
|
217
217
|
const element = node;
|
|
218
218
|
return {
|
|
219
219
|
id: element.getAttribute('id'),
|
|
220
|
-
href: element.getAttributeNS(
|
|
220
|
+
href: element.getAttributeNS(XLINK_NAMESPACE, 'href') || '',
|
|
221
221
|
type: element.getAttribute('content-type') || '',
|
|
222
222
|
};
|
|
223
223
|
},
|
|
@@ -233,7 +233,7 @@ export class JATSDOMParser {
|
|
|
233
233
|
return {
|
|
234
234
|
doi: getTrimmedTextContent(doi),
|
|
235
235
|
articleType: element.getAttribute('article-type') || '',
|
|
236
|
-
primaryLanguageCode: element.
|
|
236
|
+
primaryLanguageCode: element.getAttributeNS(XML_NAMESPACE, 'lang'),
|
|
237
237
|
...dates,
|
|
238
238
|
};
|
|
239
239
|
},
|
|
@@ -573,8 +573,8 @@ export class JATSDOMParser {
|
|
|
573
573
|
getAttrs: (node) => {
|
|
574
574
|
const element = node;
|
|
575
575
|
return {
|
|
576
|
-
href: element.getAttributeNS(
|
|
577
|
-
title: element.getAttributeNS(
|
|
576
|
+
href: element.getAttributeNS(XLINK_NAMESPACE, 'href') || '',
|
|
577
|
+
title: element.getAttributeNS(XLINK_NAMESPACE, 'title') || '',
|
|
578
578
|
};
|
|
579
579
|
},
|
|
580
580
|
},
|
|
@@ -595,7 +595,7 @@ export class JATSDOMParser {
|
|
|
595
595
|
const element = node;
|
|
596
596
|
return {
|
|
597
597
|
id: element.getAttribute('id'),
|
|
598
|
-
href: element.getAttributeNS(
|
|
598
|
+
href: element.getAttributeNS(XLINK_NAMESPACE, 'href'),
|
|
599
599
|
mimetype: element.getAttribute('mimetype'),
|
|
600
600
|
mimeSubtype: element.getAttribute('mime-subtype'),
|
|
601
601
|
};
|
|
@@ -770,7 +770,7 @@ export class JATSDOMParser {
|
|
|
770
770
|
const element = node;
|
|
771
771
|
return {
|
|
772
772
|
id: element.getAttribute('id'),
|
|
773
|
-
href: element.getAttributeNS(
|
|
773
|
+
href: element.getAttributeNS(XLINK_NAMESPACE, 'href'),
|
|
774
774
|
mimeType: element.getAttribute('mimetype'),
|
|
775
775
|
mimeSubType: element.getAttribute('mime-subtype'),
|
|
776
776
|
title: getTrimmedTextContent(element, 'title'),
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* © 2025 Atypon Systems LLC
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
|
|
17
|
+
export const XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
|
package/dist/es/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "4.2.
|
|
1
|
+
export const VERSION = "4.2.12";
|
|
@@ -18,7 +18,7 @@ import { ManuscriptNode } from '../../schema';
|
|
|
18
18
|
export declare const createNodeFromJATS: (fileName: string) => Promise<{
|
|
19
19
|
node: import("../../schema").ActualManuscriptNode;
|
|
20
20
|
journal: {
|
|
21
|
-
objectType: import("@manuscripts/json-schema
|
|
21
|
+
objectType: import("@manuscripts/json-schema").ObjectTypes;
|
|
22
22
|
abbreviatedTitles: import("../importer/jats-journal-meta-parser").AbbreviatedTitle[];
|
|
23
23
|
journalIdentifiers: import("../importer/jats-journal-meta-parser").JournalIdentifier[];
|
|
24
24
|
ISSNs: import("../importer/jats-journal-meta-parser").ISSN[];
|
|
@@ -18,7 +18,6 @@ import { SectionCategory } from '../../schema';
|
|
|
18
18
|
export declare class JATSDOMParser {
|
|
19
19
|
private sectionCategories;
|
|
20
20
|
private schema;
|
|
21
|
-
private XLINK_NAMESPACE;
|
|
22
21
|
private parser;
|
|
23
22
|
constructor(sectionCategories: SectionCategory[], schema: Schema);
|
|
24
23
|
parse(doc: Node, options?: ParseOptions): import("prosemirror-model").Node;
|
|
@@ -15,4 +15,4 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { ManuscriptNode } from '../../schema';
|
|
17
17
|
export declare const updateDocumentIDs: (node: ManuscriptNode) => string[];
|
|
18
|
-
export declare const htmlFromJatsNode: (element: Element | undefined | null, createElement?: (
|
|
18
|
+
export declare const htmlFromJatsNode: (element: Element | undefined | null, createElement?: (tagName: string) => HTMLElement) => string | undefined;
|
|
@@ -17,7 +17,7 @@ import { ActualManuscriptNode, SectionCategory } from '../../schema';
|
|
|
17
17
|
export declare const parseJATSArticle: (doc: Document, sectionCategories: SectionCategory[], template?: string) => {
|
|
18
18
|
node: ActualManuscriptNode;
|
|
19
19
|
journal: {
|
|
20
|
-
objectType: import("@manuscripts/json-schema
|
|
20
|
+
objectType: import("@manuscripts/json-schema").ObjectTypes;
|
|
21
21
|
abbreviatedTitles: import("./jats-journal-meta-parser").AbbreviatedTitle[];
|
|
22
22
|
journalIdentifiers: import("./jats-journal-meta-parser").JournalIdentifier[];
|
|
23
23
|
ISSNs: import("./jats-journal-meta-parser").ISSN[];
|
package/dist/types/lib/html.d.ts
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* © 2025 Atypon Systems LLC
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export declare const XLINK_NAMESPACE = "http://www.w3.org/1999/xlink";
|
|
17
|
+
export declare const XML_NAMESPACE = "http://www.w3.org/XML/1998/namespace";
|
|
@@ -32,4 +32,4 @@ export interface ManuscriptAttrs {
|
|
|
32
32
|
receiveDate?: number;
|
|
33
33
|
}
|
|
34
34
|
export declare const manuscript: NodeSpec;
|
|
35
|
-
export declare const isManuscriptNode: (node: ManuscriptNode) => node is
|
|
35
|
+
export declare const isManuscriptNode: (node: ManuscriptNode) => node is ManuscriptNode;
|
|
@@ -19,4 +19,4 @@ export declare const nodeTypesMap: Map<ManuscriptNodeType, ObjectTypes>;
|
|
|
19
19
|
export declare const isExecutableNodeType: (type: ManuscriptNodeType) => boolean;
|
|
20
20
|
export declare const isElementNodeType: (type: ManuscriptNodeType) => boolean;
|
|
21
21
|
export declare const isSectionNodeType: (type: ManuscriptNodeType) => boolean;
|
|
22
|
-
export declare const isNodeType: <T extends
|
|
22
|
+
export declare const isNodeType: <T extends ManuscriptNode>(node: ManuscriptNode, type: Nodes) => node is T;
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "4.2.
|
|
1
|
+
export declare const VERSION = "4.2.12";
|
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.
|
|
4
|
+
"version": "4.2.12",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-transform",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"@babel/preset-typescript": "7.23.3",
|
|
47
47
|
"@jats4r/dtds": "0.0.10",
|
|
48
48
|
"@manuscripts/eslint-config": "0.5.1",
|
|
49
|
-
"@types/jest": "
|
|
49
|
+
"@types/jest": "30.0.0",
|
|
50
50
|
"@types/lodash": "4.17.16",
|
|
51
51
|
"@types/mime": "3.0.4",
|
|
52
52
|
"@types/node": "20.17.46",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"@types/w3c-xmlserializer": "2.0.4",
|
|
56
56
|
"@typescript-eslint/eslint-plugin": "5.62.0",
|
|
57
57
|
"@typescript-eslint/parser": "5.62.0",
|
|
58
|
-
"babel-jest": "
|
|
58
|
+
"babel-jest": "30.0.5",
|
|
59
59
|
"eslint": "8.57.1",
|
|
60
60
|
"eslint-config-prettier": "8.10.0",
|
|
61
61
|
"eslint-plugin-header": "3.1.1",
|
|
@@ -70,8 +70,8 @@
|
|
|
70
70
|
"eslint-plugin-react-hooks": "4.6.2",
|
|
71
71
|
"eslint-plugin-simple-import-sort": "8.0.0",
|
|
72
72
|
"husky": "8.0.3",
|
|
73
|
-
"jest": "
|
|
74
|
-
"jest-environment-jsdom": "
|
|
73
|
+
"jest": "30.0.5",
|
|
74
|
+
"jest-environment-jsdom": "30.0.5",
|
|
75
75
|
"libxmljs2": "0.35.0",
|
|
76
76
|
"migration-base": "npm:@manuscripts/transform@2.3.20",
|
|
77
77
|
"npm-run-all": "4.1.5",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"prosemirror-state": "1.4.3",
|
|
80
80
|
"prosemirror-view": "1.39.2",
|
|
81
81
|
"rimraf": "6.0.1",
|
|
82
|
-
"typescript": "
|
|
82
|
+
"typescript": "5.9.2"
|
|
83
83
|
},
|
|
84
84
|
"engines": {
|
|
85
85
|
"node": ">=20.16.0"
|