Math notation is now correctly applied in callable messages.

parent 61885a11
...@@ -19,6 +19,9 @@ class Possibility(object): ...@@ -19,6 +19,9 @@ class Possibility(object):
if self.handler in MESSAGES: if self.handler in MESSAGES:
msg = MESSAGES[self.handler] msg = MESSAGES[self.handler]
if callable(msg):
msg = msg(self.root, self.args)
# Surround math notation with backticks. If there are any backticks # Surround math notation with backticks. If there are any backticks
# already, do not add additional backticks. The add_backticks # already, do not add additional backticks. The add_backticks
# lambda is necessary otherwise because \1 and \2 are not matched # lambda is necessary otherwise because \1 and \2 are not matched
...@@ -26,9 +29,6 @@ class Possibility(object): ...@@ -26,9 +29,6 @@ class Possibility(object):
add_backticks = lambda x: '`%s`' % ''.join(x.groups('')) add_backticks = lambda x: '`%s`' % ''.join(x.groups(''))
msg = re.sub('`([^`]*)`|\(?({[^. ]+)', add_backticks, msg) msg = re.sub('`([^`]*)`|\(?({[^. ]+)', add_backticks, msg)
if callable(msg):
msg = msg(self.root, self.args)
return msg.format(self.root, *self.args) return msg.format(self.root, *self.args)
return repr(self) return repr(self)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment