From 97dc1bf1daa1221828bcaeaa24d5f878e626a313 Mon Sep 17 00:00:00 2001 From: Ben Alpert Date: Fri, 5 Jul 2013 21:44:17 -0700 Subject: [PATCH] Add \pm, \div Reviewers: xymostech Reviewed By: xymostech Differential Revision: http://phabricator.benalpert.com/D36 --- MJLite.js | 12 +++++++----- parser.jison | 6 ++++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/MJLite.js b/MJLite.js index 2568c62e3..819d6e29e 100644 --- a/MJLite.js +++ b/MJLite.js @@ -62,11 +62,13 @@ var MJLite = (function() { }; var charLookup = { - '*': '\u2217', - '-': '\u2212', - 'cdot': '\u22C5', - 'lvert': '|', - 'rvert': '|' + "*": "\u2217", + "-": "\u2212", + "cdot": "\u22C5", + "lvert": "|", + "rvert": "|", + "pm": "\u00b1", + "div": "\u00f7" }; var textit = function(value) { diff --git a/parser.jison b/parser.jison index ff7b085a0..bb9b058db 100644 --- a/parser.jison +++ b/parser.jison @@ -9,6 +9,8 @@ cdot return 'CDOT' frac return 'FRAC' lvert return 'LVERT' rvert return 'RVERT' +pm return 'PM' +div return 'DIV' [/|a-zA-Z0-9] return 'ORD' [*+-] return 'BIN' \^ return '^' @@ -66,6 +68,10 @@ group func : 'CDOT' {$$ = [{type: 'bin', value: yytext}];} + | 'PM' + {$$ = [{type: 'bin', value: yytext}];} + | 'DIV' + {$$ = [{type: 'bin', value: yytext}];} | 'FRAC' group group {$$ = [{type: 'frac', value: {numer: $2, denom: $3}}];} | 'LVERT'