@manuscripts/transform 2.1.4 → 2.1.5-LEAN-3376-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/dist/cjs/index.js +0 -1
  2. package/dist/cjs/jats/importer/jats-body-dom-parser.js +27 -72
  3. package/dist/cjs/jats/importer/jats-body-transformations.js +3 -1
  4. package/dist/cjs/jats/importer/jats-front-parser.js +39 -1
  5. package/dist/cjs/jats/importer/jats-parser-utils.js +6 -0
  6. package/dist/cjs/jats/importer/parse-jats-article.js +3 -6
  7. package/dist/cjs/jats/jats-exporter.js +94 -83
  8. package/dist/cjs/schema/index.js +3 -2
  9. package/dist/cjs/{mathjax/mathjax-packages.js → schema/nodes/author_notes.js} +10 -3
  10. package/dist/cjs/schema/nodes/contributors.js +1 -1
  11. package/dist/cjs/schema/nodes/equation.js +12 -14
  12. package/dist/cjs/schema/nodes/equation_element.js +4 -5
  13. package/dist/cjs/schema/nodes/inline_equation.js +13 -15
  14. package/dist/cjs/transformer/builders.js +11 -14
  15. package/dist/cjs/transformer/decode.js +17 -8
  16. package/dist/cjs/transformer/encode.js +8 -25
  17. package/dist/cjs/transformer/node-types.js +2 -1
  18. package/dist/cjs/transformer/object-types.js +0 -1
  19. package/dist/es/index.js +0 -1
  20. package/dist/es/jats/importer/jats-body-dom-parser.js +28 -73
  21. package/dist/es/jats/importer/jats-body-transformations.js +3 -1
  22. package/dist/es/jats/importer/jats-front-parser.js +40 -2
  23. package/dist/es/jats/importer/jats-parser-utils.js +6 -0
  24. package/dist/es/jats/importer/parse-jats-article.js +3 -6
  25. package/dist/es/jats/jats-exporter.js +97 -86
  26. package/dist/es/schema/index.js +3 -2
  27. package/dist/{types/mathjax/mathjax-packages.d.ts → es/schema/nodes/author_notes.js} +9 -1
  28. package/dist/es/schema/nodes/contributors.js +1 -1
  29. package/dist/es/schema/nodes/equation.js +12 -14
  30. package/dist/es/schema/nodes/equation_element.js +4 -5
  31. package/dist/es/schema/nodes/inline_equation.js +13 -15
  32. package/dist/es/transformer/builders.js +9 -12
  33. package/dist/es/transformer/decode.js +17 -8
  34. package/dist/es/transformer/encode.js +8 -25
  35. package/dist/es/transformer/node-types.js +2 -1
  36. package/dist/es/transformer/object-types.js +0 -1
  37. package/dist/types/index.d.ts +0 -1
  38. package/dist/types/jats/importer/jats-front-parser.d.ts +10 -1
  39. package/dist/types/jats/jats-exporter.d.ts +5 -0
  40. package/dist/types/schema/index.d.ts +0 -1
  41. package/dist/{es/mathjax/mathjax-packages.js → types/schema/nodes/author_notes.d.ts} +10 -2
  42. package/dist/types/schema/nodes/equation.d.ts +3 -4
  43. package/dist/types/schema/nodes/equation_element.d.ts +1 -2
  44. package/dist/types/schema/nodes/inline_equation.d.ts +4 -3
  45. package/dist/types/schema/types.d.ts +1 -1
  46. package/dist/types/transformer/builders.d.ts +3 -3
  47. package/package.json +4 -5
  48. package/dist/cjs/mathjax/index.js +0 -41
  49. package/dist/cjs/mathjax/mathml-to-svg.js +0 -70
  50. package/dist/cjs/mathjax/tex-to-mathml.js +0 -49
  51. package/dist/cjs/mathjax/tex-to-svg.js +0 -59
  52. package/dist/es/mathjax/index.js +0 -12
  53. package/dist/es/mathjax/mathml-to-svg.js +0 -66
  54. package/dist/es/mathjax/tex-to-mathml.js +0 -45
  55. package/dist/es/mathjax/tex-to-svg.js +0 -55
  56. package/dist/types/mathjax/index.d.ts +0 -3
  57. package/dist/types/mathjax/mathml-to-svg.d.ts +0 -17
  58. package/dist/types/mathjax/tex-to-mathml.d.ts +0 -17
  59. package/dist/types/mathjax/tex-to-svg.d.ts +0 -17
