@manuscripts/transform 4.3.22 → 4.3.24
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 -279
- 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/jats-transformations.js +10 -0
- 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 -279
- 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/jats-transformations.js +10 -0
- 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
|
@@ -1,43 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
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
|
-
})();
|
|
35
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
const prevPackage = __importStar(require("migration-base"));
|
|
37
3
|
const migrate_1 = require("../migration/migrate");
|
|
4
|
+
const docs_1 = require("./docs");
|
|
38
5
|
describe('Prosemirror migration schema', () => {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
expect(() => (0, migrate_1.migrateFor)(oldDoc, prevPackage.getVersion())).not.toThrow();
|
|
6
|
+
test('Migrating doc from version 2.3.20 to the current', () => {
|
|
7
|
+
expect(() => (0, migrate_1.migrateFor)(docs_1.v2_3_20, '2.3.20')).not.toThrow();
|
|
42
8
|
});
|
|
43
9
|
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class Migration4312 {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.fromVersion = '4.3.11';
|
|
6
|
+
this.toVersion = '4.3.12';
|
|
7
|
+
}
|
|
8
|
+
migrateNode(node) {
|
|
9
|
+
if (node.type === 'contributor') {
|
|
10
|
+
if (node.attrs.affiliations) {
|
|
11
|
+
node.attrs.affiliationIDs = node.attrs.affiliations;
|
|
12
|
+
delete node.attrs.affiliations;
|
|
13
|
+
}
|
|
14
|
+
if (Array.isArray(node.attrs.corresp)) {
|
|
15
|
+
node.attrs.correspIDs = node.attrs.corresp.map((c) => c.correspID);
|
|
16
|
+
delete node.attrs.corresp;
|
|
17
|
+
}
|
|
18
|
+
if (Array.isArray(node.attrs.footnote)) {
|
|
19
|
+
node.attrs.footnoteIDs = node.attrs.footnote.map((f) => f.noteID);
|
|
20
|
+
delete node.attrs.footnote;
|
|
21
|
+
}
|
|
22
|
+
node.attrs.given = node.attrs.bibliographicName.given;
|
|
23
|
+
node.attrs.family = node.attrs.bibliographicName.family;
|
|
24
|
+
node.attrs.suffix = node.attrs.bibliographicName.suffix;
|
|
25
|
+
node.attrs.ORCID = node.attrs.ORCIDIdentifier;
|
|
26
|
+
delete node.attrs.bibliographicName;
|
|
27
|
+
delete node.attrs.userID;
|
|
28
|
+
delete node.attrs.ORCIDIdentifier;
|
|
29
|
+
}
|
|
30
|
+
if (node.type === 'comment') {
|
|
31
|
+
const contribution = node.attrs.contributions[0];
|
|
32
|
+
node.attrs.userID = contribution.profileID;
|
|
33
|
+
node.attrs.timestamp = contribution.timestamp;
|
|
34
|
+
delete node.attrs.contributions;
|
|
35
|
+
}
|
|
36
|
+
return node;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.default = Migration4312;
|
|
@@ -29,6 +29,7 @@ const _3_0_55_1 = __importDefault(require("./3.0.55"));
|
|
|
29
29
|
const _3_0_56_1 = __importDefault(require("./3.0.56"));
|
|
30
30
|
const _4_2_13_1 = __importDefault(require("./4.2.13"));
|
|
31
31
|
const _4_2_15_1 = __importDefault(require("./4.2.15"));
|
|
32
|
+
const _4_3_12_1 = __importDefault(require("./4.3.12"));
|
|
32
33
|
const migrations = [
|
|
33
34
|
new _1_2_5_1.default(),
|
|
34
35
|
new _2_3_22_1.default(),
|
|
@@ -41,5 +42,6 @@ const migrations = [
|
|
|
41
42
|
new _3_0_56_1.default(),
|
|
42
43
|
new _4_2_13_1.default(),
|
|
43
44
|
new _4_2_15_1.default(),
|
|
45
|
+
new _4_3_12_1.default(),
|
|
44
46
|
];
|
|
45
47
|
exports.default = migrations;
|
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.isBlockquoteElement = exports.blockquoteElement = void 0;
|
|
19
|
-
const json_schema_1 = require("@manuscripts/json-schema");
|
|
20
19
|
exports.blockquoteElement = {
|
|
21
20
|
content: 'paragraph+ attribution',
|
|
22
21
|
attrs: {
|
|
@@ -48,7 +47,6 @@ exports.blockquoteElement = {
|
|
|
48
47
|
if (blockquoteElementNode.attrs.id) {
|
|
49
48
|
attrs.id = blockquoteElementNode.attrs.id;
|
|
50
49
|
}
|
|
51
|
-
attrs['data-object-type'] = json_schema_1.ObjectTypes.QuoteElement;
|
|
52
50
|
if (blockquoteElementNode.attrs.placeholder) {
|
|
53
51
|
attrs['data-placeholder-text'] = blockquoteElementNode.attrs.placeholder;
|
|
54
52
|
}
|
|
@@ -7,21 +7,21 @@ exports.contributor = {
|
|
|
7
7
|
attrs: {
|
|
8
8
|
id: { default: '' },
|
|
9
9
|
role: { default: '' },
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
10
|
+
correspIDs: { default: [] },
|
|
11
|
+
affiliationIDs: { default: [] },
|
|
12
|
+
footnoteIDs: { default: [] },
|
|
13
|
+
given: { default: undefined },
|
|
14
|
+
family: { default: undefined },
|
|
15
|
+
prefix: { default: undefined },
|
|
16
|
+
suffix: { default: undefined },
|
|
17
|
+
email: { default: undefined },
|
|
18
|
+
ORCID: { default: undefined },
|
|
19
|
+
isCorresponding: { default: false },
|
|
20
|
+
isJointContributor: { default: false },
|
|
20
21
|
priority: { default: undefined },
|
|
21
22
|
creditRoles: { default: [] },
|
|
22
23
|
dataTracked: { default: null },
|
|
23
24
|
contents: { default: '' },
|
|
24
|
-
prefix: { default: '' },
|
|
25
25
|
},
|
|
26
26
|
group: 'block',
|
|
27
27
|
toDOM: (node) => {
|
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.equation = void 0;
|
|
19
|
-
const json_schema_1 = require("@manuscripts/json-schema");
|
|
20
19
|
exports.equation = {
|
|
21
20
|
attrs: {
|
|
22
21
|
id: { default: '' },
|
|
@@ -27,7 +26,7 @@ exports.equation = {
|
|
|
27
26
|
group: 'block',
|
|
28
27
|
parseDOM: [
|
|
29
28
|
{
|
|
30
|
-
tag: `div
|
|
29
|
+
tag: `div.MPEquation`,
|
|
31
30
|
getAttrs: (p) => {
|
|
32
31
|
const htmlEl = p;
|
|
33
32
|
return {
|
|
@@ -42,7 +41,6 @@ exports.equation = {
|
|
|
42
41
|
const equationNode = node;
|
|
43
42
|
const { id, contents, format } = equationNode.attrs;
|
|
44
43
|
const dom = document.createElement('div');
|
|
45
|
-
dom.classList.add(json_schema_1.ObjectTypes.Equation);
|
|
46
44
|
dom.setAttribute('id', id);
|
|
47
45
|
if (format) {
|
|
48
46
|
dom.setAttribute('data-equation-format', format);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isListNode = exports.listItem = exports.list = void 0;
|
|
4
|
-
const json_schema_1 = require("@manuscripts/json-schema");
|
|
5
4
|
exports.list = {
|
|
6
5
|
content: 'list_item+',
|
|
7
6
|
group: 'block list element',
|
|
@@ -39,7 +38,6 @@ exports.list = {
|
|
|
39
38
|
{
|
|
40
39
|
id: list.attrs.id,
|
|
41
40
|
'list-type': list.attrs.listStyleType,
|
|
42
|
-
'data-object-type': json_schema_1.ObjectTypes.ListElement,
|
|
43
41
|
},
|
|
44
42
|
0,
|
|
45
43
|
];
|
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.isListingNode = exports.listing = void 0;
|
|
19
|
-
const json_schema_1 = require("@manuscripts/json-schema");
|
|
20
19
|
exports.listing = {
|
|
21
20
|
attrs: {
|
|
22
21
|
id: { default: '' },
|
|
@@ -32,7 +31,7 @@ exports.listing = {
|
|
|
32
31
|
group: 'block',
|
|
33
32
|
parseDOM: [
|
|
34
33
|
{
|
|
35
|
-
tag:
|
|
34
|
+
tag: 'pre.MPListing',
|
|
36
35
|
preserveWhitespace: 'full',
|
|
37
36
|
getAttrs: (p) => {
|
|
38
37
|
const node = p;
|
|
@@ -61,7 +60,6 @@ exports.listing = {
|
|
|
61
60
|
const listingNode = node;
|
|
62
61
|
const dom = document.createElement('div');
|
|
63
62
|
dom.setAttribute('id', listingNode.attrs.id);
|
|
64
|
-
dom.classList.add(json_schema_1.ObjectTypes.Listing);
|
|
65
63
|
dom.setAttribute('data-language', listingNode.attrs.language);
|
|
66
64
|
dom.setAttribute('data-languageKey', listingNode.attrs.languageKey);
|
|
67
65
|
dom.textContent = listingNode.attrs.contents;
|
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.isParagraphNode = exports.paragraph = void 0;
|
|
19
|
-
const json_schema_1 = require("@manuscripts/json-schema");
|
|
20
19
|
exports.paragraph = {
|
|
21
20
|
content: 'inline*',
|
|
22
21
|
attrs: {
|
|
@@ -48,7 +47,6 @@ exports.paragraph = {
|
|
|
48
47
|
if (paragraphNode.attrs.id) {
|
|
49
48
|
attrs.id = paragraphNode.attrs.id;
|
|
50
49
|
}
|
|
51
|
-
attrs['data-object-type'] = json_schema_1.ObjectTypes.ParagraphElement;
|
|
52
50
|
if (paragraphNode.attrs.placeholder) {
|
|
53
51
|
attrs['data-placeholder-text'] = paragraphNode.attrs.placeholder;
|
|
54
52
|
}
|
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.isPullquoteElement = exports.pullquoteElement = void 0;
|
|
19
|
-
const json_schema_1 = require("@manuscripts/json-schema");
|
|
20
19
|
exports.pullquoteElement = {
|
|
21
20
|
content: 'quote_image? paragraph+ attribution',
|
|
22
21
|
attrs: {
|
|
@@ -49,7 +48,6 @@ exports.pullquoteElement = {
|
|
|
49
48
|
attrs.id = pullquoteElementNode.attrs.id;
|
|
50
49
|
}
|
|
51
50
|
attrs.class = 'pullquote';
|
|
52
|
-
attrs['data-object-type'] = json_schema_1.ObjectTypes.QuoteElement;
|
|
53
51
|
if (pullquoteElementNode.attrs.placeholder) {
|
|
54
52
|
attrs['data-placeholder-text'] = pullquoteElementNode.attrs.placeholder;
|
|
55
53
|
}
|
|
@@ -17,18 +17,6 @@
|
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.generateNodeID = void 0;
|
|
19
19
|
const uuid_1 = require("uuid");
|
|
20
|
-
const
|
|
21
|
-
const generateNodeID = (type) => {
|
|
22
|
-
const uniqueID = ':' + (0, uuid_1.v4)().toUpperCase();
|
|
23
|
-
let name = node_types_1.nodeTypesMap.get(type);
|
|
24
|
-
if (name === undefined) {
|
|
25
|
-
name =
|
|
26
|
-
'MP' +
|
|
27
|
-
type.name
|
|
28
|
-
.split('_')
|
|
29
|
-
.map((w) => w.charAt(0).toUpperCase() + w.slice(1))
|
|
30
|
-
.join('');
|
|
31
|
-
}
|
|
32
|
-
return name + uniqueID;
|
|
33
|
-
};
|
|
20
|
+
const node_names_1 = require("./node-names");
|
|
21
|
+
const generateNodeID = (type) => `MP${(0, node_names_1.typeName)(type)}:${(0, uuid_1.v4)()}`;
|
|
34
22
|
exports.generateNodeID = generateNodeID;
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.nodeNames = void 0;
|
|
18
|
+
exports.typeName = exports.nodeNames = void 0;
|
|
19
19
|
const schema_1 = require("../schema");
|
|
20
20
|
exports.nodeNames = new Map([
|
|
21
21
|
[schema_1.schema.nodes.title, 'Title'],
|
|
@@ -65,3 +65,8 @@ exports.nodeNames = new Map([
|
|
|
65
65
|
[schema_1.schema.nodes.supplements, 'Supplements'],
|
|
66
66
|
[schema_1.schema.nodes.attachments, 'Main Document'],
|
|
67
67
|
]);
|
|
68
|
+
const typeName = (type) => type.name
|
|
69
|
+
.split('_')
|
|
70
|
+
.map((w) => w.charAt(0).toUpperCase() + w.slice(1))
|
|
71
|
+
.join('');
|
|
72
|
+
exports.typeName = typeName;
|
|
@@ -15,54 +15,8 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.isNodeType = exports.isSectionNodeType = exports.isElementNodeType = exports.isExecutableNodeType =
|
|
19
|
-
const json_schema_1 = require("@manuscripts/json-schema");
|
|
18
|
+
exports.isNodeType = exports.isSectionNodeType = exports.isElementNodeType = exports.isExecutableNodeType = void 0;
|
|
20
19
|
const schema_1 = require("../schema");
|
|
21
|
-
exports.nodeTypesMap = new Map([
|
|
22
|
-
[schema_1.schema.nodes.abstracts, json_schema_1.ObjectTypes.Section],
|
|
23
|
-
[schema_1.schema.nodes.body, json_schema_1.ObjectTypes.Section],
|
|
24
|
-
[schema_1.schema.nodes.backmatter, json_schema_1.ObjectTypes.Section],
|
|
25
|
-
[schema_1.schema.nodes.comment, json_schema_1.ObjectTypes.CommentAnnotation],
|
|
26
|
-
[schema_1.schema.nodes.bibliography_item, json_schema_1.ObjectTypes.BibliographyItem],
|
|
27
|
-
[schema_1.schema.nodes.bibliography_element, json_schema_1.ObjectTypes.BibliographyElement],
|
|
28
|
-
[schema_1.schema.nodes.bibliography_section, json_schema_1.ObjectTypes.Section],
|
|
29
|
-
[schema_1.schema.nodes.blockquote_element, json_schema_1.ObjectTypes.QuoteElement],
|
|
30
|
-
[schema_1.schema.nodes.list, json_schema_1.ObjectTypes.ListElement],
|
|
31
|
-
[schema_1.schema.nodes.citation, json_schema_1.ObjectTypes.Citation],
|
|
32
|
-
[schema_1.schema.nodes.equation, json_schema_1.ObjectTypes.Equation],
|
|
33
|
-
[schema_1.schema.nodes.equation_element, json_schema_1.ObjectTypes.EquationElement],
|
|
34
|
-
[schema_1.schema.nodes.figure, json_schema_1.ObjectTypes.Figure],
|
|
35
|
-
[schema_1.schema.nodes.missing_figure, json_schema_1.ObjectTypes.MissingFigure],
|
|
36
|
-
[schema_1.schema.nodes.figure_element, json_schema_1.ObjectTypes.FigureElement],
|
|
37
|
-
[schema_1.schema.nodes.footnote, json_schema_1.ObjectTypes.Footnote],
|
|
38
|
-
[schema_1.schema.nodes.footnotes_element, json_schema_1.ObjectTypes.FootnotesElement],
|
|
39
|
-
[schema_1.schema.nodes.footnotes_section, json_schema_1.ObjectTypes.Section],
|
|
40
|
-
[schema_1.schema.nodes.graphical_abstract_section, json_schema_1.ObjectTypes.Section],
|
|
41
|
-
[schema_1.schema.nodes.trans_graphical_abstract, json_schema_1.ObjectTypes.Section],
|
|
42
|
-
[schema_1.schema.nodes.highlight_marker, json_schema_1.ObjectTypes.HighlightMarker],
|
|
43
|
-
[schema_1.schema.nodes.keyword, json_schema_1.ObjectTypes.Keyword],
|
|
44
|
-
[schema_1.schema.nodes.keywords_element, json_schema_1.ObjectTypes.KeywordsElement],
|
|
45
|
-
[schema_1.schema.nodes.keywords, json_schema_1.ObjectTypes.Section],
|
|
46
|
-
[schema_1.schema.nodes.keyword_group, json_schema_1.ObjectTypes.KeywordGroup],
|
|
47
|
-
[schema_1.schema.nodes.listing, json_schema_1.ObjectTypes.Listing],
|
|
48
|
-
[schema_1.schema.nodes.listing_element, json_schema_1.ObjectTypes.ListingElement],
|
|
49
|
-
[schema_1.schema.nodes.manuscript, json_schema_1.ObjectTypes.Manuscript],
|
|
50
|
-
[schema_1.schema.nodes.paragraph, json_schema_1.ObjectTypes.ParagraphElement],
|
|
51
|
-
[schema_1.schema.nodes.pullquote_element, json_schema_1.ObjectTypes.QuoteElement],
|
|
52
|
-
[schema_1.schema.nodes.section, json_schema_1.ObjectTypes.Section],
|
|
53
|
-
[schema_1.schema.nodes.table, json_schema_1.ObjectTypes.Table],
|
|
54
|
-
[schema_1.schema.nodes.table_element, json_schema_1.ObjectTypes.TableElement],
|
|
55
|
-
[schema_1.schema.nodes.affiliation, json_schema_1.ObjectTypes.Affiliation],
|
|
56
|
-
[schema_1.schema.nodes.contributor, json_schema_1.ObjectTypes.Contributor],
|
|
57
|
-
[schema_1.schema.nodes.table_element_footer, json_schema_1.ObjectTypes.TableElementFooter],
|
|
58
|
-
[schema_1.schema.nodes.contributors, json_schema_1.ObjectTypes.Section],
|
|
59
|
-
[schema_1.schema.nodes.affiliations, json_schema_1.ObjectTypes.Section],
|
|
60
|
-
[schema_1.schema.nodes.title, json_schema_1.ObjectTypes.Titles],
|
|
61
|
-
[schema_1.schema.nodes.supplement, json_schema_1.ObjectTypes.Supplement],
|
|
62
|
-
[schema_1.schema.nodes.author_notes, json_schema_1.ObjectTypes.AuthorNotes],
|
|
63
|
-
[schema_1.schema.nodes.corresp, json_schema_1.ObjectTypes.Corresponding],
|
|
64
|
-
[schema_1.schema.nodes.box_element, json_schema_1.ObjectTypes.Section],
|
|
65
|
-
]);
|
|
66
20
|
const isExecutableNodeType = (type) => (0, schema_1.hasGroup)(type, schema_1.GROUP_EXECUTABLE);
|
|
67
21
|
exports.isExecutableNodeType = isExecutableNodeType;
|
|
68
22
|
const isElementNodeType = (type) => (0, schema_1.hasGroup)(type, schema_1.GROUP_ELEMENT);
|
package/dist/cjs/version.js
CHANGED
|
@@ -29,17 +29,16 @@ describe('JATS exporter', () => {
|
|
|
29
29
|
test('export latest version', async () => {
|
|
30
30
|
const transformer = new JATSExporter();
|
|
31
31
|
const input = await readAndParseFixture('jats-example-full.xml');
|
|
32
|
-
const
|
|
32
|
+
const node = parseJATSArticle(input, sectionCategories);
|
|
33
33
|
const result = await transformer.serializeToJATS(node, {
|
|
34
34
|
csl: DEFAULT_CSL_OPTIONS,
|
|
35
|
-
journal,
|
|
36
35
|
});
|
|
37
36
|
expect(result).toMatchSnapshot('jats-export');
|
|
38
37
|
});
|
|
39
38
|
test('export with & and < in bibliography metadata', async () => {
|
|
40
39
|
const transformer = new JATSExporter();
|
|
41
40
|
const input = await readAndParseFixture('jats-example-full.xml');
|
|
42
|
-
const
|
|
41
|
+
const node = parseJATSArticle(input, sectionCategories);
|
|
43
42
|
let biblio = null;
|
|
44
43
|
node.descendants((n) => {
|
|
45
44
|
if (isBibliographyItemNode(n)) {
|
|
@@ -49,17 +48,15 @@ describe('JATS exporter', () => {
|
|
|
49
48
|
biblio.attrs.title += ' & Sons 55 < 135';
|
|
50
49
|
const result = await transformer.serializeToJATS(node, {
|
|
51
50
|
csl: DEFAULT_CSL_OPTIONS,
|
|
52
|
-
journal,
|
|
53
51
|
});
|
|
54
52
|
expect(result).toMatchSnapshot('jats-export-with-xml-unsafe-in-biblios');
|
|
55
53
|
});
|
|
56
54
|
test('export v1.1', async () => {
|
|
57
55
|
const transformer = new JATSExporter();
|
|
58
56
|
const input = await readAndParseFixture('jats-example-full.xml');
|
|
59
|
-
const
|
|
57
|
+
const node = parseJATSArticle(input, sectionCategories);
|
|
60
58
|
const result = await transformer.serializeToJATS(node, {
|
|
61
59
|
csl: DEFAULT_CSL_OPTIONS,
|
|
62
|
-
journal,
|
|
63
60
|
version: '1.1',
|
|
64
61
|
});
|
|
65
62
|
expect(result).toMatchSnapshot('jats-export-1.1');
|
|
@@ -67,11 +64,10 @@ describe('JATS exporter', () => {
|
|
|
67
64
|
test('export unknown version', async () => {
|
|
68
65
|
const transformer = new JATSExporter();
|
|
69
66
|
const input = await readAndParseFixture('jats-example-full.xml');
|
|
70
|
-
const
|
|
67
|
+
const node = parseJATSArticle(input, sectionCategories);
|
|
71
68
|
await expect(async () => {
|
|
72
69
|
await transformer.serializeToJATS(node, {
|
|
73
70
|
csl: DEFAULT_CSL_OPTIONS,
|
|
74
|
-
journal,
|
|
75
71
|
version: '1.0',
|
|
76
72
|
});
|
|
77
73
|
}).rejects.toThrow(Error);
|
|
@@ -79,10 +75,9 @@ describe('JATS exporter', () => {
|
|
|
79
75
|
test('export table-wrap-foot', async () => {
|
|
80
76
|
const transformer = new JATSExporter();
|
|
81
77
|
const input = await readAndParseFixture('jats-tables-example.xml');
|
|
82
|
-
const
|
|
78
|
+
const node = parseJATSArticle(input, sectionCategories);
|
|
83
79
|
const xml = await transformer.serializeToJATS(node, {
|
|
84
80
|
csl: DEFAULT_CSL_OPTIONS,
|
|
85
|
-
journal,
|
|
86
81
|
});
|
|
87
82
|
const resultDoc = parseXMLWithDTD(xml);
|
|
88
83
|
const tableWrapFoot = resultDoc.get('//table-wrap/table-wrap-foot');
|
|
@@ -90,36 +85,12 @@ describe('JATS exporter', () => {
|
|
|
90
85
|
expect(paragraph).not.toBeUndefined();
|
|
91
86
|
expect(tableWrapFoot).not.toBeUndefined();
|
|
92
87
|
});
|
|
93
|
-
test('add journal ID', async () => {
|
|
94
|
-
const transformer = new JATSExporter();
|
|
95
|
-
const input = await readAndParseFixture('jats-example-full.xml');
|
|
96
|
-
const { node, journal } = parseJATSArticle(input, sectionCategories);
|
|
97
|
-
const xml = await transformer.serializeToJATS(node, {
|
|
98
|
-
csl: DEFAULT_CSL_OPTIONS,
|
|
99
|
-
journal,
|
|
100
|
-
});
|
|
101
|
-
expect(xml).toMatchSnapshot('jats-export-submitted');
|
|
102
|
-
});
|
|
103
|
-
test('journal metadata', async () => {
|
|
104
|
-
const transformer = new JATSExporter();
|
|
105
|
-
const input = await readAndParseFixture('jats-import.xml');
|
|
106
|
-
const { node, journal } = parseJATSArticle(input, sectionCategories);
|
|
107
|
-
const xml = await transformer.serializeToJATS(node, {
|
|
108
|
-
csl: DEFAULT_CSL_OPTIONS,
|
|
109
|
-
journal,
|
|
110
|
-
});
|
|
111
|
-
const output = parseXMLWithDTD(xml);
|
|
112
|
-
expect(output.errors).toHaveLength(0);
|
|
113
|
-
expect(output.get('//journal-title').text()).toBe('Brain and Behavior');
|
|
114
|
-
expect(output.get('//issn').text()).toBe('2162-3279');
|
|
115
|
-
});
|
|
116
88
|
test('DTD validation', async () => {
|
|
117
89
|
const transformer = new JATSExporter();
|
|
118
90
|
const input = await readAndParseFixture('jats-import.xml');
|
|
119
|
-
const
|
|
91
|
+
const node = parseJATSArticle(input, sectionCategories);
|
|
120
92
|
const xml = await transformer.serializeToJATS(node, {
|
|
121
93
|
csl: DEFAULT_CSL_OPTIONS,
|
|
122
|
-
journal,
|
|
123
94
|
});
|
|
124
95
|
const { errors } = parseXMLWithDTD(xml);
|
|
125
96
|
expect(errors).toHaveLength(0);
|
|
@@ -127,10 +98,9 @@ describe('JATS exporter', () => {
|
|
|
127
98
|
test('DTD validation: article with title markup and citations', async () => {
|
|
128
99
|
const transformer = new JATSExporter();
|
|
129
100
|
const input = await readAndParseFixture('jats-document.xml');
|
|
130
|
-
const
|
|
101
|
+
const node = parseJATSArticle(input, sectionCategories);
|
|
131
102
|
const xml = await transformer.serializeToJATS(node, {
|
|
132
103
|
csl: DEFAULT_CSL_OPTIONS,
|
|
133
|
-
journal,
|
|
134
104
|
});
|
|
135
105
|
const { errors } = parseXMLWithDTD(xml);
|
|
136
106
|
expect(errors).toHaveLength(0);
|
|
@@ -138,10 +108,9 @@ describe('JATS exporter', () => {
|
|
|
138
108
|
test('Export link', async () => {
|
|
139
109
|
const transformer = new JATSExporter();
|
|
140
110
|
const input = await readAndParseFixture('jats-import.xml');
|
|
141
|
-
const
|
|
111
|
+
const node = parseJATSArticle(input, sectionCategories);
|
|
142
112
|
const xml = await transformer.serializeToJATS(node, {
|
|
143
113
|
csl: DEFAULT_CSL_OPTIONS,
|
|
144
|
-
journal,
|
|
145
114
|
});
|
|
146
115
|
const output = parseXMLWithDTD(xml);
|
|
147
116
|
const link = output.get('//ext-link[@ext-link-type="uri"]');
|
|
@@ -157,10 +126,9 @@ describe('JATS exporter', () => {
|
|
|
157
126
|
test('DTD validation for MathML representation', async () => {
|
|
158
127
|
const transformer = new JATSExporter();
|
|
159
128
|
const input = await readAndParseFixture('jats-example-doc.xml');
|
|
160
|
-
const
|
|
129
|
+
const node = parseJATSArticle(input, sectionCategories);
|
|
161
130
|
const xml = await transformer.serializeToJATS(node, {
|
|
162
131
|
csl: DEFAULT_CSL_OPTIONS,
|
|
163
|
-
journal,
|
|
164
132
|
});
|
|
165
133
|
const { errors } = parseXMLWithDTD(xml);
|
|
166
134
|
expect(errors).toHaveLength(0);
|
|
@@ -168,10 +136,9 @@ describe('JATS exporter', () => {
|
|
|
168
136
|
test('export with supplement', async () => {
|
|
169
137
|
const transformer = new JATSExporter();
|
|
170
138
|
const input = await readAndParseFixture('jats-import.xml');
|
|
171
|
-
const
|
|
139
|
+
const node = parseJATSArticle(input, sectionCategories);
|
|
172
140
|
const xml = await transformer.serializeToJATS(node, {
|
|
173
141
|
csl: DEFAULT_CSL_OPTIONS,
|
|
174
|
-
journal,
|
|
175
142
|
});
|
|
176
143
|
const resultDoc = parseXMLWithDTD(xml);
|
|
177
144
|
const supplementaryMaterial = resultDoc.get('//supplementary-material');
|
|
@@ -190,10 +157,9 @@ describe('JATS exporter', () => {
|
|
|
190
157
|
test('export footnotes', async () => {
|
|
191
158
|
const transformer = new JATSExporter();
|
|
192
159
|
const input = await readAndParseFixture('jats-fn-group.xml');
|
|
193
|
-
const
|
|
160
|
+
const node = parseJATSArticle(input, sectionCategories);
|
|
194
161
|
const xml = await transformer.serializeToJATS(node, {
|
|
195
162
|
csl: DEFAULT_CSL_OPTIONS,
|
|
196
|
-
journal,
|
|
197
163
|
});
|
|
198
164
|
const footnoteCategories = [
|
|
199
165
|
'con',
|