TXT output options UI

This commit is contained in:
Kovid Goyal 2018-07-05 04:42:34 +05:30
parent 9bad72f2cc
commit 7a2e621029
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 46 additions and 4 deletions

View File

@ -21,6 +21,14 @@ class TXTOutput(OutputFormatPlugin):
author = 'John Schember' author = 'John Schember'
file_type = 'txt' file_type = 'txt'
commit_name = 'txt_output' 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([ options = set([
OptionRecommendation(name='newline', recommended_value='system', 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')), 'is present. Also allows max-line-length to be below the minimum')),
OptionRecommendation(name='txt_output_formatting', OptionRecommendation(name='txt_output_formatting',
recommended_value='plain', recommended_value='plain',
choices=['plain', 'markdown', 'textile'], choices=list(ui_data['formatting_types']),
help=_('Formatting used within the document.\n' help=_('Formatting used within the document.\n'
'* plain: Produce plain text.\n' '* plain: {plain}\n'
'* markdown: Produce Markdown formatted text.\n' '* markdown: {markdown}\n'
'* textile: Produce Textile formatted text.')), '* textile: {textile}').format(**ui_data['formatting_types'])),
OptionRecommendation(name='keep_links', OptionRecommendation(name='keep_links',
recommended_value=False, level=OptionRecommendation.LOW, recommended_value=False, level=OptionRecommendation.LOW,
help=_('Do not remove links within the document. This is only ' help=_('Do not remove links within the document. This is only '

View File

@ -677,6 +677,40 @@ def pml_output(container):
g.appendChild(checkbox('full_image_depth', _('Do not &reduce image size and depth'))) 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 (<a> 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(): def restore_defaults():
for setting in registry: for setting in registry:
set(setting, get_option_default_value(setting)) set(setting, get_option_default_value(setting))