-
Notifications
You must be signed in to change notification settings - Fork 214
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
Add support for trapping and reporting sre errors. #679
Conversation
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.
The problem with this approach is that only works in the case where SRE actually fails to return something. If it returns valid something that cannot be rendered, then the menu fails on opening due to the cs preferences.
Replacing lines MathJax-src/ts/a11y/explorer.ts Line 598 in 5e238af
to MathJax-src/ts/a11y/explorer.ts Line 606 in 5e238af
by let items = null;
try {
items = sre.ClearspeakPreferences.smartPreferences(
menu.mathItem, locale);
if (box) {
items.splice(2, 0, box);
}
} catch (e) {}
return menu.factory.get('subMenu')(menu.factory, {
items: items || [],
id: 'Clearspeak'
}, sub); will take care of the problem. In the future this should really be caught in SRE and/or the context menu not here. But it will work as a temporary fix here. |
I'm not sure I understand what you are saying, but am happy to add the code you suggest. One question, though: The current code (without your new |
I note, my sentence was incomplete. Sorry, fatigue. I originally thought that if the smart preferences fail, there is really no need to compute the selection preferences. But in hindsight this is probably not smart, as they could fail on non-error elements as well. So I suggest this: let csMenu = function(menu: MJContextMenu, sub: Submenu) {
let locale = menu.pool.lookup('locale').getValue() as string;
const box = csSelectionBox(menu, locale);
let items: Object[] = [];
try {
items = sre.ClearspeakPreferences.smartPreferences(
menu.mathItem, locale);
} catch (e) {}
if (box) {
items.splice(2, 0, box);
}
return menu.factory.get('subMenu')(menu.factory, {
items: items,
id: 'Clearspeak'
}, sub);
}; |
If by "rendering" you mean by an output jax, then there is already a trap for failure to render ( It may be that a more general solution would be useful, where each |
I've made the requested change. |
I also resolved the conflict. |
If you want to wait with this for v3.2 and a more general solution, I'm OK with that. |
Even when the rendering error is caught, the menu error might prevent you from switching off whatever has caused the rendering error. Consider the scenario
Let's keep it in for 3.1.3 and have a good cleanup of that part for 3.2. |
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.
lgtm.
OK, good enough. |
This PR adds support for trapping and reporting errors that occur during the SRE enrichment process. It adds a new
enrichError()
, comparable to thecompileError()
andtypesetError()
options, that allows you to capture the error and respond to it. The default is to just issue a console warning, and to use the original (unenriched) MathML, but you could use this to present a different representation, or record the message, or whatever.This also changes the
inputData
that is being kept so thatoriginalMml
is the original serialization of the internal MathML, andenrichedMml
is the serialized enriched MathML (which used to be stored aoriginalMml
, which doesn't seem right). No other component currently uses this data, so it should be OK to make this change.