@manuscripts/transform 2.1.2 → 2.1.3-LEAN-3092-0

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 (54) 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-front-parser.js +5 -0
  4. package/dist/cjs/jats/importer/jats-parser-utils.js +6 -0
  5. package/dist/cjs/jats/importer/parse-jats-article.js +2 -1
  6. package/dist/cjs/jats/jats-exporter.js +37 -45
  7. package/dist/cjs/schema/index.js +0 -1
  8. package/dist/cjs/schema/nodes/equation.js +12 -14
  9. package/dist/cjs/schema/nodes/equation_element.js +4 -5
  10. package/dist/cjs/schema/nodes/inline_equation.js +13 -15
  11. package/dist/cjs/transformer/builders.js +1 -8
  12. package/dist/cjs/transformer/decode.js +4 -7
  13. package/dist/cjs/transformer/encode.js +5 -25
  14. package/dist/cjs/transformer/node-types.js +0 -1
  15. package/dist/cjs/transformer/object-types.js +0 -1
  16. package/dist/es/index.js +0 -1
  17. package/dist/es/jats/importer/jats-body-dom-parser.js +28 -73
  18. package/dist/es/jats/importer/jats-front-parser.js +5 -0
  19. package/dist/es/jats/importer/jats-parser-utils.js +6 -0
  20. package/dist/es/jats/importer/parse-jats-article.js +2 -1
  21. package/dist/es/jats/jats-exporter.js +37 -45
  22. package/dist/es/schema/index.js +0 -1
  23. package/dist/es/schema/nodes/equation.js +12 -14
  24. package/dist/es/schema/nodes/equation_element.js +4 -5
  25. package/dist/es/schema/nodes/inline_equation.js +13 -15
  26. package/dist/es/transformer/builders.js +0 -6
  27. package/dist/es/transformer/decode.js +4 -7
  28. package/dist/es/transformer/encode.js +5 -25
  29. package/dist/es/transformer/node-types.js +0 -1
  30. package/dist/es/transformer/object-types.js +0 -1
  31. package/dist/types/index.d.ts +0 -1
  32. package/dist/types/jats/importer/jats-front-parser.d.ts +1 -0
  33. package/dist/types/jats/jats-exporter.d.ts +1 -0
  34. package/dist/types/schema/index.d.ts +0 -1
  35. package/dist/types/schema/nodes/equation.d.ts +3 -4
  36. package/dist/types/schema/nodes/equation_element.d.ts +1 -2
  37. package/dist/types/schema/nodes/inline_equation.d.ts +4 -3
  38. package/dist/types/transformer/builders.d.ts +1 -2
  39. package/package.json +3 -4
  40. package/dist/cjs/mathjax/index.js +0 -41
  41. package/dist/cjs/mathjax/mathjax-packages.js +0 -20
  42. package/dist/cjs/mathjax/mathml-to-svg.js +0 -70
  43. package/dist/cjs/mathjax/tex-to-mathml.js +0 -49
  44. package/dist/cjs/mathjax/tex-to-svg.js +0 -59
  45. package/dist/es/mathjax/index.js +0 -12
  46. package/dist/es/mathjax/mathjax-packages.js +0 -17
  47. package/dist/es/mathjax/mathml-to-svg.js +0 -66
  48. package/dist/es/mathjax/tex-to-mathml.js +0 -45
  49. package/dist/es/mathjax/tex-to-svg.js +0 -55
  50. package/dist/types/mathjax/index.d.ts +0 -3
  51. package/dist/types/mathjax/mathjax-packages.d.ts +0 -16
  52. package/dist/types/mathjax/mathml-to-svg.d.ts +0 -17
  53. package/dist/types/mathjax/tex-to-mathml.d.ts +0 -17
  54. package/dist/types/mathjax/tex-to-svg.d.ts +0 -17
@@ -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
  },
@@ -39,6 +39,11 @@ export const jatsFrontParser = {
39
39
  }
40
40
  return titles;
41
41
  },
