mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-08 22:14:07 +02:00
Fix for Bug #1026541: non-visibile element's tail text (which should be visible) is being ignored when it shouldn't.
This commit is contained in:
parent
f1979e8196
commit
c8bf6a66f1
8 changed files with 36 additions and 5 deletions
|
|
@ -355,10 +355,17 @@ def dump_text(self, elem_tree, stylizer, page, tag_stack=[]):
|
|||
|
||||
# Ensure what we are converting is not a string and that the fist tag is part of the XHTML namespace.
|
||||
if not isinstance(elem_tree.tag, basestring) or namespace(elem_tree.tag) != XHTML_NS:
|
||||
p = elem.getparent()
|
||||
if p is not None and isinstance(p.tag, basestring) and namespace(p.tag) == XHTML_NS \
|
||||
and elem.tail:
|
||||
return [elem.tail]
|
||||
return []
|
||||
|
||||
style = stylizer.style(elem_tree)
|
||||
if style['display'] in ('none', 'oeb-page-head', 'oeb-page-foot') or style['visibility'] == 'hidden':
|
||||
if style['display'] in ('none', 'oeb-page-head', 'oeb-page-foot') \
|
||||
or style['visibility'] == 'hidden':
|
||||
if hasattr(elem, 'tail') and elem.tail:
|
||||
return [elem.tail]
|
||||
return []
|
||||
|
||||
# FB2 generated output.
|
||||
|
|
|
|||
|
|
@ -220,8 +220,11 @@ def clean_text(self, text):
|
|||
def dump_text(self, elem, stylizer, page, tag_stack=[]):
|
||||
from calibre.ebooks.oeb.base import XHTML_NS, barename, namespace
|
||||
|
||||
if not isinstance(elem.tag, basestring) \
|
||||
or namespace(elem.tag) != XHTML_NS:
|
||||
if not isinstance(elem_tree.tag, basestring) or namespace(elem_tree.tag) != XHTML_NS:
|
||||
p = elem.getparent()
|
||||
if p is not None and isinstance(p.tag, basestring) and namespace(p.tag) == XHTML_NS \
|
||||
and elem.tail:
|
||||
return [elem.tail]
|
||||
return []
|
||||
|
||||
text = []
|
||||
|
|
@ -230,6 +233,8 @@ def dump_text(self, elem, stylizer, page, tag_stack=[]):
|
|||
|
||||
if style['display'] in ('none', 'oeb-page-head', 'oeb-page-foot') \
|
||||
or style['visibility'] == 'hidden':
|
||||
if hasattr(elem, 'tail') and elem.tail:
|
||||
return [elem.tail]
|
||||
return []
|
||||
|
||||
tag = barename(elem.tag)
|
||||
|
|
|
|||
|
|
@ -142,8 +142,11 @@ def clean_text(self, text):
|
|||
def dump_text(self, elem, stylizer, page, tag_stack=[]):
|
||||
from calibre.ebooks.oeb.base import XHTML_NS, barename, namespace
|
||||
|
||||
if not isinstance(elem.tag, basestring) \
|
||||
or namespace(elem.tag) != XHTML_NS:
|
||||
if not isinstance(elem_tree.tag, basestring) or namespace(elem_tree.tag) != XHTML_NS:
|
||||
p = elem.getparent()
|
||||
if p is not None and isinstance(p.tag, basestring) and namespace(p.tag) == XHTML_NS \
|
||||
and elem.tail:
|
||||
return [elem.tail]
|
||||
return [u'']
|
||||
|
||||
text = [u'']
|
||||
|
|
@ -151,6 +154,8 @@ def dump_text(self, elem, stylizer, page, tag_stack=[]):
|
|||
|
||||
if style['display'] in ('none', 'oeb-page-head', 'oeb-page-foot') \
|
||||
or style['visibility'] == 'hidden':
|
||||
if hasattr(elem, 'tail') and elem.tail:
|
||||
return [elem.tail]
|
||||
return [u'']
|
||||
|
||||
tag = barename(elem.tag)
|
||||
|
|
|
|||
|
|
@ -229,6 +229,8 @@ def dump_text(self, elem, stylizer, tag_stack=[]):
|
|||
|
||||
if style['display'] in ('none', 'oeb-page-head', 'oeb-page-foot') \
|
||||
or style['visibility'] == 'hidden':
|
||||
if hasattr(elem, 'tail') and elem.tail:
|
||||
return elem.tail
|
||||
return u''
|
||||
|
||||
tag = barename(elem.tag)
|
||||
|
|
|
|||
|
|
@ -212,6 +212,10 @@ def dump_text(self, subitems, elem, stylizer, end='', pre=False, li = ''):
|
|||
|
||||
if not isinstance(elem.tag, basestring) \
|
||||
or namespace(elem.tag) != XHTML_NS:
|
||||
p = elem.getparent()
|
||||
if p is not None and isinstance(p.tag, basestring) and namespace(p.tag) == XHTML_NS \
|
||||
and elem.tail:
|
||||
return [elem.tail]
|
||||
return ['']
|
||||
|
||||
|
||||
|
|
@ -225,6 +229,8 @@ def dump_text(self, subitems, elem, stylizer, end='', pre=False, li = ''):
|
|||
|
||||
if style['display'] in ('none', 'oeb-page-head', 'oeb-page-foot') \
|
||||
or style['visibility'] == 'hidden':
|
||||
if hasattr(elem, 'tail') and elem.tail:
|
||||
return [elem.tail]
|
||||
return ['']
|
||||
|
||||
tag = barename(elem.tag)
|
||||
|
|
|
|||
|
|
@ -127,6 +127,8 @@ def dump_text(self, elem, stylizer):
|
|||
# Ignore anything that is set to not be displayed.
|
||||
if style['display'] in ('none', 'oeb-page-head', 'oeb-page-foot') \
|
||||
or style['visibility'] == 'hidden':
|
||||
if hasattr(elem, 'tail') and elem.tail:
|
||||
return [elem.tail]
|
||||
return ['']
|
||||
|
||||
# Soft scene breaks.
|
||||
|
|
|
|||
|
|
@ -241,6 +241,8 @@ def dump_text(self, elem, stylizer):
|
|||
# Ignore anything that is set to not be displayed.
|
||||
if style['display'] in ('none', 'oeb-page-head', 'oeb-page-foot') \
|
||||
or style['visibility'] == 'hidden':
|
||||
if hasattr(elem, 'tail') and elem.tail:
|
||||
return [elem.tail]
|
||||
return ['']
|
||||
|
||||
# Soft scene breaks.
|
||||
|
|
|
|||
|
|
@ -200,6 +200,8 @@ def dump_text(self, elem, stylizer, page):
|
|||
|
||||
if style['display'] in ('none', 'oeb-page-head', 'oeb-page-foot') \
|
||||
or style['visibility'] == 'hidden':
|
||||
if hasattr(elem, 'tail') and elem.tail:
|
||||
return [elem.tail]
|
||||
return ['']
|
||||
|
||||
tag = barename(elem.tag)
|
||||
|
|
|
|||
Loading…
Reference in a new issue