Skip to content
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

Always apply isolation when u:dir is set #942

Merged
merged 3 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions spec/formatting.md
Original file line number Diff line number Diff line change
Expand Up @@ -938,9 +938,13 @@ The _Default Bidi Strategy_ is defined as follows:
1. Let `fmt` be the formatted string representation of the _resolved value_ of `exp`.
1. Let `dir` be the directionality of `fmt`,
one of « `'LTR'`, `'RTL'`, `'unknown'` », with the same meanings as for `msgdir`.
1. Let the boolean value `isolate` be
True if the `u:dir` _option_ of the _resolved value_ of `exp` has a value other than `'inherit'`,
or False otherwise.
1. If `dir` is `'LTR'`:
1. If `msgdir` is `'LTR'`
in the formatted output, let `fmt` be itself
1. If `msgdir` is `'LTR'` in the formatted output
and `isolate` is False,
let `fmt` be itself
1. Else, in the formatted output,
prefix `fmt` with U+2066 LEFT-TO-RIGHT ISOLATE
and postfix it with U+2069 POP DIRECTIONAL ISOLATE.
Expand Down
7 changes: 6 additions & 1 deletion spec/u-namespace.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,25 @@ not valid, or some other reason.
### `u:dir`

Replaces the base directionality defined in
the _function context_ for this _expression_.
the _function context_ for this _expression_
and applies bidirectional isolation to it.

If this option is set on _markup_, a _Bad Option_ error is emitted
and the value of the `u:dir` option is ignored.

During processing, the `u:dir` option
MUST be removed from the resolved mapping of _options_
before calling the _function handler_.
Its value is retained in the _resolved value_ of the _expression_.

The value of the `u:dir` _option_ MUST be one of the following _literal_ values
or a _variable_ whose _resolved value_ is one of these _literals_:
- `ltr`: left-to-right directionality
- `rtl`: right-to-left directionality
- `auto`: directionality determined from _expression_ contents
- `inherit` (default): directionality inherited from the _message_
or from the _resolved value_ of the _operand_ without
requiring isolation of the _expression_ value.

For other values, a _Bad Option_ error is emitted
and the value of the `u:dir` option is ignored.
26 changes: 24 additions & 2 deletions test/tests/u-options.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,22 @@
},
{
"src": "hello {world :string u:dir=ltr u:id=foo}",
"exp": "hello world",
"exp": "hello \u2066world\u2069",
"expParts": [
{
"type": "literal",
"value": "hello "
},
{ "type": "bidiIsolation", "value": "\u2066" },
{
"type": "string",
"source": "|world|",
"dir": "ltr",
"id": "foo",
"value": "world"
}
},
{ "type": "bidiIsolation", "value": "\u2069" }

]
},
{
Expand Down Expand Up @@ -102,6 +105,25 @@
{ "type": "bidiIsolation", "value": "\u2069" }
]
},
{
"src": ".local $world = {world :string u:dir=ltr u:id=foo} {{hello {$world}}}",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is intended as the transitivity text, I think? Should we have one with mulitple .local declarations? or .input followed by .local?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eh, not sure if it's necessary. I think the important part is making sure that moving the option from the placeholder to a declaration works.

"exp": "hello \u2066world\u2069",
"expParts": [
{
"type": "literal",
"value": "hello "
},
{ "type": "bidiIsolation", "value": "\u2066" },
{
"type": "string",
"source": "|world|",
"dir": "ltr",
"id": "foo",
"value": "world"
},
{ "type": "bidiIsolation", "value": "\u2069" }
]
},
{
"locale": "ar",
"src": "أهلاً {بالعالم :string u:dir=rtl}",
Expand Down