whatwg / html

HTML Standard
https://html.spec.whatwg.org/multipage/
Other
7.95k stars 2.6k forks source link

Ruby styling #121

Open domenic opened 8 years ago

domenic commented 8 years ago

101 is trying to sort out the parser. Here is some data on the UA styling:

HTML Standard

ruby { display: ruby; }
rt { display: ruby-text; }

W3C HTML 5.1

ruby { display: ruby; }
rb   { display: ruby-base; white-space: nowrap; }
rt   {
    display: ruby-text;
    white-space: nowrap;
    font-size: 50%;
    font-variant-east-asian: ruby;
    text-emphasis: none;
}
rbc  { display: ruby-base-container; }
rtc  { display: ruby-text-container; }
ruby, rb, rt, rbc, rtc { unicode-bidi: isolate; }

Chrome

ruby, rt {
    text-indent: 0; /* blocks used for ruby rendering should not trigger this */
}

rt {
    line-height: normal;
    -webkit-text-emphasis: none;
}

ruby > rt {
    display: block;
    font-size: 50%;
    text-align: start;
}

ruby > rp {
    display: none;
}

WebKit

ruby, rt {
    text-indent: 0; /* blocks used for ruby rendering should not trigger this */
}

rt {
    line-height: normal;
    -webkit-text-emphasis: none;
}

ruby > rt {
    display: block;
    font-size: -webkit-ruby-text;
    text-align: start;
}

ruby > rp {
    display: none;
}

Firefox

ruby {
  display: ruby;
}
rb {
  display: ruby-base;
  white-space: nowrap;
}
rp {
  display: none;
}
rt {
  display: ruby-text;
}
rtc {
  display: ruby-text-container;
}
rtc, rt {
  white-space: nowrap;
  font-size: 50%;
  line-height: 1;
  font-variant-east-asian: ruby;
}
@supports (text-emphasis: none) {
  rtc, rt {
    text-emphasis: none;
  }
}
rtc:lang(zh), rt:lang(zh) {
  ruby-align: center;
}
rtc:lang(zh-TW), rt:lang(zh-TW) {
  font-size: 30%; /* bopomofo */
}
rtc > rt {
  font-size: inherit;
}
ruby, rb, rt, rtc {
  unicode-bidi: -moz-isolate;
}

It seems likely we should not have any styling rules for rb and rtc, as those are only in Gecko (plus W3C HTML).

kojiishi commented 8 years ago

The diff corresponds to when implementers referred the CSS Ruby spec, as it's changing quite often and quite drastically. Gecko implemented after the last large refactor of the spec, so it's most up-to-date.

I'm not familiar with how much copy of CSS specs HTML spec should have. Is it possible to simply delegate to CSS Ruby as it's still WD and is possibly to evolve further? That makes CSS spec editors a bit happier to maintain single copy.

Or do we want to have the minimum common denominator in HTML spec?

domenic commented 8 years ago

That's a good question. I've never seen a CSS spec with UA stylesheets in them before, and I note that that entire appendix is marked informative. So we'd want to have a normative definition somewhere, probably in HTML since that's where the rest of the UA stylesheet is defined (I think?).

We also need something that reflects reality. The Ruby spec you reference is reasonably close to Firefox, but not to any other browsers. So it doesn't seem likely to be a good reference anyway.

annevk commented 8 years ago

The HTML Standard should contain the default styling for ruby elements. CSS should just define how those styles are to be rendered. CSS should not define the look-and-feel of HTML markup though.

kojiishi commented 8 years ago

Thank you both, understood, but...this looks hard. No UA other than Gecko, AFAIK, has implemented display: ruby, so no specs reflect the reality as of today. But how could we define ruby rendering without using it, I don't have a good idea how to solve it.

And you're right, the CSS spec is still much before call-for-implementation, and after a large refactor, so it's far from "commonly implemented."

Maybe disregard the display property as the current spec do, and try to find common implementations for other properties?

upsuper commented 7 years ago

FWIW, the W3C i18n wg recently resolved to ask html to remove rb and rtc from the list of "obsolete" tags.

stevefaulkner commented 7 years ago

@upsuper note the request has been fulfilled https://github.com/w3c/html/issues/579

kojiishi commented 7 years ago

@upsuper shouldn't it have its own issue rather than just a comment to this issue? I support it.

zcorpan commented 7 years ago

From https://github.com/whatwg/html/pull/1799

  <p>For the purposes of the CSS ruby model, runs of children of <code>ruby</code> elements that are
  not <code>rt</code> or <code>rp</code> elements are expected to be wrapped in anonymous boxes
  whose <span>'display'</span> property has the value <span>'ruby-base'</span>. <ref
  spec=CSSRUBY></p>

@bzbarsky:

The ruby/colgroup parts are simply nonsense, imo. The HTML spec should simply define the default UA styling for those (setting the display) property and say nothing else.