-
Notifications
You must be signed in to change notification settings - Fork 797
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve capitalization and other prose formatters #1216
Conversation
- Use Python's .title() to better handle hyphenated words. - Make CAPITALIZE_ALL_WORDS (should really be named something like TITLE_CASE_ALL_WORDS) a prose formatter and extend it to handle punctuation. - Don't change case of words that already include capital letters. - Add tests.
I like this! The challenge with
Becomes:
Looks like this also removes |
A few other things I've been mulling over for my own repo:
|
Use .capitalize() rather than .title() for capitalization. Split hyphenated words and apply the same logic to their components.
…as in each word in the title case formatter.
@brief Thanks for the feedback. Think I have fixed everything except for the issue with the prose formatter not being applicable in dictation mode. I also noticed that seemed to be a problem when applying a formatter from Cursorless or using "format help" — they completely ignore the prose formatters. Can anybody think of a reason why prose formatters should not be available everywhere (code) formatters are? |
@nriley Assuming prose formatters should be available everywhere, which I agree with,
Become:
Instead of:
Only other character that might matter in prose is a left parenthesis (e.g. |
Updated; it should handle punctuation at the beginning of words. There's a bunch of nuances with prose formatters I still need to sort out — for example, should you be able to combine code and prose formatters (e.g., "kebab title")? |
Thanks. This looks good to me. Re: combining code and prose formatters, I'm not entirely sure how they differ. Why are there two different types? |
Thanks! There are three main differences between prose and code formatters:
Most of the changes I made to "title" will be of limited use if it remains a code formatter, unless you're using it for reformatting of text you might have inserted with a prose formatter. My main concern would be if people are composing "title" with other code formatters, e.g. using "kebab title this is a test", which in stock knausj returns "This-is-a-Test", but won't work with this PR as it is currently. If that is not a major concern, what I think will work is replacing the definition of Another intermediate option might be allowing composition of code with prose formatters but only if you start with a code formatter. |
Wow, thank you for the detailed explanation! Curious to know what the feedback will be on composing "title" with other code formatters. No concerns here, but I'm the wrong person to ask. I only ever use it in the context of prose and prefer "hammer" when composing since I typically want to cap the start of every word. |
- You can now reformat with prose formatters. - Reformatting with (only) a prose formatter doesn't unformat first. - Prose formatters appear in "format help", marked as such.
OK, I think I've got a reasonable solution here. You can compose prose and code formatters, but only when reformatting. Feedback appreciated! |
Looks good on my end. |
- Use Python's `.title()` to better handle hyphenated words. - Make `CAPITALIZE_ALL_WORDS` (should really be named something like `TITLE_CASE_ALL_WORDS`) a prose formatter and extend it to handle punctuation. - Don't change case of words that already include capital letters. - Add tests.
.title()
to better handle hyphenated words.CAPITALIZE_ALL_WORDS
(should really be named something likeTITLE_CASE_ALL_WORDS
) a prose formatter and extend it to handle punctuation.