mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -04:00
Fix #1828820 [calibre.utils.titlecase does not preserve whitespace](https://bugs.launchpad.net/calibre/+bug/1828820)
This commit is contained in:
parent
7658dc65d9
commit
76d9f734e9
@ -56,9 +56,14 @@ def titlecase(text):
|
||||
|
||||
all_caps = upper(text) == text
|
||||
|
||||
words = re.split('\\s+', text)
|
||||
pat = re.compile(r'(\s+)')
|
||||
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 UC_INITIALS.match(word):
|
||||
line.append(word)
|
||||
|
Loading…
x
Reference in New Issue
Block a user