@manuscripts/transform 2.1.3 → 2.1.5-LEAN-3376-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 (68) hide show
  1. package/dist/cjs/index.js +0 -1
  2. package/dist/cjs/jats/importer/jats-body-dom-parser.js +29 -88
  3. package/dist/cjs/jats/importer/jats-body-transformations.js +10 -17
  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 +116 -86
  8. package/dist/cjs/schema/index.js +5 -6
  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/schema/nodes/table.js +52 -30
  15. package/dist/cjs/schema/nodes/table_element.js +1 -1
  16. package/dist/cjs/transformer/builders.js +11 -14
  17. package/dist/cjs/transformer/decode.js +43 -25
  18. package/dist/cjs/transformer/encode.js +10 -26
  19. package/dist/cjs/transformer/node-types.js +2 -1
  20. package/dist/cjs/transformer/object-types.js +0 -1
  21. package/dist/es/index.js +0 -1
  22. package/dist/es/jats/importer/jats-body-dom-parser.js +30 -89
  23. package/dist/es/jats/importer/jats-body-transformations.js +10 -17
  24. package/dist/es/jats/importer/jats-front-parser.js +40 -2
  25. package/dist/es/jats/importer/jats-parser-utils.js +6 -0
  26. package/dist/es/jats/importer/parse-jats-article.js +3 -6
  27. package/dist/es/jats/jats-exporter.js +119 -89
  28. package/dist/es/schema/index.js +4 -5
  29. package/dist/{types/mathjax/mathjax-packages.d.ts → es/schema/nodes/author_notes.js} +9 -1
  30. package/dist/es/schema/nodes/contributors.js +1 -1
  31. package/dist/es/schema/nodes/equation.js +12 -14
  32. package/dist/es/schema/nodes/equation_element.js +4 -5
  33. package/dist/es/schema/nodes/inline_equation.js +13 -15
  34. package/dist/es/schema/nodes/table.js +51 -29
  35. package/dist/es/schema/nodes/table_element.js +1 -1
  36. package/dist/es/transformer/builders.js +9 -12
  37. package/dist/es/transformer/decode.js +43 -25
  38. package/dist/es/transformer/encode.js +10 -26
  39. package/dist/es/transformer/node-types.js +2 -1
  40. package/dist/es/transformer/object-types.js +0 -1
  41. package/dist/types/index.d.ts +0 -1
  42. package/dist/types/jats/importer/jats-front-parser.d.ts +10 -1
  43. package/dist/types/jats/jats-exporter.d.ts +5 -0
  44. package/dist/types/schema/index.d.ts +0 -2
  45. package/dist/{es/mathjax/mathjax-packages.js → types/schema/nodes/author_notes.d.ts} +10 -2
  46. package/dist/types/schema/nodes/equation.d.ts +3 -4
  47. package/dist/types/schema/nodes/equation_element.d.ts +1 -2
  48. package/dist/types/schema/nodes/inline_equation.d.ts +4 -3
  49. package/dist/types/schema/nodes/table.d.ts +5 -12
  50. package/dist/types/schema/types.d.ts +1 -1
  51. package/dist/types/transformer/builders.d.ts +3 -3
  52. package/dist/types/transformer/decode.d.ts +1 -0
  53. package/package.json +5 -5
  54. package/dist/cjs/mathjax/index.js +0 -41
  55. package/dist/cjs/mathjax/mathml-to-svg.js +0 -70
  56. package/dist/cjs/mathjax/tex-to-mathml.js +0 -49
  57. package/dist/cjs/mathjax/tex-to-svg.js +0 -59
  58. package/dist/cjs/schema/nodes/table_row.js +0 -123
  59. package/dist/es/mathjax/index.js +0 -12
  60. package/dist/es/mathjax/mathml-to-svg.js +0 -66
  61. package/dist/es/mathjax/tex-to-mathml.js +0 -45
  62. package/dist/es/mathjax/tex-to-svg.js +0 -55
  63. package/dist/es/schema/nodes/table_row.js +0 -120
  64. package/dist/types/mathjax/index.d.ts +0 -3
  65. package/dist/types/mathjax/mathml-to-svg.d.ts +0 -17
  66. package/dist/types/mathjax/tex-to-mathml.d.ts +0 -17
  67. package/dist/types/mathjax/tex-to-svg.d.ts +0 -17
  68. package/dist/types/schema/nodes/table_row.d.ts +0 -41
