mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
TXT Output: Fix specified_newlines to change the line ending type correctly.
This commit is contained in:
parent
5375c1bee0
commit
9991c41fcb
@ -19,7 +19,11 @@ class TxtNewlines(object):
|
|||||||
self.newline = self.NEWLINE_TYPES.get(newline_type.lower(), os.linesep)
|
self.newline = self.NEWLINE_TYPES.get(newline_type.lower(), os.linesep)
|
||||||
|
|
||||||
def specified_newlines(newline, text):
|
def specified_newlines(newline, text):
|
||||||
|
# Convert all newlines to \n
|
||||||
|
text = text.replace('\r\n', '\n')
|
||||||
|
text = text.replace('\r', '\n')
|
||||||
|
|
||||||
if newline == '\n':
|
if newline == '\n':
|
||||||
return text
|
return text
|
||||||
|
|
||||||
return text.replace(os.linesep, newline)
|
return text.replace('\n', newline)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user