Bugzilla – Bug 218
<ruby> support. This isn't very compatible with IE, but it seems to be relatively compatible with the Web's usage of ruby.
Last modified: 2008-06-25 13:45:07 CEST
Index: source =================================================================== --- source (revision 1703) +++ source (revision 1704) @@ -8956,8 +8956,6 @@ <h3>Text-level semantics</h3><!-- XXX ew, find a better section name --> - <!-- XXX ruby (delayed until someone can define it with error handling rules) --> - <h4>The <dfn><code>a</code></dfn> element</h4> <dl class="element"> @@ -10999,6 +10997,129 @@ + <h4>The <dfn><code>ruby</code></dfn> element</h4> + + <dl class="element"> + <dt>Categories</dt> + <dd><span>Phrasing content</span>.</dd> + <dt>Contexts in which this element may be used:</dt> + <dd>Where <span>phrasing content</span> is expected.</dd> + <dt>Content model:</dt> + <dd>One or more groups of: <span>phrasing content</span> followed either by a single <code>rt</code> element, or an <code>rp</code> element, an <code>rt</code> element, and another <code>rp</code> element.</dd> + <dt>Element-specific attributes:</dt> + <dd>None.</dd> + <dt>DOM interface:</dt> + <dd>Uses <code>HTMLElement</code>.</dd> + </dl> + + <p>The <code>ruby</code> element allows one or more spans of + phrasing content to be marked with ruby annotations.</p> + + <p>A <code>ruby</code> element represents the spans of phrasing + content it contains, ignoring all the child <code>rt</code> and + <code>rp</code> elements and their descendants. Those spans of + phrasing content have associated annotations created using the + <code>rt</code> element.</p> + + <div class="example"> + + <p>In this example, each ideograph in the text <span + lang="ja">斎藤信男</span> is annotated with + its reading.</p> + + <pre lang="ja">... <ruby> + 斎 <rt> さい </rt> + 藤 <rt> とう </rt> + 信 <rt> のぶ </rt> + 男 <rt> お </rt> +</ruby> ...</pre> + + <p>This might be rendered as:</p> + + <p><img src="images/sample-ruby.png" + alt="The four main ideographs, each with its reading annotation rendered in a smaller font above it."></p> + + </div> + + + <h4>The <dfn><code>rt</code></dfn> element</h4> + + <dl class="element"> + <dt>Categories</dt> + <dd>None.</dd> + <dt>Contexts in which this element may be used:</dt> + <dd>As a child of a <code>ruby</code> element.</dd> + <dt>Content model:</dt> + <dd><span>Phrasing content</span>.</dd> + <dt>Element-specific attributes:</dt> + <dd>None.</dd> + <dt>DOM interface:</dt> + <dd>Uses <code>HTMLElement</code>.</dd> + </dl> + + <p>The <code>rt</code> element marks the ruby text component of a + ruby annotation.</p> + + <p>An <code>rt</code> element that is a child of a <code>ruby</code> + element represents an annotation (given by its children) for the + zero or more nodes of phrasing content that immediately precedes it + in the <code>ruby</code> element, ignoring <code>rp</code> + elements.</p> + + <p>An <code>rt</code> element that is not a child of a + <code>ruby</code> element represents the same thing as its + children.</p> + + + <h4>The <dfn><code>rp</code></dfn> element</h4> + + <dl class="element"> + <dt>Categories</dt> + <dd>None.</dd> + <dt>Contexts in which this element may be used:</dt> + <dd>As a child of a <code>ruby</code> element, either immediately before or immediately after an <code>rt</code> element.</dd> + <dt>Content model:</dt> + <dd>If the <code>rp</code> element is immediately after an <code>rt</code> element that is immediately preceded by another <code>rp</code> element: a single character from Unicode character class Pe.</dd> + <dd>Otherwise: a single character from Unicode character class Ps.</dd> + <dt>Element-specific attributes:</dt> + <dd>None.</dd> + <dt>DOM interface:</dt> + <dd>Uses <code>HTMLElement</code>.</dd> + </dl> + + <p>The <code>rp</code> element can be used to provide parentheses + around a ruby text component of a ruby annotation, to be shown by + user agents that don't support ruby annotations.</p> + + <p>An <code>rp</code> element that is a child of a <code>ruby</code> + element represents nothing and it and its contents must be + ignored. An <code>rp</code> element whose parent element is not a + <code>ruby</code> element represents the same thing as its + children.</p> + + <div class="example"> + + <p>The example above, in which each ideograph in the text <span + lang="ja">斎藤信男</span> is annotated with + its reading, could be expanded to use <code>rp</code> so that in + legacy user agentthe readings are in parentheses:</p> + + <pre lang="ja">... <ruby> + 斎 <rp>(</rp><rt>さい</rt><rp>)</rp> + 藤 <rp>(</rp><rt>とう</rt><rp>)</rp> + 信 <rp>(</rp><rt>のぶ</rt><rp>)</rp> + 男 <rp>(</rp><rt>お</rt><rp>)</rp> +</ruby> ...</pre> + + <p>In conforming user agents the rendering would be as above, but + in user agents that do not support ruby, the rendering would + be:</p> + + <pre lang="ja">... 斎 (さい) 藤 (とう) 信 (のぶ) 男 (お) ...</pre> + + </div> + + <h4>Usage summary</h4> <p class="big-issue">We need to summarize the various elements, in @@ -42227,7 +42348,8 @@ <p>When the steps below require the UA to <dfn>generate implied end tags</dfn>, then, while the <span>current node</span> is a <code>dd</code> element, a <code>dt</code> element, an - <code>li</code> element, or a <code>p</code> element, the UA must + <code>li</code> element, a <code>p</code> element, an + <code>rp</code> element, or an <code>rt</code> element, the UA must pop the <span>current node</span> off the <span>stack of open elements</span>.</p> @@ -44022,6 +44144,40 @@ </dd> + <dt>A start tag whose tag name is one of: "rp", "rt"</dt> + <dd> + + <!-- the parsing rules for ruby really don't match IE much at all, + but in practice the markup used is very simple and so strict + compatibility with IE isn't required. For example, as defined + here we get very, very different behaviour than IE for + pathological cases like: + + <ruby><ol><li><p>a<rt>b + <ruby>a<rt>b<p>c + + But in practice most ruby markup falls into these cases: + + <ruby>a<rt>b</ruby> + <ruby>a<rp>b<rt>c<rp>d</ruby> + <ruby>a<rt>b</rt></ruby> + <ruby>a<rp>b</rp><rt>c</rt><rp>d</rp></ruby> + + --> + + <p>If the <span>stack of open elements</span> <span title="has an + element in scope">has a <code>ruby</code> element in scope</span>, + then <span>generate implied end tags</span>. If the <span>current + node</span> is not then a <code>ruby</code> element, this is a + <span>parse error</span>; pop all the nodes from the <span>current + node</span> up to the node immediately before the bottommost + <code>ruby</code> element on the <span>stack of open + elements</span>.</p> + + <p><span>Insert an HTML element</span> for the token.</p> + + </dd> + <dt>An end tag whose tag name is "br"</dt> <dd> <p><span>Parse error</span>. Act as if a start tag token with