Have palmdoc and ztxt pdb files use new txt parser.

This commit is contained in:
John Schember 2009-07-12 20:42:03 -04:00
parent a74210802b
commit bfaa45c563
2 changed files with 15 additions and 8 deletions

View File

@ -13,8 +13,8 @@ import struct
from calibre.ebooks.compression.palmdoc import compress_doc
from calibre.ebooks.pdb.formatwriter import FormatWriter
from calibre.ebooks.pdb.header import PdbHeaderBuilder
from calibre.ebooks.txt.writer import TxtNewlines
from calibre.ebooks.txt.writer import TxtWriter
from calibre.ebooks.txt.txtml import TXTMLizer
from calibre.ebooks.txt.newlines import TxtNewlines, specified_newlines
MAX_RECORD_SIZE = 4096
@ -45,8 +45,11 @@ class Writer(FormatWriter):
out_stream.write(record)
def _generate_text(self, spine):
txt_writer = TxtWriter(TxtNewlines('system').newline, self.log)
txt = txt_writer.dump(spine).encode(self.opts.output_encoding, 'replace')
writer = TXTMLizer(log)
txt = writer.extract_content(oeb_book, opts)
log.debug('\tReplacing newlines with selected type...')
txt = specified_newlines(TxtNewlines(opts.newline).newline, txt).encode(self.opts.output_encoding, 'replace')
txt_length = len(txt)

View File

@ -11,8 +11,9 @@ __docformat__ = 'restructuredtext en'
import struct, zlib
from calibre.ebooks.pdb.formatwriter import FormatWriter
from calibre.ebooks.txt.writer import TxtWriter, TxtNewlines
from calibre.ebooks.pdb.header import PdbHeaderBuilder
from calibre.ebooks.txt.txtml import TXTMLizer
from calibre.ebooks.txt.newlines import TxtNewlines, specified_newlines
MAX_RECORD_SIZE = 8192
@ -49,8 +50,11 @@ class Writer(FormatWriter):
out_stream.write(record)
def _generate_text(self, spine):
txt_writer = TxtWriter(TxtNewlines('system').newline, self.log)
txt = txt_writer.dump(spine).encode(self.opts.output_encoding, 'replace')
writer = TXTMLizer(log)
txt = writer.extract_content(oeb_book, opts)
log.debug('\tReplacing newlines with selected type...')
txt = specified_newlines(TxtNewlines(opts.newline).newline, txt).encode(self.opts.output_encoding, 'replace')
txt_length = len(txt)