From 6deb890595187a592a9348b5f10a3b563bf45763 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 29 Jan 2008 21:56:12 +0000 Subject: [PATCH] Implement --minimum-indent option --- src/libprs500/ebooks/lrf/__init__.py | 2 + src/libprs500/ebooks/lrf/html/convert_from.py | 4 +- src/libprs500/ebooks/lrf/lit/convert_from.py | 3 +- src/libprs500/gui2/dialogs/lrf_single.ui | 47 ++++++++++++++----- 4 files changed, 41 insertions(+), 15 deletions(-) diff --git a/src/libprs500/ebooks/lrf/__init__.py b/src/libprs500/ebooks/lrf/__init__.py index 8c5078c921..77fbd0ed33 100644 --- a/src/libprs500/ebooks/lrf/__init__.py +++ b/src/libprs500/ebooks/lrf/__init__.py @@ -123,6 +123,8 @@ def option_parser(usage, gui_mode=False): help=_('Override the CSS. Can be either a path to a CSS stylesheet or a string. If it is a string it is interpreted as CSS.')) laf.add_option('--use-spine', default=False, dest='use_spine', action='store_true', help=_('Use the element from the OPF file to determine the order in which the HTML files are appended to the LRF. The .opf file must be in the same directory as the base HTML file.')) + laf.add_option('--minimum-indent', default=0, type='float', + help='Minimum paragraph indent (the indent of the first line of a paragraph) in pts. Default: %default') laf.add_option('--font-delta', action='store', type='float', default=0., \ help=_("""Increase the font size by 2 * FONT_DELTA pts and """ '''the line spacing by FONT_DELTA pts. FONT_DELTA can be a fraction.''' diff --git a/src/libprs500/ebooks/lrf/html/convert_from.py b/src/libprs500/ebooks/lrf/html/convert_from.py index f746ad5ba4..3465d32c79 100644 --- a/src/libprs500/ebooks/lrf/html/convert_from.py +++ b/src/libprs500/ebooks/lrf/html/convert_from.py @@ -1200,8 +1200,8 @@ class HTMLConverter(object): indent = self.unit_convert(str(tag_css['text-indent']), pts=True) if not indent: indent = 0 - if hasattr(self, 'minimum_indent') and indent > 0 and indent < self.minimum_indent: - indent = self.minimum_indent + if indent > 0 and indent < 10 * self.minimum_indent: + indent = int(10 * self.minimum_indent) fp = self.font_properties(tag_css)[0] fp['parindent'] = indent diff --git a/src/libprs500/ebooks/lrf/lit/convert_from.py b/src/libprs500/ebooks/lrf/lit/convert_from.py index fe29cd2740..f40c99af28 100644 --- a/src/libprs500/ebooks/lrf/lit/convert_from.py +++ b/src/libprs500/ebooks/lrf/lit/convert_from.py @@ -90,7 +90,8 @@ def process_file(path, options, logger=None): ext = '.lrs' if options.lrs else '.lrf' options.output = os.path.abspath(os.path.basename(os.path.splitext(path)[0]) + ext) options.output = os.path.abspath(os.path.expanduser(options.output)) - options.minimum_indent = 100 + if options.minimum_indent == 0: + options.minimum_indent = 10 options.use_spine = True html_process_file(htmlfile, options, logger=logger) diff --git a/src/libprs500/gui2/dialogs/lrf_single.ui b/src/libprs500/gui2/dialogs/lrf_single.ui index 3755435efe..b20cf9bed8 100644 --- a/src/libprs500/gui2/dialogs/lrf_single.ui +++ b/src/libprs500/gui2/dialogs/lrf_single.ui @@ -562,7 +562,7 @@ - + &Word spacing: @@ -575,7 +575,7 @@ - + QAbstractSpinBox::PlusMinus @@ -600,28 +600,28 @@ - + Enable auto &rotation of images - + Insert &blank lines between paragraphs - + Ignore &tables - + &Preprocess: @@ -631,10 +631,10 @@ - + - + @@ -669,16 +669,39 @@ - + Override<br>CSS - + + + + + Minimum &indent: + + + gui_minimum_indent + + + + + + + QAbstractSpinBox::PlusMinus + + + pts + + + 1 + + + @@ -926,8 +949,8 @@ <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'DejaVu Sans'; font-size:9pt; font-weight:400; font-style:normal;"> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif';"></p></body></html> +</style></head><body style=" font-family:'DejaVu Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:9pt;"></p></body></html>