Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit bc4ef22

Browse files
committedAug 24, 2017
Fix #2890 — Ignore empty tags in HTML metadata reader
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
1 parent dd5e8a7 commit bc4ef22

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed
 

‎CHANGES.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
New in v7-maintenance
22
=====================
33

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

67
New in v7.8.9

‎nikola/plugins/compile/html.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def read_metadata(self, post, file_metadata_regexp=None, unslugify_titles=False,
106106
# let other errors raise
107107
raise
108108
title_tag = doc.find('*//title')
109-
if title_tag is not None:
109+
if title_tag is not None and title_tag.text:
110110
metadata['title'] = title_tag.text
111111
meta_tags = doc.findall('*//meta')
112112
for tag in meta_tags:
@@ -115,6 +115,8 @@ def read_metadata(self, post, file_metadata_regexp=None, unslugify_titles=False,
115115
continue
116116
elif k == 'keywords':
117117
k = 'tags'
118-
metadata[k] = tag.get('content', '')
118+
content = tag.get('content')
119+
if content:
120+
metadata[k] = content
119121
map_metadata(metadata, 'html_metadata', self.site.config)
120122
return metadata

0 commit comments

Comments
 (0)
Please sign in to comment.