@manuscripts/transform 1.3.4 → 1.3.5

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.
@@ -135,11 +135,13 @@ class JATSExporter {
135
135
  const body = this.buildBody(fragment);
136
136
  article.appendChild(body);
137
137
  const back = this.buildBack(body);
138
+ this.moveCoiStatementToAuthorNotes(back, front);
138
139
  article.appendChild(back);
139
140
  this.unwrapBody(body);
140
141
  this.moveAbstracts(front, body);
141
142
  this.moveFloatsGroup(body, article);
142
143
  this.removeBackContainer(body);
144
+ this.updateFootnoteTypes(front, back);
143
145
  }
144
146
  await this.rewriteIDs(idGenerator);
145
147
  if (mediaPathGenerator) {
@@ -1575,5 +1577,37 @@ class JATSExporter {
1575
1577
  articleMeta.appendChild(kwdGroup);
1576
1578
  }
1577
1579
  }
1580
+ moveCoiStatementToAuthorNotes(back, front) {
1581
+ const fnGroups = back.querySelectorAll('fn-group');
1582
+ fnGroups.forEach((fnGroup) => {
1583
+ if (fnGroup) {
1584
+ const coiStatement = fnGroup.querySelector('fn[fn-type="competing-interests"]');
1585
+ if (coiStatement) {
1586
+ const authorNotes = this.document.createElement('author-notes');
1587
+ authorNotes.append(coiStatement);
1588
+ const articleMeta = front.querySelector('article-meta');
1589
+ if (articleMeta) {
1590
+ const authorNoteEl = articleMeta.querySelector('author-notes');
1591
+ if (authorNoteEl) {
1592
+ authorNoteEl.append(...authorNotes.childNodes);
1593
+ }
1594
+ else {
1595
+ articleMeta.appendChild(authorNotes);
1596
+ }
1597
+ }
1598
+ }
1599
+ }
1600
+ });
1601
+ }
1602
+ updateFootnoteTypes(front, body) {
1603
+ const footnotes = [...front.querySelectorAll('fn').values()];
1604
+ footnotes.push(...body.querySelectorAll('fn'));
1605
+ footnotes.forEach((fn) => {
1606
+ const fnType = fn.getAttribute('fn-type');
1607
+ if (fnType) {
1608
+ fn.setAttribute('fn-type', (0, section_category_1.chooseJatsFnType)(fnType));
1609
+ }
1610
+ });
1611
+ }
1578
1612
  }
1579
1613
  exports.JATSExporter = JATSExporter;
@@ -18,7 +18,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
18
18
  return (mod && mod.__esModule) ? mod : { "default": mod };
19
19
  };
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.chooseSectionCategoryFromTitle = exports.chooseSectionCategory = exports.chooseSectionCategoryByType = exports.chooseSecType = exports.buildSectionCategory = exports.guessSectionCategory = exports.chooseSectionLableName = exports.chooseSectionNodeType = exports.isAnySectionNode = exports.getSectionTitles = void 0;
21
+ exports.chooseSectionCategoryFromTitle = exports.chooseSectionCategory = exports.chooseSectionCategoryByType = exports.chooseSecType = exports.chooseJatsFnType = exports.buildSectionCategory = exports.guessSectionCategory = exports.chooseSectionLableName = exports.chooseSectionNodeType = exports.isAnySectionNode = exports.getSectionTitles = void 0;
22
22
  const section_categories_json_1 = __importDefault(require("@manuscripts/data/dist/shared/section-categories.json"));
23
23
  const json_schema_1 = require("@manuscripts/json-schema");
24
24
  const schema_1 = require("../schema");
@@ -104,6 +104,15 @@ const buildSectionCategory = (node) => {
104
104
  }
105
105
  };
106
106
  exports.buildSectionCategory = buildSectionCategory;
