Skip to content

Commit

Permalink
Fix #2890 — Ignore empty tags in HTML metadata reader
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Aug 24, 2017
1 parent dd5e8a7 commit bc4ef22
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
@@ -1,6 +1,7 @@
New in v7-maintenance
=====================

* Ignore empty tags in HTML metadata reader (Issue #2890)
* Fix crash when compiling empty ``.html`` posts (Issue #2851)

New in v7.8.9
Expand Down
6 changes: 4 additions & 2 deletions nikola/plugins/compile/html.py
Expand Up @@ -106,7 +106,7 @@ def read_metadata(self, post, file_metadata_regexp=None, unslugify_titles=False,
# let other errors raise
raise
title_tag = doc.find('*//title')
if title_tag is not None:
if title_tag is not None and title_tag.text:
metadata['title'] = title_tag.text
meta_tags = doc.findall('*//meta')
for tag in meta_tags:
Expand All @@ -115,6 +115,8 @@ def read_metadata(self, post, file_metadata_regexp=None, unslugify_titles=False,
continue
elif k == 'keywords':
k = 'tags'
metadata[k] = tag.get('content', '')
content = tag.get('content')
if content:
metadata[k] = content
map_metadata(metadata, 'html_metadata', self.site.config)
return metadata

0 comments on commit bc4ef22

Please sign in to comment.