[csswg-drafts] [css-pseudo-4] Fine-tuning ::first-letter punctuation pattern matching (#5830)

fantasai has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-pseudo-4] Fine-tuning ::first-letter punctuation pattern matching ==
In https://github.com/w3c/csswg-drafts/issues/5154 we updated the spec to include "intervening" white space. Certainly for spaces before the first letter this is correct, but the example of “`A "b"` will have `A "` selected” in @csnardi’s https://github.com/w3c/csswg-drafts/issues/2164#issuecomment-359817376 shows a real problem with this approach: since we reach out to following punctuation, allowing intervening white space *after* the first letter means we'll jump a word space and scoop up opening punctuation on the other side. :( I think we definitely need to make this smarter.

A few rules we could adopt that could help:
- Break on normal word spaces and nbsp, at least on the following side of the first letter. If people want to scoop up subsequent punctuation after a space, they'll have to use typographically correct space codepoints such as thinsp.
- Exclude opening punctuation following the first letter. In writing systems without a word space, we shouldn't be picking up the opening parens after the first "letter"! Po/Pi/Pf are ambiguous, but Ps is not.
- If there's an element boundary *after* the first letter, require that the UA close ::first-letter before that boundary, excluding the content after that element boundary, rather than allowing them to create ::first-letter after (excluding the first letter itself!) or both before and after the element boundary as we do currently.

I think we also need to do some more thinking about following Po/Pi/Pf/Pd.

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/5830 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Thursday, 31 December 2020 03:37:05 UTC