mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Heuristic processing: Enable individual actions by default
This commit is contained in:
parent
1ad9b6cbfd
commit
1f9007b9a9
@ -42,6 +42,12 @@ option.
|
|||||||
For full documentation of the conversion system see
|
For full documentation of the conversion system see
|
||||||
''') + 'http://calibre-ebook.com/user_manual/conversion.html'
|
''') + 'http://calibre-ebook.com/user_manual/conversion.html'
|
||||||
|
|
||||||
|
HEURISTIC_OPTIONS = ['markup_chapter_headings',
|
||||||
|
'italicize_common_cases', 'fix_indents',
|
||||||
|
'html_unwrap_factor', 'unwrap_lines',
|
||||||
|
'delete_blank_paragraphs', 'format_scene_breaks',
|
||||||
|
'dehyphenate', 'renumber_headings']
|
||||||
|
|
||||||
def print_help(parser, log):
|
def print_help(parser, log):
|
||||||
help = parser.format_help().encode(preferred_encoding, 'replace')
|
help = parser.format_help().encode(preferred_encoding, 'replace')
|
||||||
log(help)
|
log(help)
|
||||||
@ -83,6 +89,8 @@ def option_recommendation_to_cli_option(add_option, rec):
|
|||||||
if opt.long_switch == 'verbose':
|
if opt.long_switch == 'verbose':
|
||||||
attrs['action'] = 'count'
|
attrs['action'] = 'count'
|
||||||
attrs.pop('type', '')
|
attrs.pop('type', '')
|
||||||
|
if opt.name in HEURISTIC_OPTIONS and rec.recommended_value is True:
|
||||||
|
switches = ['--disable-'+opt.long_switch]
|
||||||
add_option(Option(*switches, **attrs))
|
add_option(Option(*switches, **attrs))
|
||||||
|
|
||||||
def add_input_output_options(parser, plumber):
|
def add_input_output_options(parser, plumber):
|
||||||
@ -131,14 +139,11 @@ def add_pipeline_options(parser, plumber):
|
|||||||
),
|
),
|
||||||
|
|
||||||
'HEURISTIC PROCESSING' : (
|
'HEURISTIC PROCESSING' : (
|
||||||
_('Modify the document text and structure using common patterns.'),
|
_('Modify the document text and structure using common'
|
||||||
[
|
' patterns. Disabled by default. Use %s to enable. '
|
||||||
'enable_heuristics', 'markup_chapter_headings',
|
' Individual actions can be diable with the %s options.')
|
||||||
'italicize_common_cases', 'fix_indents',
|
% ('--enable-heuristics', '--disable-*'),
|
||||||
'html_unwrap_factor', 'unwrap_lines',
|
['enable_heuristics'] + HEURISTIC_OPTIONS
|
||||||
'delete_blank_paragraphs', 'format_scene_breaks',
|
|
||||||
'dehyphenate', 'renumber_headings',
|
|
||||||
]
|
|
||||||
),
|
),
|
||||||
|
|
||||||
'SEARCH AND REPLACE' : (
|
'SEARCH AND REPLACE' : (
|
||||||
|
@ -490,19 +490,19 @@ OptionRecommendation(name='enable_heuristics',
|
|||||||
'heuristic processing to take place.')),
|
'heuristic processing to take place.')),
|
||||||
|
|
||||||
OptionRecommendation(name='markup_chapter_headings',
|
OptionRecommendation(name='markup_chapter_headings',
|
||||||
recommended_value=False, level=OptionRecommendation.LOW,
|
recommended_value=True, level=OptionRecommendation.LOW,
|
||||||
help=_('Detect unformatted chapter headings and sub headings. Change '
|
help=_('Detect unformatted chapter headings and sub headings. Change '
|
||||||
'them to h2 and h3 tags. This setting will not create a TOC, '
|
'them to h2 and h3 tags. This setting will not create a TOC, '
|
||||||
'but can be used in conjunction with structure detection to create '
|
'but can be used in conjunction with structure detection to create '
|
||||||
'one.')),
|
'one.')),
|
||||||
|
|
||||||
OptionRecommendation(name='italicize_common_cases',
|
OptionRecommendation(name='italicize_common_cases',
|
||||||
recommended_value=False, level=OptionRecommendation.LOW,
|
recommended_value=True, level=OptionRecommendation.LOW,
|
||||||
help=_('Look for common words and patterns that denote '
|
help=_('Look for common words and patterns that denote '
|
||||||
'italics and italicize them.')),
|
'italics and italicize them.')),
|
||||||
|
|
||||||
OptionRecommendation(name='fix_indents',
|
OptionRecommendation(name='fix_indents',
|
||||||
recommended_value=False, level=OptionRecommendation.LOW,
|
recommended_value=True, level=OptionRecommendation.LOW,
|
||||||
help=_('Turn indentation created from multiple non-breaking space entities '
|
help=_('Turn indentation created from multiple non-breaking space entities '
|
||||||
'into CSS indents.')),
|
'into CSS indents.')),
|
||||||
|
|
||||||
@ -515,28 +515,28 @@ OptionRecommendation(name='html_unwrap_factor',
|
|||||||
'be reduced')),
|
'be reduced')),
|
||||||
|
|
||||||
OptionRecommendation(name='unwrap_lines',
|
OptionRecommendation(name='unwrap_lines',
|
||||||
recommended_value=False, level=OptionRecommendation.LOW,
|
recommended_value=True, level=OptionRecommendation.LOW,
|
||||||
help=_('Unwrap lines using punctuation and other formatting clues.')),
|
help=_('Unwrap lines using punctuation and other formatting clues.')),
|
||||||
|
|
||||||
OptionRecommendation(name='delete_blank_paragraphs',
|
OptionRecommendation(name='delete_blank_paragraphs',
|
||||||
recommended_value=False, level=OptionRecommendation.LOW,
|
recommended_value=True, level=OptionRecommendation.LOW,
|
||||||
help=_('Remove empty paragraphs from the document when they exist between '
|
help=_('Remove empty paragraphs from the document when they exist between '
|
||||||
'every other paragraph')),
|
'every other paragraph')),
|
||||||
|
|
||||||
OptionRecommendation(name='format_scene_breaks',
|
OptionRecommendation(name='format_scene_breaks',
|
||||||
recommended_value=False, level=OptionRecommendation.LOW,
|
recommended_value=True, level=OptionRecommendation.LOW,
|
||||||
help=_('Left aligned scene break markers are center aligned. '
|
help=_('Left aligned scene break markers are center aligned. '
|
||||||
'Replace soft scene breaks that use multiple blank lines with'
|
'Replace soft scene breaks that use multiple blank lines with'
|
||||||
'horizontal rules.')),
|
'horizontal rules.')),
|
||||||
|
|
||||||
OptionRecommendation(name='dehyphenate',
|
OptionRecommendation(name='dehyphenate',
|
||||||
recommended_value=False, level=OptionRecommendation.LOW,
|
recommended_value=True, level=OptionRecommendation.LOW,
|
||||||
help=_('Analyze hyphenated words throughout the document. The '
|
help=_('Analyze hyphenated words throughout the document. The '
|
||||||
'document itself is used as a dictionary to determine whether hyphens '
|
'document itself is used as a dictionary to determine whether hyphens '
|
||||||
'should be retained or removed.')),
|
'should be retained or removed.')),
|
||||||
|
|
||||||
OptionRecommendation(name='renumber_headings',
|
OptionRecommendation(name='renumber_headings',
|
||||||
recommended_value=False, level=OptionRecommendation.LOW,
|
recommended_value=True, level=OptionRecommendation.LOW,
|
||||||
help=_('Looks for occurrences of sequential <h1> or <h2> tags. '
|
help=_('Looks for occurrences of sequential <h1> or <h2> tags. '
|
||||||
'The tags are renumbered to prevent splitting in the middle '
|
'The tags are renumbered to prevent splitting in the middle '
|
||||||
'of chapter headings.')),
|
'of chapter headings.')),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user