Only detect the template type keyword on the first line.

Remove an extra space from the default formatter exception message.
This commit is contained in:
Charles Haley 2022-10-10 21:06:09 +01:00
parent f1f8c32975
commit 294a28433c
2 changed files with 9 additions and 2 deletions

View File

@ -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)

View File

@ -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 #####################