Skip to content

Commit

Permalink
Improving documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfontein committed Oct 25, 2016
1 parent 8785681 commit 9a2551d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion nikola/nikola.py
Expand Up @@ -1343,7 +1343,10 @@ def render_template(self, template_name, output_name, context, url_type=None, is
doc = lxml.html.document_fromstring(data, parser)
self.rewrite_links(doc, src, context['lang'], url_type)
if is_fragment:
data = (doc.text or '').encode('utf-8') + ''.encode('utf-8').join([lxml.html.tostring(child, encoding='utf-8', method='html') for child in doc.iterchildren()])
# doc.text contains text before the first HTML, or None if there was no text
# The text after HTML elements is added by tostring() (because its implicit
# argument with_tail has default value True).
data = (doc.text or '').encode('utf-8') + b''.join([lxml.html.tostring(child, encoding='utf-8', method='html') for child in doc.iterchildren()])
else:
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 9a2551d

Please sign in to comment.