Repository navigation
Conversation
Port the iOS package's LaTeXSpeech parser to the React Native package so
VoiceOver reads formulas as words ("x squared over 2", "integral from 0
to 1 of ...") instead of raw LaTeX. The math.equation label gains a
{speech} placeholder and defaults to "Math: {speech}"; {latex} still
reads the source. Inline formulas, previously a silent object
replacement character inside the paragraph element, become their own
accessibility elements, discovered through a mathLatex attribute stamped
on the attachment run. Android substitutes {speech} with the source
until a Kotlin port lands.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Port the LaTeX speech parser to Kotlin so TalkBack reads formulas as
words, resolving the {speech} placeholder of the math.equation label
for $$ blocks and for inline formulas. Inline formulas, previously a
silent object replacement character inside the paragraph node, become
TalkBack nodes of their own through a SpokenSpan interface the math
span implements, which keeps the optional math source set out of main.
Headings are now paragraph context for the accessibility helper rather
than a span it segments around, so formulas, links and images inside a
heading get their own nodes as they already do on iOS.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
maksg
force-pushed
the
rn-latex-voiceover
branch
from
October 26, 2026 13:28
cfab412 to
9a91fd8
Compare
jnowakow
requested changes
Oct 26, 2026
jnowakow
left a comment
Collaborator
There was a problem hiding this comment.
During the review I found a few issues that are worth looking at:
- Some formulas sound identical when they mean different things.
Argument.isSimpleis justitemCount == 1, but one item can be a whole fraction, root or power, so nesting disappears from the speech. Actual outputs:e^{\frac{x}{2}}and\frac{e^x}{2}both give "e to the power x over 2"\sqrt{\frac{a}{b}}and\frac{\sqrt{a}}{b}both give "square root of a over b"
This affects ENRMLaTeXSpeech.swift, LatexSpeech.kt and the upstream enriched-markdown-ios LaTeXSpeech.swift.
-
Math inside a link is read wrong on both platforms. md4c nests the math inside the link (
[see $x^2$ here](u)givesLink > [Text, LatexMathInline, Text]).- iOS:
segmentedElementsForParagraphsetssegmentStart = NSMaxRange(mathRange), which moves backwards. VoiceOver reads the link "see  here", then "Math: x squared", then "here" again as plain text. - Android:
if (span.start < segmentPos) continueskips the math span, so the formula is silent.
- iOS:
-
Multi-digit numbers are read as one number, but LaTeX takes only one digit.
\frac12gives "fraction 12 over end fraction" and the denominator is lost.x^23renders as x²3 but is spoken "x to the power 23".x_12gives "x sub 12".
-
Common constructs are misread:
\sum\limits_{i=1}^ngives "sum of limits sub i equals 1 end sub to the power n".\int\limitshas the same problem.\operatorname*{argmax}gives "times argmax".- In
pmatrix/cases, the environment names are read aloud and&and\\are silent, so rows run together.
-
The new speech tests break builds with math turned off:
- Android:
src/test/.../math/LatexSpeechTest.ktimportsLatexSpeech, which only joins the source set whenenableMathis on (build.gradle). With math off, the whole unit-test source set fails to compile. - iOS:
ENRMLaTeXSpeechTests.mmwould fail because{speech}stays as literal text. - CI never builds with math off, so this is currently hidden.
- Android:
I would also consider implementing this functionality as a shared C++ code. Current solution works but any future change has to be applied in two places.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What/Why?
Testing
PR Checklist