From 55f33736b2efdb21507abb0714cd2ff36357334b Mon Sep 17 00:00:00 2001 From: Daniel Wagner-Hall Date: Thu, 10 Sep 2015 12:04:12 +0100 Subject: [PATCH] Preserve newlines in wrapped text --- templating/build.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/templating/build.py b/templating/build.py index dadf91ce5..258e4a174 100755 --- a/templating/build.py +++ b/templating/build.py @@ -78,8 +78,10 @@ def main(input_module, file_stream=None, out_dir=None, verbose=False): def wrap(input, wrap=80, initial_indent=""): if len(input) == 0: return initial_indent + input_lines = input.split('\n') wrapper = TextWrapper(initial_indent=initial_indent, width=wrap) - return wrapper.fill(input) + output_lines = [wrapper.fill(line) for line in input_lines] + return '\n'.join(output_lines) # make Jinja aware of the templates and filters env = Environment(