[whatwg] Whitespace handling in ruby

Ian Hickson ian at hixie.ch
Tue Aug 4 18:33:52 PDT 2009


On Thu, 30 Jul 2009, Roland Steiner wrote:
>
> As I am currently writing an implementation for ruby rendering, I 
> wondered about the exact way white-space is supposed to be handled 
> between runs of ruby text.
> 
> As far as I see it, <ruby> is fundamentally an inline element, and thus 
> whitespace would normally be collapsed, but not entirely eliminated. 
> However, for the examples given for the <ruby> element, this would 
> result in a single whitespace between the ideographic characters:
> 
> <ruby> *[ws]*
> ´Á<rp>(</rp><rt>¤«¤ó</rt><rp>)</rp> *[ws]*
> »ú<rp>(</rp><rt>¤¸</rt><rp>)</rp> *[ws]*
> </ruby>
> 
> rendered without ruby support would become (easier for e-mail):
> 
> ´Á(¤«¤ó)* [ws]* »ú(¤¸)

Correct.


> The whitespace would also be present with proper ruby rendering above the
> base characters.

How so?


> OTOH, removing those white-spaces may not be desirable if the bases are not
> ideographic scripts, e.g.:
> 
> <ruby>
> European<rp>(</rp><rt>E</rt><rp>)</rp>
> Union<rp>(</rp><rt>U</rt><rp>)</rp>
> </ruby>
> 
> (This example has yet another drawback: the white-space before "Union" would
> become part of the base and thus shift the annotation "U" slightly left of
> the center of the word "Union".)

Indeed.


> For the time being I'm using a block-based rendering approach that 
> automatically eliminates leading and trailing white-space in the base 
> text, but I wondered what the correct approach would be within the scope 
> of HTML5 (aside: an XHTML-like explicit <rb> container for the ruby base 
> side-steps this problem, but is not a real option due to need for legacy 
> support).

As far as I can tell the correct approach is for whitespace to be trimmed 
as part of ideographic rendering, as required by the CSS ideographic 
rendering models, no? I'm no expert on this subject. I recommend asking 
for clarification in www-style at w3.org.


On Thu, 30 Jul 2009, Simon Pieters wrote:
> 
> "For the purposes of the CSS ruby model, runs of descendants of ruby 
> elements that are not rt or rp elements are expected to be wrapped in 
> anonymous boxes whose 'display' property has the value 'ruby-base'." 
> http://www.whatwg.org/specs/web-apps/current-work/multipage/the-xhtml-syntax.html#display-types
> 
> (That section also says rp should be display:block; shouldn't that be 
> display:none instead?)

Fixed.

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'


More information about the whatwg mailing list