mattstevens / sublime-titlecase

Smarter title casing for Sublime Text
21 stars 5 forks source link

whitelist Mc- and Mac- last names #5

Open brchristian opened 5 years ago

brchristian commented 5 years ago

As noted in https://github.com/mattstevens/sublime-titlecase/issues/1, this extension works like a dream except with words that start with "mc" or "mac", which get horribly butchered.

For instance:

macabre           =>  MacAbre
macadam           =>  MacAdam
macademia nut     =>  MacAdemia Nut
Macao             =>  MacAo
macaroni          =>  MacAroni
macaroon          =>  MacAroon
macaw             =>  MacAw
mace              =>  MacE
Macedonia         =>  MacEdonia
Mach five         =>  MacH Five
(Papier) Mache    =>  (Papier) MacHe
machete           =>  MacHete
machine           =>  MacHine
machine learning  =>  MacHine Learning
machinery         =>  MacHinery
machinist         =>  MacHinist
macho             =>  MacHo
macroeconomics    =>  MacRoeconomics
macrocosm         =>  MacRocosm

...which, I think you'll agree, is...not the desired behavior.

In fact, even a great many words that seem like surnames that should get a second capital letter in fact do not. Consider:

Macauley
Macbeth
Maclean
Machiavelli
Macintosh
Mackenzie
Mackinac
Mackintosh
Macleod

None of these should get a second capital in most cases.

This PR includes a whitelist for common names that generally should get a second capital, so that other words beginning with "mac" will be properly left with a single capital.

jpcirrus commented 4 years ago

If you replace ./titlecase/__init__.py with an updated version of the original from https://github.com/ppannuto/python-titlecase/tree/master/titlecase this issue seems to be resolved. A sample of your examples are working fine.