diff --git a/src/pyj/book_list/conversion_widgets.pyj b/src/pyj/book_list/conversion_widgets.pyj index b07d5ba680..51d0752609 100644 --- a/src/pyj/book_list/conversion_widgets.pyj +++ b/src/pyj/book_list/conversion_widgets.pyj @@ -5,13 +5,16 @@ from __python__ import bound_methods, hash_literals from elementmaker import E from gettext import gettext as _ -from dom import ensure_id, add_extra_css, build_rule +from dom import add_extra_css, build_rule, ensure_id +from utils import safe_set_inner_html CLASS_NAME = 'conversion-option-group' +indent = '↳\xa0' add_extra_css(def(): style = '' sel = '.' + CLASS_NAME + ' ' + style += build_rule(sel + 'input[type="checkbox"]', margin_left='0') style += build_rule(sel + '[data-option-name]', margin_bottom='1ex', display='block', padding_bottom='0.5ex') style += build_rule(sel + '.simple-group > label', display='table-row') style += build_rule(sel + '.simple-group > label > *', display='table-cell', padding_bottom='1ex', padding_right='1rem') @@ -223,7 +226,6 @@ def look_and_feel(container): ) g = E.div(class_='simple-group') container.appendChild(g) - indent = '↳\xa0' g.appendChild(checkbox('remove_paragraph_spacing', _('Remove &spacing between paragraphs'))) g.appendChild(float_spin('remove_paragraph_spacing_indent_size', indent + _('I&ndent size:'), min=-0.1, unit='em')) g.appendChild(checkbox('insert_blank_line', _('Insert &blank line between paragraphs'))) @@ -237,6 +239,43 @@ def look_and_feel(container): container.appendChild(textarea('extra_css', 'E&xtra CSS')) # }}} +# Heuristics {{{ +@ep +def heuristics(container): + settings = v'[]' + def add(func, name, text, **kw): + g.appendChild(func(name, text, **kw)) + settings.push(name) + + add_listener('enable_heuristics', def (name): + disabled = not get('enable_heuristics') + for dname in settings: + set_disabled(dname, disabled) + ) + blurb = _( + 'Heuristic processing means that calibre will scan your book for common patterns and fix them.' + ' As the name implies, this involves guesswork, which means that it could end up worsening the result' + ' of a conversion, if calibre guesses wrong. Therefore, it is disabled by default. Often, if a conversion' + ' does not turn out as you expect, turning on heuristics can improve matters. Read more about the various' + ' heuristic processing options in the User Manual.''').replace( + '%s', 'https://manual.calibre-ebook.com/conversion.html#heuristic-processing') + container.appendChild(E.div(style='margin-bottom: 1ex')) + safe_set_inner_html(container.lastChild, blurb) + g = E.div(class_='simple-group') + container.appendChild(g) + g.appendChild(checkbox('enable_heuristics', _('Enable &heuristic processing'))) + add(checkbox, 'unwrap_lines', _('Unwrap lines')) + add(float_spin, 'html_unwrap_factor', indent + _('Line &un-wrap factor:'), max=1, step=0.05) + + add(checkbox, 'markup_chapter_headings', _('Detect and markup unformatted chapter headings and sub headings')) + add(checkbox, 'renumber_headings', _('Renumber sequences of