Fix #1828820 [calibre.utils.titlecase does not preserve whitespace](https://bugs.launchpad.net/calibre/+bug/1828820)

This commit is contained in:
Kovid Goyal 2019-05-14 11:59:09 +05:30
parent 7658dc65d9
commit 76d9f734e9
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -56,9 +56,14 @@ def titlecase(text):
all_caps = upper(text) == text all_caps = upper(text) == text
words = re.split('\\s+', text) pat = re.compile(r'(\s+)')
line = [] line = []
for word in words: for word in pat.split(text):
if not word:
continue
if pat.match(word) is not None:
line.append(word)
continue
if all_caps: if all_caps:
if UC_INITIALS.match(word): if UC_INITIALS.match(word):
line.append(word) line.append(word)