Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #1723 from getnikola/prettier-html
make lxml reformat HTML
  • Loading branch information
ralsina committed May 19, 2015
2 parents 34f02ad + d116811 commit abdc591
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.txt
Expand Up @@ -4,6 +4,7 @@ New in master
Features
--------

* Cleaner formatting of HTML output
* Allowing category hierarchies via new option CATEGORY_ALLOW_HIERARCHIES
(Issue #1520)

Expand Down
3 changes: 2 additions & 1 deletion nikola/nikola.py
Expand Up @@ -969,7 +969,8 @@ def render_template(self, template_name, output_name, context):
src = "/".join(src.split(os.sep))

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

0 comments on commit abdc591

Please sign in to comment.