Repository navigation
fix(mobile): paragraph direction comes from the enriched-markdown fork, not injected marks - #455
Merged
Merged
Conversation
…k, not injected marks Mobile picked each paragraph's direction in JS by injecting RLM/LRM marks, which broke autolinks next to them and re-parsed the whole document on every streamed update. The enriched-markdown fork 1.2.0-oni.22 adds a native word-majority writing direction on iOS and Android, matching desktop's counting rule, so the marks go away. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Mobile chose each paragraph's direction in JS by injecting RLM/LRM marks into the markdown (7bf1fd8). The marks broke autolinks next to them, cost a whole-document remark parse on every streamed update, and could not reach table cells. This moves the rule into the enriched-markdown fork, so iOS and Android decide direction natively.
What changed
1.2.0-oni.22, aislopware/enriched-markdownoni-v1.2.0-oni.22) addswritingDirection="word-majority". Each paragraph, list item, heading and table cell goes right to left when it has more right-to-left words than left-to-right ones. Like desktop'stextDirection, it votes by sentence first, then by word, then takes the first word, and inline code doesn't count.ParagraphStyleUtils, blockquotes and tables included.TextDirectionHeuristic. Measurement and drawing share it, and inline code and highlight backgrounds take their bidi offsets from the layout that draws the text. Text with no right-to-left character keeps the platform's fast first-strong path.EnrichedMarkdownTextdefaults toword-majority. The pending question card keeps its whole-question direction on iOS. On Android it uses the native rule, because Android maps an explicit direction to first-strong.Before, the autolinks next to Arabic text lost their link styling, and "مرحبا then run the build and tests." was forced right to left. After, links work and the English sentence reads left to right.
Blockquotes and inline code, on iOS and Android:
Tests
WordMajorityDirectionTest(6 tests,:react-native-enriched-markdown:testDebugUnitTest).ENRMWritingDirectionTests. The example app's XCTest lane ran 97 tests, all passing.apps/web/src/textDirection.test.tsplus inline-code masking cases, so a mobile change that departs from desktop fails them.markdownTextDirection.test.tsgoes away with the JS marks.Council review
Round 1: Codex (gpt-6.2-sol, high) and Claude Opus, on the first fork commit and the Onicode revert. Both confirmed the counting rule matches desktop's character for character, and that the revert is complete.
استخدم `npm run build` ثم `npm test`went LTR on phones. Fixed on both platforms: iOS masks the inline-code attribute, and Android resolves each paragraph that holds code ahead of time, withCodeSpanmasked.FIRSTSTRONG_LTR.Round 2: both reviewers, on the fork's round-1 fixes. Opus confirmed all six fixed. Codex found no iOS issue. Neither found clipping, a thread-safety problem or a leak.
StaticLayoutthe old geometry built on every draw.Each of these fork changes would mean another tarball and rebuilding both native clients, so they wait for the next fork release.
Left
Plantur␣␣\nهذا شرح عربيis LTR then RTL on Android, and RTL throughout on iOS and desktop.Opus 5.5 in Claude Code, through Onicode.
🤖 Generated with Claude Code