From 904f57d9c33d1ed9831d24ef360ca1ceaea790a3 Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Thu, 11 Aug 2016 07:51:39 +0100 Subject: [PATCH] MarkdownReader: don't raise AttributeError on empty files Markdown.convert() returns early, without running any preprocessors, if source.strip() is empty. Before, Pelican would raise AttributeError in this case; now, it logs a more friendly error: ERROR: Skipping ./foo.md: could not find information about 'NameError: title' which is more consistent with the error from empty .rst files: ERROR: Skipping ./foo.rst: could not find information about 'NameError: date' --- pelican/readers.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pelican/readers.py b/pelican/readers.py index a3e89af8..48985ed6 100644 --- a/pelican/readers.py +++ b/pelican/readers.py @@ -288,7 +288,10 @@ class MarkdownReader(BaseReader): with pelican_open(source_path) as text: content = self._md.convert(text) - metadata = self._parse_metadata(self._md.Meta) + if hasattr(self._md, 'Meta'): + metadata = self._parse_metadata(self._md.Meta) + else: + metadata = {} return content, metadata