Fix potential exception in soup2html.
- Legacy-Id: 340
This commit is contained in:
parent
8deca3446e
commit
6b7137994a
|
@ -87,10 +87,9 @@ def render(node, encoding='latin-1', pre=False):
|
||||||
blocks.append(child.text+"\n\n")
|
blocks.append(child.text+"\n\n")
|
||||||
node.is_block = True
|
node.is_block = True
|
||||||
else:
|
else:
|
||||||
if child.text:
|
if child.name in space_tags and not (words[-1] and words[-1][-1] in [" ", "\t", "\n"]):
|
||||||
if child.name in space_tags and not words[-1][-1] in [" ", "\t", "\n"]:
|
words.append(" ")
|
||||||
words.append(" ")
|
words.append(child.text)
|
||||||
words.append(child.text)
|
|
||||||
else:
|
else:
|
||||||
raise ValueError("Unexpected node type: '%s'" % child)
|
raise ValueError("Unexpected node type: '%s'" % child)
|
||||||
if words:
|
if words:
|
||||||
|
|
Loading…
Reference in a new issue