Stringy icon indicating copy to clipboard operation
Stringy copied to clipboard

Changed titleize and toTitleCase methods to be much more accurate.

Open hipsterjazzbo opened this issue 7 years ago • 0 comments

Currently, title casing is very naive, in that it simply capitalises each word.

This changes titleize() and toTitleCase() do a much better job at doing proper title casing, including lower casing words that should be lower cased, and hyphenates like "Stand-In" (but not man-in-the-middle).

I have made sure that the method signature has not changed, although the output will change in a lot of cases so I'm not toll sure if this counts as breaking.

If the behaviour of upper casing every word in a string is still desired, I suggest adding a upperCaseEach() method or similar.

(Adapted from John Gruber’s script)

PS: If there is a concern about the $smallWords list being mono-lingual, I believe the Inflectors from #170 could be used here as well.

hipsterjazzbo avatar Oct 09 '17 03:10 hipsterjazzbo