This repository has been archived on 2022-05-02. You can view files and clone it, but cannot push or open issues or pull requests.
Ecosysteme/presentation/plugin/math/mathjax/input/mml/extensions/mml3.js

1 line
27 KiB
JavaScript
Raw Permalink Normal View History

2022-05-02 12:56:32 +02:00
(function(){"use strict";var __webpack_modules__={63:function(__unused_webpack_module,exports){function createTransform(){var nodeRequire=eval("require"),dirname=eval("__dirname");try{nodeRequire.resolve("saxon-js")}catch(e){throw Error("Saxon-js not found. Run the command:\n npm install saxon-js\nand try again.")}var Saxon=nodeRequire("saxon-js"),path=nodeRequire("path"),fs=nodeRequire("fs"),xsltFile=path.resolve(dirname,"mml3.sef.json"),xslt=JSON.parse(fs.readFileSync(xsltFile));return function(e){var t;e.match(/ xmlns[=:]/)||(e=e.replace(/<(?:(\w+)(:))?math/,'<$1$2math xmlns$2$1="http://www.w3.org/1998/Math/MathML"'));try{t=Saxon.transform({stylesheetInternal:xslt,sourceText:e,destination:"serialized"}).principalResult}catch(l){t=e}return t}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.createTransform=void 0,exports.createTransform=createTransform},514:function(e,t,l){var s,n=this&&this.__extends||(s=function(e,t){return(s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var l in t)Object.prototype.hasOwnProperty.call(t,l)&&(e[l]=t[l])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function l(){this.constructor=e}s(e,t),e.prototype=null===t?Object.create(t):(l.prototype=t.prototype,new l)}),m=this&&this.__read||function(e,t){var l="function"==typeof Symbol&&e[Symbol.iterator];if(!l)return e;var s,n,m=l.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(s=m.next()).done;)o.push(s.value)}catch(e){n={error:e}}finally{try{s&&!s.done&&(l=m.return)&&l.call(m)}finally{if(n)throw n.error}}return o},o=this&&this.__spreadArray||function(e,t){for(var l=0,s=t.length,n=e.length;l<s;l++,n++)e[n]=t[l];return e},a=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,l=t&&e[t],s=0;if(l)return l.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&s>=e.length&&(e=void 0),{value:e&&e[s++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(t,"__esModule",{value:!0}),t.Mml3Handler=t.Mml3=void 0;var r=l(63),c=function(){function e(t){if("undefined"==typeof XSLTProcessor)this.transform=r.createTransform();else{var l=new XSLTProcessor,s=t.adaptor.parse(e.XSLT,"text/xml");l.importStylesheet(s),this.transform=function(e){var s=t.adaptor,n=s.parse(e),m=l.transformToDocument(n);return s.serializeXML(s.body(m))}}}return e.prototype.preFilter=function(e){e.data=this.transform(e.data)},e}();t.Mml3=c,t.Mml3Handler=function(e){return e.documentClass=function(e){function t(){for(var t,l,s=[],n=0;n<arguments.length;n++)s[n]=arguments[n];var r=e.apply(this,o([],m(s)))||this,i=s[2];if(i.InputJax)try{for(var p=a(i.InputJax),x=p.next();!x.done;x=p.next()){var d=x.value;if("MathML"===d.name){if(!d.options._mml3){var h=new c(r);d.preFilters.add(h.preFilter.bind(h)),d.options._mml3=!0}break}}}catch(e){t={error:e}}finally{try{x&&!x.done&&(l=p.return)&&l.call(p)}finally{if(t)throw t.error}}return r}return n(t,e),t}(e.documentClass),e},c.XSLT='\n<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"\n\t\txmlns:m="http://www.w3.org/1998/Math/MathML"\n\t\txmlns:c="http://exslt.org/common"\n\t\texclude-result-prefixes="m c">\n<xsl:output indent="yes" omit-xml-declaration="yes"/>\n<xsl:output indent="yes" omit-xml-declaration="yes"/>\n<xsl:template match="*">\n <xsl:copy>\n <xsl:copy-of select="@*"/>\n <xsl:apply-templates/>\n </xsl:copy>\n</xsl:template>\n<xsl:template match="m:*[@dir=\'rtl\']" priority="10">\n <xsl:apply-templates mode="rtl" select="."/>\n</xsl:template>\n<xsl:template match="@*" mode="rtl">\n <xsl:copy-of select="."/>\n <xsl:attribute name="dir">ltr</xsl:attribute>\n</xsl:template>\n<xsl:template match="*" mode="rtl">\n <xsl:copy>\n <xsl:apply-templates select="@*" mode="rtl"/>\n <xsl:for-each select="node()">\n <xsl:sort data-type="number" order="descending" select="position()"/>\n <xsl:text> </xsl:text>\n <xsl:apply-templates mode="r