@manuscripts/transform 3.0.55-LEAN-4433.0 → 3.0.55

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.
Files changed (32) hide show
  1. package/dist/cjs/jats/exporter/jats-exporter.js +238 -252
  2. package/dist/cjs/jats/importer/jats-dom-parser.js +103 -85
  3. package/dist/cjs/jats/importer/jats-transformations.js +7 -10
  4. package/dist/cjs/jats/importer/parse-jats-article.js +1 -1
  5. package/dist/cjs/lib/utils.js +9 -5
  6. package/dist/cjs/schema/migration/migration-scripts/3.0.55.js +6 -70
  7. package/dist/cjs/schema/nodes/bibliography_item.js +24 -3
  8. package/dist/cjs/schema/nodes/embed.js +1 -1
  9. package/dist/cjs/schema/nodes/figure_element.js +1 -1
  10. package/dist/cjs/schema/nodes/image_element.js +1 -1
  11. package/dist/cjs/schema/nodes/table_element.js +1 -1
  12. package/dist/cjs/version.js +1 -1
  13. package/dist/es/jats/exporter/jats-exporter.js +238 -252
  14. package/dist/es/jats/importer/jats-dom-parser.js +104 -86
  15. package/dist/es/jats/importer/jats-transformations.js +5 -8
  16. package/dist/es/jats/importer/parse-jats-article.js +2 -2
  17. package/dist/es/lib/utils.js +5 -2
  18. package/dist/es/schema/migration/migration-scripts/3.0.55.js +6 -70
  19. package/dist/es/schema/nodes/bibliography_item.js +23 -2
  20. package/dist/es/schema/nodes/embed.js +1 -1
  21. package/dist/es/schema/nodes/figure_element.js +1 -1
  22. package/dist/es/schema/nodes/image_element.js +1 -1
  23. package/dist/es/schema/nodes/table_element.js +1 -1
  24. package/dist/es/version.js +1 -1
  25. package/dist/types/jats/exporter/jats-exporter.d.ts +7 -1
  26. package/dist/types/jats/importer/jats-dom-parser.d.ts +6 -3
  27. package/dist/types/jats/importer/jats-transformations.d.ts +1 -1
  28. package/dist/types/lib/utils.d.ts +1 -0
  29. package/dist/types/schema/migration/migration-scripts/3.0.55.d.ts +0 -2
  30. package/dist/types/schema/nodes/bibliography_item.d.ts +18 -2
  31. package/dist/types/version.d.ts +1 -1
  32. package/package.json +1 -1
@@ -31,6 +31,12 @@ const schema_1 = require("../../schema");
31
31
  const transformer_1 = require("../../transformer");
32
32
  const jats_versions_1 = require("./jats-versions");
33
33
  const labels_1 = require("./labels");
34
+ const publicationTypeToJats = {
35
+ article: 'journal',
36
+ 'article-journal': 'journal',
37
+ webpage: 'web',
38
+ dataset: 'data',
39
+ };
34
40
  const warn = (0, debug_1.default)('manuscripts-transform');
35
41
  const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
36
42
  const normalizeID = (id) => id.replace(/:/g, '_');
@@ -109,22 +115,7 @@ class JATSExporter {
109
115
  if (!node) {
110
116
  return undefined;
111
117
  }
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
- };
118
+ return Object.assign(Object.assign({}, node.attrs), { _id: node.attrs.id, manuscriptID, objectType: json_schema_1.ObjectTypes.BibliographyItem });
128
119
  };
129
120
  };
130
121
  this.nodesMap = new Map();
@@ -174,7 +165,7 @@ class JATSExporter {
174
165
  if (!JATSFragment.length) {
175
166
  return null;
176
167
  }
177
- const template = this.document.createElement('template');
168
+ const template = this.createElement('template');
178
169
  template.innerHTML = JATSFragment;
179
170
  return template.firstChild;
180
171
  };
@@ -220,15 +211,15 @@ class JATSExporter {
220
211
  }
221
212
  };
