mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
MOBI Output: Fix bug that was discarding non breaking spaces at the start of a paragraph when they were followed immediately by a tag. Fixes #4887 (Treatment of italics when converting to Mobi)
This commit is contained in:
parent
c97e115873
commit
f403520cc8
@ -39,6 +39,13 @@ def asfloat(value):
|
||||
return 0.0
|
||||
return float(value)
|
||||
|
||||
def isspace(text):
|
||||
if not text:
|
||||
return True
|
||||
if u'\xa0' in text:
|
||||
return False
|
||||
return text.isspace()
|
||||
|
||||
class BlockState(object):
|
||||
def __init__(self, body):
|
||||
self.body = body
|
||||
@ -438,7 +445,7 @@ class MobiMLizer(object):
|
||||
if elem.text:
|
||||
if istate.preserve:
|
||||
text = elem.text
|
||||
elif len(elem) > 0 and elem.text.isspace():
|
||||
elif len(elem) > 0 and isspace(elem.text):
|
||||
text = None
|
||||
else:
|
||||
text = COLLAPSE.sub(' ', elem.text)
|
||||
@ -481,7 +488,7 @@ class MobiMLizer(object):
|
||||
if child.tail:
|
||||
if istate.preserve:
|
||||
tail = child.tail
|
||||
elif bstate.para is None and child.tail.isspace():
|
||||
elif bstate.para is None and isspace(child.tail):
|
||||
tail = None
|
||||
else:
|
||||
tail = COLLAPSE.sub(' ', child.tail)
|
||||
|
Loading…
x
Reference in New Issue
Block a user