@@ -19,6 +19,7 @@ import { abstracts } from './nodes/abstracts';
19
19
  import { affiliation } from './nodes/affiliation';
20
20
  import { affiliations } from './nodes/affiliations';
21
21
  import { attribution } from './nodes/attribution';
22
+ import { authorNotes } from './nodes/author_notes';
22
23
  import { backmatter } from './nodes/backmatter';
23
24
  import { bibliographyElement } from './nodes/bibliography_element';
24
25
  import { bibliographyItem } from './nodes/bibliography_item';
@@ -66,11 +67,10 @@ import { sectionLabel } from './nodes/section_label';
66
67
  import { sectionTitle } from './nodes/section_title';
67
68
  import { supplement } from './nodes/supplement';
68
69
  import { supplements } from './nodes/supplements';
69
- import { table, tableBody } from './nodes/table';
70
+ import { table, tableCell, tableHeader, tableRow } from './nodes/table';
70
71
  import { tableCol, tableColGroup } from './nodes/table_col';
71
72
  import { tableElement } from './nodes/table_element';
72
73
  import { tableElementFooter } from './nodes/table_element_footer';
73
- import { tableCell, tableRow } from './nodes/table_row';
74
74
  import { text } from './nodes/text';
75
75
  import { title } from './nodes/title';
76
76
  import { tocElement } from './nodes/toc_element';
@@ -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';
@@ -120,7 +119,6 @@ export * from './nodes/section_title';
120
119
  export * from './nodes/table';
121
120
  export * from './nodes/table_col';
122
121
  export * from './nodes/table_element';
123
- export * from './nodes/table_row';
124
122
  export * from './nodes/text';
125
123
  export * from './nodes/toc_element';
126
124
  export * from './nodes/toc_section';
