Skip to content

Commit

Permalink
Fix and catch speech computation errors, add missing braille option
Browse files Browse the repository at this point in the history
  • Loading branch information
zorkow committed Feb 8, 2024
1 parent e4ae4f7 commit 799ad89
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions ts/a11y/semantic-enrich.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,21 @@ export function EnrichedMathItemMixin<N, T, D, B extends Constructor<AbstractMat
*/
public attachSpeech(document: MathDocument<N, T, D>) {
if (this.state() >= STATE.ATTACHSPEECH) return;
if (this.isEscaped || !document.options.enableEnrichment) {
this.state(STATE.ATTACHSPEECH);
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));
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;
Expand Down Expand Up @@ -359,6 +368,7 @@ export function EnrichedMathDocumentMixin<N, T, D, B extends MathDocumentConstru
...BaseDocument.OPTIONS,
enableEnrichment: true,
enableSpeech: true,
enableBraille: true,
enrichError: (doc: EnrichedMathDocument<N, T, D>,
math: EnrichedMathItem<N, T, D>,
err: Error) => doc.enrichError(doc, math, err),
Expand Down

0 comments on commit 799ad89

Please sign in to comment.