package/dist/cjs/index.js CHANGED
@@ -18,7 +18,6 @@ exports.isSectionLabelNode = void 0;
18
18
  __exportStar(require("./lib/section-group-type"), exports);
19
19
  __exportStar(require("./lib/table-cell-styles"), exports);
20
20
  __exportStar(require("./lib/utils"), exports);
21
- __exportStar(require("./mathjax"), exports);
22
21
  __exportStar(require("./schema"), exports);
23
22
  __exportStar(require("./transformer"), exports);
24
23
  __exportStar(require("./jats"), exports);
@@ -21,8 +21,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.jatsBodyDOMParser = void 0;
22
22
  const mime_1 = __importDefault(require("mime"));
23
23
  const prosemirror_model_1 = require("prosemirror-model");
24
- const mathml_to_svg_1 = require("../../mathjax/mathml-to-svg");
25
- const tex_to_svg_1 = require("../../mathjax/tex-to-svg");
26
24
  const schema_1 = require("../../schema");
27
25
  const transformer_1 = require("../../transformer");
28
26
  const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
@@ -39,6 +37,28 @@ const chooseContentType = (graphicNode) => {
39
37
  }
40
38
  }
41
39
  };
40
+ const getEquationContent = (p) => {
41
+ var _a;
42
+ const element = p;
43
+ const id = element.getAttribute('id');
44
+ const container = (_a = element.querySelector('alternatives')) !== null && _a !== void 0 ? _a : element;
45
+ let contents = '';
46
+ let format = '';
47
+ for (const child of container.childNodes) {
48
+ const nodeName = child.nodeName.replace(/^[a-z]:/, '');
49
+ switch (nodeName) {
50
+ case 'tex-math':
51
+ contents = child.innerHTML;
52
+ format = 'tex';
53
+ break;
54
+ case 'mml:math':
55
+ contents = child.outerHTML;
56
+ format = 'mathml';
57
+ break;
58
+ }
59
+ }
60
+ return { id, format, contents };
61
+ };
42
62
  const marks = [
43
63
  {
44
64
  tag: 'bold',
@@ -147,91 +167,26 @@ const nodes = [
147
167
  tag: 'inline-formula',
148
168
  node: 'inline_equation',
149
169
  getAttrs: (node) => {
150
- var _a, _b, _c, _d, _e;
151
170
  const element = node;
152
- const attrs = {
153
- id: element.getAttribute('id'),
154
- MathMLRepresentation: '',
155
- SVGRepresentation: '',
156
- TeXRepresentation: '',
157
- };
158
- const container = (_a = element.querySelector('alternatives')) !== null && _a !== void 0 ? _a : element;
159
- for (const child of container.childNodes) {
160
- const nodeName = child.nodeName.replace(/^[a-z]:/, '');
161
- switch (nodeName) {
162
- case 'tex-math':
163
- attrs.TeXRepresentation = (_c = (_b = child.textContent) === null || _b === void 0 ? void 0 : _b.trim()) !== null && _c !== void 0 ? _c : '';
164
- if (attrs.TeXRepresentation) {
165
- attrs.SVGRepresentation =
166
- (_d = (0, tex_to_svg_1.convertTeXToSVG)(attrs.TeXRepresentation, true)) !== null && _d !== void 0 ? _d : '';
167
- }
168
- break;
169
- case 'mml:math':
170
- ;
171
- child.removeAttribute('id');
172
- attrs.MathMLRepresentation = transformer_1.xmlSerializer.serializeToString(child);
173
- if (attrs.MathMLRepresentation) {
174
- attrs.SVGRepresentation =
175
- (_e = (0, mathml_to_svg_1.convertMathMLToSVG)(attrs.MathMLRepresentation, true)) !== null && _e !== void 0 ? _e : '';
176
- }
177
- break;
178
- }
179
- }
180
- return attrs;
171
+ return getEquationContent(element);
181
172
  },
182
173
  },
183
174
  {
184
175
  tag: 'disp-formula',
185
176
  node: 'equation_element',
186
177
  getAttrs: (node) => {
178
+ var _a, _b;
187
179
  const element = node;
188
- const caption = element.querySelector('figcaption');
189
180
  return {
190
181
  id: element.getAttribute('id'),
191
- suppressCaption: !caption,
182
+ label: (_b = (_a = element.querySelector('label')) === null || _a === void 0 ? void 0 : _a.textContent) !== null && _b !== void 0 ? _b : '',
192
183
  };
193
184
  },
194
185
  getContent: (node, schema) => {
195
- var _a, _b, _c, _d, _e;
196
186
  const element = node;
197
- const attrs = {
198
- MathMLStringRepresentation: '',
199
- SVGStringRepresentation: '',
200
- TeXRepresentation: '',
201
- };
202
- const container = (_a = element.querySelector('alternatives')) !== null && _a !== void 0 ? _a : element;
203
- for (const child of container.childNodes) {
204
- const nodeName = child.nodeName.replace(/^[a-z]:/, '');
205
- switch (nodeName) {
206
- case 'tex-math':
207
- attrs.TeXRepresentation = (_c = (_b = child.textContent) === null || _b === void 0 ? void 0 : _b.trim()) !== null && _c !== void 0 ? _c : '';
208
- if (attrs.TeXRepresentation) {
209
- attrs.SVGStringRepresentation =
210
- (_d = (0, tex_to_svg_1.convertTeXToSVG)(attrs.TeXRepresentation, true)) !== null && _d !== void 0 ? _d : '';
211
- }
212
- break;
213
- case 'mml:math':
214
- ;
215
- child.removeAttribute('id');
216
- attrs.MathMLStringRepresentation =
217
- transformer_1.xmlSerializer.serializeToString(child);
218
- if (attrs.MathMLStringRepresentation) {
219
- attrs.SVGStringRepresentation =
220
- (_e = (0, mathml_to_svg_1.convertMathMLToSVG)(attrs.MathMLStringRepresentation, true)) !== null && _e !== void 0 ? _e : '';
221
- }
222
- break;
223
- }
224
- }
225
- const caption = element.querySelector('figcaption');
226
- const figcaption = schema.nodes.figcaption.create();
187
+ const attrs = getEquationContent(element);
227
188
  return prosemirror_model_1.Fragment.from([
228
- schema.nodes.equation.createChecked(attrs),
229
- caption
230
- ?
231
- exports.jatsBodyDOMParser.parse(caption, {
232
- topNode: figcaption,
233
- })
234
- : figcaption,
189
+ schema.nodes.equation.createChecked(Object.assign({}, attrs)),
235
190
  ]);
236
191
  },
237
192
  },
@@ -202,7 +202,9 @@ exports.jatsBodyTransformations = {
202
202
  }
203
203
  },
204
204
  moveFootnotes(doc, group, createElement) {
205
- const footnotes = [...doc.querySelectorAll('fn:not(table-wrap-foot fn)')];
205
+ const footnotes = [
206
+ ...doc.querySelectorAll('fn:not(table-wrap-foot fn, author-notes fn)'),
207
+ ];
206
208
  const footnotesSection = doc.querySelector('sec[sec-type="endnotes"]');
207
209
  const footnotesSectionGroup = footnotesSection === null || footnotesSection === void 0 ? void 0 : footnotesSection.querySelector('fn-group');
208
210
  const containingGroup = footnotesSectionGroup || createElement('fn-group');
@@ -179,7 +179,45 @@ exports.jatsFrontParser = {
179
179
  affiliationIDs,
180
180
  };
181
181
  },
182
- parseAuthorNotes(elements) {
182
+ parseAuthorNotes(element) {
183
+ if (!element) {
184
+ return {
185
+ footnotes: [],
186
+ footnoteIDs: new Map(),
187
+ authorNotes: [],
188
+ authorNotesParagraphs: [],
189
+ correspondingIDs: new Map(),
190
+ correspondingList: [],
191
+ };
192
+ }
193
+ const { footnotes, footnoteIDs } = this.parseFootnotes([
194
+ ...element.querySelectorAll('fn:not([fn-type])'),
195
+ ]);
196
+ const authorNotesParagraphs = this.parseParagraphs([
197
+ ...element.querySelectorAll(':scope > p'),
198
+ ]);
199
+ const { correspondingList, correspondingIDs } = this.parseCorresp([
200
+ ...element.querySelectorAll('corresp'),
201
+ ]);
202
+ const authorNotes = [
203
+ (0, transformer_1.buildAuthorNotes)([
204
+ ...footnoteIDs.values(),
205
+ ...authorNotesParagraphs.map((p) => p._id),
206
+ ]),
207
+ ];
208
+ return {
209
+ footnotes,
210
+ footnoteIDs,
211
+ authorNotesParagraphs,
212
+ authorNotes,
213
+ correspondingIDs,
214
+ correspondingList,
215
+ };
216
+ },
217
+ parseParagraphs(elements) {
218
+ return elements.map((p) => (0, transformer_1.buildParagraph)(p.innerHTML));
219
+ },
220
+ parseFootnotes(elements) {
183
221
  const footnoteIDs = new Map();
184
222
  const footnotes = elements.map((element) => {
185
223
  const fn = (0, transformer_1.buildFootnote)('', element.innerHTML);
@@ -16,6 +16,8 @@
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.htmlFromJatsNode = exports.updateDocumentIDs = void 0;
19
+ const uuid_1 = require("uuid");
20
+ const schema_1 = require("../../schema");
19
21
  const transformer_1 = require("../../transformer");
20
22
  const updateDocumentIDs = (node, replacements) => {
21
23
  const warnings = [];
@@ -30,6 +32,10 @@ function recurseDoc(node, fn) {
30
32
  node.descendants((n) => fn(n));
31
33
  }
32
34
  const updateNodeID = (node, replacements, warnings) => {
35
+ if (node.type === schema_1.schema.nodes.inline_equation) {
36
+ node.attrs = Object.assign(Object.assign({}, node.attrs), { id: `InlineMathFragment:${(0, uuid_1.v4)()}` });
37
+ return;
38
+ }
33
39
  if (!('id' in node.attrs)) {
34
40
  return;
35
41
  }
@@ -35,12 +35,7 @@ const parseJATSFront = (doc, front) => {
35
35
  const { affiliations, affiliationIDs } = jats_front_parser_1.jatsFrontParser.parseAffiliations([
36
36
  ...front.querySelectorAll('article-meta > contrib-group > aff'),
37
37
  ]);
38
- const { footnotes, footnoteIDs } = jats_front_parser_1.jatsFrontParser.parseAuthorNotes([
39
- ...front.querySelectorAll('article-meta > author-notes > fn:not([fn-type])'),
40
- ]);
41
- const { correspondingList, correspondingIDs } = jats_front_parser_1.jatsFrontParser.parseCorresp([
42
- ...front.querySelectorAll('article-meta > author-notes > corresp'),
43
- ]);
38
+ const { footnotes, footnoteIDs, authorNotes, authorNotesParagraphs, correspondingIDs, correspondingList, } = jats_front_parser_1.jatsFrontParser.parseAuthorNotes(front.querySelector('article-meta > author-notes'));
44
39
  const authors = jats_front_parser_1.jatsFrontParser.parseContributors([
45
40
  ...front.querySelectorAll('article-meta > contrib-group > contrib[contrib-type="author"]'),
46
41
  ], affiliationIDs, footnoteIDs, correspondingIDs);
@@ -51,6 +46,8 @@ const parseJATSFront = (doc, front) => {
51
46
  manuscript,
52
47
  titles,
53
48
  journal,
49
+ ...authorNotesParagraphs,
50
+ ...authorNotes,
54
51
  ...footnotes,
55
52
  ...authors,
56
53
  ...affiliations,
@@ -95,7 +95,7 @@ const createDefaultIdGenerator = () => {
95
95
  const counter = (0, exports.createCounter)();
96
96
  return async (element) => {
97
97
  const value = String(counter.increment(element.nodeName));
98
- return `${element.nodeName}-${value}`;
98
+ return `${element.localName}-${value}`;
99
99
  };
100
100
  };
101
101
  const chooseRefType = (objectType) => {
@@ -164,6 +164,7 @@ class JATSExporter {
164
164
  };
165
165
  this.nodeFromJATS = (JATSFragment) => {
166
166
  JATSFragment = JATSFragment.trim();
167
+ JATSFragment = JATSFragment.replace(' ', ' ');
167
168
  if (!JATSFragment.length) {
168
169
  return null;
169
170
  }
@@ -614,6 +615,7 @@ class JATSExporter {
614
615
  this.createSerializer = () => {
615
616
  const getModel = (id) => id ? this.modelMap.get(id) : undefined;
616
617
  const nodes = {
618
+ author_notes: () => ['author-notes', 0],
617
619
  title: () => '',
618
620
  affiliations: () => '',
619
621
  contributors: () => '',
@@ -686,22 +688,20 @@ class JATSExporter {
686
688
  },
687
689
  doc: () => '',
688
690
  equation: (node) => {
689
- const formula = this.document.createElement('disp-formula');
690
- formula.setAttribute('id', normalizeID(node.attrs.id));
691
- if (node.attrs.TeXRepresentation) {
692
- const math = this.document.createElement('tex-math');
693
- math.textContent = node.attrs.TeXRepresentation;
694
- formula.appendChild(math);
695
- }
696
- else if (node.attrs.MathMLStringRepresentation) {
697
- const math = this.nodeFromJATS(node.attrs.MathMLStringRepresentation);
698
- if (math) {
699
- formula.appendChild(math);
700
- }
701
- }
702
- return formula;
691
+ return this.createEquation(node);
692
+ },
693
+ inline_equation: (node) => {
694
+ const eqElement = this.document.createElement('inline-formula');
695
+ const equation = this.createEquation(node, true);
696
+ eqElement.append(equation);
697
+ return eqElement;
698
+ },
699
+ equation_element: (node) => {
700
+ const eqElement = this.document.createElement('disp-formula');
701
+ eqElement.setAttribute('id', normalizeID(node.attrs.id));
702
+ processChildNodes(eqElement, node, schema_1.schema.nodes.equation);
703
+ return eqElement;
703
704
  },
704
- equation_element: (node) => createFigureElement(node, 'fig', node.type.schema.nodes.equation, 'equation'),
705
705
  figcaption: (node) => {
706
706
  if (!node.textContent) {
707
707
  return '';
@@ -751,28 +751,6 @@ class JATSExporter {
751
751
  },
752
752
  hard_break: () => '',
753
753
  highlight_marker: () => '',
754
- inline_equation: (node) => {
755
- const formula = this.document.createElement('inline-formula');
756
- formula.setAttribute('id', normalizeID(node.attrs.id));
757
- if (node.attrs.TeXRepresentation) {
758
- const math = this.document.createElement('tex-math');
759
- math.textContent = node.attrs.TeXRepresentation;
760
- formula.appendChild(math);
761
- }
762
- else if (node.attrs.MathMLRepresentation) {
763
- const math = this.nodeFromJATS(node.attrs.MathMLRepresentation);
764
- if (math) {
765
- formula.appendChild(math);
766
- }
767
- }
768
- else if (node.attrs.SVGRepresentation) {
769
- const math = this.nodeFromJATS(node.attrs.SVGRepresentation);
770
- if (math) {
771
- formula.appendChild(math);
772
- }
773
- }
774
- return formula;
775
- },
776
754
  inline_footnote: (node) => {
777
755
  const xref = this.document.createElement('xref');
778
756
  xref.setAttribute('ref-type', 'fn');
@@ -1058,6 +1036,7 @@ class JATSExporter {
1058
1036
  }
1059
1037
  };
1060
1038
  this.buildContributors = (articleMeta) => {
1039
+ var _a;
1061
1040
  const contributors = this.models.filter(isContributor);
1062
1041
  const authorContributors = contributors
1063
1042
  .filter((contributor) => contributor.role === 'author')
@@ -1276,56 +1255,64 @@ class JATSExporter {
1276
1255
  }
1277
1256
  });
1278
1257
  }
1279
- const noteIDs = [];
1280
- for (const contributor of [...authorContributors, ...otherContributors]) {
1281
- if (contributor.footnote) {
1282
- const ids = contributor.footnote.map((note) => {
1283
- return note.noteID;
1284
- });
1285
- noteIDs.push(...ids);
1286
- }
1287
- if (contributor.corresp) {
1288
- const ids = contributor.corresp.map((corresp) => {
1289
- return corresp.correspID;
1290
- });
1291
- noteIDs.push(...ids);
1292
- }
1293
- }
1294
- const footnotes = [];
1295
- footnotes.push(...this.models.filter((0, object_types_1.hasObjectType)(json_schema_1.ObjectTypes.Footnote)));
1296
- const correspodings = [];
1297
- correspodings.push(...this.models.filter((0, object_types_1.hasObjectType)(json_schema_1.ObjectTypes.Corresponding)));
1298
- if (footnotes || correspodings) {
1299
- const authorNotesEl = this.document.createElement('author-notes');
1300
- const usedFootnotes = footnotes.filter((footnote) => {
1301
- return noteIDs.includes(footnote._id);
1302
- });
1303
- const usedCorrespodings = correspodings.filter((corresp) => {
1304
- return noteIDs.includes(corresp._id);
1305
- });
1306
- usedFootnotes.forEach((footnote) => {
1307
- const authorFootNote = this.document.createElement('fn');
1308
- authorFootNote.setAttribute('id', normalizeID(footnote._id));
1309
- authorFootNote.innerHTML = footnote.contents;
1310
- authorNotesEl.appendChild(authorFootNote);
1311
- });
1312
- usedCorrespodings.forEach((corresponding) => {
1313
- const correspondingEl = this.document.createElement('corresp');
1314
- correspondingEl.setAttribute('id', normalizeID(corresponding._id));
1315
- if (corresponding.label) {
1316
- const labelEl = this.document.createElement('label');
1317
- labelEl.textContent = corresponding.label;
1318
- correspondingEl.appendChild(labelEl);
1258
+ const authorNotesEl = this.document.createElement('author-notes');
1259
+ const usedCorrespodings = this.getUsedCorrespondings([
1260
+ ...authorContributors,
1261
+ ...otherContributors,
1262
+ ]);
1263
+ usedCorrespodings.forEach((corresp) => {
1264
+ this.appendCorrespondingToElement(corresp, authorNotesEl);
1265
+ });
1266
+ const authorNotes = (_a = (0, json_schema_1.getModelsByType)(this.modelMap, json_schema_1.ObjectTypes.AuthorNotes)) === null || _a === void 0 ? void 0 : _a[0];
1267
+ if (authorNotes) {
1268
+ authorNotes.containedObjectIDs.forEach((id) => {
1269
+ const model = this.modelMap.get(id);
1270
+ if (!model) {
1271
+ return;
1272
+ }
1273
+ if (id.startsWith('MPParagraphElement')) {
1274
+ this.appendParagraphToElement(model, authorNotesEl);
1275
+ }
1276
+ else if (id.startsWith('MPFootnote')) {
1277
+ this.appendFootnoteToElement(model, authorNotesEl);
1319
1278
  }
1320
- correspondingEl.append(corresponding.contents);
1321
- authorNotesEl.appendChild(correspondingEl);
1322
1279
  });
1323
- if (authorNotesEl.childNodes.length > 0) {
1324
- articleMeta.insertBefore(authorNotesEl, contribGroup.nextSibling);
1325
- }
1280
+ }
1281
+ if (authorNotesEl.childNodes.length > 0) {
1282
+ articleMeta.insertBefore(authorNotesEl, contribGroup.nextSibling);
1326
1283
  }
1327
1284
  }
1328
1285
  };
1286
+ this.appendCorrespondingToElement = (corresponding, element) => {
1287
+ const correspondingEl = this.document.createElement('corresp');
1288
+ correspondingEl.setAttribute('id', normalizeID(corresponding._id));
1289
+ if (corresponding.label) {
1290
+ const labelEl = this.document.createElement('label');
1291
+ labelEl.textContent = corresponding.label;
1292
+ correspondingEl.appendChild(labelEl);
1293
+ }
1294
+ correspondingEl.append(corresponding.contents);
1295
+ element.appendChild(correspondingEl);
1296
+ };
1297
+ this.appendParagraphToElement = (paragraph, element) => {
1298
+ const parsedDoc = new DOMParser().parseFromString(paragraph.contents, 'text/html');
1299
+ const parsedParagraph = parsedDoc.body.querySelector('p');
1300
+ if (parsedParagraph) {
1301
+ const paragraphEl = this.document.createElement('p');
1302
+ paragraphEl.innerHTML = parsedParagraph.innerHTML;
1303
+ const value = parsedParagraph.getAttribute('id');
1304
+ if (value) {
1305
+ paragraphEl.setAttribute('id', value);
1306
+ }
1307
+ element.appendChild(paragraphEl);
1308
+ }
1309
+ };
1310
+ this.appendFootnoteToElement = (footnote, element) => {
1311
+ const footnoteEl = this.document.createElement('fn');
1312
+ footnoteEl.setAttribute('id', normalizeID(footnote._id));
1313
+ footnoteEl.innerHTML = footnote.contents;
1314
+ element.appendChild(footnoteEl);
1315
+ };
1329
1316
  this.fixBody = (body, fragment) => {
1330
1317
  fragment.descendants((node) => {
1331
1318
  if (node.attrs.id) {
@@ -1613,6 +1600,27 @@ class JATSExporter {
1613
1600
  this.citationTexts.set(id, output);
1614
1601
  });
1615
1602
  }
1603
+ createEquation(node, isInline = false) {
1604
+ if (node.attrs.format === 'tex') {
1605
+ const texMath = this.document.createElement('tex-math');
1606
+ texMath.innerHTML = node.attrs.contents;
1607
+ return texMath;
1608
+ }
1609
+ else {
1610
+ const math = this.nodeFromJATS(node.attrs.contents);
1611
+ const mathml = math;
1612
+ if (!isInline) {
1613
+ mathml.setAttribute('id', normalizeID(node.attrs.id));
1614
+ }
1615
+ return mathml;
1616
+ }
1617
+ }
1618
+ getUsedCorrespondings(contributors) {
1619
+ return contributors
1620
+ .flatMap((c) => { var _a; return (_a = c.corresp) !== null && _a !== void 0 ? _a : []; })
1621
+ .map((corresp) => this.modelMap.get(corresp.correspID))
1622
+ .filter((corresp) => !!corresp);
1623
+ }
1616
1624
  buildKeywords(articleMeta) {
1617
1625
  const keywords = [...this.modelMap.values()].filter((model) => model.objectType === json_schema_1.ObjectTypes.Keyword);
1618
1626
  const keywordGroups = new Map();
@@ -1684,6 +1692,9 @@ class JATSExporter {
1684
1692
  }
1685
1693
  }
1686
1694
  }
1695
+ if (!fnGroup.hasChildNodes()) {
1696
+ fnGroup.remove();
1697
+ }
1687
1698
  }
1688
1699
  }
1689
1700
  });
@@ -36,6 +36,7 @@ const abstracts_1 = require("./nodes/abstracts");
36
36
  const affiliation_1 = require("./nodes/affiliation");
37
37
  const affiliations_1 = require("./nodes/affiliations");
38
38
  const attribution_1 = require("./nodes/attribution");
39
+ const author_notes_1 = require("./nodes/author_notes");
39
40
  const backmatter_1 = require("./nodes/backmatter");
40
41
  const bibliography_element_1 = require("./nodes/bibliography_element");
41
42
  const bibliography_item_1 = require("./nodes/bibliography_item");
@@ -116,7 +117,6 @@ __exportStar(require("./nodes/footnotes_section"), exports);
116
117
  __exportStar(require("./nodes/graphical_abstract_section"), exports);
117
118
  __exportStar(require("./nodes/hard_break"), exports);
118
119
  __exportStar(require("./nodes/highlight_marker"), exports);
119
- __exportStar(require("./nodes/inline_equation"), exports);
120
120
  __exportStar(require("./nodes/inline_footnote"), exports);
121
121
  __exportStar(require("./nodes/keyword"), exports);
122
122
  __exportStar(require("./nodes/keywords_element"), exports);
@@ -216,6 +216,7 @@ exports.schema = new prosemirror_model_1.Schema({
216
216
  table_row: table_1.tableRow,
217
217
  table_col: table_col_1.tableCol,
218
218
  table_colgroup: table_col_1.tableColGroup,
219
+ table_header: table_1.tableHeader,
219
220
  text: text_1.text,
220
221
  toc_element: toc_element_1.tocElement,
221
222
  toc_section: toc_section_1.tocSection,
@@ -227,6 +228,6 @@ exports.schema = new prosemirror_model_1.Schema({
227
228
  contributors: contributors_1.contributors,
228
229
  supplements: supplements_1.supplements,
229
230
  supplement: supplement_1.supplement,
230
- table_header: table_1.tableHeader,
231
+ author_notes: author_notes_1.authorNotes,
231
232
  },
232
233
  });
@@ -15,6 +15,13 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.packages = void 0;
19
- const AllPackages_1 = require("mathjax-full/js/input/tex/AllPackages");
20
- exports.packages = AllPackages_1.AllPackages.filter((name) => name !== 'html' && name !== 'bussproofs');
18
+ exports.authorNotes = void 0;
19
+ exports.authorNotes = {
20
+ attrs: {
21
+ id: { default: '' },
22
+ dataTracked: { default: null },
23
+ },
24
+ content: '(footnote | paragraph)+',
25
+ group: 'block element',
26
+ toDOM: () => ['author-notes', 0],
27
+ };
@@ -17,7 +17,7 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.contributors = void 0;
19
19
  exports.contributors = {
20
- content: 'contributor*',
20
+ content: 'contributor* author_notes?',
21
21
  attrs: {
22
22
  id: { default: '' },
23
23
  },
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*!
3
- * © 2019 Atypon Systems LLC
3
+ * © 2023 Atypon Systems LLC
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * you may not use this file except in compliance with the License.
@@ -20,9 +20,8 @@ const json_schema_1 = require("@manuscripts/json-schema");
20
20
  exports.equation = {
21
21
  attrs: {
22
22
  id: { default: '' },
23
- MathMLStringRepresentation: { default: '' },
24
- SVGStringRepresentation: { default: '' },
25
- TeXRepresentation: { default: '' },
23
+ contents: { default: '' },
24
+ format: { default: '' },
26
25
  dataTracked: { default: null },
27
26
  },
28
27
  group: 'block',
@@ -30,26 +29,25 @@ exports.equation = {
30
29
  {
31
30
  tag: `div.${json_schema_1.ObjectTypes.Equation}`,
32
31
  getAttrs: (p) => {
33
- const dom = p;
32
+ const htmlEl = p;
34
33
  return {
35
- id: dom.getAttribute('id'),
36
- MathMLStringRepresentation: dom.getAttribute('data-mathml-string-representation'),
37
- SVGStringRepresentation: dom.innerHTML,
38
- TeXRepresentation: dom.getAttribute('data-tex-representation'),
34
+ id: htmlEl.getAttribute('id'),
35
+ format: htmlEl.getAttribute('data-equation-format'),
36
+ contents: htmlEl.innerHTML,
39
37
  };
40
38
  },
41
39
  },
42
40
  ],
43
41
  toDOM: (node) => {
44
42
  const equationNode = node;
43
+ const { id, contents, format } = equationNode.attrs;
45
44
  const dom = document.createElement('div');
46
- dom.setAttribute('id', equationNode.attrs.id);
47
45
  dom.classList.add(json_schema_1.ObjectTypes.Equation);
48
- if (equationNode.attrs.MathMLStringRepresentation) {
49
- dom.setAttribute('data-mathml-string-representation', equationNode.attrs.MathMLStringRepresentation);
46
+ dom.setAttribute('id', id);
47
+ if (format) {
48
+ dom.setAttribute('data-equation-format', format);
50
49
  }
51
- dom.setAttribute('data-tex-representation', equationNode.attrs.TeXRepresentation);
52
- dom.innerHTML = equationNode.attrs.SVGStringRepresentation;
50
+ dom.innerHTML = contents;
53
51
  return dom;
54
52
  },
55
53
  };
@@ -17,11 +17,10 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.equationElement = void 0;
19
19
  exports.equationElement = {
20
- content: '(equation | placeholder) figcaption',
20
+ content: '(equation | placeholder)',
21
21
  attrs: {
22
22
  id: { default: '' },
23
- suppressCaption: { default: true },
24
- suppressTitle: { default: undefined },
23
+ label: { default: '' },
25
24
  dataTracked: { default: null },
26
25
  comments: { default: null },
27
26
  },
@@ -29,7 +28,7 @@ exports.equationElement = {
29
28
  group: 'block element',
30
29
  parseDOM: [
31
30
  {
32
- tag: 'figure.equation',
31
+ tag: 'div.equation',
33
32
  getAttrs: (p) => {
34
33
  const dom = p;
35
34
  return {
@@ -41,7 +40,7 @@ exports.equationElement = {
41
40
  toDOM: (node) => {
42
41
  const equationElementNode = node;
43
42
  return [
44
- 'figure',
43
+ 'div',
45
44
  {
46
45
  class: 'equation',
47
46
  id: equationElementNode.attrs.id,