[csswg-drafts] [css-text] Add sentence case via `text-transform: sentence` (#8893)

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

== [css-text] Add sentence case via `text-transform: sentence` ==
We often have to turn to JS when needing only the first non-whitespace character in a multi-word string capitalized. It would be great to be able to achieve this in CSS as well.

## Basic Example

#### Usage:

```html
<span style="text-transform: sentence">test test test</span>
```

#### Would render this:

```
Test test test
```

This is roughly equivalent to this example targeting `::first-letter`:

```css
::first-letter {
  text-transform: uppercase;
}
```

## Considerations

* Should this capitalize the first character in every sentence and look for new-sentence characters in line with the current language in use, followed by a space? I will be using the terminator to describe any "end punctuation" (e.g. `.`, `?`, `!`).
  
  What should this example render as?
  ```html
  <span style="text-transform: sentence">test test test. test test test!test test test?test? test.test</span>
  ```
  
  Several options:
  * `Test test test. test test test!test test test?test? test.test`
    * only first non-whitespace char, simplest solution
  * `Test test test. Test test test!Test test test?Test? Test.Test`
    * start + after all terminators
      * first non-whitespace char
      * every first non-whitespace char after a terminator
  * `Test test test. Test test test!test test test?test? Test.test`
    * every natural sentence start
      * first non-whitespace char
      * every first non-whitespace char after a terminator + whitespace (whitespace after terminator required)

* Assuming this is implemented and with some special cases for multiple sentences (the previous consideration), should this special casing also apply to quotes by default? I will be using, but assume that this may support some/all quotation styles— `'`, `"`, <code>`</code>.
  
  What should this example render as?
  ```html
  <span style="text-transform: sentence">test 'test test. test' test, 'test'</span>
  ```
  
  Several options, again:
  * `Test 'test test. Test' test, 'test'`
    * no capitalization of quotes by default
  * `Test 'test test. Test' test, 'Test'`
    * capitalization of quotes after comma and quote but not without comma
  * `Test 'Test test. Test' Test, 'Test'`
    * capitalization of first chars in all quotes (no comma needed)
  * `Test 'Test test. Test' test, 'Test'`
    * capitalization of first chars in all quotes, but not if there is leading whitespace inside quote (ambiguous with apostrophe vs. single quote)
* How will we conduct locale research to ensure this supports all locales. Are there any gotchas with the locales introduced even with the simplest of uses (same as `::first-letter { text-transform: uppercase }`)
* Should there be any method for purposely escaping characters not desired to be capitalized?
* Should which quotes capitalized (if any) be a configurable setting, via another property?

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


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

Received on Wednesday, 31 May 2023 22:10:25 UTC