Skip to content
Snippets Groups Projects
Commit dbc158eb authored by Sander Mathijs van Veen's avatar Sander Mathijs van Veen
Browse files

Math expressions in hints are pretty printed using MathJax.

parent 65c425db
No related branches found
No related tags found
No related merge requests found
...@@ -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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment