-
Notifications
You must be signed in to change notification settings - Fork 352
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
[Locked Figure Labels] Util function to generate spoken math + use it within Locked Point aria labels #1839
base: main
Are you sure you want to change the base?
Conversation
… within Locked Point aria labels
npm Snapshot: PublishedGood news!! We've packaged up the latest commit from this PR (096a79d) and published it to npm. You Example: yarn add @khanacademy/perseus@PR1839 If you are working in Khan Academy's webapp, you can run: ./dev/tools/bump_perseus_version.sh -t PR1839 |
Size Change: +413 kB (+48.13%) 🚨 Total Size: 1.27 MB
ℹ️ View Unchanged
|
GeraldRequired Reviewers
Don't want to be involved in this pull request? Comment |
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.
Very cool! I left some suggestions inline for making the TeX parsing more robust.
// of the math inside the $ signs. | ||
// Example: "Circle with radius $\frac{1}{2}$" -> "Circle with radius one half" | ||
const convertedSpeech = mathString.replace( | ||
/\$(.*?)\$/g, |
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.
This way of identifying TeX isn't going to work in all cases, because the TeX itself can contain dollar signs (either escaped, or in subexpressions).
For example: This sandwich costs $\$50$
and $\text{$t$ seconds}$
I might recommend using @khanacademy/simple-markdown
(see perseus-markdown.tsx) to parse the string. You'll probably want to configure a separate parser instance in order to get TeX to render as speech. You could also use the parsing algorithm from mathMatcher()
, defined in pure-markdown/src/index.ts
Summary:
When auto-generating the aria labels for locked figures, we want it to use
words as if they were spoken rather than math expressions that might be
read incorrectly by the screen reader.
math details (TeX denoted by the
$...$
blocks) to spoken words.the speech engine is async. I had to use mocks in the tests for this.)
If this approach is given the okay, I'll go ahead and apply it to the
other locked figures as well in a following PR.
Issue: https://khanacademy.atlassian.net/browse/LEMS-2548
Test plan:
yarn jest packages/perseus-editor/src/widgets/interactive-graph-editor/locked-figures/util.test.ts
yarn jest packages/perseus-editor/src/widgets/interactive-graph-editor/locked-figures/locked-point-settings.test.tsx
Storybook
http://localhost:6006/iframe.html?args=&id=perseuseditor-widgets-interactive-graph--mafs-with-locked-figure-labels-all-flags&viewMode=story
$...$
) and non-TeX