From 43e03ba42c0f7dbf53bdbad929732c14a8bbacfd 2014-01-16 10:57:01
From: Jonathan Frederic <jdfreder@calpoly.edu>
Date: 2014-01-16 10:57:01
Subject: [PATCH] Use regular expressions when fixing button-like captions

---

diff --git a/IPython/html/static/notebook/js/widgets/button.js b/IPython/html/static/notebook/js/widgets/button.js
index de4759e..bea17eb 100644
--- a/IPython/html/static/notebook/js/widgets/button.js
+++ b/IPython/html/static/notebook/js/widgets/button.js
@@ -38,8 +38,8 @@ define(["notebook/js/widget"], function(){
         //          Frontent -> Frontend Sync
         update : function(){
             var description = this.model.get('description');
-            description = description.replace(' ', '&nbsp;');
-            description = description.replace('\n', '<br>\n');
+            description = description.replace(/ /g, '&nbsp;', 'm');
+            description = description.replace(/\n/g, '<br>\n', 'm');
             if (description.length == 0) {
                 this.$el.html('&nbsp;'); // Preserve button height
             } else {
diff --git a/IPython/html/static/notebook/js/widgets/selection.js b/IPython/html/static/notebook/js/widgets/selection.js
index 3bd0a8f..e5ae5a3 100644
--- a/IPython/html/static/notebook/js/widgets/selection.js
+++ b/IPython/html/static/notebook/js/widgets/selection.js
@@ -60,8 +60,8 @@ define(["notebook/js/widget"], function(){
         update : function(){
 
             var selected_item_text = this.model.get('value');
-            selected_item_text = selected_item_text.replace(' ', '&nbsp;');
-            selected_item_text = selected_item_text.replace('\n', '<br>\n');
+            selected_item_text = selected_item_text.replace(/ /g, '&nbsp;');
+            selected_item_text = selected_item_text.replace(/\n/g, '<br>\n');
             if (selected_item_text.length == 0) {
                 this.$droplabel.html('&nbsp;');
             } else {