Show More
@@ -27,7 +27,7 b' var IPython = (function (IPython) {' | |||||
27 | * |
|
27 | * | |
28 | * @class TextCell |
|
28 | * @class TextCell | |
29 | * @constructor TextCell |
|
29 | * @constructor TextCell | |
30 |
* @extend I |
|
30 | * @extend IPython.Cell | |
31 | * @param {object|undefined} [options] |
|
31 | * @param {object|undefined} [options] | |
32 | * @param [options.cm_config] {object} config to pass to CodeMirror, will extend/overwrite default config |
|
32 | * @param [options.cm_config] {object} config to pass to CodeMirror, will extend/overwrite default config | |
33 | * @param [options.placeholder] {string} default string to use when souce in empty for rendering (only use in some TextCell subclass) |
|
33 | * @param [options.placeholder] {string} default string to use when souce in empty for rendering (only use in some TextCell subclass) | |
@@ -285,7 +285,7 b' var IPython = (function (IPython) {' | |||||
285 | /** |
|
285 | /** | |
286 | * @class MarkdownCell |
|
286 | * @class MarkdownCell | |
287 | * @constructor MarkdownCell |
|
287 | * @constructor MarkdownCell | |
288 |
* @extends I |
|
288 | * @extends IPython.HTMLCell | |
289 | */ |
|
289 | */ | |
290 | var MarkdownCell = function (options) { |
|
290 | var MarkdownCell = function (options) { | |
291 | var options = options || {}; |
|
291 | var options = options || {}; | |
@@ -342,7 +342,7 b' var IPython = (function (IPython) {' | |||||
342 | /** |
|
342 | /** | |
343 | * @class RawCell |
|
343 | * @class RawCell | |
344 | * @constructor RawCell |
|
344 | * @constructor RawCell | |
345 |
* @extends I |
|
345 | * @extends IPython.TextCell | |
346 | */ |
|
346 | */ | |
347 | var RawCell = function (options) { |
|
347 | var RawCell = function (options) { | |
348 |
|
348 | |||
@@ -437,12 +437,12 b' var IPython = (function (IPython) {' | |||||
437 |
|
437 | |||
438 | /** |
|
438 | /** | |
439 | * @class HeadingCell |
|
439 | * @class HeadingCell | |
440 |
* @extends I |
|
440 | * @extends IPython.TextCell | |
441 | */ |
|
441 | */ | |
442 |
|
442 | |||
443 | /** |
|
443 | /** | |
444 | * @constructor HeadingCell |
|
444 | * @constructor HeadingCell | |
445 |
* @extends I |
|
445 | * @extends IPython.TextCell | |
446 | */ |
|
446 | */ | |
447 | var HeadingCell = function (options) { |
|
447 | var HeadingCell = function (options) { | |
448 |
|
448 | |||
@@ -501,24 +501,8 b' var IPython = (function (IPython) {' | |||||
501 | }; |
|
501 | }; | |
502 |
|
502 | |||
503 |
|
503 | |||
504 |
HeadingCell.prototype.set_rendered = function ( |
|
504 | HeadingCell.prototype.set_rendered = function (html) { | |
505 |
|
|
505 | this.element.find("div.text_cell_render").html(html); | |
506 | r.empty(); |
|
|||
507 | var link = text.replace(/ /g, '_'); |
|
|||
508 | r.append( |
|
|||
509 | $('<h'+this.level+'/>') |
|
|||
510 | .append( |
|
|||
511 | $('<a/>') |
|
|||
512 | .addClass('heading-anchor') |
|
|||
513 | .attr('id', link) |
|
|||
514 | .html(text) |
|
|||
515 | ).append( |
|
|||
516 | $('<a/>') |
|
|||
517 | .addClass('anchor-link') |
|
|||
518 | .attr('href', '#' + link) |
|
|||
519 | .text('¶') |
|
|||
520 | ) |
|
|||
521 | ); |
|
|||
522 | }; |
|
506 | }; | |
523 |
|
507 | |||
524 |
|
508 | |||
@@ -532,7 +516,28 b' var IPython = (function (IPython) {' | |||||
532 | if (this.rendered === false) { |
|
516 | if (this.rendered === false) { | |
533 | var text = this.get_text(); |
|
517 | var text = this.get_text(); | |
534 | if (text === "") { text = this.placeholder; } |
|
518 | if (text === "") { text = this.placeholder; } | |
535 | this.set_rendered(text); |
|
519 | text = Array(this.level + 1).join("#") + " " + text; | |
|
520 | text = IPython.mathjaxutils.remove_math(text); | |||
|
521 | var html = marked.parser(marked.lexer(text)); | |||
|
522 | var h = $(IPython.mathjaxutils.replace_math(html)); | |||
|
523 | // move the markdown-rendered html down one level, | |||
|
524 | // into an anchor tag for linking | |||
|
525 | html = h.html(); | |||
|
526 | var hash = h.text().replace(/ /g, '_'); | |||
|
527 | h.empty(); | |||
|
528 | var a = $('<a/>') | |||
|
529 | .addClass('heading-anchor') | |||
|
530 | .html(html) | |||
|
531 | .attr('id', hash); | |||
|
532 | // and append two anchors (one with the text, one clickable) | |||
|
533 | h.append(a).append( | |||
|
534 | $('<a/>') | |||
|
535 | .addClass('anchor-link') | |||
|
536 | .attr('href', '#' + hash) | |||
|
537 | .text('¶') | |||
|
538 | ); | |||
|
539 | ||||
|
540 | this.set_rendered(h); | |||
536 | this.typeset(); |
|
541 | this.typeset(); | |
537 | this.element.find('div.text_cell_input').hide(); |
|
542 | this.element.find('div.text_cell_input').hide(); | |
538 | this.element.find("div.text_cell_render").show(); |
|
543 | this.element.find("div.text_cell_render").show(); |
General Comments 0
You need to be logged in to leave comments.
Login now