@manuscripts/transform 2.1.4 → 2.1.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 (49) 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-parser-utils.js +6 -0
  4. package/dist/cjs/jats/jats-exporter.js +30 -38
  5. package/dist/cjs/schema/index.js +0 -1
  6. package/dist/cjs/schema/nodes/equation.js +12 -14
  7. package/dist/cjs/schema/nodes/equation_element.js +4 -5
  8. package/dist/cjs/schema/nodes/inline_equation.js +13 -15
  9. package/dist/cjs/transformer/builders.js +1 -8
  10. package/dist/cjs/transformer/decode.js +4 -7
  11. package/dist/cjs/transformer/encode.js +5 -25
  12. package/dist/cjs/transformer/node-types.js +0 -1
  13. package/dist/cjs/transformer/object-types.js +0 -1
  14. package/dist/es/index.js +0 -1
  15. package/dist/es/jats/importer/jats-body-dom-parser.js +28 -73
  16. package/dist/es/jats/importer/jats-parser-utils.js +6 -0
  17. package/dist/es/jats/jats-exporter.js +30 -38
  18. package/dist/es/schema/index.js +0 -1
  19. package/dist/es/schema/nodes/equation.js +12 -14
  20. package/dist/es/schema/nodes/equation_element.js +4 -5
  21. package/dist/es/schema/nodes/inline_equation.js +13 -15
  22. package/dist/es/transformer/builders.js +0 -6
  23. package/dist/es/transformer/decode.js +4 -7
  24. package/dist/es/transformer/encode.js +5 -25
  25. package/dist/es/transformer/node-types.js +0 -1
  26. package/dist/es/transformer/object-types.js +0 -1
  27. package/dist/types/index.d.ts +0 -1
  28. package/dist/types/jats/jats-exporter.d.ts +1 -0
  29. package/dist/types/schema/index.d.ts +0 -1
  30. package/dist/types/schema/nodes/equation.d.ts +3 -4
  31. package/dist/types/schema/nodes/equation_element.d.ts +1 -2
  32. package/dist/types/schema/nodes/inline_equation.d.ts +4 -3
  33. package/dist/types/transformer/builders.d.ts +1 -2
  34. package/package.json +4 -5
  35. package/dist/cjs/mathjax/index.js +0 -41
  36. package/dist/cjs/mathjax/mathjax-packages.js +0 -20
  37. package/dist/cjs/mathjax/mathml-to-svg.js +0 -70
  38. package/dist/cjs/mathjax/tex-to-mathml.js +0 -49
  39. package/dist/cjs/mathjax/tex-to-svg.js +0 -59
  40. package/dist/es/mathjax/index.js +0 -12
  41. package/dist/es/mathjax/mathjax-packages.js +0 -17
  42. package/dist/es/mathjax/mathml-to-svg.js +0 -66
  43. package/dist/es/mathjax/tex-to-mathml.js +0 -45
  44. package/dist/es/mathjax/tex-to-svg.js +0 -55
  45. package/dist/types/mathjax/index.d.ts +0 -3
  46. package/dist/types/mathjax/mathjax-packages.d.ts +0 -16
  47. package/dist/types/mathjax/mathml-to-svg.d.ts +0 -17
  48. package/dist/types/mathjax/tex-to-mathml.d.ts +0 -17
  49. 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
  },
@@ -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
  }
@@ -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');
@@ -1605,6 +1582,21 @@ export class JATSExporter {
1605
1582
  this.citationTexts.set(id, output);
1606
1583
  });
1607
1584
  }
