-
-
Notifications
You must be signed in to change notification settings - Fork 200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix and catch speech computation errors, add missing braille option #1053
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't catch this earlier, but I think this condition is wrong. That is, if if ((!speech && document.options.enableSpeech) || (!bralle && document.options.enableBraille)) { There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks. Good catch. |
||
[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; | ||
|
@@ -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), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do any of the calls below cause a MathJax retry error? (That is, do any call
mathjax.retryAfter()
?)If not, then you can do
this.state(STATE.ATTACHSPEECH)
above line 247, and then just return here and the other places where the state is set. That would avoid having to set the state in several places. But it only works if the rest of the code will always complete and not restart the typesetting viaretryAfter()
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should not. The only place that triggers a
retryAfter
is in line 183:MathJax-src/ts/a11y/semantic-enrich.ts
Line 183 in 799ad89
But that should have run before
attachSpeech
at all times.