From 7a2e6210298c092ca20e46de995a8749f126cfe1 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 5 Jul 2018 04:42:34 +0530 Subject: [PATCH] TXT output options UI --- .../ebooks/conversion/plugins/txt_output.py | 16 ++++++--- src/pyj/book_list/conversion_widgets.pyj | 34 +++++++++++++++++++ 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/src/calibre/ebooks/conversion/plugins/txt_output.py b/src/calibre/ebooks/conversion/plugins/txt_output.py index 7702b50dba..c9cd06d596 100644 --- a/src/calibre/ebooks/conversion/plugins/txt_output.py +++ b/src/calibre/ebooks/conversion/plugins/txt_output.py @@ -21,6 +21,14 @@ class TXTOutput(OutputFormatPlugin): author = 'John Schember' file_type = 'txt' commit_name = 'txt_output' + ui_data = { + 'newline_types': NEWLINE_TYPES, + 'formatting_types': { + 'plain': _('Plain text'), + 'markdown': _('Markdown formatted text'), + 'textile': _('TexTile formatted text') + }, + } options = set([ OptionRecommendation(name='newline', recommended_value='system', @@ -50,11 +58,11 @@ class TXTOutput(OutputFormatPlugin): 'is present. Also allows max-line-length to be below the minimum')), OptionRecommendation(name='txt_output_formatting', recommended_value='plain', - choices=['plain', 'markdown', 'textile'], + choices=list(ui_data['formatting_types']), help=_('Formatting used within the document.\n' - '* plain: Produce plain text.\n' - '* markdown: Produce Markdown formatted text.\n' - '* textile: Produce Textile formatted text.')), + '* plain: {plain}\n' + '* markdown: {markdown}\n' + '* textile: {textile}').format(**ui_data['formatting_types'])), OptionRecommendation(name='keep_links', recommended_value=False, level=OptionRecommendation.LOW, help=_('Do not remove links within the document. This is only ' diff --git a/src/pyj/book_list/conversion_widgets.pyj b/src/pyj/book_list/conversion_widgets.pyj index 9b7876e074..a835bc4dbf 100644 --- a/src/pyj/book_list/conversion_widgets.pyj +++ b/src/pyj/book_list/conversion_widgets.pyj @@ -677,6 +677,40 @@ def pml_output(container): g.appendChild(checkbox('full_image_depth', _('Do not &reduce image size and depth'))) # }}} +# RB Output {{{ +@ep +def rb_output(container): + g = E.div(class_='simple-group') + container.appendChild(g) + g.appendChild(checkbox('inline_toc', _('&Inline TOC'))) +# }}} + +# TXT Output {{{ +@ep +def txt_output(container): + g = E.div(class_='simple-group') + container.appendChild(g) + g.appendChild(lineedit('txt_output_encoding', _('O&utput encoding:'))) + g.appendChild(choices('newline', _('&Line ending style:'), ui_data.newline_types)) + g.appendChild(choices('txt_output_formatting', _('Forma&tting:'), ui_data.formatting_types)) + g = E.div(E.div(_('Options for plain text output:')), E.div(class_='simple-group', style='margin-left: 1rem; margin-top: 1ex')) + container.appendChild(g) + g = g.lastChild + g.appendChild(checkbox('inline_toc', _('&Inline TOC'))) + g.appendChild(int_spin('max_line_length', _('&Maximum line length:'), max=1000)) + g.appendChild(checkbox('force_max_line_length', _('Force maximum line &length'))) + g = E.div(E.div(_('Options for Markdown and TexTile output:')), E.div(class_='simple-group', style='margin-left: 1rem; margin-top: 1ex')) + container.appendChild(g) + g = g.lastChild + g.appendChild(checkbox('keep_links', _('Do not remove links ( tags) before processing'))) + g.appendChild(checkbox('keep_image_references', _('Do not remove image &references before processing'))) + g.appendChild(checkbox('keep_color', _('Keep text &color, when possible'))) + +@ep +def txtz_output(container): + return txt_output(container) +# }}} + def restore_defaults(): for setting in registry: set(setting, get_option_default_value(setting))