Skip to content

Commit f469542

Browse files
committed
Always apply isolation when u:dir is set
1 parent f3344b5 commit f469542

File tree

3 files changed

+33
-5
lines changed

3 files changed

+33
-5
lines changed

spec/formatting.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -938,9 +938,13 @@ The _Default Bidi Strategy_ is defined as follows:
938938
1. Let `fmt` be the formatted string representation of the _resolved value_ of `exp`.
939939
1. Let `dir` be the directionality of `fmt`,
940940
one of « `'LTR'`, `'RTL'`, `'unknown'` », with the same meanings as for `msgdir`.
941+
1. Let the boolean value `isolate` be
942+
True if the `u:dir` _option_ is set on the _resolved value_ of `exp`,
943+
or False if it is not set or the implementation does not support the option.
941944
1. If `dir` is `'LTR'`:
942-
1. If `msgdir` is `'LTR'`
943-
in the formatted output, let `fmt` be itself
945+
1. If `msgdir` is `'LTR'` in the formatted output
946+
and `isolate` is False,
947+
let `fmt` be itself
944948
1. Else, in the formatted output,
945949
prefix `fmt` with U+2066 LEFT-TO-RIGHT ISOLATE
946950
and postfix it with U+2069 POP DIRECTIONAL ISOLATE.

spec/u-namespace.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,16 @@ not valid, or some other reason.
6868
### `u:dir`
6969

7070
Replaces the base directionality defined in
71-
the _function context_ for this _expression_.
71+
the _function context_ for this _expression_
72+
and applies bidirectional isolation to it.
7273

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

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

8082
The value of the `u:dir` _option_ MUST be one of the following _literal_ values
8183
or a _variable_ whose _resolved value_ is one of these _literals_:

test/tests/u-options.json

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,22 @@
5656
},
5757
{
5858
"src": "hello {world :string u:dir=ltr u:id=foo}",
59-
"exp": "hello world",
59+
"exp": "hello \u2066world\u2069",
6060
"expParts": [
6161
{
6262
"type": "literal",
6363
"value": "hello "
6464
},
65+
{ "type": "bidiIsolation", "value": "\u2066" },
6566
{
6667
"type": "string",
6768
"source": "|world|",
6869
"dir": "ltr",
6970
"id": "foo",
7071
"value": "world"
71-
}
72+
},
73+
{ "type": "bidiIsolation", "value": "\u2069" }
74+
7275
]
7376
},
7477
{
@@ -102,6 +105,25 @@
102105
{ "type": "bidiIsolation", "value": "\u2069" }
103106
]
104107
},
108+
{
109+
"src": ".local $world = {world :string u:dir=ltr u:id=foo} {{hello {$world}}}",
110+
"exp": "hello \u2066world\u2069",
111+
"expParts": [
112+
{
113+
"type": "literal",
114+
"value": "hello "
115+
},
116+
{ "type": "bidiIsolation", "value": "\u2066" },
117+
{
118+
"type": "string",
119+
"source": "|world|",
120+
"dir": "ltr",
121+
"id": "foo",
122+
"value": "world"
123+
},
124+
{ "type": "bidiIsolation", "value": "\u2069" }
125+
]
126+
},
105127
{
106128
"locale": "ar",
107129
"src": "أهلاً {بالعالم :string u:dir=rtl}",

0 commit comments

Comments
 (0)