Fix #3377 (--toc-filter only removes alternate entries)

This commit is contained in:
Kovid Goyal 2009-09-01 17:54:55 -06:00
parent 5f6c330901
commit 707f0ffa0c
2 changed files with 11 additions and 9 deletions

View File

@ -237,14 +237,14 @@ class HTMLPreProcessor(object):
(re.compile(getattr(self.extra_opts, 'footer_regex')), lambda match : '')
)
end_rules = []
if getattr(self.extra_opts, 'unwrap_factor', None):
length = line_length(html, getattr(self.extra_opts, 'unwrap_factor'))
if length:
end_rules.append(
# Un wrap using punctuation
(re.compile(r'(?<=.{%i}[a-z\.,;:)-IA])\s*(?P<ital></(i|b|u)>)?\s*(<p.*?>)\s*(?=(<(i|b|u)>)?\s*[\w\d(])' % length, re.UNICODE), wrap_lines),
)
end_rules = []
if getattr(self.extra_opts, 'unwrap_factor', None):
length = line_length(html, getattr(self.extra_opts, 'unwrap_factor'))
if length:
end_rules.append(
# Un wrap using punctuation
(re.compile(r'(?<=.{%i}[a-z\.,;:)-IA])\s*(?P<ital></(i|b|u)>)?\s*(<p.*?>)\s*(?=(<(i|b|u)>)?\s*[\w\d(])' % length, re.UNICODE), wrap_lines),
)
for rule in self.PREPROCESS + pre_rules + rules + end_rules:
html = rule[0].sub(rule[1], html)

View File

@ -48,8 +48,10 @@ class DetectStructure(object):
if opts.toc_filter is not None:
regexp = re.compile(opts.toc_filter)
for node in self.oeb.toc.iter():
for node in list(self.oeb.toc.iter()):
if not node.title or regexp.search(node.title) is not None:
self.log('Filtering', node.title if node.title else\
'empty node', 'from TOC')
self.oeb.toc.remove(node)
if opts.page_breaks_before is not None: