[epub, mobi] added optional command line switch helpful with kindlegen conversion
[librarian.git] / librarian / text.py
index 9a4fd7a..0f3c0bb 100644 (file)
@@ -45,6 +45,8 @@ def transform(wldoc, flags=None, **options):
     if flags:
         for flag in flags:
             document.edoc.getroot().set(flag, 'yes')
     if flags:
         for flag in flags:
             document.edoc.getroot().set(flag, 'yes')
+    if 'wrapping' in options:
+        options['wrapping'] = str(options['wrapping'])
 
     result = document.transform(style, **options)
 
 
     result = document.transform(style, **options)
 
@@ -82,7 +84,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 +92,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()) + "\r\n")