Skip to content

Commit 38a2fea

Browse files
In bidi default strategy, make steps consistent with each other (#969)
* In bidi default strategy, make steps consistent with each other * Don't replace entire formatted output * Reformulate the default bidi strategy as a function * Rewrite imperatively * Add last line (emit output) * Fix formatting * Fix formatting harder * Fix formatting again * Remove erroneously-added file * Update spec/formatting.md Co-authored-by: Addison Phillips <[email protected]> * Fix indentation * Apply suggestions from Eemeli --------- Co-authored-by: Addison Phillips <[email protected]>
1 parent f0058ea commit 38a2fea

File tree

1 file changed

+29
-21
lines changed

1 file changed

+29
-21
lines changed

spec/formatting.md

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -928,31 +928,39 @@ Implementations MAY supply a _bidirectional isolation strategy_ that performs no
928928
929929
The _Default Bidi Strategy_ is defined as follows:
930930
931+
1. Let `out` be the empty string.
931932
1. Let `msgdir` be the directionality of the whole message,
932933
one of « `'LTR'`, `'RTL'`, `'unknown'` ».
933934
These correspond to the message having left-to-right directionality,
934935
right-to-left directionality, and to the message's directionality not being known.
935-
1. For each _expression_ `exp` in _pattern_:
936-
1. Let `fmt` be the formatted string representation of the _resolved value_ of `exp`.
937-
1. Let `dir` be the directionality of `fmt`,
938-
one of « `'LTR'`, `'RTL'`, `'unknown'` », with the same meanings as for `msgdir`.
939-
1. Let the boolean value `isolate` be
940-
True if the `u:dir` _option_ of the _resolved value_ of `exp` has a value other than `'inherit'`,
941-
or False otherwise.
942-
1. If `dir` is `'LTR'`:
943-
1. If `msgdir` is `'LTR'` in the formatted output
944-
and `isolate` is False,
945-
let `fmt` be itself
946-
1. Else, in the formatted output,
947-
prefix `fmt` with U+2066 LEFT-TO-RIGHT ISOLATE
948-
and postfix it with U+2069 POP DIRECTIONAL ISOLATE.
949-
1. Else, if `dir` is `'RTL'`:
950-
1. In the formatted output,
951-
prefix `fmt` with U+2067 RIGHT-TO-LEFT ISOLATE
952-
and postfix it with U+2069 POP DIRECTIONAL ISOLATE.
936+
1. For each part `part` in _pattern_:
937+
1. If `part` is a plain literal (text) part, append `part` to `out`.
938+
1. Else if `part` is a _markup_ _placeholder_:
939+
1. Let `fmt` be the formatted string representation of the _resolved value_ of `part`.
940+
Note that this is normally the empty string.
941+
1. Append `fmt` to `out`.
953942
1. Else:
954-
1. In the formatted output,
955-
prefix `fmt` with U+2068 FIRST STRONG ISOLATE
956-
and postfix it with U+2069 POP DIRECTIONAL ISOLATE.
943+
1. Let `fmt` be the formatted string representation of the _resolved value_ of `part`.
944+
1. Let `dir` be the directionality of `fmt`,
945+
one of « `'LTR'`, `'RTL'`, `'unknown'` », with the same meanings as for `msgdir`.
946+
1. Let the boolean value `isolate` be
947+
True if the `u:dir` _option_ of the _resolved value_ of `part` has a value other than `'inherit'`,
948+
or False otherwise.
949+
1. If `dir` is `'LTR'`:
950+
1. If `msgdir` is `'LTR'` and `isolate` is False:
951+
1. Append `fmt` to `out`.
952+
1. Else:
953+
1. Append U+2066 LEFT-TO-RIGHT ISOLATE to `out`.
954+
1. Append `fmt` to `out`.
955+
1. Append U+2069 POP DIRECTIONAL ISOLATE to `out`.
956+
1. Else if `dir` is `'RTL'`:
957+
1. Append U+2067 RIGHT-TO-LEFT ISOLATE to `out.`
958+
1. Append `fmt` to `out`.
959+
1. Append U+2069 POP DIRECTIONAL ISOLATE to `out`.
960+
1. Else:
961+
1. Append U+2068 FIRST STRONG ISOLATE to `out`.
962+
1. Append `fmt` to `out`.
963+
1. Append U+2069 POP DIRECTIONAL ISOLATE to `out`.
964+
1. Emit `out` as the formatted output of the message.
957965
958966

0 commit comments

Comments
 (0)