@manuscripts/transform 2.0.3 → 2.0.4-LEAN-3093
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.
- package/dist/cjs/index.js +0 -1
- package/dist/cjs/jats/importer/jats-body-dom-parser.js +24 -72
- package/dist/cjs/jats/importer/jats-body-transformations.js +0 -8
- package/dist/cjs/jats/importer/parse-jats-article.js +0 -1
- package/dist/cjs/jats/jats-exporter.js +17 -37
- package/dist/cjs/schema/index.js +0 -1
- package/dist/cjs/schema/nodes/equation.js +12 -14
- package/dist/cjs/schema/nodes/equation_element.js +4 -5
- package/dist/cjs/schema/nodes/inline_equation.js +12 -16
- package/dist/cjs/schema/nodes/table_element.js +1 -1
- package/dist/cjs/transformer/builders.js +1 -8
- package/dist/cjs/transformer/decode.js +5 -8
- package/dist/cjs/transformer/encode.js +4 -25
- package/dist/cjs/transformer/node-types.js +0 -1
- package/dist/cjs/transformer/object-types.js +0 -1
- package/dist/es/index.js +0 -1
- package/dist/es/jats/importer/jats-body-dom-parser.js +25 -73
- package/dist/es/jats/importer/jats-body-transformations.js +0 -8
- package/dist/es/jats/importer/parse-jats-article.js +0 -1
- package/dist/es/jats/jats-exporter.js +17 -37
- package/dist/es/schema/index.js +0 -1
- package/dist/es/schema/nodes/equation.js +12 -14
- package/dist/es/schema/nodes/equation_element.js +4 -5
- package/dist/es/schema/nodes/inline_equation.js +12 -16
- package/dist/es/schema/nodes/table_element.js +1 -1
- package/dist/es/transformer/builders.js +0 -6
- package/dist/es/transformer/decode.js +5 -8
- package/dist/es/transformer/encode.js +4 -25
- package/dist/es/transformer/node-types.js +0 -1
- package/dist/es/transformer/object-types.js +0 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/jats/importer/jats-body-transformations.d.ts +0 -1
- package/dist/types/schema/index.d.ts +0 -1
- package/dist/types/schema/nodes/equation.d.ts +3 -4
- package/dist/types/schema/nodes/equation_element.d.ts +1 -2
- package/dist/types/schema/nodes/inline_equation.d.ts +4 -4
- package/dist/types/transformer/builders.d.ts +1 -2
- package/package.json +4 -5
- package/dist/cjs/mathjax/index.js +0 -41
- package/dist/cjs/mathjax/mathjax-packages.js +0 -20
- package/dist/cjs/mathjax/mathml-to-svg.js +0 -70
- package/dist/cjs/mathjax/tex-to-mathml.js +0 -49
- package/dist/cjs/mathjax/tex-to-svg.js +0 -59
- package/dist/es/mathjax/index.js +0 -12
- package/dist/es/mathjax/mathjax-packages.js +0 -17
- package/dist/es/mathjax/mathml-to-svg.js +0 -66
- package/dist/es/mathjax/tex-to-mathml.js +0 -45
- package/dist/es/mathjax/tex-to-svg.js +0 -55
- package/dist/types/mathjax/index.d.ts +0 -3
- package/dist/types/mathjax/mathjax-packages.d.ts +0 -16
- package/dist/types/mathjax/mathml-to-svg.d.ts +0 -17
- package/dist/types/mathjax/tex-to-mathml.d.ts +0 -17
- 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
|
|
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,24 @@ const chooseContentType = (graphicNode) => {
|
|
|
33
31
|
}
|
|
34
32
|
}
|
|
35
33
|
};
|
|
34
|
+
const getEquationContent = (p) => {
|
|
35
|
+
var _a;
|
|
36
|
+
const element = p;
|
|
37
|
+
const container = (_a = element.querySelector('alternatives')) !== null && _a !== void 0 ? _a : element;
|
|
38
|
+
let contents = '';
|
|
39
|
+
let format = '';
|
|
40
|
+
for (const child of container.childNodes) {
|
|
41
|
+
const nodeName = child.nodeName.replace(/^[a-z]:/, '');
|
|
42
|
+
switch (nodeName) {
|
|
43
|
+
case 'tex-math':
|
|
44
|
+
case 'mml:math':
|
|
45
|
+
contents = child.outerHTML;
|
|
46
|
+
format = nodeName === 'tex-math' ? 'tex' : 'mathml';
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return { format, contents };
|
|
51
|
+
};
|
|
36
52
|
const marks = [
|
|
37
53
|
{
|
|
38
54
|
tag: 'bold',
|
|
@@ -141,91 +157,27 @@ const nodes = [
|
|
|
141
157
|
tag: 'inline-formula',
|
|
142
158
|
node: 'inline_equation',
|
|
143
159
|
getAttrs: (node) => {
|
|
144
|
-
var _a, _b, _c, _d, _e;
|
|
145
160
|
const element = node;
|
|
146
|
-
|
|
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;
|
|
161
|
+
return getEquationContent(element);
|
|
175
162
|
},
|
|
176
163
|
},
|
|
177
164
|
{
|
|
178
165
|
tag: 'disp-formula',
|
|
179
166
|
node: 'equation_element',
|
|
180
167
|
getAttrs: (node) => {
|
|
168
|
+
var _a, _b;
|
|
181
169
|
const element = node;
|
|
182
|
-
const caption = element.querySelector('figcaption');
|
|
183
170
|
return {
|
|
184
171
|
id: element.getAttribute('id'),
|
|
185
|
-
|
|
172
|
+
label: (_b = (_a = element.querySelector('label')) === null || _a === void 0 ? void 0 : _a.textContent) !== null && _b !== void 0 ? _b : '',
|
|
186
173
|
};
|
|
187
174
|
},
|
|
188
175
|
getContent: (node, schema) => {
|
|
189
|
-
var _a, _b, _c, _d, _e;
|
|
190
176
|
const element = node;
|
|
191
|
-
const attrs =
|
|
192
|
-
|
|
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();
|
|
177
|
+
const attrs = getEquationContent(element);
|
|
178
|
+
const id = element.getAttribute('id');
|
|
221
179
|
return Fragment.from([
|
|
222
|
-
schema.nodes.equation.createChecked(attrs),
|
|
223
|
-
caption
|
|
224
|
-
?
|
|
225
|
-
jatsBodyDOMParser.parse(caption, {
|
|
226
|
-
topNode: figcaption,
|
|
227
|
-
})
|
|
228
|
-
: figcaption,
|
|
180
|
+
schema.nodes.equation.createChecked(Object.assign({ id }, attrs)),
|
|
229
181
|
]);
|
|
230
182
|
},
|
|
231
183
|
},
|
|
@@ -262,14 +262,6 @@ export const jatsBodyTransformations = {
|
|
|
262
262
|
}
|
|
263
263
|
});
|
|
264
264
|
},
|
|
265
|
-
moveTableFooterToEnd(body) {
|
|
266
|
-
const footers = body.querySelectorAll('table-wrap-foot');
|
|
267
|
-
for (const footer of footers) {
|
|
268
|
-
if (footer.parentNode) {
|
|
269
|
-
footer.parentNode.appendChild(footer);
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
},
|
|
273
265
|
moveFloatsGroupToBody(doc, body, createElement) {
|
|
274
266
|
const group = doc.querySelector('floats-group');
|
|
275
267
|
if (group) {
|
|
@@ -62,7 +62,6 @@ export const parseJATSBody = (doc, body, references) => {
|
|
|
62
62
|
jatsBodyTransformations.ensureSection(body, createElement);
|
|
63
63
|
jatsBodyTransformations.moveCaptionsToEnd(body);
|
|
64
64
|
jatsBodyTransformations.fixTables(body, createElement);
|
|
65
|
-
jatsBodyTransformations.moveTableFooterToEnd(body);
|
|
66
65
|
jatsBodyTransformations.createBody(doc, body, createElement);
|
|
67
66
|
jatsBodyTransformations.createAbstracts(doc, body, createElement);
|
|
68
67
|
jatsBodyTransformations.createBackmatter(doc, body, createElement);
|
|
@@ -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
|
}
|
|
@@ -676,22 +677,23 @@ export class JATSExporter {
|
|
|
676
677
|
},
|
|
677
678
|
doc: () => '',
|
|
678
679
|
equation: (node) => {
|
|
679
|
-
const
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
680
|
+
const math = this.nodeFromJATS(node.attrs.contents);
|
|
681
|
+
const mathEl = math;
|
|
682
|
+
mathEl.setAttribute('id', normalizeID(node.attrs.id));
|
|
683
|
+
return mathEl;
|
|
684
|
+
},
|
|
685
|
+
inline_equation: (node) => {
|
|
686
|
+
const eqElement = this.document.createElement('inline-formula');
|
|
687
|
+
const math = this.nodeFromJATS(node.attrs.contents);
|
|
688
|
+
eqElement.append(math);
|
|
689
|
+
return eqElement;
|
|
690
|
+
},
|
|
691
|
+
equation_element: (node) => {
|
|
692
|
+
const eqElement = this.document.createElement('disp-formula');
|
|
693
|
+
eqElement.setAttribute('id', normalizeID(node.attrs.id));
|
|
694
|
+
processChildNodes(eqElement, node, schema.nodes.equation);
|
|
695
|
+
return eqElement;
|
|
693
696
|
},
|
|
694
|
-
equation_element: (node) => createFigureElement(node, 'fig', node.type.schema.nodes.equation, 'equation'),
|
|
695
697
|
figcaption: (node) => {
|
|
696
698
|
if (!node.textContent) {
|
|
697
699
|
return '';
|
|
@@ -741,28 +743,6 @@ export class JATSExporter {
|
|
|
741
743
|
},
|
|
742
744
|
hard_break: () => '',
|
|
743
745
|
highlight_marker: () => '',
|
|
744
|
-
inline_equation: (node) => {
|
|
745
|
-
const formula = this.document.createElement('inline-formula');
|
|
746
|
-
formula.setAttribute('id', normalizeID(node.attrs.id));
|
|
747
|
-
if (node.attrs.TeXRepresentation) {
|
|
748
|
-
const math = this.document.createElement('tex-math');
|
|
749
|
-
math.textContent = node.attrs.TeXRepresentation;
|
|
750
|
-
formula.appendChild(math);
|
|
751
|
-
}
|
|
752
|
-
else if (node.attrs.MathMLRepresentation) {
|
|
753
|
-
const math = this.nodeFromJATS(node.attrs.MathMLRepresentation);
|
|
754
|
-
if (math) {
|
|
755
|
-
formula.appendChild(math);
|
|
756
|
-
}
|
|
757
|
-
}
|
|
758
|
-
else if (node.attrs.SVGRepresentation) {
|
|
759
|
-
const math = this.nodeFromJATS(node.attrs.SVGRepresentation);
|
|
760
|
-
if (math) {
|
|
761
|
-
formula.appendChild(math);
|
|
762
|
-
}
|
|
763
|
-
}
|
|
764
|
-
return formula;
|
|
765
|
-
},
|
|
766
746
|
inline_footnote: (node) => {
|
|
767
747
|
const xref = this.document.createElement('xref');
|
|
768
748
|
xref.setAttribute('ref-type', 'fn');
|
package/dist/es/schema/index.js
CHANGED
|
@@ -98,7 +98,6 @@ export * from './nodes/footnotes_section';
|
|
|
98
98
|
export * from './nodes/graphical_abstract_section';
|
|
99
99
|
export * from './nodes/hard_break';
|
|
100
100
|
export * from './nodes/highlight_marker';
|
|
101
|
-
export * from './nodes/inline_equation';
|
|
102
101
|
export * from './nodes/inline_footnote';
|
|
103
102
|
export * from './nodes/keyword';
|
|
104
103
|
export * from './nodes/keywords_element';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* ©
|
|
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
|
-
|
|
21
|
-
|
|
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
|
|
29
|
+
const htmlEl = p;
|
|
31
30
|
return {
|
|
32
|
-
id:
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
46
|
-
|
|
43
|
+
dom.setAttribute('id', id);
|
|
44
|
+
if (format) {
|
|
45
|
+
dom.setAttribute('data-equation-format', format);
|
|
47
46
|
}
|
|
48
|
-
dom.
|
|
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)
|
|
17
|
+
content: '(equation | placeholder)',
|
|
18
18
|
attrs: {
|
|
19
19
|
id: { default: '' },
|
|
20
|
-
|
|
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: '
|
|
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
|
-
'
|
|
40
|
+
'div',
|
|
42
41
|
{
|
|
43
42
|
class: 'equation',
|
|
44
43
|
id: equationElementNode.attrs.id,
|
|
@@ -13,43 +13,39 @@
|
|
|
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
|
+
contents: { default: '' },
|
|
21
|
+
format: { default: '' },
|
|
24
22
|
},
|
|
23
|
+
selectable: false,
|
|
25
24
|
atom: true,
|
|
26
25
|
inline: true,
|
|
27
26
|
draggable: true,
|
|
28
27
|
group: 'inline',
|
|
29
28
|
parseDOM: [
|
|
30
29
|
{
|
|
31
|
-
tag: `span
|
|
30
|
+
tag: `span.MPInlineMathFragment`,
|
|
32
31
|
getAttrs: (p) => {
|
|
33
32
|
const dom = p;
|
|
34
33
|
return {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
SVGRepresentation: dom.innerHTML || '',
|
|
38
|
-
TeXRepresentation: dom.getAttribute('data-tex-representation') || '',
|
|
34
|
+
format: dom.getAttribute('data-equation-format'),
|
|
35
|
+
contents: dom.innerHTML,
|
|
39
36
|
};
|
|
40
37
|
},
|
|
41
38
|
},
|
|
42
39
|
],
|
|
43
40
|
toDOM: (node) => {
|
|
44
41
|
const inlineEquationNode = node;
|
|
42
|
+
const { contents, format } = inlineEquationNode.attrs;
|
|
45
43
|
const dom = document.createElement('span');
|
|
46
|
-
dom.classList.add(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (inlineEquationNode.attrs.MathMLRepresentation) {
|
|
50
|
-
dom.setAttribute('data-mathml-representation', inlineEquationNode.attrs.MathMLRepresentation);
|
|
44
|
+
dom.classList.add('MPInlineMathFragment');
|
|
45
|
+
if (format) {
|
|
46
|
+
dom.setAttribute('data-equation-format', format);
|
|
51
47
|
}
|
|
52
|
-
dom.innerHTML =
|
|
48
|
+
dom.innerHTML = contents;
|
|
53
49
|
return dom;
|
|
54
50
|
},
|
|
55
51
|
};
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
export const tableElement = {
|
|
17
|
-
content: '(table | placeholder)
|
|
17
|
+
content: '(table | placeholder) 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,
|
|
@@ -262,9 +262,8 @@ export class Decoder {
|
|
|
262
262
|
const model = data;
|
|
263
263
|
return schema.nodes.equation.createChecked({
|
|
264
264
|
id: model._id,
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
TeXRepresentation: model.TeXRepresentation,
|
|
265
|
+
contents: model.contents,
|
|
266
|
+
format: model.format,
|
|
268
267
|
});
|
|
269
268
|
},
|
|
270
269
|
[ObjectTypes.EquationElement]: (data) => {
|
|
@@ -283,12 +282,10 @@ export class Decoder {
|
|
|
283
282
|
else {
|
|
284
283
|
throw new MissingElement(model.containedObjectID);
|
|
285
284
|
}
|
|
286
|
-
const figcaption = this.getFigcaption(model);
|
|
287
285
|
return schema.nodes.equation_element.createChecked({
|
|
288
286
|
id: model._id,
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
}, [equation, figcaption]);
|
|
287
|
+
label: model.label,
|
|
288
|
+
}, [equation]);
|
|
292
289
|
},
|
|
293
290
|
[ObjectTypes.FootnotesElement]: (data) => {
|
|
294
291
|
const foonotesElementModel = data;
|
|
@@ -555,7 +552,7 @@ export class Decoder {
|
|
|
555
552
|
const comments = this.createCommentNodes(model);
|
|
556
553
|
comments.forEach((c) => this.comments.set(c.attrs.id, c));
|
|
557
554
|
const content = tableElementFooter
|
|
558
|
-
? [table,
|
|
555
|
+
? [table, tableElementFooter, figcaption]
|
|
559
556
|
: [table, figcaption];
|
|
560
557
|
if (model.listingID) {
|
|
561
558
|
const listing = this.createListing(model.listingID);
|
|
@@ -54,12 +54,6 @@ const listContents = (node) => {
|
|
|
54
54
|
}
|
|
55
55
|
return serializeToXML(output);
|
|
56
56
|
};
|
|
57
|
-
const svgDefs = (svg) => {
|
|
58
|
-
const template = document.createElement('template');
|
|
59
|
-
template.innerHTML = svg.trim();
|
|
60
|
-
const defs = template.content.querySelector('defs');
|
|
61
|
-
return defs ? serializeToXML(defs) : undefined;
|
|
62
|
-
};
|
|
63
57
|
const tableRowDisplayStyle = (tagName, parent) => {
|
|
64
58
|
switch (tagName) {
|
|
65
59
|
case 'thead':
|
|
@@ -345,20 +339,12 @@ const encoders = {
|
|
|
345
339
|
: false,
|
|
346
340
|
}),
|
|
347
341
|
equation: (node) => ({
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
SVGStringRepresentation: node.attrs.SVGStringRepresentation,
|
|
342
|
+
contents: node.attrs.contents,
|
|
343
|
+
format: node.attrs.format,
|
|
351
344
|
}),
|
|
352
345
|
equation_element: (node) => ({
|
|
353
346
|
containedObjectID: attributeOfNodeType(node, 'equation', 'id'),
|
|
354
|
-
|
|
355
|
-
title: inlineContentOfChildNodeType(node, node.type.schema.nodes.figcaption, node.type.schema.nodes.caption_title, false),
|
|
356
|
-
elementType: 'p',
|
|
357
|
-
suppressCaption: Boolean(node.attrs.suppressCaption) || undefined,
|
|
358
|
-
suppressTitle: node.attrs.suppressTitle === undefined ||
|
|
359
|
-
node.attrs.suppressTitle === true
|
|
360
|
-
? undefined
|
|
361
|
-
: false,
|
|
347
|
+
label: node.attrs.label,
|
|
362
348
|
}),
|
|
363
349
|
figure: (node) => ({
|
|
364
350
|
contentType: node.attrs.contentType || undefined,
|
|
@@ -405,12 +391,6 @@ const encoders = {
|
|
|
405
391
|
.map((childNode) => childNode.attrs.id)
|
|
406
392
|
.filter((id) => id),
|
|
407
393
|
}),
|
|
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
394
|
keyword: (node, parent) => ({
|
|
415
395
|
containedGroup: parent.attrs.id,
|
|
416
396
|
name: keywordContents(node),
|
|
@@ -571,8 +551,7 @@ export const encode = (node) => {
|
|
|
571
551
|
if (placeholderTypes.includes(child.type)) {
|
|
572
552
|
return;
|
|
573
553
|
}
|
|
574
|
-
if (parent.type === schema.nodes.paragraph
|
|
575
|
-
child.type !== schema.nodes.inline_equation) {
|
|
554
|
+
if (parent.type === schema.nodes.paragraph) {
|
|
576
555
|
return;
|
|
577
556
|
}
|
|
578
557
|
const { model, markers } = modelFromNode(child, parent, path, priority);
|
|
@@ -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],
|
package/dist/types/index.d.ts
CHANGED
|
@@ -32,7 +32,6 @@ export declare const jatsBodyTransformations: {
|
|
|
32
32
|
moveFootnotes(doc: Document, group: Element, createElement: (tagName: string) => HTMLElement): void;
|
|
33
33
|
moveCaptionsToEnd(body: Element): void;
|
|
34
34
|
fixTables(body: Element, createElement: (tagName: string) => HTMLElement): void;
|
|
35
|
-
moveTableFooterToEnd(body: Element): void;
|
|
36
35
|
moveFloatsGroupToBody(doc: Document, body: Element, createElement: (tagName: string) => HTMLElement): void;
|
|
37
36
|
createKeywords(document: Document, body: Element, createElement: (tagName: string) => HTMLElement): void;
|
|
38
37
|
};
|
|
@@ -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
|
-
* ©
|
|
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
|
-
|
|
21
|
-
|
|
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
|
-
|
|
22
|
-
suppressTitle?: boolean;
|
|
21
|
+
label: string;
|
|
23
22
|
comments?: CommentNode[];
|
|
24
23
|
}
|
|
25
24
|
export interface EquationElementNode extends ManuscriptNode {
|
|
@@ -15,11 +15,11 @@
|
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
TeXRepresentation: string;
|
|
20
|
+
contents: string;
|
|
21
|
+
format: string;
|
|
22
|
+
comments?: CommentNode[];
|
|
23
23
|
}
|
|
24
24
|
export interface InlineEquationNode extends ManuscriptNode {
|
|
25
25
|
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,
|
|
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) => 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.0.
|
|
4
|
+
"version": "2.0.4-LEAN-3093",
|
|
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": "
|
|
33
|
-
"@manuscripts/library": "
|
|
32
|
+
"@manuscripts/json-schema": "2.2.2-LEAN-3093",
|
|
33
|
+
"@manuscripts/library": "1.3.2-LEAN-3092-0",
|
|
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
|
"uuid": "^9.0.0",
|
|
@@ -78,4 +77,4 @@
|
|
|
78
77
|
"rimraf": "^3.0.2",
|
|
79
78
|
"typescript": "^4.0.5"
|
|
80
79
|
}
|
|
81
|
-
}
|
|
80
|
+
}
|