diff --git a/IPython/html/static/base/js/utils.js b/IPython/html/static/base/js/utils.js index 2179e9760..4be262ca8 100644 --- a/IPython/html/static/base/js/utils.js +++ b/IPython/html/static/base/js/utils.js @@ -488,6 +488,12 @@ IPython.utils = (function (IPython) { }; + var escape_html = function (text) { + // escape text to HTML + return $("
").text(text).html(); + } + + var get_body_data = function(key) { // get a url-encoded item from body.data and decode it // we should never have any encoded URLs anywhere else in code @@ -564,6 +570,7 @@ IPython.utils = (function (IPython) { url_join_encode : url_join_encode, encode_uri_components : encode_uri_components, splitext : splitext, + escape_html : escape_html, always_new : always_new, browser : browser, platform: platform, diff --git a/IPython/html/static/notebook/js/widgets/widget_bool.js b/IPython/html/static/notebook/js/widgets/widget_bool.js index 22be10651..6acbe7693 100644 --- a/IPython/html/static/notebook/js/widgets/widget_bool.js +++ b/IPython/html/static/notebook/js/widgets/widget_bool.js @@ -56,7 +56,7 @@ define(["notebook/js/widgets/widget"], function(WidgetManager){ this.$checkbox.prop('disabled', disabled); var description = this.model.get('description'); - if (description.length === 0) { + if (description.trim().length === 0) { this.$label.hide(); } else { this.$label.text(description); @@ -102,8 +102,8 @@ define(["notebook/js/widgets/widget"], function(WidgetManager){ this.$el.prop('disabled', disabled); var description = this.model.get('description'); - if (description.length === 0) { - this.$el.text(' '); // Preserve button height + if (description.trim().length === 0) { + this.$el.html(" "); // Preserve button height } else { this.$el.text(description); } diff --git a/IPython/html/static/notebook/js/widgets/widget_button.js b/IPython/html/static/notebook/js/widgets/widget_button.js index a0b747ebd..eb3c317a8 100644 --- a/IPython/html/static/notebook/js/widgets/widget_button.js +++ b/IPython/html/static/notebook/js/widgets/widget_button.js @@ -32,7 +32,7 @@ define(["notebook/js/widgets/widget"], function(WidgetManager){ // changed by another view or by a state update from the back-end. var description = this.model.get('description'); if (description.length === 0) { - this.$el.text(' '); // Preserve button height + this.$el.html(" "); // Preserve button height } else { this.$el.text(description); } diff --git a/IPython/html/static/notebook/js/widgets/widget_container.js b/IPython/html/static/notebook/js/widgets/widget_container.js index eb538c2db..e6d51f6a8 100644 --- a/IPython/html/static/notebook/js/widgets/widget_container.js +++ b/IPython/html/static/notebook/js/widgets/widget_container.js @@ -137,7 +137,7 @@ define(["notebook/js/widgets/widget"], function(WidgetManager) { }); this.$title = $('
') .addClass('widget-modal-title') - .text(' ') + .html(" ") .appendTo(this.$title_bar); this.$body = $('
') .addClass('modal-body') @@ -147,7 +147,7 @@ define(["notebook/js/widgets/widget"], function(WidgetManager) { .appendTo(this.$window); this.$show_button = $('