From 3eb6365c9618007e9fb89fd5570e28fbdcb8a6e8 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 11 Nov 2020 17:33:13 +0530 Subject: [PATCH] Fix incorrect variable names in tooltip Fixes #1903837 [Inserting hyperlink in editor: template variables do not work](https://bugs.launchpad.net/calibre/+bug/1903837) --- src/calibre/gui2/tweak_book/editor/smarts/html.py | 3 ++- src/calibre/gui2/tweak_book/widgets.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) 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)