@manuscripts/transform 2.3.38-LEAN-3911.0 → 2.4.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/__tests__/data/project-dump.json +825 -0
- package/dist/cjs/index.js +6 -6
- package/dist/cjs/jats/importer/index.js +22 -0
- package/dist/cjs/jats/importer/{jats-dom-parser.js → jats-body-dom-parser.js} +34 -273
- package/dist/cjs/jats/importer/jats-body-transformations.js +22 -74
- package/dist/cjs/jats/importer/jats-comments.js +104 -27
- package/dist/cjs/jats/importer/jats-front-parser.js +321 -0
- package/dist/cjs/jats/importer/jats-journal-meta-parser.js +1 -8
- package/dist/cjs/jats/importer/jats-parser-utils.js +5 -43
- package/dist/cjs/jats/importer/jats-reference-parser.js +23 -16
- package/dist/cjs/jats/importer/jats-references.js +18 -18
- package/dist/cjs/jats/importer/parse-jats-article.js +79 -40
- package/dist/cjs/jats/index.js +7 -7
- package/dist/cjs/jats/{exporter/jats-exporter.js → jats-exporter.js} +398 -264
- package/dist/cjs/jats/{exporter/jats-versions.js → jats-versions.js} +3 -1
- package/dist/cjs/lib/utils.js +1 -12
- package/dist/cjs/transformer/__tests__/__helpers__/doc.js +37 -0
- package/dist/cjs/transformer/builders.js +219 -0
- package/dist/cjs/transformer/decode.js +898 -0
- package/dist/cjs/transformer/document-object-types.js +31 -0
- package/dist/cjs/transformer/encode.js +674 -0
- package/dist/cjs/{jats/importer/create-article-node.js → transformer/filename.js} +9 -10
- package/dist/cjs/transformer/footnote-category.js +20 -0
- package/dist/cjs/transformer/footnotes-order.js +60 -0
- package/dist/cjs/transformer/highlight-markers.js +138 -0
- package/dist/cjs/transformer/html.js +400 -0
- package/dist/cjs/transformer/id.js +5 -10
- package/dist/cjs/transformer/index.js +18 -0
- package/dist/cjs/{jats/exporter → transformer}/labels.js +5 -4
- package/dist/cjs/transformer/manuscript-dependencies.js +21 -0
- package/dist/cjs/transformer/model-map.js +26 -0
- package/dist/cjs/{lib/deafults.js → transformer/models.js} +1 -3
- package/dist/cjs/transformer/node-names.js +1 -0
- package/dist/cjs/transformer/object-types.js +57 -0
- package/dist/cjs/transformer/project-bundle.js +94 -0
- package/dist/cjs/transformer/serializer.js +23 -0
- package/dist/cjs/transformer/timestamp.js +20 -0
- package/dist/cjs/transformer/update-identifiers.js +93 -0
- package/dist/cjs/version.js +1 -1
- package/dist/es/__tests__/data/project-dump.json +825 -0
- package/dist/es/index.js +5 -5
- package/dist/{types/jats/importer/create-article-node.d.ts → es/jats/importer/index.js} +2 -3
- package/dist/es/jats/importer/{jats-dom-parser.js → jats-body-dom-parser.js} +35 -274
- package/dist/es/jats/importer/jats-body-transformations.js +22 -74
- package/dist/es/jats/importer/jats-comments.js +101 -26
- package/dist/es/jats/importer/jats-front-parser.js +315 -0
- package/dist/es/jats/importer/jats-journal-meta-parser.js +0 -6
- package/dist/es/jats/importer/jats-parser-utils.js +6 -44
- package/dist/es/jats/importer/jats-reference-parser.js +23 -16
- package/dist/es/jats/importer/jats-references.js +18 -18
- package/dist/es/jats/importer/parse-jats-article.js +78 -41
- package/dist/es/jats/index.js +3 -5
- package/dist/es/jats/{exporter/jats-exporter.js → jats-exporter.js} +392 -258
- package/dist/es/jats/{exporter/jats-versions.js → jats-versions.js} +1 -0
- package/dist/es/lib/utils.js +0 -9
- package/dist/es/transformer/__tests__/__helpers__/doc.js +29 -0
- package/dist/es/transformer/builders.js +186 -0
- package/dist/es/transformer/decode.js +888 -0
- package/dist/es/transformer/document-object-types.js +28 -0
- package/dist/es/transformer/encode.js +664 -0
- package/dist/es/transformer/filename.js +23 -0
- package/dist/es/transformer/footnote-category.js +16 -0
- package/dist/es/transformer/footnotes-order.js +55 -0
- package/dist/es/transformer/highlight-markers.js +132 -0
- package/dist/es/transformer/html.js +393 -0
- package/dist/es/transformer/id.js +3 -8
- package/dist/es/transformer/index.js +16 -0
- package/dist/es/{jats/exporter → transformer}/labels.js +5 -4
- package/dist/es/transformer/manuscript-dependencies.js +17 -0
- package/dist/es/transformer/model-map.js +22 -0
- package/dist/es/{lib/deafults.js → transformer/models.js} +2 -2
- package/dist/es/transformer/node-names.js +1 -0
- package/dist/es/transformer/object-types.js +52 -0
- package/dist/es/transformer/project-bundle.js +85 -0
- package/dist/es/transformer/serializer.js +17 -0
- package/dist/es/transformer/timestamp.js +16 -0
- package/dist/es/transformer/update-identifiers.js +87 -0
- package/dist/es/version.js +1 -1
- package/dist/types/index.d.ts +6 -6
- package/dist/types/jats/importer/index.d.ts +16 -0
- package/dist/types/jats/importer/{jats-dom-parser.d.ts → jats-body-dom-parser.d.ts} +1 -1
- package/dist/types/jats/importer/jats-body-transformations.d.ts +1 -5
- package/dist/types/jats/importer/jats-comments.d.ts +10 -4
- package/dist/types/jats/importer/jats-front-parser.d.ts +84 -0
- package/dist/types/jats/importer/jats-journal-meta-parser.d.ts +0 -10
- package/dist/types/jats/importer/jats-references.d.ts +8 -19
- package/dist/types/jats/importer/parse-jats-article.d.ts +5 -12
- package/dist/types/jats/index.d.ts +3 -5
- package/dist/types/jats/{exporter/jats-exporter.d.ts → jats-exporter.d.ts} +29 -15
- package/dist/types/jats/{exporter/jats-versions.d.ts → jats-versions.d.ts} +1 -0
- package/dist/types/lib/utils.d.ts +0 -2
- package/dist/types/schema/nodes/bibliography_item.d.ts +3 -3
- package/dist/types/schema/nodes/contributor.d.ts +0 -10
- package/dist/types/schema/nodes/keyword_group.d.ts +0 -1
- package/dist/types/schema/nodes/manuscript.d.ts +7 -8
- package/dist/types/schema/nodes/title.d.ts +3 -0
- package/dist/types/transformer/__tests__/__helpers__/doc.d.ts +18 -0
- package/dist/types/transformer/builders.d.ts +61 -0
- package/dist/types/transformer/decode.d.ts +52 -0
- package/dist/types/transformer/document-object-types.d.ts +17 -0
- package/dist/types/transformer/encode.d.ts +29 -0
- package/dist/types/transformer/filename.d.ts +16 -0
- package/dist/types/transformer/footnote-category.d.ts +17 -0
- package/dist/{es/jats/importer/create-article-node.js → types/transformer/footnotes-order.d.ts} +8 -10
- package/dist/types/transformer/highlight-markers.d.ts +31 -0
- package/dist/types/transformer/html.d.ts +36 -0
- package/dist/types/transformer/id.d.ts +2 -5
- package/dist/types/transformer/index.d.ts +16 -0
- package/dist/types/{jats/exporter → transformer}/labels.d.ts +2 -2
- package/dist/types/transformer/manuscript-dependencies.d.ts +4 -0
- package/dist/types/transformer/model-map.d.ts +19 -0
- package/dist/types/transformer/models.d.ts +48 -0
- package/dist/types/transformer/object-types.d.ts +30 -0
- package/dist/types/transformer/project-bundle.d.ts +30 -0
- package/dist/types/transformer/serializer.d.ts +19 -0
- package/dist/types/{lib/deafults.d.ts → transformer/timestamp.d.ts} +2 -2
- package/dist/types/transformer/update-identifiers.d.ts +23 -0
- package/dist/types/types.d.ts +2 -0
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -2
- package/dist/cjs/jats/importer/jats-front-transformations.js +0 -79
- package/dist/es/jats/importer/jats-front-transformations.js +0 -76
- package/dist/types/jats/importer/jats-front-transformations.d.ts +0 -22
- package/dist/types/jats/types.d.ts +0 -1
- /package/dist/cjs/{jats/types.js → types.js} +0 -0
- /package/dist/es/{jats/types.js → types.js} +0 -0
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.
|
|
19
|
-
const
|
|
18
|
+
exports.createReferenceComments = exports.createComments = exports.markComments = exports.parseJATSComment = exports.isJATSComment = void 0;
|
|
19
|
+
const uuid_1 = require("uuid");
|
|
20
20
|
const transformer_1 = require("../../transformer");
|
|
21
|
-
|
|
21
|
+
const DEFAULT_PROFILE_ID = 'MPUserProfile:0000000000000000000000000000000000000001';
|
|
22
22
|
const isJATSComment = (node) => {
|
|
23
23
|
return (node.nodeType === node.PROCESSING_INSTRUCTION_NODE &&
|
|
24
24
|
node.nodeName === 'AuthorQuery');
|
|
@@ -27,34 +27,35 @@ exports.isJATSComment = isJATSComment;
|
|
|
27
27
|
const parseJATSComment = (node) => {
|
|
28
28
|
const text = node.textContent;
|
|
29
29
|
if (text) {
|
|
30
|
+
const id = /id="(.+)"/.exec(text);
|
|
30
31
|
const queryText = /queryText="(.+)"/.exec(text);
|
|
31
|
-
if (queryText) {
|
|
32
|
-
const parentNode = node.parentNode;
|
|
33
|
-
const index = parentNode.outerHTML.indexOf(queryText[1]);
|
|
32
|
+
if (id && queryText) {
|
|
34
33
|
return {
|
|
35
|
-
id:
|
|
34
|
+
id: id[1],
|
|
36
35
|
text: queryText[1],
|
|
37
|
-
index,
|
|
38
36
|
};
|
|
39
37
|
}
|
|
40
38
|
}
|
|
41
39
|
};
|
|
42
40
|
exports.parseJATSComment = parseJATSComment;
|
|
43
41
|
const markComments = (doc) => {
|
|
44
|
-
|
|
42
|
+
const marks = [];
|
|
45
43
|
const root = doc.getRootNode();
|
|
46
44
|
const queue = [root];
|
|
47
|
-
const commentsElement = doc.createElement('comments-annotations');
|
|
48
45
|
while (queue.length !== 0) {
|
|
49
46
|
const node = queue.shift();
|
|
50
47
|
if (node) {
|
|
51
48
|
if ((0, exports.isJATSComment)(node)) {
|
|
52
49
|
const comment = (0, exports.parseJATSComment)(node);
|
|
53
50
|
if (comment) {
|
|
54
|
-
const
|
|
55
|
-
(
|
|
56
|
-
|
|
57
|
-
|
|
51
|
+
const token = addMark(doc, node);
|
|
52
|
+
if (token) {
|
|
53
|
+
const mark = {
|
|
54
|
+
token,
|
|
55
|
+
comment,
|
|
56
|
+
};
|
|
57
|
+
marks.push(mark);
|
|
58
|
+
}
|
|
58
59
|
}
|
|
59
60
|
}
|
|
60
61
|
node.childNodes.forEach((child) => {
|
|
@@ -62,20 +63,96 @@ const markComments = (doc) => {
|
|
|
62
63
|
});
|
|
63
64
|
}
|
|
64
65
|
}
|
|
65
|
-
|
|
66
|
-
doc.documentElement.appendChild(commentsElement);
|
|
67
|
-
}
|
|
66
|
+
return marks;
|
|
68
67
|
};
|
|
69
68
|
exports.markComments = markComments;
|
|
70
|
-
const
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
69
|
+
const addMark = (doc, node) => {
|
|
70
|
+
const parent = node.parentElement;
|
|
71
|
+
if (parent) {
|
|
72
|
+
const token = (0, uuid_1.v4)();
|
|
73
|
+
const tokenNode = doc.createTextNode(token);
|
|
74
|
+
parent.insertBefore(tokenNode, node);
|
|
75
|
+
return token;
|
|
76
|
+
}
|
|
75
77
|
};
|
|
76
|
-
const
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
const createComments = (models, marks) => {
|
|
79
|
+
const comments = [];
|
|
80
|
+
for (const model of models) {
|
|
81
|
+
if ((0, transformer_1.isHighlightableModel)(model)) {
|
|
82
|
+
comments.push(...processModel(model, marks));
|
|
83
|
+
}
|
|
84
|
+
else if ((0, transformer_1.isKeyword)(model)) {
|
|
85
|
+
comments.push(...processKeyword(model, marks));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return comments;
|
|
89
|
+
};
|
|
90
|
+
exports.createComments = createComments;
|
|
91
|
+
const getFieldMarks = (content, marks) => {
|
|
92
|
+
return marks
|
|
93
|
+
.filter((m) => content.indexOf(m.token) >= 0)
|
|
94
|
+
.sort((a, b) => content.indexOf(a.token) - content.indexOf(b.token));
|
|
95
|
+
};
|
|
96
|
+
const processModel = (model, marks) => {
|
|
97
|
+
const comments = [];
|
|
98
|
+
for (const field of transformer_1.highlightableFields) {
|
|
99
|
+
const content = model[field];
|
|
100
|
+
if (!content) {
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
const results = processContent(model, content, getFieldMarks(content, marks));
|
|
104
|
+
model[field] = results.content;
|
|
105
|
+
comments.push(...results.comments);
|
|
106
|
+
}
|
|
107
|
+
return comments;
|
|
108
|
+
};
|
|
109
|
+
const processKeyword = (model, marks) => {
|
|
110
|
+
const comments = [];
|
|
111
|
+
const name = model.name;
|
|
112
|
+
let content = name;
|
|
113
|
+
for (const mark of getFieldMarks(name, marks)) {
|
|
114
|
+
content = name.replace(mark.token, '');
|
|
115
|
+
const target = model.containedGroup;
|
|
116
|
+
if (!target) {
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
const contributions = [(0, transformer_1.buildContribution)(DEFAULT_PROFILE_ID)];
|
|
120
|
+
const comment = (0, transformer_1.buildComment)(target, mark.comment.text, undefined, contributions);
|
|
121
|
+
model.name = content;
|
|
122
|
+
comments.push(comment);
|
|
123
|
+
}
|
|
124
|
+
return comments;
|
|
125
|
+
};
|
|
126
|
+
const processContent = (model, content, marks) => {
|
|
127
|
+
const comments = [];
|
|
128
|
+
let result = content;
|
|
129
|
+
for (const mark of marks) {
|
|
130
|
+
const token = mark.token;
|
|
131
|
+
const index = result.indexOf(token);
|
|
132
|
+
result = result.replace(token, '');
|
|
133
|
+
const contributions = [(0, transformer_1.buildContribution)(DEFAULT_PROFILE_ID)];
|
|
134
|
+
const selector = {
|
|
135
|
+
from: index,
|
|
136
|
+
to: index,
|
|
137
|
+
};
|
|
138
|
+
const comment = (0, transformer_1.buildComment)(model._id, mark.comment.text, selector, contributions);
|
|
139
|
+
comments.push(comment);
|
|
140
|
+
}
|
|
141
|
+
return {
|
|
142
|
+
content: result,
|
|
143
|
+
comments,
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
const createReferenceComments = (references) => {
|
|
147
|
+
const comments = [];
|
|
148
|
+
for (const item of references.getBibliographyItems()) {
|
|
149
|
+
const id = item._id;
|
|
150
|
+
for (const comment of references.getComments(id)) {
|
|
151
|
+
const contributions = [(0, transformer_1.buildContribution)(DEFAULT_PROFILE_ID)];
|
|
152
|
+
const c = (0, transformer_1.buildComment)(id, comment.text, undefined, contributions);
|
|
153
|
+
comments.push(c);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return comments;
|
|
81
157
|
};
|
|
158
|
+
exports.createReferenceComments = createReferenceComments;
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* © 2020 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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.jatsFrontParser = void 0;
|
|
22
|
+
const debug_1 = __importDefault(require("debug"));
|
|
23
|
+
const utils_1 = require("../../lib/utils");
|
|
24
|
+
const transformer_1 = require("../../transformer");
|
|
25
|
+
const jats_journal_meta_parser_1 = require("./jats-journal-meta-parser");
|
|
26
|
+
const jats_parser_utils_1 = require("./jats-parser-utils");
|
|
27
|
+
const warn = (0, debug_1.default)('manuscripts-transform');
|
|
28
|
+
const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
|
|
29
|
+
const defaultTitle = 'Untitled Manuscript';
|
|
30
|
+
exports.jatsFrontParser = {
|
|
31
|
+
parseTitles(element, createElement) {
|
|
32
|
+
var _a;
|
|
33
|
+
if (!element) {
|
|
34
|
+
return (0, transformer_1.buildTitles)(defaultTitle);
|
|
35
|
+
}
|
|
36
|
+
const title = element.querySelector('article-title');
|
|
37
|
+
const subtitle = element.querySelector('subtitle');
|
|
38
|
+
const runningTitle = element.querySelector('alt-title[alt-title-type="right-running"]');
|
|
39
|
+
const titles = (0, transformer_1.buildTitles)((_a = (0, jats_parser_utils_1.htmlFromJatsNode)(title, createElement)) !== null && _a !== void 0 ? _a : defaultTitle);
|
|
40
|
+
if (subtitle) {
|
|
41
|
+
titles.subtitle = (0, jats_parser_utils_1.htmlFromJatsNode)(subtitle, createElement);
|
|
42
|
+
}
|
|
43
|
+
if (runningTitle) {
|
|
44
|
+
titles.runningTitle = (0, jats_parser_utils_1.htmlFromJatsNode)(runningTitle, createElement);
|
|
45
|
+
}
|
|
46
|
+
return titles;
|
|
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
|
+
parseCounts(counts) {
|
|
54
|
+
var _a, _b, _c, _d, _e;
|
|
55
|
+
if (counts) {
|
|
56
|
+
const parseCount = (count) => {
|
|
57
|
+
if (count && /^-?\d+$/.test(count)) {
|
|
58
|
+
return parseInt(count);
|
|
59
|
+
}
|
|
60
|
+
else if (count) {
|
|
61
|
+
warn(`Invalid count number for ${count}`);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
const genericCounts = [];
|
|
65
|
+
const countElements = counts.querySelectorAll('count');
|
|
66
|
+
for (const element of countElements.values()) {
|
|
67
|
+
const countType = element.getAttribute('count-type');
|
|
68
|
+
const count = parseCount(element.getAttribute('count'));
|
|
69
|
+
if (countType) {
|
|
70
|
+
const genericCount = { count, countType };
|
|
71
|
+
genericCounts.push(genericCount);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
wordCount: parseCount((_a = counts.querySelector('word-count')) === null || _a === void 0 ? void 0 : _a.getAttribute('count')),
|
|
76
|
+
figureCount: parseCount((_b = counts.querySelector('fig-count')) === null || _b === void 0 ? void 0 : _b.getAttribute('count')),
|
|
77
|
+
tableCount: parseCount((_c = counts.querySelector('table-count')) === null || _c === void 0 ? void 0 : _c.getAttribute('count')),
|
|
78
|
+
equationCount: parseCount((_d = counts.querySelector('equation-count')) === null || _d === void 0 ? void 0 : _d.getAttribute('count')),
|
|
79
|
+
referencesCount: parseCount((_e = counts.querySelector('ref-count')) === null || _e === void 0 ? void 0 : _e.getAttribute('count')),
|
|
80
|
+
genericCounts: genericCounts.length > 0 ? genericCounts : undefined,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
parseJournal(element) {
|
|
85
|
+
const meta = (0, jats_journal_meta_parser_1.parseJournalMeta)(element);
|
|
86
|
+
return Object.assign(Object.assign({}, meta), (0, transformer_1.buildJournal)());
|
|
87
|
+
},
|
|
88
|
+
parseDates(historyNode) {
|
|
89
|
+
if (!historyNode) {
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
const history = {};
|
|
93
|
+
const dateToTimestamp = (dateElement) => {
|
|
94
|
+
const selectors = ['year', 'month', 'day'];
|
|
95
|
+
const values = [];
|
|
96
|
+
for (const selector of selectors) {
|
|
97
|
+
const value = (0, utils_1.getTrimmedTextContent)(dateElement, selector);
|
|
98
|
+
if (!value || isNaN(+value)) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
values.push(+value);
|
|
102
|
+
}
|
|
103
|
+
return Date.UTC(values[0], values[1], values[2]) / 1000;
|
|
104
|
+
};
|
|
105
|
+
for (const date of historyNode.children) {
|
|
106
|
+
const dateType = date.getAttribute('date-type');
|
|
107
|
+
switch (dateType) {
|
|
108
|
+
case 'received': {
|
|
109
|
+
history.receiveDate = dateToTimestamp(date);
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
case 'rev-recd': {
|
|
113
|
+
history.revisionReceiveDate = dateToTimestamp(date);
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
case 'accepted': {
|
|
117
|
+
history.acceptanceDate = dateToTimestamp(date);
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
case 'rev-request': {
|
|
121
|
+
history.revisionRequestDate = dateToTimestamp(date);
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
case 'retracted': {
|
|
125
|
+
history.retractionDate = dateToTimestamp(date);
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
case 'corrected': {
|
|
129
|
+
history.correctionDate = dateToTimestamp(date);
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return history;
|
|
135
|
+
},
|
|
136
|
+
parseAffiliations(elements) {
|
|
137
|
+
const affiliationIDs = new Map();
|
|
138
|
+
const affiliations = elements.map((element, priority) => {
|
|
139
|
+
var _a, _b;
|
|
140
|
+
const affiliation = (0, transformer_1.buildAffiliation)('', priority);
|
|
141
|
+
for (const node of element.querySelectorAll('institution')) {
|
|
142
|
+
const content = (_a = node.textContent) === null || _a === void 0 ? void 0 : _a.trim();
|
|
143
|
+
if (!content) {
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
const type = node.getAttribute('content-type');
|
|
147
|
+
if (type === 'dept') {
|
|
148
|
+
affiliation.department = content;
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
affiliation.institution = content;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
affiliation.addressLine1 =
|
|
155
|
+
(0, utils_1.getTrimmedTextContent)(element, 'addr-line:nth-of-type(1)') || undefined;
|
|
156
|
+
affiliation.addressLine2 =
|
|
157
|
+
(0, utils_1.getTrimmedTextContent)(element, 'addr-line:nth-of-type(2)') || undefined;
|
|
158
|
+
affiliation.addressLine3 =
|
|
159
|
+
(0, utils_1.getTrimmedTextContent)(element, 'addr-line:nth-of-type(3)') || undefined;
|
|
160
|
+
affiliation.postCode =
|
|
161
|
+
(0, utils_1.getTrimmedTextContent)(element, 'postal-code') || undefined;
|
|
162
|
+
affiliation.country =
|
|
163
|
+
(0, utils_1.getTrimmedTextContent)(element, 'country') || undefined;
|
|
164
|
+
const email = element.querySelector('email');
|
|
165
|
+
if (email) {
|
|
166
|
+
affiliation.email = {
|
|
167
|
+
href: email.getAttributeNS(XLINK_NAMESPACE, 'href') || undefined,
|
|
168
|
+
text: ((_b = email.textContent) === null || _b === void 0 ? void 0 : _b.trim()) || undefined,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
const id = element.getAttribute('id');
|
|
172
|
+
if (id) {
|
|
173
|
+
affiliationIDs.set(id, affiliation._id);
|
|
174
|
+
}
|
|
175
|
+
return affiliation;
|
|
176
|
+
});
|
|
177
|
+
return {
|
|
178
|
+
affiliations,
|
|
179
|
+
affiliationIDs,
|
|
180
|
+
};
|
|
181
|
+
},
|
|
182
|
+
parseAuthorNotes(element) {
|
|
183
|
+
if (!element) {
|
|
184
|
+
return {
|
|
185
|
+
footnotes: [],
|
|
186
|
+
footnoteIDs: new Map(),
|
|
187
|
+
authorNotes: [],
|
|
188
|
+
authorNotesParagraphs: [],
|
|
189
|
+
correspondingIDs: new Map(),
|
|
190
|
+
correspondingList: [],
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
const { footnotes, footnoteIDs } = this.parseFootnotes([
|
|
194
|
+
...element.querySelectorAll('fn:not([fn-type])'),
|
|
195
|
+
]);
|
|
196
|
+
const authorNotesParagraphs = this.parseParagraphs([
|
|
197
|
+
...element.querySelectorAll(':scope > p'),
|
|
198
|
+
]);
|
|
199
|
+
const { correspondingList, correspondingIDs } = this.parseCorresp([
|
|
200
|
+
...element.querySelectorAll('corresp'),
|
|
201
|
+
]);
|
|
202
|
+
const authorNotes = [
|
|
203
|
+
(0, transformer_1.buildAuthorNotes)([
|
|
204
|
+
...correspondingIDs.values(),
|
|
205
|
+
...footnoteIDs.values(),
|
|
206
|
+
...authorNotesParagraphs.map((p) => p._id),
|
|
207
|
+
]),
|
|
208
|
+
];
|
|
209
|
+
return {
|
|
210
|
+
footnotes,
|
|
211
|
+
footnoteIDs,
|
|
212
|
+
authorNotesParagraphs,
|
|
213
|
+
authorNotes,
|
|
214
|
+
correspondingIDs,
|
|
215
|
+
correspondingList,
|
|
216
|
+
};
|
|
217
|
+
},
|
|
218
|
+
parseParagraphs(elements) {
|
|
219
|
+
return elements.map((p) => (0, transformer_1.buildParagraph)(p.innerHTML));
|
|
220
|
+
},
|
|
221
|
+
parseFootnotes(elements) {
|
|
222
|
+
const footnoteIDs = new Map();
|
|
223
|
+
const footnotes = elements.map((element) => {
|
|
224
|
+
const fn = (0, transformer_1.buildFootnote)('', element.innerHTML);
|
|
225
|
+
const id = element.getAttribute('id');
|
|
226
|
+
if (id) {
|
|
227
|
+
footnoteIDs.set(id, fn._id);
|
|
228
|
+
}
|
|
229
|
+
return fn;
|
|
230
|
+
});
|
|
231
|
+
return {
|
|
232
|
+
footnotes,
|
|
233
|
+
footnoteIDs,
|
|
234
|
+
};
|
|
235
|
+
},
|
|
236
|
+
parseCorresp(elements) {
|
|
237
|
+
const correspondingIDs = new Map();
|
|
238
|
+
const correspondingList = elements.map((element) => {
|
|
239
|
+
var _a, _b, _c;
|
|
240
|
+
const label = element.querySelector('label');
|
|
241
|
+
if (label) {
|
|
242
|
+
label.remove();
|
|
243
|
+
}
|
|
244
|
+
const corresponding = (0, transformer_1.buildCorresp)((_b = (_a = element.textContent) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : '');
|
|
245
|
+
corresponding.label = ((_c = label === null || label === void 0 ? void 0 : label.textContent) === null || _c === void 0 ? void 0 : _c.trim()) || undefined;
|
|
246
|
+
const id = element.getAttribute('id');
|
|
247
|
+
if (id) {
|
|
248
|
+
correspondingIDs.set(id, corresponding._id);
|
|
249
|
+
}
|
|
250
|
+
return corresponding;
|
|
251
|
+
});
|
|
252
|
+
return {
|
|
253
|
+
correspondingList,
|
|
254
|
+
correspondingIDs,
|
|
255
|
+
};
|
|
256
|
+
},
|
|
257
|
+
parseContributors(elements, affiliationIDs, footnoteIDs, correspondingIDs) {
|
|
258
|
+
return elements.map((element, priority) => {
|
|
259
|
+
var _a, _b;
|
|
260
|
+
const name = (0, transformer_1.buildBibliographicName)({});
|
|
261
|
+
const given = (0, utils_1.getTrimmedTextContent)(element, 'name > given-names');
|
|
262
|
+
if (given) {
|
|
263
|
+
name.given = given;
|
|
264
|
+
}
|
|
265
|
+
const surname = (0, utils_1.getTrimmedTextContent)(element, 'name > surname');
|
|
266
|
+
if (surname) {
|
|
267
|
+
name.family = surname;
|
|
268
|
+
}
|
|
269
|
+
const contributor = (0, transformer_1.buildContributor)(name, 'author', priority);
|
|
270
|
+
const corresponding = element.getAttribute('corresp') === 'yes';
|
|
271
|
+
if (corresponding) {
|
|
272
|
+
contributor.isCorresponding = corresponding;
|
|
273
|
+
}
|
|
274
|
+
const orcid = (0, utils_1.getTrimmedTextContent)(element, 'contrib-id[contrib-id-type="orcid"]');
|
|
275
|
+
if (orcid) {
|
|
276
|
+
contributor.ORCIDIdentifier = orcid;
|
|
277
|
+
}
|
|
278
|
+
const xrefs = element.querySelectorAll('xref');
|
|
279
|
+
for (const xref of xrefs) {
|
|
280
|
+
if (xref) {
|
|
281
|
+
const rid = xref.getAttribute('rid');
|
|
282
|
+
const type = xref.getAttribute('ref-type');
|
|
283
|
+
if (rid) {
|
|
284
|
+
if (type === 'fn') {
|
|
285
|
+
contributor.footnote = [];
|
|
286
|
+
const footnoteID = footnoteIDs.get(rid);
|
|
287
|
+
if (footnoteID) {
|
|
288
|
+
const authorFootNoteRef = {
|
|
289
|
+
noteID: footnoteID,
|
|
290
|
+
noteLabel: ((_a = xref.textContent) === null || _a === void 0 ? void 0 : _a.trim()) || '',
|
|
291
|
+
};
|
|
292
|
+
contributor.footnote.push(authorFootNoteRef);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
else if (type === 'corresp') {
|
|
296
|
+
contributor.corresp = [];
|
|
297
|
+
const correspID = correspondingIDs.get(rid);
|
|
298
|
+
if (correspID) {
|
|
299
|
+
const authorCorrespRef = {
|
|
300
|
+
correspID: correspID,
|
|
301
|
+
correspLabel: ((_b = xref.textContent) === null || _b === void 0 ? void 0 : _b.trim()) || '',
|
|
302
|
+
};
|
|
303
|
+
contributor.corresp.push(authorCorrespRef);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
else if (type === 'aff') {
|
|
307
|
+
const rids = rid
|
|
308
|
+
.split(/\s+/)
|
|
309
|
+
.map((id) => affiliationIDs.get(id))
|
|
310
|
+
.filter(Boolean);
|
|
311
|
+
if (rids.length) {
|
|
312
|
+
contributor.affiliations = rids;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
return contributor;
|
|
319
|
+
});
|
|
320
|
+
},
|
|
321
|
+
};
|
|
@@ -15,10 +15,8 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.
|
|
19
|
-
const json_schema_1 = require("@manuscripts/json-schema");
|
|
18
|
+
exports.parseJournalMeta = exports.parseJournalISSNs = exports.parseJournalAbbreviatedTitles = exports.parseJournalIdentifiers = void 0;
|
|
20
19
|
const utils_1 = require("../../lib/utils");
|
|
21
|
-
const transformer_1 = require("../../transformer");
|
|
22
20
|
const parseJournalIdentifiers = (element) => {
|
|
23
21
|
var _a;
|
|
24
22
|
if (!element) {
|
|
@@ -93,8 +91,3 @@ const parseJournalMeta = (element) => {
|
|
|
93
91
|
};
|
|
94
92
|
};
|
|
95
93
|
exports.parseJournalMeta = parseJournalMeta;
|
|
96
|
-
const parseJournal = (element) => {
|
|
97
|
-
const meta = (0, exports.parseJournalMeta)(element);
|
|
98
|
-
return Object.assign(Object.assign({}, meta), { _id: (0, transformer_1.generateID)(json_schema_1.ObjectTypes.Journal), objectType: json_schema_1.ObjectTypes.Journal });
|
|
99
|
-
};
|
|
100
|
-
exports.parseJournal = parseJournal;
|
|
@@ -21,35 +21,21 @@ const schema_1 = require("../../schema");
|
|
|
21
21
|
const transformer_1 = require("../../transformer");
|
|
22
22
|
const updateDocumentIDs = (node, replacements) => {
|
|
23
23
|
const warnings = [];
|
|
24
|
-
|
|
25
|
-
recurseDoc(node, (n, parent) => updateNodeID(n, parent, replacements, warnings, highlightNodes));
|
|
24
|
+
recurseDoc(node, (n) => updateNodeID(n, replacements, warnings));
|
|
26
25
|
recurseDoc(node, (n) => updateNodeRID(n, replacements, warnings));
|
|
27
26
|
recurseDoc(node, (n) => updateNodeRIDS(n, replacements, warnings));
|
|
28
|
-
recurseDoc(node, (n) => updateContributorNodesIDS(n, replacements, warnings));
|
|
29
27
|
return warnings;
|
|
30
28
|
};
|
|
31
29
|
exports.updateDocumentIDs = updateDocumentIDs;
|
|
32
|
-
function recurseDoc(node, fn
|
|
33
|
-
fn(node
|
|
34
|
-
node.descendants((n
|
|
30
|
+
function recurseDoc(node, fn) {
|
|
31
|
+
fn(node);
|
|
32
|
+
node.descendants((n) => fn(n));
|
|
35
33
|
}
|
|
36
|
-
const updateNodeID = (node,
|
|
34
|
+
const updateNodeID = (node, replacements, warnings) => {
|
|
37
35
|
if (node.type === schema_1.schema.nodes.inline_equation) {
|
|
38
36
|
node.attrs = Object.assign(Object.assign({}, node.attrs), { id: `InlineMathFragment:${(0, uuid_1.v4)()}` });
|
|
39
37
|
return;
|
|
40
38
|
}
|
|
41
|
-
if (node.type === schema_1.schema.nodes.highlight_marker) {
|
|
42
|
-
node.attrs = Object.assign(Object.assign({}, node.attrs), { tid: parent === null || parent === void 0 ? void 0 : parent.attrs.id });
|
|
43
|
-
highlightNodes.push(node);
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
if (node.type === schema_1.schema.nodes.comment) {
|
|
47
|
-
const highlightNode = highlightNodes.find((n) => n.attrs.id === node.attrs.id);
|
|
48
|
-
if (highlightNode) {
|
|
49
|
-
node.attrs = Object.assign(Object.assign({}, node.attrs), { target: highlightNode.attrs.tid });
|
|
50
|
-
}
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
39
|
if (node.type === schema_1.schema.nodes.general_table_footnote) {
|
|
54
40
|
node.attrs = Object.assign(Object.assign({}, node.attrs), { id: `GeneralTableFootnote:${(0, uuid_1.v4)()}` });
|
|
55
41
|
return;
|
|
@@ -92,30 +78,6 @@ const updateNodeRIDS = (node, replacements, warnings) => {
|
|
|
92
78
|
}
|
|
93
79
|
node.attrs = Object.assign(Object.assign({}, node.attrs), { rids: previousRIDs.map((r) => replacements.get(r) || r) });
|
|
94
80
|
};
|
|
95
|
-
const updateContributorNodesIDS = (node, replacements, warnings) => {
|
|
96
|
-
var _a, _b;
|
|
97
|
-
if (node.type === schema_1.schema.nodes.contributor) {
|
|
98
|
-
const footnote = (_a = node.attrs.footnote) === null || _a === void 0 ? void 0 : _a.map((fn) => {
|
|
99
|
-
return replacements.get(fn.noteID)
|
|
100
|
-
? Object.assign(Object.assign({}, fn), { noteID: replacements.get(fn.noteID) }) : undefined;
|
|
101
|
-
}).filter(Boolean);
|
|
102
|
-
const corresp = (_b = node.attrs.corresp) === null || _b === void 0 ? void 0 : _b.map((corresp) => {
|
|
103
|
-
return replacements.get(corresp.correspID)
|
|
104
|
-
? Object.assign(Object.assign({}, corresp), { correspID: replacements.get(corresp.correspID) }) : undefined;
|
|
105
|
-
}).filter(Boolean);
|
|
106
|
-
const affiliations = node.attrs.affiliations
|
|
107
|
-
.map((affiliation) => {
|
|
108
|
-
return replacements.get(affiliation);
|
|
109
|
-
})
|
|
110
|
-
.filter(Boolean);
|
|
111
|
-
node.attrs = Object.assign(Object.assign({}, node.attrs), { footnote,
|
|
112
|
-
corresp,
|
|
113
|
-
affiliations });
|
|
114
|
-
}
|
|
115
|
-
if (node.type !== schema_1.schema.nodes.contributors) {
|
|
116
|
-
return false;
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
81
|
const JATS_TO_HTML_MAPPING = new Map([
|
|
120
82
|
['bold', 'b'],
|
|
121
83
|
['italic', 'i'],
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.jatsReferenceParser = void 0;
|
|
19
|
-
const json_schema_1 = require("@manuscripts/json-schema");
|
|
20
19
|
const utils_1 = require("../../lib/utils");
|
|
21
|
-
const
|
|
20
|
+
const builders_1 = require("../../transformer/builders");
|
|
21
|
+
const jats_comments_1 = require("./jats-comments");
|
|
22
22
|
const jats_parser_utils_1 = require("./jats-parser-utils");
|
|
23
23
|
const jats_references_1 = require("./jats-references");
|
|
24
24
|
const chooseBibliographyItemType = (publicationType) => {
|
|
@@ -40,15 +40,23 @@ exports.jatsReferenceParser = {
|
|
|
40
40
|
const authorNodes = [
|
|
41
41
|
...element.querySelectorAll('person-group[person-group-type="author"] > *'),
|
|
42
42
|
];
|
|
43
|
-
const bibliographyItem = {
|
|
44
|
-
id: (0, transformer_1.generateID)(json_schema_1.ObjectTypes.BibliographyItem),
|
|
43
|
+
const bibliographyItem = (0, builders_1.buildBibliographyItem)({
|
|
45
44
|
type: chooseBibliographyItemType(publicationType),
|
|
46
|
-
};
|
|
45
|
+
});
|
|
47
46
|
const titleNode = element.querySelector('article-title');
|
|
48
47
|
if (titleNode) {
|
|
49
48
|
bibliographyItem.title = (_a = (0, jats_parser_utils_1.htmlFromJatsNode)(titleNode, createElement)) === null || _a === void 0 ? void 0 : _a.trim();
|
|
50
49
|
}
|
|
50
|
+
const comments = [];
|
|
51
51
|
const mixedCitation = element.querySelector('mixed-citation');
|
|
52
|
+
mixedCitation === null || mixedCitation === void 0 ? void 0 : mixedCitation.childNodes.forEach((item) => {
|
|
53
|
+
if ((0, jats_comments_1.isJATSComment)(item)) {
|
|
54
|
+
const comment = (0, jats_comments_1.parseJATSComment)(item);
|
|
55
|
+
if (comment) {
|
|
56
|
+
comments.push(comment);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
});
|
|
52
60
|
if (authorNodes.length <= 0) {
|
|
53
61
|
mixedCitation === null || mixedCitation === void 0 ? void 0 : mixedCitation.childNodes.forEach((item) => {
|
|
54
62
|
var _a, _b, _c;
|
|
@@ -61,7 +69,7 @@ exports.jatsReferenceParser = {
|
|
|
61
69
|
}
|
|
62
70
|
const source = (0, utils_1.getTrimmedTextContent)(element, 'source');
|
|
63
71
|
if (source) {
|
|
64
|
-
bibliographyItem
|
|
72
|
+
bibliographyItem['container-title'] = source;
|
|
65
73
|
}
|
|
66
74
|
const volume = (0, utils_1.getTrimmedTextContent)(element, 'volume');
|
|
67
75
|
if (volume) {
|
|
@@ -82,23 +90,18 @@ exports.jatsReferenceParser = {
|
|
|
82
90
|
}
|
|
83
91
|
const year = (0, utils_1.getTrimmedTextContent)(element, 'year');
|
|
84
92
|
if (year) {
|
|
85
|
-
bibliographyItem.issued = {
|
|
93
|
+
bibliographyItem.issued = (0, builders_1.buildBibliographicDate)({
|
|
86
94
|
'date-parts': [[year]],
|
|
87
|
-
|
|
88
|
-
objectType: json_schema_1.ObjectTypes.BibliographicDate,
|
|
89
|
-
};
|
|
95
|
+
});
|
|
90
96
|
}
|
|
91
97
|
const doi = (0, utils_1.getTrimmedTextContent)(element, 'pub-id[pub-id-type="doi"]');
|
|
92
98
|
if (doi) {
|
|
93
|
-
bibliographyItem.
|
|
99
|
+
bibliographyItem.DOI = doi;
|
|
94
100
|
}
|
|
95
101
|
const authors = [];
|
|
96
102
|
authorNodes.forEach((authorNode) => {
|
|
97
103
|
var _a;
|
|
98
|
-
const name = {
|
|
99
|
-
_id: (0, transformer_1.generateID)(json_schema_1.ObjectTypes.BibliographicName),
|
|
100
|
-
objectType: json_schema_1.ObjectTypes.BibliographicName,
|
|
101
|
-
};
|
|
104
|
+
const name = (0, builders_1.buildBibliographicName)({});
|
|
102
105
|
const given = (0, utils_1.getTrimmedTextContent)(authorNode, 'given-names');
|
|
103
106
|
if (given) {
|
|
104
107
|
name.given = given;
|
|
@@ -107,6 +110,10 @@ exports.jatsReferenceParser = {
|
|
|
107
110
|
if (family) {
|
|
108
111
|
name.family = family;
|
|
109
112
|
}
|
|
113
|
+
const suffix = (0, utils_1.getTrimmedTextContent)(authorNode, 'suffix');
|
|
114
|
+
if (suffix) {
|
|
115
|
+
name.suffix = suffix;
|
|
116
|
+
}
|
|
110
117
|
if (authorNode.nodeName === 'collab') {
|
|
111
118
|
name.literal = (_a = authorNode.textContent) === null || _a === void 0 ? void 0 : _a.trim();
|
|
112
119
|
}
|
|
@@ -116,7 +123,7 @@ exports.jatsReferenceParser = {
|
|
|
116
123
|
bibliographyItem.author = authors;
|
|
117
124
|
}
|
|
118
125
|
const id = element.getAttribute('id');
|
|
119
|
-
references.add(bibliographyItem, id);
|
|
126
|
+
references.add(bibliographyItem, id, comments);
|
|
120
127
|
});
|
|
121
128
|
return references;
|
|
122
129
|
},
|