@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
@@ -15,6 +15,13 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.packages = void 0;
19
- const AllPackages_1 = require("mathjax-full/js/input/tex/AllPackages");
20
- exports.packages = AllPackages_1.AllPackages.filter((name) => name !== 'html' && name !== 'bussproofs');
18
+ exports.authorNotes = void 0;
19
+ exports.authorNotes = {
20
+ attrs: {
21
+ id: { default: '' },
22
+ dataTracked: { default: null },
23
+ },
24
+ content: '(footnote | paragraph)+',
25
+ group: 'block element',
26
+ toDOM: () => ['author-notes', 0],
27
+ };
@@ -17,7 +17,7 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.contributors = void 0;
19
19
  exports.contributors = {
20
- content: 'contributor*',
20
+ content: 'contributor* author_notes?',
21
21
  attrs: {
22
22
  id: { default: '' },
23
23
  },
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*!
3
- * © 2019 Atypon Systems LLC
3
+ * © 2023 Atypon Systems LLC
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * you may not use this file except in compliance with the License.
@@ -20,9 +20,8 @@ const json_schema_1 = require("@manuscripts/json-schema");
20
20
  exports.equation = {
21
21
  attrs: {
22
22
  id: { default: '' },
23
- MathMLStringRepresentation: { default: '' },
24
- SVGStringRepresentation: { default: '' },
25
- TeXRepresentation: { default: '' },
23
+ contents: { default: '' },
24
+ format: { default: '' },
26
25
  dataTracked: { default: null },
27
26
  },
28
27
  group: 'block',
@@ -30,26 +29,25 @@ exports.equation = {
30
29
  {
31
30
  tag: `div.${json_schema_1.ObjectTypes.Equation}`,
32
31
  getAttrs: (p) => {
33
- const dom = p;
32
+ const htmlEl = p;
34
33
  return {
35
- id: dom.getAttribute('id'),
36
- MathMLStringRepresentation: dom.getAttribute('data-mathml-string-representation'),
37
- SVGStringRepresentation: dom.innerHTML,
38
- TeXRepresentation: dom.getAttribute('data-tex-representation'),
34
+ id: htmlEl.getAttribute('id'),
35
+ format: htmlEl.getAttribute('data-equation-format'),
36
+ contents: htmlEl.innerHTML,
39
37
  };
40
38
  },
41
39
  },
42
40
  ],
43
41
  toDOM: (node) => {
44
42
  const equationNode = node;
43
+ const { id, contents, format } = equationNode.attrs;
45
44
  const dom = document.createElement('div');
46
- dom.setAttribute('id', equationNode.attrs.id);
47
45
  dom.classList.add(json_schema_1.ObjectTypes.Equation);
48
- if (equationNode.attrs.MathMLStringRepresentation) {
49
- dom.setAttribute('data-mathml-string-representation', equationNode.attrs.MathMLStringRepresentation);
46
+ dom.setAttribute('id', id);
47
+ if (format) {
48
+ dom.setAttribute('data-equation-format', format);
50
49
  }
51
- dom.setAttribute('data-tex-representation', equationNode.attrs.TeXRepresentation);
52
- dom.innerHTML = equationNode.attrs.SVGStringRepresentation;
50
+ dom.innerHTML = contents;
53
51
  return dom;
54
52
  },
55
53
  };
@@ -17,11 +17,10 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.equationElement = void 0;
19
19
  exports.equationElement = {
20
- content: '(equation | placeholder) figcaption',
20
+ content: '(equation | placeholder)',
21
21
  attrs: {
22
22
  id: { default: '' },
23
- suppressCaption: { default: true },
24
- suppressTitle: { default: undefined },
23
+ label: { default: '' },
25
24
  dataTracked: { default: null },
26
25
  comments: { default: null },
27
26
  },
@@ -29,7 +28,7 @@ exports.equationElement = {
29
28
  group: 'block element',
30
29
  parseDOM: [
31
30
  {
32
- tag: 'figure.equation',
31
+ tag: 'div.equation',
33
32
  getAttrs: (p) => {
34
33
  const dom = p;
35
34
  return {
@@ -41,7 +40,7 @@ exports.equationElement = {
41
40
  toDOM: (node) => {
42
41
  const equationElementNode = node;
43
42
  return [
44
- 'figure',
43
+ 'div',
45
44
  {
46
45
  class: 'equation',
47
46
  id: equationElementNode.attrs.id,
@@ -16,14 +16,13 @@
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.inlineEquation = void 0;
19
- const json_schema_1 = require("@manuscripts/json-schema");
20
19
  exports.inlineEquation = {
21
20
  attrs: {
22
- id: { default: '' },
23
- MathMLRepresentation: { default: '' },
24
- SVGRepresentation: { default: '' },
25
- TeXRepresentation: { default: '' },
26
21
  dataTracked: { default: null },
22
+ comments: { default: null },
23
+ id: { default: '' },
24
+ contents: { default: '' },
25
+ format: { default: '' },
27
26
  },
28
27
  atom: true,
29
28
  inline: true,
@@ -31,28 +30,27 @@ exports.inlineEquation = {
31
30
  group: 'inline',
32
31
  parseDOM: [
33
32
  {
34
- tag: `span.${json_schema_1.ObjectTypes.InlineMathFragment}`,
33
+ tag: `span.MPInlineMathFragment`,
35
34
  getAttrs: (p) => {
36
35
  const dom = p;
37
36
  return {
37
+ format: dom.getAttribute('data-equation-format'),
38
38
  id: dom.getAttribute('id'),
39
- MathMLRepresentation: dom.getAttribute('data-mathml-representation') || '',
40
- SVGRepresentation: dom.innerHTML || '',
41
- TeXRepresentation: dom.getAttribute('data-tex-representation') || '',
39
+ contents: dom.innerHTML,
42
40
  };
43
41
  },
44
42
  },
45
43
  ],
46
44
  toDOM: (node) => {
47
45
  const inlineEquationNode = node;
46
+ const { id, contents, format } = inlineEquationNode.attrs;
48
47
  const dom = document.createElement('span');
49
- dom.classList.add(json_schema_1.ObjectTypes.InlineMathFragment);
50
- dom.setAttribute('id', inlineEquationNode.attrs.id);
51
- dom.setAttribute('data-tex-representation', inlineEquationNode.attrs.TeXRepresentation);
52
- if (inlineEquationNode.attrs.MathMLRepresentation) {
53
- dom.setAttribute('data-mathml-representation', inlineEquationNode.attrs.MathMLRepresentation);
48
+ dom.setAttribute('id', id);
49
+ dom.classList.add('MPInlineMathFragment');
50
+ if (format) {
51
+ dom.setAttribute('data-equation-format', format);
54
52
  }
55
- dom.innerHTML = inlineEquationNode.attrs.SVGRepresentation;
53
+ dom.innerHTML = contents;
56
54
  return dom;
57
55
  },
58
56
  };
@@ -15,20 +15,57 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.tableBody = exports.table = void 0;
18
+ exports.tableHeader = exports.tableCell = exports.tableRow = exports.table = void 0;
19
+ const prosemirror_tables_1 = require("prosemirror-tables");
20
+ function createCellAttribute(attributeName, defaultValue = null, customGetFromDOM, customSetDOMAttr) {
21
+ return {
22
+ default: defaultValue,
23
+ getFromDOM(dom) {
24
+ if (customGetFromDOM) {
25
+ return customGetFromDOM(dom);
26
+ }
27
+ return dom.getAttribute(attributeName);
28
+ },
29
+ setDOMAttr(value, attrs) {
30
+ if (customSetDOMAttr) {
31
+ customSetDOMAttr(value, attrs);
32
+ }
33
+ else if (value) {
34
+ attrs[attributeName] = value;
35
+ }
36
+ },
37
+ };
38
+ }
39
+ const tableOptions = {
40
+ cellContent: 'inline*',
41
+ cellAttributes: {
42
+ placeholder: createCellAttribute('data-placeholder-text', 'Data', (dom) => dom.getAttribute('data-placeholder-text') || ''),
43
+ valign: createCellAttribute('valign'),
44
+ align: createCellAttribute('align'),
45
+ scope: createCellAttribute('scope'),
46
+ style: createCellAttribute('style'),
47
+ colspan: createCellAttribute('colspan', 1, (dom) => Number(dom.getAttribute('colspan') || 1), (value, attrs) => {
48
+ if (value && value !== 1) {
49
+ attrs['colspan'] = String(value);
50
+ }
51
+ }),
52
+ rowspan: createCellAttribute('rowspan', 1, (dom) => Number(dom.getAttribute('rowspan') || 1), (value, attrs) => {
53
+ if (value && value !== 1) {
54
+ attrs['rowspan'] = String(value);
55
+ }
56
+ }),
57
+ },
58
+ };
59
+ const tableNodes = (0, prosemirror_tables_1.tableNodes)(tableOptions);
19
60
  exports.table = {
20
- content: 'table_colgroup? table_body',
21
- tableRole: 'table',
22
- isolating: true,
23
- group: 'block',
24
- selectable: false,
25
61
  attrs: {
26
62
  id: { default: '' },
27
- headerRows: { default: 1 },
28
- footerRows: { default: 1 },
29
63
  dataTracked: { default: null },
30
- comments: { default: null },
31
64
  },
65
+ content: 'table_row+',
66
+ tableRole: 'table',
67
+ isolating: true,
68
+ group: 'block',
32
69
  parseDOM: [
33
70
  {
34
71
  tag: 'table',
@@ -36,35 +73,20 @@ exports.table = {
36
73
  const dom = p;
37
74
  return {
38
75
  id: dom.getAttribute('id'),
39
- headerRows: dom.dataset && dom.dataset['header-rows'],
40
- footerRows: dom.dataset && dom.dataset['footer-rows'],
41
76
  };
42
77
  },
43
78
  },
44
79
  ],
45
- toDOM: (node) => {
46
- const tableNode = node;
80
+ toDOM(node) {
47
81
  return [
48
82
  'table',
49
83
  {
50
- id: tableNode.attrs.id,
51
- 'data-header-rows': String(node.attrs.headerRows),
52
- 'data-footer-rows': String(node.attrs.footerRows),
84
+ id: node.attrs.id,
53
85
  },
54
- 0,
86
+ ['tbody', 0],
55
87
  ];
56
88
  },
57
89
  };
58
- exports.tableBody = {
59
- content: 'table_row+',
60
- group: 'block',
61
- tableRole: 'table',
62
- parseDOM: [
63
- {
64
- tag: 'tbody',
65
- },
66
- ],
67
- toDOM() {
68
- return ['tbody', 0];
69
- },
70
- };
90
+ exports.tableRow = Object.assign(Object.assign({}, tableNodes.table_row), { attrs: Object.assign(Object.assign({}, tableNodes.table_row.attrs), { dataTracked: { default: null } }) });
91
+ exports.tableCell = Object.assign(Object.assign({}, tableNodes.table_cell), { attrs: Object.assign(Object.assign({}, tableNodes.table_cell.attrs), { dataTracked: { default: null } }) });
92
+ exports.tableHeader = Object.assign(Object.assign({}, tableNodes.table_header), { attrs: Object.assign(Object.assign({}, tableNodes.table_header.attrs), { dataTracked: { default: null } }) });
@@ -17,7 +17,7 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.tableElement = void 0;
19
19
  exports.tableElement = {
20
- content: '(table | placeholder) table_element_footer? figcaption? (listing | placeholder)',
20
+ content: '(table | placeholder) table_colgroup? table_element_footer? figcaption? (listing | placeholder)',
21
21
  attrs: {
22
22
  id: { default: '' },
23
23
  paragraphStyle: { default: '' },
@@ -18,7 +18,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
18
18
  return (mod && mod.__esModule) ? mod : { "default": mod };
19
19
  };
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.buildTitles = exports.buildElementsOrder = exports.auxiliaryObjectTypes = exports.buildJournal = exports.buildAttribution = exports.buildContributorRole = exports.buildContribution = exports.buildColor = exports.buildParagraph = exports.buildSection = exports.buildCorresp = exports.buildFootnotesOrder = exports.buildFootnote = exports.buildInlineMathFragment = exports.buildNote = exports.buildComment = exports.buildSupplementaryMaterial = exports.buildAffiliation = exports.buildFigure = exports.buildKeywordGroup = exports.buildKeyword = exports.buildBibliographyElement = exports.buildBibliographicDate = exports.buildBibliographicName = exports.buildBibliographyItem = exports.buildContributor = exports.buildManuscript = exports.buildProject = void 0;
21
+ exports.buildTitles = exports.buildElementsOrder = exports.auxiliaryObjectTypes = exports.buildJournal = exports.buildAttribution = exports.buildContributorRole = exports.buildContribution = exports.buildColor = exports.buildParagraph = exports.buildSection = exports.buildCorresp = exports.buildFootnotesOrder = exports.buildAuthorNotes = exports.buildFootnote = exports.buildNote = exports.buildComment = exports.buildSupplementaryMaterial = exports.buildAffiliation = exports.buildFigure = exports.buildKeywordGroup = exports.buildKeyword = exports.buildBibliographyElement = exports.buildBibliographicDate = exports.buildBibliographicName = exports.buildBibliographyItem = exports.buildContributor = exports.buildManuscript = exports.buildProject = void 0;
22
22
  const json_schema_1 = require("@manuscripts/json-schema");
23
23
  const w3c_xmlserializer_1 = __importDefault(require("w3c-xmlserializer"));
24
24
  const schema_1 = require("../schema");
@@ -115,13 +115,6 @@ const buildNote = (target, source, contents = '') => ({
115
115
  contents,
116
116
  });
117
117
  exports.buildNote = buildNote;
118
- const buildInlineMathFragment = (containingObject, TeXRepresentation) => ({
119
- _id: (0, id_1.generateID)(json_schema_1.ObjectTypes.InlineMathFragment),
120
- objectType: json_schema_1.ObjectTypes.InlineMathFragment,
121
- containingObject: containingObject || undefined,
122
- TeXRepresentation,
123
- });
124
- exports.buildInlineMathFragment = buildInlineMathFragment;
125
118
  const buildFootnote = (containingObject, contents, kind = 'footnote') => ({
126
119
  _id: (0, id_1.generateID)(json_schema_1.ObjectTypes.Footnote),
127
120
  objectType: json_schema_1.ObjectTypes.Footnote,
@@ -130,6 +123,12 @@ const buildFootnote = (containingObject, contents, kind = 'footnote') => ({
130
123
  kind,
131
124
  });
132
125
  exports.buildFootnote = buildFootnote;
126
+ const buildAuthorNotes = (containedObjectIDs) => ({
127
+ _id: (0, id_1.generateID)(json_schema_1.ObjectTypes.AuthorNotes),
128
+ objectType: json_schema_1.ObjectTypes.AuthorNotes,
129
+ containedObjectIDs: containedObjectIDs,
130
+ });
131
+ exports.buildAuthorNotes = buildAuthorNotes;
133
132
  const buildFootnotesOrder = (footnotesList, containedObjectID) => ({
134
133
  _id: (0, id_1.generateID)(json_schema_1.ObjectTypes.FootnotesOrder),
135
134
  objectType: json_schema_1.ObjectTypes.FootnotesOrder,
@@ -153,13 +152,12 @@ const buildSection = (priority = 0, path = []) => {
153
152
  };
154
153
  };
155
154
  exports.buildSection = buildSection;
156
- const buildParagraph = (placeholderInnerHTML) => {
155
+ const buildParagraph = (innerHTML = '') => {
157
156
  const _id = (0, id_1.generateID)(json_schema_1.ObjectTypes.ParagraphElement);
158
- const element = document.createElementNS('http://www.w3.org/1999/xhtml', 'p');
157
+ const element = document.createElementNS(null, 'p');
159
158
  element.setAttribute('id', _id);
160
- element.setAttribute('class', 'MPElement');
161
- if (placeholderInnerHTML) {
162
- element.setAttribute('data-placeholder-text', placeholderInnerHTML);
159
+ if (innerHTML) {
160
+ element.innerHTML = innerHTML;
163
161
  }
164
162
  const contents = (0, w3c_xmlserializer_1.default)(element);
165
163
  return {
@@ -167,7 +165,6 @@ const buildParagraph = (placeholderInnerHTML) => {
167
165
  objectType: json_schema_1.ObjectTypes.ParagraphElement,
168
166
  elementType: 'p',
169
167
  contents,
170
- placeholderInnerHTML,
171
168
  };
172
169
  };
173
170
  exports.buildParagraph = buildParagraph;
@@ -62,6 +62,7 @@ const sortSectionsByPriority = (a, b) => a.priority === b.priority ? 0 : Number(
62
62
  exports.sortSectionsByPriority = sortSectionsByPriority;
63
63
  const getSections = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Section).sort(exports.sortSectionsByPriority);
64
64
  const getAffiliations = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Affiliation);
65
+ const getAuthorNotes = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.AuthorNotes);
65
66
  const getContributors = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Contributor);
66
67
  const getKeywordElements = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.KeywordsElement);
67
68
  const getSupplements = (modelMap) => (0, exports.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Supplement);
@@ -91,7 +92,11 @@ class Decoder {
91
92
  const contributors = getContributors(this.modelMap)
92
93
  .map((c) => this.decode(c))
93
94
  .filter(Boolean);
94
- return schema_1.schema.nodes.contributors.createAndFill({}, contributors);
95
+ const authorNotes = getAuthorNotes(this.modelMap)
96
+ .map((authorNote) => this.decode(authorNote))
97
+ .filter(Boolean);
98
+ const content = [...contributors, ...authorNotes];
99
+ return schema_1.schema.nodes.contributors.createAndFill({}, content);
95
100
  }
96
101
  createKeywordsNode() {
97
102
  const elements = getKeywordElements(this.modelMap)
@@ -280,9 +285,8 @@ class Decoder {
280
285
  const model = data;
281
286
  return schema_1.schema.nodes.equation.createChecked({
282
287
  id: model._id,
283
- MathMLStringRepresentation: model.MathMLStringRepresentation,
284
- SVGStringRepresentation: model.SVGStringRepresentation,
285
- TeXRepresentation: model.TeXRepresentation,
288
+ contents: model.contents,
289
+ format: model.format,
286
290
  });
287
291
  },
288
292
  [json_schema_1.ObjectTypes.EquationElement]: (data) => {
@@ -301,12 +305,10 @@ class Decoder {
301
305
  else {
302
306
  throw new errors_1.MissingElement(model.containedObjectID);
303
307
  }
304
- const figcaption = this.getFigcaption(model);
305
308
  return schema_1.schema.nodes.equation_element.createChecked({
306
309
  id: model._id,
307
- suppressCaption: Boolean(model.suppressCaption),
308
- suppressTitle: Boolean(model.suppressTitle === undefined ? true : model.suppressTitle),
309
- }, [equation, figcaption]);
310
+ label: model.label,
311
+ }, [equation]);
310
312
  },
311
313
  [json_schema_1.ObjectTypes.FootnotesElement]: (data) => {
312
314
  const foonotesElementModel = data;
@@ -492,6 +494,13 @@ class Decoder {
492
494
  id: model._id,
493
495
  }, content);
494
496
  },
497
+ [json_schema_1.ObjectTypes.AuthorNotes]: (data) => {
498
+ const model = data;
499
+ const content = model.containedObjectIDs.map((id) => this.decode(this.modelMap.get(id)));
500
+ return schema_1.schema.nodes.author_notes.create({
501
+ id: model._id,
502
+ }, content);
503
+ },
495
504
  [json_schema_1.ObjectTypes.Section]: (data) => {
496
505
  const model = data;
497
506
  const elements = [];
@@ -558,33 +567,32 @@ class Decoder {
558
567
  },
559
568
  [json_schema_1.ObjectTypes.Table]: (data) => {
560
569
  const model = data;
561
- const comments = this.createCommentNodes(model);
562
- comments.forEach((c) => this.comments.set(c.attrs.id, c));
563
- return this.parseContents(model.contents, undefined, this.getComments(model), {
570
+ return this.parseContents(model.contents, undefined, [], {
564
571
  topNode: schema_1.schema.nodes.table.create({
565
572
  id: model._id,
566
- comments: comments.map((c) => c.attrs.id),
567
573
  }),
568
574
  });
569
575
  },
570
576
  [json_schema_1.ObjectTypes.TableElement]: (data) => {
571
577
  const model = data;
572
578
  const table = this.createTable(model);
579
+ const tableColGroup = this.createTableColGroup(model);
573
580
  const tableElementFooter = this.createTableElementFooter(model);
574
581
  const figcaption = this.getFigcaption(model);
575
582
  const comments = this.createCommentNodes(model);
576
583
  comments.forEach((c) => this.comments.set(c.attrs.id, c));
577
- const content = tableElementFooter
578
- ? [table, tableElementFooter, figcaption]
579
- : [table, figcaption];
580
- if (model.listingID) {
581
- const listing = this.createListing(model.listingID);
582
- content.push(listing);
584
+ const content = [table];
585
+ if (tableColGroup) {
586
+ content.push(tableColGroup);
583
587
  }
584
- else {
585
- const listing = schema_1.schema.nodes.listing.create();
586
- content.push(listing);
588
+ if (tableElementFooter) {
589
+ content.push(tableElementFooter);
587
590
  }
591
+ content.push(figcaption);
592
+ const listing = model.listingID
593
+ ? this.createListing(model.listingID)
594
+ : schema_1.schema.nodes.listing.create();
595
+ content.push(listing);
588
596
  return schema_1.schema.nodes.table_element.createChecked({
589
597
  id: model._id,
590
598
  table: model.containedObjectID,
@@ -773,23 +781,33 @@ class Decoder {
773
781
  this.allowMissingElements = allowMissingElements;
774
782
  }
775
783
  createTable(model) {
776
- const tableId = model.containedObjectID;
777
- const tableModel = this.getModel(tableId);
784
+ const tableID = model.containedObjectID;
785
+ const tableModel = this.getModel(tableID);
778
786
  let table;
779
787
  if (tableModel) {
780
788
  table = this.decode(tableModel);
781
789
  }
782
790
  else if (this.allowMissingElements) {
783
791
  table = schema_1.schema.nodes.placeholder.create({
784
- id: tableId,
792
+ id: tableID,
785
793
  label: 'A table',
786
794
  });
787
795
  }
788
796
  else {
789
- throw new errors_1.MissingElement(tableId);
797
+ throw new errors_1.MissingElement(tableID);
790
798
  }
791
799
  return table;
792
800
  }
801
+ createTableColGroup(model) {
802
+ const tableID = model.containedObjectID;
803
+ const tableModel = this.getModel(tableID);
804
+ if (!tableModel || !tableModel.contents.includes('<colgroup>')) {
805
+ return undefined;
806
+ }
807
+ return this.parseContents(tableModel.contents, undefined, [], {
808
+ topNode: schema_1.schema.nodes.table_colgroup.create(),
809
+ });
810
+ }
793
811
  createTableElementFooter(model) {
794
812
  const tableElementFooterID = model.tableElementFooterID;
795
813
  if (!tableElementFooterID) {
@@ -62,12 +62,6 @@ const listContents = (node) => {
62
62
  }
63
63
  return (0, w3c_xmlserializer_1.default)(output);
64
64
  };
65
- const svgDefs = (svg) => {
66
- const template = document.createElement('template');
67
- template.innerHTML = svg.trim();
68
- const defs = template.content.querySelector('defs');
69
- return defs ? (0, w3c_xmlserializer_1.default)(defs) : undefined;
70
- };
71
65
  const tableRowDisplayStyle = (tagName, parent) => {
72
66
  switch (tagName) {
73
67
  case 'thead':
@@ -115,8 +109,9 @@ function buildTableColGroup(cols) {
115
109
  }
116
110
  const tableContents = (node, parent) => {
117
111
  const input = serializer.serializeNode(node);
112
+ const parentInput = serializer.serializeNode(parent);
118
113
  const output = document.createElement('table');
119
- const colgroup = buildTableColGroup(Array.from(input.querySelectorAll('col')));
114
+ const colgroup = buildTableColGroup(Array.from(parentInput.querySelectorAll('col')));
120
115
  if (colgroup) {
121
116
  output.appendChild(colgroup);
122
117
  }
@@ -353,20 +348,13 @@ const encoders = {
353
348
  : false,
354
349
  }),
355
350
  equation: (node) => ({
356
- MathMLStringRepresentation: node.attrs.MathMLStringRepresentation || undefined,
357
- TeXRepresentation: node.attrs.TeXRepresentation,
358
- SVGStringRepresentation: node.attrs.SVGStringRepresentation,
351
+ contents: node.attrs.contents,
352
+ format: node.attrs.format,
359
353
  }),
360
354
  equation_element: (node) => ({
361
355
  containedObjectID: attributeOfNodeType(node, 'equation', 'id'),
362
- caption: inlineContentOfChildNodeType(node, node.type.schema.nodes.figcaption, node.type.schema.nodes.caption),
363
- title: inlineContentOfChildNodeType(node, node.type.schema.nodes.figcaption, node.type.schema.nodes.caption_title, false),
364
- elementType: 'p',
365
- suppressCaption: Boolean(node.attrs.suppressCaption) || undefined,
366
- suppressTitle: node.attrs.suppressTitle === undefined ||
367
- node.attrs.suppressTitle === true
368
- ? undefined
369
- : false,
356
+ elementType: 'div',
357
+ label: node.attrs.label,
370
358
  }),
371
359
  figure: (node) => ({
372
360
  contentType: node.attrs.contentType || undefined,
@@ -395,6 +383,9 @@ const encoders = {
395
383
  table_element_footer: (node) => ({
396
384
  containedObjectIDs: containedObjectIDs(node),
397
385
  }),
386
+ author_notes: (node) => ({
387
+ containedObjectIDs: containedObjectIDs(node),
388
+ }),
398
389
  footnotes_section: (node, parent, path, priority) => ({
399
390
  category: (0, section_category_1.buildSectionCategory)(node),
400
391
  priority: priority.value++,
@@ -413,12 +404,6 @@ const encoders = {
413
404
  .map((childNode) => childNode.attrs.id)
414
405
  .filter((id) => id),
415
406
  }),
416
- inline_equation: (node, parent) => ({
417
- containingObject: parent.attrs.id,
418
- TeXRepresentation: node.attrs.TeXRepresentation,
419
- SVGRepresentation: node.attrs.SVGRepresentation,
420
- SVGGlyphs: svgDefs(node.attrs.SVGRepresentation),
421
- }),
422
407
  keyword: (node, parent) => ({
423
408
  containedGroup: parent.attrs.id,
424
409
  name: keywordContents(node),
@@ -592,8 +577,7 @@ const encode = (node) => {
592
577
  if (placeholderTypes.includes(child.type)) {
593
578
  return;
594
579
  }
595
- if (parent.type === schema_1.schema.nodes.paragraph &&
596
- child.type !== schema_1.schema.nodes.inline_equation) {
580
+ if (parent.type === schema_1.schema.nodes.paragraph) {
597
581
  return;
598
582
  }
599
583
  if (child.type === schema_1.schema.nodes.footnotes_element) {
@@ -39,7 +39,6 @@ exports.nodeTypesMap = new Map([
39
39
  [schema_1.schema.nodes.footnotes_section, json_schema_1.ObjectTypes.Section],
40
40
  [schema_1.schema.nodes.graphical_abstract_section, json_schema_1.ObjectTypes.Section],
41
41
  [schema_1.schema.nodes.highlight_marker, json_schema_1.ObjectTypes.HighlightMarker],
42
- [schema_1.schema.nodes.inline_equation, json_schema_1.ObjectTypes.InlineMathFragment],
43
42
  [schema_1.schema.nodes.keyword, json_schema_1.ObjectTypes.Keyword],
44
43
  [schema_1.schema.nodes.keywords_element, json_schema_1.ObjectTypes.KeywordsElement],
45
44
  [schema_1.schema.nodes.keywords, json_schema_1.ObjectTypes.Section],
@@ -62,6 +61,8 @@ exports.nodeTypesMap = new Map([
62
61
  [schema_1.schema.nodes.affiliations, json_schema_1.ObjectTypes.Section],
63
62
  [schema_1.schema.nodes.title, json_schema_1.ObjectTypes.Titles],
64
63
  [schema_1.schema.nodes.supplement, json_schema_1.ObjectTypes.Supplement],
64
+ [schema_1.schema.nodes.author_notes, json_schema_1.ObjectTypes.AuthorNotes],
65
+ [schema_1.schema.nodes.corresp, json_schema_1.ObjectTypes.Corresponding],
65
66
  ]);
66
67
  const isExecutableNodeType = (type) => (0, schema_1.hasGroup)(type, schema_1.GROUP_EXECUTABLE);
67
68
  exports.isExecutableNodeType = isExecutableNodeType;
@@ -38,7 +38,6 @@ exports.manuscriptObjects = [
38
38
  json_schema_1.ObjectTypes.CommentAnnotation,
39
39
  json_schema_1.ObjectTypes.Contributor,
40
40
  json_schema_1.ObjectTypes.Footnote,
41
- json_schema_1.ObjectTypes.InlineMathFragment,
42
41
  json_schema_1.ObjectTypes.Section,
43
42
  ].concat(exports.elementObjects);
44
43
  const isManuscriptModel = (model) => {
package/dist/es/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  export * from './lib/section-group-type';
2
2
  export * from './lib/table-cell-styles';
3
3
  export * from './lib/utils';
4
- export * from './mathjax';
5
4
  export * from './schema';
6
5
  export * from './transformer';
7
6
  export * from './jats';