Skip to content

Commit abdc591

Browse files
committedMay 19, 2015
Merge pull request #1723 from getnikola/prettier-html
make lxml reformat HTML
2 parents 34f02ad + d116811 commit abdc591

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed
 

‎CHANGES.txt

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ New in master
44
Features
55
--------
66

7+
* Cleaner formatting of HTML output
78
* Allowing category hierarchies via new option CATEGORY_ALLOW_HIERARCHIES
89
(Issue #1520)
910

‎nikola/nikola.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,8 @@ def render_template(self, template_name, output_name, context):
969969
src = "/".join(src.split(os.sep))
970970

971971
utils.makedirs(os.path.dirname(output_name))
972-
doc = lxml.html.document_fromstring(data)
972+
parser = lxml.html.HTMLParser(remove_blank_text=True)
973+
doc = lxml.html.document_fromstring(data, parser)
973974
doc.rewrite_links(lambda dst: self.url_replacer(src, dst, context['lang']))
974975
data = b'<!DOCTYPE html>\n' + lxml.html.tostring(doc, encoding='utf8', method='html', pretty_print=True)
975976
with open(output_name, "wb+") as post_file:

0 commit comments

Comments
 (0)
Please sign in to comment.