diff --git a/package.json b/package.json index 0e54e9c56..ef2295827 100644 --- a/package.json +++ b/package.json @@ -141,6 +141,6 @@ "mathjax-modern-font": "^4.0.0-beta.4", "mhchemparser": "^4.2.1", "mj-context-menu": "^0.9.1", - "speech-rule-engine": "^4.1.0-beta.7" + "speech-rule-engine": "^4.1.0-beta.8" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5790279e7..c25427b4c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -15,8 +15,8 @@ dependencies: specifier: ^0.9.1 version: 0.9.1 speech-rule-engine: - specifier: ^4.1.0-beta.7 - version: 4.1.0-beta.7 + specifier: ^4.1.0-beta.8 + version: 4.1.0-beta.8 devDependencies: copyfiles: @@ -567,16 +567,16 @@ packages: delayed-stream: 1.0.0 dev: true - /commander@10.0.0: - resolution: {integrity: sha512-zS5PnTI22FIRM6ylNW8G4Ap0IEOyk62fhLSD0+uHRT9McRCLGpkVNvao4bjimpK/GShynyQkFFxHhwMcETmduA==} - engines: {node: '>=14'} - dev: false - /commander@10.0.1: resolution: {integrity: sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug==} engines: {node: '>=14'} dev: true + /commander@11.1.0: + resolution: {integrity: sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==} + engines: {node: '>=16'} + dev: false + /commander@2.20.3: resolution: {integrity: sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==} dev: true @@ -1696,12 +1696,12 @@ packages: engines: {node: '>=0.10.0'} dev: true - /speech-rule-engine@4.1.0-beta.7: - resolution: {integrity: sha512-e9QntjrfSKDa/w0baCXsoPQRPD9uY0r7q86Jr8ud/5zElzdG0Beiz4mc38kFb/E53c4RuYyZKSKyug8e5cVrpQ==} + /speech-rule-engine@4.1.0-beta.8: + resolution: {integrity: sha512-XG/BnvfH3alVKS1pOpu1JkGyTlqFZGNmTFE3e47gQrCyL3oM2vT0XhNjBNrV3yEr4kjcV8vKRN/7h0nh3BO1jA==} hasBin: true dependencies: '@xmldom/xmldom': 0.9.0-beta.8 - commander: 10.0.0 + commander: 11.1.0 wicked-good-xpath: 1.3.0 dev: false diff --git a/ts/a11y/explorer/KeyExplorer.ts b/ts/a11y/explorer/KeyExplorer.ts index 267f288ae..9ea5ad84a 100644 --- a/ts/a11y/explorer/KeyExplorer.ts +++ b/ts/a11y/explorer/KeyExplorer.ts @@ -309,6 +309,13 @@ export class SpeechExplorer extends AbstractExplorer implements KeyExplo return parent && this.highlighter.isMactionNode(parent) ? parent : null; } + /** + * Computes the nesting depth announcement for the currently focused sub + * expression. + * + * @param {HTMLElement} node The current node. + * @return {HTMLElement} The refocused node. + */ public depth(node: HTMLElement): HTMLElement { this.generators.depth(node, !!this.actionable(node)); this.refocus(node); diff --git a/ts/a11y/semantic-enrich.ts b/ts/a11y/semantic-enrich.ts index 98bd7161d..56eb013d3 100644 --- a/ts/a11y/semantic-enrich.ts +++ b/ts/a11y/semantic-enrich.ts @@ -244,19 +244,23 @@ export function EnrichedMathItemMixin) { if (this.state() >= STATE.ATTACHSPEECH) return; + this.state(STATE.ATTACHSPEECH); + if (this.isEscaped || !document.options.enableEnrichment) return; let [speech, braille] = this.existingSpeech(); let [newSpeech, newBraille] = ['', '']; - if (!speech || !braille || - document.options.enableSpeech || document.options.enableBraille) { - [newSpeech, newBraille] = this.generatorPool.computeSpeech( - this.typesetRoot, this.toMathML(this.root, this)); + if ((!speech && document.options.enableSpeech) || + (!braille && document.options.enableBraille)) { + try { + [newSpeech, newBraille] = this.generatorPool.computeSpeech( + this.typesetRoot, this.toMathML(this.root, this)); + if (newSpeech) { + newSpeech = buildSpeech(newSpeech)[0]; + } + } catch (_e) { } } speech = speech || newSpeech; braille = braille || newBraille; - if (!speech && !braille) { - this.state(STATE.ATTACHSPEECH); - return; - } + if (!speech && !braille) return; const adaptor = document.adaptor; const node = this.typesetRoot; if (speech) { @@ -270,30 +274,6 @@ export function EnrichedMathItemMixin, math: EnrichedMathItem, err: Error) => doc.enrichError(doc, math, err), @@ -404,8 +385,10 @@ export function EnrichedMathDocumentMixin).attachSpeech(this); + if (this.options.enableSpeech || this.options.enableBraille) { + for (const math of this.math) { + (math as EnrichedMathItem).attachSpeech(this); + } } this.processed.set('attach-speech'); } diff --git a/ts/a11y/speech/GeneratorPool.ts b/ts/a11y/speech/GeneratorPool.ts index ccaaa81f3..63ff8e0fa 100644 --- a/ts/a11y/speech/GeneratorPool.ts +++ b/ts/a11y/speech/GeneratorPool.ts @@ -394,7 +394,7 @@ export class GeneratorPool { this.CleanUp(node); return this.lastSpeech; } - let postfix = this.summaryGenerator.getExpandable( + let postfix = this.summaryGenerator.getActionable( actionable ? (this.adaptor.childNodes(node).length === 0 ? -1 : 1) : 0);