Make the HTML shown in the regex builder closer to that actually processed by the conversion pipeline. Fixes #5549 (Not removing header/footer)

This commit is contained in:
Kovid Goyal 2010-05-28 15:22:58 -06:00
parent 2c597b855e
commit 1df7da603f
2 changed files with 10 additions and 8 deletions

View File

@ -166,7 +166,7 @@ class EbookIterator(object):
f.truncate() f.truncate()
f.write(ncss.encode(enc)) f.write(ncss.encode(enc))
def __enter__(self, processed=False): def __enter__(self, processed=False, only_input_plugin=False):
self.delete_on_exit = [] self.delete_on_exit = []
self._tdir = TemporaryDirectory('_ebook_iter') self._tdir = TemporaryDirectory('_ebook_iter')
self.base = self._tdir.__enter__() self.base = self._tdir.__enter__()
@ -184,12 +184,14 @@ class EbookIterator(object):
plumber.opts, plumber.input_fmt, self.log, plumber.opts, plumber.input_fmt, self.log,
{}, self.base) {}, self.base)
if processed or plumber.input_fmt.lower() in ('pdb', 'pdf', 'rb') and \ if not only_input_plugin:
not hasattr(self.pathtoopf, 'manifest'): if processed or plumber.input_fmt.lower() in ('pdb', 'pdf', 'rb') and \
if hasattr(self.pathtoopf, 'manifest'): not hasattr(self.pathtoopf, 'manifest'):
self.pathtoopf = write_oebbook(self.pathtoopf, self.base) if hasattr(self.pathtoopf, 'manifest'):
self.pathtoopf = create_oebbook(self.log, self.pathtoopf, plumber.opts, self.pathtoopf = write_oebbook(self.pathtoopf, self.base)
plumber.input_plugin) self.pathtoopf = create_oebbook(self.log, self.pathtoopf, plumber.opts,
plumber.input_plugin)
if hasattr(self.pathtoopf, 'manifest'): if hasattr(self.pathtoopf, 'manifest'):
self.pathtoopf = write_oebbook(self.pathtoopf, self.base) self.pathtoopf = write_oebbook(self.pathtoopf, self.base)

View File

@ -85,7 +85,7 @@ class RegexBuilder(QDialog, Ui_RegexBuilder):
def open_book(self, pathtoebook): def open_book(self, pathtoebook):
self.iterator = EbookIterator(pathtoebook) self.iterator = EbookIterator(pathtoebook)
self.iterator.__enter__(processed=True) self.iterator.__enter__(only_input_plugin=True)
text = [u''] text = [u'']
for path in self.iterator.spine: for path in self.iterator.spine:
html = open(path, 'rb').read().decode('utf-8', 'replace') html = open(path, 'rb').read().decode('utf-8', 'replace')