diff --git a/markup.py b/markup.py index 84de508..5349ad0 100644 --- a/markup.py +++ b/markup.py @@ -1,4 +1,5 @@ from __future__ import absolute_import, print_function, division +from __future__ import unicode_literals import os import json @@ -83,7 +84,10 @@ class IPythonNB(BaseReader): content = '{0}'.format(content) # So Pelican HTMLReader works parser = MyHTMLParser(self.settings, filename) if hasattr(content, 'decode'): # PY2 - content = content.decode("utf-8") + try: + content = content.decode("utf-8") + except UnicodeEncodeError: + pass # Content is already encoded. parser.feed(content) parser.close() content = parser.body