Add an option to not condense CSS

Conversion: Add an option to not condense CSS rules for margin, padding,
border, etc. Option is under the Look & Feel section of the conversion
dialog. Fixes #1233220 [Feature request: allow margin-top, margin-left, etc. when converting, instead of shortcut margin property](https://bugs.launchpad.net/calibre/+bug/1233220)
This commit is contained in:
Kovid Goyal 2013-10-04 10:29:36 +05:30
parent 038a9d99dc
commit f4f66cf42d
6 changed files with 33 additions and 18 deletions

View File

@ -141,7 +141,7 @@ def add_pipeline_options(parser, plumber):
'subset_embedded_fonts', 'embed_all_fonts',
'line_height', 'minimum_line_height',
'linearize_tables',
'extra_css', 'filter_css',
'extra_css', 'filter_css', 'expand_css',
'smarten_punctuation', 'unsmarten_punctuation',
'margin_top', 'margin_left', 'margin_right',
'margin_bottom', 'change_justification',

View File

@ -54,7 +54,7 @@ class OEBOutput(OutputFormatPlugin):
f.write(raw)
for item in oeb_book.manifest:
if item.media_type in OEB_STYLES and hasattr(item.data, 'cssText'):
if not self.opts.expand_css and item.media_type in OEB_STYLES and hasattr(item.data, 'cssText'):
condense_sheet(item.data)
path = os.path.abspath(unquote(item.href))
dir = os.path.dirname(path)

View File

@ -363,6 +363,14 @@ OptionRecommendation(name='filter_css',
'font-family,color,margin-left,margin-right')
),
OptionRecommendation(name='expand_css',
recommended_value=False, level=OptionRecommendation.LOW,
help=_(
'By default, calibre will use the shorthand form for various'
' css properties such as margin, padding, border, etc. This'
' option will cause it to use the full expanded form instead.')
),
OptionRecommendation(name='page_breaks_before',
recommended_value="//*[name()='h1' or name()='h2']",
level=OptionRecommendation.LOW,

View File

@ -151,7 +151,7 @@ class KF8Writer(object):
for item in self.oeb.manifest:
if item.media_type in OEB_STYLES:
if hasattr(item.data, 'cssText'):
if not self.opts.expand_css and hasattr(item.data, 'cssText'):
condense_sheet(self.data(item))
data = self.data(item).cssText
sheets[item.href] = len(self.flows)

View File

@ -38,7 +38,7 @@ class LookAndFeelWidget(Widget, Ui_Form):
'remove_paragraph_spacing',
'remove_paragraph_spacing_indent_size',
'insert_blank_line_size',
'input_encoding', 'filter_css',
'input_encoding', 'filter_css', 'expand_css',
'asciiize', 'keep_ligatures',
'linearize_tables']
)

View File

@ -21,13 +21,6 @@
</property>
</widget>
</item>
<item row="12" column="3">
<widget class="QCheckBox" name="opt_linearize_tables">
<property name="text">
<string>&amp;Linearize tables</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_18">
<property name="text">
@ -125,13 +118,6 @@
</property>
</widget>
</item>
<item row="11" column="1" colspan="4">
<widget class="QCheckBox" name="opt_asciiize">
<property name="text">
<string>&amp;Transliterate unicode characters to ASCII</string>
</property>
</widget>
</item>
<item row="12" column="0">
<widget class="QCheckBox" name="opt_unsmarten_punctuation">
<property name="text">
@ -422,6 +408,27 @@
</property>
</widget>
</item>
<item row="11" column="1" colspan="2">
<widget class="QCheckBox" name="opt_asciiize">
<property name="text">
<string>&amp;Transliterate unicode characters to ASCII</string>
</property>
</widget>
</item>
<item row="11" column="3" colspan="2">
<widget class="QCheckBox" name="opt_expand_css">
<property name="text">
<string>E&amp;xpand CSS</string>
</property>
</widget>
</item>
<item row="12" column="3" colspan="2">
<widget class="QCheckBox" name="opt_linearize_tables">
<property name="text">
<string>&amp;Linearize tables</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>