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):