@manuscripts/transform 2.1.1 → 2.1.2-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 (57) 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 +10 -0
  4. package/dist/cjs/jats/importer/jats-parser-utils.js +6 -0
  5. package/dist/cjs/jats/importer/parse-jats-article.js +1 -0
  6. package/dist/cjs/jats/jats-exporter.js +30 -38
  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 +3 -9
  12. package/dist/cjs/transformer/decode.js +22 -24
  13. package/dist/cjs/transformer/encode.js +14 -25
  14. package/dist/cjs/transformer/footnotes-order.js +1 -4
  15. package/dist/cjs/transformer/node-types.js +0 -1
  16. package/dist/cjs/transformer/object-types.js +0 -1
  17. package/dist/es/index.js +0 -1
  18. package/dist/es/jats/importer/jats-body-dom-parser.js +28 -73
  19. package/dist/es/jats/importer/jats-body-transformations.js +10 -0
  20. package/dist/es/jats/importer/jats-parser-utils.js +6 -0
  21. package/dist/es/jats/importer/parse-jats-article.js +1 -0
  22. package/dist/es/jats/jats-exporter.js +30 -38
  23. package/dist/es/schema/index.js +0 -1
  24. package/dist/es/schema/nodes/equation.js +12 -14
  25. package/dist/es/schema/nodes/equation_element.js +4 -5
  26. package/dist/es/schema/nodes/inline_equation.js +13 -15
  27. package/dist/es/transformer/builders.js +2 -7
  28. package/dist/es/transformer/decode.js +23 -25
  29. package/dist/es/transformer/encode.js +15 -26
  30. package/dist/es/transformer/footnotes-order.js +0 -2
  31. package/dist/es/transformer/node-types.js +0 -1
  32. package/dist/es/transformer/object-types.js +0 -1
  33. package/dist/types/index.d.ts +0 -1
  34. package/dist/types/jats/importer/jats-body-transformations.d.ts +1 -0
  35. package/dist/types/jats/jats-exporter.d.ts +1 -0
  36. package/dist/types/schema/index.d.ts +0 -1
  37. package/dist/types/schema/nodes/equation.d.ts +3 -4
  38. package/dist/types/schema/nodes/equation_element.d.ts +1 -2
  39. package/dist/types/schema/nodes/inline_equation.d.ts +4 -3
  40. package/dist/types/transformer/builders.d.ts +2 -3
  41. package/dist/types/transformer/footnotes-order.d.ts +0 -1
  42. package/package.json +3 -4
  43. package/dist/cjs/mathjax/index.js +0 -41
  44. package/dist/cjs/mathjax/mathjax-packages.js +0 -20
  45. package/dist/cjs/mathjax/mathml-to-svg.js +0 -70
  46. package/dist/cjs/mathjax/tex-to-mathml.js +0 -49
  47. package/dist/cjs/mathjax/tex-to-svg.js +0 -59
  48. package/dist/es/mathjax/index.js +0 -12
  49. package/dist/es/mathjax/mathjax-packages.js +0 -17
  50. package/dist/es/mathjax/mathml-to-svg.js +0 -66
  51. package/dist/es/mathjax/tex-to-mathml.js +0 -45
  52. package/dist/es/mathjax/tex-to-svg.js +0 -55
  53. package/dist/types/mathjax/index.d.ts +0 -3
  54. package/dist/types/mathjax/mathjax-packages.d.ts +0 -16
  55. package/dist/types/mathjax/mathml-to-svg.d.ts +0 -17
  56. package/dist/types/mathjax/tex-to-mathml.d.ts +0 -17
  57. package/dist/types/mathjax/tex-to-svg.d.ts +0 -17
@@ -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],
@@ -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
  },
@@ -262,6 +262,16 @@ export const jatsBodyTransformations = {
262
262
  }
263
263
  });
264
264
  },
265
+ orderTableFootnote(doc, body) {
266
+ const tableInlineFootnotesIds = new Set(Array.from(body.querySelectorAll('tbody > tr > td > xref[ref-type="fn"]').values()).map((inlineFootnote) => inlineFootnote.getAttribute('rid')));
267
+ const fnGroups = doc.querySelectorAll('table-wrap-foot > fn-group');
268
+ fnGroups.forEach((fnGroup) => {
269
+ const orderedFootnotes = Array.from(fnGroup.querySelectorAll('fn')).sort((fn) => tableInlineFootnotesIds.has(fn.getAttribute('id'))
270
+ ? -1
271
+ : 0);
272
+ fnGroup.replaceChildren(...orderedFootnotes);
273
+ });
274
+ },
265
275
  moveFloatsGroupToBody(doc, body, createElement) {
266
276
  const group = doc.querySelector('floats-group');
267
277
  if (group) {
@@ -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
  }
@@ -63,6 +63,7 @@ export const parseJATSBody = (doc, body, references) => {
63
63
  jatsBodyTransformations.createBackmatter(doc, body, createElement);
64
64
  jatsBodyTransformations.createSuppleMaterials(doc, body, createElement);
65
65
  jatsBodyTransformations.createKeywords(doc, body, createElement);
66
+ jatsBodyTransformations.orderTableFootnote(doc, body);
66
67
  const node = jatsBodyDOMParser.parse(body).firstChild;
67
68
  if (!node) {
68
69
  throw new Error('No content was parsed from the JATS article body');
@@ -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
  }
@@ -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,
@@ -108,10 +102,11 @@ export const buildFootnote = (containingObject, contents, kind = 'footnote') =>
108
102
  contents,
109
103
  kind,
110
104
  });