42
+ parseDOI(front) {
43
+ var _a;
44
+ const doi = front === null || front === void 0 ? void 0 : front.querySelector('article-meta > article-id[pub-id-type="doi"]');
45
+ return (_a = doi === null || doi === void 0 ? void 0 : doi.textContent) !== null && _a !== void 0 ? _a : undefined;
46
+ },
42
47
  parseCounts(counts) {
43
48
  var _a, _b, _c, _d, _e;
44
49
  if (counts) {
@@ -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
  }
@@ -28,6 +28,7 @@ export const parseJATSFront = (doc, front) => {
28
28
  const createElement = createElementFn(doc);
29
29
  const journal = jatsFrontParser.parseJournal(front.querySelector('journal-meta'));
30
30
  const titles = jatsFrontParser.parseTitles(front.querySelector('article-meta > title-group'), createElement);
31
+ const DOI = jatsFrontParser.parseDOI(front);
31
32
  const { affiliations, affiliationIDs } = jatsFrontParser.parseAffiliations([
32
33
  ...front.querySelectorAll('article-meta > contrib-group > aff'),
33
34
  ]);
@@ -42,7 +43,7 @@ export const parseJATSFront = (doc, front) => {
42
43
  ], affiliationIDs, footnoteIDs, correspondingIDs);
43
44
  const history = jatsFrontParser.parseDates(front.querySelector('article-meta > history'));
44
45
  const counts = jatsFrontParser.parseCounts(front.querySelector('article-meta counts'));
45
- const manuscript = Object.assign(Object.assign(Object.assign({}, buildManuscript()), counts), history);
46
+ const manuscript = Object.assign(Object.assign(Object.assign(Object.assign({}, buildManuscript()), counts), history), { DOI });
46
47
  return generateIDs([
47
48
  manuscript,
48
49
  titles,
@@ -88,7 +88,7 @@ const createDefaultIdGenerator = () => {
88
88
  const counter = createCounter();
89
89
  return async (element) => {
90
90
  const value = String(counter.increment(element.nodeName));
91
- return `${element.nodeName}-${value}`;
91
+ return `${element.localName}-${value}`;
92
92
  };
93
93
  };
94
94
  const chooseRefType = (objectType) => {
@@ -156,6 +156,7 @@ export class JATSExporter {
156
156
  };
157
157
  this.nodeFromJATS = (JATSFragment) => {
158
158
  JATSFragment = JATSFragment.trim();
159
+ JATSFragment = JATSFragment.replace(' ', ' ');
159
160
  if (!JATSFragment.length) {
160
161
  return null;
161
162
  }
@@ -240,7 +241,7 @@ export class JATSExporter {
240
241
  }
241
242
  };
242
243
  this.buildFront = (doi, id, links) => {
243
- var _a, _b, _c, _d;
244
+ var _a, _b, _c, _d, _e;
244
245
  const manuscript = findManuscript(this.modelMap);
245
246
  const titles = findTitles(this.modelMap);
246
247
  const front = this.document.createElement('front');
@@ -303,10 +304,10 @@ export class JATSExporter {
303
304
  articleID.textContent = id;
304
305
  articleMeta.appendChild(articleID);
305
306
  }
306
- if (doi) {
307
+ if (doi || manuscript.DOI) {
307
308
  const articleID = this.document.createElement('article-id');
308
309
  articleID.setAttribute('pub-id-type', 'doi');
309
- articleID.textContent = doi;
310
+ articleID.textContent = (_a = manuscript.DOI) !== null && _a !== void 0 ? _a : doi;
310
311
  articleMeta.appendChild(articleID);
311
312
  }
312
313
  const titleGroup = this.document.createElement('title-group');
@@ -341,14 +342,14 @@ export class JATSExporter {
341
342
  for (const supplement of supplements) {
342
343
  const supplementaryMaterial = this.document.createElement('supplementary-material');
343
344
  supplementaryMaterial.setAttribute('id', normalizeID(supplement._id));
344
- supplementaryMaterial.setAttributeNS(XLINK_NAMESPACE, 'href', (_a = supplement.href) !== null && _a !== void 0 ? _a : '');
345
- const mimeType = (_b = supplement.MIME) === null || _b === void 0 ? void 0 : _b.split('/')[0];
346
- const mimeSubType = (_c = supplement.MIME) === null || _c === void 0 ? void 0 : _c.split('/')[1];
345
+ supplementaryMaterial.setAttributeNS(XLINK_NAMESPACE, 'href', (_b = supplement.href) !== null && _b !== void 0 ? _b : '');
346
+ const mimeType = (_c = supplement.MIME) === null || _c === void 0 ? void 0 : _c.split('/')[0];
347
+ const mimeSubType = (_d = supplement.MIME) === null || _d === void 0 ? void 0 : _d.split('/')[1];
347
348
  supplementaryMaterial.setAttribute('mimetype', mimeType !== null && mimeType !== void 0 ? mimeType : '');
348
349
  supplementaryMaterial.setAttribute('mime-subtype', mimeSubType !== null && mimeSubType !== void 0 ? mimeSubType : '');
349
350
  const caption = this.document.createElement('caption');
350
351
  const title = this.document.createElement('title');
351
- title.textContent = (_d = supplement.title) !== null && _d !== void 0 ? _d : '';
352
+ title.textContent = (_e = supplement.title) !== null && _e !== void 0 ? _e : '';
352
353
  caption.append(title);
353
354
  supplementaryMaterial.append(caption);
354
355
  articleMeta.append(supplementaryMaterial);
@@ -678,22 +679,20 @@ export class JATSExporter {
678
679
  },
679
680
  doc: () => '',
680
681
  equation: (node) => {
681
- const formula = this.document.createElement('disp-formula');
682
- formula.setAttribute('id', normalizeID(node.attrs.id));
683
- if (node.attrs.TeXRepresentation) {
684
- const math = this.document.createElement('tex-math');
685
- math.textContent = node.attrs.TeXRepresentation;
686
- formula.appendChild(math);
687
- }
688
- else if (node.attrs.MathMLStringRepresentation) {
689
- const math = this.nodeFromJATS(node.attrs.MathMLStringRepresentation);
690
- if (math) {
691
- formula.appendChild(math);
692
- }
693
- }
694
- return formula;
682
+ return this.createEquation(node);
683
+ },
684
+ inline_equation: (node) => {
685
+ const eqElement = this.document.createElement('inline-formula');
686
+ const equation = this.createEquation(node, true);
687
+ eqElement.append(equation);
688
+ return eqElement;
689
+ },
690
+ equation_element: (node) => {
691
+ const eqElement = this.document.createElement('disp-formula');
692
+ eqElement.setAttribute('id', normalizeID(node.attrs.id));
693
+ processChildNodes(eqElement, node, schema.nodes.equation);
694
+ return eqElement;
695
695
  },
696
- equation_element: (node) => createFigureElement(node, 'fig', node.type.schema.nodes.equation, 'equation'),
697
696
  figcaption: (node) => {
698
697
  if (!node.textContent) {
699
698
  return '';
@@ -743,28 +742,6 @@ export class JATSExporter {
743
742
  },
744
743
  hard_break: () => '',
745
744
  highlight_marker: () => '',
746
- inline_equation: (node) => {
747
- const formula = this.document.createElement('inline-formula');
748
- formula.setAttribute('id', normalizeID(node.attrs.id));
749
- if (node.attrs.TeXRepresentation) {
750
- const math = this.document.createElement('tex-math');
751
- math.textContent = node.attrs.TeXRepresentation;
752
- formula.appendChild(math);
753
- }
754
- else if (node.attrs.MathMLRepresentation) {
755
- const math = this.nodeFromJATS(node.attrs.MathMLRepresentation);
756
- if (math) {
757
- formula.appendChild(math);
758
- }
759
- }
760
- else if (node.attrs.SVGRepresentation) {
761
- const math = this.nodeFromJATS(node.attrs.SVGRepresentation);
762
- if (math) {
763
- formula.appendChild(math);
764
- }
765
- }
766
- return formula;
767
- },
768
745
  inline_footnote: (node) => {
769
746
  const xref = this.document.createElement('xref');
770
747
  xref.setAttribute('ref-type', 'fn');
@@ -1581,6 +1558,21 @@ export class JATSExporter {
1581
1558
  this.citationTexts.set(id, output);
1582
1559
  });
1583
1560
  }
1561
+ createEquation(node, isInline = false) {
1562
+ if (node.attrs.format === 'tex') {
1563
+ const texMath = this.document.createElement('tex-math');
1564
+ texMath.innerHTML = node.attrs.contents;
1565
+ return texMath;
1566
+ }
1567
+ else {
1568
+ const math = this.nodeFromJATS(node.attrs.contents);
1569
+ const mathml = math;
1570
+ if (!isInline) {
1571
+ mathml.setAttribute('id', normalizeID(node.attrs.id));
1572
+ }
1573
+ return mathml;
1574
+ }
1575
+ }
1584
1576
  buildKeywords(articleMeta) {
1585
1577
  const keywords = [...this.modelMap.values()].filter((model) => model.objectType === ObjectTypes.Keyword);
1586
1578
  const keywordGroups = new Map();
@@ -100,7 +100,6 @@ export * from './nodes/footnotes_section';
100
100
  export * from './nodes/graphical_abstract_section';
101
101
  export * from './nodes/hard_break';
102
102
  export * from './nodes/highlight_marker';
103
- export * from './nodes/inline_equation';
104
103
  export * from './nodes/inline_footnote';
105
104
  export * from './nodes/keyword';
106
105
  export * from './nodes/keywords_element';
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * © 2019 Atypon Systems LLC
2
+ * © 2023 Atypon Systems LLC
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -17,9 +17,8 @@ import { ObjectTypes } from '@manuscripts/json-schema';
17
17
  export const equation = {
18
18
  attrs: {
19
19
  id: { default: '' },
20
- MathMLStringRepresentation: { default: '' },
21
- SVGStringRepresentation: { default: '' },
22
- TeXRepresentation: { default: '' },
20
+ contents: { default: '' },
21
+ format: { default: '' },
23
22
  dataTracked: { default: null },
24
23
  },
25
24
  group: 'block',
@@ -27,26 +26,25 @@ export const equation = {
27
26
  {
28
27
  tag: `div.${ObjectTypes.Equation}`,
29
28
  getAttrs: (p) => {
30
- const dom = p;
29
+ const htmlEl = p;
31
30
  return {
32
- id: dom.getAttribute('id'),
33
- MathMLStringRepresentation: dom.getAttribute('data-mathml-string-representation'),
34
- SVGStringRepresentation: dom.innerHTML,
35
- TeXRepresentation: dom.getAttribute('data-tex-representation'),
31
+ id: htmlEl.getAttribute('id'),
32
+ format: htmlEl.getAttribute('data-equation-format'),
33
+ contents: htmlEl.innerHTML,
36
34
  };
37
35
  },
38
36
  },
39
37
  ],
40
38
  toDOM: (node) => {
41
39
  const equationNode = node;
40
+ const { id, contents, format } = equationNode.attrs;
42
41
  const dom = document.createElement('div');
43
- dom.setAttribute('id', equationNode.attrs.id);
44
42
  dom.classList.add(ObjectTypes.Equation);
45
- if (equationNode.attrs.MathMLStringRepresentation) {
46
- dom.setAttribute('data-mathml-string-representation', equationNode.attrs.MathMLStringRepresentation);
43
+ dom.setAttribute('id', id);
44
+ if (format) {
45
+ dom.setAttribute('data-equation-format', format);
47
46
  }
48
- dom.setAttribute('data-tex-representation', equationNode.attrs.TeXRepresentation);
49
- dom.innerHTML = equationNode.attrs.SVGStringRepresentation;
47
+ dom.innerHTML = contents;
50
48
  return dom;
51
49
  },
52
50
  };
@@ -14,11 +14,10 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  export const equationElement = {
17
- content: '(equation | placeholder) figcaption',
17
+ content: '(equation | placeholder)',
18
18
  attrs: {
19
19
  id: { default: '' },
20
- suppressCaption: { default: true },
21
- suppressTitle: { default: undefined },
20
+ label: { default: '' },
22
21
  dataTracked: { default: null },
23
22
  comments: { default: null },
24
23
  },
@@ -26,7 +25,7 @@ export const equationElement = {
26
25
  group: 'block element',
27
26
  parseDOM: [
28
27
  {
29
- tag: 'figure.equation',
28
+ tag: 'div.equation',
30
29
  getAttrs: (p) => {
31
30
  const dom = p;
32
31
  return {
@@ -38,7 +37,7 @@ export const equationElement = {
38
37
  toDOM: (node) => {
39
38
  const equationElementNode = node;
40
39
  return [
41
- 'figure',
40
+ 'div',
42
41
  {
43
42
  class: 'equation',
44
43
  id: equationElementNode.attrs.id,
@@ -13,14 +13,13 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { ObjectTypes } from '@manuscripts/json-schema';
17
16
  export const inlineEquation = {
18
17
  attrs: {
19
- id: { default: '' },
20
- MathMLRepresentation: { default: '' },
21
- SVGRepresentation: { default: '' },
22
- TeXRepresentation: { default: '' },
23
18
  dataTracked: { default: null },
19
+ comments: { default: null },
20
+ id: { default: '' },
21
+ contents: { default: '' },
22
+ format: { default: '' },
24
23
  },
25
24
  atom: true,
26
25
  inline: true,
@@ -28,28 +27,27 @@ export const inlineEquation = {
28
27
  group: 'inline',
29
28
  parseDOM: [
30
29
  {
31
- tag: `span.${ObjectTypes.InlineMathFragment}`,
30
+ tag: `span.MPInlineMathFragment`,
32
31
  getAttrs: (p) => {
33
32
  const dom = p;
34
33
  return {
34
+ format: dom.getAttribute('data-equation-format'),
35
35
  id: dom.getAttribute('id'),
36
- MathMLRepresentation: dom.getAttribute('data-mathml-representation') || '',
37
- SVGRepresentation: dom.innerHTML || '',
38
- TeXRepresentation: dom.getAttribute('data-tex-representation') || '',
36
+ contents: dom.innerHTML,
39
37
  };
40
38
  },
41
39
  },
42
40
  ],
43
41
  toDOM: (node) => {
44
42
  const inlineEquationNode = node;
43
+ const { id, contents, format } = inlineEquationNode.attrs;
45
44
  const dom = document.createElement('span');
46
- dom.classList.add(ObjectTypes.InlineMathFragment);
47
- dom.setAttribute('id', inlineEquationNode.attrs.id);
48
- dom.setAttribute('data-tex-representation', inlineEquationNode.attrs.TeXRepresentation);
49
- if (inlineEquationNode.attrs.MathMLRepresentation) {
50
- dom.setAttribute('data-mathml-representation', inlineEquationNode.attrs.MathMLRepresentation);
45
+ dom.setAttribute('id', id);
46
+ dom.classList.add('MPInlineMathFragment');
47
+ if (format) {
48
+ dom.setAttribute('data-equation-format', format);
51
49
  }
52
- dom.innerHTML = inlineEquationNode.attrs.SVGRepresentation;
50
+ dom.innerHTML = contents;
53
51
  return dom;
54
52
  },
55
53
  };
@@ -95,12 +95,6 @@ export const buildNote = (target, source, contents = '') => ({
95
95
  source,
96
96
  contents,
97
97
  });
98
- export const buildInlineMathFragment = (containingObject, TeXRepresentation) => ({
99
- _id: generateID(ObjectTypes.InlineMathFragment),
100
- objectType: ObjectTypes.InlineMathFragment,
101
- containingObject: containingObject || undefined,
102
- TeXRepresentation,
103
- });
104
98
  export const buildFootnote = (containingObject, contents, kind = 'footnote') => ({
105
99
  _id: generateID(ObjectTypes.Footnote),
106
100
  objectType: ObjectTypes.Footnote,
@@ -271,9 +271,8 @@ export class Decoder {
271
271
  const model = data;
272
272
  return schema.nodes.equation.createChecked({
273
273
  id: model._id,
274
- MathMLStringRepresentation: model.MathMLStringRepresentation,
275
- SVGStringRepresentation: model.SVGStringRepresentation,
276
- TeXRepresentation: model.TeXRepresentation,
274
+ contents: model.contents,
275
+ format: model.format,
277
276
  });
278
277
  },
279
278
  [ObjectTypes.EquationElement]: (data) => {
@@ -292,12 +291,10 @@ export class Decoder {
292
291
  else {
293
292
  throw new MissingElement(model.containedObjectID);
294
293
  }
295
- const figcaption = this.getFigcaption(model);
296
294
  return schema.nodes.equation_element.createChecked({
297
295
  id: model._id,
298
- suppressCaption: Boolean(model.suppressCaption),
299
- suppressTitle: Boolean(model.suppressTitle === undefined ? true : model.suppressTitle),
300
- }, [equation, figcaption]);
296
+ label: model.label,
297
+ }, [equation]);
301
298
  },
302
299
  [ObjectTypes.FootnotesElement]: (data) => {
303
300
  const foonotesElementModel = data;
@@ -54,12 +54,6 @@ const listContents = (node) => {
54
54
  }
55
55
  return serializeToXML(output);
56
56
  };
57
- const svgDefs = (svg) => {
58
- const template = document.createElement('template');
59
- template.innerHTML = svg.trim();
60
- const defs = template.content.querySelector('defs');
61
- return defs ? serializeToXML(defs) : undefined;
62
- };
63
57
  const tableRowDisplayStyle = (tagName, parent) => {
64
58
  switch (tagName) {
65
59
  case 'thead':
@@ -345,20 +339,13 @@ const encoders = {
345
339
  : false,
346
340
  }),
347
341
  equation: (node) => ({
348
- MathMLStringRepresentation: node.attrs.MathMLStringRepresentation || undefined,
349
- TeXRepresentation: node.attrs.TeXRepresentation,
350
- SVGStringRepresentation: node.attrs.SVGStringRepresentation,
342
+ contents: node.attrs.contents,
343
+ format: node.attrs.format,
351
344
  }),
352
345
  equation_element: (node) => ({
353
346
  containedObjectID: attributeOfNodeType(node, 'equation', 'id'),
354
- caption: inlineContentOfChildNodeType(node, node.type.schema.nodes.figcaption, node.type.schema.nodes.caption),
355
- title: inlineContentOfChildNodeType(node, node.type.schema.nodes.figcaption, node.type.schema.nodes.caption_title, false),
356
- elementType: 'p',
357
- suppressCaption: Boolean(node.attrs.suppressCaption) || undefined,
358
- suppressTitle: node.attrs.suppressTitle === undefined ||
359
- node.attrs.suppressTitle === true
360
- ? undefined
361
- : false,
347
+ elementType: 'div',
348
+ label: node.attrs.label,
362
349
  }),
363
350
  figure: (node) => ({
364
351
  contentType: node.attrs.contentType || undefined,
@@ -405,12 +392,6 @@ const encoders = {
405
392
  .map((childNode) => childNode.attrs.id)
406
393
  .filter((id) => id),
407
394
  }),
408
- inline_equation: (node, parent) => ({
409
- containingObject: parent.attrs.id,
410
- TeXRepresentation: node.attrs.TeXRepresentation,
411
- SVGRepresentation: node.attrs.SVGRepresentation,
412
- SVGGlyphs: svgDefs(node.attrs.SVGRepresentation),
413
- }),
414
395
  keyword: (node, parent) => ({
415
396
  containedGroup: parent.attrs.id,
416
397
  name: keywordContents(node),
@@ -583,8 +564,7 @@ export const encode = (node) => {
583
564
  if (placeholderTypes.includes(child.type)) {
584
565
  return;
585
566
  }
586
- if (parent.type === schema.nodes.paragraph &&
587
- child.type !== schema.nodes.inline_equation) {
567
+ if (parent.type === schema.nodes.paragraph) {
588
568
  return;
589
569
  }
590
570
  if (child.type === schema.nodes.footnotes_element) {
@@ -36,7 +36,6 @@ export const nodeTypesMap = new Map([
36
36
  [schema.nodes.footnotes_section, ObjectTypes.Section],
37
37
  [schema.nodes.graphical_abstract_section, ObjectTypes.Section],
38
38
  [schema.nodes.highlight_marker, ObjectTypes.HighlightMarker],
39
- [schema.nodes.inline_equation, ObjectTypes.InlineMathFragment],
40
39
  [schema.nodes.keyword, ObjectTypes.Keyword],
41
40
  [schema.nodes.keywords_element, ObjectTypes.KeywordsElement],
42
41
  [schema.nodes.keywords, ObjectTypes.Section],
@@ -35,7 +35,6 @@ export const manuscriptObjects = [
35
35
  ObjectTypes.CommentAnnotation,
36
36
  ObjectTypes.Contributor,
37
37
  ObjectTypes.Footnote,
38
- ObjectTypes.InlineMathFragment,
39
38
  ObjectTypes.Section,
40
39
  ].concat(elementObjects);
41
40
  export const isManuscriptModel = (model) => {
@@ -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,6 +15,7 @@
15
15
  */
16
16
  export declare const jatsFrontParser: {
17
17
  parseTitles(element: Element | null, createElement: (tagName: string) => HTMLElement): import("../../transformer").Build<import("@manuscripts/json-schema/dist/types").Titles>;
18
+ parseDOI(front: Element | null): string | undefined;
18
19
  parseCounts(counts: Element | null): {
19
20
  wordCount: number | undefined;
20
21
  figureCount: number | undefined;
@@ -82,6 +82,7 @@ export declare class JATSExporter {
82
82
  protected buildBody: (fragment: ManuscriptFragment) => HTMLBodyElement;
83
83
  protected buildBack: (body: HTMLElement) => HTMLElement;
84
84
  protected createSerializer: () => void;
85
+ private createEquation;
85
86
  protected serializeFragment: (fragment: ManuscriptFragment) => HTMLElement | DocumentFragment;
86
87
  protected serializeNode: (node: ManuscriptNode) => Node;
87
88
  private validateContributor;
@@ -40,7 +40,6 @@ export * from './nodes/footnotes_section';
40
40
  export * from './nodes/graphical_abstract_section';
41
41
  export * from './nodes/hard_break';
42
42
  export * from './nodes/highlight_marker';
43
- export * from './nodes/inline_equation';
44
43
  export * from './nodes/inline_footnote';
45
44
  export * from './nodes/keyword';
46
45
  export * from './nodes/keywords_element';