diff --git a/src/calibre/gui2/tweak_book/editor/smarts/html.py b/src/calibre/gui2/tweak_book/editor/smarts/html.py index cf267b3af8..f31b9b0d6a 100644 --- a/src/calibre/gui2/tweak_book/editor/smarts/html.py +++ b/src/calibre/gui2/tweak_book/editor/smarts/html.py @@ -425,13 +425,14 @@ class Smarts(NullSmarts): template = template or DEFAULT_LINK_TEMPLATE template = template.replace('_TARGET_', prepare_string_for_xml(target, True)) offset = template.find('_TEXT_') + template = template.replace('_TEXT_', text or '') editor.highlighter.join() c = editor.textCursor() if c.hasSelection(): c.insertText('') # delete any existing selected text ensure_not_within_tag_definition(c) p = c.position() + offset - c.insertText(template.replace('_TEXT_', text or '')) + c.insertText(template) c.setPosition(p) # ensure cursor is positioned inside the newly created tag editor.setTextCursor(c) diff --git a/src/calibre/gui2/tweak_book/widgets.py b/src/calibre/gui2/tweak_book/widgets.py index e6784636d9..14de22e319 100644 --- a/src/calibre/gui2/tweak_book/widgets.py +++ b/src/calibre/gui2/tweak_book/widgets.py @@ -690,7 +690,7 @@ class InsertLink(Dialog): in the template, they will be replaced by the source filename, the destination filename and the anchor, respectively. ''').format( - '_TITLE_', '_TARGET', '_SOURCE_FILENAME_', '_DEST_FILENAME_', '_ANCHOR_')) + '_TEXT_', '_TARGET_', '_SOURCE_FILENAME_', '_DEST_FILENAME_', '_ANCHOR_')) l.addWidget(self.bb)