[txt] return Windows friendly txt file with \r\n line ends instead of \n
authorRobert Błaut <listy@blaut.biz>
Wed, 29 Jan 2014 14:48:48 +0000 (15:48 +0100)
committerRobert Błaut <listy@blaut.biz>
Wed, 29 Jan 2014 14:48:48 +0000 (15:48 +0100)
POSIX editors recognize Windows line end. Notepad on Windows does not
recognize POSIX line ends.

librarian/text.py

index 9a4fd7a..9edfa62 100644 (file)
@@ -82,7 +82,7 @@ def transform(wldoc, flags=None, **options):
             source = ""
             contributors = ""
             funders = ""
             source = ""
             contributors = ""
             funders = ""
-        return OutputFile.from_string((TEMPLATE % {
+        result = (TEMPLATE % {
             'description': description,
             'url': url,
             'license_description': license_description,
             'description': description,
             'url': url,
             'license_description': license_description,
@@ -90,7 +90,8 @@ def transform(wldoc, flags=None, **options):
             'source': source,
             'contributors': contributors,
             'funders': funders,
             'source': source,
             'contributors': contributors,
             'funders': funders,
-        }).encode('utf-8'))
+        }).encode('utf-8')
     else:
     else:
-        return OutputFile.from_string(unicode(result).encode('utf-8'))
+        result = unicode(result).encode('utf-8')
+    return OutputFile.from_string("\r\n".join(result.splitlines()))