111
- export const buildFootnotesOrder = (footnotesList) => ({
105
+ export const buildFootnotesOrder = (footnotesList, containedObjectID) => ({
112
106
  _id: generateID(ObjectTypes.FootnotesOrder),
113
107
  objectType: ObjectTypes.FootnotesOrder,
114
108
  footnotesList,
109
+ containedObjectID,
115
110
  });
116
111
  export const buildCorresp = (contents) => ({
117
112
  _id: generateID(ObjectTypes.Corresponding),
@@ -32,7 +32,7 @@ import { abstractsType, backmatterType, bodyType, } from '../lib/section-group-t
32
32
  import { schema, } from '../schema';
33
33
  import { buildTitles } from './builders';
34
34
  import { insertHighlightMarkers } from './highlight-markers';
35
- import { ExtraObjectTypes, hasObjectType, isCommentAnnotation, isManuscript, } from './object-types';
35
+ import { ExtraObjectTypes, isCommentAnnotation, isManuscript, } from './object-types';
36
36
  import { chooseSectionLableName, chooseSectionNodeType, chooseSecType, getSectionGroupType, guessSectionCategory, } from './section-category';
37
37
  import { timestamp } from './timestamp';
38
38
  const warn = debug('manuscripts-transform');
@@ -59,7 +59,6 @@ const getSupplements = (modelMap) => getModelsByType(modelMap, ObjectTypes.Suppl
59
59
  const getKeywordGroups = (modelMap) => getModelsByType(modelMap, ObjectTypes.KeywordGroup);
60
60
  const getKeywords = (modelMap) => getModelsByType(modelMap, ObjectTypes.Keyword);
61
61
  const getTitles = (modelMap) => getModelsByType(modelMap, ObjectTypes.Titles)[0];
62
- const isFootnote = hasObjectType(ObjectTypes.Footnote);
63
62
  const hasParentSection = (id) => (section) => section.path &&
64
63
  section.path.length > 1 &&
65
64
  section.path[section.path.length - 2] === id;
@@ -272,9 +271,8 @@ export class Decoder {
272
271
  const model = data;
273
272
  return schema.nodes.equation.createChecked({
274
273
  id: model._id,
275
- MathMLStringRepresentation: model.MathMLStringRepresentation,
276
- SVGStringRepresentation: model.SVGStringRepresentation,
277
- TeXRepresentation: model.TeXRepresentation,
274
+ contents: model.contents,
275
+ format: model.format,
278
276
  });
279
277
  },
280
278
  [ObjectTypes.EquationElement]: (data) => {
@@ -293,32 +291,32 @@ export class Decoder {
293
291
  else {
294
292
  throw new MissingElement(model.containedObjectID);
295
293
  }
296
- const figcaption = this.getFigcaption(model);
297
294
  return schema.nodes.equation_element.createChecked({
298
295
  id: model._id,
299
- suppressCaption: Boolean(model.suppressCaption),
300
- suppressTitle: Boolean(model.suppressTitle === undefined ? true : model.suppressTitle),
301
- }, [equation, figcaption]);
296
+ label: model.label,
297
+ }, [equation]);
302
298
  },
303
299
  [ObjectTypes.FootnotesElement]: (data) => {
304
300
  const foonotesElementModel = data;
305
- const collateByKind = foonotesElementModel.collateByKind || 'footnote';
306
301
  const footnotesOfKind = [];
307
- for (const model of this.modelMap.values()) {
308
- if (isFootnote(model) &&
309
- model.kind === collateByKind &&
310
- model.containingObject === foonotesElementModel._id) {
311
- const comments = this.createCommentNodes(model);
312
- comments.forEach((c) => this.comments.set(c.attrs.id, c));
313
- const footnote = this.parseContents(model.contents || '<div></div>', undefined, this.getComments(model), {
314
- topNode: schema.nodes.footnote.create({
315
- id: model._id,
316
- kind: model.kind,
317
- comments: comments.map((c) => c.attrs.id),
318
- }),
319
- });
320
- footnotesOfKind.push(footnote);
321
- }
302
+ const footnoteOrder = getModelsByType(this.modelMap, ObjectTypes.FootnotesOrder).find((model) => model.containedObjectID === data._id);
303
+ if (footnoteOrder) {
304
+ footnoteOrder.footnotesList.map(({ id }) => {
305
+ const model = this.modelMap.get(id);
306
+ const collateByKind = foonotesElementModel.collateByKind || 'footnote';
307
+ if (model.kind === collateByKind) {
308
+ const comments = this.createCommentNodes(model);
309
+ comments.forEach((c) => this.comments.set(c.attrs.id, c));
310
+ const footnote = this.parseContents(model.contents || '<div></div>', undefined, this.getComments(model), {
311
+ topNode: schema.nodes.footnote.create({
312
+ id: model._id,
313
+ kind: model.kind,
314
+ comments: comments.map((c) => c.attrs.id),
315
+ }),
316
+ });
317
+ footnotesOfKind.push(footnote);
318
+ }
319
+ });
322
320
  }
323
321
  return schema.nodes.footnotes_element.create({
324
322
  id: foonotesElementModel._id,