From 9991c41fcbc30e5643e60dcf5733c349c7987ba6 Mon Sep 17 00:00:00 2001 From: John Schember Date: Mon, 21 Sep 2009 17:26:37 -0400 Subject: [PATCH] TXT Output: Fix specified_newlines to change the line ending type correctly. --- src/calibre/ebooks/txt/newlines.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/calibre/ebooks/txt/newlines.py b/src/calibre/ebooks/txt/newlines.py index ae766a216f..d7e97654b4 100644 --- a/src/calibre/ebooks/txt/newlines.py +++ b/src/calibre/ebooks/txt/newlines.py @@ -19,7 +19,11 @@ class TxtNewlines(object): self.newline = self.NEWLINE_TYPES.get(newline_type.lower(), os.linesep) def specified_newlines(newline, text): + # Convert all newlines to \n + text = text.replace('\r\n', '\n') + text = text.replace('\r', '\n') + if newline == '\n': return text - return text.replace(os.linesep, newline) + return text.replace('\n', newline)