8000 csswg-drafts/css-ruby/Overview.html at 84d6ebc6c105c7c81ab886f07f042c8e613ad3cb · w3c/csswg-drafts · GitHub
Skip to content

Latest commit

 

History

History
2695 lines (1944 loc) · 122 KB

File metadata and controls

2695 lines (1944 loc) · 122 KB
</p>
<p>Once all ruby layout structures are properly parented,
the UA can start to associate bases with their annotations.
</p>
<p class="note" role="note">
Note that the UA is not required to create any of these anonymous boxes
(or the anonymous empty <i>intra-level white space</i> boxes in the pairing section)
in its internal structures,
as long as pairing and layout behaves as if they existed.
</p>
<h3 class="heading settled" data-level="2.3" id="ruby-pairing"><span class="secno">2.3. </span><span class="content">
Annotation Pairing</span><a class="self-link" href="#ruby-pairing"></a></h3>
<p>Annotation <dfn data-dfn-type="dfn" data-noexport="" id="pairing">pairing<a class="self-link" href="#pairing"></a></dfn> is the process of associating
<i>ruby annotations</i> with <i>ruby bases</i>.
Each <i>ruby annotation</i> is associated with one or more <i>ruby bases</i>,
and is said to <dfn data-dfn-type="dfn" data-noexport="" id="span">span<a class="self-link" href="#span"></a></dfn> those bases.
(A <i>ruby annotation</i> that <i>spans</i> multiple bases is called
a <dfn data-dfn-type="dfn" data-noexport="" id="spanning-annotation">spanning annotation<a class="self-link" href="#spanning-annotation"></a></dfn>.)
</p>
<p>A <i>ruby base</i> is can be associated with
only one <i>ruby annotation</i> per <i>annotation level</i>.
However, if there are multiple <i>annotation levels</i>,
it can be associated with multiple <i>ruby annotations</i>.</p>
<p>Once pairing is complete, ruby “column” units are defined,
each represented by a single <i>ruby base</i>
and one <i>ruby annotation</i> (possibly an empty, anonymous one)
from each <i>annotation level</i> in its <i>ruby segment</i>.</p>
<h4 class="heading settled" data-level="2.3.1" id="segment-pairing"><span class="secno">2.3.1. </span><span class="content">
Segment Pairing and Annotation Levels</span><a class="self-link" href="#segment-pairing"></a></h4>
<p>A ruby structure is divided into <dfn data-dfn-type="dfn" data-noexport="" id="ruby-segments">ruby segments<a class="self-link" href="#ruby-segments"></a></dfn>,
each consisting of a single <i>ruby base container</i>
followed by one or more <i>ruby annotation containers</i>.
Each <i>ruby annotation container</i> in a <i>ruby segment</i>
represents one <dfn data-dfn-type="dfn" data-lt="annotation level | level" data-noexport="" id="annotation-level">level<a class="self-link" href="#annotation-level"></a></dfn> of annotation for the base text:
the first one represents the first level of annotation,
the second one represents the second level of annotation,
and so on.
The <i>ruby base container</i> represents the <dfn data-dfn-type="dfn" data-noexport="" id="base-level">base level<a class="self-link" href="#base-level"></a></dfn>.
The <i>ruby base container</i> in each segment is thus paired
with each of the <i>ruby annotation containers</i> in that segment.
</p>
<p>In order to handle degenerate cases, some empty anonymous containers are assumed:
</p>
<ul>
<li>If the first child of a <i>ruby container</i> is a <i>ruby annotation container</i>,
an anonymous, empty <i>ruby base container</i> is assumed to exist before it.
<li>Similarly, if the <i>ruby container</i> contains consecutive <i>ruby base containers</i>,
anonymous, empty <i>ruby annotation containers</i> are assumed to exist between them.
</ul>
<p><i>Inter-segment white space</i> is effectively a <i>ruby segment</i> of its own.
</p>
<h4 class="heading settled" data-level="2.3.2" id="base-annotation-pairing"><span class="secno">2.3.2. </span><span class="content">
Unit Pairing and Spanning Annotations</span><a class="self-link" href="#base-annotation-pairing"></a></h4>
<p>Within a <i>ruby segment</i>,
each <i>ruby base</i> in the <i>ruby base container</i>
is paired with one <i>ruby annotation</i>
from each <i>ruby annotation container</i> in its <i>ruby segment</i>.
</p>
<p>If a <i>ruby annotation container</i> contains only
a single, anonymous <i>ruby annotation</i>,
then that <i>ruby annotation</i> is paired with (i.e. <i>spans</i> across)
all of the <i>ruby bases</i> in its <i>ruby segment</i>.
</p>
<p>Otherwise, each <i>ruby annotation</i> is paired,
in order, with the corresponding <i>ruby base</i> in that segment.
If there are not enough <i>ruby annotations</i> in a <i>ruby annotation container</i>,
the remaining <i>ruby bases</i> are paired with anonymous empty annotations
inserted at the end of the <i>ruby annotation container</i>.
If there are not enough <i>ruby bases</i>,
any remaining <i>ruby annotations</i> pair with empty, anonymous bases
inserted at the end of the <i>ruby base container</i>.
</p>
<p>If an implementation supports ruby markup with explicit spanning
(e.g. XHTML Complex Ruby Annotations),
it must adjust the pairing rules to pair <i>spanning annotations</i>
to their bases appropriately.
</p>
<p><i>Intra-level white space</i> does not participate in standard annotation <i>pairing</i>.
However, if the immediately-adjacent <i>ruby bases</i> or <i>ruby annotations</i>
are paired
</p>
<ul>
<li>with two <i>ruby bases</i> or <i data-lt="ruby annotations">annotations</i>
that surround corresponding <i>intra-level white space</i> in another level,
then the so-corresponding <i>intra-level white space</i> boxes are also paired.
<li>with a single spanning <i>ruby annotation</i>,
then the <i>intra-level white space</i> is also paired to that <i>ruby annotation</i>
<li>with two <i>ruby bases</i> or <i data-lt="ruby annotations">annotations</i>
with no intervening <i>intra-level white space</i>,
then the <i>intra-level white space</i> box pairs with
an anonymous empty <i>intra-level white space</i> box assumed to exist between them.
</ul>
<p class="issue" id="issue-0230a91a"><a class="self-link" href="#issue-0230a91a"></a>Insert diagram</p>
<h4 class="heading settled" data-level="2.3.3" id="nested-pairing"><span class="secno">2.3.3. </span><span class="content">
Complex Spanning with Nested Ruby</span><a class="self-link" href="#nested-pairing"></a></h4>
<p>When <i>ruby containers</i> are <dfn data-dfn-type="dfn" data-lt="nested ruby" data-noexport="" id="nested-ruby">nested<a class="self-link" href="#nested-ruby"></a></dfn>,
pairing begins with the deepest <i>ruby container</i>,
then expands out.
From the pairing perspective of the outer <i>ruby container</i>,
each <i>ruby container</i> nested within another <i>ruby container</i>
counts as representing a single <i>ruby base</i>/<i>annotation</i> per level.
The outer <i>ruby container</i>’s <i>ruby annotations</i> paired to the <i>nested ruby</i>
are therefore paired with (and <i>span</i>) all of the nested <i>ruby container</i>’s <i>ruby bases</i>.
Each <i>ruby annotation container</i> in the nested <i>ruby container</i>
occupies the same <i>annotation level</i> in the outer <i>ruby container</i>
as it does in the inner one
and participates in its layout as if it were directly contained in the outer <i>ruby container</i>.
</p>
<p>This process is recursive.
Thus, using nested <i>ruby containers</i> allows the representation
of complex spanning relationships.
</p>
<p class="issue" id="issue-9b177ca3"><a class="self-link" href="#issue-9b177ca3"></a>It’s not clear whether this falls out of layout handling of ruby containers inside ruby bases
or needs to be handled specially.
Waiting until layout is better-defined to find out...
</p>
<h3 class="heading settled" data-level="2.4" id="autohide"><span class="secno">2.4. </span><span class="content">
Autohiding Base-identical Annotations</span><a class="self-link" href="#autohide"></a></h3>
<p>If a <i>ruby annotation</i> has the exact same text content as its base,
it is <dfn data-dfn-type="dfn" data-lt="hidden ruby annotation | hidden annotation" data-noexport="" id="hidden-ruby-annotation">hidden<a class="self-link" href="#hidden-ruby-annotation"></a></dfn>.
Hiding a <i>ruby annotation</i> does not affect annotation pairing
or the block-axis positioning of boxes in other <i>levels</i>.
However the <i>hidden annotation</i> is not visible,
and it has no impact on layout
other than to separate adjacent sequences of <i>ruby annotation boxes</i> within its level,
as if they belonged to separate segments
and the <i>hidden annotation</i>’s base were not a <i>ruby base</i> but an intervening inline.
</p>
<div class="example" id="example-8959956b"><a class="self-link" href="#example-8959956b"></a>
<p>This is to allow correct inlined display of annotations
for Japanese words that are a mix of kanji and hiragana.
For example, the word <span lang="ja">振り仮名</span> should be inlined as
</p>
<p class="figure">振り仮名(ふりがな)
</p>
<p>and therefore marked up as
</p>
<pre>&lt;ruby>
&lt;rb>振&lt;/rb>&lt;rb>り&lt;/rb>&lt;rb>仮&lt;/rb>&lt;rb>名&lt;/rb>
&lt;rp>(&lt;/rp>&lt;rt>ふ&lt;/rt>&lt;rt>り&lt;/rt>&lt;rt>が&lt;/rt>&lt;rt>な&lt;/rt>&lt;rp>)&lt;/rp>
&lt;ruby></pre>
<p>However, when displayed as ruby, the “り” should be hidden
</p>
<div class="figure">
<p><img alt="Hiragana annotations for 振り仮名 appear, each pronunciation above its kanji base character." src="images/furigana-separate.png">
</p>
<p class="caption">Hiragana ruby for 振り仮名. Notice there is no hiragana annotation above り, since it is already in hiragana.
</p>
</div>
</div>
<p>When the computed value of <a class="property" data-link-type="propdesc" href="#propdef-ruby-merge">ruby-merge</a> is <a class="css" data-link-type="maybe" href="#valdef-ruby-merge-collapse">collapse</a>,
the autohiding is disabled.