mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Edit book: Insert tag button: Allow entering attributes along with the tag name to make it easy to repeatedly insert, for example, <span class="special"></span>.
This commit is contained in:
parent
f6e613df6a
commit
d23345f696
@ -272,11 +272,14 @@ class HTMLSmarts(NullSmarts):
|
||||
editor.setTextCursor(c)
|
||||
|
||||
def insert_tag(self, editor, name):
|
||||
name = name.lstrip()
|
||||
text = self.get_smart_selection(editor, update=True)
|
||||
c = editor.textCursor()
|
||||
pos = min(c.position(), c.anchor())
|
||||
c.insertText('<{0}>{1}</{0}>'.format(name, text))
|
||||
c.setPosition(pos + 1 + len(name))
|
||||
m = re.match(r'[a-zA-Z0-9:-]+', name)
|
||||
cname = name if m is None else m.group()
|
||||
c.insertText('<{0}>{1}</{2}>'.format(name, text, cname))
|
||||
c.setPosition(pos + 2 + len(name))
|
||||
editor.setTextCursor(c)
|
||||
|
||||
def verify_for_spellcheck(self, cursor, highlighter):
|
||||
|
Loading…
x
Reference in New Issue
Block a user