[ruby] Parsing-based approach

Everyone,

It strikes me from reading "Use Cases & Exploratory Approaches for Ruby
Markup" that none of the approaches presented there is really compelling
with all due respect to those who have contributed to them. I fear the
complexity of the markup could hold back use of this useful feature. I have
no idea if there is room to consider alternative approaches, but I'll
nevertheless go ahead and propose one here, which can hopefully co-exist
with existing ruby specs and implementations for backward compatibility.

The basic notion is that markup such as <ruby>東京(とうきょう)</ruby> should JUST
WORK. In this case, the reading portion (text) is rendered as ruby above
the base (if the browser supports it; otherwise, it falls back naturally).

To make this work, we need a notion of *parsing *the contents of the <ruby>
element into text and base. A first approximation would be CSS properties
that give the beginning and ending delimiter ("(" and ")" in this case) of
the ruby text portion:

ruby {
  ruby-parse-text-delimiters: "(" ")";
}

In order to allow styling of base vs. text, we can use pseudo-elements:

..my-ruby-class:ruby-base { color: red; }
..my-ruby-class:ruby-text { color: green; }

Turn off ruby with

..my-ruby-class::ruby-text { display: none; }

Of course, markup could also be given directly within the <ruby> tag, so

<ruby>東京<span style="color: purple; ">(とうきょう)</span><ruby>

But what about the "mono" vs. "group" distinction? Current proposals, as I
understand them, require the HTML author to decide which she wants and
author accordingly, with multiple <rb> and <rt> tags for the mono case. It
would be ideal if the markup could be simpler, and the mono vs. group
selection could be made at the CSS level. To allow this, I propose the
notion of a "ruby segment delimiter" which breaks both the base and text
into segments, which can be paired in the mono case, or ignored in the
group case, depending on a CSS setting. Using a slash "/" as the segment
delimiter, we would have:

東/京(とう/きょう)

The segment delimiter itself would be set as the value of the
ruby-parse-segment-delimiter CSS property. Whether or not segments are used
would be controlled by another CSS property ruby-parse-segment-apply.

ruby {
  ruby-parse-segment-delimiter: "/";
  ruby-parse-segment-apply: on; /* for mono */
}

The easiest approach to backwards compatibility, assuming we want to
preserve the <ruby> tag, is probably to say that <ruby> elements with no
<rb> or <rt> children are handled using the new mechanism. Or, a new
ruby-parse-active CSS property, defaulting to off, could control the
behavior.

My apologies if any of this is a rehash of old discussions, or if this is
not the right forum to making a proposal like this.

Regards,
--
Bob Myers

Received on Saturday, 28 July 2012 18:21:38 UTC