Skip to content
Permalink
Browse files

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 abdc591eb9d316568e52729e6d89f43025cc82b1
Showing with 3 additions and 1 deletion.
  1. +1 −0 CHANGES.txt
  2. +2 −1 nikola/nikola.py
@@ -4,6 +4,7 @@ New in master
Features
--------

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

@@ -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:

0 comments on commit abdc591

Please sign in to comment.
You can’t perform that action at this time.