##// END OF EJS Templates
Add ScrollManager to global ipy namespace in main.js instead of,...
Add ScrollManager to global ipy namespace in main.js instead of, in the bottom of the scroll manager js file.

File last commit:

r17786:0f99ba31 merge
r17868:7d0e0ec2
Show More
textcell.js
450 lines | 14.1 KiB | application/javascript | JavascriptLexer
Jonathan Frederic
Progress...
r17196 // Copyright (c) IPython Development Team.
// Distributed under the terms of the Modified BSD License.
define([
'base/js/namespace',
MinRK
move mergeopt to utils...
r17764 'base/js/utils',
Jonathan Frederic
MWE,...
r17200 'jquery',
Jonathan Frederic
Progress...
r17196 'notebook/js/cell',
'base/js/security',
Jonathan Frederic
MWE,...
r17200 'notebook/js/mathjaxutils',
'notebook/js/celltoolbar',
Jonathan Frederic
nbconvert api tests fixes
r17205 'components/marked/lib/marked',
MinRK
move mergeopt to utils...
r17764 ], function(IPython, utils, $, cell, security, mathjaxutils, celltoolbar, marked) {
Matthias BUSSONNIER
patch header-cell and use-strict
r11526 "use strict";
Jonathan Frederic
Fix all the bugs!
r17203 var Cell = cell.Cell;
Brian E. Granger
Splitting notebook.js into muliple files for development ease.
r4349
jon
In person review with @ellisonbg
r17210 var TextCell = function (options) {
jon
Added some nice comments,...
r17211 // Constructor
//
// Construct a new TextCell, codemirror mode is by default 'htmlmixed',
// and cell type is 'text' cell start as not redered.
//
// Parameters:
// options: dictionary
// Dictionary of keyword arguments.
// events: $(Events) instance
// config: dictionary
// keyboard_manager: KeyboardManager instance
// notebook: Notebook instance
jon
In person review with @ellisonbg
r17210 options = options || {};
jon
Added some nice comments,...
r17211
Matthias BUSSONNIER
JS Configurablity Take 2...
r10165 // in all TextCell/Cell subclasses
// do not assign most of members here, just pass it down
// in the options dict potentially overwriting what you wish.
// they will be assigned in the base class.
jon
In person review with @ellisonbg
r17210 this.notebook = options.notebook;
this.events = options.events;
this.config = options.config;
Jonathan Frederic
MWE,...
r17200
Matthias BUSSONNIER
JS Configurablity Take 2...
r10165 // we cannot put this as a class key as it has handle to "this".
Matthias BUSSONNIER
Make CodeMirror configurable...
r9537 var cm_overwrite_options = {
Brian E. Granger
Lots of updates and changes....
r14021 onKeyEvent: $.proxy(this.handle_keyevent,this)
Matthias BUSSONNIER
Make CodeMirror configurable...
r9537 };
MinRK
move mergeopt to utils...
r17764 var config = utils.mergeopt(TextCell, this.config, {cm_config:cm_overwrite_options});
jon
In person review with @ellisonbg
r17210 Cell.apply(this, [{
config: config,
keyboard_manager: options.keyboard_manager,
Jonathan Frederic
Some JS test fixes
r17212 events: this.events}]);
Matthias BUSSONNIER
Make CodeMirror configurable...
r9537
MinRK
give Raw Cells a placeholder...
r13668 this.cell_type = this.cell_type || 'text';
Jonathan Frederic
MWE,...
r17200 mathjaxutils = mathjaxutils;
Brian E. Granger
Implemented module and namespace pattern in js notebook.
r4352 this.rendered = false;
};
Jonathan Frederic
Fix all the bugs!
r17203 TextCell.prototype = new Cell();
Matthias BUSSONNIER
JS Configurablity Take 2...
r10165
TextCell.options_default = {
cm_config : {
extraKeys: {"Tab": "indentMore","Shift-Tab" : "indentLess"},
mode: 'htmlmixed',
Matthias BUSSONNIER
Make CodeMirror configurable...
r9537 lineWrapping : true,
}
Matthias BUSSONNIER
JS Configurablity Take 2...
r10165 };
Matthias BUSSONNIER
Make CodeMirror configurable...
r9537
Matthias BUSSONNIER
Document more function....
r8711 /**
* Create the DOM element of the TextCell
Matthias BUSSONNIER
start to document js
r8709 * @method create_element
* @private
*/
Brian Granger
Refactoring of text/markdown/rst/html cells.
r4508 TextCell.prototype.create_element = function () {
Jonathan Frederic
Fix all the bugs!
r17203 Cell.prototype.create_element.apply(this, arguments);
Brian E. Granger
Adding prompt area to non-CodeCells to indent content....
r13776
Matthias BUSSONNIER
Transfer of border-box-sizing from js to css...
r17422 var cell = $("<div>").addClass('cell text_cell');
Brian E. Granger
Better tabindex support.
r4629 cell.attr('tabindex','2');
Brian Granger
Further cleanup for celltoolbars.
r9144
Brian E. Granger
Adding prompt area to non-CodeCells to indent content....
r13776 var prompt = $('<div/>').addClass('prompt input_prompt');
cell.append(prompt);
var inner_cell = $('<div/>').addClass('inner_cell');
Jonathan Frederic
More review changes
r17214 this.celltoolbar = new celltoolbar.CellToolbar({
cell: this,
notebook: this.notebook});
Brian E. Granger
Adding prompt area to non-CodeCells to indent content....
r13776 inner_cell.append(this.celltoolbar.element);
MinRK
make input_area css generic to cells...
r15552 var input_area = $('<div/>').addClass('input_area');
Jonathan Frederic
Post in person review...
r15497 this.code_mirror = new CodeMirror(input_area.get(0), this.cm_config);
Brian E. Granger
New HTMl cell working with CodeMirror editing.
r4499 // The tabindex=-1 makes this div focusable.
Matthias BUSSONNIER
move styling from js to css
r17426 var render_area = $('<div/>').addClass('text_cell_render rendered_html')
.attr('tabindex','-1');
Brian E. Granger
Adding prompt area to non-CodeCells to indent content....
r13776 inner_cell.append(input_area).append(render_area);
cell.append(inner_cell);
Brian E. Granger
Implemented module and namespace pattern in js notebook.
r4352 this.element = cell;
};
Matthias BUSSONNIER
Document more function....
r8711 /**
* Bind the DOM evet to cell actions
Matthias BUSSONNIER
start to document js
r8709 * Need to be called after TextCell.create_element
* @private
* @method bind_event
*/
Brian Granger
Refactoring of text/markdown/rst/html cells.
r4508 TextCell.prototype.bind_events = function () {
Jonathan Frederic
Fix all the bugs!
r17203 Cell.prototype.bind_events.apply(this);
Brian E. Granger
Implemented module and namespace pattern in js notebook.
r4352 var that = this;
Brian E. Granger
More work on the dual mode UX.
r14015
Brian Granger
Lots of small notebook improvements....
r5946 this.element.dblclick(function () {
Brian E. Granger
Semi working version of basic dual mode UX....
r14016 if (that.selected === false) {
Jonathan Frederic
Progress...
r17196 this.events.trigger('select.Cell', {'cell':that});
Jonathan Frederic
Post in person review...
r15497 }
Jonathan Frederic
implemented whiteboard logic
r15531 var cont = that.unrender();
if (cont) {
that.focus_editor();
}
Brian E. Granger
Implemented module and namespace pattern in js notebook.
r4352 });
};
Brian E. Granger
Splitting notebook.js into muliple files for development ease.
r4349
Brian E. Granger
Adding new logic to cells.
r14014 // Cell level actions
Brian Granger
Refactoring of text/markdown/rst/html cells.
r4508 TextCell.prototype.select = function () {
Jonathan Frederic
Fix all the bugs!
r17203 var cont = Cell.prototype.select.apply(this);
Brian E. Granger
More work on the dual mode UX.
r14015 if (cont) {
Brian E. Granger
Adding new logic to cells.
r14014 if (this.mode === 'edit') {
this.code_mirror.refresh();
}
Jonathan Frederic
Post in person review...
r15497 }
Brian E. Granger
More work on the dual mode UX.
r14015 return cont;
MinRK
trigger textcell render on unselect instead of focusout
r5833 };
Brian E. Granger
Adding new logic to cells.
r14014 TextCell.prototype.unrender = function () {
if (this.read_only) return;
Jonathan Frederic
Fix all the bugs!
r17203 var cont = Cell.prototype.unrender.apply(this);
Brian E. Granger
More work on the dual mode UX.
r14015 if (cont) {
Brian Granger
Refactoring of text/markdown/rst/html cells.
r4508 var text_cell = this.element;
Matthias BUSSONNIER
start to document js
r8709 var output = text_cell.find("div.text_cell_render");
Brian E. Granger
Implemented module and namespace pattern in js notebook.
r4352 output.hide();
MinRK
make input_area css generic to cells...
r15552 text_cell.find('div.input_area').show();
Brian Granger
Work on the base Cell API....
r5943 if (this.get_text() === this.placeholder) {
this.set_text('');
Stefan van der Walt
Clean up javascript based on js2-mode feedback.
r5479 }
Brian E. Granger
Always refresh the CM editor upon TextCell unrender.
r15502 this.refresh();
Jonathan Frederic
Post in person review...
r15497 }
Brian E. Granger
More work on the dual mode UX.
r14015 return cont;
};
TextCell.prototype.execute = function () {
this.render();
Brian E. Granger
Adding new logic to cells.
r14014 };
Brian E. Granger
Splitting notebook.js into muliple files for development ease.
r4349
Matthias BUSSONNIER
start to document js
r8709 /**
* setter: {{#crossLink "TextCell/set_text"}}{{/crossLink}}
* @method get_text
* @retrun {string} CodeMirror current text value
*/
Brian Granger
Work on the base Cell API....
r5943 TextCell.prototype.get_text = function() {
Brian E. Granger
New HTMl cell working with CodeMirror editing.
r4499 return this.code_mirror.getValue();
Brian E. Granger
Implemented module and namespace pattern in js notebook.
r4352 };
Brian E. Granger
Splitting notebook.js into muliple files for development ease.
r4349
Matthias BUSSONNIER
start to document js
r8709 /**
* @param {string} text - Codemiror text value
* @see TextCell#get_text
* @method set_text
* */
Brian Granger
Work on the base Cell API....
r5943 TextCell.prototype.set_text = function(text) {
Brian E. Granger
New HTMl cell working with CodeMirror editing.
r4499 this.code_mirror.setValue(text);
Paul Ivanov
call unrender() when setting text of cells
r17464 this.unrender();
Brian E. Granger
New HTMl cell working with CodeMirror editing.
r4499 this.code_mirror.refresh();
Brian E. Granger
Implemented module and namespace pattern in js notebook.
r4352 };
Brian E. Granger
Splitting notebook.js into muliple files for development ease.
r4349
Matthias BUSSONNIER
start to document js
r8709 /**
* setter :{{#crossLink "TextCell/set_rendered"}}{{/crossLink}}
* @method get_rendered
* */
Brian E. Granger
Fixed text cell rendering bug.
r4513 TextCell.prototype.get_rendered = function() {
Brian Granger
Refactoring of text/markdown/rst/html cells.
r4508 return this.element.find('div.text_cell_render').html();
};
Matthias BUSSONNIER
start to document js
r8709 /**
* @method set_rendered
*/
Brian Granger
Refactoring of text/markdown/rst/html cells.
r4508 TextCell.prototype.set_rendered = function(text) {
this.element.find('div.text_cell_render').html(text);
Brian E. Granger
Implemented module and namespace pattern in js notebook.
r4352 };
Brian E. Granger
Splitting notebook.js into muliple files for development ease.
r4349
Matthias BUSSONNIER
Document more function....
r8711 /**
* Create Text cell from JSON
Matthias BUSSONNIER
start to document js
r8709 * @param {json} data - JSON serialized text-cell
Matthias BUSSONNIER
Document more function....
r8711 * @method fromJSON
Matthias BUSSONNIER
start to document js
r8709 */
Brian Granger
Refactoring of text/markdown/rst/html cells.
r4508 TextCell.prototype.fromJSON = function (data) {
Jonathan Frederic
Fix all the bugs!
r17203 Cell.prototype.fromJSON.apply(this, arguments);
Brian Granger
Refactoring of text/markdown/rst/html cells.
r4508 if (data.cell_type === this.cell_type) {
Brian E. Granger
New HTMl cell working with CodeMirror editing.
r4499 if (data.source !== undefined) {
Brian Granger
Work on the base Cell API....
r5943 this.set_text(data.source);
Paul Ivanov
fix for #1678, undo no longer clears cells...
r7587 // make this value the starting point, so that we can only undo
// to this state, instead of a blank cell
this.code_mirror.clearHistory();
Jonathan Frederic
Treat set_rendered as unsafe.
r15407 // TODO: This HTML needs to be treated as potentially dangerous
// user input and should be handled before set_rendered.
Brian E. Granger
Fixed text cell rendering bug.
r4513 this.set_rendered(data.rendered || '');
this.rendered = false;
this.render();
Stefan van der Walt
Clean up javascript based on js2-mode feedback.
r5479 }
}
Brian E. Granger
Fixed text cell rendering bug.
r4513 };
Brian E. Granger
Splitting notebook.js into muliple files for development ease.
r4349
Matthias BUSSONNIER
Document more function....
r8711 /** Generate JSON from cell
* @return {object} cell data serialised to json
*/
Brian Granger
Refactoring of text/markdown/rst/html cells.
r4508 TextCell.prototype.toJSON = function () {
Jonathan Frederic
Fix all the bugs!
r17203 var data = Cell.prototype.toJSON.apply(this);
Brian Granger
Work on the base Cell API....
r5943 data.source = this.get_text();
MinRK
give Raw Cells a placeholder...
r13668 if (data.source == this.placeholder) {
data.source = "";
}
Brian E. Granger
Massive work on the notebook document format....
r4484 return data;
Brian E. Granger
Splitting notebook.js into muliple files for development ease.
r4349 };
Brian Granger
Refactoring of text/markdown/rst/html cells.
r4508
jon
In person review with @ellisonbg
r17210 var MarkdownCell = function (options) {
jon
Added some nice comments,...
r17211 // Constructor
//
// Parameters:
// options: dictionary
// Dictionary of keyword arguments.
// events: $(Events) instance
// config: dictionary
// keyboard_manager: KeyboardManager instance
// notebook: Notebook instance
jon
In person review with @ellisonbg
r17210 options = options || {};
MinRK
move mergeopt to utils...
r17764 var config = utils.mergeopt(MarkdownCell, options.config);
jon
In person review with @ellisonbg
r17210 TextCell.apply(this, [$.extend({}, options, {config: config})]);
Matthias BUSSONNIER
JS Configurablity Take 2...
r10165
Brian Granger
Refactoring of text/markdown/rst/html cells.
r4508 this.cell_type = 'markdown';
};
Matthias BUSSONNIER
JS Configurablity Take 2...
r10165 MarkdownCell.options_default = {
cm_config: {
Jonathan Frederic
Create ipythongfm mode
r16787 mode: 'ipythongfm'
Matthias BUSSONNIER
JS Configurablity Take 2...
r10165 },
placeholder: "Type *Markdown* and LaTeX: $\\alpha^2$"
Jonathan Frederic
Post in person review...
r15497 };
Matthias BUSSONNIER
JS Configurablity Take 2...
r10165
Brian Granger
Refactoring of text/markdown/rst/html cells.
r4508 MarkdownCell.prototype = new TextCell();
Matthias BUSSONNIER
Document more function....
r8711 /**
* @method render
*/
Brian Granger
Refactoring of text/markdown/rst/html cells.
r4508 MarkdownCell.prototype.render = function () {
Jonathan Frederic
Progress...
r17196 var cont = TextCell.prototype.render.apply(this);
Brian E. Granger
More work on the dual mode UX.
r14015 if (cont) {
Brian Granger
Work on the base Cell API....
r5943 var text = this.get_text();
Jessica B. Hamrick
Parse markdown correctly when mathjax is disabled
r11843 var math = null;
Stefan van der Walt
Clean up javascript based on js2-mode feedback.
r5479 if (text === "") { text = this.placeholder; }
Jonathan Frederic
MWE,...
r17200 var text_and_math = mathjaxutils.remove_math(text);
Jessica B. Hamrick
Parse markdown correctly when mathjax is disabled
r11843 text = text_and_math[0];
math = text_and_math[1];
MinRK
use marked for markdown
r10536 var html = marked.parser(marked.lexer(text));
Jonathan Frederic
MWE,...
r17200 html = mathjaxutils.replace_math(html, math);
Jonathan Frederic
Fix all the bugs!
r17203 html = security.sanitize_html(html);
Jonathan Frederic
Fixed mardown rendering bug....
r16821 html = $($.parseHTML(html));
MinRK
always sanitize markdown...
r15637 // links in markdown cells should open in new tabs
html.find("a[href]").not('[href^="#"]').attr("target", "_blank");
this.set_rendered(html);
MinRK
make input_area css generic to cells...
r15552 this.element.find('div.input_area').hide();
Aron Ahmadia
Finalizing fixes to MathJax enhancements...
r8662 this.element.find("div.text_cell_render").show();
MinRK
always sanitize markdown...
r15637 this.typeset();
Jonathan Frederic
Post in person review...
r15497 }
Brian E. Granger
More work on the dual mode UX.
r14015 return cont;
Brian Granger
Refactoring of text/markdown/rst/html cells.
r4508 };
jon
In person review with @ellisonbg
r17210 var RawCell = function (options) {
jon
Added some nice comments,...
r17211 // Constructor
//
// Parameters:
// options: dictionary
// Dictionary of keyword arguments.
// events: $(Events) instance
// config: dictionary
// keyboard_manager: KeyboardManager instance
// notebook: Notebook instance
jon
In person review with @ellisonbg
r17210 options = options || {};
MinRK
move mergeopt to utils...
r17764 var config = utils.mergeopt(RawCell, options.config);
jon
In person review with @ellisonbg
r17210 TextCell.apply(this, [$.extend({}, options, {config: config})]);
Brian E. Granger
Semi working version of basic dual mode UX....
r14016
// RawCell should always hide its rendered div
this.element.find('div.text_cell_render').hide();
jon
In person review with @ellisonbg
r17210 this.cell_type = 'raw';
Brian Granger
Refactoring of text/markdown/rst/html cells.
r4508 };
Matthias BUSSONNIER
JS Configurablity Take 2...
r10165 RawCell.options_default = {
Paul Ivanov
raw cell placeholder text as one line
r15859 placeholder : "Write raw LaTeX or other formats here, for use with nbconvert. " +
"It will not be rendered in the notebook. " +
MinRK
give Raw Cells a placeholder...
r13668 "When passing through nbconvert, a Raw Cell's content is added to the output unmodified."
Matthias BUSSONNIER
JS Configurablity Take 2...
r10165 };
MinRK
rename plaintext cell -> raw cell
r6248 RawCell.prototype = new TextCell();
Brian Granger
Refactoring of text/markdown/rst/html cells.
r4508
Brian E. Granger
More work on the dual mode UX.
r14015 /** @method bind_events **/
RawCell.prototype.bind_events = function () {
TextCell.prototype.bind_events.apply(this);
Jonathan Frederic
Post in person review...
r15497 var that = this;
Brian E. Granger
More work on the dual mode UX.
r14015 this.element.focusout(function() {
that.auto_highlight();
Paul Ivanov
render on focus out, always pad raw cells
r15858 that.render();
Brian E. Granger
More work on the dual mode UX.
r14015 });
Paul Ivanov
remove raw cell placeholder on focus, closes #5238
r15768
this.code_mirror.on('focus', function() { that.unrender(); });
Brian E. Granger
More work on the dual mode UX.
r14015 };
Matthias BUSSONNIER
Document more function....
r8711 /**
* Trigger autodetection of highlight scheme for current cell
* @method auto_highlight
*/
Matthias BUSSONNIER
autochange highlight with cell magics...
r8202 RawCell.prototype.auto_highlight = function () {
Jonathan Frederic
MWE,...
r17200 this._auto_highlight(this.config.raw_cell_highlight);
Matthias BUSSONNIER
autochange highlight with cell magics...
r8202 };
Brian Granger
Refactoring of text/markdown/rst/html cells.
r4508
Matthias BUSSONNIER
Document more function....
r8711 /** @method render **/
MinRK
rename plaintext cell -> raw cell
r6248 RawCell.prototype.render = function () {
Jonathan Frederic
Progress...
r17196 var cont = TextCell.prototype.render.apply(this);
Paul Ivanov
remove raw cell placeholder on focus, closes #5238
r15768 if (cont){
var text = this.get_text();
if (text === "") { text = this.placeholder; }
this.set_text(text);
Paul Ivanov
render on focus out, always pad raw cells
r15858 this.element.removeClass('rendered');
Brian E. Granger
More work on the dual mode UX.
r14015 }
Paul Ivanov
remove raw cell placeholder on focus, closes #5238
r15768 return cont;
Brian Granger
A first go at RST cell support in the notebook.
r6017 };
jon
In person review with @ellisonbg
r17210 var HeadingCell = function (options) {
jon
Added some nice comments,...
r17211 // Constructor
//
// Parameters:
// options: dictionary
// Dictionary of keyword arguments.
// events: $(Events) instance
// config: dictionary
// keyboard_manager: KeyboardManager instance
// notebook: Notebook instance
jon
In person review with @ellisonbg
r17210 options = options || {};
MinRK
move mergeopt to utils...
r17764 var config = utils.mergeopt(HeadingCell, options.config);
jon
In person review with @ellisonbg
r17210 TextCell.apply(this, [$.extend({}, options, {config: config})]);
Matthias BUSSONNIER
JS Configurablity Take 2...
r10165
MinRK
give Raw Cells a placeholder...
r13668 this.level = 1;
this.cell_type = 'heading';
Brian Granger
Adding new HeadingCell.
r6018 };
Matthias BUSSONNIER
JS Configurablity Take 2...
r10165 HeadingCell.options_default = {
Paul Ivanov
proportional font-size when editing heading cells...
r17467 cm_config: {
theme: 'heading-1'
},
Matthias BUSSONNIER
JS Configurablity Take 2...
r10165 placeholder: "Type Heading Here"
};
Brian Granger
Adding new HeadingCell.
r6018
HeadingCell.prototype = new TextCell();
Matthias BUSSONNIER
Document more function....
r8711 /** @method fromJSON */
MinRK
include heading level in JSON...
r6156 HeadingCell.prototype.fromJSON = function (data) {
Jonathan Frederic
Post in person review...
r15497 if (data.level !== undefined){
MinRK
include heading level in JSON...
r6156 this.level = data.level;
}
Matthias BUSSONNIER
JS Configurablity Take 2...
r10165 TextCell.prototype.fromJSON.apply(this, arguments);
Paul Ivanov
appropriate heading level when loading from JSON
r17475 this.code_mirror.setOption("theme", "heading-"+this.level);
MinRK
include heading level in JSON...
r6156 };
Matthias BUSSONNIER
Document more function....
r8711 /** @method toJSON */
MinRK
include heading level in JSON...
r6156 HeadingCell.prototype.toJSON = function () {
Matthias BUSSONNIER
JS Configurablity Take 2...
r10165 var data = TextCell.prototype.toJSON.apply(this);
MinRK
include heading level in JSON...
r6156 data.level = this.get_level();
return data;
};
MinRK
HeadingCells are not splittable or mergeable...
r12510 /**
Matthias BUSSONNIER
Document more function....
r8711 * Change heading level of cell, and re-render
* @method set_level
*/
Brian Granger
Finishing first draft of RST and heading cells.
r6019 HeadingCell.prototype.set_level = function (level) {
this.level = level;
Paul Ivanov
proportional font-size when editing heading cells...
r17467 this.code_mirror.setOption("theme", "heading-"+level);
Brian Granger
Finishing first draft of RST and heading cells.
r6019 if (this.rendered) {
this.rendered = false;
this.render();
Jonathan Frederic
Post in person review...
r15497 }
Brian Granger
Finishing first draft of RST and heading cells.
r6019 };
Matthias BUSSONNIER
start to document js
r8709 /** The depth of header cell, based on html (h1 to h6)
Matthias BUSSONNIER
Document more function....
r8711 * @method get_level
Matthias BUSSONNIER
start to document js
r8709 * @return {integer} level - for 1 to 6
*/
Brian Granger
Finishing first draft of RST and heading cells.
r6019 HeadingCell.prototype.get_level = function () {
return this.level;
};
Brian Granger
Adding new HeadingCell.
r6018 HeadingCell.prototype.get_rendered = function () {
var r = this.element.find("div.text_cell_render");
return r.children().first().html();
Brian Granger
Finishing first draft of RST and heading cells.
r6019 };
Brian Granger
Adding new HeadingCell.
r6018
HeadingCell.prototype.render = function () {
Jonathan Frederic
Progress...
r17196 var cont = TextCell.prototype.render.apply(this);
Brian E. Granger
More work on the dual mode UX.
r14015 if (cont) {
Brian Granger
Adding new HeadingCell.
r6018 var text = this.get_text();
Jessica B. Hamrick
Parse markdown correctly when mathjax is disabled
r11843 var math = null;
MinRK
merge heading lines...
r11290 // Markdown headings must be a single line
text = text.replace(/\n/g, ' ');
Brian Granger
Adding new HeadingCell.
r6018 if (text === "") { text = this.placeholder; }
Jonathan Frederic
Progress...
r17196 text = new Array(this.level + 1).join("#") + " " + text;
Jonathan Frederic
MWE,...
r17200 var text_and_math = mathjaxutils.remove_math(text);
Jessica B. Hamrick
Parse markdown correctly when mathjax is disabled
r11843 text = text_and_math[0];
math = text_and_math[1];
MinRK
Markdown in heading cells (take 2)...
r11288 var html = marked.parser(marked.lexer(text));
Jonathan Frederic
MWE,...
r17200 html = mathjaxutils.replace_math(html, math);
Jonathan Frederic
Fix all the bugs!
r17203 html = security.sanitize_html(html);
Jonathan Frederic
Fixed mardown rendering bug....
r16821 var h = $($.parseHTML(html));
MinRK
always sanitize markdown...
r15637 // add id and linkback anchor
var hash = h.text().replace(/ /g, '-');
h.attr('id', hash);
h.append(
$('<a/>')
.addClass('anchor-link')
.attr('href', '#' + hash)
.text('ΒΆ')
);
this.set_rendered(h);
MinRK
fix a typo introduced by a rebased PR...
r15698 this.element.find('div.input_area').hide();
Brian Granger
Adding new HeadingCell.
r6018 this.element.find("div.text_cell_render").show();
MinRK
always sanitize markdown...
r15637 this.typeset();
}
Brian E. Granger
More work on the dual mode UX.
r14015 return cont;
Brian Granger
Adding new HeadingCell.
r6018 };
Jonathan Frederic
Progress...
r17196 // Backwards compatability.
Brian Granger
Refactoring of text/markdown/rst/html cells.
r4508 IPython.TextCell = TextCell;
IPython.MarkdownCell = MarkdownCell;
MinRK
rename plaintext cell -> raw cell
r6248 IPython.RawCell = RawCell;
Brian Granger
Finishing first draft of RST and heading cells.
r6019 IPython.HeadingCell = HeadingCell;
Brian Granger
Refactoring of text/markdown/rst/html cells.
r4508
Jonathan Frederic
More review changes
r17214 var textcell = {
Jonathan Frederic
Progress...
r17196 'TextCell': TextCell,
'MarkdownCell': MarkdownCell,
'RawCell': RawCell,
'HeadingCell': HeadingCell,
};
Jonathan Frederic
More review changes
r17214 return textcell;
Jonathan Frederic
Progress...
r17196 });