mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Comments editor: Use <p> </p> for empty paragraphs instead
This commit is contained in:
parent
3236f5da9e
commit
9f7f74c952
@ -78,7 +78,7 @@ def lift_styles(tag, style_map):
|
|||||||
def filter_qt_styles(style):
|
def filter_qt_styles(style):
|
||||||
for k in tuple(style):
|
for k in tuple(style):
|
||||||
# -qt-paragraph-type is a hack used by Qt for empty paragraphs
|
# -qt-paragraph-type is a hack used by Qt for empty paragraphs
|
||||||
if k.startswith('-qt-') and k != '-qt-paragraph-type':
|
if k.startswith('-qt-'):
|
||||||
del style[k]
|
del style[k]
|
||||||
|
|
||||||
|
|
||||||
@ -192,6 +192,9 @@ def cleanup_qt_markup(root):
|
|||||||
use_implicit_styling_for_a(child, style_map)
|
use_implicit_styling_for_a(child, style_map)
|
||||||
for child in tag.iterdescendants('span'):
|
for child in tag.iterdescendants('span'):
|
||||||
use_implicit_styling_for_span(child, style_map[child])
|
use_implicit_styling_for_span(child, style_map[child])
|
||||||
|
if tag.tag == 'p' and style_map[tag].get('-qt-paragraph-type') == 'empty':
|
||||||
|
del tag[:]
|
||||||
|
tag.text = '\xa0'
|
||||||
for style in itervalues(style_map):
|
for style in itervalues(style_map):
|
||||||
filter_qt_styles(style)
|
filter_qt_styles(style)
|
||||||
for tag, style in iteritems(style_map):
|
for tag, style in iteritems(style_map):
|
||||||
@ -1135,7 +1138,8 @@ class Editor(QWidget): # {{{
|
|||||||
self.wyswyg_dirty = False
|
self.wyswyg_dirty = False
|
||||||
elif index == 0: # changing to wyswyg
|
elif index == 0: # changing to wyswyg
|
||||||
if self.source_dirty:
|
if self.source_dirty:
|
||||||
self.editor.html = unicode_type(self.code_edit.toPlainText())
|
from calibre.gui2.tweak_book.widgets import PlainTextEdit
|
||||||
|
self.editor.html = PlainTextEdit.toPlainText(self.code_edit)
|
||||||
self.source_dirty = False
|
self.source_dirty = False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -1194,6 +1198,6 @@ if __name__ == '__main__':
|
|||||||
w.html = '''<h1>Test Heading</h1><blockquote>Test blockquote</blockquote><p><span style="background-color: rgb(0, 255, 255); ">He hadn't
|
w.html = '''<h1>Test Heading</h1><blockquote>Test blockquote</blockquote><p><span style="background-color: rgb(0, 255, 255); ">He hadn't
|
||||||
set <u>out</u> to have an <em>affair</em>, <span style="font-style:italic; background-color:red">
|
set <u>out</u> to have an <em>affair</em>, <span style="font-style:italic; background-color:red">
|
||||||
much</span> less a <s>long-term</s>, <b>devoted</b> one.</span><p>hello'''
|
much</span> less a <s>long-term</s>, <b>devoted</b> one.</span><p>hello'''
|
||||||
w.html = '<div><p id="moo">Testing <em>a</em> link.</p></div>'
|
w.html = '<div><p id="moo">Testing <em>a</em> link.</p><p>\xa0</p><p>ss</p></div>'
|
||||||
app.exec_()
|
app.exec_()
|
||||||
# print w.html
|
# print w.html
|
||||||
|
Loading…
x
Reference in New Issue
Block a user