Ruby use cases from the JLReq document

This document sets out to propose ways of using ruby annotation and ruby styling in CSS to achieve various results in Japanese. It uses the examples in JLREQ, since these cover most normal cases.

[1] Figure 105: Ruby and base characters

Ruby and base characters

This is standard mono-ruby phonetic annotation.

  1. XHTML markup:
    <ruby><rb>君</rb><rt>くん</rt></ruby><ruby><rb>子</rb><rt>し</rt></ruby><ruby><rb>和</rb><rt>わ</rt></ruby>して<ruby><rb>同</rb><rt>どう</rt></ruby>ぜず。

  2. HTML5 markup:
    <ruby><rt>くん</rt><rt>し</rt></ruby><ruby><rt>わ</rt></ruby>して<ruby><rt>どう</rt></ruby>ぜず。

Styling

All default settings

ie.
ruby-position: before;
ruby-align: auto; ie. distribute-space
ruby-overhang: auto; overhang allowed on either side as permitted by rules of user agent vis-a-vis adjacent characters

How it looks in this browser

XHTML: くんしてどうぜず。

HTML5: くんしてどうぜず。

[2] Figure 106: Example of ruby annotation per kanji character.

ruby annotation per kanji character

More ruby marked up phonetically character by character.

  1. XHTML markup:
    <ruby><rb>人</rb><rt>ひと</rt></ruby><ruby><rb>誨</rb><rt>おし</rt></ruby>えて<ruby><rb>倦</rb><rt>う</rt></ruby>まず

  2. HTML5 markup:
    <ruby><rt>ひと</rt></ruby><ruby><rt>おし</rt></ruby>えて<ruby><rt>う</rt></ruby>まず

Styling

All default settings

ie.
ruby-position: before;
ruby-align: auto; ie. distribute-space
ruby-overhang: auto; overhang allowed on either side as permitted by rules of user agent vis-a-vis adjacent characters

How it looks in this browser

XHTML: ひとおしえてまず

HTML5: ひとおしえてまず

[3] Figure 107: Mono-ruby for jukugo

2-2

Phonetic annotation of jukugo (kanji compound nouns), but using a character-by-character approach.

Markup

  1. XHTML simple
    <ruby><rb>鬼</rb><rt>き</rt></ruby><ruby><rb>門</rb><rt>もん</rt></ruby><ruby><rb>方</rb><rt>ほう</rt></ruby><ruby><rb>角</rb><rt>がく</rt></ruby><ruby><rb>凝</rb><rt>ぎょう</rt></ruby><ruby><rb>視</rb><rt>し</rt></ruby>する

  2. HTML5 This works fine, given the assumption that you can break lines between ruby bases within a ruby element, and that ruby text never overlaps adjacent base characters within a ruby element.

    <ruby><rt>き</rt><rt>もん</rt></ruby><ruby><rt>ほう</rt><rt>がく</rt></ruby><ruby><rt>ぎょう</rt><rt>し</rt></ruby>する

  3. XHTML complex.
    <ruby><rbc><rb>鬼</rb><rb>門</rb></rbc><rtc><rt>き</rt><rt>もん</rt></rtc></ruby><ruby><rbc><rb>方</rb><rb>角</rb></rbc><rtc><rt>ほう</rt><rt>がく</rt></rtc></ruby><ruby><rbc><rb>凝</rb><rb>視</rb></rbc><rtc><rt>ぎょう</rt><rt>し</rt></rtc></ruby>する

Styling

All default settings

ie.
ruby-position: before;
ruby-align: auto; ie. distribute-space
ruby-overhang: auto; overhang allowed on either side as permitted by rules of user agent vis-a-vis adjacent characters

How it looks in this browser

XHTML simple: もんほうがくぎょうする

HTML5: もんほうがくぎょうする

XHTML complex: もんほうがくぎょうする

[4] Figure 108: jukugo-ruby

jukugo ruby

