Skip to content

Commit 9a2551d

Browse files
committedOct 25, 2016
Improving documentation.
1 parent 8785681 commit 9a2551d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed
 

‎nikola/nikola.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1343,7 +1343,10 @@ def render_template(self, template_name, output_name, context, url_type=None, is
13431343
doc = lxml.html.document_fromstring(data, parser)
13441344
self.rewrite_links(doc, src, context['lang'], url_type)
13451345
if is_fragment:
1346-
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()])
1346+
# doc.text contains text before the first HTML, or None if there was no text
1347+
# The text after HTML elements is added by tostring() (because its implicit
1348+
# argument with_tail has default value True).
1349+
data = (doc.text or '').encode('utf-8') + b''.join([lxml.html.tostring(child, encoding='utf-8', method='html') for child in doc.iterchildren()])
13471350
else:
13481351
data = b'<!DOCTYPE html>\n' + lxml.html.tostring(doc, encoding='utf8', method='html', pretty_print=True)
13491352
with open(output_name, "wb+") as post_file:

0 commit comments

Comments
 (0)
Please sign in to comment.