diff --git a/src/calibre/utils/formatter.py b/src/calibre/utils/formatter.py index eff38203a0..2fa5901dde 100644 --- a/src/calibre/utils/formatter.py +++ b/src/calibre/utils/formatter.py @@ -137,6 +137,7 @@ class _Parser(object): # We have a function. # Check if it is a known one. We do this here so error reporting is # better, as it can identify the tokens near the problem. + id = id.strip() if id not in funcs: self.error(_('unknown function {0}').format(id)) @@ -246,6 +247,7 @@ class _CompileParser(_Parser): # We have a function. # Check if it is a known one. We do this here so error reporting is # better, as it can identify the tokens near the problem. + id = id.strip() if id not in funcs: self.error(_('unknown function {0}').format(id)) @@ -457,7 +459,7 @@ class TemplateFormatter(string.Formatter): colon += 1 funcs = formatter_functions().get_functions() - fname = fmt[colon:p] + fname = fmt[colon:p].strip() if fname in funcs: func = funcs[fname] if func.arg_count == 2: