1
0
Fork 0
forked from github/pelican

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'
This commit is contained in:
Will Thompson 2016-08-11 07:51:39 +01:00
commit 904f57d9c3

View file

@ -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