change-case icon indicating copy to clipboard operation
change-case copied to clipboard

Title Case and Sentence Case do not preserve the new line character

Open p1ckle-rick opened this issue 9 months ago • 3 comments

Title Case and Sentence Case do not preserve the new line character.

This makes it impossible to process multiple sentences or paragraphs at once eg. if using the title-case package for <textarea>

p1ckle-rick avatar Mar 15 '25 20:03 p1ckle-rick

If you’re using title case or sentence case from the change case library, it’s not designed for what you’re trying to do. Have you tried the title-case library directly? https://github.com/blakeembrey/change-case/tree/main/packages/change-case#built-in-methods

Change case assumes you are switching between different programming cases. It does not retain punctuation or other sensitivities.

blakeembrey avatar Mar 15 '25 20:03 blakeembrey

@blakeembrey

I am using the title-case package https://www.npmjs.com/package/title-case

But titleCase(...) does not support new lines, it just trims them.

p1ckle-rick avatar Mar 16 '25 03:03 p1ckle-rick

Got it, you're totally right. These two fixes should patch the issue: https://github.com/blakeembrey/change-case/commit/5a2c600beb3aa33b4d8c5288882bee3d6a16a539 and https://github.com/blakeembrey/change-case/commit/55a95d3968d7d3a1ca5a9ff6dba7c7172e1de546. Do you want to take a quick review and I'll release them if it makes sense to you?

blakeembrey avatar Mar 16 '25 06:03 blakeembrey