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 0.0
|
||||||
return float(value)
|
return float(value)
|
||||||
|
|
||||||
|
def isspace(text):
|
||||||
|
if not text:
|
||||||
|
return True
|
||||||
|
if u'\xa0' in text:
|
||||||
|
return False
|
||||||
|
return text.isspace()
|
||||||
|
|
||||||
class BlockState(object):
|
class BlockState(object):
|
||||||
def __init__(self, body):
|
def __init__(self, body):
|
||||||
self.body = body
|
self.body = body
|
||||||
@ -438,7 +445,7 @@ class MobiMLizer(object):
|
|||||||
if elem.text:
|
if elem.text:
|
||||||
if istate.preserve:
|
if istate.preserve:
|
||||||
text = elem.text
|
text = elem.text
|
||||||
elif len(elem) > 0 and elem.text.isspace():
|
elif len(elem) > 0 and isspace(elem.text):
|
||||||
text = None
|
text = None
|
||||||
else:
|
else:
|
||||||
text = COLLAPSE.sub(' ', elem.text)
|
text = COLLAPSE.sub(' ', elem.text)
|
||||||
@ -481,7 +488,7 @@ class MobiMLizer(object):
|
|||||||
if child.tail:
|
if child.tail:
|
||||||
if istate.preserve:
|
if istate.preserve:
|
||||||
tail = child.tail
|
tail = child.tail
|
||||||
elif bstate.para is None and child.tail.isspace():
|
elif bstate.para is None and isspace(child.tail):
|
||||||
tail = None
|
tail = None
|
||||||
else:
|
else:
|
||||||
tail = COLLAPSE.sub(' ', child.tail)
|
tail = COLLAPSE.sub(' ', child.tail)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user