Merge pull request #602 from mathquill/fix.visual-rendering

Fix visual rendering of sum, operator names (sin etc), supsub
diff --git a/src/commands/math/basicSymbols.js b/src/commands/math/basicSymbols.js
index 2b55143..06ea85c 100644
--- a/src/commands/math/basicSymbols.js
+++ b/src/commands/math/basicSymbols.js
@@ -122,8 +122,11 @@
           first.ctrlSeq = (isBuiltIn ? '\\' : '\\operatorname{') + first.ctrlSeq;
           last.ctrlSeq += (isBuiltIn ? ' ' : '}');
           if (TwoWordOpNames.hasOwnProperty(word)) last[L][L][L].jQ.addClass('mq-last');
-          if (nonOperatorSymbol(first[L])) first.jQ.addClass('mq-first');
-          if (nonOperatorSymbol(last[R])) last.jQ.addClass('mq-last');
+          if (!shouldOmitPadding(first[L])) first.jQ.addClass('mq-first');
+          if (!shouldOmitPadding(last[R]) && !(last[R] instanceof Bracket)) {
+            // also omit space between operator name and paren like in sin(x)
+            last.jQ.addClass('mq-last');
+          }
 
           i += len - 1;
           first = last;
@@ -132,8 +135,9 @@
       }
     }
   };
-  function nonOperatorSymbol(node) {
-    return node instanceof Symbol && !(node instanceof BinaryOperator);
+  function shouldOmitPadding(node) {
+    // omit padding if no node, or if node already has padding (to avoid double-padding)
+    return !node || (node instanceof BinaryOperator) || (node instanceof SummationNotation);
   }
 });
 var BuiltInOpNames = {}; // the set of operator names like \sin, \cos, etc that
diff --git a/src/css/math.less b/src/css/math.less
index fcaa23d..49a4214 100644
--- a/src/css/math.less
+++ b/src/css/math.less
@@ -87,7 +87,7 @@
   }
 
   big {
-    font-size: 125%;
+    font-size: 200%;
   }
 
   .mq-roman {
@@ -129,6 +129,7 @@
   //   its contents, rather than always being as wide as the subscript.
   //   See also .fraction
   .mq-supsub {
+    text-align: left;
     font-size: 90%;
     vertical-align: -.5em;
     &.mq-limit {
@@ -291,6 +292,8 @@
   }
 
   .mq-large-operator {
+    vertical-align: -.2em;
+    padding: .2em;
     text-align: center;
 
     .mq-from, big, .mq-to  {
diff --git a/test/visual.html b/test/visual.html
index 0429dd0..cda3f14 100644
--- a/test/visual.html
+++ b/test/visual.html
@@ -77,7 +77,7 @@
   <td><span class="mathquill-static-math">\sqrt{\MathQuillMathField{x^2+y^2}}</span>

 </table>

 

-<p>Clicks/mousedown to drag should work anywhere in the blue box: <div class="math-container" style="border: solid 1px lightblue; height: 5em; width: 15em; line-height: 5em; text-align: center"><span class="mathquill-math-field">a_2 x^2 + a_1 x + a_0 = 0</span></div>

+<p>Clicks/mousedown to drag should work anywhere in the blue box: <div class="math-container" style="border: solid 1px lightblue; height: 5em; width: 15em; line-height: 5em; text-align: center"><span class="mathquill-math-field">x_{very\ long\ thing}^2 + a_0 = 0</span></div>

 

 <h3>Redrawing</h3>

 <p>

@@ -187,7 +187,17 @@
 <tr><td><span class="mathquill-static-math">^{\frac{as}{ }df}</span><td><span>^{\frac{as}{ }df}</span>

 <tr><td><span class="mathquill-static-math">e^{i\pi}+1=0</span><td><span>e^{i\pi}+1=0</span>

 <tr><td><span class="mathquill-static-math">\sqrt[n]{1}</span><td><span>\sqrt[n]{1}</span>

-<tr><td><span class="mathquill-static-math">\theta + \sin 2\deg</span><td><span>\theta + \sin 2\deg</span>

+<tr><td><span class="mathquill-static-math">12a\sin b</span></td><td><span>12a\sin b</span>

+<tr><td><span class="mathquill-static-math">1a^2 \sin b</span></td><td><span>1a^2 \sin b</span>

+<tr><td><span class="mathquill-static-math">a + \sin b</span></td><td><span>a + \sin b</span>

+<tr><td><span class="mathquill-static-math">a + b</span></td><td><span>a + b</span>

+<tr><td><span class="mathquill-static-math">\sum\sin</span></td><td><span>\sum\sin</span>

+<tr><td><span class="mathquill-static-math">\sum a</span></td><td><span>\sum a</span>

+<tr><td><span class="mathquill-static-math">(\sin)</span></td><td><span>(\sin)</span>

+<tr><td><span class="mathquill-static-math">\left(\sin\right)</span></td><td><span>\left(\sin\right)</span>

+<tr><td><span class="mathquill-static-math">(x)\sin(x)</span></td><td><span>(x)\sin(x)</span>

+<tr><td><span class="mathquill-static-math">\left(x\right)\sin\left(x\right)</span></td><td><span>\left(x\right)\sin\left(x\right)</span>

+<tr><td><span class="mathquill-static-math">a \sin b</span></td><td><span>a \sin b</span>

 <tr><td><span class="mathquill-static-math">-1 + +-2</span><td><span>-1 + +-2</span>

 <tr><td><span class="mathquill-static-math">\left ( n+1 \right ) + \frac{1}{\frac{n}{k}} + \binom{n}{k}</span><td><span>\left ( n+1 \right ) + \frac{1}{\frac{n}{k}} + \binom{n}{k}</span>

 <tr><td><span class="mathquill-static-math">x_{\frac{1}{\frac{2}{3}}}^{\frac{\frac{1}{2}}{3}}</span><td><span>x_{\frac{1}{\frac{2}{3}}}^{\frac{\frac{1}{2}}{3}}</span>