mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-05 06:23:42 +02:00
FB2,PML,RB,TXT Output: Fix removing of extra spaces too aggresive
This commit is contained in:
parent
47eb8c1f3e
commit
b9ae515df6
4 changed files with 11 additions and 11 deletions
|
|
@ -241,7 +241,7 @@ def dump_text(self, elem, stylizer, page, tag_stack=[]):
|
|||
if not fb2_text or fb2_text[-1] != ' ':
|
||||
fb2_text.append(' ')
|
||||
|
||||
if hasattr(elem, 'text') and elem.text != None:
|
||||
if hasattr(elem, 'text') and elem.text:
|
||||
if 'p' not in tag_stack:
|
||||
fb2_text.append('<p>%s</p>' % prepare_string_for_xml(elem.text))
|
||||
else:
|
||||
|
|
@ -255,7 +255,7 @@ def dump_text(self, elem, stylizer, page, tag_stack=[]):
|
|||
close_tag_list.insert(0, tag_stack.pop())
|
||||
fb2_text += self.close_tags(close_tag_list)
|
||||
|
||||
if hasattr(elem, 'tail') and elem.tail != None:
|
||||
if hasattr(elem, 'tail') and elem.tail:
|
||||
if 'p' not in tag_stack:
|
||||
fb2_text.append('<p>%s</p>' % prepare_string_for_xml(elem.tail))
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -257,7 +257,7 @@ def dump_text(self, elem, stylizer, page, tag_stack=[]):
|
|||
# margin
|
||||
|
||||
# Proccess tags that contain text.
|
||||
if hasattr(elem, 'text') and elem.text != None and elem.text.strip() != '':
|
||||
if hasattr(elem, 'text') and elem.text:
|
||||
text.append(self.remove_newlines(elem.text))
|
||||
|
||||
for item in elem:
|
||||
|
|
@ -276,7 +276,7 @@ def dump_text(self, elem, stylizer, page, tag_stack=[]):
|
|||
#if style['page-break-after'] == 'always':
|
||||
# text.append('\\p')
|
||||
|
||||
if hasattr(elem, 'tail') and elem.tail != None and elem.tail.strip() != '':
|
||||
if hasattr(elem, 'tail') and elem.tail:
|
||||
text.append(self.remove_newlines(elem.tail))
|
||||
|
||||
return text
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ def dump_text(self, elem, stylizer, page, tag_stack=[]):
|
|||
tag_stack.append(style_tag)
|
||||
|
||||
# Proccess tags that contain text.
|
||||
if hasattr(elem, 'text') and elem.text != None and elem.text.strip() != '':
|
||||
if hasattr(elem, 'text') and elem.text:
|
||||
text.append(prepare_string_for_xml(elem.text))
|
||||
|
||||
for item in elem:
|
||||
|
|
@ -203,7 +203,7 @@ def dump_text(self, elem, stylizer, page, tag_stack=[]):
|
|||
|
||||
text += self.close_tags(close_tag_list)
|
||||
|
||||
if hasattr(elem, 'tail') and elem.tail != None and elem.tail.strip() != '':
|
||||
if hasattr(elem, 'tail') and elem.tail:
|
||||
text.append(prepare_string_for_xml(elem.tail))
|
||||
|
||||
return text
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ def cleanup_text(self, text):
|
|||
text = re.sub('(?<=.)%s(?=.)' % os.linesep, ' ', text)
|
||||
|
||||
# Remove multiple spaces.
|
||||
text = re.sub('[ ]+', ' ', text)
|
||||
text = re.sub('[ ]{2,}', ' ', text)
|
||||
|
||||
# Remove excessive newlines.
|
||||
text = re.sub('\n[ ]+\n', '\n\n', text)
|
||||
|
|
@ -172,15 +172,15 @@ def dump_text(self, elem, stylizer, end=''):
|
|||
# Are we in a paragraph block?
|
||||
if tag in BLOCK_TAGS or style['display'] in BLOCK_STYLES:
|
||||
in_block = True
|
||||
if not end.endswith(u'\n\n') and hasattr(elem, 'text') and elem.text != None and elem.text.strip() != '':
|
||||
if not end.endswith(u'\n\n') and hasattr(elem, 'text') and elem.text:
|
||||
text.append(u'\n\n')
|
||||
|
||||
if tag in SPACE_TAGS:
|
||||
if not end.endswith('u ') and hasattr(elem, 'text') and elem.text != None and elem.text.strip() != '':
|
||||
if not end.endswith('u ') and hasattr(elem, 'text') and elem.text:
|
||||
text.append(u' ')
|
||||
|
||||
# Process tags that contain text.
|
||||
if hasattr(elem, 'text') and elem.text != None and elem.text.strip() != '':
|
||||
if hasattr(elem, 'text') and elem.text:
|
||||
text.append(elem.text)
|
||||
|
||||
for item in elem:
|
||||
|
|
@ -192,7 +192,7 @@ def dump_text(self, elem, stylizer, end=''):
|
|||
if in_block:
|
||||
text.append(u'\n\n')
|
||||
|
||||
if hasattr(elem, 'tail') and elem.tail != None and elem.tail.strip() != '':
|
||||
if hasattr(elem, 'tail') and elem.tail:
|
||||
text.append(elem.tail)
|
||||
|
||||
return text
|
||||
|
|
|
|||
Loading…
Reference in a new issue