From a0e0f39128909d460dd74da89f741ca9e09f8e60 2012-04-15 00:46:25 From: Fernando Perez Date: 2012-04-15 00:46:25 Subject: [PATCH] Merge pull request #1490 from minrk/raw rename plaintext cell -> raw cell Raw cells should be *untransformed* when writing various output formats, as the point of them is to let users pass through IPython to their rendered document format (rst, latex, etc.). This is different from what is the logical meaning of 'plaintext', which would suggest that the contents should be preserved as unformatted plaintext (e.g. in a `
` tag, or literal block).

In the UI, these cells will be displayed as 'Raw Text'.

WARNING: any existing v3 notebooks which use plaintext cells, when read in by versions after this merge, will silently rename those cells to 'raw'.  But if such a notebook is uploaded into a pre-merge IPython, cells labeled as 'raw' will simply *not be displayed*.
---

diff --git a/IPython/frontend/html/notebook/static/js/menubar.js b/IPython/frontend/html/notebook/static/js/menubar.js
index a3d3ec0..e7da920 100644
--- a/IPython/frontend/html/notebook/static/js/menubar.js
+++ b/IPython/frontend/html/notebook/static/js/menubar.js
@@ -130,8 +130,8 @@ var IPython = (function (IPython) {
         this.element.find('#to_markdown').click(function () {
             IPython.notebook.to_markdown();
         });
-        this.element.find('#to_plaintext').click(function () {
-            IPython.notebook.to_plaintext();
+        this.element.find('#to_raw').click(function () {
+            IPython.notebook.to_raw();
         });
         this.element.find('#to_heading1').click(function () {
             IPython.notebook.to_heading(undefined, 1);
diff --git a/IPython/frontend/html/notebook/static/js/notebook.js b/IPython/frontend/html/notebook/static/js/notebook.js
index 8836013..12ac322 100644
--- a/IPython/frontend/html/notebook/static/js/notebook.js
+++ b/IPython/frontend/html/notebook/static/js/notebook.js
@@ -140,8 +140,8 @@ var IPython = (function (IPython) {
                 that.control_key_active = false;
                 return false;
             } else if (event.which === 84 && that.control_key_active) {
-                // To Plaintext = t
-                that.to_plaintext();
+                // To Raw = t
+                that.to_raw();
                 that.control_key_active = false;
                 return false;
             } else if (event.which === 49 && that.control_key_active) {
@@ -523,8 +523,8 @@ var IPython = (function (IPython) {
                 cell = new IPython.MarkdownCell(this);
             } else if (type === 'html') {
                 cell = new IPython.HTMLCell(this);
-            } else if (type === 'plaintext') {
-                cell = new IPython.PlaintextCell(this);
+            } else if (type === 'raw') {
+                cell = new IPython.RawCell(this);
             } else if (type === 'heading') {
                 cell = new IPython.HeadingCell(this);
             };
@@ -557,8 +557,8 @@ var IPython = (function (IPython) {
                 cell = new IPython.MarkdownCell(this);
             } else if (type === 'html') {
                 cell = new IPython.HTMLCell(this);
-            } else if (type === 'plaintext') {
-                cell = new IPython.PlaintextCell(this);
+            } else if (type === 'raw') {
+                cell = new IPython.RawCell(this);
             } else if (type === 'heading') {
                 cell = new IPython.HeadingCell(this);
             };
@@ -640,14 +640,14 @@ var IPython = (function (IPython) {
     };
 
 
-    Notebook.prototype.to_plaintext = function (index) {
+    Notebook.prototype.to_raw = function (index) {
         var i = this.index_or_selected(index);
         if (this.is_valid_cell_index(i)) {
             var source_element = this.get_cell_element(i);
             var source_cell = source_element.data("cell");
             var target_cell = null;
-            if (!(source_cell instanceof IPython.PlaintextCell)) {
-                target_cell = this.insert_cell_below('plaintext',i);
+            if (!(source_cell instanceof IPython.RawCell)) {
+                target_cell = this.insert_cell_below('raw',i);
                 var text = source_cell.get_text();
                 if (text === source_cell.placeholder) {
                     text = '';
@@ -1197,6 +1197,12 @@ var IPython = (function (IPython) {
             var new_cell = null;
             for (i=0; i raw
+                // handle never-released plaintext name for raw cells
+                if (cell_data.cell_type === 'plaintext'){
+                    cell_data.cell_type = 'raw';
+                }
+                
                 new_cell = this.insert_cell_below(cell_data.cell_type);
                 new_cell.fromJSON(cell_data);
             };
diff --git a/IPython/frontend/html/notebook/static/js/quickhelp.js b/IPython/frontend/html/notebook/static/js/quickhelp.js
index 4edd117..3376883 100644
--- a/IPython/frontend/html/notebook/static/js/quickhelp.js
+++ b/IPython/frontend/html/notebook/static/js/quickhelp.js
@@ -41,7 +41,7 @@ var IPython = (function (IPython) {
             {key: 'Ctrl-m k', help: 'move cell up'},
             {key: 'Ctrl-m y', help: 'code cell'},
             {key: 'Ctrl-m m', help: 'markdown cell'},
-            {key: 'Ctrl-m t', help: 'plaintext cell'},
+            {key: 'Ctrl-m t', help: 'raw cell'},
             {key: 'Ctrl-m 1-6', help: 'heading 1-6 cell'},
             {key: 'Ctrl-m p', help: 'select previous'},
             {key: 'Ctrl-m n', help: 'select next'},
diff --git a/IPython/frontend/html/notebook/static/js/textcell.js b/IPython/frontend/html/notebook/static/js/textcell.js
index 4ee76b1..edf7298 100644
--- a/IPython/frontend/html/notebook/static/js/textcell.js
+++ b/IPython/frontend/html/notebook/static/js/textcell.js
@@ -237,33 +237,33 @@ var IPython = (function (IPython) {
     };
 
 
-    // PlaintextCell
+    // RawCell
 
-    var PlaintextCell = function (notebook) {
+    var RawCell = function (notebook) {
         this.placeholder = "Type plain text and LaTeX: $\\alpha^2$";
         this.code_mirror_mode = 'rst';
         IPython.TextCell.apply(this, arguments);
-        this.cell_type = 'plaintext';
+        this.cell_type = 'raw';
     };
 
 
-    PlaintextCell.prototype = new TextCell();
+    RawCell.prototype = new TextCell();
 
 
-    PlaintextCell.prototype.render = function () {
+    RawCell.prototype.render = function () {
         this.rendered = true;
         this.edit();
     };
 
 
-    PlaintextCell.prototype.select = function () {
+    RawCell.prototype.select = function () {
         IPython.Cell.prototype.select.apply(this);
         this.code_mirror.refresh();
         this.code_mirror.focus();
     };
 
 
-    PlaintextCell.prototype.at_top = function () {
+    RawCell.prototype.at_top = function () {
         var cursor = this.code_mirror.getCursor();
         if (cursor.line === 0) {
             return true;
@@ -273,7 +273,7 @@ var IPython = (function (IPython) {
     };
 
 
-    PlaintextCell.prototype.at_bottom = function () {
+    RawCell.prototype.at_bottom = function () {
         var cursor = this.code_mirror.getCursor();
         if (cursor.line === (this.code_mirror.lineCount()-1)) {
             return true;
@@ -353,7 +353,7 @@ var IPython = (function (IPython) {
     IPython.TextCell = TextCell;
     IPython.HTMLCell = HTMLCell;
     IPython.MarkdownCell = MarkdownCell;
-    IPython.PlaintextCell = PlaintextCell;
+    IPython.RawCell = RawCell;
     IPython.HeadingCell = HeadingCell;
 
 
diff --git a/IPython/frontend/html/notebook/static/js/toolbar.js b/IPython/frontend/html/notebook/static/js/toolbar.js
index 564ed0a..a7e337c 100644
--- a/IPython/frontend/html/notebook/static/js/toolbar.js
+++ b/IPython/frontend/html/notebook/static/js/toolbar.js
@@ -113,8 +113,8 @@ var IPython = (function (IPython) {
                 IPython.notebook.to_code();
             } else if (cell_type === 'markdown')  {
                 IPython.notebook.to_markdown();
-            } else if (cell_type === 'plaintext')  {
-                IPython.notebook.to_plaintext();
+            } else if (cell_type === 'raw')  {
+                IPython.notebook.to_raw();
             } else if (cell_type === 'heading1')  {
                 IPython.notebook.to_heading(undefined, 1);
             } else if (cell_type === 'heading2')  {
diff --git a/IPython/frontend/html/notebook/templates/notebook.html b/IPython/frontend/html/notebook/templates/notebook.html
index 97f384d..7a6e3e9 100644
--- a/IPython/frontend/html/notebook/templates/notebook.html
+++ b/IPython/frontend/html/notebook/templates/notebook.html
@@ -107,7 +107,7 @@ data-notebook-id={{notebook_id}}
                 
  • Code
  • Markdown
  • -
  • Plaintext
  • +
  • Raw Text
  • Heading 1
  • Heading 2
  • Heading 3
  • @@ -171,7 +171,7 @@ data-notebook-id={{notebook_id}}