107
+ const chooseJatsFnType = (footnoteType) => {
108
+ switch (footnoteType) {
109
+ case 'competing-interests':
110
+ return 'coi-statement';
111
+ default:
112
+ return footnoteType;
113
+ }
114
+ };
115
+ exports.chooseJatsFnType = chooseJatsFnType;
107
116
  const chooseSecType = (sectionCategory) => {
108
117
  const [, suffix] = sectionCategory.split(':', 2);
109
118
  switch (suffix) {
@@ -26,7 +26,7 @@ import { buildTargets } from '../transformer/labels';
26
26
  import { isExecutableNodeType, isNodeType } from '../transformer/node-types';
27
27
  import { hasObjectType } from '../transformer/object-types';
28
28
  import { findManuscript, findManuscriptById, } from '../transformer/project-bundle';
29
- import { chooseSecType } from '../transformer/section-category';
29
+ import { chooseJatsFnType, chooseSecType, } from '../transformer/section-category';
30
30
  import { selectVersionIds } from './jats-versions';
31
31
  const warn = debug('manuscripts-transform');
32
32
  const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
@@ -128,11 +128,13 @@ export class JATSExporter {
128
128
  const body = this.buildBody(fragment);
129
129
  article.appendChild(body);
130
130
  const back = this.buildBack(body);
131
+ this.moveCoiStatementToAuthorNotes(back, front);
131
132
  article.appendChild(back);
132
133
  this.unwrapBody(body);
133
134
  this.moveAbstracts(front, body);
134
135
  this.moveFloatsGroup(body, article);
135
136
  this.removeBackContainer(body);
137
+ this.updateFootnoteTypes(front, back);
136
138
  }
137
139
  await this.rewriteIDs(idGenerator);
138
140
  if (mediaPathGenerator) {
@@ -1568,4 +1570,36 @@ export class JATSExporter {
1568
1570
  articleMeta.appendChild(kwdGroup);
1569
1571
  }
1570
1572
  }
1573
+ moveCoiStatementToAuthorNotes(back, front) {
1574
+ const fnGroups = back.querySelectorAll('fn-group');
1575
+ fnGroups.forEach((fnGroup) => {
1576
+ if (fnGroup) {
1577
+ const coiStatement = fnGroup.querySelector('fn[fn-type="competing-interests"]');
1578
+ if (coiStatement) {
1579
+ const authorNotes = this.document.createElement('author-notes');
1580
+ authorNotes.append(coiStatement);
1581
+ const articleMeta = front.querySelector('article-meta');
1582
+ if (articleMeta) {
1583
+ const authorNoteEl = articleMeta.querySelector('author-notes');
1584
+ if (authorNoteEl) {
1585
+ authorNoteEl.append(...authorNotes.childNodes);
1586
+ }
1587
+ else {
1588
+ articleMeta.appendChild(authorNotes);
1589
+ }
1590
+ }
1591
+ }
1592
+ }
1593
+ });
1594
+ }
1595
+ updateFootnoteTypes(front, body) {
1596
+ const footnotes = [...front.querySelectorAll('fn').values()];
1597
+ footnotes.push(...body.querySelectorAll('fn'));
1598
+ footnotes.forEach((fn) => {
1599
+ const fnType = fn.getAttribute('fn-type');
1600
+ if (fnType) {
1601
+ fn.setAttribute('fn-type', chooseJatsFnType(fnType));
1602
+ }
1603
+ });
1604
+ }
1571
1605
  }
@@ -92,6 +92,14 @@ export const buildSectionCategory = (node) => {
92
92
  return node.attrs.category || undefined;
93
93
  }
94
94
  };
95
+ export const chooseJatsFnType = (footnoteType) => {
96
+ switch (footnoteType) {
97
+ case 'competing-interests':
98
+ return 'coi-statement';
99
+ default:
100
+ return footnoteType;
101
+ }
102
+ };
95
103
  export const chooseSecType = (sectionCategory) => {
96
104
  const [, suffix] = sectionCategory.split(':', 2);
97
105
  switch (suffix) {
@@ -70,5 +70,7 @@ export declare class JATSExporter {
70
70
  sectionToFootnote: (section: Element, fnType: string) => HTMLElement;
71
71
  private moveFloatsGroup;
72
72
  private buildContributorName;
73
+ private moveCoiStatementToAuthorNotes;
74
+ private updateFootnoteTypes;
73
75
  }
74
76
  export {};
@@ -23,6 +23,7 @@ export declare const chooseSectionNodeType: (category?: SectionCategory) => Manu
23
23
  export declare const chooseSectionLableName: (type?: SecType) => string;
24
24
  export declare const guessSectionCategory: (elements: Element[]) => SectionCategory | undefined;
25
25
  export declare const buildSectionCategory: (node: ManuscriptNode) => SectionCategory | undefined;
26
+ export declare const chooseJatsFnType: (footnoteType: string) => string;
26
27
  export declare const chooseSecType: (sectionCategory: SectionCategory) => SecType;
27
28
  export declare const chooseSectionCategoryByType: (secType: string) => SectionCategory | undefined;
28
29
  export declare const chooseSectionCategory: (section: HTMLElement) => SectionCategory | 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": "1.3.4",
4
+ "version": "1.3.5",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-transform",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",