From 2ef59d81b2af7e7792eabd22db02c7a3f61f906d Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 15 Jul 2011 19:54:43 -0600 Subject: [PATCH] Conversion pipeline: Add an option to control the height of the blank lines inserted by calibre --- src/calibre/ebooks/conversion/cli.py | 4 +- src/calibre/ebooks/conversion/plumber.py | 11 +- src/calibre/ebooks/oeb/transforms/flatcss.py | 3 +- src/calibre/gui2/convert/look_and_feel.py | 5 +- src/calibre/gui2/convert/look_and_feel.ui | 169 +++++++++++-------- 5 files changed, 115 insertions(+), 77 deletions(-) diff --git a/src/calibre/ebooks/conversion/cli.py b/src/calibre/ebooks/conversion/cli.py index 1c01f49635..163f24e313 100644 --- a/src/calibre/ebooks/conversion/cli.py +++ b/src/calibre/ebooks/conversion/cli.py @@ -137,7 +137,9 @@ def add_pipeline_options(parser, plumber): 'extra_css', 'smarten_punctuation', 'margin_top', 'margin_left', 'margin_right', 'margin_bottom', 'change_justification', - 'insert_blank_line', 'remove_paragraph_spacing','remove_paragraph_spacing_indent_size', + 'insert_blank_line', 'insert_blank_line_size', + 'remove_paragraph_spacing', + 'remove_paragraph_spacing_indent_size', 'asciiize', ] ), diff --git a/src/calibre/ebooks/conversion/plumber.py b/src/calibre/ebooks/conversion/plumber.py index 31f125dd88..3a82cd56ca 100644 --- a/src/calibre/ebooks/conversion/plumber.py +++ b/src/calibre/ebooks/conversion/plumber.py @@ -366,9 +366,9 @@ OptionRecommendation(name='remove_paragraph_spacing', OptionRecommendation(name='remove_paragraph_spacing_indent_size', recommended_value=1.5, level=OptionRecommendation.LOW, - help=_('When calibre removes inter paragraph spacing, it automatically ' + help=_('When calibre removes blank lines between paragraphs, it automatically ' 'sets a paragraph indent, to ensure that paragraphs can be easily ' - 'distinguished. This option controls the width of that indent.') + 'distinguished. This option controls the width of that indent (in em).') ), OptionRecommendation(name='prefer_metadata_cover', @@ -384,6 +384,13 @@ OptionRecommendation(name='insert_blank_line', ) ), +OptionRecommendation(name='insert_blank_line_size', + recommended_value=0.5, level=OptionRecommendation.LOW, + help=_('Set the height of the inserted blank lines (in em).' + ' The height of the lines between paragraphs will be twice the value' + ' set here.') + ), + OptionRecommendation(name='remove_first_image', recommended_value=False, level=OptionRecommendation.LOW, help=_('Remove the first image from the input ebook. Useful if the ' diff --git a/src/calibre/ebooks/oeb/transforms/flatcss.py b/src/calibre/ebooks/oeb/transforms/flatcss.py index 368f5eb289..d006d8dd2d 100644 --- a/src/calibre/ebooks/oeb/transforms/flatcss.py +++ b/src/calibre/ebooks/oeb/transforms/flatcss.py @@ -318,7 +318,8 @@ class CSSFlattener(object): for edge in ('top', 'bottom'): cssdict['%s-%s'%(prop, edge)] = '0pt' if self.context.insert_blank_line: - cssdict['margin-top'] = cssdict['margin-bottom'] = '0.5em' + cssdict['margin-top'] = cssdict['margin-bottom'] = \ + '%fem'%self.context.insert_blank_line_size if self.context.remove_paragraph_spacing: cssdict['text-indent'] = "%1.1fem" % self.context.remove_paragraph_spacing_indent_size diff --git a/src/calibre/gui2/convert/look_and_feel.py b/src/calibre/gui2/convert/look_and_feel.py index 98b9cb8155..9b008c0d6d 100644 --- a/src/calibre/gui2/convert/look_and_feel.py +++ b/src/calibre/gui2/convert/look_and_feel.py @@ -24,7 +24,10 @@ class LookAndFeelWidget(Widget, Ui_Form): 'font_size_mapping', 'line_height', 'minimum_line_height', 'linearize_tables', 'smarten_punctuation', 'disable_font_rescaling', 'insert_blank_line', - 'remove_paragraph_spacing', 'remove_paragraph_spacing_indent_size','input_encoding', + 'remove_paragraph_spacing', + 'remove_paragraph_spacing_indent_size', + 'insert_blank_line_size', + 'input_encoding', 'asciiize', 'keep_ligatures'] ) for val, text in [ diff --git a/src/calibre/gui2/convert/look_and_feel.ui b/src/calibre/gui2/convert/look_and_feel.ui index 3dea1f66d7..0aa91e0f47 100644 --- a/src/calibre/gui2/convert/look_and_feel.ui +++ b/src/calibre/gui2/convert/look_and_feel.ui @@ -6,7 +6,7 @@ 0 0 - 600 + 642 500 @@ -31,7 +31,7 @@ - + pt @@ -97,6 +97,29 @@ + + + + Minimum &line height: + + + opt_minimum_line_height + + + + + + + % + + + 1 + + + 900.000000000000000 + + + @@ -107,7 +130,7 @@ - + pt @@ -127,6 +150,13 @@ + + + + true + + + @@ -134,48 +164,58 @@ - - - - - - Indent size: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - <p>When calibre removes inter paragraph spacing, it automatically sets a paragraph indent, to ensure that paragraphs can be easily distinguished. This option controls the width of that indent. - - - em - - - 1 - - - - - - - + + - Text justification: + Insert &blank line between paragraphs + + + + + + + em + + + 1 + + + Text &justification: + + + opt_change_justification + + + + + + + &Linearize tables - + + + + &Transliterate unicode characters to ASCII + + + + + + + Keep &ligatures + + + + Extra &CSS @@ -187,27 +227,16 @@ - - - - - - - &Transliterate unicode characters to ASCII + + + + <p>When calibre removes inter paragraph spacing, it automatically sets a paragraph indent, to ensure that paragraphs can be easily distinguished. This option controls the width of that indent. - - - - - - Insert &blank line + + em - - - - - - Keep &ligatures + + 1 @@ -218,33 +247,29 @@ - - + + - Minimum &line height: + &Indent size: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - opt_minimum_line_height + opt_remove_paragraph_spacing_indent_size - - - - % + + + + &Line size: - - 1 + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - 900.000000000000000 - - - - - - - true + + opt_insert_blank_line_size