Skip to content

Commit

Permalink
Always apply isolation when u:dir is set
Browse files Browse the repository at this point in the history
  • Loading branch information
eemeli committed Nov 17, 2024
1 parent f3344b5 commit f469542
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
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_ is set on the _resolved value_ of `exp`,
or False if it is not set or the implementation does not support the option.
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
4 changes: 3 additions & 1 deletion spec/u-namespace.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,16 @@ 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_:
Expand Down
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}}}",
"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

0 comments on commit f469542

Please sign in to comment.