Sync to trunk.

This commit is contained in:
John Schember 2009-11-22 11:31:06 -05:00
commit d396739429
8 changed files with 193 additions and 107 deletions

View File

@ -125,7 +125,7 @@ def add_pipeline_options(parser, plumber):
'extra_css', 'extra_css',
'margin_top', 'margin_left', 'margin_right', 'margin_top', 'margin_left', 'margin_right',
'margin_bottom', 'dont_justify', 'margin_bottom', 'dont_justify',
'insert_blank_line', 'remove_paragraph_spacing', 'insert_blank_line', 'remove_paragraph_spacing','remove_paragraph_spacing_indent_size',
'asciiize', 'remove_header', 'header_regex', 'asciiize', 'remove_header', 'header_regex',
'remove_footer', 'footer_regex', 'remove_footer', 'footer_regex',
] ]

View File

@ -310,6 +310,13 @@ OptionRecommendation(name='remove_paragraph_spacing',
'if the source file does not use paragraphs (<p> or <div> tags).') 'if the source file does not use paragraphs (<p> or <div> tags).')
), ),
OptionRecommendation(name='remove_paragraph_spacing_indent_size',
recommended_value=1.5, level=OptionRecommendation.LOW,
help=_('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.')
),
OptionRecommendation(name='prefer_metadata_cover', OptionRecommendation(name='prefer_metadata_cover',
recommended_value=False, level=OptionRecommendation.LOW, recommended_value=False, level=OptionRecommendation.LOW,
help=_('Use the cover detected from the source file in preference ' help=_('Use the cover detected from the source file in preference '

View File

@ -278,7 +278,7 @@ class CSSFlattener(object):
if self.context.insert_blank_line: if self.context.insert_blank_line:
cssdict['margin-top'] = cssdict['margin-bottom'] = '0.5em' cssdict['margin-top'] = cssdict['margin-bottom'] = '0.5em'
if self.context.remove_paragraph_spacing: if self.context.remove_paragraph_spacing:
cssdict['text-indent'] = '1.5em' cssdict['text-indent'] = "%1.1fem" % self.context.remove_paragraph_spacing_indent_size
if cssdict: if cssdict:
items = cssdict.items() items = cssdict.items()
items.sort() items.sort()

View File

@ -256,7 +256,7 @@ class PML_HTMLizer(object):
if code in self.SPAN_STATES: if code in self.SPAN_STATES:
del spans[spans.index(code)] del spans[spans.index(code)]
for c in divs+spans: for c in divs+spans:
if state[c][0]: if self.state[c][0]:
if c in self.STATES_VALUE_REQ: if c in self.STATES_VALUE_REQ:
text += self.STATES_TAGS[self.CODE_STATES[c]][0] % self.state[c][1] text += self.STATES_TAGS[self.CODE_STATES[c]][0] % self.state[c][1]
else: else:
@ -265,7 +265,7 @@ class PML_HTMLizer(object):
if code in self.STATES_VALUE_REQ: if code in self.STATES_VALUE_REQ:
val = self.code_value(stream) val = self.code_value(stream)
text = self.STATES_TAGS[code][0] % val text = self.STATES_TAGS[code][0] % val
state[code][1] = val self.state[code][1] = val
else: else:
text = self.STATES_TAGS[code][0] text = self.STATES_TAGS[code][0]

View File

@ -23,7 +23,7 @@ class LookAndFeelWidget(Widget, Ui_Form):
'font_size_mapping', 'line_height', 'font_size_mapping', 'line_height',
'linearize_tables', 'linearize_tables',
'disable_font_rescaling', 'insert_blank_line', 'disable_font_rescaling', 'insert_blank_line',
'remove_paragraph_spacing', 'input_encoding', 'remove_paragraph_spacing', 'remove_paragraph_spacing_indent_size','input_encoding',
'asciiize'] 'asciiize']
) )
self.db, self.book_id = db, book_id self.db, self.book_id = db, book_id
@ -32,6 +32,8 @@ class LookAndFeelWidget(Widget, Ui_Form):
self.opt_disable_font_rescaling.toggle() self.opt_disable_font_rescaling.toggle()
self.connect(self.button_font_key, SIGNAL('clicked()'), self.connect(self.button_font_key, SIGNAL('clicked()'),
self.font_key_wizard) self.font_key_wizard)
self.opt_remove_paragraph_spacing.toggle()
self.opt_remove_paragraph_spacing.toggle()
def font_key_wizard(self): def font_key_wizard(self):
from calibre.gui2.convert.font_key import FontKeyChooser from calibre.gui2.convert.font_key import FontKeyChooser

View File

