@manuscripts/transform 2.1.1-LEAN-3352-0 → 2.1.1-LEAN-3377-0
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/importer/jats-body-transformations.js +10 -0
- package/dist/cjs/jats/importer/jats-front-parser.js +0 -5
- package/dist/cjs/jats/importer/parse-jats-article.js +2 -2
- package/dist/cjs/jats/jats-exporter.js +2 -2
- package/dist/es/jats/importer/jats-body-transformations.js +10 -0
- package/dist/es/jats/importer/jats-front-parser.js +0 -5
- package/dist/es/jats/importer/parse-jats-article.js +2 -2
- package/dist/es/jats/jats-exporter.js +2 -2
- package/dist/types/jats/importer/jats-body-transformations.d.ts +1 -0
- package/dist/types/jats/importer/jats-front-parser.d.ts +0 -1
- package/package.json +2 -2
|
@@ -265,6 +265,16 @@ exports.jatsBodyTransformations = {
|
|
|
265
265
|
}
|
|
266
266
|
});
|
|
267
267
|
},
|
|
268
|
+
orderTableFootnote(doc, body) {
|
|
269
|
+
const tableInlineFootnotesIds = new Set(Array.from(body.querySelectorAll('tbody > tr > td > xref[ref-type="fn"]').values()).map((inlineFootnote) => inlineFootnote.getAttribute('rid')));
|
|
270
|
+
const fnGroups = doc.querySelectorAll('table-wrap-foot > fn-group');
|
|
271
|
+
fnGroups.forEach((fnGroup) => {
|
|
272
|
+
const orderedFootnotes = Array.from(fnGroup.querySelectorAll('fn')).sort((fn) => tableInlineFootnotesIds.has(fn.getAttribute('id'))
|
|
273
|
+
? -1
|
|
274
|
+
: 0);
|
|
275
|
+
fnGroup.replaceChildren(...orderedFootnotes);
|
|
276
|
+
});
|
|
277
|
+
},
|
|
268
278
|
moveFloatsGroupToBody(doc, body, createElement) {
|
|
269
279
|
const group = doc.querySelector('floats-group');
|
|
270
280
|
if (group) {
|
|
@@ -45,11 +45,6 @@ exports.jatsFrontParser = {
|
|
|
45
45
|
}
|
|
46
46
|
return titles;
|
|
47
47
|
},
|
|
48
|
-
parseDOI(front) {
|
|
49
|
-
var _a;
|
|
50
|
-
const doi = front === null || front === void 0 ? void 0 : front.querySelector('article-meta > article-id[pub-id-type="doi"]');
|
|
51
|
-
return (_a = doi === null || doi === void 0 ? void 0 : doi.textContent) !== null && _a !== void 0 ? _a : undefined;
|
|
52
|
-
},
|
|
53
48
|
parseCounts(counts) {
|
|
54
49
|
var _a, _b, _c, _d, _e;
|
|
55
50
|
if (counts) {
|
|
@@ -31,7 +31,6 @@ const parseJATSFront = (doc, front) => {
|
|
|
31
31
|
const createElement = createElementFn(doc);
|
|
32
32
|
const journal = jats_front_parser_1.jatsFrontParser.parseJournal(front.querySelector('journal-meta'));
|
|
33
33
|
const titles = jats_front_parser_1.jatsFrontParser.parseTitles(front.querySelector('article-meta > title-group'), createElement);
|
|
34
|
-
const DOI = jats_front_parser_1.jatsFrontParser.parseDOI(front);
|
|
35
34
|
const { affiliations, affiliationIDs } = jats_front_parser_1.jatsFrontParser.parseAffiliations([
|
|
36
35
|
...front.querySelectorAll('article-meta > contrib-group > aff'),
|
|
37
36
|
]);
|
|
@@ -46,7 +45,7 @@ const parseJATSFront = (doc, front) => {
|
|
|
46
45
|
], affiliationIDs, footnoteIDs, correspondingIDs);
|
|
47
46
|
const history = jats_front_parser_1.jatsFrontParser.parseDates(front.querySelector('article-meta > history'));
|
|
48
47
|
const counts = jats_front_parser_1.jatsFrontParser.parseCounts(front.querySelector('article-meta counts'));
|
|
49
|
-
const manuscript = Object.assign(Object.assign(Object.assign(
|
|
48
|
+
const manuscript = Object.assign(Object.assign(Object.assign({}, (0, builders_1.buildManuscript)()), counts), history);
|
|
50
49
|
return generateIDs([
|
|
51
50
|
manuscript,
|
|
52
51
|
titles,
|
|
@@ -68,6 +67,7 @@ const parseJATSBody = (doc, body, references) => {
|
|
|
68
67
|
jats_body_transformations_1.jatsBodyTransformations.createBackmatter(doc, body, createElement);
|
|
69
68
|
jats_body_transformations_1.jatsBodyTransformations.createSuppleMaterials(doc, body, createElement);
|
|
70
69
|
jats_body_transformations_1.jatsBodyTransformations.createKeywords(doc, body, createElement);
|
|
70
|
+
jats_body_transformations_1.jatsBodyTransformations.orderTableFootnote(doc, body);
|
|
71
71
|
const node = jats_body_dom_parser_1.jatsBodyDOMParser.parse(body).firstChild;
|
|
72
72
|
if (!node) {
|
|
73
73
|
throw new Error('No content was parsed from the JATS article body');
|
|
@@ -311,10 +311,10 @@ class JATSExporter {
|
|
|
311
311
|
articleID.textContent = id;
|
|
312
312
|
articleMeta.appendChild(articleID);
|
|
313
313
|
}
|
|
314
|
-
if (doi
|
|
314
|
+
if (doi) {
|
|
315
315
|
const articleID = this.document.createElement('article-id');
|
|
316
316
|
articleID.setAttribute('pub-id-type', 'doi');
|
|
317
|
-
articleID.textContent = doi
|
|
317
|
+
articleID.textContent = doi;
|
|
318
318
|
articleMeta.appendChild(articleID);
|
|
319
319
|
}
|
|
320
320
|
const titleGroup = this.document.createElement('title-group');
|
|
@@ -262,6 +262,16 @@ export const jatsBodyTransformations = {
|
|
|
262
262
|
}
|
|
263
263
|
});
|
|
264
264
|
},
|
|
265
|
+
orderTableFootnote(doc, body) {
|
|
266
|
+
const tableInlineFootnotesIds = new Set(Array.from(body.querySelectorAll('tbody > tr > td > xref[ref-type="fn"]').values()).map((inlineFootnote) => inlineFootnote.getAttribute('rid')));
|
|
267
|
+
const fnGroups = doc.querySelectorAll('table-wrap-foot > fn-group');
|
|
268
|
+
fnGroups.forEach((fnGroup) => {
|
|
269
|
+
const orderedFootnotes = Array.from(fnGroup.querySelectorAll('fn')).sort((fn) => tableInlineFootnotesIds.has(fn.getAttribute('id'))
|
|
270
|
+
? -1
|
|
271
|
+
: 0);
|
|
272
|
+
fnGroup.replaceChildren(...orderedFootnotes);
|
|
273
|
+
});
|
|
274
|
+
},
|
|
265
275
|
moveFloatsGroupToBody(doc, body, createElement) {
|
|
266
276
|
const group = doc.querySelector('floats-group');
|
|
267
277
|
if (group) {
|
|
@@ -39,11 +39,6 @@ export const jatsFrontParser = {
|
|
|
39
39
|
}
|
|
40
40
|
return titles;
|
|
41
41
|
},
|
|
42
|
-
parseDOI(front) {
|
|
43
|
-
var _a;
|
|
44
|
-
const doi = front === null || front === void 0 ? void 0 : front.querySelector('article-meta > article-id[pub-id-type="doi"]');
|
|
45
|
-
return (_a = doi === null || doi === void 0 ? void 0 : doi.textContent) !== null && _a !== void 0 ? _a : undefined;
|
|
46
|
-
},
|
|
47
42
|
parseCounts(counts) {
|
|
48
43
|
var _a, _b, _c, _d, _e;
|
|
49
44
|
if (counts) {
|
|
@@ -28,7 +28,6 @@ export const parseJATSFront = (doc, front) => {
|
|
|
28
28
|
const createElement = createElementFn(doc);
|
|
29
29
|
const journal = jatsFrontParser.parseJournal(front.querySelector('journal-meta'));
|
|
30
30
|
const titles = jatsFrontParser.parseTitles(front.querySelector('article-meta > title-group'), createElement);
|
|
31
|
-
const DOI = jatsFrontParser.parseDOI(front);
|
|
32
31
|
const { affiliations, affiliationIDs } = jatsFrontParser.parseAffiliations([
|
|
33
32
|
...front.querySelectorAll('article-meta > contrib-group > aff'),
|
|
34
33
|
]);
|
|
@@ -43,7 +42,7 @@ export const parseJATSFront = (doc, front) => {
|
|
|
43
42
|
], affiliationIDs, footnoteIDs, correspondingIDs);
|
|
44
43
|
const history = jatsFrontParser.parseDates(front.querySelector('article-meta > history'));
|
|
45
44
|
const counts = jatsFrontParser.parseCounts(front.querySelector('article-meta counts'));
|
|
46
|
-
const manuscript = Object.assign(Object.assign(Object.assign(
|
|
45
|
+
const manuscript = Object.assign(Object.assign(Object.assign({}, buildManuscript()), counts), history);
|
|
47
46
|
return generateIDs([
|
|
48
47
|
manuscript,
|
|
49
48
|
titles,
|
|
@@ -64,6 +63,7 @@ export const parseJATSBody = (doc, body, references) => {
|
|
|
64
63
|
jatsBodyTransformations.createBackmatter(doc, body, createElement);
|
|
65
64
|
jatsBodyTransformations.createSuppleMaterials(doc, body, createElement);
|
|
66
65
|
jatsBodyTransformations.createKeywords(doc, body, createElement);
|
|
66
|
+
jatsBodyTransformations.orderTableFootnote(doc, body);
|
|
67
67
|
const node = jatsBodyDOMParser.parse(body).firstChild;
|
|
68
68
|
if (!node) {
|
|
69
69
|
throw new Error('No content was parsed from the JATS article body');
|
|
@@ -303,10 +303,10 @@ export class JATSExporter {
|
|
|
303
303
|
articleID.textContent = id;
|
|
304
304
|
articleMeta.appendChild(articleID);
|
|
305
305
|
}
|
|
306
|
-
if (doi
|
|
306
|
+
if (doi) {
|
|
307
307
|
const articleID = this.document.createElement('article-id');
|
|
308
308
|
articleID.setAttribute('pub-id-type', 'doi');
|
|
309
|
-
articleID.textContent = doi
|
|
309
|
+
articleID.textContent = doi;
|
|
310
310
|
articleMeta.appendChild(articleID);
|
|
311
311
|
}
|
|
312
312
|
const titleGroup = this.document.createElement('title-group');
|
|
@@ -32,6 +32,7 @@ export declare const jatsBodyTransformations: {
|
|
|
32
32
|
moveFootnotes(doc: Document, group: Element, createElement: (tagName: string) => HTMLElement): void;
|
|
33
33
|
moveCaptionsToEnd(body: Element): void;
|
|
34
34
|
fixTables(body: Element, createElement: (tagName: string) => HTMLElement): void;
|
|
35
|
+
orderTableFootnote(doc: Document, body: Element): void;
|
|
35
36
|
moveFloatsGroupToBody(doc: Document, body: Element, createElement: (tagName: string) => HTMLElement): void;
|
|
36
37
|
createKeywords(document: Document, body: Element, createElement: (tagName: string) => HTMLElement): void;
|
|
37
38
|
createSuppleMaterials(document: Document, body: Element, createElement: (tagName: string) => HTMLElement): void;
|
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
*/
|
|
16
16
|
export declare const jatsFrontParser: {
|
|
17
17
|
parseTitles(element: Element | null, createElement: (tagName: string) => HTMLElement): import("../../transformer").Build<import("@manuscripts/json-schema/dist/types").Titles>;
|
|
18
|
-
parseDOI(front: Element | null): string | undefined;
|
|
19
18
|
parseCounts(counts: Element | null): {
|
|
20
19
|
wordCount: number | undefined;
|
|
21
20
|
figureCount: number | undefined;
|
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": "2.1.1-LEAN-
|
|
4
|
+
"version": "2.1.1-LEAN-3377-0",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-transform",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|
|
@@ -78,4 +78,4 @@
|
|
|
78
78
|
"rimraf": "^3.0.2",
|
|
79
79
|
"typescript": "^4.0.5"
|
|
80
80
|
}
|
|
81
|
-
}
|
|
81
|
+
}
|