-
-
Notifications
You must be signed in to change notification settings - Fork 0
feat: render invalid ICU placeholders as plain text #10
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
baa0edc
feat: render invalid ICU placeholders as plain text
bdshadow 03d894a
fix: capture all invalid placeholder bodies and infer their bidi
bdshadow a81a540
fix: use bidi-js for direction detection and make invalid placeholder…
bdshadow 9869133
test: cover numeric params against the lenient invalid branch
bdshadow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| declare module "bidi-js" { | ||
| export type BidiCharTypeName = | ||
| | "L" | ||
| | "R" | ||
| | "AL" | ||
| | "EN" | ||
| | "ES" | ||
| | "ET" | ||
| | "AN" | ||
| | "CS" | ||
| | "NSM" | ||
| | "BN" | ||
| | "B" | ||
| | "S" | ||
| | "WS" | ||
| | "ON" | ||
| | "LRE" | ||
| | "LRO" | ||
| | "RLE" | ||
| | "RLO" | ||
| | "PDF" | ||
| | "LRI" | ||
| | "RLI" | ||
| | "FSI" | ||
| | "PDI"; | ||
|
|
||
| export interface Bidi { | ||
| getBidiCharTypeName(char: string): BidiCharTypeName; | ||
| } | ||
|
|
||
| export default function bidiFactory(): Bidi; | ||
| } |
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,22 @@ | ||
| // This file was generated by lezer-generator. You probably shouldn't edit it. | ||
| export const | ||
| Text = 1, | ||
| TextNested = 2, | ||
| Root = 3, | ||
| Expression = 4, | ||
| ExpressionOpen = 5, | ||
| FormatExpression = 7, | ||
| Param = 8, | ||
| FormatFunction = 9, | ||
| FormatStyle = 10, | ||
| SelectExpression = 11, | ||
| SelectFunction = 12, | ||
| Offset = 13, | ||
| SelectVariant = 14, | ||
| VariantDescriptor = 15, | ||
| VariantContent = 16, | ||
| PluralPlaceholder = 17, | ||
| ExpressionClose = 19, | ||
| Nested = 20 | ||
| InvalidExpressionContent = 2, | ||
| TextNested = 3, | ||
| Root = 4, | ||
| Expression = 5, | ||
| ExpressionOpen = 6, | ||
| FormatExpression = 8, | ||
| Param = 9, | ||
| FormatFunction = 10, | ||
| FormatStyle = 11, | ||
| SelectExpression = 12, | ||
| SelectFunction = 13, | ||
| Offset = 14, | ||
| SelectVariant = 15, | ||
| VariantDescriptor = 16, | ||
| VariantContent = 17, | ||
| PluralPlaceholder = 18, | ||
| InvalidExpressionBody = 20, | ||
| ExpressionClose = 21, | ||
| Nested = 22 |
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
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
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.
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.
Design note:
enternow runs three direction policies — tags & valid Expression forced LTR, Text/TextRoot forced RTL, and invalid Expression content-derived (first-strong). By this PR's own reasoning an invalid expression is 'arbitrary user text' — yet the visually-identical Text node is forced RTL while the invalid Expression uses plaintext direction. Two rules for the same kind of content, and a direction boundary between an invalid expression and the text around it. Worth considering one content-direction policy for all user text (bigger blast radius, needs RTL regression tests) instead of a special case — and deriving direction from a maintained bidi utility rather than a bespoke 5-script regex in the view layer.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.
Kept the special case deliberately. This plugin only mounts when the language itself is RTL, so forcing Text to RTL is the point: a Latin-only fragment of an Arabic translation must still sit in the RTL paragraph flow. Switching Text to first-strong would relayout every Latin-heavy RTL translation. The invalid expression genuinely cannot reuse that policy: forcing it RTL renders Latin content with the braces flipped outward (}placeholder:space{ ), which is the neutral-brackets problem this PR fixes. The bespoke-regex half of the concern is gone now that bidi-js owns the data. If we later want one plaintext policy for all user text, I would do that as its own change with RTL regression tests.