Fix incorrect variable names in tooltip

Fixes #1903837 [Inserting hyperlink in editor: template variables do not work](https://bugs.launchpad.net/calibre/+bug/1903837)
This commit is contained in:
Kovid Goyal 2020-11-11 17:33:13 +05:30
parent 3b5016c010
commit 3eb6365c96
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 3 additions and 2 deletions

View File

@ -425,13 +425,14 @@ class Smarts(NullSmarts):
template = template or DEFAULT_LINK_TEMPLATE template = template or DEFAULT_LINK_TEMPLATE
template = template.replace('_TARGET_', prepare_string_for_xml(target, True)) template = template.replace('_TARGET_', prepare_string_for_xml(target, True))
offset = template.find('_TEXT_') offset = template.find('_TEXT_')
template = template.replace('_TEXT_', text or '')
editor.highlighter.join() editor.highlighter.join()
c = editor.textCursor() c = editor.textCursor()
if c.hasSelection(): if c.hasSelection():
c.insertText('') # delete any existing selected text c.insertText('') # delete any existing selected text
ensure_not_within_tag_definition(c) ensure_not_within_tag_definition(c)
p = c.position() + offset 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 c.setPosition(p) # ensure cursor is positioned inside the newly created tag
editor.setTextCursor(c) editor.setTextCursor(c)

View File

@ -690,7 +690,7 @@ class InsertLink(Dialog):
in the template, they will be replaced by the source filename, the destination in the template, they will be replaced by the source filename, the destination
filename and the anchor, respectively. filename and the anchor, respectively.
''').format( ''').format(
'_TITLE_', '_TARGET', '_SOURCE_FILENAME_', '_DEST_FILENAME_', '_ANCHOR_')) '_TEXT_', '_TARGET_', '_SOURCE_FILENAME_', '_DEST_FILENAME_', '_ANCHOR_'))
l.addWidget(self.bb) l.addWidget(self.bb)