Skip to content
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

Changed titleize and toTitleCase methods to be much more accurate. #171

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hipsterjazzbo
Copy link

@hipsterjazzbo hipsterjazzbo commented Oct 9, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant