mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Implement insertion of <hr>
This commit is contained in:
parent
77e2524174
commit
04d58d6877
@ -28,6 +28,8 @@ from calibre.utils.imghdr import what
|
|||||||
from polyglot.builtins import filter, iteritems, itervalues, unicode_type
|
from polyglot.builtins import filter, iteritems, itervalues, unicode_type
|
||||||
|
|
||||||
|
|
||||||
|
# Cleanup Qt markup {{{
|
||||||
|
|
||||||
def parse_style(style):
|
def parse_style(style):
|
||||||
props = filter(None, (x.strip() for x in style.split(';')))
|
props = filter(None, (x.strip() for x in style.split(';')))
|
||||||
ans = {}
|
ans = {}
|
||||||
@ -129,7 +131,7 @@ def cleanup_qt_markup(root):
|
|||||||
tag_style = style_map[tag]
|
tag_style = style_map[tag]
|
||||||
remove_margins(tag, tag_style)
|
remove_margins(tag, tag_style)
|
||||||
remove_zero_indents(tag_style)
|
remove_zero_indents(tag_style)
|
||||||
if tag.tag.startswith('h'):
|
if tag.tag.startswith('h') and tag.tag[1:] in '123456':
|
||||||
remove_heading_font_styles(tag, tag_style)
|
remove_heading_font_styles(tag, tag_style)
|
||||||
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])
|
||||||
@ -142,6 +144,7 @@ def cleanup_qt_markup(root):
|
|||||||
tag.attrib.pop('style', None)
|
tag.attrib.pop('style', None)
|
||||||
for span in root.xpath('//span[not(@style)]'):
|
for span in root.xpath('//span[not(@style)]'):
|
||||||
lift(span)
|
lift(span)
|
||||||
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
class EditorWidget(QTextEdit, LineEditECM): # {{{
|
class EditorWidget(QTextEdit, LineEditECM): # {{{
|
||||||
@ -456,7 +459,13 @@ class EditorWidget(QTextEdit, LineEditECM): # {{{
|
|||||||
self.setTextCursor(c)
|
self.setTextCursor(c)
|
||||||
|
|
||||||
def do_insert_hr(self, *args):
|
def do_insert_hr(self, *args):
|
||||||
raise NotImplementedError('TODO')
|
c = self.textCursor()
|
||||||
|
c.beginEditBlock()
|
||||||
|
c.movePosition(c.EndOfBlock, c.MoveAnchor)
|
||||||
|
c.insertHtml('<hr>')
|
||||||
|
c.endEditBlock()
|
||||||
|
self.setTextCursor(c)
|
||||||
|
self.focus_self()
|
||||||
|
|
||||||
def do_insert_link(self, *args):
|
def do_insert_link(self, *args):
|
||||||
link, name, is_image = self.ask_link()
|
link, name, is_image = self.ask_link()
|
||||||
@ -652,6 +661,7 @@ class EditorWidget(QTextEdit, LineEditECM): # {{{
|
|||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
# Highlighter {{{
|
# Highlighter {{{
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user