1585
+ createEquation(node, isInline = false) {
1586
+ if (node.attrs.format === 'tex') {
1587
+ const texMath = this.document.createElement('tex-math');
1588
+ texMath.innerHTML = node.attrs.contents;
1589
+ return texMath;
1590
+ }
1591
+ else {
1592
+ const math = this.nodeFromJATS(node.attrs.contents);
1593
+ const mathml = math;
1594
+ if (!isInline) {
1595
+ mathml.setAttribute('id', normalizeID(node.attrs.id));
1596
+ }
1597
+ return mathml;
1598
+ }
1599
+ }
1608
1600
  buildKeywords(articleMeta) {
1609
1601
  const keywords = [...this.modelMap.values()].filter((model) => model.objectType === ObjectTypes.Keyword);
1610
1602
  const keywordGroups = new Map();
@@ -99,7 +99,6 @@ export * from './nodes/footnotes_section';
99
99
  export * from './nodes/graphical_abstract_section';
100
100
  export * from './nodes/hard_break';
101
101
  export * from './nodes/highlight_marker';
102
- export * from './nodes/inline_equation';
103
102
  export * from './nodes/inline_footnote';
104
103
  export * from './nodes/keyword';
105
104
  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':
@@ -346,20 +340,13 @@ const encoders = {
346
340
  : false,
347
341
  }),
348
342
  equation: (node) => ({
349
- MathMLStringRepresentation: node.attrs.MathMLStringRepresentation || undefined,
350
- TeXRepresentation: node.attrs.TeXRepresentation,
351
- SVGStringRepresentation: node.attrs.SVGStringRepresentation,
343
+ contents: node.attrs.contents,
344
+ format: node.attrs.format,
352
345
  }),
353
346
  equation_element: (node) => ({
354
347
  containedObjectID: attributeOfNodeType(node, 'equation', 'id'),
355
- caption: inlineContentOfChildNodeType(node, node.type.schema.nodes.figcaption, node.type.schema.nodes.caption),
356
- title: inlineContentOfChildNodeType(node, node.type.schema.nodes.figcaption, node.type.schema.nodes.caption_title, false),
357
- elementType: 'p',
358
- suppressCaption: Boolean(node.attrs.suppressCaption) || undefined,
359
- suppressTitle: node.attrs.suppressTitle === undefined ||
360
- node.attrs.suppressTitle === true
361
- ? undefined
362
- : false,
348
+ elementType: 'div',
349
+ label: node.attrs.label,
363
350
  }),
