Gnome: bidi-isolate inline code in RTL MDX views#125
Open
JumpLink wants to merge 1 commit into
Open
Conversation
Neutral punctuation between an LTR inline-code span and an adjacent LTR word joined both into one left-to-right run, so quotes, dots and colons jumped to their LTR position inside RTL text - e.g. in '<tt>BNE</tt>: "Branch on not equal"' the colon and opening quote stuck to the LTR run while the closing quote resolved right-to-left. Wrap the content of <tt> spans in FIRST STRONG ISOLATE / POP DIRECTIONAL ISOLATE characters so surrounding punctuation resolves uniformly against the RTL paragraph direction; the isolated code itself is still rendered left-to-right by the bidi algorithm. Fixes #117
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.
Fixes #117
Problem
In RTL locales, neutral characters (quotes, dots, colons) next to LTR runs could resolve to the wrong side. The root cause for the asymmetric case reported in #117: when punctuation sits between two LTR runs — typically an inline-code mnemonic and a following English word — the Unicode bidi algorithm joins everything into one left-to-right run.
Real example from the Hebrew tutorial (
<tt>BNE</tt>: "Branch on not equal"inside a Hebrew sentence): the colon and the opening quote stuck to the LTR run while the closing quote correctly resolved right-to-left — exactly the "quote before but not after LTR letters" asymmetry described in the issue.Note: the simpler cases from the issue (punctuation between an LTR run and Hebrew text, or at line end) were already fixed by the RTL paragraph direction from #121; this PR fixes the remaining run-joining case.
Fix
In
MdxView.applyRtlBaseDirection, additionally wrap the content of<tt>spans in FIRST STRONG ISOLATE (U+2066–U+2069 family: FSI U+2068 / PDI U+2069) characters. Isolated runs are treated as neutral by the surrounding text, so all adjacent punctuation now resolves uniformly against the RTL paragraph direction, while the bidi algorithm still renders the isolated code itself left-to-right. FSI (first-strong) is used instead of LRI so the span direction always derives from its content. The transform is idempotent.Verification
GJS integration test loading the real generated
tutorial.uiwith the real Hebrew translations andGtk.TextDirection.RTL(mirroring the #121 methodology):<tt>spansGlyph positions verified via
PangoLayout.index_to_poson the rendered labels.Also passing:
yarn format,yarn check:format,yarn build, app-gnome type check (blueprint validation included).Notes
SourceView) keep their intentional LTR layout, unchanged.TextView/HTML and likely needs an equivalent fix — separate follow-up, same as noted in Gnome: force RTL base direction in MDX views #121.