@manuscripts/transform 2.3.34-LEAN-3911.2 → 2.3.35
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/jats/importer/index.js +3 -3
- package/dist/cjs/jats/importer/{jats-dom-parser.js → jats-body-dom-parser.js} +9 -229
- package/dist/cjs/jats/importer/jats-body-transformations.js +0 -70
- 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 -39
- package/dist/cjs/jats/importer/jats-reference-parser.js +27 -16
- package/dist/cjs/jats/importer/jats-references.js +18 -18
- package/dist/cjs/jats/importer/parse-jats-article.js +78 -42
- package/dist/cjs/jats/index.js +3 -4
- package/dist/cjs/jats/jats-exporter.js +354 -251
- package/dist/cjs/lib/utils.js +1 -9
- package/dist/cjs/schema/nodes/inline_footnote.js +1 -0
- package/dist/cjs/transformer/__tests__/__helpers__/doc.js +37 -0
- package/dist/cjs/transformer/builders.js +219 -0
- package/dist/cjs/transformer/decode.js +874 -0
- package/dist/cjs/transformer/document-object-types.js +31 -0
- package/dist/cjs/transformer/encode.js +664 -0
- 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 +6 -6
- package/dist/cjs/transformer/index.js +18 -0
- package/dist/cjs/{jats → transformer}/labels.js +3 -3
- package/dist/cjs/transformer/manuscript-dependencies.js +21 -0
- package/dist/cjs/transformer/model-map.js +26 -0
- package/dist/cjs/transformer/models.js +17 -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/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/jats/importer/index.js +1 -2
- package/dist/es/jats/importer/{jats-dom-parser.js → jats-body-dom-parser.js} +10 -230
- package/dist/es/jats/importer/jats-body-transformations.js +0 -70
- 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 -40
- package/dist/es/jats/importer/jats-reference-parser.js +27 -16
- package/dist/es/jats/importer/jats-references.js +18 -18
- package/dist/es/jats/importer/parse-jats-article.js +77 -43
- package/dist/es/jats/index.js +1 -3
- package/dist/es/jats/jats-exporter.js +356 -253
- package/dist/es/lib/utils.js +0 -7
- package/dist/es/schema/nodes/inline_footnote.js +1 -0
- package/dist/es/transformer/__tests__/__helpers__/doc.js +29 -0
- package/dist/es/transformer/builders.js +186 -0
- package/dist/es/transformer/decode.js +864 -0
- package/dist/es/transformer/document-object-types.js +28 -0
- package/dist/es/transformer/encode.js +654 -0
- package/dist/{types/jats/importer/create-article-node.d.ts → es/transformer/footnote-category.js} +2 -3
- 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 +4 -5
- package/dist/es/transformer/index.js +16 -0
- package/dist/es/{jats → transformer}/labels.js +3 -3
- package/dist/es/transformer/manuscript-dependencies.js +17 -0
- package/dist/es/transformer/model-map.js +22 -0
- package/dist/es/transformer/models.js +16 -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/update-identifiers.js +87 -0
- package/dist/es/version.js +1 -1
- package/dist/types/jats/importer/index.d.ts +1 -2
- 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 +0 -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 +1 -3
- package/dist/types/jats/jats-exporter.d.ts +29 -10
- package/dist/types/lib/utils.d.ts +0 -3
- package/dist/types/schema/nodes/bibliography_item.d.ts +6 -16
- package/dist/types/schema/nodes/contributor.d.ts +0 -10
- package/dist/types/schema/nodes/keyword_group.d.ts +0 -1
- 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 +51 -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/footnote-category.d.ts +17 -0
- package/dist/types/transformer/footnotes-order.d.ts +22 -0
- 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 +3 -4
- package/dist/types/transformer/index.d.ts +16 -0
- package/dist/types/{jats → transformer}/labels.d.ts +1 -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/transformer/update-identifiers.d.ts +23 -0
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -2
- package/dist/cjs/jats/importer/create-article-node.js +0 -31
- package/dist/cjs/jats/importer/jats-front-transformations.js +0 -262
- package/dist/es/jats/importer/create-article-node.js +0 -27
- package/dist/es/jats/importer/jats-front-transformations.js +0 -259
- package/dist/types/jats/importer/jats-front-transformations.d.ts +0 -38
- /package/dist/cjs/{jats → transformer}/filename.js +0 -0
- /package/dist/cjs/{jats → transformer}/timestamp.js +0 -0
- /package/dist/es/{jats → transformer}/filename.js +0 -0
- /package/dist/es/{jats → transformer}/timestamp.js +0 -0
- /package/dist/types/{jats → transformer}/filename.d.ts +0 -0
- /package/dist/types/{jats → transformer}/timestamp.d.ts +0 -0
|
@@ -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,26 +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 Object.assign(Object.assign({}, fn), { noteID: replacements.get(fn.noteID) });
|
|
100
|
-
});
|
|
101
|
-
const corresp = (_b = node.attrs.corresp) === null || _b === void 0 ? void 0 : _b.map((corresp) => {
|
|
102
|
-
return Object.assign(Object.assign({}, corresp), { correspID: replacements.get(corresp.correspID) });
|
|
103
|
-
});
|
|
104
|
-
const affiliations = node.attrs.affiliations.map((affiliation) => {
|
|
105
|
-
return replacements.get(affiliation);
|
|
106
|
-
});
|
|
107
|
-
node.attrs = Object.assign(Object.assign({}, node.attrs), { footnote,
|
|
108
|
-
corresp,
|
|
109
|
-
affiliations });
|
|
110
|
-
}
|
|
111
|
-
if (node.type !== schema_1.schema.nodes.contributors) {
|
|
112
|
-
return false;
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
81
|
const JATS_TO_HTML_MAPPING = new Map([
|
|
116
82
|
['bold', 'b'],
|
|
117
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,22 +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
|
-
|
|
98
|
-
|
|
99
|
-
objectType: json_schema_1.ObjectTypes.BibliographicName,
|
|
100
|
-
};
|
|
103
|
+
var _a;
|
|
104
|
+
const name = (0, builders_1.buildBibliographicName)({});
|
|
101
105
|
const given = (0, utils_1.getTrimmedTextContent)(authorNode, 'given-names');
|
|
102
106
|
if (given) {
|
|
103
107
|
name.given = given;
|
|
@@ -106,13 +110,20 @@ exports.jatsReferenceParser = {
|
|
|
106
110
|
if (family) {
|
|
107
111
|
name.family = family;
|
|
108
112
|
}
|
|
113
|
+
const suffix = (0, utils_1.getTrimmedTextContent)(authorNode, 'suffix');
|
|
114
|
+
if (suffix) {
|
|
115
|
+
name.suffix = suffix;
|
|
116
|
+
}
|
|
117
|
+
if (authorNode.nodeName === 'collab') {
|
|
118
|
+
name.literal = (_a = authorNode.textContent) === null || _a === void 0 ? void 0 : _a.trim();
|
|
119
|
+
}
|
|
109
120
|
authors.push(name);
|
|
110
121
|
});
|
|
111
122
|
if (authors.length) {
|
|
112
123
|
bibliographyItem.author = authors;
|
|
113
124
|
}
|
|
114
125
|
const id = element.getAttribute('id');
|
|
115
|
-
references.add(bibliographyItem, id);
|
|
126
|
+
references.add(bibliographyItem, id, comments);
|
|
116
127
|
});
|
|
117
128
|
return references;
|
|
118
129
|
},
|
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/*!
|
|
3
|
-
* © 2023 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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
3
|
exports.References = void 0;
|
|
19
4
|
class References {
|
|
20
5
|
constructor() {
|
|
21
6
|
this.items = new Map();
|
|
22
7
|
this.IDs = new Map();
|
|
8
|
+
this.comments = new Map();
|
|
23
9
|
}
|
|
24
|
-
add(item, id) {
|
|
25
|
-
this.items.set(item.
|
|
10
|
+
add(item, id, comments) {
|
|
11
|
+
this.items.set(item._id, item);
|
|
12
|
+
this.comments.set(item._id, comments);
|
|
26
13
|
if (id) {
|
|
27
|
-
this.IDs.set(id, item.
|
|
14
|
+
this.IDs.set(id, item._id);
|
|
28
15
|
}
|
|
29
16
|
}
|
|
30
17
|
getBibliographyItems() {
|
|
31
18
|
return [...this.items.values()];
|
|
32
19
|
}
|
|
20
|
+
getComments(id) {
|
|
21
|
+
return this.getValue(id, this.comments) || [];
|
|
22
|
+
}
|
|
23
|
+
getValue(id, map) {
|
|
24
|
+
const value = map.get(id);
|
|
25
|
+
if (value) {
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
const id2 = this.IDs.get(id);
|
|
29
|
+
if (id2) {
|
|
30
|
+
return map.get(id2);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
33
|
}
|
|
34
34
|
exports.References = References;
|