mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Automatic titlecasing: No longer try to capitalize scottish names, as there are too many special cases. Fixes #775825 (titlecase error on the word (part) macht)
This commit is contained in:
parent
86cb606dc9
commit
983d9280ec
@ -28,8 +28,6 @@ SUBPHRASE = re.compile(r'([:.;?!][ ])(%s)' % SMALL)
|
|||||||
APOS_SECOND = re.compile(r"^[dol]{1}['‘]{1}[a-z]+$", re.I)
|
APOS_SECOND = re.compile(r"^[dol]{1}['‘]{1}[a-z]+$", re.I)
|
||||||
ALL_CAPS = re.compile(r'^[A-Z\s%s]+$' % PUNCT)
|
ALL_CAPS = re.compile(r'^[A-Z\s%s]+$' % PUNCT)
|
||||||
UC_INITIALS = re.compile(r"^(?:[A-Z]{1}\.{1}|[A-Z]{1}\.{1}[A-Z]{1})+$")
|
UC_INITIALS = re.compile(r"^(?:[A-Z]{1}\.{1}|[A-Z]{1}\.{1}[A-Z]{1})+$")
|
||||||
MAC_MC = re.compile(r"^([Mm]a?c)(.+)")
|
|
||||||
|
|
||||||
|
|
||||||
_lang = None
|
_lang = None
|
||||||
|
|
||||||
@ -40,7 +38,6 @@ def lang():
|
|||||||
_lang = get_lang().lower()
|
_lang = get_lang().lower()
|
||||||
return _lang
|
return _lang
|
||||||
|
|
||||||
|
|
||||||
def titlecase(text):
|
def titlecase(text):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -78,13 +75,6 @@ def titlecase(text):
|
|||||||
line.append(icu_lower(word))
|
line.append(icu_lower(word))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if lang().startswith('en'):
|
|
||||||
match = MAC_MC.match(word)
|
|
||||||
if match and not match.group(2)[:3] in ('hin', 'ht'):
|
|
||||||
line.append("%s%s" % (capitalize(match.group(1)),
|
|
||||||
capitalize(match.group(2))))
|
|
||||||
continue
|
|
||||||
|
|
||||||
hyphenated = []
|
hyphenated = []
|
||||||
for item in word.split('-'):
|
for item in word.split('-'):
|
||||||
hyphenated.append(CAPFIRST.sub(lambda m: icu_upper(m.group(0)), item))
|
hyphenated.append(CAPFIRST.sub(lambda m: icu_upper(m.group(0)), item))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user