@manuscripts/transform 2.1.2 → 2.1.3

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.
@@ -45,6 +45,11 @@ exports.jatsFrontParser = {
45
45
  }
46
46
  return titles;
47
47
  },
48
+ parseDOI(front) {
49
+ var _a;
50
+ const doi = front === null || front === void 0 ? void 0 : front.querySelector('article-meta > article-id[pub-id-type="doi"]');
51
+ return (_a = doi === null || doi === void 0 ? void 0 : doi.textContent) !== null && _a !== void 0 ? _a : undefined;
52
+ },
48
53
  parseCounts(counts) {
49
54
  var _a, _b, _c, _d, _e;
50
55
  if (counts) {
@@ -31,6 +31,7 @@ const parseJATSFront = (doc, front) => {
31
31
  const createElement = createElementFn(doc);
32
32
  const journal = jats_front_parser_1.jatsFrontParser.parseJournal(front.querySelector('journal-meta'));
33
33
  const titles = jats_front_parser_1.jatsFrontParser.parseTitles(front.querySelector('article-meta > title-group'), createElement);
34
+ const DOI = jats_front_parser_1.jatsFrontParser.parseDOI(front);
34
35
  const { affiliations, affiliationIDs } = jats_front_parser_1.jatsFrontParser.parseAffiliations([
35
36
  ...front.querySelectorAll('article-meta > contrib-group > aff'),
36
37
  ]);
@@ -45,7 +46,7 @@ const parseJATSFront = (doc, front) => {
45
46
  ], affiliationIDs, footnoteIDs, correspondingIDs);
46
47
  const history = jats_front_parser_1.jatsFrontParser.parseDates(front.querySelector('article-meta > history'));
47
48
  const counts = jats_front_parser_1.jatsFrontParser.parseCounts(front.querySelector('article-meta counts'));
48
- const manuscript = Object.assign(Object.assign(Object.assign({}, (0, builders_1.buildManuscript)()), counts), history);
49
+ const manuscript = Object.assign(Object.assign(Object.assign(Object.assign({}, (0, builders_1.buildManuscript)()), counts), history), { DOI });
49
50
  return generateIDs([
50
51
  manuscript,
51
52
  titles,
@@ -248,7 +248,7 @@ class JATSExporter {
248
248
  }
249
249
  };
250
250
  this.buildFront = (doi, id, links) => {
251
- var _a, _b, _c, _d;
251
+ var _a, _b, _c, _d, _e;
252
252
  const manuscript = (0, project_bundle_1.findManuscript)(this.modelMap);
253
253
  const titles = (0, project_bundle_1.findTitles)(this.modelMap);
254
254
  const front = this.document.createElement('front');
@@ -311,10 +311,10 @@ class JATSExporter {
311
311
  articleID.textContent = id;
312
312
  articleMeta.appendChild(articleID);
313
313
  }
314
- if (doi) {
314
+ if (doi || manuscript.DOI) {
315
315
  const articleID = this.document.createElement('article-id');
316
316
  articleID.setAttribute('pub-id-type', 'doi');
317
- articleID.textContent = doi;
317
+ articleID.textContent = (_a = manuscript.DOI) !== null && _a !== void 0 ? _a : doi;
318
318
  articleMeta.appendChild(articleID);
319
319
  }
320
320
  const titleGroup = this.document.createElement('title-group');
@@ -349,14 +349,14 @@ class JATSExporter {
349
349
  for (const supplement of supplements) {
350
350
  const supplementaryMaterial = this.document.createElement('supplementary-material');
351
351
  supplementaryMaterial.setAttribute('id', normalizeID(supplement._id));
352
- supplementaryMaterial.setAttributeNS(XLINK_NAMESPACE, 'href', (_a = supplement.href) !== null && _a !== void 0 ? _a : '');
353
- const mimeType = (_b = supplement.MIME) === null || _b === void 0 ? void 0 : _b.split('/')[0];
354
- const mimeSubType = (_c = supplement.MIME) === null || _c === void 0 ? void 0 : _c.split('/')[1];
352
+ supplementaryMaterial.setAttributeNS(XLINK_NAMESPACE, 'href', (_b = supplement.href) !== null && _b !== void 0 ? _b : '');
353
+ const mimeType = (_c = supplement.MIME) === null || _c === void 0 ? void 0 : _c.split('/')[0];
354
+ const mimeSubType = (_d = supplement.MIME) === null || _d === void 0 ? void 0 : _d.split('/')[1];
355
355
  supplementaryMaterial.setAttribute('mimetype', mimeType !== null && mimeType !== void 0 ? mimeType : '');
356
356
  supplementaryMaterial.setAttribute('mime-subtype', mimeSubType !== null && mimeSubType !== void 0 ? mimeSubType : '');
357
357
  const caption = this.document.createElement('caption');
358
358
  const title = this.document.createElement('title');
359
- title.textContent = (_d = supplement.title) !== null && _d !== void 0 ? _d : '';
359
+ title.textContent = (_e = supplement.title) !== null && _e !== void 0 ? _e : '';
360
360
  caption.append(title);
361
361
  supplementaryMaterial.append(caption);
362
362
  articleMeta.append(supplementaryMaterial);
@@ -39,6 +39,11 @@ export const jatsFrontParser = {
39
39
  }
40
40
  return titles;
41
41
  },
42
+ parseDOI(front) {
43
+ var _a;
44
+ const doi = front === null || front === void 0 ? void 0 : front.querySelector('article-meta > article-id[pub-id-type="doi"]');
45
+ return (_a = doi === null || doi === void 0 ? void 0 : doi.textContent) !== null && _a !== void 0 ? _a : undefined;
46
+ },
42
47
  parseCounts(counts) {
43
48
  var _a, _b, _c, _d, _e;
44
49
  if (counts) {
@@ -28,6 +28,7 @@ export const parseJATSFront = (doc, front) => {
28
28
  const createElement = createElementFn(doc);
29
29
  const journal = jatsFrontParser.parseJournal(front.querySelector('journal-meta'));
30
30
  const titles = jatsFrontParser.parseTitles(front.querySelector('article-meta > title-group'), createElement);
31
+ const DOI = jatsFrontParser.parseDOI(front);
31
32
  const { affiliations, affiliationIDs } = jatsFrontParser.parseAffiliations([
32
33
  ...front.querySelectorAll('article-meta > contrib-group > aff'),
33
34
  ]);
@@ -42,7 +43,7 @@ export const parseJATSFront = (doc, front) => {
42
43
  ], affiliationIDs, footnoteIDs, correspondingIDs);
43
44
  const history = jatsFrontParser.parseDates(front.querySelector('article-meta > history'));
44
45
  const counts = jatsFrontParser.parseCounts(front.querySelector('article-meta counts'));
45
- const manuscript = Object.assign(Object.assign(Object.assign({}, buildManuscript()), counts), history);
46
+ const manuscript = Object.assign(Object.assign(Object.assign(Object.assign({}, buildManuscript()), counts), history), { DOI });
46
47
  return generateIDs([
47
48
  manuscript,
48
49
  titles,
@@ -240,7 +240,7 @@ export class JATSExporter {
240
240
  }
241
241
  };
242
242
  this.buildFront = (doi, id, links) => {
243
- var _a, _b, _c, _d;
243
+ var _a, _b, _c, _d, _e;
244
244
  const manuscript = findManuscript(this.modelMap);
245
245
  const titles = findTitles(this.modelMap);
246
246
  const front = this.document.createElement('front');
@@ -303,10 +303,10 @@ export class JATSExporter {
303
303
  articleID.textContent = id;
304
304
  articleMeta.appendChild(articleID);
305
305
  }
306
- if (doi) {
306
+ if (doi || manuscript.DOI) {
307
307
  const articleID = this.document.createElement('article-id');
308
308
  articleID.setAttribute('pub-id-type', 'doi');
309
- articleID.textContent = doi;
309
+ articleID.textContent = (_a = manuscript.DOI) !== null && _a !== void 0 ? _a : doi;
310
310
  articleMeta.appendChild(articleID);
311
311
  }
312
312
  const titleGroup = this.document.createElement('title-group');
@@ -341,14 +341,14 @@ export class JATSExporter {
341
341
  for (const supplement of supplements) {
342
342
  const supplementaryMaterial = this.document.createElement('supplementary-material');
343
343
  supplementaryMaterial.setAttribute('id', normalizeID(supplement._id));
344
- supplementaryMaterial.setAttributeNS(XLINK_NAMESPACE, 'href', (_a = supplement.href) !== null && _a !== void 0 ? _a : '');
345
- const mimeType = (_b = supplement.MIME) === null || _b === void 0 ? void 0 : _b.split('/')[0];
346
- const mimeSubType = (_c = supplement.MIME) === null || _c === void 0 ? void 0 : _c.split('/')[1];
344
+ supplementaryMaterial.setAttributeNS(XLINK_NAMESPACE, 'href', (_b = supplement.href) !== null && _b !== void 0 ? _b : '');
345
+ const mimeType = (_c = supplement.MIME) === null || _c === void 0 ? void 0 : _c.split('/')[0];
346
+ const mimeSubType = (_d = supplement.MIME) === null || _d === void 0 ? void 0 : _d.split('/')[1];
347
347
  supplementaryMaterial.setAttribute('mimetype', mimeType !== null && mimeType !== void 0 ? mimeType : '');
348
348
  supplementaryMaterial.setAttribute('mime-subtype', mimeSubType !== null && mimeSubType !== void 0 ? mimeSubType : '');
349
349
  const caption = this.document.createElement('caption');
350
350
  const title = this.document.createElement('title');
351
- title.textContent = (_d = supplement.title) !== null && _d !== void 0 ? _d : '';
351
+ title.textContent = (_e = supplement.title) !== null && _e !== void 0 ? _e : '';
352
352
  caption.append(title);
353
353
  supplementaryMaterial.append(caption);
354
354
  articleMeta.append(supplementaryMaterial);
@@ -15,6 +15,7 @@
15
15
  */
16
16
  export declare const jatsFrontParser: {
17
17
  parseTitles(element: Element | null, createElement: (tagName: string) => HTMLElement): import("../../transformer").Build<import("@manuscripts/json-schema/dist/types").Titles>;
18
+ parseDOI(front: Element | null): string | undefined;
18
19
  parseCounts(counts: Element | null): {
19
20
  wordCount: number | undefined;
20
21
  figureCount: number | undefined;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@manuscripts/transform",
3
3
  "description": "ProseMirror transformer for Manuscripts applications",
4
- "version": "2.1.2",
4
+ "version": "2.1.3",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-transform",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",