From 99106bb6fefd0b2f44c1ff418491f7d54c52cc8c Mon Sep 17 00:00:00 2001 From: Daniel Wagner-Hall Date: Thu, 10 Sep 2015 13:54:00 +0100 Subject: [PATCH] Add explanatory comments Also, remove line which was accidentally removed --- templating/build.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/templating/build.py b/templating/build.py index 6756bed9..ac3d2491 100755 --- a/templating/build.py +++ b/templating/build.py @@ -76,6 +76,11 @@ def main(input_module, file_stream=None, out_dir=None, verbose=False): return " "*indent + input def wrap(input, wrap=80, initial_indent=""): + if len(input) == 0: + return initial_indent + # TextWrapper collapses newlines into single spaces; we do our own + # splitting on newlines to prevent this, so that newlines can actually + # be intentionally inserted in text. input_lines = input.split('\n\n') wrapper = TextWrapper(initial_indent=initial_indent, width=wrap) output_lines = [wrapper.fill(line) for line in input_lines]