@manuscripts/transform 2.6.0 → 2.6.1-LEAN-3966.1
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 +6 -6
- package/dist/cjs/jats/{jats-exporter.js → exporter/jats-exporter.js} +305 -416
- package/dist/cjs/jats/{jats-versions.js → exporter/jats-versions.js} +1 -3
- package/dist/cjs/{transformer → jats/exporter}/labels.js +4 -4
- package/dist/cjs/{transformer/filename.js → jats/importer/create-article-node.js} +10 -9
- package/dist/cjs/jats/importer/jats-comments.js +32 -111
- package/dist/cjs/jats/importer/{jats-body-dom-parser.js → jats-dom-parser.js} +350 -10
- package/dist/cjs/jats/importer/jats-journal-meta-parser.js +11 -1
- package/dist/cjs/jats/importer/jats-parser-utils.js +76 -9
- package/dist/cjs/jats/importer/jats-transformations.js +397 -0
- package/dist/cjs/jats/importer/parse-jats-article.js +44 -101
- package/dist/cjs/jats/index.js +7 -7
- package/dist/cjs/{transformer/models.js → lib/deafults.js} +3 -1
- package/dist/cjs/lib/utils.js +3 -1
- package/dist/cjs/schema/nodes/highlight_marker.js +0 -4
- package/dist/cjs/transformer/id.js +1 -5
- package/dist/cjs/transformer/index.js +0 -18
- package/dist/cjs/version.js +1 -1
- package/dist/es/index.js +5 -5
- package/dist/es/jats/{jats-exporter.js → exporter/jats-exporter.js} +300 -411
- package/dist/es/jats/{jats-versions.js → exporter/jats-versions.js} +0 -1
- package/dist/es/{transformer → jats/exporter}/labels.js +4 -4
- package/dist/{cjs/transformer/model-map.js → es/jats/importer/create-article-node.js} +8 -10
- package/dist/es/jats/importer/jats-comments.js +32 -107
- package/dist/es/jats/importer/{jats-body-dom-parser.js → jats-dom-parser.js} +350 -10
- package/dist/es/jats/importer/jats-journal-meta-parser.js +9 -0
- package/dist/es/jats/importer/jats-parser-utils.js +78 -11
- package/dist/es/jats/importer/jats-transformations.js +377 -0
- package/dist/es/jats/importer/parse-jats-article.js +44 -99
- package/dist/es/jats/index.js +5 -3
- package/dist/{types/transformer/timestamp.d.ts → es/lib/deafults.js} +2 -2
- package/dist/es/lib/utils.js +1 -0
- package/dist/es/schema/nodes/highlight_marker.js +0 -4
- package/dist/es/transformer/id.js +0 -3
- package/dist/es/transformer/index.js +0 -16
- package/dist/es/version.js +1 -1
- package/dist/types/index.d.ts +6 -6
- package/dist/types/jats/{jats-exporter.d.ts → exporter/jats-exporter.d.ts} +16 -29
- package/dist/types/jats/{jats-versions.d.ts → exporter/jats-versions.d.ts} +0 -1
- package/dist/types/{transformer → jats/exporter}/labels.d.ts +2 -2
- package/dist/{es/transformer/footnote-category.js → types/jats/importer/create-article-node.d.ts} +3 -2
- package/dist/types/jats/importer/jats-comments.d.ts +2 -15
- package/dist/types/jats/importer/{jats-body-dom-parser.d.ts → jats-dom-parser.d.ts} +1 -1
- package/dist/types/jats/importer/jats-journal-meta-parser.d.ts +9 -0
- package/dist/types/jats/importer/jats-parser-utils.d.ts +2 -2
- package/dist/types/jats/importer/jats-transformations.d.ts +33 -0
- package/dist/types/jats/importer/parse-jats-article.d.ts +12 -5
- package/dist/types/jats/index.d.ts +5 -3
- package/dist/types/jats/types.d.ts +1 -0
- package/dist/{es/transformer/models.js → types/lib/deafults.d.ts} +2 -2
- package/dist/types/lib/utils.d.ts +1 -0
- package/dist/types/schema/nodes/bibliography_item.d.ts +3 -3
- package/dist/types/schema/nodes/contributor.d.ts +10 -0
- package/dist/types/schema/nodes/highlight_marker.d.ts +0 -2
- package/dist/types/schema/nodes/keyword_group.d.ts +1 -0
- package/dist/types/schema/nodes/manuscript.d.ts +8 -7
- package/dist/types/schema/nodes/title.d.ts +0 -3
- package/dist/types/transformer/id.d.ts +0 -3
- package/dist/types/transformer/index.d.ts +0 -16
- package/dist/types/version.d.ts +1 -1
- package/package.json +2 -1
- package/dist/cjs/__tests__/data/project-dump.json +0 -825
- package/dist/cjs/jats/importer/index.js +0 -22
- package/dist/cjs/jats/importer/jats-front-parser.js +0 -321
- package/dist/cjs/jats/importer/jats-reference-parser.js +0 -130
- package/dist/cjs/jats/importer/jats-references.js +0 -34
- package/dist/cjs/transformer/__tests__/__helpers__/doc.js +0 -37
- package/dist/cjs/transformer/builders.js +0 -219
- package/dist/cjs/transformer/decode.js +0 -898
- package/dist/cjs/transformer/document-object-types.js +0 -31
- package/dist/cjs/transformer/encode.js +0 -674
- package/dist/cjs/transformer/footnote-category.js +0 -20
- package/dist/cjs/transformer/footnotes-order.js +0 -60
- package/dist/cjs/transformer/highlight-markers.js +0 -138
- package/dist/cjs/transformer/html.js +0 -400
- package/dist/cjs/transformer/manuscript-dependencies.js +0 -21
- package/dist/cjs/transformer/object-types.js +0 -57
- package/dist/cjs/transformer/project-bundle.js +0 -94
- package/dist/cjs/transformer/serializer.js +0 -23
- package/dist/cjs/transformer/timestamp.js +0 -20
- package/dist/cjs/transformer/update-identifiers.js +0 -93
- package/dist/es/__tests__/data/project-dump.json +0 -825
- package/dist/es/jats/importer/index.js +0 -16
- package/dist/es/jats/importer/jats-front-parser.js +0 -315
- package/dist/es/jats/importer/jats-reference-parser.js +0 -127
- package/dist/es/jats/importer/jats-references.js +0 -30
- package/dist/es/transformer/__tests__/__helpers__/doc.js +0 -29
- package/dist/es/transformer/builders.js +0 -186
- package/dist/es/transformer/decode.js +0 -888
- package/dist/es/transformer/document-object-types.js +0 -28
- package/dist/es/transformer/encode.js +0 -664
- package/dist/es/transformer/filename.js +0 -23
- package/dist/es/transformer/footnotes-order.js +0 -55
- package/dist/es/transformer/highlight-markers.js +0 -132
- package/dist/es/transformer/html.js +0 -393
- package/dist/es/transformer/manuscript-dependencies.js +0 -17
- package/dist/es/transformer/model-map.js +0 -22
- package/dist/es/transformer/object-types.js +0 -52
- package/dist/es/transformer/project-bundle.js +0 -85
- package/dist/es/transformer/serializer.js +0 -17
- package/dist/es/transformer/timestamp.js +0 -16
- package/dist/es/transformer/update-identifiers.js +0 -87
- package/dist/types/jats/importer/index.d.ts +0 -16
- package/dist/types/jats/importer/jats-front-parser.d.ts +0 -84
- package/dist/types/jats/importer/jats-reference-parser.d.ts +0 -19
- package/dist/types/jats/importer/jats-references.d.ts +0 -12
- package/dist/types/transformer/__tests__/__helpers__/doc.d.ts +0 -18
- package/dist/types/transformer/builders.d.ts +0 -61
- package/dist/types/transformer/decode.d.ts +0 -52
- package/dist/types/transformer/document-object-types.d.ts +0 -17
- package/dist/types/transformer/encode.d.ts +0 -29
- package/dist/types/transformer/filename.d.ts +0 -16
- package/dist/types/transformer/footnote-category.d.ts +0 -17
- package/dist/types/transformer/footnotes-order.d.ts +0 -22
- package/dist/types/transformer/highlight-markers.d.ts +0 -31
- package/dist/types/transformer/html.d.ts +0 -36
- package/dist/types/transformer/manuscript-dependencies.d.ts +0 -4
- package/dist/types/transformer/model-map.d.ts +0 -19
- package/dist/types/transformer/models.d.ts +0 -48
- package/dist/types/transformer/object-types.d.ts +0 -30
- package/dist/types/transformer/project-bundle.d.ts +0 -30
- package/dist/types/transformer/serializer.d.ts +0 -19
- package/dist/types/transformer/update-identifiers.d.ts +0 -23
- package/dist/types/types.d.ts +0 -2
- /package/dist/cjs/{types.js → jats/types.js} +0 -0
- /package/dist/es/{types.js → jats/types.js} +0 -0
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* © 2020 Atypon Systems LLC
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
export { parseJATSFront, parseJATSBody, parseJATSArticle, } from './parse-jats-article';
|
|
@@ -1,315 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* © 2020 Atypon Systems LLC
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import debug from 'debug';
|
|
17
|
-
import { getTrimmedTextContent } from '../../lib/utils';
|
|
18
|
-
import { buildAffiliation, buildAuthorNotes, buildBibliographicName, buildContributor, buildCorresp, buildFootnote, buildJournal, buildParagraph, buildTitles, } from '../../transformer';
|
|
19
|
-
import { parseJournalMeta } from './jats-journal-meta-parser';
|
|
20
|
-
import { htmlFromJatsNode } from './jats-parser-utils';
|
|
21
|
-
const warn = debug('manuscripts-transform');
|
|
22
|
-
const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
|
|
23
|
-
const defaultTitle = 'Untitled Manuscript';
|
|
24
|
-
export const jatsFrontParser = {
|
|
25
|
-
parseTitles(element, createElement) {
|
|
26
|
-
var _a;
|
|
27
|
-
if (!element) {
|
|
28
|
-
return buildTitles(defaultTitle);
|
|
29
|
-
}
|
|
30
|
-
const title = element.querySelector('article-title');
|
|
31
|
-
const subtitle = element.querySelector('subtitle');
|
|
32
|
-
const runningTitle = element.querySelector('alt-title[alt-title-type="right-running"]');
|
|
33
|
-
const titles = buildTitles((_a = htmlFromJatsNode(title, createElement)) !== null && _a !== void 0 ? _a : defaultTitle);
|
|
34
|
-
if (subtitle) {
|
|
35
|
-
titles.subtitle = htmlFromJatsNode(subtitle, createElement);
|
|
36
|
-
}
|
|
37
|
-
if (runningTitle) {
|
|
38
|
-
titles.runningTitle = htmlFromJatsNode(runningTitle, createElement);
|
|
39
|
-
}
|
|
40
|
-
return titles;
|
|
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
|
-
parseCounts(counts) {
|
|
48
|
-
var _a, _b, _c, _d, _e;
|
|
49
|
-
if (counts) {
|
|
50
|
-
const parseCount = (count) => {
|
|
51
|
-
if (count && /^-?\d+$/.test(count)) {
|
|
52
|
-
return parseInt(count);
|
|
53
|
-
}
|
|
54
|
-
else if (count) {
|
|
55
|
-
warn(`Invalid count number for ${count}`);
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
const genericCounts = [];
|
|
59
|
-
const countElements = counts.querySelectorAll('count');
|
|
60
|
-
for (const element of countElements.values()) {
|
|
61
|
-
const countType = element.getAttribute('count-type');
|
|
62
|
-
const count = parseCount(element.getAttribute('count'));
|
|
63
|
-
if (countType) {
|
|
64
|
-
const genericCount = { count, countType };
|
|
65
|
-
genericCounts.push(genericCount);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
return {
|
|
69
|
-
wordCount: parseCount((_a = counts.querySelector('word-count')) === null || _a === void 0 ? void 0 : _a.getAttribute('count')),
|
|
70
|
-
figureCount: parseCount((_b = counts.querySelector('fig-count')) === null || _b === void 0 ? void 0 : _b.getAttribute('count')),
|
|
71
|
-
tableCount: parseCount((_c = counts.querySelector('table-count')) === null || _c === void 0 ? void 0 : _c.getAttribute('count')),
|
|
72
|
-
equationCount: parseCount((_d = counts.querySelector('equation-count')) === null || _d === void 0 ? void 0 : _d.getAttribute('count')),
|
|
73
|
-
referencesCount: parseCount((_e = counts.querySelector('ref-count')) === null || _e === void 0 ? void 0 : _e.getAttribute('count')),
|
|
74
|
-
genericCounts: genericCounts.length > 0 ? genericCounts : undefined,
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
parseJournal(element) {
|
|
79
|
-
const meta = parseJournalMeta(element);
|
|
80
|
-
return Object.assign(Object.assign({}, meta), buildJournal());
|
|
81
|
-
},
|
|
82
|
-
parseDates(historyNode) {
|
|
83
|
-
if (!historyNode) {
|
|
84
|
-
return undefined;
|
|
85
|
-
}
|
|
86
|
-
const history = {};
|
|
87
|
-
const dateToTimestamp = (dateElement) => {
|
|
88
|
-
const selectors = ['year', 'month', 'day'];
|
|
89
|
-
const values = [];
|
|
90
|
-
for (const selector of selectors) {
|
|
91
|
-
const value = getTrimmedTextContent(dateElement, selector);
|
|
92
|
-
if (!value || isNaN(+value)) {
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
values.push(+value);
|
|
96
|
-
}
|
|
97
|
-
return Date.UTC(values[0], values[1], values[2]) / 1000;
|
|
98
|
-
};
|
|
99
|
-
for (const date of historyNode.children) {
|
|
100
|
-
const dateType = date.getAttribute('date-type');
|
|
101
|
-
switch (dateType) {
|
|
102
|
-
case 'received': {
|
|
103
|
-
history.receiveDate = dateToTimestamp(date);
|
|
104
|
-
break;
|
|
105
|
-
}
|
|
106
|
-
case 'rev-recd': {
|
|
107
|
-
history.revisionReceiveDate = dateToTimestamp(date);
|
|
108
|
-
break;
|
|
109
|
-
}
|
|
110
|
-
case 'accepted': {
|
|
111
|
-
history.acceptanceDate = dateToTimestamp(date);
|
|
112
|
-
break;
|
|
113
|
-
}
|
|
114
|
-
case 'rev-request': {
|
|
115
|
-
history.revisionRequestDate = dateToTimestamp(date);
|
|
116
|
-
break;
|
|
117
|
-
}
|
|
118
|
-
case 'retracted': {
|
|
119
|
-
history.retractionDate = dateToTimestamp(date);
|
|
120
|
-
break;
|
|
121
|
-
}
|
|
122
|
-
case 'corrected': {
|
|
123
|
-
history.correctionDate = dateToTimestamp(date);
|
|
124
|
-
break;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
return history;
|
|
129
|
-
},
|
|
130
|
-
parseAffiliations(elements) {
|
|
131
|
-
const affiliationIDs = new Map();
|
|
132
|
-
const affiliations = elements.map((element, priority) => {
|
|
133
|
-
var _a, _b;
|
|
134
|
-
const affiliation = buildAffiliation('', priority);
|
|
135
|
-
for (const node of element.querySelectorAll('institution')) {
|
|
136
|
-
const content = (_a = node.textContent) === null || _a === void 0 ? void 0 : _a.trim();
|
|
137
|
-
if (!content) {
|
|
138
|
-
continue;
|
|
139
|
-
}
|
|
140
|
-
const type = node.getAttribute('content-type');
|
|
141
|
-
if (type === 'dept') {
|
|
142
|
-
affiliation.department = content;
|
|
143
|
-
}
|
|
144
|
-
else {
|
|
145
|
-
affiliation.institution = content;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
affiliation.addressLine1 =
|
|
149
|
-
getTrimmedTextContent(element, 'addr-line:nth-of-type(1)') || undefined;
|
|
150
|
-
affiliation.addressLine2 =
|
|
151
|
-
getTrimmedTextContent(element, 'addr-line:nth-of-type(2)') || undefined;
|
|
152
|
-
affiliation.addressLine3 =
|
|
153
|
-
getTrimmedTextContent(element, 'addr-line:nth-of-type(3)') || undefined;
|
|
154
|
-
affiliation.postCode =
|
|
155
|
-
getTrimmedTextContent(element, 'postal-code') || undefined;
|
|
156
|
-
affiliation.country =
|
|
157
|
-
getTrimmedTextContent(element, 'country') || undefined;
|
|
158
|
-
const email = element.querySelector('email');
|
|
159
|
-
if (email) {
|
|
160
|
-
affiliation.email = {
|
|
161
|
-
href: email.getAttributeNS(XLINK_NAMESPACE, 'href') || undefined,
|
|
162
|
-
text: ((_b = email.textContent) === null || _b === void 0 ? void 0 : _b.trim()) || undefined,
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
const id = element.getAttribute('id');
|
|
166
|
-
if (id) {
|
|
167
|
-
affiliationIDs.set(id, affiliation._id);
|
|
168
|
-
}
|
|
169
|
-
return affiliation;
|
|
170
|
-
});
|
|
171
|
-
return {
|
|
172
|
-
affiliations,
|
|
173
|
-
affiliationIDs,
|
|
174
|
-
};
|
|
175
|
-
},
|
|
176
|
-
parseAuthorNotes(element) {
|
|
177
|
-
if (!element) {
|
|
178
|
-
return {
|
|
179
|
-
footnotes: [],
|
|
180
|
-
footnoteIDs: new Map(),
|
|
181
|
-
authorNotes: [],
|
|
182
|
-
authorNotesParagraphs: [],
|
|
183
|
-
correspondingIDs: new Map(),
|
|
184
|
-
correspondingList: [],
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
const { footnotes, footnoteIDs } = this.parseFootnotes([
|
|
188
|
-
...element.querySelectorAll('fn:not([fn-type])'),
|
|
189
|
-
]);
|
|
190
|
-
const authorNotesParagraphs = this.parseParagraphs([
|
|
191
|
-
...element.querySelectorAll(':scope > p'),
|
|
192
|
-
]);
|
|
193
|
-
const { correspondingList, correspondingIDs } = this.parseCorresp([
|
|
194
|
-
...element.querySelectorAll('corresp'),
|
|
195
|
-
]);
|
|
196
|
-
const authorNotes = [
|
|
197
|
-
buildAuthorNotes([
|
|
198
|
-
...correspondingIDs.values(),
|
|
199
|
-
...footnoteIDs.values(),
|
|
200
|
-
...authorNotesParagraphs.map((p) => p._id),
|
|
201
|
-
]),
|
|
202
|
-
];
|
|
203
|
-
return {
|
|
204
|
-
footnotes,
|
|
205
|
-
footnoteIDs,
|
|
206
|
-
authorNotesParagraphs,
|
|
207
|
-
authorNotes,
|
|
208
|
-
correspondingIDs,
|
|
209
|
-
correspondingList,
|
|
210
|
-
};
|
|
211
|
-
},
|
|
212
|
-
parseParagraphs(elements) {
|
|
213
|
-
return elements.map((p) => buildParagraph(p.innerHTML));
|
|
214
|
-
},
|
|
215
|
-
parseFootnotes(elements) {
|
|
216
|
-
const footnoteIDs = new Map();
|
|
217
|
-
const footnotes = elements.map((element) => {
|
|
218
|
-
const fn = buildFootnote('', element.innerHTML);
|
|
219
|
-
const id = element.getAttribute('id');
|
|
220
|
-
if (id) {
|
|
221
|
-
footnoteIDs.set(id, fn._id);
|
|
222
|
-
}
|
|
223
|
-
return fn;
|
|
224
|
-
});
|
|
225
|
-
return {
|
|
226
|
-
footnotes,
|
|
227
|
-
footnoteIDs,
|
|
228
|
-
};
|
|
229
|
-
},
|
|
230
|
-
parseCorresp(elements) {
|
|
231
|
-
const correspondingIDs = new Map();
|
|
232
|
-
const correspondingList = elements.map((element) => {
|
|
233
|
-
var _a, _b, _c;
|
|
234
|
-
const label = element.querySelector('label');
|
|
235
|
-
if (label) {
|
|
236
|
-
label.remove();
|
|
237
|
-
}
|
|
238
|
-
const corresponding = buildCorresp((_b = (_a = element.textContent) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : '');
|
|
239
|
-
corresponding.label = ((_c = label === null || label === void 0 ? void 0 : label.textContent) === null || _c === void 0 ? void 0 : _c.trim()) || undefined;
|
|
240
|
-
const id = element.getAttribute('id');
|
|
241
|
-
if (id) {
|
|
242
|
-
correspondingIDs.set(id, corresponding._id);
|
|
243
|
-
}
|
|
244
|
-
return corresponding;
|
|
245
|
-
});
|
|
246
|
-
return {
|
|
247
|
-
correspondingList,
|
|
248
|
-
correspondingIDs,
|
|
249
|
-
};
|
|
250
|
-
},
|
|
251
|
-
parseContributors(elements, affiliationIDs, footnoteIDs, correspondingIDs) {
|
|
252
|
-
return elements.map((element, priority) => {
|
|
253
|
-
var _a, _b;
|
|
254
|
-
const name = buildBibliographicName({});
|
|
255
|
-
const given = getTrimmedTextContent(element, 'name > given-names');
|
|
256
|
-
if (given) {
|
|
257
|
-
name.given = given;
|
|
258
|
-
}
|
|
259
|
-
const surname = getTrimmedTextContent(element, 'name > surname');
|
|
260
|
-
if (surname) {
|
|
261
|
-
name.family = surname;
|
|
262
|
-
}
|
|
263
|
-
const contributor = buildContributor(name, 'author', priority);
|
|
264
|
-
const corresponding = element.getAttribute('corresp') === 'yes';
|
|
265
|
-
if (corresponding) {
|
|
266
|
-
contributor.isCorresponding = corresponding;
|
|
267
|
-
}
|
|
268
|
-
const orcid = getTrimmedTextContent(element, 'contrib-id[contrib-id-type="orcid"]');
|
|
269
|
-
if (orcid) {
|
|
270
|
-
contributor.ORCIDIdentifier = orcid;
|
|
271
|
-
}
|
|
272
|
-
const xrefs = element.querySelectorAll('xref');
|
|
273
|
-
for (const xref of xrefs) {
|
|
274
|
-
if (xref) {
|
|
275
|
-
const rid = xref.getAttribute('rid');
|
|
276
|
-
const type = xref.getAttribute('ref-type');
|
|
277
|
-
if (rid) {
|
|
278
|
-
if (type === 'fn') {
|
|
279
|
-
contributor.footnote = [];
|
|
280
|
-
const footnoteID = footnoteIDs.get(rid);
|
|
281
|
-
if (footnoteID) {
|
|
282
|
-
const authorFootNoteRef = {
|
|
283
|
-
noteID: footnoteID,
|
|
284
|
-
noteLabel: ((_a = xref.textContent) === null || _a === void 0 ? void 0 : _a.trim()) || '',
|
|
285
|
-
};
|
|
286
|
-
contributor.footnote.push(authorFootNoteRef);
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
else if (type === 'corresp') {
|
|
290
|
-
contributor.corresp = [];
|
|
291
|
-
const correspID = correspondingIDs.get(rid);
|
|
292
|
-
if (correspID) {
|
|
293
|
-
const authorCorrespRef = {
|
|
294
|
-
correspID: correspID,
|
|
295
|
-
correspLabel: ((_b = xref.textContent) === null || _b === void 0 ? void 0 : _b.trim()) || '',
|
|
296
|
-
};
|
|
297
|
-
contributor.corresp.push(authorCorrespRef);
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
else if (type === 'aff') {
|
|
301
|
-
const rids = rid
|
|
302
|
-
.split(/\s+/)
|
|
303
|
-
.map((id) => affiliationIDs.get(id))
|
|
304
|
-
.filter(Boolean);
|
|
305
|
-
if (rids.length) {
|
|
306
|
-
contributor.affiliations = rids;
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
return contributor;
|
|
313
|
-
});
|
|
314
|
-
},
|
|
315
|
-
};
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* © 2020 Atypon Systems LLC
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import { getTrimmedTextContent } from '../../lib/utils';
|
|
17
|
-
import { buildBibliographicDate, buildBibliographicName, buildBibliographyItem, } from '../../transformer/builders';
|
|
18
|
-
import { isJATSComment, parseJATSComment } from './jats-comments';
|
|
19
|
-
import { htmlFromJatsNode } from './jats-parser-utils';
|
|
20
|
-
import { References } from './jats-references';
|
|
21
|
-
const chooseBibliographyItemType = (publicationType) => {
|
|
22
|
-
switch (publicationType) {
|
|
23
|
-
case 'book':
|
|
24
|
-
case 'thesis':
|
|
25
|
-
return publicationType;
|
|
26
|
-
case 'journal':
|
|
27
|
-
default:
|
|
28
|
-
return 'article-journal';
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
export const jatsReferenceParser = {
|
|
32
|
-
parseReferences(elements, createElement) {
|
|
33
|
-
const references = new References();
|
|
34
|
-
elements.forEach((element) => {
|
|
35
|
-
var _a;
|
|
36
|
-
const publicationType = element.getAttribute('publication-type');
|
|
37
|
-
const authorNodes = [
|
|
38
|
-
...element.querySelectorAll('person-group[person-group-type="author"] > *'),
|
|
39
|
-
];
|
|
40
|
-
const bibliographyItem = buildBibliographyItem({
|
|
41
|
-
type: chooseBibliographyItemType(publicationType),
|
|
42
|
-
});
|
|
43
|
-
const titleNode = element.querySelector('article-title');
|
|
44
|
-
if (titleNode) {
|
|
45
|
-
bibliographyItem.title = (_a = htmlFromJatsNode(titleNode, createElement)) === null || _a === void 0 ? void 0 : _a.trim();
|
|
46
|
-
}
|
|
47
|
-
const comments = [];
|
|
48
|
-
const mixedCitation = element.querySelector('mixed-citation');
|
|
49
|
-
mixedCitation === null || mixedCitation === void 0 ? void 0 : mixedCitation.childNodes.forEach((item) => {
|
|
50
|
-
if (isJATSComment(item)) {
|
|
51
|
-
const comment = parseJATSComment(item);
|
|
52
|
-
if (comment) {
|
|
53
|
-
comments.push(comment);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
if (authorNodes.length <= 0) {
|
|
58
|
-
mixedCitation === null || mixedCitation === void 0 ? void 0 : mixedCitation.childNodes.forEach((item) => {
|
|
59
|
-
var _a, _b, _c;
|
|
60
|
-
if (item.nodeType === Node.TEXT_NODE &&
|
|
61
|
-
((_a = item.textContent) === null || _a === void 0 ? void 0 : _a.match(/[A-Za-z]+/g))) {
|
|
62
|
-
bibliographyItem.literal = (_c = (_b = mixedCitation.textContent) === null || _b === void 0 ? void 0 : _b.trim()) !== null && _c !== void 0 ? _c : '';
|
|
63
|
-
return bibliographyItem;
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
const source = getTrimmedTextContent(element, 'source');
|
|
68
|
-
if (source) {
|
|
69
|
-
bibliographyItem['container-title'] = source;
|
|
70
|
-
}
|
|
71
|
-
const volume = getTrimmedTextContent(element, 'volume');
|
|
72
|
-
if (volume) {
|
|
73
|
-
bibliographyItem.volume = volume;
|
|
74
|
-
}
|
|
75
|
-
const issue = getTrimmedTextContent(element, 'issue');
|
|
76
|
-
if (issue) {
|
|
77
|
-
bibliographyItem.issue = issue;
|
|
78
|
-
}
|
|
79
|
-
const supplement = getTrimmedTextContent(element, 'supplement');
|
|
80
|
-
if (supplement) {
|
|
81
|
-
bibliographyItem.supplement = supplement;
|
|
82
|
-
}
|
|
83
|
-
const fpage = getTrimmedTextContent(element, 'fpage');
|
|
84
|
-
const lpage = getTrimmedTextContent(element, 'lpage');
|
|
85
|
-
if (fpage) {
|
|
86
|
-
bibliographyItem.page = lpage ? `${fpage}-${lpage}` : fpage;
|
|
87
|
-
}
|
|
88
|
-
const year = getTrimmedTextContent(element, 'year');
|
|
89
|
-
if (year) {
|
|
90
|
-
bibliographyItem.issued = buildBibliographicDate({
|
|
91
|
-
'date-parts': [[year]],
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
const doi = getTrimmedTextContent(element, 'pub-id[pub-id-type="doi"]');
|
|
95
|
-
if (doi) {
|
|
96
|
-
bibliographyItem.DOI = doi;
|
|
97
|
-
}
|
|
98
|
-
const authors = [];
|
|
99
|
-
authorNodes.forEach((authorNode) => {
|
|
100
|
-
var _a;
|
|
101
|
-
const name = buildBibliographicName({});
|
|
102
|
-
const given = getTrimmedTextContent(authorNode, 'given-names');
|
|
103
|
-
if (given) {
|
|
104
|
-
name.given = given;
|
|
105
|
-
}
|
|
106
|
-
const family = getTrimmedTextContent(authorNode, 'surname');
|
|
107
|
-
if (family) {
|
|
108
|
-
name.family = family;
|
|
109
|
-
}
|
|
110
|
-
const suffix = getTrimmedTextContent(authorNode, 'suffix');
|
|
111
|
-
if (suffix) {
|
|
112
|
-
name.suffix = suffix;
|
|
113
|
-
}
|
|
114
|
-
if (authorNode.nodeName === 'collab') {
|
|
115
|
-
name.literal = (_a = authorNode.textContent) === null || _a === void 0 ? void 0 : _a.trim();
|
|
116
|
-
}
|
|
117
|
-
authors.push(name);
|
|
118
|
-
});
|
|
119
|
-
if (authors.length) {
|
|
120
|
-
bibliographyItem.author = authors;
|
|
121
|
-
}
|
|
122
|
-
const id = element.getAttribute('id');
|
|
123
|
-
references.add(bibliographyItem, id, comments);
|
|
124
|
-
});
|
|
125
|
-
return references;
|
|
126
|
-
},
|
|
127
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
export class References {
|
|
2
|
-
constructor() {
|
|
3
|
-
this.items = new Map();
|
|
4
|
-
this.IDs = new Map();
|
|
5
|
-
this.comments = new Map();
|
|
6
|
-
}
|
|
7
|
-
add(item, id, comments) {
|
|
8
|
-
this.items.set(item._id, item);
|
|
9
|
-
this.comments.set(item._id, comments);
|
|
10
|
-
if (id) {
|
|
11
|
-
this.IDs.set(id, item._id);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
getBibliographyItems() {
|
|
15
|
-
return [...this.items.values()];
|
|
16
|
-
}
|
|
17
|
-
getComments(id) {
|
|
18
|
-
return this.getValue(id, this.comments) || [];
|
|
19
|
-
}
|
|
20
|
-
getValue(id, map) {
|
|
21
|
-
const value = map.get(id);
|
|
22
|
-
if (value) {
|
|
23
|
-
return value;
|
|
24
|
-
}
|
|
25
|
-
const id2 = this.IDs.get(id);
|
|
26
|
-
if (id2) {
|
|
27
|
-
return map.get(id2);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* © 2019 Atypon Systems LLC
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import projectDump from '../../../__tests__/data/project-dump.json';
|
|
17
|
-
import { Decoder } from '../../decode';
|
|
18
|
-
export const createTestModelMap = () => {
|
|
19
|
-
const modelMap = new Map();
|
|
20
|
-
for (const component of projectDump.data) {
|
|
21
|
-
modelMap.set(component._id, component);
|
|
22
|
-
}
|
|
23
|
-
return modelMap;
|
|
24
|
-
};
|
|
25
|
-
export const createTestDoc = () => {
|
|
26
|
-
const modelMap = createTestModelMap();
|
|
27
|
-
const decoder = new Decoder(modelMap);
|
|
28
|
-
return decoder.createArticleNode();
|
|
29
|
-
};
|