@ -14,7 +14,7 @@
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2"> <item row="0" column="0">
<widget class="QCheckBox" name="opt_disable_font_rescaling"> <widget class="QCheckBox" name="opt_disable_font_rescaling">
<property name="text"> <property name="text">
<string>&amp;Disable font size rescaling</string> <string>&amp;Disable font size rescaling</string>
@ -31,7 +31,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="3"> <item row="1" column="2">
<widget class="QDoubleSpinBox" name="opt_base_font_size"> <widget class="QDoubleSpinBox" name="opt_base_font_size">
<property name="suffix"> <property name="suffix">
<string> pt</string> <string> pt</string>
@ -63,7 +63,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="2" colspan="2"> <item row="2" column="1" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="QLineEdit" name="opt_font_size_mapping"> <widget class="QLineEdit" name="opt_font_size_mapping">
@ -107,7 +107,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="3"> <item row="3" column="2">
<widget class="QDoubleSpinBox" name="opt_line_height"> <widget class="QDoubleSpinBox" name="opt_line_height">
<property name="suffix"> <property name="suffix">
<string> pt</string> <string> pt</string>
@ -127,13 +127,60 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="1" colspan="2">
<widget class="QLineEdit" name="opt_input_encoding"/>
</item>
<item row="5" column="0" colspan="3"> <item row="5" column="0" colspan="3">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QCheckBox" name="opt_remove_paragraph_spacing"> <widget class="QCheckBox" name="opt_remove_paragraph_spacing">
<property name="text"> <property name="text">
<string>Remove &amp;spacing between paragraphs</string> <string>Remove &amp;spacing between paragraphs</string>
</property> </property>
</widget> </widget>
</item> </item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Indent size:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="opt_remove_paragraph_spacing_indent_size">
<property name="toolTip">
<string>&lt;p&gt;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.</string>
</property>
<property name="suffix">
<string> em</string>
</property>
<property name="decimals">
<number>1</number>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item row="6" column="0"> <item row="6" column="0">
<widget class="QCheckBox" name="opt_insert_blank_line"> <widget class="QCheckBox" name="opt_insert_blank_line">
<property name="text"> <property name="text">
@ -155,14 +202,14 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="9" column="0" colspan="3"> <item row="9" column="0">
<widget class="QCheckBox" name="opt_asciiize"> <widget class="QCheckBox" name="opt_asciiize">
<property name="text"> <property name="text">
<string>&amp;Transliterate unicode characters to ASCII.</string> <string>&amp;Transliterate unicode characters to ASCII.</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="10" column="0" colspan="4"> <item row="10" column="0" colspan="3">
<widget class="QGroupBox" name="groupBox"> <widget class="QGroupBox" name="groupBox">
<property name="title"> <property name="title">
<string>Extra &amp;CSS</string> <string>Extra &amp;CSS</string>
@ -174,9 +221,6 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="4" column="2" colspan="2">
<widget class="QLineEdit" name="opt_input_encoding"/>
</item>
</layout> </layout>
</widget> </widget>
<resources> <resources>
@ -216,5 +260,37 @@
</hint> </hint>
</hints> </hints>
</connection> </connection>
<connection>
<sender>opt_remove_paragraph_spacing</sender>
<signal>toggled(bool)</signal>
<receiver>label_4</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
<connection>
<sender>opt_remove_paragraph_spacing</sender>
<signal>toggled(bool)</signal>
<receiver>opt_remove_paragraph_spacing_indent_size</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
</connections> </connections>
</ui> </ui>

View File

@ -163,7 +163,8 @@ Paragraph spacing
Normally, paragraphs in XHTML are rendered with a blank line between them and no leading text Normally, paragraphs in XHTML are rendered with a blank line between them and no leading text
indent. |app| has a couple of options to control this. :guilabel:`Remove spacing between paragraphs` indent. |app| has a couple of options to control this. :guilabel:`Remove spacing between paragraphs`
forcefully ensure that all paragraphs have no inter paragraph spacing. It also sets the text forcefully ensure that all paragraphs have no inter paragraph spacing. It also sets the text
indent to 1.5em to mark that start of every paragraph. :guilabel:`Insert blank line` does the indent to 1.5em (can be changed) to mark the start of every paragraph.
:guilabel:`Insert blank line` does the
opposite, guaranteeing that there is exactly one blank line between each pair of paragraphs. opposite, guaranteeing that there is exactly one blank line between each pair of paragraphs.
Both these options are very comprehensive, removing spacing, or inserting it for *all* paragraphs Both these options are very comprehensive, removing spacing, or inserting it for *all* paragraphs
(technically <p> and <div> tags). This is so that you can just set the option and be sure that (technically <p> and <div> tags). This is so that you can just set the option and be sure that