##// END OF EJS Templates
Merge pull request #717 from stefanv/htmlnotebook_highlight_markdown...
Merge pull request #717 from stefanv/htmlnotebook_highlight_markdown Add source highlighting to markdown snippets, with a theme matching the CodeMirror one we use. This only highlights source code in blocks that are indented 4 spaces in markdown cells, leaving <pre> blocks alone. If highlight is desired in <pre> blocks, a further <code> block must be created. The visual theme matches the one used for CodeMirror as much as possible.

File last commit:

r4625:898a609a
r4658:9460984a merge
Show More
printwidget.js
54 lines | 1.6 KiB | application/javascript | JavascriptLexer
var IPython = (function (IPython) {
var PrintWidget = function (selector) {
this.selector = selector;
if (this.selector !== undefined) {
this.element = $(selector);
this.style();
this.bind_events();
}
};
PrintWidget.prototype.style = function () {
this.element.find('button#print_notebook').button();
};
PrintWidget.prototype.bind_events = function () {
var that = this;
this.element.find('button#print_notebook').click(function () {
that.print_notebook();
});
};
PrintWidget.prototype.enable = function () {
this.element.find('button#print_notebook').button('enable');
};
PrintWidget.prototype.disable = function () {
this.element.find('button#print_notebook').button('disable');
};
PrintWidget.prototype.print_notebook = function () {
var w = window.open('', '_blank', 'scrollbars=1,menubar=1');
var html = '<html><head>' +
$('head').clone().html() +
'<style type="text/css">' +
'@media print { body { overflow: visible !important; } }' +
'.ui-widget-content { border: 0px; }' +
'</style>' +
'</head><body style="overflow: auto;">' +
$('#notebook').clone().html() +
'</body></html>';
w.document.open();
w.document.write(html);
w.document.close();
return false;
};
IPython.PrintWidget = PrintWidget;
return IPython;
}(IPython));