##// END OF EJS Templates
Merge pull request #4306 from minrk/raw-cell-metadata...
Matthias Bussonnier -
r13794:8c373843 merge
parent child Browse files
Show More
@@ -0,0 +1,90 b''
1 //----------------------------------------------------------------------------
2 // Copyright (C) 2012 The IPython Development Team
3 //
4 // Distributed under the terms of the BSD License. The full license is in
5 // the file COPYING, distributed as part of this software.
6 //----------------------------------------------------------------------------
7
8 //============================================================================
9 // CellToolbar Example
10 //============================================================================
11
12 (function(IPython) {
13 "use strict";
14
15 var CellToolbar = IPython.CellToolbar;
16 var raw_cell_preset = [];
17 var utils = IPython.utils;
18
19 var select_type = CellToolbar.utils.select_ui_generator([
20 ["None", "-"],
21 ["LaTeX", "text/latex"],
22 ["reST", "text/restructuredtext"],
23 ["HTML", "text/html"],
24 ["Markdown", "text/markdown"],
25 ["Python", "application/x-python"],
26 ["Custom", "dialog"],
27
28 ],
29 // setter
30 function(cell, value) {
31 if (value === "-") {
32 delete cell.metadata.raw_mimetype;
33 } else if (value === 'dialog'){
34 var dialog = $('<div/>').append(
35 $("<p/>")
36 .html("Set the MIME type of the raw cell:")
37 ).append(
38 $("<br/>")
39 ).append(
40 $('<input/>').attr('type','text').attr('size','25')
41 .val(cell.metadata.raw_mimetype || "-")
42 );
43 IPython.dialog.modal({
44 title: "Raw Cell MIME Type",
45 body: dialog,
46 buttons : {
47 "Cancel": {},
48 "OK": {
49 class: "btn-primary",
50 click: function () {
51 console.log(cell);
52 cell.metadata.raw_mimetype = $(this).find('input').val();
53 console.log(cell.metadata);
54 }
55 }
56 },
57 open : function (event, ui) {
58 var that = $(this);
59 // Upon ENTER, click the OK button.
60 that.find('input[type="text"]').keydown(function (event, ui) {
61 if (event.which === utils.keycodes.ENTER) {
62 that.find('.btn-primary').first().click();
63 return false;
64 }
65 });
66 that.find('input[type="text"]').focus().select();
67 }
68 });
69 } else {
70 cell.metadata.raw_mimetype = value;
71 }
72 },
73 //getter
74 function(cell) {
75 return cell.metadata.raw_mimetype || "";
76 },
77 // name
78 "Raw NBConvert Format",
79 // cell_types
80 ["raw"]
81 );
82
83 CellToolbar.register_callback('raw_cell.select', select_type);
84
85 raw_cell_preset.push('raw_cell.select');
86
87 CellToolbar.register_preset('Raw Cell Format', raw_cell_preset);
88 console.log('Raw Cell Format toolbar preset loaded.');
89
90 }(IPython)); No newline at end of file
@@ -0,0 +1,84 b''
1 {
2 "metadata": {
3 "name": ""
4 },
5 "nbformat": 3,
6 "nbformat_minor": 0,
7 "worksheets": [
8 {
9 "cells": [
10 {
11 "cell_type": "raw",
12 "metadata": {
13 "raw_mimetype": "text/html"
14 },
15 "source": [
16 "<b>raw html</b>"
17 ]
18 },
19 {
20 "cell_type": "raw",
21 "metadata": {
22 "raw_mimetype": "text/markdown"
23 },
24 "source": [
25 "* raw markdown\n",
26 "* bullet\n",
27 "* list"
28 ]
29 },
30 {
31 "cell_type": "raw",
32 "metadata": {
33 "raw_mimetype": "text/restructuredtext"
34 },
35 "source": [
36 "``raw rst``\n",
37 "\n",
38 ".. sourcecode:: python\n",
39 "\n",
40 " def foo(): pass\n"
41 ]
42 },
43 {
44 "cell_type": "raw",
45 "metadata": {
46 "raw_mimetype": "application/x-python"
47 },
48 "source": [
49 "def bar():\n",
50 " \"\"\"raw python\"\"\"\n",
51 " pass"
52 ]
53 },
54 {
55 "cell_type": "raw",
56 "metadata": {
57 "raw_mimetype": "text/latex"
58 },
59 "source": [
60 "\\LaTeX\n",
61 "% raw latex"
62 ]
63 },
64 {
65 "cell_type": "raw",
66 "metadata": {},
67 "source": [
68 "# no raw_mimetype metadata, should be included by default"
69 ]
70 },
71 {
72 "cell_type": "raw",
73 "metadata": {
74 "raw_mimetype": "doesnotexist"
75 },
76 "source": [
77 "garbage format defined, should never be included"
78 ]
79 }
80 ],
81 "metadata": {}
82 }
83 ]
84 } No newline at end of file
@@ -33,9 +33,9 b' var IPython = (function (IPython) {'
33 */
33 */
34 var Cell = function (options) {
34 var Cell = function (options) {
35
35
36 options = this.mergeopt(Cell, options)
36 options = this.mergeopt(Cell, options);
37 // superclass default overwrite our default
37 // superclass default overwrite our default
38
38
39 this.placeholder = options.placeholder || '';
39 this.placeholder = options.placeholder || '';
40 this.read_only = options.cm_config.readOnly;
40 this.read_only = options.cm_config.readOnly;
41 this.selected = false;
41 this.selected = false;
@@ -52,7 +52,7 b' var IPython = (function (IPython) {'
52 // same order. Easiest is to create and set to null in parent class.
52 // same order. Easiest is to create and set to null in parent class.
53
53
54 this.element = null;
54 this.element = null;
55 this.cell_type = null;
55 this.cell_type = this.cell_type || null;
56 this.code_mirror = null;
56 this.code_mirror = null;
57
57
58
58
@@ -80,6 +80,7 b' var IPython = (function (IPython) {'
80 }
80 }
81
81
82 Cell.prototype.mergeopt = function(_class, options, overwrite){
82 Cell.prototype.mergeopt = function(_class, options, overwrite){
83 options = options || {};
83 overwrite = overwrite || {};
84 overwrite = overwrite || {};
84 return $.extend(true, {}, _class.options_default, options, overwrite)
85 return $.extend(true, {}, _class.options_default, options, overwrite)
85
86
@@ -200,6 +201,7 b' var IPython = (function (IPython) {'
200 Cell.prototype.toJSON = function () {
201 Cell.prototype.toJSON = function () {
201 var data = {};
202 var data = {};
202 data.metadata = this.metadata;
203 data.metadata = this.metadata;
204 data.cell_type = this.cell_type;
203 return data;
205 return data;
204 };
206 };
205
207
@@ -37,37 +37,39 b' var IPython = (function (IPython) {'
37 this.inner_element = $('<div/>').addClass('celltoolbar')
37 this.inner_element = $('<div/>').addClass('celltoolbar')
38 this.element = $('<div/>').addClass('ctb_hideshow')
38 this.element = $('<div/>').addClass('ctb_hideshow')
39 .append(this.inner_element);
39 .append(this.inner_element);
40 this.show();
40 };
41 };
41
42
42
43
43 // The default css style for the outer celltoolbar div
44 // The default css style for the outer celltoolbar div
44 // (ctb_hideshow) is display: none. We add the ctb_show
45 // (ctb_hideshow) is display: none.
45 // class to either 1) the body to show all cell's toolbars
46 // To show the cell toolbar, *both* of the following conditions must be met:
46 // or 2) to the individual celltoolbar divs to show just one
47 // - A parent container has class `ctb_global_show`
47 // cell's toolbar.
48 // - The celltoolbar has the class `ctb_show`
49 // This allows global show/hide, as well as per-cell show/hide.
48
50
49 CellToolbar.global_hide = function () {
51 CellToolbar.global_hide = function () {
50 $('body').removeClass('ctb_show');
52 $('body').removeClass('ctb_global_show');
51 }
53 };
52
54
53
55
54 CellToolbar.global_show = function () {
56 CellToolbar.global_show = function () {
55 $('body').addClass('ctb_show');
57 $('body').addClass('ctb_global_show');
56 }
58 };
57
59
58
60
59 CellToolbar.prototype.hide = function () {
61 CellToolbar.prototype.hide = function () {
60 this.element.removeClass('ctb_show');
62 this.element.removeClass('ctb_show');
61 }
63 };
62
64
63
65
64 CellToolbar.prototype.show = function () {
66 CellToolbar.prototype.show = function () {
65 this.element.addClass('ctb_show');
67 this.element.addClass('ctb_show');
66 }
68 };
67
69
68
70
69 /**
71 /**
70 * Class variable that should contain a dict of all availlable callback
72 * Class variable that should contain a dict of all available callback
71 * we need to think of wether or not we allow nested namespace
73 * we need to think of wether or not we allow nested namespace
72 * @property _callback_dict
74 * @property _callback_dict
73 * @private
75 * @private
@@ -89,7 +91,7 b' var IPython = (function (IPython) {'
89
91
90
92
91 /**
93 /**
92 * Class variable that should contains the CellToolbar instances for each
94 * Class variable that should contain the CellToolbar instances for each
93 * cell of the notebook
95 * cell of the notebook
94 *
96 *
95 * @private
97 * @private
@@ -97,17 +99,17 b' var IPython = (function (IPython) {'
97 * @static
99 * @static
98 * @type List
100 * @type List
99 */
101 */
100 CellToolbar._instances =[]
102 CellToolbar._instances = [];
101
103
102
104
103 /**
105 /**
104 * keep a list of all the availlabel presets for the toolbar
106 * keep a list of all the available presets for the toolbar
105 * @private
107 * @private
106 * @property _presets
108 * @property _presets
107 * @static
109 * @static
108 * @type Dict
110 * @type Dict
109 */
111 */
110 CellToolbar._presets ={}
112 CellToolbar._presets = {};
111
113
112
114
113 // this is by design not a prototype.
115 // this is by design not a prototype.
@@ -180,7 +182,7 b' var IPython = (function (IPython) {'
180 * CellToolbar.register_preset('foo.foo_preset2', ['foo.c4', 'foo.c5'])
182 * CellToolbar.register_preset('foo.foo_preset2', ['foo.c4', 'foo.c5'])
181 */
183 */
182 CellToolbar.register_preset = function(name, preset_list) {
184 CellToolbar.register_preset = function(name, preset_list) {
183 CellToolbar._presets[name] = preset_list
185 CellToolbar._presets[name] = preset_list;
184 $([IPython.events]).trigger('preset_added.CellToolbar', {name: name});
186 $([IPython.events]).trigger('preset_added.CellToolbar', {name: name});
185 };
187 };
186
188
@@ -217,11 +219,11 b' var IPython = (function (IPython) {'
217 CellToolbar.activate_preset = function(preset_name){
219 CellToolbar.activate_preset = function(preset_name){
218 var preset = CellToolbar._presets[preset_name];
220 var preset = CellToolbar._presets[preset_name];
219
221
220 if(preset != undefined){
222 if(preset !== undefined){
221 CellToolbar._ui_controls_list = preset;
223 CellToolbar._ui_controls_list = preset;
222 CellToolbar.rebuild_all();
224 CellToolbar.rebuild_all();
223 }
225 }
224 }
226 };
225
227
226
228
227 /**
229 /**
@@ -235,29 +237,37 b' var IPython = (function (IPython) {'
235 for(var i in CellToolbar._instances){
237 for(var i in CellToolbar._instances){
236 CellToolbar._instances[i].rebuild();
238 CellToolbar._instances[i].rebuild();
237 }
239 }
238 }
240 };
239
241
240 /**
242 /**
241 * Rebuild all the button on the toolbar to update it's state.
243 * Rebuild all the button on the toolbar to update its state.
242 * @method rebuild
244 * @method rebuild
243 */
245 */
244 CellToolbar.prototype.rebuild = function(){
246 CellToolbar.prototype.rebuild = function(){
245 // strip evrything from the div
247 // strip evrything from the div
246 // which is probabli metainner.
248 // which is probably inner_element
247 // or this.element.
249 // or this.element.
248 this.inner_element.empty();
250 this.inner_element.empty();
249
251
250 var cdict = CellToolbar._callback_dict;
252 var callbacks = CellToolbar._callback_dict;
251 var preset = CellToolbar._ui_controls_list;
253 var preset = CellToolbar._ui_controls_list;
252 // Yes we iterate on the class varaible, not the instance one.
254 // Yes we iterate on the class variable, not the instance one.
253 for ( var index in CellToolbar._ui_controls_list){
255 for (var index in preset) {
256 var key = preset[index];
257 var callback = callbacks[key];
258 if (!callback) continue;
259
254 var local_div = $('<div/>').addClass('button_container');
260 var local_div = $('<div/>').addClass('button_container');
255 // Note,
261 try {
256 // do this the other way, wrap in try/catch and don't append if any errors.
262 callback(local_div, this.cell, this);
257 this.inner_element.append(local_div)
263 } catch (e) {
258 cdict[preset[index]](local_div, this.cell)
264 console.log("Error in cell toolbar callback " + key, e);
265 continue;
266 }
267 // only append if callback succeeded.
268 this.inner_element.append(local_div);
259 }
269 }
260 }
270 };
261
271
262
272
263 /**
273 /**
@@ -303,8 +313,8 b' var IPython = (function (IPython) {'
303 *
313 *
304 */
314 */
305 CellToolbar.utils.checkbox_ui_generator = function(name, setter, getter){
315 CellToolbar.utils.checkbox_ui_generator = function(name, setter, getter){
306 return function(div, cell) {
316 return function(div, cell, celltoolbar) {
307 var button_container = $(div)
317 var button_container = $(div);
308
318
309 var chkb = $('<input/>').attr('type', 'checkbox');
319 var chkb = $('<input/>').attr('type', 'checkbox');
310 var lbl = $('<label/>').append($('<span/>').text(name));
320 var lbl = $('<label/>').append($('<span/>').text(name));
@@ -315,11 +325,10 b' var IPython = (function (IPython) {'
315 var v = getter(cell);
325 var v = getter(cell);
316 setter(cell, !v);
326 setter(cell, !v);
317 chkb.attr("checked", !v);
327 chkb.attr("checked", !v);
318 })
328 });
319 button_container.append($('<div/>').append(lbl));
329 button_container.append($('<div/>').append(lbl));
320
330 };
321 }
331 };
322 }
323
332
324
333
325 /**
334 /**
@@ -365,16 +374,16 b' var IPython = (function (IPython) {'
365 * CellToolbar.register_callback('slideshow.select', select_type);
374 * CellToolbar.register_callback('slideshow.select', select_type);
366 *
375 *
367 */
376 */
368 CellToolbar.utils.select_ui_generator = function(list_list, setter, getter, label){
377 CellToolbar.utils.select_ui_generator = function(list_list, setter, getter, label, cell_types){
369 label= label? label: "";
378 label = label || "";
370 return function(div, cell) {
379 return function(div, cell, celltoolbar) {
371 var button_container = $(div)
380 var button_container = $(div);
372 var lbl = $("<label/>").append($('<span/>').text(label));
381 var lbl = $("<label/>").append($('<span/>').text(label));
373 var select = $('<select/>').addClass('ui-widget ui-widget-content');
382 var select = $('<select/>').addClass('ui-widget ui-widget-content');
374 for(var itemn in list_list){
383 for(var itemn in list_list){
375 var opt = $('<option/>');
384 var opt = $('<option/>')
376 opt.attr('value', list_list[itemn][1])
385 .attr('value', list_list[itemn][1])
377 opt.text(list_list[itemn][0])
386 .text(list_list[itemn][0]);
378 select.append(opt);
387 select.append(opt);
379 }
388 }
380 select.val(getter(cell));
389 select.val(getter(cell));
@@ -382,8 +391,13 b' var IPython = (function (IPython) {'
382 setter(cell, select.val());
391 setter(cell, select.val());
383 });
392 });
384 button_container.append($('<div/>').append(lbl).append(select));
393 button_container.append($('<div/>').append(lbl).append(select));
394 if (cell_types && cell_types.indexOf(cell.cell_type) == -1) {
395 celltoolbar.hide();
396 } else {
397 celltoolbar.show();
398 }
385
399
386 }
400 };
387 };
401 };
388
402
389
403
@@ -28,7 +28,7 b''
28 var button_container = div;
28 var button_container = div;
29 var button = $('<button/>')
29 var button = $('<button/>')
30 .addClass("btn btn-mini")
30 .addClass("btn btn-mini")
31 .text("Raw Edit")
31 .text("Edit Metadata")
32 .click( function () {
32 .click( function () {
33 raw_edit(cell);
33 raw_edit(cell);
34 return false;
34 return false;
@@ -40,7 +40,7 b''
40 var example_preset = [];
40 var example_preset = [];
41 example_preset.push('default.rawedit');
41 example_preset.push('default.rawedit');
42
42
43 CellToolbar.register_preset('Default', example_preset);
43 CellToolbar.register_preset('Edit Metadata', example_preset);
44 console.log('Default extension for metadata editing loaded.');
44 console.log('Default extension for cell metadata editing loaded.');
45
45
46 }(IPython));
46 }(IPython));
@@ -445,7 +445,6 b' var IPython = (function (IPython) {'
445 CodeCell.prototype.toJSON = function () {
445 CodeCell.prototype.toJSON = function () {
446 var data = IPython.Cell.prototype.toJSON.apply(this);
446 var data = IPython.Cell.prototype.toJSON.apply(this);
447 data.input = this.get_text();
447 data.input = this.get_text();
448 data.cell_type = 'code';
449 // is finite protect against undefined and '*' value
448 // is finite protect against undefined and '*' value
450 if (isFinite(this.input_prompt_number)) {
449 if (isFinite(this.input_prompt_number)) {
451 data.prompt_number = this.input_prompt_number;
450 data.prompt_number = this.input_prompt_number;
@@ -119,7 +119,7 b' var IPython = (function (IPython) {'
119 // .addClass('ui-widget-content')
119 // .addClass('ui-widget-content')
120 .append($('<option/>').attr('value','code').text('Code'))
120 .append($('<option/>').attr('value','code').text('Code'))
121 .append($('<option/>').attr('value','markdown').text('Markdown'))
121 .append($('<option/>').attr('value','markdown').text('Markdown'))
122 .append($('<option/>').attr('value','raw').text('Raw Text'))
122 .append($('<option/>').attr('value','raw').text('Raw NBConvert'))
123 .append($('<option/>').attr('value','heading1').text('Heading 1'))
123 .append($('<option/>').attr('value','heading1').text('Heading 1'))
124 .append($('<option/>').attr('value','heading2').text('Heading 2'))
124 .append($('<option/>').attr('value','heading2').text('Heading 2'))
125 .append($('<option/>').attr('value','heading3').text('Heading 3'))
125 .append($('<option/>').attr('value','heading3').text('Heading 3'))
@@ -46,11 +46,11 b' var IPython = (function (IPython) {'
46
46
47 options = this.mergeopt(TextCell,options,{cm_config:cm_overwrite_options});
47 options = this.mergeopt(TextCell,options,{cm_config:cm_overwrite_options});
48
48
49 IPython.Cell.apply(this, [options]);
49 this.cell_type = this.cell_type || 'text';
50
50
51 IPython.Cell.apply(this, [options]);
51
52
52 this.rendered = false;
53 this.rendered = false;
53 this.cell_type = this.cell_type || 'text';
54 };
54 };
55
55
56 TextCell.prototype = new IPython.Cell();
56 TextCell.prototype = new IPython.Cell();
@@ -279,8 +279,10 b' var IPython = (function (IPython) {'
279 */
279 */
280 TextCell.prototype.toJSON = function () {
280 TextCell.prototype.toJSON = function () {
281 var data = IPython.Cell.prototype.toJSON.apply(this);
281 var data = IPython.Cell.prototype.toJSON.apply(this);
282 data.cell_type = this.cell_type;
283 data.source = this.get_text();
282 data.source = this.get_text();
283 if (data.source == this.placeholder) {
284 data.source = "";
285 }
284 return data;
286 return data;
285 };
287 };
286
288
@@ -291,12 +293,10 b' var IPython = (function (IPython) {'
291 * @extends IPython.HTMLCell
293 * @extends IPython.HTMLCell
292 */
294 */
293 var MarkdownCell = function (options) {
295 var MarkdownCell = function (options) {
294 var options = options || {};
296 options = this.mergeopt(MarkdownCell, options);
295
296 options = this.mergeopt(MarkdownCell,options);
297 TextCell.apply(this, [options]);
298
297
299 this.cell_type = 'markdown';
298 this.cell_type = 'markdown';
299 TextCell.apply(this, [options]);
300 };
300 };
301
301
302 MarkdownCell.options_default = {
302 MarkdownCell.options_default = {
@@ -337,7 +337,7 b' var IPython = (function (IPython) {'
337 }
337 }
338 this.element.find('div.text_cell_input').hide();
338 this.element.find('div.text_cell_input').hide();
339 this.element.find("div.text_cell_render").show();
339 this.element.find("div.text_cell_render").show();
340 this.typeset()
340 this.typeset();
341 this.rendered = true;
341 this.rendered = true;
342 }
342 }
343 };
343 };
@@ -351,20 +351,21 b' var IPython = (function (IPython) {'
351 * @extends IPython.TextCell
351 * @extends IPython.TextCell
352 */
352 */
353 var RawCell = function (options) {
353 var RawCell = function (options) {
354
354 options = this.mergeopt(RawCell, options);
355 options = this.mergeopt(RawCell,options)
355
356 TextCell.apply(this, [options]);
357
358 this.cell_type = 'raw';
356 this.cell_type = 'raw';
357 TextCell.apply(this, [options]);
359
358
360 var that = this
359 var that = this;
361 this.element.focusout(
360 this.element.focusout(
362 function() { that.auto_highlight(); }
361 function() { that.auto_highlight(); }
363 );
362 );
364 };
363 };
365
364
366 RawCell.options_default = {
365 RawCell.options_default = {
367 placeholder : "Type plain text and LaTeX: $\\alpha^2$"
366 placeholder : "Write raw LaTeX or other formats here, for use with nbconvert.\n" +
367 "It will not be rendered in the notebook.\n" +
368 "When passing through nbconvert, a Raw Cell's content is added to the output unmodified."
368 };
369 };
369
370
370
371
@@ -382,7 +383,10 b' var IPython = (function (IPython) {'
382 /** @method render **/
383 /** @method render **/
383 RawCell.prototype.render = function () {
384 RawCell.prototype.render = function () {
384 this.rendered = true;
385 this.rendered = true;
385 this.edit();
386 var text = this.get_text();
387 if (text === "") { text = this.placeholder; }
388 console.log('rendering', text);
389 this.set_text(text);
386 };
390 };
387
391
388
392
@@ -415,8 +419,7 b' var IPython = (function (IPython) {'
415 /** @method select **/
419 /** @method select **/
416 RawCell.prototype.select = function () {
420 RawCell.prototype.select = function () {
417 IPython.Cell.prototype.select.apply(this);
421 IPython.Cell.prototype.select.apply(this);
418 this.code_mirror.refresh();
422 this.edit();
419 this.code_mirror.focus();
420 };
423 };
421
424
422 /** @method at_top **/
425 /** @method at_top **/
@@ -451,16 +454,16 b' var IPython = (function (IPython) {'
451 * @extends IPython.TextCell
454 * @extends IPython.TextCell
452 */
455 */
453 var HeadingCell = function (options) {
456 var HeadingCell = function (options) {
457 options = this.mergeopt(HeadingCell, options);
454
458
455 options = this.mergeopt(HeadingCell,options)
459 this.level = 1;
460 this.cell_type = 'heading';
456 TextCell.apply(this, [options]);
461 TextCell.apply(this, [options]);
457
462
458 /**
463 /**
459 * heading level of the cell, use getter and setter to access
464 * heading level of the cell, use getter and setter to access
460 * @property level
465 * @property level
461 */
466 */
462 this.level = 1;
463 this.cell_type = 'heading';
464 };
467 };
465
468
466 HeadingCell.options_default = {
469 HeadingCell.options_default = {
@@ -1,12 +1,10 b''
1 /* Css for the metadata edit area */
1 /* CSS for the cell toolbar */
2
3
2
4 .celltoolbar {
3 .celltoolbar {
5 border: thin solid #CFCFCF;
4 border: thin solid #CFCFCF;
6 border-bottom: none;
5 border-bottom: none;
7 background : #EEE;
6 background : #EEE;
8 border-top-right-radius: 3px;
7 border-radius : 3px 3px 0px 0px;
9 border-top-left-radius: 3px;
10 width:100%;
8 width:100%;
11 -webkit-box-pack: end;
9 -webkit-box-pack: end;
12 height:22px;
10 height:22px;
@@ -14,20 +12,6 b''
14 .reverse();
12 .reverse();
15 }
13 }
16
14
17
18 .no_input_radius {
19 border-top-right-radius: 0px;
20 border-top-left-radius: 0px;
21 }
22
23 .text_cell .ctb_prompt {
24 display: none;
25 }
26
27 .code_cell .ctb_prompt {
28 display: block;
29 }
30
31 .ctb_hideshow {
15 .ctb_hideshow {
32 display:none;
16 display:none;
33 vertical-align:bottom;
17 vertical-align:bottom;
@@ -38,41 +22,21 b''
38 padding-top: 0px;
22 padding-top: 0px;
39 }
23 }
40
24
41 .ctb_area {
42 margin:0;
43 padding:0;
44 width:100%;
45
25
46 }
26 /* ctb_show is added to the ctb_hideshow div to show the cell toolbar.
47
27 Cell toolbars are only shown when the ctb_global_show class is also set.
48
49 /*ctb_show is added to either body or the ctb_hideshow div to show
50 all or one cell's toolbars.
51 */
28 */
52 .ctb_show.ctb_hideshow, .ctb_show .ctb_hideshow {
29 .ctb_global_show .ctb_show.ctb_hideshow {
53 display:block;
30 display: block;
54 }
31 }
55
32
56 .ctb_show .input_area,
33 .ctb_global_show .ctb_show + .input_area,
57 .ctb_show .ctb_hideshow + div.text_cell_input {
34 .ctb_global_show .ctb_show + div.text_cell_input
35 {
58 border-top-right-radius: 0px;
36 border-top-right-radius: 0px;
59 border-top-left-radius: 0px;
37 border-top-left-radius: 0px;
60 }
38 }
61
39
62 .ctb_show > .celltoolbar {
63 border-bottom-right-radius: 0px;
64 border-bottom-left-radius: 0px;
65 }
66
67 .button_container {
68 margin-top:0;
69 margin-bottom:0;
70 }
71
72
73 .ui-button {
74 min-width:30px;
75 }
76 .celltoolbar .button_container select {
40 .celltoolbar .button_container select {
77 margin: 10px;
41 margin: 10px;
78 margin-top: 1px;
42 margin-top: 1px;
@@ -108,4 +72,5 b" all or one cell's toolbars."
108 border: none;
72 border: none;
109 vertical-align:top;
73 vertical-align:top;
110 height:20px;
74 height:20px;
75 min-width:30px;
111 }
76 }
@@ -1537,23 +1537,16 b' pre,code,kbd,samp{white-space:pre-wrap;}'
1537 #fonttest{font-family:monospace;}
1537 #fonttest{font-family:monospace;}
1538 p{margin-bottom:0;}
1538 p{margin-bottom:0;}
1539 .end_space{height:200px;}
1539 .end_space{height:200px;}
1540 .celltoolbar{border:thin solid #CFCFCF;border-bottom:none;background:#EEE;border-top-right-radius:3px;border-top-left-radius:3px;width:100%;-webkit-box-pack:end;height:22px;display:-webkit-box;-webkit-box-orient:horizontal;-webkit-box-align:stretch;display:-moz-box;-moz-box-orient:horizontal;-moz-box-align:stretch;display:box;box-orient:horizontal;box-align:stretch;-webkit-box-direction:reverse;-moz-box-direction:reverse;box-direction:reverse;}
1540 .celltoolbar{border:thin solid #CFCFCF;border-bottom:none;background:#EEE;border-radius:3px 3px 0px 0px;width:100%;-webkit-box-pack:end;height:22px;display:-webkit-box;-webkit-box-orient:horizontal;-webkit-box-align:stretch;display:-moz-box;-moz-box-orient:horizontal;-moz-box-align:stretch;display:box;box-orient:horizontal;box-align:stretch;-webkit-box-direction:reverse;-moz-box-direction:reverse;box-direction:reverse;}
1541 .no_input_radius{border-top-right-radius:0px;border-top-left-radius:0px;}
1542 .text_cell .ctb_prompt{display:none;}
1543 .code_cell .ctb_prompt{display:block;}
1544 .ctb_hideshow{display:none;vertical-align:bottom;padding-right:2px;}
1541 .ctb_hideshow{display:none;vertical-align:bottom;padding-right:2px;}
1545 .celltoolbar>div{padding-top:0px;}
1542 .celltoolbar>div{padding-top:0px;}
1546 .ctb_area{margin:0;padding:0;width:100%;}
1543 .ctb_global_show .ctb_show.ctb_hideshow{display:block;}
1547 .ctb_show.ctb_hideshow,.ctb_show .ctb_hideshow{display:block;}
1544 .ctb_global_show .ctb_show+.input_area,.ctb_global_show .ctb_show+div.text_cell_input{border-top-right-radius:0px;border-top-left-radius:0px;}
1548 .ctb_show .input_area,.ctb_show .ctb_hideshow+div.text_cell_input{border-top-right-radius:0px;border-top-left-radius:0px;}
1549 .ctb_show>.celltoolbar{border-bottom-right-radius:0px;border-bottom-left-radius:0px;}
1550 .button_container{margin-top:0;margin-bottom:0;}
1551 .ui-button{min-width:30px;}
1552 .celltoolbar .button_container select{margin:10px;margin-top:1px;margin-bottom:0px;padding:0;font-size:87%;width:auto;display:inline-block;height:18px;line-height:18px;vertical-align:top;}
1545 .celltoolbar .button_container select{margin:10px;margin-top:1px;margin-bottom:0px;padding:0;font-size:87%;width:auto;display:inline-block;height:18px;line-height:18px;vertical-align:top;}
1553 .celltoolbar label{display:inline-block;height:15px;line-height:15px;vertical-align:top;}
1546 .celltoolbar label{display:inline-block;height:15px;line-height:15px;vertical-align:top;}
1554 .celltoolbar label span{font-size:85%;}
1547 .celltoolbar label span{font-size:85%;}
1555 .celltoolbar input[type=checkbox]{margin:0px;margin-left:4px;margin-right:4px;}
1548 .celltoolbar input[type=checkbox]{margin:0px;margin-left:4px;margin-right:4px;}
1556 .celltoolbar .ui-button{border:none;vertical-align:top;height:20px;}
1549 .celltoolbar .ui-button{border:none;vertical-align:top;height:20px;min-width:30px;}
1557 .completions{position:absolute;z-index:10;overflow:hidden;border:1px solid #ababab;border-radius:4px;-webkit-box-shadow:0px 6px 10px -1px #adadad;-moz-box-shadow:0px 6px 10px -1px #adadad;box-shadow:0px 6px 10px -1px #adadad;}
1550 .completions{position:absolute;z-index:10;overflow:hidden;border:1px solid #ababab;border-radius:4px;-webkit-box-shadow:0px 6px 10px -1px #adadad;-moz-box-shadow:0px 6px 10px -1px #adadad;box-shadow:0px 6px 10px -1px #adadad;}
1558 .completions select{background:white;outline:none;border:none;padding:0px;margin:0px;overflow:auto;font-family:monospace;font-size:110%;color:#000000;}
1551 .completions select{background:white;outline:none;border:none;padding:0px;margin:0px;overflow:auto;font-family:monospace;font-size:110%;color:#000000;}
1559 .completions select option.context{color:#0064cd;}
1552 .completions select option.context{color:#0064cd;}
@@ -157,8 +157,8 b' class="notebook_app"'
157 title="Contents will be rendered as HTML and serve as explanatory text">
157 title="Contents will be rendered as HTML and serve as explanatory text">
158 <a href="#">Markdown</a></li>
158 <a href="#">Markdown</a></li>
159 <li id="to_raw"
159 <li id="to_raw"
160 title="Contents will display unmodified in a fixed-width font">
160 title="Contents will pass through nbconvert unmodified">
161 <a href="#">Raw Text</a></li>
161 <a href="#">Raw NBConvert</a></li>
162 <li id="to_heading1"><a href="#">Heading 1</a></li>
162 <li id="to_heading1"><a href="#">Heading 1</a></li>
163 <li id="to_heading2"><a href="#">Heading 2</a></li>
163 <li id="to_heading2"><a href="#">Heading 2</a></li>
164 <li id="to_heading3"><a href="#">Heading 3</a></li>
164 <li id="to_heading3"><a href="#">Heading 3</a></li>
@@ -297,6 +297,7 b' class="notebook_app"'
297 <script src="{{ static_url("notebook/js/contexthint.js") }}" charset="utf-8"></script>
297 <script src="{{ static_url("notebook/js/contexthint.js") }}" charset="utf-8"></script>
298
298
299 <script src="{{ static_url("notebook/js/celltoolbarpresets/default.js") }}" type="text/javascript" charset="utf-8"></script>
299 <script src="{{ static_url("notebook/js/celltoolbarpresets/default.js") }}" type="text/javascript" charset="utf-8"></script>
300 <script src="{{ static_url("notebook/js/celltoolbarpresets/rawcell.js") }}" type="text/javascript" charset="utf-8"></script>
300 <script src="{{ static_url("notebook/js/celltoolbarpresets/slideshow.js") }}" type="text/javascript" charset="utf-8"></script>
301 <script src="{{ static_url("notebook/js/celltoolbarpresets/slideshow.js") }}" type="text/javascript" charset="utf-8"></script>
301
302
302 {% endblock %}
303 {% endblock %}
@@ -1,5 +1,5 b''
1 """This module defines Exporter, a highly configurable converter
1 """This module defines a base Exporter class. For Jinja template-based export,
2 that uses Jinja2 to export notebook files into different formats.
2 see templateexporter.py.
3 """
3 """
4
4
5 #-----------------------------------------------------------------------------
5 #-----------------------------------------------------------------------------
@@ -1,6 +1,4 b''
1 """
1 """HTML Exporter class"""
2 Exporter that exports Basic HTML.
3 """
4
2
5 #-----------------------------------------------------------------------------
3 #-----------------------------------------------------------------------------
6 # Copyright (c) 2013, the IPython Development Team.
4 # Copyright (c) 2013, the IPython Development Team.
@@ -40,7 +38,10 b' class HTMLExporter(TemplateExporter):'
40
38
41 default_template = Unicode('full', config=True, help="""Flavor of the data
39 default_template = Unicode('full', config=True, help="""Flavor of the data
42 format to use. I.E. 'full' or 'basic'""")
40 format to use. I.E. 'full' or 'basic'""")
43
41
42 def _raw_mimetype_default(self):
43 return 'text/html'
44
44 @property
45 @property
45 def default_config(self):
46 def default_config(self):
46 c = Config({
47 c = Config({
@@ -1,9 +1,5 b''
1 """
1 """LaTeX Exporter class"""
2 Exporter that allows Latex Jinja templates to work. Contains logic to
2
3 appropriately prepare IPYNB files for export to LaTeX. Including but
4 not limited to escaping LaTeX, fixing math region tags, using special
5 tags to circumvent Jinja/Latex syntax conflicts.
6 """
7 #-----------------------------------------------------------------------------
3 #-----------------------------------------------------------------------------
8 # Copyright (c) 2013, the IPython Development Team.
4 # Copyright (c) 2013, the IPython Development Team.
9 #
5 #
@@ -67,6 +63,9 b' class LatexExporter(TemplateExporter):'
67 #Extension that the template files use.
63 #Extension that the template files use.
68 template_extension = Unicode(".tplx", config=True)
64 template_extension = Unicode(".tplx", config=True)
69
65
66 def _raw_mimetype_default(self):
67 return 'text/latex'
68
70
69
71 @property
70 @property
72 def default_config(self):
71 def default_config(self):
@@ -1,6 +1,5 b''
1 """
1 """Markdown Exporter class"""
2 Exporter that will export your ipynb to Markdown.
2
3 """
4 #-----------------------------------------------------------------------------
3 #-----------------------------------------------------------------------------
5 # Copyright (c) 2013, the IPython Development Team.
4 # Copyright (c) 2013, the IPython Development Team.
6 #
5 #
@@ -31,6 +30,12 b' class MarkdownExporter(TemplateExporter):'
31 'md', config=True,
30 'md', config=True,
32 help="Extension of the file that should be written to disk")
31 help="Extension of the file that should be written to disk")
33
32
33 def _raw_mimetype_default(self):
34 return 'text/markdown'
35
36 def _raw_mimetypes_default(self):
37 return ['text/markdown', 'text/html']
38
34 @property
39 @property
35 def default_config(self):
40 def default_config(self):
36 c = Config({'ExtractOutputPreprocessor':{'enabled':True}})
41 c = Config({'ExtractOutputPreprocessor':{'enabled':True}})
@@ -1,6 +1,5 b''
1 """
1 """Python script Exporter class"""
2 Python exporter which exports Notebook code into a PY file.
2
3 """
4 #-----------------------------------------------------------------------------
3 #-----------------------------------------------------------------------------
5 # Copyright (c) 2013, the IPython Development Team.
4 # Copyright (c) 2013, the IPython Development Team.
6 #
5 #
@@ -29,3 +28,7 b' class PythonExporter(TemplateExporter):'
29 file_extension = Unicode(
28 file_extension = Unicode(
30 'py', config=True,
29 'py', config=True,
31 help="Extension of the file that should be written to disk")
30 help="Extension of the file that should be written to disk")
31
32 def _raw_mimetype_default(self):
33 return 'application/x-python'
34
@@ -1,6 +1,5 b''
1 """
1 """restructuredText Exporter class"""
2 Exporter for exporting notebooks to restructured text.
2
3 """
4 #-----------------------------------------------------------------------------
3 #-----------------------------------------------------------------------------
5 # Copyright (c) 2013, the IPython Development Team.
4 # Copyright (c) 2013, the IPython Development Team.
6 #
5 #
@@ -31,6 +30,9 b' class RSTExporter(TemplateExporter):'
31 'rst', config=True,
30 'rst', config=True,
32 help="Extension of the file that should be written to disk")
31 help="Extension of the file that should be written to disk")
33
32
33 def _raw_mimetype_default(self):
34 return 'text/restructuredtext'
35
34 @property
36 @property
35 def default_config(self):
37 def default_config(self):
36 c = Config({'ExtractOutputPreprocessor':{'enabled':True}})
38 c = Config({'ExtractOutputPreprocessor':{'enabled':True}})
@@ -1,6 +1,4 b''
1 """
1 """HTML slide show Exporter class"""
2 Contains slide show exporter
3 """
4
2
5 #-----------------------------------------------------------------------------
3 #-----------------------------------------------------------------------------
6 # Copyright (c) 2013, the IPython Development Team.
4 # Copyright (c) 2013, the IPython Development Team.
@@ -19,16 +17,14 b' from IPython.utils.traitlets import Unicode'
19 from IPython.nbconvert import preprocessors
17 from IPython.nbconvert import preprocessors
20 from IPython.config import Config
18 from IPython.config import Config
21
19
22 from .templateexporter import TemplateExporter
20 from .html import HTMLExporter
23
21
24 #-----------------------------------------------------------------------------
22 #-----------------------------------------------------------------------------
25 # Classes
23 # Classes
26 #-----------------------------------------------------------------------------
24 #-----------------------------------------------------------------------------
27
25
28 class SlidesExporter(TemplateExporter):
26 class SlidesExporter(HTMLExporter):
29 """
27 """Exports HTML slides with reveal.js"""
30 Exports slides
31 """
32
28
33 file_extension = Unicode(
29 file_extension = Unicode(
34 'slides.html', config=True,
30 'slides.html', config=True,
@@ -41,15 +37,9 b' class SlidesExporter(TemplateExporter):'
41 @property
37 @property
42 def default_config(self):
38 def default_config(self):
43 c = Config({
39 c = Config({
44 'CSSHTMLHeaderPreprocessor':{
40 'RevealHelpPreprocessor': {
45 'enabled':True
41 'enabled': True,
46 },
42 },
47 'RevealHelpPreprocessor':{
48 'enabled':True,
49 },
50 'HighlightMagicsPreprocessor': {
51 'enabled':True
52 }
53 })
43 })
54 c.merge(super(SlidesExporter,self).default_config)
44 c.merge(super(SlidesExporter,self).default_config)
55 return c
45 return c
@@ -1,4 +1,4 b''
1 """This module defines Exporter, a highly configurable converter
1 """This module defines TemplateExporter, a highly configurable converter
2 that uses Jinja2 to export notebook files into different formats.
2 that uses Jinja2 to export notebook files into different formats.
3 """
3 """
4
4
@@ -126,6 +126,13 b' class TemplateExporter(Exporter):'
126 help="""Dictionary of filters, by name and namespace, to add to the Jinja
126 help="""Dictionary of filters, by name and namespace, to add to the Jinja
127 environment.""")
127 environment.""")
128
128
129 raw_mimetype = Unicode('')
130 raw_mimetypes = List(config=True,
131 help="""formats of raw cells to be included in this Exporter's output."""
132 )
133 def _raw_mimetypes_default(self):
134 return [self.raw_mimetype]
135
129
136
130 def __init__(self, config=None, extra_loaders=None, **kw):
137 def __init__(self, config=None, extra_loaders=None, **kw):
131 """
138 """
@@ -202,6 +209,8 b' class TemplateExporter(Exporter):'
202 preprocessors and filters.
209 preprocessors and filters.
203 """
210 """
204 nb_copy, resources = super(TemplateExporter, self).from_notebook_node(nb, resources, **kw)
211 nb_copy, resources = super(TemplateExporter, self).from_notebook_node(nb, resources, **kw)
212 resources.setdefault('raw_mimetype', self.raw_mimetype)
213 resources.setdefault('raw_mimetypes', self.raw_mimetypes)
205
214
206 self._load_template()
215 self._load_template()
207
216
@@ -1,6 +1,4 b''
1 """
1 """Base TestCase class for testing Exporters"""
2 Module with tests base for exporters
3 """
4
2
5 #-----------------------------------------------------------------------------
3 #-----------------------------------------------------------------------------
6 # Copyright (c) 2013, the IPython Development Team.
4 # Copyright (c) 2013, the IPython Development Team.
@@ -16,15 +14,41 b' Module with tests base for exporters'
16
14
17 import os
15 import os
18
16
17 from IPython.testing.decorators import onlyif_cmds_exist
18
19 from ...tests.base import TestsBase
19 from ...tests.base import TestsBase
20
20
21 #-----------------------------------------------------------------------------
21 #-----------------------------------------------------------------------------
22 # Class
22 # Class
23 #-----------------------------------------------------------------------------
23 #-----------------------------------------------------------------------------
24
24
25 all_raw_mimetypes = {
26 'application/x-python',
27 'text/markdown',
28 'text/html',
29 'text/restructuredtext',
30 'text/latex',
31 }
32
25 class ExportersTestsBase(TestsBase):
33 class ExportersTestsBase(TestsBase):
26 """Contains base test functions for exporters"""
34 """Contains base test functions for exporters"""
27
35
28 def _get_notebook(self):
36 exporter_class = None
29 return os.path.join(self._get_files_path(), 'notebook2.ipynb')
37 should_include_raw = None
30
38
39 def _get_notebook(self, nb_name='notebook2.ipynb'):
40 return os.path.join(self._get_files_path(), nb_name)
41
42 @onlyif_cmds_exist('pandoc')
43 def test_raw_cell_inclusion(self):
44 """test raw cell inclusion based on raw_mimetype metadata"""
45 if self.should_include_raw is None:
46 return
47 exporter = self.exporter_class()
48 (output, resources) = exporter.from_filename(self._get_notebook('rawtest.ipynb'))
49 for inc in self.should_include_raw:
50 self.assertIn('raw %s' % inc, output, "should include %s" % inc)
51 self.assertIn('no raw_mimetype metadata', output)
52 for exc in all_raw_mimetypes.difference(self.should_include_raw):
53 self.assertNotIn('raw %s' % exc, output, "should exclude %s" % exc)
54 self.assertNotIn('never be included', output)
@@ -1,6 +1,4 b''
1 """
1 """Tests for HTMLExporter"""
2 Module with tests for html.py
3 """
4
2
5 #-----------------------------------------------------------------------------
3 #-----------------------------------------------------------------------------
6 # Copyright (c) 2013, the IPython Development Team.
4 # Copyright (c) 2013, the IPython Development Team.
@@ -23,7 +21,10 b' from IPython.testing.decorators import onlyif_cmds_exist'
23 #-----------------------------------------------------------------------------
21 #-----------------------------------------------------------------------------
24
22
25 class TestHTMLExporter(ExportersTestsBase):
23 class TestHTMLExporter(ExportersTestsBase):
26 """Contains test functions for html.py"""
24 """Tests for HTMLExporter"""
25
26 exporter_class = HTMLExporter
27 should_include_raw = ['html']
27
28
28 def test_constructor(self):
29 def test_constructor(self):
29 """
30 """
@@ -57,3 +58,4 b' class TestHTMLExporter(ExportersTestsBase):'
57 """
58 """
58 (output, resources) = HTMLExporter(template_file='full').from_filename(self._get_notebook())
59 (output, resources) = HTMLExporter(template_file='full').from_filename(self._get_notebook())
59 assert len(output) > 0
60 assert len(output) > 0
61
@@ -25,6 +25,9 b' from IPython.testing.decorators import onlyif_cmds_exist'
25 class TestLatexExporter(ExportersTestsBase):
25 class TestLatexExporter(ExportersTestsBase):
26 """Contains test functions for latex.py"""
26 """Contains test functions for latex.py"""
27
27
28 exporter_class = LatexExporter
29 should_include_raw = ['latex']
30
28 def test_constructor(self):
31 def test_constructor(self):
29 """
32 """
30 Can a LatexExporter be constructed?
33 Can a LatexExporter be constructed?
@@ -1,6 +1,4 b''
1 """
1 """Tests for MarkdownExporter"""
2 Module with tests for markdown.py
3 """
4
2
5 #-----------------------------------------------------------------------------
3 #-----------------------------------------------------------------------------
6 # Copyright (c) 2013, the IPython Development Team.
4 # Copyright (c) 2013, the IPython Development Team.
@@ -22,7 +20,10 b' from ..markdown import MarkdownExporter'
22 #-----------------------------------------------------------------------------
20 #-----------------------------------------------------------------------------
23
21
24 class TestMarkdownExporter(ExportersTestsBase):
22 class TestMarkdownExporter(ExportersTestsBase):
25 """Contains test functions for markdown.py"""
23 """Tests for MarkdownExporter"""
24
25 exporter_class = MarkdownExporter
26 should_include_raw = ['markdown', 'html']
26
27
27 def test_constructor(self):
28 def test_constructor(self):
28 """
29 """
@@ -1,6 +1,4 b''
1 """
1 """Tests for PythonExporter"""
2 Module with tests for python.py
3 """
4
2
5 #-----------------------------------------------------------------------------
3 #-----------------------------------------------------------------------------
6 # Copyright (c) 2013, the IPython Development Team.
4 # Copyright (c) 2013, the IPython Development Team.
@@ -22,7 +20,10 b' from ..python import PythonExporter'
22 #-----------------------------------------------------------------------------
20 #-----------------------------------------------------------------------------
23
21
24 class TestPythonExporter(ExportersTestsBase):
22 class TestPythonExporter(ExportersTestsBase):
25 """Contains test functions for python.py"""
23 """Tests for PythonExporter"""
24
25 exporter_class = PythonExporter
26 should_include_raw = ['python']
26
27
27 def test_constructor(self):
28 def test_constructor(self):
28 """
29 """
@@ -1,6 +1,4 b''
1 """
1 """Tests for RSTExporter"""
2 Module with tests for rst.py
3 """
4
2
5 #-----------------------------------------------------------------------------
3 #-----------------------------------------------------------------------------
6 # Copyright (c) 2013, the IPython Development Team.
4 # Copyright (c) 2013, the IPython Development Team.
@@ -23,7 +21,10 b' from IPython.testing.decorators import onlyif_cmds_exist'
23 #-----------------------------------------------------------------------------
21 #-----------------------------------------------------------------------------
24
22
25 class TestRSTExporter(ExportersTestsBase):
23 class TestRSTExporter(ExportersTestsBase):
26 """Contains test functions for rst.py"""
24 """Tests for RSTExporter"""
25
26 exporter_class = RSTExporter
27 should_include_raw = ['rst']
27
28
28 def test_constructor(self):
29 def test_constructor(self):
29 """
30 """
@@ -1,6 +1,4 b''
1 """
1 """Tests for SlidesExporter"""
2 Module with tests for slides.py
3 """
4
2
5 #-----------------------------------------------------------------------------
3 #-----------------------------------------------------------------------------
6 # Copyright (c) 2013, the IPython Development Team.
4 # Copyright (c) 2013, the IPython Development Team.
@@ -23,7 +21,10 b' from IPython.testing.decorators import onlyif_cmds_exist'
23 #-----------------------------------------------------------------------------
21 #-----------------------------------------------------------------------------
24
22
25 class TestSlidesExporter(ExportersTestsBase):
23 class TestSlidesExporter(ExportersTestsBase):
26 """Contains test functions for slides.py"""
24 """Tests for SlidesExporter"""
25
26 exporter_class = SlidesExporter
27 should_include_raw = ['html']
27
28
28 def test_constructor(self):
29 def test_constructor(self):
29 """
30 """
@@ -65,10 +65,6 b' In&nbsp;[{{ cell.prompt_number }}]:'
65 </div>
65 </div>
66 {% endblock headingcell %}
66 {% endblock headingcell %}
67
67
68 {% block rawcell scoped %}
69 {{ cell.source }}
70 {% endblock rawcell %}
71
72 {% block unknowncell scoped %}
68 {% block unknowncell scoped %}
73 unknown type {{ cell.type }}
69 unknown type {{ cell.type }}
74 {% endblock unknowncell %}
70 {% endblock unknowncell %}
@@ -218,11 +218,6 b' This template does not define a docclass, the inheriting class must define this.'
218 ((( cell.source | citation2latex | markdown2latex )))
218 ((( cell.source | citation2latex | markdown2latex )))
219 ((* endblock markdowncell *))
219 ((* endblock markdowncell *))
220
220
221 % Spit out the contents of raw cells unmodified
222 ((* block rawcell scoped *))
223 ((( cell.source )))
224 ((* endblock rawcell *))
225
226 % Don't display unknown types
221 % Don't display unknown types
227 ((* block unknowncell scoped *))
222 ((* block unknowncell scoped *))
228 ((* endblock unknowncell *))
223 ((* endblock unknowncell *))
@@ -80,7 +80,10 b' consider calling super even if it is a leave block, we might insert more blocks '
80 ((*- block headingcell scoped-*))
80 ((*- block headingcell scoped-*))
81 ((*- endblock headingcell -*))
81 ((*- endblock headingcell -*))
82 ((*- elif cell.cell_type in ['raw'] -*))
82 ((*- elif cell.cell_type in ['raw'] -*))
83 ((*- block rawcell scoped-*))
83 ((*- block rawcell scoped -*))
84 ((* if cell.metadata.get('raw_mimetype', resources.get('raw_mimetype')) == resources.get('raw_mimetype') *))
85 ((( cell.source )))
86 ((* endif *))
84 ((*- endblock rawcell -*))
87 ((*- endblock rawcell -*))
85 ((*- else -*))
88 ((*- else -*))
86 ((*- block unknowncell scoped-*))
89 ((*- block unknowncell scoped-*))
@@ -63,10 +63,6 b''
63 {{ '#' * cell.level }} {{ cell.source | replace('\n', ' ') }}
63 {{ '#' * cell.level }} {{ cell.source | replace('\n', ' ') }}
64 {% endblock headingcell %}
64 {% endblock headingcell %}
65
65
66 {% block rawcell scoped %}
67 {{ cell.source }}
68 {% endblock rawcell %}
69
70 {% block unknowncell scoped %}
66 {% block unknowncell scoped %}
71 unknown type {{ cell.type }}
67 unknown type {{ cell.type }}
72 {% endblock unknowncell %} No newline at end of file
68 {% endblock unknowncell %}
@@ -46,10 +46,6 b' it introduces a new line'
46 {{ '#' * cell.level }}{{ cell.source | replace('\n', ' ') | comment_lines }}
46 {{ '#' * cell.level }}{{ cell.source | replace('\n', ' ') | comment_lines }}
47 {% endblock headingcell %}
47 {% endblock headingcell %}
48
48
49 {% block rawcell scoped %}
50 {{ cell.source | comment_lines }}
51 {% endblock rawcell %}
52
53 {% block unknowncell scoped %}
49 {% block unknowncell scoped %}
54 unknown type {{ cell.type }}
50 unknown type {{ cell.type }}
55 {% endblock unknowncell %} No newline at end of file
51 {% endblock unknowncell %}
@@ -75,10 +75,6 b''
75 {{ ("#" * cell.level + cell.source) | replace('\n', ' ') | markdown2rst }}
75 {{ ("#" * cell.level + cell.source) | replace('\n', ' ') | markdown2rst }}
76 {% endblock headingcell %}
76 {% endblock headingcell %}
77
77
78 {% block rawcell scoped %}
79 {{ cell.source }}
80 {% endblock rawcell %}
81
82 {% block unknowncell scoped %}
78 {% block unknowncell scoped %}
83 unknown type {{cell.type}}
79 unknown type {{cell.type}}
84 {% endblock unknowncell %}
80 {% endblock unknowncell %}
@@ -76,7 +76,10 b' consider calling super even if it is a leave block, we might insert more blocks '
76 {%- block headingcell scoped-%}
76 {%- block headingcell scoped-%}
77 {%- endblock headingcell -%}
77 {%- endblock headingcell -%}
78 {%- elif cell.cell_type in ['raw'] -%}
78 {%- elif cell.cell_type in ['raw'] -%}
79 {%- block rawcell scoped-%}
79 {%- block rawcell scoped -%}
80 {% if cell.metadata.get('raw_mimetype', resources.get('raw_mimetype', '')).lower() in resources.get('raw_mimetypes', ['']) %}
81 {{ cell.source }}
82 {% endif %}
80 {%- endblock rawcell -%}
83 {%- endblock rawcell -%}
81 {%- else -%}
84 {%- else -%}
82 {%- block unknowncell scoped-%}
85 {%- block unknowncell scoped-%}
General Comments 0
You need to be logged in to leave comments. Login now