Skip to content
Permalink
Browse files

Fix #2851 — fix crash when compiling empty .html posts

Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Jun 22, 2017
1 parent 27433a1 commit 3e63e39cd6a2e68953072539eb08d04c82f9c272
Showing with 9 additions and 1 deletion.
  1. +1 −0 CHANGES.txt
  2. +8 −1 nikola/plugins/compile/html.py
@@ -9,6 +9,7 @@ Features
Bugfixes
--------

* Fix crash when compiling empty ``.html`` posts (Issue #2851)
* Make failures to get source commit hash non-fatal in
``github_deploy`` (Issue #2847)
* Less cryptic error when guessing format from extension in ``new_post``
@@ -96,7 +96,14 @@ def read_metadata(self, post, file_metadata_regexp=None, unslugify_titles=False,
data = inf.read()

metadata = {}
doc = lxml.html.document_fromstring(data)
try:
doc = lxml.html.document_fromstring(data)
except lxml.etree.ParserError as e:
# Issue #374 -> #2851
if str(e) == "Document is empty":
return {}
# let other errors raise
raise
title_tag = doc.find('*//title')
if title_tag is not None:
metadata['title'] = title_tag.text

0 comments on commit 3e63e39

Please sign in to comment.