@manuscripts/transform 2.0.3-LEAN-3074-0 → 2.0.4-LEAN-3092
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/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/transformer/builders.js +1 -8
- package/dist/cjs/transformer/decode.js +4 -7
- 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/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/transformer/builders.js +0 -6
- package/dist/es/transformer/decode.js +4 -7
- 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/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
|
@@ -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
|
};
|
|
@@ -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;
|
|
@@ -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
|
@@ -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-3092",
|
|
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.2",
|
|
33
|
-
"@manuscripts/library": "1.3.
|
|
32
|
+
"@manuscripts/json-schema": "^2.2.2-LEAN-3092",
|
|
33
|
+
"@manuscripts/library": "^1.3.2",
|
|
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
|
+
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.convertTeXToSVG = exports.convertTeXToMathML = exports.convertMathMLToSVG = void 0;
|
|
27
|
-
const convertMathMLToSVG = async (mathml, display) => {
|
|
28
|
-
const { convertMathMLToSVG } = await Promise.resolve().then(() => __importStar(require('./mathml-to-svg')));
|
|
29
|
-
return convertMathMLToSVG(mathml, display);
|
|
30
|
-
};
|
|
31
|
-
exports.convertMathMLToSVG = convertMathMLToSVG;
|
|
32
|
-
const convertTeXToMathML = async (tex, display) => {
|
|
33
|
-
const { convertTeXToMathML } = await Promise.resolve().then(() => __importStar(require('./tex-to-mathml')));
|
|
34
|
-
return convertTeXToMathML(tex, display);
|
|
35
|
-
};
|
|
36
|
-
exports.convertTeXToMathML = convertTeXToMathML;
|
|
37
|
-
const convertTeXToSVG = async (tex, display) => {
|
|
38
|
-
const { convertTeXToSVG } = await Promise.resolve().then(() => __importStar(require('./tex-to-svg')));
|
|
39
|
-
return convertTeXToSVG(tex, display);
|
|
40
|
-
};
|
|
41
|
-
exports.convertTeXToSVG = convertTeXToSVG;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*!
|
|
3
|
-
* © 2019 Atypon Systems LLC
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
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');
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*!
|
|
3
|
-
* © 2019 Atypon Systems LLC
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.convertMathMLToSVG = void 0;
|
|
19
|
-
require("mathjax-full/js/util/entities/all");
|
|
20
|
-
const HTMLAdaptor_1 = require("mathjax-full/js/adaptors/HTMLAdaptor");
|
|
21
|
-
const MmlFactory_1 = require("mathjax-full/js/core/MmlTree/MmlFactory");
|
|
22
|
-
const HTMLDocument_1 = require("mathjax-full/js/handlers/html/HTMLDocument");
|
|
23
|
-
const mathml_1 = require("mathjax-full/js/input/mathml");
|
|
24
|
-
const svg_1 = require("mathjax-full/js/output/svg");
|
|
25
|
-
const transformer_1 = require("../transformer");
|
|
26
|
-
class ManuscriptsMmlFactory extends MmlFactory_1.MmlFactory {
|
|
27
|
-
constructor() {
|
|
28
|
-
super();
|
|
29
|
-
this.nodeMap.set('image', this.nodeMap.get('none'));
|
|
30
|
-
}
|
|
31
|
-
create(kind, properties = {}, children = []) {
|
|
32
|
-
if (kind === 'image') {
|
|
33
|
-
return this.node['none'](properties, children);
|
|
34
|
-
}
|
|
35
|
-
return this.node[kind](properties, children);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
class ManuscriptsHTMLAdaptor extends HTMLAdaptor_1.HTMLAdaptor {
|
|
39
|
-
setAttribute(node, name, value, ns) {
|
|
40
|
-
if (name !== 'xmlns') {
|
|
41
|
-
ns ? node.setAttributeNS(ns, name, value) : node.setAttribute(name, value);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
const InputJax = new mathml_1.MathML();
|
|
46
|
-
const OutputJax = new svg_1.SVG({
|
|
47
|
-
fontCache: 'none',
|
|
48
|
-
});
|
|
49
|
-
const adaptor = new ManuscriptsHTMLAdaptor(window);
|
|
50
|
-
const doc = new HTMLDocument_1.HTMLDocument(document, adaptor, {
|
|
51
|
-
InputJax,
|
|
52
|
-
OutputJax,
|
|
53
|
-
MmlFactory: new ManuscriptsMmlFactory(),
|
|
54
|
-
});
|
|
55
|
-
doc.addStyleSheet();
|
|
56
|
-
const convertMathMLToSVG = (mathml, display) => {
|
|
57
|
-
const item = doc.convert(mathml, {
|
|
58
|
-
display,
|
|
59
|
-
em: 16,
|
|
60
|
-
ex: 8,
|
|
61
|
-
containerWidth: 1000000,
|
|
62
|
-
lineWidth: 1000000,
|
|
63
|
-
scale: 1,
|
|
64
|
-
});
|
|
65
|
-
if (!item || !item.firstChild) {
|
|
66
|
-
return null;
|
|
67
|
-
}
|
|
68
|
-
return transformer_1.xmlSerializer.serializeToString(item.firstChild);
|
|
69
|
-
};
|
|
70
|
-
exports.convertMathMLToSVG = convertMathMLToSVG;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*!
|
|
3
|
-
* © 2019 Atypon Systems LLC
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.convertTeXToMathML = void 0;
|
|
19
|
-
require("mathjax-full/js/util/entities/all");
|
|
20
|
-
const HTMLAdaptor_1 = require("mathjax-full/js/adaptors/HTMLAdaptor");
|
|
21
|
-
const MathItem_js_1 = require("mathjax-full/js/core/MathItem.js");
|
|
22
|
-
const SerializedMmlVisitor_1 = require("mathjax-full/js/core/MmlTree/SerializedMmlVisitor");
|
|
23
|
-
const HTMLDocument_1 = require("mathjax-full/js/handlers/html/HTMLDocument");
|
|
24
|
-
const tex_1 = require("mathjax-full/js/input/tex");
|
|
25
|
-
const mathjax_packages_1 = require("./mathjax-packages");
|
|
26
|
-
const InputJax = new tex_1.TeX({
|
|
27
|
-
packages: mathjax_packages_1.packages,
|
|
28
|
-
});
|
|
29
|
-
const adaptor = new HTMLAdaptor_1.HTMLAdaptor(window);
|
|
30
|
-
const doc = new HTMLDocument_1.HTMLDocument(document, adaptor, {
|
|
31
|
-
InputJax,
|
|
32
|
-
});
|
|
33
|
-
const visitor = new SerializedMmlVisitor_1.SerializedMmlVisitor();
|
|
34
|
-
const convertTeXToMathML = (tex, display) => {
|
|
35
|
-
const item = doc.convert(tex, {
|
|
36
|
-
display,
|
|
37
|
-
em: 16,
|
|
38
|
-
ex: 8,
|
|
39
|
-
containerWidth: 1000000,
|
|
40
|
-
lineWidth: 1000000,
|
|
41
|
-
scale: 1,
|
|
42
|
-
end: MathItem_js_1.STATE.CONVERT,
|
|
43
|
-
});
|
|
44
|
-
if (!item) {
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
return visitor.visitTree(item);
|
|
48
|
-
};
|
|
49
|
-
exports.convertTeXToMathML = convertTeXToMathML;
|