diff --git a/src/calibre/gui2/dialogs/template_dialog.py b/src/calibre/gui2/dialogs/template_dialog.py index c6854f7e2c..3356dc97f8 100644 --- a/src/calibre/gui2/dialogs/template_dialog.py +++ b/src/calibre/gui2/dialogs/template_dialog.py @@ -216,7 +216,14 @@ class TemplateHighlighter(QSyntaxHighlighter): pp = self.find_paren(bn, i) if pp and pp.highlight: self.setFormat(i, length, self.Formats[format_]) + elif format_ == 'keyword': + if bn > 0 and i == 0: + if text[i:i+length] == ('python:' if self.for_python else 'program:'): + continue + print('bn', bn, format_, text[i:i+length]) + self.setFormat(i, length, self.Formats[format_]) else: + print('bn', bn, format_, text[i:i+length]) self.setFormat(i, length, self.Formats[format_]) self.setCurrentBlockState(NORMAL) @@ -796,7 +803,7 @@ class TemplateDialog(QDialog, Ui_TemplateDialog): w = tv.cellWidget(r, 0) w.setText(mi.title) w.setCursorPosition(0) - v = SafeFormat().safe_format(txt, mi, _('EXCEPTION: '), + v = SafeFormat().safe_format(txt, mi, _('EXCEPTION:'), mi, global_vars=self.global_vars, template_functions=self.all_functions, break_reporter=self.break_reporter if r == break_on_mi else None) diff --git a/src/calibre/utils/formatter.py b/src/calibre/utils/formatter.py index c052df3a9f..44f9da012e 100644 --- a/src/calibre/utils/formatter.py +++ b/src/calibre/utils/formatter.py @@ -1591,7 +1591,7 @@ class TemplateFormatter(string.Formatter): raise(ValueError( _('Syntax error on line {0} column {1}: text {2}').format(e.lineno, e.offset, e.text))) except KeyError: - raise(ValueError(_("Error: the {0} function is not defined in the template").format('evaluate'))) + raise(ValueError(_("The {0} function is not defined in the template").format('evaluate'))) # ################# Override parent classes methods #####################