From f469542e5e9faef070e0fa7bdf07f4f502be333f Mon Sep 17 00:00:00 2001 From: Eemeli Aro Date: Sun, 17 Nov 2024 15:46:07 +0200 Subject: [PATCH 1/3] Always apply isolation when u:dir is set --- spec/formatting.md | 8 ++++++-- spec/u-namespace.md | 4 +++- test/tests/u-options.json | 26 ++++++++++++++++++++++++-- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/spec/formatting.md b/spec/formatting.md index 4ac0ca295b..c5e3163409 100644 --- a/spec/formatting.md +++ b/spec/formatting.md @@ -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. diff --git a/spec/u-namespace.md b/spec/u-namespace.md index dabbcc70f2..a5122ab9c9 100644 --- a/spec/u-namespace.md +++ b/spec/u-namespace.md @@ -68,7 +68,8 @@ 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. @@ -76,6 +77,7 @@ 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_: diff --git a/test/tests/u-options.json b/test/tests/u-options.json index de0fb0891f..ee42765886 100644 --- a/test/tests/u-options.json +++ b/test/tests/u-options.json @@ -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" } + ] }, { @@ -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}", From 064015924f7496451768c8523a9a846a053b863c Mon Sep 17 00:00:00 2001 From: Eemeli Aro Date: Sun, 17 Nov 2024 17:50:35 +0200 Subject: [PATCH 2/3] Add explicit default "inherit" value --- spec/formatting.md | 4 ++-- spec/u-namespace.md | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/spec/formatting.md b/spec/formatting.md index c5e3163409..5aaafb96e9 100644 --- a/spec/formatting.md +++ b/spec/formatting.md @@ -939,8 +939,8 @@ The _Default Bidi Strategy_ is defined as follows: 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. + 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 and `isolate` is False, diff --git a/spec/u-namespace.md b/spec/u-namespace.md index a5122ab9c9..a14af647d3 100644 --- a/spec/u-namespace.md +++ b/spec/u-namespace.md @@ -84,6 +84,8 @@ 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_, + without isolation of the _expression_ value For other values, a _Bad Option_ error is emitted and the value of the `u:dir` option is ignored. From 3963d9238b4f8d47eddf17d2908b4ab0352c6748 Mon Sep 17 00:00:00 2001 From: Eemeli Aro Date: Sun, 17 Nov 2024 18:11:18 +0200 Subject: [PATCH 3/3] Update spec/u-namespace.md Co-authored-by: Addison Phillips --- spec/u-namespace.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spec/u-namespace.md b/spec/u-namespace.md index a14af647d3..03a7134313 100644 --- a/spec/u-namespace.md +++ b/spec/u-namespace.md @@ -84,8 +84,9 @@ 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_, - without isolation of the _expression_ value +- `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.