From e7911652ef34af8b436ab05201724987ca7bccca Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sun, 6 May 2012 12:45:25 +0900 Subject: [PATCH] catch missing src in img --- aqt/editor.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/aqt/editor.py b/aqt/editor.py index c87352058..ee4916709 100644 --- a/aqt/editor.py +++ b/aqt/editor.py @@ -296,8 +296,13 @@ def _filterHTML(html): tag.replaceWithChildren() # turn file:/// links into relative ones for tag in doc("img"): - if tag['src'].lower().startswith("file://"): - tag['src'] = os.path.basename(tag['src']) + 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):