mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix sr key. Change footer and header removal to generic search and replace options.
This commit is contained in:
parent
9d29e46a2c
commit
f85ba4e326
@ -183,7 +183,7 @@ def add_pipeline_options(parser, plumber):
|
||||
}
|
||||
|
||||
group_order = ['', 'LOOK AND FEEL', 'HEURISTICS',
|
||||
'SEARCH AND REPLACE' 'STRUCTURE DETECTION',
|
||||
'SEARCH AND REPLACE', 'STRUCTURE DETECTION',
|
||||
'TABLE OF CONTENTS', 'METADATA', 'DEBUG']
|
||||
|
||||
for group in group_order:
|
||||
|
@ -540,8 +540,7 @@ OptionRecommendation(name='sr1_search',
|
||||
|
||||
OptionRecommendation(name='sr1_replace',
|
||||
recommended_value='', level=OptionRecommendation.LOW,
|
||||
help=_('Replace characters (can be lambda expression) to '
|
||||
'replace the text found with sr1-search.')),
|
||||
help=_('Replace characters to replace the text found with sr1-search.')),
|
||||
|
||||
OptionRecommendation(name='sr2_search',
|
||||
recommended_value='', level=OptionRecommendation.LOW,
|
||||
@ -550,8 +549,7 @@ OptionRecommendation(name='sr2_search',
|
||||
|
||||
OptionRecommendation(name='sr2_replace',
|
||||
recommended_value='', level=OptionRecommendation.LOW,
|
||||
help=_('Replace characters (can be lambda expression) to '
|
||||
'replace the text found with sr2-search.')),
|
||||
help=_('Replace characters to replace the text found with sr2-search.')),
|
||||
|
||||
OptionRecommendation(name='sr3_search',
|
||||
recommended_value='', level=OptionRecommendation.LOW,
|
||||
@ -560,8 +558,7 @@ OptionRecommendation(name='sr3_search',
|
||||
|
||||
OptionRecommendation(name='sr3_replace',
|
||||
recommended_value='', level=OptionRecommendation.LOW,
|
||||
help=_('Replace characters (can be lambda expression) to '
|
||||
'replace the text found with sr3-search.')),
|
||||
help=_('Replace characters to replace the text found with sr3-search.')),
|
||||
]
|
||||
# }}}
|
||||
|
||||
|
@ -436,27 +436,29 @@ class HTMLPreProcessor(object):
|
||||
if not getattr(self.extra_opts, 'keep_ligatures', False):
|
||||
html = _ligpat.sub(lambda m:LIGATURES[m.group()], html)
|
||||
|
||||
if getattr(self.extra_opts, 'sr3_search', None):
|
||||
try:
|
||||
rules.insert(0, (re.compile(self.extra_opts.sr3_search), self.extra_opts.sr3_replace))
|
||||
except:
|
||||
import traceback
|
||||
print 'Failed to parse sr3-search regexp'
|
||||
traceback.print_exc()
|
||||
if getattr(self.extra_opts, 'sr2_search', None):
|
||||
try:
|
||||
rules.insert(0, (re.compile(self.extra_opts.sr2_search), self.extra_opts.sr2_replace))
|
||||
except:
|
||||
import traceback
|
||||
print 'Failed to parse sr2-search regexp'
|
||||
traceback.print_exc()
|
||||
if getattr(self.extra_opts, 'sr1_search', None):
|
||||
try:
|
||||
rules.insert(0, (re.compile(self.extra_opts.sr1_search), self.extra_opts.sr1_replace))
|
||||
except:
|
||||
import traceback
|
||||
print 'Failed to parse sr1-search regexp'
|
||||
traceback.print_exc()
|
||||
|
||||
end_rules = []
|
||||
if getattr(self.extra_opts, 'remove_header', None):
|
||||
try:
|
||||
rules.insert(0,
|
||||
(re.compile(self.extra_opts.header_regex), lambda match : '')
|
||||
)
|
||||
except:
|
||||
import traceback
|
||||
print 'Failed to parse remove_header regexp'
|
||||
traceback.print_exc()
|
||||
|
||||
if getattr(self.extra_opts, 'remove_footer', None):
|
||||
try:
|
||||
rules.insert(0,
|
||||
(re.compile(self.extra_opts.footer_regex), lambda match : '')
|
||||
)
|
||||
except:
|
||||
import traceback
|
||||
print 'Failed to parse remove_footer regexp'
|
||||
traceback.print_exc()
|
||||
|
||||
# delete soft hyphens - moved here so it's executed after header/footer removal
|
||||
if is_pdftohtml:
|
||||
# unwrap/delete soft hyphens
|
||||
|
Loading…
x
Reference in New Issue
Block a user