Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarification to default bidi strategy #968

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 30 additions & 3 deletions spec/formatting.md
Original file line number Diff line number Diff line change
Expand Up @@ -940,11 +940,12 @@ The _Default Bidi Strategy_ is defined as follows:
Note that this is normally the empty string.
1. Append `fmt` to `out`.
1. Else:
1. Let `fmt` be the formatted string representation of the _resolved value_ of `part`.
1. Let `dir` be the directionality of `fmt`,
1. Let `resval` be the _resolved value_ of `part`.
1. Let `fmt` be the formatted string representation of `resval`.
1. Let `dir` be the directionality of `resval`,
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'`,
True if the `u:dir` _option_ of `resval` has a value other than `'inherit'`,
or False otherwise.
1. If `dir` is `'LTR'`:
1. If `msgdir` is `'LTR'` and `isolate` is False:
Expand All @@ -963,4 +964,30 @@ The _Default Bidi Strategy_ is defined as follows:
1. Append U+2069 POP DIRECTIONAL ISOLATE to `out`.
1. Emit `out` as the formatted output of the message.

> [!NOTE]
> A _resolved value_ is derived from an _expression_
> together with a _formatting context_.)
> An implementation can use
> a representation of _resolved values_ that tracks
> everything needed to determine the directionality
> of the formatted string representation
> of a _resolved value_.
> This can be accomplished by incorporating
> the `isolate` flag used in step 2(iii),
> as well as the separate directionality annotation
> (one of « `'LTR'`, `'RTL'`, `'unknown'` »),
> into the representation of _resolved values_.
> Each _function handler_ can have its own means
> for determining the directionality annotation
> on the _resolved value_ it returns.
> Alternately, an implementation could simply
> determine directionality
> based on the locale.
Copy link
Collaborator

Choose a reason for hiding this comment

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

On further consideration, does this perhaps belong more appropriately in the section defining resolved values?

Specifically, I think we ought to expand a bit the paragraph starting on line 133 with something like this:

 In a _pattern_, the _resolved value_ of an _expression_ or _markup_ is used in its _formatting_.
+To account for the _Default Bidi Strategy_,
+the _resolved value_ of each _expression_ _placeholder_
+SHOULD include information about the directionality of its formatted string representation,
+as well as information about whether its formatted representation
+requires isolation from the surrounding text.

With that in place, this note could be simplified quite a bit, or even left out entirely.

Copy link
Member

Choose a reason for hiding this comment

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

This is pretty good, but I wouldn't limit it to the default bidi strategy, nor would I necessarily limit it to placeholders (other expressions might have a directionality so that the direction is commutative across assignments). Perhaps:

The resolved value of each expression
SHOULD include the string direction
of its formatted string representation,
as well as information about whether the message author
wants to suppress or require isolation from the surrounding message text,
such as is found in the Default Bidi Strategy.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Note that resolved value is an implementation-internal thing, and is therefore not expected to have public visibility during formatting. This means that attaching any normative requirements on it ought to be explicitly connected to some spec-defined consumer of that information, i.e. the Default Bidi Strategy.

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 made these changes. Also modified the example MessageValue definition to show what the directionality methods could look like.


> [!NOTE]
> Directionality SHOULD NOT be determined by introspecting
> the character sequence in the formatted string representation
> of `resval`.


eemeli marked this conversation as resolved.
Show resolved Hide resolved