mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Txt output mostly fixed
This commit is contained in:
parent
fca3f98e6a
commit
e6e9a20586
@ -39,10 +39,10 @@ class TXTOutput(OutputFormatPlugin):
|
||||
def convert(self, oeb_book, output_path, input_plugin, opts, log):
|
||||
metadata = TxtMetadata()
|
||||
if opts.prepend_author.lower() == 'true':
|
||||
metadata.author = opts.authors if opts.authors else authors_to_string(oeb_book.metadata.authors)
|
||||
metadata.author = opts.authors if opts.authors else authors_to_string(oeb_book.metadata.authors.value) if oeb_book.metadata.authors != [] else _('Unknown')
|
||||
if opts.prepend_title.lower() == 'true':
|
||||
metadata.title = opts.title if opts.title else oeb_book.metadata.title
|
||||
|
||||
metadata.title = opts.title if opts.title else oeb_book.metadata.title[0].value if oeb_book.metadata.title != [] else _('Unknown')
|
||||
|
||||
writer = TxtWriter(TxtNewlines(opts.newline).newline, log)
|
||||
txt = writer.dump(oeb_book.spine, metadata)
|
||||
|
||||
|
@ -22,16 +22,15 @@ class TxtWriter(object):
|
||||
def dump(self, spine, metadata):
|
||||
out = u''
|
||||
for item in spine:
|
||||
with open(item, 'r') as itemf:
|
||||
content = itemf.read().decode(item.encoding)
|
||||
# Convert newlines to unix style \n for processing. These
|
||||
# will be changed to the specified type later in the process.
|
||||
content = self.unix_newlines(content)
|
||||
content = self.strip_html(content)
|
||||
content = self.replace_html_symbols(content)
|
||||
content = self.cleanup_text(content)
|
||||
content = self.specified_newlines(content)
|
||||
out += content
|
||||
content = unicode(item)
|
||||
# Convert newlines to unix style \n for processing. These
|
||||
# will be changed to the specified type later in the process.
|
||||
content = self.unix_newlines(content)
|
||||
content = self.strip_html(content)
|
||||
content = self.replace_html_symbols(content)
|
||||
content = self.cleanup_text(content)
|
||||
content = self.specified_newlines(content)
|
||||
out += content
|
||||
|
||||
# Prepend metadata
|
||||
if metadata.author != None and metadata.author != '':
|
||||
|
Loading…
x
Reference in New Issue
Block a user