@manuscripts/transform 2.0.4-LEAN-3092 → 2.0.4-LEAN-3083
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 +1 -0
- package/dist/cjs/jats/importer/jats-body-dom-parser.js +72 -24
- package/dist/cjs/jats/jats-exporter.js +37 -17
- package/dist/cjs/mathjax/index.js +41 -0
- package/dist/cjs/mathjax/mathjax-packages.js +20 -0
- package/dist/cjs/mathjax/mathml-to-svg.js +70 -0
- package/dist/cjs/mathjax/tex-to-mathml.js +49 -0
- package/dist/cjs/mathjax/tex-to-svg.js +59 -0
- package/dist/cjs/schema/index.js +1 -0
- package/dist/cjs/schema/nodes/affiliation.js +2 -0
- package/dist/cjs/schema/nodes/contributor.js +2 -0
- package/dist/cjs/schema/nodes/equation.js +14 -12
- package/dist/cjs/schema/nodes/equation_element.js +5 -4
- package/dist/cjs/schema/nodes/inline_equation.js +16 -12
- package/dist/cjs/transformer/builders.js +8 -1
- package/dist/cjs/transformer/decode.js +11 -4
- package/dist/cjs/transformer/encode.js +28 -4
- package/dist/cjs/transformer/node-types.js +1 -0
- package/dist/cjs/transformer/object-types.js +1 -0
- package/dist/es/index.js +1 -0
- package/dist/es/jats/importer/jats-body-dom-parser.js +73 -25
- package/dist/es/jats/jats-exporter.js +37 -17
- package/dist/es/mathjax/index.js +12 -0
- package/dist/es/mathjax/mathjax-packages.js +17 -0
- package/dist/es/mathjax/mathml-to-svg.js +66 -0
- package/dist/es/mathjax/tex-to-mathml.js +45 -0
- package/dist/es/mathjax/tex-to-svg.js +55 -0
- package/dist/es/schema/index.js +1 -0
- package/dist/es/schema/nodes/affiliation.js +2 -0
- package/dist/es/schema/nodes/contributor.js +2 -0
- package/dist/es/schema/nodes/equation.js +14 -12
- package/dist/es/schema/nodes/equation_element.js +5 -4
- package/dist/es/schema/nodes/inline_equation.js +16 -12
- package/dist/es/transformer/builders.js +6 -0
- package/dist/es/transformer/decode.js +11 -4
- package/dist/es/transformer/encode.js +28 -4
- package/dist/es/transformer/node-types.js +1 -0
- package/dist/es/transformer/object-types.js +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/mathjax/index.d.ts +3 -0
- package/dist/types/mathjax/mathjax-packages.d.ts +16 -0
- package/dist/types/mathjax/mathml-to-svg.d.ts +17 -0
- package/dist/types/mathjax/tex-to-mathml.d.ts +17 -0
- package/dist/types/mathjax/tex-to-svg.d.ts +17 -0
- package/dist/types/schema/index.d.ts +1 -0
- package/dist/types/schema/nodes/affiliation.d.ts +2 -0
- package/dist/types/schema/nodes/contributor.d.ts +4 -2
- package/dist/types/schema/nodes/equation.d.ts +4 -3
- package/dist/types/schema/nodes/equation_element.d.ts +2 -1
- package/dist/types/schema/nodes/inline_equation.d.ts +4 -4
- package/dist/types/transformer/builders.d.ts +2 -1
- package/package.json +5 -4
|
@@ -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.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.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;
|
|
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,6 +115,13 @@ 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;
|
|
118
125
|
const buildFootnote = (containingObject, contents, kind = 'footnote') => ({
|
|
119
126
|
_id: (0, id_1.generateID)(json_schema_1.ObjectTypes.Footnote),
|
|
120
127
|
objectType: json_schema_1.ObjectTypes.Footnote,
|
|
@@ -271,8 +271,9 @@ class Decoder {
|
|
|
271
271
|
const model = data;
|
|
272
272
|
return schema_1.schema.nodes.equation.createChecked({
|
|
273
273
|
id: model._id,
|
|
274
|
-
|
|
275
|
-
|
|
274
|
+
MathMLStringRepresentation: model.MathMLStringRepresentation,
|
|
275
|
+
SVGStringRepresentation: model.SVGStringRepresentation,
|
|
276
|
+
TeXRepresentation: model.TeXRepresentation,
|
|
276
277
|
});
|
|
277
278
|
},
|
|
278
279
|
[json_schema_1.ObjectTypes.EquationElement]: (data) => {
|
|
@@ -291,10 +292,12 @@ class Decoder {
|
|
|
291
292
|
else {
|
|
292
293
|
throw new errors_1.MissingElement(model.containedObjectID);
|
|
293
294
|
}
|
|
295
|
+
const figcaption = this.getFigcaption(model);
|
|
294
296
|
return schema_1.schema.nodes.equation_element.createChecked({
|
|
295
297
|
id: model._id,
|
|
296
|
-
|
|
297
|
-
|
|
298
|
+
suppressCaption: Boolean(model.suppressCaption),
|
|
299
|
+
suppressTitle: Boolean(model.suppressTitle === undefined ? true : model.suppressTitle),
|
|
300
|
+
}, [equation, figcaption]);
|
|
298
301
|
},
|
|
299
302
|
[json_schema_1.ObjectTypes.FootnotesElement]: (data) => {
|
|
300
303
|
const foonotesElementModel = data;
|
|
@@ -615,6 +618,8 @@ class Decoder {
|
|
|
615
618
|
addressLine3: model.addressLine3,
|
|
616
619
|
postCode: model.postCode,
|
|
617
620
|
country: model.country,
|
|
621
|
+
county: model.county,
|
|
622
|
+
city: model.city,
|
|
618
623
|
email: model.email,
|
|
619
624
|
department: model.department,
|
|
620
625
|
priority: model.priority,
|
|
@@ -626,6 +631,8 @@ class Decoder {
|
|
|
626
631
|
id: model._id,
|
|
627
632
|
role: model.role,
|
|
628
633
|
affiliations: model.affiliations,
|
|
634
|
+
email: model.email,
|
|
635
|
+
isJointContributor: model.isJointContributor,
|
|
629
636
|
bibliographicName: model.bibliographicName,
|
|
630
637
|
userID: model.userID,
|
|
631
638
|
invitationID: model.invitationID,
|
|
@@ -62,6 +62,12 @@ 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
|
+
};
|
|
65
71
|
const tableRowDisplayStyle = (tagName, parent) => {
|
|
66
72
|
switch (tagName) {
|
|
67
73
|
case 'thead':
|
|
@@ -347,12 +353,20 @@ const encoders = {
|
|
|
347
353
|
: false,
|
|
348
354
|
}),
|
|
349
355
|
equation: (node) => ({
|
|
350
|
-
|
|
351
|
-
|
|
356
|
+
MathMLStringRepresentation: node.attrs.MathMLStringRepresentation || undefined,
|
|
357
|
+
TeXRepresentation: node.attrs.TeXRepresentation,
|
|
358
|
+
SVGStringRepresentation: node.attrs.SVGStringRepresentation,
|
|
352
359
|
}),
|
|
353
360
|
equation_element: (node) => ({
|
|
354
361
|
containedObjectID: attributeOfNodeType(node, 'equation', 'id'),
|
|
355
|
-
|
|
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
370
|
}),
|
|
357
371
|
figure: (node) => ({
|
|
358
372
|
contentType: node.attrs.contentType || undefined,
|
|
@@ -399,6 +413,12 @@ const encoders = {
|
|
|
399
413
|
.map((childNode) => childNode.attrs.id)
|
|
400
414
|
.filter((id) => id),
|
|
401
415
|
}),
|
|
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
|
+
}),
|
|
402
422
|
keyword: (node, parent) => ({
|
|
403
423
|
containedGroup: parent.attrs.id,
|
|
404
424
|
name: keywordContents(node),
|
|
@@ -490,6 +510,8 @@ const encoders = {
|
|
|
490
510
|
addressLine3: node.attrs.addressLine3,
|
|
491
511
|
postCode: node.attrs.postCode,
|
|
492
512
|
country: node.attrs.country,
|
|
513
|
+
county: node.attrs.county,
|
|
514
|
+
city: node.attrs.city,
|
|
493
515
|
email: node.attrs.email,
|
|
494
516
|
priority: node.attrs.priority,
|
|
495
517
|
}),
|
|
@@ -500,6 +522,7 @@ const encoders = {
|
|
|
500
522
|
userID: node.attrs.userID,
|
|
501
523
|
invitationID: node.attrs.invitationID,
|
|
502
524
|
isCorresponding: node.attrs.isCorresponding,
|
|
525
|
+
isJointContributor: node.attrs.isJointContributor,
|
|
503
526
|
ORCIDIdentifier: node.attrs.ORCIDIdentifier,
|
|
504
527
|
footnote: node.attrs.footnote,
|
|
505
528
|
corresp: node.attrs.corresp,
|
|
@@ -560,7 +583,8 @@ const encode = (node) => {
|
|
|
560
583
|
if (placeholderTypes.includes(child.type)) {
|
|
561
584
|
return;
|
|
562
585
|
}
|
|
563
|
-
if (parent.type === schema_1.schema.nodes.paragraph
|
|
586
|
+
if (parent.type === schema_1.schema.nodes.paragraph &&
|
|
587
|
+
child.type !== schema_1.schema.nodes.inline_equation) {
|
|
564
588
|
return;
|
|
565
589
|
}
|
|
566
590
|
const { model, markers } = (0, exports.modelFromNode)(child, parent, path, priority);
|
|
@@ -39,6 +39,7 @@ 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],
|
|
42
43
|
[schema_1.schema.nodes.keyword, json_schema_1.ObjectTypes.Keyword],
|
|
43
44
|
[schema_1.schema.nodes.keywords_element, json_schema_1.ObjectTypes.KeywordsElement],
|
|
44
45
|
[schema_1.schema.nodes.keywords, json_schema_1.ObjectTypes.Section],
|
|
@@ -38,6 +38,7 @@ 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,
|
|
41
42
|
json_schema_1.ObjectTypes.Section,
|
|
42
43
|
].concat(exports.elementObjects);
|
|
43
44
|
const isManuscriptModel = (model) => {
|
package/dist/es/index.js
CHANGED
|
@@ -15,8 +15,10 @@
|
|
|
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';
|
|
18
20
|
import { schema } from '../../schema';
|
|
19
|
-
import { chooseSectionCategory } from '../../transformer';
|
|
21
|
+
import { chooseSectionCategory, xmlSerializer } from '../../transformer';
|
|
20
22
|
const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
|
|
21
23
|
const chooseContentType = (graphicNode) => {
|
|
22
24
|
if (graphicNode) {
|
|
@@ -31,24 +33,6 @@ const chooseContentType = (graphicNode) => {
|
|
|
31
33
|
}
|
|
32
34
|
}
|
|
33
35
|
};
|
|
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
|
-
};
|
|
52
36
|
const marks = [
|
|
53
37
|
{
|
|
54
38
|
tag: 'bold',
|
|
@@ -157,27 +141,91 @@ const nodes = [
|
|
|
157
141
|
tag: 'inline-formula',
|
|
158
142
|
node: 'inline_equation',
|
|
159
143
|
getAttrs: (node) => {
|
|
144
|
+
var _a, _b, _c, _d, _e;
|
|
160
145
|
const element = node;
|
|
161
|
-
|
|
146
|
+
const attrs = {
|
|
147
|
+
id: element.getAttribute('id'),
|
|
148
|
+
MathMLRepresentation: '',
|
|
149
|
+
SVGRepresentation: '',
|
|
150
|
+
TeXRepresentation: '',
|
|
151
|
+
};
|
|
152
|
+
const container = (_a = element.querySelector('alternatives')) !== null && _a !== void 0 ? _a : element;
|
|
153
|
+
for (const child of container.childNodes) {
|
|
154
|
+
const nodeName = child.nodeName.replace(/^[a-z]:/, '');
|
|
155
|
+
switch (nodeName) {
|
|
156
|
+
case 'tex-math':
|
|
157
|
+
attrs.TeXRepresentation = (_c = (_b = child.textContent) === null || _b === void 0 ? void 0 : _b.trim()) !== null && _c !== void 0 ? _c : '';
|
|
158
|
+
if (attrs.TeXRepresentation) {
|
|
159
|
+
attrs.SVGRepresentation =
|
|
160
|
+
(_d = convertTeXToSVG(attrs.TeXRepresentation, true)) !== null && _d !== void 0 ? _d : '';
|
|
161
|
+
}
|
|
162
|
+
break;
|
|
163
|
+
case 'mml:math':
|
|
164
|
+
;
|
|
165
|
+
child.removeAttribute('id');
|
|
166
|
+
attrs.MathMLRepresentation = xmlSerializer.serializeToString(child);
|
|
167
|
+
if (attrs.MathMLRepresentation) {
|
|
168
|
+
attrs.SVGRepresentation =
|
|
169
|
+
(_e = convertMathMLToSVG(attrs.MathMLRepresentation, true)) !== null && _e !== void 0 ? _e : '';
|
|
170
|
+
}
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return attrs;
|
|
162
175
|
},
|
|
163
176
|
},
|
|
164
177
|
{
|
|
165
178
|
tag: 'disp-formula',
|
|
166
179
|
node: 'equation_element',
|
|
167
180
|
getAttrs: (node) => {
|
|
168
|
-
var _a, _b;
|
|
169
181
|
const element = node;
|
|
182
|
+
const caption = element.querySelector('figcaption');
|
|
170
183
|
return {
|
|
171
184
|
id: element.getAttribute('id'),
|
|
172
|
-
|
|
185
|
+
suppressCaption: !caption,
|
|
173
186
|
};
|
|
174
187
|
},
|
|
175
188
|
getContent: (node, schema) => {
|
|
189
|
+
var _a, _b, _c, _d, _e;
|
|
176
190
|
const element = node;
|
|
177
|
-
const attrs =
|
|
178
|
-
|
|
191
|
+
const attrs = {
|
|
192
|
+
MathMLStringRepresentation: '',
|
|
193
|
+
SVGStringRepresentation: '',
|
|
194
|
+
TeXRepresentation: '',
|
|
195
|
+
};
|
|
196
|
+
const container = (_a = element.querySelector('alternatives')) !== null && _a !== void 0 ? _a : element;
|
|
197
|
+
for (const child of container.childNodes) {
|
|
198
|
+
const nodeName = child.nodeName.replace(/^[a-z]:/, '');
|
|
199
|
+
switch (nodeName) {
|
|
200
|
+
case 'tex-math':
|
|
201
|
+
attrs.TeXRepresentation = (_c = (_b = child.textContent) === null || _b === void 0 ? void 0 : _b.trim()) !== null && _c !== void 0 ? _c : '';
|
|
202
|
+
if (attrs.TeXRepresentation) {
|
|
203
|
+
attrs.SVGStringRepresentation =
|
|
204
|
+
(_d = convertTeXToSVG(attrs.TeXRepresentation, true)) !== null && _d !== void 0 ? _d : '';
|
|
205
|
+
}
|
|
206
|
+
break;
|
|
207
|
+
case 'mml:math':
|
|
208
|
+
;
|
|
209
|
+
child.removeAttribute('id');
|
|
210
|
+
attrs.MathMLStringRepresentation =
|
|
211
|
+
xmlSerializer.serializeToString(child);
|
|
212
|
+
if (attrs.MathMLStringRepresentation) {
|
|
213
|
+
attrs.SVGStringRepresentation =
|
|
214
|
+
(_e = convertMathMLToSVG(attrs.MathMLStringRepresentation, true)) !== null && _e !== void 0 ? _e : '';
|
|
215
|
+
}
|
|
216
|
+
break;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
const caption = element.querySelector('figcaption');
|
|
220
|
+
const figcaption = schema.nodes.figcaption.create();
|
|
179
221
|
return Fragment.from([
|
|
180
|
-
schema.nodes.equation.createChecked(
|
|
222
|
+
schema.nodes.equation.createChecked(attrs),
|
|
223
|
+
caption
|
|
224
|
+
?
|
|
225
|
+
jatsBodyDOMParser.parse(caption, {
|
|
226
|
+
topNode: figcaption,
|
|
227
|
+
})
|
|
228
|
+
: figcaption,
|
|
181
229
|
]);
|
|
182
230
|
},
|
|
183
231
|
},
|
|
@@ -156,7 +156,6 @@ export class JATSExporter {
|
|
|
156
156
|
};
|
|
157
157
|
this.nodeFromJATS = (JATSFragment) => {
|
|
158
158
|
JATSFragment = JATSFragment.trim();
|
|
159
|
-
JATSFragment = JATSFragment.replace(' ', ' ');
|
|
160
159
|
if (!JATSFragment.length) {
|
|
161
160
|
return null;
|
|
162
161
|
}
|
|
@@ -677,23 +676,22 @@ export class JATSExporter {
|
|
|
677
676
|
},
|
|
678
677
|
doc: () => '',
|
|
679
678
|
equation: (node) => {
|
|
680
|
-
const
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
processChildNodes(eqElement, node, schema.nodes.equation);
|
|
695
|
-
return eqElement;
|
|
679
|
+
const formula = this.document.createElement('disp-formula');
|
|
680
|
+
formula.setAttribute('id', normalizeID(node.attrs.id));
|
|
681
|
+
if (node.attrs.TeXRepresentation) {
|
|
682
|
+
const math = this.document.createElement('tex-math');
|
|
683
|
+
math.textContent = node.attrs.TeXRepresentation;
|
|
684
|
+
formula.appendChild(math);
|
|
685
|
+
}
|
|
686
|
+
else if (node.attrs.MathMLStringRepresentation) {
|
|
687
|
+
const math = this.nodeFromJATS(node.attrs.MathMLStringRepresentation);
|
|
688
|
+
if (math) {
|
|
689
|
+
formula.appendChild(math);
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
return formula;
|
|
696
693
|
},
|
|
694
|
+
equation_element: (node) => createFigureElement(node, 'fig', node.type.schema.nodes.equation, 'equation'),
|
|
697
695
|
figcaption: (node) => {
|
|
698
696
|
if (!node.textContent) {
|
|
699
697
|
return '';
|
|
@@ -743,6 +741,28 @@ export class JATSExporter {
|
|
|
743
741
|
},
|
|
744
742
|
hard_break: () => '',
|
|
745
743
|
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
|
+
},
|
|
746
766
|
inline_footnote: (node) => {
|
|
747
767
|
const xref = this.document.createElement('xref');
|
|
748
768
|
xref.setAttribute('ref-type', 'fn');
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const convertMathMLToSVG = async (mathml, display) => {
|
|
2
|
+
const { convertMathMLToSVG } = await import('./mathml-to-svg');
|
|
3
|
+
return convertMathMLToSVG(mathml, display);
|
|
4
|
+
};
|
|
5
|
+
export const convertTeXToMathML = async (tex, display) => {
|
|
6
|
+
const { convertTeXToMathML } = await import('./tex-to-mathml');
|
|
7
|
+
return convertTeXToMathML(tex, display);
|
|
8
|
+
};
|
|
9
|
+
export const convertTeXToSVG = async (tex, display) => {
|
|
10
|
+
const { convertTeXToSVG } = await import('./tex-to-svg');
|
|
11
|
+
return convertTeXToSVG(tex, display);
|
|
12
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* © 2019 Atypon Systems LLC
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { AllPackages } from 'mathjax-full/js/input/tex/AllPackages';
|
|
17
|
+
export const packages = AllPackages.filter((name) => name !== 'html' && name !== 'bussproofs');
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* © 2019 Atypon Systems LLC
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import 'mathjax-full/js/util/entities/all';
|
|
17
|
+
import { HTMLAdaptor } from 'mathjax-full/js/adaptors/HTMLAdaptor';
|
|
18
|
+
import { MmlFactory } from 'mathjax-full/js/core/MmlTree/MmlFactory';
|
|
19
|
+
import { HTMLDocument } from 'mathjax-full/js/handlers/html/HTMLDocument';
|
|
20
|
+
import { MathML } from 'mathjax-full/js/input/mathml';
|
|
21
|
+
import { SVG } from 'mathjax-full/js/output/svg';
|
|
22
|
+
import { xmlSerializer } from '../transformer';
|
|
23
|
+
class ManuscriptsMmlFactory extends MmlFactory {
|
|
24
|
+
constructor() {
|
|
25
|
+
super();
|
|
26
|
+
this.nodeMap.set('image', this.nodeMap.get('none'));
|
|
27
|
+
}
|
|
28
|
+
create(kind, properties = {}, children = []) {
|
|
29
|
+
if (kind === 'image') {
|
|
30
|
+
return this.node['none'](properties, children);
|
|
31
|
+
}
|
|
32
|
+
return this.node[kind](properties, children);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
class ManuscriptsHTMLAdaptor extends HTMLAdaptor {
|
|
36
|
+
setAttribute(node, name, value, ns) {
|
|
37
|
+
if (name !== 'xmlns') {
|
|
38
|
+
ns ? node.setAttributeNS(ns, name, value) : node.setAttribute(name, value);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const InputJax = new MathML();
|
|
43
|
+
const OutputJax = new SVG({
|
|
44
|
+
fontCache: 'none',
|
|
45
|
+
});
|
|
46
|
+
const adaptor = new ManuscriptsHTMLAdaptor(window);
|
|
47
|
+
const doc = new HTMLDocument(document, adaptor, {
|
|
48
|
+
InputJax,
|
|
49
|
+
OutputJax,
|
|
50
|
+
MmlFactory: new ManuscriptsMmlFactory(),
|
|
51
|
+
});
|
|
52
|
+
doc.addStyleSheet();
|
|
53
|
+
export const convertMathMLToSVG = (mathml, display) => {
|
|
54
|
+
const item = doc.convert(mathml, {
|
|
55
|
+
display,
|
|
56
|
+
em: 16,
|
|
57
|
+
ex: 8,
|
|
58
|
+
containerWidth: 1000000,
|
|
59
|
+
lineWidth: 1000000,
|
|
60
|
+
scale: 1,
|
|
61
|
+
});
|
|
62
|
+
if (!item || !item.firstChild) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
return xmlSerializer.serializeToString(item.firstChild);
|
|
66
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* © 2019 Atypon Systems LLC
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import 'mathjax-full/js/util/entities/all';
|
|
17
|
+
import { HTMLAdaptor } from 'mathjax-full/js/adaptors/HTMLAdaptor';
|
|
18
|
+
import { STATE } from 'mathjax-full/js/core/MathItem.js';
|
|
19
|
+
import { SerializedMmlVisitor } from 'mathjax-full/js/core/MmlTree/SerializedMmlVisitor';
|
|
20
|
+
import { HTMLDocument } from 'mathjax-full/js/handlers/html/HTMLDocument';
|
|
21
|
+
import { TeX } from 'mathjax-full/js/input/tex';
|
|
22
|
+
import { packages } from './mathjax-packages';
|
|
23
|
+
const InputJax = new TeX({
|
|
24
|
+
packages,
|
|
25
|
+
});
|
|
26
|
+
const adaptor = new HTMLAdaptor(window);
|
|
27
|
+
const doc = new HTMLDocument(document, adaptor, {
|
|
28
|
+
InputJax,
|
|
29
|
+
});
|
|
30
|
+
const visitor = new SerializedMmlVisitor();
|
|
31
|
+
export const convertTeXToMathML = (tex, display) => {
|
|
32
|
+
const item = doc.convert(tex, {
|
|
33
|
+
display,
|
|
34
|
+
em: 16,
|
|
35
|
+
ex: 8,
|
|
36
|
+
containerWidth: 1000000,
|
|
37
|
+
lineWidth: 1000000,
|
|
38
|
+
scale: 1,
|
|
39
|
+
end: STATE.CONVERT,
|
|
40
|
+
});
|
|
41
|
+
if (!item) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
return visitor.visitTree(item);
|
|
45
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* © 2019 Atypon Systems LLC
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import 'mathjax-full/js/util/entities/all';
|
|
17
|
+
import { HTMLAdaptor } from 'mathjax-full/js/adaptors/HTMLAdaptor';
|
|
18
|
+
import { HTMLDocument } from 'mathjax-full/js/handlers/html/HTMLDocument';
|
|
19
|
+
import { TeX } from 'mathjax-full/js/input/tex';
|
|
20
|
+
import { SVG } from 'mathjax-full/js/output/svg';
|
|
21
|
+
import { xmlSerializer } from '../transformer';
|
|
22
|
+
import { packages } from './mathjax-packages';
|
|
23
|
+
class ManuscriptsHTMLAdaptor extends HTMLAdaptor {
|
|
24
|
+
setAttribute(node, name, value, ns) {
|
|
25
|
+
if (name !== 'xmlns') {
|
|
26
|
+
ns ? node.setAttributeNS(ns, name, value) : node.setAttribute(name, value);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const InputJax = new TeX({
|
|
31
|
+
packages,
|
|
32
|
+
});
|
|
33
|
+
const OutputJax = new SVG({
|
|
34
|
+
fontCache: 'none',
|
|
35
|
+
});
|
|
36
|
+
const adaptor = new ManuscriptsHTMLAdaptor(window);
|
|
37
|
+
const doc = new HTMLDocument(document, adaptor, {
|
|
38
|
+
InputJax,
|
|
39
|
+
OutputJax,
|
|
40
|
+
});
|
|
41
|
+
doc.addStyleSheet();
|
|
42
|
+
export const convertTeXToSVG = (tex, display) => {
|
|
43
|
+
const item = doc.convert(tex, {
|
|
44
|
+
display,
|
|
45
|
+
em: 16,
|
|
46
|
+
ex: 8,
|
|
47
|
+
containerWidth: 1000000,
|
|
48
|
+
lineWidth: 1000000,
|
|
49
|
+
scale: 1,
|
|
50
|
+
});
|
|
51
|
+
if (!item || !item.firstChild) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
return xmlSerializer.serializeToString(item.firstChild);
|
|
55
|
+
};
|
package/dist/es/schema/index.js
CHANGED
|
@@ -98,6 +98,7 @@ 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';
|
|
101
102
|
export * from './nodes/inline_footnote';
|
|
102
103
|
export * from './nodes/keyword';
|
|
103
104
|
export * from './nodes/keywords_element';
|
|
@@ -3,6 +3,7 @@ export const contributor = {
|
|
|
3
3
|
attrs: {
|
|
4
4
|
id: { default: '' },
|
|
5
5
|
role: { default: '' },
|
|
6
|
+
email: { default: '' },
|
|
6
7
|
affiliations: { default: [] },
|
|
7
8
|
footnote: { default: undefined },
|
|
8
9
|
corresp: { default: undefined },
|
|
@@ -10,6 +11,7 @@ export const contributor = {
|
|
|
10
11
|
userID: { default: undefined },
|
|
11
12
|
invitationID: { default: undefined },
|
|
12
13
|
isCorresponding: { default: undefined },
|
|
14
|
+
isJointContributor: { default: undefined },
|
|
13
15
|
ORCIDIdentifier: { default: undefined },
|
|
14
16
|
priority: { default: undefined },
|
|
15
17
|
dataTracked: { default: null },
|