@wiris/mathtype-ckeditor5 8.10.0 → 8.11.1
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/browser/index-editor.css +626 -502
- package/dist/browser/index.js +136 -47
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.umd.js +138 -49
- package/dist/browser/index.umd.js.map +1 -1
- package/dist/index.js +98 -33
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
- package/src/index.js +1 -1
- package/src/integration.js +3 -0
- package/src/plugin.js +110 -31
package/dist/browser/index.js
CHANGED
|
@@ -557,6 +557,7 @@ var purify = {exports: {}};
|
|
|
557
557
|
'accumulate',
|
|
558
558
|
'additive',
|
|
559
559
|
'alignment-baseline',
|
|
560
|
+
'amplitude',
|
|
560
561
|
'ascent',
|
|
561
562
|
'attributename',
|
|
562
563
|
'attributetype',
|
|
@@ -589,6 +590,7 @@ var purify = {exports: {}};
|
|
|
589
590
|
'edgemode',
|
|
590
591
|
'elevation',
|
|
591
592
|
'end',
|
|
593
|
+
'exponent',
|
|
592
594
|
'fill',
|
|
593
595
|
'fill-opacity',
|
|
594
596
|
'fill-rule',
|
|
@@ -617,6 +619,7 @@ var purify = {exports: {}};
|
|
|
617
619
|
'image-rendering',
|
|
618
620
|
'in',
|
|
619
621
|
'in2',
|
|
622
|
+
'intercept',
|
|
620
623
|
'k',
|
|
621
624
|
'k1',
|
|
622
625
|
'k2',
|
|
@@ -681,6 +684,7 @@ var purify = {exports: {}};
|
|
|
681
684
|
'scale',
|
|
682
685
|
'seed',
|
|
683
686
|
'shape-rendering',
|
|
687
|
+
'slope',
|
|
684
688
|
'specularconstant',
|
|
685
689
|
'specularexponent',
|
|
686
690
|
'spreadmethod',
|
|
@@ -701,6 +705,7 @@ var purify = {exports: {}};
|
|
|
701
705
|
'surfacescale',
|
|
702
706
|
'systemlanguage',
|
|
703
707
|
'tabindex',
|
|
708
|
+
'tablevalues',
|
|
704
709
|
'targetx',
|
|
705
710
|
'targety',
|
|
706
711
|
'transform',
|
|
@@ -887,7 +892,7 @@ var purify = {exports: {}};
|
|
|
887
892
|
/**
|
|
888
893
|
* Version label, exposed for easier checks
|
|
889
894
|
* if DOMPurify is up to date or not
|
|
890
|
-
*/ DOMPurify.version = '3.1.
|
|
895
|
+
*/ DOMPurify.version = '3.1.7';
|
|
891
896
|
/**
|
|
892
897
|
* Array of elements that DOMPurify removed during sanitation.
|
|
893
898
|
* Empty if nothing was removed.
|
|
@@ -904,6 +909,7 @@ var purify = {exports: {}};
|
|
|
904
909
|
const { DocumentFragment, HTMLTemplateElement, Node, Element, NodeFilter, NamedNodeMap = window1.NamedNodeMap || window1.MozNamedAttrMap, HTMLFormElement, DOMParser, trustedTypes } = window1;
|
|
905
910
|
const ElementPrototype = Element.prototype;
|
|
906
911
|
const cloneNode = lookupGetter(ElementPrototype, 'cloneNode');
|
|
912
|
+
const remove = lookupGetter(ElementPrototype, 'remove');
|
|
907
913
|
const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');
|
|
908
914
|
const getChildNodes = lookupGetter(ElementPrototype, 'childNodes');
|
|
909
915
|
const getParentNode = lookupGetter(ElementPrototype, 'parentNode');
|
|
@@ -1259,7 +1265,6 @@ var purify = {exports: {}};
|
|
|
1259
1265
|
'mtext'
|
|
1260
1266
|
]);
|
|
1261
1267
|
const HTML_INTEGRATION_POINTS = addToSet({}, [
|
|
1262
|
-
'foreignobject',
|
|
1263
1268
|
'annotation-xml'
|
|
1264
1269
|
]);
|
|
1265
1270
|
// Certain elements are allowed in both SVG and HTML
|
|
@@ -1371,9 +1376,9 @@ var purify = {exports: {}};
|
|
|
1371
1376
|
});
|
|
1372
1377
|
try {
|
|
1373
1378
|
// eslint-disable-next-line unicorn/prefer-dom-node-remove
|
|
1374
|
-
node.
|
|
1379
|
+
getParentNode(node).removeChild(node);
|
|
1375
1380
|
} catch (_) {
|
|
1376
|
-
|
|
1381
|
+
remove(node);
|
|
1377
1382
|
}
|
|
1378
1383
|
};
|
|
1379
1384
|
/**
|
|
@@ -1516,7 +1521,7 @@ var purify = {exports: {}};
|
|
|
1516
1521
|
_forceRemove(currentNode);
|
|
1517
1522
|
return true;
|
|
1518
1523
|
}
|
|
1519
|
-
/* Remove any
|
|
1524
|
+
/* Remove any occurrence of processing instructions */ if (currentNode.nodeType === NODE_TYPE.progressingInstruction) {
|
|
1520
1525
|
_forceRemove(currentNode);
|
|
1521
1526
|
return true;
|
|
1522
1527
|
}
|
|
@@ -1665,10 +1670,6 @@ var purify = {exports: {}};
|
|
|
1665
1670
|
_removeAttribute(name, currentNode);
|
|
1666
1671
|
continue;
|
|
1667
1672
|
}
|
|
1668
|
-
/* Work around a security issue with comments inside attributes */ if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|title)/i, value)) {
|
|
1669
|
-
_removeAttribute(name, currentNode);
|
|
1670
|
-
continue;
|
|
1671
|
-
}
|
|
1672
1673
|
/* Sanitize attribute content to be template-safe */ if (SAFE_FOR_TEMPLATES) {
|
|
1673
1674
|
arrayForEach([
|
|
1674
1675
|
MUSTACHE_EXPR,
|
|
@@ -1690,6 +1691,10 @@ var purify = {exports: {}};
|
|
|
1690
1691
|
// Prefix the value and later re-create the attribute with the sanitized value
|
|
1691
1692
|
value = SANITIZE_NAMED_PROPS_PREFIX + value;
|
|
1692
1693
|
}
|
|
1694
|
+
/* Work around a security issue with comments inside attributes */ if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|title)/i, value)) {
|
|
1695
|
+
_removeAttribute(name, currentNode);
|
|
1696
|
+
continue;
|
|
1697
|
+
}
|
|
1693
1698
|
/* Handle attributes that require Trusted Types */ if (trustedTypesPolicy && typeof trustedTypes === 'object' && typeof trustedTypes.getAttributeType === 'function') {
|
|
1694
1699
|
if (namespaceURI) ;
|
|
1695
1700
|
else {
|
|
@@ -2265,6 +2270,19 @@ var purifyExports = purify.exports;
|
|
|
2265
2270
|
return mathml.replace(semanticsStartingTagRegex, "").replace(semanticsEndingTagRegex, "");
|
|
2266
2271
|
}
|
|
2267
2272
|
/**
|
|
2273
|
+
* Removes semantics tag to element that contains mathml.
|
|
2274
|
+
* When using Hand to create formulas, it adds the mrow tag due to the semantics one, this one is also removed.
|
|
2275
|
+
* @param {string} element - Inner HTML text string.
|
|
2276
|
+
* @returns {string} - 'mathml' without semantics tag.
|
|
2277
|
+
*/ static removeSafeXMLSemantics(element) {
|
|
2278
|
+
// If `mrow` is found right before the `semantics` starting tag, it's removed as well
|
|
2279
|
+
const semanticsSafeStartingTagRegex = /«semantics»\s*?(«mrow»)?/gm;
|
|
2280
|
+
// If `mrow` is found right after the `annotation` ending tag, it's removed as well
|
|
2281
|
+
// alongside `semantics` closing tag and the whole `annotation` tag and its contents.
|
|
2282
|
+
const semanticsSafeEndingTagRegex = /(«\/mrow»)?\s*«annotation[\W\w]*?«\/semantics»/gm;
|
|
2283
|
+
return element.replace(semanticsSafeStartingTagRegex, "").replace(semanticsSafeEndingTagRegex, "");
|
|
2284
|
+
}
|
|
2285
|
+
/**
|
|
2268
2286
|
* Transforms all xml mathml occurrences that contain semantics to the same
|
|
2269
2287
|
* xml mathml occurrences without semantics.
|
|
2270
2288
|
* @param {string} text - string that can contain xml mathml occurrences.
|
|
@@ -3587,6 +3605,9 @@ var ko = {
|
|
|
3587
3605
|
var nl = {
|
|
3588
3606
|
latex: "LaTeX",
|
|
3589
3607
|
cancel: "Annuleren",
|
|
3608
|
+
accept: "Invoegen",
|
|
3609
|
+
manual: "Handmatig",
|
|
3610
|
+
insert_math: "Een wiskundige vergelijking invoegen - MathType",
|
|
3590
3611
|
insert_chem: "Een scheikundige formule invoegen - ChemType",
|
|
3591
3612
|
minimize: "Minimaliseer",
|
|
3592
3613
|
maximize: "Maximaliseer",
|
|
@@ -4350,7 +4371,8 @@ var translations = {
|
|
|
4350
4371
|
"annotation",
|
|
4351
4372
|
"mstack",
|
|
4352
4373
|
"msline",
|
|
4353
|
-
"msrow"
|
|
4374
|
+
"msrow",
|
|
4375
|
+
"none"
|
|
4354
4376
|
],
|
|
4355
4377
|
ADD_ATTR: [
|
|
4356
4378
|
"linebreak",
|
|
@@ -5515,12 +5537,14 @@ var translations = {
|
|
|
5515
5537
|
* @param {string} code - HTML code to be parsed
|
|
5516
5538
|
* @returns {string} HTML code parsed.
|
|
5517
5539
|
*/ static endParseSaveMode(code) {
|
|
5518
|
-
|
|
5519
|
-
|
|
5540
|
+
const savemode = Configuration.get("saveMode");
|
|
5541
|
+
const base64savemode = Configuration.get("base64savemode");
|
|
5542
|
+
if (savemode) {
|
|
5543
|
+
if (savemode === "safeXml") {
|
|
5520
5544
|
code = Parser.codeImgTransform(code, "img2mathml");
|
|
5521
|
-
} else if (
|
|
5545
|
+
} else if (savemode === "xml") {
|
|
5522
5546
|
code = Parser.codeImgTransform(code, "img2mathml");
|
|
5523
|
-
} else if (
|
|
5547
|
+
} else if (savemode === "base64" && base64savemode === "image") {
|
|
5524
5548
|
code = Parser.codeImgTransform(code, "img264");
|
|
5525
5549
|
}
|
|
5526
5550
|
}
|
|
@@ -10531,6 +10555,8 @@ IntegrationModel.prototype.getSelectedItem = undefined;
|
|
|
10531
10555
|
openNewFormulaEditor() {
|
|
10532
10556
|
// Store the editor selection as it will be lost upon opening the modal
|
|
10533
10557
|
this.core.editionProperties.selection = this.editorObject.editing.view.document.selection;
|
|
10558
|
+
// Focus on the selected editor when multiple editor instances are present
|
|
10559
|
+
WirisPlugin.currentInstance = this;
|
|
10534
10560
|
return super.openNewFormulaEditor();
|
|
10535
10561
|
}
|
|
10536
10562
|
/**
|
|
@@ -10765,7 +10791,7 @@ var mathIcon = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- Generator: Adob
|
|
|
10765
10791
|
var chemIcon = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- Generator: Adobe Illustrator 22.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->\n<svg version=\"1.1\" id=\"Layer_1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" x=\"0px\" y=\"0px\"\n\t viewBox=\"0 0 40.3 49.5\" style=\"enable-background:new 0 0 40.3 49.5;\" xml:space=\"preserve\">\n<style type=\"text/css\">\n\t.st0{fill:#A4CF61;}\n</style>\n<path class=\"st0\" d=\"M39.2,12.1c0-1.9-1.1-3.6-2.7-4.4L24.5,0.9l0,0c-0.7-0.4-1.5-0.6-2.4-0.6c-0.9,0-1.7,0.2-2.4,0.6l0,0L2.3,10.8\n\tl0,0C0.9,11.7,0,13.2,0,14.9h0v19.6h0c0,1.7,0.9,3.3,2.3,4.1l0,0l17.4,9.9l0,0c0.7,0.4,1.5,0.6,2.4,0.6c0.9,0,1.7-0.2,2.4-0.6l0,0\n\tl12.2-6.9h0c1.5-0.8,2.6-2.5,2.6-4.3c0-2.7-2.2-4.9-4.9-4.9c-0.9,0-1.8,0.3-2.5,0.7l0,0l-9.7,5.6l-12.3-7V17.8l12.3-7l9.9,5.7l0,0\n\tc0.7,0.4,1.5,0.6,2.4,0.6C37,17,39.2,14.8,39.2,12.1\"/>\n</svg>\n";
|
|
10766
10792
|
|
|
10767
10793
|
var name = "@wiris/mathtype-ckeditor5";
|
|
10768
|
-
var version = "8.
|
|
10794
|
+
var version = "8.11.1";
|
|
10769
10795
|
var description = "MathType Web for CKEditor5 editor";
|
|
10770
10796
|
var keywords = [
|
|
10771
10797
|
"chem",
|
|
@@ -10800,8 +10826,8 @@ var main = "src/plugin.js";
|
|
|
10800
10826
|
var type = "module";
|
|
10801
10827
|
var exports = {
|
|
10802
10828
|
".": "./src/plugin.js",
|
|
10803
|
-
"./dist/*.css": "./dist/*.css",
|
|
10804
10829
|
"./dist/*": "./dist/*",
|
|
10830
|
+
"./browser/*": null,
|
|
10805
10831
|
"./src/*": "./src/*",
|
|
10806
10832
|
"./theme/*": "./theme/*",
|
|
10807
10833
|
"./package.json": "./package.json"
|
|
@@ -10812,14 +10838,14 @@ var scripts = {
|
|
|
10812
10838
|
prepare: "npm run build:dist"
|
|
10813
10839
|
};
|
|
10814
10840
|
var dependencies = {
|
|
10815
|
-
"@wiris/mathtype-html-integration-devkit": "1.17.
|
|
10841
|
+
"@wiris/mathtype-html-integration-devkit": "1.17.5"
|
|
10816
10842
|
};
|
|
10817
10843
|
var devDependencies = {
|
|
10818
|
-
"@ckeditor/ckeditor5-dev-build-tools": "^
|
|
10819
|
-
ckeditor5: ">=
|
|
10844
|
+
"@ckeditor/ckeditor5-dev-build-tools": "^42.1.0",
|
|
10845
|
+
ckeditor5: ">=43.0.0"
|
|
10820
10846
|
};
|
|
10821
10847
|
var peerDependencies = {
|
|
10822
|
-
ckeditor5: ">=
|
|
10848
|
+
ckeditor5: ">=43.0.0"
|
|
10823
10849
|
};
|
|
10824
10850
|
var packageInfo = {
|
|
10825
10851
|
name: name,
|
|
@@ -10981,7 +11007,8 @@ class MathType extends Plugin {
|
|
|
10981
11007
|
schema.register("mathml", {
|
|
10982
11008
|
inheritAllFrom: "$inlineObject",
|
|
10983
11009
|
allowAttributes: [
|
|
10984
|
-
"formula"
|
|
11010
|
+
"formula",
|
|
11011
|
+
"htmlContent"
|
|
10985
11012
|
]
|
|
10986
11013
|
});
|
|
10987
11014
|
}
|
|
@@ -11065,6 +11092,50 @@ class MathType extends Plugin {
|
|
|
11065
11092
|
data.modelCursor = data.modelRange.end;
|
|
11066
11093
|
}
|
|
11067
11094
|
});
|
|
11095
|
+
// Data view -> Model
|
|
11096
|
+
editor.data.upcastDispatcher.on("element:img", (evt, data, conversionApi)=>{
|
|
11097
|
+
const { consumable, writer } = conversionApi;
|
|
11098
|
+
const { viewItem } = data;
|
|
11099
|
+
// Only upcast when is wiris formula
|
|
11100
|
+
if (viewItem.getClassNames().next().value !== "Wirisformula") {
|
|
11101
|
+
return;
|
|
11102
|
+
}
|
|
11103
|
+
const mathAttributes = [
|
|
11104
|
+
...viewItem.getAttributes()
|
|
11105
|
+
].map(([key, value])=>` ${key}="${value}"`).join("");
|
|
11106
|
+
let htmlContent = Util.htmlSanitize(`<img${mathAttributes}>`);
|
|
11107
|
+
const modelNode = writer.createElement("mathml", {
|
|
11108
|
+
htmlContent
|
|
11109
|
+
});
|
|
11110
|
+
// Find allowed parent for element that we are going to insert.
|
|
11111
|
+
// If current parent does not allow to insert element but one of the ancestors does
|
|
11112
|
+
// then split nodes to allowed parent.
|
|
11113
|
+
const splitResult = conversionApi.splitToAllowedParent(modelNode, data.modelCursor);
|
|
11114
|
+
// When there is no split result it means that we can't insert element to model tree, so let's skip it.
|
|
11115
|
+
if (!splitResult) {
|
|
11116
|
+
return;
|
|
11117
|
+
}
|
|
11118
|
+
// Insert element on allowed position.
|
|
11119
|
+
conversionApi.writer.insert(modelNode, splitResult.position);
|
|
11120
|
+
// Consume appropriate value from consumable values list.
|
|
11121
|
+
consumable.consume(viewItem, {
|
|
11122
|
+
name: true
|
|
11123
|
+
});
|
|
11124
|
+
const parts = conversionApi.getSplitParts(modelNode);
|
|
11125
|
+
// Set conversion result range.
|
|
11126
|
+
data.modelRange = writer.createRange(conversionApi.writer.createPositionBefore(modelNode), conversionApi.writer.createPositionAfter(parts[parts.length - 1]));
|
|
11127
|
+
// Now we need to check where the `modelCursor` should be.
|
|
11128
|
+
if (splitResult.cursorParent) {
|
|
11129
|
+
// If we split parent to insert our element then we want to continue conversion in the new part of the split parent.
|
|
11130
|
+
//
|
|
11131
|
+
// before: <allowed><notAllowed>foo[]</notAllowed></allowed>
|
|
11132
|
+
// after: <allowed><notAllowed>foo</notAllowed><converted></converted><notAllowed>[]</notAllowed></allowed>
|
|
11133
|
+
data.modelCursor = conversionApi.writer.createPositionAt(splitResult.cursorParent, 0);
|
|
11134
|
+
} else {
|
|
11135
|
+
// Otherwise just continue after inserted element.
|
|
11136
|
+
data.modelCursor = data.modelRange.end;
|
|
11137
|
+
}
|
|
11138
|
+
});
|
|
11068
11139
|
/**
|
|
11069
11140
|
* Whether the given view <math> element has a LaTeX annotation element.
|
|
11070
11141
|
* @param {*} math
|
|
@@ -11093,12 +11164,25 @@ class MathType extends Plugin {
|
|
|
11093
11164
|
}
|
|
11094
11165
|
function createViewImage(modelItem, { writer: viewWriter }) {
|
|
11095
11166
|
const htmlDataProcessor = new HtmlDataProcessor(viewWriter.document);
|
|
11096
|
-
const
|
|
11097
|
-
const
|
|
11098
|
-
|
|
11167
|
+
const formula = modelItem.getAttribute("formula");
|
|
11168
|
+
const htmlContent = modelItem.getAttribute("htmlContent");
|
|
11169
|
+
if (!formula && !htmlContent) {
|
|
11170
|
+
return null;
|
|
11171
|
+
}
|
|
11172
|
+
let imgElement = null;
|
|
11173
|
+
if (htmlContent) {
|
|
11174
|
+
imgElement = htmlDataProcessor.toView(htmlContent).getChild(0);
|
|
11175
|
+
} else if (formula) {
|
|
11176
|
+
const mathString = formula.replaceAll('ref="<"', 'ref="<"');
|
|
11177
|
+
const imgHtml = Parser.initParse(mathString, integration.getLanguage());
|
|
11178
|
+
imgElement = htmlDataProcessor.toView(imgHtml).getChild(0);
|
|
11179
|
+
// Add HTML element (<img>) to model
|
|
11180
|
+
viewWriter.setAttribute("htmlContent", imgHtml, modelItem);
|
|
11181
|
+
}
|
|
11099
11182
|
/* Although we use the HtmlDataProcessor to obtain the attributes,
|
|
11100
|
-
|
|
11101
|
-
|
|
11183
|
+
* we must create a new EmptyElement which is independent of the
|
|
11184
|
+
* DataProcessor being used by this editor instance
|
|
11185
|
+
*/ if (imgElement) {
|
|
11102
11186
|
return viewWriter.createEmptyElement("img", imgElement.getAttributes(), {
|
|
11103
11187
|
renderUnsafeAttributes: [
|
|
11104
11188
|
"src"
|
|
@@ -11139,7 +11223,8 @@ class MathType extends Plugin {
|
|
|
11139
11223
|
}
|
|
11140
11224
|
function createDataString(modelItem, { writer: viewWriter }) {
|
|
11141
11225
|
const htmlDataProcessor = new HtmlDataProcessor(viewWriter.document);
|
|
11142
|
-
|
|
11226
|
+
// Load img element
|
|
11227
|
+
let mathString = modelItem.getAttribute("htmlContent");
|
|
11143
11228
|
const sourceMathElement = htmlDataProcessor.toView(mathString).getChild(0);
|
|
11144
11229
|
return clone(viewWriter, sourceMathElement);
|
|
11145
11230
|
}
|
|
@@ -11151,36 +11236,40 @@ class MathType extends Plugin {
|
|
|
11151
11236
|
* Hack to transform $$latex$$ into <math> in editor.getData()'s output.
|
|
11152
11237
|
*/ editor.data.on("get", (e)=>{
|
|
11153
11238
|
let output = e.return;
|
|
11154
|
-
|
|
11155
|
-
//
|
|
11156
|
-
|
|
11239
|
+
const parsedResult = Parser.endParse(output);
|
|
11240
|
+
// Cleans all the semantics tag for safexml
|
|
11241
|
+
// including the handwritten data points
|
|
11242
|
+
e.return = MathML.removeSafeXMLSemantics(parsedResult);
|
|
11157
11243
|
}, {
|
|
11158
11244
|
priority: "low"
|
|
11159
11245
|
});
|
|
11160
11246
|
/**
|
|
11161
|
-
* Hack to transform <math> with LaTeX into $$LaTeX$$ in editor.setData().
|
|
11247
|
+
* Hack to transform <math> with LaTeX into $$LaTeX$$ and formula images in editor.setData().
|
|
11162
11248
|
*/ editor.data.on("set", (e, args)=>{
|
|
11163
11249
|
// Retrieve the data to be set on the CKEditor.
|
|
11164
11250
|
let modifiedData = args[0];
|
|
11165
11251
|
// Regex to find all mathml formulas.
|
|
11166
|
-
const regexp =
|
|
11167
|
-
|
|
11168
|
-
|
|
11169
|
-
//
|
|
11170
|
-
|
|
11171
|
-
|
|
11172
|
-
|
|
11173
|
-
|
|
11174
|
-
] : [
|
|
11175
|
-
...modifiedData.matchAll(regexp)
|
|
11176
|
-
];
|
|
11177
|
-
// Loop to find LaTeX formulas and replace the MathML for the LaTeX notation.
|
|
11252
|
+
const regexp = /(<img\b[^>]*>)|(<math(.*?)<\/math>)/gm;
|
|
11253
|
+
const formulas = [];
|
|
11254
|
+
let formula;
|
|
11255
|
+
// Both data.set from the source plugin and console command are taken into account as the data received is MathML or an image containing the MathML.
|
|
11256
|
+
while((formula = regexp.exec(modifiedData)) !== null){
|
|
11257
|
+
formulas.push(formula[0]);
|
|
11258
|
+
}
|
|
11259
|
+
// Loop to find LaTeX and formula images and replace the MathML for the both.
|
|
11178
11260
|
formulas.forEach((formula)=>{
|
|
11179
|
-
|
|
11180
|
-
if (mathml.includes('encoding="LaTeX"')) {
|
|
11261
|
+
if (formula.includes('encoding="LaTeX"')) {
|
|
11181
11262
|
// LaTeX found.
|
|
11182
|
-
let latex = "$$$" + Latex.getLatexFromMathML(
|
|
11183
|
-
modifiedData = modifiedData.replace(
|
|
11263
|
+
let latex = "$$$" + Latex.getLatexFromMathML(formula) + "$$$"; // We add $$$ instead of $$ because the replace function ignores one $.
|
|
11264
|
+
modifiedData = modifiedData.replace(formula, latex);
|
|
11265
|
+
} else if (formula.includes("<img")) {
|
|
11266
|
+
// If we found a formula image, we should find MathML data, and then substitute the entire image.
|
|
11267
|
+
const regexp = /«math\b[^»]*»(.*?)«\/math»/g;
|
|
11268
|
+
const safexml = formula.match(regexp);
|
|
11269
|
+
if (safexml !== null) {
|
|
11270
|
+
let decodeXML = MathML.safeXmlDecode(safexml[0]);
|
|
11271
|
+
modifiedData = modifiedData.replace(formula, decodeXML);
|
|
11272
|
+
}
|
|
11184
11273
|
}
|
|
11185
11274
|
});
|
|
11186
11275
|
args[0] = modifiedData;
|