Adding tracebacks, evalue and etype to the nbformat and notebook.

Brian E. Granger 15 years ago
parent 0c3bba9641
commit c72b41883f

@ -166,20 +166,6 @@ class NotebookHandler(web.RequestHandler):
# RST web service handlers
#-----------------------------------------------------------------------------
_rst_header = """========
Heading1
========
Heading2
========
Heading3
--------
Heading4
^^^^^^^^
"""
class RSTHandler(web.RequestHandler):
@ -187,15 +173,14 @@ class RSTHandler(web.RequestHandler):
if publish_string is None:
raise web.HTTPError(503)
body = self.request.body.strip()
source = _rst_header + body
template_path=os.path.join(os.path.dirname(__file__), u'templates', u'rst_template.html')
source = body
# template_path=os.path.join(os.path.dirname(__file__), u'templates', u'rst_template.html')
print template_path
defaults = {'file_insertion_enabled': 0,
'raw_enabled': 0,
'_disable_config': 1,
'stylesheet_path': 0,
'initial_header_level': 3,
'template': template_path
# 'template': template_path
}
try:
html = publish_string(source, writer_name='html',
@ -204,8 +189,6 @@ class RSTHandler(web.RequestHandler):
except:
raise web.HTTPError(400)
print html
# html = '\n'.join(html.split('\n')[7:-3])
# print html
self.set_header('Content-Type', 'text/html')
self.finish(html)

@ -204,7 +204,7 @@ var IPython = (function (IPython) {
CodeCell.prototype.append_pyerr = function (json) {
var tb = json.traceback;
if (tb !== undefined) {
if (tb !== undefined && tb.length > 0) {
var s = '';
var len = tb.length;
for (var i=0; i<len; i++) {
@ -262,7 +262,7 @@ var IPython = (function (IPython) {
CodeCell.prototype.append_text = function (data, element) {
element = element || this.element.find("div.output");
var toinsert = $("<div/>").addClass("output_stream");
toinsert.append($("<pre/>").html(utils.fixConsole(data)));
toinsert.append($("<pre/>").html(data));
element.append(toinsert);
return element;
};

@ -520,7 +520,7 @@ var IPython = (function (IPython) {
var json = {};
json.output_type = msg_type;
if (msg_type === "stream") {
json.text = content.data + '\n';
json.text = utils.fixConsole(content.data + '\n');
} else if (msg_type === "display_data") {
json = this.convert_mime_types(json, content.data);
} else if (msg_type === "pyout") {
@ -529,7 +529,11 @@ var IPython = (function (IPython) {
} else if (msg_type === "pyerr") {
json.ename = content.ename;
json.evalue = content.evalue;
json.traceback = content.traceback;
var traceback = [];
for (var i=0; i<content.traceback.length; i++) {
traceback.push(utils.fixConsole(content.traceback[i]));
}
json.traceback = traceback;
};
cell.append_output(json);
};
@ -537,7 +541,7 @@ var IPython = (function (IPython) {
Notebook.prototype.convert_mime_types = function (json, data) {
if (data['text/plain'] !== undefined) {
json.text = data['text/plain'];
json.text = utils.fixConsole(data['text/plain']);
};
if (data['text/html'] !== undefined) {
json.html = data['text/html'];
@ -688,7 +692,6 @@ var IPython = (function (IPython) {
Notebook.prototype.notebook_saved = function (data, status, xhr) {
setTimeout($.proxy(IPython.save_widget.status_save,IPython.save_widget),500);
// IPython.save_widget.status_save();
}

Loading…
Cancel
Save