catch missing src in img

This commit is contained in:
Damien Elmes 2012-05-06 12:45:25 +09:00
parent 3500195290
commit e7911652ef

View file

@ -296,8 +296,13 @@ def _filterHTML(html):
tag.replaceWithChildren()
# turn file:/// links into relative ones
for tag in doc("img"):
try:
if tag['src'].lower().startswith("file://"):
tag['src'] = os.path.basename(tag['src'])
except KeyError:
# for some bizarre reason, mnemosyne removes src elements
# from missing media
pass
# strip superfluous elements
for elem in "html", "head", "body", "meta":
for tag in doc(elem):