Merge pull request #5648 from andrewjesaitis/ticket4756

Adds markdown formatting to output cells
Min RK 12 years ago
commit 86cd81014f

@ -248,6 +248,7 @@ var IPython = (function (IPython) {
OutputArea.output_types = [
'application/javascript',
'text/html',
'text/markdown',
'text/latex',
'image/svg+xml',
'image/png',
@ -417,7 +418,9 @@ var IPython = (function (IPython) {
}
this._safe_append(toinsert);
// If we just output latex, typeset it.
if ((json['text/latex'] !== undefined) || (json['text/html'] !== undefined)) {
if ((json['text/latex'] !== undefined) ||
(json['text/html'] !== undefined) ||
(json['text/markdown'] !== undefined)) {
this.typeset();
}
};
@ -488,7 +491,9 @@ var IPython = (function (IPython) {
if (this.append_mime_type(json, toinsert, handle_inserted)) {
this._safe_append(toinsert);
// If we just output latex, typeset it.
if ((json['text/latex'] !== undefined) || (json['text/html'] !== undefined)) {
if ((json['text/latex'] !== undefined) ||
(json['text/html'] !== undefined) ||
(json['text/markdown'] !== undefined)) {
this.typeset();
}
}
@ -545,6 +550,20 @@ var IPython = (function (IPython) {
};
var append_markdown = function(markdown, md, element) {
var type = 'text/markdown';
var toinsert = this.create_output_subarea(md, "output_markdown", type);
var text_and_math = IPython.mathjaxutils.remove_math(markdown);
var text = text_and_math[0];
var math = text_and_math[1];
var html = marked.parser(marked.lexer(text));
html = IPython.mathjaxutils.replace_math(html, math);
toinsert.append(html);
element.append(toinsert);
return toinsert;
};
var append_javascript = function (js, md, element) {
// We just eval the JS code, element appears in the local scope.
var type = 'application/javascript';
@ -916,6 +935,7 @@ var IPython = (function (IPython) {
OutputArea.display_order = [
'application/javascript',
'text/html',
'text/markdown',
'text/latex',
'image/svg+xml',
'image/png',
@ -927,6 +947,7 @@ var IPython = (function (IPython) {
OutputArea.append_map = {
"text/plain" : append_text,
"text/html" : append_html,
"text/markdown": append_markdown,
"image/svg+xml" : append_svg,
"image/png" : append_png,
"image/jpeg" : append_jpeg,

Loading…
Cancel
Save