w3c / csswg-drafts

CSS Working Group Editor Drafts
https://drafts.csswg.org/
Other
4.51k stars 668 forks source link

[css-text] text-transform capitalize for words separated by periods only (no space) #8031

Open karlcow opened 2 years ago

karlcow commented 2 years ago

Enter in the URL bar of a browser:

data:text/html,<!doctype html><div style="text-transform:capitalize">what.should.we.do</div>

Both Safari and Firefox returns:

What.should.we.do

While chrome returns:

What.Should.We.Do

The spec unfortunately seems to say that this is implementation dependent: in https://drafts.csswg.org/css-text/#text-transform-mapping

For capitalize, what constitutes a “word“ is UA-dependent; [UAX29] is suggested (but not required) for determining such word boundaries. Out-of-flow elements and inline element boundaries must not introduce a text-transform word boundary and must be ignored when determining such word boundaries.

in https://www.unicode.org/reports/tr29/tr29-41.html

The goal of matching user perceptions cannot always be met exactly because the text alone does not always contain enough information to unambiguously decide boundaries. For example, the period (U+002E FULL STOP) is used ambiguously, sometimes for end-of-sentence purposes, sometimes for abbreviations, and sometimes for numbers. In most cases, however, programmatic text boundaries can match user perceptions quite closely, although sometimes the best that can be done is not to surprise the user.

There is an issue about this on https://bugs.chromium.org/p/chromium/issues/detail?id=1266835

fantasai commented 2 years ago

Are you proposing that we

Note there are probably i18n implications to either creating our own set of rules or forcing standardization on TR29 (which was not designed for this exactly).

karlcow commented 2 years ago

Not sure what are the possible outcomes. And maybe it's not that important. I'm not totally sure myself which ones I would find more logical, and maybe there is nothing that would really work. But at least we have an issue about it to point to if someone else complains about it.