@manuscripts/transform 2.1.3-LEAN-3092-0 → 2.1.3-LEAN-3376-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.
Files changed (71) hide show
  1. package/dist/cjs/index.js +1 -0
  2. package/dist/cjs/jats/importer/jats-body-dom-parser.js +74 -43
  3. package/dist/cjs/jats/importer/jats-body-transformations.js +10 -17
  4. package/dist/cjs/jats/importer/jats-front-parser.js +40 -1
  5. package/dist/cjs/jats/importer/jats-parser-utils.js +0 -6
  6. package/dist/cjs/jats/importer/parse-jats-article.js +3 -6
  7. package/dist/cjs/jats/jats-exporter.js +105 -74
  8. package/dist/cjs/mathjax/index.js +41 -0
  9. package/dist/cjs/mathjax/mathjax-packages.js +20 -0
  10. package/dist/cjs/mathjax/mathml-to-svg.js +70 -0
  11. package/dist/cjs/mathjax/tex-to-mathml.js +49 -0
  12. package/dist/cjs/mathjax/tex-to-svg.js +59 -0
  13. package/dist/cjs/schema/index.js +6 -5
  14. package/dist/cjs/schema/nodes/author_notes.js +27 -0
  15. package/dist/cjs/schema/nodes/contributors.js +1 -1
  16. package/dist/cjs/schema/nodes/equation.js +14 -12
  17. package/dist/cjs/schema/nodes/equation_element.js +5 -4
  18. package/dist/cjs/schema/nodes/inline_equation.js +15 -13
  19. package/dist/cjs/schema/nodes/table.js +52 -30
  20. package/dist/cjs/schema/nodes/table_element.js +1 -1
  21. package/dist/cjs/transformer/builders.js +14 -1
  22. package/dist/cjs/transformer/decode.js +48 -22
  23. package/dist/cjs/transformer/encode.js +30 -6
  24. package/dist/cjs/transformer/node-types.js +3 -0
  25. package/dist/cjs/transformer/object-types.js +1 -0
  26. package/dist/es/index.js +1 -0
  27. package/dist/es/jats/importer/jats-body-dom-parser.js +75 -44
  28. package/dist/es/jats/importer/jats-body-transformations.js +10 -17
  29. package/dist/es/jats/importer/jats-front-parser.js +41 -2
  30. package/dist/es/jats/importer/jats-parser-utils.js +0 -6
  31. package/dist/es/jats/importer/parse-jats-article.js +3 -6
  32. package/dist/es/jats/jats-exporter.js +106 -75
  33. package/dist/es/mathjax/index.js +12 -0
  34. package/dist/es/mathjax/mathjax-packages.js +17 -0
  35. package/dist/es/mathjax/mathml-to-svg.js +66 -0
  36. package/dist/es/mathjax/tex-to-mathml.js +45 -0
  37. package/dist/es/mathjax/tex-to-svg.js +55 -0
  38. package/dist/es/schema/index.js +5 -4
  39. package/dist/es/schema/nodes/author_notes.js +24 -0
  40. package/dist/es/schema/nodes/contributors.js +1 -1
  41. package/dist/es/schema/nodes/equation.js +14 -12
  42. package/dist/es/schema/nodes/equation_element.js +5 -4
  43. package/dist/es/schema/nodes/inline_equation.js +15 -13
  44. package/dist/es/schema/nodes/table.js +51 -29
  45. package/dist/es/schema/nodes/table_element.js +1 -1
  46. package/dist/es/transformer/builders.js +11 -0
  47. package/dist/es/transformer/decode.js +48 -22
  48. package/dist/es/transformer/encode.js +30 -6
  49. package/dist/es/transformer/node-types.js +3 -0
  50. package/dist/es/transformer/object-types.js +1 -0
  51. package/dist/types/index.d.ts +1 -0
  52. package/dist/types/jats/importer/jats-front-parser.d.ts +10 -1
  53. package/dist/types/jats/jats-exporter.d.ts +3 -1
  54. package/dist/types/mathjax/index.d.ts +3 -0
  55. package/dist/types/mathjax/mathjax-packages.d.ts +16 -0
  56. package/dist/types/mathjax/mathml-to-svg.d.ts +17 -0
  57. package/dist/types/mathjax/tex-to-mathml.d.ts +17 -0
  58. package/dist/types/mathjax/tex-to-svg.d.ts +17 -0
  59. package/dist/types/schema/index.d.ts +1 -1
  60. package/dist/types/schema/nodes/author_notes.d.ts +25 -0
  61. package/dist/types/schema/nodes/equation.d.ts +4 -3
  62. package/dist/types/schema/nodes/equation_element.d.ts +2 -1
  63. package/dist/types/schema/nodes/inline_equation.d.ts +3 -4
  64. package/dist/types/schema/nodes/table.d.ts +5 -12
  65. package/dist/types/schema/types.d.ts +1 -1
  66. package/dist/types/transformer/builders.d.ts +3 -1
  67. package/dist/types/transformer/decode.d.ts +1 -0
  68. package/package.json +7 -5
  69. package/dist/cjs/schema/nodes/table_row.js +0 -123
  70. package/dist/es/schema/nodes/table_row.js +0 -120
  71. package/dist/types/schema/nodes/table_row.d.ts +0 -41
