diff --git a/spec/formatting.md b/spec/formatting.md index 78a2a71347..fbab6e9c51 100644 --- a/spec/formatting.md +++ b/spec/formatting.md @@ -930,31 +930,39 @@ Implementations MAY supply a _bidirectional isolation strategy_ that performs no The _Default Bidi Strategy_ is defined as follows: +1. Let `out` be the empty string. 1. Let `msgdir` be the directionality of the whole message, one of « `'LTR'`, `'RTL'`, `'unknown'` ». These correspond to the message having left-to-right directionality, right-to-left directionality, and to the message's directionality not being known. -1. For each _expression_ `exp` in _pattern_: - 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 - 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. - 1. Else, if `dir` is `'RTL'`: - 1. In the formatted output, - prefix `fmt` with U+2067 RIGHT-TO-LEFT ISOLATE - and postfix it with U+2069 POP DIRECTIONAL ISOLATE. +1. For each part `part` in _pattern_: + 1. If `part` is a plain literal (text) part, append `part` to `out`. + 1. Else if `part` is a _markup_ _placeholder_: + 1. Let `fmt` be the formatted string representation of the _resolved value_ of `part`. + Note that this is normally the empty string. + 1. Append `fmt` to `out`. 1. Else: - 1. In the formatted output, - prefix `fmt` with U+2068 FIRST STRONG ISOLATE - and postfix it with U+2069 POP DIRECTIONAL ISOLATE. + 1. Let `fmt` be the formatted string representation of the _resolved value_ of `part`. + 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 `part` has a value other than `'inherit'`, + or False otherwise. + 1. If `dir` is `'LTR'`: + 1. If `msgdir` is `'LTR'` and `isolate` is False: + 1. Append `fmt` to `out`. + 1. Else: + 1. Append U+2066 LEFT-TO-RIGHT ISOLATE to `out`. + 1. Append `fmt` to `out`. + 1. Append U+2069 POP DIRECTIONAL ISOLATE to `out`. + 1. Else if `dir` is `'RTL'`: + 1. Append U+2067 RIGHT-TO-LEFT ISOLATE to `out.` + 1. Append `fmt` to `out`. + 1. Append U+2069 POP DIRECTIONAL ISOLATE to `out`. + 1. Else: + 1. Append U+2068 FIRST STRONG ISOLATE to `out`. + 1. Append `fmt` to `out`. + 1. Append U+2069 POP DIRECTIONAL ISOLATE to `out`. +1. Emit `out` as the formatted output of the message.