commit 66a43f551d73349c11792260396b680d620b10e7
parent b016015d4ede0ee0ab0d2e94a25ef5a7d469c7e5
Author: Emily Eisenberg <xymostech@gmail.com>
Date: Tue, 9 Jul 2013 16:02:44 -0700
Add llap and rlap
Summary:
By the powers of Greyskull (and maybe css) we have vanquished the
great and powerful llap! All hail!
Test Plan: Add some \llap and \rlap. Make sure it's positioned correctly.
Reviewers: spicyj
Reviewed By: spicyj
Differential Revision: http://phabricator.benalpert.com/D48
Diffstat:
4 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/MJLite.js b/MJLite.js
@@ -80,6 +80,12 @@ var buildGroup = function(group, prev) {
return makeSpan("mord mspace " + spacingClassMap[group.value]);
}
+ } else if (group.type === "llap") {
+ var inner = makeSpan("", buildExpression(group.value));
+ return makeSpan("llap", inner);
+ } else if (group.type === "rlap") {
+ var inner = makeSpan("", buildExpression(group.value));
+ return makeSpan("rlap", inner);
} else {
console.log("Unknown type:", group.type);
}
diff --git a/lexer.js b/lexer.js
@@ -25,7 +25,7 @@ var funcs = [
// Colors
'blue', 'orange', 'pink', 'red', 'green', 'gray', 'purple',
// Other functions
- 'dfrac'
+ 'dfrac', 'llap', 'rlap'
];
var anyFunc = new RegExp("^\\\\(" + funcs.join("|") + ")(?![a-zA-Z])");
diff --git a/parser.jison b/parser.jison
@@ -90,6 +90,10 @@ func
{$$ = [{type: 'color', value: {color: 'purple', value: $2}}];}
| 'dfrac' group group
{$$ = [{type: 'dfrac', value: {numer: $2, denom: $3}}];}
+ | 'llap' group
+ {$$ = [{type: 'llap', value: $2}];}
+ | 'rlap' group
+ {$$ = [{type: 'rlap', value: $2}];}
;
atom
diff --git a/static/mjlite.css b/static/mjlite.css
@@ -129,6 +129,20 @@ big parens
width: 2em;
}
+.llap, .rlap {
+ width: 0;
+ position: relative;
+}
+
+.llap > span {
+ position: absolute;
+ right: 0;
+}
+
+.rlap > span {
+ position: absolute;
+ left: 0;
+}
.mord.blue { color: #6495ed; }
.mord.orange { color: #ffa500; }