wrap pure whitespace

This commit is contained in:
Kovid Goyal 2025-02-23 13:21:36 +05:30
parent ee44d2ccd4
commit 4ff64c0b21
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 4 additions and 1 deletions

View File

@ -164,7 +164,7 @@ def add_kobo_spans(inner, root_lang):
paranum += 1
segnum = 0
increment_next_para = False
stripped = leading_whitespace_pat.sub('', text)
stripped = leading_whitespace_pat.sub('', text) or text
ws = None
if num := len(text) - len(stripped):
ws = text[:num]

View File

@ -59,6 +59,9 @@ div#book-inner {{ margin-top: 0; margin-bottom: 0; }}</style><script type="text/
suffix = '</div></div></body></html>'
for src, expected in {
# basics
'<p>one</p><p>\xa0</p>':
'<p><span class="koboSpan" id="kobo.1.1">one</span></p><p><span class="koboSpan" id="kobo.2.1">&#160;</span></p>',
'<p>Simple sentences. In a single paragraph.'
'<p>A sentence <i>with <b>nested</b>, tailed</i> formatting. Another.':