@manuscripts/transform 3.0.21-LEAN-4076.1 → 3.0.21
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/index.js +1 -2
- package/dist/cjs/jats/exporter/jats-exporter.js +7 -7
- package/dist/cjs/jats/importer/jats-dom-parser.js +972 -948
- package/dist/cjs/jats/importer/jats-transformations.js +9 -14
- package/dist/cjs/jats/importer/parse-jats-article.js +7 -5
- package/dist/cjs/lib/{section-group-type.js → section-categories.js} +4 -14
- package/dist/cjs/schema/index.js +0 -2
- package/dist/cjs/schema/migration/migration-scripts/3.0.21.js +25 -0
- package/dist/cjs/schema/migration/migration-scripts/index.js +2 -0
- package/dist/cjs/transformer/index.js +0 -1
- package/dist/cjs/version.js +1 -1
- package/dist/es/index.js +1 -2
- package/dist/es/jats/exporter/jats-exporter.js +8 -8
- package/dist/es/jats/importer/jats-dom-parser.js +970 -947
- package/dist/es/jats/importer/jats-transformations.js +9 -14
- package/dist/es/jats/importer/parse-jats-article.js +8 -6
- package/dist/es/lib/{section-group-type.js → section-categories.js} +2 -13
- package/dist/es/schema/index.js +0 -2
- package/dist/es/schema/migration/migration-scripts/3.0.21.js +23 -0
- package/dist/es/schema/migration/migration-scripts/index.js +2 -0
- package/dist/es/transformer/index.js +0 -1
- package/dist/es/version.js +1 -1
- package/dist/types/index.d.ts +1 -2
- package/dist/types/jats/importer/jats-dom-parser.d.ts +24 -9
- package/dist/types/jats/importer/jats-transformations.d.ts +2 -1
- package/dist/types/jats/importer/parse-jats-article.d.ts +2 -2
- package/dist/types/lib/{section-group-type.d.ts → section-categories.d.ts} +3 -9
- package/dist/types/schema/index.d.ts +0 -2
- package/dist/types/schema/migration/migration-scripts/3.0.21.d.ts +9 -0
- package/dist/types/schema/migration/migration-scripts/index.d.ts +2 -1
- package/dist/types/schema/types.d.ts +21 -1
- package/dist/types/transformer/index.d.ts +0 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -1
- package/dist/cjs/lib/table-cell-styles.js +0 -52
- package/dist/cjs/transformer/section-category.js +0 -263
- package/dist/es/lib/table-cell-styles.js +0 -47
- package/dist/es/transformer/section-category.js +0 -249
- package/dist/types/lib/table-cell-styles.d.ts +0 -27
- package/dist/types/transformer/section-category.d.ts +0 -31
|
@@ -17,17 +17,12 @@
|
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.fixTables = exports.orderTableFootnote = exports.moveReferencesToBackmatter = exports.createSupplementaryMaterialsSection = exports.createKeywordsSection = exports.moveCaptionsToEnd = exports.createBackmatter = exports.createAbstracts = exports.createBody = exports.createBoxedElementSection = exports.moveAbstracts = exports.moveAffiliations = exports.moveContributors = exports.moveAwards = exports.moveAuthorNotes = exports.moveTitle = void 0;
|
|
19
19
|
const deafults_1 = require("../../lib/deafults");
|
|
20
|
-
const section_group_type_1 = require("../../lib/section-group-type");
|
|
21
|
-
const transformer_1 = require("../../transformer");
|
|
22
20
|
const jats_parser_utils_1 = require("./jats-parser-utils");
|
|
23
21
|
const removeNodeFromParent = (node) => node.parentNode && node.parentNode.removeChild(node);
|
|
24
22
|
const capitalizeFirstLetter = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
|
25
23
|
const createSectionGroup = (type, createElement) => {
|
|
26
24
|
const sec = createElement('sec');
|
|
27
|
-
sec.setAttribute('sec-type', type
|
|
28
|
-
const title = createElement('title');
|
|
29
|
-
title.textContent = type.title;
|
|
30
|
-
sec.appendChild(title);
|
|
25
|
+
sec.setAttribute('sec-type', type);
|
|
31
26
|
return sec;
|
|
32
27
|
};
|
|
33
28
|
const moveTitle = (front, createElement) => {
|
|
@@ -115,7 +110,7 @@ const createBoxedElementSection = (body, createElement) => {
|
|
|
115
110
|
};
|
|
116
111
|
exports.createBoxedElementSection = createBoxedElementSection;
|
|
117
112
|
const createBody = (doc, body, createElement) => {
|
|
118
|
-
const group = createSectionGroup(
|
|
113
|
+
const group = createSectionGroup('body', createElement);
|
|
119
114
|
const paragraphs = doc.querySelectorAll('body > p');
|
|
120
115
|
group.append(...paragraphs);
|
|
121
116
|
const sections = doc.querySelectorAll('body > sec:not([sec-type="backmatter"]), body > sec:not([sec-type])');
|
|
@@ -128,16 +123,16 @@ const createBody = (doc, body, createElement) => {
|
|
|
128
123
|
};
|
|
129
124
|
exports.createBody = createBody;
|
|
130
125
|
const createAbstracts = (doc, body, createElement) => {
|
|
131
|
-
const group = createSectionGroup(
|
|
126
|
+
const group = createSectionGroup('abstracts', createElement);
|
|
132
127
|
(0, exports.moveAbstracts)(doc, group, createElement);
|
|
133
128
|
body.insertBefore(group, body.lastElementChild);
|
|
134
129
|
};
|
|
135
130
|
exports.createAbstracts = createAbstracts;
|
|
136
|
-
const createBackmatter = (doc, body, createElement) => {
|
|
137
|
-
const group = createSectionGroup(
|
|
131
|
+
const createBackmatter = (doc, body, sectionCategories, createElement) => {
|
|
132
|
+
const group = createSectionGroup('backmatter', createElement);
|
|
138
133
|
moveBackSections(doc, group);
|
|
139
134
|
moveAppendices(doc, group, createElement);
|
|
140
|
-
moveSpecialFootnotes(doc, group, createElement);
|
|
135
|
+
moveSpecialFootnotes(doc, group, sectionCategories, createElement);
|
|
141
136
|
moveFootnotes(doc, group, createElement);
|
|
142
137
|
moveAcknowledgments(doc, group, createElement);
|
|
143
138
|
body.append(group);
|
|
@@ -162,12 +157,12 @@ const moveFootnotes = (doc, group, createElement) => {
|
|
|
162
157
|
group.insertBefore(section, ((_a = group.firstChild) === null || _a === void 0 ? void 0 : _a.nextSibling) || group.firstChild);
|
|
163
158
|
}
|
|
164
159
|
};
|
|
165
|
-
const moveSpecialFootnotes = (doc, group, createElement) => {
|
|
160
|
+
const moveSpecialFootnotes = (doc, group, sectionCategories, createElement) => {
|
|
166
161
|
var _a;
|
|
167
162
|
const fns = [...doc.querySelectorAll('fn[fn-type]')];
|
|
168
163
|
for (const fn of fns) {
|
|
169
164
|
const type = fn.getAttribute('fn-type') || '';
|
|
170
|
-
const category = (
|
|
165
|
+
const category = sectionCategories.find((category) => category.synonyms.includes(type));
|
|
171
166
|
if (category) {
|
|
172
167
|
const section = createElement('sec');
|
|
173
168
|
const fnTitle = fn.querySelector('p[content-type="fn-title"]');
|
|
@@ -182,7 +177,7 @@ const moveSpecialFootnotes = (doc, group, createElement) => {
|
|
|
182
177
|
}
|
|
183
178
|
section.append(...fn.children);
|
|
184
179
|
removeNodeFromParent(fn);
|
|
185
|
-
section.setAttribute('sec-type',
|
|
180
|
+
section.setAttribute('sec-type', category.id);
|
|
186
181
|
group.append(section);
|
|
187
182
|
}
|
|
188
183
|
}
|
|
@@ -16,12 +16,13 @@
|
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.parseJATSArticle = void 0;
|
|
19
|
+
const schema_1 = require("../../schema");
|
|
19
20
|
const jats_comments_1 = require("./jats-comments");
|
|
20
21
|
const jats_dom_parser_1 = require("./jats-dom-parser");
|
|
21
22
|
const jats_journal_meta_parser_1 = require("./jats-journal-meta-parser");
|
|
22
23
|
const jats_parser_utils_1 = require("./jats-parser-utils");
|
|
23
24
|
const jats_transformations_1 = require("./jats-transformations");
|
|
24
|
-
const processJATS = (doc) => {
|
|
25
|
+
const processJATS = (doc, sectionCategories) => {
|
|
25
26
|
const createElement = createElementFn(doc);
|
|
26
27
|
(0, jats_comments_1.markComments)(doc);
|
|
27
28
|
const front = doc.querySelector('front');
|
|
@@ -41,7 +42,7 @@ const processJATS = (doc) => {
|
|
|
41
42
|
(0, jats_transformations_1.createBoxedElementSection)(body, createElement);
|
|
42
43
|
(0, jats_transformations_1.createBody)(doc, body, createElement);
|
|
43
44
|
(0, jats_transformations_1.createAbstracts)(doc, body, createElement);
|
|
44
|
-
(0, jats_transformations_1.createBackmatter)(doc, body, createElement);
|
|
45
|
+
(0, jats_transformations_1.createBackmatter)(doc, body, sectionCategories, createElement);
|
|
45
46
|
(0, jats_transformations_1.createSupplementaryMaterialsSection)(doc, body, createElement);
|
|
46
47
|
(0, jats_transformations_1.createKeywordsSection)(doc, body, createElement);
|
|
47
48
|
(0, jats_transformations_1.fixTables)(doc, body, createElement);
|
|
@@ -53,10 +54,11 @@ const processJATS = (doc) => {
|
|
|
53
54
|
(0, jats_transformations_1.moveReferencesToBackmatter)(body, back, createElement);
|
|
54
55
|
};
|
|
55
56
|
const createElementFn = (doc) => (tagName) => doc.createElement(tagName);
|
|
56
|
-
const parseJATSArticle = (doc, template) => {
|
|
57
|
+
const parseJATSArticle = (doc, sectionCategories, template) => {
|
|
57
58
|
const journal = (0, jats_journal_meta_parser_1.parseJournal)(doc);
|
|
58
|
-
processJATS(doc);
|
|
59
|
-
const node = jats_dom_parser_1.
|
|
59
|
+
processJATS(doc, sectionCategories);
|
|
60
|
+
const node = new jats_dom_parser_1.JATSDOMParser(sectionCategories, schema_1.schema).parse(doc)
|
|
61
|
+
.firstChild;
|
|
60
62
|
if (!node) {
|
|
61
63
|
throw new Error('No content was parsed from the JATS article body');
|
|
62
64
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*!
|
|
3
|
-
* ©
|
|
3
|
+
* © 2024 Atypon Systems LLC
|
|
4
4
|
*
|
|
5
5
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
6
|
* you may not use this file except in compliance with the License.
|
|
@@ -15,16 +15,6 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
title: 'Abstracts',
|
|
22
|
-
};
|
|
23
|
-
exports.bodyType = {
|
|
24
|
-
_id: 'body',
|
|
25
|
-
title: 'Body',
|
|
26
|
-
};
|
|
27
|
-
exports.backmatterType = {
|
|
28
|
-
_id: 'backmatter',
|
|
29
|
-
title: 'Backmatter',
|
|
30
|
-
};
|
|
18
|
+
exports.getGroupCateogries = void 0;
|
|
19
|
+
const getGroupCateogries = (sectionsMap, group) => Array.from(sectionsMap.values()).filter((section) => section.group === group);
|
|
20
|
+
exports.getGroupCateogries = getGroupCateogries;
|
package/dist/cjs/schema/index.js
CHANGED
|
@@ -154,8 +154,6 @@ __exportStar(require("./nodes/supplement"), exports);
|
|
|
154
154
|
__exportStar(require("./nodes/supplements"), exports);
|
|
155
155
|
__exportStar(require("./nodes/corresp"), exports);
|
|
156
156
|
__exportStar(require("./nodes/author_notes"), exports);
|
|
157
|
-
__exportStar(require("./nodes/award"), exports);
|
|
158
|
-
__exportStar(require("./nodes/awards"), exports);
|
|
159
157
|
exports.schema = new prosemirror_model_1.Schema({
|
|
160
158
|
marks: {
|
|
161
159
|
bold: marks_1.bold,
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class Migration3021 {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.fromVersion = '3.0.20';
|
|
6
|
+
this.toVersion = '3.0.21';
|
|
7
|
+
this.suffixMap = new Map([
|
|
8
|
+
['competing-interests', 'coi-statement'],
|
|
9
|
+
['acknowledgement', 'acknowledgements'],
|
|
10
|
+
['introduction', 'intro'],
|
|
11
|
+
['materials-method', 'methods'],
|
|
12
|
+
['subsection', ''],
|
|
13
|
+
]);
|
|
14
|
+
}
|
|
15
|
+
migrateNode(node) {
|
|
16
|
+
if (node.type === 'section' &&
|
|
17
|
+
node.attrs.category.startsWith('MPSectionCategory:')) {
|
|
18
|
+
const [, suffix] = node.attrs.category.split(':', 2);
|
|
19
|
+
const newCategory = this.suffixMap.get(suffix) || suffix;
|
|
20
|
+
return Object.assign(Object.assign({}, node), { attrs: Object.assign(Object.assign({}, node.attrs), { category: newCategory }) });
|
|
21
|
+
}
|
|
22
|
+
return node;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.default = Migration3021;
|
|
@@ -21,9 +21,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
21
21
|
const _1_2_5_1 = __importDefault(require("./1.2.5"));
|
|
22
22
|
const _2_3_22_1 = __importDefault(require("./2.3.22"));
|
|
23
23
|
const _3_0_12_1 = require("./3.0.12");
|
|
24
|
+
const _3_0_21_1 = __importDefault(require("./3.0.21"));
|
|
24
25
|
const migrations = [
|
|
25
26
|
new _1_2_5_1.default(),
|
|
26
27
|
new _2_3_22_1.default(),
|
|
27
28
|
new _3_0_12_1.Migration3012(),
|
|
29
|
+
new _3_0_21_1.default(),
|
|
28
30
|
];
|
|
29
31
|
exports.default = migrations;
|
package/dist/cjs/version.js
CHANGED
package/dist/es/index.js
CHANGED
|
@@ -2,10 +2,9 @@ export * from './errors';
|
|
|
2
2
|
export { getVersion } from './getVersion';
|
|
3
3
|
export * from './jats';
|
|
4
4
|
export * from './jats/types';
|
|
5
|
-
export * from './lib/section-group-type';
|
|
6
|
-
export * from './lib/table-cell-styles';
|
|
7
5
|
export * from './lib/footnotes';
|
|
8
6
|
export * from './lib/utils';
|
|
7
|
+
export * from './lib/section-categories';
|
|
9
8
|
export * from './schema';
|
|
10
9
|
export { migrateFor } from './schema/migration/migrate';
|
|
11
10
|
export { isSectionLabelNode } from './schema/nodes/section_label';
|
|
@@ -22,7 +22,7 @@ import serializeToXML from 'w3c-xmlserializer';
|
|
|
22
22
|
import { generateFootnoteLabels } from '../../lib/footnotes';
|
|
23
23
|
import { nodeFromHTML, textFromHTML } from '../../lib/html';
|
|
24
24
|
import { isCitationNode, schema, } from '../../schema';
|
|
25
|
-
import {
|
|
25
|
+
import { isExecutableNodeType, isNodeType } from '../../transformer';
|
|
26
26
|
import { selectVersionIds } from './jats-versions';
|
|
27
27
|
import { buildTargets } from './labels';
|
|
28
28
|
const warn = debug('manuscripts-transform');
|
|
@@ -776,7 +776,7 @@ export class JATSExporter {
|
|
|
776
776
|
id: normalizeID(node.attrs.id),
|
|
777
777
|
};
|
|
778
778
|
if (node.attrs.category) {
|
|
779
|
-
attrs['sec-type'] =
|
|
779
|
+
attrs['sec-type'] = node.attrs.category;
|
|
780
780
|
}
|
|
781
781
|
return ['sec', attrs, 0];
|
|
782
782
|
},
|
|
@@ -1229,7 +1229,7 @@ export class JATSExporter {
|
|
|
1229
1229
|
break;
|
|
1230
1230
|
}
|
|
1231
1231
|
case 'table': {
|
|
1232
|
-
this.fixTable(childNode
|
|
1232
|
+
this.fixTable(childNode);
|
|
1233
1233
|
break;
|
|
1234
1234
|
}
|
|
1235
1235
|
}
|
|
@@ -1250,7 +1250,7 @@ export class JATSExporter {
|
|
|
1250
1250
|
node.replaceWith(clone);
|
|
1251
1251
|
return clone;
|
|
1252
1252
|
};
|
|
1253
|
-
this.fixTable = (table
|
|
1253
|
+
this.fixTable = (table) => {
|
|
1254
1254
|
let tbody;
|
|
1255
1255
|
Array.from(table.childNodes).forEach((child) => {
|
|
1256
1256
|
if (child instanceof Element && child.tagName.toLowerCase() === 'tbody') {
|
|
@@ -1377,7 +1377,7 @@ export class JATSExporter {
|
|
|
1377
1377
|
if (availabilitySection) {
|
|
1378
1378
|
back.insertBefore(availabilitySection, back.firstChild);
|
|
1379
1379
|
}
|
|
1380
|
-
const section = body.querySelector('sec[sec-type="
|
|
1380
|
+
const section = body.querySelector('sec[sec-type="acknowledgements"]');
|
|
1381
1381
|
if (section) {
|
|
1382
1382
|
const ack = this.document.createElement('ack');
|
|
1383
1383
|
while (section.firstChild) {
|
|
@@ -1414,7 +1414,7 @@ export class JATSExporter {
|
|
|
1414
1414
|
'supported-by',
|
|
1415
1415
|
'financial-disclosure',
|
|
1416
1416
|
'ethics-statement',
|
|
1417
|
-
'
|
|
1417
|
+
'coi-statement',
|
|
1418
1418
|
];
|
|
1419
1419
|
const sections = body.querySelectorAll('sec');
|
|
1420
1420
|
for (const currentSection of sections) {
|
|
@@ -1565,7 +1565,7 @@ export class JATSExporter {
|
|
|
1565
1565
|
const fnGroups = back.querySelectorAll('fn-group');
|
|
1566
1566
|
fnGroups.forEach((fnGroup) => {
|
|
1567
1567
|
if (fnGroup) {
|
|
1568
|
-
const coiStatement = fnGroup.querySelector('fn[fn-type="
|
|
1568
|
+
const coiStatement = fnGroup.querySelector('fn[fn-type="coi-statement"]');
|
|
1569
1569
|
if (coiStatement) {
|
|
1570
1570
|
const authorNotes = this.document.createElement('author-notes');
|
|
1571
1571
|
authorNotes.append(coiStatement);
|
|
@@ -1607,7 +1607,7 @@ export class JATSExporter {
|
|
|
1607
1607
|
footnotes.forEach((fn) => {
|
|
1608
1608
|
const fnType = fn.getAttribute('fn-type');
|
|
1609
1609
|
if (fnType) {
|
|
1610
|
-
fn.setAttribute('fn-type',
|
|
1610
|
+
fn.setAttribute('fn-type', fnType);
|
|
1611
1611
|
}
|
|
1612
1612
|
});
|
|
1613
1613
|
}
|