Bp spec bidi
Draft Best Practices for Specification Developers
Handling text fragments
The following recommendations should be taken into account if you are working on a specification that passes around user-readable text in small chunks.
- It must be possible to indicate the language of the text as a whole.
- It should be possible to indicate parts of the text where the language changes.
- In a multilingual environment it must be possible for the user to receive text in the language they prefer. This may depend on implicit user preferences based on the user's system or browser setup, or on user settings explicitly negotiated with the user.
- It must be possible to indicate the direction of the text as a whole, ie. set the overall base direction, to either ltr or rtl.
- It must be possible to also set the direction to auto. This means that the base direction will be determined by examining the text itself. A typical approach here would be to set the direction based on the first strong directional character outside of any markup.
- If the overall base direction is set to auto, the direction of the content should be determined on a paragraph by paragraph basis.
- It must be possible to indicate parts of the text where the base direction changes. If markup is available, this is the preferred method. Otherwise your specification must require that Unicode control characters are recognized by the receiving application, and correctly implemented.
- To indicate the start/end of a line or paragraph you should use 'start' and 'end' rather than 'left' and 'right'.
- To indicate the beginning and end of a block of text you should use 'before' and 'after', rather than 'top' and 'bottom'.
General bidi guidelines
- provide dedicated attributes for control of base direction and bidirectional overrides; do not rely on the user applying style properties to arbitrary markup to achieve bidi control
- allow bidi attributes on all elements that contain text content
- provide attributes that allow the user to (a) create an embedded base direction or (b) override the bidirectional algorithm altogether; the attribute should allow the user to set the direction to ltr or rtl in either of these two scenarios.
- declare the default base direction of the document to be LTR.
- make it possible to set the base direction on the top level element in a document
- ensure that the base direction set on an element is applied to all contained elements and text (unless, of course, the base direction is changed by a contained element using the directional attributes)
- provide a span-like element that can be used for any text content to change the base direction in the absence of other markup
- avoid natural language text in elements that only allow for plain text and in attribute values.