mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
catch missing src in img
This commit is contained in:
parent
3500195290
commit
e7911652ef
1 changed files with 7 additions and 2 deletions
|
@ -296,8 +296,13 @@ def _filterHTML(html):
|
||||||
tag.replaceWithChildren()
|
tag.replaceWithChildren()
|
||||||
# turn file:/// links into relative ones
|
# turn file:/// links into relative ones
|
||||||
for tag in doc("img"):
|
for tag in doc("img"):
|
||||||
if tag['src'].lower().startswith("file://"):
|
try:
|
||||||
tag['src'] = os.path.basename(tag['src'])
|
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
|
# strip superfluous elements
|
||||||
for elem in "html", "head", "body", "meta":
|
for elem in "html", "head", "body", "meta":
|
||||||
for tag in doc(elem):
|
for tag in doc(elem):
|
||||||
|
|
Loading…
Reference in a new issue