@@ -196,12 +194,12 @@ export const schema = new Schema({
196
194
  section_title: sectionTitle,
197
195
  section_title_plain: sectionTitle,
198
196
  table,
199
- table_body: tableBody,
200
197
  table_cell: tableCell,
201
198
  table_element: tableElement,
202
199
  table_row: tableRow,
203
200
  table_col: tableCol,
204
201
  table_colgroup: tableColGroup,
202
+ table_header: tableHeader,
205
203
  text,
206
204
  toc_element: tocElement,
207
205
  toc_section: tocSection,
@@ -213,5 +211,6 @@ export const schema = new Schema({
213
211
  contributors,
214
212
  supplements,
215
213
  supplement,
214
+ author_notes: authorNotes,
216
215
  },
217
216
  });
@@ -13,4 +13,12 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- export declare const packages: string[];
16
+ export const authorNotes = {
17
+ attrs: {
18
+ id: { default: '' },
19
+ dataTracked: { default: null },
20
+ },
21
+ content: '(footnote | paragraph)+',
22
+ group: 'block element',
23
+ toDOM: () => ['author-notes', 0],
24
+ };
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  export const contributors = {
17
- content: 'contributor*',
17
+ content: 'contributor* author_notes?',
18
18
  attrs: {
19
19
  id: { default: '' },
20
20
  },
@@ -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
  };
@@ -13,19 +13,56 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ import { tableNodes as createTableNodes, } from 'prosemirror-tables';
17
+ function createCellAttribute(attributeName, defaultValue = null, customGetFromDOM, customSetDOMAttr) {
18
+ return {
19
+ default: defaultValue,
20
+ getFromDOM(dom) {
21
+ if (customGetFromDOM) {
22
+ return customGetFromDOM(dom);
23
+ }
24
+ return dom.getAttribute(attributeName);
25
+ },
26
+ setDOMAttr(value, attrs) {
27
+ if (customSetDOMAttr) {
28
+ customSetDOMAttr(value, attrs);
29
+ }
30
+ else if (value) {
31
+ attrs[attributeName] = value;
32
+ }
33
+ },
34
+ };
35
+ }
36
+ const tableOptions = {
37
+ cellContent: 'inline*',
38
+ cellAttributes: {
39
+ placeholder: createCellAttribute('data-placeholder-text', 'Data', (dom) => dom.getAttribute('data-placeholder-text') || ''),
40
+ valign: createCellAttribute('valign'),
41
+ align: createCellAttribute('align'),
42
+ scope: createCellAttribute('scope'),
43
+ style: createCellAttribute('style'),
44
+ colspan: createCellAttribute('colspan', 1, (dom) => Number(dom.getAttribute('colspan') || 1), (value, attrs) => {
45
+ if (value && value !== 1) {
46
+ attrs['colspan'] = String(value);
47
+ }
48
+ }),
49
+ rowspan: createCellAttribute('rowspan', 1, (dom) => Number(dom.getAttribute('rowspan') || 1), (value, attrs) => {
50
+ if (value && value !== 1) {
51
+ attrs['rowspan'] = String(value);
52
+ }
53
+ }),
54
+ },
55
+ };
56
+ const tableNodes = createTableNodes(tableOptions);
16
57
  export const table = {
17
- content: 'table_colgroup? table_body',
18
- tableRole: 'table',
19
- isolating: true,
20
- group: 'block',
21
- selectable: false,
22
58
  attrs: {
23
59
  id: { default: '' },
24
- headerRows: { default: 1 },
25
- footerRows: { default: 1 },
26
60
  dataTracked: { default: null },
27
- comments: { default: null },
28
61
  },
62
+ content: 'table_row+',
63
+ tableRole: 'table',
64
+ isolating: true,
65
+ group: 'block',
29
66
  parseDOM: [
30
67
  {
31
68
  tag: 'table',
@@ -33,35 +70,20 @@ export const table = {
33
70
  const dom = p;
34
71
  return {
35
72
  id: dom.getAttribute('id'),
36
- headerRows: dom.dataset && dom.dataset['header-rows'],
37
- footerRows: dom.dataset && dom.dataset['footer-rows'],
38
73
  };
39
74
  },
40
75
  },
41
76
  ],
42
- toDOM: (node) => {
43
- const tableNode = node;
77
+ toDOM(node) {
44
78
  return [
45
79
  'table',
46
80
  {
47
- id: tableNode.attrs.id,
48
- 'data-header-rows': String(node.attrs.headerRows),
49
- 'data-footer-rows': String(node.attrs.footerRows),
81
+ id: node.attrs.id,
50
82
  },
51
- 0,
83
+ ['tbody', 0],
52
84
  ];
53
85
  },
54
86
  };
55
- export const tableBody = {
56
- content: 'table_row+',
57
- group: 'block',
58
- tableRole: 'table',
59
- parseDOM: [
60
- {
61
- tag: 'tbody',
62
- },
63
- ],
64
- toDOM() {
65
- return ['tbody', 0];
66
- },
67
- };
87
+ export const tableRow = Object.assign(Object.assign({}, tableNodes.table_row), { attrs: Object.assign(Object.assign({}, tableNodes.table_row.attrs), { dataTracked: { default: null } }) });
88
+ export const tableCell = Object.assign(Object.assign({}, tableNodes.table_cell), { attrs: Object.assign(Object.assign({}, tableNodes.table_cell.attrs), { dataTracked: { default: null } }) });
89
+ export const tableHeader = Object.assign(Object.assign({}, tableNodes.table_header), { attrs: Object.assign(Object.assign({}, tableNodes.table_header.attrs), { dataTracked: { default: null } }) });
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  export const tableElement = {
17
- content: '(table | placeholder) table_element_footer? figcaption? (listing | placeholder)',
17
+ content: '(table | placeholder) table_colgroup? table_element_footer? figcaption? (listing | placeholder)',
18
18
  attrs: {
19
19
  id: { default: '' },
20
20
  paragraphStyle: { default: '' },
@@ -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,6 +102,11 @@ export const buildFootnote = (containingObject, contents, kind = 'footnote') =>
108
102
  contents,
109
103
  kind,
110
104
  });
105
+ export const buildAuthorNotes = (containedObjectIDs) => ({
106
+ _id: generateID(ObjectTypes.AuthorNotes),
107
+ objectType: ObjectTypes.AuthorNotes,
108
+ containedObjectIDs: containedObjectIDs,
109
+ });
111
110
  export const buildFootnotesOrder = (footnotesList, containedObjectID) => ({
112
111
  _id: generateID(ObjectTypes.FootnotesOrder),
113
112
  objectType: ObjectTypes.FootnotesOrder,
@@ -128,13 +127,12 @@ export const buildSection = (priority = 0, path = []) => {
128
127
  path: path.concat(id),
129
128
  };
130
129
  };
131
- export const buildParagraph = (placeholderInnerHTML) => {
130
+ export const buildParagraph = (innerHTML = '') => {
132
131
  const _id = generateID(ObjectTypes.ParagraphElement);
133
- const element = document.createElementNS('http://www.w3.org/1999/xhtml', 'p');
132
+ const element = document.createElementNS(null, 'p');
134
133
  element.setAttribute('id', _id);
135
- element.setAttribute('class', 'MPElement');
136
- if (placeholderInnerHTML) {
137
- element.setAttribute('data-placeholder-text', placeholderInnerHTML);
134
+ if (innerHTML) {
135
+ element.innerHTML = innerHTML;
138
136
  }
139
137
  const contents = serializeToXML(element);
140
138
  return {
@@ -142,7 +140,6 @@ export const buildParagraph = (placeholderInnerHTML) => {
142
140
  objectType: ObjectTypes.ParagraphElement,
143
141
  elementType: 'p',
144
142
  contents,
145
- placeholderInnerHTML,
146
143
  };
147
144
  };
148
145
  export const buildColor = (value, priority) => ({
@@ -53,6 +53,7 @@ export const getModelsByType = (modelMap, objectType) => {
53
53
  export const sortSectionsByPriority = (a, b) => a.priority === b.priority ? 0 : Number(a.priority) - Number(b.priority);
54
54
  const getSections = (modelMap) => getModelsByType(modelMap, ObjectTypes.Section).sort(sortSectionsByPriority);
55
55
  const getAffiliations = (modelMap) => getModelsByType(modelMap, ObjectTypes.Affiliation);
56
+ const getAuthorNotes = (modelMap) => getModelsByType(modelMap, ObjectTypes.AuthorNotes);
56
57
  const getContributors = (modelMap) => getModelsByType(modelMap, ObjectTypes.Contributor);
57
58
  const getKeywordElements = (modelMap) => getModelsByType(modelMap, ObjectTypes.KeywordsElement);
58
59
  const getSupplements = (modelMap) => getModelsByType(modelMap, ObjectTypes.Supplement);
@@ -82,7 +83,11 @@ export class Decoder {
82
83
  const contributors = getContributors(this.modelMap)
83
84
  .map((c) => this.decode(c))
84
85
  .filter(Boolean);
85
- return schema.nodes.contributors.createAndFill({}, contributors);
86
+ const authorNotes = getAuthorNotes(this.modelMap)
87
+ .map((authorNote) => this.decode(authorNote))
88
+ .filter(Boolean);
89
+ const content = [...contributors, ...authorNotes];
90
+ return schema.nodes.contributors.createAndFill({}, content);
86
91
  }
87
92
  createKeywordsNode() {
88
93
  const elements = getKeywordElements(this.modelMap)
@@ -271,9 +276,8 @@ export class Decoder {
271
276
  const model = data;
272
277
  return schema.nodes.equation.createChecked({
273
278
  id: model._id,
274
- MathMLStringRepresentation: model.MathMLStringRepresentation,
275
- SVGStringRepresentation: model.SVGStringRepresentation,
276
- TeXRepresentation: model.TeXRepresentation,
279
+ contents: model.contents,
280
+ format: model.format,
277
281
  });
278
282
  },
279
283
  [ObjectTypes.EquationElement]: (data) => {
@@ -292,12 +296,10 @@ export class Decoder {
292
296
  else {
293
297
  throw new MissingElement(model.containedObjectID);
294
298
  }
295
- const figcaption = this.getFigcaption(model);
296
299
  return schema.nodes.equation_element.createChecked({
297
300
  id: model._id,
298
- suppressCaption: Boolean(model.suppressCaption),
299
- suppressTitle: Boolean(model.suppressTitle === undefined ? true : model.suppressTitle),
300
- }, [equation, figcaption]);
301
+ label: model.label,
302
+ }, [equation]);
301
303
  },
302
304
  [ObjectTypes.FootnotesElement]: (data) => {
303
305
  const foonotesElementModel = data;
@@ -483,6 +485,13 @@ export class Decoder {
483
485
  id: model._id,
484
486
  }, content);
485
487
  },
488
+ [ObjectTypes.AuthorNotes]: (data) => {
489
+ const model = data;
490
+ const content = model.containedObjectIDs.map((id) => this.decode(this.modelMap.get(id)));
491
+ return schema.nodes.author_notes.create({
492
+ id: model._id,
493
+ }, content);
494
+ },
486
495
  [ObjectTypes.Section]: (data) => {
487
496
  const model = data;
488
497
  const elements = [];
@@ -549,33 +558,32 @@ export class Decoder {
549
558
  },
550
559
  [ObjectTypes.Table]: (data) => {
551
560
  const model = data;
552
- const comments = this.createCommentNodes(model);
553
- comments.forEach((c) => this.comments.set(c.attrs.id, c));
554
- return this.parseContents(model.contents, undefined, this.getComments(model), {
561
+ return this.parseContents(model.contents, undefined, [], {
555
562
  topNode: schema.nodes.table.create({
556
563
  id: model._id,
557
- comments: comments.map((c) => c.attrs.id),
558
564
  }),
559
565
  });
560
566
  },
561
567
  [ObjectTypes.TableElement]: (data) => {
562
568
  const model = data;
563
569
  const table = this.createTable(model);
570
+ const tableColGroup = this.createTableColGroup(model);
564
571
  const tableElementFooter = this.createTableElementFooter(model);
565
572
  const figcaption = this.getFigcaption(model);
566
573
  const comments = this.createCommentNodes(model);
567
574
  comments.forEach((c) => this.comments.set(c.attrs.id, c));
568
- const content = tableElementFooter
569
- ? [table, tableElementFooter, figcaption]
570
- : [table, figcaption];
571
- if (model.listingID) {
572
- const listing = this.createListing(model.listingID);
573
- content.push(listing);
575
+ const content = [table];
576
+ if (tableColGroup) {
577
+ content.push(tableColGroup);
574
578
  }
575
- else {
576
- const listing = schema.nodes.listing.create();
577
- content.push(listing);
579
+ if (tableElementFooter) {
580
+ content.push(tableElementFooter);
578
581
  }
582
+ content.push(figcaption);
583
+ const listing = model.listingID
584
+ ? this.createListing(model.listingID)
585
+ : schema.nodes.listing.create();
586
+ content.push(listing);
579
587
  return schema.nodes.table_element.createChecked({
580
588
  id: model._id,
581
589
  table: model.containedObjectID,
@@ -764,23 +772,33 @@ export class Decoder {
764
772
  this.allowMissingElements = allowMissingElements;
765
773
  }
766
774
  createTable(model) {
767
- const tableId = model.containedObjectID;
768
- const tableModel = this.getModel(tableId);
775
+ const tableID = model.containedObjectID;
776
+ const tableModel = this.getModel(tableID);
769
777
  let table;
770
778
  if (tableModel) {
771
779
  table = this.decode(tableModel);
772
780
  }
773
781
  else if (this.allowMissingElements) {
774
782
  table = schema.nodes.placeholder.create({
775
- id: tableId,
783
+ id: tableID,
776
784
  label: 'A table',
777
785
  });
778
786
  }
779
787
  else {
780
- throw new MissingElement(tableId);
788
+ throw new MissingElement(tableID);
781
789
  }
782
790
  return table;
783
791
  }
792
+ createTableColGroup(model) {
793
+ const tableID = model.containedObjectID;
794
+ const tableModel = this.getModel(tableID);
795
+ if (!tableModel || !tableModel.contents.includes('<colgroup>')) {
796
+ return undefined;
797
+ }
798
+ return this.parseContents(tableModel.contents, undefined, [], {
799
+ topNode: schema.nodes.table_colgroup.create(),
800
+ });
801
+ }
784
802
  createTableElementFooter(model) {
785
803
  const tableElementFooterID = model.tableElementFooterID;
786
804
  if (!tableElementFooterID) {
@@ -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':
@@ -107,8 +101,9 @@ function buildTableColGroup(cols) {
107
101
  }
108
102
  const tableContents = (node, parent) => {
109
103
  const input = serializer.serializeNode(node);
104
+ const parentInput = serializer.serializeNode(parent);
110
105
  const output = document.createElement('table');
111
- const colgroup = buildTableColGroup(Array.from(input.querySelectorAll('col')));
106
+ const colgroup = buildTableColGroup(Array.from(parentInput.querySelectorAll('col')));
112
107
  if (colgroup) {
113
108
  output.appendChild(colgroup);
114
109
  }
@@ -345,20 +340,13 @@ const encoders = {
345
340
  : false,
346
341
  }),
347
342
  equation: (node) => ({
348
- MathMLStringRepresentation: node.attrs.MathMLStringRepresentation || undefined,
349
- TeXRepresentation: node.attrs.TeXRepresentation,
350
- SVGStringRepresentation: node.attrs.SVGStringRepresentation,
343
+ contents: node.attrs.contents,
344
+ format: node.attrs.format,
351
345
  }),
352
346
  equation_element: (node) => ({
353
347
  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,
348
+ elementType: 'div',
349
+ label: node.attrs.label,
362
350
  }),
363
351
  figure: (node) => ({
364
352
  contentType: node.attrs.contentType || undefined,
@@ -387,6 +375,9 @@ const encoders = {
387
375
  table_element_footer: (node) => ({
388
376
  containedObjectIDs: containedObjectIDs(node),
389
377
  }),
378
+ author_notes: (node) => ({
379
+ containedObjectIDs: containedObjectIDs(node),
380
+ }),
390
381
  footnotes_section: (node, parent, path, priority) => ({
391
382
  category: buildSectionCategory(node),
392
383
  priority: priority.value++,
@@ -405,12 +396,6 @@ const encoders = {
405
396
  .map((childNode) => childNode.attrs.id)
406
397
  .filter((id) => id),
407
398
  }),
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
399
  keyword: (node, parent) => ({
415
400
  containedGroup: parent.attrs.id,
416
401
  name: keywordContents(node),
@@ -583,8 +568,7 @@ export const encode = (node) => {
583
568
  if (placeholderTypes.includes(child.type)) {
584
569
  return;
585
570
  }
586
- if (parent.type === schema.nodes.paragraph &&
587
- child.type !== schema.nodes.inline_equation) {
571
+ if (parent.type === schema.nodes.paragraph) {
588
572
  return;
589
573
  }
590
574
  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],
@@ -59,6 +58,8 @@ export const nodeTypesMap = new Map([
59
58
  [schema.nodes.affiliations, ObjectTypes.Section],
60
59
  [schema.nodes.title, ObjectTypes.Titles],
61
60
  [schema.nodes.supplement, ObjectTypes.Supplement],
61
+ [schema.nodes.author_notes, ObjectTypes.AuthorNotes],
62
+ [schema.nodes.corresp, ObjectTypes.Corresponding],
62
63
  ]);
63
64
  export const isExecutableNodeType = (type) => hasGroup(type, GROUP_EXECUTABLE);
64
65
  export const isElementNodeType = (type) => hasGroup(type, GROUP_ELEMENT);
@@ -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';