mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
synced 2024-12-19 02:50:44 +00:00
34 lines
2 MiB
JavaScript
34 lines
2 MiB
JavaScript
|
(function(){"use strict";var __webpack_modules__={351:function(e,t,r){var a,n=this&&this.__extends||(a=function(e,t){return a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},a(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 r(){this.constructor=e}a(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__assign||function(){return o=Object.assign||function(e){for(var t,r=1,a=arguments.length;r<a;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},o.apply(this,arguments)},i=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var a,n,o=r.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(a=o.next()).done;)i.push(a.value)}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return i},l=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var a,n=0,o=t.length;n<o;n++)!a&&n in t||(a||(a=Array.prototype.slice.call(t,0,n)),a[n]=t[n]);return e.concat(a||Array.prototype.slice.call(t))},s=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],a=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&a>=e.length&&(e=void 0),{value:e&&e[a++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(t,"__esModule",{value:!0}),t.AssistiveMmlHandler=t.AssistiveMmlMathDocumentMixin=t.AssistiveMmlMathItemMixin=t.LimitedMmlVisitor=void 0;var u=r(4474),c=r(9259),d=r(7233),p=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.getAttributes=function(t){return e.prototype.getAttributes.call(this,t).replace(/ ?id=".*?"/,"")},t}(c.SerializedMmlVisitor);function f(e){return function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.assistiveMml=function(e,t){if(void 0===t&&(t=!1),!(this.state()>=u.STATE.ASSISTIVEMML)){if(!this.isEscaped&&(e.options.enableAssistiveMml||t)){var r=e.adaptor,a=e.toMML(this.root).replace(/\n */g,"").replace(/<!--.*?-->/g,""),n=r.firstChild(r.body(r.parse(a,"text/html"))),o=r.node("mjx-assistive-mml",{unselectable:"on",display:this.display?"block":"inline"},[n]);r.setAttribute(r.firstChild(this.typesetRoot),"aria-hidden","true"),r.setStyle(this.typesetRoot,"position","relative"),r.append(this.typesetRoot,o)}this.state(u.STATE.ASSISTIVEMML)}},t}(e)}function m(e){var t;return t=function(e){function t(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var a=e.apply(this,l([],i(t),!1))||this,n=a.constructor,o=n.ProcessBits;return o.has("assistive-mml")||o.allocate("assistive-mml"),a.visitor=new p(a.mmlFactory),a.options.MathItem=f(a.options.MathItem),"addStyles"in a&&a.addStyles(n.assistiveStyles),a}return n(t,e),t.prototype.toMML=function(e){return this.visitor.visitTree(e)},t.prototype.assistiveMml=function(){var e,t;if(!this.processed.isSet("assistive-mml")){try{for(var r=s(this.math),a=r.next();!a.done;a=r.next()){a.value.assistiveMml(this)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}this.processed.set("assistive-mml")}return this},t.prototype.state=function(t,r){return void 0===r&&(r=!1),e.prototype.state.call(this,t,r),t<u.STATE.ASSISTIVEMML&&this.processed.clear("assistive-mml"),this},t}(e),t.OPTIONS=o(o({},e.OPTIONS),{enableAssistiveMml:!0,renderActions:(0,d.expandable)(o(o({},e.OPTIONS.renderActions),{assistiveMml:[u.STATE.ASSISTIVEMML]}))}),t.assistiveStyles={"mjx-assistive-mml":{position:"absolute !important",top:"0px",left:"0px",clip:"rect(1px, 1px, 1px, 1px)",padding:"1px 0px 0px 0px !important",border:"0px !important",display:"block !important",width:"auto !important",overflow:"hidden !important","-webkit-touch-callout":"none","-webki
|
||
|
/*!
|
||
|
*************************************************************************
|
||
|
*
|
||
|
* mhchemParser.ts
|
||
|
* 4.1.1
|
||
|
*
|
||
|
* Parser for the \ce command and \pu command for MathJax and Co.
|
||
|
*
|
||
|
* mhchem's \ce is a tool for writing beautiful chemical equations easily.
|
||
|
* mhchem's \pu is a tool for writing physical units easily.
|
||
|
*
|
||
|
* ----------------------------------------------------------------------
|
||
|
*
|
||
|
* Copyright (c) 2015-2021 Martin Hensel
|
||
|
*
|
||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||
|
* you may not use this file except in compliance with the License.
|
||
|
* You may obtain a copy of the License at
|
||
|
*
|
||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||
|
*
|
||
|
* Unless required by applicable law or agreed to in writing, software
|
||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||
|
* See the License for the specific language governing permissions and
|
||
|
* limitations under the License.
|
||
|
*
|
||
|
* ----------------------------------------------------------------------
|
||
|
*
|
||
|
* https://github.com/mhchem/mhchemParser
|
||
|
*
|
||
|
*/
|
||
|
Object.defineProperty(t,"__esModule",{value:!0}),t.mhchemParser=void 0;var r=function(){function e(){}return e.toTex=function(e,t){return o.go(n.go(e,t),"tex"!==t)},e}();function a(e){var t,r,a={};for(t in e)for(r in e[t]){var n=r.split("|");e[t][r].stateArray=n;for(var o=0;o<n.length;o++)a[n[o]]=[]}for(t in e)for(r in e[t])for(n=e[t][r].stateArray||[],o=0;o<n.length;o++){var i=e[t][r];i.action_=[].concat(i.action_);for(var l=0;l<i.action_.length;l++)"string"==typeof i.action_[l]&&(i.action_[l]={type_:i.action_[l]});for(var s=t.split("|"),u=0;u<s.length;u++)if("*"===n[o]){var c=void 0;for(c in a)a[c].push({pattern:s[u],task:i})}else a[n[o]].push({pattern:s[u],task:i})}return a}t.mhchemParser=r;var n={go:function(e,t){if(!e)return[];void 0===t&&(t="ce");var r,a="0",o={};o.parenthesisLevel=0,e=(e=(e=e.replace(/\n/g," ")).replace(/[\u2212\u2013\u2014\u2010]/g,"-")).replace(/[\u2026]/g,"...");for(var i=10,l=[];;){r!==e?(i=10,r=e):i--;var s=n.stateMachines[t],u=s.transitions[a]||s.transitions["*"];e:for(var c=0;c<u.length;c++){var d=n.patterns.match_(u[c].pattern,e);if(d){for(var p=u[c].task,f=0;f<p.action_.length;f++){var m=void 0;if(s.actions[p.action_[f].type_])m=s.actions[p.action_[f].type_](o,d.match_,p.action_[f].option);else{if(!n.actions[p.action_[f].type_])throw["MhchemBugA","mhchem bug A. Please report. ("+p.action_[f].type_+")"];m=n.actions[p.action_[f].type_](o,d.match_,p.action_[f].option)}n.concatArray(l,m)}if(a=p.nextState||a,!(e.length>0))return l;if(p.revisit||(e=d.remainder),!p.toContinue)break e}}if(i<=0)throw["MhchemBugU","mhchem bug U. Please report."]}},concatArray:function(e,t){if(t)if(Array.isArray(t))for(var r=0;r<t.length;r++)e.push(t[r]);else e.push(t)},patterns:{patterns:{empty:/^$/,else:/^./,else2:/^./,space:/^\s/,"space A":/^\s(?=[A-Z\\$])/,space$:/^\s$/,"a-z":/^[a-z]/,x:/^x/,x$:/^x$/,i$:/^i$/,letters:/^(?:[a-zA-Z\u03B1-\u03C9\u0391-\u03A9?@]|(?:\\(?:alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega|Gamma|Delta|Theta|Lambda|Xi|Pi|Sigma|Upsilon|Phi|Psi|Omega)(?:\s+|\{\}|(?![a-zA-Z]))))+/,"\\greek":/^\\(?:alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega|Gamma|Delta|Theta|Lambda|Xi|Pi|Sigma|Upsilon|Phi|Psi|Omega)(?:\s+|\{\}|(?![a-zA-Z]))/,"one lowercase latin letter $":/^(?:([a-z])(?:$|[^a-zA-Z]))$/,"$one lowercase latin letter$ $":/^\$(?:([a-z])(?:$|[^a-zA-Z]))\$$/,"one lowercase greek letter $":/^(?:\$?[\u03B1-\u03C9]\$?|\$?\\(?:alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega)\s*\$?)(?:\s+|\{\}|(?![a-zA-Z]))$/,digits:/^[0-9]+/,"-9.,9":/^[+\-]?(?:[0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+))/,"-9.,9 no missing 0":/^[+\-]?[0-9]+(?:[.,][0-9]+)?/,"(-)(9.,9)(e)(99)":function(e){var t=e.match(/^(\+\-|\+\/\-|\+|\-|\\pm\s?)?([0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+))?(\((?:[0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+))\))?(?:(?:([eE])|\s*(\*|x|\\times|\u00D7)\s*10\^)([+\-]?[0-9]+|\{[+\-]?[0-9]+\}))?/);return t&&t[0]?{match_:t.slice(1),remainder:e.substr(t[0].length)}:null},"(-)(9)^(-9)":/^(\+\-|\+\/\-|\+|\-|\\pm\s?)?([0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+)?)\^([+\-]?[0-9]+|\{[+\-]?[0-9]+\})/,"state of aggregation $":function(e){var t=n.patterns.findObserveGroups(e,"",/^\([a-z]{1,3}(?=[\),])/,")","");if(t&&t.remainder.match(/^($|[\s,;\)\]\}])/))return t;var r=e.match(/^(?:\((?:\\ca\s?)?\$[amothc]\$\))/);return r?{match_:r[0],remainder:e.substr(r[0].length)}:null},"_{(state of aggregation)}$":/^_\{(\([a-z]{1,3}\))\}/,"{[(":/^(?:\\\{|\[|\()/,")]}":/^(?:\)|\]|\\\})/,", ":/^[,;]\s*/,",":/^[,;]/,".":/^[.]/,". __* ":/^([.\u22C5\u00B7\u2022]|[*])\s*/,"...":/^\.\.\.(?=$|[^.])/,"^{(...)}":function(e){return n.patterns.findObserveGroups(e,"^{","","","}")},"^($...$)":function(e){return n.patterns.findObserveGroups(e,"^","$","$","")},"^a":/^\^([0-9]+|[^\\_])/,"^\\x{}{}":function(e){return n.patterns.findObserveGroups(e,"^",/^\\[a-zA-Z]+\{/,"}","","","{","}","",!0)},"^\\x{}":function(e){return n.patterns.f
|