Merge pull request #743 from Learnosity/fix.staticmath-selectable-escaping

Escape latex in staticmath selectable span
diff --git a/circle.yml b/circle.yml
index 331b639..7fd97e5 100644
--- a/circle.yml
+++ b/circle.yml
@@ -44,19 +44,27 @@
 
         mkdir -p ~/sauce-connect
         cd ~/sauce-connect
+
         if [ -x sc-*-linux/bin/sc ]; then
           echo Using cached sc-*-linux/bin/sc
         else
           time wget https://saucelabs.com/downloads/sc-latest-linux.tar.gz
           time tar -xzf sc-latest-linux.tar.gz
         fi
-        # Sauce Connect randomly fails so try twice https://git.io/vPN8v
+
         time sc-*-linux/bin/sc --user $SAUCE_USERNAME --api-key $SAUCE_ACCESS_KEY \
           --readyfile ~/sauce_is_ready
         test -e ~/sauce_was_ready && exit
+
+        echo 'Sauce Connect failed, try redownloading (https://git.io/vSxsJ)'
+        rm -rf *
+        time wget https://saucelabs.com/downloads/sc-latest-linux.tar.gz
+        time tar -xzf sc-latest-linux.tar.gz
+
         time sc-*-linux/bin/sc --user $SAUCE_USERNAME --api-key $SAUCE_ACCESS_KEY \
           --readyfile ~/sauce_is_ready
         test -e ~/sauce_was_ready && exit
+
         echo 'ERROR: Exited twice without creating readyfile' \
           | tee /dev/stderr > ~/sauce_is_ready
         exit 1
@@ -65,6 +73,17 @@
 
 test:
   pre:
+    - |-
+      # Generate link to Many-Worlds build and add to GitHub Commit Status
+      curl -i -X POST https://api.github.com/repos/mathquill/mathquill/statuses/$CIRCLE_SHA1 \
+           -u MathQuillBot:$GITHUB_STATUS_API_KEY \
+           -d '{
+                 "context": "ci/many-worlds",
+                 "state": "success",
+                 "description": "Try the tests on the Many-Worlds build of this commit:",
+                 "target_url": "http://many-worlds.glitch.me/mathquill/mathquill/commit/'$CIRCLE_SHA1'/test/"
+               }'
+
     # Safari on Sauce can only connect to port 3000, 4000, 7000, or 8000. Edge needs port 7000 or 8000.
     # https://david263a.wordpress.com/2015/04/18/fixing-safari-cant-connect-to-localhost-issue-when-using-sauce-labs-connect-tunnel/
     # https://support.saucelabs.com/customer/portal/questions/14368823-requests-to-localhost-on-microsoft-edge-are-failing-over-sauce-connect
@@ -148,7 +167,8 @@
                  "framework": "mocha",
                  "url": "http://localhost:8000/test/unit.html?post_xunit_to=http://localhost:9000",
                  "platforms": [["", "Chrome", ""]]
-      }' | tee /dev/stderr | tail -1 > js-tests.json
+               }' \
+      | tee /dev/stderr | tail -1 > js-tests.json
 
       echo '2. Wait for tests to finish:'
       echo
diff --git a/src/css/math.less b/src/css/math.less
index 743f7ca..bff1201 100644
--- a/src/css/math.less
+++ b/src/css/math.less
@@ -50,7 +50,9 @@
 
   .mq-text-mode {
     display: inline-block;
+    white-space: pre;  
   }
+
   .mq-text-mode.mq-hasCursor {
     box-shadow: inset darkgray 0 .1em .2em;
     padding: 0 .1em;
diff --git a/test/visual.html b/test/visual.html
index a2207d1..1f77a3c 100644
--- a/test/visual.html
+++ b/test/visual.html
@@ -282,6 +282,12 @@
 

 <p>Should wrap anything you type in '&lt;&gt;': <span id="wrap-typing">1+2+3</span></p>

 

+<h3>Text mode</h3>

+

+<p>Spaces at the beginning and end of text mode blocks should be visible: <span class="mathquill-static-math">1\text{ And }2</span></p>

+

+<p>Mutiple consecutive spaces in the middle of a text mode block should not collapse into one space: <span class="mathquill-static-math">\text{three   spaces}</span></p>

+

 </div>

 <script type="text/javascript">

 window.onerror = function(err) {