364
351
  figure: (node) => ({
365
352
  contentType: node.attrs.contentType || undefined,
@@ -406,12 +393,6 @@ const encoders = {
406
393
  .map((childNode) => childNode.attrs.id)
407
394
  .filter((id) => id),
408
395
  }),
409
- inline_equation: (node, parent) => ({
410
- containingObject: parent.attrs.id,
411
- TeXRepresentation: node.attrs.TeXRepresentation,
412
- SVGRepresentation: node.attrs.SVGRepresentation,
413
- SVGGlyphs: svgDefs(node.attrs.SVGRepresentation),
414
- }),
415
396
  keyword: (node, parent) => ({
416
397
  containedGroup: parent.attrs.id,
417
398
  name: keywordContents(node),
@@ -584,8 +565,7 @@ export const encode = (node) => {
584
565
  if (placeholderTypes.includes(child.type)) {
585
566
  return;
586
567
  }
587
- if (parent.type === schema.nodes.paragraph &&
588
- child.type !== schema.nodes.inline_equation) {
568
+ if (parent.type === schema.nodes.paragraph) {
589
569
  return;
590
570
  }
591
571
  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';
@@ -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';
@@ -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 { NodeSpec } from 'prosemirror-model';
17
17
  import { ManuscriptNode } from '../types';
18
18
  interface Attrs {
19
19
  id: string;
20
- MathMLStringRepresentation: string;
21
- SVGStringRepresentation: string;
22
- TeXRepresentation: string;
20
+ format: string;
21
+ contents: string;
23
22
  }
24
23
  export interface EquationNode extends ManuscriptNode {
25
24
  attrs: Attrs;
@@ -18,8 +18,7 @@ import { ManuscriptNode } from '../types';
18
18
  import { CommentNode } from './comment';
19
19
  interface Attrs {
20
20
  id: string;
21
- suppressCaption: boolean;
22
- suppressTitle?: boolean;
21
+ label: string;
23
22
  comments?: CommentNode[];
24
23
  }
25
24
  export interface EquationElementNode extends ManuscriptNode {
@@ -15,11 +15,12 @@
15
15
  */
16
16
  import { NodeSpec } from 'prosemirror-model';
17
17
  import { ManuscriptNode } from '../types';
18
+ import { CommentNode } from './comment';
18
19
  interface Attrs {
19
20
  id: string;
20
- MathMLRepresentation: string;
21
- SVGRepresentation: string;
22
- TeXRepresentation: string;
21
+ contents: string;
22
+ format: string;
23
+ comments?: CommentNode[];
23
24
  }
24
25
  export interface InlineEquationNode extends ManuscriptNode {
25
26
  attrs: Attrs;
@@ -13,7 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { Affiliation, Attribution, BibliographicDate, BibliographicName, BibliographyElement, BibliographyItem, Color, CommentAnnotation, Contribution, Contributor, ContributorRole, Corresponding, ElementsOrder, EmbeddedModel, Figure, Footnote, FootnotesOrder, InlineMathFragment, Journal, Keyword, KeywordGroup, Manuscript, ManuscriptNote, ObjectTypes, ParagraphElement, Project, Section, Supplement, Titles } from '@manuscripts/json-schema';
16
+ import { Affiliation, Attribution, BibliographicDate, BibliographicName, BibliographyElement, BibliographyItem, Color, CommentAnnotation, Contribution, Contributor, ContributorRole, Corresponding, ElementsOrder, EmbeddedModel, Figure, Footnote, FootnotesOrder, Journal, Keyword, KeywordGroup, Manuscript, ManuscriptNote, ObjectTypes, ParagraphElement, Project, Section, Supplement, Titles } from '@manuscripts/json-schema';
17
17
  import { FootnotesOrderIndexList } from './footnotes-order';
18
18
  import { CommentSelector, ManuscriptModel, ModelAttachment } from './models';
19
19
  export type Build<T> = Pick<T, Exclude<keyof T, keyof ManuscriptModel>> & {
@@ -44,7 +44,6 @@ export declare const buildAffiliation: (institution: string, priority?: number)
44
44
  export declare const buildSupplementaryMaterial: (title: string, href: string) => Build<Supplement>;
45
45
  export declare const buildComment: (target: string, contents?: string, selector?: CommentSelector, contributions?: Contribution[], annotationColor?: string) => Build<CommentAnnotation>;
46
46
  export declare const buildNote: (target: string, source: 'EMAIL' | 'EDITOR' | 'DASHBOARD', contents?: string) => Build<ManuscriptNote>;
47
- export declare const buildInlineMathFragment: (containingObject: string, TeXRepresentation: string) => Build<InlineMathFragment>;
48
47
  export declare const buildFootnote: (containingObject: string, contents: string, kind?: 'footnote' | 'endnote') => Build<Footnote>;
49
48
  export declare const buildFootnotesOrder: (footnotesList: FootnotesOrderIndexList, containedObjectID: string) => Build<FootnotesOrder>;
50
49
  export declare const buildCorresp: (contents: string) => Build<Corresponding>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@manuscripts/transform",
3
3
  "description": "ProseMirror transformer for Manuscripts applications",
4
- "version": "2.1.4",
4
+ "version": "2.1.5",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-transform",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -29,11 +29,10 @@
29
29
  "version": "yarn build"
30
30
  },
31
31
  "dependencies": {
32
- "@manuscripts/json-schema": "^2.2.4",
33
- "@manuscripts/library": "^1.3.3",
32
+ "@manuscripts/json-schema": "^2.2.5",
33
+ "@manuscripts/library": "^1.3.4",
34
34
  "debug": "^4.3.4",
35
35
  "jszip": "^3.10.1",
36
- "mathjax-full": "^3.2.2",
37
36
  "mime": "^3.0.0",
38
37
  "prosemirror-model": "^1.18.3",
39
38
  "prosemirror-tables": "^1.3.5",
@@ -79,4 +78,4 @@
79
78
  "rimraf": "^3.0.2",
80
79
  "typescript": "^4.0.5"
81
80
  }
82
- }
81
+ }