DOCX Input: Fix text elements containing only whitespace being incorrectly ignored. Fixes #2063301 [Incorrect conversion docx to epub](https://bugs.launchpad.net/calibre/+bug/2063301)

This commit is contained in:
Kovid Goyal 2024-04-30 14:34:29 +05:30
parent dd747283ca
commit d045698289
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -671,8 +671,11 @@ class Convert:
ctext = child.text ctext = child.text
if space != 'preserve': if space != 'preserve':
# Remove leading and trailing whitespace. Word ignores # Remove leading and trailing whitespace. Word ignores
# leading and trailing whitespace without preserve # leading and trailing whitespace without preserve unless
ctext = ctext.strip(' \n\r\t') # the element is only whitespace.
stripped = ctext.strip(' \n\r\t')
if stripped:
ctext = stripped
# Only use a <span> with white-space:pre-wrap if this element # Only use a <span> with white-space:pre-wrap if this element
# actually needs it, i.e. if it has more than one # actually needs it, i.e. if it has more than one
# consecutive space or it has newlines or tabs. # consecutive space or it has newlines or tabs.