diff --git a/IPython/html/static/notebook/js/textcell.js b/IPython/html/static/notebook/js/textcell.js index fd9f7da..71e604a 100644 --- a/IPython/html/static/notebook/js/textcell.js +++ b/IPython/html/static/notebook/js/textcell.js @@ -163,6 +163,7 @@ define([ * */ TextCell.prototype.set_text = function(text) { this.code_mirror.setValue(text); + this.unrender(); this.code_mirror.refresh(); }; diff --git a/IPython/html/tests/notebook/markdown.js b/IPython/html/tests/notebook/markdown.js index 0c1f61e..5f28d31 100644 --- a/IPython/html/tests/notebook/markdown.js +++ b/IPython/html/tests/notebook/markdown.js @@ -17,20 +17,31 @@ casper.notebook_test(function () { $('#to_code').mouseenter().click(); $('#to_markdown').mouseenter().click(); var cell = IPython.notebook.get_selected_cell(); - cell.set_text('# Foo'); + cell.set_text('# Bar'); $('#run_cell').mouseenter().click(); return cell.get_rendered(); }); - this.test.assertEquals(output.trim(), '

Foo

', 'Markdown menubar items work.'); + this.test.assertEquals(output.trim(), '

Bar

', 'Markdown menubar items work.'); // Test toolbar buttons. output = this.evaluate(function () { $('#cell_type').val('code').change(); $('#cell_type').val('markdown').change(); var cell = IPython.notebook.get_selected_cell(); - cell.set_text('# Foo'); + cell.set_text('# Baz'); $('#run_b').click(); return cell.get_rendered(); }); - this.test.assertEquals(output.trim(), '

Foo

', 'Markdown toolbar items work.'); + this.test.assertEquals(output.trim(), '

Baz

', 'Markdown toolbar items work.'); + + // Test JavaScript models. + var output = this.evaluate(function () { + + var cell = IPython.notebook.insert_cell_at_index('markdown', 0); + cell.set_text('# Qux'); + cell.render(); + return cell.get_rendered(); + }); + this.test.assertEquals(output.trim(), '

Qux

', 'Markdown JS API works.'); + });