@manuscripts/transform 3.0.50-LEAN-4405.0 → 3.0.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/jats/exporter/jats-exporter.js +52 -145
- package/dist/cjs/jats/importer/jats-dom-parser.js +53 -124
- package/dist/cjs/schema/nodes/bibliography_item.js +1 -17
- package/dist/cjs/version.js +1 -1
- package/dist/es/jats/exporter/jats-exporter.js +52 -145
- package/dist/es/jats/importer/jats-dom-parser.js +53 -124
- package/dist/es/schema/nodes/bibliography_item.js +1 -17
- package/dist/es/version.js +1 -1
- package/dist/types/jats/importer/jats-dom-parser.d.ts +1 -0
- package/dist/types/schema/nodes/bibliography_item.d.ts +1 -22
- package/dist/types/version.d.ts +1 -1
- package/package.json +2 -2
- package/dist/cjs/schema/migration/migration-scripts/3.0.47.js +0 -19
- package/dist/es/schema/migration/migration-scripts/3.0.47.js +0 -17
- package/dist/types/schema/migration/migration-scripts/3.0.47.d.ts +0 -8
|
@@ -109,7 +109,22 @@ class JATSExporter {
|
|
|
109
109
|
if (!node) {
|
|
110
110
|
return undefined;
|
|
111
111
|
}
|
|
112
|
-
return
|
|
112
|
+
return {
|
|
113
|
+
_id: node.attrs.id,
|
|
114
|
+
issued: node.attrs.issued,
|
|
115
|
+
DOI: node.attrs.doi,
|
|
116
|
+
manuscriptID,
|
|
117
|
+
objectType: json_schema_1.ObjectTypes.BibliographyItem,
|
|
118
|
+
author: node.attrs.author,
|
|
119
|
+
'container-title': node.attrs.containerTitle,
|
|
120
|
+
volume: node.attrs.volume,
|
|
121
|
+
issue: node.attrs.issue,
|
|
122
|
+
supplement: node.attrs.supplement,
|
|
123
|
+
page: node.attrs.page,
|
|
124
|
+
title: node.attrs.title,
|
|
125
|
+
literal: node.attrs.literal,
|
|
126
|
+
type: node.attrs.type,
|
|
127
|
+
};
|
|
113
128
|
};
|
|
114
129
|
};
|
|
115
130
|
this.serializeToJATS = async (manuscriptNode, options) => {
|
|
@@ -411,15 +426,19 @@ class JATSExporter {
|
|
|
411
426
|
const ref = this.document.createElement('ref');
|
|
412
427
|
ref.setAttribute('id', normalizeID(id));
|
|
413
428
|
const updateCitationPubType = (citationEl, pubType) => {
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
429
|
+
if (pubType) {
|
|
430
|
+
switch (pubType) {
|
|
431
|
+
case 'article':
|
|
432
|
+
case 'article-journal':
|
|
433
|
+
citationEl.setAttribute('publication-type', 'journal');
|
|
434
|
+
break;
|
|
435
|
+
default:
|
|
436
|
+
citationEl.setAttribute('publication-type', pubType);
|
|
437
|
+
break;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
else {
|
|
441
|
+
citationEl.setAttribute('publication-type', 'journal');
|
|
423
442
|
}
|
|
424
443
|
};
|
|
425
444
|
if (bibliographyItem.attrs.literal) {
|
|
@@ -432,52 +451,31 @@ class JATSExporter {
|
|
|
432
451
|
else {
|
|
433
452
|
const citation = this.document.createElement('element-citation');
|
|
434
453
|
updateCitationPubType(citation, bibliographyItem.attrs.type);
|
|
435
|
-
|
|
454
|
+
if (bibliographyItem.attrs.author) {
|
|
436
455
|
const personGroupNode = this.document.createElement('person-group');
|
|
437
|
-
personGroupNode.setAttribute('person-group-type',
|
|
456
|
+
personGroupNode.setAttribute('person-group-type', 'author');
|
|
438
457
|
citation.appendChild(personGroupNode);
|
|
439
|
-
|
|
458
|
+
bibliographyItem.attrs.author.forEach((author) => {
|
|
440
459
|
const name = this.document.createElement('string-name');
|
|
441
|
-
if (
|
|
442
|
-
const
|
|
443
|
-
|
|
444
|
-
name.appendChild(
|
|
460
|
+
if (author.family) {
|
|
461
|
+
const node = this.document.createElement('surname');
|
|
462
|
+
node.textContent = author.family;
|
|
463
|
+
name.appendChild(node);
|
|
445
464
|
}
|
|
446
|
-
if (
|
|
447
|
-
const
|
|
448
|
-
|
|
449
|
-
name.appendChild(
|
|
465
|
+
if (author.given) {
|
|
466
|
+
const node = this.document.createElement('given-names');
|
|
467
|
+
node.textContent = author.given;
|
|
468
|
+
name.appendChild(node);
|
|
450
469
|
}
|
|
451
470
|
if (name.hasChildNodes()) {
|
|
452
471
|
personGroupNode.appendChild(name);
|
|
453
472
|
}
|
|
454
|
-
if (
|
|
473
|
+
if (author.literal) {
|
|
455
474
|
const collab = this.document.createElement('collab');
|
|
456
|
-
collab.textContent =
|
|
475
|
+
collab.textContent = author.literal;
|
|
457
476
|
personGroupNode.appendChild(collab);
|
|
458
477
|
}
|
|
459
478
|
});
|
|
460
|
-
};
|
|
461
|
-
if (bibliographyItem.attrs.author) {
|
|
462
|
-
appendPersonGroup('author', bibliographyItem.attrs.author);
|
|
463
|
-
}
|
|
464
|
-
if (bibliographyItem.attrs.editor) {
|
|
465
|
-
appendPersonGroup('editor', bibliographyItem.attrs.editor);
|
|
466
|
-
}
|
|
467
|
-
if (bibliographyItem.attrs.title) {
|
|
468
|
-
const node = this.document.createElement('article-title');
|
|
469
|
-
this.setTitleContent(node, bibliographyItem.attrs.title);
|
|
470
|
-
citation.appendChild(node);
|
|
471
|
-
}
|
|
472
|
-
if (bibliographyItem.attrs.containerTitle) {
|
|
473
|
-
const node = this.document.createElement('source');
|
|
474
|
-
this.setTitleContent(node, bibliographyItem.attrs.containerTitle);
|
|
475
|
-
citation.appendChild(node);
|
|
476
|
-
}
|
|
477
|
-
if (bibliographyItem.attrs['data-title']) {
|
|
478
|
-
const node = this.document.createElement('data-title');
|
|
479
|
-
this.setTitleContent(node, bibliographyItem.attrs['data-title']);
|
|
480
|
-
citation.appendChild(node);
|
|
481
479
|
}
|
|
482
480
|
if (bibliographyItem.attrs.issued) {
|
|
483
481
|
const dateParts = bibliographyItem.attrs.issued['date-parts'];
|
|
@@ -500,6 +498,16 @@ class JATSExporter {
|
|
|
500
498
|
}
|
|
501
499
|
}
|
|
502
500
|
}
|
|
501
|
+
if (bibliographyItem.attrs.title) {
|
|
502
|
+
const node = this.document.createElement('article-title');
|
|
503
|
+
this.setTitleContent(node, bibliographyItem.attrs.title);
|
|
504
|
+
citation.appendChild(node);
|
|
505
|
+
}
|
|
506
|
+
if (bibliographyItem.attrs.containerTitle) {
|
|
507
|
+
const node = this.document.createElement('source');
|
|
508
|
+
this.setTitleContent(node, bibliographyItem.attrs.containerTitle);
|
|
509
|
+
citation.appendChild(node);
|
|
510
|
+
}
|
|
503
511
|
if (bibliographyItem.attrs.volume) {
|
|
504
512
|
const node = this.document.createElement('volume');
|
|
505
513
|
node.textContent = String(bibliographyItem.attrs.volume);
|
|
@@ -543,107 +551,6 @@ class JATSExporter {
|
|
|
543
551
|
node.textContent = String(bibliographyItem.attrs.doi);
|
|
544
552
|
citation.appendChild(node);
|
|
545
553
|
}
|
|
546
|
-
if (bibliographyItem.attrs.pubIDs) {
|
|
547
|
-
for (const pubID of bibliographyItem.attrs.pubIDs) {
|
|
548
|
-
const node = this.document.createElement('pub-id');
|
|
549
|
-
node.setAttribute('pub-id-type', pubID.type);
|
|
550
|
-
node.textContent = pubID.content;
|
|
551
|
-
citation.appendChild(node);
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
if (bibliographyItem.attrs.std) {
|
|
555
|
-
const node = this.document.createElement('std');
|
|
556
|
-
node.textContent = String(bibliographyItem.attrs.std);
|
|
557
|
-
citation.appendChild(node);
|
|
558
|
-
}
|
|
559
|
-
if (bibliographyItem.attrs.series) {
|
|
560
|
-
const node = this.document.createElement('series');
|
|
561
|
-
node.textContent = String(bibliographyItem.attrs.series);
|
|
562
|
-
citation.appendChild(node);
|
|
563
|
-
}
|
|
564
|
-
if (bibliographyItem.attrs.edition) {
|
|
565
|
-
const node = this.document.createElement('edition');
|
|
566
|
-
node.textContent = String(bibliographyItem.attrs.edition);
|
|
567
|
-
citation.appendChild(node);
|
|
568
|
-
}
|
|
569
|
-
if (bibliographyItem.attrs['publisher-place']) {
|
|
570
|
-
const node = this.document.createElement('publisher-loc');
|
|
571
|
-
node.textContent = String(bibliographyItem.attrs['publisher-place']);
|
|
572
|
-
citation.appendChild(node);
|
|
573
|
-
}
|
|
574
|
-
if (bibliographyItem.attrs.publisher) {
|
|
575
|
-
const node = this.document.createElement('publisher-name');
|
|
576
|
-
node.textContent = String(bibliographyItem.attrs.publisher);
|
|
577
|
-
citation.appendChild(node);
|
|
578
|
-
}
|
|
579
|
-
if (bibliographyItem.attrs.event) {
|
|
580
|
-
const node = this.document.createElement('conf-name');
|
|
581
|
-
node.textContent = String(bibliographyItem.attrs.event);
|
|
582
|
-
citation.appendChild(node);
|
|
583
|
-
}
|
|
584
|
-
if (bibliographyItem.attrs['event-place']) {
|
|
585
|
-
const node = this.document.createElement('conf-loc');
|
|
586
|
-
node.textContent = String(bibliographyItem.attrs['event-place']);
|
|
587
|
-
citation.appendChild(node);
|
|
588
|
-
}
|
|
589
|
-
const buildISODate = (date) => {
|
|
590
|
-
const dateParts = date['date-parts'];
|
|
591
|
-
if (dateParts && dateParts.length) {
|
|
592
|
-
const [[year, month, day]] = dateParts;
|
|
593
|
-
if (year && month && day) {
|
|
594
|
-
return new Date(Date.UTC(Number(year), Number(month) - 1, Number(day)));
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
};
|
|
598
|
-
const eventDate = bibliographyItem.attrs['event-date'];
|
|
599
|
-
if (eventDate) {
|
|
600
|
-
const isoDate = buildISODate(eventDate);
|
|
601
|
-
if (isoDate) {
|
|
602
|
-
const node = this.document.createElement('conf-date');
|
|
603
|
-
node.setAttribute('iso-8601-date', isoDate.toISOString());
|
|
604
|
-
node.textContent = isoDate.toDateString();
|
|
605
|
-
citation.appendChild(node);
|
|
606
|
-
}
|
|
607
|
-
}
|
|
608
|
-
if (bibliographyItem.attrs['number-of-pages']) {
|
|
609
|
-
const node = this.document.createElement('size');
|
|
610
|
-
node.textContent = String(bibliographyItem.attrs['number-of-pages']);
|
|
611
|
-
node.setAttribute('units', 'pages');
|
|
612
|
-
citation.appendChild(node);
|
|
613
|
-
}
|
|
614
|
-
if (bibliographyItem.attrs.volume) {
|
|
615
|
-
const node = this.document.createElement('volume');
|
|
616
|
-
node.textContent = String(bibliographyItem.attrs.volume);
|
|
617
|
-
citation.appendChild(node);
|
|
618
|
-
}
|
|
619
|
-
const dateInCitation = bibliographyItem.attrs['date-in-citation'];
|
|
620
|
-
if (dateInCitation) {
|
|
621
|
-
const isoDate = buildISODate(dateInCitation);
|
|
622
|
-
if (isoDate) {
|
|
623
|
-
const node = this.document.createElement('date-in-citation');
|
|
624
|
-
node.setAttribute('iso-8601-date', isoDate.toISOString());
|
|
625
|
-
node.textContent = isoDate.toDateString();
|
|
626
|
-
citation.appendChild(node);
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
if (bibliographyItem.attrs.institution) {
|
|
630
|
-
const node = this.document.createElement('institution');
|
|
631
|
-
node.textContent = String(bibliographyItem.attrs.institution);
|
|
632
|
-
citation.appendChild(node);
|
|
633
|
-
}
|
|
634
|
-
if (bibliographyItem.attrs.elocationID) {
|
|
635
|
-
const node = this.document.createElement('elocation-id');
|
|
636
|
-
node.textContent = String(bibliographyItem.attrs.elocationID);
|
|
637
|
-
citation.appendChild(node);
|
|
638
|
-
}
|
|
639
|
-
if (bibliographyItem.attrs.links) {
|
|
640
|
-
for (const link of bibliographyItem.attrs.links) {
|
|
641
|
-
const node = this.document.createElement('ext-link');
|
|
642
|
-
node.setAttribute('ext-link-type', link.type);
|
|
643
|
-
node.textContent = link.content;
|
|
644
|
-
citation.appendChild(node);
|
|
645
|
-
}
|
|
646
|
-
}
|
|
647
554
|
ref.appendChild(citation);
|
|
648
555
|
refList.appendChild(ref);
|
|
649
556
|
}
|
|
@@ -134,161 +134,90 @@ class JATSDOMParser {
|
|
|
134
134
|
this.getHTMLContent = (node, querySelector) => {
|
|
135
135
|
return (0, jats_parser_utils_1.htmlFromJatsNode)(node.querySelector(querySelector));
|
|
136
136
|
};
|
|
137
|
+
this.chooseBibliographyItemType = (publicationType) => {
|
|
138
|
+
switch (publicationType) {
|
|
139
|
+
case 'book':
|
|
140
|
+
case 'thesis':
|
|
141
|
+
return publicationType;
|
|
142
|
+
case 'journal':
|
|
143
|
+
default:
|
|
144
|
+
return 'article-journal';
|
|
145
|
+
}
|
|
146
|
+
};
|
|
137
147
|
this.parseRef = (element) => {
|
|
138
|
-
|
|
139
|
-
const
|
|
140
|
-
|
|
148
|
+
const publicationType = element.getAttribute('publication-type');
|
|
149
|
+
const authorNodes = [
|
|
150
|
+
...element.querySelectorAll('person-group[person-group-type="author"] > *'),
|
|
151
|
+
];
|
|
141
152
|
const id = element.id;
|
|
142
|
-
const publicationType = (_a = elementCitation === null || elementCitation === void 0 ? void 0 : elementCitation.getAttribute('publication-type')) !== null && _a !== void 0 ? _a : mixedCitation === null || mixedCitation === void 0 ? void 0 : mixedCitation.getAttribute('publication-type');
|
|
143
153
|
const attrs = {
|
|
144
154
|
id,
|
|
145
|
-
type: publicationType
|
|
146
|
-
? 'article-journal'
|
|
147
|
-
: publicationType !== null && publicationType !== void 0 ? publicationType : 'article-journal',
|
|
155
|
+
type: this.chooseBibliographyItemType(publicationType),
|
|
148
156
|
};
|
|
149
157
|
const title = this.getHTMLContent(element, 'article-title');
|
|
150
158
|
if (title) {
|
|
151
159
|
attrs.title = title;
|
|
152
160
|
}
|
|
153
|
-
const
|
|
154
|
-
if (
|
|
155
|
-
attrs.containerTitle = containerTitle;
|
|
156
|
-
}
|
|
157
|
-
const dataTitle = this.getHTMLContent(element, 'data-title');
|
|
158
|
-
if (dataTitle) {
|
|
159
|
-
attrs['data-title'] = dataTitle;
|
|
160
|
-
}
|
|
161
|
-
const authorNodes = [
|
|
162
|
-
...element.querySelectorAll('person-group[person-group-type="author"] > *'),
|
|
163
|
-
];
|
|
164
|
-
const editorNodes = [
|
|
165
|
-
...element.querySelectorAll('person-group[person-group-type="editor"] > *'),
|
|
166
|
-
];
|
|
167
|
-
if (authorNodes.length === 0) {
|
|
161
|
+
const mixedCitation = element.querySelector('mixed-citation');
|
|
162
|
+
if (authorNodes.length <= 0) {
|
|
168
163
|
mixedCitation === null || mixedCitation === void 0 ? void 0 : mixedCitation.childNodes.forEach((item) => {
|
|
169
164
|
var _a, _b;
|
|
170
165
|
if (item.nodeType === Node.TEXT_NODE &&
|
|
171
166
|
((_a = item.textContent) === null || _a === void 0 ? void 0 : _a.match(/[A-Za-z]+/g))) {
|
|
172
167
|
attrs.literal = (_b = (0, utils_1.getTrimmedTextContent)(mixedCitation)) !== null && _b !== void 0 ? _b : '';
|
|
168
|
+
return attrs;
|
|
173
169
|
}
|
|
174
170
|
});
|
|
175
171
|
}
|
|
176
|
-
const
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
const isoDateParts = isoDate === null || isoDate === void 0 ? void 0 : isoDate.split('-');
|
|
180
|
-
return (0, json_schema_1.buildBibliographicDate)({
|
|
181
|
-
'date-parts': [
|
|
182
|
-
[
|
|
183
|
-
(_a = isoDateParts === null || isoDateParts === void 0 ? void 0 : isoDateParts[0]) !== null && _a !== void 0 ? _a : '',
|
|
184
|
-
(_b = isoDateParts === null || isoDateParts === void 0 ? void 0 : isoDateParts[1]) !== null && _b !== void 0 ? _b : '',
|
|
185
|
-
(_c = isoDateParts === null || isoDateParts === void 0 ? void 0 : isoDateParts[2]) !== null && _c !== void 0 ? _c : '',
|
|
186
|
-
],
|
|
187
|
-
],
|
|
188
|
-
});
|
|
189
|
-
};
|
|
190
|
-
const buildName = (node) => {
|
|
191
|
-
const name = (0, json_schema_1.buildBibliographicName)({});
|
|
192
|
-
const given = (0, utils_1.getTrimmedTextContent)(node, 'given-names');
|
|
193
|
-
const family = (0, utils_1.getTrimmedTextContent)(node, 'surname');
|
|
194
|
-
if (given) {
|
|
195
|
-
name.given = given;
|
|
196
|
-
}
|
|
197
|
-
if (family) {
|
|
198
|
-
name.family = family;
|
|
199
|
-
}
|
|
200
|
-
if (node.nodeName === 'collab') {
|
|
201
|
-
name.literal = (0, utils_1.getTrimmedTextContent)(node);
|
|
202
|
-
}
|
|
203
|
-
return name;
|
|
204
|
-
};
|
|
205
|
-
if (authorNodes.length) {
|
|
206
|
-
attrs.author = authorNodes.map(buildName);
|
|
207
|
-
}
|
|
208
|
-
if (editorNodes.length) {
|
|
209
|
-
attrs.editor = editorNodes.map(buildName);
|
|
210
|
-
}
|
|
211
|
-
const getText = (selector) => (0, utils_1.getTrimmedTextContent)(element, selector);
|
|
212
|
-
if (getText('volume')) {
|
|
213
|
-
attrs.volume = getText('volume');
|
|
214
|
-
}
|
|
215
|
-
if (getText('issue')) {
|
|
216
|
-
attrs.issue = getText('issue');
|
|
217
|
-
}
|
|
218
|
-
if (getText('supplement')) {
|
|
219
|
-
attrs.supplement = getText('supplement');
|
|
220
|
-
}
|
|
221
|
-
if (getText('pub-id[pub-id-type="doi"]')) {
|
|
222
|
-
attrs.doi = getText('pub-id[pub-id-type="doi"]');
|
|
223
|
-
}
|
|
224
|
-
if (getText('std')) {
|
|
225
|
-
attrs.std = getText('std');
|
|
226
|
-
}
|
|
227
|
-
if (getText('series')) {
|
|
228
|
-
attrs.series = getText('series');
|
|
229
|
-
}
|
|
230
|
-
if (getText('edition')) {
|
|
231
|
-
attrs.edition = getText('edition');
|
|
232
|
-
}
|
|
233
|
-
if (getText('publisher-name')) {
|
|
234
|
-
attrs.publisher = getText('publisher-name');
|
|
172
|
+
const source = this.getHTMLContent(element, 'source');
|
|
173
|
+
if (source) {
|
|
174
|
+
attrs.containerTitle = source;
|
|
235
175
|
}
|
|
236
|
-
|
|
237
|
-
|
|
176
|
+
const volume = (0, utils_1.getTrimmedTextContent)(element, 'volume');
|
|
177
|
+
if (volume) {
|
|
178
|
+
attrs.volume = volume;
|
|
238
179
|
}
|
|
239
|
-
|
|
240
|
-
|
|
180
|
+
const issue = (0, utils_1.getTrimmedTextContent)(element, 'issue');
|
|
181
|
+
if (issue) {
|
|
182
|
+
attrs.issue = issue;
|
|
241
183
|
}
|
|
242
|
-
|
|
243
|
-
|
|
184
|
+
const supplement = (0, utils_1.getTrimmedTextContent)(element, 'supplement');
|
|
185
|
+
if (supplement) {
|
|
186
|
+
attrs.supplement = supplement;
|
|
244
187
|
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
}
|
|
248
|
-
if (getText('institution')) {
|
|
249
|
-
attrs.institution = getText('institution');
|
|
250
|
-
}
|
|
251
|
-
if (getText('elocation-id')) {
|
|
252
|
-
attrs.elocationID = getText('elocation-id');
|
|
253
|
-
}
|
|
254
|
-
const fpage = getText('fpage');
|
|
255
|
-
const lpage = getText('lpage');
|
|
188
|
+
const fpage = (0, utils_1.getTrimmedTextContent)(element, 'fpage');
|
|
189
|
+
const lpage = (0, utils_1.getTrimmedTextContent)(element, 'lpage');
|
|
256
190
|
if (fpage) {
|
|
257
191
|
attrs.page = lpage ? `${fpage}-${lpage}` : fpage;
|
|
258
192
|
}
|
|
259
|
-
const year =
|
|
193
|
+
const year = (0, utils_1.getTrimmedTextContent)(element, 'year');
|
|
260
194
|
if (year) {
|
|
261
195
|
attrs.issued = (0, json_schema_1.buildBibliographicDate)({
|
|
262
|
-
'date-parts': [[year
|
|
196
|
+
'date-parts': [[year]],
|
|
263
197
|
});
|
|
264
198
|
}
|
|
265
|
-
const
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
}));
|
|
269
|
-
if (pubIDs.length) {
|
|
270
|
-
attrs.pubIDs = pubIDs;
|
|
199
|
+
const doi = (0, utils_1.getTrimmedTextContent)(element, 'pub-id[pub-id-type="doi"]');
|
|
200
|
+
if (doi) {
|
|
201
|
+
attrs.doi = doi;
|
|
271
202
|
}
|
|
272
|
-
const
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
}
|
|
279
|
-
const dateInCitation = element.querySelector('date-in-citation');
|
|
280
|
-
if (dateInCitation) {
|
|
281
|
-
const date = buildDate(dateInCitation);
|
|
282
|
-
if (date) {
|
|
283
|
-
attrs['date-in-citation'] = date;
|
|
203
|
+
const authors = [];
|
|
204
|
+
authorNodes.forEach((authorNode) => {
|
|
205
|
+
const name = (0, json_schema_1.buildBibliographicName)({});
|
|
206
|
+
const given = (0, utils_1.getTrimmedTextContent)(authorNode, 'given-names');
|
|
207
|
+
if (given) {
|
|
208
|
+
name.given = given;
|
|
284
209
|
}
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
if (
|
|
290
|
-
|
|
210
|
+
const family = (0, utils_1.getTrimmedTextContent)(authorNode, 'surname');
|
|
211
|
+
if (family) {
|
|
212
|
+
name.family = family;
|
|
213
|
+
}
|
|
214
|
+
if (authorNode.nodeName === 'collab') {
|
|
215
|
+
name.literal = (0, utils_1.getTrimmedTextContent)(authorNode);
|
|
291
216
|
}
|
|
217
|
+
authors.push(name);
|
|
218
|
+
});
|
|
219
|
+
if (authors.length) {
|
|
220
|
+
attrs.author = authors;
|
|
292
221
|
}
|
|
293
222
|
return attrs;
|
|
294
223
|
};
|
|
@@ -22,31 +22,15 @@ exports.bibliographyItem = {
|
|
|
22
22
|
id: { default: '' },
|
|
23
23
|
type: { default: undefined },
|
|
24
24
|
author: { default: undefined },
|
|
25
|
-
doi: { default: undefined },
|
|
26
25
|
issued: { default: undefined },
|
|
27
26
|
containerTitle: { default: undefined },
|
|
27
|
+
doi: { default: undefined },
|
|
28
28
|
volume: { default: undefined },
|
|
29
29
|
issue: { default: undefined },
|
|
30
30
|
supplement: { default: undefined },
|
|
31
31
|
page: { default: undefined },
|
|
32
32
|
title: { default: undefined },
|
|
33
33
|
literal: { default: undefined },
|
|
34
|
-
'data-title': { default: undefined },
|
|
35
|
-
std: { default: undefined },
|
|
36
|
-
series: { default: undefined },
|
|
37
|
-
edition: { default: undefined },
|
|
38
|
-
publisher: { default: undefined },
|
|
39
|
-
'publisher-place': { default: undefined },
|
|
40
|
-
event: { default: undefined },
|
|
41
|
-
'event-place': { default: undefined },
|
|
42
|
-
'event-date': { default: undefined },
|
|
43
|
-
institution: { default: undefined },
|
|
44
|
-
editor: { default: undefined },
|
|
45
|
-
elocationID: { default: undefined },
|
|
46
|
-
links: { default: undefined },
|
|
47
|
-
'number-of-pages': { default: undefined },
|
|
48
|
-
pubIDs: { default: undefined },
|
|
49
|
-
'date-in-citation': { default: undefined },
|
|
50
34
|
dataTracked: { default: null },
|
|
51
35
|
},
|
|
52
36
|
selectable: false,
|
package/dist/cjs/version.js
CHANGED
|
@@ -101,7 +101,22 @@ export class JATSExporter {
|
|
|
101
101
|
if (!node) {
|
|
102
102
|
return undefined;
|
|
103
103
|
}
|
|
104
|
-
return
|
|
104
|
+
return {
|
|
105
|
+
_id: node.attrs.id,
|
|
106
|
+
issued: node.attrs.issued,
|
|
107
|
+
DOI: node.attrs.doi,
|
|
108
|
+
manuscriptID,
|
|
109
|
+
objectType: ObjectTypes.BibliographyItem,
|
|
110
|
+
author: node.attrs.author,
|
|
111
|
+
'container-title': node.attrs.containerTitle,
|
|
112
|
+
volume: node.attrs.volume,
|
|
113
|
+
issue: node.attrs.issue,
|
|
114
|
+
supplement: node.attrs.supplement,
|
|
115
|
+
page: node.attrs.page,
|
|
116
|
+
title: node.attrs.title,
|
|
117
|
+
literal: node.attrs.literal,
|
|
118
|
+
type: node.attrs.type,
|
|
119
|
+
};
|
|
105
120
|
};
|
|
106
121
|
};
|
|
107
122
|
this.serializeToJATS = async (manuscriptNode, options) => {
|
|
@@ -403,15 +418,19 @@ export class JATSExporter {
|
|
|
403
418
|
const ref = this.document.createElement('ref');
|
|
404
419
|
ref.setAttribute('id', normalizeID(id));
|
|
405
420
|
const updateCitationPubType = (citationEl, pubType) => {
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
421
|
+
if (pubType) {
|
|
422
|
+
switch (pubType) {
|
|
423
|
+
case 'article':
|
|
424
|
+
case 'article-journal':
|
|
425
|
+
citationEl.setAttribute('publication-type', 'journal');
|
|
426
|
+
break;
|
|
427
|
+
default:
|
|
428
|
+
citationEl.setAttribute('publication-type', pubType);
|
|
429
|
+
break;
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
else {
|
|
433
|
+
citationEl.setAttribute('publication-type', 'journal');
|
|
415
434
|
}
|
|
416
435
|
};
|
|
417
436
|
if (bibliographyItem.attrs.literal) {
|
|
@@ -424,52 +443,31 @@ export class JATSExporter {
|
|
|
424
443
|
else {
|
|
425
444
|
const citation = this.document.createElement('element-citation');
|
|
426
445
|
updateCitationPubType(citation, bibliographyItem.attrs.type);
|
|
427
|
-
|
|
446
|
+
if (bibliographyItem.attrs.author) {
|
|
428
447
|
const personGroupNode = this.document.createElement('person-group');
|
|
429
|
-
personGroupNode.setAttribute('person-group-type',
|
|
448
|
+
personGroupNode.setAttribute('person-group-type', 'author');
|
|
430
449
|
citation.appendChild(personGroupNode);
|
|
431
|
-
|
|
450
|
+
bibliographyItem.attrs.author.forEach((author) => {
|
|
432
451
|
const name = this.document.createElement('string-name');
|
|
433
|
-
if (
|
|
434
|
-
const
|
|
435
|
-
|
|
436
|
-
name.appendChild(
|
|
452
|
+
if (author.family) {
|
|
453
|
+
const node = this.document.createElement('surname');
|
|
454
|
+
node.textContent = author.family;
|
|
455
|
+
name.appendChild(node);
|
|
437
456
|
}
|
|
438
|
-
if (
|
|
439
|
-
const
|
|
440
|
-
|
|
441
|
-
name.appendChild(
|
|
457
|
+
if (author.given) {
|
|
458
|
+
const node = this.document.createElement('given-names');
|
|
459
|
+
node.textContent = author.given;
|
|
460
|
+
name.appendChild(node);
|
|
442
461
|
}
|
|
443
462
|
if (name.hasChildNodes()) {
|
|
444
463
|
personGroupNode.appendChild(name);
|
|
445
464
|
}
|
|
446
|
-
if (
|
|
465
|
+
if (author.literal) {
|
|
447
466
|
const collab = this.document.createElement('collab');
|
|
448
|
-
collab.textContent =
|
|
467
|
+
collab.textContent = author.literal;
|
|
449
468
|
personGroupNode.appendChild(collab);
|
|
450
469
|
}
|
|
451
470
|
});
|
|
452
|
-
};
|
|
453
|
-
if (bibliographyItem.attrs.author) {
|
|
454
|
-
appendPersonGroup('author', bibliographyItem.attrs.author);
|
|
455
|
-
}
|
|
456
|
-
if (bibliographyItem.attrs.editor) {
|
|
457
|
-
appendPersonGroup('editor', bibliographyItem.attrs.editor);
|
|
458
|
-
}
|
|
459
|
-
if (bibliographyItem.attrs.title) {
|
|
460
|
-
const node = this.document.createElement('article-title');
|
|
461
|
-
this.setTitleContent(node, bibliographyItem.attrs.title);
|
|
462
|
-
citation.appendChild(node);
|
|
463
|
-
}
|
|
464
|
-
if (bibliographyItem.attrs.containerTitle) {
|
|
465
|
-
const node = this.document.createElement('source');
|
|
466
|
-
this.setTitleContent(node, bibliographyItem.attrs.containerTitle);
|
|
467
|
-
citation.appendChild(node);
|
|
468
|
-
}
|
|
469
|
-
if (bibliographyItem.attrs['data-title']) {
|
|
470
|
-
const node = this.document.createElement('data-title');
|
|
471
|
-
this.setTitleContent(node, bibliographyItem.attrs['data-title']);
|
|
472
|
-
citation.appendChild(node);
|
|
473
471
|
}
|
|
474
472
|
if (bibliographyItem.attrs.issued) {
|
|
475
473
|
const dateParts = bibliographyItem.attrs.issued['date-parts'];
|
|
@@ -492,6 +490,16 @@ export class JATSExporter {
|
|
|
492
490
|
}
|
|
493
491
|
}
|
|
494
492
|
}
|
|
493
|
+
if (bibliographyItem.attrs.title) {
|
|
494
|
+
const node = this.document.createElement('article-title');
|
|
495
|
+
this.setTitleContent(node, bibliographyItem.attrs.title);
|
|
496
|
+
citation.appendChild(node);
|
|
497
|
+
}
|
|
498
|
+
if (bibliographyItem.attrs.containerTitle) {
|
|
499
|
+
const node = this.document.createElement('source');
|
|
500
|
+
this.setTitleContent(node, bibliographyItem.attrs.containerTitle);
|
|
501
|
+
citation.appendChild(node);
|
|
502
|
+
}
|
|
495
503
|
if (bibliographyItem.attrs.volume) {
|
|
496
504
|
const node = this.document.createElement('volume');
|
|
497
505
|
node.textContent = String(bibliographyItem.attrs.volume);
|
|
@@ -535,107 +543,6 @@ export class JATSExporter {
|
|
|
535
543
|
node.textContent = String(bibliographyItem.attrs.doi);
|
|
536
544
|
citation.appendChild(node);
|
|
537
545
|
}
|
|
538
|
-
if (bibliographyItem.attrs.pubIDs) {
|
|
539
|
-
for (const pubID of bibliographyItem.attrs.pubIDs) {
|
|
540
|
-
const node = this.document.createElement('pub-id');
|
|
541
|
-
node.setAttribute('pub-id-type', pubID.type);
|
|
542
|
-
node.textContent = pubID.content;
|
|
543
|
-
citation.appendChild(node);
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
if (bibliographyItem.attrs.std) {
|
|
547
|
-
const node = this.document.createElement('std');
|
|
548
|
-
node.textContent = String(bibliographyItem.attrs.std);
|
|
549
|
-
citation.appendChild(node);
|
|
550
|
-
}
|
|
551
|
-
if (bibliographyItem.attrs.series) {
|
|
552
|
-
const node = this.document.createElement('series');
|
|
553
|
-
node.textContent = String(bibliographyItem.attrs.series);
|
|
554
|
-
citation.appendChild(node);
|
|
555
|
-
}
|
|
556
|
-
if (bibliographyItem.attrs.edition) {
|
|
557
|
-
const node = this.document.createElement('edition');
|
|
558
|
-
node.textContent = String(bibliographyItem.attrs.edition);
|
|
559
|
-
citation.appendChild(node);
|
|
560
|
-
}
|
|
561
|
-
if (bibliographyItem.attrs['publisher-place']) {
|
|
562
|
-
const node = this.document.createElement('publisher-loc');
|
|
563
|
-
node.textContent = String(bibliographyItem.attrs['publisher-place']);
|
|
564
|
-
citation.appendChild(node);
|
|
565
|
-
}
|
|
566
|
-
if (bibliographyItem.attrs.publisher) {
|
|
567
|
-
const node = this.document.createElement('publisher-name');
|
|
568
|
-
node.textContent = String(bibliographyItem.attrs.publisher);
|
|
569
|
-
citation.appendChild(node);
|
|
570
|
-
}
|
|
571
|
-
if (bibliographyItem.attrs.event) {
|
|
572
|
-
const node = this.document.createElement('conf-name');
|
|
573
|
-
node.textContent = String(bibliographyItem.attrs.event);
|
|
574
|
-
citation.appendChild(node);
|
|
575
|
-
}
|
|
576
|
-
if (bibliographyItem.attrs['event-place']) {
|
|
577
|
-
const node = this.document.createElement('conf-loc');
|
|
578
|
-
node.textContent = String(bibliographyItem.attrs['event-place']);
|
|
579
|
-
citation.appendChild(node);
|
|
580
|
-
}
|
|
581
|
-
const buildISODate = (date) => {
|
|
582
|
-
const dateParts = date['date-parts'];
|
|
583
|
-
if (dateParts && dateParts.length) {
|
|
584
|
-
const [[year, month, day]] = dateParts;
|
|
585
|
-
if (year && month && day) {
|
|
586
|
-
return new Date(Date.UTC(Number(year), Number(month) - 1, Number(day)));
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
};
|
|
590
|
-
const eventDate = bibliographyItem.attrs['event-date'];
|
|
591
|
-
if (eventDate) {
|
|
592
|
-
const isoDate = buildISODate(eventDate);
|
|
593
|
-
if (isoDate) {
|
|
594
|
-
const node = this.document.createElement('conf-date');
|
|
595
|
-
node.setAttribute('iso-8601-date', isoDate.toISOString());
|
|
596
|
-
node.textContent = isoDate.toDateString();
|
|
597
|
-
citation.appendChild(node);
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
if (bibliographyItem.attrs['number-of-pages']) {
|
|
601
|
-
const node = this.document.createElement('size');
|
|
602
|
-
node.textContent = String(bibliographyItem.attrs['number-of-pages']);
|
|
603
|
-
node.setAttribute('units', 'pages');
|
|
604
|
-
citation.appendChild(node);
|
|
605
|
-
}
|
|
606
|
-
if (bibliographyItem.attrs.volume) {
|
|
607
|
-
const node = this.document.createElement('volume');
|
|
608
|
-
node.textContent = String(bibliographyItem.attrs.volume);
|
|
609
|
-
citation.appendChild(node);
|
|
610
|
-
}
|
|
611
|
-
const dateInCitation = bibliographyItem.attrs['date-in-citation'];
|
|
612
|
-
if (dateInCitation) {
|
|
613
|
-
const isoDate = buildISODate(dateInCitation);
|
|
614
|
-
if (isoDate) {
|
|
615
|
-
const node = this.document.createElement('date-in-citation');
|
|
616
|
-
node.setAttribute('iso-8601-date', isoDate.toISOString());
|
|
617
|
-
node.textContent = isoDate.toDateString();
|
|
618
|
-
citation.appendChild(node);
|
|
619
|
-
}
|
|
620
|
-
}
|
|
621
|
-
if (bibliographyItem.attrs.institution) {
|
|
622
|
-
const node = this.document.createElement('institution');
|
|
623
|
-
node.textContent = String(bibliographyItem.attrs.institution);
|
|
624
|
-
citation.appendChild(node);
|
|
625
|
-
}
|
|
626
|
-
if (bibliographyItem.attrs.elocationID) {
|
|
627
|
-
const node = this.document.createElement('elocation-id');
|
|
628
|
-
node.textContent = String(bibliographyItem.attrs.elocationID);
|
|
629
|
-
citation.appendChild(node);
|
|
630
|
-
}
|
|
631
|
-
if (bibliographyItem.attrs.links) {
|
|
632
|
-
for (const link of bibliographyItem.attrs.links) {
|
|
633
|
-
const node = this.document.createElement('ext-link');
|
|
634
|
-
node.setAttribute('ext-link-type', link.type);
|
|
635
|
-
node.textContent = link.content;
|
|
636
|
-
citation.appendChild(node);
|
|
637
|
-
}
|
|
638
|
-
}
|
|
639
546
|
ref.appendChild(citation);
|
|
640
547
|
refList.appendChild(ref);
|
|
641
548
|
}
|
|
@@ -131,161 +131,90 @@ export class JATSDOMParser {
|
|
|
131
131
|
this.getHTMLContent = (node, querySelector) => {
|
|
132
132
|
return htmlFromJatsNode(node.querySelector(querySelector));
|
|
133
133
|
};
|
|
134
|
+
this.chooseBibliographyItemType = (publicationType) => {
|
|
135
|
+
switch (publicationType) {
|
|
136
|
+
case 'book':
|
|
137
|
+
case 'thesis':
|
|
138
|
+
return publicationType;
|
|
139
|
+
case 'journal':
|
|
140
|
+
default:
|
|
141
|
+
return 'article-journal';
|
|
142
|
+
}
|
|
143
|
+
};
|
|
134
144
|
this.parseRef = (element) => {
|
|
135
|
-
|
|
136
|
-
const
|
|
137
|
-
|
|
145
|
+
const publicationType = element.getAttribute('publication-type');
|
|
146
|
+
const authorNodes = [
|
|
147
|
+
...element.querySelectorAll('person-group[person-group-type="author"] > *'),
|
|
148
|
+
];
|
|
138
149
|
const id = element.id;
|
|
139
|
-
const publicationType = (_a = elementCitation === null || elementCitation === void 0 ? void 0 : elementCitation.getAttribute('publication-type')) !== null && _a !== void 0 ? _a : mixedCitation === null || mixedCitation === void 0 ? void 0 : mixedCitation.getAttribute('publication-type');
|
|
140
150
|
const attrs = {
|
|
141
151
|
id,
|
|
142
|
-
type: publicationType
|
|
143
|
-
? 'article-journal'
|
|
144
|
-
: publicationType !== null && publicationType !== void 0 ? publicationType : 'article-journal',
|
|
152
|
+
type: this.chooseBibliographyItemType(publicationType),
|
|
145
153
|
};
|
|
146
154
|
const title = this.getHTMLContent(element, 'article-title');
|
|
147
155
|
if (title) {
|
|
148
156
|
attrs.title = title;
|
|
149
157
|
}
|
|
150
|
-
const
|
|
151
|
-
if (
|
|
152
|
-
attrs.containerTitle = containerTitle;
|
|
153
|
-
}
|
|
154
|
-
const dataTitle = this.getHTMLContent(element, 'data-title');
|
|
155
|
-
if (dataTitle) {
|
|
156
|
-
attrs['data-title'] = dataTitle;
|
|
157
|
-
}
|
|
158
|
-
const authorNodes = [
|
|
159
|
-
...element.querySelectorAll('person-group[person-group-type="author"] > *'),
|
|
160
|
-
];
|
|
161
|
-
const editorNodes = [
|
|
162
|
-
...element.querySelectorAll('person-group[person-group-type="editor"] > *'),
|
|
163
|
-
];
|
|
164
|
-
if (authorNodes.length === 0) {
|
|
158
|
+
const mixedCitation = element.querySelector('mixed-citation');
|
|
159
|
+
if (authorNodes.length <= 0) {
|
|
165
160
|
mixedCitation === null || mixedCitation === void 0 ? void 0 : mixedCitation.childNodes.forEach((item) => {
|
|
166
161
|
var _a, _b;
|
|
167
162
|
if (item.nodeType === Node.TEXT_NODE &&
|
|
168
163
|
((_a = item.textContent) === null || _a === void 0 ? void 0 : _a.match(/[A-Za-z]+/g))) {
|
|
169
164
|
attrs.literal = (_b = getTrimmedTextContent(mixedCitation)) !== null && _b !== void 0 ? _b : '';
|
|
165
|
+
return attrs;
|
|
170
166
|
}
|
|
171
167
|
});
|
|
172
168
|
}
|
|
173
|
-
const
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
const isoDateParts = isoDate === null || isoDate === void 0 ? void 0 : isoDate.split('-');
|
|
177
|
-
return buildBibliographicDate({
|
|
178
|
-
'date-parts': [
|
|
179
|
-
[
|
|
180
|
-
(_a = isoDateParts === null || isoDateParts === void 0 ? void 0 : isoDateParts[0]) !== null && _a !== void 0 ? _a : '',
|
|
181
|
-
(_b = isoDateParts === null || isoDateParts === void 0 ? void 0 : isoDateParts[1]) !== null && _b !== void 0 ? _b : '',
|
|
182
|
-
(_c = isoDateParts === null || isoDateParts === void 0 ? void 0 : isoDateParts[2]) !== null && _c !== void 0 ? _c : '',
|
|
183
|
-
],
|
|
184
|
-
],
|
|
185
|
-
});
|
|
186
|
-
};
|
|
187
|
-
const buildName = (node) => {
|
|
188
|
-
const name = buildBibliographicName({});
|
|
189
|
-
const given = getTrimmedTextContent(node, 'given-names');
|
|
190
|
-
const family = getTrimmedTextContent(node, 'surname');
|
|
191
|
-
if (given) {
|
|
192
|
-
name.given = given;
|
|
193
|
-
}
|
|
194
|
-
if (family) {
|
|
195
|
-
name.family = family;
|
|
196
|
-
}
|
|
197
|
-
if (node.nodeName === 'collab') {
|
|
198
|
-
name.literal = getTrimmedTextContent(node);
|
|
199
|
-
}
|
|
200
|
-
return name;
|
|
201
|
-
};
|
|
202
|
-
if (authorNodes.length) {
|
|
203
|
-
attrs.author = authorNodes.map(buildName);
|
|
204
|
-
}
|
|
205
|
-
if (editorNodes.length) {
|
|
206
|
-
attrs.editor = editorNodes.map(buildName);
|
|
207
|
-
}
|
|
208
|
-
const getText = (selector) => getTrimmedTextContent(element, selector);
|
|
209
|
-
if (getText('volume')) {
|
|
210
|
-
attrs.volume = getText('volume');
|
|
211
|
-
}
|
|
212
|
-
if (getText('issue')) {
|
|
213
|
-
attrs.issue = getText('issue');
|
|
214
|
-
}
|
|
215
|
-
if (getText('supplement')) {
|
|
216
|
-
attrs.supplement = getText('supplement');
|
|
217
|
-
}
|
|
218
|
-
if (getText('pub-id[pub-id-type="doi"]')) {
|
|
219
|
-
attrs.doi = getText('pub-id[pub-id-type="doi"]');
|
|
220
|
-
}
|
|
221
|
-
if (getText('std')) {
|
|
222
|
-
attrs.std = getText('std');
|
|
223
|
-
}
|
|
224
|
-
if (getText('series')) {
|
|
225
|
-
attrs.series = getText('series');
|
|
226
|
-
}
|
|
227
|
-
if (getText('edition')) {
|
|
228
|
-
attrs.edition = getText('edition');
|
|
229
|
-
}
|
|
230
|
-
if (getText('publisher-name')) {
|
|
231
|
-
attrs.publisher = getText('publisher-name');
|
|
169
|
+
const source = this.getHTMLContent(element, 'source');
|
|
170
|
+
if (source) {
|
|
171
|
+
attrs.containerTitle = source;
|
|
232
172
|
}
|
|
233
|
-
|
|
234
|
-
|
|
173
|
+
const volume = getTrimmedTextContent(element, 'volume');
|
|
174
|
+
if (volume) {
|
|
175
|
+
attrs.volume = volume;
|
|
235
176
|
}
|
|
236
|
-
|
|
237
|
-
|
|
177
|
+
const issue = getTrimmedTextContent(element, 'issue');
|
|
178
|
+
if (issue) {
|
|
179
|
+
attrs.issue = issue;
|
|
238
180
|
}
|
|
239
|
-
|
|
240
|
-
|
|
181
|
+
const supplement = getTrimmedTextContent(element, 'supplement');
|
|
182
|
+
if (supplement) {
|
|
183
|
+
attrs.supplement = supplement;
|
|
241
184
|
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
}
|
|
245
|
-
if (getText('institution')) {
|
|
246
|
-
attrs.institution = getText('institution');
|
|
247
|
-
}
|
|
248
|
-
if (getText('elocation-id')) {
|
|
249
|
-
attrs.elocationID = getText('elocation-id');
|
|
250
|
-
}
|
|
251
|
-
const fpage = getText('fpage');
|
|
252
|
-
const lpage = getText('lpage');
|
|
185
|
+
const fpage = getTrimmedTextContent(element, 'fpage');
|
|
186
|
+
const lpage = getTrimmedTextContent(element, 'lpage');
|
|
253
187
|
if (fpage) {
|
|
254
188
|
attrs.page = lpage ? `${fpage}-${lpage}` : fpage;
|
|
255
189
|
}
|
|
256
|
-
const year =
|
|
190
|
+
const year = getTrimmedTextContent(element, 'year');
|
|
257
191
|
if (year) {
|
|
258
192
|
attrs.issued = buildBibliographicDate({
|
|
259
|
-
'date-parts': [[year
|
|
193
|
+
'date-parts': [[year]],
|
|
260
194
|
});
|
|
261
195
|
}
|
|
262
|
-
const
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
}));
|
|
266
|
-
if (pubIDs.length) {
|
|
267
|
-
attrs.pubIDs = pubIDs;
|
|
196
|
+
const doi = getTrimmedTextContent(element, 'pub-id[pub-id-type="doi"]');
|
|
197
|
+
if (doi) {
|
|
198
|
+
attrs.doi = doi;
|
|
268
199
|
}
|
|
269
|
-
const
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
}
|
|
276
|
-
const dateInCitation = element.querySelector('date-in-citation');
|
|
277
|
-
if (dateInCitation) {
|
|
278
|
-
const date = buildDate(dateInCitation);
|
|
279
|
-
if (date) {
|
|
280
|
-
attrs['date-in-citation'] = date;
|
|
200
|
+
const authors = [];
|
|
201
|
+
authorNodes.forEach((authorNode) => {
|
|
202
|
+
const name = buildBibliographicName({});
|
|
203
|
+
const given = getTrimmedTextContent(authorNode, 'given-names');
|
|
204
|
+
if (given) {
|
|
205
|
+
name.given = given;
|
|
281
206
|
}
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
if (
|
|
287
|
-
|
|
207
|
+
const family = getTrimmedTextContent(authorNode, 'surname');
|
|
208
|
+
if (family) {
|
|
209
|
+
name.family = family;
|
|
210
|
+
}
|
|
211
|
+
if (authorNode.nodeName === 'collab') {
|
|
212
|
+
name.literal = getTrimmedTextContent(authorNode);
|
|
288
213
|
}
|
|
214
|
+
authors.push(name);
|
|
215
|
+
});
|
|
216
|
+
if (authors.length) {
|
|
217
|
+
attrs.author = authors;
|
|
289
218
|
}
|
|
290
219
|
return attrs;
|
|
291
220
|
};
|
|
@@ -19,31 +19,15 @@ export const bibliographyItem = {
|
|
|
19
19
|
id: { default: '' },
|
|
20
20
|
type: { default: undefined },
|
|
21
21
|
author: { default: undefined },
|
|
22
|
-
doi: { default: undefined },
|
|
23
22
|
issued: { default: undefined },
|
|
24
23
|
containerTitle: { default: undefined },
|
|
24
|
+
doi: { default: undefined },
|
|
25
25
|
volume: { default: undefined },
|
|
26
26
|
issue: { default: undefined },
|
|
27
27
|
supplement: { default: undefined },
|
|
28
28
|
page: { default: undefined },
|
|
29
29
|
title: { default: undefined },
|
|
30
30
|
literal: { default: undefined },
|
|
31
|
-
'data-title': { default: undefined },
|
|
32
|
-
std: { default: undefined },
|
|
33
|
-
series: { default: undefined },
|
|
34
|
-
edition: { default: undefined },
|
|
35
|
-
publisher: { default: undefined },
|
|
36
|
-
'publisher-place': { default: undefined },
|
|
37
|
-
event: { default: undefined },
|
|
38
|
-
'event-place': { default: undefined },
|
|
39
|
-
'event-date': { default: undefined },
|
|
40
|
-
institution: { default: undefined },
|
|
41
|
-
editor: { default: undefined },
|
|
42
|
-
elocationID: { default: undefined },
|
|
43
|
-
links: { default: undefined },
|
|
44
|
-
'number-of-pages': { default: undefined },
|
|
45
|
-
pubIDs: { default: undefined },
|
|
46
|
-
'date-in-citation': { default: undefined },
|
|
47
31
|
dataTracked: { default: null },
|
|
48
32
|
},
|
|
49
33
|
selectable: false,
|
package/dist/es/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "3.0.50
|
|
1
|
+
export const VERSION = "3.0.50";
|
|
@@ -16,41 +16,20 @@
|
|
|
16
16
|
import { BibliographicDate, BibliographicName } from '@manuscripts/json-schema';
|
|
17
17
|
import { NodeSpec } from 'prosemirror-model';
|
|
18
18
|
import { ManuscriptNode } from '../types';
|
|
19
|
-
export type BibliographyItemAttr = {
|
|
20
|
-
type?: string;
|
|
21
|
-
content?: string;
|
|
22
|
-
};
|
|
23
19
|
export interface BibliographyItemAttrs {
|
|
24
20
|
id: string;
|
|
25
21
|
type: string;
|
|
26
22
|
author?: BibliographicName[];
|
|
27
23
|
issued?: BibliographicDate;
|
|
28
24
|
containerTitle?: string;
|
|
25
|
+
doi?: string;
|
|
29
26
|
volume?: string;
|
|
30
27
|
issue?: string;
|
|
31
28
|
supplement?: string;
|
|
32
29
|
page?: string;
|
|
33
30
|
title?: string;
|
|
34
31
|
literal?: string;
|
|
35
|
-
'data-title'?: string;
|
|
36
|
-
std?: string;
|
|
37
|
-
series?: string;
|
|
38
|
-
edition?: string;
|
|
39
|
-
'publisher-place'?: string;
|
|
40
|
-
publisher?: string;
|
|
41
|
-
event?: string;
|
|
42
|
-
'event-place'?: string;
|
|
43
|
-
'event-date'?: BibliographicDate;
|
|
44
|
-
institution?: string;
|
|
45
|
-
editor?: BibliographicName[];
|
|
46
|
-
elocationID?: string;
|
|
47
|
-
links?: BibliographyItemAttr[];
|
|
48
|
-
'number-of-pages'?: string;
|
|
49
|
-
'date-in-citation'?: BibliographicDate;
|
|
50
|
-
pubIDs?: BibliographyItemAttr[];
|
|
51
|
-
doi?: string;
|
|
52
32
|
}
|
|
53
|
-
export type BibliographyItemType = 'article-journal' | 'book' | 'chapter' | 'paper-conference' | 'thesis' | 'webpage' | 'other' | 'standard' | 'dataset' | 'preprint';
|
|
54
33
|
export interface BibliographyItemNode extends ManuscriptNode {
|
|
55
34
|
attrs: BibliographyItemAttrs;
|
|
56
35
|
}
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "3.0.50
|
|
1
|
+
export declare const VERSION = "3.0.50";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@manuscripts/transform",
|
|
3
3
|
"description": "ProseMirror transformer for Manuscripts applications",
|
|
4
|
-
"version": "3.0.50
|
|
4
|
+
"version": "3.0.50",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-transform",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@manuscripts/json-schema": "2.2.11",
|
|
34
|
-
"@manuscripts/library": "1.3.
|
|
34
|
+
"@manuscripts/library": "1.3.13",
|
|
35
35
|
"debug": "^4.3.4",
|
|
36
36
|
"jszip": "^3.10.1",
|
|
37
37
|
"lodash": "^4.17.21",
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
class Migration3047 {
|
|
4
|
-
constructor() {
|
|
5
|
-
this.fromVersion = '3.0.46';
|
|
6
|
-
this.toVersion = '3.0.47';
|
|
7
|
-
}
|
|
8
|
-
migrateNode(node) {
|
|
9
|
-
if (node.type === 'bibliography_item') {
|
|
10
|
-
const authors = node.attrs.author || [];
|
|
11
|
-
const doi = node.attrs.doi;
|
|
12
|
-
delete node.attrs.author;
|
|
13
|
-
delete node.attrs.doi;
|
|
14
|
-
return Object.assign(Object.assign({}, node), { attrs: Object.assign(Object.assign({}, node.attrs), { authors, pubIDs: doi ? [{ type: 'doi', content: doi }] : [] }) });
|
|
15
|
-
}
|
|
16
|
-
return node;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
exports.default = Migration3047;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
class Migration3047 {
|
|
2
|
-
constructor() {
|
|
3
|
-
this.fromVersion = '3.0.46';
|
|
4
|
-
this.toVersion = '3.0.47';
|
|
5
|
-
}
|
|
6
|
-
migrateNode(node) {
|
|
7
|
-
if (node.type === 'bibliography_item') {
|
|
8
|
-
const authors = node.attrs.author || [];
|
|
9
|
-
const doi = node.attrs.doi;
|
|
10
|
-
delete node.attrs.author;
|
|
11
|
-
delete node.attrs.doi;
|
|
12
|
-
return Object.assign(Object.assign({}, node), { attrs: Object.assign(Object.assign({}, node.attrs), { authors, pubIDs: doi ? [{ type: 'doi', content: doi }] : [] }) });
|
|
13
|
-
}
|
|
14
|
-
return node;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
export default Migration3047;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { JSONNode } from '../migrate';
|
|
2
|
-
import { MigrationScript } from '../migration-script';
|
|
3
|
-
declare class Migration3047 implements MigrationScript {
|
|
4
|
-
fromVersion: string;
|
|
5
|
-
toVersion: string;
|
|
6
|
-
migrateNode(node: JSONNode): JSONNode;
|
|
7
|
-
}
|
|
8
|
-
export default Migration3047;
|