Skip to content

Commit 4e50021

Browse files
committed
[css-ruby] Add ASCII art diagrams to illustrate section 3.1.1
1 parent 02602eb commit 4e50021

File tree

1 file changed

+115
-0
lines changed

1 file changed

+115
-0
lines changed

css-ruby-1/Overview.bs

+115
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,121 @@ Inline-axis Interlinear Layout</h4>
787787
when its content is narrower than the measure of the box
788788
is specified by its 'ruby-align' property.
789789

790+
<div class=example>
791+
The following diagrams illustrate these rules,
792+
covering typical situations
793+
as well as a few more complex ones.
794+
In each case,
795+
[=base boxes=] and [=annotation boxes=] are assumed to have ''ruby-align: center'',
796+
while <!--[=base containers=] and --> [=annotation containers=] are assumed to have ''ruby-align: space-between''.
797+
798+
Red brackets (<span style=color:red>[ ]</span>) represent [=base boxes=],
799+
blue brackets (<span style=color:blue>[ ]</span>) represent [=annotation boxes=],
800+
and gray bars (<span style=color:gray>|</span>) represent the limits of [=ruby columns=].
801+
[=Ruby containers=], [=base containers=], and [=annotation containers=] are omitted.
802+
803+
<dl>
804+
<dt id=ex-separate>Separate / non spanning:
805+
<dd>
806+
<pre class=highlight>
807+
<span style=color:gray>|</span><span style=color:blue>[</span> a1 <span style=color:blue>]</span><span style=color:gray>|</span><span style=color:blue>[</span> a2 <span style=color:blue>]</span><span style=color:gray>|</span><span style=color:blue>[</span>annotation-3<span style=color:blue>]</span><span style=color:gray>|</span>
808+
<span style=color:gray>|</span><span style=color:red>[</span>base 1<span style=color:red>]</span><span style=color:gray>|</span><span style=color:red>[</span>base 2<span style=color:red>]</span><span style=color:gray>|</span><span style=color:red>[</span> base 3 <span style=color:red>]</span><span style=color:gray>|</span>
809+
</pre>
810+
811+
Boxes within each [=column=] are sized to match the widest box of that [=column=].
812+
The value of 'ruby-align' on each [=base box=] and [=annotation box=] is used
813+
to distribute the extra space in each box.
814+
815+
<dt id=ex-short-span>Spanning (short):
816+
<dd>
817+
<pre class=highlight>
818+
<span style=color:gray>|</span><span style=color:blue>[</span> a1 <span style=color:blue>]</span><span style=color:gray>|</span><span style=color:blue>[</span> short span <span style=color:blue>]</span><span style=color:gray>|</span>
819+
<span style=color:gray>|</span><span style=color:red>[</span>base 1<span style=color:red>]</span><span style=color:gray>|</span><span style=color:red>[</span>base 2<span style=color:red>]</span><span style=color:gray>|</span><span style=color:red>[</span>base 3<span style=color:red>]</span><span style=color:gray>|</span>
820+
</pre>
821+
822+
When a [=spanning annotation=] is shorter than the spanned [=bases=],
823+
there is no extra space to distribute to these [=bases=].
824+
Extra space within the [=spanning annotation=]
825+
is distributed according to 'ruby-align' on that [=annotation box=],
826+
as for non spanning ones.
827+
828+
<dt id=ex-long-span>Spanning (long):
829+
<dd>
830+
<pre class=highlight>
831+
<span style=color:gray>|</span><span style=color:blue>[</span> a1 <span style=color:blue>]</span><span style=color:gray>|</span><span style=color:blue>[</span>spanning annotation<span style=color:blue>]</span><span style=color:gray>|</span>
832+
<span style=color:gray>|</span><span style=color:red>[</span>base 1<span style=color:red>]</span><span style=color:gray>|</span><span style=color:red>[</span> base 2 <span style=color:red>]</span><span style=color:gray>|</span><span style=color:red>[</span> base 3 <span style=color:red>]</span><span style=color:gray>|</span>
833+
</pre>
834+
835+
When the [=spanning annotation=] is longer than the spanned [=base boxes=],
836+
the extra space is distributed equally between them.
837+
838+
<dt id=ex-short-merge>Merged (short):
839+
<dd>
840+
<pre class=highlight>
841+
<span style=color:gray>|</span><span style=color:blue>[</span>merged annotation<span style=color:blue>]</span><span style=color:gray>|</span>
842+
<span style=color:gray>|</span><span style=color:red>[</span>base 1<span style=color:red>]</span><span style=color:gray>|</span><span style=color:red>[</span>base 2<span style=color:red>]</span><span style=color:gray>|</span><span style=color:red>[</span>base 3<span style=color:red>]</span><span style=color:gray>|</span>
843+
</pre>
844+
845+
A [=merged annotation=] behaves similarly to a [=spanning=] one,
846+
except that distribution of any extra space in it
847+
is determined by the value of 'ruby-align' on the [=annotation container=],
848+
not on any of its [=annotation boxes=].
849+
850+
<!--
851+
<dt id=ex-long-merge>Merged (long):
852+
<dd>
853+
<pre>
854+
|[This is a long merged annotation]| <- no extra space, nothing to align
855+
|[ Base 1 ]|[ Base 2 ]|[ Base 3 ]| <- uses ruby-align on each base like for a spanner?
856+
or maybe (see https://github.com/w3c/csswg-drafts/issues/6004)
857+
|[Base 1 Base 2 Base 3]| <- treats the bases as merged as well?
858+
</pre>
859+
-->
860+
<dt id=ex-multi-level-span>Several levels, with spanning annotation:
861+
<dd>
862+
<pre class=highlight>
863+
<span style=color:gray>|</span><span style=color:blue>[</span> a1 <span style=color:blue>]</span><span style=color:gray>|</span><span style=color:blue>[</span> annotation-2 <span style=color:blue>]</span><span style=color:gray>|</span><span style=color:blue>[</span> a3 <span style=color:blue>]</span><span style=color:gray>|</span>
864+
<span style=color:gray>|</span><span style=color:blue>[</span>long annotation spanning all content<span style=color:blue>]</span><span style=color:gray>|</span>
865+
<span style=color:gray>|</span><span style=color:red>[</span> base 1 <span style=color:red>]</span><span style=color:gray>|</span><span style=color:red>[</span> base 2 <span style=color:red>]</span><span style=color:gray>|</span><span style=color:red>[</span> base 3 <span style=color:red>]</span><span style=color:gray>|</span>
866+
</pre>
867+
<pre class=highlight>
868+
<span style=color:gray>|</span><span style=color:blue>[</span> xx <span style=color:blue>]</span><span style=color:gray>|</span><span style=color:blue>[</span>annotation spanning bases<span style=color:blue>]</span><span style=color:gray>|</span>
869+
<span style=color:gray>|</span><span style=color:blue>[</span> a1 <span style=color:blue>]</span><span style=color:gray>|</span><span style=color:blue>[</span> annotation-2 <span style=color:blue>]</span><span style=color:gray>|</span><span style=color:blue>[</span> a3 <span style=color:blue>]</span><span style=color:gray>|</span>
870+
<span style=color:gray>|</span><span style=color:red>[</span>base 1<span style=color:red>]</span><span style=color:gray>|</span><span style=color:red>[</span> base 2 <span style=color:red>]</span><span style=color:gray>|</span><span style=color:red>[</span> base 3 <span style=color:red>]</span><span style=color:gray>|</span>
871+
</pre>
872+
873+
In these two examples with multiple [=levels=],
874+
each [=column=] is sized to its longest content,
875+
and [=spanning annotations=] that are still longer
876+
than the sum of the [=columns=] that they span
877+
grow them further,
878+
adding to each equally.
879+
880+
<dt id=ex-multi-level-mutli-span>Several levels, with multiple spanning annotations:
881+
<dd>
882+
<pre class=highlight>
883+
<span style=color:gray>|</span><span style=color:blue>[</span><span style=background:orange;opacity:0.3> </span> xx <span style=background:orange;opacity:0.3> </span><span style=color:blue>]</span><span style=color:gray>|</span><span style=color:blue>[</span><span style=background:orange;opacity:0.3> </span><span style=color:green>annotation spanning bases</span><span style=background:orange;opacity:0.3> </span><span style=color:blue>]</span><span style=color:gray>|</span>
884+
<span style=color:gray>|</span><span style=color:blue>[</span><span style=background:orange;opacity:0.3> </span> a1 <span style=background:orange;opacity:0.3> </span><span style=color:blue>]</span><span style=color:gray>|</span><span style=color:blue>[</span><span style=background:orange;opacity:0.3> </span><span style=background:green;opacity:0.3> </span>annotation-2<span style=background:green;opacity:0.3> </span><span style=background:orange;opacity:0.3> </span><span style=color:blue>]</span><span style=color:gray>|</span><span style=color:blue>[</span><span style=background:orange;opacity:0.3> </span><span style=background:green;opacity:0.3> </span> a3 <span style=background:green;opacity:0.3> </span><span style=background:orange;opacity:0.3> </span><span style=color:blue>]</span><span style=color:gray>|</span>
885+
<span style=color:gray>|</span><span style=color:blue>[</span><span style=color:#ae4a00>lengthy annotation spanning base content</span><span style=color:blue>]</span><span style=color:gray>|</span>
886+
<span style=color:gray>|</span><span style=color:red>[</span><span style=background:orange;opacity:0.3> </span>base 1<span style=background:orange;opacity:0.3> </span><span style=color:red>]</span><span style=color:gray>|</span><span style=color:red>[</span><span style=background:orange;opacity:0.3> </span><span style=background:green;opacity:0.3> </span> base 2 <span style=background:green;opacity:0.3> </span><span style=background:orange;opacity:0.3> </span><span style=color:red>]</span><span style=color:gray>|</span><span style=color:red>[</span><span style=background:orange;opacity:0.3> </span><span style=background:green;opacity:0.3> </span>base 3<span style=background:green;opacity:0.3> </span><span style=background:orange;opacity:0.3> </span><span style=color:red>]</span><span style=color:gray>|</span>
887+
</pre>
888+
889+
When there are multiple [=spanning annotations=],
890+
those that span fewest [=bases=] are processed first.
891+
In this case, the green one,
892+
which spans two bases,
893+
is processed before the orange one,
894+
which spans three.
895+
Changing this order would change the distribution of space.
896+
897+
To help identify which [=spanning annotation=] is responsible
898+
for which extra spacing,
899+
in this diagram
900+
the color of the text in each [=spanning annotation=] is matched
901+
with the background color of spacing it adds to other boxes.
902+
</dl>
903+
</div>
904+
790905
<h4 id="interlinear-block">
791906
Block-axis Interlinear Layout</h4>
792907

0 commit comments

Comments
 (0)