danielfrg / pelican-jupyter

Pelican plugin for blogging with Jupyter/IPython Notebooks
Apache License 2.0
423 stars 105 forks source link

<body>tags bleed into main content #105

Open tjol opened 5 years ago

tjol commented 5 years ago

The <body> tag wrapped around the content when generating a summary (I assume for good reason) also turn up in the content of the post itself, where they don't belong.

This is the change I propose to fix it:

diff --git a/markup.py b/markup.py
index 56aba92..0651f4c 100644
--- a/markup.py
+++ b/markup.py
@@ -117,11 +117,11 @@ class IPythonNB(BaseReader):
             parser = MyHTMLParser(self.settings, filename)
             if isinstance(content, six.binary_type):
                 # unicode_literals makes format() try to decode as ASCII. Enforce decoding as UTF-8.
-                content = '<body>{0}</body>'.format(content.decode("utf-8"))
+                wrapped_content = '<body>{0}</body>'.format(content.decode("utf-8"))
             else:
                 # Content already decoded
-                content = '<body>{0}</body>'.format(content)
-            parser.feed(content)
+                wrapped_content = '<body>{0}</body>'.format(content)
+            parser.feed(wrapped_content)
             parser.close()
             # content = parser.body
             metadata['summary'] = parser.summary