mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Viewer: Fix text after comments not being rendered. Fixes #1846875 [text after HTML comment in epub is not displayed](https://bugs.launchpad.net/calibre/+bug/1846875)
This commit is contained in:
parent
94ea7c67ef
commit
5e25ebd6f1
@ -590,13 +590,25 @@ def html_as_dict(root):
|
||||
stack = [(root, tree)]
|
||||
while stack:
|
||||
elem, node = stack.pop()
|
||||
for child in elem.iterchildren('*'):
|
||||
cnode = serialize_elem(child, nsmap)
|
||||
if cnode is not None:
|
||||
tags.append(cnode)
|
||||
child_tree_node = [len(tags)-1]
|
||||
node.append(child_tree_node)
|
||||
stack.append((child, child_tree_node))
|
||||
prev_child_node = None
|
||||
for child in elem.iterchildren():
|
||||
tag = getattr(child, 'tag', None)
|
||||
if tag is None or callable(tag):
|
||||
tail = getattr(child, 'tail', None)
|
||||
if tail:
|
||||
if prev_child_node is None:
|
||||
parent_node = tags[node[-1]]
|
||||
parent_node['x'] = parent_node.get('x', '') + tail
|
||||
else:
|
||||
prev_child_node['l'] = prev_child_node.get('l', '') + tail
|
||||
else:
|
||||
cnode = serialize_elem(child, nsmap)
|
||||
if cnode is not None:
|
||||
tags.append(cnode)
|
||||
child_tree_node = [len(tags)-1]
|
||||
node.append(child_tree_node)
|
||||
stack.append((child, child_tree_node))
|
||||
prev_child_node = cnode
|
||||
ns_map = [ns for ns, nsnum in sorted(iteritems(nsmap), key=lambda x: x[1])]
|
||||
return {'ns_map':ns_map, 'tag_map':tags, 'tree':tree}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user