The same jukugo but this time marked up where the basic unit is the word, but word-internal linebreaks are permitted, in which case you need to know which ruby text belongs to which base character. The third jukugo above is the complicated case, since the ruby text is distributed 3:1 across two base characters.

  1. XHTML complex. You could use two simple ruby elements for each of the first two compound words, and get the same result. You cannot for the last, since the ruby text is spread across both base characters, but (a) you have to be able to associate the right ruby text with the right base text in order to break a line between base characters (something you don't do with non-jukugo ruby), and (b) current default rules prevent ruby text from overlapping an adjacent base text element (which makes sense for the general case).

    <ruby><rbc><rb>鬼</rb><rb>門</rb></rbc><rtc><rt>き</rt><rt>もん</rt></rtc></ruby><ruby><rbc><rb>方</rb><rb>角</rb></rbc><rtc><rt>ほう</rt><rt>がく</rt></rtc></ruby><ruby><rbc><rb>凝</rb><rb>視</rb></rbc><rtc><rt>ぎょう</rt><rt>し</rt></rtc></ruby>する

  2. HTML5. Assuming that HTML5 ruby allows you to break a line between ruby bases inside a ruby element, there would have to be some rule to enable the ruby within a ruby element to be evenly spread across the base kanji for the 3rd compound word. Normally you wouldn't want that to happen, since normally ruby text doesn't cross adjacent ruby boundaries.

    <ruby><rt>き</rt><rt>もん</rt></ruby><ruby><rt>ほう</rt><rt>がく</rt></ruby><ruby><rt>ぎょう</rt><rt>し</rt></ruby>する

Styling

There is currently no way to achieve proper jukugo-ruby distribution of ruby text, since the CSS spec says that no ruby text can cross base text boundaries.

There needs to be a flag that allows overlap within a given context.

On the other hand, firefox(+extension) and IE both do seem to manage it, presumably by treating all rtc contents as group-ruby. However, this is still a simple example, later examples of jukugo-ruby will show that the distribution rules are more complex than those for group-ruby.

How it looks in this browser

XHTML: もんほうがくぎょうする

HTML5: もんほうがくぎょうする

[5] Figure 110: Jukuji readings

jukuji

Jukuji are phonetic readings where the individual sounds cannot be easily mapped to specific base characters. The annotation should be handled as group-ruby, ie. a mapping between the ruby text and ruby base as a whole, and no possibility of line break inside.

Markup will be shown for the item on the left.

  1. XHTML Simple markup is ideal.

    <ruby><rb>紫陽花</rb><rt>あじさい</rt></ruby>

  2. HTML5 This works fine, given the assumption that you cannot break line from the beginning of the ruby base to the end of the associated ruby text.

    <ruby>紫陽花<rt>あじさい</rt></ruby>

Styling

All default settings

ie.
ruby-position: before;
ruby-align: auto; ie. distribute-space
ruby-overhang: auto; overhang allowed on either side as permitted by rules of user agent vis-a-vis adjacent characters

How it looks in this browser

XHTML: 紫陽花あじさい

HTML5: 紫陽花あじさい

[6] Figure 111: Group-ruby

group-ruby

This ruby describes the meaning of the base text as a whole, rather than the pronunciation. The ruby element should be wrapped as a single unit at the end of a line.

Markup will be shown for the item on the left.

  1. XHTML simple
    <ruby><rb>境界面</rb><rt>インターフェース</rt></ruby>

  2. HTML5 This works fine, given the assumption that you cannot break line from the beginning of the ruby base to the end of the associated ruby text.

    <ruby>境界面<rt>インターフェース</rt></ruby>

Styling

All default settings

ie.
ruby-position: before;
ruby-align: auto; ie. distribute-space
ruby-overhang: auto; overhang allowed on either side as permitted by rules of user agent vis-a-vis adjacent characters

How it looks in this browser

XHTML: 境界面インターフェース

HTML5: 境界面インターフェース

[7] Figure 112: Group-ruby with Latin characters

group-ruby with Latin characters

Markup will be shown for the item on the left.

  1. XHTML simple
    <ruby><rb>編集者</rb><rt>editor</rt></ruby>

  2. HTML5 This works fine, given the assumption that you cannot break line from the beginning of the ruby base to the end of the associated ruby text.

    <ruby>編集者<rt>editor</rt></ruby>

Styling

All default settings

ie.
ruby-position: before;
ruby-align: auto; ie. distribute-space for kana, centre for latin
ruby-overhang: auto; overhang allowed on either side as permitted by rules of user agent vis-a-vis adjacent characters

How it looks in this browser

XHTML: 編集者editor

HTML5: 編集者editor

[8] Figure 117: Ruby on both sides

Ruby on both sides

Phonetic annotation on the right, semantic information on the left in this example.

Note that semantic information is usually group-ruby, whereas phonetic is usually mono-ruby or jukugo-ruby. This means that there are usually a different number of ruby text items on one side than on the other - resulting in a need for the use of the span attribute.

Markup

  1. XHTML complex. Complex markup is needed to allow for ruby text on both sides of the base text and to manage the different number of items above and below.

    <ruby><rbc><rb>東</rb><rb>南</rb></rbc><rtc><rt>とう</rt><rt>なん</rt></rtc><rtc><rt rbspan="2">たつみ</rt></rtc></ruby>の方角

There is no way to do this using HTML5 markup.

Styling

ruby-position: after; on the second rtc, otherwise defaults

All other styles can be set to defaults, ie.
ruby-position: before;
ruby-align: auto; ie. distribute-space
ruby-overhang: auto; overhang allowed on either side as permitted by rules of user agent vis-a-vis adjacent characters

If complex jukugo behaviour was required for the phonetic notation on the right, eg. with a three-kanji compound with 1:3:1 ruby kana, it would be necessary to apply some style to the right side only to make it follow jukugo distribution behaviour.

How it looks in this browser

XHTML: とうなんたつみの方角

[9] Figure 119: Positioning of nakatsuki and katatsuki ruby

image 119

These are all scenarios for katatsuki (ie. where nominally the ruby text starts at the start edge of the base text).

  1. XHTML

    版面の<ruby><rb>地</rb><rt>ち</rt></ruby>

  2. HTML5

    版面の<ruby><rt>ち</rt></ruby>

Styling katatsuki

ruby-align: start;

Otherwise defaults, ie.
ruby-position: before;
ruby-overhang: auto; overhang allowed on either side as permitted by rules of user agent vis-a-vis adjacent characters

This would work if applied to this specific bit of ruby markup, but jlreq seems to imply that a setting of katatsuki would work like this for one kana per kanji, but slightly differently for three or more kana per kanji - see [10]. It does seem to be a bit of a hassle to have to apply different styling on a ruby by ruby basis, depending on the number of kana. Perhaps we need a 'katatsuki' value for ruby-align and tell the user agent to follow the jlreq rules for implementation?

How it looks in this browser

XHTML: 版面の

HTML5: 版面の

Styling nakatsuki

All default settings

ie.
ruby-position: before;
ruby-overhang: auto; overhang allowed on either side as permitted by rules of user agent vis-a-vis adjacent characters

How it looks in this browser

XHTML: 版面の

HTML5: 版面の

[10] Figure 122: Positioning of mono-ruby

Positioning of mono-ruby

These are all scenarios for a document where a single ruby and single base character are set katatsuki (ie. where nominally the ruby text starts at the start edge of the base text).

  1. XHTML

    後/の<ruby><rb>旬</rb><rt>しゅん</rt></ruby>に/又

  2. HTML5

    後/の<ruby><rt>しゅん</rt></ruby>に/又

Styling

This is not simply ruby-align:start, since afaict from reading the CSS spec that would prevent overlap before the base, and forcing a gap after the base character in the example on the bottom-left, and removing the gap before the base character in the bottom-right example.

It seems we need a way to say 'use start where you can, but otherwise distribute and overlap as per the algorithm in jlreq'.

Alternatively, this could be coded by applying different styling to each individual ruby (eg. ruby-align: end for the bottom-left, and ruby-align: center for the bottom-right example, but that's not appealing.

How it looks in this browser

XHTML:

しゅん

しゅん

しゅん

しゅん

HTML5:

しゅん

しゅん

しゅん

しゅん

[11] Figure 123: Group ruby

Positioning of mono-ruby

  1. XHTML

    <ruby><rb>冊子体</rb><rt>コーデックス</rt></ruby>

  2. HTML5

    <ruby>冊子体<rt>コーデックス</rt></ruby>

Styling

All default settings

ie.
ruby-position: before;
ruby-align: auto; ie. distribute-space, although in this case the size of ruby and base are the same, so no distribution happens
ruby-overhang: auto; overhang allowed on either side as permitted by rules of user agent vis-a-vis adjacent characters

How it looks in this browser

XHTML: は冊子体コーデックス

HTML5: は冊子体コーデックス

[12] Figure 124: Group ruby, shorter ruby

image 124

The markup illustrates the right-hand example.

  1. XHTML

    <ruby><rb>利用許諾</rb><rt>ライセンス</rt></ruby>

  2. HTML5

    <ruby>利用許諾<rt>ライセンス</rt></ruby>

Styling

All default settings.

ie.
ruby-position: before;
ruby-align: auto; ie. distribute-space
ruby-overhang: auto; overhang allowed on either side as permitted by rules of user agent vis-a-vis adjacent characters

How it looks in this browser

XHTML: 利用許諾ライセンス

HTML5: 利用許諾ライセンス

[14] Figure 125: Group ruby, shorter ruby ending at edges of base

image 125

The markup illustrates the right-hand example.

  1. XHTML

    <ruby><rb>利用許諾</rb><rt>ライセンス</rt></ruby>

  2. HTML5

    <ruby>利用許諾<rt>ライセンス</rt></ruby>

Styling

ruby-align: distribute-letter;

Otherwise defaults, ie.
ruby-position: before;
ruby-overhang: auto; overhang allowed on either side as permitted by rules of user agent vis-a-vis adjacent characters

How it looks in this browser

XHTML: 利用許諾ライセンス

HTML5: 利用許諾ライセンス

[15] Figure 126: Group ruby, much shorter ruby

image 126

The image shows how at each end ruby is widened, to make it look better.

  1. XHTML

    <ruby><rb>なげきの聖母像</rb><rt>ピエタ</rt></ruby>

  2. HTML5

    <ruby>なげきの聖母像<rt>ピエタ</rt></ruby>

Styling

There is no CSS property value that would widen the ruby text like this. It could be done by the implementation though.

Otherwise defaults, ie.
ruby-position: before;
ruby-align: auto; ie. distribute-space
ruby-overhang: auto; overhang allowed on either side as permitted by rules of user agent vis-a-vis adjacent characters

How it looks in this browser

XHTML: なげきの聖母像ピエタ

HTML5: なげきの聖母像ピエタ

[16] Figure 127: Group ruby, longer ruby

image 127

The markup illustrates the right-hand example.

  1. XHTML

    <ruby><rb>境界面</rb><rt>インターフェース</rt></ruby>

  2. HTML5

    <ruby>境界面<rt>インターフェース</rt></ruby>

Styling

All defaults, ie.
ruby-position: before;
ruby-align: auto; ie. distribute-space
ruby-overhang: auto; overhang allowed on either side as permitted by rules of user agent vis-a-vis adjacent characters

How it looks in this browser

XHTML: 境界面インターフェース

HTML5: 境界面インターフェース

[17] Figure 128: Group ruby, longer ruby, base characters aligned to edges

image 128

The markup illustrates the right-hand example.

  1. XHTML

    <ruby><rb>境界面</rb><rt>クライアント</rt></ruby>

  2. HTML5

    <ruby>境界面<rt>クライアント</rt></ruby>

Styling

ruby-align: distribute-letter;

Otherwise defaults, ie.
ruby-position: before;
ruby-overhang: auto; overhang allowed on either side as permitted by rules of user agent vis-a-vis adjacent characters

How it looks in this browser

XHTML: 境界面インターフェース

HTML5: 境界面インターフェース

Version: $Id: index.html,v 1.8 2010/09/24 13:37:13 rishida Exp $