Skip to content

Commit 6657b80

Browse files
authored
[DESIGN] Update bidi design document to show proposed design (#871)
* [DESIGN] Update bidi design document to show proposed design The design I actually think we should adopt is the "hybrid approaches" one. This is a necessary first step on the highway to UAX31 compliance and I think is responsibly contained/managed. It is a hybrid approach, in that it permits testable strict implementations to be created (particularly for message serialization). This PR consists of moving text around. I added one "pro" to one option also. * Address comments
1 parent d4fb35b commit 6657b80

File tree

1 file changed

+49
-22
lines changed

1 file changed

+49
-22
lines changed

exploration/bidi-usability.md

Lines changed: 49 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,39 @@ Not allowing these to mix could produce annoying parse errors.
273273
274274
_Describe the proposed solution. Consider syntax, formatting, errors, registry, tooling, interchange._
275275
276+
I propose adopting a hybrid approach in which we permit "super-loose isolation".
277+
This allows user to include isolates and strongly directional characters into the whitespace
278+
portions of the syntax in order to make messages appear correctly.
279+
280+
The second part of the hybrid approach would be to recommend ("SHOULD") the "strict isolation"
281+
design for serializers.
282+
(Note that "strict" and "super-loose" use non-identical productions with the name `bidi`.
283+
These serve different purposes and are consistent with strict being narrower with super-loose.)
284+
This syntax is a subset of the super-loose syntax and can be applied selectively to messages that
285+
have RTL sequences or which have problematic display.
286+
287+
288+
## Alternatives Considered
289+
290+
_What other solutions are available?_
291+
_How do they compare against the requirements?_
292+
_What other properties they have?_
293+
294+
### Nothing
295+
We could do nothing.
296+
297+
A likely outcome of doing nothing is that RTL users would insert bidi controls into
298+
_messages_ in an attempt to make the _pattern_ and/or _placeholders_ display correctly.
299+
These controls would become part of the output of the _message_,
300+
showing up inappropriately at runtime.
301+
Because these characters are invisible, users might be very frustrated trying to manage
302+
the results or debug what is wrong with their messages.
303+
304+
By contrast, if users insert too many or the wrong controls using the recommended design,
305+
the _message_ would still be functional and would emit no undesired characters.
306+
307+
### LTR Messages with isolating sequences
308+
276309
The syntax of a _message_ assumes a left-to-right base direction
277310
both for the complete text of the _message_ as well as for each line (paragraph)
278311
contained therein.
@@ -383,7 +416,7 @@ ns-separator = [bidi] ":"
383416
bidi = [ %x200E-200F / %x061C ]
384417
```
385418

386-
### Open Issues with Proposed Design
419+
**Open Issues**
387420

388421
The ABNF changes found above put isolates and strongly directional marks into specific locations,
389422
such as directly next to `{`/`}`/`{{`/`}}` markers
@@ -393,32 +426,24 @@ A more permissive design would add the isolates and strongly directional marks t
393426
whitespace in the syntax and depend on users/editors to appropriately pair or position the marks
394427
to get optimal display.
395428

396-
## Alternatives Considered
397-
398-
_What other solutions are available?_
399-
_How do they compare against the requirements?_
400-
_What other properties they have?_
401-
402-
### Nothing
403-
We could do nothing.
404-
405-
A likely outcome of doing nothing is that RTL users would insert bidi controls into
406-
_messages_ in an attempt to make the _pattern_ and/or _placeholders_ display correctly.
407-
These controls would become part of the output of the _message_,
408-
showing up inappropriately at runtime.
409-
Because these characters are invisible, users might be very frustrated trying to manage
410-
the results or debug what is wrong with their messages.
411-
412-
By contrast, if users insert too many or the wrong controls using the recommended design,
413-
the _message_ would still be functional and would emit no undesired characters.
414429

415430
### Super-loose isolation
416431

417432
Add isolates and strongly directional marks to required and optional whitespace in the syntax.
418433
This would permit users to get the effects described by the above design,
419434
as long as they use isolates/marks in a "responsible" way.
420435

421-
(Omitting other changes found in #673)
436+
The exception to this is the namespace separator, used in `identifier`.
437+
This requires the ability to insert isolates or strongly directional marks
438+
between the namespace and name portions, where whitespace is not permitted.
439+
This is the only location in the syntax where such characters might be needed
440+
but whitespace is not at least optional.
441+
This could be defined as:
442+
```abnf
443+
ns-separator = [bidi] ":" [bidi]
444+
```
445+
446+
Here are the other ABNF changes:
422447

423448
```abnf
424449
; strongly directional marks and bidi isolates
@@ -447,7 +472,7 @@ s = ( SP / HTAB / CR / LF / %x3000 )
447472
### Strict isolation all the time
448473

449474
Apply bidi isolates in a strict way.
450-
The main differences to the proposed solution is:
475+
In this design:
451476
1. The open/close isolate characters are syntactically required to be paired.
452477
This introduces parse errors for unpaired invisible characters,
453478
which could lead to bad user experiences.
@@ -467,7 +492,7 @@ markup = "{" [s] "#" identifier [bidi] *(s option) *(s attribute) [s] ["
467492
/ "{" [s] "/" identifier [bidi] *(s option) *(s attribute) [s] "}" ; close
468493
/ "{" LRI [s] "/" identifier [bidi] *(s option) *(s attribute) [s] close-isolate "}" ; close
469494
identifier = [(namespace ns-separator)] name
470-
ns-separator = [bidi] ":"
495+
ns-separator = [bidi] ":" [bidi]
471496
bidi = [ %x200E-200F / %x061C ]
472497
```
473498

@@ -610,6 +635,8 @@ adherence to the stricter grammar.
610635
syntax errors
611636
- Provides a foundation for tools to claim strict conformance and message normalization
612637
as well as guidance to implementers to make them want to adopt it
638+
- Messages are valid while being edited (such as when the open or close isolate has been
639+
inserted but the corresponding opposite isolate hasn't been entered yet)
613640

614641
**Cons**
615642
- Requires additional effort to maintain the grammar

0 commit comments

Comments
 (0)