11.4 The bidirectional support challenge

The challenge for the stylesheet writer is to recognize when it is necessary to add marks or add embedding levels in the flow.

  • Always using a single stream of character information will only work if all of the text is in the same direction as the inline-progression direction.

    • An internationally used stylesheet would need to respect the possibility of mixing weak and neutral characters with strong characters of both directions.

  • E.g., consider mixing boilerplate text with authored text.

    • One may assume that the authored text was correctly presented to the author while being worked on, so the content could be formatted as entered without special concerns.

    • If English boilerplate text is to be abutted to language text of an arbitrary language, weak characters in the boilerplate text might be inadvertently influenced by the strong characters of the authored text.

      • The influence could rearrange characters or flip the rendering of mirrored characters found in the boilerplate.

    • Add LRM ( ‎ ) before and after the left-to-right boilerplate text;

    • add RLM ( ‏ ) before and after the right-to-left boilerplate text.

Be careful when formatting generated content, such as table of contents entries.

  • Leaders and page numbers follow the arbitrary title text.

  • The content of the title is abutted to the leaders and page numbers.

  • Wrapping the leaders and page numbers in marks will protect them from being influenced by the characters at the end of the title.

The sample files in Example 11-3 and Example 11-4 illustrate the importance of adding marks.

  • The table of contents entries are extracting arbitrary title contents.

  • If the characters preceding and following the title are not protected with strong marks, the display is corrupted;

    • the weak characters of the boilerplate are influenced by the strong characters of the title.

Example 11-3 formats two tables of contents, the first without protection and the second protecting the boilerplate of the entries from the arbitrary text directions of the characters in the titles.

Example 11-3 Adding marks
 Line 01 <!ENTITY LRM "&#x200e;">      02 <!ENTITY RLM "&#x200f;">      03 ...      04 <block space-after=".5cm">      05   This is a table of contents without using marks:      06 </block>      07 <xsl:for-each select="/doc/section">      08   <block text-align-last="justify">      09     <xsl:value-of select="position()"/>.      10     <xsl:value-of select="title"/>      11     (<xsl:value-of select="count(subsection)"/>)      12     <leader leader-pattern="dots"/>      13     <page-number-citation ref-id="{generate-id(.)}"/>      14   </block>      15 </xsl:for-each>      16       17 <block space-before="1.5cm" space-after=".5cm">      18   This is a table of contents using marks:      19 </block>      20 <xsl:for-each select="/doc/section">      21   <block text-align-last="justify">      22     <xsl:value-of select="position()"/>.  &LRM;  23     <xsl:apply-templates select="title"/>      24  &LRM;  (<xsl:value-of select="count(subsection)"/>)      25     <leader leader-pattern="dots"/>      26     <page-number-citation ref-id="{generate-id(.)}"/>      27   </block>      28 </xsl:for-each> 

Example 11-4 includes titles utilizing text of different writing directions.

Example 11-4 A test file with mixed character directions
 Line 01 <!DOCTYPE doc [      02 <!ENTITY hebrew-test  "&#x05D1;&#x05D3;&#x05D9;&#x05E7;&#x05D4;      03                        &#x05E2;&#x05D1;&#x05E8;&#x05D9;&#x05EA;">      04 <!ENTITY arabic-test1 "&#x0625;&#x062e;&#x062a;&#x0628;&#x0627;">      05 <!ENTITY arabic-test2 "&#x0631; &#x0639;&#x0631;&#x0628;&#x064a;">      06 <!ENTITY arabic-test  "&arabic-test1;&arabic-test2;">      07 ]>      08 <doc>      09   <section>      10     <title>English Test</title>      11     <subsection>Sub 1 in English</subsection>      12     ...      13     <subsection>Sub 15 in English</subsection>      14   </section>      15   <section>      16     <title>&hebrew-test;</title>      17     <subsection>Sub 1 in Hebrew</subsection>      18     ...      19     <subsection>Sub 14 in Hebrew</subsection>      20   </section>      21   <section>      22     <title>&arabic-test;</title>      23     <subsection>Sub 1 in Arabic</subsection>      24     ...      25     <subsection>Sub 14 in Arabic</subsection>      26   </section>      27   <section>      28     <title>Test Fran&#xe7;ais</title>      29     <subsection>Sub 1 in French</subsection>      30     ...      31     <subsection>Sub 12 in French</subsection>      32   </section> 

The formatted result in Figure 11-2 illustrates the impact of including the marks for protection from the characters of the titles.

Figure 11-2. Example of using marks

graphics/11fig02.gif

Note the behavior when the marks are not present (top rendering).

  • The right-to-left text influences the following weak characters " (14" and makes them all part of a right-to-left group .

    • The "(" character is displayed as ")" because it is a mirror character being displayed right-to-left.

  • The "14" still renders left-to-right because the grouping isn't powerful enough to override the inherent writing direction of the digits.

  • The original ")" and the following space are influenced by the leader and the writing direction of the line, which is left to right, so the mirroring character doesn't change.



Definitive XSL-FO
Definitive XSL-FO
ISBN: 0131403745
EAN: 2147483647
Year: 2002
Pages: 99
Authors: G. Ken Holman

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net