Skip to content
25 changes: 13 additions & 12 deletions spec/formatting.md
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,8 @@ Implementations MAY provide other _bidirectional isolation strategies_.

Implementations MAY supply a _bidirectional isolation strategy_ that performs no processing.

The _Default Bidi Strategy_ is defined as follows:
The _Default Bidi Strategy_ is defined as a function `B` from expressions
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linkify expressions.

This is weird? Where does B come from? Why is it a "function"? The text above this talks about "bidirectional isolation strategies". I think this needs to be different.

Perhaps:

The Default Bidi Strategy is defined as follows:

  1. Let out be an empty string to contain the formatted output of the message
  2. Let msgdir...
  3. For each expression exp in the pattern:
    1. If exp is a plain literal (text), append exp to out.
    2. If exp is an placeholder, let fmt be the formatted string representation of
      the resolved value of exp.
    3. Let dir be the directionality of fmt...
      // etc.
    4. Append fmt to out.
  4. Emit out as the formatted output of the message.

Note that we don't have a name for the non-placeholder bits of text in a pattern. I call them expressions here, but they aren't really expressions.

It would be even better if the section on formatting just above here defined how to make the string output. The "bidi strategy" then could be reference in that set of instructions ("apply the appropriate bidirectional isolation strategy to the contents of expression")

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I rewrote this imperatively instead of as a function. I also did a rewrite to call the components of a pattern a "part", and distinguish between text parts and placeholder parts.

to formatted strings, as follows.

1. Let `msgdir` be the directionality of the whole message,
one of « `'LTR'`, `'RTL'`, `'unknown'` ».
Expand All @@ -942,19 +943,19 @@ The _Default Bidi Strategy_ is defined as follows:
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
1. If `msgdir` is `'LTR'`
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.
`B(exp)` is `fmt`.
1. Else, `B(exp)` is
`fmt` prefixed with U+2066 LEFT-TO-RIGHT ISOLATE
and postfixed 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. `B(exp)` is
`fmt` prefixed with U+2067 RIGHT-TO-LEFT ISOLATE
and postfixed with U+2069 POP DIRECTIONAL ISOLATE.
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. `B(exp)` is
`fmt` prefixed with U+2068 FIRST STRONG ISOLATE
and postfixed with U+2069 POP DIRECTIONAL ISOLATE.