Math expressions in hints are pretty printed using MathJax.

parent 65c425db
...@@ -77,6 +77,10 @@ body { ...@@ -77,6 +77,10 @@ body {
line-height: 20px; line-height: 20px;
} }
#math .hint .MathJax {
color: #000;
}
#control-buttons { #control-buttons {
height: 21px; height: 21px;
left: 2%; left: 2%;
......
...@@ -134,6 +134,7 @@ ...@@ -134,6 +134,7 @@
var elem = $('<div class=hint/>'); var elem = $('<div class=hint/>');
elem.text(hint); elem.text(hint);
$('#math').append(elem); $('#math').append(elem);
QUEUE.Push(['Typeset', MathJax.Hub, elem[0]]);
}; };
window.append_input = function(input) { window.append_input = function(input) {
......
...@@ -262,7 +262,7 @@ class Parser(BisonParser): ...@@ -262,7 +262,7 @@ class Parser(BisonParser):
hint = self.give_hint() hint = self.give_hint()
if hint: if hint:
print hint print str(hint).replace('`', '')
else: else:
print 'No further reduction is possible.' print 'No further reduction is possible.'
......
from node import TYPE_OPERATOR from node import TYPE_OPERATOR
import re
# Each rule will append its hint message to the following dictionary. The # Each rule will append its hint message to the following dictionary. The
...@@ -18,6 +19,9 @@ class Possibility(object): ...@@ -18,6 +19,9 @@ class Possibility(object):
if self.handler in MESSAGES: if self.handler in MESSAGES:
msg = MESSAGES[self.handler] msg = MESSAGES[self.handler]
# Surround math notation with backticks
msg = re.sub('({[^ ]+)', r'`\1`', msg)
if callable(msg): if callable(msg):
msg = msg(self.root, self.args) msg = msg(self.root, self.args)
......
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