diff --git a/nbconvert/filters/markdown_mistune.py b/nbconvert/filters/markdown_mistune.py index ff209f372..a46be513f 100644 --- a/nbconvert/filters/markdown_mistune.py +++ b/nbconvert/filters/markdown_mistune.py @@ -160,7 +160,10 @@ def image(self, src, title, text): attachment_prefix = 'attachment:' if src.startswith(attachment_prefix): name = src[len(attachment_prefix):] - assert name in attachments, "missing attachment: {}".format(name) + + if not name in attachments: + raise InvalidNotebook("missing attachment: {}".format(name)) + attachment = attachments[name] # we choose vector over raster, and lossless over lossy preferred_mime_types = ['image/svg+xml', 'image/png', 'image/jpeg'] diff --git a/nbconvert/nbconvertapp.py b/nbconvert/nbconvertapp.py index e137a173d..97ca798b2 100755 --- a/nbconvert/nbconvertapp.py +++ b/nbconvert/nbconvertapp.py @@ -595,6 +595,9 @@ def initialize(self, argv=None): def default_export_format(self): return 'html' +class InvalidNotebook(Exception): + pass + #----------------------------------------------------------------------------- # Main entry point #-----------------------------------------------------------------------------