first commit

This commit is contained in:
2025-12-22 12:20:15 +08:00
commit d77a09bdaa
1027 changed files with 54150 additions and 0 deletions

View File

@@ -0,0 +1 @@
(()=>{"use strict";var t={d:(e,i)=>{for(var n in i)t.o(i,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:i[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{EnrichHandler:()=>f,EnrichedMathDocumentMixin:()=>M,EnrichedMathItemMixin:()=>u,enrichVisitor:()=>p});const i=("undefined"!=typeof window?window:global).MathJax._.components.global,n=(i.GLOBAL,i.isObject,i.combineConfig,i.combineDefaults,i.combineWithMathJax),s=(i.MathJax,MathJax._.core.MathItem),r=(s.protoItem,s.AbstractMathItem,s.STATE),a=s.newState,o=MathJax._.core.MmlTree.SerializedMmlVisitor.SerializedMmlVisitor,c=MathJax._.util.Options,h=(c.isObject,c.APPEND,c.REMOVE,c.OPTIONS,c.Expandable,c.expandable),l=(c.makeArray,c.keys,c.copy,c.insert,c.defaultOptions,c.userOptions,c.selectOptions,c.selectOptionsFromKeys,c.separateOptions,c.lookup,MathJax._.a11y.sre_ts),d=(l.locales,l.setupEngine),m=(l.engineSetup,l.toEnriched);l.parseDOM,l.addPreference,l.fromPreference,l.toPreference;a("ENRICHED",r.COMPILED+10);class p extends o{visitTree(t,e){this.mactionId=0;const i=super.visitTree(t);return this.mactionId&&(e.inputData.hasMaction=!0),i}visitHtmlNode(t,e){return t.getSerializedXML()}visitMactionNode(t,e){const[i,n]=0===t.childNodes.length?["",""]:["\n",e],s=this.childNodeMml(t,e+" ",i);let r=this.getAttributes(t);if("toggle"===t.attributes.get("actiontype")){const e=++this.mactionId;t.setProperty("mactionId",e),r=` data-maction-id="${e}" selection="${t.attributes.get("selection")}"`+r.replace(/ selection="\d+"/,"").replace(/ data-maction-id="\d+"/,"")}return`${e}<maction${r}>`+(s.match(/\S/)?i+s+n:"")+"</maction>"}}function u(t,e,i){return class extends t{constructor(){super(...arguments),this.toMathML=i}serializeMml(t){if("outerHTML"in t)return t.outerHTML;if("undefined"!=typeof Element&&"undefined"!=typeof window&&t instanceof Element){const e=window.document.createElement("div");return e.appendChild(t),e.innerHTML}return t.toString()}enrich(t,i=!1){if(!(this.state()>=r.ENRICHED)){if(!this.isEscaped&&(t.options.enableEnrichment||i)){const i=new t.options.MathItem("",e);try{let e;e=this.inputData.originalMml?this.adjustSelections():this.inputData.originalMml=this.toMathML(this.root,this);const n=m(e);this.inputData.enrichedMml=i.math=this.serializeMml(n),i.math=i.math.replace(/ role="treeitem"/g,' data-speech-node="true"').replace(/ aria-(?:posinset|owns|setsize)=".*?"/g,""),i.display=this.display,i.compile(t),this.root=i.root}catch(e){t.options.enrichError(t,this,e)}}this.state(r.ENRICHED)}}toEnriched(t){return this.serializeMml(m(t))}unEnrich(t){const i=this.inputData.originalMml;if(!i)return;const n=new t.options.MathItem("",e);n.math=i,n.display=this.display,n.compile(t),this.root=n.root}adjustSelections(){const t=this.inputData.originalMml;if(!this.inputData.hasMaction)return t;const e=[];return this.root.walkTree((t=>{t.isKind("maction")&&(e[t.attributes.get("data-maction-id")]=t)})),t.replace(/(data-maction-id="(\d+)" selection=)"\d+"/g,((t,i,n)=>`${i}"${e[n].attributes.get("selection")}"`))}}}function M(t,e){var i;return(i=class extends t{constructor(...t){super(...t),e.setMmlFactory(this.mmlFactory);const i=this.constructor.ProcessBits;i.has("enriched")||i.allocate("enriched");const n=new p(this.mmlFactory);this.options.MathItem=u(this.options.MathItem,e,((t,e)=>n.visitTree(t,e)))}enrich(){if(!this.processed.isSet("enriched")){if(this.options.enableEnrichment){d(this.options.sre);for(const t of this.math)t.enrich(this)}this.processed.set("enriched")}return this}enrichError(t,e,i){console.warn("Enrichment error:",i)}state(t,e=!1){if(super.state(t,e),t<r.ENRICHED&&(this.processed.clear("enriched"),t>=r.COMPILED))for(const t of this.math)t.unEnrich(this);return this}}).OPTIONS=Object.assign(Object.assign({},t.OPTIONS),{enableEnrichment:!0,enrichError:(t,e,i)=>t.enrichError(t,e,i),renderActions:h(Object.assign(Object.assign({},t.OPTIONS.renderActions),{enrich:[r.ENRICHED]})),sre:h({speech:"none",locale:"en",domain:"clearspeak",style:"default",braille:"nemeth",structure:!0,aria:!0})}),i}function f(t,e){return e.setAdaptor(t.adaptor),t.documentClass=M(t.documentClass,e),t}MathJax.loader&&MathJax.loader.checkVersion("a11y/semantic-enrich","4.0.0","a11y"),n({_:{a11y:{"semantic-enrich":e}}});const E=MathJax._.input.mathml_ts.MathML;MathJax.startup&&MathJax.startup.extendHandler((t=>f(t,new E({allowHtmlInTokenNodes:!0}))))})();