@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
@@ -16,14 +16,13 @@
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.inlineEquation = void 0;
19
- const json_schema_1 = require("@manuscripts/json-schema");
20
19
  exports.inlineEquation = {
21
20
  attrs: {
22
- id: { default: '' },
23
- MathMLRepresentation: { default: '' },
24
- SVGRepresentation: { default: '' },
25
- TeXRepresentation: { default: '' },
26
21
  dataTracked: { default: null },
22
+ comments: { default: null },
23
+ id: { default: '' },
24
+ contents: { default: '' },
25
+ format: { default: '' },
27
26
  },
28
27
  atom: true,
29
28
  inline: true,
@@ -31,28 +30,27 @@ exports.inlineEquation = {
31
30
  group: 'inline',
32
31
  parseDOM: [
33
32
  {
34
- tag: `span.${json_schema_1.ObjectTypes.InlineMathFragment}`,
33
+ tag: `span.MPInlineMathFragment`,
35
34
  getAttrs: (p) => {
36
35
  const dom = p;
37
36
  return {
37
+ format: dom.getAttribute('data-equation-format'),
38
38
  id: dom.getAttribute('id'),
39
- MathMLRepresentation: dom.getAttribute('data-mathml-representation') || '',
40
- SVGRepresentation: dom.innerHTML || '',
41
- TeXRepresentation: dom.getAttribute('data-tex-representation') || '',
39
+ contents: dom.innerHTML,
42
40
  };
43
41
  },
44
42
  },
45
43
  ],
46
44
  toDOM: (node) => {
47
45
  const inlineEquationNode = node;
46
+ const { id, contents, format } = inlineEquationNode.attrs;
48
47
  const dom = document.createElement('span');
49
- dom.classList.add(json_schema_1.ObjectTypes.InlineMathFragment);
50
- dom.setAttribute('id', inlineEquationNode.attrs.id);
51
- dom.setAttribute('data-tex-representation', inlineEquationNode.attrs.TeXRepresentation);
52
- if (inlineEquationNode.attrs.MathMLRepresentation) {
53
- dom.setAttribute('data-mathml-representation', inlineEquationNode.attrs.MathMLRepresentation);
48
+ dom.setAttribute('id', id);
49
+ dom.classList.add('MPInlineMathFragment');
50
+ if (format) {
51
+ dom.setAttribute('data-equation-format', format);
54
52
  }
55
- dom.innerHTML = inlineEquationNode.attrs.SVGRepresentation;
53
+ dom.innerHTML = contents;
56
54
  return dom;
57
55
  },
58
56
  };
@@ -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.buildTitles = exports.buildElementsOrder = exports.auxiliaryObjectTypes = exports.buildJournal = exports.buildAttribution = exports.buildContributorRole = exports.buildContribution = exports.buildColor = exports.buildParagraph = exports.buildSection = exports.buildCorresp = exports.buildFootnotesOrder = exports.buildFootnote = exports.buildInlineMathFragment = exports.buildNote = exports.buildComment = exports.buildSupplementaryMaterial = exports.buildAffiliation = exports.buildFigure = exports.buildKeywordGroup = exports.buildKeyword = exports.buildBibliographyElement = exports.buildBibliographicDate = exports.buildBibliographicName = exports.buildBibliographyItem = exports.buildContributor = exports.buildManuscript = exports.buildProject = void 0;
21
+ exports.buildTitles = exports.buildElementsOrder = exports.auxiliaryObjectTypes = exports.buildJournal = exports.buildAttribution = exports.buildContributorRole = exports.buildContribution = exports.buildColor = exports.buildParagraph = exports.buildSection = exports.buildCorresp = exports.buildFootnotesOrder = exports.buildAuthorNotes = exports.buildFootnote = exports.buildNote = exports.buildComment = exports.buildSupplementaryMaterial = exports.buildAffiliation = exports.buildFigure = exports.buildKeywordGroup = exports.buildKeyword = exports.buildBibliographyElement = exports.buildBibliographicDate = exports.buildBibliographicName = exports.buildBibliographyItem = exports.buildContributor = exports.buildManuscript = exports.buildProject = void 0;
22
22
  const json_schema_1 = require("@manuscripts/json-schema");
23
23
  const w3c_xmlserializer_1 = __importDefault(require("w3c-xmlserializer"));
24
24
  const schema_1 = require("../schema");
@@ -115,13 +115,6 @@ const buildNote = (target, source, contents = '') => ({
115
115
  contents,
116
116
  });
117
117
  exports.buildNote = buildNote;
118
- const buildInlineMathFragment = (containingObject, TeXRepresentation) => ({
119
- _id: (0, id_1.generateID)(json_schema_1.ObjectTypes.InlineMathFragment),
120
- objectType: json_schema_1.ObjectTypes.InlineMathFragment,
121
- containingObject: containingObject || undefined,
122
- TeXRepresentation,
123
- });
124
- exports.buildInlineMathFragment = buildInlineMathFragment;
125
118
  const buildFootnote = (containingObject, contents, kind = 'footnote') => ({
126
119
  _id: (0, id_1.generateID)(json_schema_1.ObjectTypes.Footnote),
127
120
  objectType: json_schema_1.ObjectTypes.Footnote,
@@ -130,6 +123,12 @@ const buildFootnote = (containingObject, contents, kind = 'footnote') => ({
130
123
  kind,
131
124
  });
132
125
  exports.buildFootnote = buildFootnote;
126
+ const buildAuthorNotes = (containedObjectIDs) => ({
127
+ _id: (0, id_1.generateID)(json_schema_1.ObjectTypes.AuthorNotes),
128
+ objectType: json_schema_1.ObjectTypes.AuthorNotes,
129
+ containedObjectIDs: containedObjectIDs,
130
+ });
131
+ exports.buildAuthorNotes = buildAuthorNotes;
133
132
  const buildFootnotesOrder = (footnotesList, containedObjectID) => ({
134
133
  _id: (0, id_1.generateID)(json_schema_1.ObjectTypes.FootnotesOrder),
135
134
  objectType: json_schema_1.ObjectTypes.FootnotesOrder,
@@ -153,13 +152,12 @@ const buildSection = (priority = 0, path = []) => {
153
152
  };
154
153
  };
155
154
  exports.buildSection = buildSection;
156
- const buildParagraph = (placeholderInnerHTML) => {
155
+ const buildParagraph = (innerHTML = '') => {
157
156
  const _id = (0, id_1.generateID)(json_schema_1.ObjectTypes.ParagraphElement);
158
- const element = document.createElementNS('http://www.w3.org/1999/xhtml', 'p');
157
+ const element = document.createElementNS(null, 'p');
159
158
  element.setAttribute('id', _id);
160
- element.setAttribute('class', 'MPElement');
161
- if (placeholderInnerHTML) {
162
- element.setAttribute('data-placeholder-text', placeholderInnerHTML);
159
+ if (innerHTML) {
160
+ element.innerHTML = innerHTML;
163
161
  }
164
162
  const contents = (0, w3c_xmlserializer_1.default)(element);
165
163
  return {
@@ -167,7 +165,6 @@ const buildParagraph = (placeholderInnerHTML) => {
167
165
  objectType: json_schema_1.ObjectTypes.ParagraphElement,
168
166
  elementType: 'p',
169
167
  contents,
170
- placeholderInnerHTML,
171
168
  };
172
169
  };
173
170
  exports.buildParagraph = buildParagraph;
@@ -62,6 +62,7 @@ const sortSectionsByPriority = (a, b) => a.priority === b.priority ? 0 : Number(
62
62
  exports.sortSectionsByPriority = sortSectionsByPriority;
63
63
  const getSections = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Section).sort(exports.sortSectionsByPriority);
64
64
  const getAffiliations = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Affiliation);
65
+ const getAuthorNotes = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.AuthorNotes);
65
66
  const getContributors = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Contributor);
66
67
  const getKeywordElements = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.KeywordsElement);
67
68
  const getSupplements = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Supplement);
@@ -91,7 +92,11 @@ class Decoder {
91
92
  const contributors = getContributors(this.modelMap)
92
93
  .map((c) => this.decode(c))
93
94
  .filter(Boolean);
94
- return schema_1.schema.nodes.contributors.createAndFill({}, contributors);
95
+ const authorNotes = getAuthorNotes(this.modelMap)
96
+ .map((authorNote) => this.decode(authorNote))
97
+ .filter(Boolean);
98
+ const content = [...contributors, ...authorNotes];
99
+ return schema_1.schema.nodes.contributors.createAndFill({}, content);
95
100
  }
96
101
  createKeywordsNode() {
97
102
  const elements = getKeywordElements(this.modelMap)
@@ -280,9 +285,8 @@ class Decoder {
280
285
  const model = data;
281
286
  return schema_1.schema.nodes.equation.createChecked({
282
287
  id: model._id,
283
- MathMLStringRepresentation: model.MathMLStringRepresentation,
284
- SVGStringRepresentation: model.SVGStringRepresentation,
285
- TeXRepresentation: model.TeXRepresentation,
288
+ contents: model.contents,
289
+ format: model.format,
286
290
  });
287
291
  },
288
292
  [json_schema_1.ObjectTypes.EquationElement]: (data) => {
@@ -301,12 +305,10 @@ class Decoder {
301
305
  else {
302
306
  throw new errors_1.MissingElement(model.containedObjectID);
303
307
  }
304
- const figcaption = this.getFigcaption(model);
305
308
  return schema_1.schema.nodes.equation_element.createChecked({
306
309
  id: model._id,
307
- suppressCaption: Boolean(model.suppressCaption),
308
- suppressTitle: Boolean(model.suppressTitle === undefined ? true : model.suppressTitle),
309
- }, [equation, figcaption]);
310
+ label: model.label,
311
+ }, [equation]);
310
312
  },
311
313
  [json_schema_1.ObjectTypes.FootnotesElement]: (data) => {
312
314
  const foonotesElementModel = data;
@@ -492,6 +494,13 @@ class Decoder {
492
494
  id: model._id,
493
495
  }, content);
494
496
  },
497
+ [json_schema_1.ObjectTypes.AuthorNotes]: (data) => {
498
+ const model = data;
499
+ const content = model.containedObjectIDs.map((id) => this.decode(this.modelMap.get(id)));
500
+ return schema_1.schema.nodes.author_notes.create({
501
+ id: model._id,
502
+ }, content);
503
+ },
495
504
  [json_schema_1.ObjectTypes.Section]: (data) => {
496
505
  const model = data;
497
506
  const elements = [];
@@ -62,12 +62,6 @@ const listContents = (node) => {
62
62
  }
63
63
  return (0, w3c_xmlserializer_1.default)(output);
64
64
  };
65
- const svgDefs = (svg) => {
66
- const template = document.createElement('template');
67
- template.innerHTML = svg.trim();
68
- const defs = template.content.querySelector('defs');
69
- return defs ? (0, w3c_xmlserializer_1.default)(defs) : undefined;
70
- };
71
65
  const tableRowDisplayStyle = (tagName, parent) => {
72
66
  switch (tagName) {
73
67
  case 'thead':
@@ -354,20 +348,13 @@ const encoders = {
354
348
  : false,
355
349
  }),
356
350
  equation: (node) => ({
357
- MathMLStringRepresentation: node.attrs.MathMLStringRepresentation || undefined,
358
- TeXRepresentation: node.attrs.TeXRepresentation,
359
- SVGStringRepresentation: node.attrs.SVGStringRepresentation,
351
+ contents: node.attrs.contents,
352
+ format: node.attrs.format,
360
353
  }),
361
354
  equation_element: (node) => ({
362
355
  containedObjectID: attributeOfNodeType(node, 'equation', 'id'),
363
- caption: inlineContentOfChildNodeType(node, node.type.schema.nodes.figcaption, node.type.schema.nodes.caption),
364
- title: inlineContentOfChildNodeType(node, node.type.schema.nodes.figcaption, node.type.schema.nodes.caption_title, false),
365
- elementType: 'p',
366
- suppressCaption: Boolean(node.attrs.suppressCaption) || undefined,
367
- suppressTitle: node.attrs.suppressTitle === undefined ||
368
- node.attrs.suppressTitle === true
369
- ? undefined
370
- : false,
356
+ elementType: 'div',
357
+ label: node.attrs.label,
371
358
  }),
372
359
  figure: (node) => ({
373
360
  contentType: node.attrs.contentType || undefined,
@@ -396,6 +383,9 @@ const encoders = {
396
383
  table_element_footer: (node) => ({
397
384
  containedObjectIDs: containedObjectIDs(node),
398
385
  }),
386
+ author_notes: (node) => ({
387
+ containedObjectIDs: containedObjectIDs(node),
388
+ }),
399
389
  footnotes_section: (node, parent, path, priority) => ({
400
390
  category: (0, section_category_1.buildSectionCategory)(node),
401
391
  priority: priority.value++,
@@ -414,12 +404,6 @@ const encoders = {
414
404
  .map((childNode) => childNode.attrs.id)
415
405
  .filter((id) => id),
416
406
  }),
417
- inline_equation: (node, parent) => ({
418
- containingObject: parent.attrs.id,
419
- TeXRepresentation: node.attrs.TeXRepresentation,
420
- SVGRepresentation: node.attrs.SVGRepresentation,
421
- SVGGlyphs: svgDefs(node.attrs.SVGRepresentation),
422
- }),
423
407
  keyword: (node, parent) => ({
424
408
  containedGroup: parent.attrs.id,
425
409
  name: keywordContents(node),
@@ -593,8 +577,7 @@ const encode = (node) => {
593
577
  if (placeholderTypes.includes(child.type)) {
594
578
  return;
595
579
  }
596
- if (parent.type === schema_1.schema.nodes.paragraph &&
597
- child.type !== schema_1.schema.nodes.inline_equation) {
580
+ if (parent.type === schema_1.schema.nodes.paragraph) {
598
581
  return;
599
582
  }
600
583
  if (child.type === schema_1.schema.nodes.footnotes_element) {
@@ -39,7 +39,6 @@ exports.nodeTypesMap = new Map([
39
39
  [schema_1.schema.nodes.footnotes_section, json_schema_1.ObjectTypes.Section],
40
40
  [schema_1.schema.nodes.graphical_abstract_section, json_schema_1.ObjectTypes.Section],
41
41
  [schema_1.schema.nodes.highlight_marker, json_schema_1.ObjectTypes.HighlightMarker],
42
- [schema_1.schema.nodes.inline_equation, json_schema_1.ObjectTypes.InlineMathFragment],
43
42
  [schema_1.schema.nodes.keyword, json_schema_1.ObjectTypes.Keyword],
44
43
  [schema_1.schema.nodes.keywords_element, json_schema_1.ObjectTypes.KeywordsElement],
45
44
  [schema_1.schema.nodes.keywords, json_schema_1.ObjectTypes.Section],
@@ -62,6 +61,8 @@ exports.nodeTypesMap = new Map([
62
61
  [schema_1.schema.nodes.affiliations, json_schema_1.ObjectTypes.Section],
63
62
  [schema_1.schema.nodes.title, json_schema_1.ObjectTypes.Titles],
64
63
  [schema_1.schema.nodes.supplement, json_schema_1.ObjectTypes.Supplement],
64
+ [schema_1.schema.nodes.author_notes, json_schema_1.ObjectTypes.AuthorNotes],
65
+ [schema_1.schema.nodes.corresp, json_schema_1.ObjectTypes.Corresponding],
65
66
  ]);
66
67
  const isExecutableNodeType = (type) => (0, schema_1.hasGroup)(type, schema_1.GROUP_EXECUTABLE);
67
68
  exports.isExecutableNodeType = isExecutableNodeType;
@@ -38,7 +38,6 @@ exports.manuscriptObjects = [
38
38
  json_schema_1.ObjectTypes.CommentAnnotation,
39
39
  json_schema_1.ObjectTypes.Contributor,
40
40
  json_schema_1.ObjectTypes.Footnote,
41
- json_schema_1.ObjectTypes.InlineMathFragment,
42
41
  json_schema_1.ObjectTypes.Section,
43
42
  ].concat(exports.elementObjects);
44
43
  const isManuscriptModel = (model) => {
package/dist/es/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  export * from './lib/section-group-type';
2
2
  export * from './lib/table-cell-styles';
3
3
  export * from './lib/utils';
4
- export * from './mathjax';
5
4
  export * from './schema';
6
5
  export * from './transformer';
7
6
  export * from './jats';
@@ -15,10 +15,8 @@
15
15
  */
16
16
  import mime from 'mime';
17
17
  import { DOMParser, Fragment } from 'prosemirror-model';
18
- import { convertMathMLToSVG } from '../../mathjax/mathml-to-svg';
19
- import { convertTeXToSVG } from '../../mathjax/tex-to-svg';
20
18
  import { schema } from '../../schema';
21
- import { chooseSectionCategory, xmlSerializer } from '../../transformer';
19
+ import { chooseSectionCategory } from '../../transformer';
22
20
  const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
23
21
  const chooseContentType = (graphicNode) => {
24
22
  if (graphicNode) {
@@ -33,6 +31,28 @@ const chooseContentType = (graphicNode) => {
33
31
  }
34
32
  }
35
33
  };
34
+ const getEquationContent = (p) => {
35
+ var _a;
36
+ const element = p;
37
+ const id = element.getAttribute('id');
38
+ const container = (_a = element.querySelector('alternatives')) !== null && _a !== void 0 ? _a : element;
39
+ let contents = '';
40
+ let format = '';
41
+ for (const child of container.childNodes) {
42
+ const nodeName = child.nodeName.replace(/^[a-z]:/, '');
43
+ switch (nodeName) {
44
+ case 'tex-math':
45
+ contents = child.innerHTML;
46
+ format = 'tex';
47
+ break;
48
+ case 'mml:math':
49
+ contents = child.outerHTML;
50
+ format = 'mathml';
51
+ break;
52
+ }
53
+ }
54
+ return { id, format, contents };
55
+ };
36
56
  const marks = [
37
57
  {
38
58
  tag: 'bold',
@@ -141,91 +161,26 @@ const nodes = [
141
161
  tag: 'inline-formula',
142
162
  node: 'inline_equation',
143
163
  getAttrs: (node) => {
144
- var _a, _b, _c, _d, _e;
145
164
  const element = node;
146
- const attrs = {
147
- id: element.getAttribute('id'),
148
- MathMLRepresentation: '',
149
- SVGRepresentation: '',
150
- TeXRepresentation: '',
151
- };
152
- const container = (_a = element.querySelector('alternatives')) !== null && _a !== void 0 ? _a : element;
153
- for (const child of container.childNodes) {
154
- const nodeName = child.nodeName.replace(/^[a-z]:/, '');
155
- switch (nodeName) {
156
- case 'tex-math':
157
- attrs.TeXRepresentation = (_c = (_b = child.textContent) === null || _b === void 0 ? void 0 : _b.trim()) !== null && _c !== void 0 ? _c : '';
158
- if (attrs.TeXRepresentation) {
159
- attrs.SVGRepresentation =
160
- (_d = convertTeXToSVG(attrs.TeXRepresentation, true)) !== null && _d !== void 0 ? _d : '';
161
- }
162
- break;
163
- case 'mml:math':
164
- ;
165
- child.removeAttribute('id');
166
- attrs.MathMLRepresentation = xmlSerializer.serializeToString(child);
167
- if (attrs.MathMLRepresentation) {
168
- attrs.SVGRepresentation =
169
- (_e = convertMathMLToSVG(attrs.MathMLRepresentation, true)) !== null && _e !== void 0 ? _e : '';
170
- }
171
- break;
172
- }
173
- }
174
- return attrs;
165
+ return getEquationContent(element);
175
166
  },
176
167
  },
177
168
  {
178
169
  tag: 'disp-formula',
179
170
  node: 'equation_element',
180
171
  getAttrs: (node) => {
172
+ var _a, _b;
181
173
  const element = node;
182
- const caption = element.querySelector('figcaption');
183
174
  return {
184
175
  id: element.getAttribute('id'),
185
- suppressCaption: !caption,
176
+ label: (_b = (_a = element.querySelector('label')) === null || _a === void 0 ? void 0 : _a.textContent) !== null && _b !== void 0 ? _b : '',
186
177
  };
187
178
  },
188
179
  getContent: (node, schema) => {
189
- var _a, _b, _c, _d, _e;
190
180
  const element = node;
191
- const attrs = {
192
- MathMLStringRepresentation: '',
193
- SVGStringRepresentation: '',
194
- TeXRepresentation: '',
195
- };
196
- const container = (_a = element.querySelector('alternatives')) !== null && _a !== void 0 ? _a : element;
197
- for (const child of container.childNodes) {
198
- const nodeName = child.nodeName.replace(/^[a-z]:/, '');
199
- switch (nodeName) {
200
- case 'tex-math':
201
- attrs.TeXRepresentation = (_c = (_b = child.textContent) === null || _b === void 0 ? void 0 : _b.trim()) !== null && _c !== void 0 ? _c : '';
202
- if (attrs.TeXRepresentation) {
203
- attrs.SVGStringRepresentation =
204
- (_d = convertTeXToSVG(attrs.TeXRepresentation, true)) !== null && _d !== void 0 ? _d : '';
205
- }
206
- break;
207
- case 'mml:math':
208
- ;
209
- child.removeAttribute('id');
210
- attrs.MathMLStringRepresentation =
211
- xmlSerializer.serializeToString(child);
212
- if (attrs.MathMLStringRepresentation) {
213
- attrs.SVGStringRepresentation =
214
- (_e = convertMathMLToSVG(attrs.MathMLStringRepresentation, true)) !== null && _e !== void 0 ? _e : '';
215
- }
216
- break;
217
- }
218
- }
219
- const caption = element.querySelector('figcaption');
220
- const figcaption = schema.nodes.figcaption.create();
181
+ const attrs = getEquationContent(element);
221
182
  return Fragment.from([
222
- schema.nodes.equation.createChecked(attrs),
223
- caption
224
- ?
225
- jatsBodyDOMParser.parse(caption, {
226
- topNode: figcaption,
227
- })
228
- : figcaption,
183
+ schema.nodes.equation.createChecked(Object.assign({}, attrs)),
229
184
  ]);
230
185
  },
231
186
  },
@@ -199,7 +199,9 @@ export const jatsBodyTransformations = {
199
199
  }
200
200
  },
201
201
  moveFootnotes(doc, group, createElement) {
202
- const footnotes = [...doc.querySelectorAll('fn:not(table-wrap-foot fn)')];
202
+ const footnotes = [
203
+ ...doc.querySelectorAll('fn:not(table-wrap-foot fn, author-notes fn)'),
204
+ ];
203
205
  const footnotesSection = doc.querySelector('sec[sec-type="endnotes"]');
204
206
  const footnotesSectionGroup = footnotesSection === null || footnotesSection === void 0 ? void 0 : footnotesSection.querySelector('fn-group');
205
207
  const containingGroup = footnotesSectionGroup || createElement('fn-group');
@@ -15,7 +15,7 @@
15
15
  */
16
16
  import debug from 'debug';
17
17
  import { getTrimmedTextContent } from '../../lib/utils';
18
- import { buildAffiliation, buildBibliographicName, buildContributor, buildCorresp, buildFootnote, buildJournal, buildTitles, } from '../../transformer';
18
+ import { buildAffiliation, buildAuthorNotes, buildBibliographicName, buildContributor, buildCorresp, buildFootnote, buildJournal, buildParagraph, buildTitles, } from '../../transformer';
19
19
  import { parseJournalMeta } from './jats-journal-meta-parser';
20
20
  import { htmlFromJatsNode } from './jats-parser-utils';
21
21
  const warn = debug('manuscripts-transform');
@@ -173,7 +173,45 @@ export const jatsFrontParser = {
173
173
  affiliationIDs,
174
174
  };
175
175
  },
176
- parseAuthorNotes(elements) {
176
+ parseAuthorNotes(element) {
177
+ if (!element) {
178
+ return {
179
+ footnotes: [],
180
+ footnoteIDs: new Map(),
181
+ authorNotes: [],
182
+ authorNotesParagraphs: [],
183
+ correspondingIDs: new Map(),
184
+ correspondingList: [],
185
+ };
186
+ }
187
+ const { footnotes, footnoteIDs } = this.parseFootnotes([
188
+ ...element.querySelectorAll('fn:not([fn-type])'),
189
+ ]);
190
+ const authorNotesParagraphs = this.parseParagraphs([
191
+ ...element.querySelectorAll(':scope > p'),
192
+ ]);
193
+ const { correspondingList, correspondingIDs } = this.parseCorresp([
194
+ ...element.querySelectorAll('corresp'),
195
+ ]);
196
+ const authorNotes = [
197
+ buildAuthorNotes([
198
+ ...footnoteIDs.values(),
199
+ ...authorNotesParagraphs.map((p) => p._id),
200
+ ]),
201
+ ];
202
+ return {
203
+ footnotes,
204
+ footnoteIDs,
205
+ authorNotesParagraphs,
206
+ authorNotes,
207
+ correspondingIDs,
208
+ correspondingList,
209
+ };
210
+ },
211
+ parseParagraphs(elements) {
212
+ return elements.map((p) => buildParagraph(p.innerHTML));
213
+ },
214
+ parseFootnotes(elements) {
177
215
  const footnoteIDs = new Map();
178
216
  const footnotes = elements.map((element) => {
179
217
  const fn = buildFootnote('', element.innerHTML);
@@ -13,6 +13,8 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ import { v4 as uuidv4 } from 'uuid';
17
+ import { schema } from '../../schema';
16
18
  import { generateID, nodeTypesMap } from '../../transformer';
17
19
  export const updateDocumentIDs = (node, replacements) => {
18
20
  const warnings = [];
@@ -26,6 +28,10 @@ function recurseDoc(node, fn) {
26
28
  node.descendants((n) => fn(n));
27
29
  }
28
30
  const updateNodeID = (node, replacements, warnings) => {
31
+ if (node.type === schema.nodes.inline_equation) {
32
+ node.attrs = Object.assign(Object.assign({}, node.attrs), { id: `InlineMathFragment:${uuidv4()}` });
33
+ return;
34
+ }
29
35
  if (!('id' in node.attrs)) {
30
36
  return;
31
37
  }
@@ -32,12 +32,7 @@ export const parseJATSFront = (doc, front) => {
32
32
  const { affiliations, affiliationIDs } = jatsFrontParser.parseAffiliations([
33
33
  ...front.querySelectorAll('article-meta > contrib-group > aff'),
34
34
  ]);
35
- const { footnotes, footnoteIDs } = jatsFrontParser.parseAuthorNotes([
36
- ...front.querySelectorAll('article-meta > author-notes > fn:not([fn-type])'),
37
- ]);
38
- const { correspondingList, correspondingIDs } = jatsFrontParser.parseCorresp([
39
- ...front.querySelectorAll('article-meta > author-notes > corresp'),
40
- ]);
35
+ const { footnotes, footnoteIDs, authorNotes, authorNotesParagraphs, correspondingIDs, correspondingList, } = jatsFrontParser.parseAuthorNotes(front.querySelector('article-meta > author-notes'));
41
36
  const authors = jatsFrontParser.parseContributors([
42
37
  ...front.querySelectorAll('article-meta > contrib-group > contrib[contrib-type="author"]'),
43
38
  ], affiliationIDs, footnoteIDs, correspondingIDs);
@@ -48,6 +43,8 @@ export const parseJATSFront = (doc, front) => {
48
43
  manuscript,
49
44
  titles,
50
45
  journal,
46
+ ...authorNotesParagraphs,
47
+ ...authorNotes,
51
48
  ...footnotes,
52
49
  ...authors,
53
50
  ...affiliations,