package/dist/cjs/index.js CHANGED
@@ -18,6 +18,7 @@ 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);
21
22
  __exportStar(require("./schema"), exports);
22
23
  __exportStar(require("./transformer"), exports);
23
24
  __exportStar(require("./jats"), exports);
@@ -21,6 +21,8 @@ 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");
24
26
  const schema_1 = require("../../schema");
25
27
  const transformer_1 = require("../../transformer");
26
28
  const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
@@ -37,28 +39,6 @@ const chooseContentType = (graphicNode) => {
37
39
  }
38
40
  }
39
41
  };
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
- };
62
42
  const marks = [
63
43
  {
64
44
  tag: 'bold',
@@ -167,26 +147,91 @@ const nodes = [
167
147
  tag: 'inline-formula',
168
148
  node: 'inline_equation',
169
149
  getAttrs: (node) => {
150
+ var _a, _b, _c, _d, _e;
170
151
  const element = node;
171
- return getEquationContent(element);
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;
172
181
  },
173
182
  },
174
183
  {
175
184
  tag: 'disp-formula',
176
185
  node: 'equation_element',
177
186
  getAttrs: (node) => {
178
- var _a, _b;
179
187
  const element = node;
188
+ const caption = element.querySelector('figcaption');
180
189
  return {
181
190
  id: element.getAttribute('id'),
182
- label: (_b = (_a = element.querySelector('label')) === null || _a === void 0 ? void 0 : _a.textContent) !== null && _b !== void 0 ? _b : '',
191
+ suppressCaption: !caption,
183
192
  };
184
193
  },
185
194
  getContent: (node, schema) => {
195
+ var _a, _b, _c, _d, _e;
186
196
  const element = node;
187
- const attrs = getEquationContent(element);
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();
188
227
  return prosemirror_model_1.Fragment.from([
189
- schema.nodes.equation.createChecked(Object.assign({}, attrs)),
228
+ schema.nodes.equation.createChecked(attrs),
229
+ caption
230
+ ?
231
+ exports.jatsBodyDOMParser.parse(caption, {
232
+ topNode: figcaption,
233
+ })
234
+ : figcaption,
190
235
  ]);
191
236
  },
192
237
  },
@@ -480,23 +525,9 @@ const nodes = [
480
525
  const element = node;
481
526
  return {
482
527
  id: element.getAttribute('id'),
483
- suppressFooter: !element.querySelector('table > tfoot > tr'),
484
- suppressHeader: !element.querySelector('table > thead > tr'),
485
528
  };
486
529
  },
487
530
  },
488
- {
489
- tag: 'tbody',
490
- skip: true,
491
- },
492
- {
493
- tag: 'tfoot',
494
- skip: true,
495
- },
496
- {
497
- tag: 'thead',
498
- skip: true,
499
- },
500
531
  {
501
532
  tag: 'title',
502
533
  node: 'section_title',
@@ -523,12 +554,12 @@ const nodes = [
523
554
  },
524
555
  {
525
556
  tag: 'th',
526
- node: 'table_cell',
557
+ node: 'table_header',
527
558
  getAttrs: (node) => {
528
559
  const element = node;
529
560
  const colspan = element.getAttribute('colspan');
530
561
  const rowspan = element.getAttribute('rowspan');
531
- return Object.assign(Object.assign(Object.assign({ celltype: 'th' }, (colspan && { colspan })), (rowspan && { rowspan })), { valign: element.getAttribute('valign'), align: element.getAttribute('align'), scope: element.getAttribute('scope'), style: element.getAttribute('style') });
562
+ return Object.assign(Object.assign(Object.assign({}, (colspan && { colspan })), (rowspan && { rowspan })), { valign: element.getAttribute('valign'), align: element.getAttribute('align'), scope: element.getAttribute('scope'), style: element.getAttribute('style') });
532
563
  },
533
564
  },
534
565
  {
@@ -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');
@@ -239,8 +241,12 @@ exports.jatsBodyTransformations = {
239
241
  }
240
242
  },
241
243
  fixTables(body, createElement) {
242
- const tables = body.querySelectorAll('table-wrap > table');
243
- tables.forEach((table) => {
244
+ const tableWraps = body.querySelectorAll('table-wrap');
245
+ tableWraps.forEach((tableWrap) => {
246
+ const table = tableWrap.querySelector('table');
247
+ if (!table) {
248
+ return;
249
+ }
244
250
  const colgroup = table.querySelector('colgroup');
245
251
  const cols = table.querySelectorAll('col');
246
252
  if (!colgroup && table.firstChild && cols.length > 0) {
@@ -248,20 +254,7 @@ exports.jatsBodyTransformations = {
248
254
  for (const col of cols) {
249
255
  colgroup.appendChild(col);
250
256
  }
251
- table.insertBefore(colgroup, table.firstChild);
252
- }
253
- const tbody = table.querySelector('tbody');
254
- if (tbody) {
255
- const headerRow = table.querySelector('thead > tr');
256
- if (!headerRow) {
257
- const tr = createElement('tr');
258
- tbody.insertBefore(tr, tbody.firstElementChild);
259
- }
260
- const footerRow = table.querySelector('tfoot > tr');
261
- if (!footerRow) {
262
- const tr = createElement('tr');
263
- tbody.appendChild(tr);
264
- }
257
+ tableWrap.insertBefore(colgroup, table.nextSibling);
265
258
  }
266
259
  });
267
260
  },
@@ -179,7 +179,46 @@ 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
+ ...correspondingIDs.values(),
205
+ ...footnoteIDs.values(),
206
+ ...authorNotesParagraphs.map((p) => p._id),
207
+ ]),
208
+ ];
209
+ return {
210
+ footnotes,
211
+ footnoteIDs,
212
+ authorNotesParagraphs,
213
+ authorNotes,
214
+ correspondingIDs,
215
+ correspondingList,
216
+ };
217
+ },
218
+ parseParagraphs(elements) {
219
+ return elements.map((p) => (0, transformer_1.buildParagraph)(p.innerHTML));
220
+ },
221
+ parseFootnotes(elements) {
183
222
  const footnoteIDs = new Map();
184
223
  const footnotes = elements.map((element) => {
185
224
  const fn = (0, transformer_1.buildFootnote)('', element.innerHTML);
@@ -16,8 +16,6 @@
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");
21
19
  const transformer_1 = require("../../transformer");
22
20
  const updateDocumentIDs = (node, replacements) => {
23
21
  const warnings = [];
@@ -32,10 +30,6 @@ function recurseDoc(node, fn) {
32
30
  node.descendants((n) => fn(n));
33
31
  }
34
32
  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
- }
39
33
  if (!('id' in node.attrs)) {
40
34
  return;
41
35
  }
@@ -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.localName}-${value}`;
98
+ return `${element.nodeName}-${value}`;
99
99
  };
100
100
  };
101
101
  const chooseRefType = (objectType) => {
@@ -164,7 +164,6 @@ class JATSExporter {
164
164
  };
165
165
  this.nodeFromJATS = (JATSFragment) => {
166
166
  JATSFragment = JATSFragment.trim();
167
- JATSFragment = JATSFragment.replace(' ', ' ');
168
167
  if (!JATSFragment.length) {
169
168
  return null;
170
169
  }
@@ -615,6 +614,7 @@ class JATSExporter {
615
614
  this.createSerializer = () => {
616
615
  const getModel = (id) => id ? this.modelMap.get(id) : undefined;
617
616
  const nodes = {
617
+ author_notes: () => ['author-notes', 0],
618
618
  title: () => '',
619
619
  affiliations: () => '',
620
620
  contributors: () => '',
@@ -687,20 +687,22 @@ class JATSExporter {
687
687
  },
688
688
  doc: () => '',
689
689
  equation: (node) => {
690
- return this.createEquation(node);
691
- },
692
- inline_equation: (node) => {
693
- const eqElement = this.document.createElement('inline-formula');
694
- const equation = this.createEquation(node, true);
695
- eqElement.append(equation);
696
- return eqElement;
697
- },
698
- equation_element: (node) => {
699
- const eqElement = this.document.createElement('disp-formula');
700
- eqElement.setAttribute('id', normalizeID(node.attrs.id));
701
- processChildNodes(eqElement, node, schema_1.schema.nodes.equation);
702
- return eqElement;
690
+ const formula = this.document.createElement('disp-formula');
691
+ formula.setAttribute('id', normalizeID(node.attrs.id));
692
+ if (node.attrs.TeXRepresentation) {
693
+ const math = this.document.createElement('tex-math');
694
+ math.textContent = node.attrs.TeXRepresentation;
695
+ formula.appendChild(math);
696
+ }
697
+ else if (node.attrs.MathMLStringRepresentation) {
698
+ const math = this.nodeFromJATS(node.attrs.MathMLStringRepresentation);
699
+ if (math) {
700
+ formula.appendChild(math);
701
+ }
702
+ }
703
+ return formula;
703
704
  },
705
+ equation_element: (node) => createFigureElement(node, 'fig', node.type.schema.nodes.equation, 'equation'),
704
706
  figcaption: (node) => {
705
707
  if (!node.textContent) {
706
708
  return '';
@@ -750,6 +752,28 @@ class JATSExporter {
750
752
  },
751
753
  hard_break: () => '',
752
754
  highlight_marker: () => '',
755
+ inline_equation: (node) => {
756
+ const formula = this.document.createElement('inline-formula');
757
+ formula.setAttribute('id', normalizeID(node.attrs.id));
758
+ if (node.attrs.TeXRepresentation) {
759
+ const math = this.document.createElement('tex-math');
760
+ math.textContent = node.attrs.TeXRepresentation;
761
+ formula.appendChild(math);
762
+ }
763
+ else if (node.attrs.MathMLRepresentation) {
764
+ const math = this.nodeFromJATS(node.attrs.MathMLRepresentation);
765
+ if (math) {
766
+ formula.appendChild(math);
767
+ }
768
+ }
769
+ else if (node.attrs.SVGRepresentation) {
770
+ const math = this.nodeFromJATS(node.attrs.SVGRepresentation);
771
+ if (math) {
772
+ formula.appendChild(math);
773
+ }
774
+ }
775
+ return formula;
776
+ },
753
777
  inline_footnote: (node) => {
754
778
  const xref = this.document.createElement('xref');
755
779
  xref.setAttribute('ref-type', 'fn');
@@ -850,9 +874,13 @@ class JATSExporter {
850
874
  element.setAttribute('position', 'anchor');
851
875
  return element;
852
876
  },
853
- table_body: () => ['tbody', 0],
854
877
  table_cell: (node) => [
855
- node.attrs.celltype,
878
+ 'td',
879
+ Object.assign(Object.assign({ valign: node.attrs.valign, align: node.attrs.align, scope: node.attrs.scope, style: node.attrs.style }, (node.attrs.rowspan > 1 && { rowspan: node.attrs.rowspan })), (node.attrs.colspan > 1 && { colspan: node.attrs.colspan })),
880
+ 0,
881
+ ],
882
+ table_header: (node) => [
883
+ 'th',
856
884
  Object.assign(Object.assign({ valign: node.attrs.valign, align: node.attrs.align, scope: node.attrs.scope, style: node.attrs.style }, (node.attrs.rowspan > 1 && { rowspan: node.attrs.rowspan })), (node.attrs.colspan > 1 && { colspan: node.attrs.colspan })),
857
885
  0,
858
886
  ],
@@ -933,6 +961,26 @@ class JATSExporter {
933
961
  element.appendChild(this.serializeNode(childNode));
934
962
  }
935
963
  };
964
+ const appendTable = (element, node) => {
965
+ const tableNode = findChildNodeOfType(node, node.type.schema.nodes.table);
966
+ const colGroupNode = findChildNodeOfType(node, node.type.schema.nodes.table_colgroup);
967
+ if (!tableNode) {
968
+ return;
969
+ }
970
+ const table = this.serializeNode(tableNode);
971
+ const tbodyElement = this.document.createElement('tbody');
972
+ while (table.firstChild) {
973
+ const child = table.firstChild;
974
+ table.removeChild(child);
975
+ tbodyElement.appendChild(child);
976
+ }
977
+ table.appendChild(tbodyElement);
978
+ if (colGroupNode) {
979
+ const colGroup = this.serializeNode(colGroupNode);
980
+ table.insertBefore(colGroup, table.firstChild);
981
+ }
982
+ element.appendChild(table);
983
+ };
936
984
  const createFigureElement = (node, nodeName, contentNodeType, figType) => {
937
985
  const element = createElement(node, nodeName);
938
986
  if (figType) {
@@ -953,7 +1001,7 @@ class JATSExporter {
953
1001
  const element = createElement(node, nodeName);
954
1002
  appendLabels(element, node);
955
1003
  appendChildNodeOfType(element, node, node.type.schema.nodes.figcaption);
956
- appendChildNodeOfType(element, node, node.type.schema.nodes.table);
1004
+ appendTable(element, node);
957
1005
  appendChildNodeOfType(element, node, node.type.schema.nodes.table_element_footer);
958
1006
  if ((0, node_types_1.isExecutableNodeType)(node.type)) {
959
1007
  processExecutableNode(node, element);
@@ -1011,6 +1059,7 @@ class JATSExporter {
1011
1059
  }
1012
1060
  };
1013
1061
  this.buildContributors = (articleMeta) => {
1062
+ var _a;
1014
1063
  const contributors = this.models.filter(isContributor);
1015
1064
  const authorContributors = contributors
1016
1065
  .filter((contributor) => contributor.role === 'author')
@@ -1229,49 +1278,23 @@ class JATSExporter {
1229
1278
  }
1230
1279
  });
1231
1280
  }
1232
- const noteIDs = [];
1233
- for (const contributor of [...authorContributors, ...otherContributors]) {
1234
- if (contributor.footnote) {
1235
- const ids = contributor.footnote.map((note) => {
1236
- return note.noteID;
1237
- });
1238
- noteIDs.push(...ids);
1239
- }
1240
- if (contributor.corresp) {
1241
- const ids = contributor.corresp.map((corresp) => {
1242
- return corresp.correspID;
1243
- });
1244
- noteIDs.push(...ids);
1245
- }
1246
- }
1247
- const footnotes = [];
1248
- footnotes.push(...this.models.filter((0, object_types_1.hasObjectType)(json_schema_1.ObjectTypes.Footnote)));
1249
- const correspodings = [];
1250
- correspodings.push(...this.models.filter((0, object_types_1.hasObjectType)(json_schema_1.ObjectTypes.Corresponding)));
1251
- if (footnotes || correspodings) {
1281
+ const authorNotes = (_a = (0, json_schema_1.getModelsByType)(this.modelMap, json_schema_1.ObjectTypes.AuthorNotes)) === null || _a === void 0 ? void 0 : _a[0];
1282
+ if (authorNotes) {
1252
1283
  const authorNotesEl = this.document.createElement('author-notes');
1253
- const usedFootnotes = footnotes.filter((footnote) => {
1254
- return noteIDs.includes(footnote._id);
1255
- });
1256
- const usedCorrespodings = correspodings.filter((corresp) => {
1257
- return noteIDs.includes(corresp._id);
1258
- });
1259
- usedFootnotes.forEach((footnote) => {
1260
- const authorFootNote = this.document.createElement('fn');
1261
- authorFootNote.setAttribute('id', normalizeID(footnote._id));
1262
- authorFootNote.innerHTML = footnote.contents;
1263
- authorNotesEl.appendChild(authorFootNote);
1264
- });
1265
- usedCorrespodings.forEach((corresponding) => {
1266
- const correspondingEl = this.document.createElement('corresp');
1267
- correspondingEl.setAttribute('id', normalizeID(corresponding._id));
1268
- if (corresponding.label) {
1269
- const labelEl = this.document.createElement('label');
1270
- labelEl.textContent = corresponding.label;
1271
- correspondingEl.appendChild(labelEl);
1284
+ authorNotes.containedObjectIDs.forEach((id) => {
1285
+ const model = this.modelMap.get(id);
1286
+ if (!model) {
1287
+ return;
1288
+ }
1289
+ if (id.startsWith('MPParagraphElement')) {
1290
+ this.appendParagraphToElement(model, authorNotesEl);
1291
+ }
1292
+ else if (id.startsWith('MPFootnote')) {
1293
+ this.appendFootnoteToElement(model, authorNotesEl);
1294
+ }
1295
+ else if (id.startsWith('MPCorrepsonding')) {
1296
+ this.appendCorrespondingToElement(model, authorNotesEl);
1272
1297
  }
1273
- correspondingEl.append(corresponding.contents);
1274
- authorNotesEl.appendChild(correspondingEl);
1275
1298
  });
1276
1299
  if (authorNotesEl.childNodes.length > 0) {
1277
1300
  articleMeta.insertBefore(authorNotesEl, contribGroup.nextSibling);
@@ -1279,6 +1302,29 @@ class JATSExporter {
1279
1302
  }
1280
1303
  }
1281
1304
  };
1305
+ this.appendCorrespondingToElement = (corresponding, element) => {
1306
+ const correspondingEl = this.document.createElement('corresp');
1307
+ correspondingEl.setAttribute('id', normalizeID(corresponding._id));
1308
+ if (corresponding.label) {
1309
+ const labelEl = this.document.createElement('label');
1310
+ labelEl.textContent = corresponding.label;
1311
+ correspondingEl.appendChild(labelEl);
1312
+ }
1313
+ correspondingEl.append(corresponding.contents);
1314
+ element.appendChild(correspondingEl);
1315
+ };
1316
+ this.appendParagraphToElement = (paragraph, element) => {
1317
+ const paragraphEl = this.document.createElement('p');
1318
+ paragraphEl.setAttribute('id', normalizeID(paragraph._id));
1319
+ paragraphEl.innerHTML = paragraph.contents;
1320
+ element.appendChild(paragraphEl);
1321
+ };
1322
+ this.appendFootnoteToElement = (footnote, element) => {
1323
+ const footnoteEl = this.document.createElement('fn');
1324
+ footnoteEl.setAttribute('id', normalizeID(footnote._id));
1325
+ footnoteEl.innerHTML = footnote.contents;
1326
+ element.appendChild(footnoteEl);
1327
+ };
1282
1328
  this.fixBody = (body, fragment) => {
1283
1329
  fragment.descendants((node) => {
1284
1330
  if (node.attrs.id) {
@@ -1566,21 +1612,6 @@ class JATSExporter {
1566
1612
  this.citationTexts.set(id, output);
1567
1613
  });
1568
1614
  }
1569
- createEquation(node, isInline = false) {
1570
- if (node.attrs.format === 'tex') {
1571
- const texMath = this.document.createElement('tex-math');
1572
- texMath.innerHTML = node.attrs.contents;
1573
- return texMath;
1574
- }
1575
- else {
1576
- const math = this.nodeFromJATS(node.attrs.contents);
1577
- const mathml = math;
1578
- if (!isInline) {
1579
- mathml.setAttribute('id', normalizeID(node.attrs.id));
1580
- }
1581
- return mathml;
1582
- }
1583
- }
1584
1615
  buildKeywords(articleMeta) {
1585
1616
  const keywords = [...this.modelMap.values()].filter((model) => model.objectType === json_schema_1.ObjectTypes.Keyword);
1586
1617
  const keywordGroups = new Map();
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.convertTeXToSVG = exports.convertTeXToMathML = exports.convertMathMLToSVG = void 0;
27
+ const convertMathMLToSVG = async (mathml, display) => {
28
+ const { convertMathMLToSVG } = await Promise.resolve().then(() => __importStar(require('./mathml-to-svg')));
29
+ return convertMathMLToSVG(mathml, display);
30
+ };
31
+ exports.convertMathMLToSVG = convertMathMLToSVG;
32
+ const convertTeXToMathML = async (tex, display) => {
33
+ const { convertTeXToMathML } = await Promise.resolve().then(() => __importStar(require('./tex-to-mathml')));
34
+ return convertTeXToMathML(tex, display);
35
+ };
36
+ exports.convertTeXToMathML = convertTeXToMathML;
37
+ const convertTeXToSVG = async (tex, display) => {
38
+ const { convertTeXToSVG } = await Promise.resolve().then(() => __importStar(require('./tex-to-svg')));
39
+ return convertTeXToSVG(tex, display);
40
+ };
41
+ exports.convertTeXToSVG = convertTeXToSVG;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ /*!
3
+ * © 2019 Atypon Systems LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
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');