222
213
  this.buildFront = (journal) => {
223
- const front = this.document.createElement('front');
224
- const journalMeta = this.document.createElement('journal-meta');
214
+ const front = this.createElement('front');
215
+ const journalMeta = this.createElement('journal-meta');
225
216
  front.appendChild(journalMeta);
226
- const articleMeta = this.document.createElement('article-meta');
217
+ const articleMeta = this.createElement('article-meta');
227
218
  front.appendChild(articleMeta);
228
219
  if (journal) {
229
220
  if (journal.journalIdentifiers) {
230
221
  for (const item of journal.journalIdentifiers) {
231
- const element = this.document.createElement('journal-id');
222
+ const element = this.createElement('journal-id');
232
223
  if (item.journalIDType) {
233
224
  element.setAttribute('journal-id-type', item.journalIDType);
234
225
  }
@@ -237,16 +228,16 @@ class JATSExporter {
237
228
  }
238
229
  }
239
230
  if (journal.title || journal.abbreviatedTitles) {
240
- const parentElement = this.document.createElement('journal-title-group');
231
+ const parentElement = this.createElement('journal-title-group');
241
232
  journalMeta.appendChild(parentElement);
242
233
  if (journal.title) {
243
- const element = this.document.createElement('journal-title');
234
+ const element = this.createElement('journal-title');
244
235
  element.textContent = journal.title;
245
236
  parentElement.appendChild(element);
246
237
  }
247
238
  if (journal.abbreviatedTitles) {
248
239
  for (const item of journal.abbreviatedTitles) {
249
- const element = this.document.createElement('abbrev-journal-title');
240
+ const element = this.createElement('abbrev-journal-title');
250
241
  if (item.abbrevType) {
251
242
  element.setAttribute('abbrev-type', item.abbrevType);
252
243
  }
@@ -257,7 +248,7 @@ class JATSExporter {
257
248
  }
258
249
  if (journal.ISSNs) {
259
250
  for (const item of journal.ISSNs) {
260
- const element = this.document.createElement('issn');
251
+ const element = this.createElement('issn');
261
252
  if (item.publicationType) {
262
253
  element.setAttribute('pub-type', item.publicationType);
263
254
  }
@@ -266,29 +257,29 @@ class JATSExporter {
266
257
  }
267
258
  }
268
259
  if (journal.publisherName) {
269
- const publisher = this.document.createElement('publisher');
270
- const publisherName = this.document.createElement('publisher-name');
260
+ const publisher = this.createElement('publisher');
261
+ const publisherName = this.createElement('publisher-name');
271
262
  publisherName.textContent = journal.publisherName;
272
263
  publisher.appendChild(publisherName);
273
264
  journalMeta.appendChild(publisher);
274
265
  }
275
266
  }
276
267
  if (this.manuscriptNode.attrs.doi) {
277
- const articleID = this.document.createElement('article-id');
268
+ const articleID = this.createElement('article-id');
278
269
  articleID.setAttribute('pub-id-type', 'doi');
279
270
  articleID.textContent = this.manuscriptNode.attrs.doi;
280
271
  articleMeta.appendChild(articleID);
281
272
  }
282
- const titleGroup = this.document.createElement('title-group');
273
+ const titleGroup = this.createElement('title-group');
283
274
  const titleNode = this.getFirstChildOfType(schema_1.schema.nodes.title);
284
275
  if (titleNode) {
285
- const element = this.document.createElement('article-title');
276
+ const element = this.createElement('article-title');
286
277
  this.setTitleContent(element, titleNode.textContent);
287
278
  titleGroup.appendChild(element);
288
279
  }
289
280
  const altTitlesNodes = this.getChildrenOfType(schema_1.schema.nodes.alt_title);
290
281
  altTitlesNodes.forEach((titleNode) => {
291
- const element = this.document.createElement('alt-title');
282
+ const element = this.createElement('alt-title');
292
283
  element.setAttribute('alt-title-type', titleNode.attrs.type);
293
284
  this.setTitleContent(element, titleNode.textContent);
294
285
  titleGroup.appendChild(element);
@@ -298,20 +289,19 @@ class JATSExporter {
298
289
  const supplementsNodes = this.getChildrenOfType(schema_1.schema.nodes.supplement);
299
290
  supplementsNodes.forEach((node) => {
300
291
  var _a, _b, _c, _d;
301
- const supplementaryMaterial = this.document.createElement('supplementary-material');
292
+ const supplementaryMaterial = this.createElement('supplementary-material');
302
293
  supplementaryMaterial.setAttribute('id', normalizeID(node.attrs.id));
303
294
  supplementaryMaterial.setAttributeNS(XLINK_NAMESPACE, 'href', (_a = node.attrs.href) !== null && _a !== void 0 ? _a : '');
304
295
  supplementaryMaterial.setAttribute('mimetype', (_b = node.attrs.mimeType) !== null && _b !== void 0 ? _b : '');
305
296
  supplementaryMaterial.setAttribute('mime-subtype', (_c = node.attrs.mimeSubType) !== null && _c !== void 0 ? _c : '');
306
- const caption = this.document.createElement('caption');
307
- const title = this.document.createElement('title');
297
+ const caption = this.createElement('caption');
298
+ const title = this.createElement('title');
308
299
  title.textContent = (_d = node.attrs.title) !== null && _d !== void 0 ? _d : '';
309
300
  caption.append(title);
310
301
  supplementaryMaterial.append(caption);
311
302
  articleMeta.append(supplementaryMaterial);
312
303
  });
313
- const history = articleMeta.querySelector('history') ||
314
- this.document.createElement('history');
304
+ const history = articleMeta.querySelector('history') || this.createElement('history');
315
305
  if (this.manuscriptNode.attrs.acceptanceDate) {
316
306
  const date = this.buildDateElement(this.manuscriptNode.attrs.acceptanceDate, 'accepted');
317
307
  history.appendChild(date);
@@ -353,7 +343,7 @@ class JATSExporter {
353
343
  countingElements.push(this.buildCountingElement('word-count', wordCount));
354
344
  countingElements = countingElements.filter((el) => el);
355
345
  if (countingElements.length > 0) {
356
- const counts = this.document.createElement('counts');
346
+ const counts = this.createElement('counts');
357
347
  counts.append(...countingElements);
358
348
  articleMeta.append(counts);
359
349
  }
@@ -362,7 +352,7 @@ class JATSExporter {
362
352
  }
363
353
  const selfUriAttachments = this.getChildrenOfType(schema_1.schema.nodes.attachment);
364
354
  selfUriAttachments.forEach((attachment) => {
365
- const selfUriElement = this.document.createElement('self-uri');
355
+ const selfUriElement = this.createElement('self-uri');
366
356
  selfUriElement.setAttribute('content-type', attachment.attrs.type);
367
357
  selfUriElement.setAttributeNS(XLINK_NAMESPACE, 'href', attachment.attrs.href);
368
358
  const insertBeforeElements = articleMeta.querySelector('related-article, related-object, abstract, trans-abstract, kwd-group, funding-group, support-group, conference, counts, custom-meta-group');
@@ -373,7 +363,7 @@ class JATSExporter {
373
363
  return front;
374
364
  };
375
365
  this.buildDateElement = (timestamp, type) => {
376
- const dateElement = this.document.createElement('date');
366
+ const dateElement = this.createElement('date');
377
367
  dateElement.setAttribute('date-type', type);
378
368
  const date = new Date(timestamp * 1000);
379
369
  const lookup = {
@@ -382,7 +372,7 @@ class JATSExporter {
382
372
  day: date.getUTCDate().toString().padStart(2, '0'),
383
373
  };
384
374
  for (const [key, value] of Object.entries(lookup).reverse()) {
385
- const el = this.document.createElement(key);
375
+ const el = this.createElement(key);
386
376
  el.textContent = value;
387
377
  dateElement.appendChild(el);
388
378
  }
@@ -390,13 +380,13 @@ class JATSExporter {
390
380
  };
391
381
  this.buildCountingElement = (tagName, count) => {
392
382
  if (count) {
393
- const wordCount = this.document.createElement(tagName);
383
+ const wordCount = this.createElement(tagName);
394
384
  wordCount.setAttribute('count', String(count));
395
385
  return wordCount;
396
386
  }
397
387
  };
398
388
  this.buildBody = () => {
399
- const body = this.document.createElement('body');
389
+ const body = this.createElement('body');
400
390
  this.manuscriptNode.forEach((cFragment) => {
401
391
  const serializedNode = this.serializeNode(cFragment);
402
392
  body.append(...serializedNode.childNodes);
@@ -405,7 +395,7 @@ class JATSExporter {
405
395
  return body;
406
396
  };
407
397
  this.buildBack = (body) => {
408
- const back = this.document.createElement('back');
398
+ const back = this.createElement('back');
409
399
  this.moveSectionsToBack(back, body);
410
400
  const footnotesElements = this.document.querySelectorAll('sec > fn-group');
411
401
  for (const footnotesElement of footnotesElements) {
@@ -424,7 +414,7 @@ class JATSExporter {
424
414
  let refList = this.document.querySelector('ref-list');
425
415
  if (!refList) {
426
416
  warn('No bibliography element, creating a ref-list anyway');
427
- refList = this.document.createElement('ref-list');
417
+ refList = this.createElement('ref-list');
428
418
  }
429
419
  back.appendChild(refList);
430
420
  const bibliographyItems = this.getChildrenOfType(schema_1.schema.nodes.bibliography_item);
@@ -434,163 +424,159 @@ class JATSExporter {
434
424
  if (!bibliographyItem) {
435
425
  continue;
436
426
  }
437
- const ref = this.document.createElement('ref');
427
+ const ref = this.createElement('ref');
438
428
  ref.setAttribute('id', normalizeID(id));
439
- const updateCitationPubType = (citationEl, pubType) => {
440
- if (pubType) {
441
- switch (pubType) {
442
- case 'article':
443
- case 'article-journal':
444
- citationEl.setAttribute('publication-type', 'journal');
445
- break;
446
- default:
447
- citationEl.setAttribute('publication-type', pubType);
448
- break;
449
- }
450
- }
451
- else {
452
- citationEl.setAttribute('publication-type', 'journal');
453
- }
454
- };
429
+ const getPublicationType = (pubType) => publicationTypeToJats[pubType !== null && pubType !== void 0 ? pubType : ''] || pubType || 'journal';
455
430
  if (bibliographyItem.attrs.literal) {
456
- const mixedCitation = this.document.createElement('mixed-citation');
457
- updateCitationPubType(mixedCitation, bibliographyItem.attrs.type);
458
- mixedCitation.textContent = bibliographyItem.attrs.literal;
459
- ref.appendChild(mixedCitation);
460
- refList.appendChild(ref);
431
+ this.appendElement(ref, 'mixed-citation', bibliographyItem.attrs.literal, {
432
+ 'publication-type': getPublicationType(bibliographyItem.attrs.type),
433
+ });
461
434
  }
462
435
  else {
463
- const citation = this.document.createElement('element-citation');
464
- updateCitationPubType(citation, bibliographyItem.attrs.type);
465
- if (bibliographyItem.attrs.author) {
466
- const personGroupNode = this.document.createElement('person-group');
467
- personGroupNode.setAttribute('person-group-type', 'author');
468
- citation.appendChild(personGroupNode);
469
- bibliographyItem.attrs.author.forEach((author) => {
470
- const name = this.document.createElement('string-name');
471
- if (author.family) {
472
- const node = this.document.createElement('surname');
473
- node.textContent = author.family;
474
- name.appendChild(node);
475
- }
476
- if (author.given) {
477
- const node = this.document.createElement('given-names');
478
- node.textContent = author.given;
479
- name.appendChild(node);
480
- }
481
- if (name.hasChildNodes()) {
482
- personGroupNode.appendChild(name);
483
- }
484
- if (author.literal) {
485
- const collab = this.document.createElement('collab');
486
- collab.textContent = author.literal;
487
- personGroupNode.appendChild(collab);
488
- }
489
- });
490
- }
491
- if (bibliographyItem.attrs.issued) {
492
- const dateParts = bibliographyItem.attrs.issued['date-parts'];
493
- if (dateParts && dateParts.length) {
494
- const [[year, month, day]] = dateParts;
495
- if (year) {
496
- const node = this.document.createElement('year');
497
- node.textContent = String(year);
498
- citation.appendChild(node);
499
- }
500
- if (month) {
501
- const node = this.document.createElement('month');
502
- node.textContent = String(month);
503
- citation.appendChild(node);
504
- }
505
- if (day) {
506
- const node = this.document.createElement('day');
507
- node.textContent = String(day);
508
- citation.appendChild(node);
509
- }
510
- }
511
- }
512
- if (bibliographyItem.attrs.title) {
513
- const node = this.document.createElement('article-title');
514
- this.setTitleContent(node, bibliographyItem.attrs.title);
515
- citation.appendChild(node);
516
- }
517
- if (bibliographyItem.attrs.containerTitle) {
518
- const node = this.document.createElement('source');
519
- this.setTitleContent(node, bibliographyItem.attrs.containerTitle);
520
- citation.appendChild(node);
521
- }
522
- if (bibliographyItem.attrs.volume) {
523
- const node = this.document.createElement('volume');
524
- node.textContent = String(bibliographyItem.attrs.volume);
525
- citation.appendChild(node);
526
- }
527
- if (bibliographyItem.attrs.issue) {
528
- const node = this.document.createElement('issue');
529
- node.textContent = String(bibliographyItem.attrs.issue);
530
- citation.appendChild(node);
531
- }
532
- if (bibliographyItem.attrs.supplement) {
533
- const node = this.document.createElement('supplement');
534
- node.textContent = bibliographyItem.attrs.supplement;
535
- citation.appendChild(node);
536
- }
537
- if (bibliographyItem.attrs.page) {
538
- const pageString = String(bibliographyItem.attrs.page);
539
- if (/^\d+$/.test(pageString)) {
540
- const node = this.document.createElement('fpage');
541
- node.textContent = pageString;
542
- citation.appendChild(node);
543
- }
544
- else if (/^\d+-\d+$/.test(pageString)) {
545
- const [fpage, lpage] = pageString.split('-');
546
- const fpageNode = this.document.createElement('fpage');
547
- fpageNode.textContent = fpage;
548
- citation.appendChild(fpageNode);
549
- const lpageNode = this.document.createElement('lpage');
550
- lpageNode.textContent = lpage;
551
- citation.appendChild(lpageNode);
552
- }
553
- else {
554
- const node = this.document.createElement('page-range');
555
- node.textContent = pageString;
556
- citation.appendChild(node);
436
+ const citation = this.appendElement(ref, 'element-citation', undefined, {
437
+ 'publication-type': getPublicationType(bibliographyItem.attrs.type),
438
+ });
439
+ const attributeHandlers = {
440
+ author: (v) => this.processRefPersonGroup(citation, 'author', v),
441
+ editor: (v) => this.processRefPersonGroup(citation, 'editor', v),
442
+ title: (v) => this.setTitleContent(this.appendElement(citation, 'article-title'), v),
443
+ 'container-title': (v) => this.setTitleContent(this.appendElement(citation, 'source'), v),
444
+ issued: ({ 'date-parts': parts }) => this.processDateParts(citation, parts),
445
+ volume: (v) => this.appendElement(citation, 'volume', v),
446
+ issue: (v) => this.appendElement(citation, 'issue', v),
447
+ supplement: (v) => this.appendElement(citation, 'supplement', v),
448
+ page: (v) => this.processPageString(citation, String(v)),
449
+ DOI: (v) => this.appendElement(citation, 'pub-id', v, { 'pub-id-type': 'doi' }),
450
+ std: (v) => this.appendElement(citation, 'pub-id', v, {
451
+ 'pub-id-type': 'std-designation',
452
+ }),
453
+ 'collection-title': (v) => this.appendElement(citation, 'series', v),
454
+ edition: (v) => this.appendElement(citation, 'edition', v),
455
+ 'publisher-place': (v) => this.appendElement(citation, 'publisher-loc', v),
456
+ publisher: (v) => this.appendElement(citation, 'publisher-name', v),
457
+ event: (v) => this.appendElement(citation, 'conf-name', v),
458
+ 'event-place': (v) => this.appendElement(citation, 'conf-loc', v),
459
+ 'number-of-pages': (v) => this.appendElement(citation, 'size', v, { units: 'pages' }),
460
+ institution: (v) => this.appendElement(citation, 'institution', v),
461
+ locator: (v) => this.appendElement(citation, 'elocation-id', v),
462
+ URL: (v) => this.appendElement(citation, 'ext-link', v, {
463
+ 'ext-link-type': 'uri',
464
+ }),
465
+ 'event-date': (v) => this.processDate(citation, 'conf-date', v),
466
+ accessed: (v) => this.processDate(citation, 'date-in-citation', v),
467
+ };
468
+ Object.entries(attributeHandlers).forEach(([key, handler]) => {
469
+ const value = bibliographyItem.attrs[key];
470
+ if (value) {
471
+ handler(value);
557
472
  }
558
- }
559
- if (bibliographyItem.attrs.doi) {
560
- const node = this.document.createElement('pub-id');
561
- node.setAttribute('pub-id-type', 'doi');
562
- node.textContent = String(bibliographyItem.attrs.doi);
563
- citation.appendChild(node);
564
- }
565
- ref.appendChild(citation);
566
- refList.appendChild(ref);
473
+ });
567
474
  }
475
+ refList.appendChild(ref);
568
476
  }
569
477
  return back;
570
478
  };
479
+ this.processDateParts = (parent, dateParts) => {
480
+ const [[year, month, day]] = dateParts;
481
+ if (year) {
482
+ this.appendElement(parent, 'year', String(year));
483
+ }
484
+ if (month) {
485
+ this.appendElement(parent, 'month', String(month));
486
+ }
487
+ if (day) {
488
+ this.appendElement(parent, 'day', String(day));
489
+ }
490
+ };
491
+ this.processPageString = (parent, page) => {
492
+ const numPattern = /^\d+$/;
493
+ const rangePattern = /^(\d+)-(\d+)$/;
494
+ if (numPattern.test(page)) {
495
+ this.appendElement(parent, 'fpage', page);
496
+ }
497
+ else if (rangePattern.test(page)) {
498
+ const [fpage, lpage] = page.split('-');
499
+ this.appendElement(parent, 'fpage', fpage);
500
+ this.appendElement(parent, 'lpage', lpage);
501
+ }
502
+ else {
503
+ this.appendElement(parent, 'page-range', page);
504
+ }
505
+ };
506
+ this.processDate = (parent, tag, date) => {
507
+ const buildISODate = (date) => {
508
+ const dateParts = date['date-parts'];
509
+ if (dateParts && dateParts.length) {
510
+ const [[year, month, day]] = dateParts;
511
+ if (year && month && day) {
512
+ return new Date(Date.UTC(Number(year), Number(month) - 1, Number(day)));
513
+ }
514
+ }
515
+ };
516
+ const isoDate = buildISODate(date);
517
+ if (!isoDate) {
518
+ return;
519
+ }
520
+ return this.appendElement(parent, tag, isoDate.toDateString(), {
521
+ 'iso-8601-date': isoDate.toISOString(),
522
+ });
523
+ };
524
+ this.processRefPersonGroup = (citation, type, people) => {
525
+ if (!(people === null || people === void 0 ? void 0 : people.length)) {
526
+ return;
527
+ }
528
+ const group = this.appendElement(citation, 'person-group', undefined, {
529
+ 'person-group-type': type,
530
+ });
531
+ people.forEach((person) => {
532
+ if (person.literal) {
533
+ this.appendElement(group, 'collab', person.literal);
534
+ return;
535
+ }
536
+ const name = this.createElement('string-name');
537
+ if (person.family) {
538
+ this.appendElement(name, 'surname', person.family);
539
+ }
540
+ if (person.given) {
541
+ this.appendElement(name, 'given-names', person.given);
542
+ }
543
+ if (name.childNodes.length) {
544
+ group.appendChild(name);
545
+ }
546
+ });
547
+ };
548
+ this.createElement = (tag, content, attrs) => {
549
+ const el = this.document.createElement(tag);
550
+ if (content) {
551
+ el.textContent = content;
552
+ }
553
+ if (attrs) {
554
+ Object.entries(attrs).forEach(([k, v]) => el.setAttribute(k, v));
555
+ }
556
+ return el;
557
+ };
558
+ this.appendElement = (parent, tag, content, attrs) => {
559
+ const el = this.createElement(tag, content, attrs);
560
+ parent.appendChild(el);
561
+ return el;
562
+ };
571
563
  this.createSerializer = () => {
572
564
  const nodes = {
573
565
  alt_text: (node) => {
574
- if (node.textContent) {
575
- const altText = this.document.createElement('alt-text');
576
- altText.textContent = node.textContent;
577
- return altText;
578
- }
579
- return '';
566
+ const altText = this.createElement('alt-text');
567
+ altText.textContent = node.textContent;
568
+ return altText;
580
569
  },
581
570
  long_desc: (node) => {
582
- if (node.textContent) {
583
- const longDesc = this.document.createElement('long-desc');
584
- longDesc.textContent = node.textContent;
585
- return longDesc;
586
- }
587
- return '';
571
+ const longDesc = this.createElement('long-desc');
572
+ longDesc.textContent = node.textContent;
573
+ return longDesc;
588
574
  },
589
575
  attachment: () => '',
590
576
  attachments: () => '',
591
577
  image_element: (node) => createImage(node),
592
578
  embed: (node) => {
593
- const mediaElement = this.document.createElement('media');
579
+ const mediaElement = this.createElement('media');
594
580
  const { id, href, mimetype, mimeSubtype } = node.attrs;
595
581
  mediaElement.setAttribute('id', normalizeID(id));
596
582
  mediaElement.setAttributeNS(XLINK_NAMESPACE, 'show', 'embed');
@@ -612,7 +598,7 @@ class JATSExporter {
612
598
  awards: () => ['funding-group', 0],
613
599
  award: (node) => {
614
600
  const awardGroup = node;
615
- const awardGroupElement = this.document.createElement('award-group');
601
+ const awardGroupElement = this.createElement('award-group');
616
602
  awardGroupElement.setAttribute('id', normalizeID(awardGroup.attrs.id));
617
603
  appendChildIfPresent(awardGroupElement, 'funding-source', awardGroup.attrs.source);
618
604
  awardGroup.attrs.code
@@ -670,7 +656,7 @@ class JATSExporter {
670
656
  if (!rids.length) {
671
657
  return '';
672
658
  }
673
- const xref = this.document.createElement('xref');
659
+ const xref = this.createElement('xref');
674
660
  xref.setAttribute('ref-type', 'bibr');
675
661
  xref.setAttribute('rid', normalizeID(rids.join(' ')));
676
662
  const citationTextContent = this.citationTexts.get(node.attrs.id);
@@ -694,7 +680,7 @@ class JATSExporter {
694
680
  warn('');
695
681
  return text || '';
696
682
  }
697
- const xref = this.document.createElement('xref');
683
+ const xref = this.createElement('xref');
698
684
  const type = chooseRefType(target.type);
699
685
  if (type) {
700
686
  xref.setAttribute('ref-type', type);
@@ -711,19 +697,19 @@ class JATSExporter {
711
697
  return this.createEquation(node);
712
698
  },
713
699
  general_table_footnote: (node) => {
714
- const el = this.document.createElement('general-table-footnote');
700
+ const el = this.createElement('general-table-footnote');
715
701
  el.setAttribute('id', normalizeID(node.attrs.id));
716
702
  processChildNodes(el, node, schema_1.schema.nodes.general_table_footnote);
717
703
  return el;
718
704
  },
719
705
  inline_equation: (node) => {
720
- const eqElement = this.document.createElement('inline-formula');
706
+ const eqElement = this.createElement('inline-formula');
721
707
  const equation = this.createEquation(node, true);
722
708
  eqElement.append(equation);
723
709
  return eqElement;
724
710
  },
725
711
  equation_element: (node) => {
726
- const eqElement = this.document.createElement('disp-formula');
712
+ const eqElement = this.createElement('disp-formula');
727
713
  eqElement.setAttribute('id', normalizeID(node.attrs.id));
728
714
  processChildNodes(eqElement, node, schema_1.schema.nodes.equation);
729
715
  return eqElement;
@@ -760,7 +746,7 @@ class JATSExporter {
760
746
  highlight_marker: () => '',
761
747
  inline_footnote: (node) => {
762
748
  const rids = node.attrs.rids;
763
- const xref = this.document.createElement('xref');
749
+ const xref = this.createElement('xref');
764
750
  xref.setAttribute('ref-type', 'fn');
765
751
  xref.setAttribute('rid', normalizeID(rids.join(' ')));
766
752
  xref.textContent = rids
@@ -779,7 +765,7 @@ class JATSExporter {
779
765
  if (!node.attrs.href) {
780
766
  return text;
781
767
  }
782
- const linkNode = this.document.createElement('ext-link');
768
+ const linkNode = this.createElement('ext-link');
783
769
  linkNode.setAttribute('ext-link-type', 'uri');
784
770
  linkNode.setAttributeNS(XLINK_NAMESPACE, 'href', node.attrs.href);
785
771
  linkNode.textContent = text;
@@ -790,7 +776,7 @@ class JATSExporter {
790
776
  },
791
777
  list_item: () => ['list-item', 0],
792
778
  listing: (node) => {
793
- const code = this.document.createElement('code');
779
+ const code = this.createElement('code');
794
780
  code.setAttribute('id', normalizeID(node.attrs.id));
795
781
  code.setAttribute('language', node.attrs.languageKey);
796
782
  code.textContent = node.attrs.contents;
@@ -799,7 +785,7 @@ class JATSExporter {
799
785
  listing_element: (node) => createFigureElement(node, node.type.schema.nodes.listing),
800
786
  manuscript: (node) => ['article', { id: normalizeID(node.attrs.id) }, 0],
801
787
  missing_figure: () => {
802
- const graphic = this.document.createElement('graphic');
788
+ const graphic = this.createElement('graphic');
803
789
  graphic.setAttribute('specific-use', 'MISSING');
804
790
  graphic.setAttributeNS(XLINK_NAMESPACE, 'xlink:href', '');
805
791
  return graphic;
@@ -818,10 +804,10 @@ class JATSExporter {
818
804
  return ['p', attrs, 0];
819
805
  },
820
806
  placeholder: () => {
821
- return this.document.createElement('boxed-text');
807
+ return this.createElement('boxed-text');
822
808
  },
823
809
  placeholder_element: () => {
824
- return this.document.createElement('boxed-text');
810
+ return this.createElement('boxed-text');
825
811
  },
826
812
  pullquote_element: (node) => {
827
813
  var _a;
@@ -892,7 +878,7 @@ class JATSExporter {
892
878
  if (!textContent) {
893
879
  return;
894
880
  }
895
- const element = this.document.createElement(tagName);
881
+ const element = this.createElement(tagName);
896
882
  element.textContent = textContent;
897
883
  parent.appendChild(element);
898
884
  };
@@ -912,7 +898,7 @@ class JATSExporter {
912
898
  });
913
899
  };
914
900
  const createElement = (node, nodeName) => {
915
- const element = this.document.createElement(nodeName);
901
+ const element = this.createElement(nodeName);
916
902
  element.setAttribute('id', normalizeID(node.attrs.id));
917
903
  return element;
918
904
  };
@@ -920,7 +906,7 @@ class JATSExporter {
920
906
  if (this.labelTargets) {
921
907
  const target = this.labelTargets.get(node.attrs.id);
922
908
  if (target) {
923
- const label = this.document.createElement('label');
909
+ const label = this.createElement('label');
924
910
  label.textContent = target.label;
925
911
  element.appendChild(label);
926
912
  }
@@ -928,7 +914,7 @@ class JATSExporter {
928
914
  };
929
915
  const appendAttributions = (element, node) => {
930
916
  if (node.attrs.attribution) {
931
- const attribution = this.document.createElement('attrib');
917
+ const attribution = this.createElement('attrib');
932
918
  attribution.textContent = node.attrs.attribution.literal;
933
919
  element.appendChild(attribution);
934
920
  }
@@ -946,7 +932,7 @@ class JATSExporter {
946
932
  return;
947
933
  }
948
934
  const table = this.serializeNode(tableNode);
949
- const tbodyElement = this.document.createElement('tbody');
935
+ const tbodyElement = this.createElement('tbody');
950
936
  while (table.firstChild) {
951
937
  const child = table.firstChild;
952
938
  table.removeChild(child);
@@ -984,7 +970,7 @@ class JATSExporter {
984
970
  return '';
985
971
  };
986
972
  const createGraphic = (node) => {
987
- const graphic = this.document.createElement('graphic');
973
+ const graphic = this.createElement('graphic');
988
974
  graphic.setAttributeNS(XLINK_NAMESPACE, 'xlink:href', node.attrs.src);
989
975
  if (!isChildOfNodeType(node.attrs.id, schema_1.schema.nodes.figure_element) &&
990
976
  node.attrs.type) {
@@ -1030,10 +1016,10 @@ class JATSExporter {
1030
1016
  if (listingNode) {
1031
1017
  const { contents, languageKey } = listingNode.attrs;
1032
1018
  if (contents && languageKey) {
1033
- const listing = this.document.createElement('fig');
1019
+ const listing = this.createElement('fig');
1034
1020
  listing.setAttribute('specific-use', 'source');
1035
1021
  element.appendChild(listing);
1036
- const code = this.document.createElement('code');
1022
+ const code = this.createElement('code');
1037
1023
  code.setAttribute('executable', 'true');
1038
1024
  code.setAttribute('language', languageKey);
1039
1025
  code.textContent = contents;
@@ -1069,17 +1055,17 @@ class JATSExporter {
1069
1055
  label = affiliationLabels.size + 1;
1070
1056
  affiliationLabels.set(rid, label);
1071
1057
  }
1072
- const sup = this.document.createElement('sup');
1058
+ const sup = this.createElement('sup');
1073
1059
  sup.textContent = String(label);
1074
1060
  return sup;
1075
1061
  };
1076
1062
  const createFootNotesLabels = (content) => {
1077
- const sup = this.document.createElement('sup');
1063
+ const sup = this.createElement('sup');
1078
1064
  sup.textContent = String(content);
1079
1065
  return sup;
1080
1066
  };
1081
1067
  if (authorContributorNodes.length) {
1082
- const contribGroup = this.document.createElement('contrib-group');
1068
+ const contribGroup = this.createElement('contrib-group');
1083
1069
  contribGroup.setAttribute('content-type', 'authors');
1084
1070
  articleMeta.appendChild(contribGroup);
1085
1071
  authorContributorNodes.forEach((contributor) => {
@@ -1090,14 +1076,14 @@ class JATSExporter {
1090
1076
  warn(error.message);
1091
1077
  return;
1092
1078
  }
1093
- const contrib = this.document.createElement('contrib');
1079
+ const contrib = this.createElement('contrib');
1094
1080
  contrib.setAttribute('contrib-type', 'author');
1095
1081
  contrib.setAttribute('id', normalizeID(contributor.attrs.id));
1096
1082
  if (contributor.attrs.isCorresponding) {
1097
1083
  contrib.setAttribute('corresp', 'yes');
1098
1084
  }
1099
1085
  if (contributor.attrs.ORCIDIdentifier) {
1100
- const identifier = this.document.createElement('contrib-id');
1086
+ const identifier = this.createElement('contrib-id');
1101
1087
  identifier.setAttribute('contrib-id-type', 'orcid');
1102
1088
  identifier.textContent = contributor.attrs.ORCIDIdentifier;
1103
1089
  contrib.appendChild(identifier);
@@ -1105,13 +1091,13 @@ class JATSExporter {
1105
1091
  const name = this.buildContributorName(contributor);
1106
1092
  contrib.appendChild(name);
1107
1093
  if (contributor.attrs.email) {
1108
- const email = this.document.createElement('email');
1094
+ const email = this.createElement('email');
1109
1095
  email.textContent = contributor.attrs.email;
1110
1096
  contrib.appendChild(email);
1111
1097
  }
1112
1098
  if (contributor.attrs.affiliations) {
1113
1099
  contributor.attrs.affiliations.forEach((rid) => {
1114
- const xref = this.document.createElement('xref');
1100
+ const xref = this.createElement('xref');
1115
1101
  xref.setAttribute('ref-type', 'aff');
1116
1102
  xref.setAttribute('rid', normalizeID(rid));
1117
1103
  xref.appendChild(creatAffiliationLabel(rid));
@@ -1120,7 +1106,7 @@ class JATSExporter {
1120
1106
  }
1121
1107
  if (contributor.attrs.footnote) {
1122
1108
  contributor.attrs.footnote.map((note) => {
1123
- const xref = this.document.createElement('xref');
1109
+ const xref = this.createElement('xref');
1124
1110
  xref.setAttribute('ref-type', 'fn');
1125
1111
  xref.setAttribute('rid', normalizeID(note.noteID));
1126
1112
  xref.appendChild(createFootNotesLabels(note.noteLabel));
@@ -1129,7 +1115,7 @@ class JATSExporter {
1129
1115
  }
1130
1116
  if (contributor.attrs.corresp) {
1131
1117
  contributor.attrs.corresp.map((corresp) => {
1132
- const xref = this.document.createElement('xref');
1118
+ const xref = this.createElement('xref');
1133
1119
  xref.setAttribute('ref-type', 'corresp');
1134
1120
  xref.setAttribute('rid', normalizeID(corresp.correspID));
1135
1121
  xref.appendChild(createFootNotesLabels(corresp.correspLabel));
@@ -1139,7 +1125,7 @@ class JATSExporter {
1139
1125
  contribGroup.appendChild(contrib);
1140
1126
  });
1141
1127
  if (otherContributorsNodes.length) {
1142
- const contribGroup = this.document.createElement('contrib-group');
1128
+ const contribGroup = this.createElement('contrib-group');
1143
1129
  articleMeta.appendChild(contribGroup);
1144
1130
  otherContributorsNodes.forEach((contributor) => {
1145
1131
  try {
@@ -1149,18 +1135,18 @@ class JATSExporter {
1149
1135
  warn(error.message);
1150
1136
  return;
1151
1137
  }
1152
- const contrib = this.document.createElement('contrib');
1138
+ const contrib = this.createElement('contrib');
1153
1139
  contrib.setAttribute('id', normalizeID(contributor.attrs.id));
1154
1140
  const name = this.buildContributorName(contributor);
1155
1141
  contrib.appendChild(name);
1156
1142
  if (contributor.attrs.email) {
1157
- const email = this.document.createElement('email');
1143
+ const email = this.createElement('email');
1158
1144
  email.textContent = contributor.attrs.email;
1159
1145
  contrib.appendChild(email);
1160
1146
  }
1161
1147
  if (contributor.attrs.affiliations) {
1162
1148
  contributor.attrs.affiliations.forEach((rid) => {
1163
- const xref = this.document.createElement('xref');
1149
+ const xref = this.createElement('xref');
1164
1150
  xref.setAttribute('ref-type', 'aff');
1165
1151
  xref.setAttribute('rid', normalizeID(rid));
1166
1152
  xref.appendChild(creatAffiliationLabel(rid));
@@ -1169,7 +1155,7 @@ class JATSExporter {
1169
1155
  }
1170
1156
  if (contributor.attrs.footnote) {
1171
1157
  contributor.attrs.footnote.map((note) => {
1172
- const xref = this.document.createElement('xref');
1158
+ const xref = this.createElement('xref');
1173
1159
  xref.setAttribute('ref-type', 'fn');
1174
1160
  xref.setAttribute('rid', normalizeID(note.noteID));
1175
1161
  xref.appendChild(createFootNotesLabels(note.noteLabel));
@@ -1196,54 +1182,54 @@ class JATSExporter {
1196
1182
  affiliationRIDs.indexOf(b.attrs.id));
1197
1183
  usedAffiliations.forEach((affiliation) => {
1198
1184
  var _a, _b;
1199
- const aff = this.document.createElement('aff');
1185
+ const aff = this.createElement('aff');
1200
1186
  aff.setAttribute('id', normalizeID(affiliation.attrs.id));
1201
1187
  contribGroup.appendChild(aff);
1202
1188
  if (affiliation.attrs.department) {
1203
- const department = this.document.createElement('institution');
1189
+ const department = this.createElement('institution');
1204
1190
  department.setAttribute('content-type', 'dept');
1205
1191
  department.textContent = affiliation.attrs.department;
1206
1192
  aff.appendChild(department);
1207
1193
  }
1208
1194
  if (affiliation.attrs.institution) {
1209
- const institution = this.document.createElement('institution');
1195
+ const institution = this.createElement('institution');
1210
1196
  institution.textContent = affiliation.attrs.institution;
1211
1197
  aff.appendChild(institution);
1212
1198
  }
1213
1199
  if (affiliation.attrs.addressLine1) {
1214
- const addressLine = this.document.createElement('addr-line');
1200
+ const addressLine = this.createElement('addr-line');
1215
1201
  addressLine.textContent = affiliation.attrs.addressLine1;
1216
1202
  aff.appendChild(addressLine);
1217
1203
  }
1218
1204
  if (affiliation.attrs.addressLine2) {
1219
- const addressLine = this.document.createElement('addr-line');
1205
+ const addressLine = this.createElement('addr-line');
1220
1206
  addressLine.textContent = affiliation.attrs.addressLine2;
1221
1207
  aff.appendChild(addressLine);
1222
1208
  }
1223
1209
  if (affiliation.attrs.addressLine3) {
1224
- const addressLine = this.document.createElement('addr-line');
1210
+ const addressLine = this.createElement('addr-line');
1225
1211
  addressLine.textContent = affiliation.attrs.addressLine3;
1226
1212
  aff.appendChild(addressLine);
1227
1213
  }
1228
1214
  if (affiliation.attrs.city) {
1229
- const city = this.document.createElement('city');
1215
+ const city = this.createElement('city');
1230
1216
  city.textContent = affiliation.attrs.city;
1231
1217
  aff.appendChild(city);
1232
1218
  }
1233
1219
  if (affiliation.attrs.country) {
1234
- const country = this.document.createElement('country');
1220
+ const country = this.createElement('country');
1235
1221
  country.textContent = affiliation.attrs.country;
1236
1222
  aff.appendChild(country);
1237
1223
  }
1238
1224
  if (affiliation.attrs.email) {
1239
- const email = this.document.createElement('email');
1225
+ const email = this.createElement('email');
1240
1226
  email.setAttributeNS(XLINK_NAMESPACE, 'href', (_a = affiliation.attrs.email.href) !== null && _a !== void 0 ? _a : '');
1241
1227
  email.textContent = (_b = affiliation.attrs.email.text) !== null && _b !== void 0 ? _b : '';
1242
1228
  aff.appendChild(email);
1243
1229
  }
1244
1230
  const labelNumber = affiliationLabels.get(affiliation.attrs.id);
1245
1231
  if (labelNumber) {
1246
- const label = this.document.createElement('label');
1232
+ const label = this.createElement('label');
1247
1233
  label.textContent = String(labelNumber);
1248
1234
  aff.appendChild(label);
1249
1235
  }
@@ -1256,7 +1242,7 @@ class JATSExporter {
1256
1242
  }
1257
1243
  };
1258
1244
  this.createAuthorNotesElement = () => {
1259
- const authorNotesEl = this.document.createElement('author-notes');
1245
+ const authorNotesEl = this.createElement('author-notes');
1260
1246
  const authorNotesNode = this.getFirstChildOfType(schema_1.schema.nodes.author_notes);
1261
1247
  if (authorNotesNode) {
1262
1248
  this.appendModelsToAuthorNotes(authorNotesEl, authorNotesNode);
@@ -1264,10 +1250,10 @@ class JATSExporter {
1264
1250
  return authorNotesEl;
1265
1251
  };
1266
1252
  this.appendCorrespondingToElement = (corresponding, element) => {
1267
- const correspondingEl = this.document.createElement('corresp');
1253
+ const correspondingEl = this.createElement('corresp');
1268
1254
  correspondingEl.setAttribute('id', normalizeID(corresponding.attrs.id));
1269
1255
  if (corresponding.attrs.label) {
1270
- const labelEl = this.document.createElement('label');
1256
+ const labelEl = this.createElement('label');
1271
1257
  labelEl.textContent = corresponding.attrs.label;
1272
1258
  correspondingEl.appendChild(labelEl);
1273
1259
  }
@@ -1278,17 +1264,17 @@ class JATSExporter {
1278
1264
  const parsedDoc = new DOMParser().parseFromString(paragraph.textContent, 'text/html');
1279
1265
  const parsedParagraph = parsedDoc.body.querySelector('p');
1280
1266
  if (parsedParagraph) {
1281
- const paragraphEl = this.document.createElement('p');
1267
+ const paragraphEl = this.createElement('p');
1282
1268
  paragraphEl.innerHTML = parsedParagraph.innerHTML;
1283
1269
  paragraphEl.setAttribute('id', normalizeID(paragraph.attrs.id));
1284
1270
  element.appendChild(paragraphEl);
1285
1271
  }
1286
1272
  };
1287
1273
  this.appendFootnoteToElement = (footnote, element) => {
1288
- const footnoteEl = this.document.createElement('fn');
1274
+ const footnoteEl = this.createElement('fn');
1289
1275
  footnoteEl.setAttribute('id', normalizeID(footnote.attrs.id));
1290
1276
  if (!footnote.textContent.includes('<p>')) {
1291
- const p = this.document.createElement('p');
1277
+ const p = this.createElement('p');
1292
1278
  p.innerHTML = footnote.textContent;
1293
1279
  footnoteEl.appendChild(p);
1294
1280
  }
@@ -1331,7 +1317,7 @@ class JATSExporter {
1331
1317
  });
1332
1318
  };
1333
1319
  this.changeTag = (node, tag) => {
1334
- const clone = this.document.createElement(tag);
1320
+ const clone = this.createElement(tag);
1335
1321
  for (const attr of node.attributes) {
1336
1322
  clone.setAttributeNS(null, attr.name, attr.value);
1337
1323
  }
@@ -1352,8 +1338,8 @@ class JATSExporter {
1352
1338
  return;
1353
1339
  }
1354
1340
  const tbodyRows = Array.from(tbody.childNodes);
1355
- const thead = this.document.createElement('thead');
1356
- const tfoot = this.document.createElement('tfoot');
1341
+ const thead = this.createElement('thead');
1342
+ const tfoot = this.createElement('tfoot');
1357
1343
  tbodyRows.forEach((row, i) => {
1358
1344
  const isRow = row instanceof Element && row.tagName.toLowerCase() === 'tr';
1359
1345
  if (isRow) {
@@ -1406,7 +1392,7 @@ class JATSExporter {
1406
1392
  if (!awardGroups.length) {
1407
1393
  return;
1408
1394
  }
1409
- const fundingGroup = this.document.createElement('funding-group');
1395
+ const fundingGroup = this.createElement('funding-group');
1410
1396
  awardGroups.forEach((award) => {
1411
1397
  fundingGroup.appendChild(award);
1412
1398
  });
@@ -1441,7 +1427,7 @@ class JATSExporter {
1441
1427
  }
1442
1428
  const section = body.querySelector('sec[sec-type="acknowledgements"]');
1443
1429
  if (section) {
1444
- const ack = this.document.createElement('ack');
1430
+ const ack = this.createElement('ack');
1445
1431
  while (section.firstChild) {
1446
1432
  ack.appendChild(section.firstChild);
1447
1433
  }
@@ -1452,12 +1438,12 @@ class JATSExporter {
1452
1438
  }
1453
1439
  const appendicesSections = body.querySelectorAll('sec[sec-type="appendices"]');
1454
1440
  if (appendicesSections) {
1455
- const appGroup = this.document.createElement('app-group');
1441
+ const appGroup = this.createElement('app-group');
1456
1442
  appendicesSections.forEach((section) => {
1457
1443
  if (section.parentNode) {
1458
1444
  section.parentNode.removeChild(section);
1459
1445
  }
1460
- const app = this.document.createElement('app');
1446
+ const app = this.createElement('app');
1461
1447
  app.appendChild(section);
1462
1448
  appGroup.appendChild(app);
1463
1449
  });
@@ -1486,17 +1472,17 @@ class JATSExporter {
1486
1472
  }
1487
1473
  }
1488
1474
  if (footNotes.length > 0) {
1489
- const fnGroup = this.document.createElement('fn-group');
1475
+ const fnGroup = this.createElement('fn-group');
1490
1476
  fnGroup.append(...footNotes);
1491
1477
  back.append(fnGroup);
1492
1478
  }
1493
1479
  };
1494
1480
  this.sectionToFootnote = (section, fnType) => {
1495
- const footNote = this.document.createElement('fn');
1481
+ const footNote = this.createElement('fn');
1496
1482
  footNote.setAttribute('fn-type', fnType);
1497
1483
  const title = section.querySelector('title');
1498
1484
  if (title) {
1499
- const footNoteTitle = this.document.createElement('p');
1485
+ const footNoteTitle = this.createElement('p');
1500
1486
  footNoteTitle.setAttribute('content-type', 'fn-title');
1501
1487
  footNoteTitle.textContent = title.textContent;
1502
1488
  section.removeChild(title);
@@ -1509,7 +1495,7 @@ class JATSExporter {
1509
1495
  return footNote;
1510
1496
  };
1511
1497
  this.moveFloatsGroup = (body, article) => {
1512
- const floatsGroup = this.document.createElement('floats-group');
1498
+ const floatsGroup = this.createElement('floats-group');
1513
1499
  const section = body.querySelector('sec[sec-type="floating-element"]');
1514
1500
  if (section) {
1515
1501
  floatsGroup.append(...section.children);
@@ -1520,14 +1506,14 @@ class JATSExporter {
1520
1506
  }
1521
1507
  };
1522
1508
  this.buildContributorName = (contributor) => {
1523
- const name = this.document.createElement('name');
1509
+ const name = this.createElement('name');
1524
1510
  if (contributor.attrs.bibliographicName.family) {
1525
- const surname = this.document.createElement('surname');
1511
+ const surname = this.createElement('surname');
1526
1512
  surname.textContent = contributor.attrs.bibliographicName.family;
1527
1513
  name.appendChild(surname);
1528
1514
  }
1529
1515
  if (contributor.attrs.bibliographicName.given) {
1530
- const givenNames = this.document.createElement('given-names');
1516
+ const givenNames = this.createElement('given-names');
1531
1517
  givenNames.textContent = contributor.attrs.bibliographicName.given;
1532
1518
  name.appendChild(givenNames);
1533
1519
  }
@@ -1566,7 +1552,7 @@ class JATSExporter {
1566
1552
  }
1567
1553
  createEquation(node, isInline = false) {
1568
1554
  if (node.attrs.format === 'tex') {
1569
- const texMath = this.document.createElement('tex-math');
1555
+ const texMath = this.createElement('tex-math');
1570
1556
  texMath.setAttribute('notation', 'LaTeX');
1571
1557
  texMath.setAttribute('version', 'MathJax');
1572
1558
  if (node.attrs.contents.includes('<![CDATA[')) {
@@ -1618,13 +1604,13 @@ class JATSExporter {
1618
1604
  buildKeywords(articleMeta) {
1619
1605
  const keywordGroups = this.getChildrenOfType(schema_1.schema.nodes.keyword_group);
1620
1606
  keywordGroups.forEach((group) => {
1621
- const kwdGroup = this.document.createElement('kwd-group');
1607
+ const kwdGroup = this.createElement('kwd-group');
1622
1608
  if (group.attrs.type) {
1623
1609
  kwdGroup.setAttribute('kwd-group-type', group.attrs.type);
1624
1610
  }
1625
1611
  articleMeta.appendChild(kwdGroup);
1626
1612
  group.content.forEach((keyword) => {
1627
- const kwd = this.document.createElement('kwd');
1613
+ const kwd = this.createElement('kwd');
1628
1614
  kwd.textContent = keyword.textContent;
1629
1615
  kwdGroup.appendChild(kwd);
1630
1616
  });
@@ -1663,7 +1649,7 @@ class JATSExporter {
1663
1649
  }
1664
1650
  }
1665
1651
  createAbstractNode(abstractSection) {
1666
- const abstractNode = this.document.createElement('abstract');
1652
+ const abstractNode = this.createElement('abstract');
1667
1653
  for (const node of abstractSection.childNodes) {
1668
1654
  if (node.nodeName !== 'title') {
1669
1655
  abstractNode.appendChild(node.cloneNode(true));
@@ -1685,7 +1671,7 @@ class JATSExporter {
1685
1671
  if (fnGroup) {
1686
1672
  const coiStatement = fnGroup.querySelector('fn[fn-type="coi-statement"]');
1687
1673
  if (coiStatement) {
1688
- const authorNotes = this.document.createElement('author-notes');
1674
+ const authorNotes = this.createElement('author-notes');
1689
1675
  authorNotes.append(coiStatement);
1690
1676
  const articleMeta = front.querySelector('article-meta');
1691
1677
  if (articleMeta) {
@@ -1731,7 +1717,7 @@ class JATSExporter {
1731
1717
  }
1732
1718
  fillEmptyElements(articleElement, selector, tagName = 'p') {
1733
1719
  const emptyElements = Array.from(articleElement.querySelectorAll(selector)).filter((element) => !element.innerHTML);
1734
- emptyElements.forEach((element) => element.appendChild(this.document.createElement(tagName)));
1720
+ emptyElements.forEach((element) => element.appendChild(this.createElement(tagName)));
1735
1721
  }
1736
1722
  fillEmptyFootnotes(articleElement) {
1737
1723
  this.fillEmptyElements(articleElement, 'fn');